Sunday, June 3, 2018

Cause of triangular stars in a short tube 80 telescope (ST80)


I bought a Meade short tube 80 achromatic refractor as an inexpensive way to do some wider field astrophotography. The first night out, I was surprised to see that the images of brighter stars were triangular! Here's a closeup.



I did some reading online, and found some forum pages mentioning that this can be caused by pinched optics, which are the result of the front objective being overtightened. I didn't find any sample images though - the purpose of this post is to get some out there.

The dew cap is easily removed, which gives access to the front objective retaining ring. Mine was significantly overtightened - it took a fair amount of force to loosen it. The ring should be snugged down lightly, just enough to prevent it from moving.

This resolved the problem immediately. I'm getting round stars now.

Astronomy and Spaceflight Wallpaper for Phones

This is just a collection of some of my favorite images, cropped to 9:16 aspect ratio to display well on a phone. The images here are not my own, other than the selection of the crop.

Credit:

Most come from NASA's image archives, HubbleSite, or SpaceX's Flickr page. The Alma telescope images are from the ESO's image archives.

The JunoCam images of Jupiter also need credit to Shawn Doran, who processed the raw data from JunoCam into the images seen here.

Full quality images are available for download as a zip file here. (20 MB)


 















































Thursday, March 1, 2018

Animation of Europa's shadow crossing Jupiter, 27-Feb-2018



Celestron 127SLT
ZWO ADC
ZWO ASI290MC camera
1.5x Barlow

On my first day out with my new ZWO ADC and DIY electric focuser, I was lucky to catch Europa's shadow crossing Jupiter. Io and Europa are visible, and Europa's shadow moves across the face of the planet.

Each frame was stacked from 2 minutes of data.

Here's an annotated frame, with some contrast adjustment.



Saturday, February 10, 2018

DIY Electric Focuser For Celestron 127 SLT Maksutov/Cassegrain





It's been really cloudy. For eight weeks. So I've been working on scope projects - at some point, one day, I'll be able to see the night sky again. :-)

One of the tradeoffs with the mid-price Celestron 127SLT is that it shakes rather badly when you touch it, and takes several seconds to settle down. I'm focusing using a Bahtinov mask and Sharpcap's Bahtinov aid, which gives a numeric indication of the accuracy of your focus. It can be a slow process to focus it since you tweak, wait, and tweak again.

I decided that a remotely controlled electric focuser would allow me to do a much finer focus than I could achieve by hand, since it would not require touching the scope.

This design doesn't require removal of the focuser knob - only the rubber sleeve that covers it. This sleeve slips off by hand.

If you do pursue a different design that requires removal of the focuser knob, be warned that you must not tip the telescope down toward the table with the focuser knob removed - the knob is all that prevents the main mirror from falling forward and smacking into the corrector lens, which requires a teardown and cleaning to fix. This design does not risk that situation.

It took some head scratching to figure out how to mount the motor to the optical tube assembly (OTA). It finally dawned on me that I could remove the dovetail mount, and install a bracket under it. Aluminum stock which is 1" wide fits nicely in the gap that the dovetail leaves between it and the OTA. I then made a simple motor mount out of 1.5" x 1.5" right angle aluminum stock.


I cut some slots in the motor mount so that the stepper motor could be moved back and forth a bit, to set tension on the belt. I don't have a mill, so just drilled some holes next to each other and then filed the slot to open it up.



The focuser knob is 15 mm, and the stepper motor shaft was 5 mm. I used the following parts:

Aluminum 50 tooth MXL pulley with 15 mm bore
Aluminum 30 tooth MXL pulley with 5 mm bore

Based on some belt length calculators I found online, I first tried an 8" MXL closed loop belt, which worked, but had the motor run out to the end of it's range of adjustment. I wanted the motor closer to the OTA, so I found a 7.6" MXL belt from McMaster-Carr, part number 7887k78.

The 15 mm bore pulley was a perfect fit. The 5 mm bore pulley needed to be bored out to 5.2 mm to fit the shaft.


Here's a test run, with the original 8" belt.



The stepper motor can be controlled any number of ways, depending on what you want to do. There are a number of ASCOM compliant stepper controllers driven by microprocessors. My goal was to make my scope remotely controllable across a network, so I used a Raspberry Pi Zero W and an EasyDriver , along with a 5V regulator.




For a simple web browser interface, I used information from this excellent Flask tutorial to make a very simple web app to allow coarse, medium, and fine motor control. Source code will be in a separate article once it is a bit more polished.

Everything was buttoned up in a box with strain reliefs - it runs off the same 12V jump start battery I use to power the scope. Initial tests have been very positive - I can't wait for some clear skies to test it! It focuses very smoothly with no shaking - you can see clearly through the scope during the entire focusing process. Additionally, with the stepper motor, you can move the focuser in much smaller increments than by hand.




Friday, February 9, 2018

Switching Between Client Mode and Access Point Mode on Raspberry Pi




I'm working on a project to network my telescope. I have a Raspberry Pi Zero that is controlling a power focuser, and will eventually control scope motion by sending serial commands to the hand controller.

If I'm at home, I'd like to connect to my home network. If I'm away from home, I want it to act as an access point (AP) so that I can control the scope. This would also be really useful on a network controlled robot.

This was tested on a Pi Zero W, and should work on a Pi 3 as well. It assumes the Pi is currently configured to automatically connect to your home network. Pi's that use different USB wireless NICS will need a modification to the hostapd configuration file to reflect the driver name in use.

I'm using hostapd and the ISC DHCPD server, so first:

sudo apt-get install hostapd isc-dhcp-server

My /etc/hostapd/hostapd.conf file looks like this:

# WifI interface and driver to be used
interface=wlan0
driver=nl80211

# WiFi settings
hw_mode=g
channel=6
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
macaddr_acl=0
ignore_broadcast_ssid=0

# Use WPA authentication and a pre-shared key
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP

# Network Name
ssid=MySSID
# Network password
wpa_passphrase=MyPassword

I appended the following network definition to /etc/dhcp/dhcpd.conf to define the range of addresses that it will hand out to clients when acting as an AP:

subnet 192.168.1.0 netmask 255.255.255.0 {
 range 192.168.1.10 192.168.1.50;
 option broadcast-address 192.168.1.255;
 option routers 192.168.1.125;
 default-lease-time 600;
 max-lease-time 7200;
 option domain-name "local";
 option domain-name-servers 8.8.8.8, 8.8.4.4;
}

The following script, when executed, will disconnect from any AP that the Pi is associated with and fire up the access point, setting a static IP for the Pi in the process:

sudo killall wpa_supplicant
sudo ifconfig wlan0 down
sudo ifconfig wlan0 192.168.1.125 netmask 255.255.255.0 up
sudo service isc-dhcp-server start
sudo hostapd /etc/hostapd/hostapd.conf &

Then we just need to determine if we are connected or not when the Pi boots up.

First, I added an entry in /etc/rc.local to call this script, which checks to see if I'm connected to my home AP after a brief delay:

sleep 10
OUTPUT=$(iwconfig wlan0 | grep -c MyHomeSSID)

if [ "$OUTPUT" = "0" ]
then
        echo "Not associated to home AP, starting local AP"
        logger "Home AP not found, starting local AP"
        sudo /home/pi/startAP
else
        echo "Associated to home AP, no action taken"
        logger "Home AP found, not starting local AP"
fi


Monday, November 13, 2017

From One Gun Guy To Another: A Proposal To Reduce Victims In Mass Shootings

Like all of my blog posts, this article gives my personal views and does not represent the views of my employers, past or present. 

Like a lot of folks in America, I grew up around guns. My grandfather and dad taught me to shoot in the clay pits of south Alabama, with a strong focus on safety and responsibility. As I got older, I realized that it was not only a great deal of fun, but a method of effectively protecting myself and my family against folks who might try to do us harm. I take that right and responsibility quite seriously. I practice regularly and have done a lot of reading to educate myself on the implications of using a weapon in self defense. I had a concealed carry permit and carried regularly for years, both at home and when backpacking. I'm a gun guy. I enjoy using them, and I stay ready in case I ever have to use one in defense.

