Index: /trunk/tools/queuessky.lap
===================================================================
--- /trunk/tools/queuessky.lap	(revision 34863)
+++ /trunk/tools/queuessky.lap	(revision 34863)
@@ -0,0 +1,183 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
+use Pod::Usage qw( pod2usage );
+use POSIX qw(strftime);
+
+# The rest of this is some subroutines for setting up the filter combinations
+my @filter = qw(
+g.00000
+r.00000
+i.00000
+z.00000
+y.00000
+);
+
+
+my ($ramin, $ramax, $decmin, $decmax, $absglatmin, $go);
+my $combos = 5;
+my $verbose = 0;
+
+GetOptions(
+    'ra_min=s'           =>  \$ramin,
+    'ra_max=s'           =>  \$ramax,
+    'dec_min=s'          =>  \$decmin,
+    'dec_max=s'          =>  \$decmax,
+#    'absglatmin=s'      =>  \$absglatmin,  # not yet
+    'nfilters=s'        =>  \$combos,
+    'go'                =>  \$go,
+    'verbose|v'         =>  \$verbose,
+) or pod2usage(2);
+
+unless (defined $ramin and defined $ramax) {
+    warn ("ramin and ramax are required\n");
+    pod2usage(2);
+};
+
+my $pretend = $go ? "" : " -pretend";
+
+my $filter_combos = setup_filter_combos($combos);
+
+# printcombos($filter_combos) if $verbose;
+
+my $label='LAP.ThreePi.20120706';
+
+my $datestr = strftime "%Y/%m/%d", gmtime;
+
+my $command="staticskytool -definebyquery -set_workdir neb://\@HOST\@.0/gpc1/$label/$datestr"
+    . " -set_label $label -select_label $label  -set_data_group $label -set_dist_group LAP.ThreePi"
+    . " -ra_min $ramin -ra_max $ramax"
+    . " -simple"
+    . $pretend;
+
+$command .= " -dec_min $decmin" if defined $decmin;
+$command .= " -dec_max $decmax" if defined $decmax;
+
+# XXX TODO: implement absglatmin
+
+foreach my $filter_combo (@$filter_combos) {
+    my $cmd = $command;
+    foreach my $f (@$filter_combo) {
+        $cmd .= " -select_filter $f";
+    }
+    print "$cmd\n" if $verbose;
+    my $rc = system $cmd ; #. " -glat_min 10";
+    if ($rc) {
+        my $status = $rc >> 8;
+        print STDERR "$cmd returned $rc $status\n";
+        exit $status;
+    }
+}
+
+
+
+exit 0;
+
+
+
+
+sub setup_filter_combos {
+    my $combos = shift;
+
+    die "invalid combos arg: $combos\n" unless defined $combos and ($combos eq "5" or $combos eq "4" or $combos eq "3" or $combos eq "2" or $combos eq "1");
+
+    if ($combos eq 5) {
+        my @ary;
+        push @ary, \@filter;
+        return \@ary;
+    } elsif ($combos eq 4) {
+        return makecombo4();
+    } elsif ($combos eq 3) {
+        return makecombo3();
+    } elsif ($combos eq 2) {
+        return makecombo2();
+    } elsif ($combos eq 1) {
+        my @ary;
+        foreach my $f (@filter) {
+            my @ary2 = ($f);
+            push @ary, \@ary2
+        }
+        return \@ary;
+    } else {
+        die "how did we get here?";
+    }
+}
+
+
+
+sub printcombos {
+    my $combos = shift;
+    foreach my $c (@$combos) {
+        my $str;
+        foreach my $f (@$c) {
+            $str .= " -select_filter $f";
+        }
+        print "$str\n";
+    }
+}
+
+
+sub makecombo4 {
+    my $numFilters = scalar @filter;
+    my @combos;
+
+    for (my $i = 0; $i < $numFilters; $i++) {
+        for (my $j = $i + 1; $j < $numFilters; $j++) {
+            for (my $k = $j + 1; $k < $numFilters; $k++) {
+                for (my $l = $k + 1; $l < $numFilters; $l++) {
+                    my @combo = ($filter[$i], $filter[$j], $filter[$k], $filter[$l]);
+                    push @combos, \@combo;
+                }
+            }
+        }
+    }
+    return \@combos;
+}
+
+sub makecombo3 {
+    my $numFilters = scalar @filter;
+    my @combos;
+
+    for (my $i = 0; $i < $numFilters; $i++) {
+        for (my $j = $i + 1; $j < $numFilters; $j++) {
+            for (my $k = $j + 1; $k < $numFilters; $k++) {
+                my @combo = ($filter[$i], $filter[$j], $filter[$k]);
+                push @combos, \@combo;
+            }
+        }
+    }
+    return \@combos;
+}
+
+sub makecombo2 {
+    my $numFilters = scalar @filter;
+    my @combos;
+
+    for (my $i = 0; $i < $numFilters; $i++) {
+        for (my $j = $i + 1; $j < $numFilters; $j++) {
+            my @combo = ($filter[$i], $filter[$j]);
+            push @combos, \@combo;
+        }
+    }
+    return \@combos;
+}
+
+
+__END__
+
+=pod
+
+=head1 NAME
+
+queuesskylap - queue LAP staticsky runs 
+
+=head1 SYNOPSIS
+    
+    XXX: pod TODO
+
+    queuesskylap --ra_min <ra_min> --ra_max <ra_max> --dec_min <dec_min> --dec_max <dec_max> [--go]
+
+
