コード例 #1
0
    def btn_submit_click(self, **event_args):
        if len(self.newvalues) > 0:
            draw.clear_canvas(self.canvas, "#fff")

            if self.check_blur.checked:
                self.newvalues = self.gauss_blur(self.newvalues)

            mark = self.check() * 100
            self.lbl_mark.text = str(repr(mark)) + "%"
            colour = "#198dbf"
            if mark > self.pass_mark:
                self.lbl_mark.text += "\nWell done!"
            else:
                colour = "#fff"
                self.lbl_mark.text += "\nScore  over {0}% to pass".format(
                    self.pass_mark)
            self.graph.plot(xmarker=self.graph.xmarker / self.graph.xu,
                            ymarker=self.graph.ymarker / self.graph.yu,
                            colour=colour)

            self.graph2 = draw.graph_plot(self.canvas, self.newvalues)
            self.graph2.axes_enabled = False
            self.graph2.xlabel = self.xlabel
            self.graph2.ylabel = self.ylabel
            self.graph2.xrange = self.graph.xrange
            self.graph2.yrange = self.graph.yrange
            self.graph2.plot(colour="rgb(214, 106, 72)",
                             xmarker=self.graph.xmarker / self.graph.xu,
                             ymarker=self.graph.ymarker / self.graph.yu)
コード例 #2
0
    def timer_tick (self, **event_args):
        canvas = self.canvas

        if self.first:
            self.values = fill_up(self.correct_function, self.xran)
            self.graph = draw.graph_plot(canvas, self.values)
            self.graph.axes_enabled = True
            if self.set_xrange != [None, None]:
                self.graph.xrange = self.set_xrange
            if self.set_yrange != [None, None]:
                self.graph.yrange = self.set_yrange
            self.graph.xlabel = self.xlabel
            self.graph.ylabel = self.ylabel
            self.graph.plot(colour = "#fff", xmarker = self.xmarker, ymarker = self.ymarker)

            tolx  = 100/self.graph.xu
            toly = 100/self.graph.yu

            self.corrstats = find_stationary(self.values, tol = toly)
            self.corr_x_ints = find_intersecs(self.values, tol = toly, x = True)
            self.corr_y_ints = find_intersecs(self.values, tol = tolx, y = True)

            print self.corr_x_ints
            print "\n"*3
            print self.corr_y_ints
            print "\n"*3
            print self.corrstats
            print "\n"*3
            self.first = False
コード例 #3
0
    def btn_submit_click(self, **event_args):
        self.grid_stat.clear()
        self.grid_x_int.clear()
        self.grid_y_int.clear()
        self.lbl_mark.background = "#fff"

        if len(self.all) > 0:
            draw.clear_canvas(self.canvas, "#fff")


            self.newvalues = self.gauss_blur(self.all)

            mark = self.check()*100
            #self.lbl_mark.text = str(repr(mark)) + "%"


            # colour = "#198dbf"
            # if mark >self.pass_mark:
            #     self.lbl_mark.text += "\nWell done!"
            # else:
            #     colour = "#fff"
            #     self.lbl_mark.text += "\nScore  over {0}% to pass".format(self.pass_mark)

            #self.graph.plot()

            self.graph2 = draw.graph_plot(self.canvas, self.newvalues)
            self.graph2.axes_enabled = True
            self.graph2.markers_enabled = False
            self.graph2.xlabel = self.xlabel
            self.graph2.ylabel = self.ylabel
            self.graph2.xrange = self.graph.xrange
            self.graph2.yrange = self.graph.yrange
            self.graph2.plot(colour = "rgb(214, 106, 72)", xmarker = self.xmarker, ymarker = self.ymarker)


            # diffd = self.gauss_blur([diffd],10)
            # self.graph3 = draw.graph_plot(self.canvas, diffd)
            # self.graph3.axes_enabled = False
            # self.graph3.xlabel = self.graph2.xlabel
            # self.graph3.ylabel = self.graph2.ylabel
            # self.graph3.xrange = self.graph2.xrange
            # self.graph3.yrange = self.graph2.yrange
            # #self.graph3.plot()
            #
            # diffd2 = physics.diff_5(diffd)
            # diffd2 = self.gauss_blur([diffd2],10)
            # self.graph4 = draw.graph_plot(self.canvas, diffd2)
            # self.graph4.axes_enabled = False
            # self.graph4.xlabel = self.graph2.xlabel
            # self.graph4.ylabel = self.graph2.ylabel
            # self.graph4.xrange = self.graph2.xrange
            # self.graph4.yrange = self.graph2.yrange
            #self.graph4.plot(colour = "rgb(52, 195, 96)")

            self.graph2.circle_points(zip(self.test_x_ints, [0]*len(self.test_x_ints)), "#336888")
            self.graph2.circle_points(zip([0]*len(self.test_y_ints), self.test_y_ints), "#D69648", pointoffset = len(self.test_x_ints))
            self.graph2.circle_points(self.teststats, "#339664", pointoffset = len(self.test_x_ints) + len(self.test_y_ints))
