-
Notifications
You must be signed in to change notification settings - Fork 128
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 perfmetrics portrait plot 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
.
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.
Something like "Expected scalar in input file {filename}"
?
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.
Sounds good!
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? |
We are working on it 😄 It's planned to include this in v2.12 |
Its also possible know to apply MultiModel Mean and Median over each group (i.e. project). I added a simple recipe |
I am not in favor of removing the old recipe as long as we do not reproduce the full output (e.g. including Taylor diagrams, etc.). and therefore have a new and complete "perfmetrics". So long, this PR just includes the portrait diagram. For this reason and to avoid confusion between "perfmetrics" and "portrait diagram", the new recipe (and documentation) should be simply called e.g. "recipe_portrait_plot.yml" and not contain anything like "perfmetrics" in the filenames. As a side note, I am not sure helper scripts such as "compare_netCDFs.py" need to go into the "diagnostics" folder. Maybe they do not need to go into the repository at all? |
I just talked to @bettina-gier and I think I misunderstood the removal of the recipe. So this is fine. My points about the naming remain. |
Sorry for the confusion. I didn't plan to remove the NCL based recipe just the one that reproduces its results. The helper scripts and different recipe versions will be removed before merge. Should we keep the script and the results as comments in this PR, in case some one is interested? |
Description
portrait plot
from NCL perfmetrics in python #3550Before you get started
portrait plot
from NCL 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: