def runTest(self): try: # instantiate the Admit class a = admit.Project(self.admitdir) # set up to write out figure files a.plotparams(admit.PlotControl.BATCH, admit.PlotControl.PNG) fitsin = admit.Ingest_AT(file=self.inputFile) task0id = a.addtask(fitsin) # instantiate a moment AT and set some moment parameters m = admit.Moment_AT() m.setkey('moments', [0, 1, 2]) m.setkey('sigma', 0.005) m.setkey('numsigma', [3.0]) task1id = a.addtask(m, [(task0id, 0)]) # check the fm a.fm.verify() # run admit a.run() # save it out to disk. a.write() a2 = admit.Project( self.admitdir) # read in the admit.xml and bdp files self.assertEqual(len(a.fm), len(a2.fm)) for atask in a.fm: self.assertEqual(len(a.fm[atask]._bdp_out), len(a2.fm[atask]._bdp_out)) # Note: we don't check bdp_in because they are connected # "just in time" so will be set None up read-in. self.assertEqual(a.fm._connmap, a2.fm._connmap) for at in a.fm: for i in range(len(a.fm[at]._bdp_out)): self.assertEqual(a.fm[at]._bdp_out[i]._taskid, a2.fm[at]._bdp_out[i]._taskid) self.assertEqual(a.fm[at]._bdp_out[i].xmlFile, a2.fm[at]._bdp_out[i].xmlFile) self.success = "OK" except Exception, e: m = "exception=%s, file=%s, lineno=%s" % ( sys.exc_info()[0].__name__, os.path.basename( sys.exc_info()[2].tb_frame.f_code.co_filename), sys.exc_info()[2].tb_lineno) self.success = "FAILED" traceback.print_exc() self.fail("%s failed with: %s" % (self.__class__.__name__, m))
proj.addtask(admit.Ingest_AT(file=ifile, alias='cube')) # Cube manipulation template. tmpl = proj.addtask(admit.Template_AT(imgslice=550, specpos=(183, 151)), ['cube']) # Calculate some statistics on the FITS cube (including peak point plot). cstats = proj.addtask(admit.CubeStats_AT(ppp=True), ['cube']) # Calculate the moment-0 (integrated intensity) map for the entire cube. csum = proj.addtask(admit.CubeSum_AT(numsigma=4., sigma=99.), ['cube', cstats]) # Calculate the source spectrum at (by default) the peak position in the cube. cspect = proj.addtask(admit.CubeSpectrum_AT(), ['cube', csum]) # Identify lines in the cube. lines = proj.addtask(admit.LineID_AT(numsigma=4.0, minchan=3), [cspect, cstats]) # Cut input cube into line-specific sub-cubes (padding lines by 10 channels). lcubes = proj.addtask(admit.LineCube_AT(pad=10), ['cube', lines]) # Finally, compute moment-0,1,2 maps and peak position spectrum for each line. # Since lcubes is variadic, the following tasks will be replicated as needed. mom = proj.addtask(admit.Moment_AT(moments=[0, 1, 2], mom0clip=2.0), [lcubes, cstats]) csp = proj.addtask(admit.CubeSpectrum_AT(alias='lcs'), [lcubes, mom]) # Run project and save to disk. (Open project index.html to view summary.) proj.run()
#!/usr/bin/env casarun import admit NUM_SIGMA = 2 MIN_CHAN = 2 MAX_CHAN = 10 FITS_CUBE = "/media/haotian/documents-local/ASTR4998/data/products/SerpS_TC_spw5.pbcor_cutout_180_180_100_line.fits" VLSR = 8.0 if __name__ == "__main__": p = admit.Project("{}.admit_BDP".format(FITS_CUBE), dataserver=True) t0 = p.addtask(admit.Ingest_AT(file=FITS_CUBE)) t1 = p.addtask(admit.CubeStats_AT(ppp=True), [t0]) t2 = p.addtask(admit.Moment_AT(mom0clip=2.0, numsigma=[NUM_SIGMA]), [t0, t1]) t3 = p.addtask(admit.CubeSpectrum_AT(), [t0, t2]) t5 = p.addtask( admit.LineSegment_AT(maxgap=MAX_CHAN, minchan=MIN_CHAN, numsigma=NUM_SIGMA, csub=[0, 0]), [t1, t3]) t6 = p.addtask(admit.ContinuumSub_AT(), [t0, t5]) t7 = p.addtask(admit.CubeStats_AT(ppp=True), [t6]) t8 = p.addtask(admit.Moment_AT(mom0clip=2.0, numsigma=[NUM_SIGMA]), [t6, t7]) t9 = p.addtask(admit.CubeSpectrum_AT(), [t6, t8]) t10 = p.addtask( admit.LineID_AT(allowexotics=True, maxgap=MAX_CHAN, minchan=MIN_CHAN, numsigma=NUM_SIGMA,
# a.fm.diagram(a.dir() + 'admit.dot') a.show() a.showsetkey() sys.exit(0) #doesn't work in IPython! # Default ADMIT plotting environment a.plotparams(plotmode, plottype) pm = a.getManager() # get ProjectManager bdps = [] for ap in argv[2:]: # loop over projects _p = pm.addProject(ap) # Search for Moment_AT tasks in the projects ats = pm.findTask(_p, lambda at: type(at) == type(admit.Moment_AT())) print "Found %d Moment_AT's in %s" % (len(ats), ap) for at in ats: tid = a.addtask(at) # add the AT to the bdps.append((tid, 0)) # for now, assume '0' was the mom0 print "Moment_AT ", ap, tid, 0 print "ADIR:", argv[2:] print "Found %d BDP's" % len(bdps) print "BDPs:", bdps pca = a.addtask(admit.PrincipalComponent_AT(), bdps) # Run the flow, write the outputs, update the web page. a.run() a.write()
if stop == 'linecube': a.exit(1) x = range(nlines) # place holder to contain mol/line m = {} # task id for moment on this mol/line sp = {} # task id for cubespectrum on this mol/line st = {} # task id for cubestats # loop over all lines # produce moments and spectra from the linecubes just created for i in range(nlines): x[i] = a[linecube1][i].getimagefile() print "LineDir:", i, x[i] # Moment maps from the LineCube linecubei = (linecube1, i) m[x[i]] = a.addtask(admit.Moment_AT(), [linecubei, csttab1]) print "MOMENT_AT:", m[x[i]] a[m[x[i]]].setkey('moments', [0, 1, 2]) #a[m[x[i]]].setkey('moments',[0]) #a[m[x[i]]].setkey('cutoff',[2.0,3.0,3.0]) a[m[x[i]]].setkey('numsigma', [2.0]) a[m[x[i]]].setkey('mom0clip', 2.0) if usePeak: if useCSM: momenti0 = csmom0 # CubeSum mom0 else: momenti0 = (m[x[i]], 0) # this linecube mom0 # CubeSpectrum through the line cube where the mom0 map has peak sp[x[i]] = a.addtask(admit.CubeSpectrum_AT(), [linecubei, momenti0]) elif len(maxpos) > 0: # CubeSpectrum through the line cube at given point,
import admit # Master project. p = admit.Project('all-cubes.admit', commit=False) # Flow tasks. t0 = p.addtask(admit.Ingest_AT(file='concat.spw17.image.fits')) t1 = p.addtask(admit.CubeStats_AT(), [t0]) t2 = p.addtask(admit.CubeSum_AT(numsigma=5.0, sigma=1.0), [t0, t1]) t3 = p.addtask(admit.CubeSpectrum_AT(alias='spec11'), [t0, t2]) t4 = p.addtask(admit.LineSegment_AT(minchan=4, maxgap=4, numsigma=6.0), [t1, t3]) t5 = p.addtask(admit.ContinuumSub_AT(fitorder=1, pad=40), [t0, t4]) t5a = p.addtask(admit.CubeStats_AT(), [t5]) t6 = p.addtask(admit.CubeSpectrum_AT(alias='spec12'), [t5, t2]) t7 = p.addtask(admit.Moment_AT(mom0clip=2.0, numsigma=[3.0]), [t5, t1]) t8 = p.addtask(admit.PVSlice_AT(clip=0.3, width=5), [t5, t2]) t9 = p.addtask(admit.PVCorr_AT(), [t8, t1]) t10 = p.addtask( admit.LineID_AT(csub=[1, 1], minchan=3, maxgap=4, numsigma=6.0), [t5a, t6]) t11 = p.addtask(admit.LineCube_AT(pad=40), [t5, t10]) t12 = p.addtask(admit.Moment_AT(mom0clip=2.0, moments=[0, 1, 2]), [t11, t1]) t13 = p.addtask(admit.CubeSpectrum_AT(), [t11, t12]) p.run() # Flow tasks. t20 = p.addtask(admit.Ingest_AT(file='concat.spw19.image.fits')) t21 = p.addtask(admit.CubeStats_AT(), [t20]) t22 = p.addtask(admit.CubeSum_AT(numsigma=4.0, sigma=1), [t20, t21]) t24 = p.addtask(admit.CubeSpectrum_AT(alias='spec13'), [t20, t22])
Tasks.append( p.addtask(admit.PVSlice_AT(alias="cubepv", width=KEYS["width"]), ['incube', 'insum'])) Tasks.append( p.addtask( admit.LineID_AT(csub=[1, 1], minchan=KEYS["minchan"], numsigma=KEYS["numsigma"], alias='lines'), ['instats', 'spec1'])) Tasks.append( p.addtask(admit.LineCube_AT(alias='cutcubes', pad=KEYS["pad"]), ['incube', 'lines'])) Tasks.append( p.addtask( admit.Moment_AT(alias='linemom', mom0clip=3.0, numsigma=KEYS["cutoff"], moments=[0, 1, 2]), ['cutcubes', 'instats'])) Tasks.append( p.addtask(admit.CubeSpectrum_AT(alias='linespec'), ['cutcubes', 'linemom'])) # While 'linemom' produces 3 moment image BDPs, the default input is taken # here, which is the first BDP which is the zeroth moment. This relies on # Moment_AT's default behavior of putting the zeroth moment in the # BDP index 0. Tasks.append( p.addtask(admit.PVSlice_AT(alias="linepv", width=KEYS["width"]), ['cutcubes', 'linemom'])) # # Execute ADMIT flow # p.run()
# task providing that input. # # Add spectral line processing to flow if KEYS["specpb"] == None: Tasks.append(p.addtask(admit.Ingest_AT(file=cubefile, alias='incube'))) else: Tasks.append(p.addtask(admit.Ingest_AT(file=cubefile, alias='incube', pb=KEYS["specpb"]))) Tasks.append(p.addtask(admit.CubeStats_AT (alias='instats'), ['incube'])) Tasks.append(p.addtask(admit.CubeSum_AT (alias='insum', sigma=1, numsigma=3.0), ['incube', 'instats'])) Tasks.append(p.addtask(admit.CubeSpectrum_AT (alias='spec1'), ['incube', 'insum'])) Tasks.append(p.addtask(admit.PVSlice_AT ( width=KEYS["width"]), ['incube', 'insum'])) Tasks.append(p.addtask(admit.LineID_AT (alias='lines', csub=[0,0], minchan=KEYS["minchan"], numsigma=KEYS["numsigma"]), ['instats','spec1'])) Tasks.append(p.addtask(admit.LineCube_AT (alias='cutcubes', pad=KEYS["pad"]), ['incube', 'lines'])) Tasks.append(p.addtask(admit.Moment_AT (alias='linemom', mom0clip=2.0, numsigma=KEYS["cutoff"], moments=[0, 1, 2]), ['cutcubes', 'instats'])) Tasks.append(p.addtask(admit.CubeSpectrum_AT (alias='linespec'), ['cutcubes', 'linemom'])) # While 'linemom' produces 3 moment image BDPs, the default input is taken # here, which is the first BDP which is the zeroth moment. This relies on # Moment_AT's default behavior of putting the zeroth moment in the # BDP index 0. Tasks.append(p.addtask(admit.PVSlice_AT ( width=KEYS["width"]), ['cutcubes', 'linemom'])) # If given, add continuum map processing to flow if contfile != None: if KEYS["contpb"] == None: Tasks.append(p.addtask(admit.Ingest_AT (alias='incont', file=contfile))) else: Tasks.append(p.addtask(admit.Ingest_AT (alias='incont', file=contfile, pb=KEYS["contpb"])))
project = os.getenv('PROJECT') if project is None: raise ValueError else: print(f"Project -> {project}") basefn = os.path.basename(project).replace(".image", "") print(f"basefn = {basefn}") p = admit.Project(f'{basefn}.admit', dataserver=True) # Flow tasks. t0 = p.addtask(admit.Ingest_AT(file=basefn + '.image')) t1 = p.addtask(admit.CubeStats_AT(ppp=True), [t0]) t2 = p.addtask(admit.CubeSum_AT(numsigma=5.0, sigma=99.0), [t0, t1]) t3 = p.addtask(admit.CubeSpectrum_AT(), [t0, t2]) t4 = p.addtask( admit.LineSegment_AT(csub=[0, 0], minchan=4, maxgap=6, numsigma=5.0), [t1, t3]) t5 = p.addtask(admit.ContinuumSub_AT(fitorder=1, pad=60), [t0, t4]) t6 = p.addtask(admit.CubeStats_AT(ppp=True), [t5]) t7 = p.addtask(admit.CubeSpectrum_AT(), [t5, t6]) t8 = p.addtask(admit.Moment_AT(mom0clip=2.0, numsigma=[3.0]), [t5, t6]) t9 = p.addtask(admit.LineID_AT(csub=[0, 0], minchan=4, maxgap=6, numsigma=5.0), [t6, t7]) t10 = p.addtask(admit.LineCube_AT(pad=40), [t5, t9]) t11 = p.addtask(admit.Moment_AT(mom0clip=2.0, moments=[0, 1, 2]), [t10, t6]) t11 = p.addtask(admit.CubeSpectrum_AT(), [t10, t11]) p.run() print(f"Done running ADMIT for {basefn} <-> {project}")