OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::GageData Struct Reference

Structure-of-Arrays storage for all rain gages. More...

#include <GageData.hpp>

Collaboration diagram for openswmm::GageData:

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.
 

Detailed Description

Structure-of-Arrays storage for all rain gages.

The col_name field supports the new multi-column CSV format (R08):

[RAINGAGES]
;; Name Format Interval SCF Source
RG1 VOLUME 0:15 1.0 FILE "rain.csv:EAST_STATION"
@ VOLUME
Volume.
Definition enums.h:301
int Interval
Definition rain.c:94

Member Function Documentation

◆ count()

int openswmm::GageData::count ( ) const
inlinenoexcept

Count rain gages from the source-type column.

Returns
source.size() converted to int; no name-index or column-alignment validation.
Here is the caller graph for this function:

◆ erase_at()

void openswmm::GageData::erase_at ( int idx)
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.

Parameters
[in]idxCaller-validated existing gage index with aligned hourly history; no overall index guard.
Here is the caller graph for this function:

◆ grow_to()

void openswmm::GageData::grow_to ( int n)
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.

Parameters
[in]nRequested total count; <=count() is a no-op, including negative inputs.
Here is the call graph for this function:

◆ reset_state()

void openswmm::GageData::reset_state ( )
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.

◆ resize()

void openswmm::GageData::resize ( int n)
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.

Parameters
[in]nNonnegative gage count; n*MAXPASTRAIN must fit size_t.
Here is the caller graph for this function:

◆ shrink_to_fit()

void openswmm::GageData::shrink_to_fit ( )
inline

Release excess vector capacity accumulated during parsing.

Member Data Documentation

◆ api_rainfall

std::vector<double> openswmm::GageData::api_rainfall

Current API (antecedent precipitation index) rainfall.

See also
Legacy: Gage[i].apiRainfall

◆ co_gage_index

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.

◆ col_name

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.

◆ comments

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.

◆ cumul_rain_accum

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.

◆ file_first_date

std::vector<double> openswmm::GageData::file_first_date

First record date found for this gage's station (OADate, 0 = none).

◆ file_format

std::vector<RainFileFormat> openswmm::GageData::file_format

Rain file format.

See also
Legacy: Gage[i].fileFormat

◆ file_last_date

std::vector<double> openswmm::GageData::file_last_date

Last record date found for this gage's station (OADate, 0 = none).

◆ file_path

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.

See also
Legacy: Gage[i].fname

◆ file_periods_precip

std::vector<long> openswmm::GageData::file_periods_precip

Number of records with precipitation > 0 for this station.

◆ file_start_date

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).

◆ interval_sec

std::vector<int> openswmm::GageData::interval_sec

Recording interval in seconds.

See also
Legacy: Gage[i].rainInterval

◆ is_raining

std::vector<bool> openswmm::GageData::is_raining

Current state flag (0 = no rain, 1 = raining).

See also
Legacy: Gage[i].currentHour / isUsed logic

◆ MAXPASTRAIN

int openswmm::GageData::MAXPASTRAIN = 48
staticconstexpr

Max past hours tracked per gage.

◆ next_rain_date

std::vector<double> openswmm::GageData::next_rain_date

Simulation time of the next recorded value (decimal days).

See also
Legacy: Gage[i].nextRainDate

◆ next_rainfall

std::vector<double> openswmm::GageData::next_rainfall

Rainfall rate at the next recorded interval (for interpolation).

See also
Legacy: Gage[i].nextRainfall

◆ past_rain

std::vector<double> openswmm::GageData::past_rain

Flat 2D: [gage * MAXPASTRAIN + hour]. Hourly rain totals.

◆ past_rain_accum

std::vector<double> openswmm::GageData::past_rain_accum

Per-gage accumulator for the current partial hour.

◆ past_rain_interval

std::vector<double> openswmm::GageData::past_rain_interval

Per-gage seconds in the current partial hour (0..3600).

◆ rain_series

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.

◆ rain_type

std::vector<int> openswmm::GageData::rain_type

Rain data type: 0=INTENSITY, 1=VOLUME, 2=CUMULATIVE.

See also
Legacy: Gage[i].rainType

◆ rain_units

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.

See also
Legacy: Gage[i].rainUnits

◆ rainfall

std::vector<double> openswmm::GageData::rainfall

Current rainfall rate (project length/time units — inches or mm/hr).

See also
Legacy: Gage[i].rainfall

◆ scale_factor

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.

See also
Legacy: Gage[i].scaleFactor (Build 5.3.0+)

◆ snow_factor

std::vector<double> openswmm::GageData::snow_factor

Snow catch deficiency correction factor (1.0 = no correction).

See also
Legacy: Gage[i].snowFactor

◆ source

std::vector<RainSource> openswmm::GageData::source

Precipitation source (TIMESERIES or FILE).

◆ st_cur

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():

  • st_cur: the record legacy's startDate/endDate name — -2 while there is no state (NO_DATE: no series, empty series, IGNORE_RAINFALL, not yet initialised), -1 for the pre-record interval [StartDateTime, x0) legacy forms when the record begins after the simulation start, else a record index (the FIRST record whatever its value, afterwards only records with a non-zero rate: getNextRainfall skips zero rates);
  • st_next: the record legacy's nextDate/nextRainfall name, -1 for NO_DATE;
  • st_rain: legacy Gage.rainfall as the machine last left it (0 in a gap, the current record's rate otherwise), the value gage_setReportRainfall reads; user rain units with the units and scale factors, before the monthly rain adjustment.
  • st_init: the machine has been seeded (lazily, on the first update, from the simulation start date); st_used: legacy Gage.isUsed as found then — an unused gage's machine never advances and its rainfall keeps the seeded value (legacy gage_setState returns at once; runoff_execute still reads Gage.rainfall for IsRaining).
    See also
    Legacy: gage_initState, gage_setState, getNextRainfall, gage_getNextRainDate, gage_setReportRainfall

◆ st_init

std::vector<uint8_t> openswmm::GageData::st_init

◆ st_next

std::vector<int> openswmm::GageData::st_next

◆ st_rain

std::vector<double> openswmm::GageData::st_rain

◆ st_used

std::vector<uint8_t> openswmm::GageData::st_used

◆ station_id

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".

See also
Legacy: Gage[i].staID

◆ ts_index

std::vector<int> openswmm::GageData::ts_index

Time series index (when source == TIMESERIES).

See also
Legacy: Gage[i].tSeries

◆ ts_name

std::vector<std::string> openswmm::GageData::ts_name

Timeseries name (for deferred resolution when TS parsed after gages).


The documentation for this struct was generated from the following file: