예제 #1
0
파일: nisar.py 프로젝트: kirkjens/sarpy
    def __init__(self, nisar_details):
        """

        Parameters
        ----------
        nisar_details : str|NISARDetails
            file name or NISARDetails object
        """

        if isinstance(nisar_details, str):
            nisar_details = NISARDetails(nisar_details)
        if not isinstance(nisar_details, NISARDetails):
            raise TypeError('The input argument for NISARReader must be a '
                            'filename or NISARDetails object')
        self._nisar_details = nisar_details
        sicd_data, shape_dict, symmetry = nisar_details.get_sicd_collection()
        chippers = []
        sicds = []
        for band_name in sicd_data:
            sicds.append(sicd_data[band_name])
            chippers.append(H5Chipper(nisar_details.file_name, band_name, shape_dict[band_name], symmetry))

        SICDTypeReader.__init__(self, tuple(sicds))
        BaseReader.__init__(self, tuple(chippers), reader_type="SICD")
        self._check_sizes()
예제 #2
0
    def __init__(self, sio_details):
        """

        Parameters
        ----------
        sio_details : str|SIODetails
            filename or SIODetails object
        """

        if isinstance(sio_details, str):
            sio_details = SIODetails(sio_details)
        if not isinstance(sio_details, SIODetails):
            raise TypeError('The input argument for SIOReader must be a filename or '
                            'SIODetails object.')
        self._sio_details = sio_details
        sicd_meta = sio_details.get_sicd()
        if sicd_meta.ImageData.PixelType == 'AMP8I_PHS8I':
            transform_data = amp_phase_to_complex(sicd_meta.ImageData.AmpTable)
        else:
            transform_data = 'COMPLEX'
        raw_bands = 2
        output_bands = 1
        output_dtype = 'complex64'
        chipper = BIPChipper(sio_details.file_name, sio_details.data_type, sio_details.data_size,
                             raw_bands, output_bands, output_dtype,
                             symmetry=sio_details.symmetry, transform_data=transform_data,
                             data_offset=sio_details.data_offset)

        SICDTypeReader.__init__(self, sicd_meta)
        BaseReader.__init__(self, chipper, reader_type="SICD")
        self._check_sizes()
예제 #3
0
    def __init__(self, csk_details):
        """

        Parameters
        ----------
        csk_details : str|CSKDetails
            file name or CSKDetails object
        """

        if isinstance(csk_details, string_types):
            csk_details = CSKDetails(csk_details)
        if not isinstance(csk_details, CSKDetails):
            raise TypeError('The input argument for a CSKReader must be a '
                            'filename or CSKDetails object')
        self._csk_details = csk_details
        sicd_data, shape_dict, symmetry = csk_details.get_sicd_collection()
        chippers = []
        sicds = []
        for band_name in sicd_data:
            if self._csk_details.mission_id in ['CSK', 'KMPS']:
                the_band = '{}/SBI'.format(band_name)
            elif self._csk_details.mission_id == 'CSG':
                the_band = '{}/IMG'.format(band_name)
            else:
                raise ValueError('Unhandled mission id {}'.format(
                    self._csk_details.mission_id))

            sicds.append(sicd_data[band_name])
            chippers.append(
                H5Chipper(csk_details.file_name, the_band,
                          shape_dict[band_name], symmetry))

        SICDTypeReader.__init__(self, tuple(sicds))
        BaseReader.__init__(self, tuple(chippers), reader_type="SICD")
