Grid object and related elements¶
The GridType definition.
- sarpy.io.complex.sicd_elements.Grid.DEFAULT_WEIGHT_SIZE = 512¶
the default size when generating WgtFunct from a named WgtType.
- Type:
int
- class sarpy.io.complex.sicd_elements.Grid.WgtTypeType(WindowName: str = None, Parameters: ParametersCollection | Dict = None, **kwargs)¶
Bases:
Serializable
The weight type parameters of the direction parameters.
- WindowName: str¶
Type of aperture weighting applied in the spatial frequency domain (Krow) to yield the impulse response in the row direction. Example values - “UNIFORM”, “TAYLOR”, “UNKNOWN”, “HAMMING” Required.
- Type:
str
- Parameters: ParametersCollection¶
Free form parameters list. Optional.
- Type:
ParametersCollection
- get_parameter_value(param_name: str, default: str | None = None) str | None ¶
Gets the value (first value found) associated with a given parameter name. Returns default if not found.
- Parameters:
param_name (str) – the parameter name for which to search.
default (None|str) – the default value to return if lookup fails.
- Returns:
the associated parameter value, or default.
- Return type:
str
- classmethod from_node(node, xml_ns, ns_key=None, kwargs=None)¶
For XML deserialization.
- Parameters:
node (ElementTree.Element) – dom element for serialized class instance
xml_ns (None|dict) – The xml namespace dictionary.
ns_key (None|str) – The xml namespace key. If xml_ns is None, then this is ignored. If None and xml_ns is not None, then the string default will be used. This will be recursively passed down, unless overridden by an entry of the cls._child_xml_ns_key dictionary.
kwargs (None|dict) – None or dictionary of previously serialized attributes. For use in inheritance call, when certain attributes require specific deserialization.
- Return type:
Corresponding class instance
- copy()¶
Create a deep copy.
- classmethod from_dict(input_dict)¶
For json deserialization, from dict instance.
- Parameters:
input_dict (dict) – Appropriate parameters dict instance for deserialization
- Return type:
Corresponding class instance
- is_valid(recursive=False, stack=False)¶
Returns the validity of this object according to the schema. This is done by inspecting that all required fields (i.e. entries of _required) are not None.
- Parameters:
recursive (bool) – True if we recursively check that child are also valid. This may result in verbose (i.e. noisy) logging.
stack (bool) – Print a recursive error message?
- Returns:
condition for validity of this element
- Return type:
bool
- log_validity_error(msg)¶
Log a validity check error message.
- Parameters:
msg (str) –
- log_validity_info(msg)¶
Log a validation info message.
- Parameters:
msg (str) –
- log_validity_warning(msg)¶
Log a validity check warning message.
- Parameters:
msg (str) –
- set_numeric_format(attribute, format_string)¶
Sets the numeric format string for the given attribute.
- Parameters:
attribute (str) – attribute for which the format applies - must be in _fields.
format_string (str) – format string to be applied
- Return type:
None
- to_dict(check_validity=False, strict=False, exclude=())¶
For json serialization.
- Parameters:
check_validity (bool) – Check whether the element is valid before serializing, by calling
is_valid()
.strict (bool) – Only used if check_validity = True. In that case, if True then raise an Exception (of appropriate type) if the structure is not valid, if False then log a hopefully helpful message.
exclude (tuple) – Attribute names to exclude from this generic serialization. This allows for child classes to provide specific serialization for special properties, after using this super method.
- Returns:
dict representation of class instance appropriate for direct json serialization.
- Return type:
OrderedDict
- to_node(doc, tag, ns_key=None, parent=None, check_validity=False, strict=False, exclude=())¶
For XML serialization, to a dom element.
- Parameters:
doc (ElementTree.ElementTree) – The xml Document
tag (None|str) – The tag name. Defaults to the value of self._tag and then the class name if unspecified.
ns_key (None|str) – The namespace prefix. This will be recursively passed down, unless overridden by an entry in the _child_xml_ns_key dictionary.
parent (None|ElementTree.Element) – The parent element. Defaults to the document root element if unspecified.
check_validity (bool) – Check whether the element is valid before serializing, by calling
is_valid()
.strict (bool) – Only used if check_validity = True. In that case, if True then raise an Exception (of appropriate type) if the structure is not valid, if False then log a hopefully helpful message.
exclude (tuple) – Attribute names to exclude from this generic serialization. This allows for child classes to provide specific serialization for special properties, after using this super method.
- Returns:
The constructed dom element, already assigned to the parent element.
- Return type:
ElementTree.Element
- to_xml_bytes(urn=None, tag=None, check_validity=False, strict=False)¶
Gets a bytes array, which corresponds to the xml string in utf-8 encoding, identified as using the namespace given by urn (if given).
- Parameters:
urn (None|str|dict) – The xml namespace string or dictionary describing the xml namespace.
tag (None|str) – The root node tag to use. If not given, then the class name will be used.
check_validity (bool) – Check whether the element is valid before serializing, by calling
is_valid()
.strict (bool) – Only used if check_validity = True. In that case, if True then raise an Exception (of appropriate type) if the structure is not valid, if False then log a hopefully helpful message.
- Returns:
bytes array from
ElementTree.tostring()
call.- Return type:
bytes
- to_xml_string(urn=None, tag=None, check_validity=False, strict=False)¶
Gets a xml string with utf-8 encoding, identified as using the namespace given by urn (if given).
- Parameters:
urn (None|str|dict) – The xml namespace or dictionary describing the xml namespace.
tag (None|str) – The root node tag to use. If not given, then the class name will be used.
check_validity (bool) – Check whether the element is valid before serializing, by calling
is_valid()
.strict (bool) – Only used if check_validity = True. In that case, if True then raise an Exception (of appropriate type) if the structure is not valid, if False then log a hopefully helpful message.
- Returns:
xml string from
ElementTree.tostring()
call.- Return type:
str
- class sarpy.io.complex.sicd_elements.Grid.DirParamType(UVectECF: XYZType | ndarray | list | tuple = None, SS: float = None, ImpRespWid: float = None, Sgn: int = None, ImpRespBW: float = None, KCtr: float = None, DeltaK1: float = None, DeltaK2: float = None, DeltaKCOAPoly: None | Poly2DType | ndarray | list | tuple = None, WgtType: WgtTypeType | None = None, WgtFunct: None | ndarray | list | tuple = None, **kwargs)¶
Bases:
Serializable
The direction parameters container
- UVectECF: XYZType¶
Unit vector in the increasing
(row/col)
direction (ECF) at the SCP pixel. Required.- Type:
- SS: float¶
Sample spacing in the increasing
(row/col)
direction. Precise spacing at the SCP. Required.- Type:
float
- ImpRespWid: float¶
Half power impulse response width in the increasing
(row/col)
direction. Measured at the scene center point. Required.- Type:
float
- ImpRespBW: float¶
Spatial bandwidth in
(row/col)
used to form the impulse response in the(row/col)
direction. Measured at the center of support for the SCP. Required.- Type:
float
- Sgn: int¶
Sign for exponent in the DFT to transform the
(row/col)
dimension to spatial frequency dimension. Must take one of the values in (1, -1). Required.- Type:
int
- KCtr: float¶
Center spatial frequency in the given dimension. Corresponds to the zero frequency of the DFT in the given
(row/col)
direction. Required.- Type:
float
- DeltaK1: float¶
Minimum
(row/col)
offset from KCtr of the spatial frequency support for the image. Required.- Type:
float
- DeltaK2: float¶
Maximum
(row/col)
offset from KCtr of the spatial frequency support for the image. Required.- Type:
float
- DeltaKCOAPoly: Poly2DType¶
Offset from KCtr of the center of support in the given
(row/col)
spatial frequency. The polynomial is a function of image given(row/col)
coordinate(variable 1)
and column coordinate(variable 2)
. Optional.- Type:
- WgtType: WgtTypeType¶
Parameters describing aperture weighting type applied in the spatial frequency domain to yield the impulse response in the given
(row/col)
direction. Optional.- Type:
- WgtFunct: ndarray¶
Sampled aperture amplitude weighting function (array) applied to form the SCP impulse response in the given
(row/col)
direction. Must have length exactly 2. Optional.- Type:
numpy.ndarray[float64]
- define_weight_function(weight_size: int = 512, populate: bool = False) ndarray | None ¶
Try to derive WgtFunct from WgtType, if necessary. This should likely be called from the GridType parent.
- Parameters:
weight_size (int) – the size of the WgtFunct to generate.
populate (bool) – Overwrite any populated WgtFunct value?
- Return type:
None|numpy.ndarray
- get_oversample_rate() float ¶
Gets the oversample rate. Added in version 1.2.35.
- Return type:
float
- define_response_widths(populate: bool = False) Tuple[float, float] | None ¶
Assuming that WgtFunct has been properly populated, define the response widths. This should likely be called by GridType parent.
- Parameters:
populate (bool) – Overwrite populated ImpRespWid and/or ImpRespBW?
- Returns:
None or (ImpRespBw, ImpRespWid)
- Return type:
None|(float, float)
- estimate_deltak(x_coords: ndarray | None, y_coords: ndarray | None, populate: bool = False) Tuple[float, float] | None ¶
The DeltaK1 and DeltaK2 parameters can be estimated from DeltaKCOAPoly, if necessary. This should likely be called by the GridType parent.
- Parameters:
x_coords (None|numpy.ndarray) – The physical vertex coordinates to evaluate DeltaKCOAPoly
y_coords (None|numpy.ndarray) – The physical vertex coordinates to evaluate DeltaKCOAPoly
populate (bool) – Overwite any populated DeltaK1 and DeltaK2?
- Returns:
min_deltak (float)
max_deltak (float)
- check_deltak(x_coords: ndarray | None, y_coords: ndarray | None) bool ¶
Checks the DeltaK values for validity.
- Parameters:
x_coords (None|numpy.ndarray) – The physical vertex coordinates to evaluate DeltaKCOAPoly
y_coords (None|numpy.ndarray) – The physical vertex coordinates to evaluate DeltaKCOAPoly
- Return type:
bool
- copy()¶
Create a deep copy.
- classmethod from_dict(input_dict)¶
For json deserialization, from dict instance.
- Parameters:
input_dict (dict) – Appropriate parameters dict instance for deserialization
- Return type:
Corresponding class instance
- classmethod from_node(node, xml_ns, ns_key=None, kwargs=None)¶
For XML deserialization.
- Parameters:
node (ElementTree.Element) – dom element for serialized class instance
xml_ns (None|dict) – The xml namespace dictionary.
ns_key (None|str) – The xml namespace key. If xml_ns is None, then this is ignored. If None and xml_ns is not None, then the string default will be used. This will be recursively passed down, unless overridden by an entry of the cls._child_xml_ns_key dictionary.
kwargs (None|dict) – None or dictionary of previously serialized attributes. For use in inheritance call, when certain attributes require specific deserialization.
- Return type:
Corresponding class instance
- is_valid(recursive=False, stack=False)¶
Returns the validity of this object according to the schema. This is done by inspecting that all required fields (i.e. entries of _required) are not None.
- Parameters:
recursive (bool) – True if we recursively check that child are also valid. This may result in verbose (i.e. noisy) logging.
stack (bool) – Print a recursive error message?
- Returns:
condition for validity of this element
- Return type:
bool
- log_validity_error(msg)¶
Log a validity check error message.
- Parameters:
msg (str) –
- log_validity_info(msg)¶
Log a validation info message.
- Parameters:
msg (str) –
- log_validity_warning(msg)¶
Log a validity check warning message.
- Parameters:
msg (str) –
- set_numeric_format(attribute, format_string)¶
Sets the numeric format string for the given attribute.
- Parameters:
attribute (str) – attribute for which the format applies - must be in _fields.
format_string (str) – format string to be applied
- Return type:
None
- to_dict(check_validity=False, strict=False, exclude=())¶
For json serialization.
- Parameters:
check_validity (bool) – Check whether the element is valid before serializing, by calling
is_valid()
.strict (bool) – Only used if check_validity = True. In that case, if True then raise an Exception (of appropriate type) if the structure is not valid, if False then log a hopefully helpful message.
exclude (tuple) – Attribute names to exclude from this generic serialization. This allows for child classes to provide specific serialization for special properties, after using this super method.
- Returns:
dict representation of class instance appropriate for direct json serialization.
- Return type:
OrderedDict
- to_node(doc, tag, ns_key=None, parent=None, check_validity=False, strict=False, exclude=())¶
For XML serialization, to a dom element.
- Parameters:
doc (ElementTree.ElementTree) – The xml Document
tag (None|str) – The tag name. Defaults to the value of self._tag and then the class name if unspecified.
ns_key (None|str) – The namespace prefix. This will be recursively passed down, unless overridden by an entry in the _child_xml_ns_key dictionary.
parent (None|ElementTree.Element) – The parent element. Defaults to the document root element if unspecified.
check_validity (bool) – Check whether the element is valid before serializing, by calling
is_valid()
.strict (bool) – Only used if check_validity = True. In that case, if True then raise an Exception (of appropriate type) if the structure is not valid, if False then log a hopefully helpful message.
exclude (tuple) – Attribute names to exclude from this generic serialization. This allows for child classes to provide specific serialization for special properties, after using this super method.
- Returns:
The constructed dom element, already assigned to the parent element.
- Return type:
ElementTree.Element
- to_xml_bytes(urn=None, tag=None, check_validity=False, strict=False)¶
Gets a bytes array, which corresponds to the xml string in utf-8 encoding, identified as using the namespace given by urn (if given).
- Parameters:
urn (None|str|dict) – The xml namespace string or dictionary describing the xml namespace.
tag (None|str) – The root node tag to use. If not given, then the class name will be used.
check_validity (bool) – Check whether the element is valid before serializing, by calling
is_valid()
.strict (bool) – Only used if check_validity = True. In that case, if True then raise an Exception (of appropriate type) if the structure is not valid, if False then log a hopefully helpful message.
- Returns:
bytes array from
ElementTree.tostring()
call.- Return type:
bytes
- to_xml_string(urn=None, tag=None, check_validity=False, strict=False)¶
Gets a xml string with utf-8 encoding, identified as using the namespace given by urn (if given).
- Parameters:
urn (None|str|dict) – The xml namespace or dictionary describing the xml namespace.
tag (None|str) – The root node tag to use. If not given, then the class name will be used.
check_validity (bool) – Check whether the element is valid before serializing, by calling
is_valid()
.strict (bool) – Only used if check_validity = True. In that case, if True then raise an Exception (of appropriate type) if the structure is not valid, if False then log a hopefully helpful message.
- Returns:
xml string from
ElementTree.tostring()
call.- Return type:
str
- class sarpy.io.complex.sicd_elements.Grid.GridType(ImagePlane: str = None, Type: str = None, TimeCOAPoly: Poly2DType | ndarray | list | tuple = None, Row: DirParamType = None, Col: DirParamType = None, **kwargs)¶
Bases:
Serializable
Collection grid details container
- copy()¶
Create a deep copy.
- classmethod from_dict(input_dict)¶
For json deserialization, from dict instance.
- Parameters:
input_dict (dict) – Appropriate parameters dict instance for deserialization
- Return type:
Corresponding class instance
- classmethod from_node(node, xml_ns, ns_key=None, kwargs=None)¶
For XML deserialization.
- Parameters:
node (ElementTree.Element) – dom element for serialized class instance
xml_ns (None|dict) – The xml namespace dictionary.
ns_key (None|str) – The xml namespace key. If xml_ns is None, then this is ignored. If None and xml_ns is not None, then the string default will be used. This will be recursively passed down, unless overridden by an entry of the cls._child_xml_ns_key dictionary.
kwargs (None|dict) – None or dictionary of previously serialized attributes. For use in inheritance call, when certain attributes require specific deserialization.
- Return type:
Corresponding class instance
- is_valid(recursive=False, stack=False)¶
Returns the validity of this object according to the schema. This is done by inspecting that all required fields (i.e. entries of _required) are not None.
- Parameters:
recursive (bool) – True if we recursively check that child are also valid. This may result in verbose (i.e. noisy) logging.
stack (bool) – Print a recursive error message?
- Returns:
condition for validity of this element
- Return type:
bool
- log_validity_error(msg)¶
Log a validity check error message.
- Parameters:
msg (str) –
- log_validity_info(msg)¶
Log a validation info message.
- Parameters:
msg (str) –
- log_validity_warning(msg)¶
Log a validity check warning message.
- Parameters:
msg (str) –
- set_numeric_format(attribute, format_string)¶
Sets the numeric format string for the given attribute.
- Parameters:
attribute (str) – attribute for which the format applies - must be in _fields.
format_string (str) – format string to be applied
- Return type:
None
- to_dict(check_validity=False, strict=False, exclude=())¶
For json serialization.
- Parameters:
check_validity (bool) – Check whether the element is valid before serializing, by calling
is_valid()
.strict (bool) – Only used if check_validity = True. In that case, if True then raise an Exception (of appropriate type) if the structure is not valid, if False then log a hopefully helpful message.
exclude (tuple) – Attribute names to exclude from this generic serialization. This allows for child classes to provide specific serialization for special properties, after using this super method.
- Returns:
dict representation of class instance appropriate for direct json serialization.
- Return type:
OrderedDict
- to_node(doc, tag, ns_key=None, parent=None, check_validity=False, strict=False, exclude=())¶
For XML serialization, to a dom element.
- Parameters:
doc (ElementTree.ElementTree) – The xml Document
tag (None|str) – The tag name. Defaults to the value of self._tag and then the class name if unspecified.
ns_key (None|str) – The namespace prefix. This will be recursively passed down, unless overridden by an entry in the _child_xml_ns_key dictionary.
parent (None|ElementTree.Element) – The parent element. Defaults to the document root element if unspecified.
check_validity (bool) – Check whether the element is valid before serializing, by calling
is_valid()
.strict (bool) – Only used if check_validity = True. In that case, if True then raise an Exception (of appropriate type) if the structure is not valid, if False then log a hopefully helpful message.
exclude (tuple) – Attribute names to exclude from this generic serialization. This allows for child classes to provide specific serialization for special properties, after using this super method.
- Returns:
The constructed dom element, already assigned to the parent element.
- Return type:
ElementTree.Element
- to_xml_bytes(urn=None, tag=None, check_validity=False, strict=False)¶
Gets a bytes array, which corresponds to the xml string in utf-8 encoding, identified as using the namespace given by urn (if given).
- Parameters:
urn (None|str|dict) – The xml namespace string or dictionary describing the xml namespace.
tag (None|str) – The root node tag to use. If not given, then the class name will be used.
check_validity (bool) – Check whether the element is valid before serializing, by calling
is_valid()
.strict (bool) – Only used if check_validity = True. In that case, if True then raise an Exception (of appropriate type) if the structure is not valid, if False then log a hopefully helpful message.
- Returns:
bytes array from
ElementTree.tostring()
call.- Return type:
bytes
- to_xml_string(urn=None, tag=None, check_validity=False, strict=False)¶
Gets a xml string with utf-8 encoding, identified as using the namespace given by urn (if given).
- Parameters:
urn (None|str|dict) – The xml namespace or dictionary describing the xml namespace.
tag (None|str) – The root node tag to use. If not given, then the class name will be used.
check_validity (bool) – Check whether the element is valid before serializing, by calling
is_valid()
.strict (bool) – Only used if check_validity = True. In that case, if True then raise an Exception (of appropriate type) if the structure is not valid, if False then log a hopefully helpful message.
- Returns:
xml string from
ElementTree.tostring()
call.- Return type:
str
- ImagePlane: str¶
Defines the type of image plane that the best describes the sample grid. Precise plane defined by Row Direction and Column Direction unit vectors. Takes values in
('SLANT', 'GROUND', 'OTHER')
. Required.- Type:
str
- Type: str¶
str: Defines the type of spatial sampling grid represented by the image sample grid. Row coordinate first, column coordinate second:
RGAZIM - Grid for a simple range, Doppler image. Also, the natural grid for images formed with the Polar Format Algorithm.
RGZERO - A grid for images formed with the Range Migration Algorithm. Used only for imaging near closest approach (i.e. near zero Doppler).
XRGYCR - Orthogonal slant plane grid oriented range and cross range relative to the ARP at a reference time.
XCTYAT - Orthogonal slant plane grid with X oriented cross track.
PLANE - Arbitrary plane with orientation other than the specific XRGYCR or XCTYAT.
Takes values in
('RGAZIM', 'RGZERO', 'XRGYCR', 'XCTYAT', 'PLANE')
. Required.
- TimeCOAPoly: Poly2DType¶
Time of Center Of Aperture as a polynomial function of image coordinates. The polynomial is a function of image row coordinate
(variable 1)
and column coordinate(variable 2)
. Required.- Type:
- Row: DirParamType¶
Row direction parameters. Required.
- Type:
- Col: DirParamType¶
Column direction parameters. Required.
- Type:
- derive_direction_params(ImageData, populate: bool = False)¶
Populate the
Row/Col
direction parameters from ImageData, if necessary. Expected to be called from SICD parent.- Parameters:
ImageData (sarpy.io.complex.sicd_elements.ImageData.ImageDataType) –
populate (bool) – Repopulates any present values?
- Return type:
None
- check_deltak(x_coords: ndarray | None, y_coords: ndarray | None) bool ¶
Checks the validity of DeltaK values.
- Parameters:
x_coords (None|numpy.ndarray) –
y_coords (None|numpy.ndarray) –
- Return type:
bool
- get_resolution_abbreviation() str ¶
Gets the resolution abbreviation for the suggested name.
- Return type:
str
- get_slant_plane_area() float ¶
Get the weighted slant plane area.
- Return type:
float