ARTS 2.5.4 (git: 4c0d3b4d)
test_raw.cc
Go to the documentation of this file.
1#include <autoarts.h>
2
3#include "artstime.h"
4#include "gui/plot.h"
5#include "raw.h"
6#include "test_utils.h"
7
8#include <Faddeeva/Faddeeva.hh>
9
11 return 200 + 5 * std::sin(Constant::two_pi*t.Seconds()/86400);
12}
13
15 return 220 + 25 * std::sin(Constant::two_pi*t.Seconds()/86400);
16}
17
18struct MockData {
24};
25
26MockData mock_data(const Vector& f, const Time& t, const Numeric f0, const Numeric g, const Numeric gd) {
27 MockData out;
28 out.cold = Vector(f.nelem(), 100);
29 add_noise(out.cold, 20);
30 out.meas = Vector(f.nelem());
31 out.hot = Vector(f.nelem(), 500);
32 add_noise(out.hot, 200);
33 out.th = 300;
34 out.tc = 3;
35
36 const Numeric I = time_sign(t);
37 const Numeric J = time_srcs(t);
38 Vector mock_atm_meas(f.nelem());
39 for (Index i=0; i<f.nelem(); i++) {
40 const Numeric T = std::exp(- 5e-1 * Faddeeva::w(Complex(f[i] - f0, g) / gd).real());
41 mock_atm_meas[i] = (I - J) * T + J;
42 }
43 add_noise(mock_atm_meas, 1);
44
45 for (Index i=0; i<f.nelem(); i++) {
46 out.meas[i] = out.cold[i] + (mock_atm_meas[i] - out.tc) * (out.hot[i] - out.cold[i]) / (out.th - out.tc);
47 }
48
49 return out;
50}
51
52int main() {
53 const Time now = Time() - Time().seconds_into_day();
54 const TimeStep DT(60);
55
56 constexpr Index NumSpecChannel=10'000;
57 constexpr Numeric F0 = 1.5e9;
58 constexpr Numeric g = 1e7;
59 constexpr Numeric gd = 1e6;
60
61 const Vector f_grid_raw(1e9, NumSpecChannel, 1e9/(NumSpecChannel-1));
62
63 // Mock some data
64 ArrayOfTime times;
65 ArrayOfVector rawdata;
66 ArrayOfNumeric tc_arr, th_arr;
67 for (Index i=0; i<1440; i+=4) {
68 const auto mockraw = mock_data(f_grid_raw, now+i*DT, F0, g, gd);
69 for (Index j=0; j<4; j++) {
70 times.emplace_back(now + (i+j)*DT);
71 tc_arr.emplace_back(mockraw.tc);
72 th_arr.emplace_back(mockraw.th);
73 }
74 rawdata.emplace_back(mockraw.cold);
75 rawdata.emplace_back(mockraw.meas);
76 rawdata.emplace_back(mockraw.hot);
77 rawdata.emplace_back(mockraw.meas);
78 }
79 const Vector th(th_arr);
80 const Vector tc(tc_arr);
81
82
83 // This is the ARTS interface to use the raw data
84 auto ws = ARTS::init();
85 ARTS::Var::level0_data(ws).value() = rawdata;
86 ARTS::Var::level0_time(ws).value() = times;
87
88 // Do CAHA
90 std::cout << "Plotting first, central and last CAHA calibrated data on averaged sensor_time\n";
91 ARTSGUI::plot(f_grid_raw, ARTS::Var::ybatch(ws).value()[0],
92 f_grid_raw, ARTS::Var::ybatch(ws).value()[ARTS::Var::ybatch(ws).value().nelem()/2],
93 f_grid_raw, ARTS::Var::ybatch(ws).value()[ARTS::Var::ybatch(ws).value().nelem()-1]);
94
95 // Do time averaging
97 std::cout << "Plotting CAHA calibrated data on averaged sensor_time\n";
98 ARTSGUI::plot(f_grid_raw, ARTS::Var::ybatch(ws).value());
99
100 // Do tropospheric correction
102 std::cout << "Plotting CAHA calibrated data on averaged sensor_time after tropospheric correction\n";
103 ARTSGUI::plot(f_grid_raw, ARTS::Var::ybatch(ws).value());
104
105 // Focus the data around F0
106 ARTS::Method::VectorSet(ws, ARTS::Var::f_grid(ws), f_grid_raw);
108 std::cout << "Plotting CAHA calibrated data on averaged sensor_time after tropospheric correction with simple focus\n";
109 ARTSGUI::plot(ARTS::Var::f_grid(ws).value(), ARTS::Var::ybatch(ws).value());
110}
Stuff related to time in ARTS.
std::chrono::duration< Numeric > TimeStep
A duration of time, 1 full tick should be 1 second.
Definition: artstime.h:39
void VectorSet(Vector &out, const Vector &value, const Verbosity &)
WORKSPACE METHOD: VectorSet.
Definition: auto_md.cc:26089
This can be used to make arrays out of anything.
Definition: array.h:108
Index nelem() const noexcept
Returns the number of elements.
Definition: matpackI.h:541
The Vector class.
Definition: matpackI.h:908
void ybatchTimeAveraging(ArrayOfVector &ybatch, ArrayOfTime &sensor_time, const String &time_step, const Index &disregard_first, const Index &disregard_last, const Verbosity &)
WORKSPACE METHOD: ybatchTimeAveraging.
Definition: m_raw.cc:83
void ybatchDoublingMeanFocus(Vector &f_grid, ArrayOfVector &ybatch, const Numeric &f0, const Numeric &df, const Verbosity &)
WORKSPACE METHOD: ybatchDoublingMeanFocus.
Definition: m_raw.cc:251
void ybatchColdAtmHotAtmCycle(ArrayOfVector &ybatch, ArrayOfTime &sensor_time, const ArrayOfVector &level0_data, const ArrayOfTime &level0_time, const Vector &cold_temp, const Vector &hot_temp, const Index &first_c_index, const Verbosity &)
WORKSPACE METHOD: ybatchColdAtmHotAtmCycle.
Definition: m_raw.cc:53
void ybatchTroposphericCorrectionNaiveMedianForward(ArrayOfVector &ybatch_corr, ArrayOfVector &ybatch, const ArrayOfIndex &range, const Vector &trop_temp, const Numeric &targ_temp, const Verbosity &)
WORKSPACE METHOD: ybatchTroposphericCorrectionNaiveMedianForward.
Definition: m_raw.cc:147
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
std::complex< Numeric > Complex
constexpr Numeric real(Complex c) noexcept
real
Workspace & init(Workspace &ws)
Index nelem(const Lines &l)
Number of lines.
invlib::Vector< ArtsVector > Vector
invlib wrapper type for ARTS vectors.
Definition: oem.h:31
#define w
Stuff related to generating y-data from raw data.
Vector cold
Definition: test_raw.cc:19
Vector hot
Definition: test_raw.cc:21
Numeric tc
Definition: test_raw.cc:22
Vector meas
Definition: test_raw.cc:20
Numeric th
Definition: test_raw.cc:23
Class to handle time in ARTS.
Definition: artstime.h:42
Numeric Seconds() const
Definition: artstime.h:121
TimeStep seconds_into_day() const
Definition: artstime.h:74
Numeric time_sign(const Time t)
Definition: test_raw.cc:10
MockData mock_data(const Vector &f, const Time &t, const Numeric f0, const Numeric g, const Numeric gd)
Definition: test_raw.cc:26
int main()
Definition: test_raw.cc:52
Numeric time_srcs(const Time t)
Definition: test_raw.cc:14
void add_noise(VectorView v, Numeric scale)
Add noise to vector.
Definition: test_utils.cc:38
Utility functions for testing.