最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Why do the results I extract manually not match the results I get with the code? - Stack Overflow

programmeradmin2浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 2

The difference is very likely because the API call uses version 5.2, whereas the interface you are downloading from is version 5.3.

发布评论

评论列表(0)

  1. 暂无评论