Skip to content
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

BUG: Problems handling data consisting of a single time slice #132

Closed
spencerkclark opened this issue Jan 30, 2017 · 3 comments
Closed

BUG: Problems handling data consisting of a single time slice #132

spencerkclark opened this issue Jan 30, 2017 · 3 comments

Comments

@spencerkclark
Copy link
Collaborator

spencerkclark commented Jan 30, 2017

There are numerous problems caused (in many parts of the code) if we load in data that has only one time value; I've run into this in trying to construct a test case for #129 with a file consisting of a single monthly mean.

I think it mostly has to do with the fact that in that case time is treated as a scalar coordinate and not an indexable dimension. Since there are numerous places where we try to do da.sel or da.isel on the time dimension throughout the code, we run into a lot of problems.

@spencerahill is there a way to enforce that a coordinate is always indexable (in other words make sure that it is always in ds.dims even if it only has one value)?

@spencerahill
Copy link
Owner

What immediately comes to mind for me is for us to just check upon loading if there is only a single time value.

I.e. so data_loader._load_data_from_disk would become:

    ...
    apply_preload_user_commands(file_set)
    ds =xr.open_mfdataset(file_set, preprocess=rename_grid_attrs,
                             concat_dim=internal_names.TIME_STR,
                             decode_cf=False)
    return _ensure_indexable_time(ds)

def  _ensure_indexable_time(ds):
    """"Force dataset to have indexable time coordinate.

    The primary use-case is for datasets with a single time-value, which
    results in a scalar coordinate that is therefore not indexable.
    """
    if <insert needed bool here>:
        return <insert needed logic here>
    else:
        return ds

Do you think something like that would work?

@spencerahill spencerahill added this to the v0.1.1 milestone Jan 31, 2017
@spencerahill
Copy link
Owner

Unless this becomes a major can of worms, let's get this into the v0.1.1 bugfix release; it's a not-too-uncommon use-case to have a single time value.

@spencerahill
Copy link
Owner

Closed by #135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants