Skip to content

Commit 6cbbbca

Browse files
committed
Rebuild normal_zonal_correction for inside convertion of coefficients depending on output reference surface
Correction of sign + partial for dlatitude derivation Add deflection of vertical Add all gravity function to lnharmo
1 parent 3442910 commit 6cbbbca

2 files changed

Lines changed: 315 additions & 42 deletions

File tree

lenapy/lenapy_harmo.py

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
change_reference,
3434
change_tide_system,
3535
normal_zonal_correction,
36+
sh_to_deflection_of_vertical,
37+
sh_to_gravity_disturbance,
38+
sh_to_potential_partial_derivative_longitude,
3639
)
3740
from lenapy.utils.harmo import *
3841
from lenapy.writers.gravi_writer import dataset_to_gfc
@@ -135,12 +138,12 @@ def _apply_operator(self, op, other):
135138
self.ds = self._obj.sel(l=common_l, m=common_m)
136139

137140
# case where other does not have a time dimension
138-
if "time" not in other.coords:
141+
if "time" not in other.dims:
139142
self.ds["clm"] = op(self.ds.clm, other.clm.sel(l=common_l, m=common_m))
140143
self.ds["slm"] = op(self.ds.slm, other.slm.sel(l=common_l, m=common_m))
141144

142145
elif (
143-
"time" not in self._obj.coords
146+
"time" not in self._obj.dims
144147
): # if the previous test, other has time dimension
145148
raise AssertionError(
146149
"Cannot operate on a HarmoSet with time dimension to a Harmoset without it. "
@@ -234,6 +237,59 @@ def to_grid(self, **kwargs) -> xr.DataArray:
234237
"""
235238
return sh_to_grid(self._obj, **kwargs)
236239

240+
def to_gravity_disturbance(self, **kwargs) -> xr.DataArray:
241+
"""
242+
Transform Spherical Harmonics (SH) dataset into gravity disturbance spatial DataArray.
243+
For details on the function, see :func:`lenapy.utils.gravity.sh_to_gravity_disturbance` documentation.
244+
245+
Parameters
246+
----------
247+
**kwargs :
248+
Supplementary parameters used by the function sh_to_gravity_disturbance() for conversion
249+
250+
Returns
251+
-------
252+
xr.DataArray
253+
The spatial grid gravity disturbance representation of the spherical harmonics dataset.
254+
"""
255+
return sh_to_gravity_disturbance(self._obj, **kwargs)
256+
257+
def to_potential_partial_derivative_longitude(self, **kwargs) -> xr.DataArray:
258+
"""
259+
Transform Spherical Harmonics (SH) dataset into the partial derivative of the potential regarding the longitude
260+
spatial DataArray.
261+
For details on the function, see :func:`lenapy.utils.gravity.sh_to_potential_partial_derivative_longitude`
262+
documentation.
263+
264+
Parameters
265+
----------
266+
**kwargs :
267+
Supplementary parameters used by the function sh_to_potential_partial_derivative_longitude() for conversion
268+
269+
Returns
270+
-------
271+
xr.DataArray
272+
The spatial grid partial derivative representation of the spherical harmonics dataset.
273+
"""
274+
return sh_to_potential_partial_derivative_longitude(self._obj, **kwargs)
275+
276+
def to_deflection_of_vertical(self, **kwargs) -> xr.Dataset:
277+
"""
278+
Transform Spherical Harmonics (SH) dataset into deflection of the vertical spatial DataArray.
279+
For details on the function, see :func:`lenapy.utils.gravity.sh_to_deflection_of_vertical` documentation.
280+
281+
Parameters
282+
----------
283+
**kwargs :
284+
Supplementary parameters used by the function sh_to_deflection_of_vertical() for conversion
285+
286+
Returns
287+
-------
288+
xr.Dataset
289+
The spatial grids deflection of vertical representation of the spherical harmonics dataset.
290+
"""
291+
return sh_to_deflection_of_vertical(self._obj, **kwargs)
292+
237293
def change_reference(
238294
self,
239295
new_radius: float,

0 commit comments

Comments
 (0)