IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3813


Ignore:
Timestamp:
Apr 29, 2005, 10:53:49 AM (21 years ago)
Author:
rhl
Message:

Make poisRejectStamps return a list of rejected stamps

Location:
trunk/pois
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/pois/INSTALL

    r3812 r3813  
     1You may have to update
     2    ac_pkg_swig.m4      ac_python_devel.m4 
     3from Pan-STARRS GHQ.
     4
     5-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
     6
    17To build from scratch:
    28
    3 ./autogen.sh --prefix=/Users/rhl/JHB/Tree
     9./autogen.sh --prefix=$HOME/JHB/Tree
    410
    511(or wherever you requested jhbuild to install things)
     12
     13N.b. As configured, autogen requires that a binary "autoconf-2.59" be present,
     14and even if your autoconf is 2.59, that's not good enough.  autogen has a
     15similar problem.  Fix:
     16    perl -pi -e 's/(autoconf|autoheader)-2\.59/$1/' autogen.sh
    617
    718-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  • trunk/pois/NOTES

    r3792 r3813  
    103103
    104104The file src/libpois.a has to exist
     105
     106-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
     107
     108psArray* psArrayAlloc(psU32 nalloc)
     109
     110fails to initialise the array to NULLs (not specified in the SDRS)
     111
     112-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
     113
     114"bool psListAdd(psList *list, int location, void *data);
     115
     116the first function, psListAdd, adds an entry to the list and returns a
     117boolean giving the success or failure of the operation."
     118
     119(SDRS).  It'd be better to define
     120
     121psList *psListAdd(psList *list, int location, void *data);
     122and to make
     123    psListAdd(NULL, location, data);
     124equivalent to
     125    psListAlloc(data);
     126
     127That makes the code to append to a list simpler; instead of
     128
     129     list = NULL;
     130     while(foo) {
     131        ...
     132        foo = psFooAlloc();
     133        if(list == NULL) {
     134           list = psListAlloc(foo);
     135        } else {
     136           bool ok = psListAdd(list, PS_LIST_TAIL, foo);
     137           assert(ok);
     138        }
     139        psFree(foo);
     140     }
     141
     142I can simply write:
     143
     144     list = NULL;
     145     while(foo) {
     146        ...
     147        foo = psFooAlloc();
     148        psListAdd(list, PS_LIST_TAIL, foo);
     149        psFree(foo);
     150     }
     151
     152-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
     153
  • trunk/pois/python/pois.py

    r3811 r3813  
    218218        for s in range(0, stamps.n):
    219219            stamp = pois.poisStamp_Cast(stamps.get_data(s)) # Stamp of interest
    220             if stamp.status == pois.POIS_STAMP_BAD:
    221                 ctype = "red"; dotType = "x"
    222             else:
    223                 ctype = "green"; dotType = "+"
    224                 numStamps += 1
    225 
    226             if display['stamps']:
    227                 ds9.dot(dotType, stamp.x, stamp.y, size = 5, ctype = ctype, frame = 1)
     220            if stamp:
     221                if stamp.status == pois.POIS_STAMP_BAD:
     222                    ctype = "red"; dotType = "x"
     223                else:
     224                    ctype = "green"; dotType = "+"
     225                    numStamps += 1
     226                   
     227                if display['stamps']:
     228                    ds9.dot(dotType, stamp.x, stamp.y, size = 5, ctype = ctype, frame = 1)
    228229
    229230        psTrace("pois.time", 1, ("%d stamps found at %f sec\n" % (numStamps, getTime() - startTime)))
     
    266267                                                       kernelBasisFunctions, solution, config)
    267268        # Have we converged?
    268         if not pois.poisRejectStamps(stamps, mask, deviations, config):
     269        rejected = pois.poisRejectStamps(stamps, mask, deviations, config)
     270
     271        if rejected == None:
    269272            break
    270 
     273       
    271274        if display['stamps']:
    272             for s in range(0, stamps.n):
    273                 stamp = pois.poisStamp_Cast(stamps.get_data(s)) # Stamp of interest
    274                 if stamp.status == pois.POIS_STAMP_RESET:
    275                     ds9.dot("o", stamp.x, stamp.y, size = 5, ctype = "red", frame = 1)
     275            iter = psLib.psListIteratorAlloc(rejected, psLib.PS_LIST_HEAD, False)
     276            while True:
     277                stamp = pois.poisStamp_Cast(psLib.psListGetAndIncrement(iter))
     278                if not stamp:
     279                    break
     280                ds9.dot("o", stamp.x, stamp.y, size = 5, ctype = "red", frame = 1)
    276281
    277282        if display['pause']:
  • trunk/pois/src/pois.c

    r3797 r3813  
    114114
    115115    // Iterate for a good solution
    116     bool badStamps = true;              // Do we have bad stamps, such that we need to continue to iterate?
     116    psList *badStamps = NULL;           // Do we have bad stamps, such that we need to continue to iterate?
    117117    for (int iterNum = 0; iterNum < config->numIter && badStamps; iterNum++) {
    118118        psTrace("pois", 1, "Iteration %d...\n", iterNum);
    119119
     120        psFree(badStamps);              // left over from last iteration
     121       
    120122        // Find stamps
    121123        stamps = poisFindStamps(stamps, refImage, mask, config);
     
    175177    // If there was rejection on the last round, re-solve the equation using only the good stamps
    176178    if (badStamps) {
     179        psFree(badStamps);
    177180        solution = poisSolveEquation(solution, stamps, config);
    178181    }
  • trunk/pois/src/pois.h

    r3807 r3813  
    173173
    174174// Reject stamps, based on the deviations
    175 bool poisRejectStamps(psArray *stamps,  // Array of stamps
    176                       psImage *mask,    // Mask image
    177                       const psVector *deviations, // Vector of deviations for the stamps
    178                       const poisConfig *config // Configuration
     175psList *restrict poisRejectStamps(psArray *stamps,      // Array of stamps
     176                                  psImage *mask,        // Mask image
     177                                  const psVector *deviations, // Vector of deviations for the stamps
     178                                  const poisConfig *config // Configuration
    179179    );
    180180
  • trunk/pois/src/poisFindStamps.c

    r3802 r3813  
    3333    if (stamps == NULL) {
    3434        stamps = psArrayAlloc(nsx * nsy);
    35         // Initialise
     35                                        // Initialise; should be done by psArrayAlloc
    3636        for (int i = 0; i < nsx * nsy; i++) {
    37             stamps->data[i] = poisStampAlloc();
     37            stamps->data[i] = NULL;
    3838        }
    3939    }
     
    4444        for (int j = 0; j < nsy; j++) {
    4545            poisStamp *stamp = stamps->data[num]; // The stamp
     46            if (stamp == NULL) {
     47                stamp = stamps->data[num] = poisStampAlloc();
     48            }
    4649
    4750            // Only find a new stamp if we need to
  • trunk/pois/src/poisRejectStamps.c

    r3803 r3813  
    66#define SQUARE(x) ((x)*(x))
    77
    8 bool poisRejectStamps(psArray *stamps,  // Array of stamps
    9                       psImage *mask,    // Mask image
    10                       const psVector *deviations, // Vector of deviations for the stamps
    11                       const poisConfig *config // Configuration
     8psList *restrict poisRejectStamps(psArray *stamps, // Array of stamps
     9                                  psImage *mask,        // Mask image
     10                                  const psVector *deviations, // Vector of deviations for the stamps
     11                                  const poisConfig *config // Configuration
    1212    )
    1313{
     
    2121    assert(deviations->type.type == PS_TYPE_F32);
    2222
    23     bool masked = false;                // Have we masked any stamps?
    2423    psVector *devMask = psVectorAlloc(stamps->n, PS_TYPE_U8); // Mask for statistics
    2524
     
    3029        poisStamp *stamp = stamps->data[i];     // The stamp
    3130        // Only interested in the stamps that we're actually using
    32         if (stamp->status == POIS_STAMP_USED) {
     31        if (stamp != NULL && stamp->status == POIS_STAMP_USED) {
    3332            meanDev += SQUARE(deviations->data.F32[i]);
    3433            numDev++;
     
    4140
    4241    // Reject stamps
     42    psList *rejected = NULL;            // rejected stamps
    4343    for (int s = 0; s < deviations->n; s++) {
    4444        poisStamp *stamp = stamps->data[s];
     45        if (stamp == NULL) {
     46            continue;
     47        }
     48       
    4549        if (stamp->status == POIS_STAMP_USED && fabsf(deviations->data.F32[s]) > limit) {
    46             masked = true;
    4750            psTrace("pois.rejectStamps", 1, "Rejecting stamp %d (%d,%d): %f\n", s, stamp->x, stamp->y,
    4851                    deviations->data.F32[s]);
     
    5659           
    5760            // Mark stamp for replacement
    58             stamp->status = POIS_STAMP_RESET;
     61            stamps->data[s] = NULL;
     62           
     63            if (rejected == NULL) {
     64                rejected = psListAlloc(stamp);
     65            } else {
     66                bool failed = psListAdd(rejected, PS_LIST_TAIL, stamp);
     67                assert(!failed);
     68            }
     69            psFree(stamp);
    5970        } // Bad stamps
    6071    } // Iterating over stamps
     
    6273    psFree(devMask);
    6374
    64     return masked;
     75    return rejected;
    6576}
  • trunk/pois/swig/poisSwig.i

    r3792 r3813  
    2121NEWOBJECT(poisCalculateDeviations);
    2222NEWOBJECT(poisSolveEquation);
    23 
     23%newobject poisRejectStamps;
    2424NEWOBJECT(poisImageSetVal);
    2525NEWOBJECT(poisImageSetValInMask);
Note: See TracChangeset for help on using the changeset viewer.