Posts
Photography
These are links to places where my photos have appeared online or in print:
Steam tractors on Dark Roasted Blend Stage lighting article for Technologies for Worship Magazine (also in print) Schmap.com Guide to the Florida Keys (one of several photos of Mallory Square) The Center for Educational Technology in Israel used a photo of a cell phone tower disguised as a tree in a geography book for 7th and 8th grade students
IGES file reader
I am creating a Python library for reading CAD files in IGES format. I have barely started on the project–so far, it should be able to parse arbitrary IGES files without crashing, and it can extract useful information for line segments and rational B-spline curves. That’s all I need to get my work done right now, so I don’t feel justified in spending too much more “company time” on this. I am hoping that other people will help me by adding Python classes to represent the types of entities that they need.
Replacing text in place with GNU sed
sed is a stream editor, which means that it accepts a stream of text, processes it, and spits out another stream of text. sed can process files that are too large to load into memory, and it is a completely command-line tool that can easily be integrated into shell scripts. This excellent sed tutorial was written for an old version of sed provided by Sun Microsystems, and it doesn’t cover one of the most useful features of GNU sed. GNU sed accepts a -icommand line argument that tells sed to replace the text file in place, rather than writing the output stream to another file. Another nice feature is thatsed -i will create a backup file before processing if you provide a backup suffix:
A self-contained Fortran linear equation solver
I’ve just released a self-contained Fortran module that solves a system of linear equations using the LU decomposition. Download the Fortran linear solver from github This module is based on code that was implemented and released on the Web by Jean-Pierre Moreau. His implementation was based on one of the Numerical Recipes books. I updated his code to a more strict Fortran 90 standard and added the necessary comments so that it can be built as a Python module using f2py. I replaced Jean-Pierre’s Fortran test program with a simpler, self-contained program. I also included a Python script that implements the same test case. I created this module because sometimes a self-contained routine is more appropriate than a full library. I am compiling a library that implements a custom boundary condition for a proprietary computational fluid dynamics solver (CFD-ACE+). The library has to be written in Fortran, and it has to be built using a proprietary set of build scripts. I could either try to reverse-engineer the build process and to modify it to link to a shared library like LAPACK, or I could implement a self-contained solver. Since Pierre had already implemented the solver, I was able to slightly modify his code and get it working relatively quickly.
Finding a value in an unordered Fortran array
I have been optimizing some Fortran code that involved searching for an integer value in an unordered array (we know the value occurs only once). Since there is no intrinsic procedure to accomplish this, I thought I’d try a couple of approaches to see which was fastest. The simple answer is that, in this case, brute force beats elegance, even when the target value is near the end of the array. Download the full example from GitHub
Sage: open-source mathematical software
I’ve recently gained a lot of experience with Sage, an open-source alternative to MATLAB, Mathematica, Maple, MuPAD, and Magma. Here are a couple of links to check out:
Public notebook servers--try it online right now! Interactive examples with Sage
Sage vs. Mathematica
My experience with mathematical software started my freshman year at the University of Illinois when I signed up for a calculus class that was taught almost entirely with Mathematica. I grew to love Mathematica’s symbolic computation and plotting capabilities, although I found its programming language to be cumbersome. Once I was no longer a student, Mathematica was no longer an option due to the hefty licensing fees. With the caveat that I haven’t used Mathematica in many years, I will say that Sage compares very favorably to my experience with Mathematica. Sage has a notebook interface that allows you to integrate code, results, text, typeset equations, and graphics in an interactive document that can be viewed with any standards-compliant web browser. I don’t know how Sage stacks up against Mathematica in areas of advanced mathematics. I have heard that Sage is far ahead of Mathematica in number theory, because the lead developer of Sage is a number theorist.
Moving example code to GitHub
As this site has grown, the example code has gradually become unmanageable. I’ve posted snippets and fragments here and there over the years, and the original code is scattered in various locations across several computers. Further, as people have pointed out bugs or ways to improve the examples, I’ve had a hard time making changes. This is problem is crying out for version control with a central repository. Since I’ve been using Git for the past year or so, I decided to try GitHub. So, I am gradually moving all the examples from the site to: https://github.com/cfinch/Shocksolution_Examples When I put code in a post, I will provide a link to GitHub where you can browse or download the code. You won’ t need to use Git, or even learn anything about it.
Linear system simulation with Python
Linear time-invariant (LTI) systems are widely used in the field of signal processing. Scipy contains powerful tools for simulating LTI systems in the scipy.signal package, but they are not well documented. I will provide a simple example that demonstrates how to use a few of the core classes and functions in scipy.signal for simulating LTI systems with Python.
Define an LTI system
You will need to have Scipy installed, and you will need to have Matplotlib as well to make plots. We will start with an example of a first-order LTI system, which is characterized by a single parameter known as the time constant. scipy.signal defines the class lti to represent a linear system in Python.