metachronistic

Sat, 05 Mar 2011

Skating on Goldstream Creek

Nika, overflow

Nika, Goldstream Creek

The last couple days have seen a lot of overflow on Goldstream Creek, causing it to rise more than two feet. The water moved fast enough and it’s been cold enough at night that it froze into a pretty good surface for ice skating. Many years ago we lived in a cabin at the edge of a pond near the railroad tracks and we bought ice skates so we skate on the pond. Turns out the number of days where the pond is frozen and not completely covered by snow is virtually zero, so we rarely got a chance to use them. But here, it seems that at least once or twice a year the overflow on the Creek or the DNR pond east of us will run over the snow and freeze into reasonably smooth ice.

I attempted to shoot a video while ice skating on the Creek today. It’s not the greatest video, but it does give you some idea of what it looks like. After it freezes and before the overflow starts later in the winter, I spend a lot of time walking Nika and Piper down here. During breakup, the water rises to just below the bottom of the bridge, and then recedes to between four and five feet lower than where I’m skating by the middle of summer. The bridge I duck under is where I do my river stage measurements for the National Weather Service.

Tags: , , ,
cswingle @ 18:08:05 -0800

Tue, 01 Mar 2011

Coldest Fairbanks area station

Sunset, Miller Hill

Sunset, Miller Hill

People always ask if we’re the coldest spot in town. I can’t really answer that, but I can find out if we’re the coldest reporting weather station in the region.

Once again, we’ll use PostgreSQL window functions to investigate. The following query finds the station in zone 222 (the National Weather Service region that includes Fairbanks) reporting the coldest temperature every hour during the winter, counts up all the stations that “won,” and then ranks them. The outermost query gets the total number of hourly winners and uses this to calculate the percentage of hours that each station was the coldest reporting station.

Check it out:

SELECT station, count,
    round(count / sum(count) OVER (
        ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
    ) * 100, 1) AS percent
FROM (
    SELECT station, count(*) AS count
    FROM (
        SELECT station, dt_local, temp_f,
            rank() OVER (
                PARTITION BY dt_local ORDER BY temp_f
            )
        FROM (
            SELECT location || ' (' || station_id || ')' AS station,
                date_trunc('HOUR', dt_local) AS dt_local, temp_f
            FROM observations
                INNER JOIN stations USING (station_id)
            WHERE zone_id = 222
                AND dt_local between '2010-10-01' and '2011-03-31'
        ) AS foo
    ) AS bar WHERE bar.rank = 1 GROUP BY station ORDER BY count desc
) AS foobar;

And the results:

                station                 | count | percent
----------------------------------------+-------+---------
 Goldstream Creek (DW1454)              |  2156 |    51.0
 Chena Hot Springs (CNRA2)              |   484 |    11.5
 Eielson Air Force Base (PAEI)          |   463 |    11.0
 Parks Highway, MP 325.4 (NHPA2)        |   282 |     6.7
 Small Arms Range (SRGA2)               |   173 |     4.1
 Ballaine Road (AS115)                  |   153 |     3.6
 Fairbanks Airport (PAFA)               |   125 |     3.0
 Fort Wainwright (PAFB)                 |   107 |     2.5
 Ester Dome (FBSA2)                     |   103 |     2.4
 Eagle Ridge Road (C6333)               |    81 |     1.9
 Keystone Ridge (C5281)                 |    33 |     0.8
 Skyflight Ave (D6992)                  |    21 |     0.5
 14 Mile Chena Hot Springs Road (AP823) |    21 |     0.5
 College Observatory (FAOA2)            |    11 |     0.3
 Geophysical Institute (CRC)            |    10 |     0.2
 DGGS College Road (C6400)              |     1 |     0.0

Answer: Yep. We’re the coldest.

Update: Thinking about this a little bit more, the above analysis is biased against stations that don’t report every hour. Another way to look at this is to calculate the hourly average temperature, subtract this from the data for each station during that hour, and then average those results for the whole winter. The query is made more complex because several stations report temperatures more than once an hour. If we simply averaged all these observations together with the stations that only reported once, these stations would bias the resulting hourly average. So we average each station’s hourly data, then use that to calculate the zone average for the hour. Here’s the query, and the results:

