Skip to content

Commit

Permalink
Merge pull request #608 from tscheypidi/develop
Browse files Browse the repository at this point in the history
bugfix in NPI/NDC calculations
  • Loading branch information
pfuehrlich-pik authored Nov 9, 2023
2 parents ddb6d96 + 16bcab0 commit 64172d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
-

### fixed
-
- **scripts** Fixed a bug in NPI/NDC calculations leading to missing AD policies when run with 67k


## [4.6.11] - 2023-09-05
Expand Down
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 64172d1

Please sign in to comment.