geoist.pfm package

Submodules

geoist.pfm.euler module

geoist.pfm.giconstants module

Author : Steve Chen <chenshi@cea-igp.ac.cn> Affiliation : Institute of Geophysics, CEA. Version : 0.1.0 Copyright : Copyright (C) 2018-2020 GEOIST Development Team. All Rights Reserved. License : Distributed under the MIT License. See LICENSE.txt for more info. Github : https://igp-gravity.github.io/ Description :

Holds all physical constants and unit conversions used in geoist. All modules should import the constants from here! All constants should be in SI, unless otherwise stated!

geoist.pfm.giconstants.CM = 1e-07

Proportionality constant used in the magnetic method in henry/m (SI)

geoist.pfm.giconstants.G = 6.673e-11

The gravitational constant in \(m^3 kg^{-1} s^{-1}\)

geoist.pfm.giconstants.MEAN_EARTH_RADIUS = 6378137.0

The mean earth radius in meters

geoist.pfm.giconstants.PERM_FREE_SPACE = 1.2566370614359173e-06

Permeability of free space in \(N A^{-2}\)

geoist.pfm.giconstants.SI2EOTVOS = 1000000000.0

Conversion factor from SI units to Eotvos\(1/s^2 = 10^9\ Eotvos\)

geoist.pfm.giconstants.SI2MGAL = 100000.0

Conversion factor from SI units to mGal\(1\ m/s^2 = 10^5\ mGal\)

geoist.pfm.giconstants.T2NT = 1000000000.0

Conversion factor from tesla to nanotesla

geoist.pfm.giconstants.THERMAL_DIFFUSIVITY = 1e-06

The default thermal diffusivity in \(m^2/s\)

geoist.pfm.giconstants.THERMAL_DIFFUSIVITY_YEAR = 31.5576

The default thermal diffusivity but in \(m^2/year\)

geoist.pfm.giutils module

geoist.pfm.grdio module

Name : grdio.py Created on : 2018/11/24 08:57 Author : Steve Chen <chenshi@cea-igp.ac.cn> Affiliation : Institute of Geophysics, CEA. Version : 0.1.0 Copyright : Copyright (C) 2018-2020 GEOIST Development Team. All Rights Reserved. License : Distributed under the MIT License. See LICENSE.txt for more info. Github : https://igp-gravity.github.io/ Description : Application for processing grid data of potential dataset.

class geoist.pfm.grdio.grddata

Bases: object

Grid Data Object .. attribute:: data

numpy masked array – array to contain raster data
xmin

float – min value X coordinate of raster grid

ymin

float – min value Y coordinate of raster grid

xdim

float – x-dimension of grid cell

ydim

float – y-dimension of grid cell

typeofdata

int – number of datatype

dataname

str – data name or id

rows

int – number of rows for each raster grid/band

cols

int – number of columns for each raster grid/band

nullvalue

float – grid null or nodata value

norm

dictionary – normalized data

gtr

tuple – projection information

wkt

str – projection information

units

str – description of units to be used with color bars

export_ascii(fname)

Export Ascii file

Parameters:data (grid Data) – dataset to export
export_surfer(fname, flag=True)

Export a surfer binary grid

Parameters:
  • fname (filename of grid dataset to export) –
  • flag (True - Output Grid Grid) – False - Output Bak Grid Grid
fill_nulls(method='nearest')

Fill in the NaNs or masked values on interpolated points using nearest neighbors. method=’nearest’ or ‘linear’ or ‘cubic’

grd2xyz(flag=True)

Return x,y,z 1-D array data from 2-D grid array.

Parameters:flag – True - Output Grid Grid False - Output Bak Grid Grid
Returns:x,y,z 1-D array data
load_surfer(fname, dtype='float64')

Read data from a Surfer ASCII grid file.

Parameters:

  • fname : str
    Name of the Surfer grid file
  • dtype : numpy dtype object or string
    The type of variable used for the data. Default is numpy.float64. Use numpy.float32 if the data are large and precision is not an issue.

Returns:

geoist.pfm.grdio.regular(area, shape, z=None)

Create a regular grid.

The x directions is North-South and y East-West. Imagine the grid as a matrix with x varying in the lines and y in columns.

Returned arrays will be flattened to 1D with numpy.ravel.

Parameters:

  • area
    (x1, x2, y1, y2): Borders of the grid
  • shape
    Shape of the regular grid, ie (nx, ny).
  • z
    Optional. z coordinate of the grid points. If given, will return an array with the value z.

Returns:

  • [x, y]
    Numpy arrays with the x and y coordinates of the grid points
  • [x, y, z]
    If z given. Numpy arrays with the x, y, and z coordinates of the grid points

Examples:

