Honing decimation filters


The task: Construct a low-pass filter that has its first zero --- and a good one! --- at the Nyquist frequency of a decimation.
The solution for symmetric Kaiser-Bessel window-design filters is given here.

Step 1: Use sasm02 to make a good guess

Step 2: Use fwwd-iteration
            You can plot the filter spectrum easily if you use the -I -O -mechanism

Program fwwd-iteration

USAGE:
       fwwd-iteration -f
#frq [options] <filter parameters>
 
     fwwd-iteration -f#frq [options] -I tse-file,target [-O new-tse-file]

PURPOSE:
       
Improve the position of the first zero by one of two variants,
        Strategy 1 := move the band edge
        Strategy 2 := extend the length of the filter
        which is always followed by iterative increase
of the Kaiser-parameter p
        and finally bisection. The increase of p will always be slight.
        (Next extension: estimating the leakage that is aliased into the
        decimated series).

FILTER PARAMETERS:
        FILTER D:WD KAIS #lng #wdp #f1 #f2 #fny #fcal
       
FILTER D:WD KAIS  24   2.2 0.0 0.2  0.5  0.0
   
        The upper band edge f2 can be given within a liberal tolerance,
        since a good guess is already made w.r.t. -f#frq  alt. -D#ndeci

OPTIONS:

 -f#frq      - The dimensionless frequency of the zero point
               (here unity ALWAYS means the sampling frequency).
 -D#ndeci    - Alternative to -f: Specify the decimation factor,
               frq = 1/
ndeci

 -i#maxit    - Maximum number of iterations                            [32]

 -e#eps      - Tolerance for the filter response at frq            [1.d-10]

 -dp#v       - Starting step size for Kaiser parameter iteration     [0.01]

 -df#v       - Starting step size for band edge
iteration          [-0.001]

 -dfi#v      - Initial iteration step for band edge                 [0.005]
               (This is to assure that the first zero is
               above the band edge)

 -S#s        - Strategy code s , 1 (band edge) or 2 (filter length)
               2 is indicated if band edge is critical,          
               1 if filter length is critical
                           [1]

 -I file,target
             - take the first FILTER command from a tse-file.
               This will copy the segment of the tse-file,
               invalidate the old and insert a new FILTER command

 -O[A] file  - Output (-OA: append) the FILTER command (and under
              
-I the tse-file segment) to file

 -L#eps      - Compute filter leakage. Iterate until change
               is less than eps. Don't if eps < 0                    [-1.0]

EXAMPLES:

       (1)   fwwd-iteration -f0.25 FILTER D:WD KAIS 24 2.2 0.0 0.2 0.5 0.0
FILTER D:WD KAIS   24 2.2081003952 0.0  0.203000  0.500 0.0

       (2)   setenv TSTFRQ 0.16666666667
             fwwd-iteration -f$TSTFRQ -I deci.tse,D3 -O newdeci.tse

       (3)   fwwd-iteration -L1.d-4 -S2 -f0.25 FILTER D:WD KAIS 24 2.2 0.0 XXX 0.5 0.0
...
FILTER D:WD KAIS   57 2.2221317291 0.0  0.230000  0.500 0.0
 <LpLeak>>> It.  1 Theo: 0.2500000 Pass: 0.2262110 Stop:  6.46E-10 Changes:   1.00E+00  1.00E+00 Goodness: 0.95123
 <LpLeak>>> It.  2 Theo: 0.2500000 Pass: 0.2260889 Stop:  6.57E-10 Changes:   5.40E-04  1.64E-02 Goodness: 0.95098
 <LpLeak>>> It.  3 Theo: 0.2500000 Pass: 0.2260278 Stop:  6.58E-10 Changes:   2.70E-04  2.67E-03 Goodness: 0.95085
 <LpLeak>>> It.  4 Theo: 0.2500000 Pass: 0.2259973 Stop:  6.59E-10 Changes:   1.35E-04  3.43E-04 Goodness: 0.95078
 <LpLeak>>> It.  5 Theo: 0.2500000 Pass: 0.2259821 Stop:  6.59E-10 Changes:   6.75E-05  2.52E-05 Goodness: 0.95075
 <LpLeak>>> Stop-band eff.width: (N-Nf-1)/N =  0.49994

             Goodness = sqrt(Pass/Theo)
             Stop is a square measure of the leakage. In decibel, 10 × 10log(6.6e-10) ~ -92 dB


PLOTTING
Using the second example:

             plot-filtersp -PNG ~/www/4me/filtersp -E ~/TD/newdeci.tse -ps deci-D3.ps

A variant would be desirable to plot a series of spectra in the same diagram.

&/'  (gone fishing, bye)

&/!