![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Structure-of-Arrays storage for all rain gages. More...
#include <GageData.hpp>
Public Member Functions | |
| int | count () const noexcept |
| Count rain gages from the source-type column. | |
| void | resize (int n) |
| Replace rain-gage configuration and runtime arrays with defaults. | |
| void | grow_to (int n) |
| Extend rain-gage arrays to a requested total while preserving their prefixes. | |
| void | erase_at (int idx) |
| Erase a gage from the columns visited by this helper. | |
| void | shrink_to_fit () |
| Release excess vector capacity accumulated during parsing. | |
| void | reset_state () noexcept |
| Clear dynamic rain values, state-machine cursors and antecedent history. | |
Public Attributes | |
| std::vector< int > | rain_type |
| Rain data type: 0=INTENSITY, 1=VOLUME, 2=CUMULATIVE. | |
| std::vector< RainSource > | source |
| Precipitation source (TIMESERIES or FILE). | |
| std::vector< int > | ts_index |
| Time series index (when source == TIMESERIES). | |
| std::vector< FilePathPair > | file_path |
| External rain file path (when source == FILE_RAIN). | |
| std::vector< std::string > | ts_name |
| Timeseries name (for deferred resolution when TS parsed after gages). | |
| std::vector< std::string > | col_name |
| Column name in the external multi-column file (source == FILE_RAIN). | |
| std::vector< std::string > | station_id |
| Station ID for a standard SWMM rain file (when source == FILE_RAIN). | |
| std::vector< int > | rain_units |
| Rain depth units declared in the [RAINGAGES] FILE row: 0 = IN, 1 = MM. | |
| std::vector< double > | file_first_date |
| First record date found for this gage's station (OADate, 0 = none). | |
| std::vector< double > | file_last_date |
| Last record date found for this gage's station (OADate, 0 = none). | |
| std::vector< long > | file_periods_precip |
| Number of records with precipitation > 0 for this station. | |
| std::vector< double > | file_start_date |
[RAINGAGES] FILE StartDate (OADate day, 0 = none / *). | |
| std::vector< Table > | rain_series |
| Resolved rainfall series for a FILE_RAIN gage (full file record). | |
| std::vector< RainFileFormat > | file_format |
| Rain file format. | |
| std::vector< int > | interval_sec |
| Recording interval in seconds. | |
| std::vector< double > | snow_factor |
| Snow catch deficiency correction factor (1.0 = no correction). | |
| std::vector< double > | scale_factor |
| Rainfall scaling factor (1.0 = no scaling). | |
| std::vector< double > | rainfall |
| Current rainfall rate (project length/time units — inches or mm/hr). | |
| std::vector< double > | next_rainfall |
| Rainfall rate at the next recorded interval (for interpolation). | |
| std::vector< double > | api_rainfall |
| Current API (antecedent precipitation index) rainfall. | |
| std::vector< double > | next_rain_date |
| Simulation time of the next recorded value (decimal days). | |
| std::vector< bool > | is_raining |
| Current state flag (0 = no rain, 1 = raining). | |
| std::vector< int > | st_cur |
| Legacy rain-gage state machine (gage_initState / gage_setState / getNextRainfall), kept as record indices on the gage's series and advanced by updateAllGages(): | |
| std::vector< int > | st_next |
| std::vector< double > | st_rain |
| std::vector< uint8_t > | st_init |
| std::vector< uint8_t > | st_used |
| std::vector< double > | past_rain |
| Flat 2D: [gage * MAXPASTRAIN + hour]. Hourly rain totals. | |
| std::vector< double > | past_rain_accum |
| Per-gage accumulator for the current partial hour. | |
| std::vector< double > | past_rain_interval |
| Per-gage seconds in the current partial hour (0..3600). | |
| std::vector< double > | cumul_rain_accum |
| Gap #31: Cumulative rainfall accumulator (project rain units). | |
| std::vector< std::string > | comments |
| Object comment from the INP file (';'-prefixed lines immediately above this gage's data row), joined by literal "\\n". Empty string means no comment. | |
| std::vector< int > | co_gage_index |
| Gap #53: Co-gage index — index of the primary gage sharing the same timeseries, or -1 if this gage reads independently. | |
Static Public Attributes | |
| static constexpr int | MAXPASTRAIN = 48 |
| Max past hours tracked per gage. | |
Structure-of-Arrays storage for all rain gages.
The col_name field supports the new multi-column CSV format (R08):
|
inlinenoexcept |
Count rain gages from the source-type column.
|
inline |
Erase a gage from the columns visited by this helper.
Each ordinary column is erased only if it contains idx; past_rain removes its full MAXPASTRAIN stride when present. station_id, rain_units, file_first_date/file_last_date/file_periods_precip and rain_series are not visited by the current implementation. Caller repairs these, spatial/name indexes, co-gage references and dependent subcatchments separately.
| [in] | idx | Caller-validated existing gage index with aligned hourly history; no overall index guard. |
|
inline |
Extend rain-gage arrays to a requested total while preserving their prefixes.
Appends all default gage fields and extends the flat hourly history to n*MAXPASTRAIN. May add multiple gages. Assumes existing columns aligned; allocation failure is not rolled back. Does not add names or spatial rows.
| [in] | n | Requested total count; <=count() is a no-op, including negative inputs. |
|
inlinenoexcept |
Clear dynamic rain values, state-machine cursors and antecedent history.
Restores API override=-1, cursor sentinels -2/-1 and initialization/use flags false. Preserves static source/file/table records and co-gage mapping. next_rain_date is unchanged; runtime initialization must reseed timing. Sizes/capacities are retained.
|
inline |
Replace rain-gage configuration and runtime arrays with defaults.
Defaults TIMESERIES source, unresolved table/co-gage indices, hourly intervals, unit scale/snow factors, empty file/text/table records and zero rain histories. API override=-1 and state-machine cursors=-2/-1. Counts/names are caller-managed; allocations can leave partial column replacement.
| [in] | n | Nonnegative gage count; n*MAXPASTRAIN must fit size_t. |
|
inline |
Release excess vector capacity accumulated during parsing.
| std::vector<double> openswmm::GageData::api_rainfall |
Current API (antecedent precipitation index) rainfall.
| std::vector<int> openswmm::GageData::co_gage_index |
Gap #53: Co-gage index — index of the primary gage sharing the same timeseries, or -1 if this gage reads independently.
When two gages use the same TIMESERIES source and the same ts_index, the later gage copies its rainfall from the earlier one (the primary). Matches legacy Gage[i].coGage.
| std::vector<std::string> openswmm::GageData::col_name |
Column name in the external multi-column file (source == FILE_RAIN).
New in 6.0.0 — supports "FILE path.csv:COLUMN_NAME" syntax (R08) for multi-column CSV/TSV/TSF files (format auto-detected). Empty string means use the first/only data column.
| std::vector<std::string> openswmm::GageData::comments |
Object comment from the INP file (';'-prefixed lines immediately above this gage's data row), joined by literal "\\n". Empty string means no comment.
| std::vector<double> openswmm::GageData::cumul_rain_accum |
Gap #31: Cumulative rainfall accumulator (project rain units).
Tracks the previous raw cumulative value so the delta can be computed each timestep. Initialised to 0. Matches legacy Gage[i].rainAccum.
| std::vector<double> openswmm::GageData::file_first_date |
First record date found for this gage's station (OADate, 0 = none).
| std::vector<RainFileFormat> openswmm::GageData::file_format |
Rain file format.
| std::vector<double> openswmm::GageData::file_last_date |
Last record date found for this gage's station (OADate, 0 = none).
| std::vector<FilePathPair> openswmm::GageData::file_path |
External rain file path (when source == FILE_RAIN).
Per-gage {absolute, original} carrier — see core/FilePathPair.hpp. Implicit std::string interface keeps existing readers/writers working unchanged.
| std::vector<long> openswmm::GageData::file_periods_precip |
Number of records with precipitation > 0 for this station.
| std::vector<double> openswmm::GageData::file_start_date |
[RAINGAGES] FILE StartDate (OADate day, 0 = none / *).
File records dated before this day are skipped entirely, as legacy rain.c readStdLine / readNWSLine do (date1 < day1).
| std::vector<int> openswmm::GageData::interval_sec |
Recording interval in seconds.
| std::vector<bool> openswmm::GageData::is_raining |
Current state flag (0 = no rain, 1 = raining).
|
staticconstexpr |
Max past hours tracked per gage.
| std::vector<double> openswmm::GageData::next_rain_date |
Simulation time of the next recorded value (decimal days).
| std::vector<double> openswmm::GageData::next_rainfall |
Rainfall rate at the next recorded interval (for interpolation).
| std::vector<double> openswmm::GageData::past_rain |
Flat 2D: [gage * MAXPASTRAIN + hour]. Hourly rain totals.
| std::vector<double> openswmm::GageData::past_rain_accum |
Per-gage accumulator for the current partial hour.
| std::vector<double> openswmm::GageData::past_rain_interval |
Per-gage seconds in the current partial hour (0..3600).
| std::vector<Table> openswmm::GageData::rain_series |
Resolved rainfall series for a FILE_RAIN gage (full file record).
Populated by load_external_rain_files() with the station's records accepted by the file filters, already converted to the project's rain depth units. Reusing a Table gives the runtime the same cursor/step-function lookup as an inline [TIMESERIES] gage, without polluting ctx.tables (so INP round-trips still emit FILE). Empty unless source == FILE_RAIN.
| std::vector<int> openswmm::GageData::rain_type |
Rain data type: 0=INTENSITY, 1=VOLUME, 2=CUMULATIVE.
| std::vector<int> openswmm::GageData::rain_units |
Rain depth units declared in the [RAINGAGES] FILE row: 0 = IN, 1 = MM.
Used to convert the file's raw depths into the project's rain units when the file units differ from the unit system.
| std::vector<double> openswmm::GageData::rainfall |
| std::vector<double> openswmm::GageData::scale_factor |
Rainfall scaling factor (1.0 = no scaling).
Multiplies the gage's converted rainfall intensity after the rain-type conversion (INTENSITY/VOLUME/CUMULATIVE) and unit conversion. For co-gages sharing a timeseries, the secondary gage's rainfall is scaled by scale_factor[secondary] / scale_factor[primary] so the primary's already-applied factor is removed and the secondary's substituted.
| std::vector<double> openswmm::GageData::snow_factor |
Snow catch deficiency correction factor (1.0 = no correction).
| std::vector<RainSource> openswmm::GageData::source |
Precipitation source (TIMESERIES or FILE).
| std::vector<int> openswmm::GageData::st_cur |
Legacy rain-gage state machine (gage_initState / gage_setState / getNextRainfall), kept as record indices on the gage's series and advanced by updateAllGages():
| std::vector<uint8_t> openswmm::GageData::st_init |
| std::vector<int> openswmm::GageData::st_next |
| std::vector<double> openswmm::GageData::st_rain |
| std::vector<uint8_t> openswmm::GageData::st_used |
| std::vector<std::string> openswmm::GageData::station_id |
Station ID for a standard SWMM rain file (when source == FILE_RAIN).
The [RAINGAGES] FILE grammar is Name Format Interval SCF FILE Fname Station Units [Start] [SCF]. A single rain file may hold many stations; this ID selects the rows whose first token matches. Empty means "accept all rows".
| std::vector<int> openswmm::GageData::ts_index |
Time series index (when source == TIMESERIES).
| std::vector<std::string> openswmm::GageData::ts_name |
Timeseries name (for deferred resolution when TS parsed after gages).