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

Add some test functions to ppigrf #8

Merged
merged 7 commits into from
Apr 19, 2023
Merged

Conversation

santisoler
Copy link
Contributor

@santisoler santisoler commented Oct 5, 2022

Add tests against precomputed IGRF values. There are small differences between the results that ppigrf generates and the ones that the NCEI Calculator produces on dates that require some interpolation along the dates. The difference is not significant.

Add tests against precomputed IGRF values.
@santisoler
Copy link
Contributor Author

@klaundal I've wrote some tests that compare ppigrf results against a precomputed grid I got from the NCEI Calculator. I'm seeing some discrepancies between them. Do you have any idea why it might be happening? It's due to floating point precision? Maybe a different set of coefficients? Would love to hear your opinion on this.

@klaundal
Copy link
Collaborator

@santisoler I did a quick comparison for one point with the NOAA calculator now. The deviations are very small, but too large to be floating point precision I think. I doubt that the coefficient files are different. One possibility is that it is an issue with how the time interpolation between model coefficients is implemented. And/or the conversion between geodetic and geocentric coordinates and components (I get a very good match in the eastward component, which is not affected by this).

Still, the deviations are tiny, typically less than 1 nT. This rarely has any practical consequence, but it would be good to know why it happens. Comparison with an open code would be preferable though.

@santisoler
Copy link
Contributor Author

I suspect you're right and this is coming from the interpolations on the dates. I also checked ppigrf against outputs of igrf (which I suspect the NCEI calculator is running on the background) and I get the same differences. I couldn't generate a grid with igrf because their code was failing due to some Xarray error (probably they were using a different version of Xarray). But I checked with some individual points and the differences are still there.

I've just run a quick check comparing on 2020-01-01 (so no interpolation should be carried out) and the tests pass. So apparently the difference is coming from the date interpolation. I will push new tests with no interpolation on date.

@santisoler santisoler changed the title Start adding some test functions to ppigrf Add some test functions to ppigrf Nov 25, 2022
@santisoler santisoler marked this pull request as ready for review November 25, 2022 21:15
Increase the atol so we let the test pass, accounting for the fact that
the differences are coming from the interpolations along the dates.
@santisoler
Copy link
Contributor Author

Hi @klaundal! After a few weeks (time flies!) I managed to fix the tests so they pass. I've increased the atol in the second case (in which we have to interpolate along the dates). I think this is sufficient for now and it should be ready to be merged. Let me know what you think!

@klaundal klaundal merged commit 898b76d into IAGA-VMOD:main Apr 19, 2023
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

Successfully merging this pull request may close these issues.

2 participants