PV data simulation
This package provides functions to simulate PV data using Renewables.ninja and PVGIS (for now)
Input parameters can be either user-defined or loaded directly from measured PV data files, ensuring that simulated and measured data are compared under the same assumptions.
Loading PV system parameters
To load parameters from a measured data file, use the load_pv_setup_from_meas_file function.
The file/location has to exist in the src/data/measured_pv/ folder.
from simeasren import load_pv_setup_from_meas_file
parameters = load_pv_setup_from_meas_file("Almeria")
Renewables.ninja
Simulated PV power output data from Renewables.ninja can be downloaded using the download_rn_data function.
This function queries the Renewables.ninja API for multiple datasets (MERRA2 and SARAH) and generates hourly PV electricity output based on the provided system parameters.
The resulting data is returned as a dictionary for further analysis, and the raw CSV files are saved in the project directory under results/simulated_pv.
API Token Setup
To use this function, you must have a valid Renewables.ninja API token.
Follow these steps to obtain it:
Register for a free account at renewables.ninja/register.
After logging in, visit your profile page.
Generate and copy your API token.
Provide the token as the
rn_tokenparameter when using the function.
When filled up manually, the expected parameters keys are:
Key |
Type |
Description |
|---|---|---|
|
Float |
Geographic latitude of the site |
|
Float |
Geographic longitude of the site |
|
Float |
PV module tilt angle (degrees) |
|
Float |
PV module azimuth (degrees) |
|
Float |
Installed PV capacity (kW) |
|
Float |
Overall system losses (%) |
|
Integer |
Start year of the simulation |
|
Integer |
End year of the simulation |
|
Integer |
1 for fixed-tilt systems, 0 for tracking systems |
|
Integer |
Tracking type (0 = none, 1 = single-axis, etc.) |
Example usage
With user-defined parameters
from simeasren import download_rn_data
# Define PV system parameters
pv_params = {
"Latitude": 37.0,
"Longitude": -2.5,
"Tilt": 30,
"Azimuth": 180,
"Max capacity simulation": 1000,
"System loss": 14,
"Start year": 2020,
"End year": 2020,
"Fixed": 1,
"Tracking": 0
}
# Download data
rn_data = download_rn_data("Almeria", pv_params, rn_token = "YOUR_RN_API_TOKEN")
Reading set-up from one of the measured data files:
from simeasren import download_rn_data, load_pv_setup_from_meas_file
pv_parameters = load_pv_setup_from_meas_file("Almeria")
rn_data = download_rn_data("Almeria", pv_parameters, rn_token="YOUR_RN_API_TOKEN")
PVGIS
Then simulated data can be generated in a similar fashion with PVGIS except that no token is necessary:
from simeasren import download_rn_data, load_pv_setup_from_meas_file
pv_parameters = load_pv_setup_from_meas_file("Almeria")
pvgis_data = download_pvgis_data("Almeria", pv_parameters)
Merge simulated and measured data
Most of the simeasren package functions need to read a file that combine both measured and simulated data.
To create this file for example in Almeria:
from simeasren import merge_sim_with_measured, load_pv_setup_from_meas_file, download_pvgis_data, download_rn_data
pv_parameters = load_pv_setup_from_meas_file("Almeria")
pvgis_data = download_pvgis_data("Almeria", pv_parameters)
rn_data = download_rn_data("Almeria", pv_parameters, rn_token="YOUR_RN_API_TOKEN")
merge_sim_with_measured("Almeria", pvgis_data, rn_data)
To include only pvgis data:
merge_sim_with_measured("Almeria", pvgis_data)