def dataVals(self, d): """Set mandatory data values. Values == 0.0. Will be set to Tolerance """ self._dataVals = d if self._dataVals is None: pg._y(d) pg.critical("Inversion framework needs data values to run")
def errorVals(self, d): """Set mandatory error values. Values == 0.0. Will be set to Tolerance """ self._errorVals = d if self._errorVals is None: pg._y(d) pg.critical("Inversion framework needs error values to run") if min(abs(self._errorVals)) < 1e-12: print(self._errorVals) pg.warn("Found zero error values. Setting them to a Fallback value of 1") pg.fixZero(self._errorVals, 1)
def createColorBar(gci, orientation='horizontal', size=0.2, pad=None, **kwargs): """Create a Colorbar. Shortcut to create a matplotlib colorbar within the ax for a given patchset. The colorbar is stored in the axes object as __cBar__ to avoid duplicates. Parameters ---------- gci: matplotlib graphical instance orientation: string size: float pad: float **kwargs : Forwarded to updateColorBar """ cbarTarget = plt cax = None divider = None # if hasattr(patches, 'figure'): # cbarTarget = patches.figure ax = kwargs.pop('ax', None) if ax is None: if hasattr(gci, 'ax'): ax = gci.ax elif hasattr(gci, 'axes'): ax = gci.axes elif hasattr(gci, 'get_axes'): ax = gci.get_axes() cbar = None if hasattr(ax, '__cBar__'): ax.__cBar__.remove() delattr(ax, '__cBar__') # update colorbar is broken and will not work as supposed so we need # to remove them for now if hasattr(ax, '__cBar__'): cbar = ax.__cBar__ pg._y('update', kwargs) updateColorBar(cbar, gci, **kwargs) else: divider = make_axes_locatable(ax) if divider: if orientation == 'horizontal': if pad is None: pad = 0.5 cax = divider.append_axes("bottom", size=size, pad=pad) else: if pad is None: pad = 0.1 cax = divider.append_axes("right", size=size, pad=pad) cbar = cbarTarget.colorbar(gci, cax=cax, orientation=orientation) #store the cbar into the axes to reuse it on the next call ax.__cBar__ = cbar updateColorBar(cbar, **kwargs) return cbar