-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Is your feature request related to a problem?
clisccp.py and clmodis.py has additional dimensions we need to handle during cmorization and formulas that we need to add to formulas.py.
- Link:
Describe the solution you'd like
- Extend
e3sm_to_cmip/e3sm_to_cmip/cmor_handlers/handler.py
Lines 443 to 504 in baaf12c
def _get_cmor_axis_ids_and_ips_id( self, ds: xr.Dataset, time_dim: str | None ) -> tuple[dict[str, int], int | None]: """Create the CMOR axes objects, which are set globally in the CMOR module. The CMOR ids for "time" and "lev" should be the starting elements of the axis ID map to align with how they are defined in CMOR tables. Otherwise, CMOR will need to reorder the dimensions and add the message below to the "history" attribute of a variable: "2023-11-02T21:06:00Z altered by CMOR: Reordered dimensions, original order: lat lon time.", which can produce unwanted side-effects with the structure/shape of the final array axes. Parameters ---------- ds : xr.Dataset The dataset containing axes information. time_dim : str | None An optional time dimension for the output CMIP variable (if set). Returns ------- tuple[dict[str, int], int | None] A tuple with the first element being a dictionary (value is the CMOR axis and key is the ID of the CMOR axis), and the second element being the CMOR zfactor ID for ips if the dataset and handler have hybrid sigma levels. Example: ({"time": 0, "lev": 1, "lat": 2, "lon": 3}, 4) """ axis_id_map: dict[str, int] = {} cmor_ips_id = None if time_dim is not None: units = ds[time_dim].attrs["units"] axis_id_map["time"] = cmor.axis(time_dim, units=units) if self.levels is not None: axis_id_map["lev"] = self._get_cmor_lev_axis_id(ds) # Datasets will always have a "lat" and "lon" dimension. axis_id_map["lat"] = cmor.axis( "latitude", units=ds["lat"].units, coord_vals=ds["lat"].values, cell_bounds=ds["lat_bnds"].values, ) axis_id_map["lon"] = cmor.axis( "longitude", units=ds["lon"].units, coord_vals=ds["lon"].values, cell_bounds=ds["lon_bnds"].values, ) if self._has_hybrid_sigma_levels(ds): self._set_cmor_zfactor_for_hybrid_levels(ds, axis_id_map) cmor_ips_id = self._set_and_get_cmor_zfactor_ips_id(axis_id_map) return axis_id_map, cmor_ips_id
Describe alternatives you've considered
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Projects
Status
To do