Shallow Thoughts : : science

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Thu, 01 Oct 2015

Lunar eclipse animations

[Eclipsed moon rising] The lunar eclipse on Sunday was gorgeous. The moon rose already in eclipse, and was high in the sky by the time totality turned the moon a nice satisfying deep red.

I took my usual slipshod approach to astrophotography. I had my 90mm f/5.6 Maksutov lens set up on the patio with the camera attached, and I made a shot whenever it seemed like things had changed significantly, adjusting the exposure if the review image looked like it might be under- or overexposed, occasionally attempting to refocus. The rest of the time I spent socializing with friends, trading views through other telescopes and binoculars, and enjoying an apple tart a la mode.

So the images I ended up with aren't all they could be -- not as sharply focused as I'd like (I never have figured out a good way of focusing the Rebel on astronomy images) and rather grainy.

Still, I took enough images to be able to put together a couple of animations: one of the lovely moonrise over the mountains, and one of the sequence of the eclipse through totality.

Since the 90mm Mak was on a fixed tripod, the moon drifted through the field and I had to adjust it periodically as it drifted out. So the main trick to making animations was aligning all the moon images. I haven't found an automated way of doing that, alas, but I did come up with some useful GIMP techniques, which I'm in the process of writing up as a tutorial.

Once I got the images all aligned as layers in a GIMP image, I saved them as an animated GIF -- and immediately discovered that the color error you get when converting to an indexed GIF image loses all the beauty of those red colors. Ick!

So instead, I wrote a little Javascript animation function that loads images one by one at fixed intervals. That worked a lot better than the GIF animation, plus it lets me add a Start/Stop button.

You can view the animations (or the source for the javascript animation function) here: Lunar eclipse animations

Tags: , , ,
[ 12:55 Oct 01, 2015    More science/astro | permalink to this entry | comments ]

Fri, 24 Oct 2014

Partial solar eclipse, with amazing sunspots

[Partial solar eclipse, with sunspots] We had perfect weather for the partial solar eclipse yesterday. I invited some friends over for an eclipse party -- we set up a couple of scopes with solar filters, put out food and drink and had an enjoyable afternoon.

And what views! The sunspot group right on the center of the sun's disk was the most large and complex I'd ever seen, and there were some much smaller, more subtle spots in the path of the eclipse. Meanwhile, the moon's limb gave us a nice show of mountains and crater rims silhouetted against the sun.

I didn't do much photography, but I did hold the point-and-shoot up to the eyepiece for a few shots about twenty minutes before maximum eclipse, and was quite pleased with the result.

An excellent afternoon. And I made too much blueberry bread and far too many oatmeal cookies ... so I'll have sweet eclipse memories for quite some time.

Tags: , ,
[ 09:15 Oct 24, 2014    More science/astro | permalink to this entry | comments ]

Thu, 31 Jul 2014

Predicting planetary visibility with PyEphem

Part II: Predicting Conjunctions

After I'd written a basic script to calculate when planets will be visible, the next step was predicting conjunctions, times when two or more planets are close together in the sky.

Finding separation between two objects is easy in PyEphem: it's just one line once you've set up your objects, observer and date.

p1 = ephem.Mars()
p2 = ephem.Jupiter()
observer = ephem.Observer()  # and then set it to your city, etc. ='2014/8/1')

ephem.separation(p1, p2)

So all I have to do is loop over all the visible planets and see when the separation is less than some set minimum, like 4 degrees, right?

Well, not really. That tells me if there's a conjunction between a particular pair of planets, like Mars and Jupiter. But the really interesting events are when you have three or more objects close together in the sky. And events like that often span several days. If there's a conjunction of Mars, Venus, and the moon, I don't want to print something awful like

  Conjunction between Mars and Venus, separation 2.7 degrees.
  Conjunction between the moon and Mars, separation 3.8 degrees.
  Conjunction between Mars and Venus, separation 2.2 degrees.
  Conjunction between Venus and the moon, separation 3.9 degrees.
  Conjunction between the moon and Mars, separation 3.2 degrees.
  Conjunction between Venus and the moon, separation 4.0 degrees.
  Conjunction between the moon and Mars, separation 2.5 degrees.

