Skip to content

Commit 6eb8348

Browse files
committed
updates for v2.10
1 parent 75fc7f0 commit 6eb8348

File tree

2 files changed

+89
-85
lines changed

2 files changed

+89
-85
lines changed

_episodes/06-preprocessor.md

Lines changed: 80 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Writing your own recipe"
33
teaching: 15
44
exercises: 30
5-
compatibility: ESMValTool v2.9.0
5+
compatibility: ESMValTool v2.10.0
66

77
questions:
88
- "How do I create a new recipe?"
@@ -73,18 +73,13 @@ start from scratch. This forces us to think about all the steps. We will deal
7373
with common errors as they occur throughout the development.
7474

7575
Remember the basic structure of a recipe, and notice that each of them is
76-
extensively described in the documentation under the header
77-
["The recipe
78-
format"][recipe-overview]{:target="_blank"}:
79-
80-
- [documentation](https://docs.esmvaltool.org/projects/esmvalcore/en/latest/
81-
recipe/overview.html#recipe-section-documentation){:target="_blank"}
82-
- [datasets](https://docs.esmvaltool.org/projects/esmvalcore/en/latest/recipe/
83-
overview.html#recipe-section-datasets){:target="_blank"}
84-
- [preprocessors](https://docs.esmvaltool.org/projects/esmvalcore/en/latest/
85-
recipe/overview.html#recipe-section-preprocessors){:target="_blank"}
86-
- [diagnostics](https://docs.esmvaltool.org/projects/esmvalcore/en/latest/
87-
recipe/overview.html#recipe-section-diagnostics){:target="_blank"}
76+
extensively described in the documentation following the header
77+
["Overview"][recipe-overview]{:target="_blank"}:
78+
79+
- [documentation][recipe-section-documentation]{:target="_blank"}
80+
- [datasets][recipe-section-datasets]{:target="_blank"}
81+
- [preprocessors][recipe-section-preprocessors]{:target="_blank"}
82+
- [diagnostics][recipe-section-diagnostics]{:target="_blank"}
8883

8984
This is the first place to look for help if you get stuck.
9085

@@ -120,17 +115,18 @@ esmvaltool run recipe_warming_stripes.yml
120115
In this case, it gives an error. Below you see the last few lines of the error message.
121116
```
122117
...
123-
Error validating data /home/user/esmvaltool_tutorial/recipe_warming_stripes.yml
124-
with schema /home/user/mambaforge/envs/esmvaltool_tutorial/lib/python3.10
125-
/site-packages/esmvalcore/recipe_schema.yml
126-
documentation.authors: Required field missing
127-
YYYY-MM-DD HH:mm:SS,NNN UTC [19451] INFO If you have a question or need help,
128-
please start a new discussion on https://github.com/ESMValGroup/
129-
ESMValTool/discussions
130-
If you suspect this is a bug, please open an issue on
131-
https://github.com/ESMValGroup/ESMValTool/issues
132-
To make it easier to find out what the problem is, please consider attaching
133-
the files run/recipe_*.yml and run/main_log_debug.txt from the output directory.
118+
yamale.yamale_error.YamaleError:
119+
Error validating data '/home/users/username/esmvaltool_tutorial/recipe_warming_stripes.yml'
120+
with schema '/apps/jasmin/community/esmvaltool/miniconda3_py311_23.11.0-2/envs/esmvaltool/lib/python3.11/
121+
site-packages/esmvalcore/_recipe/recipe_schema.yml'
122+
documentation.authors: Required field missing
123+
2024-05-27 13:21:23,805 UTC [41924] INFO
124+
If you have a question or need help, please start a new discussion on
125+
https://github.com/ESMValGroup/ESMValTool/discussions
126+
If you suspect this is a bug, please open an issue on https://github.com/ESMValGroup/ESMValTool/issues
127+
To make it easier to find out what the problem is, please consider attaching the
128+
files run/recipe_*.yml and run/main_log_debug.txt from the output directory.
129+
134130
```
135131
{: .error}
136132

@@ -169,23 +165,22 @@ This is the minimal recipe layout that is required by ESMValTool. If we now run
169165
the recipe again, you will probably see the following error:
170166
171167
```
172-
ValueError: Tag 'doe_john' does not exist in section 'authors' of
173-
/home/user/mambaforge/envs/esmvaltool_tutorial/python3.10/
174-
site-packages/esmvaltool/config-references.yml
168+
ValueError: Tag 'doe_john' does not exist in section
169+
'authors' of /apps/jasmin/community/esmvaltool/ESMValTool_2.10.0/esmvaltool/config-references.yml
170+
175171
```
176172
{: .error}
177173

178174
> ## Pro tip: config-references.yml
179175
>
180176
> The error message above points to a file named
181-
> [config-references.yml](https://github.com/ESMValGroup/ESMValTool/blob/main
182-
/esmvaltool/config-references.yml).
177+
> [config-references.yml][config-references]
178+
183179
> This is where ESMValTool stores all its citation information. To add yourself
184180
> as an author, add your name in the form `lastname_firstname` in alphabetical
185181
> order following the existing entries, under the `# Development team` comment.
186182
> See the
187-
> [List of authors](https://docs.esmvaltool.org/en/latest/community/
188-
code_documentation.html#list-of-authors)
183+
> [List of authors][list-of-authors]{:target="_blank"}
189184
> section in the ESMValTool documentation for more information.
190185
{: .callout}
191186

@@ -210,8 +205,7 @@ Let's add a datasets section.
210205
> Use the paths specified in the configuration file to explore the data directory,
211206
> and look at the explanation of the dataset entry
212207
> in the [ESMValTool
213-
> documentation](https://docs.esmvaltool.org/projects/esmvalcore/en/latest/
214-
recipe/overview.html#recipe-section-documentation){:target="_blank"}.
208+
> documentation][recipe-section-datasets]{:target="_blank"}.
215209
> For both the datasets, write down the following properties:
216210
>
217211
> - project
@@ -283,15 +277,17 @@ in ESMValTool.
283277
> `glob` patterns or wildcards. An example `datasets` section that uses all
284278
> available CMIP6 models and ensemble members for the `historical` experiment
285279
> will look like this:
286-
> ```yaml```
287-
>datasets:
288-
> - project: CMIP6
289-
> exp: historical
290-
> dataset: '*'
291-
> institute: '*'
292-
> ensemble: '*'
293-
> grid: '*'
294-
> Note that you will have to set the `search_esgf` option in the `config_file to
280+
>
281+
>>```yaml
282+
>>datasets:
283+
>> - project: CMIP6
284+
>> exp: historical
285+
>> dataset: '*'
286+
>> institute: '*'
287+
>> ensemble: '*'
288+
>> grid: '*'
289+
>> ```
290+
> Note that you will have to set the `search_esgf` option in the `config_file` to
295291
> `always` so that you can download data from ESGF nodes as needed.
296292
{: .callout}
297293
@@ -304,8 +300,7 @@ standard, gridded temperature data to a timeseries of temperature anomalies.
304300
> ## Defining the preprocessor
305301
>
306302
> Have a look at the available preprocessors in the
307-
> [documentation](https://docs.esmvaltool.org/projects/esmvalcore/en/latest
308-
/recipe/preprocessor.html).
303+
> [documentation][preprocessor]{:target="_blank"}.
309304
> Write down
310305
>
311306
> - Which preprocessor functions do you think we should use?
@@ -322,8 +317,7 @@ standard, gridded temperature data to a timeseries of temperature anomalies.
322317
> > case we want to compute the `mean`).
323318
> >
324319
> > The default order in which these preprocessors are applied can be seen
325-
> > [here](https://docs.esmvaltool.org/projects/esmvalcore/en/latest/api/
326-
esmvalcore.preprocessor.html#preprocessor-functions):
320+
> > [here][preprocessor-functions]{:target="_blank"}:
327321
> > `area_statistics` comes before `anomalies`. If you want to change this, you
328322
> > can use the `custom_order` preprocessor. We will keep it like this.
329323
> >
@@ -410,39 +404,6 @@ reference, here's a copy of the [recipe at this
410404
point](../files/recipe_warming_stripes.yml). This will be the point of departure
411405
for each of the modifications we'll make below.
412406
413-
> ## Multiple ensemble members
414-
>
415-
> You can choose data from multiple ensemble members for a model in a single line
416-
>
417-
>> ## Solution
418-
>>
419-
>> The `dataset` section allows you to choose more than one ensemble member
420-
>> Here's a copy of the changed
421-
>> [recipe](../files/recipe_warming_stripes_multiple_ensemble_members.yml)
422-
>>to do that.
423-
>> Changes made are shown in the diff output below:
424-
>>
425-
>> --- recipe_warming_stripes.yml
426-
>> +++ recipe_warming_stripes_multiple_ensemble_members.yml
427-
>> @@ -8,7 +8,7 @@
428-
>> - righi_mattia
429-
>>
430-
>> datasets:
431-
>> - - {dataset: BCC-ESM1, project: CMIP6, mip: Amon, exp: historical, ensemble: r1i1p1f1, grid: gn, start_year: 1850, end_year: 2014}
432-
>> + - {dataset: BCC-ESM1, project: CMIP6, mip: Amon, exp: historical, ensemble: "r(1:2)i1p1f1", grid: gn, start_year: 1850, end_year: 2014}
433-
>>
434-
>> preprocessors:
435-
>> global_anomalies:
436-
>>
437-
>>
438-
>> Pro-tip: Check out the section on a different way to use multiple ensemble
439-
>> members or even multiple experiments at
440-
>> [Concatenating data corresponding to multiple facets][datasets-overview].
441-
>>
442-
> {: .solution}
443-
{:.challenge}
444-
445-
446407
> ## Specific location selection
447408
>
448409
> On showyourstripes.org, you can download stripes for specific locations. Here we
@@ -493,11 +454,11 @@ for each of the modifications we'll make below.
493454
> {: .solution}
494455
{:.challenge}
495456
496-
> ## Different periods
457+
> ## Different time periods
497458
>
498-
> Split the diagnostic in 2: the second one should use a different period.
499-
> You're free to choose the periods yourself. For example, 1 could be 'recent',
500-
> the other '20th_century'. For this, you'll have to add a new variable group.
459+
> Split the diagnostic in two with two different time periods for the same variable.
460+
> You can choose the time periods yourself. For example, the recent past and
461+
> the 20th century. You can do this by using variable groups.
501462
>
502463
> > ## Solution
503464
> >
@@ -508,7 +469,6 @@ for each of the modifications we'll make below.
508469
> > --- recipe_warming_stripes_local.yml
509470
> > +++ recipe_warming_stripes_periods.yml
510471
> > @@ -7,7 +7,7 @@
511-
> > - righi_mattia
512472
> >
513473
> > datasets:
514474
> > - - {dataset: BCC-ESM1, project: CMIP6, mip: Amon, exp: historical,
@@ -547,7 +507,7 @@ for each of the modifications we'll make below.
547507
> preprocessors. Add a second preprocessor to add another location of your
548508
> choosing.
549509
>
550-
> Pro-tip: if you want to avoid repetition, you can use YAML anchors.
510+
>
551511
>
552512
> > ## Solution
553513
> >
@@ -601,6 +561,11 @@ for each of the modifications we'll make below.
601561
>
602562
{:.challenge}
603563
564+
>
565+
> ## Pro-tip: YAML anchors
566+
> If you want to avoid repetition, you can use YAML anchors as seen in the recipe above.
567+
{:.callout}
568+
604569
> ## Additional datasets
605570
>
606571
> So far we have defined the datasets in the datasets section of the recipe.
@@ -632,4 +597,34 @@ for each of the modifications we'll make below.
632597
> {: .solution}
633598
{:.challenge}
634599
600+
> ## Multiple ensemble members
601+
>
602+
> You can choose data from multiple ensemble members for a model in a single line
603+
>
604+
>> ## Solution
605+
>>
606+
>> The `dataset` section allows you to choose more than one ensemble member
607+
>> Here's a copy of the changed
608+
>> [recipe](../files/recipe_warming_stripes_multiple_ensemble_members.yml)
609+
>>to do that.
610+
>> Changes made are shown in the diff output below:
611+
>>```diff
612+
>>--- recipe_warming_stripes.yml 2024-05-27 15:37:52.340358967 +0100
613+
>>+++ recipe_warming_stripes_multiens.yml 2024-05-27 22:18:42.035558837 +0100
614+
>>@@ -10,7 +10,7 @@
615+
>>- ensemble: r1i1p1f1, grid: gn, start_year: 1850, end_year: 2014}
616+
>>+ ensemble: "r(1:2)i1p1f1", grid: gn, start_year: 1850, end_year: 2014}
617+
>>```
618+
>>
619+
> {: .solution}
620+
{:.challenge}
621+
622+
> ## Pro-tip: Concatenating datasets
623+
> Check out the section on a different way to use multiple ensemble
624+
> members or even multiple experiments at [Concatenating data corresponding to multiple facets]
625+
>[concatenating-datasets]{:target="_blank"}.
626+
>
627+
{: .callout}
628+
629+
635630
{% include links.md %}

_includes/links.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
[coc-reporting]: https://docs.carpentries.org/topic_folders/policies/incident-reporting.html
99
[coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html
1010
[code-documentation]: https://docs.esmvaltool.org/en/latest/community/code_documentation.html
11+
[concatenating-datasets]: https://docs.esmvaltool.org/projects/ESMValCore/en/latest/recipe/overview.html#concatenating-data-corresponding-to-multiple-facets
1112
[concept-maps]: https://carpentries.github.io/instructor-training/05-memory/
1213
[config-file]: https://docs.esmvaltool.org/projects/ESMValCore/en/latest/quickstart/configure.html
14+
[config-references]: https://github.com/ESMValGroup/ESMValTool/blob/main/esmvaltool/config-references.yml
1315
[contrib-covenant]: https://contributor-covenant.org/
1416
[contributing]: {{ repo_url }}/blob/{{ source_branch }}/CONTRIBUTING.md
1517
[cran-checkpoint]: https://cran.r-project.org/package=checkpoint
@@ -43,6 +45,7 @@
4345
[lesson-recipe]: {{ relative_root_path }}{% link _episodes/04-recipe.md %}
4446
[lesson-reference]: {{ relative_root_path }}{% link reference.md %}
4547
[lesson-setup]: {{ relative_root_path }}{% link setup.md %}
48+
[list-of-authors]: https://docs.esmvaltool.org/en/latest/community/code_documentation.html#list-of-authors
4649
[manage-environments]: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
4750
[mit-license]: https://opensource.org/licenses/mit-license.html
4851
[morea]: https://morea-framework.github.io/
@@ -52,11 +55,17 @@
5255
[pandoc]: https://pandoc.org/
5356
[paper-now]: https://github.com/PeerJ/paper-now
5457
[preproc-area-manipulation]: https://docs.esmvaltool.org/projects/ESMValCore/en/latest/recipe/preprocessor.html#area-operations
58+
[preprocessor]: https://docs.esmvaltool.org/projects/esmvalcore/en/latest/recipe/preprocessor.html
59+
[preprocessor-functions]: https://docs.esmvaltool.org/projects/esmvalcore/en/latest/api/esmvalcore.preprocessor.html#preprocessor-functions
5560
[provenance]: https://docs.esmvaltool.org/en/latest/community/diagnostic.html?highlight=provenance#recording-provenance
5661
[python-gapminder]: https://swcarpentry.github.io/python-novice-gapminder/
5762
[pyyaml]: https://pypi.python.org/pypi/PyYAML
5863
[recipe]: https://github.com/ESMValGroup/ESMValTool/blob/main/esmvaltool/recipes/examples/recipe_python.yml
5964
[recipe-overview]: https://docs.esmvaltool.org/projects/esmvalcore/en/latest/recipe/overview.html
65+
[recipe-section-datasets]: https://docs.esmvaltool.org/projects/esmvalcore/en/latest/recipe/overview.html#recipe-section-datasets
66+
[recipe-section-diagnostics]: https://docs.esmvaltool.org/projects/esmvalcore/en/latest/recipe/overview.html#recipe-section-diagnostics
67+
[recipe-section-documentation]: https://docs.esmvaltool.org/projects/esmvalcore/en/latest/recipe/overview.html#recipe-section-documentation
68+
[recipe-section-preprocessors]: https://docs.esmvaltool.org/projects/esmvalcore/en/latest/recipe/overview.html#recipe-section-preprocessors
6069
[r-markdown]: https://rmarkdown.rstudio.com/
6170
[rstudio]: https://www.rstudio.com/
6271
[ruby-install-guide]: https://www.ruby-lang.org/en/downloads/

0 commit comments

Comments
 (0)