-
Notifications
You must be signed in to change notification settings - Fork 10
fix wrong graupel tuning parameter config in data test #1075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
a108dc1
4ba05e2
ad39c68
e01367c
c8f0021
0f13ca0
200ac17
f24fb9b
de5ef7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,30 +38,27 @@ | |
| @pytest.mark.embedded_static_args | ||
| @pytest.mark.datatest | ||
| @pytest.mark.parametrize( | ||
| "experiment, model_top_height", | ||
| "experiment", | ||
| [ | ||
| (definitions.Experiments.WEISMAN_KLEMP_TORUS, 30000.0), | ||
| definitions.Experiments.WEISMAN_KLEMP_TORUS, | ||
| ], | ||
| ) | ||
|
||
| @pytest.mark.parametrize( | ||
| "date", ["2008-09-01T01:59:48.000", "2008-09-01T01:59:52.000", "2008-09-01T01:59:56.000"] | ||
| ) | ||
| def test_graupel( | ||
| experiment: definitions.Experiments, | ||
| model_top_height: ta.wpfloat, | ||
| date: str, | ||
| *, | ||
| data_provider: sb.IconSerialDataProvider, | ||
| grid_savepoint: sb.IconGridSavepoint, | ||
| metrics_savepoint: sb.MetricSavepoint, | ||
| icon_grid: icon_grid.IconGrid, | ||
| lowest_layer_thickness: ta.wpfloat, | ||
| model_top_height: ta.wpfloat, | ||
| backend: gtx_typing.Backend, | ||
| ): | ||
| pytest.xfail("Tolerances have increased with new ser_data, need to check with @ongchia") | ||
| vertical_config = v_grid.VerticalGridConfig( | ||
| icon_grid.num_levels, | ||
| lowest_layer_thickness=lowest_layer_thickness, | ||
| model_top_height=model_top_height, | ||
| ) | ||
| vertical_params = v_grid.VerticalGrid( | ||
|
|
@@ -103,16 +100,7 @@ def test_graupel( | |
| v=None, | ||
| ) | ||
|
|
||
| graupel_config = graupel.SingleMomentSixClassIconGraupelConfig( | ||
| liquid_autoconversion_option=mphys_options.LiquidAutoConversionType.SEIFERT_BEHENG, | ||
| ice_stickeff_min=0.01, | ||
| power_law_coeff_for_ice_mean_fall_speed=1.25, | ||
| exponent_for_density_factor_in_ice_sedimentation=0.3, | ||
| power_law_coeff_for_snow_fall_speed=20.0, | ||
| rain_mu=0.0, | ||
| rain_n0=1.0, | ||
| snow2graupel_riming_coeff=0.5, | ||
| ) | ||
| graupel_config = definitions.construct_gscp_graupel_config(experiment) | ||
|
|
||
| graupel_microphysics = graupel.SingleMomentSixClassIconGraupel( | ||
| graupel_config=graupel_config, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # ICON4Py - ICON inspired code in Python and GT4Py | ||
| # | ||
| # Copyright (c) 2022-2024, ETH Zurich and MeteoSwiss | ||
| # All rights reserved. | ||
| # | ||
| # Please, refer to the LICENSE file in the root directory. | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
| import ast | ||
| import pathlib | ||
| import re | ||
|
|
||
|
|
||
| def read_namelist(path: pathlib.Path) -> dict: | ||
| """ICON NAMELIST_ICON_output_atm reader. | ||
| Returns a dictionary of dictionaries, where the keys are the namelist names | ||
| and the values are dictionaries of key-value pairs from the namelist. | ||
|
|
||
| Use as: | ||
| namelists = read_namelist("/path/to/NAMELIST_ICON_output_atm") | ||
| print(namelists["NWP_TUNING_NML"]["TUNE_ZCEFF_MIN"]) | ||
| """ | ||
| with path.open() as f: | ||
| txt = f.read() | ||
| blocks = re.findall(r"&(\w+)(.*?)\/", txt, re.S) | ||
| out = {} | ||
| for name, body in blocks: | ||
| d = {} | ||
| body_content = re.sub(r"!.*", "", body) # remove comments | ||
| for line in body_content.split(","): | ||
| if "=" in line: | ||
| k, v = line.split("=", 1) | ||
| v = v.replace("T", "True").replace("F", "False") | ||
| try: | ||
| v = ast.literal_eval(v.strip()) | ||
| except Exception: | ||
| v = v.strip().strip("'") | ||
| d[k.strip()] = v | ||
| out[name] = d | ||
| return out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@havogt is this correct? otherwise, mypy complained about wrong type