Shallow Thoughts : : Apr

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Wed, 13 Apr 2005

PyTopo 0.3

I needed to print some maps for one of my geology class field trips, so I added a "save current map" key to PyTopo (which saves to .gif, and then I print it with gimp-print). It calls montage from Image Magick.

Get yer PyTopo 0.3 here.

Tags: , , ,
[ 17:56 Apr 13, 2005    More programming | permalink to this entry | ]

Tue, 12 Apr 2005

New Debian Font Weirdness

A recent change to the Debian font system has caused some odd font problems which Debian users might do well to know about.

The change has to do with the addition in /etc/fonts of a directory conf.d containing symbolic links to scripts, and the overwriting of some of the existing files in /etc/fonts.

The symptoms are varied and peculiar. On my sid system, on each boot, the system would toggle between two different font resolutions. I'd start xchat, and the fonts would be too teeny to read; so I'd call up the preferences dialog, see the font was at 9, and increase it to 12, at which point I'd see the font I was used to seeing (though the UI font in the tabs would still be teeny). Subsequent runs of xchat would be fine (except for the still-teeny tab fonts). But upon reboot, xchat would come up with the tab font correct and the channel font HUGE. Prefs dialog again: it's still at 12 where I set it last time, so now I reset it to 9, which makes it the right size. Until the next reboot, when everything became teeny again and I have to go back to 12.

The system resolution never changed, nor did the rendering of the bitmapped fonts I use in emacs and terminal clients; only the rendering of freetype scalable fonts changed with each reboot. Back in the days when all fonts were bitmapped, I would have guessed that the font system was alternating between 100dpi fonts and 72dpi fonts.

At a loss as to what might cause this strange behavior, I took a peek into /etc/fonts/conf.d, which Dave had discovered a few weeks ago when he updated his sarge system and all his bitmapped fonts disappeared. Though my problem didn't sound remotely similar to his: my bitmapped fonts were fine, it was the scalable ones which were flaky.

Turns out the symlink I'd aquired in the update, /etc/fonts/conf.d/30-debconf-no-bitmaps.conf, did indeed point to a file called no-bitmaps.conf, just as Dave's had. Just to see what would happen, I removed it, and made a new symlink, 30-debconf-yes-bitmaps.conf, pointing to yes-bitmaps.conf.

Voila! The size-toggling problem disappeared, and, even better, bitmapped fonts like "clean" now show up in gtkfontsel and in gtk font selection dialogs, which they never did before. I can use all my fonts now!

The moral is: if you've updated sarge or sid recently, and see any weirdness at all in fonts, go to /etc/fonts/conf.d and fiddle with the symlinks. Even if it doesn't seem directly related to your problem.

As to why no-bitmaps.conf causes the system to toggle between two different font scalings, that's still a mystery. The only difference between no-bitmaps.conf and yes-bitmaps.conf is that one rejects, and the other accepts, fonts that have "scalable" set to false. Why that would change the scale at which fonts are rendered is beyond me. I'll leave that up to someone who understands the new debian font system. If any such person exists.

Update 5/24/2005: turns out you can change this on a per-user basis too, with ~/.fonts.conf. man fonts.conf for details.

Tags: , ,
[ 22:45 Apr 12, 2005    More linux | permalink to this entry | ]

Sat, 09 Apr 2005

Python Expose vs. Focus

A few days ago, I mentioned my woes regarding Python sending spurious expose events every time the drawing area gains or loses focus.

Since then, I've spoken with several gtk people, and investigated several workarounds, which I'm writing up here for the benefit of anyone else trying to solve this problem.

First, "it's a feature". What's happening is that the default focus in and out handlers for the drawing area (or perhaps its parent class) assume that any widget which gains keyboard focus needs to redraw its entire window (presumably because it's locate-highlighting and therefore changing color everywhere?) to indicate the focus change. Rather than let the widget decide that on its own, the focus handler forces the issue via this expose event. This may be a bad decision, and it doesn't agree with the gtk or pygtk documentation for what an expose event means, but it's been that way for long enough that I'm told it's unlikely to be changed now (people may be depending on the current behavior).

Especially if there are workarounds -- and there are.

