Learn R Programming

reddPrec (version 0.4.0)

gapFilling: Daily precipitation reconstruction. Makes predictions to all days and locations.

Description

This function uses original data to estimate new predicted values in each location and day.

Usage

gapFilling(prec, sts, inidate, enddate, parallel = TRUE, ncpu = 2, thres = NA)

Value

A new file called Filled.RData will be created in working directory. The load of this file (load('Filled.RData')) will add a matrix containing the original data with missing values filled with this function. A new days directory will be created in working path with one file per day. Each file contains a data.frame with many rows as stations. The columns show the identifier (ID)of each station; the observed value obs (if exists); the binomial prediction predb (dry<0.5; wet>=0.5); the raw prediction of precipitation magnitude pred1 resulting from models; the corrected magnitude prediction pred2 by binomial prediction (if dry, pred2==0); the final standardized magnitude prediction pred3 and the standard error err of the model. All variables except predb are in the same units as original values (mm*10).

Arguments

prec

Object of class matrix containing the daily precipitation data. This dataset can be the cleaned.RData resulting from qcPrec function. Each column represents one station. The names of columns have to be names of the stations.

sts

Object of class matrix containing the stations info. Must have at least four fields: ID: station identifier; ALT: altitude; X: Longitude in UTM projection (meters); and Y: Latitude in UTM projection (meters). Tabulation separated.

inidate

Object of class Date in format 'YYYY-mm-dd' defining the first day of quality control process

enddate

Object of class Date in format 'YYYY-mm-dd' defining the last day of quality control process

parallel

Logical. If TRUE, parallel computing is activated and the processes will be distributed among the ncpu number of processor cores.

ncpu

Only if parallel = TRUE. Sets the number of processor cores used to parallel computing.

thres

Threshold applied to search nearest stations. If thres=NA the function will search 10 nearest observations without a distance limit. A positive number indicates the threshold in kilometers.

Author

Roberto Serrano-Notivoli

Examples

Run this code

  #loads example data
  data(precipDataset)

  #runs function
  gapFilling(prec=cleaned,sts=sts,inidate=as.Date('2001-01-01'),
    enddate=as.Date('2001-01-02'),parallel=TRUE,ncpu=2,thres=NA)

Run the code above in your browser using DataLab