

def prepare_mosaic(self, image, fov_deg, name=None):
    'Prepare a new (blank) mosaic image based on the pointing of\n        the parameter image\n        '
    header = image.get_header()
    (ra_deg, dec_deg) = (header['CRVAL1'], header['CRVAL2'])
    data_np = image.get_data()
    dtype = None
    self.bg_ref = iqcalc.get_median(data_np)
    skew_limit = self.settings.get('skew_limit', 0.1)
    (rot_deg, cdelt1, cdelt2) = wcs.get_rotation_and_scale(header, skew_threshold=skew_limit)
    self.logger.debug(('image0 rot=%f cdelt1=%f cdelt2=%f' % (rot_deg, cdelt1, cdelt2)))
    px_scale = math.fabs(cdelt1)
    cdbase = [numpy.sign(cdelt1), numpy.sign(cdelt2)]
    reuse_image = self.settings.get('reuse_image', False)
    if ((not reuse_image) or (self.img_mosaic is None)):
        self.logger.debug('creating blank image to hold mosaic')
        self.fv.gui_do(self._prepare_mosaic1, 'Creating blank image...')
        self.img_mosaic = None
        img_mosaic = dp.create_blank_image(ra_deg, dec_deg, fov_deg, px_scale, rot_deg, cdbase=cdbase, logger=self.logger, pfx='mosaic', dtype=dtype)
        if (name is not None):
            img_mosaic.set(name=name)
        imname = img_mosaic.get('name', image.get('name', 'NoName'))
        nothumb = (not self.settings.get('make_thumbs', False))
        if nothumb:
            img_mosaic.set(nothumb=True)
        else:
            img_mosaic.set(path=None)
        self.img_mosaic = img_mosaic
        self.fv.gui_call(self.fv.add_image, imname, img_mosaic, chname=self.mosaic_chname)
    else:
        self.logger.debug('Reusing previous mosaic image')
        self.fv.gui_do(self._prepare_mosaic1, 'Reusing previous mosaic image...')
        img_mosaic = dp.recycle_image(self.img_mosaic, ra_deg, dec_deg, fov_deg, px_scale, rot_deg, cdbase=cdbase, logger=self.logger, pfx='mosaic')
    header = img_mosaic.get_header()
    (rot, cdelt1, cdelt2) = wcs.get_rotation_and_scale(header, skew_threshold=skew_limit)
    self.logger.debug(('mosaic rot=%f cdelt1=%f cdelt2=%f' % (rot, cdelt1, cdelt2)))
    return img_mosaic

dataset/ETHPy150Open ejeschke/ginga/ginga/misc/plugins/Mosaic.py Mosaic.prepare_mosaic/original