Reading input functions
add_default_system_data!
MacroEnergy.add_default_system_data!
— Functionadd_default_system_data!(system_data::AbstractDict{Symbol,Any})::Nothing
Add the default system data to the system data dictionary. This adds any required fields that are missing.
clean_up_keys
MacroEnergy.clean_up_keys
— Functionclean_up_keys(dict::AbstractDict{Symbol,Any})::AbstractDict{Symbol,Any}
Clean up a Dict{Symbol,Any} object by copying values from keys that match the key name.
eager_load_json_inputs
MacroEnergy.eager_load_json_inputs
— Functioneager_load_json_inputs(json_data::AbstractDict{Symbol, Any}, rel_path::AbstractString)::AbstractDict{Symbol, Any}
Recursively loads data from sources specified in an input Dict{Symbol,Any} and returns a new
Dict{Symbol,Any} object with the data inserted.
eager_load_json_inputs(json_data::AbstractVector{<:AbstractDict{Symbol,Any}}, rel_path::AbstractString)::AbstractVector{<:AbstractDict{Symbol,Any}}
Recursively loads data from sources specified in several input Dict{Symbol,Any}, stored as a Vector,
and returns a new Vector{Dict{Symbol,Any}} object with the data inserted.
fetch_data
MacroEnergy.fetch_data
— Functionfetch_data(path::AbstractString, dict::AbstractDict{Symbol, Any}, root_path::AbstractString, lazy_load::Bool = true)::Any
Fetch data from a JSON file or directory and return it as a Dict{Symbol,Any} object.
load_csv
MacroEnergy.load_csv
— Functionload_time_series_data(file_path::AbstractString, header::AbstractVector{Symbol})::Dict{Symbol,Any}
Load time series data from one or more headers in a CSV file and return as a DataFrame.
load_default_system_data
MacroEnergy.load_default_system_data
— Functionload_default_system_data()::Dict{Symbol,Any}
Load the default system data from a JSON file. This describes the default locations for the system data files.
load_json_inputs
MacroEnergy.load_json_inputs
— Functionload_json_inputs(file_path::AbstractString; rel_path::AbstractString=dirname(file_path), lazy_load::Bool = true)::Dict{Symbol,Any}
Load JSON data from a file and return a Dict{Symbol,Any} object. The data can all be included in the
specified JSON file or distributed across multiple files and directories, with each source specified
using "path" or "timeseries" keys.\n
The `rel_path` argument is used to specify the path relative to which the file paths of this distributed
data should be resolved.\n
If `lazy_load` is set to `true`, then only the top-level data in the specified JSON file will be loaded.
If `lazy_load` is set to `false`, then the distrinuted data will be loaded recursively into the
appropriate data structures.
load_system
MacroEnergy.load_system
— Functionload_system(path::AbstractString = pwd(); lazy_load::Bool=true)
Load a system from the system_data.json
file or directory containing the system data.
Arguments
path::AbstractString = pwd()
: The path to thesystem_data.json
file or directory containing the system data.lazy_load::Bool=true
: Whether to lazy load the system data.
Returns
- A
System
object containing the case data.
Examples
system = load_system("path/to/system_data.json")
system = load_system("path/to/system_data_directory")
load_system_data
MacroEnergy.load_system_data
— Functionload_system_data(file_path::AbstractString, rel_path::AbstractString; lazy_load::Bool = true)::Dict{Symbol,Any}
Load the system data (currently only from a JSON file) given a file path and directory to search for the file in. All other file names defined in the system data file are assumed to be relative to rel_path.
load_system_data(system::System, file_path::AbstractString)::Dict{Symbol,Any}
Load the system data (currently only from a JSON file) given a file path and existing System. All other file names defined in the system data file are assumed to be relative to the data_dirpath field of the System.
prep_system_data
MacroEnergy.prep_system_data
— Functionprep_system_data(file_path::AbstractString)::Nothing
This attempts to load the system data from the file at file_path, adds any missing fields from the default system data, and writes the updated system data back to the file. In the future, we may change this to not write to the file, but for now, it's a quick way to ensure the system data is up-to-date.
load_benders_settings
MacroEnergy.load_benders_settings
— Functionload_benders_settings(settings::AbstractDict{Symbol,Any}, path::AbstractString)::AbstractDict{Symbol,Any}
Load Benders settings from a file. First checks if a specific path is provided in the settings, otherwise looks for benders_settings.json in the settings directory. Handles both absolute and relative paths.
try_load_benders_settings
MacroEnergy.try_load_benders_settings
— Functiontry_load_benders_settings(path::AbstractString)::Union{AbstractDict{Symbol,Any}, Nothing}
Attempts to load Benders settings from the given path. Returns the settings if found, nothing otherwise.