%matplotlib inline
%config InlineBackend.figure_formats=['svg']
import matplotlib
matplotlib.rcParams['figure.figsize'] = (9, 6)
import numpy as np
from matplotlib import pyplot as plt
from astropy import units as u
from astropy import coordinates as coord
from astropy.table import Column
from astroquery.vizier import Vizier
We have a dense catalogue of galaxies in which we want to flag those that are near bright stars (because they may corrupt their magnitude). We want the flagging radius to be dependent on the r magnitude of the stars, with the prescription:
$$radius[arcsec] = \exp(-0.43 * r_{mag} + 8.4)$$Don't worry, it's only an excuse to play with numpy array indices.
Numpy arrays may be indexed with a list of integers corresponding to the indexes of the elements you want (see documentation).
number_names = np.array(['zero', 'one', 'two', 'three', 'four', 'five'])
print(number_names[[3, 0, 0, 1, 2, 5, 5, 4]])
We will use the SDSS9 catalogue as a dense catalogue of galaxies, and will use the Tycho-2 catalogue to get our stars. We get these catalogues directly from Vizier.
Vizier.ROW_LIMIT = -1 # If we don't do that, Vizier only send 50 rows.
region_center = coord.SkyCoord(34.8*u.deg, -4.4*u.deg)
sdss9, tycho2 = Vizier.query_region(region_center, width="40m", catalog=['sdss9', 'tycho2'])
plt.plot(sdss9['RAJ2000'], sdss9['DEJ2000'], "bo",
markeredgecolor='None', alpha=.5, label="SDSS9 galaxies")
plt.plot(tycho2['RAmdeg'], tycho2['DEmdeg'], "y*",
label="Tycho2 stars", markersize=14)
plt.xlabel("RA")
plt.ylabel("Dec")
plt.legend()