Exemplo n.º 1
0
    def test_create (self):

        img = Image.create(N.zeros((100,100)), filename="autogen-teste.fits")
        assert os.path.exists(img.filename())
        assert img.width() == 100
        assert img.height() == 100

        os.unlink(img.filename())
Exemplo n.º 2
0
    def test_create (self):

        img = Image.create(N.zeros((100,100)), filename="autogen-teste.fits")
        assert os.path.exists(img.filename())
        assert img.width() == 100
        assert img.height() == 100

        os.unlink(img.filename())
Exemplo n.º 3
0
    def _saveImage(self, imageRequest, imageData, extra):

        (mode, binning, top, left, width,
         height) = self._getReadoutModeInfo(imageRequest["binning"],
                                            imageRequest["window"])

        binFactor = extra.get("binning_factor", 1.0)

        pix_w, pix_h = self.getPixelSize()
        focal_length = self["telescope_focal_length"]

        scale_x = binFactor * (((180 / pi) / focal_length) * (pix_w * 0.001))
        scale_y = binFactor * (((180 / pi) / focal_length) * (pix_h * 0.001))

        full_width, full_height = self.getPhysicalSize()
        CRPIX1 = ((int(full_width / 2.0)) - left) - 1
        CRPIX2 = ((int(full_height / 2.0)) - top) - 1

        t0 = time.time()
        img = Image.create(imageData, imageRequest)

        img += [
            ('DATE-OBS',
             ImageUtil.formatDate(
                 extra.get("frame_start_time",
                           dt.datetime.utcnow())), 'Date exposure started'),
            ('CCD-TEMP', extra.get("frame_temperature", -275.0),
             'CCD Temperature at Exposure Start [deg. C]'),
            ("EXPTIME", float(imageRequest['exptime'])
             or -1, "exposure time in seconds"),
            ('IMAGETYP', imageRequest['type'].strip(), 'Image type'),
            ('SHUTTER', str(imageRequest['shutter']),
             'Requested shutter state'),
            ("CRPIX1", CRPIX1, "coordinate system reference pixel"),
            ("CRPIX2", CRPIX2, "coordinate system reference pixel"),
            ("CD1_1", scale_x, "transformation matrix element (1,1)"),
            ("CD1_2", 0.0, "transformation matrix element (1,2)"),
            ("CD2_1", 0.0, "transformation matrix element (2,1)"),
            ("CD2_2", scale_y, "transformation matrix element (2,2)"),
            ('CAMERA', str(self['camera_model']), 'Camera Model'),
            ('CCD', str(self['ccd_model']), 'CCD Model'),
            ('CCD_DIMX', self.getPhysicalSize()[0], 'CCD X Dimension Size'),
            ('CCD_DIMY', self.getPhysicalSize()[1], 'CCD Y Dimension Size'),
            ('CCDPXSZX', self.getPixelSize()[0],
             'CCD X Pixel Size [micrometer]'),
            ('CCDPXSZY', self.getPixelSize()[1],
             'CCD Y Pixel Size [micrometer]')
        ]

        # register image on ImageServer
        server = getImageServer(self.getManager())
        proxy = server.register(img)

        # and finally compress the image
        img.compress(multiprocess=True)

        return proxy
    def _saveImage(self, imageRequest, imageData, extra):

        (mode, binning, top, left, width, height) = self._getReadoutModeInfo(
            imageRequest["binning"], imageRequest["window"]
        )

        binFactor = extra.get("binning_factor", 1.0)

        pix_w, pix_h = self.getPixelSize()
        focal_length = self["telescope_focal_length"]

        scale_x = binFactor * (((180 / pi) / focal_length) * (pix_w * 0.001))
        scale_y = binFactor * (((180 / pi) / focal_length) * (pix_h * 0.001))

        full_width, full_height = self.getPhysicalSize()
        CRPIX1 = ((int(full_width / 2.0)) - left) - 1
        CRPIX2 = ((int(full_height / 2.0)) - top) - 1

        t0 = time.time()
        img = Image.create(imageData, imageRequest)

        img += [
            (
                "DATE-OBS",
                ImageUtil.formatDate(extra.get("frame_start_time", dt.datetime.utcnow())),
                "Date exposure started",
            ),
            ("CCD-TEMP", extra.get("frame_temperature", -275.0), "CCD Temperature at Exposure Start [deg. C]"),
            ("EXPTIME", float(imageRequest["exptime"]) or -1, "exposure time in seconds"),
            ("IMAGETYP", imageRequest["type"].strip(), "Image type"),
            ("SHUTTER", str(imageRequest["shutter"]), "Requested shutter state"),
            ("CRPIX1", CRPIX1, "coordinate system reference pixel"),
            ("CRPIX2", CRPIX2, "coordinate system reference pixel"),
            ("CD1_1", scale_x, "transformation matrix element (1,1)"),
            ("CD1_2", 0.0, "transformation matrix element (1,2)"),
            ("CD2_1", 0.0, "transformation matrix element (2,1)"),
            ("CD2_2", scale_y, "transformation matrix element (2,2)"),
            ("CAMERA", str(self["camera_model"]), "Camera Model"),
            ("CCD", str(self["ccd_model"]), "CCD Model"),
            ("CCD_DIMX", self.getPhysicalSize()[0], "CCD X Dimension Size"),
            ("CCD_DIMY", self.getPhysicalSize()[1], "CCD Y Dimension Size"),
            ("CCDPXSZX", self.getPixelSize()[0], "CCD X Pixel Size [micrometer]"),
            ("CCDPXSZY", self.getPixelSize()[1], "CCD Y Pixel Size [micrometer]"),
        ]

        # register image on ImageServer
        server = getImageServer(self.getManager())
        proxy = server.register(img)

        # and finally compress the image
        img.compress(multiprocess=True)

        return proxy
