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

    r12800 r13275  
    1818use Statistics::Descriptive;
    1919
    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     );
     20use PS::IPP::Config qw($PS_EXIT_SUCCESS
     21                       $PS_EXIT_UNKNOWN_ERROR
     22                       $PS_EXIT_SYS_ERROR
     23                       $PS_EXIT_CONFIG_ERROR
     24                       $PS_EXIT_PROG_ERROR
     25                       $PS_EXIT_DATA_ERROR
     26                       $PS_EXIT_TIMEOUT_ERROR
     27                       caturi
     28                       );
    2929my $ipprc = PS::IPP::Config->new(); # IPP configuration
    30 use File::Spec;
     30use File::Temp qw( tempfile );
    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, $exp_tag );
    122 } else {
    123     my $example = $ipprc->convert_filename_absolute( ${$files}[0]->{path_base} ); # Example original name
    124     my ($vol, $dir, $file) = File::Spec->splitpath( $example );
    125     $workdir = $dir;
    126 }
    127 system "mkdir -p $workdir" unless -d $workdir;
    128 
    129 my $outputFile = $exp_tag . '.detproc.' . $det_id; # Root name
    130 my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
    131 
    132 # output files:
    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
     117# File lists for the two binnings
     118my ($list1File, $list1Name) = tempfile( "$exp_tag.detproc.$det_id.b1.list.XXXX", UNLINK => 1 );
     119my ($list2File, $list2Name) = tempfile( "$exp_tag.detproc.$det_id.b2.list.XXXX", UNLINK => 1 );
    135120my @means;                      # Array of means
    136121my @stdevs;                     # Array of stdevs
    137 open my $list1File, '>' . $list1Name;
    138 open my $list2File, '>' . $list2Name;
    139122foreach 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");
     123    print $list1File ($ipprc->filename( "PPIMAGE.BIN1", $file->{path_base}, $file->{class_id} ) . "\n");
     124    print $list2File ($ipprc->filename( "PPIMAGE.BIN2", $file->{path_base}, $file->{class_id} ) . "\n");
    143125    push @means, $file->{bg};
    144126    push @stdevs, $file->{bg_stdev};
     
    147129close $list2File;
    148130
    149 # Output products
     131# Output files
     132$workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir;
     133my $outputRoot = $ipprc->file_prepare( "$exp_tag.detproc.$det_id", $workdir, ${$files}[0]->{path_base} );
    150134my $jpeg1 = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
    151135my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
     
    161145            &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code);
    162146        }
    163         &my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg1;
     147        &my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg1);
    164148    }
    165149   
     
    173157            &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code);
    174158        }
    175         &my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg2;
    176     }
    177 }
    178 
    179 # Add the result into the database
    180 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );
     159        &my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($jpeg2);
     160    }
     161}
    181162
    182163unless ($no_update) {
     
    192173        exit($error_code);
    193174    }
    194 
    195     unlink $list1Name;
    196     unlink $list2Name;
    197175}
    198176
Note: See TracChangeset for help on using the changeset viewer.