Ejemplo n.º 1
0
def rcsample(dr=None):
    """
    NAME:
       rcsample
    PURPOSE:
       download the rcsample file
    INPUT:
       dr= return the path corresponding to this data release (general default)
    OUTPUT:
       (none; just downloads)
    HISTORY:
       2014-11-26 - Written - Bovy (IAS)
    """
    if dr is None: dr = path._default_dr()
    # First make sure the file doesn't exist
    filePath = path.rcsamplePath(dr=dr)
    if os.path.exists(filePath): return None
    # Check whether we can find it in its old place
    oldFilePath = path.rcsamplePath(dr=dr, _old=True)
    if os.path.exists(oldFilePath):
        # mv to new place
        try:
            os.makedirs(os.path.dirname(filePath))
        except OSError:
            pass
        shutil.move(oldFilePath, filePath)
        return None
    # Create the file path
    if dr == '11':  # special case, bc in DR12 SAS
        downloadPath = filePath.replace(
            os.path.join(path._APOGEE_DATA, _dr_string('12')),
            _base_url(dr='12'))
    else:
        downloadPath = filePath.replace(
            os.path.join(path._APOGEE_DATA, _dr_string(dr)), _base_url(dr=dr))
    _download_file(downloadPath, filePath, dr, verbose=False)
    return None
Ejemplo n.º 2
0
def rcsample(dr=None):
    """
    NAME:
       rcsample
    PURPOSE:
       download the rcsample file
    INPUT:
       dr= return the path corresponding to this data release (general default)
    OUTPUT:
       (none; just downloads)
    HISTORY:
       2014-11-26 - Written - Bovy (IAS)
    """
    if dr is None: dr= path._default_dr()
    # First make sure the file doesn't exist
    filePath= path.rcsamplePath(dr=dr)
    if os.path.exists(filePath): return None
    # Check whether we can find it in its old place
    oldFilePath= path.rcsamplePath(dr=dr,_old=True)
    if os.path.exists(oldFilePath):
        # mv to new place
        try:
            os.makedirs(os.path.dirname(filePath))
        except OSError: pass
        shutil.move(oldFilePath,filePath)
        return None
    # Create the file path
    if dr == '11': # special case, bc in DR12 SAS
        downloadPath= filePath.replace(os.path.join(path._APOGEE_DATA,
                                                    _dr_string('12')),
                                       _base_url(dr='12'))
    else:
        downloadPath= filePath.replace(os.path.join(path._APOGEE_DATA,
                                                    _dr_string(dr)),
                                       _base_url(dr=dr))
    _download_file(downloadPath,filePath,dr,verbose=False)
    return None
Ejemplo n.º 3
0
def rcsample(main=False, dr=None):
    """
    NAME:
       rcsample
    PURPOSE:
       read the rcsample file
    INPUT:
       main= (default: False) if True, only select stars in the main survey
       dr= data reduction to load the catalog for (automatically set based on APOGEE_REDUX if not given explicitly)
    OUTPUT:
       rcsample data
    HISTORY:
       2013-10-08 - Written - Bovy (IAS)
    """
    filePath = path.rcsamplePath(dr=dr)
    if not os.path.exists(filePath):
        download.rcsample(dr=dr)
    #read rcsample file
    data = fitsio.read(path.rcsamplePath(dr=dr))
    #Some cuts
    if main:
        indx = mainIndx(data)
        data = data[indx]
    return data
Ejemplo n.º 4
0
def rcsample(main=False,dr=None):
    """
    NAME:
       rcsample
    PURPOSE:
       read the rcsample file
    INPUT:
       main= (default: False) if True, only select stars in the main survey
       dr= data reduction to load the catalog for (automatically set based on APOGEE_REDUX if not given explicitly)
    OUTPUT:
       rcsample data
    HISTORY:
       2013-10-08 - Written - Bovy (IAS)
    """
    filePath= path.rcsamplePath(dr=dr)
    if not os.path.exists(filePath):
        download.rcsample(dr=dr)
    #read rcsample file
    data= fitsio.read(path.rcsamplePath(dr=dr))
    #Some cuts
    if main:
        indx= mainIndx(data)
        data= data[indx]
    return data
