ARTS 2.5.4 (git: 31ce4f0e)
artstime.cc File Reference

Stuff related to time. More...

#include "artstime.h"
#include "arts_options.h"
#include <cstdlib>
#include <ctime>

Go to the source code of this file.

Functions

TimeStep time_stepper_selection (const String &time_step)
 Returns a time step from valid string. 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 TimeStep &DT)
 Finds the index matching demands in a list of times. More...
 
std::ostream & operator<< (std::ostream &os, const Time &t)
 
std::istream & operator>> (std::istream &is, Time &t)
 
Time mean_time (const ArrayOfTime &ts, Index s, Index E)
 Computes the average time in a list. More...
 
Vector time_vector (const ArrayOfTime &times)
 Converts from each Time to seconds and returns as Vector. More...
 
ArrayOfTime time_vector (const Vector &times)
 Converts from each Vector entry by seconds and returns as ArrayOfTime. More...
 
TimeStep median (ArrayOfTimeStep dt)
 Returns the median time step. More...
 
TimeStep mean (const ArrayOfTimeStep &dt)
 Returns the mean time step. More...
 
std::ostream & operator<< (std::ostream &os, const TimeStep &dt)
 Debug output for duration. More...
 

Detailed Description

Stuff related to time.

Author
Richard Larsson
Date
2020-04-13

Definition in file artstime.cc.

Function Documentation

◆ mean()

TimeStep mean ( const ArrayOfTimeStep dt)

Returns the mean time step.

Parameters
[in]timesTimes
Returns
mean time step

Definition at line 190 of file artstime.cc.

Referenced by Raw::Reduce::focus(), NumericFromVector(), polynomial_basis_func(), test_ls(), Minimize::T4::x0(), Minimize::DPL::x0(), ybatchDoublingMeanFocus(), and yDoublingMeanFocus().

◆ 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 151 of file artstime.cc.

References ARTS_USER_ERROR_IF, Constant::e, and Array< base >::nelem().

Referenced by ybatchTimeAveraging().

◆ median()

TimeStep median ( ArrayOfTimeStep  dt)

Returns the median time step.

Takes vector by copy to sort

Parameters
[in]timesTimes
Returns
median time step

Definition at line 179 of file artstime.cc.

Referenced by test_ls(), and yMaskOutsideMedianRange().

◆ 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 68 of file artstime.cc.

References Time::EpochTime().

Referenced by time_steps().

◆ operator<<() [1/2]

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

Definition at line 104 of file artstime.cc.

◆ operator<<() [2/2]

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

Debug output for duration.

Definition at line 199 of file artstime.cc.

◆ operator>>()

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

Definition at line 122 of file artstime.cc.

◆ time_stepper_selection()

TimeStep time_stepper_selection ( const String time_step)

Returns a time step from valid string.

The string should look like: "X type". where X is parsed as a double and where valid string type(s) are: "hour", "hours", "h": Returns a X hour time step "minute", "minutes", "min": Returns a X minute time step "second", "seconds", "s": Returns a X seconds time step

Parameters
[in]time_stepA time step of format "X type"
Returns
The time step as TimeStep

Definition at line 37 of file artstime.cc.

References check_enum_error(), Constant::h, min, and my_basic_string< charT >::tolower().

Referenced by test01(), and ybatchTimeAveraging().

◆ time_steps()

ArrayOfIndex time_steps ( const ArrayOfTime times,
const TimeStep dt 
)

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]dtA duration of time
Returns
Starting index of the time-series

Definition at line 77 of file artstime.cc.

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

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

◆ time_vector() [1/2]

Vector time_vector ( const ArrayOfTime times)

Converts from each Time to seconds and returns as Vector.

Parameters
[in]timesTimes
Returns
Vector of Time->Seconds() calls

Definition at line 167 of file artstime.cc.

References Array< base >::nelem().

Referenced by jacobianCalcPointingZaInterp(), jacobianCalcPointingZaRecalc(), and x2artsSensor().

◆ time_vector() [2/2]

ArrayOfTime time_vector ( const Vector times)

Converts from each Vector entry by seconds and returns as ArrayOfTime.

Parameters
[in]timesTimes
Returns
ArrayOfTime from seconds

Definition at line 173 of file artstime.cc.

References ConstVectorView::nelem().