Learn R Programming

rcosmo: Handle and Analyse Spherical, HEALPix and Cosmic Microwave Background data on a HEALPix grid.

Use this R package as an advanced toolkit for performing Cosmic Microwave Background (CMB) data analytics. The CMB is remnant electromagnetic radiation from the epoch of recombination. As an ancient source of data on the early universe, the CMB is helping us unlock the mysteries of the Big Bang and the structure of time and space. With increasingly high resolution satellite data, intensive investigations in the past few years have resulted in many physical and mathematical results to characterize CMB radiation.

Publication

Daniel Fryer, Ming Li and Andriy Olenko, rcosmo: R Package for Analysis of Spherical, HEALPix and Cosmological Data, The R Journal (2020) 12:1, pages 206-225.

Features

rcosmo addresses various data processing and statistical analysis needs for the present generation of CMB experiments. These needs fall into the following broad categories:

  • Importing and transforming HEALPix data in convenient CMBDataFrame class objects,
  • Geometric tools suited to spherical geometry,
  • Statistical tools suited to spherical random fields,
  • Interactive visualisation.

The current version of rcosmo includes the following functionality:

  • Tidy organisation of CMB data, including HEALPix indices, metadata, CMB intensities and their

corresponding spherical and/or cartesian coordinates, as well as polarization data,

  • window subsetting tools for investigating circular, convex and non-convex polygonal sub-regions on the sphere,
  • fast empirical covariance and variogram estimation,
  • implementation and analysis of spherical harmonics, spherical wavelets, etc,
  • various methods for CMB map visualization, such as interactive 3D full sky maps rendered with OpenGL, polygon boundary visualisation, and HEALPix pixel boundary plotting,
  • spherical geometry tools, such as calculation of spherical angles, shortest distance between a point and a region, and shortest distance between two points, etc.

Installation

From CRAN:

## Uncomment to install
#install.packages('rcosmo')

Usage

library(rcosmo)

View the CMBDataFrame help file:

?CMBDataFrame

Download a CMB map from NASA archives (which may take some time to download). Then, take an approximately uniform random sample and create an interactive 3D plot:

downloadCMBMap()
sky <- CMBDataFrame("CMB_map_smica1024.fits", sample.size = 1e6)
plot(sky)

Produce a summary of the map:

summary(sky)

Extract a region of the sky:

win <- CMBWindow(theta = c(pi/2,pi/2,pi/3, pi/3), phi = c(0,pi/3,pi/3,0))
sky_win <- window(sky, new.window = win)
plot(sky_win); plot(win)

Summarise the region of the sky:

summary(sky_win)

More documentation on the way, for now view examples in the help files. There are many functions, see:

lsf.str("package:rcosmo")

Copy Link

Version

Install

install.packages('rcosmo')

Monthly Downloads

201

Version

1.1.6

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Daniel Fryer

Last Published

November 6th, 2026

Functions in rcosmo (1.1.6)

coords.data.frame

Create a new data.frame with a given coordinate system
displayPixelBoundaries

Plot HEALPix pixel boundaries
coords.CMBWindow

Coordinate system from a CMBWindow
corrCMB

Sample correlation function
geo2sph

Convert geographic to spherical coordinates
coords

Coordinate conversion generic
exprob

Threshold exceedance probability
coords.HPDataFrame

Coordinate system from a HPDataFrame
downloadCMBPS

Download CMB Power Spectra from Planck Legacy Archive.
entropyCMB

CMB Entropy
downloadCMBMap

Download CMB Maps from Planck Public Data Release.
covPwSp

Covariance estimate via power spectra
displayPixels

Display the pixels and grandchildren
extrCMB

Extreme values
geoArea.CMBWindow

Geodesic area of a CMBWindow
is.CMBDat

Check if an object is of class CMBDat
geoArea.CMBDataFrame

Geodesic area covered by a CMBDataFrame
is.CMBDataFrame

Check if an object is of class CMBDataFrame
geoAngle

Angle between two spherical directions
geoArea

geoArea generic
geoArea.HPDataFrame

Geodesic area covered by a HPDataFrame
nest2ring

Convert nest to ring ordering
maxWindowDist

Get the maximum distance between all points in a CMBWindow
healpixCentered

Check if object is assumed to have HEALPix centered coordinates
minDist

Get the minimum geodesic distance between points
minDist2nside

minDist2nside
linesCMB

Adds lines of fitted variograms to variogram plots
is.CMBWindow

Check if an object is a CMBWindow
ibp2p

Computes pixel's index using its subindex within base resolution
neighbours

Return neighbouring pixels
maxDist

Get the maximum geodesic distance between points
is.HPDataFrame

Check if an object is of class HPDataFrame
fRen

Sample Renyi function
geoDist

Geodesic distance on the unit sphere
nestSearch

Finds the closest pixel center to a point
header

Get the FITS headers from a CMBDataFrame
fmf

First Minkowski functional
jacobiPol

