Methods - Internal
Index
EnergyModelsLanguageInterfaces.bio_typeEnergyModelsLanguageInterfaces.cleanup_librariesEnergyModelsLanguageInterfaces.electricity_resourceEnergyModelsLanguageInterfaces.get_met_dataEnergyModelsLanguageInterfaces.get_pvgis_dataEnergyModelsLanguageInterfaces.get_python_functionEnergyModelsLanguageInterfaces.getfirstEnergyModelsLanguageInterfaces.heat_demand_profileEnergyModelsLanguageInterfaces.moistureEnergyModelsLanguageInterfaces.pvgis_profileEnergyModelsLanguageInterfaces.@dlsym
Utility methods
EnergyModelsLanguageInterfaces.cleanup_libraries — Function
cleanup_libraries()Close all the C module libraries that have been loaded by EnergyModelsLanguageInterfaces.
EnergyModelsLanguageInterfaces.getfirst — Function
getfirst(f::Function, a::Vector)Return the first element of Vector a satisfying the requirement of Function f.
EnergyModelsLanguageInterfaces.get_python_function — Function
get_python_function(module_name::String, function_name::String)Import the requested function function_name from the python module module_name.
EnergyModelsLanguageInterfaces.moisture — Function
bio_type(p::ResourceBio)Returns the moisture content of a ResourceBio p.
EnergyModelsLanguageInterfaces.bio_type — Function
bio_type(p::ResourceBio)Returns the biomass type of a ResourceBio p.
EnergyModelsLanguageInterfaces.electricity_resource — Function
electricity_resource(n::BioCHP)Returns the electricity resource of BioCHP node n.
EnergyModelsLanguageInterfaces.pvgis_profile — Function
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.
EnergyModelsLanguageInterfaces.get_pvgis_data — Function
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.
EnergyModelsLanguageInterfaces.get_met_data — Function
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: Iftrue, saves the retrieved data as a CSV file (default: true).
- The function may download data from remote sources if not available locally.
- If
save_csvis enabled, the data will be saved to a CSV file in the specifieddata_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_pathis provided as a relative path, it is relative to the current working directory of the Julia session. The user can check usingpwd(), respectively.
EnergyModelsLanguageInterfaces.heat_demand_profile — Function
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::DateTimeis the start of the time period for the demand profile.time_end::DateTimeis the end of the time period for the demand profile.lat::Realis the latitude of the location.lon::Realis the longitude of the location.temp_to_demand::Functionis a function mapping temperature in Kelvin to demand.data_path::Stringis the directory path to store or load temperature data (default: "metoceanapidata").filename_hint::Stringis an optional hint for naming the data file (default: "").source::Stringis the data source for temperature (default: "NORA3").reload_csv::Boolis a flag indicating whether to reload CSV data if available (default: true).save_csv::Boolis a flag indicating whether to save the generated profile to a CSV file (default: true).
Macros
EnergyModelsLanguageInterfaces.@dlsym — Macro
@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.