@@ -324,6 +324,46 @@ fig6_shade_gpp <- function(shade_gpp, site_lai) {
324324 y = " Proportion shaded GPP" )
325325}
326326
327+ # ' @rdname fig1_sensor_heights
328+ # ' @export
329+ fig7_le_rn_flux <- function (eb_result ) {
330+ classif <- eb_result %> %
331+ mutate(EB_MODEL_dT = EB_MODEL_Tl - LAYER_TA - 273.15 ) %> %
332+ filter(abs(EB_MODEL_dT ) > 0.5 ) %> %
333+ mutate(
334+ temp_group = factor (ifelse(EB_MODEL_dT < 0 , " cold" , " hot" ), levels = c(" hot" , " cold" ))
335+ )
336+
337+ label_vec <- c(
338+ " EB_MODEL_LE" = " Latent heat (λE)" ,
339+ " EB_MODEL_Rn" = " Net radiation (Rn)"
340+ )
341+
342+ classif %> %
343+ select(temp_group , EB_MODEL_Rn , EB_MODEL_LE ) %> %
344+ pivot_longer(contains(" EB_MODEL" )) %> %
345+ ggplot(aes(x = value )) +
346+ geom_density(aes(fill = temp_group , y = after_stat(scaled ))) +
347+ scale_fill_manual(
348+ values = c(" hot" = " #fdb863" , " cold" = " #0571b0" ),
349+ labels = expression(Delta * " T > 0.5 K" , Delta * " T < -0.5 K" )
350+ ) +
351+ facet_wrap(~ name ,
352+ labeller = as_labeller(label_vec ),
353+ scales = " free_x" ) +
354+ labs(x = expression(" Flux magnitude (W m" ^- 2 * " )" ),
355+ y = " Relative density" ,
356+ fill = " " ) +
357+ theme_bw() +
358+ theme(axis.text.y = element_blank(),
359+ axis.ticks.y = element_blank(),
360+ legend.position = " inside" ,
361+ legend.justification.inside = c(.95 ,.9 ),
362+ legend.title = element_blank(),
363+ legend.background = element_rect(fill = NA ))+
364+ guides(fill = guide_legend(override.aes = list (alpha = 1 )))
365+ }
366+
327367
328368# Supplemental figures ----
329369
@@ -434,6 +474,57 @@ fig_s5_g1_sensitivity <- function(wref_g1_regressions) {
434474 ))
435475}
436476
477+ # ' @rdname fig1_sensor_heights
478+ # ' @export
479+ fig_s6_omega_density <- function (eb_result ) {
480+ eb_result %> %
481+ group_by(SITE_NEON ) %> %
482+ mutate(
483+ canopy_group = case_when(
484+ LAYER_L == max(LAYER_L ) ~ " Lower" ,
485+ LAYER_L == 0 ~ " Upper" ,
486+ .default = " Middle"
487+ ),
488+ canopy_group = factor (canopy_group , levels = c(" Lower" , " Middle" , " Upper" ))
489+ ) %> %
490+ ggplot(aes(x = EB_MODEL_omega , y = SITE_NEON )) +
491+ # ggridges::geom_density_ridges(scale=1) +
492+ # Include relative canopy position?
493+ ggridges :: geom_density_ridges(aes(fill = canopy_group ), alpha = 0.75 , scale = 0.9 ) +
494+ xlim(0 , 0.4 ) +
495+ scale_y_discrete(limits = rev ) +
496+ labs(y = " " ,
497+ x = expression(" Decoupling coefficient (" * Omega * " )" ),
498+ fill = " Canopy position" )
499+ }
500+
501+ # ' @rdname fig1_sensor_heights
502+ # ' @export
503+ fig_s7_flux_boxplots <- function (eb_result ) {
504+ eb_result %> %
505+ select(SITE_NEON , LAYER_L , EB_MODEL_H , EB_MODEL_Rn , EB_MODEL_LE ) %> %
506+ group_by(SITE_NEON ) %> %
507+ rename(
508+ " H" = EB_MODEL_H ,
509+ " Rn" = EB_MODEL_Rn ,
510+ " λE" = EB_MODEL_LE
511+ ) %> %
512+ mutate(
513+ canopy_group = case_when(
514+ LAYER_L == max(LAYER_L ) ~ " Lower" ,
515+ LAYER_L == 0 ~ " Upper" ,
516+ .default = " Middle"
517+ ),
518+ canopy_group = factor (canopy_group , levels = c(" Lower" , " Middle" , " Upper" ))
519+ ) %> %
520+ pivot_longer(all_of(c(" H" , " Rn" , " λE" )), names_to = " flux" , values_to = " value" ) %> %
521+ ggplot(aes(x = value , y = canopy_group )) +
522+ geom_boxplot(aes(fill = flux ), position = " dodge" ) +
523+ geom_vline(xintercept = 0 , linetype = " dashed" ) +
524+ facet_wrap(SITE_NEON ~ . ) +
525+ labs(x = expression(" Flux magnitude" ~ " (" * W ~ m ^- 2 * " )" ), fill = " " , y = " " )
526+ }
527+
437528# Spit out all figures ----
438529# Helper function to prevent overwrites
439530safe_save <- function (filename , plot , allow_overwrite = FALSE , ... ) {
@@ -576,6 +667,11 @@ write_all_figures <- function(site_meta, search_dir, out_dir, overwrite=FALSE,
576667 allow_overwrite = overwrite ,
577668 width = 4.5 , height = 3 )
578669
670+ safe_save(file.path(out_dir , " fig7_le_rn_flux.png" ),
671+ fig7_le_rn_flux(eb_result ),
672+ allow_overwrite = overwrite ,
673+ width = 4.5 , height = 2.5 )
674+
579675 # ## Supplemental ----
580676 safe_save(file.path(out_dir , " fig_s1_lidar_fit.png" ),
581677 fig_s1_lidar_fit(lidar_constants_df , iv_io_data ),
@@ -601,4 +697,14 @@ write_all_figures <- function(site_meta, search_dir, out_dir, overwrite=FALSE,
601697 fig_s5_g1_sensitivity(wref_g1_regressions ),
602698 allow_overwrite = overwrite ,
603699 width = 8 , height = 6 )
700+
701+ safe_save(file.path(out_dir , " fig_s6_omega_density.png" ),
702+ fig_s6_omega_density(eb_result ),
703+ allow_overwrite = overwrite ,
704+ width = 4.5 , height = 3 )
705+
706+ safe_save(file.path(out_dir , " fig_s7_flux_boxplots.png" ),
707+ fig_s7_flux_boxplots(eb_result ),
708+ allow_overwrite = overwrite ,
709+ width = 7.5 , height = 6 )
604710}
0 commit comments