-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
When I try to index a variable from a zarr file with Nanosecond precision I get a failure from trying to convert the CFTime type to DateTime.
julia>using ZarrDatasets
julia> s1grdpath = "https://objectstore.eodc.eu:2222/e05ab01a9d56408d82ac32d69a5aae2a:sample-data/tutorial_data/cpm_v253/S1A_IW_GRDH_1SDV_20240201T164915_20240201T164940_052368_065517_750E.zarr"
"https://objectstore.eodc.eu:2222/e05ab01a9d56408d82ac32d69a5aae2a:sample-data/tutorial_data/cpm_v253/S1A_IW_GRDH_1SDV_20240201T164915_20240201T164940_052368_065517_750E.zarr"
julia> s1grd = ZarrDataset(s1grdpath);
julia> m = s1grd.group["S01SIWGRD_20240201T164915_0025_A299_750E_065517_VV"].group["measurements"];
julia> aztind = m["azimuth_time"]
azimuth_time (16675)
Datatype: Dates.DateTime (Int64)
Dimensions: azimuth_time
Attributes:
dtype = <u2
calendar = proleptic_gregorian
units = nanoseconds since 2024-02-01 16:49:15.722819
long_name = azimuth time for GRD IW
dimensions = Any["azimuth_time"]
_eopf_attrs = Dict{String, Any}("_eopf_decode_datetime64" => "datetime64[ns]")
julia> aztind[:]
┌ Warning: CFTime Datetime with a base units of 10^(-6) seconds cannot be converted to Dates.DateTime
└ @ CFTime ~/.julia/packages/CFTime/5Rfdq/src/conversions.jl:438
ERROR: InexactError: convert(Dates.DateTime, DateTimeProlepticGregorian(2024-02-01T16:49:15.722819)
)
Stacktrace:
[1] convert(::Type{Dates.DateTime}, dt::DateTimeProlepticGregorian{CFTime.Period{…}, Val{…}()})
@ CFTime ~/.julia/packages/CFTime/5Rfdq/src/conversions.jl:439
[2] asdate
@ ~/.julia/packages/CommonDataModel/HZ4nE/src/cfvariable.jl:277 [inlined]
[3] CFtransform
@ ~/.julia/packages/CommonDataModel/HZ4nE/src/cfvariable.jl:330 [inlined]
[4] macro expansion
@ ~/.julia/packages/CommonDataModel/HZ4nE/src/cfvariable.jl:377 [inlined]
[5] macro expansion
@ ./simdloop.jl:77 [inlined]
[6] CFtransformdata!
@ ~/.julia/packages/CommonDataModel/HZ4nE/src/cfvariable.jl:376 [inlined]
[7] CFtransformdata
@ ~/.julia/packages/CommonDataModel/HZ4nE/src/cfvariable.jl:385 [inlined]
[8] getindex(v::CommonDataModel.CFVariable{…}, indexes::Colon)
@ CommonDataModel ~/.julia/packages/CommonDataModel/HZ4nE/src/cfvariable.jl:453
[9] top-level scope
@ REPL[46]:1
Some type information was truncated. Use `show(err)` to see complete types.
It would be good to be able to keep the CFTime type and not try to convert to DateTime.
I found this line in cfvariable.jl and I think it would be good if one could set this from outside.
See the discussion in Rasters on that:
rafaqz/Rasters.jl#1000
Metadata
Metadata
Assignees
Labels
No labels