Skip to content

Transport consumption reporting  #485

Open
@trevorb1

Description

Checklist

  • I am using the current master branch
  • I am running on an up-to-date pypsa-usa environment. Update via conda env update -f envs/environment.yaml

The Issue

I believe the plotter for transport consumption is double counting the non-road transport. It is grabbing both the individual links and the aggregators. The Sankey diagram PR has a potential solution.

def get_transport_consumption(
n: pypsa.Network,
state: Optional[str] = None,
) -> pd.DataFrame:
"""
Takes load from p0 link as loads are in kVMT or similar.
"""
loads = n.links[
(n.links.carrier.str.startswith("trn-"))
& ~(n.links.carrier.str.endswith("-veh"))
& ~(n.links.carrier == ("trn-air"))
& ~(n.links.carrier == ("trn-rail"))
& ~(n.links.carrier == ("trn-boat"))
]
if state:
l = _get_links_in_state(n, state)
loads = loads[loads.index.isin(l)]
df = n.links_t.p0[loads.index].mul(n.snapshot_weightings["objective"], axis=0).T
df.index = df.index.map(lambda x: x.split("trn-")[1])
return df.groupby(level=0).sum().T
match sector:
case "res" | "com" | "ind":
return get_service_consumption(n, sector, state)
case "trn":
return get_transport_consumption(n, state)
case _:
raise NotImplementedError

Steps To Reproduce

No response

Expected Behavior

No response

Error Message

No response

Anything else?

No response

Metadata

Assignees

No one assigned

    Labels

    SectorSector Coupling IssuebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions