IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32159


Ignore:
Timestamp:
Aug 21, 2011, 10:46:36 AM (15 years ago)
Author:
eugene
Message:

set model flux for sersic-like models using analytical form; use GRID.PEAK for non-sersic like models; galaxy model flux should now be (nearly) exact

Location:
branches/eam_branches/ipp-20110710/ppSim/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110710/ppSim/src/ppSimInsertGalaxies.c

    r31449 r32159  
    137137        axes.minor       = galaxy->Rmin;
    138138        axes.theta       = galaxy->theta;
    139         pmPSF_AxesToModel (PAR, axes);
     139        pmPSF_AxesToModel (PAR, axes, type);
    140140        psF64 Area = 2.0 * M_PI * axes.major * axes.minor;
    141141
  • branches/eam_branches/ipp-20110710/ppSim/src/ppSimInsertStars.c

    r31449 r32159  
    117117        // XXX set the mag & err values (should this be done in pmSourceFromModel?)
    118118        // 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);
    120120        float Area = 2.0 * M_PI * axes.major * axes.minor;
    121121
  • branches/eam_branches/ipp-20110710/ppSim/src/ppSimMakeGalaxies.c

    r31157 r32159  
    2020    bool galaxyGridRandom = psMetadataLookupBool(&mdok, recipe, "GALAXY.GRID.RANDOM"); // Density of fakes
    2121    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
    2223   
     24    float galaxyGridXoff  = psMetadataLookupF32 (&mdok, recipe, "GALAXY.GRID.XOFF"); // centroid offset
     25    float galaxyGridYoff  = psMetadataLookupF32 (&mdok, recipe, "GALAXY.GRID.YOFF"); // centroid offset
     26
    2327    float galaxyRmajorMax = psMetadataLookupF32(&mdok, recipe, "GALAXY.RMAJOR.MAX"); // Density of fakes
    2428    float galaxyRmajorMin = psMetadataLookupF32(&mdok, recipe, "GALAXY.RMAJOR.MIN"); // Density of fakes
     
    4650    }
    4751
     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
    4860    if (galaxyDensity <= 0) return true;
    4961
     
    8799    long num = expf(logf(norm) + galaxyLum * logf(faint)) + 0.5;
    88100
     101    fprintf (stderr, "galaxy grid inst mag: %f\n", galaxyGridMag - zp - 2.5*log10(expTime));
     102
    89103    if (galaxyGrid) {
    90104        num = (int)(xSize / galaxyGridDX) * (int)(ySize / galaxyGridDY);
     
    98112
    99113        int i = 0;
    100         float refNorm = 1.0;
    101         float ourNorm = 1.0;
     114        // float refNorm = 1.0;
     115        // float ourNorm = 1.0;
    102116
    103117        for (long iy = 0.5*galaxyGridDY; iy < ySize; iy += galaxyGridDY) {
     
    106120
    107121                // 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));
    111127
    112128                // galaxyIndex from user should be for function of this form: exp(-r^(1/n))
     
    122138                float scale = (galaxyRmajorMin + rndValue * galaxyRmajorSlope);
    123139
    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 
    129140                galaxy->Rmaj  = scale;
    130141
     
    135146                galaxy->theta = (galaxyThetaMin  + rndValue * galaxyThetaSlope);
    136147               
    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;
    145169                }
     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                // }
    146174
    147175                psArrayAdd (galaxies, 100, galaxy);
Note: See TracChangeset for help on using the changeset viewer.