Save images of ksp_monitor and ksp_view_eigenvaluses with user defined names
Hi, PETSc group, I was trying to save figures of the residual and eigenvalues with different names but not default names. The default name is used when I use `-draw_save .png`. All images are saved. ``` python test.py -N 16 -test1_ksp_type gmres -test1_pc_type jacobi -test1_ksp_view_eigenvalues draw -test1_ksp_monitor draw::draw_lg -draw_save .png ``` But when I use `-draw_save abc.png`, only the figure of eigenvalues is saved. ``` python test.py -N 16 -test1_ksp_type gmres -test1_pc_type jacobi -test1_ksp_view_eigenvalues draw -test1_ksp_monitor draw::draw_lg -draw_save .png ``` How can I add the command line options, to specify different names for those images? Thanks, Zongze
It cannot be done using the default X windows monitor and -draw_save because there is no way to distinguish the files for each sub window images. However, there is an alternative. -ksp_view_eigenvalues draw:image:jeff.ppm -viewer_view -ksp_monitor_solution draw:image:joe.ppm This alternative only supports .ppm files (so you may need to call a converter on the result) and does put each image in a separate file in its own named directory, for example, joe/joe_0.ppm but at least it allows you to have different named files. Of course you can also just run your code twice with two different options. Unfortunately there is a bug in the KSP eigenmonitor viewing that I had to fix to get this to work so you'll need to checkout the barry/2023-02-08/fix-ksp-monitor-eigenvalues-draw branch of PETSc to use the option I suggest. Barry
On Feb 8, 2023, at 5:09 AM, Zongze Yang <[email protected]> wrote:
Hi, PETSc group,
I was trying to save figures of the residual and eigenvalues with different names but not default names.
The default name is used when I use `-draw_save .png`. All images are saved. ``` python test.py -N 16 -test1_ksp_type gmres -test1_pc_type jacobi -test1_ksp_view_eigenvalues draw -test1_ksp_monitor draw::draw_lg -draw_save .png ``` But when I use `-draw_save abc.png`, only the figure of eigenvalues is saved. ``` python test.py -N 16 -test1_ksp_type gmres -test1_pc_type jacobi -test1_ksp_view_eigenvalues draw -test1_ksp_monitor draw::draw_lg -draw_save .png ```
How can I add the command line options, to specify different names for those images?
Thanks, Zongze
Hi, Barry Thanks for the tip. One more question: how can I save the log (draw_lg) figure by using `draw:image:joe.ppm`? Thanks. Zongze Barry Smith <[email protected]> 于2023年2月9日周四 05:35写道:
It cannot be done using the default X windows monitor and -draw_save because there is no way to distinguish the files for each sub window images.
However, there is an alternative.
-ksp_view_eigenvalues draw:image:jeff.ppm -viewer_view -ksp_monitor_solution draw:image:joe.ppm
This alternative only supports .ppm files (so you may need to call a converter on the result) and does put each image in a separate file in its own named directory, for example, joe/joe_0.ppm but at least it allows you to have different named files. Of course you can also just run your code twice with two different options.
Unfortunately there is a bug in the KSP eigenmonitor viewing that I had to fix to get this to work so you'll need to checkout the *barry/2023-02-08/fix-ksp-monitor-eigenvalues-draw *branch of PETSc to use the option I suggest.
Barry
On Feb 8, 2023, at 5:09 AM, Zongze Yang <[email protected]> wrote:
Hi, PETSc group,
I was trying to save figures of the residual and eigenvalues with different names but not default names.
The default name is used when I use `-draw_save .png`. All images are saved. ``` python test.py -N 16 -test1_ksp_type gmres -test1_pc_type jacobi -test1_ksp_view_eigenvalues draw -test1_ksp_monitor draw::draw_lg -draw_save .png ``` But when I use `-draw_save abc.png`, only the figure of eigenvalues is saved. ``` python test.py -N 16 -test1_ksp_type gmres -test1_pc_type jacobi -test1_ksp_view_eigenvalues draw -test1_ksp_monitor draw::draw_lg -draw_save .png ```
How can I add the command line options, to specify different names for those images?
Thanks, Zongze
On Feb 9, 2023, at 3:38 AM, Zongze Yang <[email protected]> wrote:
Hi, Barry
Thanks for the tip.
One more question: how can I save the log (draw_lg) figure by using `draw:image:joe.ppm`?
I am not sure what you mean.
-ksp_monitor_solution draw:image:joe.ppm
Will create a directory called joe with a set of files in it. Each file contains one solution during the iterative process. Barry
Thanks. Zongze
Barry Smith <[email protected] <mailto:[email protected]>> 于2023年2月9日周四 05:35写道:
It cannot be done using the default X windows monitor and -draw_save because there is no way to distinguish the files for each sub window images.
However, there is an alternative.
-ksp_view_eigenvalues draw:image:jeff.ppm -viewer_view -ksp_monitor_solution draw:image:joe.ppm
This alternative only supports .ppm files (so you may need to call a converter on the result) and does put each image in a separate file in its own named directory, for example, joe/joe_0.ppm but at least it allows you to have different named files. Of course you can also just run your code twice with two different options.
Unfortunately there is a bug in the KSP eigenmonitor viewing that I had to fix to get this to work so you'll need to checkout the barry/2023-02-08/fix-ksp-monitor-eigenvalues-draw branch of PETSc to use the option I suggest.
Barry
On Feb 8, 2023, at 5:09 AM, Zongze Yang <[email protected] <mailto:[email protected]>> wrote:
Hi, PETSc group,
I was trying to save figures of the residual and eigenvalues with different names but not default names.
The default name is used when I use `-draw_save .png`. All images are saved. ``` python test.py -N 16 -test1_ksp_type gmres -test1_pc_type jacobi -test1_ksp_view_eigenvalues draw -test1_ksp_monitor draw::draw_lg -draw_save .png ``` But when I use `-draw_save abc.png`, only the figure of eigenvalues is saved. ``` python test.py -N 16 -test1_ksp_type gmres -test1_pc_type jacobi -test1_ksp_view_eigenvalues draw -test1_ksp_monitor draw::draw_lg -draw_save .png ```
How can I add the command line options, to specify different names for those images?
Thanks, Zongze
participants (2)
-
Barry Smith -
Zongze Yang