#!/usr/bin/ruby

require "numru/dcl"
include NumRu


# preparation of array
#   number of data
ndata = 45
#  NArray (computationally faster than ruby array)
press = NArray.float(ndata)
temp  = NArray.float(ndata)
# read a file
#   open a data file
file = File.open("USStdAtm.txt", "r")
#   read header
for l in 1..3
  line = file.gets
end
#   read values
for l in 1..ndata
  line = file.gets
  values = line.split(' ')
  press[l-1] = values[5].to_f
  temp [l-1] = values[4].to_f
end
#  close a file
file.close


# draw a figure
#   "display number" : 1 for monitor
#                    : 2 for pdf file
iws = 1
DCL.gropn( iws )                                   # open a device

# --- simple version from here ---
DCL.grfrm                                          # set a frame
DCL.usgrph( temp, press )
# --- simple version until here ---

# --- detailed version from here ---
#DCL.grfrm                                         # set a frame
#DCL.ussttl( 'Temperature', 'K', 'Pressure', 'Pa' )  # name and unit of axes
#DCL.grswnd(180.0, 320.0, 1300.0e2, 0.001e2) # set range of axes
#DCL.grsvpt(0.2,0.9,0.2,0.9)           # set viewport
#itr = 1
#DCL.grstrn(itr)                       # select kind of axis, 
#                                      #   1 : lin.-lin. plot
#                                      #   2 : lin.-log. plot
#                                      #   3 : log.-lin. plot
#                                      #   4 : log.-log. plot
#DCL.grstrf                            # determine axes, 
#DCL.usdaxs                            # draw axes
#DCL.uulin( temp, press )              # draw a line
#DCL.uuslnt(2)                         # set line type
#DCL.uuslni(2)                         # set line index
#DCL.uulin( temp + 5, press )          # draw a 2nd line
# --- detailed version until here ---

DCL.grcls
