Commit 73a15178 authored by Beatriz Recinos's avatar Beatriz Recinos
Browse files

make animation deal with nan

parent 1867af70
...@@ -125,39 +125,43 @@ for hour in hours_list_to_plot: ...@@ -125,39 +125,43 @@ for hour in hours_list_to_plot:
cci_to_plot = daily_sst_zonal_mean.isel(time=len(sst.time)-1) cci_to_plot = daily_sst_zonal_mean.isel(time=len(sst.time)-1)
plot_sst.plot_sst_map(cci_to_plot, ax=ax, vmin=-7, vmax=7) plot_sst.plot_sst_map(cci_to_plot, ax=ax, vmin=-7, vmax=7)
for date in dates_list: if df_buoy is None:
try: plt.close(f)
buoy_data = df_buoy[date.strftime('%Y-%m-%d')][0] pass
xx = buoy_data.lon.values else:
yy = buoy_data.lat.values for date in dates_list:
s = 30 / buoy_data.age.values try:
temp_diff = buoy_data['cci_sst'] - buoy_data['cci_sst_1x1'] buoy_data = df_buoy[date.strftime('%Y-%m-%d')][0]
temp = temp_diff.values xx = buoy_data.lon.values
yy = buoy_data.lat.values
cmap = plt.get_cmap('PiYG_r', 20) s = 30 / buoy_data.age.values
temp_diff = buoy_data['cci_sst'] - buoy_data['cci_sst_1x1']
img = ax.scatter(xx, yy, s=s, temp = temp_diff.values
c=temp, cmap=cmap, vmin=-1, vmax=1, edgecolors='k',
linewidths=0.5, cmap = plt.get_cmap('PiYG_r', 20)
transform=crs.PlateCarree())
except IndexError: img = ax.scatter(xx, yy, s=s,
pass c=temp, cmap=cmap, vmin=-1, vmax=1, edgecolors='k',
linewidths=0.5,
# Now adding the colour-bar transform=crs.PlateCarree())
cax, kw = colorbar.make_axes(ax, location='top', pad=0.07, aspect=30) except IndexError:
out = f.colorbar(img, cax=cax, **kw) pass
out.set_label('Temperature difference ($^{\circ}$C) \n'
'CCI-SST at buoy coords - CCI-SST mean in a 1x1 gridbox centred at ' # Now adding the colour-bar
'buoy coords', cax, kw = colorbar.make_axes(ax, location='top', pad=0.07, aspect=30)
size='small', out = f.colorbar(img, cax=cax, **kw)
# \n ''cci-sst at buoy coords - cci-sst avg in a 2x2 gridbox \n ' out.set_label('Temperature difference ($^{\circ}$C) \n'
weight='bold') 'CCI-SST at buoy coords - CCI-SST mean in a 1x1 gridbox centred at '
'buoy coords',
f.suptitle(plot_end_date) size='small',
#ax.set_title() # \n ''cci-sst at buoy coords - cci-sst avg in a 2x2 gridbox \n '
weight='bold')
plot_name = str(int(year)) + '_' + f"{str(int(month)):0>2}" + f"{str(int(day_to_plot)):0>2}" + f"{str(int(hour)):0>2}"
plt.savefig(os.path.join(config['plots_path'], plot_name + '.png'), f.suptitle(plot_end_date)
bbox_inches='tight', pad_inches=0.25) #ax.set_title()
plt.clf()
plt.close(f) plot_name = str(int(year)) + '_' + f"{str(int(month)):0>2}" + f"{str(int(day_to_plot)):0>2}" + f"{str(int(hour)):0>2}"
\ No newline at end of file plt.savefig(os.path.join(config['plots_path'], plot_name + '.png'),
bbox_inches='tight', pad_inches=0.25)
plt.clf()
plt.close(f)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment