@@ -71,12 +71,14 @@ def XLinear(
7171 zi = np .tile (np .stack ([zi , zi , zi , zi , zi_1 , zi_1 , zi_1 , zi_1 ], axis = 1 ).flatten (), lenT )
7272
7373 # Y coordinates: [yi, yi, yi+1, yi+1] pattern repeated
74+ # TODO consider using np.repeat for better performance
7475 yi_1 = np .clip (yi + 1 , 0 , data .shape [2 ] - 1 )
75- yi = np .tile (np .repeat ([yi , yi_1 ], 2 ), (lenT ) * (lenZ ))
76+ yi = np .tile (np .stack ([yi , yi , yi_1 , yi_1 ], axis = 1 ). flatten ( ), (lenT ) * (lenZ ))
7677
7778 # X coordinates: [xi, xi+1] for each spatial point, repeated for time/depth
79+ # TODO consider using np.repeat for better performance
7880 xi_1 = np .clip (xi + 1 , 0 , data .shape [3 ] - 1 )
79- xi = np .repeat ( [xi , xi_1 ], 2 * (lenT ) * (lenZ ))
81+ xi = np .tile ( np . stack ( [xi , xi_1 , xi , xi_1 ], axis = 1 ). flatten (), (lenT ) * (lenZ ))
8082
8183 # Create DataArrays for indexing
8284 ti_da = xr .DataArray (ti , dims = ("points" ))
@@ -87,7 +89,7 @@ def XLinear(
8789 F = data .isel ({axis_dim ["X" ]: xi_da , axis_dim ["Y" ]: yi_da , axis_dim ["Z" ]: zi_da , "time" : ti_da })
8890 F = F .data .reshape (- 1 , lenT , lenZ , 4 )
8991 # TODO check if numpy can handle this more efficiently
90- # F = data.values[tti, zii, yii, xii ].reshape(-1, 4)
92+ # F = data.values[ti, zi, yi, xi ].reshape(-1, lenT, lenZ , 4)
9193
9294 if lenT == 2 :
9395 F_t0 , F_t1 = F [:, 0 , :, :], F [:, 1 , :, :]
0 commit comments