Exemplo n.º 5
0
    def _saveImage(self, imageRequest, imageData, extras=None):

        if extras is not None:
            self.extra_header_info = extras

        imageRequest.headers += self.getMetadata(imageRequest)
        img = Image.create(imageData, imageRequest)

        # register image on ImageServer
        server = getImageServer(self.getManager())
        proxy = server.register(img)

        # and finally compress the image if asked
        if imageRequest['compress_format'].lower() != 'no':
            img.compress(format=imageRequest['compress_format'], multiprocess=True)

        return proxy
Exemplo n.º 6
0
    def test_create (self):

        img = Image.create(N.zeros((100,100)), filename="autogen-teste.fits")
        print img.width, img.height
Exemplo n.º 7
0
            pass  # will never happen!

        imageRequest.addPostHeaders(self.getManager())

        binFactor = self._binning_factors[binning]
        scale_x = binFactor * (((180 / pi) / cam["telescope_focal_length"]) *
                               (self.getPixelSize()[0] * 0.001))
        scale_y = binFactor * (((180 / pi) / cam["telescope_focal_length"]) *
                               (self.getPixelSize()[1] * 0.001))

        fullsize = self.drv.readoutModes[self.ccd][0]

        CRPIX1 = ((int(fullsize.width / 2)) - left) - 1
        CRPIX2 = ((int(fullsize.height / 2)) - top) - 1

        img = Image.create(img, imageRequest)

        img += [('DATE-OBS', ImageUtil.formatDate(self.lastFrameStartTime),
                 'Date exposure started'),
                ('CCD-TEMP', self.lastFrameTemp,
                 'CCD Temperature at Exposure Start [deg. C]'),
                ("EXPTIME", float(imageRequest['exptime'])
                 or -1, "exposure time in seconds"),
                ('IMAGETYP', imageRequest['type'].strip(), 'Image type'),
                ('SHUTTER', str(imageRequest['shutter']),
                 'Requested shutter state'),
                ("CRPIX1", CRPIX1, "coordinate system reference pixel"),
                ("CRPIX2", CRPIX2, "coordinate system reference pixel"),
                ("CD1_1", scale_x, "transformation matrix element (1,1)"),
                ("CD1_2", 0.0, "transformation matrix element (1,2)"),
                ("CD2_1", 0.0, "transformation matrix element (2,1)"),
Exemplo n.º 8
0
                    pix = self.make_dark(
                        (self["ccd_height"], self["ccd_width"]), N.float,
                        imageRequest['exptime'])
                    self.log.debug("Making flat...")
                    pix += self.make_flat(
                        (self["ccd_height"], self["ccd_width"]), N.float)
                except Exception, e:
                    self.log.warning("MakekFlat error: " + str(e))

        #Last resort if nothing else could make a picture
        if (pix == None):
            pix = N.zeros((100, 100), dtype=N.int32)

        imageRequest.fetchPostHeaders(self.getManager())

        img = Image.create(pix, imageRequest)

        # update image request
        imageRequest["filename"] = img.filename()

        img += [('DATE-OBS',
                 ImageUtil.formatDate(
                     dt.datetime.fromtimestamp(self.__lastFrameStart)))]

        server = getImageServer(self.getManager())
        proxy = server.register(img)

        self.readoutComplete(proxy)

        return proxy
Exemplo n.º 9
0
    def test_create(self):

        img = Image.create(N.zeros((100, 100)), filename="autogen-teste.fits")
        print img.width, img.height
Exemplo n.º 10
0
    def _saveImage(self, imageRequest, imageData, extra):

        (mode, binning, top, left,
         width, height) = self._getReadoutModeInfo(imageRequest["binning"],
                                                   imageRequest["window"])

        binFactor = extra.get("binning_factor", 1.0)

        pix_w, pix_h = self.getPixelSize()

        img = Image.create(imageData, imageRequest)

        if self["telescope_focal_length"] is not None:  # If there is no telescope_focal_length defined, don't store WCS
            focal_length = self["telescope_focal_length"]

            scale_x = binFactor * (((180 / pi) / focal_length) * (pix_w * 0.001))
            scale_y = binFactor * (((180 / pi) / focal_length) * (pix_h * 0.001))

            full_width, full_height = self.getPhysicalSize()
            CRPIX1 = ((int(full_width / 2.0)) - left) - 1
            CRPIX2 = ((int(full_height / 2.0)) - top) - 1

            # Adding WCS coordinates according to FITS standard.
            # Quick sheet: http://www.astro.iag.usp.br/~moser/notes/GAi_FITSimgs.html
            # http://adsabs.harvard.edu/abs/2002A%26A...395.1061G
            # http://adsabs.harvard.edu/abs/2002A%26A...395.1077C
            img += [("CRPIX1", CRPIX1, "coordinate system reference pixel"),
                ("CRPIX2", CRPIX2, "coordinate system reference pixel"),
                ("CD1_1",  scale_x * cos(self["rotation"]*pi/180.), "transformation matrix element (1,1)"),
                ("CD1_2", -scale_y * sin(self["rotation"]*pi/180.), "transformation matrix element (1,2)"),
                ("CD2_1", scale_x * sin(self["rotation"]*pi/180.), "transformation matrix element (2,1)"),
                ("CD2_2", scale_y * cos(self["rotation"]*pi/180.), "transformation matrix element (2,2)")]

        img += [('DATE-OBS',
                 ImageUtil.formatDate(
                     extra.get("frame_start_time", dt.datetime.utcnow())),
                 'Date exposure started'),

                ('CCD-TEMP', extra.get("frame_temperature", -275.0),
                 'CCD Temperature at Exposure Start [deg. C]'),

                ("EXPTIME", float(imageRequest['exptime']) or -1,
                 "exposure time in seconds"),

                ('IMAGETYP', imageRequest['type'].strip(),
                 'Image type'),

                ('SHUTTER', str(imageRequest['shutter']),
                 'Requested shutter state'),

                ('INSTRUME', str(self['camera_model']), 'Name of instrument'),
                ('CCD',    str(self['ccd_model']), 'CCD Model'),
                ('CCD_DIMX', self.getPhysicalSize()
                 [0], 'CCD X Dimension Size'),
                ('CCD_DIMY', self.getPhysicalSize()
                 [1], 'CCD Y Dimension Size'),
                ('CCDPXSZX', self.getPixelSize()[0],
                 'CCD X Pixel Size [micrometer]'),
                ('CCDPXSZY', self.getPixelSize()[1],
                 'CCD Y Pixel Size [micrometer]')]

        # register image on ImageServer
        server = getImageServer(self.getManager())
        proxy = server.register(img)

        # and finally compress the image if asked
        if imageRequest['compress_format'].lower() != 'no':
            img.compress(format=imageRequest['compress_format'], multiprocess=True)

        return proxy