Пример #1
0
def uCalSetup(data, timeIndex):
    """Sets up uCal object for a given integration with data, flagged channels, etc."""
    uCal = uc.uCalibrator(verbose=verbose, beamFWHMguess=beamFWHMguess, beamFullRange=beamFullRange, beamWidthOrder=beamWidthOrder, logFreqOrder=logFreqOrder, dampingFactor = 1.0)
    uCal.setupBaselineChannelPairs(freqs, bls, chan2FreqDict, bl2SepDict, redundancyDict)
    uCal.loadData(data, timeIndex)
    uCal.flagChans(flaggedChans=manualChannelFlags)
    uCal.defineuSampling(deltau, uMin, uMax, beamFullRange)
    return uCal
Пример #2
0
intSeps = np.arange(1,16) #* 15m  = baseline lengths
dx = 15.0 / scipy.constants.c * 1e9
chan2FreqDict = {chan: freqs[chan] for chan in chans}
separations = dx*intSeps
if calFile is None: calFile = 'psa6622_v003'
bls = getBaselines(freqs, intSeps, dataFiles[0], calFile=calFile)
bl2SepDict = {bl: np.asarray([sep,0.0]) for bl,sep in zip(bls,separations)}
redundancyDict = blRedundancyDictFromCalFile(calFile=calFile)

pickleFileName = dataFiles[0].replace('.npz', '.uCalDataWithBootstraps.p')
if loadPickle:
    uReds, uCal, uCalBootstraps, loadedDataFiles = pickle.load(open(pickleFileName,'rb'))
    if not len(uCalBootstraps) == nBootstraps or not loadedDataFiles == dataFiles: raise RuntimeError('Loaded uCalDataWithBootstraps.p does not match current specifications.')
else:
    uReds = uc.uCalReds(freqs, bls, chan2FreqDict, bl2SepDict, maxDeltau=maxDeltau, verbose=verbose) #just pass in freqs
    uCal = uc.uCalibrator(uReds.getBlChanPairs())
    data, samples = loadVisibilitiesAndSamples(dataFiles, pol, bls, redundancyDict)
    uCal.computeVisibilityCorrelations(data, samples, verbose=verbose)
    uCalBootstraps = [uc.uCalibrator(uReds.getBlChanPairs()) for i in range(nBootstraps)]
    dataBootstraps, samplesBootstraps = dataAndSamplesBootstraps(data, samples, bls, nBootstraps)
    for i in range(nBootstraps): 
        if verbose: print 'Now computing visibility correlations for bootstrap ' + str(i) + ' of ' + str(nBootstraps) + '...'
        uCalBootstraps[i].computeVisibilityCorrelations(dataBootstraps[i], samplesBootstraps[i], verbose=verbose)
    harmonizeChannelFlags(chans, uCal, uCalBootstraps, verbose=verbose)
    if verbose: print 'Now saving intermediate data products to ' + pickleFileName + ' for easy rerunning...'
    pickle.dump([uReds, uCal, uCalBootstraps, dataFiles], open(pickleFileName, 'wb'))


#%%##########################################
#   uCal Functionality
#############################################
Пример #3
0
if loadPickle:
    uReds, uCal, uCalBootstraps, loadedDataFiles = pickle.load(
        open(pickleFileName, 'rb'))
    if not len(
            uCalBootstraps) == nBootstraps or not loadedDataFiles == dataFiles:
        raise RuntimeError(
            'Loaded uCalDataWithBootstraps.p does not match current specifications.'
        )
else:
    uReds = uc.uCalReds(freqs,
                        bls,
                        chan2FreqDict,
                        bl2SepDict,
                        maxDeltau=maxDeltau,
                        verbose=verbose)  #just pass in freqs
    uCal = uc.uCalibrator(uReds.getBlChanPairs())
    data, samples = loadVisibilitiesAndSamples(dataFiles, pol, bls,
                                               redundancyDict)
    uCal.computeVisibilityCorrelations(data, samples, verbose=verbose)
    uCalBootstraps = [
        uc.uCalibrator(uReds.getBlChanPairs()) for i in range(nBootstraps)
    ]
    dataBootstraps, samplesBootstraps = dataAndSamplesBootstraps(
        data, samples, bls, nBootstraps)
    for i in range(nBootstraps):
        if verbose:
            print 'Now computing visibility correlations for bootstrap ' + str(
                i) + ' of ' + str(nBootstraps) + '...'
        uCalBootstraps[i].computeVisibilityCorrelations(dataBootstraps[i],
                                                        samplesBootstraps[i],
                                                        verbose=verbose)
Пример #4
0
    data, samples = loadVisibilitiesAndSamples(dataFiles, pol, bls, redundancyDict)
        


#############################################
#   uCal Script
#############################################

print '\nNow performing uCal...\n'

if regenerateEverything: #regenerate uReds and data
    uReds = uc.uCalReds(freqs, bls, chan2FreqDict, bl2SepDict, maxDeltau=.3) #just pass in freqs
    uReds.applyuCut(uMin=25, uMax=150)
    uReds.applyChannelFlagCut(flaggedChannels) 
    uCal = uc.uCalibrator(uReds.getBlChanPairs())
    uCal.computeVisibilityCorrelations(data, samples)
    pickle.dump([uReds, uCal], open('./Data/uCalData.p', 'wb'))
else:
    uReds, uCal = pickle.load(open('./Data/uCalData.p','rb'))

uCal.setupBinning(uBinSize = .72**.5, duBinSize = 5.0/203) #TODO: investigate uBinSize = .5 (nyquist sampling)
#uCal.setupBinning(uBinSize = .5, duBinSize = 5.0/203)

print 'Now performing logcal...'
betasLogcal, SigmasLogcal, DsLogcal = uCal.performLogcal()
noiseCovDiag = uCal.generateNoiseCovariance(betasLogcal)
betas, Sigmas, Ds = betasLogcal.copy(), SigmasLogcal.copy(), DsLogcal.copy()

print 'Now performing lincal...'
previousChiSqPerDoF = 1e10