NOAA-PMEL / PyFerret

The PyFerret program and Python module from NOAA/PMEL
https://ferret.pmel.noaa.gov/Ferret/
The Unlicense
60 stars 22 forks source link

png option with name of the image to be saved as argument #123

Open PBrockmann opened 2 years ago

PBrockmann commented 2 years ago

I am a very satisfied user with ferret and the option - batch that allows the saving of an image from the name of the argument given. With pyferret this option is deprecated.

ferret -batch myimage.gif -script myscript.jnl

with pyferret it gives

pyferret -batch myimage.png -script myscript.jnl
           *** NOTE: the use of the "-batch" command-line option is deprecated;
           *** NOTE: instead use the "FRAME /FILE=... /FORMAT=..." Ferret command

The proposal notes to add additional lines with FRAME/... into your script is very less convenient than just the use of the -batch option because you have to modify your code, creation 2 versions, one original, one for the capture. I would like to retrieve this functionality perhaps by adding a argument to the -png option for example ?

- png <filename>
PBrockmann commented 2 years ago

note that in pyferret release 7.1, the batch option was available and described as follows:

       -batch:       draw to <filename> (default "ferret.png") instead of
                     displaying to the console.  The file format will be
                     guessed from the filename extension.  When using this
                     option, new windows should not be created and the
                     FRAME command should not be used.
ACManke commented 5 months ago

The -batch option is still working, but is limited. Deprecated capabilities are unsupported and may be discontinued in the future. The basic capability of -batch with a filename is useful and should continue so I will remove the deprecated designatoin.

The current status is this:

pyferret -batch myimage.png -script myscript.jnl saves the file myimage.png. If the script draws more than one image and does not contain FRAME commands, then only the last plot is saved as myimage.png

If there are FRAME commands, a script that draws three images will produce the files:

> pyferret -batch myimage.png -script my_frame_script.jnl
> ls *.png*
ferret.png
ferret.png.~1~
ferret.png.~2~
myimage.png

where the last one created, myimage.png, is the same as the image in ferret.png.

Changes will be made so that if there are FRAME commands, then the three images will be saved as:

myimage.png.~1~
myimage.png.~2~
myimage.png

In the script we can use the FRAME command with no qualifiers, or FRAME/FILE=myimage.png can be used. Other qualifiers including /TRANSPARENT /ANNOTATE=/XPIXELS= and so on cannot be used when starting the session using -batch; and -batch combined with -transparent works only to make one image transparent.

The idea of adding an optional filename to the -png startup option is appealing, but it would involve changes in the Python code that starts PyFerret and is more involved than the simple changes to improve the batch option. I will not do this at this time.

ACManke commented 5 months ago

Looking at issue #22, which describes the implementation of -png option, there is no reason not to allow specification of an image-file name with -png. I can to do that in the code that initializes the PyFerret session. This is a better solution for the request here than extending the use of -batch, which is an imitation of the classic-Ferret capability to write to metafiles

The -png mode was implemented for use in LAS which makes only one image for each request. Multiple images from one script seem to work well, However in -png startup mode we have the limitation that any SET WINDOW commands apply to all plots.