def imgseq (inna,incl,indisk,inseq): uvdata = AIPSUVData (inna,incl,indisk,inseq) for i in AIPSCat()[1]: if i['name']==inna and i['klass']=='IMGSEQ': AIPSImage(inna,'IMGSEQ',indisk,i['seq']).zap() if i['name']==inna and i['klass']=='ICL001': AIPSImage(inna,'ICL001',indisk,i['seq']).zap() imagr=AIPSTask('imagr') imagr.indata = uvdata imagr.cellsize[1:] = [0.2,0.2] imagr.imsize[1:] = [1024,1024] imagr.uvwtfn = 'NA' imagr.uvrange[1:] = [5.0,100000.0] imagr.source[1] = 'BEAM_1' imagr.outname = inna imagr.niter = 200 imagr.nchav = 54 uvtap = [400.0,200.0,100.0,50.0] beam = [0.5,0.9,1.8,5.0] for i in range(4): imagr.uvtaper[1:] = [uvtap[i],uvtap[i]] imagr.bmaj,imagr.bmin = beam[i],beam[i] imagr.go() AIPSImage(inna,'IBM001',indisk,1).zap() AIPSImage(inna,'ICL001',indisk,1).rename(inna,'IMGSEQ',indisk,0)
def zapexisting(inna, incl, indisk=1): for i in AIPSCat()[indisk]: if i['name'] == inna and i['klass'] == incl: if i['type'] == 'MA': AIPSImage(inna, incl, indisk, i['seq']).clrstat() AIPSImage(inna, incl, indisk, i['seq']).zap() else: AIPSUVData(inna, incl, indisk, i['seq']).clrstat() AIPSUVData(inna, incl, indisk, i['seq']).zap()
def fring_global(uvdata,cals=[],fgv=0,suba=0,refant=0,antennas=[],timer=[0,0,0,1],solint=4,solsub=0,solmin=0,aparm=[1,0,0,0,1,2,4.5,0,1,0],dparm=[1,400,400,0],snv=0,gainu=0,docal=1,search=[],echan=0,bchan=1,bpv=-1,doband=-1,dofit=[0],get2n=False,flux=0): fring = AIPSTask('fring') fring.indata = uvdata fring.flagver = fgv fring.calsour[1:] = cals fring.timerang[1:] = timer fring.solint = solint fring.solsub = solsub fring.solmin = solmin fring.subarray = suba fring.antennas[1:] = antennas fring.dofit[1:] = dofit fring.refant = refant fring.gainuse = gainu fring.snver = snv fring.aparm[1:] = aparm fring.dparm[1:] = dparm fring.docalib = docal fring.doband = doband fring.bpver = bpv fring.search[1:] = search fring.bchan = bchan fring.echan = echan if get2n: # in2data=getndata(get2n[0],get2n[1]) fring.in2data=AIPSImage(*get2n) fring.flux=flux fring.inputs() HF.print_inp_to_log(fring,'FRING') fring()
def addwenss(aipsname, indisk, ra, dec, maxoff, pmin, pmax, w_max=1000., incl='IMAP'): if have_astLib: wenss = np.load('wenss2000.npy') wenss = wenss[wenss[:, 2] < 2] # only single or centre of multiple wenss = wenss[wenss[:, 3] > w_max] # only sources >w_max mJy a = correlate(np.array([[ra, dec]]), 0, 1, wenss, 0, 1, maxoff) fo = open('starsfile', 'w') for i in a: idx = int(i[1]) sra = astCoords.decimal2hms(wenss[idx, 0], ' ') sdec = astCoords.decimal2dms(wenss[idx, 1], ' ') fo.write('%s %s\n' % (sra, sdec)) fo.close() stars(aipsname, incl, indisk, intext='./starsfile', logfiledir=logfiledir) greys(aipsname, incl, indisk, pmin, pmax, 5, 1, logfiledir=logfiledir) lwpla(aipsname, incl, indisk, './' + aipsname + '_plot.ps', logfiledir=logfiledir) AIPSImage(aipsname, incl, indisk, 1).zap() os.system('rm starsfile')
def self_calibration(uvdata, source_no, RA_shift, Dec_shift, solints, sc_type, pols, imsize, niter,refant): nchan = uvdata.header.naxis[2] sutable = uvdata.table('SU',1) sourceID = str(sutable[0].source) for i in range(len(solints)): print('Self calibration iteration %d' % i) for j in range(len(pols)): print('Iteration %d: Imaging source number %d' % (i,source_no)) imagr = AIPSTask('IMAGR') pol_data = AIPSUVData(uvdata.name,pols[j],indisk,uvdata.seq) print pol_data.klass print pols[j] imagr.indata = pol_data imagr.sources[1] = sourceID #imagr.cellsize = AIPSList([findmaxb(uvdata)[0],findmaxb(uvdata)[1]]) imagr.cellsize = AIPSList([0.2,0.2]) imagr.imsize = AIPSList(imsize) imagr.docalib = 2 imagr.gainuse = i+1 imagr.stokes = pols[j] imagr.rashift[1] = RA_shift imagr.decshift[1] = Dec_shift imagr.niter = niter imagr.nchav = nchan imagr.outname = 'S%s_SC%s' % (source_no,str(i+1)) imagr.outdisk = indisk imagr.go() image = AIPSImage('S%s_SC%s' % (source_no,str(i+1)),'%sCL001'%pols[j][0],indisk,1) print('Iteration %d: Making calibrations soln w/ solint=%.1f min and %s type' % (i,solints[i],sc_type[i])) calib = AIPSTask('CALIB') calib.indata = pol_data calib.calsour[1] = sourceID calib.docalib = 2 calib.in2data = image calib.refant = refant calib.solint = solints[i] calib.aparm[1:] = 3, 0, 0, 0, 0, 0, 3, 0 calib.ncomp[1] = -1000000 calib.soltype = 'L1' calib.solmode = sc_type[i] calib.snver = i+1 calib.go() print('Iteration %d: Applying SN table %d' % (i,i)) clcal = AIPSTask('CLCAL') clcal.indata = pol_data clcal.calsour[1] = sourceID clcal.sources[1] = sourceID clcal.opcode = 'CALP' clcal.interpol = 'AMBG' clcal.snver = i+1 clcal.invers = i+1 clcal.gainver = i+1 clcal.gainuse = i+2 clcal.cutoff = 60 clcal.dobtween = 0 clcal.refant = refant clcal.go()
def aipszap(aipsname, aipsclass, indisk=1): pca = AIPSCat() for j in pca[indisk]: if j['name'] == aipsname and j['klass'] == aipsclass: if j['type'] == 'UV': data = AIPSUVData(aipsname, aipsclass, indisk, j['seq']) else: data = AIPSImage(aipsname, aipsclass, indisk, j['seq']) data.zap()
def get_fits(no): seq = 1 if no<1000: n = str(no) n = n.zfill(3) imtype = 'IIM'+n else: imtype = 'II'+str(no) dat = AIPSImage('J0528+2200',imtype,1,seq) if not dat.exists(): print imtype+' failed!!!!' fittp = AIPSTask('FITTP') fittp.indata = dat fittp.dataout = '/jop87_2/scratch/huang/rp024c/grid_trial/p0beam/beam'+str(no)+'.fits' fittp.go()
except: print 'CHECKPT b' print '***fringemap error 2***' pickle.dump(obs, open(picdir + aipsname + '.pic', 'wb')) uvdata = AIPSUVData(aipsname, 'FITS', indisk, 1) uvdata.zap() uvdata = AIPSUVData(aipsname, 'SPLIT', indisk, 1) uvdata.zap() pca = AIPSCat() try: for j in pca[indisk]: if j['name'][:len(aipsname )] == aipsname and j['klass'] == 'IMAP': imdata = AIPSImage(j['name'], 'IMAP', indisk, j['seq']) imdata.zap() print 'Removing', j['name'], '.IMAP' except: pass AIPSMessageLog().zap() except: print 'CHECK EXC' print '***exception***' time.sleep(60) aipsname = str(fi.split('/')[-1].split('.')[0])[:12] # special provisions: # delete FR606 if we are between L264200 and L266700
for i in range(5): imagr = AIPSTask('IMAGR') imagr.indata = uvdata imagr.sources[1] = sourceID imagr.cellsize[1:] = findmaxb(uvdata) imagr.imsize[1:] = sourceimsize imagr.docalib = 2 imagr.gainuse = i+1 imagr.niter = 1000 imagr.nchav = 64 imagr.outname = 'SC'+str(i+1) imagr.outdisk = indisk imagr.go() image = AIPSImage('SC'+str(i+1),'ICL001',indisk,1) calib = AIPSTask('CALIB') calib.indata = uvdata calib.calsour[1] = sourceID calib.docalib = 2 calib.in2data = image calib.refant = 15 if i+1 == 1: calib.solint = 5 if i+1 == 2: calib.solint = 2 if i+1 == 3: calib.solint = 2 if i+1 == 4: calib.solint = 1
timer=AF.scantime(uvdata, OP.st_scan[i]), refant=OP.st_refant[i], gainu=cl_hv, plotname=OP.st_plotname[i]) if OP.global_fring: for clv in range(40, uvdata.table_highver('CL')): uvdata.zap_table('CL', clv) for snv in range(45, uvdata.table_highver('SN')): uvdata.zap_table('SN', snv) if OP.gf_scan: OP.gf_timer = [] for i in OP.gf_scan: OP.gf_timer = AF.scantime(uvdata, i) if OP.get2n: imfile = AIPSImage(OP.cmap_name, 'CMAP', uvdata.disk, 1) if imfile.exists(): image = [OP.cmap_name, 'CMAP', uvdata.disk, 1] logger.info('Using clean image') if OP.use_bp: cl_hv_af = AF.do_global_fring(uvdata, cals=OP.gf_cals, sources=OP.gf_sources, bpv=1, doband=2, timer=OP.gf_timer, dofit=OP.gf_dofit, antennas=OP.gf_antennas, aparm=OP.gf_aparm, dparm=OP.gf_dparm, refant=OP.gf_refant,
from AIPS import AIPS from AIPSTask import AIPSTask from AIPSData import AIPSImage from ObitTask import ObitTask AIPS.userno = 3601 image = AIPSImage('MANDELBROT', 'MANDL', 1, 1) mandl = AIPSTask('mandl') mandl.outdata = image mandl.imsize[1:] = [512, 512] mandl.go() try: template = ObitTask('Template') template.DataType = 'AIPS' template.inName = image.name template.inClass = image.klass template.inDisk = image.disk template.inSeq = image.seq template.go() finally: image.zap()
nchan = uvdata.header.naxis[2] imagr = AIPSTask('IMAGR') imagr.nchav = nchan #use imagr to get a clean model! imagr.indata = uvdata imagr.outname = uvdata.name imagr.cellsize[1:] = findmaxb(uvdata) imagr.imsize[1:] = imsize,imsize imagr.uvwtfn='NA' imagr.nboxes = 1 imagr.nfield = 1 imagr.outdisk = indisk imagr.niter = niter imagr.go() imagedatacl = AIPSImage('A%s' % i,'ICL001',indisk,1) imean = AIPSTask('IMEAN') imean.indata = imagedatacl imean.indisk = indisk imean.doprint = 1 imean.outtext = 'PWD:IMEAN_%s.txt' % UV_files[i] imean() uvsub = AIPSTask('UVSUB') #Divide visibilites by clean model! uvsub.indata = uvdata uvsub.nmaps = 1 uvsub.in2data = imagedatacl uvsub.inver = 1 uvsub.outdisk = indisk uvsub.ncomp[1] = -1000000
print 'clean: Removal all AIPS catalog entries' print 'usage: doImage clean.py <aipsNumber>' print 'where <aipsNumber> Your *PIPELINE* AIPS number (should always be the same)' print '' quit() AIPS.userno = int(sys.argv[1]) # retrieve AIPS pipeline user number mydisk = 2 # choose a good default work disk baddisk = 1 # list a disk to avoid (0==no avoidance) catalog = AIPSCat()[mydisk] catalog_size = len(catalog) print 'catalog_size', catalog_size for xx in range(catalog_size): aname = AIPSCat()[mydisk][xx].name aclass = AIPSCat()[mydisk][xx].klass aseq = AIPSCat()[mydisk][xx].seq spectra = AIPSUVData(aname, aclass, mydisk, aseq) image = AIPSImage(aname, aclass, mydisk, aseq) if spectra.exists(): spectra.clrstat() elif image.exists(): image.clrstat() AIPSCat().zap() # empty the catalog
fitld.datain = ('PWD:' + uvdataname) fitld.ncount = 1 fitld.doconcat = 1 fitld.clint = 0 fitld.wtthresh = 0 fitld.outdisk = 2 fitld.digicor = -1 fitld.go() if file.endswith(fileend): uvname.append(uvdataname[0:8]) # makes a list of file prefixes to be used in multi self cal, all data is loaded. for i in range(len(uvname)): uvdata = AIPSUVData(uvname[i], 'SPLAT', 2, 1) #name the uv file in AIPS imagedata = AIPSImage(uvname[i], 'IIM001', 2, 1) nchan = uvdata.header.naxis[2] imagr = AIPSTask('IMAGR') imagr.nchav = nchan #use imagr to get a clean model! imagr.indata = uvdata imagr.outname = uvdata.name imagr.cellsize[1:] = findmaxb(uvdata) imagr.imsize[1:] = imsize imagr.nboxes = 1 imagr.nfield = 1 imagr.outdisk = 2 imagr.uvwtfn = '' imagr.niter = niter imagr.go()
def makeslices(imfile, source=False, freq=False, outdisk=1, **kwargs): logger = logging.getLogger('__name__') ''' imfile: location to the image source: source name to use for naming of catalog in aips, if not set the imfile name will be used freq: frequency string to use for naming of catalog in aips, if not set the imfile name will be used ''' args = { 'ang': 0, 'blc': False, 'trc': False, 'nfit': 0, 'gmax': 1, 'gwidth': 9, 'gpos': 0, 'step1': True, #rotate image 'step2': True, #make slices 'step3': True, #fit slices 'step4': True, #plot slices with fit and write output data table 'ang_step': False, 'image_fraction': 1, 'del_imcat': True, # delete image files after program is finished 'plot_slice': False } args.update(kwargs) if not args['blc']: blc, trc = get_blc_trc(imfile, args['image_fraction']) else: blc = args['blc'] trc = args['trc'] nfit = args['nfit'] gmax = args['gmax'] gwidth = args['gwidth'] gpos = args['gpos'] fitdir = 'SLFIT_{}degree'.format(args['ang']) if source: if freq: imname = source + '_' + freq else: imname = source else: imname = imfile.split('/')[-1].split('.')[0] if len(imname) > 12: imname = imname[:12] logger.info('Image name too long, will use \'{}\'\n'.format(imname)) imdata = AIPSImage(*[imname, 'FITS', outdisk, 1]) if imdata.exists() == True: imdata.zap() imcat = AT.imlod(imname, outdisk, imfile, 'FITS') imdata = AIPSImage(*AT.getndata(outdisk, imcat)) if imdata.exists() == True: logger.info('Successfully loaded new image file.\n') logger.info('Data Loaded: (%s, %s, %d, %d)\n', imdata.name, imdata.klass, imdata.disk, imdata.seq) else: logger.info('Image file not loeaded. Check input.\n') return if args['ang_step']: raw_input("Press Enter to continue...") rotname = imname[:10] + '_R' #### if args['step1']: rotdata = AIPSImage(*[rotname, 'FITS', outdisk, 1]) if rotdata.exists() == True: rotdata.zap() rotcat = AT.lgeom(imdata, rotname, outdisk, outseq=1, aparm=[0, 0, args['ang'], 0, 0, 0, 0, 0, 0]) rotdata = AIPSImage(*AT.getndata(outdisk, rotcat)) if rotdata.exists() == True: logger.info('Rotated image exists.\n') else: logger.error('Rotated image not loaded.\n') sys.exit() else: rotdata = AIPSImage(*[rotname, 'FITS', outdisk, 1]) sys.stdout.write('data that will be used {}'.format(rotdata)) ###########3#### if args['step2']: AT.extd(rotdata, 'SL', -1) j = 1 for i in range(blc[0], trc[0]): AT.slices(rotdata, blc=[i, blc[1], 1], trc=[i, trc[1], 1]) if args['plot_slice']: AT.sl2pl(rotdata, inv=j) j += 1 if args['plot_slice']: outfile = '%s_slice.pdf' % rotdata.name AT.lwpla(rotdata, outfile) ############# if args['step3']: if os.path.isdir(fitdir): for f in glob(fitdir + '/*'): os.remove(f) else: os.makedirs(fitdir) if type(gmax) != list: if type(nfit) == int: nn = np.arange(nfit, rotdata.table_highver('SL') + 1) else: nn = np.concatenate([np.arange(n[0], n[1] + 1) for n in nfit]) for ii in nn: gmax1 = gmax gwidth1 = gwidth saveLog = fitdir + '/SLFIT_{}_{}.log'.format(rotdata.name, ii) AT.slfit(rotdata, inv=int(ii), gmax=gmax, gwidth=gwidth, gpos=gpos, savelog=saveLog) lines = [] with open(saveLog, 'r') as f: for line in f: if line.find('LOGFILE') == -1: lines.append(line) # automatically get the fitting results from this slice to use as starting values for the next one jj = 0 for line in lines: if line.find('Results in physical units') != -1: gmax = float(lines[jj + 2].split()[3]) peakunit = lines[jj + 2].split()[5] gwidth = float(lines[jj + 4].split()[3]) gwidthEr = float(lines[jj + 4].split()[4]) if peakunit == 'MicroJy/BEAM': gmax *= 1e-3 #convert everything to MilliJy/beam # elif peakunit == 'MilliJy/BEAM': # gmax *= 1 break jj += 1 if np.logical_or.reduce( (gwidth < gwidthEr, gmax < gmax1 / 5., gmax > 5 * gmax1)): gmax = gmax1 gwidth = gwidth1 else: for gma, gwi, nf in zip(gmax, gwidth, nfit): for ii in range(nf[0], nf[1] + 1): AT.slfit(rotdata, inv=ii, gmax=gma, gwidth=gwi, savelog=fitdir + '/SLFIT_{}_{}.log'.format(rotdata.name, ii)) ########### if args['step4']: AT.extd(rotdata, 'PL', -1) for i in range(0, trc[0] - blc[0]): AT.sl2pl(rotdata, inv=i + 1, domod=1, dores=1) outfile = '{}_fit_{}degree'.format(rotdata.name, args['ang']) AT.lwpla(rotdata, outfile + '.pdf', docol=1, plcolors=[[0, 0, 0], [0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [1, 1, 1]]) AT.slcol(rotdata, outfile + '.txt', inv=1, nfiles=rotdata.table_highver('SL')) ################# if args['del_imcat']: sys.stdout.write('Deleting loaded map catalog and rotated catalog.\n') rotdata.zap() imdata.zap()
from AIPS import AIPS from AIPSTask import AIPSTask from AIPSData import AIPSImage AIPS.userno = 1999 image = AIPSImage('MANDELBROT', 'MANDL', 1, 1) if image.exists(): image.zap() mandl = AIPSTask('mandl') mandl.outdata = image mandl.imsize[1:] = [512, 512] mandl.go() try: image.rename('APPLE') assert (image.exists()) assert (AIPSImage('APPLE', 'MANDL', 1, 1).exists()) assert (not AIPSImage('MANDELBROT', 'MANDL', 1, 1).exists()) image.rename(seq=8) assert (image.exists()) assert (image.seq == 8) image.rename(klass='APPLE', seq=99) assert (image.exists()) image.rename(klass='PEAR', seq=0) assert (image.exists()) assert (image.seq != 0) image.rename('MANDLEBROT', seq=1) assert (image.exists()) try:
def makeaipsimage(data): image = AIPSImage(data[0], data[1], data[2], data[3]) return image
# now image all the uvfiles, base the imaging size larger than each square pca = AIPSCat(indisk) print 'run widemaps' for fitsfil in pca[indisk]: if (target in fitsfil.name) and ('UV' in fitsfil.klass): # uvdata = AIPSUVData(fitsfil.name, fitsfil.klass, indisk, fitsfil.seq) #widemaps(uvdata,indisk,fovradius,target,noiter) widebandmaps(uvdata, indisk, fovradius, target, noiter) #''' #now use APCLN added nwrigley 20141106 pca = AIPSCat(indisk) for fitsfil in pca[indisk]: if (target in fitsfil.name) and ('IIM' in fitsfil.klass): imdata = AIPSImage(fitsfil.name, fitsfil.klass, indisk, fitsfil.seq) apclean(imdata, target) #''' print 'run trimmer' # trim and flatten the images pca = AIPSCat(indisk) for fitsfil in pca[indisk]: if (target in fitsfil.name) and ('ICL' in fitsfil.klass): # imdata = AIPSImage(fitsfil.name, fitsfil.klass, indisk, fitsfil.seq) #flat(imdata,fovradius,target) trimmer(imdata, fovradius, target) print 'run flatn' runflatn(imdata, fovradius, target)
def zapim(inna, incl, indisk, top, bottom): for i in range(top, bottom - 1, -1): try: im = AIPSImage(inna, incl, indisk, i).zap() except: pass
defaultName = 'Pipeline' #Enforce name > 5 characters if len(outName) < 6: outName = defaultName[0:(6 - len(outName))] + outName print 'Outname : ', outName print 'RestFreq: ', restFreqMHz, ' (MHz)' print 'Velocity: ', velocityKmS, ' (km/s)' print 'VelWidth: ', velWidthKmS, ' (km/s)' fittp = AIPSTask('fittp') momnt = AIPSTask('momnt') subim = AIPSTask('subim') image = AIPSImage(AIPSCat()[mydisk][-1].name, 'IMLIN', mydisk, 1) # now read parameters passed inside the data header nChan = round(image.header.naxis[0]) refChan = image.header.crpix[0] nuRef = image.header.crval[0] dNu = image.header.cdelt[0] print nChan, refChan, nuRef, dNu #set rest frequency to select out the line restFreq = restFreqMHz * 1.e6 cLightKmSec = 299792.458 # speed of light in Km/Sec #These constants are particular to each source
def douvcon (antfile,freq,dec,hastart,haend,tint,chwid,nchan,outname,\ in2name='ZEROS',in2class='FITS',indisk=1,cmodel='CC',phserr=0.0,\ amperr=0.0,cboth=1.0,noisemult=0.0): uvcon = AIPSTask('uvcon') uvcon.infile = antfile if antfile[0] in './' else './' + antfile uvcon.in2name = in2name uvcon.in2class = in2class uvcon.in2disk = indisk uvcon.cmodel = cmodel uvcon.outname = outname uvcon.aparm[1:] = [ freq, 0.0, dec, hastart, haend, 0.0, tint, chwid, nchan, 0.0 ] uvcon.bparm[1:] = [ noisemult, 0.0, -1.0 * phserr, amperr, cboth, 0.0, 0.0, 0.0, 0.0, 0.0 ] save_stdout = sys.stdout sys.stdout = open('uvcon.log', 'a') uvcon.inp() sys.stdout = save_stdout uvcon.go() multi = AIPSTask('multi') multi.inname = outname multi.inclass = 'UVCON' multi.indisk = indisk multi.outclass = 'MULTI' multi.outname = outname multi.outdisk = indisk multi.go() # find the seqno of the file we just created uvcon_file_seq = findexisting(outname, 'MULTI') is_sutable = findexisting('sutable', 'fits') # load the source table if it's not on disk if not is_sutable: fitld = AIPSTask('fitld') fitld.datain = './sutable.fits' fitld.outdisk = indisk fitld.outname = 'sutable' fitld.outclass = 'fits' fitld.go() # and copy it to the uv data file we just created tacop = AIPSTask('tacop') tacop.inname = 'sutable' tacop.inclass = 'fits' tacop.indisk = indisk tacop.outname = outname tacop.outclass = 'MULTI' tacop.outseq = uvcon_file_seq tacop.outdisk = indisk tacop.inext = 'SU' tacop.go() # get a list of the antennas from the uv data file ants = np.array([]) f = open(antfile) flines = 0 for line in f: flines += 1 if '#' in line: thisant = line.split('#')[1].lstrip().rstrip() ants = np.append(ants, thisant.split()[0]) f.close() AIPSImage(in2name, in2class, indisk, 1).clrstat() if len( ants ) == flines - 3: # if we have antennas for all lines except the first 3 header lines insertants(outname, ants, inclass='MULTI')
fitld.go() fitld = AIPSTask('FITLD') fitld.datain = (directory + str(i + 2) + '/S2_model.fits') fitld.ncount = 1 fitld.doconcat = 0 fitld.clint = 0 fitld.wtthresh = 0 fitld.outname = 'S2' fitld.outclass = 'IM' fitld.outdisk = indisk fitld.digicor = -1 fitld.go() uvdata = AIPSUVData(AIPSuvdataname, 'UV', indisk, 1) image = AIPSImage('S1', 'IM', indisk, 1) uvsub = AIPSTask('UVSUB') uvsub.indata = uvdata uvsub.outdata = uvdata uvsub.in2data = image uvsub.ncomp[1] = -1000000 uvsub.factor = 1.0 uvsub.opcode = '' uvsub.go() uvdata = AIPSUVData(AIPSuvdataname, 'UV', indisk, 1) image = AIPSImage('S2', 'IM', indisk, 1) uvsub = AIPSTask('UVSUB') uvsub.indata = uvdata uvsub.in2data = image uvsub.ncomp[1] = -1000000
import math import os import urllib AIPS.userno = 1999 # Download a smallish FITS file from the EVN archive. url = 'http://archive.jive.nl/exp/N05L1_050301/pipe/n05l1_4C39.25_ICLN.FITS' file = '/tmp/' + os.path.basename(url) if not os.path.isfile(file): urllib.urlretrieve(url, file) assert (os.path.isfile(file)) name = os.path.basename(url).split('_')[1].upper() image = AIPSImage(name, 'ICLN', 1, 1) if image.exists(): image.zap() pass assert (not image.exists()) fitld = AIPSTask('fitld') fitld.datain = file fitld.outdata = image fitld.go() assert (image.exists()) try: image = WizAIPSImage(image)
if not options.calibrateonly: vlbatasks.applysntable(targetdata, snversion, "SELN", clversion, refant) snversion += 1 clversion += 1 # Correct for leakage if needed #leakagedopol = 0 if xpolmodelfile != "": # First the xpoldelays if not options.targetonly: xpolscan = 1 if not os.path.exists(xpolmodelfile): print "Can't find xpol delay model " + xpolmodelfile print "Aborting!!" sys.exit(1) xpolmodel = AIPSImage("LKGSRC", "CLEAN", 1, 1) if xpolmodel.exists(): xpolmodel.zap() vlbatasks.fitld_image(xpolmodelfile, xpolmodel) xpolsolintmins = 1 inttimesecs = 0.5 # Doesn't matter if this is wrong if os.path.exists(xpolsnfilename): os.remove(xpolsnfilename) vlbatasks.xpoldelaycal(caldata, clversion, refant, options.sourcename, xpolscan, xpolmodel, xpolsolintmins, inttimesecs, xpolsnfilename, delaywindow, ratewindow) vlbatasks.loadtable(caldata, xpolsnfilename, snversion) vlbatasks.applysntable(caldata, snversion, '2PT', clversion, refant) if not options.calibrateonly: vlbatasks.loadtable(targetdata, xpolsnfilename, snversion)