IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 9, 2009, 3:41:26 PM (18 years ago)
Author:
beaumont
Message:

sync with trunk

Location:
branches/cnb_branches/cnb_branch_20090215
Files:
102 edited
7 copied

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090215

  • branches/cnb_branches/cnb_branch_20090215/Nebulous/nebclient/src

    • Property svn:ignore
      •  

        old new  
        1010soapServerLib.c
        1111soapServer.c
         12.libs
  • branches/cnb_branches/cnb_branch_20090215/Nebulous/nebclient/tests/tap/src

    • Property svn:ignore
      •  

        old new  
        66.deps
        77Makefile
         8.libs
  • branches/cnb_branches/cnb_branch_20090215/Ohana

  • branches/cnb_branches/cnb_branch_20090215/Ohana/src/addstar/src/get2mass_full.c

    r21536 r23239  
    11# include "addstar.h"
    22# include "2mass.h"
     3
     4// XXX check to see if desired output format is PS1_V1 or later?  (use 16bit version if not?)
    35
    46// fill in the data for a JHK triplet star.  takes a pointer to the start of the line the
    … …  
    171173
    172174  switch (qual) {
    173     case 'X': star[0].measure.photFlags |= 0x0000; break;
    174     case 'U': star[0].measure.photFlags |= 0x0001; break;
    175     case 'F': star[0].measure.photFlags |= 0x0002; break;
    176     case 'E': star[0].measure.photFlags |= 0x0003; break;
    177     case 'A': star[0].measure.photFlags |= 0x0004; break;
    178     case 'B': star[0].measure.photFlags |= 0x0005; break;
    179     case 'C': star[0].measure.photFlags |= 0x0006; break;
    180     case 'D': star[0].measure.photFlags |= 0x0007; break;
     175    case 'A': star[0].measure.photFlags |= 0x00000001; break; // was: 0x0004
     176    case 'B': star[0].measure.photFlags |= 0x00000002; break; // was: 0x0005
     177    case 'C': star[0].measure.photFlags |= 0x00000004; break; // was: 0x0006
     178    case 'D': star[0].measure.photFlags |= 0x00000008; break; // was: 0x0007
     179    case 'E': star[0].measure.photFlags |= 0x00000010; break; // was: 0x0003
     180    case 'F': star[0].measure.photFlags |= 0x00000020; break; // was: 0x0002
     181    case 'U': star[0].measure.photFlags |= 0x00000040; break; // was: 0x0001
     182    case 'X': star[0].measure.photFlags |= 0x00000080; break; // was: 0x0000
    181183    default:
    182184      fprintf (stderr, "error!\n");
    … …  
    189191
    190192  switch (qual) {
    191     case '0': star[0].measure.photFlags |= 0x0000; break;
    192     case '1': star[0].measure.photFlags |= 0x0010; break;
    193     case '2': star[0].measure.photFlags |= 0x0020; break;
    194     case '3': star[0].measure.photFlags |= 0x0030; break;
    195     case '4': star[0].measure.photFlags |= 0x0040; break;
    196     case '6': star[0].measure.photFlags |= 0x0050; break;
    197     case '9': star[0].measure.photFlags |= 0x0060; break;
     193    case '0': star[0].measure.photFlags |= 0x00000100; break; // was: 0x0000
     194    case '1': star[0].measure.photFlags |= 0x00000200; break; // was: 0x0010
     195    case '2': star[0].measure.photFlags |= 0x00000400; break; // was: 0x0020
     196    case '3': star[0].measure.photFlags |= 0x00000800; break; // was: 0x0030
     197    case '4': star[0].measure.photFlags |= 0x00001000; break; // was: 0x0040
     198    case '6': star[0].measure.photFlags |= 0x00002000; break; // was: 0x0050
     199    case '9': star[0].measure.photFlags |= 0x00004000; break; // was: 0x0060
    198200    default:
    199201      fprintf (stderr, "error!\n");
    … …  
    206208
    207209  switch (qual) {
    208     case 'p': star[0].measure.photFlags |= 0x0000; break;
    209     case 'c': star[0].measure.photFlags |= 0x0100; break;
    210     case 'd': star[0].measure.photFlags |= 0x0200; break;
    211     case 's': star[0].measure.photFlags |= 0x0300; break;
    212     case 'b': star[0].measure.photFlags |= 0x0400; break;
    213     case '0': star[0].measure.photFlags |= 0x0500; break;
     210    case 'p': star[0].measure.photFlags |= 0x00010000; break; // was: 0x0000
     211    case 'c': star[0].measure.photFlags |= 0x00020000; break; // was: 0x0100
     212    case 'd': star[0].measure.photFlags |= 0x00040000; break; // was: 0x0200
     213    case 's': star[0].measure.photFlags |= 0x00080000; break; // was: 0x0300
     214    case 'b': star[0].measure.photFlags |= 0x00010000; break; // was: 0x0400
     215    case '0': star[0].measure.photFlags |= 0x00020000; break; // was: 0x0500
    214216    default:
    215217      fprintf (stderr, "error!\n");
    … …  
    222224
    223225  switch (qual) {
    224     case '0': star[0].measure.photFlags &= ~0x0008; break;
    225     case '1': star[0].measure.photFlags &= ~0x0008; break;
    226     default:  star[0].measure.photFlags |=  0x0008; break;
     226    case '0': star[0].measure.photFlags &= ~0x00300000; break; // was: ~0x0008
     227    case '1': star[0].measure.photFlags |=  0x00100000; break; // was: ~0x0008
     228    default:  star[0].measure.photFlags |=  0x00200000; break; // was:  0x0008
    227229  }     
    228230  return (TRUE);
    … …  
    232234
    233235  switch (qual) {
    234     case '0': star[0].measure.photFlags &= ~0x0080; break;
    235     case '1': star[0].measure.photFlags &= ~0x0080; break;
    236     default: 
    237       star[0].measure.photFlags |= 0x0080;
     236    case '0': star[0].measure.photFlags &= ~0x00c00000; break; // was: ~0x0080
     237    case '1': star[0].measure.photFlags |=  0x00400000; break; // was: ~0x0080
     238    default:  star[0].measure.photFlags |=  0x00800000;        // was:  0x0080
    238239      star[0].measure.extNsigma = 100.0;
    239240      break;
    … …  
    245246
    246247  switch (qual) {
    247     case '0': star[0].measure.photFlags &= ~0x0800; break;
    248     case '1': star[0].measure.photFlags &= ~0x0800; break;
    249     default:  star[0].measure.photFlags |=  0x0800; break;
     248    case '0': star[0].measure.photFlags &= ~0x03000000; break; // was: ~0x0800
     249    case '1': star[0].measure.photFlags |=  0x01000000; break; // was: ~0x0800
     250    default:  star[0].measure.photFlags |=  0x02000000; break; // was:  0x0800
    250251  }     
    251252  return (TRUE);
    … …  
    255256
    256257  switch (qual) {
    257     case '0': star[0].measure.photFlags &= ~0x1000; break;
    258     case '1': star[0].measure.photFlags &= ~0x1000; break;
    259     default:  star[0].measure.photFlags |=  0x1000; break;
     258    case '0': star[0].measure.photFlags &= ~0x0c000000; break; // was: ~0x1000
     259    case '1': star[0].measure.photFlags |=  0x04000000; break; // was: ~0x1000
     260    default:  star[0].measure.photFlags |=  0x08000000; break; // was:  0x1000
    260261  }     
    261262  return (TRUE);
    … …  
    265266
    266267  switch (qual) {
    267     case '0': star[0].measure.photFlags &= ~0x2000; break;
    268     case '1': star[0].measure.photFlags |=  0x2000; break;
     268    case '0': star[0].measure.photFlags &= ~0x10000000; break; // was: ~0x2000
     269    case '1': star[0].measure.photFlags |=  0x10000000; break; // was:  0x2000
    269270    default:  abort();
    270271  }     
    … …  
    272273}
    273274
     275// unused photFlags:
     276// 0x0000.8000
     277// 0x0004.0000
     278// 0x0008.0000
     279// 0x2000.0000
     280// 0x4000.0000
     281// 0x8000.0000
  • branches/cnb_branches/cnb_branch_20090215/Ohana/src/addstar/src/sky_tessalation.c

    r23199 r23239  
    240240  // integer number of dec zones between -90 and +90
    241241
    242   nDEC = 180.0 / CELLSIZE;
    243   dDEC = 180.0 / nDEC;
     242  // in fact, we place a single image on each pole, so the real range of dec is 180.0 - CELLSIZE:
     243
     244  nDEC = (180.0 - CELLSIZE) / CELLSIZE;
     245  dDEC = (180.0 - CELLSIZE) / nDEC;
     246  nDEC += 2;
     247
     248  // a test
     249  // for (dec = 0.0 + 0.5*dDEC; dec < +90.0; dec += dDEC) {
    244250
    245251  // generate the a collection of rectangles for each ring
    246   for (dec = -90.0 + 0.5*dDEC; dec < +90.0; dec += dDEC) {
     252  for (dec = -90.0; dec < +90.0 + 0.5*dDEC; dec += dDEC) {
    247253
    248254    ring = sky_rectangle_ring (dec, dDEC, &Nring);
     255    if (!ring) continue;
    249256
    250257    // subdivide each image (Nx x Ny subcells)
    … …  
    529536SkyRectangle *sky_rectangle_ring (float dec, float dDEC, int *nring) {
    530537
    531   int i, nRA, NX, NY;
    532   float dRA, decLower;
     538  int i, NX, NY, nRA;
    533539  SkyRectangle *ring;
     540  float theta, dRA;
    534541
    535542  // 'dec' is a guess at the center of the cell; in fact, we need to choose decLower and
    … …  
    537544
    538545  // we can determine the 'lower' bound (bound closest to the equator):
    539   decLower = (dec > 0.0) ? dec - 0.5*dDEC : dec + 0.5*dDEC;
    540 
    541   // Subdivide the 'lower' bound into an integer number of segments:
    542   nRA = cos(dec*RAD_DEG) * 360.0 / CELLSIZE; // CELLSIZE is a projection size
    543   dRA = 360.0 / nRA;                         // dRA is a size in RA degrees
     546  float decLower = (dec > 0.0) ? dec - 0.5*dDEC : dec + 0.5*dDEC;
     547
     548  // solve for actual cellsize (\theta):  tan(\delta_{n+1} - \theta/2) = tan(\delta_n + \theta/2)cos(\alpha_n / 2)
     549  float decUpper = (dec > 0.0) ? dec + dDEC : dec - dDEC;
     550
     551  if (fabs(dec) + 0.5*dDEC > 90.0) {
     552    // onPole = TRUE;
     553    theta = dDEC;
     554    nRA = 1;
     555    dRA = theta / cos(decLower*RAD_DEG); // make a square at the pole
     556  } else {
     557    // onPole = FALSE;
     558    // Subdivide the 'lower' bound into an integer number of segments:
     559    nRA = cos(RAD_DEG*decLower) * 360.0 / CELLSIZE; // CELLSIZE is a projection size
     560    dRA = 360.0 / nRA;                         // dRA is a size in RA degrees == \alpha_n
     561
     562    // tan(decUpper - theta/2) = tan(dec + theta/2) cos(dRA / 2);
     563
     564    // we solve this equation for theta (fairly ugly: expand the tangents into sin/cos, expand the
     565    // sum-of-angle sine and cosine, multiply through, convert via half-angle formulae and write
     566    // as a quadratic expression in sine(theta/2)
     567 
     568    float sd1 = sin(RAD_DEG*decUpper);
     569    float cd1 = cos(RAD_DEG*decUpper);
     570    float sd2 = sin(RAD_DEG*dec);
     571    float cd2 = cos(RAD_DEG*dec);
     572    float   k = cos(RAD_DEG*dRA/2.0);
     573
     574    float c1 =  (sd1*cd2 + sd2*cd1)*(1.0 - k);
     575    float c2 =  (sd1*cd2 - sd2*cd1)*(1.0 + k);
     576    float c3 = -(sd1*sd2 + cd1*cd2)*(1.0 + k);
     577
     578    float A = SQ(c3) + SQ(c2);
     579    float B = 2*c1*c3;
     580    float C = SQ(c1) - SQ(c2);
     581
     582    float arg = SQ(B) - 4.0*A*C;
     583
     584    float root;
     585
     586    if (dec >= 0.0) {
     587      root = (-B + sqrt (arg)) / (2.0*A);
     588      theta = +DEG_RAD*asin(root);
     589    } else {
     590      root = (-B - sqrt (arg)) / (2.0*A);
     591      theta = -DEG_RAD*asin(root);
     592    }
     593
     594    // the negative solution yields a negative cellsize
     595    // float root2 = (-B - sqrt (arg)) / (2.0*A);
     596    // float theta2 = DEG_RAD*asin(root2);
     597
     598    // test lines:
     599    // float r1 = tan(RAD_DEG*(decUpper - 0.5*theta1));
     600    // float r2 = tan(RAD_DEG*(dec + 0.5*theta1));
     601    // fprintf (stdout, "%f %f  %f  %f  %f %f  %f %f  %f %f %f\n", dec, decUpper, dRA, arg, root1, root2, theta1, theta2, r1, r2, k*r2);
     602  }
     603  fprintf (stdout, "%f %f  %f x %f (%d)\n", dec, decUpper, dRA, theta, nRA);
    544604
    545605  // I think we need to return the value of dec for the next ring, but I am not sure...
    … …  
    559619 
    560620    // range values are in projected degrees
    561     NX = cos(dec*RAD_DEG) * dRA  * 3600.0 / SCALE;
    562     NY =                    dDEC * 3600.0 / SCALE;
     621    NX = cos(decLower*RAD_DEG) * dRA   * 3600.0 / SCALE;
     622    NY =                         theta * 3600.0 / SCALE;
    563623
    564624    // crpix1,crpix2 is the projection center
    … …  
    576636
    577637
    578     fprintf (stderr, "%f %f  : %f %f\n",
    579             ring[i].coords.crval1, ring[i].coords.crval2,
    580             ring[i].coords.crpix1, ring[i].coords.crpix2);
     638    // fprintf (stderr, "%f %f  : %f %f\n",
     639    // ring[i].coords.crval1, ring[i].coords.crval2,
     640    // ring[i].coords.crpix1, ring[i].coords.crpix2);
    581641  }
    582642
  • branches/cnb_branches/cnb_branch_20090215/Ohana/src/imregister/base/get_fwhm.c

  • branches/cnb_branches/cnb_branch_20090215/Ohana/src/imregister/detrend/usage.c

  • branches/cnb_branches/cnb_branch_20090215/Ohana/src/imregister/imreg/load_probes.c

  • branches/cnb_branches/cnb_branch_20090215/Ohana/src/libdvo

    • Property svn:ignore
      •  

        old new  
        1 lib
         1
  • branches/cnb_branches/cnb_branch_20090215/Ohana/src/libdvo/lib

    • Property svn:ignore
      •  

        old new  
        1 *.linux
        2 *.lin64
        3 *.sol
        4 *.sun
        5 *.sid
        6 *.hp
        7 *.irix
        8 *.darwin.dylib
        9 *.darwin_x86.dylib
         1*.a
         2*.so
  • branches/cnb_branches/cnb_branch_20090215/Ohana/src/libfits/lib

    • Property svn:ignore
      •  

        old new  
        1 *.linux
        2 *.lin64
        3 *.sol
        4 *.sun
        5 *.sid
        6 *.hp
        7 *.irix
        8 *.darwin.dylib
        9 *.darwin_x86.dylib
         1*.a
         2*.so
  • branches/cnb_branches/cnb_branch_20090215/Ohana/src/libkapa/lib

    • Property svn:ignore
      •  

        old new  
        1 *.linux
        2 *.lin64
        3 *.sol
        4 *.sun
        5 *.sid
        6 *.hp
        7 *.irix
        8 *.darwin.dylib
        9 *.darwin_x86.dylib
         1*.a
         2*.so
  • branches/cnb_branches/cnb_branch_20090215/Ohana/src/libohana/lib

    • Property svn:ignore
      •  

        old new  
        1 *.linux
        2 *.lin64
        3 *.sol
        4 *.sun
        5 *.sid
        6 *.hp
        7 *.irix
        8 *.darwin.dylib
        9 *.darwin_x86.dylib
         1*.a
         2*.so
  • branches/cnb_branches/cnb_branch_20090215/Ohana/src/libtap/lib

    • Property svn:ignore
      •  

        old new  
        1 *.linux
        2 *.lin64
        3 *.sol
        4 *.sun
        5 *.sid
        6 *.hp
        7 *.irix
        8 *.darwin.dylib
        9 *.darwin_x86.dylib
         1*.a
         2*.so
  • branches/cnb_branches/cnb_branch_20090215/dbconfig/changes.txt

    r21434 r23239  
    795795ALTER TABLE magicInputSkyfile DROP PRIMARY KEY, ADD PRIMARY KEY(magic_id, diff_id, node);
    796796
    797 
    798 
    799797-- Version: 1.1.48
    800798
    … …  
    834832    WHERE warpImfile.skycell_id IS NULL;
    835833
    836 
    837 
     834-- Version: 1.1.49 (change detrend sequence)
     835
     836show create table detResidImfile;
     837alter table detResidImfile drop foreign key detResidImfile_ibfk_3;
  • branches/cnb_branches/cnb_branch_20090215/dbconfig/config.md

    r21310 r23239  
    22    pkg_name        STR     ippdb
    33    pkg_namespace   STR     ippdb
    4     pkg_version     STR     1.1.48
     4    pkg_version     STR     1.1.49
    55END
  • branches/cnb_branches/cnb_branch_20090215/dbconfig/det.md

    r19620 r23239  
    9090    class_id    STR         64      # Primary Key
    9191    uri         STR         255
    92     recipe      STR         64
    93     bg          F64         0.0
    94     bg_stdev    F64         0.0
    95     bg_mean_stdev   F64     0.0
    96     user_1      F64         0.0
    97     user_2      F64         0.0
    98     user_3      F64         0.0
    99     user_4      F64         0.0
    100     user_5      F64         0.0
    101 #   XXX does it make sense to 'clean' the stacked imfiled?
     92    # XXX missing path_base
     93    recipe      STR         64
     94    bg          F64         0.0
     95    bg_stdev    F64         0.0
     96    bg_mean_stdev   F64     0.0
     97    user_1      F64         0.0
     98    user_2      F64         0.0
     99    user_3      F64         0.0
     100    user_4      F64         0.0
     101    user_5      F64         0.0
     102    #   XXX does it make sense to 'clean' the stacked imfiled? (EAM: yes)
    102103    data_state  STR         64      # full, cleaned, purged (only track end states; request states are in detRunSummary by iteration)
    103104    fault       S16         0       # Key NOT NULL
    … …  
    148149    fault       S16         0       # Key NOT NULL
    149150END
    150 
    151 #detMasterFrame METADATA
    152 #    det_id      S64         0       # Primary Key
    153 #    iteration   S32         0       # Primary Key
    154 #    comment     STR         255
    155 #END
    156 #
    157 ## drop?
    158 #detMasterImfile METADATA
    159 #    det_id      S64         0       # Primary Key
    160 #    class_id    STR         64      # Primary Key
    161 #    uri         STR         255
    162 #    recipe      STR         64
    163 #END
    164151
    165152detResidImfile METADATA
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_norm_apply.pl

    r23199 r23239  
    3838    'iteration|n=s'     => \$iter,       # Iteration
    3939    'class_id|i=s'      => \$class_id,   # Class ID
    40     'value|v=s'         => \$value,      # Value to multiple (for normalisation)
     40    'value|v=s'         => \$value,      # Value to apply (for normalisation)
    4141    'input_uri|u=s'     => \$input_uri,  # Input file
    4242    'camera|c=s'        => \$camera,     # Camera
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_norm_calc.pl

    r23199 r23239  
    9090my @files;                      # The input files
    9191{
    92     my $command = "$dettool -processedimfile";
    93     $command .= " -det_id $det_id"; # Command to run
     92    my $command = "$dettool -residimfile";
     93    $command .= " -det_id $det_id";
     94    $command .= " -iteration $iter";
    9495    $command .= " -included"; # only use the inputs for this detrend run to calculate the norm
    9596    $command .= " -dbname $dbname" if defined $dbname;
    … …  
    9899    print "Running [$command]...\n" if $verbose;
    99100    if (not run(\@command, \$stdin, \$stdout, \$stderr)) {
    100         &my_die("Unable to perform dettool -processedimfile on detrend $det_id/$iter: $?",
     101        &my_die("Unable to perform dettool -residimfile on detrend $det_id/$iter: $?",
    101102                $det_id, $iter, $PS_EXIT_SYS_ERROR);
    102103    }
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_resid_exp.pl

    r23199 r23239  
    8888&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe;
    8989
     90# variables used for I/O
     91my ($command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf);
     92
     93# Get list of normalizations by class_id : stored as $norms; save to temp file for ppImage runs below
     94my (%norms, $normsName);
     95{
     96    # dettool command to select imfile data for this exp_id
     97    $command  = "$dettool -normalizedstat";
     98    $command .= " -det_id $det_id";
     99    $command .= " -iteration $iter";
     100    $command .= " -dbname $dbname" if defined $dbname;
     101    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     102        run(command => $command, verbose => $verbose);
     103    unless ($success) {
     104        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     105        warn("Unable to perform dettool -residimfile: $error_code\n");
     106        exit($error_code);
     107    }
     108    if (@$stdout_buf == 0) {
     109        &my_die("No normalizations were found", $det_id, $iter, $PS_EXIT_PROG_ERROR);
     110    }
     111
     112    # Parse the stdout buffer into a metadata
     113    my $mdcParser = PS::IPP::Metadata::Config->new;
     114    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     115        &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR);
     116
     117    # parse the file info in the metadata
     118    my $normsMD = parse_md_list($metadata) or
     119        &my_die("Unable to parse metadata list", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR);
     120
     121
     122    # write the normalizations to a file as a metadata config file in the form: class_id F32 value
     123    # XXX a possible optimization: if there is only one imfile, skip normalization
     124    my $normsFile;
     125    ($normsFile, $normsName) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.norms.XXXX", UNLINK => !$save_temps );
     126    print "saving norms to $normsName\n";
     127    foreach my $norm (@$normsMD) {
     128        my $class_id = $norm->{class_id};
     129        my $normalization = $norm->{norm};
     130
     131        $norms{$class_id} = $normalization;
     132        printf $normsFile "$class_id F32 $normalization\n",
     133    }
     134    close $normsFile;
     135}
     136
    90137# Get list of imfile files
    91138my $cmdflags;
    92 my ($files, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf);
     139my (@files);
    93140{
    94141    # dettool command to select imfile data for this exp_id
    … …  
    105152        exit($error_code);
    106153    }
    107     # XXX report an error message if stdout_buf is empty
     154    if (@$stdout_buf == 0) {
     155        &my_die("No imfiles were found", $det_id, $iter, $PS_EXIT_PROG_ERROR);
     156    }
    108157
    109158    # Parse the stdout buffer into a metadata
    … …  
    112161        &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR);
    113162
     163    # since I can't figure out how to do input and output within PERL, I'm writing the (modified) metadata to a temp file
     164    my ($statFile, $statName) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.stats.XXXX", UNLINK => !$save_temps );
     165
    114166    # parse the file info in the metadata
    115     $files = parse_md_list($metadata) or
    116         &my_die("Unable to parse metadata list", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR);
    117 
    118     # since I can't figure out how to do input and output within PERL, I'm writing to a temp file
    119     my ($statFile, $statName) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.stats.XXXX", UNLINK => !$save_temps );
    120     print "saving stats to $statName\n";
    121     foreach my $line (@$stdout_buf) {
    122         print $statFile $line;
     167    # as we parse the list of files and their stats, apply the normalization to the relevant fields
     168    # also, write out the modified metadata set
     169    foreach my $mdItem (@$metadata) {
     170        if ($mdItem->{class} ne "metadata") {
     171            carp "MD element ", $mdItem->{name}, " isn't of type METADATA --- ignored.\n";
     172            next;
     173        }
     174        my %hash;               # Hash element
     175        my $mdComponents = $mdItem->{value}; # Components of the metadata
     176
     177        # determine the class_id for this block:
     178        my $class_id;
     179        foreach my $data (@$mdComponents) {
     180            unless ($data->{name} eq "class_id") { next; }
     181            $class_id = $data->{value};
     182            last;
     183        }
     184
     185        # a new metadata block
     186        print $statFile "rawResidImfile  METADATA\n";
     187
     188        # modify and save the data in this block:
     189        foreach my $data (@$mdComponents) {
     190            my $norm = $norms{$class_id};
     191
     192            # fields to modify by the normalization:
     193            if ($data->{name} eq "bg")            { $data->{value} *= $norm; }
     194            if ($data->{name} eq "bg_stdev")      { $data->{value} *= $norm; }
     195            if ($data->{name} eq "bg_mean_stdev") { $data->{value} *= $norm; }
     196            if ($data->{name} eq "bg_skewness")   { $data->{value} *= $norm; }
     197            if ($data->{name} eq "bg_kurtosis")   { $data->{value} *= $norm; }
     198            if ($data->{name} eq "bin_stdev")     { $data->{value} *= $norm; }
     199
     200            # write out the metadata, save on the array of hashes
     201            print $statFile "  $data->{name}  $data->{type}  $data->{value}\n";
     202            $hash{$data->{name}} = $data->{value};
     203        }
     204        print $statFile "END\n";
     205        push @files, \%hash;
    123206    }
    124207    close $statFile;
    … …  
    154237my ($list1File, $list1Name) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.b1.list.XXXX", UNLINK => !$save_temps );
    155238my ($list2File, $list2Name) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.b2.list.XXXX", UNLINK => !$save_temps );
    156 foreach my $file (@$files) {
     239foreach my $file (@files) {
    157240    print $list1File ($ipprc->filename( "PPIMAGE.BIN1", $file->{path_base}, $file->{class_id} ) . "\n");
    158241    print $list2File ($ipprc->filename( "PPIMAGE.BIN2", $file->{path_base}, $file->{class_id} ) . "\n");
    … …  
    165248unless ($no_op) {
    166249    # Make the jpeg for binning 1
     250    # XXX EAM : supply the collection of normalizations as a metadata
    167251    $command = "$ppImage -list $list1Name $outroot"; # Command to run
    168252    $command .= " -recipe PPIMAGE PPIMAGE_J1";
    169253    $command .= " -recipe JPEG $recipe";
     254    $command .= " -normlist $normsName";
    170255    $command .= " -dbname $dbname" if defined $dbname;
    171256    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    … …  
    178263
    179264    # Make the jpeg for binning 2
     265    # XXX EAM : supply the collection of normalizations as a metadata
    180266    $command = "$ppImage -list $list2Name $outroot"; # Command to run
    181267    $command .= " -recipe PPIMAGE PPIMAGE_J2";
    182268    $command .= " -recipe JPEG $recipe";
     269    $command .= " -normlist $normsName";
    183270    $command .= " -dbname $dbname" if defined $dbname;
    184271    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    … …  
    215302my @fluxes;
    216303
    217 foreach my $file (@$files) {
     304foreach my $file (@files) {
    218305    my $name      = $file->{class_id};
    219306    my $mean      = $file->{bg};        # Mean for this imfile
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/ipp_cleanup.pl

    r23199 r23239  
    4545my $ipprc = PS::IPP::Config->new( $camera ) or my_die("Unable to set up", $stage_id, $PS_EXIT_CONFIG_ERROR); # this is used for PATH, NEB filename conversions
    4646
    47 # $mode must be one of "goto_cleaned", "goto_scrubbed", or "goto_purged"
    48 # goto_cleaned and goto_scrubbed both result in 'cleaned': scrubbed allows chips without config files to
    49 # be cleaned (they cannot be recovered, but the small data is left behind)
     47# $mode must be one of "goto_cleaned", "goto_scrubbed", or
     48# "goto_purged" goto_cleaned and goto_scrubbed both result in
     49# 'cleaned' on success ('scrubbed' allows chips without config files
     50# to be cleaned; they cannot be recovered, but the small data is left
     51# behind). XXX make 'scrubbed' a data_state?
    5052unless (($mode eq "goto_cleaned") || ($mode eq "goto_scrubbed") || ($mode eq "goto_purged")) {
    5153    die "invalid cleanup mode $mode\n";
    5254}
     55
     56my $error_state;
     57if ($mode eq "goto_cleaned")  { $error_state = "error_cleaned";  }
     58if ($mode eq "goto_scrubbed") { $error_state = "error_scrubbed"; }
     59if ($mode eq "goto_purged")   { $error_state = "error_purged";   }
     60
    5361
    5462my %stages = ( chip => 1, camera => 1, fake => 1, warp => 1, stack => 1, diff  => 1);
    … …  
    148156            }
    149157        } else {
    150             # if an error happens for one chip, the chipRun will stay in goto_*, but the chips will stop be run
    151             my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -code 1";
    152             $command .= " -dbname $dbname" if defined $dbname;
     158
     159            # if an error happens for one chip, the chipRun will stay in goto_*, but the chips will go to error_* (matching the goto_*)
     160            my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -set_state $error_state";
     161            $command .= " -dbname $dbname" if defined $dbname;
    153162
    154163            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    … …  
    216225
    217226    if ($status)  {
    218         my $command = "$camtool -cam_id $stage_id -updaterun";
     227        my $command;
    219228        if ($mode eq "goto_cleaned") {
    220             $command .= " -state cleaned";
    221         } else {
    222             $command .= " -state purged";
     229            $command = "$camtool -updaterun -cam_id $stage_id -set_state cleaned";
     230        }
     231        if ($mode eq "goto_scrubbed") {
     232            $command = "$camtool -updaterun -cam_id $stage_id -set_state cleaned";
     233        }
     234        if ($mode eq "goto_purged") {
     235            $command = "$camtool -updaterun -cam_id $stage_id -set_state purged";
    223236        }
    224237        $command .= " -dbname $dbname" if defined $dbname;
    … …  
    230243        }
    231244    } else {
    232         my $command = "$camtool -updateprocessedexp -cam_id $stage_id -code 1";
     245        # since 'camera' has only a single imfile, we can just update the run
     246        my $command = "$camtool -updaterun -cam_id $stage_id -set_state $error_state";
    233247        $command .= " -dbname $dbname" if defined $dbname;
    234248
    … …  
    319333            }
    320334         } else {
    321             # XXX: -updateskyfile mode does not exist, need to add it
    322             my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -code 1";
    323             $command .= " -dbname $dbname" if defined $dbname;
     335            my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -set_state $error_state";
     336            $command .= " -dbname $dbname" if defined $dbname;
    324337
    325338            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    … …  
    337350# left TODO
    338351# fake : faketool : -pendingcleanupimfile (loop over imfiles)
    339 # stack: stacktool : -pendingcleanupskyfile (loop over skyfiles)
    340 # diff:  difftool : -pendingcleanupskyfile
     352# stack: stacktool : -pendingcleanupskyfile
     353# diff:  difftool : -pendingcleanupskyfile (loop over skyfiles)
    341354
    342355die "ipp_cleanup.pl -stage $stage not yet implemented\n";
    … …  
    367380}
    368381
     382# XXX we currently do not set the error state in the db on my_die
    369383sub my_die
    370384{
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/automate.pro

    r19621 r23239  
    175175  end
    176176
     177  task.exit    crash
     178    showcommand crash
     179  end
     180
    177181  # operation times out?
    178182  task.exit    timeout
    … …  
    283287  end
    284288
     289  task.exit    crash
     290    showcommand crash
     291  end
     292
    285293  # operation times out?
    286294  task.exit    timeout
    … …  
    373381  end
    374382
     383  task.exit    crash
     384    showcommand crash
     385  end
     386
    375387  # operation times out?
    376388  task.exit    timeout
    … …  
    448460  end
    449461
     462  task.exit    crash
     463    book setword automate $pageName pantaskState INIT.REGULAR
     464    showcommand crash
     465  end
     466
    450467  # operation times out?
    451468  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/calibration.pro

    r19465 r23239  
    9090  end
    9191
     92  task.exit    crash
     93    showcommand crash
     94  end
     95
    9296  # operation times out?
    9397  task.exit    timeout
    … …  
    166170  end
    167171
     172  task.exit    crash
     173    showcommand crash
     174    book setword calBook $options:0 pantaskState CRASH
     175  end
     176
    168177  # operation timed out?
    169178  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/camera.pro

    r19559 r23239  
    104104  end
    105105
     106  task.exit    crash
     107    showcommand crash
     108  end
     109
    106110  # operation times out?
    107111  task.exit    timeout
    … …  
    177181  task.exit default
    178182    process_exit camPendingExp $options:0 $JOB_STATUS
     183  end
     184
     185  # locked list
     186  task.exit    crash
     187    showcommand crash
     188    echo "hostname: $JOB_HOSTNAME"
     189    book setword camPendingExp $options:0 pantaskState CRASH
    179190  end
    180191
    … …  
    236247  end
    237248
     249  task.exit    crash
     250    showcommand crash
     251  end
     252
    238253  # operation times out?
    239254  task.exit    timeout
    … …  
    289304  end
    290305
     306  task.exit    crash
     307    showcommand crash
     308    book setword camPendingCleanup $options:0 pantaskState CRASH
     309  end
     310
    291311  # operation timed out?
    292312  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/chip.pro

    r21464 r23239  
    111111  task.exit    default
    112112    showcommand failure
     113  end
     114
     115  task.exit    crash
     116    showcommand crash
    113117  end
    114118
    … …  
    188192  end
    189193
     194  # locked list
     195  task.exit    crash
     196    showcommand crash
     197    echo "hostname: $JOB_HOSTNAME"
     198    book setword chipPendingImfile $options:0 pantaskState CRASH
     199  end
     200
    190201  # operation timed out?
    191202  task.exit    timeout
    … …  
    235246  end
    236247
     248  task.exit    crash
     249    showcommand crash
     250  end
     251
    237252  # operation times out?
    238253  task.exit    timeout
    … …  
    291306  end
    292307
     308  task.exit    crash
     309    showcommand crash
     310  end
     311
    293312  # operation times out?
    294313  task.exit    timeout
    … …  
    344363  end
    345364
     365  task.exit    crash
     366    showcommand crash
     367    book setword chipPendingCleanup $options:0 pantaskState CRASH
     368  end
     369
    346370  # operation timed out?
    347371  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.correct.pro

    r20398 r23239  
    8585  end
    8686
     87  task.exit    crash
     88    showcommand crash
     89  end
     90
    8791  # operation times out?
    8892  task.exit    timeout
    89     showcommand
     93    showcommand timeout
    9094  end
    9195end
    … …  
    145149  end
    146150
     151  # locked list
     152  task.exit    crash
     153    showcommand crash
     154    echo "hostname: $JOB_HOSTNAME"
     155    book setword detPendingCorrectImfile $options:0 pantaskState CRASH
     156  end
     157
    147158  # operation times out?
    148159  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.mkruns.pro

    r16298 r23239  
    3434  end
    3535
     36  task.exit crash
     37    # send someone email?
     38    echo "unable to define a new detrend run"
     39  end
     40
    3641  # operation timed out?  is the database down?
    3742  task.exit timeout
    … …  
    6065  # default exit status
    6166  task.exit default
     67    echo "unable to define a new detrend run"
     68  end
     69
     70  task.exit crash
     71    # send someone email?
    6272    echo "unable to define a new detrend run"
    6373  end
    … …  
    92102  end
    93103
     104  task.exit crash
     105    # send someone email?
     106    echo "unable to define a new detrend run"
     107  end
     108
    94109  # operation timed out?  is the database down?
    95110  task.exit timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.norm.pro

    r19465 r23239  
    168168  end
    169169
     170  task.exit    crash
     171    showcommand crash
     172  end
     173
    170174  # operation times out?
    171175  task.exit    timeout
    … …  
    225229  task.exit    default
    226230    process_exit detPendingNormStatImfile $options:0 $JOB_STATUS
     231  end
     232
     233  # locked list
     234  task.exit    crash
     235    showcommand crash
     236    echo "hostname: $JOB_HOSTNAME"
     237    book setword detPendingNormStatImfile $options:0 pantaskState CRASH
    227238  end
    228239
    … …  
    278289  task.exit    default
    279290    showcommand failure
     291  end
     292
     293  task.exit    crash
     294    showcommand crash
    280295  end
    281296
    … …  
    342357  end
    343358
     359  # locked list
     360  task.exit    crash
     361    showcommand crash
     362    echo "hostname: $JOB_HOSTNAME"
     363    book setword detPendingNormImfile $options:0 pantaskState CRASH
     364  end
     365
    344366  # operation times out?
    345367  task.exit    timeout
    … …  
    395417  end
    396418
     419  task.exit    crash
     420    showcommand crash
     421  end
     422
    397423  # operation times out?
    398424  task.exit    timeout
    … …  
    452478  task.exit    default
    453479    process_exit detPendingNormExp $options:0 $JOB_STATUS
     480  end
     481
     482  # locked list
     483  task.exit    crash
     484    showcommand crash
     485    echo "hostname: $JOB_HOSTNAME"
     486    book setword detPendingNormExp $options:0 pantaskState CRASH
    454487  end
    455488
    … …  
    506539  end
    507540
     541  task.exit    crash
     542    showcommand crash
     543  end
     544
    508545  # operation times out?
    509546  task.exit    timeout
    … …  
    558595  task.exit    default
    559596    process_exit detCleanupNormStatImfile $options:0 $JOB_STATUS
     597  end
     598
     599  task.exit    crash
     600    showcommand crash
     601    book setword detCleanupNormStatImfile $options:0 pantaskState CRASH
    560602  end
    561603
    … …  
    612654  end
    613655
     656  task.exit    crash
     657    showcommand crash
     658  end
     659
    614660  # operation times out?
    615661  task.exit    timeout
    … …  
    665711  task.exit    default
    666712    process_exit detCleanupNormImfile $options:0 $JOB_STATUS
     713  end
     714
     715  task.exit    crash
     716    showcommand crash
     717    book setword detCleanupNormImfile $options:0 pantaskState CRASH
    667718  end
    668719
    … …  
    719770  end
    720771
     772  task.exit    crash
     773    showcommand crash
     774  end
     775
    721776  # operation times out?
    722777  task.exit    timeout
    … …  
    773828  end
    774829
     830  task.exit    crash
     831    showcommand crash
     832    book setword detCleanupNormExp $options:0 pantaskState CRASH
     833  end
     834
    775835  # operation timed out?
    776836  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.process.pro

    r19465 r23239  
    136136  end
    137137
     138  task.exit    crash
     139    showcommand crash
     140  end
     141
    138142  # operation times out?
    139143  task.exit    timeout
    140     showcommand
     144    showcommand timeout
    141145  end
    142146end
    … …  
    202206  end
    203207
     208  # locked list
     209  task.exit    crash
     210    showcommand crash
     211    echo "hostname: $JOB_HOSTNAME"
     212    book setword detPendingProcessedImfile $options:0 pantaskState CRASH
     213  end
     214
    204215  # operation times out?
    205216  task.exit    timeout
    … …  
    255266  end
    256267
     268  task.exit    crash
     269    showcommand crash
     270  end
     271
    257272  # operation times out?
    258273  task.exit    timeout
    … …  
    319334  end
    320335
     336  # locked list
     337  task.exit    crash
     338    showcommand crash
     339    echo "hostname: $JOB_HOSTNAME"
     340    book setword detPendingProcessedExp $options:0 pantaskState CRASH
     341  end
     342
    321343  # operation times out?
    322344  task.exit    timeout
    … …  
    371393  end
    372394
     395  task.exit    crash
     396    showcommand crash
     397  end
     398
    373399  # operation times out?
    374400  task.exit    timeout
    … …  
    424450  task.exit    default
    425451    process_exit detCleanupProcessedImfile $options:0 $JOB_STATUS
     452  end
     453
     454  # locked list
     455  task.exit    crash
     456    showcommand crash
     457    echo "hostname: $JOB_HOSTNAME"
     458    book setword detCleanupProcessedImfile $options:0 pantaskState CRASH
    426459  end
    427460
    … …  
    479512  end
    480513
     514  task.exit    crash
     515    showcommand crash
     516  end
     517
    481518  # operation times out?
    482519  task.exit    timeout
    … …  
    533570  end
    534571
     572  # locked list
     573  task.exit    crash
     574    showcommand crash
     575    echo "hostname: $JOB_HOSTNAME"
     576    book setword detCleanupProcessedExp $options:0 pantaskState CRASH
     577  end
     578
    535579  # operation timed out?
    536580  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.reject.pro

    r19465 r23239  
    8383  end
    8484
     85  task.exit    crash
     86    showcommand crash
     87  end
     88
    8589  # operation times out?
    8690  task.exit    timeout
    87     showcommand failure
     91    showcommand timeout
    8892  end
    8993end
    … …  
    143147  end
    144148
     149  # locked list
     150  task.exit    crash
     151    showcommand crash
     152    echo "hostname: $JOB_HOSTNAME"
     153    book setword detRejectExp $options:0 pantaskState CRASH
     154  end
     155
    145156  # operation times out?
    146157  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.resid.pro

    r19621 r23239  
    129129  task.exit    default
    130130    showcommand failure
     131  end
     132
     133  task.exit    crash
     134    showcommand crash
    131135  end
    132136
    … …  
    203207  end
    204208
     209  # locked list
     210  task.exit    crash
     211    showcommand crash
     212    echo "hostname: $JOB_HOSTNAME"
     213    book setword detPendingResidImfile $options:0 pantaskState CRASH
     214  end
     215
    205216  # operation times out?
    206217  task.exit    timeout
    … …  
    254265  task.exit    default
    255266    showcommand failure
     267  end
     268
     269  task.exit    crash
     270    showcommand crash
    256271  end
    257272
    … …  
    320335  end
    321336
     337  # locked list
     338  task.exit    crash
     339    showcommand crash
     340    echo "hostname: $JOB_HOSTNAME"
     341    book setword detPendingResidExp $options:0 pantaskState CRASH
     342  end
     343
    322344  # operation times out?
    323345  task.exit    timeout
    … …  
    372394  end
    373395
     396  task.exit    crash
     397    showcommand crash
     398  end
     399
    374400  # operation times out?
    375401  task.exit    timeout
    … …  
    426452  task.exit    default
    427453    process_exit detCleanupResidImfile $options:0 $JOB_STATUS
     454  end
     455
     456  # locked list
     457  task.exit    crash
     458    showcommand crash
     459    echo "hostname: $JOB_HOSTNAME"
     460    book setword detCleanupResidImfile $options:0 pantaskState CRASH
    428461  end
    429462
    … …  
    481514  end
    482515
     516  task.exit    crash
     517    showcommand crash
     518  end
     519
    483520  # operation times out?
    484521  task.exit    timeout
    … …  
    536573  end
    537574
     575  # locked list
     576  task.exit    crash
     577    showcommand crash
     578    echo "hostname: $JOB_HOSTNAME"
     579    book setword detCleanupResidExp $options:0 pantaskState CRASH
     580  end
     581
    538582  # operation timed out?
    539583  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/detrend.stack.pro

    r19465 r23239  
    101101  end
    102102
     103  task.exit    crash
     104    showcommand crash
     105  end
     106
    103107  # operation times out?
    104108  task.exit    timeout
    … …  
    163167  task.exit    default
    164168    process_exit detPendingStackedImfile $options:0 $JOB_STATUS
     169  end
     170
     171  # locked list
     172  task.exit    crash
     173    showcommand crash
     174    echo "hostname: $JOB_HOSTNAME"
     175    book setword detPendingStackedImfile $options:0 pantaskState CRASH
    165176  end
    166177
    … …  
    217228  end
    218229
     230  task.exit    crash
     231    showcommand crash
     232  end
     233
    219234  # operation times out?
    220235  task.exit    timeout
    … …  
    272287  end
    273288
     289  # locked list
     290  task.exit    crash
     291    showcommand crash
     292    echo "hostname: $JOB_HOSTNAME"
     293    book setword detCleanupStackedImfile $options:0 pantaskState CRASH
     294  end
     295
    274296  # operation timed out?
    275297  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/diff.pro

    r21312 r23239  
    112112  end
    113113
     114  task.exit    crash
     115    showcommand crash
     116  end
     117
    114118  # operation times out?
    115119  task.exit    timeout
    … …  
    173177  task.exit    default
    174178    process_exit diffSkyfile $options:0 $JOB_STATUS
     179  end
     180
     181  # locked list
     182  task.exit    crash
     183    showcommand crash
     184    echo "hostname: $JOB_HOSTNAME"
     185    book setword diffSkyfile $options:0 pantaskState CRASH
    175186  end
    176187
    … …  
    229240  end
    230241
     242  task.exit    crash
     243    showcommand crash
     244  end
     245
    231246  # operation times out?
    232247  task.exit    timeout
    … …  
    282297  end
    283298
     299  task.exit    crash
     300    showcommand crash
     301    book setword diffCleanup $options:0 pantaskState CRASH
     302  end
     303
    284304  # operation timed out?
    285305  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/fake.pro

    r21464 r23239  
    176176  end
    177177
     178  # locked list
     179  task.exit    crash
     180    showcommand crash
     181    echo "hostname: $JOB_HOSTNAME"
     182    book setword fakePendingImfile $options:0 pantaskState CRASH
     183  end
     184
    178185  # operation timed out?
    179186  task.exit    timeout
    … …  
    219226  task.exit    default
    220227    showcommand failure
     228  end
     229
     230  task.exit    crash
     231    showcommand crash
    221232  end
    222233
    … …  
    278289  end
    279290
     291  task.exit    crash
     292    showcommand crash
     293  end
     294
    280295  # operation times out?
    281296  task.exit    timeout
    … …  
    331346  end
    332347
     348  task.exit    crash
     349    showcommand crash
     350    book setword fakePendingCleanup $options:0 pantaskState CRASH
     351  end
     352
    333353  # operation timed out?
    334354  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/flatcorr.pro

    r20513 r23239  
    104104  end
    105105
     106  task.exit    crash
     107    showcommand crash
     108  end
     109
    106110  # operation times out?
    107111  task.exit    timeout
    … …  
    157161  end
    158162
     163  task.exit    crash
     164    showcommand crash
     165  end
     166
    159167  # operation times out?
    160168  task.exit    timeout
    … …  
    229237  end
    230238
     239  task.exit    crash
     240    showcommand crash
     241    book setword flatcorrBook $options:0 pantaskState CRASH
     242  end
     243
    231244  # operation timed out?
    232245  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/magic.pro

    r21436 r23239  
    118118  end
    119119
     120  task.exit    crash
     121    showcommand crash
     122  end
     123
    120124  # operation times out?
    121125  task.exit    timeout
    … …  
    189193  end
    190194
     195  task.exit    crash
     196    showcommand crash
     197    book setword magicToTree $options:0 pantaskState CRASH
     198  end
     199
    191200  # operation timed out?
    192201  task.exit    timeout
    … …  
    239248  end
    240249
     250  task.exit    crash
     251    showcommand crash
     252  end
     253
    241254  # operation times out?
    242255  task.exit    timeout
    … …  
    302315  task.exit    default
    303316    process_exit magicToProcess $options:0 $JOB_STATUS
     317  end
     318
     319  task.exit    crash
     320    showcommand crash
     321    book setword magicToProcess $options:0 pantaskState CRASH
    304322  end
    305323
    … …  
    353371  task.exit    default
    354372    showcommand failure
     373  end
     374
     375  task.exit    crash
     376    showcommand crash
    355377  end
    356378
    … …  
    423445  end
    424446
     447  task.exit    crash
     448    showcommand crash
     449    book setword magicToDS $options:0 pantaskState CRASH
     450  end
     451
    425452  # operation timed out?
    426453  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/pstamp.pro

    r21411 r23239  
    9797    end
    9898
     99    task.exit   crash
     100        showcommand crash
     101    end
     102
    99103    task.exit   timeout
    100104        showcommand timeout
    … …  
    136140    end
    137141
     142    task.exit   crash
     143        showcommand crash
     144    end
     145
    138146    task.exit   timeout
    139147        showcommand timeout
    … …  
    178186        showcommand failure
    179187        process_exit pstampRequest $options:0 $JOB_STATUS
     188    end
     189
     190    task.exit crash
     191        showcommand crash
     192        book setword pstampRequest $options:0 pantaskState CRASH
    180193    end
    181194
    … …  
    219232    end
    220233
     234    task.exit   crash
     235        showcommand crash
     236    end
     237
    221238    task.exit   timeout
    222239        showcommand timeout
    … …  
    263280        process_exit pstampFinish $options:0 $JOB_STATUS
    264281        showcommand failure
     282    end
     283
     284    task.exit crash
     285        showcommand crash
     286        book setword pstampFinish $options:0 pantaskState CRASH.run
    265287    end
    266288
    … …  
    307329    end
    308330
     331    task.exit   crash
     332        showcommand crash
     333    end
     334
    309335    task.exit   timeout
    310336        showcommand timeout
    … …  
    362388    end
    363389
     390    task.exit crash
     391        echo pstamp.job.run task.crash $JOB_ID status: $JOB_STATUS
     392        process_exit pstampJob $options:0 $JOB_STATUS
     393        showcommand crash
     394        book setword pstampJob $options:0 pantaskState CRASH
     395    end
     396
    364397    task.exit timeout
    365398        echo pstamp.job.run task.timeout $JOB_ID status: $JOB_STATUS
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/register.pro

    r20498 r23239  
    180180  end
    181181
     182  task.exit    crash
     183    showcommand crash
     184  end
     185
    182186  # operation times out?
    183187  task.exit    timeout
    … …  
    255259  task.exit default
    256260    process_exit regPendingImfile $options:0 $JOB_STATUS
     261  end
     262
     263  # locked list
     264  task.exit    crash
     265    showcommand crash
     266    echo "hostname: $JOB_HOSTNAME"
     267    book setword regPendingImfile $options:0 pantaskState CRASH
    257268  end
    258269
    … …  
    306317  task.exit    default
    307318    showcommand failure
     319  end
     320
     321  task.exit    crash
     322    showcommand crash
    308323  end
    309324
    … …  
    392407  end
    393408
     409  # locked list
     410  task.exit    crash
     411    showcommand crash
     412    echo "hostname: $JOB_HOSTNAME"
     413    book setword regPendingExp $options:0 pantaskState CRASH
     414  end
     415
     416  task.exit    crash
     417    showcommand crash
     418    book setword regPendingExp $options:0 pantaskState CRASH
     419  end
     420
    394421  # operation times out?
    395422  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/replicate.pro

    r19747 r23239  
    102102  end
    103103
     104  task.exit    crash
     105    showcommand crash
     106  end
     107
    104108  # operation times out?
    105109  task.exit    timeout
    … …  
    158162  end
    159163
     164  task.exit    crash
     165    showcommand crash
     166    book setword replicatePending $options:0 pantaskState CRASH
     167  end
     168
    160169  # operation timed out?
    161170  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/stack.pro

    r19597 r23239  
    112112  end
    113113
     114  task.exit    crash
     115    showcommand crash
     116  end
     117
    114118  # operation times out?
    115119  task.exit    timeout
    … …  
    172176  task.exit    default
    173177    process_exit stackSumSkyfile $options:0 $JOB_STATUS
     178  end
     179
     180  # locked list
     181  task.exit    crash
     182    showcommand crash
     183    echo "hostname: $JOB_HOSTNAME"
     184    book setword stackSumSkyfile $options:0 pantaskState CRASH
    174185  end
    175186
    … …  
    229240  end
    230241
     242  task.exit    crash
     243    showcommand crash
     244  end
     245
    231246  # operation times out?
    232247  task.exit    timeout
    … …  
    282297  end
    283298
     299  task.exit    crash
     300    showcommand crash
     301    book setword stackCleanup $options:0 pantaskState CRASH
     302  end
     303
    284304  # operation timed out?
    285305  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/summit.copy.pro

    r21478 r23239  
    126126        showcommand failure
    127127    end
     128    task.exit crash
     129        showcommand crash
     130    end
    128131    task.exit timeout
    129132        showcommand timeout
    … …  
    182185    showcommand failure
    183186  end
     187  task.exit     crash
     188    showcommand crash
     189  end
    184190  task.exit     timeout
    185191    showcommand timeout
    … …  
    228234          queueprint stderr
    229235        end
     236    end
     237    task.exit crash
     238        showcommand crash
    230239    end
    231240    task.exit timeout
    … …  
    296305        showcommand failure
    297306        process_exit pzPendingExp $options:0 $JOB_STATUS
     307    end
     308
     309    task.exit crash
     310        showcommand crash
     311        book setword pzPendingExp $options:0 pantaskState CRASH
    298312    end
    299313
    … …  
    344358        showcommand failure
    345359    end
     360    task.exit     crash
     361        showcommand crash
     362    end
    346363    task.exit     timeout
    347364        showcommand timeout
    … …  
    413430        book setword pzPendingImfile $pageName filename $FILENAME
    414431
     432        stdout $LOGDIR/summit.copy.log
     433        stderr $LOGDIR/summit.copy.log
     434
    415435        $run = summit_copy.pl --uri $URI --filename $FILENAME --exp_name $EXP_NAME --inst $CAMERA --telescope $TELESCOPE --class $CLASS --class_id $CLASS_ID --bytes $BYTES --md5 $MD5SUM --end_stage reg --workdir $workdir --dbname $DBNAME --timeout 120 --verbose --copies 2
    416436        if ($COMPRESS)
    … …  
    442462    end
    443463
     464    task.exit crash
     465        showcommand crash
     466        book setword pzPendingImfile $options:0 pantaskState CRASH
     467    end
     468
    444469    # operation timed out?
    445470    task.exit timeout
    … …  
    476501    task.exit default
    477502        showcommand failure
     503    end
     504    task.exit crash
     505        showcommand crash
    478506    end
    479507    task.exit timeout
    … …  
    518546  end
    519547
     548  task.exit    crash
     549    showcommand crash
     550  end
     551
    520552  # operation times out?
    521553  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTasks/warp.pro

    r20932 r23239  
    127127  end
    128128
     129  task.exit    crash
     130    showcommand crash
     131  end
     132
    129133  # operation times out?
    130134  task.exit    timeout
    … …  
    185189  task.exit    default
    186190    process_exit warpInputExp $options:0 $JOB_STATUS
     191  end
     192
     193  # locked list
     194  task.exit    crash
     195    showcommand crash
     196    echo "hostname: $JOB_HOSTNAME"
     197    book setword warpInputExp $options:0 pantaskState CRASH
    187198  end
    188199
    … …  
    239250  task.exit    default
    240251    showcommand failure
     252  end
     253
     254  task.exit    crash
     255    showcommand crash
    241256  end
    242257
    … …  
    303318  end
    304319
     320  # locked list
     321  task.exit    crash
     322    showcommand crash
     323    echo "hostname: $JOB_HOSTNAME"
     324    book setword warpPendingSkyCell $options:0 pantaskState CRASH
     325  end
     326
    305327  # operation timed out?
    306328  task.exit    timeout
    … …  
    357379  end
    358380
     381  task.exit    crash
     382    showcommand crash
     383  end
     384
    359385  # operation times out?
    360386  task.exit    timeout
    … …  
    410436  end
    411437
     438  task.exit    crash
     439    showcommand crash
     440    book setword warpPendingCleanup $options:0 pantaskState CRASH
     441  end
     442
    412443  # operation timed out?
    413444  task.exit    timeout
  • branches/cnb_branches/cnb_branch_20090215/ippTools/share/chiptool_change_imfile_data_state.sql

    r19527 r23239  
    77    chip_id = %lld
    88    AND class_id = '%s'
    9     -- only update if chipRun.state has the expected value
    10     AND (
    11         SELECT state from chipRun where chipRun.chip_id = chipProcessedImfile.chip_id
    12     ) = '%s'
    13    
    14 
     9--    -- only update if chipRun.state has the expected value
     10--    AND (
     11--        SELECT state from chipRun where chipRun.chip_id = chipProcessedImfile.chip_id
     12--    ) = '%s'
  • branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_processedimfile.sql

    r18561 r23239  
     1-- is this DISTINCT needed?
    12SELECT DISTINCT
    23  detRun.det_type,
  • branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_residimfile.sql

    r19632 r23239  
    22   detRun.det_type,
    33   detRun.mode,
    4    detResidImfile.*,
    5    rawExp.exp_time
    6  FROM detResidImfile
    7  JOIN detRun
    8    USING(det_id, iteration)
    9  JOIN rawExp
    10    USING(exp_id)
     4   rawExp.exp_time,
     5   detResidImfile.*
     6FROM detResidImfile
     7JOIN detRun
     8  USING(det_id, iteration)
     9JOIN detInputExp
     10  ON detRun.det_id = detInputExp.det_id
     11  AND detRun.iteration = detInputExp.iteration
     12  AND detResidImfile.exp_id = detInputExp.exp_id
     13JOIN rawExp
     14  ON rawExp.exp_id = detResidImfile.exp_id
  • branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_tonormalizedstat.sql

    r18118 r23239  
    1 -- select detRun.det_id (det_id)
    2 -- select detRun.iteration
    3 -- by:
    4 -- find the current iteration bassed on det_id
    5 -- find all exp_ids in the current det_id/iteration from detInputExp
    6 -- sort to detInputExp.imfiles to find the largest value per det_id/iter
    7 -- compare imfiles to the number of detStackedImfiles by class_id
    8 -- and:
    9 -- ???
    10 -- det_id is not in detStackedImfile;
    11 -- iteration is not in detStackedImfile;
    12 
    13 SELECT
    14     det_id,
    15     det_type,
    16     iteration,
    17     camera,
    18     workdir,
    19     class_id
    20 FROM
    21     (SELECT DISTINCT
    22         detRun.det_id,
    23         detRun.det_type,
    24         detRun.iteration,
    25         detRun.workdir,
    26         rawExp.camera,
    27         detStackedImfile.class_id,
    28         rawImfile.class_id as rawimfile_class_id
    29     FROM detRun
    30     JOIN detInputExp
    31         ON detRun.det_id = detInputExp.det_id
    32         AND detRun.iteration = detInputExp.iteration
    33     JOIN rawExp
    34         ON detInputExp.exp_id = rawExp.exp_id
    35     JOIN rawImfile
    36         ON rawExp.exp_id = rawImfile.exp_id
    37     LEFT JOIN detStackedImfile
    38         ON detInputExp.det_id = detStackedImfile.det_id
    39         AND detInputExp.iteration = detStackedImfile.iteration
    40         AND rawImfile.class_id = detStackedImfile.class_id
    41     LEFT JOIN detNormalizedStatImfile
    42         ON detStackedImfile.det_id = detNormalizedStatImfile.det_id
    43         AND detStackedImfile.iteration = detNormalizedStatImfile.iteration
    44         AND detStackedImfile.class_id = detNormalizedStatImfile.class_id
    45     WHERE
    46         detRun.state = 'run'
    47         AND detRun.mode = 'master'
    48         AND detNormalizedStatImfile.det_id IS NULL
    49         AND detNormalizedStatImfile.iteration IS NULL
    50         AND detNormalizedStatImfile.class_id IS NULL
    51     GROUP BY
    52 --        rawExp.exp_id,
    53         detRun.iteration,
    54         detRun.det_id
    55     HAVING
    56         COUNT(rawImfile.class_id) = COUNT(detStackedImfile.class_id)
    57         AND SUM(detStackedImfile.fault) = 0
    58     ) as tonormalizedstat
     1-- a det_run + iteration is ready for normstat when: all detResidImfile entries for that iteration corresponding to all detProcessedImfile entries are available
     2SELECT
     3  detRun.det_id,
     4  detRun.det_type,
     5  detRun.iteration,
     6  detRun.camera,
     7  detRun.workdir,
     8  detProcessedImfile.class_id,
     9  COUNT(detProcessedImfile.class_id),
     10  COUNT(detResidImfile.class_id)
     11FROM detRun
     12JOIN detProcessedImfile
     13    ON  detProcessedImfile.det_id    = detRun.det_id
     14LEFT JOIN detResidImfile
     15    ON  detResidImfile.det_id    = detProcessedImfile.det_id
     16    AND detResidImfile.class_id  = detProcessedImfile.class_id
     17    AND detResidImfile.iteration = detRun.iteration
     18LEFT JOIN detNormalizedStatImfile
     19    ON  detNormalizedStatImfile.det_id    = detRun.det_id   
     20    AND detNormalizedStatImfile.iteration = detRun.iteration
     21    AND detNormalizedStatImfile.class_id  = detProcessedImfile.class_id
     22WHERE
     23    detRun.state = 'run'
     24    AND detRun.mode = 'master'
     25    AND detNormalizedStatImfile.det_id IS NULL
     26    AND detNormalizedStatImfile.iteration IS NULL
     27    AND detNormalizedStatImfile.class_id IS NULL
     28GROUP BY
     29    detRun.iteration,
     30    detRun.det_id
     31HAVING
     32    COUNT(detProcessedImfile.class_id) = COUNT(detResidImfile.class_id)
     33    AND SUM(detResidImfile.fault) = 0
  • branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_toresidexp.sql

    r19815 r23239  
    55-- id, detrend type, and whether the exposure was included in the stack for
    66-- this iteration.
     7
     8-- require the corresponding detNormalizedExp to complete before starting
    79
    810-- select detRun.det_id
    … …  
    4143        detResidImfile.class_id
    4244    FROM detRun
     45    JOIN detNormalizedExp
     46        USING(det_id, iteration)
    4347    JOIN detInputExp
    4448        USING(det_id, iteration)
  • branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_toresidimfile.sql

    r19816 r23239  
    1313    detProcessedImfile.class_id,
    1414    detProcessedImfile.uri,
    15     detNormalizedImfile.uri AS det_uri,
     15--  detNormalizedImfile.uri AS det_uri,
     16    detStackedImfile.uri AS det_uri,
    1617    detRun.det_id AS ref_det_id,
    1718    detRun.iteration AS ref_iter,
    … …  
    2627    ON detRun.det_id = detProcessedImfile.det_id
    2728    AND detInputExp.exp_id = detProcessedImfile.exp_id
    28 JOIN detNormalizedImfile
    29     ON detRun.det_id = detNormalizedImfile.det_id
    30     AND detRun.iteration = detNormalizedImfile.iteration
    31     AND detProcessedImfile.class_id = detNormalizedImfile.class_id
    32 JOIN detNormalizedExp
    33     ON detRun.det_id = detNormalizedExp.det_id
    34     AND detRun.iteration = detNormalizedExp.iteration
     29JOIN detStackedImfile
     30    ON detRun.det_id = detStackedImfile.det_id
     31    AND detRun.iteration = detStackedImfile.iteration
     32    AND detProcessedImfile.class_id = detStackedImfile.class_id
     33-- EAM : replacing detNormalizedImfile with detStackedImfile to change the sequencing
     34-- JOIN detNormalizedImfile
     35--     ON detRun.det_id = detNormalizedImfile.det_id
     36--     AND detRun.iteration = detNormalizedImfile.iteration
     37--     AND detProcessedImfile.class_id = detNormalizedImfile.class_id
     38-- EAM : we there is no reason to wait for all stacks to complete before continuing
     39-- JOIN detNormalizedExp
     40--     ON detRun.det_id = detNormalizedExp.det_id
     41--     AND detRun.iteration = detNormalizedExp.iteration
    3542LEFT JOIN detResidImfile
    3643    ON detRun.det_id = detResidImfile.det_id
    … …  
    4148    detRun.state = 'run'
    4249    AND detRun.mode = 'master'
    43     AND detNormalizedImfile.fault = 0
    44     AND detNormalizedExp.fault = 0
     50    AND detStackedImfile.fault = 0
     51--  AND detNormalizedImfile.fault = 0
     52--  AND detNormalizedExp.fault = 0
    4553    AND detResidImfile.det_id IS NULL
    4654    AND detResidImfile.iteration IS NULL
  • branches/cnb_branches/cnb_branch_20090215/ippTools/share/pxadmin_create_tables.sql

    r21308 r23239  
    737737    REFERENCES  detInputExp(det_id, iteration, exp_id),
    738738    FOREIGN KEY (det_id, exp_id, class_id)
    739     REFERENCES  detProcessedImfile(det_id, exp_id, class_id),
    740     FOREIGN KEY (ref_det_id, ref_iter)
    741     REFERENCES  detNormalizedExp(det_id, iteration)
     739    REFERENCES  detProcessedImfile(det_id, exp_id, class_id)
    742740) ENGINE=innodb DEFAULT CHARSET=latin1;
    743741
  • branches/cnb_branches/cnb_branch_20090215/ippTools/share/warptool_change_skyfile_data_state.sql

    r19521 r23239  
    99    AND skycell_id = '%s'
    1010    -- only update if chipRun.state has the expected value
    11     AND (
    12         SELECT state from warpRun where warpRun.warp_id = warpSkyfile.warp_id
    13     ) = '%s'
    14    
    15 
     11--    AND (
     12--        SELECT state from warpRun where warpRun.warp_id = warpSkyfile.warp_id
     13--    ) = '%s'
  • branches/cnb_branches/cnb_branch_20090215/ippTools/src/chiptool.c

    r23199 r23239  
    5252static bool runMode(pxConfig *config);
    5353static bool tocleanedimfileMode(pxConfig *config);
    54 static bool tocleanedimfile_from_scrubbedMode(pxConfig *config);
     54// static bool tocleanedimfile_from_scrubbedMode(pxConfig *config);
    5555static bool tofullimfileMode(pxConfig *config);
    5656static bool topurgedimfileMode(pxConfig *config);
    5757static bool exportrunMode(pxConfig *config);
    5858static bool importrunMode(pxConfig *config);
     59static bool change_imfile_data_state(pxConfig *config, psString data_state, psString run_state);
    5960
    6061# define MODECASE(caseName, func) \
    … …  
    9293        MODECASE(CHIPTOOL_MODE_RUN,                     runMode);
    9394        MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE,         tocleanedimfileMode);
    94         MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedMode);
     95        // MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedMode);
    9596        MODECASE(CHIPTOOL_MODE_TOFULLIMFILE,            tofullimfileMode);
    9697        MODECASE(CHIPTOOL_MODE_TOPURGEDIMFILE,          topurgedimfileMode);
    … …  
    651652    PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
    652653    PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");
    653     PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
    654 
    655     if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, code)) {
     654    PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
     655    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
     656
     657    if (state && code) {
     658        psError(PS_ERR_UNKNOWN, true, "only one of -set_state and -code may be supplied");
     659        return false;
     660    }
     661
     662    if (state) {
     663      // make sure that the state string is valid
     664      if (!pxIsValidState(state)) {
     665        psError(PXTOOLS_ERR_DATA, false, "%s is not a valid state", state);
     666        return false;
     667      }
     668      if (!change_imfile_data_state(config, state, "unknown")) {
    656669        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
    657670        return false;
    658     }
    659     psFree(where);
    660 
    661     return true;
     671      }
     672      return true;
     673    }
     674
     675    if (code) {
     676      if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, code)) {
     677        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
     678        return false;
     679      }
     680      psFree(where);
     681      return true;
     682    }
     683
     684    psError(PS_ERR_UNKNOWN, true, "one of -set_state or -code must be supplied");
     685    return false;
    662686}
    663687
    … …  
    11951219// shared code for the modes -tocleanedimfile -tofullimfile -topurgedimfile
    11961220
     1221// XXX EAM : this function was enforcing only certain transitions with the SQL.  However,
     1222// this is getting fairly messy now that we have added a few additional target and
     1223// destination states.  I'm disabling these restrictions for now; is there are better way
     1224// to enforce the allowed state transitions?
     1225
    11971226static bool change_imfile_data_state(pxConfig *config, psString data_state, psString run_state)
    11981227{
    … …  
    12101239    }
    12111240
     1241    // XXX this feature is disabled (run_state is ignored)
    12121242    // note only updates if chipRun.state = run_state
    1213     if (!p_psDBRunQueryF(config->dbh, query, data_state, chip_id, class_id, run_state)) {
     1243
     1244    if (!p_psDBRunQueryF(config->dbh, query, data_state, chip_id, class_id)) {
    12141245        psError(PS_ERR_UNKNOWN, false, "database error");
    12151246        // rollback
    … …  
    12461277{
    12471278    return change_imfile_data_state(config, "cleaned", "goto_cleaned");
    1248 }
    1249 static bool tocleanedimfile_from_scrubbedMode(pxConfig *config)
    1250 {
    1251     return change_imfile_data_state(config, "cleaned", "goto_scrubbed");
    12521279}
    12531280static bool tofullimfileMode(pxConfig *config)
  • branches/cnb_branches/cnb_branch_20090215/ippTools/src/chiptoolConfig.c

    r23199 r23239  
    172172    // -updateprocessedimfile
    173173    psMetadata *updateprocessedimfileArgs = psMetadataAlloc();
    174     psMetadataAddS64(updateprocessedimfileArgs, PS_LIST_TAIL, "-chip_id",  0,            "search by chip ID", 0);
    175     psMetadataAddStr(updateprocessedimfileArgs,  PS_LIST_TAIL, "-class_id",           0, "search by class ID", NULL);
    176     psMetadataAddS16(updateprocessedimfileArgs, PS_LIST_TAIL, "-code",  0,            "set fault code (required)", 0);
     174    psMetadataAddS64(updateprocessedimfileArgs, PS_LIST_TAIL, "-chip_id",    0, "search by chip ID", 0);
     175    psMetadataAddStr(updateprocessedimfileArgs,  PS_LIST_TAIL, "-class_id",  0, "search by class ID", NULL);
     176    psMetadataAddS16(updateprocessedimfileArgs, PS_LIST_TAIL, "-code",       0, "set fault code", 0);
     177    psMetadataAddStr(updateprocessedimfileArgs, PS_LIST_TAIL, "-set_state",  0, "set state", NULL);
    177178
    178179    // -promoteexp
    … …  
    234235    psMetadataAddStr(tocleanedimfileArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
    235236
    236     // -tocleanedimfile_from_scrubbed
    237     psMetadata *tocleanedimfile_from_scrubbedArgs = psMetadataAlloc();
    238     psMetadataAddS64(tocleanedimfile_from_scrubbedArgs, PS_LIST_TAIL, "-chip_id", 0,          "chip ID to update", 0);
    239     psMetadataAddStr(tocleanedimfile_from_scrubbedArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
    240 
     237//    // -tocleanedimfile_from_scrubbed
     238//    psMetadata *tocleanedimfile_from_scrubbedArgs = psMetadataAlloc();
     239//    psMetadataAddS64(tocleanedimfile_from_scrubbedArgs, PS_LIST_TAIL, "-chip_id", 0,          "chip ID to update", 0);
     240//    psMetadataAddStr(tocleanedimfile_from_scrubbedArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
     241//
    241242    // -tofullimfile
    242243    psMetadata *tofullimfileArgs = psMetadataAlloc();
    … …  
    280281    PXOPT_ADD_MODE("-run",                  "show runs",                            CHIPTOOL_MODE_RUN,                  runArgs);
    281282    PXOPT_ADD_MODE("-tocleanedimfile",      "set imfile state to cleaned",          CHIPTOOL_MODE_TOCLEANEDIMFILE,      tocleanedimfileArgs);
    282     PXOPT_ADD_MODE("-tocleanedimfile_from_scrubbed", "set imfile state to cleaned (for goto_scrubbed)", CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedArgs);
     283    //    PXOPT_ADD_MODE("-tocleanedimfile_from_scrubbed", "set imfile state to cleaned (for goto_scrubbed)", CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedArgs);
    283284    PXOPT_ADD_MODE("-tofullimfile",         "set imfile state to full",              CHIPTOOL_MODE_TOFULLIMFILE,         tofullimfileArgs);
    284285    PXOPT_ADD_MODE("-topurgedimfile",       "set imfile state to purged",            CHIPTOOL_MODE_TOPURGEDIMFILE,       topurgedimfileArgs);
  • branches/cnb_branches/cnb_branch_20090215/ippTools/src/dettoolConfig.c

    r23199 r23239  
    640640    // -residimfile
    641641    psMetadata *residimfileArgs = psMetadataAlloc();
    642     psMetadataAddS64(residimfileArgs, PS_LIST_TAIL, "-det_id",  0,            "search for detrend ID", 0);
    643     psMetadataAddS32(residimfileArgs, PS_LIST_TAIL, "-iteration",  0,            "search for iteration number", 0);
    644     psMetadataAddS64(residimfileArgs, PS_LIST_TAIL, "-exp_id",  0,            "search by detrend ID", 0);
    645     psMetadataAddStr(residimfileArgs, PS_LIST_TAIL, "-class_id",  0,            "search for class ID", NULL);
    646     psMetadataAddStr(residimfileArgs, PS_LIST_TAIL, "-recip",  0,            "search for recipe", NULL);
    647     psMetadataAddU64(residimfileArgs, PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
     642    psMetadataAddS64(residimfileArgs,  PS_LIST_TAIL, "-det_id",  0,            "search for detrend ID", 0);
     643    psMetadataAddS32(residimfileArgs,  PS_LIST_TAIL, "-iteration",  0,            "search for iteration number", 0);
     644    psMetadataAddS64(residimfileArgs,  PS_LIST_TAIL, "-exp_id",  0,            "search by detrend ID", 0);
     645    psMetadataAddStr(residimfileArgs,  PS_LIST_TAIL, "-class_id",  0,            "search for class ID", NULL);
     646    psMetadataAddStr(residimfileArgs,  PS_LIST_TAIL, "-recip",  0,            "search for recipe", NULL);
     647    psMetadataAddU64(residimfileArgs,  PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
    648648    psMetadataAddBool(residimfileArgs, PS_LIST_TAIL, "-faulted",  0,            "only return imfiles with a fault status set", false);
    649649    psMetadataAddBool(residimfileArgs, PS_LIST_TAIL, "-simple",  0,            "use the simple output format", false);
    650     psMetadataAddStr(residimfileArgs, PS_LIST_TAIL, "-select_state",  0,            "search for state", NULL);
     650    psMetadataAddBool(residimfileArgs, PS_LIST_TAIL, "-included",  0,            "restrict results to exposures 'includeded' in the current iteration", false);
     651    psMetadataAddStr(residimfileArgs,  PS_LIST_TAIL, "-select_state",  0,            "search for state", NULL);
    651652
    652653    // -revertresidimfile
  • branches/cnb_branches/cnb_branch_20090215/ippTools/src/dettool_processedimfile.c

    r19621 r23239  
    165165    PS_ASSERT_PTR_NON_NULL(config, false);
    166166
    167     bool hasWhere = false;
    168 
    169     PXOPT_LOOKUP_BOOL(included, config->args, "-included", false);
    170     PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
    171     PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    172     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    173 
    174167    psMetadata *where = psMetadataAlloc();
    175168    PXOPT_COPY_S64(config->args, where, "-det_id", "detProcessedImfile.det_id", "==");
    … …  
    179172    PXOPT_COPY_STR(config->args, where, "-select_mode", "detRun.mode", "==");
    180173
     174    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     175    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     176
     177    PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
     178    PXOPT_LOOKUP_BOOL(included, config->args, "-included", false);
     179
    181180    psString query = pxDataGet("dettool_processedimfile.sql");
    182181    if (!query) {
    … …  
    186185    }
    187186
     187    bool hasWhere = false;
    188188    if (psListLength(where->list)) {
    189189        psString whereClause = psDBGenerateWhereSQL(where, NULL);
    … …  
    211211
    212212    if (faulted) {
     213        // list only faulted rows
    213214        psStringAppend(&query, " %s", " detProcessedImfile.fault != 0");
    214215    } else {
  • branches/cnb_branches/cnb_branch_20090215/ippTools/src/dettool_residimfile.c

    r19632 r23239  
    159159    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    160160    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     161
    161162    PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
     163    PXOPT_LOOKUP_BOOL(included, config->args, "-included", false);
    162164
    163165    psString query = pxDataGet("dettool_residimfile.sql");
    … …  
    175177    }
    176178    psFree(where);
     179
     180    // restrict search to included imfiles
     181    if (included) {
     182        if (hasWhere) {
     183            psStringAppend(&query, " AND detInputExp.include = 1");
     184        } else {
     185            psStringAppend(&query, " WHERE detInputExp.include = 1");
     186        }
     187        hasWhere = true;
     188    }
    177189
    178190    if (hasWhere) {
  • branches/cnb_branches/cnb_branch_20090215/ippTools/src/warptool.c

    r21402 r23239  
    5555static bool updateskyfileMode(pxConfig *config);
    5656
     57static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state);
    5758static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile);
    5859static bool isValidMode(pxConfig *config, const char *mode);
    … …  
    16041605// shared code for the modes -tocleanedskyfile -tofullskyfile -topurgedskyfile
    16051606
     1607// XXX EAM : this function was enforcing only certain transitions with the SQL.  However,
     1608// this is getting fairly messy now that we have added a few additional target and
     1609// destination states.  I'm disabling these restrictions for now; is there are better way
     1610// to enforce the allowed state transitions?
     1611
    16061612static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state)
    16071613{
    … …  
    16191625    }
    16201626
     1627    // XXX this feature is disabled (run_state is ignored)
    16211628    // note only updates if warpRun.state = run_state
    1622     if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id, run_state)) {
     1629
     1630    if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id)) {
    16231631        psError(PS_ERR_UNKNOWN, false, "database error");
    16241632        // rollback
    … …  
    16681676    PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", true, false);
    16691677    PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false);
     1678    PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
    16701679    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
    16711680
    1672     psString query = pxDataGet("warptool_updateskyfile.sql");
    1673 
    1674     if (!p_psDBRunQueryF(config->dbh, query, code, warp_id, skycell_id)) {
    1675         psError(PS_ERR_UNKNOWN, false, "database error");
    1676         return false;
    1677     }
    1678     psFree(query);
    1679 
    1680     return true;
    1681 }
     1681    if (state && code) {
     1682        psError(PS_ERR_UNKNOWN, true, "only one of -set_state and -code may be supplied");
     1683        return false;
     1684    }
     1685
     1686    if (state) {
     1687      // make sure that the state string is valid
     1688      if (!pxIsValidState(state)) {
     1689        psError(PXTOOLS_ERR_DATA, false, "%s is not a valid state", state);
     1690        return false;
     1691      }
     1692      if (!change_skyfile_data_state(config, state, "unknown")) {
     1693        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
     1694        return false;
     1695      }
     1696      return true;
     1697    }
     1698
     1699    if (code) {
     1700      psString query = pxDataGet("warptool_updateskyfile.sql");
     1701
     1702      if (!p_psDBRunQueryF(config->dbh, query, code, warp_id, skycell_id)) {
     1703        psError(PS_ERR_UNKNOWN, false, "database error");
     1704        return false;
     1705      }
     1706      psFree(query);
     1707      return true;
     1708    }
     1709
     1710    psError(PS_ERR_UNKNOWN, true, "one of -set_state or -code must be supplied");
     1711    return false;
     1712}
  • branches/cnb_branches/cnb_branch_20090215/ippTools/src/warptoolConfig.c

    r20973 r23239  
    348348    psMetadataAddStr(tofullskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL);
    349349
    350     // -toupdateskyfile
     350    // -updateskyfile
    351351    psMetadata *updateskyfileArgs = psMetadataAlloc();
    352     psMetadataAddS64(updateskyfileArgs, PS_LIST_TAIL, "-warp_id", 0,    "warptool ID to update", 0);
     352    psMetadataAddS64(updateskyfileArgs, PS_LIST_TAIL, "-warp_id",    0, "warptool ID to update", 0);
    353353    psMetadataAddStr(updateskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL);
    354     psMetadataAddS16(updateskyfileArgs, PS_LIST_TAIL, "-code",  0,      "new fault code", 0);
     354    psMetadataAddS16(updateskyfileArgs, PS_LIST_TAIL, "-code",       0, "set fault code", 0);
     355    psMetadataAddStr(updateskyfileArgs, PS_LIST_TAIL, "-set_state",  0, "set state", NULL);
    355356
    356357    psFree(now);
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/gpc1/ppImage.config

    r23199 r23239  
    99OVERSCAN.STAT           STR     MEDIAN
    1010OVERSCAN.BOXCAR         S32     3
     11
     12# Normalization class
     13NORM.CLASS              STR     CHIP             # How to find the per-class normalizations
    1114
    1215OLDDARK                 BOOL    FALSE
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-mef.mdc

    r23199 r23239  
    9898PPSUB.INPUT.MASK        INPUT    @FILES        FPA        MASK
    9999PPSUB.INPUT.VARIANCE    INPUT    @FILES        FPA        VARIANCE
     100PPSUB.INPUT.SOURCES     INPUT    @FILES        FPA        CMF
    100101PPSUB.REF               INPUT    @FILES        FPA        IMAGE
    101102PPSUB.REF.MASK          INPUT    @FILES        FPA        MASK
    102103PPSUB.REF.VARIANCE      INPUT    @FILES        FPA        VARIANCE
    103 PPSUB.SOURCES           INPUT    @FILES        FPA        CMF
     104PPSUB.REF.SOURCES       INPUT    @FILES        FPA        CMF
    104105
    105106## files used by ppstack
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-simple.mdc

    r23199 r23239  
    6161PPSUB.INPUT.MASK        INPUT    @FILES        FPA        MASK
    6262PPSUB.INPUT.VARIANCE    INPUT    @FILES        FPA        VARIANCE
     63PPSUB.INPUT.SOURCES     INPUT    @FILES        FPA        CMF
    6364PPSUB.REF               INPUT    @FILES        FPA        IMAGE
    6465PPSUB.REF.MASK          INPUT    @FILES        FPA        MASK
    6566PPSUB.REF.VARIANCE      INPUT    @FILES        FPA        VARIANCE
    66 PPSUB.SOURCES           INPUT    @FILES        FPA        CMF
     67PPSUB.REF.SOURCES       INPUT    @FILES        FPA        CMF
    6768
    6869## files used by ppstack
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-split.mdc

    r23199 r23239  
    7373PPSUB.INPUT.MASK        INPUT    @FILES        FPA        MASK
    7474PPSUB.INPUT.VARIANCE    INPUT    @FILES        FPA        VARIANCE
     75PPSUB.INPUT.SOURCES     INPUT    @FILES        FPA        CMF
    7576PPSUB.REF               INPUT    @FILES        FPA        IMAGE
    7677PPSUB.REF.MASK          INPUT    @FILES        FPA        MASK
    7778PPSUB.REF.VARIANCE      INPUT    @FILES        FPA        VARIANCE
    78 PPSUB.SOURCES           INPUT    @FILES        FPA        CMF
     79PPSUB.REF.SOURCES       INPUT    @FILES        FPA        CMF
    7980
    8081## files used by ppstack
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/ppImage.config

    r23199 r23239  
    4040NONLIN.SOURCE           STR     CHIP.NAME       # How to determine the source
    4141NONLIN.DATA             STR     nonlin.dat      # Filename for lookup table
     42
     43# Normalization class
     44NORM.CLASS              STR     FPA             # How to find the per-class normalizations
    4245
    4346OLDDARK         BOOL    FALSE           # Use old-style darks?
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/ppStack.config

    r21475 r23239  
    3232
    3333ZP.RADIUS       F32     1.0             # Radius (pixels) for matching sources
    34 ZP.ITER         S32     1000            # Maximum iterations for zero point
     34ZP.ITER.1       S32     5               # Iterations for zero point; pass 1
     35ZP.ITER.2       S32     1000            # Iterations for zero point; pass 2
    3536ZP.TOL          F32     1.0e-6          # Tolerance for zero point iterations
    3637ZP.TRANS.ITER   S32     2               # Iterations for transparency determination
    3738ZP.TRANS.REJ    F32     3.0             # Rejection threshold for transparency determination
    3839ZP.TRANS.THRESH F32     1.0             # Threshold for transparency determination
    39 ZP.STAR.REJ     F32     3.0             # Rejection threshold for stars
     40ZP.STAR.REJ.1   F32     20.0            # Rejection threshold for stars; pass 1
     41ZP.STAR.REJ.2   F32     3.0             # Rejection threshold for stars; pass 2
    4042ZP.STAR.LIMIT   F32     1.0e-2          # Limit on star rejection fraction for successful iteration
    41 ZP.STAR.SYS     F32     0.05            # Estimated systematic error
     43ZP.STAR.SYS.1   F32     0.10            # Estimated systematic error; pass 1
     44ZP.STAR.SYS.2   F32     0.05            # Estimated systematic error; pass 2
     45ZP.MATCH        F32     0.3             # Fraction of images to match for good star
    4246ZP.AIRMASS      METADATA                # Airmass terms by filter
    4347        g       F32     0.0
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/ppSub.config

    r21370 r23239  
    55SPATIAL.ORDER   S32     0               # Spatial polynomial order
    66REGION.SIZE     F32     0               # Iso-kernel region size (pixels)
     7SOURCE.RADIUS   F32     3.0             # Source matching radius (pixels)
    78STAMP.SPACING   F32     200             # Typical spacing between stamps (pixels)
    89STAMP.FOOTPRINT S32     20              # Size of stamps (pixels)
  • branches/cnb_branches/cnb_branch_20090215/ppArith/src/Makefile.am

    r23199 r23239  
    11bin_PROGRAMS = ppArith
    22
    3 PPARITH_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
    4 PPARITH_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
    5 PPARITH_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     3# PPARITH_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4# PPARITH_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
     5# PPARITH_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     6#
     7# # Force recompilation of ppArithVersion.c, since it gets the version information
     8# ppArithVersion.c: FORCE
     9#       touch ppArith.c
     10# FORCE: ;
    611
    7 # Force recompilation of ppArithVersion.c, since it gets the version information
    8 ppArithVersion.c: FORCE
    9         touch ppArith.c
    10 FORCE: ;
    11 
    12 ppArith_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPARITH_CFLAGS) -DPPARITH_VERSION=\"$(PPARITH_VERSION)\" -DPPARITH_BRANCH=\"$(PPARITH_BRANCH)\" -DPPARITH_SOURCE=\"$(PPARITH_SOURCE)\"
     12ppArith_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPARITH_CFLAGS) -DPPARITH_VERSION=$(SVN_VERSION) -DPPARITH_BRANCH=$(SVN_BRANCH) -DPPARITH_SOURCE=$(SVN_SOURCE)
    1313ppArith_LDFLAGS  = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PPSTATS_LIBS)   $(PSPHOT_LIBS)   $(PPARITH_LIBS)
    1414
  • branches/cnb_branches/cnb_branch_20090215/ppArith/src/ppArithVersion.c

    r23199 r23239  
    2222#include "ppArith.h"
    2323
    24 psString ppArithVersion(void)
    25 {
    2624#ifndef PPARITH_VERSION
    2725#error "PPARITH_VERSION is not set"
    … …  
    3028#error "PPARITH_BRANCH is not set"
    3129#endif
    32     return psStringCopy(PPARITH_BRANCH "@" PPARITH_VERSION);
     30#ifndef PPARITH_SOURCE
     31#error "PPARITH_SOURCE is not set"
     32#endif
     33
     34#define xstr(s) str(s)
     35#define str(s) #s
     36
     37psString ppArithVersion(void)
     38{
     39    char *value = NULL;
     40    psStringAppend(&value, "%s@%s", xstr(PPARITH_BRANCH), xstr(PPARITH_VERSION));
     41    return value;
    3342}
    3443
    3544psString ppArithSource(void)
    3645{
    37 #ifndef PPARITH_SOURCE
    38 #error "PPARITH_SOURCE is not set"
    39 #endif
    40     return psStringCopy(PPARITH_SOURCE);
     46    return psStringCopy(xstr(PPARITH_SOURCE));
    4147}
    4248
  • branches/cnb_branches/cnb_branch_20090215/ppImage/src/Makefile.am

    r23199 r23239  
    44        ppImage.h
    55
    6 PPIMAGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
    7 PPIMAGE_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
    8 PPIMAGE_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     6#PPIMAGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     7#PPIMAGE_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
     8#PPIMAGE_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
    99
    1010# Force recompilation of ppImageVersion.c, since it gets the version information
    11 ppImageVersion.c: FORCE
    12         touch ppImageVersion.c
    13 FORCE: ;
     11# ppImageVersion.c: FORCE
     12#       touch ppImageVersion.c
     13# FORCE: ;
    1414
    15 ppImage_CFLAGS = $(PPIMAGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSASTRO_CFLAGS) $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPIMAGE_VERSION=\"$(PPIMAGE_VERSION)\" -DPPIMAGE_BRANCH=\"$(PPIMAGE_BRANCH)\" -DPPIMAGE_SOURCE=\"$(PPIMAGE_SOURCE)\"
     15ppImage_CFLAGS = $(PPIMAGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSASTRO_CFLAGS) $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPIMAGE_VERSION=$(SVN_VERSION) -DPPIMAGE_BRANCH=$(SVN_BRANCH) -DPPIMAGE_SOURCE=$(SVN_SOURCE)
    1616ppImage_LDFLAGS = $(PPIMAGE_LIBS) $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    1717ppImage_SOURCES = \
  • branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImage.h

    r23199 r23239  
    8686    int remnanceSize;                   // Size for remnance detection
    8787    float remnanceThresh;               // Threshold for remnance detection
     88
     89    char *normClass;                    // class to use for per-class normalization
    8890} ppImageOptions;
    8991
  • branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageArguments.c

    r21536 r23239  
    1414    fprintf(stderr, "\t-chip CHIPNUM: Only process this chip number.\n");
    1515    fprintf(stderr, "\t-norm VALUE: Divide through by this value when done.\n");
     16    fprintf(stderr, "\t-normlist file.mdc: normalizations by class_id.\n");
    1617    fprintf(stderr, "\n");
    1718    fprintf(stderr, "Input options (single file / file list):\n");
    … …  
    128129    }
    129130
    130     // Optional normalisation factor
     131    // Optional normalization factor
    131132    if ((argnum = psArgumentGet(argc, argv, "-norm"))) {
    132133        psArgumentRemove(argnum, &argc, argv);
    133134        float norm = atof(argv[argnum]);
    134         psMetadataAddF32(config->arguments, PS_LIST_TAIL, "NORMALISATION", 0,
     135        psMetadataAddF32(config->arguments, PS_LIST_TAIL, "NORMALIZATION", 0,
    135136                         "Normalisation to apply", norm);
     137        psArgumentRemove(argnum, &argc, argv);
     138    }
     139
     140    // Optional per-class normalization table
     141    if ((argnum = psArgumentGet(argc, argv, "-normlist"))) {
     142        psArgumentRemove(argnum, &argc, argv);
     143
     144        unsigned int nFail = 0;
     145        psMetadata *normlist = psMetadataConfigRead (NULL, &nFail, argv[argnum], false);
     146        // XXX allow this file to be in nebulous?
     147
     148        psMetadataAddMetadata(config->arguments, PS_LIST_TAIL, "NORMALIZATION.TABLE", 0, "Normalization to apply", normlist);
     149        psFree (normlist);
    136150        psArgumentRemove(argnum, &argc, argv);
    137151    }
  • branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageDetrendReadout.c

    r21364 r23239  
    5454        if (!pmBiasSubtract(input, options->overscan, bias, oldDark, view)) {
    5555            psError(PS_ERR_UNKNOWN, false, "Unable to subtract bias.");
     56            psFree(detview);
    5657            return false;
    5758        }
    … …  
    6768        if (!pmDarkApply(input, dark, options->maskValue)) {
    6869            psError(PS_ERR_UNKNOWN, false, "Unable to subtract dark.");
     70            psFree(detview);
    6971            return false;
    7072        }
    … …  
    7577                        options->remnanceSize, options->remnanceThresh)) {
    7678            psError(PS_ERR_UNKNOWN, false, "Unable to mask remnance.");
     79            psFree(detview);
    7780            return false;
    7881        }
    … …  
    8386        pmReadout *shutter = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.SHUTTER");
    8487        if (!pmShutterCorrectionApply(input, shutter, pmConfigMaskGet("FLAT", config))) {
     88            psFree(detview);
    8589            return false;
    8690        }
    … …  
    9195        pmReadout *flat = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.FLAT");
    9296        if (!pmFlatField(input, flat, options->flatMask)) {
     97            psFree(detview);
    9398            return false;
    9499        }
    95100    }
    96101
    97     // Normalisation by a (known) constant
     102    // Normalization by a single (known) constant
    98103    bool mdok;                          // Status of MD lookup
    99     float norm = psMetadataLookupF32(&mdok, config->arguments, "NORMALISATION");
     104    float norm = psMetadataLookupF32(&mdok, config->arguments, "NORMALIZATION");
    100105    if (mdok && isfinite(norm) && norm != 1.0) {
    101106        pmHDU *hdu = pmHDUFromReadout(input); // HDU of interest
    … …  
    108113    }
    109114
     115# if (1)
     116    // Normalization by per-class values
     117    psMetadata *normlist = psMetadataLookupMetadata(&mdok, config->arguments, "NORMALIZATION.TABLE");
     118    if (normlist) {
     119        pmFPAfile *inputFile = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.INPUT");
     120
     121        // get the menu of class IDs
     122        psMetadata *menu = psMetadataLookupMetadata(&mdok, inputFile->camera, "CLASSID");
     123        if (!menu) {
     124            psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration");
     125            psFree(detview);
     126            return false;
     127        }
     128        // get the rule for class_id for the desired class
     129        const char *rule = psMetadataLookupStr(&mdok, menu, options->normClass);
     130        if (!rule) {
     131            psError(PS_ERR_IO, false, "Unable to find NORM.CLASS value %s in CLASSID in camera configuration", options->normClass);
     132            psFree(detview);
     133            return false;
     134        }
     135        // get the class_id from the rule
     136        char *classID = pmFPAfileNameFromRule(rule, inputFile, view);
     137        if (!classID) {
     138            psError(PS_ERR_IO, false, "error converting CLASSID rule %s to name\n", rule);
     139            psFree(detview);
     140            return false;
     141        }
     142
     143        // get normalization from the class_id
     144        float norm = psMetadataLookupF32 (&mdok, normlist, classID);
     145
     146        pmHDU *hdu = pmHDUFromReadout(input); // HDU of interest
     147        psString comment = NULL;        // Comment to add
     148        psStringAppend(&comment, "Normalization: %f", norm);
     149        psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, comment, "");
     150        psFree(comment);
     151
     152        // apply the normalization
     153        psBinaryOp(input->image, input->image, "*", psScalarAlloc(norm, PS_TYPE_F32));
     154
     155        psFree (classID);
     156    }
     157# endif
     158
    110159    if (options->doFringe) {
    111160        pmCell *fringe = pmFPAfileThisCell(config->files, detview, "PPIMAGE.FRINGE");
    112161        if (!ppImageDetrendFringeMeasure(input, fringe, false, options)) {
     162            psFree(detview);
    113163            return false;
    114164        }
  • branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageOptions.c

    r21364 r23239  
    8181    options->remnanceThresh  = 25.0;    // Threshold for remnance detection
    8282
     83    // per-class normalization source
     84    options->normClass       = NULL;    // per-class normalizations refer to this class
     85
    8386    return options;
    8487}
    … …  
    278281    options->remnanceThresh = psMetadataLookupS32(NULL, recipe, "REMNANCE.THRESH");
    279282
     283    // per-class normalization source (just a reference; don't free)
     284    options->normClass = psMetadataLookupStr(NULL, recipe, "NORM.CLASS");
     285
    280286    return options;
    281287}
  • branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageVersion.c

    r23199 r23239  
    55#include "ppImage.h"
    66
    7 psString ppImageVersion(void)
    8 {
    97#ifndef PPIMAGE_VERSION
    108#error "PPIMAGE_VERSION is not set"
    … …  
    1311#error "PPIMAGE_BRANCH is not set"
    1412#endif
    15     return psStringCopy(PPIMAGE_BRANCH "@" PPIMAGE_VERSION);
     13#ifndef PPIMAGE_SOURCE
     14#error "PPIMAGE_SOURCE is not set"
     15#endif
     16
     17#define xstr(s) str(s)
     18#define str(s) #s
     19
     20psString ppImageVersion(void)
     21{
     22    char *value = NULL;
     23    psStringAppend(&value, "%s@%s", xstr(PPIMAGE_BRANCH), xstr(PPIMAGE_VERSION));
     24    return value;
    1625}
    1726
    1827psString ppImageSource(void)
    1928{
    20 #ifndef PPIMAGE_SOURCE
    21 #error "PPIMAGE_SOURCE is not set"
    22 #endif
    23     return psStringCopy(PPIMAGE_SOURCE);
     29    return psStringCopy (xstr(PPIMAGE_SOURCE));
    2430}
    2531
    … …  
    2733{
    2834    psString version = ppImageVersion();  // Version, to return
    29     psString source = ppImageSource();    // Source
     35    psString source = ppImageSource(); // Source
    3036
    3137    psStringPrepend(&version, "ppImage ");
  • branches/cnb_branches/cnb_branch_20090215/ppMerge/src/Makefile.am

    r23199 r23239  
    11bin_PROGRAMS = ppMerge
    22
    3 PPMERGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
    4 PPMERGE_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
    5 PPMERGE_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     3# PPMERGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4# PPMERGE_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
     5# PPMERGE_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     6#
     7# # Force recompilation of ppMergeVersion.c, since it gets the version information
     8# ppMergeVersion.c: FORCE
     9#       touch ppMergeVersion.c
     10# FORCE: ;
    611
    7 # Force recompilation of ppMergeVersion.c, since it gets the version information
    8 ppMergeVersion.c: FORCE
    9         touch ppMergeVersion.c
    10 FORCE: ;
    11 
    12 ppMerge_CFLAGS = $(PPMERGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPMERGE_VERSION=\"$(PPMERGE_VERSION)\" -DPPMERGE_BRANCH=\"$(PPMERGE_BRANCH)\" -DPPMERGE_SOURCE=\"$(PPMERGE_SOURCE)\"
     12ppMerge_CFLAGS = $(PPMERGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPMERGE_VERSION=$(SVN_VERSION) -DPPMERGE_BRANCH=$(SVN_BRANCH) -DPPMERGE_SOURCE=$(SVN_SOURCE)
    1313ppMerge_LDFLAGS = $(PPMERGE_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    1414
  • branches/cnb_branches/cnb_branch_20090215/ppMerge/src/ppMergeVersion.c

    r23199 r23239  
    2222#include "ppMergeVersion.h"
    2323
    24 psString ppMergeVersion(void)
    25 {
    2624#ifndef PPMERGE_VERSION
    2725#error "PPMERGE_VERSION is not set"
    … …  
    3028#error "PPMERGE_BRANCH is not set"
    3129#endif
    32     return psStringCopy(PPMERGE_BRANCH "@" PPMERGE_VERSION);
     30#ifndef PPMERGE_SOURCE
     31#error "PPMERGE_SOURCE is not set"
     32#endif
     33
     34#define xstr(s) str(s)
     35#define str(s) #s
     36
     37psString ppMergeVersion(void)
     38{
     39    char *value = NULL;
     40    psStringAppend(&value, "%s@%s", xstr(PPMERGE_BRANCH), xstr(PPMERGE_VERSION));
     41    return value;
    3342}
    3443
    3544psString ppMergeSource(void)
    3645{
    37 #ifndef PPMERGE_SOURCE
    38 #error "PPMERGE_SOURCE is not set"
    39 #endif
    40     return psStringCopy(PPMERGE_SOURCE);
     46    return psStringCopy(xstr(PPMERGE_SOURCE));
    4147}
    4248
  • branches/cnb_branches/cnb_branch_20090215/ppSim/src/Makefile.am

    r23199 r23239  
    11bin_PROGRAMS = ppSim ppSimSequence
    22
    3 PPSIM_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
    4 PPSIM_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
    5 PPSIM_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     3# PPSIM_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4# PPSIM_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
     5# PPSIM_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     6#
     7# # Force recompilation of ppSimVersion.c, since it gets the version information
     8# ppSimVersion.c: FORCE
     9#       touch ppSimVersion.c
     10# FORCE: ;
    611
    7 # Force recompilation of ppSimVersion.c, since it gets the version information
    8 ppSimVersion.c: FORCE
    9         touch ppSimVersion.c
    10 FORCE: ;
    11 
    12 ppSim_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS) -DPPSIM_VERSION=\"$(PPSIM_VERSION)\" -DPPSIM_BRANCH=\"$(PPSIM_BRANCH)\" -DPPSIM_SOURCE=\"$(PPSIM_SOURCE)\"
     12ppSim_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS) -DPPSIM_VERSION=$(SVN_VERSION) -DPPSIM_BRANCH=$(SVN_BRANCH) -DPPSIM_SOURCE=$(SVN_SOURCE)
    1313ppSim_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSPHOT_LIBS) $(PSASTRO_LIBS)
    1414ppSim_SOURCES = \
  • branches/cnb_branches/cnb_branch_20090215/ppSim/src/ppSimVersion.c

    r23199 r23239  
    11#include "ppSim.h"
    22
    3 
    4 psString ppSimVersion(void)
    5 {
    63#ifndef PPSIM_VERSION
    74#error "PPSIM_VERSION is not set"
    … …  
    107#error "PPSIM_BRANCH is not set"
    118#endif
    12     return psStringCopy(PPSIM_BRANCH "@" PPSIM_VERSION);
     9#ifndef PPSIM_SOURCE
     10#error "PPSIM_SOURCE is not set"
     11#endif
     12
     13#define xstr(s) str(s)
     14#define str(s) #s
     15
     16psString ppSimVersion(void)
     17{
     18    char *value = NULL;
     19    psStringAppend(&value, "%s@%s", xstr(PPSIM_BRANCH), xstr(PPSIM_VERSION));
     20    return value;
    1321}
    1422
    1523psString ppSimSource(void)
    1624{
    17 #ifndef PPSIM_SOURCE
    18 #error "PPSIM_SOURCE is not set"
    19 #endif
    20     return psStringCopy(PPSIM_SOURCE);
     25    return psStringCopy(xstr(PPSIM_SOURCE));
    2126}
    2227
  • branches/cnb_branches/cnb_branch_20090215/ppStack/src/Makefile.am

    r23199 r23239  
    11bin_PROGRAMS = ppStack
    22
    3 PPSTACK_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
    4 PPSTACK_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
    5 PPSTACK_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     3# PPSTACK_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4# PPSTACK_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
     5# PPSTACK_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     6#
     7# # Force recompilation of ppStackVersion.c, since it gets the version information
     8# ppStackVersion.c: FORCE
     9#       touch ppStackVersion.c
     10# FORCE: ;
    611
    7 # Force recompilation of ppStackVersion.c, since it gets the version information
    8 ppStackVersion.c: FORCE
    9         touch ppStackVersion.c
    10 FORCE: ;
    11 
    12 ppStack_CFLAGS  = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPSTATS_CFLAGS) $(PPSTACK_CFLAGS) -DPPSTACK_VERSION=\"$(PPSTACK_VERSION)\" -DPPSTACK_BRANCH=\"$(PPSTACK_BRANCH)\" -DPPSTACK_SOURCE=\"$(PPSTACK_SOURCE)\"
     12ppStack_CFLAGS  = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPSTATS_CFLAGS) $(PPSTACK_CFLAGS) -DPPSTACK_VERSION=$(SVN_VERSION) -DPPSTACK_BRANCH=$(SVN_BRANCH) -DPPSTACK_SOURCE=$(SVN_SOURCE)
    1313ppStack_LDFLAGS = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PSPHOT_LIBS)   $(PPSTATS_LIBS)   $(PPSTACK_LIBS)
    1414
  • branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackArguments.c

    r23199 r23239  
    168168                      "Play safe with small numbers of pixels to combine?", false);
    169169    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-radius", 0, "Radius (pixels) for matching sources", NAN);
    170     psMetadataAddS32(arguments, PS_LIST_TAIL, "-zp-iter", 0, "Maximum iterations for zero point", 0);
     170    psMetadataAddS32(arguments, PS_LIST_TAIL, "-zp-iter-1", 0, "Maximum iterations for zero point; pass 1", 0);
     171    psMetadataAddS32(arguments, PS_LIST_TAIL, "-zp-iter-2", 0, "Maximum iterations for zero point; pass 2", 0);
    171172    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-tol", 0, "Tolerance for zero point iterations", NAN);
    172173    psMetadataAddS32(arguments, PS_LIST_TAIL, "-zp-trans-iter", 0, "Iterations for transparency determination", 0);
    173174    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-trans-rej", 0, "Rejection threshold for transparency determination", NAN);
    174175    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-trans-thresh", 0, "Threshold for transparency determination", NAN);
    175     psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-rej", 0, "Rejection threshold for stars", NAN);
     176    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-rej-1", 0, "Rejection threshold for stars; pass 1", NAN);
     177    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-rej-2", 0, "Rejection threshold for stars; pass 2", NAN);
    176178    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-limit", 0, "Limit on star rejection fraction for successful iteration", NAN);
    177     psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-sys", 0, "Estimated systematic error", NAN);
     179    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-sys-1", 0, "Estimated systematic error; pass 1", NAN);
     180    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-sys-2", 0, "Estimated systematic error; pass 2", NAN);
    178181    psMetadataAddStr(arguments, PS_LIST_TAIL, "-temp-image", 0, "Suffix for temporary images", NULL);
    179182    psMetadataAddStr(arguments, PS_LIST_TAIL, "-temp-mask", 0, "Suffix for temporary masks", NULL);
    … …  
    242245
    243246    VALUE_ARG_RECIPE_FLOAT("-zp-radius",       "ZP.RADIUS",       F32);
    244     VALUE_ARG_RECIPE_INT("-zp-iter",           "ZP.ITER",         S32, 0);
     247    VALUE_ARG_RECIPE_INT("-zp-iter-1",         "ZP.ITER.1",       S32, 0);
     248    VALUE_ARG_RECIPE_INT("-zp-iter-2",         "ZP.ITER.2",       S32, 0);
    245249    VALUE_ARG_RECIPE_FLOAT("-zp-tol",          "ZP.TOL",          F32);
    246250    VALUE_ARG_RECIPE_INT("-zp-trans-iter",     "ZP.TRANS.ITER",   S32, 0);
    247251    VALUE_ARG_RECIPE_FLOAT("-zp-trans-rej",    "ZP.TRANS.REJ",    F32);
    248252    VALUE_ARG_RECIPE_FLOAT("-zp-trans-thresh", "ZP.TRANS.THRESH", F32);
    249     VALUE_ARG_RECIPE_FLOAT("-zp-star-rej",     "ZP.STAR.REJ",     F32);
     253    VALUE_ARG_RECIPE_FLOAT("-zp-star-rej-1",   "ZP.STAR.REJ.1",   F32);
     254    VALUE_ARG_RECIPE_FLOAT("-zp-star-rej-2",   "ZP.STAR.REJ.2",   F32);
    250255    VALUE_ARG_RECIPE_FLOAT("-zp-star-limit",   "ZP.STAR.LIMIT",   F32);
    251     VALUE_ARG_RECIPE_FLOAT("-zp-star-sys",     "ZP.STAR.SYS",     F32);
     256    VALUE_ARG_RECIPE_FLOAT("-zp-star-sys-1",   "ZP.STAR.SYS.1",   F32);
     257    VALUE_ARG_RECIPE_FLOAT("-zp-star-sys-2",   "ZP.STAR.SYS.2",   F32);
    252258
    253259    VALUE_ARG_RECIPE_INT("-psf-instances", "PSF.INSTANCES", S32, 0);
  • branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackSources.c

    r23199 r23239  
    8181
    8282    float radius = psMetadataLookupF32(NULL, recipe, "ZP.RADIUS"); // Radius (pixels) for matching sources
    83     int iter = psMetadataLookupS32(NULL, recipe, "ZP.ITER"); // Maximum iterations
     83    int iter1 = psMetadataLookupS32(NULL, recipe, "ZP.ITER.1"); // Maximum iterations for pass 1
     84    int iter2 = psMetadataLookupS32(NULL, recipe, "ZP.ITER.2"); // Maximum iterations for pass 2
    8485    float tol = psMetadataLookupF32(NULL, recipe, "ZP.TOL"); // Tolerance for zero point iterations
    8586    int transIter = psMetadataLookupS32(NULL, recipe, "ZP.TRANS.ITER"); // Iterations for transparency
    8687    float transRej = psMetadataLookupF32(NULL, recipe, "ZP.TRANS.REJ");// Rejection threshold for transparency
    8788    float transThresh = psMetadataLookupF32(NULL, recipe, "ZP.TRANS.THRESH"); // Threshold for transparency
    88     float starRej = psMetadataLookupF32(NULL, recipe, "ZP.STAR.REJ"); // Rejection threshold for stars
     89
     90    float starRej1 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.REJ.1"); // Rejection threshold for stars
     91    float starSys1 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.SYS.1"); // Estimated systematic error
     92    float starRej2 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.REJ.2"); // Rejection threshold for stars
     93    float starSys2 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.SYS.2"); // Estimated systematic error
     94
    8995    float starLimit = psMetadataLookupF32(NULL, recipe, "ZP.STAR.LIMIT"); // Limit on star rejection fraction
    90     float starSys = psMetadataLookupF32(NULL, recipe, "ZP.STAR.SYS"); // Estimated systematic error
     96
     97    float fracMatch = psMetadataLookupF32(NULL, recipe, "ZP.MATCH"); // Fraction of images to match for star
    9198
    9299    psMetadata *airmassZP = psMetadataLookupMetadata(NULL, recipe, "ZP.AIRMASS"); // Airmass terms
    … …  
    110117        pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout
    111118        pmPSF *psf = psMetadataLookupPtr(NULL, config->arguments, "PSF.TARGET"); // PSF for fake image
    112         pmReadoutFakeFromSources(fake, FAKE_COLS, FAKE_ROWS, sourceLists->data[i], NULL, NULL, psf, 5, 0, false, true);
     119        pmReadoutFakeFromSources(fake, FAKE_COLS, FAKE_ROWS, sourceLists->data[i],
     120                                 NULL, NULL, psf, 5, 0, false, true);
    113121        psString name = NULL;
    114122        psStringAppend(&name, "start_%03d.fits", i);
    … …  
    153161    }
    154162
    155     psArray *matches = pmSourceMatchSources(sourceLists, radius); // List of matches
     163    psArray *matches = pmSourceMatchSources(sourceLists, radius, true); // List of matches
    156164    if (!matches) {
    157165        psError(PS_ERR_UNKNOWN, false, "Unable to match sources");
    … …  
    164172#endif
    165173
    166     psVector *trans = pmSourceMatchRelphot(matches, zp, iter, tol, starLimit, transIter, transRej,
    167                                            transThresh, starRej, starSys); // Transparencies for each image
     174    psVector *trans = pmSourceMatchRelphot(matches, zp, tol, iter1, starRej1, starSys1,
     175                                           iter2, starRej2, starSys2, starLimit,
     176                                           transIter, transRej, transThresh); // Transparencies for each image
    168177    if (!trans) {
    169178        psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies");
    … …  
    184193    // XXX this is a really poor output location; clean up the pmFPAfiles used in ppStack
    185194    pmCell *sourcesCell = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT");
    186     psArray *sourcesBest = psArrayAllocEmpty (100);
    187 
    188     // XXX something of a hack: require at 2 detections or 1/2 of the max possible
    189     int minMatches = PS_MAX (2, 0.5*num);
     195    psArray *sourcesBest = psArrayAllocEmpty(matches->n);
     196
     197    // XXX something of a hack: require at least 2 detections or the nominated fraction of the max possible
     198    int minMatches = PS_MAX(2, fracMatch * num);// Minimum number of matches required
    190199    for (int i = 0; i < matches->n; i++) {
    191200        pmSourceMatch *match = matches->data[i]; // Match of interest
    192         if (match->num < minMatches) continue;
     201        if (match->num < minMatches) {
     202            continue;
     203        }
    193204
    194205        // We need to grab a single instance of this source: just take the first available
    195         int nImage = match->image->data.S32[0];
    196         int nIndex = match->index->data.S32[0];
    197         psArray *sources = sourceLists->data[nImage];
    198         pmSource *source = sources->data[nIndex];
    199 
    200         // stick this sample source on sourcesBest
    201         psArrayAdd (sourcesBest, 100, source);
    202     }
    203     psMetadataAdd (sourcesCell->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE, "psphot sources", sourcesBest);
    204     psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis\n", sourcesBest->n);
    205     psFree (sourcesBest);
     206        int image = match->image->data.S32[0]; // Index of image
     207        int index = match->index->data.S32[0]; // Index of source within image
     208        psArray *sources = sourceLists->data[image]; // Sources for image
     209        pmSource *source = sources->data[index]; // Source of interest
     210
     211        psArrayAdd(sourcesBest, sourcesBest->n, source);
     212    }
     213    psMetadataAdd(sourcesCell->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE,
     214                  "psphot sources", sourcesBest);
     215    psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis", sourcesBest->n);
     216    psFree(sourcesBest);
    206217
    207218    psFree(matches);
  • branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackVersion.c

    r23199 r23239  
    1111#include "ppStack.h"
    1212
    13 psString ppStackVersion(void)
    14 {
    1513#ifndef PPSTACK_VERSION
    1614#error "PPSTACK_VERSION is not set"
    … …  
    1917#error "PPSTACK_BRANCH is not set"
    2018#endif
    21     return psStringCopy(PPSTACK_BRANCH "@" PPSTACK_VERSION);
     19#ifndef PPSTACK_SOURCE
     20#error "PPSTACK_SOURCE is not set"
     21#endif
     22
     23#define xstr(s) str(s)
     24#define str(s) #s
     25
     26psString ppStackVersion(void)
     27{
     28    char *value = NULL;
     29    psStringAppend(&value, "%s@%s", xstr(PPSTACK_BRANCH), xstr(PPSTACK_VERSION));
     30    return value;
    2231}
    2332
    2433psString ppStackSource(void)
    2534{
    26 #ifndef PPSTACK_SOURCE
    27 #error "PPSTACK_SOURCE is not set"
    28 #endif
    29     return psStringCopy(PPSTACK_SOURCE);
     35    return psStringCopy(xstr(PPSTACK_SOURCE));
    3036}
    3137
  • branches/cnb_branches/cnb_branch_20090215/ppStats/src/Makefile.am

    r23199 r23239  
    11lib_LTLIBRARIES = libppStats.la
    22
    3 PPSTATS_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
    4 PPSTATS_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
    5 PPSTATS_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     3# PPSTATS_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4# PPSTATS_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
     5# PPSTATS_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     6#
     7# # Force recompilation of ppStatsVersion.c, since it gets the version information
     8# ppStatsVersion.c: FORCE
     9#       touch ppStatsVersion.c
     10# FORCE: ;
    611
    7 # Force recompilation of ppStatsVersion.c, since it gets the version information
    8 ppStatsVersion.c: FORCE
    9         touch ppStatsVersion.c
    10 FORCE: ;
    11 
    12 libppStats_la_CFLAGS = $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPSTATS_VERSION=\"$(PPSTATS_VERSION)\" -DPPSTATS_BRANCH=\"$(PPSTATS_BRANCH)\" -DPPSTATS_SOURCE=\"$(PPSTATS_SOURCE)\"
     12libppStats_la_CFLAGS = $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPSTATS_VERSION=$(SVN_VERSION) -DPPSTATS_BRANCH=$(SVN_BRANCH) -DPPSTATS_SOURCE=$(SVN_SOURCE)
    1313libppStats_la_LDFLAGS = $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    1414
  • branches/cnb_branches/cnb_branch_20090215/ppStats/src/ppStatsVersion.c

    r23199 r23239  
    11#include "ppStatsInternal.h"
    22
    3 psString ppStatsVersion(void)
    4 {
    53#ifndef PPSTATS_VERSION
    64#error "PPSTATS_VERSION is not set"
    … …  
    97#error "PPSTATS_BRANCH is not set"
    108#endif
    11     return psStringCopy(PPSTATS_BRANCH "@" PPSTATS_VERSION);
     9#ifndef PPSTATS_SOURCE
     10#error "PPSTATS_SOURCE is not set"
     11#endif
     12
     13#define xstr(s) str(s)
     14#define str(s) #s
     15
     16psString ppStatsVersion(void)
     17{
     18    char *value = NULL;
     19    psStringAppend(&value, "%s@%s", xstr(PPSTATS_BRANCH), xstr(PPSTATS_VERSION));
     20    return value;
    1221}
    1322
    1423psString ppStatsSource(void)
    1524{
    16 #ifndef PPSTATS_SOURCE
    17 #error "PPSTATS_SOURCE is not set"
    18 #endif
    19     return psStringCopy(PPSTATS_SOURCE);
     25    return psStringCopy(xstr(PPSTATS_SOURCE));
    2026}
    2127
  • branches/cnb_branches/cnb_branch_20090215/ppSub/src/Makefile.am

    r23199 r23239  
    11bin_PROGRAMS = ppSub ppSubKernel
    22
    3 PPSUB_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
    4 PPSUB_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
    5 PPSUB_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     3# PPSUB_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4# PPSUB_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
     5# PPSUB_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     6#
     7# # Force recompilation of ppSubVersion.c, since it gets the version information
     8# ppSubVersion.c: FORCE
     9#       touch ppSubVersion.c
     10# FORCE: ;
    611
    7 # Force recompilation of ppSubVersion.c, since it gets the version information
    8 ppSubVersion.c: FORCE
    9         touch ppSubVersion.c
    10 FORCE: ;
    11 
    12 ppSub_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPSUB_CFLAGS) -DPPSUB_VERSION=\"$(PPSUB_VERSION)\" -DPPSUB_BRANCH=\"$(PPSUB_BRANCH)\" -DPPSUB_SOURCE=\"$(PPSUB_SOURCE)\"
     12ppSub_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPSUB_CFLAGS) -DPPSUB_VERSION=$(SVN_VERSION) -DPPSUB_BRANCH=$(SVN_BRANCH) -DPPSUB_SOURCE=$(SVN_SOURCE)
    1313ppSub_LDFLAGS  = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PPSTATS_LIBS)   $(PSPHOT_LIBS)   $(PPSUB_LIBS)
    1414
  • branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubArguments.c

    r23199 r23239  
    3030    fprintf(stderr, "\nPan-STARRS PSF-matched image subtraction\n\n");
    3131    fprintf(stderr, "Usage: %s INPUT.fits REFERENCE.fits OUTPUT_ROOT \n"
    32             "\t[-psf REFERENCE.psf.fits] [-sources REFERENCE.cmf]\n\n"
     32            "\t[-psf REFERENCE.psf.fits]\n\n"
    3333            "This subtracts the convolved REFERENCE from the INPUT, by default.\n",
    3434            program);
    … …  
    201201
    202202
    203     pmConfigFileSetsMD(config->arguments, &argc, argv, "PPSUB.SOURCES", "-sources", NULL);
    204 
    205203    psMetadata *arguments = config->arguments; // Command-line arguments
    206204    psMetadataAddStr(arguments, PS_LIST_TAIL, "-inmask", 0, "Input mask image", NULL);
    207205    psMetadataAddStr(arguments, PS_LIST_TAIL, "-invariance", 0, "Input variance image", NULL);
     206    psMetadataAddStr(arguments, PS_LIST_TAIL, "-insources", 0, "Input source list", NULL);
    208207    psMetadataAddStr(arguments, PS_LIST_TAIL, "-refmask", 0, "Reference mask image", NULL);
    209208    psMetadataAddStr(arguments, PS_LIST_TAIL, "-refvariance", 0, "Reference variance image", NULL);
     209    psMetadataAddStr(arguments, PS_LIST_TAIL, "-refsources", 0, "Reference source list", NULL);
    210210    psMetadataAddStr(arguments, PS_LIST_TAIL, "-stats", 0, "Statistics file", NULL);
    211211    psMetadataAddF32(arguments, PS_LIST_TAIL, "-region", 0, "Size of iso-kernel region", NAN);
    … …  
    224224    psMetadataAddF32(arguments, PS_LIST_TAIL, "-spacing", 0, "Typical stamp spacing (pixels)", NAN);
    225225    psMetadataAddS32(arguments, PS_LIST_TAIL, "-footprint", 0, "Stamp footprint half-size (pixels)", -1);
     226    psMetadataAddF32(arguments, PS_LIST_TAIL, "-source-radius", 0, "Source matching radius (pixels)", NAN);
    226227    psMetadataAddS32(arguments, PS_LIST_TAIL, "-stride", 0, "Size of convolution patches (pixels)", -1);
    227228    psMetadataAddF32(arguments, PS_LIST_TAIL, "-threshold", 0, "Minimum threshold for stamps (ADU)", NAN);
    … …  
    268269        fileList("INPUT.VARIANCE", inVariance, "Name of the input variance image", config);
    269270    }
     271    const char *inSources = psMetadataLookupStr(NULL, arguments, "-insources"); // Name of input source list
     272    if (inSources && strlen(inSources) > 0) {
     273        fileList("INPUT.SOURCES", inSources, "Name of the input source list", config);
     274    }
    270275
    271276    const char *refMask = psMetadataLookupStr(NULL, arguments, "-refmask"); // Name of reference mask
    … …  
    276281    if (refVariance && strlen(refVariance) > 0) {
    277282        fileList("REF.VARIANCE", refVariance, "Name of the reference variance image", config);
     283    }
     284    const char *refSources = psMetadataLookupStr(NULL, arguments, "-refsources"); // Name of ref source list
     285    if (refSources && strlen(refSources) > 0) {
     286        fileList("REF.SOURCES", refSources, "Name of the reference source list", config);
    278287    }
    279288
    … …  
    300309    }
    301310
    302     VALUE_ARG_RECIPE_FLOAT("-region",     "REGION.SIZE",     F32);
    303     VALUE_ARG_RECIPE_INT("-size",         "KERNEL.SIZE",     S32, 0);
    304     VALUE_ARG_RECIPE_INT("-order",        "SPATIAL.ORDER",   S32, -1);
    305     VALUE_ARG_RECIPE_FLOAT("-spacing",    "STAMP.SPACING",   F32);
    306     VALUE_ARG_RECIPE_INT("-rings-order",  "RINGS.ORDER",     S32, -1);
    307     VALUE_ARG_RECIPE_INT("-inner",        "INNER",           S32, -1);
    308     VALUE_ARG_RECIPE_INT("-spam-binning", "SPAM.BINNING",    S32, 0);
    309     VALUE_ARG_RECIPE_INT("-footprint",    "STAMP.FOOTPRINT", S32, -1);
    310     VALUE_ARG_RECIPE_INT("-stride",       "STRIDE",          S32, -1);
    311     VALUE_ARG_RECIPE_FLOAT("-threshold",  "STAMP.THRESHOLD", F32);
    312     VALUE_ARG_RECIPE_INT("-iter",         "ITER",            S32, -1);
    313     VALUE_ARG_RECIPE_FLOAT("-rej",        "REJ",             F32);
    314     VALUE_ARG_RECIPE_FLOAT("-sys",        "SYS",             F32);
    315     VALUE_ARG_RECIPE_FLOAT("-badfrac",    "BADFRAC",         F32);
    316     VALUE_ARG_RECIPE_FLOAT("-penalty",    "PENALTY",         F32);
    317     VALUE_ARG_RECIPE_FLOAT("-poor-frac",  "POOR.FRACTION",   F32);
    318     VALUE_ARG_RECIPE_INT("-bin1",         "BIN1",            S32, 0);
    319     VALUE_ARG_RECIPE_INT("-bin2",         "BIN2",            S32, 0);
     311    VALUE_ARG_RECIPE_FLOAT("-region",        "REGION.SIZE",     F32);
     312    VALUE_ARG_RECIPE_INT("-size",            "KERNEL.SIZE",     S32, 0);
     313    VALUE_ARG_RECIPE_INT("-order",           "SPATIAL.ORDER",   S32, -1);
     314    VALUE_ARG_RECIPE_FLOAT("-spacing",       "STAMP.SPACING",   F32);
     315    VALUE_ARG_RECIPE_INT("-rings-order",     "RINGS.ORDER",     S32, -1);
     316    VALUE_ARG_RECIPE_INT("-inner",           "INNER",           S32, -1);
     317    VALUE_ARG_RECIPE_INT("-spam-binning",    "SPAM.BINNING",    S32, 0);
     318    VALUE_ARG_RECIPE_INT("-footprint",       "STAMP.FOOTPRINT", S32, -1);
     319    VALUE_ARG_RECIPE_FLOAT("-source-radius", "SOURCE.RADIUS",   F32);
     320    VALUE_ARG_RECIPE_INT("-stride",          "STRIDE",          S32, -1);
     321    VALUE_ARG_RECIPE_FLOAT("-threshold",     "STAMP.THRESHOLD", F32);
     322    VALUE_ARG_RECIPE_INT("-iter",            "ITER",            S32, -1);
     323    VALUE_ARG_RECIPE_FLOAT("-rej",           "REJ",             F32);
     324    VALUE_ARG_RECIPE_FLOAT("-sys",           "SYS",             F32);
     325    VALUE_ARG_RECIPE_FLOAT("-badfrac",       "BADFRAC",         F32);
     326    VALUE_ARG_RECIPE_FLOAT("-penalty",       "PENALTY",         F32);
     327    VALUE_ARG_RECIPE_FLOAT("-poor-frac",     "POOR.FRACTION",   F32);
     328    VALUE_ARG_RECIPE_INT("-bin1",            "BIN1",            S32, 0);
     329    VALUE_ARG_RECIPE_INT("-bin2",            "BIN2",            S32, 0);
    320330
    321331    valueArgRecipeStr(arguments, recipe, "-mask-in",   "MASK.IN",  recipe);
  • branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubCamera.c

    r22419 r23239  
    4040    pmFPAfile *inputMask = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.MASK", "INPUT.MASK");
    4141    if (!status) {
    42         psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.MASK");
     42        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.MASK");
    4343        return NULL;
    4444    }
    … …  
    5151    pmFPAfile *inputVariance = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE");
    5252    if (!status) {
    53         psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.VARIANCE");
     53        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.VARIANCE");
    5454        return NULL;
    5555    }
    5656    if (inputVariance && inputVariance->type != PM_FPA_FILE_VARIANCE) {
    5757        psError(PS_ERR_IO, true, "PPSUB.INPUT.VARIANCE is not of type VARIANCE");
     58        return false;
     59    }
     60
     61    // Input source list
     62    pmFPAfile *inputSources = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.SOURCES", "INPUT.SOURCES");
     63    if (!status) {
     64        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.SOURCES");
     65        return NULL;
     66    }
     67    if (inputSources && inputSources->type != PM_FPA_FILE_CMF) {
     68        psError(PS_ERR_IO, true, "PPSUB.INPUT.SOURCES is not of type CMF");
    5869        return false;
    5970    }
    … …  
    7485    pmFPAfile *refMask = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.MASK", "REF.MASK");
    7586    if (!status) {
    76         psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.MASK");
     87        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.MASK");
    7788        return NULL;
    7889    }
    … …  
    8596    pmFPAfile *refVariance = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.VARIANCE", "REF.VARIANCE");
    8697    if (!status) {
    87         psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.VARIANCE");
     98        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.VARIANCE");
    8899        return NULL;
    89100    }
    90101    if (refVariance && refVariance->type != PM_FPA_FILE_VARIANCE) {
    91102        psError(PS_ERR_IO, true, "PPSUB.REF.VARIANCE is not of type VARIANCE");
     103        return false;
     104    }
     105
     106    // Reference source list
     107    pmFPAfile *refSources = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.SOURCES", "REF.SOURCES");
     108    if (!status) {
     109        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.SOURCES");
     110        return NULL;
     111    }
     112    if (refSources && refSources->type != PM_FPA_FILE_CMF) {
     113        psError(PS_ERR_IO, true, "PPSUB.REF.SOURCES is not of type CMF");
    92114        return false;
    93115    }
    … …  
    241263    outKernels->save = true;
    242264
    243 #if 0
    244     if (!pmFPAAddSourceFromFormat(output->fpa, "Subtraction", output->format)) {
    245         psError(PS_ERR_UNKNOWN, false, "Unable to generate output FPA.");
    246         return false;
    247     }
    248 #endif
    249 
    250     pmFPAfile *sources = pmFPAfileDefineFromArgs(&status, config, "PPSUB.SOURCES", "PPSUB.SOURCES");
    251     if (!status) {
    252         psError(PS_ERR_IO, false, "Failed to load file definition PPSUB.SOURCES");
    253         return false;
    254     }
    255     if (sources && sources->type != PM_FPA_FILE_CMF) {
    256         psError(PS_ERR_IO, true, "PPSUB.SOURCES is not of type CMF");
    257         return false;
    258     }
    259265
    260266    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
  • branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubMakePSF.c

    r23197 r23239  
    8181    // Extract the loaded sources from the associated readout, and generate PSF
    8282    // Here, we assume the image is background-subtracted
    83     pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES");
    84     psArray *sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES");
     83    psArray *sources = psMetadataLookupPtr(&mdok, minuend->analysis, "PSPHOT.SOURCES");
    8584    if (!psphotReadoutFindPSF(config, view, sources)) {
    8685        psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on subtracted image.");
  • branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubMatchPSFs.c

    r22419 r23239  
    5050
    5151    // Sources in image, used for stamps: these must be loaded from previous analysis stages
    52     pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES"); // Readout with sources
    53     psArray *sources = NULL;            // Sources in image; used for stamps
    54     if (sourcesRO) {
    55         sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES");
     52    psArray *inSources = psMetadataLookupPtr(&mdok, inRO->analysis, "PSPHOT.SOURCES"); // Input source list
     53    psArray *refSources = psMetadataLookupPtr(&mdok, refRO->analysis, "PSPHOT.SOURCES"); // Ref source list
     54
     55    psArray *sources = NULL;            // Merged list of sources
     56    if (inSources && refSources) {
     57        float radius = psMetadataLookupF32(NULL, recipe, "SOURCE.RADIUS"); // Matching radius
     58        psArray *lists = psArrayAlloc(2); // Source lists
     59        lists->data[0] = psMemIncrRefCounter(inSources);
     60        lists->data[1] = psMemIncrRefCounter(refSources);
     61        sources = pmSourceMatchMerge(lists, radius);
     62        psFree(lists);
     63        if (!sources) {
     64            psError(PS_ERR_UNKNOWN, false, "Unable to merge source lists");
     65            return false;
     66        }
     67    } else if (inSources) {
     68        sources = psMemIncrRefCounter(inSources);
     69    } else if (refSources) {
     70        sources = psMemIncrRefCounter(refSources);
    5671    }
     72
     73    psMetadataAddArray(inConv->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE,
     74                       "Merged source list", sources);
     75    psMetadataAddArray(refConv->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE,
     76                       "Merged source list", sources);
     77    psFree(sources);                    // Drop reference
    5778
    5879    int footprint = psMetadataLookupS32(NULL, recipe, "STAMP.FOOTPRINT"); // Stamp half-size
    … …  
    129150
    130151    // XXX drop the pixels associated with inRO and refRO (now that we have inConv and refConf)
    131 
     152#ifdef TESTING
    132153    psphotSaveImage (NULL, inRO->image, "inRO.fits");
    133154    psphotSaveImage (NULL, refRO->image, "refRO.fits");
    134155    psphotSaveImage (NULL, inConv->image, "inConv.fits");
    135156    psphotSaveImage (NULL, refConv->image, "refConv.fits");
     157#endif
    136158
    137159    return true;
  • branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubVersion.c

    r23199 r23239  
    2323#include "ppSub.h"
    2424
    25 psString ppSubVersion(void)
    26 {
    2725#ifndef PPSUB_VERSION
    2826#error "PPSUB_VERSION is not set"
    … …  
    3129#error "PPSUB_BRANCH is not set"
    3230#endif
    33     return psStringCopy(PPSUB_BRANCH "@" PPSUB_VERSION);
     31#ifndef PPSUB_SOURCE
     32#error "PPSUB_SOURCE is not set"
     33#endif
     34
     35#define xstr(s) str(s)
     36#define str(s) #s
     37
     38psString ppSubVersion(void)
     39{
     40    char *value = NULL;
     41    psStringAppend(&value, "%s@%s", xstr(PPSUB_BRANCH), xstr(PPSUB_VERSION));
     42    return value;
    3443}
    3544
    3645psString ppSubSource(void)
    3746{
    38 #ifndef PPSUB_SOURCE
    39 #error "PPSUB_SOURCE is not set"
    40 #endif
    41     return psStringCopy(PPSUB_SOURCE);
     47    return psStringCopy(xstr(PPSUB_SOURCE));
    4248}
    4349
  • branches/cnb_branches/cnb_branch_20090215/psLib/src/imageops/psImageInterpolate.c

    r21290 r23239  
    133133    }
    134134
    135     float norm1 = 2.0 / PS_SQR(M_PI); // Normalisation for laczos
    136     float norm2 = M_PI * 4.0 / (float)size; // Normalisation for sinc function 1
    137     float norm3 = M_PI_2 * 4.0 / (float)size; // Normalisation for sinc function 2
     135    float norm1 = size / 2.0 / PS_SQR(M_PI); // Normalisation for laczos
     136    float norm2 = M_PI;                // Normalisation for sinc function 1
     137    float norm3 = M_PI * 2.0 / (float)size; // Normalisation for sinc function 2
    138138    float pos = - (size - 1)/2 - frac;  // Position of interest
    139139    for (int i = 0; i < size; i++, pos += 1.0) {
  • branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/Makefile.am

    r23199 r23239  
    33noinst_LTLIBRARIES = libpslibsys.la
    44
    5 PSLIB_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
    6 PSLIB_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
    7 PSLIB_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     5# PSLIB_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     6# PSLIB_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
     7# PSLIB_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
    88
    99# Force recompilation of psConfigure.c, since it gets the version information
    … …  
    1212FORCE: ;
    1313
    14 libpslibsys_la_CPPFLAGS = $(SRCINC) $(PSLIB_CFLAGS) $(CFITSIO_CFLAGS) -DPSLIB_VERSION=\"$(PSLIB_VERSION)\" -DPSLIB_BRANCH=\"$(PSLIB_BRANCH)\" -DPSLIB_SOURCE=\"$(PSLIB_SOURCE)\"
     14libpslibsys_la_CPPFLAGS = $(SRCINC) $(PSLIB_CFLAGS) $(CFITSIO_CFLAGS) -DPSLIB_VERSION=$(SVN_VERSION) -DPSLIB_BRANCH=$(SVN_BRANCH) -DPSLIB_SOURCE=$(SVN_SOURCE)
    1515libpslibsys_la_SOURCES = \
    1616        psAbort.c \
  • branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/psConfigure.c

    r23199 r23239  
    4747static FILE *memCheckFile = NULL;       // File to which to write results of mem check
    4848
    49 
    50 psString psLibVersion(void)
    51 {
    5249#ifndef PSLIB_VERSION
    5350#error "PSLIB_VERSION is not set"
    … …  
    5653#error "PSLIB_BRANCH is not set"
    5754#endif
    58     return psStringCopy(PSLIB_BRANCH "@" PSLIB_VERSION);
     55#ifndef PSLIB_SOURCE
     56#error "PSLIB_SOURCE is not set"
     57#endif
     58
     59#define xstr(s) str(s)
     60#define str(s) #s
     61
     62psString psLibVersion(void)
     63{
     64    char *value = NULL;
     65    psStringAppend(&value, "%s@%s", xstr(PSLIB_BRANCH), xstr(PSLIB_VERSION));
     66    return value;
    5967}
    6068
    6169psString psLibSource(void)
    6270{
    63 #ifndef PSLIB_SOURCE
    64 #error "PSLIB_SOURCE is not set"
    65 #endif
    66     return psStringCopy(PSLIB_SOURCE);
     71    return psStringCopy(xstr(PSLIB_SOURCE));
    6772}
    6873
  • branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/psLogMsg.c

    r20546 r23239  
    195195    }
    196196
    197     int fileD = creat(dest, 0666);
     197    int fileD = open(dest, O_WRONLY | O_CREAT, 0666);
    198198    if (fileD == 0) {
    199199        psError(PS_ERR_IO, true, _("Could not open file '%s' for output."), dest);
    … …  
    316316
    317317    if (write(logFD, head, strlen(head))) {;} // ignore return value
    318    
     318
    319319    if (logMsg) {
    320320        psString msg = NULL;            // Message to print
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/config/Makefile.am

    r23199 r23239  
    11noinst_LTLIBRARIES = libpsmodulesconfig.la
    22
    3 PSMODULES_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
    4 PSMODULES_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
    5 PSMODULES_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     3# PSMODULES_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4# PSMODULES_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
     5# PSMODULES_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
    66
    77# Force recompilation of pmVersion.c, since it gets the version information
    8 pmVersion.c: FORCE
    9         touch pmVersion.c
    10 FORCE: ;
     8# pmVersion.c: FORCE
     9#       touch pmVersion.c
     10# FORCE: ;
    1111
    12 libpsmodulesconfig_la_CPPFLAGS = $(SRCINC) $(PSMODULES_CFLAGS) -DPSMODULES_VERSION=\"$(PSMODULES_VERSION)\" -DPSMODULES_BRANCH=\"$(PSMODULES_BRANCH)\" -DPSMODULES_SOURCE=\"$(PSMODULES_SOURCE)\"
     12libpsmodulesconfig_la_CPPFLAGS = $(SRCINC) $(PSMODULES_CFLAGS) -DPSMODULES_VERSION=$(SVN_VERSION) -DPSMODULES_BRANCH=$(SVN_BRANCH) -DPSMODULES_SOURCE=$(SVN_SOURCE)
    1313libpsmodulesconfig_la_LDFLAGS  = -release $(PACKAGE_VERSION)
    1414libpsmodulesconfig_la_SOURCES  = \
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/config/pmConfig.c

    r21314 r23239  
    11101110// camera.  If we are discovering the camera (config->camera == NULL), then we also load the
    11111111// recipe files for the camera.
    1112 psMetadata *pmConfigCameraFormatFromHeader(psMetadata **camera, psString *cameraName, psString *formatName, 
    1113                                            pmConfig *config, const psMetadata *header, bool readRecipes)
     1112psMetadata *pmConfigCameraFormatFromHeader(psMetadata **camera, psString *cameraName, psString *formatName,
     1113                                           pmConfig *config, const psMetadata *header, bool readRecipes)
    11141114{
    11151115    PS_ASSERT_PTR_NON_NULL(config, NULL);
    … …  
    16721672                // if the object does not exist and create isn't set, then we
    16731673                // should puke
    1674                 psError(PM_ERR_SYS, true, "Unable to access file %s", filename);
     1674                psError(PM_ERR_SYS, true, "Unable to access file %s: %s", filename, nebErr(server));
    16751675                nebServerFree(server);
    16761676                return NULL;
    … …  
    16851685        if (trunc) {
    16861686            if(truncate(path, 0) != 0) {
    1687                 psError(PS_ERR_IO, true, "Failed to truncate Nebulous file %s (real name %s)\n", filename, path);
     1687                psError(PS_ERR_IO, true, "Failed to truncate Nebulous file %s (real name %s)\n",
     1688                        filename, path);
    16881689                return NULL;
    16891690            }
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/config/pmVersion.c

    r23199 r23239  
    88#include "pmVersion.h"
    99
    10 psString psModulesVersion(void)
    11 {
    1210#ifndef PSMODULES_VERSION
    1311#error "PSMODULES_VERSION is not set"
    … …  
    1614#error "PSMODULES_BRANCH is not set"
    1715#endif
    18     return psStringCopy(PSMODULES_BRANCH "@" PSMODULES_VERSION);
     16#ifndef PSMODULES_SOURCE
     17#error "PSMODULES_SOURCE is not set"
     18#endif
     19
     20#define xstr(s) str(s)
     21#define str(s) #s
     22
     23psString psModulesVersion(void)
     24{
     25    char *value = NULL;
     26    psStringAppend(&value, "%s@%s", xstr(PSMODULES_BRANCH), xstr(PSMODULES_VERSION));
     27    return value;
    1928}
    2029
    2130psString psModulesSource(void)
    2231{
    23 #ifndef PSMODULES_SOURCE
    24 #error "PSMODULES_SOURCE is not set"
    25 #endif
    26     return psStringCopy(PSMODULES_SOURCE);
     32    return psStringCopy(xstr(PSMODULES_SOURCE));
    2733}
    2834
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceMatch.c

    r23199 r23239  
    152152
    153153
    154 psArray *pmSourceMatchSources(const psArray *sourceArrays, float radius)
     154psArray *pmSourceMatchSources(const psArray *sourceArrays, float radius, bool cullSingles)
    155155{
    156156    PS_ASSERT_ARRAY_NON_NULL(sourceArrays, NULL);
    … …  
    220220
    221221        // Match with the master list
    222 
    223         psTree *tree = psTreePlant(2, SOURCES_MAX_LEAF, xMaster, yMaster); // kd Tree with sources
    224         long numMatch = 0;              // Number of matches
    225 
    226         long size = numMaster + numSources; // New size
    227         xMaster = psVectorRealloc(xMaster, size);
    228         yMaster = psVectorRealloc(yMaster, size);
    229         matches = psArrayRealloc(matches, size);
    230 
    231         psVector *coords = psVectorAlloc(2, PS_TYPE_F32); // Coordinates for tree lookup
    232         for (int j = 0; j < numSources; j++) {
    233             coords->data.F32[0] = xImage->data.F32[j];
    234             coords->data.F32[1] = yImage->data.F32[j];
    235             long index = psTreeNearestWithin(tree, coords, radius); // Match index
    236             if (index >= 0) {
    237                 // Record the match
    238                 pmSourceMatch *match = matches->data[index]; // Match data
    239                 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j);
    240                 numMatch++;
    241             } else {
    242                 // Add to the master list
    243                 pmSourceMatch *match = pmSourceMatchAlloc(numImages); // Match data
    244                 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j);
    245                 xMaster->data.F32[numMaster] = xImage->data.F32[j];
    246                 yMaster->data.F32[numMaster] = yImage->data.F32[j];
    247                 matches->data[numMaster] = match;
    248                 numMaster++;
    249                 xMaster->n = yMaster->n = matches->n = numMaster;
    250             }
    251 
    252         }
    253         psFree(coords);
    254         psFree(tree);
    255 
     222        {
     223            psTree *tree = psTreePlant(2, SOURCES_MAX_LEAF, xMaster, yMaster); // kd Tree with sources
     224            long numMatch = 0;              // Number of matches
     225
     226            long size = numMaster + numSources; // New size
     227            xMaster = psVectorRealloc(xMaster, size);
     228            yMaster = psVectorRealloc(yMaster, size);
     229            matches = psArrayRealloc(matches, size);
     230
     231            psVector *coords = psVectorAlloc(2, PS_TYPE_F32); // Coordinates for tree lookup
     232            for (int j = 0; j < numSources; j++) {
     233                coords->data.F32[0] = xImage->data.F32[j];
     234                coords->data.F32[1] = yImage->data.F32[j];
     235                long index = psTreeNearestWithin(tree, coords, radius); // Match index
     236                if (index >= 0) {
     237                    // Record the match
     238                    pmSourceMatch *match = matches->data[index]; // Match data
     239                    pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j);
     240                    numMatch++;
     241                } else {
     242                    // Add to the master list
     243                    pmSourceMatch *match = pmSourceMatchAlloc(numImages); // Match data
     244                    pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j);
     245                    xMaster->data.F32[numMaster] = xImage->data.F32[j];
     246                    yMaster->data.F32[numMaster] = yImage->data.F32[j];
     247                    matches->data[numMaster] = match;
     248                    numMaster++;
     249                    xMaster->n = yMaster->n = matches->n = numMaster;
     250                }
     251
     252            }
     253            psFree(coords);
     254            psFree(tree);
     255        }
    256256
    257257    match_image_done:
    … …  
    263263    }
    264264
    265     // Now cull the matches that contain only a single star
    266     int numGood = 0;                    // Number of good matches
     265    if (cullSingles) {
     266        // Now cull the matches that contain only a single star
     267        int numGood = 0;                    // Number of good matches
     268        for (int i = 0; i < matches->n; i++) {
     269            pmSourceMatch *match = matches->data[i]; // Match of interest
     270            if (match->num > 1) {
     271                if (i != numGood) {
     272                    psFree(matches->data[numGood]);
     273                    matches->data[numGood] = psMemIncrRefCounter(match);
     274                }
     275                numGood++;
     276            }
     277        }
     278        matches->n = numGood;
     279        for (int i = numGood; i < numMaster; i++) {
     280            psFree(matches->data[i]);
     281            matches->data[i] = NULL;
     282        }
     283    }
     284
     285    return matches;
     286}
     287
     288
     289psArray *pmSourceMatchMerge(psArray *sourceArrays, float radius)
     290{
     291    PS_ASSERT_ARRAY_NON_NULL(sourceArrays, NULL);
     292    PS_ASSERT_FLOAT_LARGER_THAN(radius, 0.0, NULL);
     293
     294    psArray *matches = pmSourceMatchSources(sourceArrays, radius, false); // Source matches
     295    if (!matches) {
     296        psError(PS_ERR_UNKNOWN, false, "Unable to match source lists.");
     297        return NULL;
     298    }
     299
     300    int index = 0;                      // Index to current position on list
    267301    for (int i = 0; i < matches->n; i++) {
     302        pmSource *source = NULL;        // Source to put in merged list
    268303        pmSourceMatch *match = matches->data[i]; // Match of interest
    269         if (match->num > 1) {
    270             if (i != numGood) {
    271                 psFree(matches->data[numGood]);
    272                 matches->data[numGood] = psMemIncrRefCounter(match);
    273                 //                psFree(match);
    274             }
    275             numGood++;
    276         }
    277     }
    278     matches->n = numGood;
    279     for (int i = numGood; i < numMaster; i++) {
    280         psFree(matches->data[i]);
    281         matches->data[i] = NULL;
    282     }
     304        for (int j = 0; j < match->num && !source; j++) {
     305            if (!isfinite(match->mag->data.F32[j]) || !isfinite(match->magErr->data.F32[j])) {
     306                continue;
     307            }
     308            int image = match->image->data.S32[j]; // Index of image
     309            int index = match->index->data.S32[j]; // Index of source for image
     310            psArray *list = sourceArrays->data[image]; // List of interest
     311            source = list->data[index];
     312            break;
     313        }
     314
     315        if (source) {
     316            psFree(matches->data[index]);
     317            matches->data[index] = psMemIncrRefCounter(source);
     318            index++;
     319        }
     320    }
     321
     322    // Clear out the rest of the list
     323    int num = index;                    // Number of good sources
     324    for (; index < matches->n; index++) {
     325        psFree(matches->data[index]);
     326        matches->data[index] = NULL;
     327    }
     328    matches->n = num;
    283329
    284330    return matches;
    285331}
    286 
    287332
    288333// Iterate on the star magnitudes and image transparencies
    … …  
    524569psVector *pmSourceMatchRelphot(const psArray *matches, // Array of matches
    525570                               const psVector *zp, // Zero points for each image (including airmass term)
    526                                int maxIter, // Maximum number of iterations
    527571                               float tol, // Relative tolerance for convergence
     572                               int iter1, // Number of iterations for pass 1
     573                               float rej1, // Limit on rejection between iterations for pass 1
     574                               float sys1, // Systematic error in measurements for pass 1
     575                               int iter2, // Number of iterations for pass 2
     576                               float rej2, // Limit on rejection between iterations for pass 2
     577                               float sys2, // Systematic error in measurements for pass 2
    528578                               float rejLimit, // Limit on rejection between iterations
    529579                               int transIter, // Clipping iterations for transparency
    530580                               float transClip, // Clipping level for transparency
    531                                float photoLevel, // Level at which we declare image is photometric
    532                                float starClip, // Clipping for stars
    533                                float sysErr // Systematic error in measurements
     581                               float photoLevel // Level at which we declare image is photometric
    534582                               )
    535583{
    … …  
    539587    PS_ASSERT_FLOAT_LARGER_THAN(transClip, 0.0, NULL);
    540588
    541     sysErr *= sysErr;
     589    sys1 *= sys1;
     590    sys2 *= sys2;
    542591
    543592    int numImages = zp->n;              // Number of images
    … …  
    552601
    553602    float chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp,
    554                                            photo, sysErr); // chi^2 for solution
     603                                           photo, sys1); // chi^2 for solution
    555604    psTrace("psModules.objects", 1, "Initial: chi^2 = %f\n", chi2);
    556605    float lastChi2 = INFINITY;          // chi^2 on last iteration
    557606    float fracRej = INFINITY;        // Fraction of measurements rejected
    558607
    559     // in the first passes, the transparencies are not well deteremined: use high systematic error and the rejection thresholds
    560     for (int i = 0; i < 5; i++) {
     608    // In the first passes, the transparencies are not well deteremined: use high systematic error and
     609    // rejection thresholds
     610    for (int i = 0; i < iter1; i++) {
    561611
    562612        // Identify photometric nights
    … …  
    572622        psTrace("psModules.objects", 3, "Pass 1: Determined %d/%d are photometric", numPhoto, numImages);
    573623
    574         // XXX use 20 sigma rejection and 0.1 mag systematic error (move these to the recipe)
    575         fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, badImage, 20.0, PS_SQR(0.1));
     624        fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, badImage, rej1, sys1);
    576625        psTrace("psModules.objects", 3, "Pass 1: %f%% of measurements rejected", fracRej * 100);
    577626
    578         // XXX use 0.05 mag systematic error (move these to the recipe)
    579         chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp, photo, PS_SQR(0.1));
     627        chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp, photo, sys1);
    580628        psTrace("psModules.objects", 1, "Pass 1: iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej);
    581629    }
    582630
    583     for (int i = 0; i < maxIter && (fabsf(lastChi2 - chi2) > tol * chi2 || fracRej > rejLimit); i++) {
     631    for (int i = 0; i < iter2 && (fabsf(lastChi2 - chi2) > tol * chi2 || fracRej > rejLimit); i++) {
    584632        lastChi2 = chi2;
    585633
    … …  
    594642            return NULL;
    595643        }
    596         psTrace("psModules.objects", 3, "Determined %d/%d are photometric", numPhoto, numImages);
    597 
    598         fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, badImage, starClip, sysErr);
    599         psTrace("psModules.objects", 3, "%f%% of measurements rejected", fracRej * 100);
    600 
    601         chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp, photo, sysErr);
    602         psTrace("psModules.objects", 1, "iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej);
     644        psTrace("psModules.objects", 3, "Pass 2: Determined %d/%d are photometric", numPhoto, numImages);
     645
     646        fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, badImage, rej2, sys2);
     647        psTrace("psModules.objects", 3, "Pass 2: %f%% of measurements rejected", fracRej * 100);
     648
     649        chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp, photo, sys2);
     650        psTrace("psModules.objects", 1, "Pass 2: iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej);
    603651    }
    604652
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceMatch.h

    r20953 r23239  
    4848///
    4949/// Returns an array of psSourceMatch
    50 psArray *pmSourceMatchSources(const psArray *sourceArrays, // Array of arrays of sources on each image
    51                               float radius // Correlation radius
     50psArray *pmSourceMatchSources(const psArray *sourceArrays, ///< Array of arrays of sources on each image
     51                              float radius, ///< Matching radius
     52                              bool cullSingles ///< Cull "matches" with only a single source?
    5253                              );
     54
     55/// Merge two source lists
     56///
     57/// Sources are pulled from the lists into a new list, with no effort made to adjust them.
     58psArray *pmSourceMatchMerge(psArray *sourceArrays, ///< Array of arrays of sources on each image
     59                            float radius ///< Matching radius
     60    );
    5361
    5462/// Perform relative photometry to calibrate images
    5563psVector *pmSourceMatchRelphot(const psArray *matches, // Array of matches
    5664                               const psVector *zp, // Zero points for each image (including airmass term)
    57                                int maxIter, // Maximum number of iterations
    5865                               float tol, // Relative tolerance for convergence
     66                               int iter1, // Number of iterations for pass 1
     67                               float rej1, // Limit on rejection between iterations for pass 1
     68                               float sys1, // Systematic error in measurements for pass 1
     69                               int iter2, // Number of iterations for pass 2
     70                               float rej2, // Limit on rejection between iterations for pass 2
     71                               float sys2, // Systematic error in measurements for pass 2
    5972                               float rejLimit, // Limit on rejection between iterations
    6073                               int transIter, // Clipping iterations for transparency
    6174                               float transClip, // Clipping level for transparency
    62                                float photoLevel, // Level at which we declare image is photometric
    63                                float starClip, // Clipping for stars
    64                                float sysErr // Systematic error in measurements
     75                               float photoLevel // Level at which we declare image is photometric
    6576    );
    6677
  • branches/cnb_branches/cnb_branch_20090215/psastro/src/Makefile.am

    r23199 r23239  
    11lib_LTLIBRARIES = libpsastro.la
    22
    3 PSASTRO_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
    4 PSASTRO_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
    5 PSASTRO_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     3libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSASTRO_VERSION=$(SVN_VERSION) -DPSASTRO_BRANCH=$(SVN_BRANCH) -DPSASTRO_SOURCE=$(SVN_SOURCE)
     4libpsastro_la_LDFLAGS = $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    65
    76# Force recompilation of psastroVersion.c, since it gets the version information
    8 psastroVersion.c: FORCE
    9         touch psastroVersion.c
    10 FORCE: ;
    11 
    12 libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSASTRO_VERSION=\"$(PSASTRO_VERSION)\" -DPSASTRO_BRANCH=\"$(PSASTRO_BRANCH)\" -DPSASTRO_SOURCE=\"$(PSASTRO_SOURCE)\"
    13 libpsastro_la_LDFLAGS = $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
     7# can we do this with dependency info?
     8# psastroVersion.c: FORCE
     9# touch psastroVersion.c
     10# FORCE: ;
    1411
    1512bin_PROGRAMS = psastro psastroModel psastroModelFit gpcModel
  • branches/cnb_branches/cnb_branch_20090215/psastro/src/psastroVersion.c

    r23199 r23239  
    1010#include "psastroInternal.h"
    1111
    12 psString psastroVersion(void)
    13 {
    1412#ifndef PSASTRO_VERSION
    1513#error "PSASTRO_VERSION is not set"
    … …  
    1816#error "PSASTRO_BRANCH is not set"
    1917#endif
    20     return psStringCopy(PSASTRO_BRANCH "@" PSASTRO_VERSION);
     18#ifndef PSASTRO_SOURCE
     19#error "PSASTRO_SOURCE is not set"
     20#endif
     21
     22#define xstr(s) str(s)
     23#define str(s) #s
     24
     25psString psastroVersion(void)
     26{
     27    char *value = NULL;
     28    psStringAppend(&value, "%s@%s", xstr(PSASTRO_BRANCH), xstr(PSASTRO_VERSION));
     29    return value;
    2130}
    2231
    2332psString psastroSource(void)
    2433{
    25 #ifndef PSASTRO_SOURCE
    26 #error "PSASTRO_SOURCE is not set"
    27 #endif
    28     return psStringCopy(PSASTRO_SOURCE);
     34  return psStringCopy(xstr(PSASTRO_SOURCE));
    2935}
    3036
  • branches/cnb_branches/cnb_branch_20090215/psconfig/psbuild

    r23199 r23239  
    1313$stop = "";
    1414$verbose = 0;
     15$use_svn = 1;
    1516
    1617$extlibs = "none";
    … …  
    8384    if ($ARGV[0] eq "-bootstrap") {
    8485        &bootstrap ();
     86    }
     87    if ($ARGV[0] eq "-skip-svn") {
     88        $use_svn = 0;
     89        shift; next;
    8590    }
    8691    if ($ARGV[0] eq "-env") {
    … …  
    157162sub build_distribution {
    158163
     164    # set environment variables used to supply SVN info to the compilation
     165
     166    if ($use_svn) {
     167        # example dump from svn info:
     168        # pikake: svn info
     169        # Path: .
     170        # URL: https://svn.pan-starrs.ifa.hawaii.edu/repo/ipp/branches/eam_branches/eam_branch_20090303/ppImage
     171        # Repository Root: https://svn.pan-starrs.ifa.hawaii.edu/repo/ipp
     172        # Repository UUID: 60eb6cdc-a59c-4636-a4e0-dba66a9721fd
     173        # Revision: 23158
     174        # Node Kind: directory
     175        # Schedule: normal
     176        # Last Changed Author: price
     177        # Last Changed Rev: 23125
     178        # Last Changed Date: 2009-03-03 15:41:16 -1000 (Tue, 03 Mar 2009)
     179       
     180        $svn_version = `svnversion`; chomp $svn_version;
     181        @svn_info = `svn info`;
     182
     183        # get the svn_root first:
     184        foreach $line (@svn_info) {
     185            if ($line =~ m|^Repository Root:|) {
     186                ($svn_root) = $line =~ m|^Repository Root:\s*(\S*)|;
     187                last;
     188            }
     189        }
     190
     191        # now get the branch and UUID values
     192        foreach $line (@svn_info) {
     193            if ($line =~ m|^URL:|) {
     194                ($svn_branch) = $line =~ m|^URL:\s*$svn_root/*(\S*)|;
     195            }
     196            if ($line =~ m|^Repository UUID:|) {
     197                ($svn_source) = $line =~ m|^Repository UUID:\s*(\S*)|;
     198            }
     199        }
     200       
     201        $ENV{SVN_VERSION} = $svn_version;
     202        $ENV{SVN_BRANCH}  = $svn_branch;
     203        $ENV{SVN_SOURCE}  = $svn_source;
     204    } else {
     205        # alternatively, grab these from the following files:
     206        if (! -e "SVNINFO") {
     207            print "missing SVNINFO file for repository info, skipping\n";
     208        } else {
     209            @svn_info = `cat SVNINFO`;
     210            foreach $line (@svn_info) {
     211                ($name, $value) = split (" ", $line);
     212                $ENV{$name} = $value;
     213            }
     214        }
     215    }
     216    print "SVN_VERSION $ENV{SVN_VERSION}\n";
     217    print "SVN_BRANCH  $ENV{SVN_BRANCH}\n";
     218    print "SVN_SOURCE  $ENV{SVN_SOURCE}\n";
     219
    159220    # use psconfig.csh to set needed build aliases
    160 
    161221    if ($extlibs eq "check") {
    162222        $status = vsystem ("pschecklibs");
  • branches/cnb_branches/cnb_branch_20090215/psphot/src/Makefile.am

    r23199 r23239  
    11lib_LTLIBRARIES = libpsphot.la
    22
    3 PSPHOT_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
    4 PSPHOT_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
    5 PSPHOT_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     3# PSPHOT_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4# PSPHOT_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi`
     5# PSPHOT_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     6#
     7# # Force recompilation of psphotVersion.c, since it gets the version information
     8# psphotVersion.c: FORCE
     9#       touch psphotVersion.c
     10# FORCE: ;
    611
    7 # Force recompilation of psphotVersion.c, since it gets the version information
    8 psphotVersion.c: FORCE
    9         touch psphotVersion.c
    10 FORCE: ;
    11 
    12 libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSPHOT_VERSION=\"$(PSPHOT_VERSION)\" -DPSPHOT_BRANCH=\"$(PSPHOT_BRANCH)\" -DPSPHOT_SOURCE=\"$(PSPHOT_SOURCE)\"
     12libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSPHOT_VERSION=$(PSPHOT_VERSION) -DPSPHOT_BRANCH=$(PSPHOT_BRANCH) -DPSPHOT_SOURCE=$(SVN_SOURCE)
    1313libpsphot_la_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    1414
  • branches/cnb_branches/cnb_branch_20090215/psphot/src/psphotSetThreads.c

    r21392 r23239  
    2525    psFree(task);
    2626
    27     task = psThreadTaskAlloc("PSPHOT_SOURCE_STATS", 4);
     27    task = psThreadTaskAlloc("PSPHOT_SOURCE_STATS", 5);
    2828    task->function = &psphotSourceStats_Threaded;
    2929    psThreadTaskAdd(task);
  • branches/cnb_branches/cnb_branch_20090215/psphot/src/psphotSourceStats.c

    r21536 r23239  
    1515    int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); // Number of threads
    1616    if (!status) {
    17         nThreads = 0;
     17        nThreads = 0;
    1818    }
    1919
    … …  
    4141        pmSource *source = pmSourceAlloc();
    4242
    43         // add the peak
     43        // add the peak
    4444        source->peak = psMemIncrRefCounter(peak);
    4545
    46         // allocate space for moments
     46        // allocate space for moments
    4747        source->moments = pmMomentsAlloc();
    4848
    … …  
    5050        pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER);
    5151
    52         peak->assigned = true;
    53         psArrayAdd (sources, 100, source);
    54         psFree (source);
     52        peak->assigned = true;
     53        psArrayAdd (sources, 100, source);
     54        psFree (source);
    5555    }
    5656
    5757    if (!strcasecmp (breakPt, "PEAKS")) {
    58         psLogMsg ("psphot", PS_LOG_INFO, "%ld sources : %f sec\n", sources->n, psTimerMark ("psphot.stats"));
    59         psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n");
    60         psphotVisualShowMoments (sources);
    61         return sources;
     58        psLogMsg ("psphot", PS_LOG_INFO, "%ld sources : %f sec\n", sources->n, psTimerMark ("psphot.stats"));
     59        psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n");
     60        psphotVisualShowMoments (sources);
     61        return sources;
    6262    }
    6363
    … …  
    6565    int Nfail = 0;
    6666    int Nmoments = 0;
     67    int Nfaint = 0;
    6768
    6869    // choose Cx, Cy (see psphotThreadTools.c for overview of the concepts)
    … …  
    7475    for (int i = 0; i < cellGroups->n; i++) {
    7576
    76         psArray *cells = cellGroups->data[i];
    77 
    78         for (int j = 0; j < cells->n; j++) {
    79 
    80             // allocate a job -- if threads are not defined, this just runs the job
    81             psThreadJob *job = psThreadJobAlloc ("PSPHOT_SOURCE_STATS");
    82 
    83             psArrayAdd(job->args, 1, cells->data[j]); // sources
    84             psArrayAdd(job->args, 1, recipe);
    85             PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nmoments
    86             PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail
    87 
    88             if (!psThreadJobAddPending(job)) {
    89                 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    90                 psFree (job);
    91                 return NULL;
    92             }
    93             psFree(job);
     77        psArray *cells = cellGroups->data[i];
     78
     79        for (int j = 0; j < cells->n; j++) {
     80
     81            // allocate a job -- if threads are not defined, this just runs the job
     82            psThreadJob *job = psThreadJobAlloc ("PSPHOT_SOURCE_STATS");
     83
     84            psArrayAdd(job->args, 1, cells->data[j]); // sources
     85            psArrayAdd(job->args, 1, recipe);
     86            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nmoments
     87            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail
     88            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfaint
     89
     90            if (!psThreadJobAddPending(job)) {
     91                psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     92                psFree (job);
     93                return NULL;
     94            }
     95            psFree(job);
    9496
    9597# if (0)
    96                 int nfail = 0;
    97                 int nmoments = 0;
    98                 if (!psphotSourceStats_Unthreaded (&nfail, &nmoments, cells->data[j], recipe)) {
    99                     psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    100                     return NULL;
    101                 }
    102                 Nfail += nfail;
    103                 Nmoments += nmoments;
     98                int nfail = 0;
     99                int nmoments = 0;
     100                if (!psphotSourceStats_Unthreaded (&nfail, &nmoments, cells->data[j], recipe)) {
     101                    psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     102                    return NULL;
     103                }
     104                Nfail += nfail;
     105                Nmoments += nmoments;
    104106# endif
    105         }
    106 
    107         // wait for the threads to finish and manage results
    108         if (!psThreadPoolWait (false)) {
    109             psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    110             return NULL;
    111         }
    112 
    113         // we have only supplied one type of job, so we can assume the types here
    114         psThreadJob *job = NULL;
    115         while ((job = psThreadJobGetDone()) != NULL) {
    116             if (job->args->n < 1) {
    117                 fprintf (stderr, "error with job\n");
    118             } else {
    119                 psScalar *scalar = NULL;
    120                 scalar = job->args->data[2];
    121                 Nmoments += scalar->data.S32;
    122                 scalar = job->args->data[3];
    123                 Nfail += scalar->data.S32;
    124             }
    125             psFree(job);
    126         }
     107        }
     108
     109        // wait for the threads to finish and manage results
     110        if (!psThreadPoolWait (false)) {
     111            psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     112            return NULL;
     113        }
     114
     115        // we have only supplied one type of job, so we can assume the types here
     116        psThreadJob *job = NULL;
     117        while ((job = psThreadJobGetDone()) != NULL) {
     118            if (job->args->n < 1) {
     119                fprintf (stderr, "error with job\n");
     120            } else {
     121                psScalar *scalar = NULL;
     122                scalar = job->args->data[2];
     123                Nmoments += scalar->data.S32;
     124                scalar = job->args->data[3];
     125                Nfail += scalar->data.S32;
     126                scalar = job->args->data[4];
     127                Nfaint += scalar->data.S32;
     128            }
     129            psFree(job);
     130        }
    127131    }
    128132
    129133    psFree (cellGroups);
    130134
    131     psLogMsg ("psphot", PS_LOG_INFO, "%ld sources, %d moments, %d failed: %f sec\n", sources->n, Nmoments, Nfail, psTimerMark ("psphot.stats"));
     135    psLogMsg ("psphot", PS_LOG_INFO, "%ld sources, %d moments, %d faint, %d failed: %f sec\n", sources->n, Nmoments, Nfaint, Nfail, psTimerMark ("psphot.stats"));
    132136
    133137    psphotVisualShowMoments (sources);
    … …  
    166170    int Nfail = 0;
    167171    int Nmoments = 0;
     172    int Nfaint = 0;
    168173    for (int i = 0; i < sources->n; i++) {
    169174        pmSource *source = sources->data[i];
    … …  
    171176        // skip faint sources for moments measurement
    172177        if (source->peak->SN < MIN_SN) {
    173             source->mode |= PM_SOURCE_MODE_BELOW_MOMENTS_SN;
     178            source->mode |= PM_SOURCE_MODE_BELOW_MOMENTS_SN;
     179            Nfaint++;
    174180            continue;
    175181        }
    … …  
    179185        status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
    180186        if (!status) {
    181             source->mode |= PM_SOURCE_MODE_SKY_FAILURE;
    182             psErrorClear(); // XXX re-consider the errors raised here
    183             Nfail ++;
    184             continue;
     187            source->mode |= PM_SOURCE_MODE_SKY_FAILURE;
     188            psErrorClear(); // XXX re-consider the errors raised here
     189            Nfail ++;
     190            continue;
    185191        }
    186192
    … …  
    189195        status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
    190196        if (!status) {
    191             source->mode |= PM_SOURCE_MODE_SKYVAR_FAILURE;
    192             Nfail ++;
    193             psErrorClear();
    194             continue;
     197            source->mode |= PM_SOURCE_MODE_SKYVAR_FAILURE;
     198            Nfail ++;
     199            psErrorClear();
     200            continue;
    195201        }
    196202
    … …  
    208214        status = pmSourceMoments (source, BIG_RADIUS);
    209215        if (status) {
    210             source->mode |= PM_SOURCE_MODE_BIG_RADIUS;
     216            source->mode |= PM_SOURCE_MODE_BIG_RADIUS;
    211217            Nmoments ++;
    212218            continue;
    213219        }
    214220
    215         source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE;
     221        source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE;
    216222        Nfail ++;
    217223        psErrorClear();
    … …  
    225231    scalar = job->args->data[3];
    226232    scalar->data.S32 = Nfail;
    227    
     233
     234    scalar = job->args->data[4];
     235    scalar->data.S32 = Nfaint;
     236
    228237    return true;
    229238}
    … …  
    268277        status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
    269278        if (!status) {
    270             psErrorClear(); // XXX re-consider the errors raised here
    271             Nfail ++;
    272             continue;
     279            psErrorClear(); // XXX re-consider the errors raised here
     280            Nfail ++;
     281            continue;
    273282        }
    274283
    … …  
    277286        status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
    278287        if (!status) {
    279             Nfail ++;
    280             psErrorClear();
    281             continue;
     288            Nfail ++;
     289            psErrorClear();
     290            continue;
    282291        }
    283292
    … …  
    307316    *nmoments = Nmoments;
    308317    *nfail = Nfail;
    309    
     318
    310319    return true;
    311320}
    312 # endif 
     321# endif
  • branches/cnb_branches/cnb_branch_20090215/psphot/src/psphotVersion.c

    r23199 r23239  
    55#endif
    66
    7 psString psphotVersion(void)
    8 {
    97#ifndef PSPHOT_VERSION
    108#error "PSPHOT_VERSION is not set"
    … …  
    1311#error "PSPHOT_BRANCH is not set"
    1412#endif
    15     return psStringCopy(PSPHOT_BRANCH "@" PSPHOT_VERSION);
     13#ifndef PSPHOT_SOURCE
     14#error "PSPHOT_SOURCE is not set"
     15#endif
     16
     17#define xstr(s) str(s)
     18#define str(s) #s
     19
     20psString psphotVersion(void)
     21{
     22    char *value = NULL;
     23    psStringAppend(&value, "%s@%s", xstr(PSPHOT_BRANCH), xstr(PSPHOT_VERSION));
     24    return value;
    1625}
    1726
    1827psString psphotSource(void)
    1928{
    20 #ifndef PSPHOT_SOURCE
    21 #error "PSPHOT_SOURCE is not set"
    22 #endif
    23     return psStringCopy(PSPHOT_SOURCE);
     29    return psStringCopy(xstr(PSPHOT_SOURCE));
    2430}
    2531
Note: See TracChangeset for help on using the changeset viewer.