calcgis: Calculate missing station data

View source: R/calcgis.R

calcgisR Documentation

Calculate missing station data

Description

Calculate missing station data for XerMtn and CondQR50

Usage

calcgis(station)

Arguments

station

data.frame for input station data

Details

XerMtn is calculated from PSA6C if the latter is present with no NA value. If XerMtn is present with NA values, PSA6C is used if present with no NA values. XerMtn = 1 if PSA6C is 'SN', 'NC', otherwise XerMtn = 0 if PSA6C is 'CH', 'CV', 'DM', 'SC'.

CondQR50 is calculated from the quantregForest object in rfmods if all predictors are present in stations and no missing values are in the predictors. Similar to XerMtn, NA values will be predicted per row only if the column already exists. The required predictors are 'CaO_Mean', 'MgO_Mean', 'S_Mean', 'UCS_Mean', 'LPREM_mean', 'AtmCa', 'AtmMg', 'AtmSO4', 'MINP_WS', 'MEANP_WS', 'SumAve_P', 'TMAX_WS', 'XWD_WS', 'MAXWD_WS', 'LST32AVE', 'BDH_AVE', 'KFCT_AVE', 'PRMH_AVE'.

Value

The original station data with calculated fields where applicable.

See Also

chkinp

Examples


# this calculates CondQR50 and XerMtn
calcgis(demo_station)

## Not run: 
# get XerMtn from PSA6c
tmp <- demo_station[, !names(demo_station) %in% 'XerMtn']
calcgis(tmp)

# error, cannot get XerMtn if PSA6C not found
tmp <- demo_station[, !names(demo_station) %in% c('XerMtn', 'PSA6C')]
calcgis(tmp)

# get conductivity
tmp <- demo_station
calcgis(tmp)

# get conductivity for only NA 
tmp <- demo_station
tmp$CondQR50[1] <- 200
calcgis(tmp)

# error, cannot calculate conductivity if missing predictors
tmp <- demo_station[, !names(demo_station) %in% c('TMAX_WS', 'AtmSO4')]
calcgis(tmp)

# error, cannot calculate conductivity if missing values in predictors
tmp <- demo_station
tmp$MINP_WS[2] <- NA
tmp$AtmSO4[3] <- NA
calcgis(tmp)

## End(Not run)

fawda123/ASCI documentation built on April 12, 2024, 4:16 a.m.