InfrastructureSystems API Reference

InfrastructureSystems.DeterministicType
mutable struct Deterministic <: AbstractDeterministic
    name::String
    data::Union{
        SortedDict{Dates.DateTime, Vector{CONSTANT}},
        SortedDict{Dates.DateTime, Vector{POLYNOMIAL}},
        SortedDict{Dates.DateTime, Vector{PWL}},
    }
    resolution::Dates.Period
    scaling_factor_multiplier::Union{Nothing, Function}
    internal::InfrastructureSystemsInternal
end

A deterministic forecast for a particular data field in a Component.

Arguments

  • name::String: user-defined name
  • data::Union{SortedDict{Dates.DateTime, Vector{CONSTANT}}, SortedDict{Dates.DateTime, Vector{POLYNOMIAL}}, SortedDict{Dates.DateTime, Vector{PWL}}}: timestamp - scalingfactor
  • resolution::Dates.Period: forecast resolution
  • scaling_factor_multiplier::Union{Nothing, Function}: Applicable when the time series data are scaling factors. Called on the associated component to convert the values.
  • internal::InfrastructureSystemsInternal
source
InfrastructureSystems.DeterministicMethod
Deterministic(name::AbstractString, input_data::AbstractDict{Dates.DateTime,#s94} where #s94<:TimeSeries.TimeArray; normalization_factor, scaling_factor_multiplier) -> InfrastructureSystems.Deterministic

Construct Deterministic from a Dict of TimeArrays.

Arguments

  • name::AbstractString: user-defined name
  • input_data::AbstractDict{Dates.DateTime, TimeSeries.TimeArray}: time series data.
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
  • timestamp = :timestamp: If the values are DataFrames is passed then this must be the column name that contains timestamps.
source
InfrastructureSystems.DeterministicMethod
Deterministic(name::AbstractString, filename::AbstractString, component::InfrastructureSystems.InfrastructureSystemsComponent, resolution::Dates.Period; normalization_factor, scaling_factor_multiplier) -> InfrastructureSystems.Deterministic

Construct Deterministic from a CSV file. The first column must be a timestamp in DateTime format and the columns the values in the forecast window.

Arguments

  • name::AbstractString: user-defined name
  • filename::AbstractString: name of CSV file containing data
  • component::InfrastructureSystemsComponent: component associated with the data
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
source
InfrastructureSystems.DeterministicMethod
Deterministic(name::AbstractString, series_data::InfrastructureSystems.RawTimeSeries, resolution::Dates.Period; normalization_factor, scaling_factor_multiplier) -> InfrastructureSystems.Deterministic

Construct Deterministic from RawTimeSeries.

source
InfrastructureSystems.DeterministicMethod
Deterministic(forecast::InfrastructureSystems.Deterministic, data::Any) -> InfrastructureSystems.Deterministic

Construct a new Deterministic from an existing instance and a subset of data.

source
InfrastructureSystems.DeterministicMetadataType
mutable struct DeterministicMetadata <: ForecastMetadata
    name::String
    resolution::Dates.Period
    initial_timestamp::Dates.DateTime
    interval::Dates.Period
    count::Int
    time_series_uuid::UUIDs.UUID
    horizon::Int
    scaling_factor_multiplier::Union{Nothing, Function}
    internal::InfrastructureSystemsInternal
end

A deterministic forecast for a particular data field in a Component.

Arguments

  • name::String: user-defined name
  • resolution::Dates.Period
  • initial_timestamp::Dates.DateTime: time series availability time
  • interval::Dates.Period: time step between forecast windows
  • count::Int: number of forecast windows
  • time_series_uuid::UUIDs.UUID: reference to time series data
  • horizon::Int: length of this time series
  • scaling_factor_multiplier::Union{Nothing, Function}: Applicable when the time series data are scaling factors. Called on the associated component to convert the values.
  • internal::InfrastructureSystemsInternal
source
InfrastructureSystems.DeterministicSingleTimeSeriesType
mutable struct DeterministicSingleTimeSeries <: AbstractDeterministic
    single_time_series::SingleTimeSeries
    initial_timestamp::Dates.DateTime
    interval::Dates.Period
    count::Int
    horizon::Int
end

A deterministic forecast for a particular data field in a Component that wraps a SingleTimeSeries.

Arguments

  • single_time_series::SingleTimeSeries: wrapped SingleTimeSeries object
  • initial_timestamp::Dates.DateTime: time series availability time
  • interval::Dates.Period: time step between forecast windows
  • count::Int: number of forecast windows
  • horizon::Int: length of this time series
source
InfrastructureSystems.ForecastCacheMethod
ForecastCache(::Type{T<:InfrastructureSystems.Forecast}, component::InfrastructureSystems.InfrastructureSystemsComponent, name::AbstractString; start_time, horizon, cache_size_bytes, ignore_scaling_factors) -> InfrastructureSystems.ForecastCache

Construct ForecastCache to automatically control caching of forecast data. Maintains some count of forecast windows in memory based on cache_size_bytes.

Call Base.iterate or get_next_time_series_array! to retrieve data.

Arguments

  • ::Type{T}: subtype of Forecast
  • component::InfrastructureSystemsComponent: component
  • name::AbstractString: forecast name
  • start_time::Union{Nothing, Dates.DateTime} = nothing: forecast start time
  • horizon::Union{Nothing, Int} = nothing: forecast horizon
  • cache_size_bytes = TIME_SERIES_CACHE_SIZE_BYTES: maximum size of data to keep in memory
  • ignore_scaling_factors = false: controls whether to ignore scaling_factor_multiplier in the time series instance
source
InfrastructureSystems.Hdf5TimeSeriesStorageMethod
Hdf5TimeSeriesStorage(create_file::Bool; filename, directory, read_only) -> InfrastructureSystems.Hdf5TimeSeriesStorage

Constructs Hdf5TimeSeriesStorage.

Arguments

  • create_file::Bool: create new file
  • filename=nothing: if nothing, create a temp file, else use this name.
  • directory=nothing: if set and filename is nothing, create a temp file in this directory. Use tempdir() if not set. This should be set if the time series data is larger than the tmp filesystem can hold.
  • read_only = false: If true, don't allow changes to the file. Allows simultaneous read access.
source
InfrastructureSystems.InMemoryTimeSeriesStorageMethod
InMemoryTimeSeriesStorage(hdf5_storage::InfrastructureSystems.Hdf5TimeSeriesStorage) -> InfrastructureSystems.InMemoryTimeSeriesStorage

Constructs InMemoryTimeSeriesStorage from an instance of Hdf5TimeSeriesStorage.

source
InfrastructureSystems.LazyDictFromIteratorMethod

LazyDictFromIterator creates a dictionary from an iterator, but only increments the iterator and adds items to the dictionary as it needs them. In the worst case it is identical to creating a dictionary by iterating over the entire list. Each V should have a K member.

Arguments

  • K: type of the dictionary keys
  • V: type of the dictionary values
  • iter: any object implementing the Iterator interface
  • getter::Function: method to call on V to get its K
source
InfrastructureSystems.LogEventTrackerType
LogEventTracker() -> InfrastructureSystems.LogEventTracker
LogEventTracker(levels::Any) -> InfrastructureSystems.LogEventTracker

Tracks counts of all log events by level.

Examples

LogEventTracker()
LogEventTracker((Logging.Info, Logging.Warn, Logging.Error))
source
InfrastructureSystems.MultiLoggerType

Redirects log events to multiple loggers. The primary use case is to allow logging to both a file and the console. Secondarily, it can track the counts of all log messages.

Example

MultiLogger([ConsoleLogger(stderr), SimpleLogger(stream)], LogEventTracker())
source
InfrastructureSystems.MultiLoggerMethod
MultiLogger(loggers::Array{T<:Base.CoreLogging.AbstractLogger,N} where N) -> InfrastructureSystems.MultiLogger

Creates a MultiLogger with no event tracking.

Example

MultiLogger([ConsoleLogger(stderr), SimpleLogger(stream)])
source
InfrastructureSystems.ProbabilisticType
mutable struct Probabilistic <: Forecast
    name::String
    resolution::Dates.Period
    percentiles::Vector{Float64}
    data::Union{
        SortedDict{Dates.DateTime, Matrix{CONSTANT}},
        SortedDict{Dates.DateTime, Matrix{POLYNOMIAL}},
        SortedDict{Dates.DateTime, Matrix{PWL}},
    }
    scaling_factor_multiplier::Union{Nothing, Function}
    internal::InfrastructureSystemsInternal
end

A Probabilistic forecast for a particular data field in a Component.

Arguments

  • name::String: user-defined name
  • resolution::Dates.Period: forecast resolution
  • percentiles::Vector{Float64}: Percentiles for the probabilistic forecast
  • data::Union{SortedDict{Dates.DateTime, Matrix{CONSTANT}}, SortedDict{Dates.DateTime, Matrix{POLYNOMIAL}}, SortedDict{Dates.DateTime, Matrix{PWL}}}: timestamp - scalingfactor
  • scaling_factor_multiplier::Union{Nothing, Function}: Applicable when the time series data are scaling factors. Called on the associated component to convert the values.
  • internal::InfrastructureSystemsInternal
source
InfrastructureSystems.ProbabilisticMethod
Probabilistic(name::AbstractString, input_data::AbstractDict, percentiles::Array{T,1} where T, resolution::Dates.Period; normalization_factor, scaling_factor_multiplier) -> InfrastructureSystems.Probabilistic

Construct Probabilistic from a SortedDict of Arrays.

Arguments

  • name::AbstractString: user-defined name
  • input_data::AbstractDict{Dates.DateTime, Matrix{Float64}}: time series data.
  • percentiles: Percentiles represented in the probabilistic forecast
  • resolution::Dates.Period: The resolution of the forecast in Dates.Period`
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
source
InfrastructureSystems.ProbabilisticMethod
Probabilistic(name::AbstractString, input_data::AbstractDict{Dates.DateTime,#s94} where #s94<:TimeSeries.TimeArray, percentiles::Array{Float64,1}; normalization_factor, scaling_factor_multiplier) -> InfrastructureSystems.Probabilistic

Construct Probabilistic from a Dict of TimeArrays.

Arguments

  • name::AbstractString: user-defined name
  • input_data::AbstractDict{Dates.DateTime, TimeSeries.TimeArray}: time series data.
  • percentiles: Percentiles represented in the probabilistic forecast
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
  • timestamp = :timestamp: If the values are DataFrames is passed then this must be the column name that contains timestamps.
source
InfrastructureSystems.ProbabilisticMethod
Probabilistic(name::AbstractString, series_data::InfrastructureSystems.RawTimeSeries, percentiles::Array{T,1} where T, resolution::Dates.Period; normalization_factor, scaling_factor_multiplier) -> InfrastructureSystems.Probabilistic

Construct Deterministic from RawTimeSeries.

source
InfrastructureSystems.ProbabilisticMetadataType
mutable struct ProbabilisticMetadata <: ForecastMetadata
    name::String
    initial_timestamp::Dates.DateTime
    resolution::Dates.Period
    interval::Dates.Period
    count::Int
    percentiles::Vector{Float64}
    time_series_uuid::UUIDs.UUID
    horizon::Int
    scaling_factor_multiplier::Union{Nothing, Function}
    internal::InfrastructureSystemsInternal
end

A Probabilistic forecast for a particular data field in a Component.

Arguments

  • name::String: user-defined name
  • initial_timestamp::Dates.DateTime: time series availability time
  • resolution::Dates.Period
  • interval::Dates.Period: time step between forecast windows
  • count::Int: number of forecast windows
  • percentiles::Vector{Float64}: Percentiles for the probabilistic forecast
  • time_series_uuid::UUIDs.UUID: reference to time series data
  • horizon::Int: length of this time series
  • scaling_factor_multiplier::Union{Nothing, Function}: Applicable when the time series data are scaling factors. Called on the associated component to convert the values.
  • internal::InfrastructureSystemsInternal
source
InfrastructureSystems.RecorderMethod
Recorder(name::Symbol; io, mode, directory) -> InfrastructureSystems.Recorder

Construct a Recorder.

Arguments

  • name::Symbol: name of recorder
  • io::Union{Nothing, IO}: If nothing, record events in a file using name.
  • mode = "w": Only used when io is nothing.
  • directory = ".": Only used when io is nothing.
source
InfrastructureSystems.ScenariosType
mutable struct Scenarios <: Forecast
    name::String
    resolution::Dates.Period
    scenario_count::Int64
    data::Union{
        SortedDict{Dates.DateTime, Matrix{CONSTANT}},
        SortedDict{Dates.DateTime, Matrix{POLYNOMIAL}},
        SortedDict{Dates.DateTime, Matrix{PWL}},
    }
    scaling_factor_multiplier::Union{Nothing, Function}
    internal::InfrastructureSystemsInternal
end

A Discrete Scenario Based time series for a particular data field in a Component.

Arguments

  • name::String: user-defined name
  • resolution::Dates.Period: forecast resolution
  • scenario_count::Int64: Number of scenarios
  • data::Union{SortedDict{Dates.DateTime, Matrix{CONSTANT}}, SortedDict{Dates.DateTime, Matrix{POLYNOMIAL}}, SortedDict{Dates.DateTime, Matrix{PWL}}}: timestamp - scalingfactor
  • scaling_factor_multiplier::Union{Nothing, Function}: Applicable when the time series data are scaling factors. Called on the associated component to convert the values.
  • internal::InfrastructureSystemsInternal
source
InfrastructureSystems.ScenariosMethod
Scenarios(name::AbstractString, input_data::AbstractDict, resolution::Dates.Period; normalization_factor, scaling_factor_multiplier) -> InfrastructureSystems.Scenarios

Construct Scenarios from a SortedDict of Arrays.

Arguments

  • name::AbstractString: user-defined name
  • input_data::AbstractDict{Dates.DateTime, Matrix{Float64}}: time series data.
  • resolution::Dates.Period: The resolution of the forecast in Dates.Period`
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
source
InfrastructureSystems.ScenariosMethod
Scenarios(name::AbstractString, input_data::AbstractDict{Dates.DateTime,#s94} where #s94<:TimeSeries.TimeArray; normalization_factor, scaling_factor_multiplier) -> InfrastructureSystems.Scenarios

Construct Scenarios from a Dict of TimeArrays.

Arguments

  • name::AbstractString: user-defined name
  • input_data::AbstractDict{Dates.DateTime, TimeSeries.TimeArray}: time series data.
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
  • timestamp = :timestamp: If the values are DataFrames is passed then this must be the column name that contains timestamps.
source
InfrastructureSystems.ScenariosMetadataType
mutable struct ScenariosMetadata <: ForecastMetadata
    name::String
    resolution::Dates.Period
    initial_timestamp::Dates.DateTime
    interval::Dates.Period
    scenario_count::Int64
    count::Int
    time_series_uuid::UUIDs.UUID
    horizon::Int
    scaling_factor_multiplier::Union{Nothing, Function}
    internal::InfrastructureSystemsInternal
end

A Discrete Scenario Based time series for a particular data field in a Component.

Arguments

  • name::String: user-defined name
  • resolution::Dates.Period
  • initial_timestamp::Dates.DateTime: time series availability time
  • interval::Dates.Period: time step between forecast windows
  • scenario_count::Int64: Number of scenarios
  • count::Int: number of forecast windows
  • time_series_uuid::UUIDs.UUID: reference to time series data
  • horizon::Int: length of this time series
  • scaling_factor_multiplier::Union{Nothing, Function}: Applicable when the time series data are scaling factors. Called on the associated component to convert the values.
  • internal::InfrastructureSystemsInternal
source
InfrastructureSystems.SingleTimeSeriesType
mutable struct SingleTimeSeries <: StaticTimeSeries
    name::String
    data::TimeSeries.TimeArray
    scaling_factor_multiplier::Union{Nothing, Function}
    internal::InfrastructureSystemsInternal
end

A deterministic forecast for a particular data field in a Component.

Arguments

  • name::String: user-defined name
  • data::TimeSeries.TimeArray: timestamp - scalingfactor
  • scaling_factor_multiplier::Union{Nothing, Function}: Applicable when the time series data are scaling factors. Called on the associated component to convert the values.
  • internal::InfrastructureSystemsInternal
source
InfrastructureSystems.SingleTimeSeriesMethod
SingleTimeSeries(name::AbstractString, filename::AbstractString, component::InfrastructureSystems.InfrastructureSystemsComponent, resolution::Dates.Period; normalization_factor, scaling_factor_multiplier) -> InfrastructureSystems.SingleTimeSeries

Construct SingleTimeSeries from a CSV file. The file must have a column that is the name of the component.

Arguments

  • name::AbstractString: user-defined name
  • filename::AbstractString: name of CSV file containing data
  • component::InfrastructureSystemsComponent: component associated with the data
  • resolution::Dates.Period: resolution of the time series
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
source
InfrastructureSystems.SingleTimeSeriesMethod
SingleTimeSeries(name::AbstractString, data::Union{DataFrames.DataFrame, TimeSeries.TimeArray}; normalization_factor, scaling_factor_multiplier, timestamp) -> InfrastructureSystems.SingleTimeSeries

Construct SingleTimeSeries from a TimeArray or DataFrame.

Arguments

  • name::AbstractString: user-defined name
  • data::Union{TimeSeries.TimeArray, DataFrames.DataFrame}: time series data
  • normalization_factor::NormalizationFactor = 1.0: optional normalization factor to apply to each data entry
  • scaling_factor_multiplier::Union{Nothing, Function} = nothing: If the data are scaling factors then this function will be called on the component and applied to the data when get_time_series_array is called.
  • timestamp = :timestamp: If a DataFrame is passed then this must be the column name that contains timestamps.
source
InfrastructureSystems.SingleTimeSeriesMethod
SingleTimeSeries(time_series::InfrastructureSystems.SingleTimeSeries, data::TimeSeries.TimeArray) -> Any

Creates a new SingleTimeSeries from an existing instance and a subset of data.

source
InfrastructureSystems.SingleTimeSeriesMethod
SingleTimeSeries(name::String, resolution::Dates.Period, initial_time::Dates.DateTime, time_steps::Int64) -> InfrastructureSystems.SingleTimeSeries

Construct SingleTimeSeries after constructing a TimeArray from initial_time and time_steps.

source
InfrastructureSystems.SingleTimeSeriesMetadataType
mutable struct SingleTimeSeriesMetadata <: StaticTimeSeriesMetadata
    name::String
    resolution::Dates.Period
    initial_timestamp::Dates.DateTime
    time_series_uuid::UUIDs.UUID
    length::Int
    scaling_factor_multiplier::Union{Nothing, Function}
    internal::InfrastructureSystemsInternal
end

A TimeSeries Data object in contigous form.

Arguments

  • name::String: user-defined name
  • resolution::Dates.Period
  • initial_timestamp::Dates.DateTime: time series availability time
  • time_series_uuid::UUIDs.UUID: reference to time series data
  • length::Int: length of this time series
  • scaling_factor_multiplier::Union{Nothing, Function}: Applicable when the time series data are scaling factors. Called on the associated component to convert the values.
  • internal::InfrastructureSystemsInternal
source
InfrastructureSystems.StaticTimeSeriesCacheMethod
StaticTimeSeriesCache(::Type{T<:InfrastructureSystems.StaticTimeSeries}, component::InfrastructureSystems.InfrastructureSystemsComponent, name::AbstractString; cache_size_bytes, start_time, ignore_scaling_factors) -> InfrastructureSystems.StaticTimeSeriesCache

Construct StaticTimeSeriesCache to automatically control caching of time series data. Maintains rows of data in memory based on cache_size_bytes.

Call Base.iterate or get_time_series_array to retrieve data.

Arguments

  • ::Type{T}: subtype of StaticTimeSeries
  • component::InfrastructureSystemsComponent: component
  • name::AbstractString: time series name
  • cache_size_bytes = TIME_SERIES_CACHE_SIZE_BYTES: maximum size of data to keep in memory
  • ignore_scaling_factors = false: controls whether to ignore scalingfactormultiplier in the time series instance
source
InfrastructureSystems.SystemDataType
mutable struct SystemData <: InfrastructureSystemsType
    components::Components
    time_series_params::TimeSeriesParameters
    validation_descriptors::Vector
    time_series_storage::TimeSeriesStorage
    time_series_storage_file::Union{Nothing, String}
    internal::InfrastructureSystemsInternal
end

Container for system components and time series data

source
InfrastructureSystems.SystemDataMethod
SystemData(; validation_descriptor_file, time_series_in_memory, time_series_directory) -> InfrastructureSystems.SystemData

Construct SystemData to store components and time series data.

Arguments

  • validation_descriptor_file = nothing: Optionally, a file defining component validation descriptors.
  • time_series_in_memory = false: Controls whether time series data is stored in memory or in a file.
  • timeseriesdirectory = nothing`: Controls what directory time series data is stored in. Default is tempdir().
source
InfrastructureSystems.TimeSeriesDataType

Abstract type for time series stored in the system. Components store references to these through TimeSeriesMetadata values so that data can reside on storage media instead of memory.

source
InfrastructureSystems.TimeSeriesStorageType

Abstract type for time series storage implementations.

All subtypes must implement:

  • serializetimeseries!
  • addtimeseries_reference!
  • removetimeseries!
  • deserializetimeseries
  • cleartimeseries!
  • getnumtime_series
  • checkreadonly
source
Base.closeMethod
close(logger::InfrastructureSystems.MultiLogger)

Ensures that any file streams are flushed and closed.

source
Base.flushMethod
flush(logger::InfrastructureSystems.MultiLogger)

Flush any file streams.

source
Base.getMethod
get(container::InfrastructureSystems.LazyDictFromIterator, key::K) -> Any

Returns the item mapped to key. If the key is already stored then it will be returned with a dictionary lookup. If it has not been stored then iterate over the list until it is found.

Returns nothing if key is not found.

source
InfrastructureSystems._remove_item!Method
_remove_item!(path::HDF5.Group, name::AbstractString, value::AbstractString) -> Bool

Removes value from the dataset called name. Returns true if the array is empty afterwards.

source
InfrastructureSystems._validate_componentMethod
_validate_component(data::InfrastructureSystems.SystemData, component::T<:InfrastructureSystems.InfrastructureSystemsComponent)

Checks that the component exists in data and the UUID's match.

source
InfrastructureSystems.add_component!Method
add_component!(components::InfrastructureSystems.Components, component::T<:InfrastructureSystems.InfrastructureSystemsComponent; skip_validation, deserialization_in_progress)

Add a component.

Throws ArgumentError if the component's name is already stored for its concrete type.

Throws InvalidRange if any of the component's field values are outside of defined valid range.

source
InfrastructureSystems.add_time_series!Method
add_time_series!(data::InfrastructureSystems.SystemData, components::Any, time_series::InfrastructureSystems.TimeSeriesData)

Add the same time series data to multiple components.

Arguments

  • data::SystemData: SystemData
  • components: iterable of components that will store the same time series reference
  • time_series::TimeSeriesData: Any object of subtype TimeSeriesData

This is significantly more efficent than calling add_time_series! for each component individually with the same data because in this case, only one time series array is stored.

Throws ArgumentError if a component is not stored in the system.

source
InfrastructureSystems.add_time_series!Method
add_time_series!(data::InfrastructureSystems.SystemData, component::InfrastructureSystems.InfrastructureSystemsComponent, time_series::InfrastructureSystems.TimeSeriesData; skip_if_present)

Add time series data to a component.

Arguments

  • data::SystemData: SystemData
  • component::InfrastructureSystemsComponent: will store the time series reference
  • time_series::TimeSeriesData: Any object of subtype TimeSeriesData

Throws ArgumentError if the component is not stored in the system.

source
InfrastructureSystems.add_time_series_from_file_metadata!Method
add_time_series_from_file_metadata!(data::InfrastructureSystems.SystemData, ::Type{T<:InfrastructureSystems.InfrastructureSystemsComponent}, metadata_file::AbstractString; resolution)

Adds time_series from a metadata file or metadata descriptors.

Arguments

  • data::SystemData: system
  • ::Type{T}: type of the component associated with time series data; may be abstract
  • metadata_file::AbstractString: metadata file for time series that includes an array of TimeSeriesFileMetadata instances or a vector.
  • resolution::DateTime.Period=nothing: skip time_series that don't match this resolution.
source
InfrastructureSystems.add_time_series_from_file_metadata!Method
add_time_series_from_file_metadata!(data::InfrastructureSystems.SystemData, ::Type{T<:InfrastructureSystems.InfrastructureSystemsComponent}, file_metadata::Array{InfrastructureSystems.TimeSeriesFileMetadata,1}; resolution)

Adds time series data from a metadata file or metadata descriptors.

Arguments

  • data::SystemData: system
  • file_metadata::Vector{TimeSeriesFileMetadata}: metadata for time series
  • resolution::DateTime.Period=nothing: skip time_series that don't match this resolution.
source
InfrastructureSystems.check_params_compatibilityMethod
check_params_compatibility(params::InfrastructureSystems.TimeSeriesParameters, other::InfrastructureSystems.TimeSeriesParameters) -> Union{Nothing, Bool}

Return true if params match other or if params is uninitialized.

source
InfrastructureSystems.compare_valuesMethod
compare_values(x::T, y::T) -> Bool

Recursively compares struct values by performing == on each field in the struct. When performing == on values of immutable structs Julia will perform === on each field. This will return false if any field is mutable even if the contents are the same. So, comparison of any InfrastructureSystems type with an array will fail.

This is an unresolved Julia issue. Refer to https://github.com/JuliaLang/julia/issues/4648.

An option is to overload == for all subtypes of PowerSystemType. That may not be appropriate in all cases. Until the Julia developers decide on a solution, this function is provided for convenience for specific comparisons.

source
InfrastructureSystems.configure_loggingMethod
configure_logging(; console, console_stream, console_level, file, filename, file_level, file_mode, tracker, set_global) -> InfrastructureSystems.MultiLogger

Creates console and file loggers per caller specification and returns a MultiLogger.

Note: If logging to a file users must call Base.close() on the returned MultiLogger to ensure that all events get flushed.

Arguments

  • console::Bool=true: create console logger
  • console_stream::IOStream=stderr: stream for console logger
  • console_level::Logging.LogLevel=Logging.Error: level for console messages
  • file::Bool=true: create file logger
  • filename::String=log.txt: log file
  • file_level::Logging.LogLevel=Logging.Info: level for file messages
  • file_mode::String=w+: mode used when opening log file
  • tracker::Union{LogEventTracker, Nothing}=LogEventTracker(): optionally track log events
  • set_global::Bool=true: set the created logger as the global logger

Example

logger = configure_logging(filename="mylog.txt")
source
InfrastructureSystems.copy_time_series!Method
copy_time_series!(dst::InfrastructureSystems.InfrastructureSystemsComponent, src::InfrastructureSystems.InfrastructureSystemsComponent; name_mapping, scaling_factor_multiplier_mapping)

Efficiently add all time_series in one component to another by copying the underlying references.

Arguments

  • dst::InfrastructureSystemsComponent: Destination component
  • src::InfrastructureSystemsComponent: Source component
  • name_mapping::Dict = nothing: Optionally map src names to different dst names. If provided and src has a timeseries with a name not present in namemapping, that timeseries will not copied. If namemapping is nothing then all time_series will be copied with src's names.
  • scaling_factor_multiplier_mapping::Dict = nothing: Optionally map src multipliers to different dst multipliers. If provided and src has a timeseries with a multiplier not present in scalingfactormultipliermapping, that timeseries will not copied. If scalingfactormultipliermapping is nothing then all time_series will be copied with src's multipliers.
source
InfrastructureSystems.deserializeMethod
deserialize(_::Type{T<:InfrastructureSystems.InfrastructureSystemsType}, data::Dict) -> InfrastructureSystems.TestComponent

Deserialize an object from standard types stored in non-Julia formats, such as JSON, into Julia types.

source
InfrastructureSystems.fromMethod
from(time_series::InfrastructureSystems.SingleTimeSeries, timestamp::Any) -> InfrastructureSystems.SingleTimeSeries

Return a time_series truncated starting with timestamp.

source
InfrastructureSystems.from_fileMethod
from_file(::Type{InfrastructureSystems.Hdf5TimeSeriesStorage}, filename::AbstractString; read_only) -> InfrastructureSystems.Hdf5TimeSeriesStorage

Constructs Hdf5TimeSeriesStorage from an existing file.

source
InfrastructureSystems.from_jsonMethod
from_json(_::Type{T<:InfrastructureSystems.InfrastructureSystemsType}, filename::String) -> Any

Deserializes a InfrastructureSystemsType from a JSON filename.

source
InfrastructureSystems.from_jsonMethod
from_json(io::Union{IO, String}, _::Type{T<:InfrastructureSystems.InfrastructureSystemsType}) -> InfrastructureSystems.TestComponent

Deserializes a InfrastructureSystemsType from String or IO.

source
InfrastructureSystems.get_componentMethod

Get the component of type T with name. Returns nothing if no component matches. If T is an abstract type then the names of components across all subtypes of T must be unique.

See get_components_by_name for abstract types with non-unique names across subtypes.

Throws ArgumentError if T is not a concrete type and there is more than one component with requested name

source
InfrastructureSystems.get_componentsMethod
get_components(::Type{T<:InfrastructureSystems.InfrastructureSystemsComponent}, components::InfrastructureSystems.Components) -> InfrastructureSystems.FlattenIteratorWrapper{_A} where _A
get_components(::Type{T<:InfrastructureSystems.InfrastructureSystemsComponent}, components::InfrastructureSystems.Components, filter_func::Union{Nothing, Function}) -> InfrastructureSystems.FlattenIteratorWrapper{_A} where _A

Returns an iterator of components. T can be concrete or abstract. Call collect on the result if an array is desired.

Arguments

  • T: component type
  • components::Components: Components of the sytem
  • filter_func::Union{Nothing, Function} = nothing: Optional function that accepts a component of type T and returns a Bool. Apply this function to each component and only return components where the result is true.

See also: iterate_components

source
InfrastructureSystems.get_dataMethod
get_data(value::InfrastructureSystems.Deterministic) -> Union{DataStructures.SortedDict{Dates.DateTime,Array{Array{Tuple{Float64,Float64},1},1},Ord} where Ord<:Base.Order.Ordering, DataStructures.SortedDict{Dates.DateTime,Array{Float64,1},Ord} where Ord<:Base.Order.Ordering, DataStructures.SortedDict{Dates.DateTime,Array{Tuple{Float64,Float64},1},Ord} where Ord<:Base.Order.Ordering}

Get Deterministic data.

source
InfrastructureSystems.get_dataMethod
get_data(value::InfrastructureSystems.Probabilistic) -> Union{DataStructures.SortedDict{Dates.DateTime,Array{Array{Tuple{Float64,Float64},1},2},Ord} where Ord<:Base.Order.Ordering, DataStructures.SortedDict{Dates.DateTime,Array{Float64,2},Ord} where Ord<:Base.Order.Ordering, DataStructures.SortedDict{Dates.DateTime,Array{Tuple{Float64,Float64},2},Ord} where Ord<:Base.Order.Ordering}

Get Probabilistic data.

source
InfrastructureSystems.get_dataMethod
get_data(value::InfrastructureSystems.Scenarios) -> Union{DataStructures.SortedDict{Dates.DateTime,Array{Array{Tuple{Float64,Float64},1},2},Ord} where Ord<:Base.Order.Ordering, DataStructures.SortedDict{Dates.DateTime,Array{Float64,2},Ord} where Ord<:Base.Order.Ordering, DataStructures.SortedDict{Dates.DateTime,Array{Tuple{Float64,Float64},2},Ord} where Ord<:Base.Order.Ordering}

Get Scenarios data.

source
InfrastructureSystems.get_data_typeMethod
get_data_type(ts::InfrastructureSystems.TimeSeriesData) -> String

Return a String for the data type of the forecast data, this implementation avoids the use of eval on arbitrary code stored in HDF dataset.

source
InfrastructureSystems.get_extMethod
get_ext(obj::InfrastructureSystems.InfrastructureSystemsInternal) -> Union{Nothing, Dict{String,Any}}

Return a user-modifiable dictionary to store extra information.

source
InfrastructureSystems.get_log_eventsMethod
get_log_events(tracker::InfrastructureSystems.LogEventTracker, level::Base.CoreLogging.LogLevel) -> Union{Base.ValueIterator{Dict{Symbol,InfrastructureSystems.LogEvent}}, Array{Any,1}}

Returns an iterable of log events for a level.

source
InfrastructureSystems.get_next_time_series_array!Method
get_next_time_series_array!(cache::InfrastructureSystems.TimeSeriesCache) -> Any

Return the next TimeSeries.TimeArray.

Returns nothing when all data has been read. Call reset! to restart. Call get_next_time to check the start time.

Arguments

  • cache::StaticTimeSeriesCache: cached instance

Reads from storage if the data is not already in cache.

source
InfrastructureSystems.get_num_stepsMethod
get_num_steps(_::Type{T<:InfrastructureSystems.TimeSeriesFileFormat}, file::CSV.File, period::AbstractArray) -> Any

Return the number of steps specified by the period in the file.

source
InfrastructureSystems.get_num_stepsMethod
get_num_steps(_::Type{T<:InfrastructureSystems.TimeSeriesFormatPeriodAsHeader}, file::CSV.File, period::AbstractArray) -> Any

Return the number of steps specified by the period in the file.

source
InfrastructureSystems.get_num_stepsMethod
get_num_steps(_::Type{T<:Union{InfrastructureSystems.TimeSeriesFormatDateTimeAsColumn, InfrastructureSystems.TimeSeriesFormatPeriodAsColumn}}, file::CSV.File, period::AbstractArray) -> Any

Return the number of steps specified by the period in the file.

source
InfrastructureSystems.get_time_seriesMethod

Return a time series corresponding to the given parameters.

Arguments

  • ::Type{T}: Concrete subtype of TimeSeriesData to return
  • component::InfrastructureSystemsComponent: Component containing the time series
  • name::AbstractString: name of time series
  • start_time::Union{Nothing, Dates.DateTime} = nothing: If nothing, use the initial_timestamp of the time series. If T is a subtype of Forecast then start_time must be the first timstamp of a window.
  • len::Union{Nothing, Int} = nothing: Length in the time dimension. If nothing, use the entire length.
  • count::Union{Nothing, Int} = nothing: Only applicable to subtypes of Forecast. Number of forecast windows starting at start_time to return. Defaults to all available.
source
InfrastructureSystems.get_time_series_arrayFunction
get_time_series_array(component::InfrastructureSystems.InfrastructureSystemsComponent, time_series::InfrastructureSystems.StaticTimeSeries) -> Any
get_time_series_array(component::InfrastructureSystems.InfrastructureSystemsComponent, time_series::InfrastructureSystems.StaticTimeSeries, start_time::Union{Nothing, Dates.DateTime}; len, ignore_scaling_factors) -> Any

Return a TimeSeries.TimeArray from a cached StaticTimeSeries instance.

If the data are scaling factors then the stored scalingfactormultiplier will be called on the component and applied to the data unless ignorescalingfactors is true.

See also StaticTimeSeriesCache.

source
InfrastructureSystems.get_time_series_arrayMethod
get_time_series_array(component::InfrastructureSystems.InfrastructureSystemsComponent, forecast::InfrastructureSystems.Forecast, start_time::Dates.DateTime; len, ignore_scaling_factors) -> Any

Return a TimeSeries.TimeArray for one forecast window from a cached Forecast instance.

If the data are scaling factors then the stored scalingfactormultiplier will be called on the component and applied to the data unless ignorescalingfactors is true.

See also ForecastCache.

source
InfrastructureSystems.get_time_series_arrayMethod

Return a TimeSeries.TimeArray from storage for the given time series parameters.

If the data are scaling factors then the stored scalingfactormultiplier will be called on the component and applied to the data unless ignorescalingfactors is true.

source
InfrastructureSystems.get_time_series_containerMethod
get_time_series_container(value::InfrastructureSystems.InfrastructureSystemsComponent) -> InfrastructureSystems.TimeSeriesContainer

Return the internal time_series storage container or nothing, if the type doesn't store time series.

Subtypes need to implement this method if they store time series.

source
InfrastructureSystems.get_time_series_multipleFunction
get_time_series_multiple(data::InfrastructureSystems.SystemData) -> Channel{Any}
get_time_series_multiple(data::InfrastructureSystems.SystemData, filter_func::Any; type, name) -> Channel{Any}

Returns an iterator of TimeSeriesData instances attached to the system.

Note that passing a filter function can be much slower than the other filtering parameters because it reads time series data from media.

Call collect on the result to get an array.

Arguments

  • data::SystemData: system
  • filter_func = nothing: Only return time_series for which this returns true.
  • type = nothing: Only return time_series with this type.
  • name = nothing: Only return time_series matching this value.
source
InfrastructureSystems.get_time_series_multipleFunction
get_time_series_multiple(component::InfrastructureSystems.InfrastructureSystemsComponent) -> Channel{Any}
get_time_series_multiple(component::InfrastructureSystems.InfrastructureSystemsComponent, filter_func::Any; type, start_time, name) -> Channel{Any}

Returns an iterator of TimeSeriesData instances attached to the component.

Note that passing a filter function can be much slower than the other filtering parameters because it reads time series data from media.

Call collect on the result to get an array.

Arguments

  • component::InfrastructureSystemsComponent: component from which to get time_series
  • filter_func = nothing: Only return time_series for which this returns true.
  • type = nothing: Only return time_series with this type.
  • name = nothing: Only return time_series matching this value.
source
InfrastructureSystems.get_time_series_multipleMethod
get_time_series_multiple(_::Type{InfrastructureSystems.TimeSeriesMetadata}, component::InfrastructureSystems.InfrastructureSystemsComponent) -> Channel{Any}

Returns an iterator of TimeSeriesMetadata instances attached to the component.

source
InfrastructureSystems.get_time_series_timestampsFunction
get_time_series_timestamps(component::InfrastructureSystems.InfrastructureSystemsComponent, forecast::InfrastructureSystems.Forecast)
get_time_series_timestamps(component::InfrastructureSystems.InfrastructureSystemsComponent, forecast::InfrastructureSystems.Forecast, start_time::Union{Nothing, Dates.DateTime}; len) -> Array{D,1} where D<:Dates.TimeType

Return a vector of timestamps from a cached Forecast instance.

source
InfrastructureSystems.get_time_series_timestampsFunction
get_time_series_timestamps(component::InfrastructureSystems.InfrastructureSystemsComponent, time_series::InfrastructureSystems.StaticTimeSeries) -> Array{D,1} where D<:Dates.TimeType
get_time_series_timestamps(component::InfrastructureSystems.InfrastructureSystemsComponent, time_series::InfrastructureSystems.StaticTimeSeries, start_time::Union{Nothing, Dates.DateTime}; len) -> Array{D,1} where D<:Dates.TimeType

Return a vector of timestamps from a cached StaticTimeSeries instance.

source
InfrastructureSystems.get_time_series_valuesFunction
get_time_series_values(component::InfrastructureSystems.InfrastructureSystemsComponent, time_series::InfrastructureSystems.StaticTimeSeries) -> Any
get_time_series_values(component::InfrastructureSystems.InfrastructureSystemsComponent, time_series::InfrastructureSystems.StaticTimeSeries, start_time::Union{Nothing, Dates.DateTime}; len, ignore_scaling_factors) -> Any

Return an Array of values from a cached StaticTimeSeries instance for the requested time series parameters.

source
InfrastructureSystems.get_time_series_valuesMethod
get_time_series_values(component::InfrastructureSystems.InfrastructureSystemsComponent, forecast::InfrastructureSystems.Forecast, start_time::Dates.DateTime; len, ignore_scaling_factors) -> Any

Return an Array of values for one forecast window from a cached Forecast instance.

source
InfrastructureSystems.get_time_series_valuesMethod
get_time_series_values(::Type{T<:InfrastructureSystems.TimeSeriesData}, component::InfrastructureSystems.InfrastructureSystemsComponent, name::AbstractString; start_time, len, ignore_scaling_factors) -> Any

Return an Array of values from storage for the requested time series parameters.

If the data size is small and this will be called many times, consider using the version that accepts a cached TimeSeriesData instance.

source
InfrastructureSystems.get_timestampMethod
get_timestamp(_::Type{InfrastructureSystems.TimeSeriesFormatYMDPeriodAsColumn}, file::CSV.File, row_index::Int64) -> Any

Return a Dates.DateTime for the row in the CSV file.

source
InfrastructureSystems.get_unique_timestampsMethod
get_unique_timestamps(_::Type{T<:InfrastructureSystems.TimeSeriesFileFormat}, file::CSV.File) -> Array{Dict{String,Any},1}

Return a vector of dicts of unique timestamps and their counts.

source
InfrastructureSystems.headMethod
head(time_series::InfrastructureSystems.SingleTimeSeries) -> Any

Return a time_series with only the first num values.

source
InfrastructureSystems.increment_countMethod
increment_count(tracker::InfrastructureSystems.LogEventTracker, event::InfrastructureSystems.LogEvent, suppressed::Bool) -> Union{Nothing, Int64, InfrastructureSystems.LogEvent}

Increments the count of a log event.

source
InfrastructureSystems.list_recorder_eventsMethod

Return the events of type T in filename.

Arguments

  • T: event type
  • filename::AbstractString: filename containing recorder events
  • filter_func::Union{Nothing, Function} = nothing: Optional function that accepts an event of type T and returns a Bool. Apply this function to each event and only return events where the result is true.
source
InfrastructureSystems.make_time_series!Method
make_time_series!(cache::InfrastructureSystems.TimeSeriesParsingCache, ts_file_metadata::InfrastructureSystems.TimeSeriesFileMetadata) -> Any

Return a time series from TimeSeriesFileMetadata.

Arguments

  • cache::TimeSeriesParsingCache: cached data
  • ts_file_metadata::TimeSeriesFileMetadata: metadata
  • resolution::{Nothing, Dates.Period}: skip any time_series that don't match this resolution
source
InfrastructureSystems.open_file_loggerFunction
open_file_logger(func::Function, filename::String) -> Any
open_file_logger(func::Function, filename::String, level::Any) -> Any
open_file_logger(func::Function, filename::String, level::Any, mode::Any) -> Any

Opens a file logger using Logging.SimpleLogger.

Example

open_file_logger("log.txt", Logging.Info) do logger
    global_logger(logger)
    @info "hello world"
end
source
InfrastructureSystems.prepare_for_serialization!Method
prepare_for_serialization!(data::InfrastructureSystems.SystemData, filename::AbstractString; force) -> String

Parent object should call this prior to serialization so that SystemData can store the appropriate path information for the time series data.

source
InfrastructureSystems.read_time_seriesMethod
read_time_series(::Type{T<:InfrastructureSystems.TimeSeriesData}, data_file::AbstractString) -> InfrastructureSystems.RawTimeSeries
read_time_series(::Type{T<:InfrastructureSystems.TimeSeriesData}, data_file::AbstractString, component_name::Any; kwargs...) -> InfrastructureSystems.RawTimeSeries

Return a TimeArray from a CSV file.

Pass component_name when the file does not have the component name in a column header.

source
InfrastructureSystems.read_time_seriesMethod
read_time_series(::Type{T<:InfrastructureSystems.TimeSeriesFormatComponentsAsColumnsNoTime}, ::Type{#s24} where #s24<:InfrastructureSystems.StaticTimeSeries, file::CSV.File) -> InfrastructureSystems.RawTimeSeries
read_time_series(::Type{T<:InfrastructureSystems.TimeSeriesFormatComponentsAsColumnsNoTime}, ::Type{#s23} where #s23<:InfrastructureSystems.StaticTimeSeries, file::CSV.File, component_name::Any; kwargs...) -> InfrastructureSystems.RawTimeSeries

This version of the function only has component_name to match the interface. It is unused.

Set start_datetime as a keyword argument for the starting timestamp, otherwise the current day is used.

source
InfrastructureSystems.read_time_seriesMethod
read_time_series(::Type{T<:Union{InfrastructureSystems.TimeSeriesFormatDateTimeAsColumn, InfrastructureSystems.TimeSeriesFormatPeriodAsColumn}}, ::Type{#s24} where #s24<:InfrastructureSystems.StaticTimeSeries, file::CSV.File) -> InfrastructureSystems.RawTimeSeries
read_time_series(::Type{T<:Union{InfrastructureSystems.TimeSeriesFormatDateTimeAsColumn, InfrastructureSystems.TimeSeriesFormatPeriodAsColumn}}, ::Type{#s23} where #s23<:InfrastructureSystems.StaticTimeSeries, file::CSV.File, component_name::Any; kwargs...) -> InfrastructureSystems.RawTimeSeries

Return a TimeSeries.TimeArray representing the CSV file.

This version of the function only has component_name to match the interface. It is unused.

source
InfrastructureSystems.read_time_seriesMethod
read_time_series(::Type{T<:InfrastructureSystems.TimeSeriesFormatPeriodAsHeader}, ::Type{#s92} where #s92<:InfrastructureSystems.StaticTimeSeries, file::CSV.File, component_name::AbstractString; kwargs...) -> InfrastructureSystems.RawTimeSeries

This version of the function supports the format where there is no column header for a component, so the component_name must be passed in.

source
InfrastructureSystems.read_time_seriesMethod
read_time_series(::Type{T<:InfrastructureSystems.TimeSeriesFormatDateTimeAsColumn}, ::Type{InfrastructureSystems.Deterministic}, file::CSV.File) -> InfrastructureSystems.RawTimeSeries
read_time_series(::Type{T<:InfrastructureSystems.TimeSeriesFormatDateTimeAsColumn}, ::Type{InfrastructureSystems.Deterministic}, file::CSV.File, component_name::Any; kwargs...) -> InfrastructureSystems.RawTimeSeries

Return a RawTimeSeries from a CSV file.

Pass component_name when the file does not have the component name in a column header.

source
InfrastructureSystems.register_recorder!Method
register_recorder!(name::Symbol; io, mode, directory)

Register a recorder to log events. Afterwards, calls to @record name <event-type>() will record the event as JSON in <name>.log.

Callers should guarantee that unregister_recorder! is called to close the file handle.

Arguments

  • name::Symbol: name of recorder
  • io::Union{Nothing, IO}: If nothing, record events in a file using name.
  • mode = "w": Only used when io is nothing.
  • directory = ".": Only used when io is nothing.
source
InfrastructureSystems.remove_component!Method
remove_component!(_::Type{T<:InfrastructureSystems.InfrastructureSystemsComponent}, components::InfrastructureSystems.Components, name::AbstractString) -> InfrastructureSystems.InfrastructureSystemsComponent

Remove a component by its name.

Throws ArgumentError if the component is not stored.

source
InfrastructureSystems.remove_components!Method
remove_components!(_::Type{T<:InfrastructureSystems.InfrastructureSystemsComponent}, components::InfrastructureSystems.Components) -> Base.ValueIterator

Remove all components of type T.

Throws ArgumentError if the type is not stored.

source
InfrastructureSystems.remove_time_series!Method
remove_time_series!(data::InfrastructureSystems.SystemData, _::Type{T<:InfrastructureSystems.TimeSeriesData}, component::InfrastructureSystems.InfrastructureSystemsComponent, name::String)

Remove the time series data for a component.

source
InfrastructureSystems.remove_time_series!Method
remove_time_series!(data::InfrastructureSystems.SystemData, _::Type{T<:InfrastructureSystems.TimeSeriesData}) -> Union{Nothing, Int64}

Removes all time series of a particular type from a System.

Arguments

  • data::SystemData: system
  • type::Type{<:TimeSeriesData}: Type of time series objects to remove.
source
InfrastructureSystems.remove_time_series_metadata!Method
remove_time_series_metadata!(component::InfrastructureSystems.InfrastructureSystemsComponent, _::Type{T<:InfrastructureSystems.TimeSeriesMetadata}, name::AbstractString) -> Bool

Removes the metadata for a time_series. If this returns true then the caller must also remove the actual time series data.

source
InfrastructureSystems.serializeMethod

Serialize the Julia value into standard types that can be converted to non-Julia formats, such as JSON. In cases where val is an instance of a struct, return a Dict. In cases where val is a scalar value, return that value.

source
InfrastructureSystems.set_component!Method
set_component!(metadata::InfrastructureSystems.TimeSeriesFileMetadata, data::InfrastructureSystems.SystemData, mod::Module) -> Any

Set the component value in metadata by looking up the category in module. This requires that category be a string version of a component's abstract type. Modules can override for custom behavior.

source
InfrastructureSystems.show_recorder_eventsMethod
show_recorder_events(::Type{T<:InfrastructureSystems.AbstractRecorderEvent}, filename::AbstractString)
show_recorder_events(::Type{T<:InfrastructureSystems.AbstractRecorderEvent}, filename::AbstractString, filter_func::Union{Nothing, Function}; kwargs...)

Show the events of type T in filename in a table. Refer to PrettyTables.jl documentation for accepted kwargs.

Arguments

  • T: event type
  • filename::AbstractString: filename containing recorder events
  • filter_func::Union{Nothing, Function} = nothing: Optional function that accepts an event of type T and returns a Bool. Apply this function to each event and only return events where the result is true.
  • kwargs: Passed to PrettyTables

Examples

show_recorder_events(TestEvent, test_recorder.log)
show_recorder_events(TestEvent, test_recorder.log; x -> x.val2 > 2)
source
InfrastructureSystems.tailMethod
tail(time_series::InfrastructureSystems.SingleTimeSeries) -> Any

Return a time_series with only the ending num values.

source
InfrastructureSystems.toMethod
to(time_series::InfrastructureSystems.SingleTimeSeries, timestamp::Any) -> InfrastructureSystems.SingleTimeSeries

Return a time_series truncated after timestamp.

source
InfrastructureSystems.to_jsonMethod
to_json(obj::T<:InfrastructureSystems.InfrastructureSystemsType) -> String

Serializes a InfrastructureSystemsType to a JSON file.

source
InfrastructureSystems.transform_single_time_series!Method
transform_single_time_series!(data::InfrastructureSystems.SystemData, _::Type{T<:InfrastructureSystems.DeterministicSingleTimeSeries}, horizon::Int64, interval::Dates.Period)

Transform all instances of SingleTimeSeries to DeterministicSingleTimeSeries.

Any existing DeterministicSingleTimeSeries forecasts will be deleted even if the inputs are invalid.

source
InfrastructureSystems.transform_single_time_series_internal!Method
transform_single_time_series_internal!(component::InfrastructureSystems.InfrastructureSystemsComponent, _::Type{T<:InfrastructureSystems.DeterministicSingleTimeSeries}, params::InfrastructureSystems.TimeSeriesParameters) -> Bool

Transform all instances of SingleTimeSeries to DeterministicSingleTimeSeries. Do nothing if the component does not contain any instances.

All required checks must have been completed by the caller.

Return true if a transformation occurs.

source
InfrastructureSystems.validate_componentsMethod
validate_components(components::InfrastructureSystems.Components)

Iterates over all components and throws InvalidRange if any of the component's field values are outside of defined valid range.

source
InfrastructureSystems.whenMethod
when(time_series::InfrastructureSystems.SingleTimeSeries, period::Function, t::Integer) -> Any

Refer to TimeSeries.when(). Underlying data is copied.

source
InfrastructureSystems.@assert_opMacro

Throw an AssertionError if conditions like op(exp1, exp2) are false, where op is a conditional infix operator.

Examples

julia> a = 3; b = 4;
julia> @assert_op a == b
ERROR: AssertionError: 3 == 4

julia> @assert_op a + 3 > b + 4
ERROR: AssertionError: 6 > 8
source
InfrastructureSystems.@recordMacro

Record an event if the recorder with name is enabled.

Arguments

  • name::Symbol: name of recorder
  • event::AbstractRecorderEvent: event to record

Examples

@record simulation TestEvent("start", 1, 2.0)
source
InfrastructureSystems.@scoped_enumMacro

Macro to wrap Enum in a baremodule to keep the top level scope clean. The macro name should be singular. The macro will create a module for access that is plural.

Examples

@scoped_enum Fruit begin
    APPLE
    ORANGE
end

value = Fruits.APPLE

# Usage as a function parameter
foo(value::Fruits.Fruit) = nothing
source