ARTS  2.4.0(git:4fb77825)
test_time.cc
Go to the documentation of this file.
1 /* Copyright (C) 2020 Richard Larsson <larsson@mps.mpg.de>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
26 #include "artstime.h"
27 
28 void test01() {
29  auto x=ArrayOfTime(40000, Time(4));
30 
31  // Set the steps 0.5 seconds appard
32  for (Index i=0; i<x.nelem(); i++)
33  x[i] += TimeStep(0.001*Numeric(i));
34 
35  // Find every start of 5 seconds
36  auto time_str = "5 seconds";
37  auto limits = time_steps(x, time_str);
38 
39  std::cout << "The " << time_str << " intervals are:\n";
40  for (Index i=0; i<limits.nelem()-2; i++)
41  std::cout << 1+i <<": " << x[limits[i]] << " to "<< x[limits[i+1]] << "\n";
42  std::cout << limits.nelem()-1 <<": " << x[limits[limits.nelem()-2]] << " to "<< x.back() << "\n";
43 }
44 
45 int main() {
46  test01();
47  return 0;
48 }
TimeStep
std::chrono::duration< Numeric > TimeStep
A duration of time, 1 full tick should be 1 second.
Definition: artstime.h:37
time_steps
ArrayOfIndex time_steps(const ArrayOfTime &times, const String &step)
Finds the index matching demands in a list of times.
Definition: artstime.cc:60
artstime.h
Stuff related to time in ARTS.
main
int main()
Definition: test_time.cc:45
test01
void test01()
Definition: test_time.cc:28
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
ArrayOfTime
Array< Time > ArrayOfTime
List of times.
Definition: artstime.h:81
ARTS::Group::Time
Time Time
Definition: autoarts.h:110
ARTS::Var::x
Vector x(Workspace &ws) noexcept
Definition: autoarts.h:7346
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39