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 3 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
18 changes: 12 additions & 6 deletions src/core/financial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ function easiur_costs(latitude::Real, longitude::Real, grid_or_onsite::String)
EASIUR_data = nothing
try
EASIUR_data = get_EASIUR2005(type, pop_year=2020, income_year=2020, dollar_year=2010)
if type == "p150"
hdunham marked this conversation as resolved.
Show resolved Hide resolved
print("\nEASIUR_data['NOX_Annual']: ", EASIUR_data["NOX_Annual"][10,10], "\n")
end
catch e
@warn "Could not look up EASIUR health costs from point ($latitude,$longitude). {$e}"
return nothing
Expand All @@ -264,9 +267,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 +403,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 @@ -505,3 +509,5 @@ function easiur_data(; latitude::Real, longitude::Real, inflation::Real)
end
return response_dict
end

print("\nTEST!!!: ", easiur_data(;latitude=30.2672,longitude=-97.7431,inflation=0.025)["NOx_grid_cost_per_tonne"])
hdunham marked this conversation as resolved.
Show resolved Hide resolved
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