Skip to content

Incorrect calculation of variation values. #11

@willjbrown88

Description

@willjbrown88

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions