NGen
Loading...
Searching...
No Matches
CsvPerFeatureForcingProvider Class Referenceabstract

Forcing class providing time-series precipiation forcing data to the model. More...

#include <CsvPerFeatureForcingProvider.hpp>

+ Inheritance diagram for CsvPerFeatureForcingProvider:
+ Collaboration diagram for CsvPerFeatureForcingProvider:

Public Types

typedef struct tm time_type
 
using data_type = DataType
 This class provides a generic interface to data services.
 
using selection_type = SelectionType
 

Public Member Functions

 CsvPerFeatureForcingProvider (forcing_params forcing_config)
 
long get_data_start_time () const override
 the inclusive beginning of the period of time over which this instance can provide data for this forcing.
 
long get_data_stop_time () const override
 the exclusive ending of the period of time over which this instance can provide data for this forcing.
 
long record_duration () const override
 the duration of one record of this forcing source
 
size_t get_ts_index_for_time (const time_t &epoch_time) const override
 Get the index of the forcing time step that contains the given point in time.
 
double get_value (const CatchmentAggrDataSelector &selector, data_access::ReSampleMethod m) override
 Get the value of a forcing property for an arbitrary time period, converting units if needed.
 
virtual std::vector< double > get_values (const CatchmentAggrDataSelector &selector, data_access::ReSampleMethod m) override
 
bool is_param_sum_over_time_step (const std::string &name) const
 Get whether a param's value is an aggregate sum over the entire time step.
 
bool is_property_sum_over_time_step (const std::string &name) const override
 Get whether a property's per-time-step values are each an aggregate sum over the entire time step.
 
boost::span< const std::string > get_available_variable_names () const override
 Return the variables that are accessable by this data provider.
 
virtual void finalize ()
 Release any resources that should not be held as the run is shutting down.
 
virtual data_type get_value (const selection_type &selector, ReSampleMethod m=SUM)=0
 Get the value of a forcing property for an arbitrary time period, converting units if needed.
 
virtual std::vector< data_typeget_values (const selection_type &selector, ReSampleMethod m=SUM)=0
 Get the values of a forcing property for an arbitrary time period, converting units if needed.
 

Private Member Functions

void check_forcing_vector_index_bounds ()
 Checks forcing vector index bounds and adjusts index if out of vector bounds ///.
 
double get_value_for_param_name (const std::string &name, int index)
 Get the current value of a forcing param identified by its name.
 
void read_csv (std::string file_name)
 Read Forcing Data from CSV Reads only data within the specified model start and end date-times.
 

Private Attributes

std::vector< std::string > available_forcings
 
std::unordered_map< std::string, std::string > available_forcings_units
 
std::unordered_map< std::string, std::vector< double > > forcing_vectors
 
std::vector< time_t > time_epoch_vector
 
int forcing_vector_index
 
double precipitation_rate_meters_per_second
 
double air_temperature_fahrenheit
 
double latitude
 
double longitude
 
int catchment_id
 
int day_of_year
 
std::string forcing_file_name
 
time_t start_date_time_epoch
 
time_t end_date_time_epoch
 
time_t current_date_time_epoch
 

Detailed Description

Forcing class providing time-series precipiation forcing data to the model.

Member Typedef Documentation

◆ data_type

template<class DataType , class SelectionType >
using data_access::DataProvider< DataType, SelectionType >::data_type = DataType
inherited

This class provides a generic interface to data services.

◆ selection_type

template<class DataType , class SelectionType >
using data_access::DataProvider< DataType, SelectionType >::selection_type = SelectionType
inherited

◆ time_type

Constructor & Destructor Documentation

◆ CsvPerFeatureForcingProvider()

CsvPerFeatureForcingProvider::CsvPerFeatureForcingProvider ( forcing_params forcing_config)
inline

References forcing_params::path, and read_csv().

Member Function Documentation

◆ check_forcing_vector_index_bounds()

void CsvPerFeatureForcingProvider::check_forcing_vector_index_bounds ( )
inlineprivate

Checks forcing vector index bounds and adjusts index if out of vector bounds ///.

Todo
: Bounds checking is based on precipitation vector. Consider potential for vectors of different sizes and indices.
Todo
: Return appropriate warning
Todo
: Return appropriate warning

References forcing_vector_index, and time_epoch_vector.

◆ finalize()

template<class DataType , class SelectionType >
virtual void data_access::DataProvider< DataType, SelectionType >::finalize ( )
inlinevirtualinherited

Release any resources that should not be held as the run is shutting down.

In particular, this should be called before MPI_Finalize()

Reimplemented in data_access::WrappedDataProvider.

◆ get_available_variable_names()

boost::span< const std::string > CsvPerFeatureForcingProvider::get_available_variable_names ( ) const
inlineoverridevirtual

