Archive for November, 2008

First Direct Image of Multiple Exoplanets Orbiting a Star

Friday, November 14th, 2008

First Direct Image of Multiple Exoplanets Orbiting a Star | Wired Science from Wired.com

GEMINI RELEASES HISTORIC DISCOVERY IMAGE OF PLANETARY “FIRST FAMILY”

Wow! This is amazing and a serious blast from the past. It’s amazing because it’s the first time we have an image of an entire solar system.  It’s a blast from the past because the images were taken using the Gemini North and W.M. Keck Observatory telescopes.  OK, this is not the first time planets have been discovered. In fact, over 300 have been identified, but none with direct imaging. All previous planets were identified with a process called spectroscopy, which measures the slight wobble of a star as it is pulled by orbiting planets.

The problem with spectroscopy is that you only see the effects of the planet. We’ve never actually seen a planet until now. For a guy that often spends hours looking out on a clear night sky contemplating the universe, this has me giddy.

Now, why is this a blast from the past? If you check out my resume, you will see that I worked at Itek Optical Systems right out of college. Itek doesn’t exist anymore, but for a time they were at the top of the optical food chain. Mostly, Itek did work for NASA and the DOD because they were the only ones that needed and could afford what they built. However, Keck was large enough (and well funded) that Itek was one of the few firms in the world that could make it work.

Now, you’re probably thinking “What the hell does a 10 meter telescope need a software geek for?” Turns out, you can’t make a mirror 10 meters across that will support itself. It would have to be too thick and heavy. Therefore, you have to build it in pieces — 36 hexagons in this case. It’s the pieces that majorly complicate things. Normally, you want to build as accurate a main mirror as possible, but you always know that you can fix things up with secondary optics. This is very similar to a pair of glasses, and exactly what was done to Hubble when it returned blurry images at first. (BTW, Itek lost the Hubble contract because their proposal had the $700K fully assembled test that would have caught this problem. $700k sounds like a lot, but it was a whole lot less than the millions necessary to fix Hubble in space later). Unfortunately for Keck, an error in one of the 36 hexagons could not be fixed in secondary optics. Therefore, the each mirror segment had to be built to exacting specifications (within a few microns).  Still, what do you need a software guy for?  Three things actually.

First, the Keck mirror is more like a big parabola. As a result, each section is not symmetrical about its center, and that makes it extremely difficult to grind and polish with any degree of accuracy. The solution to the problem was to stress each piece to change its shape. Then you grind and polish to a symmetrical shape. Finally, you remove the stresses and the piece will pop to the asymmetrical shape you want.  The trick was to calculate how much and where to stress the piece. I make no claim to understand the formulas required to make this happen, but someone had to write the code to spit out the results.

Second, you have to know when you are done grinding and polishing. Each section had to polished to within a few microns of the desired shape. That shape was defined using Zernike coefficients.  To measure the piece, you used a carbon bar with sensors to measure height. You rotated the bar around the piece and measured the sensor heights along the line. Once you had a bunch of measurements, you needed to do a whole lot of matrix calculations to figure out the coefficients. This program was pretty straight forward.

Finally, once the piece was complete, we wanted to really know exactly what each piece looked like. That required a laser interferometer. Here is the problem though. Each piece was 2 meters across, and that required the laser source to be far enough away from the piece to require an extra mirror than normal (2 total). On top of that, minor temperature changes caused things to move around. To get an accurate measurement, you had to know exactly where everything in the room was. To figure that out, we used surveying equipment. Now, you should be asking why do we care where everything is. The reason is those two mirrors. Itek was one of the best optical manufacturers on the planet, and they made two of the flattest mirrors ever.  However, that wasn’t good enough for Keck because the defects in the flat mirrors were larger than the tolerances for Keck (it is REALLY hard to make something perfectly flat). Therefore, we had to come up with a way to remove the effects of the flat mirrors, and to do that we had to know exactly where they were.

So, your laser light path is:

  1. laser source
  2. 1st flat mirror
  3. Piece being measured
  4. 2nd flat mirror
  5. Piece being measured
  6. 1st flat mirror again
  7. Instrument

Using all the surveying data and extremely accurate data about the mirrors, my program would do all the coordinate system transformations necessary to subtract the influence of the two flat mirrors on the resulting measurements.  Again, this was a lot of matrix calculations. On an old Intel 386 (remember those?), it took about 30 minutes to solve all the equations.

All this was fun stuff for a young man right out of college to be trusted with. Here it is 20 years later, and I’m still reminded of those 2 years when a story like this comes up, or I walk by a magazine rack with Keck on the cover.

Bletchley Park Update

Thursday, November 6th, 2008

It looks like Bletchley Park may be saved for a while.  Several grants are in the works to keep what I consider the birthplace of serious computing alive for future generations to learn about.  In July, about 100 UK academics signed a letter to The Times condemning the neglect of Bletchley. That seemed to have kicked off the process.

More Asynchronous Processing

Tuesday, November 4th, 2008

In a previous series on using workling and starling for asychronous processing, I described how to setup background tasks. Here is a quick way to use this for emails without a lot of changes to your application.

First, create lib/asynch_mail.rb:


# Makes an actionmailer class queue its emails into a workling queue
# instead of sending them sycnhronously
#
# From now on all MyMailer.deliver_whatever_email calls create an entry in
# the MailerWorker.deliver_mail corresponding queue and should be processed
# by a worker. If you still want to deliver mail sycnhronously add a bang to the method call:
# MyMailer.deliver_whatever_email!
#
module AsynchMail
  def self.included(base)
    base.class_eval do
      class < < self
        alias_method :orig_method_missing, :method_missing

        # Catch deliver method calls to turn them into asynch calls
        def method_missing(method_symbol, *parameters)
          case method_symbol.id2name
          when /^deliver_([_a-z]\w*)\!/
            orig_method_missing(method_symbol, *parameters)
          when /^deliver_([_a-z]\w*)/
            mail = self.send("create_#{$1}", *parameters)
            MailerWorker.asynch_deliver_mail(:class => self.name, :mail => mail)
          else
            orig_method_missing(method_symbol, *parameters)
          end
        end
      end
    end
  end
end

Then, create app/workers/mailer_worker.rb:


class MailerWorker < Workling::Base
  def deliver_mail(options)
    Object.const_get(options[:class]).deliver(options[:mail])
  end
end

Now, all you need to do is include AsynchMail in your mailer class.


class MyMailer < ActionMailer::Base
   include AsynchMail
end

That’s it! No other changes to all your mail calls are required. All will automatically become asynchronous. If your application sends a lot of emails, I recommend you do this. There is no reason to make your users wait for an email to be sent.

The only downside with this is that now emailing happens outside of Mongrel. This means that link_to does not have access to the HOST. As a result, you can can’t easily use the route helpers to generate urls. You will need to build your urls manually. At one point, I had some code that got around this, but it stopped working when I upgraded to Rails 2.x. In my app, it was easier to fix the urls than make the other work. If someone can provide this, it would great.