swarm-modeling
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ASM Patch 3 nearing completion; hdf5 question


From: Marcus G. Daniels
Subject: Re: ASM Patch 3 nearing completion; hdf5 question
Date: 01 Jul 2001 00:05:09 -0600
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.7

>>>>> "PJ" == pauljohn  <address@hidden> writes:

PJ> Some relatively easy things to do with the ascii output, such as
PJ> "get last line from output for each run and collect into a single
PJ> file" are quite difficult for me to imagine with many hdf5
PJ> datasets. 

R can do these kind of manipulations in a direct way.  No need for an
extra file.  For example, suppose you had two text or HDF5 files
output by Swarm:

$ cat file1.txt
10 20 30
40 50 60

$ cat file2.txt
100 200 300
400 500 600

Then you could load the program below in order to collect the last
records and do statistics on them.

$ cat demo.R
lastrecords <- data.frame()

for(fi in 1:2) {
  base <- paste("file", fi, sep="")

  txt <- paste(base, ".txt", sep="")
  m <- read.table(txt)
  
  #hdf <- paste(base, ".hdf", sep="")
  #m <- hdf5load(hdf),load=FALSE)$m
 
  lastrecords <- rbind(lastrecords,m[nrow(m),])
}
print(mean(lastrecords$V2))

$ R
> source("demo.R")
[1] 275
>


Notice how the idioms for reading the text or HDF5 files have the same form.

HDF5 files are useful when the data you're dealing with has hierarchy,
is large, is sparse, or when you are concerned about the precision and
portability of numerical representations.  (Text files having
floating point numbers don't record specifics about the binary 
representation scheme for those numbers.)



                  ==================================
   Swarm-Modelling is for discussion of Simulation and Modelling techniques
   esp. using Swarm.  For list administration needs (esp. [un]subscribing),
   please send a message to <address@hidden> with "help" in the
   body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]