IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 29, 2010, 3:55:49 PM (16 years ago)
Author:
eugene
Message:

update merges from trunk

Location:
branches/eam_branches/20100225
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20100225

  • branches/eam_branches/20100225/psModules/src/objects/pmSourceMatch.c

    r26076 r27517  
    88
    99#include "pmSource.h"
     10#include "pmErrorCodes.h"
    1011
    1112#include "pmSourceMatch.h"
     
    1718#define SOURCES_MAX_LEAF 2              // Maximum number of points on a tree leaf
    1819#define ARRAY_BUFFER 16                 // Buffer for array
    19 
    2020
    2121//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    113113    psFree(match->mag);
    114114    psFree(match->magErr);
     115    psFree(match->x);
     116    psFree(match->y);
    115117    psFree(match->image);
    116118    psFree(match->index);
     119    psFree(match->mask);
    117120}
    118121
     
    180183    for (int i = 0; i < numImages; i++) {
    181184        psArray *sources = sourceArrays->data[i]; // Sources in image
    182         if (!sources) {
     185        if (!sources || sources->n == 0) {
    183186            continue;
    184187        }
     
    270273        psFree(magImage);
    271274        psFree(magErrImage);
    272     }
     275        psFree(indices);
     276    }
     277
     278    psFree(xMaster);
     279    psFree(yMaster);
     280    psFree(boundsMaster);
    273281
    274282    if (cullSingles) {
     
    608616    int numImages = zp->n;              // Number of images
    609617    int numStars = matches->n;          // Number of stars
     618    psVector *badImage = psVectorAlloc(numImages, PS_TYPE_U8); // Bad image?
     619    psVectorInit(badImage, 0);
     620
     621    // Check for data integrity
     622    {
     623        psVector *num = psVectorAlloc(numImages, PS_TYPE_S32); // Number of stars per image
     624        psVectorInit(num, 0);
     625        for (int i = 0; i < numStars; i++) {
     626            pmSourceMatch *match = matches->data[i]; // Matched stars
     627            for (int j = 0; j < match->num; j++) {
     628                int index = match->image->data.U32[j]; // Image index
     629                psAssert(index >= 0 && index < numImages, "Bad index: %d", index);
     630                num->data.S32[index]++;
     631            }
     632        }
     633        int numGood = 0;                // Number of good images
     634        for (int i = 0; i < numImages; i++) {
     635            if (num->data.S32[i] == 0 || !isfinite(zp->data.F32[i])) {
     636                badImage->data.U8[i] = 0xFF;
     637                continue;
     638            }
     639            numGood++;
     640        }
     641        psFree(num);
     642        if (numGood == 0) {
     643            psError(PM_ERR_DATA, true, "No images with good stars.");
     644            psFree(badImage);
     645            return false;
     646        }
     647    }
     648
    610649    psVector *trans = psVectorAlloc(numImages, PS_TYPE_F32); // Transparencies for each image, magnitudes
    611650    psVectorInit(trans, 0.0);
    612651    psVector *photo = psVectorAlloc(numImages, PS_TYPE_U8); // Photometric determination for each image
    613652    psVectorInit(photo, 0);
    614     psVector *badImage = psVectorAlloc(numImages, PS_TYPE_U8); // Bad image?
    615     psVectorInit(badImage, 0);
    616653    psVector *stars = psVectorAlloc(numStars, PS_TYPE_F32); // Magnitudes for each star
    617654
Note: See TracChangeset for help on using the changeset viewer.