IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 7, 2005, 2:57:14 PM (20 years ago)
Author:
Paul Price
Message:

Importing from PAP cvs tree again. This will now be the working tree.

File:
1 edited

Legend:

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

    r3681 r5743  
    2121    combineConfig *config = combineParseConfig(argc, argv); // Configuration
    2222
    23     psArray *images = stacReadImages(config->inNames); // The images
     23    psArray *headers = NULL;            // Array of headers
     24    psArray *images = stacReadImages(&headers, config->inNames); // The images
    2425    // Make fake errors
    2526    psArray *errors = psArrayAlloc(images->n);
    2627    for (int i = 0; i < images->n; i++) {
    27         psImage *image = images->data[i];
    28         psImage *err = psImageAlloc(image->numCols, image->numRows, PS_TYPE_F32);
    29         for (int y = 0; y < image->numRows; y++) {
    30             for (int x = 0; x < image->numCols; x++) {
    31                 err->data.F32[y][x] = 1.0;
    32             }
    33         }
    34         errors->data[i] = err;
     28        psImage *image = images->data[i];
     29        psImage *err = psImageAlloc(image->numCols, image->numRows, PS_TYPE_F32);
     30        for (int y = 0; y < image->numRows; y++) {
     31            for (int x = 0; x < image->numCols; x++) {
     32                err->data.F32[y][x] = 1.0;
     33            }
     34        }
     35        errors->data[i] = err;
    3536    }
    3637
    3738    // Calculate scales between images
    38     psVector *scales = NULL;            // Relative scales between images
    39     psVector *offsets = NULL;           // Offsets between images
     39    psVector *scales = NULL;            // Relative scales between images
     40    psVector *offsets = NULL;           // Offsets between images
    4041    (void)stacScales(&scales, &offsets, images, config->starFile, config->starMap, 0.0, 0.0, config->aper);
    4142
     
    4445    psVector *bad = psVectorAlloc(images->n, PS_TYPE_F32); // Bad limits
    4546    for (int i = 0; i < images->n; i++) {
    46         saturated->data.F32[i] = (config->saturated - offsets->data.F32[i]) / scales->data.F32[i];
    47         bad->data.F32[i] = (config->bad - offsets->data.F32[i]) / scales->data.F32[i];
     47        saturated->data.F32[i] = (config->saturated - offsets->data.F32[i]) / scales->data.F32[i];
     48        bad->data.F32[i] = (config->bad - offsets->data.F32[i]) / scales->data.F32[i];
    4849    }
    4950
     
    5253
    5354    // Combine the images
    54     psImage *combined = NULL;           // Combined image
    55     psArray *rejected = NULL;           // Array of rejection masks
     55    psImage *combined = NULL;           // Combined image
     56    psArray *rejected = NULL;           // Array of rejection masks
    5657    stacCombine(&combined, &rejected, images, errors, config->nReject, NULL, saturated, bad, config->reject);
    5758
    58     psFits *outFile = psFitsAlloc(config->outName);
    59     if (!psFitsWriteImage(outFile, NULL, combined, 0, NULL)) {
    60         psErrorStackPrint(stderr, "Unable to write image: %s\n", config->outName);
     59    psFits *outFile = psFitsOpen(config->outName, "r");
     60    if (!psFitsWriteImage(outFile, headers->data[0], combined, 0)) {
     61        psErrorStackPrint(stderr, "Unable to write image: %s\n", config->outName);
    6162    }
    6263    psTrace("combine", 1, "Combined image written to %s\n", config->outName);
    63     psFree(outFile);
     64    psFitsClose(outFile);
    6465
    6566    // Clean up
     67    psFree(headers);
    6668    psFree(combined);
    6769    psFree(rejected);
Note: See TracChangeset for help on using the changeset viewer.