grimbough / rhdf5

Package providing an interface between HDF5 and R
http://bioconductor.org/packages/rhdf5
61 stars 22 forks source link

Long Unix timestamps are converted to NA by h5read command in rhdf5 #113

Closed glenncampagna closed 2 years ago

glenncampagna commented 2 years ago

We have an hdf5 file from a hydrologic model run, and timestamps for data are in Unix time and unfortunately have 9 extra zeros at the end (example: 441763200000000000). When using h5read in rhdf5, these show up as NA. Is there a work-around to view the raw timestamps when using the h5read function? Our guess is that the current timestamp is too long. When simply trying to convert the given timestamp to a date-time, the as.POSIXct function gives NA... so maybe R is already trying to convert? Any help is appreciated

grimbough commented 2 years ago

Thanks for the interest in the package. Is it possible to share an example file so I can take a look?

I think the answer will depend on the format the timestamps are stored as inside the HDF5. There's type conversion between the file and R, but I'm unable to say if this is rhdf5 doing it wrong (i.e. a bug) or something currently not supported.

If you can't share a file the output from h5ls (in a terminal, not R) might show the data types.

glenncampagna commented 2 years ago

Thanks for the quick response. We actually already figured it out and used H5Dread and selected bit64conversion = "double" to get some numbers that we were actually able to work with. Thanks!