Changeset 3666 for trunk/stac/src/stacScales.c
- Timestamp:
- Apr 5, 2005, 11:51:26 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/stac/src/stacScales.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/stac/src/stacScales.c
r3613 r3666 54 54 psVector **offsetsPtr, // Offsets to return 55 55 const psArray *images, // Images on which to measure the scales and offsets 56 const stacConfig *config // Configuration 56 const char *starFile, // File containing coordinates to photometer 57 const char *starMapFile, // Map for coodinates to the common output frame 58 float xMapDiff, float yMapDiff, // Difference from the map to apply (due to size difference) 59 float aper // Aperture to use for photometry (radius) 57 60 ) 58 61 { … … 60 63 assert(offsetsPtr); 61 64 assert(images); 62 assert(config);63 65 for (int i = 0; i < images->n; i++) { 64 66 psImage *image = images->data[i]; … … 99 101 100 102 // Now the scales 101 if ( config->starFile == NULL || config->starMapFile == NULL) {103 if (starFile == NULL || starMapFile == NULL) { 102 104 psLogMsg("stac.scales", PS_LOG_INFO, 103 105 "No coordinates available to set scales --- assuming all are identical.\n"); … … 108 110 } else { 109 111 // Read star coordinates and map 110 psArray *starCoords = stacReadCoords( config->starFile); // Array of star coordinates111 psPlaneTransform *starMap = stacReadMap( config->starMapFile); // Transformation for star coordinates112 psArray *starCoords = stacReadCoords(starFile); // Array of star coordinates 113 psPlaneTransform *starMap = stacReadMap(starMapFile); // Transformation for star coordinates 112 114 113 115 // Transform the stellar positions to match the transformed reference frame 114 116 psArray *starCoordsTransformed = psArrayAlloc(starCoords->n); // Transformed positions 115 117 // Fix up difference between map and output frame 116 starMap->x->coeff[0][0] -= config->xMapDiff;117 starMap->y->coeff[0][0] -= config->yMapDiff;118 starMap->x->coeff[0][0] -= xMapDiff; 119 starMap->y->coeff[0][0] -= yMapDiff; 118 120 for (int i = 0; i < starCoords->n; i++) { 119 121 starCoordsTransformed->data[i] = psPlaneTransformApply(NULL, starMap, starCoords->data[i]); … … 139 141 psPlane *coords = starCoordsTransformed->data[j]; // The coordinates of the star 140 142 141 if (coords->x < config->aper || coords->y < config->aper ||142 coords->x + config->aper > image->numCols - 1 ||143 coords->y + config->aper > image->numRows) {143 if (coords->x < aper || coords->y < aper || 144 coords->x + aper > image->numCols - 1 || 145 coords->y + aper > image->numRows) { 144 146 mask->data.U8[j] = 1; 145 147 } else { … … 147 149 float sum = 0.0; 148 150 int numPix = 0; 149 float aper2 = SQUARE( config->aper);150 for (int y = (int)floorf(coords->y - config->aper);151 y <= (int)ceilf(coords->y + config->aper); y++) {152 for (int x = (int)floorf(coords->x - config->aper);153 x <= (int)ceilf(coords->x + config->aper); x++) {151 float aper2 = SQUARE(aper); 152 for (int y = (int)floorf(coords->y - aper); 153 y <= (int)ceilf(coords->y + aper); y++) { 154 for (int x = (int)floorf(coords->x - aper); 155 x <= (int)ceilf(coords->x + aper); x++) { 154 156 if (SQUARE((float)x + 0.5 - coords->x) + SQUARE((float)y + 0.5 - coords->y) <= 155 157 aper2) { … … 198 200 } 199 201 200 // Change the saturation and bad values201 psVector *saturated = config->saturated; // Saturation limits202 psVector *bad = config->bad; // Bad limits203 for (int i = 0; i < saturated->n; i++) {204 saturated->data.F32[i] = (saturated->data.F32[i] - offsets->data.F32[i]) / scales->data.F32[i];205 bad->data.F32[i] = (bad->data.F32[i] - offsets->data.F32[i]) / scales->data.F32[i];206 }207 208 202 return true; 209 203 }
Note:
See TracChangeset
for help on using the changeset viewer.
