##// END OF EJS Templates
Mostly working Spectrograms...
Mostly working Spectrograms Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1440:824c70b31e8a
r1465:42e61e7ce5b3
Show More
cdaweb.py
54 lines | 1.8 KiB | text/x-python | PythonLexer
Added POC AMDA python impl and CDAWEB bits...
r1430 import os
import PythonProviders
import pysciqlopcore
import numpy as np
import pandas as pds
import requests
Amda, cdaweb and test python are now fully embedded in SciQLop...
r1440 from datetime import datetime, timedelta, timezone
Added POC AMDA python impl and CDAWEB bits...
r1430 from spwc.cdaweb import cdaweb
cd = cdaweb()
WIP...
r1434 def cda_get_sample(metadata, start,stop):
ts_type = pysciqlopcore.ScalarTimeSerie
default_ctor_args = 1
Added POC AMDA python impl and CDAWEB bits...
r1430 try:
WIP...
r1434 variable_id = None
dataset_id = None
Added ability to drop data columns with CDAWEB plugin...
r1435 drop_cols = []
WIP...
r1434 for key,value in metadata:
if key == 'VAR_ID':
variable_id = value
elif key == 'DATASET_ID':
dataset_id = value
Added ability to drop data columns with CDAWEB plugin...
r1435 elif key == 'drop_col':
drop_cols.append(value)
WIP...
r1434 elif key == 'type':
if value == 'vector':
ts_type = pysciqlopcore.VectorTimeSerie
elif value == 'multicomponent':
ts_type = pysciqlopcore.MultiComponentTimeSerie
default_ctor_args = (0,2)
Amda, cdaweb and test python are now fully embedded in SciQLop...
r1440 tstart=datetime.fromtimestamp(start, tz=timezone.utc)
tend=datetime.fromtimestamp(stop, tz=timezone.utc)
WIP...
r1434 df = cd.get_variable(dataset=dataset_id,variable=variable_id,tstart=tstart,tend=tend)
Added ability to drop data columns with CDAWEB plugin...
r1435 if len(df):
df = df.drop(columns = drop_cols)
WIP...
r1434 t = np.array([d.timestamp() for d in df.index])
Added POC AMDA python impl and CDAWEB bits...
r1430 values = df.values
WIP...
r1434 return ts_type(t,values)
except Exception as e:
print(traceback.format_exc())
Added ability to drop data columns with CDAWEB plugin...
r1435 print("Error in cdaweb.py ",str(e))
WIP...
r1434 return ts_type(default_ctor_args)
Added POC AMDA python impl and CDAWEB bits...
r1430
WIP...
r1434 products = [
Added ability to drop data columns with CDAWEB plugin...
r1435 ("/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")]),
WIP...
r1434
]
PythonProviders.register_product(products, cda_get_sample)
Added POC AMDA python impl and CDAWEB bits...
r1430