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

Fix issue #370 (energy_from_power returns incorrect index for shifted hourly data) #437

Open
wants to merge 9 commits into
base: development
Choose a base branch
from
3 changes: 2 additions & 1 deletion docs/sphinx/source/changelog/v3.0.0-beta.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Enhancements
* Added codecov.yml configuration file (:pull:`420`)
* Availability module no longer considered experimental (:pull:`429`)
* Add capability to seed the CircularBlockBootstrap (:pull:`429`)
* Allow sub-daily aggregation in :py:func:`~rdtools.degradation.degradation_year_on_year` (:pull:`390`)
* Allow sub-daily aggregation in :py:func:`~rdtools.degradation.degradation_year_on_year` (:pull:`390`)

Bug fixes
---------
Expand All @@ -31,6 +31,7 @@ Bug fixes
* Deploy workflow was replaced with trusted publisher workflow for pypi (:pull:`427`)
* Fix pandas 2.0.0 deprications and update syntax changes (:pull:`428`)
* Fix numpy 2.0.0 deprications and update syntax changes (:pull:`428`)
* Fix `energy_from_power`` returns incorrect index for shifted hourly data (:issue:`370`, :pull:`437`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's move this to a pending changelog section

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.


Tests
-----
Expand Down
16 changes: 8 additions & 8 deletions rdtools/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@ def _aggregate(time_series, target_frequency, max_timedelta, series_type):
'''

# series that has same index as desired output
output_dummy = time_series.resample(target_frequency,
closed='right',
label='right').sum()
output_dummy = time_series.resample(
target_frequency, closed="right", label="right", origin="start"
).sum()

union_index = time_series.index.union(output_dummy.index)
time_series = time_series.dropna()
Expand Down Expand Up @@ -521,13 +521,13 @@ def _aggregate(time_series, target_frequency, max_timedelta, series_type):
raise ValueError("series_type must be either 'instantaneous' or 'right_labeled', "
"not '{}'".format(series_type))

series_sum = pd.Series(data=series_sum, index=time_series.index[1:])
series_sum = pd.Series(data=np.insert(series_sum, 0, np.nan), index=time_series.index)

aggregated = series_sum.resample(target_frequency,
closed='right',
label='right').sum(min_count=1)
aggregated = series_sum.resample(
target_frequency, closed="right", label="right", origin="start"
).sum(min_count=1)

return aggregated
return aggregated[1:]


def _interpolate_series(time_series, target_index, max_timedelta=None,
Expand Down
Loading