def plot_vector(self,plane,modes,axis_vals,y_mode='half_channel',spacing=(1,1),scaling=1,fig=None,ax=None,quiver_kw=None,**kwargs):
    
        FluctDF = self._getFluctDF(modes)        
        plane = self.Domain.out_to_in(plane)
        axis_vals = misc_utils.check_list_vals(axis_vals)

        plane, coord = FluctDF.CoordDF.check_plane(plane)

        if coord == 'y':
            axis_vals = indexing.ycoords_from_coords(self.avg_data,axis_vals,mode=y_mode)[0]
            int_vals = indexing.ycoords_from_norm_coords(self.avg_data,axis_vals,mode=y_mode)[0]
        else:
            int_vals = axis_vals = indexing.true_coords_from_coords(self.CoordDF,coord,axis_vals)

        x_size, z_size = FluctDF.get_unit_figsize(plane)
        figsize=[x_size,z_size*len(axis_vals)]

        axes_output = True if isinstance(ax,mpl.axes.Axes) else False

        kwargs = cplt.update_subplots_kw(kwargs,figsize=figsize)
        fig, ax = cplt.create_fig_ax_without_squeeze(len(axis_vals),fig=fig,ax=ax,**kwargs)

        title_symbol = misc_utils.get_title_symbol(coord,y_mode,False)

        for i, val in enumerate(int_vals):
            fig, ax[i] = FluctDF.plot_vector(plane,val,time=None,spacing=spacing,scaling=scaling,
                                                    fig=fig,ax=ax[i],quiver_kw=quiver_kw)
            ax[i].axes.set_xlabel(r"$%s/\delta$"%slice[0])
            ax[i].axes.set_ylabel(r"$%s/\delta$"%slice[1])
            ax[i].axes.set_title(r"$%s = %.2g$"%(title_symbol,axis_vals[i]),loc='right')

        if axes_output:
            return fig, ax[0]
        else:
            return fig, ax
예제 #2
0
    def _plot_budget_x(self,
                       budget_terms,
                       y_vals_list,
                       Y_plus=True,
                       PhyTime=None,
                       fig=None,
                       ax=None,
                       **kwargs):

        budget_terms = self._check_terms(budget_terms)

        kwargs = cplt.update_subplots_kw(kwargs, figsize=[10, 5])
        fig, ax = cplt.create_fig_ax_with_squeeze(fig, ax**kwargs)

        xaxis_vals = self.avg_data._return_xaxis()
        for comp in budget_terms:
            if y_vals_list != 'max':
                if Y_plus:
                    y_index = indexing.Y_plus_index_calc(
                        self, self.CoordDF, y_vals_list)
                else:
                    y_index = indexing.coord_index_calc(
                        self.CoordDF, 'y', y_vals_list)
                budget_term = self.budgetDF[PhyTime, comp]

                y_vals_list = indexing.ycoords_from_coords(self,
                                                           y_vals_list,
                                                           mode='wall')[0]
                for i, y_val in enumerate(y_vals_list):
                    ax.cplot(budget_term[i],
                             label=r"%s $y^+=%.2g$" % (comp, y_val))

                ncol = cplt.get_legend_ncols(
                    len(budget_terms) * len(y_vals_list))
                ax.clegend(vertical=False, ncol=ncol, fontsize=16)

            else:
                budget_term = self.budgetDF[PhyTime, comp]
                budget_term = np.amax(budget_term, axis=0)
                ax.cplot(xaxis_vals, budget_term, label=r"maximum %s" % comp)

                ncol = cplt.get_legend_ncols(len(budget_terms))
                ax.clegend(vertical=False, ncol=ncol, fontsize=16)
        fig.tight_layout()
        return fig, ax
    def plot_contour(self,comp,modes,axis_vals,plane='xz',y_mode='wall',fig=None,ax=None,pcolor_kw=None,**kwargs):
        
        FluctDF = self._getFluctDF(modes)
        
        plane = self.Domain.out_to_in(plane)
        axis_vals = misc_utils.check_list_vals(axis_vals)

        plane, coord = FluctDF.CoordDF.check_plane(plane)

        if coord == 'y':
            axis_vals = indexing.ycoords_from_coords(self.avg_data,axis_vals,mode=y_mode)[0]
            int_vals = indexing.ycoords_from_norm_coords(self.avg_data,axis_vals,mode=y_mode)[0]
        else:
            int_vals = axis_vals = indexing.true_coords_from_coords(self.CoordDF,coord,axis_vals)
            # int_vals = indexing.coord_index_calc(self.CoordDF,coord,axis_vals)
        
        x_size, z_size = FluctDF.get_unit_figsize(plane)
        figsize=[x_size,z_size*len(axis_vals)]

        axes_output = True if isinstance(ax,mpl.axes.Axes) else False

        kwargs = cplt.update_subplots_kw(kwargs,figsize=figsize)
        fig, ax = cplt.create_fig_ax_without_squeeze(len(axis_vals),fig=fig,ax=ax,**kwargs)

        title_symbol = misc_utils.get_title_symbol(coord,y_mode,False)

        for i,val in enumerate(int_vals):
            fig, ax1 = FluctDF.plot_contour(comp,plane,val,time=None,fig=fig,ax=ax[i],pcolor_kw=pcolor_kw)
            ax1.axes.set_xlabel(r"$%s/\delta$" % plane[0])
            ax1.axes.set_ylabel(r"$%s/\delta$" % plane[1])
            ax1.axes.set_title(r"$%s=%.2g$"%(title_symbol,axis_vals[i]),loc='right')
            
            cbar=fig.colorbar(ax1,ax=ax[i])
            cbar.set_label(r"$%s^\prime$"%comp)

            ax[i]=ax1
            ax[i].axes.set_aspect('equal')

        if axes_output:
            return fig, ax[0]
        else:
            return fig, ax
예제 #4
0
    def plot_vorticity_contour(self,comp,plane,axis_vals,PhyTime=None,avg_data=None,x_split_list=None,y_mode='half_channel',pcolor_kw=None,fig=None,ax=None,**kwargs):
        """
        Creates a contour plot of the vorticity contour

        Parameters
        ----------
        comp : str
            Component of the vorticity to be extracted e.g. "x" for 
            \omega_z, the spanwise vorticity
        plane : str, optional
            Plane for the contour plot for example "xz" or "rtheta" (for pipes),
            by default 'xz'
        axis_vals : int, float (or list of them)
            locations in the third axis to be plotted
        PhyTime : float, optional
            Physical time to be plotted, None can be used if the instance contains a single 
            time, by default None
        avg_data : CHAPSim_AVG
            Used to aid plotting certain locations using in the y direction 
            if wall units are used for example
        x_split_list : list, optional
            Separating domain into different streamwise lengths useful if the domain is much 
            longer than its width, by default None
        y_mode : str, optional
            Only relevant if the xz plane is being used. The y value can be selected using a 
            number of different normalisations, by default 'wall'
        fig : %(fig)s, optional
            Pre-existing figure, by default None
        ax : %(ax)s, optional
            Pre-existing axes, by default None

        Returns
        -------
        %(fig)s, %(ax)s
            output figure and axes objects
        """

        VorticityDF = self.vorticity_calc(PhyTime=PhyTime)

        plane = self.Domain.out_to_in(plane)
        axis_vals = misc_utils.check_list_vals(axis_vals)
        PhyTime = self.check_PhyTime(PhyTime)

        plane, coord = VorticityDF.CoordDF.check_plane(plane)

        if coord == 'y':
            if avg_data is None:
                msg = "If the xz plane is selected the avg_data variable must be set"
                raise TypeError(msg)

            axis_vals = indexing.ycoords_from_coords(avg_data,axis_vals,mode=y_mode)[0]
            int_vals = indexing.ycoords_from_norm_coords(avg_data,axis_vals,mode=y_mode)[0]
        else:
            int_vals = axis_vals = indexing.true_coords_from_coords(self.CoordDF,coord,axis_vals)
        
        x_size, z_size = VorticityDF.get_unit_figsize(plane)
        figsize=[x_size,z_size*len(axis_vals)]

        axes_output = True if isinstance(ax,mpl.axes.Axes) else False

        kwargs = cplt.update_subplots_kw(kwargs,figsize=figsize)
        fig, ax = cplt.create_fig_ax_without_squeeze(len(axis_vals),fig=fig,ax=ax,**kwargs)

        title_symbol = misc_utils.get_title_symbol(coord,y_mode,False)

        for i,val in enumerate(int_vals):
            fig, ax1 = VorticityDF.plot_contour(comp,plane,val,time=PhyTime,fig=fig,ax=ax[i],pcolor_kw=pcolor_kw)
            ax1.axes.set_xlabel(r"$%s/\delta$" % plane[0])
            ax1.axes.set_ylabel(r"$%s/\delta$" % plane[1])
            ax1.axes.set_title(r"$%s=%.2g$"%(title_symbol,axis_vals[i]),loc='right')
            ax1.axes.set_title(r"$t^*=%s$"%PhyTime,loc='left')
            
            cbar=fig.colorbar(ax1,ax=ax[i])
            cbar.set_label(r"$%s^\prime$"%comp)

            ax[i]=ax1
            ax[i].axes.set_aspect('equal')

        if axes_output:
            return fig, ax[0]
        else:
            return fig, ax
