utils package
Submodules
utils.generate_gif module
- utils.generate_gif.generate_gif(images_path='./plot/plot_all_timestep/', save_path='./plot/', file_name='output')[source]
generate a gif file from png files contained in a given directory * images_path: string, ‘./plot/plot_all_timestep/’ by default, contains the path of the directory in which the figures are * save_path: string, ‘./plot/’ by default, contains the path of the directory in which the gif file will be saved * file_name string, ‘output’ by default, name of the file in which the gif will be saved
- do:
open and concatenate in the alphabetic order the files contained in the given images’ directory
save the array of images as a gif in the given save directory
utils.geom_to_shapefile module
- utils.geom_to_shapefile.geom_to_shapefile(msh, name_file_out, path_out)[source]
method to save the geometry in a shapefile with the domain as a shapely.box for visualization
- input:
msh: object of the class MeshRect2D, the mesh containing the geometry to save
path_out: str, path to the folder in which the geometry will be saved
name_file_out: str, name of the file in which the geometry will be saved
- do:
generate a shapely.box corresponding the the domain
save the geometry contained in msh and the domain’s box in the file and folder given as input
utils.plot_colormap module
- utils.plot_colormap.plot_colormap(msh, xy_map, label, unit, cmap='jet', title=None, map_bound=None, save_path=None, file_name=None, file_format='pdf', figsize=(20, 15))[source]
Plot a given physical quantity
- input:
msh: object of the class MeshRect2D
xy_map: numpy array of shape (mesh.y.size, mesh.x.size), contains the mean value of the physical quantity in the cells
label: string, contains the label of the physical quantity, can be in LaTeX format
unit: string, contains the unit of the physical quantity, can be in LaTeX format
cmap: string, “jet” by default, contains the name of the colormap to use
title: string, None by default, contains the title of the figure, can be in LaTeX format
map_bound: tuple, contains the lower and upper boundary we want to impose to the colormap
save_path: string, None by default, contains the path to directory in which the figure is saved if not None
file_name: string, None by default, contains the name of the filein which the figure is saved if save_path is not None
file_format: string, ‘pdf’ by default, contains the format of the file in which the figure is saved if save_path is not None
figsize: tuple, (20, 15) by default, contains the size of the figure
- do:
plot on the whole domain the given physical quantity
save the figure in a file if the save_path input is not None, show the figure otherwise
- utils.plot_colormap.plot_colormap_all_timestep(msh, t, txy_map, label, unit, cmap='jet', save_path='./plot/plot_all_timestep/', figsize=(20, 15), restart_ite=0)[source]
Plot and save a given physical quantity at every time step
- input:
msh: object of the class MeshRect2D
t: numpy array, contains all the time at which the physical quantity is plotted
- txy_map:
numpy array of shape (t.size, mesh.y.size, mesh.x.size), contains the mean value of the physical quantity in the cells at every time step
label: string, contains the label of the physical quantity, can be in LaTeX format
unit: string, contains the unit of the physical quantity, can be in LaTeX format
cmap: string, “jet” by default, contains the name of the colormap to use
save_path: string, ‘./plot/plot_all_timestep/’ by default, contains the path to directory in which all the figures are saved
- do:
plot on the whole domain and at every time step the given physical quantity
save the figures in png files
utils.plot_cost module
utils.plot_ctrl module
- utils.plot_ctrl.plot_ctrl(msh, t, ctrl, ctrl_target=None, obs=None, trajectory_U=None, cmap='jet', title=None, map_bound=None, label='s', save_path=None, file_name=None, file_format='pdf', figsize=(20, 15))[source]
- utils.plot_ctrl.plot_ctrl_all_timestep(msh, ctrl, ctrl_target=None, obs=None, label='s', cmap='jet', save_path='./plot/plot_all_timestep/')[source]
Plot and save a given physical quantity at every time step
- input:
msh: object of the class MeshRect2D
t: numpy array, contains all the time at which the physical quantity is plotted
- txy_map:
numpy array of shape (t.size, mesh.y.size, mesh.x.size), contains the mean value of the physical quantity in the cells at every time step
label: string, contains the label of the physical quantity, can be in LaTeX format
unit: string, contains the unit of the physical quantity, can be in LaTeX format
cmap: string, “jet” by default, contains the name of the colormap to use
save_path: string, ‘./plot/plot_all_timestep/’ by default, contains the path to directory in which all the figures are saved
- do:
plot on the whole domain and at every time step the given physical quantity
save the figures in png files
utils.plot_ctrl_error module
utils.plot_env_param module
- utils.plot_env_param.plot_diffusion_tensor(msh, diffu_coeff, save_path=None, figsize=(20, 15))[source]
Plot the diffusion tensor
- input:
msh: object of the class MeshRect2D
diffu_coeff: object of the class DiffusionTensor
save_path: string, None by default, contains the path to directory in which the figure is saved if not None
figsize: tuple, (20, 15) by default, contains the size of the figure
- do:
plot on the whole domain the four component of the diffusion tensor
save the figure in a pdf file if the save_path input is not None, show the figure otherwise
- utils.plot_env_param.plot_velocity_field(msh, vel, save_path=None, file_name=None, figsize=(20, 15), space_subsampling_rate=10, scale_arrow=0.9756097560975611, width_arrow=0.2, vlim=None, title=None, format_out='pdf')[source]
Plot the velocity field
- input:
msh: object of the class MeshRect2D
vel: object of the class Velocity
save_path: string, None by default, contains the path to directory in which the figure is saved if not None
figsize: tuple, (20, 15) by default, contains the size of the figure
- do:
plot on the whole domain the velocity field with an arrow representation of the velocity vector
save the figure in a pdf file if the save_path input is not None, show the figure otherwise
utils.plot_obs module
- utils.plot_obs.plot_obs(msh, t, obs, figsize=(20, 15), cmap='jet', save_path=None, file_format='pdf', cbar_dim=[0.92, 0.15, 0.02, 0.69])[source]
Plot and save the observations at a given time step
- input:
msh: object of the class MeshRect2D
t: float, contains the time at which the observations plotted
obs: object of the class Obs, contains the observations we want to plot
cmap: string, “jet” by default, contains the name of the colormap to use
save_path: string, ‘./plot/plot_all_timestep/’ by default, contains the path to directory in which all the figures are saved
file_format: string, ‘pdf’ by default, contains the format of the file in which the figure is saved if save_path is not None
figsize: tuple, (20, 15) by default, contains the size of the figure
- do:
plot on the observations at a given time step, the points not observed are left white
save the figures in a file