The VisAO Camera
visao.py
Go to the documentation of this file.
1 ##@file visao.py
2 #
3 # The visao python module provides a python intervace to the VisAO camera
4 #
5 # The components of VisAO are combined in the VisAO class
6 #
7 
8 
9 """@module visao
10 
11  The visao python module provides a python intervace to the VisAO camera
12 
13  The components of VisAO are combined in the VisAO class
14 """
15 
16 from visaodevices import *
17 
19  def __init__(self, value):
20  self.value = value
21  def __str__(self):
22  return repr(self.value)
23 
24 
25 def sigint_handler(signum, frame):
26  """
27  Handle SIGINT so that ctrl-c will interrup a script at any point
28  """
29  raise Ctrl_C_Except('script interrupted.')
30 
31 class VisAO:
32  """
33  Class to control the VisAO Camera.
34  """
35  def __init__(self):
36  self.focus = FocusCtrl()
37  self.ccd47 = CCD47Ctrl()
38  self.gimbal = Gimbal()
39  self.shutter = Shutter()
40  self.fw2 = FilterWheel2()
41  self.fw3 = FilterWheel3()
42  self.bcu39 = framegrabber39()
43  self.fw39 = framewriter39()
44 
45  signal.signal(signal.SIGINT, sigint_handler)
46 
47  print "********************************"
48  print "VisAO script control initialized"
49  print "********************************"
50 
51  def connect(self):
52  self.focus.connect()
53  self.ccd47.connect()
54  self.shutter.connect()
55  self.fw2.connect()
56  self.fw3.connect()
57  self.gimbal.connect()
58 
59  def take_control(self):
60  self.focus.take_control()
61  self.ccd47.take_control()
62  self.shutter.take_control(1)
63  self.fw2.take_control()
64  self.fw3.take_control()
65 
66  def giveup_control(self):
67  self.focus.giveup_control()
68  self.ccd47.giveup_control()
69  self.shutter.giveup_control()
70  self.fw2.giveup_control()
71  self.fw3.giveup_control()
72 
73  def post_acq(self):
74  self.take_control()
75  self.gimbal.take_control()
76  self.ccd47.write_fifoch('serve 0')
77  self.giveup_control()
78 
79  def setup(self, filter2, filter3):
80  self.fw2.set_filter(filter2)
81  self.fw3.set_filter(filter3)
82 
83  visao_wait(2)
84 
85  self.focus.preset()
86 
87  resp = self.focus.wait_move()
88  if(resp != 1):
89  raise "setup: Focus motor error. "
90 
91  resp = self.fw2.wait_move()
92  if(resp != 0):
93  raise "setup: F/W 2 motor error. "
94 
95  resp = self.fw3.wait_move()
96  if(resp != 0):
97  raise "setup: F/W 3 motor error. "
98 
99  def take_darks(self, ndarks):
100  print "take_darks: taking %i darks" % ndarks
101  if self.shutter.get_state() != -1:
102  et = 1./self.ccd47.get_framerate()
103  print "take_darks: closing shutter"
104  self.shutter.shut()
105  if et >= 5.0:
106  self.ccd47.stop()
107  self.ccd47.start()
108  else:
109  visao_wait(et)
110  if et < .1:
111  visao_wait(.1)
112 
113  if self.shutter.get_state() != -1:
114  raise "take_darks: could not close shutter"
115 
116  print "take_darks: shutter closed"
117 
118 
119  self.ccd47.savedark(ndarks)
120  self.ccd47.wait_save()
121 
122  print "take_darks: done"
123 
124  def take_flats(self, nflt):
125  print "taking %i flats" % nflt
126  if self.shutter.get_state() != 1:
127  et = 1./self.ccd47.get_framerate()
128  print " exptime = %f" % et
129  print " opening shutter"
130  self.shutter.open()
131  visao_wait(et)
132 
133  print " shutter open"
134  self.ccd47.imtype(4)
135  visao_wait(.1)
136  self.ccd47.save(nflt)
137  self.ccd47.wait_save()
138  print " done"
139 
140  def take_science(self, nsci):
141  print "take_science: taking %i science images" % nsci
142  if self.shutter.get_state() != 1:
143  et = 1./self.ccd47.get_framerate()
144  print "take_science: opening shutter"
145  self.shutter.open()
146  if et >= 5.0:
147  self.ccd47.stop()
148  self.ccd47.start()
149  else:
150  visao_wait(et)
151  if et < .1:
152  visao_wait(.1)
153 
154  if self.shutter.get_state() != 1:
155  raise "take_science: could not open shutter"
156 
157  print "take_science: shutter open"
158 
159  self.ccd47.savescience(nsci)
160 
161  self.ccd47.wait_save()
162 
163  print "take_science: done"
164 
165  def take_linearity(self, nims, etimes):
166  """
167  Take a linearity curve.
168 
169  Takes darks and science frames at a sequence of exposure times.
170 
171  nims = number of darks and science frames to take at each exposure time
172  etimes = exposure times, e.g. [.3, .5, .75, 1.0, 2.0, 3.0], in secs
173  """
174  print "starting linearity curve . . ."
175  sd = get_visao_filename_now("linearity_")
176 
177  self.ccd47.subdir(sd)
178 
179  self.ccd47.reps(0)
180 
181  self.take_darks(nims)
182 
183  for i in range(len(etimes)):
184  print " step %i: " % i
185  self.ccd47.exptime(etimes[i])
186  visao_wait(.5)
187  et = 1./self.ccd47.get_framerate()
188  print " ccd47 exposure time set to %f" % et
189 
190  self.take_science(nims)
191 
192  print " linearity curve complete"
193 
194  self.ccd47.subdir(".")
195 
196  def science(self, totexp, exptime, masterdarks, darkint, ndark, dirname="science", appendts=1, subroutine=0):
197  """
198  Take a science data set
199 
200  Takes science images until a specified total exposure time is reached. Takes darks at intervals.
201  Other than exposure time, assumes camera is set up as you prefer.
202 
203  totexp = total science exposure time, in seconds
204  exptime = exposure time of individual images, in seconds
205  masterdarks = number of darks to take at beginning of script
206  darkint = interval between dark sets, in seconds
207  ndark = number of dark frames to take
208  dirname = base name of directory to store images in, default is "science"
209  appendts = append the standard VisAO timestamp, default is 1 (yes). set to 0 for no.
210  """
211  try:
212 
213  if exptime == 0:
214  exptime = 1/self.ccd47.get_framerate()
215  print "science: using current exposure time = %f" % exptime
216 
217  nscitot = math.floor(totexp/exptime + 0.99999)
218  nsci = math.floor(darkint/exptime)
219  if darkint <= 0:
220  nsci = nscitot
221  ndarksets = 0
222  else:
223  ndarksets = math.floor(nscitot/darkint)
224 
225  if appendts:
226  sd = get_visao_filename_now(dirname)
227  else:
228  sd = dirname
229 
230  print '\n**********************************************\n'
231  print ' Will take VisAO science data:'
232  print ' %i total science images, %f sec total science exposure' % (nscitot , (nscitot*exptime))
233  print ' in sets of %i images with %i darks in between' % (nsci , ndark)
234  print ' Total time = %f sec' % (nscitot*exptime + ndarksets*ndark*exptime)
235  print " Saving images to directory: %s" % sd
236  print '\n'
237 
238  if subroutine == 0:
239  foo = raw_input('Proceed ? [y/n] (n): ')
240  if (foo != 'y'):
241  print 'Stopping'
242  return
243 
244  print 'Proceeding . . .'
245 
246  self.connect()
247  self.take_control()
248 
249  self.ccd47.subdir(sd)
250 
251  self.focus.preset()
252  visao_wait(1.)
253  resp = self.focus.wait_move()
254  if(resp != 1):
255  raise "science: focus motor error. "
256 
257  print "science: focus motor is focused."
258 
259  #Do this after the focus check to give it time to propagate
260  set_subdir = self.ccd47.get_subdir()
261  if(set_subdir != sd):
262  visao_wait(1.)
263  set_subdir = self.ccd47.get_subdir()
264  if(set_subdir != sd):
265  print set_subdir
266  print sd
267  raise "science: ccd47 subdirectory error"
268 
269 
270  self.ccd47.exptime(exptime)
271  nsci_taken = 0
272 
273  if (masterdarks > 0):
274  self.take_darks(masterdarks)
275 
276  for i in range(int(nscitot/nsci)):
277 
278  self.take_science(nsci)
279 
280  if(ndark > 0):
281  self.take_darks(ndark)
282 
283  nsci_taken = nsci_taken + nsci
284 
285  self.take_science(nscitot-nsci_taken)
286  nsci_taken = nscitot-nsci_taken
287 
288 
289  print '\n**********************************************\n'
290  print ' Completed taking VisAO science data:'
291  print ' %i total science images taken.' % nsci_taken
292  print '\n**********************************************\n'
293 
294  self.ccd47.subdir("./")
295 
296  if subroutine == 0:
297  self.giveup_control()
298  visao_alert(1)
299  visao_script_complete()
300 
301  except Ctrl_C_Except:
302  visao_alert(1)
303 
304  self.ccd47.save(0)
305  self.ccd47.subdir("./")
306  self.shutter.open()
307  self.giveup_control()
308 
309  visao_script_stopped()
310  print '******************\n science: script stopped\n******************\n'
311 
312  except:
313  visao_alert(1)
314  self.ccd47.save(0)
315  self.ccd47.subdir("./")
316  self.shutter.open()
317  self.giveup_control()
318  visao_script_error()
319  print '******************\n science: something bad happened\n******************\n'
320  raise
321 
322  raise
323 
324 
325  def observation(self, observations, repeats, subdir="", appendts=1):
326 
327  try:
328  #Check for valid input
329  if type(observations) != tuple:
330  raise "observation: invalid observation (must be tuple)"
331 
332  #Next figure out how many observations there are
333  #with the problem being that both 1 and 11 observations must be handled
334  #given that an observation has 11 entries
335 
336  nobs = 0
337  if len(observations) == 11:
338  if type(observations[2]) is int:
339  nobs = 1
340  else:
341  nobs = len(observations)
342  else:
343  nobs = len(observations)
344 
345 
346  #now check for valid observations
347  if nobs == 1:
348  if type(observations) != tuple:
349  raise "observation: invalid observation (must be tuple)"
350 
351  if len(observations) != 11:
352  raise "observation: invalid observation (must have 11 elements)"
353 
354  #have to make this a tuple-tuple
355  observations = (observations, observations)
356  else:
357  for i in range(nobs):
358  if type(observations[i]) != tuple:
359  raise "observation: invalid observation number %d (must be tuple)" % (i+1)
360 
361  if len(observations[i]) != 11:
362  raise "observation: invalid observation number %d (must have 11 elements)" % (i+1)
363 
364  if subdir == "":
365  subdir = "observation"
366 
367  if appendts:
368  sdbase = get_visao_filename_now(subdir)
369  else:
370  sdbase = subdir
371 
372 
373 
374  keepgoing = 1
375  ntimes = 0
376 
377  self.connect()
378  self.take_control()
379 
380  while keepgoing:
381 
382  for i in range(nobs):
383 
384  print "observation: Changing filter 2 to %s . . ." % observations[i][0]
385  resp = self.fw2.set_filter(observations[i][0])
386  print "observation: Changing filter 3 to %s . . ." % observations[i][1]
387  resp = self.fw3.set_filter(observations[i][1])
388 
389  #sleep to give the filter wheels time to wake up and get moving
390  time.sleep(2)
391 
392  print "observation: Moving to focus preset"
393  self.focus.preset()
394 
395  print "observation: Programming CCD 47"
396  etime = observations[i][5]
397  minetime = getCCD47MinExp(observations[i][2],observations[i][3],1)
398  if etime < minetime:
399  etime = minetime
400  self.ccd47.set_program(observations[i][2],observations[i][3],observations[i][4], etime)
401  #ccd47.set_program waits for completion
402 
403 
404  #Now we check on the motor moves.
405  resp = self.focus.wait_move()
406  resp2 = self.fw2.wait_move()
407  resp3 = self.fw3.wait_move()
408 
409 
410  filt2 = self.fw2.get_filter()
411  filt3 = self.fw3.get_filter()
412 
413  if filt2 != observations[i][0]:
414  raise "observation: filter 2 not correct"
415 
416  if filt3 != observations[i][1]:
417  raise "observation: filter 3 not correct"
418 
419  if(resp != 1):
420  raise "observation: focus motor error"
421 
422  print "observation: In filters %s and %s, and in focus" % (filt2, filt3)
423 
424 
425  if(observations[i][10] == ""):
426  filtname2 = filt2.replace(" ", "_")
427  filtname2 = filtname2.replace("'", "p")
428 
429  filtname3 = filt3.replace(" ", "_")
430  filtname3 = filtname3.replace("'", "p")
431 
432  sd = "%s/%s_%s_%d" % (sdbase, filtname2, filtname3,i)
433  else:
434  sd = "%s/%s_%d" % (sdbase, observations[i][10], (ntimes+1))
435 
436 
437  #Now call the science script in subroutine mode
438  self.science(observations[i][6], etime, observations[i][7], observations[i][8], observations[i][9], sd, 0, 1)
439 
440 
441  #check for completion
442  ntimes = ntimes + 1
443  if ntimes >= repeats and repeats > 0:
444  keepgoing = 0
445 
446 
447  print '\n**********************************************\n'
448  print ' Completed VisAO observation:'
449  print ''
450  print '\n**********************************************\n'
451 
452  self.ccd47.subdir("./")
453 
454  self.giveup_control()
455  visao_alert(1)
456  visao_script_complete()
457 
458  except Ctrl_C_Except:
459  visao_alert(1)
460  self.giveup_control()
461  visao_script_stopped()
462  print '******************\n observation: script stopped\n******************\n'
463 
464  except:
465  visao_alert(1)
466  self.giveup_control()
467  visao_script_error()
468  print '******************\n observation: something bad happened\n******************\n'
469  raise
470 
471  raise
472 
473 
474  def dither(self, dx, dy, ims, ndarks, subdir="", appendts=1, giveup=1):
475  """
476  Take data in a dither pattern.
477 
478  Takes darks at the beginning, then takes science images at each gimbal position specified in dx,dy.
479 
480  dx = gimbal x positions (mm)
481  dy = gimbal y positions (mm)
482  ims = number of science images to take at each position.
483  ndarks = number of drks to take at the beginning
484  subdir = optional subdirectory. if not specified, then dither_[timestamp] will be used
485  appendts = append the standard VisAO timestamp, default is 1 (yes). set to 0 for no.
486  giveup = if set 1 one, then control will be taken and given up at the end of the dither
487  """
488 
489  try:
490 
491  if giveup:
492  self.take_control()
493 
494  self.gimbal.take_control()
495 
496  if subdir=="":
497  subdir = get_visao_filename_now("dither_")
498  else:
499  if appendts:
500  subdir = get_visao_filename_now(subdir)
501 
502  time.sleep(0.1)
503  self.ccd47.subdir(subdir)
504 
505 
506  #set_subdir = self.ccd47.get_subdir()
507  #if(set_subdir != subdir):
508  #raise "dither: ccd47 subdirectory error"
509 
510  startx = self.gimbal.get_xpos()
511  starty = self.gimbal.get_ypos()
512 
513  self.focus.preset()
514  visao_wait(1.)
515  resp = self.focus.wait_move()
516  if(resp != 1):
517  raise "dither: focus motor error. "
518 
519  print "dither: focus motor is focused."
520 
521 
522  print "dither: Saving %i darks" % (ndarks)
523 
524  self.take_darks(ndarks)
525 
526  print "dither: saving %i images at dither 1/%i" % (ims, len(dx))
527 
528  self.take_science(ims)
529 
530  for i in range(len(dx)):
531  print "dither: moving to pos %i/%i: %f %f . . ." % (i+1,len(dx), dx[i] , dy[i])
532  rv = self.gimbal.move_xrel(dx[i])
533  if rv != 0:
534  raise "dither: error during x dither. Halting."
535 
536  rv = self.gimbal.move_yrel(dy[i])
537  if rv != 0:
538  raise "dither: error during y dither. Halting."
539 
540  rv = self.gimbal.wait_move()
541  if rv != 0:
542  raise "dither: error during dither. Halting."
543 
544  #Wait 1 exposure time to not take a bad frame
545  et = 1./self.ccd47.get_framerate()
546  visao_wait(et)
547 
548  print "dither: saving %i images at dither %i/%i" % (ims, i, len(dx))
549 
550  rv = self.take_science(ims)
551 
552  print "dither: returning to start positions"
553 
554  rv = self.gimbal.move_xabs(startx)
555  if rv != 0:
556  raise "dither: error during x move. Halting."
557 
558  rv = self.gimbal.move_yabs(starty)
559  if rv != 0:
560  raise "dither: error during y move. Halting."
561 
562  rv = self.gimbal.wait_move()
563  if rv != 0:
564  print "raise: error during dither. Halting."
565 
566  self.ccd47.subdir(".")
567 
568  self.gimbal.giveup_control()
569 
570  if giveup:
571  self.giveup_control()
572  visao_script_complete()
573 
574  except Ctrl_C_Except:
575  if giveup == 0:
576  raise Ctrl_C_Except('script interrupted.') #If this is subordinate, pass exception on.
577 
578  visao_alert(1)
579 
580  self.ccd47.save(0)
581  self.shutter.open()
582  self.giveup_control()
583 
584  visao_script_stopped()
585  print '******************\n dither: script stopped\n******************\n'
586 
587  except:
588  visao_alert(1)
589  self.ccd47.save(0)
590  self.shutter.open()
591  self.giveup_control()
592  visao_script_error()
593  print '******************\n dither: something bad happened\n******************\n'
594  raise
595 
596  def dither_phot(self, filters, nims, ndarks, dx, dy, subdir="", appendts=1):
597  """
598  Take data in a dither pattern in multiple filters.
599 
600  Takes darks at the beginning of each filter, then takes science images at each gimbal position specified in dx,dy.
601  Then changes filters and repeats. Focus stage is moved to appropriate preset after each filter change.
602 
603  filters = list of filters to cycle through
604  nims = the number of science images to take in each dither position per filter
605  ndarks = the number of initial darks to take
606  dx = gimbal x offsets from initial position, in mm
607  dy = gimbal y offsets from initial position, in mm
608  subdir = optional subdirectory. if not specified, then dither_[timestamp] will be used
609  #appendts = append the standard VisAO timestamp, default is 1 (yes). set to 0 for no.
610  """
611  try:
612  if subdir == "":
613  subdir = "phot_dither"
614 
615  if appendts:
616  sdbase = get_visao_filename_now(subdir)
617  else:
618  sdbase = subdir
619 
620  self.connect()
621  self.take_control()
622 
623  for i in range(len(filters)):
624 
625  print "Changing filter to %s . . ." % filters[i]
626  resp = self.fw2.set_filter(filters[i])
627  time.sleep(2)
628 
629  print "Moving to focus preset . . ."
630  self.focus.preset()
631 
632  resp = self.fw2.wait_move()
633 
634  filt = self.fw2.get_filter()
635 
636  print "In filter %s . . ." % filt
637 
638  if filt!= filters[i]:
639  print "Filter not correct."
640  break
641 
642  if(resp != 0):
643  print "Focus motor error. "
644  return
645 
646  self.focus.wait_move()
647 
648  filtname = filt.replace(" ", "_")
649  filtname = filt.replace("'", "p")
650 
651  sd = "%s/%s" % (sdbase, filtname)
652  print sd
653 
654  self.dither(dx, dy, nims, ndarks, sd, 0,0)
655 
656  self.giveup_control()
657  visao_script_complete()
658 
659  except Ctrl_C_Except:
660  visao_alert(1)
661 
662  self.ccd47.save(0)
663  self.shutter.open()
664  self.giveup_control()
665 
666  visao_script_stopped()
667  print '******************\n dither_phot: script stopped\n******************\n'
668 
669  except:
670  visao_alert(1)
671  self.ccd47.save(0)
672  self.shutter.open()
673  self.giveup_control()
674  visao_script_error()
675  print '******************\n dither_phot: something bad happened\n******************\n'
676  raise
677 
678  def flats_old(self, totexp, exptime, ndark, dirname="flats"):
679  try:
680  nsci = math.floor(totexp/exptime + 0.99999)
681 
682 
683  sd = get_visao_filename_now(dirname)
684  print sd
685 
686  print '\n**********************************************\n'
687  print ' Will take VisAO flats data:'
688  print ' %i total flats per filter, %f sec total flat exposure' % (nsci, (nsci*exptime))
689  print ' With %i darks in between' % (ndark)
690  print " Saving images to directory: %s" % sd
691  print '\n'
692  foo = raw_input('Proceed ? [y/n] (n): ')
693  if (foo != 'y'):
694  print 'Stopping'
695  return
696 
697  print 'Proceeding . . .'
698  self.ccd47.subdir(sd)
699 
700  self.ccd47.exptime(exptime)
701 
702  nsci_taken = 0
703 
704 #pos1_name string "SDI H alpha"
705 #pos2_name string "SDI [S II]"
706 #pos3_name string "SDI [O I]"
707 
708  nds=["Open"]#, "ND 3.22", "ND 3 R .15"]
709 
710  filters=["r'"]
711 
712  self.fw2.set_filter(filters[0])
713 
714  for n in range(len(nds)):
715  print "Changing ND to %s . . ." % nds[n]
716  resp = self.fw3.set_filter(nds[n])
717  time.sleep(4)
718  resp = self.fw3.wait_move()
719  time.sleep(1)
720  ndn = self.fw3.get_filter()
721 
722  print "In ND %s . . ." % ndn
723 
724  if ndn!= nds[n]:
725  print "ND not correct."
726  return
727 
728  for i in range(len(filters)):
729  print "Changing filter to %s . . ." % filters[i]
730  resp = self.fw2.set_filter(filters[i])
731  time.sleep(4)
732  resp = self.fw2.wait_move()
733  time.sleep(1)
734  filt = self.fw2.get_filter()
735 
736  print "In filter %s . . ." % filt
737 
738  if filt!= filters[i]:
739  print "Filter not correct."
740  return
741  self.take_darks(ndark)
742  self.take_flats(nsci)
743 
744  visao_script_complete()
745  visao_alert(1)
746  except:
747  visao_script_error()
748  print '******************\nSomething bad happened\n******************\n'
749  visao_alert(1)
750  raise
751 
752 
753  def telemetry_cal(self, tottime, fast_darks, slow_darks, pset=0):
754  """
755  Take a telemetry data set with simultaneous focal plane data. Takes fast frames and slow frames
756 
757  tottime = total time of the measurement in seconds
758  fast_darks = number of fast darks to take
759  slow_darks = number of slow dards to take
760 
761  pset = the program set. pset=0 means 1024 and 64, pset=1 means 512 and 32
762 
763  """
764 
765  #the set commands to send to the CCD
766  fast_set = 'set 0 1 0 0' #program set 0, 64x64
767  slow_set = 'set 0 0 0 0' #program set 0, 1024x1024
768 
769  if pset == 1:
770  fast_set = 'set 1 1 0 0' #program set 1, 32x32
771  slow_set = 'set 1 0 0 0' #program set 1, 512x512
772 
773  #the exposure times
774  exptime_s = 0.031
775  exptime_l = 0.283
776 
777  if pset == 1:
778  exptime_s = .023 #0.0317662
779  exptime_l = 0.149
780 
781  self.bcu39.take_control()
782 
783 
784 
785  #Make sure we're focused
786  self.focus.preset()
787  visao_wait(1.)
788  resp = self.focus.wait_move()
789  if(resp != 1):
790  print "Focus motor error. "
791  return
792 
793  #configure for the fast frames
794  self.ccd47.write_fifoch(fast_set)
795  visao_wait(.5)
796 
797  self.ccd47.exptime(exptime_s)
798 
799  #set subdirectories
800  f = get_visao_filename_now('shuttercal_short')
801  self.ccd47.subdir('47_' + f)
802  self.fw39.take_control(1)
803  self.fw39.subdir('39_' + f)
804 
805  #take fast darks
806  self.take_darks(fast_darks)
807  self.shutter.open()
808 
809  #start saving: BCU 39 continuous, while ccd47 takes a set number of images
810  self.bcu39.save(-1)
811 
812  self.take_science(int(tottime/exptime_s+0.99999999))
813 
814  self.bcu39.save(0)
815 
816  #configure for slow frames
817  self.ccd47.write_fifoch(slow_set)
818  visao_wait(.5)
819 
820  #set subdirectories
821  f = get_visao_filename_now('shuttercal_long')
822  self.ccd47.subdir('47_' + f)
823  self.fw39.take_control(1)
824  self.fw39.subdir('39_' + f)
825 
826  self.take_darks(slow_darks)
827  self.shutter.open()
828 
829  #start saving: BCU 39 continuous, while ccd47 takes a set number of images
830  self.bcu39.save(-1)
831 
832  self.take_science(int(tottime/exptime_l+0.99999999))
833 
834  self.bcu39.save(0)
835 
836  visao_script_complete()
837  visao_alert(1)
838 
839  def take_ron(self, nf2500, nf250, nf80):
840 
841  self.shutter.shut()
842 
843  if nf2500 > 0:
844  #2500, 1024x1024, 1x1, gain=0
845  print '******************\n2500 kHz, 1024x1024, 1x1, gain 0\n******************\n'
846  self.ccd47.write_fifoch('set 0 0 0 0')
847  sd = get_visao_filename_now("ron2500_g0")
848  self.ccd47.subdir(sd)
849  visao_wait(1.)
850  self.ccd47.save(nf2500, 2)
851  self.ccd47.wait_save()
852 
853  #2500, 1024x1024, 1x1, gain=0
854  print '******************\n2500 kHz, 1024x1024, 1x1, gain 1\n******************\n'
855  self.ccd47.write_fifoch('set 0 0 1 0')
856  sd = get_visao_filename_now("ron2500_g1")
857  self.ccd47.subdir(sd)
858  visao_wait(1.)
859  self.ccd47.save(nf2500, 2)
860  self.ccd47.wait_save()
861 
862  #2500, 1024x1024, 1x1, gain=0
863  print '******************\n2500 kHz, 1024x1024, 1x1, gain 2\n******************\n'
864  self.ccd47.write_fifoch('set 0 0 2 0')
865  sd = get_visao_filename_now("ron2500_g2")
866  self.ccd47.subdir(sd)
867  visao_wait(1.)
868  self.ccd47.save(nf2500, 2)
869  self.ccd47.wait_save()
870 
871  #2500, 1024x1024, 1x1, gain=0
872  print '******************\n2500 kHz, 1024x1024, 1x1, gain 3\n******************\n'
873  self.ccd47.write_fifoch('set 0 0 3 0')
874  sd = get_visao_filename_now("ron2500_g3")
875  self.ccd47.subdir(sd)
876  visao_wait(1.)
877  self.ccd47.save(nf2500, 2)
878  self.ccd47.wait_save()
879 
880  if nf250 > 0:
881  #250, 1024x1024, 1x1, gain=0
882  print '******************\n250 kHz, 1024x1024, 1x1, gain 0\n******************\n'
883  self.ccd47.write_fifoch('set 0 2 0 0')
884  sd = get_visao_filename_now("ron250_g0")
885  self.ccd47.subdir(sd)
886  visao_wait(3.)
887  self.ccd47.save(nf250, 2)
888  self.ccd47.wait_save()
889 
890  #250, 1024x1024, 1x1, gain=1
891  print '******************\n250 kHz, 1024x1024, 1x1, gain 1\n******************\n'
892  self.ccd47.write_fifoch('set 0 2 1 0')
893  sd = get_visao_filename_now("ron250_g1")
894  self.ccd47.subdir(sd)
895  visao_wait(3.)
896  self.ccd47.save(nf250, 2)
897  self.ccd47.wait_save()
898 
899  #250, 1024x1024, 1x1, gain=2
900  print '******************\n250 kHz, 1024x1024, 1x1, gain 2\n******************\n'
901  self.ccd47.write_fifoch('set 0 2 2 0')
902  sd = get_visao_filename_now("ron250_g2")
903  self.ccd47.subdir(sd)
904  visao_wait(3.)
905  self.ccd47.save(nf250, 2)
906  self.ccd47.wait_save()
907 
908  #250, 1024x1024, 1x1, gain=3
909  print '******************\n250 kHz, 1024x1024, 1x1, gain 3\n******************\n'
910  self.ccd47.write_fifoch('set 0 2 3 0')
911  sd = get_visao_filename_now("ron250_g3")
912  self.ccd47.subdir(sd)
913  visao_wait(3.)
914  self.ccd47.save(nf250, 2)
915  self.ccd47.wait_save()
916 
917  if nf80 > 0:
918  #80, 1024x1024, 1x1, gain=0
919  print '******************\n80 kHz, 1024x1024, 1x1, gain 0\n******************\n'
920  self.ccd47.write_fifoch('set 0 4 0 0')
921  sd = get_visao_filename_now("ron80_g0")
922  self.ccd47.subdir(sd)
923  visao_wait(3.)
924  self.ccd47.save(nf80, 2)
925  self.ccd47.wait_save()
926 
927  #80, 1024x1024, 1x1, gain=1
928  print '******************\n80 kHz, 1024x1024, 1x1, gain 1\n******************\n'
929  self.ccd47.write_fifoch('set 0 4 1 0')
930  sd = get_visao_filename_now("ron80_g1")
931  self.ccd47.subdir(sd)
932  visao_wait(3.)
933  self.ccd47.save(nf80, 2)
934  self.ccd47.wait_save()
935 
936  #80, 1024x1024, 1x1, gain=2
937  print '******************\n80 kHz, 1024x1024, 1x1, gain 2\n******************\n'
938  self.ccd47.write_fifoch('set 0 4 2 0')
939  sd = get_visao_filename_now("ron80_g2")
940  self.ccd47.subdir(sd)
941  visao_wait(3.)
942  self.ccd47.save(nf80, 2)
943  self.ccd47.wait_save()
944 
945  #80, 1024x1024, 1x1, gain=3
946  print '******************\n80 kHz, 1024x1024, 1x1, gain 3\n******************\n'
947  self.ccd47.write_fifoch('set 0 4 3 0')
948  sd = get_visao_filename_now("ron80_g3")
949  self.ccd47.subdir(sd)
950  visao_wait(3.)
951  self.ccd47.save(nf80, 2)
952  self.ccd47.wait_save()
953 
954 
955  return
def connect(self)
Definition: visao.py:51
def telemetry_cal
Definition: visao.py:753
def take_linearity(self, nims, etimes)
Definition: visao.py:165
def take_flats(self, nflt)
Definition: visao.py:124
def take_science(self, nsci)
Definition: visao.py:140
def science
Definition: visao.py:196
def take_control(self)
Definition: visao.py:59
def dither
Definition: visao.py:474
def take_darks(self, ndarks)
Definition: visao.py:99
def dither_phot
Definition: visao.py:596
def giveup_control(self)
Definition: visao.py:66