GeekTool Weather Information from Yahoo! for 2016

Update (May 7, 2016): Many thanks to kind reader @chogc who asked about the metric option to display temperature in Celsius.   That feature has been corrected.  I also implemented a workaround of a Yahoo! weather bug in which the sunset time string drops the leading zero for the minutes in some locations.  Version 1.1 incorporating these fixes can be found here.


I’m a long-time GeekTool user, which I use to display various pieces of information on my Mac desktop. One of my favorite displays is current weather information. A few years ago after browsing on the Internet for various weather geeklets and scripts, I settled on one created by Thomas Upton written in Python that used Yahoo! weather for displaying current conditions, called weather.py:

Yahoo! Weather Feeds With Python

I also used two additional scripts from other sources for displaying a current weather image icon obtained from Yahoo! and another that displayed a five-day weather forecast.

Over the years, problems arose with the current weather image icon script that required various workarounds, such as switching to the French Yahoo! weather site for images.

A few months ago, all three weather scripts stopped working. I searched around for answers, which led me to various theories (see here and here) as to why the scripts no longer worked. Ultimately, the problem was due to a query change instituted by Yahoo! in its public API for retrieving weather conditions and forecasts.

I thought about patching the various scripts.  Instead, I chose to base a consolidated solution for displaying a weather icon, current weather conditions, and forecast upon Thomas Upton’s original Python script, which I called weather-new.py, partnered with a custom Bash script called weather-condition.sh for assisting with the current weather icon handling.

The changes I made to the original Python script were four-fold:

  • First, I modified the query request to Yahoo! Weather to use the new format request (more about that shortly);
  • Second, I added output of a short weather description so that I could build a Bash “wrapper” script to select a corresponding weather image from a collection of icon files for display purposes;
  • Third, I added day-night awareness to permit selection of day-night-dependent weather icons; and
  • Fourth, I added the optional display of the sunrise and sunset times and a few other weather options such as wind chill (also known as the “feels-like” temperature).

Using the Yahoo! Weather Developer documentation, I added the additional data structures to the Python script needed to obtain the additional weather information, and I also added a few new runtime options for requesting the sunrise/sunset times, determining whether it is currently day or night, returning the weather code defined in the Yahoo! Weather Developer documentation, returning the last update time for the current weather conditions, and returning the wind chill.

I also used the query change information described here to alter how the script fetched weather information from Yahoo!  One of the other consequences of the query change required a switch from using ZIP Codes to using WOEID (“Where On Earth ID”) as a location identifier. For example, queries that used to look simple like this:

http://xml.weather.yahoo.com/forecastrss?p=77001

changed into more complex queries that looked like this:

https://query.yahooapis.com/v1/public/yql?q=select+%2A+from+weather.forecast+where+woeid%3D12791322&format=xml

After making the query change to the Python script (and finding my WOEID, which I did here), collecting a set of weather icons that I liked, and creating a new Bash wrapper script for handling weather images, the results on my desktop look like this:

Window-Weather

I’m rather pleased with the result.

If you’re a GeekTool user, here is how I constructed the above, with each rounded rectangle representing a different geeklet in GeekTool:

Geektool-Weather

  • ~/Applications/weather-condition.sh is a Bash script that calls Yahoo! weather via the weather-new.py Python script to obtain the short description of the current weather condition. Based on that description, the Bash shell copies the associated weather icon file to the location /tmp/weather.png.
  • file:///tmp/weather.png shows the result of the ~/Applications/weather-condition.sh Bash script
  • ~/Applications/weather-new.py –lvrs 12791684 calls Yahoo! weather and displays the location, sunrise, sunset, and current conditions in verbose mode for WOEID 12791684 (which is my location).
  • ~/Applications/weather-new.py –-nocurr –f5 12791684 calls Yahoo! weather and displays a five-day forecast for my location without displaying the current weather status; echo Five day forecast: is for display purposes.