예제 #4
0
    def __init__(self,
                 nitf_details: Union[str, ComplexNITFDetails],
                 reverse_axes: Union[None, int, Sequence[int]] = None,
                 transpose_axes: Optional[Tuple[int, ...]] = None):
        """

        Parameters
        ----------
        nitf_details : str|ComplexNITFDetails
        reverse_axes : None|Sequence[int]
            Any entries should be restricted to `{0, 1}`. The presence of
            `0` means to reverse the rows (in the raw sense), and the presence
            of `1` means to reverse the columns (in the raw sense).
        transpose_axes : None|Tuple[int, ...]
            If presented this should be only `(1, 0)`.
        """

        if isinstance(nitf_details, str):
            nitf_details = ComplexNITFDetails(nitf_details,
                                              reverse_axes=reverse_axes,
                                              transpose_axes=transpose_axes)
        if not isinstance(nitf_details, ComplexNITFDetails):
            raise TypeError(
                'The input argument for ComplexNITFReader must be a filename or '
                'ComplexNITFDetails object.')

        SICDTypeReader.__init__(self, None, nitf_details.sicd_meta)
        NITFReader.__init__(self,
                            nitf_details,
                            reader_type="SICD",
                            reverse_axes=nitf_details.reverse_axes,
                            transpose_axes=nitf_details.transpose_axes)
        self._check_sizes()
예제 #5
0
    def __init__(self, readers):
        """

        Parameters
        ----------
        readers : List[BaseReader|str]
        """

        readers = self._validate_readers(readers)
        AggregateReader.__init__(self, readers, reader_type="SICD")

        sicds = self._define_sicds()
        SICDTypeReader.__init__(self, sicds)
예제 #6
0
    def __init__(self, readers: Union[Sequence[str], Sequence[SICDTypeReader]]):
        """

        Parameters
        ----------
        readers : Sequence[str]|Sequence[SICDTypeReader]
        """

        readers = self._validate_readers(readers)
        AggregateReader.__init__(self, readers)
        sicds = self._define_sicds()
        SICDTypeReader.__init__(self, None, sicds)
        self._check_sizes()
예제 #7
0
    def __init__(self, readers):
        """

        Parameters
        ----------
        readers : Sequence[SICDTypeReader|str]
        """

        readers = self._validate_readers(readers)
        AggregateReader.__init__(self, readers, reader_type="SICD")

        sicds = self._define_sicds()
        SICDTypeReader.__init__(self, sicds)
        self._check_sizes()
예제 #8
0
파일: csk.py 프로젝트: ngageoint/sarpy
    def __init__(self, csk_details):
        """

        Parameters
        ----------
        csk_details : str|CSKDetails
            file name or CSKDetails object
        """

        if isinstance(csk_details, str):
            csk_details = CSKDetails(csk_details)
        if not isinstance(csk_details, CSKDetails):
            raise TypeError('The input argument for a CSKReader must be a '
                            'filename or CSKDetails object')
        self._csk_details = csk_details
        sicd_data, shape_dict, dtype_dict, reverse_axes, transpose_axes = csk_details.get_sicd_collection(
        )
        data_segments = []
        sicds = []
        for band_name in sicd_data:
            if self._csk_details.mission_id in ['CSK', 'KMPS']:
                the_band = '{}/SBI'.format(band_name)
            elif self._csk_details.mission_id == 'CSG':
                the_band = '{}/IMG'.format(band_name)
            else:
                raise ValueError(
                    _unhandled_id_text.format(self._csk_details.mission_id))

            sicds.append(sicd_data[band_name])
            basic_shape = shape_dict[band_name]
            data_segments.append(
                HDF5DatasetSegment(csk_details.file_name,
                                   the_band,
                                   formatted_dtype='complex64',
                                   formatted_shape=(basic_shape[1],
                                                    basic_shape[0]),
                                   reverse_axes=reverse_axes,
                                   transpose_axes=transpose_axes,
                                   format_function=ComplexFormatFunction(
                                       raw_dtype=dtype_dict[band_name],
                                       order='IQ',
                                       band_dimension=2),
                                   close_file=True))

        SICDTypeReader.__init__(self,
                                data_segments,
                                sicds,
                                close_segments=True)
        self._check_sizes()
