Index: trunk/ippTasks/detrend.norm.pro
===================================================================
--- trunk/ippTasks/detrend.norm.pro	(revision 9104)
+++ trunk/ippTasks/detrend.norm.pro	(revision 9338)
@@ -14,4 +14,115 @@
 if ($?parallel == 0)
   $parallel = 0
+end
+
+# select images ready for copy 
+# new entries are added to queue DetrendNormStat
+# compare the new list with the ones already selected
+task	       dettool.normstat.load
+  command      dettool -tonormalizedstat -simple
+  host         local
+
+  periods      -poll 1
+  periods      -exec 5
+  periods      -timeout 5
+
+  stdout dettool.normstat.log
+  stderr dettool.normstat.log
+
+  # success
+  task.exit    0
+    # XXX is it necessary for these to be local?
+    # drop after this task macro is done?
+    local i Nqueue
+
+    # compare output with newImage queue
+    # only add entries which don't exist in queue
+    queuesize stdout -var Nqueue
+    for i 0 $Nqueue
+      queuepop stdout -var line
+      list word -split $line
+      $DET_ID   = $word:0
+      $DET_TYPE = $word:1
+      $ITER     = $word:2
+      $CAMERA   = $word:3
+      queuepush DetrendNormStat -uniq -key 1:3 "NEW $DET_ID $DET_TYPE $ITER $CAMERA"
+    end
+
+    # delete existing entries which are DONE
+    queuedrop DetrendNormStat -key 0 DONE
+  end
+
+  # locked list
+  # default exit status
+  task.exit    default
+    echo       "detrend.norm: failure"
+  end
+
+  # operation times out?
+  task.exit    timeout
+    echo       "detrend.norm: timeout"
+  end
+end
+
+# copy new images, sending job to desired host
+task	       dettool.normstat.process
+  periods      -poll 0.5
+  periods      -exec 5.0
+  periods      -timeout 30
+
+  task.exec
+    queuesize DetrendNormStat -var N
+   
+    if ($N == 0) break
+    if ($network == 0) break
+    
+    # look for new images on the internal DetrendNormStat queue
+    # caution with these 'if' statements: syntax errors 
+    # will make the task fail without given a good status
+    queuepop DetrendNormStat -var line -key 0 NEW
+    if ("$line" == "NULL") break
+
+    strpop line state
+    queuepush DetrendNormStat -replace -key 1:3 "RUN $line"
+
+    # the DetrendNormStat queue contains:
+    # STATE DET_ID ITER
+    list word -split $line
+    $DET_ID   = $word:0
+    $DET_TYPE = $word:1
+    $ITER     = $word:2
+    $CAMERA   = $word:3
+
+    # XXX add $WORKDIR/$LOG_DIR
+    stdout $CAMERA.$DET_TYPE.$DET_ID.$ITER.log
+    stderr $CAMERA.$DET_TYPE.$DET_ID.$ITER.log
+
+    # specify choice of remote host:
+    if ($parallel)
+      host anyhost
+    else
+      host local
+    end
+
+    # create example job options as a demonstration
+    options "$line"
+    echo command detrend_norm_calc.pl --det_id $DET_ID --iteration $ITER --det_type $DET_TYPE
+    command detrend_norm_calc.pl --det_id $DET_ID --iteration $ITER --det_type $DET_TYPE
+  end
+
+  # success
+  task.exit 0
+    queuepush DetrendNormStat -replace -key 1:3 "DONE $options:0"
+  end
+
+  # default exit status
+  task.exit    default
+    queuepush DetrendNormStat -replace -key 1:3 "FAIL $options:0"
+  end
+
+  # operation times out?
+  task.exit    timeout
+    queuepush DetrendNormStat -replace -key 1:3 "TIMEOUT $options:0"
+  end
 end
 
@@ -41,5 +152,13 @@
     for i 0 $Nqueue
       queuepop stdout -var line
-      queuepush DetrendNormalize -uniq -key 1:2 "NEW $line"
+      list word -split $line
+      $DET_TYPE = $word:0
+      $CAMERA   = $word:1
+      $URI      = $word:2
+      $DET_ID   = $word:3
+      $ITER     = $word:4
+      $CLASS_ID = $word:5
+      $NORM     = $word:6
+      queuepush DetrendNormalize -uniq -key 4:5 "NEW $DET_TYPE $CAMERA $URI $DET_ID $ITER $CLASS_ID $NORM"
     end
 