>>> x, y = regular((0, 10, 0, 5), (5, 3))
>>> print(x)
[  0.    0.    0.    2.5   2.5   2.5   5.    5.    5.    7.5   7.5   7.5
  10.   10.   10. ]
>>> print(x.reshape((5, 3)))
[[  0.    0.    0. ]
 [  2.5   2.5   2.5]
 [  5.    5.    5. ]
 [  7.5   7.5   7.5]
 [ 10.   10.   10. ]]
geoist.pfm.grdio.spacing(area, shape)

Returns the spacing between grid nodes

Parameters:

  • area
    (x1, x2, y1, y2): Borders of the grid
  • shape
    Shape of the regular grid, ie (nx, ny).

Returns:

  • [dx, dy]
    Spacing the y and x directions

Examples:

>>> print(spacing((0, 10, 0, 20), (11, 11)))
[1.0, 2.0]
>>> print(spacing((0, 10, 0, 20), (11, 21)))
[1.0, 1.0]
>>> print(spacing((0, 10, 0, 20), (5, 21)))
[2.5, 1.0]
>>> print(spacing((0, 10, 0, 20), (21, 21)))
[0.5, 1.0]

geoist.pfm.igrf module

Name : igrf.py Created on : 2018/09/11 17:00 Author : Steve Chen <chenshi@cea-igp.ac.cn> Affiliation : Institute of Geophysics, CEA. Version : 0.1.0 Copyright : Copyright (C) 2018-2020 GEOIST Development Team. All Rights Reserved. License : Distributed under the MIT License. See LICENSE.txt for more info. Github : https://igp-gravity.github.io/ Description : Application for ***.

class geoist.pfm.igrf.IGRF(parent=None)

Bases: object

IGRF field calculation

This produces two datasets. The first is an IGRF dataset for the area of interest, defined by some input magnetic dataset. The second is the IGRF corrected form of that input magnetic dataset.

To do this, the input dataset must be reprojected from its local projection to degrees, where the IGRF correction will take place. This is done within this class.

parent

parent – reference to the parent routine

indata

dictionary – dictionary of input datasets

outdata

dictionary – dictionary of output datasets

Parameters:
  • altmin (Double) – Minimum height of selected model.
  • altmax (Double array) – array of MAXMOD Maximum height of model.
  • maxalt (Double) – Maximum height of selected model.
  • d (float) – Declination of the field from the geographic north (deg).
  • sdate (float) – start date inputted
  • ddot (float) – annual rate of change of decl. (arc-min/yr)
  • alt (float) – altitude above WGS84 Ellipsoid
  • epoch (list) – list of MAXMOD epoch of model.
  • latitude (float) – Latitude.
  • longitude (float) – Longitude.
  • gh (numpy array) – Schmidt quasi-normal internal spherical harmonic coeff. Schmidt quasi-normal internal spherical harmonic coeff. Coefficients of resulting model. Coefficients of rate of change model.
  • i (float) – Inclination (deg).
  • idot (float) – Rate of change of i (arc-min/yr).
  • igdgc (int) – Flag for geodetic or geocentric coordinate choice.
  • irec_pos (int array) – array of MAXMOD Record counter for header
  • fileline (int) – Current line in file (for errors)
  • max1 (list, int) – array of MAXMOD Main field coefficient.
  • max2 (list, int) – array of MAXMOD Secular variation coefficient.
  • max3 (list, int) – array of MAXMOD Acceleration coefficient.
  • minyr (float) – Min year of all models
  • maxyr (float) – Max year of all models
  • yrmax (list, float) – array of MAXMOD Max year of model.
  • yrmin (list, float) – array of MAXMOD Min year of model.
dihf(gh)

Computes the geomagnetic d, i, h, and f from x, y, and z.

FORTRAN : A. Zunde, USGS, MS 964, box 25046 Federal Center, Denver,
CO. 80225
C : C. H. Shaffer, Lockheed Missiles and Space Company, Sunnyvale CA
Parameters:
  • x (float) – northward component
  • y (float) – eastward component
  • z (float) – vertically-downward component
Returns:

  • d (float) – declination
  • i (float) – inclination
  • h (float) – horizontal intensity
  • f (float) – total intensity

extrapsh(date, dte1, nmax1, nmax2, gh)

Extrapolates linearly a spherical harmonic model with a rate-of-change model.

FORTRAN : A. Zunde, USGS, MS 964, box 25046 Federal Center, Denver,
CO. 80225
C : C. H. Shaffer, Lockheed Missiles and Space Company, Sunnyvale CA
Parameters:
  • date (float) – date of resulting model (in decimal year)
  • dte1 (float) – date of base model
  • nmax1 (int) – maximum degree and order of base model
  • gh (numpy array) – Schmidt quasi-normal internal spherical harmonic coefficients of base model and rate-of-change model
  • nmax2 (int) – maximum degree and order of rate-of-change model
