Changeset 14816 for trunk/ppSim/src/ppSimMakeStars.c
- Timestamp:
- Sep 11, 2007, 1:01:03 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ppSim/src/ppSimMakeStars.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSim/src/ppSimMakeStars.c
r14667 r14816 1 1 # include "ppSim.h" 2 3 #define FAINT_FUDGE_FACTOR 1.0 // Fraction of the noise in a (boxcar) PSF for the faint limit 4 2 5 3 6 bool ppSimMakeStars(psArray *stars, pmFPA *fpa, pmConfig *config, const psRandom *rng) { … … 36 39 float readnoise = psMetadataLookupF32(&mdok, recipe, "READNOISE"); // Default read noise 37 40 if (!mdok) { 38 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find READNOISE in recipe.");39 psFree(bounds);40 return false;41 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find READNOISE in recipe."); 42 psFree(bounds); 43 return false; 41 44 } 42 45 43 // Peak fluxes: faintest and brightest levels for random stars 44 float faint = 0.1 * 10.0 * sqrtf(PS_SQR(readnoise) + (darkRate + skyRate) * expTime); 45 float bright = powf(10.0, -0.4 * (starsMag - zp)) / sqrt(2.0*M_PI) / seeing * expTime; 46 // Faintest and brightest (integrated) fluxes (actually fluence, since integrated) for random stars 47 float faint = FAINT_FUDGE_FACTOR * sqrtf(PS_SQR(readnoise) + (darkRate + skyRate) * expTime) * 48 seeing; // Faint limit is related to the noise in a (boxcar) PSF 49 float bright = powf(10.0, -0.4 * (starsMag - zp)) * expTime; // Bright limit is specified by user as mag 50 psTrace("ppSim", 6, "Faint limit: %f\n", faint); 51 psTrace("ppSim", 6, "Bright limit: %f\n", bright); 46 52 if (bright < faint) { 47 psLogMsg("ppSim", PS_LOG_INFO,48 "Image noise is above brightest random star --- no random stars added.");49 return true;53 psLogMsg("ppSim", PS_LOG_INFO, 54 "Image noise is above brightest random star --- no random stars added."); 55 return true; 50 56 } 51 57 52 58 // Normalisation, set by the specified stellar density at the specified bright magnitude 53 59 float norm = starsDensity * xSize * ySize * PS_SQR(scale * 180.0 / M_PI) / 54 powf(bright, starsLum);60 powf(bright, starsLum); 55 61 56 62 // Total number of stars down to the faint flux end 57 63 long num = expf(logf(norm) + starsLum * logf(faint)) + 0.5; 58 64 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);65 psLogMsg("ppSim", PS_LOG_INFO, "Adding %ld stars down to %f mag\n", 66 num, -2.5 * log10(faint / expTime) + zp); 61 67 62 68 long oldSize = stars->n; … … 64 70 65 71 for (long i = 0; i < num; i++) { 66 ppSimStar *star = ppSimStarAlloc ();72 ppSimStar *star = ppSimStarAlloc (); 67 73 68 // make fpa center of distribution69 star->x = psRandomUniform(rng) * xSize; // x position70 star->y = psRandomUniform(rng) * ySize; // y position74 // make fpa center of distribution 75 star->x = psRandomUniform(rng) * xSize; // x position 76 star->y = psRandomUniform(rng) * ySize; // y position 71 77 72 star->flux = expf((logf(i + 1) - logf(norm)) / starsLum); // Peak flux73 star->peak = star->flux / (2.0*M_PI*PS_SQR(seeing));78 star->flux = expf((logf(i + 1) - logf(norm)) / starsLum); // Peak flux 79 star->peak = star->flux / (2.0*M_PI*PS_SQR(seeing)); 74 80 75 stars->data[oldSize + i] = star;81 stars->data[oldSize + i] = star; 76 82 } 77 stars->n = stars->nalloc;83 stars->n = oldSize + num; 78 84 79 85 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
