|
| 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() |
0 commit comments