about 6 months ago - No comments
It's been a while since I posted anything here. And today won't mark a significant change in that pattern, I'm afraid. But my python-IDL interface, pIDLy, has been mentioned elsewhere a couple of times, so I thought I might as well put the links up here. First, IDL guru Michael Galloy found pIDLy, liked it,…
about 11 months ago - 2 comments
One of my most important roles within HerMES has been to generate the LaTeX for the lists of authors and affiliations in the astronomy journal papers (previous posts here and here). HerMES is a big consortium, so some of the papers have something like 100 authors (with each author contributing, say, 10 or 20 words,…
about 11 months ago - No comments
I thought I'd better figure out what Git and GitHub are. Git is a revision control system, enabling you to keep track of changes to computer software (for example). GitHub is a web-based hosting service for Git repositories. (The GitHub logo is the "octocat", by the way.) It's all very simple to use too. My…
about 2 years ago - 6 comments
Okay, a bit boring, but as promised, here are some Python functions to generate LaTeX source for long authors lists for MNRAS and A&A. First, a small utility: def getSortedInstituteCodes(authorList, authorInstituteCodes): """Return a list of institute codes, in the correct order for authorList. authorList = ["J.~Bloggs", "A.N.~Other"] authorInstituteCodes = {"J.~Bloggs":1, "A.N.~Other":[1,"Sussex"]} """ instituteCodes =…
about 3 years ago - No comments
They're coming thick and fast now. Here's a Python function to accompany the previous post. It's not maximally efficient, but should make sense... from scipy import stats def gaussian_pixel(minxy, maxxy, sigma, meanxy=(0.,0.), norm=None): """Return the value of a pixel sampling a 2D Gaussian, normalized such that the area under the Gaussian is 1 (default) or…
about 4 years ago - No comments
You have an image. Each pixel has a value with some uncertainty. How do you visualize the uncertainty in each pixel? Like this: Here's the Python code import numpy as np from matplotlib import pyplot as plt class FlickerImage(object): def __init__(self, im, err): self.im = im.copy() self.err = err.copy() finite = np.isfinite(self.im + self.err)…
about 4 years ago - 1 comment
Here's an easy way to display FITS images (or any array) in DS9 using Python (with PyFITS, NumPy and Numdisplay, which is part of stsci_python). First launch DS9, then in Python: import numdisplay import pyfits arr = pyfits.getdata('file.fits') numdisplay.display(arr) Easy! Alternatively, the Kapteyn package seems excellent, and uses Python's matplotlib for displaying images. It requires…
about 5 years ago - No comments
Now Python and IDL can talk to each other (okay, Python talks to IDL and IDL does what it's told), using pIDLy (pronounce as you please). I experimented with a few other solutions available online but couldn't get them to work. So I cobbled this one together with surprisingly little trouble, thanks largely to pexpect.