def set_low(self, low, channel=1): """ Set the low voltage level of the current waveform. This changes the low level while keeping the high level fixed. Parameters ---------- low : pint.Quantity The new low level in volt-compatible units """ low = Q_(low) mag = low.to('V').magnitude self.inst.write('source{}:voltage:low {}V'.format(channel, mag))
def set_high(self, high, channel=1): """ Set the high voltage level of the current waveform. This changes the high level while keeping the low level fixed. Parameters ---------- high : pint.Quantity The new high level in volt-compatible units """ high = Q_(high) mag = high.to('V').magnitude self.inst.write('source{}:voltage:high {}V'.format(channel, mag))
def set_offset(self, offset, channel=1): """ Set the voltage offset of the current waveform. This changes the offset while keeping the amplitude fixed. Parameters ---------- offset : pint.Quantity The new voltage offset in volt-compatible units """ offset = Q_(offset) mag = offset.to('V').magnitude self.inst.write('source{}:voltage:offset {}V'.format(channel, mag))
def set_phase(self, phase, channel=1): """ Set the phase offset of the current waveform. Parameters ---------- phase : pint.Quantity or number The new low level in radian-compatible units. Unitless numbers are treated as radians. """ phase = Q_(phase) # This also accepts dimensionless numbers as rads if phase < -u.pi or phase > +u.pi: raise Exception("Phase out of range. Must be between -pi and +pi") mag = phase.to('rad').magnitude self.inst.write('source{}:phase {}rad'.format(channel, mag))
rm = visa.ResourceManager() rm.list_resources() from instrumental import instrument,list_instruments,u, Q_ from instrumental.drivers.spectrometers.thorlabs_ccs import CCS paramsets = list_instruments() ccs = instrument(paramsets[0]) num_avg = 10 integration_time = '0.01 seconds' ccs.set_integration_time(integration_time) integration_time = Q_(integration_time) wait_time = integration_time/100 start_time =time.time() for i in range(num_avg): time.sleep(integration_time.to('s').magnitude) ccs.start_single_scan() while not ccs.is_data_ready(): time.sleep(wait_time.to('s').magnitude) temp = ccs.get_scan_data() if i == 0: data = temp else: data = data + temp if sum(temp >= (1.0 - 1e-5)): raise Warning('Raw data is saturated') y = data / num_avg x = ccs._wavelength_array end_time = time.time() -start_time print(end_time) plt.plot(x,y)
def _set_amplitude(self, val, units, channel): val = Q_(val) mag = val.to('V').magnitude self.inst.write('source{}:voltage {}{}'.format(channel, mag, units))