knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.align = 'center',
  fig.width = 6, 
  fig.height = 4
)
library(opcr)

Process

Reading raw data

Reading and processing the data is all done using opc_process(). This does the following steps:

  1. read in binary OPC data in .D00 file with read_focal_opc()
  2. convert to a nice tabular format with convert_single_opc()
  3. apply various quality control flags with opc_flag()
  4. use a shiny app to interactively select the downcast with opc_trim()

Here's a simple example of how to process the raw OPC data. Note that this requires the user to interactively select the downcast so does not actually run in this vignette.

opc = opc_process(ifile = 'data/raw/OPC033.D00')

OPC data format

The processed data is stored in what I refer to as an opc tibble with the following fields:

scan - the scan number, which increases with each data record
timer - the timer count, which is sent every 0.5 seconds since the unit was powered on and resets after 4095 values
atten - light attenuation
depth - instrument depth in meters
flag - quality control flag, with zero meaning good. See opc_flag() for the other definitions
secs - the number of seconds elapsed since the instrument was powered on
time - the datetime since the unit was powered on
volume_filtered - the volume of water that has passed through the OPC since the previous record, in cubic meters
esd - a nested list of the particle sizes, in Equivalent Spherical Diameter (ESD; mm) detected during this data record

Here's an example:

opc

Data in this format is the cornerstone of this package; all computation and plotting requires this opc tibble as input.

Calculate

Several functions make it convenient to calculate common OPC data products.

Size-frequency histogram

opc_histogram(opc)

Abundance profile

opc_abundance(opc)

Biomass profile

This uses the equation from Suthers et al (2006) to covert size to biomass.

opc_biomass(opc)

Abundance in size and depth matrix

opc_image(opc)

Plot

Here are some quick plots. These take an opc tibble as input, derive the relevant variables using the functions above, then return a nice ggplot. Check the function documentation for more information.

Simple downcast

opc_plot_depth(opc)

Flags

opc_plot_flags(opc)

Attenuation

opc_plot_attenuance(opc)

Histogram

opc_plot_histogram(opc)

Abundance

opc_plot_abundance(opc)

Biomass

opc_plot_biomass(opc)

Image

opc_plot_image(opc)

Multipanel

opc_plot_multipanel(opc)

Diagnostics

opc_plot_diagnostics(opc)


hansenjohnson/opcr documentation built on Jan. 24, 2023, 5:04 a.m.