Return the variables that are accessable by this data provider.

Implements data_access::DataProvider< DataType, SelectionType >.

References available_forcings.

◆ get_data_start_time()

long CsvPerFeatureForcingProvider::get_data_start_time ( ) const
inlineoverridevirtual

the inclusive beginning of the period of time over which this instance can provide data for this forcing.

Returns
The inclusive beginning of the period of time over which this instance can provide this data.

Implements data_access::DataProvider< DataType, SelectionType >.

References start_date_time_epoch.

◆ get_data_stop_time()

long CsvPerFeatureForcingProvider::get_data_stop_time ( ) const
inlineoverridevirtual

the exclusive ending of the period of time over which this instance can provide data for this forcing.

Returns
The exclusive ending of the period of time over which this instance can provide this data.

Implements data_access::DataProvider< DataType, SelectionType >.

References end_date_time_epoch.

◆ get_ts_index_for_time()

size_t CsvPerFeatureForcingProvider::get_ts_index_for_time ( const time_t & epoch_time) const
inlineoverridevirtual

Get the index of the forcing time step that contains the given point in time.

An std::out_of_range exception should be thrown if the time is not in any time step.

Parameters
epoch_timeThe point in time, as a seconds-based epoch time.
Returns
The index of the forcing time step that contains the given point in time.
Exceptions
std::out_of_rangeIf the given point is not in any time step.

Implements data_access::DataProvider< DataType, SelectionType >.

References end_date_time_epoch, and start_date_time_epoch.

Referenced by get_value().

◆ get_value() [1/2]

double CsvPerFeatureForcingProvider::get_value ( const CatchmentAggrDataSelector & selector,
data_access::ReSampleMethod m )
inlineoverride

Get the value of a forcing property for an arbitrary time period, converting units if needed.

An std::out_of_range exception should be thrown if the data for the time period is not available.

Parameters
selectorObject storing information about the data to be queried
mmethode to resample data if needed
Returns
The value of the forcing property for the described time period, with units converted if needed.
Exceptions
std::out_of_rangeIf data for the time period is not available.

References available_forcings_units, UnitsHelper::get_converted_value(), CatchmentAggrDataSelector::get_duration_secs(), CatchmentAggrDataSelector::get_init_time(), CatchmentAggrDataSelector::get_output_units(), get_ts_index_for_time(), get_value_for_param_name(), CatchmentAggrDataSelector::get_variable_name(), is_param_sum_over_time_step(), start_date_time_epoch, and time_epoch_vector.

Referenced by get_values().

◆ get_value() [2/2]

template<class DataType , class SelectionType >
virtual data_type data_access::DataProvider< DataType, SelectionType >::get_value ( const selection_type & selector,
ReSampleMethod m = SUM )
pure virtualinherited

Get the value of a forcing property for an arbitrary time period, converting units if needed.

An std::out_of_range exception should be thrown if the data for the time period is not available.

Parameters
selectorData required to establish what subset of the stored data should be accessed
mHow data is to be resampled if there is a mismatch in data alignment or repeat rate
Returns
The value of the forcing property for the described time period, with units converted if needed.
Exceptions
std::out_of_rangeIf data for the time period is not available.

Referenced by data_access::WrappedDataProvider::get_value(), and realization::Bmi_Module_Formulation::set_model_inputs_prior_to_update().

◆ get_value_for_param_name()

double CsvPerFeatureForcingProvider::get_value_for_param_name ( const std::string & name,
int index )
inlineprivate

Get the current value of a forcing param identified by its name.

Parameters
nameThe name of the forcing param for which the current value is desired.
indexThe index of the desired forcing time step from which to obtain the value.
Returns
The particular param's value at the given forcing time step.

References forcing_vectors, time_epoch_vector, and data_access::WellKnownFields.

Referenced by get_value().

◆ get_values() [1/2]

virtual std::vector< double > CsvPerFeatureForcingProvider::get_values ( const CatchmentAggrDataSelector & selector,
data_access::ReSampleMethod m )
inlineoverridevirtual

References get_value().

◆ get_values() [2/2]

template<class DataType , class SelectionType >
virtual std::vector< data_type > data_access::DataProvider< DataType, SelectionType >::get_values ( const selection_type & selector,
ReSampleMethod m = SUM )
pure virtualinherited

Get the values of a forcing property for an arbitrary time period, converting units if needed.

An std::out_of_range exception should be thrown if the data for the time period is not available.

If a provider doesn't implement this function, then by default, get_values will be a simple proxy to get_value with the result wrapped in a std::vector<double>

