IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23199


Ignore:
Timestamp:
Mar 5, 2009, 11:24:29 AM (17 years ago)
Author:
beaumont
Message:

sync with mainline

Location:
branches/cnb_branches/cnb_branch_20090215
Files:
3 deleted
145 edited
18 copied

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090215

  • branches/cnb_branches/cnb_branch_20090215/Nebulous/Build.PL

    r21495 r23199  
    1111my $pkg_dir = "./nebclient";
    1212
    13 sub ACTION_code {
    14     my $self = shift;
    15 
    16     $self->SUPER::ACTION_code(@_);
    17 
    18     my $old_pwd = getcwd();
    19     chdir $pkg_dir;
    20 
    21     unless (-e "configure") {
    22         system("./autogen.sh") == 0 or die "install failed: $?";
    23     }
    24 
    25     chdir $old_pwd;
    26 }
    27 
    28 sub ACTION_build {
    29     my $self = shift;
    30 
    31     $self->SUPER::ACTION_build(@_);
    32 
    33     my $old_pwd = getcwd();
    34     chdir $pkg_dir;
    35 
    36     unless (-e "Makefile") {
    37         system("sh ./configure") == 0 or die "build failed: $?";
    38     }
    39 
    40     system("make") == 0 or die "build failed: $?";
    41 
    42     chdir $old_pwd;
    43 }
    44 
    45 # Do not attempt to install nebclient.  It is bundled in this package for
    46 # testing only.
    47 #
     13# sub ACTION_code {
     14#     my $self = shift;
     15#
     16#     $self->SUPER::ACTION_code(@_);
     17#
     18#     my $old_pwd = getcwd();
     19#     chdir $pkg_dir;
     20#
     21#     unless (-e "configure") {
     22#         system("./autogen.sh") == 0 or die "install failed: $?";
     23#     }
     24#
     25#     chdir $old_pwd;
     26# }
     27#
     28# sub ACTION_build {
     29#     my $self = shift;
     30#
     31#     $self->SUPER::ACTION_build(@_);
     32#
     33#     my $old_pwd = getcwd();
     34#     chdir $pkg_dir;
     35#
     36#     unless (-e "Makefile") {
     37#         system("sh ./configure") == 0 or die "build failed: $?";
     38#     }
     39#
     40#     system("make") == 0 or die "build failed: $?";
     41#
     42#     chdir $old_pwd;
     43# }
     44#
    4845# sub ACTION_install {
    4946#     my $self = shift;
     
    5855#     chdir $old_pwd;
    5956# }
    60 
    61 sub ACTION_clean {
    62     my $self = shift;
    63 
    64     $self->SUPER::ACTION_clean(@_);
    65 
    66     my $old_pwd = getcwd();
    67     chdir $pkg_dir;
    68 
    69     system("make clean") == 0 or die "install failed: $?";
    70 
    71     chdir $old_pwd;
    72 }
     57#
     58# sub ACTION_clean {
     59#     my $self = shift;
     60#
     61#     $self->SUPER::ACTION_clean(@_);
     62#
     63#     my $old_pwd = getcwd();
     64#     chdir $pkg_dir;
     65#
     66#     system("make clean") == 0 or die "install failed: $?";
     67#
     68#     chdir $old_pwd;
     69# }
    7370EOF
    7471
  • branches/cnb_branches/cnb_branch_20090215/Nebulous/nebclient/src

    • Property svn:ignore
      •  

        old new  
         1Makefile.in
        12.deps
        2 .libs
        33Makefile
        4 Makefile.in
        5 SOAP.nsmap
        6 libnebclient.la
        7 nebclient.lo
         4soapClientLib.c
        85nebulous.h
         6soapClient.c
         7soapStub.h
        98soapC.c
        10 soapC.lo
        11 soapClient.c
        12 soapClient.lo
        13 soapClientLib.c
        149soapH.h
         10soapServerLib.c
        1511soapServer.c
        16 soapServerLib.c
        17 soapStub.h
        18 stdsoap2.lo
        19 xmalloc.lo
  • branches/cnb_branches/cnb_branch_20090215/Nebulous/scripts/ptest.pl

    r23197 r23199  
    55
    66use lib "./lib";
     7package main;
    78
    8 use Nebulous::Client;
     9#use Nebulous::Client;
    910use IO::Select;
    1011use IO::Socket;
     12use POSIX qw(:DEFAULT :sys_wait_h);
     13use Hook::LexWrap;
     14use Sys::Hostname;
    1115
    12 my $neb = Nebulous::Client->new(
    13 #    proxy   => 'http://localhost:80/nebulous'
    14     proxy   => 'http://alala:80/nebulous'
    15 );
     16my $print_stdout = undef;
     17
     18$| = 1;
    1619
    1720my $key = shift || 'foobar';
    1821my $kids = shift || 1;
    1922
    20 my $s = IO::Select->new();
     23$key = "/tmp/" . $key;
     24
     25#my $s = IO::Select->new();
    2126
    2227foreach my $id ( 1..$kids ) {
    23     my ($sock_parent, $sock_child) = IO::Socket->socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC);
    24     $s->add($sock_parent);
     28#    my ($sock_parent, $sock_child) = IO::Socket->socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC);
     29#    $s->add($sock_parent);
    2530
    2631    my $pid = fork;
    2732
    2833    unless ( $pid )  {
     34        # child
     35        my $sock_child = \*STDOUT;
    2936        child($sock_child, $id);
     37        shutdown($sock_child, 2);
    3038        exit 0;
    3139    }
     
    3341}
    3442
    35 while ($kids) {
    36     foreach my $child ($s->can_read(1)) {
    37         my $string = <$child>;
    38         my @events = split(/\n/, $string) if $string;
    39         print join("\n", @events), "\n" if scalar @events;
     43$SIG{CHLD} = \&REAPER;
     44
     45sub REAPER {
     46    while ((my $pid = waitpid(-1,WNOHANG)) > 0) {
     47        $kids--;
     48#        delete $children{$pid};
    4049    }
     50    $SIG{CHLD} = \&REAPER;
    4151}
    4252
    43 #while ( $kids ) {
    44 #    wait();
    45 #    $kids --;
    46 #}
    4753
    48 our $my_sock;
     54while ($kids) {
     55#    foreach my $child ($s->can_read(0)) {
     56#        my $string = do { local $/; <$child>};
     57#        my @events = split(/\n/, $string) if $string;
     58#        print join("\n", @events), "\n" if scalar @events;
     59#    }
     60}
    4961
    5062sub child
    5163{
    52     my ($sock_child, $id) = @_;
     64    my ($sock, $id) = @_;
    5365
    54     $my_sock = $sock_child;
     66    unless ($print_stdout) {
     67        my $filename = hostname() . "." . $$ . ".txt";
     68        open my $fh, ">$filename" or die "can't open $filename: $!";
     69
     70        open STDOUT, ">&", $fh or die "can't reopen STDOUT: $!";
     71        autoflush STDOUT 1;
     72    }
     73
     74#    select $sock;
     75#    $| = 1;
    5576
    5677    # child
    5778    my $fname = "${key}_$id";
    58     print $sock_child "$$ : i'm a little tea pot using key: $fname\n";
    59     my $fh = $neb->open_create( $fname );
    60     child_die("can't create file $fname") unless $fh;
    6179
    62     print $fh "fooby\n";
     80    my $neb = Nebulous::Client::Bench->new(
     81#    proxy   => 'http://localhost:80/nebulous'
     82        proxy   => 'http://alala:80/nebulous',
     83#        sock    => \*STDOUT,
     84    );
    6385
    64     close $fh;
    6586
    66     $fh = $neb->open( $fname, 'read' ) or child_die("can't open file");
    67     close $fh;
     87    while (1) {
     88#    print $sock "$$ : i'm a little tea pot using key: $fname\n";
     89        my $fh = $neb->open_create( $fname )
     90            or child_die($sock, "can't create file $fname");
     91        close $fh;
    6892
    69     $neb->lock( $fname, 'read' );
    70     $neb->unlock( $fname, 'read' );
    71     $neb->replicate( $fname );
    72     $neb->cull( $fname );
     93        $fh = $neb->open( $fname, 'read' )
     94            or child_die("can't open file");
     95        close $fh;
    7396
    74     print $sock_child "$$ : half way\n";
     97        $neb->lock( $fname, 'read' );
     98        $neb->unlock( $fname, 'read' );
     99        $neb->replicate( $fname );
     100        $neb->cull( $fname );
     101        $neb->find( $fname );
     102        $neb->copy( $fname, $fname . "_copy" );
     103        $neb->move( $fname, $fname . "_move" );
     104        $neb->delete( $fname . "_copy" );
     105        $neb->delete( $fname . "_move" );
    75106
    76     $neb->find( $fname );
    77     $neb->copy( $fname, $fname . "_copy" );
    78     $neb->move( $fname, $fname . "_move" );
    79     $neb->delete( $fname . "_copy" );
    80     $neb->delete( $fname . "_move" );
    81 
    82     print $sock_child "$$ : all done!\n";
    83 
    84     $sock_child->flush;
    85     sleep 10;
     107#    print $sock "$$ : all done!\n";
     108    }
    86109
    87110    return 1;
     
    90113sub child_die
    91114{
    92     print $my_sock $@;
    93     shutdown($my_sock, 2);
     115    my $sock = shift;
     116    print $sock @_;
     117    shutdown($sock, 2);
    94118    exit 1;
    95119}
     120
     121package Nebulous::Client::Bench;
     122
     123use base qw( Nebulous::Client );
     124
     125#sub new
     126#{
     127#    my $class = shift;
     128#    my %p = @_;
     129#
     130#    my $sock = delete $p{sock};
     131#    my $self = $class->SUPER::new(%p);
     132#    $self->{sock} = $sock;
     133#
     134#    return $self;
     135#}
     136
     137BEGIN {
     138sub make_wrapper
     139{
     140    my $method = shift;
     141
     142eval "sub $method {"
     143.'    my $self = shift;'
     144.'    my $smark = Time::HiRes::time();'
     145.'    my $ret = $self->SUPER::' . "$method" .'(@_);'
     146.'    my $emark = Time::HiRes::time();'
     147.'    printf "%-17s %-17s %s\n", $emark, " ' . "$method" . ' ", ($emark - $smark), "\n";'
     148.'    return $ret;'
     149.'}';
     150
     151}
     152
     153make_wrapper("create");
     154make_wrapper("open_create");
     155make_wrapper("replicate");
     156make_wrapper("cull");
     157make_wrapper("lock");
     158make_wrapper("unlock");
     159make_wrapper("setxattr");
     160make_wrapper("getxattr");
     161make_wrapper("listxattr");
     162make_wrapper("removexattr");
     163make_wrapper("find_objects");
     164make_wrapper("find_instances");
     165#make_wrapper("find");
     166#make_wrapper("open");
     167#make_wrapper("delete");
     168#make_wrapper("copy");
     169make_wrapper("move");
     170make_wrapper("swap");
     171make_wrapper("delete_instance");
     172make_wrapper("stat");
     173make_wrapper("mounts");
     174
     175}
     176
     1771;
  • branches/cnb_branches/cnb_branch_20090215/Ohana/Makefile.in

    r19682 r23199  
    7575        mkdir -p $(DESTLIB)
    7676        mkdir -p $(DESTBIN)
    77         for i in $(LIBS); do make $$i.install || exit; done
     77        for i in $(LIBS); do make $$i.install || exit 1; done
    7878        chmod +x ohana-config
    7979        cp -f ohana-config $(DESTBIN)/
     
    8383
    8484all:
    85         make libs || exit
    86         for i in $(PROGRAM); do make $$i || exit; done
     85        make libs || exit 1
     86        for i in $(PROGRAM); do make $$i || exit 1; done
    8787
    8888extras:
    89         for i in $(EXTRAS); do make $$i || exit; done
     89        for i in $(EXTRAS); do make $$i || exit 1; done
    9090
    9191pantasks:
    92         make libs || exit
    93         cd src/opihi; make pclient.install && exit
    94         cd src/opihi; make pcontrol.install && exit
    95         cd src/opihi; make pantasks.install && exit
     92        make libs || exit 1
     93        cd src/opihi; make pclient.install && exit 1
     94        cd src/opihi; make pcontrol.install && exit 1
     95        cd src/opihi; make pantasks.install && exit 1
    9696
    9797mana:
    9898        make libs
    9999        make kapa2.install
    100         cd src/opihi; make mana.install && exit
     100        cd src/opihi; make mana.install && exit 1
    101101
    102102dvoshell:
    103103        make libs
    104104        make kapa2.install
    105         cd src/opihi; make dvo.install && exit
     105        cd src/opihi; make dvo.install && exit 1
    106106
    107107clean:
    108108        @if [ "$(ARCH)" = "" ]; then echo ""; echo " *** please define ARCH ***"; echo; exit 1; fi
    109         for i in $(LIBS); do make $$i.clean || exit; done
    110         for i in $(PROGRAM); do make $$i.clean || exit; done
    111         for i in $(EXTRAS); do make $$i.clean || exit; done
     109        for i in $(LIBS); do make $$i.clean || exit 1; done
     110        for i in $(PROGRAM); do make $$i.clean || exit 1; done
     111        for i in $(EXTRAS); do make $$i.clean || exit 1; done
    112112        @rm -f `find . -name .mana`
    113113        @rm -f `find . -name .dvo`
     
    116116dist:
    117117        @if [ "$(ARCH)" = "" ]; then echo ""; echo " *** please define ARCH ***"; echo; exit 1; fi
    118         for i in $(LIBS); do make $$i.dist || exit; done
    119         for i in $(PROGRAM); do make $$i.dist || exit; done
     118        for i in $(LIBS); do make $$i.dist || exit 1; done
     119        for i in $(PROGRAM); do make $$i.dist || exit 1; done
    120120        @echo -n -e "\0033]0; *** Ohana: done $@ *** \0007" \
    121121
    122122install:
    123123        @if [ "$(ARCH)" = "" ]; then echo ""; echo " *** please define ARCH ***"; echo; exit 1; fi
    124         for i in $(LIBS); do make $$i.install || exit; done
    125         for i in $(PROGRAM); do make $$i.install || exit; done
     124        for i in $(LIBS); do make $$i.install || exit 1; done
     125        for i in $(PROGRAM); do make $$i.install || exit 1; done
    126126        @echo -n -e "\0033]0; *** Ohana: done $@ *** \0007" \
    127127
    128128install.extras:
    129         for i in $(EXTRAS); do make $$i.install || exit; done
     129        for i in $(EXTRAS); do make $$i.install || exit 1; done
    130130        @echo -n -e "\0033]0; *** Ohana: done $@ *** \0007" \
    131131
  • branches/cnb_branches/cnb_branch_20090215/Ohana/src/addstar/include/skycells.h

    r21536 r23199  
    1212# include <glob.h>
    1313
    14 enum {SQUARES, TRIANGLES, LOCAL};
     14enum {SQUARES, TRIANGLES, LOCAL, RINGS};
    1515enum {TETRAHEDRON, CUBE, OCTOHEDRON, DODECAHEDRON, ICOSAHEDRON};
    1616
     
    6767double SCALE;
    6868double PADDING;
     69double CELLSIZE;
    6970int    LEVEL;
    7071
     
    8485int          sky_tessellation               PROTO((FITS_DB *db, int level, int Nmax, int mode, double scale));
    8586int          sky_tessellation_init          PROTO((double scale));
     87
    8688int          sky_tessellation_local         PROTO((FITS_DB *db, int level, int Nmax));
    8789int          sky_tessellation_triangles     PROTO((FITS_DB *db, int level, int Nmax));
    8890int          sky_tessellation_squares       PROTO((FITS_DB *db, int level, int Nmax));
     91int          sky_tessellation_rings         PROTO((FITS_DB *db, int level, int Nmax));
     92
    8993int          sky_triangle_to_image          PROTO((Image *image, SkyTriangle *triangle));
    9094int          sky_triangle_to_rectangle      PROTO((SkyRectangle *image, SkyTriangle *triangle));
     95
    9196int          sky_rectangle_local            PROTO((SkyRectangle *rectangle));
    9297int          sky_subdivide_image            PROTO((Image *output, SkyRectangle *input, int Nx, int Ny));
    9398int          sky_triangle_coords            PROTO((SkyTriangle *triangle));
     99
     100SkyRectangle *sky_rectangle_ring            PROTO((float dec, float dDEC, int *nring));
     101
    94102SkyTriangle *sky_divide_triangles           PROTO((SkyTriangle *in, int *ntriangles));
    95103SkyTriangle *sky_base_triangles             PROTO((int *ntriangles));
  • branches/cnb_branches/cnb_branch_20090215/Ohana/src/addstar/src/args_skycells.c

    r21048 r23199  
    3535      MODE = LOCAL;
    3636    }
     37    if (!strcasecmp (argv[N], "rings")) {
     38      MODE = RINGS;
     39    }
    3740    remove_argument (N, &argc, argv);
    3841  }
     
    140143
    141144  LEVEL = 8;
    142   if ((MODE != LOCAL) && (N = get_argument (argc, argv, "-level"))) {
    143     remove_argument (N, &argc, argv);
    144     LEVEL = strtol (argv[N], &ptr, 10);
    145     remove_argument (N, &argc, argv);
    146     if ((*ptr != 0) || (LEVEL < 0)) {
    147       fprintf (stderr, "-level requires an integer (>= 0) argument\n");
     145  if ((MODE == SQUARES) || (MODE == TRIANGLES)) {
     146    if ((N = get_argument (argc, argv, "-level"))) {
     147      remove_argument (N, &argc, argv);
     148      LEVEL = strtol (argv[N], &ptr, 10);
     149      remove_argument (N, &argc, argv);
     150      if ((*ptr != 0) || (LEVEL < 0)) {
     151        fprintf (stderr, "-level requires an integer (>= 0) argument\n");
     152        help ();
     153      } 
     154    }
     155  }
     156
     157  CELLSIZE = 4.0;
     158  if ((MODE == RINGS) && (N = get_argument (argc, argv, "-cellsize"))) {
     159    remove_argument (N, &argc, argv);
     160    CELLSIZE = strtod (argv[N], &ptr);
     161    if ((*ptr != 0) || (CELLSIZE < 0.0)) {
     162      fprintf (stderr, "-level requires a floating-point argument\n");
    148163      help ();
    149164    } 
     165    remove_argument (N, &argc, argv);
    150166  }
    151167
  • branches/cnb_branches/cnb_branch_20090215/Ohana/src/addstar/src/sky_tessalation.c

    r21536 r23199  
    1111  sky_tessellation_init (scale);
    1212
    13   if (mode == SQUARES) {
    14     sky_tessellation_squares (db, level, Nmax);
    15     return TRUE;
    16   }
    17 
    18   if (mode == TRIANGLES) {
    19     sky_tessellation_triangles (db, level, Nmax);
    20     return TRUE;
    21   }
    22 
    23   if (mode == LOCAL) {
    24     sky_tessellation_local (db, level, Nmax);
    25     return TRUE;
     13  switch (mode) {
     14    case SQUARES:
     15      sky_tessellation_squares (db, level, Nmax);
     16      return TRUE;
     17    case TRIANGLES:
     18      sky_tessellation_triangles (db, level, Nmax);
     19      return TRUE;
     20    case LOCAL:
     21      sky_tessellation_local (db, level, Nmax);
     22      return TRUE;
     23    case RINGS:
     24      sky_tessellation_rings (db, level, Nmax);
     25      return TRUE;
     26    default:
     27      break;
    2628  }
    2729
     
    222224
    223225  free (image);
     226  return (TRUE);
     227}
     228
     229// the RINGS tessellation uses the declination zones proposed by Tamas Budavari
     230// we generate projects on uniform rings of constant dec height
     231int sky_tessellation_rings (FITS_DB *db, int level, int Nmax) {
     232
     233  int j, nDEC, Nimage, Nring;
     234  float dec, dDEC;
     235  SkyRectangle *ring;
     236  Image *image;
     237
     238  // The tessellation has one input parameter: the approximate cell size.  Starting with
     239  // the cell size, determine the optimal projection cell height (dDEC) that results in an
     240  // integer number of dec zones between -90 and +90
     241
     242  nDEC = 180.0 / CELLSIZE;
     243  dDEC = 180.0 / nDEC;
     244
     245  // generate the a collection of rectangles for each ring
     246  for (dec = -90.0 + 0.5*dDEC; dec < +90.0; dec += dDEC) {
     247
     248    ring = sky_rectangle_ring (dec, dDEC, &Nring);
     249
     250    // subdivide each image (Nx x Ny subcells)
     251    Nimage = NX_SUB*NY_SUB*Nring;
     252    ALLOCATE (image, Image, Nimage);
     253    for (j = 0; j < Nring; j++) {
     254      // convert the SkyRectangles to Images for output
     255      sky_subdivide_image (&image[j*NX_SUB*NY_SUB], &ring[j], NX_SUB, NY_SUB);
     256    }
     257
     258    /* add the new images and save */
     259    dvo_image_addrows (db, image, Nimage);
     260    SetProtect (TRUE);
     261    dvo_image_update (db, VERBOSE);
     262    SetProtect (FALSE);
     263    dvo_image_clear_vtable (db);
     264   
     265    free (ring);
     266    free (image);
     267  }   
    224268  return (TRUE);
    225269}
     
    480524
    481525  return (TRUE);
     526}
     527
     528// define the parameters of a single sky projection center
     529SkyRectangle *sky_rectangle_ring (float dec, float dDEC, int *nring) {
     530
     531  int i, nRA, NX, NY;
     532  float dRA, decLower;
     533  SkyRectangle *ring;
     534
     535  // 'dec' is a guess at the center of the cell; in fact, we need to choose decLower and
     536  // decUpper to ensure complete overlap of the cells
     537
     538  // 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
     544
     545  // I think we need to return the value of dec for the next ring, but I am not sure...
     546
     547  ALLOCATE (ring, SkyRectangle, nRA);
     548
     549  for (i = 0; i < nRA; i++) {
     550    memset (&ring[i], 0, sizeof(SkyRectangle));
     551    memset (&ring[i].coords, 0, sizeof(Coords));
     552    ring[i].coords.crval1 = i*dRA;
     553    ring[i].coords.crval2 = dec;
     554
     555    ring[i].coords.pc1_1 = +1.0;
     556    ring[i].coords.pc1_2 = +0.0;
     557    ring[i].coords.pc2_1 = -0.0;
     558    ring[i].coords.pc2_2 = +1.0;
     559 
     560    // range values are in projected degrees
     561    NX = cos(dec*RAD_DEG) * dRA  * 3600.0 / SCALE;
     562    NY =                    dDEC * 3600.0 / SCALE;
     563
     564    // crpix1,crpix2 is the projection center
     565    ring[i].coords.crpix1 = 0.5*NX;
     566    ring[i].coords.crpix2 = 0.5*NY;
     567
     568    ring[i].coords.cdelt1 = SCALE / 3600.0;
     569    ring[i].coords.cdelt2 = SCALE / 3600.0;
     570
     571    strcpy (ring[i].coords.ctype, "DEC--TAN");
     572
     573    ring[i].NX = NX;
     574    ring[i].NY = NY;
     575    ring[i].photcode = 1; // this needs to be set more sensibly
     576
     577
     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);
     581  }
     582
     583  *nring = nRA;
     584  return (ring);
    482585}
    483586
  • branches/cnb_branches/cnb_branch_20090215/PS-IPP-Config/lib/PS/IPP/Config.pm

    r21320 r23199  
    7171    unless (defined $class) {
    7272        carp "Programming error";
    73         exit($PS_EXIT_PROG_ERROR);
     73        return undef;
    7474    }
    7575
     
    8585    unless (open $file, $name) {
    8686        carp "Unable to open ipprc file $name: $!";
    87         exit($PS_EXIT_CONFIG_ERROR);
     87        return undef;
    8888    }
    8989    my @contents = <$file>;        # Contents of the ipprc file
     
    9595    unless (defined $path) {
    9696        carp "PATH is not set in $name\n";
    97         exit($PS_EXIT_CONFIG_ERROR);
     97        return undef;
    9898    }
    9999
     
    112112    bless $self, $class;
    113113
    114     $self->load_site();
    115     $self->load_system();
    116 
    117     $self->define_camera($camera) if defined $camera;
     114    $self->load_site() or return undef;
     115    $self->load_system() or return undef;
     116
     117    ( $self->define_camera($camera) or return undef ) if defined $camera;
    118118
    119119    return $self;
     
    148148                unless ($found) {
    149149                    carp "Unable to find camera configuration file $filename\n";
    150                     exit($PS_EXIT_CONFIG_ERROR);
     150                    return undef;
    151151                }
    152152            }
     
    158158
    159159    carp "Unable to find configuration file: $filename";
    160     exit($PS_EXIT_CONFIG_ERROR);
     160    return undef;
    161161}
    162162
     
    170170    unless (defined $self) {
    171171        carp "Programming error";
    172         exit($PS_EXIT_PROG_ERROR);
     172        return undef;
    173173    }
    174174
     
    176176    unless (defined $filename) {
    177177        carp "Unable to find site configuration file\n";
    178         exit($PS_EXIT_CONFIG_ERROR);
     178        return undef;
    179179    }
    180180
    181181    my $realfile = $self->_find_config($filename); # Resolved filename, after hunting the PATH
     182    ( carp "Unable to find site configuration" and return undef ) unless defined $realfile;
    182183
    183184    # Read the file
     
    185186    unless (open $file, $realfile) {
    186187        carp "Unable to open site configuration file $realfile: $!";
    187         exit($PS_EXIT_CONFIG_ERROR);
     188        return undef;
    188189    }
    189190
     
    194195    unless (defined $self->{_siteConfig}) {
    195196        carp "Failure to parse the site configuration file $realfile";
    196         exit($PS_EXIT_CONFIG_ERROR);
     197        return undef;
    197198    }
    198199
     
    207208    unless (defined $self) {
    208209        carp "Programming error";
    209         exit($PS_EXIT_PROG_ERROR);
     210        return undef;
    210211    }
    211212
     
    213214    unless (defined $filename) {
    214215        carp "Unable to find system configuration file\n";
    215         exit($PS_EXIT_CONFIG_ERROR);
     216        return undef;
    216217    }
    217218
    218219    my $realfile = $self->_find_config($filename); # Resolved filename, after hunting the PATH
     220    ( carp "Unable to find system configuration" and return undef ) unless defined $realfile;
    219221
    220222    # Read the file
     
    222224    unless (open $file, $realfile) {
    223225        carp "Unable to open system configuration file $realfile: $!";
    224         exit($PS_EXIT_CONFIG_ERROR);
     226        return undef;
    225227    }
    226228    my @contents = <$file>;
     
    230232    unless (defined $self->{_systemConfig}) {
    231233        carp "Failure to define system configuration";
    232         exit($PS_EXIT_CONFIG_ERROR);
     234        return undef;
    233235    }
    234236
     
    244246    unless (defined $self and defined $name) {
    245247        carp "Programming error";
    246         exit($PS_EXIT_PROG_ERROR);
     248        return undef;
    247249    }
    248250
     
    251253    unless (defined $filename) {
    252254        carp "Unable to find configuration file for camera $name\n";
    253         exit($PS_EXIT_CONFIG_ERROR);
     255        return undef;
    254256    }
    255257
    256258    my $realfile = $self->_find_config($filename); # Resolved filename, after hunting the PATH
     259    ( carp "Unable to find camera configuration" and return undef ) unless defined $realfile;
    257260
    258261    # Read the file
     
    260263    unless (open $file, $realfile) {
    261264        carp "Unable to open camera configuration file $realfile: $!";
    262         exit($PS_EXIT_CONFIG_ERROR);
     265        return undef;
    263266    }
    264267    my @contents = <$file>;
     
    269272    unless (defined $self->{camera}) {
    270273        carp "Failure to define camera";
    271         exit($PS_EXIT_CONFIG_ERROR);
     274        return undef;
    272275    }
    273276
     
    326329    unless (defined $self and defined $name) {
    327330        carp "Programming error";
    328         exit($PS_EXIT_PROG_ERROR);
     331        return undef;
    329332    }
    330333
     
    333336    unless (defined $pathname) {
    334337        carp "Unable to find datapath $name\n" ;
    335         exit($PS_EXIT_CONFIG_ERROR);
     338        return undef;
    336339    }
    337340
     
    340343
    341344# convert the database name and the table ID to a image source id
    342 sub source_id 
     345sub source_id
    343346{
    344347    my $self = shift;
     
    351354    my $admindb = "ippadmin";
    352355
    353     die "dbserver not defined in configuration" unless defined($dbserver);
    354     die "dbuser not defined in configuration" unless defined($dbuser);
    355     die "dbpassword not defined in configuration" unless defined($dbpassword);
    356     die "dbname not defined in configuration" unless defined($dbname);
     356    ( carp "dbserver not defined in configuration"  and return undef ) unless defined($dbserver);
     357    ( carp "dbuser not defined in configuration"  and return undef ) unless defined($dbuser);
     358    ( carp "dbpassword not defined in configuration"  and return undef ) unless defined($dbpassword);
     359    ( carp "dbname not defined in configuration"  and return undef ) unless defined($dbname);
    357360
    358361    my $dsn = "DBI:mysql:host=$dbserver;database=$admindb";
     
    363366    $stmt->execute();
    364367    my $ref = $stmt->fetchrow_hashref();
    365     die "ippdb $dbname not found" unless ($ref);
     368    ( carp "ippdb $dbname not found" and return undef ) unless ($ref);
    366369
    367370    my $proj_id = $ref->{proj_id};
     
    382385    if ($@) {
    383386        carp "Can't find Nebulous::Client.";
    384         exit($PS_EXIT_PROG_ERROR);
     387        return undef;
    385388    }
    386389
     
    390393    unless (defined $server) {
    391394        carp "Unable to find NEB_SERVER in camera configuration file.";
    392         exit($PS_EXIT_CONFIG_ERROR);
    393     }
    394 
    395     my $neb = Nebulous::Client->new( proxy => $server );
    396     unless (defined $neb) {
     395        return undef;
     396    }
     397
     398    my $neb = eval { Nebulous::Client->new( proxy => $server ); };
     399    if ($@ or not defined $neb) {
    397400        carp "Unable to find NEB_SERVER in camera configuration file.";
    398         exit($PS_EXIT_CONFIG_ERROR);
     401        return undef;
    399402    }
    400403
     
    415418    if ($scheme) {
    416419        $scheme = lc($scheme);
    417         # print "scheme: $scheme\n";
     420        # print "scheme: $scheme\n";
    418421
    419422        if ($scheme eq 'neb') {
    420             $self->_neb_start();
     423            $self->_neb_start() or ( carp "Can't start Nebulous" and return undef );
    421424            my $neb = $self->{nebulous}; # Nebulous handle
    422425            if ($create_if_doesnt_exist) {
    423                 unless ($neb->stat( $name )) {
    424                     # print "entry $name not found, creating...\n";
    425                     my $uri = $neb->create( $name );
    426                     unless(defined $uri) {
     426                my $status = eval { $neb->stat( $name ); };
     427                ( carp "Unable to stat Nebulous handle $name" and return undef ) if $@;
     428                unless ($status) {
     429                    # print "entry $name not found, creating...\n";
     430                    my $uri = eval { $neb->create( $name ); };
     431                    if ($@ or not defined $uri) {
    427432                        carp "unable to instantiate $name.";
    428                         exit($PS_EXIT_DATA_ERROR);
     433                        return undef;
    429434                    }
    430435                    my $path = URI->new( $uri )->path;
    431                     # print "created path: $path\n";
     436                    # print "created path: $path\n";
    432437                    return $path;
    433438                }
    434439            }
    435             my $path = $neb->find( $name );
    436             if (not defined $path) {
    437                 carp "neb entry $name not found, not created\n";
    438                 exit($PS_EXIT_DATA_ERROR);
    439             }
    440             # print "found path: $path\n";
     440            my $path = eval { $neb->find( $name ); };
     441            if ($@ or not defined $path) {
     442                carp "neb entry $name not found, not created\n";
     443                return undef;
     444            }
     445            # print "found path: $path\n";
    441446            return $path;
    442447        }
     
    444449        if ($scheme eq 'path' or $scheme eq 'file') {
    445450            # guaranteed to have a scheme (path:// or file://)
    446             $name = $self->convert_filename_absolute( $name );
    447             # print "resolved path to $name\n";
     451            $name = $self->convert_filename_absolute( $name ) or return undef;
     452            # print "resolved path to $name\n";
    448453        }
    449454    }
     
    454459        if (! -e $dir) {
    455460            my $rc = system "mkdir -p $dir";
    456             die "failed to create directory for $name" unless (!$rc);
     461            ( carp "failed to create directory for $name" and return undef ) unless (!$rc);
    457462        } elsif (! -d $dir ) {
    458             die "parent for $name exists and is not a directory";
    459         }
    460 
    461         open F, ">$name" or die "failed to create $name";
     463            carp "parent for $name exists and is not a directory";
     464            return undef;
     465        }
     466
     467        open F, ">$name" or ( carp "failed to create $name" and return undef );
    462468        close F;
    463         # print "created target $name\n";
     469        # print "created target $name\n";
    464470    }
    465471
     
    473479    my $name = shift;                # File name to check
    474480
    475     $self->file_prepare( $name );
     481    $self->file_prepare( $name ) or return undef;
    476482
    477483    my $scheme = file_scheme($name); # The scheme, e.g., file://, path://
     
    479485        $scheme = lc($scheme);
    480486        if ($scheme eq 'neb') {
    481             $self->_neb_start();
    482             return $self->{nebulous}->open_create( $name );
     487            $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef );
     488            my $fh = eval { $self->{nebulous}->open_create( $name ); };
     489            if ($@ or not defined $fh) {
     490                carp "Unable to open/create Nebulous handle $name";
     491                return undef;
     492            }
     493            return $fh;
    483494        }
    484495        if ($scheme eq 'path' or $scheme eq 'file') {
    485496            # guaranteed to have a scheme (path:// or file://)
    486             $name = $self->convert_filename_absolute( $name );
     497            $name = $self->convert_filename_absolute( $name ) or return undef;
    487498        }
    488499    }
     
    490501    if (-f $name) {
    491502        carp "Unable to create file $name --- file exists.";
    492         exit($PS_EXIT_SYS_ERROR);
     503        return undef;
    493504    }
    494505
     
    496507    unless (open $fh, '>', $name) {
    497508        carp "Unable to create file $name --- $!";
    498         exit($PS_EXIT_SYS_ERROR);
     509        return undef;
    499510    }
    500511    return $fh;
     
    507518    my $name = shift;                # File name to check
    508519
    509     $self->file_prepare( $name );
     520    $self->file_prepare( $name ) or return undef;
    510521
    511522    my $scheme = file_scheme($name); # The scheme, e.g., file://, path://
     
    513524        $scheme = lc($scheme);
    514525        if ($scheme eq 'neb') {
    515             $self->_neb_start();
    516             return $self->{nebulous}->open_create( $name );
     526            $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef );
     527            my $fh = eval { $self->{nebulous}->open_create( $name ) };
     528            if ($@ or not defined $fh) {
     529                carp "Unable to open/create Nebulous handle $name";
     530                return undef;
     531            }
     532            return $fh;
    517533        }
    518534        if ($scheme eq 'path' or $scheme eq 'file') {
    519535            # guaranteed to have a scheme (path:// or file://)
    520             $name = $self->convert_filename_absolute( $name );
     536            $name = $self->convert_filename_absolute( $name ) or return undef;
    521537        }
    522538    }
     
    525541    unless (open $fh, '>>', $name) {
    526542        carp "Unable to create file $name --- $!";
    527         exit($PS_EXIT_SYS_ERROR);
     543        return undef;
    528544    }
    529545    return $fh;
     
    536552    my $name = shift;                # File name to check
    537553
    538     $self->file_prepare( $name );
     554    $self->file_prepare( $name ) or return undef;
    539555
    540556    my $scheme = file_scheme($name); # The scheme, e.g., file://, path://
    541557    if (defined $scheme and lc($scheme) eq 'neb') {
    542         $self->_neb_start();
    543         $name = $self->{nebulous}->create( $name );
     558        $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef );
     559        $name = eval { $self->{nebulous}->create( $name ) };
     560        if ($@ or not defined $name) {
     561            carp "Unable to create Nebulous handle $name";
     562            return undef;
     563        }
    544564    }
    545565
     
    555575    my $scheme = file_scheme($name); # The scheme, e.g., file://, path://
    556576    if (defined $scheme and lc($scheme) eq 'neb') {
    557         $self->_neb_start();
    558         return (defined $self->{nebulous}->find_instances( $name ) ? 1 : 0);
     577        $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef );
     578        my $found = eval { $self->{nebulous}->find_instances( $name ); };
     579        ( carp "Unable to find instances of Nebulous handle $name" and return undef ) if $@;
     580        return (defined $found ? 1 : 0);
    559581    }
    560582
     
    569591    my $target = shift;                # Name of target file
    570592
    571     $self->file_prepare( $target );
     593    $self->file_prepare( $target ) or return undef;
    572594
    573595    my $scheme = file_scheme($target); # The scheme, e.g., file://, path://
    574596    if (defined $scheme and lc($scheme) eq 'neb') {
    575         $self->_neb_start();
    576         $target = $self->{nebulous}->create( $target );
     597        $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef );
     598        $target = eval { $self->{nebulous}->create( $target ); };
     599        if ($@ or not defined $target) {
     600            carp "Unable to create Nebulous handle";
     601            return undef;
     602        }
    577603    }
    578604    $target = $self->file_resolve( $target );
    579605    $source = $self->file_resolve( $source );
    580606
    581     system("cp $source $target") == 0 or (carp "Can't copy file $source to $target." and
    582                                           exit($PS_EXIT_DATA_ERROR));
     607    system("cp $source $target") == 0 or ( carp "Can't copy file $source to $target." and return undef );
    583608    return 1;
    584609}
     
    593618    my $preserve = shift;
    594619
    595     die "pathname must be defined" unless ($pathname);
     620    ( carp "pathname must be defined" and return undef ) unless ($pathname);
    596621
    597622    my $fileRef;
     
    602627
    603628    if ($preserve) {
    604         # we want to keep the file just create it in the current directory 
     629        # we want to keep the file just create it in the current directory
    605630        $fileName = "./$base";
    606         open $fileRef, ">$fileName" or die "can't open $fileName for output";
     631        open $fileRef, ">$fileName" or ( carp "can't open $fileName for output" and return undef );
    607632    } else {
    608633        #  we really want a tempfile, so put it in /tmp
     
    621646    my $scheme = file_scheme($name); # The scheme, e.g., file://, path://
    622647    if (defined $scheme and lc($scheme) eq 'neb') {
    623         $self->_neb_start();
    624         $status = $self->{nebulous}->delete( $name );
     648        $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef );
     649        $status = eval { $self->{nebulous}->delete( $name ); };
     650        ( carp "Unable to delete Nebulous handle $name" and return undef ) if $@;
    625651    } else {
    626         my $resolved = $self->file_resolve($name);
    627         if ($resolved && -e $resolved) {
     652        my $resolved = $self->file_resolve($name) or return undef;
     653        if (defined $resolved and -e $resolved) {
    628654            $status = unlink($resolved);
    629655        }
     
    638664    my $name = shift;
    639665
    640     die "need name" unless $name;
     666    ( carp "need redirection target" and return undef ) unless $name;
    641667
    642668    my $filename = $self->file_resolve($name, 1);
    643669
    644     die "cannot resolve $name" unless $filename;
     670    ( carp "cannot resolve $name" and return undef ) unless $filename;
    645671
    646672    if (! open(STDOUT, ">>$filename") ) {
     
    651677        while (! open STDOUT, ">>$filename" ) {
    652678            if ($try == $max_tries) {
    653                 die "failed to redirect stdout to $filename after trying $max_tries times";
     679                carp "failed to redirect stdout to $filename after trying $max_tries times";
     680                return undef;
    654681            }
    655682            sleep 5;
     
    658685        print STDERR "   redirect stdout to $filename succeded on try $try\n";
    659686    }
    660     open STDERR, ">>$filename" or die "failed to redirect stderr to $filename";
     687    open STDERR, ">>$filename" or ( carp "failed to redirect stderr to $filename" and return undef );
     688
     689    return 1;
    661690}
    662691
     
    676705    my $name = shift;                # File name for which to prepare
    677706    my $workdir = shift;        # Working directory
    678     my $template = shift;        # Template filename from which to get working directory if 
     707    my $template = shift;        # Template filename from which to get working directory if
    679708
    680709    if (defined $workdir) {
     
    692721    # not guaranteed to have a scheme (path:// or file://) - might be /PATH/foobar
    693722    # a relative path (PATH/foobar) is invalid here
    694     my $resolved = $self->convert_filename_absolute( $name );
     723    my $resolved = $self->convert_filename_absolute( $name ) or return undef;
    695724    my ( $vol, $dirs, $file ) = File::Spec->splitpath( $resolved );
    696725    unless (-d $dirs) {
    697         system("mkdir -p $dirs") == 0 or (carp "Can't create directory $dirs" and exit($PS_EXIT_DATA_ERROR));
     726        system("mkdir -p $dirs") == 0 or ( carp "Can't create directory $dirs" and return undef );
    698727    }
    699728
     
    716745    # not guaranteed to have a scheme (path:// or file://) - might be /PATH/foobar
    717746    # a relative path (PATH/foobar) is invalid here
    718     my $resolved = $self->convert_filename_absolute( $outroot );
     747    my $resolved = $self->convert_filename_absolute( $outroot ) or return undef;
    719748    my ( $vol, $dirs, $file ) = File::Spec->splitpath( $resolved );
    720749    unless (-d $dirs) {
    721         system("mkdir -p $dirs") == 0 or (carp "Can't create directory $dirs" and exit($PS_EXIT_DATA_ERROR));
     750        system("mkdir -p $dirs") == 0 or ( carp "Can't create directory $dirs" and return undef );
    722751    }
    723752
     
    734763    unless (defined $self and defined $name) {
    735764        carp "Programming error";
    736         exit($PS_EXIT_PROG_ERROR);
     765        return undef;
    737766    }
    738767
     
    741770
    742771    ## if this is already an absolute path (/PATH/file), just return the path
    743     unless (defined $scheme) { 
     772    unless (defined $scheme) {
    744773        if ($name =~ m|^/|) { return $name; }
    745774        # without a leading slash, this is an error
    746775        carp "Relative file name provided: relative paths are not permitted.";
    747         exit($PS_EXIT_SYS_ERROR);
     776        return undef;
    748777    }
    749778
     
    751780
    752781    if (lc($scheme) eq 'file') {
    753         # the above strips of the leading slash; replace it for file:// 
     782        # the above strips of the leading slash; replace it for file://
    754783        $name = '/' . $name;
    755784        return $name;
     
    764793    }
    765794
    766     # looks like we cannot reach here without an invalid scheme. 
    767     # programming error?
    768     # return $name;
    769 
    770     carp "Programming error";
    771     exit($PS_EXIT_PROG_ERROR);
     795    # It's already absolute
     796    return $name;
    772797}
    773798
     
    777802    my $self = shift;                # Configuration object
    778803    my $name = shift;                # raw name
    779    
     804
    780805    unless (defined $self and defined $name) {
    781806        carp "Programming error";
    782         exit($PS_EXIT_PROG_ERROR);
    783     }
    784    
     807        return undef;
     808    }
     809
    785810    # First, check to see if it's already in a relative form
    786811    my $scheme = file_scheme($name); # The scheme, e.g., file, path
     
    790815            # We may as well search for a 'better' path
    791816            # guaranteed to have a scheme (path:// or file://)
    792             $name = $self->convert_filename_absolute( $name );
     817            $name = $self->convert_filename_absolute( $name ) or return undef;
    793818        } elsif ($scheme eq 'neb') {
    794819            # No chance of changing anything --- move along
     
    796821        }
    797822    }
    798    
     823
    799824    $name = File::Spec->canonpath( $name); # Clean up
    800825    my @dirs = File::Spec->splitdir( $name );
    801    
     826
    802827    my $path_list = metadataLookupMD($self->{_siteConfig}, 'DATAPATH'); # List of paths
    803828    my $best_path;
     
    809834      $path =~ s|/*$||;
    810835      my @path_dirs = File::Spec->splitdir( $path );
    811      
     836
    812837      # Check if the path is suitable
    813838      next if scalar @path_dirs > scalar @dirs;
     
    823848      }
    824849  }
    825    
     850
    826851    $name =~ s|^/||;
    827852    $name =~ s|/$||;
     
    845870    unless (defined $self and defined $name and defined $type) {
    846871        carp "Programming error";
    847         exit($PS_EXIT_PROG_ERROR);
     872        return undef;
    848873    }
    849874
     
    854879            return undef;
    855880        }
    856        
     881
    857882        # rejections are saved as a recipe: REJECTIONS
    858883        my @rejContents = `ppConfigDump -dump-recipe REJECTIONS -camera $camera -`;
    859        
     884
    860885        # load from resulting psMetadataConfig
    861886        $self->{rejection} = $parser->parse( join '', @rejContents); # The rejection metadata
    862887        unless (defined $self->{rejection}) {
    863888            carp "Unable to parse REJECTION recipe for $camera.";
    864             exit($PS_EXIT_CONFIG_ERROR);
     889            return undef;
    865890        }
    866891    }
     
    873898          unless ($item->{class} eq "metadata") {
    874899              carp "$name within REJECTIONS is not of type METADATA";
    875               exit($PS_EXIT_PROG_ERROR);
     900              return undef;
    876901          }
    877902          my $limits = $item->{value}; # List of rejection limits
     
    880905          foreach my $limit (@$limits) {
    881906              if ($limit->{name} eq 'FILTER') {
    882                   if ($limit->{value} eq '*' or
    883                       (defined $filter and
    884                        $limit->{value} eq $filter)) {
     907                  if ($limit->{value} eq '*' or (defined $filter and $limit->{value} eq $filter)) {
    885908                      last;
    886909                  }
     
    888911              }
    889912          }
    890          
     913
    891914          foreach my $limit (@$limits) {
    892915              return $limit->{value} if $limit->{name} eq $name;
     
    915938    unless (defined $self and defined $name and defined $output) {
    916939        carp "Programming error: required inputs left undefined";
    917         exit($PS_EXIT_PROG_ERROR);
     940        return undef;
    918941    }
    919942
     
    929952            return undef;
    930953        }
    931        
     954
    932955        $filerules = metadataLookup($camera, 'FILERULES');        # File rules
    933956        unless (defined $filerules) {
     
    935958            return undef;
    936959        }
    937        
     960
    938961        if ($filerules->{class} eq "scalar" and $filerules->{type} eq "STR") {
    939962            # Allow indirection to a file
    940963            my $filename = $self->_find_config($filerules->{value}); # Resolved filename
     964            ( carp "Unable to find file rules file" and return undef ) unless defined $filename;
     965
    941966            # Read the file
    942967            my $file;                # File handle
    943968            unless (open $file, $filename) {
    944969                carp "Unable to open filerules file $filename: $!";
    945                 exit($PS_EXIT_CONFIG_ERROR);
     970                return undef;
    946971            }
    947972            my @contents = <$file>;
     
    973998        unless (defined $component) {
    974999            carp "Programming error";
    975             exit($PS_EXIT_PROG_ERROR);
     1000            return undef;
    9761001        }
    9771002        $filename =~ s/\{CHIP\.NAME\}/$component/;
     
    9801005
    9811006    return $filename;
    982 }   
     1007}
    9831008
    9841009# Return an EXTNAME From the EXTNAME.RULE table in the camera configuration
     
    9911016    unless (defined $self and defined $name) {
    9921017        carp "Programming error";
    993         exit($PS_EXIT_PROG_ERROR);
     1018        return undef;
    9941019    }
    9951020
     
    10151040        unless (defined $component) {
    10161041            carp "Programming error";
    1017             exit($PS_EXIT_PROG_ERROR);
     1042            return undef;
    10181043        }
    10191044        $extname =~ s/\{CHIP\.NAME\}/$component/;
     
    10211046
    10221047    return $extname;
    1023 }   
     1048}
    10241049
    10251050# Return catdir for tessellation, from TESSELLATIONS within the site configuration
     
    10311056    unless (defined $self and defined $self->{_siteConfig} and defined $tess_id) {
    10321057        carp "Programming error";
    1033         exit($PS_EXIT_PROG_ERROR);
     1058        return undef;
    10341059    }
    10351060
     
    10371062    unless (defined $tessellations) {
    10381063        carp "Can't find TESSELLATIONS in site configuration.\n";
    1039         exit($PS_EXIT_CONFIG_ERROR);
     1064        return undef;
    10401065    }
    10411066
     
    10501075    if (defined $scheme and lc($scheme) eq 'neb') {
    10511076        carp "Tessellation $tess_id refers to a Nebulous path: $catdir\n";
    1052         exit($PS_EXIT_CONFIG_ERROR);
     1077        return undef;
    10531078    }
    10541079
     
    10651090    unless (defined $self and defined $self->{_siteConfig} and defined $dvodb) {
    10661091        carp "Programming error";
    1067         exit($PS_EXIT_PROG_ERROR);
     1092        return undef;
    10681093    }
    10691094
     
    10711096    unless (defined $catdirs) {
    10721097        carp "Can't find DVO.CATDIRS in site configuration.\n";
    1073         exit($PS_EXIT_CONFIG_ERROR);
     1098        return undef;
    10741099    }
    10751100
     
    10841109    if (defined $scheme and lc($scheme) eq 'neb') {
    10851110        carp "DVO catdir $dvodb refers to a Nebulous path: $catdir\n";
    1086         exit($PS_EXIT_CONFIG_ERROR);
     1111        return undef;
    10871112    }
    10881113
     
    10981123    unless (defined $self and defined $self->{_siteConfig} and defined $dvodb) {
    10991124        carp "Programming error";
    1100         exit($PS_EXIT_PROG_ERROR);
     1125        return undef;
    11011126    }
    11021127
     
    11041129    unless (defined $catdirs) {
    11051130        carp "Can't find PSASTRO.CATDIRS in site configuration.\n";
    1106         exit($PS_EXIT_CONFIG_ERROR);
     1131        return undef;
    11071132    }
    11081133
     
    11171142    if (defined $scheme and lc($scheme) eq 'neb') {
    11181143        carp "PSASTRO catdir $dvodb refers to a Nebulous path: $catdir\n";
    1119         exit($PS_EXIT_CONFIG_ERROR);
     1144        return undef;
    11201145    }
    11211146
     
    11301155    unless (defined $self) {
    11311156        carp "Programming error";
    1132         exit($PS_EXIT_PROG_ERROR);
     1157        return undef;
    11331158    }
    11341159
     
    11581183    unless (defined $self and defined $reduction and defined $name) {
    11591184        carp "Programming error --- inputs undefined";
    1160         exit($PS_EXIT_PROG_ERROR);
     1185        return undef;
    11611186    }
    11621187
     
    11801205            return undef;
    11811206        }
    1182        
     1207
    11831208        if ($reductionClasses->{class} eq "scalar" and $reductionClasses->{type} eq "STR") {
    11841209            # Allow indirection to a file
    11851210            my $filename = $self->_find_config($reductionClasses->{value}); # Resolved filename
     1211            ( carp "Unable to find reduction classes file" and return undef ) unless defined $filename;
    11861212            # Read the file
    11871213            my $file;                # File handle
    11881214            unless (open $file, $filename) {
    11891215                carp "Unable to open reductionClasses file $filename: $!";
    1190                 exit($PS_EXIT_CONFIG_ERROR);
     1216                return undef;
    11911217            }
    11921218            my @contents = <$file>;
     
    12031229
    12041230    my $class = metadataLookupMD($reductionClasses, $reduction) or # Class of interest
    1205         (carp "Can't find $reduction in REDUCTION in camera configuration.\n" and
    1206          exit($PS_EXIT_CONFIG_ERROR));
     1231        ( carp "Can't find $reduction in REDUCTION in camera configuration.\n" and return undef );
    12071232
    12081233    my $actual = metadataLookupStr($class, $name) or # The actual recipe name of interest
    1209         (carp "Can't find $name in $class in REDUCTION in camera configuration.\n" and
    1210          exit($PS_EXIT_CONFIG_ERROR));
     1234        (carp "Can't find $name in $class in REDUCTION in camera configuration.\n" and return undef );
    12111235
    12121236    return $actual;
     
    12261250    }
    12271251
    1228     my $dvoImageExtract = can_run('dvoImageExtract') or die "Can't find dvoImageExtract";
    1229    
     1252    my $dvoImageExtract = can_run('dvoImageExtract') or ( carp "Can't find dvoImageExtract" and return undef );
     1253
    12301254    my $tess_dir = $self->tessellation_catdir( $tess_id ); # Tessellation catdir for DVO
    12311255    unless (defined $tess_dir) {
    12321256        carp "Can't get list of tessellations.";
    1233         return 0;
    1234     }
    1235     $tess_dir = $self->convert_filename_absolute( $tess_dir );
     1257        return undef;
     1258    }
     1259    $tess_dir = $self->convert_filename_absolute( $tess_dir ) or return undef;
    12361260
    12371261    unless ($self->file_exists( $outname )) {
    1238         my $outnameResolved = $self->file_create( $outname ); # Resolved filename, for Nebulous
     1262        my $outnameResolved = $self->file_create( $outname ) or return undef; # Resolved filename, for Nebulous
    12391263        my $command = "$dvoImageExtract -D CATDIR $tess_dir $skycell_id -o $outnameResolved";
    12401264        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    12411265            run(command => $command, verbose => $verbose);
    1242         die "Unable to perform dvoImageExtract for $tess_id $skycell_id\n" unless ($success and $self->file_exists( $outname ));
     1266        ( carp "Unable to perform dvoImageExtract for $tess_id $skycell_id\n" and return undef ) unless ($success and $self->file_exists( $outname ));
    12431267    }
    12441268
     
    12581282        unless (defined $value) {
    12591283            carp "Unable to find environment variable $name";
    1260             exit($PS_EXIT_SYS_ERROR);
     1284            return undef;
    12611285        }
    12621286        $dir =~ s/\$\{?$name\}?/$value\//;
     
    12721296    unless (defined $mdc and defined $name) {
    12731297        carp "Programming error";
    1274         exit($PS_EXIT_PROG_ERROR);
     1298        return undef;
    12751299    }
    12761300
     
    12851309    return undef;
    12861310}
    1287    
     1311
    12881312
    12891313# Lookup the metadata, checking the type is STR
     
    13251349    unless (defined $mdc and defined $name) {
    13261350        carp "Programming error";
    1327         exit($PS_EXIT_PROG_ERROR);
     1351        return undef;
    13281352    }
    13291353
  • branches/cnb_branches/cnb_branch_20090215/ippMonitor/def/detStackedImfile.d

    r18193 r23199  
    1 TABLE detStackedImfile
     1TABLE detStackedImfile, detRun
    22TITLE detStackedImfile
    33FILE  detStackedImfile.php
    44MENU  ipp.imfiles.dat
    55
    6 #     field         size  format  name                   show  link to     extras
    7 FIELD det_id,         7,  %s,    det_id
    8 FIELD iteration,      5,  %s,    iteration
    9 FIELD class_id,       8,  %s,    class_id
    10 FIELD fault,          5,  %d,    fault
    11 FIELD bg,             8,  %f,    backgnd
    12 FIELD bg_stdev,       8,  %f,    stdev
    13 FIELD bg_mean_stdev,  8,  %f,    [stdev]
    14 FIELD uri,           20,  %s,    uri
     6WHERE detStackedImfile.det_id = detRun.det_id
     7
     8# XXX change uri to path_base in db
     9ARGS  ARG1 detStackedImfile.det_id=$det_id
     10ARGS  ARG1 detStackedImfile.iteration=$iteration
     11ARGS  ARG1 camera=$detRun.camera
     12ARGS  ARG1 basename=$detStackedImfile.uri
     13
     14#     field         size  format  name      show  link to     extras
     15FIELD detStackedImfile.det_id,         7,  %s,    det_id
     16FIELD detStackedImfile.iteration,      5,  %s,    iteration
     17FIELD detStackedImfile.class_id,       8,  %s,    class_id,   value, detStackedImfile.php, ARG1
     18FIELD detStackedImfile.fault,          5,  %d,    fault
     19FIELD detStackedImfile.bg,             8,  %f,    backgnd
     20FIELD detStackedImfile.bg_stdev,       8,  %f,    stdev
     21FIELD detStackedImfile.bg_mean_stdev,  8,  %f,    [stdev]
     22FIELD detStackedImfile.uri,           20,  %s,    uri
    1523# FIELD recipe, 20,   recipe
    1624
    1725TD_CLASS list_off $fault > 0
     26
     27TAIL PHP insert_log ('LOG.EXP');
  • branches/cnb_branches/cnb_branch_20090215/ippMonitor/raw/getimage.php

    r14128 r23199  
    2222putenv("PATH=$BINDIR:$PATH");
    2323
    24 # echo "args: $args<br>";
     24if ($debug) {
     25  echo "args: $args<br>";
     26  echo "path: $PATH<br>";
     27  echo "perl: $PERLLIB<br>";
     28}
    2529
    2630# $basename may contain filename@filerule
     
    3135
    3236# $filerule = strtok("@");
    33 # echo "basename: $basename<br>";
    34 # echo "filerule: $filerule<br>";
     37
     38if ($debug) {
     39  echo "basename: $basename<br>";
     40  echo "filerule: $filerule<br>";
     41}
    3542
    3643# need to supply the camera as well...
     
    4956$basename = escapeshellarg($basename);
    5057$basename = str_replace ('..','',$basename);
     58
     59if ($debug) {
     60  exec ("which ipp_filename.pl", $output, $status);
     61  echo "output:   $output[0]<br>";
     62  echo "status:   $status<br>";
     63
     64  exec ("whoami", $output, $status);
     65  echo "output:   $output[0]<br>";
     66  echo "status:   $status<br>";
     67}
    5168
    5269exec ("ipp_filename.pl --site=$SITE --basename $basename --filerule $filerule --camera $camera --class_id $class_id", $output, $status);
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/calibrate_dvo.pl

    r20100 r23199  
    5252my $caltool  = can_run('caltool')  or (warn "Can't find caltool"  and $missing_tools = 1);
    5353
    54 if ($missing_tools) { 
     54if ($missing_tools) {
    5555    warn ("Can't find required tools");
    56     exit($PS_EXIT_CONFIG_ERROR); 
     56    exit($PS_EXIT_CONFIG_ERROR);
    5757}
    5858
     
    7474        cache_run(command => $command, verbose => 1);
    7575
    76     unless ($success) { 
     76    unless ($success) {
    7777        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    7878        &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RESORT", $status, $dbname);
     
    8383{
    8484    foreach my $filter (@filters) {
    85         my $command = "$relphot $filter";
    86         $command .= "-D CATDIR $dvodb";
    87         $command .= "-region $RAs $RAe $DECs $DECe";
     85        my $command = "$relphot $filter";
     86        $command .= "-D CATDIR $dvodb";
     87        $command .= "-region $RAs $RAe $DECs $DECe";
    8888
    89         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    90             cache_run(command => $command, verbose => 1);
     89        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     90            cache_run(command => $command, verbose => 1);
    9191
    92         unless ($success) {
    93             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    94             &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELPHOT", $status, $dbname);
    95         }
     92        unless ($success) {
     93            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     94            &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELPHOT", $status, $dbname);
     95        }
    9696    }
    9797}
     
    101101if (0) {
    102102    foreach my $filter (@filters) {
    103         my $command = "$uniphot $filter";
    104         $command .= "-D CATDIR $dvodb";
    105         $command .= "-region $RAs $RAe $DECs $DECe";
     103        my $command = "$uniphot $filter";
     104        $command .= "-D CATDIR $dvodb";
     105        $command .= "-region $RAs $RAe $DECs $DECe";
    106106
    107         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    108             cache_run(command => $command, verbose => 1);
     107        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     108            cache_run(command => $command, verbose => 1);
    109109
    110         unless ($success) {
    111             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    112             &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "UNIPHOT", $status, $dbname);
    113         }
     110        unless ($success) {
     111            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     112            &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "UNIPHOT", $status, $dbname);
     113        }
    114114    }
    115115}
     
    121121
    122122    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    123         cache_run(command => $command, verbose => 1);
     123        cache_run(command => $command, verbose => 1);
    124124
    125     unless ($success) { 
    126         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    127         &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELASTRO.OBJECTS", $status, $dbname);
     125    unless ($success) {
     126        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     127        &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELASTRO.OBJECTS", $status, $dbname);
    128128    }
    129129}
     
    135135
    136136    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    137         cache_run(command => $command, verbose => 1);
     137        cache_run(command => $command, verbose => 1);
    138138
    139     unless ($success) { 
    140         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    141         &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELASTRO.IMAGES", $status, $dbname);
     139    unless ($success) {
     140        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     141        &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELASTRO.IMAGES", $status, $dbname);
    142142    }
    143143}
     
    169169    my $region    = shift;
    170170    my $last_step = shift;
    171     my $status    = shift;
    172     my $dbname    = shift;
     171    my $status    = shift;
     172    my $dbname    = shift;
    173173
    174174    carp($msg);
    175175    if (defined $cal_id && defined $region && defined $last_step && defined $status and not $no_update) {
    176176        my $command = "$caltool -addcalrun";
    177         $command .= " -cal_id $cal_id";
     177        $command .= " -cal_id $cal_id";
    178178        $command .= " -region $region";
    179         $command .= " -last_step $last_step";
    180         $command .= " -state $status";
     179        $command .= " -last_step $last_step";
     180        $command .= " -state $status";
    181181        $command .= " -dbname $dbname" if defined $dbname;
    182182        system ($command);
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/camera_exp.pl

    r23197 r23199  
    2222use PS::IPP::Config 1.01 qw( :standard );
    2323use File::Temp qw( tempfile );
    24 
    25 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2624
    2725use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    7068    defined $camera;
    7169
    72 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    73 $SIG{__DIE__} = sub { die @_ if $^S;
    74                       my_die( $_[0], $cam_id, $PS_EXIT_UNKNOWN_ERROR ); };
    75 
    76 $ipprc->define_camera($camera);
     70my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $cam_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    7771
    7872my $logDest = $ipprc->filename("LOG.EXP", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR);
     
    8478
    8579if ($redirect) {
    86     $ipprc->redirect_output($logDest);
     80    $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $cam_id, $PS_EXIT_SYS_ERROR );
    8781    print "\n\n";
    8882    print "Starting script $0 on $host\n\n";
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/chip_imfile.pl

    r23197 r23199  
    2020use PS::IPP::Metadata::Config;
    2121use PS::IPP::Config 1.01 qw( :standard );
    22 
    23 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2422
    2523use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    7068    defined $run_state;
    7169
    72 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    73 $SIG{__DIE__} = sub { die @_ if $^S;
    74                       my_die( $_[0], $exp_id, $chip_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); };
    75 
    76 $ipprc->define_camera($camera);
     70my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    7771
    7872my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
     
    8074
    8175if ($redirect) {
    82     $ipprc->redirect_output($logDest);
     76    $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR );
    8377    print STDOUT "\n\n";
    8478    print STDOUT "Starting script $0 on $host\n\n";
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_correct_imfile.pl

    r23197 r23199  
    1818use PS::IPP::Metadata::Config;
    1919use PS::IPP::Config 1.01 qw( :standard );
    20 
    21 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2220
    2321use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    6058    and defined $camera;
    6159
    62 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    63 $SIG{__DIE__} = sub { die @_ if $^S;
    64                       my_die( $_[0], $det_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); };
    65 
    66 # XXX this exits with status = 0 on failure
    67 $ipprc->define_camera($camera);
    68 
     60my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    6961if ($redirect) {
    7062    my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id)
    7163       or &my_die("Missing entry from camera config", $det_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    72     $ipprc->redirect_output($logDest);
     64    $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $det_id, $class_id, $PS_EXIT_SYS_ERROR );
    7365}
    7466
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_norm_apply.pl

    r23197 r23199  
    1717use PS::IPP::Metadata::Config;
    1818use PS::IPP::Config 1.01 qw( :standard );
    19 
    20 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2119
    2220use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    6462    defined $outroot;
    6563
    66 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    67 $SIG{__DIE__} = sub { die @_ if $^S;
    68                       my_die( $_[0], $det_id, $iter, $class_id, $PS_EXIT_UNKNOWN_ERROR ); };
    69 
    70 $ipprc->define_camera($camera);
     64my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    7165
    7266my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id)
    7367        or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR);
    74 $ipprc->redirect_output($logDest) if $redirect;
     68$ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    7569
    7670my $RECIPE_PPIMAGE = 'PPIMAGE_N'; # Recipe to use with ppImage
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_norm_calc.pl

    r23197 r23199  
    1919use PS::IPP::Metadata::List qw( parse_md_list );
    2020use PS::IPP::Config 1.01 qw( :standard );
    21 
    22 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2321
    2422use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    5755    defined $outroot;
    5856
    59 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    60 $SIG{__DIE__} = sub { die @_ if $^S;
    61                       my_die( $_[0], $det_id, $iter, $PS_EXIT_UNKNOWN_ERROR ); };
     57my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $det_id, $iter, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    6258
    6359my $logfile = $outroot . ".log";
    64 
    65 $ipprc->redirect_output($logfile) if $redirect;
     60$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $det_id, $iter, $PS_EXIT_SYS_ERROR ) if $redirect;
    6661
    6762use constant STATISTIC => 'bg'; # Background statistic to use from the database
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_norm_exp.pl

    r23197 r23199  
    1919use PS::IPP::Metadata::List qw( parse_md_list );
    2020use File::Temp qw( tempfile );
    21 
    22 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2321
    2422use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    6058    defined $outroot;
    6159
    62 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    63 $SIG{__DIE__} = sub { die @_ if $^S;
    64                       my_die( $_[0], $det_id, $iter, $PS_EXIT_UNKNOWN_ERROR ); };
    65 
     60my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $iter, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    6661my $logfile = $outroot . ".log";
    67 
    68 $ipprc->redirect_output($logfile) if $redirect;
    69 
    70 $ipprc->define_camera($camera);
     62$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $det_id, $iter, $PS_EXIT_SYS_ERROR ) if $redirect;
    7163
    7264# Recipes to use based on reduction class
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_process_exp.pl

    r23197 r23199  
    1919use PS::IPP::Metadata::List qw( parse_md_list );
    2020use File::Temp qw( tempfile );
    21 
    22 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2321
    2422use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    6361    defined $outroot;
    6462
    65 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    66 $SIG{__DIE__} = sub { die @_ if $^S;
    67                       my_die( $_[0], $det_id, $exp_id, $PS_EXIT_UNKNOWN_ERROR ); };
    68 
    69 $ipprc->define_camera($camera);
    70 
     63my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $exp_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    7164if ($redirect) {
    7265    my $logDest = $ipprc->filename("LOG.EXP", $outroot, "NONE")
    7366        or &my_die("Missing entry in file rules", $det_id, $exp_id, $PS_EXIT_CONFIG_ERROR);
    74     $ipprc->redirect_output($logDest);
     67    $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $det_id, $exp_id, $PS_EXIT_SYS_ERROR );
    7568}
    7669
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_process_imfile.pl

    r23197 r23199  
    1717use PS::IPP::Metadata::Config;
    1818use PS::IPP::Config 1.01 qw( :standard );
    19 
    20 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2119
    2220use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    6563    defined $outroot;
    6664
    67 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    68 $SIG{__DIE__} = sub { die @_ if $^S;
    69                       my_die( $_[0], $det_id, $exp_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); };
    70 
    71 # XXX this exits with status = 0 on failure
    72 $ipprc->define_camera($camera);
    73 
     65my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    7466my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    75 
    76 $ipprc->redirect_output($logDest) if $redirect;
     67$ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    7768
    7869# Recipes to use as a function of detrend type
     
    8172my $jpeg_recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_IMAGE'); # Recipe name for JPEG
    8273
     74# The output file rule name depends on the detrend type
     75my $FILERULES = { 'FLATMASK'         => undef,
     76                  'DARKMASK'         => undef,
     77                  'MASK'             => undef,
     78                  'BIAS'             => undef,
     79                  'DARK'             => undef,
     80                  'DARK_PREMASK'     => undef,
     81                  'SHUTTER'          => 'PPIMAGE.OUTPUT.DETREND',
     82                  'FLAT_PREMASK'     => 'PPIMAGE.OUTPUT.DETREND',
     83                  'DOMEFLAT_PREMASK' => 'PPIMAGE.OUTPUT.DETREND',
     84                  'SKYFLAT_PREMASK'  => 'PPIMAGE.OUTPUT.DETREND',
     85                  'FLAT_RAW'         => 'PPIMAGE.OUTPUT.DETREND',
     86                  'DOMEFLAT_RAW'     => 'PPIMAGE.OUTPUT.DETREND',
     87                  'SKYFLAT_RAW'      => 'PPIMAGE.OUTPUT.DETREND',
     88                  'FLAT'             => 'PPIMAGE.OUTPUT.DETREND',
     89                  'DOMEFLAT'         => 'PPIMAGE.OUTPUT.DETREND',
     90                  'SKYFLAT'          => 'PPIMAGE.OUTPUT.DETREND',
     91                  'FRINGE'           => undef,
     92              };
     93
    8394&my_die("Couldn't find input file: $input_uri\n", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input_uri);
    8495
     
    93104my $cmdflags;
    94105
    95 my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
     106my $filerule = $FILERULES->{$det_type}; # File rule to use for output
     107$filerule =  "PPIMAGE.OUTPUT" unless defined $filerule;
     108
     109my $outputImage = $ipprc->filename($filerule,        $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
    96110my $outputBin1  = $ipprc->filename("PPIMAGE.BIN1",   $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
    97111my $outputBin2  = $ipprc->filename("PPIMAGE.BIN2",   $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
    98112my $outputStats = $ipprc->filename("PPIMAGE.STATS",  $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
    99113my $traceDest   = $ipprc->filename("TRACE.IMFILE",   $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR);
     114
     115
    100116# Run ppImage
    101117unless ($no_op) {
     
    105121    $command .= " -recipe PPSTATS DETSTATS";
    106122    $command .= " -stats $outputStats";
     123    $command .= " -F PPIMAGE.OUTPUT $filerule" if $filerule ne "PPIMAGE.OUTPUT";
    107124    $command .= " -tracedest $traceDest -log $logDest";
    108125    $command .= " -threads $threads" if defined $threads;
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_reject_exp.pl

    r23197 r23199  
    2020use PS::IPP::Metadata::List qw( parse_md_list );
    2121use Statistics::Descriptive;
    22 
    23 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2422
    2523my $ITER_LIMIT = 20;
     
    6058    defined $outroot;
    6159
    62 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    63 $SIG{__DIE__} = sub { die @_ if $^S;
    64                       my_die( $_[0], $det_id, $iter, $PS_EXIT_UNKNOWN_ERROR ); };
    65 
    66 # check for existing directory, generate if needed
    67 $ipprc->outroot_prepare($outroot);
    68 
     60my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $det_id, $iter, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
     61$ipprc->outroot_prepare($outroot) or my_die( "Unable to prepare output root", $det_id, $iter, $PS_EXIT_SYS_ERROR );
    6962my $logName = "$outroot.log"; # Name for log
    70 
    71 $ipprc->redirect_output($logName) if $redirect;
     63$ipprc->redirect_output($logName) or my_die( "Unable to redirect", $det_id, $iter, $PS_EXIT_SYS_ERROR ) if $redirect;
    7264
    7365# values to extract from output metadata and the stats to calculate
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_resid_exp.pl

    r23197 r23199  
    3030use File::Temp qw( tempfile );                   # tools to construct temp files
    3131use PS::IPP::Config 1.01 qw( :standard );
    32 
    33 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    3432
    3533use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); # option parsing
     
    7977    defined $outroot;
    8078
    81 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    82 $SIG{__DIE__} = sub { die @_ if $^S;
    83                       my_die( $_[0], $det_id, $iter, $exp_id, $PS_EXIT_UNKNOWN_ERROR ); };
    84 
    8579# load IPP config information for the specified camera
    86 $ipprc->define_camera($camera);
    87 
     80my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $iter, $exp_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    8881my $logDest = $ipprc->filename("LOG.EXP", $outroot) or &my_die("Missing entry from camera config", $det_id, $iter, $exp_id, $PS_EXIT_CONFIG_ERROR);
    89 
    90 $ipprc->redirect_output($logDest) if $redirect;
     82$ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $det_id, $iter, $exp_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    9183
    9284# Recipes to use based on reduction class
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_resid_imfile.pl

    r23197 r23199  
    1717use PS::IPP::Metadata::Config;
    1818use PS::IPP::Config 1.01 qw( :standard );
    19 
    20 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2119
    2220use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    7674    defined $detrend;
    7775
    78 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    79 $SIG{__DIE__} = sub { die @_ if $^S;
    80                       my_die( $_[0], $det_id, $iter, $exp_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); };
    81 
    82 $ipprc->define_camera($camera);
    83 my $logDest     = $ipprc->filename("LOG.IMFILE", $outroot, $class_id);
    84 if ($redirect) {
    85     $ipprc->redirect_output($logDest);
    86 }
     76my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
     77my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or my_die( "Unable to find LOG.IMFILE", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR );
     78$ipprc->redirect_output($logDest) or my_die( "Unable to find LOG.IMFILE", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    8779
    8880# Recipes to use as a function of detrend type and mode
     
    124116};
    125117
     118# The output file rule name depends on the detrend type
     119my $FILERULES = { 'FLATMASK'         => 'PPIMAGE.OUTPUT.RESID',
     120                  'DARKMASK'         => 'PPIMAGE.OUTPUT.RESID',
     121                  'MASK'             => 'PPIMAGE.OUTPUT.RESID',
     122                  'BIAS'             => 'PPIMAGE.OUTPUT.RESID',
     123                  'DARK'             => 'PPIMAGE.OUTPUT.RESID',
     124                  'DARK_PREMASK'     => 'PPIMAGE.OUTPUT.RESID',
     125                  'SHUTTER'          => 'PPIMAGE.OUTPUT.DETREND',
     126                  'FLAT_PREMASK'     => 'PPIMAGE.OUTPUT.DETREND',
     127                  'DOMEFLAT_PREMASK' => 'PPIMAGE.OUTPUT.DETREND',
     128                  'SKYFLAT_PREMASK'  => 'PPIMAGE.OUTPUT.DETREND',
     129                  'FLAT_RAW'         => 'PPIMAGE.OUTPUT.DETREND',
     130                  'DOMEFLAT_RAW'     => 'PPIMAGE.OUTPUT.DETREND',
     131                  'SKYFLAT_RAW'      => 'PPIMAGE.OUTPUT.DETREND',
     132                  'FLAT'             => 'PPIMAGE.OUTPUT.DETREND',
     133                  'DOMEFLAT'         => 'PPIMAGE.OUTPUT.DETREND',
     134                  'SKYFLAT'          => 'PPIMAGE.OUTPUT.DETREND',
     135                  'FRINGE'           => 'PPIMAGE.OUTPUT.RESID',
     136              };
     137
    126138# outroot examples (HOST components must be set)
    127139# file://data/ipp004.0/gpc1/20080130
     
    135147# my $outputName  = $ipprc->filename("PPIMAGE.OUTPUT", $outroot, $class_id);
    136148
    137 my $outputName  = $ipprc->filename("PPIMAGE.OUTPUT.RESID", $outroot, $class_id);
     149my $filerule = $FILERULES->{$det_type}; # File rule to use
     150
     151my $outputName  = $ipprc->filename($filerule,        $outroot, $class_id);
    138152my $bin1Name    = $ipprc->filename("PPIMAGE.BIN1",   $outroot, $class_id);
    139153my $bin2Name    = $ipprc->filename("PPIMAGE.BIN2",   $outroot, $class_id);
     
    149163    $command .= " -recipe JPEG $jpeg_recipe";
    150164    $command .= " -recipe PPSTATS RESIDUAL";
    151     $command .= " -F PPIMAGE.OUTPUT PPIMAGE.OUTPUT.RESID";
     165    $command .= " -F PPIMAGE.OUTPUT $filerule";
    152166    $command .= " -stats $outputStats";
    153167    $command .= " -tracedest $traceDest -log $logDest";
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/detrend_stack.pl

    r23197 r23199  
    1818use PS::IPP::Metadata::List qw( parse_md_list );
    1919use PS::IPP::Config 1.01 qw( :standard );
    20 
    21 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2220
    2321use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    6361    defined $outroot;
    6462
    65 $ipprc->define_camera($camera);
    6663$det_type = uc($det_type);
    6764
     65my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    6866my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id)
    6967    or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR);
    70 
    71 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    72 $SIG{__DIE__} = sub { die @_ if $^S;
    73                       my_die( $_[0], $det_id, $iter, $class_id, $PS_EXIT_UNKNOWN_ERROR ); };
    74 
    75 # optionally redirect the outputs from this script to LOG.IMFILE
    76 $ipprc->redirect_output($logDest) if $redirect;
     68$ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    7769
    7870# Recipes to use as a function of detrend type
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/diff_skycell.pl

    r23197 r23199  
    2121use Data::Dumper;
    2222use PS::IPP::Config 1.01 qw( :standard );
    23 
    24 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2523
    2624use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    6260    and defined $outroot;
    6361
    64 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    65 $SIG{__DIE__} = sub { die @_ if $^S;
    66                       my_die( $_[0], $diff_id, $skycell_id, $PS_EXIT_UNKNOWN_ERROR ); };
     62my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $diff_id, $skycell_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    6763
    6864# XXX camera is not known here; cannot use filerules...
    6965# my $logDest = $ipprc->filename("LOG.EXP", $outroot);
    7066my $logDest = "$outroot.log";
    71 $ipprc->redirect_output($logDest) if $redirect;
     67$ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    7268
    7369my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_DIFF);
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/fake_imfile.pl

    r23197 r23199  
    3636use PS::IPP::Metadata::Config;
    3737use PS::IPP::Config 1.01 qw( :standard );
    38 
    39 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    4038
    4139use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    8280    defined $outroot;
    8381
    84 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    85 $SIG{__DIE__} = sub { die @_ if $^S;
    86                       my_die( $_[0], $exp_id, $fake_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); };
    87 
    88 $ipprc->define_camera($camera);
    89 
    90 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id)  or &my_die("Missing entry from camera config", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    91 
    92 $ipprc->redirect_output($logDest) if $redirect;
     82my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
     83my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR);
     84$ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $exp_id, $fake_id, $class_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    9385
    9486# Recipes to use based on reduction class
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/ipp_cleanup.pl

    r21371 r23199  
    1818use Pod::Usage qw( pod2usage );
    1919
    20 my $ipprc = PS::IPP::Config->new(); # this is used for PATH, NEB filename conversions
    21 
    2220# Parse the command-line arguments
    2321my ($stage, $camera, $stage_id, $mode, $path_base, $dbname, $verbose, $no_op, $helplist);
    2422GetOptions('stage=s'        => \$stage,     # which analysis stage to clean?
    25            'camera|i=s'     => \$camera,    # user-supplied camera name
    26            'stage_id=s'     => \$stage_id,  # id for this stage (only needed for certain stages)
    27            'mode|m=s'       => \$mode,      # cleanup mode (clean / purge)
    28            'path_base=s'    => \$path_base, # basename for files
    29            'dbname|d=s'     => \$dbname,    # Database name
     23           'camera|i=s'     => \$camera,    # user-supplied camera name
     24           'stage_id=s'     => \$stage_id,  # id for this stage (only needed for certain stages)
     25           'mode|m=s'       => \$mode,      # cleanup mode (clean / purge)
     26           'path_base=s'    => \$path_base, # basename for files
     27           'dbname|d=s'     => \$dbname,    # Database name
    3028           'verbose'        => \$verbose,   # Print to stdout
    31            'no-op'          => \$no_op,     # pretend but don't actually inject
    32            'helplist'       => \$helplist   # give help listing
    33            ) or pod2usage( 2 );
    34 
    35 pod2usage( -msg => "remove temporary / all data files for an IPP analysis stage", 
    36            -exitval => 2) if defined $helplist;
    37 
    38 pod2usage( -msg => "Usage: $0 --camera (name) --stage (stage) --stage_id (stage_id) --mode (mode) [--path_base (path)] [--dbname dbname] [--no-op] [--help]", 
    39            -exitval => 2 ) if scalar @ARGV;
     29           'no-op'          => \$no_op,     # pretend but don't actually inject
     30           'helplist'       => \$helplist   # give help listing
     31           ) or pod2usage( 2 );
     32
     33pod2usage( -msg => "remove temporary / all data files for an IPP analysis stage",
     34           -exitval => 2) if defined $helplist;
     35
     36pod2usage( -msg => "Usage: $0 --camera (name) --stage (stage) --stage_id (stage_id) --mode (mode) [--path_base (path)] [--dbname dbname] [--no-op] [--help]",
     37           -exitval => 2 ) if scalar @ARGV;
    4038
    4139pod2usage( -msg => "Required options:--camera (name) --stage (stage) --mode (mode)",
    42            -exitval => 3) unless
     40           -exitval => 3) unless
    4341    defined $camera and
    4442    defined $stage and
    4543    defined $mode;
    4644
    47 # $mode must be one of "goto_cleaned" or "goto_purged"
    48 unless (($mode eq "goto_cleaned") || ($mode eq "goto_purged")) {
    49     die "invalid cleanup mode $mode\n";   
     45my $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
     46
     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)
     50unless (($mode eq "goto_cleaned") || ($mode eq "goto_scrubbed") || ($mode eq "goto_purged")) {
     51    die "invalid cleanup mode $mode\n";
    5052}
    5153
     
    5557}
    5658
    57 $ipprc->define_camera($camera);
    58 
    5959my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    6060
    6161# choice of files to delete depends on the stage
    6262if ($stage eq "chip") {
    63    
     63
    6464    die "--stage_id required for stage chip\n" if !$stage_id;
    6565    ### select the imfiles for this entry
     
    8787    # loop over all of the imfiles, determine the path_base and class_id for each
    8888    foreach my $imfile (@$imfiles) {
    89         my $class_id = $imfile->{class_id};
    90         my $path_base = $imfile->{path_base};
     89        my $class_id = $imfile->{class_id};
     90        my $path_base = $imfile->{path_base};
    9191        my $status = 1;
    9292
    9393        # don't clean up unless the data needed to update is available
     94        # modes goto_purged and goto_scrubbed will remove files even if the config is non-existent
    9495        if ($mode eq "goto_cleaned") {
    9596            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id);
     
    124125                addFilename (\@files, "PPIMAGE.CONFIG", $path_base, $class_id);
    125126            }
    126        
     127
    127128            # actual command to delete the files
    128129            $status = &delete_files (\@files);
    129130        }
    130131
    131         if ($status)  {
    132             my $command = "$chiptool -chip_id $stage_id -class_id $class_id";
     132        if ($status)  {
     133            my $command = "$chiptool -chip_id $stage_id -class_id $class_id";
    133134            if ($mode eq "goto_purged") {
    134135                $command .= " -topurgedimfile";
     136            } elsif ($mode eq "goto_scrubbed") {
     137                $command .= " -tocleanedimfile_from_scrubbed";
    135138            } else {
    136139                $command .= " -tocleanedimfile";
    137140            }
    138             $command .= " -dbname $dbname" if defined $dbname;
    139 
    140             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     141            $command .= " -dbname $dbname" if defined $dbname;
     142
     143            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    141144                    run(command => $command, verbose => $verbose);
    142             unless ($success) {
    143                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    144                 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
    145             }
     145            unless ($success) {
     146                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     147                &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
     148            }
    146149        } else {
    147             my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -code 1";
    148             $command .= " -dbname $dbname" if defined $dbname;
    149 
    150             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     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;
     153
     154            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    151155                    run(command => $command, verbose => $verbose);
    152             unless ($success) {
    153                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    154                 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
    155             }
    156         }
    157     }
    158 
    159 } elsif ($stage eq "camera") {
     156            unless ($success) {
     157                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     158                &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
     159            }
     160        }
     161    }
     162    exit 0;
     163}
     164
     165if ($stage eq "camera") {
    160166    die "--stage_id required for stage camera\n" if !$stage_id;
    161167    # this stage uses 'camtool'
     
    236242    }
    237243    exit 0;
    238 } elsif ($stage eq "warp") {
     244}
     245
     246if ($stage eq "warp") {
    239247    die "--stage_id required for stage warp\n" if !$stage_id;
    240248    # this stage uses 'warptool'
     
    295303        }
    296304
    297         if ($status)  {
    298             my $command = "$warptool -warp_id $stage_id -skycell_id $skycell_id";
     305        if ($status)  {
     306            my $command = "$warptool -warp_id $stage_id -skycell_id $skycell_id";
    299307            if ($mode eq "goto_purged") {
    300308                $command .= " -topurgedskyfile";
     
    302310                $command .= " -tocleanedskyfile";
    303311            }
    304             $command .= " -dbname $dbname" if defined $dbname;
    305 
    306             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     312            $command .= " -dbname $dbname" if defined $dbname;
     313
     314            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    307315                    run(command => $command, verbose => $verbose);
    308             unless ($success) {
    309                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    310                 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
    311             }
     316            unless ($success) {
     317                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     318                &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
     319            }
    312320         } else {
    313321            # XXX: -updateskyfile mode does not exist, need to add it
    314             my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -code 1";
    315             $command .= " -dbname $dbname" if defined $dbname;
     322            my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -code 1";
     323            $command .= " -dbname $dbname" if defined $dbname;
    316324
    317325            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    318326                run(command => $command, verbose => $verbose);
    319             unless ($success) {
    320                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    321                 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
    322             }
     327            unless ($success) {
     328                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     329                &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
     330            }
    323331            exit $PS_EXIT_UNKNOWN_ERROR;
    324         }
     332        }
    325333    }
    326334    exit 0;
     
    334342die "ipp_cleanup.pl -stage $stage not yet implemented\n";
    335343
    336 sub delete_files 
     344sub delete_files
    337345{
    338346    my $files = shift; # reference to a list of files to unlink
    339    
    340     # this script is, of course, very dangerous. 
     347
     348    # this script is, of course, very dangerous.
    341349    foreach my $file (@$files) {
    342         print STDERR "unlinking $file\n";
     350        print STDERR "unlinking $file\n";
    343351        $ipprc->file_delete($file);
    344352    }
     
    346354}
    347355
    348 sub addFilename 
     356sub addFilename
    349357{
    350358    my $files      = shift; # reference to a list of files to unlink
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/ipp_maskscript.pl

    r17671 r23199  
    1212use PS::IPP::Config 1.01 qw( :standard );
    1313
    14 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    15 
    1614my ($dbname, $det_id, $camera);
    17 
    1815GetOptions('dbname=s'    => \$dbname,
    19            'det_id=s'    => \$det_id,
    20            'camera|c=s'  => \$camera,
    21            ) or pod2usage( 2 );
     16           'det_id=s'    => \$det_id,
     17           'camera|c=s'  => \$camera,
     18           ) or pod2usage( 2 );
    2219
    2320pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    2421
    2522pod2usage(
    26           -msg => "USAGE: ipp_maskscript.pl --dbname (name) --det_id (id) --iter (iteration) --camera (name)",
    27           -exitval => 3,
    28           ) unless defined $dbname and defined $det_id and defined $camera;
     23          -msg => "USAGE: ipp_maskscript.pl --dbname (name) --det_id (id) --iter (iteration) --camera (name)",
     24          -exitval => 3,
     25          ) unless defined $dbname and defined $det_id and defined $camera;
    2926
    3027# I could determine the camera from a query for the detrun
    31 $ipprc->define_camera($camera);
     28my $ipprc = PS::IPP::Config->new( $camera ) or my_die("Unable to setup", $PS_EXIT_CONFIG_ERROR); # IPP configuration
    3229
    3330###  Get list of dark imfile results
     
    4744
    4845# parse the output into a list
    49 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     46my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    5047my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    5148    &my_die("Unable to parse metadata config doc", $PS_EXIT_PROG_ERROR);
     
    8178    # print STDERR "contents: @contents\n";
    8279
    83     my $parser = PS::IPP::Metadata::Config->new;        # Parser for metadata config files
     80    my $parser = PS::IPP::Metadata::Config->new;        # Parser for metadata config files
    8481    my $statsList = $parser->parse(join "", @contents) or &my_die("Unable to parse metadata for imfile stats", $PS_EXIT_SYS_ERROR);
    8582
     
    110107    open (DATA, ">$component.dat");
    111108    for (my $i = 0; $i < @{$nameX}; $i++) {
    112         print DATA "${$nameX}[$i] ${$nameY}[$i]\n";
     109        print DATA "${$nameX}[$i] ${$nameY}[$i]\n";
    113110    }
    114111    close (DATA);
     
    147144    my ($exp_time, $tag, $md) = @_;
    148145
    149     # descend through the fpa       
     146    # descend through the fpa
    150147    foreach my $entry (@$md) {
    151         # print STDERR "name: $entry->{name}, class: $entry->{class}\n";
     148        # print STDERR "name: $entry->{name}, class: $entry->{class}\n";
    152149        # recurse on nested metadata
    153150        if ($entry->{class} eq 'metadata') {
    154             my $newtag = $tag . "_" . $entry->{name};
     151            my $newtag = $tag . "_" . $entry->{name};
    155152            &parse_stats_table ($exp_time, $newtag, $entry->{value});
    156153        }
     
    161158                push @bg_stdev_data, $entry->{value};
    162159            } else {
    163                 push @bg_name,    $tag;
     160                push @bg_name,    $tag;
    164161                push @bg_data,    $entry->{value};
    165                 push @bg_exptime, $exp_time;
    166                 # print STDERR "$tag $exp_time $entry->{value}\n";
     162                push @bg_exptime, $exp_time;
     163                # print STDERR "$tag $exp_time $entry->{value}\n";
    167164            }
    168             if (!$componentsHash{$tag}) {
    169                 push @components, $tag;
    170                 $componentsHash{$tag} = 1;
    171             }
    172             next;
    173         }
     165            if (!$componentsHash{$tag}) {
     166                push @components, $tag;
     167                $componentsHash{$tag} = 1;
     168            }
     169            next;
     170        }
    174171    }
    175172    return 1;
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/magic_definerun.pl

    r21006 r23199  
    2525use PS::IPP::Config 1.01 qw( :standard );
    2626
    27 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    28 
    2927use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    3028use Pod::Usage qw( pod2usage );
    3129
     30# Look for programs we need
     31my $missing_tools;
     32my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
     33my $difftool  = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1);
     34my $warptool  = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1);
     35if ($missing_tools) {
     36    warn("Can't find required tools.");
     37    exit($PS_EXIT_CONFIG_ERROR);
     38}
     39
    3240# Parse the command-line arguments
    3341my ($exp_id, $warp_id, $min_diff_id, $label, $workdir, $dbname, $save_temps, $verbose);
    34 
    3542GetOptions(
    3643           'exp_id=s'        => \$exp_id,     # exposure identifier
     
    5057    defined $warp_id;
    5158
    52 # $ipprc->define_camera($camera);
    53 
    54 # Look for programs we need
    55 my $missing_tools;
    56 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
    57 my $difftool  = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1);
    58 my $warptool  = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1);
    59 if ($missing_tools) {
    60     warn("Can't find required tools.");
    61     exit($PS_EXIT_CONFIG_ERROR);
    62 }
     59my $ipprc = PS::IPP::Config->new() or my_die("Unable to set up", $PS_EXIT_CONFIG_ERROR); # IPP configuration
    6360
    6461my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/magic_destreak.pl

    r23197 r23199  
    2121
    2222use PS::IPP::Config 1.01 qw( :standard );
    23 
    24 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2523
    2624use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    7674    defined $outroot;
    7775
    78 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    79 $SIG{__DIE__} = sub { die @_ if $^S;
    80                       my_die( $_[0], $magic_ds_id, $component, $PS_EXIT_UNKNOWN_ERROR ); };
    81 
     76my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
     77$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR ) if $logfile;
    8278
    8379my ($skycell_args, $class_id, $skycell_id);
     
    9490    &my_die("Invalid value for stage: $stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    9591}
    96 
    97 $ipprc->redirect_output($logfile) if $logfile;
    98 
    99 $ipprc->define_camera($camera);
    100 
    10192
    10293my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/magic_mask.pl

    r23197 r23199  
    2222
    2323use PS::IPP::Config 1.01 qw( :standard );
    24 
    25 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2624
    2725use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    5856    defined $outroot;
    5957
    60 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    61 $SIG{__DIE__} = sub { die @_ if $^S;
    62                       my_die( $_[0], $magic_id, $PS_EXIT_UNKNOWN_ERROR ); };
    63 
    64 $ipprc->define_camera($camera);
    65 
    66 $ipprc->redirect_output($logfile) if $logfile;
     58my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
     59$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_id, $PS_EXIT_SYS_ERROR ) if $logfile;
    6760
    6861my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/magic_process.pl

    r23197 r23199  
    2323
    2424use PS::IPP::Config 1.01 qw( :standard );
    25 
    26 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2725
    2826use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    6260    defined $outroot;
    6361
    64 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    65 $SIG{__DIE__} = sub { die @_ if $^S;
    66                       my_die( $_[0], $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR ); };
    67 
    68 $ipprc->define_camera($camera);
     62my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_id, $node, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
     63$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_id, $node, $PS_EXIT_SYS_ERROR ) if $logfile;
    6964
    7065# RemoveStreaks doesn't know about nebulous. It expects to be able to append strings to outroot
     
    7368# of the file names as arguments
    7469if ($outroot =~ 'neb:/') {
    75     &my_die("RemoveStreaks does not support nebulous paths in outroot", $magic_id, $node,
    76         $PS_EXIT_CONFIG_ERROR);
     70    &my_die("RemoveStreaks does not support nebulous paths in outroot", $magic_id, $node, $PS_EXIT_CONFIG_ERROR);
    7771}
    7872
    7973# resolve any path:// or file:// in outroot
    8074$outroot = $ipprc->file_resolve($outroot);
    81 
    82 $ipprc->redirect_output($logfile) if $logfile;
    8375
    8476my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/magic_tree.pl

    r23197 r23199  
    2424use File::Temp qw( tempfile );
    2525use PS::IPP::Config 1.01 qw( :standard );
    26 
    27 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2826
    2927use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    7068    defined $outroot;
    7169
    72 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    73 $SIG{__DIE__} = sub { die @_ if $^S;
    74                       my_die( $_[0], $magic_id, $PS_EXIT_UNKNOWN_ERROR ); };
    75 
    76 $ipprc->define_camera($camera);
    77 
    78 $ipprc->redirect_output($logfile) if $logfile;
     70my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
     71$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_id, $PS_EXIT_SYS_ERROR ) if $logfile;
    7972
    8073my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/register_exp.pl

    r23197 r23199  
    2424use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2525use Pod::Usage qw( pod2usage );
    26 
    27 my $ipprc = PS::IPP::Config->new();
    2826
    2927# Look for commands we need
     
    5351) or pod2usage( 2 );
    5452
    55 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    56 $SIG{__DIE__} = sub { die @_ if $^S;
    57                       my_die( $_[0], $exp_id, $PS_EXIT_UNKNOWN_ERROR ); };
    58 
    59 $ipprc->redirect_output($logfile) if $logfile;
     53my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $exp_id, $PS_EXIT_CONFIG_ERROR );
     54$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $exp_id, $PS_EXIT_SYS_ERROR ) if $logfile;
    6055
    6156pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/register_imfile.pl

    r23197 r23199  
    2323use Math::Trig;
    2424
    25 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2625use File::Spec;
    2726
     
    4948) or pod2usage( 2 );
    5049
    51 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    52 $SIG{__DIE__} = sub { die @_ if $^S;
    53                       my_die( $_[0], $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_UNKNOWN_ERROR ); };
    54 
    55 $ipprc->redirect_output($logfile) if $logfile;
     50my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
     51$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_SYS_ERROR ) if $logfile;
    5652
    5753pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/stack_skycell.pl

    r23197 r23199  
    2424use File::Basename;
    2525use PS::IPP::Config 1.01 qw( :standard );
    26 
    27 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2826
    2927use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    6664    and defined $run_state;
    6765
    68 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    69 $SIG{__DIE__} = sub { die @_ if $^S;
    70                       my_die( $_[0], $stack_id, $PS_EXIT_UNKNOWN_ERROR ); };
     66my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $stack_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    7167
    7268# XXX camera is not known here; cannot use filerules...
     
    8177}
    8278
    83 $ipprc->redirect_output($logDest) if $redirect;
     79$ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $stack_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    8480
    8581my $temp_images_exist = 0;
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/warp_overlap.pl

    r23197 r23199  
    2323use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2424use Pod::Usage qw( pod2usage );
    25 
    26 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2725
    2826# Look for programs we need
     
    4947) or pod2usage( 2 );
    5048
    51 $ipprc->redirect_output($logfile) if $logfile;
    52 
    5349pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    5450pod2usage(
     
    5955    and defined $tess_dir;
    6056
    61 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    62 $SIG{__DIE__} = sub { die @_ if $^S;
    63                       my_die( $_[0], $warp_id, $PS_EXIT_UNKNOWN_ERROR ); };
    64 
    65 $ipprc->define_camera($camera);
     57my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $warp_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
     58$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $warp_id, $PS_EXIT_SYS_ERROR ) if $logfile;
    6659
    6760&my_die("Tessellation identifier not provided: $tess_dir", $warp_id, $PS_EXIT_SYS_ERROR) unless $tess_dir ne "NULL";
  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/warp_skycell.pl

    r23197 r23199  
    2424use PS::IPP::Metadata::List qw( parse_md_list );
    2525use PS::IPP::Config 1.01 qw( :standard );
    26 
    27 my $ipprc = PS::IPP::Config->new(); # IPP configuration
    2826
    2927# Look for programs we need
     
    6866    and defined $run_state;
    6967
    70 # Unhandled exceptions should be passed on to my_die so they get pushed into the database
    71 $SIG{__DIE__} = sub { die @_ if $^S;
    72                       my_die( $_[0], $warp_id, $skycell_id, $tess_dir, $PS_EXIT_UNKNOWN_ERROR ); };
    73 
    74 $ipprc->define_camera($camera);
    75 
    76 my $logDest = $ipprc->filename("LOG.EXP", $outroot, $skycell_id);
     68my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
     69
     70my $logDest = $ipprc->filename("LOG.EXP", $outroot, $skycell_id) or my_die( "Unable to get log filename", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR );
    7771$logDest .= ".update" if ($run_state eq 'update');
    7872
    79 $ipprc->redirect_output($logDest) if $redirect;
     73$ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR ) if $redirect;
    8074
    8175my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_WARP);
  • branches/cnb_branches/cnb_branch_20090215/ippTools/share/chiptool_pendingcleanupimfile.sql

    r19527 r23199  
    1515    ((chipRun.state = 'goto_cleaned' AND chipProcessedImfile.data_state = 'full')
    1616OR
     17    (chipRun.state = 'goto_scrubbed' AND chipProcessedImfile.data_state = 'full')
     18OR
    1719    (chipRun.state = 'goto_purged' AND chipProcessedImfile.data_state != 'purged'))
  • branches/cnb_branches/cnb_branch_20090215/ippTools/share/chiptool_pendingcleanuprun.sql

    r19527 r23199  
    77USING (exp_id)
    88WHERE
    9     (chipRun.state = 'goto_cleaned' OR chipRun.state = 'goto_purged')
     9    (chipRun.state = 'goto_cleaned' OR chipRun.state = 'goto_scrubbed' OR chipRun.state = 'goto_purged')
  • branches/cnb_branches/cnb_branch_20090215/ippTools/share/dettool_todetrunsummary.sql

    r14078 r23199  
    4040        AND detRunSummary.det_id IS NULL
    4141        AND detRunSummary.iteration IS NULL
     42        AND detResidExp.fault = 0
    4243    GROUP BY
    4344        detRun.det_id,
  • branches/cnb_branches/cnb_branch_20090215/ippTools/src/chiptool.c

    r21536 r23199  
    5252static bool runMode(pxConfig *config);
    5353static bool tocleanedimfileMode(pxConfig *config);
     54static bool tocleanedimfile_from_scrubbedMode(pxConfig *config);
    5455static bool tofullimfileMode(pxConfig *config);
    5556static bool topurgedimfileMode(pxConfig *config);
     
    9192        MODECASE(CHIPTOOL_MODE_RUN,                     runMode);
    9293        MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE,         tocleanedimfileMode);
     94        MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedMode);
    9395        MODECASE(CHIPTOOL_MODE_TOFULLIMFILE,            tofullimfileMode);
    9496        MODECASE(CHIPTOOL_MODE_TOPURGEDIMFILE,          topurgedimfileMode);
     
    12451247    return change_imfile_data_state(config, "cleaned", "goto_cleaned");
    12461248}
     1249static bool tocleanedimfile_from_scrubbedMode(pxConfig *config)
     1250{
     1251    return change_imfile_data_state(config, "cleaned", "goto_scrubbed");
     1252}
    12471253static bool tofullimfileMode(pxConfig *config)
    12481254{
  • branches/cnb_branches/cnb_branch_20090215/ippTools/src/chiptool.h

    r21536 r23199  
    4343    CHIPTOOL_MODE_RUN,
    4444    CHIPTOOL_MODE_TOCLEANEDIMFILE,
     45    CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED,
    4546    CHIPTOOL_MODE_TOFULLIMFILE,
    4647    CHIPTOOL_MODE_TOPURGEDIMFILE,
  • branches/cnb_branches/cnb_branch_20090215/ippTools/src/chiptoolConfig.c

    r21536 r23199  
    234234    psMetadataAddStr(tocleanedimfileArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
    235235
     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
    236241    // -tofullimfile
    237242    psMetadata *tofullimfileArgs = psMetadataAlloc();
     
    275280    PXOPT_ADD_MODE("-run",                  "show runs",                            CHIPTOOL_MODE_RUN,                  runArgs);
    276281    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);
    277283    PXOPT_ADD_MODE("-tofullimfile",         "set imfile state to full",              CHIPTOOL_MODE_TOFULLIMFILE,         tofullimfileArgs);
    278284    PXOPT_ADD_MODE("-topurgedimfile",       "set imfile state to purged",            CHIPTOOL_MODE_TOPURGEDIMFILE,       topurgedimfileArgs);
  • branches/cnb_branches/cnb_branch_20090215/ippTools/src/dettoolConfig.c

    r20375 r23199  
    7373    psMetadataAddTime(definebytagArgs, PS_LIST_TAIL, "-time_begin",  0,            "detrend applies to exposures taken during this period", NULL);
    7474    psMetadataAddTime(definebytagArgs, PS_LIST_TAIL, "-time_end",  0,            "detrend applies to exposures taken during this period", NULL);
    75     psMetadataAddTime(definebytagArgs, PS_LIST_TAIL, "-use_begin",  0,            "start of detrend run applicable period", NULL);
    76     psMetadataAddTime(definebytagArgs, PS_LIST_TAIL, "-use_end",  0,            "end of detrend run applicable period", NULL);
     75    psMetadataAddTime(definebytagArgs, PS_LIST_TAIL, "-use_begin",  0,            "start of detrend run period (CURRENTLY NOT USED)", NULL);
     76    psMetadataAddTime(definebytagArgs, PS_LIST_TAIL, "-use_end",  0,            "end of detrend run applicable period (CURRENTLY NOT USED)", NULL);
    7777    psMetadataAddStr(definebytagArgs, PS_LIST_TAIL, "-reduction",  0,            "define reduction class for processing", NULL);
    7878    psMetadataAddStr(definebytagArgs, PS_LIST_TAIL, "-label",  0,            "define detrun label", NULL);
     
    104104    psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-time_begin",  0,            "detrend applies to exposures taken during this period", NULL);
    105105    psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-time_end",  0,            "detrend applies to exposures taken during this period", NULL);
    106     psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-use_begin",  0,            "start of detrend run applicable period", NULL);
    107     psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-use_end",  0,            "end of detrend run applicable period", NULL);
     106    psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-use_begin",  0,            "start of detrend run applicable period (CURRENTLY NOT USED)", NULL);
     107    psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-use_end",  0,            "end of detrend run applicable period (CURRENTLY NOT USED)", NULL);
    108108    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-select_exp_type",  0,            "search for exp_type", NULL);
    109109    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-select_inst",  0,            "search for camera", NULL);
     
    159159    psMetadataAddTime(definebydetrunArgs, PS_LIST_TAIL, "-set_time_begin",  0,            "start of period to apply detrend too", NULL);
    160160    psMetadataAddTime(definebydetrunArgs, PS_LIST_TAIL, "-set_time_end",  0,            "end of period to apply detrend too", NULL);
    161     psMetadataAddTime(definebydetrunArgs, PS_LIST_TAIL, "-set_use_begin",  0,            "start of detrend run applicable period", NULL);
    162     psMetadataAddTime(definebydetrunArgs, PS_LIST_TAIL, "-set_use_end",  0,            "end of detrend run applicable period", NULL);
     161    psMetadataAddTime(definebydetrunArgs, PS_LIST_TAIL, "-set_use_begin",  0,            "start of detrend run applicable period (CURRENTLY NOT USED)", NULL);
     162    psMetadataAddTime(definebydetrunArgs, PS_LIST_TAIL, "-set_use_end",  0,            "end of detrend run applicable period (CURRENTLY NOT USED)", NULL);
    163163    psMetadataAddStr(definebydetrunArgs, PS_LIST_TAIL, "-set_reduction",  0,            "define reduction class for processing", NULL);
    164164    psMetadataAddStr(definebydetrunArgs, PS_LIST_TAIL, "-set_label",  0,            "define detrun label", NULL);
     
    833833    psMetadataAddTime(register_detrendArgs, PS_LIST_TAIL, "-time_begin",  0,            "detrend applies to exposures taken during this period", NULL);
    834834    psMetadataAddTime(register_detrendArgs, PS_LIST_TAIL, "-time_end",  0,            "detrend applies to exposures taken during this period", NULL);
    835     psMetadataAddTime(register_detrendArgs, PS_LIST_TAIL, "-use_begin",  0,            "start of detrend run applicable period", NULL);
    836     psMetadataAddTime(register_detrendArgs, PS_LIST_TAIL, "-use_end",  0,            "end of detrend run applicable period", NULL);
     835    psMetadataAddTime(register_detrendArgs, PS_LIST_TAIL, "-use_begin",  0,            "start of detrend run applicable period (CURRENTLY NOT USED)", NULL);
     836    psMetadataAddTime(register_detrendArgs, PS_LIST_TAIL, "-use_end",  0,            "end of detrend run applicable period (CURRENTLY NOT USED)", NULL);
    837837    psMetadataAddS64(register_detrendArgs, PS_LIST_TAIL, "-ref_det_id",  0,            "define reference det_id", 0);
    838838    psMetadataAddS32(register_detrendArgs, PS_LIST_TAIL, "-ref_iter",  0,            "define reference iteration", -1);
  • branches/cnb_branches/cnb_branch_20090215/ippTools/src/pxtools.c

    r20413 r23199  
    3030    PS_ASSERT_PTR_NON_NULL(state, false);
    3131   
    32     // XXX replace strncmp with strcmp
    33 
    3432    if (!strcmp(state, "new")) return true;
    3533    if (!strcmp(state, "reg")) return true;
     
    3836    if (!strcmp(state, "wait")) return true;
    3937    if (!strcmp(state, "goto_cleaned")) return true;
     38    if (!strcmp(state, "error_cleaned")) return true;
     39    if (!strcmp(state, "goto_scrubbed")) return true;
     40    if (!strcmp(state, "error_scrubbed")) return true;
    4041    if (!strcmp(state, "cleaned")) return true;
    4142    if (!strcmp(state, "update")) return true;
    4243    if (!strcmp(state, "purged")) return true;
    4344    if (!strcmp(state, "goto_purged")) return true;
     45    if (!strcmp(state, "error_purged")) return true;
    4446
    4547    return false;
    4648}
     49
     50// 'scrubbed' is a virtual state equivalent to cleaned, but allows files to be removed
     51// even if the config files is missing
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/gpc1/ppImage.config

    r21370 r23199  
    134134# Overscan, bias, dark, shutter
    135135PPIMAGE_OBDS       METADATA
    136   BASE.FITS        BOOL    TRUE            # Save base detrended image?
    137   BASE.MASK.FITS   BOOL    TRUE            # Save base detrended image?
     136  BASE.FITS          BOOL    TRUE            # Save base detrended image?
     137  BASE.MASK.FITS     BOOL    TRUE            # Save base detrended image?
    138138  BASE.VARIANCE.FITS BOOL    TRUE            # Save base detrended image?
    139   CHIP.FITS        BOOL    FALSE           # Save chip-mosaic-ed image?
    140   CHIP.MASK.FITS   BOOL    FALSE           # Save chip-mosaic-ed image?
    141   CHIP.VARIANCE.FITS BOOL    FALSE           # Save chip-mosaic-ed image?
    142   OVERSCAN         BOOL    TRUE            # Overscan subtraction
    143   BIAS             BOOL    FALSE           # Bias subtraction
    144   DARK             BOOL    TRUE            # Dark subtraction
    145   SHUTTER          BOOL    FALSE           # Shutter correction
    146   FLAT             BOOL    FALSE           # Flat-field normalisation
    147   MASK             BOOL    FALSE           # Mask bad pixels
    148   FRINGE           BOOL    FALSE           # Fringe subtraction
    149   PHOTOM           BOOL    FALSE           # Source identification and photometry
    150   ASTROM.CHIP      BOOL    FALSE           # Astrometry per chip?
    151   ASTROM.MOSAIC    BOOL    FALSE           # Astrometry for mosaic?
    152   BIN1.FITS        BOOL    TRUE            # Save 1st binned chip image?
    153   BIN2.FITS        BOOL    TRUE            # Save 2nd binned chip image?
     139  CHIP.FITS          BOOL    FALSE           # Save chip-mosaic-ed image?
     140  CHIP.MASK.FITS     BOOL    FALSE           # Save chip-mosaic-ed image?
     141  CHIP.VARIANCE.FITS BOOL    FALSE           # Save chip-mosaic-ed image?
     142  OVERSCAN           BOOL    TRUE            # Overscan subtraction
     143  BIAS               BOOL    FALSE           # Bias subtraction
     144  DARK               BOOL    TRUE            # Dark subtraction
     145  SHUTTER            BOOL    FALSE           # Shutter correction
     146  FLAT               BOOL    FALSE           # Flat-field normalisation
     147  MASK               BOOL    FALSE           # Mask bad pixels
     148  FRINGE             BOOL    FALSE           # Fringe subtraction
     149  PHOTOM             BOOL    FALSE           # Source identification and photometry
     150  ASTROM.CHIP        BOOL    FALSE           # Astrometry per chip?
     151  ASTROM.MOSAIC      BOOL    FALSE           # Astrometry for mosaic?
     152  BIN1.FITS          BOOL    TRUE            # Save 1st binned chip image?
     153  BIN2.FITS          BOOL    TRUE            # Save 2nd binned chip image?
     154END
     155
     156# Overscan, bias, dark, shutter
     157PPIMAGE_FLATPROC_PREMASK       METADATA
     158  BASE.FITS          BOOL    TRUE            # Save base detrended image?
     159  BASE.MASK.FITS     BOOL    TRUE            # Save base detrended image?
     160  BASE.VARIANCE.FITS BOOL    TRUE            # Save base detrended image?
     161  CHIP.FITS          BOOL    FALSE           # Save chip-mosaic-ed image?
     162  CHIP.MASK.FITS     BOOL    FALSE           # Save chip-mosaic-ed image?
     163  CHIP.VARIANCE.FITS BOOL    FALSE           # Save chip-mosaic-ed image?
     164  OVERSCAN           BOOL    TRUE            # Overscan subtraction
     165  BIAS               BOOL    FALSE           # Bias subtraction
     166  DARK               BOOL    TRUE            # Dark subtraction
     167  SHUTTER            BOOL    FALSE           # Shutter correction
     168  FLAT               BOOL    FALSE           # Flat-field normalisation
     169  MASK               BOOL    FALSE           # Mask bad pixels
     170  FRINGE             BOOL    FALSE           # Fringe subtraction
     171  PHOTOM             BOOL    FALSE           # Source identification and photometry
     172  ASTROM.CHIP        BOOL    FALSE           # Astrometry per chip?
     173  ASTROM.MOSAIC      BOOL    FALSE           # Astrometry for mosaic?
     174  BIN1.FITS          BOOL    TRUE            # Save 1st binned chip image?
     175  BIN2.FITS          BOOL    TRUE            # Save 2nd binned chip image?
     176
     177  DETREND.CONSTRAINTS  METADATA
     178    DARK METADATA
     179      DETTYPE STR DARK_PREMASK
     180    END
     181  END   
    154182END
    155183
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/gpc1/ppMerge.config

    r18252 r23199  
    2121DARK.ORDINATES  METADATA
    2222        CELL.DARKTIME   S32     1
    23         CHIP.TEMP       METADATA
    24                 ORDER   S32     1
    25                 SCALE   BOOL    TRUE
    26                 MIN     F32     -95
    27                 MAX     F32     -50
    28         END
     23#       CHIP.TEMP       METADATA
     24#               ORDER   S32     1
     25#               SCALE   BOOL    TRUE
     26#               MIN     F32     -95
     27#               MAX     F32     -50
     28#       END
    2929END
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/ipprc.config.in

    r23197 r23199  
    33# Default search path for configuration files (add $HOME if desired)
    44# Note: do not include $HOME in the distributed copy used by ippMonitor
    5 # PATH            STR     @pkgdatadir@:$HOME/.ipp:.
    6 PATH              STR     $HOME/ippconfig/:$PSCONFDIR/$PSCONFIG/share/ippconfig/
     5PATH            STR     @pkgdatadir@
     6### This is a useful setting for an individual user:
     7#PATH           STR     $HOME/ippconfig/:$PSCONFDIR/$PSCONFIG/share/ippconfig/
    78
    89# load the site-specific information from here
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-mef.mdc

    r21370 r23199  
    128128PPIMAGE.OUT.WT.SPL      OUTPUT {OUTPUT}.{CHIP.NAME}.wt.fits      VARIANCE  NONE       CHIP       TRUE      SPLIT
    129129PPIMAGE.OUTPUT.DETMASK  OUTPUT {OUTPUT}.fits                     IMAGE     MASK       CHIP       TRUE      MEF
     130PPIMAGE.OUTPUT.DETREND  OUTPUT {OUTPUT}.fits                     IMAGE     COMP_DET   CHIP       TRUE      MEF
    130131PPIMAGE.OUTPUT.RESID    OUTPUT {OUTPUT}.b0.fits                  IMAGE     COMP_SUB   CHIP       TRUE      MEF
    131132PPIMAGE.CONFIG          OUTPUT {OUTPUT}.{CHIP.NAME}.ppImage.mdc  TEXT      NONE       CHIP       TRUE      NONE
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-simple.mdc

    r21370 r23199  
    9191PPIMAGE.OUTPUT.VARIANCE OUTPUT {OUTPUT}.wt.fits      VARIANCE  NONE       FPA        TRUE      SIMPLE
    9292PPIMAGE.OUTPUT.DETMASK  OUTPUT {OUTPUT}.fits         IMAGE     NONE       FPA        TRUE      SIMPLE
     93PPIMAGE.OUTPUT.DETREND  OUTPUT {OUTPUT}.fits         IMAGE     NONE       FPA        TRUE      SIMPLE
    9394PPIMAGE.OUTPUT.RESID    OUTPUT {OUTPUT}.fits         IMAGE     NONE       FPA        TRUE      SIMPLE
    9495PPIMAGE.CONFIG          OUTPUT {OUTPUT}.ppImage.mdc  TEXT      NONE       FPA        TRUE      NONE
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/filerules-split.mdc

    r22214 r23199  
    100100PPIMAGE.OUTPUT.VARIANCE OUTPUT {OUTPUT}.{CHIP.NAME}.wt.fits      VARIANCE  COMP_WT    CHIP       TRUE      NONE
    101101PPIMAGE.OUTPUT.DETMASK  OUTPUT {OUTPUT}.{CHIP.NAME}.fits         IMAGE     DET_MASK   CHIP       TRUE      NONE
     102PPIMAGE.OUTPUT.DETREND  OUTPUT {OUTPUT}.{CHIP.NAME}.fits         IMAGE     COMP_DET   CHIP       TRUE      NONE
    102103PPIMAGE.OUTPUT.RESID    OUTPUT {OUTPUT}.{CHIP.NAME}.fits         IMAGE     COMP_SUB   CHIP       TRUE      NONE
    103104PPIMAGE.CONFIG          OUTPUT {OUTPUT}.{CHIP.NAME}.ppImage.mdc  TEXT      NONE       CHIP       TRUE      NONE
    104 
    105 #PPIMAGE.OUTPUT          OUTPUT {OUTPUT}.{CHIP.NAME}.fits         IMAGE     NONE  CHIP       TRUE      NONE
    106 #PPIMAGE.OUTPUT.MASK     OUTPUT {OUTPUT}.{CHIP.NAME}.mk.fits      MASK      NONE  CHIP       TRUE      NONE
    107 #PPIMAGE.OUTPUT.VARIANCE OUTPUT {OUTPUT}.{CHIP.NAME}.wt.fits      VARIANCE  NONE  CHIP       TRUE      NONE
    108 #PPIMAGE.OUTPUT.DETMASK  OUTPUT {OUTPUT}.{CHIP.NAME}.fits         IMAGE     NONE  CHIP       TRUE      NONE
    109105                                                                                               
    110106PPIMAGE.CHIP            OUTPUT {OUTPUT}.{CHIP.NAME}.ch.fits      IMAGE     COMP_IMG   CHIP       TRUE      NONE
     
    124120                                                                                                       
    125121PPIMAGE.STATS           OUTPUT {OUTPUT}.{CHIP.NAME}.stats        STATS     NONE       CHIP       TRUE      NONE
    126                                                                                                        
     122
    127123## note: these use the  same output naming convention since they are used for different ppMerge runs
    128 PPMERGE.OUTPUT.MASK     OUTPUT {OUTPUT}.{CHIP.NAME}.fits         MASK      NONE       CHIP       TRUE      NONE
     124PPMERGE.OUTPUT.MASK     OUTPUT {OUTPUT}.{CHIP.NAME}.fits         MASK      DET_MASK   CHIP       TRUE      NONE
    129125PPMERGE.OUTPUT.BIAS     OUTPUT {OUTPUT}.{CHIP.NAME}.fits         IMAGE     NONE       CHIP       TRUE      NONE
    130126PPMERGE.OUTPUT.DARK     OUTPUT {OUTPUT}.{CHIP.NAME}.fits         DARK      NONE       CHIP       TRUE      NONE
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/fitstypes.mdc

    r22214 r23199  
    1919# STDEV.NUM(F32) is the number of standard deviations to the edge (when SCALING = STDEV_NEGATIVE|STDEV_POSITIVE)
    2020# FLOAT(STR) is the name of a custom floating-point type
     21
     22# Compressed detrend
     23COMP_FLAT       METADATA
     24        BITPIX          S32     16
     25        SCALING         STR     MANUAL
     26        BSCALE          F32     1.0
     27        BZERO           F32     32768.0
     28        COMPRESSION     STR     RICE
     29        TILE.X          S32     0
     30        TILE.Y          S32     1
     31        TILE.Z          S32     1
     32        NOISE           S32     8
     33END
    2134
    2235DET_IMAGE       METADATA
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/ppImage.config

    r21370 r23199  
    433433  BIN1.FITS        BOOL    TRUE            # Save 1st binned chip image?
    434434  BIN2.FITS        BOOL    TRUE            # Save 2nd binned chip image?
     435END
     436
     437# used for the pre-mask version of flat-field processing
     438PPIMAGE_FLATPROC_PREMASK       METADATA
     439  BASE.FITS          BOOL    TRUE            # Save base detrended image?
     440  BASE.MASK.FITS     BOOL    TRUE            # Save base detrended image?
     441  BASE.VARIANCE.FITS BOOL    TRUE            # Save base detrended image?
     442  CHIP.FITS          BOOL    FALSE           # Save chip-mosaic-ed image?
     443  CHIP.MASK.FITS     BOOL    FALSE           # Save chip-mosaic-ed image?
     444  CHIP.VARIANCE.FITS BOOL    FALSE           # Save chip-mosaic-ed image?
     445  OVERSCAN           BOOL    TRUE            # Overscan subtraction
     446  BIAS               BOOL    TRUE            # Bias subtraction
     447  DARK               BOOL    TRUE            # Dark subtraction
     448  SHUTTER            BOOL    FALSE           # Shutter correction
     449  FLAT               BOOL    FALSE           # Flat-field normalisation
     450  MASK               BOOL    FALSE           # Mask bad pixels
     451  FRINGE             BOOL    FALSE           # Fringe subtraction
     452  PHOTOM             BOOL    FALSE           # Source identification and photometry
     453  ASTROM.CHIP        BOOL    FALSE           # Astrometry per chip?
     454  ASTROM.MOSAIC      BOOL    FALSE           # Astrometry for mosaic?
     455  BIN1.FITS          BOOL    TRUE            # Save 1st binned chip image?
     456  BIN2.FITS          BOOL    TRUE            # Save 2nd binned chip image?
     457
     458  DETREND.CONSTRAINTS  METADATA
     459    DARK METADATA
     460      DETTYPE STR DARK_PREMASK
     461    END
     462  END   
    435463END
    436464
  • branches/cnb_branches/cnb_branch_20090215/ippconfig/recipes/reductionClasses.mdc

    r20745 r23199  
    3131
    3232        # *** premask (unmasked) flat-field types
    33         FLAT_PREMASK_PROCESS    STR     PPIMAGE_OBDS
     33        FLAT_PREMASK_PROCESS    STR     PPIMAGE_FLATPROC_PREMASK
    3434        FLAT_PREMASK_RESID      STR     PPIMAGE_F
    3535        FLAT_PREMASK_VERIFY     STR     PPIMAGE_F
    3636        FLAT_PREMASK_STACK      STR     PPMERGE_FLAT
    3737        FLAT_PREMASK_JPEG_IMAGE STR     FLAT
    38         FLAT_PREMASK_JPEG_RESID STRE    FLAT_RESID
     38        FLAT_PREMASK_JPEG_RESID STR     FLAT_RESID
    3939
    4040        DOMEFLAT_PREMASK_PROCESS        STR     PPIMAGE_OBDS
  • branches/cnb_branches/cnb_branch_20090215/ppArith/src/Makefile.am

    r15571 r23199  
    11bin_PROGRAMS = ppArith
    2 ppArith_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPARITH_CFLAGS)
     2
     3PPARITH_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4PPARITH_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`
     5PPARITH_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
     8ppArithVersion.c: FORCE
     9        touch ppArith.c
     10FORCE: ;
     11
     12ppArith_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPARITH_CFLAGS) -DPPARITH_VERSION=\"$(PPARITH_VERSION)\" -DPPARITH_BRANCH=\"$(PPARITH_BRANCH)\" -DPPARITH_SOURCE=\"$(PPARITH_SOURCE)\"
    313ppArith_LDFLAGS  = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PPSTATS_LIBS)   $(PSPHOT_LIBS)   $(PPARITH_LIBS)
    414
  • branches/cnb_branches/cnb_branch_20090215/ppArith/src/ppArith.c

    r21378 r23199  
    3434    }
    3535
     36    ppArithVersionPrint();
     37
    3638    if (!ppArithArguments(argc, argv, config)) {
    3739        psErrorStackPrint(stderr, "Error reading arguments.\n");
  • branches/cnb_branches/cnb_branch_20090215/ppArith/src/ppArith.h

    r21244 r23199  
    2222 * Parse the arguments
    2323 */
    24 bool ppArithArguments(int argc, char *argv[], ///< Command-line arguments 
    25                       pmConfig *config    ///< Configuration 
     24bool ppArithArguments(int argc, char *argv[], ///< Command-line arguments
     25                      pmConfig *config    ///< Configuration
    2626    );
    2727
     
    2929 * Parse the camera input
    3030 */
    31 bool ppArithCamera(pmConfig *config       ///< Configuration 
     31bool ppArithCamera(pmConfig *config       ///< Configuration
    3232    );
    3333
     
    3535 * Loop over the FPA hierarchy
    3636 */
    37 bool ppArithLoop(pmConfig *config         ///< Configuration 
     37bool ppArithLoop(pmConfig *config         ///< Configuration
    3838    );
    3939
     
    4141 * Perform arithmetic on the readout
    4242 */
    43 bool ppArithReadout(pmReadout *output,  ///< Output readout 
    44                     const pmReadout *input1, ///< Input readout 
    45                     const pmReadout *input2, ///< Input readout 
    46                     const pmConfig *config, ///< Configuration 
    47                     const pmFPAview *view ///< View of readout on which to operate 
     43bool ppArithReadout(pmReadout *output,  ///< Output readout
     44                    const pmReadout *input1, ///< Input readout
     45                    const pmReadout *input2, ///< Input readout
     46                    const pmConfig *config, ///< Configuration
     47                    const pmFPAview *view ///< View of readout on which to operate
    4848    );
    4949
    5050/**
    51  * Put the program version information into a metadata
     51 * Put the program version information into header
    5252 */
    53 void ppArithVersionMetadata(psMetadata *metadata ///< Metadata to populate
     53bool ppArithVersionHeader(psMetadata *header ///< Header to populate
    5454    );
     55
     56/// Print version information
     57void ppArithVersionPrint(void);
    5558
    5659///@}
  • branches/cnb_branches/cnb_branch_20090215/ppArith/src/ppArithLoop.c

    r21378 r23199  
    113113                    hdu->header = psMetadataAlloc();
    114114                }
    115                 ppArithVersionMetadata(hdu->header);
     115                ppArithVersionHeader(hdu->header);
    116116                lastHDU = hdu;
    117117            }
  • branches/cnb_branches/cnb_branch_20090215/ppArith/src/ppArithVersion.c

    r21378 r23199  
    2222#include "ppArith.h"
    2323
    24 static const char *cvsTag = "$Name: not supported by cvs2svn $";///< CVS tag name
    25 
    2624psString ppArithVersion(void)
    2725{
    28     psString version = NULL;            // Version, to return
    29     psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
    30     return version;
     26#ifndef PPARITH_VERSION
     27#error "PPARITH_VERSION is not set"
     28#endif
     29#ifndef PPARITH_BRANCH
     30#error "PPARITH_BRANCH is not set"
     31#endif
     32    return psStringCopy(PPARITH_BRANCH "@" PPARITH_VERSION);
     33}
     34
     35psString ppArithSource(void)
     36{
     37#ifndef PPARITH_SOURCE
     38#error "PPARITH_SOURCE is not set"
     39#endif
     40    return psStringCopy(PPARITH_SOURCE);
    3141}
    3242
    3343psString ppArithVersionLong(void)
    3444{
    35     psString version = ppArithVersion(); // Version, to return
    36     psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
    37     psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
    38     psFree(tag);
     45    psString version = ppArithVersion();  // Version, to return
     46    psString source = ppArithSource();    // Source
     47
     48    psStringPrepend(&version, "ppArith ");
     49    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
     50    psFree(source);
     51
     52#ifdef __OPTIMIZE__
     53    psStringAppend(&version, " optimised");
     54#else
     55    psStringAppend(&version, " unoptimised");
     56#endif
     57
    3958    return version;
     59};
     60
     61bool ppArithVersionHeader(psMetadata *header)
     62{
     63    PS_ASSERT_METADATA_NON_NULL(header, false);
     64
     65    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     66    psString timeString = psTimeToISO(time); // The time in an ISO string
     67    psFree(time);
     68    psString history = NULL;               // History string
     69    psStringAppend(&history, "ppArith at %s", timeString);
     70    psFree(timeString);
     71    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     72    psFree(history);
     73
     74    psLibVersionHeader(header);
     75    psModulesVersionHeader(header);
     76    ppStatsVersionHeader(header);
     77
     78    psString version = ppArithVersion(); // Software version
     79    psString source  = ppArithSource();  // Software source
     80
     81    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPARITH.VERSION", PS_META_REPLACE,
     82                     "Software version", version);
     83    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPARITH.SOURCE", PS_META_REPLACE,
     84                     "S/W source", source);
     85
     86    psFree(version);
     87    psFree(source);
     88
     89    return true;
    4090}
    4191
    42 
    43 void ppArithVersionMetadata(psMetadata *metadata)
     92void ppArithVersionPrint(void)
    4493{
    45     PS_ASSERT_METADATA_NON_NULL(metadata,);
     94    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     95    psString timeString = psTimeToISO(time); // The time in an ISO string
     96    psFree(time);
     97    psLogMsg("ppArith", PS_LOG_INFO, "ppArith at %s", timeString);
     98    psFree(timeString);
    4699
    47100    psString pslib = psLibVersionLong();// psLib version
     
    50103    psString ppArith = ppArithVersionLong(); // ppArith version
    51104
    52     psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
    53     psString timeString = psTimeToISO(time); // The time in an ISO string
    54     psFree(time);
    55     psString head = NULL;               // Head string
    56     psStringAppend(&head, "ppArith processing at %s. Component information:", timeString);
    57     psFree(timeString);
     105    psLogMsg("ppArith", PS_LOG_INFO, "%s", pslib);
     106    psLogMsg("ppArith", PS_LOG_INFO, "%s", psmodules);
     107    psLogMsg("ppArith", PS_LOG_INFO, "%s", ppStats);
     108    psLogMsg("ppArith", PS_LOG_INFO, "%s", ppArith);
    58109
    59     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");
    60     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");
    61     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");
    62     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, "");
    63     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppArith, "");
    64 
    65     psFree(head);
    66110    psFree(pslib);
    67111    psFree(psmodules);
  • branches/cnb_branches/cnb_branch_20090215/ppImage/src/Makefile.am

    r20774 r23199  
    44        ppImage.h
    55
    6 ppImage_CFLAGS = $(PPIMAGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSASTRO_CFLAGS) $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
     6PPIMAGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     7PPIMAGE_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`
     8PPIMAGE_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     9
     10# Force recompilation of ppImageVersion.c, since it gets the version information
     11ppImageVersion.c: FORCE
     12        touch ppImageVersion.c
     13FORCE: ;
     14
     15ppImage_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)\"
    716ppImage_LDFLAGS = $(PPIMAGE_LIBS) $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    817ppImage_SOURCES = \
  • branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImage.c

    r19928 r23199  
    2121        exit(PS_EXIT_CONFIG_ERROR);
    2222    }
     23
     24    ppImageVersionPrint();
    2325
    2426    // define recipe options
  • branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImage.h

    r21364 r23199  
    208208psString ppImageVersion(void);
    209209
     210/// Return software source
     211psString ppImageSource(void);
     212
    210213/// Return long version information
    211214psString ppImageVersionLong(void);
    212215
    213 /// Update the metadata with version information for all dependencies
    214 void ppImageVersionMetadata(psMetadata *metadata ///< Metadata to update with version information
    215     );
     216/// Populate the header with version information for all dependencies
     217bool ppImageVersionHeader(psMetadata *metadata ///< Header to populate
     218    );
     219
     220/// Print version information
     221void ppImageVersionPrint(void);
    216222
    217223
  • branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageLoop.c

    r21183 r23199  
    2828    if (dump_file) {
    2929        pmConfigCamerasCull(config, NULL);
    30         pmConfigRecipesCull(config, "PPIMAGE,PPSTATS,PSPHOT,MASKS,PSASTRO");
     30        pmConfigRecipesCull(config, "PPIMAGE,PPSTATS,PSPHOT,MASKS,PSASTRO,JPEG");
    3131
    3232        pmConfigDump(config, input->fpa, dump_file);
     
    6363
    6464            // Put version information into the header
    65             pmHDU *hdu = pmHDUFromCell(cell);
     65            pmHDU *hdu = pmHDUGetHighest(input->fpa, chip, cell);
    6666            if (hdu && hdu != lastHDU) {
    67                 ppImageVersionMetadata(hdu->header);
     67                ppImageVersionHeader(hdu->header);
    6868                lastHDU = hdu;
    6969            }
     
    9696                }
    9797
    98                 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
    99                 if (!ppImageDetrendFree (config, view)) {
    100                     ESCAPE("Unable to free detrend images");
    101                 }
     98                // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
     99                if (!ppImageDetrendFree (config, view)) {
     100                    ESCAPE("Unable to free detrend images");
     101                }
    102102            }
    103103
     
    105105                ppImageDetrendRecord(cell, config, options, view);
    106106            }
    107             // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
    108             if (!ppImageDetrendFree (config, view)) {
    109                 ESCAPE("Unable to free detrend images");
    110             }
    111         }
    112         // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
    113         if (!ppImageDetrendFree (config, view)) {
    114             ESCAPE("Unable to free detrend images");
    115         }
     107            // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
     108            if (!ppImageDetrendFree (config, view)) {
     109                ESCAPE("Unable to free detrend images");
     110            }
     111        }
     112        // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
     113        if (!ppImageDetrendFree (config, view)) {
     114            ESCAPE("Unable to free detrend images");
     115        }
    116116
    117117        // Apply the fringe correction
     
    121121            }
    122122        }
    123         // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
    124         if (!ppImageFringeFree (config, view)) {
    125             ESCAPE("Unable to free fringe images");
    126         }
     123        // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
     124        if (!ppImageFringeFree (config, view)) {
     125            ESCAPE("Unable to free fringe images");
     126        }
    127127
    128128        // measure various pixel-based statistics for this image
     
    152152        }
    153153
    154         // these may be used by ppImageSubtractBackground.
    155         // if these are defined as internal files, drop them here
    156         status = true;
    157         status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL");
    158         status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV");
    159         status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND");
    160         if (!status) {
    161             psError(PSPHOT_ERR_PROG, false, "trouble dropping internal files");
    162             psFree (view);
    163             return false;
    164         }
     154        // these may be used by ppImageSubtractBackground.
     155        // if these are defined as internal files, drop them here
     156        status = true;
     157        status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL");
     158        status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV");
     159        status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND");
     160        if (!status) {
     161            psError(PSPHOT_ERR_PROG, false, "trouble dropping internal files");
     162            psFree (view);
     163            return false;
     164        }
    165165
    166166        // binning (used for display) must take place after the background is replaced, if desired
  • branches/cnb_branches/cnb_branch_20090215/ppImage/src/ppImageVersion.c

    r14000 r23199  
    55#include "ppImage.h"
    66
    7 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name
    8 
    97psString ppImageVersion(void)
    108{
    11     psString version = NULL;            // Version, to return
    12     psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
    13     return version;
     9#ifndef PPIMAGE_VERSION
     10#error "PPIMAGE_VERSION is not set"
     11#endif
     12#ifndef PPIMAGE_BRANCH
     13#error "PPIMAGE_BRANCH is not set"
     14#endif
     15    return psStringCopy(PPIMAGE_BRANCH "@" PPIMAGE_VERSION);
     16}
     17
     18psString ppImageSource(void)
     19{
     20#ifndef PPIMAGE_SOURCE
     21#error "PPIMAGE_SOURCE is not set"
     22#endif
     23    return psStringCopy(PPIMAGE_SOURCE);
    1424}
    1525
    1626psString ppImageVersionLong(void)
    1727{
    18     psString version = ppImageVersion(); // Version, to return
    19     psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
    20     psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
    21     psFree(tag);
     28    psString version = ppImageVersion();  // Version, to return
     29    psString source = ppImageSource();    // Source
     30
     31    psStringPrepend(&version, "ppImage ");
     32    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
     33    psFree(source);
     34
     35#ifdef __OPTIMIZE__
     36    psStringAppend(&version, " optimised");
     37#else
     38    psStringAppend(&version, " unoptimised");
     39#endif
     40
    2241    return version;
     42};
     43
     44bool ppImageVersionHeader(psMetadata *header)
     45{
     46    PS_ASSERT_METADATA_NON_NULL(header, false);
     47
     48    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     49    psString timeString = psTimeToISO(time); // The time in an ISO string
     50    psFree(time);
     51    psString history = NULL;               // History string
     52    psStringAppend(&history, "ppImage at %s", timeString);
     53    psFree(timeString);
     54    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     55    psFree(history);
     56
     57    psLibVersionHeader(header);
     58    psModulesVersionHeader(header);
     59    psphotVersionHeader(header);
     60    psastroVersionHeader(header);
     61    ppStatsVersionHeader(header);
     62
     63    psString version = ppImageVersion(); // ppImage software version
     64    psString source  = ppImageSource();  // ppImage software source
     65
     66    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPIMAGE.VERSION", PS_META_REPLACE,
     67                     "Software version", version);
     68    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPIMAGE.SOURCE", PS_META_REPLACE,
     69                     "S/W source", source);
     70
     71    psFree(version);
     72    psFree(source);
     73
     74    return true;
    2375}
    2476
    2577
    26 void ppImageVersionMetadata(psMetadata *metadata)
     78void ppImageVersionPrint(void)
    2779{
    28     PS_ASSERT_METADATA_NON_NULL(metadata,);
     80    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     81    psString timeString = psTimeToISO(time); // The time in an ISO string
     82    psFree(time);
     83    psLogMsg("ppImage", PS_LOG_INFO, "ppImage at %s", timeString);
     84    psFree(timeString);
    2985
    3086    psString pslib = psLibVersionLong();// psLib version
     
    3591    psString ppImage = ppImageVersionLong(); // ppImage version
    3692
    37     psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
    38     psString timeString = psTimeToISO(time); // The time in an ISO string
    39     psFree(time);
    40     psString head = NULL;               // Head string
    41     psStringAppend(&head, "ppImage processing at %s. Component information:", timeString);
    42     psFree(timeString);
     93    psLogMsg("ppImage", PS_LOG_INFO, "%s", pslib);
     94    psLogMsg("ppImage", PS_LOG_INFO, "%s", psmodules);
     95    psLogMsg("ppImage", PS_LOG_INFO, "%s", psphot);
     96    psLogMsg("ppImage", PS_LOG_INFO, "%s", psastro);
     97    psLogMsg("ppImage", PS_LOG_INFO, "%s", ppStats);
     98    psLogMsg("ppImage", PS_LOG_INFO, "%s", ppImage);
    4399
    44     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");
    45     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");
    46     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");
    47     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psphot, "");
    48     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psastro, "");
    49     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, "");
    50     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppImage, "");
    51 
    52     psFree(head);
    53100    psFree(pslib);
    54101    psFree(psmodules);
  • branches/cnb_branches/cnb_branch_20090215/ppMerge/src/Makefile.am

    r19586 r23199  
    11bin_PROGRAMS = ppMerge
    22
    3 ppMerge_CFLAGS = $(PPMERGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
     3PPMERGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4PPMERGE_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`
     5PPMERGE_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
     8ppMergeVersion.c: FORCE
     9        touch ppMergeVersion.c
     10FORCE: ;
     11
     12ppMerge_CFLAGS = $(PPMERGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPMERGE_VERSION=\"$(PPMERGE_VERSION)\" -DPPMERGE_BRANCH=\"$(PPMERGE_BRANCH)\" -DPPMERGE_SOURCE=\"$(PPMERGE_SOURCE)\"
    413ppMerge_LDFLAGS = $(PPMERGE_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    514
     
    1423        ppMergeLoop_Threaded.c  \
    1524        ppMergeSetThreads.c     \
    16         ppMergeMask.c
     25        ppMergeMask.c           \
     26        ppMergeVersion.c
    1727
    1828#       ppMergeLoop.c           
  • branches/cnb_branches/cnb_branch_20090215/ppMerge/src/ppMerge.c

    r21244 r23199  
    3838        goto die;
    3939    }
     40
     41    ppMergeVersionPrint();
    4042
    4143    ppMergeType type = psMetadataLookupS32(NULL, config->arguments, "TYPE"); ///< Type of frame
  • branches/cnb_branches/cnb_branch_20090215/ppMerge/src/ppMerge.h

    r21244 r23199  
    2828/// @{
    2929
    30 #define TIMERNAME "ppMerge"             ///< Name for timer 
    31 #define PPMERGE_RECIPE "PPMERGE"        ///< Recipe name 
    32 #define THREADED 1                      ///< Compile with threads? 
     30#define TIMERNAME "ppMerge"             ///< Name for timer
     31#define PPMERGE_RECIPE "PPMERGE"        ///< Recipe name
     32#define THREADED 1                      ///< Compile with threads?
    3333
    3434/**
     
    3636 */
    3737typedef enum {
    38     PPMERGE_TYPE_UNKNOWN,               ///< Unknown type 
    39     PPMERGE_TYPE_BIAS,                  ///< Bias frame 
    40     PPMERGE_TYPE_DARK,                  ///< (Multi-)Dark frame 
    41     PPMERGE_TYPE_MASK,                  ///< Mask frame 
    42     PPMERGE_TYPE_SHUTTER,               ///< Shutter frame 
     38    PPMERGE_TYPE_UNKNOWN,               ///< Unknown type
     39    PPMERGE_TYPE_BIAS,                  ///< Bias frame
     40    PPMERGE_TYPE_DARK,                  ///< (Multi-)Dark frame
     41    PPMERGE_TYPE_MASK,                  ///< Mask frame
     42    PPMERGE_TYPE_SHUTTER,               ///< Shutter frame
    4343    PPMERGE_TYPE_FLAT,                  ///< Flat-field frame (dome or sky)
    44     PPMERGE_TYPE_FRINGE,                ///< Fringe frame 
     44    PPMERGE_TYPE_FRINGE,                ///< Fringe frame
    4545} ppMergeType;
    4646
     
    4949 */
    5050typedef enum {
    51     PPMERGE_FILES_ALL,                  ///< All files 
    52     PPMERGE_FILES_INPUT,                ///< Input files 
    53     PPMERGE_FILES_OUTPUT                ///< Output files 
     51    PPMERGE_FILES_ALL,                  ///< All files
     52    PPMERGE_FILES_INPUT,                ///< Input files
     53    PPMERGE_FILES_OUTPUT                ///< Output files
    5454} ppMergeFiles;
    5555
     
    6060 */
    6161typedef struct {
    62     psArray *readouts;                  ///< Input readouts 
    63     bool read;                          ///< Has the scan been read? 
    64     bool busy;                          ///< Is the scan being processed? 
    65     int firstScan;                      ///< First row of the chunk to be read for this group 
    66     int lastScan;                       ///< Last row of the chunk to be read for this group 
     62    psArray *readouts;                  ///< Input readouts
     63    bool read;                          ///< Has the scan been read?
     64    bool busy;                          ///< Is the scan being processed?
     65    int firstScan;                      ///< First row of the chunk to be read for this group
     66    int lastScan;                       ///< Last row of the chunk to be read for this group
    6767} ppMergeFileGroup;
    6868
     
    7171 */
    7272bool ppMergeArguments(int argc, char *argv[], ///< Command-line arguments
    73                       pmConfig *config  ///< Configuration 
     73                      pmConfig *config  ///< Configuration
    7474    );
    7575
     
    7777 * Set up camera files
    7878 */
    79 bool ppMergeCamera(pmConfig *config     ///< Configuration 
     79bool ppMergeCamera(pmConfig *config     ///< Configuration
    8080    );
    8181
     
    8383 * Measure scale and zero-points
    8484 */
    85 bool ppMergeScaleZero(pmConfig *config  ///< Configuration 
     85bool ppMergeScaleZero(pmConfig *config  ///< Configuration
    8686    );
    8787
     
    8989 * Main loop to do the merging
    9090 */
    91 bool ppMergeLoop(pmConfig *config       ///< Configuration 
     91bool ppMergeLoop(pmConfig *config       ///< Configuration
    9292    );
    9393
     
    9595 * Main loop for masks
    9696 */
    97 bool ppMergeMask(pmConfig *config       ///< Configuration 
     97bool ppMergeMask(pmConfig *config       ///< Configuration
    9898    );
    9999
     
    101101 * Read nominated input file
    102102 */
    103 bool ppMergeFileReadInput(pmConfig *config, ///< Configuration 
    104                           pmReadout *readout, ///< Readout into which to read 
    105                           int num,      ///< Number of file in sequence 
    106                           int rows      ///< Number of rows to read at once 
     103bool ppMergeFileReadInput(pmConfig *config, ///< Configuration
     104                          pmReadout *readout, ///< Readout into which to read
     105                          int num,      ///< Number of file in sequence
     106                          int rows      ///< Number of rows to read at once
    107107    );
    108108
     
    110110 * Open nominated input file
    111111 */
    112 bool ppMergeFileOpenInput(pmConfig *config, ///< Configuration 
    113                           const pmFPAview *view, ///< View to open 
    114                           int num       ///< Number of file in sequence 
     112bool ppMergeFileOpenInput(pmConfig *config, ///< Configuration
     113                          const pmFPAview *view, ///< View to open
     114                          int num       ///< Number of file in sequence
    115115    );
    116116
     
    166166bool ppMergeSetThreads(void);
    167167
     168
     169/// Return software version
     170psString ppMergeVersion(void);
     171
     172/// Return software source
     173psString ppMergeSource(void);
     174
     175/// Return detailed software version information
     176psString ppMergeVersionLong(void);
     177
     178/// Populate a FITS header with version information
     179bool ppMergeVersionHeader(
     180    psMetadata *header                  ///< Header to populate
     181    );
     182
     183/// Print version information
     184void ppMergeVersionPrint(void);
     185
     186
    168187///@}
    169188#endif
  • branches/cnb_branches/cnb_branch_20090215/ppMerge/src/ppMergeLoop_Threaded.c

    r21365 r23199  
    137137    assert(output && output->fpa);
    138138    pmFPA *outFPA = output->fpa;        ///< Output FPA
     139    pmHDU *lastHDU = NULL;              // Last HDU that was updated
    139140    int cellNum = 0;                    ///< Index of cell
    140141    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     
    156157                // No data here
    157158                continue;
     159            }
     160
     161            // Update the header
     162            {
     163                pmHDU *hdu = pmHDUGetHighest(outFPA, outChip, outCell); // HDU for file
     164                if (hdu && hdu != lastHDU) {
     165                    ppMergeVersionHeader(hdu->header);
     166                    lastHDU = hdu;
     167                }
    158168            }
    159169
  • branches/cnb_branches/cnb_branch_20090215/ppMerge/src/ppMergeMask.c

    r21365 r23199  
    1616                      const pmFPAview *view, ///< View to chip
    1717                      bool writeOut,     ///< Write output?
     18                      pmHDU **lastHDU,   ///< HDU last updated
    1819                      psRandom *rng,    ///< Random number generator
    1920                      psMetadata *stats ///< Statistics output
     
    9697                    i, inView->chip, inView->cell);
    9798
     99            // Update the header
     100            {
     101                pmHDU *hdu = pmHDUGetHighest(outCell->parent->parent, outCell->parent, outCell); // File HDU
     102                if (hdu && hdu != *lastHDU) {
     103                    ppMergeVersionHeader(hdu->header);
     104                    *lastHDU = hdu;
     105                }
     106            }
     107
    98108            if (!pmFPAfileIOChecks(config, inView, PM_FPA_BEFORE)) {
    99109                psFree(inView);
     
    395405    assert(output && output->fpa);
    396406    pmFPA *outFPA = output->fpa;        ///< Output FPA
     407    pmHDU *lastHDU = NULL;              // Last HDU updated
    397408
    398409    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     
    409420
    410421        for (int i = 0; i < iter; i++) {
    411             if (!mergeMask(config, view, (i == iter - 1), rng, stats)) {
     422            if (!mergeMask(config, view, (i == iter - 1), &lastHDU, rng, stats)) {
    412423                psError(PS_ERR_UNKNOWN, false, "Unable to merge chip %d", view->chip);
    413424                goto PPMERGE_MASK_ERROR;
  • branches/cnb_branches/cnb_branch_20090215/ppMerge/src/ppMergeVersion.c

    r21244 r23199  
    2222#include "ppMergeVersion.h"
    2323
    24 static const char *cvsTag = "$Name: not supported by cvs2svn $";///< CVS tag name
    25 
    2624psString ppMergeVersion(void)
    2725{
    28     psString version = NULL;            ///< Version, to return
    29     psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
    30     return version;
     26#ifndef PPMERGE_VERSION
     27#error "PPMERGE_VERSION is not set"
     28#endif
     29#ifndef PPMERGE_BRANCH
     30#error "PPMERGE_BRANCH is not set"
     31#endif
     32    return psStringCopy(PPMERGE_BRANCH "@" PPMERGE_VERSION);
     33}
     34
     35psString ppMergeSource(void)
     36{
     37#ifndef PPMERGE_SOURCE
     38#error "PPMERGE_SOURCE is not set"
     39#endif
     40    return psStringCopy(PPMERGE_SOURCE);
    3141}
    3242
    3343psString ppMergeVersionLong(void)
    3444{
    35     psString version = ppMergeVersion(); ///< Version, to return
    36     psString tag = psStringStripCVS(cvsTag, "Name"); ///< CVS tag
    37     psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
    38     psFree(tag);
     45    psString version = ppMergeVersion();  // Version, to return
     46    psString source = ppMergeSource();    // Source
     47
     48    psStringPrepend(&version, "ppMerge ");
     49    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
     50    psFree(source);
     51
     52#ifdef __OPTIMIZE__
     53    psStringAppend(&version, " optimised");
     54#else
     55    psStringAppend(&version, " unoptimised");
     56#endif
     57
    3958    return version;
     59};
     60
     61bool ppMergeVersionHeader(psMetadata *header)
     62{
     63    PS_ASSERT_METADATA_NON_NULL(header, false);
     64
     65    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     66    psString timeString = psTimeToISO(time); // The time in an ISO string
     67    psFree(time);
     68    psString history = NULL;               // History string
     69    psStringAppend(&history, "ppMerge at %s", timeString);
     70    psFree(timeString);
     71    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     72    psFree(history);
     73
     74    psLibVersionHeader(header);
     75    psModulesVersionHeader(header);
     76    ppStatsVersionHeader(header);
     77
     78    psString version = ppMergeVersion(); // Software version
     79    psString source  = ppMergeSource();  // Software source
     80
     81    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPMERGE.VERSION", PS_META_REPLACE,
     82                     "Software version", version);
     83    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPMERGE.SOURCE", PS_META_REPLACE,
     84                     "S/W source", source);
     85
     86    psFree(version);
     87    psFree(source);
     88
     89    return true;
    4090}
    4191
    42 
    43 void ppMergeVersionMetadata(psMetadata *metadata)
     92void ppMergeVersionPrint(void)
    4493{
    45     PS_ASSERT_METADATA_NON_NULL(metadata,);
    46 
    47     psString pslib = psLibVersionLong();///< psLib version
    48     psString psmodules = psModulesVersionLong(); ///< psModules version
    49     psString ppStats = ppStatsVersionLong(); ///< ppStats version
    50     psString ppMerge = ppMergeVersionLong(); ///< ppMerge version
    51 
    52     psTime *time = psTimeGetNow(PS_TIME_TAI); ///< The time now
    53     psString timeString = psTimeToISO(time); ///< The time in an ISO string
     94    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     95    psString timeString = psTimeToISO(time); // The time in an ISO string
    5496    psFree(time);
    55     psString head = NULL;               ///< Head string
    56     psStringAppend(&head, "ppMerge processing at %s. Component information:", timeString);
     97    psLogMsg("ppMerge", PS_LOG_INFO, "ppMerge at %s", timeString);
    5798    psFree(timeString);
    5899
    59     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");
    60     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");
    61     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");
    62     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, "");
    63     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppMerge, "");
     100    psString pslib = psLibVersionLong();// psLib version
     101    psString psmodules = psModulesVersionLong(); // psModules version
     102    psString ppStats = ppStatsVersionLong(); // ppStats version
     103    psString ppMerge = ppMergeVersionLong(); // ppMerge version
    64104
    65     psFree(head);
     105    psLogMsg("ppImage", PS_LOG_INFO, "%s", pslib);
     106    psLogMsg("ppImage", PS_LOG_INFO, "%s", psmodules);
     107    psLogMsg("ppImage", PS_LOG_INFO, "%s", ppStats);
     108    psLogMsg("ppImage", PS_LOG_INFO, "%s", ppMerge);
     109
    66110    psFree(pslib);
    67111    psFree(psmodules);
  • branches/cnb_branches/cnb_branch_20090215/ppMerge/src/ppMergeVersion.h

    r21244 r23199  
    2020
    2121/**
     22 * Return software source
     23 */
     24psString ppMergeSource(void);
     25
     26/**
    2227 * Return long version information
    2328 */
  • branches/cnb_branches/cnb_branch_20090215/ppSim/src/Makefile.am

    r18011 r23199  
    11bin_PROGRAMS = ppSim ppSimSequence
    22
    3 ppSim_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS)
     3PPSIM_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4PPSIM_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`
     5PPSIM_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
     8ppSimVersion.c: FORCE
     9        touch ppSimVersion.c
     10FORCE: ;
     11
     12ppSim_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS) -DPPSIM_VERSION=\"$(PPSIM_VERSION)\" -DPPSIM_BRANCH=\"$(PPSIM_BRANCH)\" -DPPSIM_SOURCE=\"$(PPSIM_SOURCE)\"
    413ppSim_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSPHOT_LIBS) $(PSASTRO_LIBS)
    514ppSim_SOURCES = \
     
    3544        ppSimMosaicChip.c         \
    3645        ppSimRandomGaussian.c     \
    37         ppSimBadPixels.c
     46        ppSimBadPixels.c          \
     47        ppSimVersion.c
    3848
    3949ppSimSequence_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS)
  • branches/cnb_branches/cnb_branch_20090215/ppSim/src/ppSim.h

    r21183 r23199  
    1919
    2020// Compare a value with minimum and maximum values, replacing where required.
    21 #define COMPARE(VALUE,MIN,MAX) {                \
    22         if (VALUE < MIN) { MIN = VALUE; }       \
    23         if (VALUE > MAX) { MAX = VALUE; }       \
     21#define COMPARE(VALUE,MIN,MAX) {                \
     22        if (VALUE < MIN) { MIN = VALUE; }       \
     23        if (VALUE > MAX) { MAX = VALUE; }       \
    2424    }
    2525
     
    147147float ppSimMagToFlux (float mag, float zp);
    148148
    149 float ppSimArgToRecipeF32(bool *status, 
    150                           psMetadata *options,    // Target to which to add value
    151                           const char *recipeName, // Name for value in the recipe
    152                           psMetadata *arguments,  // Command-line arguments
    153                           const char *argName    // Argument name in the command-line arguments
     149float ppSimArgToRecipeF32(bool *status,
     150                          psMetadata *options,    // Target to which to add value
     151                          const char *recipeName, // Name for value in the recipe
     152                          psMetadata *arguments,  // Command-line arguments
     153                          const char *argName    // Argument name in the command-line arguments
    154154    );
    155155
    156156int ppSimArgToRecipeS32(bool *status,
    157                         psMetadata *options,    // Target to which to add value
    158                         const char *recipeName, // Name for value in the recipe
    159                         psMetadata *arguments,  // Command-line arguments
    160                         const char *argName      // Argument name in the command-line arguments
     157                        psMetadata *options,    // Target to which to add value
     158                        const char *recipeName, // Name for value in the recipe
     159                        psMetadata *arguments,  // Command-line arguments
     160                        const char *argName      // Argument name in the command-line arguments
    161161    );
    162162
    163163char *ppSimArgToRecipeStr(bool *status,
    164                           psMetadata *options,    // Target to which to add value
    165                           const char *recipeName, // Name for value in the recipe
    166                           psMetadata *arguments,  // Command-line arguments
    167                           const char *argName    // Argument name in the command-line arguments
     164                          psMetadata *options,    // Target to which to add value
     165                          const char *recipeName, // Name for value in the recipe
     166                          psMetadata *arguments,  // Command-line arguments
     167                          const char *argName    // Argument name in the command-line arguments
    168168    );
    169169
    170170bool ppSimArgToRecipeBool(bool *status,
    171                           psMetadata *options,    // Target to which to add value
    172                           const char *recipeName, // Name for value in the recipe
    173                           psMetadata *arguments,  // Command-line arguments
    174                           const char *argName       // Argument name in the command-line arguments
     171                          psMetadata *options,    // Target to which to add value
     172                          const char *recipeName, // Name for value in the recipe
     173                          psMetadata *arguments,  // Command-line arguments
     174                          const char *argName       // Argument name in the command-line arguments
    175175    );
    176176
     
    198198bool ppSimDefinePixels (psArray *sources, pmReadout *readout, psMetadata *recipe);
    199199
     200/// Return software version
     201psString ppSimVersion(void);
     202
     203/// Return software source
     204psString ppSimSource(void);
     205
     206/// Return long version information
     207psString ppSimVersionLong(void);
     208
    200209#endif
  • branches/cnb_branches/cnb_branch_20090215/ppStack/src/Makefile.am

    r19337 r23199  
    11bin_PROGRAMS = ppStack
    22
    3 ppStack_CFLAGS  = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPSTATS_CFLAGS) $(PPSTACK_CFLAGS)
     3PPSTACK_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4PPSTACK_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`
     5PPSTACK_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
     8ppStackVersion.c: FORCE
     9        touch ppStackVersion.c
     10FORCE: ;
     11
     12ppStack_CFLAGS  = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPSTATS_CFLAGS) $(PPSTACK_CFLAGS) -DPPSTACK_VERSION=\"$(PPSTACK_VERSION)\" -DPPSTACK_BRANCH=\"$(PPSTACK_BRANCH)\" -DPPSTACK_SOURCE=\"$(PPSTACK_SOURCE)\"
    413ppStack_LDFLAGS = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PSPHOT_LIBS)   $(PPSTATS_LIBS)   $(PPSTACK_LIBS)
    514
  • branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStack.c

    r21536 r23199  
    3333        goto die;
    3434    }
     35
     36    ppStackVersionPrint();
    3537
    3638    if (!pmModelClassInit()) {
  • branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStack.h

    r21477 r23199  
    1010// Mask values for inputs
    1111typedef enum {
    12     PPSTACK_MASK_MATCH  = 0x01,         // PSF-matching failed
    13     PPSTACK_MASK_CHI2   = 0x02,         // Chi^2 too deviant
    14     PPSTACK_MASK_REJECT = 0x04,         // Rejection failed
    15     PPSTACK_MASK_BAD    = 0x08,         // Bad image (too many pixels rejected)
     12    PPSTACK_MASK_CAL    = 0x01,         // Photometric calibration failed
     13    PPSTACK_MASK_MATCH  = 0x02,         // PSF-matching failed
     14    PPSTACK_MASK_CHI2   = 0x04,         // Chi^2 too deviant
     15    PPSTACK_MASK_REJECT = 0x08,         // Rejection failed
     16    PPSTACK_MASK_BAD    = 0x10,         // Bad image (too many pixels rejected)
    1617    PPSTACK_MASK_ALL    = 0xff          // All errors
    1718} ppStackMask;
     
    8182pmPSF *ppStackPSF(const pmConfig *config, // Configuration
    8283                  int numCols, int numRows, // Size of image
    83                   const psArray *psfs   // List of input PSFs
     84                  const psArray *psfs,  // List of input PSFs
     85                  const psVector *inputMask // Mask for inputs
    8486    );
    8587
     
    134136psString ppStackVersion(void);
    135137
     138/// Return software source
     139psString ppStackSource(void);
     140
    136141// Return long description of software version
    137142psString ppStackVersionLong(void);
    138143
    139 // Supplement metadata with software version
    140 void ppStackVersionMetadata(psMetadata *metadata // Metadata to supplement
     144// Supplement header with software version
     145bool ppStackVersionHeader(psMetadata *header // Header to supplement
    141146    );
     147
     148/// Print version information
     149void ppStackVersionPrint(void);
    142150
    143151/// Convolve image to match specified seeing
     
    158166/// Corrects the source PSF photometry to a common system.  Return the sum of the exposure times.
    159167float ppStackSourcesTransparency(const psArray *sourceLists, // Sources for each input
     168                                 psVector *inputMask, // Indicates bad input
    160169                                 const pmFPAview *view, // View to readout
    161170                                 const pmConfig *config // Configuration
  • branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackArguments.c

    r22722 r23199  
    294294    if (dump_file) {
    295295        pmConfigCamerasCull(config, NULL);
    296         pmConfigRecipesCull(config, "PPSTACK,PPSUB,PPSTATS,PSPHOT,MASKS");
     296        pmConfigRecipesCull(config, "PPSTACK,PPSUB,PPSTATS,PSPHOT,MASKS,JPEG");
    297297
    298298        pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSTACK.INPUT"); // Input file
  • branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackLoop.c

    r22214 r23199  
    257257    pmPSF *targetPSF = NULL;            // Target PSF
    258258    float sumExposure = NAN;            // Sum of exposure times
     259    psVector *inputMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for inputs
     260    psVectorInit(inputMask, 0);
    259261    if (psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) {
    260262        pmFPAfileActivate(config->files, false, NULL);
     
    283285                psFree(fileIter);
    284286                psFree(psfs);
     287                psFree(inputMask);
    285288                return false;
    286289            }
     
    299302                psFree(fileIter);
    300303                psFree(psfs);
     304                psFree(inputMask);
    301305                return false;
    302306            }
     
    324328                    psFree(sourceLists);
    325329                    psFree(targetPSF);
    326                     return false;
     330                    psFree(inputMask);
     331                   return false;
    327332                }
    328333
     
    333338                    psFree(sourceLists);
    334339                    psFree(targetPSF);
     340                    psFree(inputMask);
    335341                    return false;
    336342                }
     
    340346                    psFree(sourceLists);
    341347                    psFree(targetPSF);
     348                    psFree(inputMask);
    342349                    return false;
    343350                }
     
    351358
    352359        // Zero point calibration
    353         sumExposure = ppStackSourcesTransparency(sourceLists, view, config);
     360        sumExposure = ppStackSourcesTransparency(sourceLists, inputMask, view, config);
    354361        if (!isfinite(sumExposure) || sumExposure <= 0) {
    355362            psError(PS_ERR_UNKNOWN, false, "Unable to calculate transparency differences");
    356363            psFree(sourceLists);
    357364            psFree(targetPSF);
     365            psFree(inputMask);
    358366            return false;
    359367        }
    360368
    361369        // Generate target PSF
    362         targetPSF = ppStackPSF(config, numCols, numRows, psfs);
     370        targetPSF = ppStackPSF(config, numCols, numRows, psfs, inputMask);
    363371        psFree(psfs);
    364372        if (!targetPSF) {
     
    366374            psFree(sourceLists);
    367375            psFree(view);
     376            psFree(inputMask);
    368377            return false;
    369378        }
     
    409418    int numGood = 0;                    // Number of good frames
    410419    int numCols = 0, numRows = 0;       // Size of image
    411     psVector *inputMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for inputs
    412     psVectorInit(inputMask, 0);
    413420    psVector *matchChi2 = psVectorAlloc(num, PS_TYPE_F32); // chi^2 for stamps when matching
    414421    psVectorInit(matchChi2, NAN);
     
    419426    psArray *covariances = psArrayAlloc(num); // Covariance matrices
    420427    for (int i = 0; i < num; i++) {
     428        if (inputMask->data.U8[i]) {
     429            continue;
     430        }
    421431        psTrace("ppStack", 2, "Convolving input %d of %d to target PSF....\n", i, num);
    422432        pmFPAfileActivate(config->files, false, NULL);
     
    11681178        fileActivation(config, photFiles, true);
    11691179        pmFPAview *photView = filesIterateDown(config);
     1180        fileActivation(config, combineFiles, true);
     1181
    11701182        if (!ppStackPhotometry(config, outRO, photView)) {
    11711183            psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on output.");
     1184            filesIterateUp(config);
    11721185            psFree(outRO);
    11731186            psFree(photView);
     
    11751188        }
    11761189        psFree(photView);
    1177 
    1178         fileActivation(config, combineFiles, true);
    11791190
    11801191        if (stats) {
     
    12171228        hdu->header = psMetadataAlloc();
    12181229    }
    1219     ppStackVersionMetadata(hdu->header);
     1230    ppStackVersionHeader(hdu->header);
    12201231
    12211232    psFree(outRO);
  • branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackPSF.c

    r18918 r23199  
    99#include "ppStack.h"
    1010
    11 pmPSF *ppStackPSF(const pmConfig *config, int numCols, int numRows, const psArray *psfs)
     11pmPSF *ppStackPSF(const pmConfig *config, int numCols, int numRows,
     12                  const psArray *psfs, const psVector *inputMask)
    1213{
    1314    // Get the recipe values
     
    1920    const char *psfModel = psMetadataLookupStr(NULL, recipe, "PSF.MODEL"); // Model for PSF
    2021    int psfOrder = psMetadataLookupS32(NULL, recipe, "PSF.ORDER"); // Spatial order for PSF
     22
     23    for (int i = 0; i < psfs->n; i++) {
     24        if (inputMask->data.U8[i]) {
     25            psFree(psfs->data[i]);
     26            psfs->data[i] = NULL;
     27        }
     28    }
    2129
    2230    // Solve for the target PSF
  • branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackPhotometry.c

    r21536 r23199  
    149149    if (!psphotReadoutKnownSources(config, view, inSources)) {
    150150        // Clear the error, so that the output files are written.
    151         psWarning("Unable to perform photometry on stacked image.");
    152         psErrorStackPrint(stderr, "Error stack from photometry:");
    153         psErrorClear();
     151        psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on stacked image.");
     152        return false;
    154153    }
    155154
  • branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackSources.c

    r21536 r23199  
    1313#define FAKE_ROWS 4913
    1414
    15 float ppStackSourcesTransparency(const psArray *sourceLists, const pmFPAview *view, const pmConfig *config)
     15#ifdef TESTING
     16// Dump matches to a file
     17static void dumpMatches(const char *filename, // File to which to dump
     18                        int num,        // Number of inputs
     19                        psArray *matches, // Star matches
     20                        psVector *zp,   // Zero points
     21                        psVector *trans // Transparencies
     22                        )
     23{
     24    FILE *outMatches = fopen(filename, "w"); // Output matches
     25    psVector *mag = psVectorAlloc(num, PS_TYPE_F32); // Magnitudes for each star
     26    psVector *magErr = psVectorAlloc(num, PS_TYPE_F32); // Errors for each star
     27    for (int i = 0; i < matches->n; i++) {
     28        pmSourceMatch *match = matches->data[i]; // Match of interest
     29        psVectorInit(mag, NAN);
     30        psVectorInit(magErr, NAN);
     31        for (int j = 0; j < match->num; j++) {
     32            if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
     33                continue;
     34            }
     35            int index = match->image->data.U32[j]; // Image index
     36            mag->data.F32[index] = match->mag->data.F32[j] - zp->data.F32[index];
     37            if (trans) {
     38                mag->data.F32[index] -= trans->data.F32[index];
     39            }
     40            magErr->data.F32[index] = match->magErr->data.F32[j];
     41        }
     42        for (int j = 0; j < num; j++) {
     43            fprintf(outMatches, "%f (%f) ", mag->data.F32[j], magErr->data.F32[j]);
     44        }
     45        fprintf(outMatches, "\n");
     46    }
     47    psFree(mag);
     48    psFree(magErr);
     49    fclose(outMatches);
     50    return;
     51}
     52#endif
     53
     54
     55float ppStackSourcesTransparency(const psArray *sourceLists, psVector *inputMask,
     56                                 const pmFPAview *view, const pmConfig *config)
    1657{
    1758    PS_ASSERT_ARRAY_NON_NULL(sourceLists, NAN);
     59    PS_ASSERT_VECTOR_NON_NULL(inputMask, NAN);
     60    PS_ASSERT_VECTOR_TYPE(inputMask, PS_TYPE_U8, NAN);
     61    PS_ASSERT_VECTOR_SIZE(inputMask, sourceLists->n, NAN);
    1862    PS_ASSERT_PTR_NON_NULL(view, NAN);
    1963    PS_ASSERT_PTR_NON_NULL(config, NAN);
    2064
    21 #ifdef TESTING
     65#if defined(TESTING) && 0
    2266    {
    2367        // Deliberately induce a major transparency difference
     
    63107        pmCell *cell = pmFPAviewThisCell(view, file->fpa); // Cell of interest
    64108
    65 #ifdef TESTING
     109#if defined(TESTING) && 0
    66110        pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout
    67111        pmPSF *psf = psMetadataLookupPtr(NULL, config->arguments, "PSF.TARGET"); // PSF for fake image
     
    115159        return NAN;
    116160    }
     161
     162#ifdef TESTING
     163    dumpMatches("source_match.dat", num, matches, zp, NULL);
     164#endif
     165
    117166    psVector *trans = pmSourceMatchRelphot(matches, zp, iter, tol, starLimit, transIter, transRej,
    118167                                           transThresh, starRej, starSys); // Transparencies for each image
    119 
    120 #ifdef TESTING
    121     {
    122         // Dump the corrected magnitudes
    123         FILE *outMatches = fopen("source_match.dat", "w"); // Output matches
    124         psVector *mag = psVectorAlloc(num, PS_TYPE_F32); // Magnitudes for each star
    125         psVector *magErr = psVectorAlloc(num, PS_TYPE_F32); // Errors for each star
    126         for (int i = 0; i < matches->n; i++) {
    127             pmSourceMatch *match = matches->data[i]; // Match of interest
    128             psVectorInit(mag, NAN);
    129             psVectorInit(magErr, NAN);
    130             for (int j = 0; j < match->num; j++) {
    131                 if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
    132                     continue;
    133                 }
    134                 int index = match->image->data.U32[j]; // Image index
    135                 mag->data.F32[index] = match->mag->data.F32[j] - zp->data.F32[index] - trans->data.F32[index];
    136                 magErr->data.F32[index] = match->magErr->data.F32[j];
    137             }
    138             for (int j = 0; j < num; j++) {
    139                 fprintf(outMatches, "%f (%f) ", mag->data.F32[j], magErr->data.F32[j]);
    140             }
    141             fprintf(outMatches, "\n");
    142         }
    143         psFree(mag);
    144         psFree(magErr);
    145         fclose(outMatches);
    146     }
    147 #endif
     168    if (!trans) {
     169        psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies");
     170        return NAN;
     171    }
     172
     173#ifdef TESTING
     174    dumpMatches("source_mags.dat", num, matches, zp, trans);
     175#endif
     176
     177    for (int i = 0; i < trans->n; i++) {
     178        if (!isfinite(trans->data.F32[i])) {
     179            inputMask->data.U8[i] = PPSTACK_MASK_CAL;
     180        }
     181    }
    148182
    149183    // Save best matches SOMEWHERE for future photometry
     
    172206
    173207    psFree(matches);
    174     if (!trans) {
    175         psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies");
    176         return NAN;
    177     }
    178208
    179209    // M = m + c0 + c1 * airmass - 2.5log(t) + transparency
     
    183213    // We don't need to know the magnitude zero point for the filter, since it cancels out
    184214    for (int i = 0; i < num; i++) {
     215        if (!isfinite(trans->data.F32[i])) {
     216            continue;
     217        }
    185218        psArray *sources = sourceLists->data[i]; // Sources of interest
    186219        float magCorr = airmassTerm - 2.5*log10(sumExpTime) - zp->data.F32[i] - trans->data.F32[i];
  • branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackThread.c

    r21477 r23199  
    3636    psFree(stack->threads);
    3737    for (int i = 0; i < stack->imageFits->n; i++) {
    38         psFitsClose(stack->imageFits->data[i]);
    39         psFitsClose(stack->maskFits->data[i]);
    40         psFitsClose(stack->varianceFits->data[i]);
     38        if (stack->imageFits->data[i]) {
     39            psFitsClose(stack->imageFits->data[i]);
     40        }
     41        if (stack->maskFits->data[i]) {
     42            psFitsClose(stack->maskFits->data[i]);
     43        }
     44        if (stack->varianceFits->data[i]) {
     45            psFitsClose(stack->varianceFits->data[i]);
     46        }
    4147        stack->imageFits->data[i] = stack->maskFits->data[i] = stack->varianceFits->data[i] = NULL;
    4248    }
  • branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackVersion.c

    r18419 r23199  
    77#include <psmodules.h>
    88#include <ppStats.h>
     9#include <psphot.h>
    910
    1011#include "ppStack.h"
    1112
    12 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name
    13 
    1413psString ppStackVersion(void)
    1514{
    16     psString version = NULL;            // Version, to return
    17     psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
    18     return version;
     15#ifndef PPSTACK_VERSION
     16#error "PPSTACK_VERSION is not set"
     17#endif
     18#ifndef PPSTACK_BRANCH
     19#error "PPSTACK_BRANCH is not set"
     20#endif
     21    return psStringCopy(PPSTACK_BRANCH "@" PPSTACK_VERSION);
     22}
     23
     24psString ppStackSource(void)
     25{
     26#ifndef PPSTACK_SOURCE
     27#error "PPSTACK_SOURCE is not set"
     28#endif
     29    return psStringCopy(PPSTACK_SOURCE);
    1930}
    2031
    2132psString ppStackVersionLong(void)
    2233{
    23     psString version = ppStackVersion(); // Version, to return
    24     psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
    25     psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
    26     psFree(tag);
     34    psString version = ppStackVersion();  // Version, to return
     35    psString source = ppStackSource();    // Source
     36
     37    psStringPrepend(&version, "ppStack ");
     38    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
     39    psFree(source);
     40
     41#ifdef __OPTIMIZE__
     42    psStringAppend(&version, " optimised");
     43#else
     44    psStringAppend(&version, " unoptimised");
     45#endif
     46
    2747    return version;
    28 }
     48};
    2949
    3050
    31 void ppStackVersionMetadata(psMetadata *metadata)
     51bool ppStackVersionHeader(psMetadata *header)
    3252{
    33     PS_ASSERT_METADATA_NON_NULL(metadata,);
    34 
    35     psString pslib = psLibVersionLong();// psLib version
    36     psString psmodules = psModulesVersionLong(); // psModules version
    37     psString ppStats = ppStatsVersionLong(); // ppStats version
    38     psString ppStack = ppStackVersionLong(); // ppStack version
     53    PS_ASSERT_METADATA_NON_NULL(header, false);
    3954
    4055    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
    4156    psString timeString = psTimeToISO(time); // The time in an ISO string
    4257    psFree(time);
    43     psString head = NULL;               // Head string
    44     psStringAppend(&head, "ppStack processing at %s. Component information:", timeString);
     58    psString history = NULL;               // History string
     59    psStringAppend(&history, "ppStack at %s", timeString);
     60    psFree(timeString);
     61    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     62    psFree(history);
     63
     64    psLibVersionHeader(header);
     65    psModulesVersionHeader(header);
     66    psphotVersionHeader(header);
     67    ppStatsVersionHeader(header);
     68
     69    psString version = ppStackVersion(); // Software version
     70    psString source  = ppStackSource();  // Software source
     71
     72    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPSTACK.VERSION", PS_META_REPLACE,
     73                     "Software version", version);
     74    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPSTACK.SOURCE", PS_META_REPLACE,
     75                     "S/W source", source);
     76
     77    psFree(version);
     78    psFree(source);
     79
     80    return true;
     81}
     82
     83void ppStackVersionPrint(void)
     84{
     85    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     86    psString timeString = psTimeToISO(time); // The time in an ISO string
     87    psFree(time);
     88    psLogMsg("ppStack", PS_LOG_INFO, "ppStack at %s", timeString);
    4589    psFree(timeString);
    4690
    47     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", head);
    48     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", pslib);
    49     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", psmodules);
    50     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", ppStats);
    51     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", ppStack);
     91    psString pslib = psLibVersionLong();// psLib version
     92    psString psmodules = psModulesVersionLong(); // psModules version
     93    psString psphot = psphotVersionLong(); // psphot version
     94    psString ppStats = ppStatsVersionLong(); // psastro version
     95    psString ppStack = ppStackVersionLong(); // ppStack version
    5296
    53     psFree(head);
     97    psLogMsg("ppStack", PS_LOG_INFO, "%s", pslib);
     98    psLogMsg("ppStack", PS_LOG_INFO, "%s", psmodules);
     99    psLogMsg("ppStack", PS_LOG_INFO, "%s", psphot);
     100    psLogMsg("ppStack", PS_LOG_INFO, "%s", ppStats);
     101    psLogMsg("ppStack", PS_LOG_INFO, "%s", ppStack);
     102
    54103    psFree(pslib);
    55104    psFree(psmodules);
     105    psFree(psphot);
    56106    psFree(ppStats);
    57107    psFree(ppStack);
  • branches/cnb_branches/cnb_branch_20090215/ppStats/src/Makefile.am

    r19626 r23199  
    11lib_LTLIBRARIES = libppStats.la
    2 libppStats_la_CFLAGS = $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
     2
     3PPSTATS_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4PPSTATS_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`
     5PPSTATS_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
     8ppStatsVersion.c: FORCE
     9        touch ppStatsVersion.c
     10FORCE: ;
     11
     12libppStats_la_CFLAGS = $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPSTATS_VERSION=\"$(PPSTATS_VERSION)\" -DPPSTATS_BRANCH=\"$(PPSTATS_BRANCH)\" -DPPSTATS_SOURCE=\"$(PPSTATS_SOURCE)\"
    313libppStats_la_LDFLAGS = $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    414
  • branches/cnb_branches/cnb_branch_20090215/ppStats/src/ppStats.h

    r21183 r23199  
    2222    psList *summary;                    // Summary statistics to calculate
    2323    // Options for input data
    24     bool doFirstReadout3D;              // for 3D data, use the first readout?
     24    bool doFirstReadout3D;              // for 3D data, use the first readout?
    2525    float sample;                       // Fraction of cell to sample for statistics
    26     psImageMaskType maskVal;            // Mask value for images
     26    psImageMaskType maskVal;            // Mask value for images
    2727    psList *chips;                      // Chips to look at
    2828    psList *cells;                      // Cells to look at
     
    108108psString ppStatsVersion(void);
    109109
     110/// Return source information
     111psString ppStatsSource(void);
     112
    110113/// Return long version information
    111114psString ppStatsVersionLong(void);
     115
     116/// Populate header with version information
     117bool ppStatsVersionHeader(
     118    psMetadata *header                  ///< Header to populate
     119    );
     120
    112121
    113122void p_ppStatsGetMetadata(psMetadata *target, // Target for metadata
  • branches/cnb_branches/cnb_branch_20090215/ppStats/src/ppStatsFromMetadataPrint.c

    r20305 r23199  
    4141            VALUE_NUMERICAL_CASE(F64, "lf",   F64);
    4242          case PS_DATA_STRING:
    43             fprintf(f, "%s '%s' ", entry->flag, entry->value->data.str);
     43            if (entry->value->data.str) {
     44                fprintf(f, "%s '%s' ", entry->flag, entry->value->data.str);
     45            }
    4446            break;
    4547          case PS_DATA_BOOL:
     
    5052          case PS_DATA_TIME: {
    5153              psTime *t = (psTime*)entry->value->data.V;
    52               psString str = psTimeToISO(t);
    53               fprintf(f, "%s %.19sZ ", entry->flag, str);
    54               psFree(str);
     54              if (t) {
     55                  psString str = psTimeToISO(t);
     56                  fprintf(f, "%s %.19sZ ", entry->flag, str);
     57                  psFree(str);
     58              }
    5559              break;
    5660          }
  • branches/cnb_branches/cnb_branch_20090215/ppStats/src/ppStatsVersion.c

    r13993 r23199  
    11#include "ppStatsInternal.h"
    2 
    3 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name
    42
    53psString ppStatsVersion(void)
    64{
    7     psString version = NULL;            // Version, to return
    8     psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
    9     return version;
     5#ifndef PPSTATS_VERSION
     6#error "PPSTATS_VERSION is not set"
     7#endif
     8#ifndef PPSTATS_BRANCH
     9#error "PPSTATS_BRANCH is not set"
     10#endif
     11    return psStringCopy(PPSTATS_BRANCH "@" PPSTATS_VERSION);
     12}
     13
     14psString ppStatsSource(void)
     15{
     16#ifndef PPSTATS_SOURCE
     17#error "PPSTATS_SOURCE is not set"
     18#endif
     19    return psStringCopy(PPSTATS_SOURCE);
    1020}
    1121
    1222psString ppStatsVersionLong(void)
    1323{
    14     psString version = ppStatsVersion(); // Version, to return
    15     psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
    16     psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
    17     psFree(tag);
     24    psString version = ppStatsVersion();  // Version, to return
     25    psString source = ppStatsSource();    // Source
     26
     27    psStringPrepend(&version, "ppStats ");
     28    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
     29    psFree(source);
     30
     31#ifdef __OPTIMIZE__
     32    psStringAppend(&version, " optimised");
     33#else
     34    psStringAppend(&version, " unoptimised");
     35#endif
     36
    1837    return version;
     38};
     39
     40bool ppStatsVersionHeader(psMetadata *header)
     41{
     42    PS_ASSERT_METADATA_NON_NULL(header, false);
     43
     44    psString version = ppStatsVersion(); // Software version
     45    psString source = ppStatsSource();   // Software source
     46
     47    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPSTATS.VERSION", PS_META_REPLACE,
     48                     "Software version", version);
     49    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPSTATS.SOURCE", PS_META_REPLACE,
     50                     "S/W source", source);
     51
     52    psFree(version);
     53    psFree(source);
     54
     55    return true;
    1956}
  • branches/cnb_branches/cnb_branch_20090215/ppSub/src/Makefile.am

    r21257 r23199  
    11bin_PROGRAMS = ppSub ppSubKernel
    22
    3 ppSub_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPSUB_CFLAGS)
     3PPSUB_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4PPSUB_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`
     5PPSUB_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
     8ppSubVersion.c: FORCE
     9        touch ppSubVersion.c
     10FORCE: ;
     11
     12ppSub_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPSUB_CFLAGS) -DPPSUB_VERSION=\"$(PPSUB_VERSION)\" -DPPSUB_BRANCH=\"$(PPSUB_BRANCH)\" -DPPSUB_SOURCE=\"$(PPSUB_SOURCE)\"
    413ppSub_LDFLAGS  = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PPSTATS_LIBS)   $(PSPHOT_LIBS)   $(PPSUB_LIBS)
    514
  • branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSub.c

    r23197 r23199  
    3434        goto die;
    3535    }
     36
     37    ppSubVersionPrint();
    3638
    3739    if (!pmModelClassInit()) {
  • branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSub.h

    r23197 r23199  
    8989    );
    9090
    91 /// Put the program version information into a metadata
    92 void ppSubVersionMetadata(psMetadata *metadata ///< Metadata to populate
     91/// Put the program version information into a header
     92bool ppSubVersionHeader(psMetadata *header ///< Header to populate
    9393    );
     94
     95/// Print version information
     96void ppSubVersionPrint(void);
    9497
    9598
  • branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubArguments.c

    r23197 r23199  
    377377    if (dump_file) {
    378378        pmConfigCamerasCull(config, NULL);
    379         pmConfigRecipesCull(config, "PPSUB,PPSTATS,PSPHOT,MASKS");
     379        pmConfigRecipesCull(config, "PPSUB,PPSTATS,PSPHOT,MASKS,JPEG");
    380380
    381381        pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSUB.INPUT"); // Input file
  • branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubLoop.c

    r22419 r23199  
    5959
    6060    pmFPAview *view = pmFPAviewAlloc(0); // Pointer into FPA hierarchy
    61     pmHDU *lastHDU = NULL;              // Last HDU that was updated
    6261
    6362    // Iterate over the FPA hierarchy
     
    9998            if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    10099                return false;
    101             }
    102 
    103             // Put version information into the header
    104             pmHDU *hdu = pmHDUFromCell(inCell);
    105             if (hdu && hdu != lastHDU) {
    106                 if (!hdu->header) {
    107                     hdu->header = psMetadataAlloc();
    108                 }
    109                 ppSubVersionMetadata(hdu->header);
    110                 lastHDU = hdu;
    111100            }
    112101
  • branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubReadoutUpdate.c

    r22419 r23199  
    4444    psMetadataAddStr(outHDU->header, PS_LIST_TAIL, "PPSUB.INPUT", 0,
    4545                     "Subtraction input", inFile->filename);
     46    ppSubVersionHeader(outHDU->header);
    4647
    4748    // Statistics on the matching
  • branches/cnb_branches/cnb_branch_20090215/ppSub/src/ppSubVersion.c

    r22419 r23199  
    1919#include <psmodules.h>
    2020#include <ppStats.h>
     21#include <psphot.h>
    2122
    2223#include "ppSub.h"
    2324
    24 static const char *cvsTag = "$Name: not supported by cvs2svn $";///< CVS tag name
    25 
    2625psString ppSubVersion(void)
    2726{
    28     psString version = NULL;            // Version, to return
    29     psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
    30     return version;
     27#ifndef PPSUB_VERSION
     28#error "PPSUB_VERSION is not set"
     29#endif
     30#ifndef PPSUB_BRANCH
     31#error "PPSUB_BRANCH is not set"
     32#endif
     33    return psStringCopy(PPSUB_BRANCH "@" PPSUB_VERSION);
     34}
     35
     36psString ppSubSource(void)
     37{
     38#ifndef PPSUB_SOURCE
     39#error "PPSUB_SOURCE is not set"
     40#endif
     41    return psStringCopy(PPSUB_SOURCE);
    3142}
    3243
    3344psString ppSubVersionLong(void)
    3445{
    35     psString version = ppSubVersion(); // Version, to return
    36     psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
    37     psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
    38     psFree(tag);
     46    psString version = ppSubVersion();  // Version, to return
     47    psString source = ppSubSource();    // Source
     48
     49    psStringPrepend(&version, "ppSub ");
     50    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
     51    psFree(source);
     52
     53#ifdef __OPTIMIZE__
     54    psStringAppend(&version, " optimised");
     55#else
     56    psStringAppend(&version, " unoptimised");
     57#endif
     58
    3959    return version;
    40 }
     60};
    4161
    4262
    43 void ppSubVersionMetadata(psMetadata *metadata)
     63bool ppSubVersionHeader(psMetadata *header)
    4464{
    45     PS_ASSERT_METADATA_NON_NULL(metadata,);
    46 
    47     psString pslib = psLibVersionLong();// psLib version
    48     psString psmodules = psModulesVersionLong(); // psModules version
    49     psString ppStats = ppStatsVersionLong(); // ppStats version
    50     psString ppSub = ppSubVersionLong(); // ppSub version
     65    PS_ASSERT_METADATA_NON_NULL(header, false);
    5166
    5267    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
    5368    psString timeString = psTimeToISO(time); // The time in an ISO string
    5469    psFree(time);
    55     psString head = NULL;               // Head string
    56     psStringAppend(&head, "ppSub processing at %s. Component information:", timeString);
     70    psString history = NULL;               // History string
     71    psStringAppend(&history, "ppSub at %s", timeString);
     72    psFree(timeString);
     73    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     74    psFree(history);
     75
     76    psLibVersionHeader(header);
     77    psModulesVersionHeader(header);
     78    psphotVersionHeader(header);
     79    ppStatsVersionHeader(header);
     80
     81    psString version = ppSubVersion(); // Software version
     82    psString source  = ppSubSource();  // Software source
     83
     84    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPSUB.VERSION", PS_META_REPLACE,
     85                     "Software version", version);
     86    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPSUB.SOURCE", PS_META_REPLACE,
     87                     "S/W source", source);
     88
     89    psFree(version);
     90    psFree(source);
     91
     92    return true;
     93}
     94
     95void ppSubVersionPrint(void)
     96{
     97    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     98    psString timeString = psTimeToISO(time); // The time in an ISO string
     99    psFree(time);
     100    psLogMsg("ppSub", PS_LOG_INFO, "ppSub at %s", timeString);
    57101    psFree(timeString);
    58102
    59     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");
    60     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");
    61     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");
    62     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, "");
    63     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppSub, "");
     103    psString pslib = psLibVersionLong();// psLib version
     104    psString psmodules = psModulesVersionLong(); // psModules version
     105    psString psphot = psphotVersionLong(); // psphot version
     106    psString ppStats = ppStatsVersionLong(); // ppStats version
     107    psString ppSub = ppSubVersionLong(); // ppSub version
    64108
    65     psFree(head);
     109    psLogMsg("ppSub", PS_LOG_INFO, "%s", pslib);
     110    psLogMsg("ppSub", PS_LOG_INFO, "%s", psmodules);
     111    psLogMsg("ppSub", PS_LOG_INFO, "%s", psphot);
     112    psLogMsg("ppSub", PS_LOG_INFO, "%s", ppStats);
     113    psLogMsg("ppSub", PS_LOG_INFO, "%s", ppSub);
     114
    66115    psFree(pslib);
    67116    psFree(psmodules);
     117    psFree(psphot);
    68118    psFree(ppStats);
    69119    psFree(ppSub);
  • branches/cnb_branches/cnb_branch_20090215/psLib/configure.ac

    r21400 r23199  
    122122TMP_CPPFLAGS=${CPPFLAGS}
    123123
    124 AC_ARG_WITH(cfitsio,
    125 [AS_HELP_STRING(--with-cfitsio=DIR,Specify location of CFITSIO.)],
    126 [CFITSIO_CFLAGS="-I$withval/include"
    127  CFITSIO_LDFLAGS="-L$withval/lib"])
    128 AC_ARG_WITH(cfitsio-include,
    129 [AS_HELP_STRING(--with-cfitsio-include=DIR,Specify CFITSIO include directory.)],
    130 [CFITSIO_CFLAGS="-I$withval"])
    131 AC_ARG_WITH(cfitsio-lib,
    132 [AS_HELP_STRING(--with-cfitsio-lib=DIR,Specify CFITSIO library directory.)],
    133 [CFITSIO_LDFLAGS="-L$withval"])
     124PKG_CHECK_MODULES([CFITSIO], [cfitsio], [], AC_MSG_ERROR([CFITSIO package not found.  Obtain CFITSIO at  http://heasarc.gsfc.nasa.gov/docs/software/fitsio]))
     125
    134126PSLIB_CFLAGS="${PSLIB_CFLAGS=} ${CFITSIO_CFLAGS}"
    135 PSLIB_LIBS="${PSLIB_LIBS=} $CFITSIO_LDFLAGS -lcfitsio -lm"
     127PSLIB_LIBS="${PSLIB_LIBS=} ${CFITSIO_LIBS}"
    136128
    137129CFLAGS="${CFLAGS=} ${CFITSIO_CFLAGS}"
    138 LDFLAGS="${LDFLAGS=} ${CFITSIO_LDFLAGS}"
    139 
    140 dnl Solaris needs to suck in these symbols from unusual locations
    141 AC_SEARCH_LIBS([gethostbyname], [nsl])
    142 AC_SEARCH_LIBS([socket], [socket])
    143 
    144 AC_CHECK_HEADERS([fitsio.h],[],
    145    [AC_MSG_ERROR([CFITSIO headers not found.  Obtain CFITSIO at  http://heasarc.gsfc.nasa.gov/docs/software/fitsio or use --with-cfitsio to specify location.])]
    146 )
    147 TMP_LIBS=${LIBS}
    148 AC_CHECK_LIB(cfitsio,ffopen,[],
    149   [AC_MSG_ERROR([CFITSIO library not found.  Obtain it at  http://heasarc.gsfc.nasa.gov/docs/software/fitsio or use --with-cfitsio to specify location.])],[-lm]
    150 )
     130LDFLAGS="${LDFLAGS=} ${CFITSIO_LIBS}"
     131
    151132dnl Now check if CFITSIO supports fits_open_diskfile, i.e., is at least version 2.501
    152 AC_CHECK_LIB(cfitsio,ffdkopn,
     133AC_CHECK_FUNC(ffdkopn,
    153134  [CFITSIO_DISKFILE=1],
    154135  [AC_MSG_WARN([The CFITSIO library version is rather old.  Suggested version is 2.501 or greater.])
    155    CFITSIO_DISKFILE=0],[-lm]
     136   CFITSIO_DISKFILE=0]
    156137)
    157138
    158139AC_DEFINE_UNQUOTED([CFITSIO_DISKFILE],${CFITSIO_DISKFILE},[Define to 1 if you have fits_open_diskfile in CFITSIO])
     140
    159141AC_SUBST([CFITSIO_CFLAGS])
     142AC_SUBST([CFITSIO_LIBS])
    160143
    161144dnl restore the LIBS/CFLAGS/LDFLAGS
     
    173156TMP_CPPFLAGS=${CPPFLAGS}
    174157
    175 AC_ARG_WITH(fftw3,
    176 [AS_HELP_STRING(--with-fftw3=DIR,Specify location of FFTW version 3.)],
    177 [FFTW3_CFLAGS="-I$withval/include"
    178  FFTW3_LDFLAGS="-L$withval/lib"])
    179 AC_ARG_WITH(fftw3-include,
    180 [AS_HELP_STRING(--with-fftw3-include=DIR,Specify FFTW version 3 include directory.)],
    181 [FFTW3_CFLAGS="-I$withval"])
    182 AC_ARG_WITH(fftw3-lib,
    183 [AS_HELP_STRING(--with-fftw3-lib=DIR,Specify FFTW version 3 library directory.)],
    184 [FFTW3_LDFLAGS="-L$withval"])
     158PKG_CHECK_MODULES([FFTW3], [fftw3f], [], AC_MSG_ERROR([FFTW version 3 (--enable-float) library not found.  Obtain it at http://www.fftw.org/]))
     159
    185160PSLIB_CFLAGS="${PSLIB_CFLAGS=} ${FFTW3_CFLAGS}"
    186 PSLIB_LIBS="${PSLIB_LIBS=} $FFTW3_LDFLAGS -lfftw3f"
     161PSLIB_LIBS="${PSLIB_LIBS=} ${FFTW3_LIBS}"
    187162
    188163CFLAGS="${CFLAGS} ${FFTW3_CFLAGS}"
    189164CPPFLAGS=${CFLAGS}
    190 LDFLAGS="${LDFLAGS} ${FFTW3_LDFLAGS}"
    191 
    192 AC_CHECK_LIB(fftw3f,fftwf_plan_dft_2d,[],
    193   [AC_MSG_ERROR([FFTW version 3 (--enable-float) library not found.  Obtain it at http://www.fftw.org/ or use --with-fftw3 to specify location.])])
    194 
    195 FFTW_THREADS=0
    196 AC_CHECK_LIB(fftw3f,fftwf_init_threads,[FFTW_THREADS=1],
    197   [AC_CHECK_LIB(fftw3f_threads,fftwf_init_threads, [
    198     FFTW_THREADS=1
    199     PSLIB_LIBS="${PSLIB_LIBS=} -lfftw3f_threads"],
    200    AC_MSG_WARN([FFTW version 3 not compiled with thread support (--enable-threads)]),[-lm]
    201    )],[-lm]
    202 )
    203 
    204 dnl AC_CHECK_LIB(fftw3f,fftwf_plan_dft_2d,[],
    205 dnl   [AC_MSG_ERROR([FFTW version 3 (--enable-float) library not found.  Obtain it at http://www.fftw.org/ or use --with-fftw3 to specify location.])],[-lm]
    206 dnl )
    207 
    208 AC_CHECK_HEADERS([fftw3.h],[],
    209   [AC_MSG_ERROR([FFTW version 3 (--enable-float) headers not found.  Obtain it at http://www.fftw.org/ or use --with-fftw3 to specify location.])]
    210 )
    211 
     165LDFLAGS="${LDFLAGS} ${FFTW3_LIBS}"
     166
     167AC_CHECK_FUNC(fftwf_plan_dft_2d,[],
     168  [AC_MSG_ERROR([FFTW version 3 (--enable-float) library not found.  Obtain it at http://www.fftw.org/])])
     169AC_CHECK_FUNC(fftwf_init_threads,[FFTW_THREADS=1],[FFTW_THREADS=0])
    212170AC_DEFINE_UNQUOTED([HAVE_FFTW_THREADS],${FFTW_THREADS},[Define to 1 if you have FFTW compiled with thread support])
    213171
    214172AC_SUBST([FFTW3_CFLAGS])
     173AC_SUBST([FFTW3_LIBS])
    215174
    216175dnl restore the CFLAGS/LDFLAGS
     
    228187TMP_CPPFLAGS=${CPPFLAGS}
    229188
    230 AC_ARG_WITH(gsl-config,
    231 [AS_HELP_STRING(--with-gsl-config=FILE,Specify location of gsl-config.)],
    232 [GSL_CONFIG=$withval],
    233 [GSL_CONFIG=`which gsl-config`])
    234 AC_CHECK_FILE($GSL_CONFIG,[],
    235     [AC_MSG_ERROR([GSL is required.  Obtain it at http://www.gnu.org/software/gsl or use --with-gsl-config to specify location.])])
    236 
    237 AC_MSG_CHECKING([GSL cflags])
    238 GSL_CFLAGS="`${GSL_CONFIG} --cflags`"
    239 AC_MSG_RESULT([${GSL_CFLAGS}])
    240 
    241 AC_MSG_CHECKING([GSL ldflags])
    242 GSL_LDFLAGS="`${GSL_CONFIG} --libs`"
    243 AC_MSG_RESULT([${GSL_LDFLAGS}])
     189PKG_CHECK_MODULES([GSL], [gsl], [], AC_MSG_ERROR([GSL is required.  Obtain it at http://www.gnu.org/software/gsl]))
    244190
    245191PSLIB_CFLAGS="${PSLIB_CFLAGS=} ${GSL_CFLAGS}"
    246 PSLIB_LIBS="${PSLIB_LIBS=} ${GSL_LDFLAGS}"
     192PSLIB_LIBS="${PSLIB_LIBS=} ${GSL_LIBS}"
    247193
    248194AC_SUBST([GSL_CFLAGS])
     195AC_SUBST([GSL_LIBS])
    249196
    250197dnl restore the CFLAGS/LDFLAGS
     
    277224LDFLAGS="${LDFLAGS} ${JPEG_LDFLAGS}"
    278225
    279 AC_CHECK_HEADERS([jpeglib.h],[PSLIB_CFLAGS="$PSLIB_CFLAGS $JPEG_CFLAGS"
     226AC_CHECK_HEADERS([jpeglib.h],[PSLIB_CFLAGS="${PSLIB_CFLAGS=} ${JPEG_CFLAGS}"
    280227                              AC_SUBST(JPEG_CFLAGS)],
    281228  [AC_MSG_ERROR([libjpeg headers not found.  Obtain libjpeg from http://www.ijg.org/ or use --with-jpeg to specify location.])]
    282229)
    283230
    284 AC_CHECK_LIB(jpeg,jpeg_CreateCompress,[PSLIB_LIBS="$PSLIB_LIBS $JPEG_LDFLAGS -ljpeg"],
     231AC_CHECK_LIB(jpeg,jpeg_CreateCompress,[PSLIB_LIBS="${PSLIB_LIBS=} ${JPEG_LDFLAGS} -ljpeg"],
    285232  [AC_MSG_ERROR([libjpeg library not found.  Obtain libjpeg from http://www.ijg.org/ or use --with-jpeg to specify location.])]
    286233)
     
    291238LDFLAGS=${TMP_LDFLAGS}
    292239CPPFLAGS=${TMP_CPPFLAGS}
    293 
    294 dnl ------------------- XML2 options ---------------------
    295 dnl AC_ARG_WITH(xml2-config,
    296 dnl [AS_HELP_STRING(--with-xml2-config=FILE,Specify location of xml2-config.)],
    297 dnl [XML_CONFIG=$withval],
    298 dnl [XML_CONFIG=`which xml2-config`])
    299 dnl AC_CHECK_FILE($XML_CONFIG,[],
    300 dnl     [AC_MSG_ERROR([GNOME XML C parser is required.  Obtain it at http://www.xmlsoft.org or use --with-xml2-config to specify location.])])
    301 dnl
    302 dnl AC_MSG_CHECKING([xml2 version])
    303 dnl XML_VERSION=`xml2-config --version`
    304 dnl XML_VERSION_major=`echo $XML_VERSION | ${PERL} -pe 's|^(\d+).*|\1|'`
    305 dnl XML_VERSION_minor=`echo $XML_VERSION | ${PERL} -pe 's|^(\d+)\.(\d+).*|\2|'`
    306 dnl dnl First test the minimum version of 2.6
    307 dnl if test $XML_VERSION_major -lt 2 || ( test $XML_VERSION_major -eq 2 && test $XML_VERSION_minor -lt 6 )
    308 dnl then
    309 dnl     AC_MSG_ERROR([requires libxml2 2.6.0 or greater, found $XML_VERSION.  Install newer version or use --with-xml2-config to specify another location.])
    310 dnl else
    311 dnl     AC_MSG_RESULT([$XML_VERSION... yes])
    312 dnl fi
    313 dnl
    314 dnl AC_MSG_CHECKING([xml2 cflags])
    315 dnl XML_CFLAGS="`${XML_CONFIG} --cflags`"
    316 dnl AC_MSG_RESULT([${XML_CFLAGS}])
    317 dnl
    318 dnl AC_MSG_CHECKING([xml2 ldflags])
    319 dnl XML_LDFLAGS="`${XML_CONFIG} --libs`"
    320 dnl AC_MSG_RESULT([${XML_LDFLAGS}])
    321 dnl
    322 dnl PSLIB_CFLAGS="${PSLIB_CFLAGS=} ${XML_CFLAGS}"
    323 dnl PSLIB_LIBS="${PSLIB_LIBS=} ${XML_LDFLAGS}"
    324 dnl
    325 dnl AC_SUBST([XML_CFLAGS])
    326240
    327241dnl ------------------- SWIG options ---------------------
     
    477391  utils/Makefile
    478392])
    479 dnl src/xml/Makefile
    480 dnl test/xml/Makefile
    481 
    482393
    483394#if test "$SWIG_REQ" == "yes"
  • branches/cnb_branches/cnb_branch_20090215/psLib/src/fits/psFitsHeader.c

    r23197 r23199  
    149149
    150150
    151 bool psFitsCheckSingleCompressedImagePHU(const psFits *fits, psMetadata *header)
     151bool psFitsCheckCompressedImagePHU(const psFits *fits, psMetadata *header)
    152152{
    153153    PS_ASSERT_FITS_NON_NULL(fits, false);
     
    163163    }
    164164
    165     if (psFitsGetSize(fits) != 2) {
    166         // No second extension, or multiple extensions
     165    if (psFitsGetSize(fits) == 1) {
     166        // No extension present
    167167        return false;
    168168    }
     
    416416    // Explore the potential case that this is an empty PHU, and the first extension contains the sole image,
    417417    // which is compressed.
    418     if (psFitsCheckSingleCompressedImagePHU(fits, header)) {
     418    if (psFitsCheckCompressedImagePHU(fits, header)) {
    419419        // This is really what we want, not the empty PHU
    420420        psTrace("psLib.fits", 1,
  • branches/cnb_branches/cnb_branch_20090215/psLib/src/fits/psFitsHeader.h

    r15179 r23199  
    2020
    2121
    22 /// Determine whether the current HDU is an empty PHU with a single compressed image following.
     22/// Determine whether the current HDU is an empty PHU with a compressed image following.
    2323///
    2424/// In that case, what should be treated as an image PHU is technically an empty PHU with a binary table
     
    2626/// following compressed image to determine if this is the case.  If so, the FITS file pointer is left
    2727/// pointing at the compressed image.
    28 bool psFitsCheckSingleCompressedImagePHU(const psFits *fits, ///< FITS file pointer
    29                                          const psMetadata *header ///< Header, or NULL
     28bool psFitsCheckCompressedImagePHU(const psFits *fits, ///< FITS file pointer
     29                                   const psMetadata *header ///< Header, or NULL
    3030    );
    3131
  • branches/cnb_branches/cnb_branch_20090215/psLib/src/fits/psFitsImage.c

    r23197 r23199  
    219219    PS_ASSERT_FITS_NON_NULL(fits, NULL);
    220220
    221     if (psFitsCheckSingleCompressedImagePHU(fits, NULL)) {
     221    if (psFitsCheckCompressedImagePHU(fits, NULL)) {
    222222        // This is really what we want, not the empty PHU
    223223        psTrace("psLib.fits", 1,
     
    432432    PS_ASSERT_INT_NONNEGATIVE(z, NULL);
    433433
    434     if (psFitsCheckSingleCompressedImagePHU(fits, NULL)) {
     434    if (psFitsCheckCompressedImagePHU(fits, NULL)) {
    435435        // This is really what we want, not the empty PHU
    436436        psTrace("psLib.fits", 1,
     
    479479    }
    480480
    481     if (psFitsCheckSingleCompressedImagePHU(fits, NULL)) {
     481    if (psFitsCheckCompressedImagePHU(fits, NULL)) {
    482482        // This is really what we want, not the empty PHU
    483483        psTrace("psLib.fits", 1,
     
    873873    // code replication, and should be sufficient for our needs.
    874874
    875     if (psFitsCheckSingleCompressedImagePHU(fits, NULL)) {
     875    if (psFitsCheckCompressedImagePHU(fits, NULL)) {
    876876        // This is really what we want, not the empty PHU
    877877        psTrace("psLib.fits", 1,
  • branches/cnb_branches/cnb_branch_20090215/psLib/src/imageops/psImageCovariance.c

    r21467 r23199  
    4343    } else {
    4444        covar = psImageCovarianceNone();
     45    }
     46
     47    // Check for non-finite elements
     48    for (int y = kernel->yMin; y <= kernel->yMax; y++) {
     49        for (int x = kernel->xMin; x <= kernel->xMax; x++) {
     50            if (!isfinite(kernel->kernel[y][x])) {
     51                psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     52                        "Non-finite covariance matrix element in kernel at %d,%d", x, y);
     53                psFree(covar);
     54                return NULL;
     55            }
     56        }
     57    }
     58    for (int y = covar->yMin; y <= covar->yMax; y++) {
     59        for (int x = covar->xMin; x <= covar->xMax; x++) {
     60            if (!isfinite(covar->kernel[y][x])) {
     61                psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     62                        "Non-finite covariance matrix element in covariance matrix at %d,%d", x, y);
     63                psFree(covar);
     64                return NULL;
     65            }
     66        }
    4567    }
    4668
     
    110132float psImageCovarianceFactor(const psKernel *covariance)
    111133{
    112     return covariance ? covariance->kernel[0][0] : NAN;
     134    return covariance ? covariance->kernel[0][0] : 1.0;
    113135}
    114136
     
    144166        for (int y = covar->yMin; y <= covar->yMax; y++) {
    145167            for (int x = covar->xMin; x <= covar->xMax; x++) {
     168                if (!isfinite(covar->kernel[y][x])) {
     169                    psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     170                            "Non-finite covariance matrix element at %d,%d for input %d",
     171                            x, y, i);
     172                    psFree(sum);
     173                    return NULL;
     174                }
    146175                sum->kernel[y][x] += covar->kernel[y][x];
    147176            }
     
    192221            int radius = PS_MAX(abs(x), abs(y)); // Squarish radius
    193222            psAssert(radius <= maxRadius, "Radius doesn't fit");
     223            if (!isfinite(covar->kernel[y][x])) {
     224                psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Non-finite covariance matrix element at %d,%d",
     225                        x, y);
     226                return NULL;
     227            }
    194228            radiusSum->data.F64[radius] += fabsf(covar->kernel[y][x]);
    195229            sum += fabsf(covar->kernel[y][x]);
  • branches/cnb_branches/cnb_branch_20090215/psLib/src/pslib_strict.h

    r21283 r23199  
    110110#include "psMetadataItemParse.h"
    111111#include "psMetadataItemCompare.h"
     112#include "psMetadataHeader.h"
    112113#include "psPixels.h"
    113114#include "psArguments.h"
  • branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/Makefile.am

    r19056 r23199  
    33noinst_LTLIBRARIES = libpslibsys.la
    44
    5 libpslibsys_la_CPPFLAGS = $(SRCINC) $(PSLIB_CFLAGS) $(CFITSIO_CFLAGS)
     5PSLIB_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     6PSLIB_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`
     7PSLIB_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     8
     9# Force recompilation of psConfigure.c, since it gets the version information
     10psConfigure.c: FORCE
     11        touch psConfigure.c
     12FORCE: ;
     13
     14libpslibsys_la_CPPFLAGS = $(SRCINC) $(PSLIB_CFLAGS) $(CFITSIO_CFLAGS) -DPSLIB_VERSION=\"$(PSLIB_VERSION)\" -DPSLIB_BRANCH=\"$(PSLIB_BRANCH)\" -DPSLIB_SOURCE=\"$(PSLIB_SOURCE)\"
    615libpslibsys_la_SOURCES = \
    716        psAbort.c \
  • branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/psConfigure.c

    r18953 r23199  
    1212 *  @author Ross Harman, MHPCC
    1313 *  @author Robert DeSonia, MHPCC
     14 *  @author Paul Price, IfA
    1415 *
    15  *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2008-08-08 18:05:08 $
    17  *
    18  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     16 *  Copyright 2004-2009 Institute for Astronomy, University of Hawaii
    1917 */
    2018
     
    2624#include <stdlib.h>
    2725#include <string.h>
     26
     27#include <fitsio.h>
     28#include <longnam.h>
     29#include <fftw3.h>
     30#include <gsl/gsl_version.h>
     31#ifdef HAVE_PSDB
     32#include <mysql.h>
     33#endif
    2834
    2935#include "psAbort.h"
     
    4147static FILE *memCheckFile = NULL;       // File to which to write results of mem check
    4248
    43 static const char *cvsTag = "$Name: not supported by cvs2svn $"; // CVS tag name
    4449
    4550psString psLibVersion(void)
    4651{
    47     psString version = NULL;            // Version, to return
    48     psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
    49     return version;
     52#ifndef PSLIB_VERSION
     53#error "PSLIB_VERSION is not set"
     54#endif
     55#ifndef PSLIB_BRANCH
     56#error "PSLIB_BRANCH is not set"
     57#endif
     58    return psStringCopy(PSLIB_BRANCH "@" PSLIB_VERSION);
     59}
     60
     61psString psLibSource(void)
     62{
     63#ifndef PSLIB_SOURCE
     64#error "PSLIB_SOURCE is not set"
     65#endif
     66    return psStringCopy(PSLIB_SOURCE);
     67}
     68
     69psString psLibDependencies(void)
     70{
     71    psString deps = NULL;               // Dependencies, to return
     72    float cfitsioVersion;               // CFITSIO version number
     73    psStringAppend(&deps, "cfitsio-%.3f gsl-%s %s",
     74                   fits_get_version(&cfitsioVersion), gsl_version, fftwf_version);
     75
     76#ifdef HAVE_PSDB
     77    psStringAppend(&deps, " mysql-%s", mysql_get_client_info());
     78#endif
     79
     80    return deps;
    5081}
    5182
    5283psString psLibVersionLong(void)
    5384{
    54     psString version = psLibVersion();    // Version, to return
    55     psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
     85    psString version = psLibVersion();  // Version, to return
     86    psString source = psLibSource();    // Source
     87    psString deps = psLibDependencies();// Dependencies
    5688
    57 #ifdef HAVE_PSDB
    58     psStringAppend(&version, " (cvs tag %s), %s, %s with psDB", tag, __DATE__, __TIME__);
     89    psStringPrepend(&version, "psLib ");
     90    psStringAppend(&version, " from %s, built %s, %s with %s",
     91                   source, __DATE__, __TIME__, deps);
     92    psFree(source);
     93    psFree(deps);
     94
     95#ifdef __OPTIMIZE__
     96    psStringAppend(&version, " optimised");
    5997#else
    60     psStringAppend(&version, " (cvs tag %s), %s, %s without psDB", tag, __DATE__, __TIME__);
     98    psStringAppend(&version, " unoptimised");
    6199#endif
    62     psFree(tag);
     100
     101#ifdef PS_NO_TRACE
     102    psStringAppend(&version, " without trace");
     103#else
     104    psStringAppend(&version, " with trace");
     105#endif
     106
    63107    return version;
    64 }
     108};
    65109
    66110// Check the memory; intended for use on exit, but might be used elsewhere
  • branches/cnb_branches/cnb_branch_20090215/psLib/src/sys/psConfigure.h

    r13950 r23199  
    2020#define PS_CONFIGURE_H
    2121
     22#include <psString.h>
     23
    2224/// @addtogroup SysUtils System Utilities
    2325/// @{
     
    2931 *  @return psString: String with version name.
    3032 */
    31 psString psLibVersion(
    32     void
    33 );
     33psString psLibVersion(void);
    3434
     35/** Get current psLib source
     36 *
     37 * Returns the current psLib source name as a string.
     38 *
     39 * @return psString: String with source name.
     40 */
     41psString psLibSource(void);
     42
     43/** Get psLib dependencies' versions
     44 *
     45 * Returns the psLib dependency versions as a string.
     46 *
     47 * @return psString: String with dependencies.
     48 */
     49psString psLibDependencies(void);
    3550
    3651/** Get current psLib version (full identification)
  • branches/cnb_branches/cnb_branch_20090215/psLib/src/types/Makefile.am

    r18145 r23199  
    1414        psMetadataItemParse.c \
    1515        psMetadataItemCompare.c \
     16        psMetadataHeader.c \
    1617        psPixels.c \
    1718        psArguments.c   \
     
    3031        psMetadataItemParse.h \
    3132        psMetadataItemCompare.h \
     33        psMetadataHeader.h \
    3234        psPixels.h \
    3335        psArguments.h   \
  • branches/cnb_branches/cnb_branch_20090215/psLib/src/types/psMetadata.h

    r21278 r23199  
    3030#include "psLookupTable.h"
    3131#include "psMutex.h"
     32#include "psError.h"
    3233
    3334#define PS_DATA_IS_PRIMITIVE(TYPE) \
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/camera/pmFPAWrite.c

    r23197 r23199  
    692692                     "Centre of covariance matrix in y", -yMinCovar);
    693693
     694    // Turn off compression
     695    int bitpix = fits->options ? fits->options->bitpix : 0; // Desired bits per pixel
     696    psFitsCompression *compress = psFitsCompressionGet(fits); // Current compression options
     697    if (!psFitsSetCompression(fits, PS_FITS_COMPRESS_NONE, NULL, 0, 0, 0)) {
     698        psError(PS_ERR_UNKNOWN, false, "Unable to set FITS compression to NONE");
     699        psFree(extname);
     700        psFree(header);
     701        psFree(images);
     702        psFree(compress);
     703        return false;
     704    }
     705    if (fits->options) {
     706        fits->options->bitpix = 0;
     707    }
     708
    694709    // Write images
    695710    if (!psFitsWriteImageCube(fits, header, images, extname)) {
     
    699714        psFree(header);
    700715        psFree(images);
     716        if (fits->options) {
     717            fits->options->bitpix = bitpix;
     718        }
     719        psFitsCompressionApply(fits, compress);
     720        psFree(compress);
    701721        return 0;
    702722    }
     
    704724    psFree(header);
    705725    psFree(images);
     726
     727    // Restore compression
     728    if (fits->options) {
     729        fits->options->bitpix = bitpix;
     730    }
     731    if (!psFitsCompressionApply(fits, compress)) {
     732        psError(PS_ERR_UNKNOWN, false, "Unable to set FITS compression to NONE");
     733        psFree(compress);
     734        return false;
     735    }
     736    psFree(compress);
    706737
    707738    return true;
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/config/Makefile.am

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

    r10291 r23199  
    88#include "pmVersion.h"
    99
    10 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name
    11 
    1210psString psModulesVersion(void)
    1311{
    14     psString version = NULL;            // Version, to return
    15     psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
    16     return version;
     12#ifndef PSMODULES_VERSION
     13#error "PSMODULES_VERSION is not set"
     14#endif
     15#ifndef PSMODULES_BRANCH
     16#error "PSMODULES_BRANCH is not set"
     17#endif
     18    return psStringCopy(PSMODULES_BRANCH "@" PSMODULES_VERSION);
    1719}
     20
     21psString psModulesSource(void)
     22{
     23#ifndef PSMODULES_SOURCE
     24#error "PSMODULES_SOURCE is not set"
     25#endif
     26    return psStringCopy(PSMODULES_SOURCE);
     27}
     28
    1829
    1930psString psModulesVersionLong(void)
    2031{
    21     psString version = psModulesVersion(); // Version, to return
    22     psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
     32    psString version = psModulesVersion();  // Version, to return
     33    psString source = psModulesSource();    // Source
    2334
    24     psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
     35    psStringPrepend(&version, "psModules ");
     36    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
     37    psFree(source);
    2538
    26     psFree(tag);
     39#ifdef __OPTIMIZE__
     40    psStringAppend(&version, " optimised");
     41#else
     42    psStringAppend(&version, " unoptimised");
     43#endif
     44
     45#ifdef HAVE_NEBCLIENT
     46    psStringAppend(&version, " with nebclient");
     47#else
     48    psStringAppend(&version, " without nebclient");
     49#endif
     50
    2751    return version;
     52};
     53
     54
     55bool psModulesVersionHeader(psMetadata *header)
     56{
     57    PS_ASSERT_METADATA_NON_NULL(header, false);
     58
     59    psString version = psModulesVersion(); // Software version
     60    psString source = psModulesSource();   // Software source
     61
     62    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSMODULES.VERSION", PS_META_REPLACE,
     63                     "Software version", version);
     64    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSMODULES.SOURCE", PS_META_REPLACE,
     65                     "S/W source", source);
     66
     67    psFree(version);
     68    psFree(source);
     69
     70    return true;
    2871}
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/config/pmVersion.h

    r12696 r23199  
    11/*  @file pmVersion.h
    22 *  @brief Version functions
    3  * 
     3 *
    44 *  @author Paul Price, IfA
    55 *  @author Eugene Magnier, IfA
    6  * 
     6 *
    77 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    88 *  @date $Date: 2007-03-30 21:12:56 $
     
    2222 *  @return psString: String with version name.
    2323 */
    24 psString psModulesVersion(
    25     void
    26 );
     24psString psModulesVersion(void);
     25
     26/** Get current psModules source
     27 *
     28 *  Returns the current psModules source as a string.
     29 *
     30 *  @return psString: String with source.
     31 */
     32psString psModulesSource(void);
    2733
    2834/** Get current psModules version (full identification)
     
    3440psString psModulesVersionLong(void);
    3541
     42/// Populate a header with version information
     43bool psModulesVersionHeader(
     44    psMetadata *header                  ///< Header to populate
     45    );
     46
     47
    3648/// @}
    3749#endif
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/imcombine/pmPSFEnvelope.c

    r22722 r23199  
    115115    for (int i = 0; i < inputs->n; i++) {
    116116        pmPSF *psf = inputs->data[i];   // PSF of interest
     117        if (!psf) {
     118            continue;
     119        }
    117120        pmResiduals *resid = psf->residuals;// PSF residuals
    118121        psf->residuals = NULL;
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/Makefile.am

    r21536 r23199  
    1919        pmModelUtils.c \
    2020        pmSource.c \
     21        pmSourceMasks.c \
    2122        pmSourceMoments.c \
    2223        pmSourceExtendedPars.c \
     
    6970        pmModelUtils.h \
    7071        pmSource.h \
     72        pmSourceMasks.h \
    7173        pmSourceExtendedPars.h \
    7274        pmSourceUtils.h \
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmFootprint.c

    r20937 r23199  
    2828   }
    2929
    30    psTrace("psModules.objects", 5, "---- begin ----\n");
     30   psTrace("psModules.objects", 10, "---- begin ----\n");
    3131
    3232   psFree(tmp->spans);
    3333   psFree(tmp->peaks);
    3434
    35    psTrace("psModules.objects", 5, "---- end ----\n");
     35   psTrace("psModules.objects", 10, "---- end ----\n");
    3636}
    3737
     
    4242                              const psImage *image) // region footprint lives in
    4343{
    44     psTrace("psModules.objects", 5, "---- begin ----\n");
     44    psTrace("psModules.objects", 10, "---- begin ----\n");
    4545
    4646    static int id = 1;
     
    6969    }
    7070
    71     psTrace("psModules.objects", 5, "---- end ----\n");
     71    psTrace("psModules.objects", 10, "---- end ----\n");
    7272    return(footprint);
    7373}
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmModel.c

    r23197 r23199  
    3232static void modelFree(pmModel *tmp)
    3333{
    34     psTrace("psModules.objects", 4, "---- %s() begin ----\n", __func__);
     34    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    3535    psFree(tmp->params);
    3636    psFree(tmp->dparams);
    37     psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);
     37    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    3838}
    3939
     
    4444pmModel *pmModelAlloc(pmModelType type)
    4545{
    46     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     46    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    4747
    4848    pmModelClass *class = pmModelClassSelect (type);
     
    8787    tmp->modelFitStatus     = class->modelFitStatus;
    8888
    89     psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);
     89    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    9090    return(tmp);
    9191}
     
    130130psF32 pmModelEval(pmModel *model, psImage *image, psS32 col, psS32 row)
    131131{
    132     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     132    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    133133    PS_ASSERT_PTR_NON_NULL(image, NAN);
    134134    PS_ASSERT_PTR_NON_NULL(model, NAN);
     
    144144    tmpF = model->modelFunc (NULL, model->params, x);
    145145    psFree(x);
    146     psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);
     146    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    147147    return(tmpF);
    148148}
     
    150150psF32 pmModelEvalWithOffset(pmModel *model, psImage *image, psS32 col, psS32 row, int dx, int dy)
    151151{
    152     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     152    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    153153    PS_ASSERT_PTR_NON_NULL(image, false);
    154154    PS_ASSERT_PTR_NON_NULL(model, false);
     
    164164    tmpF = model->modelFunc (NULL, model->params, x);
    165165    psFree(x);
    166     psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);
     166    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    167167    return(tmpF);
    168168}
     
    180180    )
    181181{
    182     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     182    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    183183
    184184    PS_ASSERT_PTR_NON_NULL(model, false);
     
    344344
    345345    psFree(x);
    346     psTrace("psModules.objects", 3, "---- %s(true) end ----\n", __func__);
     346    psTrace("psModules.objects", 10, "---- %s(true) end ----\n", __func__);
    347347    return(true);
    348348}
     
    356356                psImageMaskType maskVal)
    357357{
    358     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     358    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    359359    psBool rc = AddOrSubModel(image, mask, model, mode, true, maskVal, 0.0, 0.0);
    360     psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc);
     360    psTrace("psModules.objects", 10, "---- %s(%d) end ----\n", __func__, rc);
    361361    return(rc);
    362362}
     
    370370                psImageMaskType maskVal)
    371371{
    372     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     372    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    373373    psBool rc = AddOrSubModel(image, mask, model, mode, false, maskVal, 0.0, 0.0);
    374     psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc);
     374    psTrace("psModules.objects", 10, "---- %s(%d) end ----\n", __func__, rc);
    375375    return(rc);
    376376}
     
    386386                          int dy)
    387387{
    388     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     388    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    389389    psBool rc = AddOrSubModel(image, mask, model, mode, true, maskVal, dx, dy);
    390     psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc);
     390    psTrace("psModules.objects", 10, "---- %s(%d) end ----\n", __func__, rc);
    391391    return(rc);
    392392}
     
    402402                          int dy)
    403403{
    404     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     404    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    405405    psBool rc = AddOrSubModel(image, mask, model, mode, false, maskVal, dx, dy);
    406     psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc);
     406    psTrace("psModules.objects", 10, "---- %s(%d) end ----\n", __func__, rc);
    407407    return(rc);
    408408}
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmMoments.c

    r19879 r23199  
    2727pmMoments *pmMomentsAlloc()
    2828{
    29     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     29    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    3030    pmMoments *tmp = (pmMoments *) psAlloc(sizeof(pmMoments));
    3131    tmp->Mx = 0.0;
     
    5252    tmp->nPixels = 0;
    5353
    54     psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);
     54    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    5555    return(tmp);
    5656}
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmPeaks.c

    r23197 r23199  
    3737                        pmPeakType type)
    3838{
    39     psTrace("psModules.objects", 5, "---- begin ----\n");
     39    psTrace("psModules.objects", 10, "---- begin ----\n");
    4040
    4141    if (peaks == NULL) {
     
    8282    psFree (peak);
    8383
    84     psTrace("psModules.objects", 5, "---- end ----\n");
     84    psTrace("psModules.objects", 10, "---- end ----\n");
    8585    return(peaks);
    8686}
     
    9696                                       psU32 row)
    9797{
    98     psTrace("psModules.objects", 4, "---- %s() begin ----\n", __func__);
     98    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    9999    PS_ASSERT_IMAGE_NON_NULL(image, NULL);
    100100    PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, NULL);
     
    104104        tmpVector->data.F32[col] = image->data.F32[row][col];
    105105    }
    106     psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);
     106    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    107107    return(tmpVector);
    108108}
     
    117117                             psS32 y)
    118118{
    119     psTrace("psModules.objects", 4, "---- %s() begin ----\n", __func__);
     119    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    120120    if ((x >= valid.x0) &&
    121121            (x <= valid.x1) &&
    122122            (y >= valid.y0) &&
    123123            (y <= valid.y1)) {
    124         psTrace("psModules.objects", 4, "---- %s(true) end ----\n", __func__);
     124        psTrace("psModules.objects", 10, "---- %s(true) end ----\n", __func__);
    125125        return(true);
    126126    }
    127     psTrace("psModules.objects", 4, "---- %s(false) end ----\n", __func__);
     127    psTrace("psModules.objects", 10, "---- %s(false) end ----\n", __func__);
    128128    return(false);
    129129}
     
    140140                    pmPeakType type)
    141141{
    142     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     142    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    143143    static int id = 1;
    144144    pmPeak *tmp = (pmPeak *) psAlloc(sizeof(pmPeak));
     
    157157    psMemSetDeallocator(tmp, (psFreeFunc) peakFree);
    158158
    159     psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);
     159    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    160160    return(tmp);
    161161}
     
    172172int pmPeaksCompareAscend (const void **a, const void **b)
    173173{
    174     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     174    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    175175    pmPeak *A = *(pmPeak **)a;
    176176    pmPeak *B = *(pmPeak **)b;
     
    180180    diff = A->value - B->value;
    181181    if (diff < FLT_EPSILON) {
    182         psTrace("psModules.objects", 3, "---- %s(-1) end ----\n", __func__);
     182        psTrace("psModules.objects", 10, "---- %s(-1) end ----\n", __func__);
    183183        return (-1);
    184184    } else if (diff > FLT_EPSILON) {
    185         psTrace("psModules.objects", 3, "---- %s(+1) end ----\n", __func__);
     185        psTrace("psModules.objects", 10, "---- %s(+1) end ----\n", __func__);
    186186        return (+1);
    187187    }
    188     psTrace("psModules.objects", 3, "---- %s(0) end ----\n", __func__);
     188    psTrace("psModules.objects", 10, "---- %s(0) end ----\n", __func__);
    189189    return (0);
    190190}
     
    194194int pmPeaksCompareDescend (const void **a, const void **b)
    195195{
    196     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     196    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    197197    pmPeak *A = *(pmPeak **)a;
    198198    pmPeak *B = *(pmPeak **)b;
     
    202202    diff = A->value - B->value;
    203203    if (diff < FLT_EPSILON) {
    204         psTrace("psModules.objects", 3, "---- %s(+1) end ----\n", __func__);
     204        psTrace("psModules.objects", 10, "---- %s(+1) end ----\n", __func__);
    205205        return (+1);
    206206    } else if (diff > FLT_EPSILON) {
    207         psTrace("psModules.objects", 3, "---- %s(-1) end ----\n", __func__);
     207        psTrace("psModules.objects", 10, "---- %s(-1) end ----\n", __func__);
    208208        return (-1);
    209209    }
    210     psTrace("psModules.objects", 3, "---- %s(0) end ----\n", __func__);
     210    psTrace("psModules.objects", 10, "---- %s(0) end ----\n", __func__);
    211211    return (0);
    212212}
     
    258258                         psF32 threshold)
    259259{
    260     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     260    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    261261    PS_ASSERT_VECTOR_NON_NULL(vector, NULL);
    262262    PS_ASSERT_VECTOR_NON_EMPTY(vector, NULL);
     
    276276            tmpVector = psVectorAlloc(0, PS_TYPE_U32);
    277277        }
    278         psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);
     278        psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    279279        return(tmpVector);
    280280    }
     
    341341    }
    342342
    343     psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);
     343    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    344344    return(tmpVector);
    345345}
     
    363363psArray *pmPeaksInImage(const psImage *image, psF32 threshold)
    364364{
    365     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     365    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    366366    PS_ASSERT_IMAGE_NON_NULL(image, NULL);
    367367    PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, NULL);
    368368    if ((image->numRows == 1) || (image->numCols == 1)) {
    369369        psError(PS_ERR_UNKNOWN, true, "Currently, input image must have at least 2 rows and 2 columns.");
    370         psTrace("psModules.objects", 3, "---- %s(NULL) end ----\n", __func__);
     370        psTrace("psModules.objects", 10, "---- %s(NULL) end ----\n", __func__);
    371371        return(NULL);
    372372    }
     
    425425    //
    426426    if (image->numRows == 1) {
    427         psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);
     427        psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    428428        return(list);
    429429    }
     
    549549    psFree (tmpRow);
    550550    psFree (row1);
    551     psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);
     551    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    552552    return(list);
    553553}
     
    560560    const psRegion valid)
    561561{
    562     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     562    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    563563    PS_ASSERT_PTR_NON_NULL(peaks, NULL);
    564564
     
    575575        psArrayAdd (output, 200, tmpPeak);
    576576    }
    577     psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);
     577    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    578578    return(output);
    579579}
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSource.c

    r23197 r23199  
    4141        return;
    4242
    43     psTrace("psModules.objects", 5, "---- begin ----\n");
     43    psTrace("psModules.objects", 10, "---- begin ----\n");
    4444    psFree(tmp->peak);
    4545    psFree(tmp->pixels);
     
    5555    psFree(tmp->extpars);
    5656    psFree(tmp->blends);
    57     psTrace("psModules.objects", 5, "---- end ----\n");
     57    psTrace("psModules.objects", 10, "---- end ----\n");
    5858}
    5959
     
    9494pmSource *pmSourceAlloc()
    9595{
    96     psTrace("psModules.objects", 5, "---- begin ----\n");
     96    psTrace("psModules.objects", 10, "---- begin ----\n");
    9797    static int id = 1;
    9898    pmSource *source = (pmSource *) psAlloc(sizeof(pmSource));
     
    131131    source->extNsigma = NAN;
    132132
    133     psTrace("psModules.objects", 5, "---- end ----\n");
     133    psTrace("psModules.objects", 10, "---- end ----\n");
    134134    return(source);
    135135}
     
    280280pmPSFClump pmSourcePSFClump(psRegion *region, psArray *sources, psMetadata *recipe)
    281281{
    282     psTrace("psModules.objects", 5, "---- begin ----\n");
     282    psTrace("psModules.objects", 10, "---- begin ----\n");
    283283
    284284    psArray *peaks  = NULL;
     
    496496    }
    497497
    498     psTrace("psModules.objects", 5, "---- end ----\n");
     498    psTrace("psModules.objects", 10, "---- end ----\n");
    499499    return (psfClump);
    500500}
     
    508508bool pmSourceRoughClass(psRegion *region, psArray *sources, psMetadata *recipe, pmPSFClump clump, psImageMaskType maskSat)
    509509{
    510     psTrace("psModules.objects", 5, "---- begin ----");
     510    psTrace("psModules.objects", 10, "---- begin ----");
    511511
    512512    PS_ASSERT_PTR_NON_NULL(sources, false);
     
    664664    psTrace ("psModules.objects", 2, "Ncr:      %3d\n", Ncr);
    665665
    666     psTrace("psModules.objects", 5, "---- end ----\n");
     666    psTrace("psModules.objects", 10, "---- end ----\n");
    667667    return true;
    668668}
     
    692692                     psF32 radius)
    693693{
    694     psTrace("psModules.objects", 5, "---- begin ----\n");
     694    psTrace("psModules.objects", 10, "---- begin ----\n");
    695695    PS_ASSERT_PTR_NON_NULL(source, false);
    696696    PS_ASSERT_PTR_NON_NULL(source->peak, false);
     
    807807        psTrace ("psModules.objects", 3, "insufficient valid pixels (%d vs %d; %f) for source\n",
    808808                 numPixels, (int)(0.75*R2), Sum);
    809         psTrace("psModules.objects", 5, "---- end (false) ----\n");
     809        psTrace("psModules.objects", 10, "---- end (false) ----\n");
    810810        return (false);
    811811    }
     
    824824        psTrace ("psModules.objects", 3, "large centroid swing; invalid peak %d, %d\n",
    825825                 source->peak->x, source->peak->y);
    826         psTrace("psModules.objects", 5, "---- end(false)  ----\n");
     826        psTrace("psModules.objects", 10, "---- end(false)  ----\n");
    827827        return (false);
    828828    }
     
    850850             source->moments->Mxx, source->moments->Myy, source->moments->Mxy);
    851851
    852     psTrace("psModules.objects", 5, "---- end ----\n");
     852    psTrace("psModules.objects", 10, "---- end ----\n");
    853853    return(true);
    854854}
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSource.h

    r23197 r23199  
    1919/// @addtogroup Objects Object Detection / Analysis Functions
    2020/// @{
     21
     22#include <pmSourceMasks.h>
    2123
    2224/** pmSourceType enumeration
     
    3436    PM_SOURCE_TYPE_EXTENDED,            ///< an extended object (eg, galaxy) (subtracted model is EXT)
    3537} pmSourceType;
    36 
    37 // bit flags to distinguish analysis results
    38 typedef enum {
    39     PM_SOURCE_MODE_DEFAULT          = 0x00000000, ///< Initial value: resets all bits
    40     PM_SOURCE_MODE_PSFMODEL         = 0x00000001, ///< Source fitted with a psf model (linear or non-linear)
    41     PM_SOURCE_MODE_EXTMODEL         = 0x00000002, ///< Source fitted with an extended-source model
    42     PM_SOURCE_MODE_FITTED           = 0x00000004, ///< Source fitted with non-linear model (PSF or EXT; good or bad)
    43     PM_SOURCE_MODE_FAIL             = 0x00000008, ///< Fit (non-linear) failed (non-converge, off-edge, run to zero)
    44     PM_SOURCE_MODE_POOR             = 0x00000010, ///< Fit succeeds, but low-SN, high-Chisq, or large (for PSF -- drop?)
    45     PM_SOURCE_MODE_PAIR             = 0x00000020, ///< Source fitted with a double psf
    46     PM_SOURCE_MODE_PSFSTAR          = 0x00000040, ///< Source used to define PSF model
    47     PM_SOURCE_MODE_SATSTAR          = 0x00000080, ///< Source model peak is above saturation
    48     PM_SOURCE_MODE_BLEND            = 0x00000100, ///< Source is a blend with other sourcers
    49     PM_SOURCE_MODE_EXTERNAL         = 0x00000200, ///< Source based on supplied input position
    50     PM_SOURCE_MODE_BADPSF           = 0x00000400, ///< Failed to get good estimate of object's PSF
    51     PM_SOURCE_MODE_DEFECT           = 0x00000800, ///< Source is thought to be a defect
    52     PM_SOURCE_MODE_SATURATED        = 0x00001000, ///< Source is thought to be saturated pixels (bleed trail)
    53     PM_SOURCE_MODE_CR_LIMIT         = 0x00002000, ///< Source has crNsigma above limit
    54     PM_SOURCE_MODE_EXT_LIMIT        = 0x00004000, ///< Source has extNsigma above limit
    55     PM_SOURCE_MODE_MOMENTS_FAILURE  = 0x00008000, ///< could not measure the moments
    56     PM_SOURCE_MODE_SKY_FAILURE      = 0x00010000, ///< could not measure the local sky
    57     PM_SOURCE_MODE_SKYVAR_FAILURE   = 0x00020000, ///< could not measure the local sky variance
    58     PM_SOURCE_MODE_BELOW_MOMENTS_SN = 0x00040000, ///< moments not measured due to low S/N
    59     PM_SOURCE_MODE_BIG_RADIUS       = 0x00100000, ///< poor moments for small radius, try large radius
    60     PM_SOURCE_MODE_AP_MAGS          = 0x00200000, ///< source has an aperture magnitude
    61     PM_SOURCE_MODE_BLEND_FIT        = 0x00400000, ///< source was fitted as a blend
    62     PM_SOURCE_MODE_EXTENDED_FIT     = 0x00800000, ///< full extended fit was used
    63     PM_SOURCE_MODE_EXTENDED_STATS   = 0x01000000, ///< extended aperture stats calculated
    64     PM_SOURCE_MODE_LINEAR_FIT       = 0x02000000, ///< source fitted with the linear fit
    65     PM_SOURCE_MODE_NONLINEAR_FIT    = 0x04000000, ///< source fitted with the non-linear fit
    66     PM_SOURCE_MODE_RADIAL_FLUX      = 0x08000000, ///< radial flux measurements calculated
    67     PM_SOURCE_MODE_SIZE_SKIPPED     = 0x10000000, ///< size could not be determined
    68 } pmSourceMode;
    6938
    7039typedef enum {
     
    10170    pmSourceType type;                  ///< Best identification of object.
    10271    pmSourceMode mode;                  ///< analysis flags set for object.
    103     pmSourceTmpF tmpFlags;              ///< internal-only flags
     72    pmSourceTmpF tmpFlags;              ///< internal-only flags
    10473    psArray *blends;                    ///< collection of sources thought to be confused with object
    10574    float psfMag;                       ///< calculated from flux in modelPSF
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceContour.c

    r20937 r23199  
    5959{
    6060
    61     psTrace("psModules.objects", 4, "---- %s() begin ----\n", __func__);
     61    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    6262
    6363    // We define variables incr and lastColumn so that we can use the same loop
     
    8080        float value = image->data.F32[y][subCol];
    8181        if (value <= threshold) {
    82             psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);
     82            psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    8383            return (subCol);
    8484        }
    8585        subCol += incr;
    8686    }
    87     psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);
     87    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    8888    return (lastColumn);
    8989}
     
    9999{
    100100
    101     psTrace("psModules.objects", 4, "---- %s() begin ----\n", __func__);
     101    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    102102
    103103    // We define variables incr and lastColumn so that we can use the same loop
     
    119119        float value = image->data.F32[y][subCol];
    120120        if (value >= threshold) {
    121             psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);
     121            psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    122122            if (subCol == x) {
    123123                return (subCol);
     
    127127        subCol += incr;
    128128    }
    129     psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);
     129    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    130130    return (lastColumn);
    131131}
     
    149149                       psU32 dir)
    150150{
    151     psTrace("psModules.objects", 4, "---- %s() begin ----\n", __func__);
     151    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    152152    //
    153153    // Convert coords to subImage space.
     
    159159    if (!((0 <= subCol) && (subCol < source->pixels->numCols))) {
    160160        psError(PS_ERR_UNKNOWN, true, "Starting column outside subImage range");
    161         psTrace("psModules.objects", 4, "---- %s(NAN) end ----\n", __func__);
     161        psTrace("psModules.objects", 10, "---- %s(NAN) end ----\n", __func__);
    162162        return(NAN);
    163163    }
    164164    if (!((0 <= subRow) && (subRow < source->pixels->numRows))) {
    165         psTrace("psModules.objects", 4, "---- %s(NAN) end ----\n", __func__);
     165        psTrace("psModules.objects", 10, "---- %s(NAN) end ----\n", __func__);
    166166        psError(PS_ERR_UNKNOWN, true, "Starting row outside subImage range");
    167167        return(NAN);
     
    172172    psF32 oldValue = pmModelEval(source->modelEXT, source->pixels, subCol, subRow);
    173173    if (oldValue == level) {
    174         psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);
     174        psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    175175        return(((psF32) (subCol + source->pixels->col0)));
    176176    }
     
    194194        psF32 newValue = pmModelEval(source->modelEXT, source->pixels, subCol, subRow);
    195195        if (oldValue == level) {
    196             psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);
     196            psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    197197            return((psF32) (subCol + source->pixels->col0));
    198198        }
     
    200200        if ((newValue <= level) && (level <= oldValue)) {
    201201            // This is simple linear interpolation.
    202             psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);
     202            psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    203203            return( ((psF32) (subCol + source->pixels->col0)) + ((psF32) incr) * ((level - newValue) / (oldValue - newValue)) );
    204204        }
     
    206206        if ((oldValue <= level) && (level <= newValue)) {
    207207            // This is simple linear interpolation.
    208             psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);
     208            psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    209209            return( ((psF32) (subCol + source->pixels->col0)) + ((psF32) incr) * ((level - oldValue) / (newValue - oldValue)) );
    210210        }
     
    213213    }
    214214
    215     psTrace("psModules.objects", 4, "---- %s(NAN) end ----\n", __func__);
     215    psTrace("psModules.objects", 10, "---- %s(NAN) end ----\n", __func__);
    216216    return(NAN);
    217217}
     
    222222psArray *pmSourceContour (psImage *image, int xc, int yc, float threshold)
    223223{
    224     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     224    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    225225    PS_ASSERT_PTR_NON_NULL(image, NULL);
    226226
     
    339339    tmpArray->data[0] = (psPtr *) xVec;
    340340    tmpArray->data[1] = (psPtr *) yVec;
    341     psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);
     341    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    342342    return(tmpArray);
    343343}
     
    360360                               psF32 level)
    361361{
    362     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     362    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    363363    PS_ASSERT_PTR_NON_NULL(source, false);
    364364    PS_ASSERT_PTR_NON_NULL(image, false);
     
    390390            psFree(xVec);
    391391            psFree(yVec);
    392             psTrace("psModules.objects", 3, "---- %s(NULL) end ----\n", __func__);
     392            psTrace("psModules.objects", 10, "---- %s(NULL) end ----\n", __func__);
    393393            return(NULL);
    394394            //psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not find contour edge (NAN)\n");
     
    403403            psFree(xVec);
    404404            psFree(yVec);
    405             psTrace("psModules.objects", 3, "---- %s(NULL) end ----\n", __func__);
     405            psTrace("psModules.objects", 10, "---- %s(NULL) end ----\n", __func__);
    406406            return(NULL);
    407407            //psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not find contour edge (NAN)\n");
     
    428428            psFree(xVec);
    429429            psFree(yVec);
    430             psTrace("psModules.objects", 3, "---- %s(NULL) end ----\n", __func__);
     430            psTrace("psModules.objects", 10, "---- %s(NULL) end ----\n", __func__);
    431431            return(NULL);
    432432            //psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not find contour edge (NAN)\n");
     
    440440            psFree(xVec);
    441441            psFree(yVec);
    442             psTrace("psModules.objects", 3, "---- %s(NULL) end ----\n", __func__);
     442            psTrace("psModules.objects", 10, "---- %s(NULL) end ----\n", __func__);
    443443            return(NULL);
    444444            //psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not find contour edge (NAN)\n");
     
    457457    tmpArray->data[0] = (psPtr *) yVec;
    458458    tmpArray->data[1] = (psPtr *) xVec;
    459     psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);
     459    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    460460    return(tmpArray);
    461461}
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceFitModel.c

    r23197 r23199  
    5858                       psImageMaskType maskVal)
    5959{
    60     psTrace("psModules.objects", 5, "---- %s begin ----\n", __func__);
     60    psTrace("psModules.objects", 10, "---- %s begin ----\n", __func__);
    6161    PS_ASSERT_PTR_NON_NULL(source, false);
    6262    PS_ASSERT_PTR_NON_NULL(source->pixels, false);
     
    231231
    232232    rc = (onPic && fitStatus);
    233     psTrace("psModules.objects", 5, "---- %s(%d) end ----\n", __func__, rc);
     233    psTrace("psModules.objects", 10, "---- %s(%d) end ----\n", __func__, rc);
    234234    return(rc);
    235235}
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceFitSet.c

    r21363 r23199  
    446446                     psImageMaskType maskVal)
    447447{
    448     psTrace("psModules.objects", 3, "---- %s begin ----\n", __func__);
     448    psTrace("psModules.objects", 10, "---- %s begin ----\n", __func__);
    449449    PS_ASSERT_PTR_NON_NULL(source, false);
    450450    PS_ASSERT_PTR_NON_NULL(source->pixels, false);
     
    533533    if (nPix <  thisSet->nParamSet + 1) {
    534534        psTrace (__func__, 4, "insufficient valid pixels\n");
    535         psTrace("psModules.objects", 3, "---- %s() end : fail pixels ----\n", __func__);
     535        psTrace("psModules.objects", 10, "---- %s() end : fail pixels ----\n", __func__);
    536536        for (int i = 0; i < modelSet->n; i++) {
    537537            pmModel *model = modelSet->data[i];
     
    602602
    603603    bool rc = (onPic && fitStatus);
    604     psTrace("psModules.objects", 5, "---- %s end (%d) ----\n", __func__, rc);
     604    psTrace("psModules.objects", 10, "---- %s end (%d) ----\n", __func__, rc);
    605605    return(rc);
    606606}
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceIO_CMF_PS1_V1.c

    r23197 r23199  
    209209    }
    210210
     211    psMetadata *header = psMetadataCopy(NULL, tableHeader);
     212    pmSourceMasksHeader(header);
     213
    211214    if (table->n == 0) {
    212         psFitsWriteBlank (fits, tableHeader, extname);
    213         psFree (table);
     215        psFitsWriteBlank(fits, header, extname);
     216        psFree(table);
     217        psFree(header);
    214218        return true;
    215219    }
    216220
    217221    psTrace ("pmFPAfile", 5, "writing ext data %s\n", extname);
    218     if (!psFitsWriteTable (fits, tableHeader, table, extname)) {
     222    if (!psFitsWriteTable(fits, header, table, extname)) {
    219223        psError(PS_ERR_IO, false, "writing ext data %s\n", extname);
    220224        psFree(table);
     225        psFree(header);
    221226        return false;
    222227    }
    223     psFree (table);
     228    psFree(table);
     229    psFree(header);
    224230
    225231    return true;
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceMatch.c

    r21266 r23199  
    6363        pmSource *source = sources->data[i]; // Source of interest
    6464        if (!source) continue;
    65         if (source->mode & SOURCE_MASK) continue;
    66         if (!isfinite(source->psfMag)) continue;
    67         if (!isfinite(source->errMag)) continue;
    68         if (source->psfMag > SOURCE_FAINTEST) continue;
     65        if (source->mode & SOURCE_MASK) continue;
     66        if (!isfinite(source->psfMag)) continue;
     67        if (!isfinite(source->errMag)) continue;
     68        if (source->psfMag > SOURCE_FAINTEST) continue;
    6969
    7070        float xSrc, ySrc;               // Coordinates of source
     
    290290static float sourceMatchRelphotIterate(psVector *trans, // Transparencies
    291291                                       psVector *stars, // Star magnitudes
     292                                       psVector *badImage, // Bad image mask
    292293                                       const psArray *matches, // Array of matches
    293294                                       const psVector *zp, // Zero points for each image (incl. airmass term)
     
    363364    for (int i = 0; i < numImages; i++) {
    364365        trans->data.F32[i] = accum->data.F64[i] / accumErr->data.F64[i];
    365 
     366        if (!isfinite(trans->data.F32[i])) {
     367            badImage->data.U8[i] = 0xFF;
     368        }
    366369        psTrace("psModules.objects", 3, "Transparency for image %d: %f\n", i, trans->data.F32[i]);
    367370    }
     
    379382            }
    380383            int index = match->image->data.U32[j]; // Image index
     384            if (badImage->data.U8[index]) {
     385                continue;
     386            }
    381387            float mag = match->mag->data.F32[j]; // Measured magnitude
    382388            float magErr2 = PS_SQR(match->magErr->data.F32[j]) + sysErr2; // Error in measured magnitude
     
    402408static int sourceMatchRelphotPhotometric(psVector *photo, // Photometric determination
    403409                                         const psVector *trans, // Estimated transparencies
     410                                         const psVector *badImage, // Bad image?
    404411                                         int transIter, // Iterations for transparency
    405412                                         float transClip, // Clipping level for transparency
     
    409416    psAssert(photo && photo->type.type == PS_TYPE_U8, "Need photometric determination");
    410417    psAssert(trans && trans->type.type == PS_TYPE_F32, "Need transparencies");
     418    psAssert(badImage && badImage->type.type == PS_TYPE_U8, "Need bad image determination");
    411419
    412420    int numImages = photo->n;              // Number of images
    413421
    414422    psAssert(trans->n == numImages, "Not enough transparencies: %ld", trans->n);
     423    psAssert(badImage->n == numImages, "Not enough bad image determinations: %ld", badImage->n);
    415424    psAssert(transIter >= 0, "Iterations for transparency must be non-negative: %d", transIter);
    416425    psAssert(transClip > 0, "Clipping level for transparency must be positive: %f", transClip);
     
    421430    stats->clipSigma = transClip;
    422431
    423     if (!psVectorStats(stats, trans, NULL, NULL, 0)) {
     432    if (!psVectorStats(stats, trans, NULL, badImage, 0xFF)) {
    424433        psError(PS_ERR_UNKNOWN, false, "Unable to perform statistics on transparencies.");
    425434        psFree(stats);
     
    432441    int numPhoto = 0;                   // Number of photometric images
    433442    for (int i = 0; i < numImages; i++) {
     443        if (badImage->data.U8[i]) {
     444            continue;
     445        }
    434446        if (trans->data.F32[i] < thresh) {
    435447            photo->data.U8[i] = 0xFF;
     
    451463                                      const psVector *zp, // Zero points for each image
    452464                                      const psVector *photo, // Photometric image?
     465                                      const psVector *badImage, // Bad image?
    453466                                      float starClip, // Clipping for stars
    454467                                      float sysErr2 // Systematic error squared
     
    468481    psAssert(!photo || photo->type.type == PS_TYPE_U8, "Photometric determination is wrong type");
    469482    psAssert(!photo || photo->n == numImages, "Not enough photometric determinations: %ld", photo->n);
     483    psAssert(!badImage || badImage->type.type == PS_TYPE_U8, "Photometric determination is wrong type");
     484    psAssert(!badImage || badImage->n == numImages, "Not enough bad determinations: %ld", badImage->n);
    470485
    471486    starClip = PS_SQR(starClip);
     
    481496            numMeasurements++;
    482497            int index = match->image->data.U32[j]; // Image index
     498            if (badImage->data.U8[index]) {
     499                continue;
     500            }
    483501            float mag = match->mag->data.F32[j]; // Measured magnitude
    484502            float magErr = match->magErr->data.F32[j]; // Error in measured magnitude
     
    489507            float dev = mag + cal - stars->data.F32[i]; // Deviation
    490508
    491             // only reject detections from photometric images (non-photometric images can
    492             // have large errors.  XXX Or: allow a much higher rejection threshold
    493             if (photo->data.U8[index]) {
    494               if (PS_SQR(dev) > starClip * (PS_SQR(magErr) + sysErr2)) {
    495                 numRejected++;
    496                 match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xFF;
    497               }
    498             }
     509            // only reject detections from photometric images (non-photometric images can
     510            // have large errors.  XXX Or: allow a much higher rejection threshold
     511            if (photo->data.U8[index]) {
     512                if (PS_SQR(dev) > starClip * (PS_SQR(magErr) + sysErr2)) {
     513                    numRejected++;
     514                    match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xFF;
     515                }
     516            }
    499517        }
    500518    }
     
    529547    psVector *photo = psVectorAlloc(numImages, PS_TYPE_U8); // Photometric determination for each image
    530548    psVectorInit(photo, 0);
     549    psVector *badImage = psVectorAlloc(numImages, PS_TYPE_U8); // Bad image?
     550    psVectorInit(badImage, 0);
    531551    psVector *stars = psVectorAlloc(numStars, PS_TYPE_F32); // Magnitudes for each star
    532552
    533     float chi2 = sourceMatchRelphotIterate(trans, stars, matches, zp, photo, sysErr); // chi^2 for solution
     553    float chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp,
     554                                           photo, sysErr); // chi^2 for solution
    534555    psTrace("psModules.objects", 1, "Initial: chi^2 = %f\n", chi2);
    535556    float lastChi2 = INFINITY;          // chi^2 on last iteration
     
    540561
    541562        // Identify photometric nights
    542         int numPhoto = sourceMatchRelphotPhotometric(photo, trans, transIter, transClip, photoLevel); // Number of photometric images
    543         if (numPhoto < 0) {
    544             psError(PS_ERR_UNKNOWN, false, "Unable to perform photometric determination");
    545             psFree(trans);
    546             psFree(photo);
    547             psFree(stars);
    548             return NULL;
    549         }
    550         psTrace("psModules.objects", 3, "Pass 1: Determined %d/%d are photometric", numPhoto, numImages);
    551 
    552         // XXX use 20 sigma rejection and 0.1 mag systematic error (move these to the recipe)
    553         fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, 20.0, PS_SQR(0.1));
    554         psTrace("psModules.objects", 3, "Pass 1: %f%% of measurements rejected", fracRej * 100);
    555 
    556         // XXX use 0.05 mag systematic error (move these to the recipe)
    557         chi2 = sourceMatchRelphotIterate(trans, stars, matches, zp, photo, PS_SQR(0.1)); // chi^2 for solution
    558         psTrace("psModules.objects", 1, "Pass 1: iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej);
    559     }
    560 
    561     for (int i = 0; i < maxIter && (fabsf(lastChi2 - chi2) > tol * chi2 || fracRej > rejLimit); i++) {
    562         lastChi2 = chi2;
    563 
    564         // Identify photometric nights
    565         int numPhoto = sourceMatchRelphotPhotometric(photo, trans, transIter, transClip,
     563        int numPhoto = sourceMatchRelphotPhotometric(photo, trans, badImage, transIter, transClip,
    566564                                                     photoLevel); // Number of photometric images
    567565        if (numPhoto < 0) {
     
    572570            return NULL;
    573571        }
     572        psTrace("psModules.objects", 3, "Pass 1: Determined %d/%d are photometric", numPhoto, numImages);
     573
     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));
     576        psTrace("psModules.objects", 3, "Pass 1: %f%% of measurements rejected", fracRej * 100);
     577
     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));
     580        psTrace("psModules.objects", 1, "Pass 1: iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej);
     581    }
     582
     583    for (int i = 0; i < maxIter && (fabsf(lastChi2 - chi2) > tol * chi2 || fracRej > rejLimit); i++) {
     584        lastChi2 = chi2;
     585
     586        // Identify photometric nights
     587        int numPhoto = sourceMatchRelphotPhotometric(photo, trans, badImage, transIter, transClip,
     588                                                     photoLevel); // Number of photometric images
     589        if (numPhoto < 0) {
     590            psError(PS_ERR_UNKNOWN, false, "Unable to perform photometric determination");
     591            psFree(trans);
     592            psFree(photo);
     593            psFree(stars);
     594            return NULL;
     595        }
    574596        psTrace("psModules.objects", 3, "Determined %d/%d are photometric", numPhoto, numImages);
    575597
    576         fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, starClip, sysErr);
     598        fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, badImage, starClip, sysErr);
    577599        psTrace("psModules.objects", 3, "%f%% of measurements rejected", fracRej * 100);
    578600
    579         chi2 = sourceMatchRelphotIterate(trans, stars, matches, zp, photo, sysErr); // chi^2 for solution
     601        chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp, photo, sysErr);
    580602        psTrace("psModules.objects", 1, "iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej);
    581603    }
    582604
    583605    psFree(photo);
     606    psFree(badImage);
    584607    psFree(stars);
    585608
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceSky.c

    r21363 r23199  
    5555    psImageMaskType markVal)
    5656{
    57     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     57    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    5858    PS_ASSERT_PTR_NON_NULL(source, false);
    5959    PS_ASSERT_IMAGE_NON_NULL(source->pixels, false);
     
    9191
    9292    if (isnan(value)) {
    93         psTrace("psModules.objects", 3, "---- %s(false) end ----\n", __func__);
     93        psTrace("psModules.objects", 10, "---- %s(false) end ----\n", __func__);
    9494        return(false);
    9595    }
     
    9898    }
    9999    source->moments->Sky = value;
    100     psTrace("psModules.objects", 3, "---- %s(true) end ----\n", __func__);
     100    psTrace("psModules.objects", 10, "---- %s(true) end ----\n", __func__);
    101101    return (true);
    102102}
     
    111111)
    112112{
    113     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     113    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    114114    PS_ASSERT_PTR_NON_NULL(source, false);
    115115    PS_ASSERT_IMAGE_NON_NULL(source->variance, false);
     
    147147
    148148    if (isnan(value)) {
    149         psTrace("psModules.objects", 3, "---- %s(false) end ----\n", __func__);
     149        psTrace("psModules.objects", 10, "---- %s(false) end ----\n", __func__);
    150150        return(false);
    151151    }
     
    154154    }
    155155    source->moments->dSky = value;
    156     psTrace("psModules.objects", 3, "---- %s(true) end ----\n", __func__);
     156    psTrace("psModules.objects", 10, "---- %s(true) end ----\n", __func__);
    157157    return (true);
    158158}
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceUtils.c

    r20937 r23199  
    4949                            pmModelType modelType)
    5050{
    51     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     51    psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);
    5252    PS_ASSERT_PTR_NON_NULL(source, NULL);
    5353    PS_ASSERT_PTR_NON_NULL(source->moments, NULL);
     
    6161    }
    6262
    63     psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);
     63    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    6464    return(model);
    6565}
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/objects/pmSourceVisual.c

    r22722 r23199  
    77#include "pmSourceVisual.h"
    88
    9 # if (HAVE_KAPA)
    10 # include <kapa.h>
     9#if (HAVE_KAPA)
     10#include <kapa.h>
    1111#include "pmVisual.h"
    1212
     
    155155    // continue, save (provide name), ??
    156156    pmVisualAskUser(&plotPSF);
     157
    157158    return true;
    158159}
     
    251252}
    252253
    253 # else
    254 # endif
     254#else
     255
     256bool pmSourceSetVisual(bool mode)
     257{
     258    return true;
     259}
     260
     261bool pmSourceVisualPSFModelResid(pmTrend2D *trend, psVector *x, psVector *y, psVector *param, psVector *mask)
     262{
     263    return true;
     264}
     265
     266#endif
  • branches/cnb_branches/cnb_branch_20090215/psModules/src/psmodules.h

    r23197 r23199  
    114114#include <pmPSF.h>
    115115#include <pmModel.h>
     116#include <pmSourceMasks.h>
    116117#include <pmSource.h>
    117118#include <pmSourceUtils.h>
  • branches/cnb_branches/cnb_branch_20090215/psastro/src/Makefile.am

    r21422 r23199  
     1lib_LTLIBRARIES = libpsastro.la
    12
    2 lib_LTLIBRARIES = libpsastro.la
    3 libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
    4 libpsastro_la_LDFLAGS = $(PSASTRO_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
     3PSASTRO_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4PSASTRO_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`
     5PSASTRO_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     6
     7# Force recompilation of psastroVersion.c, since it gets the version information
     8psastroVersion.c: FORCE
     9        touch psastroVersion.c
     10FORCE: ;
     11
     12libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSASTRO_VERSION=\"$(PSASTRO_VERSION)\" -DPSASTRO_BRANCH=\"$(PSASTRO_BRANCH)\" -DPSASTRO_SOURCE=\"$(PSASTRO_SOURCE)\"
     13libpsastro_la_LDFLAGS = $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    514
    615bin_PROGRAMS = psastro psastroModel psastroModelFit gpcModel
  • branches/cnb_branches/cnb_branch_20090215/psastro/src/psastro.c

    r21409 r23199  
    3434    if (!config) usage ();
    3535
     36    psastroVersionPrint();
     37
    3638    // load identify the data sources
    3739    if (!psastroParseCamera (config)) {
    38         psErrorStackPrint(stderr, "error setting up the camera\n");
    39         exit (1);
     40        psErrorStackPrint(stderr, "error setting up the camera\n");
     41        exit (1);
    4042    }
    4143
     
    4345    // select subset of stars for astrometry
    4446    if (!psastroDataLoad (config)) {
    45         psErrorStackPrint(stderr, "error loading input data\n");
    46         exit (1);
     47        psErrorStackPrint(stderr, "error loading input data\n");
     48        exit (1);
    4749    }
    4850
    4951    // run the full astrometry analysis (chip and/or mosaic)
    5052    if (!psastroAnalysis (config)) {
    51         psErrorStackPrint(stderr, "failure in psastro analysis\n");
    52         exit (1);
     53        psErrorStackPrint(stderr, "failure in psastro analysis\n");
     54        exit (1);
    5355    }
    54    
     56
    5557    // write out the results
    5658    if (!psastroDataSave (config)) {
    57         psErrorStackPrint(stderr, "failed to write out data\n");
    58         exit (1);
     59        psErrorStackPrint(stderr, "failed to write out data\n");
     60        exit (1);
    5961    }
    6062
  • branches/cnb_branches/cnb_branch_20090215/psastro/src/psastro.h

    r21422 r23199  
    9595// Return version strings.
    9696psString          psastroVersion(void);
     97psString          psastroSource(void);
    9798psString          psastroVersionLong(void);
     99bool              psastroVersionHeader(psMetadata *header);
     100bool              psastroVersionHeaderFull(psMetadata *header);
     101void              psastroVersionPrint(void);
    98102
    99103// demo plots
  • branches/cnb_branches/cnb_branch_20090215/psastro/src/psastroDataSave.c

    r21409 r23199  
    1818  return false; \
    1919}
    20  
     20
    2121/**
    2222 * this loop saves the photometry/astrometry data files
     
    3131    psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSASTRO_RECIPE);
    3232    if (!recipe) {
    33         psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe!\n");
    34         return false;
     33        psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe!\n");
     34        return false;
    3535    }
    3636
     
    3838    pmFPAfile *output = psMetadataLookupPtr (NULL, config->files, "PSASTRO.OUTPUT");
    3939    if (!output) {
    40         psError(PSASTRO_ERR_CONFIG, true, "Can't find or interpret output file rule PSASTRO.OUTPUT!\n");
    41         return false;
     40        psError(PSASTRO_ERR_CONFIG, true, "Can't find or interpret output file rule PSASTRO.OUTPUT!\n");
     41        return false;
    4242    }
    4343
     
    4848
    4949    pmFPAview *view = pmFPAviewAlloc (0);
     50    pmHDU *lastHDU = NULL;              // Last HDU updated
    5051
    5152    // open/load files as needed
     
    5556        psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    5657        if (!chip->process || !chip->file_exists) { continue; }
    57         if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
     58        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
    5859
    59         while ((cell = pmFPAviewNextCell (view, output->fpa, 1)) != NULL) {
     60        while ((cell = pmFPAviewNextCell (view, output->fpa, 1)) != NULL) {
    6061            psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    6162            if (!cell->process || !cell->file_exists) { continue; }
    62             if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
     63            if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
    6364
    64             // process each of the readouts
    65             while ((readout = pmFPAviewNextReadout (view, output->fpa, 1)) != NULL) {
    66                 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
    67                 if (!readout->data_exists) { continue; }
     65            // process each of the readouts
     66            while ((readout = pmFPAviewNextReadout (view, output->fpa, 1)) != NULL) {
     67                if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
     68                if (!readout->data_exists) { continue; }
    6869
    69                 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
    70             }
    71             if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
    72         }
    73         if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
     70                // Put version information into the header
     71                pmHDU *hdu = pmHDUGetHighest(output->fpa, chip, cell);
     72                if (hdu && hdu != lastHDU) {
     73                    psastroVersionHeaderFull(hdu->header);
     74                    lastHDU = hdu;
     75                }
     76
     77                if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
     78            }
     79            if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
     80        }
     81        if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
    7482    }
    7583    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
  • branches/cnb_branches/cnb_branch_20090215/psastro/src/psastroVersion.c

    r21409 r23199  
    55 *  @ingroup libpsastro
    66 *
    7  *  @author IfA
    8  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-07 02:03:34 $
    107 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    118 */
     
    1310#include "psastroInternal.h"
    1411
    15 static const char *cvsTag = "$Name: not supported by cvs2svn $";///< CVS tag name
    16 
    1712psString psastroVersion(void)
    1813{
    19     psString version = NULL;            // Version, to return
    20     psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
    21     return version;
     14#ifndef PSASTRO_VERSION
     15#error "PSASTRO_VERSION is not set"
     16#endif
     17#ifndef PSASTRO_BRANCH
     18#error "PSASTRO_BRANCH is not set"
     19#endif
     20    return psStringCopy(PSASTRO_BRANCH "@" PSASTRO_VERSION);
     21}
     22
     23psString psastroSource(void)
     24{
     25#ifndef PSASTRO_SOURCE
     26#error "PSASTRO_SOURCE is not set"
     27#endif
     28    return psStringCopy(PSASTRO_SOURCE);
    2229}
    2330
    2431psString psastroVersionLong(void)
    2532{
    26     psString version = psastroVersion(); // Version, to return
    27     psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
    28     psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
    29     psFree(tag);
     33    psString version = psastroVersion();  // Version, to return
     34    psString source = psastroSource();    // Source
     35
     36    psStringPrepend(&version, "psastro ");
     37    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
     38    psFree(source);
     39
     40#ifdef __OPTIMIZE__
     41    psStringAppend(&version, " optimised");
     42#else
     43    psStringAppend(&version, " unoptimised");
     44#endif
     45
    3046    return version;
     47};
     48
     49bool psastroVersionHeader(psMetadata *header)
     50{
     51    PS_ASSERT_METADATA_NON_NULL(header, false);
     52
     53    psString version = psastroVersion(); // Software version
     54    psString source = psastroSource();   // Software source
     55
     56    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSASTRO.VERSION", PS_META_REPLACE,
     57                     "Software version", version);
     58    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSASTRO.SOURCE", PS_META_REPLACE,
     59                     "S/W source", source);
     60
     61    psFree(version);
     62    psFree(source);
     63
     64    return true;
    3165}
    3266
     67bool psastroVersionHeaderFull(psMetadata *header)
     68{
     69    PS_ASSERT_METADATA_NON_NULL(header, false);
     70
     71    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     72    psString timeString = psTimeToISO(time); // The time in an ISO string
     73    psFree(time);
     74    psString history = NULL;               // History string
     75    psStringAppend(&history, "psastro at %s", timeString);
     76    psFree(timeString);
     77    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     78    psFree(history);
     79
     80    psLibVersionHeader(header);
     81    psModulesVersionHeader(header);
     82    ppStatsVersionHeader(header);
     83    psastroVersionHeader(header);
     84
     85    return true;
     86}
     87
     88void psastroVersionPrint(void)
     89{
     90    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     91    psString timeString = psTimeToISO(time); // The time in an ISO string
     92    psFree(time);
     93    psLogMsg("psastro", PS_LOG_INFO, "psastro at %s", timeString);
     94    psFree(timeString);
     95
     96    psString pslib = psLibVersionLong();// psLib version
     97    psString psmodules = psModulesVersionLong(); // psModules version
     98    psString ppStats = ppStatsVersionLong(); // ppStats version
     99    psString psastro = psastroVersionLong(); // psastro version
     100
     101    psLogMsg("psastro", PS_LOG_INFO, "%s", pslib);
     102    psLogMsg("psastro", PS_LOG_INFO, "%s", psmodules);
     103    psLogMsg("psastro", PS_LOG_INFO, "%s", ppStats);
     104    psLogMsg("psastro", PS_LOG_INFO, "%s", psastro);
     105
     106    psFree(pslib);
     107    psFree(psmodules);
     108    psFree(ppStats);
     109    psFree(psastro);
     110
     111    return;
     112}
  • branches/cnb_branches/cnb_branch_20090215/psconfig/psbuild

    r23197 r23199  
    247247
    248248        if (-e "Build.PL") {
    249             vsystem ("$psperlbuild");
    250             if ($?) { &failure($module[$i], "failure in perl Build.PL"); }
    251 
    252             vsystem ("./Build");
    253             if ($?) { &failure($module[$i], "failure in Build"); }
    254 
    255             vsystem ("./Build install");
    256             if ($?) { &failure($module[$i], "failure in Build install"); }
     249            $status = vsystem ("$psperlbuild");
     250            if ($status) { &failure($module[$i], "failure in perl Build.PL"); }
     251
     252            $status = vsystem ("./Build");
     253            if ($status) { &failure($module[$i], "failure in Build"); }
     254
     255            $status = vsystem ("./Build install");
     256            if ($status) { &failure($module[$i], "failure in Build install"); }
    257257
    258258            next;
     
    272272        if ($developer && $rebuild_this && ! -e "configure" && -e "autogen.sh") {
    273273            $skip_configure = 1;
    274             vsystem ("$psautogen $psopts");
    275             if ($?) { &failure($module[$i], "failure in psautogen"); }
     274            $status = vsystem ("$psautogen $psopts");
     275            if ($status) { &failure($module[$i], "failure in psautogen"); }
    276276        }
    277277
    278278        if ($rebuild_this && -e "configure" && !$skip_configure) {
    279             vsystem ("$psconfigure $psopts");
    280             if ($?) { &failure($module[$i], "failure in psconfigure"); }
     279            $status = vsystem ("$psconfigure $psopts");
     280            if ($status) { &failure($module[$i], "failure in psconfigure"); }
    281281        }
    282282
     
    288288
    289289        if ($clean) {
    290             vsystem ("$make clean");
    291             if ($?) { &failure($module[$i], "failure in make clean"); }
    292         }
    293 
    294         vsystem ("$make");
    295         if ($?) { &failure($module[$i], "failure in make"); }
    296 
    297         vsystem ("$make install");
    298         if ($?) { &failure($module[$i], "failure in make install"); }
     290            $status = vsystem ("$make clean");
     291            if ($status) { &failure($module[$i], "failure in make clean"); }
     292        }
     293
     294        $status = vsystem ("$make");
     295        if ($status) { &failure($module[$i], "failure in make"); }
     296
     297        $status = vsystem ("$make install");
     298        if ($status) { &failure($module[$i], "failure in make install"); }
    299299
    300300        print "*** done with $module[$i] ***\n";
  • branches/cnb_branches/cnb_branch_20090215/psconfig/pschecklibs

    r23197 r23199  
    487487
    488488sub usage {
    489     print STDERR "USAGE: pscheckperl [-version] [-build]\n";
     489    print STDERR "USAGE: pschecklibs [-version] [-build]\n";
    490490    exit 2;
    491491}
  • branches/cnb_branches/cnb_branch_20090215/psphot/src/Makefile.am

    r21392 r23199  
    11lib_LTLIBRARIES = libpsphot.la
    2 libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
     2
     3PSPHOT_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4PSPHOT_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`
     5PSPHOT_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
     8psphotVersion.c: FORCE
     9        touch psphotVersion.c
     10FORCE: ;
     11
     12libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSPHOT_VERSION=\"$(PSPHOT_VERSION)\" -DPSPHOT_BRANCH=\"$(PSPHOT_BRANCH)\" -DPSPHOT_SOURCE=\"$(PSPHOT_SOURCE)\"
    313libpsphot_la_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    414
  • branches/cnb_branches/cnb_branch_20090215/psphot/src/psphot.c

    r20411 r23199  
    99
    1010    psTimerStart ("complete");
    11     pmErrorRegister();                  // register psModule's error codes/messages
     11    pmErrorRegister();                  // register psModule's error codes/messages
    1212    psphotInit();
    1313
     
    1515    pmConfig *config = psphotArguments (argc, argv);
    1616    if (!config) {
    17         psErrorStackPrint(stderr, "Error reading arguments\n");
    18         usage ();
     17        psErrorStackPrint(stderr, "Error reading arguments\n");
     18        usage ();
    1919    }
     20
     21    psphotVersionPrint();
    2022
    2123    // load input data (config and images (signal, noise, mask)
  • branches/cnb_branches/cnb_branch_20090215/psphot/src/psphot.h

    r21536 r23199  
    1616const char     *psphotCVSName(void);
    1717psString        psphotVersion(void);
     18psString        psphotSource(void);
    1819psString        psphotVersionLong(void);
     20bool            psphotVersionHeader(psMetadata *header);
     21bool            psphotVersionHeaderFull(psMetadata *header);
     22void            psphotVersionPrint(void);
    1923
    2024bool            psphotModelTest (pmConfig *config, const pmFPAview *view, psMetadata *recipe);
  • branches/cnb_branches/cnb_branch_20090215/psphot/src/psphotImageLoop.c

    r21458 r23199  
    2626
    2727    pmFPAview *view = pmFPAviewAlloc (0);
     28    pmHDU *lastHDU = NULL;              // Last HDU updated
    2829
    2930    // files associated with the science image
     
    6465                psLogMsg ("psphot", 6, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    6566                if (! readout->data_exists) { continue; }
     67
     68                // Update the header
     69                {
     70                    pmHDU *hdu = pmHDUGetHighest(input->fpa, chip, cell);
     71                    if (hdu && hdu != lastHDU) {
     72                        psphotVersionHeaderFull(hdu->header);
     73                        lastHDU = hdu;
     74                    }
     75                }
    6676
    6777                // run the actual photometry analysis on this chip/cell/readout
  • branches/cnb_branches/cnb_branch_20090215/psphot/src/psphotVersion.c

    r12805 r23199  
    1 # include "psphotInternal.h"
     1#include "psphotInternal.h"
    22
    3 # if (HAVE_KAPA)
    4 # include <kapa.h>
    5 # endif
    6 
    7 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name
     3#ifdef HAVE_KAPA
     4#include <kapa.h>
     5#endif
    86
    97psString psphotVersion(void)
    108{
    11     psString version = NULL;            // Version, to return
    12     psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
    13     return version;
     9#ifndef PSPHOT_VERSION
     10#error "PSPHOT_VERSION is not set"
     11#endif
     12#ifndef PSPHOT_BRANCH
     13#error "PSPHOT_BRANCH is not set"
     14#endif
     15    return psStringCopy(PSPHOT_BRANCH "@" PSPHOT_VERSION);
     16}
     17
     18psString psphotSource(void)
     19{
     20#ifndef PSPHOT_SOURCE
     21#error "PSPHOT_SOURCE is not set"
     22#endif
     23    return psStringCopy(PSPHOT_SOURCE);
    1424}
    1525
    1626psString psphotVersionLong(void)
    1727{
    18     psString version = psphotVersion(); // Version, to return
    19     psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
    20     psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
     28    psString version = psLibVersion();  // Version, to return
     29    psString source = psLibSource();    // Source
    2130
    22 # if (HAVE_KAPA)
    23     psString ohanaVersion = psStringStripCVS (ohana_version(), "Name");
    24     psString libdvoVersion = psStringStripCVS (libdvo_version(), "Name");
     31    psStringPrepend(&version, "psphot ");
     32    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
     33    psFree(source);
    2534
    26     psStringAppend (&version, " with libkapa (ohana %s, libdvo: %s)", ohanaVersion, libdvoVersion);
    27     psFree (ohanaVersion);
    28     psFree (libdvoVersion);
    29 # else
    30     psStringAppend (&version, " WITHOUT libkapa");
    31 # endif
     35#ifdef __OPTIMIZE__
     36    psStringAppend(&version, " optimised");
     37#else
     38    psStringAppend(&version, " unoptimised");
     39#endif
    3240
    33     psFree(tag);
     41#ifdef HAVE_KAPA
     42#if 0
     43    // XXX Need to get ohana and libdvo versions
     44    psString ohanaVersion = psStringStripCVS(ohana_version(), "Name");
     45    psString libdvoVersion = psStringStripCVS(libdvo_version(), "Name");
     46    psStringAppend(&version, " with libkapa (ohana %s, libdvo: %s)", ohanaVersion, libdvoVersion);
     47    psFree(ohanaVersion);
     48    psFree(libdvoVersion);
     49#else
     50    psStringAppend(&version, " with libkapa");
     51#endif
     52
     53#else
     54    psStringAppend (&version, " without libkapa");
     55#endif
     56
    3457    return version;
    3558}
    3659
    37 // Defined by RHL; leaving for backwards compatibility.
    38 const char *psphotCVSName(void) {
    39    return cvsTag;
     60bool psphotVersionHeader(psMetadata *header)
     61{
     62    PS_ASSERT_METADATA_NON_NULL(header, false);
     63
     64    psString version = psphotVersion(); // Software version
     65    psString source = psphotSource();   // Software source
     66
     67    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSPHOT.VERSION", PS_META_REPLACE,
     68                     "Software version", version);
     69    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSPHOT.SOURCE", PS_META_REPLACE,
     70                     "S/W source", source);
     71
     72    psFree(version);
     73    psFree(source);
     74
     75    return true;
    4076}
     77
     78
     79bool psphotVersionHeaderFull(psMetadata *header)
     80{
     81    PS_ASSERT_METADATA_NON_NULL(header, false);
     82
     83    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     84    psString timeString = psTimeToISO(time); // The time in an ISO string
     85    psFree(time);
     86    psString history = NULL;               // History string
     87    psStringAppend(&history, "psphot at %s", timeString);
     88    psFree(timeString);
     89    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     90    psFree(history);
     91
     92    psLibVersionHeader(header);
     93    psModulesVersionHeader(header);
     94    psphotVersionHeader(header);
     95
     96    return true;
     97}
     98
     99
     100void psphotVersionPrint(void)
     101{
     102    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     103    psString timeString = psTimeToISO(time); // The time in an ISO string
     104    psFree(time);
     105    psLogMsg("psphot", PS_LOG_INFO, "psphot at %s", timeString);
     106    psFree(timeString);
     107
     108    psString pslib = psLibVersionLong();// psLib version
     109    psString psmodules = psModulesVersionLong(); // psModules version
     110    psString psphot = psphotVersionLong(); // psphot version
     111
     112    psLogMsg("psphot", PS_LOG_INFO, "%s", pslib);
     113    psLogMsg("psphot", PS_LOG_INFO, "%s", psmodules);
     114    psLogMsg("psphot", PS_LOG_INFO, "%s", psphot);
     115
     116    psFree(pslib);
     117    psFree(psmodules);
     118    psFree(psphot);
     119
     120    return;
     121}
  • branches/cnb_branches/cnb_branch_20090215/pswarp/src/Makefile.am

    r18839 r23199  
    11bin_PROGRAMS = pswarp
    2 pswarp_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PSWARP_CFLAGS)
     2
     3PSWARP_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4PSWARP_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`
     5PSWARP_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     6
     7# Force recompilation of pswarpVersion.c, since it gets the version information
     8pswarpVersion.c: FORCE
     9        touch pswarpVersion.c
     10FORCE: ;
     11
     12pswarp_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PSWARP_CFLAGS) -DPSWARP_VERSION=\"$(PSWARP_VERSION)\" -DPSWARP_BRANCH=\"$(PSWARP_BRANCH)\" -DPSWARP_SOURCE=\"$(PSWARP_SOURCE)\"
    313pswarp_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PSWARP_LIBS)
    414
     
    1828        pswarpSetThreads.c              \
    1929        pswarpTransformReadout.c        \
    20         pswarpTransformSources.c \
     30        pswarpTransformSources.c        \
    2131        pswarpTransformTile.c           \
    2232        pswarpVersion.c           
  • branches/cnb_branches/cnb_branch_20090215/pswarp/src/pswarp.c

    r21442 r23199  
    3939    if (!config) usage();
    4040
     41    pswarpVersionPrint();
     42
    4143    // load identify the data sources
    4244    if (!pswarpParseCamera(config)) {
  • branches/cnb_branches/cnb_branch_20090215/pswarp/src/pswarp.h

    r21368 r23199  
    112112 */
    113113bool pswarpSetThreads ();
     114
     115/// Return software version
     116psString pswarpVersion(void);
     117
     118/// Return software souce
     119psString pswarpSource(void);
     120
     121/// Return long software version information
     122psString pswarpVersionLong(void);
     123
     124/// Populate header with version information
     125bool pswarpVersionHeader(
     126    psMetadata *header                  ///< Header to populate
     127    );
     128
     129/// Print version information
     130void pswarpVersionPrint(void);
  • branches/cnb_branches/cnb_branch_20090215/pswarp/src/pswarpArguments.c

    r21536 r23199  
    210210                                                    "SKYCELL.CAMERA");  ///< Name of camera for skycell
    211211        pmConfigCamerasCull(config, skyCamera);
    212         pmConfigRecipesCull(config, "PSWARP,PPSTATS,PSPHOT,MASKS");
     212        pmConfigRecipesCull(config, "PSWARP,PPSTATS,PSPHOT,MASKS,JPEG");
    213213
    214214        pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PSWARP.INPUT"); // Input file
  • branches/cnb_branches/cnb_branch_20090215/pswarp/src/pswarpLoop.c

    r21468 r23199  
    339339    }
    340340
     341    pswarpVersionHeader(hdu->header);
     342
    341343    if (!pmAstromWriteWCS(hdu->header, outFPA, outChip, WCS_NONLIN_TOL)) {
    342344        psError(PS_ERR_UNKNOWN, false, "Unable to generate WCS header.");
  • branches/cnb_branches/cnb_branch_20090215/pswarp/src/pswarpVersion.c

    r21323 r23199  
    1818#include <pslib.h>
    1919#include <psmodules.h>
     20#include <psphot.h>
     21#include <ppStats.h>
    2022#include "pswarp.h"
    2123
    22 static const char *cvsTag = "$Name: not supported by cvs2svn $";///< CVS tag name
    2324
    2425psString pswarpVersion(void)
    2526{
    26     psString version = NULL;            ///< Version, to return
    27     psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
    28     return version;
     27#ifndef PSWARP_VERSION
     28#error "PSWARP_VERSION is not set"
     29#endif
     30#ifndef PSWARP_BRANCH
     31#error "PSWARP_BRANCH is not set"
     32#endif
     33    return psStringCopy(PSWARP_BRANCH "@" PSWARP_VERSION);
     34}
     35
     36psString pswarpSource(void)
     37{
     38#ifndef PSWARP_SOURCE
     39#error "PSWARP_SOURCE is not set"
     40#endif
     41    return psStringCopy(PSWARP_SOURCE);
    2942}
    3043
    3144psString pswarpVersionLong(void)
    3245{
    33     psString version = pswarpVersion(); ///< Version, to return
    34     psString tag = psStringStripCVS(cvsTag, "Name"); ///< CVS tag
    35     psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
    36     psFree(tag);
     46    psString version = pswarpVersion();  // Version, to return
     47    psString source = pswarpSource();    // Source
     48
     49    psStringPrepend(&version, "pswarp ");
     50    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
     51    psFree(source);
     52
     53#ifdef __OPTIMIZE__
     54    psStringAppend(&version, " optimised");
     55#else
     56    psStringAppend(&version, " unoptimised");
     57#endif
     58
    3759    return version;
     60};
     61
     62
     63bool pswarpVersionHeader(psMetadata *header)
     64{
     65    PS_ASSERT_METADATA_NON_NULL(header, false);
     66
     67    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     68    psString timeString = psTimeToISO(time); // The time in an ISO string
     69    psFree(time);
     70    psString history = NULL;               // History string
     71    psStringAppend(&history, "pswarp at %s", timeString);
     72    psFree(timeString);
     73    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     74    psFree(history);
     75
     76    psLibVersionHeader(header);
     77    psModulesVersionHeader(header);
     78    psphotVersionHeader(header);
     79    ppStatsVersionHeader(header);
     80
     81    psString version = pswarpVersion(); // Software version
     82    psString source  = pswarpSource();  // Software source
     83
     84    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSWARP.VERSION", PS_META_REPLACE,
     85                     "Software version", version);
     86    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSWARP.SOURCE", PS_META_REPLACE,
     87                     "S/W source", source);
     88
     89    psFree(version);
     90    psFree(source);
     91
     92    return true;
    3893}
    3994
     95void pswarpVersionPrint(void)
     96{
     97    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     98    psString timeString = psTimeToISO(time); // The time in an ISO string
     99    psFree(time);
     100    psLogMsg("pswarp", PS_LOG_INFO, "pswarp at %s", timeString);
     101    psFree(timeString);
     102
     103    psString pslib = psLibVersionLong();// psLib version
     104    psString psmodules = psModulesVersionLong(); // psModules version
     105    psString psphot = psphotVersionLong(); // psphot version
     106    psString ppStats = ppStatsVersionLong(); // ppStats version
     107    psString pswarp = pswarpVersionLong(); // pswarp version
     108
     109    psLogMsg("pswarp", PS_LOG_INFO, "%s", pslib);
     110    psLogMsg("pswarp", PS_LOG_INFO, "%s", psmodules);
     111    psLogMsg("pswarp", PS_LOG_INFO, "%s", psphot);
     112    psLogMsg("pswarp", PS_LOG_INFO, "%s", ppStats);
     113    psLogMsg("pswarp", PS_LOG_INFO, "%s", pswarp);
     114
     115    psFree(pslib);
     116    psFree(psmodules);
     117    psFree(psphot);
     118    psFree(ppStats);
     119    psFree(pswarp);
     120
     121    return;
     122}
Note: See TracChangeset for help on using the changeset viewer.