diff --git a/examples/replay/config-0.25-degree.yaml b/examples/replay/config-0.25-degree.yaml index a46faeb..f0eabfc 100644 --- a/examples/replay/config-0.25-degree.yaml +++ b/examples/replay/config-0.25-degree.yaml @@ -222,12 +222,12 @@ MOM6Dataset: cycles: start: "1994-01-01T00" - end: "1999-06-13T06" + end: "2023-12-31T06" freq: "6h" time: - start: "1993-12-31T18" - end: "1999-06-13T03" + start: "1994-01-01T00" + end: "2023-12-31T06" freq: "3h" chunks_in: @@ -284,5 +284,6 @@ MOM6Dataset: weights_file_u2t: weights_file_v2t: periodic: True + interp_method: "conservative" gaussian_grid: "gcs://noaa-ufs-gefsv13replay/ufs-hr1/0.25-degree/03h-freq/zarr/fv3.zarr" diff --git a/examples/replay/config-1.00-degree.yaml b/examples/replay/config-1.00-degree.yaml index 64cb5a8..12ab289 100644 --- a/examples/replay/config-1.00-degree.yaml +++ b/examples/replay/config-1.00-degree.yaml @@ -229,12 +229,12 @@ MOM6Dataset: cycles: start: "1994-01-01T00" - end: "1999-06-13T06" + end: "1999-06-14T00" freq: "6h" time: - start: "1993-12-31T18" - end: "1999-06-13T03" + start: "1994-01-01T00" + end: "1999-06-14T00" freq: "6h" chunks_in: @@ -291,5 +291,6 @@ MOM6Dataset: weights_file_u2t: weights_file_v2t: periodic: True + interp_method: "conservative" gaussian_grid: "gcs://noaa-ufs-gefsv13replay/ufs-hr1/1.00-degree/03h-freq/zarr/fv3.zarr" diff --git a/examples/replay/mom6_grid_0.25_degree.nc b/examples/replay/mom6_grid_0.25_degree.nc deleted file mode 100644 index ac8aee9..0000000 Binary files a/examples/replay/mom6_grid_0.25_degree.nc and /dev/null differ diff --git a/examples/replay/mom6_grid_1.00_degree.nc b/examples/replay/mom6_grid_1.00_degree.nc deleted file mode 100644 index d2f913d..0000000 Binary files a/examples/replay/mom6_grid_1.00_degree.nc and /dev/null differ diff --git a/examples/replay/replay_mover.py b/examples/replay/replay_mover.py index 7958b6f..3fd7c87 100644 --- a/examples/replay/replay_mover.py +++ b/examples/replay/replay_mover.py @@ -12,7 +12,14 @@ import dask.array as darray from zarr import NestedDirectoryStore -from ufs2arco import FV3Dataset, MOM6Dataset, CICE6Dataset, Timer, MOM6Regridder +from ufs2arco import ( + FV3Dataset, + MOM6Dataset, + CICE6Dataset, + Timer, + MOM6Regridder, + CICE6Regridder +) class ReplayMover1Degree(): @@ -110,15 +117,20 @@ def __init__( self.cycles = pd.date_range(**config[name]["cycles"]) self.time = pd.date_range(**config[name]["time"]) + self.Regridder = None if component.lower() == "fv3": self.Dataset = FV3Dataset self.cached_path = self.fv3_path + if "regrid" in self.config.keys(): + raise NotImplementedError elif component.lower() == "mom6": self.Dataset = MOM6Dataset self.cached_path = self.mom6_path + self.Regridder = MOM6Regridder elif component.lower() == "cice6": self.Dataset = CICE6Dataset self.cached_path = self.cice6_path + self.Regridder = CICE6Regridder # for move_single_dataset, we have to figure out how many resulting timestamps we have # within a single DA cycle @@ -175,7 +187,7 @@ def regrid_to_gaussian( ) lons = gaussian_grid['grid_xt'].values lats = gaussian_grid['grid_yt'].values - rg = MOM6Regridder( + rg = self.Regridder( lats1d_out=lats, lons1d_out=lons, ds_in=xds, diff --git a/ufs2arco/regrid/cice6regridder.py b/ufs2arco/regrid/cice6regridder.py index d38a537..b7dbe0d 100644 --- a/ufs2arco/regrid/cice6regridder.py +++ b/ufs2arco/regrid/cice6regridder.py @@ -35,10 +35,9 @@ def __init__( lons1d_out: np.array, ds_in: xr.Dataset, config_filename: str, - interp_method: str = "bilinear", ) -> None: super(CICE6Regridder, self).__init__( - lats1d_out, lons1d_out, ds_in, config_filename, interp_method + lats1d_out, lons1d_out, ds_in, config_filename ) def _create_regridder(self, ds_in: xr.Dataset) -> None: @@ -85,9 +84,10 @@ def _create_regridder(self, ds_in: xr.Dataset) -> None: # paths to interpolation weights files wfiles = dict() + interp_method = self.config["interp_method"] for key in ["weights_file_t2t", "weights_file_u2t"]: vin = key[-3] - default = f"weights-cice6-{self.ires}.C{vin}.{self.ores}.Ct.{self.interp_method}.nc" + default = f"weights-cice6-{self.ires}.C{vin}.{self.ores}.Ct.{interp_method}.nc" path = self.config.get(key, None) wfiles[key] = path if path is not None else default @@ -97,7 +97,7 @@ def _create_regridder(self, ds_in: xr.Dataset) -> None: self.rg_tt = xe.Regridder( ds_in_t, grid_out, - self.interp_method, + interp_method, periodic=periodic, reuse_weights=reuse, filename=wfiles["weights_file_t2t"], @@ -107,7 +107,7 @@ def _create_regridder(self, ds_in: xr.Dataset) -> None: self.rg_ut = xe.Regridder( ds_in_u, ds_in_t, - self.interp_method, + interp_method, periodic=periodic, reuse_weights=reuse, filename=wfiles["weights_file_u2t"], diff --git a/ufs2arco/regrid/mom6regridder.py b/ufs2arco/regrid/mom6regridder.py index f93e657..1b0c53b 100644 --- a/ufs2arco/regrid/mom6regridder.py +++ b/ufs2arco/regrid/mom6regridder.py @@ -38,10 +38,9 @@ def __init__( lons1d_out: np.array, ds_in: xr.Dataset, config_filename: str, - interp_method: str = "conservative", ) -> None: super(MOM6Regridder, self).__init__( - lats1d_out, lons1d_out, ds_in, config_filename, interp_method + lats1d_out, lons1d_out, ds_in, config_filename ) def create_grid_in( @@ -165,10 +164,11 @@ def _create_regridder(self, ds_in: xr.Dataset) -> None: self.ores = f"{nlon_o}x{nlat_o}" # paths to interpolation weights files + interp_method = self.config["interp_method"] wfiles = dict() for key in ["weights_file_t2t", "weights_file_u2t", "weights_file_v2t"]: vin = key[-3] - default = f"weights-mom6-{self.ires}.C{vin}.{self.ores}.Ct.{self.interp_method}.nc" + default = f"weights-mom6-{self.ires}.C{vin}.{self.ores}.Ct.{interp_method}.nc" path = self.config.get(key, None) wfiles[key] = path if path is not None else default @@ -178,7 +178,7 @@ def _create_regridder(self, ds_in: xr.Dataset) -> None: self.rg_tt = xe.Regridder( ds_in_t, grid_out, - self.interp_method, + interp_method, periodic=periodic, reuse_weights=reuse, filename=wfiles["weights_file_t2t"], @@ -189,7 +189,7 @@ def _create_regridder(self, ds_in: xr.Dataset) -> None: self.rg_ut = xe.Regridder( ds_in_u, ds_in_t, - self.interp_method, + interp_method, periodic=periodic, reuse_weights=reuse, filename=wfiles["weights_file_u2t"], @@ -199,7 +199,7 @@ def _create_regridder(self, ds_in: xr.Dataset) -> None: self.rg_vt = xe.Regridder( ds_in_v, ds_in_t, - self.interp_method, + interp_method, periodic=periodic, reuse_weights=reuse, filename=wfiles["weights_file_v2t"], diff --git a/ufs2arco/regrid/ufsregridder.py b/ufs2arco/regrid/ufsregridder.py index 0fb3a39..045ddc9 100644 --- a/ufs2arco/regrid/ufsregridder.py +++ b/ufs2arco/regrid/ufsregridder.py @@ -54,7 +54,6 @@ def __init__( lons1d_out: np.array, ds_in: xr.Dataset, config_filename: str, - interp_method: str = "conservative", ) -> None: """ Initialize the UFSRegridder object. @@ -80,7 +79,7 @@ def __init__( # specify an output resolution self.lats1d_out = lats1d_out self.lons1d_out = lons1d_out - self.interp_method = interp_method + self.interp_method = self.config["interp_method"] # create regridder self._create_regridder(ds_in)