def test_analyze(self): logger.info('== {} =='.format(self._testMethodName)) fitsFns = glob.glob('{0}/{1}'.format('../samples', self.rt.cfg['FILE_GLOB'])) dataSxtr = list() for k, fitsFn in enumerate(fitsFns): logger.info('analyze: processing fits file: {0}'.format(fitsFn)) sxtr = Sextract(debug=False, rt=self.rt, logger=logger) dSx = sxtr.sextract(fitsFn=fitsFn) if dSx: dataSxtr.append(dSx) self.assertEqual(len(dataSxtr), 14, 'return value: {}'.format(len(dataSxtr))) an = SimpleAnalysis(debug=False, dataSxtr=dataSxtr, Ds9Display=False, FitDisplay=False, focRes=float(self.rt.cfg['FOCUSER_RESOLUTION']), ev=self.ev, rt=self.rt, logger=logger) resultFitFwhm, resultMeansFwhm, resultFitFlux, resultMeansFlux = an.analyze( ) self.assertAlmostEqual(resultFitFwhm.extrFitVal, 2.2175214358, places=2, msg='return value: {}'.format( resultFitFwhm.extrFitVal)) an.display()
def createAssocList(self, fitsFn=None): rsx = Sextract(debug=self.args.sxDebug, createAssoc=self.rt.cfg['ANALYZE_ASSOC'], rt=self.rt, logger=self.logger) if self.rt.cfg['ANALYZE_FLUX']: rsx.appendFluxFields() return rsx.sextract(fitsFn=fitsFn, assocFn=self.assocFn)
def test_sextractFlux(self): logger.info('== {} =='.format(self._testMethodName)) rt = Configuration(logger=logger) rt.readConfiguration(fileName='./rts2saf-flux.cfg') sx = Sextract(debug=False, rt=rt, logger=logger) fitsFn = '../samples/20071205025911-725-RA.fits' sx.appendFluxFields() dSx = sx.sextract(fitsFn=fitsFn) self.assertEqual(dSx.fields[12], 'FLUXERR_APER', 'return value: {}'.format(dSx.fields[12]))
def test_sextract(self): logger.info('== {} =='.format(self._testMethodName)) rt = Configuration(logger=logger) rt.readConfiguration(fileName='./rts2saf-no-filter-wheel.cfg') sx = Sextract(debug=False, rt=rt, logger=logger) fitsFn = '../samples/20071205025911-725-RA.fits' dSx = sx.sextract(fitsFn=fitsFn) self.assertIs(type(dSx), DataSxtr, 'return object of type: '.format(type(dSx))) self.assertEqual( fitsFn, dSx.fitsFn, 'install sample FITS from wget http://azug.minpet.unibas.ch/~wildi/rts2saf-test-focus-2013-09-14.tgz' )
def test_selectAndAnalyze(self): logger.info('== {} =='.format(self._testMethodName)) fitsFns=glob.glob('{0}/{1}'.format('../samples', self.rt.cfg['FILE_GLOB'])) dataSxtr=list() for k, fitsFn in enumerate(fitsFns): logger.info('analyze: processing fits file: {0}'.format(fitsFn)) sxtr= Sextract(debug=False, rt=self.rt, logger=logger) dSx=sxtr.sextract(fitsFn=fitsFn) if dSx: dataSxtr.append(dSx) self.assertEqual(len(dataSxtr), 14, 'return value: {}'.format(len(dataSxtr))) an=CatalogAnalysis(debug=False, dataSxtr=dataSxtr, Ds9Display=False, FitDisplay=False, focRes=float(self.rt.cfg['FOCUSER_RESOLUTION']), moduleName='rts2saf.criteria_radius', ev=self.ev, rt=self.rt, logger=logger) accRFt, rejRFt, allrFt, accRMns, recRMns, allRMns=an.selectAndAnalyze() self.assertAlmostEqual(allrFt.extrFitVal, 2.2175214358, delta=0.1, msg='return value: {}'.format(allrFt.extrFitVal)) self.assertAlmostEqual(accRFt.extrFitVal, 2.24000979001, delta=0.1, msg='return value: {}'.format(allrFt.extrFitVal))
def sextract(self, fitsFns=None, dSxReference=None, dataRn=None): for fitsFn in fitsFns: rsx = Sextract(debug=self.args.sxDebug, rt=self.rt, logger=self.logger) if self.rt.cfg['ANALYZE_FLUX']: rsx.appendFluxFields() if dSxReference is not None: rsx.appendAssocFields() dSx = rsx.sextract(fitsFn=fitsFn, assocFn=self.assocFn) else: dSx = rsx.sextract(fitsFn=fitsFn, assocFn=None) if dSx is not None and dSx.fwhm > 0. and dSx.stdFwhm > 0.: dataRn.dataSxtrs.append(dSx) self.logger.debug('sextract: {}, ok: {}'.format( len(dSx.catalog), fitsFn)) else: self.logger.warn( 'sextract: no result, file: {0}'.format(fitsFn))
# read the run time configuration rt = Configuration(logger=logger) if not rt.readConfiguration(fileName=args.config): logger.error( 'rts2saf_focus: exiting, wrong syntax, check the configuration file: {0}' .format(args.config)) sys.exit(1) if not rt.checkConfiguration(args=args): logger.error( 'rts2saf_focus: exiting, check the configuration file: {0}'.format( args.config)) sys.exit(1) sex = Sextract(debug=args.debug, rt=rt, logger=logger) if args.fitsFn == None: logger.error('rts2af_fwhm: no --fitsFn specified, exiting'.format( args.fitsFn)) sys.exit(1) elif not os.path.exists(args.fitsFn): logger.error('rts2af_fwhm: file: {0}, does not exist, exiting'.format( args.fitsFn)) sys.exit(1) try: dataSxtr = sex.sextract(fitsFn=args.fitsFn) except Exception, e: logger.error( 'rts2af_fwhm: sextractor failed on file: {0}\nerror from sex.sextract: {1}\nexiting'
def setUp(self): self.rt = Configuration(logger=logger) self.rt.readConfiguration(fileName='./rts2saf-no-filter-wheel.cfg') self.dSx = Sextract(debug=False, rt=self.rt, logger=logger).sextract( fitsFn='../samples/20071205025911-725-RA.fits') print self.dSx.fitsFn