Like a lot of gun guys over the last few years, I've been watching the growing number of mass shootings and struggling with it. Yes, I believe guns in the hands of good guys are a good thing, but how do we balance that against folks who are mentally ill killing or injuring dozens at a time? A lot of gun folks insist it's a people problem, not a gun problem. I argue that it's both. Clearly, mentally ill people must not have access to firearms, to the greatest extent possible. But we all know how hard that is. The background check system fails sometimes, or an ill person simply has someone buy the weapon for them. Sometimes they take a family member's that is not well secured.

So we have a certain number of mentally ill folks that are going to have access to guns. How can we limit the amount of damage they can do without dramatically reducing the freedoms of millions of lawful gun owners? 

We should treat high capacity magazines (>10 rounds) the same way we treat sound suppressors ("silencers"). Existing high capacity magazines should be bought back at fair market value, or the owner acquire the tax stamp and background check. Like suppressors, the penalty for unlawful possession must have serious teeth.

To buy a suppressor, you are subjected to an extensive background check, more so than buying a firearm. For each suppressor you buy, you have to buy a tax stamp, at a cost that is affordable if someone really wants or needs it, but high enough to make it painful to buy a lot of them.  The current cost for the stamp, per suppressor, is $200.

Here are the reasons why this is an effective strategy.

1) It will dramatically reduce the number available to an attacker. Only people who really need them will keep them, and those folks will pass a more stringent background check. They WILL be available to those who need them, though, in modest number.

2) Your kids are probably receiving some form of armed intruder response training in school. I've gotten two variants of it in the workplace. They teach you to run, hide, and as a last option, to wait until the attacker is reloading, and fight. You are trained to throw things, from books to fire extinguishers, and to gang up on the attacker to immobilize him.

If an attacker has a collection of 30 round magazines, pauses to reload don't happen very often. If the magazine capacity is limited to ten rounds, the victims get two additional windows of opportunity per magazine in which to flee or fight. 

3) If someone is planning an attack and tries to accumulate a lot of them, it will be noticed.

4) It effectively limits the number of rounds an attacker can easily carry which are ready to fire.

The existing magazines that were being registered would require serialization. A system would need to be created to allow a worn magazine to be exchanged for a new one without requiring another stamp, and the worn one destroyed.

Undoubtedly, you are raising concerns. They are probably the reactions that I tend to have to any proposed gun control too. 

"The bad guys won't turn theirs in, so it won't help." 

A lot of guns used in mass shootings are obtained legally by the shooter or through family members. Making high capacity magazines harder to obtain will make it more likely that a shooter won't have a pile of those magazines on them when they commit their crime. 

"I can change a magazine really quickly. It won't make a difference."

For some people who are extensively trained to use guns under pressure- military, for example - that's probably reasonably true. For those of us who spend our days in offices, though, changing a magazine at the range doesn't translate to doing it while people are pelting you with books or whacking you over the head with a fire extinguisher. That's hard. That requires more focus than the vast majority of civilians have. 

Besides - if there is no advantage to them, why do you want one? You know that argument doesn't hold water. If they didn't have a significant advantage in an offensive situation, you wouldn't see them issued to infantry around the world.

"If we give an inch, they will take a mile. They want to ban all guns!"

If we refuse to acknowledge that the gun is a force multiplier, and do not genuinely try to find a solution that reduces harm to society, we are far more likely to lose our gun rights. Casually replying that guns don't kill people in response to a tragedy where one mentally ill person has killed dozens of innocents is callous, and counterproductive. 

Decades ago, we as a nation decided that machine guns, suppressors, high explosives, and heavy weapons should be heavily controlled because they place unreasonable power to do harm in the hands of a single person. Our gun rights have not been eroded as a result. This should be extended to high capacity magazines to limit the harm a single ill person can do.

"The second amendment isn't about hunting. We must be ready to repel a foreign invader or a hostile government."

You can do that with a good scoped bolt action hunting rifle. You can do that with 10 round magazines. If you feel really, really strongly about it, obey the law, pass the background check, and buy yourself some high capacity magazines. Then lock them up.

