def make_contour_plot(self, **kwargs):
    
        pi, bish, sp, ds, sm, de, du, sc = self.multiplot_ranges(**kwargs)

            
        if "y_range" not in kwargs:
            temp = numpy.where(self.s_axes[5] > 0)[0]
            kwargs["y_range"] = [self.s_axes[5][temp[0]], self.s_axes[5][temp[-1]]]
        
        for _sp in sp:
            for _sm in sm:
                for _du in du:
                    for _sc in sc:
                        
                        if "ax" not in kwargs:
                            fig = plt.figure()
                            ax = fig.add_subplot(111)  
                        else:
                            ax = kwargs["ax"]
                            del(kwargs["ax"])
                        

                        if _sm == 0:
                            smx = "perpendicular"
                        else:
                            smx = "parallel"
                        
                        
                        kwargs["title"] = "{name}\n{smx}".format(name = self.objectname, smx = smx)

                        PL.contourplot(self.s[:, 0, 0, _sp, _sm, :, _du, _sc].T, self.s_axes[0], self.s_axes[5], x_label = "w3 (cm-1)", y_label = self.s_units[5], ax = ax, **kwargs)
                        
                        if "ylog" in kwargs and kwargs["ylog"]:                    
                            ax.set_yscale('log')
Exemplo n.º 2
0
    def make_overview_plot(self, **kwargs):
        """
        Make a single figure with all plots. 
        
        INPUT:
        - kwargs:
            - sp, sm, de, du, sc (lists, ndarray): lists that limit the range of spectra to be plotted. By default all spectra will be plotted.
            - aspect (str, 'equal'): the aspect ratio of the axes. 
            - flip_spectrum (bool, False): by default (False) the x axis is w_3. If True, it will be w_1. Make sure the axes ranges are changed as well. 
        
        OUTPUT:
        - -
        
        DESCRIPTION:
        - - 
        
        CHANGELOG:
        2016014/RB: started function
        
        """
    
        pi, bish, sp, ds, sm, de, du, sc = self.multiplot_ranges(**kwargs)
    
        n_plots = len(sp) * len(sm) * len(de) * len(du) * len(sc)

        x, y = FU.find_subplots(n_plots, flag_verbose = self.flag_verbose)

        fig = plt.figure()
        ax = [0] * n_plots
        for ax_i in range(n_plots):
            ax[ax_i] = fig.add_subplot(y, x, ax_i + 1)  
            if "aspect" in kwargs:
                if kwargs["aspect"] != False:
                    ax[ax_i].set_aspect(kwargs["aspect"])
            else:
                ax[ax_i].set_aspect("equal")

        ax_i = 0
        for _sp in sp:
            for _sm in sm:
                for _de in de:
                    for _du in du:
                        for _sc in sc:
                            
                            title = "{name}\nsp {spx}, sm {smx}, de {dex} fs".format(name = self._basename, spx = self.s_axes[3][_sp], smx = "x",#self.s_axes[4][:,_sm], 
                            dex = self.s_axes[5][_de])
                            
                            if "flip_spectrum" in kwargs and kwargs["flip_spectrum"]:
                                PL.contourplot(self.s[:, :, 0, _sp, _sm, _de, _du, _sc], self.s_axes[1], self.s_axes[0], x_label = "w1 (cm-1)", y_label = "w3 (cm-1)", ax = ax[ax_i], title = title, **kwargs)
                     
                            else:
                                PL.contourplot(self.s[:, :, 0, _sp, _sm, _de, _du, _sc].T, self.s_axes[0], self.s_axes[1], x_label = "w3 (cm-1)", y_label = "w1 (cm-1)", ax = ax[ax_i], title = title, **kwargs)

                            ax_i += 1
                            
        return fig
