Some benchmarks with the original code:
Initial regrid dataset in fn test_xarray_regrid took 18.9291 seconds
Second regrid dataset in fn test_xarray_regrid took 13.4746 seconds
And by assigning 'weights' and 'reuse_weights' to regridder_kwargs
Initial regrid dataset in fn test_xarray_regrid took 16.8666 seconds
Second regrid dataset in fn test_xarray_regrid took 4.2991 seconds
It seems like the regridding weights in regrid_dataset are not reused as expected from the weights_location keyword.
The kwargs set at https://github.com/Ouranosinc/xscen/blob/99981803953c11d4317c576b7808403045606cca/src/xscen/regrid.py#L132
are not passed to xe.Regridder? They should be assigned to regridder_kwargs instead of kwargs
https://github.com/Ouranosinc/xscen/blob/99981803953c11d4317c576b7808403045606cca/src/xscen/regrid.py#L142
Some benchmarks with the original code: Initial regrid dataset in fn test_xarray_regrid took 18.9291 seconds Second regrid dataset in fn test_xarray_regrid took 13.4746 seconds
And by assigning 'weights' and 'reuse_weights' to regridder_kwargs Initial regrid dataset in fn test_xarray_regrid took 16.8666 seconds Second regrid dataset in fn test_xarray_regrid took 4.2991 seconds
Fixed in f12895a084d8d3521e8c721c7c2a37955fa59c07