IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 1, 2010, 3:09:47 PM (16 years ago)
Author:
Paul Price
Message:

Merging branches/haf_branches/ipp.20100512/ into trunk: addtool development to ingest sources into separate dvo catalogues and dvodb merging. (Committed by PAP for HAF)

Location:
trunk
Files:
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/ippScripts/scripts/addstar_run.pl

    r27718 r28181  
    3737}
    3838
    39 my ( $exp_tag, $add_id, $camera, $outroot, $camroot, $dbname, $reduction, $dvodb, $image_only, $verbose, $no_update,
     39my ( $exp_tag, $add_id, $camera, $outroot, $camroot, $dbname, $reduction, $dvodb, $minidvodb, $minidvodb_name, $minidvodb_group, $image_only, $verbose, $no_update,
    4040     $no_op, $redirect, $save_temps);
    4141GetOptions(
     
    4848    'reduction=s'       => \$reduction, # Reduction class
    4949    'dvodb|w=s'         => \$dvodb,  # output DVO database
     50    'minidvodb'         => \$minidvodb,  # use minidvodb?
     51    'minidvodb_name|w=s'=> \$minidvodb_name,  # miniDVO database name
     52    'minidvodb_group|w=s' => \$minidvodb_group, # miniDVO database group
    5053    'image-only'        => \$image_only,   # Print to stdout
    5154    'verbose'           => \$verbose,   # Print to stdout
     
    5861pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    5962pod2usage(
    60           -msg => "Required options: --exp_tag --add_id --camera --outroot",
     63          -msg => "Required options: --exp_tag --add_id --camera --outroot --dvodb --camroot",
    6164          -exitval => 3,
    6265          ) unless
     
    6568    defined $outroot and
    6669    defined $camroot and
     70    defined $dvodb and
    6771    defined $camera;
    68 
     72if ($minidvodb && !defined($minidvodb_group)) {
     73                my_die( "missing minidvodb_group", $add_id, 3 );
     74            }
    6975my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $add_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    7076
     
    103109my $dtime_addstar = 0;
    104110
     111if (defined $dvodbReal) {
     112        if ($minidvodb) {
     113           
     114            if (!defined($minidvodb_name)) {
     115                #take the active one, if it's not defined on the command line
     116                #reverts would have this already set, for example.
     117                my $command = "addtool -listminidvodbrun ";
     118                $command .= " -minidvodb_group $minidvodb_group" if defined $minidvodb_group;
     119                $command .= " -state 'active' -limit 1";
     120                $command .= " -dbname $dbname" if defined $dbname;
     121                print $command;
     122                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     123                    run(command => $command, verbose => $verbose);
     124                &my_die( "Unable to get active minidvodb_name", $add_id, $PS_EXIT_SYS_ERROR) unless $success;
     125                my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     126                    &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR);
     127
     128                my $components = parse_md_list($metadata) or
     129                    &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR);
     130                my $comp = $$components[0];
     131                $minidvodb_name = $comp->{minidvodb_name};
     132       
     133                if (!defined($minidvodb_name)) {
     134                    &my_die("Unable to parse minidvodb_name", $add_id, $PS_EXIT_PROG_ERROR);
     135                }
     136               
     137            }
     138            # tack on the minidvodb part to the db.
     139            $dvodbReal = $dvodbReal . '/' . $minidvodb_name . '/';
     140           
     141        }
    105142unless ($no_op) {
    106     if (defined $dvodbReal) {
     143            print $dvodbReal;
    107144
    108145        ## addstar can either save the full set of detections, or just
     
    142179$fpaCommand .= " -path_base $outroot";
    143180$fpaCommand .= " -dtime_addstar $dtime_addstar";
     181$fpaCommand .= " -dvodb_path $dvodbReal";
    144182$fpaCommand .= " -dbname $dbname" if defined $dbname;
    145 
     183print $fpaCommand;
    146184# Add the result into the database
    147185unless ($no_update) {
     
    171209        $command .= " -addprocessedexp";
    172210        $command .= " -fault $exit_code";
     211        $command .= " -dvodb_path $dvodbReal" if defined $dvodbReal;
    173212        $command .= " -path_base $outroot" if defined $outroot;
    174213        $command .= (" -dtime_addstar " . ((DateTime->now->mjd - $mjd_start) * 86400));
  • trunk/ippScripts/scripts/minidvodb_merge.pl

    r28180 r28181  
    8787unless ($no_op) {
    8888    if (defined $mergedvodbReal) {
    89         {
     89        {
    9090            my $command  = "$addstar -resort";
    9191            $command .= " -D CAMERA $camera";
     
    101101            }
    102102            $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start);  $dtime_resort = $dtime_addstar;
    103             # MJD of starting script
     103            # MJD of starting script
    104104            print "addstar -resort time $dtime_addstar\n";
    105105        }
     
    123123            print "relphot time $dtime_relphot\n";
    124124        }
    125        
    126         {
    127 
    128             my $mdcParser = PS::IPP::Metadata::Config->new;
    129            
    130 
    131             my $command = "$addtool -listminidvodbrun -state mergedsdfsad -minidvodb_group " . $minidvodb_group;
    132             $command .= " -dbname $dbname" if defined $dbname;
    133 
    134            
    135 
    136             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     125
     126        my $this_is_the_first;
     127        {
     128
     129            my $mdcParser = PS::IPP::Metadata::Config->new;
     130
     131            my $command = "$addtool -listminidvodbrun -state mergedsdfsad -minidvodb_group " . $minidvodb_group;
     132            $command .= " -dbname $dbname" if defined $dbname;
     133
     134            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    137135                    run(command => $command, verbose => $verbose);
    138             &my_die( "Unable to get list of minidvodbruns", $minidvodb_id, $PS_EXIT_SYS_ERROR) unless $success;
    139             my $this_is_the_first;
    140             if (scalar @$stdout_buf == 0 ) { #it lists nothing if it is the first
    141                 $this_is_the_first =1;
    142             } else {
    143                  my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     136            &my_die( "Unable to get list of minidvodbruns", $minidvodb_id, $PS_EXIT_SYS_ERROR) unless $success;
     137            if (scalar @$stdout_buf == 0 ) { #it lists nothing if it is the first
     138                $this_is_the_first =1;
     139            } else {
     140                my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    144141                    &my_die("Unable to parse metadata config", $minidvodb_id, $PS_EXIT_PROG_ERROR);
    145                 #this fails if there is nothing listed. I checked.
     142                #this fails if there is nothing listed. I checked.
    146143                my $components = parse_md_list($metadata) or
    147144                    &my_die("Unable to parse metadata list", $minidvodb_id, $PS_EXIT_PROG_ERROR);
    148145                my $comp = $$components[0];
    149            my  $minidvodb_name = $comp->{minidvodb_name};
    150        
     146                my  $minidvodb_name = $comp->{minidvodb_name};
     147
    151148                if (!defined($minidvodb_name)) {
    152149                    &my_die("Unable to parse minidvodb_name", $minidvodb_id, $PS_EXIT_PROG_ERROR);
    153150                } #but just to make sure, have it grab a minidvodb_name, to make sure it's not junk.
    154                  $this_is_the_first = 0;
    155             }
    156 
    157             my $merge_command;
    158             if ($this_is_the_first) {
    159                
    160                 $merge_command = "cp -rp $minidvodb $mergedvodb"
    161 
    162             } else {
    163 
    164                 $merge_command = "$dvomerge $minidvodb into $mergedvodb"
    165             }
    166 
    167 
    168 
    169             system ($merge_command);
    170 
    171             my ( $success2, $error_code2, $full_buf2, $stdout_buf2, $stderr_buf2 ) =
    172                 run(command => $merge_command, verbose => $verbose);
    173         unless ($success2) {
    174             $error_code2 = (($error_code2 >> 8) or $PS_EXIT_PROG_ERROR);
    175             &my_die("Unable to merge: $error_code", $mergedvodb, $error_code2);
    176         }
    177 
    178                    
    179             $dtime_merge = 86400.0*(DateTime->now->mjd - $mjd_relphot_start);   # MJD of starting script
     151                $this_is_the_first = 0;
     152            }
     153        }
     154
     155        {
     156            my $merge_command;
     157            if ($this_is_the_first) {
     158                $merge_command = "cp -rp $minidvodb $mergedvodb"
     159            } else {
     160                $merge_command = "$dvomerge $minidvodb into $mergedvodb"
     161            }
     162
     163            my $mjd_merge_start = DateTime->now->mjd;   # MJD of starting script
     164
     165            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     166                run(command => $merge_command, verbose => $verbose);
     167            unless ($success) {
     168                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     169                &my_die("Unable to merge: $error_code", $mergedvodb, $error_code);
     170            }
     171
     172            $dtime_merge = 86400.0*(DateTime->now->mjd - $mjd_merge_start);   # MJD of starting script
    180173            print "merge time $dtime_merge\n";
    181            
    182         }
    183        
    184 
    185         {
    186         my $command = "addtool -minidvodb_id $minidvodb_id";
    187         $command .= " -addminidvodbprocessed";
    188         $command .= " -mergedvodb_path $mergedvodbReal" if defined $mergedvodbReal;
    189         $command .= " -minidvodb_group $minidvodb_group";
    190         $command .= " -dtime_relphot $dtime_relphot"  if defined $dtime_relphot;
    191         $command .= " -dtime_relphot $dtime_resort" if defined $dtime_resort;
    192         $command .= " -dtime_relphot $dtime_merge" if defined $dtime_merge;
    193         $command .= " -dbname $dbname" if defined $dbname;
    194     #print $command;
    195         system ($command);
    196 
    197         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    198             run(command => $command, verbose => $verbose);
    199         unless ($success) {
    200             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    201             &my_die("Unable to add to minidvodbprocessed: $error_code", $mergedvodb, $error_code);
    202         }
    203 
    204         }
     174        }
     175
     176
     177        {
     178            my $command = "addtool -minidvodb_id $minidvodb_id";
     179            $command .= " -addminidvodbprocessed";
     180            $command .= " -mergedvodb_path $mergedvodbReal" if defined $mergedvodbReal;
     181            $command .= " -minidvodb_group $minidvodb_group";
     182            $command .= " -dtime_relphot $dtime_relphot"  if defined $dtime_relphot;
     183            $command .= " -dtime_relphot $dtime_resort" if defined $dtime_resort;
     184            $command .= " -dtime_relphot $dtime_merge" if defined $dtime_merge;
     185            $command .= " -dbname $dbname" if defined $dbname;
     186            #print $command;
     187
     188            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     189                run(command => $command, verbose => $verbose);
     190            unless ($success) {
     191                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     192                &my_die("Unable to add to minidvodbprocessed: $error_code", $mergedvodb, $error_code);
     193            }
     194        }
    205195
    206196    } else {
     
    217207{
    218208    my $msg = shift; # Warning message on die
    219     my $minidbvodb_id = shift; 
     209    my $minidbvodb_id = shift;
    220210    my $exit_code = shift; # Exit code to add
    221211
     
    223213
    224214if (defined $minidvodb_id ) {
    225    
     215
    226216    my $command = "addtool -minidvodb_id $minidvodb_id";
    227217    $command .= " -addminidvodbprocessed";
    228218        $command .= " -fault $exit_code";
    229         $command .= " -mergedvodb_path $mergedvodbReal" if defined $mergedvodbReal;
    230         $command .= " -minidvodb_group $minidvodb_group";
     219        $command .= " -mergedvodb_path $mergedvodbReal" if defined $mergedvodbReal;
     220        $command .= " -minidvodb_group $minidvodb_group";
    231221        $command .= " -dtime_relphot $dtime_relphot" if defined $dtime_relphot;
    232222        $command .= " -dtime_relphot $dtime_resort" if defined $dtime_resort;
    233223        $command .= " -dtime_relphot $dtime_merge" if defined $dtime_merge;
    234224        $command .= " -dbname $dbname" if defined $dbname;
    235    
    236    
     225
     226
    237227
    238228    #print $command;
Note: See TracChangeset for help on using the changeset viewer.