Go to the documentation of this file.
34 std::istringstream
x(time_step);
40 if (type ==
"hour" or type ==
"hours" or type ==
"h")
41 return TimeStep(std::chrono::hours(length ));
42 else if (type ==
"minute" or type ==
"minutes" or type ==
"min")
43 return TimeStep(std::chrono::minutes(length));
44 else if (type ==
"second" or type ==
"seconds" or type ==
"s")
45 return TimeStep(std::chrono::seconds(length));
47 throw std::runtime_error(
"Bad time step definition");
52 auto dt_internal = std::chrono::duration_cast<Time::InternalTimeStep>(dt);
54 if (dt_internal.count())
55 return t + dt_internal - t.
EpochTime() % dt_internal;
64 throw std::runtime_error(
"Can only find time steps for 2-long or longer time grids");
68 if (dt < decltype(dt)(0)) {
69 throw std::runtime_error(
"Must have positive time steps (or 0 for all times)");
98 sprintf(sec,
"%.9lf", seconds);
101 return os << 1900 +
x.tm_year <<
'-' << std::setfill(
'0') << std::setw(2)
102 << 1 +
x.tm_mon <<
'-' << std::setfill(
'0') << std::setw(2)
103 <<
x.tm_mday <<
' ' << std::setfill(
'0') << std::setw(2)
104 <<
x.tm_hour <<
':' << std::setfill(
'0') << std::setw(2)
105 <<
x.tm_min <<
':' << std::setfill(
'0') << std::setw(12) << sec;
118 throw std::runtime_error(
"Time stream must look like \"year-month-day hour:min:seconds\"");
122 x.tm_year = std::stoi(YMD[0]) - 1900;
123 x.tm_mon = std::stoi(YMD[1]) - 1;
124 x.tm_mday = std::stoi(YMD[2]);
125 x.tm_hour = std::stoi(HMS[0]);
126 x.tm_min = std::stoi(HMS[1]);
139 else if (e < 0 or e > ts.
nelem())
140 throw std::runtime_error(
"Bad last index, valid options are [-1, ts.nelem()]");
142 if (s < 0 or s > ts.
nelem())
143 throw std::runtime_error(
"Bad first index, valid options are [0, ts.nelem()]");
146 for (
Index i=s+1; i<e; i++)
147 dt += (ts[i] - ts[s]) / (e - s);
Numeric PartOfSecond() const
std::chrono::duration< Numeric > TimeStep
A duration of time, 1 full tick should be 1 second.
ArrayOfIndex time_steps(const ArrayOfTime ×, const String &step)
Finds the index matching demands in a list of times.
TimeStep time_stepper_selection(const String &time_step)
std::ostream & operator<<(std::ostream &os, const Time &t)
Output for Time.
Stuff related to time in ARTS.
This can be used to make arrays out of anything.
Time mean_time(const ArrayOfTime &ts, Index s, Index e)
Computes the average time in a list.
Time next_even(const Time &t, const TimeStep &dt)
Returns the next time after t with an even time-step.
InternalTimeStep EpochTime() const
std::istream & operator>>(std::istream &is, Time &t)
Input for Time.
NUMERIC Numeric
The type to use for all floating point numbers.
decltype(mtime)::duration InternalTimeStep
void tolower()
Convert to lower case.
void split(Array< my_basic_string< charT > > &aos, const my_basic_string< charT > &delim) const
Split string into substrings.
Class to handle time in ARTS.
Vector x(Workspace &ws) noexcept
INDEX Index
The type to use for all integer numbers and indices.
Index nelem() const
Number of elements.