Changeset 32972 for trunk/ippScripts
- Timestamp:
- Dec 19, 2011, 1:23:22 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/skycalibration.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/skycalibration.pl
r32959 r32972 48 48 print " --outroot (root) : Output root name\n"; 49 49 print " --path_base (path_base) : path_base of input\n"; 50 print " --filter (filter) : filter of input\n"; 51 print " --singlefilter : the input is the result of a single filter analysis"; 50 52 print " --reduction (class) : Reduction class\n"; 51 53 print " --verbose : Be extra verbose\n"; … … 58 60 } 59 61 60 my ($skycal_id, $stack_id, $camera, $dbname, $threads, $outroot, $path_base, $filter, $ reduction, $verbose, $no_update, $no_op, $redirect, $save_temps);62 my ($skycal_id, $stack_id, $camera, $dbname, $threads, $outroot, $path_base, $filter, $singlefilter, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps); 61 63 GetOptions( 62 64 'skycal_id=s' => \$skycal_id, # sky calibration run id … … 69 71 'filter=s' => \$filter, # filter for input stack 70 72 'reduction=s' => \$reduction, # Reduction class 73 'singlefilter' => \$singlefilter, # input was from single filter analysis 71 74 'verbose' => \$verbose, # Print to stdout 72 75 'no-update' => \$no_update, # Don't update the database? … … 111 114 my $recipe_psastro = $ipprc->reduction($reduction, 'STATICSKY_CALIBRATION'); # Recipe to use for psastro 112 115 unless ($recipe_psastro) { 113 # XXX: ADD to reduction: hard code recipe for now 114 $recipe_psastro = 'STATICSKY_CAL'; 115 # &my_die("Couldn't find selected reduction for STACKPHOT: $reduction\n", $skycal_id, $PS_EXIT_CONFIG_ERROR); 116 &my_die("Couldn't find selected reduction for STATICSKY_CALIBRATION: $reduction\n", $skycal_id, $PS_EXIT_CONFIG_ERROR); 116 117 } 117 118 … … 123 124 # find input file 124 125 # First check the expected file name where the stack_id is the FILE_ID 125 my $file = $ipprc->filename('PSPHOT.STACK.OUTPUT', $path_base, $stack_id); 126 if (! $ipprc->file_resolve($file)) { 127 # XXX: Beginning of section that can go eventually 128 129 # no file with the expected name found 130 # assume that the input is from an early staticsky run that did not use stack_id as the FILE_ID 131 # but instead used FILE_ID = [0 .. num_filters-1] 132 print "\nfailed to resolve $file\n"; 133 if (!$filter) { 134 &my_die("filter not supplied unable to identify appropriate staticsky input.", $skycal_id, $PS_EXIT_SYS_ERROR); 135 } 136 print "Trying old FILE_ID\n"; 137 my $max_filters = 5; 138 for (my $i=0; $i < $max_filters; $i++) { 139 my $file_id = sprintf "%03d", $i; 140 $file = $ipprc->filename('PSPHOT.STACK.OUTPUT', $path_base, $file_id); 141 my $resolved = $ipprc->file_resolve($file); 142 if (!$resolved) { 143 # we fail here assumming that if file_id N doesn't exist, neither to N+1 144 print "\nfailed to resolve $file\n\n"; 145 &my_die("unable to identify appropriate staticsky input.", $skycal_id, $PS_EXIT_SYS_ERROR); 146 } 147 # Check the filter id for this file 148 my $command = "$fhead $resolved | grep FILTERID"; 149 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 150 run(command => $command, verbose => 0); 151 unless ($success) { 152 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 153 &my_die("Unable to perform $command: $error_code", $skycal_id, $PS_EXIT_SYS_ERROR); 154 } 155 # Expected output: HIERARCH FPA.FILTERID = 'r.00000 ' / Filter used (parsed, abstract name) 156 my ($undef, undef, undef, $filt) = split " ", join("", @$stdout_buf); 157 my $this_filter = substr $filt, 1, 7; 158 159 # if it matches we're done 160 last if $this_filter eq $filter; 161 162 # nope loop around to try the next one 163 print "Input file for $filter is not $file ($this_filter)\n"; 164 $file = undef; 165 } 166 print "\nInput file for $stack_id filter: $filter: $file\n"; 167 168 # XXX: End of section that can go eventually 126 my $file; 127 if (!$singlefilter) { 128 $file = $ipprc->filename('PSPHOT.STACK.OUTPUT', $path_base, $stack_id); 129 if (! $ipprc->file_resolve($file)) { 130 # XXX: Beginning of section that can be removed eventually 131 132 # no file with the expected name found 133 # assume that the input is from an early staticsky run that did not use stack_id as the FILE_ID 134 # but instead used FILE_ID = [0 .. num_filters-1] 135 print "\nfailed to resolve $file\n"; 136 if (!$filter) { 137 &my_die("filter not supplied unable to identify appropriate staticsky input.", $skycal_id, $PS_EXIT_SYS_ERROR); 138 } 139 print "Trying old style FILE_ID\n"; 140 my $max_filters = 5; 141 for (my $i=0; $i < $max_filters; $i++) { 142 my $file_id = sprintf "%03d", $i; 143 $file = $ipprc->filename('PSPHOT.STACK.OUTPUT', $path_base, $file_id); 144 my $resolved = $ipprc->file_resolve($file); 145 if (!$resolved) { 146 # we fail here assumming that if file_id N doesn't exist, neither to N+1 147 print "\nfailed to resolve $file\n\n"; 148 &my_die("unable to identify appropriate staticsky input.", $skycal_id, $PS_EXIT_SYS_ERROR); 149 } 150 # Check the filter id for this file 151 my $command = "$fhead $resolved | grep FILTERID"; 152 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 153 run(command => $command, verbose => 0); 154 unless ($success) { 155 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 156 &my_die("Unable to perform $command: $error_code", $skycal_id, $PS_EXIT_SYS_ERROR); 157 } 158 # Expected output: HIERARCH FPA.FILTERID = 'r.00000 ' / Filter used (parsed, abstract name) 159 my ($undef, undef, undef, $filt) = split " ", join("", @$stdout_buf); 160 my $this_filter = substr $filt, 1, 7; 161 162 # if it matches we're done 163 last if $this_filter eq $filter; 164 165 # nope loop around to try the next one 166 print "Input file for $filter is not $file ($this_filter)\n"; 167 $file = undef; 168 } 169 print "\nInput file for $stack_id filter: $filter: $file\n"; 170 171 # XXX: End of section that can be removed eventually 172 } 173 } else { 174 # input is from a single filter static sky run use a different file rule 175 # XXX: can't we just make staticsky.pl use the same file rule? 176 $file = $ipprc->filename('PSPHOT.OUT.CMF.MEF', $path_base); 177 &my_die("Unable to find input for $stack_id $filter", $skycal_id, $PS_EXIT_SYS_ERROR) 178 unless $ipprc->file_exists($file); 179 } 180 181 if (!$file) { 182 &my_die("Unable to find input for $stack_id $filter", $skycal_id, $PS_EXIT_SYS_ERROR); 169 183 } 170 184 … … 192 206 193 207 { 194 my $command = "$ppStatsFromMetadata $stats - STATICSKY_CAL"; 208 my $resolved = $ipprc->file_resolve($stats) 209 or &my_die("failed to resolve stats file: $stats", $skycal_id, $PS_EXIT_SYS_ERROR) ; 210 my $command = "$ppStatsFromMetadata $resolved - STATICSKY_CAL"; 195 211 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 196 212 unless ($success) {
Note:
See TracChangeset
for help on using the changeset viewer.
