Skip to content

Commit

Permalink
bugfix in NPI/NDC calculations: Reference stocks were set to 0 for 67…
Browse files Browse the repository at this point in the history
…k cells in all countries leading to removal of all AD policies
  • Loading branch information
tscheypidi committed Nov 9, 2023
1 parent ddb6d96 commit 699beae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/npi_ndc/start_npi_ndc.R
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ calc_policy <- function(policy, stock, pol_type="aff", pol_mapping=pol_mapping,
#set stock to zero or Inf for countries without policies
# (representing no constraint for min and max constraints)
if(pol_type=="ad"){
stock[!(sub("\\..*$","",getCells(stock)) %in% policy_countries),,] <- 0
if(dim(stock)[1] == 59199) {
stock[!(sub("\\..*$","",getCells(stock)) %in% policy_countries),,] <- 0
} else {
stock[!(getItems(stock, "iso", full = TRUE) %in% policy_countries),,] <- 0
}
#calculate flows
flow <- calc_flows(stock)
#account only for positive flows, i.e. deforestation
Expand Down

0 comments on commit 699beae

Please sign in to comment.