ARTS  2.3.1285(git:92a29ea9-dirty)
artstime.h File Reference

Stuff related to time in ARTS. More...

#include <chrono>
#include <cmath>
#include "array.h"
#include "mystring.h"

Go to the source code of this file.

Classes

class  Time
 Class to handle time in ARTS. More...
 

Typedefs

using TimeStep = std::chrono::duration< Numeric >
 A duration of time, 1 full tick should be 1 second. More...
 
using ArrayOfTime = Array< Time >
 List of times. More...
 
using ArrayOfArrayOfTime = Array< ArrayOfTime >
 List of times. More...
 

Functions

std::ostream & operator<< (std::ostream &os, const Time &t)
 Output for Time. More...
 
std::istream & operator>> (std::istream &is, Time &t)
 Input for Time. More...
 
std::ostream & operator<< (std::ostream &os, const TimeStep &dt)
 Debug output for duration. More...
 
Time next_even (const Time &t, const TimeStep &dt)
 Returns the next time after t with an even time-step. More...
 
ArrayOfIndex time_steps (const ArrayOfTime &times, const String &step)
 Finds the index matching demands in a list of times. More...
 
Time mean_time (const ArrayOfTime &ts, Index s=0, Index e=-1)
 Computes the average time in a list. More...
 

Detailed Description

Stuff related to time in ARTS.

Author
Richard Larsson
Date
2020-04-13

Definition in file artstime.h.

Typedef Documentation

◆ ArrayOfArrayOfTime

List of times.

Definition at line 84 of file artstime.h.

◆ ArrayOfTime

List of times.

Definition at line 81 of file artstime.h.

◆ TimeStep

using TimeStep = std::chrono::duration<Numeric>

A duration of time, 1 full tick should be 1 second.

Definition at line 37 of file artstime.h.

Function Documentation

◆ mean_time()

Time mean_time ( const ArrayOfTime ts,
Index  s = 0,
Index  e = -1 
)

Computes the average time in a list.

Parameters
[in]tsA list of time
[in]sA starting index; valid range [0, ts.nelem())
[in]eThe end+1 index; valid range [-1, ts.nelem()]; -1 is treated as ts.nelem()

Definition at line 135 of file artstime.cc.

Referenced by operator<<().

◆ next_even()

Time next_even ( const Time t,
const TimeStep dt 
)

Returns the next time after t with an even time-step.

Parameters
[in]tA time
[in]dtA duration of time
Returns
Next even time, e.g., 14:14:00 with dt as 10 minutes gives 14:20:00

Definition at line 50 of file artstime.cc.

References Time::EpochTime().

Referenced by operator<<(), and time_steps().

◆ operator<<() [1/2]

std::ostream& operator<< ( std::ostream &  os,
const Time t 
)

Output for Time.

Definition at line 90 of file artstime.cc.

References Time::PartOfSecond(), and Time::toStruct().

◆ operator<<() [2/2]

std::ostream& operator<< ( std::ostream &  os,
const TimeStep dt 
)
inline

Debug output for duration.

Definition at line 93 of file artstime.h.

References mean_time(), next_even(), and time_steps().

◆ operator>>()

std::istream& operator>> ( std::istream &  is,
Time t 
)

Input for Time.

Definition at line 108 of file artstime.cc.

References Array< base >::nelem(), and my_basic_string< charT >::split().

◆ time_steps()

ArrayOfIndex time_steps ( const ArrayOfTime times,
const String step 
)

Finds the index matching demands in a list of times.

The first index is 0 and the second index is the start of the first even period of the given stepsize

The last index is times.nelem(). If output has 1 element, no range was found matching the criteria.

Parameters
[in]timesTimes sorted in ascending order
[in]stepA duration of time
Returns
Starting index of the time-series

Definition at line 60 of file artstime.cc.

References N, Array< base >::nelem(), next_even(), time_stepper_selection(), and time_steps().

Referenced by operator<<(), test01(), time_steps(), and ybatchTimeAveraging().