IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 13, 2007, 12:07:35 PM (18 years ago)
Author:
Paul Price
Message:

Fixing API of pmReadoutFake to be compatible with current version of ppSub. Will update it once I'm done working on it.

File:
1 edited

Legend:

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

    r15756 r15813  
    2222#include "pmModelUtils.h"
    2323
    24 #define MODEL_TYPE "PS_MODEL_RGAUSS"     // Type of model to use
    25 
    26 
    27 bool pmReadoutFakeFromSources(pmReadout *readout, int numCols, int numRows, const psArray *sources,
    28                               const psVector *xOffset, const psVector *yOffset, pmPSF *psf, float minFlux,
    29                               int radius)
     24#include "pmReadoutFake.h"
     25
     26#define MODEL_TYPE "PS_MODEL_RGAUSS"    // Type of model to use
     27#define MAX_AXIS_RATIO 20.0             // Maximum axis ratio for PSF model
     28
     29
     30#ifdef PAP_WORK
     31// Given an object model, circularise it by setting the axes to be identical
     32static bool circulariseModel(pmModel *model // Model to circularise
     33    )
     34{
     35    assert(model);
     36
     37    psF32 *params = model->params->data.F32; // Model parameters
     38    psEllipseAxes axes = pmPSF_ModelToAxes(params, MAX_AXIS_RATIO); // Ellipse axes
     39    // Curiously, the minor axis can be larger than the major axis, so need to check.
     40    if (axes.major >= axes.minor) {
     41        axes.minor = axes.major;
     42    } else {
     43        axes.major = axes.minor;
     44    }
     45    return pmPSF_AxesToModel(params, axes);
     46}
     47#endif
     48
     49bool pmReadoutFakeFromSources(
     50#ifdef PAP_WORK
     51    pmReadout *readout, int numCols, int numRows, const psArray *sources,
     52    const psVector *xOffset, const psVector *yOffset, pmPSF *psf,
     53    float minFlux, int radius, bool circularise
     54#else
     55    pmReadout *readout, int numCols, int numRows, const psArray *sources,
     56    float fwhm, float minFlux
     57#endif
     58    )
    3059{
    3160    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    3362    PS_ASSERT_INT_LARGER_THAN(numRows, 0, false);
    3463    PS_ASSERT_ARRAY_NON_NULL(sources, false);
     64
     65#ifdef PAP_WORK
    3566    if (xOffset || yOffset) {
    3667        PS_ASSERT_VECTOR_NON_NULL(xOffset, false);
     
    5182        return false;
    5283    }
    53 
     84#endif
    5485
    5586    readout->image = psImageRecycle(readout->image, numCols, numRows, PS_TYPE_F32);
     
    5889    int numSources = sources->n;          // Number of stars
    5990
    60 #if 0
     91#ifndef PAP_WORK
    6192    pmModelType modelType = pmModelClassGetType(MODEL_TYPE); // Type of PSF model
    6293    assert(modelType >= 0);
     
    85116        psAbort("Unsupported model type: %d", modelType);
    86117    }
    87 #endif
    88 
     118#else
    89119    pmModel *fakeModel = pmModelFromPSFforXY(psf, (float)numCols / 2.0, (float)numRows / 2.0,
    90120                                             1.0); // Fake model, with central intensity of 1.0
     121#endif
     122
    91123    float flux0 = fakeModel->modelFlux(fakeModel->params); // Flux for central intensity of 1.0
     124
     125#ifdef PAP_WORK
     126    if (circularise && !circulariseModel(fakeModel)) {
     127        psError(PS_ERR_UNKNOWN, false, "Unable to circularise PSF model.");
     128        psFree(fakeModel);
     129        return false;
     130    }
     131    psFree(fakeModel);
     132#endif
    92133
    93134    for (int i = 0; i < numSources; i++) {
     
    105146        }
    106147
     148#ifdef PAP_WORK
     149        pmModel *fakeModel = pmModelFromPSFforXY(psf, x, y, powf(10.0, -0.4 * source->psfMag) / flux0);
     150        if (!fakeModel) {
     151            psError(PS_ERR_UNKNOWN, false, "Unable to generate model for source %d (%.1f,%.1f)", i, x, y);
     152            return false;
     153        }
     154        if (circularise && !circulariseModel(fakeModel)) {
     155            psError(PS_ERR_UNKNOWN, false, "Unable to circularise PSF model.");
     156            psFree(fakeModel);
     157            return false;
     158        }
     159#else
     160        fakeModel->params->data.F32[PM_PAR_I0] = powf(10.0, -0.4 * source->psfMag) / flux0;
    107161        fakeModel->params->data.F32[PM_PAR_XPOS] = x;
    108162        fakeModel->params->data.F32[PM_PAR_YPOS] = y;
    109         fakeModel->params->data.F32[PM_PAR_I0] = powf(10.0, -0.4 * source->psfMag) / flux0;
     163#endif
    110164
    111165        psTrace("psModules.camera", 10, "Adding source at %f,%f with flux %f\n",
     
    115169        pmSource *fakeSource = pmSourceAlloc(); // Fake source to generate
    116170        fakeSource->peak = pmPeakAlloc(x, y, fakeModel->params->data.F32[PM_PAR_I0], PM_PEAK_LONE);
    117         float fakeRadius = radius > 0 ? radius : fakeModel->modelRadius(fakeModel->params, minFlux); // Radius
    118 
     171        float fakeRadius =
     172#ifdef PAP_WORK
     173            radius > 0 ? radius :
     174#endif
     175            fakeModel->modelRadius(fakeModel->params, minFlux); // Radius
     176
     177#ifdef PAP_WORK
    119178        if (xOffset) {
    120179            if (!pmSourceDefinePixels(fakeSource, readout, x + xOffset->data.S32[i],
     
    132191                return false;
    133192            }
    134         } else {
     193        } else
     194#endif
     195        {
    135196            if (!pmSourceDefinePixels(fakeSource, readout, x, y, fakeRadius)) {
    136197                psError(PS_ERR_UNKNOWN, false, "Unable to define pixels for source.");
     
    147208        }
    148209        psFree(fakeSource);
    149     }
    150 
    151     psFree(fakeModel);
     210#ifdef PAP_WORK
     211        psFree(fakeModel);
     212#endif
     213    }
    152214
    153215    return true;
Note: See TracChangeset for help on using the changeset viewer.