Skip to content

Conversation

softwareengineerprogrammer
Copy link
Owner

@softwareengineerprogrammer softwareengineerprogrammer commented Mar 5, 2025

Closed in favor of #52 due to rebasing

…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.
@softwareengineerprogrammer softwareengineerprogrammer added the bug Something isn't working label Mar 5, 2025
@softwareengineerprogrammer softwareengineerprogrammer changed the title Extraction integration fix Surface Plant time series integrations fix (Electricity Provided + other profiles final year value correction) Mar 5, 2025
Comment on lines +12 to +32
@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

Copy link
Owner Author

@softwareengineerprogrammer softwareengineerprogrammer Mar 5, 2025

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.

@softwareengineerprogrammer softwareengineerprogrammer deleted the extraction-integration-fix branch March 7, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant