示例#1
0
def test_cubefile_labels():
    filename = os.path.join(DATA_DIR, 'pattern.cub')
    image = CubeFile.open(filename)

    assert image.filename == filename
    assert image.bands == 1
    assert image.lines == 90
    assert image.samples == 90
    assert image.tile_lines == 128
    assert image.tile_samples == 128
    assert image.format == 'Tile'
    assert image.dtype == numpy.dtype('float32')
    assert image.base == 0.0
    assert image.multiplier == 1.0
    assert image.start_byte == 65536
    assert image.shape == (1, 90, 90)
    assert image.size == 8100

    filename = os.path.join(DATA_DIR, 'pattern.cub')
    image = CubeFile.open(filename)

    assert image.data.shape == (1, 90, 90)
    assert image.data.size == 8100

    expected_filename = os.path.join(DATA_DIR, 'pattern.txt')
    expected = numpy.loadtxt(expected_filename, skiprows=2).reshape(
        (1, 90, 90))

    assert_almost_equal(image.data, expected)
示例#2
0
def test_cubefile_labels():
    filename = os.path.join(DATA_DIR, 'pattern.cub')
    image = CubeFile.open(filename)

    assert image.filename == filename
    assert image.bands == 1
    assert image.lines == 90
    assert image.samples == 90
    assert image.tile_lines == 128
    assert image.tile_samples == 128
    assert image.format == 'Tile'
    assert image.dtype == numpy.dtype('float32')
    assert image.base == 0.0
    assert image.multiplier == 1.0
    assert image.start_byte == 65536
    assert image.shape == (1, 90, 90)
    assert image.size == 8100

    filename = os.path.join(DATA_DIR, 'pattern.cub')
    image = CubeFile.open(filename)

    assert image.data.shape == (1, 90, 90)
    assert image.data.size == 8100

    expected_filename = os.path.join(DATA_DIR, 'pattern.txt')
    expected = numpy.loadtxt(expected_filename, skiprows=2).reshape((1, 90, 90))

    assert_almost_equal(image.data, expected)
示例#3
0
    def readCUB(self):
        '''Read VIMS CUB data file'''
        try:
            self.cube_vis = np.array(CubeFile.open(self.fname_vis).data)
        except NameError:
            self.cube_vis = np.array([[[np.nan] * self.NS] * self.NL] * 96)

        try:
            self.cube_ir = np.array(CubeFile.open(self.fname_ir).data)
        except NameError:
            self.cube_ir = np.array([[[np.nan] * self.NS] * self.NL] * 256)

        self.cube = np.concatenate((self.cube_vis, self.cube_ir), axis=0)
        return
示例#4
0
    def readNAV(self):
        '''Read VIMS geocube data'''
        cube = np.array(CubeFile.open(self.fname).data)

        for ii, frame in enumerate(self.lbl['BandBin']['Name']):
            if frame == 'Latitude':
                self.lat = cube[ii]  # Pixel central latitude [North]
            elif frame == 'Longitude':
                self.lon = cube[ii]  # % 360 # Pixel central longitude [East]
            elif frame == 'Pixel Resolution':
                self.res = cube[ii] * 1.e-3  # Pixel resolution [km/pix]
            elif frame == 'Incidence Angle':
                self.inc = cube[ii]  # Incidence angle [deg]
            elif frame == 'Emission Angle':
                self.eme = cube[ii]  # Emission angle [deg]
            elif frame == 'Phase Angle':
                self.phase = cube[ii]  # Phase angle [deg]
            else:
                raise ValueError('ISIS NAV frame name (%s) is unknown' % frame)

        self.nan = (self.lon < NaN)
        self.lon[self.nan] = np.nan
        self.lat[self.nan] = np.nan
        self.inc[self.nan] = np.nan
        self.eme[self.nan] = np.nan
        self.phase[self.nan] = np.nan
        self.res[self.nan] = np.nan
        return
def test_cubefile_disk_format(pattern_data):
    filename = os.path.join(DATA_DIR, 'pattern.cub')
    image = CubeFile.open(filename)

    assert image.data.shape == (1, 90, 90)
    assert image.data.size == 8100

    assert_almost_equal(image.data[0], pattern_data)
示例#6
0
def test_cubefile_image_format(pattern_data):
    filename = os.path.join(DATA_DIR, 'pattern.cub')
    image = CubeFile(open(filename, 'rb'), memory_layout='IMAGE')

    assert image.data.shape == (90, 90)
    assert image.data.size == 8100

    assert_almost_equal(image.data, pattern_data)
示例#7
0
def test_cubefile_disk_format(pattern_data):
    filename = os.path.join(DATA_DIR, 'pattern.cub')
    image = CubeFile.open(filename)

    assert image.data.shape == (1, 90, 90)
    assert image.data.size == 8100

    assert_almost_equal(image.data[0], pattern_data)
def test_cubefile_labels():
    filename = os.path.join(DATA_DIR, 'pattern.cub')
    image = CubeFile.open(filename)

    assert image.filename == filename
    assert image.bands == 1
    assert image.lines == 90
    assert image.samples == 90
    assert image.tile_lines == 128
    assert image.tile_samples == 128
    assert image.format == 'Tile'
    assert image.dtype == numpy.dtype('float32')
    assert image.base == 0.0
    assert image.multiplier == 1.0
    assert image.start_byte == 65536
    assert image.shape == (1, 90, 90)
    assert image.size == 8100
示例#9
0
def test_cubefile_labels():
    filename = os.path.join(DATA_DIR, 'pattern.cub')
    image = CubeFile.open(filename)

    assert image.filename == filename
    assert image.bands == 1
    assert image.lines == 90
    assert image.samples == 90
    assert image.tile_lines == 128
    assert image.tile_samples == 128
    assert image.format == 'Tile'
    assert image.dtype == numpy.dtype('float32')
    assert image.base == 0.0
    assert image.multiplier == 1.0
    assert image.start_byte == 65536
    assert image.shape == (1, 90, 90)
    assert image.size == 8100
示例#10
0
def test_cubefile_save():
    filename = os.path.join(DATA_DIR, 'pattern.cub')
    image = CubeFile.open(filename)
    with pytest.raises(NotImplementedError):
        image.save('Temp_Image.cub')
示例#11
0
def test_stream_error():
    with pytest.raises(TypeError):
        CubeFile('filename.cub')
示例#12
0
def test_cubefile_save():
    filename = os.path.join(DATA_DIR, 'pattern.cub')
    image = CubeFile.open(filename)
    with pytest.raises(NotImplementedError):
        image.save('Temp_Image.cub')