Example for creating a custom process in AeroMAPS#
This document aims to show the recommended way to create a custom process (configuration file and custom models) and execute them within AeroMAPS.
Load and process#
First, the user has to load the framework and generate a process.
%matplotlib widget
from aeromaps.core.process import create_process
from aeromaps.core.models import (
models_traffic,
models_efficiency_top_down,
models_energy_without_fuel_effect,
models_offset,
models_climate_simple_gwpstar,
models_sustainability,
)
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[1], line 2
1 get_ipython().run_line_magic('matplotlib', 'widget')
----> 2 from aeromaps.core.process import create_process
3 from aeromaps.core.models import (
4 models_traffic,
5 models_efficiency_top_down,
(...)
9 models_sustainability,
10 )
ImportError: cannot import name 'create_process' from 'aeromaps.core.process' (/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/aeromaps/core/process.py)
Create a custom model#
Here by default we import several aggregated reference models, such as models_traffic
, that contains basic models used in AeroMAPS. Overall, these different aggregated models include 100 basic models. We recommend to keep these default models to not remove any outputs that may be needed by other models.
For instance, the models_traffic
is a dictionnary structure with keys that are the name of the model and the value an instance of the model:
models_traffic = {
"rpk_measures": RPKMeasures("rpk_measures"),
"rpk": RPK("rpk"),
"rpk_reference": RPKReference("rpk_reference"),
"total_aircraft_distance": TotalAircraftDistance("total_aircraft_distance"),
"rtk": RTK("rtk"),
"rtk_reference": RTKReference("rtk_reference"),
"ask": ASK("ask")
}
We create a custom model example MeanDistancePerInhabitantFlyer
that is located here, in the file models/mean_distance_per_inhabitant_and_flyer.py
. To integrate it in to the AeroMAPS process we propose to import it and to add it to the dictionnary containing the models.
from models.mean_distance_per_inhabitant_and_flyer import MeanDistancePerInhabitantFlyer
extended_models = {
"models_traffic": models_traffic,
"models_efficiency_top_down": models_efficiency_top_down,
"models_energy_without_fuel_effect": models_energy_without_fuel_effect,
"models_offset": models_offset,
"models_climate_simple_gwpstar": models_climate_simple_gwpstar,
"models_sustainability": models_sustainability,
"mean_distance_per_inhabitant_and_flyer": MeanDistancePerInhabitantFlyer(
"mean_distance_per_inhabitant_and_flyer"
),
}
This new ensemble of models can be provided to the process.
Create the process#
Here we show how we can use a configuration file with an example here, in the file data_files/config.json
.
There you can specify the relative path to the different files.
For example, you can provide a custom input file with the parameters you want to modify with an example here, in the file data_files/inputs.json
.
Be careful, do not forget to set the inputs required by your models, either in the resources/data/parameters.json
file if you modify the source code, or directly in the inputs.json
file from your configuration file. You can also change the inputs data directly through the code after the creation of the process (see below).
process = create_process(configuration_file="data_files/config.json", models=extended_models)
process.parameters.world_inhabitant_number_reference_years = [2020, 2030, 2040, 2050]
process.parameters.world_inhabitant_number_reference_years_values = [
7.805e9,
8.512e9,
9.159e9,
9.687e9,
] # Assumption based on the 2022 Revision of World Population Prospects from the United Nations
process.parameters.inhabitant_flyer_share_reference_years = [2020, 2030, 2040, 2050]
process.parameters.inhabitant_flyer_share_reference_years_values = [
11,
14,
17,
20,
] # Assumption based on a linear increase from Gossling and Humpe (2020) value
Compute#
Once all the parameters have been set up, the user can compute.
process.compute()
Results#
The user can then display the results. The user has access to float outputs but also to annual data outputs, with the possibility of choosing the output.
process.data["vector_outputs"][["mean_distance_per_inhabitant", "mean_distance_per_flyer"]]
mean_distance_per_inhabitant | mean_distance_per_flyer | |
---|---|---|
2000 | NaN | NaN |
2001 | NaN | NaN |
2002 | NaN | NaN |
2003 | NaN | NaN |
2004 | NaN | NaN |
2005 | NaN | NaN |
2006 | NaN | NaN |
2007 | NaN | NaN |
2008 | NaN | NaN |
2009 | NaN | NaN |
2010 | NaN | NaN |
2011 | NaN | NaN |
2012 | NaN | NaN |
2013 | NaN | NaN |
2014 | NaN | NaN |
2015 | NaN | NaN |
2016 | NaN | NaN |
2017 | NaN | NaN |
2018 | NaN | NaN |
2019 | NaN | NaN |
2020 | 378.363457 | 3439.667789 |
2021 | 556.936124 | 4928.638269 |
2022 | 732.331230 | 6313.200263 |
2023 | 904.632840 | 7601.956642 |
2024 | 1073.922080 | 8802.640001 |
2025 | 1096.554147 | 8772.433178 |
2026 | 1119.747256 | 8748.025439 |
2027 | 1143.515325 | 8729.124616 |
2028 | 1167.872641 | 8715.467471 |
2029 | 1192.833873 | 8706.816590 |
2030 | 1218.414078 | 8702.957697 |
2031 | 1245.499417 | 8709.786131 |
2032 | 1273.259321 | 8720.954250 |
2033 | 1301.710914 | 8736.314857 |
2034 | 1330.871773 | 8755.735349 |
2035 | 1360.759940 | 8779.096388 |
2036 | 1391.393933 | 8806.290717 |
2037 | 1422.792760 | 8837.222111 |
2038 | 1454.975930 | 8871.804451 |
2039 | 1487.963469 | 8909.960893 |
2040 | 1521.775932 | 8951.623130 |
2041 | 1558.445053 | 9008.352905 |
2042 | 1596.050197 | 9068.467031 |
2043 | 1634.615843 | 9131.932086 |
2044 | 1674.167120 | 9198.720440 |
2045 | 1714.729828 | 9268.809883 |
2046 | 1756.330457 | 9342.183283 |
2047 | 1798.996204 | 9418.828294 |
2048 | 1842.754993 | 9498.737076 |
2049 | 1887.635493 | 9581.906057 |
2050 | 1933.667142 | 9668.335710 |