-
Notifications
You must be signed in to change notification settings - Fork 361
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
Better way to handle NaT (not-a-time) #3414
Comments
So we need to change it to
Pls try that. Alternatively, if you wish "NaT" string to be a valid entry that yields NaN, then a separate branch is needed:
|
First option seem better. It will be visited only in case of failure while second introduces another if branch. |
In the first option, |
Struggling with the C code here, no idea what the fuss of another if branch is about 😆. I say go with the first option? It's okay to have warnings printed out (as long as they're at the info/warning level, not error). I highly doubt that anyone actually stores |
OK. Go with the first option in PR #3415. |
It's about branch prediction. For example loops with |
Thanks for pointing me to that link (never saw such a highly upvoted stackoverflow question in my life!), was very educational. Definitely should go for the vectorizable option here, it sounds a bit like the EAFP style in Python, or Easier to Ask for Forgiveness than Permission, in contrast with LBYL or Look Before You Leap. |
Description of the problem
Both Python numpy and Matlab can have a datetime called NaT, i.e., not-a-time. It's similar to NaN but for time. Not sure if Julia also has something similar.
GMT can't handle NaT. It's OK for command line, but not for external interfaces like PyGMT.
Currently, when a NaT string is passed to GMT, it reports an error and keeps running.
We should at least change the error to warning.
What's worse is:
gmt/src/gmt_api.c
Lines 12769 to 12771 in 3003c50
GMT converts the datetime strings as double values relative to the epoch time internally. In the codes above, if
dt[row]="NaT"
, the functiongmt_scanf()
returnsGMT_IS_NAN
and the variablet_vector[row]
is untouched. The value oft_vector[row]
is 0, which means 1970-01-01T12:00:00. The plot is incorrect if we're plotting a calendar plot around 1970-01-01.Ping @PaulWessel, @joa-quim and @weiji14.
The text was updated successfully, but these errors were encountered: