#! /bin/bash

#...

#rm -f MASK_EE.fits
#ellip_mask EGRESS_PWR_X_T_9.0-11.0mHz.fits 457 466 0.0012 0.0012 0.0 \
#    MASK_EE.fits

#ds9 MASK_EE.fits -scale limits 0.0 1.0 EGRESS_PWR_X_T_9.0-11.0mHz.fits \
#    -scale limits 0 5280.0

#ds9 MASK_EE.fits -scale limits 0.0 1.0 DOPP.fits -scale limits -5000 5000

rm -f LIST_EE.txt
#list_z_profile DOPP.fits MASK_EE.fits > LIST_EE.txt
list_z_profile MAG.fits MASK_EE.fits > LIST_EE.txt

##---------

#rm -f MASK_SE.fits
#ellip_mask EGRESS_PWR_X_T_9.0-11.0mHz.fits 471.5 465 0.0010 0.0006 120.0 \
#    MASK_SE.fits

##ds9 MASK_SE.fits -scale limits 0.0 1.0 EGRESS_PWR_X_T_9.0-11.0mHz.fits \
##    -scale limits 0 5280.0

rm -f LIST_SE.txt
#list_z_profile DOPP.fits MASK_SE.fits > LIST_SE.txt
list_z_profile MAG.fits MASK_SE.fits > LIST_SE.txt

#---------

#rm -f MASK_NW.fits
#ellip_mask EGRESS_PWR_X_T_9.0-11.0mHz.fits 474.0 466 0.0010 0.0006 120.0 \
#    MASK_NW.fits

##ds9 MASK_NW.fits -scale limits 0.0 1.0 EGRESS_PWR_X_T_9.0-11.0mHz.fits \
##    -scale limits 0 5280.0

rm -f LIST_NW.txt
#list_z_profile DOPP.fits MASK_NW.fits > LIST_NW.txt
list_z_profile MAG.fits MASK_NW.fits > LIST_NW.txt

#---------

#rm -f MASK_C1.fits
#ellip_mask EGRESS_PWR_X_T_9.0-11.0mHz.fits 462.0 466 0.0010 0.0006 120.0 \
#    MASK_C1.fits

##ds9 MASK_C1.fits -scale limits 0.0 1.0 EGRESS_PWR_X_T_9.0-11.0mHz.fits \
##    -scale limits 0 5280.0

rm -f LIST_C1.txt
#list_z_profile DOPP.fits MASK_C1.fits > LIST_C1.txt
list_z_profile MAG.fits MASK_C1.fits > LIST_C1.txt

#---------

#rm -f MASK_C2.fits
#ellip_mask EGRESS_PWR_X_T_9.0-11.0mHz.fits 467.0 466 0.0010 0.0006 120.0 \
#    MASK_C2.fits

##ds9 MASK_C2.fits -scale limits 0.0 1.0 EGRESS_PWR_X_T_9.0-11.0mHz.fits \
#    -scale limits 0 5280.0

rm -f LIST_C2.txt
#list_z_profile DOPP.fits MASK_C2.fits > LIST_C2.txt
list_z_profile MAG.fits MASK_C2.fits > LIST_C2.txt

#---------

rm -f FIG00.pro
echo 'setps, height = 15.0' > FIG00.pro
echo 'loadct, 6' >> FIG00.pro
echo 'xr = [0.0, 3.0]' >> FIG00.pro
echo 'yr = [-5000.0, 4000.0]' >> FIG00.pro
echo 'read_ascii, "LIST_EE.txt", t, vee' >> FIG00.pro
echo 'read_ascii, "LIST_SE.txt", t, vse' >> FIG00.pro
echo 'read_ascii, "LIST_NW.txt", t, vnw' >> FIG00.pro
echo 'read_ascii, "LIST_C1.txt", t, vc1' >> FIG00.pro
echo 'read_ascii, "LIST_C2.txt", t, vc2' >> FIG00.pro
echo 'plot, xr, -5000*[1, 1], $' >> FIG00.pro
echo 'xrange = xr, yrange = yr, /xstyle, /ystyle, $' >> FIG00.pro
echo 'xtitle = "Time(hr)", $' >> FIG00.pro
echo 'ytitle = "Magnetic Field(los, Gauss)", $' >> FIG00.pro
echo 'title  = "LOS Magnetic Profiles of Transient Seismic Sources"' \
     >> FIG00.pro
echo 'oplot, t/3600 + 1.0, vee + 1500, color =   30' >> FIG00.pro
echo 'oplot, t/3600 + 1.0, vse +    0, color =   60' >> FIG00.pro
echo 'oplot, t/3600 + 1.0, vnw - 1500, color =   90' >> FIG00.pro
echo 'oplot, t/3600 + 1.0, vc1 - 3000, color =  150' >> FIG00.pro
echo 'oplot, t/3600 + 1.0, vc2 - 4500, color =  200' >> FIG00.pro
echo 'oplot, [1.16, 1.16],         yr, color =  100' >> FIG00.pro

echo 'xyouts, 1.5,  2000, "East Kernel", $' >> FIG00.pro
echo '    alignment = 0.0' >> FIG00.pro
echo 'xyouts, 1.5,  1200, "South-East Kernel", $' >> FIG00.pro
echo '    alignment = 0.0' >> FIG00.pro
echo 'xyouts, 1.5,  -800, "North-West Kernel", $' >> FIG00.pro
echo '    alignment = 0.0' >> FIG00.pro
echo 'xyouts, 1.5, -2000, "Control 1", $' >> FIG00.pro
echo '    alignment = 0.0' >> FIG00.pro
echo 'xyouts, 1.5, -3200, "Control 2", $' >> FIG00.pro
echo '    alignment = 0.0' >> FIG00.pro

echo 'loadct, 0' >> FIG00.pro
echo 'end' >> FIG00.pro

echo '.run idl_progs' > IDL_INSTRUCTS.txt
echo '.run FIG00' >> IDL_INSTRUCTS.txt
echo 'exit' >> IDL_INSTRUCTS.txt

rm -f idl.ps
idl IDL_INSTRUCTS.txt

rm -f FIG02.eps
mv idl.ps FIG02.eps
open FIG02.eps