Exemplo n.º 3
0
    def make_plots(self, **kwargs):
        """
        Plot all 2D-IR spectra as separate plots. 
    
        INPUT:
        - kwargs:
            - sp, sm, de, du, sc (lists, ndarray): lists that limit the range of spectra to be plotted. By default all spectra will be plotted. 
            - aspect (str, 'equal'): the aspect ratio of the axes. 
            - flip_spectrum (bool, False): by default (False) the x axis is w_3. If True, it will be w_1. Make sure the axes ranges are changed as well. 
    
        DESCRIPTION:
        - - 
    
        CHANGELOG:
        201604-RB: started function
    
        """
        
        pi, bish, sp, ds, sm, de, du, sc = self.multiplot_ranges(**kwargs)

        flag_make_title = False
        if "title" not in kwargs:
            flag_make_title = True
        
        if "ax" not in kwargs:
            flag_create_fig = True
        else: 
            flag_create_fig = False
            ax = kwargs["ax"]
            del(kwargs["ax"])
        
        for _sp in sp:
            for _sm in sm:
                for _de in de:
                    for _du in du:
                        for _sc in sc:

                            if flag_create_fig:
                                fig = plt.figure()
                                ax = fig.add_subplot(111)  
                                if "aspect" in kwargs:
                                    if kwargs["aspect"] != False:
                                        ax.set_aspect(kwargs["aspect"])
                                else:
                                    ax.set_aspect("equal")

                            if flag_make_title:
                                kwargs["title"] = "%s %s fs" % (self._basename, self.s_axes[5][_de])
#                                 kwargs["title"] = "{name}\nsp {spx}, sm {smx}, de {dex} fs".format(name = self._basename, spx = self.s_axes[3][_sp], smx = self.s_axes[4][:,_sm], dex = self.s_axes[5][_de])

                            if "flip_spectrum" in kwargs and kwargs["flip_spectrum"]:
                                PL.contourplot(self.s[:, :, 0, _sp, _sm, _de, _du, _sc], self.s_axes[1], self.s_axes[0], x_label = "w1 (cm-1)", y_label = "w3 (cm-1)", ax = ax, **kwargs)
                     
                            else:
                                PL.contourplot(self.s[:, :, 0, _sp, _sm, _de, _du, _sc].T, self.s_axes[0], self.s_axes[1], x_label = "w3 (cm-1)", y_label = "w1 (cm-1)", ax = ax, **kwargs)
Exemplo n.º 4
0
    def make_contour_plot(self, **kwargs):
    
        pi, bish, sp, ds, sm, de, du, sc = self.multiplot_ranges(**kwargs)
        
        flag_make_title = False
        if "title" not in kwargs:
            flag_make_title = True
            
        if "y_range" not in kwargs:
            temp = numpy.where(self.s_axes[5] > 0)[0]
            print(temp)
            kwargs["y_range"] = [self.s_axes[5][temp[0]], self.s_axes[5][temp[-1]]]
            print(kwargs["y_range"])
        
        for _sp in sp:
            for _sm in sm:
                for _du in du:
                    for _sc in sc:
                        
                        if "ax" not in kwargs:
                            fig = plt.figure()
                            ax = fig.add_subplot(111)  
                        else:
                            ax = kwargs["ax"]
                            del(kwargs["ax"])
                            
                        kwargs["aspect"] = False
                        
                        if flag_make_title:
                            kwargs["title"] = "{name}\nsp {spx}, sm {smx}".format(name = self._basename, spx = self.s_axes[3][_sp], smx = self.s_axes[4][:,_sm])

                        PL.contourplot(self.s[:, 0, 0, _sp, _sm, :, _du, _sc].T, self.s_axes[0], self.s_axes[5], x_label = "w3 (cm-1)", y_label = self.s_units[5], ax = ax, **kwargs)
                        
                        if "ylog" in kwargs and kwargs["ylog"]:                    
                            ax.set_yscale('log')


        plt.show()
