+1 vote
438 views
I understand that one way would be to do a cross-match with the survey's catalog with a large enough radius. But what I have in mind is rather to visualise whether my source is inside or outside the DECALS contours shown e.g. here: https://datalab.noao.edu/survey.php
| 438 views

Thank you for reaching out.

There are several way to achieve this. One idea would be to check if your RA+Dec coordinates fall within a healpix ID that has any objects from the survey in it. This is of course approximative, but with nside=4096 the healpixels are only ~52 arcseconds along the side.

Example:

```# imports
from astropy_healpix import HEALPix
from astropy.coordinates import ICRS, SkyCoord
from dl import queryClient as qc

# make hp instance with ICRS frame
hp = HEALPix(nside=4096,order='nested',frame=ICRS())

# instantiate a coordinate object from RA and Dec position
ra = 323.17
dec = -16.73
c = SkyCoord(frame=ICRS, ra=ra, dec=dec, unit='deg')
print('My coordinates:',c)

# compute healpix ID from coordinates
hpid = hp.skycoord_to_healpix(c)
print('Corresponding healpix ID:', hpid)

# query ls_dr8.tractor table to see if healpix ID is populated by any survey object
hit = qc.query('select exists(select nest4096 from ls_dr8.tractor where nest4096=%d)' % hpid).split()[1]
print('Coordinates in a populated healpix? -->', hit)```

Output:

```My coordinates: <SkyCoord (ICRS): (ra, dec) in deg (323.17, -16.73)>
Corresponding healpix ID: 198924159
Coordinates in a populated healpix? --> t```

Try different RA/Dec:

```# try other coordinates
ra, dec = 323.0, -16.87
c = SkyCoord(frame=ICRS, ra=ra, dec=dec, unit='deg')
print('My coordinates:',c)
hpid = hp.skycoord_to_healpix(c)
print('Corresponding healpix ID:', hpid)
hit = qc.query('select exists(select nest4096 from ls_dr8.tractor where nest4096=%d)' % hpid).split()[1]
print('Coordinates in a populated healpix? -->', hit)
```

Output:

```My coordinates: <SkyCoord (ICRS): (ra, dec) in deg (323., -16.87)>
Corresponding healpix ID: 198924160
Coordinates in a populated healpix? --> f
```

Please let us know if this helped.
Robert

by robertdemo (8.1k points)
edited by 226