##// END OF EJS Templates
WIP...
jeandet -
r1434:865bdf496f65
parent child
Show More
@@ -1,1 +1,1
1 Subproject commit 5f1aaa704ac36252027b9da0064bdf1de063df0d
1 Subproject commit 7c86e13f8a6242eb5fe07f0da91a96a4cf68b5bf
@@ -30,10 +30,9 def get_sample(metadata,start,stop):
30 tstart=datetime.datetime.fromtimestamp(start, tz=timezone.utc)
30 tstart=datetime.datetime.fromtimestamp(start, tz=timezone.utc)
31 tend=datetime.datetime.fromtimestamp(stop, tz=timezone.utc)
31 tend=datetime.datetime.fromtimestamp(stop, tz=timezone.utc)
32 df = amda.get_parameter(start_time=tstart, stop_time=tend, parameter_id=param_id, method="REST")
32 df = amda.get_parameter(start_time=tstart, stop_time=tend, parameter_id=param_id, method="REST")
33 #t = np.array([d.timestamp()-7200 for d in df.index])
34 t = np.array([d.timestamp() for d in df.index])
33 t = np.array([d.timestamp() for d in df.index])
35 values = df.values
34 values = df.values
36 return ts_type(t,values.transpose())
35 return ts_type(t,values)
37 except Exception as e:
36 except Exception as e:
38 print(traceback.format_exc())
37 print(traceback.format_exc())
39 print("Error in amda.py ",str(e))
38 print("Error in amda.py ",str(e))
@@ -11,19 +11,42 from spwc.cdaweb import cdaweb
11
11
12 cd = cdaweb()
12 cd = cdaweb()
13
13
14 def get_sample(name,start,stop):
14 def cda_get_sample(metadata, start,stop):
15 ts_type = pysciqlopcore.ScalarTimeSerie
16 default_ctor_args = 1
15 try:
17 try:
16 tstart=datetime.datetime.fromtimestamp(start)
18 variable_id = None
17 tend=datetime.datetime.fromtimestamp(stop)
19 dataset_id = None
18 df = cd.get_variable(dataset="MMS2_SCM_SRVY_L2_SCSRVY",variable="mms2_scm_acb_gse_scsrvy_srvy_l2",tstart=tstart,tend=tend)
20 for key,value in metadata:
19 t = np.array([d.timestamp()-7200 for d in df.index])
21 if key == 'VAR_ID':
22 variable_id = value
23 elif key == 'DATASET_ID':
24 dataset_id = value
25 elif key == 'type':
26 if value == 'vector':
27 ts_type = pysciqlopcore.VectorTimeSerie
28 elif value == 'multicomponent':
29 ts_type = pysciqlopcore.MultiComponentTimeSerie
30 default_ctor_args = (0,2)
31 tstart=datetime.datetime.fromtimestamp(start, tz=timezone.utc)
32 tend=datetime.datetime.fromtimestamp(stop, tz=timezone.utc)
33 df = cd.get_variable(dataset=dataset_id,variable=variable_id,tstart=tstart,tend=tend)
34 t = np.array([d.timestamp() for d in df.index])
20 values = df.values
35 values = df.values
21 return pysciqlopcore.VectorTimeSerie(t,values)
36 print(values.shape)
37 return ts_type(t,values)
22 except Exception as e:
38 except Exception as e:
23 print("fuck ",str(e))
39 print(traceback.format_exc())
24 return pysciqlopcore.VectorTimeSerie(1)
40 print("Error in amda.py ",str(e))
41 return ts_type(default_ctor_args)
25
42
26
43
27 PythonProviders.register_product([("/CDA/mms4_scm_acb_gse_scsrvy_srvy_l2",[],[("type","vector")])],get_sample)
44 products = [
45 ("/CDA/Themis/ThA/tha_fgl_gsm", [], [("type","multicomponent"), ('size','4'), ("DATASET_ID","THA_L2_FGM"), ("VAR_ID","tha_fgl_gsm")]),
46 ("/CDA/Themis/ThB/thb_fgl_gsm", [], [("type","multicomponent"), ('size','4'), ("DATASET_ID","THB_L2_FGM"), ("VAR_ID","thb_fgl_gsm")]),
47
48 ]
49
50 PythonProviders.register_product(products, cda_get_sample)
28
51
29
52
General Comments 0
You need to be logged in to leave comments. Login now