issue_comments: 366819497
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/1914#issuecomment-366819497 | https://api.github.com/repos/pydata/xarray/issues/1914 | 366819497 | MDEyOklzc3VlQ29tbWVudDM2NjgxOTQ5Nw== | 10928117 | 2018-02-19T22:40:17Z | 2018-02-19T22:58:02Z | NONE | For "get done" I had for example the following (similar to what I linked as my initial attempt) ```python coordinates = { 'x': np.linspace(-1, 1), 'y': np.linspace(0, 10), } constants = { 'a': 1, 'b': 5 } inps = [{constants, {k: v for k, v in zip(coordinates.keys(), x)}} for x in list(it.product(*coordinates.values()))] def f(x, y, a, b): """Some dummy function.""" v = a * x2 + b * y2 return xr.DataArray(v, {'x': x, 'y': y, 'a': a, 'b': b}) simulate computation on clustervalues = list(map(lambda s: f(**s), inps)) gather and unstack the inputsds = xr.concat(values, dim='new', coords='all') ds = ds.set_index(new=list(set(ds.coords) - set(ds.dims))) ds = ds.unstack('new') ``` It is very close to what you suggest. My main question is if this can be done better. Mainly I am wondering if
1. Is there any built-in iterator over the Cartesian product of coordinates. If no, are there people that also think it would be useful?
2. Gathering together / unstacking of the data. My 3 line combo of
xarray_data = ... # some empty xarray object for inp, val in zip(inputs, values): xarray_data[inp] = val ``` I asked how to generate product of coordinates from xarray object because I was expecting that I can create Added commentHaving an empty, as filled with |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
297560256 |