"I need high capacity magazines to defend myself or my family."

High capacity magazines in a pistol are certainly potentially useful in an extended altercation on the street. If you really feel the need, it would still be available. It just would be a bit harder to do. It should be noted, though, that a review of the NRA's Armed Citizen covering 5 years of incidents involving the use of firearms by civilians for self defense indicated the following:

"As might be expected, the majority of incidents (52%) took place in the home. Next most common locale (32%) was in a business. Incidents took place in public places in 9% of reports and 7% occurred in or around vehicles.

The most common initial crimes were armed robbery (32%), home invasion (30%), and burglary (18%). Overall, shots were fired by the defender in 72% of incidents. The average and median number of shots fired was 2. When more than 2 shots were fired, it generally appeared that the defender’s initial response was to fire until empty." (emphasis mine)

Now, if you are talking about your AR, consider that carefully. If you live in a typical city or suburban area and are firing 30 rounds of .223 at your attacker, those rounds will go through walls and stand a high likelihood of injuring someone other than your attacker. 

"High capacity magazines are fun."

They sure are fun. But that is an absolutely inadequate reason to keep them so readily available when they make it easier for one mentally ill person to kill a couple dozen people. 

"The solution is to have more armed law abiding citizens."

That is an entirely separate potential solution that deserves careful study. It doesn't invalidate any of the arguments presented here.

Making high capacity magazines harder for an attacker to get will give victims under attack more time to flee, hide, or fight. 

We, as pro-gun people, need to acknowledge that the weapons we keep DO play a part in these tragedies. T-shirt slogans aren't good enough. We need to propose effective approaches to reducing the death toll from these terrible incidents.

Friday, November 3, 2017

Automated meteor/aircraft/satellite detection for sky camera in Python



Introduction

In a previous post,  I described the construction of a simple networked sky camera built with a Raspberry Pi. I was pleased with how well it worked, but quickly figured out that manually reviewing the more than 5000 frames it generated per night was a drag. 

The following describes a Python script that makes uses calls to ImageMagick on a Linux computer to identify frames that potentially contain something interesting. In a typical night, it reduces the frames for manual review from 5000+ to a dozen or so, and it picks up lighter streaks than I tend to see rapidly skimming through by hand. There are certainly more sophisticated ways to do that, but I was surprised at how well this works. Specific drawbacks are mentioned below.



Things you are likely to catch with a sky camera

My sky camera exposes for 10 seconds per frame. As a result, a bright moving object will leave a line. You can interpret the line to determine what it is.

 1) Airplanes. Lots of airplanes. You'll be surprised at how many airplanes fly over your house or observatory.

Airplanes that fly at night are required to have strobe lights on the wing tips and vertical stabilizer. As a result, they produce a distictive dot-dash-dot-dash pattern as the fly across the sky during a long exposure, which is easy for a person to identify.

Also, they cross from one side of the frame to the other, and take several frames to do it - typically three to four. They don't appear in the middle of the sky and then disappear after short distances.




Airplanes

2) Satellites. Fewer than airplanes, and they are fairly easily distinguished. First, they don't have strobes, so they appear as a fairly consistent brightness that travels in a straight line. They also usually take 3-4 frames to cross from one side to the other. If it's a straight, non-strobing line that lasts more than two frames, it's not a meteor, since it is travelling too slowly across the sky.



A satellite - 1 frame of 3

