IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 27, 2018, 3:20:35 PM (8 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/czw_branch/20170908/Ohana
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20170908/Ohana

  • branches/czw_branch/20170908/Ohana/src/opihi/cmd.data/test/periodogram.sh

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