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

Separate computing global sums / means from plotting them #32

Open
mnlevy1981 opened this issue Oct 9, 2020 · 0 comments
Open

Separate computing global sums / means from plotting them #32

mnlevy1981 opened this issue Oct 9, 2020 · 0 comments

Comments

@mnlevy1981
Copy link
Contributor

The following block in summary_plot_global_ts() has nothing to do with plotting and should be its own function:

spatial_op = diag_metadata.get("spatial_op", "average")
if spatial_op == "average":
    to_plot = da_weighted.mean(dim=reduce_dims)
    to_plot.attrs = da.attrs
    if "display_units" in diag_metadata:
        to_plot = conv_units(to_plot, diag_metadata["display_units"])
if spatial_op == "integrate":
    to_plot = da_weighted.sum(dim=reduce_dims)
    to_plot.attrs = da.attrs
    to_plot.attrs["units"] += f" {weights.attrs['units']}"
    if "integral_display_units" in diag_metadata:
        to_plot = conv_units(
            to_plot,
            diag_metadata["integral_display_units"],
            units_scalef=diag_metadata.get("integral_unit_conv"),
        )

Besides separating computation and plotting, if it is pulled out then it can then be wrapped in xpersist and cached (if so desired).

@andersy005 andersy005 added this to Xdev Dec 2, 2021
@andersy005 andersy005 moved this to 🌳 Todo in Xdev Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant