示例#1
0
def plot_horizontal_slice(res, varname, plane, record=-1, time=None,
                          add_mesh=False, fig_name=''):
    """
    Plat an horizontal slice of a 3d mesh for given plane number

    @param res (TelemacFile) Struct to file from which data will be read
    @param varname (str) Name of the variable to plot
    @param plane (int) Number of the plane from which to extrac
    @param record (str) Record to plot
    @param time (str) If >= 0.0 will get nearest record to that time (This
    overwrites record)
    @param add_mesh (boolean) If True overlay the mesh on top of the scalar map
    @param fig_name (str) If not empty save the plot in that file instead of
    showing it
    """
    # If time is positive searched for record
    if time is not None:
        rrecord = res.get_closest_record(time)
    else:
        rrecord = record

    if plane < 0:
        iplane = res.nplan + plane
    else:
        iplane = plane

    vnv_plot2d(varname, res, plane=iplane, plot_mesh=add_mesh,
               filled_contours=True,
               aspect_ratio="equal",
               record=rrecord, fig_name=fig_name)
示例#2
0
def plot_vertical_slice(res, varname, poly,
                        record=-1, time=None, add_mesh=False,
                        fig_name=''):
    """
    Plot a vertical slice of a 3d mesh

    @param res (TelemacFile) Struct to file from which data will be read
    @param varname (str) Name of the variable to plot
    @param poly (list) List of polyline points
    @param poly_discret (list) Number of dicsretization point for each segment
    @param record (str) Record to plot
    @param time (str) If >= 0.0 will get nearest record to that time (This
    overwrites record)
    @param add_mesh (boolean) If True overlay the mesh on top of the scalar map
    @param fig_name (str) If not empty save the plot in that file instead of
    showing it
    """
    # If time is positive searched for record
    if time is not None:
        rrecord = res.get_closest_record(time)
        ttime = time
    else:
        rrecord = record
        ttime = res.times[record]

    vnv_plot2d(\
            varname,
            res,
            poly=poly,
            plot_mesh=add_mesh,
            record=rrecord,
            filled_contours=True,
            aspect_ratio="equal",
            fig_name=fig_name)
示例#3
0
def plot_var(res, var, record=-1, time=None, add_mesh=False,
             fig_name=''):
    """
    Plot a scalar map for the given variable and time record

    @param res (TelemacFile) Structure to file from which data will be read
    @param var (str) Name of the variable to plot
    @param record (str) Record to plot
    @param time (str) If >= 0.0 will get nearest record to that time (This
    overwrites record)
    @param add_mesh (boolean) If True overlay the mesh on top of the scalar map
    @param fig_name (str) If not empty save the plot in that file instead of
    showing it
    """
    # If time is positive searched for record
    if time is not None:
        record = res.get_closest_record(time)
        time = res.times[record]
    else:
        time = res.times[record]

    if var not in res.varnames:
        raise TelemacException("{} is not in :\n{}".format(var, res.varnames))

    vnv_plot2d(var, res, plot_mesh=add_mesh, record=record,
               filled_contours=True,
               aspect_ratio="equal",
               fig_name=fig_name)
示例#4
0
def plot_mesh2d(res, display_bnd=False,
                display_liq_bnd=False, fig_name=''):
    """
    Plot a 2d triangular mesh with either boundary conditions or liquid
    boundary number

    @param input_file (string) File from wich to read the mesh
    @param bnd_file (string) Name of the boundary file
               (only used if display_bnd or display_liq_bnd is True)
    @param display_bnd (boolean) If True display boundary type for each
        boundary node
    @param display_liq bnd (boolean) If True display liquidi boundary number
        for each boundary node
    @param fig_name (str) If not empty save the plot in that file instead of
    showing it
    """
    if (display_bnd or display_liq_bnd) and res.boundary_file == '':
        raise TelemacException(\
                "bnd_file is mandatory if using --bnd or --liq-bnd")


    vnv_plot2d(res.varnames[0], res,
               plot_mesh=True,
               annotate_bnd=display_bnd,
               annotate_liq_bnd=display_liq_bnd,
               aspect_ratio="equal",
               fig_name=fig_name)
示例#5
0
    def _post(self):
        """
        Post-treatment processes
        """
        from postel.plot_vnv import vnv_plot2d

        # Getting files
        res_vnv_seq_t2dgeo, _ = self.get_study_res('vnv_seq:T2DGEO',
                                                   load_bnd=True)
        res_vnv_seq_t2dres, _ = self.get_study_res('vnv_seq:T2DRES')

        #Plotting mesh
        vnv_plot2d('',
                   res_vnv_seq_t2dgeo,
                   plot_mesh=True,
                   fig_size=(9, 3),
                   fig_name='img/mesh',
                   annotate_bnd=True)

        #Plotting mesh
        vnv_plot2d('',
                   res_vnv_seq_t2dgeo,
                   xlim=[-6.5, -4.0],
                   ylim=[0., 1.1],
                   plot_mesh=True,
                   fig_size=(9, 3),
                   fig_name='img/mesh2')

        # Plotting BOTTOM at 0
        vnv_plot2d('BOTTOM',
                   res_vnv_seq_t2dres,
                   record=0,
                   filled_contours=True,
                   fig_size=(9, 3),
                   fig_name='img/bathy')

        # Plotting WATER DEPTH at -1
        vnv_plot2d('WATER DEPTH',
                   res_vnv_seq_t2dres,
                   record=-1,
                   filled_contours=True,
                   fig_size=(9, 3),
                   fig_name='img/waterDepth')

        # Plotting VELOCITY at -1
        vnv_plot2d('VELOCITY',
                   res_vnv_seq_t2dres,
                   record=-1,
                   filled_contours=True,
                   fig_size=(9, 3),
                   fig_name='img/velocity')

        # Plotting VELOCITY at -1
        vnv_plot2d('VELOCITY',
                   res_vnv_seq_t2dres,
                   xlim=[-6.5, -4.0],
                   ylim=[0., 1.1],
                   record=-1,
                   filled_contours=True,
                   grid_resolution=[50, 50],
                   streamlines=True,
                   streamlines_density=1.2,
                   fig_size=(9, 3),
                   fig_name='img/velocity_strm')

        # Closing files
        res_vnv_seq_t2dgeo.close()
        res_vnv_seq_t2dres.close()