TulipaIO
TulipaIO is part of the Tulipa ecosystem of packages. The main package in this ecosystem is TulipaEnergyModel.jl. Check that package first for more information on the ecosystem.
Usage
TulipaIO is used to provide input to TulipaEnergyModel and other packages in the ecosystem. Here is some basic usage:
First, we read a fake CSV file with the relevant information.
using TulipaIO: TulipaIO
using DuckDB: DBInterface, DB
con = DBInterface.connect(DB)
table_name = TulipaIO.create_tbl(con, filepath) # filepath is the path to a CSV
"assets_data"
Then we can run SQL commands using the DuckDB interface. It returns a DuckDB.QueryResult
, which we convert to Dict to visualize:
DBInterface.execute(con, "SELECT name, variable_cost FROM $table_name WHERE type = 'conversion'") |> Dict
Dict{String, Float64} with 7 entries:
"Valhalla_H2_generator" => 0.0
"Valhalla_Fuel_cell" => 0.0
"Valhalla_Heat_pump" => 0.0
"Asgard_CCGT" => 0.0015
"Midgard_CCGT" => 0.0015
"Valhalla_Electrolyser" => 0.0
"Valhalla_GT" => 0.0015
This allows simple conversion to DataFrame as well:
using DataFrames: DataFrame
DataFrame(DBInterface.execute(con, "SELECT name, type, investable, variable_cost FROM $table_name WHERE name LIKE 'Asgard_%'"))
4×4 DataFrame
Row | name | type | investable | variable_cost |
---|---|---|---|---|
String? | String? | Bool? | Float64? | |
1 | Asgard_Battery | storage | true | 0.003 |
2 | Asgard_Solar | producer | true | 0.001 |
3 | Asgard_E_demand | consumer | false | 0.0 |
4 | Asgard_CCGT | conversion | true | 0.0015 |
Contributors
Suvayu Ali 💻 👀 🤔 |
Abel Soares Siqueira 💻 👀 🤔 |
Lauren Clisby 💻 👀 🤔 📆 |
Diego Alejandro Tejada Arango 💻 👀 |