HARPgroup / HARParchive

This repo houses HARP code development items, resources, and intermediate work products.
1 stars 0 forks source link

Week of 5/1/2023 & 5/8/2023 #813

Open juliabruneau opened 1 year ago

juliabruneau commented 1 year ago

Tasks from our weekly meeting:

Discoveries:

juliabruneau commented 1 year ago

Command to run 3 models at the same time:

rmarkdown::render('C:/Users/VT_SA/Documents/GitHub/HARParchive/HARP-2022-Summer/AutomatedScripts/ws_model_summary.Rmd',
                             output_file = 'C:/Users/VT_SA/Documents/HARP/MarkdownSummaryTest',
                             params = list( doc_title = ("Test HSP2 Model Summary"),
                             rseg.file.path = c("/media/model/p6/out/river/hsp2_2022/hydr/JA4_7280_7340_hydrd_wy.csv", "/media/model/p6/out/river/subsheds/hydr/JA4_7280_7340_hydrd_wy.csv", "/media/model/p6/out/river/subsheds/hydr/JA4_7280_7340_hydrd_wy.csv" ),
                             rseg.hydrocode = c("JA4_7280_7340","vahydrosw_wshed_JA4_7280_7340", "vahydrosw_wshed_JA4_7280_7340"),
                             rseg.ftype = c("cbp60","vahydro", "vahydro"),
                             rseg.model.version = c("cbp-6.0","cbp-6.1", "cbp-6.1"),
                             runid.list = c("hsp2_2022","subsheds", "subsheds"),
                             rseg.metric.list = c("7q10", "l90_Qout", "l30_year")
                            )
               )

Scatterplot with 3 models in it: image

If we could find 3 models within a river segment, it would give us a more realistic result, since this is just repeating one of the models twice for testing purposes. @rburghol @jdkleiner

juliabruneau commented 1 year ago

Box Plot with 3 Models

ignore the data - it was just made up in order to have 3 models...

I was able to plot the flow metrics at the same xaxis location: image

This was done by first stacking both model %diff data into one column, and then adding a 3rd column that gave a mutual column name to both the mean values, l90 values....

values       ind   V3
1 -0.0123069 Mean Flow Mean
2 -0.0123069 Mean Flow Mean
3 -0.0123069 Mean Flow Mean
4 -0.0123069 Mean Flow Mean
5 -0.0123069 Mean Flow Mean
6 -0.0123069 Mean Flow Mean
...
values  ind V3
215 -23.94453 l1.1 l1
216 -46.53405 l1.1 l1
217 -83.37953 l1.1 l1
218 -29.90746 l1.1 l1
219 -55.41005 l1.1 l1
220 -90.19874 l1.1 l1

That way I was able to fill the colors in the box plots by the flow metric. Overall code:

if (length(rseg.model.version) == 3) {

  binded <- cbind(perc.diff.data, perc.diff.data.2)[order(c(seq_along(perc.diff.data), seq_along(perc.diff.data.2)))]
  box.data <- stack(binded)
  mean <- rep("Mean", times = nrow(binded)*2)
  l90 <- rep("l90", times = nrow(binded)*2)
  l30 <- rep("l30", times = nrow(binded)*2)
  l7 <- rep("l7", times = nrow(binded)*2)
  l1 <- rep("l1", times = nrow(binded)*2)
  box.data[3] <- rep(c(mean,l90,l30,l7,l1), times = 1)

  perc.diff.fig <- ggplot() +
    geom_boxplot(box.data, mapping = aes(x = ind, y = values, fill = V3), position = "dodge") +
    geom_boxplot(outlier.colour="red", outlier.shape=8,
                  outlier.size=3) +
    stat_boxplot(geom ='errorbar') + 
    scale_x_discrete(name = "Models Compared",
                     labels = rep(c("1v2","1v3"),5)) +
    scale_y_continuous(name = "% Difference") +
    scale_fill_brewer() + 
    labs(fill="Flow Metric") +
    theme_light()

  perc.diff.fig
}
juliabruneau commented 1 year ago

Work Left on the Markdown - Final Update from Julia

I was able to finish generating the scatterplots and boxplots with 3 models. Those details are commented above.

The 1 thing with actual code that I didn't finish is to display the scatter plots at a 1:1 ratio.

Other final tasks include overall formatting any annotations/figure captions, and seeing what the best output figure heights and widths we should set for all the different figures. Now that we know it can be done in between each chunk, it should be pretty straight forward.

Then finally testing with 3 models that are actually from the same river segments, and 3 different models within it.