Changeset 14667 for trunk/ppSim/src/ppSimMakeStars.c
- Timestamp:
- Aug 25, 2007, 11:57:36 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/ppSim/src/ppSimMakeStars.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSim/src/ppSimMakeStars.c
r14531 r14667 3 3 bool ppSimMakeStars(psArray *stars, pmFPA *fpa, pmConfig *config, const psRandom *rng) { 4 4 5 bool mdok; 5 6 assert (stars); 6 7 7 bool mdok;8 psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, PPSIM_RECIPE); // Recipe 8 9 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; 10 12 11 13 float starsLum = psMetadataLookupF32(NULL, config->arguments, "STARS.LUM"); // Star luminosity func slope … … 45 47 psLogMsg("ppSim", PS_LOG_INFO, 46 48 "Image noise is above brightest random star --- no random stars added."); 47 } else { 49 return true; 50 } 48 51 49 // Normalisation, set by the specified stellar density at the specified bright magnitude50 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); 52 55 53 // Total number of stars down to the faint flux end54 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; 55 58 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); 58 61 59 long oldSize = stars->n;60 psArrayRealloc (stars, stars->n + num);62 long oldSize = stars->n; 63 psArrayRealloc (stars, stars->n + num); 61 64 62 for (long i = 0; i < num; i++) {63 ppSimStar *star = ppSimStarAlloc ();65 for (long i = 0; i < num; i++) { 66 ppSimStar *star = ppSimStarAlloc (); 64 67 65 // make fpa center of distribution66 star->x = psRandomUniform(rng) * xSize; // x position67 star->y = psRandomUniform(rng) * ySize; // y position68 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; 73 76 } 77 stars->n = stars->nalloc; 78 74 79 return true; 75 80 }
Note:
See TracChangeset
for help on using the changeset viewer.
