예제 #1
0
def main(opts):
    """
    crossmul
    """
    # prepare input rasters
    masterSlc = SLC(hdf5file=opts.master)
    masterSlcDataset = masterSlc.getSlcDataset(opts.frequency,
                                               opts.polarization)
    masterSlcRaster = Raster('', h5=masterSlcDataset)
    slaveSlc = SLC(hdf5file=opts.slave)
    slaveSlcDataset = slaveSlc.getSlcDataset(opts.frequency, opts.polarization)
    slaveSlcRaster = Raster('', h5=slaveSlcDataset)

    # prepare mulitlooked interferogram dimensions
    masterGrid = masterSlc.getRadarGrid(opts.frequency)
    length = int(masterGrid.length / opts.alks)
    width = int(masterGrid.width / opts.rlks)

    # init output directory(s)
    initDir(opts.intPathAndPrefix)
    initDir(opts.cohPathAndPrefix)

    # prepare output rasters
    driver = gdal.GetDriverByName('ISCE')
    igramDataset = driver.Create(opts.intPathAndPrefix, width, length, 1,
                                 gdal.GDT_CFloat32)
    igramRaster = Raster('', dataset=igramDataset)
    cohDataset = driver.Create(opts.cohPathAndPrefix, width, length, 1,
                               gdal.GDT_Float32)
    cohRaster = Raster('', dataset=cohDataset)

    # prepare optional rasters
    if opts.rgoff:
        rgOffRaster = Raster(opts.rgoff)
    else:
        rgOffRaster = None

    if opts.azband:
        dopMaster = masterSlc.getDopplerCentroid()
        dopSlave = slaveSlc.getDopplerCentroid()
        prf = dopMaster.getRadarGrid(opts.frequency).prf
        azimuthBandwidth = opts.azband
    else:
        dopMaster = dopSlave = None
        prf = azimuthBandwidth = 0.0

    crossmul = Crossmul()
    crossmul.crossmul(masterSlcRaster,
                      slaveSlcRaster,
                      igramRaster,
                      cohRaster,
                      rngOffset=rgOffRaster,
                      refDoppler=dopMaster,
                      secDoppler=dopSlave,
                      rangeLooks=opts.rlks,
                      azimuthLooks=opts.alks,
                      prf=prf,
                      azimuthBandwidth=azimuthBandwidth)
예제 #2
0
def main(opts):
    """
    resample SLC
    """

    # prep SLC dataset input
    productSlc = SLC(hdf5file=opts.product)

    # get grids needed for resamp object instantiation
    productGrid = productSlc.getRadarGrid(opts.frequency)

    # instantiate resamp object based on user input
    if 'cuda' not in dir(isce3) and opts.gpu:
        warnings.warn('CUDA resamp not available. Switching to CPU resamp')
        opts.gpu = False

    if opts.gpu:
        resamp = isce3.cuda.image.resampSlc(
            radarGrid=productGrid,
            doppler=productSlc.getDopplerCentroid(),
            wavelength=productGrid.wavelength)
    else:
        resamp = isce3.image.resampSlc(radarGrid=productGrid,
                                       doppler=productSlc.getDopplerCentroid(),
                                       wavelength=productGrid.wavelength)

    # set number of lines per tile if arg > 0
    if opts.linesPerTile:
        resamp.linesPerTile = opts.linesPerTile

    # Prepare input rasters
    inSlcDataset = productSlc.getSlcDataset(opts.frequency, opts.polarization)
    inSlcRaster = isce3.io.raster(filename='', h5=inSlcDataset)
    azOffsetRaster = isce3.io.raster(
        filename=os.path.join(opts.offsetdir, 'azimuth.off'))
    rgOffsetRaster = isce3.io.raster(
        filename=os.path.join(opts.offsetdir, 'range.off'))

    # Init output directory
    if opts.outFilePath:
        path, _ = os.path.split(opts.outFilePath)
        os.makedirs(path, exist_ok=True)

    # Prepare output raster
    driver = gdal.GetDriverByName('ISCE')
    outds = driver.Create(opts.outFilePath, rgOffsetRaster.width,
                          rgOffsetRaster.length, 1, gdal.GDT_CFloat32)
    outSlcRaster = isce3.io.raster(filename='', dataset=outds)

    # Run resamp
    resamp.resamp(inSlc=inSlcRaster,
                  outSlc=outSlcRaster,
                  rgoffRaster=rgOffsetRaster,
                  azoffRaster=azOffsetRaster)
예제 #3
0
def test_run():
    '''
    check if resamp runs
    '''
    # init params
    h5_path = os.path.join(iscetest.data, "envisat.h5")
    grid = isce3.product.RadarGridParameters(h5_path)
    slc = SLC(hdf5file=h5_path)

    # init resamp obj
    resamp = isce3.image.ResampSlc(grid, slc.getDopplerCentroid())
    resamp.lines_per_tile = 249

    # prepare rasters
    h5_ds = f'//science/LSAR/SLC/swaths/frequencyA/HH'
    raster_ref = f'HDF5:{h5_path}:{h5_ds}'
    input_slc = isce3.io.Raster(raster_ref)

    az_off_raster = isce3.io.Raster(
        os.path.join(iscetest.data, "offsets/azimuth.off"))
    rg_off_raster = isce3.io.Raster(
        os.path.join(iscetest.data, "offsets/range.off"))

    output_slc = isce3.io.Raster('warped.slc', rg_off_raster.width,
                                 rg_off_raster.length, rg_off_raster.num_bands,
                                 gdal.GDT_CFloat32, 'ENVI')

    # run resamp
    resamp.resamp(input_slc, output_slc, rg_off_raster, az_off_raster)
예제 #4
0
def test_run_raster_layers():
    '''
    check if topo runs
    '''
    # prepare Rdr2Geo init params
    h5_path = os.path.join(iscetest.data, "envisat.h5")

    radargrid = isce3.product.RadarGridParameters(h5_path)

    slc = SLC(hdf5file=h5_path)
    orbit = slc.getOrbit()
    doppler = slc.getDopplerCentroid()

    ellipsoid = isce3.core.Ellipsoid()

    # init Rdr2Geo class
    rdr2geo_obj = isce3.geometry.Rdr2Geo(radargrid, orbit, ellipsoid, doppler)

    # load test DEM
    dem_raster = isce3.io.Raster(
        os.path.join(iscetest.data, "srtm_cropped.tif"))
    x_raster = isce3.io.Raster("x.rdr", radargrid.width, radargrid.length, 1,
                               gdal.GDT_Float64, 'ENVI')
    y_raster = isce3.io.Raster("y.rdr", radargrid.width, radargrid.length, 1,
                               gdal.GDT_Float64, 'ENVI')
    height_raster = isce3.io.Raster("z.rdr", radargrid.width, radargrid.length,
                                    1, gdal.GDT_Float64, 'ENVI')
    incidence_angle_raster = isce3.io.Raster("inc.rdr", radargrid.width,
                                             radargrid.length, 1,
                                             gdal.GDT_Float32, 'ENVI')
    heading_angle_raster = isce3.io.Raster("hgd.rdr", radargrid.width,
                                           radargrid.length, 1,
                                           gdal.GDT_Float32, 'ENVI')
    local_incidence_angle_raster = isce3.io.Raster("localInc.rdr",
                                                   radargrid.width,
                                                   radargrid.length, 1,
                                                   gdal.GDT_Float32, 'ENVI')
    local_Psi_raster = isce3.io.Raster("localPsi.rdr", radargrid.width,
                                       radargrid.length, 1, gdal.GDT_Float32,
                                       'ENVI')
    simulated_amplitude_raster = isce3.io.Raster("simamp.rdr", radargrid.width,
                                                 radargrid.length, 1,
                                                 gdal.GDT_Float32, 'ENVI')
    layover_shadow_raster = isce3.io.Raster("layoverShadowMask.rdr",
                                            radargrid.width, radargrid.length,
                                            1, gdal.GDT_Float32, 'ENVI')

    # run
    rdr2geo_obj.topo(dem_raster, x_raster, y_raster, height_raster,
                     incidence_angle_raster, heading_angle_raster,
                     local_incidence_angle_raster, local_Psi_raster,
                     simulated_amplitude_raster, layover_shadow_raster)

    topo_raster = isce3.io.Raster(
        "topo_layers.vrt",
        raster_list=[
            x_raster, y_raster, height_raster, incidence_angle_raster,
            heading_angle_raster, local_incidence_angle_raster,
            local_Psi_raster, simulated_amplitude_raster
        ])
예제 #5
0
def test_point():
    # Subset of tests/cxx/isce3/geometry/geometry/geometry.cpp
    fn = os.path.join(iscetest.data, "envisat.h5")
    slc = SLC(hdf5file=fn)
    orbit = slc.getOrbit()
    subband = "A"
    doplut = slc.getDopplerCentroid(frequency=subband)
    grid = slc.getRadarGrid(frequency=subband)

    # First row of input_data.txt
    dt = isce3.core.DateTime("2003-02-26T17:55:22.976222")
    r = 826988.6900674499
    h = 1777.

    dem = isce3.geometry.DEMInterpolator(h)
    t = (dt - orbit.reference_epoch).total_seconds()
    dop = doplut.eval(t, r)
    wvl = grid.wavelength

    # native doppler, expect first row of output_data.txt
    llh = isce3.geometry.rdr2geo(t, r, orbit, grid.lookside, dop, wvl, dem)
    assert np.isclose(np.degrees(llh[0]), -115.44101120961082)
    assert np.isclose(np.degrees(llh[1]), 35.28794014757191)
    assert np.isclose(llh[2], 1777.)

    # zero doppler, expect first row of output_data_zerodop.txt
    llh = isce3.geometry.rdr2geo(t, r, orbit, grid.lookside, 0.0, dem=dem)
    assert np.isclose(np.degrees(llh[0]), -115.43883834023249)
    assert np.isclose(np.degrees(llh[1]), 35.29610867314526)
    assert np.isclose(llh[2], 1776.9999999993)
예제 #6
0
def test_run():
    # load parameters shared across all test runs
    # init geocode object and populate members
    rslc = SLC(hdf5file=os.path.join(iscetest.data, "envisat.h5"))
    orbit = rslc.getOrbit()
    native_doppler = rslc.getDopplerCentroid()
    native_doppler.bounds_error = False
    grid_doppler = native_doppler
    threshold_geo2rdr = 1e-8
    numiter_geo2rdr = 25
    delta_range = 1e-6
    epsg = 4326

    # get radar grid from HDF5
    radar_grid = isce3.product.RadarGridParameters(
        os.path.join(iscetest.data, "envisat.h5"))
    radar_grid = radar_grid[::10, ::10]

    heights = [0.0, 1000.0]

    output_h5 = 'envisat_geolocation_cube.h5'
    fid = h5py.File(output_h5, 'w')

    cube_group_name = '/science/LSAR/SLC/metadata/radarGrid'

    add_geolocation_grid_cubes_to_hdf5(fid, cube_group_name, radar_grid,
                                       heights, orbit, native_doppler,
                                       grid_doppler, epsg, threshold_geo2rdr,
                                       numiter_geo2rdr, delta_range)

    print('saved file:', output_h5)
예제 #7
0
def test_run():
    '''
    run geocodeSlc bindings with same parameters as C++ test to make sure it does not crash
    '''
    # load h5 for doppler and orbit
    rslc = SLC(hdf5file=os.path.join(iscetest.data, "envisat.h5"))

    # define geogrid
    geogrid = isce.product.GeoGridParameters(start_x=-115.65,
                                             start_y=34.84,
                                             spacing_x=0.0002,
                                             spacing_y=-8.0e-5,
                                             width=500,
                                             length=500,
                                             epsg=4326)

    # define geotransform
    geotrans = [
        geogrid.start_x, geogrid.spacing_x, 0.0, geogrid.start_y, 0.0,
        geogrid.spacing_y
    ]

    img_doppler = rslc.getDopplerCentroid()
    native_doppler = isce.core.LUT2d(img_doppler.x_start, img_doppler.y_start,
                                     img_doppler.x_spacing,
                                     img_doppler.y_spacing,
                                     np.zeros((geogrid.length, geogrid.width)))

    dem_raster = isce.io.Raster(
        os.path.join(iscetest.data, "geocode/zeroHeightDEM.geo"))

    radargrid = isce.product.RadarGridParameters(
        os.path.join(iscetest.data, "envisat.h5"))

    # geocode same 2 rasters as C++ version
    for xy in ['x', 'y']:
        out_raster = isce.io.Raster(f"{xy}.geo", geogrid.width, geogrid.length,
                                    1, gdal.GDT_CFloat32, "ENVI")

        in_raster = isce.io.Raster(
            os.path.join(iscetest.data, f"geocodeslc/{xy}.slc"))

        isce.geocode.geocode_slc(output_raster=out_raster,
                                 input_raster=in_raster,
                                 dem_raster=dem_raster,
                                 radargrid=radargrid,
                                 geogrid=geogrid,
                                 orbit=rslc.getOrbit(),
                                 native_doppler=native_doppler,
                                 image_grid_doppler=img_doppler,
                                 ellipsoid=isce.core.Ellipsoid(),
                                 threshold_geo2rdr=1.0e-9,
                                 numiter_geo2rdr=25,
                                 lines_per_block=1000,
                                 dem_block_margin=0.1,
                                 flatten=False)

        out_raster.set_geotransform(geotrans)
예제 #8
0
def test_cuda_geocode():
    rslc = SLC(hdf5file=os.path.join(iscetest.data, "envisat.h5"))

    dem_raster = isce3.io.Raster(
        os.path.join(iscetest.data, "geocode/zeroHeightDEM.geo"))

    dem_margin = 0.1

    # define geogrid
    epsg = 4326
    geogrid = isce3.product.GeoGridParameters(start_x=-115.65,
                                              start_y=34.84,
                                              spacing_x=0.0002,
                                              spacing_y=-8.0e-5,
                                              width=500,
                                              length=500,
                                              epsg=epsg)

    geotrans = [
        geogrid.start_x, geogrid.spacing_x, 0.0, geogrid.start_y, 0.0,
        geogrid.spacing_y
    ]

    # init RadarGeometry, orbit, and doppler from RSLC
    radargrid = isce3.product.RadarGridParameters(
        os.path.join(iscetest.data, "envisat.h5"))
    orbit = rslc.getOrbit()
    doppler = rslc.getDopplerCentroid()
    rdr_geometry = isce3.container.RadarGeometry(radargrid, orbit, doppler)

    # set interp method
    interp_method = isce3.core.DataInterpMethod.BILINEAR

    # init CUDA geocode obj
    for xy, suffix in itertools.product(['x', 'y'], ['', '_blocked']):

        lines_per_block = 126 if suffix else 1000

        cu_geocode = isce3.cuda.geocode.Geocode(geogrid, rdr_geometry,
                                                dem_raster, dem_margin,
                                                lines_per_block, interp_method)

        output_raster = isce3.io.Raster(f"{xy}{suffix}.geo", geogrid.width,
                                        geogrid.length, 1, gdal.GDT_CFloat32,
                                        "ENVI")

        input_raster = isce3.io.Raster(
            os.path.join(iscetest.data, f"geocodeslc/{xy}.slc"))

        for i in range(cu_geocode.n_blocks):
            cu_geocode.set_block_radar_coord_grid(i)

            cu_geocode.geocode_raster_block(output_raster, input_raster)

        output_raster.set_geotransform(geotrans)
예제 #9
0
def test_run():
    '''
    check if geo2rdr runs
    '''
    # prepare Geo2Rdr init params
    h5_path = os.path.join(iscetest.data, "envisat.h5")

    radargrid = isce.product.RadarGridParameters(h5_path)

    slc = SLC(hdf5file=h5_path)
    orbit = slc.getOrbit()
    doppler = slc.getDopplerCentroid()

    ellipsoid = isce.core.Ellipsoid()

    # require geolocation accurate to one millionth of a pixel.
    tol_pixels = 1e-6
    tol_seconds = tol_pixels / radargrid.prf

    # init Geo2Rdr class
    geo2rdr_obj = isce.cuda.geometry.Geo2Rdr(radargrid,
                                             orbit,
                                             ellipsoid,
                                             doppler,
                                             threshold=tol_seconds,
                                             numiter=50)

    # load rdr2geo unit test output
    rdr2geo_raster = isce.io.Raster("topo.vrt")

    # run
    geo2rdr_obj.geo2rdr(rdr2geo_raster, ".")

    # list of test outputs
    test_outputs = ["range.off", "azimuth.off"]

    # check each generated raster
    for test_output in test_outputs:
        # load dataset and get array
        test_ds = gdal.Open(test_output, gdal.GA_ReadOnly)
        test_arr = test_ds.GetRasterBand(1).ReadAsArray()

        # mask bad values
        test_arr = np.ma.masked_array(test_arr, mask=np.abs(test_arr) > 999.0)

        # compute max error (in pixels)
        test_err = np.max(np.abs(test_arr))

        # Error may slightly exceed tolerance since Newton step size isn't a
        # perfect estimate of the error in the solution.
        assert (test_err <
                2 * tol_pixels), f"{test_output} accumulated error fail"
예제 #10
0
def test_run():
    # load parameters shared across all test runs
    # init geocode object and populate members
    rslc = SLC(hdf5file=os.path.join(iscetest.data, "envisat.h5"))
    geo_obj = isce.geocode.GeocodeFloat64()
    geo_obj.orbit = rslc.getOrbit()
    geo_obj.doppler = rslc.getDopplerCentroid()
    geo_obj.ellipsoid = isce.core.Ellipsoid()
    geo_obj.threshold_geo2rdr = 1e-9
    geo_obj.numiter_geo2rdr = 25
    geo_obj.lines_per_block = 1000
    geo_obj.dem_block_margin = 1e-1
    geo_obj.radar_block_margin = 10
    geo_obj.data_interpolator = 'biquintic'

    # prepare geogrid
    geogrid_start_x = -115.6
    geogrid_start_y = 34.832
    reduction_factor = 10
    geogrid_spacingX = reduction_factor * 0.0002
    geogrid_spacingY = reduction_factor * -8.0e-5
    geo_grid_length = int(380 / reduction_factor)
    geo_grid_width = int(400 / reduction_factor)
    epsgcode = 4326
    geo_obj.geogrid(geogrid_start_x, geogrid_start_y, geogrid_spacingX,
                   geogrid_spacingY, geo_grid_width, geo_grid_length, epsgcode)

    # get radar grid from HDF5
    radar_grid = isce.product.RadarGridParameters(os.path.join(iscetest.data, "envisat.h5"))

    # load test DEM
    dem_raster = isce.io.Raster(os.path.join(iscetest.data, "geocode/zeroHeightDEM.geo"))

    # iterate thru axis
    for axis in input_axis:
        # load axis input raster
        input_raster = isce.io.Raster(os.path.join(iscetest.data, f"geocode/{axis}.rdr"))

        #  iterate thru geocode modes
        for key, value in geocode_modes.items():
            # prepare output raster
            output_path = f"{axis}_{key}.geo"
            output_raster = isce.io.Raster(output_path,
                    geo_grid_width, geo_grid_length, 1,
                    gdal.GDT_Float64, "ENVI")

            # geocode based on axis and mode
            geo_obj.geocode(radar_grid,
                    input_raster,
                    output_raster,
                    dem_raster,
                    value)
