Stats¶
This module provides functions and classes for tracking and analyzing statistics related to power grid networks.
plot_stats
¶
Generates and saves HTML plots of network statistics.
Creates histograms for various network statistics including number of generators, lines, transformers, overloads, and maximum loading. Saves the plots to an HTML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_path
|
str
|
Directory path where the stats CSV file is located and where the HTML plot will be saved. |
required |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If stats.csv is not found in the base_path directory. |
Source code in gridfm_datakit/utils/stats.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 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 56 57 58 59 60 61 |
|
Classes¶
Stats
¶
A class to track and analyze statistics related to power grid networks.
This class maintains data lists of various network metrics including number of lines, transformers, generators, overloads, maximum loading, total active power imbalance, and total reactive power imbalance.
Attributes:
Name | Type | Description |
---|---|---|
n_lines |
List of number of in-service lines over time. |
|
n_trafos |
List of number of in-service transformers over time. |
|
n_generators |
List of total in-service generators (gen + sgen) over time. |
|
n_overloads |
List of number of overloaded elements over time. |
|
max_loading |
List of maximum loading percentages over time. |
|
total_p_diff |
List of total active power imbalance over time. |
|
total_q_diff |
List of total reactive power imbalance over time. |
Source code in gridfm_datakit/utils/stats.py
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 94 95 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 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
__init__()
¶Initializes the Stats object with empty lists for all tracked metrics.
Source code in gridfm_datakit/utils/stats.py
80 81 82 83 84 85 86 87 88 |
|
load(base_path)
¶Loads the tracked statistics from a CSV file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_path
|
str
|
Directory path where the CSV file is saved. |
required |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If stats.csv is not found in the base_path directory. |
Source code in gridfm_datakit/utils/stats.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
merge(other)
¶Merges another Stats object into this one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
Stats
|
Another Stats object whose data will be merged into this one. |
required |
Source code in gridfm_datakit/utils/stats.py
120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
save(base_path)
¶Saves the tracked statistics to a CSV file.
If the file already exists, appends the new data with a continuous index. If the file doesn't exist, creates a new file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_path
|
str
|
Directory path where the CSV file will be saved. |
required |
Source code in gridfm_datakit/utils/stats.py
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 |
|
update(net)
¶Adds the current state of the network to the data lists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
net
|
pandapowerNet
|
A pandapower network object containing the current state of the grid. |
required |
Source code in gridfm_datakit/utils/stats.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|