Manual
The PSRClassesInterface module provides interfaces to access data structured by PSR to be used in its models. Currently there are two main interfaces.
- The interface for studies. This interface is designed to read parameters from the files, some examples are deficit costs, fuel costs, currency, storage capacity etc.
- The interface for reading and writing time series data. Time series data in the context of most studies have 4 dimensions (agents, stages, scenarios and blocks). Since studies of renewables with multiple agents, scenarios and stages can get quite big, we have designed different formats that are optimized to some objective (human readability, size, fast reading and writing, etc.).
Both interfaces are defined as a set of methods that need to be implemented to make a different file format work. In this manual we will describe the abstract methods and give concrete examples of code to perform the work needed.
When using the PSRClassesInterface package in your codebase we strongly advise you to create a constant PSRI
to keep the code concise and explicitly declare that a certain function came from PSRClassesInterface. This can be done by adding the following code to the top of the code
using PSRClassesInterface
const PSRI = PSRClassesInterface
Initialize Study
PSRClassesInterface.AbstractData
— TypeAbstractData
PSRClassesInterface.AbstractStudyInterface
— TypeAbstractStudyInterface
PSRClassesInterface.load_study
— Functionload_study(::AbstractStudyInterface; kwargs...)
Initialize all data structures of the study.
Each study interface has its own set of kwargs...
The easiest way to inspect the current available options is searching for this function on the Github repo of the desired interface.
Example:
data = PSRI.load_study(
PSRI.OpenInterface();
data_path = PATH_CASE_EXAMPLE_BATTERIES,
)
PSRClassesInterface.description
— Functiondescription(data::AbstractData)
Returns the study description if available.
PSRClassesInterface.max_elements
— Functionmax_elements(data::AbstractData, collection::String)
Returns an Int32
with the maximum number of elements for a given collection
.
Example:
PSRI.max_elements(data, "PSRThermalPlant")
Study dimensions
PSRClassesInterface.StageType
— TypePSRI.StageType
Possible stage types used in for reading and writing time series files.
The current possible stage types are:
STAGE_UNKNOWN
STAGE_WEEK
STAGE_MONTH
STAGE_3MONTHS
STAGE_HOUR
STAGE_DAY
STAGE_13MONTHS
STAGE_2MONTHS
STAGE_4MONTHS
STAGE_6MONTHS
STAGE_YEAR
STAGE_DECADE
PSRClassesInterface.total_stages
— Functiontotal_stages(data::AbstractData)
Returns the total number of stages of the case.
Example:
PSRI.total_stages(data)
PSRClassesInterface.total_scenarios
— Functiontotal_scenarios(data::AbstractData)
Returns the total number of scenarios of the case.
Example:
PSRI.total_scenarios(data)
PSRClassesInterface.total_blocks
— Functiontotal_blocks(data::AbstractData)
Returns the total number of blocks of the case.
Example:
PSRI.total_blocks(data)
PSRClassesInterface.total_openings
— Functiontotal_openings(data::AbstractData)
Returns the total number of openings of the case.
Example:
PSRI.total_openings(data)
PSRClassesInterface.total_stages_per_year
— Functiontotal_stages_per_year(data::AbstractData)
Returns the total number of stages per year of the case.
Example:
PSRI.total_stages_per_year(data)
Study duration and blocking
PSRClassesInterface.BlockDurationMode
PSRClassesInterface.stage_duration
PSRClassesInterface.block_duration
PSRClassesInterface.block_from_stage_hour
Read Scalar Attributes
PSRClassesInterface.configuration_parameter
— Functionconfiguration_parameter(
data::AbstractData,
attribute::String,
default::T
) where T <: MainTypes
Returns the required configuration parameter from the case. If the parameter is not registered returns the default value.
configuration_parameter(
data::AbstractData,
attribute::String,
default::Vector{T},
) where T <: MainTypes
Returns the rquired configuration parameters from the case that are vectors that are vectors. If the parameter is not registered returns the default value.
Examples:
PSRI.configuration_parameter(data, "MaximoIteracoes", 0)
PSRI.configuration_parameter(data, "MinOutflowPenalty", 0.0)
PSRI.configuration_parameter(data, "DeficitCost", [0.0])
PSRClassesInterface.get_code
— Functionget_code(data::AbstractData, collection::String)
Returns a Vector{Int32}
containing the code of each element in collection
.
Example:
PSRI.get_code(data, "PSRThermalPlant")
PSRClassesInterface.get_name
— Functionget_name(data::AbstractData, collection::String)
Returns a Vector{String}
containing the name of each element in collection
.
Example:
PSRI.get_name(data, "PSRThermalPlant")
PSRI.get_name(data, "PSRGaugingStation")
PSRClassesInterface.get_parm
— Functionget_parm(
data::AbstractData,
collection::String,
attribute::String,
index::Integer,
::Type{T};
default::T = _default_value(T),
) where T
Returns a T
containing the the value from attribute
of collection
. This function is used to get data from collections that don't vary over time.
Example:
PSRI.get_parm(data, "PSRBattery", "Einic", Float64, 1)
PSRI.get_parm(data, "PSRBattery", "ChargeRamp", Float64, 1)
PSRI.get_parm(data, "PSRBattery", "DischargeRamp", Float64, 1)
PSRClassesInterface.get_parm_1d
— Functionget_parm_1d(
data::AbstractData,
collection::String,
attribute::String,
index::Integer,
::Type{T};
default::T = _default_value(T),
) where T
Returns a T
containing the the value from attribute
of collection
. This function is used to get data from collections that don't vary over time.
Example:
PSRI.get_parm_1d(data, "PSRHydroPlant", "FP", Float64, 1)
PSRI.get_parm_1d(data, "PSRHydroPlant", "FP.VOL", Float64, 1)
PSRClassesInterface.get_parms
— Functionget_parms(
data::AbstractData,
collection::String,
attribute::String,
::Type{T};
validate::Bool = true,
ignore::Bool = false,
default::T = _default_value(T),
) where T
Returns a Vector{T}
containing the elements in collection
to a vector in julia. This function is used to get data from collections that don't vary over time
Example:
PSRI.get_parms(data, "PSRBattery", "Einic", Float64)
PSRI.get_parms(data, "PSRBattery", "ChargeRamp", Float64)
PSRI.get_parms(data, "PSRBattery", "DischargeRamp", Float64)
PSRClassesInterface.get_parms_1d
— Functionget_parms_1d(
data::AbstractData,
collection::String,
attribute::String,
::Type{T};
validate::Bool = true,
ignore::Bool = false,
default::T = _default_value(T),
) where T
Returns a Vector{T}
containing the elements in collection
to a vector in julia. This function is used to get data from collections that don't vary over time
Example:
PSRI.get_parm_1d(data, "PSRHydroPlant", "FP", Float64)
PSRI.get_parm_1d(data, "PSRHydroPlant", "FP.VOL", Float64)
Read Vector Attributes
Time controller
PSRClassesInterface.mapped_vector
— Functionmapped_vector(
data::AbstractData,
collection::String,
attribute::String,
::Type{T},
dim1::String="",
dim2::String="";
ignore::Bool=false,
map_key = collection, # reference for PSRMap pointer, if empty use class name
filters = String[], # for calling just within a subset instead of the full call
) where T
Maps a Vector{T}
containing the elements in collection
to a vector in julia. When the function update_vectors!
is called the elements of the vector will be updated to the according elements registered at the current data.time_controller
.
Example:
existing = PSRI.mapped_vector(data, "PSRThermalPlant", "Existing", Int32)
pot_inst = PSRI.mapped_vector(data, "PSRThermalPlant", "PotInst", Float64)
For more information please read the example Reading basic thermal generator parameters
When using mapped_vector
in the OpenInterface
mode the vector will be mapped with the correct values at first hand. When using mapped_vector
in the ClassicInterface
mode you should call update_vectors!
to get the good values for the collection, otherwise you might only get a vector of zeros.
PSRClassesInterface.go_to_stage
— Functiongo_to_stage(data::AbstractData, stage::Integer)
Goes to the stage
in the data
time controller.
PSRClassesInterface.go_to_dimension
— Functiongo_to_dimension(data::AbstractData, name::String, value::Integer)
Moves time controller reference of vectors indexed by dimension name
to the index value
.
Example:
cesp = PSRI.mapped_vector(data, "PSRThermalPlant", "CEsp", Float64, "segment", "block")
PSRI.go_to_stage(data, 1)
PSRI.go_to_dimension(data, "segment", 1)
PSRI.go_to_dimension(data, "block", 1)
PSRClassesInterface.update_vectors!
— Functionupdate_vectors!(data::AbstractData)
Update all mapped vectors according to the time controller inside data
.
update_vectors!(data::AbstractData, filters::Vector{String})
Update filtered classes of mapped vectors according to the time controller inside data
.
Direct access
PSRClassesInterface.get_vector
— FunctionPSRI.get_vector(
data::AbstractData,
collection::String,
attribute::String,
index::Integer,
::Type{T};
default::T = _default_value(T),
) where T
Returns a Vector{T}
of entries of the attribute
of collection
at the element with index index
.
Example:
PSRI.get_vector(data, "PSRGaugingStation", "Vazao", 1, Float64)
PSRI.get_vector(data, "PSRGaugingStation", "Data", 1, Dates.Date)
PSRClassesInterface.get_vector_1d
— FunctionPSRI.get_vector_1d(
data::AbstractData,
collection::String,
attribute::String,
index::Integer,
::Type{T};
default::T = _default_value(T),
) where T
Returns a Vector{Vector{T}}
of entries of the attribute
of collection
at the element with index index
. The outer vector contains one entry per index in dimension 1, while the inner vector is sized according to the main vector index which is tipicaaly time.
Example:
PSRI.get_vector_1d(data, "PSRArea", "Export", 1, Float64)
PSRI.get_vector_1d(data, "PSRLoad", "P", 1, Float64)
PSRClassesInterface.get_vector_2d
— FunctionPSRI.get_vector_2d(
data::AbstractData,
collection::String,
attribute::String,
index::Integer,
::Type{T};
default::T = _default_value(T),
) where T
Returns a Matrix{Vector{T}}
of entries of the attribute
of collection
at the element with index index
. The outer matrix contains one entry per index in dimension 1 and dimension 2, while the inner vector is sized according to the main vector index which is tipicaaly time.
Example:
PSRI.get_vector_2d(data, "PSRThermalPlant", "CEsp", 1, Float64)
PSRI.get_vector_2d(data, "PSRFuelConsumption", "CEsp", 1, Float64)
PSRClassesInterface.get_vectors
— FunctionPSRI.get_vectors(
data::AbstractData,
collection::String,
attribute::String,
::Type{T};
default::T = _default_value(T),
) where T
Returns a Vector{Vector{T}}
of entries of the attribute
of collection
. Each entry of the outer vector corresponding to an element of the collection.
Example:
PSRI.get_vectors(data, "PSRGaugingStation", "Vazao", Float64)
PSRI.get_vectors(data, "PSRGaugingStation", "Data", Dates.Date)
PSRClassesInterface.get_vectors_1d
— FunctionPSRI.get_vectors_1d(
data::AbstractData,
collection::String,
attribute::String,
::Type{T},
) where T
Returns a Vector{Vector{Vector{T}}}
of entries of the attribute
of collection
. Each entry of the outer vector corresponding to an element of the collection. For the containt of the 2 inner vectors see get_vector_1d
.
Example:
PSRI.get_vectors_1d(data, "PSRArea", "Export", Float64)
PSRI.get_vectors_1d(data, "PSRLoad", "P", Float64)
PSRClassesInterface.get_vectors_2d
— FunctionPSRI.get_vectors_2d(
data::AbstractData,
collection::String,
attribute::String,
::Type{T},
) where T
Returns a Vector{Matrix{Vector{T}}}
of entries of the attribute
of collection
. Each entry of the outer vector corresponding to an element of the collection. For the containt of the Matrix{Vector{T}}
see get_vector_2d
.
Example:
PSRI.get_vectors_2d(data, "PSRThermalPlant", "CEsp", Float64)
PSRI.get_vectors_2d(data, "PSRFuelConsumption", "CEsp", Float64)
PSRClassesInterface.get_nonempty_vector
— Functionget_nonempty_vector(
data::AbstractData,
colllection::String,
attribute::String,
)
Returns a vector of booleans with the number of elements of the collection. true
means the vector associated with the given attribute is non-emepty, false
means it is empty.
Example:
PSRI.get_nonempty_vector(data, "PSRThermalPlant", "ChroGerMin")
PSRI.get_nonempty_vector(data, "PSRThermalPlant", "SpinningReserve")
PSRClassesInterface.get_series
— Functionfunction get_series(
data::Data,
collection::String,
indexing_attribute::String,
index::Int,
)
Retrieves a SeriesTable object with all attributes from an element that are indexed by index_attr
.
Example
julia> PSRI.get_series(data, "PSRThermalPlant", "Data", 1)
Dict{String, Vector} with 13 entries:
"GerMin" => [0.0]
"GerMax" => [888.0]
"NGas" => [nothing]
"IH" => [0.0]
"ICP" => [0.0]
"Data" => ["1900-01-01"]
"CoefE" => [1.0]
"PotInst" => [888.0]
"Existing" => [0]
"sfal" => [0]
"NAdF" => [0]
"Unidades" => [1]
"StartUp" => [0.0]
Relations between collections
Missing docstring for PSRClassesInterface.RelationType
. Check Documenter's build log for details.
PSRClassesInterface.is_vector_relation
— Functionis_vector_relation(relation::PSRI.PMD.RelationType)
Returns true is relation
is a vector relation.
PSRClassesInterface.get_references
— Functionget_references(
data::AbstractData,
lst_from::String,
lst_to::String;
relation_type::RelationType = RELATION_1_TO_1, # type of the direct relation
)
Retrurn a Vector{String}
with the references between collections given a certain RelationType
.
PSRClassesInterface.get_vector_references
— Functionget_vector_references(
data::AbstractData,
lst_from::String,
lst_to::String;
relation_type::RelationType = RELATION_1_TO_N, # type of the direct relation
)
Retrurn a Vector{Vector{String}}
with the references between collections given a certain RelationType
.
PSRClassesInterface.get_map
— Functionget_map(
data::AbstractData,
lst_from::String,
lst_to::String;
allow_empty::Bool = true,
relation_type::RelationType = RELATION_1_TO_1, # type of the direct relation
)
Returns a Vector{Int32}
with the map between collections given a certain RelationType
. If the map is a vector [3, 2, 1] it means that the element 1 of lst_from
is related to the element 3 of lst_to
. If the relation does not exist it might return -1 or some garbage value.
Examples:
PSRI.get_map(data, "PSRBattery", "PSRSystem")
PSRI.get_map(data, "PSRMaintenanceData", "PSRThermalPlant")
PSRI.get_map(
data,
"PSRHydroPlant",
"PSRHydroPlant";
relation_type = PSRI.PMD.RELATION_TURBINE_TO,
)
PSRI.get_map(
data,
"PSRHydroPlant",
"PSRHydroPlant";
relation_type = PSRI.PMD.RELATION_SPILL_TO,
)
PSRI.get_map(
data,
"PSRHydroPlant",
"PSRHydroPlant";
relation_type = PSRI.PMD.RELATION_INFILTRATE_TO,
)
PSRI.get_map(
data,
"PSRHydroPlant",
"PSRHydroPlant";
relation_type = PSRI.PMD.RELATION_STORED_ENERGY_DONWSTREAM,
)
PSRClassesInterface.get_vector_map
— Functionget_vector_map(
data::AbstractData,
collection_from::String,
collection_to::String;
relation_type::RelationType = RELATION_1_TO_N,
)
Returns a Vector{Vector{Int32}}
to represent the relation between each element of collection_from
to multiple elements of collection_to
.
Since multiple relations might be available one might need to specify relation_type
.
Example:
PSRI.get_vector_map(data, "PSRInterconnectionSumData", "PSRInterconnection")
PSRI.get_vector_map(data, "PSRReserveGenerationConstraintData", "PSRHydroPlant")
PSRI.get_vector_map(
data,
"PSRReserveGenerationConstraintData",
"PSRThermalPlant";
relation_type = PSRI.PMD.RELATION_BACKED,
)
PSRClassesInterface.get_reverse_map
— Functionget_reverse_map(
data::AbstractData,
lst_from::String,
lst_to::String;
original_relation_type::RelationType = RELATION_1_TO_1,
)
Obtains the relation between lst_from
and lst_to
though original_relation_type
. But returns a Vector{Int32}
with the relation reversed. Some relations cannot be reversed this way since they are not bijections, in this case use get_reverse_vector_map
.
See also get_map
, get_vector_map
, get_reverse_vector_map
.
Example:
PSRI.get_reverse_map(data, "PSRMaintenanceData", "PSRHydroPlant")
# which is te reverse of
PSRI.get_map(data, "PSRMaintenanceData", "PSRHydroPlant")
PSRI.get_reverse_map(data, "PSRGenerator", "PSRThermalPlant")
# which is the reverse of
PSRI.get_map(data, "PSRGenerator", "PSRThermalPlant")
PSRClassesInterface.get_reverse_vector_map
— Functionget_reverse_vector_map(
data::AbstractData,
lst_from::String,
lst_to::String;
original_relation_type::RelationType = RELATION_1_TO_N,
)
Obtains the relation between lst_from
and lst_to
though original_relation_type
. But returns a Vector{Vector{Int32}}
with the relation reversed.
Some relations are bijections, in these cases it is also possible to use use get_reverse_map
.
See also get_map
, get_vector_map
, get_reverse_vector_map
.
Example:
# upstream turbining hydros
PSRI.get_reverse_vector_map(
data,
"PSRHydroPlant",
"PSRHydroPlant";
original_relation_type = PSRI.PMD.RELATION_TURBINE_TO,
)
# which is the reverse of
PSRI.get_map(
data,
"PSRHydroPlant",
"PSRHydroPlant";
relation_type = PSRI.PMD.RELATION_TURBINE_TO,
)
PSRI.get_reverse_vector_map(
data,
"PSRGenerator",
"PSRBus";
original_relation_type = PSRI.PMD.RELATION_1_TO_1,
)
# which is the reverse of
PSRI.get_map(data, "PSRGenerator", "PSRBus")
PSRClassesInterface.get_related
— Functionget_related(
data::AbstractData,
source::String,
target::String,
source_index::Integer,
relation_type = RELATION_1_TO_1,
)
Returns the index of the element in collection target
related to the element in the collection source
element indexed by source_index
according to the scalar relation relation_type
.
PSRClassesInterface.get_vector_related
— Functionget_vector_related(
data::AbstractData,
source::String,
target::String,
source_index::Integer,
relation_type = RELATION_1_TO_N,
)
Returns the vector of indices of the elements in collection target
related to the element in the collection source
element indexed by source_index
according to the scalar relation relation_type
.
Reflection
PSRClassesInterface.get_attribute_dim1
— Functionget_attribute_dim1(
data::AbstractData,
collection::String,
attribute::string,
index::Integer;
)
Returns the size of dimension 1 of attribute
from collection
at element index
. Errors if attribute has zero dimensions.
PSRClassesInterface.get_attribute_dim2
— Functionget_attribute_dim2(
data::AbstractData,
collection::String,
attribute::string,
index::Integer;
)
Returns the size of dimension 2 of attribute
from collection
at element index
. Errors if attribute has zero or one dimensions.
PSRClassesInterface.get_collections
— Functionget_collections(data::AbstractData)
Return Vector{String}
of valid collections (depends on loaded pmd files).
PSRClassesInterface.get_attributes
— Functionget_attributes(data::AbstractData, collection::String)
Return Vector{String}
of valid attributes from collection
.
PSRClassesInterface.get_attribute_struct
— Functionget_attribute_struct(
data::AbstractData,
collection::String,
attribute::String,
)
Returns a struct of type Attribute
with fields:
- name::String = attribute name
- is_vector::Bool = true if attribute is a vector (tipically, varies in time)
- type::DataType = attribute type (tipically: Int32, Float64, String, Dates.Date)
- dim::Int = number of additional dimensions
- index::String = if a vector represents the indexing vector (might be empty)
PSRClassesInterface.get_data_struct
— Functionget_attribute_struct(data::AbstractData)
Return a struct of type DataStruct
with collection names (strings) as keys and maps from attributes names (string) to attributes data definitions Attribute
.
PSRClassesInterface.Attribute
— Typestruct Attribute
name::String
is_vector::Bool
type::DataType
dim::Int
index::String
end
PSRClassesInterface.get_attributes_indexed_by
— Functionget_attributes_indexed_by(
data::AbstractData,
collection::String,
indexing_attribute::String
)
Return Vector{String}
of valid vector attributes from collection
that are indexed by indexing_attribute
.
PSRClassesInterface.get_relations
— Functionget_relations(data::AbstractData, collection::String)
Returns a Tuple{String, Vector{PMD.Relation}}
with relating collection
and their relation type associated to collection
.
PSRClassesInterface.get_attribute_dim
— Functionget_attribute_dim(attribute_struct::Attribute)
Read and Write Graf files
Open and Close
PSRClassesInterface.AbstractReader
— TypePSRI.AbstractReader
PSRClassesInterface.AbstractWriter
— TypePSRI.AbstractWriter
PSRClassesInterface.open
— FunctionPSRI.open(::Type{<:AbstractWriter}, path::String; kwargs...)
Method for opening file and registering time series data. If specified file doesn't exist, the method will create it, otherwise, the previous one will be overwritten. Returns updated AbstractWriter
instance.
Arguments:
writer
:AbstractWriter
instance to be used for opening file.path
: path to file.
Keyword arguments:
blocks
: case's number of blocks.scenarios
: case's number of scenarios.stages
: case's number of stages.agents
: list of element names.unit
: dimension of the elements' data.is_hourly
: if data is hourly. If yes, block dimension will be ignored.hour_discretization
: sub-hour parameter to discretize an hour into minutes.name_length
: length of element names.block_type
: case's type of block.scenarios_type
: case's type of scenario.stage_type
: case's type of stage.initial_stage
: stage at which to start registry.initial_year
: year at which to start registry.allow_unsafe_name_length
: allow element names outside safety bounds.
Examples:
PSRI.open(reader::Type{<:AbstractReader}, path::String; kwargs...)
Method for opening file and reading time series data. Returns updated AbstractReader
instance.
Arguments:
reader::Type{<:AbstractReader}
:AbstractReader
instance to be used for opening file.path::String
: path to file.
Keyword arguments:
is_hourly::Bool
: if data to be read is hourly, other than blockly.stage_type::PSRI.StageType
: thePSRClassesInterface.StageType
of the data, defaults toPSRI.STAGE_MONTH
.header::Vector{String}
: if file has a header with metadata.use_header::Bool
: if data from header should be retrieved.first_stage::Dates.Date
: stage at which start reading.verbose_header::Bool
: if data from header should be displayed during execution.
Examples:
PSRClassesInterface.close
— FunctionPSRI.close(ior::AbstractReader)
Closes the PSRClassesInterface.AbstractReader
instance.
PSRI.close(iow::AbstractWriter)
Closes the PSRClassesInterface.AbstractWriter
instance.
Write entire file
PSRClassesInterface.array_to_file
— FunctionPSRI.array_to_file
Write registry
PSRClassesInterface.write_registry
— FunctionPSRI.write_registry(
iow::AbstractWriter,
data::Vector{T},
stage::Integer,
scenario::Integer = 1,
block::Integer = 1,
) where T <: Real
Writes a data row into opened file through PSRClassesInterface.AbstractWriter
instance.
Arguments:
iow
:PSRI.AbstractWriter
instance to be used for accessing file.data
: elements data to be written.stage
: stage of the data to be written.scenario
: scenarios of the data to be written.block
: block of the data to be written.
Header information
PSRClassesInterface.is_hourly
— FunctionPSRI.is_hourly(ior::AbstractReader)
Returns a Bool
indicating whether the data in the file read by PSRClassesInterface.AbstractReader
is hourly.
PSRClassesInterface.hour_discretization
— FunctionPSRI.hour_discretization(ior::AbstractReader)
Returns an Int
indicating the hour discretization.
PSRClassesInterface.max_stages
— FunctionPSRI.max_stages(ior::AbstractReader)
Returns an Int
indicating maximum number of stages in the file read by PSRClassesInterface.AbstractReader
.
PSRClassesInterface.max_scenarios
— FunctionPSRI.max_scenarios(ior::AbstractReader)
Returns an Int
indicating maximum number of scenarios in the file read by PSRClassesInterface.AbstractReader
.
PSRClassesInterface.max_blocks
— FunctionPSRI.max_blocks(ior::AbstractReader)
Returns an Int
indicating maximum number of blocks in the file read by PSRClassesInterface.AbstractReader
.
PSRClassesInterface.max_blocks_current
— FunctionPSRI.max_blocks_current(ior::AbstractReader)
Returns an Int
indicating maximum number of blocks in the cuurent stage in the file read by PSRClassesInterface.AbstractReader
.
PSRClassesInterface.max_blocks_stage
— FunctionPSRI.max_blocks_stage(ior::AbstractReader, t::Integer)
Returns an Int
indicating maximum number of blocks in the stage t
in the file read by PSRClassesInterface.AbstractReader
.
PSRClassesInterface.max_agents
— FunctionPSRI.max_agents(ior::AbstractReader)
Returns an Int
indicating maximum number of agents in the file read by PSRClassesInterface.AbstractReader
.
PSRClassesInterface.stage_type
— Functionstage_type
PSRClassesInterface.initial_stage
— FunctionPSRI.initial_stage(ior::AbstractReader)
Returns an Int
indicating the initial stage in the file read by PSRClassesInterface.AbstractReader
.
PSRClassesInterface.initial_year
— FunctionPSRI.initial_year(ior::AbstractReader)
Returns an Int
indicating the initial year in the file read by PSRClassesInterface.AbstractReader
.
PSRClassesInterface.data_unit
— FunctionPSRI.data_unit(ior::AbstractReader)
Returns a String
indicating the unit of the data in the file read by PSRClassesInterface.AbstractReader
.
PSRClassesInterface.agent_names
— FunctionPSRI.agent_names(ior::AbstractReader)
Returns a Vector{String}
with the agent names in the file read by PSRClassesInterface.AbstractReader
.
Read entire file
PSRClassesInterface.file_to_array
— FunctionPSRI.file_to_array(::Type{T}, path::String; use_header::Bool = true, header::Vector{String} = String[]) where T <: AbstractReader
Write a file to an array
PSRClassesInterface.file_to_array_and_header
— FunctionPSRI.file_to_array_and_header(::Type{T}, path::String; use_header::Bool = true, header::Vector{String} = String[]) where T <: AbstractReader
Write a file to an array and header
Read registry
PSRClassesInterface.current_stage
— FunctionPSRI.current_stage(ior::AbstractReader)
Returns an Int
indicating the current stage in the stream of the PSRClassesInterface.AbstractReader
.
PSRClassesInterface.current_scenario
— FunctionPSRI.current_scenario(ior::AbstractReader)
Returns an Int
indicating the current scenarios in the stream of the PSRClassesInterface.AbstractReader
.
PSRClassesInterface.current_block
— FunctionPSRI.current_block(ior::AbstractReader)
Returns an Int
indicating the current block in the stream of the PSRClassesInterface.AbstractReader
.
PSRClassesInterface.goto
— FunctionPSRI.goto(
ior::AbstractReader,
t::Integer,
s::Integer = 1,
b::Integer = 1
)
Goes to the registry of the stage t
, scenario s
and block b
.
PSRClassesInterface.next_registry
— FunctionPSRI.next_registry(ior::AbstractReader)
Goes to the next registry on the PSRClassesInterface.AbstractReader
.
File conversion
PSRClassesInterface.convert_file
— Functionconvert_file
PSRClassesInterface.add_reader!
— Functionadd_reader!
Reader mapper
PSRClassesInterface.ReaderMapper
— TypeReaderMapper{T}
Missing docstring for PSRClassesInterface.add_reader!
. Check Documenter's build log for details.
Modification API
PSRClassesInterface.create_study
— Functioncreate_study(::AbstractStudyInterface; kwargs...)
Returns the Data
object of a new study.
PSRClassesInterface.create_element!
— Functioncreate_element!(
data::Data,
collection::String,
ps::Pair{String,<:Any};
default::Union{Dict{String,Any},Nothing} = nothing
)
Creates a new instance of the given collection
and returns its index.
Example:
index = PSRI.create_element!(data, "PSRClass")
PSRI.set_parm!(data, "PSRClass", index, "PSRAttr", value)
PSRClassesInterface.set_parm!
— Functionset_parm!(
data::Data,
collection::String,
attribute::String,
index::Integer,
value::T,
) where {T <: MainTypes}
Defines the value of a scalar parameter.
PSRClassesInterface.set_vector!
— Functionfunction set_vector!(
data::Data,
collection::String,
attribute::String,
index::Int,
buffer::Vector{T}
) where {T<:MainTypes}
Updates a data vector according to the given buffer
. Note: Modifying current vector length is not allowed: use set_series!
instead.
PSRClassesInterface.set_series!
— Functionfunction set_series!(
data::Data,
collection::String,
index_attr::String,
index::Int,
buffer::Dict{String,Vector}
)
Updates serial (indexed) data. All columns must be the same as before. The series length is allowed to be changed, but all vectors in the new series must have equal length.
julia> series = Dict{String, Vector}(
"GerMin" => [0.0, 1.0],
"GerMax" => [888.0, 777.0],
"NGas" => [nothing, nothing],
"IH" => [0.0, 0.0],
"CoefE" => [1.0, 2.0],
"PotInst" => [888.0, 777.0],
"ICP" => [0.0, 0.0],
"Data" => ["1900-01-01", "1900-01-02"],
"Existing" => [0, 0],
"sfal" => [0, 1],
"NAdF" => [0, 0],
"Unidades" => [1, 1],
"StartUp" => [0.0, 2.0]
);
julia> PSRI.set_series!(data, "PSRThermalPlant", 1, "Data", series)
PSRClassesInterface.write_data
— Functionwrite_data(data::Data, path::String)
Writes data to file in JSON format.
PSRClassesInterface.set_related!
— Functionset_related!(
data::AbstractData,
source::String,
target::String,
source_index::Integer,
target_index::Integer;
relation_type = RELATION_1_TO_1,
)
Sets the element source_index
from collection source
to be related to the element target_index
from collection target
in the scalar relation of type relation_type
.
PSRClassesInterface.set_vector_related!
— Functionset_vector_related!(
data::AbstractData,
source::String,
target::String,
source_index::Integer,
target_index::Vector{<:Integer};
relation_type = RELATION_1_TO_N,
)
Sets the element source_index
from collection source
to be related to the elements in target_index
from collection target
in the vector relation of type relation_type
.