IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 26, 2017, 5:50:29 AM (9 years ago)
Author:
eugene
Message:

add some more tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20170822/src/opihi/cmd.data/test/periodogram.sh

    r27435 r40143  
    110110end
    111111
     112# test using random samples, offset start, non-zero DC
     113macro test5
     114 $PASS = 1
     115 break -auto off
     116
     117 local P PI
     118 $PI = 3.14159265359
     119 $P  = 15.0
     120
     121 delete -q x t f period power
     122
     123 create x 500 800
     124 set t = 300 * rnd(x) + 500
     125 set f = sin(2*$PI*t/$P) + 0.5
     126
     127 periodogram t f 2 30 period power
     128
     129#  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
     130#  lim -n 1 period power; clear; box; plot period power
     131
     132 peak -q period power
     133
     134 if (abs ($peakpos - $P) > 0.05)
     135   $PASS = 0
     136 end
     137end
     138
     139# test using random samples, offset start, non-zero DC, some noise
     140macro test6
     141 $PASS = 1
     142 break -auto off
     143
     144 local P PI
     145 $PI = 3.14159265359
     146 $P  = 15.0
     147
     148 delete -q x t f period power
     149
     150 create x 500 800
     151 set t = 300 * rnd(x) + 500
     152 set fraw = sin(2*$PI*t/$P) + 0.5
     153
     154 # 0.05 : peakpos = 14.95
     155 # 0.10 : peakpos = 15.04 (
     156 gaussdev df t[] 0.0 0.25
     157 set f = fraw + df
     158
     159 periodogram t f 2 30 period power
     160
     161#  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
     162#  lim -n 1 period power; clear; box; plot period power
     163
     164 peak -q period power
     165
     166 if (abs ($peakpos - $P) > 0.05)
     167   $PASS = 0
     168 end
     169end
     170
     171# test using fewer random samples, offset start, non-zero DC, some noise
     172macro test7
     173 $PASS = 1
     174 break -auto off
     175
     176 local P PI
     177 $PI = 3.14159265359
     178 $P  = 15.0
     179
     180 delete -q x t f period power
     181
     182 create x 0 100
     183 set t = 100 * rnd(x)
     184 set fraw = sin(2*$PI*t/$P) + 0.5
     185
     186 # 0.05 : peakpos = 14.95
     187 # 0.10 : peakpos = 15.04 (
     188 gaussdev df t[] 0.0 0.25
     189 set f = fraw + df
     190
     191 periodogram t f 2 30 period power
     192
     193#  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
     194#  lim -n 1 period power; clear; box; plot period power
     195
     196 peak -q period power
     197
     198 if (abs ($peakpos - $P) > 0.05)
     199   $PASS = 0
     200 end
     201end
     202
     203# test using fewer random samples, high frequency, non-zero DC, some noise
     204macro test8
     205 if ($0 != 2)
     206   echo "USAGE: test8: Ndays")
     207   break
     208 end
     209 
     210 local Ndays
     211 $Ndays = $1
     212
     213 $PASS = 1
     214 break -auto off
     215
     216 local P PI
     217 $PI = 3.14159265359
     218 $P  = 0.8*rnd(0) + 0.2
     219 $trueP = $P
     220
     221 delete -q x t f period power
     222
     223 create x 0 $Ndays
     224
     225 # t is a time in days, but we always have 4 within 1 hour:
     226 set t0 = int(100 * rnd(x))
     227 set dtx = (3/24) * rnd(x)
     228 set t0 = t0 + dtx
     229
     230 set dt1 = (15.0 / 1440) * rnd(x) + ( 0 + 7.5) / 1440
     231 set dt2 = (15.0 / 1440) * rnd(x) + (15 + 7.5) / 1440
     232 set dt3 = (15.0 / 1440) * rnd(x) + (30 + 7.5) / 1440
     233
     234 delete -q t
     235 concat t0 t
     236 set tmp = t0 + dt1; concat tmp t
     237 set tmp = t0 + dt2; concat tmp t
     238 set tmp = t0 + dt3; concat tmp t
     239
     240 set fraw = sin(2*$PI*t/$P) + 0.5
     241
     242 # 0.05 : peakpos = 14.95
     243 # 0.10 : peakpos = 15.04 (
     244 gaussdev df t[] 0.0 0.25
     245 set f = fraw + df
     246
     247 periodogram t f 0.1 2.0 period power
     248
     249#  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
     250#  lim -n 1 period power; clear; box; plot period power
     251
     252 peak -q period power
     253
     254 if (abs ($peakpos - $P) > 0.05)
     255   $PASS = 0
     256 end
     257end
     258
    112259# Memory test
    113260macro memtest1
Note: See TracChangeset for help on using the changeset viewer.