Skip to content

Commit

Permalink
Merge pull request #94 from USEPA/pop_downscaling
Browse files Browse the repository at this point in the history
Pop downscaling data along with remaining new sectors. Tested and merged onto FrEDI main.
  • Loading branch information
knoiva-indecon authored Jul 10, 2024
2 parents 8d3b607 + 05f1bce commit ab989ac
Show file tree
Hide file tree
Showing 11 changed files with 575 additions and 60 deletions.
2 changes: 1 addition & 1 deletion R/frediConfig.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ frediConfig <- function(outPath){

### Minimum Years
minYear <- 2010
maxYear <- 2090
maxYear <- 2100
elasticity <- 1
# maxYear <- 2100

Expand Down
116 changes: 58 additions & 58 deletions R/fredi_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
frediData_config <- list()
###### Messages for createSystemData ######
frediData_config$messages_data = list(
loadPackages = "Loading required packages...",
sourceCode = "Loading custom functions...",
loadInputs = list(try="Loading input data...", success="Input data loaded.", fail="Could not find input data."),
calcScalars = list(try="Calculating physical and economic scalars...", success="Physical and economic scalars calculated."),
interpFuns = list(try="Getting interpolation functions...", success="Interpolation functions complete."),
saveRData = list(try="Saving results...", success="R data loaded.", fail="Could not find R data."),
outPath = list(fail="Output directory not found.", success="Created output directory.", skip="No directory created. Exiting..."),
aggImpacts = list(try="Aggregating impacts...")
)
loadPackages = "Loading required packages...",
sourceCode = "Loading custom functions...",
loadInputs = list(try="Loading input data...", success="Input data loaded.", fail="Could not find input data."),
calcScalars = list(try="Calculating physical and economic scalars...", success="Physical and economic scalars calculated."),
interpFuns = list(try="Getting interpolation functions...", success="Interpolation functions complete."),
saveRData = list(try="Saving results...", success="R data loaded.", fail="Could not find R data."),
outPath = list(fail="Output directory not found.", success="Created output directory.", skip="No directory created. Exiting..."),
aggImpacts = list(try="Aggregating impacts...")
)

###### Constants ######
###### Named constant values that are used frequently in the model
### Millions, billions
Expand Down Expand Up @@ -48,28 +48,28 @@ frediData_config$maxYear <- 2300
fredi_config <- frediData_config
###### List of Messages ######
fredi_config$list_messages = list(
loadPackages = "Loading required packages...",
sourceCode = "Loading custom functions...",
loadRData = list(
try ="Loading R data...",
success="R data loaded.",
fail ="Could not find R data."
),
loadInputs = list(
try ="Loading input data...",
success="Input data loaded.",
fail ="Could not find input data."
),
globalTemps = "Converting global temperature scenario to CONUS scenario...",
updatePopGDP = "Updating socioeconomic scenario...",
updateScalars = list(try="Updating physical and economic scalars...", success="Physical and economic scalars updated."),
scaledImpacts = list(try="Calculating annual scaled impacts", success="Calculation of scaled impacts complete."),
aggImpacts = list(try="Aggregating impacts..."),
impactTypes = list(try="Summing over impact types..."),
impactYears = list(try="Interpolating between impact estimate years..."),
modelAves = list(try="Getting model averages..."),
national = list(try="Calculating national totals...")
)
loadPackages = "Loading required packages...",
sourceCode = "Loading custom functions...",
loadRData = list(
try ="Loading R data...",
success="R data loaded.",
fail ="Could not find R data."
),
loadInputs = list(
try ="Loading input data...",
success="Input data loaded.",
fail ="Could not find input data."
),
globalTemps = "Converting global temperature scenario to CONUS scenario...",
updatePopGDP = "Updating socioeconomic scenario...",
updateScalars = list(try="Updating physical and economic scalars...", success="Physical and economic scalars updated."),
scaledImpacts = list(try="Calculating annual scaled impacts", success="Calculation of scaled impacts complete."),
aggImpacts = list(try="Aggregating impacts..."),
impactTypes = list(try="Summing over impact types..."),
impactYears = list(try="Interpolating between impact estimate years..."),
modelAves = list(try="Getting model averages..."),
national = list(try="Calculating national totals...")
)
###### Required package list ######
### Packages used in the RTool. Previous packages included: "scriptName", "stringr", and "ggplot2" # requiredPackageList <- c("tidyverse", "data.table", "openxlsx" #, #"sqldf", "openxlsx", "matrixStats", "RColorBrewer")

