HOW TO USE  hans-tsplot.env  and parameter setting with  t

hans-tsplot.env is used to plot SG data in the first case. You find it in ~/TD/plot
hans-tsplot.env is a csh/tcsh source script

Quite early after start, hans-tsplot.env contains the lines
 if ( $?TSPLOT_INIT == 1 ) then
   if ( -r $TSPLOT_INIT ) source $TSPLOT_INIT
 endif

So instead of re-engineering the script, you can write a little code fragment for
the setting of some parameters.


Important variables to be set:
 TSPLOT_PSOUT = output.ps
 TSPLOT_FILE = ( a b c )           #one file for every curve
 TSPLOT_LEGTXT = ( a b c )         #short texts, preferably no blanks (use double quotes where blanks are part of strings.
 pen = ( a b c )                   #color codes (triplets)

... optional:
 TSPLOT_TSLIST = ( '"o1 o2 ..."' '"p1 p2 ..."' '"q1 q2 ..."' )  #Options to be passed to tslist
OBS!!! double-quoted '"x y z"' if there is one ore more spaces

 set TSPLOT_OOPT = ( " " "-OB" )   #for a secondary y-axis

A way to get curves with offsets by curve number:make use of internal variables $i and $yofi
Internally the following expression is used:  set yofi=`calc $TSPLOT_DY'*'$i`
Thus:
 set TSPLOT_TSLIST = ( '-SM' '"-SM -Y$i"' )     #is possible
 set TSPLOT_TSLIST = ( '-D' '"-D -Y$yofi"' )    #is possible too
                                                #after set TSPLOT_DY = factor
                                                #or  TSPLOT_DY = ( 'const + factor' )  
 
 TSPLOT_XAXTYPE = ( type titletext )            #[Default: ( -J MJD ) ]
 TSPLOT_KALY = ( offset )                       #for a kalendar axis


Variables to be setenv:
 TSPLOT_TITLE                                   #Title for the plot
 TSPLOT_YTITLE                                  #Title for the Y-axis

Conditional interleaving scripts:
The following files are sourced-in if they exist (set-variables)
 $TSPLOT_INIT     at the start of the script
 $TSPLOT_PREP     before the first curve drawing call
 $TSPLOT_PREP_##  where ## is the number of the curve being drawn,
                                     before drawing curve 2, 3 etc.
 $TSPLOT_POST     after the last curve but before the legend is plotted.
The easiest method is to create a little library of code fragments
and link them, e.g.
set TSPLOT_POST = TSPLOT_usgs
(example adds a set of symbols representing earthquakes, Magnitude vs MJD) 

Example:
 TSPLOT_PREP_airpressure is a file with a code fragment:
 setenv TSPLOT_YR 920/1050
 setenv TSPLOT_YTIX a20f2
 setenv TSPLOT_YTITLE "Pressure [hPa]"

It is invoked after
 setenv TSPLOT_PREP_02
TSPLOT_PREP_airpressure
and the secondary axis with the title "Press.." is drawn if
 set TSPLOT_OOPT = ( " " "-OB" )
has been set.

There is heavy interplay with set-variables and environment variables:
  - tsplot interacts with Environment
  - the driver script uses set variables, in many cases arrays.
 
Utility to code the TSPLOT_INIT file:  t

 setenv TSPLOT_INIT = the-init-file
 t par val [ val ... ]

 t will write appropriate set / setenv lines into the-init-file:

 set    TSPLOT_ucase(par) = ( val val ... )   
 setenv TSPLOT_ucase(par) "val val"
using an internal list as to which par's are ENV parameters and which are cshell-variables. Adhering to this distinction is the main purpose of  t
Internally, t uses the following command to that end
 set tt = `awk -v t=$t \
 'BEGIN{if ( "KALY-TITLE-XTITLE-YTITLE-XR-XTIX-YR-YTIX-AXES-SIZE-Y0-P-" ~ t"-" ){print "ENV"}else{print "SH"}}'`
Then, depending on $tt set or setenv commands are executed. Why do we need to this like that? Well, in the ENV you cannot work with arrays as easily as in the csh., 
 
Some examples:
 setenv TSPLOT_YR -20/20

 setenv TSPLOT_YTIX a50f10
 setenv TSPLOT_XR 55000/55250
 setenv TSPLOT_XR 55165/55167
 setenv TSPLOT_XTIX a50f10
 setenv TSPLOT_XTIX a1f0.08333333
 setenv TSPLOT_XR 55010/55045
 setenv TSPLOT_XTIX a10f1
 setenv TSPLOT_XR 54990/55250
 setenv TSPLOT_XTIX a50f10
 setenv TSPLOT_XR 75/85
 setenv TSPLOT_XTIX a5f1
 setenv TSPLOT_YTITLE 'Signal [nm/s@+2@+]'
 setenv TSPLOT_YTITLE 'Pressure [hPa]'
 setenv TSPLOT_YTITLE '[@~m@~Gal]'
 setenv TSPLOT_TITLE "Onsala 2009-Nov-10 15:00 -- 16:45 UT"

After these preparations you can issue
 source hans-tsplot.env

Example: Free Oscillations

 echo Sourcing fo.init
 setenv TSPLOT_TITLE "Chile Eq. Feb. 27, 2010, SCG Onsala"
 setenv TSPLOT_XR "0/15"
 setenv TSPLOT_XTIX "a1f0.0416667"
 setenv TSPLOT_XTITLE "Hours"
 set TSPLOT_LEGTXT = ( ''SCG FO-bandp.'' )
 set TSPLOT_XAXTYPE = ( '-Nf10.5 -n/5760' 'Day after 2010-02-27' )
 set TSPLOT_FILE = ( '../o/fo.ts' )
 setenv TSPLOT_YR "-0.15/0.15"
 setenv TSPLOT_YTIX a0.1f0.02
 setenv TSPLOT_YTITLE 'Signal [-]'
 set TSPLOT_LEGX = ( '7' )
 set TSPLOT_PSOUT = ( 'fo-chile-100227.ps' )
 set TSPLOT_LEGTXT = ( '"SCG FO-bandp."' )
 set TSPLOT_TSLIST = "'-D -BHc2010,2,27,10'"
 echo fo.init end

Example: Many curves

Here you'll see that you are free to add programming after setting the most important parameters with t
or to not use t at all, editing an available script.

 echo Sourcing many-signals.init
 set TSPLOT_FILE = ( )
 set TSPLOT_LEGTXT = ( )
 set TSPLOT_POST = many-signals.post
 foreach i ( `fromto $from $to` )
 @ ii = $i
 set TSPLOT_FILE = ( $TSPLOT_FILE ../signals/A2_${ii}_100203-60s.ts )
 set TSPLOT_LEGTXT = ( $TSPLOT_LEGTXT  `xchan-units -H $i ../RAW_o054/A2100203.054` )
 end
 echo $TSPLOT_FILE
 echo $TSPLOT_LEGTXT

 set TSPLOT_XAXTYPE = ( '-Nf8.4 -n/60.' 'Hour' )
 setenv TSPLOT_XR "0/24"
 setenv TSPLOT_XTIX "a1f0.166666667"
 setenv TSPLOT_XTITLE "Hour"
 setenv TSPLOT_TITLE "2010-02-03"
 set TSPLOT_TSLIST = ( "'-SOM0.5 -Un1440'" "'-SOM0.5 -Un1440 -Y"'$ic'"'" )
 setenv TSPLOT_YR "-1/10"
 setenv TSPLOT_YTITLE "Signal [mapped]"
 set TSPLOT_PSOUT = ( 'many-signals.ps' )
 setenv TSPLOT_SIZE "9/6"
 setenv TSPLOT_XR "-6/24"
 set TSPLOT_LEGSIZ = ( '1.7/5.45' )
 set TSPLOT_LEGY = ( 0.4 )
 set pen = ( '`autocolor 20 $i`' )
 set pth = ( 3 3 )
 echo End many-signals.init

Good luck, good bye.