Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pyIGRF
## What is pyIGRF?
This is a package of IGRF-13 (International Geomagnetic Reference Field) about python version.
This is a package of IGRF-14 (International Geomagnetic Reference Field) about python version.
We can calculate magnetic field intensity and transform coordinate between GeoGraphical and GeoMagnetic.
It don't need any Fortran compiler. But it needs NumPy package.

Expand Down Expand Up @@ -28,7 +28,7 @@ the response is 7 float number about magnetic filed which is:
- F: total intensity
*unit: degree or nT*

If you want to use IGRF-13 more flexibly, you can use module *calculate*.
If you want to use IGRF-14 more flexibly, you can use module *calculate*.
There is two function which is closer to Fortran. You can change it for different coordination.
>```from pyIGRF import calculate```

Expand All @@ -37,5 +37,5 @@ Another module *load_coeffs* can be used to get *g[m][n]* or *h[m][n]* same as t



## Model Introduction and igrf13-coeffs File Download
https://www.ngdc.noaa.gov/IAGA/vmod/igrf.html
## Model Introduction and igrf14-coeffs File Download
https://www.ncei.noaa.gov/products/international-geomagnetic-reference-field
8 changes: 4 additions & 4 deletions pyIGRF.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Metadata-Version: 1.0
Name: pyIGRF
Version: 0.3.3
Summary: IGRF-13 Model by Python
Summary: IGRF-14 Model by Python
Home-page: https://github.com/zzyztyy/pyIGRF
Author: zzyztyy
Author-email: 2375672032@qq.com
License: MIT
Description: # pyIGRF
## What is pyIGRF?
This is a package of IGRF-13 (International Geomagnetic Reference Field) about python version.
This is a package of IGRF-14 (International Geomagnetic Reference Field) about python version.
We can calculate magnetic field intensity and transform coordinate between GeoGraphical and GeoMagnetic.
It don't need any Fortran compiler. But it needs NumPy package.

Expand Down Expand Up @@ -36,7 +36,7 @@ Description: # pyIGRF
- F: total intensity
*unit: degree or nT*

If you want to use IGRF-13 more flexibly, you can use module *calculate*.
If you want to use IGRF-14 more flexibly, you can use module *calculate*.
There is two function which is closer to Fortran. You can change it for different coordination.
>```from pyIGRF import calculate```

Expand All @@ -45,7 +45,7 @@ Description: # pyIGRF



## Model Introduction and igrf13-coeffs File Download
## Model Introduction and igrf14-coeffs File Download
https://www.ngdc.noaa.gov/IAGA/vmod/igrf.html

Platform: UNKNOWN
2 changes: 1 addition & 1 deletion pyIGRF.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ pyIGRF.egg-info/SOURCES.txt
pyIGRF.egg-info/dependency_links.txt
pyIGRF.egg-info/requires.txt
pyIGRF.egg-info/top_level.txt
pyIGRF/src/igrf13coeffs.txt
pyIGRF/src/igrf14coeffs.txt
8 changes: 4 additions & 4 deletions pyIGRF/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def igrf12syn(date, itype, alt, lat, elong):
definitive, otherwise they are non-definitive.
INPUT
date = year A.D. Must be greater than or equal to 1900.0 and
less than or equal to 2025.0. Warning message is given
for dates greater than 2020.0. Must be double precision.
less than or equal to 2030.0. Warning message is given
for dates greater than 2025.0. Must be double precision.
itype = 1 if geodetic (spheroid)
itype = 2 if geocentric (sphere)
alt = height in km above sea level if itype = 1
Expand Down Expand Up @@ -78,10 +78,10 @@ def igrf12syn(date, itype, alt, lat, elong):
p, q, cl, sl = [0.] * 105, [0.] * 105, [0.] * 13, [0.] * 13
x, y, z = 0., 0., 0.

if date < 1900.0 or date > 2025.0:
if date < 1900.0 or date > 2030.0:
f = 1.0
print('This subroutine will not work with a date of ' + str(date))
print('Date must be in the range 1900.0 <= date <= 2025.0')
print('Date must be in the range 1900.0 <= date <= 2030.0')
print('On return f = 1.0, x = y = z = 0')
return x, y, z, f

Expand Down
19 changes: 12 additions & 7 deletions pyIGRF/loadCoeffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def load_coeffs(filename):
return gh


gh = load_coeffs(os.path.dirname(os.path.abspath(__file__)) + '/src/igrf13coeffs.txt')
gh = load_coeffs(os.path.dirname(os.path.abspath(__file__)) + '/src/igrf14coeffs.txt')


def get_coeffs(date):
Expand All @@ -47,19 +47,24 @@ def get_coeffs(date):
print('Date must be in the range 1900.0 <= date <= 2030.0')
print('On return [], []')
return [], []
elif date >= 2020.0:
if date > 2025.0:
elif date >= 2025.0:
if date > 2030.0:
# not adapt for the model but can calculate
print('This version of the IGRF is intended for use up to 2025.0.')
print('This version of the IGRF is intended for use up to 2030.0.')
print('values for ' + str(date) + ' will be computed but may be of reduced accuracy')
t = date - 2020.0
t = date - 2025.0
tc = 1.0
# pointer for last coefficient in pen-ultimate set of MF coefficients...
ll = 3060+195
nmx = 13
nc = nmx * (nmx + 2)
ll = int(0.2 * (2025 - 1995.0))
# 19 is the number of SH models that extend to degree 10
ll = 120 * 19 + nc * ll
# ll = 3255+195 #
# nmx = 13
# nc = nmx * (nmx + 2)
else:
t = 0.2 * (date - 1900.0)
t = (date - 1900.0)/5
ll = int(t)
t = t - ll
# SH models before 1995.0 are only to degree 10
Expand Down
Loading