coords.HPDataFrame: Coordinate system from a 'HPDataFrame'

Description Usage Arguments Details Value Examples

View source: R/HPDataFrame.R

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

1
2
## S3 method for class '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.

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.

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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)

rcosmo documentation built on Dec. 11, 2021, 9:29 a.m.