Version 3 (modified by celine, 15 years ago) (diff) |
---|
back to first page ..
back to Temperature
back to Temperature download and load
Période hivernale : décembre, janvier, février Période estivale : juin, juillet, août, septembre (tel que défini dans
- Pour avoir la température estivale pour chaque année par gridid :
tapply(tmp$value[tmp$season=="summer"],list(tmp$gridid[tmp$season=="summer"],tmp$year[tmp$season=="summer"]),mean)
- Pour avoir la température hivernale pour chaque année par gridid :
tapply(tmp$value[tmp$season=="winter"],list(tmp$gridid[tmp$season=="winter"],tmp$year[tmp$season=="winter"]),mean)
- Mais c'est plus compliqué :
En fait pour les "winter temperatures" on doit prendre le mois de décembre de l'année t et les mois de janvier et février de l'année t+1 et faire la moyenne sur ces trois mois.
NNum<-length(levels(as.factor(tmp$Num))) Nyear<-length(as.numeric(min(tmp$year)):as.numeric(max(tmp$year))) tmpwinter<-array(NA,c(Ntmp,Nyear)) system.time( for(i in 1:NNum){ for(j in (as.numeric(min(tmp$year))+1):as.numeric(max(tmp$year))){ tmpwinter[i,j-as.numeric(min(tmp$year))+1]<-sum(tmp$value[tmp$month=="12"&tmp$year==(j-1)&tmp$Num==i], tmp$value[tmp$month=="1"&tmp$year==j&tmp$Num==i], tmp$value[tmp$month=="2"&tmp$year==j&tmp$Num==i])/3 } } ) tmpwinter<-as.data.frame(tmpwinter) names(tmpwinter)<-paste("w",as.numeric(min(tmp$year)):as.numeric(max(tmp$year)),sep="")