[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
new faq entry: outputting values of 2d grids
From: |
Paul Johnson |
Subject: |
new faq entry: outputting values of 2d grids |
Date: |
Fri, 30 Jul 1999 15:42:15 -0500 |
Matt Aylward gave me a few tips on outputting values from grid2d objects
(value or object grids). I've cut them down to what I see as the bar
minimum, here is what I propose to add:
How can I: Save data values from grid2d objects?
You can take a pixmap of a ZoomRaster display, but sometimes you want to
save the underlying data. You can output the data in integer format if
you use Swarm's Int2dFiler protocol. Here is a concrete example.
Suppose you have a class that is subclassed from Discrete2d. Suppose
you have objects in that grid, and each object is able to answer a
message "getOutputValue". This must return an int! Then in your
subclass of the Discrete2d, you can add a method like this:
-writeValuesToFile
{
id gridfiler;
char * filename;
asprintf(&filename, "%05dWrappedGrid.txt", getCurrentTime());
gridfiler=[Int2dFiler createBegin: [self getZone]];
[gridfiler setDiscrete2dToFile: self];
[gridfiler setValueMessage: M(getOutputValue)];
gridfiler=[gridfiler createEnd];
[gridfiler fileTo: filename];
return self;
}
In your schedule, then you can add a message that causes the object to
write its values to a file.
Then, in Matt's words:
"Once you have the data there are many ways of analysiing it. One of the
easiest is to
turn it into a pgm portablr grey map:
add an ascii header to it as follows:
P2
x_size y_size
max_value
.........int ascii data here.....
e.g., in my case:
P2
200 200
10
Then give it a .pgm extension and open it in xv, gimp ..etc.
I also import the raw data into apps like GRI for contouring and
postscript output for
LaTeX."
Cool!
Gimp gives a (somewhat gross, IMHO) contour plot. I plan to use this in
a 3d graphics program to make 3d bar charts as in the Nowak articles on
diffusion of opinion.
If I get an more stuff from Matt on this, I'll make it publicly
available.
--
Paul E. Johnson email: address@hidden
Dept. of Political Science http://lark.cc.ukans.edu/~pauljohn
University of Kansas Office: (785) 864-9086
Lawrence, Kansas 66045 FAX: (785) 864-5700
==================================
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] |
- new faq entry: outputting values of 2d grids,
Paul Johnson <=