コード例 #1
0
    def runTest(self):
        try:
            # instantiate the class

            a = admit.Project(self.admitdir)

            #use a GenerateSpectrum_AT that reads in a spectrum
            gs1 = a.addtask(
                admit.GenerateSpectrum_AT(file=self.specfile,
                                          freq=124.470,
                                          seed=-1))
            gstab1 = (gs1, 0)

            # instantiate a LineSegment AT and set parameters
            l = admit.LineSegment_AT()
            task1id = a.addtask(l, [gstab1])
            a.fm.verify()
            a.run()
            # read in the admit.xml and bdp files
            a2 = admit.Project(self.admitdir)
            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))
コード例 #2
0
    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.Smooth_AT()
            m.setkey('bmaj', {'value': 10.0, 'unit': 'arcsec'})
            m.setkey('bmin', {'value': 10.0, 'unit': 'arcsec'})
            m.setkey('velres', {'value': 205, 'unit': 'km/s'})
            m.setkey('bpa', 0.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))
コード例 #3
0
    def test_variflow(self):
        p = admit.Project(self.outputDir)
        p.setlogginglevel(50)
        p.addtask(admit.File_AT(alias='root', file='root', touch=True))
        p.addtask(admit.Flow11_AT(alias='flow1'), ['root'])
        p.addtask(admit.Flow1N_AT(alias='flow1N', n=2, touch=True, exist=True),
                  ['root'])
        p.addtask(admit.Flow11_AT(alias='sub1Nf'), ['flow1N'])
        p.addtask(admit.Flow11_AT(alias='sub1Nv'), [('flow1N', 1)])
        p.addtask(admit.FlowMN_AT(alias='flowMN', n=2, touch=True, exist=True),
                  ['flow1', 'root', ('flow1N', 1)])
        p.addtask(admit.Flow11_AT(alias='subMNf'), ['flowMN'])
        p.addtask(admit.FlowN1_AT(alias='subMNv', touch=True), [('flowMN', 0),
                                                                ('flowMN', 2)])
        p.addtask(admit.FlowN1_AT(alias='flowN1', touch=True),
                  ['flow1N', ('flowMN', 1)])
        p.addtask(admit.Flow11_AT(alias='subN1'), ['flowN1'])

        p.show()
        for n in [2, 3, 1, 2]:
            if (p.fm.find(lambda at: at._alias == 'flow1N')):
                p['flow1N'].setkey('n', n)
            if (p.fm.find(lambda at: at._alias == 'flowMN')):
                p['flowMN'].setkey('n', n + 1)

            p.run()
            p.show()

        self.assertLessEqual(len(p), 20, "Incorrect task count")
コード例 #4
0
ファイル: unittest_Admit.py プロジェクト: teuben/admit
    def test_find_bdp(self):
        project = admit.Project()

        # add one task
        task = admit.File_AT(touch=True)
        name = "File.dat"
        task.setkey("file", name)

        project.addtask(task)  # add task

        # now add an output bdp
        obdp = admit.File_BDP('Test')
        task.addoutput(obdp)

        self.p.addtask(task)

        # find_bdp() will search Admit output data directory for *.bdp files
        # should return an empty list since no *.bdp file created by this test
        ret = self.p.find_bdp()
        outdir = self.p.dir()
        if (self.verbose):
            if len(ret):
                print "Found BDPs in", outdir
            else:
                print "No BDPs Found in", outdir

        self.assertTrue(len(ret) == 0)
