esa-esdl/esdl-core

get() method should return a Dictionary rather than a list of np.arrays

Closed this issue · 5 comments

As it stands, the user can only access a multi-variable list of arrays by index and not by name.

Issue would be solved or addressed, if we use xarray (http://xarray.pydata.org) to represent Cube objects.

Actually, I don't understand the issue. We decided to return arrays because we want to be able to use the following syntax:

v1, v2, v3 = cube.data.get(['v1', 'v2', 'v3'], ...)

Where v1, v2, v3 are currently raw numpy arrays. Using xarray, these will be xarray.DataArray instances. I guess, you are asking for an xarray.Dataset-like API replacing the get() method?

Correct, using xarray would solve this issue.

For single variables, we may also introduce

 v1 = cube.data.get('v1', time=...)

rather than having to write

 v1, = cube.data.get(['v1'], time=...)

We plan to remove the get() method