Index: /trunk/Ohana/src/perl/src/dt.select
===================================================================
--- /trunk/Ohana/src/perl/src/dt.select	(revision 57)
+++ /trunk/Ohana/src/perl/src/dt.select	(revision 58)
@@ -2,5 +2,5 @@
 $SKIPDOME = 0;
 
-if (@ARGV != 6) { die "ERROR: USAGE: imselect (type) (filter) (tstart) (tend) (output) (-split | -mef)\n" }
+if (@ARGV != 6) { die "ERROR: USAGE: imselect (type) (filter) (tstart) (tend) (output) (SPLIT | MEF)\n" }
 
 $type   = "\U$ARGV[0]\E";
@@ -10,8 +10,4 @@
 $output = $ARGV[4];
 $mode   = $ARGV[5];
-
-$ptolemy = $ENV{'PTOLEMY'};
-print "PTOLEMY: $ptolemy\n";
-system ("cp $ptolemy /h/eugene/ptolemy.config");
 
 unless ($output =~ /CCDNUM/) { die "ERROR: output file needs CCDNUM component\n"; }
@@ -23,17 +19,20 @@
 if ($type eq "FLAT") {
     # define some of the relevant parameters
-    $min = 2000;
     $max = 60000;
-    $minrate = 100;
-    $ratescale = 70;
-    if ($filter eq "B") { $minrate = 0.5  * $ratescale;  }
-    if ($filter eq "V") { $minrate = 1.0  * $ratescale;  }
-    if ($filter eq "R") { $minrate = 3.5  * $ratescale;  }
-    if ($filter eq "I") { $minrate = 14.2 * $ratescale; }
-    if ($filter eq "Z") { $minrate = 10.5 * $ratescale; }
-    if ($filter eq "HA")    { $min = 1000; }
-    if ($filter eq "HAOFF") { $min = 1000; }
-    # these should come from the filter tables
-    # probably need to set these in a more intelligent fashion.
+
+    $tmp = `filtnames $filter`; chop $tmp;
+    if ($?) { die "ERROR: invalid filter $filter\n"; }
+    $filter = $tmp;
+
+    # recipe file defines detrend types & cutoff exptime values
+    $recipefile = `gconfig DETREND_RECIPES`; chop $recipefile;
+    if ($?) { die "ERROR: missing DETREND_RECIPES in configuration\n"; }
+
+    ($tmp, $tmp, $extras) = split (" ", `gconfig -c $recipefile $filter`);
+    if ($?) { die "ERROR: missing detrend recipe for $filter\n"; }
+
+    # all filters have 'flat', grab extras:
+    ($detype, $minflux, $min) = split (",", $extras);
+    if ("\U$detype\E" ne "FLAT") { die "ERROR: flat extras are missing\n"; }
 }
 
@@ -138,5 +137,5 @@
 	    # test for acceptable flux
 	    $Flux = $words2[11] / $words2[7];
-	    if ($Flux < $minrate) { print STDERR "$words[5] rejected: flux too low: $Flux vs $minrate\n"; next FRAME; }
+	    if ($Flux < $minflux) { print STDERR "$words[5] rejected: flux too low: $Flux vs $minflux\n"; next FRAME; }
 	}
     }
