Skip to content

Commit

Permalink
nodes run support func, res-csv no pm10 in name, row cates #11 #34
Browse files Browse the repository at this point in the history
- Core function outputs file without the word pm10 in variable string #11
- Core function outputs categorical variable labeling group-specific and cross-group and overall-results #11
- New local run support parallel node, temperature array helper func
- New Run scripts file
- Updated 24 hour and day time scripts to use new local run support
- Updated CSV outputs for 24 hour and day time results with no pm10 in variable names and categorical label #34
  • Loading branch information
FanWangEcon committed Feb 10, 2024
1 parent c662a19 commit d3a4716
Show file tree
Hide file tree
Showing 15 changed files with 650 additions and 687 deletions.
52 changes: 46 additions & 6 deletions R-script/ffs_pirecec_support.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
#' Local development script parameter control.
#'
#' We have a number of scripts, we want to control some core parameters
#' in those scripts. The scripts are calling core functions, we just
#' want some parameters to control the flow of scripts across multiple scripts.
#'
#' - Sets the number of cores to use for parallel processing
#' - Sets whether to generate individual threshold files or aggregate
#'
#' @description Local development path support
#'
#' @return A list of parameters to control scripts
#' @examples
#' ls_script_controls <- ffs_run_set_params()
#' it_nnodes <- ls_script_controls$it_nnodes
#' ls_run <- ls_script_controls$ls_run
#' @export
#' @author Fan Wang, \url{http://fanwangecon.github.io}
#'
ffs_run_set_params <- function() {
# The number of nodes to be forked.
# https://www.rdocumentation.org/packages/parallel/versions/3.6.2/topics/makeCluster
# 10 on precision
it_nnodes <- 18

# 1 = genereate individual threshold files, 2 aggregate threshold individual files jointsly
ls_run <- c(1, 2)
# ls_run <- c(1)
# ls_run <- c(2)

# Temperature array to evaluate
# ar_temp_bound <- seq(1, 2, by = 1)
ar_temp_bound <- seq(-40, 40, length.out = 81)

return(list(
it_nnodes = it_nnodes,
ls_run = ls_run,
ar_temp_bound = ar_temp_bound
))
}

