コード例 #1
0
ファイル: sicd.py プロジェクト: kirkjens/sarpy
    def _create_image_segment_details(self):
        super(SICDWriter, self)._create_image_segment_details()

        pixel_size, dtype, transform_data, pv_type, isubcat, image_segment_limits = self._image_parameters()
        img_groups = tuple(range(len(image_segment_limits)))
        self._img_groups = (img_groups, )

        iid2 = self._get_iid2()
        idatim = ' '
        if self.sicd_meta.Timeline is not None and self.sicd_meta.Timeline.CollectStart is not None:
            idatim = re.sub(r'[^0-9]', '', str(self.sicd_meta.Timeline.CollectStart.astype('datetime64[s]')))

        isource = self._get_isorce()

        icp, rows, cols = None, None, None
        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)
            rows = self.sicd_meta.ImageData.NumRows
            cols = self.sicd_meta.ImageData.NumCols
        abpp = 4*pixel_size
        bands = [ImageBand(ISUBCAT=entry) for entry in isubcat]

        img_details = []

        for i, entry in enumerate(image_segment_limits):
            if i == 0:
                iloc = '0000000000'
            else:
                prev_lims = image_segment_limits[i-1]
                prev_rows = prev_lims[1] - prev_lims[0]
                iloc = '{0:05d}00000'.format(prev_rows)

            this_rows = entry[1]-entry[0]
            this_cols = entry[3]-entry[2]
            subhead = ImageSegmentHeader(
                IID1='SICD{0:03d}'.format(0 if len(image_segment_limits) == 1 else i+1),
                IDATIM=idatim,
                IID2=iid2,
                ISORCE=isource,
                IREP='NODISPLY',
                ICAT='SAR',
                NROWS=this_rows,
                NCOLS=this_cols,
                PVTYPE=pv_type,
                ABPP=abpp,
                IGEOLO=interpolate_corner_points_string(numpy.array(entry, dtype=numpy.int64), rows, cols, icp),
                NBPC=1,
                NPPBH=get_npp_block(this_cols),
                NBPR=1,
                NPPBV=get_npp_block(this_rows),
                NBPP=abpp,
                IDLVL=i+1,
                IALVL=i,
                ILOC=iloc,
                Bands=ImageBands(values=bands),
                Security=self._security_tags)
            img_details.append(ImageDetails(2, dtype, transform_data, entry, subhead))

        self._img_details = tuple(img_details)
コード例 #2
0
    def _create_image_segment(self, index, img_groups, img_details):
        cur_count = len(img_details)
        pixel_size, abpp, irep, raw_dtype, transform_data, pv_type, band_count, irepband, \
            image_segment_limits = self._image_parameters(index)
        new_count = len(image_segment_limits)
        img_groups.append(tuple(range(cur_count, cur_count + new_count)))
        security = self._get_security_tags(index)

        iid2 = self._get_iid2(index)
        sidd = self.sidd_meta[index]

        idatim = self._get_fdt()

        isorce = self._get_isorce(index)

        rows = sidd.Measurement.PixelFootprint.Row
        cols = sidd.Measurement.PixelFootprint.Col

        icp = self._get_icp(sidd)
        bands = [ImageBand(ISUBCAT='', IREPBAND=entry) for entry in irepband]

        for i, entry in enumerate(image_segment_limits):
            if i == 0:
                iloc = '0000000000'
            else:
                prev_lims = image_segment_limits[i - 1]
                prev_rows = prev_lims[1] - prev_lims[0]
                iloc = '{0:05d}00000'.format(prev_rows)

            this_rows = entry[1] - entry[0]
            this_cols = entry[3] - entry[2]
            subhead = ImageSegmentHeader(
                IID1='SIDD{0:03d}{1:03d}'.format(len(img_groups), i + 1),
                IDATIM=idatim,
                IID2=iid2,
                ISORCE=isorce,
                IREP=irep,
                ICAT='SAR',
                NROWS=this_rows,
                NCOLS=this_cols,
                PVTYPE=pv_type,
                ABPP=abpp,
                IGEOLO=interpolate_corner_points_string(
                    numpy.array(entry, dtype=numpy.int64), rows, cols, icp),
                IMODE='P',
                NPPBH=get_npp_block(this_cols),
                NPPBV=get_npp_block(this_rows),
                NBPP=abpp,
                IDLVL=i + 1 + len(img_details),
                IALVL=i + len(img_details),
                ILOC=iloc,
                Bands=ImageBands(values=bands),
                Security=security)
            img_details.append(
                ImageDetails(band_count, raw_dtype, transform_data, entry,
                             subhead))
コード例 #3
0
ファイル: sidd.py プロジェクト: Bob-Asian/sarpy
    def _create_image_segment(self, index, img_groups, img_details):
        cur_count = len(img_details)
        pixel_size, abpp, irep, dtype, complex_type, pv_type, band_count, irepband, \
            image_segment_limits = self._image_parameters(index)
        new_count = len(image_segment_limits)
        img_groups.append(tuple(range(cur_count, cur_count + new_count)))
        security = self._get_security_tags(index)

        iid2 = self._get_iid2(index)
        sidd = self.sidd_meta[index]

        idatim = self._get_fdt()

        isorce = ''
        if sidd.ExploitationFeatures.Collections[
                0].Information.SensorName is not None:
            isorce = sidd.ExploitationFeatures.Collections[
                0].Information.SensorName

        rows = sidd.Measurement.PixelFootprint.Row
        cols = sidd.Measurement.PixelFootprint.Col

        icp = self._get_icp(sidd)
        bands = [ImageBand(ISUBCAT='', IREPBAND=entry) for entry in irepband]

        for i, entry in enumerate(image_segment_limits):
            this_rows = entry[1] - entry[0]
            this_cols = entry[3] - entry[2]
            subhead = ImageSegmentHeader(
                IID1='SIDD{0:03d}{1:03d}'.format(len(img_groups), i + 1),
                IDATIM=idatim,
                IID2=iid2,
                ISORCE=isorce,
                IREP=irep,
                ICAT='SAR',
                NROWS=this_rows,
                NCOLS=this_cols,
                PVTYPE=pv_type,
                ABPP=abpp,
                IGEOLO=interpolate_corner_points_string(
                    numpy.array(entry, dtype=numpy.int64), rows, cols, icp),
                IMODE='P' if irep == 'RGB' else 'B',
                NPPBH=get_npp_block(this_cols),
                NPPBV=get_npp_block(this_rows),
                NBPP=abpp,
                IDLVL=i + 1 + len(img_details),
                IALVL=i + len(img_details),
                ILOC='{0:05d}{1:05d}'.format(entry[0], entry[2]),
                Bands=ImageBands(values=bands),
                Security=security)
            img_details.append(
                ImageDetails(band_count, dtype, complex_type, entry, subhead))