IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23229


Ignore:
Timestamp:
Mar 8, 2009, 4:50:46 PM (17 years ago)
Author:
eugene
Message:

merging changes from branches/eam_branches/eam_branch_20090303 (detrend normalization resequence, cleanup error state changes; SVN_VERSION from psbuild)

Location:
trunk
Files:
51 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Ohana/src/addstar/src/sky_tessalation.c

    r23138 r23229  
    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
  • trunk/dbconfig/changes.txt

    r21434 r23229  
    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;
  • trunk/dbconfig/config.md

    r21310 r23229  
    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
  • trunk/dbconfig/det.md

    r19620 r23229  
    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
  • trunk/ippScripts/scripts/detrend_norm_apply.pl

    r23186 r23229  
    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
  • trunk/ippScripts/scripts/detrend_norm_calc.pl

    r23186 r23229  
    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    }
  • trunk/ippScripts/scripts/detrend_resid_exp.pl

    r23186 r23229  
    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
  • trunk/ippScripts/scripts/ipp_cleanup.pl

    r23186 r23229  
    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{
  • trunk/ippTools/share/chiptool_change_imfile_data_state.sql

    r19527 r23229  
    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'
  • trunk/ippTools/share/dettool_processedimfile.sql

    r18561 r23229  
     1-- is this DISTINCT needed?
    12SELECT DISTINCT
    23  detRun.det_type,
  • trunk/ippTools/share/dettool_residimfile.sql

    r19632 r23229  
    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
  • trunk/ippTools/share/dettool_tonormalizedstat.sql

    r18118 r23229  
    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
  • trunk/ippTools/share/dettool_toresidexp.sql

    r19815 r23229  
    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)
  • trunk/ippTools/share/dettool_toresidimfile.sql

    r19816 r23229  
    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
  • trunk/ippTools/share/pxadmin_create_tables.sql

    r21308 r23229  
    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
  • trunk/ippTools/share/warptool_change_skyfile_data_state.sql

    r19521 r23229  
    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'
  • trunk/ippTools/src/chiptool.c

    r22751 r23229  
    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)
  • trunk/ippTools/src/chiptoolConfig.c

    r22751 r23229  
    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);
  • trunk/ippTools/src/dettoolConfig.c

    r23154 r23229  
    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
  • trunk/ippTools/src/dettool_processedimfile.c

    r19621 r23229  
    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 {
  • trunk/ippTools/src/dettool_residimfile.c

    r19632 r23229  
    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) {
  • trunk/ippTools/src/warptool.c

    r21402 r23229  
    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}
  • trunk/ippTools/src/warptoolConfig.c

    r20973 r23229  
    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);
  • trunk/ppArith/src/Makefile.am

    r23124 r23229  
    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
  • trunk/ppArith/src/ppArithVersion.c

    r23195 r23229  
    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
  • trunk/ppImage/src/Makefile.am

    r23125 r23229  
    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 = \
  • trunk/ppImage/src/ppImage.h

    r23195 r23229  
    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
  • trunk/ppImage/src/ppImageArguments.c

    r19943 r23229  
    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    }
  • trunk/ppImage/src/ppImageDetrendReadout.c

    r21364 r23229  
    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        }
  • trunk/ppImage/src/ppImageOptions.c

    r21364 r23229  
    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}
  • trunk/ppImage/src/ppImageVersion.c

    r23195 r23229  
    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 ");
  • trunk/ppMerge/src/Makefile.am

    r23126 r23229  
    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
  • trunk/ppMerge/src/ppMergeVersion.c

    r23195 r23229  
    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
  • trunk/ppSim/src/Makefile.am

    r23139 r23229  
    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 = \
  • trunk/ppSim/src/ppSimVersion.c

    r23139 r23229  
    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
  • trunk/ppStack/src/Makefile.am

    r23143 r23229  
    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
  • trunk/ppStack/src/ppStackVersion.c

    r23195 r23229  
    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
  • trunk/ppStats/src/Makefile.am

    r23119 r23229  
    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
  • trunk/ppStats/src/ppStatsVersion.c

    r23163 r23229  
    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
  • trunk/ppSub/src/Makefile.am

    r23144 r23229  
    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
  • trunk/ppSub/src/ppSubVersion.c

    r23195 r23229  
    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
  • trunk/psLib/src/sys/Makefile.am

    r23115 r23229  
    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 \
  • trunk/psLib/src/sys/psConfigure.c

    r23116 r23229  
    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
  • trunk/psModules/src/config/Makefile.am

    r23117 r23229  
    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  = \
  • trunk/psModules/src/config/pmVersion.c

    r23193 r23229  
    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
  • trunk/psastro/src/Makefile.am

    r23195 r23229  
    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
  • trunk/psastro/src/psastroVersion.c

    r23195 r23229  
    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
  • trunk/psconfig/psbuild

    r22740 r23229  
    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");
  • trunk/psphot/src/Makefile.am

    r23118 r23229  
    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
  • trunk/psphot/src/psphotVersion.c

    r23195 r23229  
    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.