Esempio n. 1
0
def dbReviewAuto(disk, shelveDB, lcAffix, windowSize, windowOccuProfSelector, detThresholdLevel, subShelvDB=''):
    """review occultation detection result (saved in Python shelve database)
    """

    db = shelve.open('{}/{}'.format(disk, shelveDB))
    
    if len(subShelvDB) != 0:
        subdb = shelve.open('{}/{}'.format(disk, subShelvDB))
        dbKeys = subdb.keys()
        subdb.close()
    else:
        dbKeys = db.keys()

    for eventKey in dbKeys:
        obsDate, obsId = db[eventKey].obsDate, db[eventKey].obsId
        
        lcPath = '{}/{}/reduced/{}_{}_lcs'.format(disk, obsDate, obsId, lcAffix)
        fileName = '{}_2_{}_{}.fits'.format(obsDate, obsId, db[eventKey].series)
        print(fileName)
        if os.path.exists('{}/{}'.format(lcPath, fileName)) == False:
            print('Warning: file {} does not exist!'.format(fileName))
        else:
            fibre = int(db[eventKey].fibre)
            temp = db[eventKey]
            ogEventList = temp.events.keys()
            ogEventList.sort()
            rvEventList = checkOccultation(lcPath, fileName, fibre, windowSize, 32, windowOccuProfSelector, detThresholdLevel, 15.0, display=False)
        
            print('{} => {}'.format(ogEventList, rvEventList))
            if len(rvEventList) != 0:
                for rbin in rvEventList:
                    # if the distance between rbin and the ogEventList is less than assigned windowOccuProfSelector
                    # it is considered as the same event
                    dist2bin = np.array(ogEventList) - rbin
                    i = np.where(np.abs(dist2bin) <= windowOccuProfSelector)[0]
                    if len(i) == 0:
                        temp.addEvt(rbin, detThresholdLevel, 'z')
                    else:
                        temp.changeEvtSigma(ogEventList[i[0]], detThresholdLevel)
                db[eventKey] = temp
            else:
                pass

    db.close()
Esempio n. 2
0
def dbReviewManu(disk, shelveDB, lcAffix, windowSize, windowOccuProfSelector, detThresholdLevel, subShelvDB=''):
    """review occultation detection result (saved in Python shelve database)
    """

    db = shelve.open('{}/{}'.format(disk, shelveDB))

    if len(subShelvDB) != 0:
        subdb = shelve.open('{}/{}'.format(disk, subShelvDB))
        dbKeys = subdb.keys()
        subdb.close()
    else:
        dbKeys = db.keys()

    count = 0
    while count <= len(dbKeys) - 1:
        eventKey = dbKeys[count]
        obsDate, obsId = db[eventKey].obsDate, db[eventKey].obsId
        lcPath = '{}/{}/reduced/{}_{}_lcs'.format(disk, obsDate, obsId, lcAffix)
        fileName = '{}_2_{}_{}.fits'.format(obsDate, obsId, db[eventKey].series)
        
        print(count + 1, obsDate, obsId, db[eventKey].fibre, db[eventKey].events)
        # check the existance of the file to avoid the interruption of the program
        if os.path.exists('{}/{}'.format(lcPath, fileName)) == False:
            print('Warning: file {} does not exist!'.format(fileName))
        else:
            fibre = int(db[eventKey].fibre)
            temp = db[eventKey]
            ogEventList = temp.events.keys()
            ogEventList.sort()
            rvEventList = checkOccultation(lcPath, fileName, fibre, windowSize, 32, windowOccuProfSelector, detThresholdLevel, 15.0, display=True)
            if len(rvEventList) != 0:
                for rbin in rvEventList:
                    # if the distance between rbin and the ogEventList is less than assigned windowOccuProfSelector
                    # it is considered as the same event
                    dist2bin = np.array(ogEventList) - rbin
                    i = np.where(np.abs(dist2bin) <= windowOccuProfSelector)[0]
                    if len(i) == 0:
                        temp.addEvt(rbin, detThresholdLevel, 'z')
                        eType = raw_input('{} => event Type: (b)ad, (c)andidate, (e)lectric, (s)eeing, (u)nknown? => '.format(rbin))
                        if not eType:
                            pass
                        else:
                            temp.changeEvtType(rbin, eType)
                    else:
                        temp.changeEvtSigma(ogEventList[i[0]], detThresholdLevel)
                        eType = raw_input('{} => event Type: (b)ad, (c)andidate, (e)lectric, (s)eeing, (u)nknown? => '.format(rbin))
                        if not eType:
                            pass
                        else:
                            temp.changeEvtType(ogEventList[i[0]], eType)
                db[eventKey] = temp
            else:
                pass
        count = count + 1
        
        cont = raw_input('Continue? (q) for quit... ')
        if cont == 'q':
            break
        else:
            pass
            
    db.close()