Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect calculation of variation values. #11

Open
willjbrown88 opened this issue Apr 26, 2024 · 0 comments
Open

Incorrect calculation of variation values. #11

willjbrown88 opened this issue Apr 26, 2024 · 0 comments

Comments

@willjbrown88
Copy link

willjbrown88 commented Apr 26, 2024

The variation (rate of change) of the IGRF is defined in 5-year increments and should vary as a series of stepwise constants, not be continuous in time.

Lines 37-40 are incorrect at the 5-year time increments when the IGRF coefficient changes.

pyIGRF/pyIGRF/value.py

Lines 37 to 40 in 9b48889

x1, y1, z1, f1 = calculate.igrf12syn(year-1, 1, alt, lat, lon)
x2, y2, z2, f2 = calculate.igrf12syn(year+1, 1, alt, lat, lon)
x, y, z, f = (x1+x2)/2, (y1+y2)/2, (z1+z2)/2, (f1+f2)/2
dx, dy, dz, df = (x2-x1)/2, (y2-y1)/2, (z2-z1)/2, (f2-f1)/2

Something along the lines of this would be more accurate (I've not error checked this, might break when given 2025 as the year for example):

x, y, z, f = calculate.igrf12syn(year, 1, alt, lat, lon)  # need main field at `year`
x1, y1, z1, f1 = calculate.igrf12syn(5*floor(year/5), 1, alt, lat, lon)  # main field at start of 5 year interval
x2, y2, z2, f2 = calculate.igrf12syn((5*floor(year/5))+5, 1, alt, lat, lon) # main field at start of next 5 year interval
dx, dy, dz, df = (x2-x1)/5, (y2-y1)/5, (z2-z1)/5, (f2-f1)/5  # constant variation from e.g. 2010.0<=x<2015.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant