[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Swarm and VisAD via HDF5
From: |
Marcus G. Daniels |
Subject: |
Swarm and VisAD via HDF5 |
Date: |
07 May 2000 13:45:30 -0700 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4 |
Here's an example of using VisAD, a Java3D-based package for data
visualization, in conjunction with Swarm. (This uses HDF5, but since
VisAD is a Java library, you can use it directly in Swarm too.)
Instructions are for Windows NT:
1) Get and install Java 3D(TM) from:
http://java.sun.com/products/java-media/3D
(Java3D most easily works by overlaying your existing JDK
installation, so check paths carefully.)
2. Start up a Swarm terminal, and create a subdirectory for work files:
$ mkdir visad
$ cd visad
3. Download the Java DLL for HDF5:
$ wget
ftp://hdf.ncsa.uiuc.edu/HDF5/current/java-hdf5/JHI5_1_1_bin/lib/win/jhdf5.dll
4. Download the VisAD jar file:
$ wget ftp://www.ssec.wisc.edu/pub/visad-2.0/visad.jar
5. Create a HDF5 data file using a Swarm program like below.
(Note that a Swarm list is used here instead of a java.util.* list.
Java collections aren't yet supported by the Swarm serialization,
although simple Java objects are.)
$ cat Cones.java
import swarm.Globals;
import swarm.defobj.HDF5ArchiverImpl;
import swarm.defobj.Archiver;
import swarm.collections.ListImpl;
import swarm.collections.List;
public class Cones {
class Coord {
public double x, y, z;
Coord (double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
}
public List coneCoords;
public Cones () {
double thetaStep = 2 * Math.PI / 100;
int pos = 0, zi, ti;
coneCoords = new ListImpl (Globals.env.globalZone);
for (zi = 0; zi < 100; zi++)
{
double z = zi - 50;
double r = 50 - Math.abs (z);
for (ti = 0; ti < 100; ti++)
{
double theta = ti * thetaStep;
coneCoords.addLast (new Coord (z,
r * Math.sin (theta),
r * Math.cos (theta)));
}
}
}
void save (Archiver archiver) {
archiver.putShallow$object ("cones", coneCoords);
}
static void main (String args[]) {
Globals.env.initSwarm ("Cones", "0.0",
"address@hidden", args);
Cones test = new Cones ();
test.save (new HDF5ArchiverImpl (Globals.env.globalZone, "cones.hdf"));
}
}
6. Compile it:
$ javacswarm Cones.java
7. Run it:
$ javaswarm Cones
8. Run the VisAD spreadsheet using Sun JDK 1.2.2:
$ jdkswarm -cp visad.jar visad.ss.SpreadSheet
8a. Select "File/Import data" menu item, then select "cones.hdf"
8b. Select "Cell/Edit mappings" menu item, then select "Clear all"
8c. Make new variable mappings:
8c1. Click on "x" on the left, and then the X> icon.
8c2. Click on "y" on the left, and then the Y^ icon.
8c3. Click on "z" on the left, and then the Z/ icon.
8c4. Click "Done".
You should now see a 3D two-ended cone you can rotate, etc.
Note that this data file can be loaded and saved by `R' as well:
$ /rw1000/bin/Rgui
> library(hdf5)
> hdf5load("cones.hdf")
> plot(cones$x,cones$y)
==================================
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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Swarm and VisAD via HDF5,
Marcus G. Daniels <=