SELECT station,
    round(avg(diff), 1) AS avg_diff
FROM (
    SELECT station,
        dt_local,
        temp_f - avg(temp_f)
            OVER (
                PARTITION BY dt_local
                ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
            ) AS diff
    FROM (
        SELECT location || ' (' || station_id || ')' AS station,
            date_trunc('HOUR', dt_local) AS dt_local,
            avg(temp_f) AS temp_f
        FROM observations
            INNER JOIN stations USING (station_id)
        WHERE zone_id = 222 AND
            dt_local between '2010-10-01' and '2011-03-31'
        GROUP BY station, date_trunc('HOUR', dt_local)
    ) AS foo
) AS bar
GROUP BY station
ORDER BY avg_diff;
                station                 | avg_diff
----------------------------------------+----------
 Goldstream Creek (DW1454)              |     -6.8
 Eielson Air Force Base (PAEI)          |     -3.8
 Fort Wainwright (PAFB)                 |     -3.1
 Fairbanks Airport (PAFA)               |     -2.9
 Small Arms Range (SRGA2)               |     -2.8
 Chena Hot Springs (CNRA2)              |     -2.3
 DGGS College Road (C6400)              |     -0.7
 Ballaine Road (AS115)                  |     -0.6
 College Observatory (FAOA2)            |      1.0
 North Bias Drive (RSQA2)               |      1.3
 14 Mile Chena Hot Springs Road (AP823) |      3.1
 Skyflight Ave (D6992)                  |      3.3
 Geophysical Institute (CRC)            |      3.5
 Eagle Ridge Road (C6333)               |      3.8
 Parks Highway, MP 325.4 (NHPA2)        |      4.5
 Keystone Ridge (C5281)                 |      5.1
 Ester Dome (FBSA2)                     |      5.1
 Birch Hill Recreation Area (BHS)       |      6.8

Tags: , , , ,
cswingle @ 19:47:36 -0800

Sun, 30 Jan 2011

GPS location density map

Location map

Location map

A couple years ago we got iPhones, and one of my favorite apps is the RunKeeper app, which tracks your outdoor activities using the phone’s built-in GPS. When I first started using it I compared the results of the tracks from the phone to a Garmin eTrex, and they were so close that I’ve given up carrying the Garmin. The fact that the phone is always with me, makes keeping track of all my walks with Nika, and trips to work on my bicycle or skis pretty easy. Just like having a camera with you all the time means you capture a lot more images of daily life, having a GPS with you means you have the opportunity to keep much better track of where you go.

RunKeeper records locations on your phone and transfers the data to the RunKeeper web site when you get home (or during your trip if you’ve got a good enough cell signal). Once on the web site, you can look at the tracks on a Google map, and RunKeeper generates all kinds of statistics on your travels. You can also download the data as GPX files, which is what I’m working with here.

The GPX files are processed by a Python script that inserts each point into a spatially-enabled PostgreSQL database (PostGIS), and ties it to a track.

Summary views allow me to generate statistics like this, a summary of all my travels in 2010:

Type Miles Hours Speed
Bicycling 538.68 39.17 13.74
Hiking 211.81 92.84 2.29
Skiing 3.17 0.95 3.34

Another cool thing I can do is use R to generate a map showing where I’ve spent the most time. That’s what’s shown in the image on the right. If you’re familiar at all with the west side of the Goldstream Valley, you’ll be able to identify the roads, Creek, and trails I’ve been on in the last two years. The scale bar is the number of GPS coordinates fell within that grid, and you can get a sense of where I’ve travelled most. I’m just starting to learn what R can do with spatial data, so this is a pretty crude “analysis,” but here’s how I did it (in R):

