コード例 #1
0
ファイル: RGBMap.py プロジェクト: Solertis/ginga
    def __init__(self, logger, dist=None):
        Callback.Callbacks.__init__(self)

        self.logger = logger

        # For color and intensity maps
        self.cmap = None
        self.imap = None
        self.arr = None
        self.iarr = None
        self.carr = None
        self.sarr = None
        self.scale_pct = 1.0
        self.maxv = 255
        self.nptype = np.uint8

        # For scaling algorithms
        hashsize = 65536
        if dist is None:
            dist = ColorDist.LinearDist(hashsize)
        self.dist = dist

        self.reset_sarr(callback=False)

        # For callbacks
        for name in ('changed', ):
            self.enable_callback(name)
コード例 #2
0
ファイル: Preferences.py プロジェクト: hcferguson/ginga
    def __init__(self, fv, fitsimage):
        # superclass defines some variables for us, like logger
        super(Preferences, self).__init__(fv, fitsimage)

        self.chname = self.fv.get_channelName(self.fitsimage)

        self.cmap_names = cmap.get_names()
        self.imap_names = imap.get_names()
        self.zoomalg_names = ('step', 'rate')

        self.autocuts_cache = {}
        self.gui_up = False

        self.calg_names = ColorDist.get_dist_names()
        self.autozoom_options = self.fitsimage.get_autozoom_options()
        self.autocut_options = self.fitsimage.get_autocuts_options()
        self.autocut_methods = self.fitsimage.get_autocut_methods()
        self.autocenter_options = self.fitsimage.get_autocenter_options()
        self.pancoord_options = ('data', 'wcs')

        self.t_ = self.fitsimage.get_settings()
        self.t_.getSetting('autocuts').add_callback('set',
                                               self.autocuts_changed_ext_cb)
        self.t_.getSetting('autozoom').add_callback('set',
                                               self.autozoom_changed_ext_cb)
        self.t_.getSetting('autocenter').add_callback('set',
                                                      self.autocenter_changed_ext_cb)
        for key in ['pan']:
            self.t_.getSetting(key).add_callback('set',
                                          self.pan_changed_ext_cb)
        for key in ['scale']:
            self.t_.getSetting(key).add_callback('set',
                                          self.scale_changed_ext_cb)

        self.t_.getSetting('zoom_algorithm').add_callback('set', self.set_zoomalg_ext_cb)
        self.t_.getSetting('zoom_rate').add_callback('set', self.set_zoomrate_ext_cb)
        for key in ['scale_x_base', 'scale_y_base']:
            self.t_.getSetting(key).add_callback('set', self.scalebase_changed_ext_cb)
        self.t_.getSetting('rot_deg').add_callback('set', self.set_rotate_ext_cb)
        for name in ('flip_x', 'flip_y', 'swap_xy'):
            self.t_.getSetting(name).add_callback('set', self.set_transform_ext_cb)

        ## for name in ('autocut_method', 'autocut_params'):
        ##     self.t_.getSetting(name).add_callback('set', self.set_autocuts_ext_cb)

        ## for key in ['color_algorithm', 'color_hashsize', 'color_map',
        ##             'intensity_map']:
        ##     self.t_.getSetting(key).add_callback('set', self.cmap_changed_ext_cb)

        self.t_.setdefault('wcs_coords', 'icrs')
        self.t_.setdefault('wcs_display', 'sexagesimal')

        # buffer len (number of images in memory)
        self.t_.addDefaults(numImages=4)
        self.t_.getSetting('numImages').add_callback('set', self.set_buflen_ext_cb)

        self.icc_profiles = list(io_rgb.get_profiles())
        self.icc_profiles.insert(0, None)
        self.icc_intents = io_rgb.get_intents()
