-
Notifications
You must be signed in to change notification settings - Fork 45
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
Incorrect conversion of fillval to datetime #230
Comments
Just looking at the Epoch variable, the attributes are: >>> print(cdf.varattsget("Epoch"))
{
'CATDESC': 'Interval centered time tag (TBC)',
'FIELDNAM': 'Time since Jan 1, 1958',
'FILLVAL': -9223372036854775808,
'LABLAXIS': 'mms2_fgm_srvy_Epoch',
'UNITS': 'ns',
'VALIDMIN': 315576066184000000,
'VALIDMAX': 946728068183000000,
'VAR_TYPE': 'support_data',
'SCALETYP': 'linear',
'MONOTON': 'INCREASE',
'TIME_BASE': 'J2000',
'TIME_SCALE': 'Terrestrial Time',
'REFERENCE_POSITION': 'Rotating Earth Geoid',
'SI_CONVERSION': '1.0e-9>s',
'DELTA_PLUS_VAR': 'mms2_fgm_bdeltahalf_srvy_l2',
'DELTA_MINUS_VAR': 'mms2_fgm_bdeltahalf_srvy_l2'
} It looks like |
Hm then the issue must be the parsing of the cdf file instead of datetime conversion. Using cdfbrowse (CDF v3.8.1) to investigate
So what might lead to this inconsistency? |
I had a read of some CDF documents, and I think it's just convention (not a requirement) that FILLVAL time values are represented as |
Yes I went looking in the C code (cdftt2000.c), and it literally just says cdflib is actually trying to convert that number into nanoseconds before the year 2000, which is on 1707-09-22 (which they also comment in the code is the real minimum value). So thankfully its not a broader issue about time conversions. Perhaps that if statement should live somewhere in our code as well. |
That's a satisfactory enough answer to me. Thanks for looking into this! I'd prefer not to force an arbitrary value, but to do the actual conversion as cdflib is doing right now, so no change is necessary. But some people might prefer to use the CDF binaries like I do to browse the files pre-processing because it's faster. So maybe some documentation on this issue will suffice? |
I just discovered the same issue with pycdfpp, I asked to NASA CDF support ML. The answer I got was that TT2000 has 3 predefined special values:
Since it's not much documented, I leave it here. The main issue is that we can't represent all these values with python 😅, with numpy datetime64 and ns resolution the are out of reach and python datetime dosen't accept year 0. Not sure what to do with pycdfpp... |
Using the MMS example of cdf_to_xarray in the documentation,
ds.Epoch.attrs["FILLVAL"]
has value "1707-09-22T12:12:10.961224", but it should be "9999-12-31T23:59:59.99..." for MMS data.VALIDMIN
andVALIDMAX
attributes seem to be correctly converted, though. It's not a huge issue but I think this bug still needs to be fixed.The text was updated successfully, but these errors were encountered: