Changeset 41173
- Timestamp:
- Nov 27, 2019, 12:05:20 PM (6 years ago)
- Location:
- trunk/ppSim/src
- Files:
-
- 9 edited
- 1 copied
-
Makefile.am (modified) (1 diff)
-
ppSim.h (modified) (1 diff)
-
ppSimCreate.c (modified) (1 diff)
-
ppSimLoadStars.c (modified) (2 diffs)
-
ppSimLoop.c (modified) (1 diff)
-
ppSimMakeGalaxies.c (modified) (3 diffs)
-
ppSimMakeStarCluster.c (copied) (copied from branches/eam_branches/ipp-20191011/ppSim/src/ppSimMakeStarCluster.c )
-
ppSimMakeStarGrid.c (modified) (1 diff)
-
ppSimMakeStars.c (modified) (4 diffs)
-
ppSimUtils.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSim/src/Makefile.am
r38041 r41173 15 15 ppSimLoadStars.c \ 16 16 ppSimMakeStars.c \ 17 ppSimMakeStarCluster.c \ 17 18 ppSimMakeStarGrid.c \ 18 19 ppSimMakeGalaxies.c \ -
trunk/ppSim/src/ppSim.h
r28125 r41173 103 103 bool ppSimLoadStars (psArray *stars, pmFPA *fpa, pmConfig *config); 104 104 bool ppSimMakeStars(psArray *stars, pmFPA *fpa, pmConfig *config, const psRandom *rng); 105 bool ppSimMakeStarCluster(psArray *stars, pmFPA *fpa, pmConfig *config, const psRandom *rng); 105 106 bool ppSimMakeStarGrid(psArray *stars, pmFPA *fpa, pmConfig *config, const psRandom *rng); 106 107 bool ppSimInsertStars (pmReadout *readout, psImage *expCorr, psArray *stars, pmConfig *config); -
trunk/ppSim/src/ppSimCreate.c
r30618 r41173 159 159 return false; 160 160 } 161 simSources->save = true; 161 162 // XXXX TEST this is causing trouble for unknown reasons -- output step is blowing up. 163 // simSources->save = true; 164 simSources->save = false; 162 165 163 166 // if we have loaded an input image, we derive certain values from the image, if possible -
trunk/ppSim/src/ppSimLoadStars.c
r26975 r41173 24 24 float pa = psMetadataLookupF32(NULL, recipe, "PA"); // Position angle (radians) 25 25 float seeing = psMetadataLookupF32(NULL, recipe, "SEEING"); // Seeing SIGMA (pixels) 26 float scale = psMetadataLookupF32(NULL, recipe, "PIXEL.SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel) 26 float scale = psMetadataLookupF32(NULL, recipe, "PIXEL.SCALE"); // Plate scale (arcsec/pixel) 27 float scaleRad = scale * M_PI / 3600.0 / 180.0; // Plate scale in radians/pixel for WCS below 27 28 float expTime = psMetadataLookupF32(NULL, recipe, "EXPTIME"); // Exposure time (sec) 28 29 29 30 // Size of FPA 30 31 psRegion *bounds = ppSimFPABounds (fpa); 31 float radius = 0.5 * PS_MAX(bounds->x1 - bounds->x0, bounds->y1 - bounds->y0) * scale ;32 float radius = 0.5 * PS_MAX(bounds->x1 - bounds->x0, bounds->y1 - bounds->y0) * scaleRad; 32 33 33 34 float x0fpa = 0.5*(bounds->x0 + bounds->x1); … … 53 54 stars = psArrayRealloc (stars, refStars->n); 54 55 55 psProjection *proj = psProjectionAlloc(ra0, dec0, scale , scale, PS_PROJ_TAN); // Projection56 psProjection *proj = psProjectionAlloc(ra0, dec0, scaleRad, scaleRad, PS_PROJ_TAN); // Projection 56 57 57 58 // Conversion loop -
trunk/ppSim/src/ppSimLoop.c
r30618 r41173 51 51 52 52 // Add random stars 53 if (!ppSimMakeStarGrid (stars, fpa, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "failed to make random stars"); 53 if (!ppSimMakeStarGrid (stars, fpa, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "failed to make star grid"); 54 55 // Add random stars 56 if (!ppSimMakeStarCluster (stars, fpa, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "failed to make cluster stars"); 54 57 55 58 // Add random galaxies -
trunk/ppSim/src/ppSimMakeGalaxies.c
r36079 r41173 45 45 float zp = psMetadataLookupF32(&mdok, recipe, "ZEROPOINT"); // Photometric zero point 46 46 float seeing = psMetadataLookupF32(&mdok, recipe, "SEEING"); // Seeing sigma (pix) 47 float scale = psMetadataLookupF32(&mdok, recipe, "PIXEL.SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel)47 float scale = psMetadataLookupF32(&mdok, recipe, "PIXEL.SCALE"); // Plate scale (arcsec/pixel) 48 48 float skyRate = psMetadataLookupF32(&mdok, recipe, "SKY.RATE"); // Sky rate 49 49 if (isnan(skyRate)) { 50 50 float skyMags = psMetadataLookupF32(&mdok, recipe, "SKY.MAGS"); assert (mdok); 51 51 skyRate = scale * scale * ppSimMagToFlux (skyMags, zp); 52 // skyMags is in mags / square arcsec so scale must be arcsec / pixel 52 53 } 53 54 … … 94 95 95 96 // Normalisation, set by the specified stellar density at the specified bright magnitude 96 float refSum = galaxyDensity * xSize * ySize * PS_SQR(scale * 180.0 / M_PI);97 float refSum = galaxyDensity * xSize * ySize * PS_SQR(scale / 3600.0); 97 98 float normLum = refSum / (galaxyAlpha * logf(10.0) * powf(10.0, (galaxyAlpha * brightMag))); 98 99 float normScale = normLum * galaxyAlpha * logf(10.0); … … 143 144 rndValue = galaxyGridRandom ? drand48() : i / (float) nTotal; 144 145 float scale = (galaxyRmajorMin + rndValue * galaxyRmajorSlope); 145 146 146 galaxy->Rmaj = scale; 147 147 -
trunk/ppSim/src/ppSimMakeStarGrid.c
r26900 r41173 22 22 float zp = psMetadataLookupF32(&status, recipe, "ZEROPOINT"); // Photometric zero point 23 23 float seeing = psMetadataLookupF32(&status, recipe, "SEEING"); // Seeing SIGMA (pixels) 24 float scale = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel)24 float scale = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE"); // Plate scale (arcsec/pixel) 25 25 26 26 if (isnan(expTime)) ESCAPE("EXPTIME is not defined"); -
trunk/ppSim/src/ppSimMakeStars.c
r25760 r41173 27 27 float zp = psMetadataLookupF32(&status, recipe, "ZEROPOINT"); // Photometric zero point 28 28 float seeing = psMetadataLookupF32(&status, recipe, "SEEING"); // Seeing SIGMA (pixels) 29 float scale = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel) 29 float scale = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE"); // Plate scale (arcsec/pixel) 30 // there has been some confusion over pixel scale: PIXEL.SCALE is supplied in arcsec / pixel. 31 // In some other places (ppSimLoadStars.c, ppSimUtils.c) it is needed in radius for WCS conversion. 32 // in the past, it was converted to radians on load (but applied inconsisently elsewhere) 33 // Now the radian version is carried as scaleRad to be more explicit 30 34 31 35 if (isnan(darkRate)) darkRate = 0.0; … … 42 46 float skyMags = psMetadataLookupF32(&status, recipe, "SKY.MAGS"); assert (status); 43 47 skyRate = scale * scale * ppSimMagToFlux (skyMags, zp); 48 // skyMags is in mags / square arcsec, so scale must be in arcsec / pixel 44 49 } 45 50 … … 61 66 if (!status) { 62 67 refMag = brightMag; 63 refSum = starsDensity * xSize * ySize * PS_SQR(scale * 180.0 / M_PI);68 refSum = starsDensity * xSize * ySize * PS_SQR(scale / 3600.0); 64 69 } 65 70 } else { 66 71 refMag = brightMag; 67 refSum = starsDensity * xSize * ySize * PS_SQR(scale * 180.0 / M_PI);72 refSum = starsDensity * xSize * ySize * PS_SQR(scale / 3600.0); 68 73 } 69 74 psTrace("ppSim", 6, "refMag: %f, refSum: %f\n", refMag, refSum); … … 120 125 psLogMsg("ppSim", PS_LOG_INFO, "Adding %ld stars between %f and %f mag\n", nTotal, brightMag, faintMag); 121 126 127 if (nTotal > 1e7) { 128 psLogMsg("ppSim", PS_LOG_INFO, "Trying to add %d stars (far more than 10M stars!), giving up\n", (int) nTotal); 129 exit (2); 130 } 131 122 132 long oldSize = stars->n; 123 133 psArrayRealloc (stars, stars->n + nTotal); -
trunk/ppSim/src/ppSimUtils.c
r40738 r41173 16 16 float pa = psMetadataLookupF32(NULL, recipe, "PA"); // Position angle (radians) 17 17 float scale = psMetadataLookupF32(NULL, recipe, "PIXEL.SCALE"); // plate scale in arcsec / pixel 18 scale *=M_PI / 3600.0 / 180.0; // convert plate scale to radians/pixel18 float scaleRad = scale * M_PI / 3600.0 / 180.0; // convert plate scale to radians/pixel 19 19 20 20 int binning = psMetadataLookupS32(NULL, recipe, "BINNING"); // Binning in x and y … … 61 61 psMetadata *header = psMetadataAlloc(); // Header, to return 62 62 pmAstromWCS *wcs = pmAstromWCSAlloc(1, 1); // WCS structure 63 wcs->toSky = psProjectionAlloc(ra0, dec0, scale * xParity, scale* yParity, PS_PROJ_TAN);64 wcs->cdelt1 = scale * PM_DEG_RAD * xParity;65 wcs->cdelt2 = scale * PM_DEG_RAD * yParity;63 wcs->toSky = psProjectionAlloc(ra0, dec0, scaleRad * xParity, scaleRad * yParity, PS_PROJ_TAN); 64 wcs->cdelt1 = scaleRad * PM_DEG_RAD * xParity; 65 wcs->cdelt2 = scaleRad * PM_DEG_RAD * yParity; 66 66 wcs->crpix1 = x0; 67 67 wcs->crpix2 = y0;
Note:
See TracChangeset
for help on using the changeset viewer.
