ANR-COMPASS / shesha

ATTENTION: This repository is no longer up to date. The project is now available on GitLab https://gitlab.obspm.fr/cosmic-rtc/compass
https://compass.pages.obspm.fr/website/
GNU Lesser General Public License v3.0
15 stars 9 forks source link

Setting the camera gain #27

Open HorstSteuer opened 3 years ago

HorstSteuer commented 3 years ago

I am trying to simulate bad pixels on the WFS camera and hope to be able to set a per-pixel-gain map. I only found d_flat (and d_dark) both in the sutraWrap.PYRWFS and sutraWrap.CentroiderPYR_FF complete with setters. But I have not figured out how to use the setters, they always return 0 and the arrays remain empty. So I guess my question is two-fold: 1) can I manipulate the camera gain to simulate bad pixels this way and 2) how would I use the setters, i.e., what are the expected dimensions of the arrays and what is the second parameter n / nElem ?

a-sevin commented 3 years ago

Hi Host and happy new year, Okay, d_flat and d_dark are not used in the simulation by default. You have to call calibrate_img method of the centroider. I'm sorry for the late answer but we don't have a lot of time to spend on COMPASS.

  1. yes, I think you can use it to simulate bad pixels (small gain and a negative background to fix the value)
  2. I updated the docstring and we will release the version 5.1 in the same time.
        Set the dark frame for calibration

        Parameters
        ------------
        dark: (np.ndarray[ndim=2, dtype=np.float32_t): dark frame (size n by n)
        n: (int): image support size

Stay tuned !

HorstSteuer commented 3 years ago

Thank you so much! I'll give it a go and report!

HorstSteuer commented 3 years ago

Hi Arnaud! I tried to follow your advice, but ran into some problems. For the initialization I added to the supervisor:

self.rtc._rtc.d_centro[0].init_img_raw(wfs_img_shape[0], wfs_img_shape[1]) # do_calibrate_img crashes if not called
self.rtc.set_dark(0, -0.001 * np.ones(wfs_img_shape, dtype=np.float32)) # tried this also with zeros
self.rtc.set_flat(0, 0.1 + 100 * self.bad_pixel_map.multiplicativeFactor) # tried this with different constants

where self.bad_pixel_map.multiplicativeFactor is just a map of ones and zeros defining the dead pixels. Then in next() of the supervisor the following methods are called:

self.wfs.compute_wfs_image(w)
img1 = self.wfs.get_wfs_image(w)
img2 = self.rtc.get_image_raw(0)
img3 = self.rtc.get_image_calibrated(0)
self.rtc.do_calibrate_img(0)
img4 = self.wfs.get_wfs_image(w)
img5 = self.rtc.get_image_raw(0)
img6 = self.rtc.get_image_calibrated(0)

When I plot these images (see attached figure), it appears as if the calibration is done on the empty "raw image" instead of the image computed by the WFS. Am I missing a step here? image_calibration_2