Esempio n. 1
0
        usage_and_exit()

    # get initial data from db
    x_values, y_values = insert_data(input_file, MYDB)

    # plot initial data
    pylab.subplot(2, 1, 1)
    pylab.axhline()  # draw line for y-coord 0
    plot_data(x_values, y_values, color='red', label='Initial data')
    dump_data_in_range(input_file, MYDB, x_values, y_values)
    if DO_SPLINE:
        # calculate spline
        plot_data(x_values, y_values, color='red', label='Initial')
        x_values, y_values = do_spline(x_values, y_values)
        plot_data(x_values, y_values, color='green', label='Splined')

    # recenter using X_0. If X_0 = None, the recenter is not applied.
    result = recenter(x_values, y_values)
    if result is not None:
        x_values, y_values = result
        pylab.subplot(2, 1, 2)
        pylab.axhline()  # draw line for y-coord 0
        plot_data(x_values, y_values, color='green', label='Recentered')
    # calculate positive and negative integrals
    pos, neg = diff_integrate(x_values, y_values)
    # dump results to db with some sort of comment
    dump_data(input_file, MYDB, [float(pos)], [float(neg)],
              "Integrals positive and negative")
    # show all the plots
    pylab.show()
params['t1'] = "file:%s:0:0" %(FILE_1)
params['i2'] = "file:%s:0:1" %(FILE_2)
params['t2'] = "file:%s:0:0" %(FILE_2)
params['i3'] = "file:%s:0:1" %(FILE_3)
params['t3'] = "file:%s:0:0" %(FILE_3)
params['i4'] = "file:%s:0:1" %(FILE_4)
params['t4'] = "file:%s:0:0" %(FILE_4)

# Set the variable values according to the given params
i_values1 = get_values_from(params['i1'], format='csv')
t_values1 = get_values_from(params['t1'], format='csv')
i_values2 = get_values_from(params['i2'], format='csv')
t_values2 = get_values_from(params['t2'], format='csv')
i_values3 = get_values_from(params['i3'], format='csv')
t_values3 = get_values_from(params['t3'], format='csv')
i_values4 = get_values_from(params['i4'], format='csv')
t_values4 = get_values_from(params['t4'], format='csv')

it_values = [(i_values1, t_values1, FILE_1), (i_values2, t_values2, FILE_2), (i_values3, t_values3, FILE_3), 
             (i_values4, t_values4, FILE_4)]
             
#drop into the db
map(dump_data(it_values[3], MYDB, it_values[0], it_values[1], ABOUT), it_values)

# Cyclic Voltammetry
cv_data1 = zip(t_values1, i_values1)
cv_data2 = zip(t_values2, i_values2)
cv_data3 = zip(t_values3, i_values3)
cv_data4 = zip(t_values4, i_values4)