IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33282 for trunk/pstamp/scripts


Ignore:
Timestamp:
Feb 16, 2012, 1:23:19 PM (14 years ago)
Author:
bills
Message:

change input arguments to use outputBase and create results file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/dquery_job_run.pl

    r33277 r33282  
    3434my $EXTNAME = 'MOPS_DETECTABILITY_RESPONSE';
    3535my ($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);
     36my ($output_base,$dbname,$dbserver,$verbose,$save_temps);
    3737GetOptions(
    38     'input=s'         =>      \$params_file,
    39     'output=s'        =>      \$output,
    40     'workdir=s'       =>      \$workdir,
     38    'output_base=s'   =>      \$output_base,
    4139    'job_id=s'        =>      \$job_id,
    4240    'dbname=s'        =>      \$dbname,
     
    4442    'verbose'         =>      \$verbose,
    4543    'save-temps'      =>      \$save_temps,
    46     'ignore-wisdom'   =>      \$ignore_wisdom,
    4744    ) or pod2usage(2);
    4845
    4946pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    50 pod2usage( -msg => "Required options: --job_id --input --output --workdir",
     47pod2usage( -msg => "Required options: --job_id --output_base",
    5148           -exitval => 3,
    5249    ) unless
    53     defined $job_id and defined $params_file and defined $output and defined $workdir;
     50    defined $job_id and defined $output_base;
    5451
    5552my $psphotForced      = can_run('psphotForced') or (warn "Can't find psphotForced" and $missing_tools = 1);
     
    5956    exit($PS_EXIT_CONFIG_ERROR);
    6057}
     58
     59my $workdir = dirname($output_base);
     60my $params_file = "${output_base}params.mdc";
    6161
    6262unless (defined $verbose) {
     
    148148
    149149# 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}";
     150my $outroot = "${output_base}detectability.${stage}.${stage_id}";
     151$outroot .= ".$component" unless $stage eq 'chip';
     152
    152153$params->{PROC_ERROR} = 0;
    153154my $psphot_cmd = "$psphotForced -psf $psf ";
     
    161162    run(command => $psphot_cmd, verbose => $verbose);
    162163unless ($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
     172my $results = "$outroot.results";
     173open 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
     180my $class_id = $params->{CLASS_ID};
     181my $cmf = "${outroot}.${class_id}.cmf";
     182my $cmfbase = basename($cmf);
     183my ($tmp_Npix,$tmp_Qfact,$tmp_flux,$tmp_flux_error) = read_cmf_file($cmf,$rows[0]->{EXTENSION_BASE});
     184$i = 0;
     185print OUT "ROWNUM PROC_ERROR NPIX QFACTOR FLUX FLUX_SIG STAGE STAGE_ID COMPONENT CMFFILE\n";
     186foreach 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}
     197close(OUT);
    197198
    198199exit 0;
Note: See TracChangeset for help on using the changeset viewer.