def testVisualization(self): X, LAMB = numpy.meshgrid(numpy.linspace(-1.5, 1.5, self.n), numpy.linspace(-1.0, 1.0, self.m)) self.lambDim = numpy.linspace(-1.0, 1.0, self.m) self.xDim = numpy.linspace(-1.5, 1.5, self.n) lambField = DC.FieldContainer(self.lambDim, unit='1 V / m**3', longname='parameter', shortname='\lambda') xField = DC.FieldContainer(self.xDim, unit='1 m', longname='position', shortname='x') #Prepare potential V = [] for i in xrange(len(lambField.data)): u = X[i] V.append(-lambField.data[i] / 2 * u**2 + u**4 / 4 - u * self.kappa1) self.V = DC.FieldContainer(numpy.array(V), unit='1 V', dimensions=[lambField, xField], longname='electric potential', shortname=r'\varphi') self.V.seal() #Visualise result visualizer = ImageVisualizer(self.V, show=False) filename = os.path.join(self.tmpdir, 'pyphant-' + DC.parseId(self.V.id)[0] + '.pdf') visualizer.figure.savefig(filename)
def simulation(recipe, curvNo, noIndicators): worker = recipe.getWorker("ThicknessModeller") simulation = worker.plugCalcAbsorption.getResult() worker = recipe.getWorker("AddColumn") table = worker.plugCompute.getResult( subscriber=TextSubscriber("Add Column")) thickness = table[u"thickness"] index = curvNo2Index(table[u"pixel"], curvNo) worker = recipe.getWorker("MRA Exp") minimaPos = worker.plugMra.getResult()[r'\lambda_{min}'].inUnitsOf( simulation.dimensions[1]) maximaPos = worker.plugMra.getResult()[r'\lambda_{max}'].inUnitsOf( simulation.dimensions[1]) visualizer = ImageVisualizer(simulation, False) ordinate = simulation.dimensions[1].data if not noIndicators: pylab.hlines(thickness.data[index], ordinate.min(), ordinate.max(), label="$%s$" % minimaPos.shortname) abscissae = simulation.dimensions[0].data pylab.vlines(minimaPos.data[:, index], abscissae.min(), abscissae.max(), label="$%s$" % minimaPos.shortname) pylab.vlines(maximaPos.data[:, index], abscissae.min(), abscissae.max(), label="$%s$" % maximaPos.shortname)
def thicknessMap(recipe, curvNo): worker = recipe.getWorker("OscMapper") oscMap = worker.plugMapHeights.getResult() worker = recipe.getWorker("AddColumn") table = worker.plugCompute.getResult( subscriber=TextSubscriber("Add Column")) xPos = table[u"x-position"] yPos = table[u"y-position"] index = curvNo2Index(table[u"pixel"], curvNo) visualizer = ImageVisualizer(oscMap, False) pylab.plot([xPos.data[index]], [yPos.data[index]], 'xk', scalex=False, scaley=False)
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import pkg_resources pkg_resources.require('pyphant') pkg_resources.require('pyphant.imageprocessing') # for demo.h5 from pyphant.core.H5FileHandler import H5FileHandler from pyphant.visualizers.ImageVisualizer import ImageVisualizer #Load recipe from hdf file with H5FileHandler('demo.h5', 'r') as handler: recipe = handler.loadRecipe() #Configure ImageLoaderWorker inputWorker = recipe.getWorker('Load Image') imageName = 'demo.png' inputWorker.getParam('filename').value = imageName #Fetch Result worker = recipe.getWorker('Invert') result = worker.plugInvert.getResult() #Visualise result visualizer = ImageVisualizer(result) visualizer.figure.savefig('result-' + imageName)
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import os import ImageProcessing.ImageLoaderWorker as IL from pyphant.visualizers.ImageVisualizer import ImageVisualizer #Initialize ImageLoaderWorker worker = IL.ImageLoaderWorker(None) #Configure ImageLoaderWorker demoFileName = os.path.join( os.path.dirname(__file__), "pyphant-shade-Information-Analysis-Framework.png") worker.paramFilename.value = demoFileName worker.paramXScale.value = '10m' #Fetch Image as FieldContainer fieldContainer = worker.plugLoadImageAsGreyScale.getResult() #Visualise FieldContainer visualizer = ImageVisualizer(fieldContainer) visualizer.figure.savefig('annotatedLogo.png')