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 45406 #137

Merged
merged 2 commits into from
Jul 26, 2024
Merged

Tickets/dm 45406 #137

merged 2 commits into from
Jul 26, 2024

Conversation

dsanmartim
Copy link
Contributor

Hi Tiago. Here is a draft pull request for your review.

@dsanmartim dsanmartim requested a review from tribeiro July 25, 2024 21:52
@dsanmartim dsanmartim marked this pull request as ready for review July 26, 2024 13:56
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.

I have a few inline comments.


# Ensure flats_exp_times is provided in pairs
if len(config.flats_exp_times) % 2 != 0:
raise ValueError("Flats exposure times must be provided in pairs.")
Copy link
Member

Choose a reason for hiding this comment

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

Should be RuntimeError.

# Check that each pair in flats_exp_times contains equal values
for i in range(0, len(config.flats_exp_times), 2):
if config.flats_exp_times[i] != config.flats_exp_times[i + 1]:
raise ValueError(
Copy link
Member

Choose a reason for hiding this comment

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

Should be RuntimeError

if len(config.flats_exp_times) % 2 != 0:
raise ValueError("Flats exposure times must be provided in pairs.")

# Check that each pair in flats_exp_times contains equal values
Copy link
Member

Choose a reason for hiding this comment

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

Why are you enforcing it this way? Why not let the user provide a single value and take twice the number of exposures?

isinstance(config.interleave_darks["dark_exp_times"], list)
and config.interleave_darks["n_darks"]
):
raise ValueError(
Copy link
Member

Choose a reason for hiding this comment

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

Should be RuntimeError. Also, why not just ignore this altogether? just log a warning saying that n_darks are going to be ignored because dark_exp_times is an array.

"""
try:
electrometer_mode = getattr(UnitToRead, mode).value
except AttributeError:
Copy link
Member

Choose a reason for hiding this comment

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

Why convert an AttributeError into a ValueError. If anything (which I don't think is necessary) convert it into a RuntimeError... But I would just not this at all. Just do

electrometer_mode = getattr(UnitToRead, mode).value

electrometer_mode = getattr(UnitToRead, mode).value
except AttributeError:
raise ValueError(f"Invalid electrometer 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.

What if the electrometer is not defined? Above you only call configure_electrometer if electrometer_scan is passed to the configuration.

I would add an assert self.electrometer is not None here. But also, if you always need an electrometer make sure you make electrometer_scan required.

        if hasattr(config, "electrometer_scan"):
            await self.configure_electrometer(config.electrometer_scan["index"])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. But the idea is to make it optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And the code you suggested is already done in the he configure method:

      if hasattr(config, "electrometer_scan"):
            await self.configure_electrometer(config.electrometer_scan["index"])

exp_time + self.extra_scan_time
)

flat_task = self.camera.take_imgtype(
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 use take_flats? you know this is going to be a flat.

f"Taking flat {j+1}/2 with exposure time: {exp_time} "
f"seconds."
)
await self.camera.take_imgtype(
Copy link
Member

Choose a reason for hiding this comment

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

Again, use take_flats

f"Taking dark {k+1}/{len(self.config.interleave_darks['dark_exp_times'])} "
f"for pair {i // 2 + 1} of {len(self.config.flats_exp_times) // 2}."
)
await self.camera.take_imgtype(
Copy link
Member

Choose a reason for hiding this comment

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

Use take_darks

assert self.script.config.interleave_darks["n_darks"] == 2
assert self.script.config.interleave_darks["dark_exp_times"] == [30, 30]

async def test_invalid_config(self):
Copy link
Member

Choose a reason for hiding this comment

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

Maybe give a hint of what is invalid about it.

Copy link
Contributor Author

@dsanmartim dsanmartim Jul 26, 2024

Choose a reason for hiding this comment

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

I was testing an invalid electrometer mode, but this will be an enum in the schema.

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.

Looks good to me..

@dsanmartim dsanmartim merged commit ae79778 into develop Jul 26, 2024
2 checks passed
@dsanmartim dsanmartim deleted the tickets/DM-45406 branch July 26, 2024 18:43
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.

2 participants