Skip to content

Commit

Permalink
Merge pull request #40 from USEPA/thru2300
Browse files Browse the repository at this point in the history
Thru2300
  • Loading branch information
cahartin authored Dec 6, 2022
2 parents 7bb3eca + 63c1aff commit 8840149
Show file tree
Hide file tree
Showing 95 changed files with 214,085 additions and 138,067 deletions.
6 changes: 3 additions & 3 deletions FrEDI/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Package: FrEDI
Title: The Framework for Evaluating Damages and Impacts (FrEDI) with Net Present Damages (NPD)
Version: 3.2.0
Version: 3.3.7
Authors: U.S. Environmental Protection Agency (EPA) <https://epa.gov/cira/>
URL: https://epa.gov/cira/FrEDI/
Description: This R package models damages and impacts from climate change in the contiguous United States (CONUS)
using the Framework for Evaluating Damages and Impacts (FrEDI) developed as part of the Climate Change Impacts and
Risk Analysis (CIRA) project at the U.S. Environmental Protection Agency. The package contains functions that
implement FrEDI for projecting impacts from climate change and sea level rise for a selected set of
sectors. Version 3 and above includes a module for estimating impacts on socially vulnerable populations for
select sectors. Version 3.1.0 extends calculations out to 2300 to facilitate the calculation of Net Present Damages
(NPD) but only contains default values through 2090--users must provide their own inputs through 2300.
select sectors. Version 3.3.0 extends calculations out to 2300 to facilitate the calculation of Net Present Damages
(NPD) but only contains default values through 2090--users must provide their own inputs through 2300.
License: file LICENSE
Encoding: UTF-8
Depends: R (>= 3.5.0),
Expand Down
707 changes: 246 additions & 461 deletions FrEDI/R/aggregate_impacts.R

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion FrEDI/R/get_sectorInfo.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ get_sectorInfo <- function(
rename(sector = sector_label) %>%
rename(model_type = modelType) %>%
mutate(model_type = model_type %>% toupper)

### Sort
co_sectorsRef <- co_sectorsRef %>% arrange_at(.vars=c("sector"))
### GCM or SLR
gcm_string <- "GCM"
if(gcmOnly){
co_sectorsRef <- co_sectorsRef %>% filter(model_type==gcm_string)
Expand Down
70 changes: 35 additions & 35 deletions FrEDI/R/import_inputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,41 +200,41 @@ import_inputs <- function(
df_input_i <- df_input_i %>% mutate(temp_C = temp_C %>% convertTemps(from="global"))
}

###### Check Input ######
msg2 %>% paste0("Checking values...") %>% message
### Values
values_i <- df_input_i[,valueCol_i]
### Substitute NULL for missing values for min and max
if(is.na(min_i)) min_i <- NULL; if(is.na(max_i)) max_i <- NULL
### Check the status
flag_i <- values_i %>% check_inputs(xmin = min_i, xmax = max_i)
### Return and message the user if there is a flag:
flagStatus_i <- flag_i$flagged
flagRows_i <- flag_i$rows
### If flag, message user and return flagStatus_i
if(flagStatus_i){
### Message labels
numrows_i <- flagRows_i %>% length
years_i <- df_input_i$year[flagRows_i]; yearsLabel_i <- paste(years_i, collapse=",")
rangeLabel_i <- paste0("c(", min_i , ",", max_i, ")")
### Create message and message user
msg1_i <- msg2 %>% paste("Error in importing inputs for", msgName_i) %>% paste0("!")
msg2_i <- msg3 %>% paste(inputName_i, "has", numrows_i, "values outside of defined range", rangeLabel_i)
msg3_i <- msg3 %>% paste("Please correct values", msgName_i, "values for years", yearsLabel_i) %>% paste0("...")
### Message user
"\n" %>% paste0(msg0) %>% paste0("Warning:") %>% message
msg1_i %>% message; msg2_i %>% message; msg3_i %>% message
"\n" %>% paste0(msg0) %>% paste0("Exiting...") %>% message

### Return list with error and flagged rows
returnList <- list(
error_msg = paste0("Error in ", inputName_i, ". Values outside range."),
flagged_rows = flagRows_i
)

### Return list and not an inputs list if an error occurred
return(returnList)
} ### End if flagged
# ###### Check Input ######
# msg2 %>% paste0("Checking values...") %>% message
# ### Values
# values_i <- df_input_i[,valueCol_i]
# ### Substitute NULL for missing values for min and max
# if(is.na(min_i)) min_i <- NULL; if(is.na(max_i)) max_i <- NULL
# ### Check the status
# flag_i <- values_i %>% check_inputs(xmin = min_i, xmax = max_i)
# ### Return and message the user if there is a flag:
# flagStatus_i <- flag_i$flagged
# flagRows_i <- flag_i$rows
# ### If flag, message user and return flagStatus_i
# if(flagStatus_i){
# ### Message labels
# numrows_i <- flagRows_i %>% length
# years_i <- df_input_i$year[flagRows_i]; yearsLabel_i <- paste(years_i, collapse=",")
# rangeLabel_i <- paste0("c(", min_i , ",", max_i, ")")
# ### Create message and message user
# msg1_i <- msg2 %>% paste("Error in importing inputs for", msgName_i) %>% paste0("!")
# msg2_i <- msg3 %>% paste(inputName_i, "has", numrows_i, "values outside of defined range", rangeLabel_i)
# msg3_i <- msg3 %>% paste("Please correct values", msgName_i, "values for years", yearsLabel_i) %>% paste0("...")
# ### Message user
# "\n" %>% paste0(msg0) %>% paste0("Warning:") %>% message
# msg1_i %>% message; msg2_i %>% message; msg3_i %>% message
# "\n" %>% paste0(msg0) %>% paste0("Exiting...") %>% message
#
# ### Return list with error and flagged rows
# returnList <- list(
# error_msg = paste0("Error in ", inputName_i, ". Values outside range."),
# flagged_rows = flagRows_i
# )
#
# ### Return list and not an inputs list if an error occurred
# return(returnList)
# } ### End if flagged

###### Update Results List Element ######
### Add results to the file
Expand Down
Loading

0 comments on commit 8840149

Please sign in to comment.