Beispiel #1
0
def main(argv):
    global Status

    Status = global_options()

    # main window
    root = Tk()
    root.title("View Data")

    # setup interface
    # 2 windows, one control, one plot
    plot = Toplevel()
    plot.title("Plot")
    Status.plot = plot

    bg = "black"

    Status.plot_G = tkplot.tkplot(plot, 300, 500, "white", "black")
    Status.plot_tilt = tkplot.tkplot(plot, 150, 500, "white", "black")
    Status.plot_T = tkplot.tkplot(plot, 150, 500, "white", "black")
    Status.plot_E = tkplot.tkplot(plot, 150, 500, "white", "black")

    #  setup labels, etc.
    Status.plot_G.xlabeltype = "time"
    Status.plot_tilt.xlabeltype = "time"
    Status.plot_T.xlabeltype = "time"
    Status.plot_E.xlabeltype = "time"
    Status.plot_E.xlabel = "Time since station start"

    Status.plot_G.ylabel = "dG (mGal)"
    Status.plot_tilt.ylabel = "Tilt (arcsec)"
    Status.plot_T.ylabel = "Temperature (mK)"
    Status.plot_E.ylabel = "ETC (mGal)"

    bg = "white"
    fg = "black"

    #   create control window
    title_F = Frame(root, relief=RIDGE, borderwidth=2, background=bg)
    Label(title_F, text="Control Panel", foreground=fg, background=bg).grid()
    title_F.grid(sticky=E + W)

    jump_F = Frame(root, relief=RIDGE, borderwidth=2, background=bg)
    jump_F.grid(sticky=E + W)
    Label(jump_F, text="Jump to Station", foreground=fg,
          background=bg).grid(columnspan=2, row=0)
    Status.jumpValue = StringVar()
    Entry(jump_F,
          textvariable=Status.jumpValue,
          width=6,
          background=bg,
          foreground=fg).grid(row=1, column=0, sticky=W)
    Button(jump_F, command=jump_cb, text="Find", background=bg,
           foreground=fg).grid(row=1, column=1, sticky=E)

    button_F = Frame(root, relief=RIDGE, borderwidth=2, background=bg)
    button_F.grid(sticky=E + W)
    Label(button_F, text="Previous/Next Station", background=bg,
          foreground=fg).grid(columnspan=2, row=0)
    Button(button_F, command=prev_cb, text="<--", background=bg,
           foreground=fg).grid(row=1, column=0, sticky=W)
    Button(button_F, command=next_cb, text="-->", background=bg,
           foreground=fg).grid(row=1, column=1, sticky=E)

    button_F2 = Frame(root, relief=FLAT, background=bg)
    button_F2.grid(sticky=E + W)
    Button(button_F2,
           command=quit_cb,
           text="Quit",
           background=bg,
           foreground=fg).grid(row=2, column=0, sticky=W)
    Button(button_F2,
           command=print_cb,
           text="Save",
           background=bg,
           foreground=fg).grid(row=2, column=1, sticky=E)

    # get data filename
    if len(argv) > 1:
        data_file = argv[1]
        try:
            Status.data = cg5file.get_cg5_data(data_file)
        except:
            data_file = tkFileDialog.askopenfilename(
                parent=root,
                title="CG-5M data file",
                initialdir=".",
                filetypes=(("Text CG-5M files", "*.txt"), ("All files", "*")))
            if not data_file:
                print "Must enter a filename!"
                sys.exit(0)
            try:
                Status.data = cg5file.get_cg5_data(data_file)
            except:
                print "Cannot process file %s!" % data_file
                sys.exit(0)

    else:
        data_file = tkFileDialog.askopenfilename(
            parent=root,
            title="CG-5M data file",
            initialdir=".",
            filetypes=(("Text CG-5M files", "*.txt"), ("All files", "*")))
        if not data_file:
            print "Must enter a filename!"
            sys.exit(0)
        try:
            Status.data = cg5file.get_cg5_data(data_file)
        except:
            print "Cannot process file %s!" % data_file
            sys.exit(0)

    F = string.split(data_file, "/")
    Status.data_file = F[-1]
    del data_file

    # convert to relative time
    start = grav_util.calc_relative_date(Status.data)

    # create list of sorted unique ids
    ids = {}
    for i in range(len(Status.data)):
        if not ids.has_key(Status.data[i].station_id):
            ids[Status.data[i].station_id] = 1

    Status.ids = ids.keys()
    Status.ids.sort(grav_util.num_sort)

    Status.index = 0
    Status.current_id = Status.ids[Status.index]
    Status.jumpValue.set(Status.current_id)

    Status.plot.bind("<Configure>", resize)

    plot_cb()

    # go
    root.mainloop()
Beispiel #2
0
def ekvfit(Vg, Isat, epsilon=0.001, **kwargs):
    '''
    EKVFIT Attempts to fit a simplified EKV model to (VG, ISAT) pairs.
    EKVFIT(VG, ISAT, EPSILON) attempts to fit a simplified EKV model for
    the saturation region of MOS transistor operation to measured values
    of gate voltage (specified in VG) and channel current (specified in
    ISAT).  The assumed form of the model is

        ISAT = Is * (log(1 + exp(kappa*(VG - VT)/(2*0.0258)))).^2

    The return values are [Is, VT, kappa].  EKVFIT makes use of LINEFIT.
    First, it attempts to find parameters for the weak-inversion region by
    using LINEFIT on VG and log(ISAT).  Then, it attepts to find
    parameters for the strong-inversion region by using LINEFIT on VG and
    sqrt(ISAT).  It then uses the x-axis intercept from the
    strong-inversion fit as a starting value for VT and computes a
    starting value for IS via cubic-spline interpolation as twice the
    value of ISAT when VG = VT.  EKVFIT then attepts to find a the value
    of IS in the interval between one tenth the initial value of IS and
    ten times the inital value of IS that minimizes the curvature of the
    inverse EKV model applied to ISAT, given by

                     log(exp(sqrt(ISAT/Is)) - 1),

    when plotted as a function of VG, using the golden-section search.
    Once the best value of Is is found, EKVFIT uses LINEFIT to get the
    slope and intercept of the best-fit line to the EKV model inverse
    expression, given above, applied to ISAT versus VG.  The slope of this
    curve should be kappa/(2*UT) and the VG-axis intercept should be VT.

    See the LINEFIT docstring for an explanation of the EPSILON 
    parameter.
    '''
    if not isinstance(Vg, ndarray) or not isinstance(Isat, ndarray):
        raise TypeError('Vg and Isat must both be ndarrays')
    if len(Vg) != len(Isat):
        raise IndexError('Vg and Isat must have the same length')
    plotting = kwargs.get('plotting', 'off')
    WIepsilon = kwargs.get('WIepsilon', epsilon)
    SIepsilon = kwargs.get('SIepsilon', epsilon)
    if plotting not in ('on', 'off'):
        raise ValueError("if supplied, plotting must be either 'on' or 'off'")
    if plotting == 'on':
        fig = tkplot.tkplot()

    Is = 0
    VT = 0
    kappa = 0

    [WIfirst, WIlast, WIm, WIb, WIN] = linefit(Vg, log(Isat), WIepsilon)
    if WIN == 0:
        raise RuntimeError('could not find a weak-inversion region')
    elif plotting == 'on':
        fig.semilogy(Vg, Isat)
        temp = fig.ylimits()
        fig.semilogy(
            [Vg, array(Vg[WIfirst:WIlast + 1]), Vg],
            [Isat, array(Isat[WIfirst:WIlast + 1]),
             exp(WIm * Vg + WIb)], ['b.', 'r.', 'k-'])
        fig.ylimits(temp)
        fig.xlabel('VG (V)')
        fig.ylabel('Isat (A)')
        fig.ylabel('Weak-Inversion Fit', side='right')
        raw_input()
    if min(abs(array(Isat[WIfirst:WIlast + 1]))) > 1e-6:
        raise ValueError(
            'identified a candidate weak-inversion region, but all current levels exceed typical weak-inversion currents'
        )
    if max(abs(array(Isat[WIfirst:WIlast + 1]))) > 1e-6:
        print 'ValueWarning: identified a candidate weak-inversion region, but some current levels exceed typical weak-inversion currents'
