@@ -7,6 +7,7 | |||||
7 | #include <DataSource/datasources.h> |
|
7 | #include <DataSource/datasources.h> | |
8 |
|
8 | |||
9 | #include <QPair> |
|
9 | #include <QPair> | |
|
10 | #include <QList> | |||
10 | #include <SqpApplication.h> |
|
11 | #include <SqpApplication.h> | |
11 | // must be included last because of Python/Qt definition of slots |
|
12 | // must be included last because of Python/Qt definition of slots | |
12 | #include "numpy_wrappers.h" |
|
13 | #include "numpy_wrappers.h" | |
@@ -51,14 +52,14 MultiComponentTimeSerie* make_multi_comp(T& t, T& y) | |||||
51 | } |
|
52 | } | |
52 |
|
53 | |||
53 | template <typename T> |
|
54 | template <typename T> | |
54 | SpectrogramTimeSerie* make_spectro(T& t, T& y) |
|
55 | SpectrogramTimeSerie* make_spectro(T& t, T& y, T& z) | |
55 | { |
|
56 | { | |
56 |
auto |
|
57 | auto z_size = z.flat_size(); | |
57 | auto t_size = t.flat_size(); |
|
58 | auto t_size = t.flat_size(); | |
58 |
if (t_size && ( |
|
59 | if (t_size && (z_size % t_size) == 0) | |
59 | { |
|
60 | { | |
60 | return new SpectrogramTimeSerie { std::move(t.data), std::move(y.data), |
|
61 | return new SpectrogramTimeSerie { std::move(t.data), std::move(y.data), std::move(z.data), | |
61 |
{ t_size, |
|
62 | { t_size, z_size / t_size }, std::nan("1"), std::nan("1") }; | |
62 | } |
|
63 | } | |
63 | return nullptr; |
|
64 | return nullptr; | |
64 | } |
|
65 | } | |
@@ -75,7 +76,7 public: | |||||
75 |
|
76 | |||
76 | virtual ~PyDataProvider() {} |
|
77 | virtual ~PyDataProvider() {} | |
77 |
|
78 | |||
78 |
virtual QPair<QPair<NpArray, |
|
79 | virtual QPair<QPair<QPair<NpArray,NpArray>,NpArray>, DataSeriesType> get_data( | |
79 | const QMap<QString, QString>& key, double start_time, double stop_time) |
|
80 | const QMap<QString, QString>& key, double start_time, double stop_time) | |
80 | { |
|
81 | { | |
81 | (void)key, (void)start_time, (void)stop_time; |
|
82 | (void)key, (void)start_time, (void)stop_time; | |
@@ -94,20 +95,21 public: | |||||
94 | auto [data, type] |
|
95 | auto [data, type] | |
95 | = get_data(metadata, parameters.m_Range.m_TStart, parameters.m_Range.m_TEnd); |
|
96 | = get_data(metadata, parameters.m_Range.m_TStart, parameters.m_Range.m_TEnd); | |
96 |
|
97 | |||
97 |
auto& [ |
|
98 | auto& [axes, values] = data; | |
|
99 | auto& [x, y] = axes; | |||
98 | switch (type) |
|
100 | switch (type) | |
99 | { |
|
101 | { | |
100 | case DataSeriesType::SCALAR: |
|
102 | case DataSeriesType::SCALAR: | |
101 |
ts = make_scalar( |
|
103 | ts = make_scalar(x, values); | |
102 | break; |
|
104 | break; | |
103 | case DataSeriesType::VECTOR: |
|
105 | case DataSeriesType::VECTOR: | |
104 |
ts = make_vector( |
|
106 | ts = make_vector(x, values); | |
105 | break; |
|
107 | break; | |
106 | case DataSeriesType::MULTICOMPONENT: |
|
108 | case DataSeriesType::MULTICOMPONENT: | |
107 |
ts = make_multi_comp( |
|
109 | ts = make_multi_comp(x, values); | |
108 | break; |
|
110 | break; | |
109 | case DataSeriesType::SPECTROGRAM: |
|
111 | case DataSeriesType::SPECTROGRAM: | |
110 |
ts = make_spectro( |
|
112 | ts = make_spectro(x, y, values); | |
111 | break; |
|
113 | break; | |
112 | default: |
|
114 | default: | |
113 | break; |
|
115 | break; |
@@ -9,43 +9,40 from spwc.amda import AMDA | |||||
9 |
|
9 | |||
10 | amda = AMDA() |
|
10 | amda = AMDA() | |
11 |
|
11 | |||
|
12 | ||||
12 | def amda_make_scalar(var=None): |
|
13 | def amda_make_scalar(var=None): | |
13 | if var is None: |
|
14 | if var is None: | |
14 | return ((np.array(), np.array()), DataSeriesType.SCALAR) |
|
15 | return (((np.array([]), np.array([])), np.array([])), DataSeriesType.SCALAR) | |
15 | else: |
|
16 | else: | |
16 | return ((var.time,var.data), DataSeriesType.SCALAR) |
|
17 | return (((var.time, np.array([])), var.data), DataSeriesType.SCALAR) | |
|
18 | ||||
17 |
|
19 | |||
18 | def amda_make_vector(var=None): |
|
20 | def amda_make_vector(var=None): | |
19 | if var is None: |
|
21 | if var is None: | |
20 | return ((np.array(), np.array()), DataSeriesType.VECTOR) |
|
22 | return (((np.array([]), np.array([])), np.array([])), DataSeriesType.VECTOR) | |
21 | else: |
|
23 | else: | |
22 | return ((var.time,var.data), DataSeriesType.VECTOR) |
|
24 | return (((var.time, np.array([])), var.data), DataSeriesType.VECTOR) | |
|
25 | ||||
23 |
|
26 | |||
24 | def amda_make_multi_comp(var=None): |
|
27 | def amda_make_multi_comp(var=None): | |
25 | if var is None: |
|
28 | if var is None: | |
26 | return ((np.array(), np.array()), DataSeriesType.MULTICOMPONENT) |
|
29 | return (((np.array([]), np.array([])), np.array([])), DataSeriesType.MULTICOMPONENT) | |
27 | else: |
|
30 | else: | |
28 | return ((var.time,var.data), DataSeriesType.MULTICOMPONENT) |
|
31 | return (((var.time, np.array([])), var.data), DataSeriesType.MULTICOMPONENT) | |
|
32 | ||||
29 |
|
33 | |||
30 | def amda_make_spectro(var=None): |
|
34 | def amda_make_spectro(var=None): | |
31 | if var is None: |
|
35 | if var is None: | |
32 | return ((np.array(), np.array()), DataSeriesType.SPECTROGRAM) |
|
36 | return (((np.array([]), np.array([])), np.array([])), DataSeriesType.SPECTROGRAM) | |
33 | else: |
|
37 | else: | |
34 | min_sampling = float(var.meta.get("DATASET_MIN_SAMPLING","nan")) |
|
38 | min_sampling = float(var.meta.get("DATASET_MIN_SAMPLING", "nan")) | |
35 | max_sampling = float(var.meta.get("DATASET_MAX_SAMPLING","nan")) |
|
39 | max_sampling = float(var.meta.get("DATASET_MAX_SAMPLING", "nan")) | |
36 | if "PARAMETER_TABLE_MIN_VALUES[1]" in var.meta: |
|
40 | if var.y is None and len(var.data): | |
37 | min_v = np.array([ float(v) for v in var.meta["PARAMETER_TABLE_MIN_VALUES[1]"].split(',') ]) |
|
41 | var.y = np.logspace(1, 3, var.data.shape[1])[::-1] | |
38 | max_v = np.array([ float(v) for v in var.meta["PARAMETER_TABLE_MAX_VALUES[1]"].split(',') ]) |
|
42 | return (((var.time, var.y), var.data), DataSeriesType.SPECTROGRAM) | |
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,var.data), DataSeriesType.SPECTROGRAM) |
|
|||
47 | #return pysciqlopcore.SpectrogramTimeSerie(var.time,y,var.data,min_sampling,max_sampling,True) |
|
43 | #return pysciqlopcore.SpectrogramTimeSerie(var.time,y,var.data,min_sampling,max_sampling,True) | |
48 |
|
44 | |||
|
45 | ||||
49 | def amda_get_sample(metadata,start,stop): |
|
46 | def amda_get_sample(metadata, start, stop): | |
50 | ts_type = amda_make_scalar |
|
47 | ts_type = amda_make_scalar | |
51 | try: |
|
48 | try: |
@@ -82,11 +82,11 class MyProvider(PyDataProvider): | |||||
82 | var = _cache.get_data(cache_product, DateTimeRange(datetime.fromtimestamp(start, tz=timezone.utc), datetime.fromtimestamp(stop, tz=timezone.utc)), partial(_get_data, p_type), fragment_hours=24) |
|
82 | var = _cache.get_data(cache_product, DateTimeRange(datetime.fromtimestamp(start, tz=timezone.utc), datetime.fromtimestamp(stop, tz=timezone.utc)), partial(_get_data, p_type), fragment_hours=24) | |
83 | else: |
|
83 | else: | |
84 | var = _get_data(p_type, start, stop) |
|
84 | var = _get_data(p_type, start, stop) | |
85 | return ((var.time,var.data), ts_type) |
|
85 | return (((var.time, np.array([])),var.data), ts_type) | |
86 | except Exception as e: |
|
86 | except Exception as e: | |
87 | print(traceback.format_exc()) |
|
87 | print(traceback.format_exc()) | |
88 | print("Error in test.py ",str(e)) |
|
88 | print("Error in test.py ",str(e)) | |
89 | return ((np.array(), np.array()), ts_type) |
|
89 | return (((np.array([]), np.array([])), np.array([])), ts_type) | |
90 |
|
90 | |||
91 |
|
91 | |||
92 | t=MyProvider() |
|
92 | t=MyProvider() |
General Comments 0
You need to be logged in to leave comments.
Login now