Exemplo n.º 5
0
    def plot(
        self,
        plot_type="S",
        ax=False,
        x_range=[0, 0],
        y_range=[0, -1],
        pixel=-1,
        x_label="",
        y_label="",
        title="",
        flipxy=False,
        flag_verbose=False,
        **kwargs
    ):

        """
        Plot the data.
        
        INPUT:
        - plot_type ('S' (default), 'R', 'NR', 'T'): plot the spectrum, the rephasing, non-rephasing spectra or time domain. Note that R and NR only work if the Fourier transform has been done and saved.
        - ax (False (default) or matplotlib axes instance): if False, it will make a new figure, otherwise it will use the axes instance, allowing subplots etc.
        - x_label, y_label, title (string, default=''): the labels for the axes. If no label is set, it will use the default. Use 'no_label' or 'no_title' to show no label.
        - pixel (int, -1): if pixel is an element of w_3, it will plot only this pixel, otherwise it will plot a 2D-plot
        - flipxy (BOOL, False): will flip the data and the axes. Non-default labels will not be flipped. 
        - x_range, y_range (array with 2 elements, [0,0], [0,-1]): the range to be plotted. 
        Possible cases:
        - [min, max]: plot range min to max
        - [0, 0]: plot the whole range
        - [0, -1]: use the range from the other axis. If both have this, it will plot both axes complete. (ie. it is identical to both having [0,0])
        
        **kwargs (stuff for the plotting function)
        - zlimit (number or list, -1): the z-range that will be used
            Possible cases:
            zlimit = 0, show all, not don't care about centering around zero
            zlimit = -1, show all, centered around zero
            zlimit = all else, use that, centered around zero
            zlimit = [a,b], plot from a to b
        - contours (number): number of contours to be used
        - invert_colors (BOOL, False): data = -data

        CHANGELOG:
        20110910/RB: started as croc-function
        20130131/RB: rewrote function for Crocodile. Integrated it with plot_T
        20130213/RB: some arguments are now kwargs: they are not explicitly listed but are passed on to the plotting function.        
        """

        self.verbose("Plot", flag_verbose)

        if plot_type == "S":
            data = self.s
        elif plot_type == "R":
            data = numpy.real(numpy.exp(-1j * self.phase_rad) * self.f[0])
        elif plot_type == "NR":
            data = numpy.real(numpy.exp(1j * self.phase_rad) * self.f[1])
        elif plot_type == "T":
            data = numpy.concatenate((numpy.flipud(self.r[1][1:, :]), self.r[0])).T

        if pixel < 0 or pixel > len(self.s_axis[2]):

            self.verbose("  -> contourplot", flag_verbose)

            # S, R and NR are freq-freq, T is time-freq
            # flipxy will change the xy-axis
            # the labels and range may be changed, if they are not at the defaults

            if plot_type == "S" or plot_type == "R" or plot_type == "NR":
                if flipxy:
                    # not the normal way
                    data = data.T
                    x_axis = self.s_axis[0]
                    y_axis = self.s_axis[2]
                    if x_label == "":
                        x_label = r"$\omega_1 (cm^{-1})$"
                    if y_label == "":
                        y_label = r"$\omega_3 (cm^{-1})$"
                else:
                    x_axis = self.s_axis[2]
                    y_axis = self.s_axis[0]
                    if x_label == "":
                        x_label = r"$\omega_3 (cm^{-1})$"
                    if y_label == "":
                        y_label = r"$\omega_1 (cm^{-1})$"
            else:  # time domain
                if flipxy:
                    # not the normal way
                    data = data.T
                    x_axis = self.r_axis[2]
                    y_axis = numpy.concatenate((-numpy.flipud(self.r_axis[0][1:]), self.r_axis[0]))
                    if x_label == "":
                        x_label = r"$\omega_3 (cm^{-1})$"
                    if y_label == "":
                        y_label = r"$t_1 (fs)$"
                    if y_range == [0, -1]:
                        y_range = [0, 0]
                else:
                    x_axis = numpy.concatenate((-numpy.flipud(self.r_axis[0][1:]), self.r_axis[0]))
                    y_axis = self.r_axis[2]
                    if x_label == "":
                        x_label = r"$t_1 (fs)$"
                    if y_label == "":
                        y_label = r"$\omega_3 (cm^{-1})$"
                    if y_range == [0, -1]:
                        y_range = [0, 0]

            PL.contourplot(
                data,
                x_axis,
                y_axis,
                ax=ax,
                x_range=x_range,
                y_range=y_range,
                x_label=x_label,
                y_label=y_label,
                title=title,
                flag_verbose=flag_verbose,
                **kwargs
            )

        else:

            self.verbose("  -> linear plot", flag_verbose)

            if plot_type == "S" or plot_type == "R" or plot_type == "NR":
                x_axis = self.s_axis[0]
                x_label = r"$\omega_1 (cm^{-1})$"
            else:
                x_axis = self.r_axis[0]
                x_label = r"$\t_1 (fs)$"

            PL.linear(
                data[pixel],
                x_axis,
                x_range=x_range,
                y_range=y_range,
                ax=ax,
                x_label=x_label,
                y_label=y_label,
                title=title,
                flag_verbose=flag_verbose,
                **kwargs
            )

        if not ax:
            plt.show()