Changeset 11110
- Timestamp:
- Jan 15, 2007, 3:17:04 PM (19 years ago)
- Files:
-
- 2 added
- 6 edited
-
branches/eam_branch_00/ippTasks/phase0.pro (modified) (2 diffs)
-
trunk/ippScripts/scripts/Makefile.am (modified) (1 diff)
-
trunk/ippScripts/scripts/inject.pl (modified) (2 diffs)
-
trunk/ippScripts/scripts/inject_phase0.pl (added)
-
trunk/ippScripts/scripts/ipp_filename.pl (added)
-
trunk/ippScripts/scripts/phase2.pl (modified) (4 diffs)
-
trunk/ippScripts/scripts/phase3.pl (modified) (3 diffs)
-
trunk/ippTools/src/dettool.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_00/ippTasks/phase0.pro
r11109 r11110 37 37 periods -exec $loadexec 38 38 periods -timeout 30 39 40 # XXX test that this option works 41 npending 1 39 42 40 43 # silently drop stdout … … 100 103 end 101 104 102 # XXX this is still a lame rule103 $word = `basename $EXP_TAG | tr '.' ' '`104 list word -split $word105 $base = $word:0106 107 105 ## generate output log based on filerule 108 106 $outroot = $OUTPATH/$EXP_TAG -
trunk/ippScripts/scripts/Makefile.am
r10567 r11110 16 16 phase2.pl \ 17 17 phase3.pl \ 18 ipp_filename.pl \ 18 19 ipp_datapath.pl -
trunk/ippScripts/scripts/inject.pl
r10700 r11110 1 1 #!/usr/bin/env perl 2 3 # this program injects a list of single-file exposures into the db, taking the 4 # filename (without .fits) as the exp_tag. 2 5 3 6 use warnings; … … 7 10 use PS::IPP::Metadata::Config; 8 11 use PS::IPP::Metadata::List qw( parse_md_list ); 9 use Data::Dumper; 12 use File::Spec; 13 use File::Find::Rule; 14 use PS::IPP::Config; 15 my $ipprc = PS::IPP::Config->new(); 16 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 10 17 11 18 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 12 use Pod::Usage qw( pod2usage );13 19 14 my ($camera, # Camera used 15 $telescope, # Telescope used 16 $exp_type, # Type of exposure 17 $path, # Path to use 18 $inject_only # Only inject (i.e., no phase 0)? 19 ); 20 # Parse the command-line arguments 21 my ($outroot); 20 22 GetOptions( 21 'camera|c=s' => \$camera, 22 'telescope|t=s' => \$telescope, 23 'exp_type|e=s' => \$exp_type, 24 'path=s' => \$path, 25 'inject-only' => \$inject_only, 23 'outroot' => \$outroot 26 24 ) or pod2usage( 2 ); 27 25 28 pod2usage( 29 -msg => "Required options: --camera --telescope --exp_type --path", 30 -exitval => 3, 31 ) unless scalar @ARGV == 0 or (defined $camera 32 and defined $telescope 33 and defined $exp_type 34 and defined $path); 26 pod2usage( -msg => "Usage: $0 [-outroot path] (files)", -exitval => 2 ) if scalar @ARGV == 0; 35 27 36 my $mdcParser = PS::IPP::Metadata::Config->new; # Metadata config parser 28 my $pxinject = can_run('pxinject') or die "Can't find pxinject\n"; 29 my $ppStats = can_run('ppStats') or die "Can't find ppStats\n"; 37 30 38 # Look for programs we need 39 my $missing_tools; 40 my $pxinject = can_run('pxinject') or (warn "Can't find pxinject" and $missing_tools = 1); 41 my $p0tool = can_run('p0tool') or (warn "Can't find p0tool" and $missing_tools = 1); 42 my $phase0_imfile = can_run('phase0_imfile.pl') or (warn "Can't find phase0_imfile.pl" and $missing_tools = 1); 43 my $phase0_exp = can_run('phase0_exp.pl') or (warn "Can't find phase0_exp.pl" and $missing_tools = 1); 44 die "Can't find required tools.\n" if $missing_tools; 31 # if outroot is not defined, assign the current path 32 if (! $outroot) { 33 $outroot = File::Spec->rel2abs( "." ); 34 } 35 my $relroot = $ipprc->convert_filename_relative( $outroot ); 45 36 46 # Inject new data into the database 47 if (scalar @ARGV != 0) { 48 my @classes; 49 my $imfiles; 50 if ($camera eq "MEGACAM") { 51 for (my $i = 0; $i < 36; $i++) { 52 push @classes, sprintf("ccd%02d", $i); 53 } 54 } elsif ($camera eq "MCSHORT") { 55 @classes = ( 'ccd12', 'ccd13', 'ccd14', 'ccd21', 'ccd22', 'ccd23' ); 56 } elsif ($camera eq "CTIO_MOSAIC2") { 57 @classes = (); 58 } else { 59 die "Unrecognised camera name: $camera.\n"; 60 } 61 62 foreach my $exp ( @ARGV ) { 63 my $command = "$pxinject -newExp -exp_id $exp -inst $camera -telescope $telescope -exp_type $exp_type -imfiles " . (scalar @classes or 1) ; # Command to run 64 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 65 run( command => $command, verbose => 1 ); 66 die "Unable to inject $exp: $error_code\n" if not $success; 67 68 my @line = split(/\s+/, $$stdout_buf[0]); # The output line, containing the exposure tag 69 my $exp_tag = $line[2]; # The exposure tag 70 foreach my $class_id (@classes) { 71 my $command = "$pxinject -newImfile -exp_tag $exp_tag -class chip -class_id $class_id -uri $path/$exp.$class_id.fits"; # Command to run 72 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 73 run( command => $command, verbose => 1 ); 74 die "Unable to inject $exp $class_id: $error_code\n" if not $success; 75 } 76 77 if (scalar @classes == 0) { 78 my $command = "$pxinject -newImfile -exp_tag $exp_tag -class fpa -class_id fpa -uri $path/$exp.fits"; # 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 imfile: $error_code\n" if not $success; 82 } 83 84 } 37 my $num = 0; 38 foreach my $file ( @ARGV ) { 39 my $absfile = File::Spec->rel2abs( $file ); 40 inject($absfile, $relroot); 41 $num ++; 85 42 } 86 43 87 exit 0 if $inject_only;44 print "$num files injected.\n"; 88 45 89 # Phase 0 imfile processing 46 sub inject 90 47 { 91 my $command = "$p0tool -pendingimfile"; # Command to run 92 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 93 run( command => $command, verbose => 1 ); 94 die "Unable to get phase 0 imfile list: $error_code\n" if not $success; 95 my $list = parse_md_list( $mdcParser->parse( join( '', @$stdout_buf ) ) ) or 96 die "Unable to parse output from p0tool.\n"; 48 my $absfile = shift; # absolute path for this file 49 my $outroot = shift; # absolute path for output directory 97 50 98 foreach my $item (@$list) { 99 my $exp_tag = $item->{exp_tag}; 100 my $class = $item->{class}; 101 my $class_id = $item->{class_id}; 102 my $uri = $item->{uri}; 51 my ( $vol, $path, $name ) = File::Spec->splitpath( $absfile ); 52 my ( $exp ) = $name =~ /(.*)\.fits/; 103 53 104 my $command = "$phase0_imfile --exp_tag $exp_tag --class $class --class_id $class_id --uri $uri"; 105 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 106 run( command => $command, verbose => 1 ); 107 die "Unable to do phase 0 imfile processing on $exp_tag $class_id: $error_code\n" if not $success; 54 my $relfile = $ipprc->convert_filename_relative( $absfile ); 55 56 my $command_type = "$ppStats -concept FPA.OBSTYPE -concept FPA.TELESCOPE -concept FPA.INSTRUMENT $absfile"; 57 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command_type, verbose => 1); 58 die "Unable to perform ppStats: $error_code\n" if not $success; 59 my $metadata = $mdcParser->parse(join "", @$stdout_buf) 60 or die "unable to parse metadata config doc"; 61 62 my $type; 63 my $telescope; 64 my $instrument; 65 foreach my $row (@$metadata) { 66 if ($row->{name} eq "FPA.TELESCOPE") { $telescope = $row->{value}; } 67 if ($row->{name} eq "FPA.INSTRUMENT") { $instrument = $row->{value}; } # this entry must return the camera in the ipp/config system which we load 68 if ($row->{name} eq "FPA.OBSTYPE") { $type = $row->{value}; } 108 69 } 109 } 70 71 my $command_exp = "$pxinject -newExp -exp_id $exp -inst $instrument -telescope $telescope -exp_type $type -imfiles 1 -outroot $outroot" ; # Command to run 110 72 111 # Phase 0 exposure processing 112 { 113 my $command = "$p0tool -pendingexp"; # Command to run114 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =115 run( command => $command, verbose => 1 ); 116 die "Unable to get phase 0 exposure list: $error_code\n" if not $success;117 my $list = parse_md_list( $mdcParser->parse( join( '', @$stdout_buf ) ) ) or118 die "Unable to parse output from p0tool.\n"; 119 120 foreach my $item (@$list) {121 my $exp_tag = $item->{exp_tag};73 my ( $success_exp, $error_code_exp, $full_buf_exp, $stdout_buf_exp, $stderr_buf_exp ) = 74 run( command => $command_exp, verbose => 1 ); 75 die "Unable to inject $exp: $error_code_exp\n" if not $success_exp; 76 77 my @line = split(/\s+/, $$stdout_buf_exp[0]); # The output line, containing the exposure tag 78 my $exp_tag = $line[2]; # The exposure tag 79 80 my $command_imfile = "$pxinject -newImfile -exp_tag $exp_tag -class fpa -class_id fpa -uri $relfile"; # Command to run 81 82 my ( $success_imfile, $error_code_imfile, $full_buf_imfile, $stdout_buf_imfile, $stderr_buf_imfile ) = run( command => $command_imfile, verbose => 1 ); 83 die "Unable to inject $exp imfile: $error_code_imfile\n" if not $success_imfile; 122 84 123 my $command = "$phase0_exp --exp_tag $exp_tag"; 124 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 125 run( command => $command, verbose => 1 ); 126 die "Unable to do phase 0 exposure processing on $exp_tag: $error_code\n" if not $success; 127 } 128 } 129 130 END { 131 my $status = $?; 132 system("sync") == 0 133 or die "failed to execute sync: $!" ; 134 $? = $status; 85 return 1; 135 86 } 136 87 137 88 138 89 __END__ 139 140 -
trunk/ippScripts/scripts/phase2.pl
r10757 r11110 22 22 $input, # Input FITS file 23 23 $camera, # Camera 24 $outpath, # Outpath 24 25 $no_update # Don't update the database? 25 26 ); … … 29 30 'uri|u=s' => \$input, 30 31 'camera|c=s' => \$camera, 32 'outpath|o=s' => \$outpath, 31 33 'no-update' => \$no_update 32 34 ) or pod2usage( 2 ); … … 34 36 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 35 37 pod2usage( 36 -msg => "Required options: --exp_tag --class_id --uri --camera ",38 -msg => "Required options: --exp_tag --class_id --uri --camera --outpath", 37 39 -exitval => 3, 38 40 ) unless defined $expTag 39 41 and defined $classId 40 42 and defined $input 43 and defined $outpath 41 44 and defined $camera; 42 45 … … 49 52 die "Can't find required tools.\n" if $missing_tools; 50 53 54 # XXX old verion Output file name 55 # XXX old version (drop) : my ($vol, $dir, $file) = File::Spec->splitpath( $input ); 56 51 57 ### Output file name --- must match camera configuration! 52 my ($vol, $dir, $file) = File::Spec->splitpath( $input );53 58 my $outputRoot = $expTag . '.p2'; 54 $outputRoot = File::Spec->catpath( $ vol, $dir, $outputRoot );59 $outputRoot = File::Spec->catpath( $outpath, $outputRoot ); 55 60 $outputRoot = $ipprc->convert_filename_absolute($outputRoot); 56 61 $input = $ipprc->convert_filename_absolute ( $input ); -
trunk/ippScripts/scripts/phase3.pl
r11096 r11110 19 19 use Pod::Usage qw( pod2usage ); 20 20 21 my ($exp_tag, $camera, $ no_update);21 my ($exp_tag, $camera, $outpath, $no_update); 22 22 GetOptions( 23 23 'exp_tag|e=s' => \$exp_tag, 24 24 'camera|c=s' => \$camera, 25 'outpath|o=s' => \$outpath, 25 26 'no-update' => \$no_update 26 27 ) or pod2usage( 2 ); … … 28 29 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 29 30 pod2usage( 30 -msg => "Required options: --exp_tag --camera ",31 -msg => "Required options: --exp_tag --camera --outpath", 31 32 -exitval => 3, 32 33 ) unless defined $exp_tag … … 95 96 } 96 97 97 my $example = ${$files}[0]->{b1_uri}; # Example filename 98 my ($vol, $dir, $file) = File::Spec->splitpath( $example ); 98 # XXX old verison, drop 99 #my $example = ${$files}[0]->{b1_uri}; # Example filename 100 #my ($vol, $dir, $file) = File::Spec->splitpath( $example ); 99 101 100 102 # Generate the file list, and get the statistics 101 103 my $outputRoot = $exp_tag . '.p3'; # Root output name 102 $outputRoot = File::Spec->catpath( $ vol, $dir, $outputRoot );104 $outputRoot = File::Spec->catpath( $outpath, $outputRoot ); 103 105 $outputRoot = $ipprc->convert_filename_absolute($outputRoot); 104 106 my $list1Name = $outputRoot . '.b1.list'; # Name for the input file list for binning 1 -
trunk/ippTools/src/dettool.c
r11090 r11110 5946 5946 5947 5947 // XXX this is going in without checking that the det_id is valid. 5948 // it seems like it be better to be using for gein key constraints rather5948 // it seems like it be better to be using foreign key constraints rather 5949 5949 // then having to resort to a seperate query (and locking) to check that 5950 5950 // the det_id is valid
Note:
See TracChangeset
for help on using the changeset viewer.
