Skip to content

Commit

Permalink
Fix ascii timeseries inlight of the recent multi part changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrismarsh committed Jan 9, 2025
1 parent db2c029 commit abcaa54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/metdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,12 @@ void metdata::load_from_ascii(std::vector<ascii_metdata> stations, int utc_offse
std::tie(_start_time,_end_time) = find_unified_start_end();
subset(_start_time,_end_time); //subset assumes we have a valid dt

_current_ts = _start_time;
// even though multi-part ascii text files are not supported, various pieces of code assumes that both

_current_ts = _file_start_time = _start_time;
_file_end_time = _end_time;

SPDLOG_DEBUG(boost::posix_time::to_simple_string(_current_ts));
_n_timesteps = _ascii_stations.begin()->second->_obs.get_date_timeseries().size(); //grab the first timeseries, they are all the same period now
_nstations = _ascii_stations.size();

Expand Down Expand Up @@ -559,7 +564,8 @@ void metdata::subset(boost::posix_time::ptime start, boost::posix_time::ptime en

_start_time = start;
_end_time = end;
_current_ts = _file_start_time;
_current_ts = _start_time;

_n_timesteps = ( (_end_time+_dt) - _start_time).total_seconds() / _dt.total_seconds(); // need to add +dt so that we are inclusive of the last timestep
}
std::pair<boost::posix_time::ptime,boost::posix_time::ptime> metdata::start_end_time()
Expand Down Expand Up @@ -659,7 +665,7 @@ bool metdata::next()

bool metdata::next_ascii()
{

SPDLOG_DEBUG(boost::posix_time::to_simple_string(_current_ts));
for(size_t i = 0; i < nstations();i++)
{
auto s = _stations.at(i);
Expand Down
2 changes: 2 additions & 0 deletions src/metdata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ class metdata
// These two are the start and end time of the simulation. If we have loaded from a single file
// these will be equal to file_*. However, if we are loading from a multi-part file then the file_*
// tracks each file's start/end times
// _start_time, _end_time are what are used externally to manage the sim run, and the file_* are used to determine
// if another file needs to be loaded to get us to end_time, i.e., _file_end_time > _end_time
boost::posix_time::ptime _start_time, _end_time;
boost::posix_time::ptime _file_start_time, _file_end_time;
boost::posix_time::ptime _current_ts;
Expand Down

0 comments on commit abcaa54

Please sign in to comment.