inst/doc/examples/pine.R

# file pine.R
#
# This file contains a script which plots the measurement sites on a GoogleMap support
#
#
# author: Emanuele Cordano on 28-09-2012

#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

###############################################################################







rm(list=ls())
#library(Interpol.T)
#library(RMAWGEN)
library(RHUMIDITY)
library(zoo)
library(lattice)
data(pine) # contains pine hourly datasat 
index(pine) <- as.POSIXlt(index(pine),tz="A") # changes index class type



## get daily temperature Time series

station <- c("PINE")

# Calibratipn coefficien for polygonal relatioships between DDI and Daily Daw Point Temperature by Emanuele Eccel 

intercept_prec <- c(1.2)
names(intercept_prec) <- station 

coeff_prec <- c(-0.37)
names(coeff_prec) <- station 


intercept_noprec <- c(2.7)
names(intercept_noprec) <- station 

coeff_noprec <- c(-1.5)
names(coeff_noprec) <- station #adjusted!!

T_hourly <- pine$T
prec_hourly <- pine$prec
RH_hourly <- pine$RH


## daily aggregation 

prec <- aggregate(prec_hourly,by=as.Date(index(T_hourly)),FUN=sum)
Tm <- aggregate(T_hourly,by=as.Date(index(T_hourly)),FUN=mean)
Tn <- aggregate(T_hourly,by=as.Date(index(T_hourly)),FUN=min)
Tx<- aggregate(T_hourly,by=as.Date(index(T_hourly)),FUN=max)

### Daily dew temperature

Td <- TDEW(Tx=Tx,Tn=Tn,Tmean=Tm,prec=prec,lag=10,valmin_prec=0.5,intercept_prec=intercept_prec,intercept_noprec=intercept_noprec,coeff_prec=coeff_prec,coeff_noprec=coeff_noprec,DDI_lim=NULL)



RH_hourly_calc <- air_humidity(T_hourly=T_hourly,Td=Td)

# Date from which the measurement instrument work well!!!
data0 <- as.POSIXlt("2011-04-01 00:00:00",tz="A")

# start and end dates for a possible visualization!!!

start <- as.POSIXlt("2012-05-01 00:00:00",tz="A")
end <- as.POSIXlt("2012-05-15 23:00:00",tz="A")

days_calc <- (index(RH_hourly_calc)>=start & index(RH_hourly_calc)<=end)
days <- (index(RH_hourly)>=start & index(RH_hourly)<=end)

day_correct <-  (index(RH_hourly)>=data0)

RH_hourly_calc_m <- RH_hourly_calc[days_calc]
RH_hourly_m <- RH_hourly[days]
T_hourly_m <- T_hourly[days]
prec_hourly_m <- prec_hourly[days]

# temporary plot 

plot(RH_hourly_m)
lines(RH_hourly_calc_m,col=2)

# daily aggregation of relative humidity 
#
RHm <- aggregate(RH_hourly,by=as.Date(index(T_hourly)),FUN=mean)
RHn <- aggregate(RH_hourly,by=as.Date(index(T_hourly)),FUN=min)
RHx<- aggregate(RH_hourly,by=as.Date(index(T_hourly)),FUN=max)

RHm_calc <- aggregate(RH_hourly_calc,by=as.Date(index(T_hourly)),FUN=mean)
RHn_calc <- aggregate(RH_hourly_calc,by=as.Date(index(T_hourly)),FUN=min)
RHx_calc <- aggregate(RH_hourly_calc,by=as.Date(index(T_hourly)),FUN=max)
ecor/RHUMIDITY documentation built on May 15, 2019, 8:52 p.m.