Skip to content

Commit f77f75e

Browse files
Add function to generate rootpath entry for user config (#15)
* Add function to generate rootpath entry for user config * Update README.md Co-authored-by: Bouwe Andela <[email protected]> * Update readme * Specify that the data are stored using the DKRZ syntax Co-authored-by: Bouwe Andela <[email protected]>
1 parent 035c45b commit f77f75e

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The goal is to keep the repository size small (~ 100 MB), so it can be easily do
55

66
At present, the repository contains 44 monthly, and 35 daily timeseries datasets. The specifications can be found in [`datasets.yml`](esmvaltool_sample_data/datasets.yml).
77

8+
The data are stored using the data reference syntax structure from DKRZ.
9+
810
## Usage
911

1012
The functionality of this repository is kept simple.
@@ -27,13 +29,14 @@ If you want to use this dataset in your ESMValTool projects, add the following l
2729

2830
```yaml
2931
rootpath:
30-
CMIP6: <path_to_repository>/esmvaltool_sample_data/data/timeseries/
32+
CMIP6:
33+
- <path_to_repository>/esmvaltool_sample_data/data/timeseries/CMIP6
3134

3235
drs:
33-
CMIP6: default
36+
CMIP6: DKRZ
3437
```
3538
36-
If you have installed `esmvaltool_sample_data`, you can find the `rootpath` using `python -c 'from esmvaltool_sample_data import base_dir; print(base_dir.parent)'`
39+
If you have installed `esmvaltool_sample_data`, you can find the `rootpath` settings using `python -c 'import esmvaltool_sample_data, yaml; print(yaml.dump(esmvaltool_sample_data.get_rootpaths()))'`
3740

3841
## License
3942

esmvaltool_sample_data/__init__.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
VERBOSE = False
99

10-
# This ignore list is used to help with debugging
10+
# This ignore list is used to help with debugging only
11+
# for a more permanent solution, add
12+
# problematic datasets the `ignore` section in `../datasets.yml`.
1113
ignore_list = [
1214
# 'CMIP6/CMIP/AWI/AWI-ESM-1-1-LR/historical/r1i1p1f1/Amon/ta/gn/v20200212',
1315
]
@@ -50,6 +52,7 @@ def load_cubes_from_input_dirs(input_dirs: list) -> 'iris.Cube':
5052

5153

5254
def filter_ignored_datasets(dirs, root):
55+
"""Filter datasets defined in the global `ignore` list."""
5356
for drc in dirs:
5457
test_drc = str(drc.relative_to(root))
5558
if test_drc not in ignore_list:
@@ -87,6 +90,22 @@ def load_timeseries_cubes(mip_table: str = 'Amon') -> list:
8790
return list(cubes)
8891

8992

93+
def get_rootpaths() -> dict:
94+
"""Return a dict with rootpaths to update the user config in ESMValTool."""
95+
rootpath = {
96+
'rootpath': {
97+
'CMIP6': [
98+
str(base_dir / 'data' / 'timeseries' / 'CMIP6'),
99+
]
100+
},
101+
'drs': {
102+
'CMIP6': 'default',
103+
},
104+
}
105+
106+
return rootpath
107+
108+
90109
if __name__ == '__main__':
91110
VERBOSE = True
92111

0 commit comments

Comments
 (0)