예제 #9
0
    def __init__(self, sio_details):
        """

        Parameters
        ----------
        sio_details : str|SIODetails
            filename or SIODetails object
        """

        if isinstance(sio_details, str):
            sio_details = SIODetails(sio_details)
        if not isinstance(sio_details, SIODetails):
            raise TypeError(
                'The input argument for SIOReader must be a filename or '
                'SIODetails object.')
        self._sio_details = sio_details
        sicd_meta = sio_details.get_sicd()

        if sicd_meta.ImageData.PixelType == 'AMP8I_PHS8I':
            format_function = ComplexFormatFunction(
                sio_details.raw_data_type,
                order='MP',
                band_dimension=-1,
                magnitude_lookup_table=sicd_meta.ImageData.AmpTable)
        else:
            format_function = ComplexFormatFunction(sio_details.raw_data_type,
                                                    order='IQ',
                                                    band_dimension=-1)
        reverse_axes, transpose_axes = sio_details.get_symmetry()
        data_segment = NumpyMemmapSegment(sio_details.file_name,
                                          sio_details.data_offset,
                                          sio_details.raw_data_type,
                                          sio_details.raw_data_size,
                                          'complex64',
                                          sio_details.formatted_data_size,
                                          reverse_axes=reverse_axes,
                                          transpose_axes=transpose_axes,
                                          format_function=format_function,
                                          mode='r',
                                          close_file=True)

        SICDTypeReader.__init__(self,
                                data_segment,
                                sicd_meta,
                                close_segments=True)
        self._check_sizes()
예제 #10
0
    def __init__(self, nitf_details):
        """

        Parameters
        ----------
        nitf_details :  : str|BinaryIO|SICDDetails
            filename, file-like object, or SICDDetails object
        """

        if isinstance(nitf_details, string_types) or is_file_like(nitf_details):
            nitf_details = SICDDetails(nitf_details)
        if not isinstance(nitf_details, SICDDetails):
            raise TypeError(
                'The input argument for SICDReader must be a filename, file-like object, '
                'or SICDDetails object.')

        SICDTypeReader.__init__(self, nitf_details.sicd_meta)
        NITFReader.__init__(self, nitf_details, reader_type='SICD')
예제 #11
0
파일: iceye.py 프로젝트: bombaci-vsc/sarpy
    def __init__(self, iceye_details):
        """

        Parameters
        ----------
        iceye_details : str|ICEYEDetails
            file name or ICEYEDetails object
        """

        if isinstance(iceye_details, string_types):
            iceye_details = ICEYEDetails(iceye_details)
        if not isinstance(iceye_details, ICEYEDetails):
            raise TypeError('The input argument for a ICEYEReader must be a '
                            'filename or ICEYEDetails object')
        self._iceye_details = iceye_details
        sicd, data_size, symmetry = iceye_details.get_sicd()
        chipper = ICEYEChipper(iceye_details.file_name, data_size, symmetry)

        SICDTypeReader.__init__(self, sicd)
        BaseReader.__init__(self, chipper, reader_type="SICD")
예제 #12
0
    def __init__(self, nitf_details, symmetry=(False, False, False), split_bands=True):
        """

        Parameters
        ----------
        nitf_details : str|ComplexNITFDetails
        symmetry : tuple
            Passed through to ComplexNITFDetails() in the event that `nitf_details` is a file name.
        split_bands : bool
            Passed through to ComplexNITFDetails() in the event that `nitf_details` is a file name.
        """

        if isinstance(nitf_details, str):
            nitf_details = ComplexNITFDetails(nitf_details, symmetry=symmetry, split_bands=split_bands)
        if not isinstance(nitf_details, ComplexNITFDetails):
            raise TypeError('The input argument for ComplexNITFReader must be a filename or '
                            'ComplexNITFDetails object.')

        SICDTypeReader.__init__(self, nitf_details.sicd_meta)
        NITFReader.__init__(self, nitf_details, reader_type="SICD", symmetry=symmetry)
        self._check_sizes()
