Python scripts for astronomy

Astronomical research requires dozens of little calculations each day: brightness temperatures, spectral indices, optical depths, instrumental sensitivities, and many more. It is convenient to have little helper programs which you can invoke from the command line and to which you can pass a few parameters to get your calculation in a fraction of a second. I have written some Python scripts for a variety of applications, but most of them are related to the everyday work of a radio astronomer with a weakness for VLBI. Called without command line parameters, most of them print out a short message describing what they do and how to use them.

Feel free to download, use, modify and pass on these scripts, but please do not remove my name from it. Send me an email if you think they are useful, discovered a bug or improved them.

Back to main page


Script name
Purpose
AN-resort.py This is useful for re-sorting the D-term solutions from AIPS antenna tables into a human-readable format and for further processing like plotting.
angsep.py Use this to calculate the angular separation of two points on the sky (or on the ground - as you wish :-). If the separation is less than one arcsecond, the separation is calculated using the diagonal of a plane triangle.
avg.py A script to calculate the average, standard deviation, sum and mean of all colums or lines of an array of numbers. You have to specify "-cols" or "-lines" or the script won't do anything.
baseline_sensitivity.py Calculates the baseline sensitivity of two antennas with equal SEFDs.
bh-diameter.py Calculates the number of Schwarzschild radii across a given angle. Can be used to estimate how many event horozons fit into the synthesized beam to estimate how far you are from resolving the AGN.
brightness_temperature.py Calculates the brightness temperature of a radio sources directly from Planck's law. The geometry of the source is assumed to be an evenly radiating disc of the given diameter.
count.py Counts from one number to another with a specified increment and prints out all numbers inbetween either in one line or in a column.
cplx2rad.py Treats two numbers specified on command line as real and imaginary parts of a complex number and prints out the length of the vector and the angle.
dec2deg.py Converts a declination in hms format to degrees.
deg2dec.py Converts degrees to a declination in hms format.
deg2ra.py Converts degrees to right ascension.
deg2rad.py Converts degrees to radians.
difwin2aipswin.py Converts Difmap windows to the AIPS window format which can be read by IMAGR using the BOXFILE parameter. Useful if you want to reproduce the Difmap imaging in AIPS for, e.g., polarimetry images.
ffstg_lcp_only.py The "fast frequency switching tabe generator". Uses an AIPS solution (SN) table and scales the phases by a given amount. I use this to calibrate high-frequency VLBI observations with interleaved low-frequency scans.
flagfinder.py Sorts out those flags from a VLBA flagging table that flag time spans longer than a specified interval.
gd2jd.py Converts a gregorian date and time to julian date.
get_bibtex.py Program to fetch bibtex refs from ADS. On the commandline, provide a text file with one bibcode per line.
get_eff.py Program to fetch the Effelsberg webcam image every 10 seconds and to store it on local data disk with a unique timestamp. I use the images to compile movies from the webcam images.
image-sensitivity.py Calculate the nominal image sensitivity in a VLBI observation with a given number of equally sensitive antennas (e.g., the VLBA).
jd2gd.py Converts julian date to gregorian date and time.
m2pc.py Converts meters to parsecs.
make_movie.py Prepares a command file for mpeg_encode to generate a movie from the Effelsberg webcam images fetched by get_eff.py.
pc2m.py Converts parsecs to meters.
plotit.py Plots (x,y)-data read from a file using the Pgplot routines. Can also be used to interactively flag data from that file and to calculate averages and standard deviations with interactively specified areas of the plot.
polar2rect.py Program to convert polar coordinates to rectangular coordinates and to calculate T_b (don't know how trustworthy that is, better is to use brightness_temperature.py for this) from Difmap model files. It prints out a table of distances among all model components.
propmotion.py Calculates proper motions of objects. Also useful to calculate the scale in an image, i.e., parsecs per arcsecond.
ra2deg.py Converts a right ascension to degrees.
rad2deg.py Converts radians to degrees.
remspace.py Removes spaces from names of specified files or all filenames in current directory.
rotation_measure.py Calculates the rotation measure in an magnetized plasma.
sensitivity.py Calculate the image sensitivity of an inhomogeneous VLBI array, depending on the mututal source visibility at every two antennas. Prepare a data file of the format
20  000000000000000000000000111111111100000000000000  296 000000000000000000000000111111111100000000000000

where the first number is the antenna SEFD and the 48 digits inidcate times at which the source is above the horizon at the antenna in 30 min bins during 24 h.

spix.py Calculates the spectral index from flux density measurements at two frequencies.
tau_ff.py Calculates the optical depth of a plasma in the radio regime.
vector_rotation.py Rotates a vector specified on the command line n times through an angle p and calculates the vector sum. Helps to estimate the coherence loss when VLBI data are averaged over a certain time interval.


Back to main page



Last modified: Thu Apr 1 20:05:07 CEST 2004

Staff space
Public