# Example 9 -- Plot dTdrho-rho section

`Initialize Parameters'
{
    \FILE_DATA = "example9a.dat" # T vs rho
    \FILE_LOCN = "example9b.dat" # section distances
    #
    # Following values from ~/eubex/processing/to_rho_bins/do_rho_inter
    \RHO_MIN = "28.1"
    \RHO_MAX = "27.5"
    \RHO_INC = "-0.002"
    \NY = "301"
    set missing value -99.0
    \xmin = "500"
    \xmax = "0"
    \xinc = "-100"
    \ymin = "28.1"
    \ymax = "27.8"
    \yinc = "-0.1"
    \zmin = "-10"		# black
    \zmax = "0"			# white
}
`Initialize Axes'
Set up axes.
{
    set page landscape
    set x margin 5
    set x name "km"
    set x size 20
    set x axis \xmin \xmax \xinc
    set y margin 5
    set y name "$\sigma_T$"
    set y axis label horizontal
    set y axis \ymin \ymax \yinc
    set y format %.1lf
    draw axes none
}
`Initialize Files'
{
    query \data "Data file?   " ("\FILE_DATA")
    query \locn "Station locn?" ("\FILE_LOCN")
}
`Read Data'
{
    # Read x-locations
    system \.awk. '{print $2}' < \locn > TMP
    system wc TMP | \.awk. '{print $1}' > NUM
    open NUM
    read .gridx_number.
    close
    system rm NUM 
    open TMP
    read grid x .gridx_number.
    close
    system rm TMP
    # Create y-locations
    set y grid \RHO_MIN \RHO_MAX \RHO_INC
    #
    # Read data
    open \data
    read grid data \NY .gridx_number.
    close
}
if !..publication..
    draw time stamp
end if
Initialize Parameters
Initialize Axes
Initialize Files
Read Data
set image range \zmin \zmax
convert grid to image box \xmin  \ymin \xmax \ymax
query \dohisto "Do histogram scaling? (yes|no)" ("no")
if {"\dohisto" == "yes"}
    set image grayscale using histogram
end if
#
# Draw the image, then draw the axes.  If auto-drawing of axes had
# been relied upon, or if the axes had been drawn previously, parts
# of the axes would have been wiped out by spillover of the image.
draw image
draw axes frame
.axis_offset. = 0.25		# offset in cm
draw x axis at {rpn ..ybottom.. yusertocm .axis_offset. -} cm
draw y axis at {rpn ..xleft..   xusertocm .axis_offset. -} cm
.old. = ..fontsize..
set font size 0
draw y axis at {rpn ..xright..  xusertocm .axis_offset. +} cm right
set font size .old.
delete .old.
#
# All done.
draw title "Example 9 \data black=\zmin white=\zmax"
if {"\dohisto" == "yes"}
    draw title "Histogram enhanced grayscales"
end if
quit
