IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 18, 2006, 8:31:55 PM (20 years ago)
Author:
magnier
Message:

fixed handling of masks, fixed negative-radius errors in models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/objects/models/pmModel_QGAUSS.c

    r6864 r6899  
    2626    psF32 py = PAR[5]*Y;
    2727    psF32 z  = 0.5*PS_SQR(px) + 0.5*PS_SQR(py) + PAR[6]*X*Y;
     28    if (z <= 0) {
     29        if (deriv) {
     30            psF32 *dPAR = deriv->data.F32;
     31            dPAR[0] = 0.0;
     32            dPAR[1] = 0.0;
     33            dPAR[2] = 0.0;
     34            dPAR[3] = 0.0;
     35            dPAR[4] = 0.0;
     36            dPAR[5] = 0.0;
     37            dPAR[6] = 0.0;
     38            dPAR[7] = 0.0;
     39        }
     40        return(0.0);
     41    }
     42
    2843    psF32 zp = pow(z,1.25);
     44    if (isnan(zp))
     45        psAbort ("psMinLMM", "nan in zp");
    2946
    3047    psF32 r  = 1.0 / (1 + PAR[7]*z + z*zp);
     48    if (isnan(r))
     49        psAbort ("psMinLMM", "nan in r");
     50
    3151    // test: psF32 r  = 1.0 / (1 + PAR[7]*z + PS_SQR(z));
    3252    psF32 r1 = PAR[1]*r;
     
    111131psF64 pmModelFlux_QGAUSS(const psVector *params)
    112132{
    113     float f, norm, z;
     133    float z;
     134    float norm;
    114135
    115136    psF32 *PAR = params->data.F32;
     
    122143
    123144    // the area needs to be multiplied by the integral of f(z)
     145    // XXX this integral can be done faster and more accurately
    124146    norm = 0.0;
    125     for (z = 0.05; z < 50; z += 0.1) {
     147
     148    # define DZ 0.1
     149
     150    # if 0
     151
     152    float f;
     153for (z = 0.5*DZ; z < 50; z += DZ) {
    126154        f = 1.0 / (1 + PAR[7]*z + pow(z, 2.25));
    127155        // test: f = 1.0 / (1 + PAR[7]*z + PS_SQR(z));
    128156        norm += f;
    129157    }
    130     norm *= 0.1;
     158    norm *= DZ;
     159    # else
     160
     161        float f0 = 1.0;
     162    float f1, f2;
     163    for (z = DZ; z < 50; z += DZ) {
     164        f1 = 1.0 / (1 + PAR[7]*z + pow(z, 2.25));
     165        z += DZ;
     166        f2 = 1.0 / (1 + PAR[7]*z + pow(z, 2.25));
     167        norm += f0 + 4*f1 + f2;
     168        f0 = f2;
     169    }
     170    norm *= DZ / 3.0;
     171    # endif
    131172
    132173    psF64 Flux = PAR[1] * Area * norm;
Note: See TracChangeset for help on using the changeset viewer.