IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 19, 2013, 6:42:58 AM (13 years ago)
Author:
eugene
Message:

add some sersic support functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130711/ppSim/src/ppSimMakeGalaxies.c

    r34261 r35970  
    204204}
    205205
     206float pmSersicNorm (float index) {
     207
     208    float C0 = NAN;
     209    float C1 = NAN;
     210    float C2 = NAN;
     211
     212    // y = 0.201545 x^0 -0.950965 x^1 -0.315248 x^2
     213    // y = 0.402084 x^0 -1.357775 x^1 -0.105102 x^2
     214    // y = 0.619093 x^0 -1.591674 x^1 -0.041576 x^2
     215    // y = 0.770263 x^0 -1.696421 x^1 -0.023363 x^2
     216    // y = 0.885891 x^0 -1.755684 x^1 -0.015753 x^2
     217
     218    if ((index >= 0.0) && (index < 1.0)) {
     219        C0 = 0.201545; C1 = -0.950965; C2 = -0.315248;
     220        // y = 0.201545 x^0 -0.950965 x^1 -0.315248 x^2
     221    }
     222    if ((index >= 1.0) && (index < 2.0)) {
     223        C0 = 0.402084; C1 = -1.357775; C2 = -0.105102;
     224        // y = 0.402084 x^0 -1.357775 x^1 -0.105102 x^2
     225    }
     226    if ((index >= 2.0) && (index < 3.0)) {
     227        C0 = 0.619093; C1 = -1.591674; C2 = -0.041576;
     228        // y = 0.619093 x^0 -1.591674 x^1 -0.041576 x^2
     229    }
     230    if ((index >= 3.0) && (index < 4.0)) {
     231        C0 = 0.770263; C1 = -1.696421; C2 = -0.023363;
     232        // y = 0.770263 x^0 -1.696421 x^1 -0.023363 x^2
     233    }
     234    if ((index >= 4.0) && (index < 5.5)) {
     235        C0 = 0.885891; C1 = -1.755684; C2 = -0.015753;
     236        // y = 0.885891 x^0 -1.755684 x^1 -0.015753 x^2
     237    }
     238
     239    if (isnan(C0)) return NAN;
     240
     241    float lnorm = C0 + C1*index + C2*index*index;
     242    float norm = exp(lnorm);
     243    return norm;
     244}
     245
    206246bool ppSimSetGalaxyPeak (ppSimGalaxy *galaxy, pmModelType type, float index, float seeing) {
    207247
     
    219259    }
    220260
     261    // exponential
     262    // f = I0 exp (sqrt(z)) (index = 1.0)
     263
     264    // f = I0 exp (-0.5*z)
     265
    221266    if (isSersicType) {
    222267        // for a sersic model,
    223         float bn = 1.9992*index - 0.3271;
    224         float Io = exp(bn);
     268        // float bn = 1.9992*index - 0.3271;
     269        // float Io = exp(bn);
    225270                   
    226271        // 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;
     272        // float logGamma = lgamma(2.0*index);
     273        // float bnFactor = pow(bn, 2.0*index);
     274        // float norm = 2.0 * M_PI * PS_SQR(galaxy->Rmaj) * index * Io * exp(logGamma) / bnFactor;
    230275                   
     276        // find the flux of a sersic with peak = 1.0:
     277        float norm = pmSersicNorm (index);
     278        float flux = 2.0 * M_PI * galaxy->Rmaj * galaxy->Rmin * norm;
     279
    231280        // XXX probably should limit the allowed thinness of a galaxy
    232         galaxy->peak = galaxy->flux / norm / (galaxy->Rmin / galaxy->Rmaj);
     281        galaxy->peak = galaxy->flux / flux;
    233282        return true;
    234283    }
Note: See TracChangeset for help on using the changeset viewer.