IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 14, 2014, 2:28:47 PM (12 years ago)
Author:
bills
Message:

Iniital implementation of the full force stages to the pipeline.
Maginitude and galactic coordinate limits on extended source fits

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/ippScripts/scripts/psphot_fullforce_warp.pl

    r36374 r36441  
    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 --warp_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
    67     and (defined $path_base or defined $warp_id) # if we don't have warp's path_base we need warp_id
     66    and defined $path_base
     67    and defined $warp_id
    6868    and defined $skycell_id
    6969    and defined $camera
    7070    and defined $outroot;
    7171
    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 );
     72my $ipprc = PS::IPP::Config->new($camera) or my_die( "Unable to set up", $ff_id, $warp_id, $skycell_id, $PS_EXIT_CONFIG_ERROR );
    7673
    7774my $neb;
     
    8481
    8582$ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output",
    86     $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    87 
    88 if (!$path_base) {
     83    $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;
     84
     85if (0) {
     86# if (!$path_base) {
    8987    # If path_base is not supplied, look it up in the database.
    9088    my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     
    9896            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    9997            &my_die("Unable to perform warptool -warpskyfile -inputskyfile: $error_code",
    100                 $ffw_id, $skycell_id, $error_code);
     98                $ff_id, $warp_id, $skycell_id, $error_code);
    10199        }
    102100
    103101        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);
     102            &my_die("Unable to parse metadata config doc", $ff_id, $warp_id, $skycell_id, $PS_EXIT_PROG_ERROR);
    105103        $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)
     104            &my_die("Unable to parse metadata list", $ff_id, $warp_id, $skycell_id, $PS_EXIT_PROG_ERROR);
     105    }
     106
     107    &my_die("Input list does not contain exactly one elements", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR)
    110108        unless scalar @$files == 1;
    111109
     
    113111
    114112    $path_base = $warp->{path_base};
    115     &my_die("Couldn't find input path in warptool output", $ffw_id, $skycell_id, $PS_EXIT_UNKNOWN_ERROR)
     113    &my_die("Couldn't find input path in warptool output", $ff_id, $warp_id, $skycell_id, $PS_EXIT_UNKNOWN_ERROR)
    116114        unless defined $path_base;
    117115
     
    123121unless ($recipe_psphot) {
    124122    &my_die("Couldn't find selected reduction for PSPHOT: $reduction\n",
    125         $ffw_id, $skycell_id, $PS_EXIT_CONFIG_ERROR);
     123        $ff_id, $warp_id, $skycell_id, $PS_EXIT_CONFIG_ERROR);
    126124}
    127125
     
    134132print "recipe_psphot: $recipe_psphot\n";
    135133
     134# use psf measured on input warp
     135# XXX: get this from recipe
     136my $useWarpPSF = 0;
     137
    136138my $input         = $ipprc->filename('PSWARP.OUTPUT', $path_base);
    137139my $inputMask     = $ipprc->filename('PSWARP.OUTPUT.MASK', $path_base);
    138140my $inputVariance = $ipprc->filename('PSWARP.OUTPUT.VARIANCE', $path_base);
    139 my $inputPSF      = $ipprc->filename('PSPHOT.PSF.SKY.SAVE', $path_base);
     141my $inputPSF      = $useWarpPSF ? $ipprc->filename('PSPHOT.PSF.SKY.SAVE', $path_base) : "";
    140142my $inputSources  = $ipprc->filename('PSPHOT.OUTPUT.CFF', $sourceroot);
    141143
     
    144146    print "inputMask:     $inputMask\n";
    145147    print "inputVariance: $inputVariance\n";
    146     # print "inputPath:     $path_base\n";
    147     print "inputPSF:      $inputPSF\n";
     148    print "inputPSF:      $inputPSF\n" if $inputPSF;
    148149    print "inputSources:  $inputSources\n";
    149150}
    150151
    151152# 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);
     153&my_die("Couldn't find input: $input", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input);
     154&my_die("Couldn't find input: $inputMask", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask);
     155&my_die("Couldn't find input: $inputVariance", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance);
     156&my_die("Couldn't find input: $inputPSF", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) if ($inputPSF && !$ipprc->file_exists($inputPSF));
     157&my_die("Couldn't find input: $inputSources", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputSources);
    157158
    158159my $dump_config = 1;
     
    193194        unless ($success) {
    194195            $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);
     196            &my_die("Unable to perform ppSub: $error_code", $ff_id, $warp_id, $skycell_id, $error_code);
    196197        }
    197198
     
    207208            unless ($success) {
    208209                $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);
     210                &my_die("Unable to perform ppStatsFromMetadata: $error_code", $ff_id, $warp_id, $skycell_id, $error_code);
    210211            }
    211212            foreach my $line (@$stdout_buf) {
     
    226227# Add the result to the database
    227228{
    228     my $command = "$fftool -ffw_id $ffw_id -skycell_id $skycell_id";
    229     $command .= " -addwarped -path_base $outroot";
     229    my $command = "$fftool -ff_id $ff_id -warp_id $warp_id";
     230    $command .= " -addresult -path_base $outroot";
    230231    $command .= " $cmdflags";
    231232    $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
     
    239240            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    240241            my $err_message = "Unable to perform fftool -addwarped" ;
    241                 &my_die("$err_message: $error_code", $ffw_id, $skycell_id, $error_code);
     242                &my_die("$err_message: $error_code", $ff_id, $warp_id, $skycell_id, $error_code);
    242243        }
    243244    } else {
     
    262263    my $error;
    263264    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);
     265                    or &my_die("failed to prepare output file for: $filerule", $ff_id, $warp_id, $skycell_id, $error);
    265266    return $output;
    266267}
     
    275276    }
    276277
    277     &my_die("Couldn't find expected output file: $file",  $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);
     278    &my_die("Couldn't find expected output file: $file",  $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);
    278279
    279280    # Funpack to confirm we've really made things correctly
    280281    my $diskfile = $ipprc->file_resolve($file);
    281282    if ($diskfile =~ /fits/) {
    282         my $funpack  = can_run('funpack') or &my_die ("Can't find funpack", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR);
     283        my $funpack  = can_run('funpack') or &my_die ("Can't find funpack", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR);
    283284        my $check_command = "$funpack -S $diskfile > /dev/null";
    284285        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    285286            run(command => $check_command, verbose => $verbose);
    286287        if (!$success) {
    287             &my_die("Output file not a valid fits file: $file", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR);
     288            &my_die("Output file not a valid fits file: $file", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR);
    288289        }
    289290    }
     
    291292
    292293    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);
     294        $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n",  $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR);
    294295    }
    295296}
     
    299300{
    300301    my $msg = shift;            # Warning message on die
    301     my $ffw_id = shift;         # full force warp identifier
     302    my $ff_id = shift;          # full force run identifier
     303    my $warp_id = shift;        # full force warp id
    302304    my $skycell_id = shift;     # Skycell identifier
    303305    my $exit_code = shift;      # Exit code to add
     
    306308
    307309    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";
     310    if (defined $ff_id and defined $skycell_id) {
     311        my $command = "$fftool -ff_id $ff_id -warp_id $warp_id -fault $exit_code";
     312        $command .= " -addresult";
    311313        $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
    312314        $command .= " -hostname $host" if defined $host;
Note: See TracChangeset for help on using the changeset viewer.