예제 #11
0
def common_crossmul_obj():
    '''
    instantiate and return common crossmul object for both run tests
    '''
    # make SLC object and extract parameters
    slc_obj = SLC(hdf5file=os.path.join(iscetest.data, 'envisat.h5'))
    dopp = isce.core.avg_lut2d_to_lut1d(slc_obj.getDopplerCentroid())
    prf = slc_obj.getRadarGrid().prf

    crossmul = isce.signal.Crossmul()
    crossmul.set_dopplers(dopp, dopp)
    crossmul.set_az_filter(prf, 2000.0, 0.25)

    return crossmul
예제 #12
0
def add_radar_grid_cube(cfg, freq, radar_grid, orbit, dst_h5):
    ''' Write radar grid cube to HDF5

    Parameters
    ----------
    cfg : dict
        Dictionary containing run configuration
    freq : str
        Frequency in HDF5 to add cube to
    radar_grid : isce3.product.radar_grid
        Radar grid of current frequency of datasets other than offset and shadow
        layover datasets
    orbit : isce3.core.orbit
        Orbit object of current SLC
    dst_h5: str
        Path to output GUNW HDF5
    '''
    radar_grid_cubes_geogrid = cfg['processing']['radar_grid_cubes']['geogrid']
    radar_grid_cubes_heights = cfg['processing']['radar_grid_cubes']['heights']
    threshold_geo2rdr = cfg["processing"]["geo2rdr"]["threshold"]
    iteration_geo2rdr = cfg["processing"]["geo2rdr"]["maxiter"]

    ref_hdf5 = cfg["input_file_group"]["input_file_path"]
    slc = SLC(hdf5file=ref_hdf5)

    # get doppler centroid
    cube_geogrid_param = isce3.product.GeoGridParameters(
        start_x=radar_grid_cubes_geogrid.start_x,
        start_y=radar_grid_cubes_geogrid.start_y,
        spacing_x=radar_grid_cubes_geogrid.spacing_x,
        spacing_y=radar_grid_cubes_geogrid.spacing_y,
        width=int(radar_grid_cubes_geogrid.width),
        length=int(radar_grid_cubes_geogrid.length),
        epsg=radar_grid_cubes_geogrid.epsg)

    cube_group_path = '/science/LSAR/GUNW/metadata/radarGrid'

    native_doppler = slc.getDopplerCentroid(frequency=freq)
    grid_zero_doppler = isce3.core.LUT2d()
    '''
    The native-Doppler LUT bounds error is turned off to
    computer cubes values outside radar-grid boundaries
    '''
    native_doppler.bounds_error = False
    add_radar_grid_cubes_to_hdf5(dst_h5, cube_group_path,
                                 cube_geogrid_param, radar_grid_cubes_heights,
                                 radar_grid, orbit, native_doppler,
                                 grid_zero_doppler, threshold_geo2rdr,
                                 iteration_geo2rdr)
예제 #13
0
def test_point():
    h5_path = os.path.join(iscetest.data, "envisat.h5")

    radargrid = isce3.product.RadarGridParameters(h5_path)

    slc = SLC(hdf5file=h5_path)
    orbit = slc.getOrbit()
    doppler = slc.getDopplerCentroid()

    ellipsoid = isce3.core.Ellipsoid()

    llh = np.array([
        np.deg2rad(-115.72466801139711),
        np.deg2rad(34.65846532785868), 1772.0
    ])

    # run with native doppler
    aztime, slant_range = isce3.geometry.geo2rdr(llh,
                                                 ellipsoid,
                                                 orbit,
                                                 doppler,
                                                 radargrid.wavelength,
                                                 radargrid.lookside,
                                                 threshold=1.0e-10,
                                                 maxiter=50,
                                                 delta_range=10.0)

    azdate = orbit.reference_epoch + isce3.core.TimeDelta(aztime)
    assert azdate.isoformat() == "2003-02-26T17:55:33.993088889"
    npt.assert_almost_equal(slant_range, 830450.1859446081, decimal=6)

    # run again with zero doppler
    doppler = isce3.core.LUT2d()

    aztime, slant_range = isce3.geometry.geo2rdr(llh,
                                                 ellipsoid,
                                                 orbit,
                                                 doppler,
                                                 radargrid.wavelength,
                                                 radargrid.lookside,
                                                 threshold=1.0e-10,
                                                 maxiter=50,
                                                 delta_range=10.0)

    azdate = orbit.reference_epoch + isce3.core.TimeDelta(aztime)
    assert azdate.isoformat() == "2003-02-26T17:55:34.122893704"
    npt.assert_almost_equal(slant_range, 830449.6727720434, decimal=6)
예제 #14
0
def main(opts):

    #instantiate slc object from NISAR SLC class
    slc = SLC(hdf5file=opts.product)

    # extract orbit
    orbit = slc.getOrbit()

    # extract the radar grid parameters
    radarGrid = slc.getRadarGrid()

    # construct ellipsoid which is by default WGS84
    ellipsoid = isce3.core.ellipsoid()

    # get doppler centroid
    doppler = slc.getDopplerCentroid()

    # instantiate geo2rdr object based on user input
    if 'cuda' not in dir(isce3) and opts.gpu:
        warnings.warn('CUDA geo2rdr not available. Switching to CPU geo2rdr')
        opts.gpu = False

    if opts.gpu:
        geo2rdrObj = isce3.cuda.geometry.geo2rdr(radarGrid=radarGrid,
                                                 orbit=orbit,
                                                 ellipsoid=ellipsoid,
                                                 doppler=doppler,
                                                 threshold=1e-9)
    else:
        geo2rdrObj = isce3.geometry.geo2rdr(radarGrid=radarGrid,
                                            orbit=orbit,
                                            ellipsoid=ellipsoid,
                                            doppler=doppler,
                                            threshold=1e-9)

    # Read topo multiband raster
    topoRaster = isce3.io.raster(filename=opts.topopath)

    # Init output directory
    os.makedirs(opts.outdir, exist_ok=True)

    # Run geo2rdr
    geo2rdrObj.geo2rdr(topoRaster,
                       outputDir=opts.outdir,
                       azshift=opts.azoff,
                       rgshift=opts.rgoff)
예제 #15
0
파일: rdr2geo.py 프로젝트: watpet/isce3
def main(opts):

    #instantiate slc object from NISAR SLC class
    slc = SLC(hdf5file=opts.product)

    # extract orbit
    orbit = slc.getOrbit()

    # extract the radar grid parameters
    radarGrid = slc.getRadarGrid()

    # construct ellipsoid which is by default WGS84
    ellipsoid = isce3.core.ellipsoid()

    # get doppler centroid
    doppler = slc.getDopplerCentroid()

    # instantiate rdr2geo object based on user input
    if 'cuda' not in dir(isce3) and opts.gpu:
        warnings.warn('CUDA rdr2geo not available. Switching to CPU rdr2geo')
        opts.gpu = False

    if opts.gpu:
        rdr2geo = isce3.cuda.geometry.rdr2geo(radarGrid=radarGrid,
                                              orbit=orbit,
                                              ellipsoid=ellipsoid,
                                              computeMask=opts.mask,
                                              doppler=doppler)
    else:
        rdr2geo = isce3.geometry.rdr2geo(radarGrid=radarGrid,
                                         orbit=orbit,
                                         ellipsoid=ellipsoid,
                                         computeMask=opts.mask,
                                         doppler=doppler)

    # Read DEM raster
    demRaster = isce3.io.raster(filename=opts.dem)

    # Init output directory
    os.makedirs(opts.outdir, exist_ok=True)

    # Run rdr2geo
    rdr2geo.topo(demRaster, outputDir=opts.outdir)

    return 0
예제 #16
0
파일: resampSlc.py 프로젝트: watpet/isce3
def main(opts):
    """
    resample SLC
    """

    # prep SLC dataset input
    productSlc = SLC(hdf5file=opts.product)

    # get grids needed for resamp object instantiation
    productGrid = productSlc.getRadarGrid(opts.frequency)

    # instantiate resamp object
    resamp = ResampSlc(productGrid, productSlc.getDopplerCentroid(),
                       productGrid.wavelength)

    # set number of lines per tile if arg > 0
    if opts.linesPerTile:
        resamp.linesPerTile = opts.linesPerTile

    # Prepare input rasters
    inSlcDataset = productSlc.getSlcDataset(opts.frequency, opts.polarization)
    inSlcRaster = Raster('', h5=inSlcDataset)
    azOffsetRaster = Raster(
        filename=os.path.join(opts.offsetdir, 'azimuth.off'))
    rgOffsetRaster = Raster(filename=os.path.join(opts.offsetdir, 'range.off'))

    # Init output directory
    if opts.outPathAndFile:
        path, file = os.path.split(opts.outPathAndFile)
        if not os.path.isdir(path):
            os.makedirs(path)

    # Prepare output raster
    driver = gdal.GetDriverByName('ISCE')
    slcPathAndName = opts.outPathAndFile
    outds = driver.Create(os.path.join(slcPathAndName), rgOffsetRaster.width,
                          rgOffsetRaster.length, 1, gdal.GDT_CFloat32)
    outSlcRaster = Raster('', dataset=outds)

    # Run resamp
    resamp.resamp(inSlc=inSlcRaster,
                  outSlc=outSlcRaster,
                  rgoffRaster=rgOffsetRaster,
                  azoffRaster=azOffsetRaster)
