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)
In [6]:
result = Irsa.query_region(objname, catalog="fp_xsc", spatial="Cone", radius= theta * u.deg)
result
Out[6]:
In [7]:
coord = coordinates.SkyCoord(ra=ra, dec=dec, unit=(u.deg, u.deg))
In [8]:
plot_cone(coord, theta, result)
In [ ]: