IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 27, 2011, 3:09:17 PM (14 years ago)
Author:
heather
Message:

crap. I don't know why it thinks some of these are modified, but diffing them
against a fresh checkout of the trunk shows no differences.

These are the merge of addstar changes into the trunk. This adds tables,
breaking apart minidvodbRun into 2 parts (building/relphot/addstar) and
(verify/merging), which will make it easier to rebuild dvodbs in the
future. There's some debugging of various tasks here (addstar.revert, for
example), and a lot of cleanup of code.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/ippScripts/scripts/addstar_run.pl

    r32832 r33030  
    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 $stage_extra1;
     41my ( $add_id, $camera, $stage, $stage_id, $multi_num, $outroot, $stageroot, $dbname, $reduction, $dvodb, $minidvodb, $minidvodb_name, $minidvodb_group, $image_only, $verbose, $no_update,
    4042     $no_op, $redirect, $save_temps);
    4143GetOptions(
     
    4345    'camera|c=s'        => \$camera, # Camera
    4446    'stage|s=s'        => \$stage, # Camera
     47    'stage_id|w=s'   => \$stage_id,
    4548    'multi_num|w=s'    => \$multi_num, # the number for a staticskymulti (for finding cmf)
    4649    'dbname|d=s'        => \$dbname, # Database name
     
    7174    defined $dvodb and
    7275    defined $camera;
     76if ($stage =~ /cam/ && !defined $stage_id) {
     77    my_die("cam stage requires -stage_id", $add_id, 3);
     78
     79}
    7380if ($minidvodb && !defined($minidvodb_group)) {
    7481                my_die( "missing minidvodb_group", $add_id, 3 );
     
    108115
    109116# it was PSASTRO.OUTPUT
    110 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT",     $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
    111 
     117
     118my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $stageroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
     119
     120if ($stage =~ /cam/) {
     121    # if it is cam stage we need to be careful when grabbing the filename.
     122    # This breaks down into a few steps:
     123   
     124    #get info about the cam_id
     125    my $magicked;
     126    {
     127        my $mdcParser = PS::IPP::Metadata::Config->new;
     128        my $command = "$camtool -processedexp -cam_id " . $stage_id;
     129        $command .= " -dbname $dbname" if defined $dbname;
     130        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     131            run(command => $command, verbose => $verbose);
     132        &my_die( "Unable to get info on camRun", $add_id, $PS_EXIT_SYS_ERROR) unless $success;
     133        if (scalar @$stdout_buf == 0 ) { #it lists nothing if it is the first
     134            &my_die( "empty camRun", $add_id, $PS_EXIT_SYS_ERROR);
     135            print "listing nothing\n";
     136        } else {
     137            my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     138                &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR);
     139            #this fails if there is nothing listed. I checked.
     140            my $components = parse_md_list($metadata) or
     141                &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR);
     142            my $comp = $$components[0];
     143            my  $mparsed = $comp->{magicked};
     144           
     145            if (!defined($mparsed)) {
     146                &my_die("Unable to parse magicked", $add_id, $PS_EXIT_PROG_ERROR);
     147            } #but just to make sure, have it grab a minidvodb_name, to make sure it's not junk.
     148            print "found a value for magicked:$mparsed\n";
     149            $magicked = $mparsed;
     150        }
     151       
     152        #is this cam_id magicked or not?
     153        if ($magicked) {
     154            $stage_extra1 = $magicked;
     155            $fpaObjects = $ipprc->destreaked_filename("$fpaObjects") or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
     156            print "cam_id is magicked, using $fpaObjects for the cam smf\n";
     157        } else {
     158            print "cam_id is NOT magicked, using $fpaObjects for the cam smf\n";
     159        }
     160    }
     161}
    112162if (($stage =~/staticsky/) || ($stage =~/stack/)) {
    113163    $fpaObjects =~ s/smf$/cmf/;
    114    
    115 }
    116 
     164}
    117165if ($stage =~/staticsky_multi/) {
    118166    $fpaObjects =~ s/smf$/cmf/; #this should do nothing because it was already modded above
     
    120168    my $nice_num = sprintf ("%03d", $multi_num);
    121169    $fpaObjects =~ s/cmf$/$nice_num.cmf/;  #this make it look for .001.cmf, etc
    122  
    123170}
    124171
    125172my $traceDest  = $ipprc->filename("TRACE.EXP",          $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR);
    126 
     173       
    127174# convert supplied DVO database name to UNIX filename
    128175my $dvodbReal;
     
    131178    $dvodbReal = $ipprc->convert_filename_absolute( $dvodbReal ) or &my_die("can't get path for dvodb", $add_id, $PS_EXIT_CONFIG_ERROR);
    132179}
    133 
    134 
    135 
    136 
    137180my $dtime_addstar = 0;
    138 
    139181if (defined $dvodbReal) {
    140         if ($minidvodb) {
    141 
    142             #if (!defined($minidvodb_name)) {
    143                 #take the active one, if it's not defined on the command line
    144                 #reverts would have this already set, for example.
    145                 my $command = "addtool -listminidvodbrun ";
    146                 $command .= " -minidvodb_group $minidvodb_group" if defined $minidvodb_group;
    147                 $command .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name;
    148                 $command .= " -state 'active' -limit 1";
    149                 $command .= " -dbname $dbname" if defined $dbname;
    150                 print $command;
    151                 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    152                     run(command => $command, verbose => $verbose);
    153                 &my_die( "Unable to get active minidvodb_name", $add_id, $PS_EXIT_SYS_ERROR) unless $success;
    154                 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    155                     &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR);
    156 
    157                 my $components = parse_md_list($metadata) or
    158                     &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR);
    159                 my $comp = $$components[0];
    160                 $minidvodb_path = $comp->{minidvodb_path};
    161                 $minidvodb_name = $comp->{minidvodb_name};
    162 
    163                 if (!defined($minidvodb_path)) {
    164                     &my_die("Unable to parse minidvodb_path", $add_id, $PS_EXIT_PROG_ERROR);
    165                 }
    166                 if (!defined($minidvodb_name)) {
    167                     &my_die("Unable to parse minidvodb_name", $add_id, $PS_EXIT_PROG_ERROR);
    168                 }
    169             #}
    170             # tack on the minidvodb part to the db.
    171 #           $dvodbReal = $dvodbReal . '/' . $minidvodb_name . '/';
    172 #we don't need this now that I fixed the paths
    173 
    174         }
    175         else {
    176 
    177             $minidvodb_path = $dvodbReal;
    178         }
    179 
    180 unless ($no_op) {
     182    if ($minidvodb) {
     183        my $command = "addtool -listminidvodbrun ";
     184        $command .= " -minidvodb_group $minidvodb_group" if defined $minidvodb_group;
     185        $command .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name;
     186        $command .= " -state 'active' -limit 1";
     187        $command .= " -dbname $dbname" if defined $dbname;
     188        print $command;
     189        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     190            run(command => $command, verbose => $verbose);
     191        &my_die( "Unable to get active minidvodb_name", $add_id, $PS_EXIT_SYS_ERROR) unless $success;
     192        my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     193            &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR);
     194
     195        my $components = parse_md_list($metadata) or
     196            &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR);
     197        my $comp = $$components[0];
     198        $minidvodb_path = $comp->{minidvodb_path};
     199        $minidvodb_name = $comp->{minidvodb_name};
     200       
     201        if (!defined($minidvodb_path)) {
     202            &my_die("Unable to parse minidvodb_path", $add_id, $PS_EXIT_PROG_ERROR);
     203        }
     204        if (!defined($minidvodb_name)) {
     205            &my_die("Unable to parse minidvodb_name", $add_id, $PS_EXIT_PROG_ERROR);
     206        }
     207    }
     208    else {
     209        $minidvodb_path = $dvodbReal;
     210    }
     211   
     212    unless ($no_op) {
    181213            print $dvodbReal;
    182 
    183         ## addstar can either save the full set of detections, or just
    184         ## the image metadata, in the dvodb.  this is set in the
    185         ## database table addRun
    186 
    187         # addstar requires the user to have a valid .ptolemyrc which
    188         # in turn points at ippconfig/dvo.site
    189 
    190         # get the names for the camera and the real input file
    191         my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar
    192         my $realFile = $ipprc->file_resolve($fpaObjects) or &my_die("Unable to resolve $fpaObjects", $add_id, $PS_EXIT_SYS_ERROR);
    193 
    194         # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)
    195         my $command  = "$addstar -update"; # XXX optionally set -update?
    196         $command .= " -D CAMERA $camdir";
    197         $command .= " -D CATDIR $minidvodb_path";
    198         $command .= " $realFile";
    199         $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference
     214           
     215            ## addstar can either save the full set of detections, or just
     216            ## the image metadata, in the dvodb.  this is set in the
     217            ## database table addRun
     218
     219            # addstar requires the user to have a valid .ptolemyrc which
     220            # in turn points at ippconfig/dvo.site
     221
     222            # get the names for the camera and the real input file
     223            my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar
     224            my $realFile = $ipprc->file_resolve($fpaObjects) or &my_die("Unable to resolve $fpaObjects", $add_id, $PS_EXIT_SYS_ERROR);
     225           
     226            # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)
     227            my $command  = "$addstar -update"; # XXX optionally set -update?
     228            $command .= " -D CAMERA $camdir";
     229            $command .= " -D CATDIR $minidvodb_path";
     230            $command .= " $realFile";
     231            $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference
    200232            $command .= " -image" if $image_only;
    201233            if ($stage =~ /staticsky/) {
    202234                $command .= " -accept-astrom ";
    203235            }  #careful here - this matches staticsky and staticsky_multi
    204         my $mjd_addstar_start = DateTime->now->mjd;   # MJD of starting script
    205 
    206         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    207             run(command => $command, verbose => $verbose);
    208         unless ($success) {
    209             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    210             &my_die("Unable to perform addstar: $error_code", $add_id, $error_code);
    211         }
    212         $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start);   # MJD of starting script
     236            my $mjd_addstar_start = DateTime->now->mjd;   # MJD of starting script
     237
     238            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     239                run(command => $command, verbose => $verbose);
     240            unless ($success) {
     241                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     242                &my_die("Unable to perform addstar: $error_code", $add_id, $error_code);
     243            }
     244            $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start);   # MJD of starting script
    213245    }
    214246}
     
    221253$fpaCommand .= " -dvodb_path $minidvodb_path" if defined $minidvodb_path;
    222254$fpaCommand .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name;
     255$fpaCommand .= " -stage_extra1" if defined $stage_extra1;
    223256$fpaCommand .= " -dbname $dbname" if defined $dbname;
    224257print $fpaCommand;
     
    253286        $command .= " -path_base $outroot" if defined $outroot;
    254287        $command .= (" -dtime_addstar " . ((DateTime->now->mjd - $mjd_start) * 86400));
    255         $fpaCommand .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name;
     288   #     $command .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name; don't think we want it recorded (not sure)
     289        $command .= " -stage_extra1 $stage_extra1" if defined $stage_extra1;
    256290        $command .= " -dbname $dbname" if defined $dbname;
     291        print $command;
    257292        system ($command);
    258293    }
Note: See TracChangeset for help on using the changeset viewer.