I wrote that this happened only in pygtk and not C gtk, but I was wrong. The spurious expose events are only passed if the CAN_FOCUS flag is set. My C gtk test snippet did not need CAN_FOCUS, because the program from which it was taken, pho, already implements the simplest workaround: put the key-press handler on the window, rather than the drawing area. Window apparently does not have the focus/expose misbehavior.

I worry about this approach, though, because if there are any other UI elements in the window which need to respond to key events, they will never get the chance. I'd rather keep the events on the drawing area.

And that becomes possible by overriding the drawing area's default focus in/out handlers. Simply write a no-op handler which returns TRUE, and set it as the handler for both focus-in and focus-out. This is the solution I've taken (and I may change pho to do the same thing, though it's unlikely ever to be a problem in pho).

In C, there's a third workaround: query the default focus handlers, and disconnect() them. That is a little more efficient (you aren't calling your nop routines all the time) but it doesn't seem to be possible from pygtk: pygtk offers disconnect(), but there's no way to locate the default handlers in order to disconnect them.

But there's a fourth workaround which might work even in pygtk: derive a class from drawing area, and set the focus in and out handlers to null. I haven't actually tried this yet, but it may be the best approach for an app big enough that it needs its own UI classes.

One other thing: it was suggested that I should try using AccelGroups for my key bindings, instead of a key-press handler, and then I could even make the bindings user-configurable. Sounded great! AccelGroups turn out to be very easy to use, and a nice feature. But they also turn out to have undocumented limitations on what can and can't be an accelerator. In particular, the arrow keys can't be accelerators; which makes AccelGroup accelerators less than useful for a widget or app that needs to handle user-initiated scrolling or movement. Too bad!

Tags: , , ,
[ 21:52 Apr 09, 2005    More programming | permalink to this entry | ]

Wed, 06 Apr 2005

PyTopo is usable; pygtk is inefficient

While on vacation, I couldn't resist tweaking pytopo so that I could use it to explore some of the areas we were visiting.

It seems fairly usable now. You can scroll around, zoom in and out to change between the two different map series, and get the coordinates of a particular location by clicking. I celebrated by making a page for it, with a silly tux-peering-over-map icon.

One annoyance: it repaints every time it gets a focus in or out, which means, for people like me who use mouse focus, that it repaints twice for each time the mouse moves over the window. This isn't visible, but it would drag the CPU down a bit on a slow machine (which matters since mapping programs are particularly useful on laptops and handhelds).