#        warnings.warn('ValueWarning', 'identified a candidate weak-inversion region, but some current levels exceed typical weak-inversion currents')

    [SIfirst, SIlast, SIm, SIb, SIN] = linefit(Vg, sqrt(Isat), SIepsilon)
    if SIN == 0:
        raise RuntimeError('could not find a strong-inversion region')
    elif plotting == 'on':
        fig.plot(Vg, sqrt(abs(Isat)))
        temp = fig.ylimits()
        fig.plot([Vg, array(Vg[SIfirst:SIlast + 1]), Vg], [
            sqrt(abs(Isat)),
            sqrt(array(Isat[SIfirst:SIlast + 1])), SIm * Vg + SIb
        ], ['b.', 'r.', 'k-'])
        fig.ylimits(temp)
        fig.xlabel('VG (V)')
        fig.ylabel('sqrt(Isat) (sqrt(A))')
        fig.ylabel('Strong-Inversion Fit', side='right')
        raw_input()
    if max(abs(array(Isat[SIfirst:SIlast + 1]))) < 0.1e-6:
        raise ValueError(
            'identified a candidate strong-inversion region, but all current levels are lower than typical strong-inversion currents'
        )
    if min(abs(array(Isat[SIfirst:SIlast + 1]))) < 0.1e-6:
        print 'ValueWarning: identified a candidate strong-inversion region, but some current levels are lower than typical strong-inversion currents'
#        warnings.warn('ValueWarning', 'identified a candidate strong-inversion region, but some current levels are lower than typical strong-inversion currents')

    if SIfirst > WIlast:
        first = WIfirst
        last = SIlast
    elif WIfirst > SIlast:
        first = SIfirst
        last = WIlast
    else:
        raise RuntimeError(
            'weak-inversion and strong-inversion regions found were not disjoint'
        )

    VT = -SIb / SIm
    #    Is = 2*spline(array(Vg[first:last+1]), array(Isat[first:last+1]), VT)
    for i in range(first, last):
        if ((Vg[i] <= VT) and (Vg[i + 1] > VT)) or ((Vg[i + 1] <= VT) and
                                                    (Vg[i] > VT)):
            Is = 2 * (Isat[i] + (Isat[i + 1] - Isat[i]) * (VT - Vg[i]) /
                      (Vg[i + 1] - Vg[i]))
            break

    if Is == 0.:
        Is = 1e-6

    R = 0.61803399
    C = 1. - R
    tol = 1e-4

    x0 = 0.1 * Is
    x1 = Is
    x2 = (1. + 9. * C) * Is
    x3 = 10. * Is

    dVg = diff(array(Vg[first:last + 1]))
    temp = diff(log(exp(sqrt(array(Isat[first:last + 1]) / x1)) - 1)) / dVg
    f1 = std(temp) / mean(temp)
    temp = diff(log(exp(sqrt(array(Isat[first:last + 1]) / x2)) - 1)) / dVg
    f2 = std(temp) / mean(temp)

    while abs(x3 - x0) > tol * (abs(x1) + abs(x2)):
        if f2 < f1:
            x0 = x1
            x1 = x2
            x2 = R * x1 + C * x3
            f1 = f2
            temp = diff(
                log(exp(sqrt(array(Isat[first:last + 1]) / x2)) - 1)) / dVg
            f2 = std(temp) / mean(temp)
            if plotting == 'on':
                [EKVfirst, EKVlast, m, b, N] = linefit(
                    array(Vg[first:last + 1]),
                    log(exp(sqrt(array(Isat[first:last + 1]) / x2)) - 1),
                    epsilon)
                fig.plot(
                    [array(Vg[first:last + 1]),
                     array(Vg[first:last + 1])], [
                         log(exp(sqrt(array(Isat[first:last + 1]) / x2)) - 1),
                         m * array(Vg[first:last + 1]) + b
                     ], ['b.', 'k-'])
                fig.xlabel('VG (V)')
                fig.ylabel('log(exp(sqrt(Isat/Is))-1)')
                fig.ylabel('Optimizing Is = {0}A'.format(num2str(x2, 3)),
                           side='right')
                raw_input()
        else:
            x3 = x2
            x2 = x1
            x1 = R * x2 + C * x0
            f2 = f1
            temp = diff(
                log(exp(sqrt(array(Isat[first:last + 1]) / x1)) - 1)) / dVg
            f1 = std(temp) / mean(temp)
            if plotting == 'on':
                [EKVfirst, EKVlast, m, b, N] = linefit(
                    array(Vg[first:last + 1]),
                    log(exp(sqrt(array(Isat[first:last + 1]) / x1)) - 1),
                    epsilon)
                fig.plot(
                    [array(Vg[first:last + 1]),
                     array(Vg[first:last + 1])], [
                         log(exp(sqrt(array(Isat[first:last + 1]) / x1)) - 1),
                         m * array(Vg[first:last + 1]) + b
                     ], ['b.', 'k-'])
                fig.xlabel('VG (V)')
                fig.ylabel('log(exp(sqrt(Isat/Is))-1)')
                fig.ylabel('Optimizing Is = {0}A'.format(num2str(x1, 3)),
                           side='right')
                raw_input()

    Is = x1 if f1 < f2 else x2

    [EKVfirst, EKVlast, m, b,
     N] = linefit(array(Vg[first:last + 1]),
                  log(exp(sqrt(array(Isat[first:last + 1]) / Is)) - 1),
                  epsilon)
    VT = -b / m
    kappa = 2 * m * 0.0258
    if plotting == 'on':
        fig.semilogy(Vg, Isat)
        temp = fig.ylimits()
        fig.semilogy([Vg, array(Vg[first:last + 1]), Vg], [
            Isat,
            array(Isat[first:last + 1]), Is * (log(1 + exp(kappa * (Vg - VT) /
                                                           (2 * 0.0258))))**2
        ], ['b.', 'r.', 'k-'])
        fig.ylimits(temp)
        fig.xlabel('VG (V)')
        fig.ylabel('Isat (A)')
        fig.ylabel('EKV Fit: Is = {0}A, VT = {1!s}V, kappa = {2!s}'.format(
            num2str(Is, 3), round(VT, 3), round(kappa, 3)),
                   side='right')
        raw_input()
        fig.plot(Vg, sqrt(abs(Isat)))
        temp = fig.ylimits()
        fig.plot([Vg, array(Vg[first:last + 1]), Vg], [
            sqrt(abs(Isat)),
            sqrt(array(Isat[first:last + 1])),
            sqrt(Is * (log(1 + exp(kappa * (Vg - VT) / (2 * 0.0258))))**2)
        ], ['b.', 'r.', 'k-'])
        fig.ylimits(temp)
        fig.xlabel('VG (V)')
        fig.ylabel('sqrt(Isat) (sqrt(A))')
        fig.ylabel('EKV Fit: Is = {0!s}A, VT = {1!s}V, kappa = {2!s}'.format(
            num2str(Is, 3), round(VT, 3), round(kappa, 3)),
                   side='right')
        raw_input()
    return [Is, VT, kappa]