... and so on, for each day. I'd prefer something like:

Conjunction between Mars, Venus and the moon lasts from Friday through Sunday.
  Mars and Venus are closest on Saturday (2.2 degrees).
  The moon and Mars are closest on Sunday (2.5 degrees).

At first I tried just keeping a list of planets involved in the conjunction. So if I see Mars and Jupiter close together, I'd make a list [mars, jupiter], and then if I see Venus and Mars on the same date, I search through all the current conjunction lists and see if either Venus or Mars is already in a list, and if so, add the other one. But that got out of hand quickly. What if my conjunction list looks like [ [mars, venus], [jupiter, saturn] ] and then I see there's also a conjunction between Mars and Jupiter? Oops -- how do you merge those two lists together?

The solution to taking all these pairs and turning them into a list of groups that are all connected actually lies in graph theory: each conjunction pair, like [mars, venus], is an edge, and the trick is to find all the connected edges. But turning my list of conjunction pairs into a graph so I could use a pre-made graph theory algorithm looked like it was going to be more code -- and a lot harder to read and less maintainable -- than making a bunch of custom Python classes.

I eventually ended up with three classes: ConjunctionPair, for a single conjunction observed between two bodies on a single date; Conjunction, a collection of ConjunctionPairs covering as many bodies and dates as needed; and ConjunctionList, the list of all Conjunctions currently active. That let me write methods to handle merging multiple conjunction events together if they turned out to be connected, as well as a method to summarize the event in a nice, readable way.

So predicting conjunctions ended up being a lot more code than I expected -- but only because of the problem of presenting it neatly to the user. As always, user interface represents the hardest part of coding.

The working script is on github at

Tags: , , ,
[ 19:57 Jul 31, 2014    More science/astro | permalink to this entry | comments ]

Wed, 23 Jul 2014

Predicting planetary visibility with PyEphem

Part 1: Basic Planetary Visibility

All through the years I was writing the planet observing column for the San Jose Astronomical Association, I was annoyed at the lack of places to go to find out about upcoming events like conjunctions, when two or more planets are close together in the sky. It's easy to find out about conjunctions in the next month, but not so easy to find sites that will tell you several months in advance, like you need if you're writing for a print publication (even a club newsletter).

For some reason I never thought about trying to calculate it myself. I just assumed it would be hard, and wanted a source that could spoon-feed me the predictions.

The best source I know of is the RASC Observer's Handbook, which I faithfully bought every year and checked each month so I could enter that month's events by hand. Except for January and February, when I didn't have the next year's handbook yet by the time my column went to press and I was on my own. I have to confess, I was happy to get away from that aspect of the column when I moved.

In my new town, I've been helping the local nature center with their website. They had some great pages already, like a What's Blooming Now? page that keeps track of which flowers are blooming now and only shows the current ones. I've been helping them extend it by adding features like showing only flowers of a particular color, separating the data into CSV databases so it's easier to add new flowers or butterflies, and so forth. Eventually we hope to build similar databases of birds, reptiles and amphibians.

And recently someone suggested that their astronomy page could use some help. Indeed it could -- it hadn't been updated in about five years. So we got to work looking for a source of upcoming astronomy events we could use as a data source for the page, and we found sources for a few things, like moon phases and eclipses, but not much.

Someone asked about planetary conjunctions, and remembering how I'd always struggled to find that data, especially in months when I didn't have the RASC handbook yet, I got to wondering about calculating it myself. Obviously it's possible to calculate when a planet will be visible, or whether two planets are close to each other in the sky. And I've done some programming with PyEphem before, and found it fairly easy to use. How hard could it be?

Note: this article covers only the basic problem of predicting when a planet will be visible in the evening. A followup article will discuss the harder problem of conjunctions.

Calculating planet visibility with PyEphem

