Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
array_extension=SerializableArray):
if not issubclass(array_extension, SerializableArray):
raise TypeError('array_extension must be a subclass of SerializableArray.')
self.child_type = child_type
tags = tag_dict[name]
self.array = tags.get('array', False)
if not self.array:
raise ValueError(
'Attribute {} is populated in the `_collection_tags` dictionary without `array`=True. '
'This is inconsistent with using _SerializableArrayDescriptor.'.format(name))
self.child_tag = tags['child_tag']
self._typ_string = 'numpy.ndarray[{}]:'.format(str(child_type).strip().split('.')[-1][:-2])
self.array_extension = array_extension
self.minimum_length = self._DEFAULT_MIN_LENGTH if minimum_length is None else int_func(minimum_length)
self.maximum_length = self._DEFAULT_MAX_LENGTH if maximum_length is None else int_func(maximum_length)
if self.minimum_length > self.maximum_length:
raise ValueError(
'Specified minimum length is {}, while specified maximum length is {}'.format(
self.minimum_length, self.maximum_length))
super(_SerializableArrayDescriptor, self).__init__(name, required, strict=strict, docstring=docstring)
'/dopplerCentroidCoefficients').text.split()],
dtype=numpy.float64)
doppler_cent_ref_time = float(self._find('./dopplerCentroid'
'/dopplerCentroidEstimate'
'/dopplerCentroidReferenceTime').text)
doppler_cent_time_est = parse_timestring(self._find('./dopplerCentroid'
'/dopplerCentroidEstimate'
'/timeOfDopplerCentroidEstimate').text)
else:
raise ValueError('unhandled generation {}'.format(self.generation))
doppler_cent_poly = Poly1DType(Coefs=doppler_cent_coeffs)
alpha = 2.0/speed_of_light
t_0 = doppler_cent_ref_time - alpha*inca.R_CA_SCP
scaled_coeffs = doppler_cent_poly.shift(t_0, alpha, return_poly=False)
inca.DopCentroidPoly = Poly2DType(Coefs=numpy.reshape(scaled_coeffs, (scaled_coeffs.size, 1)))
# adjust doppler centroid for spotlight, we need to add a second
# dimension to DopCentroidPoly
if collection_info.RadarMode.ModeType == 'SPOTLIGHT':
doppler_cent_est = get_seconds(doppler_cent_time_est, start_time, precision='us')
doppler_cent_col = (doppler_cent_est - time_scp_zd)/col_spacing_zd
dop_poly = numpy.zeros((scaled_coeffs.shape[0], 2), dtype=numpy.float64)
dop_poly[:, 0] = scaled_coeffs
dop_poly[0, 1] = -look*center_freq*alpha*numpy.sqrt(vel_ca_squared)/inca.R_CA_SCP
# dopplerCentroid in native metadata was defined at specific column,
# which might not be our SCP column. Adjust so that SCP column is correct.
dop_poly[0, 0] = dop_poly[0, 0] - (dop_poly[0, 1]*doppler_cent_col*grid.Col.SS)
inca.DopCentroidPoly = Poly2DType(Coefs=dop_poly)
grid.Col.DeltaKCOAPoly = Poly2DType(Coefs=inca.DopCentroidPoly.get_array()*col_spacing_zd/grid.Col.SS)
# compute grid.Col.DeltaK1/K2 from DeltaKCOAPoly
coeffs = grid.Col.DeltaKCOAPoly.get_array()[:, 0]
def create_poly(arr, poly_order=2):
rg_poly = polynomial.polyfit(coords_rg.flatten(), arr.flatten(), poly_order)
az_poly = polynomial.polyfit(coords_az.flatten(), arr.flatten(), poly_order)
return Poly2DType(Coefs=numpy.outer(az_poly/numpy.max(az_poly), rg_poly))
ss_scale = numpy.sqrt(vel_ca_squared)*inca.DRateSFPoly[0, 0]
grid.Col.SS = col_spacing_zd*ss_scale
grid.Col.ImpRespBW = -look*doppler_bandwidth/ss_scale
inca.TimeCAPoly = Poly1DType(Coefs=[time_scp_zd, 1./ss_scale])
# doppler centroid
if self.generation == 'RS2':
doppler_cent_coeffs = numpy.array(
[float(entry) for entry in self._find('./imageGenerationParameters'
'/dopplerCentroid'
'/dopplerCentroidCoefficients').text.split()],
dtype=numpy.float64)
doppler_cent_ref_time = float(self._find('./imageGenerationParameters'
'/dopplerCentroid'
'/dopplerCentroidReferenceTime').text)
doppler_cent_time_est = parse_timestring(self._find('./imageGenerationParameters'
'/dopplerCentroid'
'/timeOfDopplerCentroidEstimate').text)
elif self.generation == 'RCM':
doppler_cent_coeffs = numpy.array(
[float(entry) for entry in self._find('./dopplerCentroid'
'/dopplerCentroidEstimate'
'/dopplerCentroidCoefficients').text.split()],
dtype=numpy.float64)
doppler_cent_ref_time = float(self._find('./dopplerCentroid'
'/dopplerCentroidEstimate'
'/dopplerCentroidReferenceTime').text)
doppler_cent_time_est = parse_timestring(self._find('./dopplerCentroid'
'/dopplerCentroidEstimate'
'/timeOfDopplerCentroidEstimate').text)
else:
raise ValueError('unhandled generation {}'.format(self.generation))
def check_module(module_name):
# import the module
import_module(module_name)
# fetch the module from the modules dict
module = sys.modules[module_name]
# check all classes of the module itself
for element_name, element_type in inspect.getmembers(module, inspect.isclass):
if issubclass(element_type, TREExtension) and element_type != TREExtension:
register_tre(element_type, tre_id=element_name, replace=False)
# walk down any subpackages
path, fil = os.path.split(module.__file__)
if not fil.startswith('__init__.py'):
# there are no subpackages
return
for sub_module in pkgutil.walk_packages([path, ]):
_, sub_module_name, _ = sub_module
sub_name = "{}.{}".format(module_name, sub_module_name)
check_module(sub_name)
_required = ('DomainType', 'SGN', 'Timeline', 'FxBand', 'TOASwath')
# descriptors
DomainType = _StringEnumDescriptor(
'DomainType', ('FX', 'TOA'), _required, strict=DEFAULT_STRICT,
docstring='Indicates the domain represented by the sample dimension of the '
'CPHD signal array(s), where "FX" denotes Transmit Frequency, and '
'"TOA" denotes Difference in Time of Arrival') # type: str
SGN = _IntegerEnumDescriptor(
'SGN', (-1, 1), _required, strict=DEFAULT_STRICT,
docstring='Phase SGN applied to compute target signal phase as a function of '
r'target :math:`\Delta TOA^{TGT}`. Target phase in cycles. '
r'For simple phase model :math:`Phase(fx) = SGN \times fx \times \Delta TOA^{TGT}` '
r'In TOA domain, phase of the mainlobe peak '
r':math:`Phase(\Delta TOA^{TGT}) = SGN \times fx_C \times \Delta TOA^{TGT}`'
'.') # type: int
Timeline = _SerializableDescriptor(
'Timeline', TimelineType, _required, strict=DEFAULT_STRICT,
docstring='Parameters that describe the collection times for the data contained '
'in the product') # type: TimelineType
FxBand = _SerializableDescriptor(
'FxBand', FxBandType, _required, strict=DEFAULT_STRICT,
docstring='Parameters that describe the FX frequency limits for the signal array(s) '
'contained in the product.') # type: FxBandType
TOASwath = _SerializableDescriptor(
'TOASwath', TOASwathType, _required, strict=DEFAULT_STRICT,
docstring='Parameters that describe the time-of-arrival (TOA) swath limits for the '
'signal array(s) contained in the product.') # type: TOASwathType
TropoParameters = _SerializableDescriptor(
'TropoParameters', TropoParametersType, _required, strict=DEFAULT_STRICT,
docstring='Parameters used to compute the propagation delay due to the '
'troposphere.') # type: Union[None, TropoParametersType]
IonoParameters = _SerializableDescriptor(
FXN2 = _SerializableDescriptor(
'FXN2', PerVectorParameterF8, _required, strict=DEFAULT_STRICT,
docstring='') # type: PerVectorParameterF8
TOA1 = _SerializableDescriptor(
'TOA1', PerVectorParameterF8, _required, strict=DEFAULT_STRICT,
docstring='') # type: PerVectorParameterF8
TOA2 = _SerializableDescriptor(
'TOA2', PerVectorParameterF8, _required, strict=DEFAULT_STRICT,
docstring='') # type: PerVectorParameterF8
TOAE1 = _SerializableDescriptor(
'TOAE1', PerVectorParameterF8, _required, strict=DEFAULT_STRICT,
docstring='') # type: PerVectorParameterF8
TOAE2 = _SerializableDescriptor(
'TOAE2', PerVectorParameterF8, _required, strict=DEFAULT_STRICT,
docstring='') # type: PerVectorParameterF8
TDTropoSRP = _SerializableDescriptor(
'TDTropoSRP', PerVectorParameterF8, _required, strict=DEFAULT_STRICT,
docstring='') # type: PerVectorParameterF8
TDIonoSRP = _SerializableDescriptor(
'TDIonoSRP', PerVectorParameterF8, _required, strict=DEFAULT_STRICT,
docstring='') # type: PerVectorParameterF8
SC0 = _SerializableDescriptor(
'SC0', PerVectorParameterF8, _required, strict=DEFAULT_STRICT,
docstring='') # type: PerVectorParameterF8
SCSS = _SerializableDescriptor(
'SCSS', PerVectorParameterF8, _required, strict=DEFAULT_STRICT,
docstring='') # type: PerVectorParameterF8
SIGNAL = _SerializableDescriptor(
'SIGNAL', PerVectorParameterI8, _required, strict=DEFAULT_STRICT,
docstring='') # type: PerVectorParameterI8
AddedPVP = _SerializableListDescriptor(
'AddedPVP', UserDefinedPVPType, _collections_tags, _required, strict=DEFAULT_STRICT,
self.Verticals = Verticals
super(AccuracyType, self).__init__(**kwargs)
class PositionalAccuracyType(Serializable):
"""
Describes the horizontal and vertical point and regional information for the DED.
"""
_fields = ('NumRegions', 'AbsoluteAccuracy', 'PointToPointAccuracy')
_required = ('NumRegions', 'AbsoluteAccuracy', 'PointToPointAccuracy')
# Descriptor
NumRegions = _IntegerDescriptor(
'NumRegions', _required, strict=DEFAULT_STRICT,
docstring='Number of positional accuracy regions.') # type: int
AbsoluteAccuracy = _SerializableDescriptor(
'AbsoluteAccuracy', AccuracyType, _required, strict=DEFAULT_STRICT,
docstring='') # type: AccuracyType
PointToPointAccuracy = _SerializableDescriptor(
'PointToPointAccuracy', AccuracyType, _required, strict=DEFAULT_STRICT,
docstring='') # type: AccuracyType
def __init__(self, NumRegions=None, AbsoluteAccuracy=None, PointToPointAccuracy=None, **kwargs):
"""
Parameters
----------
NumRegions : int
AbsoluteAccuracy : AccuracyType
PointToPointAccuracy : AccuracyType
kwargs
"""
'EarthModel', 'IARP', 'ReferenceSurface', 'ImageArea', 'ImageAreaCornerPoints',
'ExtendedArea', 'ImageGrid')
_required = ('EarthModel', 'IARP', 'ReferenceSurface', 'ImageArea', 'ImageAreaCornerPoints')
_collections_tags = {
'ImageAreaCornerPoints': {'array': True, 'child_tag': 'IACP'}}
# descriptors
EarthModel = _StringEnumDescriptor(
'EarthModel', ('WGS_84', ), _required, strict=DEFAULT_STRICT, default_value='WGS_84',
docstring='Specifies the earth model used for specifying geodetic coordinates. All heights are '
'Height Above the Ellipsoid (HAE) unless specifically '
'noted.') # type: str
IARP = _SerializableDescriptor(
'IARP', IARPType, _required, strict=DEFAULT_STRICT,
docstring='Image Area Reference Point (IARP). The IARP is the origin of '
'the Image Area Coordinate system.') # type: IARPType
ReferenceSurface = _SerializableDescriptor(
'ReferenceSurface', ReferenceSurfaceType, _required, strict=DEFAULT_STRICT,
docstring='Parameters that define the Reference Surface used for the '
'product.') # type: ReferenceSurfaceType
ImageArea = _SerializableDescriptor(
'ImageArea', AreaType, _required, strict=DEFAULT_STRICT,
docstring='Image Area is defined by a rectangle aligned with Image Area coordinates (IAX, IAY). '
'May be reduced by the optional polygon.') # type: AreaType
ImageAreaCornerPoints = _SerializableCPArrayDescriptor(
'ImageAreaCornerPoints', LatLonCornerType, _collections_tags, _required, strict=DEFAULT_STRICT,
docstring='Image Area Corner Points (IACPs) that bound the full resolution '
'image area.') # type: Union[SerializableCPArray, List[LatLonCornerType]]
ExtendedArea = _SerializableDescriptor(
'ExtendedArea', AreaType, _required, strict=DEFAULT_STRICT,
docstring='Extended Area is defined by a rectangle aligned with Image Area coordinates '
'(IAX, IAY). May be reduced by the optional polygon.') # type: Union[None, AreaType]
ImageGrid = _SerializableDescriptor(
self.uIAYLL = uIAYLL
super(LLPlanarType, self).__init__(**kwargs)
class ReferenceSurfaceType(Serializable):
"""
Parameters that define the Reference Surface used for the product.
"""
_fields = ('Planar', 'HAE')
_required = ()
_choice = ({'required': True, 'collection': _fields}, )
# descriptors
Planar = _SerializableDescriptor(
'Planar', ECFPlanarType, _required, strict=DEFAULT_STRICT,
docstring='The ECF planar surface definition.') # type: Union[None, ECFPlanarType]
HAE = _SerializableDescriptor(
'HAE', LLPlanarType, _required, strict=DEFAULT_STRICT,
docstring='The HAE surface definition.') # type: Union[None, LLPlanarType]
def __init__(self, Planar=None, HAE=None, **kwargs):
"""
Parameters
----------
Planar : ECFPlanarType|None
HAE : LLPlanarType|None
kwargs
"""
if '_xml_ns' in kwargs:
self._xml_ns = kwargs['_xml_ns']
if '_xml_ns_key' in kwargs: