def get_levelized_cost(solution, cost_class='monetary', carrier='power',
                       group=None, locations=None,
                       unit_multiplier=1.0):
    """
    Get the levelized cost per unit of energy produced for the given
    ``cost_class`` and ``carrier``, optionally for a subset of technologies
    given by ``group`` and a subset of ``locations``.

    Parameters
    ----------
    solution : solution container
    cost_class : str, default 'monetary'
    carrier : str, default 'power'
    group : str, default None
        Limit the computation to members of the given group (see the
        groups table in the solution for valid groups).
    locations : str or iterable, default None
        Limit the computation to the given location or locations.
    unit_multiplier : float or int, default 1.0
        Adjust unit of the returned cost value. For example, if model units
        are kW and kWh, ``unit_multiplier=1.0`` will return cost per kWh, and
        ``unit_multiplier=0.001`` will return cost per MWh.

    """
    if group:
        members = solution.groups.to_pandas().at[group, 'members'].split('|')
    else:
        members = slice(None)
    if locations is None:
        locations = slice(None)

    # Make sure that locations is a list if it's a single value
    if isinstance(locations, (str, float, int)):
        locations = [locations]

    cost = solution['costs'].loc[dict(k=cost_class, x=locations, y=members)].sum(dim='x').to_pandas()
    ec_prod = solution['ec_prod'].loc[dict(c=carrier, x=locations, y=members)].sum(dim='x').to_pandas()

    return (ec_prod / cost) * unit_multiplier
dataset/ETHPy150Open calliope-project/calliope/calliope/analysis.py/get_levelized_cost/swapped operands of `/`