Skip to content

Commit

Permalink
Merge branch 'master' into pr_455 sync 1.3.55
Browse files Browse the repository at this point in the history
  • Loading branch information
Darder committed Jul 25, 2023
2 parents 334748c + 6e43f90 commit f8e5c0d
Show file tree
Hide file tree
Showing 16 changed files with 2,677 additions and 67 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ SarPy follows a continuous release process, so there are fairly frequent release
Since essentially every (squash merge) commit corresponds to a release, specific
release points are not being annotated in GitHub.

## [1.3.55] - 2023-07-19
### Added
- Added test for SARPY to/from XML logic.
### Fixed
- Fixed AntGPid typo to AntGPId.
- Fixed SARPY correctly finding TxAntenna/RcvAntenna PVPs using from_file in cphd_consistency.py.
- Fixed SARPY correctly specifying EBFreqShiftSF in AntPatternType.
- Fixed SARPY correctly handling AddedParameters as a single element with repeated Parameter children.
- Fixed EndPoint type to Endpoint.
- Fixed SARPY correctly including index as a child element instead of an attribute in LSVertexType.

## [1.3.54] - 2023-07-19
### Added
- Added RadarModeType class to SIDD with SCANSAR option.

## [1.3.53] - 2023-07-11
### Added
- Added 3db contours to transmit and receive beam footprints for CPHD kmzs.
Expand Down
2 changes: 1 addition & 1 deletion sarpy/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
'__license__', '__copyright__']

from sarpy.__details__ import __classification__, _post_identifier
_version_number = '1.3.53'
_version_number = '1.3.55'

__version__ = _version_number + _post_identifier

Expand Down
2 changes: 1 addition & 1 deletion sarpy/consistency/cphd_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def from_file(cls, filename, schema=None, check_signal_data=False):
pvp_block = infile.read(header['PVP_BLOCK_SIZE'])

cphdroot_no_ns = strip_namespace(etree.fromstring(etree.tostring(cphdroot)))
fields = [parse_pvp_elem(field) for field in list(cphdroot_no_ns.find('./PVP'))]
fields = [parse_pvp_elem(field) for field in list(cphdroot_no_ns.findall('./PVP//Offset/..'))]
dtype = np.dtype({'names': [name for name, _ in fields],
'formats': [info['dtype'] for _, info in fields],
'offsets': [info['offset']*8 for _, info in fields]}).newbyteorder('B')
Expand Down
19 changes: 10 additions & 9 deletions sarpy/io/phase_history/cphd1_elements/Antenna.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def version_required(self) -> Tuple[int, int, int]:
class GainPhasePolyType(Serializable):
"""A container for the Gain and Phase Polygon definitions."""

_fields = ('GainPoly', 'PhasePoly', 'AntGPid')
_fields = ('GainPoly', 'PhasePoly', 'AntGPId')
_required = ('GainPoly', 'PhasePoly')
# descriptors
GainPoly = SerializableDescriptor(
Expand All @@ -385,17 +385,18 @@ class GainPhasePolyType(Serializable):
docstring='One-way signal phase (in cycles) as a function of DCX (variable 1) and '
'DCY (variable 2). Phase relative to phase at DCX = 0 and DCY = 0, '
'so constant coefficient is always 0.0.') # type: Poly2DType
AntGPid = StringDescriptor(
'AntGPid', _required, strict=DEFAULT_STRICT,
docstring='') # type: Optional[str]
AntGPId = StringDescriptor(
'AntGPId', _required, strict=DEFAULT_STRICT,
docstring='Identifier of the Antenna Gain/Phase support array that specifies the '
'one-way pattern.') # type: Optional[str]

def __init__(self, GainPoly=None, PhasePoly=None, AntGPid=None, **kwargs):
def __init__(self, GainPoly=None, PhasePoly=None, AntGPId=None, **kwargs):
"""
Parameters
----------
GainPoly : Poly2DType|numpy.ndarray|list|tuple
PhasePoly : Poly2DType|numpy.ndarray|list|tuple
AntGPid : None|str
AntGPId : None|str
kwargs
"""

Expand All @@ -405,7 +406,7 @@ def __init__(self, GainPoly=None, PhasePoly=None, AntGPid=None, **kwargs):
self._xml_ns_key = kwargs['_xml_ns_key']
self.GainPoly = GainPoly
self.PhasePoly = PhasePoly
self.AntGPid = AntGPid
self.AntGPId = AntGPId
super(GainPhasePolyType, self).__init__(**kwargs)

