The aurora borealis and aurora australis, commonly known as the northern and southern lights, are a beautiful natural phenomenon. I have been sort of interested in seeing them for a while, and when I went to college at Michigan Tech last fall, I thought "Here's my chance! I can finally see the aurora!" When I was doing some research on viewing the aurora, I found out that auroras are visible pretty far south, just not very often. If you live north of the red line on the map, or slightly south of it, the aurora should be visible at your location sometime within the next few years. A few years is a long time to wait, but the aurora is worth it. If you are farther north, the aurora can be seen much more frequently. I personally saw it three times last school year in northern Michigan, and I know of at least two other times during the year that it was visible that I missed.

Those times I missed the aurora bring me to the main point of this instructable: knowing when the aurora will be visible. If you think terrestrial weather predictions are bad, I'm not sure I can even explain how unreliable space weather (this is the official term) predictions are. The longest useful prediction only goes three days out, and only gives a rough idea of what the aurora will be like. There are models that predict the auroral strength one to four hours ahead of time, and these are fairly reliable. The problem with this is that unless you check the predictions every day at the least, and preferably every few hours at night (when you're sleeping), knowing when to look for the aurora is hard. I've started to learn some computer programming in my classes at school, and NOAA provides lots of data on the aurora, so I decided to make a program that would let me know when the aurora is likely to be visible.

This isn't a very complicated program; all the programming experience I have is stuff that was included in my basic introduction to engineering courses. I used MATLAB, but any programming language that can access internet data will do the trick.

Picture from: "Red and green auroras" by Arctic light Frank Olsen, Norway - Own work. Licensed under CC BY-SA 3.0 via Wikimedia Commons.

Step 1: Aurora Explained

Before I explain how to predict and see the aurora, I want to explain some basics of what it is and how it works.

When solar wind and particles hit the upper atmosphere, near the magnetic poles, atmospheric gases are excited and ionized. When the gases return to their normal state, they release energy in the form of visible light. Green, emitted by oxygen, is the most common color.

When solar activity is strong, more atoms are excited and release light, so the aurora is brighter, more colorful, and visible farther from the poles. As a result, most aurora predictions focus on solar activity.

The kp index is a measure of geomagnetic activity. This is the index used on the map in the previous step. To be seen very far south, a high kp index is needed. An index of 9 occurs roughly four times per 11 year solar cycle. Lower kp indices are reached much more often. See this website (look under the geomagnetic storm tab) for more detail on the frequency of storm strength.