Beispiel #3
0
def correction(repeats, data, tares, options, window, write):
    global figures
    # 1) compute drift function, using tare matrix
    # 2) display dg vs. time
    # 3) display residual between repeats after computing drift
    # 4) allow entry of tare pts on plot
    # 5) go back to 1) until done, then break

    # mangle filename
    t = string.split(options["raw_file"], "/")
    fname = t[-1]
    del t
    timestamp = time.asctime(time.localtime(time.time()))

    figures.order = int(options["order"])
    figures.start_order = int(options["start_order"])
    if figures.order < 0:  # minimum of flat drift fn
        figures.order = 0
    figures.weighting = grav_util.Truth(options["weighted_drift"])

    # init figures.C to dummy value
    figures.C = [0.0]

    figures.repeats = repeats
    figures.data = data
    figures.tares = tares

    # flag to determine if we plot
    figures.window = window

    # save pointer to write() function
    figures.write = write

    # plot dg vs time and pre-/post-drift dG
    # 3 windows
    if figures.window:
        win1 = tkplot.Toplevel()
        win2 = tkplot.Toplevel()
        win3 = tkplot.Toplevel()
        win4 = tkplot.Toplevel()
        win5 = tkplot.Toplevel()

        win1.title("Instructions")
        win2.title("Figure 1")
        win3.title("Figure 2")
        win4.title("Figure 3")

        bg = "white"
        fg = "black"
        figure1 = tkplot.tkplot(win2, 600, 800, bg, fg)
        figure1.show()
        figure2 = tkplot.tkplot(win3, 600, 800, bg, fg)
        figure2.show()
        figure3 = tkplot.tkplot(win4, 600, 800, bg, fg)
        figure3.show()
        figure4 = tkplot.tkplot(win5, 600, 800, bg, fg)
        figure4.show()

        figures.fig1 = figure1
        figures.fig2 = figure2
        figures.fig3 = figure3
        figures.fig4 = figure4
        figures.win1 = win1

        # setup plot parameters
        figure1.title = "Drift Correction vs. Time\n%s\n%s" % (fname,
                                                               timestamp)
        figure1.xlabel = "Time (hrs)"
        figure1.xlabeltype = "time"
        figure1.ylabel = "Drift Correction (uGal)"
        figure1.nprec = 2

        figure2.title = "g-<g> BEFORE Drift Correction\n%s\n%s" % (fname,
                                                                   timestamp)
        figure2.xlabel = "Time (hrs)"
        figure2.xlabeltype = "time"
        figure2.ylabel = "dg (uGal)"
        figure2.nprec = 2

        figure3.title = "g-<g> AFTER Drift Correction\n%s\n%s" % (fname,
                                                                  timestamp)
        figure3.xlabel = "Time (hrs)"
        figure3.xlabeltype = "time"
        figure3.ylabel = "dg (uGal)"
        figure3.nprec = 2

        figure4.title = "Station Repeat Spans\n%s\n%s" % (fname, timestamp)
        figure4.xlabel = "Time (hrs)"
        figure4.xlabeltype = "time"
        figure4.ylabel = ""
        figure4.nprec = 0
        figure4.ytics(0)

        # create buttons in window 1
        labeltext = '    --- INSTRUCTIONS ---\n\
UPDATE - Updates the figures, recomputing the drift function and dG.\n\
SAVE - Sends a PostScript copy of all figures to disk with fixed filenames.\n\
TARE ENTRY - Enter a tare using the mouse in Figure 2.\n\
TARE EDIT - Edit the times and values of existing tares, or add new ones.\n\
DONE - Return to the text window and finish reduction\n'

        win1.configure(width=400, height=200)
        window_width = int(win1.cget("width"))
        label1 = tkplot.Label(win1,
                              text=labeltext,
                              wraplength=(window_width - 10),
                              justify="left")
        # create buttons, and pack it all here
        button1 = tkplot.Button(win1,
                                padx=5,
                                pady=5,
                                text="Update",
                                width=10,
                                height=1,
                                command=apply_cb)
        button2 = tkplot.Button(win1,
                                padx=5,
                                pady=5,
                                text="Save",
                                width=10,
                                height=1,
                                command=print_cb)
        button3 = tkplot.Button(win1,
                                padx=5,
                                pady=5,
                                text="Tare Entry",
                                width=10,
                                height=1,
                                command=tare_cb)
        button5 = tkplot.Button(win1,
                                padx=5,
                                pady=5,
                                text="Tare Edit",
                                width=10,
                                height=1,
                                command=edit_cb)
        button4 = tkplot.Button(win1,
                                padx=5,
                                pady=5,
                                text="Done",
                                width=6,
                                height=1,
                                command=done_cb)
        label1.grid(columnspan=2)
        button1.grid(row=1, column=0)
        button2.grid(row=1, column=1)
        button3.grid(row=2, column=0)
        button5.grid(row=2, column=1)
        button4.grid(row=3, columnspan=2)
        figures.label1 = label1
        figures.button3 = button3
        figures.button5 = button5

        apply_cb(None)
        if figures.window == 2:
            print_cb(None)
        else:
            win1.mainloop()
        win1.destroy()
        win2.destroy()
        win3.destroy()
        win4.destroy()
        win5.destroy()

    else:
        apply_cb(None)

    # reset nodrift_gravity to tare-corrected gravity
    for i in data.keys():
        data[i].nodrift_gravity = data[i].G

    return (figures.order, figures.C)
Beispiel #4
0
    def __init__(self, **kwargs):
        self.state_handler = None

        self.smu = smu.smu()
        if self.smu == None:
            print 'Could not find a USB Source/Measure Unit device.'

        self.background = '#CDCDCD'
        self.delay = 2

        self.root = kwargs.get('parent')
        if self.root == None:
            if __name__ != '__main__':
                self.root = tk.Toplevel(__main__.__root__)
            else:
                self.root = tk.Tk()
            self.root.configure(background=self.background)
            self.root.title('SMUtake')
            self.root.protocol('WM_DELETE_WINDOW', self.shut_down)

        self.function_options = ('SV/MI', 'SI/MV')
        self.primary_source_options = ('CH1', 'CH2')
        self.speed_accuracy_options = ('accurate', 'medium', 'fast')
        self.axes_options = ('linear', 'log')

        self.buffer_lengths = ((1, 1, 1), (1, 1, 1), (1, 1, 1), (1, 1, 1),
                               (5, 3, 1), (10, 5, 3))

        self.ch1_function_var = tk.StringVar()
        self.ch1_function_var.set(self.function_options[0])
        self.ch1_source_name_var = tk.StringVar()
        self.ch1_source_name_var.set('')
        self.ch1_source_values_var = tk.StringVar()
        self.ch1_source_values_var.set('')
        self.ch1_measurement_name_var = tk.StringVar()
        self.ch1_measurement_name_var.set('')
        self.ch1_measurement_auto_var = tk.IntVar()
        self.ch1_measurement_auto_var.set(1)
        self.ch1_measurement_plot_var = tk.IntVar()
        self.ch1_measurement_plot_var.set(0)

        self.ch2_function_var = tk.StringVar()
        self.ch2_function_var.set(self.function_options[0])
        self.ch2_source_name_var = tk.StringVar()
        self.ch2_source_name_var.set('')
        self.ch2_source_values_var = tk.StringVar()
        self.ch2_source_values_var.set('')
        self.ch2_measurement_name_var = tk.StringVar()
        self.ch2_measurement_name_var.set('')
        self.ch2_measurement_auto_var = tk.IntVar()
        self.ch2_measurement_auto_var.set(1)
        self.ch2_measurement_plot_var = tk.IntVar()
        self.ch2_measurement_plot_var.set(0)

        self.primary_source_var = tk.StringVar()
        self.primary_source_var.set(self.primary_source_options[0])

        self.speed_accuracy_var = tk.StringVar()
        self.speed_accuracy_var.set(self.speed_accuracy_options[0])

        self.xaxis_var = tk.StringVar()
        self.xaxis_var.set(self.axes_options[0])

        self.left_yaxis_var = tk.StringVar()
        self.left_yaxis_var.set(self.axes_options[0])

        self.right_yaxis_var = tk.StringVar()
        self.right_yaxis_var.set(self.axes_options[0])

        ch_settings_frame = tk.Frame(self.root, background=self.background)

        ch1_settings_frame = tk.LabelFrame(
            ch_settings_frame,
            text=self.primary_source_options[0] + ' Settings',
            background=self.background,
            padx=5,
            pady=5)

        ch1_function_row = tk.Frame(ch1_settings_frame,
                                    background=self.background)
        ch1_function_menu = tk.OptionMenu(ch1_function_row,
                                          self.ch1_function_var,
                                          *self.function_options)
        self.set_width(ch1_function_menu, self.function_options)
        ch1_function_menu.pack(side=tk.RIGHT)
        tk.Label(ch1_function_row,
                 text='Function:',
                 background=self.background).pack(side=tk.RIGHT)
        ch1_function_row.pack(side=tk.TOP, anchor=tk.W)

        ch1_source_frame = tk.LabelFrame(ch1_settings_frame,
                                         text='Source',
                                         background=self.background,
                                         padx=5,
                                         pady=5)

        ch1_source_name_row = tk.Frame(ch1_source_frame,
                                       background=self.background)
        tk.Entry(ch1_source_name_row,
                 textvariable=self.ch1_source_name_var).pack(side=tk.RIGHT)
        tk.Label(ch1_source_name_row, text='Name:',
                 background=self.background).pack(side=tk.RIGHT)
        ch1_source_name_row.pack(side=tk.TOP, anchor=tk.E, pady=2)

        ch1_source_values_row = tk.Frame(ch1_source_frame,
                                         background=self.background)
        tk.Entry(ch1_source_values_row,
                 textvariable=self.ch1_source_values_var).pack(side=tk.RIGHT)
        tk.Label(ch1_source_values_row,
                 text='Values:',
                 background=self.background).pack(side=tk.RIGHT)
        ch1_source_values_row.pack(side=tk.TOP, anchor=tk.E, pady=2)

        ch1_source_frame.pack(side=tk.TOP, pady=5)

        ch1_measurement_frame = tk.LabelFrame(ch1_settings_frame,
                                              text='Measurement',
                                              background=self.background,
                                              padx=5,
                                              pady=5)

        ch1_measurement_name_row = tk.Frame(ch1_measurement_frame,
                                            background=self.background)
        tk.Entry(
            ch1_measurement_name_row,
            textvariable=self.ch1_measurement_name_var).pack(side=tk.RIGHT)
        tk.Label(ch1_measurement_name_row,
                 text='Name:',
                 background=self.background).pack(side=tk.RIGHT)
        ch1_measurement_name_row.pack(side=tk.TOP, anchor=tk.E, pady=2)

        ch1_measurement_settings_row = tk.Frame(ch1_measurement_frame,
                                                background=self.background)
        tk.Checkbutton(ch1_measurement_settings_row,
                       text='Autorange',
                       variable=self.ch1_measurement_auto_var,
                       background=self.background).pack(side=tk.LEFT)
        tk.Checkbutton(ch1_measurement_settings_row,
                       text='Plot',
                       variable=self.ch1_measurement_plot_var,
                       background=self.background).pack(side=tk.LEFT, padx=5)
        ch1_measurement_settings_row.pack(side=tk.TOP, pady=2)

        ch1_measurement_frame.pack(side=tk.TOP, fill=tk.X)

        ch1_settings_frame.pack(side=tk.TOP, padx=5, pady=5)

        ch2_settings_frame = tk.LabelFrame(
            ch_settings_frame,
            text=self.primary_source_options[1] + ' Settings',
            background=self.background,
            padx=5,
            pady=5)

        ch2_function_row = tk.Frame(ch2_settings_frame,
                                    background=self.background)
        ch2_function_menu = tk.OptionMenu(ch2_function_row,
                                          self.ch2_function_var,
                                          *self.function_options)
        self.set_width(ch2_function_menu, self.function_options)
        ch2_function_menu.pack(side=tk.RIGHT)
        tk.Label(ch2_function_row,
                 text='Function:',
                 background=self.background).pack(side=tk.RIGHT)
        ch2_function_row.pack(side=tk.TOP, anchor=tk.W)

        ch2_source_frame = tk.LabelFrame(ch2_settings_frame,
                                         text='Source',
                                         background=self.background,
                                         padx=5,
                                         pady=5)

        ch2_source_name_row = tk.Frame(ch2_source_frame,
                                       background=self.background)
        tk.Entry(ch2_source_name_row,
                 textvariable=self.ch2_source_name_var).pack(side=tk.RIGHT)
        tk.Label(ch2_source_name_row, text='Name:',
                 background=self.background).pack(side=tk.RIGHT)
        ch2_source_name_row.pack(side=tk.TOP, anchor=tk.E, pady=2)

        ch2_source_values_row = tk.Frame(ch2_source_frame,
                                         background=self.background)
        tk.Entry(ch2_source_values_row,
                 textvariable=self.ch2_source_values_var).pack(side=tk.RIGHT)
        tk.Label(ch2_source_values_row,
                 text='Values:',
                 background=self.background).pack(side=tk.RIGHT)
        ch2_source_values_row.pack(side=tk.TOP, anchor=tk.E, pady=2)

        ch2_source_frame.pack(side=tk.TOP, pady=5)

        ch2_measurement_frame = tk.LabelFrame(ch2_settings_frame,
                                              text='Measurement',
                                              background=self.background,
                                              padx=5,
                                              pady=5)

        ch2_measurement_name_row = tk.Frame(ch2_measurement_frame,
                                            background=self.background)
        tk.Entry(
            ch2_measurement_name_row,
            textvariable=self.ch2_measurement_name_var).pack(side=tk.RIGHT)
        tk.Label(ch2_measurement_name_row,
                 text='Name:',
                 background=self.background).pack(side=tk.RIGHT)
        ch2_measurement_name_row.pack(side=tk.TOP, anchor=tk.E, pady=2)

        ch2_measurement_settings_row = tk.Frame(ch2_measurement_frame,
                                                background=self.background)
        tk.Checkbutton(ch2_measurement_settings_row,
                       text='Autorange',
                       variable=self.ch2_measurement_auto_var,
                       background=self.background).pack(side=tk.LEFT)
        tk.Checkbutton(ch2_measurement_settings_row,
                       text='Plot',
                       variable=self.ch2_measurement_plot_var,
                       background=self.background).pack(side=tk.LEFT, padx=5)
        ch2_measurement_settings_row.pack(side=tk.TOP, pady=2)

        ch2_measurement_frame.pack(side=tk.TOP, fill=tk.X)

        ch2_settings_frame.pack(side=tk.TOP, padx=5, pady=5)

        ch_settings_frame.pack(side=tk.LEFT, anchor=tk.S)

        plot_frame = tk.Frame(self.root, background=self.background)

        settings_row = tk.Frame(plot_frame, background=self.background)

        measurement_settings_frame = tk.LabelFrame(settings_row,
                                                   text='Measurement Settings',
                                                   background=self.background,
                                                   padx=5,
                                                   pady=5)

        primary_source_row = tk.Frame(measurement_settings_frame,
                                      background=self.background)
        primary_source_menu = tk.OptionMenu(primary_source_row,
                                            self.primary_source_var,
                                            *self.primary_source_options)
        self.set_width(primary_source_menu, self.speed_accuracy_options)
        primary_source_menu.pack(side=tk.RIGHT)
        tk.Label(primary_source_row,
                 text='Primary Source:',
                 background=self.background).pack(side=tk.RIGHT)
        primary_source_row.pack(side=tk.TOP, anchor=tk.E, pady=2)

        speed_accuracy_row = tk.Frame(measurement_settings_frame,
                                      background=self.background)
        speed_accuracy_menu = tk.OptionMenu(speed_accuracy_row,
                                            self.speed_accuracy_var,
                                            *self.speed_accuracy_options)
        self.set_width(speed_accuracy_menu, self.speed_accuracy_options)
        speed_accuracy_menu.pack(side=tk.RIGHT)
        tk.Label(speed_accuracy_row,
                 text='Speed/Accuracy:',
                 background=self.background).pack(side=tk.RIGHT)
        speed_accuracy_row.pack(side=tk.TOP, anchor=tk.E, pady=2)

        measurement_settings_frame.pack(side=tk.LEFT,
                                        fill=tk.Y,
                                        padx=5,
                                        pady=5)

        axes_settings_frame = tk.LabelFrame(settings_row,
                                            text='Axes Settings',
                                            background=self.background,
                                            padx=5,
                                            pady=5)

        xaxis_row = tk.Frame(axes_settings_frame, background=self.background)
        xaxis_menu = tk.OptionMenu(xaxis_row, self.xaxis_var,
                                   *self.axes_options)
        self.set_width(xaxis_menu, self.axes_options)
        xaxis_menu.pack(side=tk.RIGHT)
        tk.Label(xaxis_row, text='X-Axis:',
                 background=self.background).pack(side=tk.RIGHT)
        xaxis_row.pack(side=tk.TOP, anchor=tk.E, pady=2)

        left_yaxis_row = tk.Frame(axes_settings_frame,
                                  background=self.background)
        left_yaxis_menu = tk.OptionMenu(left_yaxis_row, self.left_yaxis_var,
                                        *self.axes_options)
        self.set_width(left_yaxis_menu, self.axes_options)
        left_yaxis_menu.pack(side=tk.RIGHT)
        tk.Label(left_yaxis_row,
                 text='Left Y-Axis:',
                 background=self.background).pack(side=tk.RIGHT)
        left_yaxis_row.pack(side=tk.TOP, anchor=tk.E, pady=2)

        right_yaxis_row = tk.Frame(axes_settings_frame,
                                   background=self.background)
        right_yaxis_menu = tk.OptionMenu(right_yaxis_row, self.right_yaxis_var,
                                         *self.axes_options)
        self.set_width(right_yaxis_menu, self.axes_options)
        right_yaxis_menu.pack(side=tk.RIGHT)
        tk.Label(right_yaxis_row,
                 text='Right Y-Axis:',
                 background=self.background).pack(side=tk.RIGHT)
        right_yaxis_row.pack(side=tk.TOP, anchor=tk.E, pady=2)

        axes_settings_frame.pack(side=tk.LEFT, padx=5, pady=5)

        self.run_stop_button = tk.Button(settings_row,
                                         text='Start',
                                         command=self.sweep_start)
        self.run_stop_button.pack(side=tk.LEFT, anchor=tk.E, padx=40)

        settings_row.pack(side=tk.BOTTOM, anchor=tk.W)

        plot_row = tk.Frame(plot_frame, background=self.background)
        plot_row.pack(side=tk.BOTTOM,
                      anchor=tk.W,
                      fill=tk.BOTH,
                      expand=tk.TRUE)

        plot_frame.pack(side=tk.LEFT,
                        anchor=tk.S,
                        fill=tk.BOTH,
                        expand=tk.TRUE)

        self.root.update()

        plot_width = float(settings_row.winfo_width())
        plot_height = float(ch_settings_frame.winfo_height() -
                            settings_row.winfo_height())
        self.plot = tkplot.tkplot(parent=plot_row,
                                  width=plot_width,
                                  height=plot_height)
        self.plot.yaxes['right'] = self.plot.y_axis(name='right',
                                                    color='#FF0000')
        self.plot.right_yaxis = 'right'
def main(data):
    global priv
    priv = PrivateData()
    priv.data = data

    # General flowchart
    # Build GUI
    #   Main window to set plot options
    #     3 buttons at bottom:
    #        1. PLOT - redraw the plot
    #	   2. QUIT - end the session (maybe have confirmation dialog!)
    #        3. CLEAR - erase plot and start again
    #   Plot window to draw plots
    #   Key window with plot key (symbol -> data map)

    # main window
    priv.root = tkplot.Toplevel()
    priv.root.title("Interactive Data Viewer")
    #priv.root.configure()
    priv.main_frame = tkplot.Frame(priv.root, relief="flat", borderwidth=3)

    # Instructions
    instruct_box = tkplot.Frame(priv.root, relief="raised", borderwidth=3)
    instructions = "View Raw Data Module\nv0.8 June 1999"
    tkplot.Label(instruct_box, text=instructions).grid()

    #   Plot fields
    fields_box = tkplot.Frame(priv.main_frame, relief="raised", borderwidth=3)
    tkplot.Label(fields_box, text="Plot field:").grid()
    priv.field = tkplot.StringVar()
    tkplot.Radiobutton(fields_box,
                       var=priv.field,
                       text="Gravity Reading",
                       value="G").grid(sticky="W")
    tkplot.Radiobutton(fields_box,
                       var=priv.field,
                       text="Gravity +- Std. Dev.",
                       value="S").grid(sticky="W")
    tkplot.Radiobutton(fields_box, var=priv.field, text="Tilt X",
                       value="X").grid(sticky="W")
    tkplot.Radiobutton(fields_box, var=priv.field, text="Tilt Y",
                       value="Y").grid(sticky="W")
    tkplot.Radiobutton(fields_box, var=priv.field, text="ETC",
                       value="E").grid(sticky="W")
    tkplot.Radiobutton(fields_box, var=priv.field, text="Duration",
                       value="D").grid(sticky="W")
    tkplot.Radiobutton(fields_box,
                       var=priv.field,
                       text="# Rejected",
                       value="R").grid(sticky="W")

    # Station filter
    filter_box = tkplot.Frame(priv.main_frame, relief="raised", borderwidth=3)
    tkplot.Label(filter_box, text="Plot station:").pack(side="top",
                                                        fill="both")
    station_sb = tkplot.Scrollbar(filter_box, orient="vertical")
    priv.station = tkplot.Listbox(filter_box,
                                  selectmode="multiple",
                                  yscrollcommand=station_sb.set)
    priv.station.configure(height=4)
    station_sb.config(command=priv.station.yview)
    station_sb.pack(side="right", fill="y")
    priv.station.pack(side="left", fill="both", expand=1)

    # create unique ID list
    ids = []
    last_id = ""
    for i in range(len(data)):
        if data[i].station_id != last_id:
            last_id = data[i].station_id
            unique = True
            for i in range(len(ids)):
                if ids[i] == last_id:
                    unique = False
            if unique:
                ids.append(last_id)

    # fill the selection box
    priv.station.insert("end", "All stations")
    for i in range(len(ids)):
        priv.station.insert("end", ids[i])

    # Plot style choices
    style_box = tkplot.Frame(priv.main_frame, relief="raised", borderwidth=3)
    tkplot.Label(style_box, text="Plot Style:").grid()
    priv.ptstyle = tkplot.StringVar()
    priv.lstyle = tkplot.StringVar()
    tkplot.Label(style_box, text="Point Type").grid(row=1,
                                                    column=0,
                                                    sticky="W")
    tkplot.Label(style_box, text="Line Type").grid(row=1, column=1, sticky="W")
    tkplot.Radiobutton(style_box, var=priv.ptstyle, text="None",
                       value="None").grid(row=2, column=0, sticky="W")
    tkplot.Radiobutton(style_box, var=priv.ptstyle, text="X",
                       value="X").grid(row=3, column=0, sticky="W")
    tkplot.Radiobutton(style_box, var=priv.ptstyle, text="o",
                       value="o").grid(row=4, column=0, sticky="W")
    tkplot.Radiobutton(style_box, var=priv.ptstyle, text="+",
                       value="+").grid(row=5, column=0, sticky="W")
    tkplot.Radiobutton(style_box, var=priv.ptstyle, text="*",
                       value="*").grid(row=6, column=0, sticky="W")
    tkplot.Radiobutton(style_box, var=priv.lstyle, text="None",
                       value="None").grid(row=2, column=1, sticky="W")
    tkplot.Radiobutton(style_box, var=priv.lstyle, text="Solid",
                       value="-").grid(row=3, column=1, sticky="W")
    tkplot.Radiobutton(style_box, var=priv.lstyle, text="Gray12",
                       value="1").grid(row=4, column=1, sticky="W")
    tkplot.Radiobutton(style_box, var=priv.lstyle, text="Gray25",
                       value="2").grid(row=5, column=1, sticky="W")
    tkplot.Radiobutton(style_box, var=priv.lstyle, text="Gray75",
                       value="4").grid(row=6, column=1, sticky="W")

    # bottom buttons
    plot_button = tkplot.Button(priv.main_frame, text="Plot", command=plot_cb)
    clear_button = tkplot.Button(priv.main_frame,
                                 text="Clear",
                                 command=clear_cb)
    print_button = tkplot.Button(priv.main_frame,
                                 text="Save",
                                 command=print_cb)
    quit_button = tkplot.Button(priv.main_frame, text="Quit", command=quit_cb)

    # Grid (display) the interface
    instruct_box.grid()
    fields_box.grid(column=0, row=0, rowspan=2, sticky="WENS")
    filter_box.grid(column=1, row=0, sticky="WENS")
    style_box.grid(column=1, row=1, sticky="WENS")
    priv.main_frame.grid()

    plot_button.grid(column=0, row=2)
    clear_button.grid(column=1, row=2)
    print_button.grid(column=0, row=3)
    quit_button.grid(column=1, row=3)

    # Setup Plot window(s)
    priv.plot_win = tkplot.Toplevel()
    priv.plot_win.title("Data Plot")
    priv.plot_area = tkplot.tkplot(priv.plot_win, 480, 640, "white", "black")
    priv.plot_area.show()

    priv.plot_area.title = ""
    priv.plot_area.xlabel = "Time"
    priv.plot_area.xlabeltype = "time"
    priv.plot_area.ylabel = ""
    priv.plot_area.nprec = 3
    priv.plot_area.xstart = 99999.0
    priv.plot_area.xo = 99999.0
    priv.plot_area.xend = 0.0
    priv.plot_area.ystart = 99999.0
    priv.plot_area.yo = 99999.0
    priv.plot_area.yend = 0.0

    # Run mainloop()
    priv.root.mainloop()

    # die on callback
    return
Beispiel #6
0
def main(argv):
  global Status

  Status = global_options()

  # main window
  root = Tk()
  root.title("View Aliod Data")

  # setup interface
  # 2 windows, one control, one plot
  plot = Toplevel()
  plot.title("Aliod Data Plot")

  bg = "black"

  #   create 4 plot areas
  G_frame = Frame(plot, relief=FLAT, background=bg)
  tilt_frame = Frame(plot, relief=FLAT, background=bg)
  T_frame = Frame(plot, relief=FLAT, background=bg)
  E_frame = Frame(plot, relief=FLAT, background=bg)

  Status.plot_G = tkplot.tkplot(G_frame, 400, 800, "white", "black")
  Status.plot_tilt = tkplot.tkplot(tilt_frame, 200, 800, "white", "black")
  Status.plot_T = tkplot.tkplot(T_frame, 150, 800, "white", "black")
  Status.plot_V = tkplot.tkplot(E_frame, 150, 800, "white", "black")

  #  setup labels, etc.
  Status.plot_G.xlabeltype = "time"
  Status.plot_tilt.xlabeltype = "time"
  Status.plot_T.xlabeltype = "time"
  Status.plot_V.xlabeltype = "time"
  Status.plot_V.xlabel = "Time since station start (H:M:S)"

  Status.plot_G.ylabel = "dG (mGal)"
  Status.plot_tilt.ylabel = "Tilt (count - 30000)"
  Status.plot_T.ylabel = "Temperature Difference (K)"
  Status.plot_V.ylabel = "Battery Voltage (V)"

  G_frame.grid()
  tilt_frame.grid()
  T_frame.grid()
  E_frame.grid()

  bg = "white"
  fg = "black"

  #   create control window
  title_F = Frame(root, relief=RIDGE, borderwidth=2, background=bg)
  Label(title_F, text="Control Panel", foreground=fg, background=bg).grid()
  title_F.grid(sticky=E+W)

  jump_F = Frame(root, relief=RIDGE, borderwidth=2, background=bg)
  jump_F.grid(sticky=E+W)
  Label(jump_F, text="Jump to Station", foreground=fg, background=bg).grid(columnspan=2, row=0)
  Status.jumpValue = StringVar()
  Entry(jump_F, textvariable=Status.jumpValue, width=6, background=bg,
    foreground=fg).grid(row=1, column=0, sticky=W)
  Button(jump_F, command=jump_cb, text="Find", background=bg,
    foreground=fg).grid(row=1, column=1, sticky=E)

  button_F = Frame(root, relief=RIDGE, borderwidth=2, background=bg)
  button_F.grid(sticky=E+W)
  Label(button_F, text="Previous/Next Station", background=bg,
    foreground=fg).grid(columnspan=2, row=0)
  Button(button_F, command=prev_cb, text="<--", background=bg,
    foreground=fg).grid(row=1, column=0, sticky=W)
  Button(button_F, command=next_cb, text="-->", background=bg,
    foreground=fg).grid(row=1, column=1, sticky=E)

  button_F2 =  Frame(root, relief=FLAT, background=bg)
  button_F2.grid(sticky=E+W)
  Button(button_F2, command=quit_cb, text="Quit", background=bg,
    foreground=fg).grid(row=2, column=0, sticky=W)
  Button(button_F2, command=print_cb, text="Save", background=bg,
    foreground=fg).grid(row=2, column=1, sticky=E)

  # get data filename
  if len(argv) > 2:
    data_file = argv[2]
    meter_file = argv[1]
    Status.data = aliodfile.get_aliod_data(data_file, meter_file, 1)

  else:
    data_file = tkFileDialog.askopenfilename(parent=root, title="Aliod data file",
	initialdir=".", filetypes=(("Data files", "*.txt"),
	("All files", "*")))
    if not data_file:
      print "Must enter a filename!"
      sys.exit(0)
    meter_file = tkFileDialog.askopenfilename(parent=root,
	title="Aliod Meter file",
	initialdir=".", filetypes=(("Meter files", "*.inf"),
	("All files", "*")))
    if not meter_file:
      print "Must enter a filename!"
      sys.exit(0)
    try:
      Status.data = aliodfile.get_aliod_data(data_file, meter_file)
    except:
      print "Cannot process file %s (meter constant file %s)!"%(data_file,
        meter_file)
      sys.exit(0)

  F = string.split(data_file, "/")
  Status.data_file = F[-1]
  del data_file, meter_file

  # convert to relative time
  start = grav_util.calc_relative_date(Status.data)

  # create list of sorted unique ids
  ids = {}
  for i in range(len(Status.data)):
    if not ids.has_key(Status.data[i].station_id):
      ids[Status.data[i].station_id] = 1

  Status.ids = ids.keys()
  Status.ids.sort(grav_util.num_sort)

  Status.index = 0
  Status.current_id = Status.ids[Status.index]
  Status.jumpValue.set(Status.current_id)

  plot_cb()

  # go
  root.mainloop()
