IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 28, 2008, 1:20:29 PM (18 years ago)
Author:
beaumont
Message:

New plots for fixChips and CommonScale

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branch_20081011/psastro/src/psastroUtils.c

    r12806 r20443  
    2020
    2121    float pixelScaleUse = 1.0, pixelScale1 = 1.0,  pixelScale2 = 1.0,  pixelScale = 1.0;
     22    psVector *oldScale = psVectorAllocEmpty (fpa->chips->n, PS_TYPE_F32);
    2223
    2324    char *option = psMetadataLookupStr (NULL, recipe, "PSASTRO.COMMON.SCALE.OPTION");
    2425    if (option == NULL) {
    25         psError(PSASTRO_ERR_DATA, false, "no choice set for common scale option\n");
    26         return false;
     26        psError(PSASTRO_ERR_DATA, false, "no choice set for common scale option\n");
     27        return false;
    2728    }
    2829
    2930    bool useExternal = true;
     31    int nobj = 0;
    3032
    3133    // find the min or max scale chip
    3234    if (!strcasecmp (option, "MIN") || !strcasecmp (option, "MAX")) {
    3335
    34         bool useMax = !strcasecmp (option, "MAX");
    35         pixelScaleUse = (useMax) ? FLT_MIN : FLT_MAX;
    36 
    37         for (int i = 0; i < fpa->chips->n; i++) {
    38             pmChip *chip = fpa->chips->data[i];
    39             if (!chip->process || !chip->file_exists) { continue; }
    40             if (!chip->toFPA) { continue; }
    41 
    42             pixelScale1 = hypot (chip->toFPA->x->coeff[1][0], chip->toFPA->x->coeff[0][1]);
    43             pixelScale2 = hypot (chip->toFPA->y->coeff[1][0], chip->toFPA->y->coeff[0][1]);
    44             pixelScale = 0.5*(pixelScale1 + pixelScale2);
    45            
    46             pixelScaleUse = (useMax) ? PS_MAX (pixelScale, pixelScaleUse) : PS_MIN (pixelScale, pixelScaleUse);
    47         }
    48         useExternal = false;
    49     }
     36        bool useMax = !strcasecmp (option, "MAX");
     37        pixelScaleUse = (useMax) ? FLT_MIN : FLT_MAX;
     38
     39        for (int i = 0; i < fpa->chips->n; i++) {
     40            pmChip *chip = fpa->chips->data[i];
     41            if (!chip->process || !chip->file_exists) { continue; }
     42            if (!chip->toFPA) { continue; }
     43
     44            pixelScale1 = hypot (chip->toFPA->x->coeff[1][0], chip->toFPA->x->coeff[0][1]);
     45            pixelScale2 = hypot (chip->toFPA->y->coeff[1][0], chip->toFPA->y->coeff[0][1]);
     46            pixelScale = 0.5*(pixelScale1 + pixelScale2);
     47            oldScale->data.F32[nobj++] = pixelScale;
     48            pixelScaleUse = (useMax) ? PS_MAX (pixelScale, pixelScaleUse) : PS_MIN (pixelScale, pixelScaleUse);
     49        }
     50        useExternal = false;
     51        oldScale->n = nobj;
     52    }
     53
    5054
    5155    // rescale each chip by the reference scale
    5256    for (int i = 0; i < fpa->chips->n; i++) {
    53         pmChip *chip = fpa->chips->data[i];
    54         if (!chip->process || !chip->file_exists) { continue; }
    55         if (!chip->toFPA) { continue; }
    56 
    57         psPlaneTransform *toFPA = chip->toFPA;
    58         psPlaneTransform *fromFPA = chip->fromFPA;
    59            
    60         pixelScale1 = hypot (toFPA->x->coeff[1][0], toFPA->x->coeff[0][1]);
    61         pixelScale2 = hypot (toFPA->y->coeff[1][0], toFPA->y->coeff[0][1]);
    62 
    63         if (useExternal) {
    64             pixelScaleUse = getChipPixelScale (chip);
    65         }
    66 
    67         for (int i = 0; i <= toFPA->x->nX; i++) {
    68             for (int j = 0; j <= toFPA->x->nX; j++) {
    69                 toFPA->x->coeff[i][j] *= pixelScaleUse/pixelScale1;
    70                 toFPA->y->coeff[i][j] *= pixelScaleUse/pixelScale2;
    71                 fromFPA->x->coeff[i][j] *= pixelScale1/pixelScaleUse;
    72                 fromFPA->y->coeff[i][j] *= pixelScale2/pixelScaleUse;
    73             }
    74         }
     57        pmChip *chip = fpa->chips->data[i];
     58        if (!chip->process || !chip->file_exists) { continue; }
     59        if (!chip->toFPA) { continue; }
     60
     61        psPlaneTransform *toFPA = chip->toFPA;
     62        psPlaneTransform *fromFPA = chip->fromFPA;
     63
     64        pixelScale1 = hypot (toFPA->x->coeff[1][0], toFPA->x->coeff[0][1]);
     65        pixelScale2 = hypot (toFPA->y->coeff[1][0], toFPA->y->coeff[0][1]);
     66
     67        if (useExternal) {
     68            pixelScaleUse = getChipPixelScale (chip);
     69        }
     70
     71        for (int i = 0; i <= toFPA->x->nX; i++) {
     72            for (int j = 0; j <= toFPA->x->nX; j++) {
     73                toFPA->x->coeff[i][j] *= pixelScaleUse/pixelScale1;
     74                toFPA->y->coeff[i][j] *= pixelScaleUse/pixelScale2;
     75                fromFPA->x->coeff[i][j] *= pixelScale1/pixelScaleUse;
     76                fromFPA->y->coeff[i][j] *= pixelScale2/pixelScaleUse;
     77            }
     78        }
    7579
    7680    }
    7781    psastroMosaicSetAstrom (fpa);
     82    if (!useExternal) {
     83        psastroVisualPlotCommonScale (fpa, oldScale);
     84    }
     85    psFree (oldScale);
    7886    return true;
    7987}
Note: See TracChangeset for help on using the changeset viewer.