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

New Peak Ratio #435

Merged
merged 5 commits into from
May 8, 2024
Merged

New Peak Ratio #435

merged 5 commits into from
May 8, 2024

Conversation

daniel-caichac-DHI
Copy link
Collaborator

@daniel-caichac-DHI daniel-caichac-DHI commented Apr 19, 2024

Hi.

After a long discussion we decided to update the peak selection in the Peak Ratio.

  • Before this PullRequest the individual N-largests peaks between model and measurements were selected and then intersected (ie, finding the joint-events only), and the remaining joint-peaks were used in the calculation.
  • With this PullRequest , all individual peaks are selected independently (from measurements and model), intersected (finding the joint-events), and then the N-largest peaks are used for the calculation.

Small change but has some implications in the results. Also the number of times the user gets a NaN (no joint events) is much lower now (still can happen with very short time series with no evident peaks).
I had to obviously update the tests results of PR as the expected values now change.

Aligns with what was done here:
https://github.com/DHI/potpy/pull/39

@ecomodeller
Copy link
Member

I'm trying to understand the parameters of the peak_ratio by this Streamlit app

I think the inter_event_level could be explained in some, perhaps in a Notes section.

It is also interesting to understand how the default values for these parameters were chosen.

image

@daniel-caichac-DHI
Copy link
Collaborator Author

What a pro. I'm amazed.

As for the parameters, I guess we can just reference MIke EVA manual
image

https://manuals.mikepoweredbydhi.help//2024/General/EVA_UserGuide.pdf

@daniel-caichac-DHI
Copy link
Collaborator Author

@ecomodeller don't forget about the peasants

@daniel-caichac-DHI daniel-caichac-DHI requested review from ecomodeller and removed request for jsmariegaard April 29, 2024 12:21
@daniel-caichac-DHI
Copy link
Collaborator Author

all comments addressed

Copy link
Member

@ecomodeller ecomodeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peak ratio is a very specific metric and I will assume that users of this metric are aware of the details.

df_filter["Maximum"] = df_filter.max(axis=1)
df_filter.sort_values(by="Maximum", ascending=False, inplace=True)
# Finally we do the selection of the N- largest peaks from either model or measured
df_filter = df_filter.iloc[0:top_n_peaks, :]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

top_n_peaks has to be integer for this to work. This is not always the case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daniel-caichac-DHI did you take a look at this?

@@ -543,20 +544,20 @@ def peak_ratio(
obs: pd.Series,
model: np.ndarray,
inter_event_level: float = 0.7,
AAP: int = 2,
inter_event_time="36h",
AAP: Union[int, float] = 2,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to use integer?

Suggested change
AAP: Union[int, float] = 2,
AAP: float = 2.0,

@ecomodeller ecomodeller merged commit 72d5183 into main May 8, 2024
11 checks passed
@ecomodeller ecomodeller deleted the Update_PR branch May 8, 2024 07:07
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

Successfully merging this pull request may close these issues.

2 participants