Skip to content

Commit

Permalink
Realize geocoding for stack data
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyPechnikov committed Jul 7, 2024
1 parent 2d5d2e3 commit a2d595b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pygmtsar/pygmtsar/Stack_geocode.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ def ra2ll(self, data, autoscale=True):
import xarray as xr
import numpy as np

if 'stack' in data.dims and 'y' in data.coords and 'x' in data.coords:
trans_inv = self.get_trans_inv().interp(y=data.y, x=data.x, method='nearest')
return data.assign_coords(
lat=('stack', trans_inv['lt'].data),
lon=('stack', trans_inv['ll'].data)
)

# helper check
if not 'y' in data.dims or not 'x' in data.dims:
print ('NOTE: the input data not in radar coordinates, miss geocoding')
Expand Down Expand Up @@ -340,6 +347,13 @@ def ll2ra(self, data, autoscale=True):
import xarray as xr
import numpy as np

if 'stack' in data.dims and 'lat' in data.coords and 'lon' in data.coords:
trans = self.get_trans().interp(lat=data.lat, lon=data.lon, method='nearest')
return data.assign_coords(
y=('stack', trans['azi'].data),
x=('stack', trans['rng'].data)
)

# helper check
if not 'lat' in data.dims or not 'lon' in data.dims:
print ('NOTE: the input data not in geograophic coordinates, miss inverse geocoding')
Expand Down

0 comments on commit a2d595b

Please sign in to comment.