In [1]:
import sys
sys.path.append('../alma-calibrator/src/utils/')

from galenv import *

from astroquery.irsa import Irsa

%matplotlib inline

In [2]:
def plot_cone(coord, theta, res, xSize=7.5, ySize=7.5, title='', show=True, savefig=False, imgname="plot.png"):
        '''Only cone
        coord = astropy coordinates
        theta = Cone angle
        res = result catalog
        '''
        ra = coord.ra.value
        dec = coord.dec.value

        fig = plt.figure(figsize=(xSize, ySize))        
        gs = gridspec.GridSpec(1, 1)
        
        ax = plt.subplot(gs[0])
        # ax.axis('equal')
        limangle = 1.5*theta
        ax.set_xlim((ra-limangle, ra+limangle))
        ax.set_ylim((dec-limangle, dec+limangle))
        
        # Central position/object
        ax.plot(ra, dec, 'ro', alpha=0.5)
        
        # Catalog object
        ax.plot(res['ra'], res['dec'], 'k.')
        
        plt.gca().invert_xaxis() # RA from E to W
        ax.set_xlabel('RA (deg)')
        ax.set_ylabel('DEC (deg)')
        plt.title(title)

        # Circle
        # it is wrong if I draw a circle around (ra, dec) with radius theta
        # due to small circle in celestial sphere for DEC
        circle = plt.Circle((ra, dec), theta, fc='none', ec='black')
        ax.add_artist(circle)
        
        fig.tight_layout()

        if savefig:
            plt.savefig(imgname)

        if show:
            plt.show()

        plt.close()

In [3]:
ga = Galenv()

In [4]:
objname = "3C 279"
tangential_dist = 5.0 # Mpc

In [5]:
z, v0, ra, dec = ga.queryobject_byname(objname)
print(z, v0, ra, dec)

dA, theta = ga.calc_dA_theta(z, tangential_dist)
print(dA, theta)


0.5362 160749.0 194.04653 -5.78931
1344.817110605312 0.21302442934895835

In [6]:
result = Irsa.query_region(objname, catalog="fp_xsc", spatial="Cone", radius= theta * u.deg)

result


Out[6]:
Table masked=True length=2
designationradecclonclatsup_rasup_decglonglatdensityr_k20fej_m_k20fej_msig_k20fej_flg_k20feh_m_k20feh_msig_k20feh_flg_k20fek_m_k20fek_msig_k20fek_flg_k20fek_bak_phisup_basup_phir_extj_m_exth_m_exth_msig_extk_m_extk_msig_extcc_flgdistangleid
degdegdegdegdegdegarcsmagmagmagmagmagmagdegdegarcsmagmagmagmagmagarcsdeg
objectfloat64float64objectobjectfloat64float64float64float64float64float64float64float64int32float64float64int32float64float64int32float64int32float64int32float64float64float64float64float64float64objectfloat64float64object
12555264-0549194193.969-5.82212h55m52.65s-05d49m19.46s193.969269-5.822131304.96157.0322.755.514.7120.064014.0280.078013.7780.12100.6351.09010.4814.36513.6410.09713.6140.1910300.498795246.8872350
12563258-0545041194.136-5.75112h56m32.59s-05d45m04.10s194.135757-5.751063305.2757.0972.685.215.2650.119014.6360.161013.8810.1601.0901.09010.315.10814.380.23513.6540.2410347.93133566.7422591

In [7]:
coord = coordinates.SkyCoord(ra=ra, dec=dec, unit=(u.deg, u.deg))

In [8]:
plot_cone(coord, theta, result)



In [ ]: