Type: Package
Title: Calculate Single Station Metabolism from Diurnal Oxygen Curves
Version: 1.1.3
Date: 2023-10-09
Author: Stephen A Sefick Jr.
Maintainer: Stephen A Sefick Jr. <ssefick@gmail.com>
URL: https://github.com/ssefick/StreamMetabolism
Depends: zoo, chron, suntools
Description: I provide functions to calculate Gross Primary Productivity, Net Ecosystem Production, and Ecosystem Respiration from single station diurnal Oxygen curves.
License: GPL (≥ 3)
LazyLoad: yes
Repository: CRAN
NeedsCompilation: no
Packaged: 2023-10-17 12:05:20 UTC; root
Date/Publication: 2023-10-17 12:50:07 UTC

Iternal .Random.seed

Description

Internal .Random.seed

Details

This is not to be called by the user.


Iternal .required

Description

Internal .required

Details

This is not to be called by the user.


Saturation Concentration at temp

Description

Calculates the concentration(mg/L) @ 100

Usage

Cs(x)

Arguments

x

Temperature in Degrees Celcius

Details

enter one temperature or a zoo time series of temperature

Value

single value or time series of mg/L@saturation for that temperature

Author(s)

Stephen A Sefick Jr.

References

APHA (2005). Standard Methods for the Examination of Water and Wastewater. 21st Edition. Eds: Eaton, A.D., L.S. Clesceri, E.W. Rice and A. E. Greenberg. Washington D.C., published jointly by the American Public Health Association, the American Water Works Association and the Water Environment Federation.

Examples

#single temperature
temp <- sample(20:30, 1)
Cs(temp)

#USGS Data (DOTemp)
library(chron)
library(zoo)
data(DOTemp)
Cs(DOTemp[,1])

Rhode River Street Pier–Maryland data set

Description

Test data set from Stephens and Jennings SWProd calculator (USGS). The data has been interpolated to make it have readings every fifteen minutes.

Usage

data(DOTemp)

Format

DateTime

DateTime

Temp

Temperature in Celcius

DO

Dissolved Oxygen

Details

This is only for example and should be used judiciously for any kind of ecosystem interpretation (requires zoo and chron packages).

Source

Stephens, D.W., and Jennings, M.E., 1976, Determination of primary productivity and community metabolism in streams and lakes using diel oxygen measurements: U.S. Geological Survey Computer Contribution, 100 p.


Temperature Correction For Reaeration Value

Description

Temperature Correction For Reaeration Value. Corrects reaeration value to temperature of the stream.

Usage

Kt(K, temp)

Arguments

K

Rearation Coefficient single value or in a zoo object

temp

temperature value at time t in Degrees Celcius

Value

Single Values or zoo series

Author(s)

Stephen A Sefick Jr

References

Thyssen, N., Erlandsen, M., Jeppesen, E., Holm T. F.,1983. Modelling the reaeration capacity of low-land streams dominated by submerged macrophytes. In: Lauenroth, W.K., Skogerboe, G.V., Flug, M. (Eds.), Analysis of Ecological Systems: State of the Art in Ecological Modelling. Elsevier, pp. 861-867 as reported in Izagirre O., M. Bermejo, J. Pozo, and A. Elosegi. 2007. RIVERMET: An Excel-based tool to calculate river metabolism from diel oxygen-concentration curves. Environmental Modelling & Software, 22:24-32.

Examples

#data USGS
data(DOTemp)
#velocity 0.6, depth 0.4572
d <- ODobbins(0.6, 0.4572)
Kcorr <- Kt(d , DOTemp[,1])

O'Conner Dobbins Surface Renewal Method for calculating Rearration Coeffiecient

Description

calculate reaeration coefficient with the O'Conner Dobbins method

Usage

ODobbins(vel, dep)

Arguments

vel

velocity in m/s

dep

depth in meters

Details

Surface Renewal

Value

Reaeration Cofficient (1/d)

Author(s)

Stephen A Sefick Jr.

References

O'Connor, D. J., and W. E. Dobbins (1958). Mechanisms of reaeration in natural streams. Transactions of American Society of Civil Engineers, 123: 641-666.

Examples

#velocity 0.6
#depth 0.4572
ODobbins(0.6, 0.4572)

Calculate Ecosystem Production with the Single Station Method

Description

Calculate ER, NEP, and GPP from diurnal oxygen curves.

Usage

SM(depth, min_interval, DO, temp,
K, day, sr="00:00:00", ss="23:45:00",
start="00:00:00", end="23:45:00")

