ywyw / dat-wise

Importer for the WISE All-Sky Data Products
3 stars 3 forks source link

dat-wise

A dat importer for the all-sky data release from WISE

Disclaimer: Work in progress

columns.csv has the metadata for the WISE data

Thanks to Starlink for parsing the column names!

To run the demo, download the following:

Docker image

Download an example FITS file here:

curl http://lambda.gsfc.nasa.gov/data/map/dr4/ancillary/masks/wmap_temperature_analysis_mask_r9_7yr_v4.fits -o example.fits

usage: username, databasename

python healpixdb.py "Y" "tempdb"

POSTGRES schema: nside | npix | ipix | filename

This should insert all the healpixels into a POSTGRES database of your naming and print them out.

Demo for ra/dec to healpix geohash:

import numpy
import healpy
m = numpy.arange(healpy.nside2npix(4))
healpy.mollview(m, nest=True, title="Mollview image NESTED")
nside = 4
(theta,phi) = radec2polar(60,-1.25)
ipix = polar2healpix(theta,phi,nside)
(binnum, remainder) = ipix2tuple(ipix,nside)
print tuple2hash(binnum,remainder)
bounds = healpy.boundaries(1,0,nest=True,step=1)
vectranspose = bounds.T
numpy.array(healpy.vec2ang(vectranspose))
map(polar2radec, numpy.array(healpy.vec2ang(vectranspose)).T)

For a bbox query of npix = 12 resolution:

simplequery(ramin,decmin,ramax,decmax)

For a query returning minimum resolution healpix:

fullquerywrap(ramin,decmin,ramax,decmax,nsidemin)

Breakdown of bounding box query cases:

All possible intersections of a rectangular query against a curved Healpix are as follows:

Case one

This case is handled by testing each Healpix corner and seeing if it's within range of the bounding box, which is easy

Case two

This case is done by the radec2healpix function, which tests each corner of the bbox and sees if it lands within the Healpix in question, also straightforward

Case three

This is an edge case that took some consideration, when no corners of either fall within the other, this is a fairly fast and easy way to avoid complex math and dealing with curved Healpix edges

A fourth case occurs when the Healpix is entirely inside the bounding box, and here, we decide not to divide this pixel further in the recursive set algorithm.

WIP