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

Not ideal behavior when updating Grib2Message datetime attributes. #158

Closed
EricEngle-NOAA opened this issue Sep 23, 2024 · 0 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@EricEngle-NOAA
Copy link
Collaborator

Currently, grib2io allows you to update the Grib2Message attributes refDate, leadTime, and duration. They are presented to the user as datetime.datetime and datetime.timedelta objects respectively. The attr validDate exists as a read-only attribute, but in certain PDTNs, there are elements in Section4 PDT to hold the "valid date" components (year, month, day, hour, minute, and second).

In those certain PDTs (i.e. time interval variables), the leadTime attr represents the beginning of the time period. The leadTime can be summed with the time interval of "Statistical Process" (duration attr) to find the end of the time interval.

The following table is the desired behavior when modifying datetime attributes.

Attrs refDate leadTime duration validDate
refDate YES NO NO YES
leadTime NO YES NO YES
duration NO NO YES YES
validDate NO NO NO NO

The table reads as...modifying refDate, leadTime, and duration attrs will obviously modify that attribute, but it will also modify the validDate since they are interconnected. However, the validDate cannot be modified directly and is considered read-only. Setting this attr will raise a warning.

NOTE: Even though continuous variables do not have a duration, the Grib2Message object will have a duration attributes with value of 0.

IMPORTANT: Currently (as of v2.3.0), modifying the leadTime attribute takes the duration value into consideration. This behavior will change with changes in the linked pull request.

Moving forward... It will be the responsibility of the user to make sure the refDate, leadTime, and duration attributes are correct for the given GRIB2 message. For time interval PDTs, where the valid date components are a part of the PDT, those components are gotten from the computed validDate attribute.

@EricEngle-NOAA EricEngle-NOAA added the bug Something isn't working label Sep 23, 2024
@EricEngle-NOAA EricEngle-NOAA self-assigned this Sep 23, 2024
EricEngle-NOAA added a commit to EricEngle-NOAA/grib2io that referenced this issue Sep 23, 2024
This commit cleans up code for setting refDate, leadTime, and
duration Grib2Message attributes.

The xarray backend now ignore those attrs when calling the
grib2io.update_attrs() accessor method for DataArrays.

This commit references NOAA-MDL#158
EricEngle-NOAA added a commit that referenced this issue Sep 24, 2024
This commit cleans up code for setting refDate, leadTime, and
duration Grib2Message attributes.

The xarray backend now ignore those attrs when calling the
grib2io.update_attrs() accessor method for DataArrays.

This commit references #158

Co-authored-by: Eric Engle <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant