Skip to content
Prev 299151 / 398503 Next

Please help

Hello,

A short code to include real monthly calendar to your data, similar to 
the one inside NCEP2 reanalysis.

library(ncdf)

lon <- seq(from=140.0251, to=146.6751, length.out=241)
lat <- seq(from=-38.975, to=-31.025, length.out=160)
x=dim.def.ncdf("Lon","degreesE",as.double(lon))
y=dim.def.ncdf("Lat","degreesN",as.double(lat))


y1 = 1800        # start of the period
y2 = 2012        # end of the period

year <- seq(y1,y2,1)
day <- 
c(31,28,31,30,31,30,31,31,30,31,30,31)%*%matrix(1,1,length(year)); 
day[2,leap.year(year)] <- 29; day <- as.vector(day)
hour <- day*24; hour <- c(hour[1],cumsum(hour[1:length(hour)-1]))
year <- rep(year,each=12)

syntime <- hour[year==1968] #change the year or change this line to 
include more years
t=dim.def.ncdf("Time","hours since 1800-1-1 00:00:00",syntime,unlim=TRUE)


And your "mrain" matrix should have 3 dimensions (lon x lat x time), 
before to save it as a NetCDF file.

Regards.


Le 04/07/2012 23:13, Jun Chen a ?crit :