Arguments

depth

depth m K

min_interval

time resolution (e.g., 15 min)

temp

Zoo time Series temperature in degrees Celcius (see details)

DO

Zoo time Series Dissolved Oxygen in mg/L (see details)

day

date of the day of interest must be in quotes

start

time of the start of the "day" usually 00:00:00 must be in quotes

end

time of the end of the "day" usually 23:45:00 must be in quotes

sr

time of sunrise in the form 04:22:00 must be in quotes

ss

time of sunset in the form 19:23:00 must be in quotes

K

K at 20 deg. C (1/dt; e.g., 1/15min)

Details

The input data has to be a zoo time series constructed with a chron date time object of month/day/year hr:min:sec (i.e., 08/18/70 23:15:00)

sr and ss should be after and before the start and end of the time series, respectively.

ER is calculated as sum Et (i.e, mean nighttime NEP corrected for the difference in daytime temp and average nighttime temp)

GPP is calculated by summing NEP-ERt from sunrise to sunset

NEP=ER+GPP

Tested Against Rivermet spreadsheet (Izagirre 2007). The data from station 1 (7/10 - 7/15/2003) were used with K=0.07 from "Introduced K". ER, NEP, and GPP are in mg/L*d. The results were not identical. When Estimation from rivermet was regressed on estimation from this software, GPP, ER, and NEP intercepts did not differ significantly from 0 and slopes were nearly 1: 0.94, 0.91, and 0.95, respectively. Further testing is greatly appreciated.

Value

ER

Ecosystem Respiration

NEP

Net Ecosystem Production

GPP

Gross Primary Productivity

Author(s)

Stephen A Sefick Jr.

References

Odum, H. T. (1956). "Primary production in flowing waters." Limnology and Oceanography, 1: 102-117.

Thyssen, N., Erlandsen, M., Jeppesen, E., Holm T. F.,1983. Modelling the reaeration capacity of low-land streams

M.R. Grace and S.J. Imberger. 2006. "Stream Metabolism: Performing & Interpreting Measurements". Water Studies Centre Monash University, Murray Darling Basin Commission and New South Wales Department of Environment and Climate Change. 204 pp. Accessed at http://www.sci.monash.edu.au/wsc/docs/tech-manual-v3.pdf

Izagirre, O., M. Bermejo, J. Pozo, and A. Elosegi. 2007. RIVERMET: An Excel-based tool to calculate river metabolism from diel oxygen concentration curves. Environmental Modelling and Software, 22: 24-32.

Examples

#zoo real data
#velocity 0.6
#depth 0.4572
#sunrise 6:00AM
#sunset 8:15PM
#K/96 to get K per dt (i.e., 96 15 min interval in 1 day)
data(DOTemp)

K <- ODobbins(0.6, 0.4572)
prod <- SM(min_interval=15, K=K/96,
depth=0.4572, temp=DOTemp[,1], DO=DOTemp[,2],
day="8/18/70", start="00:00:00",
end="23:45:00", sr="06:00:00", ss="20:15:00")
prod


Internal StreamMetabolism objects

Description

Internal SteamMetabolism objects.

Details

These are not to be called by the user.


Convert from cubic feet per second to liters per second

Description

Convert from cubic feet persecond to liters per second

Usage

cfs.lps(x)

Arguments

x

Discharge in cfs

Author(s)

Stephen A Sefick Jr.


contiguous.zoo

Description

find continuous non NA portions of zoo time series data

Usage

contiguous.zoo(x)

Arguments

x

zoo time series object whatever indexes you want

Details

if you want to just find the contiguous portions of just one signal and not the interaction between two just duplicate the signal contiguous.zoo(data.frame(x, coredata(x))) should give you what you want

Value

data frame constiting of

start

start index

end

end index

lengths

length of record

value

logical stating whether a continuous string of non-NA values

Author(s)

Gabor Grothendieck and Stephen A Sefick Jr.


Change in Oxygen per time step

Description

Calculate the rate of change of Dissolved Oxygen

Usage

dC.dt(x)

Arguments

x

Dissolved Oxygen time series

Details

input zoo series takes the difference of DOt+1 - DOt

Value

zoo series of Dissolved Oxygen Differences with an NA for the first value as there is no value before that to subtract

Author(s)

Stephen A Sefick Jr.

References

Odum, H. T. (1956). "Primary production in flowing waters." Limnology and Oceanography, 1: 102-117.