def __call__(self, x, y):
Expand Down Expand Up @@ -444,7 +445,7 @@ def minimize_order(self):

def version_required(self) -> Tuple[int, int, int]:
required = (1, 0, 1)
if self.AntGPid is not None:
if self.AntGPId is not None:
required = max(required, (1, 1, 0))
return required

Expand All @@ -455,7 +456,7 @@ class AntPatternType(Serializable):
"""

_fields = (
'Identifier', 'FreqZero', 'GainZero', 'EBFreqShift', 'EBFreqShift',
'Identifier', 'FreqZero', 'GainZero', 'EBFreqShift', 'EBFreqShiftSF',
'MLFreqDilation', 'MLFreqDilationSF', 'GainBSPoly', 'AntPolRef',
'EB', 'Array', 'Element', 'GainPhaseArray')
_required = (
Expand Down
24 changes: 12 additions & 12 deletions sarpy/io/phase_history/cphd1_elements/Channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import numpy

from .base import DEFAULT_STRICT, FLOAT_FORMAT
from .blocks import POLARIZATION_TYPE, AreaType
from sarpy.io.xml.base import Serializable, SerializableArray, ParametersCollection, \
from .blocks import POLARIZATION_TYPE, AreaType, AddedParametersType
from sarpy.io.xml.base import Serializable, SerializableArray, \
Arrayable
from sarpy.io.xml.descriptors import StringDescriptor, StringEnumDescriptor, StringListDescriptor, \
IntegerDescriptor, FloatDescriptor, BooleanDescriptor, ParametersDescriptor, \
IntegerDescriptor, FloatDescriptor, BooleanDescriptor, \
SerializableDescriptor, SerializableListDescriptor, SerializableArrayDescriptor


Expand Down Expand Up @@ -71,7 +71,7 @@ def get_array(self, dtype=numpy.float64) -> numpy.ndarray:
@classmethod
def from_array(cls, array: numpy.ndarray):
"""
Construct from a iterable.
Construct from an iterable.
Parameters
----------
Expand Down Expand Up @@ -295,7 +295,7 @@ def version_required(self) -> Tuple[int, int, int]:


