<jupyter_start><jupyter_text>Heat budget calculationClose the heat budget on the native grid<jupyter_code>import xarray as xr
%matplotlib inline
rootdir = '/archive/oar.gfdl.cmip6/ESM4/DECK/ESM4_piControl_D/gfdl.ncrc4-intel16-prod-openmp/pp/'
datadir = 'ocean_annual/av/annual_10yr/'
filename = 'ocean_annual.0941-0950.ann.nc'
ds = xr.open_dataset(rootdir+datadir+filename)<jupyter_output><empty_output><jupyter_text>Temperature  [degC]Potential temperature: `thetao` (x,y,z)  Surface heat fluxes[W m^-2]  Outgoing longwave: `rlntds` (x,y)  Incoming shortwave: `rsdo` (x,y,z)  Sensible: `hfsso` (x,y)  Latent: `hflso` (x,y)    Bottom boundary heat flux[W m^-2]  Geothermal: `hfgeou` (x,y,z)    Advective heat flux (by residual mean)[W m^-2]  Zonal flux: `T_adx` (x,y,z)  Meridional flux: `T_ady` (x,y,z)    Diffusive heat flux[W m^-2]  Zonal flux: `T_diffx` (x,y,z)  Meridional flux: `T_diffy` (x,y,z)  Heat flux due to parameterized mesoscale diffusion: `T_dfxy_cont_tendency` (x,y,z)   Temperature tendency due to parameterized mesoscale diffusion `T_dfxy_conc_tendency` (x,y,z) [degC s^-1]  Vertical remapTemperature tendency due to remap: `T_tendency_vert_remap` (x,y,z) [degC s^-1]Or as heat content: `Th_tendency_vert_remap` (x,y,z) [W m  Temperature tendency[degC s-1]   Tendency: `T_tendency` [x,y,z]<jupyter_code># Try to pull all of the terms together into one dataset
ds_budget = xr.merge([ds.thetao, ds.T_tendency, ds.rlntds, ds.rsdo, ds.hfsso, ds.hflso])
s = ds_budget.isel(zi=0)
s
hflx = s.rlntds+s.rsdo+s.hfsso+s.hflso
hflx.plot()
ds.hfrainds<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1405166981726528, 'fraction_numerical': 0.015122873345935728, 'mean_word_length': 6.057777777777778, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '194263', 'license': 'MIT', 'n_tokens_mistral': 715, 'n_tokens_neox': 692, 'n_words': 148, 'path': 'notebooks/archive/calc_budget_heat.ipynb', 'repo_name': 'gmacgilchrist/wmt_bgc', 'size': '1587'}