@@ -5,37 +5,37 @@ using Mimi, CSVFiles, DataFrames, Query, Interpolations
55
66 country = Index()
77
8- SSP_source = Parameter{String}() # can be one of IIASA GDP, OECD Env-Growth, PIK GDP_32, and Benveniste
9- SSP = Parameter{String}() # can be one of SSP1, SSP2, SSP3, SSP4, SSP5
10- emissions_source = Parameter{String}() # can be one of Leach
11- emissions_scenario = Parameter{String}() # can be one of SSP119, SSP126, SSP245, SSP370, SSP585
8+ SSP_source = Parameter{String}() # can be one of IIASA GDP, OECD Env-Growth, PIK GDP_32, and Benveniste
9+ SSP = Parameter{String}() # can be one of SSP1, SSP2, SSP3, SSP4, SSP5
10+ emissions_source = Parameter{String}() # can be one of Leach
11+ emissions_scenario = Parameter{String}() # can be one of SSP119, SSP126, SSP245, SSP370, SSP585
1212
13- country_names = Parameter{String}(index= [country]) # need the names of the countries from the dimension
13+ country_names = Parameter{String}(index= [country]) # need the names of the countries from the dimension
1414
15- population = Variable(index= [time, country], unit= " million" )
16- population_global = Variable(index= [time], unit= " million" )
17- gdp = Variable(index= [time, country], unit= " billion US\$ 2005/yr" )
18- gdp_global = Variable(index= [time], unit= " billion US\$ 2005/yr" )
15+ population = Variable(index= [time, country], unit= " million" )
16+ population_global = Variable(index= [time], unit= " million" )
17+ gdp = Variable(index= [time, country], unit= " billion US\$ 2005/yr" )
18+ gdp_global = Variable(index= [time], unit= " billion US\$ 2005/yr" )
1919
20- co2_emissions = Variable(index= [time], unit= " GtC/yr" )
21- ch4_emissions = Variable(index= [time], unit= " MtCH4/yr" )
22- n2o_emissions = Variable(index= [time], unit= " MtN/yr" )
23- sf6_emissions = Variable(index= [time], unit= " MtSF6/yr" )
20+ co2_emissions = Variable(index= [time], unit= " GtC/yr" )
21+ ch4_emissions = Variable(index= [time], unit= " MtCH4/yr" )
22+ n2o_emissions = Variable(index= [time], unit= " MtN/yr" )
23+ sf6_emissions = Variable(index= [time], unit= " MtSF6/yr" )
2424
25- function init(p,v, d)
25+ function init(p, v, d)
2626
2727 # ----------------------------------------------------------------------
2828 # Checks
2929
3030 ssp_model_options = [" IIASA GDP" , " OECD Env-Growth" , " PIK GDP_23" , " Benveniste" ]
3131 ! (p. SSP_source in ssp_model_options) && error(" Model $(p. SSP_source) provided to SSPs component SSP_source parameter not found in available list: $(ssp_model_options) " )
32-
32+
3333 ssp_options = [" SSP1" , " SSP2" , " SSP3" , " SSP4" , " SSP5" ]
3434 ! (p. SSP in ssp_options) && error(" SSP $(p. SSP) provided to SSPs component SSP parameter not found in available list: $(ssp_options) " )
35-
35+
3636 emissions_source_options = [" Leach" ]
3737 ! (p. emissions_source in emissions_source_options) && error(" Model $(p. emissions_source) provided to SSPs component emissions_source parameter not found in available list: $(emissions_source_options) " )
38-
38+
3939 emissions_scenario_options = [" SSP119" , " SSP126" , " SSP245" , " SSP370" , " SSP585" ]
4040 ! (p. emissions_scenario in emissions_scenario_options) && error(" emissions_scenario $(p. emissions_scenario) provided to SSPs component emissions_scenario parameter not found in available list: $(emissions_scenario_options) " )
4141
@@ -73,21 +73,21 @@ using Mimi, CSVFiles, DataFrames, Query, Interpolations
7373
7474 if ! haskey(g_emissions_scenario_datasets, emissions_scenario_dict_key)
7575 if p. emissions_source == " Leach"
76- emissions_data = load(emissions_path, skiplines_begin = 6 ) |>
77- DataFrame |>
78- i -> rename!(i, Symbol.([:year, names(i)[2 : end ]. .. ])) |>
79- DataFrame |>
80- @select(:year, :carbon_dioxide, :nitrous_oxide, :methane, :sf6) |>
81- DataFrame
76+ emissions_data = load(emissions_path, skiplines_begin= 6 ) |>
77+ DataFrame |>
78+ i -> rename!(i, Symbol.([:year, names(i)[2 : end ]. .. ])) |>
79+ DataFrame |>
80+ @select(:year, :carbon_dioxide, :nitrous_oxide, :methane, :sf6) |>
81+ DataFrame
8282 else # already perfect formatted
83- emissions_data = load(emissions_path)|> DataFrame
83+ emissions_data = load(emissions_path) |> DataFrame
8484 end
8585
86- g_emissions_scenario_datasets[emissions_scenario_dict_key]= emissions_data
87- end
86+ g_emissions_scenario_datasets[emissions_scenario_dict_key] = emissions_data
87+ end
8888 end
8989
90- function run_timestep(p,v,d, t)
90+ function run_timestep(p, v, d, t)
9191
9292 ssp_dict_key = Symbol(p. SSP_source, " -" , p. SSP)
9393 emissions_scenario_dict_key = Symbol(p. emissions_source, " -" , p. emissions_scenario)
@@ -109,27 +109,27 @@ using Mimi, CSVFiles, DataFrames, Query, Interpolations
109109 # t and only the SSP countries found in the model countries list,
110110 # already checked that all model countries are in SSP countries list
111111 subset = g_ssp_datasets[ssp_dict_key] |>
112- @filter(_. year == gettime(t) && _. country in p. country_names) |>
113- DataFrame
112+ @filter(_. year == gettime(t) && _. country in p. country_names) |>
113+ DataFrame
114114
115115 # get the ordered indices of the SSP countries within the parameter
116116 # of the model countries, already checked that all model countries
117117 # are in SSP countries list
118118 order = indexin(p. country_names, subset. country)
119119
120- v. population[t,:] = subset. pop[order]
121- v. gdp[t,:] = subset. gdp[order]
122-
120+ v. population[t, :] = subset. pop[order]
121+ v. gdp[t, :] = subset. gdp[order]
122+
123123 # add global data for future accessibility and quality control
124- v. population_global[t] = sum(v. population[t,:])
125- v. gdp_global[t] = sum(v. gdp[t,:])
124+ v. population_global[t] = sum(v. population[t, :])
125+ v. gdp_global[t] = sum(v. gdp[t, :])
126126
127127 # ----------------------------------------------------------------------
128128 # Emissions
129129
130130 subset = g_emissions_scenario_datasets[emissions_scenario_dict_key] |>
131- @filter(_. year == gettime(t)) |>
132- DataFrame
131+ @filter(_. year == gettime(t)) |>
132+ DataFrame
133133
134134 v. co2_emissions[t] = subset. carbon_dioxide[1 ]
135135 v. ch4_emissions[t] = subset. methane[1 ]
0 commit comments