Esempio n. 1
0
def plotSpectrum(paths):
    if type(paths) == str:
        paths = [paths]
    fig = plt.figure()
    fig.patch.set_alpha(0)
    ax1 = SubplotHost(fig, 111)
    fig.add_subplot(ax1)
    for p in paths:
        data = np.loadtxt(p, skiprows=9)
        ax1.plot(eV_To_nm / data[:, 0], data[:, 1])

    ax1.set_ylabel('Intensity (arb. units)')
    ax2 = ax1.twin()
    ax1.set_xlabel('Energy (eV)')
    # ax2 is responsible for "top" axis and "right" axis
    #    ticks = ax1.get_xticks()
    tticks = np.round(eV_To_nm / ax1.get_xticks(), 2)
    tticks = np.array(tticks, np.int)
    ax2.set_xticks([eV_To_nm / t for t in tticks])
    ax2.set_xticklabels(tticks)
    #ax2.axis["top"].label.set_visible(True)
    ax1.ticklabel_format(axis='y', style='sci', scilimits=(0, 0))
    ax2.set_xlabel('Wavelength (nm)')
    ax2.set_yticks([])


#def main():
#    path = input("Enter the path of your file: ")
#    path=path.replace('"','')
#    path=path.replace("'",'')
##    path = r'C:/Users/sylvain.finot/Documents/data/2019-03-11 - T2597 - 5K/Fil3/TRCL-cw455nm/TRCL.dat'
#    plotSpectrum(path)
#
#if __name__ == '__main__':
#    main()
Esempio n. 2
0
def diffusion1D(length_microns, log10D_m2s, time_seconds, init=1., fin=0.,
                erf_or_sum='erf', show_plot=True, 
                style=styles.style_blue, infinity=100, points=100, 
                centered=True, axes=None, symmetric=True,
                maximum_value=1.):
    """
    Simplest implementation for 1D diffusion.
    
    Takes required inputs length, diffusivity, and time 
    and plots diffusion curve on new or specified figure. 
    Optional inputs are unit initial value and final values. 
    Defaults assume diffusion out, so init=1. and fin=0. 
    Reverse these for diffusion in.
    
    Change scale of y-values with maximum_value keyword.
    
    Returns figure, axis, x vector in microns, and model y data.
    """    
    if symmetric is True:
        params = params_setup1D(length_microns, log10D_m2s, time_seconds,
                                init=init, fin=fin)
        x_diffusion, y_diffusion = diffusion1D_params(params, points=points)
        if centered is False:
            a_length = (max(x_diffusion) - min(x_diffusion)) / 2
            x_diffusion = x_diffusion + a_length
    else:
        # multiply length by two
        params = params_setup1D(length_microns*2, log10D_m2s, time_seconds,
                                init=init, fin=fin)
        x_diffusion, y_diffusion = diffusion1D_params(params, points=points)        

        # divide elongated profile in half
        x_diffusion = x_diffusion[int(points/2):]
        y_diffusion = y_diffusion[int(points/2):]
        if centered is True:
            a_length = (max(x_diffusion) - min(x_diffusion)) / 2
            x_diffusion = x_diffusion - a_length 

    if show_plot is True:
        if axes is None:
            fig = plt.figure()          
            ax  = SubplotHost(fig, 1,1,1)
            ax.grid()
            ax.set_ylim(0, maximum_value)
            ax.set_xlabel('position ($\mu$m)')
            ax.set_xlim(min(x_diffusion), max(x_diffusion))
            ax.plot(x_diffusion, y_diffusion*maximum_value, **style)
            ax.set_ylabel('Unit concentration or final/initial')
            fig.add_subplot(ax)
        else:
            axes.plot(x_diffusion, y_diffusion*maximum_value, **style)
            fig = None
            ax = None            
    else:
        fig = None
        ax = None
    
    return fig, ax, x_diffusion, y_diffusion
