IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2010, 5:06:01 PM (16 years ago)
Author:
watersc1
Message:

Almost working version of the mask-stats/software revision code.

Almost.

Location:
branches/czw_branch/20100427
Files:
13 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20100427

  • branches/czw_branch/20100427/ippScripts/scripts/automate_stacks.pl

    r27712 r28017  
    5656# Grab options
    5757my ( $date, $camera, $dbname, $logfile, $verbose, $manual);
    58 my ( $help, $isburning, $force_stack_count, $test_mode, $this_target_only, $this_filter_only);
     58my ( $help, $isburning, $force_stack_count, $test_mode, $this_target_only, $this_filter_only, $check_mode);
    5959my ( $check_registration, $define_burntool, $queue_burntool, $check_chips, $queue_chips);
    6060my ( $check_stacks, $queue_stacks, $check_diffs, $queue_diffs, $clean_old);
     
    7070    'isburning'            => \$isburning,
    7171    'force_stack_count'    => \$force_stack_count,
     72    'check'                => \$check_mode,
    7273    'test_mode'            => \$test_mode,
    7374    'this_target_only=s'   => \$this_target_only,
     
    116117    defined $queue_chips or defined $queue_stacks or
    117118    defined $check_chips or defined $check_stacks or
    118     defined $test_mode or defined $clean_old;
     119    defined $test_mode or defined $clean_old or defined $check_mode;
    119120
    120121# Configurable parameters from our config file.
     
    127128my %stackable_list = ();
    128129my %reduction_class = ();
    129 my $retention_time = 9000;
    130 
     130my %clean_commands = ();
     131my %clean_retention = ();
     132my %noclean_list = ();
    131133# Grab the configuration data.
    132134my $conf_cmd = "$ppConfigDump -dump-recipe NIGHTLY_SCIENCE -";
     
    141143my $metadata = $mdcParser->parse(join "", @$stdout_buf);
    142144foreach my $entry (@{ $metadata }) {
    143     if (${ $entry }{name} eq 'RETENTION_TIME') {
    144         $retention_time = ${ $entry }{value};
    145     }
     145    if (@{ $entry }{name} eq 'CLEAN_MODES') {
     146        my @mode_data = @{ ${ $entry }{value} };
     147        my $this_mode = '';
     148        foreach my $mentry (@mode_data) {
     149            if (${ $mentry }{name} eq 'MODE') {
     150                $this_mode = ${ $mentry }{value};
     151            }
     152            elsif (${ $mentry }{name} eq 'COMMAND') {
     153                $clean_commands{$this_mode} = ${ $mentry }{value};
     154            }
     155            elsif (${ $mentry }{name} eq 'RETENTION_TIME') {
     156                $clean_retention{$this_mode} = ${ $mentry }{value};
     157            }
     158        }
     159    }
     160#    if (${ $entry }{name} eq 'RETENTION_TIME') {
     161#        $retention_time = ${ $entry }{value};
     162#    }
    146163    elsif (${ $entry }{name} eq 'FILTERS') {
    147164        push @filter_list, ${ $entry }{value};
     
    173190                $reduction_class{$this_target} = ${ $tentry }{value};
    174191            }
     192            elsif (${ $tentry }{name} eq 'NOCLEAN') {
     193                $noclean_list{$this_target} = ${ $tentry }{value};
     194            }
    175195        }
    176196    }
     
    218238if (defined($test_mode)) {
    219239    $debug = 1;
    220 }
    221 
    222 if (defined($check_registration) || defined($test_mode)) {
     240    my $z;
     241    foreach $z (@target_list) {
     242        print "TARGET: $z $tessID_list{$z} $obsmode_list{$z} $object_list{$z} $comment_list{$z} $stackable_list{$z} $reduction_class{$z}\n";
     243    }
     244    foreach $z (@filter_list) {
     245        print "FILTER: $z\n";
     246    }
     247    foreach $z (keys (%clean_commands)) {
     248        print "CLEAN: $z $clean_commands{$z} $clean_retention{$z}\n";
     249    }
     250   
     251}
     252
     253if (defined($check_registration) || defined($test_mode) || defined($check_mode)) {
    223254    $metadata_out{nsState} = 'NEW';
    224255    my ($Nsummit_exp,$Nfaults) = check_summit_copy($date);
    225256    return_metadata($date);
    226     unless (defined($test_mode)) { exit(0); }
     257    unless (defined($test_mode) || defined($check_mode)) { exit(0); }
    227258}
    228259if (defined($define_burntool) || defined($test_mode)) {
     
    237268    unless (defined($test_mode)) { exit(0); }
    238269}
    239 if (defined($check_chips) || defined($test_mode)) {
     270if (defined($check_chips) || defined($test_mode) || defined($check_mode)) {
    240271    $metadata_out{nsState} = 'QUEUECHIPS';
    241272    &execute_chips($date,"pretend");
     
    244275    }
    245276    return_metadata($date);
    246     unless (defined($test_mode)) { exit(0); }
     277    unless (defined($test_mode) || defined($check_mode)) { exit(0); }
    247278}
    248279if (defined($queue_chips)) {
     
    252283    exit(0);
    253284}
    254 if (defined($check_stacks) || defined($test_mode)) {
     285if (defined($check_stacks) || defined($test_mode) || defined($check_mode)) {
    255286    $metadata_out{nsState} = 'TOWARP';
    256287    &execute_stacks($date,"pretend");
     
    259290    }
    260291    return_metadata($date);
    261     unless (defined($test_mode)) { exit(0); }
     292    unless (defined($test_mode) || defined($check_mode)) { exit(0); }
    262293}
    263294if (defined($queue_stacks)) {
    264295    $metadata_out{nsState} = 'STACKING';
    265296    &execute_stacks($date);
    266     if ($metadata_out{nsState} == 'QUEUESTACKING') {
     297    if ($metadata_out{nsState} eq 'QUEUESTACKING') {
    267298        $metadata_out{nsState} = 'STACKING_POSSIBLE_ERROR';
    268299    }
     
    424455    }
    425456
    426     if ($#{ $stderr_buf } > -1) {
    427         $metadata_out{nsState} = 'ERROR';
    428         return(1);
    429     }
     457#    if ($#{ $stderr_buf } > -1) {
     458#        $metadata_out{nsState} = 'ERROR';
     459#        return(1);
     460#    }
    430461
    431462    my $N = 0;
     
    433464    foreach my $row (@burntool_entries) {
    434465        my ($trash,$start,$end);
    435         ($trash,$trash,$start,$end) = (split /\s+/,$row);
    436 
     466        (undef,$trash,$start,$end) = (split /\s+/,$row);
     467        if ($trash ne 'burntool') {
     468            $metadata_out{nsState} = 'ERROR';
     469            return(1);
     470        }
    437471        for (my $class_counter = 0; $class_counter < 60; $class_counter++) {
    438472            $metadata_out{"bt${N}Begin"} = $start;
     
    731765    my $date = shift;
    732766    my $target = shift;
     767    my $mode = shift;
     768
     769    my $command = $clean_commands{$mode};
     770    my $retention_time = $clean_retention{$mode};
    733771
    734772    my ($year,$month,$day) = split /-/,$date;
     
    740778
    741779    my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($cleaning_date,$target);
    742 
    743     my $args .= " -dbname gpc1 -updaterun -set_state goto_cleaned -state full -data_group $data_group ";
     780    my $args = $command;
     781    $args .= " -dbname gpc1 -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label $label -data_group $data_group ";
    744782    if ($debug == 1) {
    745783        $args .= ' -pretend ';
     
    752790    my $pretend = shift;
    753791
    754     foreach my $target (@target_list) {
    755         my ($cleaning_date,$args) = construct_cleantool_args($date,$target);
    756 
    757         my $command = $chiptool . $args;
    758         print STDERR "$command\n";
    759         if (!(defined($pretend) || $debug == 1)) {
     792    foreach my $mode (keys (%clean_commands)) {
     793        foreach my $target (@target_list) {
     794            if (exists($noclean_list{$target})) {
     795                next;
     796            }
     797            my ($cleaning_date,$command) = construct_cleantool_args($date,$target,$mode);
     798
     799            print STDERR "$command\n";
     800            if (!(defined($pretend) || $debug == 1)) {
    760801#           print STDERR "BEAR IS DRIVING!?\n";
    761             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    762                 run ( command => $command, verbose => $verbose );
    763             unless ($success) {
    764                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    765                 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
    766             }
    767         }
    768         $command = $warptool . $args;
    769         print STDERR "$command\n";
    770         if (!(defined($pretend) || $debug == 1)) {
    771 #           print STDERR "BEAR IS DRIVING $pretend $debug!?\n";
    772             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    773                 run ( command => $command, verbose => $verbose );
    774             unless ($success) {
    775                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    776                 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
    777             }
    778         }
     802                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     803                    run ( command => $command, verbose => $verbose );
     804                unless ($success) {
     805                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     806                    &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
     807                }
     808            }
     809        }
    779810    }
    780811    return(0);
  • branches/czw_branch/20100427/ippScripts/scripts/camera_exp.pl

    r27718 r28017  
    280280        unless ($success) {
    281281            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     282            print STDERR (join "\n", @$stderr_buf);
    282283            &my_die("Unable to perform psastro: $error_code", $cam_id, $error_code);
    283284        }
  • branches/czw_branch/20100427/ippScripts/scripts/diff_skycell.pl

    r27784 r28017  
    399399            $command .= " -hostname $host" if defined $host;
    400400            $command .= " -path_base $outroot" if defined $outroot;
    401             $command .= " -dbname $dbname" if defined $dbname;
    402401        } else {
    403402            $command .= " -updatediffskyfile";
    404403        }
     404        $command .= " -dbname $dbname" if defined $dbname;
    405405        run(command => $command, verbose => $verbose);
    406406    }
  • branches/czw_branch/20100427/ippScripts/scripts/ipp_cleanup.pl

    r27757 r28017  
    192192            # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
    193193            my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
    194             $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned";
     194            $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
    195195            $command .= " -dbname $dbname" if defined $dbname;
    196196            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    309309        # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
    310310        my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
    311         $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned";
     311        $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
    312312        $command .= " -dbname $dbname" if defined $dbname;
    313313        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    447447            # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
    448448            my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
    449             $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned";
     449            $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
    450450            $command .= " -dbname $dbname" if defined $dbname;
    451451            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    581581            # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
    582582            my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
    583             $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned";
     583            $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
    584584            $command .= " -dbname $dbname" if defined $dbname;
    585585            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    731731            # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
    732732            my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
    733             $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned";
     733            $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
    734734            $command .= " -dbname $dbname" if defined $dbname;
    735735            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
  • branches/czw_branch/20100427/ippScripts/scripts/magic_destreak.pl

    r27718 r28017  
    4242# Parse the command-line arguments
    4343my ($magic_ds_id, $camera, $streaks, $inv_streaks, $exp_id, $stage, $stage_id, $component, $uri, $path_base, $cam_path_base, $cam_reduction);
    44 my ($outroot, $recoveryroot);
     44my ($outroot, $recoveryroot, $magicked);
    4545my ($replace, $release);
    4646my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile);
     
    6262           'recoveryroot=s' => \$recoveryroot,# "directory" for saving the images of excised pixels
    6363           'replace=s'      => \$replace,    # replace the input images with the results.
     64           'magicked=s'     => \$magicked,   # magicked state of the run
    6465           'release'        => \$release,    # NAN masked pixels for release
    6566           'save-temps'     => \$save_temps, # Save temporary files?
     
    7273
    7374pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    74 pod2usage( -msg => "Required options: --magic_ds_id --camera --streaks --stage --stage_id --component --uri --path_base --outroot",
     75pod2usage( -msg => "Required options: --magic_ds_id --camera --streaks --stage --stage_id --component --uri --path_base --outroot --magicked",
    7576           -exitval => 3) unless
    7677    defined $magic_ds_id and
     
    8384    defined $uri and
    8485    defined $path_base and
    85     defined $outroot;
     86    defined $outroot and
     87    defined $magicked;
    8688
    8789my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
     
    210212                    &my_die("Unable to parse metadata list", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR);
    211213
    212             $temp_dir = tempdir( CLEANUP => !$save_temps);
    213214            ($sfh, $skycell_list) = tempfile( "/tmp/skycell_list.XXXX", UNLINK => !$save_temps);
    214215
     
    219220                } else {
    220221                    # diff run must have been cleaned up, need to create this skycell file on the fly
     222                    if (!defined $temp_dir ) {
     223                        $temp_dir = tempdir( CLEANUP => !$save_temps);
     224                    }
    221225                    my $skycell_id = $skycell->{skycell_id};
    222226                    $skycell_uri = "$temp_dir/$skycell_id";
     
    248252            my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -";
    249253            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    250                 run(command => $command, verbose => $verbose);
     254                    # note verbose == 0 to avoid polluting log files with almost always useless information
     255                run(command => $command, verbose => 0);
    251256            unless ($success) {
    252257                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     
    267272        $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path_base);
    268273
    269         if ($dynamicMasks) {
     274        # if magicked is non-zero we are updating a previously magicked component. In this case we don't
     275        # touch the camera mask
     276        if (!$magicked and $dynamicMasks) {
    270277            $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id);
    271278            $ch_mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);
  • branches/czw_branch/20100427/ippScripts/scripts/magic_destreak_cleanup.pl

    r27718 r28017  
    6363$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $PS_EXIT_SYS_ERROR ) if $logfile;
    6464
    65 if (0) {
    66 my $nebulousServer = metadataLookupStr( $ipprc->{_siteConfig}, 'NEB_SERVER' );
    67 &my_die("cannot find NEB_SERVER in site configuration", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if !$nebulousServer;
    68 
    69 my $nebulous = eval { Nebulous::Client->new( proxy => $nebulousServer ); };
    70 if ($@ or not defined $nebulous) {
    71     &my_die ("Unable to create a Nebulous::Client object with proxy $nebulousServer", $magic_ds_id, $PS_EXIT_CONFIG_ERROR);
    72 }
    73 }
    7465
    7566$dbname = metadataLookupStr( $ipprc->{_siteConfig}, 'DBNAME' ) if !$dbname;
     
    10899
    109100
     101&my_die("cleanup not supported for camera stage", $magic_ds_id, $PS_EXIT_PROG_ERROR) if $stage eq "camera";
     102
     103
    110104&my_die("unexpected run state found: $state", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if $state ne "goto_cleaned";
    111105&my_die("clean not allowed for raw stage, use goto_restore", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if $stage eq "raw";
     
    130124$dbh->disconnect() or warn $dbh->errstr;
    131125
     126# We no longer clean up the camera stage mask files, but the code was left in place in case
     127# we change our minds.
     128my $cleanup_cam_mask = 0;
     129
    132130my $dynamicMasks;               # Use dynamic masks?
    133131foreach my $comp (@components) {
     
    140138        if ($stage eq "chip") {
    141139            # Check to see if we're using dynamic masks
    142             if (!defined $dynamicMasks) {
     140            if ($cleanup_cam_mask && !defined $dynamicMasks) {
    143141                # Get the PSASTRO recipe
    144142                my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -";
  • branches/czw_branch/20100427/ippScripts/scripts/magic_destreak_revert.pl

    r27718 r28017  
    3838
    3939# Parse the command-line arguments
    40 my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base, $cam_reduction);
     40my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base, $cam_reduction, $magicked);
    4141my ($outroot, $recoveryroot, $replace, $release, $bytes, $md5sum);
    4242my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile);
     
    5555           'replace=s'      => \$replace,    # replace the input images with the results.
    5656           'bothways=s'     => \$bothways,   # run has inverse files (bothways diff)
     57           'magicked=s'     => \$magicked,   # magicked state of the run
    5758           'save-temps'     => \$save_temps, # Save temporary files?
    5859           'dbname=s'       => \$dbname,     # Database name
     
    6465
    6566pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    66 pod2usage( -msg => "Required options: --magic_ds_id --camera --stage --stage_id --component --path_base --outroot",
     67pod2usage( -msg => "Required options: --magic_ds_id --camera --stage --stage_id --component --path_base --outroot --magicked",
    6768           -exitval => 3) unless
    6869    defined $magic_ds_id and
     
    7273    defined $component and
    7374    defined $path_base and
     75    defined $magicked and
    7476    defined $outroot;
    7577
     
    7779
    7880&my_die("cam_path_base is required for chip stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) if ($stage eq 'chip' and !$cam_path_base);
     81
     82
    7983
    8084my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
     
    169173        my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -";
    170174        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    171             run(command => $command, verbose => $verbose);
     175            # note verbose == 0 to keep from polluting log file with lots of usually useless information
     176            run(command => $command, verbose => 0);
    172177        unless ($success) {
    173178            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     
    182187    }
    183188
     189    $image  = $ipprc->filename("PPIMAGE.CHIP", $path_base, $class_id);
     190    $weight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $path_base, $class_id);
     191
    184192    # we use the mask output from the camera stage for input and replace
    185193    # the output of the chip stage with that mask as well.
    186     $image  = $ipprc->filename("PPIMAGE.CHIP", $path_base, $class_id);
    187     $weight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $path_base, $class_id);
    188 
    189     if ($dynamicMasks) {
     194    # Note that when destreaking as part of an update $magicked is non-zero.
     195    # In this case we do not touch the camera stage mask so there is no need to revert it
     196    if (!$magicked and $dynamicMasks) {
    190197        $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id);
    191198        $ch_mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);
     
    195202
    196203    $bimage  = $ipprc->filename("PPIMAGE.CHIP", $backup_path_base, $class_id);
    197     # This is kludgey but correct
     204    # This is somewhat kludgey but it works whether the mask is camera mask or chip mask
    198205    $bmask   = dirname($backup_path_base) . "/SR_" . basename($mask);
    199206    $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $class_id);
  • branches/czw_branch/20100427/ippScripts/scripts/magic_process.pl

    r27718 r28017  
    9999    }
    100100
    101     my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     101    $inputs = $mdcParser->parse_list(join "", @$stdout_buf) or
    102102        &my_die("Unable to parse metadata config doc", $magic_id, $node, $PS_EXIT_PROG_ERROR);
    103 
    104     $inputs = parse_md_list($metadata) or
    105         &my_die("Unable to parse metadata list", $magic_id, $node, $PS_EXIT_PROG_ERROR);
    106103}
    107104
    108105
    109106my @outputs;
     107my $inverse;                    # Using inverse diff?
    110108### Do the heavy lifting
    111109{
     
    263261                cat_list_to_list($mfh, $in_path_base, "mask.list");
    264262                cat_list_to_list($wfh, $in_path_base, "weight.list");
     263
     264                if ($innode->{inverse}) {
     265                    $inverse = 1;
     266                }
    265267            }
    266268            close $in_fh;
     
    330332    }
    331333}
     334
    332335if ($node eq "root") {
    333336    my $streaks_file = "$outroot.streaks";
     
    348351    &run_verifystreaks($baseroot);
    349352
    350     my $command = "$magictool -addmask";
    351     $command   .= " -magic_id $magic_id";
    352     $command   .= " -uri $streaks_file";
    353     $command   .= " -streaks $num_streaks";
    354     $command   .= " -dbname $dbname" if defined $dbname;
    355 
    356     # Add the processed file to the database
    357     unless ($no_update) {
     353    my $exp_id;                 # Exposure identifier
     354    my $cam_path;               # Camera stage path_base
     355    {
     356        my $command = "magictool -exposure -magic_id $magic_id";
     357        $command .= " -inverse" if defined $inverse;
     358        $command .= " -dbname $dbname" if defined $dbname;
    358359        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    359360            run(command => $command, verbose => $verbose);
    360         unless ($success) {
    361             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    362             # This isn't going to work because our result was already entered.
    363             &my_die("Unable to perform magictool -addmask: $error_code", $magic_id, $node, $error_code);
    364         }
    365     } else {
    366         print "Skipping command: $command\n";
     361        my $exposures = $mdcParser->parse_list(join "", @$stdout_buf);
     362        my $exp = $$exposures[0]; # Exposure of interest (should only be one)
     363
     364        $exp_id = $exp->{exp_id};
     365        $cam_path = $exp->{path_base};
     366    }
     367
     368    {
     369        my $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path); # Astrometry file
     370        my $streaks = "$outroot.streaks";                           # Streaks file
     371        my $clusters = "$baseroot.verify/${exp_id}_clusterPos.txt"; # Clusters file
     372
     373        my $command = "ppCoord -astrom $astrom -streaks $streaks";
     374        if ($ipprc->file_exists($clusters)) {
     375            $command .= " -clusters $clusters";
     376        }
     377
     378        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     379            run(command => $command, verbose => $verbose);
     380        open my $coords, "> $outroot.coords";
     381        print $coords join("", @$stdout_buf);
     382        close $coords;
     383    }
     384
     385
     386    {
     387        my $command = "$magictool -addmask";
     388        $command   .= " -magic_id $magic_id";
     389        $command   .= " -uri $streaks_file";
     390        $command   .= " -streaks $num_streaks";
     391        $command   .= " -dbname $dbname" if defined $dbname;
     392
     393        # Add the processed file to the database
     394        unless ($no_update) {
     395            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     396                run(command => $command, verbose => $verbose);
     397            unless ($success) {
     398                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     399                # This isn't going to work because our result was already entered.
     400                &my_die("Unable to perform magictool -addmask: $error_code", $magic_id, $node, $error_code);
     401            }
     402        } else {
     403            print "Skipping command: $command\n";
     404        }
    367405    }
    368406}
  • branches/czw_branch/20100427/ippScripts/scripts/make_burntool_pcontrol.pl

    r27033 r28017  
    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    unless($object) {
     325        $object = '';
     326    }
     327    if ($exp_type eq 'OBJECT') {
     328        foreach my $target (@target_list) {
     329#           print STDERR "$target $obsmode_list{$target} $exp_type $obs_mode $object $comment\n";
     330            if (($obs_mode =~ /$obsmode_list{$target}/)&&
     331                ($object   =~ /$object_list{$target}/)&&
     332                ($comment  =~ /$comment_list{$target}/)) {
     333                $return_value = 1;
     334            }
     335#           print ">$return_value $exp_type $obs_mode $object $comment $target $obsmode_list{$target} $object_list{$target} $comment_list{$target}\n";
     336            if ($return_value) {
     337                return($return_value);
     338            }
     339        }
     340    }
     341    return(0);
    280342}
    281343
  • branches/czw_branch/20100427/ippScripts/scripts/receive_advance.pl

    r27718 r28017  
    6060    &my_die( "Unable to set up", $fileset_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    6161
    62 # update the fileset entry
    63 
    64 if ($dbinfo_uri and ($dbinfo_uri ne "NULL")) {
     62my $import_run_to_db = 0;
     63if ($import_run_to_db and $dbinfo_uri and ($dbinfo_uri ne "NULL")) {
    6564    my $filename = basename($dbinfo_uri);
    6665    my ($stage) = $filename =~ m|^dbinfo\.(\S+)\.\d+\.mdc$|; # Stage of interest
     
    102101}
    103102
     103# update the fileset entry
    104104# All done
    105105{
  • branches/czw_branch/20100427/ippScripts/scripts/register_exp.pl

    r27718 r28017  
    127127$command .= " -end_stage $end_stage" if defined $end_stage;
    128128$command .= " -tess_id   $tess_id"   if defined $tess_id;
     129$command .= " -state full";
    129130$command .= " $cmdflags";
    130131
  • branches/czw_branch/20100427/ippScripts/scripts/register_imfile.pl

    r27718 r28017  
    174174$command .= " -hostname $host" if defined $host;
    175175$command .= " -dbname $dbname" if defined $dbname;
     176$command .= " -data_state full";
    176177$command .= " $cmdflags";
    177178
Note: See TracChangeset for help on using the changeset viewer.