Some code snippets and functioning programs, mostly in Python (except GLADOS which is IDL).
Basics (another, better resource is the Python cheat sheet)
Change to directory where the script is :ChDir.py
Declare a blank array : BlankArray.py
Find the number of lines in a file : NLines.py
FInd and trim NaNs : AddTrimNaNs.py
Find indices of NaNs in a list and delete them : FindNans.py
List files with specified extension : ListFiles.py
LIst of random numbers : ListRandom.py
Read array or list from file : ArrayFromFile.py. Alternative, possibly clearer version : ArrayFromFile_2.py
Some basic math functions and timing : MathTime.py
Split a string by character : SplitString.py
Write or append to a file : FileOps.py
Read parameters from a file, avoid reading in line breaks : ReadFile.py
Basics - Blender (2.49) specific (see also the Blender 2.49 Python API)
Change to .blend file directory : ChBlendDir.py
Delete verticies : DelVerts.py
Basic GUI : GUIExample.py
File broswer : FileBrowser.py (note this is bugged - can't send name to rest of program properly)
Get mesh from specified object, give it materials : MeshMaterials.py
Get materials of an object : GetMaterial.py
Move verticies : MoveVerts.py
Check if a point is inside a mesh : PointInMesh.py
Set draw mode to solid or transparent : DrawModes.py
Extrude points : ExtrudePoints.py
Object selection : SelectObjects.py
Create a material with a texture : ImageTexture.py
Get the scale-independent, bounding box size of an object : BoundingBox.py
FitsBaseline.py, FitsBaseline_SN.py :Fits and subtracts nth-order polynomials with sigma clipping on spectral axis of data cubes. The SN version divides the spectra by their rms, returning a signal-to-noise cube rather than flux. Also available in IDL versions : FitsBaseline.pro, FitsBaseline_SN.pro
FitsMaskedBaseline.py : Takes two cubes as input, one with sources/RFI masked, one with no masking. Does the polynomial fitting as above on the masked cube, then subtracts the result from the unmasked cube. This can give better results if a large portion of the spectral baseline contains signal.
FitMed.py : Measure the median of the spatial (x-axis) bandpass and subtracts it.
SimMinMed .py: Chops the spectral bandpass up into boxes and measure the median in each box. Finds the minimum of the medians and subtracts it from the whole scan.
SimMedMed.py : As above, but usies the median of the medians instead of the minimum of the medians.
UserMed.py : Takes two cubes as input, one with sources masked, one without. Measures the median of the spatial bandpass in the masked cube, then subtracts this from the unmasked cube. Since the user has direct control over what to mask, this can use the maximum possible amount of the bandpass, so may be more accurate than MinMed or MedMed.
Fits2Text.py : Converts a FITS file into ASCII.
Text2Fits.py : Converts ASCII to FITS. Not very robust though.
FluxInject.py : Adds flux into a data cube at the specified location.
GaussFluxInject.py : Adds flux with a 2D Gaussian profile.
Interpolate.py : Interpolates extra channels.
LatLong-XYZ.py : Converts cubes of latitude-longitude format into XY format.
DeGuass.py : Removes a Gaussian function. User can specify input parameters or allow them to vary (chi-squared minimization), e.g. center coordinates, FWHM, peak value. Works on multiple channels in 3D data cubes.
DeGuass_2D,py : Ony works on 2D data but can also iteratively fit ellipticity and position angle.
BlankFits.py : Creates a blank FITS file with the same header information as another.
AddHeader.py : Add FITS header keyword.
FRELLED : 3D FITS viewer. Doea ALL of the things !
GLADOS : Source-finding program for HI data cubes. Takes three cubes as input : two orthogonal polarisations plus the average. Searches the average cube for sources spanning a specified number of channels, then checks for corresponding detections in each polarisation. Afterwards, matches sources in close proximity using starlink routines.
AGES cataloguing : Takes separate files containing inputs for mbspect and runs mbspect using each of them. Saves a file containing the input parameters and mbspect measurements, the ASCII log file of the specta, and postscripts.
Photometry : Programs to assist in bulk downloading and naming of SDSS FITS files, as well as automatically generating ds9 regions for aperture photometery.
Wedge plotting : Reads in a file of RA, Dec, velocity and makes a wedge plot (aka pie slice). You'll have to make your own axes or modify the ones provided.