from setup_cbp import *
import cbpassist as ca
import time

d['cbp.pinhole'] = 'grid'
d['cbp.alt'] =  'IDLE'
d['cbp.az'] = 'IDLE'
d['sbig.filter'] = 'Vi'

outdir = 'mondrik_temp_test/Vi_1nm_scan'

if not os.path.exists(outdir):
    os.mkdir(outdir)

# wl = np.arange(400, 1052, 2) # For full filter @ 2nm spacing
wl = np.arange(450,650,1) # For Vi filter, not including the leak

e,_ = ca.calc_exp_time(wl)
t_expected = 2.*((np.sum(e) + 10.*len(e)) / 60.)
print('Approximate time for scan: {} min'.format(t_expected))
print('This might be made longer by frequent ND filter rotations')

for w in wl:
    exptime, filter_pos = ca.calc_exp_time(w)
    d['sbig.EXPTIME'] = exptime+10.
    d['keithley.exptime'] = str(exptime)
    d['laser.wavelength'] = str(w)
    d['ndfilter.pos'] = str(filter_pos)

    #  Do dark
    d['keithley'] = False
    print('Taking Dark')
    sched.shoot(d, outdir)
    d['keithley'] = True
    print('Taking Light')
    sched.shoot(d, outdir)
