healpy / healpy

Python healpix maps tools
healpy.readthedocs.org
GNU General Public License v2.0
262 stars 187 forks source link

ring-to-nest confusion #418

Closed DanielLenz closed 7 years ago

DanielLenz commented 7 years ago

(I've also posted this as a question on stackoverflow, since I'm quite sure that I misunderstood something. Feel free to post there as well and I'll gladly accept the answer.)

I've been working with superpixel masking and ran into something that appeared odd to me. When trying to reproduce the top two panels of Gorski+ (2002, Fig. 4), I did the following:

# This plot shows us the pixels 4, 5, 6, 7 and matches the illustration in the
# Gorski+ (2002) paper, Fig. 4, top two panels

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

fig, (ax1, ax2, ax3) = plt.subplots(figsize=(14, 14), nrows=3)

nside = 2
npix = hp.nside2npix(nside)

hpkw = dict(min=3, max=8, cmap='jet', rot=[-180, 0], flip='geo', hold=True)

plt.axes(ax1)
hp.cartview(np.arange(npix), title='Input ring ordering', **hpkw)

plt.axes(ax2)
hp.cartview(hp.reorder(np.arange(npix), r2n=True), title='ring-to-nest converted', **hpkw)

plt.axes(ax3)
hp.cartview(hp.reorder(np.arange(npix), n2r=True), title='nest-to-ring converted', **hpkw)
plt.show()

That gives me this figure, which shows that the conversion of the ordering scheme with 'ring2nest' does not work, but 'nest2ring' does, even though the input map is in ring ordering.

What am I missing here?

zonca commented 7 years ago

When you plot NESTED you need to set nest=True

Il ven 27 ott 2017, 20:50 Daniel notifications@github.com ha scritto:

I've been working with superpixel masking and ran into something that appeared odd to me. When trying to reproduce the top two panels of Gorski+ (2002, Fig. 4) http://iopscience.iop.org/article/10.1086/427976/pdf, I did the following:

This plot shows us the pixels 4, 5, 6, 7 and matches the illustration in the

Gorski+ (2002) paper, Fig. 4, top two panels

fig, (ax1, ax2, ax3) = plt.subplots(figsize=(14, 14), nrows=3)

hpkw = dict(min=3, max=8, cmap='jet', rot=[-180, 0], flip='geo', hold=True)

plt.axes(ax1) hp.cartview(np.arange(npix1), title='Input ring ordering', **hpkw)

plt.axes(ax2) hp.cartview(hp.reorder(np.arange(npix1), r2n=True), title='ring-to-nest converted', **hpkw)

plt.axes(ax3) hp.cartview(hp.reorder(np.arange(npix1), n2r=True), title='nest-to-ring converted', **hpkw) plt.show()

That gives me this figure https://github.com/healpy/healpy/files/1423096/ring_nest_conversion.pdf, which shows that the conversion of the ordering scheme with 'ring2nest' does not work, but 'nest2ring' does, even though the input map is in ring ordering.

What am I missing here?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/healpy/healpy/issues/418, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXYctoqHX0vkHngwmcomMv0W8LlpWsyks5swiX0gaJpZM4QJeGJ .

DanielLenz commented 7 years ago

Thanks for the quick solution!