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

Tickets/dm 44670 #141

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open

Tickets/dm 44670 #141

wants to merge 4 commits into from

Conversation

elanaku
Copy link

@elanaku elanaku commented Jun 10, 2024

ATCalSys updated so that (1) the filter scans have the correct wavelength range, (2) that setup_electrometers takes inputs from the config file about the electrometer mode, range, and integration time, and (3) there is only one electrometer scan per exposure.

Copy link
Contributor

@parfa30 parfa30 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 putting in this function @elanaku. I think this should work. Just have a couple questions that maybe @tribeiro will have to answer.

await electrometer.cmd_setIntegrationTime.set_start(
intTime=integration_time
)
await electrometer.cmd_performZeroCalib.start(timeout=self.long_timeout)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be set_start or just start? @tribeiro

Copy link
Member

@tribeiro tribeiro Jun 11, 2024

Choose a reason for hiding this comment

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

just start.. we only use set_start when we need to pass command parameters. Note that timeout is not a command parameter.

@@ -226,19 +253,21 @@ async def run_calibration_sequence(

calibration_type = getattr(CalibrationType, str(config_data["calib_type"]))
if calibration_type == CalibrationType.WhiteLight:
calibration_wavelenghts = np.array([float(config_data["wavelength"])])
calibration_wavelengths = np.array([float(config_data["wavelength"])])
else:
wavelength = float(config_data["wavelength"])
wavelength_width = float(config_data["wavelength_width"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change wavelength_width to something like filter_width or band_width. I find this term confusing. And why not just have a wavelength_start and wavelength_end with resolution?

Copy link
Member

Choose a reason for hiding this comment

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

I think this is a matter of personal preference. I find passing center wavelength + width more expressive. This is not a filter or band width, but rather the "scan width". I think we can certainly change these to something else if you think they will be more clear, but let's not do it as part of this ticket. Let's focus on what is being doing here instead.

Feel free to open a ticket for updating this though, and we can discuss in the ticket what would be a better solution.

Copy link
Member

@tribeiro tribeiro 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 the updates Elana. I have a few comments I hope you will take into consideration before I can approve the PR.

Also, can you please update the test_setup_electrometers in tests/auxtel/test_atcalsys.py to reflect the changes you've made? basically, make sure the commands you added are awaited as expected?

for component_name in self.components_attr
if "electrometer" in component_name
]:
await electrometer.cmd_setMode.set_start(mode=mode)
Copy link
Member

Choose a reason for hiding this comment

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

Please, add a timeout to all the calls to set_start here and in the next 3 lines. You can use timeout=self.long_timeout.

)

async def setup_electrometers(
self, mode: int = 1, range: float = -1, integration_time: float = 0.1
Copy link
Member

Choose a reason for hiding this comment

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

do you really need the default values here? it seems like this is always getting values from config_data above. I suggest you remove the default values.

async def setup_electrometers(
self, mode: int = 1, range: float = -1, integration_time: float = 0.1
) -> None:
"""Setup all electrometers."""
Copy link
Member

Choose a reason for hiding this comment

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

Please document the input parameters.

await asyncio.gather(
task_setup_monochromator,
task_setup_latiss,
task_setup_monochromator, task_setup_latiss, task_setup_electrometer
Copy link
Member

Choose a reason for hiding this comment

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

This is a picky comment but do you mind adding a comma after task_setup_electrometer? This will cause black to format the code such that each task is in a separate line (like it was originally), thus reducing the signature change when we add new tasks.

Copy link
Member

@tribeiro tribeiro left a comment

Choose a reason for hiding this comment

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

Here some additional comments.

I think this is mostly ready to go. However, before I approve it, please, check my latest comments and cleanup the git history.

Also, one note on the news fragment. Since you are doing more than one change, the way to do that is by creating different files, one for each change. This will also allow you to properly classify them. It works like this:

file doc/news/DM-44670.bugfix.rst

Update ATCalSys so that the filter scans have the correct wavelength range.

file doc/news/DM-44670.feature.rst

Update BaseCalSys.setup_electrometers to setup electrometer mode, range, and integration time from input parameters.

file doc/news/DM-44670.feature.1.rst

Update ATCalSys.prepare_for_flat to call setup_electrometer.

file doc/news/DM-44670.feature.2.rst

Update atcasys configuration such that the electrometer exposure time is similar to the camera exposure time and to include the additional electrometer configuration.

@@ -309,12 +318,10 @@ async def _take_data(
exposures_done: asyncio.Future = asyncio.Future()

fiber_spectrum_exposure_coroutine = self.take_fiber_spectrum(
exposure_time=fiber_spectrum_exposure_time,
exposures_done=exposures_done,
exposure_time=fiber_spectrum_exposure_time, exposures_done=exposures_done
Copy link
Member

Choose a reason for hiding this comment

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

please, undo this change here.

)
electrometer_exposure_coroutine = self.take_electrometer_scan(
exposure_time=electrometer_exposure_time,
exposures_done=exposures_done,
exposure_time=electrometer_exposure_time, exposures_done=exposures_done
Copy link
Member

Choose a reason for hiding this comment

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

please, undo this change here.

async def setup_electrometers(self) -> None:
"""Setup all electrometers."""
async def setup_electrometers(
self, mode: int, range: float, integration_time: float
Copy link
Member

Choose a reason for hiding this comment

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

if mode is an enumeration, please, use the enumeration instead of an int.

Copy link
Author

Choose a reason for hiding this comment

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

I think we do pass an int that is then turned into an enum by the controller in ts_electrometer (at least, that's my understanding - @parfa30 can confirm). Should I make a note of that? Should I call this an enum value?

Copy link
Member

Choose a reason for hiding this comment

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

yes, we are always passing int when we send the commands. But this is a high level user interface. So, if there is an enumeration that represents the values, we should probably use it.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, I will add in the enumeration!


Parameters
----------
mode : `int`
Copy link
Member

Choose a reason for hiding this comment

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

if this is an enumeration, please use the enum instead

@parfa30 parfa30 force-pushed the tickets/DM-44670 branch 2 times, most recently from 5196040 to 79d2100 Compare June 19, 2024 01:15
Electrometer measurement range.
"""
elec_mode = getattr(UnitToRead, mode)
elecMode = elec_mode.value
Copy link
Member

@tribeiro tribeiro Jun 25, 2024

Choose a reason for hiding this comment

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

Please, merge these 2 lines into:

electrometer_mode = getattr(UnitToRead, mode).value

for electrometer in [
getattr(self.rem, component_name)
for component_name in self.components_attr
if "electrometer" in component_name
]:
await electrometer.cmd_setMode.set_start(
mode=elecMode,
Copy link
Member

Choose a reason for hiding this comment

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

Replace this with electrometer_mode

@parfa30
Copy link
Contributor

parfa30 commented Jun 25, 2024

Made those changes and fixed a problem with the tests. Rebased with develop.

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

3 participants