Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/whatsnew/v0.2.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Bug Fixes
* Remove freq parameter from :py:func:`pvanalytics.quality.gaps.completeness`
and :py:func:`pvanalytics.quality.gaps.completeness_score`. Frequency is now
always calculated from the input data's DatetimeIndex. (:pull:`236`)
* Suppress divide-by-zero warnings in
:mod:`pvanalytics.features.snow` and precision-loss warnings in
:mod:`pvanalytics.quality.outliers` by extending ``np.errstate`` to
include ``invalid='ignore'``. (:issue:`#237`, :pull:`YYY`)

Requirements
~~~~~~~~~~~~
Expand All @@ -39,3 +43,4 @@ Testing
Contributors
~~~~~~~~~~~~
* Cliff Hansen (:ghuser:`cwhanse`)
* Omesh Chandure (:ghuser: `Omesh37`)
2 changes: 1 addition & 1 deletion pvanalytics/features/snow.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def categorize(transmission, measured_voltage,
modeled_voltage_with_snow_copy = np.where(
transmission == 0, 0, modeled_voltage_with_snow)

with np.errstate(divide='ignore'):
with np.errstate(divide='ignore', invalid='ignore'):
vmp_ratio =\
measured_voltage /\
modeled_voltage_with_snow_copy
Expand Down
4 changes: 3 additions & 1 deletion pvanalytics/quality/outliers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Functions for identifying and labeling outliers."""
import pandas as pd
import numpy as np
from scipy import stats
from statsmodels import robust

Expand Down Expand Up @@ -75,7 +76,8 @@ def zscore(data, zmax=1.5, nan_policy='raise'):
"nan_policy. Expected 'raise' or 'omit'.")

is_outlier = pd.Series(False, index=data.index)
is_outlier.loc[~nan_mask] = abs(stats.zscore(data[~nan_mask])) > zmax
with np.errstate(invalid='ignore'):
is_outlier.loc[~nan_mask] = abs(stats.zscore(data[~nan_mask])) > zmax
return is_outlier


Expand Down
5 changes: 4 additions & 1 deletion pvanalytics/util/_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,7 @@ def _quartic(x, a, b, c, e):
)
model = _quartic(x, params[0], params[1], params[2], params[3])
residuals = y - model
return 1 - (np.sum(residuals**2) / np.sum((y - np.mean(y))**2))
ss_tot = np.sum((y - np.mean(y))**2)
if ss_tot == 0:
return 0.0
return 1 - (np.sum(residuals**2) / ss_tot)
Loading