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_norm_exp.pl

    r12800 r13275  
    1717use PS::IPP::Metadata::List qw( parse_md_list );
    1818use Statistics::Descriptive;
     19use File::Temp qw( tempfile );
    1920
    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     );
     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 );
     
    115115}
    116116
    117 # Set output directory
    118 if (defined $workdir) {
    119     $workdir = $ipprc->convert_filename_absolute( $workdir );
    120     my $subdir = "$camera.$det_type.$det_id";
    121     $workdir = File::Spec->catdir( $workdir, $subdir );
    122 } else {
    123     my $example = $ipprc->convert_filename_absolute( ${$files}[0]->{path_base} ); # Example file, for path
    124     my ($vol, $dir, $file) = File::Spec->splitpath( $example );
    125     $workdir = $dir;
    126 }
    127 system "mkdir -p $workdir" unless -d $workdir;
    128 
    129 # Generate the file list, and get the statistics
    130 my $outputFile = "$camera.$det_type.norm.$det_id.$iter"; # Root output name
    131 my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
    132 
    133 my $list1Name = $outputRoot . '.b1.list'; # Name for the input file list for binning 1
    134 my $list2Name = $outputRoot . '.b2.list'; # Name for the input file list for binning 2
     117my ($list1File, $list1Name) = tempfile( "$camera.$det_type.norm.$det_id.$iter.b1.list.XXXX", UNLINK => 1 );
     118my ($list2File, $list2Name) = tempfile( "$camera.$det_type.norm.$det_id.$iter.b2.list.XXXX", UNLINK => 1 );
    135119my @means;                      # Array of means
    136120my @stdevs;                     # Array of stdevs
    137 open my $list1File, '>' . $list1Name;
    138 open my $list2File, '>' . $list2Name;
    139121foreach my $file (@$files) {
    140     my $origRoot = $ipprc->convert_filename_absolute( $file->{path_base} ); # Original root name
    141     print $list1File ( $ipprc->filename( "PPIMAGE.BIN1", $origRoot, $file->{class_id} ) . "\n");
    142     print $list2File ( $ipprc->filename( "PPIMAGE.BIN2", $origRoot, $file->{class_id} ) . "\n");
     122    print $list1File ( $ipprc->filename( "PPIMAGE.BIN1", $file->{path_base}, $file->{class_id} ) . "\n");
     123    print $list2File ( $ipprc->filename( "PPIMAGE.BIN2", $file->{path_base}, $file->{class_id} ) . "\n");
    143124    push @means, $file->{bg};
    144125    push @stdevs, $file->{bg_stdev};
     
    148129
    149130# Output products
     131$workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
     132my $outputRoot = $ipprc->file_prepare( "$camera.$det_type.norm.$det_id.$iter", $workdir );
    150133my $jpeg1Name = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
    151134my $jpeg2Name = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
     
    157140        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    158141            run(command => $command, verbose => 1);
    159         &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $jpeg1Name;
     142        &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1Name);
    160143    }
    161144   
     
    165148        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    166149            run(command => $command, verbose => 1);
    167         &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $jpeg2Name;
     150        &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2Name);
    168151    }
    169152}
    170 
    171 # Add the result into the database
    172 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );
    173153
    174154unless ($no_update) {
     
    183163        &my_die("Unable to perform dettool -addnormalizedexp: $error_code", $det_id, $iter, $error_code);
    184164    }
    185 
    186     unlink $list1Name;
    187     unlink $list2Name;
    188165}
    189166
Note: See TracChangeset for help on using the changeset viewer.