CMBDataFrame
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.
as.CMBDataFrame(df, ordering, nside, spix, drop.coords = FALSE)
Any data.frame
or HPDataFrame
whose rows are
in HEALPix order
character string that specifies the ordering scheme ("ring" or "nested")
an integer
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)
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.
A CMBDataFrame
# NOT RUN {
## 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)
# }
Run the code above in your browser using DataLab