TerraSAR-X
Reader Interface
TERRASAR-X product format reader.
Attributes
prod_path
module-attribute
prod_path = 'C:\\Users\\marco.spadoni\\Desktop\\TSX_2024\\TDX1_SAR__SSC______SC_S_SRA_20240825T052632_20240825T052643'
channels
module-attribute
raster_file
module-attribute
channel_metadata
module-attribute
channel_metadata = read_channel_metadata(prod_path.joinpath(f'{prod_path.name}.xml'), raster_file)
data
module-attribute
data = np.abs(read_channel_data(raster_file, block_to_read, channel_metadata.burst_info)) ** 2
Classes
Functions:
read_channel_metadata
read_channel_metadata(xml_path: str | Path, associated_cos_raster_path: str | Path | None = None) -> support.TERRASARXChannelMetadata
Generate TERRASARXChannelMetadata object from product metadata
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xml_path
|
str | Path
|
path to xml metadata file |
required |
associated_cos_raster_path
|
str | Path | None
|
path to the channel .cos raster, provide None if product is MGD, by default None |
None
|
Returns:
| Type | Description |
|---|---|
TERRASARXChannelMetadata
|
TERRASAR-X channel metadata object |
read_product_metadata
Read all channels' metadata
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xml_path
|
str | Path
|
|
required |
Returns:
| Type | Description |
|---|---|
dict[str, TERRASARXChannelMetadata]
|
channels' metadata dictionary |
open_product
read_channel_data
read_channel_data(raster_file: str | Path, block_to_read: list[int], burst_info: BurstInfo, scaling_conversion: float = 1) -> np.ndarray
Read channel raster data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raster_file
|
str | Path
|
path to channel raster data |
required |
block_to_read
|
list[int]
|
data block to be read, to be specified as a list of 4 integers, in the form: Text Only
|
required |
burst_info
|
BurstInfo
|
burst info object |
required |
scaling_conversion
|
float
|
scaling conversion to be multiplied to the data read (sqrt of calibration factor), by default 1 |
1
|
Returns:
| Type | Description |
|---|---|
ndarray
|
ROI read from raster |
Raises:
| Type | Description |
|---|---|
ValueError
|
out of bounds in lines |
ValueError
|
out of bounds in samples |
ValueError
|
invalid raster file |
Utilities
TERRASAR-X reader support module.
Classes
InvalidTERRASARXProduct
Bases: RuntimeError
Invalid TERRASAR-X product
InvalidTERRASARXProjection
Bases: RuntimeError
Invalid TERRASAR-X projection
TERRASARXProductVariant
Bases: Enum
TERRASAR-X product type
TERRASARXAcquisitionModes
Bases: Enum
TERRASAR-X L1 acquisition modes
TERRASARXProjections
TERRASARXAttitude
dataclass
TERRASAR-X sensor's attitude
Attributes
Methods:
TERRASARXChannelMetadata
dataclass
Attributes
image_radiometric_quantity
instance-attribute
Methods:
__init__
__init__(image_calibration_factor: float, image_radiometric_quantity: SARRadiometricQuantity, polarization: str, burst_info: BurstInfo, raster_info: RasterInfo, dataset_info: DatasetInfo, swath_info: SwathInfo, sampling_constants: SARSamplingFrequencies, doppler_centroid_poly: DopplerEvaluator, doppler_rate_poly: DopplerEvaluator, coordinate_conversions: CoordinatesConversions, state_vectors: StateVectors, attitude: TERRASARXAttitude) -> None
TERRASARXProduct
TERRASAR-X product object
Attributes
channels_number
property
Returning the number of channels of TERRASAR-X product
channels_list
property
Returning the list of channels in terms of SwathID (swath-polarization)
acquisition_time
property
Acquisition start time for this product
acquisition_mode
property
Acquisition mode for this product
footprint
property
Product footprint as tuple of (min lat, max lat, min lon, max lon)
metadata_file
property
Returning the product metadata file path of TERRASAR-X product
Methods:
Functions:
get_basic_info_from_metadata
get_basic_info_from_metadata(metadata_path: str | Path) -> tuple[PreciseDateTime, TERRASARXProductVariant, tuple[float, float, float, float], TERRASARXAcquisitionModes]
Recovering basic product information
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata_path
|
str | Path
|
path to TERRASAR-X basic product specification xml file |
required |
Returns:
| Type | Description |
|---|---|
PreciseDateTime
|
acquisition time in PreciseDateTime format |
TERRASARXProductVariant
|
product variant |
tuple[float, float, float, float]
|
scene footprint in [min lat, max lat, min lon, max lon] |
TERRASARXAcquisitionModes
|
acquisition mode |
raster_info_from_metadata
raster_info_from_metadata(root: _Element, projection: SARProjection, beam_id: str) -> RasterInfo
Creating a RasterInfo metadata element from xml node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
_Element
|
root metadata xml node |
required |
projection
|
SARProjection
|
SAR product projection |
required |
beam_id
|
str
|
beam identifier string |
required |
Returns:
| Type | Description |
|---|---|
RasterInfo
|
RasterInfo metadata object |
burst_info_from_raster
Generate burst info from raster file in the case of scansar ssc products
burst_info_from_metadata
Get BurstInfo object from metadata file for non scansar ssc products
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raster_info
|
RasterInfo
|
product raster info |
required |
Returns:
| Type | Description |
|---|---|
BurstInfo
|
burst info dataclass |
dataset_info_from_metadata
dataset_info_from_metadata(root: _Element, projection: SARProjection, acq_mode: TERRASARXAcquisitionModes, prod_variant: TERRASARXProductVariant) -> DatasetInfo
Creating a DatasetInfo metadata element from xml nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
_Element
|
root metadata xml node |
required |
projection
|
SARProjection
|
SAR product projection |
required |
acq_mode
|
TERRASARXAcquisitionModes
|
TERRASAR-X product acquisition mode |
required |
prod_variant
|
TERRASARXProductVariant
|
TERRASAR-X product variant |
required |
Returns:
| Type | Description |
|---|---|
DatasetInfo
|
DatasetInfo metadata object |
sampling_constants_from_metadata
sampling_constants_from_metadata(root: _Element, raster_info: RasterInfo, beam_id: str, projection: SARProjection, acq_mode: TERRASARXAcquisitionModes) -> SARSamplingFrequencies
Creating a SARSamplingFrequencies metadata element from xml nodes
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
_Element
|
root metadata xml node |
required |
raster_info
|
RasterInfo
|
rasterInfo |
required |
beam_id
|
str
|
beam identifier string |
required |
projection
|
SARProjection
|
SAR product projection |
required |
acq_mode
|
TERRASARXAcquisitionModes
|
TERRASAR-X acquisition mode |
required |
Returns:
| Type | Description |
|---|---|
SARSamplingFrequencies
|
sampling frequencies |
get_acquisition_mode
Convert TERRASAR-X imaging mode to acquisition mode
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
imaging_mode
|
str
|
TERRASAR-X imaging mode |
required |
Returns:
| Type | Description |
|---|---|
TERRASARXAcquisitionModes
|
acquisition mode among STRIPMAP, SCANSAR, SPOTLIGHT |
get_SARProjection_from_TERRASARXProjection
Convert TERRASAR-X projection to generic SAR projection
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projection
|
TERRASARXProjections
|
TERRASAR-X product projection |
required |
Returns:
| Type | Description |
|---|---|
SARProjection
|
SAR product projection |
Raises:
| Type | Description |
|---|---|
InvalidTERRASARXProjection
|
Invalid TERRASAR-X product projection |
polarization_list_from_metadata
get_radiometric_quantity_from_metadata
Get SARRadiometricQuantity object from metadata
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
_Element
|
root metadata xml node |
required |
Returns:
| Type | Description |
|---|---|
SARRadiometricQuantity | None
|
SAR radiometric quantity object |
generate_channels_names
generate_raster_paths
get_beams_list_from_metadata
calibration_factor_from_metadata
swath_info_from_metadata
swath_info_from_metadata(prod_variant: TERRASARXProductVariant, root: _Element, beam_id: str) -> SwathInfo
Creating a SwathInfo metadata object from metadata file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prod_variant
|
TERRASARXProductVariant
|
TERRASAR-X product variant |
required |
root
|
_Element
|
root metadata xml node |
required |
beam_id
|
str
|
beam identifier string |
required |
Returns:
| Type | Description |
|---|---|
SwathInfo
|
SwathInfo metadata object |
state_vectors_from_metadata
Generating StateVectors object directly from product metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
_Element
|
root metadata xml node |
required |
Returns:
| Type | Description |
|---|---|
StateVectors
|
orbit's state vectors dataclass |
doppler_centroid_poly_from_metadata
Creating a DopplerEvaluator doppler centroid polynomial wrapper from metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
_Element
|
root metadata xml node |
required |
beam_id
|
str
|
beam identifier string |
required |
Returns:
| Type | Description |
|---|---|
DopplerEvaluator
|
DopplerEvaluator dataclass for Doppler Centroid polynomial |
doppler_rate_poly_from_metadata
doppler_rate_poly_from_metadata(root: _Element, beam_id: str, prod_variant: TERRASARXProductVariant) -> DopplerEvaluator
Creating a DopplerEvaluator doppler rate vector polynomial wrapper from metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
_Element
|
root metadata xml node |
required |
beam_id
|
str
|
beam identifier string |
required |
prod_variant
|
TERRASARXProductVariant
|
TERRASAR-X product variant |
required |
Returns:
| Type | Description |
|---|---|
DopplerEvaluator
|
DopplerEvaluator dataclass for Doppler Rate polynomial |
coordinates_conversions_from_metadata
coordinates_conversions_from_metadata(prod_variant: TERRASARXProductVariant, root: _Element, raster_info: RasterInfo, state_vectors: StateVectors, doppler_centroid_poly: DopplerEvaluator) -> CoordinatesConversions
Generating CoordinateConversions object from metadata
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prod_variant
|
TERRASARXProductVariant
|
TERRASAR-X product variant |
required |
root
|
_Element
|
root metadata xml node |
required |
raster_info
|
RasterInfo
|
product raster info |
required |
state_vectors
|
StateVectors
|
product state vectors |
required |
doppler_centroid_poly
|
DopplerEvaluator
|
product doppler centroid evaluator |
required |
Returns:
| Type | Description |
|---|---|
CoordinatesConversions
|
polynomial for coordinate conversion dataclass |
is_terrasarx_product
Check if input path corresponds to a valid TERRASAR-X product, basic version.
Conditions to be met for basic validity: - path is dir - GEOREF.xml file exists - product.html file exists - read basic info from product.html file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product
|
str | Path
|
path to the product to be checked |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if it is a valid product, else False |
attitude_data_from_metadata
Creating a TERRASARXAttitude metadata element from xml node
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
_Element
|
root metadata xml node |
required |
Returns:
| Type | Description |
|---|---|
TERRASARXAttitude
|
TERRASAR-X attitude using quaternions |