Skip to content

Latest commit

 

History

History
81 lines (69 loc) · 3.77 KB

using-with-python.md

File metadata and controls

81 lines (69 loc) · 3.77 KB
title keywords sidebar permalink summary toc
Using SHTOOLS in Python
spherical harmonics software package, spherical harmonic transform, legendre functions, multitaper spectral analysis, fortran, Python, gravity, magnetic field
mydoc_sidebar
using-with-python.html
To use SHTOOLS in Python, it is only necessary to import the pyshtools module.
true
<style> table:nth-of-type(n) { display:table; width:100%; } table:nth-of-type(n) th:nth-of-type(2) { width:75%; } </style>

The pyshtools module

To use SHTOOLS in Python, it is only necessary to execute this statement in the Python environment

import pyshtools

This will load the following classes and subpackages into the pyshtools namespace:

Class Description
SHCoeffs Class for spherical harmonic coefficients
SHGrid Class for global grids
SHWindow Class for localization windows
Slepian Class for Slepian functions.
SlepianCoeffs Class for Slepian expansion coefficients.
SHGravCoeffs Class for gravitational potential spherical harmonic coefficients.
SHGravGrid Class for global gridded gravitational field data.
SHGravTensor Class for the gravity tensor and eigenvalues.
SHGeoid Class for the geoid.
SHMagCoeffs Class for magnetic potential spherical harmonic coefficients.
SHMagGrid Class for global gridded magnetic field data.
SHMagTensor Class for the magnetic field tensor and eigenvalues.
Subpackage Description
shclasses All pyshtools classes and subclasses
shtools All Python wrapped Fortran 95 routines
legendre Legendre functions
expand Spherical harmonic expansion routines
shio Spherical harmonic I/O, storage, and conversion routines
spectralanalysis Global and localized spectral analysis routines
rotate Spherical harmonic rotation routines
gravmag Gravity and magnetics routines
constant pyshtools constants
utils Utilities

To use the pyshtools matplotlib style parameters for publication quality graphics, input

pyshtools.utils.figstyle()

This function takes optional parameters for specifying the screen resolution, the relative width of the figure, the physical width of the journal page in inches, and the aspect ratio of the figure.

If you are using iPython, which adds improved functionality to Python, the available pyshtools routines can be explored by typing

pyshtools.[tab]

where [tab] is the tab key.

Documentation

To read the documentation of a routine in iPython, such as MakeGridDH, enter

pyshtools.expand.MakeGridDH?

Alternatively, the documentation can be accessed from the Python components menu item on this web site.

The constant subpackage defines physical constants related to the gravity, topography, and magnetic field of the terrestrial planets. Each of these is an instance of an astropy Constant class, which has the attributes name, value, uncertainty, unit, and reference. To see all information about an individual constant, enter

print(pyshtools.constant.r_mars)