Commit fe0ffdec authored by Turner's avatar Turner
Browse files

2022 switch

parent 6c9a4cb7
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -366,7 +366,7 @@ get_EIA_annual_gen <- function(gnr_dir, plt_dir){
    gen_1970_2000


  2001:2021 %>%
  2001:2022 %>%
    map_dfr(function(yr){

      if(yr %in% 2001:2002){
@@ -423,7 +423,7 @@ get_EIA_annual_gen <- function(gnr_dir, plt_dir){
        )
      }

      if(yr %in% 2008:2021){
      if(yr %in% 2008:2022){

        if(yr %in% 2008:2010){
          file_name <- paste0(gnr_dir, "f923_", yr,
@@ -495,7 +495,7 @@ get_EIA_annual_gen <- function(gnr_dir, plt_dir){

  # generate table of hrs per year for computation of maximum output
  tibble(
    date = seq.Date(from = ymd("1970-01-01"), to = ymd("2021-12-31"), by = 1)
    date = seq.Date(from = ymd("1970-01-01"), to = ymd("2022-12-31"), by = 1)
  ) |>
    mutate(year = year(date)) |>
    summarise(n_hrs = n() * 24, .by = year) ->
+8 −8
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ plot_CF_trend_map <- function(CFs, CF_trends, EHA, WBD){

  # get CF trends and split into categories
  CF_trends |>
    filter(analysis == "flow period plus") |>
    filter(analysis == "flow period add 2022") |>
    mutate(trend_CFpp_per_decade = sens_slope * 10 * 100) |>
    select(COMPLXID, trend_CFpp_per_decade, p_value) ->
    trend_data_all_plants
@@ -218,7 +218,7 @@ plot_CF_trend_map <- function(CFs, CF_trends, EHA, WBD){

  ### CA ####
  CFs |>
    filter(year %in% 1980:2021,
    filter(year %in% 1980:2022,
           COMPLXID %in% filter(dam_points,
                                substr(HUC, 1, 2) == "18")$COMPLXID) ->
    dam_gen_CA
@@ -262,7 +262,7 @@ plot_CF_trend_map <- function(CFs, CF_trends, EHA, WBD){

  ### CA ####
  CFs |>
    filter(year %in% 1980:2021,
    filter(year %in% 1980:2022,
           COMPLXID %in% filter(dam_points,
                                substr(HUC, 1, 2) %in% c("14", "15"))$COMPLXID) ->
    dam_gen_CO
@@ -306,7 +306,7 @@ plot_CF_trend_map <- function(CFs, CF_trends, EHA, WBD){

  ### PNW ####
  CFs |>
    filter(year %in% 1980:2021,
    filter(year %in% 1980:2022,
           COMPLXID %in% filter(dam_points,
                                State %in% c("WA", "OR", "ID"))$COMPLXID) ->
    dam_gen_PNW
@@ -351,7 +351,7 @@ plot_CF_trend_map <- function(CFs, CF_trends, EHA, WBD){

  ### SE ####
  CFs |>
    filter(year %in% 1980:2021,
    filter(year %in% 1980:2022,
           COMPLXID %in% filter(dam_points,
                                State %in% c("TN", "AL",
                                             "GA", "SC", "MD",
@@ -397,7 +397,7 @@ plot_CF_trend_map <- function(CFs, CF_trends, EHA, WBD){

  ### NE ####
  CFs |>
    filter(year %in% 1980:2021,
    filter(year %in% 1980:2022,
           COMPLXID %in% filter(dam_points,
                                State %in% c("NY", "VT",
                                             "NH", "ME", "MA",
@@ -1280,8 +1280,8 @@ plot_shift_sparks <- function(trend_shift_analysis,
    model_residuals_all

  trend_shift_analysis |>
    mutate(shift_more_likely = if_else(p_shift  < p_trend, T, F)) |>
    arrange(shift_yr) |>
    mutate(shift_more_likely = if_else(p_shift  <= p_trend, T, F)) |>
    arrange(shift_yr) |> #filter(COMPLXID == "hc1333")
    filter(shift_more_likely == TRUE) |> #count(shift_yr) |> arrange(shift_yr)
    select(COMPLXID, shift_yr) |>
    left_join(dam_names, by = join_by(COMPLXID)) |>
+2 −1
Original line number Diff line number Diff line
@@ -11,7 +11,8 @@ get_CF_trends <- function(annual_CFs){
    ~start_yr, ~end_yr, ~analysis,
    #1970, 2021, "full period",
    1980, 2019, "flow period",
    1980, 2021, "flow period plus"
    1980, 2021, "flow period plus",
    1980, 2022, "flow period add 2022"
    #2001, 2021, "923 period"
  ) |>
    pmap_dfr(function(start_yr, end_yr, analysis){
+2 −2
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ list(
  tar_target(
    model_data_ready,
    prep_model_data(plant_to_flow_H_mapping = plant_to_flow_H_mapping,
                    CFs = dam_annual_gen_cap_CF_1970_2021,
                    CFs = dam_annual_gen_cap_CF_1970_2022,
                    flows = DayFlow),
    format = "parquet"
  ),
@@ -145,7 +145,7 @@ list(
  ),
  tar_target(
    CF_trend_map,
    plot_CF_trend_map(CFs = dam_annual_gen_cap_CF_1970_2021,
    plot_CF_trend_map(CFs = dam_annual_gen_cap_CF_1970_2022,
                      CF_trends = CF_trends,
                      EHA = EHA, WBD = WBD),
    format = "rds"
+26 −24

File changed.

Preview size limit exceeded, changes collapsed.