




Python scripts for FIR filter coefficients calculation for feedback.

-- FIR_coef.py

   To get FIR filter coefficients,
   run as 
   $ FIR_coef.py   xxx.py 
        then the result is send stdout, which is the same as output of FIR_coef (xxx.out) shown below.

-- FIR_coef.py

   To get FIR _filter response,
   run as 
   $ FIR_coef.py   xxx.fir or xxx.out 
      then the result is send to stdout, which is the same as output of FIR_resp (xxx.resp) shown below

Shell script file for easy to run python script

-- FIR_make

   To get FIR filter coefficients and its gain and phase response on tune,
   run as

   $ FIR_make xxx.py

   then, FIR_make runs FIR_coef and FIR_resp shown below to get FIR filter coefficients and
   its tune response.

-- FIR_coef

   To make FIR filter coefficients, as 

   $ FIR_coef  xxx.py  <xxx1.py>  <xxx2.py> ...
      ( Multiple input files are accepteed for seaquential processing )
      The output files are
        xxx.fir         Coefficients of FIR filter
        xxx.out         Output file = xxx.fir + comment lines 
        xx.fir has the format (except the lines start with "#" ) 
             number taps of FIR filter
             coef[0]   turn[0]
             coef[1]   turn[1] 
             coef[2]   turn[2] 
             ...

-- FIR_resp 

   To get FIR filter tune response (gain and phase), run as

   $ FIR_resp  output_file_of_FIR_coef (xxx.out or xxx.fir)
      output files are
        xxx.FIR_gain    Gain of FIR filter vs tune   (1st col: tune (0-1), 2nd : gain)
        xxx.FIR_phase   Phases of FIR filter vs tune (1st col: tune (0-1), 2nd : phase in degree)
        xxx.resp        Response of FIR filter for tune

   if you specify target tune as
   $ FIR_resp  output_file_of_FIR_coef  target_tune 
   then, the effecitive gain is calculated.


-- input file ---

For FIR_coef.py, following is an example of the contents of input file.
-- input file contents start here --
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 here --
parameters of /constraints on  FIR filter for each tune 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
   for nu=0, no phase parameter is required.

      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 ) 
##################################
