Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions cdds/cdds/common/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,7 @@ def retrieve_grid_objects(variable_name: str, mip_table_id: str, model: str) ->
plugin = PluginStore.instance().get_plugin()
grids_mapping = plugin.models_parameters(model).grids_mapping()

if "_" in variable_name:
variable_name = variable_name.split("_")[0]

grid_type, grid_name = grids_mapping.retrieve_mapping(variable_name, mip_table_id)

grid = None
if grid_type is not None and grid_name is not None:
grid = Grid(model, grid_type, grid_name)
Expand Down
58 changes: 49 additions & 9 deletions cdds/cdds/common/plugins/cmip7/cmip7_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,52 @@ def from_name(cls, name: str) -> 'GridLabel':
return grid_label
raise KeyError('Not supported grid labels for {}'.format(name))

NATIVE = 'native', 'g100', False
NATIVE_ZONAL = 'native-zonal', 'g100z', False
REGRIDDED = 'regridded', 'g100', False
GLOBAL_MEAN = 'global-mean', 'g100', False
UGRID = 'ugrid', 'g100', True
VGRID = 'vgrid', 'g100', True
UVGRID = 'uvgrid', 'g100', True
UVGRID_ZONAL = 'uvgrid-zonal', 'g100z', True
SITES = 'sites', 'g100', False
LATLON_NATIVE = 'latlon-native', 'g110', False
LATLON_UVGRID = 'latlon-uvgrid', 'g115', False
LATLON_UGRID = 'latlon-ugrid', 'g108', False
LATLON_VGRID = 'latlon-vgrid', 'g109', False

TRIPOLAR_NATIVE = 'tripolar-native', 'g126', False
TRIPOLAR_UGRID = 'tripolar-ugrid', 'g125', False
TRIPOLAR_VGRID = 'tripolar-vgrid', 'g124', False


class Cmip7GridLabelHH(GridLabel):
"""Represents grid labels. Each grid label consists of:
* the grid name, for example: 'native'
* the label, for example: 'gn'
* a flag to specify if label requires extra information
"""

def __init__(self, grid_name: str, label: str, extra_info: bool) -> None:
self.grid_name = grid_name
self.label = label
self.extra_info = extra_info

@classmethod
def from_name(cls, name: str) -> 'GridLabel':
"""Returns the corresponding GridLabel enum for the grid with the given name

Parameters
----------
name : str
Name of the grid

Returns
-------
GridLabel
Corresponding GridLabel enum
"""
for grid_label in Cmip7GridLabelHH:
if grid_label.grid_name == name.lower():
return grid_label
raise KeyError('Not supported grid labels for {}'.format(name))

LATLON_NATIVE = 'latlon-native', 'g137', False
LATLON_UVGRID = 'latlon-uvgrid', 'g138', False
LATLON_UGRID = 'latlon-ugrid', 'g139', False
LATLON_VGRID = 'latlon-vgrid', 'g140', False

TRIPOLAR_NATIVE = 'tripolar-native', 'g154', False
TRIPOLAR_UGRID = 'tripolar-ugrid', 'g155', False
TRIPOLAR_VGRID = 'tripolar-vgrid', 'g153', False
34 changes: 33 additions & 1 deletion cdds/cdds/common/plugins/cmip7/cmip7_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
import logging
import os

from typing import List
from typing import List, Type

from cdds.common.plugins.common import LoadResults
from cdds.common.plugins.base.base_models import BaseModelParameters, ModelId, BaseModelStore
from cdds.common.plugins.cmip7.cmip7_grid_mapping import CMIP7GridMapping
from cdds.common.plugins.cmip7.cmip7_grid import Cmip7GridLabel, Cmip7GridLabelHH
from cdds.common.plugins.grid import GridLabel


class Cmip7ModelId(ModelId):
Expand Down Expand Up @@ -71,6 +73,16 @@ def um_version(self) -> str:
"""
return '10.8'

def grid_labels(self) -> Type[GridLabel]:
"""Returns the grid labels related to CMIP7 models.

Returns
-------
Cmip7GridLabel
Grid labels
"""
return Cmip7GridLabel


class UKCM2_0_LL_Params(BaseModelParameters):
"""Class to store the parameters for the UKCM2.0 model."""
Expand Down Expand Up @@ -112,6 +124,16 @@ def um_version(self) -> str:
"""
return '10.8'

def grid_labels(self) -> Type[GridLabel]:
"""Returns the grid labels related to CMIP7 models.

Returns
-------
Cmip7GridLabel
Grid labels
"""
return Cmip7GridLabel


class UKCM2a_0_HH_Params(BaseModelParameters):
"""Class to store the parameters for the UKCM2a high res model."""
Expand Down Expand Up @@ -153,6 +175,16 @@ def um_version(self) -> str:
"""
return '10.8'

def grid_labels(self) -> Type[GridLabel]:
"""Returns the grid labels related to CMIP7 models.

Returns
-------
Cmip7GridLabel
Grid labels
"""
return Cmip7GridLabelHH


class Cmip7ModelsStore(BaseModelStore):
"""Singleton class to store for each model the corresponding parameters.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
[aerosol]
default = atmos native
default = atmos latlon-native

[atmos]
default = atmos native
default = atmos latlon-native

[atmosChem]
default = atmos native
default = atmos latlon-native

[land]
default = atmos native
default = atmos latlon-native

[landIce]
default = atmos native
default = atmos latlon-native

[ocean]
default = ocean native
default = ocean tripolar-native

[ocnBgchem]
default = ocean native
default = ocean tripolar-native

[seaIce]
default = ocean native
default = ocean tripolar-native
Loading