Skip to content
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

Generate climatology on the fly for AutoAssess soil moisture #3197

Merged
merged 29 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a982577
Add ORCID
alistairsellar Dec 18, 2022
fb5cb14
Remove reference to climatology files
alistairsellar Dec 18, 2022
874bbb3
Try adding CCI obs
alistairsellar Jan 14, 2023
413311a
Make CCI additional_dataset and add preprocessor
alistairsellar May 10, 2023
50c4d61
Decouple metrics script from autoassess wrapper
alistairsellar May 10, 2023
04e7d3e
New function to write metrics files
alistairsellar May 10, 2023
e93d2a3
Fix provenance
alistairsellar May 10, 2023
1a2aca3
Merge branch 'main' into autoassess_soilmoisture_obs_fly
alistairsellar May 26, 2023
adb36fd
Fix the easy Codacy errors
alistairsellar Jun 2, 2023
8ff4a01
Break provenance into own function for pylint
alistairsellar Jun 2, 2023
5ab7e63
Fix new style error
alistairsellar Jun 2, 2023
686ea3e
Remove doc mention of autoassess_area_base...
alistairsellar Jun 2, 2023
2efbc26
Remove from broken recipes list
alistairsellar Jun 2, 2023
2f7e6d3
Merge branch 'main' into autoassess_soilmoisture_obs_fly
alistairsellar Jun 2, 2023
50812a9
Use correct references key
alistairsellar Jun 14, 2023
57e55d8
Correct documentation
alistairsellar Jun 14, 2023
cbd7c85
Merge branch 'autoassess_soilmoisture_obs_fly' of github.com:ESMValGr…
alistairsellar Jun 14, 2023
8cad172
Merge branch 'main' into autoassess_soilmoisture_obs_fly
alistairsellar Jun 14, 2023
6f79a0e
Fix provenance to associate with output file
alistairsellar Jun 16, 2023
332392b
Remove redundant mini config dict
alistairsellar Jun 16, 2023
4e8d4e3
Document new argument
alistairsellar Jun 16, 2023
f266afc
Add provenance for AutoAssess metrics plots
alistairsellar Jun 16, 2023
1aa65b1
Merge branch 'main' into autoassess_soilmoisture_obs_fly
alistairsellar Jun 16, 2023
c2c6104
Merge branch 'autoassess_soilmoisture_obs_fly' of github.com:ESMValGr…
alistairsellar Jun 16, 2023
473af6d
Add provenance for intermediate cube save
alistairsellar Jun 19, 2023
e8cebfe
Move unit conversion into its own function
alistairsellar Jun 19, 2023
64225ed
Merge branch 'main' into autoassess_soilmoisture_obs_fly
alistairsellar Jun 19, 2023
e64ee64
Fix style error
alistairsellar Jun 19, 2023
10cb722
Make provenance specific to model dataset
alistairsellar Jun 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions doc/sphinx/source/recipes/broken_recipe_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ More details can be found in the :ref:`broken recipe policy
- Affected diagnostics
- Problem
- GitHub issue
* - :ref:`recipe_autoassess_landsurface_soilmoisture.yml <recipe_autoassess_landsurface_soilmoisture.rst>`
- All
- Dependency on some external climatology files
- `#2309 <https://github.com/ESMValGroup/ESMValTool/issues/2309>`_
* - `recipe_check_obs.yml`
- `ERA5_native6`
- Derivation of custom variables `rlus` and `rsus`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Performance metrics:

Metrics are calculated using model and observation multi-year climatologies (seasonal means)
for meteorological seasons:

* December-January-February (djf)
* March-April-May (mam)
* June-July-August (jja)
Expand All @@ -38,7 +39,6 @@ Recipes are stored in esmvaltool/recipes/

Diagnostics are stored in esmvaltool/diag_scripts/autoassess/

* autoassess_area_base.py: wrapper for autoassess scripts
* land_surface_soilmoisture/soilmoisture.py: script to calculate soil moisture
metrics
* plot_autoassess_metrics.py: plot normalised assessment metrics
Expand All @@ -47,21 +47,17 @@ Diagnostics are stored in esmvaltool/diag_scripts/autoassess/
User settings in recipe
-----------------------

#. Script autoassess_area_base.py
#. Script soilmoisture.py

*Required settings for script*

* area: must equal land_surface_soilmoisture to select this diagnostic
* control_model: name of model to be used as control
* exp_model: name of model to be used as experiment
* start: date (YYYY/MM/DD) at which period begins (see note on time gating)
* end: date (YYYY/MM/DD) at which period ends (see note on time gating)
* climfiles_root: path to observation climatologies

*Optional settings for script*

* title: arbitrary string with name of diagnostic
* obs_models: unused for this recipe
none

*Required settings for variables*

Expand Down Expand Up @@ -97,7 +93,8 @@ User settings in recipe
Variables
---------

* mrsos (land, monthly mean, longitude latitude time)
* mrsos (from models: land, monthly mean, longitude latitude time)
* sm (from observations: land, monthly mean, longitude latitude time)