예제 #5
0
    def plot_vector(self,plane,axis_vals,avg_data,PhyTime=None,y_mode='half_channel',spacing=(1,1),scaling=1,fig=None,ax=None,quiver_kw=None,**kwargs):
        """
        Create vector plot of a plane of the instantaneous flow

        Parameters
        ----------
        plane : str, optional
            Plane for the contour plot for example "xz" or "rtheta" (for pipes),
            by default 'xz'
        axis_vals : int, float (or list of them)
            locations in the third axis to be plotted
        avg_data : CHAPSim_AVG
            Used to aid plotting certain locations using in the y direction 
            if wall units are used for example
        PhyTime : float, optional
            Physical time to be plotted, None can be used if the instance contains a single 
            time, by default None
        y_mode : str, optional
            Only relevant if the xz plane is being used. The y value can be selected using a 
            number of different normalisations, by default 'wall'
        spacing : tuple, optional
            [description], by default (1,1)
        scaling : int, optional
            [description], by default 1
        x_split_list : list, optional
            Separating domain into different streamwise lengths useful if the domain is much 
            longer than its width, by default None
        fig : %(fig)s, optional
            Pre-existing figure, by default None
        ax : %(ax)s, optional
            Pre-existing axes, by default None
        quiver_kw : dict, optional
            Argument passed to matplotlib quiver plot, by default None
        
        Returns
        -------
        %(fig)s, %(ax)s
            output figure and axes objects
        """
        plane = self.Domain.out_to_in(plane)
        axis_vals = misc_utils.check_list_vals(axis_vals)
        PhyTime = self.check_PhyTime(PhyTime)

        plane, coord = self.InstDF.CoordDF.check_plane(plane)

        if coord == 'y':
            if avg_data is None:
                msg = "If the xz plane is selected the avg_data variable must be set"
                raise TypeError(msg)
            axis_vals = indexing.ycoords_from_coords(avg_data,axis_vals,mode=y_mode)[0]
            int_vals = indexing.ycoords_from_norm_coords(avg_data,axis_vals,mode=y_mode)[0]
        else:
            int_vals = axis_vals = indexing.true_coords_from_coords(self.CoordDF,coord,axis_vals)

        x_size, z_size = self.InstDF.get_unit_figsize(plane)
        figsize=[x_size*len(axis_vals),z_size]

        axes_output = True if isinstance(ax,mpl.axes.Axes) else False

        kwargs = cplt.update_subplots_kw(kwargs,figsize=figsize)
        fig, ax = cplt.create_fig_ax_without_squeeze(len(axis_vals),fig=fig,ax=ax,**kwargs)

        title_symbol = misc_utils.get_title_symbol(coord,y_mode,False)

        for i, val in enumerate(int_vals):
            fig, ax[i] = self.InstDF.plot_vector(plane,val,time=PhyTime,spacing=spacing,scaling=scaling,
                                                    fig=fig,ax=ax[i],quiver_kw=quiver_kw)
            ax[i].axes.set_xlabel(r"$%s/\delta$"%slice[0])
            ax[i].axes.set_ylabel(r"$%s/\delta$"%slice[1])
            ax[i].axes.set_title(r"$%s = %.2g$"%(title_symbol,axis_vals[i]),loc='right')
            ax[i].axes.set_title(r"$t^*=%s$"%PhyTime,loc='left')

        if axes_output:
            return fig, ax[0]
        else:
            return fig, ax
