IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23225


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

merging changes from head into my branch

Location:
branches/eam_branches/eam_branch_20090303
Files:
119 edited
10 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/eam_branch_20090303

  • branches/eam_branches/eam_branch_20090303/Nebulous/nebclient/src

    • Property svn:ignore
      •  

        old new  
         1Makefile.in
        12.deps
         3Makefile
         4soapClientLib.c
         5nebulous.h
         6soapClient.c
         7soapStub.h
         8soapC.c
         9soapH.h
         10soapServerLib.c
         11soapServer.c
        212.libs
        3 Makefile
        4 Makefile.in
        5 SOAP.nsmap
        6 libnebclient.la
        7 nebclient.lo
        8 nebulous.h
        9 soapC.c
        10 soapC.lo
        11 soapClient.c
        12 soapClient.lo
        13 soapClientLib.c
        14 soapH.h
        15 soapServer.c
        16 soapServerLib.c
        17 soapStub.h
        18 stdsoap2.lo
        19 xmalloc.lo
  • branches/eam_branches/eam_branch_20090303/Nebulous/nebclient/tests/tap/src

    • Property svn:ignore
      •  

        old new  
        66.deps
        77Makefile
         8.libs
  • branches/eam_branches/eam_branch_20090303/Ohana/src/libdvo

    • Property svn:ignore
      •  

        old new  
        1 lib
         1
  • branches/eam_branches/eam_branch_20090303/Ohana/src/libdvo/lib

    • Property svn:ignore
      •  

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

    • Property svn:ignore
      •  

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

    • Property svn:ignore
      •  

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

    • Property svn:ignore
      •  

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

    • Property svn:ignore
      •  

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

    • Property svn:ignore set to
      *.a
      *.so
  • branches/eam_branches/eam_branch_20090303/PS-IPP-Config/lib/PS/IPP/Config.pm

    r21320 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/calibrate_dvo.pl

    r20100 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/camera_exp.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/chip_imfile.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/detrend_correct_imfile.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/detrend_norm_apply.pl

    r23209 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/detrend_norm_calc.pl

    r23209 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/detrend_norm_exp.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/detrend_process_exp.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/detrend_process_imfile.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/detrend_reject_exp.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/detrend_resid_exp.pl

    r23209 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/detrend_resid_imfile.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/detrend_stack.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/diff_skycell.pl

    r22433 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/fake_imfile.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/ipp_cleanup.pl

    r23176 r23225  
    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;
     44
     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
    4646
    4747# $mode must be one of "goto_cleaned", "goto_scrubbed", or
     
    5050# to be cleaned; they cannot be recovered, but the small data is left
    5151# behind). XXX make 'scrubbed' a data_state?
    52 
    5352unless (($mode eq "goto_cleaned") || ($mode eq "goto_scrubbed") || ($mode eq "goto_purged")) {
    54     die "invalid cleanup mode $mode\n";   
     53    die "invalid cleanup mode $mode\n";
    5554}
    5655
     
    6665}
    6766
    68 $ipprc->define_camera($camera);
    69 
    7067my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    7168
    7269# choice of files to delete depends on the stage
    7370if ($stage eq "chip") {
    74    
     71
    7572    die "--stage_id required for stage chip\n" if !$stage_id;
    7673    ### select the imfiles for this entry
     
    9895    # loop over all of the imfiles, determine the path_base and class_id for each
    9996    foreach my $imfile (@$imfiles) {
    100         my $class_id = $imfile->{class_id};
    101         my $path_base = $imfile->{path_base};
     97        my $class_id = $imfile->{class_id};
     98        my $path_base = $imfile->{path_base};
    10299        my $status = 1;
    103100
    104101        # don't clean up unless the data needed to update is available
    105         # modes goto_purged and goto_scrubbed will remove files even if the config is non-existent
     102        # modes goto_purged and goto_scrubbed will remove files even if the config is non-existent
    106103        if ($mode eq "goto_cleaned") {
    107104            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id);
     
    136133                addFilename (\@files, "PPIMAGE.CONFIG", $path_base, $class_id);
    137134            }
    138        
     135
    139136            # actual command to delete the files
    140137            $status = &delete_files (\@files);
    141138        }
    142139
    143         if ($status)  {
    144             my $command = "$chiptool -chip_id $stage_id -class_id $class_id";
     140        if ($status)  {
     141            my $command = "$chiptool -chip_id $stage_id -class_id $class_id";
    145142            if ($mode eq "goto_purged") {
    146143                $command .= " -topurgedimfile";
    147144            } elsif ($mode eq "goto_scrubbed") {
    148145                $command .= " -tocleanedimfile_from_scrubbed";
    149             } else {
     146            } else {
    150147                $command .= " -tocleanedimfile";
    151148            }
    152             $command .= " -dbname $dbname" if defined $dbname;
    153 
    154             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     149            $command .= " -dbname $dbname" if defined $dbname;
     150
     151            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    155152                    run(command => $command, verbose => $verbose);
    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             }
     153            unless ($success) {
     154                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     155                &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
     156            }
    160157        } else {
    161             # if an error happens for a chip, the chipRun will stay in goto_*, but the chips will go to error_* (matching the goto_*)
     158
     159            # if an error happens for one chip, the chipRun will stay in goto_*, but the chips will go to error_* (matching the goto_*)
    162160            my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -set_state $error_state";
    163161            $command .= " -dbname $dbname" if defined $dbname;
    164162
    165             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     163            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    166164                    run(command => $command, verbose => $verbose);
    167             unless ($success) {
    168                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    169                 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
    170             }
    171         }
     165            unless ($success) {
     166                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     167                &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
     168            }
     169        }
    172170    }
    173171    exit 0;
    174 } 
     172}
    175173
    176174if ($stage eq "camera") {
     
    258256    }
    259257    exit 0;
    260 } 
     258}
    261259
    262260if ($stage eq "warp") {
     
    319317        }
    320318
    321         if ($status)  {
    322             my $command = "$warptool -warp_id $stage_id -skycell_id $skycell_id";
     319        if ($status)  {
     320            my $command = "$warptool -warp_id $stage_id -skycell_id $skycell_id";
    323321            if ($mode eq "goto_purged") {
    324322                $command .= " -topurgedskyfile";
     
    326324                $command .= " -tocleanedskyfile";
    327325            }
    328             $command .= " -dbname $dbname" if defined $dbname;
    329 
    330             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     326            $command .= " -dbname $dbname" if defined $dbname;
     327
     328            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    331329                    run(command => $command, verbose => $verbose);
    332             unless ($success) {
    333                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    334                 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
    335             }
     330            unless ($success) {
     331                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     332                &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
     333            }
    336334         } else {
    337335            my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -set_state $error_state";
     
    340338            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    341339                run(command => $command, verbose => $verbose);
    342             unless ($success) {
    343                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    344                 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
    345             }
     340            unless ($success) {
     341                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     342                &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
     343            }
    346344            exit $PS_EXIT_UNKNOWN_ERROR;
    347         }
     345        }
    348346    }
    349347    exit 0;
     
    357355die "ipp_cleanup.pl -stage $stage not yet implemented\n";
    358356
    359 sub delete_files 
     357sub delete_files
    360358{
    361359    my $files = shift; # reference to a list of files to unlink
    362    
    363     # this script is, of course, very dangerous. 
     360
     361    # this script is, of course, very dangerous.
    364362    foreach my $file (@$files) {
    365         print STDERR "unlinking $file\n";
     363        print STDERR "unlinking $file\n";
    366364        $ipprc->file_delete($file);
    367365    }
     
    369367}
    370368
    371 sub addFilename 
     369sub addFilename
    372370{
    373371    my $files      = shift; # reference to a list of files to unlink
  • branches/eam_branches/eam_branch_20090303/ippScripts/scripts/ipp_maskscript.pl

    r17671 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/magic_definerun.pl

    r21006 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/magic_destreak.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/magic_mask.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/magic_process.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/magic_tree.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/register_exp.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/register_imfile.pl

    r22428 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/stack_skycell.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/warp_overlap.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippScripts/scripts/warp_skycell.pl

    r22430 r23225  
    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/eam_branches/eam_branch_20090303/ippconfig/gpc1/format_20080925.config

    r21023 r23225  
    189189        FPA.RA          STR     RA
    190190        FPA.DEC         STR     DEC
    191         FPA.RADECSYS    STR     RADECSYS
     191        FPA.RADECSYS    STR     EQUINOX
    192192        FPA.OBSTYPE     STR     OBSTYPE
    193193        FPA.OBJECT      STR     OBJECT
  • branches/eam_branches/eam_branch_20090303/ippconfig/gpc1/format_20080929.config

    r21023 r23225  
    184184        FPA.RA          STR     RA
    185185        FPA.DEC         STR     DEC
    186         FPA.RADECSYS    STR     RADECSYS
     186        FPA.RADECSYS    STR     EQUINOX
    187187        FPA.OBSTYPE     STR     OBSTYPE
    188188        FPA.OBJECT      STR     OBJECT
  • branches/eam_branches/eam_branch_20090303/ippconfig/gpc1/format_20081011.config

    r20951 r23225  
    174174        FPA.RA          STR     RA
    175175        FPA.DEC         STR     DEC
    176         FPA.RADECSYS    STR     RADECSYS
     176        FPA.RADECSYS    STR     EQUINOX
    177177        FPA.OBSTYPE     STR     OBSTYPE
    178178        FPA.OBJECT      STR     OBJECT
  • branches/eam_branches/eam_branch_20090303/ippconfig/gpc1/format_20090120.config

    r21539 r23225  
    173173        FPA.RA          STR     RA
    174174        FPA.DEC         STR     DEC
    175         FPA.RADECSYS    STR     RADECSYS
     175        FPA.RADECSYS    STR     EQUINOX
    176176        FPA.OBSTYPE     STR     OBSTYPE
    177177        FPA.OBJECT      STR     OBJECT
  • branches/eam_branches/eam_branch_20090303/ippconfig/gpc1/format_20090220.config

    r22212 r23225  
    173173        FPA.RA          STR     RA
    174174        FPA.DEC         STR     DEC
    175         FPA.RADECSYS    STR     RADECSYS
     175        FPA.RADECSYS    STR     EQUINOX
    176176        FPA.OBSTYPE     STR     OBSTYPE
    177177        FPA.OBJECT      STR     OBJECT
  • branches/eam_branches/eam_branch_20090303/ippconfig/gpc1/format_mef.config

    r22685 r23225  
    168168        FPA.RA          STR     RA
    169169        FPA.DEC         STR     DEC
    170         FPA.RADECSYS    STR     RADECSYS
     170        FPA.RADECSYS    STR     EQUINOX
    171171        FPA.OBSTYPE     STR     OBSTYPE
    172172        FPA.OBJECT      STR     OBJECT
  • branches/eam_branches/eam_branch_20090303/ippconfig/gpc1/format_orig.config

    r21023 r23225  
    182182        # FPA.RA          STR     COMRA
    183183        # FPA.DEC         STR     COMDEC
    184         FPA.RADECSYS    STR     RADECSYS
     184        FPA.RADECSYS    STR     EQUINOX
    185185        FPA.OBSTYPE     STR     OBSTYPE
    186186        FPA.OBJECT      STR     OBJECT
  • branches/eam_branches/eam_branch_20090303/ippconfig/gpc1/format_relphot.config

    r21023 r23225  
    105105        FPA.RA          STR     RA
    106106        FPA.DEC         STR     DEC
    107         FPA.RADECSYS    STR     RADECSYS
     107        FPA.RADECSYS    STR     EQUINOX
    108108        FPA.OBSTYPE     STR     OBSTYPE
    109109        FPA.OBJECT      STR     OBJECT
  • branches/eam_branches/eam_branch_20090303/ippconfig/recipes/filerules-mef.mdc

    r21370 r23225  
    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/eam_branches/eam_branch_20090303/ippconfig/recipes/filerules-simple.mdc

    r21370 r23225  
    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/eam_branches/eam_branch_20090303/ippconfig/recipes/filerules-split.mdc

    r21531 r23225  
    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/eam_branches/eam_branch_20090303/ippconfig/recipes/fitstypes.mdc

    r21534 r23225  
    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/eam_branches/eam_branch_20090303/ippconfig/recipes/ppStack.config

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

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

    r21244 r23225  
    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/eam_branches/eam_branch_20090303/ppArith/src/ppArithLoop.c

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

    r23202 r23225  
    6565};
    6666
    67 void ppArithVersionMetadata(psMetadata *metadata)
     67bool ppArithVersionHeader(psMetadata *header)
    6868{
    69     PS_ASSERT_METADATA_NON_NULL(metadata,);
     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, "ppArith 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
     84    psString version = ppArithVersion(); // Software version
     85    psString source  = ppArithSource();  // Software source
     86
     87    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPARITH.VERSION", PS_META_REPLACE,
     88                     "Software version", version);
     89    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPARITH.SOURCE", PS_META_REPLACE,
     90                     "S/W source", source);
     91
     92    psFree(version);
     93    psFree(source);
     94
     95    return true;
     96}
     97
     98void ppArithVersionPrint(void)
     99{
     100    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     101    psString timeString = psTimeToISO(time); // The time in an ISO string
     102    psFree(time);
     103    psLogMsg("ppArith", PS_LOG_INFO, "ppArith at %s", timeString);
     104    psFree(timeString);
    70105
    71106    psString pslib = psLibVersionLong();// psLib version
     
    74109    psString ppArith = ppArithVersionLong(); // ppArith version
    75110
    76     psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
    77     psString timeString = psTimeToISO(time); // The time in an ISO string
    78     psFree(time);
    79     psString head = NULL;               // Head string
    80     psStringAppend(&head, "ppArith processing at %s. Component information:", timeString);
    81     psFree(timeString);
     111    psLogMsg("ppArith", PS_LOG_INFO, "%s", pslib);
     112    psLogMsg("ppArith", PS_LOG_INFO, "%s", psmodules);
     113    psLogMsg("ppArith", PS_LOG_INFO, "%s", ppStats);
     114    psLogMsg("ppArith", PS_LOG_INFO, "%s", ppArith);
    82115
    83     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");
    84     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");
    85     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");
    86     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, "");
    87     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppArith, "");
    88 
    89     psFree(head);
    90116    psFree(pslib);
    91117    psFree(psmodules);
  • branches/eam_branches/eam_branch_20090303/ppImage/src/ppImage.c

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

    r23205 r23225  
    216216psString ppImageVersionLong(void);
    217217
    218 /// Update the metadata with version information for all dependencies
    219 void ppImageVersionMetadata(psMetadata *metadata ///< Metadata to update with version information
    220     );
     218/// Populate the header with version information for all dependencies
     219bool ppImageVersionHeader(psMetadata *metadata ///< Header to populate
     220    );
     221
     222/// Print version information
     223void ppImageVersionPrint(void);
    221224
    222225
  • branches/eam_branches/eam_branch_20090303/ppImage/src/ppImageLoop.c

    r22734 r23225  
    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            }
  • branches/eam_branches/eam_branch_20090303/ppImage/src/ppImageVersion.c

    r23204 r23225  
    4848};
    4949
    50 void ppImageVersionMetadata(psMetadata *metadata)
     50bool ppImageVersionHeader(psMetadata *header)
    5151{
    52     PS_ASSERT_METADATA_NON_NULL(metadata,);
     52    PS_ASSERT_METADATA_NON_NULL(header, false);
     53
     54    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     55    psString timeString = psTimeToISO(time); // The time in an ISO string
     56    psFree(time);
     57    psString history = NULL;               // History string
     58    psStringAppend(&history, "ppImage at %s", timeString);
     59    psFree(timeString);
     60    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     61    psFree(history);
     62
     63    psLibVersionHeader(header);
     64    psModulesVersionHeader(header);
     65    psphotVersionHeader(header);
     66    psastroVersionHeader(header);
     67    ppStatsVersionHeader(header);
     68
     69    psString version = ppImageVersion(); // ppImage software version
     70    psString source  = ppImageSource();  // ppImage software source
     71
     72    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPIMAGE.VERSION", PS_META_REPLACE,
     73                     "Software version", version);
     74    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPIMAGE.SOURCE", PS_META_REPLACE,
     75                     "S/W source", source);
     76
     77    psFree(version);
     78    psFree(source);
     79
     80    return true;
     81}
     82
     83
     84void ppImageVersionPrint(void)
     85{
     86    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     87    psString timeString = psTimeToISO(time); // The time in an ISO string
     88    psFree(time);
     89    psLogMsg("ppImage", PS_LOG_INFO, "ppImage at %s", timeString);
     90    psFree(timeString);
    5391
    5492    psString pslib = psLibVersionLong();// psLib version
     
    5997    psString ppImage = ppImageVersionLong(); // ppImage version
    6098
    61     psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
    62     psString timeString = psTimeToISO(time); // The time in an ISO string
    63     psFree(time);
    64     psString head = NULL;               // Head string
    65     psStringAppend(&head, "ppImage processing at %s. Component information:", timeString);
    66     psFree(timeString);
     99    psLogMsg("ppImage", PS_LOG_INFO, "%s", pslib);
     100    psLogMsg("ppImage", PS_LOG_INFO, "%s", psmodules);
     101    psLogMsg("ppImage", PS_LOG_INFO, "%s", psphot);
     102    psLogMsg("ppImage", PS_LOG_INFO, "%s", psastro);
     103    psLogMsg("ppImage", PS_LOG_INFO, "%s", ppStats);
     104    psLogMsg("ppImage", PS_LOG_INFO, "%s", ppImage);
    67105
    68     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");
    69     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");
    70     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");
    71     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psphot, "");
    72     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psastro, "");
    73     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, "");
    74     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppImage, "");
    75 
    76     psFree(head);
    77106    psFree(pslib);
    78107    psFree(psmodules);
  • branches/eam_branches/eam_branch_20090303/ppMerge/src/ppMerge.c

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

    r21244 r23225  
    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/eam_branches/eam_branch_20090303/ppMerge/src/ppMergeLoop_Threaded.c

    r21365 r23225  
    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/eam_branches/eam_branch_20090303/ppMerge/src/ppMergeMask.c

    r21365 r23225  
    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/eam_branches/eam_branch_20090303/ppMerge/src/ppMergeVersion.c

    r23202 r23225  
    6565};
    6666
    67 void ppMergeVersionMetadata(psMetadata *metadata)
     67bool ppMergeVersionHeader(psMetadata *header)
    6868{
    69     PS_ASSERT_METADATA_NON_NULL(metadata,);
     69    PS_ASSERT_METADATA_NON_NULL(header, false);
    7070
    71     psString pslib = psLibVersionLong();///< psLib version
    72     psString psmodules = psModulesVersionLong(); ///< psModules version
    73     psString ppStats = ppStatsVersionLong(); ///< ppStats version
    74     psString ppMerge = ppMergeVersionLong(); ///< ppMerge version
     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, "ppMerge at %s", timeString);
     76    psFree(timeString);
     77    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     78    psFree(history);
    7579
    76     psTime *time = psTimeGetNow(PS_TIME_TAI); ///< The time now
    77     psString timeString = psTimeToISO(time); ///< The time in an ISO string
     80    psLibVersionHeader(header);
     81    psModulesVersionHeader(header);
     82    ppStatsVersionHeader(header);
     83
     84    psString version = ppMergeVersion(); // Software version
     85    psString source  = ppMergeSource();  // Software source
     86
     87    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPMERGE.VERSION", PS_META_REPLACE,
     88                     "Software version", version);
     89    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPMERGE.SOURCE", PS_META_REPLACE,
     90                     "S/W source", source);
     91
     92    psFree(version);
     93    psFree(source);
     94
     95    return true;
     96}
     97
     98void ppMergeVersionPrint(void)
     99{
     100    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     101    psString timeString = psTimeToISO(time); // The time in an ISO string
    78102    psFree(time);
    79     psString head = NULL;               ///< Head string
    80     psStringAppend(&head, "ppMerge processing at %s. Component information:", timeString);
     103    psLogMsg("ppMerge", PS_LOG_INFO, "ppMerge at %s", timeString);
    81104    psFree(timeString);
    82105
    83     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");
    84     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");
    85     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");
    86     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, "");
    87     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppMerge, "");
     106    psString pslib = psLibVersionLong();// psLib version
     107    psString psmodules = psModulesVersionLong(); // psModules version
     108    psString ppStats = ppStatsVersionLong(); // ppStats version
     109    psString ppMerge = ppMergeVersionLong(); // ppMerge version
    88110
    89     psFree(head);
     111    psLogMsg("ppImage", PS_LOG_INFO, "%s", pslib);
     112    psLogMsg("ppImage", PS_LOG_INFO, "%s", psmodules);
     113    psLogMsg("ppImage", PS_LOG_INFO, "%s", ppStats);
     114    psLogMsg("ppImage", PS_LOG_INFO, "%s", ppMerge);
     115
    90116    psFree(pslib);
    91117    psFree(psmodules);
  • branches/eam_branches/eam_branch_20090303/ppStack/src/ppStack.c

    r21258 r23225  
    3333        goto die;
    3434    }
     35
     36    ppStackVersionPrint();
    3537
    3638    if (!pmModelClassInit()) {
  • branches/eam_branches/eam_branch_20090303/ppStack/src/ppStack.h

    r23143 r23225  
    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
     
    140142psString ppStackVersionLong(void);
    141143
    142 // Supplement metadata with software version
    143 void ppStackVersionMetadata(psMetadata *metadata // Metadata to supplement
     144// Supplement header with software version
     145bool ppStackVersionHeader(psMetadata *header // Header to supplement
    144146    );
     147
     148/// Print version information
     149void ppStackVersionPrint(void);
    145150
    146151/// Convolve image to match specified seeing
     
    161166/// Corrects the source PSF photometry to a common system.  Return the sum of the exposure times.
    162167float ppStackSourcesTransparency(const psArray *sourceLists, // Sources for each input
     168                                 psVector *inputMask, // Indicates bad input
    163169                                 const pmFPAview *view, // View to readout
    164170                                 const pmConfig *config // Configuration
  • branches/eam_branches/eam_branch_20090303/ppStack/src/ppStackArguments.c

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

    r22730 r23225  
    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);
     
    12131223        hdu->header = psMetadataAlloc();
    12141224    }
    1215     ppStackVersionMetadata(hdu->header);
     1225    ppStackVersionHeader(hdu->header);
    12161226
    12171227    psFree(outRO);
  • branches/eam_branches/eam_branch_20090303/ppStack/src/ppStackPSF.c

    r18918 r23225  
    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/eam_branches/eam_branch_20090303/ppStack/src/ppStackSources.c

    r21260 r23225  
    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
     
    3781
    3882    float radius = psMetadataLookupF32(NULL, recipe, "ZP.RADIUS"); // Radius (pixels) for matching sources
    39     int iter = psMetadataLookupS32(NULL, recipe, "ZP.ITER"); // Maximum iterations
     83    int iter1 = psMetadataLookupS32(NULL, recipe, "ZP.ITER.1"); // Maximum iterations for pass 1
     84    int iter2 = psMetadataLookupS32(NULL, recipe, "ZP.ITER.2"); // Maximum iterations for pass 2
    4085    float tol = psMetadataLookupF32(NULL, recipe, "ZP.TOL"); // Tolerance for zero point iterations
    4186    int transIter = psMetadataLookupS32(NULL, recipe, "ZP.TRANS.ITER"); // Iterations for transparency
    4287    float transRej = psMetadataLookupF32(NULL, recipe, "ZP.TRANS.REJ");// Rejection threshold for transparency
    4388    float transThresh = psMetadataLookupF32(NULL, recipe, "ZP.TRANS.THRESH"); // Threshold for transparency
    44     float starRej = psMetadataLookupF32(NULL, recipe, "ZP.STAR.REJ"); // Rejection threshold for stars
     89
     90    float starRej1 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.REJ.1"); // Rejection threshold for stars
     91    float starSys1 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.SYS.1"); // Estimated systematic error
     92    float starRej2 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.REJ.2"); // Rejection threshold for stars
     93    float starSys2 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.SYS.2"); // Estimated systematic error
     94
    4595    float starLimit = psMetadataLookupF32(NULL, recipe, "ZP.STAR.LIMIT"); // Limit on star rejection fraction
    46     float starSys = psMetadataLookupF32(NULL, recipe, "ZP.STAR.SYS"); // Estimated systematic error
     96
     97    float fracMatch = psMetadataLookupF32(NULL, recipe, "ZP.MATCH"); // Fraction of images to match for star
    4798
    4899    psMetadata *airmassZP = psMetadataLookupMetadata(NULL, recipe, "ZP.AIRMASS"); // Airmass terms
     
    63114        pmCell *cell = pmFPAviewThisCell(view, file->fpa); // Cell of interest
    64115
    65 #ifdef TESTING
     116#if defined(TESTING) && 0
    66117        pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout
    67118        pmPSF *psf = psMetadataLookupPtr(NULL, config->arguments, "PSF.TARGET"); // PSF for fake image
    68         pmReadoutFakeFromSources(fake, FAKE_COLS, FAKE_ROWS, sourceLists->data[i], NULL, NULL, psf, 5, 0, false, true);
     119        pmReadoutFakeFromSources(fake, FAKE_COLS, FAKE_ROWS, sourceLists->data[i],
     120                                 NULL, NULL, psf, 5, 0, false, true);
    69121        psString name = NULL;
    70122        psStringAppend(&name, "start_%03d.fits", i);
     
    114166        return NAN;
    115167    }
    116     psVector *trans = pmSourceMatchRelphot(matches, zp, iter, tol, starLimit, transIter, transRej,
    117                                            transThresh, starRej, starSys); // Transparencies for each image
    118 
    119 #ifdef TESTING
    120     {
    121         // Dump the corrected magnitudes
    122         FILE *outMatches = fopen("source_match.dat", "w"); // Output matches
    123         psVector *mag = psVectorAlloc(num, PS_TYPE_F32); // Magnitudes for each star
    124         psVector *magErr = psVectorAlloc(num, PS_TYPE_F32); // Errors for each star
    125         for (int i = 0; i < matches->n; i++) {
    126             pmSourceMatch *match = matches->data[i]; // Match of interest
    127             psVectorInit(mag, NAN);
    128             psVectorInit(magErr, NAN);
    129             for (int j = 0; j < match->num; j++) {
    130                 if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
    131                     continue;
    132                 }
    133                 int index = match->image->data.U32[j]; // Image index
    134                 mag->data.F32[index] = match->mag->data.F32[j] - zp->data.F32[index] - trans->data.F32[index];
    135                 magErr->data.F32[index] = match->magErr->data.F32[j];
    136             }
    137             for (int j = 0; j < num; j++) {
    138                 fprintf(outMatches, "%f (%f) ", mag->data.F32[j], magErr->data.F32[j]);
    139             }
    140             fprintf(outMatches, "\n");
    141         }
    142         psFree(mag);
    143         psFree(magErr);
    144         fclose(outMatches);
    145     }
    146 #endif
     168
     169#ifdef TESTING
     170    dumpMatches("source_match.dat", num, matches, zp, NULL);
     171#endif
     172
     173    psVector *trans = pmSourceMatchRelphot(matches, zp, tol, iter1, starRej1, starSys1,
     174                                           iter2, starRej2, starSys2, starLimit,
     175                                           transIter, transRej, transThresh); // Transparencies for each image
     176    if (!trans) {
     177        psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies");
     178        return NAN;
     179    }
     180
     181#ifdef TESTING
     182    dumpMatches("source_mags.dat", num, matches, zp, trans);
     183#endif
     184
     185    for (int i = 0; i < trans->n; i++) {
     186        if (!isfinite(trans->data.F32[i])) {
     187            inputMask->data.U8[i] = PPSTACK_MASK_CAL;
     188        }
     189    }
    147190
    148191    // Save best matches SOMEWHERE for future photometry
    149192    // XXX this is a really poor output location; clean up the pmFPAfiles used in ppStack
    150193    pmCell *sourcesCell = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT");
    151     psArray *sourcesBest = psArrayAllocEmpty (100);
    152 
    153     // XXX something of a hack: require at 2 detections or 1/2 of the max possible
    154     int minMatches = PS_MAX (2, 0.5*num);
     194    psArray *sourcesBest = psArrayAllocEmpty(matches->n);
     195
     196    // XXX something of a hack: require at least 2 detections or the nominated fraction of the max possible
     197    int minMatches = PS_MAX(2, fracMatch * num);// Minimum number of matches required
    155198    for (int i = 0; i < matches->n; i++) {
    156         pmSourceMatch *match = matches->data[i]; // Match of interest
    157         if (match->num < minMatches) continue;
    158 
    159         // We need to grab a single instance of this source: just take the first available
    160         int nImage = match->image->data.S32[0];
    161         int nIndex = match->index->data.S32[0];
    162         psArray *sources = sourceLists->data[nImage];
    163         pmSource *source = sources->data[nIndex];
    164        
    165         // stick this sample source on sourcesBest
    166         psArrayAdd (sourcesBest, 100, source);
    167     }
    168     psMetadataAdd (sourcesCell->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE, "psphot sources", sourcesBest);
    169     psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis\n", sourcesBest->n);
    170     psFree (sourcesBest);
     199        pmSourceMatch *match = matches->data[i]; // Match of interest
     200        if (match->num < minMatches) {
     201            continue;
     202        }
     203
     204        // We need to grab a single instance of this source: just take the first available
     205        int image = match->image->data.S32[0]; // Index of image
     206        int index = match->index->data.S32[0]; // Index of source within image
     207        psArray *sources = sourceLists->data[image]; // Sources for image
     208        pmSource *source = sources->data[index]; // Source of interest
     209
     210        psArrayAdd(sourcesBest, sourcesBest->n, source);
     211    }
     212    psMetadataAdd(sourcesCell->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE,
     213                  "psphot sources", sourcesBest);
     214    psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis", sourcesBest->n);
     215    psFree(sourcesBest);
    171216
    172217    psFree(matches);
    173     if (!trans) {
    174         psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies");
    175         return NAN;
    176     }
    177218
    178219    // M = m + c0 + c1 * airmass - 2.5log(t) + transparency
     
    182223    // We don't need to know the magnitude zero point for the filter, since it cancels out
    183224    for (int i = 0; i < num; i++) {
     225        if (!isfinite(trans->data.F32[i])) {
     226            continue;
     227        }
    184228        psArray *sources = sourceLists->data[i]; // Sources of interest
    185229        float magCorr = airmassTerm - 2.5*log10(sumExpTime) - zp->data.F32[i] - trans->data.F32[i];
  • branches/eam_branches/eam_branch_20090303/ppStack/src/ppStackThread.c

    r21477 r23225  
    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/eam_branches/eam_branch_20090303/ppStack/src/ppStackVersion.c

    r23202 r23225  
    77#include <psmodules.h>
    88#include <ppStats.h>
     9#include <psphot.h>
    910
    1011#include "ppStack.h"
     
    5455
    5556
    56 void ppStackVersionMetadata(psMetadata *metadata)
     57bool ppStackVersionHeader(psMetadata *header)
    5758{
    58     PS_ASSERT_METADATA_NON_NULL(metadata,);
    59 
    60     psString pslib = psLibVersionLong();// psLib version
    61     psString psmodules = psModulesVersionLong(); // psModules version
    62     psString ppStats = ppStatsVersionLong(); // ppStats version
    63     psString ppStack = ppStackVersionLong(); // ppStack version
     59    PS_ASSERT_METADATA_NON_NULL(header, false);
    6460
    6561    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
    6662    psString timeString = psTimeToISO(time); // The time in an ISO string
    6763    psFree(time);
    68     psString head = NULL;               // Head string
    69     psStringAppend(&head, "ppStack processing at %s. Component information:", timeString);
     64    psString history = NULL;               // History string
     65    psStringAppend(&history, "ppStack at %s", timeString);
     66    psFree(timeString);
     67    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     68    psFree(history);
     69
     70    psLibVersionHeader(header);
     71    psModulesVersionHeader(header);
     72    psphotVersionHeader(header);
     73    ppStatsVersionHeader(header);
     74
     75    psString version = ppStackVersion(); // Software version
     76    psString source  = ppStackSource();  // Software source
     77
     78    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPSTACK.VERSION", PS_META_REPLACE,
     79                     "Software version", version);
     80    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPSTACK.SOURCE", PS_META_REPLACE,
     81                     "S/W source", source);
     82
     83    psFree(version);
     84    psFree(source);
     85
     86    return true;
     87}
     88
     89void ppStackVersionPrint(void)
     90{
     91    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     92    psString timeString = psTimeToISO(time); // The time in an ISO string
     93    psFree(time);
     94    psLogMsg("ppStack", PS_LOG_INFO, "ppStack at %s", timeString);
    7095    psFree(timeString);
    7196
    72     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", head);
    73     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", pslib);
    74     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", psmodules);
    75     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", ppStats);
    76     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", ppStack);
     97    psString pslib = psLibVersionLong();// psLib version
     98    psString psmodules = psModulesVersionLong(); // psModules version
     99    psString psphot = psphotVersionLong(); // psphot version
     100    psString ppStats = ppStatsVersionLong(); // psastro version
     101    psString ppStack = ppStackVersionLong(); // ppStack version
    77102
    78     psFree(head);
     103    psLogMsg("ppStack", PS_LOG_INFO, "%s", pslib);
     104    psLogMsg("ppStack", PS_LOG_INFO, "%s", psmodules);
     105    psLogMsg("ppStack", PS_LOG_INFO, "%s", psphot);
     106    psLogMsg("ppStack", PS_LOG_INFO, "%s", ppStats);
     107    psLogMsg("ppStack", PS_LOG_INFO, "%s", ppStack);
     108
    79109    psFree(pslib);
    80110    psFree(psmodules);
     111    psFree(psphot);
    81112    psFree(ppStats);
    82113    psFree(ppStack);
  • branches/eam_branches/eam_branch_20090303/ppStats/src/ppStats.h

    r23119 r23225  
    114114psString ppStatsVersionLong(void);
    115115
     116/// Populate header with version information
     117bool ppStatsVersionHeader(
     118    psMetadata *header                  ///< Header to populate
     119    );
     120
     121
    116122void p_ppStatsGetMetadata(psMetadata *target, // Target for metadata
    117123                          psMetadata *source, // Source for metadata
  • branches/eam_branches/eam_branch_20090303/ppStats/src/ppStatsFromMetadataPrint.c

    r20305 r23225  
    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/eam_branches/eam_branch_20090303/ppStats/src/ppStatsVersion.c

    r23202 r23225  
    4343    return version;
    4444};
     45
     46bool ppStatsVersionHeader(psMetadata *header)
     47{
     48    PS_ASSERT_METADATA_NON_NULL(header, false);
     49
     50    psString version = ppStatsVersion(); // Software version
     51    psString source = ppStatsSource();   // Software source
     52
     53    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPSTATS.VERSION", PS_META_REPLACE,
     54                     "Software version", version);
     55    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPSTATS.SOURCE", PS_META_REPLACE,
     56                     "S/W source", source);
     57
     58    psFree(version);
     59    psFree(source);
     60
     61    return true;
     62}
  • branches/eam_branches/eam_branch_20090303/ppSub/src/ppSub.c

    r21524 r23225  
    3434        goto die;
    3535    }
     36
     37    ppSubVersionPrint();
    3638
    3739    if (!pmModelClassInit()) {
  • branches/eam_branches/eam_branch_20090303/ppSub/src/ppSub.h

    r21524 r23225  
    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/eam_branches/eam_branch_20090303/ppSub/src/ppSubLoop.c

    r21524 r23225  
    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/eam_branches/eam_branch_20090303/ppSub/src/ppSubMatchPSFs.c

    r21524 r23225  
    129129
    130130    // XXX drop the pixels associated with inRO and refRO (now that we have inConv and refConf)
    131 
     131#ifdef TESTING
    132132    psphotSaveImage (NULL, inRO->image, "inRO.fits");
    133133    psphotSaveImage (NULL, refRO->image, "refRO.fits");
    134134    psphotSaveImage (NULL, inConv->image, "inConv.fits");
    135135    psphotSaveImage (NULL, refConv->image, "refConv.fits");
     136#endif
    136137
    137138    return true;
  • branches/eam_branches/eam_branch_20090303/ppSub/src/ppSubReadoutUpdate.c

    r21524 r23225  
    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/eam_branches/eam_branch_20090303/ppSub/src/ppSubVersion.c

    r23202 r23225  
    1919#include <psmodules.h>
    2020#include <ppStats.h>
     21#include <psphot.h>
    2122
    2223#include "ppSub.h"
     
    6667
    6768
    68 void ppSubVersionMetadata(psMetadata *metadata)
     69bool ppSubVersionHeader(psMetadata *header)
    6970{
    70     PS_ASSERT_METADATA_NON_NULL(metadata,);
    71 
    72     psString pslib = psLibVersionLong();// psLib version
    73     psString psmodules = psModulesVersionLong(); // psModules version
    74     psString ppStats = ppStatsVersionLong(); // ppStats version
    75     psString ppSub = ppSubVersionLong(); // ppSub version
     71    PS_ASSERT_METADATA_NON_NULL(header, false);
    7672
    7773    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
    7874    psString timeString = psTimeToISO(time); // The time in an ISO string
    7975    psFree(time);
    80     psString head = NULL;               // Head string
    81     psStringAppend(&head, "ppSub processing at %s. Component information:", timeString);
     76    psString history = NULL;               // History string
     77    psStringAppend(&history, "ppSub at %s", timeString);
     78    psFree(timeString);
     79    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     80    psFree(history);
     81
     82    psLibVersionHeader(header);
     83    psModulesVersionHeader(header);
     84    psphotVersionHeader(header);
     85    ppStatsVersionHeader(header);
     86
     87    psString version = ppSubVersion(); // Software version
     88    psString source  = ppSubSource();  // Software source
     89
     90    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPSUB.VERSION", PS_META_REPLACE,
     91                     "Software version", version);
     92    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPSUB.SOURCE", PS_META_REPLACE,
     93                     "S/W source", source);
     94
     95    psFree(version);
     96    psFree(source);
     97
     98    return true;
     99}
     100
     101void ppSubVersionPrint(void)
     102{
     103    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     104    psString timeString = psTimeToISO(time); // The time in an ISO string
     105    psFree(time);
     106    psLogMsg("ppSub", PS_LOG_INFO, "ppSub at %s", timeString);
    82107    psFree(timeString);
    83108
    84     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");
    85     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");
    86     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");
    87     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, "");
    88     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppSub, "");
     109    psString pslib = psLibVersionLong();// psLib version
     110    psString psmodules = psModulesVersionLong(); // psModules version
     111    psString psphot = psphotVersionLong(); // psphot version
     112    psString ppStats = ppStatsVersionLong(); // ppStats version
     113    psString ppSub = ppSubVersionLong(); // ppSub version
    89114
    90     psFree(head);
     115    psLogMsg("ppSub", PS_LOG_INFO, "%s", pslib);
     116    psLogMsg("ppSub", PS_LOG_INFO, "%s", psmodules);
     117    psLogMsg("ppSub", PS_LOG_INFO, "%s", psphot);
     118    psLogMsg("ppSub", PS_LOG_INFO, "%s", ppStats);
     119    psLogMsg("ppSub", PS_LOG_INFO, "%s", ppSub);
     120
    91121    psFree(pslib);
    92122    psFree(psmodules);
     123    psFree(psphot);
    93124    psFree(ppStats);
    94125    psFree(ppSub);
  • branches/eam_branches/eam_branch_20090303/psLib/configure.ac

    r21400 r23225  
    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/eam_branches/eam_branch_20090303/psLib/src/sys/psLogMsg.c

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

    r23148 r23225  
    1919
    2020    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSLIB.VERSION", PS_META_REPLACE,
    21                      "psLib software version", version);
     21                     "Software version", version);
    2222    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSLIB.SOURCE", PS_META_REPLACE,
    23                      "psLib software source", source);
     23                     "S/W source", source);
    2424
    2525    psFree(version);
  • branches/eam_branches/eam_branch_20090303/psModules/src/config/pmConfig.c

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

    r23202 r23225  
    4949#endif
    5050
     51#ifdef HAVE_NEBCLIENT
     52    psStringAppend(&version, " with nebclient");
     53#else
     54    psStringAppend(&version, " without nebclient");
     55#endif
     56
    5157    return version;
    5258};
     
    6167
    6268    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSMODULES.VERSION", PS_META_REPLACE,
    63                      "psModules software version", version);
     69                     "Software version", version);
    6470    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSMODULES.SOURCE", PS_META_REPLACE,
    65                      "psModules software source", source);
     71                     "S/W source", source);
    6672
    6773    psFree(version);
  • branches/eam_branches/eam_branch_20090303/psModules/src/imcombine/pmPSFEnvelope.c

    r21363 r23225  
    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/eam_branches/eam_branch_20090303/psModules/src/objects/Makefile.am

    r21516 r23225  
    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/eam_branches/eam_branch_20090303/psModules/src/objects/pmFootprint.c

    r20937 r23225  
    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/eam_branches/eam_branch_20090303/psModules/src/objects/pmModel.c

    r21515 r23225  
    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/eam_branches/eam_branch_20090303/psModules/src/objects/pmMoments.c

    r19879 r23225  
    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/eam_branches/eam_branch_20090303/psModules/src/objects/pmPeaks.c

    r21514 r23225  
    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/eam_branches/eam_branch_20090303/psModules/src/objects/pmSource.c

    r21513 r23225  
    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/eam_branches/eam_branch_20090303/psModules/src/objects/pmSource.h

    r21516 r23225  
    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/eam_branches/eam_branch_20090303/psModules/src/objects/pmSourceContour.c

    r20937 r23225  
    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/eam_branches/eam_branch_20090303/psModules/src/objects/pmSourceFitModel.c

    r21512 r23225  
    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/eam_branches/eam_branch_20090303/psModules/src/objects/pmSourceFitSet.c

    r21363 r23225  
    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/eam_branches/eam_branch_20090303/psModules/src/objects/pmSourceIO_CMF_PS1_V1.c

    r21528 r23225  
    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/eam_branches/eam_branch_20090303/psModules/src/objects/pmSourceMatch.c

    r21266 r23225  
    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    }
     
    506524psVector *pmSourceMatchRelphot(const psArray *matches, // Array of matches
    507525                               const psVector *zp, // Zero points for each image (including airmass term)
    508                                int maxIter, // Maximum number of iterations
    509526                               float tol, // Relative tolerance for convergence
     527                               int iter1, // Number of iterations for pass 1
     528                               float rej1, // Limit on rejection between iterations for pass 1
     529                               float sys1, // Systematic error in measurements for pass 1
     530                               int iter2, // Number of iterations for pass 2
     531                               float rej2, // Limit on rejection between iterations for pass 2
     532                               float sys2, // Systematic error in measurements for pass 2
    510533                               float rejLimit, // Limit on rejection between iterations
    511534                               int transIter, // Clipping iterations for transparency
    512535                               float transClip, // Clipping level for transparency
    513                                float photoLevel, // Level at which we declare image is photometric
    514                                float starClip, // Clipping for stars
    515                                float sysErr // Systematic error in measurements
     536                               float photoLevel // Level at which we declare image is photometric
    516537                               )
    517538{
     
    521542    PS_ASSERT_FLOAT_LARGER_THAN(transClip, 0.0, NULL);
    522543
    523     sysErr *= sysErr;
     544    sys1 *= sys1;
     545    sys2 *= sys2;
    524546
    525547    int numImages = zp->n;              // Number of images
     
    529551    psVector *photo = psVectorAlloc(numImages, PS_TYPE_U8); // Photometric determination for each image
    530552    psVectorInit(photo, 0);
     553    psVector *badImage = psVectorAlloc(numImages, PS_TYPE_U8); // Bad image?
     554    psVectorInit(badImage, 0);
    531555    psVector *stars = psVectorAlloc(numStars, PS_TYPE_F32); // Magnitudes for each star
    532556
    533     float chi2 = sourceMatchRelphotIterate(trans, stars, matches, zp, photo, sysErr); // chi^2 for solution
     557    float chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp,
     558                                           photo, sys1); // chi^2 for solution
    534559    psTrace("psModules.objects", 1, "Initial: chi^2 = %f\n", chi2);
    535560    float lastChi2 = INFINITY;          // chi^2 on last iteration
    536561    float fracRej = INFINITY;        // Fraction of measurements rejected
    537562
    538     // in the first passes, the transparencies are not well deteremined: use high systematic error and the rejection thresholds
    539     for (int i = 0; i < 5; i++) {
     563    // In the first passes, the transparencies are not well deteremined: use high systematic error and
     564    // rejection thresholds
     565    for (int i = 0; i < iter1; i++) {
    540566
    541567        // 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,
     568        int numPhoto = sourceMatchRelphotPhotometric(photo, trans, badImage, transIter, transClip,
    566569                                                     photoLevel); // Number of photometric images
    567570        if (numPhoto < 0) {
     
    572575            return NULL;
    573576        }
    574         psTrace("psModules.objects", 3, "Determined %d/%d are photometric", numPhoto, numImages);
    575 
    576         fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, starClip, sysErr);
    577         psTrace("psModules.objects", 3, "%f%% of measurements rejected", fracRej * 100);
    578 
    579         chi2 = sourceMatchRelphotIterate(trans, stars, matches, zp, photo, sysErr); // chi^2 for solution
    580         psTrace("psModules.objects", 1, "iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej);
     577        psTrace("psModules.objects", 3, "Pass 1: Determined %d/%d are photometric", numPhoto, numImages);
     578
     579        fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, badImage, rej1, sys1);
     580        psTrace("psModules.objects", 3, "Pass 1: %f%% of measurements rejected", fracRej * 100);
     581
     582        chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp, photo, sys1);
     583        psTrace("psModules.objects", 1, "Pass 1: iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej);
     584    }
     585
     586    for (int i = 0; i < iter2 && (fabsf(lastChi2 - chi2) > tol * chi2 || fracRej > rejLimit); i++) {
     587        lastChi2 = chi2;
     588
     589        // Identify photometric nights
     590        int numPhoto = sourceMatchRelphotPhotometric(photo, trans, badImage, transIter, transClip,
     591                                                     photoLevel); // Number of photometric images
     592        if (numPhoto < 0) {
     593            psError(PS_ERR_UNKNOWN, false, "Unable to perform photometric determination");
     594            psFree(trans);
     595            psFree(photo);
     596            psFree(stars);
     597            return NULL;
     598        }
     599        psTrace("psModules.objects", 3, "Pass 2: Determined %d/%d are photometric", numPhoto, numImages);
     600
     601        fracRej = sourceMatchRelphotReject(trans, stars, matches, zp, photo, badImage, rej2, sys2);
     602        psTrace("psModules.objects", 3, "Pass 2: %f%% of measurements rejected", fracRej * 100);
     603
     604        chi2 = sourceMatchRelphotIterate(trans, stars, badImage, matches, zp, photo, sys2);
     605        psTrace("psModules.objects", 1, "Pass 2: iter = %d: chi^2 = %f rejected = %f\n", i, chi2, fracRej);
    581606    }
    582607
    583608    psFree(photo);
     609    psFree(badImage);
    584610    psFree(stars);
    585611
  • branches/eam_branches/eam_branch_20090303/psModules/src/objects/pmSourceMatch.h

    r20953 r23225  
    5555psVector *pmSourceMatchRelphot(const psArray *matches, // Array of matches
    5656                               const psVector *zp, // Zero points for each image (including airmass term)
    57                                int maxIter, // Maximum number of iterations
    5857                               float tol, // Relative tolerance for convergence
     58                               int iter1, // Number of iterations for pass 1
     59                               float rej1, // Limit on rejection between iterations for pass 1
     60                               float sys1, // Systematic error in measurements for pass 1
     61                               int iter2, // Number of iterations for pass 2
     62                               float rej2, // Limit on rejection between iterations for pass 2
     63                               float sys2, // Systematic error in measurements for pass 2
    5964                               float rejLimit, // Limit on rejection between iterations
    6065                               int transIter, // Clipping iterations for transparency
    6166                               float transClip, // Clipping level for transparency
    62                                float photoLevel, // Level at which we declare image is photometric
    63                                float starClip, // Clipping for stars
    64                                float sysErr // Systematic error in measurements
     67                               float photoLevel // Level at which we declare image is photometric
    6568    );
    6669
  • branches/eam_branches/eam_branch_20090303/psModules/src/objects/pmSourceSky.c

    r21363 r23225  
    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/eam_branches/eam_branch_20090303/psModules/src/objects/pmSourceUtils.c

    r20937 r23225  
    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/eam_branches/eam_branch_20090303/psModules/src/psmodules.h

    r22699 r23225  
    113113#include <pmPSF.h>
    114114#include <pmModel.h>
     115#include <pmSourceMasks.h>
    115116#include <pmSource.h>
    116117#include <pmSourceUtils.h>
  • branches/eam_branches/eam_branch_20090303/psastro/src/Makefile.am

    r23202 r23225  
    11lib_LTLIBRARIES = libpsastro.la
    22
    3 # PSASTRO_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
    4 # PSASTRO_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
    5 # PSASTRO_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
    6 #
    7 # # Force recompilation of psastroVersion.c, since it gets the version information
     3libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSASTRO_VERSION=$(SVN_VERSION) -DPSASTRO_BRANCH=$(SVN_BRANCH) -DPSASTRO_SOURCE=$(SVN_SOURCE)
     4libpsastro_la_LDFLAGS = $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
     5
     6# Force recompilation of psastroVersion.c, since it gets the version information
     7# can we do this with dependency info?
    88# psastroVersion.c: FORCE
    9 #       touch psastroVersion.c
     9# touch psastroVersion.c
    1010# FORCE: ;
    11 
    12 libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSASTRO_VERSION=$(SVN_VERSION) -DPSASTRO_BRANCH=$(SVN_BRANCH) -DPSASTRO_SOURCE=$(SVN_SOURCE)
    13 libpsastro_la_LDFLAGS = $(PSASTRO_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    1411
    1512bin_PROGRAMS = psastro psastroModel psastroModelFit gpcModel
  • branches/eam_branches/eam_branch_20090303/psastro/src/psastro.c

    r21409 r23225  
    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/eam_branches/eam_branch_20090303/psastro/src/psastro.h

    r23157 r23225  
    9898psString          psastroVersionLong(void);
    9999bool              psastroVersionHeader(psMetadata *header);
     100bool              psastroVersionHeaderFull(psMetadata *header);
     101void              psastroVersionPrint(void);
    100102
    101103// demo plots
  • branches/eam_branches/eam_branch_20090303/psastro/src/psastroDataSave.c

    r21409 r23225  
    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/eam_branches/eam_branch_20090303/psastro/src/psastroVersion.c

    r23202 r23225  
    6161
    6262    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSASTRO.VERSION", PS_META_REPLACE,
    63                      "psastro software version", version);
     63                     "Software version", version);
    6464    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSASTRO.SOURCE", PS_META_REPLACE,
    65                      "psastro software source", source);
     65                     "S/W source", source);
    6666
    6767    psFree(version);
     
    7070    return true;
    7171}
     72
     73bool psastroVersionHeaderFull(psMetadata *header)
     74{
     75    PS_ASSERT_METADATA_NON_NULL(header, false);
     76
     77    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     78    psString timeString = psTimeToISO(time); // The time in an ISO string
     79    psFree(time);
     80    psString history = NULL;               // History string
     81    psStringAppend(&history, "psastro at %s", timeString);
     82    psFree(timeString);
     83    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     84    psFree(history);
     85
     86    psLibVersionHeader(header);
     87    psModulesVersionHeader(header);
     88    ppStatsVersionHeader(header);
     89    psastroVersionHeader(header);
     90
     91    return true;
     92}
     93
     94void psastroVersionPrint(void)
     95{
     96    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     97    psString timeString = psTimeToISO(time); // The time in an ISO string
     98    psFree(time);
     99    psLogMsg("psastro", PS_LOG_INFO, "psastro at %s", timeString);
     100    psFree(timeString);
     101
     102    psString pslib = psLibVersionLong();// psLib version
     103    psString psmodules = psModulesVersionLong(); // psModules version
     104    psString ppStats = ppStatsVersionLong(); // ppStats version
     105    psString psastro = psastroVersionLong(); // psastro version
     106
     107    psLogMsg("psastro", PS_LOG_INFO, "%s", pslib);
     108    psLogMsg("psastro", PS_LOG_INFO, "%s", psmodules);
     109    psLogMsg("psastro", PS_LOG_INFO, "%s", ppStats);
     110    psLogMsg("psastro", PS_LOG_INFO, "%s", psastro);
     111
     112    psFree(pslib);
     113    psFree(psmodules);
     114    psFree(ppStats);
     115    psFree(psastro);
     116
     117    return;
     118}
  • branches/eam_branches/eam_branch_20090303/psphot/src/psphot.c

    r20411 r23225  
    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/eam_branches/eam_branch_20090303/psphot/src/psphot.h

    r23156 r23225  
    1919psString        psphotVersionLong(void);
    2020bool            psphotVersionHeader(psMetadata *header);
     21bool            psphotVersionHeaderFull(psMetadata *header);
     22void            psphotVersionPrint(void);
    2123
    2224bool            psphotModelTest (pmConfig *config, const pmFPAview *view, psMetadata *recipe);
  • branches/eam_branches/eam_branch_20090303/psphot/src/psphotImageLoop.c

    r21458 r23225  
    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/eam_branches/eam_branch_20090303/psphot/src/psphotSetThreads.c

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

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

    r23202 r23225  
    7272
    7373    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSPHOT.VERSION", PS_META_REPLACE,
    74                      "psphot software version", version);
     74                     "Software version", version);
    7575    psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PSPHOT.SOURCE", PS_META_REPLACE,
    76                      "psphot software source", source);
     76                     "S/W source", source);
    7777
    7878    psFree(version);
     
    8181    return true;
    8282}
     83
     84
     85bool psphotVersionHeaderFull(psMetadata *header)
     86{
     87    PS_ASSERT_METADATA_NON_NULL(header, false);
     88
     89    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     90    psString timeString = psTimeToISO(time); // The time in an ISO string
     91    psFree(time);
     92    psString history = NULL;               // History string
     93    psStringAppend(&history, "psphot at %s", timeString);
     94    psFree(timeString);
     95    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     96    psFree(history);
     97
     98    psLibVersionHeader(header);
     99    psModulesVersionHeader(header);
     100    psphotVersionHeader(header);
     101
     102    return true;
     103}
     104
     105
     106void psphotVersionPrint(void)
     107{
     108    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     109    psString timeString = psTimeToISO(time); // The time in an ISO string
     110    psFree(time);
     111    psLogMsg("psphot", PS_LOG_INFO, "psphot at %s", timeString);
     112    psFree(timeString);
     113
     114    psString pslib = psLibVersionLong();// psLib version
     115    psString psmodules = psModulesVersionLong(); // psModules version
     116    psString psphot = psphotVersionLong(); // psphot version
     117
     118    psLogMsg("psphot", PS_LOG_INFO, "%s", pslib);
     119    psLogMsg("psphot", PS_LOG_INFO, "%s", psmodules);
     120    psLogMsg("psphot", PS_LOG_INFO, "%s", psphot);
     121
     122    psFree(pslib);
     123    psFree(psmodules);
     124    psFree(psphot);
     125
     126    return;
     127}
  • branches/eam_branches/eam_branch_20090303/pswarp/src/Makefile.am

    r23145 r23225  
    2828        pswarpSetThreads.c              \
    2929        pswarpTransformReadout.c        \
    30         pswarpTransformSources.c \
     30        pswarpTransformSources.c        \
    3131        pswarpTransformTile.c           \
    3232        pswarpVersion.c           
  • branches/eam_branches/eam_branch_20090303/pswarp/src/pswarp.c

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

    r23145 r23225  
    121121/// Return long software version information
    122122psString 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/eam_branches/eam_branch_20090303/pswarp/src/pswarpLoop.c

    r21468 r23225  
    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/eam_branches/eam_branch_20090303/pswarp/src/pswarpVersion.c

    r23145 r23225  
    1818#include <pslib.h>
    1919#include <psmodules.h>
     20#include <psphot.h>
     21#include <ppStats.h>
    2022#include "pswarp.h"
    2123
     
    5759    return version;
    5860};
     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;
     93}
     94
     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.