Marie – please contact me

Marie, we had talked about acoustics on Thursday. I did not receive your text. Please reply via email or comment here. (Comments are moderated, so only I will see). Thank you.

PySide in Anaconda3

When using Matplotlib in Anaconda 3, and if you’re trying to use QT4Agg, you may get the error message
ImportError: No module named 'PySide'

To fix this, you can try (using your Anaconda3 pip)
pip install pyside
This will take several minutes and may require the prerequisites:

sudo apt-get install libxext-dev python-qt4 qt4-dev-tools build-essential



Using USB-serial FTDI adapters with Intel Edison

The current Yocto kernel distro available for the Intel Edison (version 68 by configure_edison --version) does not include the FTDI driver. Thus when you plug a USB-serial adapter into the USB OTG host port, you’ll see it partially recognized in dmesg tail upon plugin, but you won’t see an assignment to a /dev/ttyUSB_ device.

You need to install the FTDI kernel module first.
opkg install kernel-module-ftdi-sio
This assumes you have already setup the unofficial opkg repository.

Now when you type dmesg tail you’ll see the line something like
usb: FTDI USB Serial Device converter now attached to ttyUSB0

You may have to update your kernel if this doesn’t work.

Connecting to Boston University’s 802.1x Wifi from a Linux device

If you don’t have a graphical desktop, BU’s Enterprise Wifi requires the following manual settigns. The settings below are from BU’s recommended settings.  Their webpage has now been updated per my suggestion.

# nano /etc/wpa_supplicant/wpa_supplicant.conf

paste at the end
ssid=”BU (802.1x)”

pairwise=CCMP TKIP
identity=”Your BU login”
password=”your Kerberos Password: be aware others can read this file!”


# reboot

This results in the feedback upon successful connection:

# wpa_cli -i wlan0 status

ssid=BU (802.1x)
key_mgmt=WPA2/IEEE 802.1X/EAP
Supplicant PAE state=AUTHENTICATED
selectedMethod=21 (EAP-TTLS)
EAP-TTLSv0 Phase2 method=MSCHAPV2

WriteLatex vs. ShareLatex

Short answer: Use ShareLatex

1) ShareLatex is much faster to compile. I have a 30 page journal article draft with numerous figures, and WriteLatex seems to take on the order of a minute to compile while ShareLatex was substantially less.

2) ShareLatex has far better error/warning feedback and a much better IDE overall. WriteLatex error/warnings keep disappearing and the line number with error is not clearly indicated.

3) ShareLatex is open-source. WriteLatex is NOT open source.

Python findpeaks

If you’re looking for a Python function that works like Matlab’s “findpeaks” checkout SciPy argrelmax.

If you want to do a comparison in the same code, you can call Octave findpeaks using Oct2Py, or use the Matlab Python API in Matlab R2014b

Intel Edison: Measuring USB voltage on breakout board

I have been trying out a variety of power sources. One is the 4xAA battery holder to female USB Verbatim 97928 available for about $10. It seems to have a well regulated 5.0 volt output.


The red arrow points to the side of the “74″ diode that comes right off the micro USB connector. I measured 5.00 Volts there with the Edison running on the Verbatim 97928. On the other side (downstream) of the diode I measured 4.72 Volts with the Edison idling. This voltage drop is expected due to the forward bias diode voltage drop.

Under 100% of one core CPU load, I measured 4.98V on the USB side, and 4.66V on the Edison side of this diode while powering from the USB port on the Verbatim 97928. The miniscule apparent 20mV voltage drop on the battery/USB side of the diode is likely to come from ohmic losses in the USB connector and cable.

Based on measurements of Intel Edison power consumption, and assuming 2000mAh, I estimate 10-12 hours of battery life on 4xAA alkaline batteries assuming continuous 100% CPU of one of the two CPU cores (other core idle). Normally the Edison will be mostly resting, drawing perhaps 100mW.

Thus with mixed use, I might expect to get up to 4-5 days of continuous mixed use operation on 4xAA batteries for the Intel Edison.

Miniconda Python on Intel Edison

Since the Intel Edison is a 32-bit CPU, we use the 32-bit version. But first, we need to install GNU Tar because Busybox tar doesn’t have some needed tar options, and it’s not compatible with GNU tar archives (!).

Since original writing, AlexT_Intel has put GNU tar in the opkg repository, so you can just do:

opkg install tar

tar xvf tar*
cd tar*

The ./configure takes almost a minute on a desktop PC, so it will take a few minutes on the Edison. Likewise for the make step.
You’ll see the tar binary at ~/tar-1.28/src/tar
nano ~/.bashrc
add the line
alias tar='/home/root/tar-1.28/src/tar'

Now let’s get Miniconda


Finally run the install (all typed on one line)

BASH_ENV=/home/root/.bashrc bash

when install complete, since Edison normally uses Dash shell, we create

echo "export PATH=/home/root/miniconda3/bin:$PATH" >> ~/.profile

Then reopening a Terminal window to the Edison will show

Python 3.4.1 |Continuum Analytics, Inc.| (default, Sep 10 2014, 17:21:42)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux

And you can use all the very easy to use conda goodness of Miniconda to trivially install packages like Numpy, SciPy, OpenCV, etc. on the Intel Edison.


conda update conda
conda install numpy scipy astropy

Python logging module versions to disk

I run Python massively in parallel with GNU Parallel across numerous remote PCs. I want to have the version numbers of the Python modules I’m using logged to disk. Here’s how I do so for Python 2.7 and 3.4

Python using NaN or None as sentinel

Sometimes I was forced to use NaN as a sentinel value, for example with the current version of Numba that can’t handle “is not None”.

The summary is that comparing to None instead of NaN is over 100 times faster. This negates the advantage of Numba when you have to compare to sentinel values!

Here’s a test with Python 3.4:

$ ipython3
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
IPython 2.3.0 -- An enhanced Interactive Python.
from numpy import isnan
%timeit ~isnan(0)
100000 loops, best of 3: 3.75 µs per loop
%timeit 0 is not None
10000000 loops, best of 3: 35.6 ns per loop

And Python 2.7

Python 2.7.6 (default, Mar 22 2014, 22:59:56)
IPython 2.3.0 -- An enhanced Interactive Python.
%timeit ~isnan(0)
100000 loops, best of 3: 3.73 µs per loop
%timeit 0 is not None
10000000 loops, best of 3: 41.5 ns per loop