Index: trunk/ippTools/share/Makefile.am
===================================================================
--- trunk/ippTools/share/Makefile.am	(revision 31205)
+++ trunk/ippTools/share/Makefile.am	(revision 31236)
@@ -164,4 +164,5 @@
 	disttool_definebyquery_fake.sql \
 	disttool_definebyquery_raw.sql \
+	disttool_definebyquery_raw_no_magic.sql \
 	disttool_definebyquery_sky.sql \
 	disttool_definebyquery_stack.sql \
Index: trunk/ippTools/share/difftool_listrun.sql
===================================================================
--- trunk/ippTools/share/difftool_listrun.sql	(revision 31205)
+++ trunk/ippTools/share/difftool_listrun.sql	(revision 31236)
@@ -20,4 +20,5 @@
     camProcessedInput.zpt_lq,
     camProcessedInput.zpt_uq,
+    camProcessedInput.fwhm_major,
     rawInput.comment,
     rawInput.exp_time,
@@ -25,4 +26,5 @@
     rawInput.exp_name AS exp_name_1,
     rawInput.exp_id AS exp_id_1,
+    rawInput.filter AS filter_1,
     rawInput.comment AS comment_1,
     rawInput.dateobs AS dateobs_1,
@@ -34,4 +36,5 @@
     rawTemplate.exp_name AS exp_name_2,
     rawTemplate.exp_id AS exp_id_2,
+    rawInput.filter AS filter_2,
     rawTemplate.comment AS comment_2,
     rawTemplate.dateobs AS dateobs_2,
Index: trunk/ippTools/share/disttool_definebyquery_raw_no_magic.sql
===================================================================
--- trunk/ippTools/share/disttool_definebyquery_raw_no_magic.sql	(revision 31236)
+++ trunk/ippTools/share/disttool_definebyquery_raw_no_magic.sql	(revision 31236)
@@ -0,0 +1,18 @@
+SELECT 
+    'raw' AS stage,
+    rawExp.exp_id AS stage_id,
+    rawExp.exp_name AS run_tag,
+    rawExp.magicked,
+    CAST(NULL AS CHAR(255)) AS label,
+    CAST(NULL AS CHAR(255)) AS data_group,
+    distTarget.dist_group,
+    distTarget.target_id,
+    distTarget.clean
+FROM rawExp
+JOIN distTarget ON distTarget.stage = 'raw'
+    AND rawExp.filter = distTarget.filter
+JOIN rcInterest USING(target_id)
+LEFT JOIN distRun ON distRun.stage_id = exp_id AND distRun.target_id = distTarget.target_id
+WHERE distRun.dist_id IS NULL           -- no existing distRun for this exposure
+    AND distTarget.state = 'enabled'    -- target and intrest are enabled
+    AND rcInterest.state = 'enabled'
Index: trunk/ippTools/share/disttool_pending_SSdiff.sql
===================================================================
--- trunk/ippTools/share/disttool_pending_SSdiff.sql	(revision 31205)
+++ trunk/ippTools/share/disttool_pending_SSdiff.sql	(revision 31236)
@@ -6,4 +6,5 @@
     stage_id,
     diffSkyfile.skycell_id AS component,
+    exp_type,
     clean,
     rawExp.camera,
Index: trunk/ippTools/share/disttool_pending_camera.sql
===================================================================
--- trunk/ippTools/share/disttool_pending_camera.sql	(revision 31205)
+++ trunk/ippTools/share/disttool_pending_camera.sql	(revision 31236)
@@ -6,4 +6,5 @@
     stage_id,
     'exposure' AS component,
+    exp_type,
     clean,
     rawExp.camera,
Index: trunk/ippTools/share/disttool_pending_chip.sql
===================================================================
--- trunk/ippTools/share/disttool_pending_chip.sql	(revision 31205)
+++ trunk/ippTools/share/disttool_pending_chip.sql	(revision 31236)
@@ -6,4 +6,5 @@
     stage_id,
     chipProcessedImfile.class_id AS component,
+    exp_type,
     distRun.clean,
     rawExp.camera,
Index: trunk/ippTools/share/disttool_pending_chip_bg.sql
===================================================================
--- trunk/ippTools/share/disttool_pending_chip_bg.sql	(revision 31205)
+++ trunk/ippTools/share/disttool_pending_chip_bg.sql	(revision 31236)
@@ -6,4 +6,5 @@
     stage_id,
     chipBackgroundImfile.class_id AS component,
+    exp_type,
     distRun.clean,
     rawExp.camera,
Index: trunk/ippTools/share/disttool_pending_diff.sql
===================================================================
--- trunk/ippTools/share/disttool_pending_diff.sql	(revision 31205)
+++ trunk/ippTools/share/disttool_pending_diff.sql	(revision 31236)
@@ -6,4 +6,5 @@
     stage_id,
     diffSkyfile.skycell_id AS component,
+    exp_type,
     clean,
     rawExp.camera,
Index: trunk/ippTools/share/disttool_pending_fake.sql
===================================================================
--- trunk/ippTools/share/disttool_pending_fake.sql	(revision 31205)
+++ trunk/ippTools/share/disttool_pending_fake.sql	(revision 31236)
@@ -6,4 +6,5 @@
     stage_id,
     fakeProcessedImfile.class_id AS component,
+    exp_type,
     clean,
     rawExp.camera,
Index: trunk/ippTools/share/disttool_pending_raw.sql
===================================================================
--- trunk/ippTools/share/disttool_pending_raw.sql	(revision 31205)
+++ trunk/ippTools/share/disttool_pending_raw.sql	(revision 31236)
@@ -1,2 +1,4 @@
+SELECT * FROM (
+-- rawExp magicked with re_place
 SELECT
     distRun.dist_id,
@@ -6,4 +8,5 @@
     rawExp.exp_id AS stage_id,
     rawImfile.class_id AS component,
+    rawExp.exp_type,
     clean,
     rawExp.camera,
@@ -38,8 +41,49 @@
     AND distRun.stage = 'raw'
     AND distComponent.dist_id IS NULL
-    AND (rawExp.magicked OR distRun.no_magic)
+    -- AND (rawExp.magicked OR distRun.no_magic)
+    AND rawExp.magicked
     -- need to have magicked the chip image which makes the camera mask
     AND chipProcessedImfile.magicked != 0
     AND camRun.magicked > 0 
+    AND (Label.active OR Label.active IS NULL)
+UNION
+SELECT
+    -- raw images no_magic required
+    distRun.dist_id,
+    distRun.label,
+    distTarget.dist_group,
+    'raw' AS stage,
+    rawExp.exp_id AS stage_id,
+    rawImfile.class_id AS component,
+    rawExp.exp_type,
+    clean,
+    rawExp.camera,
+    CONCAT_WS('.', distRun.outroot, CONVERT(distRun.dist_id, CHAR)) as outdir,
+    -- XXX: replace this with rawImfile.path_base once it exists
+    TRIM(TRAILING '.fits' FROM rawImfile.uri) AS path_base,
+    CAST(NULL AS CHAR(255)) AS alt_path_base,
+    -- pass camera stage path base since we want the camera mask file. The script knows what to do
+    CAST(NULL AS CHAR(255)) AS chip_path_base,
+    CAST(NULL AS CHAR(255)) AS state,
+    CAST(NULL AS CHAR(255)) AS data_state,
+    0 as quality,
+    distRun.no_magic,
+    rawImfile.magicked,
+    IFNULL(Label.priority, 10000) AS priority
+FROM distRun
+JOIN distTarget USING(target_id, stage, clean)
+JOIN rawExp ON rawExp.exp_id = stage_id 
+            AND distTarget.stage = 'raw' AND distRun.alternate = 0
+JOIN rawImfile USING(exp_id)
+LEFT JOIN distComponent 
+    ON distRun.dist_id = distComponent.dist_id 
+    AND rawImfile.class_id = distComponent.component
+LEFT JOIN Label ON distRun.label = Label.label
+WHERE
+    distRun.state = 'new'
+    AND distRun.clean = 0
+    AND distRun.stage = 'raw'
+    AND distComponent.dist_id IS NULL
+    AND (distRun.no_magic)
     AND (Label.active OR Label.active IS NULL)
 UNION
@@ -52,4 +96,5 @@
     rawExp.exp_id AS stage_id,
     rawImfile.class_id AS component,
+    rawExp.exp_type,
     clean,
     rawExp.camera,
@@ -96,4 +141,5 @@
     rawExp.exp_id AS stage_id,
     'exposure' AS component,
+    rawExp.exp_type,
     clean,
     rawExp.camera,
@@ -120,2 +166,4 @@
     AND distComponent.dist_id IS NULL
     AND (Label.active OR Label.active IS NULL)
+) AS distRun
+WHERE 1
Index: trunk/ippTools/share/disttool_pending_sky.sql
===================================================================
--- trunk/ippTools/share/disttool_pending_sky.sql	(revision 31205)
+++ trunk/ippTools/share/disttool_pending_sky.sql	(revision 31236)
@@ -6,4 +6,5 @@
     stage_id,
     stackRun.skycell_id AS component,
+    exp_type,
     clean,
     rawExp.camera,
Index: trunk/ippTools/share/disttool_pending_stack.sql
===================================================================
--- trunk/ippTools/share/disttool_pending_stack.sql	(revision 31205)
+++ trunk/ippTools/share/disttool_pending_stack.sql	(revision 31236)
@@ -6,4 +6,5 @@
     stage_id,
     stackRun.skycell_id AS component,
+    exp_type,
     clean,
     rawExp.camera,
Index: trunk/ippTools/share/disttool_pending_warp.sql
===================================================================
--- trunk/ippTools/share/disttool_pending_warp.sql	(revision 31205)
+++ trunk/ippTools/share/disttool_pending_warp.sql	(revision 31236)
@@ -6,4 +6,5 @@
     stage_id,
     warpSkyfile.skycell_id AS component,
+    exp_type,
     clean,
     rawExp.camera,
Index: trunk/ippTools/share/disttool_pending_warp_bg.sql
===================================================================
--- trunk/ippTools/share/disttool_pending_warp_bg.sql	(revision 31205)
+++ trunk/ippTools/share/disttool_pending_warp_bg.sql	(revision 31236)
@@ -6,4 +6,5 @@
     stage_id,
     warpBackgroundSkyfile.skycell_id AS component,
+    exp_type,
     clean,
     rawExp.camera,
