migrate to the latest xarray version
When installing the new version of xarray I got the following error:
/usr/local/Caskroom/miniconda/base/envs/sst_env/bin/python /Users/brivas/ORCHESTRA_sst/sst_differences.py
{'long_name': 'analysed sea surface temperature', 'standard_name': 'sea_water_temperature', 'units': 'kelvin', 'description': 'CCI-SST interpolated to ICOADS drifting buoy location and averaged on a 1.0 degree resolution cell'}
Traceback (most recent call last):
File "/Users/brivas/ORCHESTRA_sst/sst_differences.py", line 52, in <module>
grid_boxes_with_data = xr.apply_ufunc(non_zero_data,
File "/usr/local/Caskroom/miniconda/base/envs/sst_env/lib/python3.8/site-packages/xarray/core/computation.py", line 1174, in apply_ufunc
return apply_dataarray_vfunc(
File "/usr/local/Caskroom/miniconda/base/envs/sst_env/lib/python3.8/site-packages/xarray/core/computation.py", line 293, in apply_dataarray_vfunc
result_var = func(*data_vars)
File "/usr/local/Caskroom/miniconda/base/envs/sst_env/lib/python3.8/site-packages/xarray/core/computation.py", line 767, in apply_variable_ufunc
raise ValueError(
ValueError: applied function returned data with unexpected number of dimensions. Received 0 dimension(s) but expected 1 dimensions with names: ('time',)
According to stackoverflow this is because the new version of the xarray.apply_ufunc requires the latitudes to be sorted in an ascending way.
see the following xarray documentation and blog post link.
This issue is not a problem in xarray version 0.16.0
The error can be fix by sorting the latitudes first here and than running the xr.apply_ufunc()
See lines L49 onwards