コード例 #5
0
ファイル: Archive_SpecLine.py プロジェクト: teuben/admit
def _run(argv):

    # Verify arguments are good
    if (not admit.recipeutils._processargs(argv, REQARGS, OPTARGS, KEYS,
                                           KEYDESC, __doc__)):
        return

    cubefile = argv[1]
    projdir = os.path.splitext(argv[1])[0] + '.admit'
    pbcorfile = None
    if len(argv) == 3:
        pbcorfile = argv[2]
    #========================================================================
    # Master project.  Beginning for ADMIT Commands
    #
    p = admit.Project(projdir, commit=False)

    # convert key values from string
    try:
        KEYS["minchan"] = int(KEYS["minchan"])
        KEYS["numsigma"] = float(KEYS["numsigma"])
        KEYS["pad"] = int(KEYS["pad"])
        KEYS["width"] = int(KEYS["width"])
        KEYS["cutoff"] = ast.literal_eval(str(KEYS["cutoff"]))
        KEYS["box"] = ast.literal_eval(str(KEYS["box"]))
    except Exception, e:
        print("Exception converting keyword value to number:", e)
        return
コード例 #6
0
ファイル: Source_Spectra.py プロジェクト: teuben/admit
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()
コード例 #7
0
ファイル: runtest_helloworld.py プロジェクト: teuben/admit
    def runTest(self):
        try:
            # instantiate the class
            a = admit.Project(self.admitdir)

            # instantiate hello world at
            h = admit.HelloWorld_AT(yourname="Bob")

            task1id = a.addtask(h)

            # check the fm
            a.fm.verify()

            # run admit and save to disk
            a.run()

            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))
                if (len(a.fm[atask]._bdp_in) != 0
                        and len(a2.fm[atask]._bdp_in) != 0):
                    self.assertEqual(a.fm[atask]._bdp_in[0]._taskid,
                                     a2.fm[atask]._bdp_in[0]._taskid)

            self.assertEqual(a.fm._connmap, a2.fm._connmap)

            for at in a.fm:
                for i in range(len(a.fm[at]._bdp_out)):
                    print "%d %d %d %s %s\n" % (i,
                                                a.fm[at]._bdp_out[i]._taskid,
                                                a2.fm[at]._bdp_out[i]._taskid,
                                                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))
コード例 #8
0
ファイル: unittest_Admit.py プロジェクト: teuben/admit
    def setUp(self):
        self.verbose = False
        self.testName = "Admit Unit Test"

        # sometimes CWD is set to self.outputDir that is deleted by
        # tearDown() function, then we need to change back to the parent dir
        try:
            os.getcwd()

        except OSError:
            os.chdir('..')

        self.outputDir = "AdmitUnitTest"
        self.p = admit.Project(self.outputDir)
コード例 #9
0
ファイル: unittest_multiflow1.py プロジェクト: teuben/admit
    def test_multiflow(self):

        # Parent projects.
        p1 = admit.Project(self.outputDir + "/p1")
        p2 = admit.Project(self.outputDir + "/p2")
        for p in [p1, p2]:
            task = admit.File_AT(touch=True)
            task.setkey("file", "File.dat")
            tid1 = p.addtask(task)

            task = admit.Flow11_AT(alias="at" + p.baseDir[-2])  # at1 or at2
            task.setkey("file", "Flow11.dat")
            tid2 = p.addtask(task, [(tid1, 0)])

            p.run()

        # Multiflow project.
        mflow = admit.Project(self.outputDir + "/mflow")

        # Add parent projects to the multiflow.
        # Note they must be completely up-to-date for this to succeed.
        pid1 = mflow.pm.addProject(self.outputDir + "/p1")
        pid2 = mflow.pm.addProject(self.outputDir + "/p2")
        print "Parent project p1 ID = ", pid1
        print "Parent project p2 ID = ", pid2

        # Find some ATs to link into the multiflow.
        # Here searching is done by alias name.
        stuples = []
        for pid in [pid1, pid2]:
            alias = "at" + mflow.pm[pid].baseDir[-2]
            print "Looking for alias", alias, "..."
            ats = mflow.pm.findTaskAlias(pid, alias)
            print "Result:", ats
            self.assertEqual(len(ats), 1, "Found wrong number of matches")
            self.assertEqual(ats[0]._alias, alias, "Alias mismatch")
            self.assertNotEqual(ats[0].getProject(), 0, "Null project ID")
            print alias, "belongs to project ", \
                  mflow.pm.getProjectDir(ats[0].getProject())

            # Add task to the multiflow (must be a root task---no stuples).
            tid = mflow.addtask(ats[0])
            print "tid=%d stale=%s" % (tid, mflow[tid].isstale())
            self.assertNotEqual(tid, -1, "mflow.addtask(" + alias + ") failed")
            stuples.append((tid, 0))

        # Combine output from the two newly linked tasks.
        print "stuples =", stuples
        tid = mflow.addtask(admit.FlowN1_AT(file="FlowN1.dat", touch=True),
                            stuples)
        self.assertNotEqual(tid, -1, "mflow.addtask(FlowN1) failed")

        mflow.show()
        # Run the multiflow.
        mflow.run()

        # Make at2 out of date, then re-run the multiflow to update everything.
        at2 = mflow.findtask(lambda at: at._alias == "at2")
        self.assertEqual(len(at2), 1, "Found wrong number of matches for at2")
        self.assertEqual(at2[0]._alias, "at2", "Alias mismatch for at2")
        at2[0].setkey("file", "Flow11-at2.dat")
        mflow.show()
        mflow.run()
コード例 #10
0
ファイル: admit-example0.py プロジェクト: astroumd/admit
# for individual spectral lines.
#
# Usage: admit-example0.py input.fits
#
# =============================================================================

# Used Python and ADMIT functionality.
import os
import admit

# 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.
コード例 #11
0
#!/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,
コード例 #12
0
#  announce version
print 'ADMIT3: Version ', version

#  do the work in a proper ".admit" directory
adir = admit_dir(file)
#   dirty method, it really should check if adir is an admit directory
if clean and adir != file:
    print "Removing previous results from ", adir
    os.system('rm -rf %s' % adir)
    create = True
else:
    create = False

a = admit.Project(adir,
                  name='Testing ADMIT3 style pipeline - version %s' % version,
                  create=create,
                  loglevel=loglevel)

if a.new:
    print "Starting a new ADMIT using ", argv[0]
    os.system('cp -a %s %s' % (argv[0], adir))
    a.set(admit_dir=adir)
else:
    print "All done, we just read an existing admit.xml and it should do nothing"
    print "Use admit0.py to re-run inside of your admit directory"
    #
    a.fm.diagram(a.dir() + 'admit.dot')
    a.show()
    a.showsetkey()
    sys.exit(0)  #doesn't work in IPython!
コード例 #13
0
    def setUp(self):
        self.root = admit.utils.admit_root()
        self.testoutput = self.root + "/INTEGTESTRESULT"
        self.success = "FAILED"
        self.testName = "Test LineSegment_AT vs. LineID_AT identifylines=False"

        self.transitions = [
            [["13COv=0", [110.15, 110.25], 6.0, 30.0,
              5.0]],  # 0 single 13CO line
            [["CH3CNv=0", [110.21, 110.5], 8.5, 15.0,
              0.0]],  # 2 Methyl cyanide cluster
            [["N2H+v=0", [93.1, 93.2], 15.5, 0.25,
              0.0]],  # 4 narrow, blended hyperfines
            [
                ["COv=0", [115.2, 115.3], 5.5, 20.0,
                 -30.0],  # 6 galactic emission type spectrum
                ["COv=0", [115.2, 115.3], 5.0, 20.0, 30.0]
            ],
            [
                ["COv=0", [115.2, 115.3], 5.5, 20.0,
                 -30.0],  # 8 P-cygni type profile
                ["COv=0", [115.2, 115.3], -5.0, 20.0, 30.0]
            ],
            [
                ["(CH3)2COv=0", [240.0, 242.0], 10.0, 5.0,
                 0.0],  # 10 complex molecules
                ["CH3OCHOv=0", [240.0, 242.0], 15.0, 3.0, 1.0],
                ["CH3CH2CNv=0", [240.0, 242.0], 20.0, 5.0, 0.0],
                ["CH3OCH3", [240.0, 242.0], 5.0, 5.0, 0.0],
                ["CH3OHvt=0", [240.0, 242.0], 20.0, 5.0, 0.0],
                ["CH3OHvt=1", [240.0, 242.0], 5.0, 5.0, 0.0]
            ],
            [
                ["COv=0", [115.2, 115.3], 3.0, 30.0,
                 -40.0],  # 12 outflow type spectrum
                ["COv=0", [115.2, 115.3], 3.0, 30.0, 40.0],
                ["COv=0", [115.2, 115.3], 6.0, 8.0, 15.0],
                ["COv=0", [115.2, 115.3], 5.5, 8.0, -15.0],
                ["COv=0", [115.2, 115.3], -3.5, 8.0, 0.0]
            ],
            [["CH3CH2CNv=0", [93.65, 93.7], 8.0, 2.0, 0.0],
             ["CH3OCH3", [93.65, 93.7], 6.5, 2.0,
              0.0]],  # 14 blended lines from different molecules
            [["Hα", [99.02, 99.025], 4.0, 55.0, -10.0],
             ["CH3CHOvt=1", [99.02, 99.025], 4.0, 5.0,
              0.0]],  # 16 wide and narrow blended lines
            [["N2H+v=0", [93.1, 93.2], -15.5, 0.25,
              0.0]],  # 18 pure absorption
            [["NH2CHO", [102.2, 102.25], 5.5, 17.0, -40.0],
             ["NH2CHO", [102.2, 102.25], 5.0, 17.0, 40.0],
             ["CH3CCHv=0", [102.5, 102.55], 30.0, 17.0, -39.0],
             ["CH3CCHv=0", [102.5, 102.55], 25.0, 17.0, 39.0],
             ["H2CS", [103.0, 103.1], 6.5, 17.0, -40.0],
             ["H2CS", [103.0, 103.1], 5.7, 17.0, 40.0],
             ["DNCO", [101.9, 102.1], 3.5, 10.0,
              39.5]],  # 20 glactic emission with multiple non-tier 1 molecules
            [["CH3CCHv=0", [102.547, 102.55], 6.5, 6.0, 0.0],
             ["CH3CCHv=0", [102.547, 102.55], 6.5, 6.0, 4.0],
             ["CH3CCHv=0", [102.547, 102.55], 6.5, 6.0, -4.0],
             ["CH3CCHv=0", [102.547, 102.55], 6.5, 6.0, -8.0],
             ["CH3CCHv=0", [102.547, 102.55], 6.5, 6.0, 8.0],
             ["CH3CCHv=0", [102.547, 102.55], 6.5, 6.0, -12.0],
             ["CH3CCHv=0", [102.547, 102.55], 6.5, 6.0, 12.0],
             ["CH3CCHv=0", [102.547, 102.55], 6.5, 6.0, 16.0],
             ["CH3CCHv=0", [102.547, 102.55], 6.5, 6.0, -16.0],
             ["CH3CCHv=0", [102.547, 102.55], 6.5, 6.0, 20.0],
             ["CH3CCHv=0", [102.547, 102.55], 6.5, 6.0, -20.0],
             ["CH3CCHv=0", [102.547, 102.55], 6.5, 6.0, 24.0],
             ["CH3CCHv=0", [102.547, 102.55], 6.5, 6.0,
              -24.0]],  # 22 wide plateau like line
            [["NH2CHO", [102.2, 102.25], 3.5, 8.0, 1.0],
             ["CH3CCHv=0", [102.5, 102.55], 2.2, 4.0, -1.5],
             ["H2CS", [103.0, 103.1], 4.5, 5.2, 0.0],
             ["DNCO", [101.9, 102.1], 3.0, 3.5, 0.5]],  # 24 few weak lines
            [["CH3OCH3", [90.935, 90.94], 12.0, 0.5,
              0.1]]  # 26 pure triplet of lines
        ]
        self.delta = [
            0.5, 0.5, 0.005, 0.5, 0.5, 0.5, 0.1, 0.1, 0.2, 0.005, 0.4, 0.2,
            0.5, 0.025
        ]  #MHz
        self.contin = [
            0.5, 1.3, 0.1, 3.0, 1.2, 0.5, 0.1, 1.2, 2.0, 1.0, 10.0, 3.0, 0.0,
            1.5, 2.5
        ]  #SNR
        self.seed = [10, 25, 15, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]
        self.freq = [
            110.25, 110.3, 93.175, 115.271, 115.3, 241.0, 115.26, 93.68, 99.0,
            93.175, 102.5, 102.52, 102.55, 90.94
        ]  #GHz
        self.nchan = [
            1000, 500, 2000, 1000, 1000, 4000, 1000, 1000, 1000, 2100, 4000,
            800, 4000, 1000
        ]

        today = dt.date.today()
        date = "%i-%02i-%02i" % (today.year, today.month, today.day)
        plotmode = admit.PlotControl.BATCH  # NOPLOT, BATCH, INTERACTIVE, SHOW_AT_END
        plottype = admit.PlotControl.PNG  # PNG, JPG, etc.
        loglevel = 50  # 10=DEBUG, 15=TIMING 20=INFO 30=WARNING 40=ERROR 50=FATAL
        self.outdir = tempfile.mkdtemp()
        self.admitdir = "%s/%s" % (self.outdir, date)
        print "##################  %s Project directory = %s  ################" % (
            self.__class__.__name__, self.admitdir)

        admit.util.utils.rmdir(self.outdir)

        self.a = admit.Project(self.admitdir,
                               name='LineSegment vs. LineID',
                               create=True,
                               loglevel=loglevel)

        # Default ADMIT plotting environment
        self.a.plotparams(plotmode, plottype)
