From 865bdf496f65bbbf354341cb7cb3b56b7d0f28f2 2019-04-12 14:19:01 From: Alexis Jeandet Date: 2019-04-12 14:19:01 Subject: [PATCH] WIP Signed-off-by: Alexis Jeandet --- diff --git a/core b/core index 5f1aaa7..7c86e13 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 5f1aaa704ac36252027b9da0064bdf1de063df0d +Subproject commit 7c86e13f8a6242eb5fe07f0da91a96a4cf68b5bf diff --git a/plugins/python_providers/resources/amda.py b/plugins/python_providers/resources/amda.py index e2a5741..353176c 100644 --- a/plugins/python_providers/resources/amda.py +++ b/plugins/python_providers/resources/amda.py @@ -30,10 +30,9 @@ def get_sample(metadata,start,stop): tstart=datetime.datetime.fromtimestamp(start, tz=timezone.utc) tend=datetime.datetime.fromtimestamp(stop, tz=timezone.utc) df = amda.get_parameter(start_time=tstart, stop_time=tend, parameter_id=param_id, method="REST") - #t = np.array([d.timestamp()-7200 for d in df.index]) t = np.array([d.timestamp() for d in df.index]) values = df.values - return ts_type(t,values.transpose()) + return ts_type(t,values) except Exception as e: print(traceback.format_exc()) print("Error in amda.py ",str(e)) diff --git a/plugins/python_providers/resources/cdaweb.py b/plugins/python_providers/resources/cdaweb.py index 0c34219..4ce73a9 100644 --- a/plugins/python_providers/resources/cdaweb.py +++ b/plugins/python_providers/resources/cdaweb.py @@ -11,19 +11,42 @@ from spwc.cdaweb import cdaweb cd = cdaweb() -def get_sample(name,start,stop): +def cda_get_sample(metadata, start,stop): + ts_type = pysciqlopcore.ScalarTimeSerie + default_ctor_args = 1 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) - t = np.array([d.timestamp()-7200 for d in df.index]) + variable_id = None + dataset_id = None + for key,value in metadata: + if key == 'VAR_ID': + variable_id = value + elif key == 'DATASET_ID': + dataset_id = 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.datetime.fromtimestamp(start, tz=timezone.utc) + tend=datetime.datetime.fromtimestamp(stop, tz=timezone.utc) + df = cd.get_variable(dataset=dataset_id,variable=variable_id,tstart=tstart,tend=tend) + t = np.array([d.timestamp() 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) + print(values.shape) + return ts_type(t,values) + except Exception as e: + print(traceback.format_exc()) + print("Error in amda.py ",str(e)) + return ts_type(default_ctor_args) -PythonProviders.register_product([("/CDA/mms4_scm_acb_gse_scsrvy_srvy_l2",[],[("type","vector")])],get_sample) +products = [ + ("/CDA/Themis/ThA/tha_fgl_gsm", [], [("type","multicomponent"), ('size','4'), ("DATASET_ID","THA_L2_FGM"), ("VAR_ID","tha_fgl_gsm")]), + ("/CDA/Themis/ThB/thb_fgl_gsm", [], [("type","multicomponent"), ('size','4'), ("DATASET_ID","THB_L2_FGM"), ("VAR_ID","thb_fgl_gsm")]), + +] + +PythonProviders.register_product(products, cda_get_sample)