-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
driver / SR830 : add the snap XY command to read X and Y together #1333
Conversation
The snap command records the values of X and Y at a single instant. This is a way to query values at the same time. This is important when the time constant is very short, < 100 ms. -> tuple (x,y)
typographical error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great addition! Nevertheless,
- please make it a method rather than a parameter since it is not settable, and returns two values
- is "X,Y" combination the only one that the device can return?
- please use lowercase "snake_case" names for parameters to be in accordance with the default style guide for python
the snap_xy is now a function using "add_function". in turn get_cmd -> call_cmd, and get_parser -> return_parser. SNAP_XY is also now lowercase
Hi astafan8, I've put the changes you recommended. It is now a function and in snake_case. the "X,Y" is not the only combination, but it the most important of the snap commands. In brief: This single snap_xy function I think covers the 99% of the use cases. What do you think? make it generalized? or simple? |
@@ -386,7 +386,17 @@ def parse_offset_get(s): | |||
get_cmd='OUTP? 4', | |||
get_parser=float, | |||
unit='deg') | |||
|
|||
|
|||
self.add_function('snap_xy', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant class bound method, like def snap_xy(...): ....
. Sorry that I was not clear enough.
@GeneralSarsby Yes, indeed, since you are implementing this great and useful feature, please, implement it in a flexible way. You can refer to this implementation in SR860 as a reference. Also, users will be very thankful if you also update the example notebook for SR830 with information on this feature (see the example notebook for SR860 for an example). I'm sure that there will be users who will fall into the 1% of the cases that |
Codecov Report
@@ Coverage Diff @@
## master #1333 +/- ##
==========================================
- Coverage 73.15% 72.22% -0.93%
==========================================
Files 79 83 +4
Lines 9156 9566 +410
==========================================
+ Hits 6698 6909 +211
- Misses 2458 2657 +199 |
snap is now a class bound method. it can be used as lockin.snap('x','y') -> tuple(x,y) it checks for a correct number of parameters and that the parameters are valid. It is not fussy about 'x' or 'X', and the confusing phase option can be 'p', 'P', 'Phase', 'phase', or 'θ'. to help with compatibility between similar drivers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, a flexible snap
method is much better. But please respond to my comments. Also, i'd really encourage you to document this feature in the example notebook (let me know if you need help with that).
mands will result in time delays, which may be greater than the time con- | ||
stant, between reading X and Y (or R and θ) | ||
Thus reading X,Y OR R,θ yields a coherent snapshot of the output signal. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's great that this corresponds to the description in the manual. However, i think it is also important that the following is also mentioned here:
The values of X and Y are recorded at a single instant. The values of R
and θ are also recorded at a single instant. Thus reading X,Y OR R,θ
yields a coherent snapshot of the output signal. If X,Y,R and θ are all
read, then the values of X,Y are recorded approximately 10µs apart from
R,θ. Thus, the values of X and Y may not yield the exact values of R and
θ from a single SNAP? query.
The values of the Aux Inputs may have an uncertainty of up to 32µs. The
frequency is computed only every other period or 40 ms, whichever is
longer.
The SNAP? command is a query only command. The SNAP? command
is used to
def snap(self, *parameter_names: str) -> Tuple[float, ...]: | ||
""" | ||
Gets the values of either 2, 3, 4, 5 or 6 parameters at a single instant. | ||
For example, SNAP? is a way to query values of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, substitute the notions of exact visa commands which they parameters/methods from the driver. We developer drivers exactly for the reason of hiding all of this visa-level stuff.
def snap(self, *parameter_names: str) -> Tuple[float, ...]: | ||
""" | ||
Gets the values of either 2, 3, 4, 5 or 6 parameters at a single instant. | ||
For example, SNAP? is a way to query values of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"for example"? this does not read nicely ((
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to re-write the whole docstring to make things clearer. Both with what the function does and with the limitations. I think this also covers a previous comment. We can develop this further if needed.
|
||
Args: | ||
*parameter_names | ||
2 or 3 names of parameters for which the values are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 or 3? it should be "from 2 up to 6", right?
Args: | ||
*parameter_names | ||
2 or 3 names of parameters for which the values are | ||
requested; valid names can be found in `PARAMETER_NAMES` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: SNAP_PARAMETERS
?
Gets the values of either 2, 3, 4, 5 or 6 parameters at a single instant. | ||
For example, SNAP? is a way to query values of | ||
X and Y (or R and θ) which are taken at the same time. This is important | ||
when the time constant is very short. Using the OUTP? or OUTR? com- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
within qcodes, we are generally following pep8, which requires the lines of code to not exceed 80 characters. Could you please adjust the code accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. This can be done.
f'to `SNAP_PARAMETERS` for a list of valid ' | ||
f'parameter names') | ||
|
||
p_ids = [self.PARAMETER_NAMES[name.lower()] for name in parameter_names] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: perhaps SNAP_PARAMETERS
?
(have this change been tested after all? :) )
Rewritten the doc string cleaning up the text. Removed all notions of visa commands. Removed space from 'aux 4' -> 'aux4' and similar in the SNAP_PARAMETERS. All lines are less than 80 characters long. To follow PEP8. Fixed typos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now i think it's ready :) Assuming that it has been tested on the actual instrument.
|
||
def snap(self, *parameters: str) -> Tuple[float, ...]: | ||
""" | ||
Get between 2 and 6 parameters at a single instant. This provides a coherent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so far as i know the text for the docstring shall start from """
, like this:
def smth():
"""
a great docstring
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition our docstrings should be valid restructured text using the Google docs extension see https://qcodes.github.io/Qcodes/examples/Creating%20Instrument%20Drivers.html#Documentation and https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
Specifically the args, returns and example sections should conform to the standard and you are not allowed to create other sections like the Units and Limitations. You probably want to put this in a notes section
@GeneralSarsby When you confirm that the feature has been tested on the actual instrument, I am going to merge. Looking forward to hearing from you |
included Tuple from the typing module. fixed the docstring indent. rearranged the section headings in the docstring.
The snap command records the values of X and Y at a single instant. This is a way to query values at the same time. This is important when the time constant is very short, < 100 ms.
-> tuple (x,y)
Changes proposed in this pull request: