Methods - Internal

Index

Utility methods

EnergyModelsLanguageInterfaces.pvgis_profileFunction
pvgis_profile(time_start::DateTime, params::PVParameters;
    peakpower::Real=1.0,
    data_path::String = "pvgis_cache",
    filename_hint::String = "",
    normalize::Bool = true,
    no_weather_years::Int = 1,
    remove_leap_day::Bool = true,
)

Fetches hourly photovoltaic (PV) power output data for a specified start time (time_start), PV system parameters (params), and additional options, using the PVGIS seriescalc API. The function caches the results locally in a CSV file to optimize subsequent calls.

The actual call to the PVGIS API is handled by the helper function get_pvgis_data see get_pvgis_data for details.

Arguments

  • time_start::DateTime: The start of the time range for which the PV output data is requested.
  • params::PVParameters: Struct containing PV system and location parameters (e.g., latitude, longitude, peak power, technology, etc.).
  • peakpower::Real=1.0: Nominal peak power of the PV system in kilowatts (kW).
  • data_path::String="pvgis_cache": Directory where the cached CSV file will be stored.
  • filename_hint::String="": Optional string to include in the cache file name for identification.
  • normalize::Bool=true: Whether to normalize the power output by the peak power (i.e., return values between 0 and 1).
  • no_weather_years::Int=1: Number of years of weather data to fetch.
  • remove_leap_day::Bool=true: Whether to remove February 29th from the results.

Returns

A DataFrame containing the following columns:

  • :time_utc: Timestamps in UTC, rounded to the nearest hour.
  • :pv: PV power output in kilowatts (kW), normalized if requested.
source
EnergyModelsLanguageInterfaces.get_pvgis_dataFunction
get_pvgis_data(start_year::Int64, end_year::Int64, params::PVParameters, peakpower::Real, normalize::Bool)

Arguments

  • start_year::Int64: The starting year for the PVGIS data request.
  • end_year::Int64: The ending year for the PVGIS data request.
  • params::PVParameters: Struct containing PV system and location parameters (e.g., latitude, longitude, technology, etc.).
  • peakpower::Real = 1.0: Nominal peak power of the PV system in kilowatts (kW).
  • normalize::Bool = true: Whether to normalize the power output by the peak power.

Fetches hourly photovoltaic (PV) power output data for the specified years and PV system parameters using the PVGIS seriescalc API.

Details

The function queries the PVGIS seriescalc API, which provides hourly PV power output data based on the specified location, system parameters, and meteorological data. The API calculates the power output using the following inputs:

  • Solar radiation data.
  • PV system parameters (e.g., peak power, technology, mounting type).
  • Meteorological data (e.g., air temperature, wind speed).

The response includes hourly data for the specified years, which is parsed and processed into a DataFrame. The power output is converted from watts (W) to kilowatts (kW) for better readability.

Caching

The results are cached locally in a CSV file to avoid redundant API calls. The cache file is stored in the specified data_path directory, and its name includes the date, number of years, and an optional filename_hint.

Note

The PVGIS API documentation is available at: https://joint-research-centre.ec.europa.eu/photovoltaic-geographical-information-system-pvgis/getting-started-pvgis/pvgis-user-manual_en

Note

Due to current limitations on PVGIS, only dates within the years 2005 to 2023 can be queried.

source
EnergyModelsLanguageInterfaces.get_met_dataFunction
get_met_data(
    time_start::DateTime, 
    time_end::DateTime, 
    lat::Real, 
    lon::Real, 
    product::String, 
    variables::Vector{String}; 
    data_path::String = "metocean_api_data", 
    filename_hint::String = "", 
    reload_csv::Bool = true, 
    save_csv::Bool = true, 
)

Fetches meteorological data for a specified time range and geographic location.

Arguments

  • time_start::DateTime: Start of the time range for data retrieval.
  • time_end::DateTime: End of the time range for data retrieval.
  • lat::Real: Latitude of the location.
  • lon::Real: Longitude of the location.
  • product::String: Name of the meteorological data product to use.
  • variables::Vector{String}: List of meteorological variables to retrieve.
  • data_path::String: Directory path where data files are stored or will be saved.
  • filename_hint::String: Hint for naming the output file.
  • reload_csv::Bool: If true, reloads CSV data if available (default: true).
  • save_csv::Bool: If true, saves the retrieved data as a CSV file (default: true).
Usage of the function
  • The function may download data from remote sources if not available locally.
  • If save_csv is enabled, the data will be saved to a CSV file in the specified data_path.
  • For use of the "ERA5" data source, the user needs to register and obtain a CDS API key. This can be achieved by performing step 1: https://cds.climate.copernicus.eu/how-to-api
  • If data_path is provided as a relative path, it is relative to the current working directory of the Julia session. The user can check using pwd(), respectively.
source
EnergyModelsLanguageInterfaces.heat_demand_profileFunction
heat_demand_profile(
    time_start::DateTime,
    time_end::DateTime,
    lat::Real,
    lon::Real,
    temp_to_demand::Function;
    data_path::String = "metocean_api_data",
    filename_hint::String = "",
    source::String = "NORA3",
    reload_csv::Bool = true,
    save_csv::Bool = true,
)

Generates a heat demand profile for a specified location and time period using temperature data and a user-provided temperature-to-demand mapping function.

The function retrieves temperature data for the given latitude and longitude from the specified data source (e.g., "NORA3" or "ERA5") and applies the temp_to_demand function to convert temperature values into heat demand.

The data source is queried using the get_met_data function, which handles data retrieval, caching, and storage.

Arguments

  • time_start::DateTime is the start of the time period for the demand profile.
  • time_end::DateTime is the end of the time period for the demand profile.
  • lat::Real is the latitude of the location.
  • lon::Real is the longitude of the location.
  • temp_to_demand::Function is a function mapping temperature in Kelvin to demand.
  • data_path::String is the directory path to store or load temperature data (default: "metoceanapidata").
  • filename_hint::String is an optional hint for naming the data file (default: "").
  • source::String is the data source for temperature (default: "NORA3").
  • reload_csv::Bool is a flag indicating whether to reload CSV data if available (default: true).
  • save_csv::Bool is a flag indicating whether to save the generated profile to a CSV file (default: true).
source

Macros

EnergyModelsLanguageInterfaces.@dlsymMacro
@dlsym(lib, func)

This macro uses dlsym to load a function from a shared library specified by lib and func. It caches the result in a Ref to avoid repeated lookups. If the symbol is already loaded, it returns the cached pointer. Otherwise, it loads the symbol, caches it, and then returns the pointer.

source