metachronistic

Sun, 31 Jan 2010

Kittens roam

Utility area doors

Utility area doors

We’ve been wanting to let the kittens into the rest of the house for several weeks now, but when we got close to letting them downstairs we realized they could get into all sorts of trouble in the utility area in the bathroom where the water heater, pump, and washing machine are. Worse, if they got in there, they could climb around behind the shower and tub surround and we’d have no way of getting them out.

So I built the doors you can see in the photo. They’re made from clear pine. I’d originally planned on using “pocket-screw technology,” on the doors, but when driving the pocket screws from the back of the rails into the styles, they cracked the styles. I wound up using glue and dowels instead, and they seem solid. I was a little worried because the doors were so large, but they’re flat and slide easily in the tracks I made.

The image looks a little warped because it’s a series of photos that are joined together using the AutoStitch iPhone app. It’s a pretty good alternative when you don’t have a wide angle lens.

Today was the first day the kittens came downstairs (except once when Jenson escaped), and things seemed to go well. Nika and Piper have been spending nights with all of us, so they’re used to the kittens. Buddy and Deuce mostly seemed afraid. Koidern and Kiva were both very interested, and spent the whole time cautiously following the kittens around. After an hour or so we put the kittens back upstairs to let everyone relax. I opened up the gates again this afternoon and captured this video of Kiva’s interaction with Tallys (and a little of Jenson). Tallys is the one rolling around on the floor in front of the heater, seemingly trying to play with Kiva’s feet.

The music (which was playing on the stereo as I recorded the video on my iPhone) is from Four Tet’s latest record.

Tags: , , , ,
cswingle @ 17:41:38 -0800

A’s 2010 Roster heatmap

I recently saw a pair of blog posts showing how to make heatmaps with straight R and with ggplot2. Basketball doesn’t really interest me, so I figured I’d attempt to do the same thing for the 2010 Oakland Athletics 40-man roster. Results are at the bottom of the post.

First, I needed to get the 40-man roster:

$ w3m -dump "http://oakland.athletics.mlb.com/team/roster_40man.jsp?c_id=oak" > 40man

Then trim it down so it’s just a listing of the player’s names.

Next, get the baseball data bank (BDB) database from http://baseball-databank.org/, convert and insert it into a PostgreSQL database using mysql2pgsql.perl.

A Python script reads the names from the roster, and dumps a CSV file of the batting and pitching data for the past two seasons for the players passed in.

$ cat 40man_names | ./get_two-year_batter_stats.py

The batting data looks like this:

            name  , age,   g,    ba,   obp,   slg,   ops,  rc,   hrr,    kr,   bbr
Daric Barton (1B) ,  25, 194, 0.238, 0.342, 0.365, 0.707,  73, 0.017, 0.173, 0.134
Travis Buck (RF)  ,  27,  74, 0.223, 0.289, 0.392, 0.682,  28, 0.035, 0.202, 0.073
Chris Carter (LF) ,  28,  13, 0.261, 0.320, 0.261, 0.581,   1, 0.000, 0.360, 0.080
...

I’ve used the counting stats in the BDB to calculate batting average (ba), on-base percentage (obp), slugging percentage (slg), OPS (on-base percentage + slugging percentage), runs created (rc), home run rate (hrr), strikeout rate (kr) and walks rate (bbr).

And the pitching data:

            name   , age,  g,      ip,  w, l,    sv,    wp,    lp,    wf,   era,    k9,   bb9,   hr9
Brett Anderson (P) ,  22,  30, 175.33, 11,  11,   0,  0.37,  0.37,  0.00,  4.06,  7.70,  2.36,  1.03
Andrew Bailey (P)  ,  26,  68,  83.33,  6,   3,  26,  0.09,  0.04,  0.04,  1.84,  9.83,  2.92,  0.54
Jerry Blevins (P)  ,  27,  56,  60.00,  1,   3,   0,  0.02,  0.05, -0.04,  3.75,  8.70,  3.30,  0.60
...

