calibrators[pol].nTime = len(timing) calibrators[pol].nFrequency = nfreq calibrators[pol].removeDegeneracy = removedegen calibrators[pol].convergePercent = converge_percent calibrators[pol].maxIteration = max_iter calibrators[pol].stepSize = step_size timer = time.time() calibrators[pol].compute_redundantinfo(badAntenna = badAntenna, badUBLpair = badUBLpair, antennaLocationTolerance = redundancy_tol) print "Redundant info on %s computed in %f minutes."%(pol, (time.time() - timer)/60.) info = calibrators[pol].Info.get_info() ###prepare rawCalpar for each calibrator and consider, if needed, raw calibration################ if need_crude_cal: initant, solution_path, additional_solution_path, degen, _ = omni.find_solution_path(info, tol = calibrators[pol].antennaLocationTolerance, verbose = False) crude_calpar[pol] = np.array([omni.raw_calibrate(rawdata[p, 0, f], info, initant, solution_path, additional_solution_path, degen) for f in range(calibrators[pol].nFrequency)]) data[p] = omni.apply_calpar(rawdata[p], crude_calpar[pol], calibrators[pol].totalVisibilityId) else: data[p] = rawdata[p] #calibrators[pol].rawCalpar = np.zeros((calibrators[pol].nTime, calibrators[pol].nFrequency, 3 + 2 * (calibrators[pol].Info.nAntenna + calibrators[pol].Info.nUBL)),dtype='float32') ################################ ########calibrate################ ################################ ################first round of calibration ######################### print FILENAME + " MSG: starting calibration on %s. nTime = %i, nFrequency = %i ..."%(pol, calibrators[pol].nTime, calibrators[pol].nFrequency), sys.stdout.flush() timer = time.time() additivein = np.zeros_like(data[p])
adds = {} cdata = [None, None] for p, key in zip(range(len(data)), wantpols.keys()): calibrators[key] = RedundantCalibrator_CHIME( len(data_pack['feed_positions'])) calibrators[key].compute_redundantinfo(data_pack, badAntenna=badAntenna, badUBLpair=badUBLpair) info = calibrators[key].Info.get_info() calibrators[key].nTime = nt calibrators[key].nFrequency = nfreq ###prepare rawCalpar for each calibrator and consider, if needed, raw calibration################ if need_crude_cal: initant, solution_path, additional_solution_path, degen, _ = omni.find_solution_path( info) crude_calpar[key] = np.array([ omni.raw_calibrate(data[p, 0, f], info, initant, solution_path, additional_solution_path, degen) for f in range(calibrators[key].nFrequency) ]) data[p] = omni.apply_calpar(data[p], crude_calpar[key], calibrators[key].totalVisibilityId) calibrators[key].rawCalpar = np.zeros( (calibrators[key].nTime, calibrators[key].nFrequency, 3 + 2 * (calibrators[key].Info.nAntenna + calibrators[key].Info.nUBL)), dtype='float32') ####calibrate################ calibrators[key].removeDegeneracy = removedegen
calibrators[key].convergePercent = converge_percent calibrators[key].maxIteration = max_iter calibrators[key].stepSize = step_size timer = time.time() calibrators[key].compute_redundantinfo( badAntenna=badAntenna, badUBLpair=badUBLpair, antennaLocationTolerance=redundancy_tol) print "Redundant info on %s computed in %f minutes." % ( key, (time.time() - timer) / 60.) info = calibrators[key].Info.get_info() ###prepare rawCalpar for each calibrator and consider, if needed, raw calibration################ if need_crude_cal: initant, solution_path, additional_solution_path, degen, _ = omni.find_solution_path( info, verbose=False) crude_calpar[key] = np.array([ omni.raw_calibrate(rawdata[p, 0, f], info, initant, solution_path, additional_solution_path, degen) for f in range(calibrators[key].nFrequency) ]) data[p] = omni.apply_calpar(rawdata[p], crude_calpar[key], calibrators[key].totalVisibilityId) else: data[p] = rawdata[p] calibrators[key].rawCalpar = np.zeros( (calibrators[key].nTime, calibrators[key].nFrequency, 3 + 2 * (calibrators[key].Info.nAntenna + calibrators[key].Info.nUBL)), dtype='float32') ####calibrate################
#calibrators = [omni.RedundantCalibrator(nant, info = infopaths[key]) for key in wantpols.keys()] calibrators = {} omnigains = {} adds = {} cdata = [None,None] for p, key in zip(range(len(data)), wantpols.keys()): calibrators[key] = RedundantCalibrator_CHIME(len(data_pack['feed_positions'])) calibrators[key].compute_redundantinfo(data_pack, badAntenna = badAntenna, badUBLpair = badUBLpair) info = calibrators[key].Info.get_info() calibrators[key].nTime = nt calibrators[key].nFrequency = nfreq ###prepare rawCalpar for each calibrator and consider, if needed, raw calibration################ if need_crude_cal: initant, solution_path, additional_solution_path, degen, _ = omni.find_solution_path(info) crude_calpar[key] = np.array([omni.raw_calibrate(data[p, 0, f], info, initant, solution_path, additional_solution_path, degen) for f in range(calibrators[key].nFrequency)]) data[p] = omni.apply_calpar(data[p], crude_calpar[key], calibrators[key].totalVisibilityId) calibrators[key].rawCalpar = np.zeros((calibrators[key].nTime, calibrators[key].nFrequency, 3 + 2 * (calibrators[key].Info.nAntenna + calibrators[key].Info.nUBL)),dtype='float32') ####calibrate################ calibrators[key].removeDegeneracy = removedegen calibrators[key].convergePercent = converge_percent calibrators[key].maxIteration = max_iter calibrators[key].stepSize = step_size ################first round of calibration ######################### print FILENAME + " MSG: starting calibration on %s %s. nTime = %i, nFrequency = %i ..."%(dataano, key, calibrators[key].nTime, calibrators[key].nFrequency), sys.stdout.flush() timer = time.time()
calibrators[pol].maxIteration = max_iter calibrators[pol].stepSize = step_size timer = time.time() calibrators[pol].compute_redundantinfo( badAntenna=badAntenna, badUBLpair=badUBLpair, antennaLocationTolerance=redundancy_tol) print "Redundant info on %s computed in %f minutes." % ( pol, (time.time() - timer) / 60.) info = calibrators[pol].Info.get_info() ###prepare rawCalpar for each calibrator and consider, if needed, raw calibration################ if need_crude_cal: initant, solution_path, additional_solution_path, degen, _ = omni.find_solution_path( info, tol=calibrators[pol].antennaLocationTolerance, verbose=False) crude_calpar[pol] = np.array([ omni.raw_calibrate(rawdata[p, 0, f], info, initant, solution_path, additional_solution_path, degen) for f in range(calibrators[pol].nFrequency) ]) data[p] = omni.apply_calpar(rawdata[p], crude_calpar[pol], calibrators[pol].totalVisibilityId) else: data[p] = rawdata[p] #calibrators[pol].rawCalpar = np.zeros((calibrators[pol].nTime, calibrators[pol].nFrequency, 3 + 2 * (calibrators[pol].Info.nAntenna + calibrators[pol].Info.nUBL)),dtype='float32') ################################ ########calibrate################
calibrators[key].nTime = len(timing) calibrators[key].nFrequency = nfreq calibrators[key].removeDegeneracy = removedegen calibrators[key].convergePercent = converge_percent calibrators[key].maxIteration = max_iter calibrators[key].stepSize = step_size timer = time.time() calibrators[key].compute_redundantinfo(badAntenna = badAntenna, badUBLpair = badUBLpair, antennaLocationTolerance = redundancy_tol) print "Redundant info on %s computed in %f minutes."%(key, (time.time() - timer)/60.) info = calibrators[key].Info.get_info() ###prepare rawCalpar for each calibrator and consider, if needed, raw calibration################ if need_crude_cal: initant, solution_path, additional_solution_path, degen, _ = omni.find_solution_path(info, verbose = False) crude_calpar[key] = np.array([omni.raw_calibrate(rawdata[p, 0, f], info, initant, solution_path, additional_solution_path, degen) for f in range(calibrators[key].nFrequency)]) data[p] = omni.apply_calpar(rawdata[p], crude_calpar[key], calibrators[key].totalVisibilityId) else: data[p] = rawdata[p] calibrators[key].rawCalpar = np.zeros((calibrators[key].nTime, calibrators[key].nFrequency, 3 + 2 * (calibrators[key].Info.nAntenna + calibrators[key].Info.nUBL)),dtype='float32') ####calibrate################ ################first round of calibration ######################### print FILENAME + " MSG: starting calibration on %s. nTime = %i, nFrequency = %i ..."%(key, calibrators[key].nTime, calibrators[key].nFrequency), sys.stdout.flush() timer = time.time() additivein = np.zeros_like(data[p]) calibrators[key].logcal(data[p], additivein, verbose=True) additiveout = calibrators[key].lincal(data[p], additivein, verbose=True) print "Done. %fmin"%(float(time.time()-timer)/60.)