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

Expose valid kwargs in documentation for .to_xarray() method #138

Closed
ahuang11 opened this issue Oct 9, 2019 · 2 comments
Closed

Expose valid kwargs in documentation for .to_xarray() method #138

ahuang11 opened this issue Oct 9, 2019 · 2 comments

Comments

@ahuang11
Copy link

ahuang11 commented Oct 9, 2019

Following the example in #137

I was trying to do this:
col.search(model='CFSv2', variable='prate').to_xarray(decode_times=False)

But I got the error:

ValueError: some chunks keys are not dimensions on this object: {'time'}

When I tried looking at the docstring, I couldn't find anything that mentioned how to change the time coordinate.

Signature: cat.to_xarray(**kwargs)
Docstring:
Return dataset as an xarray dataset
Additional keyword arguments are passed through to methods in aggregate.py

I had to look at source.py to see the available kwargs:

        if 'decode_times' not in _kwargs:
            _kwargs.update(decode_times=True)
        if 'compat' not in _kwargs:
            _kwargs.update(compat='no_conflicts')
        if 'time_coord_name' not in _kwargs:
            _kwargs.update(time_coord_name='time')
        if 'ensemble_dim_name' not in _kwargs:
            _kwargs.update(ensemble_dim_name='member_id')
        if 'chunks' not in _kwargs:
            _kwargs.update(chunks={_kwargs['time_coord_name']: 'auto'})
        if 'override_coords' not in _kwargs:
            _kwargs.update(override_coords=False)
        if 'join' not in _kwargs:
            _kwargs.update(join='outer')
        if 'preprocess' not in _kwargs:
            _kwargs.update(preprocess=None)
        if 'merge_exp' not in _kwargs:
            _kwargs.update(merge_exp=True)

And finally, I got it to work:
col.search(model='CFSv2', variable='prate').to_xarray(decode_times=False, time_coord_name='target')

So I guess it'd be easier for people if the to_xarray method showed something like (or more detailed):

Signature: cat.to_xarray(**kwargs)
Docstring:
Return dataset as an xarray dataset
Valid kwargs: decode_times, compat, ... etc
Additional keyword arguments are passed through to methods in aggregate.py
@andersy005
Copy link
Member

So I guess it'd be easier for people if the to_xarray method showed something like (or more detailed):

I concur

The aggregate.py module will be removed in the next release because most of the things we used to do ourselves have been implemented in xarray>=0.13.

Here's what the to_xarray() is going to look like:

https://github.com/NCAR/intake-esm/blob/87c94eb126f27a4acd897c1ba9789325a8892c4e/intake_esm/core.py#L105-L112

I will update the docstring with your suggestion

@andersy005
Copy link
Member

This has been addressed in #135

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

No branches or pull requests

2 participants