Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easiur fix #255

Merged
merged 4 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/core/financial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ function easiur_costs(latitude::Real, longitude::Real, grid_or_onsite::String)
USD_2010_to_2020 = 1.246
try
costs_per_tonne = Dict(
"NOx" => EASIUR_data["NOX_Annual"][x - 1, y - 1] .* USD_2010_to_2020,
"SO2" => EASIUR_data["SO2_Annual"][x - 1, y - 1] .* USD_2010_to_2020,
"PM25" => EASIUR_data["PEC_Annual"][x - 1, y - 1] .* USD_2010_to_2020
"NOx" => EASIUR_data["NOX_Annual"][x, y] .* USD_2010_to_2020,
"SO2" => EASIUR_data["SO2_Annual"][x, y] .* USD_2010_to_2020,
"PM25" => EASIUR_data["PEC_Annual"][x, y] .* USD_2010_to_2020
)
return costs_per_tonne
catch
Expand Down Expand Up @@ -400,12 +400,13 @@ function get_EASIUR2005(stack::String; pop_year::Int64=2005, income_year::Int64=
end

fn_2005 = joinpath(EASIUR_data_lib,"sc_8.6MVSL_$(stack)_pop2005.hdf5")
ret_map = JLD.load(fn_2005)
ret_map = JLD.load(fn_2005)

if pop_year != 2005
fn_growth = joinpath(EASIUR_data_lib,"sc_growth_rate_pop2005_pop2040_$(stack).hdf5")
map_rate = JLD.load(fn_growth)
map_rate = JLD.load(fn_growth)
for (k,v) in map_rate
setindex!(ret_map, v .* (v.^(pop_year - 2005)), k)
setindex!(ret_map, ret_map[k] .* (v.^(pop_year - 2005)), k)
hdunham marked this conversation as resolved.
Show resolved Hide resolved
end
end
if income_year != 2005
Expand Down Expand Up @@ -504,4 +505,4 @@ function easiur_data(; latitude::Real, longitude::Real, inflation::Real)
response_dict[ekey*"_cost_escalation_rate_fraction"] = escalation[ekey]
end
return response_dict
end
end
8 changes: 8 additions & 0 deletions test/test_with_xpress.jl
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,14 @@ end
# TODO test for tiered TOU demand rates
end

@testset "EASIUR" begin
d = JSON.parsefile("./scenarios/pv.json")
d["Site"]["latitude"] = 30.2672
d["Site"]["longitude"] = -97.7431
scen = Scenario(d)
@test scen.financial.NOx_grid_cost_per_tonne ≈ 4534.032470 atol=0.1
end

@testset "Wind" begin
m = Model(optimizer_with_attributes(Xpress.Optimizer, "OUTPUTLOG" => 0))
d = JSON.parsefile("./scenarios/wind.json")
Expand Down
Loading