コード例 #3
0
ファイル: Preferences.py プロジェクト: aaronroodman/ginga
    def __init__(self, fv, fitsimage):
        # superclass defines some variables for us, like logger
        super(Preferences, self).__init__(fv, fitsimage)

        self.chname = self.fv.get_channelName(self.fitsimage)

        self.cmap_names = cmap.get_names()
        self.imap_names = imap.get_names()
        self.zoomalg_names = ('step', 'rate')
        
        self.autocuts_cache = {}
        self.gui_up = False

        self.calg_names = ColorDist.get_dist_names()
        self.autozoom_options = self.fitsimage.get_autozoom_options()
        self.autocut_options = self.fitsimage.get_autocuts_options()
        self.autocut_methods = self.fitsimage.get_autocut_methods()

        self.t_ = self.fitsimage.get_settings()
        self.t_.getSetting('autocuts').add_callback('set',
                                               self.autocuts_changed_ext_cb)
        self.t_.getSetting('autozoom').add_callback('set',
                                               self.autozoom_changed_ext_cb)
        for key in ['pan']:
            self.t_.getSetting(key).add_callback('set',
                                          self.pan_changed_ext_cb)
        for key in ['scale']:
            self.t_.getSetting(key).add_callback('set',
                                          self.scale_changed_ext_cb)

        self.t_.getSetting('zoom_algorithm').add_callback('set', self.set_zoomalg_ext_cb)
        self.t_.getSetting('zoom_rate').add_callback('set', self.set_zoomrate_ext_cb)
        for key in ['scale_x_base', 'scale_y_base']:
            self.t_.getSetting(key).add_callback('set', self.scalebase_changed_ext_cb)
        self.t_.getSetting('rot_deg').add_callback('set', self.set_rotate_ext_cb)
        for name in ('flip_x', 'flip_y', 'swap_xy'):
            self.t_.getSetting(name).add_callback('set', self.set_transform_ext_cb)

        for name in ('autocut_method', 'autocut_params'):
            self.t_.getSetting(name).add_callback('set', self.set_autocuts_ext_cb)

        ## for key in ['color_algorithm', 'color_hashsize', 'color_map',
        ##             'intensity_map']:
        ##     self.t_.getSetting(key).add_callback('set', self.cmap_changed_ext_cb)
            
        self.t_.setdefault('wcs_coords', 'icrs')
        self.t_.setdefault('wcs_display', 'sexagesimal')
コード例 #4
0
ファイル: RGBMap.py プロジェクト: godber/ginga
    def __init__(self, logger, dist=None):
        Callback.Callbacks.__init__(self)

        self.logger = logger

        # For color and intensity maps
        self.cmap = None
        self.imap = None
        self.arr = None
        self.iarr = None
        self.carr = None
        self.sarr = None

        # For scaling algorithms
        hashsize = 65536
        if dist == None:
            dist = ColorDist.LinearDist(hashsize)
        self.dist = dist

        # For callbacks
        for name in ('changed', ):
            self.enable_callback(name)
コード例 #5
0
    def __init__(self, logger, dist=None, bpp=None):
        Callback.Callbacks.__init__(self)

        self.logger = logger

        # For color and intensity maps
        self.cmap = None
        self.imap = None
        self.arr = None
        self.iarr = None
        self.carr = None
        self.sarr = None
        self.scale_pct = 1.0
        # length of the color map
        self.maxc = 255

        # targeted bit depth per-pixel band of the output RGB array
        # (can be less than the data size of the output array)
        if bpp is None:
            bpp = 8
        self.bpp = bpp
        # maximum value that we can generate in this range
        self.maxv = 2 ** self.bpp - 1
        # data size per pixel band in the output RGB array
        self._set_dtype()

        # For scaling algorithms
        hashsize = 65536
        if dist is None:
            dist = ColorDist.LinearDist(hashsize)
        self.dist = dist

        self.reset_sarr(callback=False)

        # For callbacks
        for name in ('changed', ):
            self.enable_callback(name)
コード例 #6
0
    def __init__(self, logger, dist=None):
        super(PassThruRGBMapper, self).__init__(logger)

        # ignore passed in distribution
        self.dist = ColorDist.LinearDist(256)
コード例 #7
0
 def set_hash_algorithm(self, name, callback=True, **kwdargs):
     hashsize = self.dist.get_hash_size()
     dist = ColorDist.get_dist(name)(hashsize, **kwdargs)
     self.set_dist(dist, callback=callback)
コード例 #8
0
 def get_hash_algorithms(self):
     return ColorDist.get_dist_names()
