##// END OF EJS Templates
MultiComponent TS almost complete...
jeandet -
r1432:db5304cf6c8c
parent child
Show More
@@ -1,1 +1,1
1 Subproject commit 41273d8529cddde1c8b6bcea03d71d9cd1a18c06
1 Subproject commit 9a080a34054c21a67236f761e8843005c07ff0ba
@@ -95,7 +95,8 struct AxisSetter
95 95 template <typename T>
96 96 struct AxisSetter<T,
97 97 typename std::enable_if_t<std::is_base_of<ScalarTimeSerie, T>::value
98 or std::is_base_of<VectorTimeSerie, T>::value>>
98 or std::is_base_of<VectorTimeSerie, T>::value
99 or std::is_base_of<MultiComponentTimeSerie, T>::value>>
99 100 {
100 101 static void setProperties(QCustomPlot&, SqpColorScale&)
101 102 {
@@ -204,6 +205,9 std::unique_ptr<IAxisHelper> IAxisHelperFactory::create(Variable2& variable) noe
204 205 case DataSeriesType::VECTOR:
205 206 return std::make_unique<AxisHelper<VectorTimeSerie>>(
206 207 std::dynamic_pointer_cast<VectorTimeSerie>(variable.data()));
208 case DataSeriesType::MULTICOMPONENT:
209 return std::make_unique<AxisHelper<MultiComponentTimeSerie>>(
210 std::dynamic_pointer_cast<MultiComponentTimeSerie>(variable.data()));
207 211 default:
208 212 // Creates default helper
209 213 break;
@@ -33,7 +33,8 struct PlottablesSetter
33 33 template <typename T>
34 34 struct PlottablesSetter<T,
35 35 typename std::enable_if_t<std::is_base_of<ScalarTimeSerie, T>::value
36 or std::is_base_of<VectorTimeSerie, T>::value>>
36 or std::is_base_of<VectorTimeSerie, T>::value
37 or std::is_base_of<MultiComponentTimeSerie, T>::value>>
37 38 {
38 39 static void setProperties(PlottablesMap& plottables)
39 40 {
@@ -124,6 +125,8 std::unique_ptr<IPlottablesHelper> IPlottablesHelperFactory::create(Variable2& v
124 125 return std::make_unique<PlottablesHelper<SpectrogramTimeSerie>>();
125 126 case DataSeriesType::VECTOR:
126 127 return std::make_unique<PlottablesHelper<VectorTimeSerie>>();
128 case DataSeriesType::MULTICOMPONENT:
129 return std::make_unique<PlottablesHelper<MultiComponentTimeSerie>>();
127 130 default:
128 131 // Returns default helper
129 132 break;
@@ -261,7 +261,8 struct PlottablesUpdater<T, typename std::enable_if_t<std::is_base_of<VectorTime
261 261
262 262
263 263 template <typename T>
264 struct PlottablesUpdater<T, typename std::enable_if_t<std::is_base_of<MultiComponentTimeSerie, T>::value>>
264 struct PlottablesUpdater<T,
265 typename std::enable_if_t<std::is_base_of<MultiComponentTimeSerie, T>::value>>
265 266 {
266 267 static void setPlotYAxisRange(T& dataSeries, const DateTimeRange& xAxisRange, QCustomPlot& plot)
267 268 {
@@ -269,11 +270,13 struct PlottablesUpdater<T, typename std::enable_if_t<std::is_base_of<MultiCompo
269 270 if (auto serie = dynamic_cast<MultiComponentTimeSerie*>(&dataSeries))
270 271 {
271 272 // TODO
272 // std::for_each(
273 // std::begin(*serie), std::end(*serie), [&minValue, &maxValue](const auto& v) {
274 // minValue = std::min({ minValue, std::min_element(v.begin(),v.end()) });
275 // maxValue = std::max({ maxValue, std::max_element(v.begin(),v.end()) });
276 // });
273 // std::for_each(
274 // std::begin(*serie), std::end(*serie), [&minValue, &maxValue](const
275 // auto& v) {
276 // minValue = std::min({ minValue,
277 // std::min_element(v.begin(),v.end()) }); maxValue = std::max({
278 // maxValue, std::max_element(v.begin(),v.end()) });
279 // });
277 280 }
278 281
279 282 plot.yAxis->setRange(QCPRange { minValue, maxValue });
@@ -289,7 +292,12 struct PlottablesUpdater<T, typename std::enable_if_t<std::is_base_of<MultiCompo
289 292 auto dataContainer = QSharedPointer<SqpDataContainer>::create();
290 293 if (auto serie = dynamic_cast<MultiComponentTimeSerie*>(&dataSeries))
291 294 {
292 // TODO
295 // TODO
296 std::for_each(std::begin(*serie), std::end(*serie),
297 [&dataContainer, component = plottable.first](const auto& value) {
298 dataContainer->appendGraphData(
299 QCPGraphData(value.t(), value[component]));
300 });
293 301 }
294 302 graph->setData(dataContainer);
295 303 }
@@ -8,6 +8,7 import pysciqlopcore
8 8 import numpy as np
9 9 import pandas as pds
10 10 import requests
11 import copy
11 12 from spwc.amda import AMDA
12 13
13 14 amda = AMDA()
@@ -22,13 +23,15 def get_sample(metadata,start,stop):
22 23 elif key == 'type':
23 24 if value == 'vector':
24 25 ts_type = pysciqlopcore.VectorTimeSerie
25 tstart=datetime.datetime.utcfromtimestamp(start)
26 tend=datetime.datetime.utcfromtimestamp(stop)
26 elif value == 'multicomponent':
27 ts_type = pysciqlopcore.MultiComponentTimeSerie
28 tstart=datetime.datetime.fromtimestamp(start, tz=timezone.utc)
29 tend=datetime.datetime.fromtimestamp(stop, tz=timezone.utc)
27 30 df = amda.get_parameter(start_time=tstart, stop_time=tend, parameter_id=param_id)
28 31 #t = np.array([d.timestamp()-7200 for d in df.index])
29 32 t = np.array([d.timestamp() for d in df.index])
30 33 values = df.values
31 return ts_type(t,values)
34 return ts_type(t,values.transpose())
32 35 return ts_type(1)
33 36 except Exception as e:
34 37 print(traceback.format_exc())
@@ -38,7 +41,7 def get_sample(metadata,start,stop):
38 41
39 42 if len(amda.component) is 0:
40 43 amda.update_inventory()
41 parameters = amda.parameter.copy()
44 parameters = copy.deepcopy(amda.parameter)
42 45 for name,component in amda.component.items():
43 46 if 'components' in parameters[component['parameter']]:
44 47 parameters[component['parameter']]['components'].append(component)
@@ -50,8 +53,11 for key,parameter in parameters.items():
50 53 path = f"/AMDA/{parameter['mission']}/{parameter['instrument']}/{parameter['dataset']}/{parameter['name']}"
51 54 components = [component['name'] for component in parameter.get('components',[])]
52 55 metadata = [ (key,item) for key,item in parameter.items() if key is not 'components' ]
53 if parameter.get('size',0) is '3':
56 n_components = parameter.get('size',0)
57 if n_components is '3':
54 58 metadata.append(("type","vector"))
59 elif n_components !=0:
60 metadata.append(("type","multicomponent"))
55 61 else:
56 62 metadata.append(("type","scalar"))
57 63 products.append( (path, components, metadata))
@@ -6,12 +6,39 import numpy as np
6 6
7 7 someglobal = 1
8 8
9 def test(name,start,stop):
10 x = np.arange(start, stop)
9 def make_scalar(x):
11 10 y = np.cos(x/10.)
12 11 return pysciqlopcore.ScalarTimeSerie(x,y)
13 12
13 def make_vector(x):
14 v=np.ones((3,len(x)))
15 for i in range(3):
16 v[:][i] = np.cos(x/10. + float(i))
17 return pysciqlopcore.VectorTimeSerie(x,v)
18
19
20 def make_multicomponent(x):
21 v=np.ones((4,len(x)))
22 for i in range(4):
23 v[:][i] = float(i+1) * np.cos(x/10. + float(i))
24 return pysciqlopcore.MultiComponentTimeSerie(x,v)
25
26
27 def get_data(metadata,start,stop):
28 x = np.arange(start, stop)
29 for key,value in metadata:
30 if key == 'xml:id':
31 param_id = value
32 elif key == 'type':
33 if value == 'vector':
34 return make_vector(x)
35 elif value == 'multicomponent':
36 return make_multicomponent(x)
37 return make_scalar(x)
38
39
40
14 41
15 #PythonProviders.register_product(["/folder1/folder2/product1", "/folder1/folder3/product2", "/folder4/folder5/product3"],test)
42 PythonProviders.register_product([("/tests/scalar",[],[("type","scalar")]), ("/tests/vector",[],[("type","vector")]), ("/tests/multicomponent",[],[("type","multicomponent"),('size','4')])],get_data)
16 43
17 44
General Comments 0
You need to be logged in to leave comments. Login now