home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 593770078

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
593770078 MDU6SXNzdWU1OTM3NzAwNzg= 3931 Interpolate 3D array by another 3D array 30388627 closed 0     10 2020-04-04T08:09:07Z 2020-04-05T01:22:44Z 2020-04-05T01:22:44Z NONE      

I have two data:

  1. 3D data with z(height) levels
  2. 3D pressure data which are at the same levels

Then, I want to interpolate the first 3D data to another 3D pressure data. I have to iterate through x, y and interpolate the data by pressure levels.

This is too slow when the 3D array is large. Is there a more efficient and easier method to accomplish this?

MCVE Code Sample

```python import xarray as xr import numpy as np

x = 10 y = 10 z = 4 data = np.arange(xyz).reshape((x, y, z))

bottom_up data

bottom_up = xr.DataArray(data, coords={'x': np.arange(x), 'y': np.arange(y), 'z': np.arange(z)}, dims=['x', 'y', 'z'] )

corresponding pressure data

pressure = xr.DataArray(data+1, coords={'x': np.arange(x), 'y': np.arange(y), 'z': np.arange(z)}, dims=['x', 'y', 'z'] )

pressure levels which data are interpolated to

interp_p = xr.DataArray(data[:, :, :-2]+0.5, coords={'x': np.arange(x), 'y': np.arange(y), 'z': np.arange(z-2)}, dims=['x', 'y', 'z'])

empty DataArray where interpolated values are saved

output = interp_p.copy(data=np.full_like(interp_p, np.nan))

iterate through x and y

for x in bottom_up.x: for y in bottom_up.y: # replace bottom_up with pressure bottom_up = bottom_up.assign_coords(z=(pressure[x, y, :]).values) # interpolate data to interpolated pressure levels output[x, y, :] = bottom_up[x, y, :].interp(z=interp_p[x, y, :], kwargs={'fill_value': 'extrapolate'} ) print(output) ```

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3931/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 10 rows from issue in issue_comments
Powered by Datasette · Queries took 0.696ms · About: xarray-datasette