\cancel mode verify
! 2/94 - polar_2d.jnl 


! NOTE: The map projection capabilities beginning with Ferret v5.0
! provide far more flexibility for making plots with curvilinear coordinates.
! Run the script  mp_demo  for an introduction


! Description: produce a 2D polar stereographic plot

! usage:  GO polar_2d plot_command variable [rotation] [#_points] [limit] [fill] [file] [pole]

! plot_command:		one of "SHADE" [default], "CONTOUR", or "FILL"
!			including qualifiers (see note below)
! variable:		variable or expression to be plotted.
!			Must include explicit qualifiers with region
!			encompassing the area to be plotted 
! (optional) rotation:	rotation of projected plot.  Zero [default] means
!			prime meridian centered in upper half of plot
!			Use rotation = 105 for FNOC and NMC plots
! (optional) #_points:	number of points on X and Y axes of the final
!			plot (essentially, the resolution of the plot)
!			Use #_points=63 for FNOC grid, #_points=65 for NMC
! (optional) limit:	fraction of full region that will be displayed
!			Default = 1 (full region).  e.g. 0.5 will display
!			only the -.5 to .5 region from the full plot
! (optional) fill:	Either FILL or HOLE(default) to indicate how points
!			bordering on missing values should be treated
! (optional) file:	name of file to receive the sampled points
!			Default = polar_grid.dat
!			Note: the format of this file will be unformatted
!			with #_points columns per record.
! (optional) pole:      pole, +1 is north pole (default), -1 is south pole.

! Note on plot command qualifiers:
!  Use /TITLE= to annotate your plot
!  /OVERLAY works fine
!  /SET_UP requires manual setting and resetting of PPL tics and axlabp
!  /X/Y/Z/T/I/J/K/L qualifiers will refer to the OUTPUT (page layout) grid
!	not to the input (lat/long) grid		


! check that parameters are OK to the best we can
query/ignore $1%<Use: GO polar_2d plot_command variable [angle] [#] [limit] ["FILL"] [file]%
query/ignore $2%<Use: GO polar_2d plot_command variable [angle] [#] [limit] ["FILL"] [file]%

! define the rotation
let/quiet polar_rotation=$3"0"
let/quiet signgr = if ($8"1.0") ge 0.0 then 1.0 else (-1.0)

! extract the data ready to plot
GO convert_to_polar_2d $2 $4"201" $6"HOLE" $7"polar_grid.dat"

! produce the plot
GO box_plot $1/x=-$5"1":$5"1"/y=-$5"1":$5"1" polar[d=$7"polar_grid.dat"]

! coach the user on how to make quick replots
MESSAGE/Cont "The following plotting command can be modified and reused:"
MESSAGE/Cont >>>GO box_plot $1/x=-$5"1":$5"1"/y=-$5"1":$5"1" polar[d=$7"polar_grid.dat"]

set mode/last verify
message/continue "NOTE: The map projection capabilities beginning with Ferret v5.0"
message/continue "provide far more flexibility for plots with curvilinear coordinates."
message/continue "Run the script  mp_demo  for an introduction"
