as.CMBDataFrame: Convert objects to 'CMBDataFrame'

Description Usage Arguments Value Examples

Description

Safely converts a data.frame to a CMBDataFrame. The rows of the data.frame are assumed to be in the HEALPix order given by ordering, and at the HEALPix resolution given by nside. Coordinates, if present, are assumed to correspond to HEALPix pixel centers. The coordinates must be named either x,y,z (cartesian) or theta, phi (spherical colatitude and longitude respectively). If df is a HPDataFrame then it is possible that df has attribute healpixCentered = TRUE, in which case as.CMBDataFrame will perform HEALPix centering of coordinates.

Usage

1
as.CMBDataFrame(df, ordering, nside, spix, drop.coords = FALSE)

Arguments

df

Any data.frame or HPDataFrame whose rows are in HEALPix order

ordering

character string that specifies the ordering scheme ("ring" or "nested")

nside

an integer 2^k that specifies the Nside (resolution) HEALPix parameter

spix

an integer vector that specifies the HEALPix pixel index corresponding to each row of df. If spix is left blank and df is a data.frame, then df is assumed to contain data for every pixel at resolution parameter nside (the full sky). In other words, in this case, the number of rows of df must be equal to 12*nside^2. However, if spix is left blank and df is a CMBDataFrame, then spix is set equal to pix(df)

drop.coords

A logical. If df is a HPDataFrame then it is possible that df has attribute healpixCentered = TRUE, in which case as.CMBDataFrame will perform HEALPix centering of coordinates. If drop.coords = TRUE then this will be done by dropping existing coordinates entirely (quicker) to rely only on HEALPix pixel indices. Otherwise if drop.coords = FALSE this will be done by replacing existing coordinates with locations of HEALPix pixel centers.

Value

A CMBDataFrame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Example 1: Create df with no coords, then create CMBDataFrames cmbdf and
## df2 with spherical coords

df <- data.frame(I=rnorm(12))
df

cmbdf <- as.CMBDataFrame(df,ordering= "ring", nside=1)
summary(cmbdf)
pix(cmbdf)
coords(cmbdf)

df2 <- coords(cmbdf, new.coords = "spherical")
df2

## Example 2: Create CMBDataFrames for first 10 Healpix centers

df <- data.frame(I=rnorm(10))
df
cmbdf <- as.CMBDataFrame(df,ordering= "ring", nside=2, spix=1:10)
summary(cmbdf)
pix(cmbdf)

frycast/rcosmo documentation built on June 4, 2019, 5:13 p.m.