Skip to content

[BUG] Incorrect bin counts shown in expected_power_analysis_by.plot_with_distributions #245

@ejsimley

Description

@ejsimley

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

In the function expected_power_analysis_by.plot_with_distributions, the histogram of wind direction or wind speed bins that gets plotted has the wrong bin edges and includes the wrong bin count for the last bin. This is because the bins argument passed to sns.histplot here:

https://github.com/NREL/flasc/blob/f3ed1c8ebdee32759c32e94fc0f273cf678b8290/flasc/analysis/expected_power_analysis_by.py#L390

sns.histplot(
    data=self.df_pandas, x=x_var, ax=axarr[1], bins=sorted(self.df_pandas[x_var].unique())
)

contains the bin centers instead of the bin edges. As a result, the last bin value shown contains the count for the last two wind direction or wind speed bins.

Expected Behavior

I would expect the histogram to have bin edges +/- 0.5*wd_step (or ws_step) from the bin centers, which would capture the correct count in each bin.

This could be fixed by passing the bin edges (using wd_step or ws_step) to sns.histplot, but I was thinking this could be a good opportunity to update expected_power_analysis_by.plot_with_distributions so the plots have the same format as those produced by energy_ratio_output.plot_uplift.

Steps To Reproduce

This behavior can be seen in the plots generated by t_wd.plot_with_distributions() in the examples_smarteole
/10_uplift_with_expected_power.ipynb" notebook. Note that the count shown in the last wind direction bin is greater than expected.

Environment

Anything else?

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions