addDataQuality: Add Data Quality Matrix to PyPam NetCDF

View source: R/addDataQuality.R

addDataQualityR Documentation

Add Data Quality Matrix to PyPam NetCDF

Description

Add or modify the existing data quality matrix data in a PyPam (or similar) hybrid millidecade NetCDF output. This data adds or modifies the "quality_flag" variable of a NetCDF file, which is a matrix of numbers 1,2,3, or 4 that is the same dimensions as the hybrid millidecade outputs. The input NetCDF files are modified unless preview=TRUE

Usage

addDataQuality(
  x,
  annotation = NULL,
  platformColumn = NULL,
  updateUnknown = FALSE,
  preview = FALSE,
  plot = FALSE,
  reset = FALSE,
  verbose = FALSE
)

formatDQDf(annotation)

Arguments

x

one or more NetCDF files or a folder containing NetCDF files. If x is a folder, all files with extension ".nc" will be listed from the first level of the folder (non-recursive)

annotation

a dataframe of annotations specifying the time-frequency bounds and quality flags to be changed. Columns for time bounds must be called start and end, must be in UTC timezone, and either POSIXct format or in YYYY-MM-DD HH:MM:SS. Columns for frequency bounds must be called freqMin and freqMax and have numeric frequency values in Hz. Column for quality code must be called quality and have numeric values from 1,2,3,4. Can also have additional column file specifying that a given annotation only applies to a specific file, or a column to match the "platform" attribute of the NetCDF file (see platformColumn)

platformColumn

NetCDF files should contain a "platform" global attribute, this can be used to specify that certain rows of annotation only apply to certain files in x. This value specifies the name of the column in annotation should be used (e.g. "deployment_code" means annotation$deployment_code contains values that will match the "platform" global attribute)

updateUnknown

if FALSE, then existing quality flags of "2" will not be changed, otherwise flags of "2" will be updated to this value (must be one of 1, 3, or 4)

preview

if TRUE, then no changes are applied to the NetCDF files, instead only plots are shown. It is recommended to run with preview=TRUE first to check that annotations appear to be applied properly

plot

if TRUE, a plot of the quality matrix is shown. If "new", the plot is only shown if any annotations have been applied to the file. If FALSE no plot is created

reset

if TRUE, all quality flag flags are reset to a value of "2" before applying further annotations. Can be useful if incorrect annotations were previously applied. If reset=TRUE and annotation=NULL, then all quality code values will be "2"

verbose

logical flag to show or hide some messages

Value

TRUE or FALSE to indicate whether or not any annotations were applied. If x is multiple files or a folder of files, the returned vector has names equal to the file names

Author(s)

Taiki Sakai taiki.sakai@noaa.gov


PAMscapes documentation built on Oct. 3, 2026, 1:06 a.m.