diff --git a/COWAT/WatASit[v1].pcl b/COWAT/WatASit[v1].pcl old mode 100644 new mode 100755 diff --git a/COWAT/WatASit[v1].pst b/COWAT/WatASit[v1].pst old mode 100644 new mode 100755 diff --git a/COWAT/WatASit[v1]_bb.pcl b/COWAT/WatASit[v1]_bb.pcl old mode 100644 new mode 100755 diff --git a/COWAT/WatASit[v1]_bb.pst b/COWAT/WatASit[v1]_bb.pst old mode 100644 new mode 100755 diff --git a/COWAT/data/canal.txt b/COWAT/data/canal.txt old mode 100644 new mode 100755 diff --git a/COWAT/data/debit.csv b/COWAT/data/debit.csv old mode 100644 new mode 100755 diff --git a/COWAT/data/etp.csv b/COWAT/data/etp.csv old mode 100644 new mode 100755 diff --git a/COWAT/data/farmplot.txt b/COWAT/data/farmplot.txt old mode 100644 new mode 100755 diff --git a/COWAT/data/fontaigneux.csv b/COWAT/data/fontaigneux.csv old mode 100644 new mode 100755 diff --git a/COWAT/data/ia.txt b/COWAT/data/ia.txt old mode 100644 new mode 100755 diff --git a/COWAT/data/pluie.csv b/COWAT/data/pluie.csv old mode 100644 new mode 100755 diff --git a/COWAT/data/runoff.txt b/COWAT/data/runoff.txt old mode 100644 new mode 100755 diff --git a/COWAT/data/wintake.txt b/COWAT/data/wintake.txt old mode 100644 new mode 100755 diff --git a/COWAT/maps/altitude.asc b/COWAT/maps/altitude.asc old mode 100644 new mode 100755 diff --git a/COWAT/maps/data_bruno_div1ZOOM.env b/COWAT/maps/data_bruno_div1ZOOM.env old mode 100644 new mode 100755 diff --git a/COWAT/maps/geol1.asc b/COWAT/maps/geol1.asc old mode 100644 new mode 100755 diff --git a/COWAT/maps/mnt1.asc b/COWAT/maps/mnt1.asc old mode 100644 new mode 100755 diff --git a/COWAT/maps/ocs1.asc b/COWAT/maps/ocs1.asc old mode 100644 new mode 100755 diff --git a/COWAT/maps/out.env b/COWAT/maps/out.env old mode 100644 new mode 100755 diff --git a/COWAT/maps/soil.asc b/COWAT/maps/soil.asc old mode 100644 new mode 100755 diff --git a/COWAT/maps/soil1.asc b/COWAT/maps/soil1.asc old mode 100644 new mode 100755 diff --git a/COWAT/maps/spatial_ent.env b/COWAT/maps/spatial_ent.env old mode 100644 new mode 100755 diff --git a/COWAT/maps/spatial_ent[2015]_div1.env b/COWAT/maps/spatial_ent[2015]_div1.env old mode 100644 new mode 100755 diff --git a/COWAT/maps/spatial_ent[2015]_div1ZOOM.env b/COWAT/maps/spatial_ent[2015]_div1ZOOM.env old mode 100644 new mode 100755 diff --git a/COWAT/maps/spatial_ent[2015]_div1ZOOM_SAUV(ASAonly).env b/COWAT/maps/spatial_ent[2015]_div1ZOOM_SAUV(ASAonly).env old mode 100644 new mode 100755 diff --git a/COWAT/maps/spatial_ent[2015]_div2.env b/COWAT/maps/spatial_ent[2015]_div2.env old mode 100644 new mode 100755 diff --git a/COWAT/maps/spatial_ent[2015]_div3.env b/COWAT/maps/spatial_ent[2015]_div3.env old mode 100644 new mode 100755 diff --git a/COWAT/maps/spatial_ent[2015]_div4.env b/COWAT/maps/spatial_ent[2015]_div4.env old mode 100644 new mode 100755 diff --git a/COWAT/maps/spatial_ent[2015]_div5.env b/COWAT/maps/spatial_ent[2015]_div5.env old mode 100644 new mode 100755 diff --git a/COWAT/maps/streams1.asc b/COWAT/maps/streams1.asc old mode 100644 new mode 100755 diff --git a/COWAT/maps/test.env b/COWAT/maps/test.env old mode 100644 new mode 100755 diff --git a/OptirigInWatASit.R b/OptirigInWatASit.R new file mode 100644 index 0000000000000000000000000000000000000000..6f8206471992233bb019ee1bbcf5f781432171d2 --- /dev/null +++ b/OptirigInWatASit.R @@ -0,0 +1,84 @@ + +library(tidyr) +library(ggplot2) + +# set directories for R-cormas + r_cormas_dir <- "/home/bonte/git/r-cormas" + +############ +## Pilote-daily-step-function## +############ + #NB: meto include pluie mÊtÊo +runPiloteStep <- function(parcellId, lai, irrigation, meteo) { + res <- data.frame(id = parcellId, lai = lai + 1, hi = lai / 30 ) + return(res) +} + +##################### +## RUN Cormas cowat## +##################### + +###################### +#### Init model ###### +###################### +setwd(r_cormas_dir) +#load the cormas functions +source("cormas-func.R") + +r <- openModel("COWAT", parcelFile="WatASit[v5.9.3].pcl") + +# Activate probes about crops (Facultatif: to get data from cormas) +r <- activateProbe("idProbe","ECrop") +r <- activateProbe("laiProbe","ECrop") +r <- activateProbe("dailyWaterRecieved","ECrop") + +# r <- Choose initial state and time step function (scenarios) +r <- setInit("INIT_2017_54x44") +r <- setStep("goHourlyWithouRiverStep:") + +#Set simulation duration +simDayNb <- 153 + +############################## +##### Simulate coupled model### +############################## +days <- c() +riverFlows <- c() + +#Initialise simulation + r <- initSimu() + +#Create a dataFrame +cropResults <- data.frame(id = 0, lai = 0, hi = 0, irrigation =0 ) +cropResults <- data.frame(id = NULL, lai = NULL, hi = NULL, irrigation =NULL, day = NULL ) + +#Run a simulation of simDayNb days +for (day in 1:simDayNb){ + + ## Simulate 24 hours of cormas + r <- runSimu(duration = 24) + + # Get the state of crops + lais <- getAttributesOfEntities("lai", "ECrop") + irrigations <- getAttributesOfEntities("dailyWaterRecieved", "ECrop") + rains <- getAttributesOfEntities("rain", "ECrop") + + #Simulate the new state of crops with pilote + newCropState <- runPiloteStep(parcellId = lais$ids, lai = lais$values, irrigation = irrigations$values, rain = rains$values) + + #Set the new state of crops in cormas + setAttributesOfEntities("lai", "ECrop", newCropState$id, newCropState$lai) + setAttributesOfEntities("hi", "ECrop", newCropState$id, newCropState$hi) + + #Save results in R (even though they are also in cormas) + newCropState$irrigation <- irrigations$values + newCropState$day <- day + cropResults <- rbind(cropResults, newCropState ) +} + +#Observe the evolution of parcells states in Cormas.. +# To do in Cormas + + + + diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/WatASit100.zip b/WatASit100.zip old mode 100644 new mode 100755 diff --git a/r-cormas-cowat-example.R b/r-cormas-cowat-example.R old mode 100644 new mode 100755