IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28534


Ignore:
Timestamp:
Jun 28, 2010, 8:11:04 PM (16 years ago)
Author:
Paul Price
Message:

Merging trunk in preparation for merging branch to trunk.

Location:
branches/pap
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/Nebulous-Server/bin/neb-host

    r28492 r28534  
    159159
    160160    neb-host [<nebulous host> <nebulous state>]
     161    [--note '<status note>']
    161162    [--host <nebulous host>] [--state <up|down|repair>]
    162163    [--dbhost <database host>] [--db <database name>]
     
    174175=over 4
    175176
     177=item * --note <status note>
     178
     179Set a status note for the specified volume.
     180
    176181=item * --host <nebulous host>
    177182
  • branches/pap/Nebulous-Server/bin/nebdiskd

    r28492 r28534  
    5353# set the process name for easy pgrep-ability
    5454$0 = 'nebdiskd';
    55 my $rcfile = "$ENV{HOME}/.nebdiskrc";
     55#my $rcfile = "$ENV{HOME}/.nebdiskrc";
     56my $rcfile = $ENV{NEBDISKDRC};
     57unless (defined($rcfile)) {
     58    $rcfile = '/etc/nebdiskd.rc';
     59}
    5660$rcfile = File::Spec->canonpath($rcfile);
    5761
     
    7175my %host_removed = ();
    7276my $failure_limit = 5;
    73 
    74 
    7577
    7678#my $mounts = $c->get_mounts;
     
    143145$SIG{HUP}  = sub { $c = read_rcfile($rcfile) };
    144146
     147my $date = localtime();
     148$log->warn("BEGIN: $date with RCFILE: $rcfile");
    145149
    146150while (1) {
  • branches/pap/Nebulous-Server/lib/Nebulous/Server.pm

    r28446 r28534  
    99no warnings qw( uninitialized );
    1010
    11 our $VERSION = '0.17';
     11our $VERSION = '0.18';
    1212
    1313use base qw( Class::Accessor::Fast );
     
    15081508
    15091509    return \@keys;
     1510}
     1511
     1512sub find_objects_wildcard
     1513{
     1514    my $self = shift;
     1515
     1516    my $log = $self->log;
     1517    $log->debug( "entered - @_" );
     1518
     1519    my ($pattern) = validate_pos( @_,
     1520        {
     1521            type        => SCALAR,
     1522            optional    => 1,
     1523        },
     1524    );
     1525
     1526    my $sql = $self->sql;
     1527    my $db  = $self->_db_for_index(0);
     1528   
     1529    # validate that we have a key to deal with
     1530    eval {
     1531        $pattern = parse_neb_key($pattern) if defined $pattern;
     1532    };
     1533    $log->logdie("$@") if $@;
     1534
     1535    unless (defined $pattern) {
     1536        $log->debug( "leaving" );
     1537        $log->logdie("no keys found");
     1538    }
     1539
     1540    # parse out the directory we're working in, and decide if we are a directory
     1541    my $dir_id = $self->_resolve_dir_parent_id(key => $pattern, dir_id => 1);
     1542    my $work_dir;
     1543    my $file_pattern;
     1544    if (defined $dir_id) {
     1545        $work_dir = $pattern;
     1546        $file_pattern = '%';
     1547    }
     1548    else {
     1549        my $dir_plain = dirname($pattern);
     1550        if ($dir_plain eq 'neb:') {
     1551            $dir_plain = 'neb:///';
     1552        }
     1553        if ($dir_plain) {
     1554            $work_dir = parse_neb_key($dir_plain);
     1555        }
     1556        else {
     1557            $work_dir = parse_neb_key('/');
     1558        }
     1559        $file_pattern = basename $pattern;
     1560        unless ($file_pattern) {
     1561            $file_pattern = '%';
     1562        }
     1563       
     1564        $dir_id = $self->_resolve_dir_parent_id(key => $work_dir, dir_id => 1);
     1565        unless (defined $dir_id) {
     1566            $log->logdie("pattern $work_dir does not match any key or directory");
     1567        }
     1568    }
     1569   
     1570    # find dirs under dir
     1571    my @dir_keys;
     1572
     1573    eval {
     1574        $log->debug("looking for directories under dir: $dir_id");
     1575        my $query = $db->prepare_cached( $sql->find_dir_by_parent_id . " AND dirname LIKE ? ");
     1576        $query->execute( $dir_id, $file_pattern );
     1577
     1578        while ( my $row = $query->fetchrow_hashref ) {
     1579            next if $row->{'dir_id'} == 1;
     1580            my $dir = $row->{'dirname'};
     1581            if ($dir_id == 1) {
     1582                push @dir_keys, $dir . '/' if $dir;
     1583            } else {
     1584                push @dir_keys, $work_dir->path . '/' . $dir . '/' if $dir;
     1585            }
     1586            $log->debug( "matched $dir" ) if $dir;
     1587        }
     1588    };
     1589    $log->logdie("database error: $@") if $@;
     1590
     1591    # find files under dir
     1592    my @keys;
     1593    eval {
     1594        $log->debug("looking for objects under dir: $dir_id");
     1595        my $query = $db->prepare_cached( $sql->find_object_by_dir_id . " AND ext_id_basename LIKE ? ");
     1596        $query->execute( $dir_id , $file_pattern);
     1597
     1598        while ( my $row = $query->fetchrow_hashref ) {
     1599            my $key = $row->{ 'ext_id' };
     1600            push @keys, $key if $key;
     1601            $log->debug( "matched $key" ) if $key;
     1602        }
     1603    };
     1604    $log->logdie("database error: $@") if $@;
     1605
     1606    $log->debug( "leaving" );
     1607   
     1608    return [sort(@dir_keys), sort(@keys)];
     1609
    15101610}
    15111611
  • branches/pap/Nebulous/bin/neb-ls

    r24346 r28534  
    11#!/usr/bin/env perl
    22
    3 # Copyright (C) 2007-2009  Joshua Hoblitt
     3# Copyright (C) 2007-2009  Joshua Hoblitt, 2010 Chris Waters
    44
    55use strict;
     
    1616my (
    1717    $server,
    18     $long,
    19 #    $recursive,
     18    $path,
     19    $column,
    2020);
    2121
    2222$server = $ENV{'NEB_SERVER'} unless $server;
    2323
    24 # make --long the default
    25 $long = 1;
    2624
    2725GetOptions(
    2826    'server|s=s'    => \$server,
    29 #    'recursive|r'   => \$recursive,
    30     'l|1'           => \$long,
     27    'path|p'        => \$path,
     28    'column|c'      => \$column,
    3129) || pod2usage( 2 );
     30
     31# twiddle column so that it does it by default.
     32
     33$column = not $column;
    3234
    3335my $pattern = shift;
     
    4749$pattern ||= "/";
    4850
    49 #if ($recursive) {
    50 #    $pattern = "^" . $pattern . ".*";
    51 #} else {
    52 #    $pattern = "^" . $pattern . "\$";
    53 #}
     51my $keys = $neb->find_objects_wildcard($pattern);
    5452
    55 my $keys = $neb->find_objects($pattern);
    56 
     53if ($path) {
     54    my @files;
     55    foreach my $key (@{ $keys }) {
     56        my $uris = $neb->find_instances($key);
     57        if (defined $uris) {
     58            push @files, URI->new(@$uris[0])->file;
     59        }
     60    }
     61    @{ $keys } = @files;
     62}
    5763if ($keys) {
    58     if ($long) {
    59         print join("\n", @{ $keys }), "\n";
    60     } else {
    61         print join(" ", @{ $keys }), "\n";
     64    if ($column) {
     65        open(COLUMN,"|column") || die "Cannot open column command.";
     66        print COLUMN join("\n", @{ $keys }), "\n";
     67        close(COLUMN);
     68    }
     69    else {
     70        print join("\n", @{ $keys }), "\n";
    6271    }
    6372}
     73
    6474
    6575__END__
     
    7383=head1 SYNOPSIS
    7484
    75     neb-ls [--server <URL>] [-l|-1] [--recursive] <pattern>
     85    neb-ls [--server <URL>] [-c] [-p] <pattern>
    7686
    7787=head1 DESCRIPTION
    7888
    7989This program list Nebulous keys matched by C<<pattern>>.  Call it with no
    80 arguments is equivalanet to searching with the pattern C<.*>.  Where
    81 C<<pattern>> is a POSIX 1003.2 compatable regular repression.
     90arguments is equivalent to searching with the pattern C<neb://>.  SQL like
     91wildcards are supported to select out certain files.
    8292
    8393=head1 OPTIONS
     
    8595=over 4
    8696
    87 =item * -l|-1
     97=item * --path|-p
    8898
    89 Use a long listing format.
     99Find the disk files corresponding to the keys found.
     100
     101=item * --column|-c
     102
     103Disable column formatting, and output results one to a line.
    90104
    91105Optional
    92106
    93 =cut
    94 #=item * --recursive|-r
    95 #
    96 #By default C<neb-ls> will only try to match the exact string provided to it.
    97 #With this option set all keys which match C<<pattern>> as a REGEX or substring
    98 #will be returned.
    99 #
    100 #Optional
    101 #
    102107=item * --server|-s <URL>
    103108
     
    122127=back
    123128
    124 =head1 CREDITS
    125 
    126 Just me, myself, and I.
    127 
    128129=head1 SUPPORT
    129130
     
    132133=head1 AUTHOR
    133134
    134 Joshua Hoblitt <jhoblitt@cpan.org>
     135Joshua Hoblitt <jhoblitt@cpan.org>, Chris Waters
    135136
    136137=head1 COPYRIGHT
    137138
    138 Copyright (C) 2007-2009  Joshua Hoblitt.  All rights reserved.
     139Copyright (C) 2007-2010  Joshua Hoblitt / Chris Waters.  All rights reserved.
    139140
    140141This program is free software; you can redistribute it and/or modify it under
  • branches/pap/Nebulous/lib/Nebulous/Client.pm

    r28446 r28534  
    99no warnings qw( uninitialized );
    1010
    11 our $VERSION = '0.17';
     11our $VERSION = '0.18';
    1212
    1313use Digest::MD5;
     
    741741}
    742742
     743sub find_objects_wildcard
     744{
     745    my $self = shift;
     746
     747    my @args = validate_pos( @_,
     748        {
     749            type        => SCALAR,
     750            optional    => 1,
     751        },
     752    );
     753
     754    $log->debug( "entered - @_" );
     755
     756    my $response = $self->{ 'server' }->find_objects_wildcard( @args );
     757    if ( $response->fault ) {
     758        $self->set_err($response->faultstring);
     759
     760        if ($response->faultstring =~ /no keys found/) {
     761            $log->debug( "leaving" );
     762            return;
     763        }
     764        if ($response->faultstring =~ /does not match any key or directory/) {
     765            $log->debug( "leaving" );
     766            return;
     767        }
     768
     769        $log->logdie("unhandled fault - ", $self->err);
     770    }
     771
     772    my $keys = $response->result;
     773
     774    $log->debug( "server found: @$keys" );
     775
     776#    foreach my $path ( @{ $uris } ) {
     777#        $path = _get_file_path( $path );
     778#    }
     779
     780    $log->debug( "leaving" );
     781
     782    return $keys;
     783}
     784
    743785
    744786sub find_instances
  • branches/pap/ippScripts/scripts/automate_stacks.pl

    r28444 r28534  
    766766    $cmd .= " -workdir $workdir ";
    767767    $cmd .= " -label $label ";
     768    $cmd .= " -use_begin ${date}T00:00:00 -use_end ${date}T23:59:59 ";
    768769    if ($maxN > 0) {
    769770        $cmd .= " -random_subset -random_limit $maxN ";
  • branches/pap/ippScripts/scripts/dqstats_bundle.pl

    r27718 r28534  
    7373# Output products
    7474unless (defined($uri)) {
    75     $uri = "/data/${host}.0/tmp/dqstats.${dqstats_id}.fits";
     75    $uri = "/tmp/dqstats.${dqstats_id}.fits";
    7676}
    7777#$ipprc->outroot_prepare($uri); # hm....need to think more here.
     
    9090    unless ($success) {
    9191        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     92        unlink($uri);
    9293        &my_die("Unable to create the bundle.: $error_code", $dqstats_id, $error_code);
    9394    }
     
    106107    unless ($success) {
    107108        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     109        unlink($uri);
    108110        &my_die("Unable to register the bundle.: $error_code", $dqstats_id, $error_code);
    109111    }
  • branches/pap/ippTasks/dqstats.pro

    r27304 r28534  
    3737  task dqstats.revert
    3838    active false
     39  end
     40end
     41
     42macro dqstats.revert.on
     43  task dqstats.revert
     44    active true
     45  end
     46end
     47
     48macro dqstats.revert.off
     49  task dqstats.revert
     50    active true
    3951  end
    4052end
     
    109121
    110122  ## we want only a single outstanding dqstats job. 
    111   host         local
    112123  npending     1
    113124
     
    187198  periods      -timeout 120.0
    188199  npending     1
     200  active       false
    189201
    190202  stdout NULL
  • branches/pap/ippTasks/ipphosts.mhpcc.config

    r28438 r28534  
    253253END
    254254
    255 # this list is no longer used
    256 # XXX : delete if this does not cause trouble
    257 ## ipphosts METADATA
    258 ##   camera STR distribution
    259 ##   count  S32  26
    260 ##   0      STR ipp021
    261 ##   1      STR ipp023
    262 ##   2      STR ipp024
    263 ##   3      STR ipp026
    264 ##   4      STR ipp028
    265 ##   5      STR ipp029
    266 ##   6      STR ipp030
    267 ##   7      STR ipp031
    268 ##   8      STR ipp032
    269 ##   9      STR ipp033
    270 ##  10      STR ipp034
    271 ##  11      STR ipp035
    272 ##  12      STR ipp036
    273 ##  13      STR ipp038
    274 ##  14      STR ipp039
    275 ##  15      STR ipp040
    276 ##  16      STR ipp041
    277 ##  17      STR ipp043
    278 ##  18      STR ipp044
    279 ##  19      STR ipp045
    280 ##  20      STR ipp046
    281 ##  21      STR ipp047
    282 ##  22      STR ipp048
    283 ##  23      STR ipp050
    284 ##  24      STR ipp051
    285 ##  25      STR ipp052
    286 ## END
     255ipphosts METADATA
     256  camera STR distribution
     257  count  S32  26
     258  0      STR ipp021
     259  1      STR ipp023
     260  2      STR ipp024
     261  3      STR ipp026
     262  4      STR ipp028
     263  5      STR ipp029
     264  6      STR ipp030
     265  7      STR ipp031
     266  8      STR ipp032
     267  9      STR ipp033
     268 10      STR ipp034
     269 11      STR ipp035
     270 12      STR ipp036
     271 13      STR ipp038
     272 14      STR ipp039
     273 15      STR ipp040
     274 16      STR ipp041
     275 17      STR ipp043
     276 18      STR ipp044
     277 19      STR ipp045
     278 20      STR ipp046
     279 21      STR ipp047
     280 22      STR ipp048
     281 23      STR ipp050
     282 24      STR ipp051
     283 25      STR ipp052
     284END
    287285
    288286ipphosts METADATA
  • branches/pap/ippToPsps/scripts/createDb.pl

    r28206 r28534  
    2525print "* Connected to '$dbname' on 'dbserver'\n";
    2626
    27 if (!doesTableExist("revision")) {
    28     createRevision_1();
     27my $currentRevision = -1;
     28
     29my $latestRevision = 3;
     30    print "* Latest revision = $latestRevision\n";
     31
     32while ($currentRevision != $latestRevision) {
     33
     34    $currentRevision = getRevision();
     35    print "* Current revision = $currentRevision\n";
     36
     37    if ($currentRevision == 0) {createRevision_1();}
     38    elsif ($currentRevision == 1) {createRevision_2();}
     39    elsif ($currentRevision == 2) {createRevision_3();}
     40
    2941}
    30 
    31 
    3242$db->disconnect();
    3343print "* Disconnected from '$dbname' on 'dbserver'\n";
    3444print "*\n*******************************************************************************\n\n";
     45
    3546
    3647#######################################################################################
     
    5061            primary key (revision)
    5162            );
    52 SQL
    53         $query->execute;
    54 
    55     $query = $db->prepare(<<SQL);
    56     INSERT INTO revision (revision) VALUES (1);
    5763SQL
    5864        $query->execute;
     
    7783    $query->execute;
    7884
     85setRevision(1);
     86
     87}
     88
     89#######################################################################################
     90#
     91# Create revision 2 of the database
     92#
     93#######################################################################################
     94sub createRevision_2 {
     95
     96    print "* Creating revision 2 of '$dbname'\n";
     97
     98        my $query = $db->prepare(<<SQL);
     99
     100        ALTER TABLE batches
     101        ADD COLUMN merged TINYINT DEFAULT 0
     102SQL
     103    $query->execute;
     104
     105setRevision(2);
     106}
     107
     108#######################################################################################
     109#
     110# Create revision 3 of the database
     111#
     112#######################################################################################
     113sub createRevision_3 {
     114
     115    print "* Creating revision 3 of '$dbname'\n";
     116
     117        my $query = $db->prepare(<<SQL);
     118
     119        ALTER TABLE batches
     120        ADD COLUMN total_detections BIGINT DEFAULT 0
     121SQL
     122    $query->execute;
     123
     124setRevision(3);
     125}
     126
     127
     128#######################################################################################
     129#
     130# Sets current revision of ippToPsps database
     131#
     132#######################################################################################
     133sub setRevision {
     134    my ($revision) = @_;
     135
     136    my $query = $db->prepare(<<SQL);
     137    INSERT INTO revision (revision) VALUES ($revision);
     138SQL
     139        $query->execute;
    79140}
    80141
     
    82143#
    83144# Gets current revision of ippToPsps database
     145#
     146#######################################################################################
     147sub getRevision {
     148
     149    if (!doesTableExist("revision")) {return 0;}
     150
     151    my $query = $db->prepare(<<SQL);
     152
     153    SELECT revision
     154        FROM revision
     155        ORDER BY revision DESC LIMIT 1;
     156SQL
     157   $query->execute;
     158   my @row = $query->fetchrow_array();
     159
     160   return $row[0];
     161}
     162
     163#######################################################################################
     164#
     165# Checks whether a certain table exists
    84166#
    85167#######################################################################################
     
    99181    my $count = $query->fetchrow_array();
    100182
    101     printf( "* Table '$table' %s\n", $count ? "exists" : "does not exist");
    102 
    103183    return $count;
    104184}
  • branches/pap/ippToPsps/scripts/ippToPsps_run.pl

    r28260 r28534  
    1010use constant DB_SOCKET => '/var/run/mysqld/mysqld.sock';
    1111use File::Temp qw(tempfile);
     12use XML::LibXML;
    1213
    1314# globals
     
    7374
    7475# make a temporary file for saving results
    75 my ($resultsFile, $resultsFileName) = tempfile( "/tmp/ippToPsps_results.XXXX", UNLINK => !$save_temps);
     76my ($resultsFile, $resultsFilePath) = tempfile( "/tmp/ippToPsps_results.XXXX", UNLINK => !$save_temps);
    7677
    7778process();
     
    118119}
    119120
    120 
    121121#######################################################################################
    122122#
     
    160160            AND chipRun.exp_id = rawExp.exp_id
    161161            AND camRun.dist_group = '$survey'   
     162            AND rawExp.dateobs >= '2010-02-20'
    162163            GROUP BY  rawExp.exp_id
    163164            ORDER BY rawExp.exp_id ASC;
     
    457458
    458459    # read results
    459     open (MYFILE, $resultsFileName);
    460     my $i = 0;
    461 
    462     # detection results
    463     my $minObjId;
    464     my $maxObjId;
    465     my $filename;
    466     if($batchType eq 'det') {
    467 
    468         while (<MYFILE>) {
    469             chomp;
    470             if ($i == 0) { $filename = $_; }
    471             if ($i == 1) { $minObjId = $_; }
    472             if ($i == 2) { $maxObjId = $_; }
    473             $i++;
    474         }
    475     }
    476     close (MYFILE);
     460    my $parser = XML::LibXML->new;
     461    my $doc = $parser->parse_file($resultsFilePath);
     462    my $filename = $doc->findvalue('//filename');
     463    my $minObjId = $doc->findvalue('//minObjID');
     464    my $maxObjId = $doc->findvalue('//maxObjID');
    477465
    478466    # create XML file
     
    794782    $command .= " -survey $surveyType";
    795783    $command .= " -batch $batchType";
    796     $command .= " -results $resultsFileName";
     784    $command .= " -results $resultsFilePath";
    797785
    798786    # run command
  • branches/pap/ippToPsps/src/ippToPsps.c

    r28249 r28534  
    5353    }
    5454
     55    // save XML document for results
     56    if (this->resultsXmlDoc) {
     57   
     58        xmlSaveFormatFileEnc(this->resultsPath, this->resultsXmlDoc, "UTF-8", 1);
     59
     60        xmlFreeDoc(this->resultsXmlDoc);
     61        xmlCleanupParser();
     62        xmlMemoryDump();
     63    }
     64
    5565    psFree(this->fitsInPath);
    5666    psFree(this->resultsPath);
     
    5969    psFree(this->pmconfig);
    6070
    61     if (this->resultsFile) fclose(this->resultsFile);
    6271
    6372    for(uint32_t i=0; i<this->numOfInputFiles; i++)
     
    246255    this->fitsInPath = NULL;
    247256    this->resultsPath = NULL;
    248     this->resultsFile = NULL;
     257    this->resultsXmlDoc = NULL;
    249258    this->numOfInputFiles = 0;
    250259    this->inputFiles = NULL;
     
    304313    }
    305314
     315    // create a config object
    306316    this->config = ippToPspsConfig_Constructor(this->configsDir);
    307317    if (this->config == NULL) {
     
    311321    }
    312322
    313     // ready results file, if necessary
     323    // create XML document for results
    314324    if (this->resultsPath) {
    315325
    316         this->resultsFile = fopen (this->resultsPath, "w+");
    317 
    318         if (this->resultsFile == NULL) {
    319 
    320             psError(PS_ERR_UNKNOWN, false, "Unable to open results file at %s", this->resultsPath);
    321             // not essential to write results, so don't bail out
    322         }
    323         else {
    324             if (fprintf(this->resultsFile, "%s\n", outputName) < 1 )     
    325                 psError(PS_ERR_IO, false, "Unable to write FITS output filename to'%s'\n", this->resultsPath);
    326         }
     326        this->resultsXmlDoc = xmlNewDoc(BAD_CAST "1.0");
     327        xmlNodePtr rootNode = xmlNewNode(NULL, BAD_CAST "ippToPsps_Results");
     328        xmlDocSetRootElement(this->resultsXmlDoc, rootNode);
     329        xmlNewChild(rootNode, NULL, BAD_CAST "filename", BAD_CAST outputName);
    327330    }
    328331
  • branches/pap/ippToPsps/src/ippToPsps.h

    r28249 r28534  
    1515#include <dvo_util.h>
    1616#include "ippToPspsConfig.h"
     17#include <libxml/parser.h>
     18#include <libxml/tree.h>
    1719
    1820#define MAXDETECT 30000 //TODO limit ok?
     
    2022typedef struct {
    2123
    22     uint32_t expId;            // the exposure ID to be used
    23     psString expName;          // the exposure name
    24     psString surveyType;       // the survey type, eg 3PI, MD01, STS, SSS
    25     uint8_t batchType;         // PSPS batch type
    26     psString fitsInPath;       // path to FITS input
    27     psString resultsPath;      // path to results file
    28     FILE* resultsFile;         // file for results 
    29     uint16_t numOfInputFiles;  // number of input files
    30     char** inputFiles;         // array of input file names
    31     psString fitsOutPath;      // path to FITS output
    32     fitsfile *fitsOut;         // output FITS file
    33     psString configsDir;       // path to IPP/PSPS mapping file
    34     pmConfig* pmconfig;        // pmConfig
    35     dvoConfig* dvoConfig;      // dvo database
    36     IppToPspsConfig* config;   // config structure
    37     int exitCode;              // ps exit code
     24    uint32_t expId;             // the exposure ID to be used
     25    psString expName;           // the exposure name
     26    psString surveyType;        // the survey type, eg 3PI, MD01, STS, SSS
     27    uint8_t batchType;          // PSPS batch type
     28    psString fitsInPath;        // path to FITS input
     29    psString resultsPath;       // path to results file
     30    xmlDocPtr resultsXmlDoc;    // pointer to XML document for results
     31    uint16_t numOfInputFiles;   // number of input files
     32    char** inputFiles;          // array of input file names
     33    psString fitsOutPath;       // path to FITS output
     34    fitsfile *fitsOut;          // output FITS file
     35    psString configsDir;        // path to IPP/PSPS mapping file
     36    pmConfig* pmconfig;         // pmConfig
     37    dvoConfig* dvoConfig;       // dvo database
     38    IppToPspsConfig* config;    // config structure
     39    int exitCode;               // ps exit code
    3840
    3941    int (*run)();
  • branches/pap/ippToPsps/src/ippToPspsBatchDetection.c

    r28424 r28534  
    386386
    387387    // write results
    388     if (this->resultsFile) {
    389 
    390         if (fprintf(this->resultsFile, "%ld\n", minObjID) < 1 )
    391             psError(PS_ERR_IO, false, "Unable to write min Object ID to'%s'\n", this->resultsPath);
    392         if (fprintf(this->resultsFile, "%ld\n", maxObjID) < 1 )
    393             psError(PS_ERR_IO, false, "Unable to write max Object ID to'%s'\n", this->resultsPath);
    394         if (fprintf(this->resultsFile, "%ld\n", totalDetectionsOut) < 1 )
    395             psError(PS_ERR_IO, false, "Unable to write totalDetectionsOut to'%s'\n", this->resultsPath);
     388    if (this->resultsXmlDoc) {
     389
     390        xmlNodePtr rootNode = xmlDocGetRootElement(this->resultsXmlDoc);
     391        char tmp[100];
     392        sprintf(tmp, "%ld", minObjID);
     393        xmlNewChild(rootNode, NULL, BAD_CAST "minObjID", BAD_CAST tmp);
     394        sprintf(tmp, "%ld", maxObjID);
     395        xmlNewChild(rootNode, NULL, BAD_CAST "maxObjID", BAD_CAST tmp);
     396        sprintf(tmp, "%ld", totalDetectionsOut);
     397        xmlNewChild(rootNode, NULL, BAD_CAST "totalDetections", BAD_CAST tmp);
    396398    }
    397399
  • branches/pap/ippToPsps/src/ippToPspsBatchTest.c

    r27809 r28534  
    331331    if (fits_close_file(fitsIn, &status)) fits_report_error(stderr, status);
    332332
    333     // write results
    334     if (this->resultsFile) {
    335 
    336         if (fprintf(this->resultsFile, "%ld\n", minObjID) < 1 )
    337             psError(PS_ERR_IO, false, "Unable to write min Object ID to'%s'\n", this->resultsPath);
    338         if (fprintf(this->resultsFile, "%ld\n", maxObjID) < 1 )
    339             psError(PS_ERR_IO, false, "Unable to write max Object ID to'%s'\n", this->resultsPath);
    340     }
    341 
    342333    psLogMsg("ippToPsps", PS_LOG_INFO, "Data written for a total of %d chips/OTAs", nOta);
    343334
  • branches/pap/ippTools/src/bgtool.c

    r28486 r28534  
    10781078    PXOPT_COPY_F32(config->args,   where, "-sun_angle_max",      "rawExp.sun_angle",      "<");
    10791079    pxAddLabelSearchArgs(config,   where, "-warp_label",         "warpRun.label",         "==");
    1080     pxAddLabelSearchArgs(config,   where, "-bg_label",           "chipBackgroundRun.label", "==");
     1080    pxAddLabelSearchArgs(config,   where, "-chip_label",         "chipBackgroundRun.label", "==");
    10811081
    10821082    if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
  • branches/pap/ippTools/src/bgtoolConfig.c

    r28486 r28534  
    249249    psMetadataAddF32(definewarpArgs, PS_LIST_TAIL, "-sun_angle_max", 0, "search by max solar angle", NAN);
    250250    psMetadataAddStr(definewarpArgs, PS_LIST_TAIL, "-warp_label", PS_META_DUPLICATE_OK, "search on warpRun label", NULL);
    251     psMetadataAddStr(definewarpArgs, PS_LIST_TAIL, "-bg_label", PS_META_DUPLICATE_OK, "search on warpBackgroundRun label", NULL);
     251    psMetadataAddStr(definewarpArgs, PS_LIST_TAIL, "-chip_label", PS_META_DUPLICATE_OK, "search on chipBackgroundRun label", NULL);
    252252    psMetadataAddBool(definewarpArgs, PS_LIST_TAIL, "-rerun", 0, "rerun data?", false);
    253253    psMetadataAddStr(definewarpArgs, PS_LIST_TAIL, "-set_workdir", 0, "define workdir", NULL);
  • branches/pap/ippTools/src/magictool.c

    r28279 r28534  
    13651365    // check that state is a valid string value
    13661366    if (!(
    1367             (strncmp(state, "new", 4) == 0)
    1368             || (strncmp(state, "full", 5) == 0)
    1369             || (strncmp(state, "drop", 5) == 0)
    1370             || (strncmp(state, "reg", 4) == 0)
     1367            (strncmp(state, "new", 3) == 0)
     1368            || (strncmp(state, "full", 4) == 0)
     1369            || (strncmp(state, "drop", 4) == 0)
     1370            || (strncmp(state, "reg", 3) == 0)
    13711371        )
    13721372    ) {
  • branches/pap/magic/remove/src/streaksremove.c

    r28275 r28534  
    577577}
    578578
    579 static void 
     579static void
    580580setStreakBits(psImage *maskImage, psU32 maskStreak)
    581581{
     
    644644            if (exciseAll) {
    645645                strkGetMaskValues(sf);
    646                
     646
    647647                // add the STREAK bit to the mask image pixels
    648648                setStreakBits(sf->inMask->image, sf->maskStreak);
     
    941941        psArray *inTable = psFitsReadTable(in->fits);
    942942        if (!inTable) {
    943             psErrorStackPrint(stderr, "failed to read tablle in %s", in->resolved_name);
    944             streaksExit("", PS_EXIT_DATA_ERROR);
    945         }
    946         if (!inTable->n) {
    947             psErrorStackPrint(stderr, "table in %s is empty", in->resolved_name);
     943            psErrorStackPrint(stderr, "failed to read table in %s", in->resolved_name);
    948944            streaksExit("", PS_EXIT_DATA_ERROR);
    949945        }
     
    983979                streaksExit("", PS_EXIT_DATA_ERROR);
    984980            }
     981        } else if (psArrayLength(inTable) == 0) {
     982            printf("No input sources\n");
     983            // We'd like to write a blank table, but this is as good as it gets without more work to parse the
     984            // header and create dummy columns.
     985            if (!psFitsWriteBlank(out->fits, header, extname)) {
     986                psErrorStackPrint(stderr, "failed to write empty header to %s", out->resolved_name);
     987                streaksExit("", PS_EXIT_DATA_ERROR);
     988            }
    985989        } else {
    986990            printf("Censored ALL %d sources\n", numCensored);
  • branches/pap/psLib/src/fits/psFitsImage.c

    r27313 r28534  
    415415    if (fits_read_subset(fits->fd, info->fitsDatatype, info->firstPixel, info->lastPixel,
    416416                         info->increment, nullValue, output->data.V[0], &anynull, &status) != 0) {
    417         psFitsError(status, true, "Reading FITS file failed.");
     417        psFitsError(status, true, "Reading FITS file %s failed.", fits->fd->Fptr->filename);
    418418        return false;
    419419    }
  • branches/pap/psLib/src/fits/psFitsTable.c

    r28216 r28534  
    3939
    4040    int status = 0;                     // CFITSIO status
     41
     42    // Check for empty table, which looks like an image
     43    int hdutype;                        // Type of HDU
     44    fits_get_hdu_type(fits->fd, &hdutype, &status);
     45    if (psFitsError(status, true, "Could not determine the HDU type.")) {
     46        return -1;
     47    }
     48    if (hdutype == IMAGE_HDU) {
     49        // It could be an empty table
     50        int naxis = 0;                  // Dimensions of image
     51        if (fits_get_img_dim(fits->fd, &naxis, &status) != 0) {
     52            psFitsError(status, true, "Unable to determine dimension for table.");
     53            return -1;
     54        }
     55        if (naxis != 0) {
     56            psFitsError(PS_ERR_BAD_FITS, true, "Current FITS HDU is not a table.");
     57            return -1;
     58        }
     59        return 0;
     60    }
     61
    4162    long numRows;                       // Number of rows
    4263    if (fits_get_num_rows(fits->fd, &numRows, &status)) {
     
    4869}
    4970
     71
    5072// Check the FITS file in preparation for reading a table
    5173static bool readTableCheck(const psFits *fits // FITS file
    5274                           )
    5375{
    54     PS_ASSERT_FITS_NON_NULL(fits, NULL);
     76    PS_ASSERT_FITS_NON_NULL(fits, false);
    5577
    5678    if (psFitsGetExtNum(fits) == 0 && !psFitsMoveExtNum(fits, 1, false)) {
     
    5880        return false;
    5981    }
    60 
    6182
    6283    // check that we are positioned on a table HDU
     
    6788        return false;
    6889    }
    69     if (hdutype != ASCII_TBL && hdutype != BINARY_TBL) {
    70         psError(PS_ERR_IO, true, _("Current FITS HDU is not a table."));
     90    if (hdutype == IMAGE_HDU) {
     91        // It could be an empty table
     92        int naxis = 0;                  // Dimensions of image
     93        if (fits_get_img_dim(fits->fd, &naxis, &status) != 0) {
     94            psFitsError(status, true, "Unable to determine dimension for table.");
     95            return false;
     96        }
     97        if (naxis != 0) {
     98            psFitsError(PS_ERR_BAD_FITS, true, "Current FITS HDU is not a table.");
     99            return false;
     100        }
     101    } else if (hdutype != ASCII_TBL && hdutype != BINARY_TBL) {
     102        psError(PS_ERR_BAD_FITS, true, _("Current FITS HDU is not a table."));
    71103        return false;
    72104    }
  • branches/pap/psModules/src/objects/pmSourceMatch.c

    r28119 r28534  
    227227            }
    228228
     229            numMaster = size;
    229230            xMaster->n = size;
    230231            yMaster->n = size;
  • branches/pap/psModules/src/objects/pmSourcePhotometry.c

    r28426 r28534  
    393393    psImage *mask     = source->maskObj;
    394394
     395    if (!flux || !variance || !mask) {
     396        return false;
     397    }
     398
    395399    for (int iy = 0; iy < flux->numRows; iy++) {
    396400        for (int ix = 0; ix < flux->numCols; ix++) {
  • branches/pap/psphot/src/psphotApResid.c

    r28405 r28534  
    328328    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "DAPMIFIT", PS_DATA_F32 | PS_META_REPLACE, "ap residual scatter", psf->dApResid);
    329329    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "NAPMIFIT", PS_DATA_S32 | PS_META_REPLACE, "number of apresid stars", psf->nApResid);
    330     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "APLOSS",   PS_DATA_F32 | PS_META_REPLACE, "aperture loss (mag)", psf->growth->apLoss);
     330    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "APLOSS",   PS_DATA_F32 | PS_META_REPLACE, "aperture loss (mag)", psf->growth ? psf->growth->apLoss : NAN);
    331331
    332332    psLogMsg ("psphot.apresid", PS_LOG_DETAIL, "aperture residual: %f +/- %f\n", psf->ApResid, psf->dApResid);
Note: See TracChangeset for help on using the changeset viewer.