<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>input/.gitignore</filename>
    </added>
    <added>
      <filename>log/.gitignore</filename>
    </added>
    <added>
      <filename>output/.gitignore</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -4,3 +4,4 @@ log/*
 db/*.sqlite3
 *.swp
 database.yml
+doc/*</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -1,32 +1,62 @@
 require 'lib/ruby-processing'
 
-$co2_low_bound = 370
+# global variables for the benefit of Processing
+# lower and upper bounds for recorded CO2 
+$co2_low_bound = 370 
 $co2_high_bound = 450
 
+# Co2ColorCode implements the color scale used to render columns of
+# CO2 in Google Earth.  
+#
+# == Usage
+#
+#   Co2ColorCode.colorify(co2_ppm) #=&gt; appropriate color in hex format
+#   Co2ColorCode.make_color_bar #=&gt; outputs an image of the color scale
 class Co2ColorCode
+
+  # Returns the color associated with @value@ of CO2
+  #
+  # Return format is #AABBGGRR in hexadecimal notation
   def self.colorify(value)
     v = value.to_f
-    if v == -9999.99
+    if v == -9999.99 # -9999.99 is the fill value for the dataset
       return abgr(0,0,0,0)
     else
-      c = normalized_colorify(normalize(v, $co2_low_bound, $co2_high_bound))
+      c = normalized_colorify(
+        normalize($co2_low_bound, $co2_high_bound, v)
+      )
+      
       abgr(255 ,255*c[2], 255*c[1], 255*c[0])
     end
   end
 
+  # Returns the color for the associated normalized value
+  # 
+  # Return format is [red, green, blue] where all components are in range
+  # [0.0, 1.0]
   def self.normalized_colorify(norm_value)
     hsv((norm_value*300) +60, 0.75, 0.75)
   end
 
+  # Writes a PNG of the color scale to disk using Processing.  This image can
+  # be used as a ScreenOverlay in Google Earth
   def self.make_color_bar
     Co2ColorCodeBar.new :title =&gt; &quot;Color Bar&quot;, :height =&gt; 400, :width =&gt; 60 
   end
 
-
+  # Convenience method to format integer color components into abgr hex format
   def self.abgr(a,b,g,r)
     &quot;%02X%02X%02X%02X&quot; % [a,b,g,r]
   end
 
+  # Converts a value expressed in HSV colormode to RGB
+  # 
+  # @h@ is on range [0, 360]
+  # @s@ and @v@ are on range [0.0, 1.0]
+  #
+  # Returns [red, green, blue] where all components are on range [0.0, 1.0]
+  # Math stolen from 
+  # http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_HSV_to_RGB
   def self.hsv(h, s, v)
     h_i = (h/60).floor.to_i % 6
     f = (h/60) - (h/60).floor
@@ -50,8 +80,8 @@ class Co2ColorCode
     end
   end
 
-
-  def self.normalize(value, min, max)
+  # Constrains values on range [min, max] to between 0.0 and 1.0
+  def self.normalize(min, max, value)
     if value &gt; max
       return max
     elsif value &lt; min
@@ -61,34 +91,45 @@ class Co2ColorCode
     end
   end
 
+  # Linear Interpolation: transforms @value@ on range [0.0, 1.0] to equivalent
+  # value on range [min, max]
   def self.lerp(min, max, value)
     (max-min)*value + min
   end
 end
 
+# Processing class to create color bar for Co2ColorCode
 class Co2ColorCodeBar &lt; Processing::App
   def setup
     background(255)
     font = load_font(&quot;#{GTRON_ROOT}/lib/Electron-12.vlw&quot;)
     text_font(font)
     fill(0)
-    last_line_number = nil
+
+    last_line_number = nil #ensures proper spacing of labels
     for i in (0...height)
       value = (1.0/height)*i
-      colors = Co2ColorCode.normalized_colorify(value).map{|v| (255*v).to_i } 
+
+      #transform colors on range [0.0, 1.0] to colors on range [0, 255]
+      colors = Co2ColorCode.normalized_colorify(value).map{|v| (255*v).to_i }
+
       stroke(colors[0], colors[1], colors[2])
       line(25,i,width,i)
 
+      # find co2 measurement associated with generated normalized value
       orig_val = Co2ColorCode.lerp($co2_low_bound, $co2_high_bound, value).to_i
       
+      # label significant points on the bar with values
       if (orig_val % 10 == 0) &amp;&amp; orig_val != last_line_number
         last_line_number = orig_val
         text(&quot;#{orig_val}&quot;, 2, i+12)
-        #stroke(0)
-        #line(23,i,height,i)
       end
     end
+
     save &quot;#{GTRON_ROOT}/output/co2_color_bar.png&quot;
+    
+    # close window and quit the method
+    # There might be a cleaner way
     exit
   end
 end</diff>
      <filename>lib/co2_color_code.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,18 +13,36 @@ include Math
 # the ones without that suffix return KML::Polygon
 class KmlShapes
 
+  # Creates an extruded circle centered on (@lat@, @lon@) at altitude @alt@
+  # with a radius of @radius@ (in meters)
+  #
+  # Google Earth is extremely weird about making real cylinders (I would love
+  # a triangle strip primitive) so cylinders are faked by extruding towards
+  # the center of the earth.  Luckily this meets the needs of the ASCENDS
+  # visualization
   def self.cylinder(lon, lat, alt, radius)
     cylinder = circle(lon, lat, alt, radius)
     cylinder.extrude = true
     cylinder
   end
 
+  # Creates a Google Earth polygon that is a circle centered on (@lat@, @lon@)
+  # at an altitude of @alt@ with a radius of @radius@ (in meters).
   def self.circle(lon, lat, alt, radius)
     bounds = circle_coords(lon, lat, alt, radius)
-    KML::Polygon.new(:outer_boundary_is =&gt; format_bounds(bounds + [bounds.first]),
-                    :altitude_mode =&gt; 'absolute')
+    KML::Polygon.new(
+      :outer_boundary_is =&gt; format_bounds(bounds + [bounds.first]),
+      :altitude_mode =&gt; 'absolute'
+    )
   end
 
+  # generates coordinates in the form [[lon, lat, alt],...] for a circle
+  # centered on (@lon@, @lat@) at altitude @alt@ with a radius of @radius@
+  # (in meters)
+  #
+  # This code uses the haversine formula and was ported from a PHP
+  # Google Earth circle generator:
+  # http://dev.bt23.org/keyhole/circlegen/output.phps
   def self.circle_coords(lon, lat, alt, radius)
     lat = deg2rad(lat)
     lon = deg2rad(lon)
@@ -45,14 +63,18 @@ class KmlShapes
   end
 
   private
+
+  # converts degrees to radians
   def self.deg2rad(degree)
     degree.to_f*(PI/180.0)
   end
 
+  # converts radians to degrees
   def self.rad2deg(radian)
     radian.to_f*(180.0/PI)
   end
   
+  # returns LinearRing object with correct bounds
   def self.format_bounds(bounds)
     KML::LinearRing.new(:coordinates =&gt; bounds)
   end</diff>
      <filename>lib/kml_shapes.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a6b76decde0ab2a790fe4a53f7e2316d4b713cd9</id>
    </parent>
  </parents>
  <author>
    <name>Ben Hughes</name>
    <email>ben@pixelmachine.org</email>
  </author>
  <url>http://github.com/schleyfox/ascends_viz/commit/83d8a100b3b02037c6b3905385215f442d900c6a</url>
  <id>83d8a100b3b02037c6b3905385215f442d900c6a</id>
  <committed-date>2008-06-24T14:48:40-07:00</committed-date>
  <authored-date>2008-06-24T14:48:40-07:00</authored-date>
  <message>Commented my helper libraries

* added dirs so it doesn't fail weirdly</message>
  <tree>c1da0e3336a8c0ad93b36aa997b232bdf95a131d</tree>
  <committer>
    <name>Ben Hughes</name>
    <email>ben@pixelmachine.org</email>
  </committer>
</commit>
