def AMI430_3D(): import numpy as np import qcodes.instrument.sims as sims from qcodes.instrument.ip_to_visa import AMI430_VISA from qcodes.instrument_drivers.american_magnetics.AMI430 import AMI430_3D visalib = sims.__file__.replace('__init__.py', 'AMI430.yaml@sim') mag_x = AMI430_VISA('x', address='GPIB::1::INSTR', visalib=visalib, terminator='\n', port=1) mag_y = AMI430_VISA('y', address='GPIB::2::INSTR', visalib=visalib, terminator='\n', port=1) mag_z = AMI430_VISA('z', address='GPIB::3::INSTR', visalib=visalib, terminator='\n', port=1) field_limit = [ lambda x, y, z: x == 0 and y == 0 and z < 3, lambda x, y, z: np.linalg.norm([x, y, z]) < 2 ] driver = AMI430_3D("AMI430_3D", mag_x, mag_y, mag_z, field_limit) try: yield driver, mag_x, mag_y, mag_z finally: driver.close() mag_x.close() mag_y.close() mag_z.close()
def current_driver(): """ Start three mock instruments representing current drivers for the x, y, and z directions. """ mag_x = AMI430_VISA('x', address='GPIB::1::65535::INSTR', visalib=visalib, terminator='\n', port=1) mag_y = AMI430_VISA('y', address='GPIB::2::65535::INSTR', visalib=visalib, terminator='\n', port=1) mag_z = AMI430_VISA('z', address='GPIB::3::65535::INSTR', visalib=visalib, terminator='\n', port=1) driver = AMI430_3D("AMI430-3D", mag_x, mag_y, mag_z, field_limit) yield driver mag_x.close() mag_y.close() mag_z.close() driver.close()
def magnet_axes_instances(): """ Start three mock instruments representing current drivers for the x, y, and z directions. """ mag_x = AMI430_VISA('x', address='GPIB::1::INSTR', visalib=visalib, terminator='\n', port=1) mag_y = AMI430_VISA('y', address='GPIB::2::INSTR', visalib=visalib, terminator='\n', port=1) mag_z = AMI430_VISA('z', address='GPIB::3::INSTR', visalib=visalib, terminator='\n', port=1) yield mag_x, mag_y, mag_z mag_x.close() mag_y.close() mag_z.close()
def _make_ami430(): mag = AMI430_VISA('ami430', address='GPIB::1::INSTR', visalib=visalib, terminator='\n', port=1) yield mag mag.close()
def ami430(request): mag = AMI430_VISA('ami430', address='GPIB::1::INSTR', visalib=visalib, terminator='\n', port=1, has_current_rating=request.param) yield mag mag.close()
def test_warning_increased_max_ramp_rate(): """ Test that a warning is raised if we increase the maximum current ramp rate. We want the user to be really sure what he or she is doing, as this could risk quenching the magnet """ max_ramp_rate = AMI430_VISA._DEFAULT_CURRENT_RAMP_LIMIT # Increasing the maximum ramp rate should raise a warning target_ramp_rate = max_ramp_rate + 0.01 with pytest.warns(AMI430Warning, match="Increasing maximum ramp rate") as excinfo: AMI430_VISA("testing_increased_max_ramp_rate", address='GPIB::4::65535::INSTR', visalib=visalib, terminator='\n', port=1, current_ramp_limit=target_ramp_rate) assert len(excinfo) >= 1 # Check we at least one warning.
def test_warning_increased_max_ramp_rate(): """ Test that a warning is raised if we increase the maximum current ramp rate. We want the user to be really sure what he or she is doing, as this could risk quenching the magnet """ max_ramp_rate = AMI430_VISA.default_current_ramp_limit # Increasing the maximum ramp rate should raise a warning target_ramp_rate = max_ramp_rate + 0.01 with pytest.raises(Warning) as excinfo: AMI430_VISA("testing_increased_max_ramp_rate", address='GPIB::4::65535::INSTR', visalib=visalib, terminator='\n', port=1, current_ramp_limit=target_ramp_rate) assert "Increasing maximum ramp rate" in excinfo.value.args[0]