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

Unify netCDF4 and scipy backends in the public API #333

Merged
merged 6 commits into from
Feb 25, 2015

Conversation

shoyer
Copy link
Member

@shoyer shoyer commented Feb 24, 2015

Fixes #273
and half of #272

To serialize a dataset to a string/bytes, simply use ds.to_netcdf(). This behavior copies DataFrame.to_csv() from pandas. The legacy dump and dumps methods are deprecated.

My main concern is that the default "format" option is depends on what dependencies the user has installed or if they are saving a file. That seems non-ideal, but may perhaps be the most pragmatic choice given the limitations of the netCDF4 format.

This change also adds:

  • Support for writing datasets to a particular NETCDF4 group
  • Support for opening netCDF3 files from disk even without netCDF4-python if scipy is installed.

CC @akleeman

Fixes GH273

To serialize a dataset to a string/bytes, simply use `ds.to_netcdf()`. This
behavior copies `DataFrame.to_csv()` from pandas.

This change also adds support for writing datasets to a particular NETCDF4 group.

The legacy `dump` and `dumps` methods are deprecated.
@shoyer shoyer changed the title Unify netCDF4 and scipy backends in to_netcdf Unify netCDF4 and scipy backends in the public API Feb 24, 2015
@@ -54,7 +54,7 @@ def _nc4_values_and_dtype(var):
return var, dtype


def _nc4_group(ds, group):
def _nc4_group(ds, group, mode):
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be nice to have a way to list groups in a netCDF, to facilitate opening ... but that's probably future work.

Copy link
Member Author

Choose a reason for hiding this comment

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

At some point, it could be nice to have a full API for loading a set of datasets from groups. But not in this PR.

shoyer added a commit that referenced this pull request Feb 25, 2015
Unify netCDF4 and scipy backends in the public API
@shoyer shoyer merged commit b6baa76 into pydata:master Feb 25, 2015
@shoyer shoyer deleted the to_netcdf-refresh branch February 25, 2015 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unify netCDF4 and scipy backends in to_netcdf
2 participants