[R-sig-Geo] transform hourly data matrix to daily array

Sancta Vega sanctavega at gmail.com
Sat Aug 6 19:39:48 CEST 2016


	
>
> I read a ncdf file but I can't get the correct time info and I don't 
> know where is my error. Any help please. This is my code.
>
> |# rm(list=ls())library(ncdf)nc=open.ncdf("tmp.1979-2014.nc")nc 
> [1]"file tmp.1979-2014.nc has 3 dimensions:"[1]"lon Size: 55"[1]"lat 
> Size: 41"[1]"time Size: 52596"[1]"------------------------"[1]"file 
> tmp.1979-2014.nc has 1 variables:"[1]"float tmp[lon,lat,time] 
> Longname: Temperature Missval:1e+30"lon=nc$dim$lon$vals 
> lat=nc$dim$lat$vals lev=nc$dim$level$vals time=nc$dim$time$vals 
> units=nc$dim$time$units start=as.POSIXct('1979-01-01 
> 00:00',tz='UTC')end=as.POSIXct('2014-12-31 
> 18:00',tz='UTC')times=as.POSIXct(ncin$dim$time$vals*60*60,origin='1957-01-0100:00:00',tz='UTC')t1=which(times 
> ==start)t2=which(times ==end)t1 [1]369t2 [1]51504|
>
> t1 and t2 must be respectively 1 and 52596 according to my file.
>
>  1. What is wrong in my code?
>  2. How can I calculate daily mean of my hourly file?
>


	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list