-
Notifications
You must be signed in to change notification settings - Fork 127
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
recreate perfmetric plots in python #3551
base: main
Are you sure you want to change the base?
Conversation
what a noble venture, Lukas! Godspeed 🏁 🍺 |
… into perfmetric_python
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of more comments of things I found while running an example recipe. Apart from these small issues, the diagnostic worked really nicely and the plot looks awesome 🚀
dataset[cfg["x_by"]].str.lower(), dataset[cfg["y_by"]].str.lower(), | ||
dataset[cfg["group_by"]].str.lower(), | ||
dataset[cfg["split_by"]].str.lower() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can lead to errors with any of the facets is None
. For example, the default value if no split
is given for a dataset is None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that actually happened to me as well. I worked around it by setting everything that is None
to 'None'
, but that is probably not the best solution ;).
log.warning("Metadata found for %s", selection) | ||
das = xr.open_dataset(metas[0]["filename"]) | ||
varname = list(das.data_vars.keys())[0] | ||
return das[varname].values.item() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great to raise a nicer error here if the data is non-scalar, at the moment this gives ValueError: can only convert an array of size 1 to a Python scalar
.
So far we used the distance_metrics prerpocessor from within the recipe, which works but has some limitations in practise and can lead to messy recipes. I added an optional function to apply it from within the plot diagnostic. I.e. use |
if None in data.coords[cfg["split_by"]].values: | ||
cfg.update({"default_split": None}) | ||
else: | ||
cfg.update({"default_split": data.coords[cfg["split_by"]].values[0]}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this overwrite a user-defined default_split
? Do we want this?
Hi, we are currently working on the ESMValTool release for v2.11.0. We're wondering if you'd be able to complete this PR by the end of next week (Friday 10th May). Otherwise, please let us know, and we'll move it into the next milestone for you 🙂 |
I don't see this PR be ready until next week. The next milestone is more realistic I'd say. |
except IndexError as exc: | ||
raise IndexError("No reference found for metric.") from exc | ||
ref_cube = iris.load_cube(reference["filename"]) | ||
for meta in y_metas: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should support multiple references (with different split facets). The split (maybe the full set of split/group/x/y) needs also to be part of the filename to avoid overwriting files.
I just came across this. It looks great. Any progress? |
split_legend(cfg, grid, data) | ||
basename = "portrait_plot" | ||
fname = get_plot_filename(basename, cfg) | ||
plt.savefig(fname, bbox_inches="tight", dpi=cfg["dpi"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provenance recording is missing here (the plot does not show up in the index.html
file).
We are working on it 😄 It's planned to include this in v2.12 |
Description
perfmetrics
in python #3550Before you get started
perfmetrics
in python #3550Checklist
It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.
New or updated recipe/diagnostic
New or updated data reformatting script
To help with the number of pull requests: