def fetch_gaia_catalogue(center, radius, extracolumns=[], column_filters={}, **kwargs): """ "query the gaia catalogue thought Vizier (I/337, DR1) using astroquery. This function requieres an internet connection. Parameters ---------- center: [string] 'ra dec' position of the center of the catalogue to query. radius: [string] 'value unit' radius of the region to query. For instance '1d' means a 1 degree raduis extracolumns: [list-of-string] -optional- Add extra column from the V/139 catalogue that will be added to the basic query (default: position, ID, object-type, magnitudes) column_filters: [dict] -optional- Selection criterium for the queried catalogue. **kwargs goes to astroquery.vizier.Vizier Returns ------- SDSSCatalogue (child of Catalogue) """ try: from astroquery import vizier except: raise ImportError("install astroquery. (pip install astroquery)") # Basic Info # -------------- columns = [ "RA_ICRS", "DE_ICRS", "e_RA_ICRS", "e_DE_ICRS", "Source", "Dup", "o_<Gmag>", "<FG>", "e_<FG>", "<Gmag>", "Var" ] columns = columns + extracolumns column_quality = {} # Nothing there yet c = vizier.Vizier(catalog="I/337/gaia", columns=columns, column_filters=kwargs_update(column_quality, **column_filters), **kwargs) c.ROW_LIMIT = "unlimited" t = c.query_region(center, radius=radius).values()[0] cat = GAIACatalogue(empty=True) cat.create(t.columns, None, key_ra="RA_ICRS", key_dec="DE_ICRS") return cat
def download_catalog(cls, radec, radius=1, r_unit="deg", columns=None, column_filters={'Gmag': '10..20'}): """ """ from astroquery import vizier from astropy import coordinates, units # Check that it's good format ra, dec = np.asarray(radec, dtype="float") if columns is None: columns = [ "Source", "PS1", "SDSSDR13", "RA_ICRS", "DE_ICRS", "Gmag", "e_Gmag", "GmagCorr", "RPmag", "e_RPmag", "BPmag", "e_BPmag", "FG", "e_FG", "FGCorr", "FRP", "e_FRP", "FBP", "e_FBP", "Plx", "e_Plx", "PM", "pmRA", "e_pmRA", "pmDE", "e_pmDE" ] # Clean names mv_columns = {c: c.lower() for c in columns} mv_columns["RA_ICRS"] = "ra" mv_columns["DE_ICRS"] = "dec" if "PS1" in columns: mv_columns["PS1"] = "ps1_id" if "SDSSDR13" in columns: mv_columns["SDSSDR13"] = "sdssdr13_id" # # Downloading coord = coordinates.SkyCoord(ra=ra, dec=dec, unit=(units.deg, units.deg)) angle = coordinates.Angle(radius, r_unit) v = vizier.Vizier(columns, column_filters=column_filters) v.ROW_LIMIT = -1 # cache is False is necessary, notably when running in a computing center. gaiatable = v.query_region(coord, radius=angle, catalog=cls.VIZIER_CAT, cache=False) if gaiatable is None: raise IOError( f"cannot query the region {ra}, {dec} of {radius}{r_unit} for {catalog}" ) gaiatable = gaiatable.values() if len(gaiatable) == 0: raise IOError( f"querying the region {ra}, {dec} of {radius}{r_unit} for {catalog} returns 0 entries" ) gaiatable = gaiatable[0] gaiatable['colormag'] = gaiatable['BPmag'] - gaiatable['RPmag'] # - # return gaiatable.to_pandas().set_index('Source').rename(mv_columns, axis=1)
def fetch_gaia_catalogue(self, radius, r_unit="deg", extracolumns=["Var"], column_filters={"Gmag": "0..25"}, **kwargs): """ query online gaia-catalogue in Vizier (I/345, DR2) using astroquery. This function requieres an internet connection. Parameters ---------- center: [string] 'ra dec' position of the center of the catalogue to query. radius: [string] 'value unit' radius of the region to query. For instance '1d' means a 1 degree raduis extracolumns: [list-of-string] -optional- Add extra column from the V/139 catalogue that will be added to the basic query (default: position, ID, object-type, magnitudes) column_filters: [dict] -optional- Selection criterium for the queried catalogue. **kwargs goes to astroquery.vizier.Vizier Returns ------- GAIA Catalogue (child of Catalogue) """ columns = [ "Source", "RA_ICRS", "e_RA_ICRS", "DE_ICRS", "e_ED_ICRS", "Var" ] #for band in SDSS_INFO["bands"]: #try: coord = SkyCoord(ra=self.ra, dec=self.dec, unit=(u.deg, u.deg)) angle = Angle(radius, r_unit) v = vizier.Vizier(columns, column_filters=column_filters) v.ROW_LIMIT = -1 t = v.query_region(coord, radius=angle, catalog="I/345/gaia2").values()[0] return t
def vizier_query(OBJECT, PHOTCAT, CATPROP, ROW_LIMIT=-1, RADIUS=10. * u.arcmin): v = vizier.Vizier(columns=CATPROP[PHOTCAT]['INPUT'], catalog=CATPROP[PHOTCAT]['CATID'], row_limit=ROW_LIMIT) result = v.query_region(coord.SkyCoord(OBJECT['ra'], OBJECT['dec'], unit=u.deg), radius=RADIUS) if len(result) > 0: try: result = result[CATPROP[PHOTCAT]['CATID_OUT']][CATPROP[PHOTCAT] ['OUTPUT']] return result except: return table.Table(names=CATPROP[PHOTCAT]['OUTPUT']) else: return table.Table(names=CATPROP[PHOTCAT]['OUTPUT'])
def fetch_wise_catalogue(center, radius, extracolumns=[], column_filters={"Jmag": "5..30"}): """ query online wise-catalogue in Vizier (II/328) using astroquery. This function requieres an internet connection. Parameters ---------- center: [string] 'ra dec' position of the center of the catalogue to query. radius: [string] 'value unit' radius of the region to query. For instance '1d' means a 1 degree raduis extracolumns: [list-of-string] -optional- Add extra column from the II/328 catalogue that will be added to the basic query (default: position, ID, magnitudes) column_filters: [dict] -optional- Selection criterium for the queried catalogue. **kwargs goes to astroquery.vizier.Vizier Returns ------- WISECatalogue (child of Catalogue) """ try: from astroquery import vizier except: raise ImportError("install astroquery. (pip install astroquery)") # ----------- # - DL info columns = [ "AllWISE", "ID", "RAJ2000", "DEJ2000", ] for band in ["J", "H", "K", "W1", "W2", "W3", "W4"]: columns.append("%smag" % band) columns.append("e_%smag" % band) columns = columns + extracolumns # - WARNING if discovered that some of the bandmag were missing if too many colums requested c = vizier.Vizier(catalog="II/328", columns=columns, column_filters=column_filters, **kwargs) c.ROW_LIMIT = 100000 try: t = c.query_region(center, radius=radius).values()[0] except: raise IOError( "Error while querying the given coords. You might not have an internet connection" ) cat = WISECatalogue(empty=True) cat.create(t.columns, None, key_class="ToBeDone", value_star=None, key_ra="RAJ2000", key_dec="DEJ2000") return cat
def fetch_sdss_catalogue(center, radius, extracolumns=[], column_filters={"rmag": "5..25"}, **kwargs): """ query online sdss-catalogue in Vizier (V/139, DR9) using astroquery. This function requieres an internet connection. Parameters ---------- center: [string] 'ra dec' position of the center of the catalogue to query. radius: [string] 'value unit' radius of the region to query. For instance '1d' means a 1 degree raduis extracolumns: [list-of-string] -optional- Add extra column from the V/139 catalogue that will be added to the basic query (default: position, ID, object-type, magnitudes) column_filters: [dict] -optional- Selection criterium for the queried catalogue. **kwargs goes to astroquery.vizier.Vizier Returns ------- SDSSCatalogue (child of Catalogue) """ from .sdss import SDSS_INFO try: from astroquery import vizier except: raise ImportError("install astroquery. (pip install astroquery)") # ----------- # - DL info columns = [ "cl", "objID", #"SDSS9", "RAJ2000", "e_RAJ2000", "DEJ2000", "e_DEJ2000", #"ObsDate","Q"#"mode", ] for band in SDSS_INFO["bands"]: columns.append("%smag" % band) columns.append("e_%smag" % band) columns = columns + extracolumns column_quality = {"mode": "1", "Q": "2.3"} # - WARNING if discovered that some of the bandmag were missing if too many colums requested c = vizier.Vizier(catalog="V/139", columns=columns, column_filters=kwargs_update(column_quality, **column_filters), **kwargs) c.ROW_LIMIT = "unlimited" #try: t = c.query_region(center, radius=radius).values()[0] #except : # raise IOError("Error while querying the given coords. You might not have an internet connection") cat = SDSSCatalogue(empty=True) cat.create(t.columns, None, key_class="cl", value_star=6, key_id="objID", key_ra="RAJ2000", key_dec="DEJ2000") return cat
import astropy.units as au import astropy.coordinates as ac import astroquery.vizier as av # obtain a list of available Vizier catalogues with a reference to Gaia DR2 cat_list = av.Vizier.find_catalogs("Gaia DR2") print({k: v.description for k, v in cat_list.items()}) # define a sky-coordinate of our position and make a first query: sky_coord = ac.SkyCoord(ra=210.0, dec=-10.0, unit=(au.deg, au.deg)) # do a first query with a radius of 0.05 deg around our position # with 'all' quantities available. # # The '**' for the columns means 'all available quantities' gaia_query = av.Vizier(columns=["**"]) first_query = gaia_query.query_region(sky_coord, radius=0.05 * au.deg, catalog='I/345') #first_query = gaia_query.query_region(sky_coord, # width=0.05 * au.deg, # height=0.05 * au.deg, # catalog='I/345') # print(first_query) print(first_query['I/345/gaia2']) # Note: Please run the notebook yourself to see the output of the # following cell. It would be too big and not really useful here.