Exemplo n.º 1
0
outPath = ast.literal_eval(config['Data']['outPath'])  # path to output data
beamFile = ast.literal_eval(
    config['Data']['beamFile'])  # path and filename to beam map file
mapFlag = ast.literal_eval(config['Data']['mapFlag'])
filePrefix = ast.literal_eval(config['Data']['filePrefix'])
b2hPath = ast.literal_eval(config['Data']['b2hPath'])
config_file = ast.literal_eval(
    config['Data']['ditherStackFile'])  #path and name of ditherStack file.

print('Starting conversion of ' + config_file +
      ' into HDF5 files, one file per dither position. ')
print('Removing ' + str(args.bufferTime[0]) +
      ' seconds from the beginning and end of each h5 file.')

# Read in config file
configData = readDict()
configData.read_from_file(config_file)

nPos = configData['nPos']
startTimes = configData['startTimes']
stopTimes = configData['stopTimes']

timestamp = int(startTimes[0])
value = datetime.datetime.fromtimestamp(timestamp)
print('Data collection started on ' + value.strftime('%Y-%m-%d %H:%M:%S'))

# ********* Bin2HDF config file format is
# Path
# First file number
# nFiles
# beamFile (complete path)
Exemplo n.º 2
0
def makeCubeTimestream(configFileName):
    
    configData = readDict()
    configData.read_from_file(configFileName)

    # Extract parameters from config file
    nPos = int(configData['nPos'])
    startTimes = np.array(configData['startTimes'], dtype=int)
    stopTimes = np.array(configData['stopTimes'], dtype=int)
    darkSpan = np.array(configData['darkSpan'], dtype=int)
    flatSpan = np.array(configData['flatSpan'], dtype=int)
    xPos = np.array(configData['xPos'], dtype=int)
    yPos = np.array(configData['yPos'], dtype=int)
    numRows = int(configData['numRows'])
    numCols = int(configData['numCols'])
    upSample = int(configData['upSample'])
    padFraction = float(configData['padFraction'])
    coldCut = int(configData['coldCut'])
    fitPos = bool(configData['fitPos'])
    target = str(configData['target'])
    run = str(configData['run'])
    date = str(configData['date'])
    outputDir = str(configData['outputDir'])
    useImg = bool(configData['useImg'])
    doHPM = bool(configData['doHPM'])
    subtractDark = bool(configData['subtractDark'])
    divideFlat = bool(configData['divideFlat'])
    refFile = str(configData['refFile'])

    #hard coded for now to the daytime wvl cal we did with the WL data
    wvlCalTS = '1491870376'

    calPath = os.getenv('MKID_PROC_PATH', '/')
    timeMaskPath = os.path.join(calPath,"darkHotPixMasks")
    hpPath = os.path.join(timeMaskPath,date)


    #################################################           
    # Create empty arrays to save to npz file later
    timeStamps=[]
    cubes = []
    #################################################


    #get wvl cal soln file name
    cfn = FileName(run=run,date=date,tstamp=wvlCalTS).calSoln()

    #loop through obs files and each second within each file to make 1-s cubes
    for ts in startTimes:
        #load obs file
        obsFN = FileName(run=run, date=date, tstamp=str(ts)).obs()
        print(obsFN)
        obs = darkObsFile(obsFN)
        totalIntTime = obs.totalIntegrationTime
        #load wvlSoln file
        obs.loadWvlCalFile(cfn)
        for i in range(totalIntTime):
            fullTS = ts+i
            timeStamps.append(fullTS)
            print(i, fullTS)

            #get spectral cube for this second
            cDict = obs.getSpectralCube(i,1,weighted=False,fluxWeighted=False,energyBinWidth=0.07)
            cube = cDict['cube']
            cubes.append(cube)

    wvlBinEdges = np.array(cDict['wvlBinEdges'])
    cubes = np.array(cubes)
    times = np.array(timeStamps)

    #################################################
    # Setup npz file to save imageStack intermediate/cal files, parameter, and output
    stackPath = os.path.join(calPath,"imageStacks")
    npzPath = os.path.join(stackPath,date)

    #if configFileName.split('/')[0] is not 'Params':
    #    print "Config file not in Params! Output stack will have wrong filename!"
    #    print configFileName.split('/')[0]
    #    npzBaseName = target
    #else:
    npzBaseName = configFileName.split('/')[1].split('.')[0]
    npzFileName = npzPath+'/%s.npz'%npzBaseName
    print(npzFileName)

    np.savez(npzFileName, times=times, cubes=cubes, wvlBinEdges = wvlBinEdges)
    return {'cubes':cubes,'times':times,'wvlBinEdges':wvlBinEdges}