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

sunmoonpos: import some of the SOFA C library #583

Open
wants to merge 2 commits into
base: demo5
Choose a base branch
from

Conversation

ourairquality
Copy link

for a better estimate of the sun and moon positions.

The original C code is add in lib/sofa/src/ and the bundle of functions used are added together in src/sofa.c

Noticed that the sun and moon position did not agree well with that from SOFA, and these are inputs into some of the tide displacement calculations and it can make a significant difference to the tide displacements.

This PR is a possible alternative using the SOFA C library. Just a few files from this library, bundled into a single file src/sofa.c to keep the build simple. Alternatively the SOFA library could be built and linked separately, but having tried both approaches it seems simpler to just bundle the few functions into a single file. The original code is placed in lib/sofa/src/ for reference.

Also noted that these return the ECI position and this still needs to be convert to ECEF using eci2ecef() and this also appears to be a little off, but the differences for eci2ecef() appear to have a negligible impact on the tide displacements.

Does anyone care enough about the sun and moon position to bother with this?

Is using SOFA a useful approach?

Any strong opinions on bundling the few functions into one file vs building a separate library?

@ourairquality ourairquality mentioned this pull request Mar 2, 2025
for a better estimate of the sun and moon positions.

The original C code is add in lib/sofa/src/ and the bundle
of functions used are added together in src/sofa.c
Function arguments that are not modified are declared as const.

Static local variables and data that were effectively constants are
declared as const to make it clear that there is no thread safety
issue.
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.

1 participant