<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>