From a2d595b8eaf8d54689bd7f7335ffafbabf8dddf6 Mon Sep 17 00:00:00 2001 From: Alexey Pechnikov Date: Mon, 8 Jul 2024 03:05:21 +0700 Subject: [PATCH] Realize geocoding for stack data --- pygmtsar/pygmtsar/Stack_geocode.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pygmtsar/pygmtsar/Stack_geocode.py b/pygmtsar/pygmtsar/Stack_geocode.py index 89a979e1..1950038a 100644 --- a/pygmtsar/pygmtsar/Stack_geocode.py +++ b/pygmtsar/pygmtsar/Stack_geocode.py @@ -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') @@ -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')