Here I’ve calculated innings pitched (ip), winning percentage (wp), losing percentage (lp), win frequency (wf), earned run average (era), strikeouts per nine innings (k9), walks per nine (bb9), and home runs given up per nine innings (hr9). All these stats are for the last two Major League seasons.

Finally, generate the heat maps in R. For batting statistics:

library(ggplot2)
mlb <- read.csv('batting.csv')
mlb$name <- with(mlb, reorder(name, ops))
mlb.m <- melt(mlb)
mlb.m <- ddply(mlb.m, .(variable), transform, rescale = rescale(value))
(p <- ggplot(mlb.m, aes(variable, name)) +
+   geom_tile(aes(fill = rescale), colour = "white") +
+   scale_fill_gradient(low = "gold", high = "darkgreen"))
base_size <- 14
p + theme_grey(base_size = base_size) + labs(x = "", y = "") +
+   scale_x_discrete(expand = c(0, 0)) + scale_y_discrete(expand = c(0, 0)) +
+   opts(legend.position = "none", axis.ticks = theme_blank(),
+   axis.text.x = theme_text(size = base_size * 0.8, angle = 0, hjust = 0.5, colour = "black"),
+   axis.text.y = theme_text(size = base_size * 0.8, lineheight = 0.9, colour="black", hjust = 1))
    

Pitching statistics are the same, except the third line (where I order the data frame) is:

mlb$name <- with(mlb, reorder(name, 1/(era+0.1)))
    

The results:

A’s batting heatmap, ordered by OPS

A’s pitching heatmap, ordered by ERA

You have to keep the number of games (or innings pitched for pitchers) in mind when you look at these charts. I don’t even know who some of those guys are, probably because they’ve only barely played in the majors. It might make some sense to split the pitching plot into plots for starters and relievers, but I’d need a good way to determine a pitcher’s status (innings pitched divided by games beyond some threshold, perhaps?).

As for the A’s, I like their pitching, but have serious doubts about their offense. I sure hope some of the younger guys on this chart start reaching their power potential because having Jack Cust as your only offensive weapon doesn’t bode well for the team scoring runs.

Tags: , , , ,
cswingle @ 14:40:21 -0800

Mon, 23 Nov 2009

Tallys, Jenson & Caslon

Three kitties on the railing

Tallys, Jenson and Caslon

Tallys and Jenson on the railing

Tallys and Jenson on the railing


We finally agreed on some names for our kittens: Tallys is the small black kitten, Jenson is gray and white and Caslon is the larger of the two black boys. They’re all serif fonts, as Andrea says, “because they’ve got tails!” We struggled for a long time with different naming schemes, but both of us really liked Tallys and Jenson as names, and once we’d gotten those two it was just a question of finding a third font that was appropriate. Caslon is one of my favorite fonts (it’s the typeface used for the body text in The New Yorker), and I think it fits well with the other two.

The kittens are still living in the bedroom but this weekend I fenced in the area at the top of the stairs and came up with a setup that should allow us to leave the bedroom door open and give them a little more room. This way we can slowly expand their range upstairs by opening the doors to the other rooms before letting them downstairs. There’s always a chance they will figure a way around my cat-catchers, or that they’ll jump off the balcony railing, but so far we’re only letting them out when we’re home so we can keep an eye out. The biggest problem with this plan is that the dogs can see the kittens at the top of the stairs and as a result, they’re staring and whining at them. Hopefully this behavior will stop in the near future.

Jenson on the railing

Jenson

Caslon sleeping on the railing

Caslon sleeping


Tags: , , , ,
cswingle @ 17:54:25 -0800

Sat, 07 Nov 2009

Sleep and play

Sleeping on me

Sleeping on me

In the last day or two the kittens have gotten more snuggly in between bursts of activity. Last night all three slept with us; one up next to Andrea and the other two between us on the bed. Then, after this morning’s playtime I laid down on the bed to watch This Old House and all three kittens came up and crashed all over me. Gray-white and Black-black were zonked but little Gray-black was still playful and kept jumping between snoozing kittens trying to entice a battle. Eventually all three (Java, Python, and C?) dropped to sleep and I managed to get the photo on the right.

