IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38937 for trunk/ippScripts


Ignore:
Timestamp:
Oct 21, 2015, 5:44:52 PM (11 years ago)
Author:
watersc1
Message:

Untested fullforce_summary handlers. addtool compiles and addstar_run.pl doesn't complain about variables, but I have not confirmed they work correctly.

File:
1 edited

Legend:

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

    r38090 r38937  
    3131my $addtool = can_run('addtool') or (warn "Can't find addtool" and $missing_tools = 1);
    3232my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);
     33my $fftool  = can_run('fftool') or (warn "Can't find fftool" and $missing_tools = 1);
     34
    3335my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     36
    3437my $addstar = can_run('addstar') or (warn "Can't find addstar" and $missing_tools = 1);
     38my $loadgalphot = can_run('loadgalphot') or (warn "Can't find loadgalphot" and $missing_tools = 1);
     39
    3540if ($missing_tools) {
    3641    warn("Can't find required tools.");
     
    9297}
    9398
     99my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     100
     101# Output products
     102$ipprc->outroot_prepare($outroot);
     103
     104
     105#
     106# Step 1: sort out reductions / recipes
     107#
     108
     109
    94110# Recipes to use based on reduction class
    95111$reduction = 'DEFAULT' unless defined $reduction;
     
    101117#}
    102118
    103 if ($stage =~/fullforce/) {
     119if ($stage eq 'fullforce') {
    104120    $reduction='DEFAULT';
    105121    #hardwired because why not
    106122}
    107 if ($stage =~/diff/) {
     123elsif ($stage eq 'fullforce_summary') {
     124    $reduction = 'DEFAULT';
     125}
     126elsif ($stage eq 'diff') {
    108127    $reduction='DEFAULT';
    109128    #hardwired because why not
     
    112131my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR');
    113132# XXX This is now not used: do we still need it?
    114 if ($stage =~/cam/) {
     133if ($stage eq 'cam') {
    115134  $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use
    116135}
    117 if ($stage =~/stack/) {
     136elsif ($stage eq 'stack') {
    118137  $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR_STACK'); # Recipe to use
     138}
     139elsif ($stage eq 'skycal') {
     140    $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use                                                             
    119141}
    120142#if ($stage =~/staticsky/) {
    121143#  $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR_STATICSKY'); # Recipe to use
    122144#}
    123 if ($stage =~/skycal/) {
    124     $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use                                                             
    125 }
    126145
    127146
     
    129148&my_die("Unrecognised ADDSTAR recipe", $add_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_addstar;
    130149
    131 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    132 
    133 # Output products
    134 $ipprc->outroot_prepare($outroot);
    135150
    136151# the camera configurations should define the psastro output to be a single file (MEF), regardless of the inputs
     152
     153#
     154# Step 2: Determine where sources should come from, modify them as needed.
     155#
     156
    137157
    138158# it was PSASTRO.OUTPUT
     
    141161my $fpaObjectsAlt = $fpaObjects;
    142162
    143 if ($stage =~ /skycal/) {
     163if ($stage eq 'skycal') {
    144164    #should be ok for skycal?
    145165    print "using $fpaObjects for $stage\n";
    146166}
    147 if ($stage =~/diff/) {
     167elsif ($stage eq 'diff') {
    148168    print "using $fpaObjects for $stage\n";
    149169}
    150 if ($stage =~/fullforce/)  {
     170elsif ($stage eq 'fullforce')  {
    151171    print "using $fpaObjects for $stage\n";
    152172}
    153173
    154 
    155 
    156 if ($stage =~ /cam/) {
     174if ($stage eq 'cam') {
    157175    # if it is cam stage we need to be careful when grabbing the filename.
    158176    # This breaks down into a few steps:
     
    197215}
    198216
    199 if (($stage =~/stack/ || $stage =~ /skycal/ || $stage =~/diff/ || $stage=~/fullforce/)) {
     217if (($stage eq 'stack') ||
     218    ($stage eq 'skycal') ||
     219    ($stage eq 'diff') ||
     220    ($stage eq 'fullforce')||
     221    ($stage eq 'fullforce_summary')) {
    200222    $fpaObjects =~ s/smf$/cmf/;
    201223    $fpaObjectsAlt =~ s/smf$/cmf/;
    202 
    203224}
    204225
     
    206227my $fpaObjects2;
    207228my $checkalt = 0;
    208 if ($stage =~/staticsky/) {
     229if ($stage eq 'staticsky') {
    209230    $checkalt = 1;
    210231    my $sources   = $ipprc->filename("PSPHOT.OUT.CMF.MEF", $stageroot); #this is mostly rigtht except the .cmf needs either
     
    239260        $fpaObjects = $fpaObjects1;
    240261    }
    241      
    242 
    243 }
     262}
     263
     264
     265#
     266# Step 3 Set up addtool/loadgalphot commands.
     267#
    244268
    245269my $traceDest  = $ipprc->filename("TRACE.EXP",          $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
     
    251275    $dvodbReal = $ipprc->convert_filename_absolute( $dvodbReal ) or &my_die("can't get path for dvodb", $add_id, $PS_EXIT_CONFIG_ERROR);
    252276}
     277
    253278my $dtime_addstar = 0;
    254279if (defined $dvodbReal) {
    255280    if ($minidvodb) {
    256         my $command = "addtool -listminidvodbrun ";
     281        my $command = "$addtool -listminidvodbrun ";
    257282        $command .= " -minidvodb_group $minidvodb_group" if defined $minidvodb_group;
    258283        $command .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name;
     
    285310    unless ($no_op) {
    286311            print $dvodbReal;
    287            
    288312            ## addstar can either save the full set of detections, or just
    289313            ## the image metadata, in the dvodb.  this is set in the
     
    311335            }           
    312336
    313             # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)
    314             my $command  = "$addstar -update"; # XXX optionally set -update?
    315             $command .= " -D CAMERA $camdir";
    316             $command .= " -D CATDIR $minidvodb_path";
    317             $command .= " -D ZERO_POINT_OPTION $zeroPointOption";
    318             $command .= " $realFile";
    319             $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference
    320             $command .= " -image" if $image_only;
    321             if ($stage =~ /staticsky/) {
    322                 $command .= " -accept-astrom -quick-airmass";
    323             }  #careful here - this matches staticsky and staticsky_multi
    324             if ($stage =~ /skycal/) {
    325                 $command .= " -quick-airmass";
    326             }  #careful here - this matches staticsky and staticsky_multi
    327             if ($stage =~ /diff/) {
    328                 $command .= " -accept-astrom";
     337            my $command;
     338
     339            if ($stage ne 'fullforce_summary') {
     340                # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)
     341                $command  = "$addstar -update"; # XXX optionally set -update?
     342                $command .= " -D CAMERA $camdir";
     343                $command .= " -D CATDIR $minidvodb_path";
     344                $command .= " -D ZERO_POINT_OPTION $zeroPointOption";
     345                $command .= " $realFile";
     346                $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference
     347                $command .= " -image" if $image_only;
     348                if ($stage =~ /staticsky/) {
     349                    $command .= " -accept-astrom -quick-airmass";
     350                }  #careful here - this matches staticsky and staticsky_multi
     351                if ($stage =~ /skycal/) {
     352                    $command .= " -quick-airmass";
     353                }  #careful here - this matches staticsky and staticsky_multi
     354                if ($stage =~ /diff/) {
     355                    $command .= " -accept-astrom";
     356                }
     357                if ($stage =~ /fullforce/) {
     358                    $command .= " -accept-astrom -xrad";
     359                }
    329360            }
    330             if ($stage =~ /fullforce/) {
    331                 $command .= " -accept-astrom -xrad";
     361            else { # Full force summary case
     362                # We need to know the filter to set up the photcode, as the summaries do not include that in the header.
     363                # We /could/ set up the addtool stuff to pass that in to the script when needed, but that would require adding
     364                # a lot of extra hooks and option handlers.  Therefore, call out to fftool, and get the filter that way, and
     365                # construct the correct photcode.
     366
     367                my $photcode = '';
     368                {
     369                    my $ff_command = "$fftool -dbname ${dbname} -summary -ff_id ${stage_id}";
     370                    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     371                        run(command => $command, verbose => $verbose);
     372                    unless ($success) {
     373                        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     374                        &my_die("Unable to fetch filter via fftool: $error_code", $add_id, $error_code);
     375                    }
     376                    my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or
     377                        &my_die("Unable to determine ff summary information.", $add_id, $error_code);
     378                    my $metadata = parse_md_list($MDlist);
     379                    my $ffSummary = $metadata->[0];
     380                    my $filter = $ffSummary->{filter};
     381                   
     382                    $filter =~ s/\.00000//;
     383                    $photcode = "GPC1.${filter}.ForcedWarp";
     384                }
     385
     386                $command =  "$loadgalphot -v ";
     387                $command .= " -D CAMERA $camdir ";
     388                $command .= " -D CATDIR $minidvodb_path ";
     389                $command .= " $realFile ";
     390                $command .= " -p $photcode ";
    332391            }
    333 
     392                   
    334393            my $mjd_addstar_start = DateTime->now->mjd;   # MJD of starting script
    335 
     394           
    336395            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    337396                run(command => $command, verbose => $verbose);
Note: See TracChangeset for help on using the changeset viewer.