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

Error generating AEP histograms using GAM Model #291

Open
ajayxcel opened this issue Apr 23, 2024 · 1 comment
Open

Error generating AEP histograms using GAM Model #291

ajayxcel opened this issue Apr 23, 2024 · 1 comment

Comments

@ajayxcel
Copy link

ajayxcel commented Apr 23, 2024

Hi Sir, I have faced an error while trying to plot histograms for AEP using GAM Model (02c_augmented_aep_analysis). In the plant data for the availability, I have taken negative availability as 'Zero' and left everything as it is for positive availability. If the availability loss is positive at the negative net energy timestamps, then the error occurs while generating GAM AEP histograms. If availability loss is zero for negative net energy timestamps, the error disappears. Does using zero availability loss at negative net energy impact the results? Or is it the condition that availability loss should be zero when net energy is negative?
I have attached error for your reference. Thak you!

ValueError                                Traceback (most recent call last)
Cell In[50], line 2
      1 # Plot a distribution of AEP values from the Monte-Carlo OA method - gam model
----> 2 aep_gam.plot_result_aep_distributions()

File ~\AppData\Local\anaconda3\envs\openoa-env\lib\site-packages\openoa\analysis\aep.py:1456, in MonteCarloAEP.plot_result_aep_distributions(self, xlim_aep, xlim_availability, xlim_curtail, ylim_aep, ylim_availability, ylim_curtail, return_fig, figure_kwargs, plot_kwargs, annotate_kwargs)
   1454 plot_results = self.results.copy()
   1455 plot_results[["avail_pct", "curt_pct"]] = plot_results[["avail_pct", "curt_pct"]] * 100
-> 1456 return plot.plot_distributions(
   1457     data=plot_results,
   1458     which=["aep_GWh", "avail_pct", "curt_pct"],
   1459     xlabels=["AEP (GWh/yr)", "Availability Loss (%)", "Curtailment Loss (%)"],
   1460     xlim=(xlim_aep, xlim_availability, xlim_curtail),
   1461     ylim=(ylim_aep, ylim_availability, ylim_curtail),
   1462     return_fig=return_fig,
   1463     figure_kwargs=figure_kwargs,
   1464     plot_kwargs=plot_kwargs,
   1465     annotate_kwargs=annotate_kwargs,
   1466 )

File ~\AppData\Local\anaconda3\envs\openoa-env\lib\site-packages\openoa\utils\plot.py:726, in plot_distributions(data, which, xlabels, xlim, ylim, return_fig, figure_kwargs, plot_kwargs, annotate_kwargs, title)
    724 vals = data[col].values
    725 u_vals = vals.mean()
--> 726 ax.hist(vals, 40, density=1, **plot_kwargs)
    727 ax.annotate(
    728     f"Mean = {u_vals:.1f}",
    729     (0.05, 0.9),
    730     xycoords="axes fraction",
    731     **annotate_kwargs,
    732 )
    733 uncertainty = (vals.std() / u_vals) if u_vals != 0.0 else 0.0

File ~\AppData\Local\anaconda3\envs\openoa-env\lib\site-packages\matplotlib\__init__.py:1478, in _preprocess_data.<locals>.inner(ax, data, *args, **kwargs)
   1475 @functools.wraps(func)
   1476 def inner(ax, *args, data=None, **kwargs):
   1477     if data is None:
-> 1478         return func(ax, *map(sanitize_sequence, args), **kwargs)
   1480     bound = new_sig.bind(ax, *args, **kwargs)
   1481     auto_label = (bound.arguments.get(label_namer)
   1482                   or bound.kwargs.get(label_namer))

File ~\AppData\Local\anaconda3\envs\openoa-env\lib\site-packages\matplotlib\axes\_axes.py:6862, in Axes.hist(self, x, bins, range, density, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs)
   6858 # Loop through datasets
   6859 for i in range(nx):
   6860     # this will automatically overwrite bins,
   6861     # so that each histogram uses the same bins
-> 6862     m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs)
   6863     tops.append(m)
   6864 tops = np.array(tops, float)  # causes problems later if it's an int

File ~\AppData\Local\anaconda3\envs\openoa-env\lib\site-packages\numpy\lib\histograms.py:780, in histogram(a, bins, range, density, weights)
    680 r"""
    681 Compute the histogram of a dataset.
    682 
   (...)
    776 
    777 """
    778 a, weights = _ravel_and_check_weights(a, weights)
--> 780 bin_edges, uniform_bins = _get_bin_edges(a, bins, range, weights)
    782 # Histogram is an integer or a float array depending on the weights.
    783 if weights is None:

File ~\AppData\Local\anaconda3\envs\openoa-env\lib\site-packages\numpy\lib\histograms.py:426, in _get_bin_edges(a, bins, range, weights)
    423     if n_equal_bins < 1:
    424         raise ValueError('`bins` must be positive, when an integer')
--> 426     first_edge, last_edge = _get_outer_edges(a, range)
    428 elif np.ndim(bins) == 1:
    429     bin_edges = np.asarray(bins)

File ~\AppData\Local\anaconda3\envs\openoa-env\lib\site-packages\numpy\lib\histograms.py:315, in _get_outer_edges(a, range)
    312         raise ValueError(
    313             'max must be larger than min in range parameter.')
    314     if not (np.isfinite(first_edge) and np.isfinite(last_edge)):
--> 315         raise ValueError(
    316             "supplied range of [{}, {}] is not finite".format(first_edge, last_edge))
    317 elif a.size == 0:
    318     # handle empty arrays. Can't determine range, so use 0-1.
    319     first_edge, last_edge = 0, 1

ValueError: supplied range of [-inf, -inf] is not finite
@RHammond2
Copy link
Collaborator

Hi @ajayxcel I would need to see the values being passed to the histogram method as it appears some of the results themselves are invalid data. Do you have more information to replicate this error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants