Commit cee66ed7 authored by vertighel's avatar vertighel
Browse files

debug logs

parent 545720b8
Loading
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -229,6 +229,7 @@ class Camera(BaseDevice):
        datetime : str, optional
            UTC ISO-8601 string stored for later FITS header use.
        """
        
        if self._looping:
            log.error("Camera is looping. Stop the loop first.")
            self.error.append("Camera is looping")
@@ -249,11 +250,14 @@ class Camera(BaseDevice):
        str or None
            Absolute path to the saved FITS file, or None on failure.
        """
        
        if filepath is None:
            from ..config.constants import viewer_fits_path
            filepath = viewer_fits_path(getattr(self, '_viewer_key', None))
        h = self._check_connection()
        if not h: return

        log.debug(f"Getting original data")        
        while not self._lib.ArtemisImageReady(h):
            time.sleep(0.1)

@@ -261,6 +265,7 @@ class Camera(BaseDevice):
        self._lib.ArtemisGetImageData(h, ctypes.byref(x), ctypes.byref(y),
                                      ctypes.byref(w), ctypes.byref(h_img),
                                      ctypes.byref(bx), ctypes.byref(by))
        log.debug(f"Got original data")

        buf_ptr = self._lib.ArtemisImageBuffer(h)
        if not buf_ptr:
@@ -269,6 +274,8 @@ class Camera(BaseDevice):
        from pathlib import Path
        from ..config.constants import frame_type as _frame_type
        Path(filepath).parent.mkdir(parents=True, exist_ok=True)

        
        size = w.value * h_img.value
        buffer = (ctypes.c_uint16 * size).from_address(buf_ptr)
        data = np.frombuffer(buffer, dtype=np.uint16).reshape(h_img.value, w.value)
@@ -313,7 +320,9 @@ class Camera(BaseDevice):
        hdr['IMAGETYP'] = (_frame_type.get(ft, str(ft)) if ft is not None else "",
                           "Image type")

        log.debug(f"Writing on disk")
        hdu.writeto(filepath, overwrite=True)
            log.debug(f"Written")
        return filepath

    @property
+10 −0
Original line number Diff line number Diff line
@@ -434,13 +434,20 @@ class Guider(Mako):
        str or None
            Absolute path to the saved FITS file, or None if no image is available.
        """
        
        if filepath is None:
            from ..config.constants import viewer_fits_path
            filepath = viewer_fits_path(getattr(self, '_viewer_key', None))

            
        log.debug(f"Getting original data")
        data = self.matrix
        if data is None:
            return None
        
        Path(filepath).parent.mkdir(parents=True, exist_ok=True)
        log.debug(f"Got original data")
        
        hdu = fits.PrimaryHDU(data)
        hdr = hdu.header
        hdr['INSTRUME'] = (f'Mako GigE {self.id}', 'Camera identifier')
@@ -452,5 +459,8 @@ class Guider(Mako):
        if bx is not None:
            hdr['XBINNING'] = (bx, 'X binning factor')
            hdr['YBINNING'] = (by, 'Y binning factor')
            
        log.debug(f"Writing on disk")
        hdu.writeto(filepath, overwrite=True)
        log.debug(f"Written")
        return filepath
+2 −2
Original line number Diff line number Diff line
@@ -322,9 +322,9 @@ class Camera(STX):

        self._wait_if_needed()

        log.debug(f"Getting original FITS")
        log.debug(f"Getting original data")
        res = requests.get(f"{self.addr}/{self.element}.FIT")
        log.debug(f"Got original FITS")
        log.debug(f"Got original data")

        from pathlib import Path
        Path(filepath).parent.mkdir(parents=True, exist_ok=True)