Skip to content

A simple forward model of an estuarine dissolved oxygen time series.

Notifications You must be signed in to change notification settings

jmarriola/fwoxy

Repository files navigation

fwoxy.R

Jill M. Arriola, Maria Herrmann, and Marcus Beck

R-CMD-check

Description

This R package, fwoxy, is a simple forward oxygen mass balance model that predicts the oxygen concentration of a well-mixed water column given the initial conditions and forcings. The primary use of this model is as a lab component for a marine biogeochemistry course to further understanding of biogeochemical and physical processes that influence ecosystem metabolism.

The development version of this package can be installed from Github:

install.packages('devtools')
library(devtools)
devtools::install_github('jmarriola/fwoxy')

Functions

There are six functions included in this package:

  1. fun_density.R - Calculates the density of seawater.
  2. fun_eqb_oxygen.R - Determines the oxygen equilibrium between the water column and air.
  3. fun_gas_transfer_velocity.R - Estimates the gas transfer velocity across the air-sea interface.
  4. fun_par_sin_model.R - Creates the PAR signal using a sin wave model.
  5. fun_schmidt_oxygen.R - Determines the Schmidt number, a unitless number used in calculating gas transfer velocity.
  6. fwoxy.R - The main function which sources the prior listed functions and runs the forward oxygen model.

Note: Functions 1 - 5 are sourced by the fwoxy.R function and do not need to be called separately. These functions should not be modified on their own.

Running fwoxy

Before identifying parameters for the model, load fwoxy for fwoxy.R to run:

library(fwoxy)

Inputs: Parameters and forcings of the model

First, set the initial concentration of oxygen in the water column (oxy_ic). Next, set the parameters of the light efficiency (a_param) and ecosystem respiration (er_param). Equilibrium values for oxy_ic, a_param, and er_param are 250 (mmol/m3), 0.2 ((mmol/m3)/day)/(W/m2)), and 20 (mmol/m3/day), respectively.

# Set model parameters
oxy_ic <- 250           # (mmol/m^3), initial oxygen concentration
a_param <- 0.2          # ((mmol/m^3)/day)/(W/m^2), light efficiency
er_param <- 20          # (mmol/m^3/day), ecosystem respiration

Finally, set the forcings of the model. Currently, the model only accepts a constant value for each of the forcings. The forcings are depth of the well-mixed water column (ht_const), salinity (salt_const), water temperature (temp_const), and windspeed at 10 m height (wspd_const). Equilibrium values for ht_const, salt_const, temp_const, and wspd_const are 3 (m), 25 (ppt), 25 (deg C), and 3 (m/s), respectively.

# Constant Forcings
ht_const <- 3           # m, height of the water column
salt_const <- 25        # ppt, salinity
temp_const <- 25        # deg C, water temperature
wspd_const <- 3         # m/s, wind speed at 10 m

Although atmospheric pressure is used to calculate seawater density, in this forward model the atmospheric pressure is not defined by the user and is pre-set to 0 in the functions.

Recommendations for the ranges of the input parameters and forcings and their equilibrium values (listed below) are based on the minimum and 95th percentile values from data collected at the Cat Point Apalachicola Bay, Florida, NERR station from the year 2012.

Input Min Max Equilibrium
oxy_ic 100 300 250
a_param 0.1 1.0 0.2
er_param 0 80 20
ht_const 0.5 5.0 3.0
salt_const 5 35 25
temp_const 15 30 25
wspd_const 0 6 3

Running the forward model

Once the inputs of the parameters and the forcings are set, you can now run the model. Before running the model select a unique name so that you can easily identify the results of this specific run. This object will store the results of the model outputs (here, example is used as the object). To include the argument values set for the constant parameters and forcings, you must call them in the function as shown here:

example <- fwoxy(oxy_ic = oxy_ic, a_param = a_param, er_param = er_param, 
                 ht_in = ht_const, salt_in = salt_const, temp_in = temp_const,
                 wspd_in = wspd_const)

Outputs

The forward model will output a data frame to the R environment that can be saved as a .csv file in the working directory using the following code:

write.csv(example, "example.csv", row.names = FALSE)

In addition to the data frame, the fwoxy function will create two plots in the Plots view in RStudio (see examples below). The top figure is the forward oxygen concentration time series versus time. This plot illustrates how the dissolved oxygen concentration (mmol/m3) in the water column will change due to the parameters and forcings of the model. The bottom figure is a plot of daily fluxes (mmol/m3/day) of the time rate of change of oxygen (dcdtd), the ecosystem respiration (erd), the gas exchange (gasexd), and the gross primary productivity (gppd) versus time. Neither of these plots will be automatically output to the working drive and will need to be saved by the user.

Outputs

About

A simple forward model of an estuarine dissolved oxygen time series.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages