Skip to content

Commit

Permalink
Add coarsen parameter to geocode_parallel() function
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyPechnikov committed Jul 28, 2023
1 parent 866c935 commit 40a2b29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pygmtsar/pygmtsar/SBAS_geocode.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class SBAS_geocode(SBAS_sbas):

def geocode_parallel(self, pairs=None, chunksize=None):
def geocode_parallel(self, pairs=None, coarsen=4, chunksize=None):
"""
Perform parallel geocoding of the interferograms.
Expand All @@ -31,7 +31,7 @@ def geocode_parallel(self, pairs=None, chunksize=None):
# build trans_dat, trans_ dat_inv and topo_ra grids for merged subswaths
# for single-digit subswath the grids already created for interferogram processing
if len(str(self.get_subswath())) > 1:
self.topo_ra_parallel()
self.topo_ra_parallel(coarsen=coarsen)

# build geographic coordinates transformation matrix for landmask and other grids
self.intf_ll2ra_matrix_parallel(pairs=pairs, chunksize=chunksize)
Expand Down
7 changes: 5 additions & 2 deletions pygmtsar/pygmtsar/SBAS_topo_ra.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def topo_ra_parallel(self, coarsen=4, interactive=False, **kwargs):
# cleanup - sometimes writing NetCDF handlers are not closed immediately and block reading access
import gc; gc.collect()

def get_topo_ra(self):
def get_topo_ra(self, chunksize=None):
"""
Get the radar topography grid.
Expand All @@ -123,6 +123,9 @@ def get_topo_ra(self):
import xarray as xr
import dask.array

if chunksize is None:
chunksize = self.chunksize

def func(topo):
# flip vertically for GMTSAR compatibility reasons
topo = xr.DataArray(dask.array.flipud(topo), coords=topo.coords, attrs=topo.attrs, name=topo.name)
Expand All @@ -131,6 +134,6 @@ def func(topo):
return topo.rename({'a': 'y', 'r': 'x'})
return topo

topos = self.open_grids(None, 'topo_ra', func=func)
topos = self.open_grids(None, 'topo_ra', chunksize=chunksize, func=func)

return topos[0] if len(topos)==1 else topos

0 comments on commit 40a2b29

Please sign in to comment.