diff --git a/core b/core index b9379e0..41273d8 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit b9379e008899fce30581fbbf2b3fefd6fe36cee2 +Subproject commit 41273d8529cddde1c8b6bcea03d71d9cd1a18c06 diff --git a/gui/src/Visualization/VisualizationGraphHelper.cpp b/gui/src/Visualization/VisualizationGraphHelper.cpp index 2a0bc4d..1a89d27 100644 --- a/gui/src/Visualization/VisualizationGraphHelper.cpp +++ b/gui/src/Visualization/VisualizationGraphHelper.cpp @@ -27,7 +27,10 @@ public: template struct PlottablesCreator { - static PlottablesMap createPlottables(QCustomPlot&) { return {}; } + static PlottablesMap createPlottables(QCustomPlot&, const std::shared_ptr& dataSeries) + { + return {}; + } }; PlottablesMap createGraphs(QCustomPlot& plot, int nbGraphs) @@ -53,7 +56,10 @@ PlottablesMap createGraphs(QCustomPlot& plot, int nbGraphs) template struct PlottablesCreator::value>> { - static PlottablesMap createPlottables(QCustomPlot& plot) { return createGraphs(plot, 1); } + static PlottablesMap createPlottables(QCustomPlot& plot, const std::shared_ptr& dataSeries) + { + return createGraphs(plot, 1); + } }; /** @@ -63,7 +69,24 @@ struct PlottablesCreator struct PlottablesCreator::value>> { - static PlottablesMap createPlottables(QCustomPlot& plot) { return createGraphs(plot, 3); } + static PlottablesMap createPlottables(QCustomPlot& plot, const std::shared_ptr& dataSeries) + { + return createGraphs(plot, 3); + } +}; + +/** + * Specialization of PlottablesCreator for MultiComponentTimeSeries + * @sa VectorSeries + */ +template +struct PlottablesCreator::value>> +{ + static PlottablesMap createPlottables(QCustomPlot& plot, const std::shared_ptr& dataSeries) + { + return createGraphs(plot, dataSeries->size(1)); + } }; /** @@ -74,7 +97,7 @@ template struct PlottablesCreator::value>> { - static PlottablesMap createPlottables(QCustomPlot& plot) + static PlottablesMap createPlottables(QCustomPlot& plot, const std::shared_ptr& dataSeries) { PlottablesMap result {}; result.insert({ 0, new QCPColorMap { plot.xAxis, plot.yAxis } }); @@ -236,6 +259,54 @@ struct PlottablesUpdater +struct PlottablesUpdater::value>> +{ + static void setPlotYAxisRange(T& dataSeries, const DateTimeRange& xAxisRange, QCustomPlot& plot) + { + double minValue = 0., maxValue = 0.; + if (auto serie = dynamic_cast(&dataSeries)) + { + // TODO +// std::for_each( +// std::begin(*serie), std::end(*serie), [&minValue, &maxValue](const auto& v) { +// minValue = std::min({ minValue, std::min_element(v.begin(),v.end()) }); +// maxValue = std::max({ maxValue, std::max_element(v.begin(),v.end()) }); +// }); + } + + plot.yAxis->setRange(QCPRange { minValue, maxValue }); + } + + static void updatePlottables( + T& dataSeries, PlottablesMap& plottables, const DateTimeRange& range, bool rescaleAxes) + { + for (const auto& plottable : plottables) + { + if (auto graph = dynamic_cast(plottable.second)) + { + auto dataContainer = QSharedPointer::create(); + if (auto serie = dynamic_cast(&dataSeries)) + { +// TODO + } + graph->setData(dataContainer); + } + } + + if (!plottables.empty()) + { + auto plot = plottables.begin()->second->parentPlot(); + + if (rescaleAxes) + { + plot->rescaleAxes(); + } + } + } +}; + /** * Specialization of PlottablesUpdater for spectrograms * @sa SpectrogramSeries @@ -346,7 +417,7 @@ struct PlottablesHelper : public IPlottablesHelper PlottablesMap create(QCustomPlot& plot) const override { - return PlottablesCreator::createPlottables(plot); + return PlottablesCreator::createPlottables(plot, m_DataSeries); } void update( @@ -395,6 +466,9 @@ std::unique_ptr createHelper(std::shared_ptr varia case DataSeriesType::VECTOR: return std::make_unique>( std::dynamic_pointer_cast(variable->data())); + case DataSeriesType::MULTICOMPONENT: + return std::make_unique>( + std::dynamic_pointer_cast(variable->data())); default: // Creates default helper break; diff --git a/plugins/python_providers/resources/amda.py b/plugins/python_providers/resources/amda.py index f3cff40..c4b469f 100644 --- a/plugins/python_providers/resources/amda.py +++ b/plugins/python_providers/resources/amda.py @@ -1,7 +1,8 @@ import sys sys.path.append("/home/jeandet/Documents/prog/build-SciQLop-Desktop-Debug/core") +import traceback import os -import datetime +from datetime import datetime, timedelta, timezone import PythonProviders import pysciqlopcore import numpy as np @@ -21,16 +22,16 @@ def get_sample(metadata,start,stop): elif key == 'type': if value == 'vector': ts_type = pysciqlopcore.VectorTimeSerie - tstart=datetime.datetime.fromtimestamp(start) - tend=datetime.datetime.fromtimestamp(stop) + tstart=datetime.datetime.utcfromtimestamp(start) + tend=datetime.datetime.utcfromtimestamp(stop) df = amda.get_parameter(start_time=tstart, stop_time=tend, parameter_id=param_id) - t = np.array([d.timestamp()-7200 for d in df.index]) + #t = np.array([d.timestamp()-7200 for d in df.index]) + t = np.array([d.timestamp() for d in df.index]) values = df.values - print(len(t)) - print(len(values)) return ts_type(t,values) return ts_type(1) except Exception as e: + print(traceback.format_exc()) print("Error in amda.py ",str(e)) return ts_type(1) diff --git a/plugins/python_providers/resources/cdaweb.py b/plugins/python_providers/resources/cdaweb.py index ac52c90..0c34219 100644 --- a/plugins/python_providers/resources/cdaweb.py +++ b/plugins/python_providers/resources/cdaweb.py @@ -13,21 +13,6 @@ cd = cdaweb() def get_sample(name,start,stop): try: - tstart=datetime.datetime.fromtimestamp(start).strftime('%Y%m%dT%H%M%SZ') - tend=datetime.datetime.fromtimestamp(stop).strftime('%Y%m%dT%H%M%SZ') - req_url=f"https://cdaweb.gsfc.nasa.gov/WS/cdasr/1/dataviews/sp_phys/datasets/MMS4_SCM_SRVY_L2_SCSRVY/data/{tstart},{tend}/mms4_scm_acb_gse_scsrvy_srvy_l2?format=csv" - resp = requests.get(req_url,headers={"Accept":"application/json"}) - csv_url = resp.json()['FileDescription'][0]['Name'] - df = pds.read_csv(csv_url,comment='#',index_col=0, infer_datetime_format=True,parse_dates=True) - t = np.array([d.timestamp()-7200 for d in df.index]) - values = df.values - return pysciqlopcore.VectorTimeSerie(t,values) - except Exception as e: - print("fuck ",str(e)) - return pysciqlopcore.VectorTimeSerie(1) - -def get_sample(name,start,stop): - try: tstart=datetime.datetime.fromtimestamp(start) tend=datetime.datetime.fromtimestamp(stop) df = cd.get_variable(dataset="MMS2_SCM_SRVY_L2_SCSRVY",variable="mms2_scm_acb_gse_scsrvy_srvy_l2",tstart=tstart,tend=tend) diff --git a/plugins/python_providers/resources/test.py b/plugins/python_providers/resources/test.py new file mode 100644 index 0000000..467e704 --- /dev/null +++ b/plugins/python_providers/resources/test.py @@ -0,0 +1,17 @@ +import sys +sys.path.append("/home/jeandet/Documents/prog/build-SciQLop-Desktop-Debug/core") +import PythonProviders +import pysciqlopcore +import numpy as np + +someglobal = 1 + +def test(name,start,stop): + x = np.arange(start, stop) + y = np.cos(x/10.) + return pysciqlopcore.ScalarTimeSerie(x,y) + + +#PythonProviders.register_product(["/folder1/folder2/product1", "/folder1/folder3/product2", "/folder4/folder5/product3"],test) + + diff --git a/plugins/python_providers/src/python_providers.cpp b/plugins/python_providers/src/python_providers.cpp index 27acf63..384709d 100644 --- a/plugins/python_providers/src/python_providers.cpp +++ b/plugins/python_providers/src/python_providers.cpp @@ -23,7 +23,7 @@ const auto DATA_SOURCE_NAME = QStringLiteral("PythonProviders"); class PythonProvider : public IDataProvider { public: - PythonProvider(PythonInterpreter::provider_funct_t f) : _pythonFunction { f } {} + explicit PythonProvider(PythonInterpreter::provider_funct_t f) : _pythonFunction { f } {} PythonProvider(const PythonProvider& other) : _pythonFunction { other._pythonFunction } {} @@ -147,5 +147,4 @@ void PythonProviders::register_product( }); dataSourceController.setDataSourceItem(id, std::move(root)); dataSourceController.setDataProvider(id, std::make_unique(f)); - std::cout << "Gone there" << std::endl; }