WECGridTime
API Reference
Centralized time coordination for WEC-Grid simulations.
Coordinates temporal aspects across power system modeling (PSS®E, PyPSA), WEC simulations (WEC-Sim), and visualization components. Manages simulation time windows, sampling intervals, and ensures cross-platform alignment.
Attributes:
Name | Type | Description |
---|---|---|
start_time |
datetime
|
Simulation start timestamp. Defaults to current date at midnight. |
num_steps |
int
|
Number of simulation time steps. Defaults to 288 (24 hours at 5-minute intervals). |
freq |
str
|
Pandas frequency string for time intervals. Defaults to "5min" (5-minute intervals). |
sim_stop |
datetime
|
Calculated simulation end timestamp. Automatically computed from start_time, sim_length, and freq. Updated whenever simulation parameters change. |
Example
Default 24-hour simulation at 5-minute intervals
time_mgr = WECGridTime() print(f"Duration: {time_mgr.num_steps} steps") print(f"Interval: {time_mgr.freq}") Duration: 288 steps Interval: 5T
Custom simulation period
from datetime import datetime time_mgr = WECGridTime( ... start_time=datetime(2023, 6, 15, 0, 0, 0), ... sim_length=144, # 12 hours ... freq="5min" ... ) print(f"Start: {time_mgr.start_time}")
Source code in src/wecgrid/util/time.py
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 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 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 |
|
snapshots
property
Generate time snapshots for simulation time series.
Returns:
Type | Description |
---|---|
DatetimeIndex
|
pd.DatetimeIndex: Simulation timestamps from start_time with length sim_length. |
set_end_time(end_time)
Set simulation duration by specifying the desired end time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
end_time
|
datetime
|
Desired simulation end timestamp. Must be later than current start_time. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If end_time is earlier than or equal to start_time. |
Source code in src/wecgrid/util/time.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
update(*, start_time=None, num_steps=None, freq=None)
Update simulation time parameters with automatic recalculation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_time
|
datetime
|
New simulation start timestamp. |
None
|
num_steps
|
int
|
New number of simulation time steps. |
None
|
freq
|
str
|
New pandas frequency string for time intervals. |
None
|
Source code in src/wecgrid/util/time.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|