!******************************************************************************!
! Test macro for KAISWIN. There are still minor differences between the X-Midas
! version and the NeXtMidas version; mainly, the NeXtMidas version may force the
! last element of the filter to be 0.
!
! @author  Jason Broussard / J. Czechowski IV
! @version $Id: test_kaiswind.mm,v 1.3 2013/01/09 19:09:44 jxc Exp $
! @since   NeXtMidas 2.1.1
!******************************************************************************!
startmacro
  res l:kaistap 0

  ! ==== GENERATE FILTERS IN NEXTMIDAS =========================================
  kaiswind/ntaps=32        ram:test_filt1  BANDPASS  3.05e6 1e6   0.01e6    5e6
  kaiswind/ntaps=512       ram:test_filt2  BANDPASS  5.05e6 8.1e6 0.01e6   10e6
  kaiswind/ntaps=512       ram:test_filt3  LOW          2e6 ,,,            10e6
  kaiswind/ntaps=1024      ram:test_filt4  LOW          333 ,,,           2.5e6
  kaiswind/ntaps=4096      ram:test_filt5  HIGH     21.93e6 ,,,          28.8e6
  kaiswind/ntaps=64        ram:test_filt6  HIGH       111e6 ,,,           999e6
  kaiswind/ntaps=512       ram:test_filt7  LOW           83 ,,,             100
  kaiswind/ntaps=512       ram:test_filt8  BANDPASS  3.05e6 2.1e6  1.5e6   10e6
  kaiswind/ntaps=64        ram:test_filt9  HIGH       888e6 ,,     222e6  900e6
  kaiswind/ntaps=64        ram:test_filt10 HIGH       555e6 ,,     333e6  777e6 50
  kaiswind/ntaps=32        ram:test_filt11 LOW           22 ,,,             100 30
  kaiswind/taprslt=kaistap ram:test_filt12 BANDPASS  3.05e6   1e6 0.01e6    5e6
  kaiswind/cmplx           ram:test_filt13 BANDPASS  3.05e6   1e6 0.01e6    5e6

  ! ==== COMPATE FILTERS TO PRIOR X-MIDAS RESULTS ==============================
  res D:tolr 2e-6

  file open/d tag nxm.dsp.dat.kaiswinspecs.tmp
    do cnt 1 tag.size
      invoke exp tag.getDataTable(^cnt-1)
      res    act {}
      statistics/onebase ram:test_filt^{cnt} ,act.MEAN,act.STDV,act.ELEM,,act.MAXV,act.MINV,,,act.MAXO,act.MINO

      foreach col inList "MEAN,STDV,MAXV,MINV,ELEM"
        calc delta act.^{col} exp.^{col} - abs
if (delta gt tolr) then
  res exp
  res act
endif
        assert/text="Verifying ^{col} of output file for test ^cnt" delta le tolr
      endfor
    enddo
  file close tag

  assert/text="^reg.main.name: Verifying TAPRSLT switch " ^kaistap eq 3623
endmacro
