IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14071


Ignore:
Timestamp:
Jul 8, 2007, 3:33:31 PM (19 years ago)
Author:
eugene
Message:

adding detrend sequencing tools

Location:
trunk/ippTasks
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTasks/mkdetrend.pro

    r8193 r14071  
    11
    2 input detrend.mkruns.pro
    3 input detrend.process.pro
    4 input detrend.stack.pro
    5 input detrend.norm.pro
    6 input detrend.resid.pro
    7 input detrend.assess.pro
    8 
     2# example output from a dettool -definebyquery
     3# detRun  METADATA 
     4#    det_id           STR       3               
     5#    iteration        S32       0             
     6#    det_type         STR       SHUTTER         
     7#    mode             STR       master         
     8#    state            STR       run             
     9#    filelevel        STR       FPA             
     10# END
     11
     12macro load.detRunDefs
     13  if ($0 != 2)
     14    echo "USAGE: load.detRunDefs (filename)"
     15    break
     16  end
     17  queueload detruns -x "cat $1"
     18  ipptool2book detruns detRunDef -key detRunName
     19  queuedelete detruns
     20end
     21
     22task detrun.launch
     23  host         local
     24
     25  periods      -poll 1
     26  periods      -exec 5
     27  periods      -timeout 30
     28  active       true
     29  npending     1
     30
     31  # each outstanding detrend run blocks the next one.  only launch the next
     32  # if the current one is done
     33  task.exec
     34    local i N found detRunName prereq prereqState cmdOptions dbname
     35
     36    # how many detRunDefs are waiting to be started?
     37    book npages detRunDef -var N -key pantaskState NULL
     38    echo "detrun.launch N: $N"
     39    if ($N == 0) break
     40
     41    $found = 0
     42
     43    # search the detRunDef book for an entry which is unstarted (state NULL)
     44    # and for which the dependencies are done
     45    for i 0 $N
     46      book getpage detRunDef $i -var detRunName -key pantaskState NULL
     47      echo "detrun.launch detRunName: $detRunName"
     48      if ("$detRunName" == "NULL") break
     49
     50      book getword detRunDef $detRunName prereq -var prereq
     51      echo "detrun.launch prereq: $prereq"
     52      echo "detrun.launch detRunName: $detRunName"
     53      if (("$prereq" == "NULL") || ("$prereq" == "NONE"))
     54        $found = 1
     55        last
     56      end
     57
     58      # prereq must exist and be in state of DONE
     59      book getword detRunDef $prereq pantaskState -var prereqState
     60      echo "detrun.launch prereqState: $prereqState"
     61      echo "detrun.launch detRunName: $detRunName"
     62      if ("$prereqState" == "DONE")
     63        $found = 1
     64        last
     65      end
     66
     67      if ($found == 0)
     68        if ($VERBOSE >= 2)
     69          echo "$detRunName not ready"
     70        end
     71      else
     72        if ($VERBOSE >= 2)
     73          echo "$detRunName ready"
     74        end
     75      end
     76    end
     77
     78    if ($found == 0) break
     79
     80    echo "detrun.launch detRunName: $detRunName"
     81
     82    book getword detRunDef $detRunName options -var cmdOptions
     83    book getword detRunDef $detRunName dbname -var dbname
     84    book setword detRunDef $detRunName pantaskState INIT
     85
     86    if ($VERBOSE >= 1)
     87      echo "starting detrend $detRunName :"
     88      echo "command dettool $cmdOptions -dbname $dbname"
     89    end
     90
     91    options $dbname $detRunName
     92    command dettool $cmdOptions -dbname $dbname
     93  end
     94
     95  task.exit $EXIT_SUCCESS
     96    local detRunID
     97
     98    $dbname = $options:0
     99    $detRunName = $options:1
     100
     101    # convert 'stdout' to book format
     102    ipptool2book stdout detRun -key det_id -uniq
     103    if ($VERBOSE > 2)
     104      book listbook detRun
     105    end
     106
     107    # we should have launched only a single detRun
     108    book getpage detRun 0 -var detRunID
     109    if ($detRunID == NULL)
     110      echo "ERROR:detRun not defined"
     111      break
     112    end
     113
     114    # we need to track the detID generated
     115    book setword detRunDef $detRunName detRunID $detRunID
     116    book setword detRunDef $detRunName pantaskState RUN
     117
     118    # drop the detRun book after we've grabbed the state
     119    book delete detRun
     120  end
     121end
     122
     123$detRunNcheck = 0
     124
     125# loop over the outstanding detRuns and update state
     126task detrun.check
     127  host         local
     128
     129  periods      -poll 1
     130  periods      -exec 5
     131  periods      -timeout 30
     132  active       true
     133  npending     1
     134
     135  # each outstanding detrend run blocks the next one.  only launch the next
     136  # if the current one is done
     137  task.exec
     138    local i N found detRunName detRunID dbname
     139
     140    book npages detRunDef -var N -key pantaskState RUN
     141    if ($N == 0) break
     142    if ($detRunNcheck >= $N)
     143      $detRunNcheck = 0
     144    end
     145
     146    # try the next detRun entry which is in state RUN
     147    book getpage detRunDef $detRunNcheck -var detRunName -key pantaskState RUN
     148    $detRunNcheck ++
     149
     150    if ("$detRunName" == "NULL")
     151      if ($VERBOSE >= 3)
     152        echo "no more active detruns (Ncheck = $detRunNcheck)"
     153      end
     154      break
     155    end
     156
     157    # info needed to check on current state
     158    book getword detRunDef $detRunName detRunID -var detRunID
     159    book getword detRunDef $detRunName dbname -var dbname
     160
     161    if ($VERBOSE >= 2)
     162      echo " checking on $detRunName"
     163      echo "command dettool -runs -det_id $detRunID -dbname $dbname"
     164    end
     165
     166    # we need a dettool command which takes a specific det_id and returns
     167    # the current state
     168    options $dbname $detRunName
     169    command dettool -runs -det_id $detRunID -dbname $dbname
     170  end
     171
     172  task.exit $EXIT_SUCCESS
     173    local detRunID state
     174
     175    $dbname = $options:0
     176    $detRunName = $options:1
     177
     178    # convert 'stdout' to book format
     179    ipptool2book stdout detRun -key det_id -uniq
     180    if ($VERBOSE > 2)
     181      book listbook detRun
     182    end
     183
     184    # we should have launched only a single detRun
     185    book getpage detRun 0 -var detRunID
     186    if ("$detRunID" == "NULL")
     187      echo "ERROR:detRun not defined"
     188      break
     189    end
     190
     191    # what is the current state of the detRun?
     192    book getword detRun $detRunID state -var state
     193
     194    # use any other state?
     195    if ("$state" == "stop")
     196      # update the state for this detRunName, drop detRun page
     197      book setword detRunDef $detRunName pantaskState DONE
     198      echo "$detRunName is done"
     199    else
     200      echo "$detRunName is still running"
     201    end
     202
     203    # drop this book when completed
     204    book delete detRun
     205  end
     206end
  • trunk/ippTasks/pantasks.pro

    r14042 r14071  
    77$scripts = .
    88
    9 $loadpoll = 1
     9$loadpoll = 0.25
    1010$loadexec = 5
    1111$runpoll = 0.5
Note: See TracChangeset for help on using the changeset viewer.