import scheduler
from stardice import configfiles
from glob import glob
import astropy.io.fits as pyfits
import logging
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG)
import numpy as np
from notification import notify
import os

outdir = '../data/spectro_bench/linearity'
if not os.path.exists(outdir):
    os.mkdir(outdir)
    
sbig_pos = 29500
zwo_pos = 91500

config = configfiles.Config('spectro_bench.cfg')

sched = scheduler.Scheduler(config)
#sched.sbig.set_filter('EMPTY')

d = sched.get_default()

leds = np.load('../drivers/ardice/led16_1.npy')

#d['sbig'] = False
d['zwo'] = True
d['xy.x'] = int(zwo_pos)

d['ar.led'] = 5
d['ar.iled'] = 100
d['mono.grating'] = 3
d['mono.wavelength'] = 0
d['mono.slits'] = 3000
d['phd.range'] = 2e-6
d['phd.nsamples'] = 10
workpoint = [1500, 1000, 340, 313, 431, 387, 1000, 1000, 900, 900,
             1000, 1000, 1000, 2000, 2000, 2000]

'''
notify('time scan started')
try:
    for shutter in ['close', 'open']:
        d['ar.shutter'] = shutter
        for exptime in np.logspace(-3, 0, 100):
            d['zwo.exptime'] = float(exptime)
            for i in range(30):
                sched.shoot(d, outdir)
    #notify('led %d completed' % led['led'])
finally:
    notify('time scan stopped')

'''
