This repository contains an R script that estimates the statistical relationship between monthly mean of daily precipitation rate and the fraction of days in the month having 0.2 mm or greater precipitation, i.e., "wet days".
The functional relationship between the two variables is: wetf ~ log(prec) where wetf is the fraction of days in the month with precipitation >= 0.2 mm (fraction) and prec is the monthly mean of the daily precipitation rate (mm).
The R script ingests a netCDF input file containing monthly mean precipitation rate and wet day fraction, and outputs a file generated by the netCDF cdl template wetVpre-linear-annual.cdl that contains the following variables:
- slope
- intercept
- adjusted R-squared
- root-mean-squared error (from the R function
RMSE())
The linear least-squares regression is performed using the R function lm().
The fitting scheme requires at least 10 observations of positive precipitation and wet days to run. Code is provided in the R script for performing the regression monthly (commented out), along with just using all the data in a particular gridcell.
For gridcells where no regression can be performed, e.g., in desert areas with little to no precipitation, missing values are placed in the output rasters. These missing values could later be filled in using interpolation, e.g., using CDO function setmisstodis.