Returns:

  • gh (numpy array) – Schmidt quasi-normal internal spherical harmonic coefficients
  • nmax (int) – maximum degree and order of resulting model

getshc(file, iflag, strec, nmax_of_gh, gh)

Reads spherical harmonic coefficients from the specified model into an array.

FORTRAN: Bill Flanagan, NOAA CORPS, DESDIS, NGDC, 325 Broadway,
Boulder CO. 80301
C: C. H. Shaffer, Lockheed Missiles and Space Company, Sunnyvale CA
Parameters:
  • file (file) – reference to a file object
  • iflag – Flag for SV equal to 1 or not equal to 1 for designated read statements
  • strec (int) – Starting record number to read from model
  • nmax_of_gh (int) – Maximum degree and order of model
Returns:

gh – Schmidt quasi-normal internal spherical harmonic coefficients

Return type:

list

interpsh(date, dte1, nmax1, dte2, nmax2, gh)

Interpolates linearly, in time, between two spherical harmonic models.

FORTRAN : A. Zunde, USGS, MS 964, box 25046 Federal Center, Denver,
CO. 80225
C : C. H. Shaffer, Lockheed Missiles and Space Company, Sunnyvale CA
Parameters:
  • date (float) – date of resulting model (in decimal year)
  • dte1 (float) – date of earlier model
  • nmax1 (int) – maximum degree and order of earlier model
  • gh (numpy array) – Schmidt quasi-normal internal spherical harmonic coefficients of earlier model and internal model
  • dte2 (float) – date of later model
  • nmax2 (int) – maximum degree and order of later model
Returns:

  • gh (numpy array) – coefficients of resulting model
  • nmax (int) – maximum degree and order of resulting model

pnt(latitude, longitude, alt)

Settings Dialog. This is the main entrypoint into this routine. It also contains the main IGRF code.

shval3(igdgc, flat, flon, elev, nmax, gh)

Calculates field components from spherical harmonic (sh) models.

Based on subroutine ‘igrf’ by D. R. Barraclough and S. R. C. Malin, report no. 71/1, institute of geological sciences, U.K.

FORTRAN : Norman W. Peddie, USGS, MS 964, box 25046 Federal Center,
Denver, CO. 80225
C : C. H. Shaffer, Lockheed Missiles and Space Company, Sunnyvale CA
Parameters:
  • igdgc (int) – indicates coordinate system used set equal to 1 if geodetic, 2 if geocentric
  • latitude (float) – north latitude, in degrees
  • longitude (float) – east longitude, in degrees
  • elev (float) – WGS84 altitude above ellipsoid (igdgc=1), or radial distance from earth’s center (igdgc=2)
  • a2,b2 (float) – squares of semi-major and semi-minor axes of the reference spheroid used for transforming between geodetic and geocentric coordinates or components
  • nmax (int) – maximum degree and order of coefficients
Returns:

  • x (float) – northward component
  • y (float) – eastward component
  • z (float) – vertically-downward component

geoist.pfm.normgra module

geoist.pfm.pftrans module

geoist.pfm.tide module

Name : tide.py Created on : 2018/11/03 17:00 Author : Steve Chen <chenshi@cea-igp.ac.cn> Affiliation : Institute of Geophysics, CEA. Version : 0.1.0 Copyright : Copyright (C) 2018-2020 GEOIST Development Team. All Rights Reserved. License : Distributed under the MIT License. See LICENSE.txt for more info. Github : https://igp-gravity.github.io/ Description : Application for ***.

class geoist.pfm.tide.TideModel

Bases: object

Class to encapsulate the Longman 1959 tide model.

calculate_julian_century(timestamp)

Calculate the julian century and hour.

Take a datetime object and calculate the decimal Julian century and floating point hour. This is in reference to noon on December 31, 1899 as stated in the Longman paper.

Parameters:timestamp (datetime) – Time stamp to convert
Returns:Julian century and hour
Return type:float, float
plot()

Plot the model results.

Make a simple plot of the gravitational tide results from the model run.

run_model()

Run the model for a range of times.

Runs the tidal model beginning at start_time with time steps of increment seconds for days.

solve_longman(lat, lon, alt, time)

Solve the tide model.

Given the location and datetime object, computes the current gravitational tide and associated quantities. Latitude and longitude and in the traditional decimal notation, altitude is in meters, time is a datetime object.

Parameters:
  • lat (float) – latitude (in degrees)
  • lon (float) – longitude (in degrees)
  • alt (float) – altitude (in meters)
  • time (datetime) – time at which to solve the model
Returns:

lunar, solar, and total gravitational tides

Return type:

float, float, float

write(fname)

Write model results to file.

Write results out of a file for later analysis or reading into another method for analysis/correction of data.

Parameters:fname (string) – name of file to save

Module contents