def seriesExposure(self, protocol, imType, itime, numexp=1, binning=1): """ This will start and exposure, likely the run till abort setting, and keep reading out images for the specified time. """ retval,width,height = andor.GetDetector() print 'GetDetector:', retval,width,height print "SetAcquisitionMode:", andor.SetAcquisitionMode(5) print 'SetReadMode:', andor.SetReadMode(4) print 'SetImage:', andor.SetImage(binning,binning,1,width,1,height) print 'GetDetector (again):', andor.GetDetector() print 'SetExposureTime:', andor.SetExposureTime(itime) print 'SetKineticTime:', andor.SetKineticCycleTime(0) if(imType == "bias"): itime = 0 andor.SetShutter(1,2,0,0) # TLL mode high, shutter mode Permanently Closed, 0 millisec open/close print 'SetExposureTime:', andor.SetExposureTime(0) else: andor.SetShutter(1,0,5,5) print 'SetExposureTime:', andor.SetExposureTime(itime) # TLL mode high, shutter mode Fully Auto, 5 millisec open/close print 'StartAcquisition:', andor.StartAcquisition() status = andor.GetStatus() print status counter = 1 while(status[1]==andor.DRV_ACQUIRING and counter <= numexp): status = andor.GetStatus() print status acquired = andor.WaitForAcquisition() status = andor.GetStatus() if(status[1] == andor.DRV_ACQUIRING and acquired == andor.DRV_SUCCESS): data = np.zeros(width/binning*height/binning, dtype='uint16') # reserve room for image results = andor.GetMostRecentImage16(data) # store image data print results, 'success={}'.format(results == 20002) # print if the results were successful if(results == andor.DRV_SUCCESS): # if the array filled store successfully data=data.reshape(width/binning,height/binning) # reshape into image print data.shape,data.dtype hdu = fits.PrimaryHDU(data,do_not_scale_image_data=True,uint=True) filename = time.strftime('/data/forTCC/image_%Y%m%d_%H%M%S.fits') hdu.writeto(filename,clobber=True) print "wrote: {}".format(filename) protocol.sendData("seriesSent " + str(counter)+","+itime+","+filename) counter += 1 print "Aborting", andor.AbortAcquisition() return "series 1" # exits with 1 for success
def funcProcess(self, protocol, data): ''' B{Process Method} Used to Determine Response to Data - If Incoming File is Signalled (via data['func']): - Set the Proto Instance File-name & File-size - Change the Proto Line Mode to "Raw" - Create the Buffer Obj to Buffer Incoming Data - If a Query is Signalled - Send the Current Q Info ''' # If the "Func" key is "file" -> File Incoming if data['func'] == 'file': # Sets the Protocol Instance Filename & File size protocol.fname = os.path.basename(data["filename"]) protocol.sizeTotal = data["size"] protocol.tags = data['tags'] self.Logger.msg('File -> {} <- Incoming...'.format( protocol.fname) ) # Set the Line Mode to "Raw" protocol.setRawMode() protocol.buffer = StringIO() self.Logger.msg('Line Mode set to "Raw", Buffer Created :)') # If the "Func" key is "query" -> Relay Current Q Details elif data['func'] == 'query': self.Logger.msg('The Q has been queried..') # Send the Current Q Info to the Client protocol.sendData(self.q.info) self.Logger.msg('Current Q Info Transmitted')
def kseriesExposure(self, protocol, imType, itime, filter="", readTime=3, numexp=1, binning=1, numAccum=1, accumCycleTime=0, kCycleTime=0): """ This handles multiple image acquisition using the camera kinetic series capability. The basic arguements are the passed in protocol, the image type, integration time, filter type, readout index, number of exposures, and binning type. In the future this function could be modified to include accumulations or add time the kinetic cycle time. Accumulations are how many images should be readout as one, and kCycleTime can add time between each exposure that is taken. """ global isAborted isAborted = False retval, width, height = andor.GetDetector() logger.debug('GetDetector: ' + str(retval) + " " + str(width) + " " + str(height)) logger.debug("SetAcquisitionMode: " + str(andor.SetAcquisitionMode(3))) logger.debug('SetReadMode: ' + str(andor.SetReadMode(4))) logger.debug( 'SetImage: ' + str(andor.SetImage(binning, binning, 1, width, 1, height))) logger.debug('GetDetector (again): ' + str(andor.GetDetector())) if imType == "bias": itime = 0 andor.SetShutter( 1, 2, 0, 0 ) # TLL mode high, shutter mode Permanently Closed, 0 millisec open/close logger.debug('SetExposureTime: ' + str(andor.SetExposureTime(0))) else: if imType in ['flat', 'object']: andor.SetShutter(1, 0, 5, 5) else: andor.SetShutter(1, 2, 0, 0) logger.debug( 'SetExposureTime: ' + str(andor.SetExposureTime(itime)) ) # TLL mode high, shutter mode Fully Auto, 5 millisec open/close logger.debug("SetNumberOfAccumulations: " + str(andor.SetNumberAccumulations(numAccum))) # number of exposures to be combined logger.debug("SetAccumulationTime: " + str(andor.SetAccumulationCycleTime(accumCycleTime))) logger.debug("SetNumberOfKinetics: " + str(andor.SetNumberKinetics(numexp))) # this is the number of exposures the user wants logger.debug('SetKineticTime: ' + str(andor.SetKineticCycleTime(accumCycleTime))) logger.debug("SetTriggerMode: " + str(andor.SetTriggerMode(0))) logger.debug("Timings: " + str(andor.GetAcquisitionTimings())) logger.debug("SetHSSpeed: " + str(andor.SetHSSpeed(0, readTime))) # default readTime is index 3 which is 0.5 MHz or ~6 sec # write headers attributes = [imType, binning, itime, filter] # header = self.getHeader(attributes) header = self.getHeader_2(attributes, 'heimdall') logger.debug('StartAcquisition: ' + str(andor.StartAcquisition())) status = andor.GetStatus() logger.debug(str(status)) imageAcquired = False counter = 1 while status[1] == andor.DRV_ACQUIRING: status = andor.GetStatus() progress = andor.GetAcquisitionProgress() runtime = 0 if progress[2] == counter or (not isAborted and progress[2] == 0 and imageAcquired): runtime -= time.clock() data = np.zeros(width // binning * height // binning, dtype='uint16') # reserve room for image results = andor.GetMostRecentImage16(data) # store image data logger.debug( str(results) + " " + 'success={}'.format(results == 20002) ) # print if the results were successful logger.debug('image number: ' + str(progress[2])) if results == andor.DRV_SUCCESS: # if the array filled store successfully data = data.reshape(width // binning, height // binning) # reshape into image logger.debug(str(data.shape) + " " + str(data.dtype)) hdu = fits.PrimaryHDU(data, do_not_scale_image_data=True, uint=True, header=header) # filename = time.strftime('/data/forTCC/image_%Y%m%d_%H%M%S.fits') filename = fits_utils.get_image_path('series') hdu.writeto(filename, clobber=True) logger.debug("wrote: {}".format(filename)) protocol.sendData("seriesSent" + str(counter) + " " + str(counter) + "," + str(itime) + "," + filename) # make a new header and write time to it for new exposure. # header = self.getHeader(attributes) header = self.getHeader_2(attributes, 'heimdall') if counter == numexp: logger.info("entered abort") isAborted = True imageAcquired = True counter += 1 runtime += time.clock() logger.debug("Took %f seconds to write." % runtime) return "series 1," + str(counter) # exits with 1 for success
def realTimeExposure(self, protocol, imType, itime, binning=1): """ Inputs are the Evora server protocol, the image type, the integration time, and the binning size. Runs camera in RunTillAbort mode. """ # global acquired retval, width, height = andor.GetDetector() logger.debug('GetDetector: ' + str(retval) + " " + str(width) + " " + str(height)) logger.debug("SetAcquisitionMode: " + str(andor.SetAcquisitionMode(5))) logger.debug('SetReadMode: ' + str(andor.SetReadMode(4))) logger.debug( 'SetImage: ' + str(andor.SetImage(binning, binning, 1, width, 1, height))) logger.debug('GetDetector (again): ' + str(andor.GetDetector())) logger.debug('SetExposureTime: ' + str(andor.SetExposureTime(itime))) logger.debug('SetKineticTime: ' + str(andor.SetKineticCycleTime(0))) if imType == "bias": andor.SetShutter( 1, 2, 0, 0 ) # TLL mode high, shutter mode Permanently Closed, 0 millisec open/close logger.debug('SetExposureTime: ' + str(andor.SetExposureTime(0))) else: if imType in ['flat', 'object']: andor.SetShutter(1, 0, 5, 5) else: andor.SetShutter(1, 2, 0, 0) logger.debug( 'SetExposureTime: ' + str(andor.SetExposureTime(itime)) ) # TLL mode high, shutter mode Fully Auto, 5 millisec open/close data = np.zeros(width // binning * height // binning, dtype='uint16') logger.debug( "SetHSSpeed: " + str(andor.SetHSSpeed(0, 1)) ) # read time on real is fast because they aren't science images logger.debug('StartAcquisition: ' + str(andor.StartAcquisition())) status = andor.GetStatus() logger.debug(str(status)) workingImNum = 1 start = time.time() end = 0 while status[1] == andor.DRV_ACQUIRING: progress = andor.GetAcquisitionProgress() currImNum = progress[ 2] # won't update until an acquisition is done status = andor.GetStatus() if status[1] == andor.DRV_ACQUIRING and currImNum == workingImNum: logger.debug("Progress: " + str(andor.GetAcquisitionProgress())) results = andor.GetMostRecentImage16(data) # store image data logger.debug( str(results) + 'success={}'.format(results == 20002) ) # print if the results were successful if results == andor.DRV_SUCCESS: # if the array filled store successfully data = data.reshape(width // binning, height // binning) # reshape into image logger.debug(str(data.shape) + " " + str(data.dtype)) hdu = fits.PrimaryHDU(data, do_not_scale_image_data=True, uint=True) # filename = time.strftime('/tmp/image_%Y%m%d_%H%M%S.fits') filename = fits_utils.get_image_path('real') hdu.writeto(filename, clobber=True) logger.debug("wrote: {}".format(filename)) data = np.zeros(width // binning * height // binning, dtype='uint16') protocol.sendData("realSent %s" % filename) # print("Sending", "realSent%d" % (workingImNum)) workingImNum += 1 end = time.time() logger.debug("Took %f seconds" % (end - start)) start = time.time() return "real 1" # exits with 1 for success
def kseriesExposure(self, protocol, imType, itime, filter="", readTime=3, numexp=1, binning=1, numAccum=1, accumCycleTime=0, kCycleTime=0): """ This handles multiple image acquisition using the camera kinetic series capability. The basic arguements are the passed in protocol, the image type, integration time, filter type, readout index, number of exposures, and binning type. In the future this function could be modified to include accumulations or add time the kinetic cycle time. Accumulations are how many images should be readout as one, and kCycleTime can add time between each exposure that is taken. """ global isAborted isAborted = False retval,width,height = andor.GetDetector() logger.debug('GetDetector: ' + str(retval) + " " + str(width) + " " + str(height)) logger.debug("SetAcquisitionMode: " + str(andor.SetAcquisitionMode(3))) logger.debug('SetReadMode: ' + str(andor.SetReadMode(4))) logger.debug('SetImage: ' + str(andor.SetImage(binning,binning,1,width,1,height))) logger.debug('GetDetector (again): ' + str(andor.GetDetector())) if(imType == "bias"): itime = 0 andor.SetShutter(1,2,0,0) # TLL mode high, shutter mode Permanently Closed, 0 millisec open/close logger.debug('SetExposureTime: ' + str(andor.SetExposureTime(0))) else: if(imType in ['flat', 'object']): andor.SetShutter(1,0,5,5) else: andor.SetShutter(1,2,0,0) logger.debug('SetExposureTime: ' + str(andor.SetExposureTime(itime))) # TLL mode high, shutter mode Fully Auto, 5 millisec open/close logger.debug("SetNumberOfAccumulations: " + str(andor.SetNumberAccumulations(numAccum))) # number of exposures to be combined logger.debug("SetAccumulationTime: " + str(andor.SetAccumulationCycleTime(accumCycleTime))) logger.debug("SetNumberOfKinetics: " + str(andor.SetNumberKinetics(numexp))) # this is the number of exposures the user wants logger.debug('SetKineticTime: ' + str(andor.SetKineticCycleTime(accumCycleTime))) logger.debug("SetTriggerMode: " + str(andor.SetTriggerMode(0))) logger.debug("Timings: " + str(andor.GetAcquisitionTimings())) logger.debug("SetHSSpeed: " + str(andor.SetHSSpeed(0, readTime))) # default readTime is index 3 which is 0.5 MHz or ~6 sec # write headers attributes = [imType, binning, itime, filter] header = self.getHeader(attributes) logger.debug('StartAcquisition: ' + str(andor.StartAcquisition())) status = andor.GetStatus() logger.debug(str(status)) imageAcquired = False counter = 1 while(status[1] == andor.DRV_ACQUIRING): status = andor.GetStatus() progress = andor.GetAcquisitionProgress() runtime = 0 if(progress[2] == counter or (not isAborted and progress[2] == 0 and imageAcquired)): runtime -= time.clock() data = np.zeros(width//binning*height//binning, dtype='uint16') # reserve room for image results = andor.GetMostRecentImage16(data) # store image data logger.debug(str(results) + " " + 'success={}'.format(results == 20002)) # print if the results were successful logger.debug('image number: ' + str(progress[2])) if(results == andor.DRV_SUCCESS): # if the array filled store successfully data=data.reshape(width//binning,height//binning) # reshape into image logger.debug(str(data.shape) + " " + str(data.dtype)) hdu = fits.PrimaryHDU(data,do_not_scale_image_data=True,uint=True, header=header) #filename = time.strftime('/data/forTCC/image_%Y%m%d_%H%M%S.fits') filename = als.getImagePath('series') hdu.writeto(filename,clobber=True) logger.debug("wrote: {}".format(filename)) protocol.sendData("seriesSent"+str(counter)+" "+str(counter)+","+str(itime)+","+filename) # make a new header and write time to it for new exposure. header = self.getHeader(attributes) if(counter == numexp): logger.info("entered abort") isAborted = True imageAcquired = True counter += 1 runtime += time.clock() logger.debug("Took %f seconds to write." % runtime) return "series 1,"+str(counter) # exits with 1 for success
def realTimeExposure(self, protocol, imType, itime, binning=1): """ Inputs are the Evora server protocol, the image type, the integration time, and the binning size. Runs camera in RunTillAbort mode. """ #global acquired retval,width,height = andor.GetDetector() logger.debug('GetDetector: ' + str(retval) + " " + str(width) + " " + str(height)) logger.debug("SetAcquisitionMode: " + str(andor.SetAcquisitionMode(5))) logger.debug('SetReadMode: ' + str(andor.SetReadMode(4))) logger.debug('SetImage: ' + str(andor.SetImage(binning,binning,1,width,1,height))) logger.debug('GetDetector (again): ' + str(andor.GetDetector())) logger.debug('SetExposureTime: ' + str(andor.SetExposureTime(itime))) logger.debug('SetKineticTime: ' + str(andor.SetKineticCycleTime(0))) if(imType == "bias"): andor.SetShutter(1,2,0,0) # TLL mode high, shutter mode Permanently Closed, 0 millisec open/close logger.debug('SetExposureTime: ' + str(andor.SetExposureTime(0))) else: if(imType in ['flat', 'object']): andor.SetShutter(1,0,5,5) else: andor.SetShutter(1,2,0,0) logger.debug('SetExposureTime: ' + str(andor.SetExposureTime(itime))) # TLL mode high, shutter mode Fully Auto, 5 millisec open/close data = np.zeros(width//binning*height//binning, dtype='uint16') logger.debug("SetHSSpeed: " + str(andor.SetHSSpeed(0, 1))) # read time on real is fast because they aren't science images logger.debug('StartAcquisition: ' + str(andor.StartAcquisition())) status = andor.GetStatus() logger.debug(str(status)) workingImNum = 1 start = time.time() end = 0 while(status[1]==andor.DRV_ACQUIRING): progress = andor.GetAcquisitionProgress() currImNum = progress[2] # won't update until an acquisition is done status = andor.GetStatus() if(status[1] == andor.DRV_ACQUIRING and currImNum == workingImNum): logger.debug("Progress: " + str(andor.GetAcquisitionProgress())) results = andor.GetMostRecentImage16(data) # store image data logger.debug(str(results) + 'success={}'.format(results == 20002)) # print if the results were successful if(results == andor.DRV_SUCCESS): # if the array filled store successfully data=data.reshape(width//binning,height//binning) # reshape into image logger.debug(str(data.shape) + " " + str(data.dtype)) hdu = fits.PrimaryHDU(data,do_not_scale_image_data=True,uint=True) #filename = time.strftime('/tmp/image_%Y%m%d_%H%M%S.fits') filename = als.getImagePath('real') hdu.writeto(filename,clobber=True) logger.debug("wrote: {}".format(filename)) data = np.zeros(width//binning*height//binning, dtype='uint16') protocol.sendData("realSent " + filename) workingImNum += 1 end = time.time() logger.debug("Took %f seconds" % (end-start)) start = time.time() return "real 1" # exits with 1 for success
def realTimeExposure(self, protocol, imType, itime, binning=1): """ This will start and exposure, likely the run till abort setting, and keep reading out images for the specified time. """ #global acquired retval,width,height = andor.GetDetector() print 'GetDetector:', retval,width,height print "SetAcquisitionMode:", andor.SetAcquisitionMode(5) print 'SetReadMode:', andor.SetReadMode(4) print 'SetImage:', andor.SetImage(binning,binning,1,width,1,height) print 'GetDetector (again):', andor.GetDetector() print 'SetExposureTime:', andor.SetExposureTime(itime) print 'SetKineticTime:', andor.SetKineticCycleTime(0) if(imType == "bias"): andor.SetShutter(1,2,0,0) # TLL mode high, shutter mode Permanently Closed, 0 millisec open/close print 'SetExposureTime:', andor.SetExposureTime(0) else: if(imType in ['flat', 'object']): andor.SetShutter(1,0,5,5) else: andor.SetShutter(1,2,0,0) print 'SetExposureTime:', andor.SetExposureTime(itime) # TLL mode high, shutter mode Fully Auto, 5 millisec open/close data = np.zeros(width/binning*height/binning, dtype='uint16') print 'StartAcquisition:', andor.StartAcquisition() status = andor.GetStatus() print status while(status[1]==andor.DRV_ACQUIRING): #status = andor.GetStatus() #print status #acquired = andor.WaitForAcquisitionTimeOut(int(itime)) #if acquired == andor.DRV_SUCCESS: # print acquired, 'success={}'.format(acquired == andor.DRV_SUCCESS) #print acquired acquired = andor.WaitForAcquisition() status = andor.GetStatus() #if(status[1] != andor.DRV_ACQUIRING): #print status #acquired = andor.GetAcquiredData16(data) #print acquired, 'success={}'.format(acquired == andor.DRV_SUCCESS) #acc, series = np.zeros((1,), dtype=np.int_), np.zeros((1,), dtype=np.int_) #results = andor.GetAcquisitionProgress(acc, series) #acquired = None #results = andor.GetMostRecentImage16(data) #if(results == andor.DRV_SUCCESS): # print results if(status[1] == andor.DRV_ACQUIRING and acquired == andor.DRV_SUCCESS): data = np.zeros(width/binning*height/binning, dtype='uint16') # reserve room for image results = andor.GetMostRecentImage16(data) # store image data print results, 'success={}'.format(results == 20002) # print if the results were successful if(results == andor.DRV_SUCCESS): # if the array filled store successfully data=data.reshape(width/binning,height/binning) # reshape into image print data.shape,data.dtype hdu = fits.PrimaryHDU(data,do_not_scale_image_data=True,uint=True) filename = time.strftime('/tmp/image_%Y%m%d_%H%M%S.fits') hdu.writeto(filename,clobber=True) print "wrote: {}".format(filename) data = np.zeros(width/binning*height/binning, dtype='uint16') protocol.sendData("realSent " + filename) return "real 1" # exits with 1 for success