IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 4, 2007, 4:52:03 PM (19 years ago)
Author:
Paul Price
Message:

Major upgrade to allow use of Nebulous

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/detrend_reject_imfile.pl

    r12979 r13275  
    1717use PS::IPP::Metadata::List qw( parse_md_list );
    1818use Statistics::Descriptive;
    19 
    20 use PS::IPP::Config qw(
    21     $PS_EXIT_SUCCESS
    22     $PS_EXIT_UNKNOWN_ERROR
    23     $PS_EXIT_SYS_ERROR
    24     $PS_EXIT_CONFIG_ERROR
    25     $PS_EXIT_PROG_ERROR
    26     $PS_EXIT_DATA_ERROR
    27     $PS_EXIT_TIMEOUT_ERROR
    28     );
     19use File::Temp qw( tempfile );
     20
     21use PS::IPP::Config qw($PS_EXIT_SUCCESS
     22                       $PS_EXIT_UNKNOWN_ERROR
     23                       $PS_EXIT_SYS_ERROR
     24                       $PS_EXIT_CONFIG_ERROR
     25                       $PS_EXIT_PROG_ERROR
     26                       $PS_EXIT_DATA_ERROR
     27                       $PS_EXIT_TIMEOUT_ERROR
     28                       caturi
     29                       );
    2930my $ipprc = PS::IPP::Config->new(); # IPP configuration
    30 use File::Spec;
    3131
    3232use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    9393}
    9494
    95 # Set output directory
    96 if (defined $workdir) {
    97     $workdir = $ipprc->convert_filename_absolute( $workdir );
    98     my $subdir = "$camera.$det_type.$det_id";
    99     $workdir = File::Spec->catdir( $workdir, $subdir, $exp_tag );
    100 } else {
    101     my $example = $ipprc->convert_filename_absolute( ${$files}[0]->{path_base} ); # Example original name
    102     my ($vol, $dir, $file) = File::Spec->splitpath( $example );
    103     $workdir = $dir;
    104 }
    105 system "mkdir -p $workdir" unless -d $workdir;
    106 
    107 # Generate the file list, and get the statistics
    108 my $outputFile = "$exp_tag.detresid.$det_id.$iter"; # Root name
    109 my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
    110 
    111 my $list1Name = $outputRoot . '.b1.list'; # Name for the input file list for binning 1
    112 my $list2Name = $outputRoot . '.b2.list'; # Name for the input file list for binning 2
    113 
     95
     96my ($list1File, $list1Name) = tempfile( "$exp_tag.detresid.$det_id.$iter.b1.list.XXXX", UNLINK => 1 );
     97my ($list2File, $list2Name) = tempfile( "$exp_tag.detresid.$det_id.$iter.b2.list.XXXX", UNLINK => 1 );
    11498my @means;                      # Array of means
    11599my @variances;                  # Array of variances
    116100my @meanStdevs;                 # Array of mean stdevs
    117101my @names;                      # Array of names (class_id)
    118 open my $list1File, '>' . $list1Name;
    119 open my $list2File, '>' . $list2Name;
    120102foreach my $file (@$files) {
    121     my $origRoot = $ipprc->convert_filename_absolute( $file->{path_base} ); # Original root name
    122     print $list1File ($ipprc->filename( "PPIMAGE.BIN1", $origRoot, $file->{class_id} ) . "\n");
    123     print $list2File ($ipprc->filename( "PPIMAGE.BIN2", $origRoot, $file->{class_id} ) . "\n");
     103    print $list1File ($ipprc->filename( "PPIMAGE.BIN1", $file->{path_base}, $file->{class_id} ) . "\n");
     104    print $list2File ($ipprc->filename( "PPIMAGE.BIN2", $file->{path_base}, $file->{class_id} ) . "\n");
    124105    push @means, $file->{bg};
    125106    push @meanStdevs, $file->{bg_mean_stdev};
     
    131112close $list2File;
    132113
    133 # Output products --- need to synch with the camera configuration!
     114# Output products
     115$workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
     116my $outputRoot = $ipprc->file_prepare( "$exp_tag.detresid.$det_id.$iter", $workdir, ${$files}[0]->{path_base} );
    134117my $jpeg1Name = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
    135118my $jpeg2Name = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
     
    146129            &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code);
    147130        }
    148         &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg1Name;
     131        &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name);
    149132    }
    150133   
     
    158141            &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code);
    159142        }
    160         &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg2Name;
     143        &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name);
    161144    }
    162145}
     
    173156my $reject_exp_sn           = rejection_limit( 'EXP.SN',           $det_type, $filter );
    174157
    175 my $logName = "$exp_tag.detreject.$det_id.$iter.log"; # Name for log
    176 $logName = File::Spec->catfile( $workdir, $logName );
     158my $logName = caturi( $workdir, "$exp_tag.detreject.$det_id.$iter.log" ); # Name for log
    177159my $logFile;
    178160unless ($no_op) {
    179     open $logFile, "> $logName" or &my_die("Unable to open log file $logName", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR);
     161    $logFile = $ipprc->file_create_open( $logName );
    180162}
    181163
     
    311293
    312294# Add the result into the database
    313 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );
    314 
    315295my $bg = $mean;
    316296my $bg_stdev = $stdev;
     
    330310        exit($error_code);
    331311    }
    332 
    333     unlink $list1Name;
    334     unlink $list2Name;
    335312}
    336313
Note: See TracChangeset for help on using the changeset viewer.