home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 288607926

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/1317#issuecomment-288607926 https://api.github.com/repos/pydata/xarray/issues/1317 288607926 MDEyOklzc3VlQ29tbWVudDI4ODYwNzkyNg== 1386642 2017-03-23T03:32:50Z 2017-03-23T03:40:22Z CONTRIBUTOR

I had the chance to play around with stack and unstack, and it appears that these actually do nearly all the work needed here, so you can disregard my last comment. The only logic which is somewhat unwieldy is code which creates a DataArray from the eofs dask array. This is a complete example using the air dataset: ```python air = load_dataset("air_temperature").air

A = air.stack(features=['lat', 'lon']).chunk() A-= A.mean('features')

,,eofs = svd_compressed(A.data, 4)

wrap eofs in dataarray

dims = ['modes', 'features'] coords = {}

for i, dim in enumerate(dims): if dim in A.dims: coords[dim] = A[dim] elif dim in coords: pass else: coords[dim] = np.arange(eofs.shape[i])

eofs = xr.DataArray(eofs, dims=dims, coords=coords).unstack('features') `` This is pretty compact as is, so maybe the ugly final bit could be replaced with a convenience function likeunstack_array(eofs, dims, coords)or a method callA.unstack_array(eofs, dims, new_coords={})`.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  216215022
Powered by Datasette · Queries took 0.699ms · About: xarray-datasette