I have an xarray DataArray which has coordinates lat, lon, time (and height but I have only one level). I am using stats to summarise the time series at each point and have a function to do this. I would like the function to return either a numpy array at each grid (lat/lon) point or a string (or write this directly to my file). The process is slow and therefore I am using dask in order to parallelise.
So far I have successfully applied u_func along all of the dimension of the DataArray to give one of the input parameters to this function. Using the function below:
ds['binsNew'] = xr.apply_ufunc(vectorized_fn1,ds['bins'], dask='allowed')
However the below function is not working as expected
fit_params = xr.apply_ufunc(vectorized_fn2_ts_stats, ds['WS'], ds['binsNew'],ds['lon'],ds['lat'],
input_core_dims=[['time'],['time'],[],[]],
vectorize=True,
dask='parallelized')
Yesterday it appeared to produce the array required within the function but not be able to store in the DataArray. However today within the function if I print the input variables, they are all incorrectly 1 and it appears to only be executing the function for one location on the grid.
Does anyone have any advice on whether this approach should work, or a better way to tackle the issue?