<jupyter_start><jupyter_text>Heat Fluxes<jupyter_code># We add all the fluxes together since in ECMWF positive is always downwards
# So positive short wave will heat the ocean 
# Positive latent would mean that condensation took place.
surf_heat_flux = ds.slhf + ds.ssr + ds.str + ds.sshf
ds.ssr.sel(latitude=-52, longitude=35, method='nearest').isel(time=slice(0,48)).plot(label='Short Wave')
ds.str.sel(latitude=-52, longitude=35, method='nearest').isel(time=slice(0,48)).plot(label='Long Wave')
ds.sshf.sel(latitude=-52, longitude=35, method='nearest').isel(time=slice(0,48)).plot(label='Sensible')
ds.slhf.sel(latitude=-52, longitude=35, method='nearest').isel(time=slice(0,48)).plot(label='Latent')
surf_heat_flux.sel(latitude=-52, longitude=35, method='nearest').isel(time=slice(0,48)).plot(label='total')
plt.grid()
plt.legend()
surf_heat_flux_mean = (surf_heat_flux).rolling(time=24, center=True).mean()
(surf_heat_flux/3600).sel(latitude=-52, longitude=35, method='nearest').plot(label='Hourly')
(surf_heat_flux_mean/3600).sel(latitude=-52, longitude=35, method='nearest').plot(label='Daily Mean')

plt.legend()
(surf_heat_flux_mean/3600).sel(latitude=slice(-50,-52), longitude=slice(30,34)).sel(time=slice('2019-04-15','2019-08-15')
                                                                                   ).mean(['latitude','longitude']).plot(label='Daily Mean West', color='Green')
(surf_heat_flux_mean/3600).sel(latitude=slice(-52,-54), longitude=slice(35,38)).sel(time=slice('2019-04-15','2019-08-15')
                                                                                   ).mean(['latitude','longitude']).plot(label='Daily Mean East', color='Purple')
plt.ylabel('Surface Heat Flux ($W/m^2$)')
plt.legend()
plt.grid()
(surf_heat_flux_mean/3600).sel(latitude=slice(-50,-52), longitude=slice(30,34)).sel(time=slice('2019-04-15','2019-08-15')
                                                                                   ).mean(['latitude','longitude']).plot.hist(label='Daily Mean West', color='Green')
(surf_heat_flux_mean/3600).sel(latitude=slice(-52,-54), longitude=slice(35,38)).sel(time=slice('2019-04-15','2019-08-15')
                                                                                   ).mean(['latitude','longitude']).plot.hist(label='Daily Mean East', color='Purple', alpha=0.5)
plt.xlabel('Surface Heat Flux ($W/m^2$)')
plt.legend()
plt.grid()
plt.figure(figsize=(12,4))
plt.subplot(121)
(surf_heat_flux_mean/3600).sel(time=slice('2019-05-01','2019-05-05')).mean('time').plot(vmin=-200, vmax=200, cmap='RdBu_r')
plt.title('Surface Heat Flux Averaged 2019-05-01 to 05')

plt.subplot(122)
(surf_heat_flux_mean/3600).sel(time=slice('2019-07-26','2019-07-31')).mean('time').plot(vmin=-200, vmax=200, cmap='RdBu_r')
plt.title('Surface Heat Flux Averaged 2019-07-26 to 31')

plt.tight_layout()<jupyter_output><empty_output><jupyter_text>Freshwater Fluxes<jupyter_code>surf_fw_flux = ds.tp + ds.e
ds.e.sel(latitude=-52, longitude=35, method='nearest').isel(time=slice(0,48)).plot(label='Evaporation')
ds.tp.sel(latitude=-52, longitude=35, method='nearest').isel(time=slice(0,48)).plot(label='Precipitation')
surf_fw_flux.sel(latitude=-52, longitude=35, method='nearest').isel(time=slice(0,48)).plot(label='Total Fresh Water')
plt.legend()
plt.grid()
surf_fw_flux_mean = (surf_fw_flux).rolling(time=24, center=True).mean()
(surf_fw_flux/3600).sel(latitude=-52, longitude=35, method='nearest').plot(label='Hourly')
(surf_fw_flux_mean/3600).sel(latitude=-52, longitude=35, method='nearest').plot(label='Daily Mean')

plt.legend()

(surf_fw_flux_mean/3600 * 100*360*24*3600).sel(latitude=slice(-50,-52), longitude=slice(30,34)).sel(time=slice('2019-04-15','2019-08-15')
                                                                                   ).mean(['latitude','longitude']).plot(label='Daily Mean West', color='Green')
(surf_fw_flux_mean/3600 * 100*360*24*3600).sel(latitude=slice(-52,-54), longitude=slice(35,38)).sel(time=slice('2019-04-15','2019-08-15')
                                                                                   ).mean(['latitude','longitude']).plot(label='Daily Mean East', color='Purple')
plt.ylabel('Surface Fresh Water Flux ($cm/yr$)')
plt.legend()
plt.grid()