Predictions for the kp index are available for the next three days, as well as the next four hours and next hour. We will look at the sources for our program. (The image is a graph for the one hour prediction. This graph normally contains the four hour prediction, but that hasn't been working for the last month or so.)

There are also several sources that examine the kp index and other factors to give a simpler aurora prediction. We will also look at these sources.

Step 2: Wing Kp

To explain how to write the program, I'm first going to explain the source and my method in one step, the give a MATLAB specific explanation and code in the next.

The first thing the program needs to do is determine if the aurora is going to be any good or not. One source I use is the wing kp model from NOAA. It is available here. If you select the data tab at the bottom, NOAA will give you the data for the graph as text, which is much easier to work with. This is what I use for my program. MATLAB has a built in function called webread that will read the data for me if I just give it the URL. Load this data into your program in whatever way works for you.

The numbers we are interested in are at the very bottom of the file; this is the most recent data. You can have a lot of fun scrolling up and down the file to look at the headers and the data you actually want. The only numbers in this whole file that we care about are the one and four hour predicted indices. If the model isn't working correctly, the value will be -1. Ignore anything that is -1. Once you have the most recent kp predictions (updated roughly every 15 minutes), the program can compare this to a threshold for notification that you set for your location. Most of the time, the prediction will be too low to notify.

Step 3: Wing Kp - MATLAB

Just a warning before I show you my code, I have often joked that some of my methods would make a computer scientist cry. My methods can be rather unconventional at times, but they do work.

When MATLAB uses webread, the data comes in as an almost 80,000 character string. This is not so good to work with. You can do what I did at first, which is just count which characters you want and set up MATLAB to extract the 77,312th through 77,314th characters, and hope NOAA doesn't change their formatting. I apologize to any computer programmers out there who are weeping at this method.

I want to force the chart into a matrix, with one number per cell. I did this by removing the headers. The headers end with a long row of dashes, so I removed everything before that. I then wrote the data, without headers, to a text file. When I load the data from the text file, MATLAB says, "Hey! This data is in nice, neat columns. How about I just put this in a matrix for you real quick. There you go. Nice and easy to use." Then the most recent kp prediction can be extracted without any trouble.

I also chose to extract the time and include it in the message.

This segment of the program was written as a function with no input arguments. If you type kp into the command window, the message will pop up.

Step 4: Ovation

Another model I use to determine the chance of a visible aurora is the Ovation model from NOAA. The URL directly to the map as shown in the image isn't working for me now, but here it is if you want to try. The map is visible on the overview page for the space weather prediction center, available here. Scroll down until you find a map that looks like the one in the image. This model takes into account more factors than just kp indices, and gives a percent chance of viewing the aurora.

The raw data is available here. The headers are frustratingly vague, not giving a point of reference for where the data begins. Also, NOAA says there are 1096 longitude values, but I am fairly sure that there are only 1024 values. After a couple of hours of messing with it, I was able to use the raw data to make a map similar to the one NOAA makes, and compare to theirs to find a point of reference. I believe that the first row of data is for the south pole and the last row is for the north pole. The left column is opposite the prime meridian, and moves east around the globe. I compared calculates I made this way with a website that does a similar thing, and the answers matched up.

For the program, load the data just like for the wing kp model. The number to extract will vary based on each person's location, unlike the kp model.

To find which row of data to use, add 90 to your latitude (for the northern hemisphere) and divide by 180 (the degrees of latitude between the poles). This will tell you, as a decimal, how far down the chart to go. Multiply this decimal by the 512, the number of rows. Round this to the nearest integer, and use data from this row.

To find the column, use a similar method. Add 180 to your longitude (make sure it is negative for the western hemisphere), divide by 360, and multiply by 1024.

Once you know your row and column, it is fairly easy to extract the single data point that gives the percent chance of a visible aurora at your location in the next half hour.

Step 5: Ovation- MATLAB

On this file, I just counted the number of characters in the heading and removed that, then did the sent it to a text file and reloaded to get it into a useful format. You really have to do the whole text file shenanigan on for this (or some other method to get it into a matrix), because it's just over 2 million characters long. Finding the value for your latitude and longitude in that mess is not going to happen without reformatting.

After the data is nice and pretty, use the method in the previous step to find your row and column, then extract it.

The program I show here has the latitude and longitude of Houghton, Michigan. You will need to change this to your latitude and longitude, because unlike the kp model, this model is location specific.

Step 6: Notification

Now the computer knows what the chances of an aurora are. This is good progress on the program, but the idea is that you know when the aurora is visible, not just your computer.

The simplest, but also the least useful means of notification would be a display on the screen in your program or a noise. This only works if you are looking at your computer or nearby.

I decided that it would be nice to get texts about the aurora, so I programmed that in. It sounds complicated to get a computer program to text, but it is not too bad. I found out that most major phone providers provide an email address for each phone account that texts any emails to the phone. For example, for Verizon phones, sending a email to 1234567890@vext.com would go to the person with the phone number (123)-456-7890. Now our program only has to send an email, which is more manageable. Alternatively, email could be the notification method as well.

MATLAB again has come to my rescue, with a built in sendmail function. For other languages, Google has an API available here that will send email.

Step 7: Notification- MATLAB

The sendmail command itself is easy to use, configuring it is what is hard.

There are a bunch of settings and preferences that need to be set for the sendmail function to work. I only can verify that these specific settings work for gmail. Please use a junk email account for this, because you have to put your username and password as plaintext in the code. Also, when you first try to send an email with MATLAB, Google denies access to the account, because it thinks MATLAB is trying to hack the account. Google sent me an email telling me that it blocked the sign in attempt, and gave me an option to undo my security settings. Yet another reason to use a junk email account.

The sendmail function first needs the email address to send to, the subject, and then the body. For sending as a text, I leave the subject blank.

Step 8: Putting It Together

Now that we have ways of predicting how strong the aurora will be, and a way to notify the user, it is easy to put together.

You can choose how strong the aurora needs to be to alert- any chance at all, 10%, 50%, it's up to you. This can be done with a simple if statement.

Then pause for at least 15 minutes, and repeat. To be effective, the program needs to run continuously. It's not a very intensive program, but I don't want to be running it continuously. Also, I can't use MATLAB for anything else while the aurora program is running. My solution is to monitor the three day forecast, and only run the program if there is a reasonable chance of viewing the aurora.

One idea I had is running the program on a mini computer such as a raspberry pi, where it could be run indefinitely. I know this wouldn't be possible with MATLAB, because MATLAB needs a fair amount of computing power to even open, much less do anything. If anybody tries this, I would love to hear about it.

Step 9: Additional Resources

Wing Kp and Ovation are just a few of the many sources of information on the aurora. NOAA and the space weather prediction center are very good about providing data and information. I would encourage you to look at their website to find more information.

Here is a list of other sites to look at.

Darkness- I think this goes without saying, but it must be very dark to see the aurora. This link gives sunrise and sunset times for many locations. When making the calender, check the box for astronomical twilight. This is when it is totally dark.

3 Day- This prediction gives a rough idea of what conditions will be like over the next three days. Note that almost all NOAA data has times and dates in UTC, which is four hours ahead of EDT.

Solar Flares- Solar flares provide an indication of solar activity. An M-class flare is good, and and X-class flare is great.

Alaska Geophysical Institute- Another map and overall aurora prediction.

Weather- It must be clear to see the aurora. If you click 'Tabular Forecast' under 'Additional Forecasts and Information' for your location, there is an option to get an XML document containing the hourly weather forecast for the next week. This includes cloud cover percentages. This could be a useful feature to include in your program. There's no point in being woken up because the aurora is great if the sky is totally cloudy.

Step 10: Get Out There!

The only way you'll ever see the aurora is if you go outside and look. I've gone outside to look for the aurora probably around 10 times without seeing it for each time that I have. Going out into the cold and snow (Houghton got over 180 inches last winter, and that's over 30 inches below average) is rough, but it is totally worth it for the times I've seen the aurora.

The pictures above are ones I've taken myself. Getting good pictures of the aurora is hard without a very expensive camera and tripod for taking long exposure pictures. The longest exposure my point-and-shoot will do is 4 seconds and I don't have a tripod, so this is the best I could do. What I can't capture in a picture is one of my favorite parts of the aurora- how it moves and shifts with time.

Strong solar storms do happen. One occurred in 1859 that caused visible auroras in the Caribbean. It was bright enough to read by in the northern US. However, it also fried a lot of telegraph systems. If a similar storm occurred today, it would destroy much of our power grid and the repair cost is estimated in the trillions of dollars. But, man, the aurora would be gorgeous.

So get out there and start looking! (you can wait until it's dark if you must)

<p>I created an aurora alert myself now, with some simple php scripts. First is reading this file for solar flares: <a href="http://services.swpc.noaa.gov/text/goes-xray-flux-primary.txt" rel="nofollow">http://services.swpc.noaa.gov/text/goes-xray-flux-...</a> every 30 minutes, the script looks after values with e-6 or higher (-5, -4, ..) and fires an alarm, when values are higher than 8.0e-6 (-&gt; C8.0 Class Flare on the sun). It also monitors if the flare persists an if yes how long and how high the maximum value is.</p><p>Second is this file for current Kp values (actually the last 3 hours): <a href="http://services.swpc.noaa.gov/text/daily-geomagnetic-indices.txt" rel="nofollow">http://services.swpc.noaa.gov/text/daily-geomagnet...</a></p><p>Alarm fires, when a Kp of 5 or higher occurs. Also gives information about current solar wind speed and Bz value then.</p><p>Third is this file (<a href="http://services.swpc.noaa.gov/text/3-day-solar-geomag-predictions.txt" rel="nofollow">http://services.swpc.noaa.gov/text/3-day-solar-geo...</a>) which is read every day at 00:30 and fires an alarm, when there are Kp values &gt;5 predicted for the next 3 days or when the probability of a solar flare or proton event is &gt;50%</p><p>If you are interested you can see it on http.//space-view.net (curently only in german) and in my space-view app. In the app there is also a push notification on the alerts</p>
<p>You could add more data to it. Especially from the ACE satellite's EPAM device. A solar storm soon hitting the magnetic field will drastically increase the values for &quot;Speed&quot; and the proton density. </p><p>Also the MAG/SWEPAM could be worth a look, because for visible auroras the interplanetary magnetic field has to be aligned to the magnetic south, which you can see through a negative Bz value. When the Bz changes to negative you also want a more or less stable Phi curve. When these conditions meet, a visible aurora will be very likely to happen and an alarm can be sent.</p>
<p>Good points. These are factors I look at in more detail when other indicators go off. I also believe that the ovation model takes all of this and more into account to provide an easier to understand prediction.</p>
<p>Great idea. Witnessing the aurora is definitely worth the work!</p>
<p>I did something similar (though not as cool) with pushbullet. Way to go!</p>
<p>My kids vividly remember when I drug them out of bed in the middle of the night and made them get their coats on and go stand out in the dark to look at the sky. Fortunately they remember it fondly. That night was one of the better ones with the flashing colors covering more than 3/4 of the sky. I am always amazed that with all that frantic activity it is totally silent. You are so used to things like thunder but there is nothing. Just the buzzing of the mosquitoes as they take advantage of your standing still with your mouth open. </p><p>We see them a lot here, kind of take it for granted. Often when driving at night you can see it along with occasional meteors. But you do need good conditions, dim moon, very few clouds, and not so cold that it freezes you to the ground. </p><p>People are so used to light pollution that many don't even know what it is like to be totally in the dark. It is fun to take people who are city dwellers out to an area where there are no lights and turn the car off and have them get out. They can't believe its so dark. Then have them look at the sky. Most have never seen the stars like that. It is often an inspiring moment for them. To really see how big the universe is kind of puts their stresses and such in a different perspective. </p>
<p>This is amazing! I've always wanted to see the northern lights. This is a great soluition to make sure that you never miss an event. I like the idea of running it on a light weight computer. I'd be very interested in seeing if anyone does anything like that as well. </p>

About This Instructable




Bio: I am a mechanical engineering student. I enjoy building things, learning how stuff works, and other engineering activities. I also like running, biking, and being ... More »
More by mooinghorse:Aurora Alerts Tea Holder Radio controlled match igniter 
Add instructable to: