Skip to content

Commit d6846fe

Browse files
committed
fix geoid gravity functional
1 parent 832ef8e commit d6846fe

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

src/shtns_backend/shtns.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ def lonlat_grid(self,nmax=None,lon=None,lat=None,gtype="gauss"):
368368
dslonlat=xr.Dataset(coords=dict(lon=("nlonlat",lon),lat=("nlonlat",lat)))
369369
else:
370370
#we need to check whether the proposed grid is compatible with SHTns
371-
371+
#rough estimate of nmax needed
372+
dres=min(np.median(np.diff(lon)),np.median(np.diff(lat)))
373+
nmax=int(180/dres)
372374
sh = shtns.sht(nmax, nmax, norm=shtns.sht_orthonormal+shtns.SHT_NO_CS_PHASE)
373375
sh.set_grid(len(lat),len(lon),shtns_type)
374376
dslonlat=xr.Dataset(coords=dict(lon=lon,lat=lat))

src/shxarray/earth/ellipsoid.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
# This file is part of the shxarray software which is licensed
3+
# under the Apache License version 2.0 (see the LICENSE file in the main repository)
4+
# Copyright Roelof Rietbroek (r.rietbroek@utwente.nl), 2025
5+
#
6+
7+
import xarray as xr
8+
import shxarray
9+
10+
def get_GRS80_Stokes():
11+
"""
12+
Return the GRS80 ellipsoid as Stokes coefficients
13+
"""
14+
a = 6378137.0
15+
f = 1.0 / 298.257222101
16+
nmax=8
17+
dsgrs80=xr.DataArray.sh.zeros(nmax)
18+
dsgrs80.attrs['title']='GRS80'
19+
dsgrs80.attrs['a_earth']=a
20+
dsgrs80.attrs['f_earth']=f
21+
#fill out derived values
22+
dsgrs80.loc[dict(n=0,m=0)]=1
23+
dsgrs80.loc[dict(n=2,m=0)]=-0.48416685489612e-03
24+
dsgrs80.loc[dict(n=4,m=0)]=0.79030407333333e-06
25+
dsgrs80.loc[dict(n=6,m=0)]=-0.16872510013651e-08
26+
dsgrs80.loc[dict(n=8,m=0)]=-0.34609833692685e-11
27+
28+
return dsgrs80
29+

src/shxarray/kernels/gravfunctionals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Stokes2Geoid(IsoKernelBase):
3333
transform=("stokes","geoid")
3434
def __init__(self,nmax):
3535
super().__init__()
36-
self._dsiso=a_earth*xr.DataArray(np.ones([121]),dims=['n'],coords=dict(n=np.arange(nmax+1)))
36+
self._dsiso=a_earth*xr.DataArray(np.ones([nmax+1]),dims=['n'],coords=dict(n=np.arange(nmax+1)))
3737

3838
class Load2Geoid(IsoKernelBase):
3939
"""Provides an isotropic kernel representing the transformation of a surface load (in m) to geoid height in meter"""

0 commit comments

Comments
 (0)