Repository navigation
Igrf14 - #1199
Merged
Merged
Igrf14#1199
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI PR message:
Summary
This replaces the hand-copied IGRF-13 tables with IGRF-14 coefficients generated at build time from arts-cat-data. Along the way it fixes several bugs in IGRF, in the magnetic-field Jacobian, and in
Time.Requires
mag-field/igrf.txton arts-cat-datamainbefore merging. CI downloads it.IGRF
make_igrf_data, reads the official IAGA filemag-field/igrf.txtfrom arts-cat-data. Moving to a new IGRF generation means replacing that file. The model is now IGRF-14, valid 1900–2030.IGRF::Data::valid_range, and in Python aspyarts3.arts.igrf_valid_range. The docs repeat no dates or generation, so they stay correct after a data update.IGRF13becomesIGRF, including the XML type name, andigrf13.*becomesigrf.*.pyarts3.arts.igrfis now the time of the call, not the time of import.Alken2021andBeggan2026.Legendre coefficients and magnetic-field retrievals
layout_triangular,TriangularMatrix, and a fixed-sizetriangular_cdata_t. It replacesLegendre::SchmidtMatrix; the Python equivalent ismath.TriangularMatrix.SchmidthLegendre::w(). The Jacobian used the geodetic altitude as the geocentric radius, so every derivative was wrong, often by orders of magnitude. For example, ∂B_r/∂g₁⁰ came out as about 4×10⁵ at 90 km and −∞ at the surface, instead of about 1.SchmidthLegendre::ghis now a vector in IGRF's order. The XML layout changes accordingly.schmidt_fieldcalcnever reads them.Time
Timeis. A point in time plus a fixed offset from UTC, by default UTC itself. Parsing and printing use C++20<chrono>dates instead ofstd::tm,mktimeandlocaltime. As a result:2000-01-01T12:00:00Z,…+09:00) and the existing space-separated form. Printing always includes the offset.Timehas<=>. Python==and<now compare times; before,==compared object identity.datetime: aware datetimes keep their offset, and naive ones are UTC..timereturns an aware datetime, and there is a newutc_offsetproperty. Adatetimeis no longer implicitly converted when passed where aTimeis expected; useTime(dt). The Python binding uses only nanobind's public API.Time(float)and the.secsetter are exact. Before, they could be off by about 1 µs, depending on when they were called.Time ± float.Time ± duration,time_steps,next_even,mean_time(which ignored its end index),median,meanandTimeStepType.PartOfSecond,seconds_into_day,operator Numeric,toStruct,toGMTStructandtoTimeT.Time(std::tm)andTime(std::time_t)constructors, andtest_time.cc.Changed results
7-zeeman-refractivenow uses a fixed date. Its default time ("now") would drift with the secular variation and eventually break the example.Tests
tests/core/igrf/reference-values.py: 60 cases from one independent run of the officialigrf14.f(not included in ARTS), with a tolerance of 0.1 nT. The measured agreement is 0.015 nT, limited by the Fortran program's single-precision constants; with those corrected it is 6×10⁻¹⁰ nT.cpp.fast.core.test_schmidt_legendre_jacobian: every derivative against central finite differences.tests/python/time-formats.py: accepted and rejected time strings, and round trips.🤖 Generated with Claude Code