Esempio n. 3
0
def plotComponentStress(r, sigmaR, sigmaTheta, sigmaZ,
                        sigmaEq, filename, i, loc):
    a = r[0,0]; b = r[0,-1]
    trX = Q_(1, 'inch').to('mm').magnitude
    trY = Q_(1, 'ksi').to('MPa').magnitude
    trans = mtransforms.Affine2D().scale(trX,trY)
    fig = plt.figure(figsize=(4, 3.5))
    ax = SubplotHost(fig, 1, 1, 1)
    axa = ax.twin(trans)
    axa.set_viewlim_mode("transform")
    axa.axis["top"].set_label(r'\textsc{radius}, $r$ (in.)')
    axa.axis["top"].label.set_visible(True)
    axa.axis["right"].set_label(r'\textsc{stress component}, $\sigma$ (ksi)')
    axa.axis["right"].label.set_visible(True)
    ax = fig.add_subplot(ax)
    ax.plot(r[i,:]*1e3, sigmaR[i,:]*1e-6, '^-',
            label='$\sigma_r$')
    ax.plot(r[i,:]*1e3, sigmaTheta[i,:]*1e-6, 'o-',
            label=r'$\sigma_\theta$')
    ax.plot(r[i,:]*1e3, sigmaZ[i,:]*1e-6, 'v-',
            label='$\sigma_z$')
    ax.plot(r[i,:]*1e3, sigmaEq[i,:]*1e-6, 's-',
            label='$\sigma_\mathrm{eq}$')
    ax.set_xlabel(r'\textsc{radius}, $r$ (mm)')
    ax.set_xlim((a*1e3)-0.1,(b*1e3)+0.1)
    ax.set_ylabel(r'\textsc{stress component}, $\sigma$ (MPa)')
    ax.legend(loc=loc)
    #labels = ax.get_xticklabels()
    #plt.setp(labels, rotation=30)
    fig.tight_layout()
    fig.savefig(filename, transparent=True)
    plt.close(fig)
Esempio n. 4
0
def plot_diffusion1D(x_microns,
                     model,
                     initial_value=None,
                     fighandle=None,
                     axishandle=None,
                     top=1.2,
                     style=None,
                     fitting=False,
                     show_km_scale=False,
                     show_initial=True):
    """Takes x and y diffusion data and plots 1D diffusion profile input"""
    a_microns = (max(x_microns) - min(x_microns)) / 2.
    a_meters = a_microns / 1e3

    if fighandle is None and axishandle is not None:
        print 'Remember to pass in handles for both figure and axis'
    if fighandle is None or axishandle is None:
        fig = plt.figure()
        ax = SubplotHost(fig, 1, 1, 1)
        ax.grid()
        ax.set_ylim(0, top)
    else:
        fig = fighandle
        ax = axishandle

    if style is None:
        if fitting is True:
            style = {'linestyle': 'none', 'marker': 'o'}
        else:
            style = styles.style_lightgreen

    if show_km_scale is True:
        ax.set_xlabel('Distance (km)')
        ax.set_xlim(0., 2. * a_meters / 1e3)
        x_km = x_microns / 1e6
        ax.plot((x_km) + a_meters / 1e3, model, **style)
    else:
        ax.set_xlabel('position ($\mu$m)')
        ax.set_xlim(-a_microns, a_microns)
        ax.plot(x_microns, model, **style)

    if initial_value is not None and show_initial is True:
        ax.plot(ax.get_xlim(), [initial_value, initial_value], '--k')

    ax.set_ylabel('Unit concentration or final/initial')
    fig.add_subplot(ax)

    return fig, ax
Esempio n. 5
0
def make_3DWB_water_profile(final_profile,
                            water_ppmH2O_initial=None,
                            initial_profile=None,
                            initial_area_list=None,
                            initial_area_positions_microns=None,
                            show_plot=True,
                            top=1.2,
                            fig_ax=None):
    """Take a profile and initial water content.
    Returns the whole-block water concentration profile based on
    the profile's attribute wb_areas. If wb_areas have not been made, 
    some initial profile information and various options are passed
    to make_3DWB_area_profile().
    Default makes a plot showing A/Ao and water on parasite y-axis
    """
    fin = final_profile
    init = initial_profile

    # Set initial water
    if water_ppmH2O_initial is not None:
        w0 = water_ppmH2O_initial
    else:
        if fin.sample is not None:
            if fin.sample.initial_water is not None:
                w0 = fin.sample.initial_water
        elif init is not None:
            if init.sample is not None:
                if init.sample.initial_water is not None:
                    w0 = init.sample.initial_water
        else:
            print 'Need initial water content.'
            return False

    # Set whole-block areas
    if (fin.wb_areas is not None) and (len(fin.wb_areas) > 0):
        wb_areas = fin.wb_areas
    else:
        wb_areas = make_3DWB_area_profile(fin, initial_profile,
                                          initial_area_list,
                                          initial_area_positions_microns)
    water = wb_areas * w0
    if show_plot is True:
        # Use a parasite y-axis to show water content
        fig = plt.figure()
        ax_areas = SubplotHost(fig, 1, 1, 1)
        fig.add_subplot(ax_areas)
        area_tick_marks = np.arange(0, 100, 0.2)
        ax_areas.set_yticks(area_tick_marks)
        ax_water = ax_areas.twin()
        ax_water.set_yticks(area_tick_marks)
        if isinstance(w0, uncertainties.Variable):
            ax_water.set_yticklabels(area_tick_marks * w0.n)
        else:
            ax_water.set_yticklabels(area_tick_marks * w0)
        ax_areas.axis["bottom"].set_label('Position ($\mu$m)')
        ax_areas.axis["left"].set_label('Final area / Initial area')
        ax_water.axis["right"].set_label('ppm H$_2$O')
        ax_water.axis["top"].major_ticklabels.set_visible(False)
        ax_water.axis["right"].major_ticklabels.set_visible(True)
        ax_areas.grid()
        ax_areas.set_ylim(0, 1.2)
        if fin.len_microns is not None:
            leng = fin.len_microns
        else:
            leng = fin.set_len()
        ax_areas.set_xlim(-leng / 2.0, leng / 2.0)

        style = fin.choose_marker_style()
        ax_areas.plot([-leng / 2.0, leng / 2.0], [1, 1], **style_1)
        ax_areas.plot(fin.positions_microns - leng / 2.0, wb_areas, **style)
        return water, fig, ax_areas
    else:
        return water
