################################################################################ # Course SMACH - January 2014 # project - Script to read weather data for climate change projection # version $Date:: 2014-01-13 0#$ by $Author: brun $(v0: 2013-10-9) ################################################################################ setwd("D:/CourseSmach/data/weather/DRIAS") load("SCRATCH08_arpege_v4_retic.rda") weather_drias=SCRATCH08_arpege_v4_retic # first lines of data.frame head(weather_drias) # structure of data.frame str(weather_drias) # table of scenarios and periods unique(weather_drias[,c("scenario","period")]) attr(weather_drias, "nom_variable") # conversion precipitation kg/m2/s => mm/day weather_drias$rain= weather_drias$prr * (60*60*24) ################################################################################ # representation of weather tendancy weather_drias$scenario_period_site= paste(weather_drias$scenario , weather_drias$period, weather_drias$idPoint, sep="_") res = lapply(unique(weather_drias$scenario_period_site), function(sps) { data.frame(sps=sps,mean_T=mean(weather_drias[weather_drias$scenario_period_site==sps,"tas"]),mean_Rain=mean(weather_drias[weather_drias$scenario_period_site==sps,"rain"]), stringsAsFactors=FALSE) }) res=do.call(rbind, res) sps=do.call(rbind,strsplit(res$sps, "_")) colnames(sps)=c("scenario", "period", "site") res=cbind(sps, res[,-1] ################################################################################ # to complete.... # end of file