issues: 2115555965
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2115555965 | I_kwDOAMm_X85-GNJ9 | 8695 | Return a 3D object alongside 1D object in apply_ufunc | 15331990 | closed | 0 | 7 | 2024-02-02T18:47:14Z | 2024-04-28T19:59:31Z | 2024-04-28T19:59:31Z | CONTRIBUTOR | Is your feature request related to a problem?Currently, I have something similar to this, where the Since Any ideas on how I can modify this to make it more efficient? ```python import xarray as xr import numpy as np air = xr.tutorial.open_dataset("air_temperature")["air"] input_lat = np.arange(20, 45) def interp1d_np(data, base_lat, input_lat): new_lat = input_lat + 0.25 return np.interp(new_lat, base_lat, data), new_lat ds, new_lat = xr.apply_ufunc( interp1d_np, # first the function air, air.lat, # as above input_lat, # as above input_core_dims=[["lat"], ["lat"], ["lat"]], # list with one entry per arg output_core_dims=[["lat"], ["lat"]], # returned data has one dimension exclude_dims=set(("lat",)), # dimensions allowed to change size. Must be a set! vectorize=True, # loop over non-core dims ) new_lat = new_lat.isel(lon=0, time=0).values ds["lat"] = new_lat ``` Describe the solution you'd likeEither be able to automatically assign the new_lat to the returned xarray object, or allow a 1D dataset to be returned Describe alternatives you've consideredNo response Additional contextNo response |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/8695/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |