def frequency(self, frequency): """Defines RF frequency""" if self.has_doubler: truncated_range(frequency, (SG380.MIN_RF, 2*SG380.MAX_RF)) else: truncated_range(frequency, (SG380.MIN_RF, SG380.MAX_RF)) self.write("FREQ%.6f" % frequency)
def frequency(self, frequency): """Defines RF frequency""" if self.has_doubler: truncated_range(frequency, (SG380.MIN_RF, 2*SG380.MAX_RF)) else: truncated_range(frequency, (SG380.MIN_RF, SG380.MAX_RF)) self.write("FREQ%.6f" % frequency)
def configure_frequency_array_measurement(self, n_samples, channel): """ Configure the counter for an array of measurements. :param n_samples: The number of samples :param channel: Measurment channel (A, B, C, E, INTREF) """ n_samples = truncated_range(n_samples, [1, self.MAX_BUFFER_SIZE]) channel = strict_discrete_set(channel, self.CHANNELS) channel = self.CHANNELS[channel] self.write(f":CONF:ARR:FREQ {n_samples},(@{channel})")
def wavelength(self, value): """Wavelength in nm.""" if self.wavelength_settable: # Store min and max wavelength to only request them once. if not hasattr(self, "_wavelength_min"): self._wavelength_min = self.wavelength_min if not hasattr(self, "_wavelength_max"): self._wavelength_max = self.wavelength_max value = truncated_range( value, [self._wavelength_min, self._wavelength_max]) self.write("SENSE:CORR:WAV {}".format(value)) else: raise AttributeError( f"{self.sensor_name} does not allow setting the wavelength.")
def test_truncated_range(): assert truncated_range(5, range(10)) == 5 assert truncated_range(5.1, range(10)) == 5.1 assert truncated_range(-10, range(10)) == 0 assert truncated_range(20, range(10)) == 9
def voltage(self, level): voltage_range = [0, 5] if self.channel == 3 else [0, 30] new_level = truncated_range(level, voltage_range) self.write("SOURce:VOLTage:LEVel:IMMediate:AMPLitude %g" % new_level)
def test_truncated_range(): assert truncated_range(5, range(10)) == 5 assert truncated_range(5.1, range(10)) == 5.1 assert truncated_range(-10, range(10)) == 0 assert truncated_range(20, range(10)) == 9