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 data_vars and coords arguments to xr.open_mfdataset in DataLoaders #240

Conversation

spencerkclark
Copy link
Collaborator

This option ultimately did make it in to xarray version 0.10.0, so we can now clean up the logic required to work around the issue discussed here #199 (comment).

@spencerahill
Copy link
Owner

Thanks @spencerkclark! Looks good to me. Go ahead and merge at your discretion.

@spencerkclark
Copy link
Collaborator Author

@spencerahill great! I'm considering making data_vars and coords user-settable options in DataLoaders in light of #236 (probably within this PR). Do you think that would be a good idea?

@spencerahill
Copy link
Owner

@spencerkclark yes definitely. Thanks for the in-depth troubleshooting on that one.

Ping me once that's in and ready and I'll give it another look over

@spencerkclark spencerkclark changed the title Use data_vars='minimal' in xr.open_mfdataset Expose data_vars and coords arguments to xr.open_mfdataset in DataLoaders Dec 3, 2017
@spencerkclark
Copy link
Collaborator Author

@spencerahill @micahkim23 this should be ready for another review.

Copy link
Owner

@spencerahill spencerahill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple minor points + one request. Otherwise looks good!

else:
int_names = (set(GRID_ATTRS.keys()) -
set(TIME_VAR_STRS))
int_names = GRID_ATTRS.keys()
grid_attrs_in_ds = set(int_names).intersection(set(ds.coords) |
set(ds.data_vars))
ds.set_coords(grid_attrs_in_ds, inplace=True)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind taking care of #244 while you're at it by removing this use of inplace?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, that should be straightforward.

else:
int_names = (set(GRID_ATTRS.keys()) -
set(TIME_VAR_STRS))
int_names = GRID_ATTRS.keys()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just use GRID_ATTRS.keys() directly rather than defining int_names

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was the way it was prior to #199 (I think because of line length in the following line). Happy to change it though.

self._set_default('preprocess_func', preprocess_func,
lambda ds, **kwargs: ds)

def _maybe_inherit(self, template, attr, value):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this and _set_default aren't using any of the object's methods or attributes, I think it would be cleaner to define these at the module level as functions: def _maybe_inherit(obj, template, attr, value): etc.

Also, are the two different enough to warrant separate definitions? Am I correct that _set_default(obj, attr, value, getattr(template, attr)) == _maybe_inherit(obj, template, attr, value)?

If you do keep both, I'd suggest making the signatures more homogenous: obj, attr, value, template/default.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed! Good catch. I'll clean these up when I get a chance.

@spencerkclark
Copy link
Collaborator Author

Appveyor seems to have been well-behaved today :). @spencerahill let me know if my changes look good to you.

@spencerahill
Copy link
Owner

Appveyor seems to have been well-behaved today

Quick, let's merge before it gets tempermental! 😜

Thanks @spencerkclark , this is great.

@spencerahill spencerahill merged commit 67ec619 into spencerahill:develop Dec 4, 2017
@spencerkclark spencerkclark deleted the only-compare-coord-if-it-exists-2 branch December 4, 2017 03:06
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

Successfully merging this pull request may close these issues.

None yet

2 participants