How to use the astroquery.vizier.Vizier function in astroquery

To help you get started, we’ve selected a few astroquery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Stargrazer82301 / CAAPR / CAAPR_AstroMagic / PTS / pts / magic / tools / catalogs.py View on Github external
:param catalog:
    :param keywords:
    :param radius:
    :param limit:
    :param column_filters:
    :return:
    """

    # Define the center coordinate for the box
    coordinate = SkyCoordinate(ra=box[0], dec=box[1], unit="deg", frame="fk5") # frame: icrs, fk5... ?

    # Make a Vizier object
    if column_filters is None:
        viz = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'], keywords=keywords)
    else:
        viz = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'], column_filters=column_filters, keywords=keywords)

    # No limit on the number of entries
    viz.ROW_LIMIT = limit if limit is not None else -1

    # Query the box of our image frame
    result = viz.query_region(coordinate.to_astropy(), width=box[3] * Unit("deg"), height=box[2] * Unit("deg"), catalog=catalog)

    region_string = "# Region file format: DS9 version 3.0\n"
    region_string += "global color=green\n"

    # Result may contain multiple tables (for different catalogs)
    for table in result:

        # For every entry in the table
        for entry in table:
github RadioAstronomySoftwareGroup / pyuvsim / reference_simulations / get_gleam.py View on Github external
import sys

try:
    from astroquery.vizier import Vizier
except ImportError as e:
    raise ImportError("astroquery module required to use the download_gleam script") from e

catalog_dir = "first_generation/catalog_files/"
name = "gleam.vot"

opath = os.path.join(catalog_dir, name)
if os.path.exists(opath):
    print("GLEAM already downloaded to {}.".format(opath))
    sys.exit()
Vizier.ROW_LIMIT = -1
Vizier.columns = ['GLEAM', 'RAJ2000', 'DEJ2000', 'Fintwide']
catname = 'VIII/100/gleamegc'
tab = Vizier.get_catalogs(catname)[0]
tab.write(opath, format='votable')

print("GLEAM catalog downloaded and saved to " + opath)
github Stargrazer82301 / CAAPR / CAAPR_AstroMagic / PTS / pts / magic / tools / catalogs.py View on Github external
This function ...
    :param box:
    :param catalog:
    :param keywords:
    :param radius:
    :param limit:
    :param column_filters:
    :return:
    """

    # Define the center coordinate for the box
    coordinate = SkyCoordinate(ra=box[0], dec=box[1], unit="deg", frame="fk5") # frame: icrs, fk5... ?

    # Make a Vizier object
    if column_filters is None:
        viz = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'], keywords=keywords)
    else:
        viz = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'], column_filters=column_filters, keywords=keywords)

    # No limit on the number of entries
    viz.ROW_LIMIT = limit if limit is not None else -1

    # Query the box of our image frame
    result = viz.query_region(coordinate.to_astropy(), width=box[3] * Unit("deg"), height=box[2] * Unit("deg"), catalog=catalog)

    region_string = "# Region file format: DS9 version 3.0\n"
    region_string += "global color=green\n"

    # Result may contain multiple tables (for different catalogs)
    for table in result:

        # For every entry in the table
github waqasbhatti / astrobase / astrobase / services / limbdarkening.py View on Github external
if not 2300 < teff < 12000:
        if teff < 15000:
            LOGWARNING('using 12000K atmosphere LD coeffs even tho teff={}'.
                       format(teff))
        else:
            LOGERROR('got teff error')
    if not 2.5 < logg < 6:
        if teff < 15000:
            # Rough guess: assume star is B6V, Pecaut & Mamajek (2013) table.
            _Mstar = 4*units.Msun
            _Rstar = 2.9*units.Rsun
            logg = np.log10((const.G * _Mstar / _Rstar**2).cgs.value)
        else:
            LOGERROR('got logg error')

    Vizier.ROW_LIMIT = -1
    catalog_list = Vizier.find_catalogs('J/A+A/600/A30')
    catalogs = Vizier.get_catalogs(catalog_list.keys())
    t = catalogs[1]
    sel = t['Type'] == 'r'
    df = t[sel]

    # Each Teff has 8 tabulated logg values. First, find the best teff match.
    best_teff_match_inds = (np.abs(df['Teff'] - teff)).argsort()[:8]
    teff_matching_rows = df[best_teff_match_inds]

    # Then, among those best 8, get the best logg match.
    best_logg_match_ind = (
        np.abs(teff_matching_rows['logg'] - logg)
    ).argsort()[0]
    teff_logg_matching_row = teff_matching_rows[best_logg_match_ind]
