IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 6, 2012, 6:32:19 PM (14 years ago)
Author:
watersc1
Message:

merge from trunk. Preliminary versions of stacktool/warptool updates and regenerate_background.pl script. The warp code is finished and tested, and I still need to get the stack version resolved.

Location:
branches/czw_branch/20120906/ippScripts
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20120906/ippScripts/Build.PL

    r33627 r34772  
    128128        scripts/listvideocells.pl
    129129        scripts/skycalibration.pl
     130        scripts/regenerate_background.pl
    130131    )],
    131132    dist_abstract => 'Scripts for running the Pan-STARRS IPP',
  • branches/czw_branch/20120906/ippScripts/MANIFEST

    r31435 r34772  
    4646scripts/skycell_jpeg.pl
    4747scripts/lap_science.pl
     48scripts/regenerate_background.pl
    4849t/00_distribution.t
  • branches/czw_branch/20120906/ippScripts/scripts/addstar_run.pl

    r34265 r34772  
    300300            $command .= " -image" if $image_only;
    301301            if ($stage =~ /staticsky/) {
    302                 $command .= " -accept-astrom ";
     302                $command .= " -accept-astrom -quick-airmass";
     303            }  #careful here - this matches staticsky and staticsky_multi
     304            if ($stage =~ /skycal/) {
     305                $command .= " -quick-airmass";
    303306            }  #careful here - this matches staticsky and staticsky_multi
    304307
  • branches/czw_branch/20120906/ippScripts/scripts/background_chip.pl

    r33054 r34772  
    7373
    7474if ($redirect) {
    75     $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR );
     75    $ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR );
    7676    print STDOUT "\n\n";
    7777    print STDOUT "Starting script $0 on $host\n\n";
     
    155155
    156156$ipprc->outroot_prepare($outroot);
    157 my $out_image = $ipprc->filename("PPBACKGROUND.OUTPUT", $outroot, $class_id);
    158 my $out_mask = $ipprc->filename("PPBACKGROUND.OUTPUT.MASK", $outroot, $class_id);
    159 my $out_stats = $ipprc->filename("PPBACKGROUND.STATS", $outroot, $class_id);
    160 my $out_config = $ipprc->filename("PPBACKGROUND.CONFIG", $outroot, $class_id);
    161 my $traceDest = $ipprc->filename("TRACE.IMFILE", $outroot, $class_id);
     157#my $out_image = $ipprc->filename("PPBACKGROUND.OUTPUT", $outroot, $class_id);
     158#my $out_mask = $ipprc->filename("PPBACKGROUND.OUTPUT.MASK", $outroot, $class_id);
     159#my $out_stats = $ipprc->filename("PPBACKGROUND.STATS", $outroot, $class_id);
     160#my $out_config = $ipprc->filename("PPBACKGROUND.CONFIG", $outroot, $class_id);
     161#my $traceDest = $ipprc->filename("TRACE.IMFILE", $outroot, $class_id);
     162
     163my $out_image = prepare_output("PPBACKGROUND.OUTPUT", $outroot, $class_id, 1);
     164my $out_mask = prepare_output("PPBACKGROUND.OUTPUT.MASK", $outroot, $class_id, 1);
     165my $out_stats = prepare_output("PPBACKGROUND.STATS", $outroot, $class_id, 1);
     166my $out_config = prepare_output("PPBACKGROUND.CONFIG", $outroot, $class_id, 1);
     167my $traceDest = prepare_output("TRACE.IMFILE", $outroot, $class_id, 1);
    162168
    163169# Run ppImage
     
    238244### Pau.
    239245
     246# Prepare to write to an output file
     247#   Lookup the filename in the rules.
     248#   Make sure that if file exists and is a nebulous file that there is only one instance
     249#   Deal with files that have been lost.
     250sub prepare_output
     251{
     252    my $filerule = shift;
     253    my $outroot  = shift;
     254    my $class_id = shift;
     255    my $delete = shift;
     256    $delete = 0 if !defined $delete;
     257
     258    my $error;
     259    my $output = $ipprc->prepare_output($filerule, $outroot, $class_id, $delete, \$error)
     260                    or &my_die("failed to prepare output file for: $filerule", $chip_bg_id, $class_id, $error);
     261    return $output;
     262}
     263
     264
    240265
    241266sub my_die
  • branches/czw_branch/20120906/ippScripts/scripts/background_warp.pl

    r33054 r34772  
    8888my $logDest = $ipprc->filename("LOG.EXP", $outroot, $skycell_id) or my_die( "Unable to get log filename", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR );
    8989
    90 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;
     90$ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    9191
    9292# Recipes to use based on reduction class
     
    158158&my_die("Can't find input astrometry: $astrometry", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) unless $ipprc->file_exists($astrometry);
    159159
    160 my $out_image = $ipprc->filename("PSWARP.OUTPUT", $outroot, $skycell_id );
    161 my $out_mask = $ipprc->filename("PSWARP.OUTPUT.MASK", $outroot, $skycell_id);
    162 my $out_stats = $ipprc->filename("SKYCELL.STATS", $outroot, $skycell_id );
    163 my $out_config = $ipprc->filename("PSWARP.CONFIG", $outroot, $skycell_id);
    164 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot, $skycell_id);
    165 
    166 my $skyFile = $ipprc->filename("SKYCELL.TEMPLATE", $outroot, $skycell_id );
     160#my $out_image = $ipprc->filename("PSWARP.OUTPUT", $outroot, $skycell_id );
     161#my $out_mask = $ipprc->filename("PSWARP.OUTPUT.MASK", $outroot, $skycell_id);
     162#my $out_stats = $ipprc->filename("SKYCELL.STATS", $outroot, $skycell_id );
     163#my $out_config = $ipprc->filename("PSWARP.CONFIG", $outroot, $skycell_id);
     164#my $traceDest = $ipprc->filename("TRACE.EXP", $outroot, $skycell_id);
     165
     166my $out_image = prepare_output("PSWARP.OUTPUT", $outroot, $skycell_id,  1);
     167my $out_mask = prepare_output("PSWARP.OUTPUT.MASK", $outroot, $skycell_id, 1);
     168my $out_stats = prepare_output("SKYCELL.STATS", $outroot, $skycell_id, 1);
     169my $out_config = prepare_output("PSWARP.CONFIG", $outroot, $skycell_id, 1);
     170my $traceDest = prepare_output("TRACE.EXP", $outroot, $skycell_id, 1);
     171
     172my $skyFile = prepare_output("SKYCELL.TEMPLATE", $outroot, $skycell_id, 1);
     173
    167174$ipprc->skycell_file( $tess_dir, $skycell_id, $skyFile, $verbose ) or &my_die("Unable to generate template skycell", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR);
    168175
     
    239246### Pau.
    240247
     248sub prepare_output
     249{
     250    my $filerule = shift;
     251    my $outroot  = shift;
     252    my $skycell_id = shift;
     253    my $delete = shift;
     254    $delete = 0 if !defined $delete;
     255
     256    my $error;
     257    my $output = $ipprc->prepare_output($filerule, $outroot, $skycell_id, $delete, \$error)
     258                    or &my_die("failed to prepare output file for: $filerule", $warp_bg_id, $skycell_id, $error);
     259    return $output;
     260}
     261
    241262
    242263sub my_die
  • branches/czw_branch/20120906/ippScripts/scripts/destreak_restore_camera.pl

    r34402 r34772  
    440440    }
    441441
     442    my $backup_url = shift;
    442443    my $original_url = shift;
    443     my $backup_url = shift;
    444444
    445445    # rename the backup as the orig
     
    449449    my $moved;
    450450    eval {
    451         $moved = nebulous->move($backup_url, $original_url);
     451        $moved = $nebulous->move($backup_url, $original_url);
    452452    };
    453453    if ($@ or not $moved) {
  • branches/czw_branch/20120906/ippScripts/scripts/detrend_process_imfile.pl

    r33666 r34772  
    2727my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
    2828my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     29my $nebrepair = can_run('neb-repair') or (warn "Can't find neb-repair" and $missing_tools = 1);
     30
    2931if ($missing_tools) {
    3032    warn("Can't find required tools.");
     
    124126# Run ppImage
    125127unless ($no_op) {
     128    my $repair_cmd = "$nebrepair $input_uri";
     129    my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose);
     130    unless ($repair_success) {
     131        &my_die("Unable to attempt repair: $input_uri $repair_error_code", $det_id, $exp_id, $class_id $PS_EXIT_SYS_ERROR);
     132    }
     133
     134
    126135    my $command = "$ppImage -file $input_uri $outroot";
    127136    $command .= " -recipe PPIMAGE $ppimage_recipe";
  • branches/czw_branch/20120906/ippScripts/scripts/ipp_apply_burntool_single.pl

  • branches/czw_branch/20120906/ippScripts/scripts/lap_science.pl

    r34313 r34772  
    671671#       }
    672672        # Do quality checks here
     673        if ($verbose) {
     674            printf("TEST: %d %d %d\n",$exposure->{exp_id},$exposure->{chip_id},$exposure->{chip_component_count});
     675        }
     676        # Checks to ensure we do not divide by zero.  Mostly happens with old diffs, it seems.
     677        if ($exposure->{chip_component_count} == 0) {
     678            $exposure->{chip_component_count} = 1;
     679        }
     680        if ($exposure->{cam_component_count} == 0) {
     681            $exposure->{cam_component_count} = 1;
     682        }
     683        if ($exposure->{warp_component_count} == 0) {
     684            $exposure->{warp_component_count} = 1;
     685        }
     686        if ($exposure->{diff_component_count} == 0) {
     687            $exposure->{diff_component_count} = 1;
     688        }
     689
    673690        my $is_bad_quality = 0;
    674691        if ((defined($exposure->{chipRun_state}))&&($exposure->{chipRun_state} eq 'full')&&
  • branches/czw_branch/20120906/ippScripts/scripts/magic_destreak.pl

  • branches/czw_branch/20120906/ippScripts/scripts/publish_file.pl

    r30376 r34772  
    3232my $pubtool = can_run('pubtool') or (warn "Can't find pubtool" and $missing_tools = 1);
    3333my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);
     34my $regtool = can_run('regtool') or (warn "Can't find regtool" and $missing_tools = 1);
    3435my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1);
    3536my $ppMops = can_run('ppMops') or (warn "Can't find ppMops" and $missing_tools = 1);
     
    4445my ( $pub_id, $camera, $stage, $stage_id, $fileset, $format, $product, $workdir, $need_magic );
    4546my ( $dbname, $verbose, $no_update, $no_op, $save_temps, $redirect );
    46 my ( $output_format );
     47my ( $output_format, $difftype );
    4748
    4849GetOptions(
     
    7273    defined $stage and
    7374    defined $stage_id and
    74     defined $workdir;
     75    defined $workdir and
     76    defined $dbname;
    7577
    7678my $outroot = "$workdir/$product.$pub_id"; # Output root name
     
    166168    my %negative;               # Data for negative diff detections
    167169    foreach my $comp ( @$components ) {
    168         my $path_base = $comp->{path_base}; # Base name for file
     170        my $path_base = $comp->{path_base}; # Base name for file
    169171        if (!$need_magic and $comp->{magicked}) {
    170172            # This client is authorized to receive uncensored detections
     
    194196
    195197        $filename = $resolved;
     198
     199        my $cam_id = $comp->{cam_id_1};
     200        #print "Getting info from camera stage $cam_id\n";
     201        my $cam_command =  "$camtool -processedexp -cam_id $cam_id";
     202        $cam_command .= " -dbname $dbname" if defined $dbname;
     203        my ( $cam_success, $cam_error_code, $cam_full_buf, $cam_stdout_buf, $cam_stderr_buf ) =
     204            run(command => $cam_command, verbose => $verbose);
     205        &my_die( "Unable to retrieve filename", $pub_id, $PS_EXIT_SYS_ERROR) unless $cam_success;
     206        my $cam_metadata = $mdcParser->parse(join "", @$cam_stdout_buf) or
     207            &my_die("Unable to parse metadata config", $pub_id, $PS_EXIT_PROG_ERROR);
     208        my $cam_components = parse_md_list($cam_metadata) or
     209            &my_die("Unable to parse metadata list", $pub_id, $PS_EXIT_PROG_ERROR);
     210        &my_die("More than one entry for cam_id $stage_id", $pub_id, $PS_EXIT_PROG_ERROR) if scalar @$cam_components > 1;
     211        my $cam_comp = $$cam_components[0];
     212
     213        my $exp_id = $comp->{exp_id_1};
     214        #print "Getting info from raw stage $exp_id\n";
     215        my $reg_command =  "$regtool -processedimfile -exp_id $exp_id";
     216        $reg_command .= " -dbname $dbname" if defined $dbname;
     217        my ( $reg_success, $reg_error_code, $reg_full_buf, $reg_stdout_buf, $reg_stderr_buf ) =
     218            run(command => $reg_command, verbose => $verbose);
     219        &my_die( "Unable to retrieve filename", $pub_id, $PS_EXIT_SYS_ERROR) unless $reg_success;
     220        my $reg_metadata = $mdcParser->parse(join "", @$reg_stdout_buf) or
     221            &my_die("Unable to parse metadata config", $pub_id, $PS_EXIT_PROG_ERROR);
     222        my $reg_components = parse_md_list($reg_metadata) or
     223            &my_die("Unable to parse metadata list", $pub_id, $PS_EXIT_PROG_ERROR);
     224        my $reg_comp = $$reg_components[0];
     225
     226        # Now get the difftype value from diff->{diff_mode}
     227        my $difftype = "";
     228        if ($comp->{diff_mode} == 1) {
     229            $difftype = "WW";
     230        } elsif ($comp->{diff_mode} == 2) {
     231            $difftype = "WS";
     232        } elsif ($comp->{diff_mode} == 3) {
     233            $difftype = "SW"; # Not used yet
     234        } elsif ($comp->{diff_mode} == 4) {
     235            $difftype = "SS";
     236        } else {
     237            $difftype = "Unsupported diff_mode value: [" . $comp->{diff_mode} . "]";
     238        }
    196239
    197240        my $data = { zp => $zp,
     
    207250                     output_format => $comp->{output_format},
    208251                     direction => 1,
     252                     comment => $reg_comp->{comment},
     253                     obsmode => $reg_comp->{obs_mode},
     254                     difftype => $difftype,
     255                     sky => $cam_comp->{bg},
     256                     shutoutc => $reg_comp->{dateobs},
    209257        };
    210258
     259        #warn("Checking for positive");
    211260        diff_check(\%positive, $data, "positive");
    212261
     
    239288                         diff_id => $comp->{diff_id},
    240289                         direction => 0,
     290                         comment => $reg_comp->{comment},
     291                         obsmode => $reg_comp->{obs_mode},
     292                         difftype => $difftype,
     293                         sky => $cam_comp->{bg},
     294                         shutoutc => $reg_comp->{dateobs},
    241295            };
    242296
     297            #warn("Checking for negative");
    243298            diff_check(\%negative, $data, "negative");
    244299
     
    288343    &my_die( "Unable to register with data store", $pub_id, $PS_EXIT_SYS_ERROR) unless $success;
    289344}
    290 
    291 
    292345
    293346### Pau.
     
    311364    $data->{diff_id} = $comp->{diff_id} unless defined $data->{diff_id};
    312365    $data->{direction} = $comp->{direction} unless defined $data->{direction};
     366    $data->{comment} = $comp->{comment} unless defined $data->{comment};
     367    $data->{obsmode} = $comp->{obsmode} unless defined $data->{obsmode};
     368    $data->{difftype} = $comp->{difftype} unless defined $data->{difftype};
     369    $data->{sky} = $comp->{sky} unless defined $data->{sky};
     370    $data->{shutoutc} = $comp->{shutoutc} unless defined $data->{shutoutc};
    313371
    314372    &my_die("zp value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{zp} and $comp->{zp} != $data->{zp};
     
    323381    &my_die("diff_id value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{diff_id} and $comp->{diff_id} != $data->{diff_id};
    324382    &my_die("direction value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{direction} and $comp->{direction} != $data->{direction};
     383    &my_die("comment value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{comment} and $comp->{comment} ne $data->{comment};
     384    &my_die("obsmode value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{obsmode} and $comp->{obsmode} ne $data->{obsmode};
     385    &my_die("difftype value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{difftype} and $comp->{difftype} ne $data->{difftype};
     386    &my_die("sky value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{sky} and $comp->{sky} != $data->{sky};
     387    &my_die("shutoutc value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{shutoutc} and $comp->{shutoutc} ne $data->{shutoutc};
    325388
    326389    return 1;
     
    350413    $command .= " -astrom_rms " . $data->{astrom} if defined $data->{astrom};
    351414    $command .= " -version " . $data->{output_format} if defined $data->{output_format};
     415    $command .= " -comment \"" . $data->{comment} . "\"" if defined $data->{comment};
     416    $command .= " -obsmode " . $data->{obsmode} if defined $data->{obsmode};
     417    $command .= " -difftype " . $data->{difftype} if defined $data->{difftype};
     418    $command .= " -sky " . $data->{sky} if defined $data->{sky};
     419    $command .= " -shutoutc \"" . $data->{shutoutc} . "\"" if defined $data->{shutoutc};
    352420
    353421    unless ($no_op) {
  • branches/czw_branch/20120906/ippScripts/scripts/regenerate_background.pl

    r34756 r34772  
    1010use IPC::Cmd 0.36 qw( can_run run );
    1111use File::Spec;
     12use File::Temp qw( tempfile );
    1213use PS::IPP::Config 1.01 qw( :standard );
    1314use Getopt::Long qw (GetOptions :config auto_help auto_version gnu_getopt );
    1415use Pod::Usage qw( pod2usage );
     16use PS::IPP::Metadata::Config;
     17use PS::IPP::Metadata::List qw( parse_md_list );
     18
     19
    1520
    1621my $ppConfigDump = can_run('ppConfigDump');
     
    6772    my $astromSource;               # The astrometry source
    6873    {
    69         my $command = "$ppConfigDump -camera $camera -recipe PSWARP DEFAULT -dump-recipe PSWARP -";
     74        my $command = "$ppConfigDump -camera $camera -recipe PSWARP BACKGROUND -dump-recipe PSWARP -";
    7075        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    7176            run(command => $command, verbose => $verbose);
     
    97102    }
    98103
    99     my $in_md = $mdcParser->parse_list(join "", @$stdout_buf) or
     104    my $in_md = $mdcParser->parse(join "", @$stdout_buf) or
    100105        &my_die("Unable to parse metadata config doc", $stage, $stage_id, $PS_EXIT_PROG_ERROR);
    101106    $imfiles  = parse_md_list($in_md) or
     
    165170                &my_die("Unable to generate template skycell",$skycell_id,$warp_id,$PS_EXIT_SYS_ERROR);
    166171        }
    167 
     172        my $bkgOut_log = prepare_output("LOG.EXP",$path_base . ".BKG_REG",$skycell_id,1);
    168173
    169174        # Construct pswarp command
    170175        my $pswarp_command = "$pswarp ";
    171176        $pswarp_command .= " -list $bkgList_name -astromlist $astromList_name -bkglist $bkgList_name ";
     177        $pswarp_command .= " ${path_base} ";
    172178        $pswarp_command .= " $skyCell_name ";
    173179        $pswarp_command .= " -F PSPHOT.PSF.SAVE PSPHOT.PSF.SKY.SAVE -F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF ";
     
    186192        unless ($success) {
    187193            $error_code = (($error_code >> 8)  or $PS_EXIT_PROG_ERROR);
     194            &my_die("Unable to perform pswarp: $error_code", $stage, $stage_id, $error_code);
     195        }
     196       
     197        my $update_command = "$warptool ";
     198        $update_command .= " -updateskyfile -warp_id $warp_id -skycell_id $skycell_id ";
     199        $update_command .= " -set_background_model 1 ";
     200        $update_command .= " -dbname $dbname " if defined $dbname;
     201
     202        ( $success, $error_code, $full_buf, $stdout_buf, $stderrr_buf ) =
     203            run(command => $update_command, verbose => $verbose);
     204        unless ($success) {
     205            $error_code = (($error_code >> 8)  or $PS_EXIT_PROG_ERROR);
    188206            &my_die("Unable to perform warptool: $error_code", $stage, $stage_id, $error_code);
    189207        }
     
    223241   
    224242    my $num = 0;
    225    
     243    my $path_base = '/tmp/x';
     244    my $expTime   = 60;
     245
    226246    my ($inputMDC_file, $inputMDC_name) = tempfile("/tmp/bkgreg.stack.mdc.${stage_id}.XXXX",
    227247                                                   UNLINK => !$save_temps);
     
    242262    }
    243263    close($inputMDC_file);
    244    
     264
     265    my $bkgOut_log = prepare_output("LOG.IMFILE",$path_base . "BKG_REG",$skycell_id,1);   
     266
    245267    my $ppStack_command = "$ppStackMedian -input $inputMDC_name $path_base ";
    246268    $ppStack_command   .= " -recipe PPSTACK STACK -recipe PPSUB STACK -recipe PSPHOT STACK ";
     
    253275    $ppStack_command   .= " -Db PHOTOMETRY F -Db VARIANCE F -Db CONVOLVE F ";
    254276    $ppStack_command   .= " -Df DEFAULT.EXPTIME $expTime ";
    255     $ppStack_command   .= " -threads $threads -log $bkgOut_log ";
     277    $ppStack_command   .= " -threads 1 -log $bkgOut_log ";
    256278    $ppStack_command   .= " -dbname $dbname " if defined $dbname;
    257279
  • branches/czw_branch/20120906/ippScripts/scripts/skycalibration.pl

    r34151 r34772  
    3333my $psastro = can_run('psastro') or (warn "Can't find psastro" and $missing_tools = 1);
    3434my $fhead = can_run('fhead') or (warn "Can't find fhead" and $missing_tools = 1);
     35my $fields = can_run('fields') or (warn "Can't find fields" and $missing_tools = 1);
    3536my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    3637my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     
    191192}
    192193
     194my $resolved = $ipprc->file_resolve($file);
     195if (!$resolved) {
     196    &my_die("Unable to find input file: $file", $skycal_id, $PS_EXIT_SYS_ERROR);
     197}
     198
     199# read the input header to find the number of detections and the number of detections
     200# with extended model
     201my $n_detections = 0;
     202my $n_extended = 0;
     203{
     204    my $command = "echo $resolved | $fields -n SkyChip.psf NAXIS2";
     205    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     206            run(command => $command, verbose => 0);
     207        # fields does not return 0 on success
     208    (undef, $n_detections)  = split " ", join "", @$stdout_buf;
     209    chomp $n_detections;
     210    &my_die("Unable to find number of detections from $file: ", $skycal_id, $PS_EXIT_SYS_ERROR)
     211        unless defined $n_detections;
     212
     213    $command = "echo $resolved | $fields -n SkyChip.hdr NDET_EXT";
     214    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     215            run(command => $command, verbose => 0);
     216    (undef, $n_extended)  = split " ", join "", @$stdout_buf;
     217    chomp $n_extended;
     218    &my_die("Unable to find number of extended objects from $file: ", $skycal_id, $PS_EXIT_SYS_ERROR)
     219        unless defined $n_extended;
     220}
     221
     222
    193223# Perform psastro analysis
    194224my $output_sources_filerule =  'PSASTRO.OUTPUT.CMF';
     
    246276{
    247277    my $command = "$staticskytool -skycal_id $skycal_id";
     278    $command .= " -n_detections $n_detections";
     279    $command .= " -n_extended $n_extended";
    248280    $command .= " -addskycalresult -path_base $outroot";
    249281    $command .= " $cmdflags";
  • branches/czw_branch/20120906/ippScripts/scripts/staticsky.pl

    r33979 r34772  
    124124my $nInputs = @$files;
    125125
    126 if ($nInputs > 1) {
     126if (1) {
    127127        my $recipe_psphot  = $ipprc->reduction($reduction, 'STACKPHOT_PSPHOT'); # Recipe to use for psphot
    128128        my $recipe_ppsub   = $ipprc->reduction($reduction, 'STACKPHOT_PPSUB'); # Recipe to use for ppsub
     
    266266        }
    267267} else {
     268    # XXX This mode is no longer used. We run psphotStack even if there is only one filter
    268269        # single input. Run psphot
    269270        # find the recipe
     
    302303            $mask   = $ipprc->filename("PPSTACK.UNCONV.MASK",     $path_base ); # Mask name
    303304            $variance = $ipprc->filename("PPSTACK.UNCONV.VARIANCE", $path_base ); # Weight name
     305            $expnum = $ipprc->filename("PPSTACK.OUTPUT.EXPNUM", $path_base ); # Expnum name
    304306        } else {
    305307            $image  = $ipprc->filename("PPSTACK.OUTPUT",          $path_base ); # Image name
    306308            $mask   = $ipprc->filename("PPSTACK.OUTPUT.MASK",     $path_base ); # Mask name
    307309            $variance = $ipprc->filename("PPSTACK.OUTPUT.VARIANCE", $path_base ); # Weight name
    308             $expnum = $ipprc->filename("PPSTACK.OUTPUT.EXPNUM", $path_base ); # Weight name
     310            $expnum = $ipprc->filename("PPSTACK.OUTPUT.EXPNUM", $path_base ); # Expnum name
    309311        }
    310312
Note: See TracChangeset for help on using the changeset viewer.