LCPFCT solver–accessible from Python

LCPFCT from Python
LCPFCT from Python

The venerable NRL Flux-Corrected Transport algorithm for Solving Generalized Continuity Equations has been cited in hundreds of publications and is used by myself in my PhD thesis and general research.

I have updated the syntax of the original Fortran code slightly to fit with the FORTRAN 77 standard (not changing algorithm behavior, only syntactical correctness). As a byproduct, I have made demo plotting code available in Python that uses f2py to make the LCPFCT run from Python at an order 50x speedup overall since you don’t have to write output to disk and then read it back in via a custom parsing algorithm.

installing wine on ubuntu 14.04 after upgrade from ubuntu 12.04

I had the issue a few others had where trying to install WINE on an Ubuntu 14.04 x64 system that had previously been upgraded from Ubuntu x64 wouldn’t work with a message about liblcms2-2 conflicting with liblcms2-2:i386. Even the Wine PPA wouldn’t help.

Then I ran across a fix where you type
sudo apt-get install liblcms2-2=2.5-0ubuntu4
and then you can install wine!

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

Matplotlib: 3-D mesh wiregrid example

Some of the Matplotlib 3-D examples out there are a little out of date. Here is a minimal working example for the current version of Matplotlib 1.4

#!/usr/bin/env python
from mpl_toolkits.mplot3d import Axes3D # this line must come before the next line!
from matplotlib.pyplot import figure,show
from numpy import linspace,meshgrid,pi,sin #for testing
key point: the line "from mpl_toolkits.mplot3d import Axes3D" needs to come before
the "from matplotlib.pyplot import ...." line in the FIRST file you run.
To be sure, I make the "from mpl_toolkits.mplot3d ..." line come first in my
main function file (the one I invoke from the command line or Spyder)

def test():
    x,y = meshgrid(linspace(0,2*pi),linspace(0,2*pi))

    z = sin(x+0.5*y)
    ax = figure().gca(projection='3d')

if __name__ == '__main__':
    test() Windows client under Wine / Linux

So far, the webcam doesn’t work, but the send/receive audio does work on a test call. I didn’t test receiving video.

NOTE: in an actual conference, I wasn’t able to get sound, and so had to use a telephone. I have also seen problems with this for people using Windows and Mac at a large conference–leading the remote speaker to call in.

I personally avoid using GoToMeeting and would recommend using Google Hangouts or Skype instead of GoToMeeting for desktop sharing, video and audio between Mac/Linux/Windows/Android/iOS.

I tested this on Ubuntu 14.04 with wine 1.7.18. Again, this ultimately failed in a real conference. I don’t recommend GoToMeeting at this time for Linux or any operating system where you have a lot of people counting on it actually working..

1) Get the latest MSI file for GoToMeeting — I used V6.2.1 build 1350 from

2) in Terminal, type
wine msiexec /i ~/Downloads/G2MSetup6.2.1350_IT.msi
3) You may not have sound by default. To fix this, start GoToMeeting, right-click the flower toolbar icon, select Preferences, Audio, and select the Pulseaudio device for each.
Uncheck the “Automatically adjust my system mixer settings” and “Use automatic volume and noise processing” boxes.

Quote of the Day

Some think the Earth is spherical, others that it is flat and drum-shaped.
For evidence they bring the fact that, as the sun rises and sets, the part concealed by the Earth shows a straight and not a curved edge, whereas if the Earth were spherical the line of section would have to be circular . . .
. . . but in eclipses of the moon the outline is always curved: and, since it is the interposition of the Earth that makes the eclipse, the form of this line will be caused by the form of the Earth’s surface, which is therefore spherical.
Aristotle. “On the Heavens”. Written 350 B.C.E.

Quoted in:
Kabanikhin, Sergey I. Inverse and Ill-Posed problems

Winetricks “voice had cried out in terror” error resolve

if you get a winetricks error like:
wine cmd.exe /c echo '%ProgramFiles%' returned a string containing the word 'unknown', as if a voice had cried out in terror, and was suddenly silenced.

You can fix it by doing the following
1) backup your existing system.reg file by typing in Terminal:
cp ~/.wine/system.reg ~/.wine/system.reg.bak
2) gedit and replace all
C:\\Program Files

rigctl / hamlib with Kenwood TS-2000

On a modern PC, you may notice intermittent errors with the Kenwood TS-2000 , something like:
read_string(): Timed out 0.2 seconds without reading a character.

The solution seems to be making rigctl wait for the TS-2000 to catchup by using the hardware handshake–you need a “real” RS232 cable for this to work, with the correct DSR/RTS pins included and connected.

try the command:
rigctl -m 214 -s 57600 -r COM1 -C serial_handshake=Hardware