Esempio n. 1
0
    def test_write_default_header(self):
        data_filename = 'test_write_ermapper_grid'

        # setup test data
        original_grid = num.array([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]])
        # Write test data
        ermapper_grids.write_ermapper_data(original_grid, data_filename)
        # Write test header using all default values
        header_filename = data_filename + '.ers'
        ermapper_grids.write_ermapper_header(header_filename)

        # Check that the read in values match the default values
        header = ermapper_grids.read_ermapper_header(header_filename)

        assert header['datum'] == '"GDA94"'
        assert header['projection'] == '"GEOGRAPHIC"'
        assert header['coordinatetype'] == 'LL'
        assert header['rotation'] == '0:0:0.0'
        assert header['celltype'] == 'IEEE4ByteReal'
        assert header['nullcellvalue'] == '-99999'
        assert header['xdimension'] == '100'
        assert header['registrationcellx'] == '0'
        assert header['ydimension'] == '100'
        assert header['registrationcelly'] == '2'
        assert header['nroflines'] == '3'
        assert header['nrofcellsperline'] == '4'
        assert header['longitude'] == '0:0:0'
        assert header['latitude'] == '0:0:0'
        assert header['nrofbands'] == '1'
        assert header['value'] == '"Default_Band"'

        # Clean up created files
        remove(data_filename)
        remove(header_filename)
    def test_write_default_header(self):
        data_filename = 'test_write_ermapper_grid'

        # setup test data
        original_grid = num.array([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]])
        # Write test data
        ermapper_grids.write_ermapper_data(original_grid, data_filename)
        # Write test header using all default values
        header_filename = data_filename + '.ers'                              
        ermapper_grids.write_ermapper_header(header_filename)

        # Check that the read in values match the default values
        header = ermapper_grids.read_ermapper_header(header_filename)

        assert header['datum'] == '"GDA94"'
        assert header['projection'] == '"GEOGRAPHIC"'  
        assert header['coordinatetype'] == 'LL'
        assert header['rotation'] == '0:0:0.0'
        assert header['celltype'] == 'IEEE4ByteReal'
        assert header['nullcellvalue'] == '-99999'
        assert header['xdimension'] == '100'
        assert header['registrationcellx'] == '0'
        assert header['ydimension'] == '100'
        assert header['registrationcelly'] == '2'
        assert header['nroflines'] == '3'
        assert header['nrofcellsperline'] == '4'
        assert header['longitude'] == '0:0:0'
        assert header['latitude'] == '0:0:0'
        assert header['nrofbands'] == '1'
        assert header['value'] == '"Default_Band"'

        # Clean up created files
        remove(data_filename)
        remove(header_filename)
Esempio n. 3
0
    def test_write_non_default_header(self):
        header_filename = 'test_write_ermapper_grid.ers'

        # setup test data
        header = {}
        # have some values that aren't defaults
        header['nroflines'] = '2'
        header['nrofcellsperline'] = '3'

        # Write test header using non-default values
        ermapper_grids.write_ermapper_header(header_filename, header)

        # Check that the read in values match the default values
        header = ermapper_grids.read_ermapper_header(header_filename)

        # default values
        assert header['datum'] == '"GDA94"'
        assert header['projection'] == '"GEOGRAPHIC"'
        assert header['coordinatetype'] == 'LL'
        assert header['rotation'] == '0:0:0.0'
        assert header['celltype'] == 'IEEE4ByteReal'
        assert header['nullcellvalue'] == '-99999'
        assert header['xdimension'] == '100'
        assert header['registrationcellx'] == '0'
        assert header['ydimension'] == '100'
        assert header['longitude'] == '0:0:0'
        assert header['latitude'] == '0:0:0'
        assert header['nrofbands'] == '1'
        assert header['value'] == '"Default_Band"'

        # non-default values
        assert header['nroflines'] == '2'
        assert header['nrofcellsperline'] == '3'
        assert header['registrationcelly'] == '1'

        # Clean up created files
        remove(header_filename)
    def test_write_non_default_header(self):
        header_filename = 'test_write_ermapper_grid.ers'

        # setup test data
        header = {}
        # have some values that aren't defaults
        header['nroflines'] = '2'
        header['nrofcellsperline'] = '3'
        
        # Write test header using non-default values                           
        ermapper_grids.write_ermapper_header(header_filename, header)

        # Check that the read in values match the default values
        header = ermapper_grids.read_ermapper_header(header_filename)

        # default values
        assert header['datum'] == '"GDA94"'
        assert header['projection'] == '"GEOGRAPHIC"'  
        assert header['coordinatetype'] == 'LL'
        assert header['rotation'] == '0:0:0.0'
        assert header['celltype'] == 'IEEE4ByteReal'
        assert header['nullcellvalue'] == '-99999'
        assert header['xdimension'] == '100'
        assert header['registrationcellx'] == '0'
        assert header['ydimension'] == '100'
        assert header['longitude'] == '0:0:0'
        assert header['latitude'] == '0:0:0'
        assert header['nrofbands'] == '1'
        assert header['value'] == '"Default_Band"'

        # non-default values
        assert header['nroflines'] == '2'
        assert header['nrofcellsperline'] == '3'
        assert header['registrationcelly'] == '1'

        # Clean up created files
        remove(header_filename)