Ejemplo n.º 1
0
def query_simbad(obj):
    simbad = astroquery.simbad.Simbad()
    simbad.remove_votable_fields('coordinates')
    simbad.add_votable_fields('sp', 'flux(B)', 'flux(V)')
    result = simbad.query_object(obj)
    result['FLUX_B-V'] = result['FLUX_B'] - result['FLUX_V']
    return result
Ejemplo n.º 2
0
def getInfo(ra=-1, dec=-1, name=-1):
    simbad = astroquery.simbad.Simbad()
    simbad.add_votable_fields('sp')
    simbad.add_votable_fields('sp_bibcode')
    simbad.add_votable_fields('ids')
    simbad.add_votable_fields('otype')
    simbad.add_votable_fields('plx')
    simbad.add_votable_fields('plx_bibcode')
    if (name != -1):
        star = simbad.query_object(name)[0]
    elif (ra != -1) & (dec != -1):
        coord = astropy.coordinates.SkyCoord(ra,
                                             dec,
                                             frame='icrs',
                                             unit=(u.hourangle, u.deg))
        star = simbad.query_region(coord, radius=100 * u.arcsecond)
        #finds nearest object with a 2MASS name (in case something spurious is closer to given coords)
        whichEntry = 0
        while 1 - ('2MASS' in star[whichEntry]['IDS'].decode('utf-8')):
            ids = star[whichEntry]['IDS'].decode('utf-8')
            whichEntry += 1
        star = star[whichEntry]
    else:
        print('\n Must enter name or coords (ra, dec) of star')

    ra = star['RA']
    dec = star['DEC']
    names = star['IDS'].decode('utf-8')
    startPoint = names.find('2MASS ') + len('2MASS ')
    startName = names[startPoint:]
    endPoint = startName.find('|')
    if endPoint == -1:
        tmName = startName
    else:
        tmName = startName[:endPoint]
    if (tmName[0] != 'J') & (
            name != -1
    ):  #if this named star doesn't have a 2mass name, looks for the nearest one that does
        print('\n No 2MASS entry for star: ', mainName)
        print('Looking for nearest object with a 2MASS name')
        return getInfo(ra=ra, dec=dec)

    starDict = {}

    starDict['SimbadName'] = star['MAIN_ID'].decode(
        'utf-8')  #getting rid of small b...
    starDict['2MASSID'] = tmName
    starDict['ObjectType'] = star['OTYPE'].decode('utf-8')
    starDict['StellarType'] = star['SP_TYPE'].decode('utf-8')
    starDict['StellarTypeSource'] = getRef(star['SP_BIBCODE'].decode('utf-8'))
    starDict['RA'] = ra
    starDict['DEC'] = dec
    starDict['CoordSource'] = getRef(star['COO_BIBCODE'].decode('utf-8'))
    if np.ma.is_masked(star['PLX_VALUE']):  # No parralax data for this star
        starDict['Distance'] = -1
        starDict['DistanceSource'] = ''
    else:
        starDict['Distance'] = 1000 / star[
            'PLX_VALUE']  #1000 as Simbad gives value in mas
        starDict['DistanceSource'] = getRef(
            star['PLX_BIBCODE'].decode('utf-8'))

    Teff, rad, lum, Ag = gaiaData(ra, dec)
    gaiaSource = "Gaia Collaboration 2018"
    starDict['Teff'] = Teff
    starDict['TeffSource'] = gaiaSource
    if Teff <= 0:
        starDict['TeffSource'] = ""
    starDict['Radius'] = rad
    starDict['RadiusSource'] = gaiaSource
    if rad <= 0:
        starDict['RadiusSource'] = ""
    starDict['Luminosity'] = lum
    starDict['LuminositySource'] = gaiaSource
    if lum <= 0:
        starDict['LuminositySource'] = ""
    starDict['Ag'] = Ag
    starDict['AgSource'] = gaiaSource
    if Ag <= 0:
        starDict['AgSource'] = ""

    return starDict
Ejemplo n.º 3
0
def getCoords(name):
    simbad = astroquery.simbad.Simbad()
    star = simbad.query_object(name)[0]
    return star['RA'], star['DEC']