Multi-dimensional data example
Explore multi-dimensional data using the TID, SHIELDOSE-2 model.

# coding=utf-8
from nom_client.nom_client import NoMClient
"""
title: Multi-dimensional data example
description: Explore multi-dimensional data using the TID, SHIELDOSE-2 model.
"""

conf = {
    "servers": {
        "ext_rest_server": {
            "type": "rest",
            "server_addr": "https://nom.esa.int",
            "api_version": "api",
            "api_key": ""
        }
    }
}


nom_client = NoMClient("eqflux_model_example", client_configuration=conf,
                       default_server_id="ext_rest_server",
                       debug_output=False)

sapre_model_gto = nom_client.get_model('sapre')

sapre_gto_result = nom_client.run_model(sapre_model_gto)
print(sapre_gto_result)


ap8ae8_model = nom_client.get_model('ae8ap8')
ap8ae8_model.set_external_input(external_input_name="trajectory", external_input=sapre_gto_result)
ap8ae8_results = nom_client.run_model(ap8ae8_model)
print(ap8ae8_results)

# Solar particle models
sapphire_worst_fluence_model = nom_client.get_model('sapphire-worst-event-fluence')
sapphire_worst_fluence_model.set_external_input(external_input_name="trajectory", external_input=sapre_gto_result)
sapphire_worst_fluence_results = nom_client.run_model(sapphire_worst_fluence_model)
print(sapphire_worst_fluence_results)


# Effects models

eqflux_model = nom_client.get_model('eqflux')
# eqflux_model.set_external_input(external_input_name="trappedParticleSpectrum", external_input=ap8ae8_results)
eqflux_model.set_external_input(external_input_name="solarParticleSpectrum",
                                external_input=sapphire_worst_fluence_results)
eqflux_result = nom_client.run_model(eqflux_model)
print(eqflux_result)

r = nom_client.get_model_run_results(model_run_name="eqflux",
                                     model_result_name="summary_equivalent_fluences_pmax")

print(r)

# plot_all(nom_client.get_model_runs(model_run_names='sapphire-worst-event-fluence'))