Examples

data(DOTemp)
Diffconc <- dC.dt(DOTemp[,2])
plot(Diffconc)

Format Dates

Description

Used in the FUN argument of read.zoo for dates in the format mm/dd/yyyy hh:mm:ss

Usage

fmt.chron(x)

Arguments

x

Data Time Column

Details

used internally in read.production

Author(s)

Stephen A Sefick Jr

See Also

read.production


Liters Per Second to Cubic Feet per Second

Description

Convience Function for converting from liters per second to cubic feet per second

Usage

lps.cfs(x)

Arguments

x

Discharge in Liters per Second

Value

Discharge in Cubic feet per second

Author(s)

Stephen A Sefick Jr

Examples

lps.cfs(134000)

Liters per second to cubic meters per second

Description

Conversion Function

Usage

lps.cms(x)

Arguments

x

discharge in Liters per second

Details

single value or if zoo series - zoo object

Value

single value or if zoo series - zoo object

Author(s)

Stephen A Sefick Jr.

Examples

lps.cms(134000)

Read in Time Series Data as zoo Object

Description

Wrapper Function to read.zoo

Usage

read.production(data)

Arguments

data

a csv file with headers and the date as mm/dd/yyyy hh:mm:ss format (think excel spreadsheet date format and the file is saved as a csv file)

Details

This is a wrapper function to read.zoo with a specific format required see above

Value

zoo object

Author(s)

Stephen A Sefick Jr

See Also

read.table


Numeric Integration Using Simpson's method

Description

Numeric Integration using the Simpson Method

Usage

simp(y, a = NULL, b = NULL, x = NULL, n = 200)

Arguments

y

y values to integrate

x

x values to integrate over

a

NULL

b

NULL

n

number of divisions defaults to 200

Value

Numeric Value of the integration

Author(s)

Rolf Turner

Examples

# 4-x^2-y^2
fun <- function(x, y){
	a <- 4
	b <- x^2
	d <- y^2
	z <- a-b-d
	return(z)
	}
	
a <- fun(seq(-1000,1000,1), seq(-1000,1000,1))
simp(a, x=-1000:1000, n=1000)	

Calculate Sunrise Sunset Times

Description

This function calculates sunrise sunset times in POSIXct and returns it in a handy dandy format to either export as a csv file or use directly in the calculation of Stream Metabolism. This function is based on maptools which is based on the NOAA sunrise sunset claculator.

Usage

sunrise.set(lat, long, date, timezone = "UTC", num.days = 1)

Arguments

lat

Latitude in decimal degrees

long

Longitude in decimal degrees

date

starting date (needs to be in quotes and in the format yyyy/mm/dd)

timezone

Time zone set to UTC default (needs to be in quotes)

num.days

1 if you just want only the calculation preformed on "date" (default)

Details

Remember that the Prime Meridian is 0 through Greenwich, England. So anything W is - and anything E is +. Also anything in the Northern hemisphere is + latitude and Southern Hemisphere is - lattitude. Generally UTC+5 is Eastern Standard Time, UTC+6 is CST, UTC+7 MST, UTC+8 PST. Another way of specifying time zones is Country City see examples. Be aware of timezones and daylight and standard time when using this function!!!!!!! This will help you avoid headaches caused because minor oversites = large error in your calculations

Value

output

data frame with all dates sunrise and sunset times specified

Author(s)

Stephen A Sefick Jr.

References

old site: https://gml.noaa.gov/grad/solcalc/sunrise.html

new site: https://gml.noaa.gov/grad/solcalc/sunrise.html

Examples

#This is for Atlanta Georgia 
#(Only so that you can compare it to the NOAA 
#website that is given above)
sunrise.set(33.43, -84.22, "2008/01/01", timezone="UTC+5") 	

#Same As above but look at Time Zone Specification
sunrise.set(33.43, -84.22, "2008/01/01", timezone="America/New_York")


Time Windows of Diurnal Curves

Description

Takes a time window of a larger series

Usage

window_chron(x, day1, hour1, day2, hour2, ...)

Arguments

x

data to be subsetted

day1

start day

hour1

start time

day2

end date

hour2

end time

...

other arguments

Value

subset by time

Author(s)

Stephen A Sefick Jr.

References

chron, window, window.zoo

See Also

window

Examples

#with real data
data(DOTemp)
d <- window_chron(DOTemp, "8/18/70", "06:00:00", "8/18/70", "20:15:00")
plot(d)