def apply_cal_factor_to_prof(dir, psr_file, cal_factor, rfi_mitigation=False, threshold=3, setdata=True): file = dir + psr_file ar = Archive(file, verbose=False) if rfi_mitigation: rfi_mit = RFIMitigator(ar) rfi_mit.zap_minmax(threshold=threshold) nchan = ar.getNchan() nsub = ar.getNsubint() data = ar.getData() converted_data_aa, converted_data_bb = IQUV_to_AABB(data, basis="cartesian") new_converted_aa, new_converted_bb, new_converted, new_data = np.empty( nsub, dtype=object), np.empty(nsub, dtype=object), np.empty( nsub, dtype=object), np.empty(nsub, dtype=object) for i, sub in enumerate(np.arange(nsub)): new_converted_aa[i] = row_multiply(converted_data_aa[i], cal_factor[0]) new_converted_bb[i] = row_multiply(converted_data_bb[i], cal_factor[1]) new_converted[i] = np.array((new_converted_aa[i], new_converted_bb[i])) new_data[i] = AABB_to_IQUV(new_converted[i], basis="cartesian") if setdata: ar.setData(new_data) return new_data, ar
def apply_cal_factor_to_prof(dir, psr_file, cal_factor, rfi_mitigation=False, threshold=3, setdata=True): cal_fa = vector_to_diagonal(cal_factor[0]) cal_fb = vector_to_diagonal(cal_factor[1]) file = dir + psr_file ar = Archive(file, verbose=False) if rfi_mitigation: rfi_mit = RFIMitigator(ar) rfi_mit.zap_minmax(threshold=threshold) nchan = ar.getNchan() nsub = ar.getNsubint() data = ar.getData(squeeze=False) print(data.shape) print(cal_fa.shape) converted_data = IQUV_to_AABB(data, basis="cartesian") print(converted_data.shape) exit() new_converted = [] new_data = [] s = np.array(s) aa = np.dot(converted_data, cal_fa) bb = np.dot(s, cal_fb) new_converted.append((aa, bb)) new_data.append(AABB_to_IQUV(new_converted[i], basis="cartesian")) print("Almost done") a = np.array(new_converted) new_data = np.array(new_data) print(new_data.shape) if setdata: ra = ar.setData(new_data) return new_data, ra