Ejemplo n.º 5
0
def rcsample(main=False):
    """
    NAME:
       rcsample
    PURPOSE:
       read the rcsample file
    INPUT:
       main= (default: False) if True, only select stars in the main survey
    OUTPUT:
       rcsample data
    HISTORY:
       2013-10-08 - Written - Bovy (IAS)
    """
    #read rcsample file
    data= fitsio.read(path.rcsamplePath())
    #Some cuts
    if main:
        indx= mainIndx(data)
        data= data[indx]
    return data
Ejemplo n.º 6
0
def rcsample(dr=None):
    """
    NAME:
       rcsample
    PURPOSE:
       download the rcsample file
    INPUT:
       dr= return the path corresponding to this data release (general default)
    OUTPUT:
       (none; just downloads)
    HISTORY:
       2014-11-26 - Written - Bovy (IAS)
    """
    if dr is None: dr= path._default_dr()
    # First make sure the file doesn't exist
    filePath= path.rcsamplePath(dr=dr)
    if os.path.exists(filePath): return None
    # Create the file path
    downloadPath=\
        os.path.join(_base_url(dr=dr),
                     'apogee/vac/apogee-rc/cat/apogee-rc-DR%s.fits' % dr)
    _download_file(downloadPath,filePath,dr,verbose=False)
    return None
Ejemplo n.º 7
0
def rcsample(main=False,
             dr=None,
             xmatch=None,
             use_astroNN=False,
             use_astroNN_abundances=False,
             use_astroNN_distances=False,
             use_astroNN_ages=False,
             **kwargs):
    """
    NAME:
       rcsample
    PURPOSE:
       read the rcsample file
    INPUT:
       main= (default: False) if True, only select stars in the main survey
       dr= data reduction to load the catalog for (automatically set based on APOGEE_REDUX if not given explicitly)
       xmatch= (None) uses gaia_tools.xmatch.cds to x-match to an external catalog (eg., Gaia DR2 for xmatch='vizier:I/345/gaia2') and caches the result for re-use; requires jobovy/gaia_tools
       use_astroNN= (False) if True, swap in astroNN (Leung & Bovy 2019a) parameters (get placed in, e.g., TEFF and TEFF_ERR), astroNN distances (Leung & Bovy 2019b), and astroNN ages (Mackereth, Bovy, Leung, et al. (2019)
       use_astroNN_abundances= (False) only swap in astroNN parameters and abundances, not distances and ages
       use_astroNN_distances= (False) only swap in astroNN distances, not  parameters and abundances and ages
       use_astroNN_ages= (False) only swap in astroNN ages, not  parameters and abundances and distances
        +gaia_tools.xmatch.cds keywords 
    OUTPUT:
       rcsample data[,xmatched table]
    HISTORY:
       2013-10-08 - Written - Bovy (IAS)
       2018-05-09 - Add xmatch - Bovy (UofT) 
       2018-10-20 - Added use_astroNN - Bovy (UofT) 
       2018-02-15 - Add astroNN distances and corresponding options - Bovy (UofT) 
       2018-02-16 - Add astroNN ages and corresponding options - Bovy (UofT) 
    """
    filePath = path.rcsamplePath(dr=dr)
    if not os.path.exists(filePath):
        download.rcsample(dr=dr)
    #read rcsample file
    data = fitsread(path.rcsamplePath(dr=dr))
    # Swap in astroNN results?
    if use_astroNN or kwargs.get('astroNN', False) or use_astroNN_abundances:
        _warn_astroNN_abundances()
        astroNNdata = astroNN()
        # Match on (ra,dec)
        m1, m2, _ = _xmatch(data,
                            astroNNdata,
                            maxdist=2.,
                            colRA1='RA',
                            colDec1='DEC',
                            colRA2='RA',
                            colDec2='DEC')
        data = data[m1]
        astroNNdata = astroNNdata[m2]
        data = _swap_in_astroNN(data, astroNNdata)
    if use_astroNN or kwargs.get('astroNN', False) or use_astroNN_distances:
        _warn_astroNN_distances()
        astroNNdata = astroNNDistances()
        # Match on (ra,dec)
        m1, m2, _ = _xmatch(data,
                            astroNNdata,
                            maxdist=2.,
                            colRA1='RA',
                            colDec1='DEC',
                            colRA2='ra_apogee',
                            colDec2='dec_apogee')
        data = data[m1]
        astroNNdata = astroNNdata[m2]
        data = _add_astroNN_distances(data, astroNNdata)
    if use_astroNN or kwargs.get('astroNN', False) or use_astroNN_ages:
        _warn_astroNN_ages()
        astroNNdata = astroNNAges()
        data = _add_astroNN_ages(data, astroNNdata)
    if not xmatch is None:
        from gaia_tools.load import _xmatch_cds
        if use_astroNN or kwargs.get('astroNN', False):
            matchFilePath = filePath.replace('rc-', 'rc-astroNN-')
        elif use_astroNN_abundances:
            matchFilePath = filePath.replace('rc-', 'rc-astroNN-abundances-')
        elif use_astroNN_distances:
            matchFilePath = filePath.replace('rc-', 'rc-astroNN-distances-')
        elif use_astroNN_ages:
            matchFilePath = filePath.replace('rc-', 'rc-astroNN-ages-')
        else:
            matchFilePath = filePath
        ma, mai = _xmatch_cds(data, xmatch, matchFilePath, **kwargs)
        data = data[mai]
    #Some cuts
    if main:
        indx = mainIndx(data)
        data = data[indx]
        if not xmatch is None: ma = ma[indx]
    if not xmatch is None:
        return (data, ma)
    else:
        return data
