Library

Library

Documentation for SpineInterface.jl.

Contents

Index

Types

Missing docstring.

Missing docstring for ObjectLike. Check Documenter's build log for details.

Object

A type for representing an object in a Spine db.

TimeSlice

A type for representing a slice of time.

Anything

A type with no fields that is the type of anything.

Functions

using_spinedb(db_url::String, mod=@__MODULE__; upgrade=false)

Extend module mod with convenience functions to access the contents of the Spine db at the given RFC-1738 url. If upgrade is true, then the database is upgraded to the latest revision.

See ObjectClass(), RelationshipClass(), and Parameter() for details on how to call the convenience functors.

(<oc>::ObjectClass)(;<keyword arguments>)

An Array of Object instances corresponding to the objects in class oc.

Arguments

For each parameter associated to oc in the database there is a keyword argument named after it. The purpose is to filter the result by specific values of that parameter.

Examples

julia> using SpineInterface;

julia> url = "sqlite:///" * joinpath(dirname(pathof(SpineInterface)), "..", "examples/data/example.sqlite");

julia> using_spinedb(url)

julia> sort(node())
5-element Array{Object,1}:
 Dublin
 Espoo
 Leuven
 Nimes
 Sthlm

julia> commodity(state_of_matter=:gas)
1-element Array{Object,1}:
 wind
(<rc>::RelationshipClass)(;<keyword arguments>)

An Array of Object tuples corresponding to the relationships of class rc.

Arguments

  • For each object class in rc there is a keyword argument named after it. The purpose is to filter the result by an object or list of objects of that class, or to accept all objects of that class by specifying anything for this argument.
  • _compact::Bool=true: whether or not filtered object classes should be removed from the resulting tuples.
  • _default=[]: the default value to return in case no relationship passes the filter.

Examples

julia> using SpineInterface;

julia> url = "sqlite:///" * joinpath(dirname(pathof(SpineInterface)), "..", "examples/data/example.sqlite");

julia> using_spinedb(url)

julia> sort(node__commodity())
5-element Array{NamedTuple,1}:
 (node = Dublin, commodity = wind)
 (node = Espoo, commodity = wind)
 (node = Leuven, commodity = wind)
 (node = Nimes, commodity = water)
 (node = Sthlm, commodity = water)

julia> node__commodity(commodity=:water)
2-element Array{Object,1}:
 Nimes
 Sthlm

julia> node__commodity(node=(:Dublin, :Espoo))
1-element Array{Object,1}:
 wind

julia> sort(node__commodity(node=anything))
2-element Array{Object,1}:
 water
 wind

julia> sort(node__commodity(commodity=:water, _compact=false))
2-element Array{NamedTuple,1}:
 (node = Nimes, commodity = water)
 (node = Sthlm, commodity = water)

julia> node__commodity(commodity=:gas, _default=:nogas)
:nogas
(<p>::Parameter)(;<keyword arguments>)

The value of parameter p for a given object or relationship.

Arguments

  • For each object class associated with p there is a keyword argument named after it. The purpose is to retrieve the value of p for a specific object.
  • For each relationship class associated with p, there is a keyword argument named after each of the object classes involved in it. The purpose is to retrieve the value of p for a specific relationship.
  • i::Int64: a specific index to retrieve in case of an array value (ignored otherwise).
  • t::TimeSlice: a specific time-index to retrieve in case of a time-varying value (ignored otherwise).
  • inds: indexes for navigating a Map (ignored otherwise). Tuples correspond to navigating nested Maps.
  • _strict::Bool: whether to raise an error or return nothing if the parameter is not specified for the given arguments.

Examples

julia> using SpineInterface;

julia> url = "sqlite:///" * joinpath(dirname(pathof(SpineInterface)), "..", "examples/data/example.sqlite");

julia> using_spinedb(url)

julia> tax_net_flow(node=:Sthlm, commodity=:water)
4

julia> demand(node=:Sthlm, i=1)
21
indices(p::Parameter; kwargs...)

An iterator over all objects and relationships where the value of p is different than nothing.

Arguments

  • For each object class where p is defined, there is a keyword argument named after it; similarly, for each relationship class where p is defined, there is a keyword argument named after each object class in it. The purpose of these arguments is to filter the result by an object or list of objects of an specific class, or to accept all objects of that class by specifying anything for the corresponding argument.

Examples

julia> using SpineInterface;

julia> url = "sqlite:///" * joinpath(dirname(pathof(SpineInterface)), "..", "examples/data/example.sqlite");

julia> using_spinedb(url)

julia> collect(indices(tax_net_flow))
1-element Array{NamedTuple{(:commodity, :node),Tuple{Object,Object}},1}:
 (commodity = water, node = Sthlm)

julia> collect(indices(demand))
5-element Array{Object,1}:
 Nimes
 Sthlm
 Leuven
 Espoo
 Dublin
TimeSlice(start::DateTime, end_::DateTime)

Construct a TimeSlice with bounds given by start and end_.

duration(t::TimeSlice)

The duration of time slice t.

before(a::TimeSlice, b::TimeSlice)

Determine whether the end point of a is exactly the start point of b.

iscontained(b, a)

Determine whether b is contained in a.

overlaps(a::TimeSlice, b::TimeSlice)

Determine whether a and b overlap.

overlap_duration(a::TimeSlice, b::TimeSlice)

The duration of the period where a and b overlap.

t_lowest_resolution(t_iter)

Return an Array containing only time slices from t_iter that aren't contained in any other.

t_highest_resolution(t_iter)

Return an Array containing only time slices from t_iter that do not contain any other.

Missing docstring.

Missing docstring for write_parameters(::Any, ::String). Check Documenter's build log for details.

Constants

anything

The singleton instance of type Anything, used to specify all-pass filters in calls to RelationshipClass().