ICON Community Interface 0.4.0
Loading...
Searching...
No Matches
variables.py
Go to the documentation of this file.
1# @authors 11/2023 :: ICON Community Interface <comin@icon-model.org>
2#
3# SPDX-License-Identifier: BSD-3-Clause
4#
5# Please see the file LICENSE in the root of the source tree for this code.
6# Where software is supplied by third parties, it is indicated in the
7# headers of the routines.
8
9import comin
10
12
13comin.var_request_add(("test", 1), False)
15 ("test", 1),
16 tracer=False,
17 tracer_turb=False,
18 units="%",
19 hgrid_id=comin.COMIN_HGRID_UNSTRUCTURED_CELL,
20)
21comin.metadata_set(("test", 1), custom_metadata=42)
22
23
24@comin.register_callback(comin.EP_SECONDARY_CONSTRUCTOR)
26 global test
27 test = comin.var_get(
28 [comin.EP_ATM_WRITE_OUTPUT_BEFORE], ("test", 1), comin.COMIN_FLAG_READ
29 )
30
31 # tests break in iteration of the var list
32 print(f"{('pres', 1) in comin.var_descr_list()=}")
33
34 # print all variables
35 for var_name, var_id in comin.var_descr_list():
36 metadata = comin.metadata((var_name, var_id))
37 print(
38 f"{var_name=}, {var_id=}, tracer={metadata.get('tracer', None)} units={metadata.get('units', None)}"
39 )
40
41 # use the metadata as a dictionary:
42 print(comin.metadata(("test", 1))["custom_metadata"])
43
44 for key, data in comin.metadata(("test", 1)).items():
45 print(f"{key}: {data}")
46
47
48@comin.register_callback(comin.EP_ATM_WRITE_OUTPUT_BEFORE)
50 print(f"{test.descriptor=}")
51 print(f"{test.to_3d.shape=}")
52 test_lvl4 = test.to_xarray().isel(level=4)
53 print(f"{test_lvl4.dims=}")
var_get(context, var_descriptor, flag)
get variable object, arguments: [entry point], (name string, domain id), access flag)
Definition comin.py:107
metadata_set(var_descriptor, **kwargs)
sets metadata for a requested field, arguments: name string, domain id, metadata key,...
Definition comin.py:189
current_get_plugin_info()
returns object describing the current plugin
Definition comin.py:146
var_descr_list()
List of exposed variables (descriptors)
Definition comin.py:177
output_before()
Definition variables.py:49
secondary_constructor()
Definition variables.py:25