IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42114 for trunk/ippTests


Ignore:
Timestamp:
Mar 16, 2022, 3:28:13 PM (4 years ago)
Author:
eugene
Message:

better code to match chips / masks / smf entries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTests/ippCheck/cammask.pro

    r42031 r42114  
    5252 $smfreal = `neb-locate -p $smffile`
    5353 
     54 # sets the list chipName:0 - chipName:n based on chipRun
    5455 get.chip.metadata $dbname $chipID
     56
     57 # set the list camMask:0 - camMask:n based on nebulous listing
     58 # some cam-stage masks may be missing, these are set to NONE
     59 # the number of entries in both lists is the same (chipName:n)
    5560 get.chip.mask.files $camPath
    5661 
     62 # read in the PHU header
     63 rd PHU $smfreal
     64
     65 # set the list chipNseq:0 - chipNseq:n based on smf entries.
     66 # Some chips may be missing from the smf, these are set to -1
     67 # $chipNseq:n = $chipName:n
     68 get.chip.smf.Nseq $smfreal
     69
    5770 for i 0 $camMask:n
    58    echo $chipName:$i $camMask:$i
     71   echo $chipName:$i $chipNseq:$i $camMask:$i
    5972 end
    6073
     
    7184 set Nref = ramp(Rref)
    7285
    73  # read in the PHU header
    74  rd PHU $smfreal
    75 
    76  # create the chipName list from the smffile and calculate the index numbers.
    77  # NOTE: if a chip is missing from the smf, this may be inconsistent with chipMask:n
    78  # XXX for now, we fail is this happens
    79  list chipsRaw -x "ftable -list $smfreal | grep -n hdr | prcol 1 | sed s/.hdr//"
    80  for i 0 $chipsRaw:n
    81   list word -splitbychar : $chipsRaw:$i
    82   $chipNseq:$i = $word:0 - 3; # this number depends on the number of leading tables
    83   if ("$chipName:$i" != "$word:1")
    84     echo "ERROR: missing chip from smffile: " $chipName:$i
    85     break
    86   end
    87  end
    88 
    89   # delete any existing output vectors
    90   foreach field $SMF_FIELDS_CAM $REF_FIELDS_CAM $XTR_FIELDS_CAM
    91     delete -q $field\_out
    92   end
     86 # delete any existing output vectors
     87 foreach field $SMF_FIELDS_CAM $REF_FIELDS_CAM $XTR_FIELDS_CAM
     88   delete -q $field\_out
     89 end
    9390
    9491 # find matching entries in smf file
    9592 for i 0 $chipName:n
     93   ## echo $chipName:$i $chipNseq:$i $camMask:$i
     94
     95   if ($chipNseq:$i < 0) continue
     96
    9697   get.chip.detect.stats $chipName:$i $chipNseq:$i
    97    get.chip.mask.stats $camMask:$i
     98
     99   if ("$camMask:$i" == "NONE")
     100     # if the mask files are missing, all are masked or unmasked?
     101     set Q1ref_onchp = zero(Xref_onchp) + 1.0
     102   else
     103     get.chip.mask.stats $camMask:$i
     104   end
    98105
    99106   foreach field $SMF_FIELDS_CAM
     
    241248
    242249 # get the full list from nebulous (faster than getting each one at a time)
    243  list tmpName -x "neb-ls $pathbase.%.mk.fits"
     250 list tmpName -x "neb-ls -c $pathbase.%.mk.fits"
    244251
    245252 # the list of masks might not match the list of chips
     253 # mark missing cam-stage masks with NONE
    246254 $j = 0
     255 echo "chipName:n $chipName:n"
    247256 for i 0 $chipName:n
     257   # if we get to the end of the list, assign the missing entries to NONE
     258   if ($j >= $tmpName:n)
     259    $camMask:$i = NONE
     260    continue
     261   end
    248262   list word -splitbychar . $tmpName:$j
    249263   $Nch = $word:n - 3
     
    254268   end
    255269   $camMask:$i = $tmpName:$j
    256    if ($VERBOSE) echo "found chipMask $camMask:$i"
     270   if ($VERBOSE) echo "found chipMask $camMask:$i ($chipName:$i) : $i $j $chipName:n $tmpName:n"
    257271   if ($COPYMASKS) exec neb-copy $camMask:$i $OUTDIR
    258272   $j ++
    259273 end
    260274 $camMask:n = $chipName:n
     275end
     276
     277# get the file names of the chip mask files.
     278# these are actually the masks from the camera stage which
     279# has the dynamic masking applied
     280macro get.chip.smf.Nseq
     281 if ($0 != 2)
     282  echo "USAGE: get.camera.smf.Nseq (smffile)"
     283  echo " sets chipNseq:0 - chipNseq:n"
     284  break
     285 end
     286
     287 local i j smffile
     288 $smffile = $1
     289
     290 # identify the chips in the smffile and calculate the index numbers.
     291 # NOTE: if a chip is missing from the smf, set Nseq to -1
     292 list chipsRaw -x "ftable -list $smfreal | grep -n hdr | prcol 1 | sed s/.hdr//"
     293
     294 $j = 0
     295 for i 0 $chipName:n
     296   # if we get to the end of the list, assign the missing entries to NONE
     297   if ($j >= $chipsRaw:n)
     298    $chipNseq:$i = -1
     299    continue
     300   end
     301   list word -splitbychar : $chipsRaw:$j
     302   $myNseq = $word:0 - 3; # this number depends on the number of leading tables
     303   $mychip = $word:1
     304   if ($mychip != $chipName:$i)
     305    $chipNseq:$i = -1
     306    continue
     307   end
     308   $chipNseq:$i = $myNseq
     309   if ($VERBOSE) echo "found chip entry $chipNseq:$i ($chipName:$i) : $i $j $chipName:n $chipsRaw:n"
     310   $j ++
     311 end
     312 $chipNseq:n = $chipName:n
    261313end
    262314
Note: See TracChangeset for help on using the changeset viewer.