##// END OF EJS Templates
Merge pull request 358 from SciQLop-fork develop...
trabillard -
r976:dbc4bcb5f74b merge
parent child
Show More
@@ -0,0 +1,59
1 # -----------
2 # AMDA INFO :
3 # -----------
4 # AMDA_ABOUT : Created by CDPP/AMDA(c)
5 # AMDA_VERSION : 3.5.0
6 # AMDA_ACKNOWLEDGEMENT : CDPP/AMDA Team
7 #
8 # --------------
9 # REQUEST INFO :
10 # --------------
11 # REQUEST_STRUCTURE : one-file-per-parameter-per-interval
12 # REQUEST_TIME_FORMAT : ISO 8601
13 # REQUEST_OUTPUT_PARAMS : tha_ion_sp
14 #
15 # -----------------
16 # BASE PARAMETERS :
17 # -----------------
18 #
19 # MISSION_ID : NONE
20 #
21 # INSTRUMENT_ID : NONE
22 #
23 # DATASET_ID : tha-esa-l2i
24 # DATASET_NAME : ion full mode
25 # DATASET_SOURCE : CDPP/DDServer
26 # DATASET_GLOBAL_START : 2007-03-07T18:53:59.134
27 # DATASET_GLOBAL_STOP : 2017-11-04T18:35:25.907
28 # DATASET_MIN_SAMPLING : 96
29 # DATASET_MAX_SAMPLING : 385
30 #
31 # PARAMETER_ID : tha_ion_sp
32 # PARAMETER_NAME : tha_ion_sp
33 # PARAMETER_SHORT_NAME : spectra
34 # PARAMETER_UNITS : eV/(cm^2-s-sr-eV)
35 # PARAMETER_TENSOR_ORDER : 0
36 # PARAMETER_TABLE[0] : energy
37 # PARAMETER_TABLE_UNITS[0] : eV
38 # PARAMETER_TABLE_MIN_VALUES[0] : 5.00000,6.50000,8.70000,11.4000
39 # PARAMETER_TABLE_MAX_VALUES[0] : 6.50000,8.70000,11.4000
40 # PARAMETER_FILL_VALUE : nan
41 # PARAMETER_UCD : phys.flux.density;phys.energy;phys.atmol.ionStage
42 #
43 #
44 # ---------------
45 # INTERVAL INFO :
46 # ---------------
47 # INTERVAL_START : 2012-11-06T09:13:31.000
48 # INTERVAL_STOP : 2012-11-06T10:35:07.000
49 #
50 # ------
51 # DATA :
52 # ------
53 # DATA_COLUMNS : AMDA_TIME, tha_ion_sp[0], tha_ion_sp[1], tha_ion_sp[2]
54 #
55 2012-11-06T09:14:35.000 16313.780 15405.838 8946.475
56 2012-11-06T09:16:10.000 12631.465 11957.925 18133.158
57 2012-11-06T09:17:45.000 8223.368 15026.249 10875.621
58 2012-11-06T09:19:20.000 27595.301 25617.533 24051.619
59 2012-11-06T09:20:55.000 12820.613 11179.109 19283.221 No newline at end of file
@@ -0,0 +1,59
1 # -----------
2 # AMDA INFO :
3 # -----------
4 # AMDA_ABOUT : Created by CDPP/AMDA(c)
5 # AMDA_VERSION : 3.5.0
6 # AMDA_ACKNOWLEDGEMENT : CDPP/AMDA Team
7 #
8 # --------------
9 # REQUEST INFO :
10 # --------------
11 # REQUEST_STRUCTURE : one-file-per-parameter-per-interval
12 # REQUEST_TIME_FORMAT : ISO 8601
13 # REQUEST_OUTPUT_PARAMS : tha_ion_sp
14 #
15 # -----------------
16 # BASE PARAMETERS :
17 # -----------------
18 #
19 # MISSION_ID : NONE
20 #
21 # INSTRUMENT_ID : NONE
22 #
23 # DATASET_ID : tha-esa-l2i
24 # DATASET_NAME : ion full mode
25 # DATASET_SOURCE : CDPP/DDServer
26 # DATASET_GLOBAL_START : 2007-03-07T18:53:59.134
27 # DATASET_GLOBAL_STOP : 2017-11-04T18:35:25.907
28 # DATASET_MIN_SAMPLING : 96
29 # DATASET_MAX_SAMPLING : 385
30 #
31 # PARAMETER_ID : tha_ion_sp
32 # PARAMETER_NAME : tha_ion_sp
33 # PARAMETER_SHORT_NAME : spectra
34 # PARAMETER_UNITS : eV/(cm^2-s-sr-eV)
35 # PARAMETER_TENSOR_ORDER : 0
36 # PARAMETER_TABLE[0] : energy
37 # PARAMETER_TABLE_UNITS[0] : eV
38 # PARAMETER_TABLE_MIN_VALUES[0] : 5.00000,6.50000,8.70000
39 # PARAMETER_TABLE_MAX_VALUES[0] : 6.50000,8.70000,11.4000
40 # PARAMETER_FILL_VALUE : nan
41 # PARAMETER_UCD : phys.flux.density;phys.energy;phys.atmol.ionStage
42 #
43 #
44 # ---------------
45 # INTERVAL INFO :
46 # ---------------
47 # INTERVAL_START : 2012-11-06T09:13:31.000
48 # INTERVAL_STOP : 2012-11-06T09:21:00.000
49 #
50 # ------
51 # DATA :
52 # ------
53 # DATA_COLUMNS : AMDA_TIME, tha_ion_sp[0], tha_ion_sp[1], tha_ion_sp[2]
54 #
55 2012-11-06T09:14:35.000 16313.780 15405.838 8946.475
56 2012-11-06T09:16:10.000 12631.465 11957.925 18133.158
57 2012-11-06T09:17:45.000 8223.368 15026.249 10875.621
58 2012-11-06T09:19:20.000 27595.301 25617.533 24051.619
59 2012-11-06T09:20:55.000 12820.613 11179.109 19283.221 No newline at end of file
@@ -0,0 +1,59
1 # -----------
2 # AMDA INFO :
3 # -----------
4 # AMDA_ABOUT : Created by CDPP/AMDA(c)
5 # AMDA_VERSION : 3.5.0
6 # AMDA_ACKNOWLEDGEMENT : CDPP/AMDA Team
7 #
8 # --------------
9 # REQUEST INFO :
10 # --------------
11 # REQUEST_STRUCTURE : one-file-per-parameter-per-interval
12 # REQUEST_TIME_FORMAT : ISO 8601
13 # REQUEST_OUTPUT_PARAMS : tha_ion_sp
14 #
15 # -----------------
16 # BASE PARAMETERS :
17 # -----------------
18 #
19 # MISSION_ID : NONE
20 #
21 # INSTRUMENT_ID : NONE
22 #
23 # DATASET_ID : tha-esa-l2i
24 # DATASET_NAME : ion full mode
25 # DATASET_SOURCE : CDPP/DDServer
26 # DATASET_GLOBAL_START : 2007-03-07T18:53:59.134
27 # DATASET_GLOBAL_STOP : 2017-11-04T18:35:25.907
28 # DATASET_MIN_SAMPLING : 96
29 # DATASET_MAX_SAMPLING : 385
30 #
31 # PARAMETER_ID : tha_ion_sp
32 # PARAMETER_NAME : tha_ion_sp
33 # PARAMETER_SHORT_NAME : spectra
34 # PARAMETER_UNITS : eV/(cm^2-s-sr-eV)
35 # PARAMETER_TENSOR_ORDER : 0
36 # PARAMETER_TABLE[0] : energy
37 # PARAMETER_TABLE_UNITS[0] : eV
38 # PARAMETER_TABLE_MIN_VALUES[0] : 5.00000,6.50000,8.70000,11.4000
39 # PARAMETER_TABLE_MAX_VALUES[0] : 6.50000,8.70000,11.4000,14.6000
40 # PARAMETER_FILL_VALUE : nan
41 # PARAMETER_UCD : phys.flux.density;phys.energy;phys.atmol.ionStage
42 #
43 #
44 # ---------------
45 # INTERVAL INFO :
46 # ---------------
47 # INTERVAL_START : 2012-11-06T09:13:31.000
48 # INTERVAL_STOP : 2012-11-06T09:21:00.000
49 #
50 # ------
51 # DATA :
52 # ------
53 # DATA_COLUMNS : AMDA_TIME, tha_ion_sp[0], tha_ion_sp[1], tha_ion_sp[2], tha_ion_sp[3]
54 #
55 2012-11-06T09:14:35.000 16313.780 15405.838 8946.475 20907.664
56 2012-11-06T09:16:10.000 12631.465 11957.925 18133.158 32076.725
57 2012-11-06T09:17:45.000 8223.368 15026.249 10875.621 13008.381
58 2012-11-06T09:19:20.000 27595.301 25617.533 24051.619 13142.759
59 2012-11-06T09:20:55.000 12820.613 11179.109 19283.221 23226.998 No newline at end of file
@@ -0,0 +1,59
1 # -----------
2 # AMDA INFO :
3 # -----------
4 # AMDA_ABOUT : Created by CDPP/AMDA(c)
5 # AMDA_VERSION : 3.5.0
6 # AMDA_ACKNOWLEDGEMENT : CDPP/AMDA Team
7 #
8 # --------------
9 # REQUEST INFO :
10 # --------------
11 # REQUEST_STRUCTURE : one-file-per-parameter-per-interval
12 # REQUEST_TIME_FORMAT : ISO 8601
13 # REQUEST_OUTPUT_PARAMS : tha_ion_sp
14 #
15 # -----------------
16 # BASE PARAMETERS :
17 # -----------------
18 #
19 # MISSION_ID : NONE
20 #
21 # INSTRUMENT_ID : NONE
22 #
23 # DATASET_ID : tha-esa-l2i
24 # DATASET_NAME : ion full mode
25 # DATASET_SOURCE : CDPP/DDServer
26 # DATASET_GLOBAL_START : 2007-03-07T18:53:59.134
27 # DATASET_GLOBAL_STOP : 2017-11-04T18:35:25.907
28 # DATASET_MIN_SAMPLING : 96
29 # DATASET_MAX_SAMPLING : 385
30 #
31 # PARAMETER_ID : tha_ion_sp
32 # PARAMETER_NAME : tha_ion_sp
33 # PARAMETER_SHORT_NAME : spectra
34 # PARAMETER_UNITS : eV/(cm^2-s-sr-eV)
35 # PARAMETER_TENSOR_ORDER : 0
36 # PARAMETER_TABLE[0] : energy
37 # PARAMETER_TABLE_UNITS[0] : eV
38 # PARAMETER_TABLE_MIN_VALUES[0] : 8.70000,6.50000,11.4000,5.00000
39 # PARAMETER_TABLE_MAX_VALUES[0] : 11.4000,8.70000,14.6000,6.50000
40 # PARAMETER_FILL_VALUE : nan
41 # PARAMETER_UCD : phys.flux.density;phys.energy;phys.atmol.ionStage
42 #
43 #
44 # ---------------
45 # INTERVAL INFO :
46 # ---------------
47 # INTERVAL_START : 2012-11-06T09:13:31.000
48 # INTERVAL_STOP : 2012-11-06T09:21:00.000
49 #
50 # ------
51 # DATA :
52 # ------
53 # DATA_COLUMNS : AMDA_TIME, tha_ion_sp[0], tha_ion_sp[1], tha_ion_sp[2], tha_ion_sp[3]
54 #
55 2012-11-06T09:14:35.000 8946.475 15405.838 20907.664 16313.780
56 2012-11-06T09:16:10.000 18133.158 11957.925 32076.725 12631.465
57 2012-11-06T09:17:45.000 10875.621 15026.249 13008.381 8223.368
58 2012-11-06T09:19:20.000 24051.619 25617.533 13142.759 27595.301
59 2012-11-06T09:20:55.000 19283.221 11179.109 23226.998 12820.613 No newline at end of file
@@ -0,0 +1,59
1 # -----------
2 # AMDA INFO :
3 # -----------
4 # AMDA_ABOUT : Created by CDPP/AMDA(c)
5 # AMDA_VERSION : 3.5.0
6 # AMDA_ACKNOWLEDGEMENT : CDPP/AMDA Team
7 #
8 # --------------
9 # REQUEST INFO :
10 # --------------
11 # REQUEST_STRUCTURE : one-file-per-parameter-per-interval
12 # REQUEST_TIME_FORMAT : ISO 8601
13 # REQUEST_OUTPUT_PARAMS : tha_ion_sp
14 #
15 # -----------------
16 # BASE PARAMETERS :
17 # -----------------
18 #
19 # MISSION_ID : NONE
20 #
21 # INSTRUMENT_ID : NONE
22 #
23 # DATASET_ID : tha-esa-l2i
24 # DATASET_NAME : ion full mode
25 # DATASET_SOURCE : CDPP/DDServer
26 # DATASET_GLOBAL_START : 2007-03-07T18:53:59.134
27 # DATASET_GLOBAL_STOP : 2017-11-04T18:35:25.907
28 # DATASET_MIN_SAMPLING : 96
29 # DATASET_MAX_SAMPLING : 385
30 #
31 # PARAMETER_ID : tha_ion_sp
32 # PARAMETER_NAME : tha_ion_sp
33 # PARAMETER_SHORT_NAME : spectra
34 # PARAMETER_UNITS : eV/(cm^2-s-sr-eV)
35 # PARAMETER_TENSOR_ORDER : 0
36 # PARAMETER_TABLE[0] : energy
37 # PARAMETER_TABLE_UNITS[0] : eV
38 # PARAMETER_TABLE_MIN_VALUES[0] : 5.00000,6.50000,8.70000,11.4000
39 # PARAMETER_TABLE_MAX_VALUES[0] : 6.50000,8.70000,11.4000,14.6000
40 # PARAMETER_FILL_VALUE : -1.
41 # PARAMETER_UCD : phys.flux.density;phys.energy;phys.atmol.ionStage
42 #
43 #
44 # ---------------
45 # INTERVAL INFO :
46 # ---------------
47 # INTERVAL_START : 2012-11-06T09:13:31.000
48 # INTERVAL_STOP : 2012-11-06T09:21:00.000
49 #
50 # ------
51 # DATA :
52 # ------
53 # DATA_COLUMNS : AMDA_TIME, tha_ion_sp[0], tha_ion_sp[1], tha_ion_sp[2], tha_ion_sp[3]
54 #
55 2012-11-06T09:14:35.000 -1.000 15405.838 8946.475 -1.000
56 2012-11-06T09:16:10.000 12631.465 -1.000 18133.158 -1.000
57 2012-11-06T09:17:45.000 8223.368 -1.000 10875.621 -1.000
58 2012-11-06T09:19:20.000 27595.301 25617.533 24051.619 -1.000
59 2012-11-06T09:20:55.000 12820.613 11179.109 19283.221 -1.000 No newline at end of file
@@ -0,0 +1,59
1 # -----------
2 # AMDA INFO :
3 # -----------
4 # AMDA_ABOUT : Created by CDPP/AMDA(c)
5 # AMDA_VERSION : 3.5.0
6 # AMDA_ACKNOWLEDGEMENT : CDPP/AMDA Team
7 #
8 # --------------
9 # REQUEST INFO :
10 # --------------
11 # REQUEST_STRUCTURE : one-file-per-parameter-per-interval
12 # REQUEST_TIME_FORMAT : ISO 8601
13 # REQUEST_OUTPUT_PARAMS : tha_ion_sp
14 #
15 # -----------------
16 # BASE PARAMETERS :
17 # -----------------
18 #
19 # MISSION_ID : NONE
20 #
21 # INSTRUMENT_ID : NONE
22 #
23 # DATASET_ID : tha-esa-l2i
24 # DATASET_NAME : ion full mode
25 # DATASET_SOURCE : CDPP/DDServer
26 # DATASET_GLOBAL_START : 2007-03-07T18:53:59.134
27 # DATASET_GLOBAL_STOP : 2017-11-04T18:35:25.907
28 # DATASET_MIN_SAMPLING : 96
29 # DATASET_MAX_SAMPLING : 385
30 #
31 # PARAMETER_ID : tha_ion_sp
32 # PARAMETER_NAME : tha_ion_sp
33 # PARAMETER_SHORT_NAME : spectra
34 # PARAMETER_UNITS : eV/(cm^2-s-sr-eV)
35 # PARAMETER_TENSOR_ORDER : 0
36 # PARAMETER_TABLE[0] : energy
37 # PARAMETER_TABLE_UNITS[0] : eV
38 # PARAMETER_TABLE_MIN_VALUES[0] : 5.00000,6.50000,8.70000,11.4000
39 # PARAMETER_TABLE_MAX_VALUES[0] : 6.50000,8.70000,11.4000,14.6000
40 # PARAMETER_FILL_VALUE : nan
41 # PARAMETER_UCD : phys.flux.density;phys.energy;phys.atmol.ionStage
42 #
43 #
44 # ---------------
45 # INTERVAL INFO :
46 # ---------------
47 # INTERVAL_START : 2012-11-06T09:13:31.000
48 # INTERVAL_STOP : 2012-11-06T09:21:00.000
49 #
50 # ------
51 # DATA :
52 # ------
53 # DATA_COLUMNS : AMDA_TIME, tha_ion_sp[0], tha_ion_sp[1], tha_ion_sp[2], tha_ion_sp[3]
54 #
55 2012-11-06T09:14:35.000 nan 15405.838 8946.475 nan
56 2012-11-06T09:16:10.000 12631.465 nan 18133.158 nan
57 2012-11-06T09:17:45.000 8223.368 nan 10875.621 nan
58 2012-11-06T09:19:20.000 27595.301 25617.533 24051.619 nan
59 2012-11-06T09:20:55.000 12820.613 11179.109 19283.221 nan No newline at end of file
@@ -92,7 +92,7 void VisualizationCursorItem::setVisible(bool value)
92 if (value != isVisible()) {
92 if (value != isVisible()) {
93
93
94 if (value) {
94 if (value) {
95 Q_ASSERT(!impl->m_LineItem && !impl->m_Plot);
95 Q_ASSERT(!impl->m_LineItem && !impl->m_LabelItem);
96
96
97 impl->m_LineItem = new QCPItemStraightLine{impl->m_Plot};
97 impl->m_LineItem = new QCPItemStraightLine{impl->m_Plot};
98 auto pen = QPen{CURSOR_PEN_STYLE};
98 auto pen = QPen{CURSOR_PEN_STYLE};
@@ -118,7 +118,7 void VisualizationCursorItem::setVisible(bool value)
118 impl->updateCursorPosition();
118 impl->updateCursorPosition();
119 }
119 }
120 else {
120 else {
121 Q_ASSERT(impl->m_LineItem && impl->m_Plot);
121 Q_ASSERT(impl->m_LineItem && impl->m_LabelItem);
122
122
123 // Note: the items are destroyed by QCustomPlot in removeItem
123 // Note: the items are destroyed by QCustomPlot in removeItem
124 impl->m_Plot->removeItem(impl->m_LineItem);
124 impl->m_Plot->removeItem(impl->m_LineItem);
@@ -1,6 +1,7
1 #include "AmdaResultParser.h"
1 #include "AmdaResultParser.h"
2
2
3 #include <Data/ScalarSeries.h>
3 #include <Data/ScalarSeries.h>
4 #include <Data/SpectrogramSeries.h>
4 #include <Data/VectorSeries.h>
5 #include <Data/VectorSeries.h>
5
6
6 #include <QObject>
7 #include <QObject>
@@ -24,27 +25,65 QString inputFilePath(const QString &inputFileName)
24
25
25 template <typename T>
26 template <typename T>
26 struct ExpectedResults {
27 struct ExpectedResults {
27 explicit ExpectedResults() = default;
28
28
29 explicit ExpectedResults(Unit xAxisUnit, Unit valuesUnit, const QVector<QDateTime> &xAxisData,
29 ExpectedResults &setParsingOK(bool parsingOK)
30 QVector<double> valuesData)
31 : ExpectedResults(xAxisUnit, valuesUnit, xAxisData,
32 QVector<QVector<double> >{std::move(valuesData)})
33 {
30 {
31 m_ParsingOK = parsingOK;
32 return *this;
34 }
33 }
35
34
36 /// Ctor with QVector<QDateTime> as x-axis data. Datetimes are converted to doubles
35 ExpectedResults &setXAxisUnit(Unit xAxisUnit)
37 explicit ExpectedResults(Unit xAxisUnit, Unit valuesUnit, const QVector<QDateTime> &xAxisData,
38 QVector<QVector<double> > valuesData)
39 : m_ParsingOK{true},
40 m_XAxisUnit{xAxisUnit},
41 m_ValuesUnit{valuesUnit},
42 m_XAxisData{},
43 m_ValuesData{std::move(valuesData)}
44 {
36 {
37 m_XAxisUnit = std::move(xAxisUnit);
38 return *this;
39 }
40
41 ExpectedResults &setXAxisData(const QVector<QDateTime> &xAxisData)
42 {
43 m_XAxisData.clear();
44
45 // Converts QVector<QDateTime> to QVector<double>
45 // Converts QVector<QDateTime> to QVector<double>
46 std::transform(xAxisData.cbegin(), xAxisData.cend(), std::back_inserter(m_XAxisData),
46 std::transform(xAxisData.cbegin(), xAxisData.cend(), std::back_inserter(m_XAxisData),
47 [](const auto &dateTime) { return dateTime.toMSecsSinceEpoch() / 1000.; });
47 [](const auto &dateTime) { return dateTime.toMSecsSinceEpoch() / 1000.; });
48
49 return *this;
50 }
51
52 ExpectedResults &setValuesUnit(Unit valuesUnit)
53 {
54 m_ValuesUnit = std::move(valuesUnit);
55 return *this;
56 }
57
58 ExpectedResults &setValuesData(QVector<double> valuesData)
59 {
60 m_ValuesData.clear();
61 m_ValuesData.push_back(std::move(valuesData));
62 return *this;
63 }
64
65 ExpectedResults &setValuesData(QVector<QVector<double> > valuesData)
66 {
67 m_ValuesData = std::move(valuesData);
68 return *this;
69 }
70
71 ExpectedResults &setYAxisEnabled(bool yAxisEnabled)
72 {
73 m_YAxisEnabled = yAxisEnabled;
74 return *this;
75 }
76
77 ExpectedResults &setYAxisUnit(Unit yAxisUnit)
78 {
79 m_YAxisUnit = std::move(yAxisUnit);
80 return *this;
81 }
82
83 ExpectedResults &setYAxisData(QVector<double> yAxisData)
84 {
85 m_YAxisData = std::move(yAxisData);
86 return *this;
48 }
87 }
49
88
50 /**
89 /**
@@ -86,6 +125,22 struct ExpectedResults {
86 return (std::isnan(itValue) && std::isnan(value)) || seriesIt.value(i) == value;
125 return (std::isnan(itValue) && std::isnan(value)) || seriesIt.value(i) == value;
87 });
126 });
88 }
127 }
128
129 // Checks y-axis (if defined)
130 auto yAxis = dataSeries->yAxis();
131 QCOMPARE(yAxis.isDefined(), m_YAxisEnabled);
132
133 if (m_YAxisEnabled) {
134 // Unit
135 QCOMPARE(yAxis.unit(), m_YAxisUnit);
136
137 // Data
138 auto yAxisSize = yAxis.size();
139 QCOMPARE(yAxisSize, m_YAxisData.size());
140 for (auto i = 0; i < yAxisSize; ++i) {
141 QCOMPARE(yAxis.at(i), m_YAxisData.at(i));
142 }
143 }
89 }
144 }
90 else {
145 else {
91 QVERIFY(results == nullptr);
146 QVERIFY(results == nullptr);
@@ -96,17 +151,24 struct ExpectedResults {
96 bool m_ParsingOK{false};
151 bool m_ParsingOK{false};
97 // Expected x-axis unit
152 // Expected x-axis unit
98 Unit m_XAxisUnit{};
153 Unit m_XAxisUnit{};
99 // Expected values unit
100 Unit m_ValuesUnit{};
101 // Expected x-axis data
154 // Expected x-axis data
102 QVector<double> m_XAxisData{};
155 QVector<double> m_XAxisData{};
156 // Expected values unit
157 Unit m_ValuesUnit{};
103 // Expected values data
158 // Expected values data
104 QVector<QVector<double> > m_ValuesData{};
159 QVector<QVector<double> > m_ValuesData{};
160 // Expected data series has y-axis
161 bool m_YAxisEnabled{false};
162 // Expected y-axis unit (if axis defined)
163 Unit m_YAxisUnit{};
164 // Expected y-axis data (if axis defined)
165 QVector<double> m_YAxisData{};
105 };
166 };
106
167
107 } // namespace
168 } // namespace
108
169
109 Q_DECLARE_METATYPE(ExpectedResults<ScalarSeries>)
170 Q_DECLARE_METATYPE(ExpectedResults<ScalarSeries>)
171 Q_DECLARE_METATYPE(ExpectedResults<SpectrogramSeries>)
110 Q_DECLARE_METATYPE(ExpectedResults<VectorSeries>)
172 Q_DECLARE_METATYPE(ExpectedResults<VectorSeries>)
111
173
112 class TestAmdaResultParser : public QObject {
174 class TestAmdaResultParser : public QObject {
@@ -150,6 +212,13 private slots:
150 void testReadScalarTxt();
212 void testReadScalarTxt();
151
213
152 /// Input test data
214 /// Input test data
215 /// @sa testReadSpectrogramTxt()
216 void testReadSpectrogramTxt_data();
217
218 /// Tests parsing spectrogram series of a TXT file
219 void testReadSpectrogramTxt();
220
221 /// Input test data
153 /// @sa testReadVectorTxt()
222 /// @sa testReadVectorTxt()
154 void testReadVectorTxt_data();
223 void testReadVectorTxt_data();
155
224
@@ -168,77 +237,85 void TestAmdaResultParser::testReadScalarTxt_data()
168 // Valid files
237 // Valid files
169 QTest::newRow("Valid file")
238 QTest::newRow("Valid file")
170 << QStringLiteral("ValidScalar1.txt")
239 << QStringLiteral("ValidScalar1.txt")
171 << ExpectedResults<ScalarSeries>{
240 << ExpectedResults<ScalarSeries>{}
172 Unit{QStringLiteral("nT"), true}, Unit{},
241 .setParsingOK(true)
173 QVector<QDateTime>{dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
242 .setXAxisUnit(Unit{"nT", true})
243 .setXAxisData({dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
174 dateTime(2013, 9, 23, 9, 2, 30), dateTime(2013, 9, 23, 9, 3, 30),
244 dateTime(2013, 9, 23, 9, 2, 30), dateTime(2013, 9, 23, 9, 3, 30),
175 dateTime(2013, 9, 23, 9, 4, 30), dateTime(2013, 9, 23, 9, 5, 30),
245 dateTime(2013, 9, 23, 9, 4, 30), dateTime(2013, 9, 23, 9, 5, 30),
176 dateTime(2013, 9, 23, 9, 6, 30), dateTime(2013, 9, 23, 9, 7, 30),
246 dateTime(2013, 9, 23, 9, 6, 30), dateTime(2013, 9, 23, 9, 7, 30),
177 dateTime(2013, 9, 23, 9, 8, 30), dateTime(2013, 9, 23, 9, 9, 30)},
247 dateTime(2013, 9, 23, 9, 8, 30), dateTime(2013, 9, 23, 9, 9, 30)})
178 QVector<double>{-2.83950, -2.71850, -2.52150, -2.57633, -2.58050, -2.48325, -2.63025,
248 .setValuesData({-2.83950, -2.71850, -2.52150, -2.57633, -2.58050, -2.48325, -2.63025,
179 -2.55800, -2.43250, -2.42200}};
249 -2.55800, -2.43250, -2.42200});
180
250
181 QTest::newRow("Valid file (value of first line is invalid but it is converted to NaN")
251 QTest::newRow("Valid file (value of first line is invalid but it is converted to NaN")
182 << QStringLiteral("WrongValue.txt")
252 << QStringLiteral("WrongValue.txt")
183 << ExpectedResults<ScalarSeries>{
253 << ExpectedResults<ScalarSeries>{}
184 Unit{QStringLiteral("nT"), true}, Unit{},
254 .setParsingOK(true)
185 QVector<QDateTime>{dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
255 .setXAxisUnit(Unit{"nT", true})
186 dateTime(2013, 9, 23, 9, 2, 30)},
256 .setXAxisData({dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
187 QVector<double>{std::numeric_limits<double>::quiet_NaN(), -2.71850, -2.52150}};
257 dateTime(2013, 9, 23, 9, 2, 30)})
258 .setValuesData({std::numeric_limits<double>::quiet_NaN(), -2.71850, -2.52150});
188
259
189 QTest::newRow("Valid file that contains NaN values")
260 QTest::newRow("Valid file that contains NaN values")
190 << QStringLiteral("NaNValue.txt")
261 << QStringLiteral("NaNValue.txt")
191 << ExpectedResults<ScalarSeries>{
262 << ExpectedResults<ScalarSeries>{}
192 Unit{QStringLiteral("nT"), true}, Unit{},
263 .setParsingOK(true)
193 QVector<QDateTime>{dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
264 .setXAxisUnit(Unit{("nT"), true})
194 dateTime(2013, 9, 23, 9, 2, 30)},
265 .setXAxisData({dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
195 QVector<double>{std::numeric_limits<double>::quiet_NaN(), -2.71850, -2.52150}};
266 dateTime(2013, 9, 23, 9, 2, 30)})
267 .setValuesData({std::numeric_limits<double>::quiet_NaN(), -2.71850, -2.52150});
196
268
197 // Valid files but with some invalid lines (wrong unit, wrong values, etc.)
269 // Valid files but with some invalid lines (wrong unit, wrong values, etc.)
198 QTest::newRow("No unit file") << QStringLiteral("NoUnit.txt")
270 QTest::newRow("No unit file")
199 << ExpectedResults<ScalarSeries>{Unit{QStringLiteral(""), true},
271 << QStringLiteral("NoUnit.txt")
200 Unit{}, QVector<QDateTime>{},
272 << ExpectedResults<ScalarSeries>{}.setParsingOK(true).setXAxisUnit(Unit{"", true});
201 QVector<double>{}};
273
202 QTest::newRow("Wrong unit file")
274 QTest::newRow("Wrong unit file")
203 << QStringLiteral("WrongUnit.txt")
275 << QStringLiteral("WrongUnit.txt")
204 << ExpectedResults<ScalarSeries>{Unit{QStringLiteral(""), true}, Unit{},
276 << ExpectedResults<ScalarSeries>{}
205 QVector<QDateTime>{dateTime(2013, 9, 23, 9, 0, 30),
277 .setParsingOK(true)
206 dateTime(2013, 9, 23, 9, 1, 30),
278 .setXAxisUnit(Unit{"", true})
207 dateTime(2013, 9, 23, 9, 2, 30)},
279 .setXAxisData({dateTime(2013, 9, 23, 9, 0, 30), dateTime(2013, 9, 23, 9, 1, 30),
208 QVector<double>{-2.83950, -2.71850, -2.52150}};
280 dateTime(2013, 9, 23, 9, 2, 30)})
281 .setValuesData({-2.83950, -2.71850, -2.52150});
209
282
210 QTest::newRow("Wrong results file (date of first line is invalid")
283 QTest::newRow("Wrong results file (date of first line is invalid")
211 << QStringLiteral("WrongDate.txt")
284 << QStringLiteral("WrongDate.txt")
212 << ExpectedResults<ScalarSeries>{
285 << ExpectedResults<ScalarSeries>{}
213 Unit{QStringLiteral("nT"), true}, Unit{},
286 .setParsingOK(true)
214 QVector<QDateTime>{dateTime(2013, 9, 23, 9, 1, 30), dateTime(2013, 9, 23, 9, 2, 30)},
287 .setXAxisUnit(Unit{"nT", true})
215 QVector<double>{-2.71850, -2.52150}};
288 .setXAxisData({dateTime(2013, 9, 23, 9, 1, 30), dateTime(2013, 9, 23, 9, 2, 30)})
289 .setValuesData({-2.71850, -2.52150});
216
290
217 QTest::newRow("Wrong results file (too many values for first line")
291 QTest::newRow("Wrong results file (too many values for first line")
218 << QStringLiteral("TooManyValues.txt")
292 << QStringLiteral("TooManyValues.txt")
219 << ExpectedResults<ScalarSeries>{
293 << ExpectedResults<ScalarSeries>{}
220 Unit{QStringLiteral("nT"), true}, Unit{},
294 .setParsingOK(true)
221 QVector<QDateTime>{dateTime(2013, 9, 23, 9, 1, 30), dateTime(2013, 9, 23, 9, 2, 30)},
295 .setXAxisUnit(Unit{"nT", true})
222 QVector<double>{-2.71850, -2.52150}};
296 .setXAxisData({dateTime(2013, 9, 23, 9, 1, 30), dateTime(2013, 9, 23, 9, 2, 30)})
297 .setValuesData({-2.71850, -2.52150});
223
298
224 QTest::newRow("Wrong results file (x of first line is NaN")
299 QTest::newRow("Wrong results file (x of first line is NaN")
225 << QStringLiteral("NaNX.txt")
300 << QStringLiteral("NaNX.txt")
226 << ExpectedResults<ScalarSeries>{
301 << ExpectedResults<ScalarSeries>{}
227 Unit{QStringLiteral("nT"), true}, Unit{},
302 .setParsingOK(true)
228 QVector<QDateTime>{dateTime(2013, 9, 23, 9, 1, 30), dateTime(2013, 9, 23, 9, 2, 30)},
303 .setXAxisUnit(Unit{"nT", true})
229 QVector<double>{-2.71850, -2.52150}};
304 .setXAxisData({dateTime(2013, 9, 23, 9, 1, 30), dateTime(2013, 9, 23, 9, 2, 30)})
305 .setValuesData({-2.71850, -2.52150});
230
306
231 QTest::newRow("Invalid file type (vector)")
307 QTest::newRow("Invalid file type (vector)")
232 << QStringLiteral("ValidVector1.txt")
308 << QStringLiteral("ValidVector1.txt")
233 << ExpectedResults<ScalarSeries>{Unit{QStringLiteral("nT"), true}, Unit{},
309 << ExpectedResults<ScalarSeries>{}.setParsingOK(true).setXAxisUnit(Unit{"nT", true});
234 QVector<QDateTime>{}, QVector<double>{}};
235
310
236 // Invalid files
311 // Invalid files
237 QTest::newRow("Invalid file (unexisting file)") << QStringLiteral("UnexistingFile.txt")
312 QTest::newRow("Invalid file (unexisting file)")
238 << ExpectedResults<ScalarSeries>{};
313 << QStringLiteral("UnexistingFile.txt")
314 << ExpectedResults<ScalarSeries>{}.setParsingOK(false);
239
315
240 QTest::newRow("Invalid file (file not found on server)") << QStringLiteral("FileNotFound.txt")
316 QTest::newRow("Invalid file (file not found on server)")
241 << ExpectedResults<ScalarSeries>{};
317 << QStringLiteral("FileNotFound.txt")
318 << ExpectedResults<ScalarSeries>{}.setParsingOK(false);
242 }
319 }
243
320
244 void TestAmdaResultParser::testReadScalarTxt()
321 void TestAmdaResultParser::testReadScalarTxt()
@@ -246,6 +323,91 void TestAmdaResultParser::testReadScalarTxt()
246 testRead<ScalarSeries>(AmdaResultParser::ValueType::SCALAR);
323 testRead<ScalarSeries>(AmdaResultParser::ValueType::SCALAR);
247 }
324 }
248
325
326 void TestAmdaResultParser::testReadSpectrogramTxt_data()
327 {
328 testReadDataStructure<SpectrogramSeries>();
329
330 // ////////// //
331 // Test cases //
332 // ////////// //
333
334 // Valid files
335 QTest::newRow("Valid file (three bands)")
336 << QStringLiteral("spectro/ValidSpectrogram1.txt")
337 << ExpectedResults<SpectrogramSeries>{}
338 .setParsingOK(true)
339 .setXAxisUnit(Unit{"t", true})
340 .setXAxisData({dateTime(2012, 11, 6, 9, 14, 35), dateTime(2012, 11, 6, 9, 16, 10),
341 dateTime(2012, 11, 6, 9, 17, 45), dateTime(2012, 11, 6, 9, 19, 20),
342 dateTime(2012, 11, 6, 9, 20, 55)})
343 .setYAxisEnabled(true)
344 .setYAxisUnit(Unit{"eV"})
345 .setYAxisData({5.75, 7.6, 10.05}) // middle of the intervals of each band
346 .setValuesUnit(Unit{"eV/(cm^2-s-sr-eV)"})
347 .setValuesData(QVector<QVector<double> >{
348 {16313.780, 12631.465, 8223.368, 27595.301, 12820.613},
349 {15405.838, 11957.925, 15026.249, 25617.533, 11179.109},
350 {8946.475, 18133.158, 10875.621, 24051.619, 19283.221}});
351
352 auto fourBandsResult
353 = ExpectedResults<SpectrogramSeries>{}
354 .setParsingOK(true)
355 .setXAxisUnit(Unit{"t", true})
356 .setXAxisData({dateTime(2012, 11, 6, 9, 14, 35), dateTime(2012, 11, 6, 9, 16, 10),
357 dateTime(2012, 11, 6, 9, 17, 45), dateTime(2012, 11, 6, 9, 19, 20),
358 dateTime(2012, 11, 6, 9, 20, 55)})
359 .setYAxisEnabled(true)
360 .setYAxisUnit(Unit{"eV"})
361 .setYAxisData({5.75, 7.6, 10.05, 13.}) // middle of the intervals of each band
362 .setValuesUnit(Unit{"eV/(cm^2-s-sr-eV)"})
363 .setValuesData(QVector<QVector<double> >{
364 {16313.780, 12631.465, 8223.368, 27595.301, 12820.613},
365 {15405.838, 11957.925, 15026.249, 25617.533, 11179.109},
366 {8946.475, 18133.158, 10875.621, 24051.619, 19283.221},
367 {20907.664, 32076.725, 13008.381, 13142.759, 23226.998}});
368
369 QTest::newRow("Valid file (four bands)")
370 << QStringLiteral("spectro/ValidSpectrogram2.txt") << fourBandsResult;
371 QTest::newRow("Valid file (four unsorted bands)")
372 << QStringLiteral("spectro/ValidSpectrogram3.txt")
373 << fourBandsResult; // Bands and values are sorted
374
375 auto nan = std::numeric_limits<double>::quiet_NaN();
376
377 auto nanValuesResult
378 = ExpectedResults<SpectrogramSeries>{}
379 .setParsingOK(true)
380 .setXAxisUnit(Unit{"t", true})
381 .setXAxisData({dateTime(2012, 11, 6, 9, 14, 35), dateTime(2012, 11, 6, 9, 16, 10),
382 dateTime(2012, 11, 6, 9, 17, 45), dateTime(2012, 11, 6, 9, 19, 20),
383 dateTime(2012, 11, 6, 9, 20, 55)})
384 .setYAxisEnabled(true)
385 .setYAxisUnit(Unit{"eV"})
386 .setYAxisData({5.75, 7.6, 10.05, 13.}) // middle of the intervals of each band
387 .setValuesUnit(Unit{"eV/(cm^2-s-sr-eV)"})
388 .setValuesData(
389 QVector<QVector<double> >{{nan, 12631.465, 8223.368, 27595.301, 12820.613},
390 {15405.838, nan, nan, 25617.533, 11179.109},
391 {8946.475, 18133.158, 10875.621, 24051.619, 19283.221},
392 {nan, nan, nan, nan, nan}});
393
394 QTest::newRow("Valid file (containing NaN values)")
395 << QStringLiteral("spectro/ValidSpectrogramNaNValues.txt") << nanValuesResult;
396 QTest::newRow("Valid file (containing fill values)")
397 << QStringLiteral("spectro/ValidSpectrogramFillValues.txt")
398 << nanValuesResult; // Fill values are replaced by NaN values in the data series
399
400 // Invalid files
401 QTest::newRow("Invalid file (inconsistent bands)")
402 << QStringLiteral("spectro/InvalidSpectrogramWrongBands.txt")
403 << ExpectedResults<SpectrogramSeries>{}.setParsingOK(false);
404 }
405
406 void TestAmdaResultParser::testReadSpectrogramTxt()
407 {
408 testRead<SpectrogramSeries>(AmdaResultParser::ValueType::SPECTROGRAM);
409 }
410
249 void TestAmdaResultParser::testReadVectorTxt_data()
411 void TestAmdaResultParser::testReadVectorTxt_data()
250 {
412 {
251 testReadDataStructure<VectorSeries>();
413 testReadDataStructure<VectorSeries>();
@@ -257,24 +419,27 void TestAmdaResultParser::testReadVectorTxt_data()
257 // Valid files
419 // Valid files
258 QTest::newRow("Valid file")
420 QTest::newRow("Valid file")
259 << QStringLiteral("ValidVector1.txt")
421 << QStringLiteral("ValidVector1.txt")
260 << ExpectedResults<VectorSeries>{
422 << ExpectedResults<VectorSeries>{}
261 Unit{QStringLiteral("nT"), true}, Unit{},
423 .setParsingOK(true)
262 QVector<QDateTime>{dateTime(2013, 7, 2, 9, 13, 50), dateTime(2013, 7, 2, 9, 14, 6),
424 .setXAxisUnit(Unit{"nT", true})
425 .setXAxisData({dateTime(2013, 7, 2, 9, 13, 50), dateTime(2013, 7, 2, 9, 14, 6),
263 dateTime(2013, 7, 2, 9, 14, 22), dateTime(2013, 7, 2, 9, 14, 38),
426 dateTime(2013, 7, 2, 9, 14, 22), dateTime(2013, 7, 2, 9, 14, 38),
264 dateTime(2013, 7, 2, 9, 14, 54), dateTime(2013, 7, 2, 9, 15, 10),
427 dateTime(2013, 7, 2, 9, 14, 54), dateTime(2013, 7, 2, 9, 15, 10),
265 dateTime(2013, 7, 2, 9, 15, 26), dateTime(2013, 7, 2, 9, 15, 42),
428 dateTime(2013, 7, 2, 9, 15, 26), dateTime(2013, 7, 2, 9, 15, 42),
266 dateTime(2013, 7, 2, 9, 15, 58), dateTime(2013, 7, 2, 9, 16, 14)},
429 dateTime(2013, 7, 2, 9, 15, 58), dateTime(2013, 7, 2, 9, 16, 14)})
267 QVector<QVector<double> >{
430 .setValuesData(
268 {-0.332, -1.011, -1.457, -1.293, -1.217, -1.443, -1.278, -1.202, -1.22, -1.259},
431 {{-0.332, -1.011, -1.457, -1.293, -1.217, -1.443, -1.278, -1.202, -1.22, -1.259},
269 {3.206, 2.999, 2.785, 2.736, 2.612, 2.564, 2.892, 2.862, 2.859, 2.764},
432 {3.206, 2.999, 2.785, 2.736, 2.612, 2.564, 2.892, 2.862, 2.859, 2.764},
270 {0.058, 0.496, 1.018, 1.485, 1.662, 1.505, 1.168, 1.244, 1.15, 1.358}}};
433 {0.058, 0.496, 1.018, 1.485, 1.662, 1.505, 1.168, 1.244, 1.15, 1.358}});
271
434
272 // Valid files but with some invalid lines (wrong unit, wrong values, etc.)
435 // Valid files but with some invalid lines (wrong unit, wrong values, etc.)
273 QTest::newRow("Invalid file type (scalar)")
436 QTest::newRow("Invalid file type (scalar)")
274 << QStringLiteral("ValidScalar1.txt")
437 << QStringLiteral("ValidScalar1.txt")
275 << ExpectedResults<VectorSeries>{Unit{QStringLiteral("nT"), true}, Unit{},
438 << ExpectedResults<VectorSeries>{}
276 QVector<QDateTime>{},
439 .setParsingOK(true)
277 QVector<QVector<double> >{{}, {}, {}}};
440 .setXAxisUnit(Unit{"nT", true})
441 .setXAxisData({})
442 .setValuesData(QVector<QVector<double> >{{}, {}, {}});
278 }
443 }
279
444
280 void TestAmdaResultParser::testReadVectorTxt()
445 void TestAmdaResultParser::testReadVectorTxt()
General Comments 0
You need to be logged in to leave comments. Login now