Changeset 19932 for trunk/ippScripts/scripts/fake_imfile.pl
- Timestamp:
- Oct 6, 2008, 2:03:10 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/fake_imfile.pl (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/fake_imfile.pl
r18562 r19932 2 2 3 3 ## this script is run on every imfile to perform the fake source 4 ## analysis and the forced photometry analysis. 4 ## analysis and the forced photometry analysis. 5 5 6 6 ## For the fake source analysis, we load the image, inject a number of … … 12 12 13 13 ## For the forced photometry, we need to use the measured astrometry 14 ## to select the desired locations in pixel coord. 14 ## to select the desired locations in pixel coord. 15 15 16 16 # XXX : seeing needs to be determined from the input PSF (not currently done in ppSim) … … 27 27 print "Starting script $0 on $host\n\n"; 28 28 29 use DateTime; 30 my $mjd_start = DateTime->now->mjd; # MJD of starting script 31 29 32 use vars qw( $VERSION ); 30 33 $VERSION = '0.01'; … … 41 44 42 45 # Parse the command-line arguments 43 my ( $exp_id, $fake_id, $class_id, $chiproot, $camroot, $camera, $outroot, 46 my ( $exp_id, $fake_id, $class_id, $chiproot, $camroot, $camera, $outroot, 44 47 $dbname, $reduction, $verbose, $no_update, $no_op, $redirect ); 45 48 GetOptions( 46 'exp_id=s' => \$exp_id, # Exposure identifier47 'fake_id=s' => \$fake_id, # Chiptool identifier48 'class_id=s' => \$class_id, # Class identifier49 'chiproot=s' => \$chiproot, # Input Chip files (root)50 'camroot=s' => \$camroot, # Input Camera files (root)51 'camera|c=s' => \$camera,# Camera52 'outroot|w=s' => \$outroot, # output file base name53 'dbname|d=s' => \$dbname, # Database name54 'reduction=s' => \$reduction, # Reduction class55 'verbose' => \$verbose, # Print to stdout56 'no-update' => \$no_update, # Don't update the database?57 'no-op' => \$no_op,# Don't do any operations?49 'exp_id=s' => \$exp_id, # Exposure identifier 50 'fake_id=s' => \$fake_id, # Chiptool identifier 51 'class_id=s' => \$class_id, # Class identifier 52 'chiproot=s' => \$chiproot, # Input Chip files (root) 53 'camroot=s' => \$camroot, # Input Camera files (root) 54 'camera|c=s' => \$camera, # Camera 55 'outroot|w=s' => \$outroot, # output file base name 56 'dbname|d=s' => \$dbname, # Database name 57 'reduction=s' => \$reduction, # Reduction class 58 'verbose' => \$verbose, # Print to stdout 59 'no-update' => \$no_update, # Don't update the database? 60 'no-op' => \$no_op, # Don't do any operations? 58 61 'redirect-output' => \$redirect, 59 62 ) or pod2usage( 2 ); … … 61 64 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 62 65 pod2usage( -msg => "Required options: --exp_id --fake_id --class_id --chiproot --camroot --camera --outroot", 63 -exitval => 3) unless66 -exitval => 3) unless 64 67 defined $exp_id and 65 68 defined $fake_id and … … 104 107 } 105 108 106 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files109 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 107 110 108 111 # outroot examples (HOST components must be set) … … 120 123 my $chipPSF = $ipprc->filename("PSPHOT.PSF.SAVE", $chiproot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR); 121 124 my $cameraObjects = $ipprc->filename("PSASTRO.OUTPUT", $camroot) or &my_die("Missing entry from camera config", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR); 122 my $traceDest = $ipprc->filename("TRACE.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR);125 my $traceDest = $ipprc->filename("TRACE.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR); 123 126 124 127 # XXX check for existence of input data … … 128 131 my $command = "$ppConfigDump -camera $camera -dump-recipe PPSIM -recipe PPSIM $recipe -"; 129 132 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 130 run(command => $command, verbose => $verbose);133 run(command => $command, verbose => $verbose); 131 134 unless ($success) { 132 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);133 &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $fake_id, $class_id, $PS_EXIT_SYS_ERROR);135 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 136 &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $fake_id, $class_id, $PS_EXIT_SYS_ERROR); 134 137 } 135 138 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or 136 &my_die("Unable to parse metadata config doc", $exp_id, $fake_id, $class_id, $PS_EXIT_SYS_ERROR);139 &my_die("Unable to parse metadata config doc", $exp_id, $fake_id, $class_id, $PS_EXIT_SYS_ERROR); 137 140 138 141 ## allow the output images to be optional, depending on the recipe / reduction class … … 156 159 157 160 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 158 run(command => $command, verbose => $verbose);161 run(command => $command, verbose => $verbose); 159 162 unless ($success) { 160 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);161 &my_die("Unable to perform ppSim: $error_code", $exp_id, $fake_id, $class_id, $error_code);163 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 164 &my_die("Unable to perform ppSim: $error_code", $exp_id, $fake_id, $class_id, $error_code); 162 165 } 163 166 … … 167 170 # XXX use this to parse the output metadata : eg, detection limits, Nfakes, Nforced 168 171 # Get the statistics on the processed image 169 # my $statsFile; # File handle172 # my $statsFile; # File handle 170 173 # open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $exp_id, $fake_id, $class_id, $PS_EXIT_SYS_ERROR); 171 174 # my @contents = <$statsFile>; # Contents of file 172 175 # close $statsFile; 173 # 176 # 174 177 # # parse the statistics MDC file 175 # my $mdcParser = PS::IPP::Metadata::Config->new(); # Parser for metadata config files178 # my $mdcParser = PS::IPP::Metadata::Config->new(); # Parser for metadata config files 176 179 # my $metadata = $mdcParser->parse(join "", @contents); 177 180 # unless ($metadata) { 178 # &my_die("Unable to parse metadata config doc", $exp_id, $fake_id, $class_id, $PS_EXIT_PROG_ERROR);181 # &my_die("Unable to parse metadata config doc", $exp_id, $fake_id, $class_id, $PS_EXIT_PROG_ERROR); 179 182 # } 180 # 183 # 181 184 # # extract the stats from the metadata 182 185 # unless ($stats->parse($metadata)) { 183 # &my_die("Failure extracting metadata from the statistics output file.\n", $exp_id, $fake_id, $class_id, $PS_EXIT_PROG_ERROR);186 # &my_die("Failure extracting metadata from the statistics output file.\n", $exp_id, $fake_id, $class_id, $PS_EXIT_PROG_ERROR); 184 187 # } 185 188 } else { … … 194 197 $command .= " -path_base $outroot"; 195 198 $command .= " -dbname $dbname" if defined $dbname; 199 $command .= (" -dtime_script " . (($mjd_start - DateTime->now->mjd) * 86400)); 196 200 # XXX add this after defined 197 201 # $command .= $stats->cmdflags(); … … 200 204 unless ($no_update) { 201 205 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 202 run(command => $command, verbose => $verbose);206 run(command => $command, verbose => $verbose); 203 207 unless ($success) { 204 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);205 warn("Unable to perform faketool -addprocessedimfile: $error_code\n");206 exit($error_code);208 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 209 warn("Unable to perform faketool -addprocessedimfile: $error_code\n"); 210 exit($error_code); 207 211 } 208 212 } else { … … 220 224 carp($msg); 221 225 if (defined $exp_id and defined $fake_id and defined $class_id and not $no_update) { 222 my $command = "$faketool -addprocessedimfile"; 223 $command .= " -fake_id $fake_id"; 224 $command .= " -exp_id $exp_id"; 225 $command .= " -class_id $class_id"; 226 $command .= " -path_base $outroot"; 227 $command .= " -code $exit_code"; 228 $command .= " -dbname $dbname" if defined $dbname; 226 my $command = "$faketool -addprocessedimfile"; 227 $command .= " -fake_id $fake_id"; 228 $command .= " -exp_id $exp_id"; 229 $command .= " -class_id $class_id"; 230 $command .= " -path_base $outroot"; 231 $command .= (" -dtime_script " . (($mjd_start - DateTime->now->mjd) * 86400)); 232 $command .= " -code $exit_code"; 233 $command .= " -dbname $dbname" if defined $dbname; 229 234 system ($command); 230 235 }
Note:
See TracChangeset
for help on using the changeset viewer.
