Flow Preprocessing#
This page documents the classes and functions in the flow_preprocessing module of the HydroGenerate package.
- class FlowPreProcessingParameters(minimum_turbineflow, minimum_turbineflow_percent, annual_maintenance_flag, major_maintenance_flag)#
Bases:
objectConfiguration container for flow preprocessing.
This class holds user-configurable parameters that control minimum turbine flow enforcement and maintenance scheduling. It does not perform any computations by itself; the values are consumed by
FlowPreProcessing.- Parameters:
minimum_turbineflow (float or None) – Absolute minimum turbine flow (m³/s). If provided, this overrides the percentage-based minimum flow. If
None, the minimum is computed fromminimum_turbineflow_percent(or a default of 10%).minimum_turbineflow_percent (float or int or None) – Minimum turbine flow as a percentage of
design_flow(1–100). Used only whenminimum_turbineflowisNone.annual_maintenance_flag (bool) – If
True, apply annual maintenance by setting turbine flow to zero for the lowest-flow calendar week each year (based on mean weekly flow).major_maintenance_flag (bool) – If
True, apply major maintenance by setting turbine flow to zero for the lowest-flow two-week period every five years.
Notes
These parameters are typically attached to a higher-level flow object (e.g., a project-specific container) and then read by methods in
FlowPreProcessing.
- class FlowPreProcessing#
Bases:
objectFlow preprocessing routines operating on a provided flow object.
Methods in this class update values on
flow_objin-place (most importantlyflow_obj.turbine_flow).Notes
The caller is responsible for ensuring that:
flow_obj.turbine_flowis a 1D numpy array aligned withflow_obj.datetime_index.flow_obj.datetime_indexis a pandas.DatetimeIndex whose name (or level name) is"dateTime"so thatpd.Grouper(level="dateTime", ...)works as written in the implementation.
- max_turbineflow_checker(flow_obj)#
Cap turbine flow at the design flow.
- Parameters:
flow_obj (object) –
A flow object with attributes:
turbine_flow(numpy.ndarray)design_flow(float)minimum_turbineflow(float or None)minimum_turbineflow_percent(float or None)
Notes
Updates flow_obj.turbine_flow (numpy.ndarray), where each element is min(flow, design_flow).
- min_turbineflow_checker(flow_obj)#
Enforce a minimum turbine flow threshold.
Any values in
flow_obj.turbine_flowthat fall below the computed minimum are replaced with zero.- Parameters:
flow_obj (object)
Notes
This method modifies
flow_obj.turbine_flowin place.If
flow_obj.minimum_turbineflowisNone, the minimum flow is computed as:min_flow = (minimum_turbineflow_percent / 100) * design_flow
where
minimum_turbineflow_percentdefaults to 10 if not provided.
- annual_maintenance_implementer(flow_obj)#
Apply annual maintenance by zeroing the lowest-flow week each year.
The method identifies the calendar week with the lowest mean weekly flow (aggregated across all years) and sets turbine flow to zero for that week in every year of the dataset.
- Parameters:
flow_obj (object)
Notes
This method modifies
flow_obj.turbine_flowin place.Weekly means are computed using
freq='W'and grouped by calendar week number (%W). The maintenance window spans 7 days starting on the Monday of the selected week.
- major_maintenance_implementer(flow_obj)#
Apply major maintenance by zeroing a low-flow two-week period every 5 years.
The method identifies the calendar week associated with the lowest mean two-week flow and applies a 14-day zero-flow window starting from that week in each major-maintenance year.
- Parameters:
flow_obj (object)
Notes
This method modifies
flow_obj.turbine_flowin place.Major maintenance years occur every five years starting after the first year of the dataset. Two-week means are computed using
freq='2W'.