Common SICD-Type objects (sarpy.io.complex.base)

Base common features for complex readers

class sarpy.io.complex.base.SICDTypeReader(data_segment: None | DataSegment | Sequence[DataSegment], sicd_meta: None | SICDType | Sequence[SICDType], close_segments: bool = True, delete_files: None | str | Sequence[str] = None)

Bases: BaseReader

A class for ensuring common SICD reading functionality.

Changed in version 1.3.0 for reading changes.

property sicd_meta: None | SICDType | Tuple[SICDType, ...]

the sicd meta_data or meta_data collection.

Type:

None|SICDType|Tuple[SICDType, …]

get_sicds_as_tuple() None | Tuple[SICDType, ...]

Get the sicd or sicd collection as a tuple - for simplicity and consistency of use.

Return type:

None|Tuple[SICDType, …]

get_sicd_partitions(match_function: ~typing.Callable = <function is_general_match>) Tuple[Tuple[int, ...], ...]

Partition the sicd collection into sub-collections according to match_function, which is assumed to establish an equivalence relation.

Parameters:

match_function (callable) – This match function must have call signature (SICDType, SICDType) -> bool, and defaults to sarpy.io.complex.sicd_elements.utils.is_general_match(). This function is assumed reflexive, symmetric, and transitive.

Return type:

Tuple[Tuple[int, …], …]

get_sicd_bands() Tuple[str, ...]

Gets the list of bands for each sicd.

Return type:

Tuple[str, …]

get_sicd_polarizations() Tuple[str, ...]

Gets the list of polarizations for each sicd.

Return type:

Tuple[str]

close() None

This should perform any necessary clean-up operations, like closing open file handles, deleting any temp files, etc.

property closed: bool

Is the reader closed? Reading will result in a ValueError

Type:

bool

property data_segment: DataSegment | Tuple[DataSegment, ...]

The data segment collection.

Type:

DataSegment|Tuple[DataSegment, …]

property data_size: Tuple[int, ...] | Tuple[Tuple[int, ...]]

the output/formatted data size(s) of the data segment(s). If there is a single data segment, then this will be Tuple[int, …], otherwise it will be Tuple[Tuple, int, …], …].

Type:

Tuple[int, …]|Tuple[Tuple[int, …], …]

property file_name: str | None

Defined as a convenience property.

Type:

None|str

property files_to_delete_on_close: List[str]

A collection of files to delete on the close operation.

Type:

List[str]

get_data_segment_as_tuple() Tuple[DataSegment, ...]

Get the data segment collection as a tuple, to avoid the need for redundant checking issues.

Return type:

Tuple[DataSegment, …]

get_data_size_as_tuple() Tuple[Tuple[int, ...], ...]

Get the data size collection as a tuple of tuples, to avoid the need for redundant checking issues.

Return type:

Tuple[Tuple[int, …], …]

get_raw_data_size_as_tuple() Tuple[Tuple[int, ...], ...]

Get the raw data size collection as a tuple of tuples, to avoid the need for redundant checking issues.

Return type:

Tuple[Tuple[int, …], …]

property image_count: int

The number of images/data segments from which to read.

Type:

int

property raw_data_size: Tuple[int, ...] | Tuple[Tuple[int, ...]]

the raw data size(s) of the data segment(s). If there is a single data segment, then this will be Tuple[int, …], otherwise it will be Tuple[Tuple, int, …], …].

Type:

Tuple[int, …]|Tuple[Tuple[int, …], …]

read(*ranges: None | int | Tuple[int, ...] | slice, index: int = 0, squeeze: bool = True) ndarray

Read formatted data from the given data segment. Note this is an alias to the __call__() called as reader(*ranges, index=index, raw=False, squeeze=squeeze).

Parameters:
  • ranges (Sequence[Union[None, int, Tuple[int, ...], slice]]) – The slice definition appropriate for data_segment[index].read() usage.

  • index (int) – The data_segment index. This is ignored if image_count== 1.

  • squeeze (bool) – Squeeze length 1 dimensions out of the shape of the return array?

Return type:

numpy.ndarray

See also

See

meth:sarpy.io.general.data_segment.DataSegment.read.

read_chip(*ranges: Sequence[None | int | Tuple[int, ...] | slice], index: int = 0, squeeze: bool = True) ndarray

This is identical to read(), and presented for backwards compatibility.

Parameters:
  • ranges (Sequence[Union[None, int, Tuple[int, ...], slice]]) –

  • index (int) –

  • squeeze (bool) –

Return type:

numpy.ndarray

See also

read()

read_raw(*ranges: None | int | Tuple[int, ...] | slice, index: int = 0, squeeze: bool = True) ndarray

Read raw data from the given data segment. Note this is an alias to the __call__() called as reader(*ranges, index=index, raw=True, squeeze=squeeze).

Parameters:
  • ranges (Sequence[Union[None, int, Tuple[int, ...], slice]]) – The slice definition appropriate for data_segment[index].read() usage.

  • index (int) – The data_segment index. This is ignored if image_count== 1.

  • squeeze (bool) – Squeeze length 1 dimensions out of the shape of the return array?

Return type:

numpy.ndarray

See also

See

meth:sarpy.io.general.data_segment.DataSegment.read_raw.

property reader_type: str

A descriptive string for the type of reader

Type:

str

class sarpy.io.complex.base.FlatSICDReader(sicd_meta, underlying_array, formatted_dtype: None | str | dtype = None, formatted_shape: None | Tuple[int, ...] = None, reverse_axes: None | int | Sequence[int] = None, transpose_axes: None | Tuple[int, ...] = None, format_function: None | FormatFunction = None, close_segments: bool = True)

Bases: FlatReader, SICDTypeReader

Create a sicd type reader directly from an array.

Changed in version 1.3.0 for reading changes.

write_to_file(output_file, check_older_version=False, check_existence=False)

Write a file for the given in-memory reader.

Parameters:
  • output_file (str) –

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

  • check_existence (bool) – Should we check if the given file already exists, and raise an exception if so?

close() None

This should perform any necessary clean-up operations, like closing open file handles, deleting any temp files, etc.

property closed: bool

Is the reader closed? Reading will result in a ValueError

Type:

bool

property data_segment: DataSegment | Tuple[DataSegment, ...]

The data segment collection.

Type:

DataSegment|Tuple[DataSegment, …]

property data_size: Tuple[int, ...] | Tuple[Tuple[int, ...]]

the output/formatted data size(s) of the data segment(s). If there is a single data segment, then this will be Tuple[int, …], otherwise it will be Tuple[Tuple, int, …], …].

Type:

Tuple[int, …]|Tuple[Tuple[int, …], …]

property file_name: str | None

Defined as a convenience property.

Type:

None|str

property files_to_delete_on_close: List[str]

A collection of files to delete on the close operation.

Type:

List[str]

get_data_segment_as_tuple() Tuple[DataSegment, ...]

Get the data segment collection as a tuple, to avoid the need for redundant checking issues.

Return type:

Tuple[DataSegment, …]

get_data_size_as_tuple() Tuple[Tuple[int, ...], ...]

Get the data size collection as a tuple of tuples, to avoid the need for redundant checking issues.

Return type:

Tuple[Tuple[int, …], …]

get_raw_data_size_as_tuple() Tuple[Tuple[int, ...], ...]

Get the raw data size collection as a tuple of tuples, to avoid the need for redundant checking issues.

Return type:

Tuple[Tuple[int, …], …]

get_sicd_bands() Tuple[str, ...]

Gets the list of bands for each sicd.

Return type:

Tuple[str, …]

get_sicd_partitions(match_function: ~typing.Callable = <function is_general_match>) Tuple[Tuple[int, ...], ...]

Partition the sicd collection into sub-collections according to match_function, which is assumed to establish an equivalence relation.

Parameters:

match_function (callable) – This match function must have call signature (SICDType, SICDType) -> bool, and defaults to sarpy.io.complex.sicd_elements.utils.is_general_match(). This function is assumed reflexive, symmetric, and transitive.

Return type:

Tuple[Tuple[int, …], …]

get_sicd_polarizations() Tuple[str, ...]

Gets the list of polarizations for each sicd.

Return type:

Tuple[str]

get_sicds_as_tuple() None | Tuple[SICDType, ...]

Get the sicd or sicd collection as a tuple - for simplicity and consistency of use.

Return type:

None|Tuple[SICDType, …]

property image_count: int

The number of images/data segments from which to read.

Type:

int

property raw_data_size: Tuple[int, ...] | Tuple[Tuple[int, ...]]

the raw data size(s) of the data segment(s). If there is a single data segment, then this will be Tuple[int, …], otherwise it will be Tuple[Tuple, int, …], …].

Type:

Tuple[int, …]|Tuple[Tuple[int, …], …]

read(*ranges: None | int | Tuple[int, ...] | slice, index: int = 0, squeeze: bool = True) ndarray

Read formatted data from the given data segment. Note this is an alias to the __call__() called as reader(*ranges, index=index, raw=False, squeeze=squeeze).

Parameters:
  • ranges (Sequence[Union[None, int, Tuple[int, ...], slice]]) – The slice definition appropriate for data_segment[index].read() usage.

  • index (int) – The data_segment index. This is ignored if image_count== 1.

  • squeeze (bool) – Squeeze length 1 dimensions out of the shape of the return array?

Return type:

numpy.ndarray

See also

See

meth:sarpy.io.general.data_segment.DataSegment.read.

read_chip(*ranges: Sequence[None | int | Tuple[int, ...] | slice], index: int = 0, squeeze: bool = True) ndarray

This is identical to read(), and presented for backwards compatibility.

Parameters:
  • ranges (Sequence[Union[None, int, Tuple[int, ...], slice]]) –

  • index (int) –

  • squeeze (bool) –

Return type:

numpy.ndarray

See also

read()

read_raw(*ranges: None | int | Tuple[int, ...] | slice, index: int = 0, squeeze: bool = True) ndarray

Read raw data from the given data segment. Note this is an alias to the __call__() called as reader(*ranges, index=index, raw=True, squeeze=squeeze).

Parameters:
  • ranges (Sequence[Union[None, int, Tuple[int, ...], slice]]) – The slice definition appropriate for data_segment[index].read() usage.

  • index (int) – The data_segment index. This is ignored if image_count== 1.

  • squeeze (bool) – Squeeze length 1 dimensions out of the shape of the return array?

Return type:

numpy.ndarray

See also

See

meth:sarpy.io.general.data_segment.DataSegment.read_raw.

property reader_type: str

A descriptive string for the type of reader

Type:

str

property sicd_meta: None | SICDType | Tuple[SICDType, ...]

the sicd meta_data or meta_data collection.

Type:

None|SICDType|Tuple[SICDType, …]

class sarpy.io.complex.base.SubsetSICDReader(reader, row_bounds, column_bounds, index=0, close_parent=False)

Bases: SICDTypeReader

Create a reader based on a specific subset of a given SICDTypeReader.

Changed in version 1.3.0 for reading changes.

close() None

This should perform any necessary clean-up operations, like closing open file handles, deleting any temp files, etc.

property closed: bool

Is the reader closed? Reading will result in a ValueError

Type:

bool

property data_segment: DataSegment | Tuple[DataSegment, ...]

The data segment collection.

Type:

DataSegment|Tuple[DataSegment, …]

property data_size: Tuple[int, ...] | Tuple[Tuple[int, ...]]

the output/formatted data size(s) of the data segment(s). If there is a single data segment, then this will be Tuple[int, …], otherwise it will be Tuple[Tuple, int, …], …].

Type:

Tuple[int, …]|Tuple[Tuple[int, …], …]

property files_to_delete_on_close: List[str]

A collection of files to delete on the close operation.

Type:

List[str]

get_data_segment_as_tuple() Tuple[DataSegment, ...]

Get the data segment collection as a tuple, to avoid the need for redundant checking issues.

Return type:

Tuple[DataSegment, …]

get_data_size_as_tuple() Tuple[Tuple[int, ...], ...]

Get the data size collection as a tuple of tuples, to avoid the need for redundant checking issues.

Return type:

Tuple[Tuple[int, …], …]

get_raw_data_size_as_tuple() Tuple[Tuple[int, ...], ...]

Get the raw data size collection as a tuple of tuples, to avoid the need for redundant checking issues.

Return type:

Tuple[Tuple[int, …], …]

get_sicd_bands() Tuple[str, ...]

Gets the list of bands for each sicd.

Return type:

Tuple[str, …]

get_sicd_partitions(match_function: ~typing.Callable = <function is_general_match>) Tuple[Tuple[int, ...], ...]

Partition the sicd collection into sub-collections according to match_function, which is assumed to establish an equivalence relation.

Parameters:

match_function (callable) – This match function must have call signature (SICDType, SICDType) -> bool, and defaults to sarpy.io.complex.sicd_elements.utils.is_general_match(). This function is assumed reflexive, symmetric, and transitive.

Return type:

Tuple[Tuple[int, …], …]

get_sicd_polarizations() Tuple[str, ...]

Gets the list of polarizations for each sicd.

Return type:

Tuple[str]

get_sicds_as_tuple() None | Tuple[SICDType, ...]

Get the sicd or sicd collection as a tuple - for simplicity and consistency of use.

Return type:

None|Tuple[SICDType, …]

property image_count: int

The number of images/data segments from which to read.

Type:

int

property raw_data_size: Tuple[int, ...] | Tuple[Tuple[int, ...]]

the raw data size(s) of the data segment(s). If there is a single data segment, then this will be Tuple[int, …], otherwise it will be Tuple[Tuple, int, …], …].

Type:

Tuple[int, …]|Tuple[Tuple[int, …], …]

read(*ranges: None | int | Tuple[int, ...] | slice, index: int = 0, squeeze: bool = True) ndarray

Read formatted data from the given data segment. Note this is an alias to the __call__() called as reader(*ranges, index=index, raw=False, squeeze=squeeze).

Parameters:
  • ranges (Sequence[Union[None, int, Tuple[int, ...], slice]]) – The slice definition appropriate for data_segment[index].read() usage.

  • index (int) – The data_segment index. This is ignored if image_count== 1.

  • squeeze (bool) – Squeeze length 1 dimensions out of the shape of the return array?

Return type:

numpy.ndarray

See also

See

meth:sarpy.io.general.data_segment.DataSegment.read.

read_chip(*ranges: Sequence[None | int | Tuple[int, ...] | slice], index: int = 0, squeeze: bool = True) ndarray

This is identical to read(), and presented for backwards compatibility.

Parameters:
  • ranges (Sequence[Union[None, int, Tuple[int, ...], slice]]) –

  • index (int) –

  • squeeze (bool) –

Return type:

numpy.ndarray

See also

read()

read_raw(*ranges: None | int | Tuple[int, ...] | slice, index: int = 0, squeeze: bool = True) ndarray

Read raw data from the given data segment. Note this is an alias to the __call__() called as reader(*ranges, index=index, raw=True, squeeze=squeeze).

Parameters:
  • ranges (Sequence[Union[None, int, Tuple[int, ...], slice]]) – The slice definition appropriate for data_segment[index].read() usage.

  • index (int) – The data_segment index. This is ignored if image_count== 1.

  • squeeze (bool) – Squeeze length 1 dimensions out of the shape of the return array?

Return type:

numpy.ndarray

See also

See

meth:sarpy.io.general.data_segment.DataSegment.read_raw.

property reader_type: str

A descriptive string for the type of reader

Type:

str

property sicd_meta: None | SICDType | Tuple[SICDType, ...]

the sicd meta_data or meta_data collection.

Type:

None|SICDType|Tuple[SICDType, …]

property file_name: None

Defined as a convenience property.

Type:

None|str