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
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
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
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()
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