Day/Night Terminator on Map

QUESTION: Can you show me how to create a map projection and draw a day/night terminator on it?

ANSWER: Thanks to Kelly Dean and Andrew Cool for supplying me with example code to help me answer this question. The solution I have come up with is slightly different from theirs, and uses the AVHRR image of the world that comes with the IDL distribution example data files as the basis for the map projection. In their code, they simply draw a circle about the edge of the terminator. I wanted to show the portion of the world map in darkness in darker colors.

To accomplish this, I do a bit of fancy dancing with the AVHRR image, converting a 24-bit image from RGB to the HLS color system, modifying the lightness values, the switching back to RGB. This worked considerably better than I expected it to work.

The program I came up with is named cgTerminatorMap. The user can specify the center latitude and longitude of the map, and any of seven different map projections, as well as the date and time. The seven allowed map projections are:

If time is unspecified, the current date and time are used.

Here is an example of using the program. Note that many programs from both the Coyote Library and the Johns Hopkins University Applied Physics Lab (JHUAPL) Library are required. You should download both of these libraries and add them to your IDL path to use this program. You can see an example of the map and download the code for the program in the Coyote Plot Gallery.

   IDL> Window, XSize=800, YSize=400, Title='Day/Night Terminator on a Map Projection'
   IDL> Terminator_Map, -120, 0, Map_Projection='CYLINDRICAL', Time=SYSTIME()
A map projection with day/night terminator.
Here is an Robinson map projection taken at 11:30 AM Colorado time on 15 November 2011. The yellow dot is the latitude/longitude point of the sun on the map. The night side of the terminator is rendered in darker colors.

Here is code you could use to animate the day/night terminator over a 24-hour period.

   PRO Animate_Terminator
      thisWindow = !D.Window
      Window, /Free, /Pixmap, XSize=800, YSize=400
      pixmap = !D.Window
      XInterAnimate, Set=[800, 400, 24], /ShowLoad
      FOR j=0, 23 DO BEGIN
         hour = String(j, Format='(I2)')
         cgTerminator_Map, Map=5, Time='12 APR 2006 ' + hour + ':00:00', Image=image
         XInterAnimate, Frame=j, Image=image
      XInterAnimate, 10
      WDelete, pixmap
      IF thisWindow GE 0 THEN WSet, thisWindow

Web Coyote's Guide to IDL Programming