Changeset 20804
- Timestamp:
- Nov 19, 2008, 3:27:29 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroUtils.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroUtils.c
r12806 r20804 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 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 50 62 51 63 // rescale each chip by the reference scale 52 64 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 } 76 87 } 77 88 psastroMosaicSetAstrom (fpa); 89 if (!useExternal) { 90 psastroVisualPlotCommonScale (fpa, oldScale); 91 } 92 psFree (oldScale); 78 93 return true; 79 94 }
Note:
See TracChangeset
for help on using the changeset viewer.
