-
Notifications
You must be signed in to change notification settings - Fork 8
enable time_coord_name
to be different from "time"
#39
Comments
Here's an alternative suggestion, instead of relying on For each dimension in the dataset, if it has a corresponding variable, and |
As discussed in #48 there are a variety of imperfect options for determining "time". I suggest we check for a single If there is no We could consider checking units, as @klindsay28 suggest, but that introduces complexity and there might be multiple variables or no variables with |
What about the following order of operations:
I think the order of (2) - (4) is up for debate but my thinking is
There are some edge-cases to consider, especially centered around multiple variables with 2a. If there are multiple variables with |
Keep in mind that it is only convention that dictates a single unlimited dimension will be time. The only true way to check if a coordinate is a valid time coordinate is to check the units. And there is no way to pick the “right one” if there are multiple without user input. |
Would this be enough? def infer_time_coord_name(ds):
unlimited_dims = ds.encoding.get('unlimited_dims', None)
if len(unlimited_dims) == 1:
time_coord_name = list(unlimited_dims)[0]
return time_coord_name
else:
raise ValueError("Couldn't infer `time_coord_name` from multiple unlimited dimensions: %s \n\t\t ***** Please specify time_coord_name to use. *****" %unlimited_dims)
def compute_mon_climatology(dset, time_coord_name=None):
# Infer the time_coord_name
if time_coord_name is None:
time_coord_name = infer_time_coord_name(dset)
# Do The Computation |
@andersy005 I would prefer to look for a variable named "time" in the triage approach. How about the following?
|
@matt-long, your suggestion makes more sense. I will add it to the PR |
I have to admit, I grow more bothered by assuming that a single unlimited dimension is time. It is probably almost always true, but the problem is that if we are trying to identify the time coordinate so that we can do operations that can only be done if the coordinate is truly a time coordinate (eg, grouping by month or year, etc) then the only way to know how to do that is from the units and calendar. And if you have the units, then you can use cf-units to detect if it is truly a time coordinate. And that is much more robust. |
What if instead of Operations on the existing Are there Dataset operations on Are there |
xref: This issue is partially addressed in #48. Next step:
|
We assume throughout that the time coordinate is named "time", but this is overly restrictive.
We should introduce a variable
time_coord_name
and accept optional user input for this.If the user does not supply
time_coord_name
, attempt to infer by looking for coordinate named "time", or checking forunlimited_dim
.Many instance like
"time.month"
will have to be changed to variables too:time_dot_month = '.'.join([time_coord_name, "month"])
The text was updated successfully, but these errors were encountered: