common.py
Cross-cutting network helpers: load clipping and resource meta-data attachment.
clip_negative_loads_for_edge_cases(n, snakemake)
Clip negative Loads for selected edge cases.
This is neccessary, because some electricity demands are calculated
from heuristics. For example, heat for electricity from
energy_totals and population share is deducted from
regional base load. This can lead to negative Loads if
heuristics yield larger values than input data sets. However,
there are many examples where this may happen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
pypsa.Network
|
The network before solve step. |
required |
snakemake
|
snakemake.script.Snakemake
|
The Snakemake workflow object providing inputs, params, config, and outputs. |
required |
Returns:
| Type | Description |
|---|---|
None
|
Updates network in place. |
Raises:
| Type | Description |
|---|---|
RunTimeError
|
If expected edge cases could not be found. |
Source code in mods/network/common.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
modify_prenetwork(n, snakemake)
Apply all PyPSA-AT specific modifications to the pre-network.
This is the single entry point for all AT-specific modifications during
the modify_prenetwork Snakemake step. It orchestrates the individual
modification functions and encapsulates the conditional logic for when
each modification applies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
pypsa.Network
|
The pre-network to be modified in place. |
required |
snakemake
|
snakemake.script.Snakemake
|
The Snakemake workflow object providing inputs, params, config, and wildcards. |
required |
Returns:
| Type | Description |
|---|---|
None
|
Updates the :class: |
Source code in mods/network/common.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
prepare_sector_network(n, snakemake, nodes, costs, spatial)
Apply all PyPSA-AT specific modifications during prepare_sector_network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
The pre-network to be modified in place. |
required | |
snakemake
|
The Snakemake workflow object providing inputs, params, and config. |
required | |
costs
|
Processed cost DataFrame for the current planning horizon. |
required | |
nodes
|
Clustered node index ( |
required | |
spatial
|
Spatial namespace produced by |
required |
Returns:
| Type | Description |
|---|---|
|
Modifies the network in place. |
Source code in mods/network/common.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |