Exemplo n.º 1
0
    def _create_data_extension_details(self):
        super(SICDWriter, self)._create_data_extension_details()
        uh_args = self.sicd_meta.get_des_details()

        desshdt = str(self.sicd_meta.ImageCreation.DateTime.astype('datetime64[s]'))
        if desshdt[-1] != 'Z':
            desshdt += 'Z'
        uh_args['DESSHDT'] = desshdt

        desshlpg = ''
        if self.sicd_meta.GeoData is not None and self.sicd_meta.GeoData.ImageCorners is not None:
            # noinspection PyTypeChecker
            icp = self.sicd_meta.GeoData.ImageCorners.get_array(dtype=numpy.float64)
            temp = []
            for entry in icp:
                temp.append('{0:0=+12.8f}{1:0=+13.8f}'.format(entry[0], entry[1]))
            temp.append(temp[0])
            desshlpg = ''.join(temp)
        uh_args['DESSHLPG'] = desshlpg

        subhead = DataExtensionHeader(
            Security=self._security_tags,
            UserHeader=XMLDESSubheader(**uh_args))

        self._des_details = (
            DESDetails(subhead, self.sicd_meta.to_xml_bytes(tag='SICD')), )
Exemplo n.º 2
0
    def _create_sidd_des_segment(self, index):
        """
        Create the details for the sidd data extension at `index`.

        Parameters
        ----------
        index : int

        Returns
        -------
        DESDetails
        """

        imgs = self._img_groups[index]
        security = self.image_details[imgs[0]].subheader.Security
        sidd = self.sidd_meta[index]
        uh_args = sidd.get_des_details()

        try:
            desshdt = str(
                sidd.ProductCreation.ProcessorInformation.ProcessingDateTime.
                astype('datetime64[s]'))
        except AttributeError:
            desshdt = str(numpy.datetime64('now'))
        if desshdt[-1] != 'Z':
            desshdt += 'Z'
        uh_args['DESSHDT'] = desshdt

        desshlpg = ''
        icp = self._get_icp(sidd)
        if icp is not None:
            temp = []
            for entry in icp:
                temp.append('{0:0=+12.8f}{1:0=+13.8f}'.format(
                    entry[0], entry[1]))
            temp.append(temp[0])
            desshlpg = ''.join(temp)
        uh_args['DESSHLPG'] = desshlpg
        subhead = DataExtensionHeader(Security=security,
                                      UserHeader=XMLDESSubheader(**uh_args))
        return DESDetails(subhead, sidd.to_xml_bytes(tag='SIDD'))
Exemplo n.º 3
0
    def _create_sicd_des_segment(self, index):
        """
        Create the details for the sicd data extension at `index`.

        Parameters
        ----------
        index : int

        Returns
        -------
        DESDetails
        """

        security_tags = self.security_tags
        sicd = self.sicd_meta[index]
        uh_args = sicd.get_des_details(check_version1_compliance=True)
        if sicd.ImageCreation.DateTime is None:
            desshdt = datetime.utcnow().isoformat('T', timespec='seconds')
        else:
            desshdt = str(sicd.ImageCreation.DateTime.astype('datetime64[s]'))
        if desshdt[-1] != 'Z':
            desshdt += 'Z'
        uh_args['DESSHDT'] = desshdt

        desshlpg = ''
        if sicd.GeoData is not None and sicd.GeoData.ImageCorners is not None:
            # noinspection PyTypeChecker
            icp = sicd.GeoData.ImageCorners.get_array(dtype=numpy.float64)
            temp = []
            for entry in icp:
                temp.append('{0:0=+12.8f}{1:0=+13.8f}'.format(
                    entry[0], entry[1]))
            temp.append(temp[0])
            desshlpg = ''.join(temp)
        uh_args['DESSHLPG'] = desshlpg

        subhead = DataExtensionHeader(Security=security_tags,
                                      UserHeader=XMLDESSubheader(**uh_args))

        return DESDetails(
            subhead, sicd.to_xml_bytes(tag='SICD', urn=uh_args['DESSHTN']))