Skip to content

Commit

Permalink
add a specific class for altimetry results, allowing to add specific …
Browse files Browse the repository at this point in the history
…method (and information) + formatting
  • Loading branch information
ghislainp committed Aug 13, 2024
1 parent f918c57 commit e2dd999
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
17 changes: 17 additions & 0 deletions smrt/core/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,23 @@ def sigmaVH_dB(self, **kwargs):
# # yield Result(data)


class AltimetryResult(ActiveResult):

def delay_doppler_map(self, **kwargs):
"""Return the delay Doppler map"""
assert "fdoppler" in self.data.dims
return self.sigma(**kwargs)

def waveform(self, **kwargs):
"""Return the waveform"""

if "fdoppler" in self.data.dims:
wf = self.sigma(**kwargs).sum(dim="fdoppler")
else:
wf = self.sigma(**kwargs)
return wf


# DON'T ERASE THIS, this is not needed at this stage but could be.
# This is ResultGroup is inspired from xarray, itself being inspired from pandas
# There is probably a few rough corner, but it works.
Expand Down
1 change: 1 addition & 0 deletions smrt/core/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,4 @@ def __init__(self, frequency, altitude, beamwidth, pulse_bandwidth, sigma_p=None
self.nominal_gate = nominal_gate
self.off_nadir_angle = off_nadir_angle
self.beam_asymmetry = beam_asymmetry
self.antenna_gain = antenna_gain
8 changes: 7 additions & 1 deletion smrt/inputs/altimeter_list.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@


from math import pi
from smrt.core.sensor import make_multi_channel_altimeter, altimeter
from smrt.core.error import SMRTError

Expand Down Expand Up @@ -49,6 +50,7 @@ def sentinel3_sral(channel=None):
nominal_gate=44,
ngate=128,
beamwidth=1.35,
antenna_gain=1,
),
}

Expand All @@ -66,6 +68,7 @@ def saral_altika():
nominal_gate=51,
ngate=128,
beamwidth=0.605,
antenna_gain=1,
)
return altimeter(channel='Ka', **params)

Expand All @@ -85,6 +88,7 @@ def cryosat2_lrm():
nominal_gate=50, # Estimate - needs better definition
ngate=128,
beamwidth=1.2,
antenna_gain=1,
)
return altimeter(channel='Ku', **params)

Expand All @@ -95,7 +99,7 @@ def cryosat2_sin():
Parameters from https://earth.esa.int/web/eoportal/satellite-missions/c-missions/cryosat-2
Altitude from https://doi.org/10.1016/j.asr.2018.04.014
Beam width is 1.08 along track and 1.2 across track. Unfortunately SMRT is not able to take into
account elliptical footprints yet.
account elliptical footprints yet in LRM
"""

Expand All @@ -105,6 +109,7 @@ def cryosat2_sin():
nominal_gate=164, # Estimate - needs better definition
ngate=512,
beamwidth=1.2,
antenna_gain=1,
)
return altimeter(channel='Ku', **params)

Expand All @@ -126,6 +131,7 @@ def asiras_lam(altitude=None):
nominal_gate=41, # Estimate - needs better definition
ngate=256,
beamwidth=2.2,
antenna_gain=1,
)
return altimeter(channel='Ku', **params)

Expand Down
6 changes: 3 additions & 3 deletions smrt/rtsolver/nadir_lrm_altimetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from smrt.core.globalconstants import C_SPEED
from smrt.core.error import SMRTError, smrt_warn
from smrt.core.result import ActiveResult
from smrt.core.result import AltimetryResult
from smrt.rtsolver.waveform_model import Brown1977

import xarray as xr
Expand Down Expand Up @@ -144,9 +144,9 @@ def solve(self, snowpack, emmodels, sensor, atmosphere=None):
total = np.sum(waveform, axis=0) # compute the total

waveform = np.append(waveform, total[None, :], axis=0) # add the total
res = ActiveResult(waveform[:, :, None, None], coords=[('contribution', ['surface', 'interfaces', 'volume', 'total'])] + coords)
res = AltimetryResult(waveform[:, :, None, None], coords=[('contribution', ['surface', 'interfaces', 'volume', 'total'])] + coords)
else:
res = ActiveResult(waveform[:, None, None], coords=coords)
res = AltimetryResult(waveform[:, None, None], coords=coords)

if len(self.z_gate) >= len(t_gate):
# shorten
Expand Down
4 changes: 2 additions & 2 deletions smrt/rtsolver/test_nadir_lrm_altimetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_nonscattering_noabsorption():
m = Model(NonScattering, NadirLRMAltimetry, rtsolver_options=dict(theta_inc_sampling=1))
res = m.run(sensor, sp)

assert np.all(res.sigma() == 0)
assert np.all(res.waveform() == 0)


def test_scattering_noabsorption():
Expand All @@ -39,6 +39,6 @@ def test_scattering_noabsorption():
res = m.run(sensor, sp)
print(np.sum(res.data))

assert np.allclose(np.sum(res.sigma()), 4.25624771e-24)
assert np.allclose(np.sum(res.waveform()), 4.25624771e-24)


6 changes: 2 additions & 4 deletions smrt/rtsolver/waveform_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ def __init__(self, sensor, numerical_convolution=False):

self.sensor = sensor

self.G0 = 1 # antenna_gain0

log2 = 0.6931471805599453
self.gamma = 2 / log2 * np.sin(np.deg2rad(self.sensor.beamwidth) / 2)**2

Expand All @@ -34,7 +32,7 @@ def G(self, theta, phi):

newtheta = np.arccos((np.cos(self.sensor.off_nadir_angle) + rho_h * np.sin(self.sensor.off_nadir_angle)
* np.cos(phi)) / np.sqrt(1 + rho_h**2))
return self.G0 * np.exp(-2 / self.gamma * np.sin(newtheta)**2) # Eq 4
return self.sensor.antenna_gain * np.exp(-2 / self.gamma * np.sin(newtheta)**2) # Eq 4

def PFS(self, tau, surface_slope=0, shift_nominal_gate=True):
# tau = t - 2*h/c
Expand All @@ -49,7 +47,7 @@ def PFS(self, tau, surface_slope=0, shift_nominal_gate=True):
# include Earth curvature as in Newkrik and Brown, 1992
e = C_SPEED / (self.sensor.altitude * (1 + self.sensor.altitude / EARTH_RADIUS)) * otau #

coef = self.G0**2 * self.sensor.wavelength**2 * C_SPEED / (4 * (4 * np.pi)**2 * self.sensor.altitude**3)
coef = self.sensor.antenna_gain**2 * self.sensor.wavelength**2 * C_SPEED / (4 * (4 * np.pi)**2 * self.sensor.altitude**3)

if self.sensor.off_nadir_angle != 0 and surface_slope != 0:
raise NotImplementedError("It is currently not possible to account for both off_nadir and tilted terrain. It would be necessary"
Expand Down

0 comments on commit e2dd999

Please sign in to comment.