library(RPostgreSQL)
library(spatstat)
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, dbname="new_gps", host="nsyn")
points <- dbGetQuery(con,
    "SELECT type,
        ST_X(ST_Transform(the_geom, 32606)) AS x,
        ST_Y(ST_Transform(the_geom, 32606)) AS y
     FROM points
        INNER JOIN tracks USING (track_id)
        INNER JOIN types USING (type_id)
     WHERE ST_Y(the_geom) > 60 AND ST_X(the_geom) > -148;"
)
points_ppp <- ppp(points$x, points$y, c(min(points$x), max(points$x)), c(min(points$y), max(points$y)))
Lab.palette <- colorRampPalette(c("blue", "magenta", "red", "yellow", "white"), bias=2, space="Lab")
spatstat.options(npixel = c(500, 500))
map <- pixellate(points_ppp)
png("loc_map.png", width = 700, height = 600)
image(map, col = Lab.palette(256), main = "Gridded location counts")
dev.off()

Here’s a similar map showing just my walks with Nika and Piper:

Hiking trips

Walks with Nika and Piper

And here's something similar using ggplot2:

library(ggplot2)
m <- ggplot(data = points, aes(x = x, y = y)) + stat_density2d(geom = "tile", aes(fill = ..density..), contour = FALSE)
m + scale_fill_gradient2(low = "white", mid = "blue", high = "red", midpoint = 5e-07)

I trimmed off the legend and axis labels:

ggplot2 density map

ggplot2, geom_density2d

Tags: , , , ,
cswingle @ 10:52:40 -0800

Sat, 29 Jan 2011

On Chesil Beach, Ian McEwan

Deuce, On Chesil Beach

Deuce, On Chesil Beach

I’ve read a lot of Ian McEwan over the years, and it’s impressive how different his stories are, and how precise and well written they are. On Chesil Beach is a horror of a story where a single moment is fully visualized and expertly drawn, and when it, ahem, comes, you know that things will never be the same for the characters. I guess this is McEwan’s expertise: visualizing characters suddenly drawn into situations so far from their expectation that you never quite know how they will react.

In this case, one wonders if the outcome of the story would be different if the time or place were different? I should hope that a more modern sensibility, more open dialog about intimacy, perhaps even premarital sexual investigation, would prevent the sort of misunderstanding that’s at the center of this book.

Anyway, I enjoyed it, but I wasn’t as blown away as many of the reviewers were. I do like, oddly enough, what People magazine wrote about the book:

No one can unpack a single frozen moment better than McEwan.

Very true.

Tags: ,
cswingle @ 22:53:02 -0800

Genesee Beer

Genesee Beer

Genesee Beer

Most Fridays we get take out from our local Thai restaurant, Lemongrass, and sometimes we stop at a convenience store on the way to see if there are any interesting or new beers (and sometimes wine) available. Yesterday I saw one of these, a 24-ounce can of Genesee Beer. A couple years ago I found a six-pack of Genesee Cream Ale at Goldhill Liquor, but I haven’t seen straight-up Genesee since I left Rochester a couple decades ago. Needless to say, I bought it, and am now very much enjoying the refreshing, light taste, with just a bit more than a hint of corn in the flavor.

My favorite homebrew, Piper’s Irish-American Red Ale also has this subtle corn flavor. Corn (and later, rice) have a distinct place in American brewing history because it was a way to reduce the excess protein found in the 6-row barley that grew well in North America. By contrast, the traditional European brewing grain, 2-row barley, only has enough enzymes (protein) to convert it’s own starches to sugars, so there wasn’t a problem with excess protein in the final beer. With 6-row grain, there are enough enzymes to convert additional brewing adjuncts like corn, reducing the protein content in the final beer (and also, incidentally, making the beer cheaper to produce).

Genesee Brewing has been in continuous operation (except for during Prohibition, of course) in Rochester, New York since 1878, and is still an independently owned brewery that’s part of the North American Breweries name (along with Labatts, Pyramid, MacTarnahan’s and a few other small breweries). If you’re going to drink an American light lager, it might as well be a good one like Genesee instead of the mega-industry, foreign-owned, over-commercialized swill like Budweiser, Coors, Miller, etc.

Tags: , ,
cswingle @ 18:47:45 -0800

Staying warm

Cold cabin

Cold cabin