コード例 #4
0
    def timer_tick (self, **event_args):
        canvas = self.canvas
        self.cw = canvas.get_width()
        self.ch = canvas.get_height()
        cw = self.cw
        ch = self.ch

        if self.first:
            self.fill_up()
            self.graph = draw.graph_plot(canvas, self.values)
            self.graph.axes_enabled = True
            if self.set_xrange != [None, None]:
                self.graph.xrange = self.set_xrange
            if self.set_yrange != [None, None]:
                self.graph.yrange = self.set_yrange
            self.graph.xlabel = self.xlabel
            self.graph.ylabel = self.ylabel
            self.graph.plot(colour = "#fff", xmarker = self.xmarker, ymarker = self.ymarker)
            self.first = False
コード例 #5
0
    def timer_tick (self, **event_args):
        canvas = self.canvas
        self.cw = canvas.get_width()
        self.ch = canvas.get_height()
        cw = self.cw
        ch = self.ch

        if self.first:
            self.fill_up()
            self.graph = draw.graph_plot(canvas, self.values)
            self.graph.markers_enabled = False
            if self.set_xrange != [None, None]:
                self.graph.xrange = self.set_xrange
            if self.set_yrange != [None, None]:
                self.graph.yrange = self.set_yrange
            self.graph.xlabel = self.xlabel
            self.graph.ylabel = self.ylabel
            self.graph.plot(colour = "#fff", xmarker = self.xmarker, ymarker = self.ymarker)
            self.first = False
コード例 #6
0
    def draw_slit_int(self, N, d, a, wav, choice="slits"):
        canvas = self.canvas
        x_stp = self.x_stp
        x = []
        fx = []
        for i in range(int(float(self.W) / x_stp)):
            x.append(i * x_stp - float(self.W) / 2)
            ang = math.asin((x[i]) / self.R)
            if choice == "slits":
                fx.append(self.slit_int(N, d, wav, ang))
            else:
                fx.append(self.single_int(a, wav, ang))

        graph = draw.graph_plot(canvas, zip(x, fx))
        graph.yrange[0] = 0
        graph.xlabel = "x/m"
        graph.ylabel = "I"
        graph.axes_enabled = False
        graph.plot()
        draw.reset2(canvas, self.xu)
コード例 #7
0
    def draw_slit_int(self, N, d, a, wav, choice = "slits"):
        canvas = self.canvas
        x_stp = self.x_stp
        x = []
        fx = []
        for i in range(int(float(self.W)/x_stp)):
            x.append(i*x_stp- float(self.W)/2)
            ang = math.asin((x[i] )/self.R)
            if choice =="slits":
                fx.append(self.slit_int(N,d,wav,ang))
            else:
                fx.append(self.single_int(a,wav,ang))

        graph = draw.graph_plot(canvas,zip(x,fx))
        graph.yrange[0] = 0
        graph.xlabel = "x/m"
        graph.ylabel = "I"
        graph.axes_enabled = False
        graph.plot()
        draw.reset2(canvas, self.xu)
コード例 #8
0
    def btn_submit_click(self, **event_args):
        if len(self.newvalues) > 0:
            draw.clear_canvas(self.canvas, "#fff")

            if self.check_blur.checked:
                self.newvalues = self.gauss_blur(self.newvalues)

            mark = self.check()*100
            self.lbl_mark.text = str(repr(mark)) + "%"
            colour = "#198dbf"
            if mark >self.pass_mark:
                self.lbl_mark.text += "\nWell done!"
            else:
                colour = "#fff"
                self.lbl_mark.text += "\nScore  over {0}% to pass".format(self.pass_mark)
            self.graph.plot( xmarker = self.graph.xmarker/self.graph.xu, ymarker = self.graph.ymarker/self.graph.yu, colour = colour)

            self.graph2 = draw.graph_plot(self.canvas, self.newvalues)
            self.graph2.axes_enabled = False
            self.graph2.xlabel = self.xlabel
            self.graph2.ylabel = self.ylabel
            self.graph2.xrange = self.graph.xrange
            self.graph2.yrange = self.graph.yrange
            self.graph2.plot(colour = "rgb(214, 106, 72)", xmarker = self.graph.xmarker/self.graph.xu, ymarker = self.graph.ymarker/self.graph.yu)
コード例 #9
0
    def btn_submit_click(self, **event_args):
        if len(self.all) > 0:
            draw.clear_canvas(self.canvas, "#fff")


            self.newvalues = graphs.gauss_blur(self.all)

            tolx  = 100/self.graph.xu
            toly = 100/self.graph.yu

            self.teststats = find_stationary(self.newvalues, tol = toly)
            self.test_x_ints = find_intersecs(self.newvalues, tol = toly, x = True)
            self.test_y_ints = find_intersecs(self.newvalues, tol = tolx, y = True)

            self.lbl_mark.text = ""
            numbers = True


            if len(self.corrstats) != len(self.teststats):
                self.lbl_mark.text += "Wrong number of stationary points"
                self.lbl_mark.background = self.error_red
                numbers = False

            if len(self.corr_x_ints) != len(self.test_x_ints):
                self.lbl_mark.text += "\nWrong number of x intersections"
                self.lbl_mark.background = self.error_red
                numbers = False

            if len(self.corr_y_ints) != len(self.test_y_ints):
                self.lbl_mark.text += "\nWrong number of y intersections"
                self.lbl_mark.background = self.error_red
                numbers = False

            if numbers:
                xquads = False
                yquads = False
                statquads = False
                for i in range(len(self.test_x_ints)):
                    test = self.test_x_ints[i]
                    corr = self.corr_x_ints[i]
                    if test*corr<=0:
                        xquads = True

                for i in range(len(self.test_y_ints)):
                    test = self.test_y_ints[i]
                    corr = self.corr_y_ints[i]
                    if test*corr<=0:
                        yquads = True

                for i in range(len(self.teststats)):
                    test = self.teststats[i]
                    corr = self.corrstats[i]

                    if test[0]*corr[0]<=0 or test[1]*corr[1]<=0:
                        statquads = True

                if xquads or yquads or statquads:
                    self.lbl_mark.background = self.error_red
                    if xquads:
                        self.lbl_mark.text += "\nWrong sign for x Intersection(s)"
                    if yquads:
                        self.lbl_mark.text += "\nWrong sign for y Intersection(s)"
                    if statquads:
                        self.lbl_mark.text += "\nStationary point(s) in wrong quadrant"
                else:
                    mark = self.check()*100
                    self.lbl_mark.text = "{0}%".format(round(score))

                    self.lbl_mark.background = "#fff"

                    #TODO pass mark checking
                    if score >self.pass_mark:
                        self.lbl_mark.text += "\nWell done!"
                    else:
                        self.lbl_mark.text += "\nScore  over {0}% to pass".format(self.pass_mark)

                    self.graph2 = draw.graph_plot(self.canvas, self.newvalues)
                    self.graph2.axes_enabled = True
                    self.graph2.xlabel = self.xlabel
                    self.graph2.ylabel = self.ylabel
                    self.graph2.xrange = self.graph.xrange
                    self.graph2.yrange = self.graph.yrange
                    self.graph2.plot(colour = self.draw_colour, xmarker = self.xmarker, ymarker = self.ymarker)