Skip to content
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

Instrument/spectro270 m #1103

Open
wants to merge 50 commits into
base: master
Choose a base branch
from

Conversation

Daniel-Mael
Copy link

Hi,

We are two students at the National Institute of Applied Sciences (INSA) in Toulouse, France, working on a project with Mr. Sébastien Weber.

The project aims at instrumenting an optical spectrometer type Jobin Yvon 270M using Python. After creating a Python driver for this instrument, we want to use it with PyMoDAQ.

Yours sincerely,
Maël Le Blanc and Daniel Perales Rios
4th year Engineering Physics students at INSA Toulouse

Daniel-Mael and others added 30 commits November 24, 2023 14:44
This reverts commit 3698e6b.
Creation of the auto_baud function for initialising the 270M and the motor function.
We have added some functions for basic control of the spectrometer control.
We have added the function for controlling the motor depending on the wavelength, and controlling that the motor is not busy.
Adaptation to work in pyvisa instead of serial, and creation of the grating motor property and grating motor setter, as well as grating wavelength property and setter, to control respectively the absolute position of the grating motor and the wavelength.
Update in the authors file
writing properties of the grating and slits motors,
writing methods
writing tests for the spectrometer
Updating the read and write functions, and the timeouts.
Deleting unnecessary file
Updating the test file without the device.
Modification to the test file
adding test for get_entry_slit_microns
Updating the test files
Updating the test functions for the entry and exit slits
Update to the tests
Added the test files for the entry slit microns functions and for the motor stop and motor busy check
Finishing the test file without device for the Jobin Yvon 270M Spectrometer.
Further commenting the code of the driver for the Jobin Yvon 270M spectrometer.
Updating the test file without device for the spectrometer JY270m.
Correcting some problems of the JY270m's test with device.
Slight modification of the test file for the JY270m spectrometer.
Defining two extra properties that will be used in the test file for the JY270m instrument.
Further commenting the test file with device for the JY270M.
@BenediktBurger
Copy link
Member

Welcome you two @Daniel-Mael.

Thanks for contributing.

As a start, please merge the current master branch into your branch in order to have an up to date code base.

Copy link
Member

@BenediktBurger BenediktBurger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution.

Here is a first round of comments. Don't be discouraged by them.

Comment on lines +3 to +5
######
JobinYvon
######
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add spaces in the title as it is meant for humans. Also, the hashes should be as long as the text, for example:

Suggested change
######
JobinYvon
######
##########
Jobin Yvon
##########

Comment on lines +1 to +7
######################
Jobin Yvon Instruments
######################


Spectro270M Spectrometer
========================
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is only for the Spectro 270M spectrometer, therefore you do not need to repeat the manufacturer name. The manufacturer name from jobinyvon/index.rst will be the header!

Suggested change
######################
Jobin Yvon Instruments
######################
Spectro270M Spectrometer
========================
########################
Spectro270M Spectrometer
########################

Comment on lines +73 to +74
@property
def lambda_0(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you use properties instead of just setting lambda_0 = 1171.68 ?

Comment on lines +98 to +106
kwargs.update(dict(baud_rate=9600,
timeout=self.default_timeout,
parity=Parity.none,
data_bits=8,
stop_bits=StopBits.one,
flow_control=ControlFlow.dtr_dsr,
write_termination='',
read_termination='',
includeSCPI=False))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which of these things is hard coded and cannot be changed?
These unchangable parameters (for example includeSCPI) can enter directly the super().__init__() call.

name,
**kwargs)

gsteps = Instrument.control(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grating_steps would be more descriptive, wouldn't it?

Comment on lines +315 to +317
def check_get_errors(self, error):
print(error)
pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you doing here?
Residual of testing?

Comment on lines +328 to +338
def motor_busy_check(self):
"""
This function checks if at least one of the motors is busy.
"""
ans = self.write_read(b'E\r').decode()
if ans == "oz":
"We return False if the motor is not busy."
return False
if ans == "oq":
"We return True if the motor is busy."
return True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a property: motor_busy, which will return True or False?

Suggested change
def motor_busy_check(self):
"""
This function checks if at least one of the motors is busy.
"""
ans = self.write_read(b'E\r').decode()
if ans == "oz":
"We return False if the motor is not busy."
return False
if ans == "oq":
"We return True if the motor is busy."
return True
motor_busy = Instrument.measurement("E\r", values={True: "oq", False: "oz"}, map_values=True)

Comment on lines +350 to +360
if __name__ == '__main__':
spectro = JY270M('COM1',
baud_rate=9600,
timeout=300,
parity=Parity.none,
data_bits=8,
stop_bits=StopBits.one,
flow_control=ControlFlow.dtr_dsr,
write_termination='',
read_termination='',
includeSCPI=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove these lines.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding tests!

Comment on lines +7 to +19
@pytest.fixture(scope="module")
def init_communication():
instr = JY270M('COM1',
baud_rate=9600,
timeout=300,
parity=Parity.none,
data_bits=8,
stop_bits=StopBits.one,
flow_control=ControlFlow.dtr_dsr,
write_termination='',
read_termination='',
includeSCPI=False)
return instr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See our documentation on how to write device tests.
For we have a fixture, which allows to give the resource name via command line parameter as not everyone has their instrument at COM1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants