Tuesday, March 20, 2007

serial ports and Mac os X

It is pretty straightforward to add a serial port to your Mac using a serial to RS232 converter. I bought a USBG-232 converter from usbgear, that has a foot cable, and lights so you can check the connection at the hardware level.

Don't bother with the drivers on their website, which are outdated. Go to FTDI, the company that makes the chip inside. They have up-to-date drivers even for intel Macs.

To talk to your serial device, you could get goSerial, but I wanted to do some on-the-fly analysis using python (of course). For this, I use pyserial. You just have to make sure that you link to the serial device correctly, as the FTDI drivers call it something nonstandard.

Wednesday, March 7, 2007

non-linear colormaps in matplotlib

Here is a way to do non-linear colormaps in matplotlib. You can select a base colormap, and a series of levels, and this class will remap the (linear) colormap such that your new selected levels define the linear positions along the map. This can be used for plotting bathymetry, specifically, where you may want to have more contours in the shallows than deep. Grab the code here: nlcmap.py.