sarpy icon indicating copy to clipboard operation
sarpy copied to clipboard

Support reading CF8 CPHDs with an AmpSF PVP

Open pressler-vsc opened this issue 1 year ago • 1 comments

SarPy's CPHD reader currently errors out when attempting to open a CF8-valued CPHD that contains an AmpSF PVP:

>>> import sarpy.io.phase_history.converter
>>> sarpy.io.phase_history.converter.open_phase_history('/data/cf8_with_ampsf.cphd')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/vscuser/git/glweb/software/third-party/sarpy/sarpy/io/phase_history/converter.py", line 79, in open_phase_history
    reader = opener(file_name)
             ^^^^^^^^^^^^^^^^^
  File "/home/vscuser/git/glweb/software/third-party/sarpy/sarpy/io/phase_history/cphd.py", line 1011, in is_a
    return CPHDReader(cphd_details)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscuser/git/glweb/software/third-party/sarpy/sarpy/io/phase_history/cphd.py", line 519, in __init__
    data_segments = self._create_data_segments()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscuser/git/glweb/software/third-party/sarpy/sarpy/io/phase_history/cphd.py", line 564, in _create_data_segments
    format_function = AmpScalingFunction(raw_dtype, amplitude_scaling=amp_sf)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscuser/git/glweb/software/third-party/sarpy/sarpy/io/phase_history/cphd.py", line 78, in __init__
    self.set_amplitude_scaling(amplitude_scaling)
  File "/home/vscuser/git/glweb/software/third-party/sarpy/sarpy/io/phase_history/cphd.py", line 126, in set_amplitude_scaling
    raise ValueError(
ValueError: A scaling multiplier has been supplied,
        but the raw datatype is not `int8` or `int16`.

This documented limitation is not a limitation of the CPHD spec (e.g. from NGA.STND.0068-1_1.1.0_CPHD, pg. 25):

image

SarPy should support reading these CPHDs.

pressler-vsc avatar Oct 27 '23 18:10 pressler-vsc

I as well would please want SarPy to support this

eleehiga avatar Nov 15 '23 19:11 eleehiga