Calculate Jacobi polynomial values
nside

nside generic
nside.CMBDataFrame

HEALPix Nside parameter from a CMBDataFrame
parent

Return index of parent pixel
pix.CMBDataFrame

HEALPix pixel indices from CMBDataFrame
p2ibp

Return pixel index within its base pixel
pix.HPDataFrame

HEALPix pixel indices from HPDataFrame
ordering<-.HPDataFrame

Assign new ordering scheme to HPDataFrame
nside.HPDataFrame

HEALPix Nside parameter from a HPDataFrame
pix<-

pix generic
ordering<-

ordering generic
nestSearch_step

nestSearch_step
numeric2col

numeric2col
p2bp

Return base pixel to which pixel belongs
ordering

ordering generic
plot.variogram

Plot sample variogram
plot.CMBCovariance

Plot sample CMBCovariance
ordering.CMBDataFrame

HEALPix ordering scheme from a CMBDataFrame
ordering.HPDataFrame

HEALPix ordering scheme from a HPDataFrame
pix2coords

Convert pixel indices to cartesian/spherical coordinates
pix

pix generic
plot.CMBWindow

Visualise a CMBWindow
plot.CMBDataFrame

Plot CMB Data
print.CMBDataFrame

Print CMBDataFrame
print.HPDataFrame

Print a HPDataFrame
pwSpCorr

Power spectra estimate via correlation
plotcovmodelCMB

Plot theoretical CMBCovariance
plot.CMBCorrelation

Plot sample CMBCorrelation
plotAngDis

Plot angular scatterplots and means
print.summary.HPDataFrame

Print a summary of a HPDataFrame
pix<-.CMBDataFrame

Assign new pixel indices to a CMBDataFrame
onBPBoundary

a version of onBPBoundary to use with neighbours
ordering<-.CMBDataFrame

Assign a new ordering scheme to a CMBDataFrame
print.summary.CMBDataFrame

Print a summary of a CMBDataFrame
pixelArea

Area of a HEALPix pixel
pixelWindow

Find high resolution pixels falling in a lower resolution window
plot.HPDataFrame

Plot HPDataFrame
rbind.CMBDataFrame

rbind for CMBDataFrames
qstat

q-statistic
sampleCMB

Take a simple random sample from a CMBDataFrame
qqnormWin

Normal QQ plot for CMBWindow
ring2nest

Convert ring to nest ordering.
qqplotWin

Quantile-Quantile plots for CMBWindows
siblings

Return siblings of pixel
rcosmo

Handling and Analysing CMB data
resolution

Get the arcmin resolution from a CMBDataFrame
practicalRangeCMB

Practical range for covariance function
plotvariogram

Plot theoretical variogram
print.summary.CMBWindow

Print a summary of a CMBWindow
separatingNside

separatingNside
summary.CMBDataFrame

Summarise a CMBDataFrame
subWindow

subWindow
winType

Get/change winType
summary.HPDataFrame

Summarise a HPDataFrame
variofitCMB

Estimates parameters of variograms
summary.CMBWindow

Summarise a CMBWindow
variogramCMB

Sample variogram
sphericalHarmonics

Compute spherical harmonic values at given points on the sphere.
triangulate

Triangulate a polygonal CMBWindow
winType<-

Assign new winType to a CMBWindow
window.CMBDat

Get a sub window from a CMBDat object
window.HPDataFrame

Get a sub window from a HPDataFrame
window.CMBDataFrame

Get a sub window from CMBDataFrame
window.data.frame

Get a sub window from a data.frame
window

window generic
window<-.CMBDataFrame

Assign a new CMBWindow to a CMBDataFrame
window<-

window generic
areCompatibleCMBDFs

Check compatibleness of CMBDataFrames
CMBDat

CMBDat class
CMBWindow

CMBWindow class.
assumedConvex<-

Change the assumedConvex boolean of a CMBWindow
assumedUniquePix

Check if object was assumed to have unique HEALPix indices
assumedConvex

Check if a CMBWindow is assumed convex.
CMBDataFrame

CMBDataFrame class
HPDataFrame

HPDataFrame class
ancestor

Return index of \(k\)th ancestor pixel
as.CMBDataFrame

Convert objects to CMBDataFrame
baseNeighbours

Return neighbours of base pixels
coords<-.CMBDataFrame

Assign new coordinate system to a CMBDataFrame
children

Return children of a pixel
coords<-.data.frame

coords<-

Coordinate conversion generic
borderPattern

Border pattern is resolution independent
coords<-.CMBWindow

Assign new coordinate system to CMBWindow
coords<-.HPDataFrame

Assign new coordinate system to a HPDataFrame
chi2CMB

Chi-squared statistic for two CMBWindows
cbind.CMBDataFrame

cbind for CMBDataFrames
coords.CMBDataFrame

Coordinate system from a CMBDataFrame
covCMB

Sample covariance function
covmodelCMB

Computes values of covariance functions