3) Meteors. If it appears in no more than 2 frames (since it's possible for it to occur at the end of one frame and the start of another) and it doesn't cross the whole frame, congratulations - you've probably captured a rock from space! An airplane or satellite is not expected to start in the middle of the sky, but a meteor can.


Orionid meteor - Oct 2017. Stack of two sequential images that the meteor was on, cropped

Finding frames with possible objects in them

If you are running your sky camera on a clear night, detection of things moving can be as easy as identifying frames that are significantly different from the frame before it. Since the Earth is rotating, we expect it to change a little, so a "fuzz" factor is applied - a small amount of change is ignored. If that threshold is exceeded, though, we should set the frame aside for a person to look at. This simple operation sifts through thousands of frames and pulls out the ones that have something happening remarkably well. 

Of course, if you have trees or clouds in your frame, it's likely that motion of those will trigger it too - a false positive. Clouds can be identified reasonably well by simply dropping frames that exceed a certain brightness threshold, but that increases computing time and you might miss a frame that has something interesting in it that also has a cloud. It's a tradeoff. At the moment, I only capture images on pretty clear nights, so I leave the brightness thresholding turned off to speed processing. If you want the function enabled, you can just uncomment the line in main() that calls it.

Running the program

The program currently runs on a Linux computer with Python and ImageMagick installed. Most distros have these already. An example command looks like this. The first argument is the directory containing the images you captured, and the second is your desired output directory. Frames that the program determines may be interesting are copied to the output folder.

./findMeteors.py 20-10-2017 20-10-2017-output/

You must assign the program file execute privileges on your Linux box - usually, this will do the trick:

chmod u+x findmeteors.py


Program listing and download


Listing follows... please let me know if you find it useful. 


#!/usr/bin/env python

import sys
import os
import subprocess
import shutil

def removeBrightImages(images, threshold):
 #The average graylevel of an image may be found using the string format "%[mean]"
 #convert image -format "%[mean]" info:
 count = 0
 darkFrames = []
 for image in images:
  if count > 0:

   command = 'convert ' + image + ' -format "%[mean]" info:'
   try:
    val = subprocess.check_output(command,shell=True) 

   except subprocess.CalledProcessError as e:

    val = e.output

   if float(val) < threshold:
    print "Adding " + image + ": brightness under threshold, queued for comparison"
    darkFrames.append(image)
   else:
    print "Rejecting " + image + ": brightness exceeds threshold"
  count = count + 1
 print darkFrames
 return darkFrames

def findChanges(images, fuzz, threshold):
 #fuzz is currently hardcoded below
 count = 0
 changedFrames = []
 commandList = []
 for image in images:
  if count > 0:
   #Trying to do this the better way with arguments and no shell=True results in the conversion
   #of the output to an int failing below, and I have not figured out why.

   #print "Comparing " + lastImage + " to " + image

   command = "compare -metric ae -fuzz 15% " +  lastImage + " " + image + " null: 2>&1"
   try:
    val = subprocess.check_output(command,shell=True) 

   #The compare program returns 2 on error otherwise 0 if the images are similar or 1 if they are dissimilar.
   except subprocess.CalledProcessError as e:

    val = e.output

        if e.returncode == 2:
     print "Error in image comparison routine."
     sys.exit()

   if int(val) > threshold:
    print image + ": " + val + ", item found"
    changedFrames.append(image)
   else:
    print "Checking: " + image 

  lastImage = image
  count = count + 1

 return changedFrames

def saveImages(images):
 for image in images:
  shutil.copy2(image, sys.argv[2]) 



def genImageList():
 imageList = []
 for file in os.listdir(sys.argv[1]):
      if file.endswith(".jpg"):
          imageList.append(os.path.join(sys.argv[1], file))
 imageList.sort()
 return imageList


def checkArgs():
 if len(sys.argv) != 3:
  print "Usage: ./findMeteors.py  "
  sys.exit()

 if os.path.isdir(sys.argv[2]):
  print "Output directory exists already, refusing to overwrite it. Exiting."
  sys.exit()
 else:
  print "Creating output directory"
      os.makedirs(sys.argv[2])



def main():

 #if brightness thresholding is enabled, set threshold. Higher is brighter.
 brightnessThreshold = 2000

 #frame difference comparison senstivity. A higher value reduces sensitivity. 0-100.
 fuzzFactor = 15

 #the number of pixels that must be different between frames in order to flag it as interesting.
 diffThreshold = 100

 checkArgs()
 images = genImageList()
 #if you want to enable brightness thresholding, uncomment the line below
 #images = removeBrightImages(images, float(brightnessThreshold))
 changedFrames = findChanges(images, fuzzFactor, diffThreshold)
 saveImages(changedFrames)

if __name__ == '__main__':
  main()