IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25246


Ignore:
Timestamp:
Sep 2, 2009, 9:58:54 AM (17 years ago)
Author:
Paul Price
Message:

Getting ready to run it.

Location:
branches/pap/psphot/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/pap/psphot/src/Makefile.am

    r24586 r25246  
    128128        psphotCheckStarDistribution.c  \
    129129        psphotThreadTools.c            \
    130         psphotAddNoise.c
     130        psphotAddNoise.c               \
     131        psphotFake.c
    131132
    132133# dropped? psphotGrowthCurve.c
  • branches/pap/psphot/src/psphot.h

    r24890 r25246  
    7676bool            psphotExtendedSourceAnalysis (pmReadout *readout, psArray *sources, psMetadata *recipe);
    7777bool            psphotExtendedSourceFits (pmReadout *readout, psArray *sources, psMetadata *recipe);
     78bool            psphotFake(pmReadout *readout, const pmPSF *psf, const psMetadata *recipe, const psArray *realSources);
    7879
    7980// thread-related:
  • branches/pap/psphot/src/psphotFake.c

    r25230 r25246  
    2020                      float smoothNsigma,       // Smoothing limit
    2121                      psImageMaskType maskVal   // Value to mask
    22                       );
     22                      )
    2323{
    2424    PM_ASSERT_READOUT_NON_NULL(ro, false);
    2525    PM_ASSERT_READOUT_VARIANCE(ro, false);
    26     PS_ASSERT_METADATA_NON_NULL(recipe, false);
    27 
    28     float smoothSigma  = 0.5*(FWHM_X + FWHM_Y) / (2.0*sqrtf(2.0*log(2.0)));
     26
     27    float smoothSigma  = 0.5*(xFWHM + yFWHM) / (2.0*sqrtf(2.0*log(2.0)));
    2928    psKernel *kernel = psImageSmoothKernel(smoothSigma, smoothNsigma); // Kernel used for smoothing
    30     psKernel *newCovar = psImageCovarianceCalculate(kernel, readout->covariance); // Covariance matrix
     29    psKernel *newCovar = psImageCovarianceCalculate(kernel, ro->covariance); // Covariance matrix
    3130    psFree(kernel);
    3231    float factor = psImageCovarianceFactor(newCovar); // Variance factor
     
    5049    }
    5150    if (minFlux) {
    52         int fudge = psMetadataLookupF32(NULL, recipe, "FAKE.MINFLUX"); // Fudge factor for minimum flux
    53         *minFlux = sqrtf(meanVar) * fudge;
     51        *minFlux = sqrtf(meanVar);
    5452    }
    5553
     
    6058static bool fakeGenerate(psImage **xSrc, psImage **ySrc, // Positions of sources
    6159                         const pmReadout *ro,            // Readout of interest
     60                         const pmPSF *psf,               // Point-spread function
    6261                         const psVector *magOffsets,     // Magnitude offsets for fake sources
    6362                         int numSources,                 // Number of fake sources for each bin
     
    6867    PM_ASSERT_READOUT_NON_NULL(ro, false);
    6968    PM_ASSERT_READOUT_IMAGE(ro, false);
    70     PS_ASSERT_METADATA_NON_NULL(recipe, false);
    7169    PS_ASSERT_VECTOR_NON_NULL(magOffsets, false);
    7270    PS_ASSERT_VECTOR_TYPE(magOffsets, PS_TYPE_F32, false);
    7371
    74     int numBins = magOffset->n;                                     // Number of bins
     72    int numBins = magOffsets->n;                                    // Number of bins
    7573    int numCols = ro->image->numCols, numRows = ro->image->numRows; // Size of image
    7674
     
    8482
    8583    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator
    86     for (int i = 0; i <= numBins; i++) {
    87         psArray *data = psArrayAlloc(3); // Sources for bin
    88 
    89         psVector *x = psVectorAlloc(numSources, PS_TYPE_F32);
    90         psVector *y = psVectorAlloc(numSources, PS_TYPE_F32);
    91 
    92         float mag = refMag + magOffset->data.F32[i]; // Instrumental magnitude of sources
    93 
    94         for (int j = 0; j <= numSources; j++) {
    95             x->data.F32[j] = psRandomUniform(rng) * numCols;
    96             y->data.F32[j] = psRandomUniform(rng) * numRows;
    97             magAll->data.F32[i * numSources + j] = mag;
     84    for (int i = 0, index = 0; i <= numBins; i++) {
     85        float mag = refMag + magOffsets->data.F32[i]; // Instrumental magnitude of sources
     86
     87        for (int j = 0; j <= numSources; j++, index++) {
     88            xAll->data.F32[index] = psRandomUniform(rng) * numCols;
     89            yAll->data.F32[index] = psRandomUniform(rng) * numRows;
     90            magAll->data.F32[index] = mag;
    9891        }
    99         memcpy(xSrc->data.F32[i], x->data.F32, numSources * PSELEMTYPE_SIZEOF(PS_TYPE_F32));
    100         memcpy(ySrc->data.F32[i], y->data.F32, numSources * PSELEMTYPE_SIZEOF(PS_TYPE_F32));
    101         memcpy(&xAll->data.F32[i * numSources], x->data.F32, numSources * PSELEMTYPE_SIZEOF(PS_TYPE_F32));
    102         memcpy(&yAll->data.F32[i * numSources], y->data.F32, numSources * PSELEMTYPE_SIZEOF(PS_TYPE_F32));
     92        memcpy((*xSrc)->data.F32[i], &xAll->data.F32[i * numSources],
     93              numSources * PSELEMTYPE_SIZEOF(PS_TYPE_F32));
     94        memcpy((*ySrc)->data.F32[i], &yAll->data.F32[i * numSources],
     95              numSources * PSELEMTYPE_SIZEOF(PS_TYPE_F32));
    10396    }
    10497    psFree(rng);
    10598
    106     pmReadout *fakeRO = pmReadoutAlloc(); // Fake readout
    107     if (!pmReadoutFakeFromVectors(fakeRO, xAll, yAll, mag, NULL, NULL, psf, minFlux, NAN, false, false)) {
     99    pmReadout *fakeRO = pmReadoutAlloc(NULL); // Fake readout
     100    if (!pmReadoutFakeFromVectors(fakeRO, xAll, yAll, magAll, NULL, NULL, psf, minFlux, NAN, false, false)) {
    108101        psError(PS_ERR_UNKNOWN, false, "Unable to generate fake image");
    109102        psFree(fakeRO);
     
    125118
    126119// *** in this section, perform the photometry for fake sources ***
    127 bool psphotFake(pmConfig *config, pmReadout *readout, const pmPSF *psf,
    128                 const psMetadata *recipe, const psArray *realSources)
     120bool psphotFake(pmReadout *readout, const pmPSF *psf, const psMetadata *recipe, const psArray *realSources)
    129121{
    130     PS_ASSERT_PTR_NON_NULL(config, false);
    131122    PM_ASSERT_READOUT_NON_NULL(readout, false);
    132123    PM_ASSERT_READOUT_IMAGE(readout, false);
     
    138129
    139130    // Collect recipe information
     131    bool mdok;                                                 // Status of MD lookup
    140132    float xFWHM = psMetadataLookupF32(NULL, recipe, "FWHM_X"); // PSF size in x
    141133    float yFWHM = psMetadataLookupF32(NULL, recipe, "FWHM_Y"); // PSF size in y
     
    155147    }
    156148    psVector *magOffsets = psMetadataLookupVector(NULL, recipe, "FAKE.MAG"); // Magnitude offsets
    157     if (!magOffset || magOffset->type.type != PS_TYPE_F32) {
     149    if (!magOffsets || magOffsets->type.type != PS_TYPE_F32) {
    158150        psError(PSPHOT_ERR_CONFIG, false, "Unable to find FAKE.MAG F32 vector in recipe");
    159151        return NULL;
     
    164156        return NULL;
    165157    }
    166     psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Value to mask
    167 
     158    float minFluxFudge = psMetadataLookupF32(&mdok, recipe, "FAKE.MINFLUX"); // Fudge factor for minimum flux
     159    if (!mdok) {
     160        minFluxFudge = 1.0;
     161    }
     162
     163    psImageMaskType maskVal = psMetadataLookupImageMask(NULL, recipe, "MASK.PSPHOT"); // Value to mask
    168164
    169165    // remove all sources, adding noise for subtracted sources
     
    177173        return false;
    178174    }
     175    minFlux *= minFluxFudge;
    179176
    180177    psImage *xFake = NULL, *yFake = NULL; // Coordinates of sources, each bin in a row
    181     if (!fakeGenerate(&xFake, &yFake, readout, magOffsets, numSources, magLim, minFlux)) {
     178    if (!fakeGenerate(&xFake, &yFake, readout, psf, magOffsets, numSources, magLim, minFlux)) {
    182179        psError(PS_ERR_UNKNOWN, false, "Unable to generate fake sources");
    183180        psFree(xFake);
  • branches/pap/psphot/src/psphotOutput.c

    r21366 r25246  
    228228    psMetadataItemSupplement (header, recipe, "MSKY_NY");
    229229
     230    // fake source recovery statistics
     231    psMetadataItemSupplement(header, recipe, "FAKE.EFF");
     232    psMetadataItemSupplement(header, recipe, "FAKE.MAG");
     233    psMetadataItemSupplement(header, recipe, "FAKE.REF");
     234
    230235    psMetadataAddF32 (header, PS_LIST_TAIL, "DT_PHOT", PS_META_REPLACE, "elapsed psphot time", psTimerMark ("psphotReadout"));
    231236
  • branches/pap/psphot/src/psphotReadout.c

    r24890 r25246  
    6161    // display the backsub and backgnd images
    6262    psphotVisualShowBackground (config, view, readout);
    63    
     63
    6464    // run a single-model test if desired (exits from here if test is run)
    6565    psphotModelTest (config, view, recipe);
     
    224224    psphotMagnitudes(config, readout, view, sources, psf);
    225225
     226    if (!psphotFake(readout, psf, recipe, sources)) {
     227        psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
     228        psErrorClear();
     229    }
     230
    226231    // replace failed sources?
    227232    // psphotReplaceUnfitSources (sources);
Note: See TracChangeset for help on using the changeset viewer.