def move(self, stage1, stage2): """ Moves the stages with the specified values. Since GSC-02 is a half-step stepping driver, 1 pulse corresponds to "half-step movement" in the stage catalogues. """ if not (-16777214 <= stage1 <= 16777214): raise exceptions.ValueError('stage1 must be between -16777214 and 16777214.') if not (-16777214 <= stage2 <= 16777214): raise exceptions.ValueError('stage2 must be between -16777214 and 16777214.') command = 'M:W' if stage1 >= 0: command += '+P%d' % stage1 else: command += '-P%d' % -stage1 if stage2 >= 0: command += '+P%d' % stage2 else: command += '-P%d' % -stage2 self.write(command) self.go()
def setSpeed(self, minSpeed, maxSpeed, accelerationTime): """ Sets the movement speeds of the stages minSpeed: Minimum speed (PPS) maxSpeed: Maximum speed (PPS) accelerationTime: Acceleration time to be taken from min to max (ms) written by YK """ if not (1 <= minSpeed <= maxSpeed <= 500000): raise exceptions.ValueError('Must be 1 <= minSpeed1 <= maxSpeed1 <= 500000.') if not (0 <= accelerationTime <= 1000): raise exceptions.ValueError('Must be 00 <= accelerationTime <= 1000.') self.write('D:WS%dF%dR%dS%dF%dR%d' % (minSpeed, maxSpeed, accelerationTime, minSpeed, maxSpeed, accelerationTime))
def write(self, command): btemp = command + '\r\n' self.serial.write(btemp.encode()) """ SHOT702 reply b'OK' or b'NG' written by YK """ atemp = self.readline() atemp = str(atemp).replace("'","") atemp = atemp.replace('b','') if atemp == 'NG': raise exceptions.ValueError('Device was not accepted properly')
def create_subset_pulse(self, center_wl_nm, NPTS): """ Create new pulse with smaller frequency span, centered at closest grid point to center_wl_nm, with NPTS grid points and frequency-grid values from this pulse. """ if NPTS >= self.NPTS: raise exceptions.ValueError( "New pulse must have fewer points than existing one.") p = Pulse() center_idx = np.argmin(abs(self.wl_nm - center_wl_nm)) # We want to reduce the frequency span, which means holding df fixed # while reducing NPTS. The time window is 1/df, so this means holding # the time window fixed as well. p._frep_MHz = self.frep_MHz p.set_center_wavelength_nm(self.wl_nm[center_idx]) p.set_time_window_ps(self.time_window_ps) p.set_NPTS(NPTS) idx1 = center_idx - (NPTS >> 1) idx2 = center_idx + (NPTS >> 1) p.set_AW(self.AW[idx1:idx2]) return p
def setSpeed(self, highspeed, minSpeed1, maxSpeed1, accelerationTime1, minSpeed2, maxSpeed2, accelerationTime2): """ Sets the movement speeds of the stages highspeed: If true, speed range is 50-20000, else 1-200 minSpeed1/2: Minimum speed (PPS) maxSpeed1/2: Maximum speed (PPS) accelerationTime1/2: Acceleration time to be taken from min to max (ms) | _________ ... maximum speed (PPS) | / \ | / \ | / \ ... minimum speed (PPS) | | | | | | |__|______________|________ <-> acceleration time (ms) <-> deceleration time (ms) """ if not highspeed: if not (1 <= minSpeed1 <= maxSpeed1 <= 200): raise exceptions.ValueError('Must be 1 <= minSpeed1 <= maxSpeed1 <= 200 in low speed range.') if not (1 <= minSpeed2 <= maxSpeed2 <= 200): raise exceptions.ValueError('Must be 1 <= minSpeed2 <= maxSpeed2 <= 200 in low speed range.') else: if not (50 <= minSpeed1 <= maxSpeed1 <= 20000): raise exceptions.ValueError('Must be 50 <= minSpeed1 <= maxSpeed1 <= 20000 in high speed range.') if not (50 <= minSpeed2 <= maxSpeed2 <= 20000): raise exceptions.ValueError('Must be 50 <= minSpeed2 <= maxSpeed2 <= 20000 in high speed range.') if not (0 <= accelerationTime1 <= 1000): raise exceptions.ValueError('Must be 00 <= accelerationTime1 <= 1000.') if not (0 <= accelerationTime2 <= 1000): raise exceptions.ValueError('Must be 00 <= accelerationTime2 <= 1000.') if highspeed: self.write('D:2S%dF%dR%dS%dF%dR%d' % (minSpeed1, maxSpeed1, accelerationTime1, minSpeed2, maxSpeed2, accelerationTime2)) else: self.write('D:1S%dF%dR%dS%dF%dR%d' % (minSpeed1, maxSpeed1, accelerationTime1, minSpeed2, maxSpeed2, accelerationTime2))
def setBaudRate(self, rate): # changed by YK if rate in (38400): self.__baudRate = rate else: raise exceptions.ValueError('Invalid buard rate %d was given. Must be chosen from 38400.' % rate)
def setBaudRate(self, rate): if rate in (2400, 4800, 9600, 19200): self.__baudRate = rate else: raise exceptions.ValueError('Invalid buard rate %d was given. Must be chosen from 2400/4800/9600/19200.' % rate)
def __get_w0(self): r""" Return center angular frequency (THz) """ if self._centerfrequency is None: raise exceptions.ValueError('Center frequency is not set.') return 2.0 * np.pi * self._centerfrequency