# healpy.pixelfunc.ang2pix¶

`healpy.pixelfunc.``ang2pix`(nside, theta, phi, nest=False, lonlat=False)

Parameters: nside : int, scalar or array-like The healpix nside parameter, must be a power of 2, less than 2**30 theta, phi : float, scalars or array-like Angular coordinates of a point on the sphere nest : bool, optional if True, assume NESTED pixel ordering, otherwise, RING pixel ordering lonlat : bool If True, input angles are assumed to be longitude and latitude in degree, otherwise, they are co-latitude and longitude in radians. pix : int or array of int The healpix pixel numbers. Scalar if all input are scalar, array otherwise. Usual numpy broadcasting rules apply.

Examples

```>>> import healpy as hp
>>> hp.ang2pix(16, np.pi/2, 0)
1440
```
```>>> hp.ang2pix(16, [np.pi/2, np.pi/4, np.pi/2, 0, np.pi], [0., np.pi/4, np.pi/2, 0, 0])
array([1440,  427, 1520,    0, 3068])
```
```>>> hp.ang2pix(16, np.pi/2, [0, np.pi/2])
array([1440, 1520])
```
```>>> hp.ang2pix([1, 2, 4, 8, 16], np.pi/2, 0)
array([   4,   12,   72,  336, 1440])
```
```>>> hp.ang2pix([1, 2, 4, 8, 16], 0, 0, lonlat=True)
array([   4,   12,   72,  336, 1440])
```