IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20804


Ignore:
Timestamp:
Nov 19, 2008, 3:27:29 PM (17 years ago)
Author:
eugene
Message:

check for valid data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastroUtils.c

    r12806 r20804  
    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            if (chip->cells->n == 0) { continue; }
     45            pmCell *cell = chip->cells->data[0];
     46            if (!cell->process || !cell->file_exists) { continue; }
     47
     48            if (cell->readouts->n == 0) { continue; }
     49            pmReadout *readout = cell->readouts->data[0];
     50            if (! readout->data_exists) { continue; }
     51
     52            pixelScale1 = hypot (chip->toFPA->x->coeff[1][0], chip->toFPA->x->coeff[0][1]);
     53            pixelScale2 = hypot (chip->toFPA->y->coeff[1][0], chip->toFPA->y->coeff[0][1]);
     54            pixelScale = 0.5*(pixelScale1 + pixelScale2);
     55            oldScale->data.F32[nobj++] = pixelScale;
     56            pixelScaleUse = (useMax) ? PS_MAX (pixelScale, pixelScaleUse) : PS_MIN (pixelScale, pixelScaleUse);
     57        }
     58        useExternal = false;
     59        oldScale->n = nobj;
     60    }
     61
    5062
    5163    // rescale each chip by the reference scale
    5264    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         }
    75 
     65        pmChip *chip = fpa->chips->data[i];
     66        if (!chip->process || !chip->file_exists) { continue; }
     67        if (!chip->toFPA) { continue; }
     68
     69        psPlaneTransform *toFPA = chip->toFPA;
     70        psPlaneTransform *fromFPA = chip->fromFPA;
     71
     72        pixelScale1 = hypot (toFPA->x->coeff[1][0], toFPA->x->coeff[0][1]);
     73        pixelScale2 = hypot (toFPA->y->coeff[1][0], toFPA->y->coeff[0][1]);
     74
     75        if (useExternal) {
     76            pixelScaleUse = getChipPixelScale (chip);
     77        }
     78
     79        for (int i = 0; i <= toFPA->x->nX; i++) {
     80            for (int j = 0; j <= toFPA->x->nX; j++) {
     81                toFPA->x->coeff[i][j] *= pixelScaleUse/pixelScale1;
     82                toFPA->y->coeff[i][j] *= pixelScaleUse/pixelScale2;
     83                fromFPA->x->coeff[i][j] *= pixelScale1/pixelScaleUse;
     84                fromFPA->y->coeff[i][j] *= pixelScale2/pixelScaleUse;
     85            }
     86        }
    7687    }
    7788    psastroMosaicSetAstrom (fpa);
     89    if (!useExternal) {
     90        psastroVisualPlotCommonScale (fpa, oldScale);
     91    }
     92    psFree (oldScale);
    7893    return true;
    7994}
Note: See TracChangeset for help on using the changeset viewer.