IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 4, 2005, 11:37:01 AM (21 years ago)
Author:
Paul Price
Message:

Updated to psLib rel5alpha1

File:
1 edited

Legend:

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

    r2783 r3375  
    11#include <stdio.h>
     2#include <assert.h>
    23#include <math.h>
    34#include "pslib.h"
     
    1516    // Would like to use psVectorStats, but it doesn't have errors built in yet
    1617    psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
    17     (void)psVectorStats(stats, values, masks, 1);
     18    (void)psVectorStats(stats, values, NULL, masks, 1);
    1819    float mean = stats->sampleMean;
    1920    psFree(stats);
     
    4748{
    4849    psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
    49     (void)psVectorStats(stats, values, masks, 1);
     50    (void)psVectorStats(stats, values, NULL, masks, 1);
    5051    float median = stats->sampleMedian;
    5152    psFree(stats);
     
    7677        psImage *error = (psImage *)errors->data[i]; // The error image
    7778
    78         if ((image->numCols != numCols) || (image->numRows != numRows)) {
    79             psError("stac.combine",
    80                     "Image size mismatch on error image %d\nExpected %dx%d, got %dx%d\n",
    81                     i, numCols, numRows, image->numCols, image->numRows);
    82             return false;
    83         }
    84         if ((error->numCols != numCols) || (error->numRows != numRows)) {
    85             psError("stac.combine",
    86                     "Image size mismatch on error image %d\nExpected %dx%d, got %dx%d\n",
    87                     i, numCols, numRows, error->numCols, error->numRows);
    88             return false;
    89         }
     79        assert(image->numCols == numCols && image->numRows == numRows);
     80        assert(error->numCols == numCols && error->numRows == numRows);
    9081    }
    9182
    9283    // Check combined image
     84    assert(!*combined || ((*combined)->numRows == numRows) && ((*combined)->numCols == numCols));
    9385    if (*combined == NULL) {
    9486        *combined = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Combined image
    95     } else if (((*combined)->numRows != numRows) || ((*combined)->numCols != numCols)) {
    96         psError("stac.combine", "Size of combined image (%dx%d) does not match inputs (%dx%d)\n",
    97                 (*combined)->numCols, (*combined)->numRows, numCols, numRows);
    98         return false;
    9987    }
    10088
    10189    // Check area of interest
    102     if (region && ((region->numRows != numRows) || (region->numCols != numCols))) {
    103         psError("stac.combine", "Size of area of interest (%dx%d) does not match inputs (%dx%d)\n",
    104                 region->numCols, region->numRows, numCols, numRows);
    105         return false;
    106     }
     90    assert(!region || (region->numRows == numRows) && (region->numCols == numCols));
    10791
    10892    psTrace("stac.combine", 1, "Combining images....\n");
     
    117101            // Allocate the rejection masks, if required
    118102            *rejected = psArrayAlloc(nImages);
    119         } else if ((*rejected)->n != nImages) {
    120             psError("stac.combine", "Number of rejection masks (%d) does not match number of input"
    121                     "images (%d).\n", (*rejected)->n, nImages);
    122             return NULL;
     103        } else {
     104            assert((*rejected)->n != nImages);
    123105        }
    124106
     
    208190    if (nReject > 0) {
    209191        for (int i = 0; i < nImages; i++) {
    210             char rejfile[MAXCHAR];      // Filename of rejection image
    211             sprintf(rejfile,"%s.shiftrej",config->inputs->data[i]);
    212             psImageWriteSection((psImage*)((*rejected)->data[i]),0,0,0,NULL,0,rejfile);
     192            char rejName[MAXCHAR];      // Filename of rejection image
     193            sprintf(rejName,"%s.shiftrej",config->inputs->data[i]);
     194
     195            psFits *rejFile = psFitsAlloc(rejName);
     196            if (!psFitsWriteImage(rejFile, NULL, (*rejected)->data[i], 0, NULL)) {
     197                psErrorStackPrint(stderr, "Unable to write image: %s\n", rejName);
     198            }
     199            psTrace("stac", 1, "Rejection image written to %s\n", rejName);
     200            psFree(rejFile);
    213201        }
    214202    }
    215203    // Write chi^2 image
    216204    iteration++;
    217     char chifile[MAXCHAR];              // Filename of chi^2 image
    218     sprintf(chifile,"chi2_%d.fits",iteration);
    219     psImageWriteSection(chi2,0,0,0,NULL,0,chifile);
     205    char chiName[MAXCHAR];              // Filename of chi^2 image
     206    sprintf(chiName,"chi2_%d.fits",iteration);
     207    psFits *chiFile = psFitsAlloc(chiName);
     208    if (!psFitsWriteImage(chiFile, NULL, chi2 , 0, NULL)) {
     209        psErrorStackPrint(stderr, "Unable to write image: %s\n", chiName);
     210    }
     211    psTrace("stac", 1, "Chi^2 image written to %s\n", chiName);
     212    psFree(chiFile);
    220213    psFree(chi2);
    221214#endif
Note: See TracChangeset for help on using the changeset viewer.