AeroVis: Reproducing the DTLZ1 Animation

As I’m working to reproduce Josh’s DTLZ1 Animation that he demoed in the group meeting last week, I thought I’d write a list of my workflow here on the blog.

  1. Load the DTLZ1.par file from the examples folder on ANGEL
  2. In Edit… Plotting Preferences, go to the Glyph tab, and change the size of the glyphs to something like 0.02.  You just want to change the size so you can see the points better.
  3. To get the axes to scale the correct way…first fast-forward the animation to the end using the animation controls.
  4. Then, open “Central Variable Controls”, and reset each axis to its natural scale.  Lock the scaling of the axes so they don’t change by clicking “lock” on each axis.
  5. “Rewind” the animation to the beginning.
  6. In animation tools, find the pulldown menu for “Sync By”.  Change the sync by option to NFE.  Then, type 25000 in the “skip to” box.  Any time you change something in a menu box, be sure to hit Enter on your keyboard to accept the command.  This will fast-forward the animation to a point where you see some solutions appearing in the glyph cube.
  7. The next step will rotate the cube to show a little bit of depth for 3d.  You’ll want to think about a starting and an ending point that you desire.  Then, move the cube to the starting point.
  8. Take a snapshot using the “take snapshot” tool.
  9. Without moving the mouse, set an interpolation camera in “gif controls.”
  10. Now move carefully to the second view that you want.  This will be the one you keep for the rest of the animation.  Set a second interpolation camera.
  11. We’re ready to start the first animation!  Click the red “record” button in GIF controls.  Then, click the “interpolate spline” button in GIF controls.  Finally, click “create GIF”
  12. Now the window should be at its final view for the animation of the actual MOEA search.  Click “clear keyframes” in the GIF controls.  Also make sure the red record button is still depressed.  Finally, set the “frame skip” in GIF controls to 8, and hit enter.
  13. Now hit play in “Animation Controls”.  You should see the Image Stack amount increasing in GIF controls.
  14. You can “pause” to stop the animation at any time.  When complete, click “Create GIF” in the GIF controls to complete.

The animation files were created successfully!  Here’s a short list of tasks in PowerPoint then to complete the exercise:

  1. If you wish, make your first slide with introductory points using the static version of the figure, in your Snapshots folder.  The subsequent animations can be placed on different slides.
  2. In Image Tools in PowerPoint, make sure that each figure (the static one and the two animations) are exactly the same size.  For example, round off the width of the figure to a round number, and the height should follow.
  3. Then, click in the bottom right corner of Image Tools to get to the size and position dialog box.  In position, make each figure have the exact same horizontal and vertical position.  This will ensure that the figures don’t “jump around” on screen between slides.

And that’s it!

AeroVis: Turning a Glyph Plot Into a Figure

This post assumes you’ve already figured out which variables to assign to which axes and found a good camera angle.  I explain how to use AeroVis, a raster graphics editor, and a vector graphics editor to make a good-looking vector graphic that you can improve iteratively.  It’s important to be able to do this because the first version of your figure will always need improvement: your glyphs were too small, or too large, or the wrong color.  Or perhaps you need two similar figures: brushed and unbrushed, or the same glyphs with two different colorings.  In any case, being able to make changes to your figures without starting from scratch will save you a lot of time.

Let’s take an example where you want to make two versions of a plot: one showing all of the glyphs, and another highlighting glyphs with a particular characteristic.  You could do this purely in AeroVis, and it looks pretty good.  But for really detailed control over the appearance of the figure, I recommend the procedure below.

Start in AeroVis with the view you like.

AeroVis glyph plot showing all glyphs.

Starting glyph plot.

Camera View Settings

Before you go capturing any screenshots, carefully record the camera view settings. Do this by finding the camera settings icon on the view menu. Click it.  It opens up the camera view settings dialog.  Write everything down.

Camera icon from AeroVis

Camera Settings icon

Camera Settings dialog

Camera Settings dialog

Double-check.  Once you’ve captured the camera information, you can close AeroVis, come back later, and generate exactly the same image.

Capturing the Image

Open the Snapshot Controls dialog by clicking the snapshot icon in AeroVis.

Snapshot Icon

AeroVis snapshot controls

AeroVis snapshot controls

Resize by a big factor.  I like 5.0, but suit yourself and don’t be embarrassed to make a huge file.

Now turn off the axes and repeat.  We’re going to make better-looking axes by hand, but we need to know where they are relative to the glyphs, which is why we made the first plot.

The same glyph plot with no axes

Creating the Vector Graphics File

Open up Illustrator or Inkscape.  Make a layer called “reference.”  Import the version of the image that has axes into your reference layer.

Now make a layer called “axes.”  Using the reference layer as a guide, draw axes.  You’re doing this because, while you can’t make the glyphs into smooth, beautiful vector graphics, you can fix the axes.  Include whatever axes labels you want.  I like to draw the back walls, but you could just do the principal axes, or the whole box like AeroVis does.

Vector graphics axes

Vector graphics axes

