clim <- slb1_meteo[as.integer(format(slb1_meteo$dates,"%Y")) %in% 2001:2005,]
clim$month <- as.integer(format(clim$dates, "%m"))
prec_meas <- clim$prec
correct_prec_frei <- with(clim,
correct_prec(month, tmean, prec, station.exposure = "frei"))
correct_prec_lg <- with(clim,
correct_prec(month, tmean, prec, station.exposure = "lg"))
correct_prec_mg <- with(clim,
correct_prec(month, tmean, prec, station.exposure = "mg"))
correct_prec_sg <- with(clim,
correct_prec(month, tmean, prec, station.exposure = "sg"))
plot(clim$dates, cumsum(correct_prec_frei),
type = "l", col = "violet", xlab = "dates", ylab = "cum. precipitation (mm)")
lines(clim$dates, cumsum(correct_prec_lg), col = "blue")
lines(clim$dates, cumsum(correct_prec_mg), col = "green")
lines(clim$dates, cumsum(correct_prec_sg), col = "red")
lines(clim$dates, cumsum(prec_meas))
legend('bottomright', c('frei', "lg", "mg", "sg"),
col = c("violet", "blue", "green", "red", "black"),
lty = 1, pch = NULL )
Run the code above in your browser using DataLab