Ejemplo n.º 8
0
    xmatch= (None) uses gaia_tools.xmatch.cds to x-match to an external catalog (eg., Gaia DR2 for xmatch='vizier:I/345/gaia2') and caches the result for re-use; requires jobovy/gaia_tools
    use_astroNN= (False) if True, swap in astroNN (Leung & Bovy 2019a) parameters (get placed in, e.g., TEFF and TEFF_ERR), astroNN distances (Leung & Bovy 2019b), and astroNN ages (Mackereth, Bovy, Leung, et al. (2019)
    use_astroNN_abundances= (False) only swap in astroNN parameters and abundances, not distances and ages
    use_astroNN_distances= (False) only swap in astroNN distances, not  parameters and abundances and ages
    use_astroNN_ages= (False) only swap in astroNN ages, not  parameters and abundances and distances
     +gaia_tools.xmatch.cds keywords 
 OUTPUT:
    rcsample data[,xmatched table]
 HISTORY:
    2013-10-08 - Written - Bovy (IAS)
    2018-05-09 - Add xmatch - Bovy (UofT) 
    2018-10-20 - Added use_astroNN - Bovy (UofT) 
    2018-02-15 - Add astroNN distances and corresponding options - Bovy (UofT) 
    2018-02-16 - Add astroNN ages and corresponding options - Bovy (UofT) 
 """
 filePath= path.rcsamplePath(dr=dr)
 if not os.path.exists(filePath):
     download.rcsample(dr=dr)
 #read rcsample file
 data= fitsread(path.rcsamplePath(dr=dr))
 # Swap in astroNN results?
 if use_astroNN or kwargs.get('astroNN',False) or use_astroNN_abundances:
     _warn_astroNN_abundances()
     astroNNdata= astroNN()
     # Match on (ra,dec)
     m1,m2,_= _xmatch(data,astroNNdata,maxdist=2.,
         colRA1='RA',colDec1='DEC',colRA2='RA',colDec2='DEC')
     data= data[m1]
     astroNNdata= astroNNdata[m2]
     data= _swap_in_astroNN(data,astroNNdata)
 if use_astroNN or kwargs.get('astroNN',False) or use_astroNN_distances:
Ejemplo n.º 9
0
def rcsample(main=False,dr=None,xmatch=None,
             use_astroNN=False,use_astroNN_abundances=False,
             use_astroNN_distances=False,use_astroNN_ages=False,
             **kwargs):
    """
    NAME:
       rcsample
    PURPOSE:
       read the rcsample file
    INPUT:
       main= (default: False) if True, only select stars in the main survey
       dr= data reduction to load the catalog for (automatically set based on APOGEE_REDUX if not given explicitly)
       xmatch= (None) uses gaia_tools.xmatch.cds to x-match to an external catalog (eg., Gaia DR2 for xmatch='vizier:I/345/gaia2') and caches the result for re-use; requires jobovy/gaia_tools
       use_astroNN= (False) if True, swap in astroNN (Leung & Bovy 2019a) parameters (get placed in, e.g., TEFF and TEFF_ERR), astroNN distances (Leung & Bovy 2019b), and astroNN ages (Mackereth, Bovy, Leung, et al. (2019)
       use_astroNN_abundances= (False) only swap in astroNN parameters and abundances, not distances and ages
       use_astroNN_distances= (False) only swap in astroNN distances, not  parameters and abundances and ages
       use_astroNN_ages= (False) only swap in astroNN ages, not  parameters and abundances and distances
        +gaia_tools.xmatch.cds keywords 
    OUTPUT:
       rcsample data[,xmatched table]
    HISTORY:
       2013-10-08 - Written - Bovy (IAS)
       2018-05-09 - Add xmatch - Bovy (UofT) 
       2018-10-20 - Added use_astroNN - Bovy (UofT) 
       2018-02-15 - Add astroNN distances and corresponding options - Bovy (UofT) 
       2018-02-16 - Add astroNN ages and corresponding options - Bovy (UofT) 
    """
    filePath= path.rcsamplePath(dr=dr)
    if not os.path.exists(filePath):
        download.rcsample(dr=dr)
    #read rcsample file
    data= fitsread(path.rcsamplePath(dr=dr))
    # Swap in astroNN results?
    if use_astroNN or kwargs.get('astroNN',False) or use_astroNN_abundances:
        _warn_astroNN_abundances()
        astroNNdata= astroNN()
        # Match on (ra,dec)
        m1,m2,_= _xmatch(data,astroNNdata,maxdist=2.,
            colRA1='RA',colDec1='DEC',colRA2='RA',colDec2='DEC')
        data= data[m1]
        astroNNdata= astroNNdata[m2]
        data= _swap_in_astroNN(data,astroNNdata)
    if use_astroNN or kwargs.get('astroNN',False) or use_astroNN_distances:
        _warn_astroNN_distances()
        astroNNdata= astroNNDistances()
        # Match on (ra,dec)
        m1,m2,_= _xmatch(data,astroNNdata,maxdist=2.,
            colRA1='RA',colDec1='DEC',colRA2='ra_apogee',colDec2='dec_apogee')
        data= data[m1]
        astroNNdata= astroNNdata[m2]
        data= _add_astroNN_distances(data,astroNNdata)
    if use_astroNN or kwargs.get('astroNN',False) or use_astroNN_ages:
        _warn_astroNN_ages()
        astroNNdata= astroNNAges()
        data= _add_astroNN_ages(data,astroNNdata)       
    if not xmatch is None:
        from gaia_tools.load import _xmatch_cds
        if use_astroNN or kwargs.get('astroNN',False):
            matchFilePath= filePath.replace('rc-','rc-astroNN-')
        elif use_astroNN_abundances:
            matchFilePath= filePath.replace('rc-','rc-astroNN-abundances-')
        elif use_astroNN_distances:
            matchFilePath= filePath.replace('rc-','rc-astroNN-distances-')
        elif use_astroNN_ages:
            matchFilePath= filePath.replace('rc-','rc-astroNN-ages-')
        else:
            matchFilePath= filePath
        ma,mai= _xmatch_cds(data,xmatch,matchFilePath,**kwargs)
        data= data[mai]
    #Some cuts
    if main:
        indx= mainIndx(data)
        data= data[indx]
        if not xmatch is None: ma= ma[indx]
    if not xmatch is None:
        return (data,ma)
    else:
        return data