IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26334


Ignore:
Timestamp:
Dec 3, 2009, 5:53:09 PM (16 years ago)
Author:
watersc1
Message:

Updated to correctly identify dates in which no science data was taken, and tell this to the user.

Also now determines how many exposures have had burntool run on them already, so we can identify how successful the summit was at running burntool.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/make_burntool_pcontrol.pl

    r25952 r26334  
    3535                   ) or die "Unable to connect to database $DBI::errstr\n";
    3636
     37# Determine what the value of "BURNTOOL.STATE.GOOD" currently is:
     38$burntoolStateGood = 999;
     39open(LAZY,"ppConfigDump -camera GPC1 -dump-camera - |") || die "Can't run ppConfigDump\n";
     40while(<LAZY>) {
     41    chomp;
     42    if ($_ =~ /BURNTOOL.STATE.GOOD/) {
     43        @line = split /\s+/;
     44        $burntoolStateGood = $line[2];
     45    }
     46}
     47close(LAZY);
     48#unless( $burntoolStateGood == 999) {
     49#    print STDERR "GOOD == $burntoolStateGood\n";
     50#}
     51
     52
    3753# List of which obs_modes are "science" and which are something else.
    3854%science = ('MD' => 1, '3PI' => 1, 'STS' => 1, 'CAL' => 1, 'M31' => 1, 'SS' => 1,
     
    4157    $science{Unknown} = 1;
    4258}
    43 # Zero the arrays.
     59
     60# Zero the arrays and counters
    4461@dates_min = ();
    4562@dates_max = ();
    46 
     63$N_burntooled_images = 0;
     64$N_total_images = 0;
     65$N_ranges = 0;
    4766# Parse SQL query and fill any valid dates to the arrays
    4867if (exists($opt{Q})) {
     
    6685    }
    6786}
     87
    6888# Read a single date, and calculate the end and insert
    6989elsif (exists($opt{d})) {
     
    7393    push @dates_max, sprintf("%04d-%02d-%02d",$year,$mon,$date);
    7494}
     95
    7596# Just shift the supplied values into the arrays.
    7697else {
     
    92113    print "##query: SELECT dateobs FROM rawExp WHERE $opt{Q}\n";
    93114}
    94 #for ($d = 0; $d <= $#dates_min; $d++) {
     115
    95116while ($#dates_min > -1) {
    96117    $date_min = shift(@dates_min);
     
    138159            $science{$obs_mode} = 0;
    139160        }
    140 #%science = ('MD' => 1, '3PI' => 1, 'STS' => 1, 'CAL' => 1, 'M31' => 1, 'SS' => 1,
    141 #           'ENGINEERING' => 0, 'NULL' => 0, 'Unknown' => 0, ' ' => 0);
    142 # I don't like this bit, but we need to work around the bad values of obs_mode that periodically crop up.
    143 # This isn't the most robust solution (which would of course be "having trustworthy obs_mode values"), but
    144 # it'll probably work for now.
    145161        if ((($science{$obs_mode} == 1)&&($comment !~ /Daytime/))||
    146162            (($science{$obs_mode} == 0)&&(
    147163                                          ($comment =~ /MD/)||($comment =~ /ThreePi/)||
    148164                                          ($comment =~ /STS/)||($comment =~ /M31/)||
    149                                           ($comment =~ /CAL/)||($comment =~ /SS/)||($comment =~ /SVS/)|| ($comment =~ /Sweetspot/)|| ($comment =~ /cal/)|| ($comment =~ /virgo/)|| ($comment =~ /Virgo/)|| ($comment =~ /kepler/)||
     165                                          ($comment =~ /CAL/i)||($comment =~ /SS/)||($comment =~ /SVS/)||
     166                                          ($comment =~ /Sweetspot/)||($comment =~ /virgo/i)||($comment =~ /kepler/)||
    150167                                          ($comment =~ /sdss/))))                                         
    151168        {
     
    174191        next;
    175192    }
     193
    176194    # Scan again and count how many exposures are between windows
    177195    foreach $row_ref (@{ $data_ref }) {
     
    212230                }
    213231            }
    214 #           print ">>>$i $start_s[$i] $skips[$i]\n";
    215         }
    216 #       print ">>> $dateobs\n";
     232        }
    217233    }
    218234
     
    227243    }
    228244    # Print out the end points in the format burntool wants.
     245
    229246    for ($i = 0; $i <= $#start_s; $i++) {
    230247        @start_t = localtime($start_s[$i]);
    231248        @end_t = localtime($end_s[$i]);
    232         printf(" burntool %04d-%02d-%02dT%02d:%02d:%02d %04d-%02d-%02dT%02d:%02d:%02d\n",
    233                $start_t[5] + 1900,$start_t[4] + 1,$start_t[3],
    234                $start_t[2],$start_t[1],$start_t[0],
    235                $end_t[5] + 1900,$end_t[4] + 1,$end_t[3],
    236                $end_t[2],$end_t[1],$end_t[0]);
     249       
     250        my $date_min = sprintf("%04d-%02d-%02dT%02d:%02d:%02d",
     251                               $start_t[5] + 1900,$start_t[4] + 1,$start_t[3],
     252                               $start_t[2],$start_t[1],$start_t[0]);
     253        my $date_max = sprintf("%04d-%02d-%02dT%02d:%02d:%02d",
     254                               $end_t[5] + 1900,$end_t[4] + 1,$end_t[3],
     255                               $end_t[2],$end_t[1],$end_t[0]);
     256
     257        my $total_images_sth = "SELECT count(exp_id) from rawImfile where dateobs >= '$date_min' AND dateobs <= '$date_max'";
     258        my $im_ref = $db->selectall_arrayref( $total_images_sth );
     259        $N_total_images += ${ $im_ref }[0][0];
     260
     261        my $burntooled_images_sth = "SELECT count(exp_id) from rawImfile where dateobs >= '$date_min' AND dateobs <= '$date_max' AND abs(burntool_state) = $burntoolStateGood";
     262        $im_ref = $db->selectall_arrayref( $burntooled_images_sth );
     263        $N_burntooled_images += ${ $im_ref }[0][0];
     264       
     265
     266        printf(" burntool %s %s\n",$date_min,$date_max);
    237267    }
    238268    print "\n";
    239 }
    240 
    241 unless(exists($opt{b})) {
     269    $N_ranges += $#start_s;
     270}
     271
     272if ($N_ranges == 0) {
     273    print_short_epilogue();
     274}
     275
     276unless(exists($opt{b}) || ($N_ranges == 0)) {
    242277    print_epilogue();
    243278}
     
    275310return(0);
    276311}
     312sub print_short_epilogue {
     313    print << 'END_SHORT_EPILOGUE';
     314
     315    echo "There were no science exposures to process. Sorry, try again tomorrow."
     316
     317end
     318END_SHORT_EPILOGUE
     319}
    277320
    278321sub print_epilogue {
     322    print " echo 'There were $N_total_images total images, of which $N_burntooled_images were already burntooled.'\n";
     323    print "### BTSTAT $N_total_images $N_burntooled_images\n";
    279324    print << 'END_EPILOGUE';
    280325   
Note: See TracChangeset for help on using the changeset viewer.