sw_upgrade: Upgrade a 'rSOILWAT2'-classed object from an older package...

sw_upgradeR Documentation

Upgrade a rSOILWAT2-classed object from an older package version

Description

Missing slots and elements are added and take the new default values from SOILWAT2.

Usage

sw_upgrade(object, verbose = FALSE)

## S4 method for signature 'ANY'
sw_upgrade(object, verbose = FALSE)

## S4 method for signature 'swFiles'
sw_upgrade(object, verbose = FALSE)

## S4 method for signature 'swMonthlyScalingParams'
sw_upgrade(object, verbose = FALSE)

## S4 method for signature 'swWeather'
sw_upgrade(object, verbose = FALSE)

upgrade_weatherColumns(
  weatherDF,
  template_weatherColumns = c("Year", "DOY", weather_dataColumns())
)

upgrade_weatherDF(
  weatherDF,
  template_weatherColumns = c("Year", "DOY", weather_dataColumns())
)

upgrade_weatherHistory(object, verbose = FALSE)

## S4 method for signature 'swProd'
sw_upgrade(object, verbose = FALSE)

## S4 method for signature 'swSite'
sw_upgrade(object, verbose = FALSE)

upgrade_soilLayers(
  soilLayers,
  template_soilLayerProperties = soilLayer_dataColumns()
)

## S4 method for signature 'swSoils'
sw_upgrade(object, verbose = FALSE)

## S4 method for signature 'swOUT'
sw_upgrade(object, verbose = FALSE)

## S4 method for signature 'swEstabSpecies'
sw_upgrade(object, verbose = FALSE)

## S4 method for signature 'swEstab'
sw_upgrade(object, verbose = FALSE)

## S4 method for signature 'swInputData'
sw_upgrade(object, verbose = FALSE)

Arguments

object

An object of a rSOILWAT2 class.

verbose

A logical value.

weatherDF

A data frame with weather variables.

template_weatherColumns

A vector with requested weather variables.

soilLayers

A two-dimensional object representing soil layers in rows and soil properties in columns, see slot "Layers" of ⁠["swSoils-class"]⁠.

template_soilLayerProperties

A vector of standard names of soil properties, see soilLayer_dataColumns().

Value

The upgraded object, if needed, to match the current version with missing slots and elements filled with default values.

For upgrade_weatherColumns(): an updated weatherDF with requested column name changes.

For upgrade_weatherDF(): an updated weatherDF with requested columns.

For upgrade_soilLayers(): an updated soilLayers matrix with requested columns (a new "som_frac" is initialized to the default value of 0).

Details

List of changes:

  • Changes with v6.3.0:

    • class swSoils:

      • new slot "omSWRCp"; slot "SWRCp" refers to mineral soil

      • slot "Layers" gained column "som_frac"

    • class swSite: new slots "depth_sapric" and "SurfaceTemperatureMethod"

  • Changes with v6.2.0:

    • class swWeatherData: slot "data" changed column name ("specHavg_pct" to "specHavg_gPERkg") and units ("%" to "g kg-1").

  • Changes with v6.1.0:

    • class swInputData: new slot "spinup" of new class swSpinup

    • class swFiles: new total of 27 input files

  • Changes with v6.0.0:

    • class swSite: new slots "swrc_flags", "has_swrcp", and "SoilDensityInputType"

    • class swSoils: new slot "SWRCp"

    • class swFiles: SWRC parameter input file added as file 6 for a new total of 23

    • class swProd: new slot "veg_method"

    • class swWeatherData: new slots "use_cloudCoverMonthly", "use_windSpeedMonthly", "use_humidityMonthly", "dailyInputFlags", and "desc_rsds"

    • class swWeatherData: slot "data" gained 11 new columns: "cloudCov_pct", "windSpeed_mPERs", "windSpeed_east_mPERs", "windSpeed_north_mPERs", "rHavg_pct", "rHmax_pct", "rHmin_pct", "specHavg_pct", "Tdewpoint_C", "actVP_kPa", and "shortWR"

  • Changes with v5.4.0:

    • classes swEstabSpecies and swEstab: new slot "vegType"

  • Changes with v5.2.0:

    • class swOUT: "FROZEN" added as outkey 28 for a new total of 32

  • Changes with v3.1.0:

    • class swOUT: "BIOMASS" added as outkey 31 for a new total of 31

  • Changes with v2.3.0:

    • class swOUT: "SWA" added as outkey 8 for a new total of 30

Examples

x <- sw_upgrade(rSOILWAT2::sw_exampleData, verbose = TRUE)

upgrade_weatherColumns(
  data.frame(DOY = 1:2, Tmax_C = runif(2), dummy = runif(2))
)
upgrade_weatherColumns(
  data.frame(DOY = 1:2, Tmax_C = runif(2), specHavg_pct = NA)
)

upgrade_weatherDF(
  data.frame(DOY = 1:2, Tmax_C = runif(2), dummy = runif(2))
)
upgrade_weatherDF(
  data.frame(DOY = 1:2, Tmax_C = runif(2), specHavg_pct = NA)
)

upgrade_soilLayers(
  data.frame(sand_frac = runif(2), clay_frac = runif(2), dummy = runif(2))
)
soils <- slot(rSOILWAT2::sw_exampleData, "soils")
upgrade_soilLayers(slot(soils, "Layers")[, 1:12L, drop = FALSE])


Burke-Lauenroth-Lab/rSOILWAT2 documentation built on June 2, 2025, 8:17 a.m.