[Thread Prev][Thread Next][Index]

Ferret how-to: labelling contour extrema



Ferret how_to:

	******************************************
	* How to label extrema on a contour plot *
	******************************************

On Mar 18,  2:29pm, Jack J. Katzfey wrote:
> Subject: Ferret question (max/min on contour)

> Is it possible to plot the maximum and/or minimum values on a 
> contour plot?  Ideally, these should be relative max/mins over
> the plot, not just the absolute max/min for the whole plot.

=====================

Hi Jack,

Ferret has no contour option to automatically annotate the local
minima and maxima on a contour plot, however, the script below allows
you easily to annotate selected extrema. Here's an example of using it:

------
    Mark the sea level pressure maximum in the N. Pacific

	yes? SET DATA coads_climatology
	yes? SHADE/L=1/LEVELS=40 slp
	yes? GO extremum MAX "slp[l=1]" x=170w:110w y=20N:40N 0.15 2
------

	- steve

===============================================================

\cancel mode verify
! extremum.jnl - annotate an extremum for a region on a plot 
! 3/96

! Description: Annotate an extremum for a region on a plot 

! arg no.:                1         2        3         4         5      6
! usage:  GO extremum min_or_max variable "X=lo:hi" "Y=lo:hi" [size] [delta]
 
! where
!          min_or_max is "MIN" or "MAX" as desired
!          variable   is the expression that has been contoured
!          X=lo:hi    is the X range over which to locate the extremum
!          Y=lo:hi    is the Y range over which to locate the extremum
!          size       is the label size for the extremum value [default=0.15]
!          delta      is the distance above the extrema to locate the label

! example: mark the sea level pressure maximum in the N. Pacific
!          SET DATA coads_climatology
!          ! GO graticule             ! optional - helps to locate extrema
!          SHADE/L=1/LEVELS=40 slp
!          GO extremum MAX "slp[l=1]" x=170w:110w y=20N:40N 0.15 2

! Note: this quick and dirty version is suitable only for 2D plots in the
! XY plane. Extension to other planes is straightforward. 

! the user must specify "min" or "max"
QUERY/IGNORE this $1%|MIN|MAX|<Usage: GO extremum "min"_or_"max" variable "X=lo:hi" "Y=lo:hi" [text_size]%

! define a variable with the expression currently on the plot
LET/quiet field = $2%<Usage: GO extremum min_or_max variable "X=lo:hi" "Y=lo:hi" [text_size]%

let extremum = field[$3@$1,$4@$1]      ! becomes field[X=lo:hi@MAX,Y=lo:hi@MAX]
LET/quiet field0 = field - extremum
LET/quiet xlocs = field0[$3@loc:0]     ! becomes X=lo:hi@loc:0
LET/quiet ylocs = field0[$4@loc:0]

! put a plot mark over the maximum
PLOT/VS/OVER/NOLABEL/SYM=2 `xlocs[$4@ave]`,`ylocs[$3@ave]`

! label the maximum (place label above the mark)
LABEL `xlocs[$4@ave]`,`ylocs[$3@ave]+$6"0"`,0,0,$5".15" "@CR`extremum`"

! clean up
SET MODE/LAST VERIFY



[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / ERL / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement