Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/esheldon/healpix_util
Some python tools to work with healpix
https://github.com/esheldon/healpix_util
Last synced: 11 days ago
JSON representation
Some python tools to work with healpix
- Host: GitHub
- URL: https://github.com/esheldon/healpix_util
- Owner: esheldon
- Created: 2014-08-03T15:00:10.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-10-13T15:25:39.000Z (about 4 years ago)
- Last Synced: 2024-10-19T19:37:02.379Z (19 days ago)
- Language: C
- Homepage:
- Size: 85.9 KB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
healpix
=======Some tools to work with healpix.
Note reader utilities use camelCase to avoid name collision
with the healpy readers.a few examples
==============```python
import healpix_util as hu# create a HealPix object. This will carry around the nside, scheme, npix,
# etc.hpix=hu.HealPix("ring", 4096)
print(hpix)
scheme: 1
scheme_name: RING
nside: 4096
npix: 201326592
ncap: 33546240
area: 6.24178e-08 square degrees
area: 0.000224704 square arcmin
area: 0.808935 square arcsec# has many attributes, e.g. .scheme, .nside, .npix, .area, etc.
# find pixel number for input ra,dec arrays
pixnums = hpix.eq2pix(ra, dec)
ra, dec = hpix.pix2eq(pixnums)# or for theta,phi
pixnums = hpix.ang2pix(theta, phi)
theta, phi = hpix.pix2ang(pixnums)# query disc
pixnums = hpix.query_disc(ra, dec, radius_degrees)
pixnums = hpix.query_disc(ra, dec, radius_degrees, inclusive=True)
pixnums = hpix.query_disc(theta, phi, radius_radians, system='ang')# load a healpix.Map object
m = hu.readMap(filename)
m = hu.readMap(filename, column='I')# load multiple Maps into an ordered dict, keyed by column name
maps=hu.readMaps(filename)
maps=hu.readMaps(filename,columns=["I","Q"])# convert between schemes
mnest = m.convert("nest")
mring = m.convert("ring")# find the mapval for the input coordinates
mapvals = m.get_mapval(ra, dec)
mapvals = m.get_mapval(theta, phi, system='ang')# load a healpix.DensityMap, a special map that represents
# a spatial density
dmap=hu.readDensityMap(filename)
dmaps=hu.readDensityMaps(filename)# generate random points from the map
ra,dec = dmap.genrand(100000)# limit the range to a region known to have non-zero density, or
# weight. This will speed it up greatly
ra,dec = dmap.genrand(100000, ra_range=[60.,95.], dec_range=[-62.,-42.])# generate randoms in theta,phi
theta,phi = dmap.genrand(100000, system='ang', theta_range=tr, phi_range=pr)# healpy routines are pulled into the healpix_util namespace
npix=hu.nside2npix(nside)# obscure features
# check quadrants around the input points
# make sure weighted position ellipticity in adjacent quadrants
# less than 0.05
ellip_max=0.05
for i in xrange(ra.size):
maskflags[i] = dmap.check_quad(ra[i], dec[i], radius_degrees[i], ellip_max)# see docs on quad_check
# checking maskflags > 1 indicates the cluster is "good", but note during
# a lensing measurement you should be careful to always use sources from
# the same pair of quadrants (unless all are good)
```dependencies
============
- numpy
- healpy
- fitsio # for file reading