コード例 #1
0
ファイル: test_cubestats.py プロジェクト: teuben/admit
def run(fileName):
    # instantiate the class
    a = ad.Admit()
    # instantiate a moment AT
    c = mcs.CubeStats_AT()
    # set some moment parameters
    c.setParameter("imagename", fileName)

    # add the moment AT to the admit class
    a.addTask(c)
    # run admit (specifically the tasks that need it
    c.run()
    # save it out to disk (this will not be needed soon as I a working on
    # a way to write out the xml inside of the run commmand
    a.write()

    a2 = ad.Admit()  # read in the admit.xml and bdp.xml files

    # this should print out something reasonable ending in .xml
    for i in a.tasks[0].products:
        if (i.xmlFile == a2.tasks[0].products[0].xmlFile):
            print "\n\nPASS\n"
            return

    print "\n\nFAIL\n"
コード例 #2
0
ファイル: test_helloworld.py プロジェクト: teuben/admit
def run():
    # instantiate the class
    a = ad.Admit()

    # instantiate a moment AT
    h = hw.HelloWorld_AT()
    # add the moment AT to the admit class
    a.addtask(h)
    # set some moment parameters
    h.setkey("yourname", "Bill")
    h.setkey("planet", "Mars")

    # run admit (specifically the tasks that need it)
    h.execute()
    # save it out to disk (this will not be needed soon as I a working on
    # a way to write out the xml inside of the run commmand
    a.write()

    a2 = ad.Admit()  # read in the admit.xml and bdp.xml files

    cmd = "rm -f %s/../HelloWorld_AT.p*" % (loc)
    os.system(cmd)
    cmd = "rm -f %s/../../bdp/HelloWorld_BDP.p*" % (loc)
    os.system(cmd)
    dtd.generate()

    print "These pairs should match"
    for at in a.fm:
        print "FlowManager task ", a.fm[at]
        print "FlowManager task ", a2.fm[at]
        print "LEN ", len(a.fm[at]._bdp_out)
        print "LEN ", len(a2.fm[at]._bdp_out)
        print "Input ", a.fm[at]._bdp_in[0]._taskid
        print "Input ", a2.fm[at]._bdp_in[0]._taskid
        print "\n\n"

    print "Conn map ", a.fm._connmap
    print "Conn map ", a2.fm._connmap
    print "\n\n"

    print "Conn map ", a.fm._depsmap
    print "Conn map ", a2.fm._depsmap
    print "\n\n"

    for at in a.fm:
        for i in a.fm[at].bdp_out:
            if (i.xmlFile == a2.fm[at]._bdp_out[0]._xmlFile):
                print "File ", i.xmlFile
                print "File ", a2.fm[at]._bdp_out[0]._xmlFile
                print "\n\nPASS\n"
                return
    print "\n\nFAIL\n"
コード例 #3
0
ファイル: test_file.py プロジェクト: teuben/admit
def run(fileName=None, touch=False):
    # instantiate ADMIT
    a = ad.Admit()

    # Instantiate the class.  This can be done in two ways, both will
    # work, it just depends if you need 'a0' ('i0' you always need)
    if True:
        # the AT, then the ATI
        a0 = File_AT()
        i0 = a.addtask(a0)
    else:
        # get the ATI via ADMIT, but then grab AT reference for convenience
        i0 = a.addtask(File_AT())
        a0 = a[i0]

    # set some keys
    a0.setkey('file', fileName)
    a0.setkey('touch', False)
    a0.setkey('exist', True)

    # run the task(s). This also can be done in two ways.
    if False:
        # run only this one task, but it bypassed some checks in FlowManager
        # so for example, calling it twice, will run it twice
        # after running, explicit BDPs would need to be saved
        a0.run()
        a0[0].write()
    else:
        # run the whole ADMIT flow, although it's just one task (a0)
        # but calling it twice, 2nd run would not run the task since
        a.run()
        a.write()
コード例 #4
0
ファイル: test_Flow1N.py プロジェクト: teuben/admit
import sys, os

from admit.AT import AT
import admit.Admit as admit
from admit.at.File_AT import File_AT
from admit.at.Flow1N_AT import Flow1N_AT

if __name__ == '__main__':
    n = 3
    touch = True
    subdir = False
    subdir = True

    #  pick where admit will do its work, any cmdline argument will be the dirname
    if len(sys.argv) > 1:
        a = admit.Admit(sys.argv[1])
    else:  # or else the current directory
        a = admit.Admit()

    print 'Flow11:  new admit?', a.new

    a1 = File_AT()
    i1 = a.addtask(a1)
    a1.setkey('file', 'Flow1N.dat')
    a1.setkey('touch', touch)

    a2 = Flow1N_AT()
    i2 = a.addtask(a2, [(i1, 0)])
    a2.setkey('n', n)
    a2.setkey('touch', touch)
    a2.setkey('subdir', subdir)