Ever since I finished renovating the new cabin, we’ve been keeping it warm in the hope that we’ll find a renter for it. But once we passed the start of the semester at UAF, we essentially gave up looking and have been waiting out the winter to try renting it again. The place is heated by a oil-burning Toyotomi direct vent heater that was only a few months old when we bought the place because the previous heater had been stolen. In our house and the red cabin, we use a similar heater called a Monitor. In Fairbanks, “monitor” is the word people use to describe this style of direct vent heater. Unfortunately, MPI was purchased by Toyotomi and the line has been discontinued.

I’ve been trying to check on the new cabin every day, but I didn’t go over there on Thursday and when Nika and I went over there yesterday, the Toyo had quit working (WTF!?). I’d previously checked it around 4 PM on Wednesday, and finally got the heat back on at around 5 PM on Friday. It was 16°F in the cabin at that point. Over the course of those two days and one hour, the average outside temperature was -3.9°F. The cabin was 60°F when I left it on Wednesday, so it lost just under one degree per hour (although the heat loss is a function of the difference between internal and external temperature, so the heat loss isn’t linear). At that rate, it probably would have been above freezing if I’d checked on it on Thursday.

So mistake number one was not checking it every day. The heater had been so reliable thus far this winter that I got complacent.

Crawlspace icicle

Crawlspace icicle

Guess what mistake number two was? Thankfully I’d shut off the pump before closing the place up in fall, but there’s still at least 100 gallons of water in the tank in the bathroom, and water sitting in the pipes, pump and on-demand water heater. I went over there this morning to see if any of the pipes were cracked and if there was any water anywhere.

Initially there was no sign of damage except for a little water underneath the pump. After looking under the house (see the photo on the right), it’s clear that there’s a leak somewhere near the pump, and all the pressure left in the pressure tank pumped a few gallons of water onto the floor, where it found a way to get through the vinyl floor, the new subfloor I installed this summer, and down into the structure and eventually out the bottom of the cabin.

After fiddling with opening faucets, I eventually hit on some combination of open valves that released a vacuum near the hot water heater, and water started pouring out, so there’s a leak somewhere in the hot water heater as well as near or inside the pump. Later in the day I went back with an air compressor and forced air into the hot and cold water lines, opening and closing different faucets until I forced all the water out of the pipes.

Lessons learned: check on the heat every day, and if there won’t be anyone in there, make sure to blow out all the water lines. In spring I’ll be replacing the hot water heater and probably the pump. Hopefully the pressure tank and the washing machine weren’t damaged, but at least I don’t need to replace the water lines or the water tank.

Tags: , , ,
cswingle @ 15:27:03 -0800

Montana 1948, Larry Watson

Caslon and Montana 1948

Caslon and Montana 1948

Montana 1948 is a book published by Milkweed Editions, a non-profit press that attempts to “nurture and publish transformative literature.” I’m not sure what that means, but this is the second Milkweed National Fiction Award winner that I’ve read (The Farther Shore by Matthew Eck is the other). It’s a short little book told from the first person perspective of an adult recounting events that happened when he was twelve. It’s a simple story about family, small towns, and how each of the characters react to acts of violence against Native Americans in their community.

The main character maintains some distance from the events that take place—“I felt a contentment outside human society that I couldn’t feel within it.”—and so he allows the reader to draw their own conclusions about what drives the other characters to do what they do. The author is very good at evoking the feel of the time and place of the story. An enjoyable read.

It’s a good looking book too, with a slightly shorter and wider page size than is typical, and a nice thick shiny cover. It’s typeset in Perpetua, which is a font I like, but I felt like the italics were too small for the body text (see the image below). I’m not sure how this would happen unless it’s an intentional feature of the font set. It looked funny to me.

Perpetua, small italics

Tags: ,
cswingle @ 14:37:07 -0800

Sun, 23 Jan 2011

The Bad Girl, Mario Vargas Llosa

Koidern, The Bad Girl

Koidern and The Bad Girl

Finished Mario Vargas Llosa’s The Bad Girl this morning. This is apparently a rewrite of Flaubert’s Madame Bovary. Never having read Flaubert, I wouldn’t have recognized the similarities, but I doubt if I’d enjoy that book as much as The Bad Girl. Lydia Davis just re-translated it into English (“the English translation it deserves”, according to Kathryn Harrison in the New York Times), so maybe it’s worth a read.

The book is written from the first-person perspective of Ricardo Somocurcio, covering his entire life. As the bad girl disappears and reappears, she throws his life into chaos, ecstasy, and ruin each time. He’s unable to overcome his love for her, regardless of the depths she plumbs in her quest to make a life for herself and escape the poverty of her family. It isn’t the most compelling plot, but Somocurcio tells a very entertaining tale, and anyone who has experienced the ways that love defeats reason will understand what he goes through. It’s also something of a guilty pleasure to witness how the bad girl uses her power over Somocurcio (and the other men she exploits) to get what she wants, and observe the train wreck when she moves on.

I only highlighted one line in the book. I don’t think it characterizes the message of the book, but perhaps one of them: “In this life things rarely happen the way we little pissants plan them.” I wonder what word was actually used in the Spanish original, and translated into pissant here?

Good book. I’ll be reading more Vargas Llosa in the future, starting with The War of the End of the World, which is considered to be his best novel.

Tags: ,
cswingle @ 12:22:10 -0800

Wed, 19 Jan 2011

Power consumption, TED

Device Watts
Time capsule 12
MacBook Pro 26
Linux server 20
Refrigerator 42
46″ LCD TV 50
Arctic entryway ventilation fan 50
Circulating pump 62
Boot driers 71
Sewage treatment plant 350
Jeep heaters 640
Dakota heaters 650
Water pump 1,240
Bedroom heater 1,500

A little over a year ago we bought a whole house energy monitor (The Energy Detective (T.E.D)). It’s got a pair of clamping ammeters that measure the current going through the main power leads inside the breaker panel in our house. This information is transmitted to a small console that we’ve got in the living room, as well as a unit that is connected to our wireless router and displays a web page with the data. I wrote a script that reads this data every minute and stores it in a database. It can also send the data to Google Power if you’re not interested in storing the data yourself.

The console that comes with it runs on rechargeable batteries charged by the cradle it sits in. That means that you can take the console with you to see how much electricity various devices in the house consume. You just watch the display, turn on whatever it is you want to measure, and within a second or two, you can see the wattage increase on the display. We’ve measured the power that the major devices around our house consume, shown in the table on the right.

The lights aren’t in the table. Much of the downstairs is lit with R40 bulbs in ceiling cans, in which we’ve placed 23 Watt CFLs. The most common lighting pattern in the winter is to have the four lights in the kitchen and the single can above the couch on, which is just under 100 Watts. We also have six motion sensing lights, four in the dog yard and one on the shed. Four of these are CFL bulbs (around 20 Watts), and two are outdoor floods (70 Watts). When the dogs are outside in the dark, we’re typically using around 180 Watts to light the dog yard, and the motion sensors also consume some energy even when the bulbs aren’t lit.

Of the devices in the table, we’re always running the sewage treatment plant, the time capsule and the Linux server (around 380 Watts). In winter the circulating pump is running all the time keeping the water and septic lines thawed and we use lights and various other heaters quite a bit more.

Here’s a series of boxplots showing the distribution of our power consumption, by month, for the last year:

Power consumption by month

Box and whisker plots show the distribution of a dataset without making any assumptions about the statistical distribution of the data. The box shows the range over which half the points fall (the inter-quartile distance, or IQD), and the horizontal line through the box is the median of the data. For example, in November, over half our power usage falls between about 480 and 750 Watts, with the median consumption just over 500 Watts. If that were the average, we’d use 12 KWHours / day (500 Watts * 24 hours / 1000 Watts/KWatt). The blue vertical lines extending from the boxes (the whiskers) indicate the spread of the majority of the rest of the points. The actual length of these is a somewhat arbitrary 1.5 times the IQD and provides a view of how variable the data is above and below the median. In the case of power consumption, you can tell that the distribution of the points is heavily skewed toward lower consumption values, but that there is a long tail toward higher consumption values. This makes sense when you realize that we’re almost never going to be using less than 380 Watts, but if it’s the dead of winter, our cars are plugged in and the water pump and refrigerator are on, we’ll get a very high spike in our usage. The orange points that extend beyond the whiskers are the actual data values that were outside of the box and whiskers. Again, for this data, we’ve got a lot of these “outliers” because those exceptionally high draw events happen all the time, just not for very long.

