IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 5, 2010, 3:42:52 PM (16 years ago)
Author:
watersc1
Message:

This needs more work to be cleaned up, but I've changed the script to read the nightly science config file to determine which exposures need to be burntooled. This should ensure that we catch all of the data we care about.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/make_burntool_pcontrol.pl

    r27033 r27865  
    1 #!/usr/bin/perl -w
     1#!/usr/bin/env perl
    22# script to generate a pcontrol.pro file to run burntool on a set of data.
    33
    44use DBI;
     5use warnings;
    56use DateTime;
    67use Getopt::Std;
     8use PS::IPP::Metadata::List qw( parse_md_list );
     9use PS::IPP::Config 1.01 qw( :standard );
     10use IPC::Cmd 0.36 qw( can_run run);
    711
    812use constant DB_SOCKET => '/var/run/mysqld/mysqld.sock';
     
    3539                   ) or die "Unable to connect to database $DBI::errstr\n";
    3640
     41my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     42if ($missing_tools) {
     43    die "Cannot find required tools.";
     44}
    3745# Determine what the value of "BURNTOOL.STATE.GOOD" currently is:
    3846$burntoolStateGood = 999;
    39 open(LAZY,"ppConfigDump -camera GPC1 -dump-camera - |") || die "Can't run ppConfigDump\n";
     47open(LAZY,"$ppConfigDump -camera GPC1 -dump-camera - |") || die "Can't run ppConfigDump\n";
    4048while(<LAZY>) {
    4149    chomp;
     
    4654}
    4755close(LAZY);
    48 #unless( $burntoolStateGood == 999) {
    49 #    print STDERR "GOOD == $burntoolStateGood\n";
    50 #}
    51 
    52 
    53 # List of which obs_modes are "science" and which are something else.
    54 %science = ('MD' => 1, '3PI' => 1, 'STS' => 1, 'CAL' => 1, 'M31' => 1, 'SS' => 1,
    55             'ENGINEERING' => 0, 'NULL' => 0, 'Unknown' => 1, ' ' => 0);
     56
     57# Read the nightly science config file and use that to determine which data is science
     58my $verbose = 0;
     59my $conf_cmd = "$ppConfigDump -dump-recipe NIGHTLY_SCIENCE -";
     60my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     61    run(command => $conf_cmd, verbose => $verbose);
     62unless ($success) {
     63    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     64    &my_die("Unable to perform ppConfigDUmp: $error_code", $date, $PS_EXIT_SYS_ERROR);
     65}
     66
     67my @target_list;
     68my %object_list;
     69my $comment_list;
     70
     71my $mdcParser = PS::IPP::Metadata::Config->new;
     72my $metadata = $mdcParser->parse(join "", @$stdout_buf);
     73foreach my $entry (@{ $metadata }) {
     74    if (${ $entry }{name} eq 'TARGETS') {
     75        my @target_data = @{ ${ $entry }{value} };
     76        my $this_target = '';
     77       
     78        foreach my $tentry (@target_data) {
     79            if (${ $tentry }{name} eq 'NAME') {
     80                $this_target = ${ $tentry }{value};
     81                push @target_list, $this_target;
     82                $obsmode_list{$this_target} = '.*';
     83                $object_list{$this_target} = '.*';
     84                $comment_list{$this_target} = '.*';
     85            }
     86            elsif (${ $tentry }{name} eq 'OBSMODE') {
     87                $obsmode_list{$this_target} = ${ $tentry }{value};
     88                $obsmode_list{$this_target} =~ s/%//;
     89            }
     90            elsif (${ $tentry }{name} eq 'OBJECT') {
     91                $object_list{$this_target} = ${ $tentry }{value};
     92                $object_list{$this_target} =~ s/%//;
     93            }
     94            elsif (${ $tentry }{name} eq 'COMMENT') {
     95                $comment_list{$this_target} = ${ $tentry }{value};
     96                $comment_list{$this_target} =~ s/%//;
     97            }
     98        }
     99    }
     100}
    56101if (exists($opt{P})) {
    57     $science{Unknown} = 1;
     102    push @target_list, 'PR';
     103    $obsmode_list{'PR'} = 'Unknown';
     104    $object_list{'PR'} = '.*';
     105    $comment_list{'PR'} = '.*';
    58106}
    59107
     
    119167   
    120168    # Find _ALL_ observations within the date range we care about
    121     $sth = "SELECT exp_id,dateobs,pon_time,exp_type,obs_mode,comment FROM rawExp WHERE " .
     169    $sth = "SELECT exp_id,dateobs,pon_time,exp_type,obs_mode,comment,object FROM rawExp WHERE " .
    122170        "dateobs >= '${date_min}' AND dateobs <= '${date_max}' order by dateobs";
    123171
     
    133181    foreach $row_ref (@{ $data_ref }) {
    134182
    135         ($exp_id,$dateobs,$pontime,$exp_type,$obs_mode,$comment) = @{ $row_ref };
     183        ($exp_id,$dateobs,$pontime,$exp_type,$obs_mode,$comment,$object) = @{ $row_ref };
    136184        # Fix nulls in the database
    137185        if (!defined($obs_mode)) {
    138186            $obs_mode = ' ';
    139187        }
     188        if (!defined($object)) {
     189            $object = ' ';
     190        }
    140191        if (!defined($comment)) {
    141192            $comment = ' ';
     
    144195        ($date,$time) = split / /, $dateobs;
    145196        ($year,$month,$day) = split /-/, $date;
    146         ($hour,$minute,$second) = split /:/, $time;
     197        ($hour,$minute,$second) = split /:/, $time; # / # This stops emacs run-on syntax highlights.
    147198       
    148199        $dt = DateTime->new( year   => $year, month  => $month, day    => $day,
     
    155206        $et = $dt->epoch();
    156207
    157 
    158         if (!exists($science{$obs_mode})) {
    159             $science{$obs_mode} = 0;
    160         }
    161         if ((($science{$obs_mode} == 1)&&($comment !~ /Daytime/))||
    162             (($science{$obs_mode} == 0)&&(
    163                                           ($comment =~ /MD/)||($comment =~ /ThreePi/)||
    164                                           ($comment =~ /STS/i)||($comment =~ /M31/)||($comment =~ /Stellar Transit/)||
    165                                           ($comment =~ /CAL/i)||($comment =~ /SS/)||($comment =~ /SVS/)||
    166                                           ($comment =~ /Sweetspot/)||($comment =~ /virgo/i)||($comment =~ /kepler/)||
    167                                           ($comment =~ /sdss/))))                                         
    168         {
     208        if (is_science($exp_type,$obs_mode,$object,$comment)) {
    169209            if ($start_s[-1] == 0) {
    170210                $start_s[-1] = $et - 1800;
     
    194234    # Scan again and count how many exposures are between windows
    195235    foreach $row_ref (@{ $data_ref }) {
    196         ($exp_id,$dateobs,$pontime,$exp_type,$obs_mode,$comment) = @{ $row_ref };
     236        ($exp_id,$dateobs,$pontime,$exp_type,$obs_mode,$comment,$object) = @{ $row_ref };
    197237        if (!defined($obs_mode)) {
    198238            $obs_mode = ' ';
     
    204244        ($date,$time) = split / /, $dateobs;
    205245        ($year,$month,$day) = split /-/, $date;
    206         ($hour,$minute,$second) = split /:/, $time;
     246        ($hour,$minute,$second) = split /:/, $time; # / # another emacs syntax highlight bug.
    207247       
    208248        $dt = DateTime->new( year   => $year, month  => $month, day    => $day,
     
    215255        $et = $dt->epoch();
    216256
    217         if (!exists($science{$obs_mode})) {
    218             die "No mode >>$obs_mode<<\n";
    219         }
    220        
    221257        for ($i = 0; $i <= $#start_s; $i++) {
    222             if (($et < $start_s[$i])&&($science{$obs_mode} == 0)) {
     258            if (($et < $start_s[$i])&&(is_science($exp_type,$obs_mode,$object,$comment) == 0)) {
    223259                if ($i == 0) {
    224260                    $skips[$i]++;
     
    278314unless(exists($opt{b}) || ($N_ranges == 0)) {
    279315    print_epilogue();
     316}
     317
     318
     319# Subroutine to use the configuration file data and the exposure data to determine whether or not something is "science"
     320sub is_science {
     321#    if (is_science($exp_type,$obs_mode,$object,$comment)) {
     322    my ($exp_type,$obs_mode,$object,$comment) = @_;
     323    my $return_value = 0;
     324    if ($exp_type eq 'OBJECT') {
     325        foreach my $target (@target_list) {
     326            if (($obs_mode =~ /$obsmode_list{$target}/)&&
     327                ($object   =~ /$object_list{$target}/)&&
     328                ($comment  =~ /$comment_list{$target}/)) {
     329                $return_value = 1;
     330            }
     331#           print ">$return_value $exp_type $obs_mode $object $comment $target $obsmode_list{$target} $object_list{$target} $comment_list{$target}\n";
     332            if ($return_value) {
     333                return($return_value);
     334            }
     335        }
     336    }
     337    return(0);
    280338}
    281339
Note: See TracChangeset for help on using the changeset viewer.