Changeset 14048
- Timestamp:
- Jul 6, 2007, 3:44:38 PM (19 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 9 edited
-
detrend_norm_exp.pl (modified) (7 diffs)
-
detrend_process_exp.pl (modified) (9 diffs)
-
detrend_process_imfile.pl (modified) (8 diffs)
-
detrend_reject_exp.pl (modified) (16 diffs)
-
detrend_reject_imfile.pl (modified) (16 diffs)
-
detrend_resid.pl (modified) (10 diffs)
-
detrend_stack.pl (modified) (3 diffs)
-
register_exp.pl (modified) (3 diffs)
-
register_imfile.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_norm_exp.pl
r14009 r14048 16 16 use IPC::Cmd 0.36 qw( can_run run ); 17 17 use PS::IPP::Metadata::Config; 18 use PS::IPP::Metadata::Stats; 19 18 20 use PS::IPP::Metadata::List qw( parse_md_list ); 19 21 use File::Temp qw( tempfile ); … … 33 35 use Pod::Usage qw( pod2usage ); 34 36 35 my ($det_id, $iter, $det_type, $camera, $dbname, $workdir, $ no_update, $no_op);37 my ($det_id, $iter, $det_type, $camera, $dbname, $workdir, $reduction, $no_update, $no_op); 36 38 GetOptions( 37 'det_id|d=s' => \$det_id, 38 'iteration|i=s' => \$iter, 39 'camera|c=s' => \$camera, 40 'det_type|t=s' => \$det_type, 41 'dbname|d=s' => \$dbname, # Database name 42 'workdir|w=s' => \$workdir, # Working directory, for output files 43 'no-update' => \$no_update, 44 'no-op' => \$no_op, 45 ) or pod2usage( 2 ); 39 'det_id|d=s' => \$det_id, 40 'iteration|i=s' => \$iter, 41 'camera|c=s' => \$camera, 42 'det_type|t=s' => \$det_type, 43 'dbname|d=s' => \$dbname, # Database name 44 'workdir|w=s' => \$workdir, # Working directory, for output files 45 'reduction|=s' => \$reduction, 46 'no-update' => \$no_update, 47 'no-op' => \$no_op, 48 ) or pod2usage( 2 ); 46 49 47 50 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; … … 58 61 $reduction = 'DETREND' unless defined $reduction; 59 62 60 my $recipe1 = $ipprc->reduction($reduction, 'JPEG_BIN1_IMAGE ' . uc($det_type); # Recipe to use63 my $recipe1 = $ipprc->reduction($reduction, 'JPEG_BIN1_IMAGE_' . uc($det_type)); # Recipe to use 61 64 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe1; 62 65 63 my $recipe2 = $ipprc->reduction($reduction, 'JPEG_BIN2_IMAGE ' . uc($det_type); # Recipe to use66 my $recipe2 = $ipprc->reduction($reduction, 'JPEG_BIN2_IMAGE_' . uc($det_type)); # Recipe to use 64 67 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe2; 65 68 … … 69 72 # XXX (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 1 70 73 my $STATS = 71 [72 # KEYWORD STATISTIC CHIPTOOL FLAG73 { name => "bg", type => "mean", flag => "-bg" },74 { name => "bg", type => "stdev", flag => "-bg_mean_stdev" },75 { name => "bg_stdev", type => "rms", flag => "-bg_stdev" },76 # { name => "bg_mean_stdev", type => "rms", flag => "-bg_mean_stdev" },77 ];74 [ 75 # KEYWORD STATISTIC CHIPTOOL FLAG 76 { name => "bg", type => "mean", flag => "-bg" }, 77 { name => "bg", type => "stdev", flag => "-bg_mean_stdev" }, 78 { name => "bg_stdev", type => "rms", flag => "-bg_stdev" }, 79 # { name => "bg_mean_stdev", type => "rms", flag => "-bg_mean_stdev" }, 80 ]; 78 81 79 82 # Look for programs we need … … 87 90 88 91 # Get list of component files 89 my $files; # Array of component files92 my ($files, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf); 90 93 { 91 my $command= "$dettool -normalizedimfile -det_id $det_id -iteration $iter"; # Command to run94 $command = "$dettool -normalizedimfile -det_id $det_id -iteration $iter"; # Command to run 92 95 $command .= " -dbname $dbname" if defined $dbname; 93 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =96 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 94 97 run(command => $command, verbose => 1); 95 98 unless ($success) { … … 131 134 unless ($no_op) { 132 135 # Make the jpeg for binning 1 133 { 134 my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run 135 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 136 run(command => $command, verbose => 1); 137 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name); 138 } 136 $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run 137 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 138 run(command => $command, verbose => 1); 139 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name); 139 140 140 141 # Make the jpeg for binning 2 141 { 142 my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run 143 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 144 run(command => $command, verbose => 1); 145 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name); 146 } 142 $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run 143 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 144 run(command => $command, verbose => 1); 145 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name); 146 147 147 } 148 148 149 149 # command to update the database 150 my $command= "$dettool -addnormalizedexp";150 $command = "$dettool -addnormalizedexp"; 151 151 $command .= " -det_id $det_id"; 152 152 $command .= " -iteration $iter"; … … 164 164 # Add the processed file to the database 165 165 unless ($no_update) { 166 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =166 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 167 167 run(command => $command, verbose => 1); 168 168 unless ($success) { -
trunk/ippScripts/scripts/detrend_process_exp.pl
r14009 r14048 16 16 use IPC::Cmd 0.36 qw( can_run run ); 17 17 use PS::IPP::Metadata::Config; 18 use PS::IPP::Metadata::Stats; 19 18 20 use PS::IPP::Metadata::List qw( parse_md_list ); 19 21 use File::Temp qw( tempfile ); … … 33 35 use Pod::Usage qw( pod2usage ); 34 36 35 my ($det_id, $ det_type, $exp_tag, $camera, $dbname, $workdir, $no_update, $no_op);37 my ($det_id, $exp_id, $det_type, $exp_tag, $camera, $dbname, $workdir, $reduction, $no_update, $no_op); 36 38 GetOptions( 37 39 'det_id|d=s' => \$det_id, 38 40 'det_type|t=s' => \$det_type, 39 'exp_tag|e=s' => \$exp_tag, 41 'exp_id|d=s' => \$exp_id, 42 'exp_tag|=s' => \$exp_tag, 40 43 'camera|c=s' => \$camera, 41 44 'dbname|d=s' => \$dbname, # Database name 42 45 'workdir|w=s' => \$workdir, # Working directory, for output files 46 'reduction|=s' => \$reduction, 43 47 'no-update' => \$no_update, 44 48 'no-op' => \$no_op, … … 46 50 47 51 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 48 pod2usage( -msg => "Required options: --det_id --det_type --exp_ tag --camera",52 pod2usage( -msg => "Required options: --det_id --det_type --exp_id --exp_tag --camera", 49 53 -exitval => 3) 50 54 unless defined $det_id 51 55 and defined $det_type 56 and defined $exp_id 52 57 and defined $exp_tag 53 58 and defined $camera; … … 58 63 $reduction = 'DETREND' unless defined $reduction; 59 64 60 my $recipe1 = $ipprc->reduction($reduction, 'JPEG_BIN1_IMAGE ' . uc($det_type); # Recipe to use61 &my_die("Unrecognised detrend type: $det_type", $det_id, $ iter, $PS_EXIT_PROG_ERROR) unless defined $recipe1;62 63 my $recipe2 = $ipprc->reduction($reduction, 'JPEG_BIN2_IMAGE ' . uc($det_type); # Recipe to use64 &my_die("Unrecognised detrend type: $det_type", $det_id, $ iter, $PS_EXIT_PROG_ERROR) unless defined $recipe2;65 my $recipe1 = $ipprc->reduction($reduction, 'JPEG_BIN1_IMAGE_' . uc($det_type)); # Recipe to use 66 &my_die("Unrecognised detrend type: $det_type", $det_id, $exp_id, $PS_EXIT_PROG_ERROR) unless defined $recipe1; 67 68 my $recipe2 = $ipprc->reduction($reduction, 'JPEG_BIN2_IMAGE_' . uc($det_type)); # Recipe to use 69 &my_die("Unrecognised detrend type: $det_type", $det_id, $exp_id, $PS_EXIT_PROG_ERROR) unless defined $recipe2; 65 70 66 71 # values to extract from output metadata and the stats to calculate … … 87 92 88 93 # Get list of component files 89 my $files; # Array of component files94 my ($files, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf); 90 95 { 91 my $command = "$dettool -processedimfile -det_id $det_id -exp_tag $exp_tag"; # Command to run96 $command = "$dettool -processedimfile -det_id $det_id -exp_id $exp_id"; # Command to run 92 97 $command .= " -dbname $dbname" if defined $dbname; 93 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =94 run(command => $command, verbose => 1); 95 unless ($success) { 96 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 97 &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $exp_ tag, $error_code);98 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 99 run(command => $command, verbose => 1); 100 unless ($success) { 101 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 102 &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $exp_id, $error_code); 98 103 } 99 104 … … 101 106 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 102 107 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 103 &my_die("Unable to parse metadata config doc", $det_id, $exp_ tag, $PS_EXIT_PROG_ERROR);108 &my_die("Unable to parse metadata config doc", $det_id, $exp_id, $PS_EXIT_PROG_ERROR); 104 109 105 110 # parse the file info in the metadata 106 111 $files = parse_md_list($metadata) or 107 &my_die("Unable to parse metadata list", $det_id, $exp_ tag, $PS_EXIT_PROG_ERROR);112 &my_die("Unable to parse metadata list", $det_id, $exp_id, $PS_EXIT_PROG_ERROR); 108 113 109 114 # parse the stats in the metadata 110 115 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 111 116 unless ($stats->parse($metadata)) { 112 &my_die("Unable to find all values in statistics output.\n", $ chip_id, $class_id, $PS_EXIT_PROG_ERROR);117 &my_die("Unable to find all values in statistics output.\n", $det_id, $exp_id, $PS_EXIT_PROG_ERROR); 113 118 } 114 119 } … … 132 137 unless ($no_op) { 133 138 # Make the jpeg for binning 1 134 { 135 my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run 136 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 137 run(command => $command, verbose => 1); 138 unless ($success) { 139 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 140 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code); 141 } 142 &my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1); 143 } 139 $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run 140 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 141 run(command => $command, verbose => 1); 142 unless ($success) { 143 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 144 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_id, $error_code); 145 } 146 &my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1); 144 147 145 148 # Make the jpeg for binning 2 146 { 147 my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run 148 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 149 run(command => $command, verbose => 1); 150 unless ($success) { 151 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 152 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code); 153 } 154 &my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2); 155 } 149 $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run 150 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 151 run(command => $command, verbose => 1); 152 unless ($success) { 153 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 154 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_id, $error_code); 155 } 156 &my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2); 156 157 } 157 158 158 159 # Command to update the database 159 my $command= "$dettool -addprocessedexp";160 $command = "$dettool -addprocessedexp"; 160 161 $command .= " -det_id $det_id"; 161 $command .= " -exp_ tag $exp_tag";162 $command .= " -exp_id $exp_id"; 162 163 $command .= " -recip $recipe1,$recipe2 -path_base $outputRoot"; 163 164 $command .= " -dbname $dbname" if defined $dbname; … … 172 173 # Add the processed file to the database 173 174 unless ($no_update) { 174 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =175 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 175 176 run(command => $command, verbose => 1); 176 177 unless ($success) { … … 187 188 my $msg = shift; # Warning message on die 188 189 my $det_id = shift; # Detrend identifier 189 my $exp_ tag= shift; # Exposure tag190 my $exp_id = shift; # Exposure tag 190 191 my $exit_code = shift; # Exit code to add 191 192 192 193 carp($msg); 193 if ($det_id and $exp_ tagand not $no_update) {194 if ($det_id and $exp_id and not $no_update) { 194 195 my $command = "$dettool -addprocessedexp"; 195 196 $command .= " -det_id $det_id"; 196 $command .= " -exp_ tag $exp_tag";197 $command .= " -exp_id $exp_id"; 197 198 $command .= " -code $exit_code"; 198 199 $command .= " -dbname $dbname" if defined $dbname; -
trunk/ippScripts/scripts/detrend_process_imfile.pl
r14009 r14048 32 32 use Pod::Usage qw( pod2usage ); 33 33 34 my ($det_id, $exp_ tag, $class_id, $det_type, $input_uri, $camera, $dbname, $workdir, $reduction, $no_update, $no_op);34 my ($det_id, $exp_id, $class_id, $det_type, $exp_tag, $input_uri, $camera, $dbname, $workdir, $reduction, $no_update, $no_op); 35 35 GetOptions( 36 36 'det_id|d=s' => \$det_id, 37 'exp_ tag|e=s' => \$exp_tag,37 'exp_id|e=s' => \$exp_id, 38 38 'class_id|i=s' => \$class_id, 39 39 'det_type|t=s' => \$det_type, 40 'exp_tag|=s' => \$exp_tag, 40 41 'input_uri|u=s' => \$input_uri, 41 42 'camera|c=s' => \$camera, … … 48 49 49 50 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 50 pod2usage( -msg => "Required options: --det_id --exp_ tag --class_id --det_type--input_uri --camera",51 pod2usage( -msg => "Required options: --det_id --exp_id --class_id --det_type --exp_tag --input_uri --camera", 51 52 -exitval => 3) 52 53 unless defined $det_id 53 and defined $exp_ tag54 and defined $exp_id 54 55 and defined $class_id 55 56 and defined $det_type 57 and defined $exp_tag 56 58 and defined $input_uri 57 59 and defined $camera; … … 83 85 $ppImage .= " -dbname $dbname" if defined $dbname; 84 86 85 &my_die("Couldn't find input file: $input_uri\n", $ chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input_uri);87 &my_die("Couldn't find input file: $input_uri\n", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input_uri); 86 88 87 89 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir; … … 89 91 my $outputRoot = $ipprc->file_prepare( "$exp_tag/$exp_tag.detproc.$det_id", $workdir, $input_uri ); 90 92 91 my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $class_id) ;92 my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id) ;93 my $outputBin2 = $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $class_id) ;94 my $outputStats = $ipprc->filename("PPIMAGE.STATS", $outputRoot, $class_id) ;93 my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 94 my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 95 my $outputBin2 = $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 96 my $outputStats = $ipprc->filename("PPIMAGE.STATS", $outputRoot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 95 97 96 98 # Run ppImage … … 105 107 unless ($success) { 106 108 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 107 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_ tag, $class_id, $error_code);109 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_id, $class_id, $error_code); 108 110 } 109 111 110 &my_die("Couldn't find expected output file: $outputImage", $det_id, $exp_ tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage);111 &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_ tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);112 &my_die("Couldn't find expected output file: $outputBin1", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin1);113 &my_die("Couldn't find expected output file: $outputBin2", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin2);112 &my_die("Couldn't find expected output file: $outputImage", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage); 113 &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats); 114 &my_die("Couldn't find expected output file: $outputBin1", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin1); 115 &my_die("Couldn't find expected output file: $outputBin2", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin2); 114 116 115 117 # Get the statistics on the processed image … … 122 124 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 123 125 my $metadata = $mdcParser->parse(join "", @contents) 124 or &my_die("Unable to parse metadata config", $det_id, $exp_ tag, $class_id, $PS_EXIT_PROG_ERROR);126 or &my_die("Unable to parse metadata config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 125 127 126 128 # extract the stats from the metadata 127 129 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 128 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $exp_ tag, $class_id, $PS_EXIT_PROG_ERROR);130 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 129 131 } 130 132 … … 132 134 my $command = "$dettool -addprocessedimfile"; 133 135 $command .= " -det_id $det_id"; 134 $command .= " -exp_ tag $exp_tag";136 $command .= " -exp_id $exp_id"; 135 137 $command .= " -class_id $class_id"; 136 138 $command .= " -recip $reduction"; … … 162 164 my $msg = shift; # Warning message on die 163 165 my $det_id = shift; # Detrend identifier 164 my $exp_ tag= shift; # Exposure tag166 my $exp_id = shift; # Exposure tag 165 167 my $class_id = shift; # Class identifier 166 168 my $exit_code = shift; # Exit code to add 167 169 168 170 carp($msg); 169 if ($det_id and $exp_ tagand $class_id and not $no_update) {171 if ($det_id and $exp_id and $class_id and not $no_update) { 170 172 my $command = "$dettool -addprocessedimfile"; 171 173 $command .= " -det_id $det_id"; 172 $command .= " -exp_ tag $exp_tag";174 $command .= " -exp_id $exp_id"; 173 175 $command .= " -class_id $class_id"; 174 176 $command .= " -code $exit_code"; -
trunk/ippScripts/scripts/detrend_reject_exp.pl
r14009 r14048 16 16 use IPC::Cmd 0.36 qw( can_run run ); 17 17 use PS::IPP::Metadata::Config; 18 use PS::IPP::Metadata::Stats; 19 18 20 use PS::IPP::Metadata::List qw( parse_md_list ); 19 21 use Statistics::Descriptive; … … 86 88 87 89 # Get list of component files 88 my $exposures; # Array of exposures90 my ($exposures, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf); 89 91 { 90 92 # dettool command to select exp data for this det_run 91 my$command = "$dettool -residexp";93 $command = "$dettool -residexp"; 92 94 $command .= " -det_id $det_id"; 93 95 $command .= " -iteration $iter"; 94 96 $command .= " -dbname $dbname" if defined $dbname; 95 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =97 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 96 98 run(command => $command, verbose => 1); 97 99 unless ($success) { … … 118 120 } 119 121 120 my @expTags; # Array of exposure IDs 121 my @accept; # Array of accept flags 122 my @include; # Array of include flags 123 foreach my $exposure (@$exposures) { 124 &my_die("Unable to find exposure id.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $exposure->{exp_tag}; 125 &my_die("Unable to find accept.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $exposure->{accept}; 126 &my_die("Unable to find include.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $exposure->{include}; 127 } 128 122 # we use the statistics of the ensemble to accept/reject exposurs 129 123 my $ensMeanMean = &STATS_value_for_flag ($REJSTATS, "ensMeanMean"); 130 124 my $ensMeanStdev = &STATS_value_for_flag ($REJSTATS, "ensMeanStdev"); … … 147 141 unless ($no_op) { 148 142 $logFile = $ipprc->file_create_append( $logName ); 149 print $logFile "Ensemble mean $ meanEnsemble +/- $stdevEnsemble, stdev $meanStdevEnsemble\n\n";143 print $logFile "Ensemble mean $ensMeanMean +/- $ensMeanStdevMean, stdev $ensStdevMean\n\n"; 150 144 } 151 145 … … 153 147 my $numChanges = 0; # Number of exposures with changed status 154 148 my $numReject = 0; # Number of exposures rejected 155 156 for (my $i = 0; $i < scalar @$exposures; $i++) { 157 my $file = $files[$i]; 158 my $mean = $file->{bg}; # Mean for this exposure 159 my $stdev = $file->{bg_stdev}; # Stdev for this exposure 160 my $meanStdev = $file->{bg_mean_stdev}; # Stdev of Means for this exposure 161 162 my $expTag = $exposure->{exp_tag}; 163 my $accept = $exposure->{accept}; 164 my $include = $exposure->{include}; 149 my $firstElement = 1; 150 151 foreach my $exposure (@$exposures) { 152 my $mean = $exposure->{bg}; # Mean for this exposure 153 my $stdev = $exposure->{bg_stdev}; # Stdev for this exposure 154 my $meanStdev = $exposure->{bg_mean_stdev}; # Stdev of Means for this exposure 155 my $expID = $exposure->{exp_id}; 156 my $accept = $exposure->{accept}; 157 my $include = $exposure->{include}; 158 159 &my_die("Unable to find exposure id.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $expID; 160 &my_die("Unable to find accept.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $accept; 161 &my_die("Unable to find include.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $include; 165 162 166 163 my $reject = 0; # Reject this exposure? 167 164 168 my $command= "$dettool -updateresidexp";165 $command = "$dettool -updateresidexp"; 169 166 $command .= " -det_id $det_id"; 170 167 $command .= " -iteration $iter"; 171 $command .= " -exp_ tag $expTag";168 $command .= " -exp_id $expID"; 172 169 $command .= " -dbname $dbname" if defined $dbname; 173 170 … … 175 172 # Rejected this at an earlier stage 176 173 unless ($no_op) { 177 print $logFile "Rejecting $exp Tagbased on earlier determination.\n";174 print $logFile "Rejecting $expID based on earlier determination.\n"; 178 175 } 179 176 $reject = 1; … … 185 182 # Make sure something gets rejected (just once!), just so that 186 183 # we can trace the full range of the workflow 187 if ($ i == 0and $iter == 0) {184 if ($firstElement and $iter == 0) { 188 185 $reject = 1; 189 186 } … … 194 191 my $delta = abs($mean - $ensMeanMean); 195 192 if ($delta > ($reject_mean * $ensMeanStdev)) { 196 print $logFile "Rejecting $exp Tagbased on ensemble mean value: ";193 print $logFile "Rejecting $expID based on ensemble mean value: "; 197 194 $reject = 1; 198 195 #goto UPDATE; 199 196 } else { 200 print $logFile "$exp TagOK against ensemble mean: ";197 print $logFile "$expID OK against ensemble mean: "; 201 198 } 202 199 print $logFile "$mean --> $delta vs " . $reject_mean * $ensMeanStdev . "\n"; 203 200 } else { 204 print $logFile "No rejection of $exp Tagfor ensemble mean\n";201 print $logFile "No rejection of $expID for ensemble mean\n"; 205 202 } 206 203 … … 208 205 my $delta = abs($stdev - $ensStdevMean); 209 206 if ($delta > ($reject_stdev * $ensStdevStdev)) { 210 print $logFile "Rejecting $exp Tagbased on ensemble stdev: ";207 print $logFile "Rejecting $expID based on ensemble stdev: "; 211 208 $reject = 1; 212 209 #goto UPDATE; 213 210 } else { 214 print $logFile "$exp TagOK against ensemble stdev: ";211 print $logFile "$expID OK against ensemble stdev: "; 215 212 } 216 213 print $logFile "$stdev --> $delta sigma vs " . $reject_stdev * $ensStdevStdev . "\n"; 217 214 } else { 218 print $logFile "No rejection of $exp Tagfor ensemble stdev\n";215 print $logFile "No rejection of $expID for ensemble stdev\n"; 219 216 } 220 217 … … 222 219 my $delta = abs($meanStdev - $ensMeanStdevMean); 223 220 if ($delta > ($reject_meanstdev * $ensMeanStdevStdev)) { 224 print $logFile "Rejecting $exp Tagbased on ensemble mean stdev: ";221 print $logFile "Rejecting $expID based on ensemble mean stdev: "; 225 222 $reject = 1; 226 223 #goto UPDATE; 227 224 } else { 228 print $logFile "$exp TagOK against ensemble mean stdev: ";225 print $logFile "$expID OK against ensemble mean stdev: "; 229 226 } 230 227 print $logFile "$meanStdev --> $delta sigma vs " . $reject_meanstdev * $ensMeanStdevStdev. "\n"; 231 228 } else { 232 print $logFile "No rejection of $exp Tagfor ensemble mean stdev\n";229 print $logFile "No rejection of $expID for ensemble mean stdev\n"; 233 230 } 234 231 … … 242 239 if ((not $include and not $reject) or ($include and $reject)) { 243 240 unless ($no_op) { 244 print $logFile "Status of $exp Taghas changed.\n";241 print $logFile "Status of $expID has changed.\n"; 245 242 } 246 243 $numChanges++; … … 249 246 unless ($no_update) { 250 247 # Update 251 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =248 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 252 249 run(command => $command, verbose => 1); 253 250 unless ($success) { … … 268 265 269 266 # Rejecting everything --- stop before something bad happens! 270 if ($numReject == scalar @ means) {267 if ($numReject == scalar @$exposures) { 271 268 $master = 0; 272 269 $stop = 1; … … 279 276 } 280 277 281 my$command = "$dettool -adddetrunsummary";278 $command = "$dettool -adddetrunsummary"; 282 279 $command .= " -det_id $det_id"; 283 280 $command .= " -iteration $iter"; … … 294 291 # Put results into the database 295 292 unless ($no_update) { 296 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =293 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 297 294 run(command => $command, verbose => 1); 298 295 unless ($success) { … … 310 307 $command .= " -dbname $dbname" if defined $dbname; 311 308 312 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =309 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 313 310 run(command => $command, verbose => 1); 314 311 unless ($success) { -
trunk/ippScripts/scripts/detrend_reject_imfile.pl
r14009 r14048 22 22 use IPC::Cmd 0.36 qw( can_run run ); # tools to run UNIX programs with control over I/O 23 23 use PS::IPP::Metadata::Config; # tools to parse the psMetadataConfig files 24 use PS::IPP::Metadata::Stats; 25 24 26 use PS::IPP::Metadata::List qw( parse_md_list ); # tools to parse a metadata into a hash list 25 27 use Statistics::Descriptive; # tools for calculating basic statistical quantities … … 41 43 42 44 # parse the command-line options 43 my ($det_id, $iter, $exp_ tag, $det_type, $camera, $filter, $reject, $dbname, $workdir, $no_update, $no_op);45 my ($det_id, $iter, $exp_id, $exp_tag, $det_type, $camera, $filter, $reject, $dbname, $workdir, $reduction, $no_update, $no_op); 44 46 GetOptions( 45 47 'det_id|d=s' => \$det_id, 46 48 'iteration=s' => \$iter, 47 'exp_tag|e=s' => \$exp_tag, 49 'exp_id|e=s' => \$exp_id, 50 'exp_tag|=s' => \$exp_tag, 48 51 'det_type|t=s' => \$det_type, 49 52 'camera=s' => \$camera, … … 52 55 'dbname|d=s' => \$dbname, # Database name 53 56 'workdir|w=s' => \$workdir, # Working directory, for output files 57 'reduction|=s' => \$reduction, 54 58 'no-update' => \$no_update, 55 59 'no-op' => \$no_op, … … 57 61 58 62 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 59 pod2usage( -msg => "Required options: --det_id --iteration --exp_ tag --det_type --camera",63 pod2usage( -msg => "Required options: --det_id --iteration --exp_id --exp_tag --det_type --camera", 60 64 -exitval => 3) 61 65 unless defined $det_id 62 66 and defined $iter 67 and defined $exp_id 63 68 and defined $exp_tag 64 69 and defined $det_type … … 71 76 $reduction = 'DETREND' unless defined $reduction; 72 77 73 my $recipe1 = $ipprc->reduction($reduction, 'JPEG_BIN1_RESID ' . uc($det_type); # Recipe to use78 my $recipe1 = $ipprc->reduction($reduction, 'JPEG_BIN1_RESID_' . uc($det_type)); # Recipe to use 74 79 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe1; 75 80 76 my $recipe2 = $ipprc->reduction($reduction, 'JPEG_BIN2_RESID ' . uc($det_type); # Recipe to use81 my $recipe2 = $ipprc->reduction($reduction, 'JPEG_BIN2_RESID_' . uc($det_type)); # Recipe to use 77 82 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe2; 78 83 … … 82 87 # XXX (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 1 83 88 my $STATS = 84 [85 # KEYWORD STATISTIC CHIPTOOL FLAG86 { name => "bg", type => "mean", flag => "-bg" },87 { name => "bg_mean_stdev", type => "stdev", flag => "-bg_mean_stdev" },88 { name => "bg_stdev", type => "rms", flag => "-bg_stdev" },89 { name => "bin_stdev", type => "rms", flag => "-bin_stdev" },90 { name => "fringe_0", type => "mean", flag => "-fringe_0" },91 { name => "fringe_1", type => "rms", flag => "-fringe_1" },92 { name => "fringe_0", type => "stdev", flag => "-fringe_2" },93 { name => "user_1", type => "mean", flag => "-user_1" }, # fringe residual94 { name => "user_2", type => "rms", flag => "-user_2" }, # fringe residual95 { name => "user_3", type => "stdev", flag => "-user_1" }, # fringe residual96 ];89 [ 90 # KEYWORD STATISTIC CHIPTOOL FLAG 91 { name => "bg", type => "mean", flag => "-bg" }, 92 { name => "bg_mean_stdev", type => "stdev", flag => "-bg_mean_stdev" }, 93 { name => "bg_stdev", type => "rms", flag => "-bg_stdev" }, 94 { name => "bin_stdev", type => "rms", flag => "-bin_stdev" }, 95 { name => "fringe_0", type => "mean", flag => "-fringe_0" }, 96 { name => "fringe_1", type => "rms", flag => "-fringe_1" }, 97 { name => "fringe_0", type => "stdev", flag => "-fringe_2" }, 98 { name => "user_1", type => "mean", flag => "-user_1" }, # fringe residual 99 { name => "user_2", type => "rms", flag => "-user_2" }, # fringe residual 100 { name => "user_3", type => "stdev", flag => "-user_1" }, # fringe residual 101 ]; 97 102 98 103 # Look for programs we need … … 106 111 107 112 # Get list of imfile files 108 my $files; # Array of imfile files113 my ($files, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf); 109 114 { 110 # dettool command to select imfile data for this exp_ tag111 my $command= "$dettool -residimfile";115 # dettool command to select imfile data for this exp_id 116 $command = "$dettool -residimfile"; 112 117 $command .= " -det_id $det_id"; 113 118 $command .= " -iteration $iter"; 114 $command .= " -exp_ tag $exp_tag";119 $command .= " -exp_id $exp_id"; 115 120 $command .= " -dbname $dbname" if defined $dbname; 116 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =121 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 117 122 run(command => $command, verbose => 1); 118 123 unless ($success) { … … 126 131 my $mdcParser = PS::IPP::Metadata::Config->new; 127 132 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 128 &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_ tag, $PS_EXIT_PROG_ERROR);133 &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR); 129 134 130 135 # parse the file info in the metadata 131 136 $files = parse_md_list($metadata) or 132 &my_die("Unable to parse metadata list", $det_id, $iter, $exp_ tag, $PS_EXIT_PROG_ERROR);137 &my_die("Unable to parse metadata list", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR); 133 138 134 139 # Parse the statistics on the residual image 135 140 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 136 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_ tag, $class_id, $PS_EXIT_PROG_ERROR);141 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR); 137 142 } 138 143 … … 162 167 # build the JPEG images 163 168 unless ($no_op) { 164 165 169 # Make the jpeg for binning 1 166 { 167 my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run 168 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 169 run(command => $command, verbose => 1); 170 unless ($success) { 171 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 172 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code); 173 } 174 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name); 175 } 170 $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run 171 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 172 run(command => $command, verbose => 1); 173 unless ($success) { 174 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 175 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_id, $error_code); 176 } 177 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name); 176 178 177 179 # Make the jpeg for binning 2 178 { 179 my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run 180 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 181 run(command => $command, verbose => 1); 182 unless ($success) { 183 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 184 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code); 185 } 186 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name); 187 } 180 $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run 181 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 182 run(command => $command, verbose => 1); 183 unless ($success) { 184 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 185 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_id, $error_code); 186 } 187 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name); 188 188 } 189 189 … … 207 207 my $reject_exp_bin_sn = rejection_limit( 'EXP.BIN.SN', $det_type, $filter ); 208 208 209 # storage variables210 211 # load the arrays from the imfile output table212 foreach my $file (@$files) {213 if ($file->{exp_time} > 0.0) {214 push @fluxes, $file->{bg} / $file->{exp_time}; # mean background counts / sec215 } else {216 push @fluxes, $file->{bg};217 }218 }219 220 # Reject based on the stats of the imfiles221 # it is VALID to reject on more than one criterion222 &my_die("Number of means and number of variances differ!", $det_id, $iter, $exp_tag, $PS_EXIT_PROG_ERROR) unless scalar @means == scalar @variances;223 224 209 # storage array 225 210 my @fluxes; 226 211 227 for (my $i = 0; $i < scalar @$files; $i++) { 228 my $file = $files[$i]; 212 foreach my $file (@$files) { 229 213 my $name = $file->{class_id}; 230 214 my $mean = $file->{bg}; # Mean for this imfile … … 234 218 235 219 # calculate and save the fluxes 236 my $flux = $mean / $file->{exp_time};220 my $flux; 237 221 if ($file->{exp_time} == 0.0) { 238 push @fluxes, $mean; 222 $flux = $mean; 223 } else { 224 $flux = $mean / $file->{exp_time}; 239 225 } 240 226 push @fluxes, $flux; … … 296 282 # component means is larger than the limit 297 283 if ($reject_imfile_meanstdev > 0) { 298 if ($meanStdev s> $reject_imfile_meanstdev) {284 if ($meanStdev > $reject_imfile_meanstdev) { 299 285 print $logFile "Rejecting exposure based on bad imfile mean stdev for $name: "; 300 286 $reject = 1; … … 302 288 print $logFile "Imfile mean stdev for $name meets requirements: "; 303 289 } 304 print $logFile "$meanStdev svs $reject_imfile_meanstdev\n";290 print $logFile "$meanStdev vs $reject_imfile_meanstdev\n"; 305 291 } else { 306 292 print $logFile "No rejection on imfile mean stdev for $name\n"; … … 479 465 } 480 466 481 my $command = "$dettool -addresidexp -det_id $det_id -iteration $iter -exp_tag $exp_tag";467 $command = "$dettool -addresidexp -det_id $det_id -iteration $iter -exp_id $exp_id"; 482 468 $command .= " -recip $recipe1,$recipe2 -path_base $outputRoot "; 483 469 $command .= ' -reject' if $reject; … … 492 478 493 479 unless ($no_update) { 494 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =480 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 495 481 run(command => $command, verbose => 1); 496 482 unless ($success) { … … 516 502 my $det_id = shift; # Detrend identifier 517 503 my $iter = shift; # Iteration 518 my $exp_ tag= shift; # Exposure tag504 my $exp_id = shift; # Exposure tag 519 505 my $exit_code = shift; # Exit code to add 520 506 521 507 carp($msg); 522 if ($det_id and $iter and $exp_ tagand not $no_update) {508 if ($det_id and $iter and $exp_id and not $no_update) { 523 509 my $command = "$dettool -addresidexp"; 524 510 $command .= " -det_id $det_id"; 525 511 $command .= " -iteration $iter"; 526 $command .= " -exp_ tag $exp_tag";512 $command .= " -exp_id $exp_id"; 527 513 $command .= " -code $exit_code"; 528 514 $command .= " -dbname $dbname" if defined $dbname; -
trunk/ippScripts/scripts/detrend_resid.pl
r14009 r14048 32 32 use Pod::Usage qw( pod2usage ); 33 33 34 my ($det_id, $iter, $exp_ tag, $class_id, $det_type, $detrend, $input_uri, $camera, $mode, $dbname, $workdir, $reduction, $no_update, $no_op);34 my ($det_id, $iter, $exp_id, $exp_tag, $class_id, $det_type, $detrend, $input_uri, $camera, $mode, $dbname, $workdir, $reduction, $no_update, $no_op); 35 35 GetOptions( 36 36 'det_id|d=s' => \$det_id, 37 37 'iteration=s' => \$iter, 38 'exp_tag|e=s' => \$exp_tag, 38 'exp_id|e=s' => \$exp_id, 39 'exp_tag|=s' => \$exp_tag, 39 40 'class_id|i=s' => \$class_id, 40 41 'det_type|t=s' => \$det_type, … … 51 52 52 53 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 53 pod2usage( -msg => "Required options: --det_id --iteration --exp_ tag --class_id --det_type --camera --input_uri --mode --detrend (not for 'verify' mode)",54 pod2usage( -msg => "Required options: --det_id --iteration --exp_id --exp_tag --class_id --det_type --camera --input_uri --mode --detrend (not for 'verify' mode)", 54 55 -exitval => 3) 55 56 unless defined $det_id 56 57 and defined $iter 58 and defined $exp_id 57 59 and defined $exp_tag 58 60 and defined $class_id … … 73 75 $recipe = uc($det_type) . '_VERIFY'; 74 76 } else { 75 &my_die("Unrecognised mode: $mode", $det_id, $iter, $exp_ tag, $class_id, $PS_EXIT_PROG_ERROR);77 &my_die("Unrecognised mode: $mode", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 76 78 } 77 79 $recipe = $ipprc->reduction($reduction, $recipe); … … 139 141 if (lc($mode) ne 'verify') { 140 142 my $detFlag = DETRENDS->{lc($det_type)}; 141 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_ tag, $class_id, $PS_EXIT_PROG_ERROR) unless defined $detFlag;143 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR) unless defined $detFlag; 142 144 $command .= " $detFlag $detrend"; 143 145 } … … 147 149 unless ($success) { 148 150 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 149 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $exp_ tag, $class_id, $error_code);150 } 151 &my_die("Couldn't find expected output file: $outputName", $det_id, $iter, $exp_ tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputName);152 &my_die("Couldn't find expected output file: $outputStats", $det_id, $iter, $exp_ tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);153 &my_die("Couldn't find expected output file: $bin1Name", $det_id, $iter, $exp_ tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin1Name);154 &my_die("Couldn't find expected output file: $bin2Name", $det_id, $iter, $exp_ tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin2Name);151 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code); 152 } 153 &my_die("Couldn't find expected output file: $outputName", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputName); 154 &my_die("Couldn't find expected output file: $outputStats", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats); 155 &my_die("Couldn't find expected output file: $bin1Name", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin1Name); 156 &my_die("Couldn't find expected output file: $bin2Name", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin2Name); 155 157 156 158 # Load the raw output stats file 157 159 my $statsFile; # File handle 158 open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $exp_ tag, $class_id, $PS_EXIT_SYS_ERROR);160 open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR); 159 161 my @contents = <$statsFile>; # Contents of file 160 162 close $statsFile; … … 162 164 # Parse the stats file contents into a metadata 163 165 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 164 my $metadata = $mdcParser->parse(join "", @contents) or &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_ tag, $class_id, $PS_EXIT_PROG_ERROR);166 my $metadata = $mdcParser->parse(join "", @contents) or &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 165 167 166 168 # Parse the statistics on the residual image 167 169 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 168 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_ tag, $class_id, $PS_EXIT_PROG_ERROR);170 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 169 171 170 172 # run ppStats on the binned image … … 174 176 unless ($success) { 175 177 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 176 &my_die("Unable to perform ppStats: $error_code", $det_id, $iter, $exp_ tag, $class_id, $error_code);178 &my_die("Unable to perform ppStats: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code); 177 179 } 178 180 179 181 # parse the binned image statistics 180 my $binnedMetadata = $mdcParser->parse(join "", @$stdout_buf) or &my_die("Unable to parse metadata output", $det_id, $iter, $exp_ tag, $class_id, $PS_EXIT_PROG_ERROR);182 my $binnedMetadata = $mdcParser->parse(join "", @$stdout_buf) or &my_die("Unable to parse metadata output", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 181 183 182 184 my $binnedStats = PS::IPP::Metadata::Stats->new($BINNED_STATS); # Stats parser 183 $binnedStats->parse($binnedMetadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_ tag, $class_id, $PS_EXIT_PROG_ERROR);185 $binnedStats->parse($binnedMetadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 184 186 } 185 187 … … 188 190 $command .= " -det_id $det_id"; 189 191 $command .= " -iteration $iter"; 190 $command .= " -exp_ tag $exp_tag";192 $command .= " -exp_id $exp_id"; 191 193 $command .= " -class_id $class_id"; 192 194 $command .= " -recip $recipe"; … … 196 198 197 199 # add in the elements from the selected stats above 198 foreach my $entry (@$STATS @$BINNED_STATS) {200 foreach my $entry (@$STATS, @$BINNED_STATS) { 199 201 my $value = $entry->{value}; 200 202 my $flag = $entry->{flag}; … … 220 222 my $det_id = shift; # Detrend identifier 221 223 my $iter = shift; # Iteration 222 my $exp_ tag= shift; # Exposure tag224 my $exp_id = shift; # Exposure tag 223 225 my $class_id = shift; # Class identifier 224 226 my $exit_code = shift; # Exit code to add 225 227 226 228 carp($msg); 227 if ($det_id and $iter and $exp_ tagand not $no_update) {229 if ($det_id and $iter and $exp_id and not $no_update) { 228 230 my $command = "$dettool -addresidimfile"; 229 231 $command .= " -det_id $det_id"; 230 232 $command .= " -iteration $iter"; 231 $command .= " -exp_ tag $exp_tag";233 $command .= " -exp_id $exp_id"; 232 234 $command .= " -class_id $class_id"; 233 235 $command .= " -code $exit_code"; -
trunk/ippScripts/scripts/detrend_stack.pl
r14009 r14048 88 88 } 89 89 90 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;91 92 my $outputRoot = $ipprc->file_prepare( "$camera.$det_type.$det_id.$iter.$class_id", $workdir, ${$files}[0]->{uri} );93 my $outputStack = $outputRoot . '.fits'; # Output name94 my $outputStats = $outputRoot . '.stats'; # Statistics name95 96 90 # Get list of files to stack 97 my $files; # Array of files to be stacked91 my ($files, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf); 98 92 { 99 my$command = "$dettool -processedimfile -included";93 $command = "$dettool -processedimfile -included"; 100 94 $command .= " -det_id $det_id"; 101 95 $command .= " -class_id $class_id"; 102 96 $command .= " -dbname $dbname" if defined $dbname; 103 97 104 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =98 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 105 99 run(command => $command, verbose => $verbose); 106 100 unless ($success) { … … 116 110 } 117 111 118 my $command = "$ppMerge $outputStack"; # Command to run 112 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir; 113 114 my $outputRoot = $ipprc->file_prepare( "$camera.$det_type.$det_id.$iter.$class_id", $workdir, ${$files}[0]->{uri} ); 115 my $outputStack = $outputRoot . '.fits'; # Output name 116 my $outputStats = $outputRoot . '.stats'; # Statistics name 117 118 $command = "$ppMerge $outputStack"; # Command to run 119 119 foreach my $file (@$files) { 120 120 $command .= ' ' . $file->{uri}; … … 128 128 unless ($no_op) { 129 129 130 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =130 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 131 131 run(command => $command, verbose => $verbose); 132 132 unless ($success) { -
trunk/ippScripts/scripts/register_exp.pl
r14039 r14048 19 19 use IPC::Cmd 0.36 qw( can_run run ); 20 20 use PS::IPP::Metadata::Config; 21 use PS::IPP::Metadata::List qw( parse_md_list ); 22 use Statistics::Descriptive; 21 use PS::IPP::Metadata::Stats; 23 22 24 23 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 62 61 { name => "exp_name", type => "constant", flag => "-exp_name" }, # File level 63 62 { name => "telescope", type => "constant", flag => "-telescope" }, # File level 64 { name => " inst",type => "constant", flag => "-inst" }, # File level63 { name => "camera", type => "constant", flag => "-inst" }, # File level 65 64 { name => "filelevel", type => "constant", flag => "-filelevel" }, # File level 66 65 { name => "object", type => "constant", flag => "-object" }, … … 120 119 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 121 120 unless ($stats->parse($metadata)) { 122 &my_die ("Unable to find all values", $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR); 123 } 124 } 121 &my_die ("Unable to find all values", $exp_id, $PS_EXIT_CONFIG_ERROR); 122 } 123 } 124 125 # we require at a minimum: -telescope, -inst, -filelevel, -class_id, -exp_type 126 if (uc(&STATS_value_for_flag ($STATS, "-telescope")) eq "NAN") { &my_die ("telescope not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 127 if (uc(&STATS_value_for_flag ($STATS, "-inst")) eq "NAN") { &my_die ("inst not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 128 if (uc(&STATS_value_for_flag ($STATS, "-filelevel")) eq "NAN") { &my_die ("filelevel not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 129 if (uc(&STATS_value_for_flag ($STATS, "-exp_type")) eq "NAN") { &my_die ("exp_type not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 130 if (uc(&STATS_value_for_flag ($STATS, "-exp_name")) eq "NAN") { &my_die ("exp_name not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 125 131 126 132 my $command = "$regtool -addprocessedexp"; -
trunk/ippScripts/scripts/register_imfile.pl
r14039 r14048 20 20 use PS::IPP::Metadata::Config; 21 21 use PS::IPP::Metadata::Stats; 22 use Data::Dumper;23 22 24 23 use PS::IPP::Config qw( … … 38 37 use Pod::Usage qw( pod2usage ); 39 38 40 my ($cache, $exp_id, $tmp_class_id, $ exp_name, $uri, $workdir, $dbname, $no_update, $no_op);39 my ($cache, $exp_id, $tmp_class_id, $tmp_exp_name, $uri, $workdir, $dbname, $no_update, $no_op); 41 40 GetOptions( 42 41 'caches' => \$cache, 43 42 'exp_id|e=s' => \$exp_id, 44 43 'tmp_class_id|i=s' => \$tmp_class_id, 45 ' exp_name|n=s' => \$exp_name,44 'tmp_exp_name|n=s' => \$tmp_exp_name, 46 45 'uri|u=s' => \$uri, 47 46 'workdir|w=s' => \$workdir, # Working directory for output files … … 52 51 53 52 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 54 pod2usage( -msg => "Required options: --exp_id --tmp_class_id -- exp_name --uri",53 pod2usage( -msg => "Required options: --exp_id --tmp_class_id --tmp_exp_name --uri", 55 54 -exitval => 3) unless 56 55 defined $exp_id and 57 56 defined $tmp_class_id and 58 defined $ exp_name and57 defined $tmp_exp_name and 59 58 defined $uri; 60 59 … … 114 113 unless ($success) { 115 114 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 116 &my_die ("Unable to perform ppStats on exposure id $exp_id: $error_code", $exp_id, $ exp_name, $tmp_class_id, $error_code);115 &my_die ("Unable to perform ppStats on exposure id $exp_id: $error_code", $exp_id, $tmp_exp_name, $tmp_class_id, $error_code); 117 116 } 118 117 … … 121 120 my $metadata = $mdcParser->parse(join "", @$stdout_buf); # XXX is this join necessary? 122 121 unless ($metadata) { 123 &my_die ("Unable to parse metadata config doc", $exp_id, $ exp_name, $tmp_class_id, $PS_EXIT_PROG_ERROR);122 &my_die ("Unable to parse metadata config doc", $exp_id, $tmp_exp_name, $tmp_class_id, $PS_EXIT_PROG_ERROR); 124 123 } 125 124 … … 127 126 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 128 127 unless ($stats->parse($metadata)) { 129 &my_die ("Unable to find all values", $exp_id, $ exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR);128 &my_die ("Unable to find all values", $exp_id, $tmp_exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); 130 129 } 131 130 } 132 131 133 132 # we require at a minimum: -telescope, -inst, -filelevel, -class_id, -exp_type 134 if (uc(&STATS_value_for_flag ($STATS, "-telescope")) eq "NAN") { &my_die ("telescope not found", $exp_id, $ exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); }135 if (uc(&STATS_value_for_flag ($STATS, "-inst")) eq "NAN") { &my_die ("inst not found", $exp_id, $ exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); }136 if (uc(&STATS_value_for_flag ($STATS, "-filelevel")) eq "NAN") { &my_die ("filelevel not found", $exp_id, $ exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); }137 if (uc(&STATS_value_for_flag ($STATS, "-class_id")) eq "NAN") { &my_die ("class_id not found", $exp_id, $ exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); }138 if (uc(&STATS_value_for_flag ($STATS, "-exp_type")) eq "NAN") { &my_die ("exp_type not found", $exp_id, $ exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); }133 if (uc(&STATS_value_for_flag ($STATS, "-telescope")) eq "NAN") { &my_die ("telescope not found", $exp_id, $tmp_exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); } 134 if (uc(&STATS_value_for_flag ($STATS, "-inst")) eq "NAN") { &my_die ("inst not found", $exp_id, $tmp_exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); } 135 if (uc(&STATS_value_for_flag ($STATS, "-filelevel")) eq "NAN") { &my_die ("filelevel not found", $exp_id, $tmp_exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); } 136 if (uc(&STATS_value_for_flag ($STATS, "-class_id")) eq "NAN") { &my_die ("class_id not found", $exp_id, $tmp_exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); } 137 if (uc(&STATS_value_for_flag ($STATS, "-exp_type")) eq "NAN") { &my_die ("exp_type not found", $exp_id, $tmp_exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); } 139 138 140 139 my $command = "$regtool -addprocessedimfile"; 141 140 $command .= " -exp_id $exp_id"; 142 $command .= " -exp_name $ exp_name"; # keep the supplied exp_name (could be derived from the file)141 $command .= " -exp_name $tmp_exp_name"; # keep the supplied exp_name (could be derived from the file) 143 142 $command .= " -tmp_class_id $tmp_class_id"; # the original class_id supplied by the user, replace by ppStats CLASS.ID 144 143 $command .= " -dbname $dbname" if defined $dbname;
Note:
See TracChangeset
for help on using the changeset viewer.
