IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15838


Ignore:
Timestamp:
Dec 14, 2007, 3:12:29 PM (18 years ago)
Author:
Paul Price
Message:

Converting to new API. Removing all traces of old system.

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

Legend:

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

    r15815 r15838  
    2828
    2929
    30 #ifdef PAP_WORK
    3130// Given an object model, circularise it by setting the axes to be identical
    3231static bool circulariseModel(pmModel *model // Model to circularise
     
    4544    return pmPSF_AxesToModel(params, axes);
    4645}
    47 #endif
    4846
    49 #ifdef PAP_WORK
    5047bool pmReadoutFakeFromSources(pmReadout *readout, int numCols, int numRows, const psArray *sources,
    51                               const psVector *xOffset, const psVector *yOffset, pmPSF *psf,
     48                              const psVector *xOffset, const psVector *yOffset, const pmPSF *psf,
    5249                              float minFlux, int radius, bool circularise)
    53 #else
    54 pmReadout *pmReadoutFakeFromSources(int numCols, int numRows, const psArray *sources,
    55                                     float fwhm, float minFlux)
    56 #endif
    5750{
    58 #ifdef PAP_WORK
    5951    PS_ASSERT_PTR_NON_NULL(readout, false);
    60 #else
    61     pmReadout *readout = pmReadoutAlloc(NULL);
    62 #endif
    6352    PS_ASSERT_INT_LARGER_THAN(numCols, 0, false);
    6453    PS_ASSERT_INT_LARGER_THAN(numRows, 0, false);
    6554    PS_ASSERT_ARRAY_NON_NULL(sources, false);
    6655
    67 #ifdef PAP_WORK
    6856    if (xOffset || yOffset) {
    6957        PS_ASSERT_VECTOR_NON_NULL(xOffset, false);
     
    8472        return false;
    8573    }
    86 #endif
    8774
    8875    readout->image = psImageRecycle(readout->image, numCols, numRows, PS_TYPE_F32);
     
    9178    int numSources = sources->n;          // Number of stars
    9279
    93 #ifndef PAP_WORK
    94     pmModelType modelType = pmModelClassGetType(MODEL_TYPE); // Type of PSF model
    95     assert(modelType >= 0);
    96     pmModel *fakeModel = pmModelAlloc(modelType);
    97 
    98     float sigma = fwhm / (2.0 * sqrtf(2.0 * log(2.0))); // Gaussian sigma
    99 
    100     fakeModel->params->data.F32[PM_PAR_SKY] = 0.0;
    101     fakeModel->params->data.F32[PM_PAR_I0] = 1.0;
    102     fakeModel->params->data.F32[PM_PAR_XPOS] = NAN;
    103     fakeModel->params->data.F32[PM_PAR_YPOS] = NAN;
    104     fakeModel->params->data.F32[PM_PAR_SXX] = sigma * M_SQRT2;
    105     fakeModel->params->data.F32[PM_PAR_SYY] = sigma * M_SQRT2;
    106     fakeModel->params->data.F32[PM_PAR_SXY] = 0.0;
    107     switch (modelType) {
    108       case 0:                           // GAUSS
    109       case 1:                           // PGAUSS
    110         break;
    111       case 2:                           // QGAUSS
    112         fakeModel->params->data.F32[PM_PAR_7] = 1.0;
    113         break;
    114       case 3:                           // RGAUSS
    115         fakeModel->params->data.F32[PM_PAR_7] = 2.0;
    116         break;
    117       default:
    118         psAbort("Unsupported model type: %d", modelType);
    119     }
    120 #else
    12180    pmModel *fakeModel = pmModelFromPSFforXY(psf, (float)numCols / 2.0, (float)numRows / 2.0,
    12281                                             1.0); // Fake model, with central intensity of 1.0
    123 #endif
    12482
    12583    float flux0 = fakeModel->modelFlux(fakeModel->params); // Flux for central intensity of 1.0
    12684
    127 #ifdef PAP_WORK
    12885    if (circularise && !circulariseModel(fakeModel)) {
    12986        psError(PS_ERR_UNKNOWN, false, "Unable to circularise PSF model.");
     
    13289    }
    13390    psFree(fakeModel);
    134 #endif
    13591
    13692    for (int i = 0; i < numSources; i++) {
     
    148104        }
    149105
    150 #ifdef PAP_WORK
    151106        pmModel *fakeModel = pmModelFromPSFforXY(psf, x, y, powf(10.0, -0.4 * source->psfMag) / flux0);
    152107        if (!fakeModel) {
     
    159114            return false;
    160115        }
    161 #else
    162         fakeModel->params->data.F32[PM_PAR_I0] = powf(10.0, -0.4 * source->psfMag) / flux0;
    163         fakeModel->params->data.F32[PM_PAR_XPOS] = x;
    164         fakeModel->params->data.F32[PM_PAR_YPOS] = y;
    165 #endif
    166116
    167117        psTrace("psModules.camera", 10, "Adding source at %f,%f with flux %f\n",
     
    171121        pmSource *fakeSource = pmSourceAlloc(); // Fake source to generate
    172122        fakeSource->peak = pmPeakAlloc(x, y, fakeModel->params->data.F32[PM_PAR_I0], PM_PEAK_LONE);
    173         float fakeRadius =
    174 #ifdef PAP_WORK
    175             radius > 0 ? radius :
    176 #endif
    177             fakeModel->modelRadius(fakeModel->params, minFlux); // Radius
     123        float fakeRadius = radius > 0 ? radius : fakeModel->modelRadius(fakeModel->params, minFlux); // Radius
    178124
    179 #ifdef PAP_WORK
    180125        if (xOffset) {
    181126            if (!pmSourceDefinePixels(fakeSource, readout, x + xOffset->data.S32[i],
     
    193138                return false;
    194139            }
    195         } else
    196 #endif
    197         {
     140        } else {
    198141            if (!pmSourceDefinePixels(fakeSource, readout, x, y, fakeRadius)) {
    199142                psError(PS_ERR_UNKNOWN, false, "Unable to define pixels for source.");
     
    210153        }
    211154        psFree(fakeSource);
    212 #ifdef PAP_WORK
    213155        psFree(fakeModel);
    214 #endif
    215156    }
    216157
    217     return
    218 #ifdef PAP_WORK
    219         true
    220 #else
    221         readout
    222 #endif
    223         ;
    224 
     158    return true;
    225159}
  • trunk/psModules/src/camera/pmReadoutFake.h

    r15815 r15838  
    1212#include <pmPSF.h>
    1313
    14 
    15 //#define PAP_WORK
    16 
    17 
    18 #ifdef PAP_WORK
    1914/// Generate a fake readout from an array of sources
    2015bool pmReadoutFakeFromSources(pmReadout *readout, ///< Output readout, or NULL
     
    2318                              const psVector *xOffset, ///< x offsets for sources (source -> img), or NULL
    2419                              const psVector *yOffset, ///< y offsets for sources (source -> img), or NULL
    25                               pmPSF *psf, ///< PSF for sources
     20                              const pmPSF *psf, ///< PSF for sources
    2621                              float minFlux, ///< Minimum flux to bother about; for setting source radius
    2722                              int radius, ///< Fixed radius for sources
    2823                              bool circularise ///< Circularise PSF model?
    2924    );
    30 #else
    31 pmReadout *pmReadoutFakeFromSources(int numCols, int numRows, ///< Dimension of image
    32                                     const psArray *sources, ///< Array of pmSource
    33                                     float target, ///< Target FWHM
    34                                     float minFlux ///< Minimum flux to bother about; for setting source radius
    35     );
    36 #endif // PAP_WORK
    37 
    38 
    39 
    4025
    4126#endif
Note: See TracChangeset for help on using the changeset viewer.