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

Quantify wind speed shift #42

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

samuelwnaylor
Copy link
Collaborator

No description provided.

- Moves Operational Curve shift calculations into their own module
- Refactor into separate curve specific functions
  (with underlying more generic private functions)

This change improves readability and ease of adding further curve shift
calculations.
In similar way that power curve, rpm and pitch shifts are already
calculated, this change adds wind speed shift to the ops curve shift
module
Display the sign (+/-) of the curve shift value in the log warning
message for clarity of the actual shift rather than just displaying the
abs() value that is used when determining whether to raise a log warning
@samuelwnaylor samuelwnaylor force-pushed the quantify-wind-speed-shift branch from a56d21c to 4fac54c Compare November 19, 2024 10:21
@samuelwnaylor samuelwnaylor marked this pull request as ready for review November 19, 2024 10:53
Copy link
Contributor

@aclerc aclerc left a comment

Choose a reason for hiding this comment

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

I am seeing some differences in integration tests, will email you with further detail. I might have found the reasons (see comments) but not totally sure. Apologies there were not unit tests for the original check_for_ops_curve_shift function you are replacing

wind_up/ops_curve_shift.py Outdated Show resolved Hide resolved
wind_up/ops_curve_shift.py Outdated Show resolved Hide resolved
Comment on lines -417 to -422
if abs(results_dict[descr]) > warn_thresh:
if warning_msg is None:
warning_msg = f"{wtg_name} check_for_ops_curve_shift warnings:"
warning_msg += f" abs({descr}) > {warn_thresh}: {abs(results_dict[descr]):.3f}"
if warning_msg is not None:
result_manager.warning(warning_msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

this logic is valuable to keep so that ops curve shifts result in a single consolidated warning, please port it to ops_curve_shift.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wind_up/ops_curve_shift.py Outdated Show resolved Hide resolved
Comment on lines -397 to -398
pre_dropna_df = pre_df.dropna(subset=[scada_ws_col, pw_col, pt_col, rpm_col]).copy()
post_dropna_df = post_df.dropna(subset=[scada_ws_col, pw_col, pt_col, rpm_col]).copy()
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not completely sure but I think this dropna logic is missing in the new ops_curve_shift.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not completely sure but I think this dropna logic is missing in the new ops_curve_shift.py

This logic is here now

self.pre_df = self.pre_df.dropna(subset=list(required_cols)).copy()

I've added NaN handling to the tests too...

NaN included in df and the assertion in a test

Required columns are necessary for all curve plot types. The required
columns for any curve plot are wind_speed, power, pitch and rpm
@samuelwnaylor samuelwnaylor force-pushed the quantify-wind-speed-shift branch from fea2710 to e6eefe7 Compare December 3, 2024 15:29
@samuelwnaylor samuelwnaylor force-pushed the quantify-wind-speed-shift branch from e02387c to eff9dfd Compare December 5, 2024 12:53
@samuelwnaylor samuelwnaylor force-pushed the quantify-wind-speed-shift branch from eff9dfd to 6045c39 Compare December 5, 2024 12:55
Copy link
Contributor

@aclerc aclerc left a comment

Choose a reason for hiding this comment

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

Maybe I am misunderstanding the commit history but it seems there are no test case changes associated with this fix 6045c39. If that's the case then I think a test relevant to this logic needs adding, ie at least one test should fail before this commit and pass after it

post_df["expected_y"] = np.interp(post_df[conf.x_col], mean_curve["x_mean"], mean_curve["y_mean"])
mean_df = post_df.mean()

if conf.name in [CurveTypes.PITCH.value, CurveTypes.PITCH]:
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like it would be better if there were exactly 1 way to identify if the curve shift calculation is for pitch. What about give conf a curvetype attribute which is type CurveTypes so you would have if conf.curve_type == CurveTypes.PITCH:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since CurveTypes inherits from str and Enum, then we could simply it to if conf.name == CurveTypes.PITCH.

@samuelwnaylor
Copy link
Collaborator Author

Maybe I am misunderstanding the commit history but it seems there are no test case changes associated with this fix 6045c39. If that's the case then I think a test relevant to this logic needs adding, ie at least one test should fail before this commit and pass after it

The tests were

Maybe I am misunderstanding the commit history but it seems there are no test case changes associated with this fix 6045c39. If that's the case then I think a test relevant to this logic needs adding, ie at least one test should fail before this commit and pass after it

The test case did not change because by chance the test case had conf.name = "pitch" and conf.y_col = "pitch". It was only when running analysis for an actual wind farm that the results were different prior to the fix in commit 6045c39.

I'll add different strings for conf.name and conf.y_col in the test case

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