(surf_fw_flux_mean/3600 * 100*360*24*3600).sel(latitude=slice(-50,-52), longitude=slice(30,34)).sel(time=slice('2019-04-15','2019-08-15')
                                                                                   ).mean(['latitude','longitude']).plot.hist(label='Daily Mean West', color='Green')
(surf_fw_flux_mean/3600 * 100*360*24*3600).sel(latitude=slice(-52,-54), longitude=slice(35,38)).sel(time=slice('2019-04-15','2019-08-15')
                                                                                   ).mean(['latitude','longitude']).plot.hist(label='Daily Mean East', color='Purple')
plt.xlabel('Surface Fresh Water Flux ($cm/yr$)')
plt.legend()
plt.grid()

plt.figure(figsize=(12,4))
plt.subplot(121)
(surf_fw_flux_mean/3600 * 100*360*24*3600).sel(time=slice('2019-05-01','2019-05-05')).mean('time').plot(vmin=-200, vmax=200, cmap='RdBu_r')
plt.title('Surface FW Flux Averaged 2019-05-01 to 05')

plt.subplot(122)
(surf_fw_flux_mean/3600 * 100*360*24*3600).sel(time=slice('2019-07-26','2019-07-31')).mean('time').plot(vmin=-200, vmax=200, cmap='RdBu_r')
plt.title('Surface FW Flux Averaged 2019-07-26 to 31')

plt.tight_layout()<jupyter_output><empty_output><jupyter_text>Wind Stress<jupyter_code>wind_speed = (ds.u10**2 + ds.v10**2)**0.5
wind_speed_mean = (wind_speed).rolling(time=24, center=True).mean()
wind_speed.sel(latitude=-52, longitude=35, method='nearest').plot(label='Hourly')
wind_speed_mean.sel(latitude=-52, longitude=35, method='nearest').plot(label='Daily Mean')

plt.legend()

wind_speed.sel(latitude=slice(-50,-52), longitude=slice(30,34)).sel(time=slice('2019-04-15','2019-08-15')
                                                                                   ).mean(['latitude','longitude']).plot(label='Daily Mean West', color='Green')
wind_speed.sel(latitude=slice(-52,-54), longitude=slice(35,38)).sel(time=slice('2019-04-15','2019-08-15')
                                                                                   ).mean(['latitude','longitude']).plot(label='Daily Mean East', color='Purple')
plt.ylabel('Wind Speed ($m/s$)')
plt.legend()
plt.grid()


wind_speed.sel(latitude=slice(-50,-52), longitude=slice(30,34)).sel(time=slice('2019-04-15','2019-08-15')
                                                                                   ).mean(['latitude','longitude']).plot.hist(label='Daily Mean West', color='Green')
wind_speed.sel(latitude=slice(-52,-54), longitude=slice(35,38)).sel(time=slice('2019-04-15','2019-08-15')
                                                                                   ).mean(['latitude','longitude']).plot.hist(label='Daily Mean East', color='Purple')
plt.xlabel('Wind Speed ($m/s$)')
plt.legend()
plt.grid()

plt.figure(figsize=(12,4))
plt.subplot(121)
wind_speed.sel(time=slice('2019-05-01','2019-05-01')).mean('time').plot(vmin=5, vmax=15, cmap='Reds')
plt.title('Surface FW Flux Averaged 2019-05-01 to 05')

plt.subplot(122)
wind_speed.sel(time=slice('2019-07-31','2019-07-31')).mean('time').plot(vmin=5, vmax=15, cmap='Reds')
plt.title('Surface FW Flux Averaged 2019-07-26 to 31')

plt.tight_layout()
plt.figure(figsize=(12,4))
plt.subplot(121)
ds.u10.sel(time=slice('2019-05-01','2019-05-01')).mean('time').plot(vmin=-15, vmax=15, cmap='RdBu_r')
plt.title('Surface FW Flux Averaged 2019-05-01 to 05')

plt.subplot(122)
ds.u10.sel(time=slice('2019-07-31','2019-07-31')).mean('time').plot(vmin=-15, vmax=15, cmap='RdBu_r')
plt.title('Surface FW Flux Averaged 2019-07-26 to 31')

plt.tight_layout()
plt.figure(figsize=(12,4))
plt.subplot(121)
ds.v10.sel(time=slice('2019-05-01','2019-05-01')).mean('time').plot(vmin=-15, vmax=15, cmap='RdBu_r')
plt.title('Surface FW Flux Averaged 2019-05-01 to 05')

plt.subplot(122)
ds.v10.sel(time=slice('2019-07-31','2019-07-31')).mean('time').plot(vmin=-15, vmax=15, cmap='RdBu_r')
plt.title('Surface FW Flux Averaged 2019-07-26 to 31')

plt.tight_layout()
(ds.sst-273.15).isel(time=0).plot.contourf()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20075251850952786, 'fraction_numerical': 0.10765869644374318, 'mean_word_length': 3.671201814058957, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '655076', 'license': 'MIT', 'n_tokens_mistral': 3577, 'n_tokens_neox': 2867, 'n_words': 343, 'path': 'notebooks/sogos_descriptive_paper/0.0_db_explore_surface_fluxes.ipynb', 'repo_name': 'dhruvbalwada/sogos', 'size': '8239'}