def plotTIMO(r, s, feaCmp, feaEq, filename):
    a = r[0,0]; b = r[0,-1]
    trX = Q_(1, 'inch').to('mm').magnitude
    trY = Q_(1, 'ksi').to('MPa').magnitude
    trans = mtransforms.Affine2D().scale(trX,trY)
    fig = plt.figure(figsize=(4, 3.5))
    ax = SubplotHost(fig, 1, 1, 1)
    axa = ax.twin(trans)
    axa.set_viewlim_mode("transform")
    axa.axis["top"].set_label(r'\textsc{radius}, $r$ (in.)')
    axa.axis["top"].label.set_visible(True)
    axa.axis["right"].set_label(r'\textsc{stress component}, $\sigma$ (ksi)')
    axa.axis["right"].label.set_visible(True)
    ax = fig.add_subplot(ax)
    ax.plot(r[0,:]*1e3, s.sigmaTheta[0,:]*1e-6, '-', color='C0')
    ax.plot((a+feaCmp[:,0])*1e3, feaCmp[:,4]*1e-6, 'o', color='C0')
    ax.plot(r[0,:]*1e3, s.sigmaR[0,:]*1e-6, '-', color='C1')
    ax.plot((a+feaCmp[:,0])*1e3, feaCmp[:,5]*1e-6, '^', color='C1')
    ax.plot(r[0,:]*1e3, s.sigmaZ[0,:]*1e-6, '-', color='C2')
    ax.plot((a+feaCmp[:,0])*1e3, feaCmp[:,6]*1e-6, 'v', color='C2')
    ax.plot(r[0,:]*1e3, s.sigmaEq[0,:]*1e-6, '-', color='C3')
    ax.plot((a+feaEq[:,0])*1e3, feaEq[:,1]*1e-6, 's', color='C3')
    ax.plot(r[0,:]*1e3, s.sigmaRTheta[0,:]*1e-6, '-', color='C4')
    ax.plot((a+feaCmp[:,0])*1e3, feaCmp[:,7]*1e-6, '+', color='C4')
    ax.set_xlabel(r'\textsc{radius}, $r$ (mm)')
    ax.set_xlim((a*1e3)-10,(b*1e3)+10)
    ax.set_ylabel(r'\textsc{stress component}, $\sigma$ (MPa)')
    #ax.set_ylim(-400, 400)
    c0line = Line2D([], [], color='C0', marker='o',
                    label=r'$\sigma_\theta$')
    c1line = Line2D([], [], color='C1', marker='^',
                    label=r'$\sigma_r$')
    c2line = Line2D([], [], color='C2', marker='v',
                    label=r'$\sigma_z$')
    c3line = Line2D([], [], color='C3', marker='s',
                    label=r'$\sigma_\mathrm{eq}$')
    c4line = Line2D([], [], color='C4', marker='+',
                    label=r'$\tau_{r\theta}$')
    handles=[c0line, c1line, c2line, c4line, c3line]
    labels = [h.get_label() for h in handles]
    ax.legend([handle for i,handle in enumerate(handles)],
              [label for i,label in enumerate(labels)], loc='best')
    fig.tight_layout()
    fig.savefig(filename, transparent=True)
    plt.close(fig)
for j in range (shape_z_ana):
    mu_ana[j] = cosmo.dist_modulus(z_ana[j],Omega_m,(1.-Omega_m),h)
    
#---------------------
#Plotting the analytical models and the data
#-------------------
fig = pl.figure()

host = SubplotHost(fig, 1,1,1)

host.set_xlabel('$z$',fontsize=21)
host.set_ylabel('$\mu$',fontsize=21)

fig.add_subplot(host)

p1 = host.plot(z_ana,mu_ana,'r-',lw=1.5,label="$\Omega_m = 0.3$")

p2 = host.errorbar(z,mu,yerr=0.1,fmt='o',color='k',lw=1.5,label="SN data")

leg = pl.legend(loc=4,fontsize=18)
#host.set_ylim(0,48)

#pl.xticks(visible=False)
#pl.yticks(visible=False)
#host.yaxis.get_label().set_color(p1.get_color())
#leg.texts[0].set_color(p1.get_color())
#host.yaxis.get_label().set_color(p2.get_color())
#leg.texts[1].set_color(p2.get_color())
#host.yaxis.get_label().set_color(p3.get_color())
#leg.texts[2].set_color(p3.get_color())
#host.yaxis.get_label().set_color(p4.get_color())
Esempio n. 8
0
ax2_eV_to_Eh = mtransforms.Affine2D().scale(cst.eV_to_Eh, cst.Eh_to_eV)
ax2_Eh = ax2_eV.twin(ax2_eV_to_Eh)
ax2_Eh .set_viewlim_mode("transform")
fig2.add_subplot(ax2_eV)


# Plot NumericalHeating as a function of dt for every potential depth
dbase_potentials = (base_potentials[-1] - base_potentials[0]) / float(max_plot-1) # -1 since we want the number of intervals
c = 0
for j in xrange(len(potential_shapes)):
    for base_potentials_close in np.arange(base_potentials[-1]+dbase_potentials/2.0, base_potentials[0], -dbase_potentials):
        nothing, index0 = find_nearest(base_potentials,  base_potentials_close)
        nothing, index1 = find_nearest(potential_shapes, potential_shapes[j])
        #nothing, index2 = find_nearest(dts,              dts[i])
        ax1_eV.plot(dts, NumericalHeating[index0, index1, :],
                    colors_and_symbols.symb_col(c),
                    label = r"" + str(base_potentials[index0]) + " Eh")
                    #label = r"Potential depth: " + str(base_potentials[index0]) + " Eh (" + potential_shapes[j] + " )")
        # When the NumericalHeating is negative, we have cooling, which would not appear on the log scale plot.
        cooling_indices = np.where(NumericalHeating[index0, index1, :] <= 0.0)
        if (len(cooling_indices[0]) >= 1):
            ax1_eV.plot(dts[cooling_indices], abs(NumericalHeating[index0, index1, :][cooling_indices]),
                        '.' + colors_and_symbols.symb_col(c))
        c += 1

# Plot NumericalHeating as a function of potential depth for every dt
ddt = (dts[-1] - dts[0]) / float(max_plot-1+1) # -1 since we want the number of intervals
                                               # +1 so the skipped dt = 0.005 as does not reduce the number of curves
c = 0
for j in xrange(len(potential_shapes)):
    for dt_close in np.arange(dts[-1]+ddt/2.0, dts[0], -ddt):
Esempio n. 9
0
    def plot(self,
             r1=None,
             r2=None,
             nav_im=None,
             norm='log',
             scroll_step=1,
             alpha=0.3,
             cmap=None,
             pct=0.1,
             mradpp=None,
             widget=None):
        '''
        Interactive plotting of the virtual aperture images.

        The sliders control the parameters and may be clicked, dragged or scrolled.
        Clicking on inner (r1) and outer (r2) slider labels sets the radii values
        to the minimum and maximum, respectively.

        Parameters
        ----------
        r1 : scalar
            Inner radius of aperture in pixels.
        r2 : scalar
            Inner radius of aperture in pixels.
        nav_im : None or ndarray
            Image used for the navigation plot. If None, a blank image is used.
        norm : None or string:
            If not None and norm='log', a logarithmic cmap normalisation is used.
        scroll_step : int
            Step in pixels used for each scroll event.
        alpha : float
            Alpha for aperture plot in [0, 1].
        cmap : None or a matplotlib colormap
            If not None, the colormap used for both plots.
        pct : scalar
            Slice image percentile in [0, 50).
        mradpp : None or scalar
            mrad per pixel.
        widget : Pop_Up_Widget
            A custom class consisting of mutliple widgets

        '''

        from matplotlib.widgets import Slider

        self._scroll_step = max([1, int(scroll_step)])
        self._pct = pct

        if norm is not None:
            if norm.lower() == 'log':
                from matplotlib.colors import LogNorm
                norm = LogNorm()

        # condition rs
        if r1 is not None:
            self.r1 = r1
        else:
            if self.r1 is None:
                self.r1 = 0
        if r2 is not None:
            self.r2 = r2
        else:
            if self.r2 is None:
                self.r2 = int((self.data_shape[-2:] / 4).mean())
        self.rc = (self.r2 + self.r1) / 2.0

        if nav_im is None:
            nav_im = np.zeros(self.data_shape[-2:])

        # calculate data
        virtual_image = self.annular_slice(self.r1, self.r2)
        print("MRADPP", mradpp)
        # prepare plots
        if mradpp is None:
            if widget is not None:
                print("True")
                docked = widget.setup_docking("Virtual Annular",
                                              "Bottom",
                                              figsize=(8.4, 4.8))
                fig = docked.get_fig()
                fig.clf()
                (ax_nav, ax_cntrst) = fig.subplots(1, 2)
                self._f_nav = fig
            else:
                self._f_nav, (ax_nav, ax_cntrst) = plt.subplots(1,
                                                                2,
                                                                figsize=(8.4,
                                                                         4.8))

        else:
            # add 2nd x-axis
            # https://matplotlib.org/examples/axes_grid/parasite_simple2.html
            from mpl_toolkits.axes_grid1.parasite_axes import SubplotHost
            import matplotlib.transforms as mtransforms
            if widget is not None:
                print("False")
                docked = widget.setup_docking("Virtual Annular",
                                              "Bottom",
                                              figsize=(8.4, 4.8))
                self._f_nav = docked.get_fig()
                self._f_nav.clf()
            else:
                self._f_nav = plt.figure(figsize=(8.4, 4.8))
            ax_nav = SubplotHost(self._f_nav, 1, 2, 1)
            ax_cntrst = SubplotHost(self._f_nav, 1, 2, 2)

            aux_trans = mtransforms.Affine2D().scale(1.0 / mradpp, 1.0)
            ax_mrad = ax_cntrst.twin(aux_trans)
            ax_mrad.set_viewlim_mode("transform")

            self._f_nav.add_subplot(ax_nav)
            self._f_nav.add_subplot(ax_cntrst)

            ax_mrad.axis["top"].set_label('mrad')
            ax_mrad.axis["top"].label.set_visible(True)
            ax_mrad.axis["right"].major_ticklabels.set_visible(False)

        self._f_nav.subplots_adjust(bottom=0.3, wspace=0.3)
        if widget is not None:
            axr1 = fig.add_axes([0.10, 0.05, 0.80, 0.03])
            axr2 = fig.add_axes([0.10, 0.10, 0.80, 0.03])
            axr3 = fig.add_axes([0.10, 0.15, 0.80, 0.03])

        else:
            axr1 = plt.axes([0.10, 0.05, 0.80, 0.03])
            axr2 = plt.axes([0.10, 0.10, 0.80, 0.03])
            axr3 = plt.axes([0.10, 0.15, 0.80, 0.03])

        val_max = self.r_pix.max()
        try:
            self._sr1 = Slider(axr1,
                               'r1',
                               0,
                               val_max - 1,
                               valinit=self.r1,
                               valfmt='%0.0f',
                               valstep=1)
            self._sr2 = Slider(axr2,
                               'r2',
                               1,
                               val_max,
                               valinit=self.r2,
                               valfmt='%0.0f',
                               valstep=1)
        except AttributeError:
            self._sr1 = Slider(axr1,
                               'r1',
                               0,
                               val_max - 1,
                               valinit=self.r1,
                               valfmt='%0.0f')
            self._sr2 = Slider(axr2,
                               'r2',
                               1,
                               val_max,
                               valinit=self.r2,
                               valfmt='%0.0f')
        self._sr3 = Slider(axr3,
                           'rc',
                           1,
                           val_max,
                           valinit=self.rc,
                           valfmt='%0.1f')

        # these don't seem to work
        #self._sr1.slider_max = self._sr2
        #self._sr2.slider_min = self._sr1

        self._sr1.on_changed(self._update_r_from_slider)
        self._sr2.on_changed(self._update_r_from_slider)
        self._sr3.on_changed(self._update_rc_from_slider)

        ax_nav.imshow(nav_im, norm=norm, cmap=cmap)
        ax_nav.set_xlabel('Detector X (pixels)')
        ax_nav.set_ylabel('Detector Y (pixels)')

        # line plot
        r_cntrst_max = int(np.abs(self.data_shape[-2:] - self.cyx).max())
        dw = 1
        rs = np.arange(dw, r_cntrst_max)

        r1, r2 = self.r1, self.r2
        sls = np.array([self.annular_slice(r - dw, r) for r in rs])
        self.r1, self.r2 = r1, r2

        self._contrast_y = np.std(sls, (1, 2))**2 / np.mean(sls, (1, 2))
        self._contrast_x = rs - dw / 2.0
        ax_cntrst.plot(self._contrast_x, self._contrast_y)
        ax_cntrst.minorticks_on()
        ax_cntrst.set_xlabel('Radius (pixels)')
        ax_cntrst.set_ylabel('Contrast (std^2/mean)')
        self._span = ax_cntrst.axvspan(self.r1,
                                       self.r2,
                                       color=[1, 0, 0, 0.1],
                                       ec='r')

        # wedges
        fc = [0, 0, 0, alpha]
        ec = 'r'
        from matplotlib.patches import Wedge
        self._rmax = val_max + 1
        self._w2 = Wedge(self.cyx[::-1],
                         self._rmax,
                         0,
                         360,
                         width=self._rmax - self.r2,
                         fc=fc,
                         ec=ec)
        self._w1 = Wedge(self.cyx[::-1],
                         self.r1,
                         0,
                         360,
                         width=self.r1,
                         fc=fc,
                         ec=ec)
        ax_nav.add_artist(self._w2)
        ax_nav.add_artist(self._w1)

        if widget is not None:
            docked = widget.setup_docking("Virtual Annular",
                                          "Bottom",
                                          figsize=(8.4, 4.8))
            fig = docked.get_fig()
            fig.clf()
            ax_im = fig.subplots(1, 1)
            self._f_im = fig
        else:
            self._f_im, ax_im = plt.subplots(1, 1)
        vmin, vmax = np.percentile(virtual_image, [self._pct, 100 - self._pct])
        self._vim = ax_im.imshow(virtual_image,
                                 cmap=cmap,
                                 vmin=vmin,
                                 vmax=vmax)
        if widget is not None:
            self._cb = fig.colorbar(self._vim)
        else:
            self._cb = plt.colorbar(self._vim)
        self._cb.set_label('Counts')
        ax_im.set_xlabel('Scan X (pixels)')
        ax_im.set_ylabel('Scan Y (pixels)')

        cid = self._f_nav.canvas.mpl_connect('scroll_event', self._onscroll)

        self._sr1.label.set_picker(True)
        self._sr2.label.set_picker(True)
        cid_pick = self._f_nav.canvas.mpl_connect('pick_event', self._onpick)
Esempio n. 10
0
#	ax_wn.set_xlim(675, 1700)
ax_wn.invert_xaxis()
#	x_wn=np.array([800, 1000, 1200, 1400, 1600])
#	ax_wn.set_xticks(x_wn)
ax_wn.xaxis.tick_top()
ax_wn.tick_params(axis='x', direction = 'in', labelsize=11)
ax_wn.tick_params(axis='y', left=False, labelleft=False)
ax_wn.xaxis.set_label_position('top')
ax_mn.xaxis.tick_bottom()
ax_mn.xaxis.set_label_position('bottom')

print('load data')
datat=np.loadtxt('dpt_files/Chrysene/p1_08_chry_v2.dpt', delimiter = ',')
data2=nrmlze(datat, 0)

ax_wn.plot(datat[:,0], data2 + offset, 'k-', lw=0.5, linestyle='-')

offset=offset+1.15

ax_wn.set_ylim([-.5, offset+0.5])
ax_wn.set_ylabel('intensity, a.u.', fontsize=11)
ax_mn.set_xlabel('wavelength, $\mu$m', fontsize=11)
ax_wn.set_xlabel('wavenumber, cm$^{-1}$', fontsize=11)

#fig.suptitle('wavenumber, cm$^{-1}$', fontsize=11)

#plt.subplots_adjust(top=0.88,
#bottom=0.11,
#left=0.035,
#right=0.965,
#hspace=0.2,
Esempio n. 11
0
    os.chdir(basedir)
    print(dirlist)

    offset = 0
    x_minimum1 = 675
    x_maximum1 = 1700

    for i in dirlist:
        if fnmatch.fnmatch(i, '*.dpt'):
            datat = np.loadtxt(i, delimiter=',')
            data2 = nrmlze(datat, 0)

            mask1 = ((datat[:, 0] >= x_minimum1) & (datat[:, 0] <= x_maximum1))
            ax_wn.plot(datat[mask1, 0],
                       data2[mask1] + offset,
                       'k-',
                       lw=0.5,
                       linestyle='-')

            offset = offset + 1.15
        else:
            continue

    os.chdir('../../')
    ax_wn.set_ylim([-.5, offset + 0.5])
    if n == 1:
        ax_wn.set_ylabel('intensity, a.u.', fontsize=11)

    if n == 2:
        ax_mn.set_xlabel('wavelength, $\mu$m', fontsize=11)
#mu_data = np.array(data.mu(), dtype=dtype)
#z_data = data[:]['z']
#sigma_data = data[:]['sigma']
#---------------------
#Plotting the analytical models and the data
#-------------------
fig = pl.figure()

host = SubplotHost(fig, 1,1,1)

host.set_xlabel('$z$',fontsize=21)
host.set_ylabel('$\mu$',fontsize=21)

fig.add_subplot(host)

p1 = host.plot(z,mu[0,:],'r-',lw=1.5,label="$\Omega_m = 0.2$")
p2 = host.plot(z,mu[1,:],'b--',lw=1.5,label="$\Omega_m = 0.3$")
p3 = host.plot(z,mu[2,:],'k-.',lw=1.5,label="$\Omega_m = 0.4$")
p4 = host.plot(z,mu[3,:],'m:',lw=1.5,label="$\Omega_m = 0.5$")
p5 = host.errorbar(z_data,mu_data,yerr=sigma_data,fmt='o',color='k',lw=1.5,label="SN data")

leg = pl.legend(loc=4,fontsize=18)
#host.set_ylim(0,48)

