Protracted Matter
Saturday, December 29, 2012
Shun the Mouse
So, it's a problem when it comes to me using Apple products. Yes, I'm sure there are key commands that I can use. I'm also sure that I could script some new ones if necessary. At it's heart, however, Apple is a consumer UI company. It might have disability access leanings (and be good at it), but it is so very different from everything else I use on a regular basis that I'm inclined not to learn them.
Thankfully, I did find a solution for things like checking my email or my calendar without having to use the mouse or fuss with window management. A wonderful person posted an AppleScript snippet to open webpages in Chrome without duplicating them. By tying this into a Quicksilver, I can quickly open anew or go to an existing gmail or calendar tab in Chrome with a few quick commands. I've used this a lot in the last few days and enjoy it quite a bit.
I also found that setting my default mail composer to Google Mail also helps avoid the mail app; I think there's something in Quicksilver to do this as well.
The only thing that is missing is a good way to quickly add appointments in Google calendar without having to fill out the form (and get confirmation that they were added quickly). There used to be a quick add API on the calendar, but I think it's been removed. However, for now I am happy with my keyboard-focused workflow... until another mouse-driven annoyance pops up.
Wednesday, August 29, 2012
Nonlinear colormap in Matplotlib
One of the difficulties I deal with is data that is not evenly distributed across a particular range. Sometimes, I want to highlight a particularly small set of values with great color contrasts and leave other portions of the range to be much less distinguished. For this, I went looking for a way to have a non-linear colormap in matplotlib. To be clear, I didn't want the data itself to be transformed, rather I wanted the color mapping to progress through a normal colormap like cm.jet but expand and contract portions of the map across the entire of values to provide granular resolution at a specific range of values. The graphs below show the difference when using a linear colormap and a transformed colormap:
Image before:
Image after:
I found a script to perform this mapping. It allows the user to set a number of levels that get used to transform the colormap. My modified version of the script is below:
""" nlcmap - a nonlinear cmap from specified levels Copyright (c) 2006-2007, Robert Hetland <hetland@tamu.edu> Release under MIT license. Some hacks added 2012 noted in code (@MRR) """ from pylab import * from numpy import * from matplotlib.colors import LinearSegmentedColormap class nlcmap(LinearSegmentedColormap): """A nonlinear colormap""" name = 'nlcmap' def __init__(self, cmap, levels): self.cmap = cmap # @MRR: Need to add N for backend self.N = cmap.N self.monochrome = self.cmap.monochrome self.levels = asarray(levels, dtype='float64') self._x = self.levels / self.levels.max() self._y = linspace(0.0, 1.0, len(self.levels)) #@MRR Need to add **kw for 'bytes' def __call__(self, xi, alpha=1.0, **kw): """docstring for fname""" # @MRR: Appears broken? # It appears something's wrong with the # dimensionality of a calculation intermediate #yi = stineman_interp(xi, self._x, self._y) yi = interp(xi, self._x, self._y) return self.cmap(yi, alpha) if __name__ == '__main__': y, x = mgrid[0.0:3.0:100j, 0.0:5.0:100j] H = 50.0 * exp( -(x**2 + y**2) / 4.0 ) levels = [0, 1, 2, 3, 6, 9, 20, 50] cmap_lin = cm.jet cmap_nonlin = nlcmap(cmap_lin, levels) subplot(2,1,1) contourf(x, y, H, levels, cmap=cmap_nonlin) colorbar() subplot(2,1,2) contourf(x, y, H, levels, cmap=cmap_lin) colorbar() savefig('nlcmap_example.png')Some of the comments above point to changes that I had to make to get the script to work. Specifically:
- pylab.stineman_interp gave an error relating to the dimensionality of some of the intermediate calculations
- one of the backends requested the colormaps N member, which wasn't set in the original
- the **kw parameter wasn't passed to the __call__ method, causing problems when optional parameters such as bytes were passed.
Monday, June 6, 2011
Updating LaTeX on Mac (Hard and Easy Way)
- Switches the /Library/TeX/Distributions/.DefaultTeX directory to link to one of the directories ending in .texdist in /Library/TeX/Distributions. Each of these directories contain links to different TeX resources.
- The contents of /Library/TeX/Distributions/.DefaultTeX/Contents then contains links to the man, root, and other TeX package resources for the default TeX package.
- This switch changes what the symbolic links in /usr/texbin refer to.
Wednesday, April 14, 2010
Pretty Bubbles
Heavy, hot, sturdy, and allegedly used in the quest for global thermonuclear war, it is a sweet piece of machine. What caught my attention, however, was not its sleek metal case or awesome yellow 80x24 character ELD display but the type of memory the GRiD Compass 1101 used for non-volatile memory.
The GRiD Compass had three modules of bubble memory for long-term storage. This type of memory relied upon "bubbles" of magnetic data. Stored on a two dimensional surface, these bubbles were manipulated by external magnetic fields. By altering these fields, bubbles of magnetism could be shepherded down a magnetic surface toward a read/write head. By connecting the output of one edge of the magnetic surface to the other, bits could be looped back to the other side of the module. Putting many of these loops together, multiple bits could be read in parallel.
Contrasted with the spinning disks of magnetic residue we use to this day, it seems like an elegant solution for non-volatile storage in a historically important but less than elegant era of personal computing.
Unfortunately, bubble memory was not to be. As hard drives improved and dropped in price, bubble memory was abandoned in all but harsh operating environments. Still, the idea of little bubbles of magnetism moving down looped pathways is amazing to me. This type of solid state memory would have been an interesting alternative technology to the modern quantum-mechanically based flash storage devices that are ubiquitous today.
Interestingly, the idea using bubbles as information storage is not over. New research into non-magnetic bubbles continues for "lab on a chip"-style tools, giving bubbles a continuing role in the evolution computational machines.