Monitoring dog-kitten interactions at night is still keeping us from getting a good night’s sleep, but I think we’re making gradual progress. Nika has made her peace with the situation and just tries to stay out of the way. Piper is very playful and interested in as much interaction as they’ll let her, but she still moves too fast and they’re not letting her get very close. I think it will take time for the kittens to relax and realize that Piper is just curious.

The video was shot a couple days ago, and it’s nothing more than a trio of kittens warping all over the bedroom for almost four minutes. My main intent was to capture my favorite ninja kitten move: when two charge straight at each other, and just before colliding they jump straight up in the air and start battling as they fall back to the ground. I think I got at least one airborne wresting match in this video (at around 1:28).

Tags: ,
cswingle @ 13:16:39 -0800

Thu, 05 Nov 2009

Kitten progress

Wassat?

BB, GW

We’re making progress integrating the kittens into our lives. They’re still living in our bedroom and are getting more comfortable with their surroundings. Last night we had Piper and Nika sleep in the room with us, and things went as well as could be expected. The kittens slept until around 3 AM, and the bravest of the bunch (black-black) came out and asserted his position to Piper. Piper did really well, but after about a half an hour of kitty spitting, hissing and swatting, we decided to give both species a break and I went downstairs and slept on the couch with the dogs. Nika doesn’t appear to want anything to do with the little guys, and Piper’s interest appears to be simple curiosity. We haven’t seen any aggressive behaviors or chasing, but so far the interactions have been pretty minimal.

We haven’t come up with any names yet, so we’re calling them by their colorations. The top photo shows “black-black” and “gray-white,” and the third kitten is “gray-black.” Andrea asked her Facebook friends for names and we’ve gotten a lot of suggestions. My favorite so far is Sam, Merry and Pippin, but even that combination doesn’t seem quite right. Andrea came up with Ash, Soot and Coal, which would be perfect for their colorations, but I’m not crazy about naming a cat after a fossil fuel. Font names are also a possibility, but no one would know what they mean. Characters from The Wire and names based on sports teams have been briefly considered. Part of the problem is that we’re friends with a lot of dog mushers, and that means that almost any name or naming scheme has been used and is associated with a dog or litter. If there wasn’t an Alaskan plant litter in Bonnie’s yard, those would have been great names (Ledum, Salix, etc.). So we’re still working on it.

Favorite sleeping spot

Favorite sleeping spot

Black-black is very brave and was the first one out to challenge Piper (and attack her wagging tail), followed by gray-white. The two of them spend most of their play time chasing each other around the room, battling. Gray-black is quite a bit thinner than the other two and is very skittish even with his brothers. He’s also the best climber, and is the only one who has shown any interest in snuggling with us. We’ve gotten all three to purr, but while they’re awake, they seem much more interested in racing around, jumping about, and climbing all over everything than cuddling with us.

They like to sleep in the bottom drawer of an armoire in the corner (photo left). When they first came into the room, they managed to squeeze under the decorative trim on the bottom of the cabinet (my last post showed grey-white coming out from there), and from there climbed up the backs of the drawers. We eventually removed the second drawer because it was hard to know in which drawer you might find a kitten, and we were afraid of accidentally injuring one opening the drawers. The open space also allows them to get in without going underneath, something they won’t be able to do much longer.

Tags: ,
cswingle @ 10:43:58 -0800

Tue, 03 Nov 2009

Kitties!

Oh hai!

Oh hai!

After more than two years, we are finally cat owners again. A veterinarian friend of ours knew someone fostering a pregnant cat for the local animal shelter, and after a few visits with Mom and the kittens, eight weeks, and a major hassle with the shelter, we got three male kittens. There are two black kittens and one grey and white one. They’re hanging out in the bedroom while we work on re-introducing all the dogs to cats (and the kittens to dogs).