#pl.xticks(visible=False)
#pl.yticks(visible=False)
#host.yaxis.get_label().set_color(p1.get_color())
#leg.texts[0].set_color(p1.get_color())
#host.yaxis.get_label().set_color(p2.get_color())
#leg.texts[1].set_color(p2.get_color())
#host.yaxis.get_label().set_color(p3.get_color())
Esempio n. 13
0
for i in xrange(nb_particles):
    if all_particles[i].cs >= 0:
        str_elem = "i"
        str_cs = "+"
        if i == impacting_electron.nearest:
            symbol = "rs"
        else:
            symbol = "ro"
    else:
        str_elem = "e"
        symbol = "bo"
        str_cs = ""

    # Potential
    if plot_V:
        ax_V_Eh.plot(all_particles[i].pos, all_particles[i].V, symbol)
        ax_V_Eh.text(
            all_particles[i].pos,
            all_particles[i].V,
            r" $" + str_elem + "_{" + str(i) + "}\ (" + str(all_particles[i].cs) + str_cs + ")$",
            horizontalalignment="left",
        )
    # Energy
    # if (plot_U):
    #    ax_U_Eh.plot(all_particles[i].pos, all_particles[i].U(), symbol)
    #    ax_U_Eh.text(all_particles[i].pos, all_particles[i].U(), r' $' + str_elem + '_{' + str(i) + '}\ (' + str(all_particles[i].cs) + str_cs + ')$', horizontalalignment = "center")


# ******************************************************************************
# Potential plot
# ******************************************************************************
                 -11.02,
                 -11.1, 
                 Jaipur.whatIsD(Celsius, orient='y')
                 ])

# Jaipur diopside fast direction
#ax.plot(np.log10(0.016), Jaipur.whatIsD(Celsius, orient='x'), **Jaipur.basestyle)
#ax.text(-1.55, -10.8, 'Jaipur diopside\nfast direction', ha='center')

# augite PMR-53
#ax.plot(np.log10(0.026), -11.02, **PMR.basestyle)
#ax.text(-1.75, -11.3, 'augite\nPMR-53',)

# Nushan cpx
#ax.plot(np.log10(0.204), Nushan.whatIsD(Celsius, orient='z'), **Nushan.basestyle) 
ax.plot(np.log10(0.154), Nushan.whatIsD(Celsius, orient='z'), **Nushan.basestyle)
ax.text(-0.7, -12.35, unicode('N\374shan\ncpx', 'latin-1'), ha='center')

# Fuego cpx
#FuegoLoc = (np.log10(0.133), (Jaipur.whatIsD(Celsius, orient='x')+Jaipur.whatIsD(Celsius, orient='y'))/2.)
FuegoLoc = (np.log10(0.066), (Jaipur.whatIsD(Celsius, orient='x')+Jaipur.whatIsD(Celsius, orient='y'))/2.)
ax.add_artist(Ellipse(FuegoLoc, 0.06, 1., facecolor='none', edgecolor='k'))
#ax.text(-0.95, -11.5, 'Fuego\nphenocryst', ha='right')
ax.text(-1.225, -10.85, 'Fuego phenocryst', ha='right', rotation=90)

# Xenoliths
#xenoMin = np.log10(0.11 - 0.035)
#xenoMax = np.log10(0.11 + 0.035)
xenoMin = np.log10(0.07 - 0.045)
xenoMax = np.log10(0.07 + 0.045)
xenoDrange = 1.
Esempio n. 15
0
def plotNACA(r, sigma, fea, i, filename, loc, ylabel):
    a = r[0,0]; b = r[0,-1]
    trX = Q_(1, 'inch').to('mm').magnitude
    trY = Q_(1, 'ksi').to('MPa').magnitude
    trans = mtransforms.Affine2D().scale(trX,trY)
    fig = plt.figure(figsize=(4, 3.5))
    ax = SubplotHost(fig, 1, 1, 1)
    axa = ax.twin(trans)
    axa.set_viewlim_mode("transform")
    axa.axis["top"].set_label(r'\textsc{radius}, $r$ (in.)')
    axa.axis["top"].label.set_visible(True)
    axa.axis["right"].set_label(ylabel+' (ksi)')
    axa.axis["right"].label.set_visible(True)
    ax = fig.add_subplot(ax)
    ax.plot(r[0,:]*1e3, sigma[0,:]*1e-6, '-',
            color='C0',label=r'$\theta=0^\circ$')
    ax.plot((a+fea[0][:,0])*1e3, fea[0][:,i]*1e-6, 'o',
            color='C0', markevery=1)
    ax.plot(r[0,:]*1e3, sigma[20,:]*1e-6, '-',
            color='C1', label=r'$\theta=60^\circ$')
    ax.plot((a+fea[1][:,0])*1e3, fea[1][:,i]*1e-6, '^',
            color='C1', markevery=1)
    ax.plot(r[0,:]*1e3, sigma[40,:]*1e-6, '-',
            color='C2', label=r'$\theta=120^\circ$')
    ax.plot((a+fea[2][:,0])*1e3, fea[2][:,i]*1e-6, 'v',
            color='C2', markevery=1)
    ax.plot(r[0,:]*1e3, sigma[60,:]*1e-6, '-',
            color='C3', label=r'$\theta=180^\circ$')
    ax.plot((a+fea[3][:,0])*1e3, fea[3][:,i]*1e-6, 's',
            color='C3', markevery=1)
    ax.set_xlabel(r'\textsc{radius}, $r$ (mm)')
    ax.set_xlim((a*1e3)-10,(b*1e3)+10)
    ax.set_ylabel(ylabel+' (MPa)')
    #ax.set_ylim(-400, 400)
    c0line = Line2D([], [], color='C0', marker='o',
                   label=r'$\theta=0^\circ$')
    c1line = Line2D([], [], color='C1', marker='^',
                   label=r'$\theta=60^\circ$')
    c2line = Line2D([], [], color='C2', marker='v',
                   label=r'$\theta=120^\circ$')
    c3line = Line2D([], [], color='C3', marker='s',
                   label=r'$\theta=180^\circ$')
    handles=[c0line, c1line, c2line, c3line]
    labels = [h.get_label() for h in handles]
    ax.legend([handle for i,handle in enumerate(handles)],
              [label for i,label in enumerate(labels)], loc=loc)
    fig.tight_layout()
    fig.savefig(filename, transparent=True)
    plt.close(fig)
Esempio n. 16
0
ax_Fe.set_xticks(parasite_tick_locations)
ax_Fe.set_xticklabels(Fe_labels)
ax_Fe.axis["top"].set_label("Fe (a.p.f.u.)")
ax_Fe.axis["top"].label.set_visible(True)
ax_Fe.axis["right"].major_ticklabels.set_visible(False)

ax.set_ylabel('log$_{10}$ diffusivity$_{H}$ $(m^2/s)$ at 800 $\degree$C')
ax.set_xlabel('log$_{10}$ Fe (a.p.f.u.)')

label = ['name'] * 10

#for idx in range(len(Names)):
for idx in [0, 1, 2, 3, 4, 6, 7]:
    ax.plot(
        x[idx],
        bulk[idx],  #label=Names[idx], 
        clip_on=False,
        **style[idx])

    # individual labels
    xyloc = (x[idx], bulk[idx])
    if np.isnan(FeOwt[idx]):
        label[idx] = ''.join(
            (Names[idx], '\n[Mg# ', '{:.1f}'.format(MgNumber[idx]), ']'))
    elif 'Fuego' in Names[idx]:
        label[idx] = ''.join(
            (Names[idx], '\n[Mg# ', '{:.1f}'.format(MgNumber[idx]), ',\n',
             '{:.2f}'.format(FeOwt[idx]), '% FeO]'))
    else:
        label[idx] = ''.join(
            (Names[idx], '\n[Mg# ', '{:.1f}'.format(MgNumber[idx]), ', ',
Esempio n. 17
0
ax_Fe.set_xticks(parasite_tick_locations)
ax_Fe.set_xticklabels(Fe_labels)
ax_Fe.axis["top"].set_label("Fe (a.p.f.u.)")
ax_Fe.axis["top"].label.set_visible(True)
ax_Fe.axis["right"].major_ticklabels.set_visible(False)


ax.set_ylabel('log$_{10}$ diffusivity$_{H}$ $(m^2/s)$ at 800 $\degree$C')
ax.set_xlabel('log$_{10}$ Fe (a.p.f.u.)')


label = ['name'] * 10

#for idx in range(len(Names)):
for idx in [0, 1, 2, 3, 4, 6, 7]:
    ax.plot(x[idx], bulk[idx], #label=Names[idx], 
            clip_on=False, **style[idx])

# individual labels
    xyloc = (x[idx], bulk[idx])
    if np.isnan(FeOwt[idx]):
        label[idx] = ''.join((Names[idx], '\n[Mg# ', 
                         '{:.1f}'.format(MgNumber[idx]), ']'))
    elif 'Fuego' in Names[idx]:
        label[idx] = ''.join((Names[idx], '\n[Mg# ', '{:.1f}'.format(MgNumber[idx]),
                     ',\n', '{:.2f}'.format(FeOwt[idx]), '% FeO]'))
    else:
        label[idx] = ''.join((Names[idx], '\n[Mg# ', '{:.1f}'.format(MgNumber[idx]),
                     ', ', '{:.2f}'.format(FeOwt[idx]), '% FeO]'))

#        label = ''.join((Names[idx], '\nMg# ', '{:.1f}'.format(MgNumber[idx]),
#                         '\nFeO wt%: ',