3
3
import numpy as np
4
4
import streamlit as st
5
5
from datetime import datetime , timedelta , time , timezone
6
+ from zoneinfo import ZoneInfo
6
7
from pvsite_datamodel .read import get_site_by_uuid
7
8
from pvsite_datamodel .read .model import get_models
8
9
from sqlalchemy .orm import Session
15
16
)
16
17
17
18
import plotly .graph_objects as go
18
- import pytz
19
19
20
20
# Penalty Calculator
21
21
def calculate_penalty (df , region , asset_type , capacity_kw ):
@@ -129,7 +129,8 @@ def pvsite_forecast_page():
129
129
timezone_selected = st .sidebar .selectbox (
130
130
"Select timezone" , ["UTC" , "Asia/Calcutta" ]
131
131
)
132
- timezone_selected = pytz .timezone (timezone_selected )
132
+
133
+ timezone_selected = ZoneInfo (timezone_selected )
133
134
134
135
day_after_tomorrow = datetime .today () + timedelta (days = 3 )
135
136
starttime = st .sidebar .date_input (
@@ -221,18 +222,16 @@ def pvsite_forecast_page():
221
222
endtime = datetime .combine (endtime , time .min )
222
223
223
224
# change to the correct timezone
224
- # starttime = starttime.replace(tzinfo=timezone_selected)
225
- # endtime = endtime.replace(tzinfo=timezone_selected)
226
- starttime = timezone_selected .localize (starttime )
227
- endtime = timezone_selected .localize (endtime )
225
+ starttime = starttime .replace (tzinfo = timezone_selected )
226
+ endtime = endtime .replace (tzinfo = timezone_selected )
228
227
229
228
# change to utc
230
- starttime = starttime .astimezone (pytz .utc )
231
- endtime = endtime .astimezone (pytz .utc )
229
+ starttime = starttime .astimezone (timezone .utc )
230
+ endtime = endtime .astimezone (timezone .utc )
232
231
233
232
if created is not None :
234
- created = timezone_selected . localize ( created )
235
- created = created .astimezone (pytz .utc )
233
+ created = created . replace ( tzinfo = timezone_selected )
234
+ created = created .astimezone (timezone .utc )
236
235
237
236
# great ml model names for this site
238
237
@@ -286,7 +285,7 @@ class Models:
286
285
y = [i .forecast_power_kw for i in forecast_values ]
287
286
288
287
# convert to timezone
289
- x = [i .replace (tzinfo = pytz .utc ) for i in x ]
288
+ x = [i .replace (tzinfo = timezone .utc ) for i in x ]
290
289
x = [i .astimezone (timezone_selected ) for i in x ]
291
290
292
291
ys [model .name ] = y
@@ -310,7 +309,7 @@ class Models:
310
309
]
311
310
312
311
# convert to timezone
313
- xx = [i .replace (tzinfo = pytz .utc ) for i in xx ]
312
+ xx = [i .replace (tzinfo = timezone .utc ) for i in xx ]
314
313
xx = [i .astimezone (timezone_selected ) for i in xx ]
315
314
316
315
df_forecast = []
0 commit comments