diff --git a/R/swmpr_analyze.R b/R/swmpr_analyze.R index e8b84e3..3dc26d1 100644 --- a/R/swmpr_analyze.R +++ b/R/swmpr_analyze.R @@ -746,7 +746,7 @@ hist.swmpr <- function(x, subset = NULL, select, operator = NULL, ...) { #' dat <- qaqc(apacpnut) #' #' ## plot -#' plot_summary(dat, param = 'chla_n') +#' plot_summary(dat, param = 'chla_n', years = c(2007, 2013)) #' plot_summary <- function(swmpr_in, ...) UseMethod('plot_summary') @@ -849,6 +849,8 @@ plot_summary.swmpr <- function(swmpr_in, param, years = NULL, ...){ # universal plot setting my_theme <- theme(axis.text = element_text(size = 8)) + # browser() + # plot 1 - means and obs cols <- colorRampPalette(c('lightblue', 'lightgreen'))(nrow(mo_agg)) cols <- cols[rank(mo_agg[, param])] @@ -890,13 +892,18 @@ plot_summary.swmpr <- function(swmpr_in, param, years = NULL, ...){ # monthly means by year to_plo <- dat_plo[, names(dat_plo) %in% c('month', 'year', param)] form_in <- as.formula(paste(param, '~ .')) - to_plo <- aggregate(form_in, to_plo, function(x) mean(x, na.rm = T)) + to_plo <- aggregate(form_in, to_plo, function(x) mean(x, na.rm = T), + na.action = na.pass) to_plo$month <- factor(to_plo$month, labels = mo_labs, levels = mo_levs) names(to_plo)[names(to_plo) %in% param] <- 'V1' midpt <- mean(to_plo$V1, na.rm = T) - p4 <- ggplot(to_plo, aes(x = year, y = month, fill = V1)) + + p4 <- ggplot(subset(to_plo, !is.na(V1)), + aes(x = year, y = month, fill = V1)) + geom_tile() + + geom_tile(data = subset(to_plo, is.na(V1)), + aes(x = year, y = month), fill = NA + ) + scale_fill_gradient2(name = ylab, low = 'lightblue', mid = 'lightgreen', high = 'tomato', midpoint = midpt) + theme_classic() + @@ -912,8 +919,12 @@ plot_summary.swmpr <- function(swmpr_in, param, years = NULL, ...){ names(to_plo)[names(to_plo) %in% param] <- 'trend' to_plo$anom <- with(to_plo, V1 - trend) rngs <- max(abs(range(to_plo$anom, na.rm = T))) - p5 <- ggplot(to_plo, aes(x = year, y = month, fill = anom)) + + p5 <- ggplot(subset(to_plo, !is.na(anom)), + aes(x = year, y = month, fill = anom)) + geom_tile() + + geom_tile(data = subset(to_plo, is.na(anom)), + aes(x = year, y = month), fill = NA + ) + scale_fill_gradient2(name = ylab, low = 'lightblue', mid = 'lightgreen', high = 'tomato', midpoint = 0, limits = c(-1 * rngs, rngs)) + @@ -982,7 +993,7 @@ plot_summary.swmpr <- function(swmpr_in, param, years = NULL, ...){ #' #' The open-water method is a common approach to quantify net ecosystem metabolism using a mass balance equation that describes the change in dissolved oxygen over time from the balance between photosynthetic and respiration processes, corrected using an empirically constrained air-sea gas diffusion model (see Ro and Hunt 2006, Thebault et al. 2008). The diffusion-corrected DO flux estimates are averaged separately over each day and night of the time series. The nighttime average DO flux is used to estimate respiration rates, while the daytime DO flux is used to estimate net primary production. To generate daily integrated rates, respiration rates are assumed constant such that hourly night time DO flux rates are multiplied by 24. Similarly, the daytime DO flux rates are multiplied by the number of daylight hours, which varies with location and time of year, to yield net daytime primary production. Respiration rates are subtracted from daily net production estimates to yield gross production rates. The metabolic day is considered the 24 hour period between sunsets on two adjacent calendar days. #' -#' Aereal rates for gross production and total respiration are based on volumetric rates normalized to the depth of the water column at the sampling location, which is assumed to be well-mixed, such that the DO sensor is reflecting the integrated processes in the entire water column (including the benthos). Water column depth is calculated as the mean value of the depth variable across the time series in the \code{\link{swmpr}} object. Depth values are floored at one meter for very shallow stations and 0.5 meters is also added to reflect the practice of placing sensors slightly off of the bottom. Additionally, the air-sea gas exchange model is calibrated with wind data either collected at, or adjusted to, wind speed at 10 m above the surface. The metadata should be consulted for exact height. The value can be changed manually using a \code{height} argument, which is passed to \code{\link{calckl}}. +#' Areal rates for gross production and total respiration are based on volumetric rates normalized to the depth of the water column at the sampling location, which is assumed to be well-mixed, such that the DO sensor is reflecting the integrated processes in the entire water column (including the benthos). Water column depth is calculated as the mean value of the depth variable across the time series in the \code{\link{swmpr}} object. Depth values are floored at one meter for very shallow stations and 0.5 meters is also added to reflect the practice of placing sensors slightly off of the bottom. Additionally, the air-sea gas exchange model is calibrated with wind data either collected at, or adjusted to, wind speed at 10 m above the surface. The metadata should be consulted for exact height. The value can be changed manually using a \code{height} argument, which is passed to \code{\link{calckl}}. #' #' A minimum of three records are required for both day and night periods to calculate daily metabolism estimates. Occasional missing values for air temperature, barometric pressure, and wind speed are replaced with the climatological means (hourly means by month) for the period of record using adjacent data within the same month as the missing data. #' diff --git a/README.Rmd b/README.Rmd index f096078..3c9be6b 100644 --- a/README.Rmd +++ b/README.Rmd @@ -350,13 +350,12 @@ data(apacpnut) dat <- qaqc(apacpnut) ## plot -plot_summary(dat, param = 'chla_n') +plot_summary(dat, param = 'chla_n', years = c(2007, 2013)) ``` Estimates of ecosystem metabolism provide a useful measure of overall system productivity. These estimates are commonly used to evaluate whether an ecosystem is a net source or sink of organic material. The open-water method is a common approach to quantify net ecosystem metabolism using a mass balance equation that describes the change in dissolved oxygen over time from the balance between photosynthetic and respiration rates, corrected for air-sea gas diffusion at the surface. The diffusion-corrected DO flux estimates are averaged during day and night for each 24 hour period in the time series, where flux is an hourly rate of DO change. DO flux is averaged during night hours for respiration and averaged during day hours for net production. Respiration rates are assumed constant during day and night such that total daily rates are calculated as hourly respiration multiplied by 24. The metabolic day is considered the 24 hour period between sunsets on two adjacent calendar days. Respiration is subtracted from daily net production estimates to yield gross production. -The `ecometab` function is used to implement an adaptation of the open-water method. -Several assumptions must be met for a valid interpretation of the results. In general, the dissolved oxygen time series is assumed to represent the same water mass over time. Tidal advection may have a significant influence on the time series, which can contribute to a significant amount of noise in metabolic estimates. The extent to which tidal advection influences the dissolved oxygen signal depends on various site-level characteristics and an intimate knowledge of the site may be required. Volumetric rates for gross production and total respiration are also based on total depth of the water column, which is assumed to be mixed. Water column depth is based on mean value for the depth variable across the time series and is floored at 1 meter for very shallow stations. Additionally, the volumetric reaeration coefficient requires an estimate of the anemometer height of the weather station, which is set as 10 meters by default. The metadata should be consulted for exact height. Other assumptions may apply and the user should consult the relevant literature (see the references in the help file). All estimates are in mmol of oxygen but can be converted to grams by changing the default arguments (i.e., 1mmol O2 = 32 mg O2, 1000 mg = 1g, multiply all estimates by 32/1000). +The `ecometab` function is used to implement an adaptation of the open-water method. Several assumptions must be met for a valid interpretation of the results. In general, the dissolved oxygen time series is assumed to represent the same water mass over time. Tidal advection may have a significant influence on the time series, which can contribute to a significant amount of noise in metabolic estimates. The extent to which tidal advection influences the dissolved oxygen signal depends on various site-level characteristics and an intimate knowledge of the site may be required. Volumetric rates for gross production and total respiration are also based on total depth of the water column, which is assumed to be mixed. Water column depth is based on mean value for the depth variable across the time series and is floored at 1 meter for very shallow stations. Additionally, the volumetric reaeration coefficient requires an estimate of the anemometer height of the weather station, which is set as 10 meters by default. The metadata should be consulted for exact height. Other assumptions may apply and the user should consult the relevant literature (see the references in the help file). All estimates are in mmol of oxygen but can be converted to grams by changing the default arguments (i.e., 1mmol O2 = 32 mg O2, 1000 mg = 1g, multiply all estimates by 32/1000). The following is an example that shows how to use the function from a combined water quality and weather data set. The results can be plotted using `plot_metab`. diff --git a/README.html b/README.html index 8414542..0c889c4 100644 --- a/README.html +++ b/README.html @@ -338,10 +338,10 @@

An overview of methods for swmpr objects

dat <- qaqc(apacpnut) ## plot -plot_summary(dat, param = 'chla_n') +plot_summary(dat, param = 'chla_n', years = c(2007, 2013))

plot of chunk unnamed-chunk-21

Estimates of ecosystem metabolism provide a useful measure of overall system productivity. These estimates are commonly used to evaluate whether an ecosystem is a net source or sink of organic material. The open-water method is a common approach to quantify net ecosystem metabolism using a mass balance equation that describes the change in dissolved oxygen over time from the balance between photosynthetic and respiration rates, corrected for air-sea gas diffusion at the surface. The diffusion-corrected DO flux estimates are averaged during day and night for each 24 hour period in the time series, where flux is an hourly rate of DO change. DO flux is averaged during night hours for respiration and averaged during day hours for net production. Respiration rates are assumed constant during day and night such that total daily rates are calculated as hourly respiration multiplied by 24. The metabolic day is considered the 24 hour period between sunsets on two adjacent calendar days. Respiration is subtracted from daily net production estimates to yield gross production.

-

The ecometab function is used to implement an adaptation of the open-water method.
Several assumptions must be met for a valid interpretation of the results. In general, the dissolved oxygen time series is assumed to represent the same water mass over time. Tidal advection may have a significant influence on the time series, which can contribute to a significant amount of noise in metabolic estimates. The extent to which tidal advection influences the dissolved oxygen signal depends on various site-level characteristics and an intimate knowledge of the site may be required. Volumetric rates for gross production and total respiration are also based on total depth of the water column, which is assumed to be mixed. Water column depth is based on mean value for the depth variable across the time series and is floored at 1 meter for very shallow stations. Additionally, the volumetric reaeration coefficient requires an estimate of the anemometer height of the weather station, which is set as 10 meters by default. The metadata should be consulted for exact height. Other assumptions may apply and the user should consult the relevant literature (see the references in the help file). All estimates are in mmol of oxygen but can be converted to grams by changing the default arguments (i.e., 1mmol O2 = 32 mg O2, 1000 mg = 1g, multiply all estimates by 32/1000).

+

The ecometab function is used to implement an adaptation of the open-water method. Several assumptions must be met for a valid interpretation of the results. In general, the dissolved oxygen time series is assumed to represent the same water mass over time. Tidal advection may have a significant influence on the time series, which can contribute to a significant amount of noise in metabolic estimates. The extent to which tidal advection influences the dissolved oxygen signal depends on various site-level characteristics and an intimate knowledge of the site may be required. Volumetric rates for gross production and total respiration are also based on total depth of the water column, which is assumed to be mixed. Water column depth is based on mean value for the depth variable across the time series and is floored at 1 meter for very shallow stations. Additionally, the volumetric reaeration coefficient requires an estimate of the anemometer height of the weather station, which is set as 10 meters by default. The metadata should be consulted for exact height. Other assumptions may apply and the user should consult the relevant literature (see the references in the help file). All estimates are in mmol of oxygen but can be converted to grams by changing the default arguments (i.e., 1mmol O2 = 32 mg O2, 1000 mg = 1g, multiply all estimates by 32/1000).

The following is an example that shows how to use the function from a combined water quality and weather data set. The results can be plotted using plot_metab.

## import water quality and weather data
 data(apadbwq)
diff --git a/README.md b/README.md
index 8a2e651..d63afe7 100644
--- a/README.md
+++ b/README.md
@@ -398,15 +398,14 @@ data(apacpnut)
 dat <- qaqc(apacpnut)
 
 ## plot
-plot_summary(dat, param = 'chla_n')
+plot_summary(dat, param = 'chla_n', years = c(2007, 2013))
 ```
 
 ![plot of chunk unnamed-chunk-21](README_files/figure-html/unnamed-chunk-21.png) 
 
 Estimates of ecosystem metabolism provide a useful measure of overall system productivity.  These estimates are commonly used to evaluate whether an ecosystem is a net source or sink of organic material.  The open-water method is a common approach to quantify net ecosystem metabolism using a mass balance equation that describes the change in dissolved oxygen over time from the balance between photosynthetic and respiration rates, corrected for air-sea gas diffusion at the surface.  The diffusion-corrected DO flux estimates are averaged during day and night for each 24 hour period in the time series, where flux is an hourly rate of DO change. DO flux is averaged during night hours for respiration and averaged during day hours for net production. Respiration rates are assumed constant during day and night such that total daily rates are calculated as hourly respiration multiplied by 24. The metabolic day is considered the 24 hour period between sunsets on two adjacent calendar days.  Respiration is subtracted from daily net production estimates to yield gross production.  
 
-The `ecometab` function is used to implement an adaptation of the open-water method.  
-Several assumptions must be met for a valid interpretation of the results.  In general, the dissolved oxygen time series is assumed to represent the same water mass over time.  Tidal advection may have a significant influence on the time series, which can contribute to a significant amount of noise in metabolic estimates.  The extent to which tidal advection influences the dissolved oxygen signal depends on various site-level characteristics and an intimate knowledge of the site may be required.  Volumetric rates for gross production and total respiration are also based on total depth of the water column, which is assumed to be mixed.  Water column depth is based on mean value for the depth variable across the time series and is floored at 1 meter for very shallow stations.  Additionally, the volumetric reaeration coefficient requires an estimate of the anemometer height of the weather station, which is set as 10 meters by default.  The metadata should be consulted for exact height. Other assumptions may apply and the user should consult the relevant literature (see the references in the help file).  All estimates are in mmol of oxygen but can be converted  to grams by changing the default arguments (i.e., 1mmol O2 = 32 mg O2, 1000 mg = 1g, multiply all estimates by 32/1000). 
+The `ecometab` function is used to implement an adaptation of the open-water method.  Several assumptions must be met for a valid interpretation of the results.  In general, the dissolved oxygen time series is assumed to represent the same water mass over time.  Tidal advection may have a significant influence on the time series, which can contribute to a significant amount of noise in metabolic estimates.  The extent to which tidal advection influences the dissolved oxygen signal depends on various site-level characteristics and an intimate knowledge of the site may be required.  Volumetric rates for gross production and total respiration are also based on total depth of the water column, which is assumed to be mixed.  Water column depth is based on mean value for the depth variable across the time series and is floored at 1 meter for very shallow stations.  Additionally, the volumetric reaeration coefficient requires an estimate of the anemometer height of the weather station, which is set as 10 meters by default.  The metadata should be consulted for exact height. Other assumptions may apply and the user should consult the relevant literature (see the references in the help file).  All estimates are in mmol of oxygen but can be converted  to grams by changing the default arguments (i.e., 1mmol O2 = 32 mg O2, 1000 mg = 1g, multiply all estimates by 32/1000). 
 
 The following is an example that shows how to use the function from a combined water quality and weather data set.  The results can be plotted using `plot_metab`.
 
diff --git a/README_cache/html/unnamed-chunk-21_25730de7146413ffd27d010457528451.RData b/README_cache/html/unnamed-chunk-21_25730de7146413ffd27d010457528451.RData
deleted file mode 100644
index dd7991a..0000000
Binary files a/README_cache/html/unnamed-chunk-21_25730de7146413ffd27d010457528451.RData and /dev/null differ
diff --git a/README_cache/html/unnamed-chunk-21_72ae25950162c321e8675a05a4ccd9c0.RData b/README_cache/html/unnamed-chunk-21_72ae25950162c321e8675a05a4ccd9c0.RData
new file mode 100644
index 0000000..fe42595
Binary files /dev/null and b/README_cache/html/unnamed-chunk-21_72ae25950162c321e8675a05a4ccd9c0.RData differ
diff --git a/README_cache/html/unnamed-chunk-21_25730de7146413ffd27d010457528451.rdb b/README_cache/html/unnamed-chunk-21_72ae25950162c321e8675a05a4ccd9c0.rdb
similarity index 100%
rename from README_cache/html/unnamed-chunk-21_25730de7146413ffd27d010457528451.rdb
rename to README_cache/html/unnamed-chunk-21_72ae25950162c321e8675a05a4ccd9c0.rdb
diff --git a/README_cache/html/unnamed-chunk-21_25730de7146413ffd27d010457528451.rdx b/README_cache/html/unnamed-chunk-21_72ae25950162c321e8675a05a4ccd9c0.rdx
similarity index 100%
rename from README_cache/html/unnamed-chunk-21_25730de7146413ffd27d010457528451.rdx
rename to README_cache/html/unnamed-chunk-21_72ae25950162c321e8675a05a4ccd9c0.rdx
diff --git a/README_files/figure-html/unnamed-chunk-21.png b/README_files/figure-html/unnamed-chunk-21.png
index b7632ff..10596c2 100644
Binary files a/README_files/figure-html/unnamed-chunk-21.png and b/README_files/figure-html/unnamed-chunk-21.png differ