def VLAUVFITS(inUV, filename, outDisk, err, compress=False, \ exclude=["AIPS HI", "AIPS AN", "AIPS FQ", "AIPS SL", "AIPS PL"], \ include=[], headHi=False): """ Write UV data as FITS file Write a UV data set as a FITAB format file History written to header inUV = UV data to copy filename = name of FITS file inDisk = FITS directory number err = Python Obit Error/message stack exclude = List of table types NOT to copy NB: "AIPS HI" isn't really a table and gets copied anyway include = List of table types to copy (FQ, AN always done ) Exclude has presidence over include headHi = if True move history to header, else leave in History table returns FITS UV data object """ ################################################################ # Checks if not UV.PIsA(inUV): raise TypeError, "inUV MUST be a Python Obit UV" if not OErr.OErrIsA(err): raise TypeError, "err MUST be an OErr" # # Set output outUV = UV.newPFUV("FITS UV DATA", filename, outDisk, False, err) if err.isErr: OErr.printErrMsg(err, "Error creating FITS data") #Compressed? if compress: inInfo = UV.PGetList(outUV) # dim = [1, 1, 1, 1, 1] InfoList.PAlwaysPutBoolean(inInfo, "Compress", dim, [True]) # Copy UV.PCopy(inUV, outUV, err) if err.isErr: OErr.printErrMsg(err, "Error copying UV data to FITS") # History inHistory = History.History("inhistory", outUV.List, err) outHistory = History.History("outhistory", outUV.List, err) # Add history outHistory.Open(History.READWRITE, err) outHistory.TimeStamp(" Start Obit uvtab", err) outHistory.WriteRec( -1, "uvtab / FITS file " + filename + " disk " + str(outDisk), err) outHistory.Close(err) # History in header? if headHi: History.PCopy2Header(inHistory, outHistory, err) OErr.printErrMsg(err, "Error with history") # zap table outHistory.Zap(err) # Copy Tables UV.PCopyTables(inUV, outUV, exclude, include, err) return outUV # return new object
def VLAUVLoad(filename, inDisk, Aname, Aclass, Adisk, Aseq, err, logfile=''): """ Read FITS uvtab file into AIPS Read a UVTAB FITS UV data file and write an AIPS data set filename = name of FITS file inDisk = FITS directory number Aname = AIPS name of file Aclass = AIPS class of file Aseq = AIPS sequence number of file, 0=> create new Adisk = FITS directory number err = Python Obit Error/message stack logfile = logfile for messages returns AIPS UV data object """ ################################################################ # # Checks if not OErr.OErrIsA(err): raise TypeError, "err MUST be an OErr" # # Get input inUV = UV.newPFUV("FITS UV DATA", filename, inDisk, True, err) if err.isErr: OErr.printErrMsg(err, "Error with FITS data") # Get output, create new if seq=0 if Aseq < 1: OErr.printErr(err) # Print any outstanding messages user = OSystem.PGetAIPSuser() Aseq = AIPSDir.PHiSeq(Adisk, user, Aname, Aclass, "MA", err) # If it already exists, increment seq if AIPSDir.PTestCNO(Adisk, user, Aname, Aclass, "MA", Aseq, err) > 0: Aseq = Aseq + 1 OErr.PClear(err) # Clear any message/error mess = "Creating AIPS UV file " + Aname + "." + Aclass + "." + str( Aseq) + " on disk " + str(Adisk) printMess(mess, logfile) outUV = UV.newPAUV("AIPS UV DATA", Aname, Aclass, Adisk, Aseq, False, err) if err.isErr: OErr.printErrMsg(err, "Error creating AIPS data") # Copy UV.PCopy(inUV, outUV, err) if err.isErr: OErr.printErrMsg(err, "Error copying UV data to AIPS") # Copy History inHistory = History.History("inhistory", inUV.List, err) outHistory = History.History("outhistory", outUV.List, err) History.PCopyHeader(inHistory, outHistory, err) # Add history outHistory.Open(History.READWRITE, err) outHistory.TimeStamp(" Start Obit uvlod", err) outHistory.WriteRec( -1, "uvlod / FITS file " + filename + " disk " + str(inDisk), err) outHistory.Close(err) # # Copy Tables exclude = [ "AIPS HI", "AIPS AN", "AIPS FQ", "AIPS SL", "AIPS PL", "History" ] include = [] UV.PCopyTables(inUV, outUV, exclude, include, err) return outUV # return new object