IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 18, 2006, 12:20:45 PM (20 years ago)
Author:
Paul Price
Message:

Updating to use psLib rel11. Main problem was that vector and array lengths ('n' element) are no longer set to equal the number of allocated values ('nalloc' element) when allocated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/stac/src/combineConfig.c

    r3680 r6887  
    1111{
    1212    fprintf (stderr, "shift: shift an image, given the transformation\n"
    13              "Usage: %s [-h] [-v] [-g GAIN] [-r READNOISE] [-s SAT] [-b BAD] [-p FILE MAP] [-a APER] [-k SIGMAREJ] [-n NREJECT] OUT IN1 IN2...\n"
    14              "where\n"
    15              "\t-h           Help (this info)\n"
    16              "\t-v           Increase verbosity level\n"
    17              "\t-g GAIN      Gain in e/ADU (1.0)\n"
    18              "\t-r READNOISE Read noise in e (0.0)\n"
    19              "\t-s SAT       Saturation point (65535)\n"
    20              "\t-b BAD       Bad level (0)\n"
    21              "\t-p FILE MAP  Specify file containing star coordinates, with map\n"
    22              "\t-a APER      Aperture radius for photometry (3.0)\n"
    23              "\t-k SIGMAREJ  k-sigma rejection threshold (3.0)\n"
    24              "\t-n NREJECT   Number of rejection iterations (1)\n"
    25              "\tOUT          Output image\n"
    26              "\tIN1 IN2...   Input images (identical size)\n",
    27              programName
    28         );
     13             "Usage: %s [-h] [-v] [-g GAIN] [-r READNOISE] [-s SAT] [-b BAD] [-p FILE MAP] [-a APER] [-k SIGMAREJ] [-n NREJECT] OUT IN1 IN2...\n"
     14             "where\n"
     15             "\t-h           Help (this info)\n"
     16             "\t-v           Increase verbosity level\n"
     17             "\t-g GAIN      Gain in e/ADU (1.0)\n"
     18             "\t-r READNOISE Read noise in e (0.0)\n"
     19             "\t-s SAT       Saturation point (65535)\n"
     20             "\t-b BAD       Bad level (0)\n"
     21             "\t-p FILE MAP  Specify file containing star coordinates, with map\n"
     22             "\t-a APER      Aperture radius for photometry (3.0)\n"
     23             "\t-k SIGMAREJ  k-sigma rejection threshold (3.0)\n"
     24             "\t-n NREJECT   Number of rejection iterations (1)\n"
     25             "\tOUT          Output image\n"
     26             "\tIN1 IN2...   Input images (identical size)\n",
     27             programName
     28        );
    2929}
    3030
     
    3535
    3636    // Parameters with default values
    37     config->verbose = 0;                // Verbosity level
    38     config->gain = 1.0;                 // Gain (e/ADU)
    39     config->readnoise = 0.0;            // Read noise (e)
    40     config->reject = 4.0;               // Rejection threshold (sigma)
    41     config->nReject = 1;                // Number of rejection iterations
    42     config->saturated = 65535.0;        // Saturation level
    43     config->bad = 0.0;                  // Bad level
    44     config->outName = NULL;             // Output name
    45     config->inNames = NULL;             // Input names;
    46     config->starFile = NULL;            // Filename of file containing stars
    47     config->starMap = NULL;             // Map for stars
    48     config->aper = 3.0;                 // Aperture for photometry
     37    config->verbose = 0;                // Verbosity level
     38    config->gain = 1.0;                 // Gain (e/ADU)
     39    config->readnoise = 0.0;            // Read noise (e)
     40    config->reject = 4.0;               // Rejection threshold (sigma)
     41    config->nReject = 1;                // Number of rejection iterations
     42    config->saturated = 65535.0;        // Saturation level
     43    config->bad = 0.0;                  // Bad level
     44    config->outName = NULL;             // Output name
     45    config->inNames = NULL;             // Input names;
     46    config->starFile = NULL;            // Filename of file containing stars
     47    config->starMap = NULL;             // Map for stars
     48    config->aper = 3.0;                 // Aperture for photometry
    4949
    5050    return config;
     
    6262    combineConfig *config = combineConfigAlloc(); // Configuration
    6363
    64     const char *programName = argv[0];  // Program name
     64    const char *programName = argv[0];  // Program name
    6565
    6666    /* Variables for getopt */
     
    7272    while ((opt = getopt(argc, argv, "hvg:r:s:b:p:a:k:n:")) != -1) {
    7373        switch (opt) {
    74           case 'h':
    75             help(programName);
    76             exit(EXIT_SUCCESS);
    77           case 'v':
     74          case 'h':
     75            help(programName);
     76            exit(EXIT_SUCCESS);
     77          case 'v':
    7878            config->verbose++;
    7979            break;
    80           case 'r':
     80          case 'r':
    8181            if (sscanf(optarg, "%f", &config->readnoise) != 1) {
    82                 printf("Unable to read readnoise.\n");
    83                 help(programName);
    84                 exit(EXIT_FAILURE);
    85             }
    86             break;
    87           case 'g':
    88             if (sscanf(optarg, "%f", &config->gain) != 1) {
    89                 printf("Unable to read gain.\n");
    90                 help(programName);
    91                 exit(EXIT_FAILURE);
    92             }
    93             break;
    94           case 's':
    95             if (sscanf(optarg, "%f", &config->saturated) != 1) {
    96                 printf("Unable to read saturation limit.\n");
    97                 help(programName);
    98                 exit(EXIT_FAILURE);
    99             }
    100             break;
    101           case 'b':
    102             if (sscanf(optarg, "%f", &config->bad) != 1) {
    103                 printf("Unable to read bad limit.\n");
    104                 help(programName);
    105                 exit(EXIT_FAILURE);
    106             }
    107             break;
    108           case 'p':
    109             if (argc < optind+1) {
    110                 printf("Unable to read photometric files.\n");
    111                 help(programName);
    112                 exit(EXIT_FAILURE);
    113             }
    114             config->starFile = argv[optind-1];
    115             config->starMap = argv[optind++];
    116             // Note: incrementing optind, so I can read more than one parameter.
    117             break;
    118           case 'a':
    119             if (sscanf(optarg, "%f", &config->aper) != 1) {
    120                 printf("Unable to read aperture.\n");
     82                printf("Unable to read readnoise.\n");
    12183                help(programName);
    12284                exit(EXIT_FAILURE);
    12385            }
    124             break;
    125           case 'k':
    126             if (sscanf(optarg, "%f", &config->reject) != 1) {
    127                 printf("Unable to read rejection limit.\n");
     86            break;
     87          case 'g':
     88            if (sscanf(optarg, "%f", &config->gain) != 1) {
     89                printf("Unable to read gain.\n");
    12890                help(programName);
    12991                exit(EXIT_FAILURE);
    13092            }
    131             break;
    132           case 'n':
    133             if (sscanf(optarg, "%d", &config->nReject) != 1) {
    134                 printf("Unable to read number of rejection iterations.\n");
    135                 help(programName);
     93            break;
     94          case 's':
     95            if (sscanf(optarg, "%f", &config->saturated) != 1) {
     96                printf("Unable to read saturation limit.\n");
     97                help(programName);
    13698                exit(EXIT_FAILURE);
    13799            }
    138             break;
    139           default:
    140             printf("Bad option: %c\n", opt);
    141             help(programName);
    142             exit(EXIT_FAILURE);
    143         }
     100            break;
     101          case 'b':
     102            if (sscanf(optarg, "%f", &config->bad) != 1) {
     103                printf("Unable to read bad limit.\n");
     104                help(programName);
     105                exit(EXIT_FAILURE);
     106            }
     107            break;
     108          case 'p':
     109            if (argc < optind+1) {
     110                printf("Unable to read photometric files.\n");
     111                help(programName);
     112                exit(EXIT_FAILURE);
     113            }
     114            config->starFile = argv[optind-1];
     115            config->starMap = argv[optind++];
     116            // Note: incrementing optind, so I can read more than one parameter.
     117            break;
     118          case 'a':
     119            if (sscanf(optarg, "%f", &config->aper) != 1) {
     120                printf("Unable to read aperture.\n");
     121                help(programName);
     122                exit(EXIT_FAILURE);
     123            }
     124            break;
     125          case 'k':
     126            if (sscanf(optarg, "%f", &config->reject) != 1) {
     127                printf("Unable to read rejection limit.\n");
     128                help(programName);
     129                exit(EXIT_FAILURE);
     130            }
     131            break;
     132          case 'n':
     133            if (sscanf(optarg, "%d", &config->nReject) != 1) {
     134                printf("Unable to read number of rejection iterations.\n");
     135                help(programName);
     136                exit(EXIT_FAILURE);
     137            }
     138            break;
     139          default:
     140            printf("Bad option: %c\n", opt);
     141            help(programName);
     142            exit(EXIT_FAILURE);
     143        }
    144144    }
    145145
     
    151151        exit(EXIT_FAILURE);
    152152    }
    153     config->outName = argv[0];          // Output filename
     153    config->outName = argv[0];          // Output filename
    154154    config->inNames = psArrayAlloc(argc-1); // Input filenames
     155    config->inNames->n = argc-1;
    155156    for (int i = 1; i < argc; i++) {
    156         config->inNames->data[i-1] = psAlloc(strlen(argv[i]));
    157         strncpy(config->inNames->data[i-1], argv[i], strlen(argv[i]));
     157        config->inNames->data[i-1] = psAlloc(strlen(argv[i]));
     158        strncpy(config->inNames->data[i-1], argv[i], strlen(argv[i]));
    158159    }
    159160
Note: See TracChangeset for help on using the changeset viewer.