Skip to content Skip to sidebar Skip to footer

Plotting A Numpy Array In Healpy

I am attempting to produce a beam on a healpix map, using healpy. For starters, I would like to be able to produce a 2D gaussian in a mollweide projection, but I really don't know

Solution 1:

here is how I do this:

using a small trick. I insert a point at the desired Gaussian centrer and then I use "smearing" to create a Gaussian with some sigma.

Here is some example:

#!/usr/bin/env python
import numpy as np
import healpy as hp
import pylab as pl

NSIDE=512 #the map garannularity

m_sm=np.arange(hp.nside2npix(NSIDE)) # creates the map
m_sm=m_sm*0. # sets all values to zero

theta=np.radians(80.) # coordinates for the gaussian
phi=np.radians(20.)

indx=hp.pixelfunc.ang2pix(NSIDE,theta,phi) # getting the index of the point corresponding to the coordinates
m_sm[indx]=1. # setting that point value to 1.

gmap=hp.smoothing(m_sm, sigma=np.radians(20.),verbose=False,lmax=1024) # creating a new map, smmeared version of m_sm

hp.mollview(gmap, title="Gaussian Map") #draw it
pl.show()

now if you want to do that by hand, you would use a function for a gaussian

1) you feed it some coordinates

2) you retrieve the index corresponding to that coordinate using:

indx=hp.pixelfunc.ang2pix(NSIDE,theta,phi)

3) you set the value for that point to the value from your gaussian function. i.e.:

my_healpy_map[indx]=my_gauss(theta, phy, mean_theta, mean_phy, sigma_theta, sigma_phy)

Post a Comment for "Plotting A Numpy Array In Healpy"