def process(self, ts): source = self.params['source'] catalog = self.params['catalog'] if 'Dish' in ts.attrs['telescope']: ant_type = 'dish' elif 'Cylinder' in ts.attrs['telescope']: ant_type = 'cylinder' else: raise RuntimeError('Unknown antenna type %s' % ts.attrs['telescope']) feedno = ts['feedno'][:].tolist() ts.redistribute(0) # make time the dist axis # array aa = ts.array try: # convert an observing time to the ra_dec of the array pointing of that time src_time = get_ephdate(source, tzone=ts.attrs['timezone']) # utc time aa.date = str(ephem.Date(src_time)) # utc time # print 'date:', aa.date antpointing = np.radians(ts['antpointing'][-1, :, :]) # radians azs = antpointing[:, 0] alts = antpointing[:, 1] if np.allclose(azs, azs[0]) and np.allclose(alts, alts[0]): az = azs[0] alt = alts[0] else: raise ValueError('Antennas do not have a common pointing') az, alt = ephem.degrees(az), ephem.degrees(alt) src_ra, src_dec = aa.radec_of(az, alt) source = '%s_%s' % (src_ra, src_dec) # print 'source:', source except ValueError: pass # source srclist, cutoff, catalogs = a.scripting.parse_srcs(source, catalog) cat = a.src.get_catalog(srclist, cutoff, catalogs) assert (len(cat) == 1), 'Allow only one source' s = cat.values()[0] if mpiutil.rank0: print 'Phase to source %s.' % source show_progress = self.params['show_progress'] progress_step = self.params['progress_step'] ts.time_and_bl_data_operate(self.phs, show_progress=show_progress, progress_step=progress_step, aa=aa, s=s) return super(Phs2src, self).process(ts)
def process(self, ts): source = self.params['source'] catalog = self.params['catalog'] if 'Dish' in ts.attrs['telescope']: ant_type = 'dish' elif 'Cylinder' in ts.attrs['telescope']: ant_type = 'cylinder' else: raise RuntimeError('Unknown antenna type %s' % ts.attrs['telescope']) feedno = ts['feedno'][:].tolist() ts.redistribute(0) # make time the dist axis # array aa = ts.array try: # convert an observing time to the ra_dec of the array pointing of that time src_time = get_ephdate(source, tzone=ts.attrs['timezone']) # utc time aa.date = str(ephem.Date(src_time)) # utc time # print 'date:', aa.date antpointing = np.radians(ts['antpointing'][-1, :, :]) # radians azs = antpointing[:, 0] alts = antpointing[:, 1] if np.allclose(azs, azs[0]) and np.allclose(alts, alts[0]): az = azs[0] alt = alts[0] else: raise ValueError('Antennas do not have a common pointing') az, alt = ephem.degrees(az), ephem.degrees(alt) src_ra, src_dec = aa.radec_of(az, alt) source = '%s_%s' % (src_ra, src_dec) # print 'source:', source except ValueError: pass # source srclist, cutoff, catalogs = a.scripting.parse_srcs(source, catalog) cat = a.src.get_catalog(srclist, cutoff, catalogs) assert(len(cat) == 1), 'Allow only one source' s = cat.values()[0] if mpiutil.rank0: print 'Undo the source-phase %s to phase to the zenith.' % source ts.time_and_bl_data_operate(self.phs, aa=aa, s=s) ts.add_history(self.history) return ts
def process(self, ts): source = self.params["source"] catalog = self.params["catalog"] if "Dish" in ts.attrs["telescope"]: ant_type = "dish" elif "Cylinder" in ts.attrs["telescope"]: ant_type = "cylinder" else: raise RuntimeError("Unknown antenna type %s" % ts.attrs["telescope"]) feedno = ts["feedno"][:].tolist() ts.redistribute(0) # make time the dist axis # array aa = ts.array try: # convert an observing time to the ra_dec of the array pointing of that time src_time = get_ephdate(source, tzone=ts.attrs["timezone"]) # utc time aa.date = str(ephem.Date(src_time)) # utc time # print 'date:', aa.date antpointing = np.radians(ts["antpointing"][-1, :, :]) # radians azs = antpointing[:, 0] alts = antpointing[:, 1] if np.allclose(azs, azs[0]) and np.allclose(alts, alts[0]): az = azs[0] alt = alts[0] else: raise ValueError("Antennas do not have a common pointing") az, alt = ephem.degrees(az), ephem.degrees(alt) src_ra, src_dec = aa.radec_of(az, alt) source = "%s_%s" % (src_ra, src_dec) # print 'source:', source except ValueError: pass # source srclist, cutoff, catalogs = a.scripting.parse_srcs(source, catalog) cat = a.src.get_catalog(srclist, cutoff, catalogs) assert len(cat) == 1, "Allow only one source" s = cat.values()[0] if mpiutil.rank0: print "Phase to source %s." % source ts.time_and_bl_data_operate(self.phs, aa=aa, s=s) ts.add_history(self.history) return ts