chaosmagpy.chaos.load_IGRF_txtfile

chaosmagpy.chaos.load_IGRF_txtfile(filepath, name=None)[source]

Load the IGRF internal field model from the TXT-file with the piecewise-polynomial coefficients.

Parameters:
filepathstr

Path to the IGRF TXT-file (not part of ChaosMagPy).

namestr, optional

User defined name of the model. Defaults to the filename without the file extension.

Returns:
modelBaseModel

Class BaseModel instance.

Notes

The field is linearly extrapolated in the 5-year period at the end of the model time interval (i.e. in the period 2020-2025 for IGRF-13) using the predictive secular variation in the IGRF.

References

The latest IGRF coefficients can be downloaded at https://www.ncei.noaa.gov/products/international-geomagnetic-reference-field.

Examples

import chaosmagpy as cp
import matplotlib.pyplot as plt
import numpy as np

model = cp.load_IGRF_txtfile('irgf13coeffs.txt')  # load model TXT-file

fig, ax = plt.subplots(1, 1, figsize=(10, 6))

time = np.linspace(1900., 2020., 1000)  # decimal years
mjd = cp.data_utils.dyear_to_mjd(time, leap_year=True)

coeffs = model.synth_coeffs(mjd, nmax=1)

ax.plot(time, coeffs)
ax.set_title(model.name)
ax.set_xlabel('years')
ax.set_ylabel('nT')

ax.legend(['$g_1^0$', '$g_1^1$', '$h_1^1$'])

plt.tight_layout()
plt.show()