Expand All @@ -88,7 +88,7 @@ fredi_config$list_years <- seq(fredi_config$minYear, fredi_config$maxYear,
fredi_config$elasticity0 <- 1
fredi_config$aggList0 <- c("national", "modelaverage", "impactyear", "impacttype")
fredi_config$groupLevels0 <- c("sector", "adaptation", "impactYear", "impactType", "modelType", "model", "region", "state", "postal")

###### temps2slr constants ######
fredi_config$temps2slr <- list(
### Phi: (i.e., "c", above) is a temperature-independent rate term with e-folding time tau2. I.e., phi is the multi-millennial contribution to GMSL in mm/year.
Expand Down Expand Up @@ -120,30 +120,30 @@ fredi_config$temps2slr <- list(
### Defaults for regional images
# def_img_device <- "png"
fredi_config$get_plots <- list(
def_img_unit = "in",

### Heights and Widths
### Heat Maps: ~28 for GCM, ~10 for SLR
def_heat_width = 16,
base_heat_ht_per = 0.13, ### Per region and group

### Annual damage images, by region and sector
### Different heights for regions, national (originally 6 for regions, 4.5 for national).
base_rib_ht = 2,
base_rib_per = 1.25, ### Per region
base_rib_width_per = 1.5, ### Per adaptation
base_rib_width = 4,

###### Scale column ######
### Dataframe of units
df_units = data.frame(
log10mod3 = 0:4,
unitLabel = c("", "Thousands", "Millions", "Billions", "Trillions")
) %>%
mutate(
unitName = unitLabel %>% tolower,
unitValue = 10^(3*log10mod3),
valueLog10 = unitValue %>% log10
def_img_unit = "in",

### Heights and Widths
### Heat Maps: ~28 for GCM, ~10 for SLR
def_heat_width = 16,
base_heat_ht_per = 0.13, ### Per region and group

### Annual damage images, by region and sector
### Different heights for regions, national (originally 6 for regions, 4.5 for national).
base_rib_ht = 2,
base_rib_per = 1.25, ### Per region
base_rib_width_per = 1.5, ### Per adaptation
base_rib_width = 4,

###### Scale column ######
### Dataframe of units
df_units = data.frame(
log10mod3 = 0:4,
unitLabel = c("", "Thousands", "Millions", "Billions", "Trillions")
) %>%
select(unitName, unitLabel, unitValue, valueLog10, log10mod3)
mutate(
unitName = unitLabel %>% tolower,
unitValue = 10^(3*log10mod3),
valueLog10 = unitValue %>% log10
) %>%
select(unitName, unitLabel, unitValue, valueLog10, log10mod3)
)
2 changes: 1 addition & 1 deletion R/utils_configure_sv.R
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ get_svPopList <- function(
msg1 <- msg0 |> paste0("\t")

###### Constants ######
c_intYears <- seq(2000, 2090, by=5) ### years for interpolating
c_intYears <- seq(2000, 2100, by=5) ### years for interpolating

###### Check for Data ######
### Check if there is a data file and if not, exit
Expand Down
Binary file modified data/sv/format_styles.rda
Binary file not shown.
Binary file modified data/sv/svDataList.rda
Binary file not shown.
Binary file modified data/sv/svPopData.rda
Binary file not shown.
Binary file modified data/sysdata.rda
Binary file not shown.
Binary file modified data_tests/generalConfig_testResults.xlsx
Binary file not shown.
Binary file modified inst/extdata/FrEDI_config.xlsx
Binary file not shown.
Loading

0 comments on commit ab989ac

Please sign in to comment.