Tag Archives: Python

Running Tornado on dotCloud

To brush up my web development skills, I decided to try Tornado. I also wanted to find a hosting service of some sort for my projects, which must be cheap and developer friendly. There, dotCloud seemed very nice and I … Continue reading

Posted in Uncategorized | Tagged , , , , | Leave a comment

Searching for Nearest-Neighbors between Two Coordinate Catalogs

Say I have two catalogs of points, each in two-dimensional space. For each object in a catalog, I want to find the nearest object(s) in the other catalog. I can do this by computing the distances between every single unique … Continue reading

Posted in Uncategorized | Tagged , , , , | Leave a comment

Using Linux Shell Command within Python

If you just want to do some simple task, this would do:

Posted in Uncategorized | Tagged , , , | Leave a comment

SciPy Weave Bug in Debian Squeeze

I was trying to remove a bottleneck by converting a portion of Python code into C++ via scipy.weave.inline, and encountered a bug. Here is my code: And this is what I get: Fortunately there is a fix: The fix for … Continue reading

Posted in Uncategorized | Tagged , , , , , , | Leave a comment

Comparing the Efficiencies of Gaussian Convolution Routines

These days I quite often need to convolve (i.e., smooth) 2D images by some Gaussian. There are quite a few routines that can do this with varying efficiencies. So I compared a couple of them. On my laptop, this script … Continue reading

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Suppressing Warnings in PyFITS

PyFITS is obviously a great Python package if you ever need to deal with data in astronomy. One thing that consistently annoyed me however was their use of warning messages.  For example, whenever you overwrite an existing FITS file, the … Continue reading

Posted in Uncategorized | Tagged , , , | 2 Comments

Estimating Standard Deviation from N Data Points

In astronomy people often estimate a standard deviation in, say, background counts from the observed data themselves, since it is very difficult to know what true standard deviations are. Then the question is this: How many measurements (e.g., the number … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

Python Utility for the UVBLUE Stellar Spectrum Library

I have a need to use spectra from UVBLUE, but they only supply IDL programs (who needs these any more?) to deal with the data.  I want to use the spectra in Python, so I ported their program.  Download it … Continue reading

Posted in Research | Tagged , , | Leave a comment

Testing if a Point is Inside a Polygon in Python

Finally got around to find this out by Googling.  It’s a useful function so I reproduce it here for copy & paste: def inside_polygon(x, y, points): “”” Return True if a coordinate (x, y) is inside a polygon defined by … Continue reading

Posted in Uncategorized | Tagged | Leave a comment

python-mode.el for Emacs

On Debian, you can simply install the package “python-mode,” but this describes the manual method. For OS X (I currently use Snow Leopard), I can install the python-mode package via FinkCommander. First, download python-mode.el and place it under ~/.emacs.d (create … Continue reading

Posted in Linux, Mac OS X, Snow Leopard | Tagged , , , , , | 1 Comment