Changeset 34134
- Timestamp:
- Jul 10, 2012, 2:34:42 PM (14 years ago)
- Location:
- branches/eam_branches/ipp-20120627/ppSim/src
- Files:
-
- 2 edited
-
ppSimInsertGalaxies.c (modified) (4 diffs)
-
ppSimMakeGalaxies.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120627/ppSim/src/ppSimInsertGalaxies.c
r34083 r34134 76 76 if (type == -1) { 77 77 psError (PS_ERR_UNKNOWN, false, "invalid model name"); 78 return false;78 return false; 79 79 } 80 80 … … 136 136 PAR[PM_PAR_YPOS] = yChip; 137 137 138 psEllipseAxes axes; 139 axes.major = galaxy->Rmaj; 140 axes.minor = galaxy->Rmin; 141 axes.theta = galaxy->theta; 142 pmPSF_AxesToModel (PAR, axes, type); 143 psF64 Area = 2.0 * M_PI * axes.major * axes.minor; 138 if (type == pmModelClassGetType ("PS_MODEL_TRAIL")) { 139 PAR[PM_PAR_LENGTH] = galaxy->Rmaj; 140 PAR[PM_PAR_SIGMA] = galaxy->Rmin; 141 PAR[PM_PAR_THETA] = galaxy->theta; 142 } else { 143 psEllipseAxes axes; 144 axes.major = galaxy->Rmaj; 145 axes.minor = galaxy->Rmin; 146 axes.theta = galaxy->theta; 147 pmPSF_AxesToModel (PAR, axes, type); 148 } 149 psF64 Area = 2.0 * M_PI * galaxy->Rmaj * galaxy->Rmin; 144 150 145 151 if (nParam == 8) { … … 147 153 } 148 154 149 // set the normalization to get the desired flux150 // XXX for now, use peak: pmModelSetFlux (model, galaxy->flux);151 152 155 // XXX let the flux limit be a user-defined number of sky sigmas (not just 1.0) 153 156 float radius = model->modelRadius (model->params, 0.1*roughNoise); 154 157 radius = PS_MAX (radius, 1.0); 158 155 159 // XXX the exp(-r^0.25) models can go way out if allowed... 156 160 radius = PS_MIN (radius, 300.0); … … 176 180 177 181 float par8 = (model->params->n == 8) ? model->params->data.F32[7] : 0.0; 178 fprintf (outfile, "%8.3f %8.3f %10.2f %2d %7.3f %5.3f %5.3f %5.3f %5.3f %5.3f\n", galaxy->x, galaxy->y, flux, 1, source->psfMag, source->psfMagErr, axes.major, axes.minor, axes.theta, par8);182 fprintf (outfile, "%8.3f %8.3f %10.2f %2d %7.3f %5.3f %5.3f %5.3f %5.3f %5.3f\n", galaxy->x, galaxy->y, flux, 1, source->psfMag, source->psfMagErr, galaxy->Rmaj, galaxy->Rmin, galaxy->theta, par8); 179 183 180 184 psArrayAdd (sources, 100,source); -
branches/eam_branches/ipp-20120627/ppSim/src/ppSimMakeGalaxies.c
r32350 r34134 1 1 # include "ppSim.h" 2 3 bool ppSimSetGalaxyPeak (ppSimGalaxy *galaxy, pmModelType type, float index, float seeing); 2 4 3 5 bool ppSimMakeGalaxies(psArray *galaxies, pmFPA *fpa, pmConfig *config, const psRandom *rng) { … … 19 21 int galaxyGridDY = psMetadataLookupS32 (&mdok, recipe, "GALAXY.GRID.DY"); // Density of fakes 20 22 bool galaxyGridRandom = psMetadataLookupBool(&mdok, recipe, "GALAXY.GRID.RANDOM"); // Density of fakes 21 float galaxyGridPeak = psMetadataLookupF32 (&mdok, recipe, "GALAXY.GRID.PEAK"); // peak flux of fakes23 // float galaxyGridPeak = psMetadataLookupF32 (&mdok, recipe, "GALAXY.GRID.PEAK"); // peak flux of fakes 22 24 float galaxyGridMag = psMetadataLookupF32 (&mdok, recipe, "GALAXY.GRID.MAG"); // peak flux of fakes 23 25 … … 42 44 float expTime = psMetadataLookupF32(&mdok, recipe, "EXPTIME"); // Exposure time 43 45 float zp = psMetadataLookupF32(&mdok, recipe, "ZEROPOINT"); // Photometric zero point 44 //float seeing = psMetadataLookupF32(&mdok, recipe, "SEEING"); // Seeing sigma (pix)46 float seeing = psMetadataLookupF32(&mdok, recipe, "SEEING"); // Seeing sigma (pix) 45 47 float scale = psMetadataLookupF32(&mdok, recipe, "PIXEL.SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel) 46 48 float skyRate = psMetadataLookupF32(&mdok, recipe, "SKY.RATE"); // Sky rate … … 150 152 galaxy->theta = (galaxyThetaMin + rndValue * galaxyThetaSlope); 151 153 152 bool sersicType = false; 153 sersicType |= (type == pmModelClassGetType ("PS_MODEL_SERSIC")); 154 sersicType |= (type == pmModelClassGetType ("PS_MODEL_EXP")); 155 sersicType |= (type == pmModelClassGetType ("PS_MODEL_DEV")); 156 if (sersicType) { 157 if (type == pmModelClassGetType ("PS_MODEL_DEV")) index = 4.0; 158 if (type == pmModelClassGetType ("PS_MODEL_EXP")) index = 1.0; 159 160 // for a sersic model, 161 float bn = 1.9992*index - 0.3271; 162 float Io = exp(bn); 163 164 // the integral of a Sersic has an analytical form as follows: 165 float logGamma = lgamma(2.0*index); 166 float bnFactor = pow(bn, 2.0*index); 167 float norm = 2.0 * M_PI * PS_SQR(galaxy->Rmaj) * index * Io * exp(logGamma) / bnFactor; 168 169 // XXX probably should limit the allowed thinness of a galaxy 170 galaxy->peak = galaxyGridFlux / norm / (galaxy->Rmin / galaxy->Rmaj); 171 } else { 172 galaxy->peak = galaxyGridPeak; 173 } 154 galaxy->flux = galaxyGridFlux; 155 ppSimSetGalaxyPeak (galaxy, type, index, seeing); 174 156 175 157 // if (0) { … … 206 188 galaxy->theta = (psRandomUniform(rng) * galaxyThetaSlope + galaxyThetaMin); 207 189 208 bool sersicType = false; 209 sersicType |= (type == pmModelClassGetType ("PS_MODEL_SERSIC")); 210 sersicType |= (type == pmModelClassGetType ("PS_MODEL_EXP")); 211 sersicType |= (type == pmModelClassGetType ("PS_MODEL_DEV")); 212 if (sersicType) { 213 if (type == pmModelClassGetType ("PS_MODEL_DEV")) index = 4.0; 214 if (type == pmModelClassGetType ("PS_MODEL_EXP")) index = 1.0; 215 216 // for a sersic model, 217 float bn = 1.9992*index - 0.3271; 218 float Io = exp(bn); 219 220 // the integral of a Sersic has an analytical form as follows: 221 float logGamma = lgamma(2.0*index); 222 float bnFactor = pow(bn, 2.0*index); 223 float norm = 2.0 * M_PI * PS_SQR(galaxy->Rmaj) * index * Io * exp(logGamma) / bnFactor; 224 225 // XXX probably should limit the allowed thinness of a galaxy 226 float galaxyMag = PS_MIN (faintMag, PS_MAX (brightMag, (log10((i + 1.0) / normScale) / galaxyAlpha))); 227 228 galaxy->flux = ppSimMagToFlux (galaxyMag, zp) * expTime; 229 galaxy->peak = galaxy->flux / norm / (galaxy->Rmin / galaxy->Rmaj); 230 } 190 // XXX probably should limit the allowed thinness of a galaxy 191 float galaxyMag = PS_MIN (faintMag, PS_MAX (brightMag, (log10((i + 1.0) / normScale) / galaxyAlpha))); 192 193 galaxy->flux = ppSimMagToFlux (galaxyMag, zp) * expTime; 194 ppSimSetGalaxyPeak (galaxy, type, index, seeing); 231 195 232 196 if (1) { … … 239 203 return true; 240 204 } 205 206 bool ppSimSetGalaxyPeak (ppSimGalaxy *galaxy, pmModelType type, float index, float seeing) { 207 208 bool isSersicType = false; 209 if (type == pmModelClassGetType ("PS_MODEL_DEV")) { 210 index = 4.0; 211 isSersicType = true; 212 } 213 if (type == pmModelClassGetType ("PS_MODEL_EXP")) { 214 index = 1.0; 215 isSersicType = true; 216 } 217 if (type == pmModelClassGetType ("PS_MODEL_SERSIC")) { 218 isSersicType = true; 219 } 220 221 if (isSersicType) { 222 // for a sersic model, 223 float bn = 1.9992*index - 0.3271; 224 float Io = exp(bn); 225 226 // the integral of a Sersic has an analytical form as follows: 227 float logGamma = lgamma(2.0*index); 228 float bnFactor = pow(bn, 2.0*index); 229 float norm = 2.0 * M_PI * PS_SQR(galaxy->Rmaj) * index * Io * exp(logGamma) / bnFactor; 230 231 // XXX probably should limit the allowed thinness of a galaxy 232 galaxy->peak = galaxy->flux / norm / (galaxy->Rmin / galaxy->Rmaj); 233 return true; 234 } 235 236 if (type == pmModelClassGetType ("PS_MODEL_TRAIL")) { 237 // galaxy->Rmaj -> PM_PAR_LENGTH 238 // seeing -> PM_PAR_SIGMA 239 galaxy->Rmin = seeing / 2.35; // Rmin is used for sigma 240 galaxy->peak = galaxy->flux / (galaxy->Rmaj * galaxy->Rmin * 2.0 * sqrt(2.0 * M_PI)); 241 return true; 242 } 243 244 galaxy->peak = galaxy->flux / (2 * M_PI * galaxy->Rmaj * galaxy->Rmin); 245 return true; 246 }
Note:
See TracChangeset
for help on using the changeset viewer.
