IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 6, 2007, 3:57:15 PM (19 years ago)
Author:
Paul Price
Message:

Implementing dual-convolution. This required reworking those
functions involved with calculating and solving the equations; moved
these into a separate file and made various other cleanups (e.g.,
assertions for pmSubtractionKernels). Removed the normalisation
(central pixel) term from all kernels, because this shouldn't be in
the second kernel (there's only one normalisation term between the two
kernels); the normalisation is treated explicitly in the equations,
along with the background (still only a constant background is
supported for now, but there's a lot of support for a polynomial
background for when I get around to putting it in the equations).
Tested the single convolution, and it's working; same results as
before, apparently. Haven't tested dual convolution yet.

Location:
trunk/psModules/src/camera
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmReadoutFake.c

    r15424 r15756  
    2020#include "pmSource.h"
    2121#include "pmSourceUtils.h"
     22#include "pmModelUtils.h"
    2223
    2324#define MODEL_TYPE "PS_MODEL_RGAUSS"     // Type of model to use
    2425
    2526
    26 pmReadout *pmReadoutFakeFromSources(int numCols, int numRows, const psArray *sources,
    27                                     float fwhm, float minFlux)
     27bool pmReadoutFakeFromSources(pmReadout *readout, int numCols, int numRows, const psArray *sources,
     28                              const psVector *xOffset, const psVector *yOffset, pmPSF *psf, float minFlux,
     29                              int radius)
    2830{
    29     PS_ASSERT_INT_LARGER_THAN(numCols, 0, NULL);
    30     PS_ASSERT_INT_LARGER_THAN(numRows, 0, NULL);
    31     PS_ASSERT_ARRAY_NON_NULL(sources, NULL);
    32     PS_ASSERT_FLOAT_LARGER_THAN(fwhm, 0.0, NULL);
    33     PS_ASSERT_FLOAT_LARGER_THAN(minFlux, 0.0, NULL);
     31    PS_ASSERT_PTR_NON_NULL(readout, false);
     32    PS_ASSERT_INT_LARGER_THAN(numCols, 0, false);
     33    PS_ASSERT_INT_LARGER_THAN(numRows, 0, false);
     34    PS_ASSERT_ARRAY_NON_NULL(sources, false);
     35    if (xOffset || yOffset) {
     36        PS_ASSERT_VECTOR_NON_NULL(xOffset, false);
     37        PS_ASSERT_VECTOR_NON_NULL(yOffset, false);
     38        PS_ASSERT_VECTORS_SIZE_EQUAL(xOffset, yOffset, false);
     39        PS_ASSERT_VECTOR_TYPE(xOffset, PS_TYPE_S32, false);
     40        PS_ASSERT_VECTOR_TYPE_EQUAL(xOffset, yOffset, false);
     41        if (xOffset->n != sources->n) {
     42            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     43                    "Number of offset vectors (%ld) and sources (%ld) doesn't match",
     44                    xOffset->n, sources->n);
     45            return false;
     46        }
     47    }
     48    PS_ASSERT_PTR_NON_NULL(psf, false);
     49    if (radius > 0 && isfinite(minFlux) && minFlux > 0.0) {
     50        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Cannot define both minimum flux and fixed radius.");
     51        return false;
     52    }
    3453
    35     pmReadout *readout = pmReadoutAlloc(NULL); // Output readout
    36     readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
     54
     55    readout->image = psImageRecycle(readout->image, numCols, numRows, PS_TYPE_F32);
    3756    psImageInit(readout->image, 0);
    3857
    3958    int numSources = sources->n;          // Number of stars
    4059
     60#if 0
    4161    pmModelType modelType = pmModelClassGetType(MODEL_TYPE); // Type of PSF model
    4262    assert(modelType >= 0);
     
    6585        psAbort("Unsupported model type: %d", modelType);
    6686    }
     87#endif
    6788
     89    pmModel *fakeModel = pmModelFromPSFforXY(psf, (float)numCols / 2.0, (float)numRows / 2.0,
     90                                             1.0); // Fake model, with central intensity of 1.0
    6891    float flux0 = fakeModel->modelFlux(fakeModel->params); // Flux for central intensity of 1.0
    69 
    7092
    7193    for (int i = 0; i < numSources; i++) {
     
    93115        pmSource *fakeSource = pmSourceAlloc(); // Fake source to generate
    94116        fakeSource->peak = pmPeakAlloc(x, y, fakeModel->params->data.F32[PM_PAR_I0], PM_PEAK_LONE);
    95         float radius = fakeModel->modelRadius(fakeModel->params, minFlux); // Radius of interest for source
     117        float fakeRadius = radius > 0 ? radius : fakeModel->modelRadius(fakeModel->params, minFlux); // Radius
    96118
    97         if (!pmSourceDefinePixels(fakeSource, readout, x, y, radius)) {
    98             psError(PS_ERR_UNKNOWN, false, "Unable to define pixels for source.");
    99             psFree(readout);
    100             psFree(fakeModel);
    101             return NULL;
    102         }
    103 
    104         if (!pmModelAdd(fakeSource->pixels, NULL, fakeModel, PM_MODEL_OP_FULL, 0)) {
    105             psError(PS_ERR_UNKNOWN, false, "Unable to add model of source to image.");
    106             psFree(readout);
    107             psFree(fakeModel);
    108             return NULL;
     119        if (xOffset) {
     120            if (!pmSourceDefinePixels(fakeSource, readout, x + xOffset->data.S32[i],
     121                                      y + yOffset->data.S32[i], fakeRadius)) {
     122                psError(PS_ERR_UNKNOWN, false, "Unable to define pixels for source.");
     123                psFree(readout);
     124                psFree(fakeModel);
     125                return false;
     126            }
     127            if (!pmModelAddWithOffset(fakeSource->pixels, NULL, fakeModel, PM_MODEL_OP_FULL, 0,
     128                                      - xOffset->data.S32[i], - yOffset->data.S32[i])) {
     129                psError(PS_ERR_UNKNOWN, false, "Unable to add model of source to image.");
     130                psFree(readout);
     131                psFree(fakeModel);
     132                return false;
     133            }
     134        } else {
     135            if (!pmSourceDefinePixels(fakeSource, readout, x, y, fakeRadius)) {
     136                psError(PS_ERR_UNKNOWN, false, "Unable to define pixels for source.");
     137                psFree(readout);
     138                psFree(fakeModel);
     139                return false;
     140            }
     141            if (!pmModelAdd(fakeSource->pixels, NULL, fakeModel, PM_MODEL_OP_FULL, 0)) {
     142                psError(PS_ERR_UNKNOWN, false, "Unable to add model of source to image.");
     143                psFree(readout);
     144                psFree(fakeModel);
     145                return false;
     146            }
    109147        }
    110148        psFree(fakeSource);
     
    113151    psFree(fakeModel);
    114152
    115     return readout;
     153    return true;
    116154}
  • trunk/psModules/src/camera/pmReadoutFake.h

    r15362 r15756  
    66#include <pmFPA.h>
    77
    8 // Generate a fake readout from an array of sources
    9 pmReadout *pmReadoutFakeFromSources(int numCols, int numRows, ///< Dimension of image
    10                                     const psArray *sources, ///< Array of pmSource
    11                                     float fwhm, ///< FWHM for sources
    12                                     float minFlux ///< Minimum flux to bother about; for setting object size
     8#include <pmMoments.h>
     9#include <pmResiduals.h>
     10#include <pmGrowthCurve.h>
     11#include <pmTrend2D.h>
     12#include <pmPSF.h>
     13
     14
     15/// Generate a fake readout from an array of sources
     16bool pmReadoutFakeFromSources(pmReadout *readout, ///< Output readout, or NULL
     17                              int numCols, int numRows, ///< Dimension of image
     18                              const psArray *sources, ///< Array of pmSource
     19                              const psVector *xOffset, ///< x offsets for sources (source -> img), or NULL
     20                              const psVector *yOffset, ///< y offsets for sources (source -> img), or NULL
     21                              pmPSF *psf, ///< PSF for sources
     22                              float minFlux, ///< Minimum flux to bother about; for setting source radius
     23                              int radius ///< Fixed radius for sources
    1324    );
    1425
    15 
    16 
    17 
    1826#endif
Note: See TracChangeset for help on using the changeset viewer.