IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 9, 2022, 12:36:31 PM (4 years ago)
Author:
eugene
Message:

switch from label to data_group based queries; handle smf files with inconsistent extensions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20211108/ippTests/ippCheck/smfcheck.pro

    r42030 r42031  
    1717  end
    1818
    19   local output expname dgrp1 dgrp2
     19  local output expname dgrp1 dgrp2 saveplot
    2020  $output  = $1
    2121  $expname = $2
     
    3131  $smf2    = `neb-locate -p $smffile`
    3232
     33  $saveplot =
     34  if ($SAVEPLOT)
     35    $saveplot = +plot
     36  end
    3337  smf.compare.all.extensions $output $smf1 $smf2
    3438end
    3539
    3640macro smf.compare.all.extensions
    37   getargs +plot   BOOL  -var SAVEPLOT
     41  # defaults to 'false' if +plot is not provided
     42  getargs +plot     BOOL  -var SAVEPLOT
    3843
    3944  if ($0 != 4)
    40     echo "USAGE: smf.compare.all.extensions (output) (smf1) (smf2) [-plot]"
     45    echo "USAGE: smf.compare.all.extensions (output) (smf1) (smf2)"
    4146    break
    4247  end
     
    6166
    6267  # does the smf have the right number of extensions?
    63   list ext0 -x "ftable -list $smf1"
    64   list ext1 -x "ftable -list $smf2"
    65 
    66   ok ($ext0:n == $ext1:n) "same number of extensions"
    67   if ($ext0:n != $ext1:n)
    68     echo "impossible to continue with mismatched extensions"
    69     echo "smf1 : $smf1"
    70     echo "smf2 : $smf2"
    71     exit 3
    72   end
     68  # generate a list of just the extension names:
     69  list tablelines -x "ftable -list $smf1"
     70  smf.compare.extract.extnames ext0 tablelines
     71
     72  list tablelines -x "ftable -list $smf2"
     73  smf.compare.extract.extnames ext1 tablelines
     74
     75  smf.compare.match.extlists ext0 ext1
     76
     77  ## ok ($ext0:n == $ext1:n) "same number of extensions"
     78  ## if ($ext0:n != $ext1:n)
     79  ##   echo "impossible to continue with mismatched extensions"
     80  ##   echo "smf1 : $smf1"
     81  ##   echo "smf2 : $smf2"
     82  ##   exit 3
     83  ## end
    7384
    7485  # track the number of chips for which the XYnn.hdr keys failed
     
    7788
    7889  # XXX how to do the next steps if the numbers do not match?
    79   # NOTE: ext0:0 is the title line
    80   for i 1 $ext0:n
    81     list w0 -split $ext0:$i
    82     list w1 -split $ext1:$i
    83     ok ($w0:0 == $w1:0) "matching ext names"
    84 
    85     $extname = $w0:0
     90  for Next1 0 $ext0:n
     91    $Next2 = $match1:$Next1
     92    if ($Next2 == -1)
     93      echo "not ok : missing extenion $ext0:$Next1"
     94      next
     95    end
     96
     97    ok ($ext0:$Next1 == $ext1:$Next2) "matching ext names"
     98    $extname = $ext0:$Next1
     99    # NOTE: analysis below uses ext sequence number (i,j)
     100    # extname is only used to name output products
     101
     102    # ippCheckKeys uses 0 == PHU, 1 = 1st extension
     103    # smf.compare.onechip uses 0 = 1st extension
    86104
    87105    # if extname is XYnn.hdr, compare the headers
    88106    strstr -q $extname .hdr -start s1
    89107    if ($s1 == 4)
    90       $Next = $i - 1
    91       echo "# check keys for $extname == FITS entry number $Next"
    92       exec ippCheckKeys $smf1 $Next $smf2 $Next >& $outroot.$extname.keys
     108      echo "##### check keys for $extname == FITS entry number $Next1,$Next2 #####"
     109      echo "##### comparison results in $outroot.$extname.keys               #####"
     110      exec ippCheckKeys $smf1 $Next1 $smf2 $Next2 >& $outroot.$extname.keys
    93111      smf.compare.keys $outroot.$extname.keys hdrKeys
    94112      if ($NfailKeys) set NfailHdr = $NfailHdr + 1
     
    98116    strstr -q $extname .psf -start s1
    99117    if ($s1 == 4)
    100       $Next = $i - 1
    101       echo "# check keys for $extname == FITS entry number $Next"
    102       exec ippCheckKeys $smf1 $Next $smf2 $Next >& $outroot.$extname.keys
     118      echo "##### check keys for $extname == FITS entry number $Next1,$Next2 #####"
     119      echo "##### comparison results in $outroot.$extname.keys               #####"
     120      exec ippCheckKeys $smf1 $Next1 $smf2 $Next2 >& $outroot.$extname.keys
    103121      smf.compare.keys $outroot.$extname.keys psfKeys
    104122      if ($NfailKeys) set NfailPsf = $NfailPsf + 1
    105123
    106       echo "# check fields for $extname == FITS entry number $Next"
    107       smf.compare.onechip $outroot.$extname $smf1 $smf2 {$Next - 1}; # Note smf.compare.onechip counts from 0 = first extension
     124      echo "##### check fields for $extname == FITS entry number $Next1,$Next2 #####"
     125      echo "##### comparison results in $outroot.$extname.txt                  #####"
     126      smf.compare.onechip $outroot.$extname $smf1 {$Next1-1} $smf2 {$Next2-1}; # Note smf.compare.onechip counts from 0 = first extension
    108127    end
    109128  end
     
    116135# generate plot and comparison txt file for one chip (extension)
    117136macro smf.compare.onechip
    118   if ($0 != 5)
    119     echo "USAGE: smf.compare.onechip (output) (smf1) (smf2) (extension)"
    120     break
    121   end
    122 
    123   local output smf1 smf2 extnum
     137  if ($0 != 6)
     138    echo "USAGE: smf.compare.onechip (output) (smf1) (ext1) (smf2) (ext2)"
     139    break
     140  end
     141
     142  local output smf1 smf2 ext1 ext2
    124143  $output = $1
    125144  $smf1 = $2
    126   $smf2 = $3
    127   $extnum = $4
     145  $ext1 = $3
     146  $smf2 = $4
     147  $ext2 = $5
    128148
    129149  dirname $output -var mydir
     
    135155  # load in the full set of data for this extension
    136156  # NOTE : t0 and t1 are used to label the sets of vectors
    137   smf.load.fields $smf1 $extnum t1
    138   smf.load.fields $smf2 $extnum t2
     157  smf.load.fields $smf1 $ext1 t1
     158  smf.load.fields $smf2 $ext2 t2
    139159
    140160  # generate the matched lists (index1, index2)
     
    211231  # add a test here?
    212232  vstat -q dX
    213   ok ($SIGMA < 0.1) "X position stdev < 0.1"
     233  ok ($SIGMA < 0.1) "X position stdev $SIGMA < 0.1"
    214234  vstat -q dY
    215   ok ($SIGMA < 0.1) "Y position stdev < 0.1"
     235  ok ($SIGMA < 0.1) "Y position stdev $SIGMA < 0.1"
    216236end
    217237
     
    607627 book getword mybook $pagename cam_id    -var camID
    608628 book delete mybook
     629end
     630
     631######## generate a list of the entries in list2 which correspond to the entries in list 1
     632macro smf.compare.match.extlists
     633 if ($0 != 3)
     634  echo "USAGE: smf.compare.match.extlists (list1) (list2)"
     635  break
     636 end
     637
     638 # if I can assume the two lists have the same order (with just inserts or deletions in one or the other)
     639 # then I can step through the list only once
     640 # otherwise, I need to do N^2 comparisons?
     641
     642 $list1 = $1
     643 $list2 = $2
     644
     645 $N1 = $$list1:n 
     646 $N2 = $$list2:n 
     647 
     648 for i 0 $N1
     649   $match1:$i = -1
     650 end
     651 $match1:n = $N1
     652
     653 for i 0 $N2
     654   $match2:$i = -1
     655 end
     656 $match2:n = $N2
     657
     658 for i 0 $N1
     659   for j 0 $N2
     660     if ($match2:$j != -1) continue
     661     if ($$list1:$i == $$list2:$j)
     662       $match1:$i = $j
     663       $match2:$j = $i
     664       last
     665     end
     666   end
     667   if ($match1:$i == -1)
     668     echo "ERROR: missing extension $$list1:$i in file 2"
     669   end
     670 end
     671
     672 for j 0 $N2
     673   if ($match2:$j == -1)
     674     echo "WARNING: unexpected extension $$list2:$j in file 2"
     675   end
     676 end
     677end
     678
     679#######
     680macro smf.compare.extract.extnames
     681  if ($0 != 3)
     682    echo "USAGE: smf.compare.extract.extnames (outlist) (inlist)"
     683    break
     684  end
     685
     686  local i j inlist outlist
     687  $outlist = $1
     688  $inlist = $2
     689
     690  # NOTE: inlist:0 is the title line
     691  for i 1 $$inlist:n
     692    $j = $i - 1
     693    list words -split $$inlist:$i
     694    $$outlist:$j = $words:0
     695  end
     696  $$outlist:n = $tablelines:n - 1
    609697end
    610698
Note: See TracChangeset for help on using the changeset viewer.