#!/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,
# Retrieve FITS file name, respecting CASA options. ifile = admit.utils.casa_argv(sys.argv)[1] # Create (or re-open) the ADMIT project. # Our project directory is the input path with extension set to admit. proj = admit.Project(os.path.splitext(ifile)[0] + '.admit', commit=False) # Ingest the FITS cube. 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.
#! /usr/bin/env casarun # # Example multi-file admit flow, hardcoded for a specific 4-spw case # # REMOVE existing project directory before running script for the first time! # 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()
if stop == 'smooth': a.exit(1) else: bandcube1_orig = () # ingest-cont: only used for source finding for CubeSpectrum, this map is not used # to subtract the continuum, since there is no guarentee about the # resolution ('cont' maps usually mismatch, 'mfs' maps are ok but not # part of the ALMA pipeline if cont != '': # @todo note we don't have an option here to do pb? ingest2 = a.addtask( admit.Ingest_AT(file=cont, basename=basename, alias='sfcont')) contmap = (ingest2, 0) a.run() # cubestats2 = a.addtask(admit.CubeStats_AT(), [contmap]) #a[cubestats1].setkey('robust',robust) csttab2 = (cubestats2, 0) sfind2 = a.addtask(admit.SFind2D_AT(), [contmap, csttab2]) cslist = (sfind2, 0) a.run() ncs = len(a[cslist[0]][0]) print "N Cont sources in ingested contmap :", ncs if ncs == 0: cslist = () else: cslist = () # cubestats cubestats1 = a.addtask(admit.CubeStats_AT(), [bandcube1]) a[cubestats1].setkey('robust', robust)
# list object for Tasks so we don't have to individually name them Tasks = [] if pbcorfile == None: Tasks.append( p.addtask( admit.Ingest_AT(alias='incube', file=cubefile, box=KEYS["box"]))) else: Tasks.append( p.addtask( admit.Ingest_AT(alias='incube', file=cubefile, pb=pbcorfile, box=KEYS["box"]))) Tasks.append(p.addtask(admit.CubeStats_AT(alias='instats'), ['incube'])) Tasks.append( p.addtask(admit.CubeSum_AT(sigma=1, numsigma=3.0, alias='insum'), ['incube', 'instats'])) Tasks.append( p.addtask(admit.CubeSpectrum_AT(alias='spec1'), ['incube', 'insum'])) 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(
print "All done, we just read an existing admit.xml and it should do nothing" a.fm.diagram(a.dir() + 'admit.dot') a.show() a.showsetkey() sys.exit(0) # doesn't work properly in IPython! # Default ADMIT plotting environment a.plotparams(plotmode, plottype) # Ingest ingest1 = a.addtask(admit.Ingest_AT(file=file, alias=alias)) a[ingest1].setkey('mask', useMask) bandcube1 = (ingest1, 0) # CubeStats - will also do log(Noise),log(Peak) plot cubestats1 = a.addtask(admit.CubeStats_AT(), [bandcube1]) a[cubestats1].setkey('robust', robust) a[cubestats1].setkey('ppp', usePPP) csttab1 = (cubestats1, 0) # CubeSum moment1 = a.addtask(admit.CubeSum_AT(), [bandcube1, csttab1]) a[moment1].setkey('numsigma', 4.0) # Nsigma clip in cube # >0 force single cuberms sigma from cubestats; <0 would use rms(freq) table a[moment1].setkey('sigma', 99.0) csmom0 = (moment1, 0) # CubeSpectrum if len(maxpos) > 0: cubespectrum1 = a.addtask(admit.CubeSpectrum_AT(), [bandcube1]) a[cubespectrum1].setkey('pos', maxpos)
KEYS["pad"] = int(KEYS["pad"]) KEYS["cutoff"] = ast.literal_eval(str(KEYS["cutoff"])) except Exception, e: print("Exception converting keyword value to number:", e) return # # Set-up all ADMIT Flow tasks for execution including their aliases and connections # The aliases allow you to refer to a task's input by the alias name of the (previous) # task providing that input. # if pbcorfile == None: Task0 = p.addtask(admit.Ingest_AT(file=cubefile, alias='incube')) else: Task0 = p.addtask( admit.Ingest_AT(file=cubefile, pb=pbcorfile, alias='incube')) Task1 = p.addtask(admit.CubeStats_AT(alias='instats'), ['incube']) Task2 = p.addtask(admit.CubeSum_AT(sigma=1, numsigma=3.0, alias='insum'), ['incube', 'instats']) Task3 = p.addtask(admit.CubeSpectrum_AT(alias='spec1'), ['incube', 'insum']) Task4 = p.addtask( admit.LineID_AT(csub=[1, 1], minchan=KEYS["minchan"], numsigma=KEYS["numsigma"], alias='lines'), ['instats', 'spec1']) Task5 = p.addtask(admit.LineCube_AT(alias='cutcubes', pad=KEYS["pad"]), ['incube', 'lines']) Task6 = p.addtask( admit.Moment_AT(mom0clip=3.0, numsigma=KEYS["cutoff"], moments=[0, 1, 2],
bandcube2 = (smooth1, 0) # Forget about the original, so we can continue the flow with the smoothed cube # in this model, it would be better to use insmooth= for Ingest_AT, it doesn't # need the extra space to hold bandcube1 # # Another model could be to have two flows in this script, up to LineID, # one with each (or more) smoothing factor and decide which one to continue with # or do LineID with bandcube2, but make linecube's from bandcube1 bandcube1 = bandcube2 # If a continuum image was given, set up to ingest it and run # source-find on it. if cont != '': ingest2 = a.addtask(admit.Ingest_AT(file=cont, alias=alias + '-cont')) contmap = (ingest2, 0) cubestats2 = a.addtask(admit.CubeStats_AT(), [contmap]) csttab2 = (cubestats2, 0) sfind2 = a.addtask(admit.SFind2D_AT(), [contmap, csttab2]) cslist = (sfind2, 0) else: cslist = () # CubeStats - will also do log(Noise),log(Peak) plot cubestats1 = a.addtask(admit.CubeStats_AT(), [bandcube1]) a[cubestats1].setkey('robust', robust) a[cubestats1].setkey('ppp', usePPP) csttab1 = (cubestats1, 0) # CubeSum moment1 = a.addtask(admit.CubeSum_AT(), [bandcube1, csttab1]) a[moment1].setkey('numsigma', 4.0) # Nsigma clip in cube
import admit import os 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()