General open and conversion methods (sarpy.io.complex.converter)

This module provide utilities for converting from any complex format that we can read to SICD or SIO format. The same conversion utility can be used to subset data.

sarpy.io.complex.converter.register_opener(open_func: Callable) None

Provide a new opener.

Parameters:

open_func (callable) – This is required to be a function which takes a single argument (file name). This function should return a sarpy.io.complex.base.SICDTypeReader instance if the referenced file is viable for the underlying type, and None otherwise.

Return type:

None

sarpy.io.complex.converter.parse_openers() None

Automatically find the viable openers (i.e. is_a()) in the various modules.

sarpy.io.complex.converter.open_complex(file_name: str | BinaryIO) SICDTypeReader

Given a file, try to find and return the appropriate reader object.

Parameters:

file_name (str|BinaryIO) –

Return type:

SICDTypeReader

Raises:

SarpyIOError

class sarpy.io.complex.converter.Converter(reader, output_directory, output_file=None, frame=None, row_limits=None, col_limits=None, output_format='SICD', check_older_version=False, check_existence=True)

Bases: object

This is a class for conversion (of a single frame) of one complex format to SICD or SIO format. Another use case is to create a (contiguous) subset of a given complex dataset. This class is intended to be used as a context manager.

property writer: SICDWriter | SIOWriter

The writer instance.

Type:

SICDWriter|SIOWriter

write_data(max_block_size=None)

Assuming that the desired changes have been made to the writer instance nitf header tags, write the data.

Parameters:

max_block_size (None|int) – (nominal) maximum block size in bytes. Minimum value is \(2^{20} = 1~\text{MB}\). Default value is \(2^{26} = 64~\text{MB}\).

Return type:

None

sarpy.io.complex.converter.conversion_utility(input_file, output_directory, output_files=None, frames=None, output_format='SICD', row_limits=None, column_limits=None, max_block_size=None, check_older_version=False, preserve_nitf_information=False, check_existence=True, dem_filename_pattern=None, dem_type=None, geoid_file=None)

Copy SAR complex data to a file of the specified format.

Parameters:
  • input_file (str|SICDTypeReader) – Reader instance, or the name of file to convert.

  • output_directory (str) – The output directory. This must exist.

  • output_files (None|str|List[str]) – The name of the output file(s), or list of output files matching frames. If not provided, then sicd.get_suggested_name(frame) will be used.

  • frames (None|int|list) – Set of frames to convert. Default is all.

  • output_format (str) – The output file format to write, from {‘SICD’, ‘SIO’}, optional. Default is SICD.

  • row_limits (None|Tuple[int, int]|List[Tuple[int, int]]) – Rows start/stop. Default is all.

  • column_limits (None|Tuple[int, int]|List[Tuple[int, int]]) – Columns start/stop. Default is all.

  • max_block_size (None|int) – (nominal) maximum block size in bytes. Passed through to the Converter class.

  • check_older_version (bool) – Try to use a less recent version of SICD (1.1), for possible application compliance issues?

  • preserve_nitf_information (bool) – Try to preserve NITF information? This only applies in the case that the file being read is actually a NITF file.

  • check_existence (bool) – Check for the existence of any possibly overwritten file?

  • dem_filename_pattern (str | None) – Optional string specifying a Digital Elevation Model (DEM) filename pattern. This is a format string that specifies a glob pattern that will uniquely specify a DEM file from the Lat/Lon of the SW corner of the DEM tile. See the utils/convert_to_sicd help text for more details.

  • dem_type (str | None) – Optional DEM type (‘GeoTIFF’, ‘GeoTIFF:WGS84’, ‘GeoTIFF:EGM2008’, etc.). This parameter is required when dem_filename_pattern is specified. For ‘GeoTIFF’ DEM files, the reference surface can be either WGS84 or any of the geoid models. The reference surface is appended to the DEM type with a ‘:’ separator. If the reference surface is not specified, then EGM2008 is assumed.

  • geoid_file (str | None) – Optional Geoid file which might be needed when dem_filename_pattern is specified.

Return type:

None