It turns out this is a pygtk problem: any pygtk drawing area window gets spurious Expose events every time the focus changes (whether or not you've asked to track focus events), and it reports that the whole window needs to be repainted, and doesn't seem to be distinguishable in any way from a real Expose event. The regular gtk libraries (called from C) don't do this, nor do Xlib C programs; only pygtk.

I filed bug 172842 on pygtk; perhaps someone will come up with a workaround, though the couple of pygtk developers I found on #pygtk couldn't think of one (and said I shouldn't worry about it since most people don't use pointer focus ... sigh).

Tags: , , , ,
[ 17:26 Apr 06, 2005    More programming | permalink to this entry | ]

Sun, 03 Apr 2005

Rainbow Basin: the Barstow Syncline

We started the day at Zzyzx, south of Baker. I'd been told that there were lots of geologically interesting things to see there.

If so, we couldn't find them. There's a little cluster of buildings marking the Desert Research Center, but it doesn't seem to be open to casual visitors; rather, they do classes and tours by appointment. Zzyzx abuts the southwest end of Soda Dry Lake, so you can get good views of the dry lakebed (with a little water on it here and there, thanks to the very wet winter) and across it to Mojave Rd and the Kelso Dunes. Worth the 5 mile detour off the freeway? Well, no, not really. But Dave was happy to find a relatively windless place where we could fly model airplanes for a few minutes.

Fortunately, Zzyxz wasn't the target of the day; that honor fell to Rainbow Basin, a few miles north of Barstow on the road to Fort Irwin. We'd actually tried to go to Rainbow Basin once before while passing through Barstow, but got lost. This time we had a more detailed map, since Rainbow Basin occupies a whole chapter in Geology Underfoot, Southern California.

Except it turned out that map wasn't any better than the wide-scale auto club map. The problem is that when you're coming in from the northeast, there's an exit off I-15 for "Fort Irwin Rd", even though no such exit shows on any of the maps. Fort Irwin Rd. is the road all the maps show as leading to Rainbow Basin. So that's the road to take, right?

Well, it turns out that Fort Irwin Rd and the more westward Irwin Rd angle together to meet at a point well north of the Rainbow Basin turnoff, which is on Irwin Rd. Irwin Rd. is the road all the maps label as Fort Irwin Rd, while Fort Irwin Rd. doesn't exist on the maps at all. Confused yet?

Here's the secret: if you exit I-15 at Fort Irwin Rd, make a left when you get to Irwin Rd. and angle back toward Barstow. Drive for longer than you think you should, and Look for a dirt road going off to the right called Fossil Beds Rd, which has no signs whatsoever related to Rainbow Basin even though supposedly there's a sign for it if you're coming in the other direction. Once you find Fossil Beds Rd, you're on track, and there are signs for the rest of the way.

Is it worth bothering with all this? Absolutely! Geology Underfoot rightly recommends starting with the "scenic loop drive", a short, one lane, one way dirt road that looks a little rough but really shouldn't be a problem for any car (at least when dry). It winds down through narrow canyons composed of colorful highly tilted layers of mudstone and tuff, then up a little hill to a parking area which offers a panoramic view of the Barstow Syncline, where the rock layers have been warped by fault compression into a striking U-shaped depression in an action mimicking the larger scale raising of the Transverse Ranges north of the Los Angeles basin by the San Andreas fault.

Curiously, on an intensely crowded weekend, Rainbow Basin was almost deserted. At the Syncline parking area we joined one other vehicle, a white van belonging to the "Loma Linda Department of Natural Sciences (Geology and Biology)". We never did spot the Loma Lindans; presumably they were down in the syncline measuring strike and dip. I hope my class field trips turn out to be this interesting.

Geology Underfoot recommends following the scenic drive with a hike of Owl Canyon, from Rainbow Basin's camping area, so we did so. The Owl Canyon trail offers a chance to walk through the axis of the syncline, up a mostly-dry creekbed to a dry waterfall. The colors aren't as impressive as the layers visible from the scenic loop, but the more subtle colors are interesting: the book mentions the green mudstone all along the wash (green from weathering of volcanic ash, not from copper) but doesn't mention the strikingly colorful granites washed down into the canyon, reds and bright greens as well as greys and blacks.

Along the way, there's a short cave in the side of the canyon marking a tributary which runs in wet weather. The book recommends bringing flashlights if one wishes to explore the cave. Since we had only bought the book a day earlier, we weren't well prepared for that; fortunately, I had my little blue LED keychain flashlight clipped to my water bottle, which turned out to be fine since the cave was so short.

Rainbow Basin was an excellent conclusion to our Mojave desert trip. This well hidden pocket park is well worth a side trip if you're anywhere near Barstow and have any interest in geology, or just in a short scenic drive among colorful desert rocks. Assuming, of course, that you can find the road in.

Tags: ,
[ 22:31 Apr 03, 2005    More travel/mojave | permalink to this entry | ]

Fri, 01 Apr 2005

Mojave

The East Mojave National Reserve is the nation's newest member of the national park system, signed into law as one of President Clinton's final acts. Growing up in LA, I'd driven through various parts of the Mojave desert since I was old enough to drive, but I hadn't been there since the park was created, and I didn't have much idea what specific interesting places might be there, except for Kelso Dunes, distantly visible from the interstate near Baker and always intriguing on our previous trips.

But where to go? I had no information about what was where, just an auto club road map and the topographic map collection I've been using to work on my pytopo program. The road map had ranger hat symbols at the town of Baker, at Mitchell Caverns down at the south end of the preserve, and at an obscure intersection of two minor roads in the south-central part of the reserve.

Dave didn't want to go to Baker -- it's a tacky little town whose two claims to fame are the World's Tallest Thermometer and a restaurant called the Bun Boy, though I have fond memories of our stay at Baker on the first night of our first trip together. Mitchell Caverns was too far and likely to be too crowded during spring break week. So we decided on the third option, which followed a road that led toward Kelso Dunes. Even if we didn't find a ranger station, at least we'd see the dunes; and there was an intriguing place somewhere along the road called "Hole in the Wall" which sounded worth checking out.

Roads in the preserve are mostly dirt, but are well graded and very well signed, and finding our way was no problem. Wonder of wonders, Hole in the Wall is the ranger station and campground marked on the auto club roadmap, and they have a very nice visitor's center and bookshop. Although they didn't have any books on the geology of the area (not their fault: no one has written one and they wish someone would!) they did have another in the "Geology Underfoot" series which covered, among other places, Rainbow Basin, tomorrow's target.

Newly armed with books and maps, we headed down the Rings Trail, Hole in the Wall's showpiece. It's short (though it connects to several much longer trails), fun and interesting: you scramble down over blocks of the colorful local tuff until you get to a steep slot, where metal rings have been bolted into the rock to provide handholds. Two such ring ladders and a bit more rock scrambling get you to the bottom of the slot canyon, where you can admire the fabulous colorful tuff towers above you, inspect the interesting tuff and volcanic breccia comprising the rocks, with their inclusions of hornblende, obsidian and other interesting minerals, and walk out to where the canyon emerges into normal Mojave desert with a view of the Providence Mountains and Mid Hills.

A very rewarding stop, and a fascinating place.

One curiosity about the Hole in the Wall Ring Trail: the sign at the trailhead makes a big deal about how strenuous the hike is. It's not really all that strenuous (the two ring climbs are short) but it could be unnerving for someone with poor balance or a fear of heights, too narrow for very overweight people, and of course it's not at all wheelchair accessible. But what they don't mention: if you drive south a few hundred feet on the road and turn west onto Wild Horse Canyon loop, in a very short distance you're more or less at the bottom of the Ring Trail. It's not as fun as climbing down the ring ladders, but would be well worthwhile for someone who couldn't see the canyon any other way.

With time left in the day, we took another route to Kelso Dunes, going back the way we came but by way of Wild Horse Canyon Rd, which the ranger recommended. I'm not sure why; there wasn't much on that road which we hadn't already seen from other roads. But taking the seemingly more direct route to Kelso, it turned out, involved quite a lot of slow jeep trail and probably would have taken quite a bit longer, so no harm done.

The highest of the Kelso Dunes rises to 600 feet, dwarfing the 140 foot rise of the famous Mesquite Dunes in Death Valley. Since I'd missed yet another chance to explore and photograph the Mesquite dunes a few days earlier, I was happy to be at Kelso.

The parking area was packed, but there's plenty of room on the sand: it wasn't crowded away from the parking lot. Getting to the dunes involves fighting for some portion of a mile along a deep sandy trail, then scrabbling your way up the side of the dunes.

The dunes are covered with wind ripples and tracks of all sorts of animals (mostly lizards, insects, hikers, and their dogs and children) and plants (the dune grass bends in the wind, and the tips of each blade make an arc in the sand.)

Near the top, you start feeling like an Everest trekker: you eye the cornice of sand along the ridge to the north, and watch the turbulent eddies of sand blowing off the tip of the peak above you as the wind howls past and threatens to blow you off the mountain. Well, okay, admittedly it's a bit warmer and you don't need oxygen tanks.

We went as high as the Hillary Step, but Dave's eyes were protesting from too much sand under his contact lenses, and the wind got worse with every foot ascended, so we stopped there. Our sherpas had long since deserted us.

Descending is much quicker than ascending. For one thing, you can take giant moon leaps, or "ski" down the sides of steep slopes, if you don't mind getting your shoes full of sand. Alas, the long level slog from the base of the dunes back to the parking lot is no easier in the return direction.

We drove out via Kelbaker Rd, past perhaps the most perfect collection of cinder cones I've ever seen together in one area. The map says they have a lava tube there, too. We'll have to come back and check it out some time.

Tags: ,
[ 09:26 Apr 01, 2005    More travel/mojave | permalink to this entry | ]