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
readFITS.r reads multi-dimensional arrays (e.g. images and image
cubes)
and binary tables (bintables). 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. The only known incompleteness is the absence of bit,
complex and array descriptor data types for bintables.
frameFITS.r reads a FITS binatble into an R
data frame, using additional code contributed by Eric H. Neilsen, Jr.
of the Fermi National Accelerator Laboratory. Usage and an
example are in the comments at the top of the file.
writeFITSim.r writes a multi-dimensional
array (e.g. an image or
image cube) in integer or float, single or double precision. For
usage and examples see the comments at the top of the file.
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 (independent bins, not smoothing)
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.
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.