-
Notifications
You must be signed in to change notification settings - Fork 3
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 precipitation histogram to prognostic run report #1271
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
98e8061
Add OrderedList class to report
41976a2
Add diagnostic of precipitation histogram
df2db9a
Stop requiring two runs if making report from folder
56bc134
Better OrderedList API
ebccbef
Set histogram diagnostic coordinate to bin midpoints
29a8f80
Add process.html page with diurnal cycle and precip PDF
53ce8fd
Remove obsolete failing units tests
2bc64e1
Merge branch 'master' into feature/process-page
7085fc9
Case HISTOGRAM_BINS.keys() to list
095423d
Save bin widths to allow accurate cdf calculation
02d5be2
Add metric for various percentiles
5647c1e
Delete unused constant
eb099c9
Rename function to not be duplicated
caec3f9
Fix navigation link
ee55d10
Add table of precip percentiles to process page
0fa128f
Refactor compute_percentile function and add tests
48e9f6a
Add docstring
92edd8c
Refactor histogram calc to new function in VCM
c3c476b
Fix lint and typechecking
7097de2
Compute 3-hourly mean before histogram
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
from .create_report import create_html, insert_report_figure, Metrics, Metadata, Link | ||
from .create_report import ( | ||
create_html, | ||
insert_report_figure, | ||
Metrics, | ||
Metadata, | ||
Link, | ||
OrderedList, | ||
) | ||
|
||
__version__ = "0.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import Any, Hashable, Mapping, Tuple | ||
|
||
import numpy as np | ||
import xarray as xr | ||
|
||
|
||
def histogram(da: xr.DataArray, **kwargs) -> Tuple[xr.DataArray, xr.DataArray]: | ||
"""Compute histogram and return tuple of counts and bin widths. | ||
|
||
Args: | ||
da: input data | ||
kwargs: optional parameters to pass on to np.histogram | ||
|
||
Return: | ||
counts, bin_widths tuple of xr.DataArrays. The coordinate of both arrays is | ||
equal to the left side of the histogram bins. | ||
""" | ||
coord_name = f"{da.name}_bins" if da.name is not None else "bins" | ||
count, bins = np.histogram(da, **kwargs) | ||
coords: Mapping[Hashable, Any] = {coord_name: bins[:-1]} | ||
width = bins[1:] - bins[:-1] | ||
width_da = xr.DataArray(width, coords=coords, dims=[coord_name]) | ||
count_da = xr.DataArray(count, coords=coords, dims=[coord_name]) | ||
if "units" in da.attrs: | ||
count_da[coord_name].attrs["units"] = da.units | ||
width_da[coord_name].attrs["units"] = da.units | ||
width_da.attrs["units"] = da.units | ||
return count_da, width_da |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 switched to using the
vcm.dump_nc
version of this a while ago, so this func is unused.