I am trying to write a dask array into a netcdf file and I am getting a memory error, which I find a little strange as the the size of the dask array isn't too big. It's about 0.04 GB. It's dimension are as following:
<xarray.Dataset>
Dimensions: (latitude: 2000, longitude: 5143)
Coordinates:
* latitude (latitude) float64 -29.98 -29.93 -29.88 -29.83 -29.78 -29.73 ...
* longitude (longitude) float64 -180.0 -179.9 -179.9 -179.8 -179.8 -179.7 ...
Data variables:Tmax (latitude, longitude) float32
**dask.array shape=(2000, 5143), chunksize=(2000, 5143)**
I also tried rechunking and that doesn't help either. Please let me know if you have any tips. Thank you!
Here is how I am generating the dask array to be written to netcdf.
DATA = xr.open_mfdataset(INFILE, concat_dim='Month', autoclose=True)
MONTH_MEAN = DATA.mean(dim='Month')
DIFF_MEAN = ((MONTH_MEAN.isel(time=np.arange(17, 34))).mean(dim='time') -
(MONTH_MEAN.isel(time=np.arange(17)))).mean(dim='time')
OUTFILE = OUTFILE_template.format(CHIRTS_INDIR, DATA_LIST[c])
DIFF_MEAN.to_netcdf(OUTFILE)
The dimension of DATA the original dask array that contains data from all the input files, is:
<xarray.Dataset>
Dimensions: (Month: 12, latitude: 2000, longitude: 5143, time: 34)
Coordinates:
* latitude (latitude) float64 -29.98 -29.93 -29.88 -29.83 -29.78 -29.73 ...
* longitude (longitude) float64 -180.0 -179.9 -179.9 -179.8 -179.8 -179.7 ...
* time (time) datetime64[ns] 1983-12-31 1984-12-31 1985-12-31 ...
Dimensions without coordinates: Month
Data variables:
Tmax (Month, time, latitude, longitude)
float32 dask.array<shape=(12, 34, 2000, 5143),
chunksize=(1, 34, 2000, 5143)>