We haven’t come up with names yet, mostly because we were afraid to name animals that the shelter might have given to someone else. We’d like to come up with a naming scheme (Soot, Ash, and Coal were one set under consideration; Taiga, Tundra, and some unidentified Alaska ecotype were another), but nothing has really hit the mark.

Expect many, many blog posts with sickeningly cute kitten photos.

Escape from armoire

Escape from under the dresser

Tags: ,
cswingle @ 19:26:16 -0800

Tue, 27 Oct 2009

Snow!

Snow on the road

Snow on the road

We got 2 inches of snow yesterday (October 26th), so the wait is finally over.

I made the mistake of riding my bicycle to work yesterday, as the snow was falling. It wasn’t too bad on my way in to work, but by the time I left, more than an inch of snow had fallen and the roads hadn’t been plowed. I do have studded, knobby tires on my bicycle, but they’re don’t work very well in situations where the snow is deeper than the tread. I managed to stay upright the whole way home, but it was some white-knuckle, one-wheel drive bicycling.

Note: Yesterday’s first real snowfall was the 8th latest in the 62 year historical record I have access to for the Fairbanks airport station. I’m not sure where the statistics reported in Tuesday’s newspaper came from.

Tags: , , ,
cswingle @ 6:18:39 -0800

Fri, 23 Oct 2009

First snowfall: the final word?

DNR pond

frozen DNR pond

It’s been almost a month since I last discussed the first true snowfall date (when the snow that falls stays on the ground for the entire winter) in Fairbanks, and we’re still without snow on the ground. It hasn’t been that cold yet, but the average temperature is enough below freezing that the local ponds have started freezing. Without snow, there’s a lot of ice skating going on around town. I’m hoping to head out this weekend and do some skating on the pond in the photo above. Still, most folks in Fairbanks are hoping for snow.

Since my last post, I’ve gotten access to data from the National Climate Data Center, and have been working on getting it all processed into a database. I’ve worked out a procedure for processing the daily COOP data, which means I can repeat my earlier snow depth analysis with a longer (and more consistent) data set. The following figure shows the same basic analysis as in my previous post, but now I’ve got data from 1948 to 2008.

Snow depth histogram

The latest date for the first true snowfall was November 11th, 1962, and we’re almost three weeks away from that date. But we’re also on the right side of the distribution—the mean (and median) date is October 14th, and we’re 9 days past that with no significant snow in the forecast. I’ve also marked the earliest (September 13th, 1992) and latest (November 1st, 1997) first snowfall dates in recent history. 1992 was the year the snow fell while the leaves were still on the trees, causing major power outages and a lot of damage. I think 1997 was the year that we didn’t get much snow at all, which caused a lot of problems for water and septic lines buried in the ground. A deep snowpack provides a good insulating layer that keeps buried water lines from freezing and in 1997 a lot of things froze.


Great Horned Owl

Great Horned Owl, digi-scoped with my iPhone

This is also the time of the year when some of the winter birds start making themselves less scarce. We saw our first Pine Grosbeaks of the year, three days later than last year’s first observation, a Northern Goshawk flew over a couple weeks ago, and we got some great views of this Great Horned Owl on Saturday. Andrea took some spectacular photos with her digital camera, and I experimented with my iPhone and the scope we bought in Homer this year. It’s quite a challenge to get the tiny iPhone lens properly oriented with the eyepiece image in the scope, but the photos are pretty impressive when you get it all set up. Even a pretty wimpy camera becomes powerful when looking through a nice scope.

Winter is on it’s way, just a bit late this year. I’ve been taking advantage by riding my bike to work fairly often. Earlier in the week I replaced my normal tires with carbide-studded tires, so I’ll be ready when the ice and snow finally comes.

Tags: , , , , ,
cswingle @ 17:22:35 -0800

Fri, 25 Sep 2009

First “true” snowfall

Piper and Nika on the Creek

Piper and Nika on the Creek, Feb 2009

