From: <zk...@us...> - 2009-07-20 23:07:10
|
Revision: 651 http://pyphant.svn.sourceforge.net/pyphant/?rev=651&view=rev Author: zklaus Date: 2009-07-20 23:06:59 +0000 (Mon, 20 Jul 2009) Log Message: ----------- Merge branch 'master' into svn-trunk * master: Enh: Support manual color scaling in ImageVisualizer. Modified Paths: -------------- trunk/src/pyphant/pyphant/visualizers/ImageVisualizer.py trunk/src/workers/OSC/OSC/OscAbsorption.py Modified: trunk/src/pyphant/pyphant/visualizers/ImageVisualizer.py =================================================================== --- trunk/src/pyphant/pyphant/visualizers/ImageVisualizer.py 2009-07-20 21:08:00 UTC (rev 650) +++ trunk/src/pyphant/pyphant/visualizers/ImageVisualizer.py 2009-07-20 23:06:59 UTC (rev 651) @@ -111,8 +111,20 @@ ymax=scipy.amax(y) #Support for images with non uniform axes adapted from python-matplotlib-doc/examples/pcolor_nonuniform.py ax = self.figure.add_subplot(111) + vmin = self.fieldContainer.attributes.get('vmin', None) + vmax = self.fieldContainer.attributes.get('vmax', None) + if vmin is not None: + vmin /= self.fieldContainer.unit + if vmax is not None: + vmax /= self.fieldContainer.unit if MPL_LT_0_98_1 or self.fieldContainer.isLinearlyDiscretised(): - pylab.imshow(self.fieldContainer.maskedData, extent=(xmin, xmax, ymin, ymax), origin='lower', interpolation='nearest',aspect='auto') + pylab.imshow(self.fieldContainer.maskedData, + aspect='auto', + interpolation='nearest', + vmin=vmin, + vmax=vmax, + origin='lower', + extent=(xmin, xmax, ymin, ymax)) pylab.colorbar(format=F(self.fieldContainer), ax=ax) else: im = NonUniformImage(ax, extent=(xmin,xmax,ymin,ymax)) @@ -120,6 +132,10 @@ ax.images.append(im) ax.set_xlim(xmin,xmax) ax.set_ylim(ymin,ymax) + if vmin is not None or vmax is not None: + im.set_clim(vmin, vmax) + else: + im.autoscale_None() pylab.colorbar(im,format=F(self.fieldContainer), ax=ax) pylab.xlabel(self.fieldContainer.dimensions[-1].shortlabel) pylab.ylabel(self.fieldContainer.dimensions[-2].shortlabel) Modified: trunk/src/workers/OSC/OSC/OscAbsorption.py =================================================================== --- trunk/src/workers/OSC/OSC/OscAbsorption.py 2009-07-20 21:08:00 UTC (rev 650) +++ trunk/src/workers/OSC/OSC/OscAbsorption.py 2009-07-20 23:06:59 UTC (rev 651) @@ -162,7 +162,10 @@ ("yAxis", u"y-Axis", [u"vertical_table_position"], None), ("field", u"Field", [u"thickness"], None), ("extentX", u"Extension of x-axis [%%]", 10, None), - ("extentY", u"Extension of y-axis [%%]", 10, None)] + ("extentY", u"Extension of y-axis [%%]", 10, None), + ("overrideV", u"Override value limits", False, None), + ("vmin", u"Minimal value", "0 nm", None), + ("vmax", u"Maximal value", "100 nm", None)] def inithook(self): self._logger = logging.getLogger("pyphant") @@ -180,23 +183,31 @@ yOff, yStep, yInd = grid2Index(yf, self.paramExtentY.value) xMax = xInd.maxV yMax = yInd.maxV - xDim = DataContainer.FieldContainer( numpy.linspace(xInd.minV,xInd.maxV,xInd.stepCount)-0.5*xStep, xCon.unit, - longname = xCon.longname, shortname = xCon.shortname ) - yDim = DataContainer.FieldContainer( numpy.linspace(yInd.minV,yInd.maxV,yInd.stepCount)-0.5*yStep, yCon.unit, - longname = yCon.longname, shortname = yCon.shortname ) - img = numpy.ones((yInd.stepCount, xInd.stepCount), dtype='float')*numpy.NaN + xDim = DataContainer.FieldContainer( + numpy.linspace(xInd.minV,xInd.maxV,xInd.stepCount)-0.5*xStep, + xCon.unit, + longname = xCon.longname, shortname = xCon.shortname ) + yDim = DataContainer.FieldContainer( + numpy.linspace(yInd.minV,yInd.maxV,yInd.stepCount)-0.5*yStep, + yCon.unit, + longname = yCon.longname, shortname = yCon.shortname ) + img = numpy.ones((yInd.stepCount, xInd.stepCount), + dtype='float')*numpy.NaN mask = numpy.ones((yInd.stepCount, xInd.stepCount), dtype='bool') for i in xrange(xf.size): xi = xInd[xf[i]] yi = yInd[yf[i]] if not mask[yi, xi]: - self._logger.warning("Duplicate data for pixel (%.4g,%.4g). Using first found value. Is your data corrupt?"%(xf[i],yf[i])) + self._logger.warning("Duplicate data for pixel (%.4g,%.4g). " + "Using first found value. " + "Is your data corrupt?"%(xf[i],yf[i])) else: img[yi, xi] = h[i] if h[i]>0: mask[yi, xi] = False - result = DataContainer.FieldContainer( img, fCon.unit, mask=mask, dimensions=[yDim, xDim], - longname=u'Map of %s'%fCon.longname, shortname=fCon.shortname) + result = DataContainer.FieldContainer( + img, fCon.unit, mask=mask, dimensions=[yDim, xDim], + longname=u'Map of %s'%fCon.longname, shortname=fCon.shortname) return result @Worker.plug(Connectors.TYPE_IMAGE) @@ -211,5 +222,15 @@ con.data = con.data.astype('float') xf, yf, h = tuple([ con.data for con in cons ]) result = self.calcNormal(osc, xCon, yCon, fCon, xf, yf, h) + if self.paramOverrideV.value: + vs = self.paramVmin.value, self.paramVmax.value + from pyphant.quantities.PhysicalQuantities import ( + isPhysicalQuantity, PhysicalQuantity) + try: + vs = [PhysicalQuantity(v) for v in vs] + except SyntaxError: + vs = [float(v) for v in vs] + result.attributes['vmin'] = vs[0] + result.attributes['vmax'] = vs[1] result.seal() return result This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |