Jay Hickey

Technology, life, and fascinating web encounters.


Bringing Dark Sky to the Mac with PySky

I love the Dark Sky app for iOS. It's the best way to find out if rain or snow is imminent. Weather is unpredictable and inaccurate, but Dark Sky has honestly never failed me. It's amazing.

I've been thinking about how nice it would be to have Dark Sky on my Mac too. Since school has been pretty busy, I haven't been able to work on personal projects like this as I'd like. But I finally played with Dark Sky's newly released API—specifically Ryan Larrabure's Python wrapper. It was extremely easy to pull in all of the natural English language forecast information and display it cleanly on my Desktop with GeekTool. The output looked like this:

Rain, 44° F

Rain for 45 min

Moderate rain

Moderate chance of rain

Right after I finished it, Dr. Drang made an awesome post on plotting Dark Sky data with matplotlib. This inspired me to dig a little deeper and incorporate a precipitation intensity plot. Huge thanks go out to him for such a great post. Here's what the intensity plot looks like:

I also decided to incorporate Dr. Drang's method of using standard Python JSON decoding, instead of Ryan's Python wrapper. This saves the extra step of installing another module.

PySky is my result of these shenanigans. Here's it is:

# -*- coding: utf-8 -*-
import json
import urllib
from os import environ
from sys import exit, argv
import matplotlib.pyplot as plt

# If desired, enter lat & long as arguments
  lat = argv[1]
  lon = argv[2]
except IndexError:
  lat = 39.200932
  lon = -84.376009

# Get my API key and construct the URL
  with open(environ['HOME'] + '/.darksky') as rcfile:
    for line in rcfile:
      k, v = line.split(':')
      if k.strip() == 'APIkey':
        APIkey = v.strip()
    dsURL = 'https://api.darkskyapp.com/v1/forecast/%s/%s,%s' \
          % (APIkey, lat, lon)
except (IOError, NameError):
  print "Failed to get API key"

# Get the data from Dark Sky.
  jsonString = urllib.urlopen(dsURL).read()
  weather = json.loads(jsonString)
except (IOError, ValueError):
  print "Connection failure to %s" % dsURL

print 'NOW\n' +  str(weather['currentSummary']).capitalize() + ', '\
    + str(weather['currentTemp']) + u'° F'.encode('utf8') + '\n'
print 'NEXT HOUR \n' + weather['hourSummary'].capitalize() + '\n'

# Highest intensity in the next 3 hours.
hrsType = [ i['type'] for i in weather['dayPrecipitation'][1:4] ]
hrsProb = [ i['probability'] for i in weather['dayPrecipitation'][1:4] ]

chance = max(hrsProb)
probIndex = hrsProb.index(chance)

if chance > 0.8:
  nextThreeHrs = '%s' % (str(hrsType[probIndex])).capitalize()
elif chance > 0.5:
  nextThreeHrs = '%s likely' % (str(hrsType[probIndex])).capitalize()
elif chance > 0.2:
  nextThreeHrs = 'Possible %s' % str(hrsType[probIndex])
  nextThreeHrs = 'No precipitation'

print  'FOLLOWING 3 HRS\n' + nextThreeHrs.capitalize() + '\n'
print 'NEXT 24 HRS \n' + weather['daySummary'].capitalize() + '\n'

# Hourly intensity information for plot.
intensity = [x['intensity'] for x in weather['hourPrecipitation']]
time = [(x['time'] - weather['hourPrecipitation'][0]['time'])/60 \
     for x in weather['hourPrecipitation']]

# Plot dashed lines at intensity ranges.
plt.hlines(15, 0, 59, colors='black', linestyles='dashed')
plt.hlines(30, 0, 59, colors='black', linestyles='dashed')
plt.hlines(45, 0, 59, colors='black', linestyles='dashed')

