diff --git a/build_mosaic.sh b/build_mosaic.sh index ef9ff2a..812d20a 100755 --- a/build_mosaic.sh +++ b/build_mosaic.sh @@ -20,6 +20,8 @@ for arg in "$@"; do shift done +echo "Weeks ago: $weeks_ago" + # Check if required arguments are set if [ -z "$weeks_ago" ] || [ -z "$data_dir" ]; then echo "Missing arguments. Use: build_mosiac.sh --weeks_ago=3 --data_dir=chemba" diff --git a/r_app/CI_report_dashboard_planet.Rmd b/r_app/CI_report_dashboard_planet.Rmd index 86f6ba2..1c03956 100644 --- a/r_app/CI_report_dashboard_planet.Rmd +++ b/r_app/CI_report_dashboard_planet.Rmd @@ -200,7 +200,7 @@ subchunkify <- function(g, fig_height=7, fig_width=5) { ), collapse = '') sub_chunk <- paste0(" - `","``{r sub_chunk_", floor(runif(1) * 10000), ", fig.height=", fig_height, ", fig.width=", fig_width, ", echo=FALSE}", +`","``{r sub_chunk_", floor(runif(1) * 10000), ", fig.height=", fig_height, ", fig.width=", fig_width, ", echo=FALSE}", "\n(", g_deparsed , ")()", @@ -283,36 +283,10 @@ cum_ci_plot <- function(pivotName){ max_date = max(Date), days = max_date - min_date) - # perfect_pivot_raw <- CI_quadrant %>% group_by(Field) %>% filter(Field == "5.1" & season == "2022") %>% - # group_by(DOY) %>% summarise(cumulative_CI = mean(cumulative_CI)) %>% mutate(CI_rate = cumulative_CI/DOY) %>% - # mutate(mean_rolling10 = rollapplyr(CI_rate , width = 10, FUN = mean, partial = TRUE)) - unique_seasons <- unique(date_preperation_perfect_pivot$season) - # if(length(unique_seasons) == 3) { - # unique_seasons <- unique_seasons[c(2,3)] - # } else if(length(unique_seasons) == 4) { - # unique_seasons <- unique_seasons[c(3,4)] - # } else { - # unique_seasons <- unique_seasons - # } - # perfect_pivot <- perfect_pivot_raw - # - # for (s in unique_seasons) { - # season_dates <- seq(from = date_preperation_perfect_pivot$min_date[date_preperation_perfect_pivot$season == s], - # to = date_preperation_perfect_pivot$min_date[date_preperation_perfect_pivot$season == s] + nrow(perfect_pivot_raw) - 1, - # by = "1 day") - # col_name <- as.character(s) - # perfect_pivot <- dplyr::bind_cols(perfect_pivot, tibble(!!col_name := season_dates)) - # } - # - # perfect_pivot <- perfect_pivot %>% - # pivot_longer(cols = -c("DOY", "cumulative_CI", "CI_rate", "mean_rolling10"), - # names_to = "season", values_to = "Date") - - g <- ggplot(data= data_ci2 %>% filter(season %in% unique_seasons)) + - # facet_wrap(~Year, scales = "free_x") + + g <- ggplot(data= data_ci2) + geom_line( aes(Date, mean_rolling10, col = subField)) + # geom_line(data= perfect_pivot, aes(Date , mean_rolling10, col = "Model CI (p5.1 Data 2022, \n date x axis is fictive)"), lty="11",size=1) + labs(title = paste("14 day rolling MEAN CI rate - Pivot ", pivotName))+ @@ -323,7 +297,6 @@ cum_ci_plot <- function(pivotName){ legend.title = element_text(size = 8), legend.text = element_text(size = 8)) + guides(color = guide_legend(nrow = 2, byrow = TRUE)) - # options(repr.plot.width = 2, repr.plot.height = 2) subchunkify(g, 3.2, 10) } @@ -375,40 +348,42 @@ tm_shape(CI, unit = "m")+ ``` \newpage - ```{r plots_ci_estate, eval=FALSE, fig.height=3.8, fig.width=10, message=FALSE, warning=FALSE, include=FALSE, results='asis'} # # pivots <- AllPivots_merged %>% filter(pivot != c("1.1", "1.17")) -pivots_estate <- AllPivots_merged %>% filter(pivot %in% c("1.1", "1.2", "1.3", "1.4", "1.6", "1.7", "1.8", "1.9", "1.10", "1.11", "1.12", "1.13", "1.14" , "1.16" , "1.17" , "1.18" , "6.1", "6.2", "DL1.1", "DL1.3")) %>% filter(pivot != "1.17") +pivots_estate <- AllPivots_merged %>% filter(Field %in% c("6.2")) #, "1.2", "1.3", "1.4")) #, "1.6", "1.7", "1.8", "1.9", "1.10", "1.11", "1.12", "1.13", "1.14" , "1.16" , "1.17" , "1.18" , "6.1", "6.2", "DL1.1", "DL1.3")) %>% filter(pivot != "1.17") # pivots <- AllPivots_merged %>% filter(pivot != c("1.1", "1.17")) # pivots_estate <- AllPivots_merged %>% filter(pivot %in% c("1.1", "1.2", "1.7")) %>% filter(pivot != "1.17") -walk(pivots_estate$pivot, ~ { + +walk(pivots_estate$Field, ~ { + cat("# Hello!!!") cat("\n") # Add an empty line for better spacing ci_plot(.x) # cum_ci_plot(.x) }) ``` - -```{r looping over sub_area, echo=FALSE, fig.height=3.8, fig.width=10, message=FALSE, warning=FALSE, results='asis'} -pivots_grouped <- AllPivots_merged %>% - group_by(sub_area) %>% - arrange(sub_area) # Optional: arrange the groups alphabetically by sub_area +```{r looping_over_sub_area, echo=FALSE, fig.height=3.8, fig.width=10, message=FALSE, warning=FALSE, results='asis', eval=TRUE} +pivots_grouped <- AllPivots_merged # %>% +# group_by(sub_area) %>% +# arrange(sub_area) # Optional: arrange the groups alphabetically by sub_area # Iterate over each subgroup for (subgroup in unique(pivots_grouped$sub_area)) { - cat("\n") - cat("# Subgroup: ", subgroup, "\n") # Add a title for the subgroup +cat("# HELLO!!!") +print(" PRINT") +# cat("\n") +# cat("# Subgroup: ", subgroup, "\n") # Add a title for the subgroup subset_data <- filter(pivots_grouped, sub_area == subgroup) - cat('\\pagebreak') +# cat("\\pagebreak") walk(subset_data$Field, ~ { - cat("\n") # Add an empty line for better spacing + # cat("\n") # Add an empty line for better spacing ci_plot(.x) - cat("\n") + # cat("\n") cum_ci_plot(.x) - cat("\n") + # cat("\n") }) } ``` diff --git a/r_app/Rplots.pdf b/r_app/Rplots.pdf index de7759a..43ef5b7 100644 Binary files a/r_app/Rplots.pdf and b/r_app/Rplots.pdf differ