-
Notifications
You must be signed in to change notification settings - Fork 1
Surface Plant time series integrations fix (Electricity Provided + other profiles final year value correction) #50
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
Conversation
…Wh integration (WIP)
…electricity_pumping_power. FIXME TODO WIP marked for remaining integrations to adjust.
… into SurfacePlant, SurfacePlantAGS, and SurfacePlantIndustrialHeat (other plant types remain WIP/TODO to fix still; unit tests not yet updated)
…low this commit to serve as a checkpoint that ensures unit tests are passing and results are not affected by any structural issues in refactoring.
@staticmethod | ||
def integrate_time_series_slice( | ||
series: np.ndarray, | ||
_i: int, | ||
time_steps_per_year: int, | ||
utilization_factor: float | ||
) -> np.float64: | ||
_slice = series[(0 + _i * time_steps_per_year):((_i + 1) * time_steps_per_year) + 1] | ||
|
||
# Note that len(_slice) - 1 may be less than time_steps_per_year for the last slice. | ||
|
||
if len(_slice) == 1: | ||
return _slice[0] | ||
|
||
dx_steps = len(_slice) - 1 | ||
|
||
return np.trapz( | ||
_slice, | ||
dx=1. / dx_steps * 365. * 24. | ||
) * 1000. * utilization_factor | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The crux of this fix is that the previous behavior was doing the equivalent of erroneously setting dx_steps
to time_steps_per_year
. The last slices of the time series in question always have one less data point than time_steps_per_year
, which was causing the trapezoidal rule to behave as if the slice had a 'phantom' entry with value=0 appended to it, thus lowering the estimated integral value of the slice.
Closed in favor of #52 due to rebasing