Open Data Interface (ODI) data
Model API name: odi-data
Open Data Interface (ODI) data
Version: v5
Model developer:
Model provision:
Model example
# coding=utf-8
import datetime
import json
import sys
from pprint import pprint
import dateutil.parser
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
import matplotlib.dates as mdates
from nom_client.nom_client import NoMClient
from nom_client.utils.math_utils import calc_int
conf = {
"servers": {
"ext_rest_server": {
"type": "rest",
"server_addr": "https://nom.esa.int",
"api_version": "api",
"api_key": ""
}
}
}
nom_client = NoMClient("odi-example", client_configuration=conf)
# Set the NoM server
nom_client.set_default_server("ext_rest_server")
# Get the model specification from the server.
odi_model = nom_client.get_model('odi-data')
odi_model.set_params(operation="list-datasets")
r = nom_client.run_model(odi_model)
dd = r.get_model_result_by_name(result_name="datasets")
datasets_json = dd.get_data()
datasets = json.loads(datasets_json)
for dataset_name, dataset in datasets.items():
print(f"Dataset: {dataset_name} - {dataset['title']}")
odi_model.set_params(operation="read-metadata", dataSetName="sepem_rds_2_0_h_wbkg", metadataFormat="odi")
r = nom_client.run_model(odi_model)
dd = r.get_model_result_by_name(result_name="sepem_rds_2_0_h_wbkg")
json_data = dd.get_data()
meta_data = json.loads(json_data)
dataset_startdate = meta_data['epoch_start']
dataset_enddate = meta_data['epoch_end']
# Get the last 1 day of data
datetime_enddate = dateutil.parser.isoparse(dataset_enddate)
datetime_startdate = datetime_enddate - datetime.timedelta(1)
odi_model.set_params(operation="read-data", dataSetName="sepem_rds_2_0_h_wbkg",
startDateTime=datetime_startdate.isoformat(),
endDateTime=datetime_enddate.isoformat())
r = nom_client.run_model(odi_model)
dd = r.get_model_result_by_name(result_name="sepem_rds_2_0_h_wbkg")
epoch = dd.get_variable_data(variable_name="epoch")[0]
e = np.array(epoch)
flux = dd.get_variable_data(variable_name="fpdo")
flux_units = r["sepem_rds_2_0_h_wbkg"]['fpdo'].units
flux_labels = list(dd.get_variable_data(variable_name="fpdo_labl_1").squeeze())
flux_T = flux.T
energies = [6.012736, 8.695174, 12.57435, 18.18407, 26.29643, 38.02797, 54.99322, 79.52708, 115.0061, 166.3133, 240.5099]
fig, ax = plt.subplots(figsize=(12, 12))
plt.rcParams['figure.figsize'] = [15, 10]
plt.rc('font', size=14)
plt.title('Flux', fontsize=18)
plt.grid(True)
date_form = mdates.DateFormatter("%d-%m-%y")
ax.xaxis.set_major_formatter(date_form)
plt.semilogy(e, flux.T, '-', linewidth=2.0, markersize=12.0)
fontP = FontProperties()
fontP.set_size('small')
plt.legend(prop=fontP, labels=flux_labels)
plt.xlabel("Datetime")
plt.ylabel(f"Flux ({flux_units})")
plt.gcf().autofmt_xdate()
plt.show()
Model references
No references