Skip to content

aeromaps.models.impacts.generic_energy_model.common.energy_carriers_manager

EnergyCarrierMetadata dataclass

EnergyCarrierMetadata(name=None, aircraft_type=None, default=False, mandate_type=None, energy_origin=None, resources_used=None, resources_used_processes=None, cost_model=None, environmental_model=None)

Dataclass to hold metadata for an energy carrier.

Attributes:

Name Type Description
name str

Name of the energy carrier.

aircraft_type str

Type of aircraft the energy carrier is associated with.

default bool

Indicates if this is the default energy carrier for the aircraft type.

mandate_type str

Type of mandate the energy carrier obeys to (share, volume)

energy_origin str

Origin of the energy (e.g., renewable, fossil).

resources_used List[str]

List of resources used by the energy carrier.

resources_used_processes dict

Dictionary mapping resources used by associated processes.

cost_model str

Type of cost model used (e.g., top-down, bottom-up).

environmental_model str

Type of environmental model used (e.g., top-down, bottom-up).

EnergyCarrierManager

EnergyCarrierManager(carriers=None)

Manager class to handle a collection of energy carriers and provide methods to add and retrieve them based on various criteria.

Attributes:

Name Type Description
carriers List[EnergyCarrierMetadata]

List of energy carrier metadata instances.

Initialize the EnergyCarrierManager with an optional list of energy carriers.

Parameters:

Name Type Description Default
carriers List[EnergyCarrierMetadata]

Initial list of energy carrier metadata instances.

None
Source code in aeromaps/models/impacts/generic_energy_model/common/energy_carriers_manager.py
53
54
55
56
57
58
59
60
61
62
def __init__(self, carriers: List[EnergyCarrierMetadata] = None):
    """
    Initialize the EnergyCarrierManager with an optional list of energy carriers.

    Parameters
    ----------
    carriers : List[EnergyCarrierMetadata], optional
        Initial list of energy carrier metadata instances.
    """
    self.carriers = carriers if carriers is not None else []

add

add(carrier)

Add a new energy carrier to the manager.

Parameters:

Name Type Description Default
carrier EnergyCarrierMetadata

Energy carrier metadata instance to add.

required
Source code in aeromaps/models/impacts/generic_energy_model/common/energy_carriers_manager.py
64
65
66
67
68
69
70
71
72
73
def add(self, carrier: EnergyCarrierMetadata):
    """
    Add a new energy carrier to the manager.

    Parameters
    ----------
    carrier
        Energy carrier metadata instance to add.
    """
    self.carriers.append(carrier)

get

get(**criteria)

Retrieve energy carriers that match all specified criteria.

Parameters:

Name Type Description Default
criteria

Keyword arguments used to match attributes of energy carriers; only carriers matching all provided criteria are returned.

{}

Returns:

Type Description
matches

Energy carrier metadata instances that match the given criteria.

Source code in aeromaps/models/impacts/generic_energy_model/common/energy_carriers_manager.py
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
def get(self, **criteria) -> List[EnergyCarrierMetadata]:
    """
    Retrieve energy carriers that match all specified criteria.

    Parameters
    ----------
    criteria
        Keyword arguments used to match attributes of energy carriers; only carriers matching all provided criteria are returned.

    Returns
    -------
    matches
        Energy carrier metadata instances that match the given criteria.
    """
    return [
        c
        for c in self.carriers
        if all(
            val in getattr(c, attr, {}).values()
            if isinstance(getattr(c, attr, None), dict)
            else val in getattr(c, attr, [])
            if isinstance(getattr(c, attr, None), list)
            else getattr(c, attr, None) == val
            for attr, val in criteria.items()
        )
    ]

get_all

get_all()

Return all energy carriers managed by this object.

Returns:

Type Description
carriers

All energy carrier metadata instances stored in the manager.

Source code in aeromaps/models/impacts/generic_energy_model/common/energy_carriers_manager.py
102
103
104
105
106
107
108
109
110
111
def get_all(self):
    """
    Return all energy carriers managed by this object.

    Returns
    -------
    carriers
        All energy carrier metadata instances stored in the manager.
    """
    return self.carriers

get_all_types

get_all_types(parameter)

Retrieve unique values of a specified attribute across all energy carriers.

Parameters:

Name Type Description Default
parameter str

Name of the attribute to aggregate unique values for.

required

Returns:

Type Description
values

Unique values of the specified parameter across all energy carriers.

Source code in aeromaps/models/impacts/generic_energy_model/common/energy_carriers_manager.py
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
def get_all_types(self, parameter: str) -> List:
    """
    Retrieve unique values of a specified attribute across all energy carriers.

    Parameters
    ----------
    parameter
        Name of the attribute to aggregate unique values for.

    Returns
    -------
    values
        Unique values of the specified parameter across all energy carriers.
    """
    return list(
        {
            getattr(carrier, parameter, None)
            for carrier in self.carriers
            if getattr(carrier, parameter, None) is not None
        }
    )