コード例 #14
0
ファイル: admit5.py プロジェクト: teuben/admit
#! /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()
コード例 #15
0
    def runTest(self):
        try:
            # instantiate the class
            a = admit.Project(self.admitDir)
            a.plotparams(admit.PlotControl.BATCH,admit.PlotControl.PNG)

            fitsin = admit.Ingest_AT(file=self.inputFile)
            task0id = a.addtask(fitsin)

            l = admit.LineID_AT()
            task2id = a.addtask(l)
            l._needToSave = True
            ll = admit.LineList_BDP()

#             ll.addRow([115.271,"CO","CO-115.271","Carbon Monoxide","1-0",0.0,0.0,3.2,0.01,1.3,0.0,5.0,15,20,5.2])
#             ll.addRow([115.832,"U", "U-115.832", "", "",0.0,0.0,0.0,0.0,0.0,0.0,0.0,25,35,2.4])

            # keys (column names of LineList_BDP)
            # "frequency", "uid", "formula", "name", "transition", "velocity", 
            # "El", "Eu", "linestrength", "peakintensity", "peakoffset", "fwhm", 
            # "startchan", "endchan", "peakrms", "blend"
            keys = {"frequency":115.271, "uid":"CO","formula":"CO-115.271",
                    "name":"Carbon Monoxide", "transition":"1-0",
                    "velocity":0.0,
                    "linestrength":0.01, "peakintensity":1.3,
                    "peakoffset":0.0, "fwhm":5.0,
                    "peakrms":5.2, "blend":0}

            data = admit.LineData()
            data.setkey(name=keys)
            ll.addRow(data)

            keys = {"frequency":115.832, "uid":"U","formula":"U-115.832",
                    "name":"", "transition":"",
                    "velocity":0.0,
                    "linestrength":0.0, "peakintensity":0.0,
                    "peakoffset":0.0, "fwhm":0.0,
                    "peakrms":2.4, "blend":0}

            data.setkey(name=keys)
            ll.addRow(data)

            l.addoutput(ll)
            l.markUpToDate()

            # instantiate a linecube_AT
            lcube = admit.LineCube_AT()
            task1id = a.addtask(lcube,[(task0id,0),(task2id,0)])

            # check the fm 
            a.fm.verify()

            # run admit 
            a.run()
            a.write()
            # read in the admit.xml and bdp files
            a2 = admit.Project(self.admitDir)

            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))
            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))
