Exemplo n.º 1
0
def upload_snid_plot(sedmfile, plotfile, db):            
    ''' commit the classification comments
    
       id   | tablename | tableid | username |  type   | comment | date   | sourceid |   attachment  
    '''
    #Retrieve information from the SEDM file header.
    sedmp = get_sedm_paramters(sedmfile)
    
    sourceid = get_sourceid(db, sedmp["OBJECT"].replace("PTF", ""))
    
    if sedmp.has_key("SNIDMATCHRLAP") and float(sedmp["SNIDMATCHRLAP"])>5:
        comment = "SNID automatic classification. Best fit is a %s %s at z=%.3f+-%.3f at %d+-%d days"%(sedmp["SNIDMATCHTYPE"], sedmp["SNIDMATCHSUBTYPE"], float(sedmp["SNIDZMED"]), float(sedmp["SNIDZMEDERR"]), float(sedmp["SNIDAGEM"]), float(sedmp["SNIDAGEMERR"]))    
    else:
        comment = 'SNID could not find a good match'
    
    print comment

    #Fill the parameters for the DB with the right values.
    params = {}
    params['id'] = -1
    params['tablename'] = 'sources'
    params['tableid'] = sourceid
    params['username'] = '******'
    params['type'] = 'info'
    params['comment'] = comment
    params['sourceid'] =  sourceid
    params['attachment'] = os.path.join('attachments/', os.path.basename(plotfile))

    
    # commit the entry to the DB
    newrow = ptf.altertable(db, 'annotations', -1, params)
    
    print newrow
Exemplo n.º 2
0
def upload_sedm(sedmfile, db):
    
    ''' id | sourceid | programid | instrumentid |         obsdate         | exptime | snr | snrwav | minwav  | maxwav  | 
    dataformat |                   datapath                   |      observer       | reducedby | classification |     lastmodified        | spectype | uploadedby '''
    
    
    
    #Retrieve information from the SEDM file header.
    sedmp = get_sedm_paramters(sedmfile)
       
    #Read the spectrum
    spec = np.genfromtxt(sedmfile, comments="#")

    #Fill the parameters for the DB with the right values.
    params = {}
    params['id'] = -1
    params['sourceid'] =  get_sourceid(db, sedmp["OBJECT"].replace("PTF", ""))
    params['programid'] = 4
    params['instrumentid'] = 65
    params['obsdate'] = sedmp["OBSUTC"][0:8]
    params['exptime'] = sedmp["EXPTIME"]
    params['snr'] = ''
    params['snrwav'] = ''
    params['minwav'] = np.nanmin(spec[:,0])
    params['maxwav'] = np.nanmax(spec[:,0])
    params['dataformat'] = 'ascii'
    params['datapath'] = os.path.join('ptf/spectra/data/', os.path.basename(sedmfile))
    params['observer'] = 'SEDM robot'
    params['reducedby'] = 'SEDM reducer'
    params['spectype'] = 'object'
    params['uploadedby'] = 'bookkeeper'

    if sedmp.has_key("SNIDMATCHRLAP") and float(sedmp["SNIDMATCHRLAP"])>5:
        params['classification'] = sedmp["SNIDMATCHTYPE"]
    else:
        params['classification'] = ''

    
    # commit the entry to the DB
    newrow = ptf.altertable(db, 'spec', -1, params)
    
    print newrow
Exemplo n.º 3
0
def upload_sedm(sedmfile, db):
    ''' id | sourceid | programid | instrumentid |         obsdate         | exptime | snr | snrwav | minwav  | maxwav  | 
    dataformat |                   datapath                   |      observer       | reducedby | classification |     lastmodified        | spectype | uploadedby '''

    #Retrieve information from the SEDM file header.
    sedmp = get_sedm_paramters(sedmfile)

    #Read the spectrum
    spec = np.genfromtxt(sedmfile, comments="#")

    #Fill the parameters for the DB with the right values.
    params = {}
    params['id'] = -1
    params['sourceid'] = get_sourceid(db, sedmp["OBJECT"].replace("PTF", ""))
    params['programid'] = 4
    params['instrumentid'] = 65
    params['obsdate'] = sedmp["OBSUTC"][0:8]
    params['exptime'] = sedmp["EXPTIME"]
    params['snr'] = ''
    params['snrwav'] = ''
    params['minwav'] = np.nanmin(spec[:, 0])
    params['maxwav'] = np.nanmax(spec[:, 0])
    params['dataformat'] = 'ascii'
    params['datapath'] = os.path.join('ptf/spectra/data/',
                                      os.path.basename(sedmfile))
    params['observer'] = 'SEDM robot'
    params['reducedby'] = 'SEDM reducer'
    params['spectype'] = 'object'
    params['uploadedby'] = 'bookkeeper'

    if sedmp.has_key("SNIDMATCHRLAP") and float(sedmp["SNIDMATCHRLAP"]) > 5:
        params['classification'] = sedmp["SNIDMATCHTYPE"]
    else:
        params['classification'] = ''

    # commit the entry to the DB
    newrow = ptf.altertable(db, 'spec', -1, params)

    print newrow
Exemplo n.º 4
0
def upload_snid_plot(sedmfile, plotfile, db):
    ''' commit the classification comments
    
       id   | tablename | tableid | username |  type   | comment | date   | sourceid |   attachment  
    '''
    #Retrieve information from the SEDM file header.
    sedmp = get_sedm_paramters(sedmfile)

    sourceid = get_sourceid(db, sedmp["OBJECT"].replace("PTF", ""))

    if sedmp.has_key("SNIDMATCHRLAP") and float(sedmp["SNIDMATCHRLAP"]) > 5:
        comment = "SNID automatic classification. Best fit is a %s %s at z=%.3f+-%.3f at %d+-%d days" % (
            sedmp["SNIDMATCHTYPE"], sedmp["SNIDMATCHSUBTYPE"],
            float(sedmp["SNIDZMED"]), float(sedmp["SNIDZMEDERR"]),
            float(sedmp["SNIDAGEM"]), float(sedmp["SNIDAGEMERR"]))
    else:
        comment = 'SNID could not find a good match'

    print comment

    #Fill the parameters for the DB with the right values.
    params = {}
    params['id'] = -1
    params['tablename'] = 'sources'
    params['tableid'] = sourceid
    params['username'] = '******'
    params['type'] = 'info'
    params['comment'] = comment
    params['sourceid'] = sourceid
    params['attachment'] = os.path.join('attachments/',
                                        os.path.basename(plotfile))

    # commit the entry to the DB
    newrow = ptf.altertable(db, 'annotations', -1, params)

    print newrow