\cancel mode verify
! fland.jnl - a land mask (overlay or "basemap")
! (default 20 minute resolution)
! See also focean.jnl for an ocean mask
! 4/93
! 	 10/93 - updated for Ferret V3.01
! 	 2/94  - added [basemap]
! 	 11/94 - added transparent overlays and "detail" control
!	  3/95 - added region arguments -- mostly to help point-and-click
!	 11/96 - use patterns for transparent fills
!        11/96 - use plot region (xaxis_min, xaxis_max) if available
!         9/18 - Ferret plots: Use a checkerboard fill for transparent;
!                PyFerret plots use opacity. Break up the setting of
!                qualifiers to make the script readable.

! Description: Plot or overlay an area-filled map of the continents

! usage:       arg1        arg2        arg3          arg4      arg5      arg6    arg7
!  GO fland [resolution] [palette] [overlay_style] [detail] [x=lo:hi] [y=lo:hi] [axes]

! arg 1 - resolution - may be 120,60,40,20,10, or 5     default=20
!	  To use resolution "nnn" the file etoponnn must exist.
! arg 2 - palette - may be any palette on your system.  Normally solid colors
!		    like black, gray,red, etc. (see Fpalette '*') default=gray
! arg 3 - overlay_style - "basemap", "transparent", or "overlay" (default)
! arg 4 - detailed - may be "detailed", "all" or "solid"  default=solid
!	  Use "detailed" together with a spectrum like dark_terrestrial
!	  Use "all" to plot oceans as well as land.
! arg 5 - longitude limits - specify as for any FERRET longitude range
! arg 6 - latitude  limits - specify as for any FERRET latitude  range
! arg 7 - use /AXES qualifier so axes and graticules defined will be drawn. (v7.44)
 
! examples:
!	  GO fland 		! default - 20 minute resolution, color gray
!	  GO fland 120		! 120 minute resolution
!	  GO fland 5		! 5 minute resolution - caution! it's LARGE
!	  GO fland 40 red	! 40 minute resolution with palette red.spk
!	  GO fland 40 red basemap
!	  GO fland 40 dark_terrestrial overlay detailed
!	  GO fland 20 gray transparent
!	  GO fland " " red	! default (20) minute resolution in red
!	  GO fland 20 dark_terrestrial overlay detailed x=80e:180e y=20s:90n
!	  GO fland 20 gray overlay " " " " " " axes
! 
!	SET DATA monthly_navy_winds; VECTOR/l=1 uwnd,vwnd
!	GO fland  60 dark_terrestrial transparent detailed
!
!       GO focean 40 white basemap
!       GO focean 40 blue_light transparent
!       GO fland 40 black transparent

! Note 1: To use resolution "nnn" the file etoponnn must exist.
! Note 2: If "basemap" is given then the current default region will determine
!	  the region to be plotted, or use arguments 5 and 6
! Note 3: The transparent option creates a see-through overlay land mask

! check the overlay/basemap/transparent option
query/ignore $3%overlay|overlay|basemap|transparent<3rd argument of GO fland must be "overlay", "basemap", or "transparent"%
query/ignore $4%not_required|detailed|solid|all> <4th argument of GO fland may be "detailed", "solid" or "all" (ocean, too)%

set data/save

def sym xlo_hack ($xaxis_min%0%)
def sym xhi_hack ($xaxis_max%360%)
def sym map_reg = [$5%x=($xlo_hack):($xhi_hack)%]

! Open the requested dataset
set data etopo$1"20"

let plot_var = rose

! Define qualifiers from the arguments and defaults
cancel symbol fland_qual

! transparency: 
! in PyFerret use an opacity setting.
! in Ferret do a "checkerboard" plot which works in all plot modes. 

if ($3"0|transparent>1|*>0") then
  if ($program_name"0|PyFerret>1|*>0") THEN
     define symbol fland_qual = /opacity=50
  else
     let ii = i[gx=rose]
     let jj = j[gy=rose]
     let plot_var = if mod(ii+jj,3) eq 0 then rose
   endif
endif

! contour levels
define symbol fland_qual = ($fland_qual)\
/lev=$4"(0,10000,10000)|detailed>(0,200,50)(200,1000,100)(1000,10000,1000)|solid>(0,10000,10000)|all>(-200,200,50)(-1000,1000,200)(-8000,8000,1000)"


! color palette
define symbol fland_qual = ($fland_qual)/pal=$2"gray"

! basemap or overlay, transparent setting handled above
if ($3"1|overlay>1|basemap>0|transparent>1|*>0") then 
  define symbol fland_qual = ($fland_qual)/($3"overlay|overlay|transparent>overlay")
endif

! longitude and latitude subset
if ($5"0|*>1") then define symbol fland_qual = ($fland_qual)/$5"0"

if ($6"0|*>1") then define symbol fland_qual = ($fland_qual)/$6"0"


if ($7"0|axes>1|*>0") then define symbol fland_qual = ($fland_qual)/axes


! draw the plot
shade/nolab/nokey/($fland_qual) plot_var($map_reg)

! clean up
cancel data etopo$1"20"

set data/restore

cancel symbol fland_qual
set mode/last verify
