Changeset 19327
- Timestamp:
- Sep 2, 2008, 9:37:48 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/flatcorr_proc.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/flatcorr_proc.pl
r17671 r19327 12 12 13 13 # dettool -register -det_type FLATCORR -filelevel (level) -workdir -inst, etc 14 14 15 # foreach $imfile () 15 16 # dettool -register_imfile -uri, etc, etc … … 54 55 55 56 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 56 pod2usage( -msg => "Required options: --corr_id --dvodb --region --filter ",57 pod2usage( -msg => "Required options: --corr_id --dvodb --region --filter --workdir", 57 58 -exitval => 3) unless 58 59 defined $corr_id and 59 60 defined $dvodb and 60 61 defined $region and 62 defined $workdir and 61 63 defined $filter; 62 64 … … 77 79 78 80 $outgrid = "$workdir/grid.$corr_id.fits"; 79 $outcorr = "$workdir/corr.$corr_id .fits";81 $outcorr = "$workdir/corr.$corr_id"; 80 82 81 83 # parse the region (RAs,RAe:DECs,DECe) : item = +/-NNN.NNNN … … 90 92 $command .= "-region $RAs $RAe $DECs $DECe"; 91 93 $command .= "-grid $outgrid"; 92 $command .= "-imfreeze ?";94 $command .= "-imfreeze"; 93 95 94 96 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 101 103 } 102 104 103 # use one of the input raw images as a reference image 104 # XXX I'm not sure how this works: do I run this once per imfile for a given exp? 105 my ($reffile) 106 { 107 my $command = "$flatcoor -flatcorrimfile -limit 1"; 108 109 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 110 cache_run(command => $command, verbose => 1); 111 112 unless ($success) { 113 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 114 &my_die ("Unable to perform flatcorr -flatcorrimfile: $error_code", $dvo_id, $region, "RELPHOT", $status, $dbname); 115 } 116 105 # get a single input exposure 106 # flatcorr -inputexp -corr_id $corr_id -limit 1 107 my $chip_id; 108 { 109 my $command = "$flatcorr -inputexp -corr_id $corr_id -limit 1"; # Command to run 110 $command .= " -dbname $dbname" if defined $dbname; 111 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 112 run(command => $command, verbose => $verbose); 113 unless ($success) { 114 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 115 &my_die("Unable to perform camtool: $error_code", $corr_id, $error_code); 116 } 117 117 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 118 &my_die("Unable to parse metadata config doc", $dvo_id, $region, "RELPHOT", $status, $dbname, $PS_EXIT_PROG_ERROR);); 119 120 my $imfiles = parse_md_list($metadata) or 121 &my_die("Unable to parse metadata list", $dvo_id, $region, "RELPHOT", $status, $dbname, $PS_EXIT_PROG_ERROR);); 122 123 my $imfile = $imfiles->[0]; 124 $reffile = $imfile->{uri}; 125 } 126 127 { 128 my $command = "$dvoMakeCorr -file $outgrid -ref $reffile $outcorr"; 129 130 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 131 cache_run(command => $command, verbose => 1); 132 133 unless ($success) { 134 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 135 &my_die ("Unable to perform dvoMakeCorr: $error_code", $dvo_id, $region, "RELASTRO.OBJECTS", $status, $dbname); 136 } 137 } 138 139 { 140 my $command = "$dettool -register"; 118 &my_die("Unable to parse metadata config doc", $corr_id, $PS_EXIT_PROG_ERROR); 119 120 # extract the metadata for the files into a hash list 121 $files = parse_md_list($metadata) or 122 &my_die("Unable to parse metadata list", $corr_id, $PS_EXIT_PROG_ERROR); 123 124 # check for existence 125 my $file = $$files[0]; 126 $chip_id = $file->{chip_id}; 127 } 128 129 # get the list of imfiles for the single input exposure 130 # flatcorr -inputimfile -chip_id $chip_id 131 my $files; 132 { 133 my $command = "$flatcorr -inputimfile -chip_id $chip_id"; # Command to run 134 $command .= " -dbname $dbname" if defined $dbname; 135 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 136 run(command => $command, verbose => $verbose); 137 unless ($success) { 138 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 139 &my_die("Unable to perform camtool: $error_code", $corr_id, $error_code); 140 } 141 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 142 &my_die("Unable to parse metadata config doc", $corr_id, $PS_EXIT_PROG_ERROR); 143 144 # extract the metadata for the files into a hash list 145 $files = parse_md_list($metadata) or 146 &my_die("Unable to parse metadata list", $corr_id, $PS_EXIT_PROG_ERROR); 147 } 148 149 # set up the detrend run to store the corrected imfiles 150 my $det_id; 151 { 152 my $command = "$dettool -register_detrend"; 141 153 $command .= "-det_type FLATCORR"; 142 154 $command .= "-file_level $fileLevel"; … … 151 163 unless ($success) { 152 164 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 153 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RELASTRO.IMAGES", $status, $dbname); 154 } 155 } 156 157 my $command = "$flatcorr -done"; 165 &my_die ("Unable to register new detrend: $error_code", $corr_id, $PS_EXIT_PROG_ERROR); 166 } 167 168 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 169 &my_die("Unable to parse metadata config doc", $corr_id, $PS_EXIT_PROG_ERROR); 170 171 # extract the metadata for the files into a hash list 172 my $output = parse_md_list($metadata) or 173 &my_die("Unable to parse metadata list", $corr_id, $PS_EXIT_PROG_ERROR); 174 175 my $file = $$output[0]; 176 177 $det_id = $file->{det_id}; 178 } 179 180 # use input chip image as a reference image 181 foreach my $file (@$files) { 182 # create the detrend correction for the imfiles based on the input imfiles 183 my $reffile = $file->{uri}; 184 my $class_id = $file->{class_id}; 185 186 my $uri = ipprc_filename ($outcorr, "DVO.CORR", class_id); 187 188 my $command = "$dvoMakeCorr -file $outgrid -ref $reffile $outcorr"; 189 190 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 191 cache_run(command => $command, verbose => 1); 192 193 unless ($success) { 194 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 195 &my_die ("Unable to perform dvoMakeCorr: $error_code", $corr_id, $PS_EXIT_PROG_ERROR); 196 } 197 198 # register the detrend correction imfile 199 my $command = "$dettool -register_detrend_imfile"; 200 $command .= " -det_id $det_id"; 201 $command .= " -class_id $class_id"; 202 $command .= " -uri $uri"; 203 $command .= " -dbname $dbname" if defined $dbname; 204 205 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 206 cache_run(command => $command, verbose => 1); 207 208 unless ($success) { 209 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 210 &my_die ("Unable to register new detrend: $error_code", $corr_id, $PS_EXIT_PROG_ERROR); 211 } 212 } 213 214 my $command = "$dettool -updatedetrun"; 215 $command .= " -det_id $det_id"; 216 $command .= " -state XXX"; 217 $command .= " -dbname $dbname" if defined $dbname; 218 219 # Push the results into the database 220 unless ($no_update) { 221 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 222 run(command => $command, verbose => 1); 223 unless ($success) { 224 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 225 warn ("Unable to perform dettool -updatedetrun: $error_code"); 226 exit($error_code); 227 } 228 } else { 229 print "skipping command: $command\n"; 230 } 231 232 my $command = "$flatcorr -addprocess"; 158 233 $command .= " -corr_id $corr_id"; 159 $command .= " -stats UNKNOWN";160 234 $command .= " -dbname $dbname" if defined $dbname; 161 235
Note:
See TracChangeset
for help on using the changeset viewer.