On Wednesday I reported the results of my analysis examining the average date of first snow recorded at the Fairbanks Airport weather station. It was based on the snow_flag boolean field in the ISD database. In that post I mentioned that examining snow depth data might show the date on which permanent snow (snow that lasts all winter) first falls in Fairbanks. I’m calling this the first “true” snowfall of the season.

For this analysis I looked at the snow depth field in the ISD database for the Fairbanks station. The data was present for the years between 1973 and 1999, but isn’t in the database before that date. I’m not sure why it’s not in there after 1999, but luckily I’ve been collecting and archiving the data in the Fairbanks Daily Climate Summary (which includes a snow depth measurement) since late 2000. Combining those two data sets, I’ve got data for 27 years.

The SQL query I came up with to get the data from the data sets is a good estimate of what we’re interested in, but isn’t perfect because it only finds the date of first snow that lasts at least a week. In a place like Fairbanks where the turn to winter is so rapid and so dependent on the high albedo of snow cover, I think it’s close enough to the truth. Unfortunately, the query is brutally slow because it involves six (!) inner self-joins. The idea is to join the table containing snow depth data against itself, incrementing the date by one day at each join. The result set before the WHERE statement is the data for each date, plus the data for the six days following that date. The WHERE clause requires that snow depth on all those seven dates is above zero. This large query is a subquery of the main query which selects the earliest date found in each year.

There must be a better way to deal with conditions like this where we’re interested in the consecutive nature of the phenomenon, but I couldn’t figure out any other way to handle it in SQL, so here it is:

SELECT year, min(date) FROM
    (
        SELECT extract(year from a.dt) AS year,
            to_char(extract(month from a.dt), '00') ||
                '-' ||
                ltrim(to_char(extract(day from a.dt), '00')) AS date
        FROM isd_daily AS a
            INNER JOIN isd_daily AS b
                ON a.isd_id=b.isd_id AND
                    a.dt=b.dt - interval '1 day'
            INNER JOIN isd_daily AS c
                ON a.isd_id=c.isd_id AND
                    a.dt=c.dt - interval '2 days'
            INNER JOIN isd_daily AS d
                ON a.isd_id=d.isd_id AND
                    a.dt=d.dt - interval '3 day'
            INNER JOIN isd_daily AS e
                ON a.isd_id=e.isd_id AND
                    a.dt=e.dt - interval '4 day'
            INNER JOIN isd_daily AS f
                ON a.isd_id=f.isd_id AND
                    a.dt=f.dt - interval '5 day'
            INNER JOIN isd_daily AS g
                ON a.isd_id=g.isd_id AND
                    a.dt=g.dt - interval '6 day'
        WHERE a.isd_id = '702610-26411' AND
            a.snow_depth > 0 AND
            b.snow_depth > 0 AND
            c.snow_depth > 0 AND
            d.snow_depth > 0 AND
            e.snow_depth > 0 AND
            f.snow_depth > 0 AND
            g.snow_depth > 0 AND
            extract(month from a.dt) > 7
    ) AS snow_depth_conseq
GROUP BY year
ORDER BY year;

See what I mean? It’s pretty ugly. Running the result through the same R script as in my previous snowfall post yields this plot:

First true snowfall histogram

Between 1973 and 2008 we’ve gotten snow lasting the whole winter starting as early as September 12th (that was the infamous 1992), and as late as the first of November (1976). The median date is October 13th, which matches my impression. Now that the leaves have largely fallen off the trees, I’m hoping we get our first true snowfall on the early end of the distribution. We’ve still got a few things to take care of (a couple new dog houses, insulating the repaired septic line, etc.), but once those are done, I’m ready for the Creek to freeze and snow to blanket the trails.

Tags: , , , ,
cswingle @ 18:21:58 -0800

Wed, 23 Sep 2009

Sky

Sky

Sky

Tags: , , ,
cswingle @ 19:01:10 -0800
Next Page »

Back to Swingley Development
Powered by WordPress