コード例 #9
0
ファイル: RGBMap.py プロジェクト: danny-cohen/ginga
    def __init__(self, logger, dist=None, settings=None, bpp=None):
        Callback.Callbacks.__init__(self)

        self.logger = logger

        # Create settings and set defaults
        if settings is None:
            settings = Settings.SettingGroup(logger=self.logger)
        self.settings = settings
        self.t_ = settings
        self.settings_keys = ['color_map', 'intensity_map',
                              'color_array', 'shift_array',
                              'color_algorithm', 'color_hashsize',
                              ]

        # add our defaults
        self.t_.add_defaults(color_map='gray', intensity_map='ramp',
                             color_algorithm='linear',
                             color_hashsize=65535,
                             color_array=None, shift_array=None)
        self.t_.get_setting('color_map').add_callback('set',
                                                      self.color_map_set_cb)
        self.t_.get_setting('intensity_map').add_callback('set',
                                                          self.intensity_map_set_cb)
        self.t_.get_setting('color_array').add_callback('set',
                                                        self.color_array_set_cb)
        self.t_.get_setting('shift_array').add_callback('set',
                                                        self.shift_array_set_cb)
        self.t_.get_setting('color_hashsize').add_callback('set',
                                                           self.color_hashsize_set_cb)
        self.t_.get_setting('color_algorithm').add_callback('set',
                                                            self.color_algorithm_set_cb)

        # For color and intensity maps
        self.cmap = None
        self.imap = None
        self.arr = None
        self.iarr = None
        self.carr = None
        self.sarr = None
        self.scale_pct = 1.0

        # targeted bit depth per-pixel band of the output RGB array
        # (can be less than the data size of the output array)
        if bpp is None:
            bpp = 8
        self.bpp = bpp
        # maximum value that we can generate in this range
        self.maxc = int(2 ** self.bpp - 1)
        # data size per pixel band in the output RGB array
        self._set_dtype()

        # For scaling algorithms
        hashsize = self.t_.get('color_hashsize', 65536)
        if dist is None:
            color_alg_name = self.t_.get('color_algorithm', 'linear')
            color_dist_class = ColorDist.get_dist(color_alg_name)
            dist = color_dist_class(hashsize)
        self.dist = dist

        # For callbacks
        for name in ('changed', ):
            self.enable_callback(name)

        self.suppress_changed = self.suppress_callback('changed', 'last')

        carr = self.t_.get('color_array', None)
        sarr = self.t_.get('shift_array', None)

        cm_name = self.t_.get('color_map', 'gray')
        self.set_color_map(cm_name)

        im_name = self.t_.get('intensity_map', 'ramp')
        self.set_intensity_map(im_name)

        # Initialize color array
        if carr is not None:
            self.set_carr(carr)
        else:
            self.calc_cmap()

        # Initialize shift array
        if sarr is not None:
            self.set_sarr(sarr)
        else:
            self.reset_sarr(callback=False)
コード例 #10
0
ファイル: RGBMap.py プロジェクト: danny-cohen/ginga
    def __init__(self, logger, dist=None, bpp=None):
        super(PassThruRGBMapper, self).__init__(logger, bpp=bpp)

        # ignore passed in distribution
        maxlen = self.maxc + 1
        self.dist = ColorDist.LinearDist(maxlen)
コード例 #11
0
ファイル: RGBMap.py プロジェクト: danny-cohen/ginga
 def color_algorithm_set_cb(self, setting, name):
     size = self.t_.get('color_hashsize', self.dist.get_hash_size())
     dist = ColorDist.get_dist(name)(size)
     self.set_dist(dist, callback=True)
コード例 #12
0
 def test_dist_function(self, dist_name):
     dist = cd.get_dist(dist_name)(self.hashsize, colorlen=self.colorlen)
     y = dist.hash_array(self.data)
     expected_y = self.scale_and_rescale(dist_name, self.data)
     np.testing.assert_allclose(y, expected_y)
コード例 #13
0
ファイル: Preferences.py プロジェクト: zhouyaoji/ginga
    def __init__(self, fv, fitsimage):
        # superclass defines some variables for us, like logger
        super(Preferences, self).__init__(fv, fitsimage)

        self.cmap_names = cmap.get_names()
        self.imap_names = imap.get_names()
        self.zoomalg_names = ('step', 'rate')

        self.autocuts_cache = {}
        self.gui_up = False

        self.calg_names = ColorDist.get_dist_names()
        self.autozoom_options = self.fitsimage.get_autozoom_options()
        self.autocut_options = self.fitsimage.get_autocuts_options()
        self.autocut_methods = self.fitsimage.get_autocut_methods()
        self.autocenter_options = self.fitsimage.get_autocenter_options()
        self.pancoord_options = ('data', 'wcs')
        self.sort_options = ('loadtime', 'alpha')

        self.t_ = self.fitsimage.get_settings()
        self.t_.get_setting('autocuts').add_callback(
            'set', self.autocuts_changed_ext_cb)
        self.t_.get_setting('autozoom').add_callback(
            'set', self.autozoom_changed_ext_cb)
        self.t_.get_setting('autocenter').add_callback(
            'set', self.autocenter_changed_ext_cb)
        for key in ['pan']:
            self.t_.get_setting(key).add_callback('set',
                                                  self.pan_changed_ext_cb)
        for key in ['scale']:
            self.t_.get_setting(key).add_callback('set',
                                                  self.scale_changed_ext_cb)

        self.t_.get_setting('zoom_algorithm').add_callback(
            'set', self.set_zoomalg_ext_cb)
        self.t_.get_setting('zoom_rate').add_callback('set',
                                                      self.set_zoomrate_ext_cb)
        for key in ['scale_x_base', 'scale_y_base']:
            self.t_.get_setting(key).add_callback(
                'set', self.scalebase_changed_ext_cb)
        self.t_.get_setting('rot_deg').add_callback('set',
                                                    self.set_rotate_ext_cb)
        for name in ('flip_x', 'flip_y', 'swap_xy'):
            self.t_.get_setting(name).add_callback('set',
                                                   self.set_transform_ext_cb)

        ## for name in ('autocut_method', 'autocut_params'):
        ##     self.t_.get_setting(name).add_callback('set', self.set_autocuts_ext_cb)

        ## for key in ['color_algorithm', 'color_hashsize', 'color_map',
        ##             'intensity_map']:
        ##     self.t_.get_setting(key).add_callback('set', self.cmap_changed_ext_cb)

        self.t_.setdefault('wcs_coords', 'icrs')
        self.t_.setdefault('wcs_display', 'sexagesimal')

        # buffer len (number of images in memory)
        self.t_.add_defaults(numImages=4)
        self.t_.get_setting('numImages').add_callback('set',
                                                      self.set_buflen_ext_cb)

        # preload images
        self.t_.add_defaults(preload_images=False)

        self.icc_profiles = list(rgb_cms.get_profiles())
        self.icc_profiles.insert(0, None)
        self.icc_intents = rgb_cms.get_intents()
