class TestTemperatureFocPosModel(unittest.TestCase):

    def tearDown(self):
        try:
            os.unlink(self.plotFnIn)
        except:
            pass

    def setUp(self):
        from rts2saf.data import ResultFit
        self.plotFnIn='./test-temperaturemodel-plot.png'
        date = '2013-09-08T09:30:09'
        resultFitFwhm=list()
        for i in range(0,10):
            resultFitFwhm.append(ResultFit(ambientTemp=float(i), extrFitPos=float( 2 * i)))

        self.ft = TemperatureFocPosModel(showPlot=False, date=date,  comment='unittest', plotFn=self.plotFnIn, resultFitFwhm=resultFitFwhm, logger=logger)

    def test_fitData(self):
        logger.info('== {} =='.format(self._testMethodName))
        par, flag= self.ft.fitData()
        if flag:
            # ToDo might not what I want
            self.assertAlmostEqual(par[0], 8.881784197e-16, places=6, msg='return value: '.format(par[0]))
        else:
            self.assertEqual(0, 1, 'fit failed')
                            
    #@unittest.skip('feature not yet implemented')
    def test_plotData(self):
        logger.info('== {} =='.format(self._testMethodName))
        par, flag= self.ft.fitData()
        plotFnOut=self.ft.plotData()
        self.assertEqual(self.plotFnIn, plotFnOut, 'return value: {}'.format(plotFnOut))
Example #2
0
    if len(aRs.fS) == 0:
        logger.warn(
            'rts2saf_analyze: exiting, no files found in basepath: {}'.format(
                args.basePath))
        sys.exit(1)

    rFf = aRs.analyzeRuns()

    if len(rFf) == 0:
        logger.error('rts2saf_analyze: no results, exiting')
        sys.exit(1)

    if args.model:
        if rFf[0].ambientTemp in 'NoTemp':
            logger.warn(
                'rts2saf_analyze: no ambient temperature available in FITS files, no model fitted'
            )
        else:
            # temperature model
            PLOTFN = ev.expandToPlotFileName(
                plotFn='{}/temp-model.png'.format(args.basePath))
            dom = TemperatureFocPosModel(showPlot=True,
                                         date=ev.startTime[0:19],
                                         comment='test run',
                                         plotFn=PLOTFN,
                                         resultFitFwhm=rFf,
                                         logger=logger)
            dom.fitData()
            dom.plotData()
            logger.info('rts2saf_analyze: storing plot at: {}'.format(PLOTFN))
Example #3
0
        sys.exit(1)

    if not args.toconsole:
        print 'you may wish to enable logging to console --toconsole'
        print 'log file is written to: {}'.format(args.logfile)


    aRs = AnalyzeRuns(debug = args.debug, basePath = args.basePath, args = args, rt = rtc, ev = ev, logger = logger, xdisplay = XDISPLAY)
    aRs.aggregateRuns()
    if len(aRs.fS) == 0:
        logger.warn('rts2saf_analyze: exiting, no files found in basepath: {}'.format(args.basePath))
        sys.exit(1)

    rFf = aRs.analyzeRuns()
    
    if len(rFf)==0:
        logger.error('rts2saf_analyze: no results, exiting')
        sys.exit(1)

    if args.model:            
        if rFf[0].ambientTemp in 'NoTemp':
            logger.warn('rts2saf_analyze: no ambient temperature available in FITS files, no model fitted')
        else:
            # temperature model
            PLOTFN = ev.expandToPlotFileName( plotFn = '{}/temp-model.png'.format(args.basePath))
            dom = TemperatureFocPosModel(showPlot = True, date = ev.startTime[0:19],  comment = 'test run', plotFn = PLOTFN, resultFitFwhm = rFf, logger = logger)
            dom.fitData()
            dom.plotData()
            logger.info('rts2saf_analyze: storing plot at: {}'.format(PLOTFN))