Ejemplo n.º 1
0
    def __init__(self,
                 name,
                 productName=None,
                 configFile=None,
                 debugLevel=30,
                 makeCmdrConnection=True):

        self.version = __version__

        actorcore.Actor.SDSSActor.__init__(self,
                                           name,
                                           productName=productName,
                                           configFile=configFile)

        self.logger.setLevel(debugLevel)
        # self.logger.propagate = True

        self.models = {}
        for actor in 'boss', :
            self.models[actor] = opscore.actor.model.Model(actor)

        myGlobals.config = self.config
        myGlobals.models = self.models
        myGlobals.actor = self

        m, b, constants, coeff = get_collimation_constants(self.config)
        myGlobals.hartmann = boss_collimate.Hartmann(self, m, b, constants,
                                                     coeff)
        myGlobals.hartmann_thread = None

        # Spectrographs to process.
        myGlobals.specs = self.config['spec']['specs'].split(' ')
        myGlobals.cameras = self.config['spec']['cameras'].split(' ')
Ejemplo n.º 2
0
    def setUp(self):
        super(TestHartmann, self).setUp()
        self.actor.models = self.actorState.models
        m, b, constants, coeff = get_config_constants()

        self.hart = boss_collimate.Hartmann(self.actor, m, b, constants, coeff)
        self.hart.cmd = self.cmd
        self.hart.mjd = 12345

        myGlobals.specs = ['sp1', 'sp2']
        myGlobals.cameras = ['b1', 'b2', 'r1', 'r2']
Ejemplo n.º 3
0
    def setUp(self):
        self.verbose = True
        super(HartmannCmdTester, self).setUp()
        self.timeout = 1

        self.actor.models = self.actorState.models

        m, b, constants, coeff = hartmann.get_collimation_constants(config)
        self.hart = boss_collimate.Hartmann(self.actor, m, b, constants, coeff)
        self.hart.cmd = self.cmd

        myGlobals.specs = config['spec']['specs'].split(' ')
        myGlobals.cameras = config['spec']['cameras'].split(' ')
Ejemplo n.º 4
0
"""

import configparser
import cProfile
import pstats
import time

from actorcore import TestHelper
from hartmannActor import boss_collimate, hartmannActor_main

config = configparser.ConfigParser()
config.read('../etc/hartmann.cfg')
m, b, constants, coeff = hartmannActor_main.get_collimation_constants(config)

cmd = TestHelper.Cmd(verbose=True)
hart = boss_collimate.Hartmann(None, m, b, constants, coeff)
hart.spec = 'sp1'
hart.cmd = cmd

# NOTE: this isn't going to tell us anything, because all the work happens
# inside the 4 processes, and Profile doesn't tell us anything about that.
# Need to profile a single OneCam call if we really want to learn what's up.
# print 'Profiling full hartmann __call__()'
# print '----------------------------------'
# prof = cProfile.Profile()
# prof.runcall(hart.collimate,165006,indir='data/',cmd=cmd,moveMotors=False)
# prof.dump_stats('hartmann.prof')
# p = pstats.Stats('hartmann.prof')
# p.strip_dirs()
# p.sort_stats('time').print_stats(10)
Ejemplo n.º 5
0
def main(argv=None):
    parser = argparse.ArgumentParser(description=__doc__,
                                     prog=os.path.basename(sys.argv[0]))
    parser.add_argument('FILE1',
                        metavar='FILE1',
                        type=str,
                        help='The first hartmann file (generally left).')
    parser.add_argument(
        'FILE2',
        metavar='FILE2',
        default=None,
        nargs='?',
        help='Optional second hartmann file (generally right).')
    parser.add_argument(
        '-m',
        default=None,
        dest='m',
        nargs=4,
        type=float,
        help='Slope of the offset->motor function: b1 r1 b2 r2.')
    parser.add_argument(
        '-b',
        default=None,
        dest='b',
        nargs=4,
        type=float,
        help='Intercept of the offset->motor function: b1 r1 b2 r2.')
    parser.add_argument('--bsteps',
                        default=None,
                        dest='bsteps',
                        type=float,
                        help='steps per degree for the blue ring')
    parser.add_argument('--badres',
                        default=None,
                        dest='badres',
                        type=float,
                        help='tolerance for bad residual on blue ring')
    parser.add_argument('--coeff',
                        default=None,
                        dest='coeff',
                        nargs=4,
                        type=float,
                        help='"funny fudge factors": b1 r1 b2 r2.')
    parser.add_argument(
        '--noCheckImage',
        dest='noCheckImage',
        action='store_true',
        help="Don't perform variance calculation for missing light.")

    args = parser.parse_args()

    exp1 = args.FILE1
    indir, expnum1 = os.path.split(exp1)
    expnum1 = get_expnum(expnum1)
    if args.FILE2:
        indir, expnum2 = os.path.split(args.FILE2)
        expnum2 = get_expnum(expnum2)

    if '/data/spectro' in indir:
        mjd = int(os.path.split(indir)[-1])
    else:
        mjd = None

    cmd = TestHelper.Cmd(verbose=True)
    config = configparser.ConfigParser()
    config.read(os.environ['HARTMANNACTOR_DIR'] + '/etc/hartmann.cfg')
    m, b, constants, coeff = hartmannActor_main.get_collimation_constants(
        config)

    if args.m is not None:
        m = cams_params(args.m)
    if args.b is not None:
        b = cams_params(args.b)
    if args.bsteps is not None:
        constants['bsteps'] = args.bsteps
    if args.badres is not None:
        constants['badres'] = args.badres
    if args.coeff is not None:
        coeff = cams_params(args.coeff)

    hart = boss_collimate.Hartmann(None, m, b, constants, coeff)

    hart.collimate(expnum1,
                   indir=indir,
                   mjd=mjd,
                   cmd=cmd,
                   plot=True,
                   noCheckImage=args.noCheckImage)