def test(field=0,weight="Uniform"): print>>log,"reading test MS" # MS=ClassMS.ClassMS("/media/6B5E-87D0/killMS2/TEST/Simul/0000.MS") MS= ClassMS.ClassMS("CYG-B-test.MS", DoReadData=False) t=table(MS.MSName,ack=False).query("FIELD_ID==%d"%field) WEIGHT=t.getcol("WEIGHT_SPECTRUM") flag_all=t.getcol("FLAG") uvw=t.getcol("UVW") t.close() ImShape=(1, 1, 6125, 6125) CellSizeRad=(0.06/3600)*np.pi/180 CW=ClassWeighting(ImShape,CellSizeRad) #CW.CalcWeights(MS.uvw[199:200],WEIGHT[199:200,0:3],MS.flag_all[199:200,0:3],MS.ChanFreq[0:3],Weighting="Uniform") flag_all.fill(0) # for i in [206]:#range(200,211): # r0,r1=i,i+10 # print r0,r1 # uvw=np.float64(MS.uvw[r0:r1].copy()) # flags=MS.flag_all[r0:r1,0:3].copy() # W=WEIGHT[r0:r1,0:3].copy() # W.fill(1) # freqs=MS.ChanFreq[0:3].copy() # CW.CalcWeights(uvw,W,flags,freqs,Weighting="Uniform") WEIGHT = WEIGHT.mean(axis=2) WEIGHT.fill(1) #flag_all[MS.A0==MS.A1]=1 #WEIGHT[MS.flag_all[:,:,0]==1]=0 print>>log,"calculating test weights for shape %s"%(flag_all.shape,) CW.CalcWeights(uvw,WEIGHT,flag_all,MS.ChanFreq,Robust=0,Weighting=weight)
def setJones(self): from DDFacet.Data import ClassJones from DDFacet.Data import ClassMS SolsName=self.SolsName if "[" in SolsName: SolsName=SolsName.replace("[","") SolsName=SolsName.replace("]","") SolsName=SolsName.split(",") GD={"Beam":{"Model":self.BeamModel, "LOFARBeamMode":"A", "DtBeamMin":5., "NBand":self.BeamNBand, "CenterNorm":1}, "Image":{"PhaseCenterRADEC":None}, "DDESolutions":{"DDSols":SolsName, "SolsDir":self.SolsDir, "GlobalNorm":None, "JonesNormList":"AP"}, "Cache":{"Dir":""} } print("Reading Jones matrices solution file:", file=log) ms=ClassMS.ClassMS(self.DicoMSInfos[self.iCurrentMS]["MSName"],GD=GD,DoReadData=False,) JonesMachine = ClassJones.ClassJones(GD, ms, CacheMode=False) JonesMachine.InitDDESols(self.DicoDATA) #JJ=JonesMachine.MergeJones(self.DicoDATA["killMS"]["Jones"],self.DicoDATA["Beam"]["Jones"]) # import killMS.Data.ClassJonesDomains # DomainMachine=killMS.Data.ClassJonesDomains.ClassJonesDomains() # if "killMS" in self.DicoDATA.keys(): # self.DicoDATA["killMS"]["Jones"]["FreqDomain"]=self.DicoDATA["killMS"]["Jones"]["FreqDomains"] # if "Beam" in self.DicoDATA.keys(): # self.DicoDATA["Beam"]["Jones"]["FreqDomain"]=self.DicoDATA["Beam"]["Jones"]["FreqDomains"] # if "killMS" in self.DicoDATA.keys() and "Beam" in self.DicoDATA.keys(): # JonesSols=DomainMachine.MergeJones(self.DicoDATA["killMS"]["Jones"],self.DicoDATA["Beam"]["Jones"]) # elif "killMS" in self.DicoDATA.keys() and not ("Beam" in self.DicoDATA.keys()): # JonesSols=self.DicoDATA["killMS"]["Jones"] # elif not("killMS" in self.DicoDATA.keys()) and "Beam" in self.DicoDATA.keys(): # JonesSols=self.DicoDATA["Beam"]["Jones"] #self.DicoJones["G"]=np.swapaxes(self.NormJones(JonesSols["Jones"]),1,3) # Normalize Jones matrices if self.DoJonesCorr_kMS: JonesSols=self.DicoDATA["killMS"]["Jones"] self.DicoJones_kMS["G"]=np.swapaxes(JonesSols["Jones"],1,3) # Normalize Jones matrices self.DicoJones_kMS['tm']=(JonesSols["t0"]+JonesSols["t1"])/2. self.DicoJones_kMS['ra']=JonesMachine.ClusterCat['ra'] self.DicoJones_kMS['dec']=JonesMachine.ClusterCat['dec'] self.DicoJones_kMS['FreqDomains']=JonesSols['FreqDomains'] self.DicoJones_kMS['FreqDomains_mean']=np.mean(JonesSols['FreqDomains'],axis=1) self.DicoJones_kMS['IDJones']=np.zeros((self.NDir,),np.int32) for iDir in range(self.NDir): ra=self.PosArray.ra[iDir] dec=self.PosArray.dec[iDir] self.DicoJones_kMS['IDJones'][iDir]=np.argmin(AngDist(ra,self.DicoJones_kMS['ra'],dec,self.DicoJones_kMS['dec'])) if self.DoJonesCorr_Beam: JonesSols = JonesMachine.GiveBeam(np.unique(self.DicoDATA["times"]), quiet=True,RaDec=(self.PosArray.ra,self.PosArray.dec)) self.DicoJones_Beam["G"]=np.swapaxes(JonesSols["Jones"],1,3) # Normalize Jones matrices self.DicoJones_Beam['tm']=(JonesSols["t0"]+JonesSols["t1"])/2. self.DicoJones_Beam['ra']=self.PosArray.ra self.DicoJones_Beam['dec']=self.PosArray.dec self.DicoJones_Beam['FreqDomains']=JonesSols['FreqDomains'] self.DicoJones_Beam['FreqDomains_mean']=np.mean(JonesSols['FreqDomains'],axis=1)