-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0482d1
commit cf7b5af
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" We noticed that for lots of the passive sites, the tilt was wrong in the database.""" | ||
|
||
import os | ||
from pvconsumer.solar_sheffield_passiv import get_all_systems_from_solar_sheffield | ||
from pvsite_datamodel.connection import DatabaseConnection | ||
from pvsite_datamodel.read.site import get_all_sites | ||
|
||
url = os.getenv("SS_URL") | ||
user_id = os.getenv("SS_USER_ID") | ||
key = os.getenv("SS_KEY") | ||
ocf_url_db = os.getenv("URL_DB") | ||
|
||
all_pv_systems_df = get_all_systems_from_solar_sheffield() | ||
|
||
connection = DatabaseConnection(url=url, echo=True) | ||
with connection.get_session() as session: | ||
|
||
# get all sites | ||
sites = get_all_sites(session) | ||
sites_found = 0 | ||
|
||
for site in sites: | ||
all_pv_systems_df_temp = all_pv_systems_df[all_pv_systems_df['pv_system_id'] == site.client_site_id] | ||
|
||
if len(all_pv_systems_df_temp) == 0: | ||
print(f"Site {site.client_site_id} not found in solar sheffield") | ||
continue | ||
else: | ||
sites_found += 1 | ||
print(f"Site {site.client_site_id} found in solar sheffield") | ||
old_tilt = site.tilt | ||
new_tilt = all_pv_systems_df_temp.iloc[0].tilt | ||
print(f"Old tilt: {old_tilt}, new tilt: {new_tilt}") | ||
if new_tilt != 'None': | ||
new_tilt = float(new_tilt) | ||
|
||
if (new_tilt != 'None') and (new_tilt is not None) and (old_tilt != new_tilt): | ||
site.tilt = new_tilt | ||
print(f"Updated tilt for site {site.client_site_id} from {old_tilt} to {new_tilt}") | ||
session.commit() | ||
|
||
|
||
print(f"Found {sites_found} sites in solar sheffield") |