コード例 #16
0
ファイル: LineIDBaseline.py プロジェクト: teuben/admit
freq = [
    110.25, 110.3, 93.175, 115.271, 115.3, 241.0, 115.26, 93.68, 99.0, 93.175,
    102.5, 102.52, 102.55, 90.94
]  #GHz
nchan = [
    1000, 500, 2000, 1000, 1000, 4000, 1000, 1000, 1000, 2100, 4000, 800, 4000,
    1000
]

projdir = "%s/%s" % (args['dir'][0], date)
print "##################  PROJECTDIR = %s  ################" % projdir

admit.util.utils.rmdir(projdir)

a = admit.Project(projdir,
                  name='Testing LineID',
                  create=True,
                  loglevel=loglevel)

# Default ADMIT plotting environment
a.plotparams(plotmode, plottype)

for i in range(len(transitions)):
    spec = a.addtask(
        admit.GenerateSpectrum_AT(seed=seed[i],
                                  nchan=nchan[i],
                                  contin=contin[i],
                                  delta=delta[i],
                                  freq=freq[i],
                                  transitions=transitions[i],
                                  alias="test_%i" % (i)))
    bdp_in = [(spec, 0)]
コード例 #17
0
ファイル: Archive_Pipeline.py プロジェクト: teuben/admit
    # convert key values from string
    try:
        KEYS["minchan"]  = int(KEYS["minchan"])
        KEYS["numsigma"] = float(KEYS["numsigma"])
        KEYS["pad"]      = int(KEYS["pad"])
        KEYS["width"]    = int(KEYS["width"])
        KEYS["cutoff"]   = ast.literal_eval(str(KEYS["cutoff"]))
    except Exception, e:
        print("Exception converting keyword value to number:",e)
        return

    #========================================================================
    # Master project.  Beginning for ADMIT Commands
    # 
    p = admit.Project(projdir,commit=False,loglevel=loglevel)
    
    # list object for Tasks so we don't have to individually name them
    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"])))
