[R] construction of a 4 dimensions binary file
Flore MOUNIER
mounier at lmd.polytechnique.fr
Wed Jan 15 17:35:03 CET 2003
Dear R users,
At present I have 22 files with girded data in 3-Dimensions (longitude,
latitude, time), each file being one level of the atmosphere. I would like to
compact these 22 levels into a unique and big file.
If you know how to do such an operation please fill free to contact me.
P.S.: Here is the beginning of my programme:
###########
#Dimension#
##########
nlon<-25; londeb<-1 ; lonfin<-25
nlat<-25; latdeb<-1; latfin<-25
nb<-122; tdeb<-1; tfin<-122
tsel<-tfin-tdeb+1
lonsel<-lonfin-londeb+1
latsel<-latfin-latdeb+1
hgt <- array(0,dim=c(nlon,nlat,nb))
#
#############
#file openning#
############
andeb <- 1 ; anfin <- 22
an <- c("1979","1980","1981","1982","1983","1984","1985","1986","1987","1988"
,"1989","1990","1991","1992","1993","1994","1995","1996","1997","1998","1999","2000")
andeb <- 1 ; anfin <- 4 ;nan<-anfin-andeb+1
path <- "/ws/mounier/Info./Grads/OLR/data"
deb<-"/olr."
ext <- ".dat"
for (o in andeb:anfin)
{a <-file (paste(path,deb,an[o],ext,sep=""),"rb")
hgt[1:nlon,1:nlat,1:nb] <- readBin(a,real(),size=4,nb*nlon*nlat)
#############
#NEW FILE #
###########
c<-file("/ws/mounier/Info./Grads/OLR/data/olr.79_00.test.dat","wb")
for (k in 1:tsel)
for (j in 1:latsel) {
{writeBin(hgt[1:lonsel,j,k],c,size=4, endian="little")}}
close(a)}
close(c)
Than you in advance for any advice.,
Flore
--
Flore MOUNIER
Laboratoire de Météorologie Dynamique
Ecole Polytechnique
F 91128 Palaiseau Cedex
Tél: 01-69-33-36-19
Fax: 01-69-33-30-49
e-mail : mounier at lmd.polytechnique.fr
More information about the R-help
mailing list