<jupyter_start><jupyter_text>Setting up the mock deviceMeasurements are controlled through the `MeasurementControl` usually instantiated as `MC`<jupyter_code>from pycqed.instrument_drivers.virtual_instruments.mock_device import Mock_Device
MC = measurement_control.MeasurementControl('MC',live_plot_enabled=True, verbose=True)
MC.station = station
station.add_component(MC)

mock_device = Mock_Device('mock_device')
mock_device.mw_pow(-20)
mock_device.res_freq(7.400023457e9)
mock_device.cw_noise_level(.0005)
mock_device.acq_delay(.05)<jupyter_output><empty_output><jupyter_text>Measuring a resonator using the conventional methodPoints are chosen on a linspace of 100 points. This is enough to identify the location of the resonator.<jupyter_code>freqs = np.linspace(7.39e9, 7.41e9, 100)

d = det.Function_Detector(mock_device.S21,value_names=['Magn', 'Phase'], 
                          value_units=['V', 'deg'])
MC.set_sweep_function(mock_device.mw_freq)
MC.set_sweep_points(freqs)
MC.set_detector_function(d)
dat=MC.run('test')<jupyter_output><empty_output><jupyter_text>Using 1D adaptive sampler from the MC This can also be done using an adaptive `Leaner1D` object, chosing 100 points optimally in the interval.<jupyter_code>mock_device.acq_delay(.05)

d = det.Function_Detector(mock_device.S21, value_names=['Magn', 'Phase'], value_units=['V', 'deg'])

MC.set_sweep_function(mock_device.mw_freq)
MC.set_detector_function(d)
MC.set_adaptive_function_parameters({'adaptive_function': adaptive.Learner1D, 
                                     'goal':lambda l: l.npoints>100, 
                                     'bounds':(7.39e9, 7.41e9)})
dat = MC.run(mode='adaptive')
from pycqed.analysis import measurement_analysis as ma
# ma.Homodyne_Analysis(close_fig=False, label='M')<jupyter_output><empty_output><jupyter_text>Two D learnerThe learner can also be used to adaptively sample a 2D /heatmap type experiment. However, currently we do not have easy plotting function for that and we still need to rely on the adaptive Learner plotting methods. It would be great to have this working with a realtime pyqtgraph based plotting window so that we can use this without the notebooks.<jupyter_code>d = det.Function_Detector(mock_device.S21, value_names=['Magn', 'Phase'], value_units=['V', 'deg'])
MC.set_sweep_function(mock_device.mw_freq)
MC.set_sweep_function_2D(mock_device.mw_pow)
MC.set_detector_function(d)
MC.set_adaptive_function_parameters({'adaptive_function': adaptive.Learner2D, 
                                     'goal':lambda l: l.npoints>20*20, 
                                     'bounds':((7.398e9, 7.402e9), 
                                               (-20, -10))})
dat = MC.run(mode='adaptive')


# Required to be able to use the fancy interpolating plot 
adaptive.notebook_extension()
MC.learner.plot(tri_alpha=.1)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10288494960027807, 'fraction_numerical': 0.02780674313521029, 'mean_word_length': 4.577519379844961, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '8516', 'license': 'MIT', 'n_tokens_mistral': 1019, 'n_tokens_neox': 921, 'n_words': 206, 'path': 'examples/Adaptive sampling example using a mock device object.ipynb', 'repo_name': 'ZW7436/PycQED_py3', 'size': '2877'}