class AntennaType(Serializable):
""""
"""
Antenna Phase Center and Antenna Pattern identifiers for
the antenna(s) used to collect and form the signal array data.
"""
Expand Down Expand Up @@ -656,8 +656,7 @@ class ChannelType(Serializable):
_required = (
'RefChId', 'FXFixedCPHD', 'TOAFixedCPHD', 'SRPFixedCPHD', 'Parameters')
_collections_tags = {
'Parameters': {'array': False, 'child_tag': 'Parameters'},
'AddedParameters': {'array': False, 'child_tag': 'AddedParameters'}}
'Parameters': {'array': False, 'child_tag': 'Parameters'}}
# descriptors
RefChId = StringDescriptor(
'RefChId', _required, strict=DEFAULT_STRICT,
Expand All @@ -679,9 +678,10 @@ class ChannelType(Serializable):
'Parameters', ChannelParametersType, _collections_tags, _required, strict=DEFAULT_STRICT,
docstring='Parameter Set that describes a CPHD data '
'channel.') # type: List[ChannelParametersType]
AddedParameters = ParametersDescriptor(
'AddedParameters', _collections_tags, _required, strict=DEFAULT_STRICT,
docstring='Additional free form parameters.') # type: Union[None, ParametersCollection]
AddedParameters = SerializableDescriptor(
'AddedParameters', AddedParametersType, _required, strict=DEFAULT_STRICT,
docstring='Block for including additional parameters that describe '
'the channels and/or signal arrays.') # type: Union[None, AddedParametersType]

def __init__(
self,
Expand All @@ -690,7 +690,7 @@ def __init__(
TOAFixedCPHD: bool = None,
SRPFixedCPHD: bool = None,
Parameters: List[ChannelParametersType] = None,
AddedParameters: Optional[ParametersCollection] = None,
AddedParameters: Optional[AddedParametersType] = None,
**kwargs):
"""
Expand All @@ -701,7 +701,7 @@ def __init__(
TOAFixedCPHD : bool
SRPFixedCPHD : bool
Parameters : List[ChannelParametersType]
AddedParameters : None|ParametersCollection
AddedParameters : None|AddedParametersType
kwargs
"""

Expand Down
27 changes: 13 additions & 14 deletions sarpy/io/phase_history/cphd1_elements/ErrorParameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

from typing import Union, Tuple, Optional

from sarpy.io.xml.base import Serializable, ParametersCollection
from sarpy.io.xml.descriptors import FloatDescriptor, SerializableDescriptor, \
ParametersDescriptor
from sarpy.io.xml.base import Serializable
from sarpy.io.xml.descriptors import FloatDescriptor, SerializableDescriptor
from sarpy.io.complex.sicd_elements.blocks import ErrorDecorrFuncType
from sarpy.io.complex.sicd_elements.ErrorStatistics import PosVelErrType, TropoErrorType

from .base import DEFAULT_STRICT, FLOAT_FORMAT
from .blocks import AddedParametersType


class RadarSensorType(Serializable):
Expand Down Expand Up @@ -71,7 +71,8 @@ class IonoErrorType(Serializable):

_fields = ('IonoRangeVertical', 'IonoRangeRateVertical', 'IonoRgRgRateCC', 'IonoRangeVertDecorr')
_required = ('IonoRgRgRateCC', )
_numeric_format = {'IonoRangeVertical': FLOAT_FORMAT, 'IonoRangeRateVertical': FLOAT_FORMAT, 'IonoRgRgRateCC': FLOAT_FORMAT}
_numeric_format = {'IonoRangeVertical': FLOAT_FORMAT, 'IonoRangeRateVertical': FLOAT_FORMAT,
'IonoRgRgRateCC': FLOAT_FORMAT}
# descriptors
IonoRangeVertical = FloatDescriptor(
'IonoRangeVertical', _required, strict=DEFAULT_STRICT, bounds=(0, None),
Expand Down Expand Up @@ -169,7 +170,6 @@ class MonostaticType(Serializable):

_fields = ('PosVelErr', 'RadarSensor', 'TropoError', 'IonoError', 'AddedParameters')
_required = ('PosVelErr', 'RadarSensor')
_collections_tags = {'AddedParameters': {'array': False, 'child_tag': 'Parameter'}}
# descriptors
PosVelErr = SerializableDescriptor(
'PosVelErr', PosVelErrType, _required, strict=DEFAULT_STRICT,
Expand All @@ -184,9 +184,9 @@ class MonostaticType(Serializable):
IonoError = SerializableDescriptor(
'IonoError', IonoErrorType, _required, strict=DEFAULT_STRICT,
docstring='Ionosphere delay error statistics.') # type: IonoErrorType
AddedParameters = ParametersDescriptor(
'AddedParameters', _collections_tags, _required, strict=DEFAULT_STRICT,
docstring='Additional error parameters.') # type: ParametersCollection
AddedParameters = SerializableDescriptor(
'AddedParameters', AddedParametersType, _required, strict=DEFAULT_STRICT,
docstring='Additional error parameters that may be added') # type: Union[None, AddedParametersType]

def __init__(self, PosVelErr=None, RadarSensor=None, TropoError=None, IonoError=None,
AddedParameters=None, **kwargs):
Expand All @@ -198,7 +198,7 @@ def __init__(self, PosVelErr=None, RadarSensor=None, TropoError=None, IonoError=
RadarSensor : RadarSensorType
TropoError : None|TropoErrorType
IonoError : None|IonoErrorType
AddedParameters : None|ParametersCollection|dict
AddedParameters : None|AddedParametersType
kwargs
"""

Expand Down Expand Up @@ -261,17 +261,16 @@ class BistaticType(Serializable):

_fields = ('TxPlatform', 'RcvPlatform', 'AddedParameters')
_required = ('TxPlatform', )
_collections_tags = {'AddedParameters': {'array': False, 'child_tag': 'Parameter'}}
# descriptors
TxPlatform = SerializableDescriptor(
'TxPlatform', PlatformType, _required, strict=DEFAULT_STRICT,
docstring='Error statistics for the transmit platform.') # type: PlatformType
RcvPlatform = SerializableDescriptor(
'RcvPlatform', PlatformType, _required, strict=DEFAULT_STRICT,
docstring='Error statistics for the receive platform.') # type: PlatformType
AddedParameters = ParametersDescriptor(
'AddedParameters', _collections_tags, _required, strict=DEFAULT_STRICT,
docstring='Additional error parameters.') # type: ParametersCollection
AddedParameters = SerializableDescriptor(
'AddedParameters', AddedParametersType, _required, strict=DEFAULT_STRICT,
docstring='Additional error parameters that may be added') # type: Union[None, AddedParametersType]

def __init__(self, TxPlatform=None, RcvPlatform=None, AddedParameters=None, **kwargs):
"""
Expand All @@ -280,7 +279,7 @@ def __init__(self, TxPlatform=None, RcvPlatform=None, AddedParameters=None, **kw
----------
TxPlatform : PlatformType
RcvPlatform : PlatformType
AddedParameters : None|ParametersCollection|dict
AddedParameters : None|AddedParametersType|dict
kwargs
"""

Expand Down
34 changes: 17 additions & 17 deletions sarpy/io/phase_history/cphd1_elements/GeoInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@


class LineType(Serializable):
_fields = ('EndPoint', 'size')
_required = ('EndPoint', 'size')
_fields = ('Endpoint', 'size')
_required = ('Endpoint', 'size')

def __init__(self, EndPoint=None, **kwargs):
def __init__(self, Endpoint=None, **kwargs):
"""
Parameters
----------
EndPoint : List[LatLonArrayElementType]|numpy.ndarray|list|tuple
Endpoint : List[LatLonArrayElementType]|numpy.ndarray|list|tuple
kwargs
"""

Expand All @@ -37,7 +37,7 @@ def __init__(self, EndPoint=None, **kwargs):
self._xml_ns = kwargs['_xml_ns']
if '_xml_ns_key' in kwargs:
self._xml_ns_key = kwargs['_xml_ns_key']
self.EndPoint = EndPoint
self.Endpoint = Endpoint
super(LineType, self).__init__(**kwargs)

@property
Expand All @@ -49,15 +49,15 @@ def size(self):
return 0 if self._array is None else self._array.size

@property
def EndPoint(self):
def Endpoint(self):
"""
numpy.ndarray: The array of points.
"""

return numpy.array([], dtype='object') if self._array is None else self._array

@EndPoint.setter
def EndPoint(self, value):
@Endpoint.setter
def Endpoint(self, value):
if value is None:
self._array = None
return
Expand All @@ -83,10 +83,10 @@ def EndPoint(self, value):
elif isinstance(entry, (numpy.ndarray, list, tuple)):
use_value.append(LatLonArrayElementType.from_array(entry, index=i+1))
else:
raise TypeError('Got unexpected type for element of EndPoint array `{}`'.format(type(entry)))
raise TypeError('Got unexpected type for element of Endpoint array `{}`'.format(type(entry)))
self._array = numpy.array(use_value, dtype='object')
else:
raise TypeError('Got unexpected type for EndPoint array `{}`'.format(type(value)))
raise TypeError('Got unexpected type for Endpoint array `{}`'.format(type(value)))

def __getitem__(self, item):
return self._array.__getitem__(item)
Expand All @@ -109,11 +109,11 @@ def from_node(cls, node, xml_ns, ns_key=None, kwargs=None):
LineType
"""

end_point_key = cls._child_xml_ns_key.get('EndPoint', ns_key)
end_point_key = cls._child_xml_ns_key.get('Endpoint', ns_key)
end_points = []
for cnode in find_children(node, 'EndPoint', xml_ns, end_point_key):
for cnode in find_children(node, 'Endpoint', xml_ns, end_point_key):
end_points.append(LatLonArrayElementType.from_node(cnode, xml_ns, ns_key=end_point_key))
return cls(EndPoint=end_points)
return cls(Endpoint=end_points)

def to_node(self, doc, tag, ns_key=None, parent=None, check_validity=False, strict=DEFAULT_STRICT, exclude=()):
if parent is None:
Expand All @@ -125,16 +125,16 @@ def to_node(self, doc, tag, ns_key=None, parent=None, check_validity=False, stri
node = create_new_node(doc, '{}:{}'.format(ns_key, tag), parent=parent)

node.attrib['size'] = str(self.size)
end_point_key = self._child_xml_ns_key.get('EndPoint', ns_key)
end_point_key = self._child_xml_ns_key.get('Endpoint', ns_key)

for entry in self.EndPoint:
entry.to_node(doc, 'EndPoint', ns_key=end_point_key, parent=node,
for entry in self.Endpoint:
entry.to_node(doc, 'Endpoint', ns_key=end_point_key, parent=node,
check_validity=check_validity, strict=strict)
return node

def to_dict(self, check_validity=False, strict=DEFAULT_STRICT, exclude=()):
return OrderedDict([
('EndPoint', [entry.to_dict() for entry in self.EndPoint]),
('Endpoint', [entry.to_dict() for entry in self.Endpoint]),
('size', self.size)])


Expand Down
Loading

0 comments on commit f8e5c0d

Please sign in to comment.