Image/Data Reading

The basics for complex format data reading is presented in the first example. This builds on that example, and presents more details for other reader types.

Reader Confusion

In sarpy, the readers for different image types are generally implemented in one of the subpackages:

  • sarpy.io.complex - for complex images directly analogous to SICD format

  • sarpy.io.product - for standard image derived products like SIDD and WBID

  • sarpy.io.phase_history - for CPHD images/data

  • sarpy.io.received - for CRSD images/data

Each of these subpackages contains an open() function (aliased from the converter module), which should open eligible files of ONLY their given type. For example, the sarpy.io.complex.open() function will open a SICD or SLC products from Cosmo Skymed, RadarSat, Sentinel, etc, but will not open a SIDD/WBID, CPHD, CRSD, or general NITF file which isn’t analogous to a SICD.

SICD-Type Readers

As generally outlined in the first example, the complex format readers are all shaped to be directly analogous for a SICD reader. The readers are all defined in the sarpy.io.complex subpackage.

The general opening method is defined as sarpy.io.complex.converter.open_complex(), with basic usage as indicated by the below example.

from sarpy.io.complex.converter import open_complex

reader = open_complex('<path to file>')

print('reader type = {}'.format(type(reader)))  # see the explicit reader type

print('image size = {}'.format(reader.data_size))
print('image size as tuple = {}'.format(reader.get_data_size_as_tuple()))

Any reader returned by this function should be an extension of the class sarpy.io.complex.base.SICDTypeReader.

Some basic properties:

Derived Product (SIDD-Type) Readers

Derived products, like WBID or SIDD files, have readers defined in the sarpy.io.product subpackage. Such products are expected to be explicitly images derived from a SICD type file, and processed to a standard (likely 8-bit) image for viewing/interpreting by a human user.

The general opening method is defined as sarpy.io.product.converter.open_product(), with basic usage as indicated by

from sarpy.io.product.converter import open_product
reader = open_product('< path to file>')

print('reader type = {}'.format(type(reader)))  # see the explicit reader type

print('image size = {}'.format(reader.data_size))
print('image size as tuple = {}'.format(reader.get_data_size_as_tuple()))

Any reader retruned by this function should be an extension of the class sarpy.io.product.base.SIDDTypeReader.

Some basic properties:

Phase History (CPHD) Readers

The Compensated Phase History Data (CPHD) have readers defined in the sarpy.io.phase_history subpackage. The standard for CPHD version 0.3 is significantly different than the standard for version 1.0, and separate readers for version 0.3 (sarpy.io.phase_history.cphd.CPHDReader0_3) and for version 1.0 (sarpy.io.phase_history.cphd.CPHDReader1_0) are implemented for each; both of which extend the common abstract parent given in sarpy.io.phase_history.cphd.CPHDReader.

The general opening method is defined as sarpy.io.phase_history.converter.open_phase_history(), with basic usage as indicated by

from sarpy.io.phase_history.converter import open_phase_history
reader = open_phase_history('< path to file>')

print('reader type = {}'.format(type(reader)))  # see the explicit reader type

print('image size = {}'.format(reader.data_size))
print('image size as tuple = {}'.format(reader.get_data_size_as_tuple()))

Any reader returned by the function will be an extension of the class sarpy.io.phase_history.base.CPHDTypeReader.

Some basic properties:

Received Signal Data (CRSD) Readers

The Compensated Received Signal Data (CRSD) have readers defined in the sarpy.io.received subpackage. The general opening method is defined as sarpy.io.received.converter.open_received(), with basic usage as indicated by

from sarpy.io.received.converter import open_received
reader = open_received('< path to file>')

print('reader type = {}'.format(type(reader)))  # see the explicit reader type

print('image size = {}'.format(reader.data_size))
print('image size as tuple = {}'.format(reader.get_data_size_as_tuple()))

Any reader returned by the function will be an extension of the class sarpy.io.received.base.CRSDTypeReader.

Some basic properties:

NITF Option of Last Resort

Some support for general NITF file (not SICD, SIDD, or some radar specific format) opening provided in the sarpy.io.general subpackage. This is certainly not fully fledged support for every type of NITF, particularly for reading compressed image data.

The commandline utility defined in sarpy.utils.nitf_utils may be very useful for a variety of metadata extraction purposes.