Parameters
output_nameThe name of the forcing property of interest.
init_time_epochThe epoch time (in seconds) of the start of the time period.
duration_secondsThe length of the time period, in seconds.
output_unitsThe expected units of the desired output value.
Returns
std::vector<double> The vector of values of the forcing property for the described time period, with units converted if needed.
Exceptions
std::out_of_rangeIf data for the time period is not available.

Referenced by data_access::WrappedDataProvider::get_values(), and realization::Bmi_Module_Formulation::set_model_inputs_prior_to_update().

◆ is_param_sum_over_time_step()

bool CsvPerFeatureForcingProvider::is_param_sum_over_time_step ( const std::string & name) const
inline

Get whether a param's value is an aggregate sum over the entire time step.

Certain params, like rain fall, are aggregated sums over an entire time step. Others, such as pressure, are not such sums and instead something else like an instantaneous reading or an average value over the time step.

It may be the case that forcing data is needed for some discretization different than the forcing time step. These values can be calculated (or at least approximated), but doing so requires knowing which values are summed versus not.

Parameters
nameThe name of the forcing param for which the current value is desired.
Returns
Whether the param's value is an aggregate sum.

Referenced by get_value(), and is_property_sum_over_time_step().

◆ is_property_sum_over_time_step()

bool CsvPerFeatureForcingProvider::is_property_sum_over_time_step ( const std::string & name) const
inlineoverridevirtual

Get whether a property's per-time-step values are each an aggregate sum over the entire time step.

Certain properties, like rain fall, are aggregated sums over an entire time step. Others, such as pressure, are not such sums and instead something else like an instantaneous reading or an average value.

It may be the case that forcing data is needed for some discretization different than the forcing time step. This aspect must be known in such cases to perform the appropriate value interpolation.

Parameters
nameThe name of the forcing property for which the current value is desired.
Returns
Whether the property's value is an aggregate sum.

Reimplemented from data_access::DataProvider< DataType, SelectionType >.

References is_param_sum_over_time_step().

◆ read_csv()

void CsvPerFeatureForcingProvider::read_csv ( std::string file_name)
inlineprivate

Read Forcing Data from CSV Reads only data within the specified model start and end date-times.

Parameters
file_nameForcing file name
Todo
TODO: Return appropriate error

References available_forcings, available_forcings_units, end_date_time_epoch, forcing_vectors, CSVReader::getData(), start_date_time_epoch, time_epoch_vector, and data_access::WellKnownFields.

Referenced by CsvPerFeatureForcingProvider().

◆ record_duration()

long CsvPerFeatureForcingProvider::record_duration ( ) const
inlineoverridevirtual

the duration of one record of this forcing source

Returns
The duration of one record of this forcing source

Implements data_access::DataProvider< DataType, SelectionType >.

References time_epoch_vector.

Member Data Documentation

◆ air_temperature_fahrenheit

double CsvPerFeatureForcingProvider::air_temperature_fahrenheit
private

◆ available_forcings

std::vector<std::string> CsvPerFeatureForcingProvider::available_forcings
private

◆ available_forcings_units

std::unordered_map<std::string, std::string> CsvPerFeatureForcingProvider::available_forcings_units
private

Referenced by get_value(), and read_csv().

◆ catchment_id

int CsvPerFeatureForcingProvider::catchment_id
private

◆ current_date_time_epoch

time_t CsvPerFeatureForcingProvider::current_date_time_epoch
private

◆ day_of_year

int CsvPerFeatureForcingProvider::day_of_year
private

◆ end_date_time_epoch

time_t CsvPerFeatureForcingProvider::end_date_time_epoch
private

◆ forcing_file_name

std::string CsvPerFeatureForcingProvider::forcing_file_name
private

◆ forcing_vector_index

int CsvPerFeatureForcingProvider::forcing_vector_index
private

◆ forcing_vectors

std::unordered_map<std::string, std::vector<double> > CsvPerFeatureForcingProvider::forcing_vectors
private
Todo
: Look into aggregation of data, relevant libraries, and storing frequency information

Referenced by get_value_for_param_name(), and read_csv().

◆ latitude

double CsvPerFeatureForcingProvider::latitude
private

◆ longitude

double CsvPerFeatureForcingProvider::longitude
private

◆ precipitation_rate_meters_per_second

double CsvPerFeatureForcingProvider::precipitation_rate_meters_per_second
private
Todo
: Are these used?

◆ start_date_time_epoch

time_t CsvPerFeatureForcingProvider::start_date_time_epoch
private

◆ time_epoch_vector

std::vector<time_t> CsvPerFeatureForcingProvider::time_epoch_vector
private
Todo
: Consider making epoch time the iterator

Referenced by check_forcing_vector_index_bounds(), get_value(), get_value_for_param_name(), read_csv(), and record_duration().


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