IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 6, 2005, 6:43:52 PM (21 years ago)
Author:
Paul Price
Message:

Importing current working PAP version (many bug fixes since this branch) straight on top of this version, and tidying up a bit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pois/src/poisParseConfig.c

    r3805 r5717  
    44#include "pois.h"
    55
    6 static void help(void)
     6void help(void)
    77{
    88    fprintf (stderr, "POIS: Pan-STARRS (or Pricey's) Optimal Image Subtraction\n"
    9              "Usage: pois [-h] [-v] [-k X Y] [-t T] [-s S1 S2] [-b BAD] [-B BG] [-o N] [-n NSTAMPS] [-i ITER] [-r REJ] REF IN OUT\n"
     9             "Usage: pois [-h] [-v] [-k X Y] [-t T] [-s S1 S2] [-b B1 B2] [-B BG] [-o N] [-n NSTAMPS] [-S STAMPS] [-i ITER] [-r REJ] [-m] REF IN OUT\n"
    1010             "where\n"
    1111             "\t-h         Help (this info)\n"
     
    1414             "\t-t T       Threshold for stamps on reference image (0)\n"
    1515             "\t-s S1 S2   Saturation level for reference (S1) and input (S2) (50000)\n"
    16              "\t-b BAD     Bad level for both images (0)\n"
     16             "\t-b B1 B2   Bad level for both images (0)\n"
    1717             "\t-B BG      Level to add to background to get above zero (0)\n"
    1818             "\t-o ORDER   Order of spatial variations in the kernel (0)\n"
    1919             "\t-n NSTAMPS Number of stamps in each dimension (5)\n"
     20             "\t-S STAMPS  File from which to read stamps\n"
     21             "\t-R         Reverse the sense of the subtraction (REF - IN)\n"
    2022             "\t-i ITER    Number of rejection iterations (10)\n"
    2123             "\t-r REJ     Rejection level in standard deviations (2.5)\n"
     24             "\t-m         Output mask frame (OUT.mask)\n"
    2225             "\tREF        Reference image\n"
    2326             "\tIN         Input image (to be matched to REF)\n"
     
    2629}
    2730
    28 poisConfig *restrict poisConfigAlloc(void)
     31poisConfig *poisParseConfig(int argc, // Number of command-line arguments
     32                            char **argv // Command-line arguments
     33    )
    2934{
    30     poisConfig *config = (poisConfig *) psAlloc(sizeof(poisConfig));
     35    poisConfig *config;                 // Configuration values
     36
     37    /* Variables for getopt */
     38    int opt;   /* Option, from getopt */
     39    extern char *optarg;   /* Argument accompanying switch */
     40    extern int optind;   /* getopt variables */
     41
     42    /* Initialise configuration */
     43    config = (poisConfig *) psAlloc(sizeof(poisConfig));
    3144    config->verbose = 0;
    3245    config->refFile = NULL;
     
    3952    config->refSat = 60000.0;
    4053    config->inSat = 60000.0;
    41     config->bad = 0.0;
     54    config->refBad = 0.0;
     55    config->inBad = 0.0;
    4256    config->background = 0.0;
    4357    config->spatialOrder = 0;
     
    4761    config->sigmaRej = 2.5;
    4862    config->penalty = 0.0;
    49 
    50     return config;
    51 }
    52 
    53 
    54 poisConfig *poisParseConfig(int argc, // Number of command-line arguments
    55                             char **argv // Command-line arguments
    56     )
    57 {
    58     poisConfig *config  = poisConfigAlloc(); // Configuration values
    59 
    60     /* Variables for getopt */
    61     int opt;   /* Option, from getopt */
    62     extern char *optarg;   /* Argument accompanying switch */
    63     extern int optind;   /* getopt variables */
    64 
    65     /* Initialise configuration */
     63    config->stampFile = NULL;
     64    config->reverse = false;
     65    config->mask = false;
    6666
    6767    /* Parse command-line arguments using getopt */
    68     while ((opt = getopt(argc, argv, "hvk:f:q:t:s:o:b:B:n:i:r:p:")) != -1) {
     68    while ((opt = getopt(argc, argv, "hvRmk:f:q:t:s:o:b:B:n:i:r:p:S:")) != -1) {
    6969        switch (opt) {
    7070          case 'h':
     
    115115            break;
    116116          case 'b':
    117             if (sscanf(optarg, "%f", &config->bad) != 1) {
    118                 help();
     117            if ((sscanf(argv[optind-1], "%f", &config->refBad) != 1) ||
     118                (sscanf(argv[optind++], "%f", &config->inBad) != 1)) {
     119                /*
     120                  Note: incrementing optind, so I can read more than
     121                  one parameter.
     122                */
     123                help();
    119124                exit(EXIT_FAILURE);
    120             }
     125            }
    121126            break;
    122127          case 'B':
     
    151156            }
    152157            break;
     158          case 'S':
     159            config->stampFile = argv[optind-1];
     160            config->threshold = -INFINITY;
     161            break;
     162          case 'R':
     163            config->reverse = true;
     164            break;
     165          case 'm':
     166            config->mask = true;
     167            break;
    153168          default:
    154169            help();
Note: See TracChangeset for help on using the changeset viewer.