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

load datasets bypassing query #163

Merged
merged 2 commits into from
Dec 7, 2016
Merged

Conversation

benjimin
Copy link
Contributor

@benjimin benjimin commented Dec 6, 2016

A simple way to convert datacube datasets to xarray datasets.

For experimenting with task apps (producing datasets that have not yet been indexed), this would get the benefits that xarray.open_dataset lack and avoid:

from unittest import mock
with mock.patch('datacube.api.core.Datacube.product_observations') as po:
    po.return_value = [dataset]
    n = dc.load(product='ls5_nbar_albers', measurements=['swir1','nir','green'])
with mock.patch('datacube.api.core.Datacube.product_observations') as po:
    po.return_value = result
    w = dc.load(product='wofs_albers')

@omad
Copy link
Member

omad commented Dec 6, 2016

That sounds useful to me Ben. And it's a really nice small change.

Can you please update the formatting to make our overzealous pylint happy and I'll merge it in.

************* Module datacube.api.core
C:274, 0: Trailing whitespace (trailing-whitespace)
C:275, 0: Line too long (121/120) (line-too-long)

@omad omad merged commit 2ec4615 into opendatacube:develop Dec 7, 2016
@benjimin benjimin deleted the load-ds branch December 7, 2016 00:08
@coveralls
Copy link

coveralls commented Dec 7, 2016

Coverage Status

Coverage remained the same at 80.152% when pulling 51bedef on benjimin:load-ds into ee75ff1 on data-cube:develop.

@v0lat1le
Copy link
Contributor

Without context I'd say that product_sources and product_data should be used for that. load is meant as a higher level API where knowledge of existence of datasets is not required...

So, what's the context for this, why is this needed?

@omad
Copy link
Member

omad commented Dec 12, 2016

If you have a datacube dataset from somewhere, and you want to load the associate data from it. You can do it with product_sources and product_data, but it requires some extra code messing around with their required parameters.

@benjimin
Copy link
Contributor Author

Welcome back Greg. I think your concern that rarely-used optional arguments (in high-level API) impose undue cognitive burden on python users (to less emotively paraphrase "people's heads will explode") is misplaced; it is consistent with the high-level API style of popular python libraries, such as plot in matplotlib (e.g. the transform argument can bypass parts of its functionality; it is more convenient than replicating with the low-level API, and most users safely ignore it without needing to learn about the transforms which underlie matplotlib). The other good news is that the naming for product_sources, product_observations, etc has been fixed to describe to users what they do.

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

4 participants