estimateSnowFraction: Estimate snow fraction

Description Usage Arguments Details Value Author(s) Examples

View source: R/estimateSnowFraction.R

Description

The fraction of frozen water of (potential) precipitation is estimated by using a temperature threshold. The function can be useful e.g. to estimate the number of snow days or to accumulate the snow water equivalent.

Usage

1
estimateSnowFraction(y, thr = 0.9, trans = 1)

Arguments

y

numeric vector, matrix, or array. Contains the temperature values. See the 'Examples' for how to deal with objects from package raster.

thr

real number. Temperatures below this threshold value convert rain to snow.

trans

positive real number. Defines the transition range (see 'Details').

Details

To allow for fractional water freezing, thr gets extended by trans. Thus

y < thr - trans

will convert precipitation into snow, whereas

y > thr + trans

preserves precipitation as rain. For the range spanned by trans linear interpolation takes place.

The default values for thr and trans are based on a hydrological analysis in the Thur catchment (Switzerland) and refer to temperature in degree Celsius.

Value

Numeric array with the same dimensions as y, giving the snow fraction as a number in [0,1].

Author(s)

Original code provided by Ole R.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
## simulate temperature and precipitation series
x <- seq(0,2*pi,length.out=365)
temp <- 5*sin(x-2)+rnorm(365)
precip <- rgamma(365,shape=2,rate=0.1)
precip[sample(x=1:365,size=250)] <- 0

## separate snow from precipitation
thr <- 0
trans <- 1
f <- estimateSnowFraction(y=temp,thr=thr,trans=trans)
snow <- precip*f
rain <- precip-snow

## plot series
par(mfrow=c(3,1),mar=c(0.5,4,0.5,1),oma=c(4,0,0,0))
plot(temp,type='l',ylab='degree Celsius',xaxt='n')
abline(h=c(thr,thr-trans,thr+trans),lty=3)
plot(precip,type='s',ylab='mm',xaxt='n',col='red')
par(new=TRUE)
plot(snow,type='s',xlab=NA,ylab=NA,axes=FALSE,col='blue')
plot(f,type='l',ylab='snow fraction',xlab='time',xpd=NA)

## Not run: 
## how to deal with temperature fields packed in a RasterBrick
library(raster)
x <- 5 # grid cells in longitude
y <- 5 # grid cells in latitude
z <- 2 # number of time steps
temp <- brick(array(rnorm(x*y*z,sd=4),dim=c(x,y,z)))
f <- estimateSnowFraction(y=as.array(temp))

## make f a RasterBrick with the same attributes as temp
e <- extent(temp)
f <- brick(f,xmn=e[1],xmx=e[2],ymn=e[3],ymx=e[4],crs=proj4string(temp))
## End(Not run)

hydro-giub/hydroBE documentation built on Sept. 20, 2019, 9:27 a.m.