Data
Loading Data
E4ST.read_data — Functionread_data(config) -> dataPulls in data found in files listed in the config, and stores into data.
Calls the following functions:
read_data_files!(config, data)- read in the data from filesmodify_raw_data!(config, data)- GivesModifications a chance to modify the raw data before the data gets setup.setup_data!(config, data)- Sets up the data, modifying/adding to the tables as needed.modify_setup_data!(config, data)- GivesModifications a chance to modify the setup data before the model is built.
E4ST.read_data_files! — Methodread_data_files!(config, data)Loads in the data files presented in the config.
E4ST.modify_raw_data! — Methodmodify_raw_data!(config, data)Allows Modifications to modify the raw data - calls modify_raw_data!(mod, config, data)
E4ST.setup_data! — Functionsetup_data!(config, data)Sets up the data, modifying, adding to, or combining the tables as needed. New generators built in the setup_gen_table! function.
E4ST.modify_setup_data! — Methodmodify_setup_data!(config, data)Allows Modifications to modify the raw data - calls modify_setup_data!(mod, config, data)
E4ST.read_summary_table! — Functionread_summary_table!(config, data)Loads in the summary table for each of the other tables.
E4ST.setup_table! — Methodsetup_table!(config, data, table_name)Sets up the data[:table_name]. Calls setup_table!(config, data, Val(table_name)), if defined.
Accessor Functions
E4ST.get_table_summary — Functionget_table_summary(data, table_name) -> summary::SubDataFrameReturns a summary of table_name, read in from summarize_table and read_summary_table!.
E4ST.get_table_names — Functionget_table_names(data) -> table_listReturns a list of all the tables in data.
E4ST.get_table — Functionget_table(data, table_name, conditions...) -> subtable::SubDataFrameReturn a subset of the table table_name for which the row passes the conditions. Conditions are Pairs generally consisting of <column name> => value. Here are some examples of supported conditions:
:genfuel => "ng"- All rows for whichrow.genfuel == "ng""bus_idx" => 1- All rows for whichrow.bus_idx == 1. Note that the column name can be String or Symbol:bus_idx => "1"- All rows for whichrow.bus_idx == 1. Note that this is a String but it will get converted to the eltype of table.bus_idx for the comparison:year_on => ("y2022", "y2030")- All rows for whichrow.year_onis between "y2022" and "y2030", inclusive. Also works for fractional years.:genfuel => ["ng", "solar", "wind"]- All rows for whichrow.genfuelis either "ng", "solar", or "wind":emis_co2 => f::Function- All rows for which f(row.emis_co2) returnstrue. For example>(0), orx->(0<x<=0.5)
get_table(data, table_name::Symbol) -> table::DataFrameRetrieves data[table_name], enforcing that it is a DataFrame. See get_table_names for a list of available tables.
E4ST.get_table_row_idxs — Functionget_table_row_idxs(data, table_name, conditions...) -> row_idxs::Vector{Int64}Gets the row indices for data[table_name] for which the conditions hold true. See get_table for a description of possible conditions
E4ST.get_table_val — Functionget_table_val(data, table_name, col_name, row_idx) -> valReturns the value of the table at column col_name and row row_idx
Related functions:
get_table_num(data, table_name, col_name, row_idx, yr_idx, hr_idx): retrieves theFloat64fromdata[variable_name], indexing by year and hour.get_num(data, name, yr_idx, hr_idx): retrieves aFloat64fromdata, indexing by year and hour.get_val(data, variable_name): retrieves the value from data[variable_name] regardless of type, not indexed by row, year or hour.
E4ST.get_table_num — Functionget_table_num(data, table_name, col_name, row_idx, yr_idx, hr_idx) -> num::Float64Retrieves a Float64 from table[row_idx, col_idx][yr_idx, hr_idx]. This indexes into Containers as needed and will still work for Float64 columns.
Related functions:
get_table_val(data, table_name, col_name, row_idx): retrieves the raw value from the table (without indexing by year/hour).get_num(data, name, yr_idx, hr_idx): retrieves aFloat64fromdata, indexing by year and hour.
E4ST.get_table_col — Functionget_table_col(data, table_name, col_name) -> col::VectorE4ST.get_table_col_type — Functionget_table_col_type(data, table_name, column_name) -> ::TypeE4ST.get_table_col_unit — Functionget_table_col_unit(data, table_name, column_name) -> unit::Type{<:Unit}E4ST.get_table_col_description — Functionget_table_col_description(data, table_name, column_name) -> descriptionE4ST.get_row_idxs — Functionget_row_idxs(table, conditions) -> row_idxsReturns row indices of the passed-in table that correspond to conditions, where conditions can be:
::Colon- all rows::Int64- a single row::AbstractVector{Int64}- a list of rowsp::Pair- returns a Vector containing the index of each row for whichcomparison(p[2], typeof(row[p[1]]))(row[p[1]])is true. Seecomparisonpairs, an iterator ofPairs - returns a Vector containing the indices which satisfy all the pairs as above.
Some possible pairs to filter by:
:nation => "narnia": checks if thenationcolumn is equal to the string "narnia":emis_co2 => >=(0.1): checks if theemis_co2column is greater than or equal to 0.1:age => (2,10): checks if theagecolumn is between 2, and 10, inclusive. To be exclusive, use different values like (2.0001, 9.99999) for clarity:state => in(("alabama", "arkansas")): checks if thestatecolumn is either "alabama" or "arkansas"
Used in get_table and get_table_row_idxs.
E4ST.get_year_idxs — Functionget_year_idxs(data, year_idxs) -> idxsConverts year_idxs into a usable set of indices that can index into get_years(data). year_idxs can be any of the following types:
ColonInt64AbstractVector{Int64}AbstractString- Representing the year, i.e. "y2020"AbstractVector{<:AbstractString}- a vector of strings representing the year, i.e. "y2020"Tuple{<:AbstractString, <:AbstractString}Function- a function of the year string that returns a boolean. I.e. <=("y2030")
E4ST.get_hour_idxs — Functionget_hour_idxs(data, hour_idxs)Converts hour_idxs into a usable set of indices that can index into hourly data. hour_idxs can be any of the following types:
ColonInt64AbstractVector{Int64}
E4ST.has_table — Functionhas_table(data, table_name) -> BoolE4ST.get_num — Functionget_num(data, variable_name, yr_idx, hr_idx) -> num::Float64
get_num(table, col_name, row_idx, yr_idx, hr_idx) -> num::Float64Retrieves a Float64 from data[variable_name], indexing by year and hour. Works for Containers and Numbers.
Related functions:
get_table_val(data, table_name, col_name, row_idx): retrieves the raw value from the table (without indexing by year/hour).get_table_num(data, table_name, col_name, row_idx, yr_idx, hr_idx): retrieves theFloat64fromdata[variable_name], indexing by year and hour.get_val(data, variable_name): retrieves the value from data[variable_name] regardless of type, not indexed by row, year or hour.
E4ST.parse_comparison — Functionparse_comparison(s) -> compParses the string, s for a comparison with which to filter a table.
Possible examples of strings s to parse:
"nation=>narnia"- All rows for which row.nation=="narnia""bus_idx=>5"- All rows for which row.bus_idx==5"year_on=>(y2002,y2030)"- All rows for whichrow.year_onis between 2002 and 2030, inclusive."emis_co2=>(0.0,4.99)"- All rows for whichrow.emis_co2is between 0.0 and 4.99, inclusive. (Works for integers and negatives too)"emis_co2=> >(0)"- All rows for whichrow.emis_co2is greater than 0 (Works for integers and negatives too)"year_on=> >(y2002)- All rows for whichrow.year_onis greater than "y2002" (works for fractional years too, such as "y2002.4")"genfuel=>[ng, wind, solar]"- All rows for whichrow.genfuelis "ng", "wind", or "solar". Works for Ints and Floats too."genfuel=>![ng, coal, biomass]"- All rows for whichrow.genfuelis not "ng", "coal", or "biomass". Works for Ints and Floats too.
E4ST.parse_comparisons — Functionparse_comparisons(row::DataFrameRow) -> pairsReturns a set of pairs to be used in filtering rows of another table. Looks for the following properties in the row:
area, subarea- if the row has a non-empty area and subarea, it will parse the comparisonrow.area=>row.subareafilter_- if the row has any non-emptyfilter_(i.e.filter1,filter2) values, it will parse the comparison viaparse_comparisongenfuel- if the row has a non-emptygenfuel, it will add an comparion that checks that each row'sgenfuelequals this valuegentype- if the row has a non-emptygentype, it will add an comparion that checks that each row'sgentypeequals this valueload_type- if the row has a non-emptyload_type, it will add an comparion that checks that each row'sload_typeequals this value
parse_comparisons(d::AbstractDict) -> pairsReturns a set of pairs to be used in filtering rows of another table, where each value d
E4ST.parse_year_idxs — Functionparse_year_idxs(s::AbstractString) -> comparisonsParse a year comparison. Could take the following forms:
"y2020"- year 2020 only""- All years, returns (:)"1"- year index 1"[1,2,3]"
E4ST.parse_hour_idxs — Functionparse_hour_idxs(s::AbstractString) -> comparisonsParse a year comparison. Could take the following forms:
"1"- hour 1 only""- All hours, returns (:)"season=>winter"- returns "season"=>"winter"
E4ST.comparison — Functioncomparison(value, v) -> comp::FunctionReturns the appropriate comparison function for value to be compared to each member of v.
comparison(value, ::Type) -> comp::FunctionReturns the appropriate comparison function for value to be compared to the 2nd argument type. Here are a few options:
- comparison(f::Function, ::Type) -> f
- comparison(s::String, ::Type{<:AbstractString}) -> ==(s)