rcosmo (version 1.1.2)

coords.HPDataFrame: Coordinate system from a HPDataFrame

Description

Add or change coordinates in a HPDataFrame. This does not affect the argument object hpdf. Instead it returns a new HPDataFrame with the desired coordinates. To change hpdf directly see coords<-.HPDataFrame.

Usage

# S3 method for HPDataFrame
coords(x, new.coords, healpixCentered = FALSE, ...)

Arguments

x

a HPDataFrame, hpdf.

new.coords

specifies the new coordinate system ("spherical" or "cartesian")

healpixCentered

boolean. If TRUE then columns x,y,z or theta, phi will be ignored and removed if present. This forces the coordinates to be found from HEALPix pixel indices only. Then the HEALPixCentered attribute of hpdf will be set to TRUE.

...

Unused arguments.

Value

A HPDataFrame with columns x,y,z (cartesian) or theta, phi (colatitude and longitude respectively)

Details

If columns exist labelled x,y,z (cartesian) or theta, phi (colatitude and longitude respectively), then these will be treated as the coordinates of hpdf and converted accordingly. If columns x,y,z or theta,phi are not present then the healpix pixel indices as given by pix(hpdf) are used for assigning coordinates.

Examples

Run this code
# NOT RUN {
df <- HPDataFrame(I = rep(0,12), nside = 1)
coords(df, new.coords = "cartesian")
# Notice that df is unchanged
df

# Instead, change df directly
coords(df) <- "spherical"

## specify cartesian coordinates then convert to spherical
hp1 <- HPDataFrame(x = c(1,0,0), y = c(0,1,0), z = c(0,0,1),
                   nside = 1, auto.spix = TRUE)
hp1 <- coords(hp1, new.coords = "spherical")

## Instead, ignore/drop existing coordinates and use HEALPix only
hp2 <- HPDataFrame(x = c(1,0,0), y = c(0,1,0), z = c(0,0,1),
                   nside = 1, auto.spix = TRUE)
hp2 <- coords(hp1, new.coords = "spherical", healpixCentered = TRUE)

# }

Run the code above in your browser using DataLab