def _run(argv): # Verify arguments are good if ( not admit.recipeutils._processargs(argv,REQARGS,OPTARGS,KEYS,KEYDESC,__doc__)): return bdpname = argv[1] cubefile = argv[2] projdir = os.path.splitext(argv[2])[0] + '.admit' pbcorfile = None if len(argv) == 4: pbcorfile = argv[3] #======================================================================== # Master project. Beginning for ADMIT Commands # p = admit.Project(projdir,commit=False) # # 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. # Task0 = p.addtask(admit.BDPIngest_AT( alias='bdptable', file=bdpname )) if pbcorfile == None: Task1 = p.addtask(admit.Ingest_AT(alias='incube', file=cubefile )) else: Task1 = p.addtask(admit.Ingest_AT(alias='incube', file=cubefile, pb=pbcorfile)) Task2 = p.addtask(admit.CubeSpectrum_AT(alias='cubespec',xaxis=KEYS["xaxis"]), ['incube', 'bdptable']) # # Execute ADMIT flow # p.run()
# 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. # 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.)
#!/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,
try: sfind1 = a.addtask(admit.SFind2D_AT(alias='csm'), [csmom0]) a[sfind1].setkey('numsigma', numsigma) a.run() ncs = len(a[sfind1][0]) print "N sources in CSM:", ncs if ncs > 0: cslist = (sfind1, 0) except: print "SFind2D failed on the CSM map... Continuing on" # PJT testing # a.exit(1) # CubeSpectrum if len(maxpos) > 0: cubespectrum1 = a.addtask(admit.CubeSpectrum_AT(), [bandcube1]) a[cubespectrum1].setkey('pos', maxpos) else: bdp_in = [bandcube1] if cspbdp[0] and len(csttab1) > 0: bdp_in.append(csttab1) if cspbdp[1] and len(csmom0) > 0: bdp_in.append(csmom0) if cspbdp[2] and len(cslist) > 0: bdp_in.append(cslist) # could be CONT or CSM #print "CSP: using %d bpd's" % (len(bdp_in)) #print "BDP_IN",bdp_in cubespectrum1 = a.addtask(admit.CubeSpectrum_AT(), bdp_in) a[cubespectrum1].setkey('sources', sources) csptab1 = (cubespectrum1, 0) if stop == 'cubespectrum': a.exit(1)
#! /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()
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( p.addtask(admit.LineCube_AT(alias='cutcubes', pad=KEYS["pad"]), ['incube', 'lines'])) Tasks.append( p.addtask( admit.Moment_AT(alias='linemom',
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], alias='linemom'), ['cutcubes', 'instats']) Task7 = p.addtask(admit.CubeSpectrum_AT(alias='linespec'), ['cutcubes', 'linemom'])
Tasks = [] # # 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. # # 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:
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}")