IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 31, 2005, 5:07:12 PM (21 years ago)
Author:
Paul Price
Message:

Working very nicely now.

File:
1 edited

Legend:

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

    r3387 r3610  
    99{
    1010    fprintf (stderr, "STAC: Simultaneous Telescope Array Combination\n"
    11              "Usage: %s [-h] [-v] [-g GAIN] [-r RN] [-o NX NY] [-s SAT] [-b BAD] [-k REJ] [-n NREJECT] [-k FRAC] [-G GRAD] OUT IN1 IN2...\n"
     11             "Usage: %s [-h] [-v] [-g GAIN] [-r RN] [-o NX NY] [-S] [-s SAT] [-b BAD] [-p FILE MAP] [-a APER] [-k REJ] [-n NREJECT] [-k FRAC] [-G GRAD] OUT IN1 IN2...\n"
    1212             "where\n"
    1313             "\t-h           Help (this info)\n"
     
    1616             "\t-r           Read noise (e) for detectors\n"
    1717             "\t-o NX NY     Size of output image (512, 512)\n"
    18              "\t-s SAT       Saturation level (65536)\n"
     18             "\t-S           Save shifted images (false)\n"
     19             "\t-s SAT       Saturation level (65535)\n"
    1920             "\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 size to use for photometry (3 pix)\n"
    2023             "\t-k REJ       Rejection level (k-sigma; 3.5)\n"
    2124             "\t-n NREJECT   Number of rejection iterations (2)\n"
     
    3942    config->inputs = NULL;
    4043    config->output = NULL;
     44    config->saveShifts = false;
     45    config->starFile = NULL;
     46    config->starMapFile = NULL;
     47    config->aper = 3.0;
    4148    config->outnx = 512;
    4249    config->outny = 512;
    43     config->saturated = 65535.0;
    44     config->bad = 0.0;
     50    config->saturated = NULL;           // Saturations; will fill this in later, when we know how many images
     51    config->bad = NULL;                 // Bad levels; will fill this in later, when we know how many images
    4552    config->reject = 3.0;
    4653    config->frac = 0.5;
     
    5461void stacConfigFree(stacConfig *config)
    5562{
    56     // Free the vector, if necessary
     63    // Free the vectors, if necessary
    5764    if (config->inputs) {
    5865        psFree(config->inputs);
     66    }
     67    if (config->saturated) {
     68        psFree(config->saturated);
     69    }
     70    if (config->bad) {
     71        psFree(config->bad);
    5972    }
    6073    // Free everything
     
    6982    stacConfig *config = stacConfigAlloc(); // Configuration values
    7083    const char *programName = argv[0];  // Program name
     84
     85    float saturated = 65535.0;          // Saturation level
     86    float bad = 0.0;                    // Bad level
    7187
    7288    /* Variables for getopt */
     
    7692
    7793    /* Parse command-line arguments using getopt */
    78     while ((opt = getopt(argc, argv, "hvg:r:o:s:b:k:n:f:G:")) != -1) {
     94    while ((opt = getopt(argc, argv, "hvSg:r:o:s:b:k:n:f:G:p:a:")) != -1) {
    7995        switch (opt) {
    8096          case 'h':
     
    87103            if (sscanf(optarg, "%f", &config->gain) != 1) {
    88104                help(programName);
     105                exit(EXIT_FAILURE);
    89106            }
    90107            break;
     
    92109            if (sscanf(optarg, "%f", &config->readnoise) != 1) {
    93110                help(programName);
     111                exit(EXIT_FAILURE);
    94112            }
    95113            break;
     
    97115            if ((sscanf(argv[optind-1], "%d", &config->outnx) != 1) ||
    98116                (sscanf(argv[optind++], "%d", &config->outny) != 1)) {
    99                 /*
    100                   Note: incrementing optind, so I can read more than
    101                   one parameter.
    102                 */
     117                // Note: incrementing optind, so I can read more than one parameter.
    103118                help(programName);
    104119                exit(EXIT_FAILURE);
     
    106121            break;
    107122          case 's':
    108             if (sscanf(optarg, "%f", &config->saturated) != 1) {
    109                 help(programName);
     123            if (sscanf(optarg, "%f", &saturated) != 1) {
     124                help(programName);
     125                exit(EXIT_FAILURE);
    110126            }
    111127            break;
    112128          case 'b':
    113             if (sscanf(optarg, "%f", &config->bad) != 1) {
    114                 help(programName);
     129            if (sscanf(optarg, "%f", &bad) != 1) {
     130                help(programName);
     131                exit(EXIT_FAILURE);
     132            }
     133            break;
     134          case 'p':
     135            if (argc < optind+1) {
     136                help(programName);
     137                exit(EXIT_FAILURE);
     138            }
     139            config->starFile = argv[optind-1];
     140            config->starMapFile = argv[optind++];
     141            // Note: incrementing optind, so I can read more than one parameter.
     142            break;
     143          case 'a':
     144            if (sscanf(optarg, "%f", &config->aper) != 1) {
     145                help(programName);
     146                exit(EXIT_FAILURE);
    115147            }
    116148            break;
     
    118150            if (sscanf(optarg, "%f", &config->reject) != 1) {
    119151                help(programName);
     152                exit(EXIT_FAILURE);
    120153            }
    121154            break;
     
    123156            if (sscanf(optarg, "%d", &config->nReject) != 1) {
    124157                help(programName);
     158                exit(EXIT_FAILURE);
    125159            }
    126160            break;
     
    128162            if (sscanf(optarg, "%f", &config->frac) != 1) {
    129163                help(programName);
     164                exit(EXIT_FAILURE);
    130165            }
    131166            break;
     
    133168            if (sscanf(optarg, "%f", &config->grad) != 1) {
    134169                help(programName);
    135             }
     170                exit(EXIT_FAILURE);
     171            }
     172            break;
     173          case 'S':
     174            config->saveShifts = true;
    136175            break;
    137176          default:
     
    156195    }
    157196
     197    // Create the saturation and bad vectors
     198    config->saturated = psVectorAlloc(argc-1, PS_TYPE_F32);
     199    config->bad = psVectorAlloc(argc-1, PS_TYPE_F32);
     200    for (int i = 0; i < argc - 1; i++) {
     201        ((psVector*)config->saturated)->data.F32[i] = saturated;
     202        ((psVector*)config->bad)->data.F32[i] = bad;
     203    }
     204
    158205    // Debugging output
    159206    psTrace("stac.config", 8, "Parsed command line for configuration\n");
Note: See TracChangeset for help on using the changeset viewer.