def loadVisibilitiesAndSamples(dataFiles, pol, blList, redundancyDict): """Based on Zaki and Carina's omni_get_k.py""" print 'Now reading all data files...' data = {} samples = {} jds = [] lsts = [] files = [] conjugate = [(0, 101), (0, 62), (0, 100), (0, 97), (12, 43), (57, 64)] for fl in dataFiles: print ' Reading %s' % fl meta, _, mdl, _ = omni.from_npz(fl) jd = meta['jds'] lst = meta['lsts'] jds.append(jd) lsts.append(lst) files.append(fl.split('/')[-1]) #ignore the folder for b in bls: if b in conjugate: _d = np.conj(mdl[pol][b]) else: _d = mdl[pol][b] if b not in data.keys(): data[b] = _d else: data[b] = np.concatenate((data[b], _d), axis=0) samples[b] = redundancyDict[b] * np.ones(data[b].shape) samples[b][ data[b] == 0] = 0 #TODO: we need a more sophisticated way of handling flagging than this!!! return data, samples
def loadVisibilitiesAndSamples(dataFiles, pol, blList, redundancyDict, flags): """Loads visibilities and samples from omnical npzs. Applies flags.""" print 'Now reading all data files...' data = {} samples = {} jds = [] lsts = [] files = [] conjugate = [(0,101), (0,62), (0,100), (0,97), (12,43), (57,64)] for fl in dataFiles: print ' Reading %s'%fl meta,_,mdl,_ = omni.from_npz(fl) jd = meta['jds'] lst = meta['lsts'] jds.append(jd) lsts.append(lst) files.append(fl.split('/')[-1]) #ignore the folder for b in bls: if b in conjugate: _d = np.conj(mdl[pol][b]) else: _d = mdl[pol][b] if b not in data.keys(): data[b] = _d else: data[b] = np.concatenate((data[b],_d), axis=0) samples[b] = redundancyDict[b] * np.ones(data[b].shape) samples[b][data[b]==0] = 0 if flags is not None: for b in bls: data[b][flags==1] = 0 #apply flags for b in bls: samples[b][flags==1] = 0 #apply flags return data, samples
def loadVisibilitiesAndSamples(dataFiles, pol, blList, redundancyDict, flags): """Loads visibilities and samples from omnical npzs. Applies flags.""" print 'Now reading all data files...' data = {} samples = {} jds = [] lsts = [] files = [] conjugate = [(0, 101), (0, 62), (0, 100), (0, 97), (12, 43), (57, 64)] for fl in dataFiles: print ' Reading %s' % fl meta, _, mdl, _ = omni.from_npz(fl) jd = meta['jds'] lst = meta['lsts'] jds.append(jd) lsts.append(lst) files.append(fl.split('/')[-1]) #ignore the folder for b in bls: if b in conjugate: _d = np.conj(mdl[pol][b]) else: _d = mdl[pol][b] if b not in data.keys(): data[b] = _d else: data[b] = np.concatenate((data[b], _d), axis=0) samples[b] = redundancyDict[b] * np.ones(data[b].shape) samples[b][data[b] == 0] = 0 if flags is not None: for b in bls: data[b][flags == 1] = 0 #apply flags for b in bls: samples[b][flags == 1] = 0 #apply flags return data, samples
def flag_by_chisq(filenames, nsig=12, deg=8, outfile=False): '''Use the omnical global chisq to flag the model visibilities.''' m,g,v,x = omni.from_npz(filenames) f = {} for pol in g.keys(): if not pol in f: f[pol] = {} for k in g[pol].keys(): chisq = m['chisq'+str(k)+pol[0]] #iterate twice on flattening bandpass to find rfi mask = n.zeros_like(chisq, dtype=n.bool) #Run loop twice to get better fit after removing large rfi for i in range(2): wgts = n.logical_not(mask) chisq *= wgts med_chisq = n.median(chisq, axis=0) w = n.median(chisq,axis=0)!=0. fit = n.polyfit(n.arange(len(med_chisq))[w], n.log10(med_chisq[w]), deg=8) flat_chisq = chisq/10**n.polyval(fit, n.arange(len(med_chisq))) med = n.median(flat_chisq) sig = n.sqrt(n.median(n.abs(flat_chisq-med)**2)) mask |= n.where(flat_chisq > (med + nsig*sig), True, False) #import IPython; IPython.embed() f[pol][k] = n.logical_not(mask)#weights for the data if outfile: pass return m,g,v,x,f
def loadVisibilitiesAndSamples(dataFiles, pol, blList, redundancyDict): """Based on Zaki and Carina's omni_get_k.py""" print 'Now reading all data files...' data = {} samples = {} jds = [] lsts = [] files = [] conjugate = [(0,101), (0,62), (0,100), (0,97), (12,43), (57,64)] for fl in dataFiles: print ' Reading %s'%fl meta,_,mdl,_ = omni.from_npz(fl) jd = meta['jds'] lst = meta['lsts'] jds.append(jd) lsts.append(lst) files.append(fl.split('/')[-1]) #ignore the folder for b in bls: if b in conjugate: _d = np.conj(mdl[pol][b]) else: _d = mdl[pol][b] if b not in data.keys(): data[b] = _d else: data[b] = np.concatenate((data[b],_d), axis=0) samples[b] = redundancyDict[b] * np.ones(data[b].shape) samples[b][data[b]==0] = 0 #TODO: we need a more sophisticated way of handling flagging than this!!! return data, samples
def getBaselines(freqs, intSeps, exampleDataFile, calFile='psa6622_v003'): aa = a.cal.get_aa(calFile, freqs) blstr, _, bl2sep = zsa.grid2ij(aa.ant_layout) m, _, mdl, _ = omni.from_npz(exampleDataFile) bls = [(0, i) for i in intSeps] for ij in mdl['xx'].keys(): bl = a.miriad.ij2bl(ij[0], ij[1]) try: s = tuple(map(int, bl2sep[bl].split(','))) except (KeyError): continue if s in bls and s[0] == 0: bls[s[-1] - 1] = ij return bls
def getBaselines(freqs, intSeps, exampleDataFile, calFile='psa6622_v003'): aa = a.cal.get_aa(calFile, freqs) blstr, _, bl2sep = zsa.grid2ij(aa.ant_layout) m, _, mdl,_= omni.from_npz(exampleDataFile) bls = [(0,i) for i in intSeps] for ij in mdl['xx'].keys(): bl = a.miriad.ij2bl(ij[0],ij[1]) try: s = tuple(map(int,bl2sep[bl].split(','))) except(KeyError): continue if s in bls and s[0] == 0: bls[s[-1]-1] = ij return bls
def loadVisibilitiesAndSamples(dataFile, pol, blList, redundancyDict, flags): """Loads visibilities and samples from an omnical npz. Applies flags.""" data, samples = {}, {} jds, lsts = [], [] conjugate = [(0,101), (0,62), (0,100), (0,97), (12,43), (57,64)] if verbose: print 'Reading %s'%dataFile meta,_,mdl,_ = omni.from_npz(dataFile) jd = meta['jds'] lst = meta['lsts'] jds.append(jd) lsts.append(lst) for b in bls: if b in conjugate: _d = np.conj(mdl[pol][b]) else: _d = mdl[pol][b] if b not in data.keys(): data[b] = _d else: data[b] = np.concatenate((data[b],_d), axis=0) samples[b] = redundancyDict[b] * np.ones(data[b].shape) samples[b][data[b]==0] = 0 if flags is not None: for b in bls: data[b][flags==1] = 0 #apply flags for b in bls: samples[b][flags==1] = 0 #apply flags return data, samples
alwaysFlaggedChannels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 169, 183, 185, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 75, 76, 77] alsoFlagTheseChannels = [14, 15, 55, 101, 123, 179, 180, 181, 182, 184, 186] flaggedChannels = sorted(list(set(alwaysFlaggedChannels).union(set(alsoFlagTheseChannels)))) seps = np.arange(1,16) #* 15m = baseline lengths dx = 15.0 separations = dx*seps freqs = np.arange(.1,.2,.1/203) #freqs = np.arange(.1,.2,.1/203)[160:] chans = range(len(freqs)) chan2FreqDict = {chan: freqs[chan] for chan in chans} uTolerance = 15.0 * 15 * (freqs[1]-freqs[0]) / 3e8 * 1e9 aa = a.cal.get_aa('psa6622_v003', freqs) blstr, _, bl2sep = zsa.grid2ij(aa.ant_layout) m, _, mdl,_= omni.from_npz(dataFiles[0]) bls = [(0,i) for i in seps] for ij in mdl['xx'].keys(): bl = a.miriad.ij2bl(ij[0],ij[1]) try: s = tuple(map(int,bl2sep[bl].split(','))) except(KeyError): continue if s in bls and s[0] == 0: bls[s[-1]-1] = ij bl2SepDict = {bl: np.asarray([sep,0.0]) for bl,sep in zip(bls,separations)} #bl2SepDict = {bl: np.asarray([sep]) for bl,sep in zip(bls,separations)} def blRedundancyDictFromCalFile(calFile = 'psa6622_v003'): """ Uses Omnical to figure out the number of redundant baselines for a given separation (as demarkated by a representative baseline tuple). Returns redundancyDict and also saves it as an instance variable."""
#! /usr/bin/env python import numpy as n import aipy as a import optparse, sys import capo.omni as omni, capo.zsa as zsa, capo.arp as arp import pylab as p, os o = optparse.OptionParser() a.scripting.add_standard_options(o, cal=True) opts, args = o.parse_args(sys.argv[1:]) pol = 'xx' freqs = n.arange(.1, .2, .1 / 203) aa = a.cal.get_aa('psa6622_v003', freqs) blstr, _, bl2sep = zsa.grid2ij(aa.ant_layout) m, _, mdl, _ = omni.from_npz(args[0]) seps = n.arange(1, 16) #* 15m = baseline lengths bls = [(0, i) for i in seps] sep2ij = {} for ij in mdl['xx'].keys(): bl = a.miriad.ij2bl(ij[0], ij[1]) try: s = tuple(map(int, bl2sep[bl].split(','))) except (KeyError): continue if s in bls and s[0] == 0: bls[s[-1] - 1] = ij #print bls conjugate = [(0, 101), (0, 62), (0, 100), (0, 97), (12, 43), (57, 64)]
import numpy as n import ipdb as PDB cal = 'psa6622_v002' exec('from {cal} import prms'.format(cal=cal)) grid=grid2ij(prms['ant_layout'])[0] def ij2grid(bl): for sep in grid: if bl in grid[sep].split(','): return sep def bltxt(bltuple): return '%s_%s'%bltuple print ij2grid('0_103') seps = ['0,1'] data = {} for filename in sys.argv[1:]: meta, gains, vismdl, xtalk, jds, lsts, freqs = from_npz(filename) #for select off my bls for pol in vismdl: try: data[pol] except(KeyError): data[pol] = {} for bl in vismdl[pol]: blsep = ij2grid(bltxt(bl)) if blsep in seps: try: data[pol][blsep].append(vismdl[pol][bl]) except(KeyError):data[pol][blsep] = [vismdl[pol][bl]] datacount = 0 for pol in data: for sep in data[pol]: try: data[pol][sep] = n.concatenate(data[pol][sep]) except(TypeError):
import aipy as a import numpy as np import optparse, sys, os import capo.omni as omni, capo.zsa as zsa, capo.arp as arp import healpy as hp import matplotlib.pyplot as plt #%% meta, _, mdl, _ = omni.from_npz( './SimulatedVisibilities/simple.2456679.35658.xx.npz') meta2, _, mdl2, _ = omni.from_npz('../Data/zen.2456679.35658.xx.npz') #%% data = mdl['xx'] data2 = mdl2['xx'] bls = [(0, 103), (1, 4), (0, 101), (0, 62), (0, 100), (1, 13), (1, 70), (1, 56), (1, 71), (1, 59), (0, 97), (12, 43), (9, 71), (9, 59), (57, 64)] conjugate = [(0, 101), (0, 62), (0, 100), (0, 97), (12, 43), (57, 64)] aa = a.cal.get_aa('psa6622_v003', 0.1 / 203, 0.1, 203) blLengths = [ np.abs((np.round( aa.get_baseline(blIndex[0], blIndex[1]) * a.const.c / 1.5e12))[0]) for blIndex in bls ] freqs = aa.get_afreqs() plt.figure(1)
import numpy as n import aipy as a import optparse,sys import capo.omni as omni, capo.zsa as zsa, capo.arp as arp import pylab as p, os o = optparse.OptionParser() a.scripting.add_standard_options(o, cal=True) opts,args = o.parse_args(sys.argv[1:]) pol='xx' freqs = n.arange(.1,.2,.1/203) aa = a.cal.get_aa('psa6622_v003', freqs) blstr, _, bl2sep = zsa.grid2ij(aa.ant_layout) m, _, mdl,_= omni.from_npz(args[0]) seps = n.arange(1,16) #* 15m = baseline lengths bls = [(0,i) for i in seps] sep2ij = {} for ij in mdl['xx'].keys(): bl = a.miriad.ij2bl(ij[0],ij[1]) try: s = tuple(map(int,bl2sep[bl].split(','))) except(KeyError): continue if s in bls and s[0] == 0: bls[s[-1]-1] = ij #print bls conjugate = [(0,101), (0,62), (0,100), (0,97), (12,43), (57,64)]
uTolerance = 15.0 * 15 * (freqs[1] - freqs[0]) / 3e8 * 1e9 o = optparse.OptionParser() a.scripting.add_standard_options(o, cal=True) opts, dataFiles = o.parse_args(sys.argv[1:]) if len(sys.argv[1:]) == 0: #This option is for testing #dataFiles = ["./Data/" + file for file in os.listdir("./Data") if file.endswith("uvcRRE.npz")] dataFiles = [ "./Data/" + file for file in os.listdir("./Data") if file.endswith("2456943.57058.xx.uvcRRE.npz") ] aa = a.cal.get_aa('psa6622_v003', freqs) blstr, _, bl2sep = zsa.grid2ij(aa.ant_layout) m, _, mdl, _ = omni.from_npz(dataFiles[0]) bls = [(0, i) for i in seps] sep2ij = {} for ij in mdl['xx'].keys(): bl = a.miriad.ij2bl(ij[0], ij[1]) try: s = tuple(map(int, bl2sep[bl].split(','))) except (KeyError): continue if s in bls and s[0] == 0: bls[s[-1] - 1] = ij baselineFreqPairs = {} print 'Now finding all baseline/frequency pairs...' for ch1, f1 in enumerate(freqs):
dx = 15.0 separations = dx*seps freqs = np.arange(.1,.2,.1/203) uTolerance = 15.0 * 15 * (freqs[1]-freqs[0]) / 3e8 * 1e9 o = optparse.OptionParser() a.scripting.add_standard_options(o, cal=True) opts,dataFiles = o.parse_args(sys.argv[1:]) if len(sys.argv[1:]) == 0: #This option is for testing #dataFiles = ["./Data/" + file for file in os.listdir("./Data") if file.endswith("uvcRRE.npz")] dataFiles = ["./Data/" + file for file in os.listdir("./Data") if file.endswith("2456943.57058.xx.uvcRRE.npz")] aa = a.cal.get_aa('psa6622_v003', freqs) blstr, _, bl2sep = zsa.grid2ij(aa.ant_layout) m, _, mdl,_= omni.from_npz(dataFiles[0]) bls = [(0,i) for i in seps] sep2ij = {} for ij in mdl['xx'].keys(): bl = a.miriad.ij2bl(ij[0],ij[1]) try: s = tuple(map(int,bl2sep[bl].split(','))) except(KeyError): continue if s in bls and s[0] == 0: bls[s[-1]-1] = ij baselineFreqPairs = {} print 'Now finding all baseline/frequency pairs...'
uv.rewind() if opts.infile: xfile = '%f.xtalk.rep.npz' % jd if not os.path.exists(xfile): xfile = '%f.xtalk.npz' % jd if not os.path.exists(xfile): print xfile, 'does not exist. Skipping...' continue print ' using', xfile xtalk = np.load(xfile) else: guess, cnt, xtalk = {}, {}, {} if opts.omnimdl: #if pass in omnical file, load in the mdl omnifile = opts.omnimdl % '.'.join( filename.split('/')[-1].split('.')[0:4]) m, _, mdl, _ = omni.from_npz(omnifile) #make info object so that we can get a mapping of mdl bls to all bls. aa = a.cal.get_aa(opts.cal, np.array([.150])) info = omni.aa_to_info(aa) redmapping = {} for k in mdl[a.miriad.pol2str[uv['pol']]].keys(): for gp in info.get_reds(): if k in gp: for kk in gp: redmapping[kk] = k for (uvw, t, (i, j)), d, f in uv.all(raw=True): ti = np.where(m['jds'] == t)[0] bl = str(a.pol.ijp2blp(i, j, uv['pol'])) if not guess.has_key(bl): guess[bl], cnt[bl] = 0, 0 if (i, j) in [(97, 80), (80, 97), (72, 96), (96, 72), (43, 88), (88, 43)]:
(uvw,jd,(i,j)),d,f = uv.read(raw=True) uv.rewind() if opts.infile: xfile = '%f.xtalk.rep.npz' % jd if not os.path.exists(xfile): xfile = '%f.xtalk.npz' % jd if not os.path.exists(xfile): print xfile, 'does not exist. Skipping...' continue print ' using', xfile xtalk = np.load(xfile) else: guess, cnt, xtalk = {}, {}, {} if opts.omnimdl: #if pass in omnical file, load in the mdl omnifile = opts.omnimdl % '.'.join(filename.split('/')[-1].split('.')[0:4]) m,_,mdl,_ = omni.from_npz(omnifile) #make info object so that we can get a mapping of mdl bls to all bls. aa = a.cal.get_aa(opts.cal, np.array([.150])) info = omni.aa_to_info(aa) redmapping = {} for k in mdl[a.miriad.pol2str[uv['pol']]].keys(): for gp in info.get_reds(): if k in gp: for kk in gp : redmapping[kk] = k for (uvw,t,(i,j)),d,f in uv.all(raw=True): ti = np.where(m['jds']==t)[0] bl = str(a.pol.ijp2blp(i,j,uv['pol'])) if not guess.has_key(bl): guess[bl], cnt[bl] = 0, 0 if (i,j) in [(97,80), (80,97), (72,96), (96,72), (43, 88), (88,43)]: if opts.verbose: print 'No Model Visibility for {0}'.format((i,j)) ml = np.zeros_like(d)
def ij2grid(bl): for sep in grid: if bl in grid[sep].split(','): return sep def bltxt(bltuple): return '%s_%s' % bltuple print ij2grid('0_103') seps = ['0,1'] data = {} for filename in sys.argv[1:]: meta, gains, vismdl, xtalk, jds, lsts, freqs = from_npz(filename) #for select off my bls for pol in vismdl: try: data[pol] except (KeyError): data[pol] = {} for bl in vismdl[pol]: blsep = ij2grid(bltxt(bl)) if blsep in seps: try: data[pol][blsep].append(vismdl[pol][bl]) except (KeyError): data[pol][blsep] = [vismdl[pol][bl]] datacount = 0 for pol in data:
a single npz file per decimal JD. This lets us use omni_apply.py to calibrate xx,xy,yx,yy at once, even though we only used info from the linear instrumental polarizations. Assumes xx and yy npz files are in the same directory. Returns """ o = optparse.OptionParser() o.set_usage('merge_omni_npz.py [options] /path/to/*xx.npz') opts,args = o.parse_args(sys.argv[1:]) def merge_dicts(*dict_args): result = {} for dictionary in dict_args: result.update(dictionary) return result for xx_npz in args: yy_npz = xx_npz.replace("xx","yy") new_npz = xx_npz.replace("xx.","") print "Reading %s %s"%(xx_npz,yy_npz) metax,gainsx,vismdlx,xtalkx = omni.from_npz(xx_npz) metay,gainsy,vismdly,xtalky = omni.from_npz(yy_npz) meta = merge_dicts(metax,metay) gains = merge_dicts(gainsx,gainsy) vismdl = merge_dicts(vismdlx,vismdly) xtalk = merge_dicts(xtalkx,xtalky) print " => %s"%new_npz omni.to_npz(new_npz,meta,gains,vismdl,xtalk)
#o.add_option('-C',dest='cal',default='psa6622_v003',type='string', # help='Path and name of calfile.') a.scripting.add_standard_options(o,chan=True) opts,args = o.parse_args(sys.argv[1:]) chan = int(opts.chan) ### Save Options ### for filename in args: print filename,'-->', outfile = filename[:-4]+'.slice.npz' print outfile if os.path.exists(outfile): print " ... exists. skipping" continue meta,gains,vismdl,xtalk = from_npz(filename) slice_gains = {} slice_vismdl = {} slice_xtalk = {} for pol in gains: slice_gains[pol] = {} for ant,gain in gains[pol].iteritems(): slice_gains[pol][ant] = n.array([g[chan] for g in gain]) for pol in vismdl: slice_vismdl[pol] = {} for bl,vis in vismdl[pol].iteritems(): slice_vismdl[pol][bl] = n.array([v[chan] for v in vis]) slice_xtalk[pol] = {} for bl,xt in xtalk[pol].iteritems(): slice_xtalk[pol][bl] = n.array(xt[chan]) to_npz(outfile,meta,slice_gains,slice_vismdl,slice_xtalk)
to calibrate xx,xy,yx,yy at once, even though we only used info from the linear instrumental polarizations. Assumes xx and yy npz files are in the same directory. Returns """ o = optparse.OptionParser() o.set_usage('merge_omni_npz.py [options] /path/to/*xx.npz') opts, args = o.parse_args(sys.argv[1:]) def merge_dicts(*dict_args): result = {} for dictionary in dict_args: result.update(dictionary) return result for xx_npz in args: yy_npz = xx_npz.replace("xx", "yy") new_npz = xx_npz.replace("xx.", "") print "Reading %s %s" % (xx_npz, yy_npz) metax, gainsx, vismdlx, xtalkx = omni.from_npz(xx_npz) metay, gainsy, vismdly, xtalky = omni.from_npz(yy_npz) meta = merge_dicts(metax, metay) gains = merge_dicts(gainsx, gainsy) vismdl = merge_dicts(vismdlx, vismdly) xtalk = merge_dicts(xtalkx, xtalky) print " => %s" % new_npz omni.to_npz(new_npz, meta, gains, vismdl, xtalk)
#allus = np.arange(100,102,.1) #pixelDecs = np.asarray([-25])/180.0*np.pi #pixelRAs = np.asarray([90])/180.0*np.pi #fluxes = np.asarray([100]) pixelDecs = np.asarray([-30, -35, -20, -10, 5, -30, -50, -40, -60, -20 ]) / 180.0 * np.pi pixelRAs = np.asarray([90, 60, 120, 76, 91, 44, 50, 70, 30, 10 ]) / 180.0 * np.pi fluxes = np.asarray([100, 49, 125, 60, 20, 99, 22, 102, 5, 30]) * 1.0 #spectralIndices = np.ones(len(fluxes)) * -2.55 spectralIndices = np.asarray( [-2.45, -2.3, -2.7, -2.4, -2.55, -2.63, -2.51, -2.3, -2.9, -2.5]) + 2 for source in sourceFiles: meta, _, _, _ = omni.from_npz(source) # times = meta['jds'] times = [meta['jds'][0]] meta['SimulationOptions'] = opts.__dict__ #vismdl = {opts.pol: {blIndex: np.zeros((len(times), opts.nchan), dtype=complex) for blIndex in blIndices}} visibilities = np.zeros((len(allus), len(freqs)), dtype=complex) allPixelTops, allPixelAzAlts = [], [] for time in times: aa.set_jultime(time) pixelEq = a.coord.radec2eq([pixelRAs, pixelDecs]) pixelTop = a.coord.eq2top_m(-aa.sidereal_time(), aa.lat).dot(pixelEq) allPixelTops.append(pixelTop) allPixelAzAlts.append(a.coord.top2azalt(pixelTop)) for chan in range(opts.nchan):
import capo.omni as omni import numpy as n, pylab as p, capo.plot as plot import sys args = sys.argv()[1:] m,g,v,x = omni.from_npz(args, verbose=True)
conjugate = [(0,101), (0,62), (0,100), (0,97), (12,43), (57,64)] aa = a.cal.get_aa(opts.cal, opts.sdf, opts.sfreq, opts.nchan) freqs = aa.get_afreqs() #Fixed coordinate calculations healpixCoords = np.transpose(np.asarray(hp.pix2ang(NSIDE,np.arange(12*NSIDE**2)))) pixelRAs = healpixCoords[:,1] pixelDecs = -healpixCoords[:,0] + np.pi/2 galCoords = SkyCoord(frame="icrs", ra=pixelRAs*u.rad, dec=pixelDecs*u.rad).transform_to("galactic") #I should probably make this command line parameterizable allus = np.arange(10,160,.125) for source in sourceFiles: meta,_,_,_ = omni.from_npz(source) # times = meta['jds'] times = [meta['jds'][0]] meta['SimulationOptions'] = opts.__dict__ #vismdl = {opts.pol: {blIndex: np.zeros((len(times), opts.nchan), dtype=complex) for blIndex in blIndices}} visibilities = np.zeros((len(allus), len(freqs)),dtype=complex) allPixelTops, allPixelAzAlts = [],[] for time in times: aa.set_jultime(time) pixelEq = a.coord.radec2eq([pixelRAs,pixelDecs]) pixelTop = a.coord.eq2top_m(-aa.sidereal_time(),aa.lat).dot(pixelEq) allPixelTops.append(pixelTop) allPixelAzAlts.append(a.coord.top2azalt(pixelTop)) for chan in range(opts.nchan):
import aipy as a import numpy as np import optparse, sys, os import capo.omni as omni, capo.zsa as zsa, capo.arp as arp import healpy as hp import matplotlib.pyplot as plt #%% meta,_,mdl,_ = omni.from_npz('./SimulatedVisibilities/simple.2456679.35658.xx.npz') meta2,_,mdl2,_ = omni.from_npz('../Data/zen.2456679.35658.xx.npz') #%% data = mdl['xx'] data2 = mdl2['xx'] bls = [(0, 103), (1, 4), (0, 101), (0, 62), (0, 100), (1, 13), (1, 70), (1, 56), (1, 71), (1, 59), (0, 97), (12, 43), (9, 71), (9, 59), (57, 64)] conjugate = [(0,101), (0,62), (0,100), (0,97), (12,43), (57,64)] aa = a.cal.get_aa('psa6622_v003', 0.1/203, 0.1, 203) blLengths = [np.abs((np.round(aa.get_baseline(blIndex[0],blIndex[1]) * a.const.c / 1.5e12))[0]) for blIndex in bls] freqs = aa.get_afreqs()
#! /usr/bin/env python -u import numpy as n import aipy as a import optparse, sys import capo.omni as omni, capo.zsa as zsa, capo.arp as arp import pylab as p o = optparse.OptionParser() a.scripting.add_standard_options(o, cal=True) opts, args = o.parse_args(sys.argv[1:]) pol = 'xx' freqs = n.arange(.1, .2, .1 / 203) aa = a.cal.get_aa('psa6622_v003', freqs) blstr, _, bl2sep = zsa.grid2ij(aa.ant_layout) _, _, mdl, _, jds, lsts, freqs = omni.from_npz(args[0]) seps = n.arange(1, 16) #* 15m = baseline lengths bls = [(0, i) for i in seps] sep2ij = {} for ij in mdl['xx'].keys(): bl = a.miriad.ij2bl(ij[0], ij[1]) try: s = tuple(map(int, bl2sep[bl].split(','))) except (KeyError): continue if s in bls and s[0] == 0: bls[s[-1] - 1] = ij print bls conjugate = [(0, 101), (0, 62), (0, 100), (0, 97), (12, 43), (57, 64)]
import numpy as n import aipy as a import optparse, sys import capo.omni as omni, capo.zsa as zsa, capo.arp as arp import pylab as p o = optparse.OptionParser() a.scripting.add_standard_options(o, cal=True) opts, args = o.parse_args(sys.argv[1:]) pol = "xx" freqs = n.arange(0.1, 0.2, 0.1 / 203) aa = a.cal.get_aa("psa6622_v003", freqs) blstr, _, bl2sep = zsa.grid2ij(aa.ant_layout) _, _, mdl, _, jds, lsts, freqs = omni.from_npz(args[0]) seps = n.arange(1, 16) # * 15m = baseline lengths bls = [(0, i) for i in seps] sep2ij = {} for ij in mdl["xx"].keys(): bl = a.miriad.ij2bl(ij[0], ij[1]) try: s = tuple(map(int, bl2sep[bl].split(","))) except (KeyError): continue if s in bls and s[0] == 0: bls[s[-1] - 1] = ij print bls conjugate = [(0, 101), (0, 62), (0, 100), (0, 97), (12, 43), (57, 64)]