-
Notifications
You must be signed in to change notification settings - Fork 332
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
Dev/princetoninstruments #994
base: master
Are you sure you want to change the base?
Conversation
…monochromator. Initial commit with most properties and methods drafted.
…sn't included in any toctree".
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.
Thank you very much for your contribution.
A few comments for the first round.
It is the second instrument to use pint, see #929 for the first one.
Some solutions might have to be discussed.
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.
As it is a new manufacturer, you have to add this file to the parent folder's index.rst as well, see https://pymeasure.readthedocs.io/en/latest/dev/adding_instruments/instrument.html#adding-documentation
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 add some protocol tests, especially as the instrument seems to need some hacks. For the tests, see https://pymeasure.readthedocs.io/en/latest/dev/adding_instruments/tests.html#protocol-tests
|
||
# RAD_TO_COUNTS inferred from default INIT-OFFSET values and three grating | ||
# positions on a turret. | ||
RAD_TO_COUNTS = 4_608_000/(2*np.pi) # [counts/rad] |
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.
Interesting. I've never seen a number defined with underscores.
By the way, it is good practice (mandated by some PEP) to have spaces around operators:
RAD_TO_COUNTS = 4_608_000/(2*np.pi) # [counts/rad] | |
RAD_TO_COUNTS = 4_608_000 / (2 * np.pi) # [counts/rad] |
kwargs.setdefault('write_termination', '\r') | ||
kwargs.setdefault('read_termination', '\r\n') |
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.
You can include these into the asrl dictionary as well with the same effects.
'stop_bits': pyvisa.constants.StopBits.one, | ||
'parity': pyvisa.constants.Parity.none, | ||
}, | ||
**kwargs |
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 add, whether the device supports SCPI or not (includeSCPI
parameter).
def write_bytes(self): | ||
"""Not implemented -- use adapter method.""" | ||
raise NotImplementedError("Use adapter method") | ||
|
||
def read_bytes(self): | ||
"""Not implemented -- use adapter method.""" | ||
raise NotImplementedError("Use adapter method") | ||
|
||
def write_binary_values(self): | ||
"""Not implemented -- use adapter method.""" | ||
raise NotImplementedError("Use adapter method") | ||
|
||
def read_binary_values(self): | ||
"""Not implemented -- use adapter method.""" | ||
raise NotImplementedError("Use adapter method") |
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 remove these blocking methods.
Set as a pint compatible value. | ||
""", | ||
get_process=lambda v: ureg.Quantity(v), # convert to quantity | ||
set_process=lambda v: ureg.Quantity(v).m_as('nm/min'), |
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 ease of use, could you add some method, which assumes the correct unit, for example something like:
def generate_magnitude_extractor(units)
def get_quantity_magnitude(value):
if isinstance(value, ureg.Quantity):
return value.m_as(units)
else:
return value
return get_quantity_magnitude
scan_rate = Instrument.control(...
set_process=generate_magnitude_extractor("nm/min")
That will make it easier to use for people who do not use pint (yet).
For another instrument with pint, see #929
# GRATING | ||
# ?GRATING |
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.
That's already in the control
defined, you do not need to repeat it in front.
# ?GRATING | ||
grating = Instrument.control( | ||
"?GRATING", "%d GRATING", | ||
"""Control grating being used. |
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.
"""Control grating being used. | |
"""Control which grating to use. |
Driver for the Princeton Instruments SP2300i spectrograph/monochromator.
It's a weirdly designed instrument... when connected via RS232 the commands are echoed back. Also, the instrument will not return the termination character until the command has been fully processed (sometimes 10's of seconds). The routes I took around these issues are a bit hacky, but hopefully it's still a useful starting point.