-
|
Hello everyone, I’m just getting started with QCoDeS, so apologies if this is a basic question. We’re working with an optical setup where we need to run long measurements at a fixed position. To keep the sample in focus, we use a piezo connected to the sample stage. The piezo is driven via an analog output of a DAQ card, and the same DAQ is used to read out the electrical signal from an APD. What I’m trying to do is implement a function that optimizes the stage (piezo) position based on the detected counts. I’d like to trigger this optimization either:
What’s the best way to integrate this kind of “autofocus” step into a simple measurement loop like the one below? with context_meas.run() as datasaver:
for set_v in np.linspace(0, 25, 10):
dac.ch1.set(set_v)
get_v = dmm.v1.get()
datasaver.add_result((dac.ch1, set_v), (dmm.v1, get_v))
dataset = datasaver.datasetHope the question is clear—thanks a lot for any advice! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
What an interesting quesion! thank you! this really depends on how you identify the moment when this refocus is needed. So if for example you want to do it every 10 points of the sweep, then just add a condition for that inside the for-loop: for idx, set_v in enumerate(np.linspace(0,25,100):
if idx % 10 == 0:
do_auto_focus()
....If you have a morecomplicated scenario, you can still implement it - that's the power of the measurement context manager (as compared to e.g. dond function) that it's plain python, so feel free to do what you need to do, and at some point just call add_result when the time is right to store the data. |
Beta Was this translation helpful? Give feedback.
oh, that's completely up to you :) You have full freedom to define as many DB files and Experiemnt objects in them as you see reasonable for your use case. There should be plenty of public API in qcodes to give you the freedom here. My humble opinion is that a signle DB file would do, but then you can ensure that you have different Experiements for the actual measurement and the intermediate auto focusing or whatever, just pass the correct experiment object to dond/Measurement and that's it.