Changeset 33282 for trunk/pstamp/scripts
- Timestamp:
- Feb 16, 2012, 1:23:19 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/dquery_job_run.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/dquery_job_run.pl
r33277 r33282 34 34 my $EXTNAME = 'MOPS_DETECTABILITY_RESPONSE'; 35 35 my ($req_id,$job_id,$req_name,$product,$need_magic,$missing_tools,$project); 36 my ($ params_file,$output,$workdir,$dbname,$dbserver,$verbose,$save_temps,$ignore_wisdom);36 my ($output_base,$dbname,$dbserver,$verbose,$save_temps); 37 37 GetOptions( 38 'input=s' => \$params_file, 39 'output=s' => \$output, 40 'workdir=s' => \$workdir, 38 'output_base=s' => \$output_base, 41 39 'job_id=s' => \$job_id, 42 40 'dbname=s' => \$dbname, … … 44 42 'verbose' => \$verbose, 45 43 'save-temps' => \$save_temps, 46 'ignore-wisdom' => \$ignore_wisdom,47 44 ) or pod2usage(2); 48 45 49 46 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 50 pod2usage( -msg => "Required options: --job_id -- input --output --workdir",47 pod2usage( -msg => "Required options: --job_id --output_base", 51 48 -exitval => 3, 52 49 ) unless 53 defined $job_id and defined $ params_file and defined $output and defined $workdir;50 defined $job_id and defined $output_base; 54 51 55 52 my $psphotForced = can_run('psphotForced') or (warn "Can't find psphotForced" and $missing_tools = 1); … … 59 56 exit($PS_EXIT_CONFIG_ERROR); 60 57 } 58 59 my $workdir = dirname($output_base); 60 my $params_file = "${output_base}params.mdc"; 61 61 62 62 unless (defined $verbose) { … … 148 148 149 149 # Run psphotForced on the target list. 150 my $tmpdir = tempdir("detect.$job_id.XXXX", DIR => "${workdir}/", CLEANUP => !$save_temps); 151 my $outroot = "$tmpdir/detectability.${stage}.${fpa_id}.${job_id}"; 150 my $outroot = "${output_base}detectability.${stage}.${stage_id}"; 151 $outroot .= ".$component" unless $stage eq 'chip'; 152 152 153 $params->{PROC_ERROR} = 0; 153 154 my $psphot_cmd = "$psphotForced -psf $psf "; … … 161 162 run(command => $psphot_cmd, verbose => $verbose); 162 163 unless ($success) { 163 $params->{PROC_ERROR} = $PSTAMP_SYSTEM_ERROR;164 } 165 166 # Why not parse out results here? 167 # Convert psphot output to response 168 if ($params->{PROC_ERROR} == 0) { 169 my $class_id = $params->{CLASS_ID}; 170 my $cmf = "${outroot}.${class_id}.cmf"; 171 my ($tmp_Npix,$tmp_Qfact,$tmp_flux,$tmp_flux_error) = read_cmf_file($cmf,$rows[0]->{EXTENSION_BASE});172 my $i = 0; 173 foreach my $row (@rows) {174 $row->{PROC_ERROR} = $params->{PROC_ERROR};175 176 $row->{NPIX} = ${ $tmp_Npix }[$i];177 $row->{QFACTOR} = ${ $tmp_Qfact }[$i]; 178 $row->{FLUX} = ${ $tmp_flux }[$i]; 179 $row->{FLUX_SIG} = ${ $tmp_flux_error }[$i];180 181 # print "$fpa_id $image $#{ $processing_request{$fpa_id}{$image} } $result_index $i ${ $tmp_Npix }[$i]\n";182 $i++;183 } 184 } 185 else{186 foreach my $row (@rows) {187 $row->{PROC_ERROR} = $params->{PROC_ERROR}; 188 189 $row->{NPIX} = 0;190 $row->{QFACTOR} = 0.0;191 $row->{FLUX} = 0.0;192 $row->{FLUX_SIG} = 0.0;193 }194 } 195 196 #write_response_file($output,\%query);164 # $params->{PROC_ERROR} = $PSTAMP_SYSTEM_ERROR; 165 my $rc = $error_code >> 8; 166 my_die("$command failed: $error_code $rc", 167 $params->{QUERY_ID},$fpa_id,$params->{'MJD-OBS'}, 168 $params->{FILTER},$params->{OBSCODE},$params->{STAGE}, 169 $rc); 170 } 171 172 my $results = "$outroot.results"; 173 open OUT, ">$results" or 174 my_die("Failed to open results file $results", 175 $params->{QUERY_ID},$fpa_id,$params->{'MJD-OBS'}, 176 $params->{FILTER},$params->{OBSCODE},$params->{STAGE}, 177 $PS_EXIT_UNKNOWN_ERROR); 178 179 # Read the output cmf and produce the data we need for the response file 180 my $class_id = $params->{CLASS_ID}; 181 my $cmf = "${outroot}.${class_id}.cmf"; 182 my $cmfbase = basename($cmf); 183 my ($tmp_Npix,$tmp_Qfact,$tmp_flux,$tmp_flux_error) = read_cmf_file($cmf,$rows[0]->{EXTENSION_BASE}); 184 $i = 0; 185 print OUT "ROWNUM PROC_ERROR NPIX QFACTOR FLUX FLUX_SIG STAGE STAGE_ID COMPONENT CMFFILE\n"; 186 foreach my $row (@rows) { 187 $row->{PROC_ERROR} = $params->{PROC_ERROR}; 188 189 $row->{NPIX} = ${ $tmp_Npix }[$i]; 190 $row->{QFACTOR} = ${ $tmp_Qfact }[$i]; 191 $row->{FLUX} = ${ $tmp_flux }[$i]; 192 $row->{FLUX_SIG} = ${ $tmp_flux_error }[$i]; 193 194 print OUT "$row->{ROWNUM} $row->{PROC_ERROR} $row->{NPIX} $row->{QFACTOR} $row->{FLUX} $row->{FLUX_SIG} $stage $stage_id $component $cmfbase\n"; 195 $i++; 196 } 197 close(OUT); 197 198 198 199 exit 0;
Note:
See TracChangeset
for help on using the changeset viewer.