# Plot the values.
plt.fill_between(time, intensity, color='#ffff00', alpha = .8, linewidth=2)
plt.axis([0, 59, 0, 60], frameon = True)
plt.xticks([10, 20, 30, 40, 50])
plt.yticks([7.5, 22.5, 37.5, 52.5], ['sporadic', 'light', 'moderate', 'heavy'],\
plt.tick_params('y', length=0)
plt.xlabel('Minutes from now')

# Save out to a png image.
plt.savefig('/Volumes/MacHD/Projects/darksky-scripts/ds-rain-1.png', dpi=220, \
  transparent=True, bbox_inches='tight')

GitHub is where you can download the source and view instructions to both run the script and display it on your Desktop with GeekTool—the latter of which makes PySky really useful. It looks like this on my Mac:

An explanation of the beginning of the script—reading in the latitude and longitude coordinates, getting the API key in from the ~/.darksky file, and retrieving JSON data from the Dark Sky—is better explained in Dr. Drang's post. He also does a great job at describing the plot routine.

I really like the presentation of data in the Dark Sky iOS apps, so I wanted PySky to show almost all same the info:

Displaying the English language forecast information was really all I had to do. The Hourly Forecast API Docs and some simple introspection told me most of what I needed to know about the weather variable containing the returned JSON object from Dark Sky.

"Now" and "Next Hour" information was easily retrieved with weather['currentSummary'] and weather['hourSummary']. I don't find "Overnight", "Morning", and "Afternoon" particularly useful, so they're replaced with "Next 24 Hours" data from weather['daySummary'].

For the "Following 3 Hours" information, I used weather['dayPrecipitation'] data. The docs explain that dayPrecipitation contains an array of precipitation predictions for the next 24 hours. The size of dayPrecipitation is 25, where dayPrecipitation[0] is the current precipitation, and dayPrecipitation[24] is 24 hours from now. Each dayPrecipitation[n] contains a dictionary with precipitation probability, type, temp, and time:

"dayPrecipitation": [
    { "probability": 1.0,
      "type": "rain",
      "temp": 65,
      "time": 1325607311 },

    { "probability": 0.84,
      "type": "rain",
      "temp": 65,
      "time": 1325610911 },

    { "probability": 0.8,
      "type": "rain",
      "temp": 65,
      "time": 1325614511 },

We just want the type and probability for hours [1:4]1, so I created a list of each like so:

hrsType = [ i['type'] for i in weather['dayPrecipitation'][1:4] ]
hrsProb = [ i['probability'] for i in weather['dayPrecipitation'][1:4] ]

The next line, chance = max(hrsProb), finds the maximum probability of precipitation, and probIndex = hrsProb.index(max(hrsProb)) finds the index (hour) of that maximum. Then we just find the type of precipitation at this index and print it out with terms such as "likely" or "possible" depending on the max probability:

if chance > 0.8:
  nextThreeHrs = '%s' % (str(hrsType[probIndex])).capitalize()
elif chance > 0.5:
  nextThreeHrs = '%s likely' % (str(hrsType[probIndex])).capitalize()
elif chance > 0.2:
  nextThreeHrs = 'Possible %s' % str(hrsType[probIndex])
  nextThreeHrs = 'No precipitation'

I haven't tested this enough to be sure that 0.8, 0.5, and 0.2 are proper probability thresholds, but they've been fine so far for me.

I think this might be one of the quickest and most basic scrips I've written, but it's also one of the most useful to me. Having the precipitation forecast at a quick glance on my computer will come in handy every day when I check the weather in the morning. I'm always looking for ways to make my programs better, so if you have any suggestions for improvements please get in touch.

  1. [1:4] means from element 1 up to, but not including 4. 


iPhone 5: the Little Things

The iPhone 5 has been out for almost a week now. After using it constantly and reading way too many reviews, I've become really interested with some of the little, specific changes Apple made. So this isn't a full review—visit those other links if that's what you want—it's more a conglomerate of the interesting "little things"1 in the iPhone 5.

Call Quality

The first thing I did when I got the 5 was make a phone call with it. It's what most of that money I pay AT&T is for, so I figured I would see if there were any improvements. Because of no voice-over-LTE yet, call reception in my area is still terrible. But from the quality side, it's amazing how much clearer and easier to hear everyone is.

There are 3 microphones on the iPhone 5—bottom, front, and back. This is one more than the iPhone 4/4S, and the addition is noticeable. For the first time, noise canceling isn't just for the person on the other end. I notice it on my end too. You know the white noise sound and slight suction feeling when you put on noise canceling headphones? It feels like that in my ear when I'm on the phone. I was at the extremely busy and loud Cincinnati Oktoberfest last weekend and had no trouble calling a cab while standing right behind the loud music stage. I'm no longer mashing on the "volume up" button, straining to hear.

Wideband Audio

Wideband audio would also be nice, but isn't coming to U.S. It would mean calls have less midrange and more bass and treble, i.e., voices have a much fuller sound, and less of that talking-through-a-tin-can sound. Wideband audio is known as HD voice on most Android phones, which also isn't supported here. I'm hoping the carriers can enable this in the future, but it's a lot of backend work I don't think any provider wants to put money towards. It's upsetting to think the iPhone has the hardware to make call quality even better, but it's likely we'll never hear it.

Built-in Speaker

Both the sound quality and loudness of the built-in speaker are fantastic and vastly improved. I use a Jambox whenever I need a speaker phone or want to play music on the go, but it's undeniable that good built-in speakers are important to many people. The speaker is definitely larger, giving everything less tin in the treble range and a fuller bass response. Compared to the 4/4S, the speaker gets decently louder too.


As I'm sure you already know, the display is taller. I have a love / hate relationship with this. On one hand, I love being able to see more of a web page and Twitter. However, I can barely reach the top left corner while using the phone with one hand. And I have pretty big hands. I have to really stretch, and sometimes even shimmy my hand up in order to reach the back button in apps like TweetBot, Reeder, or even Mail. I can see this really being an issue for people with smaller hands. Overall I'm happy with the change, but unless Apple makes up real estate by replacing the home button with more screen, I seriously don't want a display larger than 4 inches.

Not only is the display bigger, it's better than any other smartphone on the market. The in-cell technology means the LCD is merged with the touch sensor, allowing the screen to be even thinner. Not only that, it also has a full sRGB color gamut, meaning colors really pop and are accurately represented. Held side by side with the 4/4S, you can really notice the difference—much darker blacks and more saturated colors that look great, but not ridiculous like the PenTile displays on other devices. This truly is one of the best displays around—better than even computer monitors and televisions. But don't just take my word for it—all you need to do is look at Anandtech's in-depth analysis of the display to see how accurate it really is.


LTE is great. AT&T is abysmal in a majority Cincinnati, but now with LTE, pages actually load. Around town, I've run speed tests giving me close to 25 Mbps down and 6 Mbps up. That's just below the speeds I get on my 30/10 fiber connection at home. This has made made me happy to be with AT&T again.

I'm pleased with the speeds, but worried about how it'll perform once the network gets saturated and more people get LTE phones. A big concern is that AT&T only has 5 MHz bandwidth LTE in Cincinnati, as opposed to the more common 10 MHz. This larger bandwidth allows for much faster maximum speeds and higher capacity. Brian Klug of Anandtech tweeted a nice chart the other day showing max speeds at these different bandwidths:

If you’re wondering about the difference in max speeds for 5MHz vs 10MHz FDD-LTE, this table is your friend: i.imgur.com/z74tS.png 2x2 = now

LTE Peak Data Rates
  — Brian Klug (@nerdtalker) Tue Sep 25 2012 8:53 PM CDT

Verizon and AT&T have 10 MHz in most areas, but Sprint is 5 MHz everywhere. I can't recommend anyone switch to Sprint with their lack of LTE coverage and this choice in bandwidth. 5 MHz is OK for right now, but once the network gets loaded things will slow down. Hopefully carriers will add bandwidth if problems arise, though I'm not holding my breath.

If you want to see what the bandwidth is in your area, enter Field Test Mode by calling *3001#12345#* then selecting "Serving Cell Info". You should see something like this4:

Field Test

I think it's interesting to look at the DL and UL frequencies too, but I'm taking and RF and Microwave class this semester that relates to these parameters. Nevertheless, Field Test Mode is pretty expansive on the iPhone 5 compared to previous iPhones5.

Vibrator Motor

Looking at iFixit's teardown, it seems like the iPhone 5 has the same vibrator motor as the iPhone 4. That is, a rotational motor with a counterweight. I can confirm that the vibration is identical to that of my old iPhone 4. Conversely, the 4S has a linear oscillating vibrator, which uses an electromagnet instead of a standard spinning motor.

I hear that the oscillating vibrator is better, but I can't be really be the judge since I've never owned a 4S. What I do know though, is that the rotational motor is free spinning, so you can hear it rattle when shaking the phone. Shake your iPhone 4 or 5 rapidly next to your ear and listen to the top right corner. Hear that soft rattle? That's the vibrator spinning. That doesn't happen in a 4S. No big deal by any means, but for such a beautifully engineered phone, I'm curious as to what the design decision was for jumping back to the rotational motor.

Headphone Jack

I love having the headphone jack on bottom. I loved it on my old 1st generation iPod Touch, and am excited to have it back. But a lot of people dislike the change. Here are my four theories why Apple made the move:

  1. You can actually put your phone in your pocket the way I (and, I assume, most people) do. Top in first, with the screen side facing the leg. With all previous iPhones, I had to place it in bottom first if headphones were in, causing weird fumbling when pulling it out of my pocket.
  2. When you're using the iPhone 5 with headphones in and holding it in front of you, the cord isn't dangling over the screen and blocking your thumb. You also have more cable slack this way.
  3. Might be far fetched, but it's possible another reason for the move is Apple's lack of iPhone docks. Before, it was nice to be able to dock your iPhone while keeping the headphones in. Now with Airplay, iTunes Wi-Fi sync, iTunes Match, and automatic iCloud backups, people rarely need to plug their iPhones in short of charging them at night. I have yet to plug mine into my Mac, and don't plan to anytime soon.
  4. There just wasn't enough room in the top of the phone and the new, smaller lightning connector freed up some space in the bottom for a headphone jack. From what I can see, the 720p front facing camera occupies a good amount of real estate up top2.

Regardless of why they did it3, I'm definitely a fan.

The Crux

I really like my iPhone 5. It's shockingly light, ridiculously fast, and built like nothing I've ever owned6. These "little things" aren't so little when they add up to make the best cell phone ever made. I can't wait to keep using this thing and discovering more.

  1. Alright maybe some medium-sized things too, but I I'll in sprinkle some personal insight on those. 

  2. The 720p front camera is great by the way. Not only for all the ladies who use it to take self-portraits of themselves with their friends, but FaceTime looks better too. Especially if the receiving end is on an iPad. 

  3. At least one of these theories has to be correct though, right? 

  4. I wish Apple would've optimized Field Test Mode for the iPhone 5 screen. Stupid black bars. 

  5. Although I have no clue what most of the data means. 

  6. And no worn out home button like on my old iPhone 4! 


iPhone 5 Announced

The iPhone 5 was announced yesterday, dressed up exactly as expected. Taller 4" screen, thinner, lighter, and contained in a unibody aluminum housing. It will be released next Friday, September 21st. I can't wait to get it.

A lot of pundits are disappointed by the lack of surprise and new features, but I love the new phone. If nothing had been leaked early, I think everyone would be more excited. But with Apple's massive production needs, hardware leaks are inevitable. That's just the way it's going to be now.

I think the only iPhone 5 hardware feature that wasn't leaked ahead of time was the weight1—it's 20% lighter than the iPhone 4S. Doesn't sound like much, but it's the first thing most bloggers who've held the device noticed. See what Joshua Topolsky over at The Verge has to say in the first 30 seconds of this hands-on:

I can't wait to pre-order mine tomorrow and (hopefully) have it in my hands next Friday. Here's what I'm most excited about2:

  • A6 Processor: This is the best improvement—my iPhone 4 is feeling slower every day. AnandTech has confirmed the iPhone 5 is powered by two ARM Cortex A15 cores on Samsung's 32nm LP HK+MG process. This marks the first time Apple has beat Samsung and TI to bringing a new ARM processor to the market. So this thing is cutting edge, and really fast3.

  • Size: A larger screen but smaller overall volume and width is exactly what I want in the iPhone. I wish it didn't have to be any taller, but a third of an inch won't kill me. Keeping the same width is most important, because wide Android phones look just terrible in the front pockets of properly fitted, slim-cut jeans. And unless you have ogre fists, good luck typing one handed.

  • LTE: I couldn't decide whether or not to stay on AT&T or jump back to my family's Sprint Plan4. But now that AT&T has promised LTE in Cincinnati by the end of the year, I'll be sticking with them. Might regret it later, but Sprint is way too far behind on LTE coverage to even be considered.

  • Sapphire Crystal Lens Cover: Sapphire crystal is second in hardness only to diamond. I've gone through multiple iPhone 4 backings, and almost all of them had scratched lenses from me just setting the phone on a table. A case could solved the problem, but I hate cases. This new lens protection is going to make those 8-megapixel photos and giant panoramas look great every time.

  • EarPods: These earbuds were 3 years in the making, went trough 124 iterations, and tested on 600 people. Apple claims EarPods were designed to fit everyone's ears. And they stay in your ears, which can't be said about the previous white buds.

Update: AnandTech has retracted their claim that the iPhone 5 is powered by an ARM Cortex A15. While the previous Apple A5 and A5X were based on the ARMv7 Cortex A9 (and the A4 on Cortex A8 before that), the iPhone 5 isn't based on a vanilla A9 or A15. It's an entirely custom Apple design, but is manufactured on a 32 nm fab and has Virtual Floating Point (VFP) 4, just like the A15. The VFPv4 unit's 32 registers will allow for much faster computations per core (the previous upgrade from VFPv2 to VFPv3 for the A9 doubled the performance of the FPU). So Judging from the AnandTech hands-on, I still think this phone will be shockingly faster than even the 4S.

  1. And what the processor is based off of, but I'll get to that in a second. 

  2. I'm only going to mention new features that were announced yesterday. None of the "known since WWDC in June" iOS 6 software stuff. I've been running the new iOS on my iPhone 4 for a while, so none of that is new to me. But I will say: Apple Maps is fast and looks nice, but terrible for finding points-of-interest. I'm pretty disappointed in Maps, to be honest. Everything else is great though. 

  3. Watch the rest of the hands-on video above to see just how fast it is. 

  4. Hopping to Verizon would be even better, but since they switched to only Share Everything plans, an account with just one line is way too expensive. 


The Missing iPhone Keyboard

Update (Sept 18, 2014): With the release of iOS 8, Apple is allowing third party keyboards. And guess what? SwiftKey has released a keyboard.

With the imminent launch of iOS 6 and the iPhone 5, I thought it would be fun to talk about a missing iOS feature—one that isn't going to make it into the iPhone 5, and probably won't ever exist in iOS. It's a feature all of my Android-loving friends and family members swear by—so much so that they refuse to switch to an iPhone because of it's inexistence in the Apple universe. It's called SwiftKey.

So what is SwiftKey? If you've never owned an Andriod phone, I doubt you've heard of it. Here's a synopsis from TouchType's 'What is SwiftKey?' page:

SwiftKey gives much more accurate corrections and predictions than other keyboards, because it’s powered by natural language technology. It understands how words work together, meaning very sloppy typing just works and the word you’ll probably want next is magically predicted.

Basically, SwiftKey adds a 5th row to your keyboard, above the normal QWERTY keyboard. This row gives you three suggestions of what word you want to type next, based on previous words and letters you've already typed. It also learns your common phrases and sentence structures, so you might only need to hit a letter or two before tapping through the predictions to finish a phrase. It makes on-screen typing extremely quick and accurate.

Every Android user I've talked to claims that once you spend some time with SwiftKey, you can't go back to anything else. As iPhone owners, we've all been screwed over by autocorrect before—there are entire websites dedicated to making fun of it—yet the iPhone keyboard is no different than it was in 2007. Apple has added new words to the dictionary over the years, but the method of typing on the iPhone hasn't changed. So why wouldn't Apple incorporate something like SwiftKey into iOS?

Well actually, they did. Or at least they almost did. Many users were excited about a year ago when hacker Sonny Dickson found a hidden autocorrect bar in iOS 5. It was basically SwiftKey ported to iOS. All you had to do was modify a .plist file to enable it. Most thought this was a clear sign that a new keyboard would show up in iOS 5.1. But it never happened.

So why haven't we seen SwiftKey in iOS? I know nothing about the software patents SwiftKey has, but I doubt that's the reason. Apple could buy SwiftKey without blinking an eye. I think the reason we haven't, and never will see SwiftKey on iOS, is because of the nature of how we type on iPhones—or at least how we're supposed to type. I never thought about it until I heard Merlin Mann1 on episode 79 of Hypercritical (at about the 1:36:00 mark). He hit the nail on the head:

Think about when you very first picked up an iPhone and started typing on it. In my case—in retrospect—it's crazy how long it took me to get that I had to stop typing like I was on a computer, which is where I would, basically, hunt and peck. And I would hit one letter at a time, and correct every miss-hit letter, because that's how you type. And you know what I do now? I go, "Naghhhhhh" and I just hit it fast with my thumbs, and it gets it mostly right! And then I go fix the misspellings. And its a thousand times faster than hunting and pecking.

That's how I type on my iPhone too. It's definitely the best way. SwiftKey goes against that methodology—you have to look at the predictions as you type, taking it one word at a time. The iPhone screws up typing often, but it has some advantages. For one, I'm not required to constantly stare at my phone when I type, so texting while walking isn't as dangerous. I'm also forced to proofread what I write. Typo corrections are quick and fairly painless.

But a lot of people don't type this way. Many become extremely frustrated when autocorrect screws up. SwiftKey would ameliorate that, while also helping convince some Android users to give iOS a chance. But all in all, we've grown accustom to the quirks of the iPhone keyboard. It's simple, and actually pretty good. And in the Apple world, simplicity reigns2.

  1. If you don't know who Merlin Mann is, shame on you. Go listen to Roderick on the Line right now. I promise you won't regret it.  

  2. Playing devil's advocate with myself: the iPhone 5 screen is going to be 176 pixels taller, and each row on an iPhone keyboard is about 108 pixels high. Therefore, adding a 5th row for the SwiftKey autocorrect bar wouldn't cause the keyboard to use a higher percentage of the screen than it already does. So you never know. But I still don't see it happening.