IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 25, 2007, 11:57:36 AM (19 years ago)
Author:
eugene
Message:

added galaxies, some tweaks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSim/src/ppSimMakeStars.c

    r14531 r14667  
    33bool ppSimMakeStars(psArray *stars, pmFPA *fpa, pmConfig *config, const psRandom *rng) {
    44
     5    bool mdok;
    56    assert (stars);
    67
    7     bool mdok;
     8    psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, PPSIM_RECIPE); // Recipe
    89
    9     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe
     10    bool starsFake = psMetadataLookupBool(&mdok, recipe, "STARS.FAKE"); // Density of fakes
     11    if (!starsFake) return true;
    1012
    1113    float starsLum = psMetadataLookupF32(NULL, config->arguments, "STARS.LUM"); // Star luminosity func slope
     
    4547        psLogMsg("ppSim", PS_LOG_INFO,
    4648                 "Image noise is above brightest random star --- no random stars added.");
    47     } else {
     49        return true;
     50    }
    4851
    49         // Normalisation, set by the specified stellar density at the specified bright magnitude
    50         float norm = starsDensity * xSize * ySize * PS_SQR(scale * 180.0 / M_PI) /
    51             powf(bright, starsLum);
     52    // Normalisation, set by the specified stellar density at the specified bright magnitude
     53    float norm = starsDensity * xSize * ySize * PS_SQR(scale * 180.0 / M_PI) /
     54        powf(bright, starsLum);
    5255
    53         // Total number of stars down to the faint flux end
    54         long num = expf(logf(norm) + starsLum * logf(faint)) + 0.5;
     56    // Total number of stars down to the faint flux end
     57    long num = expf(logf(norm) + starsLum * logf(faint)) + 0.5;
    5558
    56         psLogMsg("ppSim", PS_LOG_INFO, "Adding %ld stars down to %f mag\n", num,
    57                 -2.5 * log10(faint * sqrt(2.0*M_PI) * seeing / expTime) + zp);
     59    psLogMsg("ppSim", PS_LOG_INFO, "Adding %ld stars down to %f mag\n", num,
     60            -2.5 * log10(faint * sqrt(2.0*M_PI) * seeing / expTime) + zp);
    5861
    59         long oldSize = stars->n;
    60         psArrayRealloc (stars, stars->n + num);
     62    long oldSize = stars->n;
     63    psArrayRealloc (stars, stars->n + num);
    6164
    62         for (long i = 0; i < num; i++) {
    63             ppSimStar *star = ppSimStarAlloc ();
     65    for (long i = 0; i < num; i++) {
     66        ppSimStar *star = ppSimStarAlloc ();
    6467
    65             // make fpa center of distribution
    66             star->x    = psRandomUniform(rng) * xSize; // x position
    67             star->y    = psRandomUniform(rng) * ySize; // y position
    68             star->peak = expf((logf(i + 1) - logf(norm)) / starsLum); // Peak flux
    69             star->flux = star->peak * sqrt(2.0*M_PI)*seeing;
    70             stars->data[oldSize + i] = star;
    71         }
    72         stars->n = stars->nalloc;
     68        // make fpa center of distribution
     69        star->x    = psRandomUniform(rng) * xSize; // x position
     70        star->y    = psRandomUniform(rng) * ySize; // y position
     71
     72        star->flux = expf((logf(i + 1) - logf(norm)) / starsLum); // Peak flux
     73        star->peak = star->flux / (2.0*M_PI*PS_SQR(seeing));
     74
     75        stars->data[oldSize + i] = star;
    7376    }
     77    stars->n = stars->nalloc;
     78
    7479    return true;
    7580}
Note: See TracChangeset for help on using the changeset viewer.