def test_T_1_auto_get_scale_factor_to(): domcfg_fr = open_domcfg_fr() nemo_ds = xr.open_dataset("data/xnemogcm.nemo.nc") nemo_ds.load() domcfg_to = open_domcfg_to() grid_fr = xgcm.Grid(domcfg_fr, periodic=False) grid_to = xgcm.Grid(domcfg_to, periodic=False, metrics=_metrics) v_fr = (nemo_ds["thetao"] * 0 + 1) * domcfg_fr.tmask v_to = remap_vertical( v_fr, grid_fr, grid_to, axis="Z", scale_factor_fr=domcfg_fr.e3t_0 ) _assert_same_integrated_value( v_fr, v_to, e3_fr=domcfg_fr.e3t_0, e3_to=domcfg_to.e3t_0 )
def test_T_0_same_fr_and_to(): domcfg_fr = open_domcfg_fr() nemo_ds = xr.open_dataset("data/xnemogcm.nemo.nc") nemo_ds.load() domcfg_to = domcfg_fr grid_fr = xgcm.Grid(domcfg_fr, periodic=False) grid_to = xgcm.Grid(domcfg_to, periodic=False) v_fr = nemo_ds["thetao"] * 0 * domcfg_fr.tmask v_to = remap_vertical( v_fr, grid_fr, grid_to, axis="Z", scale_factor_fr=domcfg_fr.e3t_0, scale_factor_to=domcfg_to.e3t_0, ) _assert_same_domcfg(v_fr, v_to)
def test_W_0_same_fr_and_to(): domcfg_fr = open_domcfg_fr() nemo_ds = xr.open_dataset("data/xnemogcm.nemo.nc") nemo_ds.load() domcfg_to = domcfg_fr grid_fr = xgcm.Grid(domcfg_fr, periodic=False) grid_to = xgcm.Grid(domcfg_to, periodic=False) v_fr = nemo_ds["woce"] * 0 try: v_to = remap_vertical( v_fr, grid_fr, grid_to, axis="Z", scale_factor_fr=domcfg_fr.e3t_0, scale_factor_to=domcfg_to.e3t_0, ) except NotImplementedError: return 0 _assert_same_domcfg(v_fr, v_to)
def test_U(): domcfg_fr = open_domcfg_fr() nemo_ds = xr.open_dataset("data/xnemogcm.nemo.nc") nemo_ds.load() domcfg_to = open_domcfg_to() grid_fr = xgcm.Grid(domcfg_fr, periodic=False) grid_to = xgcm.Grid(domcfg_to, periodic=False) v_fr = nemo_ds["uo"] v_to = remap_vertical( v_fr, grid_fr, grid_to, axis="Z", scale_factor_fr=domcfg_fr.e3u_0, scale_factor_to=domcfg_to.e3u_0, z_fr=grid_fr.interp(domcfg_fr.gdepw_0, "X", boundary="extend"), z_to=domcfg_to.gdepw_0.isel({"x_c": 1, "y_c": 1}).drop_vars(["x_c", "y_c"]), ) _assert_same_integrated_value( v_fr, v_to, e3_fr=domcfg_fr.e3u_0, e3_to=domcfg_to.e3u_0 )