I’ve put the weather-new.py Python script, weather-condition.sh Bash script, and a set of weather icons into a zip archive, which you can grab here. I also put the geeklets in the archive for your use if you’re a GeekTool user. Just double-click the geeklets to install them into GeekTool, and customize the geeklets based on your WOEID and where you placed the scripts and weather icon folder. I placed mine in ~/Applications (the Applications folder inside my home folder, not the main Applications folder where applications are kept). If you place the scripts and weather icon folder into an alternative location, also make the corresponding location mods to the weather-condition.sh script.

Enjoy!

Advertisements
GeekTool Weather Information from Yahoo! for 2016

LED Versus Incandescent Bulbs (3rd Update)

In LED Versus Incandescent Bulbs (An Update), I mentioned that I replaced the incandescent bulbs in my kitchen with LED bulbs:

  • Former: BR-30 soft white bulb, 65 W, 635 lumens, 2700K
  • New: Philips SlimStyle 65W-equivalent BR-30 soft white bulb, 9.5 W, 650 lumens, 2700 K

Over the following year after switching to the LED bulbs, I felt as if my electricity bills were slightly lower. To verify, I pulled my electricity bills and computed the total energy cost for the year before versus the year after. I found I actually saved $120 in electricity costs. I decided to perform some match to see if the amount of savings was directly attributable to the lower energy consumption of the LED bulbs in the kitchen.[1]

If your home is like mine, the kitchen is the center of activity in the home. In my kitchen I have five bulbs that burn, on average, about eight hours per day – two hours in the morning, and six in the evening, roughly. The power consumption for one of the LED bulbs I mentioned earlier is 55.5 W less than the equivalent incandescent it replaced. Multiply by five bulbs yields 277.5 W less to light the kitchen with the LED bulbs than with the incandescent bulbs.

To figure out annual energy usage and cost per year, I’ll perform some simple math. First, I’ll convert 277.5 W into kilowatts by dividing it by 1000, and then calculate the energy usage in kilowatt-hours per year:

0.2775 kW * 8 hours/day * 365 days/year = 810 kW-hr/year

At 12 cents per kilowatt-hour rate for electricity in my area, the result is an annual net savings of about $97:

810 kW-hr/year * $0.12/kW-hr = $97/year

That’s in the ballpark of the $120 in savings I actually saw.

The bottom line is that the decrease in my electricity bills is highly correlated to the switch from incandescent bulbs to LED bulbs in my kitchen. It gives me a thought to identify other opportunities to save elsewhere in the house. At least from a lighting standpoint, I know I have to be careful to identify higher-usage lights to be able to recoup the costs of the LED bulbs. But there are other electricity-consuming devices in the house….


[1]Clearly, variations in usage of other electricity-consuming devices will pollute the answer. In Houston we rely upon air conditioning to bear the warmer months, which is often a big consumer of electricity and causes large seasonal variations in total energy cost from month to month. By taking the annual average and assuming that the usage of electricity is the same from year to year, it should negate these seasonal effects.

LED Versus Incandescent Bulbs (3rd Update)

Challenger at 30

This is a somber week for those of us in the space business as we pause and reflect on those who we lost. The Space Shuttle Challenger accident happened 30 years ago this week. Below are several links I collected that capture much of what I’m feeling this week.

NASA Day of Remembrance: http://www.nasa.gov/externalflash/DOR2016/index.html

New York Times: The Challenger Space Shuttle Disaster, 30 Years Later http://www.nytimes.com/interactive/2016/01/29/science/space/challenger-explosion-30-year-anniversary.html

NPR: 30 Years After Explosion, Challenger Engineer Still Blames Himself http://www.npr.org/sections/thetwo-way/2016/01/28/464744781/30-years-after-disaster-challenger-engineer-still-blames-himself

NASASpaceFlight.com: The Challenger seven remembered 30 years after STS-51L http://www.nasaspaceflight.com/2016/01/the-challenger-seven-remembered-51l/