コード例 #5
0
ファイル: test_moment.py プロジェクト: teuben/admit
        print "Input ",a2.fm.tasks[at].bdp_in[0].taskid
        print "\n\n"
    
    
    print "Conn map ",a.fm._connmap
    print "Conn map ",a2.fm._connmap
    print "\n\n"
    
    print "Conn map ",a.fm._depsmap
    print "Conn map ",a2.fm._depsmap
    print "\n\n"
    
    for at in a.fm.tasks:
        for i in a.fm.tasks[at].bdp_out :
            if(i.xmlFile == a2.fm.tasks[at].bdp_out[0].xmlFile):
                print "File ",i.xmlFile
                print "File ",a2.fm.tasks[at].bdp_out[0].xmlFile
                print "\n\nPASS\n"
                print "running a2 again:"
                a2.run()
                return
    print "\n\nFAIL\n"

if __name__ == "__main__":
    import sys
    
    argv = ad.casa_argv(sys.argv)
    if len(argv) > 1:
        print "Working on ",argv[1]
        run(argv[1])
コード例 #6
0
ファイル: test_moment.py プロジェクト: teuben/admit
def run(fileName):
    # instantiate the class
    a = ad.Admit()
    s = spw.SpwCube_BDP(taskid=1234, xmlFile="spw_test_object.bdp")

    image = Image({bt.CASA: fileName})
    s.image = image
    # instantiate a moment AT
    m = ma.Moment_AT()
    # add the moment AT to the admit class
    a.addtask(m)
    # set some moment parameters
    m.setkey("outfile", "tester")
    m.setkey("moments", [0, 1, 2])
    print s.image.images
    m.addInput(s)
    # output filenames will be:
    #   tester.integrated           mom=0
    #   tester.weighted_coord       mom=1
    #   weighted_dispersion_coord   mom=2

    # run admit (specifically the tasks that need it
    if False:
        m.execute()
    else:
        a.run()
    # save it out to disk (this will not be needed soon as I a working on
    # a way to write out the xml inside of the run commmand
    a.write()

    print "ALL DONE. NOW READING BACK"

    a2 = ad.Admit()  # read in the admit.xml and bdp.xml files

    # this should print out something reasonable ending in .xml
    #print a.tasks[0].out[0].xmlFile
    #print a2.tasks[0].out[0].xmlFile

    print "These pairs should match"
    for at in a.fm.tasks:
        print "FlowManager tasks ", a.fm.tasks
        print "FlowManager tasks ", a2.fm.tasks
        print "LEN ", len(a.fm.tasks[at].bdp_out)
        print "LEN ", len(a2.fm.tasks[at].bdp_out)
        print "Input ", a.fm.tasks[at].bdp_in[0].taskid
        print "Input ", a2.fm.tasks[at].bdp_in[0].taskid
        print "\n\n"

    print "Conn map ", a.fm._connmap
    print "Conn map ", a2.fm._connmap
    print "\n\n"

    print "Conn map ", a.fm._depsmap
    print "Conn map ", a2.fm._depsmap
    print "\n\n"

    for at in a.fm.tasks:
        for i in a.fm.tasks[at].bdp_out:
            if (i.xmlFile == a2.fm.tasks[at].bdp_out[0].xmlFile):
                print "File ", i.xmlFile
                print "File ", a2.fm.tasks[at].bdp_out[0].xmlFile
                print "\n\nPASS\n"
                print "running a2 again:"
                a2.run()
                return
    print "\n\nFAIL\n"
コード例 #7
0
ファイル: test_moment.py プロジェクト: teuben/admit
        print "Input ", a2.fm.tasks[at].bdp_in[0].taskid
        print "\n\n"

    print "Conn map ", a.fm._connmap
    print "Conn map ", a2.fm._connmap
    print "\n\n"

    print "Conn map ", a.fm._depsmap
    print "Conn map ", a2.fm._depsmap
    print "\n\n"

    for at in a.fm.tasks:
        for i in a.fm.tasks[at].bdp_out:
            if (i.xmlFile == a2.fm.tasks[at].bdp_out[0].xmlFile):
                print "File ", i.xmlFile
                print "File ", a2.fm.tasks[at].bdp_out[0].xmlFile
                print "\n\nPASS\n"
                print "running a2 again:"
                a2.run()
                return
    print "\n\nFAIL\n"


