diff --git a/examples/config/plotter.yaml b/examples/config/plotter.yaml index fe0796b6..9810dc1e 100644 --- a/examples/config/plotter.yaml +++ b/examples/config/plotter.yaml @@ -24,7 +24,8 @@ # - var: name of the scalar variable to be plotted (color scale) # - scale: scaling of the variable (scaling done just before plotting) # - log: use (or not) a log scale for the color axis -# - color_lim: clamping range for the color axis (null for complete range) +# - color_lim: limit range for the color axis (null for complete range) +# - clamp_lim: clamping range for the color axis (null for complete range) # - filter_lim: hide voxels/points with values outside this range (null for complete range) # - point_size: size of the marker used for plotting on the point cloud # @@ -36,7 +37,8 @@ # - var_vector: name of the vector variable to be plotted (arrow direction) # - scale: scaling of the scalar variable (scaling done just before plotting) # - log: use (or not) a log scale for the color axis -# - color_lim: clamping range for the color axis (null for complete range) +# - color_lim: limit range for the color axis (null for complete range) +# - clamp_lim: clamping range for the color axis (null for complete range) # - filter_lim: hide arrows with scalar values outside this range (null for complete range) # - arrow_threshold: relative threshold for hiding arrows with small scalar values # - arrow_scale: relative arrow length (with respect to the voxel size) @@ -80,6 +82,7 @@ "scale": 1.0 "log": false "color_lim": null + "clamp_lim": null "filter_lim": null "point_size": 10.0 "V_m_abs": @@ -95,6 +98,7 @@ "scale": 1.0 "log": false "color_lim": null + "clamp_lim": null "filter_lim": null "point_size": 10.0 "S_c_abs": @@ -110,6 +114,7 @@ "scale": 1.0e-9 "log": false "color_lim": null + "clamp_lim": null "filter_lim": null "point_size": 10.0 "Q_m_abs": @@ -125,6 +130,7 @@ "scale": 1.0 "log": false "color_lim": null + "clamp_lim": null "filter_lim": null "point_size": 10.0 "P_c_abs": @@ -140,6 +146,7 @@ "scale": 1.0e-6 "log": false "color_lim": null + "clamp_lim": null "filter_lim": null "point_size": 10.0 "P_m_abs": @@ -155,6 +162,7 @@ "scale": 1.0e-6 "log": false "color_lim": null + "clamp_lim": null "filter_lim": null "point_size": 10.0 "J_c_norm": @@ -170,6 +178,7 @@ "scale": 1.0e-6 "log": false "color_lim": null + "clamp_lim": null "filter_lim": null "point_size": 10.0 "J_c_vec": @@ -186,6 +195,7 @@ "scale": 1.0e-6 "log": false "color_lim": null + "clamp_lim": null "filter_lim": null "arrow_threshold": 1.0e-3 "arrow_scale": 0.75 @@ -202,6 +212,7 @@ "scale": 1.0e+3 "log": false "color_lim": null + "clamp_lim": null "filter_lim": null "point_size": 10.0 "B_m_vec": @@ -218,6 +229,7 @@ "scale": 1.0e+3 "log": false "color_lim": null + "clamp_lim": null "filter_lim": null "arrow_threshold": 1.0e-3 "arrow_scale": 0.75 @@ -234,6 +246,7 @@ "scale": 1.0 "log": false "color_lim": null + "clamp_lim": null "filter_lim": null "point_size": 10.0 "H_vec": @@ -250,6 +263,7 @@ "scale": 1.0 "log": false "color_lim": null + "clamp_lim": null "filter_lim": null "arrow_threshold": 1.0e-3 "arrow_scale": 0.75 diff --git a/pypeec/lib_check/check_data_visualization.py b/pypeec/lib_check/check_data_visualization.py index e2bc2aa5..20327ce2 100644 --- a/pypeec/lib_check/check_data_visualization.py +++ b/pypeec/lib_check/check_data_visualization.py @@ -222,7 +222,7 @@ def _check_data_plot_plotter(layout, data_plot): # check the options for scalar and arrow plots if layout in ["scalar_voxel", "scalar_point", "arrow_voxel", "arrow_point"]: # check type - key_list = ["title", "scale", "log", "legend", "color_lim", "filter_lim"] + key_list = ["title", "scale", "log", "legend", "color_lim", "clamp_lim", "filter_lim"] datachecker.check_dict("data_plot", data_plot, key_list=key_list) # check data @@ -231,6 +231,7 @@ def _check_data_plot_plotter(layout, data_plot): datachecker.check_string("legend", data_plot["legend"], can_be_empty=True) datachecker.check_float("scale", data_plot["scale"], is_positive=True, can_be_zero=True) datachecker.check_float_array("color_lim", data_plot["color_lim"], size=2, can_be_none=True) + datachecker.check_float_array("clamp_lim", data_plot["clamp_lim"], size=2, can_be_none=True) datachecker.check_float_array("filter_lim", data_plot["filter_lim"], size=2, can_be_none=True) # check the scalar options diff --git a/pypeec/lib_visualization/manage_pyvista.py b/pypeec/lib_visualization/manage_pyvista.py index c2629d87..65efb24e 100644 --- a/pypeec/lib_visualization/manage_pyvista.py +++ b/pypeec/lib_visualization/manage_pyvista.py @@ -235,7 +235,7 @@ def _get_filter_scalar(obj, var, filter_lim): return obj -def _get_clamp_scalar(obj, var, color_lim): +def _get_clamp_scalar(obj, var, clamp_lim): """ Clamp a scalar variable between a lower and upper bound. """ @@ -245,11 +245,11 @@ def _get_clamp_scalar(obj, var, color_lim): return obj # handle None - if color_lim is None: + if clamp_lim is None: c_min = -float("inf") c_max = +float("inf") else: - (c_min, c_max) = color_lim + (c_min, c_max) = clamp_lim # get var data = obj[var] @@ -277,6 +277,7 @@ def _plot_scalar(pl, obj, data_plot, plot_clip, plot_theme): scale = data_plot["scale"] log = data_plot["log"] filter_lim = data_plot["filter_lim"] + clamp_lim = data_plot["clamp_lim"] color_lim = data_plot["color_lim"] point_size = data_plot["point_size"] legend = data_plot["legend"] @@ -298,12 +299,13 @@ def _plot_scalar(pl, obj, data_plot, plot_clip, plot_theme): obj_tmp = obj.copy(deep=True) obj_tmp = _get_scale_scalar(obj_tmp, var, scale) obj_tmp = _get_filter_scalar(obj_tmp, var, filter_lim) - obj_tmp = _get_clamp_scalar(obj_tmp, var, color_lim) + obj_tmp = _get_clamp_scalar(obj_tmp, var, clamp_lim) # add the resulting plot to the plotter arg = dict( scalars=var, log_scale=log, + clim=color_lim, point_size=point_size, scalar_bar_args=scalar_bar_args, render_points_as_spheres=True, @@ -329,6 +331,7 @@ def _plot_arrow(pl, grid, obj, data_plot, plot_clip, plot_theme): scale = data_plot["scale"] log = data_plot["log"] filter_lim = data_plot["filter_lim"] + clamp_lim = data_plot["clamp_lim"] color_lim = data_plot["color_lim"] arrow_scale = data_plot["arrow_scale"] arrow_threshold = data_plot["arrow_threshold"] @@ -357,14 +360,19 @@ def _plot_arrow(pl, grid, obj, data_plot, plot_clip, plot_theme): obj_tmp = _get_filter_vector(obj_tmp, var_norm, arrow_threshold) obj_tmp = _get_scale_scalar(obj_tmp, var_norm, scale) obj_tmp = _get_filter_scalar(obj_tmp, var_norm, filter_lim) - obj_tmp = _get_clamp_scalar(obj_tmp, var_norm, color_lim) + obj_tmp = _get_clamp_scalar(obj_tmp, var_norm, clamp_lim) # get arrow size d_char = min(grid.spacing) factor = d_char*arrow_scale # add the resulting plot to the plotter - arg = dict(scalars=var_norm, log_scale=log, scalar_bar_args=scalar_bar_args) + arg = dict( + scalars=var_norm, + log_scale=log, + clim=color_lim, + scalar_bar_args=scalar_bar_args, + ) if obj_tmp.n_cells > 0: glyph_tmp = obj_tmp.glyph(orient=var_time, scale=False, factor=factor) _get_clip_mesh(pl, glyph_tmp, arg, plot_clip)