IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 10, 2010, 3:39:59 PM (16 years ago)
Author:
eugene
Message:

updates from the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/tools/make_burntool_pcontrol.pl

    r25952 r26852  
    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]);
    237     }
    238     print "\n";
    239 }
    240 
    241 unless(exists($opt{b})) {
     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);
     267    }
     268    unless(exists($opt{d})) {
     269        print "\n";
     270    }
     271    $N_ranges += ($#start_s + 1);
     272}
     273
     274if ($N_ranges == 0) {
     275    print_short_epilogue();
     276}
     277
     278unless(exists($opt{b}) || ($N_ranges == 0)) {
    242279    print_epilogue();
    243280}
     
    275312return(0);
    276313}
     314sub print_short_epilogue {
     315    if (exists($opt{b})) {
     316        print STDERR "There were no science exposures to process. Sorry, try again tomorrow.\n";
     317        return();
     318    }
     319    print << 'END_SHORT_EPILOGUE';
     320
     321    echo "There were no science exposures to process. Sorry, try again tomorrow."
     322
     323end
     324END_SHORT_EPILOGUE
     325}
    277326
    278327sub print_epilogue {
     328    print " echo 'There were $N_total_images total images, of which $N_burntooled_images were already burntooled.'\n";
     329    print "### BTSTAT $N_total_images $N_burntooled_images\n";
    279330    print << 'END_EPILOGUE';
    280331   
Note: See TracChangeset for help on using the changeset viewer.