-
Notifications
You must be signed in to change notification settings - Fork 0
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
Parsing delta_t to DatePeriod? #8
Comments
BTW I implemented this with something like: function get_period(index, attrs)
if haskey(attrs, "delta_t")
period = parse_period(attrs["delta_t"])
elseif haskey(attrs, "avg_period")
period = parse_period(attrs["avg_period"])
else
nothing
end
end
function parse_period(period_str::String)
regex = r"(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)"
mtch = match(regex, period_str)
if mtch isa Nothing
nothing
else
vals = Tuple(parse.(Int, mtch.captures))
periods = (Year, Month, Day, Hour, Minute, Second)
if length(vals) == length(periods)
sum(map((p, v) -> p(v), periods, vals))
else
nothing
end
end
end Witch returns a It could go here if you want. |
Is this part of the CF conventions? If yes, can you share a link that I can learn about it? |
No sorry I reallised it's not actually CF, its CDC. It's just fairly common in netcdf files I use. https://psl.noaa.gov/data/gridded/conventions/cdc_netcdf_standard.shtml CF conventions don't seem to specify how to get/set the interval between time points, or at least I haven't been able to find anything clear. So to get the timespan in months you would have to use some heuristics to work out the closest interval to the points in the series, which is pretty awful, but guess I will have to write it at some stage. The difficult part is the spacing doesn't have to be equal so you need to check every date in the index to make sure it roughly e.g. month spaced for months in whatever the calendar is. But when you know the step size in julia I think with CF the idea is that there is another vector that holds the time bounds, so that each interval is self contained. But I've never seen an actual file that had that in it. |
Thanks, but the aim for this package to just implement the CF conventions. |
I would like to get time periods in julia
DatePeriod
object likeMonth(1)
from netcdf time dimensiondelta_t
fields like"0000-01-00 00:00:00"
. This would give correct time ranges in GeoData.jl.Are there tools here that would already do that, or get some of the way?
The text was updated successfully, but these errors were encountered: