USAGE:   
           redtp { -S | -T }  { MJD | -i index }


           redtp { MJD | -i index } [word word ...]
 
 PURPOSE:
            Utility for plotting super-campaign results:
            return the reduced tp-time of a sample
. Writes to STDOUT
            Called within do-merging-job

 NOT TOO VERSATILE:
            Depending on the parametrisation in urtapm, this script
            might require further adaptation in do-merging-job
            See Example 3 below.           
 
 OPTIONS:
   -S     - generate GMT-symbol commands, psxy -S.. -W.. -G.. with y-offsets
            for our sets of Instruments, Platforms, Orientations
            Colour distinguishes Instruments
            y-offsets distinguish Platforms
            Upright or inverted triangles distinguish Orientation
 
   -T     - generate GMT pstext input to print date strings
 
  Neither -S nor -T:
            print reduced index and word word ...
 
   -i #i  - query by series index i. Default is by MJD (Modified Julian Date)
 
 
ENVIRONMENT:

   ORIENTATION_EQUIVALENT_COMMAND <command-or-script>
            Depending on the intrument/platform/orientation
            logistics in urtapm a code might be translated
            into another one for plotting.
            Example:
               setenv ORIENTATION_EQUIVALENT_COMMAND orientation-A-is-S
            with the simple script containing sed 's/A/S/'
            The result of the translation should yield
            S N or U . Other results need extension in the
            do_symbols part of the script (new symbols at
            different y-offset etc.)
 
   PLATFORM_EQUIVALENT_COMMAND <command-or-script>
            same as above, for the platform code, however
            The result of the translation should yield
            AA AS AC or AU . Other results need extension in the
            do_symbols part of the script
 
   VAR <variant>
            Preferably with a leading minus, like -O
            Will mark all (?) file names out (and some in)
            in order to distinguish different solutions
            depending on parameters in the urtapm job.
 
 

 FILES:
   Fixed tp-mc-file:   o/scg-cal-merged$var.ra.mc
   Tsf-edit commands:  tp.tse         
 
 EXAMPLES:  
 (1)
   set projects = ( `awk '/^#D/{print $3}' project-dates.lst` )
   # The projecs can be selected more narrowly, of course.
   echo $projects[10]
   redtp -i `tp-index-of-project $projects[10]`
 
 (2)
   setenv CLIPDTP 3.
   setenv VAR -AUN
   awk '/^#J/{printf "redtp -S %13.6f %s %s %s\n", ($4+$5)/2,$6,$7,$8}' project-dates.lst | uniq > ! redtp.cmd
   source redtp.cmd    # to be launched inside a script like  plot-tp
 
 redtp.cmd  consists of GMT-calls like
   psxy <<EOF -R -JX -K -O -G255/0/0 -W1/255/0/0 -St0.08 >> $ps
   9.591551 -1000
   EOF
 for each project

(3) Analysing orientation offsets per instrument.
The orientation code coming with the platform code in the results of urtapm
(like t/feature$VAR.tbl ) will have lost all distinction. The code must be obtained from somewhere else.
 In this script the following lines decode instrument, platform and orientation
    set ori = `echo $3 | $orientalt`
    set plf = `echo $2 | $platfalt`
Both variables are set to cat by default, and optionally redefined from the environment as explained above.
    set gmt = ( )

    set gmt = (      `echo $1   | awk '{sub(/FG5-220/,"-G255/0/0 -W1/255/0/0",$0);sub(/FG5-233/,"-G0/0/255 -W1/0/0/255",$0);print $0}'` )

    set gmt = ( $gmt `echo $ori | awk '/N/{print "-St0.08"} /S/{print "-Si0.08"} /U/{print "-Sc0.07"}'` )

    set y   = ( `echo $plf $ori | awk 'BEGIN{y=0} ($2 ~ "N"){y=12} ($2 ~ "S"){y=-12} ($2 ~ "U"){y=0} \
                                       /AU/{print y-1150} /AA/{print y-1050} /AC/{print y-950} /AS/{print y-850} /AN/{print y-750}'` -1200 )

To some extent, these rules can be extended. What gets printed for $y must be coherent with the layout of the plot,
check with plot-merged-residual
In do-merging-job , section prepare_plot , the following lines will replace an orientation code U or A
to the one attached to the project:
    set r = ( `tp-index-of-project $features $p` )
    if ( $r[4] == A || $r[4] == U ) set r = ( $r[1-3] `the-orientation-of -S $p` was $r[4] )

 
...

.bye