I am trying to save the sequence of plots of 24 hours of ERA5 data from .nc file without plotting them. I am using xarray for reading .nc data. Here is my code:
import xarray as xr
import matplotlib.image as img
data = 'wind.nc'
DS = xr.open_dataset(data)['u10']
fig, ax = plt.subplots(1, 1, figsize=(7, 3.5))
for i in range(24):
x = '2022-01-31T0' + str(i) + ':00'
y = str(i) + '.PNG'
DS.sel(time=x).plot(cmap='bone')
plt.title('U Wind Component')
plt.axis('off')
plt.savefig(y, bbox_inches='tight')
Is there any way to accomplish this without showing the plots or any other library that does the job?