Coverage for src/CSET/loaders/transects.py: 44%
10 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-05 21:08 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-05 21:08 +0000
1# © Crown copyright, Met Office (2022-2025) and CSET contributors.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
15"""Load transect recipes."""
17import itertools
19from CSET.recipes import Config, RawRecipe, get_models
22def load(conf: Config):
23 """Yield recipes from the given workflow configuration."""
24 # Load a list of model detail dictionaries.
25 models = get_models(conf.asdict())
27 # Pressure level fields.
28 if conf.EXTRACT_PLEVEL_TRANSECT: 28 ↛ 29line 28 didn't jump to line 29 because the condition on line 28 was never true
29 for model, field in itertools.product(
30 models,
31 conf.PRESSURE_LEVEL_FIELDS,
32 ):
33 yield RawRecipe(
34 recipe="transect.yaml",
35 variables={
36 "VARNAME": field,
37 "VERTICAL_COORDINATE": "pressure",
38 "MODEL_NAME": model["name"],
39 "START_COORDS": conf.PLEVEL_TRANSECT_STARTCOORDS,
40 "FINISH_COORDS": conf.PLEVEL_TRANSECT_FINISHCOORDS,
41 "SUBAREA_TYPE": conf.SUBAREA_TYPE if conf.SELECT_SUBAREA else None,
42 "SUBAREA_EXTENT": conf.SUBAREA_EXTENT
43 if conf.SELECT_SUBAREA
44 else None,
45 },
46 model_ids=model["id"],
47 aggregation=False,
48 )
50 # Model level fields
51 if conf.EXTRACT_MLEVEL_TRANSECT: 51 ↛ 52line 51 didn't jump to line 52 because the condition on line 51 was never true
52 for model, field in itertools.product(
53 models,
54 conf.MODEL_LEVEL_FIELDS,
55 ):
56 yield RawRecipe(
57 recipe="transect.yaml",
58 variables={
59 "VARNAME": field,
60 "VERTICAL_COORDINATE": "model_level_number",
61 "MODEL_NAME": model["name"],
62 "START_COORDS": conf.MLEVEL_TRANSECT_STARTCOORDS,
63 "FINISH_COORDS": conf.MLEVEL_TRANSECT_FINISHCOORDS,
64 "SUBAREA_TYPE": conf.SUBAREA_TYPE if conf.SELECT_SUBAREA else None,
65 "SUBAREA_EXTENT": conf.SUBAREA_EXTENT
66 if conf.SELECT_SUBAREA
67 else None,
68 },
69 model_ids=model["id"],
70 aggregation=False,
71 )