geomodels.wmmf module

World Magnetic Model Format tools.

Classes and function for reading and writing files in World Magnetic Model Format and in IGRF text format.

See: https://geographiclib.sourceforge.io/html/magnetic.html#magneticformat and https://www.ngdc.noaa.gov/IAGA/vmod/igrf.html.

class geomodels.wmmf.MetaData(Name: str = 'N/A', Description: str = 'International Geomagnetic Reference Field', URL: str = 'http://ngdc.noaa.gov/IAGA/vmod/igrf.html', Publisher: str = 'International Association of Geomagnetism and Aeronomy', ReleaseDate: str = 'N/A', DataCutOff: str = 'N/A', ConversionDate: str = 'N/A', DataVersion: int = 1, Radius: int = 6371200, NumModels: int = 0, Epoch: int = 1900, DeltaEpoch: int = 5, MinTime: int = 0, MaxTime: int = 0, MinHeight: int = -1000, MaxHeight: int = 600000, NumConstants: int = 0, Normalization: int = 1, ID: str = 'N/A', N: int = 0, M: int = 0, FORMAT_VERSION: int = 1)[source]

Bases: object

World Magnetic Model Format metadata.

ByteOrder = 'little'
ConversionDate = 'N/A'
DataCutOff = 'N/A'
DataVersion = 1
DeltaEpoch = 5
Description = 'International Geomagnetic Reference Field'
Epoch = 1900
FORMAT_VERSION = 1
ID = 'N/A'
M = 0
MaxHeight = 600000
MaxTime = 0
MinHeight = -1000
MinTime = 0
N = 0
Name = 'N/A'
Normalization = 1
NumConstants = 0
NumModels = 0
Publisher = 'International Association of Geomagnetism and Aeronomy'
Radius = 6371200
ReleaseDate = 'N/A'
Type = 'linear'
URL = 'http://ngdc.noaa.gov/IAGA/vmod/igrf.html'
get_id() → str[source]

Return the model ID (eventually inferred by the model name).

get_years() → List[int][source]

Return the list of years associated to teh models.

load(filename: Union[str, os.PathLike]) → None[source]

Load a metadata file in WMM format and return a MetaData object.

save(filename: Union[str, os.PathLike]) → None[source]
class geomodels.wmmf.SphCoeffSet(C, S)

Bases: tuple

C

Alias for field number 0

S

Alias for field number 1

class geomodels.wmmf.WmmData(filename: Union[str, os.PathLike, None] = None)[source]

Bases: object

Magnetic field data.

classmethod from_metadata_and_coeffs(medadata: geomodels.wmmf.MetaData, coeffs: OrderedDict[str, geomodels.wmmf.SphCoeffSet]) → geomodels.wmmf.WmmData[source]
load(filename: Union[str, os.PathLike]) → None[source]

Load metadata and spherical harmonics coefficients.

save(outpath: Union[str, os.PathLike], force: bool = False) → None[source]

Save data in WMM format (metadata and binary).

geomodels.wmmf.import_igrf_txt(path: Union[str, os.PathLike]) → geomodels.wmmf.WmmData[source]

Decode a spherical harmonics coefficient file in IGRF text format.

Parameters:path – the path to a local filename or a remote URL.