R language utility functions with astronomical
application
The R language is a straightforward and powerful language for
manipulating, analyzing, and displaying data. It is free
software with releases for Unix, Windows, and Mac operating
systems. The language is in active open-source development
by the R Development Core Team of the R Foundation for Statistical
Computing, Vienna, Austria, as a language and environment for
statistical computing. More information is available at http://www.R-project.org.
For the code below, comments and bug reports are always welcome; a
contact link is at the
bottom of the page.
FITS file utilities
Functions in FITSio read multi-dimensional
arrays (images and image cubes)
and
bintables, and write a multi-dimensional
array (image or
image cube) data. The function contains sub-functions that can
read and parse headers and read image and binatbles
independently. For usage and examples see the comments at the top
of the file. Within these extension types, the only known
incompleteness is the absence of bit,
complex and array descriptor data types for bintables.
Package description and help files are here. FITSio is available as:
FITS is the Flexible Image Transport System, a common file format in
astronomy. Further information, including format specifications
and
example files, is available at http://fits.gsfc.nasa.gov/
and http://www.cv.nrao.edu/fits/,
among other places.
Julian date
dmjd2ut.r converts decimal modified Julian date
to UT (or UT with a
time offset for local times). The function contains a general
Julian date to UT
day conversion sub-function that can be called independently.
ut2dmjd.r converts UT to decimal modified
Julian date. The function contains a general calendar day to
Julian day conversion sub-function that can be called independently.
Binning (akin to smoothing but for independent bins, not binning
for e.g. histograms)
Binning in this application is averaging adjacent elements in a vector,
for instance binning a spectrum to increase the signal to noise ratio
at the cost of spectral resolution. As an example, for a sequence
of numbers {1 5 3 8 9 2}, binning by three would produce the two values
{3, 6.33}, the means of (1+5+3)/3 = 3 and (8+9+2)/3 = 6.33.
bin.r is a straightforward but inefficient (it uses
a for loop) binning routine that is useful for simple vectors.
For usage see the comments at the top of the file.
binmat.r generates a matrix that, with a matrix
multiplication, bins vectors or multiple vectors stored in
matrices. This is efficient for binning large numbers of
vectors. binmat2.r does the same but
leaves the size of the original matrix unchanged by repeating elements
within the bins. For usage see the comments at the top of the
file.
Miscellaneous functions
lookbacktime.r computes the standard cosmological lookback time
in Gyr as a function of redshift z.
ha_freq.r generates the frequencies of H-alpha
recombination lines.
planetFux.r provides the observed flux density in Jy for a
circular disk planet with uniform temperature and a Gaussian telescope
beam.
ruze.r gives the Ruze efficiency factor as a
function of rms surface error and frequency.
clipIm.r enhances image contrast by clipping the
amplitudes of an image (array).
svdinv.r performs an SVD matrix inversion
for ill-conditioned or non-square matrices.
Code on this page was developed
for analyzing instrumental data from
the Zpectrometer,
an ultrawideband spectrometer for high-redshift galaxy searches with
the U.S. National Radio Astronomy Observatory's 100 meter diameter
Robert C. Byrd Green Bank Telescope. The Zpectrometer was
supported
by National Science Foundation grant AST-0503946.
Questions or comments? Please contact Andrew Harris.