Example #1
0
def populateFlatCals(runPath,lookupPath=None):
    if lookupPath is None:
        lookupPath = os.environ['MKID_CAL_LOOKUP']
    if not os.path.exists(path):
        writeNewCalLookupFile(path)

    lookup = CalLookupFile(path,mode='a')

    for root,dirs,files in os.walk(runPath):
        obsFilenames = fnmatch.filter(files,'obs*.h5')
        for obsFilename in obsFilenames:
            obsPath = os.path.join(root,obsFilename)
            
            try:
                obs = util.ObsFile.ObsFile(obsPath)
                fn = FileName(obsFile=obsPath)
                params = {}
                params['obs_run'],params['obs_date'],params['obs_tstamp'] = fn.getComponents()
                params['flatSoln_run'] = params['obs_run']

                if params['obs_date'] in ['20140923','20140924','20141020','20141021','20141022']:
                    params['flatSoln_date'] = params['obs_date']
                else:
                    if params['obs_date'] == '20140925':
                        params['flatSoln_date'] = '20140924'
                print params
                lookup.updateObs(newParams=params)
            except:
                pass
Example #2
0
def populateTimeMasks(runPath,lookupPath=None):
    if lookupPath is None:
        lookupPath = os.environ['MKID_CAL_LOOKUP']
    if not os.path.exists(path):
        writeNewCalLookupFile(path)

    lookup = CalLookupFile(path,mode='a')
    for root,dirs,files in os.walk(runPath):
        obsFilenames = fnmatch.filter(files,'obs*.h5')
        for obsFilename in obsFilenames:
            obsPath = os.path.join(root,obsFilename)
            
            try:
                obs = util.ObsFile.ObsFile(obsPath)
                fn = FileName(obsFile=obsPath)
                params = {}
                params['obs_run'],params['obs_date'],params['obs_tstamp'] = fn.getComponents()
                params['timeMask_run'],params['timeMask_date'],params['timeMask_tstamp'] = fn.getComponents()
                print params
                lookup.updateObs(newParams=params)
            except:
                pass
Example #3
0
def populateWaveCals(runPath,lookupPath=None):
    if lookupPath is None:
        lookupPath = os.environ['MKID_CAL_LOOKUP']
    if not os.path.exists(path):
        writeNewCalLookupFile(path)

    lookup = CalLookupFile(path,mode='a')
    for root,dirs,files in os.walk(runPath):
        obsFilenames = fnmatch.filter(files,'obs*.h5')
        for obsFilename in obsFilenames:
            obsPath = os.path.join(root,obsFilename)
            
            try:
                obs = util.ObsFile.ObsFile(obsPath)
                fn = FileName(obsFile=obsPath)
                params = {}
                params['obs_run'],params['obs_date'],params['obs_tstamp'] = fn.getComponents()
                params['waveSoln_run'] = params['obs_run']

                obs.loadBestWvlCalFile()
                waveCalPath = obs.wvlCalFileName
                waveCalFilename = os.path.basename(waveCalPath)
                if waveCalFilename.startswith('master'):
                    params['waveSoln_isMasterCal'] = True
                    tstamp = waveCalFilename.split('_')[1].split('.')[0]
                    params['waveSoln_tstamp'] = tstamp
                    params['waveSoln_date'] = ''
                else:
                    params['waveSoln_isMasterCal'] = False
                    tstamp = waveCalFilename.split('_')[1].split('.')[0]
                    params['waveSoln_tstamp'] = tstamp
                    dirs = os.path.dirname(os.path.normpath(waveCalPath)).split(os.sep)
                    params['waveSoln_date'] = dirs[-1]
                print params
                lookup.updateObs(newParams=params)
            except:
                pass