Observations and reformat scripts
Expand All @@ -122,56 +119,3 @@ Example plots
:alt: Soilmoisture_Metrics.png

Normalised metrics plot comparing a control and experiment simulation


Additional notes on usage
-------------------------
The ``landsurface_soilmoisture`` area metric is part of the ``esmvaltool/diag_scripts/autoassess`` diagnostics,
and, as any other ``autoassess`` metric, it uses the ``autoassess_area_base.py`` as general purpose
wrapper. This wrapper accepts a number of input arguments that are read through from the recipe.

This recipe is part of the larger group of Autoassess metrics ported to ESMValTool
from the native Autoassess package from the UK's Met Office. The ``diagnostics`` settings
are almost the same as for the other Autoassess metrics.

**Currently this recipe is marked as broken, because it only runs on Jasmin due to a dependency on some
external climatology files.**

.. note::

**Time gating for autoassess metrics.**

To preserve the native Autoassess functionalities,
data loading and selection on time is done somewhat
differently for ESMValTool's autoassess metrics: the
time selection is done in the preprocessor as per usual but
a further time selection is performed as part of the diagnostic.
For this purpose the user will specify a ``start:`` and ``end:``
pair of arguments of ``scripts: autoassess_script`` (see below
for example). These are formatted as ``YYYY/MM/DD``; this is
necessary since the Autoassess metrics are computed from 1-Dec
through 1-Dec rather than 1-Jan through 1-Jan. This is a temporary
implementation to fully replicate the native Autoassess functionality
and a minor user inconvenience since they need to set an extra set of
``start`` and ``end`` arguments in the diagnostic; this will be phased
when all the native Autoassess metrics have been ported to ESMValTool
review has completed.


An example of standard inputs as read by ``autoassess_area_base.py`` and passed
over to the diagnostic/metric is listed below.


.. code-block:: yaml

scripts:
autoassess_landsurf_soilmoisture: &autoassess_landsurf_soilmoisture_settings
script: autoassess/autoassess_area_base.py
title: "Autoassess Land-Surface Soilmoisture Diagnostic"
area: land_surface_soilmoisture
control_model: IPSL-CM5A-LR
exp_model: inmcm4
obs_models: []
start: 1997/12/01
end: 2002/12/01
climfiles_root: '/gws/nopw/j04/esmeval/autoassess_specific_files/files' # on JASMIN
6 changes: 5 additions & 1 deletion esmvaltool/config-references.yml
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ authors:
sellar_alistair:
name: Sellar, Alistair
institute: MetOffice, UK
orcid:
orcid: 0000-0002-2955-7254
wyser_klaus:
name: Wyser, Klaus
institute: SMHI, Sweden
Expand Down Expand Up @@ -668,6 +668,10 @@ authors:
institute:
orcid:
github: mcreader97
rumbold_heather:
name: Heather, Rumbold
institute: Met Office, UK
orcid:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you asked Heather? I can ask Steve on Whatsapp to ask her, if not 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to ORCID website she does not have one. She is on maternity leave at present.

senftleben_daniel:
name: Senftleben, Daniel
institute: DLR, Germany
Expand Down
34 changes: 27 additions & 7 deletions esmvaltool/diag_scripts/autoassess/_plot_mo_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import matplotlib.pyplot as plt
import numpy as np

from esmvaltool.diag_scripts.shared import save_figure

# Define some colours
BLACK = '#000000'
RED = '#FF0000'
Expand Down Expand Up @@ -596,7 +598,8 @@ def plot_nac(cref,
acc=None,
extend_y=False,
title=None,
ofile=None):
ofile=None,
config=None):
"""
Routine to produce NAC plot.

Expand All @@ -611,6 +614,7 @@ def plot_nac(cref,
:param bool extend_y: Extend y-axis to include obs/acc ranges
:param str title: Plot title
:param str ofile: Plot file name
:param dict config: ESMValTool configuration object
"""
# initialize
if metrics is None:
Expand Down Expand Up @@ -682,15 +686,31 @@ def plot_nac(cref,
legend.set_title('Vs %s' % cref, prop={'size': 'small'})

# Display or produce file
if ofile:
# Create directory to write file to
odir = os.path.dirname(ofile)
if not os.path.isdir(odir):
os.makedirs(odir)
if ofile and config:
os.makedirs(config['plot_dir'], exist_ok=True)
provenance = get_provenance_record(config)
# Note that bbox_inches only works for png plots
plt.savefig(ofile, bbox_extra_artists=(legend, ), bbox_inches='tight')
save_figure(ofile, provenance, config, fig,
bbox_extra_artists=(legend, ), bbox_inches='tight')
else:
# Need the following to attempt to display legend in frame
fig.subplots_adjust(right=0.85)
plt.show()
plt.close()


def get_provenance_record(config):
"""Create a provenance record describing the diagnostic data and plot."""
filenames = [item["filename"] for item in config["input_data"].values()]
record = {
'caption': 'Normalised assessment criteria plot',
'plot_type': 'metrics',
'authors': [
'williams_keith',
'predoi_valeriu',
'sellar_alistair'
],
"ancestors": filenames,
}

return record