I am working with a 2D dataset with the x and y dimensions representing two separate variables, and the combined 2D grid representing a third variable. Here’s a visual example of the dataset
and the x and y dimensions are constructed with the following:
y = np.arange(15,65)
x = np.arange(0,80,0.2)
xarray.DataArray'data'x: 50y: 400
array([[0.00000000e+00, 2.56638376e-07, 1.03175274e-06, ...,
2.52311498e-02, 2.53122803e-02, 2.53934718e-02],
[0.00000000e+00, 2.55799935e-07, 1.03203815e-06, ...,
2.54385639e-02, 2.55209708e-02, 2.56034412e-02],
[0.00000000e+00, 2.55260643e-07, 1.03282824e-06, ...,
2.56052146e-02, 2.56887540e-02, 2.57723593e-02],
...,
[0.00000000e+00, 4.74244857e-07, 1.48383797e-06, ...,
1.14323251e-02, 1.14721933e-02, 1.15120999e-02],
[0.00000000e+00, 4.84593744e-07, 1.50243858e-06, ...,
1.12702770e-02, 1.13094343e-02, 1.13486288e-02],
[0.00000000e+00, 4.95238907e-07, 1.52144658e-06, ...,
1.11227610e-02, 1.11612533e-02, 1.11997816e-02]])
I’ve looked into using xarray’s interp function to interpolate a value with an input x-variable and y-variable:
x_interp=44
y_interp=37
interp_value = da.interp(x=x_interp, y=y_interp)
however, I am interested in going the opposite direction – how can I utilize numpy/xarray/scipy to go the opposite direction to derive the y-value with an input x_interp
and interp_value
?
2