IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25425


Ignore:
Timestamp:
Sep 16, 2009, 6:35:31 PM (17 years ago)
Author:
watersc1
Message:

changes to support new burntool_state

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/share/pxadmin_create_tables.sql

    r25420 r25425  
    223223    teltemp_extra FLOAT,
    224224    pon_time FLOAT,
     225    burntool_state SMALLINT,
    225226    user_1 DOUBLE,
    226227    user_2 DOUBLE,
  • trunk/ippTools/share/regtool_updateprocessedimfile.sql

    r23546 r25425  
    11UPDATE rawImfile
    2   SET user_1 = %lf
     2  SET burntool_state = %d
    33  WHERE
    44    rawImfile.exp_id = %lld
  • trunk/ippTools/src/regtool.c

    r25420 r25425  
    224224    PXOPT_LOOKUP_F32(teltemp_extra, config->args, "-teltemp_extra", false, false);
    225225    PXOPT_LOOKUP_F32(pon_time, config->args, "-pon_time", false, false);
     226    PXOPT_LOOKUP_S16(burntool_state, config->args, "-burntool_state", false, false);
    226227    PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false);
    227228    PXOPT_LOOKUP_F64(user_2, config->args, "-user_2", false, false);
     
    467468
    468469    PXOPT_LOOKUP_S16(fault, config->args, "-fault",   false, false);
    469     PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false);
    470 
    471     if ((fault == INT16_MAX) && !isfinite(user_1)) {
    472         psError(PS_ERR_UNKNOWN, false, "one of -fault or -user_1 must be selected");
    473         return false;
    474     }
    475     if ((fault != INT16_MAX) && isfinite(user_1)) {
    476         psError(PS_ERR_UNKNOWN, false, "only one of -fault or -user_1 must be selected");
     470/*     PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false); */
     471    PXOPT_LOOKUP_S16(burntool_state, config->args, "-burntool_state", false, false);
     472   
     473    if ((fault == INT16_MAX) && !isfinite(burntool_state)) {
     474        psError(PS_ERR_UNKNOWN, false, "one of -fault or -burntool_state must be selected");
     475        return false;
     476    }
     477    if ((fault != INT16_MAX) && isfinite(burntool_state)) {
     478        psError(PS_ERR_UNKNOWN, false, "only one of -fault or -burntool_state must be selected");
    477479        return false;
    478480    }
     
    491493    }
    492494
    493     if (isfinite(user_1)) {
     495    if (isfinite(burntool_state)) {
    494496        psString query = pxDataGet("regtool_updateprocessedimfile.sql");
    495497        if (!query) {
     
    498500        }
    499501
    500         if (!p_psDBRunQueryF(config->dbh, query, user_1, exp_id, class_id)) {
     502        if (!p_psDBRunQueryF(config->dbh, query, burntool_state, exp_id, class_id)) {
    501503            psError(PS_ERR_UNKNOWN, false, "database error");
    502504            psFree(query);
  • trunk/ippTools/src/regtoolConfig.c

    r25418 r25425  
    155155    ADD_OPT(S64, updateprocessedimfileArgs, "-exp_id",        "search by exposure ID", 0);
    156156    ADD_OPT(Str, updateprocessedimfileArgs, "-class_id",      "search by class ID", NULL);
    157     ADD_OPT(F64, updateprocessedimfileArgs, "-user_1",        "set user stat (1)", NAN);
     157    ADD_OPT(S16, updateprocessedimfileArgs, "-burntool_state",        "set burntool state", 0);
    158158    ADD_OPT(S16, updateprocessedimfileArgs, "-fault",          "set fault code", INT16_MAX);
    159159
  • trunk/ippconfig/gpc1/camera.config

    r25383 r25425  
    147147
    148148PHOTCODE.RULE           STR     {DETECTOR}.{FILTER.ID}.{CHIP.NAME}      # Rule for generating photcode
     149
     150BURNTOOL.STATE.GOOD     S16     12  # Value for burntool_state with the most recent bt version.
  • trunk/ippconfig/gpc1/format_20090220.config

    r25299 r25425  
    207207        FPA.TELTEMP.TRUSS  STR  TELTEMTR # Mid truss temperatures (C
    208208        FPA.TELTEMP.EXTRA  STR  TELTEMEX # Miscellaneous temperatures (C)     
     209
     210        FPA.BURNTOOL.APPLIED STR BTOOLAPP
    209211
    210212        FPA.PON.TIME    STR     PONTIME
  • trunk/ippconfig/recipes/ppImage.config

    r25299 r25425  
    5656SCAN.ROWS        S32     100
    5757
    58 BURNTOOL.TRAILS U16 0x01
     58# Which regions identified by burntool to mask. 0x01 : only unfit trails, 0x02 "up" trails, 0x04 "down" trails
     59BURNTOOL.TRAILS     U16 0x01
    5960
    6061# Non-linearity correction
  • trunk/ippconfig/recipes/ppStats.config

    r24773 r25425  
    190190  CONCEPT       STR     FPA.TELTEMP.EXTRA  # Miscellaneous temperatures (C)     
    191191
     192  CONCEPT       STR     FPA.BURNTOOL.APPLIED
     193
    192194  CONCEPT       STR     FPA.PON.TIME    # time since last power on
    193195
  • trunk/ippconfig/recipes/ppStatsFromMetadata.config

    r23940 r25425  
    4444  ENTRY  VAL  FPA.TELTEMP.EXTRA   F32  CONSTANT          -teltemp_extra       # Miscellaneous temperatures (C)
    4545  ENTRY  VAL  FPA.PON.TIME        F32  CONSTANT          -pon_time            # time since last power on
     46#  ENTRY  VAL  FPA.BURNTOOL.APPLIED S32 CONSTANT          -burntool_state      #
    4647  ENTRY  VAL  CHIP.TEMP           F32  SAMPLE_MEAN       -ccd_temp            # CCD temperature
    4748  ENTRY  VAL  CELL.EXPOSURE       F32  SAMPLE_MEAN       -exp_time            # Exposure time
  • trunk/psModules/src/concepts/pmConcepts.c

    r25046 r25425  
    329329        conceptRegisterF32("FPA.TELTEMP.EXTRA", "Telescope Temperatures: extra", p_pmConceptParse_TELTEMPS, NULL, NULL, false, PM_FPA_LEVEL_FPA);
    330330        conceptRegisterF32("FPA.PON.TIME", "Power On Time", NULL, NULL, NULL, false, PM_FPA_LEVEL_FPA);
     331        conceptRegisterS32("FPA.BURNTOOL.APPLIED", "Status of burntool processing", p_pmConceptParse_BTOOLAPP,NULL,NULL,false,PM_FPA_LEVEL_FPA);
    331332        conceptRegisterF32("FPA.EXPOSURE", "Exposure time (sec)", NULL, NULL, NULL, false, PM_FPA_LEVEL_FPA);
    332333    }
     
    344345        conceptRegisterF32("CHIP.TEMP", "Temperature of chip", NULL, NULL, NULL, false, PM_FPA_LEVEL_CHIP);
    345346        conceptRegisterStr("CHIP.ID", "Chip identifier", NULL, NULL, NULL, false, PM_FPA_LEVEL_CHIP);
     347
    346348    }
    347349
  • trunk/psModules/src/concepts/pmConceptsRead.c

    r24824 r25425  
    7373        return false;
    7474    }
    75 
    7675    psTrace ("psModules.concepts", 3, "parsing concept: %s\n", spec->blank->name);
    7776    if (!strcmp (spec->blank->name, "CELL.XPARITY")) {
     
    275274        psMetadataItem *headerItem = NULL; // The value of the concept from the header
    276275
     276
    277277        psTrace ("psModules.concepts", 3, "reading concept: %s\n", name);
    278278        if (!strcmp (name, "CELL.XPARITY")) {
     
    307307            }
    308308        }
    309 
    310309        if (!headerItem) {
    311310            psMetadataItem *formatItem = psMetadataLookup(transSpec, name); // Item with keyword
     
    328327            }
    329328            psString keywords = formatItem->data.str; // The FITS keywords
    330 
    331329            // In case there are multiple headers
    332330            psList *keys = psStringSplit(keywords, " ,;", true); // List of keywords
  • trunk/psModules/src/concepts/pmConceptsStandard.c

    r25134 r25425  
    160160    assert(concept);
    161161    assert(pattern);
    162 
    163162    double value = NAN;
    164163    switch (concept->type) {
     
    632631    return psMetadataItemAllocS32(pattern->name, pattern->comment, binning);
    633632}
     633
     634// BTOOLAPP
     635psMetadataItem *p_pmConceptParse_BTOOLAPP(const psMetadataItem *concept,
     636                                          const psMetadataItem *pattern,
     637                                          pmConceptSource source,
     638                                          const psMetadata *cameraFormat,
     639                                          const pmFPA *fpa,
     640                                          const pmChip *chip,
     641                                          const pmCell *cell)
     642{
     643  assert(concept);
     644  assert(pattern);
     645
     646  int bt_status = 0;
     647
     648  if (concept->type != PS_DATA_BOOL) {
     649    psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Type for %s (%x) is not BOOL\n",
     650            concept->name, concept->type);
     651    return NULL;
     652  }
     653
     654  if (concept->data.B == true) {
     655    bt_status = -2;
     656  }
     657  else if (concept->data.B == false) {
     658    bt_status = 1 ;
     659  }
     660 
     661  return psMetadataItemAllocS32(concept->name, concept->comment, bt_status);
     662
    634663
    635664// Get the current value of a concept
  • trunk/psModules/src/concepts/pmConceptsStandard.h

    r22699 r25425  
    115115    );
    116116
     117/// Format for the BTOOLAPP conceptn
     118psMetadataItem *p_pmConceptParse_BTOOLAPP(
     119    const psMetadataItem *concept, ///< Concept to format
     120    const psMetadataItem *pattern,
     121    pmConceptSource source, ///< Source for concept
     122    const psMetadata *cameraFormat, ///< Camera format definition
     123    const pmFPA *fpa, ///< FPA for concept, or NULL
     124    const pmChip *chip, ///< Chip for concept, or NULL
     125    const pmCell *cell ///< Cell for concept, or NULL
     126    );
     127
     128
    117129/// Parse the cell binning concepts: CELL.XBIN, CELL.YBIN
    118130psMetadataItem *p_pmConceptParse_CELL_Binning(
  • trunk/tools/examine_burntool_pcontrol.pl

    r25300 r25425  
    22
    33# script to print out information about the current status of a burntool run.
    4 
    54use DBI;
    65use Getopt::Std;
     
    1514    print STDERR "         status of the processing.  On the OTA grid:\n";
    1615    print STDERR "                  _             Blank chip\n";
    17     print STDERR "                  N             Null value for user_1. No burntool attempted.\n";
    18     print STDERR "                  O             0.1 value for user_1. Burntool failed or is running.\n";
    19     print STDERR "                  B             1.0 value for user_1. Burntool succeeded.\n";
     16    print STDERR "                  N             Null/zero value for burntool_state. No burntool attempted.\n";
     17    print STDERR "                  O             -1 value for burntool_state. Burntool is running.\n";
     18    print STDERR "                  E             -2 value for burntool_state. Error!\n";
     19    print STDERR "                  B             Current version value for burntool_state. Burntool succeeded.\n";
     20    print STDERR "                  b             Old version value for burntool_state. Burntool needs to be rerun.\n";
    2021    exit(1);
    2122}
    22 
    23 # Read a class_id and user_1 pair, and set the correct cell of the (sorry, global) character array vector
     23$| = 1;
     24# Determine what the value of "BURNTOOL.STATE.GOOD" currently is:
     25$burntoolStateGood = 999;
     26open(LAZY,"ppConfigDump -camera GPC1 -dump-camera - |") || die "Can't run ppConfigDump\n";
     27while(<LAZY>) {
     28    chomp;
     29    if ($_ =~ /BURNTOOL.STATE.GOOD/) {
     30        @line = split /\s+/;
     31        $burntoolStateGood = $line[2];
     32    }
     33}
     34close(LAZY);
     35unless( $burntoolStateGood == 999) {
     36    print STDERR "GOOD == $burntoolStateGood\n";
     37}
     38
     39# Read a class_id and burntool_state pair, and set the correct cell of the (sorry, global) character array vector
    2440sub class_to_vector {
    2541    my $class = shift;
    26     my $user1 = shift;
     42    my $burntool_state = shift;
    2743    my $char = '_';
    28     if ($user1 == 1.0) {
    29         $char = '[32mB[m';
     44    if (abs($burntool_state) == $burntoolStateGood) {
     45        $char = '[32;01mB[m';
    3046        $burncount++;
    3147    }
    32     elsif ($user1 == 0.1) {
     48    elsif ($burntool_state == -1) {
     49        $char = '[01;33mP[m';
     50    }
     51    elsif ($burntool_state == 0) {
    3352        $char = '[31mO[m';
    3453    }
    35     elsif ($user1 == -1.0) {
    36         $char = '[34mN[m';
     54    elsif ($burntool_state == -2) {
     55        $char = '[35;01;44;05mE[m';
     56    }
     57    elsif ($burntool_state == -3) {
     58        $char = '[34mX[m';
     59    }
     60    else {
     61        $char = '[32mb[m';
    3762    }
    3863   
     
    4772# Engauge autoflush, in case the database server is acting up.
    4873$| = 1;
    49 
    5074
    5175# Load the pcontrol.pro file, and create arrays of the dates included
     
    96120    # Get the data.  The limit is there to keep the database happy.  I don't think you can observe that many
    97121    # images on a single night.
    98     $sth = "SELECT exp_id,exp_name,obs_mode,dateobs,class_id,user_1,comment FROM rawImfile WHERE dateobs >= '${dmin}' AND dateobs <= '${dmax}' order by dateobs limit 60000";
     122    $sth = "SELECT exp_id,exp_name,obs_mode,dateobs,class_id,burntool_state,comment FROM rawImfile WHERE dateobs >= '${dmin}' AND dateobs <= '${dmax}' order by dateobs limit 60000";
    99123    $data_ref = $db->selectall_arrayref( $sth );
    100124
     
    122146   
    123147    foreach $row_ref (@{ $data_ref }) {
    124         ($exp_id,$exp_name, $obs_mode,$dateobs,$class_id,$user_1,$comment) = @{ $row_ref };
     148        ($exp_id,$exp_name, $obs_mode,$dateobs,$class_id,$burntool_state,$comment) = @{ $row_ref };
     149
    125150        # Correct for nulls in the database.
    126151        if (!defined($obs_mode)) {
    127152            $obs_mode = 'NULL';
    128153        }
    129         if (!defined($user_1)) {
    130             $user_1 = -1;
     154        if (!defined($burntool_state)) {
     155            $burntool_state = 0;
    131156        }
    132157        if (!defined($comment)) {
    133158            $comment = ' ';
    134159        }
    135 
     160#       print "$exp_id $class_id $burntool_state\n";
    136161        # If we're still working on the same exp_id, update the chip we got
    137162        if ($exp_id == $cur_exp_id) {
    138             class_to_vector($class_id,$user_1);
     163            class_to_vector($class_id,$burntool_state);
    139164        }
    140165        else {
     
    156181            }
    157182            ($cur_exp_id,$cur_exp_name,$cur_obs_mode,$cur_dateobs,$cur_comment) = ($exp_id,$exp_name,$obs_mode,$dateobs,$comment);
    158             class_to_vector($class_id,$user_1);
     183            class_to_vector($class_id,$burntool_state);
    159184        }
    160185    }
     
    169194    if ($burncount != 60) {
    170195        for ($j = 0; $j < 64; $j++) {
    171             $vector[$j] =~ s/\[..m(.).*/$1/;
    172             if ($vector[$j] ne 'B') {
     196#           printf("%d %s %d\n",$j, $vector[$j], ($vector[$j] !~ /B/));
     197            if ($vector[$j] !~ /B/) {
    173198                if ($vector[$j] ne '_') {
    174199                    $id = sprintf("XY%d%d",int($j / 8),$j % 8);
  • trunk/tools/ipp_apply_burntool.pl

    r25412 r25425  
    1212use Carp;
    1313
    14 use IPC::Cmd 0.36 qw( can_run );
    15 use IPC::Run 0.36 qw( run );
     14use IPC::Cmd 0.36 qw( can_run run );
     15#use IPC::Run 0.36 qw( run );
    1616use PS::IPP::Metadata::List qw( parse_md_list );
    1717use PS::IPP::Config 1.01 qw( :standard );
     
    2020use Pod::Usage qw( pod2usage );
    2121
    22 my ( $class_id, $dateobs_begin, $dateobs_end, $skip_burned, $rerun_from_first, $dbname, $logfile, $verbose, $save_temps);
     22my ( $class_id, $dateobs_begin, $dateobs_end, $convert, $camera, $dbname, $logfile, $verbose, $save_temps);
    2323GetOptions(
    2424    'class_id=s'        => \$class_id, # chip identifier
    2525    'dateobs_begin=s'   => \$dateobs_begin, # exposure date/time range start
    2626    'dateobs_end=s'     => \$dateobs_end, # exposure date/time range stop
     27    'camera=s'          => \$camera,     # Camera
    2728    'dbname|d=s'        => \$dbname, # Database name
    2829    'logfile=s'         => \$logfile,
    29     'skip_burned'       => \$skip_burned,   # Print to stdout
    30     'rerun_from_first'  => \$rerun_from_first,   # Print to stdout
    3130    'verbose'           => \$verbose,   # Print to stdout
    3231    'save-temps'        => \$save_temps, # Save temporary files?
     32
    3333    ) or pod2usage( 2 );
    3434
     
    4343    defined $dbname;
    4444
    45 if ($skip_burned and $rerun_from_first) { &my_die("-rerun_from_first and -skip_burned are incompatible"); }
     45unless (defined $camera) {
     46    $camera = "GPC1";
     47#    warn("No camera defined. Defaulting to $camera and warning.");
     48}
    4649
    4750my $missing_tools;
     
    4952my $funpack  = can_run('funpack')  or (warn "Can't find funpack" and $missing_tools = 1);
    5053my $burntool = can_run('burntool') or (warn "Can't find burntool" and $missing_tools = 1);
    51 my $fpack    = can_run('fpack')    or (warn "Can't find fpack" and $missing_tools = 1);
     54my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     55#my $fpack    = can_run('fpack')    or (warn "Can't find fpack" and $missing_tools = 1);
    5256if ($missing_tools) {
    5357    warn("Can't find required tools.");
     
    5761my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    5862
     63# IPP configuration (including nebulous)
     64my $ipprc = PS::IPP::Config->new( $camera ) or my_die("Unable to set up");
     65
     66$ipprc->redirect_output($logfile) if $logfile;
     67
     68# Determine the value of a "good" burntool run.
     69my $config_cmd = "$ppConfigDump -camera $camera -dump-camera - | grep BURNTOOL";
     70my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     71    run ( command => $config_cmd, verbose => $verbose);
     72unless ($success) {
     73    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     74    &my_die("Unable to perform ppConfigDump: $error_code", 0, 0, $class_id, $PS_EXIT_SYS_ERROR);
     75}
     76
     77my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
     78    &my_die("Unable to parse metadata config doc", 0, 0, $class_id, $PS_EXIT_SYS_ERROR);
     79
     80my $burntoolStateGood = 999;
     81foreach my $cfg (@$recipeData) {
     82    if ($cfg->{name} eq 'BURNTOOL.STATE.GOOD') {
     83        $burntoolStateGood = $cfg->{value};
     84    }
     85}
     86if ($burntoolStateGood == 999) {
     87    &my_die("Failed to determine BURNTOOL.STATE.GOOD", $burntoolStateGood, $class_id, 0, $PS_EXIT_SYS_ERROR);
     88}
     89my $outState = -1 * abs($burntoolStateGood);
     90
     91print ">>$burntoolStateGood<<\n";
     92
     93# Define list of images to examine.
    5994my $command = "$regtool -processedimfile";
    6095$command .= " -class_id $class_id";
     
    6499$command .= " -dbname $dbname" if defined $dbname;
    65100
    66 my @command = split /\s+/, $command;
    67 my ( $stdin, $stdout, $stderr ); # Buffers for running program
    68 print "Running [$command]...\n" if $verbose;
    69 if (not run(\@command, \$stdin, \$stdout, \$stderr)) {
    70     &my_die("Unable to perform regtool -processedimfile");
    71 }
    72 print $stdout . "\n" if $verbose;
    73 
    74 my @files;
    75 my @whole = split /\n/, $stdout;
    76 my @single = ();
    77 while ( scalar @whole > 0 ) {
    78     my $value = shift @whole;
    79     push @single, $value;
    80     if ($value =~ /^\s*END\s*$/) {
    81         push @single, "\n";
    82 
    83         my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) );
    84         &my_die("Unable to parse output from regtool") unless defined $list;
    85         push @files, @$list;
    86         @single = ();
    87     }
    88 }
    89 
    90 # IPP configuration (including nebulous)
    91 my $ipprc = PS::IPP::Config->new() or my_die("Unable to set up");
    92 
    93 $ipprc->redirect_output($logfile) if $logfile;
    94 
    95 my $Nfiles = @files;
    96 print "files: $Nfiles\n";
     101( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     102    run ( command => $command, verbose => $verbose);
     103unless ($success) {
     104    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     105    &my_die("Unable to perform regtool: $error_code", $class_id, $dateobs_begin, $dateobs_end, $PS_EXIT_SYS_ERROR);
     106}
     107
     108my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     109    &my_die("Unable to parse metadata", $class_id, $dateobs_begin, $dateobs_end, $PS_EXIT_SYS_ERROR);
     110
     111my $files = parse_md_list($metadata) or
     112    &my_die("Unable to parse metadat list", $class_id, $dateobs_begin, $dateobs_end, $PS_EXIT_SYS_ERROR);
    97113
    98114my $REALRUN = 1;
    99 my $RAWTABLES = 1;
    100 # XXX if we want to avoid using the raw tables in this script, we need to delay deletion of the tempfile until the next pass.
    101 
    102 # first pass: mark the db entries to catch failures
    103 # these will not be identified as burned by chip processing (user_1 > 0.5)
    104 if (! $skip_burned)  {
    105     foreach my $file (@files) {
     115
     116# Process each file in turn, checking to see if it needs processing, and doing it all in a single pass
     117my $processNext = 0;
     118my $previousTable = '';
     119
     120foreach my $file (@$files) {
     121    my $exp_id = $file->{exp_id};
     122    my $state = $file->{burntool_state};
     123
     124    my $rawImfile = $file->{uri};
     125    my $rawImfileReal = $ipprc->file_resolve($rawImfile, 0);
     126   
     127    my $outTable  = $file->{uri};
     128    $outTable  =~ s/fits$/burn.tbl/;
     129    my $outTableReal = $ipprc->file_resolve($outTable, 1);
     130   
     131    my $process = 0;
     132
     133    if ($state == 0) {
     134        $process = 1;
     135    }
     136    elsif ($state == -1) {
     137        $process = 1;
     138    }
     139    elsif ($state == -3) {
     140        $process = 1;
     141    }
     142    elsif ($state == -2) {
     143        &my_die("Aborting as $rawImfile has modified pixel data!");
     144    }
     145    elsif ($state == $burntoolStateGood) {
     146        $process = 0;
     147        $previousTable = "infits=$rawImfileReal";
     148    }
     149    elsif ($state == -1 * $burntoolStateGood) {
     150        $process = 0;
     151        $previousTable = "in=$outTableReal";
     152    }
     153    else {
     154        $process = 1;
     155    }
     156
     157    if (($process == 1)||($processNext == 1)) {
     158        $processNext = 1;
     159        # Set state to processing
     160        my $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -1", $REALRUN);
     161        if ($status) {
     162            &my_die("failed to update imfile");
     163        }
     164        $file->{burntool_state} = -1;
    106165       
    107         # rerun_from_first treats the first image as already burned (if it is already burned)
    108         # the artifact table from the first file is used for the rest of the sequence.
    109         if ($rerun_from_first) {
    110             $skip_burned = 1;
    111             $rerun_from_first = 0;
    112             next;
    113         }
    114         my $exp_id = $file->{exp_id};
    115 
    116         my $status;
    117         $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -user_1 0.1", 1);
     166        my $tempfile = new File::Temp ( TEMPLATE => "$file->{exp_name}.XXXX",
     167                                        DIR => '/tmp/',
     168                                        UNLINK => !$save_temps,
     169                                        SUFFIX => '.fits');
     170        my $tempPixels = $tempfile->filename;
     171       
     172        # Run burntool
     173        $status = vsystem ("$funpack -S $rawImfileReal > $tempPixels", $REALRUN);
     174        if ($status) {
     175            &my_die("failed on funpack",$exp_id,$class_id);
     176        }
     177        if ($previousTable ne '') {
     178            $status = vsystem ("$burntool $tempPixels $previousTable out=$outTableReal tableonly=t persist=t", $REALRUN);
     179        }
     180        else {
     181            $status = vsystem ("$burntool $tempPixels out=$outTableReal tableonly=t persist=t", $REALRUN);
     182        }
     183        if ($status) {
     184            &my_die("failed on burntool",$exp_id,$class_id);
     185        }
     186       
     187        $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state $outState", $REALRUN);
    118188        if ($status) {
    119189            &my_die("failed to update imfile");
    120190        }
    121         $file->{user_1} = 0.1;
    122     }
    123 }
    124 
    125 my $prevFileOpt = "";
    126 foreach my $file (@files) {
    127     my $exp_id = $file->{exp_id};
    128 
    129     my $rawImfile = $file->{uri};
    130     my $rawImfileReal;
    131     if ($REALRUN) {
    132         $rawImfileReal = $ipprc->file_resolve($rawImfile, 0);
    133     } else {
    134         ($rawImfileReal) = $rawImfile =~ m|^neb:/(.*)|;
    135     }
    136     print "rawImfile: $rawImfile -> $rawImfileReal\n";
    137 
    138     # mangle name, create tmp file (always a UNIX file)
    139     my $basename = `basename $rawImfile`; chomp $basename;
    140     my $tempfile = new File::Temp ( TEMPLATE => "$basename.XXXX",
    141                                     DIR => '/tmp',
    142                                     UNLINK => !$save_temps,
    143                                     SUFFIX => '.fits');
    144     my $tmpImfileReal = $tempfile->filename;
    145     # print "tmpImfile: $tmpImfile -> $tmpImfileReal\n";
    146    
    147     # destination for the burntool-applied image file (may be a NEB file)
    148     my $outImfile = $rawImfile;
    149     $outImfile =~ s/fits$/burn.fits/;
    150     my $outImfileReal = $ipprc->file_resolve($outImfile, 1);
    151     # print "outImfile: $outImfile -> $outImfileReal\n";
    152 
    153     # burntool now can write the artifacts to the fits file.
    154     # destination for the burntool artifacts.  use this if RAWTABLES is set.
    155     my $artImfile;
    156     my $artImfileReal;
    157     if ($RAWTABLES) {
    158         $artImfile = $rawImfile;
    159         $artImfile =~ s/fits$/burn.tbl/;
    160         $artImfileReal = $ipprc->file_resolve($artImfile, 1);
    161         # print "artImfile: $artImfile -> $artImfileReal\n";
    162     }
    163 
    164     print "$rawImfile : $skip_burned, $file->{user_1}\n";
    165 
    166     if (! ($skip_burned and ($file->{user_1} > 0.5))) {
    167         print "running on: $rawImfile\n";
    168         # uncompress the image (do we need to check if it is compressed?)
    169         my $status = vsystem ("$funpack -S $rawImfileReal > $tmpImfileReal", $REALRUN);
    170         if ($status) {
    171             &my_die("failed on funpack");
    172         }
    173 
    174         if ($RAWTABLES) {
    175             $status = vsystem ("$burntool $tmpImfileReal out=$artImfileReal $prevFileOpt persist=t", $REALRUN);
    176         } else {
    177             $status = vsystem ("$burntool $tmpImfileReal $prevFileOpt persist=t", $REALRUN);
    178         }
    179         if ($status) {
    180             &my_die("failed on burntool");
    181         }
    182 
    183         # compress the image (do we need to check if it is compressed?)
    184         $status = vsystem ("$fpack -S $tmpImfileReal > $outImfileReal", $REALRUN);
    185         if ($status) {
    186             &my_die("failed on fpack");
    187         }
    188 
    189         # set the user_1 value to a new result value for now
    190         $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -user_1 2.0", 1);
    191         if ($status) {
    192             &my_die("failed to update imfile");
    193         }
    194         print "\n";
    195     }
    196     # save the artifact file for the next image
    197     if ($RAWTABLES) {
    198         $prevFileOpt = "in=$artImfileReal";
    199     } else {
    200         $prevFileOpt = "infits=$artImfileReal";
    201     }
    202 }
    203 
     191
     192        $previousTable = "in=$outTableReal";
     193
     194        print "\n";
     195    }
     196}
     197   
    204198exit 0;
    205199
     
    220214sub my_die {
    221215    my $message = shift;
    222 
     216    if ($#_ != -1) {
     217        my $exp_id = shift;
     218        my $class_id = shift;
     219        vsystem("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -3",1);
     220    }
    223221    printf STDERR "$message\n";
    224222    exit 1;
Note: See TracChangeset for help on using the changeset viewer.