示例#1
0
 def plotBox(self, name, data, data_range=None):
     box = Frame(self, border=2, relief=SUNKEN)
     box.pack(side=TOP, fill=BOTH, expand=YES)
     frame = Frame(box, background='grey')
     frame.pack(side=TOP, fill=X, expand=NO)
     Label(frame, text=string.capitalize(string.join(
                       string.split(name , '_'), ' ')),
           background='grey').pack(side=LEFT)
     if data_range is None:
         min = Numeric.minimum.reduce(data[:,1])
         max = Numeric.maximum.reduce(data[:,1])
         min, max = plotRange(min, max)
     else:
         min, max = data_range
     plot_objects = []
     plot_data = data
     time = plot_data[:,0]
     jumps = Numeric.repeat(Numeric.arange(len(time)-1),
                            Numeric.less(time[1:], time[:-1]))+1
     for i in self.master.restarts:
         plot_objects.append(PolyLine([(self.time[i], min),
                                       (self.time[i], max)],
                                      color='black',
                                      stipple='gray25'))
     plot_objects.insert(0, PolyLine(plot_data, color = 'red'))
     plot = PlotCanvas(box, 400, 100, zoom=1,
                       select=self.master._selectRange)
     plot.pack(side=LEFT, fill=BOTH, expand=YES)
     plot.draw(PlotGraphics(plot_objects),
               'automatic', (min, max))
     plot.bind('<Double-Button-1>', lambda event, d=plot_data:
                                    externalPlot(d))
     self.registerPlot(plot)
     self.setSelection(plot)
    def __init__(self, master, rb_projector):
        PlotWindow.__init__(self, master, "Rigid-body motion projections")
        plot_range = 0.
        for i in range(6):
            series = rb_projector[i][:, 1]
            lower = Numeric.minimum.reduce(series)
            upper = Numeric.maximum.reduce(series)
            lower, upper = plotRange(lower, upper)
            plot_range = max(plot_range, upper - lower)

        for column, offset, type in [(0, 0, "Translation "),
                                     (1, 3, "Rotation ")]:
            for i in range(3):
                data = rb_projector[i + offset]
                box = Frame(self, border=2, relief=SUNKEN)
                box.grid(row=i, column=column, sticky=N + W + E + S)
                frame = Frame(box, background='grey')
                frame.pack(side=TOP, fill=X, expand=NO)
                Label(frame, text=type + ["X", "Y", "Z"][i],
                      background='grey').pack(side=LEFT)
                minv = Numeric.minimum.reduce(data[:, 1])
                maxv = Numeric.maximum.reduce(data[:, 1])
                minv, maxv = plotRange(minv, maxv)
                middle = 0.5 * (maxv + minv)
                if maxv - minv < plot_range:
                    minv = middle - 0.5 * plot_range
                    maxv = middle + 0.5 * plot_range
                plot_objects = [PolyLine(data, color='red')]
                plot = PlotCanvas(box,
                                  400,
                                  100,
                                  zoom=1,
                                  select=self.master._selectRange)
                plot.pack(side=LEFT, fill=BOTH, expand=YES)
                plot.draw(PlotGraphics(plot_objects), 'automatic',
                          (minv, maxv))
                plot.bind('<Double-Button-1>',
                          lambda event, d=data: externalPlot(d))
                self.registerPlot(plot)
                self.setSelection(plot)
