Changeset 20443 for branches/cnb_branch_20081011/psastro/src/psastroUtils.c
- Timestamp:
- Oct 28, 2008, 1:20:29 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branch_20081011/psastro/src/psastroUtils.c
r12806 r20443 20 20 21 21 float pixelScaleUse = 1.0, pixelScale1 = 1.0, pixelScale2 = 1.0, pixelScale = 1.0; 22 psVector *oldScale = psVectorAllocEmpty (fpa->chips->n, PS_TYPE_F32); 22 23 23 24 char *option = psMetadataLookupStr (NULL, recipe, "PSASTRO.COMMON.SCALE.OPTION"); 24 25 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; 27 28 } 28 29 29 30 bool useExternal = true; 31 int nobj = 0; 30 32 31 33 // find the min or max scale chip 32 34 if (!strcasecmp (option, "MIN") || !strcasecmp (option, "MAX")) { 33 35 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 50 54 51 55 // rescale each chip by the reference scale 52 56 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 } 75 79 76 80 } 77 81 psastroMosaicSetAstrom (fpa); 82 if (!useExternal) { 83 psastroVisualPlotCommonScale (fpa, oldScale); 84 } 85 psFree (oldScale); 78 86 return true; 79 87 }
Note:
See TracChangeset
for help on using the changeset viewer.
