Пример #1
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))
Пример #2
0
    a[ingest1].setkey('restfreq', restfreq)
if len(inbox) > 0:
    a[ingest1].setkey('box', inbox)
if len(inedge) > 0:
    a[ingest1].setkey('edge', inedge)
bandcube1 = (ingest1, 0)

if False:
    # test File_AT:
    file1 = a.addtask(admit.File_AT(file=file))

if stop == 'ingest': a.exit(1)

# smooth
if len(smooth) > 0:
    smooth1 = a.addtask(admit.Smooth_AT(), [bandcube1])
    a[smooth1].setkey('bmaj', {'value': smooth[0], 'unit': 'pixel'})
    a[smooth1].setkey('bmin', {'value': smooth[1], 'unit': 'pixel'})
    a[smooth1].setkey('bpa', 0.0)
    if len(smooth) > 2:
        a[smooth1].setkey('velres', {'value': smooth[2], 'unit': 'pixel'})

    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_orig = bandcube1