<jupyter_start><jupyter_text>Calculate the b-factor for hydrographic data<jupyter_code>%load_ext autoreload
%autoreload 2
import so_decadal_variability as so
import numpy as np
from xhistogram.xarray import histogram
import xarray as xr
from dask.diagnostics import ProgressBar
oceanname = 'iap'
timeslice = slice('1979','2018')
save=True

ds = so.process.loaddata_oceanonly(oceanname=oceanname,timeslice=timeslice,roll=False)
ds, xgrid = so.grid.get_xgcm(ds)
b = so.wmt.calc_bfactor(ds,xgrid)
b.name = 'b'

if save:
    with ProgressBar():
        so.process.save_ocean(b,oceanname)
b, abs_drd, abs_dgd = so.wmt._calc_bfactor(ds['ct'],ds['sa'],ds['rho'],ds['alpha'],ds['beta'],ds['gamman'],xgrid)
abs_drd.isel(depth=5).sel(time='2002-10-01').plot(vmax=2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1464968152866242, 'fraction_numerical': 0.024203821656050957, 'mean_word_length': 7.451612903225806, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '85819', 'license': 'MIT', 'n_tokens_mistral': 334, 'n_tokens_neox': 315, 'n_words': 53, 'path': 'notebooks/calc_bfactor_obs.ipynb', 'repo_name': 'gmacgilchrist/so_decadal_variability', 'size': '785'}