Skip to contents

Create the Variables table

Usage

create_variables(
  L0_flat,
  VariableCode,
  VariableName,
  VariableUnitsName,
  SampleMedium,
  ValueType,
  IsRegular,
  TimeSupport,
  TimeUnitsName,
  DataType,
  GeneralCategory,
  NoDataValue
)

Arguments

L0_flat

(tbl_df, tbl, data.frame) The fully joined source L0 dataset, in "flat" format (see details).

VariableCode

(character) Column in L0_flat containing the user or organization-defined code to describe the variable.

VariableName

(character) Column in L0_flat containing the full text name of the variable that was measured, observed, modeled, etc. Must be from the ODM CV (see VariableNameCV)

VariableUnitsName

(character) Column in L0_flat containing the name of units of the data values associated with a variable. Must be from the ODM CV (see UnitsCV)

SampleMedium

(character) Column in L0_flat containing the medium in which the sample or observation was taken or made. Must be from the ODM CV (see SampleMediumCV)

ValueType

(character) Column in L0_flat that indicates how the data value was generated. Must be from the ODM CV (see ValueTypeCV)

IsRegular

(character) Column in L0_flat that indicates whether the data values are from a regularly sampled time series.

TimeSupport

(character) Column in L0_flat containing the numerical value that indicates the time support (or temporal footprint) of the data values. 0 is used to indicate data values that are instantaneous. Other values indicate the time over which the data values are implicitly or explicitly averaged or aggregated.

TimeUnitsName

(character) Column in L0_flat containing the name of units of the time support. If TimeSupport is 0, indicating an instantaneous observation, a unit needs to still be given for completeness, although it is arbitrary. Must be from the ODM CV (see UnitsCV)

DataType

(character) Column in L0_flat that indicates how the value applies over a time interval. Must be from the ODM CV (see DataTypeCV)

GeneralCategory

(character) Column in L0_flat containing the general category of data. Must be from the ODM CV (see GeneralCategoryCV)

NoDataValue

(character) Column in L0_flat containing the numeric value used to encode when a data value is not available for this variable.

Value

(tbl_df, tbl, data.frame) The Variables table.

Details

This function appends columns to the L0_flat table and returns the augmented table.

"flat" format refers to the fully joined source L0 dataset in "wide" form with the exception of the core observation variables, which are in "long" form (i.e. using the variable_name, value, unit columns of the observation table). This "flat" format is the "widest" an L1 hymetDP dataset can be consistently spread due to the frequent occurrence of L0 source datasets with > 1 core observation variable.

Examples


flat <- hymet_L0_flat

  Variables <- hymetDP::create_variables(
    L0_flat = flat,
    VariableCode = "VariableCode",
    VariableName = "VariableName",
    VariableUnitsName = "VariableUnitsName",
    SampleMedium = "SampleMedium",
    ValueType = "ValueType",
    IsRegular = "IsRegular",
    TimeSupport = "TimeSupport",
    TimeUnitsName = "TimeUnitsName",
    DataType = "DataType",
    GeneralCategory = "GeneralCategory",
    NoDataValue = "NoDataValue")

  Variables
#> # A tibble: 3 × 11
#>   VariableCode VariableName    VariableUnitsNa… SampleMedium ValueType IsRegular
#>   <chr>        <chr>           <chr>            <chr>        <chr>     <lgl>    
#> 1 1            Discharge       liters per seco… Surface wat… Derived … TRUE     
#> 2 2            Temperature     degree celsius   Surface wat… Field Ob… TRUE     
#> 3 3            Specific condu… microsiemens pe… Surface wat… Field Ob… TRUE     
#> # … with 5 more variables: TimeSupport <dbl>, TimeUnitsName <chr>,
#> #   DataType <chr>, GeneralCategory <chr>, NoDataValue <dbl>