IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33022


Ignore:
Timestamp:
Dec 24, 2011, 9:44:18 AM (15 years ago)
Author:
heather
Message:

final changes to get addstar changes working.

Location:
branches/haf_add201112
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/haf_add201112/ippScripts/scripts/addstar_run.pl

    r33021 r33022  
    3030my $missing_tools;
    3131my $addtool = can_run('addtool') or (warn "Can't find addtool" and $missing_tools = 1);
     32my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);
    3233my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    3334my $addstar = can_run('addstar') or (warn "Can't find addstar" and $missing_tools = 1);
     
    3738}
    3839my $minidvodb_path;
    39 my ( $add_id, $camera, $stage, $multi_num, $outroot, $stageroot, $dbname, $reduction, $dvodb, $minidvodb, $minidvodb_name, $minidvodb_group, $image_only, $verbose, $no_update,
     40my ( $add_id, $camera, $stage, $stage_id, $multi_num, $outroot, $stageroot, $dbname, $reduction, $dvodb, $minidvodb, $minidvodb_name, $minidvodb_group, $image_only, $verbose, $no_update,
    4041     $no_op, $redirect, $save_temps);
    4142GetOptions(
     
    4344    'camera|c=s'        => \$camera, # Camera
    4445    'stage|s=s'        => \$stage, # Camera
     46    'stage_id|w=s'   => \$stage_id,
    4547    'multi_num|w=s'    => \$multi_num, # the number for a staticskymulti (for finding cmf)
    4648    'dbname|d=s'        => \$dbname, # Database name
     
    7173    defined $dvodb and
    7274    defined $camera;
     75if ($stage =~ /cam/ && !defined $stage_id) {
     76    my_die("cam stage requires -stage_id", $add_id, 3);
     77
     78}
    7379if ($minidvodb && !defined($minidvodb_group)) {
    7480                my_die( "missing minidvodb_group", $add_id, 3 );
     
    109115# it was PSASTRO.OUTPUT
    110116
    111 
     117my $fpaObjects;
    112118if ($stage =~ /cam/) {
    113119    # if it is cam stage we need to be careful when grabbing the filename.
    114120    # This breaks down into a few steps:
    115 
     121   
    116122    #get info about the cam_id
    117123    my $magicked;
    118124    {
    119        
    120         my $mdcParser = PS::IPP::Metadata::Config->new;
     125        my $mdcParser = PS::IPP::Metadata::Config->new;
    121126        my $command = "$camtool -processedexp -cam_id " . $stage_id;
    122127        $command .= " -dbname $dbname" if defined $dbname;
     
    125130        &my_die( "Unable to get info on camRun", $add_id, $PS_EXIT_SYS_ERROR) unless $success;
    126131        if (scalar @$stdout_buf == 0 ) { #it lists nothing if it is the first
    127            &my_die( "empty camRun", $add_id, $PS_EXIT_SYS_ERROR
    128             print "listing nothing\n";
    129         } else {
    130             my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    131                 &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR);
    132             #this fails if there is nothing listed. I checked.
    133             my $components = parse_md_list($metadata) or
    134                 &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR);
    135             my $comp = $$components[0];
    136             my  $mparsed = $comp->{magicked};
    137            
    138             if (!defined($mparsed)) {
    139                 &my_die("Unable to parse magicked", $add_id, $PS_EXIT_PROG_ERROR);
    140             } #but just to make sure, have it grab a minidvodb_name, to make sure it's not junk.
    141             print "found a value for magicked:$mparsed\n";
    142             $magicked = $mparsed;
    143         }
    144 
    145 
    146 
    147     #is this cam_id magicked or not?
    148     if ($magicked) {
    149         my $fpaObjects = $ipprc->destreak_filename("PSASTRO.OUTPUT",     $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
    150     } else {
    151 
    152         my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT",     $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
    153     }
    154 
    155 
     132            &my_die( "empty camRun", $add_id, $PS_EXIT_SYS_ERROR);
     133            print "listing nothing\n";
     134        } else {
     135            my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     136                &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR);
     137            #this fails if there is nothing listed. I checked.
     138            my $components = parse_md_list($metadata) or
     139                &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR);
     140            my $comp = $$components[0];
     141            my  $mparsed = $comp->{magicked};
     142           
     143            if (!defined($mparsed)) {
     144                &my_die("Unable to parse magicked", $add_id, $PS_EXIT_PROG_ERROR);
     145            } #but just to make sure, have it grab a minidvodb_name, to make sure it's not junk.
     146            print "found a value for magicked:$mparsed\n";
     147            $magicked = $mparsed;
     148        }
     149       
     150        #is this cam_id magicked or not?
     151        if ($magicked) {
     152            $fpaObjects = $ipprc->destreak_filename("PSASTRO.OUTPUT",     $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
     153            print "cam_id is magicked, using $fpaObjects for the cam smf\n";
     154        } else {
     155           
     156            $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT",     $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
     157            print "cam_id is NOT magicked, using $fpaObjects for the cam smf\n";
     158        }
     159    }
    156160} else {
    157 
    158     my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT",     $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
     161    # for non cam stages, grabe the file name like this:
     162    $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT",     $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
    159163}
    160164if (($stage =~/staticsky/) || ($stage =~/stack/)) {
    161165    $fpaObjects =~ s/smf$/cmf/;
    162    
    163 }
    164 
     166}
    165167if ($stage =~/staticsky_multi/) {
    166168    $fpaObjects =~ s/smf$/cmf/; #this should do nothing because it was already modded above
     
    168170    my $nice_num = sprintf ("%03d", $multi_num);
    169171    $fpaObjects =~ s/cmf$/$nice_num.cmf/;  #this make it look for .001.cmf, etc
    170  
    171172}
    172173
    173174my $traceDest  = $ipprc->filename("TRACE.EXP",          $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
    174 
     175       
    175176# convert supplied DVO database name to UNIX filename
    176177my $dvodbReal;
     
    179180    $dvodbReal = $ipprc->convert_filename_absolute( $dvodbReal ) or &my_die("can't get path for dvodb", $add_id, $PS_EXIT_CONFIG_ERROR);
    180181}
    181 
    182 
    183 
    184 
    185182my $dtime_addstar = 0;
    186 
    187183if (defined $dvodbReal) {
    188         if ($minidvodb) {
    189 
    190             #if (!defined($minidvodb_name)) {
    191                 #take the active one, if it's not defined on the command line
    192                 #reverts would have this already set, for example.
    193                 my $command = "addtool -listminidvodbrun ";
    194                 $command .= " -minidvodb_group $minidvodb_group" if defined $minidvodb_group;
    195                 $command .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name;
    196                 $command .= " -state 'active' -limit 1";
    197                 $command .= " -dbname $dbname" if defined $dbname;
    198                 print $command;
    199                 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    200                     run(command => $command, verbose => $verbose);
    201                 &my_die( "Unable to get active minidvodb_name", $add_id, $PS_EXIT_SYS_ERROR) unless $success;
    202                 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    203                     &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR);
    204 
    205                 my $components = parse_md_list($metadata) or
    206                     &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR);
    207                 my $comp = $$components[0];
    208                 $minidvodb_path = $comp->{minidvodb_path};
    209                 $minidvodb_name = $comp->{minidvodb_name};
    210 
    211                 if (!defined($minidvodb_path)) {
    212                     &my_die("Unable to parse minidvodb_path", $add_id, $PS_EXIT_PROG_ERROR);
    213                 }
    214                 if (!defined($minidvodb_name)) {
    215                     &my_die("Unable to parse minidvodb_name", $add_id, $PS_EXIT_PROG_ERROR);
    216                 }
    217             #}
    218             # tack on the minidvodb part to the db.
    219 #           $dvodbReal = $dvodbReal . '/' . $minidvodb_name . '/';
    220 #we don't need this now that I fixed the paths
    221 
    222         }
    223         else {
    224 
    225             $minidvodb_path = $dvodbReal;
    226         }
    227 
    228 unless ($no_op) {
     184    if ($minidvodb) {
     185        my $command = "addtool -listminidvodbrun ";
     186        $command .= " -minidvodb_group $minidvodb_group" if defined $minidvodb_group;
     187        $command .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name;
     188        $command .= " -state 'active' -limit 1";
     189        $command .= " -dbname $dbname" if defined $dbname;
     190        print $command;
     191        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     192            run(command => $command, verbose => $verbose);
     193        &my_die( "Unable to get active minidvodb_name", $add_id, $PS_EXIT_SYS_ERROR) unless $success;
     194        my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     195            &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR);
     196
     197        my $components = parse_md_list($metadata) or
     198            &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR);
     199        my $comp = $$components[0];
     200        $minidvodb_path = $comp->{minidvodb_path};
     201        $minidvodb_name = $comp->{minidvodb_name};
     202       
     203        if (!defined($minidvodb_path)) {
     204            &my_die("Unable to parse minidvodb_path", $add_id, $PS_EXIT_PROG_ERROR);
     205        }
     206        if (!defined($minidvodb_name)) {
     207            &my_die("Unable to parse minidvodb_name", $add_id, $PS_EXIT_PROG_ERROR);
     208        }
     209    }
     210    else {
     211        $minidvodb_path = $dvodbReal;
     212    }
     213   
     214    unless ($no_op) {
    229215            print $dvodbReal;
    230 
    231         ## addstar can either save the full set of detections, or just
    232         ## the image metadata, in the dvodb.  this is set in the
    233         ## database table addRun
    234 
    235         # addstar requires the user to have a valid .ptolemyrc which
    236         # in turn points at ippconfig/dvo.site
    237 
    238         # get the names for the camera and the real input file
    239         my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar
    240         my $realFile = $ipprc->file_resolve($fpaObjects) or &my_die("Unable to resolve $fpaObjects", $add_id, $PS_EXIT_SYS_ERROR);
    241 
    242         # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)
    243         my $command  = "$addstar -update"; # XXX optionally set -update?
    244         $command .= " -D CAMERA $camdir";
    245         $command .= " -D CATDIR $minidvodb_path";
    246         $command .= " $realFile";
    247         $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference
     216           
     217            ## addstar can either save the full set of detections, or just
     218            ## the image metadata, in the dvodb.  this is set in the
     219            ## database table addRun
     220
     221            # addstar requires the user to have a valid .ptolemyrc which
     222            # in turn points at ippconfig/dvo.site
     223
     224            # get the names for the camera and the real input file
     225            my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar
     226            my $realFile = $ipprc->file_resolve($fpaObjects) or &my_die("Unable to resolve $fpaObjects", $add_id, $PS_EXIT_SYS_ERROR);
     227           
     228            # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)
     229            my $command  = "$addstar -update"; # XXX optionally set -update?
     230            $command .= " -D CAMERA $camdir";
     231            $command .= " -D CATDIR $minidvodb_path";
     232            $command .= " $realFile";
     233            $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference
    248234            $command .= " -image" if $image_only;
    249235            if ($stage =~ /staticsky/) {
    250236                $command .= " -accept-astrom ";
    251237            }  #careful here - this matches staticsky and staticsky_multi
    252         my $mjd_addstar_start = DateTime->now->mjd;   # MJD of starting script
    253 
    254         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    255             run(command => $command, verbose => $verbose);
    256         unless ($success) {
    257             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    258             &my_die("Unable to perform addstar: $error_code", $add_id, $error_code);
    259         }
    260         $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start);   # MJD of starting script
     238            my $mjd_addstar_start = DateTime->now->mjd;   # MJD of starting script
     239
     240            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     241                run(command => $command, verbose => $verbose);
     242            unless ($success) {
     243                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     244                &my_die("Unable to perform addstar: $error_code", $add_id, $error_code);
     245            }
     246            $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start);   # MJD of starting script
    261247    }
    262248}
  • branches/haf_add201112/ippTasks/addstar.pro

    r32832 r33022  
    318318    book getword addPendingExp $pageName stage_extra1 -var STAGE_EXTRA1
    319319    book getword addPendingExp $pageName stageroot -var STAGEROOT
    320     book getword addPendingExp $pageName stage -var STAGE 
     320    book getword addPendingExp $pageName stage -var STAGE
     321    book getword addPendingExp $pageName stage_id -var STAGE_ID
    321322    book getword addPendingExp $pageName workdir -var WORKDIR_TEMPLATE
    322323    book getword addPendingExp $pageName reduction -var REDUCTION
     
    367368    if ("$STAGE" == "staticsky_multi")
    368369      $run = $run --multi_num $STAGE_EXTRA1
     370    end
     371    if ("$STAGE" == "cam")
     372      $run = $run --stage_id $STAGE_ID
    369373    end
    370374    if ("$IMAGE_ONLY" == "T")
Note: See TracChangeset for help on using the changeset viewer.