예제 #1
0
    def setup_method(cls):
        # create common combined header obj so the headers are only read once
        # tricker: needs both ifg headers, and DEM one for the extents
        filenames = ['r20090713_VV.slc.par', 'r20090817_VV.slc.par']
        hdr_paths = [join(GAMMA_TEST_DIR, f) for f in filenames]
        hdrs = [gamma.parse_epoch_header(p) for p in hdr_paths]
        dem_hdr_path = join(GAMMA_TEST_DIR, 'dem16x20raw.dem.par')

        cls.DEM_HDR = gamma.parse_dem_header(dem_hdr_path)
        cls.COMBINED = gamma.combine_headers(*hdrs, dem_hdr=cls.DEM_HDR)
예제 #2
0
    def test_parse_gamma_dem_header(self):
        path = join(GAMMA_TEST_DIR, 'dem16x20raw.dem.par')
        hdrs = gamma.parse_dem_header(path)

        self.assert_equal(hdrs[ifc.PYRATE_NCOLS], 16)
        self.assert_equal(hdrs[ifc.PYRATE_NROWS], 20)
        self.assert_equal(hdrs[ifc.PYRATE_LAT], -33.3831945)
        self.assert_equal(hdrs[ifc.PYRATE_LONG], 150.3870833)
        self.assert_equal(hdrs[ifc.PYRATE_X_STEP], 6.9444445e-05)
        self.assert_equal(hdrs[ifc.PYRATE_Y_STEP], -6.9444445e-05)
예제 #3
0
    def test_unw_contains_same_data_as_numpy_array(self):
        from datetime import time
        temp_unw = tempfile.mktemp(suffix='.unw')
        temp_tif = tempfile.mktemp(suffix='.tif')

        # setup some header files for use in write_geotif
        dem_header_file = common.SML_TEST_DEM_HDR_GAMMA
        dem_header = gamma.parse_dem_header(dem_header_file)

        header = gamma.parse_epoch_header(
            os.path.join(common.GAMMA_SML_TEST_DIR, '20060828_slc.par'))
        header.update(dem_header)

        base_header = gamma.parse_baseline_header(
            os.path.join(common.GAMMA_SML_TEST_DIR,
                         '20060828-20061211_base.par'))
        header.update(base_header)

        # insert some dummy data so we are the dem in write_fullres_geotiff is not
        # not activated and ifg write_fullres_geotiff operation works
        header[ifc.PYRATE_TIME_SPAN] = 0
        header[ifc.SECOND_DATE] = 0
        header[ifc.DATA_UNITS] = 'degrees'
        header[ifc.DATA_TYPE] = ifc.ORIG
        header[ifc.SECOND_TIME] = time(10)

        # now create arbitrary data
        data = np.random.rand(dem_header[ifc.PYRATE_NROWS],
                              dem_header[ifc.PYRATE_NCOLS])

        # convert numpy array to .unw
        shared.write_unw_from_data_or_geotiff(geotif_or_data=data,
                                              dest_unw=temp_unw,
                                              ifg_proc=1)
        # convert the .unw to geotif
        shared.write_fullres_geotiff(header=header,
                                     data_path=temp_unw,
                                     dest=temp_tif,
                                     nodata=np.nan)

        # now compare geotiff with original numpy array
        ds = gdal.Open(temp_tif, gdal.GA_ReadOnly)
        data_lv_theta = ds.ReadAsArray()
        ds = None
        np.testing.assert_array_almost_equal(data, data_lv_theta)
        try:
            os.remove(temp_tif)
        except PermissionError:
            print("File opened by another process.")

        try:
            os.remove(temp_unw)
        except PermissionError:
            print("File opened by another process.")
예제 #4
0
    def test_to_geotiff_dem(self):
        hdr_path = join(GAMMA_TEST_DIR, 'dem16x20raw.dem.par')
        hdr = gamma.parse_dem_header(hdr_path)
        data_path = join(GAMMA_TEST_DIR, 'dem16x20raw.dem')
        self.dest = os.path.join(TEMPDIR, "tmp_gamma_dem.tif")

        write_fullres_geotiff(hdr, data_path, self.dest, nodata=0)
        exp_path = join(GAMMA_TEST_DIR, 'dem16x20_subset_from_gamma.tif')
        exp_ds = gdal.Open(exp_path)
        ds = gdal.Open(self.dest)

        # compare data and geographic headers
        # HACK: round  expected to nearest integer
        assert_array_almost_equal(np.rint(exp_ds.ReadAsArray()),
                                  ds.ReadAsArray())
        self.compare_rasters(exp_ds, ds)
        md = ds.GetMetadata()
        assert md['AREA_OR_POINT'] == 'Area'
예제 #5
0
 def setup_method(self):
     self.err = gamma.GammaException
     dem_hdr_path = join(GAMMA_TEST_DIR, 'dem16x20raw.dem.par')
     self.dh = gamma.parse_dem_header(dem_hdr_path)
예제 #6
0
from tests import common

elevation_file = os.path.join(
    common.SML_TEST_GAMMA,
    os.path.splitext(common.SML_TEST_DEM_GAMMA)[0] + '.lv_theta')

inc_file = os.path.join(
    common.SML_TEST_GAMMA,
    os.path.splitext(common.SML_TEST_DEM_GAMMA)[0] + '.inc')

dest_lv_theta = os.path.splitext(elevation_file)[0] + '_lv_theta.tif'
dest_inc = os.path.splitext(elevation_file)[0] + '_inc.tif'

dem_header_file = common.SML_TEST_DEM_HDR_GAMMA

dem_header = gamma.parse_dem_header(dem_header_file)

header = gamma.parse_epoch_header(
    os.path.join(common.SML_TEST_GAMMA, '20060828_slc.par'))

incidence_angle = header[ifc.PYRATE_INCIDENCE_DEGREES]
incidence_data = np.ones(
    shape=(dem_header[ifc.PYRATE_NROWS],
           dem_header[ifc.PYRATE_NCOLS])) * incidence_angle

elevation_data = np.ones(
    shape=(dem_header[ifc.PYRATE_NROWS],
           dem_header[ifc.PYRATE_NCOLS])) * (90.0 - incidence_angle)

shared.write_unw_from_data_or_geotiff(geotif_or_data=incidence_data,
                                      dest_unw=inc_file,
예제 #7
0
파일: test_gamma.py 프로젝트: sixy6e/PyRate
 def setup_method(self):
     self.err = gamma.GammaException
     dem_hdr_path = join(GAMMA_TEST_DIR, 'dem16x20raw.dem.par')
     self.dh = gamma.parse_dem_header(dem_hdr_path)
     base_hdr_path = join(GAMMA_TEST_DIR, '20160114-20160126_base.par')
     self.bh = gamma.parse_baseline_header(base_hdr_path)