Ortho-rectification methodology (sarpy.processing.ortho_rectify)¶
Common ortho-rectification elements
- class sarpy.processing.ortho_rectify.base.FullResolutionFetcher(reader: str | SICDTypeReader, dimension: int = 0, index: int = 0, block_size: None | int | float = 10)¶
Bases:
object
This is a base class for provided a simple API for processing schemes where full resolution is required along the processing dimension, so sub-sampling along the processing dimension does not decrease the amount of data which must be fetched.
- property reader: SICDTypeReader¶
The reader instance.
- Type:
- property dimension: int¶
The dimension along which to perform the color subaperture split.
- Type:
int
- property data_size: Tuple[int, ...]¶
The data size for the reader at the given index.
- Type:
Tuple[int, …]
- property index: int¶
The index of the reader.
- Type:
int
- property block_size: float | None¶
The approximate processing block size in MB, where None represents processing in a single block.
- Type:
None|float
- property block_size_in_bytes: int | None¶
The approximate processing block size in bytes.
- Type:
None|int
- get_fetch_block_size(start_element: int, stop_element: int) int ¶
Gets the fetch block size for the given full resolution section. This assumes that the fetched data will be 8 bytes per pixel, in accordance with single band complex64 data.
- Parameters:
start_element (int) –
stop_element (int) –
- Return type:
int
- static extract_blocks(the_range: slice | Tuple[int, int, int], index_block_size: None | int | float) Tuple[List[Tuple[int, int, int]], List[Tuple[int, int]]] ¶
Convert the single range definition into a series of range definitions in keeping with fetching of the appropriate block sizes.
- Parameters:
the_range (slice|Tuple[int, int, int]) – The input (off processing axis) range.
index_block_size (None|int|float) – The size of blocks (number of indices).
- Returns:
range_definitions (List[Tuple[int, int, int]]) – The sequence of range definitions (start index, stop index, step) relative to the overall image.
limit_indices (List[Tuple[int, int]]) – The sequence of start/stop indices for positioning of the given range relative to the original range.
- class sarpy.processing.ortho_rectify.base.OrthorectificationIterator(ortho_helper: OrthorectificationHelper, calculator: FullResolutionFetcher | None = None, bounds: None | ndarray | tuple | list = None, remap_function: RemapFunction | None = None, recalc_remap_globals: bool = False)¶
Bases:
object
This provides a generator for an Orthorectification process on a given reader/index/(pixel) bounds.
- property ortho_helper: OrthorectificationHelper¶
The ortho-rectification helper.
- Type:
- property calculator: FullResolutionFetcher¶
The calculator instance.
- Type:
- property pixel_bounds: ndarray¶
Of the form (row min, row max, col min, col max).
- Type:
numpy.ndarray
- property ortho_bounds: ndarray¶
Of the form (row min, row max, col min, col max). Note that these are “unnormalized” orthorectified pixel coordinates.
- Type:
numpy.ndarray
- property ortho_data_size: Tuple[int, int]¶
The size of the overall ortho-rectified output.
- Type:
Tuple[int, int]
- property remap_function: RemapFunction | None¶
The remap function to be applied.
- Type:
None|RemapFunction
- get_ecf_image_corners() ndarray | None ¶
The corner points of the overall ortho-rectified output in ECF coordinates. The ordering of these points follows the SICD convention.
- Return type:
numpy.ndarray
- get_llh_image_corners() ndarray | None ¶
The corner points of the overall ortho-rectified output in Lat/Lon/HAE coordinates. The ordering of these points follows the SICD convention.
- Return type:
None|numpy.ndarray
- next() Tuple[ndarray, Tuple[int, int]] ¶
Get the next iteration of ortho-rectified data.
- Returns:
data (numpy.ndarray)
indices (Tuple[int, int]) – The (normalized) indices (start_row, start_col) for this section of data, relative to overall output shape.
Unified methods of projection between sicd pixel coordinates, some ortho-rectified pixel grid coordinates, and geophysical coordinates
- class sarpy.processing.ortho_rectify.projection_helper.ProjectionHelper(sicd, row_spacing=None, col_spacing=None, default_pixel_method='GEOM_MEAN')¶
Bases:
object
Abstract helper class which defines the projection interface for ortho-rectification usage for a sicd type object.
- property row_spacing¶
The row pixel spacing
- Type:
float
- property col_spacing¶
The column pixel spacing
- Type:
float
- ecf_to_ortho(coords)¶
Gets the (ortho_row, ortho_column) coordinates in the ortho-rectified system for the provided physical coordinates in ECF (X, Y, Z) coordinates.
- Parameters:
coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- ecf_to_pixel(coords)¶
Gets the (pixel_row, pixel_column) coordinates for the provided physical coordinates in ECF (X, Y, Z) coordinates.
- Parameters:
coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- ll_to_ortho(ll_coords)¶
Gets the (ortho_row, ortho_column) coordinates in the ortho-rectified system for the provided physical coordinates in (Lat, Lon) coordinates.
Note that there is inherent ambiguity when handling the missing elevation, and the effect is likely methodology dependent.
- Parameters:
ll_coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- llh_to_ortho(llh_coords)¶
Gets the (ortho_row, ortho_column) coordinates in the ortho-rectified system for the providednphysical coordinates in (Lat, Lon, HAE) coordinates.
- Parameters:
llh_coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- pixel_to_ortho(pixel_coords)¶
Gets the ortho-rectified indices for the point(s) in pixel coordinates.
- Parameters:
pixel_coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- pixel_to_ecf(pixel_coords)¶
Gets the ECF coordinates for the point(s) in pixel coordinates.
- Parameters:
pixel_coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- ortho_to_ecf(ortho_coords)¶
Get the ecf coordinates for the point(s) in ortho-rectified coordinates.
- Parameters:
ortho_coords (numpy.ndarray) – Point(s) in the ortho-recitified coordinate system, of the form (ortho_row, ortho_column).
- Return type:
numpy.ndarray
- ortho_to_llh(ortho_coords)¶
Get the lat/lon/hae coordinates for the point(s) in ortho-rectified coordinates.
- Parameters:
ortho_coords (numpy.ndarray) – Point(s) in the ortho-recitified coordinate system, of the form (ortho_row, ortho_column).
- Return type:
numpy.ndarray
- ortho_to_pixel(ortho_coords)¶
Get the pixel indices for the point(s) in ortho-rectified coordinates.
- Parameters:
ortho_coords (numpy.ndarray) – Point(s) in the ortho-recitified coordinate system, of the form (ortho_row, ortho_column).
- Returns:
The array of indices, of the same shape as new_coords, which indicate (row, column) pixel (fractional) indices.
- Return type:
numpy.ndarray
- get_pixel_array_bounds(coords)¶
Extract integer bounds of the input array, expected to have final dimension of size 2.
- Parameters:
coords (numpy.ndarray) –
- Returns:
Of the form (min_row, max_row, min_column, max_column).
- Return type:
numpy.ndarray
- class sarpy.processing.ortho_rectify.projection_helper.PGProjection(sicd, reference_point=None, reference_pixels=None, normal_vector=None, row_vector=None, col_vector=None, row_spacing=None, col_spacing=None, default_pixel_method='GEOM_MEAN')¶
Bases:
ProjectionHelper
Class which helps perform the Planar Grid (i.e. Ground Plane) ortho-rectification for a sicd-type object using the SICD projection model directly.
- property reference_point: ndarray¶
The grid reference point.
- Type:
numpy.ndarray
- property reference_pixels: ndarray¶
The ortho-rectified pixel coordinates of the grid reference point.
- Type:
numpy.ndarray
- property normal_vector: ndarray¶
The normal vector.
- Type:
numpy.ndarray
- set_reference_point(reference_point=None)¶
Sets the reference point, which must be provided in ECF coordinates.
- Parameters:
reference_point (None|numpy.ndarray) – The reference point (origin) of the planar grid. If None, then the sicd.GeoData.SCP.ECF will be used.
- Return type:
None
- set_reference_pixels(reference_pixels=None)¶
Sets the reference point, which must be provided in ECF coordinates.
- Parameters:
reference_pixels (None|numpy.ndarray) – The ortho-rectified pixel coordinates for the reference point (origin) of the planar grid. If None, then the (0, 0) will be used.
- Return type:
None
- property row_vector¶
The grid increasing row direction (ECF) unit vector.
- Type:
numpy.ndarray
- property col_vector¶
The grid increasing column direction (ECF) unit vector.
- Type:
numpy.ndarray
- property reference_hae¶
The height above the ellipsoid of the reference point.
- Type:
float
- set_plane_frame(normal_vector=None, row_vector=None, col_vector=None)¶
Set the plane unit normal, and the row and column vectors, in ECF coordinates. Note that the perpendicular component of col_vector with respect to the row_vector will be used.
If normal_vector, row_vector, and col_vector are all None, then the normal to the Earth tangent plane at the reference point is used for normal_vector. The row_vector will be defined as the perpendicular component of sicd.Grid.Row.UVectECF to normal_vector. The colummn_vector will be defined as the component of sicd.Grid.Col.UVectECF perpendicular to both normal_vector and row_vector.
If only normal_vector is supplied, then the row_vector and column_vector will be defined similarly as the perpendicular components of sicd.Grid.Row.UVectECF and sicd.Grid.Col.UVectECF.
Otherwise, all vectors supplied will be normalized, but are required to be mutually perpendicular. If only two vectors are supplied, then the third will be determined.
- Parameters:
normal_vector (None|numpy.ndarray) – The vector defining the outward unit normal in ECF coordinates.
row_vector (None|numpy.ndarray) – The vector defining increasing column direction.
col_vector (None|numpy.ndarray) – The vector defining increasing column direction.
- Return type:
None
- plane_ecf_to_ortho(coords)¶
Converts ECF coordinates known to be in the ground plane to ortho grid coordinates.
- Parameters:
coords (numpy.ndarray) –
- Return type:
numpy.ndarray
- ecf_to_ortho(coords)¶
Gets the (ortho_row, ortho_column) coordinates in the ortho-rectified system for the provided physical coordinates in ECF (X, Y, Z) coordinates.
- Parameters:
coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- ecf_to_pixel(coords)¶
Gets the (pixel_row, pixel_column) coordinates for the provided physical coordinates in ECF (X, Y, Z) coordinates.
- Parameters:
coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- ll_to_ortho(ll_coords)¶
Gets the (ortho_row, ortho_column) coordinates in the ortho-rectified system for the provided physical coordinates in (Lat, Lon) coordinates. In this case, the missing altitude will be set to reference_hae, which is imperfect.
- Parameters:
ll_coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- llh_to_ortho(llh_coords)¶
Gets the (ortho_row, ortho_column) coordinates in the ortho-rectified system for the providednphysical coordinates in (Lat, Lon, HAE) coordinates.
- Parameters:
llh_coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- ortho_to_ecf(ortho_coords)¶
Get the ecf coordinates for the point(s) in ortho-rectified coordinates.
- Parameters:
ortho_coords (numpy.ndarray) – Point(s) in the ortho-recitified coordinate system, of the form (ortho_row, ortho_column).
- Return type:
numpy.ndarray
- ortho_to_pixel(ortho_coords)¶
Get the pixel indices for the point(s) in ortho-rectified coordinates.
- Parameters:
ortho_coords (numpy.ndarray) – Point(s) in the ortho-recitified coordinate system, of the form (ortho_row, ortho_column).
- Returns:
The array of indices, of the same shape as new_coords, which indicate (row, column) pixel (fractional) indices.
- Return type:
numpy.ndarray
- pixel_to_ortho(pixel_coords)¶
Gets the ortho-rectified indices for the point(s) in pixel coordinates.
- Parameters:
pixel_coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- pixel_to_ecf(pixel_coords)¶
Gets the ECF coordinates for the point(s) in pixel coordinates.
- Parameters:
pixel_coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- property col_spacing¶
The column pixel spacing
- Type:
float
- get_pixel_array_bounds(coords)¶
Extract integer bounds of the input array, expected to have final dimension of size 2.
- Parameters:
coords (numpy.ndarray) –
- Returns:
Of the form (min_row, max_row, min_column, max_column).
- Return type:
numpy.ndarray
- ortho_to_llh(ortho_coords)¶
Get the lat/lon/hae coordinates for the point(s) in ortho-rectified coordinates.
- Parameters:
ortho_coords (numpy.ndarray) – Point(s) in the ortho-recitified coordinate system, of the form (ortho_row, ortho_column).
- Return type:
numpy.ndarray
- property row_spacing¶
The row pixel spacing
- Type:
float
- class sarpy.processing.ortho_rectify.projection_helper.PGRatPolyProjection(sicd, reference_point=None, reference_pixels=None, normal_vector=None, row_vector=None, col_vector=None, row_spacing=None, col_spacing=None, default_pixel_method='GEOM_MEAN', row_samples=51, col_samples=51, alt_samples=11, alt_span=250)¶
Bases:
PGProjection
- perform_rational_poly_fitting()¶
Defined the rational polynomial functions via fitting.
- property col_spacing¶
The column pixel spacing
- Type:
float
- property col_vector¶
The grid increasing column direction (ECF) unit vector.
- Type:
numpy.ndarray
- ecf_to_ortho(coords)¶
Gets the (ortho_row, ortho_column) coordinates in the ortho-rectified system for the provided physical coordinates in ECF (X, Y, Z) coordinates.
- Parameters:
coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- get_pixel_array_bounds(coords)¶
Extract integer bounds of the input array, expected to have final dimension of size 2.
- Parameters:
coords (numpy.ndarray) –
- Returns:
Of the form (min_row, max_row, min_column, max_column).
- Return type:
numpy.ndarray
- ll_to_ortho(ll_coords)¶
Gets the (ortho_row, ortho_column) coordinates in the ortho-rectified system for the provided physical coordinates in (Lat, Lon) coordinates. In this case, the missing altitude will be set to reference_hae, which is imperfect.
- Parameters:
ll_coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- llh_to_ortho(llh_coords)¶
Gets the (ortho_row, ortho_column) coordinates in the ortho-rectified system for the providednphysical coordinates in (Lat, Lon, HAE) coordinates.
- Parameters:
llh_coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- property normal_vector: ndarray¶
The normal vector.
- Type:
numpy.ndarray
- ortho_to_ecf(ortho_coords)¶
Get the ecf coordinates for the point(s) in ortho-rectified coordinates.
- Parameters:
ortho_coords (numpy.ndarray) – Point(s) in the ortho-recitified coordinate system, of the form (ortho_row, ortho_column).
- Return type:
numpy.ndarray
- ortho_to_llh(ortho_coords)¶
Get the lat/lon/hae coordinates for the point(s) in ortho-rectified coordinates.
- Parameters:
ortho_coords (numpy.ndarray) – Point(s) in the ortho-recitified coordinate system, of the form (ortho_row, ortho_column).
- Return type:
numpy.ndarray
- pixel_to_ecf(pixel_coords)¶
Gets the ECF coordinates for the point(s) in pixel coordinates.
- Parameters:
pixel_coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- plane_ecf_to_ortho(coords)¶
Converts ECF coordinates known to be in the ground plane to ortho grid coordinates.
- Parameters:
coords (numpy.ndarray) –
- Return type:
numpy.ndarray
- property reference_hae¶
The height above the ellipsoid of the reference point.
- Type:
float
- property reference_pixels: ndarray¶
The ortho-rectified pixel coordinates of the grid reference point.
- Type:
numpy.ndarray
- property reference_point: ndarray¶
The grid reference point.
- Type:
numpy.ndarray
- property row_spacing¶
The row pixel spacing
- Type:
float
- property row_vector¶
The grid increasing row direction (ECF) unit vector.
- Type:
numpy.ndarray
- set_plane_frame(normal_vector=None, row_vector=None, col_vector=None)¶
Set the plane unit normal, and the row and column vectors, in ECF coordinates. Note that the perpendicular component of col_vector with respect to the row_vector will be used.
If normal_vector, row_vector, and col_vector are all None, then the normal to the Earth tangent plane at the reference point is used for normal_vector. The row_vector will be defined as the perpendicular component of sicd.Grid.Row.UVectECF to normal_vector. The colummn_vector will be defined as the component of sicd.Grid.Col.UVectECF perpendicular to both normal_vector and row_vector.
If only normal_vector is supplied, then the row_vector and column_vector will be defined similarly as the perpendicular components of sicd.Grid.Row.UVectECF and sicd.Grid.Col.UVectECF.
Otherwise, all vectors supplied will be normalized, but are required to be mutually perpendicular. If only two vectors are supplied, then the third will be determined.
- Parameters:
normal_vector (None|numpy.ndarray) – The vector defining the outward unit normal in ECF coordinates.
row_vector (None|numpy.ndarray) – The vector defining increasing column direction.
col_vector (None|numpy.ndarray) – The vector defining increasing column direction.
- Return type:
None
- set_reference_pixels(reference_pixels=None)¶
Sets the reference point, which must be provided in ECF coordinates.
- Parameters:
reference_pixels (None|numpy.ndarray) – The ortho-rectified pixel coordinates for the reference point (origin) of the planar grid. If None, then the (0, 0) will be used.
- Return type:
None
- set_reference_point(reference_point=None)¶
Sets the reference point, which must be provided in ECF coordinates.
- Parameters:
reference_point (None|numpy.ndarray) – The reference point (origin) of the planar grid. If None, then the sicd.GeoData.SCP.ECF will be used.
- Return type:
None
- ecf_to_pixel(coords)¶
Gets the (pixel_row, pixel_column) coordinates for the provided physical coordinates in ECF (X, Y, Z) coordinates.
- Parameters:
coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- ortho_to_pixel(ortho_coords)¶
Get the pixel indices for the point(s) in ortho-rectified coordinates.
- Parameters:
ortho_coords (numpy.ndarray) – Point(s) in the ortho-recitified coordinate system, of the form (ortho_row, ortho_column).
- Returns:
The array of indices, of the same shape as new_coords, which indicate (row, column) pixel (fractional) indices.
- Return type:
numpy.ndarray
- pixel_to_ortho(pixel_coords)¶
Gets the ortho-rectified indices for the point(s) in pixel coordinates.
- Parameters:
pixel_coords (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
Methods for ortho-rectification
- class sarpy.processing.ortho_rectify.ortho_methods.OrthorectificationHelper(reader, index=0, proj_helper=None, complex_valued=False, pad_value=None, apply_radiometric=None, subtract_radiometric_noise=False)¶
Bases:
object
Abstract helper class which defines ortho-rectification process for a sicd-type reader object.
- property reader: SICDTypeReader¶
The reader instance.
- Type:
- property index: int¶
The index for the desired sicd element.
- Type:
int
- property proj_helper: ProjectionHelper¶
The projection helper instance.
- Type:
- property out_dtype: dtype¶
The output data type.
- Type:
numpy.dtype
- property pad_value¶
The value to use for any portions of the array which extend beyond the range of where the reader has data.
- set_index_and_proj_helper(index, proj_helper=None)¶
Sets the index and proj_helper objects.
- Parameters:
index (int) –
proj_helper (ProjectionHelper) –
- Return type:
None
- property apply_radiometric: None | str¶
This indicates which, if any, of the radiometric scale factors to apply in the result. If not None, this must be one of (‘RCS’, ‘SIGMA0’, ‘GAMMA0’, ‘BETA0’).
Setting to a value other than None will result in an error if 1.) complex_valued is True, or 2.) the appropriate corresponding element sicd.Radiometric.RCSSFPoly, sicd.Radiometric.SigmaZeroSFPoly, sicd.Radiometric.GammaZeroSFPoly, or sicd.Radiometric.BetaZeroSFPoly is not populated with a valid polynomial.
- Type:
None|str
- property subtract_radiometric_noise¶
This indicates whether the radiometric noise should be subtracted from the pixel amplitude. If apply_radiometric is not None, then this subtraction will happen applying the corresponding scaling.
Setting this to True will result in an error unless the given sicd structure has sicd.Radiometric.NoiseLevel.NoisePoly populated with a viable polynomial and sicd.Radiometric.NoiseLevel.NoiseLevelType == ‘ABSOLUTE’.
- Type:
bool
- get_full_ortho_bounds()¶
Gets the bounds for the ortho-rectified coordinates for the full sicd image.
- Returns:
Of the form [min row, max row, min column, max column].
- Return type:
numpy.ndarray
- get_valid_ortho_bounds()¶
Gets the bounds for the ortho-rectified coordinates for the valid portion of the sicd image. This is the outer bounds of the valid portion, so may contain some portion which is not itself valid.
If sicd.ImageData.ValidData is not defined, then the full image bounds will be returned.
- Returns:
Of the form [min row, max row, min column, max column].
- Return type:
numpy.ndarray
- get_orthorectification_bounds_from_pixel_object(coordinates)¶
Determine the ortho-rectified (coordinate-system aligned) rectangular bounding region which contains the provided coordinates in pixel space.
- Parameters:
coordinates (GeometryObject|numpy.ndarray|list|tuple) – The coordinate system of the input will be assumed to be pixel space.
- Returns:
Of the form (row_min, row_max, col_min, col_max).
- Return type:
numpy.ndarray
- get_orthorectification_bounds_from_latlon_object(coordinates)¶
Determine the ortho-rectified (coordinate-system aligned) rectangular bounding region which contains the provided coordinates in lat/lon space.
- Parameters:
coordinates (GeometryObject|numpy.ndarray|list|tuple) – The coordinate system of the input will be assumed to be lat/lon space. Note a GeometryObject is expected to follow lon/lat ordering paradigm, by convention.
- Returns:
Of the form (row_min, row_max, col_min, col_max).
- Return type:
numpy.ndarray
- static validate_bounds(bounds)¶
Validate a pixel type bounds array.
- Parameters:
bounds (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- bounds_to_rectangle(bounds)¶
From a bounds style array, construct the four corner coordinate array. This follows the SICD convention of going CLOCKWISE around the corners.
- Parameters:
bounds (numpy.ndarray|list|tuple) – Of the form (row min, row max, col min, col max).
- Returns:
The (integer valued) bounds and rectangular coordinates.
- Return type:
(numpy.ndarray, numpy.ndarray)
- extract_pixel_bounds(bounds)¶
Validate the bounds array of orthorectified pixel coordinates, and determine the required bounds in reader pixel coordinates. If the
- Parameters:
bounds (numpy.ndarray|list|tuple) –
- Returns:
The integer valued orthorectified and reader pixel coordinate bounds.
- Return type:
(numpy.ndarray, numpy.ndarray)
- get_real_pixel_bounds(pixel_bounds)¶
Fetch the real pixel limit from the nominal pixel limits - this just factors in the image reader extent.
- Parameters:
pixel_bounds (numpy.ndarray) –
- Return type:
numpy.ndarray
- get_orthorectified_from_array(ortho_bounds, row_array, col_array, value_array)¶
Construct the orthorectified array covering the orthorectified region given by ortho_bounds based on the values_array, which spans the pixel region defined by row_array and col_array.
This is mainly a helper method, and should only be called directly for specific and directed reasons.
- Parameters:
ortho_bounds (numpy.ndarray) – Determines the orthorectified bounds region, of the form (min row, max row, min column, max column).
row_array (numpy.ndarray) – The rows of the pixel array. Must be one-dimensional, monotonically increasing, and have row_array.size = value_array.shape[0].
col_array – The columns of the pixel array. Must be one-dimensional, monotonically increasing, and have col_array.size = value_array.shape[1].
value_array – The values array. If this has complex dtype and complex_valued=False, then the
numpy.abs()
will be applied.
- Return type:
numpy.ndarray
- get_orthorectified_for_ortho_bounds(bounds)¶
Determine the array corresponding to the array of bounds given in ortho-rectified pixel coordinates.
- Parameters:
bounds (numpy.ndarray|list|tuple) – Of the form (row_min, row_max, col_min, col_max). Note that non-integer values will be expanded outwards (floor of minimum and ceil at maximum). Following Python convention, this will be inclusive at the minimum and exclusive at the maximum.
- Return type:
numpy.ndarray
- get_orthorectified_for_pixel_bounds(pixel_bounds)¶
Determine the array corresponding to the given array bounds given in reader pixel coordinates.
- Parameters:
pixel_bounds (numpy.ndarray|list|tuple) – Of the form (row_min, row_max, col_min, col_max).
- Return type:
numpy.ndarray
- get_orthorectified_for_pixel_object(coordinates)¶
Determine the ortho-rectified rectangular array values, which will bound the given object - with coordinates expressed in pixel space.
- Parameters:
coordinates (GeometryObject|numpy.ndarray|list|tuple) – The coordinate system of the input will be assumed to be pixel space.
- Return type:
numpy.ndarray
- get_orthorectified_for_latlon_object(ll_coordinates)¶
Determine the ortho-rectified rectangular array values, which will bound the given object - with coordinates expressed in lat/lon space.
- Parameters:
ll_coordinates (GeometryObject|numpy.ndarray|list|tuple) – The coordinate system of the input will be assumed to be pixel space. Note a GeometryObject is expected to follow lon/lat ordering paradigm, by convention.
- Return type:
numpy.ndarray
- class sarpy.processing.ortho_rectify.ortho_methods.NearestNeighborMethod(reader, index=0, proj_helper=None, complex_valued=False, pad_value=None, apply_radiometric=None, subtract_radiometric_noise=False)¶
Bases:
OrthorectificationHelper
Nearest neighbor ortho-rectification method.
Warning
Modification of the proj_helper parameters when the default full image bounds have been defained (i.e. sicd.RadarCollection.Area is defined) may result in unintended results.
- property apply_radiometric: None | str¶
This indicates which, if any, of the radiometric scale factors to apply in the result. If not None, this must be one of (‘RCS’, ‘SIGMA0’, ‘GAMMA0’, ‘BETA0’).
Setting to a value other than None will result in an error if 1.) complex_valued is True, or 2.) the appropriate corresponding element sicd.Radiometric.RCSSFPoly, sicd.Radiometric.SigmaZeroSFPoly, sicd.Radiometric.GammaZeroSFPoly, or sicd.Radiometric.BetaZeroSFPoly is not populated with a valid polynomial.
- Type:
None|str
- bounds_to_rectangle(bounds)¶
From a bounds style array, construct the four corner coordinate array. This follows the SICD convention of going CLOCKWISE around the corners.
- Parameters:
bounds (numpy.ndarray|list|tuple) – Of the form (row min, row max, col min, col max).
- Returns:
The (integer valued) bounds and rectangular coordinates.
- Return type:
(numpy.ndarray, numpy.ndarray)
- extract_pixel_bounds(bounds)¶
Validate the bounds array of orthorectified pixel coordinates, and determine the required bounds in reader pixel coordinates. If the
- Parameters:
bounds (numpy.ndarray|list|tuple) –
- Returns:
The integer valued orthorectified and reader pixel coordinate bounds.
- Return type:
(numpy.ndarray, numpy.ndarray)
- get_full_ortho_bounds()¶
Gets the bounds for the ortho-rectified coordinates for the full sicd image.
- Returns:
Of the form [min row, max row, min column, max column].
- Return type:
numpy.ndarray
- get_orthorectification_bounds_from_latlon_object(coordinates)¶
Determine the ortho-rectified (coordinate-system aligned) rectangular bounding region which contains the provided coordinates in lat/lon space.
- Parameters:
coordinates (GeometryObject|numpy.ndarray|list|tuple) – The coordinate system of the input will be assumed to be lat/lon space. Note a GeometryObject is expected to follow lon/lat ordering paradigm, by convention.
- Returns:
Of the form (row_min, row_max, col_min, col_max).
- Return type:
numpy.ndarray
- get_orthorectification_bounds_from_pixel_object(coordinates)¶
Determine the ortho-rectified (coordinate-system aligned) rectangular bounding region which contains the provided coordinates in pixel space.
- Parameters:
coordinates (GeometryObject|numpy.ndarray|list|tuple) – The coordinate system of the input will be assumed to be pixel space.
- Returns:
Of the form (row_min, row_max, col_min, col_max).
- Return type:
numpy.ndarray
- get_orthorectified_for_latlon_object(ll_coordinates)¶
Determine the ortho-rectified rectangular array values, which will bound the given object - with coordinates expressed in lat/lon space.
- Parameters:
ll_coordinates (GeometryObject|numpy.ndarray|list|tuple) – The coordinate system of the input will be assumed to be pixel space. Note a GeometryObject is expected to follow lon/lat ordering paradigm, by convention.
- Return type:
numpy.ndarray
- get_orthorectified_for_ortho_bounds(bounds)¶
Determine the array corresponding to the array of bounds given in ortho-rectified pixel coordinates.
- Parameters:
bounds (numpy.ndarray|list|tuple) – Of the form (row_min, row_max, col_min, col_max). Note that non-integer values will be expanded outwards (floor of minimum and ceil at maximum). Following Python convention, this will be inclusive at the minimum and exclusive at the maximum.
- Return type:
numpy.ndarray
- get_orthorectified_for_pixel_bounds(pixel_bounds)¶
Determine the array corresponding to the given array bounds given in reader pixel coordinates.
- Parameters:
pixel_bounds (numpy.ndarray|list|tuple) – Of the form (row_min, row_max, col_min, col_max).
- Return type:
numpy.ndarray
- get_orthorectified_for_pixel_object(coordinates)¶
Determine the ortho-rectified rectangular array values, which will bound the given object - with coordinates expressed in pixel space.
- Parameters:
coordinates (GeometryObject|numpy.ndarray|list|tuple) – The coordinate system of the input will be assumed to be pixel space.
- Return type:
numpy.ndarray
- get_orthorectified_from_array(ortho_bounds, row_array, col_array, value_array)¶
Construct the orthorectified array covering the orthorectified region given by ortho_bounds based on the values_array, which spans the pixel region defined by row_array and col_array.
This is mainly a helper method, and should only be called directly for specific and directed reasons.
- Parameters:
ortho_bounds (numpy.ndarray) – Determines the orthorectified bounds region, of the form (min row, max row, min column, max column).
row_array (numpy.ndarray) – The rows of the pixel array. Must be one-dimensional, monotonically increasing, and have row_array.size = value_array.shape[0].
col_array – The columns of the pixel array. Must be one-dimensional, monotonically increasing, and have col_array.size = value_array.shape[1].
value_array – The values array. If this has complex dtype and complex_valued=False, then the
numpy.abs()
will be applied.
- Return type:
numpy.ndarray
- get_real_pixel_bounds(pixel_bounds)¶
Fetch the real pixel limit from the nominal pixel limits - this just factors in the image reader extent.
- Parameters:
pixel_bounds (numpy.ndarray) –
- Return type:
numpy.ndarray
- get_valid_ortho_bounds()¶
Gets the bounds for the ortho-rectified coordinates for the valid portion of the sicd image. This is the outer bounds of the valid portion, so may contain some portion which is not itself valid.
If sicd.ImageData.ValidData is not defined, then the full image bounds will be returned.
- Returns:
Of the form [min row, max row, min column, max column].
- Return type:
numpy.ndarray
- property index: int¶
The index for the desired sicd element.
- Type:
int
- property out_dtype: dtype¶
The output data type.
- Type:
numpy.dtype
- property pad_value¶
The value to use for any portions of the array which extend beyond the range of where the reader has data.
- property proj_helper: ProjectionHelper¶
The projection helper instance.
- Type:
- property reader: SICDTypeReader¶
The reader instance.
- Type:
- set_index_and_proj_helper(index, proj_helper=None)¶
Sets the index and proj_helper objects.
- Parameters:
index (int) –
proj_helper (ProjectionHelper) –
- Return type:
None
- property subtract_radiometric_noise¶
This indicates whether the radiometric noise should be subtracted from the pixel amplitude. If apply_radiometric is not None, then this subtraction will happen applying the corresponding scaling.
Setting this to True will result in an error unless the given sicd structure has sicd.Radiometric.NoiseLevel.NoisePoly populated with a viable polynomial and sicd.Radiometric.NoiseLevel.NoiseLevelType == ‘ABSOLUTE’.
- Type:
bool
- static validate_bounds(bounds)¶
Validate a pixel type bounds array.
- Parameters:
bounds (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- class sarpy.processing.ortho_rectify.ortho_methods.BivariateSplineMethod(reader, index=0, proj_helper=None, complex_valued=False, pad_value=None, apply_radiometric=None, subtract_radiometric_noise=False, row_order=1, col_order=1)¶
Bases:
OrthorectificationHelper
Bivariate spline interpolation ortho-rectification method.
Warning
Modification of the proj_helper parameters when the default full image bounds have been defained (i.e. sicd.RadarCollection.Area is defined) may result in unintended results.
- property apply_radiometric: None | str¶
This indicates which, if any, of the radiometric scale factors to apply in the result. If not None, this must be one of (‘RCS’, ‘SIGMA0’, ‘GAMMA0’, ‘BETA0’).
Setting to a value other than None will result in an error if 1.) complex_valued is True, or 2.) the appropriate corresponding element sicd.Radiometric.RCSSFPoly, sicd.Radiometric.SigmaZeroSFPoly, sicd.Radiometric.GammaZeroSFPoly, or sicd.Radiometric.BetaZeroSFPoly is not populated with a valid polynomial.
- Type:
None|str
- bounds_to_rectangle(bounds)¶
From a bounds style array, construct the four corner coordinate array. This follows the SICD convention of going CLOCKWISE around the corners.
- Parameters:
bounds (numpy.ndarray|list|tuple) – Of the form (row min, row max, col min, col max).
- Returns:
The (integer valued) bounds and rectangular coordinates.
- Return type:
(numpy.ndarray, numpy.ndarray)
- extract_pixel_bounds(bounds)¶
Validate the bounds array of orthorectified pixel coordinates, and determine the required bounds in reader pixel coordinates. If the
- Parameters:
bounds (numpy.ndarray|list|tuple) –
- Returns:
The integer valued orthorectified and reader pixel coordinate bounds.
- Return type:
(numpy.ndarray, numpy.ndarray)
- get_full_ortho_bounds()¶
Gets the bounds for the ortho-rectified coordinates for the full sicd image.
- Returns:
Of the form [min row, max row, min column, max column].
- Return type:
numpy.ndarray
- get_orthorectification_bounds_from_latlon_object(coordinates)¶
Determine the ortho-rectified (coordinate-system aligned) rectangular bounding region which contains the provided coordinates in lat/lon space.
- Parameters:
coordinates (GeometryObject|numpy.ndarray|list|tuple) – The coordinate system of the input will be assumed to be lat/lon space. Note a GeometryObject is expected to follow lon/lat ordering paradigm, by convention.
- Returns:
Of the form (row_min, row_max, col_min, col_max).
- Return type:
numpy.ndarray
- get_orthorectification_bounds_from_pixel_object(coordinates)¶
Determine the ortho-rectified (coordinate-system aligned) rectangular bounding region which contains the provided coordinates in pixel space.
- Parameters:
coordinates (GeometryObject|numpy.ndarray|list|tuple) – The coordinate system of the input will be assumed to be pixel space.
- Returns:
Of the form (row_min, row_max, col_min, col_max).
- Return type:
numpy.ndarray
- get_orthorectified_for_latlon_object(ll_coordinates)¶
Determine the ortho-rectified rectangular array values, which will bound the given object - with coordinates expressed in lat/lon space.
- Parameters:
ll_coordinates (GeometryObject|numpy.ndarray|list|tuple) – The coordinate system of the input will be assumed to be pixel space. Note a GeometryObject is expected to follow lon/lat ordering paradigm, by convention.
- Return type:
numpy.ndarray
- get_orthorectified_for_ortho_bounds(bounds)¶
Determine the array corresponding to the array of bounds given in ortho-rectified pixel coordinates.
- Parameters:
bounds (numpy.ndarray|list|tuple) – Of the form (row_min, row_max, col_min, col_max). Note that non-integer values will be expanded outwards (floor of minimum and ceil at maximum). Following Python convention, this will be inclusive at the minimum and exclusive at the maximum.
- Return type:
numpy.ndarray
- get_orthorectified_for_pixel_bounds(pixel_bounds)¶
Determine the array corresponding to the given array bounds given in reader pixel coordinates.
- Parameters:
pixel_bounds (numpy.ndarray|list|tuple) – Of the form (row_min, row_max, col_min, col_max).
- Return type:
numpy.ndarray
- get_orthorectified_for_pixel_object(coordinates)¶
Determine the ortho-rectified rectangular array values, which will bound the given object - with coordinates expressed in pixel space.
- Parameters:
coordinates (GeometryObject|numpy.ndarray|list|tuple) – The coordinate system of the input will be assumed to be pixel space.
- Return type:
numpy.ndarray
- get_orthorectified_from_array(ortho_bounds, row_array, col_array, value_array)¶
Construct the orthorectified array covering the orthorectified region given by ortho_bounds based on the values_array, which spans the pixel region defined by row_array and col_array.
This is mainly a helper method, and should only be called directly for specific and directed reasons.
- Parameters:
ortho_bounds (numpy.ndarray) – Determines the orthorectified bounds region, of the form (min row, max row, min column, max column).
row_array (numpy.ndarray) – The rows of the pixel array. Must be one-dimensional, monotonically increasing, and have row_array.size = value_array.shape[0].
col_array – The columns of the pixel array. Must be one-dimensional, monotonically increasing, and have col_array.size = value_array.shape[1].
value_array – The values array. If this has complex dtype and complex_valued=False, then the
numpy.abs()
will be applied.
- Return type:
numpy.ndarray
- get_real_pixel_bounds(pixel_bounds)¶
Fetch the real pixel limit from the nominal pixel limits - this just factors in the image reader extent.
- Parameters:
pixel_bounds (numpy.ndarray) –
- Return type:
numpy.ndarray
- get_valid_ortho_bounds()¶
Gets the bounds for the ortho-rectified coordinates for the valid portion of the sicd image. This is the outer bounds of the valid portion, so may contain some portion which is not itself valid.
If sicd.ImageData.ValidData is not defined, then the full image bounds will be returned.
- Returns:
Of the form [min row, max row, min column, max column].
- Return type:
numpy.ndarray
- property index: int¶
The index for the desired sicd element.
- Type:
int
- property out_dtype: dtype¶
The output data type.
- Type:
numpy.dtype
- property pad_value¶
The value to use for any portions of the array which extend beyond the range of where the reader has data.
- property proj_helper: ProjectionHelper¶
The projection helper instance.
- Type:
- property reader: SICDTypeReader¶
The reader instance.
- Type:
- set_index_and_proj_helper(index, proj_helper=None)¶
Sets the index and proj_helper objects.
- Parameters:
index (int) –
proj_helper (ProjectionHelper) –
- Return type:
None
- property subtract_radiometric_noise¶
This indicates whether the radiometric noise should be subtracted from the pixel amplitude. If apply_radiometric is not None, then this subtraction will happen applying the corresponding scaling.
Setting this to True will result in an error unless the given sicd structure has sicd.Radiometric.NoiseLevel.NoisePoly populated with a viable polynomial and sicd.Radiometric.NoiseLevel.NoiseLevelType == ‘ABSOLUTE’.
- Type:
bool
- static validate_bounds(bounds)¶
Validate a pixel type bounds array.
- Parameters:
bounds (numpy.ndarray|list|tuple) –
- Return type:
numpy.ndarray
- property row_order¶
The spline order for the x/row coordinate, where 1 <= row_order <= 5.
- Type:
int
- property col_order¶
The spline order for the y/col coordinate, where 1 <= col_order <= 5.
- Type:
int