Check that the unit of a variable in a NetCDF file is equivalent to the expected unit.

check_unit(variable, nc, variable_table, warn_unknown = TRUE)

Arguments

variable

Name of target variable, as a length 1 character

nc

NetCDF object containing target variable

variable_table

`data.frame` linking standard names to their units. Must contain columns "cf_standard_name" and "units". Default is [pecan_standard_met_table].

warn_unknown

Logical. If `TRUE` (default), throw a warning for variables not in `variable_table`. Otherwise, ignore unknown variables.

Value

`TRUE` if unit is correct, or `try-error` object if there is a mismatch.