Function reference

NEMO provides several functions intended for end users - these are documented below. There are also a number of internal functions in NEMO that are documented in the program's Julia code.

calculatescenario

See Calculating a scenario.

convertscenariounits

NemoMod.convertscenariounitsFunction
convertscenariounits(
    path::String; 
    energy_multiplier::Float64 = 1.0, 
    power_multiplier::Float64 = 1.0, 
    cost_multiplier::Float64 = 1.0, 
    emissions_multiplier::Float64 = 1.0, 
    quiet::Bool = false
)

Converts units of measure in the scenario database at path. Quantities denominated in energy units are multiplied by energy_multiplier, quantities denominated in power units are multiplied by power_multiplier, quantities denominated in cost units are multiplied by cost_multiplier, and quantities denominated in emissions units are multiplied by emissions_multiplier. The quiet argument suppresses non-essential status messages.

This function assumes that consistent energy and power units are used across regions, and it converts both parameter and variable tables. It also converts default values in the DefaultParams table.

source

convert_ini_to_toml

NemoMod.convert_ini_to_tomlFunction
 convert_ini_to_toml(ini_path::String, toml_path::String, quiet::Bool = false)

Converts a configuration file from NEMO 2.2 or earlier (in INI format) to the TOML format used in NEMO version 2.3 and later.

Arguments

  • ini_path::String: Path to the INI file to be converted.
  • toml_path::String: Path where the new TOML file should be saved.
  • quiet::Bool = false: Suppresses low-priority status messages (which are otherwise printed to STDOUT).
source

convert_osemosys

NemoMod.convert_osemosysFunction
convert_osemosys(osemosys_path::String, nemo_path::String;
    defaults::Dict{String, Float64} = Dict{String, Float64}(),
    quiet::Bool = false,
    config_path::String = "")

Converts an OSeMOSYS scenario database to NEMO format.

osemosys_path can be either:

  • A path to an SQLite database with OSeMOSYS-format tables (as produced by otoole), or
  • A path to a directory of otoole-format CSV files (one CSV per OSeMOSYS table, with columns named after set members and VALUE). In this case, config_path must also be provided. The CSV directory is loaded into a temporary SQLite database in-process using CSV.jl and YAML.jl — otoole does not need to be installed.

The OSeMOSYS tables should use uppercase column names matching set names (e.g., REGION, TECHNOLOGY, YEAR) and VALUE for data columns.

Creates a new NEMO scenario database at nemo_path using createnemodb, then copies and transforms data from the OSeMOSYS source. Tables that exist only in NEMO (e.g., transmission network tables) are left empty.

Arguments

  • osemosys_path::String: Path to the source OSeMOSYS SQLite database or otoole CSV directory.
  • nemo_path::String: Path for the output NEMO SQLite database (will be created/overwritten).
  • defaults::Dict{String, Float64} = Dict{String, Float64}(): Default values to set in the NEMO DefaultParams table, keyed by parameter table name.
  • quiet::Bool = false: Suppresses status messages when true.
  • config_path::String = "": Path to otoole config.yaml file. Required when osemosys_path is a CSV directory. Used to determine each CSV's schema (column types and indices) and to validate that every CSV file in the directory matches a declared table.
source

createnemodb

NemoMod.createnemodbFunction
createnemodb(path::String;
defaultvals::Dict{String, Float64} = Dict{String, Float64}(),
foreignkeys::Bool = false)

Creates an empty NEMO scenario database in SQLite. If the specified database already exists, drops and recreates NEMO tables in the database.

Arguments

  • path::String: Full path to the scenario database, including the file name.
  • defaultvals::Dict{String, Float64} = Dict{String, Float64}(): Dictionary of parameter table names and default values for val column.
  • foreignkeys::Bool = false: Indicates whether to create foreign keys within the database.
source

data_validation

NemoMod.data_validationFunction
data_validation(db::SQLite.DB; expected_version::Int = NEMO_DB_VERSION)

Validates a NEMO scenario database for internal consistency. Each check that finds violations emits a single @warn message summarizing the violations for that check. If any check finds at least one violation, this function throws an error after all checks have run, instructing the user to consult the preceding warnings.

Verifies up front that the database schema is at expected_version (default: the current NEMO data dictionary version). If the database is at a different version, throws an error without running any checks, since the checks assume the latest schema.

Arguments

  • db::SQLite.DB: An open NEMO scenario database.
  • expected_version::Int = NEMO_DB_VERSION: The schema version the checks were written for. Override only for advanced/testing scenarios.
source

dropdefaultviews

dropresulttables

NemoMod.dropresulttablesFunction
dropresulttables(db::SQLite.DB, quiet::Bool = true)

Drops all tables in db whose name begins with ""v"" or ""sqlite_stat"" (both case-sensitive). The quiet parameter determines whether most status messages are suppressed.

source

logmsg

NemoMod.logmsgFunction
logmsg(msg::String, suppress=false, dtm=now()::DateTime)

Prints a log message (msg) to STDOUT. The message is suppressed if suppress == true. dtm determines the date and time included in the printed message.

Examples

julia> using Dates

julia> logmsg("Test message", false, DateTime(2020))
2020-01-Jan 00:00:00.000 Test message
source

setparamdefault

NemoMod.setparamdefaultFunction
setparamdefault(db::SQLite.DB, table::String, val::Float64)

Sets the default value for a parameter table in a NEMO scenario database.

Arguments

  • db::SQLite.DB: Scenario database containing the parameter table.
  • table::String: Table name (case-sensitive).
  • val::Float64: Parameter value (must be a floating-point number).
source

find_infeasibilities

NemoMod.find_infeasibilitiesFunction
find_infeasibilities(m::JuMP.Model,
    silent_solver::Bool=false
)

Returns a Vector of constraint data for constraints in m that cause infeasibility. silent_solver suppresses output from the solver for m.

Arguments

  • m::JuMP.Model: Model to check for infeasibility. Should be a NEMO model created with calculatescenario.
  • silent_solver::Bool = false: Suppresses output from the solver for m.
source