IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11110


Ignore:
Timestamp:
Jan 15, 2007, 3:17:04 PM (19 years ago)
Author:
eugene
Message:

adding outpath option to scripts

Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_00/ippTasks/phase0.pro

    r11109 r11110  
    3737  periods      -exec $loadexec
    3838  periods      -timeout 30
     39
     40  # XXX test that this option works
     41  npending     1
    3942
    4043  # silently drop stdout
     
    100103    end
    101104
    102     # XXX this is still a lame rule
    103     $word = `basename $EXP_TAG | tr '.' ' '`
    104     list word -split $word
    105     $base = $word:0
    106 
    107105    ## generate output log based on filerule
    108106    $outroot = $OUTPATH/$EXP_TAG
  • trunk/ippScripts/scripts/Makefile.am

    r10567 r11110  
    1616        phase2.pl \
    1717        phase3.pl \
     18        ipp_filename.pl \
    1819        ipp_datapath.pl
  • trunk/ippScripts/scripts/inject.pl

    r10700 r11110  
    11#!/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.
    25
    36use warnings;
     
    710use PS::IPP::Metadata::Config;
    811use PS::IPP::Metadata::List qw( parse_md_list );
    9 use Data::Dumper;
     12use File::Spec;
     13use File::Find::Rule;
     14use PS::IPP::Config;
     15my $ipprc = PS::IPP::Config->new();
     16my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    1017
    1118use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    12 use Pod::Usage qw( pod2usage );
    1319
    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
     21my ($outroot);
    2022GetOptions(
    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
    2624) or pod2usage( 2 );
    2725
    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);
     26pod2usage( -msg => "Usage: $0 [-outroot path] (files)", -exitval => 2 ) if scalar @ARGV == 0;
    3527
    36 my $mdcParser = PS::IPP::Metadata::Config->new; # Metadata config parser
     28my $pxinject = can_run('pxinject') or die "Can't find pxinject\n";
     29my $ppStats = can_run('ppStats') or die "Can't find ppStats\n";
    3730
    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
     32if (! $outroot) {
     33    $outroot = File::Spec->rel2abs( "." );
     34}
     35my $relroot = $ipprc->convert_filename_relative( $outroot );
    4536
    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     }
     37my $num = 0;
     38foreach my $file ( @ARGV ) {
     39    my $absfile = File::Spec->rel2abs( $file );
     40    inject($absfile, $relroot);
     41    $num ++;
    8542}
    8643
    87 exit 0 if $inject_only;
     44print "$num files injected.\n";
    8845
    89 # Phase 0 imfile processing
     46sub inject
    9047{
    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
    9750
    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/;
    10353
    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}; }
    10869    }
    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
    11072
    111 # Phase 0 exposure processing
    112 {
    113     my $command = "$p0tool -pendingexp"; # Command to run
    114     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 ) ) ) or
    118         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;
    12284
    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;
    13586}
    13687
    13788
    13889__END__
    139 
    140 
  • trunk/ippScripts/scripts/phase2.pl

    r10757 r11110  
    2222    $input,                     # Input FITS file
    2323    $camera,                    # Camera
     24    $outpath,                   # Outpath
    2425    $no_update                  # Don't update the database?
    2526    );
     
    2930    'uri|u=s'       => \$input,
    3031    'camera|c=s'    => \$camera,
     32    'outpath|o=s'   => \$outpath,
    3133    'no-update'     => \$no_update
    3234) or pod2usage( 2 );
     
    3436pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    3537pod2usage(
    36     -msg => "Required options: --exp_tag --class_id --uri --camera",
     38    -msg => "Required options: --exp_tag --class_id --uri --camera --outpath",
    3739    -exitval => 3,
    3840) unless defined $expTag
    3941    and defined $classId
    4042    and defined $input
     43    and defined $outpath
    4144    and defined $camera;
    4245
     
    4952die "Can't find required tools.\n" if $missing_tools;
    5053
     54# XXX old verion Output file name
     55# XXX old version (drop) : my ($vol, $dir, $file) = File::Spec->splitpath( $input );
     56
    5157### Output file name --- must match camera configuration!
    52 my ($vol, $dir, $file) = File::Spec->splitpath( $input );
    5358my $outputRoot =  $expTag . '.p2';
    54 $outputRoot = File::Spec->catpath( $vol, $dir, $outputRoot );
     59$outputRoot = File::Spec->catpath( $outpath, $outputRoot );
    5560$outputRoot = $ipprc->convert_filename_absolute($outputRoot);
    5661$input = $ipprc->convert_filename_absolute ( $input );
  • trunk/ippScripts/scripts/phase3.pl

    r11096 r11110  
    1919use Pod::Usage qw( pod2usage );
    2020
    21 my ($exp_tag, $camera, $no_update);
     21my ($exp_tag, $camera, $outpath, $no_update);
    2222GetOptions(
    2323    'exp_tag|e=s'       => \$exp_tag,
    2424    'camera|c=s'        => \$camera,
     25    'outpath|o=s'   => \$outpath,
    2526    'no-update'         => \$no_update
    2627) or pod2usage( 2 );
     
    2829pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    2930pod2usage(
    30     -msg => "Required options: --exp_tag --camera",
     31    -msg => "Required options: --exp_tag --camera --outpath",
    3132    -exitval => 3,
    3233) unless defined $exp_tag
     
    9596}
    9697
    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 );
    99101
    100102# Generate the file list, and get the statistics
    101103my $outputRoot = $exp_tag . '.p3'; # Root output name
    102 $outputRoot = File::Spec->catpath( $vol, $dir, $outputRoot );
     104$outputRoot = File::Spec->catpath( $outpath, $outputRoot );
    103105$outputRoot = $ipprc->convert_filename_absolute($outputRoot);
    104106my $list1Name = $outputRoot . '.b1.list'; # Name for the input file list for binning 1
  • trunk/ippTools/src/dettool.c

    r11090 r11110  
    59465946
    59475947    // XXX this is going in without checking that the det_id is valid.
    5948     // it seems like it be better to be using forgein key constraints rather
     5948    // it seems like it be better to be using foreign key constraints rather
    59495949    // then having to resort to a seperate query (and locking) to check that
    59505950    // the det_id is valid
Note: See TracChangeset for help on using the changeset viewer.