示例#3
0
    def __init__(self, master, rb_projector):
        PlotWindow.__init__(self, master, "Rigid-body motion projections")
        plot_range = 0.
        for i in range(6):
            series = rb_projector[i][:, 1]
            lower = Numeric.minimum.reduce(series)
            upper = Numeric.maximum.reduce(series)
            lower, upper = plotRange(lower, upper)
            plot_range = max(plot_range, upper-lower)

        for column, offset, type in [(0, 0, "Translation "),
                                     (1, 3, "Rotation ")]:
            for i in range(3):
                data = rb_projector[i+offset]
                box = Frame(self, border=2, relief=SUNKEN)
                box.grid(row=i, column=column, sticky=N+W+E+S)
                frame = Frame(box, background='grey')
                frame.pack(side=TOP, fill=X, expand=NO)
                Label(frame, text=type + ["X", "Y", "Z"][i],
                      background='grey').pack(side=LEFT)
                minv = Numeric.minimum.reduce(data[:,1])
                maxv = Numeric.maximum.reduce(data[:,1])
                minv, maxv = plotRange(minv, maxv)
                middle = 0.5*(maxv+minv)
                if maxv-minv < plot_range:
                    minv = middle-0.5*plot_range
                    maxv = middle+0.5*plot_range
                plot_objects = [PolyLine(data, color = 'red')]
                plot = PlotCanvas(box, 400, 100, zoom=1,
                                  select=self.master._selectRange)
                plot.pack(side=LEFT, fill=BOTH, expand=YES)
                plot.draw(PlotGraphics(plot_objects), 'automatic',
                          (minv, maxv))
                plot.bind('<Double-Button-1>', lambda event, d=data:
                                                      externalPlot(d))
                self.registerPlot(plot)
                self.setSelection(plot)
 def plotBox(self, name, data, data_range=None):
     box = Frame(self, border=2, relief=SUNKEN)
     box.pack(side=TOP, fill=BOTH, expand=YES)
     frame = Frame(box, background='grey')
     frame.pack(side=TOP, fill=X, expand=NO)
     Label(frame,
           text=string.capitalize(string.join(string.split(name, '_'),
                                              ' ')),
           background='grey').pack(side=LEFT)
     if data_range is None:
         min = Numeric.minimum.reduce(data[:, 1])
         max = Numeric.maximum.reduce(data[:, 1])
         min, max = plotRange(min, max)
     else:
         min, max = data_range
     plot_objects = []
     plot_data = data
     time = plot_data[:, 0]
     jumps = Numeric.repeat(Numeric.arange(len(time) - 1),
                            Numeric.less(time[1:], time[:-1])) + 1
     for i in self.master.restarts:
         plot_objects.append(
             PolyLine([(self.time[i], min), (self.time[i], max)],
                      color='black',
                      stipple='gray25'))
     plot_objects.insert(0, PolyLine(plot_data, color='red'))
     plot = PlotCanvas(box,
                       400,
                       100,
                       zoom=1,
                       select=self.master._selectRange)
     plot.pack(side=LEFT, fill=BOTH, expand=YES)
     plot.draw(PlotGraphics(plot_objects), 'automatic', (min, max))
     plot.bind('<Double-Button-1>',
               lambda event, d=plot_data: externalPlot(d))
     self.registerPlot(plot)
     self.setSelection(plot)
