flux: flux

View source: R/flux.R

fluxR Documentation

flux

Description

Plot cospectrum for flux and calculate flux.

Usage

flux(
  .data,
  .A,
  Acorrection = 0,
  Units = "",
  scaleFactor = 1,
  spans = 49,
  smoothBins = 0,
  legend.position = "bottomleft",
  .plot = TRUE,
  plotRibbon = TRUE,
  printTitle = TRUE,
  wavelengthLimit = 2000,
  Par = NA,
  CSprevious = NA,
  ...
)

Arguments

.data

A Ranadu-convention data.frame containing at least the variables Time, TASX, WIC, and the scalar to use for the flux calculation.

.A

The name of a variable in .data to use as the scalar in the flux calculation.

Acorrection

A vector of length matching the rows in .data that specifies a correction to be applied to .A. This is provided to enable correction of the temperature for dynamic heating, in case the "Par" option below is used to correct the measurements, because the recovery temperature should be corrected before the dynamic-heating correction is subtracted. The sign of this parameter should be negative in that case and will be alphaR*TASX^2/Cp where alphaR is the recovery factor. The default is 0.

Units

A character string or bquote expression for the units. For math expressions this is best provided as a bquote term; e.g., for heat flux, Units = bquote("W"~m^-2). The default is ” giving no units.

scaleFactor

A vector of length equal to the rows in .data that specifies a weight factor multiplying the cospectrum to obtain the flux cospectrum. Default: 1. For sensible heat flux, for example, this should be the product of air density and specific heat at constant pressure.

spans

The length of the Daniell-smoother sequence to use smoothing the cospectrum. Default is 49.

smoothBins

If a value larger than 5 is provided, the frequency range is divided into this number of intervals evenly spaced in the logarithm of the frequency. Then estimates of the spectral density are binned into those intervals and averaged to smooth the spectrum. Initial smoothing can be provided by "spans" (if larger than 4). The smoothing by the "smoothBins" parameter is applied after and in addition to those smoothing methods. The default (0) suppresses this smoothing.

legend.position

This parameter specifies the position for the legend. The default is 'bottomleft'. The legend can also be suppressed by setting this parameter to NA. Then a legend can still be added after the plot generation.

.plot

Should the result be plotted? Default is TRUE, but if FALSE no plot is generated but the plot-line definitions are still returned in a data.frame.

plotRibbon

Should the standard-deviation ribbon be shown with the bin-averaged values? Default is TRUE unless the bin-averaged line is suppressed by a low value of smoothBins.

printTitle

Should the title be printed containing flux values? Default is TRUE.

wavelengthLimit

The largest wavelength to include in the "FluxL" calculation. The default is 2000 [meters].

Par

Optional time-response characteristics of the variable .A to use to correct for the time response. If provided, this should be a data.frame with variables a, tau1, and tau2. The argument a represents the fraction of a two-time-constant response caused by the direct measurement (e.g., by exposure to the temperature of the airstream) and tau1 is the characteristic time constant for that response. If a is not 1, tau2 should represent a second time constant, e.g., the response characteristic of the wire support in the case of a temperature sensor. The variables tau1 and tau2 can be vectors with length matching the number of rows in the ".data" data-frame, to permits variations dependent on Mach number and air density.

CSprevious

An optional data.frame returned from a previous call to "flux()". The corresponding exceedance function will be plotted on the new copectrum as a dashed brown line. This option is provided to enable comparison to the previous results.

...

Additional arguments to pass to plot().

Details

For a specified scalar variable, calculates the cospectrum with WIC and the exceedance function. Scales by specified variables (e.g., air density and specific heat for sensible heat flux) and accepts specifications for the units of the result and for the upper-wavelength limit. Optionally adds a line representing averaged values in equal-log-interval spacing, optionally with standard-deviation shading. Returns a data.frame with the values, and plots the result unless the "plot" argument is set FALSE.

Value

A data.frame containing the frequency, the smoothed cospectrum (not weighted by frequency), and the exceedance values. The data.frame also has attributes "Flux" and "FluxL" representing the total flux and the flux from wavelengths smaller than the wavelength wavelengthLimit. The wavelengthLimit is also included as an attribute. If smoothBins > 5, the bin-averaged values are also returned as a data.frame named "smoothed data.frame".

Author(s)

William Cooper

Examples

#' X <- flux(RAFdata, 'ATX', scaleFactor=RAFdata$PSXC*100/((RAFdata$ATX+273.15)*287)*1005)

NCAR/Ranadu documentation built on Jan. 27, 2023, 1:09 a.m.