def _construct_chipper(self, segment, index): # get the image size sidd = self.sidd_meta[index] rows = sidd.Measurement.PixelFootprint.Row cols = sidd.Measurement.PixelFootprint.Col # extract the basic elements for the chippers dtype, dtype_out, bands_in, bands_out, complex_type = self._check_img_details( segment) if len(segment) == 1: return self._define_chipper(segment[0], dtype=dtype, bands_in=bands_in, complex_type=complex_type, dtype_out=dtype_out, bands_out=bands_out) else: # get the bounds definition bounds = self._get_chipper_partitioning(segment, rows, cols) # define the chippers chippers = [ self._define_chipper(img_index, dtype=dtype, bands_in=bands_in, complex_type=complex_type, dtype_out=dtype_out, bands_out=bands_out) for img_index in segment ] # define the aggregate chipper return AggregateChipper(bounds, dtype_out, chippers, bands_out=bands_out)
def _construct_chipper(self, segment, index): # get the image size sidd = self.sidd_meta[index] rows = sidd.Measurement.PixelFootprint.Row cols = sidd.Measurement.PixelFootprint.Col # extract the basic elements for the chippers raw_dtype, output_dtype, raw_bands, output_bands, transform_data = self._check_img_details( segment) if len(segment) == 1: return self._define_chipper(segment[0], raw_dtype=raw_dtype, raw_bands=raw_bands, transform_data=transform_data, output_dtype=output_dtype, output_bands=output_bands) else: # get the bounds definition bounds = self._get_chipper_partitioning(segment, rows, cols) # define the chippers chippers = [ self._define_chipper(img_index, raw_dtype=raw_dtype, raw_bands=raw_bands, transform_data=transform_data, output_dtype=output_dtype, output_bands=output_bands) for img_index in segment ] # define the aggregate chipper return AggregateChipper(bounds, output_dtype, chippers, output_bands=output_bands)
def _construct_chipper(self, segment, index): meta = self.sicd_meta pixel_type = meta.ImageData.PixelType # NB: SICDs are required to be stored as big-endian if pixel_type == 'RE32F_IM32F': raw_dtype = numpy.dtype('>f4') transform_data = 'COMPLEX' elif pixel_type == 'RE16I_IM16I': raw_dtype = numpy.dtype('>i2') transform_data = 'COMPLEX' elif pixel_type == 'AMP8I_PHS8I': raw_dtype = numpy.dtype('>u1') transform_data = amp_phase_to_complex(meta.ImageData.AmpTable) else: raise ValueError( 'Pixel Type {} not recognized.'.format(pixel_type)) # verify that the collective output of _extract_chipper_params makes sense for img_index in segment: inp_dtype, _, _, _, _ = self._extract_chipper_params(img_index) if inp_dtype.name != raw_dtype.name: raise ValueError( 'Image segment at index {} apparently has dtype {}, expected {} ' 'from the SICD definition'.format(img_index, inp_dtype, raw_dtype)) if len(segment) == 1: return self._define_chipper(segment[0], raw_dtype=raw_dtype, raw_bands=2, transform_data=transform_data, output_dtype='complex64', output_bands=1) else: # get the bounds definition bounds = self._get_chipper_partitioning(segment, meta.ImageData.NumRows, meta.ImageData.NumCols) # define the chippers collection chippers = [ self._define_chipper(img_index, raw_dtype=raw_dtype, raw_bands=2, transform_data=transform_data, output_dtype='complex64', output_bands=1) for img_index in segment ] # define the aggregate chipper return AggregateChipper(bounds, 'complex64', chippers, output_bands=1)