##// END OF EJS Templates
Added back AMDA plugin, but Python impl this time :)...
jeandet -
r1496:7c6302eee778
parent child
Show More
@@ -0,0 +1,124
1 import traceback
2 import os
3 from datetime import datetime, timedelta, timezone
4 from SciQLopBindings import PyDataProvider, Product, VectorTimeSerie, ScalarTimeSerie, DataSeriesType
5 import numpy as np
6 import requests
7 import copy
8 from spwc.amda import AMDA
9
10 amda = AMDA()
11
12 def amda_make_scalar(var=None):
13 if var is None:
14 return ((np.array(), np.array()), DataSeriesType.SCALAR)
15 else:
16 return ((var.time.copy(),var.data.copy()), DataSeriesType.SCALAR)
17
18 def amda_make_vector(var=None):
19 if var is None:
20 return ((np.array(), np.array()), DataSeriesType.VECTOR)
21 else:
22 return ((var.time.copy(),var.data.copy()), DataSeriesType.VECTOR)
23
24 def amda_make_multi_comp(var=None):
25 if var is None:
26 return ((np.array(), np.array()), DataSeriesType.MULTICOMPONENT)
27 else:
28 return ((var.time.copy(),var.data.copy()), DataSeriesType.MULTICOMPONENT)
29
30 def amda_make_spectro(var=None):
31 if var is None:
32 return ((np.array(), np.array()), DataSeriesType.SPECTROGRAM)
33 else:
34 min_sampling = float(var.meta.get("DATASET_MIN_SAMPLING","nan"))
35 max_sampling = float(var.meta.get("DATASET_MAX_SAMPLING","nan"))
36 if "PARAMETER_TABLE_MIN_VALUES[1]" in var.meta:
37 min_v = np.array([ float(v) for v in var.meta["PARAMETER_TABLE_MIN_VALUES[1]"].split(',') ])
38 max_v = np.array([ float(v) for v in var.meta["PARAMETER_TABLE_MAX_VALUES[1]"].split(',') ])
39 y = (max_v + min_v)/2.
40 elif "PARAMETER_TABLE_MIN_VALUES[0]" in var.meta:
41 min_v = np.array([ float(v) for v in var.meta["PARAMETER_TABLE_MIN_VALUES[0]"].split(',') ])
42 max_v = np.array([ float(v) for v in var.meta["PARAMETER_TABLE_MAX_VALUES[0]"].split(',') ])
43 y = (max_v + min_v)/2.
44 else:
45 y = np.logspace(1,3,var.data.shape[1])[::-1]
46 return ((var.time.copy(),var.data.copy()), DataSeriesType.SPECTROGRAM)
47 #return pysciqlopcore.SpectrogramTimeSerie(var.time,y,var.data,min_sampling,max_sampling,True)
48
49 def amda_get_sample(metadata,start,stop):
50 ts_type = amda_make_scalar
51 try:
52 param_id = None
53 for key,value in metadata:
54 if key == 'xml:id':
55 param_id = value
56 elif key == 'type':
57 if value == 'vector':
58 ts_type = amda_make_vector
59 elif value == 'multicomponent':
60 ts_type = amda_make_multi_comp
61 elif value == 'spectrogram':
62 ts_type = amda_make_spectro
63 tstart=datetime.fromtimestamp(start, tz=timezone.utc)
64 tend=datetime.fromtimestamp(stop, tz=timezone.utc)
65 var = amda.get_parameter(start_time=tstart, stop_time=tend, parameter_id=param_id, method="REST")
66 return ts_type(var)
67 except Exception as e:
68 print(traceback.format_exc())
69 print("Error in amda.py ",str(e))
70 return ts_type()
71
72
73 class AmdaProvider(PyDataProvider):
74 def __init__(self):
75 super(AmdaProvider,self).__init__()
76 if len(amda.component) is 0:
77 amda.update_inventory()
78 parameters = copy.deepcopy(amda.parameter)
79 for name,component in amda.component.items():
80 if 'components' in parameters[component['parameter']]:
81 parameters[component['parameter']]['components'].append(component)
82 else:
83 parameters[component['parameter']]['components']=[component]
84
85 products = []
86 for key,parameter in parameters.items():
87 path = f"/AMDA/{parameter['mission']}/{parameter.get('observatory','')}/{parameter['instrument']}/{parameter['dataset']}/{parameter['name']}"
88 components = [component['name'] for component in parameter.get('components',[])]
89 metadata = { key:item for key,item in parameter.items() if key is not 'components' }
90 n_components = parameter.get('size',0)
91 if n_components == '3':
92 metadata["type"]="vector"
93 elif parameter.get('display_type','')=="spectrogram":
94 metadata["type"]="spectrogram"
95 elif n_components !=0:
96 metadata["type"]="multicomponent"
97 else:
98 metadata["type"]="scalar"
99 products.append( Product(path, components, metadata))
100 self.register_products(products)
101 for mission in amda.mission:
102 self.set_icon(f'/AMDA/{mission}','satellite')
103
104 def get_data(self,metadata,start,stop):
105 ts_type = amda_make_scalar
106 try:
107 param_id = metadata['xml:id']
108 ts_type_str = metadata['type']
109 if ts_type_str == 'vector':
110 ts_type = amda_make_vector
111 elif ts_type_str == 'multicomponent':
112 ts_type = amda_make_multi_comp
113 elif ts_type_str == 'spectrogram':
114 ts_type = amda_make_spectro
115 tstart=datetime.fromtimestamp(start, tz=timezone.utc)
116 tend=datetime.fromtimestamp(stop, tz=timezone.utc)
117 var = amda.get_parameter(start_time=tstart, stop_time=tend, parameter_id=param_id, method="REST")
118 return ts_type(var)
119 except Exception as e:
120 print(traceback.format_exc())
121 print("Error in amda.py ",str(e))
122 return ts_type()
123
124 _amda = AmdaProvider()
@@ -0,0 +1,260
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
4 <svg
5 xmlns:dc="http://purl.org/dc/elements/1.1/"
6 xmlns:cc="http://creativecommons.org/ns#"
7 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8 xmlns:svg="http://www.w3.org/2000/svg"
9 xmlns="http://www.w3.org/2000/svg"
10 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12 id="svg4437"
13 version="1.1"
14 inkscape:version="0.92.4 (unknown)"
15 width="307"
16 height="158"
17 sodipodi:docname="satellite.svg">
18 <metadata
19 id="metadata4443">
20 <rdf:RDF>
21 <cc:Work
22 rdf:about="">
23 <dc:format>image/svg+xml</dc:format>
24 <dc:type
25 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
26 <dc:title></dc:title>
27 </cc:Work>
28 </rdf:RDF>
29 </metadata>
30 <defs
31 id="defs4441" />
32 <sodipodi:namedview
33 pagecolor="#ffffff"
34 bordercolor="#666666"
35 borderopacity="1"
36 objecttolerance="10"
37 gridtolerance="10"
38 guidetolerance="10"
39 inkscape:pageopacity="0"
40 inkscape:pageshadow="2"
41 inkscape:window-width="2560"
42 inkscape:window-height="1376"
43 id="namedview4439"
44 showgrid="false"
45 inkscape:zoom="2.0064155"
46 inkscape:cx="404.11031"
47 inkscape:cy="175.13214"
48 inkscape:window-x="2560"
49 inkscape:window-y="27"
50 inkscape:window-maximized="1"
51 inkscape:current-layer="svg4437">
52 <inkscape:grid
53 type="xygrid"
54 id="grid4959" />
55 </sodipodi:namedview>
56 <g
57 inkscape:groupmode="layer"
58 id="layer1"
59 inkscape:label="Layer 1"
60 transform="translate(0,-242)">
61 <path
62 style="fill:#000000;fill-opacity:1;stroke:none"
63 d="m 115.77577,336.08354 17.81454,-48.43596 24.69555,-3.13086 11.31724,3.2219 20.68325,19.13803 -17.60732,50.11469 -23.51037,9.49468 -22.92646,-7.97442 z"
64 id="path4448"
65 inkscape:connector-curvature="0"
66 sodipodi:nodetypes="ccccccccc" />
67 </g>
68 <g
69 inkscape:groupmode="layer"
70 id="layer2"
71 inkscape:label="Layer2"
72 transform="translate(0,-242)">
73 <path
74 style="fill:#000000;fill-opacity:1;stroke:none"
75 d="m 121.6147,377.93505 10.57545,-18.33761 11.59408,3.95814 -2.84607,20.97636 z"
76 id="path4961"
77 inkscape:connector-curvature="0" />
78 </g>
79 <g
80 id="g4978"
81 transform="rotate(-18.168185,-166.03465,383.32882)"
82 style="fill:#000000;fill-opacity:1;stroke:none;stroke-opacity:1">
83 <path
84 sodipodi:nodetypes="ssssssssssssssssss"
85 inkscape:connector-curvature="0"
86 id="path4963"
87 d="m 290.03125,131.375 c -5.12246,0 -15.85135,7.26238 -18.87486,12.80548 -3.02351,5.5431 -5.16493,8.80227 -5.16493,17.05217 0,8.2499 1.78899,12.21393 4.8125,17.75703 3.02351,5.5431 14.10483,13.51032 19.22729,13.51032 5.12246,0 9.50774,-3.73815 12.53125,-9.28125 3.02351,-5.5431 4.84375,-13.03135 4.84375,-21.28125 0,-8.2499 -1.82024,-15.73815 -4.84375,-21.28125 -3.02351,-5.5431 -7.40879,-9.28125 -12.53125,-9.28125 z m 0,3 c 3.63625,0 7.18992,2.73881 9.90625,7.71875 2.71633,4.97994 4.46875,12.03603 4.46875,19.84375 0,7.80772 -1.75242,14.86381 -4.46875,19.84375 -2.71633,4.97994 -6.27,7.71875 -9.90625,7.71875 -3.63625,0 -7.15867,-2.73881 -9.875,-7.71875 -2.71633,-4.97994 -4.46875,-12.03603 -4.46875,-19.84375 0,-7.80772 1.75242,-14.86381 4.46875,-19.84375 2.71633,-4.97994 6.23875,-7.71875 9.875,-7.71875 z"
88 style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:Sans;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;baseline-shift:baseline;text-anchor:start;display:inline;overflow:visible;visibility:visible;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3;marker:none;enable-background:accumulate" />
89 <rect
90 ry="0.23655923"
91 y="143.4912"
92 x="269.29535"
93 height="0.7551648"
94 width="33.616547"
95 id="rect4969"
96 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
97 transform="matrix(0.99806914,0.06211281,0.07469932,0.9972061,0,0)" />
98 <ellipse
99 transform="matrix(0.77587022,0,0,0.80357988,69.860721,32.761382)"
100 id="path4975"
101 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
102 cx="314.44934"
103 cy="161.4097"
104 rx="2.5550661"
105 ry="2.4669604" />
106 </g>
107 <rect
108 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
109 id="rect4983"
110 width="3.7996066"
111 height="23.331676"
112 x="150.11719"
113 y="-98.335892"
114 ry="0.40695283"
115 transform="matrix(0.72487381,0.68888167,-0.71868209,0.69533881,0,0)" />
116 <rect
117 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
118 id="rect4985"
119 width="23.964754"
120 height="23.612339"
121 x="48.285038"
122 y="26.776302"
123 ry="0"
124 transform="rotate(19.88622)" />
125 <rect
126 ry="0"
127 y="-1.7701057"
128 x="48.285038"
129 height="23.612339"
130 width="23.964754"
131 id="rect4987"
132 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
133 transform="rotate(19.88622)" />
134 <rect
135 ry="0"
136 y="26.776302"
137 x="77.183228"
138 height="23.612339"
139 width="23.964754"
140 id="rect4991"
141 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
142 transform="rotate(19.88622)" />
143 <rect
144 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
145 id="rect4993"
146 width="23.964754"
147 height="23.612339"
148 x="77.183228"
149 y="-1.7701057"
150 ry="0"
151 transform="rotate(19.88622)" />
152 <rect
153 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
154 id="rect4995"
155 width="23.964754"
156 height="23.612339"
157 x="19.034573"
158 y="26.423878"
159 ry="0"
160 transform="rotate(19.88622)" />
161 <rect
162 ry="0"
163 y="-1.7701057"
164 x="19.386967"
165 height="23.612339"
166 width="23.964754"
167 id="rect4997"
168 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
169 transform="rotate(19.88622)" />
170 <rect
171 ry="0"
172 y="26.776302"
173 x="106.78786"
174 height="23.612339"
175 width="23.964754"
176 id="rect4999"
177 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
178 transform="rotate(19.88622)" />
179 <rect
180 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
181 id="rect5001"
182 width="23.964754"
183 height="23.612339"
184 x="106.78786"
185 y="-1.7701057"
186 ry="0"
187 transform="rotate(19.88622)" />
188 <rect
189 transform="rotate(19.88622)"
190 ry="0"
191 y="27.104183"
192 x="242.16132"
193 height="23.612339"
194 width="23.964754"
195 id="rect5003"
196 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
197 <rect
198 transform="rotate(19.88622)"
199 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
200 id="rect5005"
201 width="23.964754"
202 height="23.612339"
203 x="242.16132"
204 y="-1.4422622"
205 ry="0" />
206 <rect
207 transform="rotate(19.88622)"
208 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
209 id="rect5007"
210 width="23.964754"
211 height="23.612339"
212 x="271.05969"
213 y="27.104183"
214 ry="0" />
215 <rect
216 transform="rotate(19.88622)"
217 ry="0"
218 y="-1.4422622"
219 x="271.05969"
220 height="23.612339"
221 width="23.964754"
222 id="rect5009"
223 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
224 <rect
225 transform="rotate(19.88622)"
226 ry="0"
227 y="26.751751"
228 x="212.91084"
229 height="23.612339"
230 width="23.964754"
231 id="rect5011"
232 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
233 <rect
234 transform="rotate(19.88622)"
235 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
236 id="rect5013"
237 width="23.964754"
238 height="23.612339"
239 x="213.26323"
240 y="-1.4422622"
241 ry="0" />
242 <rect
243 transform="rotate(19.88622)"
244 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
245 id="rect5015"
246 width="23.964754"
247 height="23.612339"
248 x="300.66321"
249 y="27.104183"
250 ry="0" />
251 <rect
252 transform="rotate(19.88622)"
253 ry="0"
254 y="-1.4422622"
255 x="300.66321"
256 height="23.612339"
257 width="23.964754"
258 id="rect5017"
259 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.0940001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
260 </svg>
@@ -116,6 +116,10 public:
116 return ts;
116 return ts;
117 }
117 }
118
118
119 inline void set_icon(const QString& path, const QString& name)
120 {
121 sqpApp->dataSources().setIcon(path, name);
122 }
119
123
120 inline void register_products(const QVector<Product*>& products)
124 inline void register_products(const QVector<Product*>& products)
121 {
125 {
@@ -1,2 +1,3
1
1
2 configure_file(input:'TestPlugin.py', output:'TestPlugin.py', copy:true)
2 configure_file(input:'TestPlugin.py', output:'TestPlugin.py', copy:true)
3 configure_file(input:'SPWC-Amda.py', output:'SPWC-Amda.py', copy:true)
@@ -28,5 +28,6
28 <file>icones/save.png</file>
28 <file>icones/save.png</file>
29 <file>icones/discard.png</file>
29 <file>icones/discard.png</file>
30 <file>icones/Simple_icon_time.svg</file>
30 <file>icones/Simple_icon_time.svg</file>
31 <file>icones/satellite.svg</file>
31 </qresource>
32 </qresource>
32 </RCC>
33 </RCC>
@@ -32,7 +32,7 DataSourceWidget::DataSourceWidget(QWidget* parent)
32 // Connection to filter tree
32 // Connection to filter tree
33 connect(ui->filterLineEdit, &QLineEdit::textChanged, &m_model_proxy, static_cast<void (QSortFilterProxyModel::*)(const QString&)>(
33 connect(ui->filterLineEdit, &QLineEdit::textChanged, &m_model_proxy, static_cast<void (QSortFilterProxyModel::*)(const QString&)>(
34 &QSortFilterProxyModel::setFilterRegExp));
34 &QSortFilterProxyModel::setFilterRegExp));
35
35 sqpApp->dataSources().addIcon("satellite",QVariant(QIcon(":/icones/satellite.svg")));
36 }
36 }
37
37
38 DataSourceWidget::~DataSourceWidget() noexcept
38 DataSourceWidget::~DataSourceWidget() noexcept
General Comments 0
You need to be logged in to leave comments. Login now