Skip to content

Commit

Permalink
Merge pull request #247 from NREL/patch_development_with_2.0.4
Browse files Browse the repository at this point in the history
Fix leading nans bug in _aggregate (#245)
  • Loading branch information
mdeceglie authored Dec 5, 2020
2 parents a4987a1 + 2ed33f8 commit 39993fc
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 15 deletions.
26 changes: 13 additions & 13 deletions docs/degradation_and_soiling_example.ipynb

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions docs/sphinx/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
RdTools Change Log
==================

.. include:: changelog/v2.0.4.rst
.. include:: changelog/v2.1.0-beta.0.rst
.. include:: changelog/v2.0.3.rst
.. include:: changelog/v2.0.2.rst
.. include:: changelog/v2.0.1.rst
.. include:: changelog/v2.0.0.rst
.. include:: changelog/pre_2.0.0.rst


14 changes: 14 additions & 0 deletions docs/sphinx/source/changelog/v2.0.4.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*******************************************
v2.0.4 and v2.1.0-beta.1 (December 4, 2020)
*******************************************

Bug Fixes
---------
* Fix bug related to leading NaN values with
:py:func:`~rdtools.normalization.energy_from_power`. This fixed a small
normalization error in ``degradation_and_soiling_example.ipynb`` and
slightly changed the clear-sky degradation results (:issue:`244`, :pull:`245`)

Contributors
------------
* Kevin Anderson (:ghuser:`kanderso-nrel`)
3 changes: 3 additions & 0 deletions rdtools/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,9 @@ def _aggregate(time_series, target_frequency, max_timedelta, series_type):
max_interval_nanoseconds = max_timedelta.total_seconds() * 10.0**9

gap_mask = t_diffs > max_interval_nanoseconds
if time_series.index[0] != union_index[0]:
# mask leading NaNs
gap_mask[:time_series.index[0]] = True

time_series = time_series.reindex(union_index)
t_diffs = np.diff(time_series.index.astype('int64').values)
Expand Down
9 changes: 9 additions & 0 deletions rdtools/test/energy_from_power_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,12 @@ def test_energy_from_power_single_value_with_target():
expected_result = pd.Series([100.], index=times, name='energy_Wh')
result = energy_from_power(power, target_frequency='H')
pd.testing.assert_series_equal(result, expected_result)

def test_energy_from_power_leading_nans():
# GH 244
power = pd.Series(1, pd.date_range('2019-01-01', freq='15min', periods=5))
power.iloc[:2] = np.nan
expected_result = pd.Series([np.nan, np.nan, 0.25, 0.25],
index=power.index[1:], name='energy_Wh')
result = energy_from_power(power)
pd.testing.assert_series_equal(result, expected_result)

0 comments on commit 39993fc

Please sign in to comment.