コード例 #14
0
 def test_dist_function(self, dist_name):
     dist = cd.get_dist(dist_name)(self.hashsize, colorlen=self.colorlen)
     y = dist.hash_array(self.data)
     expected_y = self.scale_and_rescale(dist_name, self.data)
     np.testing.assert_allclose(y, expected_y)
コード例 #15
0
ファイル: RGBMap.py プロジェクト: ejeschke/ginga
    def __init__(self, logger, dist=None, settings=None, bpp=None):
        Callback.Callbacks.__init__(self)

        self.logger = logger

        # Create settings and set defaults
        if settings is None:
            settings = Settings.SettingGroup(logger=self.logger)
        self.settings = settings
        self.t_ = settings
        self.settings_keys = ['color_map', 'intensity_map',
                              'color_array', 'shift_array',
                              'color_algorithm', 'color_hashsize',
                              ]

        # add our defaults
        self.t_.add_defaults(color_map='gray', intensity_map='ramp',
                             color_algorithm='linear',
                             color_hashsize=65535,
                             color_array=None, shift_array=None)
        self.t_.get_setting('color_map').add_callback('set',
                                                      self.color_map_set_cb)
        self.t_.get_setting('intensity_map').add_callback('set',
                                                          self.intensity_map_set_cb)
        self.t_.get_setting('color_array').add_callback('set',
                                                        self.color_array_set_cb)
        self.t_.get_setting('shift_array').add_callback('set',
                                                        self.shift_array_set_cb)
        self.t_.get_setting('color_hashsize').add_callback('set',
                                                           self.color_hashsize_set_cb)
        self.t_.get_setting('color_algorithm').add_callback('set',
                                                            self.color_algorithm_set_cb)

        # For color and intensity maps
        self.cmap = None
        self.imap = None
        self.arr = None
        self.iarr = None
        self.carr = None
        self.sarr = None
        self.scale_pct = 1.0

        # targeted bit depth per-pixel band of the output RGB array
        # (can be less than the data size of the output array)
        if bpp is None:
            bpp = 8
        self.bpp = bpp
        # maximum value that we can generate in this range
        self.maxc = 2 ** self.bpp - 1
        # data size per pixel band in the output RGB array
        self._set_dtype()

        # For scaling algorithms
        hashsize = self.t_.get('color_hashsize', 65536)
        if dist is None:
            color_alg_name = self.t_.get('color_algorithm', 'linear')
            color_dist_class = ColorDist.get_dist(color_alg_name)
            dist = color_dist_class(hashsize)
        self.dist = dist

        # For callbacks
        for name in ('changed', ):
            self.enable_callback(name)

        self.suppress_changed = self.suppress_callback('changed', 'last')

        carr = self.t_.get('color_array', None)
        sarr = self.t_.get('shift_array', None)

        cm_name = self.t_.get('color_map', 'gray')
        self.set_color_map(cm_name)

        im_name = self.t_.get('intensity_map', 'ramp')
        self.set_intensity_map(im_name)

        # Initialize color array
        if carr is not None:
            self.set_carr(carr)
        else:
            self.calc_cmap()

        # Initialize shift array
        if sarr is not None:
            self.set_sarr(sarr)
        else:
            self.reset_sarr(callback=False)
コード例 #16
0
ファイル: RGBMap.py プロジェクト: ejeschke/ginga
 def color_algorithm_set_cb(self, setting, name):
     size = self.t_.get('color_hashsize', self.dist.get_hash_size())
     dist = ColorDist.get_dist(name)(size)
     self.set_dist(dist, callback=True)