Quartz: 30 years ago, NASA lost 7 astronauts in the Challenger explosion. Here’s how it moved forward. http://qz.com/604712/30-years-ago-nasa-lost-7-astronauts-in-the-challenger-explosion-heres-how-it-moved-forward/

For anyone middle age and older, I’m sure you can recall with crystal clarity where you were when news broke that Challenger exploded a little more than a minute into its flight. Either you saw it as it happened, or heard about it moments afterwards. I was newly in graduate school, having arrived at the University of Illinois a little more than a week before the accident. I remember being shocked, seeing the tragedy unfold before my eyes, and deeply saddened about the loss of life, asking myself, “Was it worth it?” President Reagan’s words afterwards convinced me that we needed to move forward while honoring those who paid the ultimate sacrifice. His words helped build a resolve in me such that in a short two years after, I joined the ranks of the men and women who were at the time working to return Shuttles to flight. That’s where I’ve been ever since.

Challenger at 30

2015 in review

Many thanks to my loyal readers.  Here’s to a successful year just completed, and to the new year to come!

The WordPress.com stats helper monkeys prepared a 2015 annual report for this blog.

Here’s an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 15,000 times in 2015. If it were a concert at Sydney Opera House, it would take about 6 sold-out performances for that many people to see it.

Click here to see the complete report.

2015 in review

August Volatility in the US Stock Market

statistics-810024_640

Driving home the other day, I heard a segment on NPR that was discussing the recent market downturn and its possible causes. Interestingly enough, one of the guests during the segment asserted the following:

“Firstly, the markets are very thin right now because it is August and you have a lot of the seasoned traders away on vacation. You’ve got less volume than anywhere in the markets. And so there’s a long tradition of people overreacting during this vacation season.”

When pressed on this point, the guest analyst didn’t waiver:

“But the reality is that, you know, many of the most seasoned and senior traders tend to go on vacation this time of year. And yes, we can all remain in contact with our iPhones and our iPads and whatever else while we’re on the beaches. But traditionally, you have had a lot of pretty wild market movements in the month of August historically.”

The question of volatility seems to be an easy point to test. First, some assumptions:

  • A market index such as the S&P 500 is an indicator of the broader market performance.
  • Volatility is high if the closing price on a given day is markedly different (up or down) than the closing price on the day prior.
  • A given month is more volatile if it has more high-volatility days than another month.

Based on the assertion that August volatility is caused by junior traders, I infer that with senior traders in charge, there should be less volatility. Otherwise, I claim that the causal relationship between volatility and the seniority of the traders is not provable.

To test the theory, I downloaded the S&P 500 closing prices for the last 10 years and performed some calculations. First, for each day I calculated the change in closing price, and percentage change in closing price. Here is an example:

Date
D(i)

S&P 500 Closing Price
P(i)

Change from Previous Day
C(i) = P(i)-P(i-1)

Percentage Change from Previous Day
R(i) = C(i)/P(i-1)

2005-08-25

1212.39

2005-08-26

1205.10

-7.29

-0.601%

2005-08-29

1212.28

+7.18

+0.596%

2005-08-30

1208.41

-3.87

-0.319%

2005-08-31

1220.33

+11.92

+0.986%

The variations in the percentage change in closing price, calculated by finding the standard deviation, will provide the measure of market volatility in accordance with the assumptions above.

Using the S&P 500 closing prices for the last 10 years, performing the above calculations, segregating the data into 12 separate monthly bins, and calculating the standard deviations for each monthly bin yields the following:

 Month Standard Deviation Rank
Jan 0.0114 7
Feb 0.0109 8
Mar 0.0128 5
Apr 0.0096 12
May 0.0105 10
Jun 0.0109 9
Jul 0.0100 11
Aug 0.0136 4
Sep 0.0141 3
Oct 0.0191 1
Nov 0.0168 2
Dec 0.0122 6