See how they aren’t all jagged like in the snapshot?  That’s why we did this.

Add Transparency

Open up the image that doesn’t have axes using a raster graphics editor like Photoshop or the Gimp.  Add transparency to the current layer.  Select the color white, and delete it.  Now all that’s left is the glyphs and the legend. Note from Joe: This transparency idea is great. One benefit is you can draw things behind the glyphs if you’d like, such as gridlines. Also, you can use the “Lasso” tool to trace around the figure to remove previous labels, and if you use transparency to get rid of the whitespace, when you import it into another program, it will have nice and “clean” edges.

Over in your vector graphics editor, make a new layer.  Call it “glyphs”.  In Gimp/Photoshop, select the rectangle containing just the glyphs, then copy and paste it into the glyphs layer of your vector graphics image.  Line up these glyphs with the glyphs in the reference layer, then hide the reference layer.  Now you have a version of your glyph plot with nice axes!

Note from Joe: If you have problems copy/pasting like Matt suggests, you can save your copy/paste in a png (which preserves transparency) and turn compression completely off. I don’t think you use much quality doing this, and you have a copy of the file with no axes for your reference later on.

Glyph plot with nice axes

Glyph plot with nice axes

Second Figure

This is where it helps to have written down the camera settings. We’re going to make a second figure with certain glyphs emphasized.  Go back to AeroVis, and enter your camera settings. Brush the data so that only your chosen glyphs are visible.  Hide the axes, and take a snapshot.

Brushed Data with No Axes

Brushed Data with No Axes

Open the snapshot in your raster editor (Gimp / Photoshop).  As before, add transparency, select and delete the color white.  Make a new layer in your vector editor (Inkscape / Illustrator) above the axes layer but below the glyphs layer.  Paste the glyphs there and line them up.  You may need to hide the glyphs layer and use the reference layer instead, if you can’t see the ones you just pasted in.  Adjust the transparency of the glyphs layer until there’s a clear distinction between your emphasized glyphs and your de-emphasized glyphs.  The reason we put the new layer under the glyphs layer is that, with the transparency, it preserves the illusion of depth.  Any glyphs that were obscuring the emphasized glyphs in the original screenshot still appear to be in front of the emphasized glyphs.

Final Plot with Emphasized Glyphs

Final Plot with Emphasized Glyphs

AeroVis Documentation

Hello AeroVis Users:

I have uploaded the documentation for AeroVis as well as the summary files associated with the Qt upgrade and bug fixes/upgrades.  Links to the files are available below:

AeroVisQt_Documentation_v2012.01.04

AeroVisQt_v2012.01.01_Updates&BugFixes

AeroVisQt_v2011_QtUpgradeSummary

I will try and keep these files as up-to-date as possible with changes to the software.  Please note that in order to download the software, you will need to be added to the Angel hosting site.  Please email me if you need to be added to the site.

–Josh

Code Sample: Modify AeroVis files for Matlab

This is one in a series of code examples. Others: Timing for C++

You may find yourself in a situation where you have to modify the data directly in an AeroVis input file.  For example, I had to change all my objectives into metric units.  The following code, “aerovischangeformat.m” took the old aerovis input file, “wrrcaseC_aerovis.out” and changed it to “wrrcaseC_aerovis_metric.out”.

This is a good exercise to use Matlab’s low level file input/output, as explained here, to do some powerful stuff.  I’d suggest modifying this code for your own purposes if you need it.  To use these codes, copy and paste them into new text files from the website.

aerovischangeformat.m

 filename_base = 'wrrcaseC_aerovis';
 extension = '.out';
 modifier = '_metric';
 num_headerlines = 5;
 num_columns = 7;
 header_rewrite_ix = 2;
 header_rewrites = {'# <DATA_HEADER> Cost, Reliability, Dropped Transfers , Surplus Water, Rights, Options, Leases'};


%% Perform calcs

%open file
 fid = fopen([filename_base extension]);

%read headers
 for i = 1:num_headerlines
     headers{i} = fgetl(fid);
 end

%get data
 rawdata = fscanf(fid, '%f', inf);
 fclose(fid);

%reshape data
 raw_it = 1;
 row_it = 1;
 while 1
     if raw_it > length(rawdata)
        break;
     end
     for col_it = 1:num_columns
         data(row_it, col_it) = rawdata(raw_it);
         raw_it = raw_it + 1;
     end
     row_it = row_it + 1;
 end

%modify data
 data(:,1) = data(:,1)./1000000; %in millions
 data(:,3) = data(:,3).*(1233.48184/1e6); %acre-foot into cubic m
 data(:,4) = data(:,4).*(1233.48184/1e6); %acre-foot into cubic m
 data(:,5) = data(:,5).*(1233.48184/1e6); %acre-foot into cubic m
 data(:,6) = data(:,6).*(1233.48184/1e6); %acre-foot into cubic m
 data(:,7) = data(:,7).*(1233.48184/1e6); %acre-foot into cubic m