#' Local developemnt path support
#'
#' @description Local development path support
Expand All @@ -7,7 +48,6 @@
#' @author Fan Wang, \url{http://fanwangecon.github.io}
#'
ffs_pirecec_path_run <- function() {

# 1. Get dropbox path
spt_root_prj_main_dropbox_xps15 <- file.path(
"C:", "Users", "fan",
Expand All @@ -17,7 +57,7 @@ ffs_pirecec_path_run <- function() {
spt_root_prj_main_dropbox_vostro <- file.path(
"C:", "Users", "fan",
"Documents",
"Dropbox (UH-ECON)",
"Dropbox (UH-ECON)",
fsep = .Platform$file.sep
)

Expand All @@ -34,16 +74,16 @@ ffs_pirecec_path_run <- function() {

# 2. get r functions and source (outside of package usage)
spt_cec_sandbox_r_func_fan <- file.path(
spt_root_prj_main_dropbox,
"repos", "prjcec",
spt_root_prj_main_dropbox,
"repos", "prjcec",
"r",
# "sandbox", "r", "function",
fsep = .Platform$file.sep
)
spt_cec_sandbox_r_func <- spt_cec_sandbox_r_func_fan
spt_cec_sandbox_r_func_fan <- file.path(
spt_root_prj_main_dropbox,
"repos", "prjcec",
spt_root_prj_main_dropbox,
"repos", "prjcec",
"r",
# "sandbox", "r", "function",
fsep = .Platform$file.sep
Expand Down
19 changes: 11 additions & 8 deletions R-script/run_1a_mean_child_all24/ffs_pirecec_demo_1990_all24.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# Implements Part 1 of https://github.com/ClimateInequality/PrjCEC/issues/34
# Follows from `R-script/code_d_regional/ffp_cec_inequality_run_demo_loc_a2_parallel_region_1990.R`

# 0. Master controls -----
# 0. Load local script support ------
source("R-script/ffs_pirecec_support.R")
ls_script_controls <- ffs_run_set_params()
it_nnodes <- ls_script_controls$it_nnodes
ls_run <- ls_script_controls$ls_run
ar_temp_bound <- ls_script_controls$ar_temp_bound
# 1 = parallel gen results over thresholds, 2 = combine parallel results across thresholds
# ls_run <- c(1, 2)
ls_run <- c(2)
# ls_run <- c(1)

# 1. Load libraries ------
source("R-script/ffs_pirecec_support.R")
# ls_run <- c(2)

# Load data managment and statistics packages
library(readr)
library(dplyr)
library(tidyr)
library(stringr)
library(ggplot2)
# library(tidyverse)

Expand All @@ -28,9 +30,10 @@ if (1 %in% ls_run) {
# Get the number of cores
it_n_cores_computer <- parallel::detectCores()
glue::glue("Number of cores on computers:{it_n_cores_computer}")
glue::glue("Using these number of cores:{it_nnodes}")
# Start cluster
ob_cluster <- parallel::makeCluster(
10,
it_nnodes,
type = "PSOCK"
)
# Register cluster
Expand Down Expand Up @@ -81,7 +84,7 @@ str_prefix_time <- "day"
# 9. Stats to compute within year
st_time_stats <- "share"
# ar_temp_bound <- seq(1,1, by=1)
ar_temp_bound <- seq(-40, 40, length.out = 81)
# ar_temp_bound <- seq(-40, 40, length.out = 81)
bl_greater <- TRUE

# Sub_group of focus
Expand Down
21 changes: 12 additions & 9 deletions R-script/run_1a_mean_child_all24/ffs_pirecec_demo_2020_all24.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# Implements Part 1 of https://github.com/ClimateInequality/PrjCEC/issues/34
# Follows from `R-script/code_d_regional/ffp_cec_inequality_run_demo_loc_a2_parallel_region_1990.R`

# 0. Master controls -----
# 1 = parallel gen results over thresholds, 2 = combine parallel results across thresholds
ls_run <- c(1, 2)
ls_run <- c(2)
# ls_run <- c(1)

# 1. Load libraries ------
# 0. Load local script support ------
source("R-script/ffs_pirecec_support.R")
ls_script_controls <- ffs_run_set_params()
it_nnodes <- ls_script_controls$it_nnodes
ls_run <- ls_script_controls$ls_run
ar_temp_bound <- ls_script_controls$ar_temp_bound
# 1 = parallel gen results over thresholds, 2 = combine parallel results across thresholds
# ls_run <- c(1, 2)
# ls_run <- c(2)

# Load data managment and statistics packages
library(readr)
library(dplyr)
library(tidyr)
library(stringr)
library(ggplot2)
# library(tidyverse)

Expand All @@ -28,9 +30,10 @@ if (1 %in% ls_run) {
# Get the number of cores
it_n_cores_computer <- parallel::detectCores()
glue::glue("Number of cores on computers:{it_n_cores_computer}")
glue::glue("Using these number of cores:{it_nnodes}")
# Start cluster
ob_cluster <- parallel::makeCluster(
10,
it_nnodes,
type = "PSOCK"
)
# Register cluster
Expand Down Expand Up @@ -81,7 +84,7 @@ str_prefix_time <- "day"
# 9. Stats to compute within year
st_time_stats <- "share"
# ar_temp_bound <- seq(1,1, by=1)
ar_temp_bound <- seq(-40, 40, length.out = 81)
# ar_temp_bound <- seq(-40, 40, length.out = 81)
bl_greater <- TRUE

# Sub_group of focus
Expand Down
2 changes: 2 additions & 0 deletions R-script/run_1b_mean_child_6t22/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Day time hours only analysis

In this folder, we first generate from the full day hours file day time only hours files, and then we generate 2020 vs 1990 differences for the average individual (child) using day time hours only.

See part 1 of <https://github.com/ClimateInequality/PrjCEC/issues/35>. And part 2 of <https://github.com/ClimateInequality/PrjCEC/issues/34>.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Implements https://github.com/ClimateInequality/PrjCEC/issues/35
# Implements Part 1 of https://github.com/ClimateInequality/PrjCEC/issues/35

# 1. Load libraries ------
source("R-script/ffs_pirecec_support.R")
Expand Down
18 changes: 11 additions & 7 deletions R-script/run_1b_mean_child_6t22/ffs_pirecec_demo_1990_6t22.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# Implements Part 1 of https://github.com/ClimateInequality/PrjCEC/issues/34
# Follows from `R-script/code_d_regional/ffp_cec_inequality_run_demo_loc_a2_parallel_region_1990.R`

# 0. Master controls -----
# 1 = parallel gen results over thresholds, 2 = combine parallel results across thresholds
ls_run <- c(1, 2)
ls_run <- c(2)

# 1. Load libraries ------
# 0. Load local script support ------
source("R-script/ffs_pirecec_support.R")
ls_script_controls <- ffs_run_set_params()
it_nnodes <- ls_script_controls$it_nnodes
ls_run <- ls_script_controls$ls_run
ar_temp_bound <- ls_script_controls$ar_temp_bound
# 1 = parallel gen results over thresholds, 2 = combine parallel results across thresholds
# ls_run <- c(1, 2)
# ls_run <- c(2)

# Load data managment and statistics packages
library(readr)
library(dplyr)
library(tidyr)
library(stringr)
library(ggplot2)
# library(tidyverse)

Expand All @@ -27,9 +30,10 @@ if (1 %in% ls_run) {
# Get the number of cores
it_n_cores_computer <- parallel::detectCores()
glue::glue("Number of cores on computers:{it_n_cores_computer}")
glue::glue("Using these number of cores:{it_nnodes}")
# Start cluster
ob_cluster <- parallel::makeCluster(
12,
it_nnodes,
type = "PSOCK"
)
# Register cluster
Expand Down
19 changes: 11 additions & 8 deletions R-script/run_1b_mean_child_6t22/ffs_pirecec_demo_2020_6t22.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# Implements Part 1 of https://github.com/ClimateInequality/PrjCEC/issues/34
# Follows from `R-script/code_d_regional/ffp_cec_inequality_run_demo_loc_a2_parallel_region_1990.R`

# 0. Master controls -----
# 1 = parallel gen results over thresholds, 2 = combine parallel results across thresholds
ls_run <- c(1, 2)
ls_run <- c(2)
# ls_run <- c(1)

# 1. Load libraries ------
# 0. Load local script support ------
source("R-script/ffs_pirecec_support.R")
ls_script_controls <- ffs_run_set_params()
it_nnodes <- ls_script_controls$it_nnodes
ls_run <- ls_script_controls$ls_run
ar_temp_bound <- ls_script_controls$ar_temp_bound
# 1 = parallel gen results over thresholds, 2 = combine parallel results across thresholds
# ls_run <- c(1, 2)
# ls_run <- c(2)

# Load data managment and statistics packages
library(readr)
library(dplyr)
library(tidyr)
library(stringr)
library(ggplot2)
# library(tidyverse)

Expand All @@ -28,9 +30,10 @@ if (1 %in% ls_run) {
# Get the number of cores
it_n_cores_computer <- parallel::detectCores()
glue::glue("Number of cores on computers:{it_n_cores_computer}")
glue::glue("Using these number of cores:{it_nnodes}")
# Start cluster
ob_cluster <- parallel::makeCluster(
3,
it_nnodes,
type = "PSOCK"
)
# Register cluster
Expand Down
Loading

0 comments on commit d3a4716

Please sign in to comment.