Exemplo n.º 1
0
class GlobalType(Serializable):
    """
    The Global type definition.
    """

    _fields = (
        'DomainType', 'SGN', 'Timeline', 'FxBand', 'TOASwath', 'TropoParameters', 'IonoParameters')
    _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(
        'IonoParameters', IonoParametersType, _required, strict=DEFAULT_STRICT,
        docstring='Parameters used to compute propagation effects due to the '
                  'ionosphere.')  # type: Union[None, IonoParametersType]

    def __init__(self, DomainType=None, SGN=None, Timeline=None, FxBand=None, TOASwath=None,
                 TropoParameters=None, IonoParameters=None, **kwargs):
        """

        Parameters
        ----------
        DomainType : str
        SGN : int
        Timeline : TimelineType
        FxBand : FxBandType|numpy.ndarray|list|tuple
        TOASwath : TOASwathType|numpy.ndarray|list|tuple
        TropoParameters : None|TropoParametersType
        IonoParameters : None|IonoParametersType
        kwargs
        """

        if '_xml_ns' in kwargs:
            self._xml_ns = kwargs['_xml_ns']
        if '_xml_ns_key' in kwargs:
            self._xml_ns_key = kwargs['_xml_ns_key']
        self.DomainType = DomainType
        self.SGN = SGN
        self.Timeline = Timeline
        self.FxBand = FxBand
        self.TOASwath = TOASwath
        self.TropoParameters = TropoParameters
        self.IonoParameters = IonoParameters
        super(GlobalType, self).__init__(**kwargs)
Exemplo n.º 2
0
class GlobalType(Serializable):
    """
    The Global type definition.
    """

    _fields = (
        'DomainType', 'PhaseSGN', 'RefFreqIndex', 'CollectStart',
        'CollectDuration', 'TxTime1', 'TxTime2', 'ImageArea')
    _required = (
        'DomainType', 'PhaseSGN', 'CollectStart', 'CollectDuration',
        'TxTime1', 'TxTime2', 'ImageArea')
    _numeric_format = {
        'CollectDuration': '0.16G', 'TxTime1': '0.16G', 'TxTime2': '0.16G'}
    # 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
    PhaseSGN = _IntegerEnumDescriptor(
        'PhaseSGN', (-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
    RefFreqIndex = _IntegerDescriptor(
        'RefFreqIndex', _required, strict=DEFAULT_STRICT,
        docstring='Indicates if the RF frequency values are expressed as offsets from '
                  'a reference frequency (RefFreq).')  # type: Union[None, int]
    CollectStart = _DateTimeDescriptor(
        'CollectStart', _required, strict=DEFAULT_STRICT, numpy_datetime_units='us',
        docstring='Collection Start date and time (UTC). Time reference used for times '
                  'measured from collection start (i.e. slow time t = 0). For bistatic '
                  'collections, the time is the transmit platform collection '
                  'start time. The default display precision is microseconds, but this '
                  'does not that accuracy in value.')  # type: numpy.datetime64
    CollectDuration = _FloatDescriptor(
        'CollectDuration', _required, strict=DEFAULT_STRICT,
        docstring='The duration of the collection, in seconds.')  # type: float
    TxTime1 = _FloatDescriptor(
        'TxTime1', _required, strict=DEFAULT_STRICT, bounds=(0, None),
        docstring='Earliest TxTime value for any signal vector in the product. '
                  'Time relative to Collection Start in seconds.')  # type: float
    TxTime2 = _FloatDescriptor(
        'TxTime2', _required, strict=DEFAULT_STRICT, bounds=(0, None),
        docstring='Latest TxTime value for any signal vector in the product. '
                  'Time relative to Collection Start in seconds.')  # type: float
    ImageArea = _SerializableDescriptor(
        'ImageArea', ImageAreaType, _required, strict=DEFAULT_STRICT,
        docstring='Parameters describing the ground area covered by this '
                  'product.')  # type: ImageAreaType

    def __init__(self, DomainType=None, PhaseSGN=None, RefFreqIndex=None, CollectStart=None,
                 CollectDuration=None, TxTime1=None, TxTime2=None, ImageArea=None, **kwargs):
        """

        Parameters
        ----------
        DomainType : str
        PhaseSGN : int
        RefFreqIndex : None|int
        CollectStart : numpy.datetime64|datetime.datetime|str
        CollectDuration : float
        TxTime1 : float
        TxTime2 : float
        ImageArea : ImageAreaType
        kwargs
        """

        if '_xml_ns' in kwargs:
            self._xml_ns = kwargs['_xml_ns']
        if '_xml_ns_key' in kwargs:
            self._xml_ns_key = kwargs['_xml_ns_key']
        self.DomainType = DomainType
        self.PhaseSGN = PhaseSGN
        self.RefFreqIndex = RefFreqIndex
        self.CollectStart = CollectStart
        self.CollectDuration = CollectDuration
        self.TxTime1 = TxTime1
        self.TxTime2 = TxTime2
        self.ImageArea = ImageArea
        super(GlobalType, self).__init__(**kwargs)
Exemplo n.º 3
0
class VectorParametersType(Serializable):
    """
    The vector parameters sizes object.
    """

    _fields = ('TxTime', 'TxPos', 'RcvTime', 'RcvPos', 'SRPTime', 'SRPPos',
               'AmpSF', 'TropoSRP', 'FxParameters', 'TOAParameters')
    _required = ('TxTime', 'TxPos', 'RcvTime', 'RcvPos', 'SRPPos')
    _choice = ({
        'required': False,
        'collection': ('FxParameters', 'TOAParameters')
    }, )
    # descriptors
    TxTime = _IntegerEnumDescriptor(
        'TxTime', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the TxTime field')  # type: int
    TxPos = _IntegerEnumDescriptor(
        'TxPos', (24, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the TxPos field')  # type: int
    RcvTime = _IntegerEnumDescriptor(
        'RcvTime', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the RcvTime field')  # type: int
    RcvPos = _IntegerEnumDescriptor(
        'RcvPos', (24, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the RcvPos field')  # type: int
    SRPTime = _IntegerEnumDescriptor(
        'SRPTime', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=None,
        docstring='The size of the SRPTime field')  # type: int
    SRPPos = _IntegerEnumDescriptor(
        'SRPPos', (24, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the SRPPos field')  # type: int
    AmpSF = _IntegerEnumDescriptor(
        'AmpSF', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=None,
        docstring='The size of the AmpSF field')  # type: int
    TropoSRP = _IntegerEnumDescriptor(
        'TropoSRP', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=None,
        docstring='The size of the TropoSRP field')  # type: int
    FxParameters = _SerializableDescriptor(
        'FxParameters',
        FxParametersType,
        _required,
        strict=DEFAULT_STRICT,
        docstring='The frequency parameters, only present when DomainType is '
        'FX.')  # type: Union[None, FxParametersType]
    TOAParameters = _SerializableDescriptor(
        'TOAParameters',
        FxParametersType,
        _required,
        strict=DEFAULT_STRICT,
        docstring='The TOA parameters, only present when DomainType is '
        'TOA.')  # type: Union[None, TOAParametersType]

    def __init__(self,
                 TxTime=8,
                 TxPos=24,
                 RcvTime=8,
                 RcvPos=24,
                 SRPTime=None,
                 SRPPos=24,
                 AmpSF=None,
                 TropoSRP=None,
                 FxParameters=None,
                 TOAParameters=None,
                 **kwargs):
        """

        Parameters
        ----------
        TxTime : int
        TxPos : int
        RcvTime : int
        RcvPos : int
        SRPTime : None|int
        SRPPos : int
        AmpSF : None|int
        TropoSRP : None|int
        FxParameters : None|FxParametersType
        TOAParameters : None|TOAParametersType
        kwargs
        """

        if '_xml_ns' in kwargs:
            self._xml_ns = kwargs['_xml_ns']
        if '_xml_ns_key' in kwargs:
            self._xml_ns_key = kwargs['_xml_ns_key']
        self.TxTime = TxTime
        self.TxPos = TxPos
        self.RcvTime = RcvTime
        self.RcvPos = RcvPos
        self.SRPTime = SRPTime
        self.SRPPos = SRPPos
        self.AmpSF = AmpSF
        self.TropoSRP = TropoSRP
        self.FxParameters = FxParameters
        self.TOAParameters = TOAParameters
        super(VectorParametersType, self).__init__(**kwargs)

    def get_size(self):
        """
        The size in bytes of this component of the vector.

        Returns
        -------
        int
        """

        out = 0
        for fld in self._fields:
            val = getattr(self, fld)
            if val is None:
                pass
            elif isinstance(val, integer_types):
                out += val
            elif isinstance(val, (FxParametersType, TOAParametersType)):
                out += val.get_size()
            else:
                raise TypeError('Got unhandled type {}'.format(type(val)))
        return out

    def get_position_offset_and_size(self, field):
        """
        Get the offset and size of the given field from the beginning of the vector.

        Parameters
        ----------
        field : str

        Returns
        -------
        None|(int, int)
        """

        out = 0
        for fld in self._fields:
            val = getattr(self, fld)
            if fld == field:
                if val is not None:
                    return out, val
                else:
                    return None

            if val is None:
                pass
            elif isinstance(val, integer_types):
                out += val
            elif isinstance(val, (FxParametersType, TOAParametersType)):
                res = val.get_position_offset_and_size(field)
                if res is not None:
                    return out + res[0], res[1]
                else:
                    out += val.get_size()
            else:
                raise TypeError('Got unhandled type {}'.format(type(val)))
        return None

    def get_vector_dtype(self):
        """
        Gets the dtype for the corresponding structured array for the full PVP array.

        Returns
        -------
        numpy.dtype
            This will be a compound dtype for a structured array.
        """

        the_type_info = []
        for fld in self._fields:
            val = getattr(self, fld)
            if val is None:
                continue
            if fld in ['FxParameters', 'TOAParameters']:
                the_type_info.extend(val.get_dtype_components())
            else:
                assert isinstance(
                    val, integer_types
                ), 'CPHD 0.3 PVP field {} should be an integer, got {}'.format(
                    fld, val)
                if val == 8:
                    the_type_info.append((fld, '>f8'))
                elif val == 24:
                    the_type_info.append((fld, '>f8', (3, )))
                else:
                    raise ValueError(
                        'Got unhandled value {} for CPHD 0.3 PVP field {}'.
                        format(val, fld))
        return numpy.dtype(the_type_info)
Exemplo n.º 4
0
class FxParametersType(Serializable):
    """
    The FX vector parameters.
    """

    _fields = ('Fx0', 'Fx_SS', 'Fx1', 'Fx2')
    _required = _fields
    # descriptors
    Fx0 = _IntegerEnumDescriptor(
        'Fx0', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the Fx0 field')  # type: int
    Fx_SS = _IntegerEnumDescriptor(
        'Fx_SS', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the Fx_SS field')  # type: int
    Fx1 = _IntegerEnumDescriptor(
        'Fx1', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the Fx1 field')  # type: int
    Fx2 = _IntegerEnumDescriptor(
        'Fx2', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the Fx2 field')  # type: int

    def __init__(self, Fx0=8, Fx_SS=8, Fx1=8, Fx2=8, **kwargs):
        if '_xml_ns' in kwargs:
            self._xml_ns = kwargs['_xml_ns']
        if '_xml_ns_key' in kwargs:
            self._xml_ns_key = kwargs['_xml_ns_key']
        self.Fx0 = Fx0
        self.Fx1 = Fx1
        self.Fx2 = Fx2
        self.Fx_SS = Fx_SS
        super(FxParametersType, self).__init__(**kwargs)

    @staticmethod
    def get_size():
        """
        The size in bytes of this component of the vector.

        Returns
        -------
        int
        """

        return 32

    def get_position_offset_and_size(self, field):
        """
        Get the offset and size of the given field from the beginning of the vector.

        Parameters
        ----------
        field : str

        Returns
        -------
        None|int
        """

        if field not in self._fields:
            return None

        out = 0
        for fld in self._fields:
            val = getattr(self, fld)
            if fld == field:
                return out, val
            else:
                out += val
        return None

    def get_dtype_components(self):
        """
        Gets the dtype components.

        Returns
        -------
        List[Tuple]
        """

        return [(entry, '>f8') for entry in self._fields]
Exemplo n.º 5
0
class TOAParametersType(Serializable):
    """
    The TOA vector parameters.
    """

    _fields = ('DeltaTOA0', 'TOA_SS')
    _required = _fields
    # descriptors
    DeltaTOA0 = _IntegerEnumDescriptor(
        'DeltaTOA0', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the DeltaTOA0 field')  # type: int
    TOA_SS = _IntegerEnumDescriptor(
        'TOA_SS', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the TOA_SS field')  # type: int

    def __init__(self, DeltaTOA0=8, TOA_SS=8, **kwargs):
        if '_xml_ns' in kwargs:
            self._xml_ns = kwargs['_xml_ns']
        if '_xml_ns_key' in kwargs:
            self._xml_ns_key = kwargs['_xml_ns_key']
        self.DeltaTOA0 = DeltaTOA0
        self.TOA_SS = TOA_SS
        super(TOAParametersType, self).__init__(**kwargs)

    @staticmethod
    def get_size():
        """
        The size in bytes of this component of the vector.

        Returns
        -------
        int
        """

        return 16

    def get_position_offset_and_size(self, field):
        """
        Get the offset and size of the given field from the beginning of the vector.

        Parameters
        ----------
        field : str

        Returns
        -------
        None|(int, int)
        """

        if field not in self._fields:
            return None

        out = 0
        for fld in self._fields:
            val = getattr(self, fld)
            if fld == field:
                return out, val
            else:
                out += val
        return None
Exemplo n.º 6
0
class VectorParametersType(Serializable):
    """
    The vector parameters sizes object.
    """

    _fields = ('TxTime', 'TxPos', 'RcvTime', 'RcvPos', 'SRPTime', 'SRPPos',
               'AmpSF', 'TropoSRP', 'FxParameters', 'TOAParameters')
    _required = ('TxTime', 'TxPos', 'RcvTime', 'RcvPos', 'SRPPos')
    _choice = [{
        'required': False,
        'collection': ('FxParameters', 'TOAParameters')
    }]
    # descriptors
    TxTime = _IntegerEnumDescriptor(
        'TxTime', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the TxTime field')  # type: int
    TxPos = _IntegerEnumDescriptor(
        'TxPos', (24, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the TxPos field')  # type: int
    RcvTime = _IntegerEnumDescriptor(
        'RcvTime', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the RcvTime field')  # type: int
    RcvPos = _IntegerEnumDescriptor(
        'RcvPos', (24, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the RcvPos field')  # type: int
    SRPTime = _IntegerEnumDescriptor(
        'SRPTime', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=None,
        docstring='The size of the SRPTime field')  # type: int
    SRPPos = _IntegerEnumDescriptor(
        'SRPPos', (24, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=8,
        docstring='The size of the SRPPos field')  # type: int
    AmpSF = _IntegerEnumDescriptor(
        'AmpSF', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=None,
        docstring='The size of the AmpSF field')  # type: int
    TropoSRP = _IntegerEnumDescriptor(
        'TropoSRP', (8, ),
        _required,
        strict=DEFAULT_STRICT,
        default_value=None,
        docstring='The size of the TropoSRP field')  # type: int
    FxParameters = _SerializableDescriptor(
        'FxParameters',
        FxParametersType,
        _required,
        strict=DEFAULT_STRICT,
        docstring='The frequency parameters, only present when DomainType is '
        'FX.')  # type: Union[None, FxParametersType]
    TOAParameters = _SerializableDescriptor(
        'TOAParameters',
        FxParametersType,
        _required,
        strict=DEFAULT_STRICT,
        docstring='The TOA parameters, only present when DomainType is '
        'TOA.')  # type: Union[None, TOAParametersType]

    def __init__(self,
                 TxTime=8,
                 TxPos=24,
                 RcvTime=8,
                 RcvPos=24,
                 SRPTime=None,
                 SRPPos=24,
                 AmpSF=None,
                 TropoSRP=None,
                 FxParameters=None,
                 TOAParameters=None,
                 **kwargs):
        """

        Parameters
        ----------
        TxTime : int
        TxPos : int
        RcvTime : int
        RcvPos : int
        SRPTime : None|int
        SRPPos : int
        AmpSF : None|int
        TropoSRP : None|int
        FxParameters : None|FxParametersType
        TOAParameters : None|TOAParametersType
        kwargs
        """

        if '_xml_ns' in kwargs:
            self._xml_ns = kwargs['_xml_ns']
        if '_xml_ns_key' in kwargs:
            self._xml_ns_key = kwargs['_xml_ns_key']
        self.TxTime = TxTime
        self.TxPos = TxPos
        self.RcvTime = RcvTime
        self.RcvPos = RcvPos
        self.SRPTime = SRPTime
        self.SRPPos = SRPPos
        self.AmpSF = AmpSF
        self.TropoSRP = TropoSRP
        self.FxParameters = FxParameters
        self.TOAParameters = TOAParameters
        super(VectorParametersType, self).__init__(**kwargs)

    def get_size(self):
        """
        The size in bytes of this component of the vector.

        Returns
        -------
        int
        """

        out = 0
        for fld in self._fields:
            val = getattr(self, fld)
            if val is None:
                pass
            elif isinstance(val, integer_types):
                out += val
            elif isinstance(val, (FxParametersType, TOAParametersType)):
                out += val.get_size()
            else:
                raise TypeError('Got unhandled type {}'.format(type(val)))
        return out

    def get_position_offset_and_size(self, field):
        """
        Get the offset and size of the given field from the beginning of the vector.

        Parameters
        ----------
        field : str

        Returns
        -------
        None|(int, int)
        """

        out = 0
        for fld in self._fields:
            val = getattr(self, fld)
            if fld == field:
                if val is not None:
                    return out, val
                else:
                    return None

            if val is None:
                pass
            elif isinstance(val, integer_types):
                out += val
            elif isinstance(val, (FxParametersType, TOAParametersType)):
                res = val.get_position_offset_and_size(field)
                if res is not None:
                    return out + res[0], res[1]
                else:
                    out += val.get_size()
            else:
                raise TypeError('Got unhandled type {}'.format(type(val)))
        return None