%write new file
 fid = fopen([filename_base modifier extension], 'wt');

  rewrite_it = 1;
 for i = 1:length(headers)
     if i ~= header_rewrite_ix(rewrite_it)
          fprintf(fid, '%s\n', headers{i});
     else
          fprintf(fid, '%s\n', header_rewrites{rewrite_it});
          if ( (rewrite_it + 1) <= length(header_rewrites))
              rewrite_it = rewrite_it + 1;
          end
     end
 end

%now write data
 outputformat = '%15.6f';
 for i = 1:num_columns-1
     outputformat = [outputformat '\t%15.6f'];
 end
 outputformat = [outputformat '\n'];

row_it = 1;
 while 1
     fprintf(fid, outputformat, data(row_it,:));
     row_it = row_it+1;
     if (row_it > size(data,1)) break; end;
 end
 fprintf(fid, '#');

fclose(fid);

wrrcaseC_aerovis.out

 # <GEN_HEADER> RS, Run, Gen, Popsize, Archive, NFE, Eperf, Eind, Time
 # <DATA_HEADER> cost, reliability, drops, surplus, rights, leases, options
 #
 2 6 16 1454 957 469224 0.000 0.000000 196470.880000
 #
 9000000.00000 0.98287 33956.00000 11818.40000 30190.00000 17504.66900 84891.78000
 9000000.00000 0.98550 33357.30000 11737.50000 30143.00000 17475.20000 84418.66000
 9000000.00000 0.98737 34495.60000 11854.20000 30009.00000 18333.50000 85987.38000
 9000000.00000 0.98405 35056.30000 11918.00000 30105.00000 17504.29000 86682.51000
 9000000.00000 0.98548 32555.40000 11619.40000 30212.00000 17511.52000 83590.19000
 #

wrrcaseC_aerovis_metric.out

 # <GEN_HEADER> RS, Run, Gen, Popsize, Archive, NFE, Eperf, Eind, Time
 # <DATA_HEADER> Cost, Reliability, Dropped Transfers , Surplus Water, Rights, Options, Leases
 #
 2 6 16 1454 957 469224 0.000 0.000000 196470.880000
 #
 9.000000 0.982870 41.884109 14.577782 37.238817 21.591691 104.712469
 9.000000 0.985500 41.145624 14.477993 37.180843 21.555342 104.128884
 9.000000 0.987370 42.549696 14.621940 37.015557 22.614039 106.063872
 9.000000 0.984050 43.241309 14.700637 37.133971 21.591224 106.921302
 9.000000 0.985480 40.156495 14.332319 37.265953 21.600142 103.106981
 #

AeroVis: Notes on Making GIFs

Hi everybody.  Here is a rough outline for the procedure for making an animated GIF in AeroVis and adding it to a Powerpoint.  The video I made shows the basic procedure, but the instructions below have extra instructions for using Powerpoint and making sure the gifs come out right.

Open Aerovis and get the plotting axis and window size set to where you want it.  Don’t resize the plotting window at all during the following steps, since you’ll want a consistent size throughout creating the animation.

  1. Open “Gif Controls” in the Tools menu of AeroVis.
  2. Click the red circle to indicate you want to “record” your actions in the gif.
  3. Set your frame speed and iterations.  Typically frame speed = 0.1 and iterations = 1 is appropriate.  Iterations = 1 means that the animation will occur once and not repeat.  Type 1 in the iterations box and press enter.  This is very important to make sure the setting will get written onto the gif file correctly.
  4. A nice trick is to combine the “take snapshot” tool with the create gif tool.  At the beginning of your animation, press the “Take Snapshot” command in the Window menu.  Then, without moving the screen, add an interpolation camera using the “Add Camera” button.  Continue adding interpolation cameras in positions where you want the animation to progress.  At the last interpolation camera, save a second snapshot using the “take snapshot” tool.
  5. To actually create the frames for the animation, click the interpolate spline button (and if you want to add a rotation, click the rotate camera button).  You should notice the image stack size increasing.  When you’ve added all the images to the image stack that you want, click “Create GIF’
  6. The image will be in the /Animations/ folder where your AeroVis data files are stored.
  7. In powerpoint, make one slide that has the first static image (from the /Snapshots/ folder).  Then, create a second slide that contains the gif animation.  Finally, if you want to annotate the end of the animation, make a third slide that has the last snapshot in it.
  8. You’ll want to make sure that the images line up just right.  Click to expand the image size options in Picture Tools in PowerPoint to make an exact image size and position, and repeat for all three slides to get the images to line up correctly.
  9. Also, please refer to the following website (http://www.soniacoleman.com/Tutorials/PowerPoint/animated_gifs/gifs.htm) for an explanation of the GIF header elements related to looping and iterations and how these relate to proper operation of the GIF file in MS PowerPoint.

Note From Josh:  Joe brings up a good point here.  For some entry boxes in come of the AeroVis dialogs, you have to be sure and press enter in order for the value you entered to make it into the software.  I will work on improving this behavior so that instead, AeroVis will capture entry box elements as they are being typed to eliminate the need to press “enter”.