IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28334


Ignore:
Timestamp:
Jun 15, 2010, 11:22:56 AM (16 years ago)
Author:
watersc1
Message:

association and jpegs look fine. random simtest errors are a bit worrying, though.

Location:
branches/czw_branch/20100519
Files:
8 added
1 deleted
42 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20100519

  • branches/czw_branch/20100519/Ohana

  • branches/czw_branch/20100519/Ohana/src/photdbc/src/copy_images.c

    r17284 r28334  
    33int copy_images (char *outdir) {
    44
    5   int status, Nimage;
     5  int status;
     6  off_t Nimage;
    67  char *ImageOut;
    78  FITS_DB in;
  • branches/czw_branch/20100519/Ohana/src/photdbc/src/join_stars.c

    r27435 r28334  
    77  off_t Naverage, Nmeasure, *index;
    88  double *X, *Y, dX, dY, dR, RADIUS2;
    9   double Sr, Sd, Rmid, Dmid;
     9  double Rmid, Dmid;
    1010  int basecode, baseNsec, Nsecfilt, *found;
    1111
     
    202202
    203203  if (Nmeas != Nmeasure) {
    204     fprintf (stderr, "failure to match %d measures (%d of %d matched)\n", Nmeasure - Nmeas, Nmeas, Nmeasure);
     204    fprintf (stderr, "failure to match "OFF_T_FMT" measures ("OFF_T_FMT" of "OFF_T_FMT" matched)\n", Nmeasure - Nmeas, Nmeas, Nmeasure);
    205205  }
    206206 
  • branches/czw_branch/20100519/Ohana/src/photdbc/src/make_subcatalog.c

    r17284 r28334  
    55int make_subcatalog (Catalog *subcatalog, Catalog *catalog) {
    66 
    7   int i, j, offset;
    8   int NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm, Nsecfilt;
     7  off_t i, j, offset;
     8  off_t NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm, Nsecfilt;
    99  double mag, minMag;
    1010
     
    105105
    106106  if (VERBOSE) {
    107     fprintf (stderr, "%d: using %d stars (%d measures) for catalog\n", i,
     107    fprintf (stderr, OFF_T_FMT": using "OFF_T_FMT" stars ("OFF_T_FMT" measures) for catalog\n", i,
    108108             subcatalog[0].Naverage, subcatalog[0].Nmeasure);
    109109  }
  • branches/czw_branch/20100519/Ohana/src/photdbc/src/photdbc.c

    r25757 r28334  
    6060       
    6161    // XXX add other filters here:
    62     join_stars (&outcatalog);
     62    // join_stars (&outcatalog);
    6363    // unique_measures (catalog);
    6464    // flag_measures (&db, catalog);
  • branches/czw_branch/20100519/dbconfig/changes.txt

    r28304 r28334  
    17561756) ENGINE=innodb DEFAULT CHARSET=latin1;
    17571757
    1758 -- Version 1.1.69
     1758ALTER TABLE pstampRequest ADD COLUMN timestamp TIMESTAMP AFTER outdir;
     1759
     1760-- Version 1.1.69 warp/stack/diff summary and stack associations.
     1761
    17591762CREATE TABLE warpSummary (
    17601763    warp_id     BIGINT,
     
    18041807) ENGINE=innodb DEFAULT CHARSET=latin1;
    18051808
     1809
     1810
     1811
     1812
  • branches/czw_branch/20100519/dbconfig/pstamp.md

    r28304 r28334  
    3131    uri         STR         255
    3232    outdir      STR         255
     33    timestamp   UTC         0001-01-01T00:00:00Z
    3334    fault       S32         0
    3435END
  • branches/czw_branch/20100519/ippScripts/scripts/addstar_run.pl

    r28304 r28334  
    3636    exit($PS_EXIT_CONFIG_ERROR);
    3737}
    38 
     38my $minidvodb_path;
    3939my ( $exp_tag, $add_id, $camera, $outroot, $camroot, $dbname, $reduction, $dvodb, $minidvodb, $minidvodb_name, $minidvodb_group, $image_only, $verbose, $no_update,
    4040     $no_op, $redirect, $save_temps);
     
    132132                    &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR);
    133133                my $comp = $$components[0];
     134                $minidvodb_path = $comp->{minidvodb_path};
    134135                $minidvodb_name = $comp->{minidvodb_name};
    135136       
     137                if (!defined($minidvodb_path)) {
     138                    &my_die("Unable to parse minidvodb_path", $add_id, $PS_EXIT_PROG_ERROR);
     139                }
    136140                if (!defined($minidvodb_name)) {
    137141                    &my_die("Unable to parse minidvodb_name", $add_id, $PS_EXIT_PROG_ERROR);
    138                 }
    139                
     142                }
    140143            }
    141144            # tack on the minidvodb part to the db.
    142             $dvodbReal = $dvodbReal . '/' . $minidvodb_name . '/';
     145#           $dvodbReal = $dvodbReal . '/' . $minidvodb_name . '/';
     146#we don't need this now that I fixed the paths     
    143147           
    144148        }
     
    160164        my $command  = "$addstar -update"; # XXX optionally set -update?
    161165        $command .= " -D CAMERA $camdir";
    162         $command .= " -D CATDIR $dvodbReal";
     166        $command .= " -D CATDIR $minidvodb_path";
    163167        $command .= " $realFile";
    164168        $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference
     
    182186$fpaCommand .= " -path_base $outroot";
    183187$fpaCommand .= " -dtime_addstar $dtime_addstar";
    184 $fpaCommand .= " -dvodb_path $dvodbReal" if defined $dvodbReal;
     188$fpaCommand .= " -dvodb_path $minidvodb_path" if defined $minidvodb_path;
    185189$fpaCommand .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name;
    186190$fpaCommand .= " -dbname $dbname" if defined $dbname;
     
    213217        $command .= " -addprocessedexp";
    214218        $command .= " -fault $exit_code";
    215         $command .= " -dvodb_path $dvodbReal" if defined $dvodbReal;
     219        $command .= " -dvodb_path $minidvodb_path" if defined $minidvodb_path;
    216220        $command .= " -path_base $outroot" if defined $outroot;
    217221        $command .= (" -dtime_addstar " . ((DateTime->now->mjd - $mjd_start) * 86400));
  • branches/czw_branch/20100519/ippScripts/scripts/minidvodb_createdb.pl

    r28304 r28334  
    3939}
    4040
    41 my (  $outroot, $dbname, $dvodb,$minidvodb_interval, $minidvodb_group, $camera,  $verbose, $no_update,
     41my (  $outroot, $dbname, $dvodb, $minidvodb,$minidvodb_interval, $minidvodb_group, $camera,  $verbose, $no_update,
    4242     $no_op, $redirect, $save_temps);
    4343GetOptions(   
     
    4747    'outroot|w=s'       => \$outroot, # output file base name
    4848    'dvodb|w=s'         => \$dvodb,  # output DVO database
     49    'minidvodb|w=s'     => \$minidvodb, # output miniDVODB
    4950    'interval|w=s'      => \$minidvodb_interval, #interval between creation of minidvodbs (default = 1day)
    5051    'verbose'           => \$verbose,   # Print to stdout
     
    9798    exit(4);
    9899}
     100my $minidvodbReal;
     101if (defined $minidvodb) {
     102    $minidvodbReal = $ipprc->dvo_catdir( $minidvodb ); # catdir for DVO
     103    $minidvodbReal = $ipprc->convert_filename_absolute( $minidvodbReal );
     104} else {
     105    warn("minidvodb undefined:\n");
     106    exit(4);
     107}
     108
    99109
    100110if (!defined $minidvodb_interval) {
     
    215225    my $fpaCommand = "$addtool -addminidvodbrun";
    216226    $fpaCommand .= " -set_minidvodb_group $minidvodb_group";
     227    $fpaCommand .= " -set_minidvodb_path  $minidvodbReal" if defined $minidvodbReal;
    217228    $fpaCommand .= " -set_mergedvodb_path $dvodbReal";
    218229    $fpaCommand .= " -dbname $dbname" if defined $dbname;
  • branches/czw_branch/20100519/ippScripts/scripts/skycell_jpeg.pl

    r28304 r28334  
    273273        my $path_base  = $imfile->{path_base};
    274274        my $quality    = $imfile->{quality};
    275         my $state      = $imfile->{data_state};
     275        my $state      = $imfile->{state};
    276276        my $fault      = $imfile->{fault};
    277277        my $projection_cell = $skycell_id;
    278         if ($quality == 8007 or $state ne 'full' or $fault != 0) {
     278        if ($quality == 8007 or $state ne 'full') {
    279279            next;
    280280        }
     
    333333    if (scalar (keys %tangents) == 0) {
    334334        my $projection_cell = 'NULL';
    335         $command = "$stacktool -addsummary -stack_id $stage_id -projection_cell $projection_cell -path_base $outroot";
    336         if (defined($dbname)) {
    337             $command .= " -dbname $dbname";
    338         }
    339        
    340         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
    341         unless ($success) {
    342             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    343             &my_die("unable to update diff summary: $error_code", $stage_id, $error_code);
     335        $command = "$stacktool -addsummary -sass_id $stage_id -projection_cell $projection_cell -path_base $outroot";
     336        if (defined($dbname)) {
     337            $command .= " -dbname $dbname";
     338        }
     339#       print "$command\n";
     340        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
     341        unless ($success) {
     342            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     343            &my_die("unable to update stack summary: $error_code", $stage_id, $error_code);
    344344        }
    345345    }   
  • branches/czw_branch/20100519/ippTasks/diff.pro

    r28304 r28334  
    574574    book getword diffPendingSummary $pageName workdir -var WORKDIR_TEMPLATE
    575575    book getword diffPendingSummary $pageName dbname -var DBNAME
    576     book getword warpPendingSummary $pageName tess_id -var TESS_DIR
     576    book getword diffPendingSummary $pageName tess_id -var TESS_DIR
    577577    book getword diffPendingSummary $pageName diff_mode -var DIFF_MODE
    578578    book getword diffPendingSummary $pageName state -var RUN_STATE
     
    601601
    602602    ## generate outroot specific to this exposure
    603     sprintf outroot "%s/%s/%s/%s.%s.%sdif.%s.summary" $WORKDIR $TESS_ID $SKYCELL_ID $TESS_ID $SKYCELL_ID $DIFF_TAG $DIFF_ID
     603    sprintf outroot "%s/%s/%s.%sdif.%s.summary" $WORKDIR $TESS_ID $TESS_ID $DIFF_TAG $DIFF_ID
    604604
    605605
  • branches/czw_branch/20100519/ippTasks/minidvodb.pro

    r28304 r28334  
    131131## you get no choice - you add all of them in at the same time. you can always turn off the tasks you don't want to run.
    132132macro add.minidvodb
    133   if ($0 != 5)
    134     echo "USAGE: add.minidvodb (minidvodb_group) (dvodb) (interval days) (camera)"
     133  if ($0 != 6)
     134    echo "USAGE: add.minidvodb (minidvodb_group) (minidvodb) (dvodb) (interval days) (camera)"
    135135    break
    136136  end
     
    139139  book newpage MINIDVODB $1
    140140  book setword MINIDVODB $1 MINIDVODB_GROUP $1
    141   book setword MINIDVODB $1 DVODB $2
     141  book setword MINIDVODB $1 DVODB $3
    142142  book setword MINIDVODB $1 STATE PENDING
    143143  #merge 
    144144  book newpage MINIDVODB_MERGE $1
    145145  book setword MINIDVODB_MERGE $1 MINIDVODB_GROUP $1
    146   book setword MINIDVODB_MERGE $1 DVODB $2
     146  book setword MINIDVODB_MERGE $1 DVODB $3
    147147  book setword MINIDVODB_MERGE $1 STATE PENDING
    148148  #active 
    149149  book newpage MINIDVODB_ACTIVE $1
    150150  book setword MINIDVODB_ACTIVE $1 MINIDVODB_GROUP $1
    151   book setword MINIDVODB_ACTIVE $1 DVODB $2
     151  book setword MINIDVODB_ACTIVE $1 DVODB $3
    152152  book setword MINIDVODB_ACTIVE $1 STATE PENDING
    153153
     
    155155  book newpage MINIDVODB_CREATE $1
    156156  book setword MINIDVODB_CREATE $1 MINIDVODB_GROUP $1
    157   book setword MINIDVODB_CREATE $1 DVODB $2
    158   book setword MINIDVODB_CREATE $1 DVODB_DAYS $3
    159   book setword MINIDVODB_CREATE $1 CAMERA $4 
     157  book setword MINIDVODB_CREATE $1 MINIDVODB $2
     158  book setword MINIDVODB_CREATE $1 DVODB $3
     159  book setword MINIDVODB_CREATE $1 DVODB_DAYS $4
     160  book setword MINIDVODB_CREATE $1 CAMERA $5 
    160161  book setword MINIDVODB_CREATE $1 STATE PENDING 
    161162end
     
    542543     
    543544    book setword MINIDVODB_CREATE $minidvodb_group STATE DONE
     545    book getword MINIDVODB_CREATE $minidvodb_group MINIDVODB -var minidvodb
    544546    book getword MINIDVODB_CREATE $minidvodb_group DVODB -var dvodb
    545547    book getword MINIDVODB_CREATE $minidvodb_group DVODB_DAYS -var dvodb_days
    546548    book getword MINIDVODB_CREATE $minidvodb_group CAMERA -var camera
    547     $run = minidvodb_createdb.pl --camera $camera --outroot $dvodb --dvodb $dvodb --minidvodb_group $minidvodb_group --interval $dvodb_days
     549    $run = minidvodb_createdb.pl --camera $camera --outroot $dvodb --dvodb $dvodb --minidvodb $minidvodb --minidvodb_group $minidvodb_group --interval $dvodb_days
    548550 
    549551    if ($DB:n == 0)
  • branches/czw_branch/20100519/ippTasks/stack.pro

    r28304 r28334  
    1010### Initialise the books containing the tasks to do
    1111book init stackSumSkyfile
     12book init stackPendingSummary
    1213#book init stackCleanup
    1314
     
    1617$stack_revert_DB = 0
    1718#$stackCleanup_DB = 0
     19$stackSummary_DB = 0
    1820
    1921### Check status of stacking tasks
     
    2628macro stack.reset
    2729  book init stackSumSkyfile
     30  book init stackPendingSummary
    2831#  book init stackCleanup
    2932end
     
    4043    active false
    4144  end
     45  task stack.summary.load
     46    active true
     47  end
     48  task stack.summary.run
     49    active true
     50  end
    4251end
    4352
     
    5160  end
    5261  task stack.revert
     62    active false
     63  end
     64  task stack.summary.load
     65    active false
     66  end
     67  task stack.summary.run
    5368    active false
    5469  end
     
    403418end
    404419
     420### Load tasks for doing the stack summary
     421### Tasks are loaded into stackPendingSummary
     422task           stack.summary.load
     423  host         local
     424
     425  periods      -poll $LOADPOLL
     426  periods      -exec $LOADEXEC
     427  periods      -timeout 1200
     428  npending     1
     429
     430  stdout       NULL
     431  stderr       $LOGDIR/stack.summary.load
     432
     433  task.exec
     434    if ($LABEL:n == 0) break
     435    $run = stacktool -tosummary
     436    if ($DB:n == 0)
     437      option DEFAULT
     438    else
     439      # save the DB name for the exit tasks
     440      option $DB:$stackSummary_DB
     441      $run = $run -dbname $DB:$stackSummary_DB
     442      $stackSummary_DB ++
     443      if ($stackSummary_DB >= $DB:n) set stackSummary_DB = 0
     444    end
     445    add_poll_args run
     446    add_poll_labels run
     447    command $run
     448  end
     449
     450  # success
     451  task.exit     0
     452    # convert 'stdout' to book format
     453    ipptool2book stdout stackPendingSummary -key sass_id -uniq -setword dbname $options:0 -setword pantaskState INIT
     454    if ($VERBOSE > 2)
     455      book listbook stackPendingSummary
     456    end
     457
     458    # delete existing entries in the appropriate pantaskStates
     459    process_cleanup stackPendingSummary
     460  end
     461
     462  # locked list
     463  task.exit     default
     464    showcommand failure
     465  end
     466
     467  task.exit     crash
     468    showcommand crash
     469  end
     470
     471  # operation times out?
     472  task.exit     timeout
     473    showcommand timeout
     474  end
     475end
     476
     477### Run tasks for doing the stack summary
     478task           stack.summary.run
     479  periods      -poll $RUNPOLL
     480  periods      -exec $RUNEXEC
     481  periods      -timeout 60
     482
     483  task.exec
     484    # if we are unable to run the 'exec', use a long retry time
     485    periods -exec $RUNEXEC
     486
     487    book npages stackPendingSummary -var N
     488    if ($N == 0) break
     489    if ($NETWORK == 0) break
     490
     491    # look for new images in stackPendingSummary (pantaskState == INIT)
     492    book getpage stackPendingSummary 0 -var pageName -key pantaskState INIT
     493    if ("$pageName" == "NULL") break
     494
     495    book setword stackPendingSummary $pageName pantaskState RUN
     496    book getword stackPendingSummary $pageName sass_id -var SASS_ID
     497    book getword stackPendingSummary $pageName camera -var CAMERA
     498    book getword stackPendingSummary $pageName workdir -var WORKDIR_TEMPLATE
     499    book getword stackPendingSummary $pageName dbname -var DBNAME
     500    book getword stackPendingSummary $pageName tess_id -var TESS_DIR
     501    book getword stackPendingSummary $pageName state -var RUN_STATE
     502    book getword stackPendingSummary $pageName projection_cell -var projection_cell
     503
     504    # set the host and workdir
     505    host anyhost
     506    strsub $WORKDIR_TEMPLATE @HOST@.0 $default_host -var WORKDIR
     507
     508    basename $TESS_DIR -var TESS_ID
     509
     510    ## generate outroot specific to this association
     511    sprintf outroot "%s/%s/%s.stk.%s.summary" $WORKDIR $TESS_ID $TESS_ID $SASS_ID
     512
     513    stdout $LOGDIR/stack.summary.log
     514    stderr $LOGDIR/stack.summary.log
     515
     516    $run = skycell_jpeg.pl --stage stack --stage_id $SASS_ID --camera $CAMERA --outroot $outroot
     517    add_standard_args run
     518
     519    # save the pageName for future reference below
     520    options $pageName
     521
     522    # create the command line
     523    if ($VERBOSE > 1)
     524        echo command $run
     525    end
     526    periods -exec 0.05
     527    command $run
     528  end
     529
     530  # default exit status
     531  task.exit       default
     532    process_exit stackPendingSummary $options:0 $JOB_STATUS
     533  end
     534
     535  # locked list
     536  task.exit       crash
     537    showcommand crash
     538    echo "hostname: $JOB_HOSTNAME"
     539    book setword stackPendingSummary $options:0 pantaskState CRASH
     540  end
     541
     542  # operation timed out?
     543  task.exit       timeout
     544    showcommand timeout
     545    book setword stackPendingSummary $options:0 pantaskState TIMEOUT
     546  end
     547end
     548
  • branches/czw_branch/20100519/ippToPsps/src/ippToPspsBatchDetection.c

    r28304 r28334  
    5454    float zptObs, zeroPoint, exposureTime;
    5555    char filterType[20];
     56    double obsTime;
     57    double expStart;
     58    double expTime;
    5659    status=0; fits_read_key(fitsIn, TFLOAT, "ZPT_OBS", &zptObs, NULL, &status);
    5760    status=0; fits_read_key(fitsIn, TFLOAT, "ZPT_REF", &zeroPoint, NULL, &status);
    5861    status=0; fits_read_key(fitsIn, TFLOAT, "EXPREQ", &exposureTime, NULL, &status);
    5962    status=0; fits_read_key(fitsIn, TSTRING, "FILTERID", filterType, NULL, &status);
    60    
     63    status=0; fits_read_key(fitsIn, TDOUBLE, "MJD-OBS", &expStart, NULL, &status);
     64    status=0; fits_read_key(fitsIn, TDOUBLE, "EXPTIME", &expTime, NULL, &status);
     65    obsTime = expStart + (expTime/172800); // exp start plus half exp time (converted from secs to days)
     66   
    6167    ippToPspsConfig_writeTable(this->config, fitsIn, this->fitsOut, 1, "FrameMeta", true);
    6268
     
    8389
    8490    // stuff to keep from psf.hdr header
    85     double obsTime = 0.0;
    8691    int sourceId = -1;
    8792    int imageId = -1;
     
    132137    long ippDetectID[MAXDETECT];
    133138    long imageID[MAXDETECT];
    134     float obsTimes[MAXDETECT];
     139    double obsTimes[MAXDETECT];
    135140    float instFlux[MAXDETECT];
    136141    float instFluxErr[MAXDETECT];
     
    195200            status=0; fits_read_key(fitsIn, TFLOAT, "IQ_FW2", &momentMin, NULL, &status);
    196201            status=0; fits_read_key(fitsIn, TLONG, "IMAGEID", &imageId, NULL, &status);
    197             status=0; fits_read_key(fitsIn, TDOUBLE, "MJD-OBS", &obsTime, NULL, &status);
    198202            status=0; fits_read_key(fitsIn, TLONG, "SOURCEID", &sourceId, NULL, &status);
    199203
     
    333337            fits_write_col(this->fitsOut, TBYTE, DETECTION_SURVEYID, 1, 1, nDet, surveyIDs, &status);
    334338            fits_write_col(this->fitsOut, TLONGLONG, DETECTION_IMAGEID, 1, 1, nDet, imageID, &status);
    335             fits_write_col(this->fitsOut, TFLOAT, DETECTION_OBSTIME, 1, 1, nDet, obsTimes, &status);
     339            fits_write_col(this->fitsOut, TDOUBLE, DETECTION_OBSTIME, 1, 1, nDet, obsTimes, &status);
    336340            fits_write_col(this->fitsOut, TFLOAT, DETECTION_INSTFLUX, 1, 1, nDet, instFlux, &status);
    337341            fits_write_col(this->fitsOut, TFLOAT, DETECTION_INSTFLUXERR, 1, 1, nDet, instFluxErr, &status);
  • branches/czw_branch/20100519/ippTools/share/pxadmin_create_tables.sql

    r28304 r28334  
    14111411        uri VARCHAR(255),
    14121412        outdir     VARCHAR(255),
     1413        timestamp TIMESTAMP,
    14131414        fault SMALLINT,
    14141415        PRIMARY KEY(req_id),
  • branches/czw_branch/20100519/ippTools/src/addtool.c

    r28304 r28334  
    817817  }
    818818
     819  if (minidvodb_path) {
     820    psStringAppend(&minidvodb_path,"/%s",minidvodb_name);
     821  }
     822
     823
    819824  psString query = NULL;
    820825
  • branches/czw_branch/20100519/ippTools/src/pstamptool.c

    r28304 r28334  
    271271        uri,
    272272        NULL,   // outdir
     273        NULL,   // timestamp
    273274        0       // fault
    274275        )) {
     
    547548    PXOPT_LOOKUP_BOOL(clearfault,config->args, "-clearfault",    false);
    548549
     550    if (!state && !label && !outProduct && !fault && !uri && !outdir && !name && !reqType && !clearfault) {
     551        psError(PS_ERR_UNKNOWN, true, "at least one set option is required");
     552        return false;
     553    }
     554
    549555    psMetadata *where = psMetadataAlloc();
    550556    PXOPT_COPY_S64(config->args, where, "-req_id",     "req_id", "==");
     
    552558    PXOPT_COPY_S32(config->args, where, "-fault",      "fault", "==");
    553559    PXOPT_COPY_STR(config->args, where, "-state",      "state", "==");
     560    PXOPT_COPY_TIME(config->args, where, "-timestamp_begin", "timestamp", ">=");
     561    PXOPT_COPY_TIME(config->args, where, "-timestamp_end", "timestamp", "<=");
    554562    pxAddLabelSearchArgs(config, where, "-label",      "pstampRequest.label", "LIKE");
    555563    if (!psListLength(where->list)) {
     
    559567    }
    560568
    561     psString query = psStringCopy("UPDATE pstampRequest SET");
     569    psString query = psStringCopy("UPDATE pstampRequest SET timestamp = UTC_TIMESTAMP()");
    562570
    563571    psString stateCheck = NULL;
    564     char c = ' ';
    565572    if (state) {
    566         psStringAppend(&query, "%c state = '%s'", c, state);
    567         c = ',';
     573        psStringAppend(&query, ", state = '%s'", state);
    568574        if (!strcmp(state, "goto_cleaned")) {
    569575            psStringAppend(&stateCheck, " AND state != 'cleaned'");
     
    571577    }
    572578    if (label) {
    573         psStringAppend(&query, "%c label = '%s'", c, label);
    574         c = ',';
     579        psStringAppend(&query, ", label = '%s'", label);
    575580    }
    576581    if (outProduct) {
    577         psStringAppend(&query, "%c outProduct = '%s'", c, outProduct);
    578         c = ',';
     582        psStringAppend(&query, ", outProduct = '%s'", outProduct);
    579583    }
    580584    if (outdir) {
    581         psStringAppend(&query, "%c outdir = '%s'", c, outdir);
    582         c = ',';
     585        psStringAppend(&query, ", outdir = '%s'", outdir);
    583586    }
    584587    if (clearfault) {
     
    587590            return false;
    588591        }
    589         psStringAppend(&query, "%c fault = 0", c);
    590         c = ',';
     592        psStringAppend(&query, ", fault = 0");
    591593    } else if (fault) {
    592         psStringAppend(&query, "%c fault = %d", c, fault);
    593         c = ',';
     594        psStringAppend(&query, ", fault = %d", fault);
    594595    }
    595596    if (uri) {
    596         psStringAppend(&query, "%c uri = '%s'", c, uri);
    597         c = ',';
     597        psStringAppend(&query, ", uri = '%s'", uri);
    598598    }
    599599    if (name) {
    600         psStringAppend(&query, "%c name = '%s'", c, name);
    601         c = ',';
     600        psStringAppend(&query, ", name = '%s'", name);
    602601    }
    603602    if (reqType) {
    604         psStringAppend(&query, "%c reqType = '%s'", c, reqType);
    605         c = ',';
    606     }
    607     if (c != ',') {
    608         psError(PS_ERR_UNKNOWN, true, "at least one set option is required");
    609         return false;
     603        psStringAppend(&query, ", reqType = '%s'", reqType);
    610604    }
    611605
  • branches/czw_branch/20100519/ippTools/src/pstamptoolConfig.c

    r28304 r28334  
    103103    psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-state", 0,        "search by state", NULL);
    104104    psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by pstampJob label (LIKE comparision)", NULL);
     105    psMetadataAddTime(updatereqArgs, PS_LIST_TAIL, "-timestamp_begin", 0, "search by timestamp (>=)", NULL);
     106    psMetadataAddTime(updatereqArgs, PS_LIST_TAIL, "-timestamp_end", 0, "search by timestamp (<=)", NULL);
    105107    psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-set_state", 0,        "new state", NULL);
    106108    psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-set_label", 0,        "new label", NULL);
  • branches/czw_branch/20100519/ippTools/src/stacktool.c

    r28304 r28334  
    13721372  if (psListLength(where->list)) {
    13731373    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    1374     psStringAppend(&query, " WHERE %s", whereClause);
     1374    psStringAppend(&query, " AND %s", whereClause);
    13751375    psFree(whereClause);
    13761376  } else if (!all) {
     
    13871387    psFree(limitString);
    13881388  }
    1389  
     1389
    13901390  if (!p_psDBRunQuery(config->dbh, query)) {
    13911391    psError(PS_ERR_UNKNOWN, false, "database error");
  • branches/czw_branch/20100519/ippconfig/recipes/filerules-mef.mdc

    r28164 r28334  
    153153PPBGRESTORE.INPUT       INPUT    @FILES        CHIP       IMAGE
    154154PPBGRESTORE.BACKMDL     INPUT    @FILES        CHIP       IMAGE
     155
     156PPBACKGROUND.IMAGE        INPUT    @FILES        CHIP       IMAGE
     157PPBACKGROUND.MASK         INPUT    @FILES        CHIP       MASK
     158PPBACKGROUND.PATTERN      INPUT    @FILES        CHIP       PATTERN
     159PPBACKGROUND.BACKGROUND   INPUT    @FILES        CHIP       IMAGE
    155160
    156161### output file definitions
     
    330335
    331336PPBGRESTORE.OUTPUT      OUTPUT {OUTPUT}.{CHIP.NAME}.fits         IMAGE     COMP_IMG   CHIP       TRUE      NONE
     337
     338PPBACKGROUND.OUTPUT          OUTPUT {OUTPUT}.{CHIP.NAME}.fits    IMAGE     COMP_IMG   CHIP       TRUE      NONE
     339PPBACKGROUND.OUTPUT.MASK     OUTPUT {OUTPUT}.{CHIP.NAME}.mk.fits MASK      COMP_MASK  CHIP       TRUE      NONE
  • branches/czw_branch/20100519/ippconfig/recipes/filerules-simple.mdc

    r28164 r28334  
    128128
    129129PPVIZPATTERN.INPUT        INPUT    @FILES        CHIP       PATTERN
     130
     131PPBACKGROUND.IMAGE        INPUT    @FILES        CHIP       IMAGE
     132PPBACKGROUND.MASK         INPUT    @FILES        CHIP       MASK
     133PPBACKGROUND.PATTERN      INPUT    @FILES        CHIP       PATTERN
     134PPBACKGROUND.BACKGROUND   INPUT    @FILES        CHIP       IMAGE
    130135
    131136### output file definitions
     
    295300
    296301PPBGRESTORE.OUTPUT           OUTPUT {OUTPUT}.fits                 IMAGE           NONE       FPA        TRUE      NONE
     302
     303PPBACKGROUND.OUTPUT          OUTPUT {OUTPUT}.{CHIP.NAME}.fits         IMAGE           NONE       FPA        TRUE      NONE
     304PPBACKGROUND.OUTPUT.MASK     OUTPUT {OUTPUT}.{CHIP.NAME}.mk.fits      MASK            NONE       FPA        TRUE      NONE
  • branches/czw_branch/20100519/ippconfig/recipes/filerules-split.mdc

    r28164 r28334  
    139139                         
    140140PPVIZPATTERN.INPUT        INPUT    @FILES        CHIP       PATTERN
     141
     142PPBACKGROUND.IMAGE        INPUT    @FILES        CHIP       IMAGE
     143PPBACKGROUND.MASK         INPUT    @FILES        CHIP       MASK
     144PPBACKGROUND.PATTERN      INPUT    @FILES        CHIP       PATTERN
     145PPBACKGROUND.BACKGROUND   INPUT    @FILES        CHIP       IMAGE
    141146
    142147### output file definitions
     
    321326PPVIZPATTERN.CHIP            OUTPUT {OUTPUT}.{CHIP.NAME}.ch.fits      IMAGE           NONE       CHIP       TRUE      NONE
    322327
     328PPBACKGROUND.OUTPUT          OUTPUT {OUTPUT}.{CHIP.NAME}.fits         IMAGE           COMP_IMG   CHIP       TRUE      NONE
     329PPBACKGROUND.OUTPUT.MASK     OUTPUT {OUTPUT}.{CHIP.NAME}.mk.fits      MASK            COMP_MASK  CHIP       TRUE      NONE
    323330
    324331# FILERULE naming operators:
  • branches/czw_branch/20100519/ppBackground

    • Property svn:ignore set to
      configure
      Makefile.in
      ignore
      config.log
      depcomp
      config.status
      config.guess
      ltmain.sh
      config.sub
      autom4te.cache
      libtool
      missing
      Makefile
      aclocal.m4
      install-sh
  • branches/czw_branch/20100519/ppBackground/configure.ac

    r28304 r28334  
    2020PKG_CHECK_MODULES([PSLIB], [pslib >= 1.0.0])
    2121PKG_CHECK_MODULES([PSMODULE], [psmodules >= 1.0.0])
    22 PKG_CHECK_MODULES([PSPHOT], [psphot >= 1.0.0])
     22PKG_CHECK_MODULES([PPSTATS], [ppStats >= 1.0.0])
     23PKG_CHECK_MODULES([PSPHOT], [psphot])
     24
     25AC_PATH_PROG([ERRORCODES], [psParseErrorCodes], [missing])
     26if test "$ERRORCODES" = "missing" ; then
     27  AC_MSG_ERROR([psParseErrorCodes is required])
     28fi
    2329
    2430dnl Set CFLAGS for build
  • branches/czw_branch/20100519/ppBackground/src

    • Property svn:ignore set to
      ppBackground
      Makefile.in
      config.h
      ppBackgroundVersionDefinitions.h
      .deps
      Makefile
      ppBackgroundErrorCodes.c
      ppBackgroundErrorCodes.h
      stamp-h1
      config.h.in
  • branches/czw_branch/20100519/ppBackground/src/Makefile.am

    r28304 r28334  
    22
    33if HAVE_SVNVERSION
    4 PPVIZPATTERN_VERSION=`$(SVNVERSION) ..`
     4PPBACKGROUND_VERSION=`$(SVNVERSION) ..`
    55else
    6 PPVIZPATTERN_VERSION="UNKNOWN"
     6PPBACKGROUND_VERSION="UNKNOWN"
    77endif
    88
    99if HAVE_SVN
    10 PPVIZPATTERN_BRANCH=`$(SVN) info .. | $(SED) -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'`
    11 PPVIZPATTERN_SOURCE=`$(SVN) info | $(SED) -n -e 's/Repository UUID: // p'`
     10PPBACKGROUND_BRANCH=`$(SVN) info .. | $(SED) -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'`
     11PPBACKGROUND_SOURCE=`$(SVN) info | $(SED) -n -e 's/Repository UUID: // p'`
    1212else
    13 PPVIZPATTERN_BRANCH="UNKNOWN"
    14 PPVIZPATTERN_SOURCE="UNKNOWN"
     13PPBACKGROUND_BRANCH="UNKNOWN"
     14PPBACKGROUND_SOURCE="UNKNOWN"
    1515endif
    1616
     
    1919ppBackgroundVersionDefinitions.h: ppBackgroundVersionDefinitions.h.in FORCE
    2020        -$(RM) ppBackgroundVersionDefinitions.h
    21         $(SED) -e "s|@PPVIZPATTERN_VERSION@|\"$(PPVIZPATTERN_VERSION)\"|" -e "s|@PPVIZPATTERN_BRANCH@|\"$(PPVIZPATTERN_BRANCH)\"|" -e "s|@PPVIZPATTERN_SOURCE@|\"$(PPVIZPATTERN_SOURCE)\"|" ppBackgroundVersionDefinitions.h.in > ppBackgroundVersionDefinitions.h
     21        $(SED) -e "s|@PPBACKGROUND_VERSION@|\"$(PPBACKGROUND_VERSION)\"|" -e "s|@PPBACKGROUND_BRANCH@|\"$(PPBACKGROUND_BRANCH)\"|" -e "s|@PPBACKGROUND_SOURCE@|\"$(PPBACKGROUND_SOURCE)\"|" ppBackgroundVersionDefinitions.h.in > ppBackgroundVersionDefinitions.h
    2222FORCE: ;
    2323
     
    2525
    2626
    27 ppBackground_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPBACKGROUND_CFLAGS)
    28 ppBackground_LDFLAGS  = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PSPHOT_LIBS)   $(PPBACKGROUND_LIBS)
     27ppBackground_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPBACKGROUND_CFLAGS)
     28ppBackground_LDFLAGS  = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PPSTATS_LIBS)   $(PSPHOT_LIBS)   $(PPBACKGROUND_LIBS)
    2929
    3030ppBackground_SOURCES =          \
     
    3535        ppBackgroundLoop.c      \
    3636        ppBackgroundVersion.c   \
    37         ppBackgroundModel.c     \
    38         ppBackgroundErrorCodes.c
     37        ppBackgroundRestore.c   \
     38        ppBackgroundErrorCodes.c        \
     39        ppBackgroundExit.c
    3940
    4041noinst_HEADERS = \
  • branches/czw_branch/20100519/ppBackground/src/ppBackground.c

    r28304 r28334  
    66#include <pslib.h>
    77#include <psmodules.h>
     8#include <psphot.h>
    89
    910#include "ppBackground.h"
     
    1213{
    1314    ppBackgroundVersionPrint();
     15
     16    pmErrorRegister();
     17    psphotErrorRegister();
     18    ppBackgroundErrorRegister();
    1419
    1520    ppBackgroundData *data = ppBackgroundDataInit(&argc, argv);
     
    4651        }
    4752        data->statsFile = NULL;
    48         pmConfigRunFilenameAddWrite(data->config, "STATS", data->statsName);
    4953        exitValue = ppBackgroundExitCode(exitValue);
    5054    }
  • branches/czw_branch/20100519/ppBackground/src/ppBackground.h

    r28304 r28334  
    55#include <psmodules.h>
    66
    7 #include <ppBackgroundErrorCodes.h>
     7#include "ppBackgroundErrorCodes.h"
    88
    99#define PPBACKGROUND_RECIPE "PPBACKGROUND"      // Recipe name
     
    3737    );
    3838
     39/// Restore the background to an image
     40bool ppBackgroundRestore(
     41    pmChip *chip,                       // Chip to correct
     42    const pmChip *background,           // Chip with background model
     43    const pmChip *pattern,              // Chip with pattern
     44    const pmFPAview *view,              // View to data
     45    pmConfig *config                    // Configuration
     46    );
     47
    3948/// Determine exit code
    4049psExit ppBackgroundExitCode(
  • branches/czw_branch/20100519/ppBackground/src/ppBackgroundArguments.c

    r28304 r28334  
    4545    assert(data->config);
    4646
    47     psMetadata *arguments = psMetadataAlloc(); // Command-line arguments
     47    psMetadata *arguments = data->config->arguments;
    4848    psMetadataAddStr(arguments, PS_LIST_TAIL, "-pattern", 0, "Filename of pattern correction", NULL);
    4949    psMetadataAddStr(arguments, PS_LIST_TAIL, "-background", 0, "Filename of background model", NULL);
    50     psMetadataAddStr(arguments, PS_LIST_TAIL, "-image", 0, "Filename of image", NULL);
     50    psMetadataAddStr(arguments, PS_LIST_TAIL, "-image", 0, "Filename of image (required)", NULL);
    5151    psMetadataAddStr(arguments, PS_LIST_TAIL, "-mask", 0, "Filename of mask", NULL);
     52    psMetadataAddStr(arguments, PS_LIST_TAIL, "-stats", 0, "Output statistics file", NULL);
     53    psMetadataAddStr(arguments, PS_LIST_TAIL, "-dumpconfig", 0, "Output configuration file", NULL);
    5254    if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 2) {
    5355        usage(argv[0], arguments, data);
     
    5961    data->maskName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-mask"));
    6062    data->outRoot = psStringCopy(argv[1]);
    61     psMetadataAddStr(data->config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Output root name", data->outRoot);
     63    psMetadataAddStr(arguments, PS_LIST_TAIL, "OUTPUT", 0, "Output root name", data->outRoot);
    6264
    6365    psTrace("ppBackground", 1, "Done reading command-line arguments\n");
    64     psFree(arguments);
    6566
    6667    if (!data->patternName && !data->backgroundName) {
     
    6869        return false;
    6970    }
     71    if (!data->imageName) {
     72        psError(PPBACKGROUND_ERR_CONFIG, true, "Must specify -image");
     73        return false;
     74    }
    7075
    7176    PS_ASSERT_STRING_NON_EMPTY(data->outRoot, false);
     77
     78    const char *statsName = psMetadataLookupStr(NULL, arguments, "-stats");
     79    if (statsName) {
     80        data->statsFile = fopen(statsName, "w");
     81        if (!data->statsFile) {
     82            psError(PPBACKGROUND_ERR_IO, true, "Unable to open statistics file %s", statsName);
     83            return false;
     84        }
     85        data->stats = psMetadataAlloc();
     86        pmConfigRunFilenameAddWrite(data->config, "STATS", statsName);
     87    }
    7288
    7389    return true;
  • branches/czw_branch/20100519/ppBackground/src/ppBackgroundCamera.c

    r28304 r28334  
    3232    bool status;                        // Status of file definition
    3333
    34     fileArguments("PATTERN", data->patternName, "Input pattern", data->config);
    35     pmFPAfile *pattern = pmFPAfileDefineFromArgs(&status, data->config, "PPBACKGROUND.PATTERN",
    36                                                  "PATTERN"); // File
    37     if (!status) {
    38         psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.PATTERN");
    39         return false;
     34    if (data->patternName) {
     35        fileArguments("PATTERN", data->patternName, "Input pattern", data->config);
     36        pmFPAfileDefineFromArgs(&status, data->config, "PPBACKGROUND.PATTERN", "PATTERN"); // File
     37        if (!status) {
     38            psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.PATTERN");
     39            return false;
     40        }
    4041    }
    4142
    42     fileArguments("BACKGROUND", data->backgroundName, "Input background model", data->config);
    43     pmFPAfile *background = pmFPAfileBindFromArgs(&status, data->config, "PPBACKGROUND.BACKGROUND",
    44                                                   "BACKGROUND"); // File
    45     if (!status) {
    46         psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.BACKGROUND");
    47         return false;
     43    if (data->backgroundName) {
     44        fileArguments("BACKGROUND", data->backgroundName, "Input background model", data->config);
     45        pmFPAfileDefineFromArgs(&status, data->config, "PPBACKGROUND.BACKGROUND", "BACKGROUND"); // File
     46        if (!status) {
     47            psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.BACKGROUND");
     48            return false;
     49        }
    4850    }
    4951
    50     fileArguments("IMAGE", data->backgroundName, "Input uncorrected image", data->config);
    51     pmFPAfile *image = pmFPAfileBindFromArgs(&status, background, data->config, "PPBACKGROUND.IMAGE",
    52                                              "IMAGE"); // File
    53     if (!status) {
     52    fileArguments("IMAGE", data->imageName, "Input uncorrected image", data->config);
     53    pmFPAfile *image = pmFPAfileDefineFromArgs(&status, data->config, "PPBACKGROUND.IMAGE",
     54                                               "IMAGE"); // File
     55    if (!status || !image) {
    5456        psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.IMAGE");
    5557        return false;
    5658    }
    5759
    58     fileArguments("MASK", data->backgroundName, "Input uncorrected mask", data->config);
    59     pmFPAfile *mask = pmFPAfileBindFromArgs(&status, image, data->config, "PPBACKGROUND.MASK",
    60                                               "MASK"); // File
     60    fileArguments("MASK", data->maskName, "Input uncorrected mask", data->config);
     61    pmFPAfileBindFromArgs(&status, image, data->config, "PPBACKGROUND.MASK", "MASK"); // File
    6162    if (!status) {
    6263        psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.MASK");
     
    6465    }
    6566
    66     pmFPAfile *output = pmFPAfileDefineOutput(data->config, file->fpa, "PPBACKGROUND.OUTPUT");
     67    pmFPAfile *output = pmFPAfileDefineOutput(data->config, image->fpa, "PPBACKGROUND.OUTPUT");
    6768    if (!output) {
    6869        psError(psErrorCodeLast(), false, "Unable to define output.");
     
    7071    }
    7172    output->save = true;
     73
     74    pmFPAfile *outMask = pmFPAfileDefineOutput(data->config, output->fpa, "PPBACKGROUND.OUTPUT.MASK");
     75    if (!outMask) {
     76        psError(psErrorCodeLast(), false, "Unable to define output.");
     77        return false;
     78    }
     79    outMask->save = true;
    7280
    7381#if 0
  • branches/czw_branch/20100519/ppBackground/src/ppBackgroundExit.c

    r28304 r28334  
    1313    if (errorCode != PS_ERR_NONE) {
    1414        pmFPAfileFreeSetStrict(false);
    15         psErrorStackPrint(stderr, "Error in subtraction:");
     15        psErrorStackPrint(stderr, "Error in background restoration:");
    1616        switch (errorCode) {
    1717          case PS_ERR_UNKNOWN:
  • branches/czw_branch/20100519/ppBackground/src/ppBackgroundLoop.c

    r28304 r28334  
    66#include <pslib.h>
    77#include <psmodules.h>
     8#include <ppStats.h>
    89
    910#include "ppBackground.h"
     
    1314{
    1415    pmConfig *config = data->config;                                        // Configuration data
    15     pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPBACKGROUND.BACKGROUND", 0);
     16    pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPBACKGROUND.IMAGE", 0);
    1617    pmFPAfile *patternFile = pmFPAfileSelectSingle(config->files, "PPBACKGROUND.PATTERN", 0); // File with data
     18    pmFPAfile *bgFile = pmFPAfileSelectSingle(config->files, "PPBACKGROUND.BACKGROUND", 0);   // File with bg
    1719    pmFPA *patternMosaic = pmFPAConstruct(file->camera, file->cameraName); // Mosaicked FPA for pattern
    1820
    19     psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); // Mask value to set
     21    psImageMaskType maskBad = pmConfigMaskGet("DETECTOR", config); // Mask value to set
    2022
    2123    pmFPAview *view = pmFPAviewAlloc(0); // Pointer into FPA hierarchy
     
    3436        }
    3537
    36         if (chip->cell->n > 1) {
     38        if (chip->cells->n > 1) {
    3739            psError(PPBACKGROUND_ERR_CONFIG, true,
    3840                    "Input image and background model should be chip-mosaicked");
     
    4446            pmFPAfileActivate(config->files, true, "PPBACKGROUND.PATTERN");
    4547
    46             pmCell *cell;               // Cell with pattern data
     48            pmCell *patternCell;               // Cell with pattern data
    4749            while ((patternCell = pmFPAviewNextCell(view, patternFile->fpa, 1))) {
    48                 if (!cell->process || !cell->file_exists) {
     50                if (!patternCell->process || !patternCell->file_exists) {
    4951                    continue;
    5052                }
     
    6870                    // Get size of image from concepts
    6971                    if (numCols == 0 || numRows == 0) {
    70                         numCols = psMetadataLookupS32(NULL, cell->concepts, "CELL.XSIZE");
    71                         numRows = psMetadataLookupS32(NULL, cell->concepts, "CELL.YSIZE");
     72                        numCols = psMetadataLookupS32(NULL, patternCell->concepts, "CELL.XSIZE");
     73                        numRows = psMetadataLookupS32(NULL, patternCell->concepts, "CELL.YSIZE");
    7274                    }
    7375                    // Get size of image from TRIMSEC
    7476                    if (numCols == 0 || numRows == 0) {
    75                         psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");
     77                        psRegion *trimsec = psMetadataLookupPtr(NULL, patternCell->concepts, "CELL.TRIMSEC");
    7678                        numCols = trimsec->x1 - trimsec->x0;
    7779                        numRows = trimsec->y1 - trimsec->y0;
     
    8486                    readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    8587                    psImageInit(readout->image, 0.0);
     88                    readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
     89                    psImageInit(readout->mask, 0);
    8690
    8791                    if (!pmPatternRowApply(readout, maskBad) || !pmPatternCellApply(readout, maskBad)) {
     
    9195
    9296                    // Remove bias sections to avoid warnings
    93                     psMetadataItem *biassec = psMetadataLookup(patternRO->parent->concepts, "CELL.BIASSEC");
     97                    psMetadataItem *biassec = psMetadataLookup(patternCell->concepts, "CELL.BIASSEC");
    9498                    if (psListLength(biassec->data.V)) {
    9599                        psFree(biassec->data.V);
     
    114118            }
    115119
    116             pmChip *mosaic = pmFPAviewThisChip(view, patternMosaic); // Chip for mosaicked pattern
    117             if (!pmChipMosaic(mosaic, chip, true, maskBad)) {
    118                 psError(psErrorCodeLast(), false, "Unable to mosaic pattern correction");
    119                 return false;
     120            if (data->patternName) {
     121                pmChip *patternChip = pmFPAviewThisChip(view, patternFile->fpa); // Chip for pattern
     122                pmChip *mosaic = pmFPAviewThisChip(view, patternMosaic); // Chip for mosaicked pattern
     123                if (!mosaic->hdu && !mosaic->parent->hdu) {
     124                    pmFPAAddSourceFromView(patternMosaic, view, file->format);
     125                }
     126                if (!pmChipMosaic(mosaic, patternChip, true, maskBad)) {
     127                    psError(psErrorCodeLast(), false, "Unable to mosaic pattern correction");
     128                    return false;
     129                }
     130                pmFPAfileActivate(config->files, true, NULL);
     131            //            pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN");
    120132            }
    121             pmFPAfileActivate(config->files, true, NULL);
    122             pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN");
    123133        }
    124134
     135        pmChip *patternChip = patternFile ? pmFPAviewThisChip(view, patternMosaic) : NULL; // Chip with pattern
     136        pmChip *bgChip = bgFile ? pmFPAviewThisChip(view, bgFile->fpa) : NULL; // Chip with background model
     137        if (!ppBackgroundRestore(chip, bgChip, patternChip, view, config)) {
     138            psError(psErrorCodeLast(), false, "Unable to replace background");
     139            return false;
     140        }
     141        pmChipFreeData(patternChip);
    125142
    126 
    127 
    128 
    129 
    130 
    131                 pmHDU *hdu = pmHDUGetLowest(file->fpa, chip, cell); // HDU for readout
    132                 if (!hdu) {
    133                     psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find HDU for data.");
    134                     return false;
    135                 }
    136                 if (!hdu->header) {
    137                     hdu->header = psMetadataAlloc();
    138                 }
    139                 ppBackgroundVersionHeader(hdu->header);
    140 
    141 
    142 
    143 
    144 
    145 
    146 
     143        pmHDU *hdu = pmHDUGetLowest(file->fpa, chip, NULL); // HDU for chip
     144        if (!hdu) {
     145            psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find HDU for data.");
     146            return false;
     147        }
     148        if (!hdu->header) {
     149            hdu->header = psMetadataAlloc();
     150        }
     151        ppBackgroundVersionHeader(hdu->header);
    147152
    148153        // Chip
     
    158163    }
    159164
     165    psFree(patternMosaic);
     166
     167    if (data->stats) {
     168        psImageMaskType maskVal = 0;    // Bits to mask
     169        if (!pmConfigMaskSetBits(&maskVal, NULL, config)) {
     170            psError(psErrorCodeLast(), false, "Unable to find bits to mask");
     171            return false;
     172        }
     173        ppStatsFPA(data->stats, file->fpa, view, maskVal, config);
     174    }
     175
     176    psFree(view);
     177
    160178    return true;
    161179}
  • branches/czw_branch/20100519/ppBackground/src/ppBackgroundVersionDefinitions.h.in

    r28304 r28334  
    1 #ifndef PPVIZPATTERN_VERSION_DEFINITIONS_H
    2 #define PPVIZPATTERN_VERSION_DEFINITIONS_H
     1#ifndef PPBACKGROUND_VERSION_DEFINITIONS_H
     2#define PPBACKGROUND_VERSION_DEFINITIONS_H
    33
    4 #define PPVIZPATTERN_VERSION @PPVIZPATTERN_VERSION@ // SVN version
    5 #define PPVIZPATTERN_BRANCH  @PPVIZPATTERN_BRANCH@  // SVN branch
    6 #define PPVIZPATTERN_SOURCE  @PPVIZPATTERN_SOURCE@  // SVN source
     4#define PPBACKGROUND_VERSION @PPBACKGROUND_VERSION@ // SVN version
     5#define PPBACKGROUND_BRANCH  @PPBACKGROUND_BRANCH@  // SVN branch
     6#define PPBACKGROUND_SOURCE  @PPBACKGROUND_SOURCE@  // SVN source
    77
    88#endif
  • branches/czw_branch/20100519/ppImage/src/ppImageLoop.c

    r28304 r28334  
    5151            ESCAPE("load failure for Chip");
    5252        }
    53         printf("PPI: %x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
     53
    5454        // crosstalk measurement needs to be done on the entire chip at once, and before
    5555        // signal levels are modified by the detrending.  If crosstalk measurement is
     
    6565          ESCAPE("Unable to perform crosstalk correction");
    6666        }
    67         printf("PPI: %x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
     67
    6868        psTimerStart(TIMER_DETREND);
    6969        pmCell *cell;                   // Cell from chip
     
    152152            ESCAPE("Unable to free detrend images");
    153153        }
    154         printf("PPI: %x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
     154
    155155        // Apply the fringe correction
    156156        if (options->doFringe) {
     
    163163            ESCAPE("Unable to free fringe images");
    164164        }
    165         printf("PPI: %x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
     165
    166166        // Apply the pattern correction
    167167        if (options->doPatternRow || options->doPatternCell) {
     
    170170          }
    171171        }
    172         printf("PPI: %x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
     172
    173173        // measure various pixel-based statistics for this image
    174174        if (!ppImagePixelStats(config, stats, options, view)) {
    175175            ESCAPE("Unable to measures pixel stats for image");
    176176        }
    177         printf("PPI: %x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
     177
    178178        if (!ppImageMosaicChip(config, options, view, "PPIMAGE.CHIP", "PPIMAGE.OUTPUT")) {
    179179            ESCAPE("Unable to mosaic chip");
     
    182182
    183183        // we perform photometry on the readouts of this chip in the output
    184         printf("PPI: %x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
     184
    185185        psTimerStart(TIMER_PHOT);
    186186        if (options->doPhotom) {
  • branches/czw_branch/20100519/ppImage/src/ppImageMosaic.c

    r28304 r28334  
    99{
    1010    bool status;                        // Status of MD lookup
    11         printf("PPIM: %x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
     11
    1212    pmFPAfile *in = psMetadataLookupPtr(&status, config->files, inFile); // Input file
    1313    if (!status) {
     
    1515        exit(EXIT_FAILURE);
    1616    }
    17         printf("PPIM: %x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
     17
    1818    pmFPAfile *out = psMetadataLookupPtr(&status, config->files, outFile); // Output file
    1919    if (!status) {
     
    2121        exit(EXIT_FAILURE);
    2222    }
    23         printf("PPIM: %x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
     23
    2424    pmChip *outChip = pmFPAviewThisChip(view, out->fpa);
    2525    pmChip *inChip = pmFPAviewThisChip(view, in->fpa);
     
    2727        pmFPAAddSourceFromView(out->fpa, view, out->format);
    2828    }
    29         printf("PPIM: %x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
     29
    3030    // If the input is a dark (normalising and mosaicking) then it looks like a video cell and will be ignored
    3131    // by pmChipMosaic.  We therefore hack the structure so it doesn't look like a video cell.
    3232    psVector *darkNumbers = NULL;       // Number of dark readouts for each cell
    33     //    psVectorInit(darkNumbers, 0);
    34     printf("PPIM: %x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    3533    if (psMetadataLookupBool(&status, config->arguments, "INPUT_IS_DARK")) {
    3634        darkNumbers = psVectorAlloc(inChip->cells->n, PS_TYPE_S32);
     
    4543        }
    4644    }
    47         printf("PPMI: %x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
     45
    4846    psTrace("pmChipMosaic", 5, "mosaic chip %s to %s (xbin,ybin: %d,%d to %d,%d)\n",
    4947            in->name, out->name, in->xBin, in->yBin, out->xBin, out->yBin);
  • branches/czw_branch/20100519/ppStack/src/ppStackTarget.c

    r28304 r28334  
    164164
    165165        psStats *bg = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics for background
     166        float mean = NAN;                                  // Measured mean variance
    166167        if (!psImageBackground(bg, NULL, variance, mask, maskVal, rng)) {
    167             psError(PPSTACK_ERR_DATA, false, "Can't measure background for image.");
    168             psFree(rng);
    169             return NULL;
     168            psErrorClear();
     169            // Retry using all the available pixels
     170            bg->nSubsample = variance->numCols * variance->numRows + 1;
     171            if (!psImageStats(bg, variance, mask, maskVal)) {
     172                psLogMsg("ppStack", PS_LOG_DETAIL,
     173                         "Couldn't measure mean variance for image %d; retrying.", i);
     174                psErrorClear();
     175                // Retry with desperate statistic
     176                bg->options = PS_STAT_SAMPLE_MEAN;
     177                if (!psImageStats(bg, variance, mask, maskVal)) {
     178                    psWarning("Unable to measure mean variance for image %d --- rejecting.", i);
     179                    psErrorStackPrint(stderr, "Unable to measure mean variance for image %d", i);
     180                    options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_PSF;
     181                    goto DONE;
     182                } else {
     183                    // Desperate retry
     184                    mean = bg->sampleMean;
     185                }
     186            } else {
     187                // Retry with all available pixels
     188                mean = bg->robustMedian;
     189            }
     190        } else {
     191            // First attempt
     192            mean = bg->robustMedian;
    170193        }
    171194
     
    177200        }
    178201
     202    DONE:
     203        psFree(bg);
    179204        if (!ppStackFilesIterateUp(config)) {
    180205            psFree(rng);
  • branches/czw_branch/20100519/psLib/src/sys/psAbort.c

    r28304 r28334  
    2323#include <stdarg.h>
    2424#include <stdlib.h>
     25#include <string.h>
    2526#include <unistd.h>
    2627
     28#if defined(HAVE_BACKTRACE)
     29#include <execinfo.h>
     30#define BACKTRACE_BUFFER_SIZE 256       // Maximum size of backtrace
     31#endif
     32
    2733#include "psAbort.h"
     34#include "psString.h"
     35#include "psMemory.h"
    2836#include "psError.h"
    2937#include "psLogMsg.h"
     38
     39// Write backtrace to log
     40static inline void psBacktrace(void)
     41{
     42#ifdef HAVE_BACKTRACE
     43    void **bt = psAlloc(BACKTRACE_BUFFER_SIZE * sizeof(void *)); // Backtrace information
     44    if (!bt) {
     45        psLogMsg("psLib.sys", PS_LOG_ABORT, "Unable to allocate memory for backtrace");
     46        return;
     47    }
     48    int size = backtrace(bt, BACKTRACE_BUFFER_SIZE);             // Size of backtrace
     49    char **strings = backtrace_symbols((void *const *)bt, size);
     50    psLogMsg("psLib.sys", PS_LOG_ABORT, "Backtrace depth: %d", size);
     51    for (int i = 0; i < size; i++) {
     52        // if the caller was an anon function then strchr won't
     53        // find a '(' in the string and will return NULL
     54        char *caller = strchr(strings[i], '(');
     55        if (caller) {
     56            // skip over the '('
     57            caller++;
     58            // find the end of the symbol name
     59            size_t callerLength = abs(strchr(caller, '+') - caller);
     60            psString name = psStringNCopy(caller, callerLength);
     61            psLogMsg("psLib.sys", PS_LOG_ABORT, "Backtrace %d: %s", i, name);
     62            psFree(name);
     63        } else {
     64            psLogMsg("psLib.sys", PS_LOG_ABORT, "Backtrace %d: (unknown)", i);
     65        }
     66    }
     67#endif // ifdef HAVE_BACKTRACE
     68}
    3069
    3170void p_psAbort(const char *file,
     
    4685    // Clean up stack after variable arguement has been used
    4786    va_end(argPtr);
     87
     88    psBacktrace();
    4889
    4990    // Call system abort function to terminate program execution
     
    72113    va_end(argPtr);
    73114
     115    psBacktrace();
     116
    74117    // Call system abort function to terminate program execution
    75118    fsync(psLogGetDestination());
  • branches/czw_branch/20100519/psLib/src/sys/psThread.c

    r28304 r28334  
    210210        psThreadTask *task = psHashLookup(tasks, job->type); // Task to execute job
    211211        psAssert(task, "Couldn't find thread task %s", job->type);
    212         psAssert(job->args->n == task->nArgs, "invalid number of arguments to %s (%ld supplied, expected %d)", task->type, job->args->n, task->nArgs);
     212        psAssert(job->args->n == task->nArgs,
     213                 "invalid number of arguments to %s (%ld supplied, expected %d)",
     214                 task->type, job->args->n, task->nArgs);
    213215        bool status = task->function(job); // Status of executing task
    214216
  • branches/czw_branch/20100519/psModules/src/config/pmConfig.c

    r27161 r28334  
    306306    *config = psMetadataConfigRead(NULL, &numBadLines, realName, true);
    307307    if (numBadLines > 0) {
    308         psError(PM_ERR_CONFIG, false, "%d bad lines in %s configuration file (%s)",
     308        psError(PM_ERR_CONFIG, true, "%d bad lines in %s configuration file (%s)",
    309309                numBadLines, description, realName);
    310310        psFree (realName);
     
    17511751    psMetadataItem *item = psMetadataLookup(camera, "FILERULES"); // Item with the file rule of interest
    17521752    if (!item) {
    1753         psError(PM_ERR_CONFIG, false, "Unable to find FILERULES in the camera configuration.");
     1753        psError(PM_ERR_CONFIG, true, "Unable to find FILERULES in the camera configuration.");
    17541754        return NULL;
    17551755    }
     
    17711771    }
    17721772
    1773     return psMetadataLookupMetadata(&mdok, filerules, realname);
     1773    return psMetadataLookupMetadata(NULL, filerules, realname);
    17741774}
    17751775
  • branches/czw_branch/20100519/pstamp/src/pstamp.h

    r28304 r28334  
    3333#define PSTAMP_SELECT_BACKMDL   32
    3434#define PSTAMP_SELECT_INVERSE 1024
     35#define PSTAMP_SELECT_UNCONV  2048
     36#define PSTAMP_USE_IMFILE_ID 16384
    3537
    36 #define PSTAMP_WAIT_FOR_UPDATE 2048
     38#define PSTAMP_NO_WAIT_FOR_UPDATE 32768
    3739
    3840#define PSTAMP_CENTER_IN_PIXELS 1
  • branches/czw_branch/20100519/tools/chip_outputs.pl

    r27690 r28334  
    2323                             'PSF' => '.psf',     # Point-spread function
    2424                             'LOG' => '.log',     # Processing log
     25                             'PATTERN' => '.ptn', # Pattern subtraction
     26                             'MODEL' => '.mdl.fits', # Background model
    2527                         };
    2628
Note: See TracChangeset for help on using the changeset viewer.