Astronomy Functions, Tools and Routines


A collection of commonly used astronomy functions, tools and routines.


The astro package provides a series of functions, tools and routines in everyday use within astronomy.

Broadly speaking, one may group these functions into 7 main areas, namely: cosmology, FITS file manipulation, the Sersic function, plotting, data manipulation, statistics and general convenience functions and scripting tools. An overview of these sub-packages and their functions is as follows:


Cosmology Calculator: coscalc,

Comoving distance (line of sight): comovdist.los,

Comoving distance (transverse): comovdist.trans,

Angular diameter distance: angdist,

Luminosity distance: lumdist,

Comoving volume: comovvol,

Lookback time: lookback,

Redshift at a given Lookback time: lookback2z,

Age of the Universe: age,

Redshift at a given age: age2z,

Angular size conversion: angsize


Read FITS files (images/tables & headers): read.fits,

Read FITS header: read.fitshdr,

Read FITS key: read.fitskey,

Read FITS image: read.fitsim,

Read FITS table: read.fitstab,

Get FITS keyword value: get.fitskey,

Put FITS keyword value: put.fitskey,

Write FITS files: write.fits,

Write FITS header: write.fitshdr,

Write FITS key: write.fitskey,

Plot FITS images: plotfits,

Write large binary files: writeBin64,

Strip leading/trailing characters: strip


The Sersic function: sersic,

Convert between Sersic radii: convrad,

Convert between Sersic surface brightnesses: convmu,

Convert half-light radius to scalelength: re2h,

Convert scalelength to half-light radius: h2re,

Calculate a combined half-light radius: combrad,

Central Concentration: concen,

The Petrosian function: petro,

Petrosian index: petroindex,

Petrosian radius: petrorad,

The Kron function: kron,

Kron radius: kronrad


Astro plot: aplot,

Astro axis: aaxis,

Astro colourbar: acb,

Astro box: abox,

Astro alpha-transparency colour conversion: acol,

Ellipse: ellipse,

Plot labelling: label,

Plot shading: shade,

Shadowed text: shadowtext,

Cardinal points: cardinal,

Scale marks: scalemark


Astro kernel density estimator: akde2d,

The Gaussian Function: gauss,

The Schechter Function: schechter,

The Luminosity Density: lumdens,

Calculate Schechter Function Binned Variables: schechter.bin,

Fit to the Schechter Function:,

Error ellipses for a Schechter fit: schechter.ellipse


Chi-Squared Probability Density Function: chipdf,

Chi-Squared Cumulative Distribution Function: chicdf,

Chi-Squared P-Value: chipval,

Calculate the chi-squared statistic for a given p-value: chipval,

The incomplete gamma function: igamma,

Astro qbeta function: aqbeta,

Sigma-clipped mean: scmean


Absolute Magnitude of the Sun: solar,

Central Angle: cenang,

Human-readable time strings: nicetime,

For-loop ETA: eta


Lee Kelvin <>

Want to suggest features or report bugs for Use the GitHub issue tracker. Vote for new features on Trello.

comments powered by Disqus