Ejemplo n.º 1
0
import peak_assign as pn

close("all")
f, ax = subplots(figsize=(20,6))
<<<<<<< HEAD
name_of_the_plot_nc=['%s h'%(array(nonano.x_value(nonano.Readfile)[i])) for i in range (shape(nonano.x_value(nonano.Readfile))[0])]
name_of_the_plot_nnc=['%s h'%(array(nnc.x_value(nnc.Readfile)[i])) for i in range (shape(nnc.x_value(nnc.Readfile))[0])]
=======
name_of_the_plot_nc=['%s h'%(array(nonano.x_value()[i])) for i in range (shape(nonano.x_value())[0])]
name_of_the_plot_nnc=['%s h'%(array(nnc.x_value()[i])) for i in range (shape(nnc.x_value())[0])]
>>>>>>> 4fd4d8775961b746663b468da51d99862c5c9d2e

[ax.plot(nonano.curve()[i][0],(np.array(nonano.curve()[i][1])-array(nonano.curve()[0][1]))*10 , '-',alpha=1,label='no nano, %s - 0 h'%(name_of_the_plot_nc[i])) for i in nonano.Readfile()[2]]

[ax.plot(nnc.curve()[i][0],(np.array(nnc.curve()[i][1])-array(nnc.curve()[0][1]))*10 + 5, '--',linewidth=1.5,alpha=1,label='nano, %s - 4.35 h'%(name_of_the_plot_nnc[i])) for i in nnc.Readfile()[2]]

legend(loc=0, fontsize ='small',ncol=2,columnspacing=0.5, labelspacing=0)

#add vertical lines at the local max
i_range = [0, 2, 5, 8]
lengthOftheLine = [0.92,0.9,0.9,0.9,0.9,0.9,0.8,0.8,0.9,0.9]
[ax.axvline(pn.find_local_max(nonano.curve())[1][i],ymin=0,ymax=lengthOftheLine[i],color='k') for i in i_range]

#add names of the peaks
position_y = [3.5,1,2.5 ,2.5, 3, 3,2,2.7,3.5]
[text(pn.find_local_max(nonano.curve())[1][i],position_y[i], pn.name_of_the_peak(nonano.curve())[i],horizontalalignment='center',fontsize=14) for i in i_range]

f.show()

#   f.savefig('/Users/hty/desktop/diff pdf compare %s.pdf'%('full range'))
Ejemplo n.º 2
0
            c=S.Spec.line_color[-1],
            label='Drying with nano-ZrO$_2$ (%s - %s)' %
            (name_of_the_plot[i], name_of_the_plot[0])) for i in [1]
]

#add vertical lines at the local max

# num_of_peak_showed = [0,2,5]
num_of_peak_showed = arange(9)
num_of_peak_showed = append(num_of_peak_showed, [-3, -2, -1])

lengthOftheLine = [
    0.6, 0.63, 0.66, 0, 0.68, 0.8, 0.75, 0.61, 0.69, 0.8, 0.8, 0.8
]
[
    ax.axvline(pn.find_local_max(interm2_syn)[1][i],
               ymin=0,
               ymax=lengthOftheLine[i],
               color='k',
               ls=':') for i in num_of_peak_showed
]

#add names of the peaks
position_y = [0.12, 0.15, 0.2, 1.1, 0.2, 0.33, 0.25, 0.14, 0.22]
[
    text(pn.find_local_max(interm2_syn)[1][i],
         position_y[i],
         pn.name_of_the_peak(interm2_syn)[i],
         horizontalalignment='center',
         verticalalignment='bottom',
         fontsize=14,
Ejemplo n.º 3
0
peakPosition = [
    interm2_syn[0][0][local_max[0][4]], interm2_syn[0][0][local_max[0][5]],
    interm2_syn[0][0][local_max[0][6]], 2.8,
    interm2_syn[0][0][local_max[0][7]], interm2_syn[0][0][local_max[0][8]],
    3.9, interm2_syn[0][0][local_max[0][9]],
    interm2_syn[0][0][local_max[0][10]]
]

nameOfthePeak = [
    'Si-O', 'Al/Mg-O', 'Ca-O', 'O-O', 'Si-Si', 'Ca-Si', 'Ca-Ca', 'Si-O', 'Ca-O'
]
''

# do normalization
norm_factor_wrt_last_curve = [
    interm2_syn[-1][1][pn.find_local_max(interm2_syn)[0][0][4]] /
    interm2_syn[i][1][pn.find_local_max(interm2_syn)[0][i][4]]
    for i in range(shape(data_files_1)[0])
]

norm_factor_wrt_first_curve = [
    interm2_syn[0][1][local_max[0][4]] / interm2_syn[i][1][local_max[i][4]]
    for i in range(shape(data_files_1)[0])
]

# set style of the plot
style.use('classic')

#change font properties of the plots
font = {'family': 'normal', 'weight': 'normal', 'size': 17}
matplotlib.rc('font', **font)
Ejemplo n.º 4
0
def plot():
    # start plotting
    close('all')
    f, ax0 = subplots(figsize=(6, 4.5))

    subplots_adjust(left=0.15, bottom=0.16)

    #    text(0.05, 0.9, target.__name__, transform=ax0.transAxes)

    # no normalization
    # [ax0.plot(interm2_syn[i][0],np.array(interm2_syn[i][1]), alpha=1,label='%s'%(name_of_the_plot[i])) for i in range (np.shape(data_files_1)[0])]

    # with normalization
    [
        ax0.plot(interm2_syn[i][0],
                 np.array(interm2_syn[i][1]) * norm_factor_wrt_first_curve[i],
                 alpha=1,
                 label='%s' % (name_of_the_plot[i]),
                 color=line_color[i + interval - 5])
        for i in range(np.shape(data_files_1)[0])
    ]

    #add vertical lines at the local max

    # num_of_peak_showed = [0,2,5]
    num_of_peak_showed = arange(9)
    num_of_peak_showed = append(num_of_peak_showed, [-3, -2, -1])

    lengthOftheLine = [
        0.85, 0.3, 0.66, 0.4, 0.61, 0.8, 0.6, 0.55, 0.6, 0.8, 0.8, 0.8
    ]
    [
        ax0.axvline(pn.find_local_max(interm2_syn)[1][i],
                    ymin=0,
                    ymax=lengthOftheLine[i],
                    color='k',
                    ls=':') for i in num_of_peak_showed
    ]

    #add names of the peaks
    position_y = [3.2, -0.8, 1.8, 0, 1.5, 2.7, 1.5, 1, 1.5]
    [
        text(pn.find_local_max(interm2_syn)[1][i],
             position_y[i],
             pn.name_of_the_peak(interm2_syn)[i],
             horizontalalignment='center',
             verticalalignment='bottom',
             fontsize=14,
             rotation=80) for i in num_of_peak_showed
    ]

    #increase the freq of the ticks
    locator_params(axis='x', tight=True, nbins=10)

    xlim(0.8, 6)
    # ylim (-0.4,0.4)
    #ax.axhline(y=0, color='k')

    ylabel('G(r) ($\AA^{-2}$)')
    xlabel(r'r ($\AA$)')
    legend(loc=4,
           fontsize='small',
           ncol=1,
           columnspacing=0.5,
           labelspacing=0,
           frameon=True)

    f.show()
Ejemplo n.º 5
0
def difference_plot(gs0, gs1, title_text=''):
    # f, ax = subplots(nrows=2, ncols=1, sharex=True, figsize=(7,7))

    ax0 = subplot(gs0)
    text(0.1, 4.5, title_text)
    [
        ax0.plot(interm2_syn[i][0],
                 np.array(interm2_syn[i][1]) * norm_factor_wrt_first_curve[i],
                 alpha=1,
                 label='%s' % (name_of_the_plot[i]),
                 color=line_color[i + interval - 4])
        for i in range(np.shape(data_files_1)[0])
    ]

    # [ax.plot(interm2_syn[i][0],np.array(interm2_syn[i][1])*norm_factor_wrt_first_curve[i], alpha=1,label='%s'%(name_of_the_plot[i])) for i in range (np.shape(data_files_1)[0])]

    #add vertical lines at the local max

    # num_of_peak_showed = [0,2,5]
    num_of_peak_showed = arange(9)
    # num_of_peak_showed = append(num_of_peak_showed, [-3, -2, -1])

    lengthOftheLine = [
        0.85, 0.3, 0.66, 0.55, 0.61, 0.8, 0.6, 0.55, 0.6, 0.8, 0.8, 0.8
    ]
    [
        ax0.axvline(pn.find_local_max(interm2_syn)[1][i],
                    ymin=0,
                    ymax=lengthOftheLine[i],
                    color='k',
                    ls=':') for i in num_of_peak_showed
    ]

    #add names of the peaks
    position_y = [3.2, -0.8, 1.8, 1, 1.5, 2.7, 1.5, 1, 1.5]
    [
        text(pn.find_local_max(interm2_syn)[1][i],
             position_y[i],
             pn.name_of_the_peak(interm2_syn)[i],
             horizontalalignment='center',
             verticalalignment='bottom',
             fontsize=14,
             rotation=80) for i in num_of_peak_showed
    ]

    #increase the freq of the ticks
    locator_params(axis='x', tight=True, nbins=10)

    xlim(0.8, 6)
    ylim(-3, 4)
    #ax.axhline(y=0, color='k')

    ylabel('G(r) ($\AA^{-2}$)')
    Legend = ax0.legend(loc=4,
                        fontsize='small',
                        ncol=2,
                        columnspacing=0.5,
                        labelspacing=0,
                        frameon=True,
                        title='Drying time')
    setp(Legend.get_title(), fontsize='small')
    '''difference plots'''
    ax1 = subplot(gs1)
    mag_factor = 1
    # text(0.1, 0.5, '(b)')

    line_type = ['-', '-', '--', '-']
    marker_type = ['', '', '', '']
    line_width = [1, 1, 1.5, 2]

    [
        ax1.plot(
            interm2_syn[i][0],
            (np.array(interm2_syn[i][1]) * norm_factor_wrt_first_curve[i] -
             array(interm2_syn[0][1])),
            linestyle=line_type[i],
            linewidth=line_width[i],
            alpha=1,
            label='%s - %s' % (name_of_the_plot[i], name_of_the_plot[0]),
            color=line_color[i + interval - 5])
        for i in range(np.shape(data_files_1)[0])[1:]
    ]

    #difference plots
    # [ax.plot(interm2_syn[i][0],(np.array(interm2_syn[i][1])*norm_factor_wrt_first_curve[i]-array(interm2_syn[0][1]))*5 + 6, '--', alpha=1,label='%s - %s'%(name_of_the_plot[i], name_of_the_plot[0])) for i in range (np.shape(data_files_1)[0])]

    # [ax.plot(interm2_syn[i][0],(np.array(interm2_syn[i][1])-array(interm2_syn[0][1]))*5 + 10, '--', linewidth=1.5,alpha=1,label='%s - 0h no norm.'%(name_of_the_plot[i])) for i in range (np.shape(data_files_1)[0])]
    locator_params(axis='x', tight=True, nbins=10)

    xlabel(r'r ($\AA$)')
    xlim(0.8, 6)
    ylim(-0.6, 0.5)
    # text(5,7.5,'x 5')
    legend(loc=4,
           fontsize='small',
           ncol=2,
           columnspacing=0.5,
           labelspacing=0,
           frameon=True)
    title('Difference', fontsize='small')
    return target.__name__
Ejemplo n.º 6
0
        '%s h' % (array(target.peaks(target.Readfile)[0][0::data_interval][i]))
        for i in range(shape(data_files_1)[0])
    ]
else:
    data_interval = 9
    data_files_1 = target.Readfile()[1][0::data_interval]
    name_of_the_plot = [
        '%s h' % (array(target.peaks(target.Readfile)[0][0::data_interval][i]))
        for i in range(shape(data_files_1)[0])
    ]

interm2_syn = gd.curve(data_files_1, 141)

# do normalization
norm_factor_wrt_last_curve = [
    interm2_syn[-1][1][pn.find_local_max(interm2_syn)[0][0][4]] /
    interm2_syn[i][1][pn.find_local_max(interm2_syn)[0][i][4]]
    for i in range(shape(data_files_1)[0])
]

norm_factor_wrt_first_curve = [
    interm2_syn[0][1][pn.find_local_max(interm2_syn)[0][0][4]] /
    interm2_syn[i][1][pn.find_local_max(interm2_syn)[0][i][4]]
    for i in range(shape(data_files_1)[0])
]

# set style of the plot
# style.use('classic')

#change font properties of the plots
font = {'family': 'serif', 'weight': 'normal', 'size': 17}
Ejemplo n.º 7
0
import sys
sys.path.append('/Users/hty/Google Drive/python_modules')
import getData as gd
from numpy import *
from matplotlib.pyplot import *
sys.path.append('/Users/hty/Google Drive/research/APS exp/py_files')
import peak_assign as pn
# import target file
import noNano_rh0 as target


data_file = target.read_reciprocal_space_files('.sq')[1]

xy = gd.curve(data_file,141)

close("all")

# remember to update the range of the label****
[plot(xy[i][0],xy[i][1],label='%s h'%(target.read_reciprocal_space_files('.sq')[3] [i])) for i in range (shape(xy)[0])]
legend(loc=0, fontsize =14,ncol=1,columnspacing=1, labelspacing=0.1)
xlabel(r'r ($\AA^{-1}$)')
ylabel('S(Q)')

show()

local_max = pn.find_local_max(xy)[0]

peak_pos = [xy[i][0][local_max[i][0]] for i in range(shape(xy)[0])]