Changeset 32159
- Timestamp:
- Aug 21, 2011, 10:46:36 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110710/ppSim/src
- Files:
-
- 3 edited
-
ppSimInsertGalaxies.c (modified) (1 diff)
-
ppSimInsertStars.c (modified) (1 diff)
-
ppSimMakeGalaxies.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110710/ppSim/src/ppSimInsertGalaxies.c
r31449 r32159 137 137 axes.minor = galaxy->Rmin; 138 138 axes.theta = galaxy->theta; 139 pmPSF_AxesToModel (PAR, axes );139 pmPSF_AxesToModel (PAR, axes, type); 140 140 psF64 Area = 2.0 * M_PI * axes.major * axes.minor; 141 141 -
branches/eam_branches/ipp-20110710/ppSim/src/ppSimInsertStars.c
r31449 r32159 117 117 // XXX set the mag & err values (should this be done in pmSourceFromModel?) 118 118 // XXX i should be applying the gain and the correct effective area 119 psEllipseAxes axes = pmPSF_ModelToAxes (model->params->data.F32, 20.0 );119 psEllipseAxes axes = pmPSF_ModelToAxes (model->params->data.F32, 20.0, model->type); 120 120 float Area = 2.0 * M_PI * axes.major * axes.minor; 121 121 -
branches/eam_branches/ipp-20110710/ppSim/src/ppSimMakeGalaxies.c
r31157 r32159 20 20 bool galaxyGridRandom = psMetadataLookupBool(&mdok, recipe, "GALAXY.GRID.RANDOM"); // Density of fakes 21 21 float galaxyGridPeak = psMetadataLookupF32 (&mdok, recipe, "GALAXY.GRID.PEAK"); // peak flux of fakes 22 float galaxyGridMag = psMetadataLookupF32 (&mdok, recipe, "GALAXY.GRID.MAG"); // peak flux of fakes 22 23 24 float galaxyGridXoff = psMetadataLookupF32 (&mdok, recipe, "GALAXY.GRID.XOFF"); // centroid offset 25 float galaxyGridYoff = psMetadataLookupF32 (&mdok, recipe, "GALAXY.GRID.YOFF"); // centroid offset 26 23 27 float galaxyRmajorMax = psMetadataLookupF32(&mdok, recipe, "GALAXY.RMAJOR.MAX"); // Density of fakes 24 28 float galaxyRmajorMin = psMetadataLookupF32(&mdok, recipe, "GALAXY.RMAJOR.MIN"); // Density of fakes … … 46 50 } 47 51 52 // determine the galaxy model 53 char *modelName = psMetadataLookupStr(&mdok, recipe, "GALAXY.MODEL"); // galaxy model name 54 pmModelType type = pmModelClassGetType (modelName); 55 if (type == -1) { 56 psError (PS_ERR_UNKNOWN, false, "invalid model name"); 57 return false; 58 } 59 48 60 if (galaxyDensity <= 0) return true; 49 61 … … 87 99 long num = expf(logf(norm) + galaxyLum * logf(faint)) + 0.5; 88 100 101 fprintf (stderr, "galaxy grid inst mag: %f\n", galaxyGridMag - zp - 2.5*log10(expTime)); 102 89 103 if (galaxyGrid) { 90 104 num = (int)(xSize / galaxyGridDX) * (int)(ySize / galaxyGridDY); … … 98 112 99 113 int i = 0; 100 float refNorm = 1.0;101 float ourNorm = 1.0;114 // float refNorm = 1.0; 115 // float ourNorm = 1.0; 102 116 103 117 for (long iy = 0.5*galaxyGridDY; iy < ySize; iy += galaxyGridDY) { … … 106 120 107 121 // make fpa center of distribution 108 galaxy->x = ix; 109 galaxy->y = iy; 110 galaxy->peak = galaxyGridPeak; 122 // center the galaxy peak on the center of a pixel 123 galaxy->x = ix + 0.5 + galaxyGridXoff; 124 galaxy->y = iy + 0.5 + galaxyGridYoff; 125 126 float galaxyGridFlux = expTime * powf(10.0, -0.4 * (galaxyGridMag - zp)); 111 127 112 128 // galaxyIndex from user should be for function of this form: exp(-r^(1/n)) … … 122 138 float scale = (galaxyRmajorMin + rndValue * galaxyRmajorSlope); 123 139 124 // for a sersic model,125 float bn = 1.9992*index - 0.3271;126 float fR = 1.0 / (sqrt(2.0) * pow (bn, index));127 float Io = exp(bn);128 129 140 galaxy->Rmaj = scale; 130 141 … … 135 146 galaxy->theta = (galaxyThetaMin + rndValue * galaxyThetaSlope); 136 147 137 if (i == 0) { 138 refNorm = Io*scale*scale; 139 } 140 ourNorm = refNorm / (Io*scale*scale); 141 galaxy->peak *= ourNorm; 142 143 if (0) { 144 fprintf (stderr, "Rmaj: %f, scale: %f, index: %f, bn: %f, Ro: %f, Io: %f, theta: %f\n", galaxy->Rmaj, scale, index, bn, fR, Io, galaxy->theta); 148 bool sersicType = false; 149 sersicType |= (type == pmModelClassGetType ("PS_MODEL_SERSIC")); 150 sersicType |= (type == pmModelClassGetType ("PS_MODEL_EXP")); 151 sersicType |= (type == pmModelClassGetType ("PS_MODEL_DEV")); 152 if (sersicType) { 153 if (type == pmModelClassGetType ("PS_MODEL_DEV")) index = 4.0; 154 if (type == pmModelClassGetType ("PS_MODEL_EXP")) index = 1.0; 155 156 // for a sersic model, 157 float bn = 1.9992*index - 0.3271; 158 float Io = exp(bn); 159 160 // the integral of a Sersic has an analytical form as follows: 161 float logGamma = lgamma(2.0*index); 162 float bnFactor = pow(bn, 2.0*index); 163 float norm = 2.0 * M_PI * PS_SQR(galaxy->Rmaj) * index * Io * exp(logGamma) / bnFactor; 164 165 // XXX probably should limit the allowed thinness of a galaxy 166 galaxy->peak = galaxyGridFlux / norm / (galaxy->Rmin / galaxy->Rmaj); 167 } else { 168 galaxy->peak = galaxyGridPeak; 145 169 } 170 171 // if (0) { 172 // fprintf (stderr, "Rmaj: %f, scale: %f, index: %f, bn: %f, Ro: %f, Io: %f, theta: %f\n", galaxy->Rmaj, scale, index, bn, fR, Io, galaxy->theta); 173 // } 146 174 147 175 psArrayAdd (galaxies, 100, galaxy);
Note:
See TracChangeset
for help on using the changeset viewer.
