Add prefer_datetime keyword for Raster constructor#1002
Conversation
|
Just need to add the same arguments to the ArchGDAL method, even if it just gets ignored there |
|
I added the prefer_datetime arg also to the _dims method of a RasterDataset. I also bumped the CDM version to 0.3.10 because this is where this keyword landed. This should be good to go now that the change was merged into CDM. |
|
@felixcremer is this meant to work now? |
|
Bump @felixcremer |
|
Unfortunately this uncovered a bug with reading date times in Rasters. I would need some hint where this is done so that I can fix it. using Rasters
using Zarr
using ZarrDatasets
using Dates
testdatapath = Downloads.download("https://github.com/user-attachments/files/25968262/testdata.zip")
zstore = Zarr.ZipStore(Mmap.mmap(testdatapath))
z = zopen(zstore)
ras = Raster(ZarrDataset(zstore), prefer_datetime=false)
rti = dims(ras, :azimuth_time)
rti_diffs = Dates.value.(diff(rti.val))
zdiffs = diff(z.arrays["azimuth_time"][:])
zdiffs == rti_diffs
CFTime.units(rti[1]) # Whould have expected "nanoseconds since 2025-06-26T05:34:21.819152" as they are written in the .zattrs |
|
I thought that this might be related to the fact, that the units of the element type of the time axis are microseconds since 1900-01-01 but I fixed this locally and the time axis is still wrong. |
|
Netcdf handles this - so I suspect this is a CommonDataModel problem |
|
Per default CommonDataModel currently converts the time values to DateTimes (unless prefer_datetime = false). Note that Dates.value does return milliseconds for julia's DateTime structures but for CFTime structures the units on the metadata. |
This adds the prefer_datetime keyword argument to the Raster constructor and forwards it to cfvariable.
This closes #1000.