@@ -79,17 +198,21 @@
 
     strpop line state
-    queuepush DetrendNormalize -replace -key 1:2 "RUN $line"
+    queuepush DetrendNormalize -replace -key 4:5 "RUN $line"
 
     # the DetrendNormalize queue contains:
     # STATE DET_ID ITER
     list word -split $line
-    $DET_ID   = $word:0
-    $ITER     = $word:1
-
-    # XXX we need to get CAMERA and TYPE from this query
-    # stdout $CAMERA.$TYPE.$DET_ID.$ITER.log
-    # stderr $CAMERA.$TYPE.$DET_ID.$ITER.log
-    stdout isp.flat.$DET_ID.$ITER.log
-    stderr isp.flat.$DET_ID.$ITER.log
+    $DET_TYPE = $word:0
+    $CAMERA   = $word:1
+    $URI      = $word:2
+    $DET_ID   = $word:3
+    $ITER     = $word:4
+    $CLASS_ID = $word:5
+    $NORM     = $word:6
+
+    $LOG_DIR = `dirname $URI`
+
+    stdout $WORKDIR/$LOG_DIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
+    stderr $WORKDIR/$LOG_DIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
 
     # specify choice of remote host:
@@ -102,127 +225,21 @@
     # create example job options as a demonstration
     options "$line"
-    echo command detrend_norm_calc.pl --det_id $DET_ID --iteration $ITER
-    command detrend_norm_calc.pl --det_id $DET_ID --iteration $ITER
+    echo command detrend_norm_apply.pl --det_id $DET_ID --iteration $ITER --class_id $CLASS_ID --value $NORM --input_uri $URI --camera $CAMERA --det_type $DET_TYPE
+    command detrend_norm_apply.pl --det_id $DET_ID --iteration $ITER --class_id $CLASS_ID --value $NORM --input_uri $URI --camera $CAMERA --det_type $DET_TYPE
   end
 
   # success
   task.exit 0
-    queuepush DetrendNormalize -replace -key 1:2 "DONE $options:0"
-  end
-
-  # default exit status
-  task.exit    default
-    queuepush DetrendNormalize -replace -key 1:2 "FAIL $options:0"
-  end
-
-  # operation times out?
-  task.exit    timeout
-    queuepush DetrendNormalize -replace -key 1:2 "TIMEOUT $options:0"
-  end
-end
-
-# select images ready for copy 
-# new entries are added to queue DetrendNormStat
-# compare the new list with the ones already selected
-task	       dettool.normstat.load
-  command      dettool -normstat -simple
-  host         local
-
-  periods      -poll 1
-  periods      -exec 5
-  periods      -timeout 5
-
-  stdout dettool.normstat.log
-  stderr dettool.normstat.log
-
-  # success
-  task.exit    0
-    # XXX is it necessary for these to be local?
-    # drop after this task macro is done?
-    local i Nqueue
-
-    # compare output with newImage queue
-    # only add entries which don't exist in queue
-    queuesize stdout -var Nqueue
-    for i 0 $Nqueue
-      queuepop stdout -var line
-      queuepush DetrendNormStat -uniq -key 1:2 "NEW $line"
-    end
-
-    # delete existing entries which are DONE
-    queuedrop DetrendNormStat -key 0 DONE
-  end
-
-  # locked list
-  # default exit status
-  task.exit    default
-    echo       "detrend.norm: failure"
-  end
-
-  # operation times out?
-  task.exit    timeout
-    echo       "detrend.norm: timeout"
-  end
-end
-
-# copy new images, sending job to desired host
-task	       dettool.normstat.process
-  periods      -poll 0.5
-  periods      -exec 5.0
-  periods      -timeout 30
-
-  task.exec
-    queuesize DetrendNormStat -var N
-   
-    if ($N == 0) break
-    if ($network == 0) break
-    
-    # look for new images on the internal DetrendNormStat queue
-    # caution with these 'if' statements: syntax errors 
-    # will make the task fail without given a good status
-    queuepop DetrendNormStat -var line -key 0 NEW
-    if ("$line" == "NULL") break
-
-    strpop line state
-    queuepush DetrendNormStat -replace -key 1:2 "RUN $line"
-
-    # the DetrendNormStat queue contains:
-    # STATE DET_ID ITER
-    list word -split $line
-    $DET_ID   = $word:0
-    $ITER     = $word:1
-
-    # XXX we need to get CAMERA and TYPE from this query
-    # stdout $CAMERA.$TYPE.$DET_ID.$ITER.log
-    # stderr $CAMERA.$TYPE.$DET_ID.$ITER.log
-    stdout isp.flat.$DET_ID.$ITER.log
-    stderr isp.flat.$DET_ID.$ITER.log
-
-    # specify choice of remote host:
-    if ($parallel)
-      host anyhost
-    else
-      host local
-    end
-
-    # create example job options as a demonstration
-    options "$line"
-    echo command detrend_norm_apply.pl --det_id $DET_ID --iteration $ITER
-    command detrend_norm_apply.pl --det_id $DET_ID --iteration $ITER
-  end
-
-  # success
-  task.exit 0
-    queuepush DetrendNormStat -replace -key 1:2 "DONE $options:0"
-  end
-
-  # default exit status
-  task.exit    default
-    queuepush DetrendNormStat -replace -key 1:2 "FAIL $options:0"
-  end
-
-  # operation times out?
-  task.exit    timeout
-    queuepush DetrendNormStat -replace -key 1:2 "TIMEOUT $options:0"
+    queuepush DetrendNormalize -replace -key 4:5 "DONE $options:0"
+  end
+
+  # default exit status
+  task.exit    default
+    queuepush DetrendNormalize -replace -key 4:5 "FAIL $options:0"
+  end
+
+  # operation times out?
+  task.exit    timeout
+    queuepush DetrendNormalize -replace -key 4:5 "TIMEOUT $options:0"
   end
 end
@@ -253,5 +270,13 @@
     for i 0 $Nqueue
       queuepop stdout -var line
-      queuepush DetrendNormalizeExposures -uniq -key 1:2 "NEW $line"
+      list word -split $line
+      $DET_ID   = $word:0
+      $ITER     = $word:1
+      $DET_TYPE = $word:2
+      $CAMERA   = $word:3
+      #$TELESCOPE= $word:4
+      #$EXP_TYPE = $word:5
+      #$IMFILES  = $word:6
+      queuepush DetrendNormalizeExposures -uniq -key 1:2 "NEW $DET_ID $ITER $DET_TYPE $CAMERA"
     end
 
@@ -298,10 +323,13 @@
     $DET_ID   = $word:0
     $ITER     = $word:1
-
-    # XXX we need to get CAMERA and TYPE from this query
-    # stdout $CAMERA.$TYPE.$DET_ID.$ITER.log
-    # stderr $CAMERA.$TYPE.$DET_ID.$ITER.log
-    stdout isp.flat.$DET_ID.$ITER.log
-    stderr isp.flat.$DET_ID.$ITER.log
+    $DET_TYPE = $word:2
+    $CAMERA   = $word:3
+    #$TELESCOPE= $word:4
+    #$EXP_TYPE = $word:5
+    #$IMFILES  = $word:6
+
+    # XXX add $WORKDIR/$LOG_DIR
+    stdout $CAMERA.$DET_TYPE.$DET_ID.$ITER.log
+    stderr $CAMERA.$DET_TYPE.$DET_ID.$ITER.log
 
     # specify choice of remote host:
@@ -314,6 +342,6 @@
     # create example job options as a demonstration
     options "$line"
-    echo command detrend_norm_apply.pl --det_id $DET_ID --iteration $ITER
-    command detrend_norm_apply.pl --det_id $DET_ID --iteration $ITER
+    echo command detrend_norm_exp.pl --det_id $DET_ID --iteration $ITER --camera $CAMERA --det_type $DET_TYPE
+    command detrend_norm_exp.pl --det_id $DET_ID --iteration $ITER --camera $CAMERA --det_type $DET_TYPE
   end
 