コード例 #18
0
ファイル: hello_multiworld1.py プロジェクト: teuben/admit
#!/usr/bin/env python
#
# Hello multiworld (type 1) test script.
#
# Run unittest_multiflow1.py first to create projects p1, p2;
# otherwise no tasks will be found and the script will fail.
#
import admit
import admit.at as at

# Create multiflow project.
mflow = admit.Project("mflow")
pm = mflow.getManager()

# Add projects with tasks to link.
proj1 = pm.addProject("p1")
proj2 = pm.addProject("p2")

# Find some tasks and link them into the multiflow.
stuples = []
#
ats = pm.findTaskAlias(proj1, "at1")
tid = mflow.addtask(ats[0])
stuples.append((tid, 0))

ats = pm.findTaskAlias(proj2, "at2")
tid = mflow.addtask(ats[0])
stuples.append((tid, 0))

# Combine outputs from the linked tasks into a new task.
tid = mflow.addtask(at.FlowN1(file="FlowN1.dat", touch=True), stuples)
コード例 #19
0
 def setUp(self):
     self.verbose = False
     self.testName = "AT Base Class Unit Test"
     self.project = admit.Project("UnitTest")
コード例 #20
0
ファイル: admit_script.py プロジェクト: xinglunju/reduction
# set up admit in the casa environment
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])