github mommermi / photometrypipeline / pp_distill.py View on Github external
# derive observation midtime of sequence
    midtime = np.average([cat.obstime[0] for cat in catalogs])

    # setup Vizier query
    # note: column filters uses original Vizier column names
    # -> green column names in Vizier

    logging.info(('query Vizier for VSX at %7.3f/%+8.3f in '
                  + 'a %.2f deg radius') %
                 (ra_deg, dec_deg, rad_deg))

    field = coord.SkyCoord(ra=ra_deg, dec=dec_deg, unit=(u.deg, u.deg),
                           frame='icrs')

    vquery = Vizier(columns=['Name', 'RAJ2000', 'DEJ2000'])
    try:
        data = vquery.query_region(field,
                                   width=("%fd" % rad_deg),
                                   catalog="B/vsx/vsx")[0]
    except IndexError:
        if display:
            print('no data available from VSX')
            logging.error('no data available from VSX')
            return []

    objects = []
    for cat_idx, cat in enumerate(catalogs):
        for star in data:
            objects.append({'ident': star['Name'],
                            'obsdate.jd': cat.obstime[0],
                            'cat_idx': cat_idx,
github gbrammer / grizli / grizli / prep.py View on Github external
import astropy.units as u
    import astropy.coordinates as coord
    
    coo = coord.SkyCoord(ra=ra, dec=dec, unit=(u.deg, u.deg),
                         frame='icrs')
        
    gdict = get_gaia_DR2_vizier_columns()
    
    try:
        keys = list(gdict.keys())
        
        # Hack, Vizier object doesn't seem to allow getting all keys
        # simultaneously (astroquery v0.3.7)
        N = 9
        for i in range(len(keys)//N+1):
            v = Vizier(catalog=catalog, columns=['+_r']+keys[i*N:(i+1)*N])
            v.VIZIER_SERVER = server
            tab = v.query_region(coo, radius="{0}m".format(radius), catalog=catalog)[0]
            if i == 0:
                result = tab
            else:
                for k in tab.colnames:
                    #print(i, k)
                    result[k] = tab[k]
                    
        for k in gdict:
            if k in result.colnames:
                result.rename_column(k, gdict[k])
    except:
        return False
        
    return result
github henrysky / astroNN / astroNN / datasets / apokasc.py View on Github external
def apokasc_load(combine=True):
    """
    NAME:
        apokasc_load
    PURPOSE:
        load apokasc result (Precise surface gravity measurement)
    INPUT:
        combine (boolean): True to combine gold snd basic standard
    OUTPUT:
    HISTORY:
        2017-Dec-23 - Written - Henry Leung (University of Toronto)
    """
    catalog_list = Vizier.find_catalogs('apokasc')
    Vizier.ROW_LIMIT = 99999
    catalogs_gold = Vizier.get_catalogs(catalog_list.keys())[1]
    catalogs_basic = Vizier.get_catalogs(catalog_list.keys())[2]
    gold_ra = catalogs_gold['_RA']
    gold_dec = catalogs_gold['_DE']
    gold_logg = catalogs_gold['log_g_']
    basic_ra = catalogs_basic['_RA']
    basic_dec = catalogs_basic['_DE']
    basic_logg = catalogs_basic['log.g2']

    if combine is True:
        ra = np.append(np.array(gold_ra), np.array(basic_ra))
        dec = np.append(np.array(gold_dec), np.array(basic_dec))
        logg = np.append(np.array(gold_logg), np.array(basic_logg))
        return ra, dec, logg
    else:
        return gold_ra, gold_dec, gold_logg, basic_ra, basic_dec, basic_logg
github astrocatalogs / supernovae / tasks / vizier.py View on Github external
def do_lennarz(catalog):
    """Import data from the Lennarz catalog."""
    task_str = catalog.get_current_task_str()
    viz = Vizier(columns=['**'])
    viz.ROW_LIMIT = -1
    viz.VIZIER_SERVER = 'vizier.cfa.harvard.edu'
    result = viz.get_catalogs('J/A+A/538/A120/usc')
    table = result[list(result.keys())[0]]
    table.convert_bytestring_to_unicode()

    bibcode = '2012A&A...538A.120L'
    for ri, row in enumerate(pbar(table, task_str)):
        row = convert_aq_output(row)
        name = 'SN' + row['SN']
        name = catalog.add_entry(name)

        source = catalog.entries[name].add_source(bibcode=bibcode)
        catalog.entries[name].add_quantity(SUPERNOVA.ALIAS, name, source)

        if row['RAJ2000']:
github Stargrazer82301 / CAAPR / CAAPR_AstroMagic / PTS / pts / magic / tools / catalogs.py View on Github external
:param ra_span:
    :param dec_span:
    :return:
    """

    # Initialize a list to contain the galaxies
    names = []

    # Other way ?? Much more results ?
    #ra_radius = 0.5 * ra_span.value
    #dec_radius = 0.5 * dec_span.value
    #radius = math.sqrt(ra_radius**2 + dec_radius**2)
    #result_table = Ned.query_region(center, radius=radius)

    # Create a new Vizier object and set the row limit to -1 (unlimited)
    viz = Vizier(keywords=["galaxies", "optical"])
    viz.ROW_LIMIT = -1

    # Debugging
    log.debug("Querying the HYPERLEDA catalog ...")

    # Query Vizier and obtain the resulting table
    result = viz.query_region(center.to_astropy(), width=ra_span, height=dec_span, catalog=["VII/237"])

    # I noticed something strange happening once; where there were no entries in the result,
    # with the following parameters:
    #   center = (149.07614359, 69.24847936)
    #   ra_span = 1.600000128 deg
    #   dec_span = 1.3966667784 deg
    #   catalog = ["VII/237"]
    # When ra_span was only slightly changed (e.g. change the last digit to a '7'), output was normal
    # Thus, it seems that the query goes wrong with specific values of the width (and/or height), in which
github Stargrazer82301 / CAAPR / CAAPR_AstroMagic / PTS / pts / magic / tools / catalogs.py View on Github external
except astroquery.exceptions.TimeoutError:

        # Set attributes
        gal_name = name
        gal_redshift = None
        gal_type = None

    except:

        # Set attributes
        gal_name = name
        gal_redshift = None
        gal_type = None

    # Create a new Vizier object and set the row limit to -1 (unlimited)
    viz = Vizier(keywords=["galaxies", "optical"])
    viz.ROW_LIMIT = -1

    # Query Vizier and obtain the resulting table
    result = viz.query_object(name.replace(" ", ""), catalog=["VII/237"])

    # Not found ... TODO: fix this ... this object was in the first query output
    if len(result) == 0: return name, position, None, None, [], None, None, None, None, None, None

    table = result[0]

    # Get the correct entry (sometimes, for example for mergers, querying with the name of one galaxy gives two hits! We have to obtain the right one each time!)
    if len(table) == 0: raise ValueError("The galaxy could not be found under this name")
    elif len(table) == 1: entry = table[0]
    else:

        entry = None