Skip to content

Commit

Permalink
Cleanup from review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mattw-nws authored and PhilMiller committed Sep 21, 2023
1 parent 2eafb94 commit 5243209
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 70 deletions.
74 changes: 5 additions & 69 deletions include/forcing/NullForcingProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,37 @@

#include <vector>
#include <string>
#include <iostream>
#include <ctime>
#include <time.h>
#include "AorcForcing.hpp"
#include <stdexcept>
#include <limits>
#include "GenericDataProvider.hpp"
#include "DataProviderSelectors.hpp"
#include <exception>

/**
* @brief Forcing class providing time-series precipiation forcing data to the model.
* @brief Forcing class that returns no variables to the simulation--use this e.g. if a BMI model provides forcing data.
*/
class NullForcingProvider : public data_access::GenericDataProvider
{
public:

NullForcingProvider(forcing_params forcing_config):start_date_time_epoch(forcing_config.simulation_start_t),
end_date_time_epoch(forcing_config.simulation_end_t),
current_date_time_epoch(forcing_config.simulation_start_t),
forcing_vector_index(-1)
{}
NullForcingProvider(){}

// BEGIN DataProvider interface methods

/**
* @brief the inclusive beginning of the period of time over which this instance can provide data for this forcing.
*
* @return The inclusive beginning of the period of time over which this instance can provide this data.
*/
long get_data_start_time() override {
//FIXME: Trace this back and you will find that it is the simulation start time, not having anything to do with the forcing at all.
// Apparently this "worked", but at a minimum the description above is false.
//return start_date_time_epoch;
// LONG_MIN is a large negative number, so we return 0 as the starting time
return 0;
}

/**
* @brief the exclusive ending of the period of time over which this instance can provide data for this forcing.
*
* @return The exclusive ending of the period of time over which this instance can provide this data.
*/
long get_data_stop_time() override {
//return end_date_time_epoch;
return LONG_MAX;
}

/**
* @brief the duration of one record of this forcing source
*
* @return The duration of one record of this forcing source
*/
long record_duration() override {
return 1;
}

/**
* Get the index of the forcing time step that contains the given point in time.
*
* An @ref std::out_of_range exception should be thrown if the time is not in any time step.
*
* @param epoch_time The point in time, as a seconds-based epoch time.
* @return The index of the forcing time step that contains the given point in time.
* @throws std::out_of_range If the given point is not in any time step.
*/
size_t get_ts_index_for_time(const time_t &epoch_time) override {
return 0;
}

/**
* Get the value of a forcing property for an arbitrary time period, converting units if needed.
*
* An @ref std::out_of_range exception should be thrown if the data for the time period is not available.
*
* @param selector Object storing information about the data to be queried
* @param m methode to resample data if needed
* @throws std::runtime_error as this provider does not provide forcing value/values
*/
double get_value(const CatchmentAggrDataSelector& selector, data_access::ReSampleMethod m) override
{
throw std::runtime_error("Called get_value function in NullDataProvider");
Expand All @@ -90,19 +44,6 @@ class NullForcingProvider : public data_access::GenericDataProvider
throw std::runtime_error("Called get_values function in NullDataProvider");
}

/**
* 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.
*
* @param name The name of the forcing property for which the current value is desired.
* @return Whether the property's value is an aggregate sum.
*/
//TODO this one used in Bmi_Module_Formulation.hpp and Bmi_Multi_Formulation.hpp
inline bool is_property_sum_over_time_step(const std::string& name) override {
throw std::runtime_error("Got request for variable " + name + " but no such variable is provided by NullForcingProvider." + SOURCE_LOC);
}
Expand All @@ -112,14 +53,9 @@ class NullForcingProvider : public data_access::GenericDataProvider
}

private:

std::vector<std::string> available_forcings;

int forcing_vector_index;

time_t start_date_time_epoch;
time_t end_date_time_epoch;
time_t current_date_time_epoch;
};

#endif // NGEN_NULLFORCING_H
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace realization {
}
#endif
else if (forcing_config.provider == "NullForcingProvider"){
fp = std::make_shared<NullForcingProvider>(forcing_config);
fp = std::make_shared<NullForcingProvider>();
}
else { // Some unknown string in the provider field?
throw std::runtime_error(
Expand Down

0 comments on commit 5243209

Please sign in to comment.