예제 #13
0
    def __init__(self, iceye_details):
        """

        Parameters
        ----------
        iceye_details : str|ICEYEDetails
            file name or ICEYEDetails object
        """

        if isinstance(iceye_details, str):
            iceye_details = ICEYEDetails(iceye_details)
        if not isinstance(iceye_details, ICEYEDetails):
            raise TypeError('The input argument for a ICEYEReader must be a '
                            'filename or ICEYEDetails object')
        self._iceye_details = iceye_details
        sicd, reverse_axes, transpose_axes = iceye_details.get_sicd()
        data_segment = get_iceye_data_segment(iceye_details.file_name,
                                              reverse_axes, transpose_axes)

        SICDTypeReader.__init__(self, data_segment, sicd, close_segments=True)
        self._check_sizes()
예제 #14
0
    def __init__(self, capella_details):
        """

        Parameters
        ----------
        capella_details : str|CapellaDetails
        """

        if isinstance(capella_details, string_types):
            capella_details = CapellaDetails(capella_details)

        if not isinstance(capella_details, CapellaDetails):
            raise TypeError('The input argument for capella_details must be a '
                            'filename or CapellaDetails object')
        self._capella_details = capella_details
        sicd = self.capella_details.get_sicd()
        chipper = NativeTiffChipper(
            self.capella_details.tiff_details,
            symmetry=self.capella_details.get_symmetry())

        SICDTypeReader.__init__(self, sicd)
        BaseReader.__init__(self, chipper, reader_type="SICD")
예제 #15
0
파일: nisar.py 프로젝트: ngageoint/sarpy
    def __init__(self, nisar_details: Union[str, NISARDetails]):
        """

        Parameters
        ----------
        nisar_details : str|NISARDetails
            file name or NISARDetails object
        """

        if isinstance(nisar_details, str):
            nisar_details = NISARDetails(nisar_details)
        if not isinstance(nisar_details, NISARDetails):
            raise TypeError('The input argument for NISARReader must be a '
                            'filename or NISARDetails object')
        self._nisar_details = nisar_details
        sicd_data, shape_dict, reverse_axes, transpose_axes = nisar_details.get_sicd_collection()
        data_segments = []
        sicds = []
        for band_name in sicd_data:
            sicds.append(sicd_data[band_name])
            raw_shape, raw_dtype = shape_dict[band_name]
            formatted_shape = (raw_shape[1], raw_shape[0]) if transpose_axes is not None \
                else raw_shape[:2]
            if raw_dtype.name == 'complex64':
                formatted_dtype = raw_dtype
                format_function = None
            else:
                formatted_dtype = 'complex64'
                format_function = ComplexFormatFunction(raw_dtype=raw_dtype, order='IQ', band_dimension=-1)

            data_segments.append(
                HDF5DatasetSegment(
                    nisar_details.file_name, band_name,
                    formatted_dtype=formatted_dtype, formatted_shape=formatted_shape,
                    reverse_axes=reverse_axes, transpose_axes=transpose_axes,
                    format_function=format_function, close_file=True))

        SICDTypeReader.__init__(self, data_segments, sicds, close_segments=True)
        self._check_sizes()
예제 #16
0
    def __init__(self, capella_details):
        """

        Parameters
        ----------
        capella_details : str|CapellaDetails
        """

        if isinstance(capella_details, str):
            capella_details = CapellaDetails(capella_details)

        if not isinstance(capella_details, CapellaDetails):
            raise TypeError('The input argument for capella_details must be a '
                            'filename or CapellaDetails object')
        self._capella_details = capella_details
        sicd = self.capella_details.get_sicd()
        reverse_axes, transpose_axes = self.capella_details.get_symmetry()
        data_segment = NativeTiffDataSegment(self.capella_details.tiff_details,
                                             reverse_axes=reverse_axes,
                                             transpose_axes=transpose_axes)

        SICDTypeReader.__init__(self, data_segment, sicd, close_segments=True)
        self._check_sizes()