[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: a HDF5 interface for extending datasets
From: |
Marcus G. Daniels |
Subject: |
Re: a HDF5 interface for extending datasets |
Date: |
19 Mar 2001 20:22:54 -0800 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4 |
>>>>> "MD" == Marcus G Daniels <address@hidden> writes:
MD> Note I haven't merged it with the analysis module -- maybe someone
MD> would find that useful and do the work...
Done -- multiple EZGraphs can write multiple sequences to a HDF5 file.
Thanks to Marcus Daniels for implementing this! ;-)
ftp://ftp.swarm.org/pub/swarm/src/testing/swarm-2001-03-19.tar.gz
ftp://ftp.swarm.org/pub/swarm/binaries/w32/latest/javaswarm.dll.gz
libkaffeswarm.dll.gz
swarm.jar.gz
swarm.dll.gz
Here's an example:
$ javaswarm TestEZGraphHDF5
$ h5ls -r data.hdf
/data.hdf/graph Group
/data.hdf/graph/agent Dataset {5/Inf}
$ R
> library(hdf5)
> hdf5load("data.hdf")
> graph$agent
[1] 0.4184809 0.3824659 0.1066448 0.3124061 0.3738690
> quit()
$ cat TestEZGraphHDF5.java
import swarm.Globals;
import swarm.defobj.Zone;
import swarm.activity.Activity;
import swarm.objectbase.SwarmImpl;
import swarm.objectbase.Swarm;
import swarm.activity.Schedule;
import swarm.activity.ScheduleImpl;
import swarm.analysis.EZGraphImpl;
import swarm.analysis.EZGraph;
import swarm.analysis.EZSequence;
import swarm.defobj.HDF5;
import swarm.defobj.HDF5C;
import swarm.defobj.HDF5Impl;
import swarm.defobj.HDF5CImpl;
import swarm.Selector;
import java.io.File;
public class TestEZGraphHDF5 extends SwarmImpl {
EZSequence sequence;
HDF5 dataFile;
class Agent {
double value;
Agent (double value) {
this.value = value;
}
void newValue () {
value = Globals.env.uniformDblRand.getDoubleWithMin$withMax (.1, 1);
}
public double getAgentValue () {
return value;
}
}
Schedule schedule;
EZGraph ezgraph;
Agent standaloneAgent;
TestEZGraphHDF5 (Zone aZone) {
super (aZone);
}
public void stepSim () {
standaloneAgent.newValue ();
ezgraph.step ();
}
public Object buildObjects () {
super.buildObjects ();
standaloneAgent = new Agent (1.0);
new File ("data.hdf").delete ();
HDF5CImpl hdf5C = new HDF5CImpl (new HDF5Impl ());
hdf5C.createBegin (getZone ());
hdf5C.setWriteFlag (true);
hdf5C.setName ("data.hdf");
dataFile = (HDF5) hdf5C.createEnd ();
ezgraph = new EZGraphImpl (getZone (), dataFile, "graph");
try {
Selector sel = new Selector (Agent.class,
"getAgentValue",
false);
sequence =
ezgraph.createSequence$withFeedFrom$andSelector ("agent",
standaloneAgent,
sel);
} catch (Exception e) {
e.printStackTrace (System.err);
System.exit (1);
}
return this;
}
public Object buildActions () {
super.buildActions ();
schedule = new ScheduleImpl (getZone (), true);
try {
Selector sel = new Selector (getClass (), "stepSim", false);
schedule.at$createActionTo$message (0, this, sel);
schedule.at$createActionTo$message (1, this, sel);
schedule.at$createActionTo$message (2, this, sel);
schedule.at$createActionTo$message (3, this, sel);
schedule.at$createActionTo$message (4, this, sel);
} catch (Exception e) {
e.printStackTrace (System.err);
System.exit (1);
}
return this;
}
public Activity activateIn (Swarm swarmContext) {
super.activateIn (swarmContext);
schedule.activateIn (this);
return getActivity ();
}
public void drop () {
dataFile.drop ();
super.drop ();
}
static void main (String []args) {
Globals.env.initSwarm ("TestEZGraphHDF5", "0.0", "address@hidden",
args);
TestEZGraphHDF5 ezgraphTest = new TestEZGraphHDF5 (Globals.env.globalZone);
ezgraphTest.buildObjects ();
ezgraphTest.buildActions ();
ezgraphTest.activateIn (null).run();
ezgraphTest.drop ();
}
}
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.