Danny Price recently left a comment to let me know about a new Python package he's developing called hickle. The goal of "hickle" is to create a module that works like Python's pickle module but stores its data in the HDF5 binary file format. This is a promising approach, because I advocate storing binary data … Continue reading pickle, hickle and HDF5

## Building NumPy and SciPy with Intel Composer 2013 and the MKL

Since Python is widely used as a high-productivity language for scientific computing, Intel has created a page showing how to build NumPy with Intel compilers and the Math Kernel Library (MKL). I would like to clarify a few items regarding building NumPy on a 64-bit Red Hat Enterprise Linux 5.4 system. Since this is a … Continue reading Building NumPy and SciPy with Intel Composer 2013 and the MKL

## Tricks for Writing XML with Python 3

I've added a Python 3 XML example to my Shocksolution_Examples repo on GitHub. The new example shows how to generate an XML file which functions as a template for building a GUI with wxGlade. However, this example should be helpful for anyone who needs to create XML files with Python. The full example is on … Continue reading Tricks for Writing XML with Python 3

## Building SciPy with Intel compilers and MKL on 64bit RHEL 5

This is a follow-up to my earlier post about building NumPy with Intel compilers and the Intel MKL on CentOS 5. I will now explain how to build SciPy (which requires NumPy). First, download and unpack the SciPy source tarball. The following command can be used to build SciPy: LDFLAGS="" FFLAGS="-fPIC -openmp" python2.7 setup.py build … Continue reading Building SciPy with Intel compilers and MKL on 64bit RHEL 5

## Building NumPy on a 64-bit Red Hat Cluster with Intel MKL

In a previous post I described how to build an optimized version of NumPy using the Intel compilers and Math Kernel Library (MKL). This post will update those instructions, since it has been a few years and I am now using NumPy 1.6.1, MKL 10.0.1.014 and Red Hat 4.1.1 (kernel 2.6.18-8.el5). First, copy the file … Continue reading Building NumPy on a 64-bit Red Hat Cluster with Intel MKL

## Python string format examples

The format method for Python strings (introduced in 2.6) is very flexible and powerful. It's also easy to use, but the documentation is not very clear. It all makes sense with a few examples. I'll start with one and add more as I have time: Formatting a floating-point number "{0:.4f}".format(0.1234567890) "{0:.4f}".format(10.1234567890) The result is the … Continue reading Python string format examples

## How to build ScipPy with Python 2.7.2 on CentOS5

EDIT: added --enable-shared to configure script for building Python, and added /home/yourname/lib to shared library path. This is necessary for building some packages such as pycairo (which you may need to build pygtk and matplotlib). EDIT 2: you should use the --prefix=/home/yourusername instead of --user. The prefix option places packages in the standard location: /home/yourusername/lib/python2.7/site-packages. … Continue reading How to build ScipPy with Python 2.7.2 on CentOS5

## Removing an axis or both axes from a matplotlib plot

Sometimes, the frame around a matplotlib plot can detract from the information you are trying to convey. How do you remove the frame, ticks, or axes from a matplotlib plot? The full example is available on github. First, we construct a figure and an axes object: fig1 = plt.figure(facecolor='white') ax1 = plt.axes(frameon=False) The Axes object … Continue reading Removing an axis or both axes from a matplotlib plot

## Python: lists to tuples and tuples to lists

Get the code for this example The zip function in Python accepts a number of sequences (such as lists or arrays) and returns a list of tuples. The first element of each tuple comes from the first sequence, the second from the second sequence, and so on. For example: a = range(0, 5) b = … Continue reading Python: lists to tuples and tuples to lists

## 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 … Continue reading A self-contained Fortran linear equation solver