Changeset 14039
- Timestamp:
- Jul 5, 2007, 6:16:04 PM (19 years ago)
- Location:
- trunk/ippScripts
- Files:
-
- 5 edited
-
Build.PL (modified) (1 diff)
-
scripts/ipp_serial_inject.pl (modified) (6 diffs)
-
scripts/ipp_serial_inject_mosaic.pl (modified) (3 diffs)
-
scripts/register_exp.pl (modified) (1 diff)
-
scripts/register_imfile.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/Build.PL
r13150 r14039 42 42 scripts/stack_skycell.pl 43 43 scripts/ipp_serial_inject.pl 44 scripts/ipp_serial_inject_split.pl 44 45 scripts/ipp_serial_inject_mosaic.pl 45 46 scripts/ipp_serial_register.pl -
trunk/ippScripts/scripts/ipp_serial_inject.pl
r14021 r14039 3 3 # this program injects a list of single-file exposures into the db, 4 4 # taking the filename (without .fits) as the exp_tag. the user 5 # supplies a temporary telescope and instrumentname. these are used5 # supplies a temporary telescope and camera name. these are used 6 6 # for informational purposes only until the registration step can 7 # determine the true telescope and instrumentname from the image7 # determine the true telescope and camera name from the image 8 8 # headers. 9 9 … … 24 24 25 25 # Parse the command-line arguments 26 my ($workdir, $dbname, $telescope, $ instrument, $help);26 my ($workdir, $dbname, $telescope, $camera, $help); 27 27 GetOptions( 28 28 'workdir|w=s' => \$workdir, # working directory for output files 29 29 'dbname|d=s' => \$dbname, # Database name 30 30 'telescope|t=s' => \$telescope, # user-supplied telescope name 31 ' instrument|i=s' => \$instrument, # user-supplied instrumentname31 'camera|i=s' => \$camera, # user-supplied camera name 32 32 'help' => \$help # give help listing 33 33 ) or pod2usage( 2 ); 34 34 35 pod2usage( -msg => "inject one or many files into the IPP pipeline database", -exitval => 2 35 pod2usage( -msg => "inject one or many files into the IPP pipeline database", 36 -exitval => 2) if 37 defined $help; 36 38 37 pod2usage( -msg => "Usage: $0 --telescope (name) -- instrument(name) [--workdir path] [--dbname dbname] (files)",39 pod2usage( -msg => "Usage: $0 --telescope (name) --camera (name) [--workdir path] [--dbname dbname] (files)", 38 40 -exitval => 2 ) if 39 scalar @ARGV == 0;41 scalar @ARGV == 0; 40 42 41 pod2usage( -msg => "Required options: --telescope (name) -- instrument(name)",43 pod2usage( -msg => "Required options: --telescope (name) --camera (name)", 42 44 -exitval => 3) unless 43 defined $telescope and44 defined $instrument;45 defined $telescope and 46 defined $camera; 45 47 46 48 my $pxinject = can_run('pxinject') or die "Can't find pxinject\n"; … … 54 56 my $num = 0; 55 57 foreach my $file ( @ARGV ) { 58 # check for file existence 59 if (! -e $file) { die "file $file not found\n"; } 56 60 my $absfile = File::Spec->rel2abs( $file ); 57 inject($absfile, $workdir, $dbname, $telescope, $ instrument);61 inject($absfile, $workdir, $dbname, $telescope, $camera); 58 62 $num ++; 59 63 } … … 67 71 my $dbname = shift; # IPP database to use 68 72 my $telescope = shift; # user-specified telescope 69 my $ instrument = shift; # user-specified instrument73 my $camera = shift; # user-specified camera 70 74 71 75 my ( $vol, $path, $name ) = File::Spec->splitpath( $absfile ); … … 74 78 my $relfile = $ipprc->convert_filename_relative( $absfile ); 75 79 76 my $command_exp = "$pxinject -newExp -exp_name $exp_name -inst $instrument -telescope $telescope -imfiles 1 -workdir $workdir" ; # Command to run 77 if ($dbname) { 78 $command_exp = "$command_exp -dbname $dbname"; 79 } 80 # the telescope, instrument, and exp_name used here are temporary : register replaces them with the true values 81 my $command_exp = "$pxinject -newExp"; 82 $command_exp .= " -tmp_exp_name $exp_name"; 83 $command_exp .= " -tmp_inst $camera"; 84 $command_exp .= " -tmp_telescope $telescope"; 85 $command_exp .= " -workdir $workdir"; 86 $command_exp .= " -dbname $dbname" if defined $dbname; 80 87 81 88 my ( $success_exp, $error_code_exp, $full_buf_exp, $stdout_buf_exp, $stderr_buf_exp ) = … … 86 93 my $exp_id = $line[2]; # The exposure tag 87 94 88 # XXX the class_id used here should be temporary : register should replace it with the true class_id 89 my $command_imfile = "$pxinject -newImfile -exp_id $exp_id -exp_name $exp_name -class fpa -class_id fpa -uri $relfile"; # Command to run 90 if ($dbname) { 91 $command_imfile = "$command_imfile -dbname $dbname"; 92 } 95 # the class_id used here is temporary : register replaces it with the true class_id 96 my $command_imfile = "$pxinject -newImfile"; 97 $command_imfile .= " -exp_id $exp_id"; 98 $command_imfile .= " -tmp_class_id fpa"; 99 $command_imfile .= " -uri $relfile"; 100 $command_imfile .= " -dbname $dbname" if defined ($dbname); 93 101 94 102 my ( $success_imfile, $error_code_imfile, $full_buf_imfile, $stdout_buf_imfile, $stderr_buf_imfile ) = run( command => $command_imfile, verbose => 1 ); 95 103 die "Unable to inject $exp_name imfile: $error_code_imfile\n" if not $success_imfile; 104 105 # the class_id used here is temporary : register replaces it with the true class_id 106 my $command_update = "$pxinject -updatenewExp"; 107 $command_update .= " -exp_id $exp_id"; 108 $command_update .= " -state run"; 109 $command_update .= " -dbname $dbname" if defined ($dbname); 110 111 my ( $success_update, $error_code_update, $full_buf_update, $stdout_buf_update, $stderr_buf_update ) = run( command => $command_update, verbose => 1 ); 112 die "Unable to update $exp_name: $error_code_update\n" if not $success_update; 96 113 97 114 return 1; -
trunk/ippScripts/scripts/ipp_serial_inject_mosaic.pl
r13275 r14039 1 1 #!/usr/bin/env perl 2 3 # this program injects a set of multi-file exposures into the db. the 4 # program takes a list of base exposure names and injects all files 5 # associated with the exposure. It constructs the expected filenames 6 # from the exposure tag and rules for the camera. This program is for 7 # the test only since it requires too much information at the inject 8 # stage. use 'ipp_serial_inject.pl' for single-file images and 9 # 'ipp_serial_inject_split.pl' for multiple file images in split 10 # format 11 12 # this program should not fail because of the data format or the 13 # configuration, except for the very basic database setup. 2 14 3 15 use warnings; … … 75 87 } 76 88 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 89 foreach my $exp_name ( @ARGV ) { 90 my $command = "$pxinject -newExp"; 91 " -exp_name $exp_name"; 92 " -inst $camera"; 93 " -telescope $telescope"; 94 " -workdir $workdir"; 95 " -dbname $dbname" if defined $dbname; 96 " -imfiles " . (scalar @classes or 1) ; # Command to run 97 79 98 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 80 99 run( command => $command, verbose => 1 ); 81 die "Unable to inject $exp : $error_code\n" if not $success;100 die "Unable to inject $exp_name: $error_code\n" if not $success; 82 101 83 102 my @line = split(/\s+/, $$stdout_buf[0]); # The output line, containing the exposure tag 84 my $exp_ tag= $line[2]; # The exposure tag103 my $exp_id = $line[2]; # The exposure tag 85 104 for (my $i = 0; $i < scalar @classes; $i++) { 86 105 my $class_id = $classes[$i]; 87 106 my $file_id = $files[$i]; 88 my $filename = $exp . $file_id . '.fits';89 $filename = caturi( $exp , $filename ) if defined $add_dir;107 my $filename = $exp_name . $file_id . '.fits'; 108 $filename = caturi( $exp_name, $filename ) if defined $add_dir; 90 109 $filename = caturi( $path, $filename ); 91 110 … … 93 112 94 113 $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 114 my $command = "$pxinject -newImfile"; 115 " -exp_id $exp_id"; 116 " -exp_name $exp_name"; 117 " -class chip"; 118 " -class_id $class_id"; 119 " -uri $filename"; 120 " -dbname $dbname" if defined ($dbname); # Command to run 121 96 122 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 97 123 run( command => $command, verbose => 1 ); -
trunk/ippScripts/scripts/register_exp.pl
r14021 r14039 136 136 } 137 137 138 my $exp_type = &STATS_value_for_flag ( "-exp_type");138 my $exp_type = &STATS_value_for_flag ($STATS, "-exp_type"); 139 139 140 140 # Add the detrend flag, if needed -
trunk/ippScripts/scripts/register_imfile.pl
r14021 r14039 38 38 use Pod::Usage qw( pod2usage ); 39 39 40 my ($cache, $exp_id, $ class_id, $exp_name, $uri, $workdir, $dbname, $no_update, $no_op);40 my ($cache, $exp_id, $tmp_class_id, $exp_name, $uri, $workdir, $dbname, $no_update, $no_op); 41 41 GetOptions( 42 'caches' => \$cache,43 'exp_id|e=s' => \$exp_id,44 ' class_id|i=s' => \$class_id,45 'exp_name|n=s' => \$exp_name,46 'uri|u=s' => \$uri,47 'workdir|w=s' => \$workdir, # Working directory for output files48 'dbname|d=s' => \$dbname,# Database name49 'no-update' => \$no_update,50 'no-op' => \$no_op,42 'caches' => \$cache, 43 'exp_id|e=s' => \$exp_id, 44 'tmp_class_id|i=s' => \$tmp_class_id, 45 'exp_name|n=s' => \$exp_name, 46 'uri|u=s' => \$uri, 47 'workdir|w=s' => \$workdir, # Working directory for output files 48 'dbname|d=s' => \$dbname,# Database name 49 'no-update' => \$no_update, 50 'no-op' => \$no_op, 51 51 ) or pod2usage( 2 ); 52 52 53 53 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 54 pod2usage( -msg => "Required options: --exp_id -- class_id --exp_name --uri",54 pod2usage( -msg => "Required options: --exp_id --tmp_class_id --exp_name --uri", 55 55 -exitval => 3) unless 56 56 defined $exp_id and 57 defined $ class_id and57 defined $tmp_class_id and 58 58 defined $exp_name and 59 59 defined $uri; … … 79 79 { name => "FPA.TELESCOPE", type => "constant", flag => "-telescope" }, # Telescope 80 80 { name => "FPA.INSTRUMENT", type => "constant", flag => "-inst" }, # Instrument 81 { name => "CHIP.TEMP" type => "mean", flag => "-ccd_temp" }, # CCD temperature82 { name => "CELL.EXPOSURE" type => "mean", flag => "-exp_time" }, # Exposure time83 { name => "SAT_PIXEL_FRAC" type => "mean", flag => "-sat_pixel_frac" }# fraction of saturated pixels81 { name => "CHIP.TEMP", type => "mean", flag => "-ccd_temp" }, # CCD temperature 82 { name => "CELL.EXPOSURE", type => "mean", flag => "-exp_time" }, # Exposure time 83 { name => "SAT_PIXEL_FRAC", type => "mean", flag => "-sat_pixel_frac" }, # fraction of saturated pixels 84 84 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg" }, 85 85 { name => "ROBUST_MEDIAN", type => "stdev", flag => "-bg_mean_stdev" }, … … 114 114 unless ($success) { 115 115 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 116 &my_die ("Unable to perform ppStats on exposure id $exp_id: $error_code", $exp_id, $ class_id, $error_code);116 &my_die ("Unable to perform ppStats on exposure id $exp_id: $error_code", $exp_id, $exp_name, $tmp_class_id, $error_code); 117 117 } 118 118 … … 121 121 my $metadata = $mdcParser->parse(join "", @$stdout_buf); # XXX is this join necessary? 122 122 unless ($metadata) { 123 &my_die ("Unable to parse metadata config doc", $exp_id, $ class_id, $PS_EXIT_PROG_ERROR);123 &my_die ("Unable to parse metadata config doc", $exp_id, $exp_name, $tmp_class_id, $PS_EXIT_PROG_ERROR); 124 124 } 125 125 … … 127 127 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 128 128 unless ($stats->parse($metadata)) { 129 &my_die ("Unable to find all values", $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR); 130 } 131 } 129 &my_die ("Unable to find all values", $exp_id, $exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); 130 } 131 } 132 133 # we require at a minimum: -telescope, -inst, -filelevel, -class_id, -exp_type 134 if (uc(&STATS_value_for_flag ($STATS, "-telescope")) eq "NAN") { &my_die ("telescope not found", $exp_id, $exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); } 135 if (uc(&STATS_value_for_flag ($STATS, "-inst")) eq "NAN") { &my_die ("inst not found", $exp_id, $exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); } 136 if (uc(&STATS_value_for_flag ($STATS, "-filelevel")) eq "NAN") { &my_die ("filelevel not found", $exp_id, $exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); } 137 if (uc(&STATS_value_for_flag ($STATS, "-class_id")) eq "NAN") { &my_die ("class_id not found", $exp_id, $exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); } 138 if (uc(&STATS_value_for_flag ($STATS, "-exp_type")) eq "NAN") { &my_die ("exp_type not found", $exp_id, $exp_name, $tmp_class_id, $PS_EXIT_CONFIG_ERROR); } 132 139 133 140 my $command = "$regtool -addprocessedimfile"; 134 141 $command .= " -exp_id $exp_id"; 135 $command .= " -temp_class_id $class_id"; # the original class_id supplied by the user, replace by ppStats CLASS.ID136 142 $command .= " -exp_name $exp_name"; # keep the supplied exp_name (could be derived from the file) 143 $command .= " -tmp_class_id $tmp_class_id"; # the original class_id supplied by the user, replace by ppStats CLASS.ID 137 144 $command .= " -dbname $dbname" if defined $dbname; 138 145 … … 153 160 exit($error_code); 154 161 } 162 } else { 163 print "skipping command: $command\n"; 155 164 } 156 165 … … 173 182 my $msg = shift; # Warning message on die 174 183 my $exp_id = shift; 175 my $class_id = shift; 184 my $exp_name = shift; 185 my $tmp_class_id = shift; 176 186 my $exit_code = shift; 177 187 188 # for failed imfiles, we insert UNKNOWN for inst, telescope, class_id 189 178 190 carp($msg); 179 if ($exp_id && $ class_id and not $no_update) {191 if ($exp_id && $tmp_class_id and not $no_update) { 180 192 my $command = "$regtool -addprocessedimfile"; 181 193 $command .= " -exp_id $exp_id"; 182 $command .= " -class_id $class_id"; 194 $command .= " -exp_name $exp_name"; 195 $command .= " -tmp_class_id $tmp_class_id"; 196 $command .= " -telescope UNKNOWN"; 197 $command .= " -inst UNKNOWN"; 198 $command .= " -class_id $tmp_class_id"; 183 199 $command .= " -code $exit_code"; 184 200 $command .= " -dbname $dbname" if defined $dbname; 185 ###system ($command);201 system ($command); 186 202 } 187 203 exit $exit_code; 204 } 205 206 sub STATS_value_for_flag 207 { 208 my $STATS = shift; 209 my $flag = shift; 210 211 foreach my $entry (@$STATS) { 212 if ($flag eq $entry->{flag}) { 213 return $entry->{value}; 214 } 215 } 216 return 'NAN'; 188 217 } 189 218
Note:
See TracChangeset
for help on using the changeset viewer.