Based on the daily variations in the S&P 500 closing prices over the last 10 years, it is true that August is one of the more volatile months. However, the variations in August are exceeded by the Fall months – September (#3), November (#2), and October (#1). Therefore, if the “junior varsity” traders being in charge cause volatility in August, what is the explanation for the even higher volatility in the Fall months?

Perhaps the guest analyst had some other measure of volatility in mind – inter-day swings in prices, daily trading volume, or something else I haven’t considered. Based on the volatility in daily closing prices, however, August is in the top half of volatile months, but isn’t as volatile as the Fall months. Therefore, I question the association of August volatility with junior traders. Based on data over the last 10 years, it doesn’t seem to be a viable explanation based on the assumptions above.


References:

Is The Stock Market Volatility A Correction Or A Full-Blown Crisis? August 25, 2015
http://www.npr.org/2015/08/25/434668675/is-the-stock-market-volatility-a-correction-or-a-full-blown-crisis

S&P 500 Historical Data, last updated 2015-08-26 6:51 PM CDT
https://research.stlouisfed.org/fred2/series/SP500/downloaddata

Image via pixabay.com
https://pixabay.com/en/statistics-chart-graphic-bar-810024/

August Volatility in the US Stock Market

Six Years of Leading Space

Hard to believe I started LeadingSpace six years ago this month. Time flies.

Looking over the history of LeadingSpace and its 180 articles to date, I note that my writing focus has shifted with time, with several distinct phases. When I started LeadingSpace in 2009, I was leading a team of professionals charged with figuring out a strategy on how to keep two of NASA’s key facilities operating with the impending end of the Space Shuttle Program. I chose to use LeadingSpace as a vehicle to share my experiences in transitioning to a new leadership role, learning the specific situation at hand, and getting to know the people involved. In 2009 this was the primary focus of LeadingSpace, with an occasional new contribution since. The topic of Team Leadership marks the first phase of LeadingSpace.

Hints in late 2009 of changes to come in human spaceflight policy were unveiled in early 2010 with the cancellation of the Constellation Program, leading to uncertainty and debates over space policy and implementation. Some of that initial uncertainty spilled over into my work life. Consequently, much of the focus of my writing shifted from team leadership situations into dealing with change.

One of the key pieces I wrote during this time was a major multi-part treatise on the value proposition for human spaceflight, where I attempted to define a framework for conversing about its future:

Leading change and defining a value proposition for human spaceflight mark the second phase of LeadingSpace.

Starting in 2012, with my personal focus directed towards working on an Executive MBA under a two-year fellowship, I wrote a bit less. I tended to post quick blurbs on current topics. Towards the end of the two-year sabbatical I wrote a few pieces applying some of the operations management and federal budgeting principles I learned in the EMBA program.

I also shared a major multi-part treatise on elements of strategy that must be considered for the future of human spaceflight, based on a term paper I wrote for a Strategic Management class.

Thus we come to the end of third phase.

What will the future hold for LeadingSpace? It could be many things, and I have a lot of options. An ambitious project I have on my to-do list is to meld the human spaceflight value proposition series with the Strategizing for NASA series. Also, judging by pageviews the Transactional, Transitional, and Transformational Change post is by far the most popular piece I’ve written. Perhaps that indicates a hunger for information on dealing with change. I’m also drawn to matters of strategy in a broader context than human spaceflight, such as the recent decision by Target to exit the Canadian market. I have a draft post written on that. I also could return to the roots of LeadingSpace and write about my current experiences in a new role, which today deal with building a supply web of data and processes for planning, training, and executing NASA’s future Exploration missions. This would entail an interesting topical mix of influence leadership, operations management, and federal budgeting.

In other words, the future looks very promising for LeadingSpace. I hope you don’t mind that I take you where the wind blows.

Most of all, thank you for reading.

Six Years of Leading Space

2014 in Review

Many thanks to the WordPress.com stats helper monkeys, who prepared a 2014 annual report for Leading Space.  Here’s to a fabulous ’15!

Here’s an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 18,000 times in 2014. If it were a concert at Sydney Opera House, it would take about 7 sold-out performances for that many people to see it.

Click here to see the complete report.

2014 in Review