Changeset 13275 for trunk/ippScripts/scripts/camera_exp.pl
- Timestamp:
- May 4, 2007, 4:52:03 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/camera_exp.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/camera_exp.pl
r13090 r13275 17 17 use PS::IPP::Metadata::List qw( parse_md_list ); 18 18 use 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 ); 19 use File::Temp qw( tempfile ); 20 21 use 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 ); 29 30 my $ipprc = PS::IPP::Config->new(); # IPP configuration 30 use File::Spec;31 31 32 32 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 125 125 } 126 126 127 # Set output directory 128 if (defined $workdir) { 129 $workdir = $ipprc->convert_filename_absolute( $workdir ); 130 $workdir = File::Spec->catdir( $workdir, $exp_id ); 131 } else { 132 my $example = $ipprc->convert_filename_absolute( ${$files}[0]->{path_base}) ; # Example original name 133 my ($vol, $dir, $file) = File::Spec->splitpath( $example ); 134 $workdir = $dir; 135 } 136 system "mkdir -p $workdir" unless -d $workdir; 137 138 # Generate the file list, and get the statistics 139 my $outputFile = "$exp_id.cam$cam_id"; 140 my $outputRoot = File::Spec->catfile( $workdir, $outputFile ); 141 142 my $list1Name = $outputRoot . '.b1.list'; # Name for the input file list for binning 1 143 my $list2Name = $outputRoot . '.b2.list'; # Name for the input file list for binning 2 144 my $list3Name = $outputRoot . '.b3.list'; # Name for the input file list for chip astrometry 127 my ($list1File, $list1Name) = tempfile( "$exp_id.cam$cam_id.b1.list.XXXX", UNLINK => 1 ); # For binning 1 128 my ($list2File, $list2Name) = tempfile( "$exp_id.cam$cam_id.b2.list.XXXX", UNLINK => 1 ); # For binning 2 129 my ($list3File, $list3Name) = tempfile( "$exp_id.cam$cam_id.b3.list.XXXX", UNLINK => 1 ); # For astrometry 145 130 146 131 my @means; # Array of means 147 132 my @stdevs; # Array of stdevs 148 open my $list1File, '>' . $list1Name;149 open my $list2File, '>' . $list2Name;150 open my $list3File, '>' . $list3Name;151 152 print "$list1Name $list2Name $list3Name\n";153 154 133 my $chipObjects; 155 134 foreach my $file (@$files) { 156 135 # use the path_base as OUTPUT root and convert the filenames with ipprc->filename: 157 136 my $class_id = $file->{class_id}; 158 my $origRoot = $ipprc->convert_filename_absolute( $file->{path_base} ); # Original root name 159 160 # if there is only one chip, we use this name for the input to addstar 161 $chipObjects = $ipprc->filename("PSASTRO.OUTPUT", $origRoot, $class_id); 162 print $list1File $ipprc->filename("PPIMAGE.BIN1", $origRoot, $class_id); 163 print $list2File $ipprc->filename("PPIMAGE.BIN2", $origRoot, $class_id); 137 138 # If there is only one chip, we use this name for the input to addstar 139 $chipObjects = $ipprc->filename("PSASTRO.OUTPUT", $file->{path_base}, $class_id); 140 print $list1File $ipprc->filename("PPIMAGE.BIN1", $file->{path_base}, $class_id); 141 print $list2File $ipprc->filename("PPIMAGE.BIN2", $file->{path_base}, $class_id); 164 142 print $list3File $chipObjects; 165 143 push @means, $file->{bg}; … … 170 148 close $list3File; 171 149 172 # Output products --- need to synch with the camera configuration! 150 # Output products 151 $workdir = caturi( $workdir, $exp_id ) if defined $workdir; 152 my $outputRoot = $ipprc->file_prepare( "$exp_id.cam$cam_id", $workdir, ${$files}[0]->{path_base} ); 173 153 my $jpeg1 = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1 174 154 my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2 175 155 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $outputRoot); # MEF psastro output 176 # my $dvo_camera = $ipprc->dvocamera();177 156 178 157 unless ($no_op) { … … 188 167 &my_die("Unable to perform psastro: $error_code", $cam_id, $error_code); 189 168 } 190 &my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $fpaObjects;191 169 } else { 192 system "cp $chipObjects $fpaObjects"; 193 } 170 $ipprc->file_copy($chipObjects, $fpaObjects); 171 } 172 &my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($fpaObjects); 194 173 195 174 # run addstar on either the single chip output or the single fpa output … … 197 176 # XXX which in turn points at ippconfig/dvo.site 198 177 { 199 my $command = "addstar -D CAMERA $camera $fpaObjects";178 my $command = "addstar -D CAMERA $camera " . $ipprc->file_resolve($fpaObjects); 200 179 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 201 180 run(command => $command, verbose => 1); … … 215 194 &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code); 216 195 } 217 &my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ jpeg1;196 &my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg1); 218 197 } 219 198 … … 227 206 &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code); 228 207 } 229 &my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $jpeg2; 230 } 231 } 232 233 # XXX keep the same outroot as the input 208 &my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg2); 209 } 210 } 211 234 212 # Add the result into the database 235 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );236 237 213 unless ($no_update) { 238 214 my $command = "$camtool -addprocessedexp -cam_id $cam_id -uri UNKNOWN -path_base $outputRoot " . … … 247 223 exit($error_code); 248 224 } 249 250 unlink $list1Name;251 unlink $list2Name;252 225 } 253 226
Note:
See TracChangeset
for help on using the changeset viewer.
