コード例 #1
0
ファイル: read.py プロジェクト: zoidy/puq
    def __init__(self, parent, callback):
        self.callback = callback

        # create a popup menu
        self.aMenu = Menu(root, tearoff=0)
        for color in sq_colors:
            self.aMenu.add_command(image=sq_image(color), command=lambda c=color: self.callback(c))

        # attach popup to frame
        parent.bind("<Button-1>", self.popup)
コード例 #2
0
ファイル: read.py プロジェクト: wang159/puq
    def __init__(self, parent, callback):
        self.callback = callback

        # create a popup menu
        self.aMenu = Menu(root, tearoff=0)
        for color in sq_colors:
            self.aMenu.add_command(image=sq_image(color), command=lambda c=color: self.callback(c))

        # attach popup to frame
        parent.bind("<Button-1>", self.popup)
コード例 #3
0
ファイル: read.py プロジェクト: zoidy/puq
 def color_changed(self, color):
     self.color = color
     self.changed()
     if self.nb:
         self.nb.tab(self.tnum,image=sq_image(color))
     self.clab.config(image=sq_image(color))
コード例 #4
0
ファイル: read.py プロジェクト: zoidy/puq
    def __init__(self, parent, obj, plotframe, nb=None, color=None, desc=None):
        #print "PdfFrameSimple Init"
        self.plotframe = plotframe
        self.a = plotframe.get_plot()

        self.nb = nb
        if nb:
            self.tnum = color
        color = self.get_color(color)

        bframe = Frame(parent)
        lframe = Frame(bframe, bd=1)
        rframe = Frame(bframe)

        self.show = IntVar(value=1)
        if nb:
            if desc:
                tframe = Frame(bframe)
                Label(tframe, text=desc, font=Font(weight="bold")).pack(fill=X, expand=1)
                tframe.pack(side=TOP, fill=X, expand=0)

            c = Checkbutton(lframe, variable=self.show, command=self.cb)
            c.pack()
            tool1 = ToolTip(c, follow_mouse=1, text='Show Plot')

        img = sq_image(color)
        self.clab = Label(lframe, text='  ', image=img)
        self.clab.photo = img
        self.clab.bind("<Button-1>", self.popup)
        cp = ColorPop(self.clab, callback=self.color_changed)
        tool2 = ToolTip(self.clab, follow_mouse=1, text='Select Plot Color')
        self.clab.pack(fill=X, expand=1)

        if isinstance(obj, PDF):
            self.par = None
            self.pdf = obj
        else:
            self.par = obj
            self.pdf = obj.pdf

        self.min = None
        self.max = None
        self.pdf_orig = self.pdf

        self.color = color
        self.line2, = self.a.plot(self.pdf.x, self.pdf.y, color=self.color, linewidth=3)

        # BOTTOM RIGHT
        frame3 = Frame(rframe)
        if self.par:
            frame1 = Frame(rframe)
            MyLabel(frame1, 'Type', self.par.__class__.__name__, bg='white').frame.pack(side=LEFT, padx=5)
        self.mean = MyLabel(frame3, "Mean", '%.3g' % self.pdf.mean)
        self.dev = MyLabel(frame3, "Dev", '%.3g' % self.pdf.dev)
        self.mode = MyLabel(frame3, "Mode", '%.3g' % self.pdf.mode)
        for lab in [self.mean, self.dev, self.mode]:
            lab.frame.pack(side=LEFT, padx=5)
        self.entry_min = MyEntry(frame3, "Min", StringVar(), '%.3g' % self.pdf.range[0], callback=self.min_changed)
        self.entry_max = MyEntry(frame3, "Max", StringVar(), '%.3g' % self.pdf.range[1], callback=self.max_changed)
        if self.par:
            frame1.pack(side=TOP, anchor='nw', fill=BOTH, expand=1)
        frame3.pack(side=BOTTOM, anchor='nw', fill=BOTH, expand=1)

        lframe.pack(side=LEFT, fill=X, expand=0)
        rframe.pack(side=RIGHT, fill=X, expand=1)
        bframe.pack(side=TOP, fill=X, expand=0)
コード例 #5
0
ファイル: read.py プロジェクト: zoidy/puq
    def __init__(self, parent, obj, plotframe, nb=None, color=None, desc=None):
        #print "PdfFrameComplex Init"
        self.plotframe = plotframe
        self.a = plotframe.get_plot()

        self.nb = nb
        if nb:
            self.tnum = color
        color = self.get_color(color)

        bframe = Frame(parent)
        lframe = Frame(bframe)
        rframe = Frame(bframe)

        self.show = IntVar(value=1)
        self.bars = IntVar(value=0)
        cframe = LabelFrame(bframe)

        # add color selector and show to details
        if nb:
            if desc:
                tframe = Frame(bframe)
                Label(tframe, text=desc, font=Font(weight="bold")).pack(side=TOP, fill=BOTH, expand=1)
            c1 = Checkbutton(cframe, variable=self.show, command=self.cb, pady=5, text='Show')
            c1.pack(fill=BOTH, expand=1)
            ToolTip(c1, follow_mouse=1, text='Show Plot')

        img = sq_image(color)
        self.clab = Label(cframe, image=img)
        self.clab.photo = img
        self.clab.bind("<Button-1>", self.popup)
        self.clab.pack(fill=BOTH, expand=1)
        ToolTip(self.clab, follow_mouse=1, text='Select Plot Color')

        c2 = Checkbutton(cframe, variable=self.bars, command=self.cb, pady=5, text='Bars')
        c2.pack(fill=BOTH, expand=1)
        ToolTip(c2, follow_mouse=1, text='Show Histogram Bars')
        cp = ColorPop(self.clab, callback=self.color_changed)

        if isinstance(obj, PDF):
            self.par = None
            self.pdf = obj
        else:
            self.pdf = obj.pdf
            self.par = obj

        self.data = self.pdf.data
        self.fit = False

        kde = gaussian_kde(self.data)
        bw = kde.factor
        self.bw = None

        iqr = scipy.stats.scoreatpercentile(self.data, 75) - scipy.stats.scoreatpercentile(self.data, 25)
        if iqr == 0.0:
            self.nbins=50
        else:
            self.nbins = int((np.max(self.data) - np.min(self.data)) / (2*iqr/len(self.data)**(1.0/3)) + .5)
            self.nbins = max(2, self.nbins)

        self.min = None
        self.max = None

        pdf = self.pdf

        self.color = color

        if self.bars.get():
            self.line1 = self.a.hist(self.data, self.nbins, normed=1, facecolor=self.color, alpha=0.2)

        if self.show.get():
            self.line2, = self.a.plot(pdf.x, pdf.y, color=color, linewidth=3)

        # BOTTOM RIGHT - FIT FRAME
        fitframe = LabelFrame(rframe, text="FIT")
        RB(fitframe, ["Gaussian", "Linear"], val=self.fit, callback=self.fit_changed)

        # Bandwidth frame
        bwframe = LabelFrame(fitframe, text='Bandwidth', padx=5, pady=5)
        res = 10**round(math.log(bw/100.0, 10))
        r1 = round(bw / 10.0)
        if r1 == 0.0:
            r1 += res
        r2 = round(bw * 10.0)
        self.bwscale = Scale(bwframe, from_=r1, to=r2, orient=HORIZONTAL,
            resolution=res, showvalue=0, command=self.bw_changed)
        self.bwscale.set(bw)
        self.bwscale.config(command=self.bw_changed)
        self.bwe = Entry(bwframe, width=5)
        self.bwe.bind('<Return>', self.bw_changed)
        self.bwe.pack(side=LEFT)
        self.bwscale.set(bw)
        self.bwe.delete(0, END)
        self.bwe.insert(0, "%.3g" % bw)
        self.bwscale.pack(fill=BOTH, expand=True, side=LEFT)

        # Bin frame
        binframe = LabelFrame(fitframe, text='Bins', padx=5, pady=5)
        self.binscale = Scale(binframe, from_=2, to=100, orient=HORIZONTAL,
            resolution=1, showvalue=0)
        self.binscale.set(self.nbins)
        self.binscale.config(command=self.bins_changed)
        self.bine = Entry(binframe, width=5)
        self.bine.bind('<Return>', self.bins_changed)
        self.bine.pack(side=LEFT)
        self.bine.delete(0, END)
        self.bine.insert(0, str(self.nbins))
        self.binscale.pack(fill=BOTH, expand=True, side=LEFT)
        bwframe.pack(side=TOP, fill=BOTH, expand=True)
        binframe.pack(side=TOP, fill=BOTH, expand=True)

        self.bwscale.config(state='disabled')
        self.bwe.config(state='disabled')

        fitframe.pack(side=RIGHT, fill=BOTH, expand=1)

        # Bottom Left Frame
        fdata = LabelFrame(lframe, text='Raw Data', padx=5, pady=5)
        f1 = Frame(fdata)
        f2 = Frame(fdata)
        MyLabel(f1, "Mean", '%.3g' % np.mean(self.data)).frame.pack(side=LEFT, padx=5)
        MyLabel(f1, "Dev", '%.3g' % np.std(self.data)).frame.pack(side=LEFT, padx=5)
        MyLabel(f2, "Min", '%.3g' % np.min(self.data)).frame.pack(side=LEFT, padx=5)
        MyLabel(f2, "Max", '%.3g' % np.max(self.data)).frame.pack(side=LEFT, padx=5)
        fpdf = LabelFrame(lframe, text='Fitted PDF', padx=5, pady=5)
        f1.pack(side=TOP, pady = 5, padx = 10, fill=BOTH)
        f2.pack(side=TOP, pady = 5, padx = 10, fill=BOTH)

        f1 = Frame(fpdf)
        f2 = Frame(fpdf)
        self.entry_min = MyEntry(f2, "Min", StringVar(), '%.3g' % pdf.range[0], callback=self.min_changed)
        self.entry_max = MyEntry(f2, "Max", StringVar(), '%.3g' % pdf.range[1], callback=self.max_changed)
        self.label_mean = MyLabel(f1, "Mean", '%.3g' % pdf.mean)
        self.label_dev = MyLabel(f1, "Dev", '%.3g' % pdf.dev)
        self.label_mode = MyLabel(f1, "Mode", '%.3g' % pdf.mode)

        for lab in [self.label_mean, self.label_dev, self.label_mode]:
            lab.frame.pack(side=LEFT, padx=5)
        f1.pack(side=TOP, pady = 5, padx = 10, fill=BOTH)
        f2.pack(side=TOP, pady = 5, padx = 10, fill=BOTH)

        fdata.pack(side=TOP, fill=BOTH)
        fpdf.pack(side=TOP, fill=BOTH)

        if nb and desc:
            tframe.pack(side=TOP, fill=BOTH, expand=0)
        cframe.pack(side=LEFT, fill=BOTH, expand=0)

        lframe.pack(side=LEFT, fill=BOTH, expand=1)
        rframe.pack(side=RIGHT, fill=BOTH, expand=1)
        bframe.pack(side=TOP, fill=BOTH, expand=1)