예제 #17
0
def test_run():
    # load parameters shared across all test runs
    # init geocode object and populate members
    rslc = SLC(hdf5file=os.path.join(iscetest.data, "envisat.h5"))
    orbit = rslc.getOrbit()
    native_doppler = rslc.getDopplerCentroid()
    native_doppler.bounds_error = False
    grid_doppler = native_doppler
    threshold_geo2rdr = 1e-8
    numiter_geo2rdr = 25
    delta_range = 1e-8

    # prepare geogrid
    geogrid = isce3.product.GeoGridParameters(start_x=-115.65,
                                              start_y=34.84,
                                              spacing_x=0.0002,
                                              spacing_y=-8.0e-5,
                                              width=500,
                                              length=500,
                                              epsg=4326)

    # get radar grid from HDF5
    radar_grid = isce3.product.RadarGridParameters(
        os.path.join(iscetest.data, "envisat.h5"))

    heights = [0.0, 1000.0]

    output_h5 = 'envisat_radar_grid_cube.h5'
    fid = h5py.File(output_h5, 'w')

    cube_group_name = '/science/LSAR/GCOV/metadata/radarGrid'

    add_radar_grid_cubes_to_hdf5(fid, cube_group_name, geogrid, heights,
                                 radar_grid, orbit, native_doppler,
                                 grid_doppler, threshold_geo2rdr,
                                 numiter_geo2rdr, delta_range)

    print('saved file:', output_h5)
예제 #18
0
def test_run():
    '''
    check if topo runs
    '''
    # prepare Rdr2Geo init params
    h5_path = os.path.join(iscetest.data, "envisat.h5")

    radargrid = isce3.product.RadarGridParameters(h5_path)

    slc = SLC(hdf5file=h5_path)
    orbit = slc.getOrbit()
    doppler = slc.getDopplerCentroid()

    ellipsoid = isce3.core.Ellipsoid()

    # init Rdr2Geo class
    rdr2geo_obj = isce3.cuda.geometry.Rdr2Geo(radargrid, orbit,
            ellipsoid, doppler)

    # load test DEM
    dem_raster = isce3.io.Raster(os.path.join(iscetest.data, "srtm_cropped.tif"))

    # run
    rdr2geo_obj.topo(dem_raster, ".")
예제 #19
0
def run(cfg):
    '''
    run geocodeSlc according to parameters in cfg dict
    '''
    # pull parameters from cfg
    input_hdf5 = cfg['input_file_group']['input_file_path']
    output_hdf5 = cfg['product_path_group']['sas_output_file']
    freq_pols = cfg['processing']['input_subset']['list_of_frequencies']
    geogrids = cfg['processing']['geocode']['geogrids']
    radar_grid_cubes_geogrid = cfg['processing']['radar_grid_cubes']['geogrid']
    radar_grid_cubes_heights = cfg['processing']['radar_grid_cubes']['heights']
    dem_file = cfg['dynamic_ancillary_file_group']['dem_file']
    threshold_geo2rdr = cfg['processing']['geo2rdr']['threshold']
    iteration_geo2rdr = cfg['processing']['geo2rdr']['maxiter']
    lines_per_block = cfg['processing']['blocksize']['y']
    dem_block_margin = cfg['processing']['dem_margin']
    flatten = cfg['processing']['flatten']

    # init parameters shared by frequency A and B
    slc = SLC(hdf5file=input_hdf5)
    orbit = slc.getOrbit()
    dem_raster = isce3.io.Raster(dem_file)
    epsg = dem_raster.get_epsg()
    proj = isce3.core.make_projection(epsg)
    ellipsoid = proj.ellipsoid

    # Doppler of the image grid (Zero for NISAR)
    image_grid_doppler = isce3.core.LUT2d()

    info_channel = journal.info("gslc.run")
    info_channel.log("starting geocode SLC")

    t_all = time.time()
    with h5py.File(output_hdf5, 'a') as dst_h5:
        for freq in freq_pols.keys():
            frequency = f"frequency{freq}"
            pol_list = freq_pols[freq]
            radar_grid = slc.getRadarGrid(freq)
            geo_grid = geogrids[freq]

            # get doppler centroid
            native_doppler = slc.getDopplerCentroid(frequency=freq)

            for polarization in pol_list:
                t_pol = time.time()

                output_dir = os.path.dirname(os.path.abspath(output_hdf5))
                os.makedirs(output_dir, exist_ok=True)

                raster_ref = f'HDF5:{input_hdf5}:/{slc.slcPath(freq, polarization)}'
                slc_raster = isce3.io.Raster(raster_ref)

                # access the HDF5 dataset for a given frequency and polarization
                dataset_path = f'/science/LSAR/GSLC/grids/{frequency}/{polarization}'
                gslc_dataset = dst_h5[dataset_path]

                # Construct the output ratster directly from HDF5 dataset
                gslc_raster = isce3.io.Raster(
                    f"IH5:::ID={gslc_dataset.id.id}".encode("utf-8"),
                    update=True)

                # run geocodeSlc
                isce3.geocode.geocode_slc(gslc_raster, slc_raster, dem_raster,
                                          radar_grid, geo_grid, orbit,
                                          native_doppler, image_grid_doppler,
                                          ellipsoid, threshold_geo2rdr,
                                          iteration_geo2rdr, lines_per_block,
                                          dem_block_margin, flatten)

                # the rasters need to be deleted
                del gslc_raster
                del slc_raster

                # output_raster_ref = f'HDF5:{output_hdf5}:/{dataset_path}'
                gslc_raster = isce3.io.Raster(
                    f"IH5:::ID={gslc_dataset.id.id}".encode("utf-8"))
                compute_stats_complex_data(gslc_raster, gslc_dataset)

                t_pol_elapsed = time.time() - t_pol
                info_channel.log(
                    f'polarization {polarization} ran in {t_pol_elapsed:.3f} seconds'
                )

            if freq.upper() == 'B':
                continue

            cube_geogrid = isce3.product.GeoGridParameters(
                start_x=radar_grid_cubes_geogrid.start_x,
                start_y=radar_grid_cubes_geogrid.start_y,
                spacing_x=radar_grid_cubes_geogrid.spacing_x,
                spacing_y=radar_grid_cubes_geogrid.spacing_y,
                width=int(radar_grid_cubes_geogrid.width),
                length=int(radar_grid_cubes_geogrid.length),
                epsg=radar_grid_cubes_geogrid.epsg)

            cube_group_name = '/science/LSAR/GSLC/metadata/radarGrid'

            native_doppler.bounds_error = False
            '''
            The native-Doppler LUT bounds error is turned off to
            computer cubes values outside radar-grid boundaries
            '''
            add_radar_grid_cubes_to_hdf5(dst_h5, cube_group_name, cube_geogrid,
                                         radar_grid_cubes_heights, radar_grid,
                                         orbit, native_doppler,
                                         image_grid_doppler, threshold_geo2rdr,
                                         iteration_geo2rdr)

    t_all_elapsed = time.time() - t_all
    info_channel.log(
        f"successfully ran geocode SLC in {t_all_elapsed:.3f} seconds")
