I want a Python code, give it an Excel file and it will give me the results.
The colored results are the correct results that I got manually from the site PVGIS(/). As for the other results, I got them using Python code. They are close, but I want correct and accurate results. Please help.
optimize_slope_azimuth = 1
optimizeazimuth=0
for lat, lon in zip(df["Latitudes"], df["Longitudes"]):
url = (f"={lat}&lon={lon}&peakpower=1&loss=14"
f"&mountingplace=free&optimalinclination={optimize_slope_azimuth}&optimalangles={optimizeazimuth}"
f"&outputformat=json")
response = requests.get(url)
if response.status_code == 200:
data = response.json()
yearly_pv_energy = data["outputs"]["totals"]["fixed"]["E_y"] # [kWh]
yearly_irradiation = data["outputs"]["totals"]["fixed"]["H(i)_y"] # [kWh/m2]
year_variability = data["outputs"]["totals"]["fixed"]["SD_y"] # [kWh]
results.append({
"Latitude": lat,
"Longitude": lon,
"Yearly PV Energy [kWh]": yearly_pv_energy,
"Yearly In-Plane Irradiation [kWh/m2]": yearly_irradiation,
"Year-to-Year Variability [kWh]": year_variability
})
I want a Python code, give it an Excel file and it will give me the results.
The colored results are the correct results that I got manually from the site PVGIS(https://re.jrc.ec.europa.eu/pvg_tools/en/). As for the other results, I got them using Python code. They are close, but I want correct and accurate results. Please help.
optimize_slope_azimuth = 1
optimizeazimuth=0
for lat, lon in zip(df["Latitudes"], df["Longitudes"]):
url = (f"https://re.jrc.ec.europa.eu/api/v5_2/PVcalc?lat={lat}&lon={lon}&peakpower=1&loss=14"
f"&mountingplace=free&optimalinclination={optimize_slope_azimuth}&optimalangles={optimizeazimuth}"
f"&outputformat=json")
response = requests.get(url)
if response.status_code == 200:
data = response.json()
yearly_pv_energy = data["outputs"]["totals"]["fixed"]["E_y"] # [kWh]
yearly_irradiation = data["outputs"]["totals"]["fixed"]["H(i)_y"] # [kWh/m2]
year_variability = data["outputs"]["totals"]["fixed"]["SD_y"] # [kWh]
results.append({
"Latitude": lat,
"Longitude": lon,
"Yearly PV Energy [kWh]": yearly_pv_energy,
"Yearly In-Plane Irradiation [kWh/m2]": yearly_irradiation,
"Year-to-Year Variability [kWh]": year_variability
})
Share
Improve this question
edited Mar 16 at 5:17
Hai Vu
40.9k15 gold badges71 silver badges102 bronze badges
asked Mar 14 at 21:30
Oussama LatelliOussama Latelli
11 silver badge
1 Answer
Reset to default 2The difference is very likely because the API call uses version 5.2, whereas the interface you are downloading from is version 5.3.