NOAA-PMEL / Ferret

The Ferret program from NOAA/PMEL
https://ferret.pmel.noaa.gov/Ferret/
The Unlicense
55 stars 21 forks source link

watermarks on plots #1983

Open AnsleyManke opened 3 years ago

AnsleyManke commented 3 years ago

We've been working on a new capability to put a watermark on plots for SOCAT.

Right now this is implemented as SET WINDOW/WMARK= where the qualifiers get the image file name and path, the opacity, an optional scale factor, and the x and y locations. The x and y locations are in plot inches, multiplied by 100 to give the internal plot-plus location numbers.

SET WINDOW/WMARK="/home/user/images/filename.png"//WMXLOC=50/WMYLOC=50

will put the image a half-inch from the upper left-hand corner.

In Ferret (PyFerret) it's pretty impossible to put anything on a plot "page" independent of a plot. For locating the image on the plot other than at the upper left, we would have to draw the plot, and get information back from PPLUS about the lengths of the axes on the page and the location of the axis origin. Then clear the plot window and make a new SET WINDOW command, computing say, the lower left corner using the window size and axis length.

This is like locating a label using the x-origin, y-origin, xlen and ylen axis lengths and page width and height that come back from PlotPlus after making a plot. That's this kind of thing: https://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/customizing-plots/LABELS#_VPID_240

which is kind of complex and roundabout.

I think that because there may be aspect ratio settings, different margins set using the "go margins.jnl" script, and perhaps viewports, that it's going to be hard to reliably put the watermark on the plot page using a SET WINDOW command.

A better method might be to either add the qualifiers to the ANNOTATE command, making adding an image into a new option instead of adding a text label, or model a new command on ANNOTATE. The options in ANNOTATE allow the user to specify the location of the label it's adding in User units (e.g. degrees north or east), or in plot inches (the /NOUSER option) or in normalized units.

Probably the better path would be to make a new command based on ANNOTATE, but the logic that ANNOTATE uses to locate the text could be reused. That logic - I think - should be just what is needed, possibly scaling by 100 to send the information to the existing Python calls to place the image.

In the LAS scripts, this command would be added after the plot is drawn, right before or after the call to the script

GO labels_above_plot

The scripts currently checked in have changes in

LAS_open_window.jnl LAS_setup_watermark.jnl set_full_margins.jnl

If done with a new command or the ANNOTATE command, the changes in set_full_margins should remain if the watermark is being drawn in the plot margins.