[Python] Why do the results I extract manually not match the results I get with the code?

Discussão em 'Python' iniciado por Stack, Março 14, 2025.

  1. Stack

    Stack Membro Participativo

    I want a Python code, give it an Excel file and it will give me the results.

    comparison image between manual and automated 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
    })

    Continue reading...

Compartilhe esta Página