Example #1
0
def plot_stack(mystack,what="intensity",title0="X",title1="Y",title2="Z"):

    from silx.gui.plot.StackView import StackViewMainWindow
    from silx.gui import qt


    app = qt.QApplication(sys.argv[1:])

    sv = StackViewMainWindow()
    sv.setColormap("jet", autoscale=True)
    if what == "intensity":
        sv.setStack(numpy.absolute(mystack))
    elif what == "real":
        sv.setStack(numpy.real(mystack))
    elif what == "imaginary":
        sv.setStack(numpy.imag(mystack))
    elif what == "phase":
        sv.setStack(numpy.angle(mystack))
    elif what == "phase_deg":
        sv.setStack(numpy.angle(mystack,deg=True))
    else:
        raise Exception("Undefined label "+what)

    sv.setLabels([title0,title1,title2])
    sv.show()

    app.exec_()
def plot_data3D(data3D,
                dataScan,
                dataX,
                dataY,
                title="",
                xtitle="",
                ytitle=""):

    xmin = numpy.min(dataX)
    xmax = numpy.max(dataX)
    ymin = numpy.min(dataY)
    ymax = numpy.max(dataY)

    stepX = dataX[1] - dataX[0]
    stepY = dataY[1] - dataY[0]
    if len(dataScan) > 1: stepScan = dataScan[1] - dataScan[0]
    else: stepScan = 1.0

    if stepScan == 0.0: stepScan = 1.0
    if stepX == 0.0: stepX = 1.0
    if stepY == 0.0: stepY = 1.0

    dim0_calib = (dataScan[0], stepScan)
    dim1_calib = (ymin, stepY)
    dim2_calib = (xmin, stepX)

    data_to_plot = numpy.swapaxes(data3D, 1, 2)

    colormap = {
        "name": "temperature",
        "normalization": "linear",
        "autoscale": True,
        "vmin": 0,
        "vmax": 0,
        "colors": 256
    }

    plot_canvas = StackViewMainWindow()

    plot_canvas.setGraphTitle(title)
    plot_canvas.setLabels(["Scanned Variable", ytitle, xtitle])
    plot_canvas.setColormap(colormap=colormap)

    plot_canvas.setStack(numpy.array(data_to_plot),
                         calibrations=[dim0_calib, dim1_calib, dim2_calib])

    plot_canvas.show()
Example #3
0
#
# ###########################################################################*/
"""This script is a simple example to illustrate how to use the StackView
widget.
"""
import numpy
import sys
from silx.gui import qt
# from silx.gui.plot import StackView
from silx.gui.plot.StackView import StackViewMainWindow

app = qt.QApplication(sys.argv[1:])
    
x, y, z = numpy.meshgrid(numpy.linspace(-10, 10, 200),
                         numpy.linspace(-10, 5, 150),
                         numpy.linspace(-5, 10, 120),
                         indexing="ij")
mystack = numpy.asarray(numpy.sin(x * y * z) / (x * y * z),
                        dtype='float32')

# sv = StackView()
sv = StackViewMainWindow()
sv.setColormap("jet", autoscale=True)
sv.setStack(mystack)
sv.setLabels(["x: -10 to 10 (200 samples)",
              "y: -10 to 5 (150 samples)",
              "z: -5 to 10 (120 samples)"])
sv.show()

app.exec_()
Example #4
0
app = qt.QApplication(sys.argv[1:])

a, b, c = numpy.meshgrid(numpy.linspace(-10, 10, 200),
                         numpy.linspace(-10, 5, 150),
                         numpy.linspace(-5, 10, 120),
                         indexing="ij")
mystack = numpy.asarray(numpy.sin(a * b * c) / (a * b * c), dtype='float32')

# linear calibrations (a, b), x -> a + bx
dim0_calib = (-10., 20. / 200.)
dim1_calib = (-10., 15. / 150.)
dim2_calib = (-5., 15. / 120.)

# sv = StackView()
sv = StackViewMainWindow()
sv.setStack(mystack, calibrations=[dim0_calib, dim1_calib, dim2_calib])
sv.setLabels([
    "dim0: -10 to 10 (200 samples)", "dim1: -10 to 5 (150 samples)",
    "dim2: -5 to 10 (120 samples)"
])
sv.setColormap("jet")
sv.scaleColormapRangeToStack()

# Enable use of mask in other tools: colormap autoscale, histogram, profile
maskToolsWidget = sv.getPlotWidget().getMaskToolsDockWidget().widget()
maskToolsWidget.setItemMaskUpdated(True)

sv.show()

app.exec_()
Example #5
0
import numpy
import sys
from silx.gui import qt
from silx.gui.plot.StackView import StackViewMainWindow

app = qt.QApplication(sys.argv[1:])
    
a, b, c = numpy.meshgrid(numpy.linspace(-10, 10, 200),
                         numpy.linspace(-10, 5, 150),
                         numpy.linspace(-5, 10, 120),
                         indexing="ij")
mystack = numpy.asarray(numpy.sin(a * b * c) / (a * b * c),
                        dtype='float32')

# linear calibrations (a, b), x -> a + bx
dim0_calib = (-10., 20. / 200.)
dim1_calib = (-10., 15. / 150.)
dim2_calib = (-5., 15. / 120.)

# sv = StackView()
sv = StackViewMainWindow()
sv.setColormap("jet", autoscale=True)
sv.setStack(mystack,
            calibrations=[dim0_calib, dim1_calib, dim2_calib])
sv.setLabels(["dim0: -10 to 10 (200 samples)",
              "dim1: -10 to 5 (150 samples)",
              "dim2: -5 to 10 (120 samples)"])
sv.show()

app.exec_()