flget_Pfunction {FjordLight}R Documentation

Extract p function data from a NetCDF file downloaded by FjordLight.

Description

This functions will conveniently extract the p function data stored within a NetCDF file downloaded via fl_DownloadFjord. There are options for how the user would like to subset the data, which data format the data should be extracted to, and if the user would like to plot the data in the process.

Usage

flget_Pfunction(
  fjord,
  type = "coastal",
  period = "Global",
  month = NULL,
  year = NULL,
  mode = "function",
  PLOT = FALSE,
  add = FALSE,
  ...
)

Arguments

fjord

Expects the object loaded via fl_LoadFjord.

type

Whether the p function should show values for the coastal zone (< 200 m deep), or the shallow zone (< 50 m deep).

period

Here the user determines which time period of data should be loaded. To load the total average values (default) use "Global". One may chose instead to load the "Yearly" or "Monthly" values. Note that monthly values here represent the climatological average for the month, not one month in a given year. If the user would like one specific month of data (only available for bottom PAR), they should use flget_PARbottomMonthlyTS.

month

The monthly climatology to extract. Accepts an integer value from 3 to 10. This argument is ignored if period = "Yearly".

year

The yearly average to extract. Currently accepts an integer value from 2003 to 2022. This argument is ignored if period = "Monthly".

mode

Determines the basic process that this function performs. The default mode = "function" will allow the user to create a function that they can then use themselves to determine p curves using their own input (see examples). Or to access the underlying p function data directly set mode = "df".

PLOT

Boolean argument (default = FALSE) that tells the function if the user would like the loaded data to be plotted or not.

add

Boolean (i.e. TRUE/FALSE) to tell the function to add the p function plot to an existing plot. See examples below.

...

Additional arguments that may be passed to flplot_Pfunction, which will implement them using base R plotting functionality.

Value

Depending on which arguments the user chooses for mode, a function will be returned (see examples). Or a two column data.frame:

irradianceLevel

A threshold value [mol photons m-2 d-1]

optics_global|year|month

The column name is determined by the arguments passed to optics and either global, year, or month, depending on which period was indicated. These values show the percent of the fjord (filtered for pixels with a depth of 200 m or shallower) that received at least the amount of irradiance indicated in the irradianceLevel column.

Author(s)

Bernard Gentili & Robert Schlegel

Examples

# Load data
fjord_code <- "test"
fjorddata <- fl_LoadFjord(fjord_code, dirdata = system.file("extdata", package = "FjordLight"))

# Create a function
fG <- flget_Pfunction(fjorddata, "shallow", "Global")

# Then use it with specific PAR thresholds
irradiance_levels <- c(0.1, 1, 10)
fG(irradiance_levels)

# As a 2 column data.frame
f2012 <- flget_Pfunction(fjorddata, "shallow", "Yearly", year = 2012, mode = "df", PLOT = TRUE)
str(f2012)

# Plot a P-function
fGlob <- flget_Pfunction(fjorddata, "coastal", "Global", PLOT = TRUE, lty = 1, col = 1, lwd = 2,
                         Main = paste(fjord_code, "P-functions"), ylim = c(0, 50))


[Package FjordLight version 0.8 Index]