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

ENH: adds "UnitsDataArray.open" and "UnitsDataArray.create" class methods #334

Closed
wants to merge 3 commits into from

Conversation

mlshapiro
Copy link
Contributor

@mlshapiro mlshapiro commented Nov 11, 2019

  • Adds UnitsDataArray.open class method
  • Changes create_data_array to create_dataarray to be consistent with xarray naming convention in methods.
  • Deprecated create_dataarray in favor of UnitsDataArray.create

This feature adds the ability to symmetrically go between UnitsDataArray -> netcdf -> UnitsDataArray. The goal is move away from pickle in the lambda function interface and more generally, provide users a way to export/import binary outputs from/to PODPAC.

Both creare_dataarray and open_dataarray could probably be classmethods, like we have done in the Coordinates module. It may also be useful to export and import methods on UnitsDataArray that uses the to_netcdf and open_datarray in the background.
Done in e9abbc4

Example

# Eval with simple example
from podpac.data import Array
from podpac import Coordinates, UnitsDataArray
import numpy as np

# mock data
data = np.random.rand(5, 5)

# create native coordinates for data
lat = np.linspace(-10, 10, 5)
lon = np.linspace(-10, 10, 5)
native_coords = Coordinates([lat, lon], ['lat', 'lon'])

# create Array DataSource node
node= Array(source=data, native_coordinates=native_coords)

# evaluate
output = node.eval(node_array.native_coordinates)

# export
output_netcdf = output.to_netcdf()

# import
output2 = UnitsDataArray.open(output_netcdf)

# goal:
# output2 == output

Changes "create_data_array" to "create_dataarray" to be consistent with xarray naming convention in methods.

This feature adds the ability to symmetrically go between UnitsDataArray -> netcdf -> UnitsDataArray.  The goal is move away from pickle in the lambda function interface and more generally, provide users a way to share binary outputs and get them back in PODPAC.
@mlshapiro mlshapiro requested a review from jmilloy November 11, 2019 19:21
@mlshapiro mlshapiro self-assigned this Nov 11, 2019
@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 82.176% when pulling f77e0c6 on feature/open_dataaray into 5f64ab2 on develop.

@coveralls
Copy link

coveralls commented Nov 11, 2019

Coverage Status

Coverage increased (+0.08%) to 82.19% when pulling e9abbc4 on feature/open_dataaray into 5f64ab2 on develop.

Copy link
Contributor

@mpu-creare mpu-creare left a comment

Choose a reason for hiding this comment

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

THis looks good, and I think it will work just fine. I would prefer the functions to be a class method on UnitsDataArray

@mpu-creare
Copy link
Contributor

Also, looks like the build is failing, which may explain the reduced coverage https://travis-ci.org/creare-com/podpac/builds/610568191

@mlshapiro
Copy link
Contributor Author

I would prefer the functions to be a class method on UnitsDataArray

I would prefer this too. I'll make this change and review before merging

…vor of classmethods `UnitsDataArray.create()` and `UnitsDataArray.open()`

This is much more clear to me and completes discussion in #334
…hould be overwritten by the aws-improvements branch
@mlshapiro mlshapiro changed the title ENH: adds "open_dataarray" method to units module. ENH: adds "UnitsDataArray.open" and "UnitsDataArray.create" class methods Nov 13, 2019
@mlshapiro
Copy link
Contributor Author

Updated PR context above

@mlshapiro mlshapiro closed this Nov 13, 2019
@mlshapiro mlshapiro deleted the feature/open_dataaray branch November 13, 2019 18:18
@mpu-creare
Copy link
Contributor

There was something nagging at the back of my mind. We did serialize/deserialize already in the cache: see here: https://github.com/creare-com/podpac/blob/develop/podpac/core/cache/file_cache_store.py#L147

I'm guessing those lines will need some (minor) updates as well

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.

3 participants