Changeset 34792
- Timestamp:
- Dec 11, 2012, 11:09:13 AM (14 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/skycalibration.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/skycalibration.pl
r34738 r34792 134 134 # First check the expected file name where the stack_id is the FILE_ID 135 135 my $file; 136 if (!$singlefilter) { 136 # if (!$singlefilter) { 137 if (1) { 138 137 139 $file = $ipprc->filename('PSPHOT.STACK.OUTPUT', $path_base, $stack_id); 138 140 if (! $ipprc->file_resolve($file)) { 139 # XXX: Beginning of section that can be removed eventually140 141 # no file with the expected name found142 # assume that the input is from an early staticsky run that did not use stack_id as the FILE_ID143 # but instead used FILE_ID = [0 .. num_filters-1]144 141 print "\nfailed to resolve $file\n"; 145 if (!$filter) { 146 &my_die("filter not supplied unable to identify appropriate staticsky input.", $skycal_id, $PS_EXIT_SYS_ERROR); 147 } 148 print "Trying old style FILE_ID\n"; 149 my $max_filters = 5; 150 for (my $i=0; $i < $max_filters; $i++) { 151 my $file_id = sprintf "%03d", $i; 152 $file = $ipprc->filename('PSPHOT.STACK.OUTPUT', $path_base, $file_id); 153 my $resolved = $ipprc->file_resolve($file); 154 if (!$resolved) { 155 # we fail here assumming that if file_id N doesn't exist, neither to N+1 156 print "\nfailed to resolve $file\n\n"; 157 &my_die("unable to identify appropriate staticsky input.", $skycal_id, $PS_EXIT_SYS_ERROR); 142 # file with proper file rule not found. Try older systems 143 if ($singlefilter) { 144 # input is from a single filter static sky run which used psphot instead of psphotStack 145 # The file rule is different for psphot 146 $file = $ipprc->filename('PSPHOT.OUT.CMF.MEF', $path_base); 147 &my_die("Unable to find input for $stack_id $filter", $skycal_id, $PS_EXIT_SYS_ERROR) 148 unless $ipprc->file_exists($file); 149 } else { 150 # XXX: Beginning of section that can be removed eventually 151 # no file with the expected name found 152 # assume that the input is from an early multifilter staticsky run that did not use stack_id as the FILE_ID 153 # but instead used FILE_ID = [0 .. num_filters-1] 154 if (!$filter) { 155 &my_die("filter not supplied unable to identify appropriate staticsky input.", $skycal_id, $PS_EXIT_SYS_ERROR); 158 156 } 159 # Check the filter id for this file 160 my $command = "$fhead $resolved | grep FILTERID"; 161 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 162 run(command => $command, verbose => 0); 163 unless ($success) { 164 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 165 &my_die("Unable to perform $command: $error_code", $skycal_id, $PS_EXIT_SYS_ERROR); 157 print "Trying old style FILE_ID\n"; 158 my $max_filters = 5; 159 for (my $i=0; $i < $max_filters; $i++) { 160 my $file_id = sprintf "%03d", $i; 161 $file = $ipprc->filename('PSPHOT.STACK.OUTPUT', $path_base, $file_id); 162 my $resolved = $ipprc->file_resolve($file); 163 if (!$resolved) { 164 # we fail here assumming that if file_id N doesn't exist, neither to N+1 165 print "\nfailed to resolve $file\n\n"; 166 &my_die("unable to identify appropriate staticsky input.", $skycal_id, $PS_EXIT_SYS_ERROR); 167 } 168 # Check the filter id for this file 169 my $command = "$fhead $resolved | grep FILTERID"; 170 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 171 run(command => $command, verbose => 0); 172 unless ($success) { 173 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 174 &my_die("Unable to perform $command: $error_code", $skycal_id, $PS_EXIT_SYS_ERROR); 175 } 176 # Expected output: HIERARCH FPA.FILTERID = 'r.00000 ' / Filter used (parsed, abstract name) 177 my ($undef, undef, undef, $filt) = split " ", join("", @$stdout_buf); 178 my $this_filter = substr $filt, 1, 7; 179 180 # if it matches we're done 181 last if $this_filter eq $filter; 182 183 # nope loop around to try the next one 184 print "Input file for $filter is not $file ($this_filter)\n"; 185 $file = undef; 166 186 } 167 # Expected output: HIERARCH FPA.FILTERID = 'r.00000 ' / Filter used (parsed, abstract name) 168 my ($undef, undef, undef, $filt) = split " ", join("", @$stdout_buf); 169 my $this_filter = substr $filt, 1, 7; 170 171 # if it matches we're done 172 last if $this_filter eq $filter; 173 174 # nope loop around to try the next one 175 print "Input file for $filter is not $file ($this_filter)\n"; 176 $file = undef; 177 } 187 } 188 # XXX: End of section that can be removed eventually 189 } 190 if ($file) { 178 191 print "\nInput file for $stack_id filter: $filter: $file\n"; 179 180 # XXX: End of section that can be removed eventually 181 } 182 } else { 183 # input is from a single filter static sky run use a different file rule 184 # XXX: can't we just make staticsky.pl use the same file rule? 185 $file = $ipprc->filename('PSPHOT.OUT.CMF.MEF', $path_base); 186 &my_die("Unable to find input for $stack_id $filter", $skycal_id, $PS_EXIT_SYS_ERROR) 187 unless $ipprc->file_exists($file); 188 } 189 190 if (!$file) { 191 &my_die("Unable to find input for $stack_id $filter", $skycal_id, $PS_EXIT_SYS_ERROR); 192 } else { 193 &my_die("Unable to find input file for stack_id $stack_id.", $skycal_id, $PS_EXIT_SYS_ERROR); 194 } 192 195 } 193 196 … … 197 200 } 198 201 199 # read the input header to find the number of detections and the number of detections 200 # with extended model 202 # XXX: The following is for compatability with psphotStack cmfs created prior to adding NDET 203 # read the input header to find the number of detections 204 my $compatability_flags = ""; 201 205 my $n_detections = 0; 202 my $n_extended = 0;203 206 { 207 # NSTARS is buggy. It only counts sources with a model, and counts them twice. 208 # We want the actual number of sources (real + matched). Use the length of the psf table 204 209 my $command = "echo $resolved | $fields -n SkyChip.psf NAXIS2"; 205 210 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 211 216 unless defined $n_detections; 212 217 213 $command = "echo $resolved | $fields -n SkyChip.hdr NDET_EXT"; 214 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 215 run(command => $command, verbose => 0); 216 (undef, $n_extended) = split " ", join "", @$stdout_buf; 217 chomp $n_extended; 218 &my_die("Unable to find number of extended objects from $file: ", $skycal_id, $PS_EXIT_SYS_ERROR) 219 unless defined $n_extended; 218 $compatability_flags .= " -n_detections $n_detections"; 219 220 220 } 221 221 … … 257 257 } 258 258 259 # if ppStats didn't get n_detections use the compatability version extracted above 260 $cmdflags .= $compatability_flags unless ($cmdflags =~ /-n_detections/); 261 259 262 my $quality; 260 263 ($quality) = $cmdflags =~ /-quality (\d+)/; … … 276 279 { 277 280 my $command = "$staticskytool -skycal_id $skycal_id"; 278 $command .= " -n_detections $n_detections";279 $command .= " -n_extended $n_extended";280 281 $command .= " -addskycalresult -path_base $outroot"; 281 282 $command .= " $cmdflags";
Note:
See TracChangeset
for help on using the changeset viewer.
