Skip to content

Commit a243ab5

Browse files
committed
[Refactor]: CDAT Migration - Update dependencies and remove Dataset._add_cf_attrs_to_z_axes() (#891)
1 parent 3a70cdf commit a243ab5

File tree

4 files changed

+26
-38
lines changed

4 files changed

+26
-38
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
from e3sm_diags.parameter.core_parameter import CoreParameter
3+
from e3sm_diags.run import runner
4+
5+
param = CoreParameter()
6+
7+
# param.reference_data_path = '/global/cfs/cdirs/e3sm/diagnostics/observations/Atm/climatology'
8+
# param.test_data_path = '/global/cfs/cdirs/e3sm/zhang40/e3sm_diags_for_EAMxx/data/Cess'
9+
param.reference_data_path = (
10+
"/global/cfs/cdirs/e3sm/diagnostics/observations/Atm/climatology"
11+
)
12+
param.test_data_path = "/global/cfs/cdirs/e3sm/chengzhu/eamxx/post/data/rgr"
13+
param.test_name = "eamxx_decadal"
14+
param.seasons = ["ANN"]
15+
# param.save_netcdf = True
16+
17+
prefix = "/global/cfs/cdirs/e3sm/www/cdat-migration-fy24"
18+
param.results_dir = os.path.join(prefix, "889-z-axis-bnds")
19+
20+
runner.sets_to_run = ["zonal_mean_2d"]
21+
22+
runner.run_diags([param])

conda-env/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ dependencies:
2424
- numpy >=2.0.0,<3.0.0
2525
- shapely >=2.0.0,<3.0.0
2626
- xarray >=2024.03.0
27-
- xcdat >=0.6.0
28-
- xesmf >=0.7.0
27+
- xcdat >=0.7.3,<1.0.0
28+
- xesmf >=0.8.7
2929
- xskillscore >=0.0.20
3030
# Testing
3131
# ==================

conda-env/dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ dependencies:
2222
- numpy >=2.0.0,<3.0.0
2323
- shapely >=2.0.0,<3.0.0
2424
- xarray >=2024.03.0
25-
- xcdat >=0.6.0
26-
- xesmf >=0.7.0
25+
- xcdat >=0.7.3,<1.0.0
26+
- xesmf >=0.8.7
2727
- xskillscore >=0.0.20
2828
# Testing
2929
# =======================

e3sm_diags/driver/utils/dataset_xr.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -419,11 +419,6 @@ def _get_climo_dataset(self, season: str) -> xr.Dataset:
419419
filepath = self._get_climo_filepath(season)
420420
ds = self._open_climo_dataset(filepath)
421421

422-
# Add CF attributes to Z axes if they are missing.
423-
# NOTE: This is a temporary workaround for xCDAT.
424-
# Refer to https://github.com/xCDAT/xcdat/pull/708
425-
ds = self._add_cf_attrs_to_z_axes(ds)
426-
427422
if self.var in self.derived_vars_map:
428423
ds = self._get_dataset_with_derived_climo_var(ds)
429424
elif self.var in ds.data_vars.keys():
@@ -439,35 +434,6 @@ def _get_climo_dataset(self, season: str) -> xr.Dataset:
439434

440435
return ds
441436

442-
def _add_cf_attrs_to_z_axes(self, ds: xr.Dataset) -> xr.Dataset:
443-
"""Add CF attributes to the Z axis of the dataset if the Z axis exists.
444-
445-
This method is a temporary solution to enable xCDAT to properly
446-
retrieve bounds for Z axes that do not have CF attributes, which
447-
is required for downstream regridding operations.
448-
449-
Parameters
450-
----------
451-
ds : xr.Dataset
452-
The dataset.
453-
454-
Returns
455-
-------
456-
xr.Dataset
457-
The dataset with CF attributes added to the Z axes.
458-
"""
459-
try:
460-
dim = xc.get_dim_keys(ds, axis="Z")
461-
except KeyError:
462-
pass
463-
else:
464-
axis_attr = ds[dim].attrs.get("axis")
465-
466-
if axis_attr is None:
467-
ds[dim].attrs["axis"] = "Z"
468-
469-
return ds
470-
471437
def _open_climo_dataset(self, filepath: str) -> xr.Dataset:
472438
"""Open a climatology dataset.
473439

0 commit comments

Comments
 (0)