issue_comments: 609023296
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/3931#issuecomment-609023296 | https://api.github.com/repos/pydata/xarray/issues/3931 | 609023296 | MDEyOklzc3VlQ29tbWVudDYwOTAyMzI5Ng== | 30388627 | 2020-04-04T12:45:03Z | 2020-04-04T12:50:12Z | NONE | @mathause Thanks! It works well. Here's the solution: Code``` def interp1d_np(data, x, xi): from scipy import interpolate # return np.interp(xi, x, data) f = interpolate.interp1d(x, data, fill_value='extrapolate') return f(xi) interped = xr.apply_ufunc( interp1d_np, # first the function bottom_up, # now arguments in the order expected by 'interp1_np' pressure.values, # as above interp_p.values, # as above input_core_dims=[["z"], ["z"], ["new_z"]], # list with one entry per arg output_core_dims=[["new_z"]], # returned data has one dimension exclude_dims=set(("z",)), # dimensions allowed to change size. Must be a set! vectorize=True, # loop over non-core dims ) interped = interped.rename({"new_z": "z"}) print(np.testing.assert_allclose(output.values, interped.values)) ``` Result:
However, when I apply it to my real data, I got some errors: Code``` def interp1d_np(data, x, xi): from scipy import interpolate f = interpolate.interp1d(x, data, fill_value='extrapolate') return f(xi)
``` Error:
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
593770078 |