예제 #1
0
def apVisit(plateid, mjd, fiberid, telescope='apo25m', dr=None):
    """
    NAME: apVisit
    PURPOSE: download a single apVisit file
    INPUT:
       plateid = 4-digit plate ID
       mjd = 5-digit MJD
       fiberid = 3-digit fiber ID
       telescope= ('apo25m') Telescope at which this plate has been observed ('apo25m' for standard APOGEE-N, 'apo1m' for the 1m telescope)
       dr = return the path corresponding to this data release (general default)
    OUTPUT: (none; just downloads)
    HISTORY: 2016-11 - Meredith Rawls
       2019-01-28 - Added telescope keyword, clarified that it's plateid that's needed - Bovy (UofT)
       TODO: automatically find all apVisit files for a given apogee ID and download them
    """
    if dr is None:
        dr = path._default_dr()
    # First make sure the file doesn't exist
    filePath = path.apVisitPath(plateid, mjd, fiberid,
                                telescope=telescope,dr=dr)
    if os.path.exists(filePath):
        return None
    # Create the file path
    downloadPath = filePath.replace(os.path.join(path._APOGEE_DATA, _dr_string(dr)),
                                      _base_url(dr=dr))
    _download_file(downloadPath, filePath, dr)
    return None
예제 #2
0
파일: read.py 프로젝트: hippoh/apogee
def apVisit(loc_id, mjd, fiberid, ext=1, dr=None, header=True):
    """
    NAME: apVisit
    PURPOSE: Read a single apVisit file for a given location, MJD, and fiber
    INPUT:
       loc_id = 4-digit location ID (field for 1m targets)
       mjd = 5-digit MJD
       fiberid = 3-digit fiber ID
       ext= (1) extension to load
       header= (True) if True, also return the header
       dr= return the path corresponding to this data release (general default)
    OUTPUT: 
       header=False:
            1D array with apVisit fluxes (ext=1)
            1D array with apVisit flux errors (ext=2)
            corresponding wavelength grid (ext=4) **WARNING** SORTED FROM HIGH TO LOW WAVELENGTH !!!
            go here to learn about other extensions:
            https://data.sdss.org/datamodel/files/APOGEE_REDUX/APRED_VERS/TELESCOPE/PLATE_ID/MJD5/apVisit.html
       header=True:
            (3D array with three portions of whichever extension you specified, header)
    HISTORY: 2016-11 - Meredith Rawls
       TODO: automatically find all apVisit files for a given apogee ID and download them
    """
    filePath = path.apVisitPath(loc_id, mjd, fiberid, dr=dr)
    if not os.path.exists(filePath):
        download.apVisit(loc_id, mjd, fiberid, dr=dr)
    data = fitsio.read(filePath, ext, header=header)
    if header == False:  # stitch three chips together in increasing wavelength order
        data = data.flatten()
        data = numpy.flipud(data)
    return data
예제 #3
0
def apVisit(loc_id, mjd, fiberid, ext=1, dr=None, header=True):
    """
    NAME: apVisit
    PURPOSE: Read a single apVisit file for a given location, MJD, and fiber
    INPUT:
       loc_id = 4-digit location ID (field for 1m targets)
       mjd = 5-digit MJD
       fiberid = 3-digit fiber ID
       ext= (1) extension to load
       header= (True) if True, also return the header
       dr= return the path corresponding to this data release (general default)
    OUTPUT: 
       header=False:
            1D array with apVisit fluxes (ext=1)
            1D array with apVisit flux errors (ext=2)
            corresponding wavelength grid (ext=4) **WARNING** SORTED FROM HIGH TO LOW WAVELENGTH !!!
            go here to learn about other extensions:
            https://data.sdss.org/datamodel/files/APOGEE_REDUX/APRED_VERS/TELESCOPE/PLATE_ID/MJD5/apVisit.html
       header=True:
            (3D array with three portions of whichever extension you specified, header)
    HISTORY: 2016-11 - Meredith Rawls
       TODO: automatically find all apVisit files for a given apogee ID and download them
    """
    filePath = path.apVisitPath(loc_id, mjd, fiberid, dr=dr)
    if not os.path.exists(filePath):
        download.apVisit(loc_id, mjd, fiberid, dr=dr)
    data = fitsio.read(filePath, ext, header=header)
    if header == False: # stitch three chips together in increasing wavelength order
        data = data.flatten()
        data = numpy.flipud(data)
    return data