The first step was figuring out when planets were up. That was straightforward. Make a list of the easily visible planets (remember, this is for a nature center, so people using the page aren't expected to have telescopes):

import ephem

planets = [

Then we need an observer with the right latitude, longitude and elevation. Elevation is apparently in meters, though they never bother to mention that in the PyEphem documentation:

observer = ephem.Observer() = "Los Alamos"
observer.lon = '-106.2978' = '35.8911'
observer.elevation = 2286  # meters, though the docs don't actually say

Then we loop over the date range for which we want predictions. For a given date d, we're going to need to know the time of sunset, because we want to know which planets will still be up after nightfall. = d
sunset = observer.previous_setting(sun)

Then we need to loop over planets and figure out which ones are visible. It seems like a reasonable first approach to declare that any planet that's visible after sunset and before midnight is worth mentioning.

Now, PyEphem can tell you directly the rising and setting times of a planet on a given day. But I found it simplified the code if I just checked the planet's altitude at sunset and again at midnight. If either one of them is "high enough", then the planet is visible that night. (Fortunately, here in the mid latitudes we don't have to worry that a planet will rise after sunset and then set again before midnight. If we were closer to the arctic or antarctic circles, that would be a concern in some seasons.)

min_alt = 10. * math.pi / 180.
for planet in planets: = sunset
    if planet.alt > min_alt:
        print, "is already up at sunset"

Easy enough for sunset. But how do we set the date to midnight on that same night? That turns out to be a bit tricky with PyEphem's date class. Here's what I came up with:

    midnight = list(
    midnight[3:6] = [7, 0, 0] =
    if planet.alt > min_alt:
        print, "will rise before midnight"

What's that 7 there? That's Greenwich Mean Time when it's midnight in our time zone. It's hardwired because this is for a web site meant for locals. Obviously, for a more general program, you should get the time zone from the computer and add accordingly, and you should also be smarter about daylight savings time and such. The PyEphem documentation, fortunately, gives you tips on how to deal with time zones. (In practice, though, the rise and set times of planets on a given day doesn't change much with time zone.)

And now you have your predictions of which planets will be visible on a given date. The rest is just a matter of writing it out into your chosen database format.

In the next article, I'll cover planetary and lunar conjunctions -- which were superficially very simple, but turned out to have some tricks that made the programming harder than I expected.

Tags: , , ,
[ 21:32 Jul 23, 2014    More science/astro | permalink to this entry | comments ]

Sat, 07 Sep 2013

Daytime Venus-Moon-Saturn conjunction

Tomorrow, Sunday September 8th, is an interesting astronomical event: a nice conjunction of a slim crescent moon and gibbous Venus, with Saturn hanging above and to the left of the pair.

That alone isn't anything unusual, though they'll be a lovely naked-eye sight just after nightfall. But here's the kicker: they'll be quite a bit closest during the daytime, best around 2-3 in the afternoon, Which makes for a fun exercise: can you find the crescent moon during daylight, then use it to guide you to Venus (right above it, about a degree away) and Saturn (about 10 degrees away, down and left)?

They'll be just a little east of due south, and about 40 degrees up. You'll definitely need binoculars to find Saturn, and they might help in finding the other two as well, depending on how bright and how hazy your afternoon sky is. Once you find them, a low powered telescope view should show Venus' phase and Saturn's rings. Venus is gibbous, alas; it would have been fun to see two crescents lined up one above the other.

If you have trouble finding them, wait until 3:30 pm, when they'll be transiting. At that point, you should be able to point due south, sweep your binoculars (or just your eyes) up just short of halfway to the zenith, and the moon should be there.

If you don't get a chance to watch the daylight conjunction, or don't have binoculars or a telescope handy, at least take a naked eye look at the trio at nightfall.

Mars and an early view of Comet ISON

As long as I'm reposting tips from my SJAA Ephemeris Shallow Sky column, there's another interesting thing in the sky this month: Comet C/2012 S1 ISON. Yes, that's the "super comet" that's supposed to become brighter than the moon. No, it won't be bright yet. It's still super wimpy, and worse, it's still in the morning sky, so it's not an easy or convenient target.

On the other hand, through September and October, Mars and Comet ISON will be within a few degrees of each other. So if you're willing to stay up (or get up) for early morning dark-sky observing, and you have a big telescope, this could be a nice view.

The comet won't be very impressive yet -- it's only expected to be 10th magnitude in September -- but such close proximity to Mars makes it easy to find and keep track of. In September, the pair don't rise until about 3:30am, and that won't change much for the next few months. The comet will probably stay below naked eye visibility at least for the next two months, brightening from 11th magnitude in early September to maybe 7th magnitude by Halloween.

As September opens, ISON makes a triangle with Mars and M44, the Beehive cluster. The comet stands about 2 degrees north of the Beehive and about 5 degrees east of Mars. But it closes with Mars as the month progresses: by the end of September you can find the comet about two degrees north of Mars, and by the middle of October they'll be down to only a degree apart (with ISON brightening to about ninth magnitude).

About that Beehive cluster: right now (September 7 through 9), Mars is passing right through the Beehive, like an angry red wasp among the smaller bees. Should be a nice view even if the comet isn't. It's a good binocular or even naked eye view (though great with a telescope, too). So if you find yourself up before dawn, definitely take a look.

[ 19:34 Sep 07, 2013    More science/astro | permalink to this entry | comments ]

Wed, 03 Jul 2013

Mad Moon Models

[This a slight revision of my monthly "Shallow Sky" column in the SJAA Ephemeris newsletter. Looks like the Ephemeris no longer has an online HTML version, just the PDF of the whole newsletter, so I may start reposting my Ephemeris columns here more often.]

[Plate IX: The Lunar Apennines, Archemedes &c.] Last month I stumbled upon a loony moon book I hadn't seen before, one that deserves consideration by all lunar observers.

The book is The Moon: Considered as a Planet, a World, and a Satellite by James Nasmyth, C.E. and James Carpenter, F.R.A.S. It's subtitled "with twenty-six illustrative plates of lunar objects, phenomena, and scenery; numerous woodcuts &c." It was written in 1885.

Astronomers may recognize the name Nasmyth: his name is attached to a modified Cassegrain focus design used in a lot of big observatory telescopes. Astronomy was just a hobby for him, though; he was primarily a mechanical engineer. His coauthor, James Carpenter, was an astronomer at the Royal Greenwich Observatory.

The most interesting thing about their book is the plates illustrating lunar features. In 1885, photography wasn't far enough along to get good close-up photos of the moon through a telescope. But Nasmyth and Carpenter wanted to show something beyond sketches. So they built highly detailed models of some of the most interesting areas of the moon, complete with all their mountains, craters and rilles, then photographed them under the right lighting conditions for interesting shadows similar to what you'd see when that area was on the terminator.

[David North explaining the moon] I loved the idea, since I'd worked on a similar but much less ambitious project myself. Over a decade ago, before we were married, Dave North got the idea to make a 3-D model of the full moon that he could use for the SJAA astronomy class. I got drafted to help. We started by cutting a 3-foot disk of wood, on which we drew a carefully measured grid corresponding to the sections in Rukl's Atlas of the Moon. Then, section by section, we drew in the major features we wanted to incorporate. Once the drawing was done, we mixed up some spackle -- some light, and some with a little black paint in it for the mare areas -- and started building up relief on top of the features we'd sketched. The project was a lot of fun, and we use the moon model when giving talks (otherwise it hangs on the living room wall).

Nasmyth and Carpenter's models cover only small sections of the moon -- Copernicus, Plato, the Apennines -- but in amazing detail. Looking at their photos really is like looking at the moon at high magnification on a night of great seeing.

So I had to get the book. Amazon has two versions, a paperback and a hardcover. I opted for the paperback, which turns out to be scanned from a library book (there's even a scan of the pocket where the book's index card goes). Some of the scanning is good, but some of the plates come out all black. Not very satisfying.

But once I realized that an 1885 book was old enough to be public domain, I checked the web. I found two versions: one at and one on Google Books. They're scans from two different libraries; the scan is better, but the epub version I downloaded for my ebook reader has some garbled text and a few key plates, like Clavius, missing. The Google version is a much worse scan and I couldn't figure out if they had an epub version. I suspect the hardcover on Amazon is likely a scan from yet a fourth library.

At the risk of sounding like some crusty old Linux-head, wouldn't it be nice if these groups could cooperate on making one GOOD version rather than a bunch of bad ones?

I also discovered that the San Jose library has a copy. A REAL copy, not a scan. It gave me a nice excuse to take the glass elevator up to the 8th floor and take in the view of San Jose. And once I got it, I scanned all the moon sculpture plates myself. Sadly, like the ebook, the San Jose copy is missing Copernicus. I wonder if vandals are cutting that page out of library copies? That makes me wince even to think of it, but I know such things happen.

Whichever version you prefer, I'd recommend that lunies get hold of a copy. It's a great introduction to planetary science, with very readable discussions of how you measure things like the distance and size of the moon. It's an even better introduction to lunar observing: if you merely go through all of their descriptions of interesting lunar areas and try to observe the features they mention, you'll have a great start on a lunar observing program that'll keep you busy for months. For experienced observers, it might give you a new appreciation of some lunar regions you thought you already knew well. Not at super-fine levels of detail -- no Alpine Valley rille -- but a lot of good discussion of each area.

[Plate XVIII: Aristarchus & Herodotus ] Other parts of the book are interesting only from a historical perspective. The physical nature of lunar features wasn't a settled issue in 1885, but Nasmyth and Carpenter feel confident that all of the major features can be explained as volcanism. Lunar craters are the calderas of enormous volcanoes; mountain ranges are volcanic too, built up from long cracks in the moon's crust, like the Cascades range in the Pacific Northwest.

There's a whole chapter on "Cracks and Radiating Streaks", including a wonderful plate of a glass ball with cracks, caused by deformation, radiating from a single point. They actually did the experiment: they filled a glass globe with water and sealed it, then "plunged it into a warm bath". The cracks that resulted really do look a bit like Tycho's rays (if you don't look TOO closely: lunar rays actually line up with the edges of the crater, not the center).

It's fun to read all the arguments that are plausible, well reasoned -- and dead wrong. The idea that craters are caused by meteorite impacts apparently hadn't even been suggested at the time.

Anyway, I enjoyed the book and would definitely recommend it. The plates and observing advice can hold their own against any modern observing book, and the rest ... is a fun historical note.

Here are some places to get it:


Or, try your local public library -- they might have a real copy!

Tags: , , , ,
[ 16:12 Jul 03, 2013    More science/astro | permalink to this entry | comments ]

Wed, 08 May 2013

Gamymede whac-a-moon tonight

A couple of months ago I wrote about watching an eclipse of Europa by Jupiter's shadow. It's a game I call "Whac-a-Moon", where a moon comes out from behind Jupiter, but stays there for only a short time then disappears into eclipse. If you aren't ready for it, it's gone.

This can only happen when Jupiter's shadow is offset from Jupiter that there's a gap between the planet and the shadow as seen from Earth. Jupiter is getting low in the west, and soon we'll lose it behind the sun, but tonight, Wednesday May 8, there's a decent Ganymede Whac-a-Moon opportunity for those of us on the US west coast.

Ganymede disappears behind Jupiter at 6:45 pm PDT, still during daylight. Some time around 9:43 Ganymede reappears from behind Jupiter, but it only stays visible for a couple of minutes before entering Jupiter's eclipse. Don't trust these times I'm giving you: set up at least five minutes early, preferably more than that. And set up somewhere with a good western horizon, because Jupiter will be very low, less than 8 degrees above the horizon.

You can simulate the event on my Javascript Jupiter. When the G goes blue, that means Ganymede is in eclipse. But the simulation won't show you the interesting part: how gradual the eclipse is, as the moon slides through the edge of Jupiter's shadow. During the Europa eclipse a few months ago, I wanted to record the time of disappearance so I could adjust my code accordingly, but I found I couldn't pin it down at all -- Europa started dimming almost as soon as it emerged from behind Jupiter, and kept dimming until I couldn't convince myself I saw it any more.

So far, I've only watched Europa as it slid into eclipse by Jupiter's shadow; I haven't whacked Ganymede. But Ganymede is so much larger that I suspect the slow dimming effect will be even more obvious. Unfortunately, I'm not optimistic about being able to see it myself; we've had cloudy skies here for the last few nights, and that combined with the low western horizon may do me in. I may have to wait until autumn, when Jupiter will next be visible in our evening skies. But I hope someone reading this gets a chance to see this month's eclipse.

Tags: ,
[ 11:46 May 08, 2013    More science/astro | permalink to this entry | comments ]

Tue, 12 Mar 2013

The Europa Eclipse -- results

I wrote last week about an upcoming eclipse of Europa by Jupiter's shadow. One of the interesting things I'd found was how much the predicted times of Europa's appearance from behind Jupiter, and subsequent disappearance into Jupiter's shadow, varied depending on which program you were using. I had just recently managed to get my own Javascript Jupiter page showing eclipse events, and its times didn't agree with any of the other programs either. So I was burning with curiosity to know who was right.

The predicted times were:
Europa appears Europa disappears
XEphem 7:43 7:59
S&T Jupiter's Moons 7:40 7:44
my Javascript Jupiter 7:45 7:52
Stellarium 6:49 7:05

I was out of town on March 10. I brought along a travel scope, an Orion 80mm f/6 Orion Express. Not the perfect planetary scope, but certainly enough to see Europa. (The Galilean moons are even visible in binoculars, as long as you mount the binoculars on a tripod or otherwise hold them steady.)

I synchronized my watch and had the telescope set up by 7:35. Sure enough, there was no Europa there. But at 7:38 on the dot, I saw the first hint of Europa peeking out. No question about it. I watched, and timed, and by 7:41 the whole disk of Europa was visible and I could start to think I could see blackness between it and Jupiter. I'd been to a school star party a few days earlier and hadn't cleaned my eyepieces afterward -- oops! -- so the view was a little foggy and it was hard to tell for sure exactly when Europa's disk cleared Jupiter.

In fact, no matter which eyepiece I used, the fogginess seemed to get worse and worse. I had a hard time seeing Europa at all. Finally I realized that I was looking through a tree branch, and moved the scope. But by the time I got it moved again, Europa had gotten even harder to see. That was when I realized that it had been going into eclipse practically the whole time I was watching it. It was already significantly dimmed by 7:43, very dim indeed by 7:48 and gone -- in the 80mm -- by 7:49:20, though I suspect it still would have been visible in a larger scope with clean eyepieces.

So that's why the times in different programs varied so much! Galilean moons aren't point sources: you can't predict a single time for a moon disappearance, appearance or eclipse. Do you want to predict the beginning of the event, the end of the event or the time at the moon's center point? And that goes double for eclipses, where the moon is gradually sliding into the shadow of Jupiter's atmosphere. I found that it took over seven minutes the moon to go from full brightness to fully eclipsed. So what part of that do you predict?

All in all, a very interesting observing session. I'm looking forward to observing more of these eclipses, doing more timings, and tuning my program to give better predictions. (I notice my program was significantly late on both the appearance and the eclipse. I'll work on that. Better to err on the early side, and not miss anything!)

While I was adding eclipses to my Jupiter program, I also added longer-range predictions, so it would be easier to find out when these events will happen. Once that was implemented, I looked for upcoming Whac-a-Moon events. I found one on Mar 26, when Ganymede appears at 7:29pm PDT (add 7 hours for GMT). Europa and its shadow are transiting Jupiter's disk, too, so there's plenty to look at. Ganymede then enters eclipse at 9:40pm PDT. A long time between the events, I know, but it's easy enough to leave a scope set up in the backyard and go out to check it now and then.

These times are from my Javascript Jupiter program and may be a few minutes late. Always be ready at least five minutes early in case the predictions are off, no matter which program you use. Don't say I didn't warn you.

I found no events in April visible at night in California (for other time zones, you can generate predictions on my Javascript Jupiter page). But May 8 has a decent one: Ganymede appears at 9:44pm PDT, then disappears into eclipse at 9:46. Based on what I saw tonight with Europa, that means the moon should start to fade almost immediately after it has emerged from behind Jupiter, maybe even before it has fully emerged. Ganymede's larger size may also mean the fade-out will take longer. Stay tuned. Jupiter will be very low by then, only 7 degrees above the horizon.

Not many events to observe -- this is a bit rarer than I'd thought. Of course, there are lots of moons disappearing into eclipse and appearing from out of it every night, so watching that long gradual appearance or disappearance isn't difficult; the only rare part is when they appear briefly between Jupiter and Jupiter's shadow. That is relatively rare, and I'm glad I had a chance to catch it.

Tags: ,
[ 19:55 Mar 12, 2013    More science/astro | permalink to this entry | comments ]