##// END OF EJS Templates
PySide2 bindings + some GUI clean...
PySide2 bindings + some GUI clean - simple Python plugin with scalar product works - launcher args are forwarded to SciQLop app, this allow to choose between wayland and xcb for example - removed all not implemented widgets on main GUI - moved all widgets except plots into QDocWidgets Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1440:824c70b31e8a
r1478:6e3f56cd8c8b
Show More
cdaweb.py
54 lines | 1.8 KiB | text/x-python | PythonLexer
import os
import PythonProviders
import pysciqlopcore
import numpy as np
import pandas as pds
import requests
from datetime import datetime, timedelta, timezone
from spwc.cdaweb import cdaweb
cd = cdaweb()
def cda_get_sample(metadata, start,stop):
ts_type = pysciqlopcore.ScalarTimeSerie
default_ctor_args = 1
try:
variable_id = None
dataset_id = None
drop_cols = []
for key,value in metadata:
if key == 'VAR_ID':
variable_id = value
elif key == 'DATASET_ID':
dataset_id = value
elif key == 'drop_col':
drop_cols.append(value)
elif key == 'type':
if value == 'vector':
ts_type = pysciqlopcore.VectorTimeSerie
elif value == 'multicomponent':
ts_type = pysciqlopcore.MultiComponentTimeSerie
default_ctor_args = (0,2)
tstart=datetime.fromtimestamp(start, tz=timezone.utc)
tend=datetime.fromtimestamp(stop, tz=timezone.utc)
df = cd.get_variable(dataset=dataset_id,variable=variable_id,tstart=tstart,tend=tend)
if len(df):
df = df.drop(columns = drop_cols)
t = np.array([d.timestamp() for d in df.index])
values = df.values
return ts_type(t,values)
except Exception as e:
print(traceback.format_exc())
print("Error in cdaweb.py ",str(e))
return ts_type(default_ctor_args)
products = [
("/CDA/Themis/ThA/tha_fgl_gsm", [], [("type","vector"), ('drop_col','UT__sec'), ("DATASET_ID","THA_L2_FGM"), ("VAR_ID","tha_fgl_gsm")]),
("/CDA/Themis/ThB/thb_fgl_gsm", [], [("type","vector"), ('drop_col','UT__sec'), ("DATASET_ID","THB_L2_FGM"), ("VAR_ID","thb_fgl_gsm")]),
]
PythonProviders.register_product(products, cda_get_sample)