Skip to content

Commit 686c0f2

Browse files
authored
feat: add harmonic resolution calculator (#44)
increase version number
1 parent 86a6b4e commit 686c0f2

File tree

4 files changed

+127
-1
lines changed

4 files changed

+127
-1
lines changed

doc/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ missions
9999
user_guide/aod1b_geocenter.md
100100
user_guide/aod1b_oblateness.md
101101
user_guide/calc_mascon.rst
102+
user_guide/calc_harmonic_resolution.rst
102103
user_guide/calc_sensitivity_kernel.rst
103104
user_guide/combine_harmonics.rst
104105
user_guide/convert_harmonics.rst
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
===========================
2+
calc_harmonic_resolution.py
3+
===========================
4+
5+
- Calculates the spatial resolution that can be resolved by the spherical harmonics of a certain degree [Barthelmes2013]_ [HofmannWellenhof2006]_
6+
- Default method uses the smallest half-wavelength that can be resolved
7+
- Secondary method calculates the smallest possible bump that can be resolved
8+
9+
Calling Sequence
10+
################
11+
12+
.. code-block:: bash
13+
14+
python calc_harmonic_resolution --lmax 60 --cap
15+
16+
`Source code`__
17+
18+
.. __: https://github.com/tsutterley/read-GRACE-harmonics/blob/main/scripts/calc_harmonic_resolution.py
19+
20+
Command Line Options
21+
####################
22+
23+
- ``--help``: list the command line options
24+
- ``-l X``, ``--lmax X``: maximum spherical harmonic degree
25+
- ``-R X``, ``--radius X``: Average radius of the Earth (km)
26+
- ``-C``, ``--cap``: Calculate the smallest possible bump that can be resolved
27+
28+
References
29+
##########
30+
31+
.. [Barthelmes2013] F. Barthelmes, "Definition of Functionals of the Geopotential and Their Calculation from Spherical Harmonic Models", GeoForschungsZentrum Scientific Technical Report, STR09/02, (2013). `doi: 10.2312/GFZ.b103-0902-26 <https://doi.org/10.2312/GFZ.b103-0902-26>`_
32+
33+
.. [HofmannWellenhof2006] B. Hofmann-Wellenhof and H. Moritz, *Physical Geodesy*, 2nd Edition, 403 pp., (2006). `doi: 10.1007/978-3-211-33545-1 <https://doi.org/10.1007/978-3-211-33545-1>`_

scripts/calc_harmonic_resolution.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env python
2+
u"""
3+
calc_harmonic_resolution.py
4+
Written by Tyler Sutterley (09/2020)
5+
6+
Calculates the spatial resolution that can be resolved
7+
by the spherical harmonics of a certain degree
8+
Default method uses the smallest half-wavelength that can be resolved
9+
(is equal to approximately 20000/lmax km)
10+
Secondary method calculates the smallest possible bump that can be resolved
11+
by dividing the area of a sphere by (lmax+1)^2
12+
13+
CALLING SEQUENCE:
14+
python calc_harmonic_resolution.py --lmax 60 --cap
15+
16+
COMMAND LINE OPTIONS:
17+
-l X, --lmax X: maximum degree of spherical harmonics
18+
-R X, --radius X: average radius of the Earth in kilometers
19+
-C, --cap: calculate the smallest possible bump that can be resolved
20+
21+
PYTHON DEPENDENCIES:
22+
numpy: Scientific Computing Tools For Python (https://numpy.org)
23+
24+
REFERENCES:
25+
Hofmann-Wellenhof and Moritz, "Physical Geodesy" (2005)
26+
http://www.springerlink.com/content/978-3-211-33544-4
27+
Barthelmes, "Definition of Functionals of the Geopotential and Their
28+
Calculation from Spherical Harmonic Models", STR09/02 (2009)
29+
http://icgem.gfz-potsdam.de/str-0902-revised.pdf
30+
31+
UPDATE HISTORY:
32+
Updated 09/2020: using argparse to set parameters
33+
Updated 10/2019: changing Y/N flags to True/False
34+
Updated 02/2014: minor update to if statement
35+
Updated 08/2013: changed SPH_CAP option to (Y/N)
36+
Written 01/2013
37+
"""
38+
import sys
39+
import argparse
40+
import numpy as np
41+
42+
#-- PURPOSE: Calculates minimum spatial resolution that can be resolved
43+
#-- from spherical harmonics of a maximum degree
44+
def calc_harmonic_resolution(LMAX, RADIUS=6371.0008, SPH_CAP=False):
45+
"""
46+
Calculates minimum spatial resolution that can be resolved from
47+
spherical harmonics of a maximum degree
48+
49+
Arguments
50+
---------
51+
LMAX: maximum spherical harmonic degree
52+
53+
Keyword arguments
54+
-----------------
55+
RADIUS: average radius of the Earth in kilometers
56+
SPH_CAP: calculate the smallest possible bump that can be resolved
57+
"""
58+
if SPH_CAP:
59+
# Smallest diameter of a spherical cap that can be resolved by the
60+
# harmonics. Size of the smallest bump, half-wavelength, which can
61+
# be produced by the clm/slm
62+
psi_min = 4.0*RADIUS*np.arcsin(1.0/(LMAX+1.0))
63+
else:
64+
# Shortest half-wavelength that can be resolved by the clm/slm
65+
# This estimation is based on the number of possible zeros along
66+
# the equator
67+
psi_min = np.pi*RADIUS/LMAX
68+
return psi_min
69+
70+
# Main program that calls calc_harmonic_resolution()
71+
def main():
72+
# Read the system arguments listed after the program
73+
parser = argparse.ArgumentParser()
74+
parser.add_argument('--lmax','-l', metavar='LMAX',
75+
type=int, nargs='+',
76+
help='maximum degree of spherical harmonics')
77+
parser.add_argument('--radius','-R',
78+
type=float, default=6371.0008,
79+
help='Average radius of the Earth in kilometers')
80+
parser.add_argument('--cap','-C',
81+
default=False, action='store_true',
82+
help='Calculate smallest possible bump that can be resolved')
83+
args,_ = parser.parse_known_args()
84+
# for each entered spherical harmonic degree
85+
for LMAX in args.lmax:
86+
psi_min = calc_harmonic_resolution(LMAX,
87+
RADIUS=args.radius, SPH_CAP=args.cap)
88+
print('{0:5d}: {1:0.4f} km'.format(LMAX,psi_min))
89+
90+
# run main program
91+
if __name__ == '__main__':
92+
main()

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.1.23
1+
1.0.2.0

0 commit comments

Comments
 (0)