if __name__ == "__main__":
    import sys

    argv = ad.casa_argv(sys.argv)
    if len(argv) > 1:
        print "Working on ", argv[1]
        run(argv[1])
コード例 #8
0
ファイル: admit0.py プロジェクト: teuben/admit
#           result in irreproducable errors.
#           If so, go back to step 1.
#           Also, and this is a more serious problem, if the flow
#           produces a variable number of BDPs, the static flow
#           doesn't know how to handle this, and the flow will crash.
#           If so, go back to step 1 as well.
#
# =================================================================================================================
# python system modules
import sys, os, math
# admit modules
import admit.Admit as admit
import admit.util.PlotControl as PlotControl

# open admit in the current directory
a = admit.Admit()

if a.new:
    m1 = "Cannot continue, there is no ADMIT project here. "
    m2 = "You need to run this from within the .admit directory"
    raise Exception, m1 + m2

# test
#print "OBJECT:", a.summaryData['object']

# if you want to change the plotting characteristics for the existing flow,
# you need expert mode per AT.
# You  can however change any new AT's with the global ADMIT plotting parameters:
# e.g.
a.plotparams(PlotControl.BATCH, PlotControl.PNG)
# a.plotparams(PlotControl.INTERACTIVE,PlotControl.PNG)
コード例 #9
0
def run(fileName, method):
    """
    Ingest using ADMIT, and return the ADMIT instance for any
    further analysis
    method:    if blank, only ingest, otherwise use spectrum or stats or both
    """
    # instantiate ADMIT, we can only handle .fits files here
    loc = fileName.rfind('.')
    adir = fileName[:loc] + '.admit'

    a = ad.Admit(adir)
    a.plotmode(0)
    # just set an ADMIT variable
    a.set(foobar=1)
    print 'admit::foobar =', a.get('foobar')

    # Instantiate the AT, add it to ADMIT, and set some Ingest parameters
    a0 = Ingest_AT(file=fileName)
    i0 = a.addtask(a0)

    # run and save
    a.run()
    a.write()

    # inspect BDP? This will be a SpwCube_BDP
    b0 = a0[0]
    print 'BDP_0 has the following images:', b0.image.images

    if True:
        # enable if you want to check if indeed nothing happens here
        print "BEGIN running again"
        a.run()
        print "END running again"

    if method == "moment":
        from admit.at.Moment_AT import Moment_AT
        a1 = Moment_AT()
        i1 = a.addtask(a1, [(i0, 0)])
        a1.setkey('moments', [0, 1, 2])
    elif method == "stats":
        from admit.at.CubeStats_AT import CubeStats_AT
        a1 = CubeStats_AT()
        i1 = a.addtask(a1, [(i0, 0)])
    elif method == "spectrum":
        from admit.at.CubeSpectrum_AT import CubeSpectrum_AT
        a1 = CubeSpectrum_AT()
        a1.setkey('pos', [70, 70])
        i1 = a.addtask(a1, [(i0, 0)])
    elif method == "both":
        # cubestats will pass its maxpos= to cubespectrum
        from admit.at.CubeStats_AT import CubeStats_AT
        from admit.at.CubeSpectrum_AT import CubeSpectrum_AT
        a1 = CubeStats_AT()
        i1 = a.addtask(a1, [(i0, 0)])
        a2 = CubeSpectrum_AT()
        i2 = a.addtask(a2, [(i0, 0), (i1, 0)])
    else:
        print "No method ", method

    print "Final run"
    a.run()
    a.write()
    print "All done. admit.xml written"
    return a
コード例 #10
0
# Before command line parsing, attempt to find 'admit_vars.py' with variables to override the admit vars here
# this doesn't work yet, since CASA modifies the python environment
try:
    print 'Trying admit_vars'
    import admit_vars
    book = get_admit_vars('admit_vars')
    for key,val in book.iteritems():
        # print "ADMIT_VAR: ",key,val,type(key),type(val)
        exec(key + '=' + repr(val))
except:
    print "No admit_vars.py found, and that's ok."


# allow a command line argument to be the fits file name
argv = admit.casa_argv(sys.argv)
if len(argv) > 1:
    file  = argv[1]
    alias = ""
if len(argv) > 2:
    file  = argv[1]
    alias = argv[2]
if len(argv) > 3:
    file  = argv[1]
    alias = argv[2]
    cont  = argv[3]

#-----------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------- start of script -----------------------------------------------

#  announce version