|
| 1 | +# ICON4Py - ICON inspired code in Python and GT4Py |
| 2 | +# |
| 3 | +# Copyright (c) 2022-2024, ETH Zurich and MeteoSwiss |
| 4 | +# All rights reserved. |
| 5 | +# |
| 6 | +# Please, refer to the LICENSE file in the root directory. |
| 7 | +# SPDX-License-Identifier: BSD-3-Clause |
| 8 | + |
| 9 | +import dataclasses |
| 10 | +import enum |
| 11 | +import os |
| 12 | +import pathlib |
| 13 | +from collections.abc import Mapping |
| 14 | +from typing import Final, Literal |
| 15 | + |
| 16 | + |
| 17 | +_TEST_UTILS_PATH: Final = pathlib.Path(__file__) / ".." |
| 18 | +_MODEL_PATH: Final = _TEST_UTILS_PATH / ".." |
| 19 | +_COMMON_PATH: Final = _MODEL_PATH / ".." / ".." / ".." / ".." |
| 20 | + |
| 21 | +DEFAULT_TEST_DATA_FOLDER: Final = "testdata" |
| 22 | +TEST_DATA_PATH: Final[pathlib.Path] = pathlib.Path( |
| 23 | + os.getenv("TEST_DATA_PATH") or (_COMMON_PATH / ".." / DEFAULT_TEST_DATA_FOLDER) |
| 24 | +) |
| 25 | +GRIDS_PATH: Final[pathlib.Path] = TEST_DATA_PATH / "grids" |
| 26 | +SERIALIZED_DATA_PATH: Final[pathlib.Path] = TEST_DATA_PATH / "ser_icondata" |
| 27 | + |
| 28 | + |
| 29 | +class GridKind(enum.Enum): |
| 30 | + REGIONAL = "REGIONAL" |
| 31 | + GLOBAL = "GLOBAL" |
| 32 | + TORUS = "TORUS" |
| 33 | + |
| 34 | + |
| 35 | +@dataclasses.dataclass |
| 36 | +class Grid: |
| 37 | + name: str |
| 38 | + description: str |
| 39 | + kind: GridKind |
| 40 | + sizes: Mapping[Literal["cell", "edge", "vertex"], int] |
| 41 | + file_name: str | None = None |
| 42 | + |
| 43 | + |
| 44 | +class Grids: |
| 45 | + SIMPLE: Final = Grid( |
| 46 | + name="<simple-grid>", |
| 47 | + description="Torus grid, fully defined in code (simple.py) used for testing ", |
| 48 | + sizes={"cell": 18, "vertex": 9, "edge": 27}, |
| 49 | + kind=GridKind.TORUS, |
| 50 | + file_name=None, |
| 51 | + ) |
| 52 | + R02B04_GLOBAL: Final = Grid( |
| 53 | + name="R02B04_GLOBAL_GRID_URI", |
| 54 | + description="R02B04, small global grid, default grid used in ICON testing", |
| 55 | + sizes={"cell": 20480, "vertex": 10242, "edge": 30720}, |
| 56 | + kind=GridKind.GLOBAL, |
| 57 | + file_name="icon_grid_0013_R02B04_R.nc", |
| 58 | + ) |
| 59 | + |
| 60 | + R02B07_GLOBAL: Final = Grid( |
| 61 | + name="R02B07_GLOBAL_GRID_URI", |
| 62 | + description="R02b07, large global grid", |
| 63 | + sizes={"cell": 1310720, "vertex": 655362, "edge": 1966080}, |
| 64 | + kind=GridKind.GLOBAL, |
| 65 | + file_name="icon_grid_0023_R02B07_G.nc", |
| 66 | + ) |
| 67 | + R19_B07_MCH_LOCAL: Final = Grid( |
| 68 | + name="R19_B07_MCH_2KM", |
| 69 | + description="Grid used in the icon-ch2 (2km resolution) operational setup of MeteoSwiss", |
| 70 | + sizes={"cell": 283876, "vertex": 142724, "edge": 426599}, |
| 71 | + kind=GridKind.REGIONAL, |
| 72 | + file_name="icon_grid_0002_R19B07_mch.nc", |
| 73 | + ) |
| 74 | + MCH_OPR_R04B07_DOMAIN01: Final = Grid( |
| 75 | + name="R04B07_DOMAIN01", |
| 76 | + description="Grid used in the icon-ch2_small experiment (used by MeteoSwiss for quick verification of icon-ch2 setup) )", |
| 77 | + sizes={"cell": 10700, "vertex": 5510, "edge": 16209}, |
| 78 | + kind=GridKind.REGIONAL, |
| 79 | + file_name="mch_opr_r4b7_DOM01.nc", |
| 80 | + ) |
| 81 | + MC_CH_R04B09_DSL: Final = Grid( |
| 82 | + name="MC_CH_R04B09_DSL", |
| 83 | + description="grid used in the mch_ch_r04b09_dsl experiment used for verification of ICON-exclaim DSL port", |
| 84 | + sizes={"cell": 20896, "vertex": 10663, "edge": 31558}, |
| 85 | + kind=GridKind.REGIONAL, |
| 86 | + file_name="grid.nc", |
| 87 | + ) |
| 88 | + TORUS_100X116_1000M: Final = Grid( |
| 89 | + name="TORUS_100X116_1000M_GRID_URI", |
| 90 | + description="Torus grid with a domain length of 100000m and resolution (edge length) of 1000m ", |
| 91 | + sizes={"cell": 23200, "vertex": 11600, "edge": 34800}, |
| 92 | + kind=GridKind.TORUS, |
| 93 | + file_name=" Torus_Triangles_100x116_1000m.nc", |
| 94 | + ) |
| 95 | + TORUS_50000x5000: Final = Grid( |
| 96 | + name="TORUS_50000x5000_RES500", |
| 97 | + description="Torus grid with a domain length 50000m of resolution of 557m", |
| 98 | + sizes={"cell": 1056, "vertex": 52, "edge": 1584}, |
| 99 | + kind=GridKind.TORUS, |
| 100 | + file_name="Torus_Triangles_50000m_x_5000m_res500m.nc", |
| 101 | + ) |
| 102 | + |
| 103 | + |
| 104 | +@dataclasses.dataclass |
| 105 | +class Experiment: |
| 106 | + name: str |
| 107 | + description: str |
| 108 | + grid: Grid |
| 109 | + num_levels: int |
| 110 | + partitioned_data: Mapping[int, str] | None = None |
| 111 | + |
| 112 | + |
| 113 | +class Experiments: |
| 114 | + GLOBAL: Final = Experiment( |
| 115 | + name="exclaim_ape_R02B04", description="", grid=Grids.R02B04_GLOBAL, num_levels=60 |
| 116 | + ) |
| 117 | + REGIONAL: Final = Experiment( |
| 118 | + name="mch_ch_r04b09_dsl", |
| 119 | + description="Regional setup used by EXCLAIM to validate the icon-exclaim.", |
| 120 | + grid=Grids.MC_CH_R04B09_DSL, |
| 121 | + ) |
| 122 | + JABW: Final = Experiment( |
| 123 | + name="jabw_R02B04", |
| 124 | + description="Jablonowski Williamson atmospheric test case", |
| 125 | + grid=Grids.R02B04_GLOBAL, |
| 126 | + ) |
| 127 | + GAUSS3D: Final = Experiment( |
| 128 | + name="gauss3d_torus", description="Gauss 3d test case", grid=Grids.TORUS_50000x5000 |
| 129 | + ) |
| 130 | + WEISMAN_KLEMP: Final = Experiment( |
| 131 | + name="weisman_klemp_torus", |
| 132 | + description="Weisman-Klemp experiment on Torus Grid", |
| 133 | + grid=Grids.TORUS_50000x5000, |
| 134 | + ) |
| 135 | + |
| 136 | + |
| 137 | +# GRID_DATA_URIS: Final[Mapping[GridName, Mapping[int, str]]] = { |
| 138 | +# GridName.MC_CH_R04B09_DSL: {1: "https://polybox.ethz.ch/index.php/s/hD232znfEPBh4Oh/download"}, |
| 139 | +# GridName.R02B04_GLOBAL: {1: "https://polybox.ethz.ch/index.php/s/AKAO6ImQdIatnkB/download"}, |
| 140 | +# GridName.TORUS_100X116_1000M: {1: "https://polybox.ethz.ch/index.php/s/yqvotFss9i1OKzs/download"}, |
| 141 | +# GridName.TORUS_50000x5000: {1: "https://polybox.ethz.ch/index.php/s/eclzK00TM9nnLtE/download"}, |
| 142 | +# GridName.ICON: { |
| 143 | +# 1: "https://polybox.ethz.ch/index.php/s/f42nsmvgOoWZPzi/download", |
| 144 | +# 2: "https://polybox.ethz.ch/index.php/s/P6F6ZbzWHI881dZ/download", |
| 145 | +# 4: "https://polybox.ethz.ch/index.php/s/NfES3j9no15A0aX/download", |
| 146 | +# }, |
| 147 | +# GridName.GLOBAL: {1: "https://polybox.ethz.ch/index.php/s/2n2WpTgZFlTCTHu/download"}, |
| 148 | +# GridName.DATA_URIS_JABW: {1: "https://polybox.ethz.ch/index.php/s/5W3Z2K6pyo0egzo/download"}, |
| 149 | +# GridName.DATA_URIS_GAUSS3D: {1: "https://polybox.ethz.ch/index.php/s/ZuqDIREPVits9r0/download"}, |
| 150 | +# GridName.DATA_URIS_WK: {1: "https://polybox.ethz.ch/index.php/s/ByLnyii7MMRHJbK/download"}, |
| 151 | +# } |
| 152 | +# GRID_IDS = { |
| 153 | +# ExperimentName.GLOBAL: uuid.UUID("af122aca-1dd2-11b2-a7f8-c7bf6bc21eba"), |
| 154 | +# ExperimentName.REGIONAL: uuid.UUID("f2e06839-694a-cca1-a3d5-028e0ff326e0"), |
| 155 | +# ExperimentName.JABW: uuid.UUID("af122aca-1dd2-11b2-a7f8-c7bf6bc21eba"), |
| 156 | +# ExperimentName.GAUSS3D: uuid.UUID("80ae276e-ec54-11ee-bf58-e36354187f08"), |
| 157 | +# ExperimentName.WEISMAN_KLEMP: uuid.UUID("80ae276e-ec54-11ee-bf58-e36354187f08"), |
| 158 | +# } |
| 159 | + |
| 160 | +# MCH_CH_R04B09_LEVELS = 65 |
| 161 | +# GLOBAL_NUM_LEVELS = 60 |
| 162 | +# GLOBAL_GRIDFILE = "icon_grid_0013_R02B04_R.nc" |
| 163 | +# REGIONAL_GRIDFILE = "grid.nc" |
0 commit comments