コード例 #6
0
ファイル: read.py プロジェクト: wang159/puq
 def color_changed(self, color):
     self.color = color
     self.changed()
     if self.nb:
         self.nb.tab(self.tnum,image=sq_image(color))
     self.clab.config(image=sq_image(color))
コード例 #7
0
ファイル: read.py プロジェクト: wang159/puq
    def __init__(self, parent, obj, plotframe, nb=None, color=None, desc=None):
        #print "PdfFrameSimple Init"
        self.plotframe = plotframe
        self.a = plotframe.get_plot()

        self.nb = nb
        if nb:
            self.tnum = color
        color = self.get_color(color)

        bframe = Frame(parent)
        lframe = Frame(bframe, bd=1)
        rframe = Frame(bframe)

        self.show = IntVar(value=1)
        if nb:
            if desc:
                tframe = Frame(bframe)
                Label(tframe, text=desc, font=Font(weight="bold")).pack(fill=X, expand=1)
                tframe.pack(side=TOP, fill=X, expand=0)

            c = Checkbutton(lframe, variable=self.show, command=self.cb)
            c.pack()
            tool1 = ToolTip(c, follow_mouse=1, text='Show Plot')

        img = sq_image(color)
        self.clab = Label(lframe, text='  ', image=img)
        self.clab.photo = img
        self.clab.bind("<Button-1>", self.popup)
        cp = ColorPop(self.clab, callback=self.color_changed)
        tool2 = ToolTip(self.clab, follow_mouse=1, text='Select Plot Color')
        self.clab.pack(fill=X, expand=1)

        if isinstance(obj, PDF):
            self.par = None
            self.pdf = obj
        else:
            self.par = obj
            self.pdf = obj.pdf

        self.min = None
        self.max = None
        self.pdf_orig = self.pdf

        self.color = color
        self.line2, = self.a.plot(self.pdf.x, self.pdf.y, color=self.color, linewidth=3)

        # BOTTOM RIGHT
        frame3 = Frame(rframe)
        if self.par:
            frame1 = Frame(rframe)
            MyLabel(frame1, 'Type', self.par.__class__.__name__, bg='white').frame.pack(side=LEFT, padx=5)
        self.mean = MyLabel(frame3, "Mean", '%.3g' % self.pdf.mean)
        self.dev = MyLabel(frame3, "Dev", '%.3g' % self.pdf.dev)
        self.mode = MyLabel(frame3, "Mode", '%.3g' % self.pdf.mode)
        for lab in [self.mean, self.dev, self.mode]:
            lab.frame.pack(side=LEFT, padx=5)
        self.entry_min = MyEntry(frame3, "Min", StringVar(), '%.3g' % self.pdf.range[0], callback=self.min_changed)
        self.entry_max = MyEntry(frame3, "Max", StringVar(), '%.3g' % self.pdf.range[1], callback=self.max_changed)
        if self.par:
            frame1.pack(side=TOP, anchor='nw', fill=BOTH, expand=1)
        frame3.pack(side=BOTTOM, anchor='nw', fill=BOTH, expand=1)

        lframe.pack(side=LEFT, fill=X, expand=0)
        rframe.pack(side=RIGHT, fill=X, expand=1)
        bframe.pack(side=TOP, fill=X, expand=0)
