#! /bin/csh
#
# C shell script for plotting egf-format 3-component waveforms
#   made by Y. Kakehi
#
# 1. set output filename, input filenames, station names, and components

set output   = waveplot1.ps              # output filename
set wave_ew  = a1170546.kob.ew
set wave_ns  = a1170546.kob.ns
set wave_ud  = a1170546.kob.ud
set sta_ew   = "KOB EW"
set sta_ns   = "KOB NS"
set sta_ud   = "KOB UD"
set x_length = 15.0
set t_max    = 100.0

# 2. find maximum amplitude and set shell variable "maxamp"
#   note: egf_format_max1 is a program to output the maximum amplitude
#         of input (egf format) waveform file as standard output

set maxamp = `egf_format_max1` << EOF 
3
$wave_ew
$wave_ns
$wave_ud
EOF

# 3. set parameters for plotting waveforms

set size1        = $x_length/4.0
set range1       = 0/$t_max/-$maxamp/$maxamp
set x_axis       = a10f10:"s":
set y_axis       = a${maxamp}f${maxamp}:"cm/s/s":
set axis_tick_ew = W
set axis_tick_ns = W
set axis_tick_ud = WS
set xorg_ew      = 10.0
set yorg_ew      = 13.0
set xorg_ns      =   .0
set yorg_ns      = -5.0
set xorg_ud      =  0.0
set yorg_ud      = -5.0

# 4. set parameters for drawing station name etc.

set size2     = 10.0/4.5
set range2    = 0/10/0/4.5
set sta_x     = 0.1
set sta_y     = 4.5
set sta_point = 14


# 5a. plot waveform (EW component)
#   note: egf_format1 is a program to output
#           time  amplitude
#         of input (egf-format) waveform file as standard output

egf_format1 << EOF | \
 psxy -JX$size1 -R$range1 -B$x_axis/$y_axis$axis_tick_ew \
 -X$xorg_ew -Y$yorg_ew -V -K >! $output
$wave_ew
EOF

# 5b. draw station name etc. (EW component)

pstext -JX$size2 -R$range2 -V -O -K << EOF >> $output
$sta_x  $sta_y  $sta_point  0.0  0  9  $sta_ew
EOF

# 6a. plot waveform (NS component)

egf_format1 << EOF | \
 psxy -JX$size1 -R$range1 -B$x_axis/$y_axis$axis_tick_ns \
 -X$xorg_ns -Y$yorg_ns -V -O -K >> $output
$wave_ns
EOF

# 6b. draw station name etc. (NS component)

pstext -JX$size2 -R$range2 -V -O -K << EOF >> $output
$sta_x  $sta_y  $sta_point  0.0  0  9  $sta_ns
EOF

# 7a. plot waveform (UD component)

egf_format1 << EOF | \
 psxy -JX$size1 -R$range1 -B$x_axis/$y_axis$axis_tick_ud \
 -X$xorg_ud -Y$yorg_ud -V -O -K >> $output
$wave_ud
EOF

# 7b. draw station name etc. (UD component)

pstext -JX$size2 -R$range2 -V -O << EOF >> $output
$sta_x  $sta_y  $sta_point  0.0  0  9  $sta_ud
EOF







