

if test $# -lt 1 ; then
   echo "usage: `basename $0`  FIR_filter_python_file1  <FIR_filter_python_file2 ... >"
cat <<BLOCK 
##################################
### example of input python file
#--- BEGIN --
turnL = [ 1,2,4,5,7,8,9 ]                         # previous turn number for position data
tune0 = {"nu":0,    "gain":0,             "order":0 } # parameters for tune1 
tune1 = {"nu":0.15, "gain":1, "zeta":-30, "order":1 } # parameters for tune2  
tuneL = [ tune0, tune1 ]                              # list of parameters defined
#--- END --
# parameters are
#   nu     : target tune
#   gain   : gain at target tune 
#   zeta   : phase at target tune in degree
#   order  : order of the Tylor expansion for tune shift around target tune
#      order = 0 : filter is just band pass filter, 
#      order = 1 : to make flat region in gain and phase around target tune 
#      order = 2 : to make more wider flat region in gain and phase around target tune
#          ....
#      the FIR filter calculated have the tune response at targe tunes
#        G(nu) = gain * exp( i*zeta )
#        d^n G(nu)/dnu^n = 0 at nu for n = 1,2, .., order 
#          (flat gain and phase around nu if order != 0 ) 
#   for nu=0, no phase parameter is required.
#
##################################
BLOCK
   exit
fi

for FILE in $* ; do
  if test ! -f $FILE ; then
    echo file: $FILE not found
  else
    echo $FILE
    NAME=`echo $FILE | sed 's/.py$//g' `
    OUT=${NAME}.out
    FIR=${NAME}.fir
    echo "FIR_coef $FILE -> ${OUT} ${FIR}"
    FIR_coef  $FILE 
    echo "FIR_resp ${FIR}"
    echo "   -> ${NAME}.resp    ${NAME}.FIR_gain   ${NAME}.FIR_phase" 
    FIR_resp   ${NAME}.out
  fi 
done    
