IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36394


Ignore:
Timestamp:
Dec 12, 2013, 3:13:44 PM (13 years ago)
Author:
bills
Message:

fftool exists! Don't pass warp psf file to psphotFullForce

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/bills_branches/bills_201312/ippScripts/scripts/psphot_fullforce_warp.pl

    r36374 r36394  
    3131my $psphotFullForce = can_run('psphotFullForce') or (warn "Can't find psphotFullForce" and $missing_tools = 1);
    3232my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    33 # XXX: fftool is yet to be written
    34 my $fftool = "fftool";  # can_run('fftool') or (warn "Can't find fftool" and $missing_tools = 1);
     33my $fftool = can_run('fftool') or (warn "Can't find fftool" and $missing_tools = 1);
    3534if ($missing_tools) {
    3635    warn("Can't find required tools.");
     
    3837}
    3938
    40 my ($ffw_id, $warp_id, $skycell_id, $path_base, $sourceroot, $camera);
     39my ($ff_id, $warp_id, $skycell_id, $path_base, $sourceroot, $camera);
    4140my ($outroot, $reduction);
    4241my ($dbname, $threads, $verbose, $no_update, $no_op, $redirect);
    4342
    4443GetOptions(
    45     'ffw_id=s'          => \$ffw_id,
     44    'ff_id=s'          => \$ff_id,
    4645    'warp_id=s'         => \$warp_id,   # warp identifier
    4746    'skycell_id=s'      => \$skycell_id,# Skycell identifier
    4847    'warp_path_base=s'  => \$path_base, # path_base of the warp skycell
    49     'sourceroot=s'      => \$sourceroot,# path_base of sources
     48    'sources_path_base=s' => \$sourceroot,# path_base of sources
    5049    'camera=s'          => \$camera,    # camera name of sources
    5150    'dbname|d=s'        => \$dbname,    # Database name
     
    6160pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    6261pod2usage(
    63     -msg => "Required options: --ffw_id --sourceroot --skycell_id --warp_path_base --outroot --camera",
     62    -msg => "Required options: --ff_id --sourceroot --skycell_id --warp_path_base --outroot --camera",
    6463    -exitval => 3,
    65           ) unless defined $ffw_id,
     64          ) unless defined $ff_id,
    6665    and defined $sourceroot
    6766    and (defined $path_base or defined $warp_id) # if we don't have warp's path_base we need warp_id
     
    7069    and defined $outroot;
    7170
    72 # XXX: fftool is not ready to run commands that update the database
    73 $no_update = 1;
    74 
    75 my $ipprc = PS::IPP::Config->new($camera) or my_die( "Unable to set up", $ffw_id, $skycell_id, $PS_EXIT_CONFIG_ERROR );
     71my $ipprc = PS::IPP::Config->new($camera) or my_die( "Unable to set up", $ff_id, $skycell_id, $PS_EXIT_CONFIG_ERROR );
    7672
    7773my $neb;
     
    8480
    8581$ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output",
    86     $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;
     82    $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    8783
    8884if (!$path_base) {
     
    9894            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    9995            &my_die("Unable to perform warptool -warpskyfile -inputskyfile: $error_code",
    100                 $ffw_id, $skycell_id, $error_code);
     96                $ff_id, $skycell_id, $error_code);
    10197        }
    10298
    10399        my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    104             &my_die("Unable to parse metadata config doc", $ffw_id, $skycell_id, $PS_EXIT_PROG_ERROR);
     100            &my_die("Unable to parse metadata config doc", $ff_id, $skycell_id, $PS_EXIT_PROG_ERROR);
    105101        $files = parse_md_list($metadata) or
    106             &my_die("Unable to parse metadata list", $ffw_id, $skycell_id, $PS_EXIT_PROG_ERROR);
    107     }
    108 
    109     &my_die("Input list does not contain exactly one elements", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR)
     102            &my_die("Unable to parse metadata list", $ff_id, $skycell_id, $PS_EXIT_PROG_ERROR);
     103    }
     104
     105    &my_die("Input list does not contain exactly one elements", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR)
    110106        unless scalar @$files == 1;
    111107
     
    113109
    114110    $path_base = $warp->{path_base};
    115     &my_die("Couldn't find input path in warptool output", $ffw_id, $skycell_id, $PS_EXIT_UNKNOWN_ERROR)
     111    &my_die("Couldn't find input path in warptool output", $ff_id, $skycell_id, $PS_EXIT_UNKNOWN_ERROR)
    116112        unless defined $path_base;
    117113
     
    123119unless ($recipe_psphot) {
    124120    &my_die("Couldn't find selected reduction for PSPHOT: $reduction\n",
    125         $ffw_id, $skycell_id, $PS_EXIT_CONFIG_ERROR);
     121        $ff_id, $skycell_id, $PS_EXIT_CONFIG_ERROR);
    126122}
    127123
     
    134130print "recipe_psphot: $recipe_psphot\n";
    135131
     132# use psf measured on input warp
     133# XXX: get this from recipe
     134my $useWarpPSF = 0;
     135
    136136my $input         = $ipprc->filename('PSWARP.OUTPUT', $path_base);
    137137my $inputMask     = $ipprc->filename('PSWARP.OUTPUT.MASK', $path_base);
    138138my $inputVariance = $ipprc->filename('PSWARP.OUTPUT.VARIANCE', $path_base);
    139 my $inputPSF      = $ipprc->filename('PSPHOT.PSF.SKY.SAVE', $path_base);
     139my $inputPSF      = $useWarpPSF ? $ipprc->filename('PSPHOT.PSF.SKY.SAVE', $path_base) : "";
    140140my $inputSources  = $ipprc->filename('PSPHOT.OUTPUT.CFF', $sourceroot);
    141141
     
    144144    print "inputMask:     $inputMask\n";
    145145    print "inputVariance: $inputVariance\n";
    146     # print "inputPath:     $path_base\n";
    147     print "inputPSF:      $inputPSF\n";
     146    print "inputPSF:      $inputPSF\n" if $inputPSF;
    148147    print "inputSources:  $inputSources\n";
    149148}
    150149
    151150# check that the inputs exist (and have non-zero size)
    152 &my_die("Couldn't find input: $input", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input);
    153 &my_die("Couldn't find input: $inputMask", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask);
    154 &my_die("Couldn't find input: $inputVariance", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance);
    155 &my_die("Couldn't find input: $inputPSF", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputPSF);
    156 &my_die("Couldn't find input: $inputSources", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputSources);
     151&my_die("Couldn't find input: $input", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input);
     152&my_die("Couldn't find input: $inputMask", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask);
     153&my_die("Couldn't find input: $inputVariance", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance);
     154&my_die("Couldn't find input: $inputPSF", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR) if ($inputPSF && !$ipprc->file_exists($inputPSF));
     155&my_die("Couldn't find input: $inputSources", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputSources);
    157156
    158157my $dump_config = 1;
     
    193192        unless ($success) {
    194193            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    195             &my_die("Unable to perform ppSub: $error_code", $ffw_id, $skycell_id, $error_code);
     194            &my_die("Unable to perform ppSub: $error_code", $ff_id, $skycell_id, $error_code);
    196195        }
    197196
     
    207206            unless ($success) {
    208207                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    209                 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $ffw_id, $skycell_id, $error_code);
     208                &my_die("Unable to perform ppStatsFromMetadata: $error_code", $ff_id, $skycell_id, $error_code);
    210209            }
    211210            foreach my $line (@$stdout_buf) {
     
    226225# Add the result to the database
    227226{
    228     my $command = "$fftool -ffw_id $ffw_id -skycell_id $skycell_id";
    229     $command .= " -addwarped -path_base $outroot";
     227    my $command = "$fftool -ff_id $ff_id";
     228    $command .= " -addresult -path_base $outroot";
    230229    $command .= " $cmdflags";
    231230    $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
     
    239238            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    240239            my $err_message = "Unable to perform fftool -addwarped" ;
    241                 &my_die("$err_message: $error_code", $ffw_id, $skycell_id, $error_code);
     240                &my_die("$err_message: $error_code", $ff_id, $skycell_id, $error_code);
    242241        }
    243242    } else {
     
    262261    my $error;
    263262    my $output = $ipprc->prepare_output($filerule, $outroot, undef, $delete, \$error)
    264                     or &my_die("failed to prepare output file for: $filerule", $ffw_id, $skycell_id, $error);
     263                    or &my_die("failed to prepare output file for: $filerule", $ff_id, $skycell_id, $error);
    265264    return $output;
    266265}
     
    275274    }
    276275
    277     &my_die("Couldn't find expected output file: $file",  $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);
     276    &my_die("Couldn't find expected output file: $file",  $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);
    278277
    279278    # Funpack to confirm we've really made things correctly
    280279    my $diskfile = $ipprc->file_resolve($file);
    281280    if ($diskfile =~ /fits/) {
    282         my $funpack  = can_run('funpack') or &my_die ("Can't find funpack", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR);
     281        my $funpack  = can_run('funpack') or &my_die ("Can't find funpack", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR);
    283282        my $check_command = "$funpack -S $diskfile > /dev/null";
    284283        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    285284            run(command => $check_command, verbose => $verbose);
    286285        if (!$success) {
    287             &my_die("Output file not a valid fits file: $file", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR);
     286            &my_die("Output file not a valid fits file: $file", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR);
    288287        }
    289288    }
     
    291290
    292291    if ($replicate and $neb) {
    293         $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n",  $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR);
     292        $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n",  $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR);
    294293    }
    295294}
     
    299298{
    300299    my $msg = shift;            # Warning message on die
    301     my $ffw_id = shift;         # full force warp identifier
     300    my $ff_id = shift;         # full force warp identifier
    302301    my $skycell_id = shift;     # Skycell identifier
    303302    my $exit_code = shift;      # Exit code to add
     
    306305
    307306    warn($msg);
    308     if (defined $ffw_id and defined $skycell_id) {
    309         my $command = "$fftool -ffw_id $ffw_id -skycell_id $skycell_id -fault $exit_code";
    310         $command .= " -addffskyfile";
     307    if (defined $ff_id and defined $skycell_id) {
     308        my $command = "$fftool -ff_id $ff_id -fault $exit_code";
     309        $command .= " -addresult";
    311310        $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
    312311        $command .= " -hostname $host" if defined $host;
Note: See TracChangeset for help on using the changeset viewer.