コード例 #8
0
ファイル: read.py プロジェクト: wang159/puq
    def __init__(self, parent, obj, plotframe, nb=None, color=None, desc=None):
        #print "PdfFrameComplex Init"
        self.plotframe = plotframe
        self.a = plotframe.get_plot()

        self.nb = nb
        if nb:
            self.tnum = color
        color = self.get_color(color)

        bframe = Frame(parent)
        lframe = Frame(bframe)
        rframe = Frame(bframe)

        self.show = IntVar(value=1)
        self.bars = IntVar(value=0)
        cframe = LabelFrame(bframe)

        # add color selector and show to details
        if nb:
            if desc:
                tframe = Frame(bframe)
                Label(tframe, text=desc, font=Font(weight="bold")).pack(side=TOP, fill=BOTH, expand=1)
            c1 = Checkbutton(cframe, variable=self.show, command=self.cb, pady=5, text='Show')
            c1.pack(fill=BOTH, expand=1)
            ToolTip(c1, follow_mouse=1, text='Show Plot')

        img = sq_image(color)
        self.clab = Label(cframe, image=img)
        self.clab.photo = img
        self.clab.bind("<Button-1>", self.popup)
        self.clab.pack(fill=BOTH, expand=1)
        ToolTip(self.clab, follow_mouse=1, text='Select Plot Color')

        c2 = Checkbutton(cframe, variable=self.bars, command=self.cb, pady=5, text='Bars')
        c2.pack(fill=BOTH, expand=1)
        ToolTip(c2, follow_mouse=1, text='Show Histogram Bars')
        cp = ColorPop(self.clab, callback=self.color_changed)

        if isinstance(obj, PDF):
            self.par = None
            self.pdf = obj
        else:
            self.pdf = obj.pdf
            self.par = obj

        self.data = self.pdf.data
        self.fit = False

        kde = gaussian_kde(self.data)
        bw = kde.factor
        self.bw = None

        iqr = scipy.stats.scoreatpercentile(self.data, 75) - scipy.stats.scoreatpercentile(self.data, 25)
        if iqr == 0.0:
            self.nbins=50
        else:
            self.nbins = int((np.max(self.data) - np.min(self.data)) / (2*iqr/len(self.data)**(1.0/3)) + .5)
            self.nbins = max(2, self.nbins)

        self.min = None
        self.max = None

        pdf = self.pdf

        self.color = color

        if self.bars.get():
            self.line1 = self.a.hist(self.data, self.nbins, normed=1, facecolor=self.color, alpha=0.2)

        if self.show.get():
            self.line2, = self.a.plot(pdf.x, pdf.y, color=color, linewidth=3)

        # BOTTOM RIGHT - FIT FRAME
        fitframe = LabelFrame(rframe, text="FIT")
        RB(fitframe, ["Gaussian", "Linear"], val=self.fit, callback=self.fit_changed)

        # Bandwidth frame
        bwframe = LabelFrame(fitframe, text='Bandwidth', padx=5, pady=5)
        res = 10**round(math.log(bw/100.0, 10))
        r1 = round(bw / 10.0)
        if r1 == 0.0:
            r1 += res
        r2 = round(bw * 10.0)
        self.bwscale = Scale(bwframe, from_=r1, to=r2, orient=HORIZONTAL,
            resolution=res, showvalue=0, command=self.bw_changed)
        self.bwscale.set(bw)
        self.bwscale.config(command=self.bw_changed)
        self.bwe = Entry(bwframe, width=5)
        self.bwe.bind('<Return>', self.bw_changed)
        self.bwe.pack(side=LEFT)
        self.bwscale.set(bw)
        self.bwe.delete(0, END)
        self.bwe.insert(0, "%.3g" % bw)
        self.bwscale.pack(fill=BOTH, expand=True, side=LEFT)

        # Bin frame
        binframe = LabelFrame(fitframe, text='Bins', padx=5, pady=5)
        self.binscale = Scale(binframe, from_=2, to=100, orient=HORIZONTAL,
            resolution=1, showvalue=0)
        self.binscale.set(self.nbins)
        self.binscale.config(command=self.bins_changed)
        self.bine = Entry(binframe, width=5)
        self.bine.bind('<Return>', self.bins_changed)
        self.bine.pack(side=LEFT)
        self.bine.delete(0, END)
        self.bine.insert(0, str(self.nbins))
        self.binscale.pack(fill=BOTH, expand=True, side=LEFT)
        bwframe.pack(side=TOP, fill=BOTH, expand=True)
        binframe.pack(side=TOP, fill=BOTH, expand=True)

        self.bwscale.config(state='disabled')
        self.bwe.config(state='disabled')

        fitframe.pack(side=RIGHT, fill=BOTH, expand=1)

        # Bottom Left Frame
        fdata = LabelFrame(lframe, text='Raw Data', padx=5, pady=5)
        f1 = Frame(fdata)
        f2 = Frame(fdata)
        MyLabel(f1, "Mean", '%.3g' % np.mean(self.data)).frame.pack(side=LEFT, padx=5)
        MyLabel(f1, "Dev", '%.3g' % np.std(self.data)).frame.pack(side=LEFT, padx=5)
        MyLabel(f2, "Min", '%.3g' % np.min(self.data)).frame.pack(side=LEFT, padx=5)
        MyLabel(f2, "Max", '%.3g' % np.max(self.data)).frame.pack(side=LEFT, padx=5)
        fpdf = LabelFrame(lframe, text='Fitted PDF', padx=5, pady=5)
        f1.pack(side=TOP, pady = 5, padx = 10, fill=BOTH)
        f2.pack(side=TOP, pady = 5, padx = 10, fill=BOTH)

        f1 = Frame(fpdf)
        f2 = Frame(fpdf)
        self.entry_min = MyEntry(f2, "Min", StringVar(), '%.3g' % pdf.range[0], callback=self.min_changed)
        self.entry_max = MyEntry(f2, "Max", StringVar(), '%.3g' % pdf.range[1], callback=self.max_changed)
        self.label_mean = MyLabel(f1, "Mean", '%.3g' % pdf.mean)
        self.label_dev = MyLabel(f1, "Dev", '%.3g' % pdf.dev)
        self.label_mode = MyLabel(f1, "Mode", '%.3g' % pdf.mode)

        for lab in [self.label_mean, self.label_dev, self.label_mode]:
            lab.frame.pack(side=LEFT, padx=5)
        f1.pack(side=TOP, pady = 5, padx = 10, fill=BOTH)
        f2.pack(side=TOP, pady = 5, padx = 10, fill=BOTH)

        fdata.pack(side=TOP, fill=BOTH)
        fpdf.pack(side=TOP, fill=BOTH)

        if nb and desc:
            tframe.pack(side=TOP, fill=BOTH, expand=0)
        cframe.pack(side=LEFT, fill=BOTH, expand=0)

        lframe.pack(side=LEFT, fill=BOTH, expand=1)
        rframe.pack(side=RIGHT, fill=BOTH, expand=1)
        bframe.pack(side=TOP, fill=BOTH, expand=1)