Cumulative frequency / density plot

Another way to look at the data is to divide it into summer and winter, and examine the kernel density and cumulative frequency distribution of the data. In this case, the dependent variable (power consumption) is on the x-axis, and we’re looking at how often we’re using that amount of electricity. Looking at the winter density data (the red, solid curve on the left), you can see that there’s a peak just under 500 Watts where most of our usage is, but there’s also smaller peaks around 1,200 Watts and 1,800 Watts. These are probably spikes due to plugging in the vehicle heaters in the morning before we go to work (480 baseline + 640 + 650 = 1,770). The 1,200 Watt peak may be due to just having one vehicle plugged in, or due to the combination of other heaters and the lights being turned on. In summer, there’s a big spike around 350 and a secondary spike around 400. I’m not sure what that cause of that pair of peaks is, but if you look at the monthly density plots, it’s a common pattern for all the summer months. My guess is it’s the baseline sewage treatment plant, plus turning on the lights in the evening. But there aren’t really any other peaks after the distribution drops to close to zero after 1,000 Watts.

The blue line is the cumulative frequency distribution, and it can tell you what percentage of the data points occur on either side of a particular usage value. For example, if you read horizontally across the winter plot from the 0.5 (50%) mark, this intersects the blue line at just over 500 Watts. That means that half of the time, we’re using more than 500 Watts, and half the time we’re using less. The difference between summer and winter is really clear when you look at the cumulative frequency: in summer 95% of our electricity usage is below 750 Watts, but in winter 20% of our usage is above that value.

There’s still a lot more that could be done with all this data. At some point I’d like to relate our usage to other data such as the outside temperature, and I know there are statistical techniques that could help pull apart the total consumption data into it’s individual pieces. For example, as I look at the console right now it’s showing 697 Watts. I know that the sewage treatment plant, stereo, time machine, Linux server, and my laptop are all on. When the ventilation fan goes on, the signal will jump by that amount, and remain at that level until it goes off. Given enough data, these individual, incremental changes in the total consumption should reveal themselves (assuming I actually knew what the technique was, and how to perform the analysis…).

What does all this data really mean? Well, I’m not entirely sure. The idea behind these devices is that they will cause people to use less electricity because they’re getting instant feedback on how what they’re doing affects their usage. The problem is that we’ve already done almost everything what we can do to reduce our usage. Even so, it’s nice to see what’s happening, and a sudden, unexplained spike on the console can let us know when something is on that shouldn’t be.

Tags: , ,
cswingle @ 13:24:41 -0800

Sun, 16 Jan 2011

Faithful Place, Tana French

Cats on the cat tree

Tallys, Jenson and Caslon on the cat tree

Thus far in 2011 I’ve read three books. I finished Paul Auster’s Invisible, and read Girl Factory by Jim Krusoe on New Year’s Day. I read a few raves of the Auster book, and I’d put it in a very long list of his better books. Maybe not in the top five, but one not to miss if you like his writing. Girl Factory was excellent. After I finished it, I wrote to myself: “Highly entertaining, and the main character had a great voice. New favorite book of 2011, one day into it.” Two weeks later and I’ll stick to that opinion.

The book I just finished, while watching the Bears thrash the Seahawks, was Tana French’s Faithful Place. I can’t remember why I picked it up, but I probably should have known by the style of the dust jacket that it wouldn’t be quite my taste. It’s in the crime genre, and was a little too filled with the stock and trade of that category for me. Even so, the characters are spectacularly well fleshed out, and the sense of place was great. I don’t know anything about the lower class rowhouses of Dublin where the action takes place, but I had no trouble filling the blanks from her detailed descriptions.

Anyway, it wasn’t really my thing, but if you enjoy literate crime fiction, this is a book I can recommend.

Tags: , , ,
cswingle @ 13:50:14 -0800
« Previous PageNext Page »

Back to Swingley Development
Powered by WordPress

Switch to our mobile site