-
Notifications
You must be signed in to change notification settings - Fork 30
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
Time dimension with month units cannot be loaded #181
Comments
Why do you think it was a bad job to store the time coordinates as Float64? The first example in the CF conventions on time, also uses a double underneath:
I normally thing integers are a better match for discrete timestamps though, which is the reason DateTime is backed by integers, and hence this issue. To resolve this, I guess it's fine to round to the nearest millisecond? |
I've loaded data .nc from about 20 different sources/researchgroups/models, and this is the first time I got this specific error. So I thought it was an export mistake. I stand corrected, so I apologize for wrongly blaming the exporting person.
The problem is, I don't even know what the data are. I mean, I don't know if the data are literally counting the time entries from 1 to 240, or if they are representing milliseconds from an epoch. I would need to go back to |
The data are actually integers. You can avoid using the CF convention transformations like this:
I see in the code that it already is doing rounding to milliseconds in lines like
But for some reason it is not hitting that path. For scalar getindex it is also wrong I think since it doesn't return a DateTime. julia> ds["time"][1]
0.0
julia> ds["time"][1:2]
ERROR: MethodError: Cannot `convert` an object of type Float64 to an object of type Dates.DateTime
Closest candidates are:
convert(::Type{Dates.DateTime}, ::T2) where T2<:Union{DateTimeJulian, DateTimeProlepticGregorian, DateTimeStandard} at d:\visser_mn\.julia\packages\CFTime\n09Um\src\CFTime.jl:308
convert(::Type{Dates.DateTime}, ::Dates.Date) at d:\visser_mn\.julia\juliaup\julia-1.8.0-rc1+0~x64\share\julia\stdlib\v1.8\Dates\src\conversions.jl:30
convert(::Type{Dates.DateTime}, ::Dates.Millisecond) at d:\visser_mn\.julia\juliaup\julia-1.8.0-rc1+0~x64\share\julia\stdlib\v1.8\Dates\src\conversions.jl:34
...
Stacktrace:
[1] setindex!(A::Vector{Dates.DateTime}, x::Float64, i1::Int64)
@ Base .\array.jl:966
[2] macro expansion
@ d:\visser_mn\.julia\packages\NCDatasets\4ceso\src\cfvariable.jl:663 [inlined] |
Thanks, I did not see the link to the file initially. I got it. |
I think the issue is the https://github.com/JuliaGeo/CFTime.jl/blob/master/src/CFTime.jl#L434
But I think it is standard conform (https://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/ch04s04.html):
|
Ah I see. But then why don't we hit the |
Yes, we should have an error or warning. I guess we might had it in the past, but then it was silenced by an overzealous try/catch. In master, we have now a warning:
With the master version of CFTime, the month units is now understood as |
Is there anything left before this can be closed? |
ops, sorry, i haven't tested this yet. I'll test it and reopen if anything goes south! (I'm assuming taht an update will just fix things, as it will update CFTime) |
Hi there, I have this error:
As you can see, even though the time specification follows CF conventions, it actually stores the data as floats. So, someone did a bad job exporting the files properly, that is true, however, I think in this case we shouldn't have an error. We should have a warning clause, and the dimension should be loaded as any other floating point dimension, once a detection of Floats in time happens.
What do you think? The data are here: https://owncloud.gwdg.de/index.php/s/qdLsvW6iMmnYEPK
Versions latest stable all:
The text was updated successfully, but these errors were encountered: