Skip to content

Instantly share code, notes, and snippets.

@jurand71
Created August 23, 2022 06:10
Show Gist options
  • Save jurand71/359b7f7447eb5a626cb17446e6bd3810 to your computer and use it in GitHub Desktop.
Save jurand71/359b7f7447eb5a626cb17446e6bd3810 to your computer and use it in GitHub Desktop.
import numpy as np
import pandas as pd
import pvlib
f = pd.read_csv("osm_m_pl_geokod.csv", dtype={'city': 'str', 'county': 'str', 'state': 'str',
'lat':np.float64, 'lon':np.float64,
'place_id':'Int64', 'osm_id':'Int64', 'display_name':'str'})
# calculate power of pv installation
def obtain_pv_power_from_PVGIS(lat, lon):
poa, _, _ = pvlib.iotools.get_pvgis_hourly(
latitude = lat,
longitude = lon,
start = pd.Timestamp('2020-01-01'),
end = pd.Timestamp('2020-12-31'),
raddatabase = 'PVGIS-SARAH2',
components = True,
surface_tilt = 0,
surface_azimuth = 0,
pvcalculation = True,
peakpower = 1,
pvtechchoice = 'crystSi',
mountingplace = 'free',
loss = 0,
trackingtype = 0,
url='https://re.jrc.ec.europa.eu/api/v5_2/',
)
poa['P'] = poa['P'].div(1000)
return poa
def obtain_power_for_location(lat, lon):
try:
poa = obtain_pv_power_from_PVGIS(lat, lon)
return poa['P'].sum()
except:
return None
places['power'] = places.apply(lambda row: obtain_power_for_location(row.lat,row.lon), axis=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment