def __init__(self, h5path='/', overwrite_data=False, link_type="hard", create_dataset_args=None): deprecation.deprecated_warning( type_="Class", name="SpecToHdf5Writer", since_version="0.6", replacement="silx.io.convert.Hdf5Writer") Hdf5Writer.__init__(self, h5path, overwrite_data, link_type, create_dataset_args)
def __init__(self, parent=None, plot=None, title=None): super(ScatterProfileToolBar, self).__init__(parent, plot) if title is not None: deprecation.deprecated_warning("Attribute", name="title", reason="removed", since_version="0.13.0", only_once=True, skip_backtrace_count=1) self.setScheme("scatter")
def __init__(self, parent=None, plot=None, profileWindow=None, title=None): super(ProfileToolBar, self).__init__(title, parent) assert plot is not None if title is not None: deprecated_warning("Attribute", name="title", reason="removed", since_version="0.13.0", only_once=True, skip_backtrace_count=1) self._plotRef = weakref.ref(plot) # If a profileWindow is defined, # It will be used to display all the profiles self._manager = _CustomProfileManager(self, plot) self._manager.setProfileWindow(profileWindow) self._manager.setDefaultColorFromCursorColor(True) self._manager.setItemType(image=True) self._manager.setActiveItemTracking(True) # Actions self._browseAction = actions.mode.ZoomModeAction(plot, parent=self) self._browseAction.setVisible(False) self.freeLineAction = None self._createProfileActions() self._editor = self._manager.createEditorAction(self) # ActionGroup self.actionGroup = qt.QActionGroup(self) self.actionGroup.addAction(self._browseAction) self.actionGroup.addAction(self.hLineAction) self.actionGroup.addAction(self.vLineAction) self.actionGroup.addAction(self.lineAction) self.actionGroup.addAction(self._editor) modes = MultiModeAction(self) modes.addAction(self.hLineAction) modes.addAction(self.vLineAction) modes.addAction(self.lineAction) if self.freeLineAction is not None: modes.addAction(self.freeLineAction) modes.addAction(self.crossAction) self.__multiAction = modes # Add actions to ToolBar self.addAction(self._browseAction) self.addAction(modes) self.addAction(self._editor) self.addAction(self.clearAction) plot.sigActiveImageChanged.connect(self._activeImageChanged) self._activeImageChanged()
def __init__(self, name=None, colors=None, normalization=LINEAR, vmin=None, vmax=None, autoscaleMode=MINMAX): qt.QObject.__init__(self) self._editable = True self.__gamma = 2.0 # Default NaN color: fully transparent white self.__nanColor = numpy.array(self._DEFAULT_NAN_COLOR, dtype=numpy.uint8) assert normalization in Colormap.NORMALIZATIONS assert autoscaleMode in Colormap.AUTOSCALE_MODES if normalization is Colormap.LOGARITHM: if (vmin is not None and vmin < 0) or (vmax is not None and vmax < 0): m = "Unsuported vmin (%s) and/or vmax (%s) given for a log scale." m += ' Autoscale will be performed.' m = m % (vmin, vmax) _logger.warning(m) vmin = None vmax = None self._name = None self._colors = None if colors is not None and name is not None: deprecation.deprecated_warning( "Argument", name="silx.gui.plot.Colors", reason="name and colors can't be used at the same time", since_version="0.10.0", skip_backtrace_count=1) colors = None if name is not None: self.setName(name) # And resets colormap LUT elif colors is not None: self.setColormapLUT(colors) else: # Default colormap is grey self.setName("gray") self._normalization = str(normalization) self._autoscaleMode = str(autoscaleMode) self._vmin = float(vmin) if vmin is not None else None self._vmax = float(vmax) if vmax is not None else None self.__warnBadVmin = True self.__warnBadVmax = True
def __init__(self, h5path='/', overwrite_data=False, link_type="hard", create_dataset_args=None): deprecation.deprecated_warning( type_="Class", name="SpecToHdf5Writer", since_version="0.6", replacement="silx.io.convert.Hdf5Writer") Hdf5Writer.__init__(self, h5path, overwrite_data, link_type, create_dataset_args)
def __init__(self, name=None, colors=None, normalization=LINEAR, vmin=None, vmax=None): qt.QObject.__init__(self) self._editable = True assert normalization in Colormap.NORMALIZATIONS if normalization is Colormap.LOGARITHM: if (vmin is not None and vmin < 0) or (vmax is not None and vmax < 0): m = "Unsuported vmin (%s) and/or vmax (%s) given for a log scale." m += ' Autoscale will be performed.' m = m % (vmin, vmax) _logger.warning(m) vmin = None vmax = None self._name = None self._colors = None if colors is not None and name is not None: deprecation.deprecated_warning( "Argument", name="silx.gui.plot.Colors", reason="name and colors can't be used at the same time", since_version="0.10.0", skip_backtrace_count=1) colors = None if name is not None: self.setName(name) # And resets colormap LUT elif colors is not None: self.setColormapLUT(colors) else: # Default colormap is grey self.setName("gray") self._normalization = str(normalization) self._vmin = float(vmin) if vmin is not None else None self._vmax = float(vmax) if vmax is not None else None
def __init__(self, parent=None, stackview=None, title=None): """QToolBar providing profile tools for an image or a stack of images. :param parent: the parent QWidget :param stackview: :class:`StackView` instance on which to operate. :param str title: See :class:`QToolBar`. :param parent: See :class:`QToolBar`. """ # TODO: add param profileWindow (specify the plot used for profiles) super(Profile3DToolBar, self).__init__(parent=parent, plot=stackview.getPlotWidget()) if title is not None: deprecated_warning("Attribute", name="title", reason="removed", since_version="0.13.0", only_once=True, skip_backtrace_count=1) self.stackView = stackview """:class:`StackView` instance"""
def __init__(self, name=None, colors=None, normalization=LINEAR, vmin=None, vmax=None): qt.QObject.__init__(self) self._editable = True assert normalization in Colormap.NORMALIZATIONS if normalization is Colormap.LOGARITHM: if (vmin is not None and vmin < 0) or (vmax is not None and vmax < 0): m = "Unsuported vmin (%s) and/or vmax (%s) given for a log scale." m += ' Autoscale will be performed.' m = m % (vmin, vmax) _logger.warning(m) vmin = None vmax = None self._name = None self._colors = None if colors is not None and name is not None: deprecation.deprecated_warning("Argument", name="silx.gui.plot.Colors", reason="name and colors can't be used at the same time", since_version="0.10.0", skip_backtrace_count=1) colors = None if name is not None: self.setName(name) # And resets colormap LUT elif colors is not None: self.setColormapLUT(colors) else: # Default colormap is grey self.setName("gray") self._normalization = str(normalization) self._vmin = float(vmin) if vmin is not None else None self._vmax = float(vmax) if vmax is not None else None
def __init__( self, filename, mode=None, locking=None, enable_file_locking=None, swmr=None, libver=None, **kwargs, ): r"""The arguments `locking` and `swmr` should not be specified explicitly for normal use cases. :param str filename: :param str or None mode: read-only by default :param bool or None locking: by default it is disabled for `mode='r'` and `swmr=False` and enabled for all other modes. :param bool or None enable_file_locking: deprecated :param bool or None swmr: try both modes when `mode='r'` and `swmr=None` :param None or str or tuple libver: :param \**kwargs: see `h5py.File.__init__` """ # File locking behavior has changed in recent versions of libhdf5 if HDF5_HAS_LOCKING_ARGUMENT != H5PY_HAS_LOCKING_ARGUMENT: _logger.critical( "The version of libhdf5 ({}) used by h5py ({}) is not supported: " "Do not expect file locking to work.".format( h5py.version.hdf5_version, h5py.version.version)) if mode is None: mode = "r" elif mode not in ("r", "w", "w-", "x", "a", "r+"): raise ValueError("invalid mode {}".format(mode)) if not HAS_SWMR: swmr = False if swmr and libver is None: libver = self._SWMR_LIBVER if enable_file_locking is not None: deprecated_warning( type_="argument", name="enable_file_locking", replacement="locking", since_version="1.0", ) if locking is None: locking = enable_file_locking locking = _hdf5_file_locking(mode=mode, locking=locking, swmr=swmr, libver=libver) if self._LOCKING_MGR is None: kwargs.setdefault("locking", locking) else: self._LOCKING_MGR.set_locking(locking) if HAS_TRACK_ORDER: kwargs.setdefault("track_order", True) try: super().__init__(filename, mode=mode, swmr=swmr, libver=libver, **kwargs) except OSError as e: # wlock wSWMR rlock rSWMR OSError: Unable to open file (...) # 1 TRUE FALSE FALSE FALSE - # 2 TRUE FALSE FALSE TRUE - # 3 TRUE FALSE TRUE FALSE unable to lock file, errno = 11, error message = 'Resource temporarily unavailable' # 4 TRUE FALSE TRUE TRUE unable to lock file, errno = 11, error message = 'Resource temporarily unavailable' # 5 TRUE TRUE FALSE FALSE file is already open for write (may use <h5clear file> to clear file consistency flags) # 6 TRUE TRUE FALSE TRUE - # 7 TRUE TRUE TRUE FALSE file is already open for write (may use <h5clear file> to clear file consistency flags) # 8 TRUE TRUE TRUE TRUE - if (mode == "r" and swmr is None and "file is already open for write" in str(e)): # Try reading in SWMR mode (situation 5 and 7) swmr = True if libver is None: libver = self._SWMR_LIBVER super().__init__(filename, mode=mode, swmr=swmr, libver=libver, **kwargs) else: raise else: self._file_open_callback() try: if mode != "r" and swmr: # Try setting writer in SWMR mode self.swmr_mode = True except Exception: self.close() raise
def dicttoh5(treedict, h5file, h5path='/', mode="w", overwrite_data=None, create_dataset_args=None, update_mode=None): """Write a nested dictionary to a HDF5 file, using keys as member names. If a dictionary value is a sub-dictionary, a group is created. If it is any other data type, it is cast into a numpy array and written as a :mod:`h5py` dataset. Dictionary keys must be strings and cannot contain the ``/`` character. If dictionary keys are tuples they are interpreted to set h5 attributes. The tuples should have the format (dataset_name, attr_name). Existing HDF5 items can be deleted by providing the dictionary value ``None``, provided that ``update_mode in ["modify", "replace"]``. .. note:: This function requires `h5py <http://www.h5py.org/>`_ to be installed. :param treedict: Nested dictionary/tree structure with strings or tuples as keys and array-like objects as leafs. The ``"/"`` character can be used to define sub trees. If tuples are used as keys they should have the format (dataset_name,attr_name) and will add a 5h attribute with the corresponding value. :param h5file: File name or h5py-like File, Group or Dataset :param h5path: Target path in the HDF5 file relative to ``h5file``. Default is root (``"/"``) :param mode: Can be ``"r+"`` (read/write, file must exist), ``"w"`` (write, existing file is lost), ``"w-"`` (write, fail if exists) or ``"a"`` (read/write if exists, create otherwise). This parameter is ignored if ``h5file`` is a file handle. :param overwrite_data: Deprecated. ``True`` is approximately equivalent to ``update_mode="modify"`` and ``False`` is equivalent to ``update_mode="add"``. :param create_dataset_args: Dictionary of args you want to pass to ``h5f.create_dataset``. This allows you to specify filters and compression parameters. Don't specify ``name`` and ``data``. :param update_mode: Can be ``add`` (default), ``modify`` or ``replace``. * ``add``: Extend the existing HDF5 tree when possible. Existing HDF5 items (groups, datasets and attributes) remain untouched. * ``modify``: Extend the existing HDF5 tree when possible, modify existing attributes, modify same-sized dataset values and delete HDF5 items with a ``None`` value in the dict tree. * ``replace``: Replace the existing HDF5 tree. Items from the root of the HDF5 tree that are not present in the root of the dict tree will remain untouched. Example:: from silx.io.dictdump import dicttoh5 city_area = { "Europe": { "France": { "Isère": { "Grenoble": 18.44, ("Grenoble","unit"): "km2" }, "Nord": { "Tourcoing": 15.19, ("Tourcoing","unit"): "km2" }, }, }, } create_ds_args = {'compression': "gzip", 'shuffle': True, 'fletcher32': True} dicttoh5(city_area, "cities.h5", h5path="/area", create_dataset_args=create_ds_args) """ if overwrite_data is not None: reason = ("`overwrite_data=True` becomes `update_mode='modify'` and " "`overwrite_data=False` becomes `update_mode='add'`") deprecated_warning( type_="argument", name="overwrite_data", reason=reason, replacement="update_mode", since_version="0.15", ) if update_mode is None: if overwrite_data: update_mode = "modify" else: update_mode = "add" else: valid_existing_values = ("add", "replace", "modify") if update_mode not in valid_existing_values: raise ValueError(("Argument 'update_mode' can only have values: {}" "".format(valid_existing_values))) if overwrite_data is not None: logger.warning("The argument `overwrite_data` is ignored") if not isinstance(treedict, Mapping): raise TypeError("'treedict' must be a dictionary") h5file, h5path = _normalize_h5_path(h5file, h5path) def _iter_treedict(attributes=False): nonlocal treedict for key, value in treedict.items(): if isinstance(key, tuple) == attributes: yield key, value change_allowed = update_mode in ("replace", "modify") with _SafeH5FileWrite(h5file, mode=mode) as h5f: # Create the root of the tree if h5path in h5f: if not is_group(h5f[h5path]): if update_mode == "replace": del h5f[h5path] h5f.create_group(h5path) else: return else: h5f.create_group(h5path) # Loop over all groups, links and datasets for key, value in _iter_treedict(attributes=False): h5name = h5path + key exists = h5name in h5f if value is None: # Delete HDF5 item if exists and change_allowed: del h5f[h5name] exists = False elif isinstance(value, Mapping): # HDF5 group if exists and update_mode == "replace": del h5f[h5name] exists = False if value: dicttoh5(value, h5f, h5name, update_mode=update_mode, create_dataset_args=create_dataset_args) elif not exists: h5f.create_group(h5name) elif is_link(value): # HDF5 link if exists and update_mode == "replace": del h5f[h5name] exists = False if not exists: # Create link from h5py link object h5f[h5name] = value else: # HDF5 dataset if exists and not change_allowed: continue data = _prepare_hdf5_write_value(value) # Edit the existing dataset attrs_backup = None if exists: try: h5f[h5name][()] = data continue except Exception: # Delete the existing dataset if update_mode != "replace": if not is_dataset(h5f[h5name]): continue attrs_backup = dict(h5f[h5name].attrs) del h5f[h5name] # Create dataset # can't apply filters on scalars (datasets with shape == ()) if data.shape == () or create_dataset_args is None: h5f.create_dataset(h5name, data=data) else: h5f.create_dataset(h5name, data=data, **create_dataset_args) if attrs_backup: h5f[h5name].attrs.update(attrs_backup) # Loop over all attributes for key, value in _iter_treedict(attributes=True): if len(key) != 2: raise ValueError( "HDF5 attribute must be described by 2 values") h5name = h5path + key[0] attr_name = key[1] if h5name not in h5f: # Create an empty group to store the attribute h5f.create_group(h5name) h5a = h5f[h5name].attrs exists = attr_name in h5a if value is None: # Delete HDF5 attribute if exists and change_allowed: del h5a[attr_name] exists = False else: # Add/modify HDF5 attribute if exists and not change_allowed: continue data = _prepare_hdf5_write_value(value) h5a[attr_name] = data
# in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ###########################################################################*/ __authors__ = ["T. Vincent"] __license__ = "MIT" __date__ = "15/07/2020" from silx.utils.deprecation import deprecated_warning deprecated_warning(type_='module', name=__file__, replacement='silx.gui.utils.matplotlib', since_version='0.14.0') from silx.gui.utils.matplotlib import FigureCanvasQTAgg # noqa
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ############################################################################*/ """Deprecated module. Use :mod:`convert` instead.""" from .convert import Hdf5Writer from .convert import write_to_h5 from .convert import convert as other_convert from silx.utils import deprecation deprecation.deprecated_warning(type_="Module", name="silx.io.spectoh5", since_version="0.6", replacement="silx.io.convert") class SpecToHdf5Writer(Hdf5Writer): def __init__(self, h5path='/', overwrite_data=False, link_type="hard", create_dataset_args=None): deprecation.deprecated_warning( type_="Class", name="SpecToHdf5Writer", since_version="0.6", replacement="silx.io.convert.Hdf5Writer") Hdf5Writer.__init__(self, h5path, overwrite_data, link_type, create_dataset_args) # methods whose signatures changed
def setColormap(self, colormap=None, normalization=None, autoscale=None, vmin=None, vmax=None, colors=None): """Set the colormap and update active image. Parameters that are not provided are taken from the current colormap. The colormap parameter can also be a dict with the following keys: - *name*: string. The colormap to use: 'gray', 'reversed gray', 'temperature', 'red', 'green', 'blue'. - *normalization*: string. The mapping to use for the colormap: either 'linear' or 'log'. - *autoscale*: bool. Whether to use autoscale (True) or range provided by keys 'vmin' and 'vmax' (False). - *vmin*: float. The minimum value of the range to use if 'autoscale' is False. - *vmax*: float. The maximum value of the range to use if 'autoscale' is False. - *colors*: optional. Nx3 or Nx4 array of float in [0, 1] or uint8. List of RGB or RGBA colors to use (only if name is None) :param colormap: Name of the colormap in 'gray', 'reversed gray', 'temperature', 'red', 'green', 'blue'. Or a :class`.Colormap` object. :type colormap: dict or str. :param str normalization: Colormap mapping: 'linear' or 'log'. :param bool autoscale: Whether to use autoscale or [vmin, vmax] range. Default value of autoscale is False. This option is not compatible with h5py datasets. :param float vmin: The minimum value of the range to use if 'autoscale' is False. :param float vmax: The maximum value of the range to use if 'autoscale' is False. :param numpy.ndarray colors: Only used if name is None. Custom colormap colors as Nx3 or Nx4 RGB or RGBA arrays """ # if is a colormap object or a dictionary if isinstance(colormap, Colormap) or isinstance(colormap, dict): # Support colormap parameter as a dict errmsg = "If colormap is provided as a Colormap object, all other parameters" errmsg += " must not be specified when calling setColormap" assert normalization is None, errmsg assert autoscale is None, errmsg assert vmin is None, errmsg assert vmax is None, errmsg assert colors is None, errmsg if isinstance(colormap, dict): reason = 'colormap parameter should now be an object' replacement = 'Colormap()' since_version = '0.6' deprecated_warning(type_='function', name='setColormap', reason=reason, replacement=replacement, since_version=since_version) _colormap = Colormap._fromDict(colormap) else: _colormap = colormap else: norm = normalization if normalization is not None else 'linear' name = colormap if colormap is not None else 'gray' _colormap = Colormap(name=name, normalization=norm, vmin=vmin, vmax=vmax, colors=colors) # Patch: since we don't apply this colormap to a single 2D data but # a 2D stack we have to deal manually with vmin, vmax if autoscale is None: # set default autoscale = False elif autoscale and is_dataset(self._stack): # h5py dataset has no min()/max() methods raise RuntimeError( "Cannot auto-scale colormap for a h5py dataset") else: autoscale = autoscale self.__autoscaleCmap = autoscale if autoscale and (self._stack is not None): _vmin, _vmax = _colormap.getColormapRange(data=self._stack) _colormap.setVRange(vmin=_vmin, vmax=_vmax) else: if vmin is None and self._stack is not None: _colormap.setVMin(self._stack.min()) else: _colormap.setVMin(vmin) if vmax is None and self._stack is not None: _colormap.setVMax(self._stack.max()) else: _colormap.setVMax(vmax) cursorColor = cursorColorForColormap(_colormap.getName()) self._plot.setInteractiveMode('zoom', color=cursorColor) self._plot.setDefaultColormap(_colormap) # Update active image colormap activeImage = self._plot.getActiveImage() if isinstance(activeImage, items.ColormapMixIn): activeImage.setColormap(self.getColormap())
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ############################################################################*/ """Deprecated module. Use :mod:`convert` instead.""" from .convert import Hdf5Writer from .convert import write_to_h5 from .convert import convert as other_convert from silx.utils import deprecation deprecation.deprecated_warning(type_="Module", name="silx.io.spectoh5", since_version="0.6", replacement="silx.io.convert") class SpecToHdf5Writer(Hdf5Writer): def __init__(self, h5path='/', overwrite_data=False, link_type="hard", create_dataset_args=None): deprecation.deprecated_warning( type_="Class", name="SpecToHdf5Writer", since_version="0.6", replacement="silx.io.convert.Hdf5Writer") Hdf5Writer.__init__(self, h5path, overwrite_data, link_type,
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ###########################################################################*/ """Depracted module linking old PlotAction with the actions.xxx""" __author__ = ["V.A. Sole", "T. Vincent"] __license__ = "MIT" __date__ = "01/06/2017" from silx.utils.deprecation import deprecated_warning deprecated_warning(type_='module', name=__file__, reason='PlotActions refactoring', replacement='plot.actions', since_version='0.6') from .actions import PlotAction from .actions.io import CopyAction from .actions.io import PrintAction from .actions.io import SaveAction from .actions.control import ColormapAction from .actions.control import CrosshairAction from .actions.control import CurveStyleAction from .actions.control import GridAction from .actions.control import KeepAspectRatioAction from .actions.control import PanWithArrowKeysAction
def setColormap(self, colormap=None, normalization=None, autoscale=None, vmin=None, vmax=None, colors=None): """Set the colormap and update active image. Parameters that are not provided are taken from the current colormap. The colormap parameter can also be a dict with the following keys: - *name*: string. The colormap to use: 'gray', 'reversed gray', 'temperature', 'red', 'green', 'blue'. - *normalization*: string. The mapping to use for the colormap: either 'linear' or 'log'. - *autoscale*: bool. Whether to use autoscale (True) or range provided by keys 'vmin' and 'vmax' (False). - *vmin*: float. The minimum value of the range to use if 'autoscale' is False. - *vmax*: float. The maximum value of the range to use if 'autoscale' is False. - *colors*: optional. Nx3 or Nx4 array of float in [0, 1] or uint8. List of RGB or RGBA colors to use (only if name is None) :param colormap: Name of the colormap in 'gray', 'reversed gray', 'temperature', 'red', 'green', 'blue'. Or a :class`.Colormap` object. :type colormap: dict or str. :param str normalization: Colormap mapping: 'linear' or 'log'. :param bool autoscale: Whether to use autoscale or [vmin, vmax] range. Default value of autoscale is False. This option is not compatible with h5py datasets. :param float vmin: The minimum value of the range to use if 'autoscale' is False. :param float vmax: The maximum value of the range to use if 'autoscale' is False. :param numpy.ndarray colors: Only used if name is None. Custom colormap colors as Nx3 or Nx4 RGB or RGBA arrays """ # if is a colormap object or a dictionary if isinstance(colormap, Colormap) or isinstance(colormap, dict): # Support colormap parameter as a dict errmsg = "If colormap is provided as a Colormap object, all other parameters" errmsg += " must not be specified when calling setColormap" assert normalization is None, errmsg assert autoscale is None, errmsg assert vmin is None, errmsg assert vmax is None, errmsg assert colors is None, errmsg if isinstance(colormap, dict): reason = 'colormap parameter should now be an object' replacement = 'Colormap()' since_version = '0.6' deprecated_warning(type_='function', name='setColormap', reason=reason, replacement=replacement, since_version=since_version) _colormap = Colormap._fromDict(colormap) else: _colormap = colormap else: norm = normalization if normalization is not None else 'linear' name = colormap if colormap is not None else 'gray' _colormap = Colormap(name=name, normalization=norm, vmin=vmin, vmax=vmax, colors=colors) if autoscale is not None: deprecated_warning( type_='function', name='setColormap', reason='autoscale argument is replaced by a method', replacement='scaleColormapRangeToStack', since_version='0.14') self.__autoscaleCmap = bool(autoscale) cursorColor = cursorColorForColormap(_colormap.getName()) self._plot.setInteractiveMode('zoom', color=cursorColor) self._plot.setDefaultColormap(_colormap) # Update active image colormap activeImage = self.getActiveImage() if isinstance(activeImage, items.ColormapMixIn): activeImage.setColormap(self.getColormap()) if self.__autoscaleCmap: # scaleColormapRangeToStack needs to be called **after** # setDefaultColormap so getColormap returns the right colormap self.scaleColormapRangeToStack()
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ###########################################################################*/ """Depracted module linking old PlotAction with the actions.xxx""" __author__ = ["V.A. Sole", "T. Vincent"] __license__ = "MIT" __date__ = "01/06/2017" from silx.utils.deprecation import deprecated_warning deprecated_warning(type_='module', name=__file__, reason='PlotActions refactoring', replacement='plot.actions', since_version='0.6') from .actions import PlotAction from .actions.io import CopyAction from .actions.io import PrintAction from .actions.io import SaveAction from .actions.control import ColormapAction from .actions.control import CrosshairAction from .actions.control import CurveStyleAction from .actions.control import GridAction from .actions.control import KeepAspectRatioAction from .actions.control import PanWithArrowKeysAction
# THE SOFTWARE. # # ############################################################################*/ """Matplotlib's new colormaps""" import numpy import logging from matplotlib.colors import ListedColormap import matplotlib.colors import matplotlib.cm import silx.resources from silx.utils.deprecation import deprecated, deprecated_warning deprecated_warning(type_='module', name=__file__, replacement='silx.gui.colors.Colormap', since_version='0.10.0') _logger = logging.getLogger(__name__) _AVAILABLE_AS_RESOURCE = ('magma', 'inferno', 'plasma', 'viridis') """List available colormap name as resources""" _AVAILABLE_AS_BUILTINS = ('gray', 'reversed gray', 'temperature', 'red', 'green', 'blue') """List of colormaps available through built-in declarations""" _CMAPS = {} """Cache colormaps"""
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ############################################################################*/ """Matplotlib's new colormaps""" import numpy import logging from matplotlib.colors import ListedColormap import matplotlib.colors import matplotlib.cm import silx.resources from silx.utils.deprecation import deprecated, deprecated_warning deprecated_warning(type_='module', name=__file__, replacement='silx.gui.colors.Colormap', since_version='0.10.0') _logger = logging.getLogger(__name__) _AVAILABLE_AS_RESOURCE = ('magma', 'inferno', 'plasma', 'viridis') """List available colormap name as resources""" _AVAILABLE_AS_BUILTINS = ('gray', 'reversed gray', 'temperature', 'red', 'green', 'blue') """List of colormaps available through built-in declarations""" _CMAPS = {} """Cache colormaps"""