Fix SeparateICZarrWriterAdapter mislabeling time calendar as julian#1325
Open
brianhenn wants to merge 1 commit into
Open
Fix SeparateICZarrWriterAdapter mislabeling time calendar as julian#1325brianhenn wants to merge 1 commit into
brianhenn wants to merge 1 commit into
Conversation
The separate-ensemble-members zarr writer encoded the time coordinate values using the source calendar but constructed the ZarrWriter without a time_calendar argument, so the coordinate was always tagged with the default 'julian' calendar. For non-julian data (e.g. noleap) this silently mislabeled every timestamp, causing readers that honor the CF calendar attribute to misinterpret the dates. Pass time_calendar=first_batch_time.dt.calendar so the label matches the already-correct encoded values, and add a regression test parametrized over julian/proleptic_gregorian/noleap.
5241996 to
b505173
Compare
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.
The zarr data writer used with
separate_ensemble_members: true(SeparateICZarrWriterAdapter) encoded thetimecoordinate values using the source calendar but constructed theZarrWriterwithout atime_calendarargument, so the coordinate was always tagged with the default"julian"calendar. For non-julian data (e.g. the noleap CM4 piControl dataset) this silently mislabeled every timestamp, so any reader that honors the CFcalendarattribute misinterprets the dates (a >1-year offset for piControl data starting near year 1). This PR passes the source calendar through to the writer so the label matches the already-correct encoded values.Changes:
fme.ace.inference.data_writer.zarr.SeparateICZarrWriterAdapter._initialize_writers: passtime_calendar=first_batch_time.dt.calendarwhen constructing eachZarrWriter.fme.ace.inference.data_writer.test_zarr.test_separate_ic_writer_preserves_time_calendar: new regression test, parametrized over julian/proleptic_gregorian/noleap, asserting the storedtimecalendar attribute matches the source and decoded times round-trip. Fails on noleap/proleptic_gregorian before the fix.Tests added
If dependencies changed, "deps only" image rebuilt and "latest_deps_only_image.txt" file updated
Resolves #1324