def UVMakeIF(outUV, nIF, err, solInt=10.): """ Change number of IFs from 1 to nIF Operation done in place * outUV = output Obit UV object Only really works for AIPS * nIF = number of desired output IFs MUST be the same number of channels per IF * err = Obit error/message stack * solInt = Solution interval for remade CL table. """ ################################################################ # Checks if not UV.PIsA(outUV): raise TypeError("outUV MUST be a defined Python Obit UV") # Input can have 1 or no IFs defined jlocif = outUV.Desc.Dict["jlocif"] if jlocif >= 0 and outUV.Desc.Dict["inaxes"][jlocif] > 1: raise RuntimeError("Input UV has excessive IFs already:" \ +str(outUV.Desc.Dict["inaxes"][jlocif])) # Check number of requested IFs if nIF < 2: raise RuntimeError("Too few output IFs requested: " + str(nIF)) # Must be an even number of channels per output IF jlocf = outUV.Desc.Dict["jlocf"] nchan = outUV.Desc.Dict["inaxes"][jlocf] if (nchan % nIF) != 0: raise RuntimeError("Unequal numbers of channels per " + str(nIF) + " IFs") # Patch UV Descriptor DescMakeIF(outUV, nIF, err) # Convert FQ Table UpdateFQ2(outUV, nIF, err) # Convert AN Table maxant = UpdateAN2(outUV, nIF, err) # Convert SU Table UpdateSU2(outUV, nIF, err) # Regenerate CL table 1 - delete any old outUV.ZapTable("AIPS CL", -1, err) print('(Re) generate CL table') UV.PTableCLfromNX(outUV, maxant, err, calInt=solInt) # dummy FG 1 print('Dummy entry in Flag table 1') UV.PFlag(outUV, err, timeRange=[-10., -9.], Ants=[200, 200], Stokes='0000', Reason='Dummy') # Update outUV.UpdateDesc(err) OErr.printErrMsg(err, "Error updating output")
def attach_CL_from_NX_table(self, max_ant_nr): """ Creates a CL table associated with this UV file from an NX table. Parameters ---------- max_ant_nr : integer Maximum antenna number written to the AIPS AN table. """ err_msg = ("Error creating CL table " "from NX table on UV file '%s'" % self.name) try: UV.PTableCLfromNX(self.uv, max_ant_nr, self._err) except Exception: raise Exception(err_msg) handle_obit_err(err_msg, self._err)
def KAT2AIPS (katdata, outUV, disk, fitsdisk, err, \ calInt=1.0, static=None, **kwargs): """Convert MeerKAT MVF data set to an Obit UV. This module requires katdat and katpoint and their dependencies contact Ludwig Schwardt <*****@*****.**> for details. Parameters ---------- katdata : string input katdal object outUV : ?? Obit UV object, shoud be a KAT template for the appropriate number of IFs and poln. disk : int AIPS Disk number fitsdisk: int FITS Disk number err : ?? Obit error/message stack calInt : Calibration interval in min. targets : list, optinal List of targetnames to extract from the file stop_w : bool Fring stop data? (Values only for KAT-7) """ ################################################################ OErr.PLog(err, OErr.Info, "Converting MVF data to AIPS UV format.") OErr.printErr(err) print("Converting MVF data to AIPS UV format.\n") # Extract metadata meta = GetKATMeta(katdata, err) # TODO: Fix this all up so that the below isn't the case! if meta["products"].size != meta["nants"] * meta["nants"] * 4: raise ValueError( "Only full stokes and all correlation products are supported.") # Extract AIPS parameters of the uv data to the metadata meta["Aproject"] = outUV.Aname meta["Aclass"] = outUV.Aclass meta["Aseq"] = outUV.Aseq meta["Adisk"] = disk meta["calInt"] = calInt meta["fitsdisk"] = fitsdisk # Update descriptor UpdateDescriptor(outUV, meta, err) # Write AN table WriteANTable(outUV, meta, err) # Write FQ table WriteFQTable(outUV, meta, err) # Write SU table WriteSUTable(outUV, meta, err) # Convert data ConvertKATData(outUV, katdata, meta, err, static=static, blmask=kwargs.get('blmask', 1.e10), stop_w=kwargs.get('stop_w', False), timeav=kwargs.get('timeav', 1), flag=kwargs.get('flag', False), doweight=kwargs.get('doweight', True), doflags=kwargs.get('doflags', True)) # Index data OErr.PLog(err, OErr.Info, "Indexing data") OErr.printErr(err) UV.PUtilIndex(outUV, err) # Open/close UV to update header outUV.Open(UV.READONLY, err) outUV.Close(err) if err.isErr: OErr.printErrMsg(err, message="Update UV header failed") # initial CL table OErr.PLog(err, OErr.Info, "Create Initial CL table") OErr.printErr(err) print("Create Initial CL table\n") UV.PTableCLfromNX(outUV, meta["maxant"], err, calInt=calInt) outUV.Open(UV.READONLY, err) outUV.Close(err) if err.isErr: OErr.printErrMsg(err, message="Update UV header failed") # History outHistory = History.History("outhistory", outUV.List, err) outHistory.Open(History.READWRITE, err) outHistory.TimeStamp("Convert MeerKAT MVF data to Obit", err) for name in katdata.name.split(','): for line in _history_wrapper.wrap("datafile = " + name): outHistory.WriteRec(-1, line, err) outHistory.WriteRec(-1, "calInt = " + str(calInt), err) outHistory.Close(err) outUV.Open(UV.READONLY, err) outUV.Close(err) if err.isErr: OErr.printErrMsg(err, message="Update UV header failed") # Return the metadata for the pipeline return meta