Eric Chassande-Mottin
Eric Chassande-Mottin

Reputation: 105

inconsistent definition of longitude and latitude for healpy.pixelfunc.get_interp_val() or healpy.mollview()?

when I rotate a Healpix map along longitude or latitude, I get the wrong behavior. I'm probably missing something obvious here but so far, I failed to find what.

See demo:

import numpy as np
import healpy as hp
import matplotlib.pyplot as plt

nside = 4
npix = hp.nside2npix(nside)

idx = 70
offset = 1 # rad

# set one pixel to 1 in the map
data = np.array(np.equal(np.arange(npix), idx), dtype=float)

hp.mollview(data, nest=True, title='original')

# longitude and co-latitude in radians
theta, phi = hp.pix2ang(nside, np.arange(npix), nest=True)

# rotate: offset on longitude, keep co-latitude the same
rotated = hp.get_interp_val(data, theta + offset, phi, nest=True)

hp.mollview(rotated, nest=True, title='rotated longitude')

# rotate: keep longitude the same, offset on co-latitude
rotated = hp.get_interp_val(data, theta, phi+offset, nest=True)

hp.mollview(rotated, nest=True, title='rotated latitude')

and results:

The dot in the map rotated along longitude is translated vertically, while it is translated horizontally for the rotation along latitude. I'd expect the reverse.

Any hint about what's wrong here?

E.

Upvotes: 1

Views: 304

Answers (1)

Andrea Zonca
Andrea Zonca

Reputation: 8773

Theta is co-latitude, Phi is longitude. It is confusing because their order is inverted than what we usually expect. In fact even in healpy, for example in pix2ang if you set lonlat to true, you get as outputs first Longitude and then Latitude. Unfortunately this is the convention and we have to stick to this.

Upvotes: 1

Related Questions