예제 #4
0
파일: read.py 프로젝트: teaghan/apogee
def apVisit(plateid,
            mjd,
            fiberid,
            ext=1,
            telescope='apo25m',
            dr=None,
            header=False):
    """
    NAME: apVisit
    PURPOSE: Read a single apVisit file for a given plate, MJD, and fiber
    INPUT:
       plateid = 4-digit plate ID (field for 1m targets), float
       mjd = 5-digit MJD, float
       fiberid = 3-digit fiber ID, float
       ext = (1) extension to load
       header = (False) if True, return ONLY the header for the specified extension
       telescope= ('apo25m') Telescope at which this plate has been observed ('apo25m' for standard APOGEE-N, 'apo1m' for the 1m telescope)
       dr = return the path corresponding to this data release (general default)
    OUTPUT: 
       header=False:
            1D array with apVisit fluxes (ext=1), or
            1D array with apVisit flux errors (ext=2), or
            1D wavelength grid (ext=4) **WARNING** SORTED FROM HIGH TO LOW WAVELENGTH !!!
            etc.
            go here to learn about other extension choices:
            https://data.sdss.org/datamodel/files/APOGEE_REDUX/APRED_VERS/TELESCOPE/PLATE_ID/MJD5/apVisit.html
       header=True:
            header for the specified extension only (see link above)
    HISTORY: 2016-11 - added by Meredith Rawls
             2019-01 - long overdue plateid vs. locid bugfix
                       added readheader function which doesn't fail for ext=0
       2019-01-28 - Added telescope keyword - Bovy (UofT)
       TODO: automatically find all apVisit files for a given apogee ID and download them
    """
    filePath = path.apVisitPath(plateid,
                                mjd,
                                fiberid,
                                telescope=telescope,
                                dr=dr)
    if not os.path.exists(filePath):
        download.apVisit(plateid, mjd, fiberid, telescope=telescope, dr=dr)
    if header:
        data = headerread(filePath, ext)
    if not header:  # stitch three chips together in increasing wavelength order
        data = fitsread(filePath, ext)
        data = data.flatten()
        data = numpy.flipud(data)
    return data
예제 #5
0
파일: read.py 프로젝트: jobovy/apogee
def apVisit(plateid, mjd, fiberid, ext=1, telescope='apo25m',
            dr=None, header=False):
    """
    NAME: apVisit
    PURPOSE: Read a single apVisit file for a given plate, MJD, and fiber
    INPUT:
       plateid = 4-digit plate ID (field for 1m targets), float
       mjd = 5-digit MJD, float
       fiberid = 3-digit fiber ID, float
       ext = (1) extension to load
       header = (False) if True, return ONLY the header for the specified extension
       telescope= ('apo25m') Telescope at which this plate has been observed ('apo25m' for standard APOGEE-N, 'apo1m' for the 1m telescope)
       dr = return the path corresponding to this data release (general default)
    OUTPUT: 
       header=False:
            1D array with apVisit fluxes (ext=1), or
            1D array with apVisit flux errors (ext=2), or
            1D wavelength grid (ext=4) **WARNING** SORTED FROM HIGH TO LOW WAVELENGTH !!!
            etc.
            go here to learn about other extension choices:
            https://data.sdss.org/datamodel/files/APOGEE_REDUX/APRED_VERS/TELESCOPE/PLATE_ID/MJD5/apVisit.html
       header=True:
            header for the specified extension only (see link above)
    HISTORY: 2016-11 - added by Meredith Rawls
             2019-01 - long overdue plateid vs. locid bugfix
                       added readheader function which doesn't fail for ext=0
       2019-01-28 - Added telescope keyword - Bovy (UofT)
       TODO: automatically find all apVisit files for a given apogee ID and download them
    """
    filePath = path.apVisitPath(plateid, mjd, fiberid,
                                telescope=telescope,dr=dr)
    if not os.path.exists(filePath):
        download.apVisit(plateid, mjd, fiberid, telescope=telescope,dr=dr)
    if header:
        data = headerread(filePath, ext)
    if not header: # stitch three chips together in increasing wavelength order
        data = fitsread(filePath, ext)
        data = data.flatten()
        data = numpy.flipud(data)
    return data
예제 #6
0
파일: download.py 프로젝트: jcbird/apogee
def apVisit(loc_id, mjd, fiberid, dr=None):
    """
    NAME: apVisit
    PURPOSE: download a single apVisit file
    INPUT:
       loc_id = 4-digit location ID (field for 1m targets)
       mjd = 5-digit MJD
       fiberid = 3-digit fiber ID
       dr = return the path corresponding to this data release (general default)
    OUTPUT: (none; just downloads)
    HISTORY: 2016-11 - Meredith Rawls
       TODO: automatically find all apVisit files for a given apogee ID and download them
    """
    if dr is None:
        dr = path._default_dr()
    # First make sure the file doesn't exist
    filePath = path.apVisitPath(loc_id, mjd, fiberid, dr=dr)
    if os.path.exists(filePath):
        return None
    # Create the file path    
    downloadPath = filePath.replace(os.path.join(path._APOGEE_DATA, _dr_string(dr)), 
                                      _base_url(dr=dr))
    _download_file(downloadPath, filePath, dr)
    return None
예제 #7
0
def apVisit(loc_id, mjd, fiberid, dr=None):
    """
    NAME: apVisit
    PURPOSE: download a single apVisit file
    INPUT:
       loc_id = 4-digit location ID (field for 1m targets)
       mjd = 5-digit MJD
       fiberid = 3-digit fiber ID
       dr = return the path corresponding to this data release (general default)
    OUTPUT: (none; just downloads)
    HISTORY: 2016-11 - Meredith Rawls
       TODO: automatically find all apVisit files for a given apogee ID and download them
    """
    if dr is None:
        dr = path._default_dr()
    # First make sure the file doesn't exist
    filePath = path.apVisitPath(loc_id, mjd, fiberid, dr=dr)
    if os.path.exists(filePath):
        return None
    # Create the file path
    downloadPath = filePath.replace(
        os.path.join(path._APOGEE_DATA, _dr_string(dr)), _base_url(dr=dr))
    _download_file(downloadPath, filePath, dr)
    return None