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

Add Hovmöller time vs. lat/lon plot to diagnostic monitor/multi_datsets.py #3338

Closed
17 tasks done
lukruh opened this issue Sep 5, 2023 · 2 comments · Fixed by #3341
Closed
17 tasks done

Add Hovmöller time vs. lat/lon plot to diagnostic monitor/multi_datsets.py #3338

lukruh opened this issue Sep 5, 2023 · 2 comments · Fixed by #3341
Assignees
Milestone

Comments

@lukruh
Copy link
Contributor

lukruh commented Sep 5, 2023

See https://de.wikipedia.org/wiki/Hovm%C3%B6ller-Diagramm.

Aim: add new plot type hovmoeller_time_vs_lat_or_lon to monitor/multi_datasets.py.

Large parts of the necessary code can be copy-pasted from here:

def create_zonal_mean_profile_plot(self, datasets, short_name):
"""Create zonal mean profile plot."""
plot_type = 'zonal_mean_profile'
if plot_type not in self.plots:
return
if not datasets:
raise ValueError(f"No input data to plot '{plot_type}' given")
# Get reference dataset if possible
ref_dataset = self._get_reference_dataset(datasets, short_name)
if ref_dataset is None:
logger.info("Plotting %s without reference dataset", plot_type)
else:
logger.info("Plotting %s with reference dataset '%s'", plot_type,
self._get_label(ref_dataset))
# Get plot function
plot_func = self._get_plot_func(plot_type)
# Create a single plot for each dataset (incl. reference dataset if
# given)
for dataset in datasets:
if dataset == ref_dataset:
continue
ancestors = [dataset['filename']]
if ref_dataset is None:
(plot_path, netcdf_paths) = (
self._plot_zonal_mean_profile_without_ref(plot_func,
dataset)
)
caption = (
f"Zonal mean profile of {dataset['long_name']} of dataset "
f"{dataset['dataset']} (project {dataset['project']}) "
f"from {dataset['start_year']} to {dataset['end_year']}."
)
else:
(plot_path, netcdf_paths) = (
self._plot_zonal_mean_profile_with_ref(plot_func, dataset,
ref_dataset)
)
caption = (
f"Zonal mean profile of {dataset['long_name']} of dataset "
f"{dataset['dataset']} (project {dataset['project']}) "
f"including bias relative to {ref_dataset['dataset']} "
f"(project {ref_dataset['project']}) from "
f"{dataset['start_year']} to {dataset['end_year']}."
)
ancestors.append(ref_dataset['filename'])
# If statistics are shown add a brief description to the caption
if self.plots[plot_type]['show_stats']:
caption += (
" The number in the top left corner corresponds to the "
"spatial mean (weighted by grid cell areas).")
# Save plot
plt.savefig(plot_path, **self.cfg['savefig_kwargs'])
logger.info("Wrote %s", plot_path)
plt.close()
# Save netCDFs
for (netcdf_path, cube) in netcdf_paths.items():
io.iris_save(cube, netcdf_path)
# Provenance tracking
provenance_record = {
'ancestors': ancestors,
'authors': ['schlund_manuel'],
'caption': caption,
'plot_types': ['vert'],
'long_names': [dataset['long_name']],
}
with ProvenanceLogger(self.cfg) as provenance_logger:
provenance_logger.log(plot_path, provenance_record)
for netcdf_path in netcdf_paths:
provenance_logger.log(netcdf_path, provenance_record)

Use /work/bd1179/esmvaltool_hackathon/recipes/recipe_hovmoeller_time_vs_lat_or_lon.yml to get started. You find more detailed instructions in this file.

TODO:

  • Discuss which variable/which regions/which observations we want to show.
  • adjust labels and order depending on lat or lon
  • documentation in diagnostic file
  • test meridional and zonal pp
  • single plot without reference
  • multi panel with reference and bias
  • consistent order in docs, methods, plot types etc..
  • try to enable/change all recipe options
    • rasterize does not work
    • remove show stats
    • replace minor tick labels with minor ticks
  • update captions and provenance
  • discuss defaults and options with others working on hovmoellers
  • example recipes in monitor with some example options
  • example plots in docs doc/sphinx/source/recipes/recipe_monitor.rst add plot image to the bottom (compressed <100k)
  • flake, codespell, isort multi_datasets.py
  • add authors to recipe (and diag?)
@lukruh lukruh converted this from a draft issue Sep 5, 2023
@lukruh lukruh self-assigned this Sep 5, 2023
@lukruh
Copy link
Contributor Author

lukruh commented Sep 5, 2023

@lukruh
Copy link
Contributor Author

lukruh commented Sep 6, 2023

we should test _add_stats() again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
2 participants