diff --git a/Prototypes/Cotton/Cotton_Shaun.apsimx b/Prototypes/Cotton/Cotton_Shaun.apsimx index 18bc75a181..65c1f94300 100644 --- a/Prototypes/Cotton/Cotton_Shaun.apsimx +++ b/Prototypes/Cotton/Cotton_Shaun.apsimx @@ -2,7 +2,7 @@ "$type": "Models.Core.Simulations, Models", "ExplorerWidth": 282, "Version": 79, - "ApsimVersion": "Version 0.0.0.0, built 2020-02-24", + "ApsimVersion": "Version 0.0.0.0, built 2020-02-27", "Name": "Simulations", "Children": [ { @@ -6511,9 +6511,10 @@ "$type": "Models.PostSimulationTools.ExcelInput, Models", "FileName": "emerald.xlsx", "SheetNames": [ - "Yield", - "Fruit", - "SoilWater" + "Emerald_Phenology", + "Emerald_Yield", + "Emerald_Fruit", + "Emerald_SoilWater" ], "Name": "Emerald", "Children": [], @@ -6521,10 +6522,24 @@ "Enabled": true, "ReadOnly": false }, + { + "$type": "Models.PostSimulationTools.ExcelInput, Models", + "FileName": "narrabri.xlsx", + "SheetNames": [ + "Narrabri_Yield", + "Narrabri_Plant", + "Narrabri_SoilWater" + ], + "Name": "Narrabri", + "Children": [], + "IncludeInDocumentation": false, + "Enabled": true, + "ReadOnly": false + }, { "$type": "Models.PostSimulationTools.PredictedObserved, Models", "PredictedTableName": "DailyReport", - "ObservedTableName": "Fruit", + "ObservedTableName": "Emerald_Fruit", "FieldNameUsedForMatch": "Clock.Today", "FieldName2UsedForMatch": null, "FieldName3UsedForMatch": null, diff --git a/Prototypes/Cotton/emerald.xlsx b/Prototypes/Cotton/emerald.xlsx index 872c032771..925c6fcb98 100644 Binary files a/Prototypes/Cotton/emerald.xlsx and b/Prototypes/Cotton/emerald.xlsx differ diff --git a/Prototypes/Cotton/munge-experiment-data/.Rhistory b/Prototypes/Cotton/munge-experiment-data/.Rhistory new file mode 100644 index 0000000000..ec1f59f25d --- /dev/null +++ b/Prototypes/Cotton/munge-experiment-data/.Rhistory @@ -0,0 +1,512 @@ +lai_2007 <- lai_2007 %>% pivot_longer(cols = c("79","92","115","135","170"), names_to = "das", values_to = "lai") +lai_2007 <- lai_2007 %>% pivot_longer(cols = lai, names_to = "variable", values_to = "values") +bolls_2007 <- bolls_2007 %>% pivot_longer(cols = c("79","92","115","135","170"), names_to = "das", values_to = "bolls") +bolls_2007 <- bolls_2007 %>% pivot_longer(cols = bolls, names_to = "variable", values_to = "values") +squares_2007 <- squares_2007 %>% pivot_longer(cols = c("79","92","115","135","170"), names_to = "das", values_to = "squares") +squares_2007 <- squares_2007 %>% pivot_longer(cols = squares, names_to = "variable", values_to = "values") +sites_2007 <- sites_2007 %>% pivot_longer(cols = c("79","92","115","135","170"), names_to = "das", values_to = "sites") +sites_2007 <- sites_2007 %>% pivot_longer(cols = sites, names_to = "variable", values_to = "values") +plant_2007 <- bind_rows(lai_2007, sites_2007, squares_2007, bolls_2007) +plant_2007 <- plant_2007 %>% pivot_wider(names_from = variable, values_from = values) +plant_2007 <- plant_2007 %>% mutate(year = 2007) %>% select(year, das, Treatment, everything()) +yield_2007 <- yield_2007 %>% mutate(year = 2007) %>% select(year, Treatment, everything()) +# 2008 +# ---- +lai_2008 <- lai_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "lai") +lai_2008 <- lai_2008 %>% pivot_longer(cols = lai, names_to = "variable", values_to = "values") +bolls_2008 <- bolls_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "bolls") +bolls_2008 <- bolls_2008 %>% pivot_longer(cols = bolls, names_to = "variable", values_to = "values") +squares_2008 <- squares_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "squares") +squares_2008 <- squares_2008 %>% pivot_longer(cols = squares, names_to = "variable", values_to = "values") +sites_2008 <- sites_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "sites") +sites_2008 <- sites_2008 %>% pivot_longer(cols = sites, names_to = "variable", values_to = "values") +greenbolls_2008 <- greenbolls_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "greenbolls") +greenbolls_2008 <- greenbolls_2008 %>% pivot_longer(cols = greenbolls, names_to = "variable", values_to = "values") +openbolls_2008 <- openbolls_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "openbolls") +openbolls_2008 <- openbolls_2008 %>% pivot_longer(cols = openbolls, names_to = "variable", values_to = "values") +plant_2008 <- bind_rows(lai_2008, sites_2008, squares_2008, bolls_2008, greenbolls_2008, openbolls_2008) +plant_2008 <- plant_2008 %>% pivot_wider(names_from = variable, values_from = values) +plant_2008 <- plant_2008 %>% mutate(year = 2008) %>% select(year, das, Treatment, everything()) +yield_2008 <- yield_2008 %>% mutate(year = 2008) %>% select(year, Treatment, everything()) +# Combined +# -------- +plant <- bind_rows(plant_2006, plant_2007, plant_2008) +yield <- bind_rows(yield_2006, yield_2007, yield_2008) +#! /bin/bash +library(tidyverse) +library(readxl) +library(writexl) +library(lubridate) +dir_sourcedata <- file.path("C:","Users","ver078","Dropbox","CottonModel","OldData","Narrabri(Stephen)", "Soil Probe Data") +path <- file.path(dir_sourcedata, "ProbeReading Summary.xls") +#nb. the probes only went down to 120cm. So all the sw measurments are the cumulative sw down to 120cm +# 2006 +# ---- +blue_date <- read_xls(path, sheet = "2006-07", range = "C6:AJ6", col_names = FALSE) +blue_sw <- read_xls(path, sheet = "2006-07", range = "C7:AJ7", col_names = FALSE) +blue_date <- t(blue_date) +blue_sw <- t(blue_sw) +blue <- data_frame(blue_date,blue_sw) +names(blue)[1] <- "date" +names(blue)[2] <- "sw_120" +blue_2006 <- blue %>% mutate(year = 2006, treatment = "Blue") %>% select(year, treatment, date, sw_120) +red_date <- read_xls(path, sheet = "2006-07", range = "C11:AJ11", col_names = FALSE) +red_sw <- read_xls(path, sheet = "2006-07", range = "C12:AJ12", col_names = FALSE) +red_date <- t(red_date) +red_sw <- t(red_sw) +red <- data_frame(red_date,red_sw) +names(red)[1] <- "date" +names(red)[2] <- "sw_120" +red_2006 <- red %>% mutate(year = 2006, treatment = "Red") %>% select(year, treatment, date, sw_120) +green_date <- read_xls(path, sheet = "2006-07", range = "C16:AC16", col_names = FALSE) +green_sw <- read_xls(path, sheet = "2006-07", range = "C17:AC17", col_names = FALSE) +green_date <- t(green_date) +green_sw <- t(green_sw) +green <- data_frame(green_date,green_sw) +names(green)[1] <- "date" +names(green)[2] <- "sw_120" +green_2006 <- green %>% mutate(year = 2006, treatment = "Green") %>% select(year, treatment, date, sw_120) +grey_date <- read_xls(path, sheet = "2006-07", range = "C21:Z21", col_names = FALSE) +grey_sw <- read_xls(path, sheet = "2006-07", range = "C22:Z22", col_names = FALSE) +grey_date <- t(grey_date) +grey_sw <- t(grey_sw) +grey <- data_frame(grey_date,grey_sw) +names(grey)[1] <- "date" +names(grey)[2] <- "sw_120" +grey_2006 <- grey %>% mutate(year = 2006, treatment = "Grey") %>% select(year, treatment, date, sw_120) +# 2007 +# ---- +blue_date <- read_xls(path, sheet = "2007-08", range = "C6:AP6", col_names = FALSE) +blue_sw <- read_xls(path, sheet = "2007-08", range = "C7:AP7", col_names = FALSE) +blue_date <- t(blue_date) +blue_sw <- t(blue_sw) +blue <- data_frame(blue_date,blue_sw) +names(blue)[1] <- "date" +names(blue)[2] <- "sw_120" +blue_2007 <- blue %>% mutate(year = 2007, treatment = "Blue") %>% select(year, treatment, date, sw_120) +red_date <- read_xls(path, sheet = "2007-08", range = "C11:AC11", col_names = FALSE) +red_sw <- read_xls(path, sheet = "2007-08", range = "C12:AC12", col_names = FALSE) +red_date <- t(red_date) +red_sw <- t(red_sw) +red <- data_frame(red_date,red_sw) +names(red)[1] <- "date" +names(red)[2] <- "sw_120" +red_2007 <- red %>% mutate(year = 2007, treatment = "Red") %>% select(year, treatment, date, sw_120) +green_date <- read_xls(path, sheet = "2007-08", range = "C16:AB16", col_names = FALSE) +green_sw <- read_xls(path, sheet = "2007-08", range = "C17:AB17", col_names = FALSE) +green_date <- t(green_date) +green_sw <- t(green_sw) +green <- data_frame(green_date,green_sw) +names(green)[1] <- "date" +names(green)[2] <- "sw_120" +green_2007 <- green %>% mutate(year = 2007, treatment = "Green") %>% select(year, treatment, date, sw_120) +grey_date <- read_xls(path, sheet = "2007-08", range = "C21:Y21", col_names = FALSE) +grey_sw <- read_xls(path, sheet = "2007-08", range = "C22:Y22", col_names = FALSE) +grey_date <- t(grey_date) +grey_sw <- t(grey_sw) +grey <- data_frame(grey_date,grey_sw) +names(grey)[1] <- "date" +names(grey)[2] <- "sw_120" +grey_2007 <- grey %>% mutate(year = 2007, treatment = "Grey") %>% select(year, treatment, date, sw_120) +# 2008 +# ---- +blue_date <- read_xls(path, sheet = "2008-09", range = "C6:AP6", col_names = FALSE) +blue_sw <- read_xls(path, sheet = "2008-09", range = "C7:AP7", col_names = FALSE) +blue_date <- t(blue_date) +blue_sw <- t(blue_sw) +blue <- data_frame(blue_date,blue_sw) +names(blue)[1] <- "date" +names(blue)[2] <- "sw_120" +blue_2008 <- blue %>% mutate(year = 2008, treatment = "Blue") %>% select(year, treatment, date, sw_120) +red_date <- read_xls(path, sheet = "2008-09", range = "C11:AH11", col_names = FALSE) +red_sw <- read_xls(path, sheet = "2008-09", range = "C12:AH12", col_names = FALSE) +red_date <- t(red_date) +red_sw <- t(red_sw) +red <- data_frame(red_date,red_sw) +names(red)[1] <- "date" +names(red)[2] <- "sw_120" +red_2008 <- red %>% mutate(year = 2008, treatment = "Red") %>% select(year, treatment, date, sw_120) +green_date <- read_xls(path, sheet = "2008-09", range = "C16:AI16", col_names = FALSE) +green_sw <- read_xls(path, sheet = "2008-09", range = "C17:AI17", col_names = FALSE) +green_date <- t(green_date) +green_sw <- t(green_sw) +green <- data_frame(green_date,green_sw) +names(green)[1] <- "date" +names(green)[2] <- "sw_120" +green_2008 <- green %>% mutate(year = 2008, treatment = "Green") %>% select(year, treatment, date, sw_120) +grey_date <- read_xls(path, sheet = "2008-09", range = "C21:Z21", col_names = FALSE) +grey_sw <- read_xls(path, sheet = "2008-09", range = "C22:Z22", col_names = FALSE) +grey_date <- t(grey_date) +grey_sw <- t(grey_sw) +grey <- data_frame(grey_date,grey_sw) +names(grey)[1] <- "date" +names(grey)[2] <- "sw_120" +grey_2008 <- grey %>% mutate(year = 2008, treatment = "Grey") %>% select(year, treatment, date, sw_120) +# Combine years +# ------------- +blue <- bind_rows(blue_2006, blue_2007, blue_2008) +red <- bind_rows(red_2006, red_2007, red_2008) +green <- bind_rows(green_2006, green_2007, green_2008) +grey <- bind_rows(grey_2006, grey_2007, grey_2008) +soilwater <- bind_rows(blue, red, green, grey) +#! /bin/bash +library(tidyverse) +library(readxl) +library(writexl) +library(lubridate) +dir_sourcedata <- file.path("C:","Users","ver078","Dropbox","CottonModel","OldData","Narrabri(Stephen)", "Soil Probe Data") +path <- file.path(dir_sourcedata, "ProbeReading Summary.xls") +#nb. the probes only went down to 120cm. So all the sw measurments are the cumulative sw down to 120cm +# WRITE TO SPREADSHEET +# -------------------- +sheets <- list(Yield = yield, Plant = plant, SoilWater = soilwater) +write_xlsx(x = sheets, path = "./output/narrabri.xlsx") +#! /bin/bash +library(tidyverse) +library(readxl) +library(writexl) +library(lubridate) +dir_sourcedata <- file.path("C:","Users","ver078","Dropbox","CottonModel","OldData","Narrabri(Stephen)", "Soil Probe Data") +path <- file.path(dir_sourcedata, "ProbeReading Summary.xls") +#nb. the probes only went down to 120cm. So all the sw measurments are the cumulative sw down to 120cm +# 2006 +# ---- +blue_date <- read_xls(path, sheet = "2006-07", range = "C6:AJ6", col_names = FALSE) +blue_sw <- read_xls(path, sheet = "2006-07", range = "C7:AJ7", col_names = FALSE) +blue_date <- t(blue_date) +blue_sw <- t(blue_sw) +blue <- data_frame(blue_date,blue_sw) +names(blue)[1] <- "date" +names(blue)[2] <- "sw_120" +blue_2006 <- blue %>% mutate(year = 2006, treatment = "Blue") %>% select(year, treatment, date, sw_120) +red_date <- read_xls(path, sheet = "2006-07", range = "C11:AJ11", col_names = FALSE) +red_sw <- read_xls(path, sheet = "2006-07", range = "C12:AJ12", col_names = FALSE) +red_date <- t(red_date) +red_sw <- t(red_sw) +red <- data_frame(red_date,red_sw) +names(red)[1] <- "date" +names(red)[2] <- "sw_120" +red_2006 <- red %>% mutate(year = 2006, treatment = "Red") %>% select(year, treatment, date, sw_120) +green_date <- read_xls(path, sheet = "2006-07", range = "C16:AC16", col_names = FALSE) +green_sw <- read_xls(path, sheet = "2006-07", range = "C17:AC17", col_names = FALSE) +green_date <- t(green_date) +green_sw <- t(green_sw) +green <- data_frame(green_date,green_sw) +names(green)[1] <- "date" +names(green)[2] <- "sw_120" +green_2006 <- green %>% mutate(year = 2006, treatment = "Green") %>% select(year, treatment, date, sw_120) +grey_date <- read_xls(path, sheet = "2006-07", range = "C21:Z21", col_names = FALSE) +grey_sw <- read_xls(path, sheet = "2006-07", range = "C22:Z22", col_names = FALSE) +grey_date <- t(grey_date) +grey_sw <- t(grey_sw) +grey <- data_frame(grey_date,grey_sw) +names(grey)[1] <- "date" +names(grey)[2] <- "sw_120" +grey_2006 <- grey %>% mutate(year = 2006, treatment = "Grey") %>% select(year, treatment, date, sw_120) +# 2007 +# ---- +blue_date <- read_xls(path, sheet = "2007-08", range = "C6:AP6", col_names = FALSE) +blue_sw <- read_xls(path, sheet = "2007-08", range = "C7:AP7", col_names = FALSE) +blue_date <- t(blue_date) +blue_sw <- t(blue_sw) +blue <- data_frame(blue_date,blue_sw) +names(blue)[1] <- "date" +names(blue)[2] <- "sw_120" +blue_2007 <- blue %>% mutate(year = 2007, treatment = "Blue") %>% select(year, treatment, date, sw_120) +red_date <- read_xls(path, sheet = "2007-08", range = "C11:AC11", col_names = FALSE) +red_sw <- read_xls(path, sheet = "2007-08", range = "C12:AC12", col_names = FALSE) +red_date <- t(red_date) +red_sw <- t(red_sw) +red <- data_frame(red_date,red_sw) +names(red)[1] <- "date" +names(red)[2] <- "sw_120" +red_2007 <- red %>% mutate(year = 2007, treatment = "Red") %>% select(year, treatment, date, sw_120) +green_date <- read_xls(path, sheet = "2007-08", range = "C16:AB16", col_names = FALSE) +green_sw <- read_xls(path, sheet = "2007-08", range = "C17:AB17", col_names = FALSE) +green_date <- t(green_date) +green_sw <- t(green_sw) +green <- data_frame(green_date,green_sw) +names(green)[1] <- "date" +names(green)[2] <- "sw_120" +green_2007 <- green %>% mutate(year = 2007, treatment = "Green") %>% select(year, treatment, date, sw_120) +grey_date <- read_xls(path, sheet = "2007-08", range = "C21:Y21", col_names = FALSE) +grey_sw <- read_xls(path, sheet = "2007-08", range = "C22:Y22", col_names = FALSE) +grey_date <- t(grey_date) +grey_sw <- t(grey_sw) +grey <- data_frame(grey_date,grey_sw) +names(grey)[1] <- "date" +names(grey)[2] <- "sw_120" +grey_2007 <- grey %>% mutate(year = 2007, treatment = "Grey") %>% select(year, treatment, date, sw_120) +# 2008 +# ---- +blue_date <- read_xls(path, sheet = "2008-09", range = "C6:AP6", col_names = FALSE) +blue_sw <- read_xls(path, sheet = "2008-09", range = "C7:AP7", col_names = FALSE) +blue_date <- t(blue_date) +blue_sw <- t(blue_sw) +blue <- data_frame(blue_date,blue_sw) +names(blue)[1] <- "date" +names(blue)[2] <- "sw_120" +blue_2008 <- blue %>% mutate(year = 2008, treatment = "Blue") %>% select(year, treatment, date, sw_120) +red_date <- read_xls(path, sheet = "2008-09", range = "C11:AH11", col_names = FALSE) +red_sw <- read_xls(path, sheet = "2008-09", range = "C12:AH12", col_names = FALSE) +red_date <- t(red_date) +red_sw <- t(red_sw) +red <- data_frame(red_date,red_sw) +names(red)[1] <- "date" +names(red)[2] <- "sw_120" +red_2008 <- red %>% mutate(year = 2008, treatment = "Red") %>% select(year, treatment, date, sw_120) +green_date <- read_xls(path, sheet = "2008-09", range = "C16:AI16", col_names = FALSE) +green_sw <- read_xls(path, sheet = "2008-09", range = "C17:AI17", col_names = FALSE) +green_date <- t(green_date) +green_sw <- t(green_sw) +green <- data_frame(green_date,green_sw) +names(green)[1] <- "date" +names(green)[2] <- "sw_120" +green_2008 <- green %>% mutate(year = 2008, treatment = "Green") %>% select(year, treatment, date, sw_120) +grey_date <- read_xls(path, sheet = "2008-09", range = "C21:Z21", col_names = FALSE) +grey_sw <- read_xls(path, sheet = "2008-09", range = "C22:Z22", col_names = FALSE) +grey_date <- t(grey_date) +grey_sw <- t(grey_sw) +grey <- data_frame(grey_date,grey_sw) +names(grey)[1] <- "date" +names(grey)[2] <- "sw_120" +grey_2008 <- grey %>% mutate(year = 2008, treatment = "Grey") %>% select(year, treatment, date, sw_120) +# Combine years +# ------------- +blue <- bind_rows(blue_2006, blue_2007, blue_2008) +red <- bind_rows(red_2006, red_2007, red_2008) +green <- bind_rows(green_2006, green_2007, green_2008) +grey <- bind_rows(grey_2006, grey_2007, grey_2008) +soilwater <- bind_rows(blue, red, green, grey) +#! /bin/bash +library(tidyverse) +library(readxl) +library(writexl) +library(lubridate) +dir_sourcedata <- file.path("C:","Users","ver078","Dropbox","CottonModel","OldData","Narrabri(Stephen)", "Soil Probe Data") +path <- file.path(dir_sourcedata, "ProbeReading Summary.xls") +#nb. the probes only went down to 120cm. So all the sw measurments are the cumulative sw down to 120cm +# WRITE TO SPREADSHEET +# -------------------- +sheets <- list(Yield = yield, Plant = plant, SoilWater = soilwater) +write_xlsx(x = sheets, path = "./output/narrabri.xlsx") +help("write_xlsx") +help("write_xlsx") +#! /bin/bash +library(tidyverse) +library(readxl) +library(writexl) +library(lubridate) +dir_sourcedata <- file.path("C:","Users","ver078","Dropbox","CottonModel","OldData","Narrabri(Stephen)") +path <- file.path(dir_sourcedata, "Deficit Trials - Output Summary.xls") +# Get Input Data from Spreadsheet +# ------------------------------- +lai_2006 <- read_xls(path, sheet = "Actuals 0607", range = "D4:K8") +bolls_2006 <- read_xls(path, sheet = "Actuals 0607", range = "D12:K16") #actually "fruit count" but I interperate this as boll no. +yield_2006 <- read_xls(path, sheet = "Actuals 0607", range = "D27:E31") +sites_2006 <- read_xls(path, sheet = "Actuals 0607", range = "P4:T8") +lai_2007 <- read_xls(path, sheet = "Actuals 0708", range = "D4:K8") +bolls_2007 <- read_xls(path, sheet = "Actuals 0708", range = "D12:K16") +squares_2007 <- read_xls(path, sheet = "Actuals 0708", range = "D20:K24") +yield_2007 <- read_xls(path, sheet = "Actuals 0708", range = "D27:E31") +sites_2007 <- read_xls(path, sheet = "Actuals 0708", range = "P4:U8") +lai_2008 <- read_xls(path, sheet = "Actuals 0809", range = "D4:K8") +bolls_2008 <- read_xls(path, sheet = "Actuals 0809", range = "D12:K16") +squares_2008 <- read_xls(path, sheet = "Actuals 0809", range = "D20:K24") +yield_2008 <- read_xls(path, sheet = "Actuals 0809", range = "D27:G31") +sites_2008 <- read_xls(path, sheet = "Actuals 0809", range = "P4:U8") +greenbolls_2008 <- read_xls(path, sheet = "Actuals 0809", range = "O12:U16") +openbolls_2008 <- read_xls(path, sheet = "Actuals 0809", range = "O20:U25") +maturity_2008 <- read_xls(path, sheet = "Actuals 0809", range = "P28:Q33") +# Clean up the input data +# ----------------------- +lai_2006 <- lai_2006 %>% select(-2,-3) +lai_2007 <- lai_2007 %>% select(-2,-3) +lai_2008 <- lai_2008 %>% select(-2,-3) +bolls_2006 <- bolls_2006 %>% select(-2,-3) +bolls_2007 <- bolls_2007 %>% select(-2,-3) +bolls_2008 <- bolls_2008 %>% select(-2,-3) +squares_2007 <- squares_2007 %>% select(-2,-3) +squares_2008 <- squares_2008 %>% select(-2,-3) +greenbolls_2008 <- greenbolls_2008 %>% select(-2) +openbolls_2008 <- openbolls_2008 %>% select(-2) +# Munge the Data +# -------------- +# 2006 +# ---- +lai_2006 <- lai_2006 %>% pivot_longer(cols = c("71","86","104","126","161"), names_to = "das", values_to = "lai") +lai_2006 <- lai_2006 %>% pivot_longer(cols = lai, names_to = "variable", values_to = "values") +bolls_2006 <- bolls_2006 %>% pivot_longer(cols = c("71","86","104","126","161"), names_to = "das", values_to = "bolls") +bolls_2006 <- bolls_2006 %>% pivot_longer(cols = bolls, names_to = "variable", values_to = "values") +sites_2006 <- sites_2006 %>% pivot_longer(cols = c("71","86","104","126"), names_to = "das", values_to = "sites") +sites_2006 <- sites_2006 %>% pivot_longer(cols = sites, names_to = "variable", values_to = "values") +plant_2006 <- bind_rows(lai_2006, sites_2006, bolls_2006) +plant_2006 <- plant_2006 %>% pivot_wider(names_from = variable, values_from = values) +plant_2006 <- plant_2006 %>% mutate(year = 2006) %>% select(year, das, Treatment, everything()) +yield_2006 <- yield_2006 %>% mutate(year = 2006) %>% select(year, Treatment, everything()) +# 2007 +# ---- +lai_2007 <- lai_2007 %>% pivot_longer(cols = c("79","92","115","135","170"), names_to = "das", values_to = "lai") +lai_2007 <- lai_2007 %>% pivot_longer(cols = lai, names_to = "variable", values_to = "values") +bolls_2007 <- bolls_2007 %>% pivot_longer(cols = c("79","92","115","135","170"), names_to = "das", values_to = "bolls") +bolls_2007 <- bolls_2007 %>% pivot_longer(cols = bolls, names_to = "variable", values_to = "values") +squares_2007 <- squares_2007 %>% pivot_longer(cols = c("79","92","115","135","170"), names_to = "das", values_to = "squares") +squares_2007 <- squares_2007 %>% pivot_longer(cols = squares, names_to = "variable", values_to = "values") +sites_2007 <- sites_2007 %>% pivot_longer(cols = c("79","92","115","135","170"), names_to = "das", values_to = "sites") +sites_2007 <- sites_2007 %>% pivot_longer(cols = sites, names_to = "variable", values_to = "values") +plant_2007 <- bind_rows(lai_2007, sites_2007, squares_2007, bolls_2007) +plant_2007 <- plant_2007 %>% pivot_wider(names_from = variable, values_from = values) +plant_2007 <- plant_2007 %>% mutate(year = 2007) %>% select(year, das, Treatment, everything()) +yield_2007 <- yield_2007 %>% mutate(year = 2007) %>% select(year, Treatment, everything()) +# 2008 +# ---- +lai_2008 <- lai_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "lai") +lai_2008 <- lai_2008 %>% pivot_longer(cols = lai, names_to = "variable", values_to = "values") +bolls_2008 <- bolls_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "bolls") +bolls_2008 <- bolls_2008 %>% pivot_longer(cols = bolls, names_to = "variable", values_to = "values") +squares_2008 <- squares_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "squares") +squares_2008 <- squares_2008 %>% pivot_longer(cols = squares, names_to = "variable", values_to = "values") +sites_2008 <- sites_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "sites") +sites_2008 <- sites_2008 %>% pivot_longer(cols = sites, names_to = "variable", values_to = "values") +greenbolls_2008 <- greenbolls_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "greenbolls") +greenbolls_2008 <- greenbolls_2008 %>% pivot_longer(cols = greenbolls, names_to = "variable", values_to = "values") +openbolls_2008 <- openbolls_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "openbolls") +openbolls_2008 <- openbolls_2008 %>% pivot_longer(cols = openbolls, names_to = "variable", values_to = "values") +plant_2008 <- bind_rows(lai_2008, sites_2008, squares_2008, bolls_2008, greenbolls_2008, openbolls_2008) +plant_2008 <- plant_2008 %>% pivot_wider(names_from = variable, values_from = values) +plant_2008 <- plant_2008 %>% mutate(year = 2008) %>% select(year, das, Treatment, everything()) +yield_2008 <- yield_2008 %>% mutate(year = 2008) %>% select(year, Treatment, everything()) +# Combined +# -------- +plant <- bind_rows(plant_2006, plant_2007, plant_2008) +yield <- bind_rows(yield_2006, yield_2007, yield_2008) +#! /bin/bash +library(tidyverse) +library(readxl) +library(writexl) +library(lubridate) +dir_sourcedata <- file.path("C:","Users","ver078","Dropbox","CottonModel","OldData","Narrabri(Stephen)", "Soil Probe Data") +path <- file.path(dir_sourcedata, "ProbeReading Summary.xls") +#nb. the probes only went down to 120cm. So all the sw measurments are the cumulative sw down to 120cm +# 2006 +# ---- +blue_date <- read_xls(path, sheet = "2006-07", range = "C6:AJ6", col_names = FALSE) +blue_sw <- read_xls(path, sheet = "2006-07", range = "C7:AJ7", col_names = FALSE) +blue_date <- t(blue_date) +blue_sw <- t(blue_sw) +blue <- data_frame(blue_date,blue_sw) +names(blue)[1] <- "date" +names(blue)[2] <- "sw_120" +blue_2006 <- blue %>% mutate(year = 2006, treatment = "Blue") %>% select(year, treatment, date, sw_120) +red_date <- read_xls(path, sheet = "2006-07", range = "C11:AJ11", col_names = FALSE) +red_sw <- read_xls(path, sheet = "2006-07", range = "C12:AJ12", col_names = FALSE) +red_date <- t(red_date) +red_sw <- t(red_sw) +red <- data_frame(red_date,red_sw) +names(red)[1] <- "date" +names(red)[2] <- "sw_120" +red_2006 <- red %>% mutate(year = 2006, treatment = "Red") %>% select(year, treatment, date, sw_120) +green_date <- read_xls(path, sheet = "2006-07", range = "C16:AC16", col_names = FALSE) +green_sw <- read_xls(path, sheet = "2006-07", range = "C17:AC17", col_names = FALSE) +green_date <- t(green_date) +green_sw <- t(green_sw) +green <- data_frame(green_date,green_sw) +names(green)[1] <- "date" +names(green)[2] <- "sw_120" +green_2006 <- green %>% mutate(year = 2006, treatment = "Green") %>% select(year, treatment, date, sw_120) +grey_date <- read_xls(path, sheet = "2006-07", range = "C21:Z21", col_names = FALSE) +grey_sw <- read_xls(path, sheet = "2006-07", range = "C22:Z22", col_names = FALSE) +grey_date <- t(grey_date) +grey_sw <- t(grey_sw) +grey <- data_frame(grey_date,grey_sw) +names(grey)[1] <- "date" +names(grey)[2] <- "sw_120" +grey_2006 <- grey %>% mutate(year = 2006, treatment = "Grey") %>% select(year, treatment, date, sw_120) +# 2007 +# ---- +blue_date <- read_xls(path, sheet = "2007-08", range = "C6:AP6", col_names = FALSE) +blue_sw <- read_xls(path, sheet = "2007-08", range = "C7:AP7", col_names = FALSE) +blue_date <- t(blue_date) +blue_sw <- t(blue_sw) +blue <- data_frame(blue_date,blue_sw) +names(blue)[1] <- "date" +names(blue)[2] <- "sw_120" +blue_2007 <- blue %>% mutate(year = 2007, treatment = "Blue") %>% select(year, treatment, date, sw_120) +red_date <- read_xls(path, sheet = "2007-08", range = "C11:AC11", col_names = FALSE) +red_sw <- read_xls(path, sheet = "2007-08", range = "C12:AC12", col_names = FALSE) +red_date <- t(red_date) +red_sw <- t(red_sw) +red <- data_frame(red_date,red_sw) +names(red)[1] <- "date" +names(red)[2] <- "sw_120" +red_2007 <- red %>% mutate(year = 2007, treatment = "Red") %>% select(year, treatment, date, sw_120) +green_date <- read_xls(path, sheet = "2007-08", range = "C16:AB16", col_names = FALSE) +green_sw <- read_xls(path, sheet = "2007-08", range = "C17:AB17", col_names = FALSE) +green_date <- t(green_date) +green_sw <- t(green_sw) +green <- data_frame(green_date,green_sw) +names(green)[1] <- "date" +names(green)[2] <- "sw_120" +green_2007 <- green %>% mutate(year = 2007, treatment = "Green") %>% select(year, treatment, date, sw_120) +grey_date <- read_xls(path, sheet = "2007-08", range = "C21:Y21", col_names = FALSE) +grey_sw <- read_xls(path, sheet = "2007-08", range = "C22:Y22", col_names = FALSE) +grey_date <- t(grey_date) +grey_sw <- t(grey_sw) +grey <- data_frame(grey_date,grey_sw) +names(grey)[1] <- "date" +names(grey)[2] <- "sw_120" +grey_2007 <- grey %>% mutate(year = 2007, treatment = "Grey") %>% select(year, treatment, date, sw_120) +# 2008 +# ---- +blue_date <- read_xls(path, sheet = "2008-09", range = "C6:AP6", col_names = FALSE) +blue_sw <- read_xls(path, sheet = "2008-09", range = "C7:AP7", col_names = FALSE) +blue_date <- t(blue_date) +blue_sw <- t(blue_sw) +blue <- data_frame(blue_date,blue_sw) +names(blue)[1] <- "date" +names(blue)[2] <- "sw_120" +blue_2008 <- blue %>% mutate(year = 2008, treatment = "Blue") %>% select(year, treatment, date, sw_120) +red_date <- read_xls(path, sheet = "2008-09", range = "C11:AH11", col_names = FALSE) +red_sw <- read_xls(path, sheet = "2008-09", range = "C12:AH12", col_names = FALSE) +red_date <- t(red_date) +red_sw <- t(red_sw) +red <- data_frame(red_date,red_sw) +names(red)[1] <- "date" +names(red)[2] <- "sw_120" +red_2008 <- red %>% mutate(year = 2008, treatment = "Red") %>% select(year, treatment, date, sw_120) +green_date <- read_xls(path, sheet = "2008-09", range = "C16:AI16", col_names = FALSE) +green_sw <- read_xls(path, sheet = "2008-09", range = "C17:AI17", col_names = FALSE) +green_date <- t(green_date) +green_sw <- t(green_sw) +green <- data_frame(green_date,green_sw) +names(green)[1] <- "date" +names(green)[2] <- "sw_120" +green_2008 <- green %>% mutate(year = 2008, treatment = "Green") %>% select(year, treatment, date, sw_120) +grey_date <- read_xls(path, sheet = "2008-09", range = "C21:Z21", col_names = FALSE) +grey_sw <- read_xls(path, sheet = "2008-09", range = "C22:Z22", col_names = FALSE) +grey_date <- t(grey_date) +grey_sw <- t(grey_sw) +grey <- data_frame(grey_date,grey_sw) +names(grey)[1] <- "date" +names(grey)[2] <- "sw_120" +grey_2008 <- grey %>% mutate(year = 2008, treatment = "Grey") %>% select(year, treatment, date, sw_120) +# Combine years +# ------------- +blue <- bind_rows(blue_2006, blue_2007, blue_2008) +red <- bind_rows(red_2006, red_2007, red_2008) +green <- bind_rows(green_2006, green_2007, green_2008) +grey <- bind_rows(grey_2006, grey_2007, grey_2008) +soilwater <- bind_rows(blue, red, green, grey) +#! /bin/bash +library(tidyverse) +library(readxl) +library(writexl) +library(lubridate) +dir_sourcedata <- file.path("C:","Users","ver078","Dropbox","CottonModel","OldData","Narrabri(Stephen)", "Soil Probe Data") +path <- file.path(dir_sourcedata, "ProbeReading Summary.xls") +#nb. the probes only went down to 120cm. So all the sw measurments are the cumulative sw down to 120cm +# WRITE TO SPREADSHEET +# -------------------- +sheets <- list(Yield = yield, Plant = plant, SoilWater = soilwater) +write_xlsx(x = sheets, path = "./output/narrabri.xlsx") +help("write_xlsx") diff --git a/Prototypes/Cotton/munge-experiment-data/output/APSIMClassicValidation.xlsx b/Prototypes/Cotton/munge-experiment-data/output/APSIMClassicValidation.xlsx index 839b3b9551..fa15d36aaa 100644 Binary files a/Prototypes/Cotton/munge-experiment-data/output/APSIMClassicValidation.xlsx and b/Prototypes/Cotton/munge-experiment-data/output/APSIMClassicValidation.xlsx differ diff --git a/Prototypes/Cotton/munge-experiment-data/output/ayr.xlsx b/Prototypes/Cotton/munge-experiment-data/output/ayr.xlsx index d117546151..0d91477acd 100644 Binary files a/Prototypes/Cotton/munge-experiment-data/output/ayr.xlsx and b/Prototypes/Cotton/munge-experiment-data/output/ayr.xlsx differ diff --git a/Prototypes/Cotton/munge-experiment-data/output/emerald.xlsx b/Prototypes/Cotton/munge-experiment-data/output/emerald.xlsx index 872c032771..925c6fcb98 100644 Binary files a/Prototypes/Cotton/munge-experiment-data/output/emerald.xlsx and b/Prototypes/Cotton/munge-experiment-data/output/emerald.xlsx differ diff --git a/Prototypes/Cotton/munge-experiment-data/output/narrabri.xlsx b/Prototypes/Cotton/munge-experiment-data/output/narrabri.xlsx new file mode 100644 index 0000000000..520f08632e Binary files /dev/null and b/Prototypes/Cotton/munge-experiment-data/output/narrabri.xlsx differ diff --git a/Prototypes/Cotton/munge-experiment-data/scripts/ayr/ayr.r b/Prototypes/Cotton/munge-experiment-data/scripts/ayr/ayr.r index 0d3850f431..d80036fc84 100644 --- a/Prototypes/Cotton/munge-experiment-data/scripts/ayr/ayr.r +++ b/Prototypes/Cotton/munge-experiment-data/scripts/ayr/ayr.r @@ -57,7 +57,7 @@ bolls <- bind_rows(bolls_2009, bolls_2010, bolls_2011, bolls_2012) #nb. 2008 dat # WRITE TO SPREADSHEET # -------------------- -sheets <- list(Phenology = phenology, Harvest = harvest, Plant = plant, Light = light_interception, Nodes = nodes_over_time, Bolls = bolls) +sheets <- list(Ayr_Phenology = phenology, Ayr_Harvest = harvest, Ayr_Plant = plant, Ayr_Light = light_interception, Ayr_Nodes = nodes_over_time, Ayr_Bolls = bolls) write_xlsx(x = sheets, path = "./output/ayr.xlsx") diff --git a/Prototypes/Cotton/munge-experiment-data/scripts/emerald/emerald.r b/Prototypes/Cotton/munge-experiment-data/scripts/emerald/emerald.r index 42b69ccd5b..c20d193c84 100644 --- a/Prototypes/Cotton/munge-experiment-data/scripts/emerald/emerald.r +++ b/Prototypes/Cotton/munge-experiment-data/scripts/emerald/emerald.r @@ -48,7 +48,7 @@ soilwater <- soilwater %>% select(Clock.Today, SimulationName, everything()) # WRITE TO SPREADSHEET # -------------------- -sheets <- list(Phenology = phenology, Yield = yield, Fruit = fruit, SoilWater = soilwater) +sheets <- list(Emerald_Phenology = phenology, Emerald_Yield = yield, Emerald_Fruit = fruit, Emerald_SoilWater = soilwater) write_xlsx(x = sheets, path = "./output/emerald.xlsx") diff --git a/Prototypes/Cotton/munge-experiment-data/scripts/narrabri/narrabri.r b/Prototypes/Cotton/munge-experiment-data/scripts/narrabri/narrabri.r new file mode 100644 index 0000000000..831bfd00e5 --- /dev/null +++ b/Prototypes/Cotton/munge-experiment-data/scripts/narrabri/narrabri.r @@ -0,0 +1,51 @@ +#! /bin/bash + + +library(tidyverse) + +library(readxl) +library(writexl) + +library(lubridate) + + +dir_sourcedata <- file.path("C:","Users","ver078","Dropbox","CottonModel","OldData","Narrabri(Stephen)", "Soil Probe Data") +path <- file.path(dir_sourcedata, "ProbeReading Summary.xls") + + +#nb. the probes only went down to 120cm. So all the sw measurments are the cumulative sw down to 120cm + + + + + +# ADD SimulationName Column and Clock.Today column +# ------------------------------------------------ +# nb. this is needed to do predicted vs observed in ApsimX + +yield <- yield %>% mutate("Clock.Today" = format(date, "%d/%m/%Y")) +yield <- yield %>% mutate(SimulationName = paste("Narrabri_", year, "Sow", Treatment, sep = "")) +yield <- yield %>% select(Clock.Today, SimulationName, everything()) + +plant <- plant %>% mutate("Clock.Today" = format(date, "%d/%m/%Y")) +plant <- plant %>% mutate(SimulationName = paste("Narrabri_", year, "Sow", Treatment, sep = "")) +plant <- plant %>% select(Clock.Today, SimulationName, everything()) + +soilwater <- soilwater %>% mutate("Clock.Today" = format(date, "%d/%m/%Y")) +soilwater <- soilwater %>% mutate(SimulationName = paste("Narrabri_", year, "Sow", treatment, sep = "")) +soilwater <- soilwater %>% select(Clock.Today, SimulationName, everything()) + + + + + + + + +# WRITE TO SPREADSHEET +# -------------------- + +sheets <- list(Narrabri_Yield = yield, Narrabri_Plant = plant, Narrabri_SoilWater = soilwater) +write_xlsx(x = sheets, path = "./output/narrabri.xlsx") + + diff --git a/Prototypes/Cotton/munge-experiment-data/scripts/narrabri/narrabri_actuals.r b/Prototypes/Cotton/munge-experiment-data/scripts/narrabri/narrabri_actuals.r index 7fb5bf1837..fc664a90c4 100644 --- a/Prototypes/Cotton/munge-experiment-data/scripts/narrabri/narrabri_actuals.r +++ b/Prototypes/Cotton/munge-experiment-data/scripts/narrabri/narrabri_actuals.r @@ -14,24 +14,133 @@ path <- file.path(dir_sourcedata, "Deficit Trials - Output Summary.xls") + +# Get Input Data from Spreadsheet +# ------------------------------- + lai_2006 <- read_xls(path, sheet = "Actuals 0607", range = "D4:K8") -boll_no_2006 <- read_xls(path, sheet = "Actuals 0607", range = "D12:K16") #actually "fruit count" but I interperate this as boll no. +bolls_2006 <- read_xls(path, sheet = "Actuals 0607", range = "D12:K16") #actually "fruit count" but I interperate this as boll no. yield_2006 <- read_xls(path, sheet = "Actuals 0607", range = "D27:E31") -sites_no_2006 <- read_xls(path, sheet = "Actuals 0607", range = "P4:T8") +sites_2006 <- read_xls(path, sheet = "Actuals 0607", range = "P4:T8") lai_2007 <- read_xls(path, sheet = "Actuals 0708", range = "D4:K8") -boll_no_2007 <- read_xls(path, sheet = "Actuals 0708", range = "D12:K16") -square_no_2007 <- read_xls(path, sheet = "Actuals 0708", range = "D20:K24") +bolls_2007 <- read_xls(path, sheet = "Actuals 0708", range = "D12:K16") +squares_2007 <- read_xls(path, sheet = "Actuals 0708", range = "D20:K24") yield_2007 <- read_xls(path, sheet = "Actuals 0708", range = "D27:E31") -sites_no_2007 <- read_xls(path, sheet = "Actuals 0708", range = "P4:T8") +sites_2007 <- read_xls(path, sheet = "Actuals 0708", range = "P4:U8") lai_2008 <- read_xls(path, sheet = "Actuals 0809", range = "D4:K8") -boll_no_2008 <- read_xls(path, sheet = "Actuals 0809", range = "D12:K16") -square_no_2008 <- read_xls(path, sheet = "Actuals 0809", range = "D20:K24") -yield_2008 <- read_xls(path, sheet = "Actuals 0809", range = "D27:E31") -sites_no_2008 <- read_xls(path, sheet = "Actuals 0809", range = "P4:T8") -greenboll_no_2008 <- read_xls(path, sheet = "Actuals 0809", range = "P4:T8") -openboll_no_2008 <- read_xls(path, sheet = "Actuals 0809", range = "P4:T8") -maturity_2008 <- read_xls(path, sheet = "Actuals 0809", range = "P4:T8") \ No newline at end of file +bolls_2008 <- read_xls(path, sheet = "Actuals 0809", range = "D12:K16") +squares_2008 <- read_xls(path, sheet = "Actuals 0809", range = "D20:K24") +yield_2008 <- read_xls(path, sheet = "Actuals 0809", range = "D27:G31") +sites_2008 <- read_xls(path, sheet = "Actuals 0809", range = "P4:U8") +greenbolls_2008 <- read_xls(path, sheet = "Actuals 0809", range = "O12:U16") +openbolls_2008 <- read_xls(path, sheet = "Actuals 0809", range = "O20:U25") +maturity_2008 <- read_xls(path, sheet = "Actuals 0809", range = "P28:Q33") + + + +# Clean up the input data +# ----------------------- + +lai_2006 <- lai_2006 %>% select(-2,-3) +lai_2007 <- lai_2007 %>% select(-2,-3) +lai_2008 <- lai_2008 %>% select(-2,-3) + +bolls_2006 <- bolls_2006 %>% select(-2,-3) +bolls_2007 <- bolls_2007 %>% select(-2,-3) +bolls_2008 <- bolls_2008 %>% select(-2,-3) + +squares_2007 <- squares_2007 %>% select(-2,-3) +squares_2008 <- squares_2008 %>% select(-2,-3) + +greenbolls_2008 <- greenbolls_2008 %>% select(-2) +openbolls_2008 <- openbolls_2008 %>% select(-2) + + + + +# Munge the Data +# -------------- + + +# 2006 +# ---- + +lai_2006 <- lai_2006 %>% pivot_longer(cols = c("71","86","104","126","161"), names_to = "das", values_to = "lai") +lai_2006 <- lai_2006 %>% pivot_longer(cols = lai, names_to = "variable", values_to = "values") +bolls_2006 <- bolls_2006 %>% pivot_longer(cols = c("71","86","104","126","161"), names_to = "das", values_to = "bolls") +bolls_2006 <- bolls_2006 %>% pivot_longer(cols = bolls, names_to = "variable", values_to = "values") +sites_2006 <- sites_2006 %>% pivot_longer(cols = c("71","86","104","126"), names_to = "das", values_to = "sites") +sites_2006 <- sites_2006 %>% pivot_longer(cols = sites, names_to = "variable", values_to = "values") + +plant_2006 <- bind_rows(lai_2006, sites_2006, bolls_2006) +plant_2006 <- plant_2006 %>% pivot_wider(names_from = variable, values_from = values) +plant_2006 <- plant_2006 %>% mutate(date = dmy("10/10/2006") + days(das)) +plant_2006 <- plant_2006 %>% mutate(year = 2006) %>% select(year, Treatment, date, das, everything()) + +yield_2006 <- yield_2006 %>% mutate(date = dmy("10/10/2006") + days(163)) # I have no idea what the harvest date was so I used das=163 because last value in long table in "Actuals 0607" worksheet +yield_2006 <- yield_2006 %>% mutate(year = 2006) %>% select(year, Treatment, everything()) + + +# 2007 +# ---- + +lai_2007 <- lai_2007 %>% pivot_longer(cols = c("79","92","115","135","170"), names_to = "das", values_to = "lai") +lai_2007 <- lai_2007 %>% pivot_longer(cols = lai, names_to = "variable", values_to = "values") +bolls_2007 <- bolls_2007 %>% pivot_longer(cols = c("79","92","115","135","170"), names_to = "das", values_to = "bolls") +bolls_2007 <- bolls_2007 %>% pivot_longer(cols = bolls, names_to = "variable", values_to = "values") +squares_2007 <- squares_2007 %>% pivot_longer(cols = c("79","92","115","135","170"), names_to = "das", values_to = "squares") +squares_2007 <- squares_2007 %>% pivot_longer(cols = squares, names_to = "variable", values_to = "values") +sites_2007 <- sites_2007 %>% pivot_longer(cols = c("79","92","115","135","170"), names_to = "das", values_to = "sites") +sites_2007 <- sites_2007 %>% pivot_longer(cols = sites, names_to = "variable", values_to = "values") + +plant_2007 <- bind_rows(lai_2007, sites_2007, squares_2007, bolls_2007) +plant_2007 <- plant_2007 %>% pivot_wider(names_from = variable, values_from = values) +plant_2007 <- plant_2007 %>% mutate(date = dmy("15/10/2007") + days(das)) +plant_2007 <- plant_2007 %>% mutate(year = 2007) %>% select(year, Treatment, date, das, everything()) + + +yield_2007 <- yield_2007 %>% mutate(date = dmy("15/10/2007") + days(218)) # I have no idea what the harvest date was so I used das=218 because last value in long table in "Actuals 0607" worksheet +yield_2007 <- yield_2007 %>% mutate(year = 2007) %>% select(year, Treatment, everything()) + + + +# 2008 +# ---- + +lai_2008 <- lai_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "lai") +lai_2008 <- lai_2008 %>% pivot_longer(cols = lai, names_to = "variable", values_to = "values") +bolls_2008 <- bolls_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "bolls") +bolls_2008 <- bolls_2008 %>% pivot_longer(cols = bolls, names_to = "variable", values_to = "values") +squares_2008 <- squares_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "squares") +squares_2008 <- squares_2008 %>% pivot_longer(cols = squares, names_to = "variable", values_to = "values") +sites_2008 <- sites_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "sites") +sites_2008 <- sites_2008 %>% pivot_longer(cols = sites, names_to = "variable", values_to = "values") +greenbolls_2008 <- greenbolls_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "greenbolls") +greenbolls_2008 <- greenbolls_2008 %>% pivot_longer(cols = greenbolls, names_to = "variable", values_to = "values") +openbolls_2008 <- openbolls_2008 %>% pivot_longer(cols = c("76","90","116","137","165"), names_to = "das", values_to = "openbolls") +openbolls_2008 <- openbolls_2008 %>% pivot_longer(cols = openbolls, names_to = "variable", values_to = "values") + +plant_2008 <- bind_rows(lai_2008, sites_2008, squares_2008, bolls_2008, greenbolls_2008, openbolls_2008) +plant_2008 <- plant_2008 %>% pivot_wider(names_from = variable, values_from = values) +plant_2008 <- plant_2008 %>% mutate(date = dmy("15/10/2008") + days(das)) +plant_2008 <- plant_2008 %>% mutate(year = 2008) %>% select(year, Treatment, date, das, everything()) + +yield_2008 <- yield_2008 %>% mutate(date = dmy("15/10/2008") + days(218)) # I have no idea what the harvest date was so I used das=218 because last value in long table in "Actuals 0607" worksheet +yield_2008 <- yield_2008 %>% mutate(year = 2008) %>% select(year, Treatment, everything()) + + +# Combined +# -------- + +plant <- bind_rows(plant_2006, plant_2007, plant_2008) + +yield <- bind_rows(yield_2006, yield_2007, yield_2008) + + + + + diff --git a/Prototypes/Cotton/munge-experiment-data/scripts/narrabri/narrabri_soilprobe.r b/Prototypes/Cotton/munge-experiment-data/scripts/narrabri/narrabri_soilprobe.r new file mode 100644 index 0000000000..4921b347eb --- /dev/null +++ b/Prototypes/Cotton/munge-experiment-data/scripts/narrabri/narrabri_soilprobe.r @@ -0,0 +1,166 @@ +#! /bin/bash + + +library(tidyverse) + +library(readxl) +library(writexl) + +library(lubridate) + + +dir_sourcedata <- file.path("C:","Users","ver078","Dropbox","CottonModel","OldData","Narrabri(Stephen)", "Soil Probe Data") +path <- file.path(dir_sourcedata, "ProbeReading Summary.xls") + + +#nb. the probes only went down to 120cm. So all the sw measurments are the cumulative sw down to 120cm + + +# 2006 +# ---- + +blue_date <- read_xls(path, sheet = "2006-07", range = "C6:AJ6", col_names = FALSE) +blue_sw <- read_xls(path, sheet = "2006-07", range = "C7:AJ7", col_names = FALSE) +blue_date <- t(blue_date) %>% as.Date() +blue_sw <- t(blue_sw) +blue <- tibble(date = blue_date, sw_120 = blue_sw) +# names(blue)[1] <- "date" +# names(blue)[2] <- "sw_120" +blue_2006 <- blue %>% mutate(year = 2006, treatment = "Blue") %>% select(year, treatment, date, sw_120) + + +red_date <- read_xls(path, sheet = "2006-07", range = "C11:AJ11", col_names = FALSE) +red_sw <- read_xls(path, sheet = "2006-07", range = "C12:AJ12", col_names = FALSE) +red_date <- t(red_date) %>% as.Date() +red_sw <- t(red_sw) +red <- tibble(date = red_date, sw_120 = red_sw) +# names(red)[1] <- "date" +# names(red)[2] <- "sw_120" +red_2006 <- red %>% mutate(year = 2006, treatment = "Red") %>% select(year, treatment, date, sw_120) + + +green_date <- read_xls(path, sheet = "2006-07", range = "C16:AC16", col_names = FALSE) +green_sw <- read_xls(path, sheet = "2006-07", range = "C17:AC17", col_names = FALSE) +green_date <- t(green_date) %>% as.Date() +green_sw <- t(green_sw) +green <- tibble(date = green_date, sw_120 = green_sw) +# names(green)[1] <- "date" +# names(green)[2] <- "sw_120" +green_2006 <- green %>% mutate(year = 2006, treatment = "Green") %>% select(year, treatment, date, sw_120) + + +grey_date <- read_xls(path, sheet = "2006-07", range = "C21:Z21", col_names = FALSE) +grey_sw <- read_xls(path, sheet = "2006-07", range = "C22:Z22", col_names = FALSE) +grey_date <- t(grey_date) %>% as.Date() +grey_sw <- t(grey_sw) +grey <- tibble(date = grey_date, sw_120 = grey_sw) +# names(grey)[1] <- "date" +# names(grey)[2] <- "sw_120" +grey_2006 <- grey %>% mutate(year = 2006, treatment = "Grey") %>% select(year, treatment, date, sw_120) + + + + +# 2007 +# ---- + +blue_date <- read_xls(path, sheet = "2007-08", range = "C6:AP6", col_names = FALSE) +blue_sw <- read_xls(path, sheet = "2007-08", range = "C7:AP7", col_names = FALSE) +blue_date <- t(blue_date) %>% as.Date() +blue_sw <- t(blue_sw) +blue <- tibble(date = blue_date, sw_120 = blue_sw) +# names(blue)[1] <- "date" +# names(blue)[2] <- "sw_120" +blue_2007 <- blue %>% mutate(year = 2007, treatment = "Blue") %>% select(year, treatment, date, sw_120) + + +red_date <- read_xls(path, sheet = "2007-08", range = "C11:AC11", col_names = FALSE) +red_sw <- read_xls(path, sheet = "2007-08", range = "C12:AC12", col_names = FALSE) +red_date <- t(red_date) %>% as.Date() +red_sw <- t(red_sw) +red <- tibble(date = red_date, sw_120 = red_sw) +# names(red)[1] <- "date" +# names(red)[2] <- "sw_120" +red_2007 <- red %>% mutate(year = 2007, treatment = "Red") %>% select(year, treatment, date, sw_120) + + +green_date <- read_xls(path, sheet = "2007-08", range = "C16:AB16", col_names = FALSE) +green_sw <- read_xls(path, sheet = "2007-08", range = "C17:AB17", col_names = FALSE) +green_date <- t(green_date) %>% as.Date() +green_sw <- t(green_sw) +green <- tibble(date = green_date, sw_120 = green_sw) +# names(green)[1] <- "date" +# names(green)[2] <- "sw_120" +green_2007 <- green %>% mutate(year = 2007, treatment = "Green") %>% select(year, treatment, date, sw_120) + + +grey_date <- read_xls(path, sheet = "2007-08", range = "C21:Y21", col_names = FALSE) +grey_sw <- read_xls(path, sheet = "2007-08", range = "C22:Y22", col_names = FALSE) +grey_date <- t(grey_date) %>% as.Date() +grey_sw <- t(grey_sw) +grey <- tibble(date = grey_date, sw_120 = grey_sw) +# names(grey)[1] <- "date" +# names(grey)[2] <- "sw_120" +grey_2007 <- grey %>% mutate(year = 2007, treatment = "Grey") %>% select(year, treatment, date, sw_120) + + + + +# 2008 +# ---- + +blue_date <- read_xls(path, sheet = "2008-09", range = "C6:AP6", col_names = FALSE) +blue_sw <- read_xls(path, sheet = "2008-09", range = "C7:AP7", col_names = FALSE) +blue_date <- t(blue_date) %>% as.Date() +blue_sw <- t(blue_sw) +blue <- tibble(date = blue_date, sw_120 = blue_sw) +# names(blue)[1] <- "date" +# names(blue)[2] <- "sw_120" +blue_2008 <- blue %>% mutate(year = 2008, treatment = "Blue") %>% select(year, treatment, date, sw_120) + + +red_date <- read_xls(path, sheet = "2008-09", range = "C11:AH11", col_names = FALSE) +red_sw <- read_xls(path, sheet = "2008-09", range = "C12:AH12", col_names = FALSE) +red_date <- t(red_date) %>% as.Date() +red_sw <- t(red_sw) +red <- tibble(date = red_date, sw_120 = red_sw) +# names(red)[1] <- "date" +# names(red)[2] <- "sw_120" +red_2008 <- red %>% mutate(year = 2008, treatment = "Red") %>% select(year, treatment, date, sw_120) + + +green_date <- read_xls(path, sheet = "2008-09", range = "C16:AI16", col_names = FALSE) +green_sw <- read_xls(path, sheet = "2008-09", range = "C17:AI17", col_names = FALSE) +green_date <- t(green_date) %>% as.Date() +green_sw <- t(green_sw) +green <- tibble(date = green_date, sw_120 = green_sw) +# names(green)[1] <- "date" +# names(green)[2] <- "sw_120" +green_2008 <- green %>% mutate(year = 2008, treatment = "Green") %>% select(year, treatment, date, sw_120) + + +grey_date <- read_xls(path, sheet = "2008-09", range = "C21:Z21", col_names = FALSE) +grey_sw <- read_xls(path, sheet = "2008-09", range = "C22:Z22", col_names = FALSE) +grey_date <- t(grey_date) %>% as.Date() +grey_sw <- t(grey_sw) +grey <- tibble(date = grey_date, sw_120 = grey_sw) +# names(grey)[1] <- "date" +# names(grey)[2] <- "sw_120" +grey_2008 <- grey %>% mutate(year = 2008, treatment = "Grey") %>% select(year, treatment, date, sw_120) + + + +# Combine years +# ------------- + +blue <- bind_rows(blue_2006, blue_2007, blue_2008) +red <- bind_rows(red_2006, red_2007, red_2008) +green <- bind_rows(green_2006, green_2007, green_2008) +grey <- bind_rows(grey_2006, grey_2007, grey_2008) + +soilwater <- bind_rows(blue, red, green, grey) + + + + + diff --git a/Prototypes/Cotton/narrabri.xlsx b/Prototypes/Cotton/narrabri.xlsx new file mode 100644 index 0000000000..520f08632e Binary files /dev/null and b/Prototypes/Cotton/narrabri.xlsx differ