IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 4, 2007, 4:52:03 PM (19 years ago)
Author:
Paul Price
Message:

Major upgrade to allow use of Nebulous

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/camera_exp.pl

    r13090 r13275  
    1717use PS::IPP::Metadata::List qw( parse_md_list );
    1818use 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     );
     19use File::Temp qw( tempfile );
     20
     21use 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                       );
    2930my $ipprc = PS::IPP::Config->new(); # IPP configuration
    30 use File::Spec;
    3131
    3232use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    125125}
    126126
    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
     127my ($list1File, $list1Name) = tempfile( "$exp_id.cam$cam_id.b1.list.XXXX", UNLINK => 1 ); # For binning 1
     128my ($list2File, $list2Name) = tempfile( "$exp_id.cam$cam_id.b2.list.XXXX", UNLINK => 1 ); # For binning 2
     129my ($list3File, $list3Name) = tempfile( "$exp_id.cam$cam_id.b3.list.XXXX", UNLINK => 1 ); # For astrometry
    145130
    146131my @means;                      # Array of means
    147132my @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 
    154133my $chipObjects;
    155134foreach my $file (@$files) {
    156135    # use the path_base as OUTPUT root and convert the filenames with ipprc->filename:
    157136    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);
    164142    print $list3File $chipObjects;
    165143    push @means, $file->{bg};
     
    170148close $list3File;
    171149
    172 # Output products --- need to synch with the camera configuration!
     150# Output products
     151$workdir = caturi( $workdir, $exp_id ) if defined $workdir;
     152my $outputRoot = $ipprc->file_prepare( "$exp_id.cam$cam_id", $workdir, ${$files}[0]->{path_base} );
    173153my $jpeg1 = $ipprc->filename("PPIMAGE.JPEG1", $outputRoot); # Binned JPEG #1
    174154my $jpeg2 = $ipprc->filename("PPIMAGE.JPEG2", $outputRoot); # Binned JPEG #2
    175155my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $outputRoot); # MEF psastro output
    176 # my $dvo_camera = $ipprc->dvocamera();
    177156
    178157unless ($no_op) {
     
    188167            &my_die("Unable to perform psastro: $error_code", $cam_id, $error_code);
    189168        }
    190         &my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $fpaObjects;
    191169    } 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);
    194173
    195174    # run addstar on either the single chip output or the single fpa output
     
    197176    # XXX which in turn points at ippconfig/dvo.site
    198177    {
    199         my $command = "addstar -D CAMERA $camera $fpaObjects";
     178        my $command = "addstar -D CAMERA $camera " . $ipprc->file_resolve($fpaObjects);
    200179        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    201180            run(command => $command, verbose => 1);
     
    215194            &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);
    216195        }
    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);
    218197    }
    219198
     
    227206            &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);
    228207        }
    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
    234212# Add the result into the database
    235 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );
    236 
    237213unless ($no_update) {
    238214    my $command = "$camtool -addprocessedexp -cam_id $cam_id -uri UNKNOWN -path_base $outputRoot " .
     
    247223        exit($error_code);
    248224    }
    249 
    250     unlink $list1Name;
    251     unlink $list2Name;
    252225}
    253226
Note: See TracChangeset for help on using the changeset viewer.