IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 26, 2011, 5:21:42 PM (15 years ago)
Author:
eugene
Message:

report the diff chisq as well as the residual chisq; truncate SVD at dynamic range of 1e10; fix the scaling process

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/psModules/src/imcombine/pmSubtractionMatch.c

    r30362 r30383  
    476476                        const psArray *sources, const char *stampsName,
    477477                        pmSubtractionKernelsType type, int size, int spatialOrder,
    478                         const psVector *isisWidths, const psVector *isisOrders,
     478                        psVector *isisWidths, const psVector *isisOrders,
    479479                        int inner, int ringsOrder, int binning, float penalty,
    480480                        bool optimum, const psVector *optFWHMs, int optOrder, float optThreshold,
     
    695695            // check on the kernel scaling -- if the kron-based radial moments are very different, adjust to match them
    696696            {
    697                 float fwhm1;
    698                 float fwhm2;
    699                 pmSubtractionGetFWHMs(&fwhm1, &fwhm2);
    700                 psAssert(isfinite(fwhm1), "fwhm 1 not set");
    701                 psAssert(isfinite(fwhm2), "fwhm 2 not set");
     697                // float fwhm1;
     698                // float fwhm2;
     699                // pmSubtractionGetFWHMs(&fwhm1, &fwhm2);
     700                // psAssert(isfinite(fwhm1), "fwhm 1 not set");
     701                // psAssert(isfinite(fwhm2), "fwhm 2 not set");
    702702
    703703                // XXX this is BAD: depends on the relationship below:
     
    706706                float radMoment1 = stamps->normWindow1 / 2.75;
    707707                float radMoment2 = stamps->normWindow2 / 2.75;
    708 
    709                 float maxFWHM = PS_MAX(fwhm1, fwhm2);
    710                 float maxRadial = PS_MAX(radMoment1, radMoment2);
     708                pmSubtractionParamsScale(NULL, NULL, isisWidths, radMoment1, radMoment2);
     709
     710                // float maxFWHM = PS_MAX(fwhm1, fwhm2);
     711                // float maxRadial = PS_MAX(radMoment1, radMoment2);
    711712               
    712713                // if (fabs(2.0*(maxFWHM - maxRadial)/(maxFWHM + maxRadial)) > 0.25) {
    713                 if (1) {
    714 
    715                     float scale = maxRadial / maxFWHM;
    716                     psLogMsg ("psModules.imcombine", PS_LOG_INFO, "Kron and FWHM scales are quite different, re-scale by %f to use Kron", scale);
    717                    
    718                     for (int i = 0; i < isisWidths->n; i++) {
    719                         isisWidths->data.F32[i] *= scale;
    720                     }
    721                 }
     714                // if (1) {
     715                //
     716                //     float scale = maxRadial / maxFWHM;
     717                //     psLogMsg ("psModules.imcombine", PS_LOG_INFO, "Kron and FWHM scales are quite different, re-scale by %f to use Kron", scale);
     718                //    
     719                //     for (int i = 0; i < isisWidths->n; i++) {
     720                //      isisWidths->data.F32[i] *= scale;
     721                //     }
     722                // }
    722723            }
    723724
     
    12521253}
    12531254
    1254 
    1255 bool pmSubtractionParamsScale(int *kernelSize, int *stampSize, psVector *widths,
    1256                               float scaleRef, float scaleMin, float scaleMax)
     1255static float scaleRefOption = NAN;
     1256static float scaleMinOption = NAN;
     1257static float scaleMaxOption = NAN;
     1258static bool  scaleOption = false;
     1259
     1260bool pmSubtractionParamScaleOptions(bool scale, float scaleRef, float scaleMin, float scaleMax) {
     1261
     1262    if (scale) {
     1263        PS_ASSERT_FLOAT_LARGER_THAN(scaleRef, 0.0, false);
     1264        PS_ASSERT_FLOAT_LARGER_THAN(scaleMin, 0.0, false);
     1265        PS_ASSERT_FLOAT_LARGER_THAN(scaleMax, 0.0, false);
     1266        PS_ASSERT_FLOAT_LARGER_THAN(scaleMax, scaleMin, false);
     1267    }
     1268
     1269    scaleRefOption = scaleRef;
     1270    scaleMinOption = scaleMin;
     1271    scaleMaxOption = scaleMax;
     1272    scaleOption = scale;
     1273   
     1274    return true;
     1275}
     1276
     1277bool pmSubtractionParamsScale(int *kernelSize, int *stampSize, psVector *widths, float fwhm1, float fwhm2)
    12571278{
    1258     PS_ASSERT_PTR_NON_NULL(kernelSize, false);
    1259     PS_ASSERT_PTR_NON_NULL(stampSize, false);
     1279    // PS_ASSERT_PTR_NON_NULL(kernelSize, false);
     1280    // PS_ASSERT_PTR_NON_NULL(stampSize, false);
    12601281    PS_ASSERT_VECTOR_NON_NULL(widths, false);
    12611282    PS_ASSERT_VECTOR_TYPE(widths, PS_TYPE_F32, false);
    1262     PS_ASSERT_FLOAT_LARGER_THAN(scaleRef, 0.0, false);
    1263     PS_ASSERT_FLOAT_LARGER_THAN(scaleMin, 0.0, false);
    1264     PS_ASSERT_FLOAT_LARGER_THAN(scaleMax, 0.0, false);
    1265     PS_ASSERT_FLOAT_LARGER_THAN(scaleMax, scaleMin, false);
    1266 
    1267     float fwhm1;
    1268     float fwhm2;
    1269 
    1270     pmSubtractionGetFWHMs(&fwhm1, &fwhm2);
    1271     psAssert(isfinite(fwhm1), "fwhm 1 not set");
    1272     psAssert(isfinite(fwhm2), "fwhm 2 not set");
     1283
     1284    if (!scaleOption) return true;
     1285
     1286    // pmSubtractionGetFWHMs(&fwhm1, &fwhm2);
     1287    // psAssert(isfinite(fwhm1), "fwhm 1 not set");
     1288    // psAssert(isfinite(fwhm2), "fwhm 2 not set");
    12731289   
    12741290    // float diff = sqrtf(PS_SQR(PS_MAX(fwhm1, fwhm2)) - PS_SQR(PS_MIN(fwhm1, fwhm2))); // Difference
    1275     float scale = PS_MAX(fwhm1, fwhm2) / scaleRef;      // Scaling factor
    1276 
    1277     if (isfinite(scaleMin) && scale < scaleMin) {
    1278         scale = scaleMin;
    1279     }
    1280     if (isfinite(scaleMax) && scale > scaleMax) {
    1281         scale = scaleMax;
     1291    float scale = PS_MAX(fwhm1, fwhm2) / scaleRefOption;      // Scaling factor
     1292
     1293    if (isfinite(scaleMinOption) && scale < scaleMinOption) {
     1294        scale = scaleMinOption;
     1295    }
     1296    if (isfinite(scaleMaxOption) && scale > scaleMaxOption) {
     1297        scale = scaleMaxOption;
    12821298    }
    12831299
     
    12851301        widths->data.F32[i] *= scale;
    12861302    }
    1287     *kernelSize = *kernelSize * scale + 0.5;
    1288     *stampSize = *stampSize * scale + 0.5;
    1289 
    1290     psLogMsg("psModules.imcombine", PS_LOG_INFO,
    1291              "Scaling kernel parameters by %f: %d %d", scale, *kernelSize, *stampSize);
     1303    if (kernelSize) {
     1304        *kernelSize = *kernelSize * scale + 0.5;
     1305    }
     1306    if (stampSize) {
     1307        *stampSize = *stampSize * scale + 0.5;
     1308    }
     1309
     1310    psLogMsg("psModules.imcombine", PS_LOG_INFO, "Scaling kernel parameters by %f", scale);
     1311    if (kernelSize) psLogMsg("psModules.imcombine", PS_LOG_INFO, " modified kernel size %d", *kernelSize);
     1312    if (stampSize) psLogMsg("psModules.imcombine", PS_LOG_INFO, " modified stamp size %d", *stampSize);
    12921313
    12931314    return true;
Note: See TracChangeset for help on using the changeset viewer.