IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 110


Ignore:
Timestamp:
Oct 7, 2003, 11:58:12 PM (23 years ago)
Author:
eugene
Message:

added code to handle PHU entry
added new header comment blocks
added preserve mode
added defringe mode (defringe.ccd)
better error handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/perl/src/flatten.flips

    r70 r110  
    22
    33# grab the command line options
    4 $use_fringe = 0;
     4$defringe = 0;
    55$use_mask = 1;
    66$fast = 0;
     
    88$close = "";
    99$config = "";
     10$preserve = 0;
    1011@tARGV = ();
    1112for (; @ARGV > 0; ) {
     
    2223        shift; shift; shift; next;
    2324    }
     25    if ($ARGV[0] eq "-preserve") {
     26        $preserve = 1;
     27        shift; next;
     28    }
    2429    if ($ARGV[0] eq "-fast") {
    2530        $fast = 1;
     
    3540    }
    3641    if ($ARGV[0] eq "-defringe") {
    37         $use_fringe = 1;
     42        $defringe = 1;
    3843        shift; next;
    3944    }
     
    5560$mode   = uppercase ($ARGV[3]);
    5661
     62$chipname = "-chipname";
    5763$infile = $input;
    5864if ($mode eq "MEF") { $infile = "$input\[$ccd]"; }
     65if ($ccd eq "phu") {
     66    $infile = "$input";
     67    $ccd = "ccd00";
     68    $chipname = "";
     69}
    5970
    6071# remove old file if it exists
     
    6374
    6475# find the appropriate detrend images (need to fix output name for MEF - option?)
    65 $flat=`detsearch $config -chipname -quiet -image $input $ccd $mode -type flat $close`; chop ($flat);
     76$flat=`detsearch $config $chipname -quiet -image $input $ccd $mode -type flat $close`; chop ($flat);
    6677if ($?) { die "ERROR: can't get flat for image\n"; }
    6778
    6879if (!$fast) {
    69     $bias=`detsearch $config -chipname -quiet -image $input $ccd $mode -type bias $close`; chop ($bias);
     80    $bias=`detsearch $config $chipname -quiet -image $input $ccd $mode -type bias $close`; chop ($bias);
    7081    if ($?) { die "ERROR: can't get bias for image\n"; }
    7182
    72     $dark=`detsearch $config -chipname -quiet -image $input $ccd $mode -type dark $close`; chop ($dark);
     83    $dark=`detsearch $config $chipname -quiet -image $input $ccd $mode -type dark $close`; chop ($dark);
    7384    if ($?) { die "ERROR: can't get dark for image\n"; }
    7485}
     
    7788$mask = "none";
    7889if ($use_mask) {
    79     $mask=`detsearch $config -chipname -quiet -image $input $ccd $mode -type mask $close`; chop ($mask);
     90    $mask=`detsearch $config $chipname -quiet -image $input $ccd $mode -type mask $close`; chop ($mask);
    8091    if ($?) { die "ERROR: can't get mask for image\n"; }
    8192}
     
    89100$fringe = "none";
    90101$frpts  = "none";
    91 if ($use_fringe) {
    92 
    93     die "ERROR: -fringe not yet available in flatten.flips\n";
     102if ($defringe) {
    94103
    95104    $filterword  = `gconfig $config FILTER-KEYWORD`;    chop ($filterword);
     
    107116   
    108117    # check for DEFRINGE, DEMODE
    109     $use_fringe = 0;
     118    $defringe = 0;
    110119    for ($i = 0; $i < @detypes; $i++) {
    111120        if ($detypes[$i] eq "fringe") {
    112             if ($exptime >= $cutoffs[$i]) { $use_fringe = 1; }
     121            if ($exptime >= $cutoffs[$i]) { $defringe = 1; }
    113122            last;
    114123        }
    115     }
    116 
    117     # grab necessary detrend files
    118     if ($use_fringe) {
    119         $fringe = `detsearch $config -chipname -quiet -image $input $ccd $mode -type fringe $close`; chop ($fringe);
    120         if ($?) { die "ERROR: can't get fringe for image\n"; }
    121 
    122         $frpts  = `detsearch $config -chipname -quiet -image $input $ccd $mode -type frpts $close`;
    123         if ($?) { die "ERROR: can't get fringe points for image\n"; }
    124124    }
    125125}
     
    131131    ($junk, $t1) = split (" ", `echo $input    | fields $exptimeword`);
    132132    ($name, $t2) = split (" ", `echo $darkfile | fields $exptimeword`);
    133     print STDERR "darktime: $input, $t1; $darkfile, $t2\n";
    134133    $darkfactor = `darktime.$darkword $t1 $t2`; chop ($darkfactor);
    135134    if ($?) { die "ERROR: failure to get darkfactor $t1 $t2\n"; }
     
    178177    }
    179178
    180     # header blocks
    181     $line =~ s|DOHEADER|0|;
    182     $line =~ s|NBLOCKS|0|;
     179    # header blocks - we need an extra block for elixir keywords
     180    $line =~ s|DOHEADER|1|;
     181    $line =~ s|NBLOCKS|5|;
    183182}
    184183
     
    193192$stat = $?;
    194193
    195 unlink $temp;
     194if ($preserve) {
     195    print STDERR "imred input file: $temp\n";
     196} else {
     197    unlink $temp;
     198}
     199
     200if ($stat) {
     201    if (! $quiet) { print STDOUT "ERROR: failure running flatten.flips\n"; }
     202    exit 1;
     203}
     204
     205if ($defringe) {
     206    system ("mv $output $output.det");
     207    if ($?) {
     208        print STDERR "failure to save temporary output file\n";
     209        exit 1;
     210    }
     211
     212    system ("defringe.ccd -quiet $close $output.dat $output $ccd SPLIT");
     213    if ($?) {
     214        print STDERR "failure in defringe\n";
     215        $stat = 1;
     216    }
     217    unlink "$output.dat";
     218}   
    196219
    197220if (! $quiet) {
     
    202225    }
    203226}
    204 exit $stat;
     227
     228# always return 1, don't return just the exit status
     229if ($stat) {
     230    exit 1;
     231} else {
     232    exit 0;
     233}
    205234
    206235sub vsystem {
Note: See TracChangeset for help on using the changeset viewer.