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

Longitude normalization #160

Merged
merged 13 commits into from
Nov 21, 2024
Merged

Longitude normalization #160

merged 13 commits into from
Nov 21, 2024

Conversation

zmoon
Copy link
Member

@zmoon zmoon commented Nov 18, 2024

The longitude wrapping/normalization can introduce small floating point errors into longitude coordinates. For example:

>>> (120.711744 + 180) % 360 - 180
120.71174400000001

In some situations (no renames), _dataset_to_monet was doing this in place. That should now not happen. Additionally, currently I have it set to compute if lon normalization is necessary (min/max) and skip it otherwise, which seems advantageous.

In [35]: a = np.random.rand(int(1e7))

In [36]: %timeit (a.min(), a.max())
10.8 ms ± 60.7 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

In [37]: %timeit (a + 180) % 360 - 180
296 ms ± 3.08 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

cc: @rschwant @bbakernoaa

zmoon added 13 commits November 18, 2024 14:56
For many cases, this is not necessary, since rename creates
a new ds obj, but if no renames have occurred, longitude
in the original `dset` will be modified
before it was just ignored
don't see why not
remap_nearest calls dataset-to-monet on both target and source
internally
Note COARDS and CF seem to both allow longitudes
other than [-180, 180) format
@zmoon zmoon merged commit 92f9959 into noaa-oar-arl:develop Nov 21, 2024
6 checks passed
@zmoon zmoon deleted the lon-norm branch November 21, 2024 20:14
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