예제 #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_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.")
예제 #3
0
    def test_parse_gamma_epoch_header(self):
        # minimal required headers are:
        # date:      2009  7 13
        # radar_frequency:        5.3310040e+09   Hz
        path = join(GAMMA_TEST_DIR, 'r20090713_VV.slc.par')
        hdrs = gamma.parse_epoch_header(path)

        exp_date = date(2009, 7, 13)
        assert hdrs[ifc.FIRST_DATE] == exp_date

        exp_wavelen = LIGHTSPEED / 5.3310040e+09
        assert hdrs[ifc.PYRATE_WAVELENGTH_METRES] == exp_wavelen

        incidence_angle = 22.9671
        assert hdrs[ifc.PYRATE_INCIDENCE_DEGREES] == incidence_angle
예제 #4
0
    def test_combine_headers(self):
        filenames = ['r20090713_VV.slc.par', 'r20090817_VV.slc.par']
        paths = [join(GAMMA_TEST_DIR, p) for p in filenames]
        hdr0, hdr1 = [gamma.parse_epoch_header(p) for p in paths]

        chdr = gamma.combine_headers(hdr0, hdr1, self.dh)

        exp_timespan = (18 + 17) / ifc.DAYS_PER_YEAR
        self.assert_equal(chdr[ifc.PYRATE_TIME_SPAN], exp_timespan)

        exp_date = date(2009, 7, 13)
        self.assert_equal(chdr[ifc.FIRST_DATE], exp_date)
        exp_date2 = date(2009, 8, 17)
        self.assert_equal(chdr[ifc.SECOND_DATE], exp_date2)

        exp_wavelen = LIGHTSPEED / 5.3310040e+09
        self.assert_equal(chdr[ifc.PYRATE_WAVELENGTH_METRES], exp_wavelen)
예제 #5
0
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,
                                      ifg_proc=1)

shared.write_unw_from_data_or_geotiff(geotif_or_data=elevation_data,