def get_train_data(start, stop): amda = AMDA() parameter_id = "al" parameter_desc = amda.collection.find(parameter_id) dataset_desc = amda.collection.find(parameter_desc.dataset_id) dataset = amda.get(dataset_desc, start=start, stop=stop) return dataset["AL"][:]
import sys sys.path.insert(0, "/home/aschulz/amdapy") import amdapy from amdapy.amda import AMDA, Timespan import datetime tdelta = datetime.timedelta(days=2) amda = AMDA() parameter_id = "psp_spi_aee" parameter_description = amda.collection.find(parameter_id) print("parameter descrition :\n{}".format(parameter_description)) # get the time dataset_description = amda.collection.find(parameter_description.dataset_id) t0 = dataset_description.starttime + tdelta t1 = t0 + tdelta tinterval = Timespan(t0, t1) print("getting data from {} to {}".format(t0, t1)) parameter_data = amda.get(parameter_description, tinterval) print(parameter_data) print(parameter_data.data) # print columns names print(parameter_data.data.columns)
t_int = [ dataset_description.starttime, dataset_description.starttime + datetime.timedelta(days=30) ] try_getting_data(dataset_description, amda, "Trying to getting first month dataset...", \ "\tError", t_int[0], t_int[1]) try_getting_data(parameter_description, amda_conn, "Trying to get first month parameter...", \ "\tError", t_int[0], t_int[1]) def try_getting_last_month_data(parameter_description, dataset_description, amda_conn): t_int = [ dataset_description.stoptime - datetime.timedelta(days=30), dataset_description.stoptime ] try_getting_data(dataset_description, amda, "Trying to getting last month dataset...", \ "\tError", t_int[0], t_int[1]) try_getting_data(parameter_description, amda_conn, "Trying to get last month parameter...", \ "\tError", t_int[0], t_int[1]) amda = AMDA() param_d = amda.collection.find("al") dataset_d = amda.collection.find(param_d.dataset_id) ## Try to get the first hour of data try_getting_first_hour_of_data(param_d, dataset_d, amda) try_getting_full_data(param_d, dataset_d, amda) try_getting_1_month_data(param_d, dataset_d, amda) try_getting_last_month_data(param_d, dataset_d, amda)
import matplotlib.pyplot as plt import sys sys.path.insert(0,"/home/aschulz/amdapy") from amdapy.amda import AMDA amda=AMDA() dataset_id="tao-ura-sw" dataset_desc=amda.collection.find(dataset_id) dataset=amda.get(dataset_desc) dataset["velocity"].plot(dataset_id="tao-ura-sw") plt.show()
aa = np.abs(np.diff(tmp)) / tmp[:-1] ax2.plot(train_data.index[w_s:-w_s], a) f.autofmt_xdate() plt.show() exit() # plot the training data and the corresponding events fig = plt.figure() plt.title("Training data : AL index") plt.xlabel("Time") plt.ylabel("AL (nT)") plt.plot(train_data) fig.autofmt_xdate() plt.show() exit() amda = AMDA() parameter_id = "al" parameter_desc = amda.collection.find(parameter_id) dataset_desc = amda.collection.find(parameter_desc.dataset_id) start = dataset_desc.starttime start = datetime.datetime(year=2008, month=1, day=4, hour=6, minute=0) dataset = amda.get(dataset_desc, start=start, stop=start + timedelta(hours=4)) print(dataset) import numpy as np # label file /mlPlasmas-model-substorms/data/... al = dataset["AL"][:].to_numpy() au = dataset["AU"][:].to_numpy()
import sys #sys.path.insert(0,"/home/aschulz/amdapy") from amdapy.amda import AMDA amda = AMDA() dataset_id = "tao-ura-sw" dataset_desc = amda.collection.find(dataset_id) dataset = amda.get(dataset_desc) print(">>>dataset") print(dataset) print(">>>dataset[:]") print(dataset[:]) print(">>>dataset[\"density\"]") print(dataset["density"]) # get_parameter parameter_id = "ura_sw_n" parameter_desc = amda.collection.find(parameter_id) print(">>> parameter_desc") print(parameter_desc) parameter = amda.get(parameter_desc) print(">>> parameter") print(parameter) print(">>> parameter[:]") print(parameter[:]) # amdapy.amda.Dataset.iter_parameter print(">>> [p.name for p in dataset.iter_parameter()]") print([p.name for p in dataset.iter_parameter()]) print(">>> [p.units for p in dataset.iter_parameter()]") print([p.units for p in dataset.iter_parameter()])