예제 #20
0
파일: rtc.py 프로젝트: isce-framework/isce3
def test_rtc():

    # Open HDF5 file and create radar grid parameter
    print('iscetest.data:', iscetest.data)
    h5_path = os.path.join(iscetest.data, 'envisat.h5')
    slc_obj = SLC(hdf5file=h5_path)
    frequency = 'A'
    radar_grid_sl = slc_obj.getRadarGrid(frequency)

    # Open DEM raster
    dem_file = os.path.join(iscetest.data, 'srtm_cropped.tif')
    dem_obj = isce3.io.Raster(dem_file)

    # Crop original radar grid parameter
    radar_grid_cropped = \
            radar_grid_sl.offset_and_resize(30, 135, 128, 128)

    # Multi-look original radar grid parameter
    nlooks_az = 5
    nlooks_rg = 5
    radar_grid_ml = \
            radar_grid_sl.multilook(nlooks_az, nlooks_rg)

    # Create orbit and Doppler LUT
    orbit = slc_obj.getOrbit()
    doppler = slc_obj.getDopplerCentroid()
    doppler.bounds_error = False
    # doppler = isce3.core.LUT2d()

    # set input parameters
    input_terrain_radiometry = isce3.geometry.RtcInputTerrainRadiometry.BETA_NAUGHT
    output_terrain_radiometry = isce3.geometry.RtcOutputTerrainRadiometry.GAMMA_NAUGHT

    rtc_area_mode = isce3.geometry.RtcAreaMode.AREA_FACTOR

    for radar_grid_str in radar_grid_str_list:

        # Open DEM raster
        if (radar_grid_str == 'cropped'):
            radar_grid = radar_grid_cropped
        else:
            radar_grid = radar_grid_ml

        for rtc_algorithm in rtc_algorithm_list:

            geogrid_upsampling = 1

            # test removed because it requires high geogrid upsampling (too
            # slow)
            if (rtc_algorithm
                    == isce3.geometry.RtcAlgorithm.RTC_BILINEAR_DISTRIBUTION
                    and radar_grid_str == 'cropped'):
                continue
            elif (rtc_algorithm ==
                  isce3.geometry.RtcAlgorithm.RTC_BILINEAR_DISTRIBUTION):
                filename = './rtc_bilinear_distribution_' + radar_grid_str + '.bin'
            else:
                filename = './rtc_area_proj_' + radar_grid_str + '.bin'

            print('generating file:', filename)

            # Create output raster
            out_raster = isce3.io.Raster(filename, radar_grid.width,
                                         radar_grid.length, 1,
                                         gdal.GDT_Float32, 'ENVI')

            # Call RTC
            isce3.geometry.compute_rtc(radar_grid, orbit, doppler, dem_obj,
                                       out_raster, input_terrain_radiometry,
                                       output_terrain_radiometry,
                                       rtc_area_mode, rtc_algorithm,
                                       geogrid_upsampling)

            del out_raster

    # check results
    for radar_grid_str in radar_grid_str_list:
        for rtc_algorithm in rtc_algorithm_list:

            # test removed because it requires high geogrid upsampling (too
            # slow)
            if (rtc_algorithm
                    == isce3.geometry.RtcAlgorithm.RTC_BILINEAR_DISTRIBUTION
                    and radar_grid_str == 'cropped'):
                continue
            elif (rtc_algorithm ==
                  isce3.geometry.RtcAlgorithm.RTC_BILINEAR_DISTRIBUTION):
                max_rmse = 0.7
                filename = './rtc_bilinear_distribution_' + radar_grid_str + '.bin'
            else:
                max_rmse = 0.1
                filename = './rtc_area_proj_' + radar_grid_str + '.bin'

            print('evaluating file:', os.path.abspath(filename))

            # Open computed integrated-area raster
            test_gdal_dataset = gdal.Open(filename)

            # Open reference raster
            ref_filename = os.path.join(iscetest.data,
                                        'rtc/rtc_' + radar_grid_str + '.bin')

            ref_gdal_dataset = gdal.Open(ref_filename)
            print('reference file:', ref_filename)

            assert (
                test_gdal_dataset.RasterXSize == ref_gdal_dataset.RasterXSize)
            assert (
                test_gdal_dataset.RasterYSize == ref_gdal_dataset.RasterYSize)

            square_sum = 0.0  # sum of square difference
            n_nan = 0  # number of NaN pixels
            n_npos = 0  # number of non-positive pixels

            # read test and ref arrays
            test_array = test_gdal_dataset.GetRasterBand(1).ReadAsArray()
            ref_array = ref_gdal_dataset.GetRasterBand(1).ReadAsArray()

            n_valid = 0

            # iterates over rows (i) and columns (j)
            for i in range(ref_gdal_dataset.RasterYSize):
                for j in range(ref_gdal_dataset.RasterXSize):

                    # if nan, increment n_nan
                    if (np.isnan(test_array[i, j])
                            or np.isnan(ref_array[i, j])):
                        n_nan = n_nan + 1
                        continue

                    # if n_npos, incremennt n_npos
                    if (ref_array[i, j] <= 0 or test_array[i, j] <= 0):
                        n_npos = n_npos + 1
                        continue

                    # otherwise, increment n_valid
                    n_valid = n_valid + 1
                    square_sum += (test_array[i, j] - ref_array[i, j])**2
            print('    ----------------')
            print('    # total:', n_valid + n_nan + n_npos)
            print('    ----------------')
            print('    # valid:', n_valid)
            print('    # NaNs:', n_nan)
            print('    # non-positive:', n_npos)
            print('    ----------------')
            assert (n_valid != 0)

            # Compute average over entire image
            rmse = np.sqrt(square_sum / n_valid)

            print('    RMSE =', rmse)
            print('    ----------------')
            # Enforce bound on average pixel-error
            assert (rmse < max_rmse)

            # Enforce bound on number of ignored pixels
            assert (n_nan < 1e-4 * ref_gdal_dataset.RasterXSize *
                    ref_gdal_dataset.RasterYSize)
            assert (n_npos < 1e-4 * ref_gdal_dataset.RasterXSize *
                    ref_gdal_dataset.RasterYSize)
예제 #21
0
파일: crossmul.py 프로젝트: watpet/isce3
def main(opts):
    """
    crossmul
    """
    # prepare input rasters
    referenceSlc = SLC(hdf5file=opts.reference)
    referenceSlcDataset = referenceSlc.getSlcDataset(opts.frequency,
                                                     opts.polarization)
    referenceSlcRaster = isce3.io.raster(filename='', h5=referenceSlcDataset)
    secondarySlc = SLC(hdf5file=opts.secondary)
    if opts.secondaryRaster:
        secondarySlcRaster = isce3.io.raster(filename=opts.secondaryRaster)
    else:
        secondarySlcDataset = secondarySlc.getSlcDataset(
            opts.frequency, opts.polarization)
        secondarySlcRaster = isce3.io.raster(filename='',
                                             h5=secondarySlcDataset)

    # prepare mulitlooked interferogram dimensions
    referenceGrid = referenceSlc.getRadarGrid(opts.frequency)
    length = int(referenceGrid.length / opts.alks)
    width = int(referenceGrid.width / opts.rlks)

    # init output directory(s)
    getDir = lambda filepath: os.path.split(filepath)[0]
    os.makedirs(getDir(opts.intFilePath), exist_ok=True)
    os.makedirs(getDir(opts.cohFilePath), exist_ok=True)

    # prepare output rasters
    driver = gdal.GetDriverByName('ISCE')
    igramDataset = driver.Create(opts.intFilePath, width, length, 1,
                                 gdal.GDT_CFloat32)
    igramRaster = isce3.io.raster(filename='', dataset=igramDataset)
    # coherence only generated when multilooked enabled
    if (opts.alks > 1 or opts.rlks > 1):
        cohDataset = driver.Create(opts.cohFilePath, width, length, 1,
                                   gdal.GDT_Float32)
        cohRaster = isce3.io.raster(filename='', dataset=cohDataset)
    else:
        cohRaster = None

    # prepare optional rasters
    if opts.rgoff:
        rgOffRaster = isce3.io.raster(filename=opts.rgoff)
    else:
        rgOffRaster = None

    if opts.azband:
        dopReference = referenceSlc.getDopplerCentroid()
        dopSecondary = secondarySlc.getDopplerCentroid()
        prf = referenceSlc.getSwathMetadata(
            opts.frequency).nominalAcquisitionPRF
        azimuthBandwidth = opts.azband
    else:
        dopReference = dopSecondary = None
        prf = azimuthBandwidth = 0.0

    # instantiate crossmul object based on user input
    if 'cuda' not in dir(isce3) and opts.gpu:
        warnings.warn('CUDA crossmul not available. Switching to CPU crossmul')
        opts.gpu = False

    if opts.gpu:
        crossmul = isce3.cuda.signal.crossmul()
    else:
        crossmul = isce3.signal.crossmul()

    crossmul.crossmul(referenceSlcRaster,
                      secondarySlcRaster,
                      igramRaster,
                      cohRaster,
                      rngOffset=rgOffRaster,
                      refDoppler=dopReference,
                      secDoppler=dopSecondary,
                      rangeLooks=opts.rlks,
                      azimuthLooks=opts.alks,
                      prf=prf,
                      azimuthBandwidth=azimuthBandwidth)
예제 #22
0
def run(cfg: dict, output_hdf5: str = None, resample_type='coarse'):
    '''
    run crossmul
    '''
    # pull parameters from cfg
    ref_hdf5 = cfg['input_file_group']['input_file_path']
    sec_hdf5 = cfg['input_file_group']['secondary_file_path']
    freq_pols = cfg['processing']['input_subset']['list_of_frequencies']
    flatten = cfg['processing']['crossmul']['flatten']

    if flatten is not None:
        flatten_path = cfg['processing']['crossmul']['flatten']

    if output_hdf5 is None:
        output_hdf5 = cfg['product_path_group']['sas_output_file']

    # init parameters shared by frequency A and B
    ref_slc = SLC(hdf5file=ref_hdf5)
    sec_slc = SLC(hdf5file=sec_hdf5)

    error_channel = journal.error('crossmul.run')
    info_channel = journal.info("crossmul.run")
    info_channel.log("starting crossmultipy")

    # check if gpu ok to use
    use_gpu = isce3.core.gpu_check.use_gpu(cfg['worker']['gpu_enabled'],
                                           cfg['worker']['gpu_id'])
    if use_gpu:
        # Set the current CUDA device.
        device = isce3.cuda.core.Device(cfg['worker']['gpu_id'])
        isce3.cuda.core.set_device(device)
        crossmul = isce3.cuda.signal.Crossmul()
    else:
        crossmul = isce3.signal.Crossmul()

    crossmul.range_looks = cfg['processing']['crossmul']['range_looks']
    crossmul.az_looks = cfg['processing']['crossmul']['azimuth_looks']
    crossmul.oversample = cfg['processing']['crossmul']['oversample']
    crossmul.rows_per_block = cfg['processing']['crossmul']['rows_per_block']

    # check if user provided path to raster(s) is a file or directory
    coregistered_slc_path = pathlib.Path(
        cfg['processing']['crossmul']['coregistered_slc_path'])
    coregistered_is_file = coregistered_slc_path.is_file()
    if not coregistered_is_file and not coregistered_slc_path.is_dir():
        err_str = f"{coregistered_slc_path} is invalid; needs to be a file or directory."
        error_channel.log(err_str)
        raise ValueError(err_str)

    t_all = time.time()
    with h5py.File(output_hdf5, 'a', libver='latest', swmr=True) as dst_h5:
        for freq, pol_list in freq_pols.items():
            # get 2d doppler, discard azimuth dependency, and set crossmul dopplers
            ref_dopp = isce3.core.avg_lut2d_to_lut1d(
                ref_slc.getDopplerCentroid(frequency=freq))
            sec_dopp = isce3.core.avg_lut2d_to_lut1d(
                sec_slc.getDopplerCentroid(frequency=freq))
            crossmul.set_dopplers(ref_dopp, sec_dopp)

            freq_group_path = f'/science/LSAR/RIFG/swaths/frequency{freq}'

            if flatten is not None:
                # set frequency dependent range offset raster
                flatten_raster = isce3.io.Raster(
                    f'{flatten_path}/geo2rdr/freq{freq}/range.off')

                # prepare range filter parameters
                rdr_grid = ref_slc.getRadarGrid(freq)
                rg_pxl_spacing = rdr_grid.range_pixel_spacing
                wavelength = rdr_grid.wavelength
                rg_sample_freq = isce3.core.speed_of_light / 2.0 / rg_pxl_spacing
                rg_bandwidth = ref_slc.getSwathMetadata(
                    freq).processed_range_bandwidth

                # set crossmul range filter
                crossmul.set_rg_filter(rg_sample_freq, rg_bandwidth,
                                       rg_pxl_spacing, wavelength)

            for pol in pol_list:
                pol_group_path = f'{freq_group_path}/interferogram/{pol}'

                # prepare reference input raster
                ref_raster_str = f'HDF5:{ref_hdf5}:/{ref_slc.slcPath(freq, pol)}'
                ref_slc_raster = isce3.io.Raster(ref_raster_str)

                # prepare secondary input raster
                if coregistered_is_file:
                    raster_str = f'HDF5:{sec_hdf5}:/{sec_slc.slcPath(freq, pol)}'
                else:
                    raster_str = str(
                        coregistered_slc_path /
                        f'{resample_type}_resample_slc/'
                        f'freq{freq}/{pol}/coregistered_secondary.slc')

                sec_slc_raster = isce3.io.Raster(raster_str)

                # access the HDF5 dataset for a given frequency and polarization
                dataset_path = f'{pol_group_path}/wrappedInterferogram'
                igram_dataset = dst_h5[dataset_path]

                # Construct the output ratster directly from HDF5 dataset
                igram_raster = isce3.io.Raster(
                    f"IH5:::ID={igram_dataset.id.id}".encode("utf-8"),
                    update=True)

                # call crossmul with coherence if multilooked
                if crossmul.range_looks > 1 or crossmul.az_looks > 1:
                    # access the HDF5 dataset for a given frequency and polarization
                    dataset_path = f'{pol_group_path}/coherenceMagnitude'
                    coherence_dataset = dst_h5[dataset_path]

                    # Construct the output ratster directly from HDF5 dataset
                    coherence_raster = isce3.io.Raster(
                        f"IH5:::ID={coherence_dataset.id.id}".encode("utf-8"),
                        update=True)

                    if flatten is not None:
                        crossmul.crossmul(ref_slc_raster, sec_slc_raster,
                                          flatten_raster, igram_raster,
                                          coherence_raster)
                    else:
                        crossmul.crossmul(ref_slc_raster, sec_slc_raster,
                                          igram_raster, coherence_raster)

                    # Allocate raster statistics for coherence
                    compute_stats_real_data(coherence_raster,
                                            coherence_dataset)

                    del coherence_raster
                else:
                    # no coherence without multilook
                    crossmul.crossmul(ref_slc_raster, sec_slc_raster,
                                      igram_raster)
                del igram_raster

                # Allocate stats for rubbersheet offsets
                stats_offsets(dst_h5, freq, pol)

    t_all_elapsed = time.time() - t_all
    info_channel.log(
        f"successfully ran crossmul in {t_all_elapsed:.3f} seconds")
예제 #23
0
def run(cfg, resample_type):
    '''
    run resample_slc
    '''
    input_hdf5 = cfg['input_file_group']['secondary_file_path']
    scratch_path = pathlib.Path(cfg['product_path_group']['scratch_path'])
    freq_pols = cfg['processing']['input_subset']['list_of_frequencies']

    # According to the type of resampling, choose proper resample cfg
    resamp_args = cfg['processing'][f'{resample_type}_resample']

    # Get SLC parameters
    slc = SLC(hdf5file=input_hdf5)

    info_channel = journal.info('resample_slc.run')
    info_channel.log('starting resampling SLC')

    # Check if use GPU or CPU resampling
    use_gpu = isce3.core.gpu_check.use_gpu(cfg['worker']['gpu_enabled'],
                                           cfg['worker']['gpu_id'])

    if use_gpu:
        # Set current CUDA device
        device = isce3.cuda.core.Device(cfg['worker']['gpu_id'])
        isce3.cuda.core.set_device(device)

    t_all = time.time()

    for freq in freq_pols.keys():
        # Get frequency specific parameters
        radar_grid = slc.getRadarGrid(frequency=freq)
        native_doppler = slc.getDopplerCentroid(frequency=freq)

        # Open offsets
        offsets_dir = pathlib.Path(resamp_args['offsets_dir'])

        # Create separate directories for coarse and fine resample
        # Open corresponding range/azimuth offsets
        resample_slc_scratch_path = scratch_path / \
                                    f'{resample_type}_resample_slc' / f'freq{freq}'
        if resample_type == 'coarse':
            offsets_path = offsets_dir / 'geo2rdr' / f'freq{freq}'
            rg_off = isce3.io.Raster(str(offsets_path / 'range.off'))
            az_off = isce3.io.Raster(str(offsets_path / 'azimuth.off'))
        else:
            # We checked the existence of HH/VV offsets in resample_slc_runconfig.py
            # Select the first offsets available between HH and VV
            freq_offsets_path = offsets_dir / 'rubbersheet_offsets' / f'freq{freq}'
            if os.path.isdir(str(freq_offsets_path / 'HH')):
                offsets_path = freq_offsets_path / 'HH'
            else:
                offsets_path = freq_offsets_path / 'VV'
            rg_off = isce3.io.Raster(str(offsets_path / 'range.off.vrt'))
            az_off = isce3.io.Raster(str(offsets_path / 'azimuth.off.vrt'))

        # Create resample slc directory
        resample_slc_scratch_path.mkdir(parents=True, exist_ok=True)

        # Initialize CPU or GPU resample object accordingly
        if use_gpu:
            Resamp = isce3.cuda.image.ResampSlc
        else:
            Resamp = isce3.image.ResampSlc

        resamp_obj = Resamp(radar_grid, native_doppler)

        # If lines per tile is > 0, assign it to resamp_obj
        if resamp_args['lines_per_tile']:
            resamp_obj.lines_per_tile = resamp_args['lines_per_tile']

        # Get polarization list for which resample SLCs
        pol_list = freq_pols[freq]

        for pol in pol_list:
            # Create directory for each polarization
            out_dir = resample_slc_scratch_path / pol
            out_dir.mkdir(parents=True, exist_ok=True)
            out_path = out_dir / 'coregistered_secondary.slc'

            # Extract and create raster of SLC to resample
            h5_ds = f'/{slc.SwathPath}/frequency{freq}/{pol}'
            raster_path = f'HDF5:{input_hdf5}:{h5_ds}'
            raster = isce3.io.Raster(raster_path)

            # Create output raster
            resamp_slc = isce3.io.Raster(str(out_path), rg_off.width,
                                         rg_off.length, rg_off.num_bands,
                                         gdal.GDT_CFloat32, 'ENVI')
            resamp_obj.resamp(raster, resamp_slc, rg_off, az_off)

    t_all_elapsed = time.time() - t_all
    info_channel.log(
        f"successfully ran resample in {t_all_elapsed:.3f} seconds")
예제 #24
0
 def doppler(self):
     tempSlc = SLC(hdf5file=self.state.input_hdf5)
     dop = tempSlc.getDopplerCentroid()
     
     return dop
예제 #25
0
def runGeocodeSLC(self):
    self._print('starting geocode module')

    state = self.state

    time_id = str(time.time())

    orbit = self.orbit

    dem_raster = isce3.io.raster(filename=state.dem_file)

    # construct ellipsoid which is by default WGS84
    ellipsoid = isce3.core.ellipsoid()

    slc = SLC(hdf5file=self.state.input_hdf5)
    for freq in state.subset_dict.keys():
        frequency = "frequency{}".format(freq)
        pol_list = state.subset_dict[freq]
        radar_grid = self.radar_grid_list[freq]
        geo_grid = self.geogrid_dict[frequency]
        for polarization in pol_list:
            self._print(
                f'working on frequency: {freq}, polarization: {polarization}')
            # get doppler centroid
            native_doppler = slc.getDopplerCentroid(frequency=freq)

            # Doppler of the image grid (Zero for NISAR)
            image_grid_doppler = isce3.core.lut2d()

            output_dir = os.path.dirname(
                os.path.abspath(self.state.output_hdf5))
            os.makedirs(output_dir, exist_ok=True)

            slc_dataset = self.slc_obj.getSlcDataset(freq, polarization)
            slc_raster = isce3.io.raster(filename='', h5=slc_dataset)

            # access the HDF5 dataset for a given frequency and polarization
            dst_h5 = h5py.File(state.output_hdf5, 'a')
            dataset_path = f'science/LSAR/GSLC/grids/{frequency}/{polarization}'
            gslc_dataset = dst_h5[dataset_path]

            # Construct the output ratster directly from HDF5 dataset
            gslc_raster = isce3.io.raster(filename='',
                                          h5=gslc_dataset,
                                          access=gdal.GA_Update)

            # This whole section requires better sanity check and handling defaults
            threshold_geo2rdr = self.userconfig['runconfig']['groups'][
                'processing']['geo2rdr']['threshold']
            iteration_geo2rdr = self.userconfig['runconfig']['groups'][
                'processing']['geo2rdr']['maxiter']
            lines_per_block = self.userconfig['runconfig']['groups'][
                'processing']['blocksize']['y']
            dem_block_margin = self.userconfig['runconfig']['groups'][
                'processing']['dem_margin']
            flatten = self.userconfig['runconfig']['groups']['processing'][
                'flatten']

            # this may not be the best way. needs to be revised
            if flatten:
                self._print("flattening is True")
            else:
                self._print("flattening is False")

            if np.isnan(threshold_geo2rdr):
                threshold_geo2rdr = 1.0e-9

            if np.isnan(iteration_geo2rdr):
                iteration_geo2rdr = 25

            if np.isnan(lines_per_block):
                lines_per_block = 1000

            if np.isnan(dem_block_margin):
                dem_block_margin = 0.1

            # run geocodeSlc :
            isce3.geocode.geocodeSlc(gslc_raster, slc_raster, dem_raster,
                                     radar_grid, geo_grid, orbit,
                                     native_doppler, image_grid_doppler,
                                     ellipsoid, threshold_geo2rdr,
                                     iteration_geo2rdr, lines_per_block,
                                     dem_block_margin, flatten)

            # the rasters need to be deleted
            del gslc_raster
            del slc_raster

            dst_h5.close()
예제 #26
0
def run(cfg):
    '''
    run GCOV
    '''

    # pull parameters from cfg
    input_hdf5 = cfg['input_file_group']['input_file_path']
    output_hdf5 = cfg['product_path_group']['sas_output_file']
    freq_pols = cfg['processing']['input_subset']['list_of_frequencies']
    flag_fullcovariance = cfg['processing']['input_subset']['fullcovariance']
    flag_symmetrize_cross_pol_channels = \
        cfg['processing']['input_subset']['symmetrize_cross_pol_channels']
    scratch_path = cfg['product_path_group']['scratch_path']

    radar_grid_cubes_geogrid = cfg['processing']['radar_grid_cubes']['geogrid']
    radar_grid_cubes_heights = cfg['processing']['radar_grid_cubes']['heights']

    # DEM parameters
    dem_file = cfg['dynamic_ancillary_file_group']['dem_file']
    dem_margin = cfg['processing']['dem_margin']
    dem_interp_method_enum = cfg['processing']['dem_interpolation_method_enum']

    # unpack geocode run parameters
    geocode_dict = cfg['processing']['geocode']
    geocode_algorithm = geocode_dict['algorithm_type']
    output_mode = geocode_dict['output_mode']
    flag_apply_rtc = geocode_dict['apply_rtc']
    memory_mode = geocode_dict['memory_mode']
    geogrid_upsampling = geocode_dict['geogrid_upsampling']
    abs_cal_factor = geocode_dict['abs_rad_cal']
    clip_max = geocode_dict['clip_max']
    clip_min = geocode_dict['clip_min']
    geogrids = geocode_dict['geogrids']
    flag_upsample_radar_grid = geocode_dict['upsample_radargrid']
    flag_save_nlooks = geocode_dict['save_nlooks']
    flag_save_rtc = geocode_dict['save_rtc']
    flag_save_dem = geocode_dict['save_dem']

    # unpack RTC run parameters
    rtc_dict = cfg['processing']['rtc']
    output_terrain_radiometry = rtc_dict['output_type']
    rtc_algorithm = rtc_dict['algorithm_type']
    input_terrain_radiometry = rtc_dict['input_terrain_radiometry']
    rtc_min_value_db = rtc_dict['rtc_min_value_db']
    rtc_upsampling = rtc_dict['dem_upsampling']

    # unpack geo2rdr parameters
    geo2rdr_dict = cfg['processing']['geo2rdr']
    threshold = geo2rdr_dict['threshold']
    maxiter = geo2rdr_dict['maxiter']

    if (flag_apply_rtc and output_terrain_radiometry
            == isce3.geometry.RtcOutputTerrainRadiometry.SIGMA_NAUGHT):
        output_radiometry_str = "radar backscatter sigma0"
    elif (flag_apply_rtc and output_terrain_radiometry
          == isce3.geometry.RtcOutputTerrainRadiometry.GAMMA_NAUGHT):
        output_radiometry_str = 'radar backscatter gamma0'
    elif input_terrain_radiometry == isce3.geometry.RtcInputTerrainRadiometry.BETA_NAUGHT:
        output_radiometry_str = 'radar backscatter beta0'
    else:
        output_radiometry_str = 'radar backscatter sigma0'

    # unpack pre-processing
    preprocess = cfg['processing']['pre_process']
    rg_look = preprocess['range_looks']
    az_look = preprocess['azimuth_looks']
    radar_grid_nlooks = rg_look * az_look

    # init parameters shared between frequencyA and frequencyB sub-bands
    slc = SLC(hdf5file=input_hdf5)
    dem_raster = isce3.io.Raster(dem_file)
    zero_doppler = isce3.core.LUT2d()
    epsg = dem_raster.get_epsg()
    proj = isce3.core.make_projection(epsg)
    ellipsoid = proj.ellipsoid
    exponent = 2

    info_channel = journal.info("gcov.run")
    error_channel = journal.error("gcov.run")
    info_channel.log("starting geocode COV")

    t_all = time.time()
    for frequency in freq_pols.keys():

        t_freq = time.time()

        # unpack frequency dependent parameters
        radar_grid = slc.getRadarGrid(frequency)
        if radar_grid_nlooks > 1:
            radar_grid = radar_grid.multilook(az_look, rg_look)
        geogrid = geogrids[frequency]
        input_pol_list = freq_pols[frequency]

        # do no processing if no polarizations specified for current frequency
        if not input_pol_list:
            continue

        # set dict of input rasters
        input_raster_dict = {}

        # `input_pol_list` is the input list of polarizations that may include
        # HV and VH. `pol_list` is the actual list of polarizations to be
        # geocoded. It may include HV but it will not include VH if the
        # polarimetric symmetrization is performed
        pol_list = input_pol_list
        for pol in pol_list:
            temp_ref = \
                f'HDF5:"{input_hdf5}":/{slc.slcPath(frequency, pol)}'
            temp_raster = isce3.io.Raster(temp_ref)
            input_raster_dict[pol] = temp_raster
        # symmetrize cross-polarimetric channels (if applicable)
        if (flag_symmetrize_cross_pol_channels and 'HV' in input_pol_list
                and 'VH' in input_pol_list):

            # create output raster
            symmetrized_hv_temp = tempfile.NamedTemporaryFile(dir=scratch_path,
                                                              suffix='.tif')

            # get cross-polarimetric channels from input_raster_dict
            hv_raster_obj = input_raster_dict['HV']
            vh_raster_obj = input_raster_dict['VH']

            # create output symmetrized HV object
            symmetrized_hv_obj = isce3.io.Raster(symmetrized_hv_temp.name,
                                                 hv_raster_obj.width,
                                                 hv_raster_obj.length,
                                                 hv_raster_obj.num_bands,
                                                 hv_raster_obj.datatype(),
                                                 'GTiff')

            # call symmetrization function
            isce3.polsar.symmetrize_cross_pol_channels(hv_raster_obj,
                                                       vh_raster_obj,
                                                       symmetrized_hv_obj)

            # ensure changes are flushed to disk by closing & re-opening the
            # raster.
            del symmetrized_hv_obj
            symmetrized_hv_obj = isce3.io.Raster(symmetrized_hv_temp.name)

            # Since HV and VH were symmetrized into HV, remove VH from
            # `pol_list` and `from input_raster_dict`.
            pol_list.remove('VH')
            input_raster_dict.pop('VH')

            # Update `input_raster_dict` with the new `symmetrized_hv_obj`
            input_raster_dict['HV'] = symmetrized_hv_obj

        # construct input rasters
        input_raster_list = []
        for pol in pol_list:
            input_raster_list.append(input_raster_dict[pol])

        # set paths temporary files
        input_temp = tempfile.NamedTemporaryFile(dir=scratch_path,
                                                 suffix='.vrt')
        input_raster_obj = isce3.io.Raster(input_temp.name,
                                           raster_list=input_raster_list)

        # init Geocode object depending on raster type
        if input_raster_obj.datatype() == gdal.GDT_Float32:
            geo = isce3.geocode.GeocodeFloat32()
        elif input_raster_obj.datatype() == gdal.GDT_Float64:
            geo = isce3.geocode.GeocodeFloat64()
        elif input_raster_obj.datatype() == gdal.GDT_CFloat32:
            geo = isce3.geocode.GeocodeCFloat32()
        elif input_raster_obj.datatype() == gdal.GDT_CFloat64:
            geo = isce3.geocode.GeocodeCFloat64()
        else:
            err_str = 'Unsupported raster type for geocoding'
            error_channel.log(err_str)
            raise NotImplementedError(err_str)

        orbit = slc.getOrbit()

        # init geocode members
        geo.orbit = orbit
        geo.ellipsoid = ellipsoid
        geo.doppler = zero_doppler
        geo.threshold_geo2rdr = threshold
        geo.numiter_geo2rdr = maxiter
        geo.dem_block_margin = dem_margin

        # set data interpolator based on the geocode algorithm
        if output_mode == isce3.geocode.GeocodeOutputMode.INTERP:
            geo.data_interpolator = geocode_algorithm

        geo.geogrid(geogrid.start_x, geogrid.start_y, geogrid.spacing_x,
                    geogrid.spacing_y, geogrid.width, geogrid.length,
                    geogrid.epsg)

        # create output raster
        temp_output = tempfile.NamedTemporaryFile(dir=scratch_path,
                                                  suffix='.tif')

        output_raster_obj = isce3.io.Raster(temp_output.name, geogrid.width,
                                            geogrid.length,
                                            input_raster_obj.num_bands,
                                            gdal.GDT_Float32, 'GTiff')

        nbands_off_diag_terms = 0
        out_off_diag_terms_obj = None
        if flag_fullcovariance:
            nbands = input_raster_obj.num_bands
            nbands_off_diag_terms = (nbands**2 - nbands) // 2
            if nbands_off_diag_terms > 0:
                temp_off_diag = tempfile.NamedTemporaryFile(dir=scratch_path,
                                                            suffix='.tif')
                out_off_diag_terms_obj = isce3.io.Raster(
                    temp_off_diag.name, geogrid.width, geogrid.length,
                    nbands_off_diag_terms, gdal.GDT_CFloat32, 'GTiff')

        if flag_save_nlooks:
            temp_nlooks = tempfile.NamedTemporaryFile(dir=scratch_path,
                                                      suffix='.tif')
            out_geo_nlooks_obj = isce3.io.Raster(temp_nlooks.name,
                                                 geogrid.width, geogrid.length,
                                                 1, gdal.GDT_Float32, "GTiff")
        else:
            temp_nlooks = None
            out_geo_nlooks_obj = None

        if flag_save_rtc:
            temp_rtc = tempfile.NamedTemporaryFile(dir=scratch_path,
                                                   suffix='.tif')
            out_geo_rtc_obj = isce3.io.Raster(temp_rtc.name, geogrid.width,
                                              geogrid.length, 1,
                                              gdal.GDT_Float32, "GTiff")
        else:
            temp_rtc = None
            out_geo_rtc_obj = None

        if flag_save_dem:
            temp_interpolated_dem = tempfile.NamedTemporaryFile(
                dir=scratch_path, suffix='.tif')
            if (output_mode == isce3.geocode.GeocodeOutputMode.AREA_PROJECTION
                ):
                interpolated_dem_width = geogrid.width + 1
                interpolated_dem_length = geogrid.length + 1
            else:
                interpolated_dem_width = geogrid.width
                interpolated_dem_length = geogrid.length
            out_geo_dem_obj = isce3.io.Raster(temp_interpolated_dem.name,
                                              interpolated_dem_width,
                                              interpolated_dem_length, 1,
                                              gdal.GDT_Float32, "GTiff")
        else:
            temp_interpolated_dem = None
            out_geo_dem_obj = None

        # geocode rasters
        geo.geocode(radar_grid=radar_grid,
                    input_raster=input_raster_obj,
                    output_raster=output_raster_obj,
                    dem_raster=dem_raster,
                    output_mode=output_mode,
                    geogrid_upsampling=geogrid_upsampling,
                    flag_apply_rtc=flag_apply_rtc,
                    input_terrain_radiometry=input_terrain_radiometry,
                    output_terrain_radiometry=output_terrain_radiometry,
                    exponent=exponent,
                    rtc_min_value_db=rtc_min_value_db,
                    rtc_upsampling=rtc_upsampling,
                    rtc_algorithm=rtc_algorithm,
                    abs_cal_factor=abs_cal_factor,
                    flag_upsample_radar_grid=flag_upsample_radar_grid,
                    clip_min=clip_min,
                    clip_max=clip_max,
                    radargrid_nlooks=radar_grid_nlooks,
                    out_off_diag_terms=out_off_diag_terms_obj,
                    out_geo_nlooks=out_geo_nlooks_obj,
                    out_geo_rtc=out_geo_rtc_obj,
                    out_geo_dem=out_geo_dem_obj,
                    input_rtc=None,
                    output_rtc=None,
                    dem_interp_method=dem_interp_method_enum,
                    memory_mode=memory_mode)

        del output_raster_obj

        if flag_save_nlooks:
            del out_geo_nlooks_obj

        if flag_save_rtc:
            del out_geo_rtc_obj

        if flag_save_dem:
            del out_geo_dem_obj

        if flag_fullcovariance:
            # out_off_diag_terms_obj.close_dataset()
            del out_off_diag_terms_obj

        with h5py.File(output_hdf5, 'a') as hdf5_obj:
            hdf5_obj.attrs['Conventions'] = np.string_("CF-1.8")
            root_ds = f'/science/LSAR/GCOV/grids/frequency{frequency}'

            h5_ds = os.path.join(root_ds, 'listOfPolarizations')
            if h5_ds in hdf5_obj:
                del hdf5_obj[h5_ds]
            pol_list_s2 = np.array(pol_list, dtype='S2')
            dset = hdf5_obj.create_dataset(h5_ds, data=pol_list_s2)
            dset.attrs['description'] = np.string_(
                'List of processed polarization layers with frequency ' +
                frequency)

            h5_ds = os.path.join(root_ds, 'radiometricTerrainCorrectionFlag')
            if h5_ds in hdf5_obj:
                del hdf5_obj[h5_ds]
            dset = hdf5_obj.create_dataset(h5_ds, data=bool(flag_apply_rtc))

            # save GCOV diagonal elements
            xds = hdf5_obj[os.path.join(root_ds, 'xCoordinates')]
            yds = hdf5_obj[os.path.join(root_ds, 'yCoordinates')]
            cov_elements_list = [p.upper() + p.upper() for p in pol_list]

            # save GCOV imagery
            _save_hdf5_dataset(temp_output.name,
                               hdf5_obj,
                               root_ds,
                               yds,
                               xds,
                               cov_elements_list,
                               long_name=output_radiometry_str,
                               units='',
                               valid_min=clip_min,
                               valid_max=clip_max)

            # save listOfCovarianceTerms
            freq_group = hdf5_obj[root_ds]
            if not flag_fullcovariance:
                _save_list_cov_terms(cov_elements_list, freq_group)

            # save nlooks
            if flag_save_nlooks:
                _save_hdf5_dataset(temp_nlooks.name,
                                   hdf5_obj,
                                   root_ds,
                                   yds,
                                   xds,
                                   'numberOfLooks',
                                   long_name='number of looks',
                                   units='',
                                   valid_min=0)

            # save rtc
            if flag_save_rtc:
                _save_hdf5_dataset(temp_rtc.name,
                                   hdf5_obj,
                                   root_ds,
                                   yds,
                                   xds,
                                   'areaNormalizationFactor',
                                   long_name='RTC area factor',
                                   units='',
                                   valid_min=0)

            # save interpolated DEM
            if flag_save_dem:
                '''
                The DEM is interpolated over the geogrid pixels vertices
                rather than the pixels centers.
                '''
                if (output_mode ==
                        isce3.geocode.GeocodeOutputMode.AREA_PROJECTION):
                    dem_geogrid = isce3.product.GeoGridParameters(
                        start_x=geogrid.start_x - geogrid.spacing_x / 2,
                        start_y=geogrid.start_y - geogrid.spacing_y / 2,
                        spacing_x=geogrid.spacing_x,
                        spacing_y=geogrid.spacing_y,
                        width=int(geogrid.width) + 1,
                        length=int(geogrid.length) + 1,
                        epsg=geogrid.epsg)
                    yds_dem, xds_dem = \
                        set_get_geo_info(hdf5_obj, root_ds, dem_geogrid)
                else:
                    yds_dem = yds
                    xds_dem = xds

                _save_hdf5_dataset(temp_interpolated_dem.name,
                                   hdf5_obj,
                                   root_ds,
                                   yds_dem,
                                   xds_dem,
                                   'interpolatedDem',
                                   long_name='Interpolated DEM',
                                   units='')

            # save GCOV off-diagonal elements
            if flag_fullcovariance:
                off_diag_terms_list = []
                for b1, p1 in enumerate(pol_list):
                    for b2, p2 in enumerate(pol_list):
                        if (b2 <= b1):
                            continue
                        off_diag_terms_list.append(p1.upper() + p2.upper())
                _save_list_cov_terms(cov_elements_list + off_diag_terms_list,
                                     freq_group)
                _save_hdf5_dataset(temp_off_diag.name,
                                   hdf5_obj,
                                   root_ds,
                                   yds,
                                   xds,
                                   off_diag_terms_list,
                                   long_name=output_radiometry_str,
                                   units='',
                                   valid_min=clip_min,
                                   valid_max=clip_max)

            t_freq_elapsed = time.time() - t_freq
            info_channel.log(
                f'frequency {frequency} ran in {t_freq_elapsed:.3f} seconds')

            if frequency.upper() == 'B':
                continue

            cube_geogrid = isce3.product.GeoGridParameters(
                start_x=radar_grid_cubes_geogrid.start_x,
                start_y=radar_grid_cubes_geogrid.start_y,
                spacing_x=radar_grid_cubes_geogrid.spacing_x,
                spacing_y=radar_grid_cubes_geogrid.spacing_y,
                width=int(radar_grid_cubes_geogrid.width),
                length=int(radar_grid_cubes_geogrid.length),
                epsg=radar_grid_cubes_geogrid.epsg)

            cube_group_name = '/science/LSAR/GCOV/metadata/radarGrid'
            native_doppler = slc.getDopplerCentroid()
            '''
            The native-Doppler LUT bounds error is turned off to
            computer cubes values outside radar-grid boundaries
            '''
            native_doppler.bounds_error = False
            add_radar_grid_cubes_to_hdf5(hdf5_obj, cube_group_name,
                                         cube_geogrid,
                                         radar_grid_cubes_heights, radar_grid,
                                         orbit, native_doppler, zero_doppler,
                                         threshold, maxiter)

    t_all_elapsed = time.time() - t_all
    info_channel.log(
        f"successfully ran geocode COV in {t_all_elapsed:.3f} seconds")