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}
from Utils.FileName import FileName from arrayPopup import plotArray import numpy as np import lightCurves as lc import matplotlib.pylab as plt plt.rc('font', family='serif') import pdfs from scipy import stats from scipy.signal import periodogram from statsmodels.tsa.stattools import acovf,acf,ccf import HotPix.darkHotPixMask as dhpm ### WL and PiHer data used for WL vs. on-sky correlation comparisons #load obs file for wl wlobs = darkObsFile(FileName(run='PAL2017a',date='20170410',tstamp='1491869200').obs()) #load up timed packet images #this WL obs file has a move at 18 seconds. Just cut it out, stationary after. #wlTPI = wlobs.getTimedPacketImage(firstSec=18, integrationTime=118) #Concatenate photon time stamp lists together for 3 selected pixels wlA = wlTPI['timestamps'][24][76] wlB = wlTPI['timestamps'][24][77] wlD = wlTPI['timestamps'][25][76] wlTS = wlA wlTS = np.append(wlTS,wlB) wlTS = np.append(wlTS,wlD) # make 5ms light curves wlLC = lc.lightCurve(wlTS,shortExposure=.01)
import lightCurves as lc import matplotlib.pylab as plt plt.rc('font', family='serif') import pdfs from scipy import stats from scipy.signal import periodogram from statsmodels.tsa.stattools import acovf, acf, ccf import HotPix.darkHotPixMask as dhpm #import skimage for in-painting interp from skimage import restoration #load bad pix mask for pi Her bpm = dhpm.loadMask( '/mnt/data0/CalibrationFiles/darkHotPixMasks/20170409/1491826154.npz') #load obs file for Pi Her phobs = darkObsFile( FileName(run='PAL2017a', date='20170409', tstamp='1491827562').obs()) phTPI = phobs.getTimedPacketImage(firstSec=0, integrationTime=118) shortT = 0.01 show = False totalT = 1.000 nFrames = int(totalT / shortT) stack = [] for n in range(nFrames): im = np.empty((80, 40), dtype=float) im.fill(np.nan) for i in np.arange(20, 60): #80 for j in np.arange(40, 120): #125
from Utils.FileName import FileName from arrayPopup import plotArray import numpy as np import lightCurves as lc import matplotlib.pylab as plt plt.rc('font', family='serif') import pdfs from scipy import stats from scipy.signal import periodogram from statsmodels.tsa.stattools import acovf,acf,ccf import HotPix.darkHotPixMask as dhpm ### WL and PiHer data used for WL vs. on-sky correlation comparisons #load obs file for wl wlobs = darkObsFile(FileName(run='PAL2017a',date='20170410',tstamp='1491869200').obs()) #load up timed packet images #this WL obs file has a move at 18 seconds. Just cut it out, stationary after. #wlTPI = wlobs.getTimedPacketImage(firstSec=18, integrationTime=118) #Concatenate photon time stamp lists together for 3 selected pixels wlA = wlTPI['timestamps'][24][76] wlB = wlTPI['timestamps'][24][77] wlD = wlTPI['timestamps'][25][76] wlTS = wlA wlTS = np.append(wlTS,wlB) wlTS = np.append(wlTS,wlD) # 69 her companion location timestamps saoA = saoTPI['timestamps'][46][98]
from scipy.signal import periodogram from statsmodels.tsa.stattools import acovf, acf, ccf import HotPix.darkHotPixMask as dhpm object = '69h' totalInt = 80 #for 69 Her data. Seems to be a move around 80s in. #totalInt = 118 #for piHer data. Dither move shortly after. ### WL and PiHer data used for WL vs. on-sky correlation comparisons #load up timed packet images #this WL obs file has a move at 18 seconds. Just cut it out, stationary after. if object == 'wl': #WL timed packet image target = r'WL' #load obs file for wl obs = darkObsFile( FileName(run='PAL2017a', date='20170410', tstamp='1491869200').obs()) wlTPI = obs.getTimedPacketImage(firstSec=18, integrationTime=118) bpm = dhpm.loadMask( '/mnt/data0/CalibrationFiles/darkHotPixMasks/20170410/1491870115.npz') basePath = '/mnt/data0/ProcessedData/seth/speckleAnalysis/WL_stats/allPlots_20170817/10ms/' TPI = wlTPI elif object == 'ph': #pi Her timed packet image target = r'$\pi$ Her' #load obs file for Pi Her obs = darkObsFile( FileName(run='PAL2017a', date='20170409', tstamp='1491827562').obs()) phTPI = obs.getTimedPacketImage(firstSec=0, integrationTime=totalInt) bpm = dhpm.loadMask( '/mnt/data0/CalibrationFiles/darkHotPixMasks/20170409/1491826154.npz')
import matplotlib.pylab as plt plt.rc('font', family='serif') import pdfs from scipy import stats from scipy.signal import periodogram from statsmodels.tsa.stattools import acovf,acf,ccf import HotPix.darkHotPixMask as dhpm #import skimage for in-painting interp from skimage import restoration #load bad pix mask for pi Her bpm = dhpm.loadMask('/mnt/data0/CalibrationFiles/darkHotPixMasks/20170409/1491826154.npz') #load obs file for Pi Her phobs = darkObsFile(FileName(run='PAL2017a',date='20170409',tstamp='1491827562').obs()) phTPI = phobs.getTimedPacketImage(firstSec=0, integrationTime=118) shortT = 0.01 show=False totalT = 1.000 nFrames = int(totalT/shortT) stack = [] for n in range(nFrames): im = np.empty((80,40),dtype=float) im.fill(np.nan) for i in np.arange(20,60): #80
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}
from scipy.signal import periodogram from statsmodels.tsa.stattools import acovf,acf,ccf import HotPix.darkHotPixMask as dhpm object = '69h' totalInt = 80 #for 69 Her data. Seems to be a move around 80s in. #totalInt = 118 #for piHer data. Dither move shortly after. ### WL and PiHer data used for WL vs. on-sky correlation comparisons #load up timed packet images #this WL obs file has a move at 18 seconds. Just cut it out, stationary after. if object == 'wl': #WL timed packet image target = r'WL' #load obs file for wl obs = darkObsFile(FileName(run='PAL2017a',date='20170410',tstamp='1491869200').obs()) wlTPI = obs.getTimedPacketImage(firstSec=18, integrationTime=118) bpm = dhpm.loadMask('/mnt/data0/CalibrationFiles/darkHotPixMasks/20170410/1491870115.npz') basePath = '/mnt/data0/ProcessedData/seth/speckleAnalysis/WL_stats/allPlots_20170817/10ms/' TPI = wlTPI elif object == 'ph': #pi Her timed packet image target = r'$\pi$ Her' #load obs file for Pi Her obs = darkObsFile(FileName(run='PAL2017a',date='20170409',tstamp='1491827562').obs()) phTPI = obs.getTimedPacketImage(firstSec=0, integrationTime=totalInt) bpm = dhpm.loadMask('/mnt/data0/CalibrationFiles/darkHotPixMasks/20170409/1491826154.npz') basePath = '/mnt/data0/ProcessedData/seth/speckleAnalysis/piHer_stats/allPlots_20170817/30ms/' TPI = phTPI