示例#5
0
    def __init__(self, master, mode_projector, indices):
        from Scientific.Statistics import mean, standardDeviation
        title = "Normal mode projections (Temperature: %5.1f K)" \
                % mode_projector.temperature
        PlotWindow.__init__(self, master, title)
        self.mode_projector = mode_projector

        plot_range = 0.
        for i in indices:
            series = mode_projector[i][:, 1]
            average = mean(series)
            deviation = standardDeviation(series)
            lower = Numeric.minimum.reduce(series)
            lower = min(lower, average-deviation)
            upper = Numeric.maximum.reduce(series)
            upper = max(upper, average+deviation)
            lower, upper = plotRange(lower, upper)
            plot_range = max(plot_range, upper-lower)

        nmodes = mode_projector.numberOfModes()
        for i in range(len(indices)):
            if indices[i] < 0:
                indices[i] = nmodes+indices[i]
        next_indices = []
        step = indices[1] - indices[0]
        i = indices[-1]
        while len(next_indices) < 4:
            i = i + step
            if i >= nmodes:
                break
            next_indices.append(i)
        previous_indices = []
        i = indices[0]
        while len(previous_indices) < 4:
            i = i - step
            if i < 6:
                break
            previous_indices.insert(0, i)
        if next_indices or previous_indices:
            frame = Frame(self)
            frame.pack(side=BOTTOM, fill=X, expand=YES)
            if previous_indices:
                Button(frame, text="Previous",
                       command=lambda s=self, pi=previous_indices:
                               s.modeProjection(pi)).pack(side=LEFT)
            if next_indices:
                Button(frame, text="Next",
                       command=lambda s=self, ni=next_indices:
                               s.modeProjection(ni)).pack(side=RIGHT)

        for i in range(len(indices)):
            number = indices[i]
            data = mode_projector[number]
            fluctuation = self.mode_projector.amplitude(number)
            average = mean(data[:, 1])
            deviation = standardDeviation(data[:, 1])
            box = Frame(self, border=2, relief=SUNKEN)
            box.pack(side=TOP, fill=BOTH, expand=YES)
            frame = Frame(box, background='grey')
            frame.pack(side=TOP, fill=X, expand=NO)
            Label(frame, text="Mode %d" % number,
                  background='grey').pack(side=LEFT)
            Button(frame, text="Animation", background='grey',
                   command=lambda s=self, n=number:
                                  s.animateMode(n, 1.)).pack(side=RIGHT)
            Button(frame, text="View", background='grey',
                   command=lambda s=self, n=number:
                                  s.viewMode(n)).pack(side=RIGHT)
            minv = Numeric.minimum.reduce(data[:,1])
            maxv = Numeric.maximum.reduce(data[:,1])
            minv, maxv = plotRange(minv, maxv)
            middle = 0.5*(maxv+minv)
            if maxv-minv < plot_range:
                minv = middle-0.5*plot_range
                maxv = middle+0.5*plot_range
            plot_objects = [PolyLine([(data[1, 0], average-fluctuation),
                                      (data[1, 0], average+fluctuation)],
                                     color='blue', width=3),
                            PolyLine([(data[-1, 0], average-deviation),
                                      (data[-1, 0], average+deviation)],
                                     color='green', width=3)]
            plot_objects.insert(0, PolyLine(data, color = 'red'))
            plot = PlotCanvas(box, 400, 100, zoom=1,
                              select=self.master._selectRange)
            plot.pack(side=LEFT, fill=BOTH, expand=YES)
            plot.draw(PlotGraphics(plot_objects), 'automatic', (minv, maxv))
            plot.bind('<Double-Button-1>', lambda event, d=data:
                                           externalPlot(d))
            self.registerPlot(plot)
            self.setSelection(plot)
    def __init__(self, master, mode_projector, indices):
        from Scientific.Statistics import mean, standardDeviation
        title = "Normal mode projections (Temperature: %5.1f K)" \
                % mode_projector.temperature
        PlotWindow.__init__(self, master, title)
        self.mode_projector = mode_projector

        plot_range = 0.
        for i in indices:
            series = mode_projector[i][:, 1]
            average = mean(series)
            deviation = standardDeviation(series)
            lower = Numeric.minimum.reduce(series)
            lower = min(lower, average - deviation)
            upper = Numeric.maximum.reduce(series)
            upper = max(upper, average + deviation)
            lower, upper = plotRange(lower, upper)
            plot_range = max(plot_range, upper - lower)

        nmodes = mode_projector.numberOfModes()
        for i in range(len(indices)):
            if indices[i] < 0:
                indices[i] = nmodes + indices[i]
        next_indices = []
        step = indices[1] - indices[0]
        i = indices[-1]
        while len(next_indices) < 4:
            i = i + step
            if i >= nmodes:
                break
            next_indices.append(i)
        previous_indices = []
        i = indices[0]
        while len(previous_indices) < 4:
            i = i - step
            if i < 6:
                break
            previous_indices.insert(0, i)
        if next_indices or previous_indices:
            frame = Frame(self)
            frame.pack(side=BOTTOM, fill=X, expand=YES)
            if previous_indices:
                Button(frame,
                       text="Previous",
                       command=lambda s=self, pi=previous_indices: s.
                       modeProjection(pi)).pack(side=LEFT)
            if next_indices:
                Button(frame,
                       text="Next",
                       command=lambda s=self, ni=next_indices: s.
                       modeProjection(ni)).pack(side=RIGHT)

        for i in range(len(indices)):
            number = indices[i]
            data = mode_projector[number]
            fluctuation = self.mode_projector.amplitude(number)
            average = mean(data[:, 1])
            deviation = standardDeviation(data[:, 1])
            box = Frame(self, border=2, relief=SUNKEN)
            box.pack(side=TOP, fill=BOTH, expand=YES)
            frame = Frame(box, background='grey')
            frame.pack(side=TOP, fill=X, expand=NO)
            Label(frame, text="Mode %d" % number,
                  background='grey').pack(side=LEFT)
            Button(frame,
                   text="Animation",
                   background='grey',
                   command=lambda s=self, n=number: s.animateMode(n, 1.)).pack(
                       side=RIGHT)
            Button(frame,
                   text="View",
                   background='grey',
                   command=lambda s=self, n=number: s.viewMode(n)).pack(
                       side=RIGHT)
            minv = Numeric.minimum.reduce(data[:, 1])
            maxv = Numeric.maximum.reduce(data[:, 1])
            minv, maxv = plotRange(minv, maxv)
            middle = 0.5 * (maxv + minv)
            if maxv - minv < plot_range:
                minv = middle - 0.5 * plot_range
                maxv = middle + 0.5 * plot_range
            plot_objects = [
                PolyLine([(data[1, 0], average - fluctuation),
                          (data[1, 0], average + fluctuation)],
                         color='blue',
                         width=3),
                PolyLine([(data[-1, 0], average - deviation),
                          (data[-1, 0], average + deviation)],
                         color='green',
                         width=3)
            ]
            plot_objects.insert(0, PolyLine(data, color='red'))
            plot = PlotCanvas(box,
                              400,
                              100,
                              zoom=1,
                              select=self.master._selectRange)
            plot.pack(side=LEFT, fill=BOTH, expand=YES)
            plot.draw(PlotGraphics(plot_objects), 'automatic', (minv, maxv))
            plot.bind('<Double-Button-1>',
                      lambda event, d=data: externalPlot(d))
            self.registerPlot(plot)
            self.setSelection(plot)