Beispiel #7
0
def main(argv):
    global Status

    Status = global_options()

    # main window
    root = Tk()
    root.title("View Aliod Data")

    # setup interface
    # 2 windows, one control, one plot
    plot = Toplevel()
    plot.title("Aliod Data Plot")

    bg = "black"

    #   create 4 plot areas
    G_frame = Frame(plot, relief=FLAT, background=bg)
    tilt_frame = Frame(plot, relief=FLAT, background=bg)
    T_frame = Frame(plot, relief=FLAT, background=bg)
    E_frame = Frame(plot, relief=FLAT, background=bg)

    Status.plot_G = tkplot.tkplot(G_frame, 400, 800, "white", "black")
    Status.plot_tilt = tkplot.tkplot(tilt_frame, 200, 800, "white", "black")
    Status.plot_T = tkplot.tkplot(T_frame, 150, 800, "white", "black")
    Status.plot_V = tkplot.tkplot(E_frame, 150, 800, "white", "black")

    #  setup labels, etc.
    Status.plot_G.xlabeltype = "time"
    Status.plot_tilt.xlabeltype = "time"
    Status.plot_T.xlabeltype = "time"
    Status.plot_V.xlabeltype = "time"
    Status.plot_V.xlabel = "Time since station start (H:M:S)"

    Status.plot_G.ylabel = "dG (mGal)"
    Status.plot_tilt.ylabel = "Tilt (count - 30000)"
    Status.plot_T.ylabel = "Temperature Difference (K)"
    Status.plot_V.ylabel = "Battery Voltage (V)"

    G_frame.grid()
    tilt_frame.grid()
    T_frame.grid()
    E_frame.grid()

    bg = "white"
    fg = "black"

    #   create control window
    title_F = Frame(root, relief=RIDGE, borderwidth=2, background=bg)
    Label(title_F, text="Control Panel", foreground=fg, background=bg).grid()
    title_F.grid(sticky=E + W)

    jump_F = Frame(root, relief=RIDGE, borderwidth=2, background=bg)
    jump_F.grid(sticky=E + W)
    Label(jump_F, text="Jump to Station", foreground=fg,
          background=bg).grid(columnspan=2, row=0)
    Status.jumpValue = StringVar()
    Entry(jump_F,
          textvariable=Status.jumpValue,
          width=6,
          background=bg,
          foreground=fg).grid(row=1, column=0, sticky=W)
    Button(jump_F, command=jump_cb, text="Find", background=bg,
           foreground=fg).grid(row=1, column=1, sticky=E)

    button_F = Frame(root, relief=RIDGE, borderwidth=2, background=bg)
    button_F.grid(sticky=E + W)
    Label(button_F, text="Previous/Next Station", background=bg,
          foreground=fg).grid(columnspan=2, row=0)
    Button(button_F, command=prev_cb, text="<--", background=bg,
           foreground=fg).grid(row=1, column=0, sticky=W)
    Button(button_F, command=next_cb, text="-->", background=bg,
           foreground=fg).grid(row=1, column=1, sticky=E)

    button_F2 = Frame(root, relief=FLAT, background=bg)
    button_F2.grid(sticky=E + W)
    Button(button_F2,
           command=quit_cb,
           text="Quit",
           background=bg,
           foreground=fg).grid(row=2, column=0, sticky=W)
    Button(button_F2,
           command=print_cb,
           text="Save",
           background=bg,
           foreground=fg).grid(row=2, column=1, sticky=E)

    # get data filename
    if len(argv) > 2:
        data_file = argv[2]
        meter_file = argv[1]
        Status.data = aliodfile.get_aliod_data(data_file, meter_file, 1)

    else:
        data_file = tkFileDialog.askopenfilename(
            parent=root,
            title="Aliod data file",
            initialdir=".",
            filetypes=(("Data files", "*.txt"), ("All files", "*")))
        if not data_file:
            print "Must enter a filename!"
            sys.exit(0)
        meter_file = tkFileDialog.askopenfilename(
            parent=root,
            title="Aliod Meter file",
            initialdir=".",
            filetypes=(("Meter files", "*.inf"), ("All files", "*")))
        if not meter_file:
            print "Must enter a filename!"
            sys.exit(0)
        try:
            Status.data = aliodfile.get_aliod_data(data_file, meter_file)
        except:
            print "Cannot process file %s (meter constant file %s)!" % (
                data_file, meter_file)
            sys.exit(0)

    F = string.split(data_file, "/")
    Status.data_file = F[-1]
    del data_file, meter_file

    # convert to relative time
    start = grav_util.calc_relative_date(Status.data)

    # create list of sorted unique ids
    ids = {}
    for i in range(len(Status.data)):
        if not ids.has_key(Status.data[i].station_id):
            ids[Status.data[i].station_id] = 1

    Status.ids = ids.keys()
    Status.ids.sort(grav_util.num_sort)

    Status.index = 0
    Status.current_id = Status.ids[Status.index]
    Status.jumpValue.set(Status.current_id)

    plot_cb()

    # go
    root.mainloop()