Changeset 13275
- Timestamp:
- May 4, 2007, 4:52:03 PM (19 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 18 edited
-
camera_exp.pl (modified) (8 diffs)
-
chip_imfile.pl (modified) (6 diffs)
-
detrend_norm_apply.pl (modified) (5 diffs)
-
detrend_norm_exp.pl (modified) (6 diffs)
-
detrend_process_exp.pl (modified) (6 diffs)
-
detrend_process_imfile.pl (modified) (5 diffs)
-
detrend_reject_exp.pl (modified) (2 diffs)
-
detrend_reject_imfile.pl (modified) (8 diffs)
-
detrend_resid.pl (modified) (5 diffs)
-
detrend_stack.pl (modified) (5 diffs)
-
diff_skycell.pl (modified) (7 diffs)
-
ipp_datapath.pl (modified) (1 diff)
-
ipp_serial_inject_mosaic.pl (modified) (3 diffs)
-
ipp_simulation_data.pl (modified) (10 diffs)
-
register_imfile.pl (modified) (4 diffs)
-
stack_skycell.pl (modified) (6 diffs)
-
warp_overlap.pl (modified) (8 diffs)
-
warp_skycell.pl (modified) (5 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 -
trunk/ippScripts/scripts/chip_imfile.pl
r13129 r13275 14 14 use PS::IPP::Metadata::Stats; 15 15 use Data::Dumper; 16 use PS::IPP::Config qw( 17 $PS_EXIT_SUCCESS 18 $PS_EXIT_UNKNOWN_ERROR19 $PS_EXIT_SYS_ERROR20 $PS_EXIT_CONFIG_ERROR21 $PS_EXIT_PROG_ERROR22 $PS_EXIT_DATA_ERROR23 $PS_EXIT_TIMEOUT_ERROR 24 );16 use PS::IPP::Config qw($PS_EXIT_SUCCESS 17 $PS_EXIT_UNKNOWN_ERROR 18 $PS_EXIT_SYS_ERROR 19 $PS_EXIT_CONFIG_ERROR 20 $PS_EXIT_PROG_ERROR 21 $PS_EXIT_DATA_ERROR 22 $PS_EXIT_TIMEOUT_ERROR 23 caturi 24 ); 25 25 my $ipprc = PS::IPP::Config->new(); # IPP configuration 26 use File::Spec;27 26 28 27 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 78 77 $ppImage .= " -dbname $dbname" if defined $dbname; 79 78 80 $input = $ipprc->convert_filename_absolute( $input );81 79 82 # Set output directory 83 if (defined $workdir) { 84 $workdir = $ipprc->convert_filename_absolute( $workdir ); 85 $workdir = File::Spec->catdir( $workdir, $exp_id ); 86 } else { 87 my ($vol, $dir, $file) = File::Spec->splitpath( $input ); 88 $workdir = $dir; 89 } 90 system "mkdir -p $workdir" unless -d $workdir; 80 $workdir = caturi( $workdir, $exp_id ) if defined $workdir; 91 81 92 ### Output file name --- must match camera configuration! 93 my $outputFile = "$exp_id.chp$chip_id"; 94 my $outputRoot = File::Spec->catfile( $workdir, $outputFile ); 82 my $outputRoot = $ipprc->file_prepare( "$exp_id.chp$chip_id", $workdir, $input ); 95 83 my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $class_id); 96 84 my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id); … … 104 92 print "outputBin1: $outputBin1\n"; 105 93 print "outputStats: $outputStats\n"; 106 94 107 95 my $command = "$ppImage -file $input $outputRoot -recipe PPIMAGE " . RECIPE . 108 96 " -stat $outputStats"; # Command to run ppImage … … 113 101 &my_die("Unable to perform ppImage: $error_code", $chip_id, $class_id, $error_code); 114 102 } 115 &my_die("Couldn't find expected output file: $outputImage\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ outputImage;116 &my_die("Couldn't find expected output file: $outputBin1\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ outputBin1;117 &my_die("Couldn't find expected output file: $outputBin2\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ outputBin2;118 &my_die("Couldn't find expected output file: $outputStats\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ outputStats;103 &my_die("Couldn't find expected output file: $outputImage\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage); 104 &my_die("Couldn't find expected output file: $outputBin1\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin1); 105 &my_die("Couldn't find expected output file: $outputBin2\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin2); 106 &my_die("Couldn't find expected output file: $outputStats\n", $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats); 119 107 120 108 # Get the statistics on the processed image 121 109 my $statsFile; # File handle 122 open $statsFile, $ outputStatsor &my_die("Can't open statistics file $outputStats: $!", $chip_id, $class_id, $PS_EXIT_SYS_ERROR);110 open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 123 111 my @contents = <$statsFile>; # Contents of file 124 112 close $statsFile; … … 131 119 132 120 # Add the processed file to the database 133 $outputImage = $ipprc->convert_filename_relative( $outputImage);134 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );135 136 121 my $bg = ($stats->bg_mean() or 'NAN'); 137 122 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); … … 155 140 exit($error_code); 156 141 } 157 158 unlink $outputStats;159 142 } 160 143 -
trunk/ippScripts/scripts/detrend_norm_apply.pl
r12800 r13275 14 14 use Data::Dumper; 15 15 16 use PS::IPP::Config qw( 17 $PS_EXIT_SUCCESS 18 $PS_EXIT_UNKNOWN_ERROR19 $PS_EXIT_SYS_ERROR20 $PS_EXIT_CONFIG_ERROR21 $PS_EXIT_PROG_ERROR22 $PS_EXIT_DATA_ERROR23 $PS_EXIT_TIMEOUT_ERROR 24 );16 use PS::IPP::Config qw($PS_EXIT_SUCCESS 17 $PS_EXIT_UNKNOWN_ERROR 18 $PS_EXIT_SYS_ERROR 19 $PS_EXIT_CONFIG_ERROR 20 $PS_EXIT_PROG_ERROR 21 $PS_EXIT_DATA_ERROR 22 $PS_EXIT_TIMEOUT_ERROR 23 caturi 24 ); 25 25 my $ipprc = PS::IPP::Config->new(); # IPP configuration 26 use File::Spec;27 26 28 27 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 82 81 } 83 82 84 $ input = $ipprc->convert_filename_absolute( $input );83 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir; 85 84 86 # Set output directory 87 if (defined $workdir) { 88 $workdir = $ipprc->convert_filename_absolute( $workdir ); 89 my $subdir = "$camera.$det_type.$det_id"; 90 $workdir = File::Spec->catdir( $workdir, $subdir ); 91 } else { 92 my ($vol, $dir, $file) = File::Spec->splitpath( $input ); 93 $workdir = $dir; 94 } 95 system "mkdir -p $workdir" unless -d $workdir; 96 97 # Output name 98 my $outputFile = "$camera.$det_type.norm.$det_id.$iter"; # Root name 99 my $outputRoot = File::Spec->catfile( $workdir, $outputFile ); 100 85 my $outputRoot = $ipprc->file_prepare( "$camera.$det_type.norm.$det_id.$iter", $workdir, $input ); 101 86 my $output = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $class_id); 102 87 my $b1name = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id); 103 88 my $b2name = $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $class_id); 104 105 89 my $statsName = $outputRoot . '.' . $class_id . '.stats'; # Statistics file 106 90 … … 116 100 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $class_id, $error_code); 117 101 } 118 &my_die("Can't find expected output file: $output", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless - e $output;119 &my_die("Can't find expected output file: $b1name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless - e $b1name;120 &my_die("Can't find expected output file: $b2name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless - e $b2name;121 &my_die("Can't find expected output file: $statsName", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless - e $statsName;102 &my_die("Can't find expected output file: $output", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($output); 103 &my_die("Can't find expected output file: $b1name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($b1name); 104 &my_die("Can't find expected output file: $b2name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($b2name); 105 &my_die("Can't find expected output file: $statsName", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($statsName); 122 106 123 107 # Get the statistics on the normalised image 124 my $statsFile; # File handle 125 open $statsFile, $statsName or &my_die("Can't open statistics file $statsName: $!\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 108 my $statsFile; # File handle 109 open $statsFile, $ipprc->file_resolve($statsName) or &my_die("Can't open statistics file $statsName: $!\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 110 &my_die("Can't open statistics file $statsName: $!\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless defined $statsFile; 126 111 my @contents = <$statsFile>; # Contents of file 127 112 close $statsFile; … … 130 115 or &my_die("Unable to parse metadata config", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 131 116 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 132 } 117 } 133 118 134 119 # Update the database 135 $output = $ipprc->convert_filename_relative( $output );136 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );137 138 120 my $bg = ($stats->bg_mean() or 'NAN'); 139 121 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); … … 153 135 exit($error_code); 154 136 } 155 156 unlink $statsName;157 137 } 158 138 -
trunk/ippScripts/scripts/detrend_norm_exp.pl
r12800 r13275 17 17 use PS::IPP::Metadata::List qw( parse_md_list ); 18 18 use Statistics::Descriptive; 19 use File::Temp qw( tempfile ); 19 20 20 use PS::IPP::Config qw( 21 $PS_EXIT_SUCCESS 22 $PS_EXIT_UNKNOWN_ERROR23 $PS_EXIT_SYS_ERROR24 $PS_EXIT_CONFIG_ERROR25 $PS_EXIT_PROG_ERROR26 $PS_EXIT_DATA_ERROR27 $PS_EXIT_TIMEOUT_ERROR 28 );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 ); … … 115 115 } 116 116 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 117 my ($list1File, $list1Name) = tempfile( "$camera.$det_type.norm.$det_id.$iter.b1.list.XXXX", UNLINK => 1 ); 118 my ($list2File, $list2Name) = tempfile( "$camera.$det_type.norm.$det_id.$iter.b2.list.XXXX", UNLINK => 1 ); 135 119 my @means; # Array of means 136 120 my @stdevs; # Array of stdevs 137 open my $list1File, '>' . $list1Name;138 open my $list2File, '>' . $list2Name;139 121 foreach 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"); 143 124 push @means, $file->{bg}; 144 125 push @stdevs, $file->{bg_stdev}; … … 148 129 149 130 # Output products 131 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir; 132 my $outputRoot = $ipprc->file_prepare( "$camera.$det_type.norm.$det_id.$iter", $workdir ); 150 133 my $jpeg1Name = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1 151 134 my $jpeg2Name = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2 … … 157 140 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 158 141 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); 160 143 } 161 144 … … 165 148 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 166 149 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); 168 151 } 169 152 } 170 171 # Add the result into the database172 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );173 153 174 154 unless ($no_update) { … … 183 163 &my_die("Unable to perform dettool -addnormalizedexp: $error_code", $det_id, $iter, $error_code); 184 164 } 185 186 unlink $list1Name;187 unlink $list2Name;188 165 } 189 166 -
trunk/ippScripts/scripts/detrend_process_exp.pl
r12800 r13275 18 18 use Statistics::Descriptive; 19 19 20 use PS::IPP::Config qw( 21 $PS_EXIT_SUCCESS 22 $PS_EXIT_UNKNOWN_ERROR23 $PS_EXIT_SYS_ERROR24 $PS_EXIT_CONFIG_ERROR25 $PS_EXIT_PROG_ERROR26 $PS_EXIT_DATA_ERROR27 $PS_EXIT_TIMEOUT_ERROR 28 );20 use 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 ); 29 29 my $ipprc = PS::IPP::Config->new(); # IPP configuration 30 use File:: Spec;30 use File::Temp qw( tempfile ); 31 31 32 32 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 115 115 } 116 116 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 118 my ($list1File, $list1Name) = tempfile( "$exp_tag.detproc.$det_id.b1.list.XXXX", UNLINK => 1 ); 119 my ($list2File, $list2Name) = tempfile( "$exp_tag.detproc.$det_id.b2.list.XXXX", UNLINK => 1 ); 135 120 my @means; # Array of means 136 121 my @stdevs; # Array of stdevs 137 open my $list1File, '>' . $list1Name;138 open my $list2File, '>' . $list2Name;139 122 foreach 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"); 143 125 push @means, $file->{bg}; 144 126 push @stdevs, $file->{bg_stdev}; … … 147 129 close $list2File; 148 130 149 # Output products 131 # Output files 132 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir; 133 my $outputRoot = $ipprc->file_prepare( "$exp_tag.detproc.$det_id", $workdir, ${$files}[0]->{path_base} ); 150 134 my $jpeg1 = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1 151 135 my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2 … … 161 145 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code); 162 146 } 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); 164 148 } 165 149 … … 173 157 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code); 174 158 } 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 } 181 162 182 163 unless ($no_update) { … … 192 173 exit($error_code); 193 174 } 194 195 unlink $list1Name;196 unlink $list2Name;197 175 } 198 176 -
trunk/ippScripts/scripts/detrend_process_imfile.pl
r12800 r13275 17 17 use PS::IPP::Metadata::Stats; 18 18 19 use PS::IPP::Config qw( 20 $PS_EXIT_SUCCESS 21 $PS_EXIT_UNKNOWN_ERROR22 $PS_EXIT_SYS_ERROR23 $PS_EXIT_CONFIG_ERROR24 $PS_EXIT_PROG_ERROR25 $PS_EXIT_DATA_ERROR26 $PS_EXIT_TIMEOUT_ERROR 27 );19 use PS::IPP::Config qw($PS_EXIT_SUCCESS 20 $PS_EXIT_UNKNOWN_ERROR 21 $PS_EXIT_SYS_ERROR 22 $PS_EXIT_CONFIG_ERROR 23 $PS_EXIT_PROG_ERROR 24 $PS_EXIT_DATA_ERROR 25 $PS_EXIT_TIMEOUT_ERROR 26 caturi 27 ); 28 28 my $ipprc = PS::IPP::Config->new(); # IPP configuration 29 use File::Spec;30 29 31 30 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 88 87 } 89 88 90 $ input_uri = $ipprc->convert_filename_absolute( $input_uri );89 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir; 91 90 92 # Set output directory 93 if (defined $workdir) { 94 $workdir = $ipprc->convert_filename_absolute( $workdir ); 95 my $subdir = "$camera.$det_type.$det_id"; 96 $workdir = File::Spec->catdir( $workdir, $subdir, $exp_tag ); 97 } else { 98 my ($vol, $dir, $file) = File::Spec->splitpath( $input_uri ); 99 $workdir = $dir; 100 } 101 system "mkdir -p $workdir" unless -d $workdir; 102 103 # Output files 104 my $outputFile = "$exp_tag.detproc.$det_id"; # Root name 105 my $outputRoot = File::Spec->catfile( $workdir, $outputFile ); 91 my $outputRoot = $ipprc->file_prepare( "$exp_tag.detproc.$det_id", $workdir, $input_uri ); 106 92 my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $class_id); 107 93 my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id); … … 120 106 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $class_id, $error_code); 121 107 } 122 &my_die("Couldn't find expected output file: $outputImage", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ outputImage;123 &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ outputStats;124 &my_die("Couldn't find expected output file: $outputBin1", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ outputBin1;125 &my_die("Couldn't find expected output file: $outputBin2", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ outputBin2;108 &my_die("Couldn't find expected output file: $outputImage", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage); 109 &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats); 110 &my_die("Couldn't find expected output file: $outputBin1", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin1); 111 &my_die("Couldn't find expected output file: $outputBin2", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin2); 126 112 127 113 # Get the statistics on the processed image 128 114 my $statsFile; # File handle 129 open $statsFile, "$outputStats"or die "Can't open statistics file $outputStats: $!\n";115 open $statsFile, $ipprc->file_resolve("$outputStats") or die "Can't open statistics file $outputStats: $!\n"; 130 116 my @contents = <$statsFile>; # Contents of file 131 117 close $statsFile; … … 135 121 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 136 122 } 137 138 # Take off the absolute path, to stuff into the database139 $outputImage = $ipprc->convert_filename_relative( $outputImage );140 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );141 123 142 124 my $bg = ($stats->bg_mean() or 'NAN'); … … 158 140 exit($error_code); 159 141 } 160 161 unlink $outputStats;162 142 } 163 143 -
trunk/ippScripts/scripts/detrend_reject_exp.pl
r12800 r13275 17 17 use PS::IPP::Metadata::List qw( parse_md_list ); 18 18 use Statistics::Descriptive; 19 use File::Spec; 20 21 use PS::IPP::Config qw( 22 $PS_EXIT_SUCCESS 23 $PS_EXIT_UNKNOWN_ERROR 24 $PS_EXIT_SYS_ERROR 25 $PS_EXIT_CONFIG_ERROR 26 $PS_EXIT_PROG_ERROR 27 $PS_EXIT_DATA_ERROR 28 $PS_EXIT_TIMEOUT_ERROR 29 ); 19 20 use 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 ); 30 29 my $ipprc = PS::IPP::Config->new(); # IPP configuration 31 30 … … 122 121 my $reject_meanstdev = rejection_limit( 'ENSEMBLE.MEANSTDEV', $det_type, $filter ); 123 122 124 my $logName = "$camera.$det_type.$det_id.$iter.detreject.log"; # Name for log 125 if (defined $workdir) { 126 $workdir = $ipprc->convert_filename_absolute( $workdir ); 127 my $subdir = "$camera.$det_type.$det_id"; 128 $workdir = File::Spec->catdir( $workdir, $subdir ); 129 system "mkdir -p $workdir" unless -d $workdir; 130 $logName = File::Spec->catfile( $workdir, $logName ); 131 } 123 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir; 124 125 my $logName = $ipprc->file_prepare( "$camera.$det_type.$det_id.$iter.detreject.log", $workdir ); # Name for log 126 132 127 my $logFile; 133 128 unless ($no_op) { 134 open $logFile, "> $logName" or &my_die("Unable to open log file $logName.\n", $det_id, $iter, $PS_EXIT_SYS_ERROR);129 $logFile = $ipprc->file_create_open( $logName ); 135 130 print $logFile "Ensemble mean " . $meanStats->mean() . " +/- " . $meanStats->standard_deviation . 136 131 ", stdev " . $stdevStats->mean() . " +/- " . $stdevStats->standard_deviation() . "\n\n"; -
trunk/ippScripts/scripts/detrend_reject_imfile.pl
r12979 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 ); … … 93 93 } 94 94 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 96 my ($list1File, $list1Name) = tempfile( "$exp_tag.detresid.$det_id.$iter.b1.list.XXXX", UNLINK => 1 ); 97 my ($list2File, $list2Name) = tempfile( "$exp_tag.detresid.$det_id.$iter.b2.list.XXXX", UNLINK => 1 ); 114 98 my @means; # Array of means 115 99 my @variances; # Array of variances 116 100 my @meanStdevs; # Array of mean stdevs 117 101 my @names; # Array of names (class_id) 118 open my $list1File, '>' . $list1Name;119 open my $list2File, '>' . $list2Name;120 102 foreach 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"); 124 105 push @means, $file->{bg}; 125 106 push @meanStdevs, $file->{bg_mean_stdev}; … … 131 112 close $list2File; 132 113 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; 116 my $outputRoot = $ipprc->file_prepare( "$exp_tag.detresid.$det_id.$iter", $workdir, ${$files}[0]->{path_base} ); 134 117 my $jpeg1Name = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1 135 118 my $jpeg2Name = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2 … … 146 129 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code); 147 130 } 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); 149 132 } 150 133 … … 158 141 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code); 159 142 } 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); 161 144 } 162 145 } … … 173 156 my $reject_exp_sn = rejection_limit( 'EXP.SN', $det_type, $filter ); 174 157 175 my $logName = "$exp_tag.detreject.$det_id.$iter.log"; # Name for log 176 $logName = File::Spec->catfile( $workdir, $logName ); 158 my $logName = caturi( $workdir, "$exp_tag.detreject.$det_id.$iter.log" ); # Name for log 177 159 my $logFile; 178 160 unless ($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 ); 180 162 } 181 163 … … 311 293 312 294 # Add the result into the database 313 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );314 315 295 my $bg = $mean; 316 296 my $bg_stdev = $stdev; … … 330 310 exit($error_code); 331 311 } 332 333 unlink $list1Name;334 unlink $list2Name;335 312 } 336 313 -
trunk/ippScripts/scripts/detrend_resid.pl
r12800 r13275 18 18 use Data::Dumper; 19 19 20 use PS::IPP::Config qw( 21 $PS_EXIT_SUCCESS 22 $PS_EXIT_UNKNOWN_ERROR23 $PS_EXIT_SYS_ERROR24 $PS_EXIT_CONFIG_ERROR25 $PS_EXIT_PROG_ERROR26 $PS_EXIT_DATA_ERROR27 $PS_EXIT_TIMEOUT_ERROR 28 );20 use 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 ); 29 29 my $ipprc = PS::IPP::Config->new(); # IPP configuration 30 use File::Spec;31 30 32 31 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 118 117 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR) unless defined $recipe; 119 118 120 # Set output directory 121 if (defined $workdir) { 122 $workdir = $ipprc->convert_filename_absolute( $workdir ); 123 my $subdir = "$camera.$det_type.$det_id"; 124 $workdir = File::Spec->catdir( $workdir, $subdir, $exp_tag ); 125 } else { 126 my ($vol, $dir, $file) = File::Spec->splitpath( $ipprc->convert_filename_absolute( $input_uri ) ); 127 $workdir = $dir; 128 } 129 system "mkdir -p $workdir" unless -d $workdir; 130 131 my $outputFile = "$exp_tag.detresid.$det_id.$iter"; # Root name 132 my $outputRoot = File::Spec->catfile( $workdir, $outputFile ); 133 119 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir; 120 121 my $outputRoot = $ipprc->file_prepare( "$exp_tag.detresid.$det_id.$iter", $workdir, $input_uri ); 134 122 my $outputName = $ipprc->filename("PPIMAGE.OUTPUT", $outputRoot, $class_id); 135 123 my $bin1Name = $ipprc->filename("PPIMAGE.BIN1", $outputRoot, $class_id); 136 124 my $bin2Name = $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $class_id); 137 138 125 my $outputStats = $outputRoot . '.' . $class_id . '.stats'; 139 140 $detrend = $ipprc->convert_filename_absolute( $detrend ) if defined $detrend;141 $input_uri = $ipprc->convert_filename_absolute( $input_uri );142 126 143 127 # Run ppImage … … 160 144 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $exp_tag, $class_id, $error_code); 161 145 } 162 &my_die("Couldn't find expected output file: $outputName", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ outputName;163 &my_die("Couldn't find expected output file: $outputStats", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ outputStats;164 &my_die("Couldn't find expected output file: $bin1Name", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ bin1Name;165 &my_die("Couldn't find expected output file: $bin2Name", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ bin2Name;146 &my_die("Couldn't find expected output file: $outputName", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputName); 147 &my_die("Couldn't find expected output file: $outputStats", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats); 148 &my_die("Couldn't find expected output file: $bin1Name", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin1Name); 149 &my_die("Couldn't find expected output file: $bin2Name", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin2Name); 166 150 167 151 # Get the statistics on the residual image 168 152 my $statsFile; # File handle 169 open $statsFile, $ outputStatsor &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR);153 open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR); 170 154 my @contents = <$statsFile>; # Contents of file 171 155 close $statsFile; … … 178 162 179 163 # Add the processed file to the database 180 $outputName = $ipprc->convert_filename_relative( $outputName );181 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );182 183 164 my $bg = ($stats->bg_mean() or 'NAN'); 184 165 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); … … 198 179 exit($error_code); 199 180 } 200 201 unlink $outputStats;202 181 } 203 182 -
trunk/ippScripts/scripts/detrend_stack.pl
r12800 r13275 18 18 use PS::IPP::Metadata::Stats; 19 19 20 use PS::IPP::Config qw( 21 $PS_EXIT_SUCCESS 22 $PS_EXIT_UNKNOWN_ERROR23 $PS_EXIT_SYS_ERROR24 $PS_EXIT_CONFIG_ERROR25 $PS_EXIT_PROG_ERROR26 $PS_EXIT_DATA_ERROR27 $PS_EXIT_TIMEOUT_ERROR 28 );20 use 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 ); 29 29 my $ipprc = PS::IPP::Config->new(); # IPP configuration 30 use File::Spec;31 30 32 31 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 98 97 } 99 98 100 # Set output directory 101 if (defined $workdir) { 102 $workdir = $ipprc->convert_filename_absolute( $workdir ); 103 my $subdir = "$camera.$det_type.$det_id"; 104 $workdir = File::Spec->catdir( $workdir, $subdir ); 105 } else { 106 my $example = $ipprc->convert_filename_absolute( ${$files}[0]->{uri} ); # Example file 107 my ($vol, $dir, $file) = File::Spec->splitpath( $example ); 108 $workdir = $dir; 109 } 110 system "mkdir -p $workdir" unless -d $workdir; 99 $workdir = caturi( $workdir, "$camera.$det_type.$det_id" ) if defined $workdir; 111 100 112 # Stack the files 113 my $outputFile = "$camera.$det_type.$det_id.$iter.$class_id"; # Root name 114 my $outputRoot = File::Spec->catfile( $workdir, $outputFile ); 101 my $outputRoot = $ipprc->file_prepare( "$camera.$det_type.$det_id.$iter.$class_id", $workdir, ${$files}[0]->{uri} ); 115 102 my $outputStack = $outputRoot . '.fits'; # Output name 116 103 my $outputStats = $outputRoot . '.stats'; # Statistics name 117 104 105 # Stack the files 118 106 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 119 107 unless ($no_op) { 120 108 my $command = "$ppMerge $outputStack"; # Command to run 121 109 foreach my $file (@$files) { 122 my $uri = $file->{uri}; # URI for input file 123 $uri = $ipprc->convert_filename_absolute($uri); 124 $command .= ' ' . $uri; 110 $command .= ' ' . $file->{uri}; 125 111 } 126 112 $command .= " -recipe PPMERGE $recipe"; … … 134 120 &my_die("Unable to perform ppMerge: $error_code", $det_id, $iter, $class_id, $error_code); 135 121 } 136 &my_die("Unable to find expected output file: $outputStack\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ outputStack;137 &my_die("Unable to find expected output file: $outputStats\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ outputStats;122 &my_die("Unable to find expected output file: $outputStack\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStack); 123 &my_die("Unable to find expected output file: $outputStats\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats); 138 124 139 125 # Get the statistics on the stacked image 140 open(my $statsFile, "$outputStats") or126 open(my $statsFile, $ipprc->file_resolve("$outputStats")) or 141 127 &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 142 128 my $contents = do { local $/; <$statsFile> }; # Contents of file … … 156 142 157 143 # Add the resultant into the database 158 $outputStack = $ipprc->convert_filename_relative($outputStack);159 144 unless ($no_update) { 160 145 my $command = "$dettool -addstacked -det_id $det_id -iteration $iter -class_id $class_id" . … … 170 155 exit($error_code); 171 156 } 172 173 unlink $outputStats;174 157 } 175 158 -
trunk/ippScripts/scripts/diff_skycell.pl
r13118 r13275 19 19 use Data::Dumper; 20 20 21 use PS::IPP::Config qw( 22 $PS_EXIT_SUCCESS 23 $PS_EXIT_UNKNOWN_ERROR24 $PS_EXIT_SYS_ERROR25 $PS_EXIT_CONFIG_ERROR26 $PS_EXIT_PROG_ERROR27 $PS_EXIT_DATA_ERROR28 $PS_EXIT_TIMEOUT_ERROR 29 );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 ); 30 30 my $ipprc = PS::IPP::Config->new(); # IPP configuration 31 use File::Spec;32 31 33 32 use constant POIS_OPTIONS => '-v -B 1000'; … … 89 88 my $camera; # Camera 90 89 foreach my $file (@$files) { 91 my $uri = $ipprc->convert_filename_absolute( $file->{uri} ); # URI for file92 90 if (defined $file->{template} and $file->{template}) { 93 $template = $ uri;94 } else { 95 $input = $ uri;91 $template = $file->{uri}; 92 } else { 93 $input = $file->{uri}; 96 94 } 97 95 if (defined $tess_id) { … … 119 117 $ipprc->define_camera($camera); 120 118 121 ### Working directory122 if (defined $workdir) {123 $workdir = $ipprc->convert_filename_absolute( $workdir );124 $workdir = File::Spec->catdir( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id );125 } else {126 my ($vol, $dir, $file) = File::Spec->splitpath( $input );127 $workdir = $dir;128 }129 system "mkdir -p $workdir" unless -d $workdir;130 119 131 120 # Get the output filenames 132 my $outputFile = "$tess_id.$skycell_id.dif$diff_id"; # Root name 133 my $outputRoot = File::Spec->catfile( $workdir, $outputFile ); 134 121 $workdir = caturi( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id ) if defined $workdir; 122 my $outputRoot = $ipprc->file_prepare( "$tess_id.$skycell_id.dif$diff_id", $workdir, $input ); 135 123 my $outputName = $outputRoot . ".fits"; 136 124 my $bin1Name = $ipprc->filename("PPIMAGE.BIN1", $outputRoot); … … 138 126 my $outputStats = $outputRoot . '.stats'; 139 127 128 129 ### XXX We have to play around some here, because pois can't use Nebulous 130 my $outputNameResolved = $ipprc->file_create( $outputName ); 131 my $templateResolved = $ipprc->file_resolve( $template ); 132 my $inputResolved = $ipprc->file_resolve( $input ); 133 140 134 # Perform subtraction 141 135 my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 142 136 unless ($no_op) { 143 my $command = "$pois " . POIS_OPTIONS() . " $template $input $outputName"; # Command to run pois137 my $command = "$pois " . POIS_OPTIONS() . " $templateResolved $inputResolved $outputNameResolved"; # Command to run pois 144 138 145 139 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 149 143 &my_die("Unable to perform ppImage: $error_code", $diff_id, $error_code); 150 144 } 151 &my_die("Couldn't find expected output file: $outputName", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ outputName;152 # &my_die("Couldn't find expected output file: $bin1Name", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ bin1Name;153 # &my_die("Couldn't find expected output file: $bin2Name", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ bin2Name;154 # &my_die("Couldn't find expected output file: $outputStats", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ outputStats;145 &my_die("Couldn't find expected output file: $outputName", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputName); 146 # &my_die("Couldn't find expected output file: $bin1Name", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin1Name); 147 # &my_die("Couldn't find expected output file: $bin2Name", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin2Name); 148 # &my_die("Couldn't find expected output file: $outputStats", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats); 155 149 156 150 # Get the statistics on the residual image 157 151 if (0) { ### Disabled because pois doesn't output stats yet 158 152 my $statsFile; # File handle 159 open $statsFile, $ outputStatsor &my_die("Can't open statistics file $outputStats: $!", $diff_id, $PS_EXIT_SYS_ERROR);153 open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $diff_id, $PS_EXIT_SYS_ERROR); 160 154 my @contents = <$statsFile>; # Contents of file 161 155 close $statsFile; … … 167 161 168 162 # Add the processed file to the database 169 $outputName = $ipprc->convert_filename_relative( $outputName );170 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );171 172 163 my $bg = ($stats->bg_mean() or 'NAN'); 173 164 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); … … 187 178 &my_die("Unable to perform difftool -adddiffskyfile: $error_code", $diff_id, $error_code); 188 179 } 189 190 # unlink $outputStats;191 180 } 192 181 -
trunk/ippScripts/scripts/ipp_datapath.pl
r10572 r13275 9 9 die "No filename specified.\n" if scalar @ARGV != 1; 10 10 11 print $ipprc-> convert_filename_absolute(shift @ARGV) . "\n";11 print $ipprc->file_resolve(shift @ARGV) . "\n"; 12 12 13 13 1; -
trunk/ippScripts/scripts/ipp_serial_inject_mosaic.pl
r13018 r13275 5 5 6 6 use IPC::Cmd 0.36 qw( can_run run ); 7 use PS::IPP::Config ;7 use PS::IPP::Config qw( caturi ); 8 8 use Data::Dumper; 9 use File::Spec;10 9 11 10 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 14 13 my ($camera, # Camera used 15 14 $telescope, # Telescope used 16 $workdir, # Working directory to append17 15 $dbname, # Database name 16 $workdir, # Working directory 17 $path, # Path to data 18 18 ); 19 19 GetOptions( 20 'camera|c=s' => \$camera,20 'camera|c=s' => \$camera, 21 21 'telescope|t=s' => \$telescope, 22 'workdir=s' => \$workdir, 23 'dbname=s' => \$dbname, 22 'workdir=s' => \$workdir, 23 'path=s' => \$path, 24 'dbname=s' => \$dbname, 24 25 ) or pod2usage( 2 ); 25 26 26 27 pod2usage( 27 -msg => "Required options: --camera --telescope --workdir -- dbname",28 -msg => "Required options: --camera --telescope --workdir --path --dbname", 28 29 -exitval => 3, 29 ) unless defined $camera and defined $telescope and defined $workdir and defined $dbname; 30 ) unless defined $camera 31 and defined $telescope 32 and defined $workdir 33 and defined $path 34 and defined $dbname; 30 35 31 36 my $ipprc = PS::IPP::Config->new(); # IPP configuration 32 my $workdir_abs = $ipprc->convert_filename_absolute( $workdir );33 37 34 38 # Look for programs we need … … 36 40 my $pxinject = can_run('pxinject') or (warn "Can't find pxinject" and $missing_tools = 1); 37 41 42 if (scalar @ARGV == 0) { 43 die "No exposures provided.\n"; 44 } 45 38 46 # Inject new data into the database 39 if (scalar @ARGV != 0) { 40 my @classes; # Names of the classes 41 my @files; # What to add to the filename for each class 42 my $imfiles; 43 my $add_dir; # Add directory name to get file name? 44 if ($camera eq "MEGACAM") { 45 for (my $i = 0; $i < 36; $i++) { 46 push @classes, sprintf("ccd%02d", $i); 47 push @files, sprintf(".ccd%02d", $i); 48 } 49 } elsif ($camera eq "MCSHORT") { 50 @classes = ( 'ccd12', 'ccd13', 'ccd14', 'ccd21', 'ccd22', 'ccd23' ); 51 @files = ( '.ccd12', '.ccd13', '.ccd14', '.ccd21', '.ccd22', '.ccd23' ); 52 53 } elsif ($camera eq "CTIO_MOSAIC2") { 54 @classes = (); 55 @files = (); 56 } elsif ($camera eq "TC3") { 57 @classes = ( 'CCID58-1-06b2', 'CCID45-1-14A', 'CCID45-1-11A', 'CCID45-1-22A', 58 'CCID45-1-04C', 'CCID45-1-13A', 'CCID45-1-05A', 'CCID45-1-19A' ); 59 @files = ( '00', '01', '10', '11', '20', '21', '30', '31' ); 60 $add_dir = 1; 61 } elsif ($camera eq "SIMMOSAIC") { 62 @classes = ( 'Chip00', 'Chip01', 'Chip10', 'Chip11' ); 63 @files = ( '.Chip00', '.Chip01', '.Chip10', '.Chip11' ); 64 } elsif ($camera eq "SIMTEST") { 65 @classes = (); 66 @files = (); 67 } else { 68 die "Unrecognised camera name: $camera.\n"; 47 my @classes; # Names of the classes 48 my @files; # What to add to the filename for each class 49 my $imfiles; 50 my $add_dir; # Add directory name to get file name? 51 if ($camera eq "MEGACAM") { 52 for (my $i = 0; $i < 36; $i++) { 53 push @classes, sprintf("ccd%02d", $i); 54 push @files, sprintf(".ccd%02d", $i); 55 } 56 } elsif ($camera eq "MCSHORT") { 57 @classes = ( 'ccd12', 'ccd13', 'ccd14', 'ccd21', 'ccd22', 'ccd23' ); 58 @files = ( '.ccd12', '.ccd13', '.ccd14', '.ccd21', '.ccd22', '.ccd23' ); 59 } elsif ($camera eq "CTIO_MOSAIC2") { 60 @classes = (); 61 @files = (); 62 } elsif ($camera eq "TC3") { 63 @classes = ( 'CCID58-1-06b2', 'CCID45-1-14A', 'CCID45-1-11A', 'CCID45-1-22A', 64 'CCID45-1-04C', 'CCID45-1-13A', 'CCID45-1-05A', 'CCID45-1-19A' ); 65 @files = ( '00', '01', '10', '11', '20', '21', '30', '31' ); 66 $add_dir = 1; 67 } elsif ($camera eq "SIMMOSAIC") { 68 @classes = ( 'Chip00', 'Chip01', 'Chip10', 'Chip11' ); 69 @files = ( '.Chip00', '.Chip01', '.Chip10', '.Chip11' ); 70 } elsif ($camera eq "SIMTEST") { 71 @classes = (); 72 @files = (); 73 } else { 74 die "Unrecognised camera name: $camera.\n"; 75 } 76 77 foreach my $exp ( @ARGV ) { 78 my $command = "$pxinject -newExp -exp_id $exp -inst $camera -telescope $telescope -workdir $workdir -dbname $dbname -imfiles " . (scalar @classes or 1) ; # Command to run 79 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 80 run( command => $command, verbose => 1 ); 81 die "Unable to inject $exp: $error_code\n" if not $success; 82 83 my @line = split(/\s+/, $$stdout_buf[0]); # The output line, containing the exposure tag 84 my $exp_tag = $line[2]; # The exposure tag 85 for (my $i = 0; $i < scalar @classes; $i++) { 86 my $class_id = $classes[$i]; 87 my $file_id = $files[$i]; 88 my $filename = $exp . $file_id . '.fits'; 89 $filename = caturi( $exp, $filename ) if defined $add_dir; 90 $filename = caturi( $path, $filename ); 91 92 die "Unable to find file $filename" unless -f $ipprc->file_resolve( $filename ); 93 94 $filename = $ipprc->convert_filename_relative( $filename ); 95 my $command = "$pxinject -newImfile -exp_tag $exp_tag -class chip -class_id $class_id -uri $filename -dbname $dbname"; # Command to run 96 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 97 run( command => $command, verbose => 1 ); 98 die "Unable to inject $exp $class_id: $error_code\n" if not $success; 69 99 } 70 100 71 foreach my $exp ( @ARGV ) { 72 my $command = "$pxinject -newExp -exp_id $exp -inst $camera -telescope $telescope -workdir $workdir -dbname $dbname -imfiles " . (scalar @classes or 1) ; # Command to run 101 if (scalar @classes == 0) { 102 my $filename = "$exp.fits"; 103 $filename = caturi( $exp, $filename ) if defined $add_dir; 104 $filename = caturi( $path, $filename ); 105 106 die "Unable to find file $filename" unless -f $ipprc->file_resolve( $filename ); 107 108 $filename = $ipprc->convert_filename_relative( $filename ); 109 my $command = "$pxinject -newImfile -exp_tag $exp_tag -class fpa -class_id fpa -dbname $dbname -uri $filename"; # Command to run 73 110 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 74 111 run( command => $command, verbose => 1 ); 75 die "Unable to inject $exp: $error_code\n" if not $success; 76 77 my @line = split(/\s+/, $$stdout_buf[0]); # The output line, containing the exposure tag 78 my $exp_tag = $line[2]; # The exposure tag 79 for (my $i = 0; $i < scalar @classes; $i++) { 80 my $class_id = $classes[$i]; 81 my $file_id = $files[$i]; 82 my $filename = "$exp$file_id.fits"; 83 $filename = File::Spec->catfile( $exp, $filename ) if defined $add_dir; 84 $filename = File::Spec->catfile( $workdir_abs, $filename); 85 $filename = $ipprc->convert_filename_relative( $filename ); 86 my $command = "$pxinject -newImfile -exp_tag $exp_tag -class chip -class_id $class_id -uri $filename -dbname $dbname"; # Command to run 87 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 88 run( command => $command, verbose => 1 ); 89 die "Unable to inject $exp $class_id: $error_code\n" if not $success; 90 } 112 die "Unable to inject $exp imfile: $error_code\n" if not $success; 113 } 91 114 92 if (scalar @classes == 0) {93 my $filename = "$exp.fits";94 $filename = File::Spec->catfile( $exp, $filename ) if defined $add_dir;95 $filename = File::Spec->catfile( $workdir_abs, $filename);96 $filename = $ipprc->convert_filename_relative( $filename );97 my $command = "$pxinject -newImfile -exp_tag $exp_tag -class fpa -class_id fpa -dbname $dbname -uri $filename"; # Command to run98 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =99 run( command => $command, verbose => 1 );100 die "Unable to inject $exp imfile: $error_code\n" if not $success;101 }102 103 }104 115 } 105 116 106 117 END { 107 118 my $status = $?; 108 system("sync") == 0109 or die "failed to execute sync: $!" ;110 $? = $status;119 system("sync") == 0 120 or die "failed to execute sync: $!" ; 121 $? = $status; 111 122 } 112 123 -
trunk/ippScripts/scripts/ipp_simulation_data.pl
r13122 r13275 13 13 use Pod::Usage qw( pod2usage ); 14 14 use PS::IPP::Config qw( 15 $PS_EXIT_SUCCESS 16 $PS_EXIT_UNKNOWN_ERROR 17 $PS_EXIT_SYS_ERROR 18 $PS_EXIT_CONFIG_ERROR 19 $PS_EXIT_PROG_ERROR 20 $PS_EXIT_DATA_ERROR 21 $PS_EXIT_TIMEOUT_ERROR 22 ); 15 $PS_EXIT_SUCCESS 16 $PS_EXIT_UNKNOWN_ERROR 17 $PS_EXIT_SYS_ERROR 18 $PS_EXIT_CONFIG_ERROR 19 $PS_EXIT_PROG_ERROR 20 $PS_EXIT_DATA_ERROR 21 $PS_EXIT_TIMEOUT_ERROR 22 caturi 23 ); 23 24 24 25 my $ipprc = PS::IPP::Config->new(); # IPP configuration … … 28 29 $telescope, # Telesceope name 29 30 $dbname, # Database name 31 $path, # Path to data 30 32 $workdir, # Working directory for data 31 33 $no_update # Don't update the database … … 37 39 'telescope=s' => \$telescope, 38 40 'dbname=s' => \$dbname, 41 'path=s' => \$path, 39 42 'workdir=s' => \$workdir, 40 43 'no-update' => \$no_update, … … 44 47 45 48 pod2usage( 46 -msg => "Required options: --name -- camera --telescope --dbname",49 -msg => "Required options: --name --path --camera --telescope --dbname", 47 50 -exitval => 3, 48 51 ) unless 49 52 defined $name and 53 defined $path and 50 54 defined $camera and 51 55 defined $telescope and 52 56 defined $dbname; 53 57 58 $workdir = $path if not defined $workdir; 54 59 55 60 # Look for programs we need … … 64 69 exit($PS_EXIT_CONFIG_ERROR); 65 70 } 66 67 $workdir = $ipprc->convert_filename_absolute( $workdir );68 71 69 72 # Number of bias images … … 120 123 my $basename; # Output base filename 121 124 ( $basename, $counter ) = filename( $name, $counter ); 122 my $filename = File::Spec->catfile( $workdir, $basename ) if defined $workdir; # File name125 my $filename = caturi( $path, $basename ); 123 126 run( command => "$ppSim -camera $camera -type BIAS $filename", 124 127 verbose => 1 ) or die "Unable to run ppSim"; 125 run( command => "$inject --camera $camera --telescope $telescope -- workdir $workdir " .128 run( command => "$inject --camera $camera --telescope $telescope --path $path --workdir $workdir " . 126 129 "--dbname $dbname $basename", 127 130 verbose => 1 ) or die "Unable to inject file."; … … 132 135 my $basename; # Output base filename 133 136 ( $basename, $counter ) = filename( $name, $counter ); 134 my $filename = File::Spec->catfile( $workdir, $basename ) if defined $workdir; # File name137 my $filename = caturi( $path, $basename ); 135 138 run ( command => "$ppSim -camera $camera -type DARK -exptime $exptime $filename", 136 139 verbose => 1 ) or die "Unable to run ppSim"; 137 run( command => "$inject --camera $camera --telescope $telescope -- workdir $workdir " .140 run( command => "$inject --camera $camera --telescope $telescope --path $path --workdir $workdir " . 138 141 "--dbname $dbname $basename", 139 142 verbose => 1 ) or die "Unable to inject file."; … … 146 149 my $basename; # Output base filename 147 150 ( $basename, $counter ) = filename( $name, $counter ); 148 my $filename = File::Spec->catfile( $workdir, $basename ) if defined $workdir; # File name151 my $filename = caturi( $path, $basename ); 149 152 run( command => "$ppSim -camera $camera -type FLAT -filter $filter -exptime $exptime $filename", 150 153 verbose => 1 ) or die "Unable to run ppSim"; 151 run( command => "$inject --camera $camera --telescope $telescope -- workdir $workdir " .154 run( command => "$inject --camera $camera --telescope $telescope --path $path --workdir $workdir " . 152 155 "--dbname $dbname $basename", 153 156 verbose => 1 ) or die "Unable to inject file."; … … 174 177 my $basename; # Output base filename 175 178 ( $basename, $counter ) = filename( $name, $counter ); 176 my $filename = File::Spec->catfile( $workdir, $basename ) if defined $workdir; # File name179 my $filename = caturi( $path, $basename ); 177 180 run( command => "$ppSim -camera $camera -type OBJECT -filter $filter -exptime $exptime " . 178 181 "-skyrate $sky -ra $ra -dec $dec -pa $pa -scale $scale -zp $zp -seeing $seeing $filename", 179 182 verbose => 1 ) or die "Unable to run ppSim"; 180 run( command => "$inject --camera $camera --telescope $telescope -- workdir $workdir " .181 "--dbname $dbname $basename ",183 run( command => "$inject --camera $camera --telescope $telescope --path $path --workdir $workdir " . 184 "--dbname $dbname $basename", 182 185 verbose => 1 ) or die "Unable to inject file."; 183 186 } … … 199 202 } 200 203 201 202 203 204 204 __END__ -
trunk/ippScripts/scripts/register_imfile.pl
r12934 r13275 59 59 60 60 my $RECIPE = "PPSTATS_PHASE0"; # Recipe to use for ppStats 61 # use constant RECIPE => "PPSTATS_PHASE0"; # Recipe to use for ppStats62 61 63 62 # These values should be constant for all components … … 104 103 ); 105 104 106 # Resolve the input URI107 $uri = $ipprc->convert_filename_absolute($uri);108 109 105 # Run ppStats on the input file 110 106 my $stats; … … 131 127 unless ($stats->parse($metadata)) { 132 128 warn ("Unable to find all values"); 133 &my_die ($exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 134 # XXX is this a programming or a config error? 129 &my_die ($exp_tag, $class_id, $PS_EXIT_CONFIG_ERROR); 135 130 } 136 131 137 132 if (0) { 138 # XXX for a test, randomly declare a failure and return to pantasks139 my $rnd = rand(1);140 if ($rnd > 0.5) {141 warn ("random failure");142 &my_die ($exp_tag, $class_id, $PS_EXIT_DATA_ERROR);143 }144 }133 # XXX for a test, randomly declare a failure and return to pantasks 134 my $rnd = rand(1); 135 if ($rnd > 0.5) { 136 warn ("random failure"); 137 &my_die ($exp_tag, $class_id, $PS_EXIT_DATA_ERROR); 138 } 139 } 145 140 } 146 141 … … 175 170 unless ($success) { 176 171 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 177 # XXX if we can't run -addprocessedimfile, we can't actually set the 178 # error code. 179 # XXX if this is not a database error, it is probably a 180 # programming error (in regtool or the passed args) 172 # If we can't run -addprocessedimfile, we can't actually set the error code. If this is not 173 # a database error, it is probably a programming error (in regtool or the passed args) 181 174 warn ("Unable to perform regtool -addprocessedimfile: $error_code"); 182 175 exit($error_code); -
trunk/ippScripts/scripts/stack_skycell.pl
r13120 r13275 19 19 use Data::Dumper; 20 20 21 use PS::IPP::Config qw( 22 $PS_EXIT_SUCCESS 23 $PS_EXIT_UNKNOWN_ERROR24 $PS_EXIT_SYS_ERROR25 $PS_EXIT_CONFIG_ERROR26 $PS_EXIT_PROG_ERROR27 $PS_EXIT_DATA_ERROR28 $PS_EXIT_TIMEOUT_ERROR 29 );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 ); 30 30 my $ipprc = PS::IPP::Config->new(); # IPP configuration 31 use File::Spec;32 31 33 32 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 86 85 my $camera; # Camera 87 86 foreach my $file (@$files) { 88 my $uri = $ipprc->convert_filename_absolute( $file->{uri} ); # URI for file 89 $inputList .= "$uri "; 87 $inputList .= $file->{uri} . ' '; 90 88 if (defined $tess_id) { 91 89 &my_die("Tesselation identifiers don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless … … 110 108 $ipprc->define_camera($camera); 111 109 112 113 ### Working directory114 if (defined $workdir) {115 $workdir = $ipprc->convert_filename_absolute( $workdir );116 $workdir = File::Spec->catdir( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id );117 } else {118 my ($vol, $dir, $file) = File::Spec->splitpath( $ipprc->convert_filename_absolute( $$files[0]->{uri} ) );119 $workdir = $dir;120 }121 system "mkdir -p $workdir" unless -d $workdir;122 123 110 # Get the output filenames 124 my $outputFile = "$tess_id.$skycell_id.stk$stack_id"; # Root name 125 my $outputRoot = File::Spec->catfile( $workdir, $outputFile ); 126 111 $workdir = caturi( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id ) if defined $workdir; 112 my $outputRoot = $ipprc->file_prepare( "$tess_id.$skycell_id.stk$stack_id", $workdir, $$files[0]->{uri} ); 127 113 my $outputName = $outputRoot . ".fits"; 128 114 #my $bin1Name = $ipprc->filename("PPSTAC.BIN1", $outputRoot); … … 141 127 &my_die("Unable to perform ppImage: $error_code", $stack_id, $error_code); 142 128 } 143 &my_die("Couldn't find expected output file: $outputName", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ outputName;144 # &my_die("Couldn't find expected output file: $bin1Name", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ bin1Name;145 # &my_die("Couldn't find expected output file: $bin2Name", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ bin2Name;146 # &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ outputStats;129 &my_die("Couldn't find expected output file: $outputName", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputName); 130 # &my_die("Couldn't find expected output file: $bin1Name", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin1Name); 131 # &my_die("Couldn't find expected output file: $bin2Name", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin2Name); 132 # &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats); 147 133 148 134 # Get the statistics on the residual image 149 135 if (0) { ### Disabled because ppStac doesn't output stats yet 150 136 my $statsFile; # File handle 151 open $statsFile, $ outputStatsor &my_die("Can't open statistics file $outputStats: $!", $stack_id, $PS_EXIT_SYS_ERROR);137 open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $stack_id, $PS_EXIT_SYS_ERROR); 152 138 my @contents = <$statsFile>; # Contents of file 153 139 close $statsFile; … … 159 145 160 146 # Add the processed file to the database 161 $outputName = $ipprc->convert_filename_relative( $outputName );162 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );163 164 147 my $bg = ($stats->bg_mean() or 'NAN'); 165 148 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); … … 179 162 &my_die("Unable to perform stacktool -addsumskyfile: $error_code", $stack_id, $error_code); 180 163 } 181 182 # unlink $outputStats;183 164 } 184 165 -
trunk/ippScripts/scripts/warp_overlap.pl
r13176 r13275 17 17 use PS::IPP::Metadata::Stats; 18 18 use PS::IPP::Metadata::List qw( parse_md_list ); 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 metadataLookupStr 29 ); 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 metadataLookupStr 29 caturi 30 ); 30 31 my $ipprc = PS::IPP::Config->new(); # IPP configuration 31 32 use File::Spec; … … 82 83 } 83 84 84 # Make sure everything is from the same exposure, and get the exposure tag85 my $exp_tag; # Exposure tag86 foreach my $imfile ( @$imfiles ) {87 unless (defined $exp_tag) {88 $exp_tag = $imfile->{exp_tag};89 } elsif ($exp_tag ne $imfile->{exp_tag}) {90 &my_die("Multiple exposures in the same warp.", $warp_id, $PS_EXIT_SYS_ERROR);91 }92 }93 94 # Set output directory95 if (defined $workdir) {96 $workdir = $ipprc->convert_filename_absolute( $workdir );97 } else {98 my $example = $ipprc->convert_filename_absolute( $$imfiles[0]->{uri} );99 my ($vol, $dir, $file) = File::Spec->splitpath( $example );100 $workdir = $dir;101 }102 system "mkdir -p $workdir" unless -d $workdir;103 104 105 85 # Determine the imfile/skycell overlaps 106 86 my @overlaps = (); … … 111 91 my $tessellations = $ipprc->tessellations(); # Hash of defined tessellations 112 92 foreach my $tess_id ( keys %$tessellations ) { 93 ### Because DVO doesn't use psModules, it doesn't understand Nebulous --- check 94 my $uri = URI->new( $$tessellations{$tess_id} ); 95 if (defined $uri->scheme() and $uri->scheme() eq 'neb') { 96 &my_die("Tessellation $tess_id refers to a Nebulous path: $$tessellations{$tess_id}", $warp_id, $PS_EXIT_CONFIG_ERROR); 97 } 98 113 99 my $tess_dir = $ipprc->convert_filename_absolute( $$tessellations{$tess_id} ); # Catdir for DVO 114 100 print STDERR "tessellation: $tess_id, $tess_dir\n"; 115 101 116 102 my $imfile = $imfiles->[0]; 117 my $camRoot = $i pprc->convert_filename_absolute( $imfile->{cam_path_base} );103 my $camRoot = $imfile->{cam_path_base}; 118 104 my $psastroFile = $ipprc->filename("PSASTRO.OUTPUT", $camRoot); # MEF psastro output 119 105 … … 123 109 124 110 # run the dvoImageOverlaps program to get the overlaps with this image 125 my $command = "$dvoImageOverlaps -D CATDIR $tess_dir $psastroFile";111 my $command = "$dvoImageOverlaps -D CATDIR $tess_dir " . $ipprc->file_resolve($psastroFile); 126 112 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 127 113 run(command => $command, verbose => 1); … … 145 131 if ($fileLevel eq "chip") { 146 132 my $class_id = $imfile->{class_id}; 147 my $chipRoot = $ipprc-> convert_filename_absolute( $imfile->{chip_path_base} );133 my $chipRoot = $ipprc->file_resolve( $imfile->{chip_path_base} ); 148 134 my $extname = $ipprc->extname_rule("CMF.HEAD", $class_id); # MEF psastro output 149 135 … … 176 162 # Extract the skycells to images, used as warp templates. 177 163 foreach my $skycell_id (@unique_skycells) { 178 my $skyDir = File::Spec->catdir($workdir, "tess_" . $tess_id, "sky_" . $skycell_id ); 179 system "mkdir -p $skyDir" unless -d $skyDir; 180 my $skyFile = File::Spec->catfile( $skyDir , $skycell_id ); 181 my $command = "$dvoImageExtract -D CATDIR $tess_dir $skycell_id -o $skyFile"; 182 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 183 run(command => $command, verbose => 1); 184 unless ($success) { 185 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 186 &my_die("Unable to perform dvoImageExtract: $error_code", $warp_id, $error_code); 164 my $skyDir = caturi($workdir, "tess_" . $tess_id, "sky_" . $skycell_id ); 165 my $skyFile = $ipprc->file_prepare( $skycell_id, $skyDir ); 166 unless ($ipprc->file_exists( $skyFile )) { 167 my $skyFileResolved = $ipprc->file_create( $skyFile ); # Resolved filename, for Nebulous 168 my $command = "$dvoImageExtract -D CATDIR $tess_dir $skycell_id -o $skyFileResolved"; 169 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 170 run(command => $command, verbose => 1); 171 unless ($success) { 172 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 173 &my_die("Unable to perform dvoImageExtract: $error_code", $warp_id, $error_code); 174 } 187 175 } 188 176 } … … 202 190 203 191 # Generate a MDC file with the overlaps 204 my $overlapName = File::Spec->catfile( $workdir, 'overlaps.wrp' . $warp_id . '.mdc' ); 205 open my $overlapFile, "> $overlapName" or die "Unable to open mdc file $overlapName"; 192 my ($overlapFile, $overlapName) = tempfile( 'overlaps.wrp' . $warp_id . '.mdc.XXXX', UNLINK => 1 ); 206 193 print $overlapFile "warpSkyCellMap MULTI\n\n"; 207 194 foreach my $overlap (@overlaps) { … … 229 216 exit($error_code); 230 217 } 231 232 unlink $overlapName;233 218 } 234 219 -
trunk/ippScripts/scripts/warp_skycell.pl
r13112 r13275 18 18 use PS::IPP::Metadata::List qw( parse_md_list ); 19 19 20 use PS::IPP::Config qw( 21 $PS_EXIT_SUCCESS 22 $PS_EXIT_UNKNOWN_ERROR23 $PS_EXIT_SYS_ERROR24 $PS_EXIT_CONFIG_ERROR25 $PS_EXIT_PROG_ERROR26 $PS_EXIT_DATA_ERROR27 $PS_EXIT_TIMEOUT_ERROR 28 );20 use 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 ); 29 29 my $ipprc = PS::IPP::Config->new(); # IPP configuration 30 30 use File::Spec; 31 use File::Temp qw( tempfile ); 31 32 32 33 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 84 85 } 85 86 86 # Set output directory 87 if (defined $workdir) { 88 $workdir = $ipprc->convert_filename_absolute( $workdir ); 89 $workdir = File::Spec->catdir( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id ); 90 } else { 91 my $example = $ipprc->convert_filename_absolute( $$imfiles[0]->{uri} ); 92 my ($vol, $dir, $file) = File::Spec->splitpath( $example ); 93 $workdir = $dir; 94 } 95 system "mkdir -p $workdir" unless -d $workdir; 96 97 my $outputFile = "$tess_id.$skycell_id.wrp$warp_id"; # Root name 98 my $outputRoot = File::Spec->catfile( $workdir, $outputFile ); 87 $workdir = caturi( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id ) if defined $workdir; 88 my $outputRoot = $ipprc->file_prepare( "$tess_id.$skycell_id.wrp$warp_id", $workdir, $$imfiles[0]->{uri} ); 99 89 my $outputImage = $ipprc->filename("PSWARP.OUTPUT", $outputRoot, $skycell_id ); 100 90 my $outputBin1 = $ipprc->filename("PSWARP.BIN1", $outputRoot, $skycell_id ); 101 91 my $outputBin2 = $ipprc->filename("PSWARP.BIN2", $outputRoot, $skycell_id ); 102 92 my $outputStats = $outputRoot . '.stats'; 103 my $skyFile = File::Spec->catfile( $workdir, $skycell_id ); # Target sky cell file 104 my $listName = $outputRoot . '.list'; 93 my $skyFile = caturi( $workdir, $skycell_id ); # Target sky cell file 105 94 106 95 # Get list of filenames 107 open my $listFile, "> $listName" or &my_die("Unable to open $listName", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR);96 my ($listFile, $listName) = tempfile( "$tess_id.$skycell_id.wrp$warp_id.list.XXXX", UNLINK => 1); 108 97 foreach my $imfile (@$imfiles) { 109 my $uri = $ipprc->convert_filename_absolute( $imfile->{uri} ); 110 111 print $listFile "$uri\n"; 98 print $listFile ( $imfile->{uri} . "\n"); 112 99 } 113 100 close $listFile; … … 123 110 &my_die("Unable to perform pswarp: $error_code", $warp_id, $skycell_id, $error_code); 124 111 } 125 &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ outputImage;126 &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ outputStats;127 # &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ outputBin1;128 # &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ outputBin2;112 &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage); 113 &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats); 114 # &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin1); 115 # &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin2); 129 116 130 117 # Get the statistics on the warped image 131 118 my $statsFile; # File handle 132 open $statsFile, "$outputStats"or die "Can't open statistics file $outputStats: $!\n";119 open $statsFile, $ipprc->file_resolve($outputStats) or die "Can't open statistics file $outputStats: $!\n"; 133 120 my @contents = <$statsFile>; # Contents of file 134 121 close $statsFile; … … 138 125 } 139 126 140 # Take off the absolute path, to stuff into the database 141 $outputImage = $ipprc->convert_filename_relative( $outputImage ); 142 $outputRoot = $ipprc->convert_filename_relative( $outputRoot ); 143 127 # Add the processed file to the database 144 128 my $bg = ($stats->bg_mean() or 'NAN'); 145 129 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); 146 147 # Add the processed file to the database148 130 unless ($no_update) { 149 131 my $command = "$warptool -addwarped -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_id" . … … 159 141 exit($error_code); 160 142 } 161 162 unlink $outputStats;163 143 } 164 144
Note:
See TracChangeset
for help on using the changeset viewer.
