Shallow Thoughts : : science
Akkana's Musings on Open Source Computing, Science, and Nature.
Tue, 22 May 2012
I've just seen the annular eclipse, and what a lovely sight it was!
This was only my second significant solar eclipse, the first being a
partial when I was a teenager. So I was pretty excited about an
annular so nearby -- the centerline was only about a 4-hour drive from home.
We'd made arrangements to join the Shasta astronomy club's eclipse party
at Whiskeytown Lake, up in the Trinity Alps. Sounded like a lovely spot,
and we'd be able to trade views with the members of the local astronomy
club as well as showing off the eclipse to the public. As astronomers
bringing telescopes, we'd get reserved parking and didn't even have to
pay the park fee. Sounded good!
Not knowing whether we might hit traffic, we left home first thing in
the morning, hours earlier than we figured was really necessary.
A good thing, as it turned out.
Not because we hit any traffic -- but because when we got to the site,
it was a zoo. There were cars idling everywhere, milling up and
down every road looking for parking spots.
We waited in the queue at the formal site, and finally got to the
front of the line, where we told the ranger we were bringing
telescopes for the event. He said well, um, we could drive in and
unload, but there was no parking so we'd just have to drive out
after unloading, hope to find a parking spot on the road somewhere,
and walk back.
What a fiasco!
After taking a long look at the constant stream of cars inching along in
both directions and the chaotic crowd at the site, we decided the
better part of valor was to leave this vale of tears and high-tail it
back to our motel in Red Bluff, only little farther south of the
centerline and still well within the path of annularity. Fortunately
we'd left plenty of extra time, so we made it back with time to spare.
The Annular Eclipse itself
One striking thing about watching the eclipse through a telescope was
how fast the moon moves. The sun was well decorated with several excellent
large sunspot groups, so we were able to watch the moon swallow them
bit by bit.
Some of the darker sunspot umbras even showed something like a
black drop effect
as they disappeared behind the moon. We couldn't see the same
effect on the smaller sunspot groups, or on the penumbras.
There was also a pronounced black drop effect at the onset and end
of annularity.
The seeing was surprisingly good, as solar observing goes. Not only
could we see good detail on the sunspot groups and solar faculae,
but we could easily see irregularities in the shape of the moon's
surface -- in particular one small sharp mountain peak on the leading edge,
and what looked like a raised crater wall farther south on that
leading edge. We never did get a satisfactory identification on
either feature.
After writing and speaking about eclipse viewing, I felt honor bound
to try viewing with pinholes of several sizes. I found that during early
stages of the eclipse, the pinholes had to be both small (under about
5 mm) and fairly round to show much. Later in the eclipse,
nearly anything worked to show the crescent or the annular ring,
including interlaced fingers or the shadow of a pine tree on the wall.
I wish I'd remembered to take an actual hole punch, which would have
been just about perfect.
I also tried projection through binoculars, and convinced myself that
it would probably work as a means of viewing next month's Venus
transit -- but only with the binoculars on a tripod. Hand-holding
them is fiddly and difficult. (Of course, never look through
binoculars at the sun without a solar filter.) Look for an upcoming
article with more details on binocular projection.
The cast of characters
For us, the motel parking lot worked out great. We were staying at the
Crystal Motel in Red Bluff, an unassuming little motel that proved to be
clean and quiet, with friendly, helpful staff and the fastest motel
wi-fi connection I've ever seen. Maybe not the most scenic of
locations, but that was balanced by the convenience of having the car
and room so close by.
And we were able to show the eclipse to locals
and motel guests who wouldn't have been able to see it otherwise.
Many of these people, living right in the eclipse path, didn't even
know there was an eclipse happening, so poor had the media coverage been.
(That was true in the bay area too -- most people I talked to last week
didn't know there was an eclipse coming up, let alone how or where to
view it.)
We showed the eclipse to quite a cast of characters --
- The mother with medical problems, obviously feeling quite poorly
but still bringing her husband and son out for repeated views.
- the woman who said she didn't want to be in the sun because she'd
been drinking too much by the pool.
- The family where Dad kept looking through paper glasses the kids
insisted was a "3-D viewer". Alarmed, we took a look, and found it
was a perfectly reasonable eclipse viewer marked SAFE FOR SOLAR VIEWING.
Whew!
- The teen girl who kept looking directly at the sun despite everyone
telling her not to ... I hope she didn't damage her vision.
- The kid who wanted to borrow my binocular to look at some birds
circling in the distance. I wanted to let him, but with all the
attention on the sun I was too nervous, so instead I changed the
subject and showed him how to identify turkey vultures (wings in a V,
tipping from side to side) even without binoculars).
- The man who sat in a parking space near us reading a catalog,
telling us repeatedly he was just reading his catalog. When Dave
insisted he come and take a look, he looked in the eyepiece for about
ten seconds, then looked Dave in the eye and informed him solemnly
that he was just reading his catalog.
- The family who'd been instructed by their grandmother, in the hospital
awaiting an operation, to watch the eclipse and bring back pictures for her.
I hope they got some decent ones!
In between visitors, we had plenty of time to fiddle with equipment,
take photos, and take breaks sitting in the shade to cool down.
(Annularity was pleasantly cool, but the rest of the eclipse stayed
hot on an over 90 degree central valley day.)
There's a lot to be said for sidewalk astronomy! Overall, I'm glad
we ended up where we did rather than in that Whiskeytown chaos.
Here's my collection of
Images
from the "Ring of Fire" Annular Eclipse, May 2012, from Red Bluff, CA.
Tags: astronomy, science, eclipse, travel
[
10:42 May 22, 2012
More science/astro |
permalink to this entry |
comments
]
Wed, 16 May 2012
This Sunday, May 20th, the western half of the US will be treated
to an annular solar eclipse.
Annular means that the moon is a bit farther away than usual, so it
won't completely cover the sun even if you travel to the eclipse
centerline. Why? Well, the moon's orbit around the earth
isn't perfectly circular, so sometimes it's farther away, sometimes
nearer. Remember all the hype two weeks ago about the "supermoon",
where it was unusually close at full moon? The other side of that
is that during this eclipse, at new moon, the moon is unusually far
away, and therefore a little smaller, not quite big enough to cover
the sun.
Since the sun will never be totally covered, make sure
you have a safe solar filter for this one -- don't look with your
naked eyes! You want a solar filter anyway, if you have any kind of
telescope or even binoculars, because of next month's once-in-a-lifetime
Venus transit (I'll write about that separately).
But if you don't have a solar filter and absolutely can't get one
in time, read on -- I'll have some suggestions later even for people
without any sort of optical aid.
But first, the path of the eclipse.
Here in the bay area, we're just a bit south of the southern limit of the
annular path, which passes just south of the town of Redway, through
Covelo, just south of Willows, then just misses Yuba City and
Auburn. If you want to be closer to the centerline, go camping at
Lassen National Park or Lake Shasta, or head to Reno or Tahoe
If you're inclined to travel, NASA has a great
interactive
2012 eclipse map you can use to check out possible locations.
Even back in the bay area, we still get a darn good dinner show. The partial
eclipse starts at 5:17 pm PDT, with maximum eclipse at 6:33. The sun
will be 18 degrees above the horizon at that point, and 89%
eclipsed. Compare that with 97% for a site right on the centerline --
remember, since this is an annular eclipse, no place sees 100%
coverage. The partial eclipse ends at 7:40 -- still well before
sunset, which isn't until 8:11.
Photographers, if you want a shot of an annular eclipse as the sun
sets, you'll need to head east, to Albuquerque, NM or Lubbock, TX.
A little before sunset, the centerline also crosses
near a lot of great vacation spots like Bryce, Zion and Canyon de Chelly.
I mentioned that even without a solar filter, there are ways of
watching the eclipse. The simplest is with a pinhole. You don't need
to use an actual pin -- the size and shape of the hole isn't critical,
as you can see in this
image
of the sun through the leaves of a tree during a 2005 eclipse in Malta.
If you don't have a leafy tree handy, you can even lace your fingers
together and look at the shadow of your hands. This eclipse will be
very low in the sky, continuing through sunset, so you may need to
project its shadow onto a wall rather than the ground.
If you have some
time to prepare, take a piece of cardboard and punch a few holes
through it. Try different sizes -- an actual pinhole, a BBQ skewer,
a 3-hole punch, maybe even bigger holes up to the size of a penny.
You might also try using aluminum foil -- you can get very clean
circular holes that way, which might give a crisper image.
Here's a good page on
eclipse
pinhole projection.
What works best? I don't remember! It's been a very long time since
the last eclipse here! Do the experiment! I know I will be.
If you do have a telescope or binoculars but couldn't get a solar
filter in time, don't despair. Instead of looking through the
eyepiece, you can project the sun's image onto a white screen or even
the ground or a wall. Use a cheap, low-power eyepiece -- any eyepiece
you use for solar projection will get very hot, and you don't want to
risk ruining a fancy one.
Point the telescope at the sun -- it's easy to tell when it's
lined up by watching the shadow of the telescope -- and rotate the
eyepiece so that it's aimed at your screen, which can be as simple
as a sheet of paper. Be careful where that eyepiece is aimed -- make
sure no one can walk through the path or put their hand in the way,
and if you have a finderscope, make sure it's covered.
This solar projection method works with binoculars too, but you'll want
to mount them on a tripod so you don't have to hold them the whole time.
Of course, another great way to watch the eclipse is with your local
astronomy club. I expect every club in the bay area -- and there are a
lot of them -- will have telescopes out to share the eclipse with the
public. So check with your local club --
San Jose Astronomical Association,
Peninsula Astronomical Society,
San Francisco Sidewalk
Astronomers,
San Francisco Amateur Astronomers,
or any of the others on the AANC's list of
Amateur
Astronomy Clubs in Northern California
or the
SF
Chronicle's list of astronomy clubs.
This eclipse should be pretty cool -- and a great chance to test
out your solar equipment before next month's Venus transit.
When I went to put the event on my wall calendar last month, I discovered
the calendar already had an entry for May 20: it's the start of Bear
Awareness Week. So if you head up to Lassen or Shasta to watch the
eclipse, be sure to be aware of the bears! (Also, maybe I should get a
calendar that's a little more in tune with the sky.)
Tags: astronomy, science, eclipse
[
20:12 May 16, 2012
More science/astro |
permalink to this entry |
comments
]
Fri, 27 Apr 2012
Venus has been a beautiful sight in the evening sky for months, but
at the end of April it's reaching a brightness peak, magnitude -4.7.
By then, if you look at it in a telescope or even good binoculars,
you'll see it has waned to a crescent. That's a bit non-obvious:
when the moon is a crescent, it's a lot fainter than a full moon.
So why is Venus brightest in its crescent phase?
It has to do with their orbits. The moon is always about the same
distance away, about 385,000 km or 239,000 miles (I've owned cars with
more miles than that!), though it varies a little, from 362,600 km at
perigee to 405,400 km at apogee.
When we look at the full moon, not only are we seeing the whole
Earth-facing surface illuminated, but the central part of that light
is reflecting straight up off the moon's surface. When we look at a
crescent moon, we're seeing light that's near the moon's sunrise or
sunset point -- dimmer and more spread out than the concentrated light
of noon -- and in addition we're seeing less of it.
Venus, in contrast, varies its distance from us immensely.
We can't see Venus when it's "full", because it's on the other side of
the sun from us and lost in the sun's glow. It'll next be there a year
from now, in April of 2013. But if we could see it when it's full, Venus
would be a distant 1.7 AU from us. An AU is an Astronomical Unit, the
average distance of the earth from the sun or about 89 million miles,
so Venus when it's full is about 170 million miles away.
Its disk is a tiny 9.9 arcseconds (an arcsecond is 1/3600 of a degree)
-- about the size of Mars this month.
In contrast, when we look at the crescent Venus around the end of this
month, although we're only seeing about 28% of its surface illuminated,
and that only with glancing twilight rays, it's much closer to us --
less than half an AU, or about 45 million miles -- and its disk
extends a huge 37 arcseconds, bigger than Jupiter this month.
Of course, eventually, as Venus pulls between us and the sun, its
crescent gets so slim that even its huge size can't compensate. So
its peak brightness happens when those two curves cross, when the disk
is somewhere around 27% illuminated, as happens at the end of this
month and the beginning of May.
Exactly when? Good question. The RASC Handbook says Venus' "greatest
illuminated extent" is on April 30, but PyEphem and XEphem say Venus
is actually brighter from May 3-8 ... and when it emerges from the
sun's glare and moves into the morning sky in June, it'll be slightly
brighter still, peaking at magnitude -4.8 in the first week of July.)
Tracking Venus with PyEphem
When I started my Shallow
Sky column this month, I saw the notice of Venus's maximum
brightness and greatest illuminated extent in the
RASC Handbook. But
I wanted more details -- how much did its distance and size really change,
when would the brightness peak again as it emerged from the sun's glare,
when would it next be "full"?
PyEphem made it easy to
calculate all this. Just create an ephem.Venus() object,
calculate its values for any date of interest, then print out
parameters like phase, mag, earth_distance and size.
In just a few minutes of programming, I had a nice table of Venus data.
import ephem
venus = ephem.Venus()
print '%10s %6s %6s %6s %6s' % ('date', '%', 'mag', 'dist', 'size')
def print_venus(when) :
venus.compute(when)
fmt = '%02d-%02d-%02d %6.2f %6.2f %6.2f %6.2f'
trip = when.triple()
print fmt % (trip[0], trip[1], trip[2],
venus.phase, venus.mag, venus.earth_distance, venus.size)
# Loop from the beginning of 2012 through the middle of 2013:
d = ephem.date('2012')
end_date = ephem.date('2013/6/1')
while d < end_date :
print_venus(d)
# Add a week:
d = ephem.date(d + ephem.hour * 24)
I've found PyEphem very handy for calculations like this --
and it's great to be able to double-check listings in other publications.
Tags: astronomy, programming, python
[
13:44 Apr 27, 2012
More science/astro |
permalink to this entry |
comments
]
Tue, 03 Apr 2012
How do you show equations on a web page? Every now and then, I write
an article that involves math, and I wrestle with that problem.
The obvious (but wrong) approach: MathML
It was nearly fifteen years ago that MathML was recommended as a
standard for embedding equations inside an HTML page. I remember being
excited about it back then. There were a few problems -- like the
availability of fonts including symbols for integrals, summations
and so forth -- but they seemed minor. That was 1998.
Now, in 2012, I found myself wanting to write an article involving an
integral, so I looked into the state of MathML. I found that even now,
all these years later, it wasn't widely supported.
In Firefox I could show some simple equations, like
and
But when I tried them in Chromium, I learned that webkit-based
browsers don't support MathML. At all. The exception is Safari:
apparently Apple has added some MathML support into their browser
but hasn't contributed that code back to webkit (yet?)
Besides that, MathML is ridiculously hard to use. Here's the code for
that little integral:
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<semantics>
<mrow>
<msubsup>
<mo>∫</mo>
<mn>x = 0</mn>
<mi>∞</mi>
</msubsup>
<mfrac>
<mrow>
<mo>ⅆ</mo>
<mi>x</mi>
</mrow>
<mi>x</mi>
</mfrac>
</mrow>
</semantics>
</mrow>
</math>
Ugh! You can't even specify infinity without using an HTML numeric
entity. And the code for the quadratic equation is even worse (use View
Source if you want to see it).
Good ol' tables
Several years ago, I wrote about the
Twelve
Days of Christmas and how to calculate the total number of gifts
represented in the song.
I needed summations, and I was rather proud of working out a way to
use HTML tables to display all the sums and line up everything correctly.
It wasn't exactly publication-quality graphics, but it was readable.
More recently, I worked out a way to do exponentials that way,
and found a hint about
how to do integrals:
| now | | |
|
| ∫
| P (t) |
dt |
| P0 = | ———— |
| 1 + t |
| 0 | | |
Looks a little better than the tiny MathML version. But the code isn't
any easier to read:
<table border="0" cellpadding="0" cellspacing="0">
<tr><td><td align="center"><small><i>now</i></small></td><td></td><td></td></tr>
<tr>
<td>
<td rowspan="3" valign="middle"><font size="6" style="font-size:3em" class="bigsym">∫</font>
<td align="center"><i>P</i> (<i>t</i>)</td>
<td rowspan="3" valign="middle"> <i>dt</i></td></tr>
<tr><td>P<sub>0</sub> =<td align="center">————</td></tr>
<tr><td><td align="center">1 + <i>t</i></td></tr>
<tr><td><td valign="top"><small><i>0</i></small></td><td></td><td></td></tr>
</table>
The solution: MathJax
And then I discovered MathJAX.
It was added recently to the Udacity
forums, and I think it's also what MITx
is using for their courses.
MathJax is fantastic. It's an open-source library that lets you
specify equations in readable ways -- you can use MathML, but you
can also use LaTEX or even ASCII math like `x = (-b +- sqrt(b^2-4ac))/(2a) .`
It uses Javascript: you put your equations in the text of the page
with delimiters like $$ around them (you can control the delimiters),
then run a function that scans the page content and replaces any
equations it sees with pretty graphics. (Viewers using NoScript
or similar extensions will need to allow mathjax.org to see the
equations, unless you make a local copy of the mathjax.org libraries,
which you probably should anyway if you're using a lot of equations.)
For displaying those graphics,
MathJax might use MathML, HTML and CSS, or whatever, depending on the
user's browser ... but you don't have to worry about that.
(Alas,
even
in Firefox, MathML rendering isn't up to par so MathJax doesn't
use it by default, though you can
specify it as
an option if you know your equations render well.)
Here's that integral again, using LaTeX format:
$$ P_0 =\int_0^\infty \frac {P(t) dt}{1 + t} $$
and
$$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$
It's beautiful! And although I don't know LaTex at all -- been wanting an
excuse to learn it -- I put together that integral with five minutes
of web searching. (The quadratic code came from a MathJax demo page.)
Here's what the code looks like:
$$ P_0 =\int_0^\infty \frac {P(t) dt}{1 + t} $$
$$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$
MathJax is even smart enough to notice the code there is in a
<pre> tag, so I didn't have to find a way to escape it.
I'm sold! The MathJax team has really put together a nice package, and
I think we'll be seeing it on a lot more websites.
If you want to try it, start here:
Getting Started
with MathJAX.
Tags: math, science, html, web, mathml
[
15:45 Apr 03, 2012
More science |
permalink to this entry |
comments
]
Tue, 13 Mar 2012
The MITx 6.002 "Circuits
and Electronics" class started a week ago Monday. Exciting -- I'm hoping
I'll be able to learn all those electronics concepts that baffle me
while I'm trying to design simple circuits. (Assuming I make it --
I'm struggling and it's only the first week.)
One of the early exercises required integrating a trig function.
No problem -- I used
Wikipedia's
tables of integrals. But subsequent discussion of that problem
in the forums reminded me that when you're after a numeric solution,
we do have computers to do that sort of thing for us.
In particular, someone linked to
Wolfram
Alpha: integral (120sqrt(2)cos(2pi60t))^2/110 from 0 to 1/60
A nifty tool that I should remember to use more often!
Not only does it give you the numeric answer, but it also gives you
a nice symbolic display (so you can make sure you typed in what
you thought you were typing in), and a graph.
There was one hitch, though. In this particular problem, there was some
debate over the integration limits -- should it be 0 to 1/60 or 0 to 1?
If you try the same thing with 0 to 1, you still get the numeric answer,
but you get "Computation timed out", with a link labeled "Try again with
more time" that leads to an exhortation to subscribe to Wolfram Alpha Pro.
Of course, that made me antsy and made me wonder ... aren't there local
solutions? What if I want to calculate an integral when I'm away from
a fast network? Is there some way to do this using Python, Octave or R?
And of course there is. I haven't found an easy way to get the pretty
graphics, but you can get the numerical results fairly easily.
In Octave, it's a bit roundabout: you have to
define
a function, then call quad. The easiest way is to use inline:
octave:2> f = inline("(120 * sqrt(2) * cos(120 * pi * x))^2 / 110");
octave:3> quad(f, 0, 1/60)
ans = 2.1818
though you can also define a function this way:
octave:4> function y = ff(t)
> y = (120 * sqrt(2) * cos(120 * pi * tx))^2 / 110;
> endfunction
octave:5> quad(f, 0, 1/60)
ans = 2.1818
Here's how to do the same thing in Python using
SciPy:
import scipy
import math
scipy.integrate.quad(lambda t: (120 * math.sqrt(2) * math.cos(120 * math.pi * t))**2 / 110., 0, 1./60)[0] * 60
Of course, you don't need to use lambda -- you can also define a
function and pass it to scipy.integrate.quad.
None of this gets the nice graphics of Wolfram Alpha, though of
course either Python or Octave can be programmed to generate them.
I saw a presentation at PyCon about a package called
Sage that can probably
do nice graphics. But it's about a 350Mb download, so trying it
wasn't an option during the conference, and now the site is down
due to an electrical problem. So for now, Wolfram Alpha
wins the graphics war.
Tags: math
[
19:44 Mar 13, 2012
More science |
permalink to this entry |
comments
]
Thu, 29 Dec 2011
My SJAA planet-observing column for January is about
the Analemma and the
Equation of Time.
The analemma is that funny figure-eight you see on world globes in the
middle of the Pacific Ocean. Its shape is the shape traced out by
the sun in the sky, if you mark its position at precisely the same
time of day over the course of an entire year.
The analemma has two components: the vertical component represents
the sun's declination, how far north or south it is in our sky.
The horizontal component represents the equation of time.
The equation of time describes how the sun moves relatively faster or
slower at different times of year. It, too, has two components: it's
the sum of two sine waves, one representing how the earth speeds up
and slows down as it moves in its elliptical orbit, the other a
function the tilt (or "obliquity") of the earth's axis compared to
its orbital plane, the ecliptic.
The Wikipedia page for
Equation of
time includes a link to a lovely piece of
R code by
Thomas Steiner showing how the two components relate. It's labeled
in German, but since the source is included, I was able to add English
labels and use it for my article.
But if you look at photos
of real analemmas in the sky, they're always tilted. Shouldn't they
be vertical? Why are they tilted, and how does the tilt vary with
location? To find out, I wanted a program to calculate the analemma.
Calculating analemmas in PyEphem
The very useful astronomy Python package
PyEphem
makes it easy to calculate the position of any astronomical object
for a specific location. Install it with: easy_install pyephem
for Python 2, or easy_install ephem for Python 3.
import ephem
observer = ephem.city('San Francisco')
sun = ephem.Sun()
sun.compute(observer)
print sun.alt, sun.az
The alt and az are the altitude and azimuth of the sun right now.
They're printed as strings: 25:23:16.6 203:49:35.6
but they're actually type 'ephem.Angle', so float(sun.alt) will
give you a number in radians that you can use for calculations.
Of course, you can specify any location, not just major cities.
PyEphem doesn't know San Jose, so here's the approximate location of
Houge Park where the San Jose Astronomical
Association meets:
observer = ephem.Observer()
observer.name = "San Jose"
observer.lon = '-121:56.8'
observer.lat = '37:15.55'
You can also specify elevation, barometric pressure and other parameters.
So here's a simple analemma, calculating the sun's position at noon
on the 15th of each month of 2011:
for m in range(1, 13) :
observer.date('2011/%d/15 12:00' % (m))
sun.compute(observer)
I used a simple PyGTK window to plot sun.az and sun.alt, so once
it was initialized, I drew the points like this:
# Y scale is 45 degrees (PI/2), horizon to halfway to zenith:
y = int(self.height - float(self.sun.alt) * self.height / math.pi)
# So make X scale 45 degrees too, centered around due south.
# Want az = PI to come out at x = width/2.
x = int(float(self.sun.az) * self.width / math.pi / 2)
# print self.sun.az, float(self.sun.az), float(self.sun.alt), x, y
self.drawing_area.window.draw_arc(self.xgc, True, x, y, 4, 4, 0, 23040)
So now you just need to calculate the sun's position at the same time
of day but different dates spread throughout the year.
And my 12-noon analemma came out almost vertical! Maybe the tilt I saw
in analemma photos was just a function of taking the photo early in
the morning or late in the afternoon? To find out, I calculated the
analemma for 7:30am and 4:30pm, and sure enough, those were tilted.
But wait -- notice my noon analemma was almost vertical -- but
it wasn't exactly vertical. Why was it skewed at all?
Time is always a problem
As always with astronomy programs, time zones turned out to be the
hardest part of the project. I tried to add other locations to my
program and immediately ran into a problem.
The ephem.Date class always uses UTC, and has no concept
of converting to the observer's timezone. You can convert to the timezone
of the person running the program with localtime, but
that's not useful when you're trying to plot an analemma at local noon.
At first, I was only calculating analemmas for my own location.
So I set time to '20:00', that being the UTC for my local noon.
And I got the image at right. It's an analemma, all right, and
it's almost vertical. Almost ... but not quite. What was up?
Well, I was calculating for 12 noon clock time -- but clock time isn't
the same as mean solar time unless you're right in the middle of your
time zone.
You can calculate what your real localtime is (regardless of
what politicians say your time zone should be) by using your longitude
rather than your official time zone:
date = '2011/%d/12 12:00' % (m)
adjtime = ephem.date(ephem.date(date) \
- float(self.observer.lon) * 12 / math.pi * ephem.hour)
observer.date = adjtime
Maybe that needs a little explaining. I take the initial time string,
like '2011/12/15 12:00', and convert it to an ephem.date.
The number of hours I want to adjust is my longitude (in radians)
times 12 divided by pi -- that's because if you go pi (180) degrees
to the other side of the earth, you'll be 12 hours off.
Finally, I have to multiply that by ephem.hour because ...
um, because that's the way to add hours in PyEphem and they don't really
document the internals of ephem.Date.
Set the observer date to this adjusted time before calculating your
analemma, and you get the much more vertical figure you see here.
This also explains why the morning and evening analemmas weren't
symmetrical in the previous run.
This code is location independent, so now I can run my analemma program
on a city name, or specify longitude and latitude.
PyEphem turned out to be a great tool for exploring analemmas.
But to really understand analemma shapes, I had more exploring to do.
I'll write about that, and post my complete analemma program,
in the next article.
Tags: analemma, astronomy, science, programming, python, writing
[
19:54 Dec 29, 2011
More science/astro |
permalink to this entry |
comments
]
Thu, 22 Dec 2011
Today is the winter solstice -- the official beginning of winter.
The solstice is determined by the Earth's tilt on its axis, not
anything to do with the shape of its orbit: the solstice is the point
when the poles come closest to pointing toward or away from the sun.
To us, standing on Earth, that means the winter solstice is the day
when the sun's highest point in the sky is lowest.
You can calculate the exact time of the equinox using the handy Python
package PyEphem.
Install it with: easy_install pyephem
for Python 2, or easy_install ephem for Python 3.
Then ask it for the date of the next or previous equinox.
You have to give it a starting date, so I'll pick a date in late summer
that's nowhere near the solstice:
>>> ephem.next_solstice('2011/8/1')
2011/12/22 05:29:52
That agrees with my RASC Observer's Handbook: Dec 22, 5:30 UTC. (Whew!)
PyEphem gives all times in UTC, so, since I'm in California, I subtract
8 hours to find out that the solstice was actually last night at 9:30.
If I'm lazy, I can get PyEphem to do the subtraction for me:
ephem.date(ephem.next_solstice('2011/8/1') - 8./24)
2011/12/21 21:29:52
I used 8./24 because PyEphem's dates are in decimal days, so in order
to subtract 8 hours I have to convert that into a fraction of a 24-hour day.
The decimal point after the 8 is to get Python to do the division in
floating point, otherwise it'll do an integer division and subtract
int(8/24) = 0.
The shortest day
The winter solstice also pretty much marks the shortest day of the year.
But was the shortest day yesterday, or today?
To check that, set up an "observer" at a specific place on Earth,
since sunrise and sunset times vary depending on where you are.
PyEphem doesn't know about San Jose, so I'll use San Francisco:
>>> import ephem
>>> observer = ephem.city("San Francisco")
>>> sun = ephem.Sun()
>>> for i in range(20,25) :
... d = '2011/12/%i 20:00' % i
... print d, (observer.next_setting(sun, d) - observer.previous_rising(sun, d)) * 24
2011/12/20 20:00 9.56007901422
2011/12/21 20:00 9.55920379754
2011/12/22 20:00 9.55932991847
2011/12/23 20:00 9.56045709446
2011/12/24 20:00 9.56258416496
I'm multiplying by 24 to get hours rather than decimal days.
So the shortest day, at least here in the bay area, was actually yesterday,
2011/12/21. Not too surprising, since the solstice wasn't that long
after sunset yesterday.
If you look at the actual sunrise and sunset times, you'll find
that the latest sunrise and earliest sunset don't correspond to the
solstice or the shortest day. But that's all tied up with the equation
of time and the analemma ... and I'll cover that in a separate article.
Tags: astronomy, science, programming, python, writing
[
10:28 Dec 22, 2011
More science/astro |
permalink to this entry |
comments
]
Tue, 07 Jun 2011
My SJAA Ephemeris planetary
astronomy column for next month will discuss Saturn, among other topics,
since Saturn is the main planet visible in the evening sky right now.
Saturn has some storms visible right now in the north polar and
equatorial bands, and a great way to focus your attention to see
more detail through a telescope, especially on subtle details like
Saturnian storms, is to take pencil and paper and sketch what you see.
I've recommended sketching in my column many times before, but don't
talk about it on the blog very often.
When sketching Saturn, it helps to start with a template, so you can
concentrate on the interesting details of the rings and bands rather
than fussing over trying to get the exact width of the rings right.
Saturn's tilt changes with time -- right now it's tilted at 8°
to observers here on Earth -- so sometimes the rings are open wide,
sometimes they're narrow, and sometimes (as last year) they're edge-on
and invisible to us. That's a hassle to try to get right in a sketch,
when you'd rather be focusing on the gaps in the rings and the
pastel colors of the cloud bands on the planet.
ALPO, the Association of Lunar
and Planetary Observers, makes templates for sketching Saturn;
but I had trouble finding any online that showed a tilt appropriate
for this month's Saturn. You can get observing materials by joining
ALPO, but sheesh! you shouldn't have to join an organization just to
get a simple sketching template. And I wanted one for my column.
Besides, the ALPO templates fill in too much detail -- they don't
really give you a chance to do your own ring sketch.
So here's an easy way to make a Saturn sketching template with GIMP.
Start with an image
You can calculate the aspect ratio you need for the planet from the
ring tilt, but why go to all that trouble? I started with an image
of Saturn I got by running
XEphem.
Call up View->Saturn, then make the window as big as you can.
Of course, you may substitute any planetarium program of your choosing,
as long as it shows Saturn with the right ring tilt.
I used GIMP's screenshot facility to open this as an image:
File->Create->Screenshot..., then
Select a region to grab.
You can also use a recent photo of Saturn. The point here is to get
something that's the right shape: it doesn't matter if it's beautiful
or large.
Fix the rotation and size
You want the rings horizontal, if they're not already. Use GIMP's Free
Rotate tool to do that. You can eyeball it to make it approximately right,
or if you want to be more accurate, use the Measure tool (the icon looks
like a drawing compass) to measure from one edge of the rings to the
other and note the angle in the status bar at the bottom of the window.
Then when you use Free Rotate, type in the number you measured.
You'll be printing this out on sketching paper, so if the original
image is small, use Image->Scale to expand it. Remember, you
won't be looking at this original image -- it's just for tracing --
so don't worry if the image comes out fuzzy after you scale it up.
I made mine about 1000 pixels wide.
Make a white background layer
Layer->New Layer... to make a new layer; check "white"
in the dialog. Then click the eyeball icon next to it in the Layers
dialog to make it invisible. You'll want it later.
Outline the planet on its own layer
Layer->New Layer... to make a new layer; this time make
it transparent, not white.
I named mine "planet", since this is where I'll draw the ellipse
for the planet. (Yes, Saturn is an ellipse, not a sphere. So is
the Earth, for that matter, but Saturn is a lot less spherical
than Earth is.)
Choose the ellipse selection tool and drag out a selection that matches
the outer edges of the planet. Use the resize handles to adjust the
selection until it fits as closely as you can manage.
In the Toolbox or the Brushes dialog, choose the smallest hard brush,
"Circle (01)".
Then Edit->Stroke Selection.... Click "Stroke with a paint
tool", and click Stroke.
Tip: You may notice my template ended up with very jaggy lines.
That's a common artifact of GIMP's Stroke Selection.
I'm not worried about it for a sketching template, but if the jaggies
bother you, you can get a much smoother line by converting the
selection to a path and stroking the path instead of the selection.
Preview your work so far
Go back to the Layers dialog and make that white layer visible again,
so you can see the outline you just made. You may want to do
Select->None and click on some tool other than ellipse
select, so the selection outline disappears and you can see the line better.
If you're not happy with your planet outline, Edit->Undo and
repeat with a different selection, a thicker line or whatever.
Outline the rings on their own layer
Repeat what you just did for the planet, this time for the rings.
I recommend using a new layer for just the rings (you'll see why in
the next step).
I outlined just the outside of the rings, so the sketch can show the
ring thickness. ALPO's templates don't do this, but how much
ring you can see can vary based on seeing conditions. If you want the
inner edge of the ring on your template, add it now.
Erase the hidden parts of the ring and planet outlines
You can't see the rings where they go behind the planet, or the part
of the planet hidden by the rings. And you don't want your template
lines spoiling your sketch in those regions. So use GIMP's eraser tool
and a large brush to erase the appropriate parts.
This is a little easier if you used separate layers for the rings and
planet: you won't have to be as careful with the eraser. But it's not
a big deal: this is a template, not a finished artwork, and you're
going to be drawing over it anyway. So don't sweat it too much.
Optionally, make the lines fainter
I made the template lines fainter using the Opacity slider in
the Layers dialog on the planet and ring layers. Of course, you can
just draw in grey in the first place, but I like being able to decide
afterward what color I want, or change it later.
Label the template
Trust me, you'll be really annoyed if you decide in 2026 that you want
to make another Saturn sketch, find your old template but can't remember
what ring tilt it's for. So use the Text tool to label either the current
date or the approximate ring tilt. Or put that information in an image
comment under Image->Image Properties..., or in the filename.
Save your template as XCF.gz, save a copy in some other format like
jpg, png or gif, and you're ready to print templates on paper.
Then go out and sketch Saturn!
Tags: astronomy, sketching, gimp
[
14:13 Jun 07, 2011
More science/astro |
permalink to this entry |
comments
]