예제 #6
0
    def plot_mode_contour(self,
                          comp,
                          modes,
                          axis_val,
                          plane='xz',
                          y_mode='wall',
                          fig=None,
                          ax=None,
                          pcolor_kw=None,
                          **kwargs):

        modes = misc_utils.check_list_vals(modes)
        axes_output = True if isinstance(ax, mpl.axes.Axes) else False

        axis_val = misc_utils.check_list_vals(axis_val)

        if len(axis_val) > 1:
            msg = "This routine can only process one slice in a single call"
            raise ValueError(msg)

        for i, mode in enumerate(modes):

            PODmodes = self.POD_modesDF.values[:, :, :, :, mode]
            POD_modeDF = cd.flowstruct3D(self._coorddata,
                                         PODmodes,
                                         index=self.POD_modesDF.index)
            plane, coord = POD_modeDF.CoordDF.check_plane(plane)

            if coord == 'y':
                val = indexing.ycoords_from_coords(self.avg_data,
                                                   axis_val,
                                                   mode=y_mode)[0][0]
                int_val = indexing.ycoords_from_norm_coords(self.avg_data,
                                                            axis_val,
                                                            mode=y_mode)[0][0]
            else:
                int_val = val = indexing.true_coords_from_coords(
                    self.CoordDF, coord, axis_val)[0]

            if i == 0:
                x_size, z_size = POD_modeDF.get_unit_figsize(plane)
                figsize = [x_size, z_size * len(modes)]
                kwargs = cplt.update_subplots_kw(kwargs, figsize=figsize)
                fig, ax = cplt.create_fig_ax_without_squeeze(len(modes),
                                                             fig=fig,
                                                             ax=ax,
                                                             **kwargs)

            title_symbol = misc_utils.get_title_symbol(coord, y_mode, False)

            fig, ax[i] = POD_modeDF.plot_contour(comp,
                                                 plane,
                                                 int_val,
                                                 time=None,
                                                 fig=fig,
                                                 ax=ax[i],
                                                 pcolor_kw=pcolor_kw)
            ax[i].axes.set_xlabel(r"$%s/\delta$" % plane[0])
            ax[i].axes.set_ylabel(r"$%s/\delta$" % plane[1])
            ax[i].axes.set_title(r"$%s=%.2g$" % (title_symbol, val),
                                 loc='right')
            ax[i].axes.set_title(r"Mode %d" % (mode + 1), loc='left')
            cbar = fig.colorbar(ax[i], ax=ax[i].axes)
            ax[i].axes.set_aspect('equal')

        if axes_output:
            return fig, ax[0]
        else:
            return fig, ax