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

Create a simple use example for a camera #226

Closed
wants to merge 0 commits into from

Conversation

erinpougheon
Copy link
Collaborator

@erinpougheon erinpougheon commented Jul 15, 2024

Fixes #189.

Also tried to update the link for the Allied Vision cameras in the environment.yml file to link it to Vimba X VmbPy library.

@erinpougheon
Copy link
Collaborator Author

erinpougheon commented Jul 16, 2024

After creating a new environment as described in the README of catkit (but with a new name):
The GUI is working in simulation. There is only a camera viewer.
image

I tested the code on hardware too, on the THD2 testbed, with the visitor_camera (called science camera in the testbed_example of catkit). It worked as expected after the installation of vmbpy for the allied vision camera.
Here are two screenshots of what it looks like, when the flat is on and without the flat, with the laser on.

image (14)
image (13)

@erinpougheon erinpougheon requested a review from ivalaginja July 16, 2024 13:11
@erinpougheon erinpougheon changed the title Create an simple use example for a camera Create a simple use example for a camera Jul 16, 2024
@erinpougheon
Copy link
Collaborator Author

For the Vimba update in the environment.yml, I let the previous link, because when I try to update it, I have a GitHub error, saying that it can be install from git (which in logical regarding the documentation of vmbpy of Vimba X). My suggestion might be to delete completly this line, but I'll wait for you opinion.

@erinpougheon erinpougheon force-pushed the feature/simple_example_camera branch from f0db62e to 970bfc9 Compare July 16, 2024 14:46
Copy link
Collaborator

@ivalaginja ivalaginja left a comment

Choose a reason for hiding this comment

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

Looking good! Just some small stuff to address.

The big question we need to answer here is whether we can move some of the GUI stuff into the actual catkit2 package. @erinpougheon how about you address the comments I left, and then we try to estimate together whether this is doable?

@@ -20,7 +20,7 @@ def open(self):

self.images = self.make_data_stream('images', 'float64', self.model.focal_grid.shape, 20)

self.update_atmosphere()
self.update_atmosphere
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was this change intentional? self.atmosphere is a callable, so it usually should keep the parentheses in order to be called properly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes it is. Before deleting the parenthesis, I had an error TypeError: update_atmosphere() takes 1 positional argument but 2 were given. It is the only solution I found to solve this problem.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I find that weird. Let me have a look at this and I'll come back to you, because currently I can't find an explanation for this behavior.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ehpor any clue what might be happening here? @erinpougheon could you post the error message you're getting for this here please?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image (13)

Copy link
Collaborator

@raphaelpclt raphaelpclt Jul 18, 2024

Choose a reason for hiding this comment

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

Hmmm I think you're avoiding the error, but I don't think the atmosphere works either. My intuition is that it just doesn't do anything.

If you look at the simulator.py code here, https://github.com/spacetelescope/catkit2/blob/a7c17df19636676151d965e67d0085367ba14769/catkit2/simulator/simulator.py#L131C13-L131C41, it calls the callback function with time as an argument. So it will call self.update_atmosphere(t), that has 2 arguments (self, and t). You would need to define def update_atmosphere(self, t) or something like that.

Also, looking at the code, I feel the simple_simulator on develop is bugged.

catkit2/services/simple_simulator/simple_simulator.py Outdated Show resolved Hide resolved
testbed_example/cli_interface.py Outdated Show resolved Hide resolved
testbed_example/config/services.yml Outdated Show resolved Hide resolved
testbed_example/config/services.yml Outdated Show resolved Hide resolved
testbed_example/user_interface/bench_display.py Outdated Show resolved Hide resolved
testbed_example/user_interface/bench_display.py Outdated Show resolved Hide resolved
vbox_sidebar.addWidget(self.tree)

# Set to values of camera
self.p.param('Exposure', 'ExposureTime').setValue(self.camera.exposure_time / 1e6)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is something I want to address, although maybe not in this PR. This is a hard-coded conversion factor for the units of the camera exposure time, which is not fantastic in the example. Could you open an issue that says: "Remove hard-coded exposure time scaling in simple camera viewer" and link it here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here is the corresponding new issue : #228

testbed_example/user_interface/common.py Outdated Show resolved Hide resolved
testbed_example/user_interface/logging_display.py Outdated Show resolved Hide resolved
@ivalaginja
Copy link
Collaborator

For the Vimba update in the environment.yml, I let the previous link, because when I try to update it, I have a GitHub error, saying that it can be install from git (which in logical regarding the documentation of vmbpy of Vimba X). My suggestion might be to delete completly this line, but I'll wait for you opinion.

@erinpougheon ok. Can you open an issue for this ("Update Vimba Python package installation to VimbaX" or something like that) so that we don't forget about it?

@erinpougheon
Copy link
Collaborator Author

For the Vimba update in the environment.yml, I let the previous link, because when I try to update it, I have a GitHub error, saying that it can be install from git (which in logical regarding the documentation of vmbpy of Vimba X). My suggestion might be to delete completly this line, but I'll wait for you opinion.

@erinpougheon ok. Can you open an issue for this ("Update Vimba Python package installation to VimbaX" or something like that) so that we don't forget about it?

Done, here is the new issue : #229

@erinpougheon
Copy link
Collaborator Author

I changed everything you requested !

@erinpougheon erinpougheon requested a review from ivalaginja July 16, 2024 15:26
Copy link
Collaborator

@ivalaginja ivalaginja left a comment

Choose a reason for hiding this comment

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

One mini thing to fix, please, and the other comment is more a note to myself - consider this PR done from your side, and I will try to check why I find that one callable call weird.

testbed_example/user_interface/bench_display.py Outdated Show resolved Hide resolved
@@ -20,7 +20,7 @@ def open(self):

self.images = self.make_data_stream('images', 'float64', self.model.focal_grid.shape, 20)

self.update_atmosphere()
self.update_atmosphere
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find that weird. Let me have a look at this and I'll come back to you, because currently I can't find an explanation for this behavior.

@ivalaginja
Copy link
Collaborator

While trying to figure out what is happening with the update_atmosphere() method, I saw that the input to adding a callback function is not only the wrong way around where you fixed it, but also in the DM method:

self.add_callback(at_time, callback)

Could you fix that one as well please? It is not used in the example you set up so we didn't notice, but since we're already on it, let's fix that one too.

@erinpougheon
Copy link
Collaborator Author

erinpougheon commented Jul 19, 2024

@ivalaginja changed the simulator and optical model used in the example, so we don't have the same problem with the update_atmosphere(). (I think we can maybe open a new issue to just adress this simulator problem, I don't know).

Now, the example is working in simulation (evn though there is no light on it, because light is not implmented in the new example of simulation). Here is the result on the simulated server:
image

Hardware test on the THD2 testbed: Everything works as expected. I was able to have the viewer (we can see things because I turned on a laser). I could change the ROI, the gain, the exposure time etc.
image (14)

I think this PR is ready for final review and can be merged. I added the parenthesis back in the update_atmosphere function, in case we want it to be a separate issue.

@erinpougheon erinpougheon requested a review from ivalaginja July 19, 2024 12:49
Comment on lines 33 to 36
@property
def focal_grid(self):
return hcipy.make_focal_grid(12, 32)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you think wherever you needed the focal_grid you could just use the detector_grid below? I would like the grid parameters to be read from the configuration, and I was trying to call things in the detector plane (where the focal grid is) with "detector" to keep things more or less consistent.

@@ -12,7 +12,7 @@ def __init__(self):
super().__init__('example_simulator')

def open(self):
self.model = ExampleOpticalModel()
self.model = ExampleOpticalModel(self.testbed.config)
Copy link
Collaborator

@ivalaginja ivalaginja Jul 19, 2024

Choose a reason for hiding this comment

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

Nice catch on this - I also think it needs to be self.testbed.config['simulator']? Otherwise I am not sure what pool of configurations it tries to read, between all the different configuration files the example has. It might be automatically choosing the right one, but it's better to be explicit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made it go on the simulator file in the optical model, but I can defenitly change that you're right.

@ivalaginja ivalaginja requested a review from raphaelpclt July 19, 2024 13:56
@erinpougheon
Copy link
Collaborator Author

erinpougheon commented Jul 19, 2024

image

Here is the viewer (in simulation, because we changed nothing that has to do with the hardware) after the changes, everything works.

@erinpougheon erinpougheon requested a review from ivalaginja July 19, 2024 14:05
ivalaginja
ivalaginja previously approved these changes Jul 19, 2024
Copy link
Collaborator

@ivalaginja ivalaginja left a comment

Choose a reason for hiding this comment

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

Good by me. Please wait with merging until we hear back from @raphaelpclt.

Copy link
Collaborator

@raphaelpclt raphaelpclt left a comment

Choose a reason for hiding this comment

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

The code looks good overall. A few things can be removed (like experiment paths in the config - catkit2 doesn't implement experiment structures). Still pending discussion on what to let public or not.

Options:
-p, --port PORT_ID The port number on which the testbed server operates.
Defaults to the port specified in the config file.
--simulated Whether the testbed server should be run in simulated mode or not.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure - shouldn't --simulated be the default option or hardcoded? This example will never be running not simulated I guess.

@ivalaginja ivalaginja force-pushed the feature/simple_example_camera branch from 926695f to 8f235c3 Compare August 2, 2024 13:27
@ivalaginja ivalaginja closed this Aug 2, 2024
@ivalaginja ivalaginja force-pushed the feature/simple_example_camera branch from 8f235c3 to fcce243 Compare August 2, 2024 13:29
@spacetelescope spacetelescope deleted a comment from raphaelpclt Aug 2, 2024
@spacetelescope spacetelescope deleted a comment from raphaelpclt Aug 2, 2024
@spacetelescope spacetelescope deleted a comment from raphaelpclt Aug 2, 2024
@ivalaginja ivalaginja deleted the feature/simple_example_camera branch August 2, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set up example use case and document
3 participants