Skip to content

Commit

Permalink
Merge pull request #4770 from ver078/cotton
Browse files Browse the repository at this point in the history
Cotton
  • Loading branch information
hol353 authored Mar 2, 2020
2 parents fb26ef5 + a17557f commit fb03546
Show file tree
Hide file tree
Showing 13 changed files with 872 additions and 19 deletions.
25 changes: 20 additions & 5 deletions Prototypes/Cotton/Cotton_Shaun.apsimx
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down Expand Up @@ -6511,20 +6511,35 @@
"$type": "Models.PostSimulationTools.ExcelInput, Models",
"FileName": "emerald.xlsx",
"SheetNames": [
"Yield",
"Fruit",
"SoilWater"
"Emerald_Phenology",
"Emerald_Yield",
"Emerald_Fruit",
"Emerald_SoilWater"
],
"Name": "Emerald",
"Children": [],
"IncludeInDocumentation": false,
"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,
Expand Down
Binary file modified Prototypes/Cotton/emerald.xlsx
Binary file not shown.
512 changes: 512 additions & 0 deletions Prototypes/Cotton/munge-experiment-data/.Rhistory

Large diffs are not rendered by default.

Binary file not shown.
Binary file modified Prototypes/Cotton/munge-experiment-data/output/ayr.xlsx
Binary file not shown.
Binary file modified Prototypes/Cotton/munge-experiment-data/output/emerald.xlsx
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Prototypes/Cotton/munge-experiment-data/scripts/ayr/ayr.r
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down
Original file line number Diff line number Diff line change
@@ -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")


Original file line number Diff line number Diff line change
Expand Up @@ -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")
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)





Loading

0 comments on commit fb03546

Please sign in to comment.