IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 5, 2005, 11:51:26 AM (21 years ago)
Author:
Paul Price
Message:

Removing stac-specific configuration out of functions so that I can use them in other programs. Program appears to work as it did before.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/stac/src/stacScales.c

    r3613 r3666  
    5454                psVector **offsetsPtr,  // Offsets to return
    5555                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)
    5760    )
    5861{
     
    6063    assert(offsetsPtr);
    6164    assert(images);
    62     assert(config);
    6365    for (int i = 0; i < images->n; i++) {
    6466        psImage *image = images->data[i];
     
    99101
    100102    // Now the scales
    101     if (config->starFile == NULL || config->starMapFile == NULL) {
     103    if (starFile == NULL || starMapFile == NULL) {
    102104        psLogMsg("stac.scales", PS_LOG_INFO,
    103105                 "No coordinates available to set scales --- assuming all are identical.\n");
     
    108110    } else {
    109111        // Read star coordinates and map
    110         psArray *starCoords = stacReadCoords(config->starFile); // Array of star coordinates
    111         psPlaneTransform *starMap = stacReadMap(config->starMapFile); // Transformation for star coordinates
     112        psArray *starCoords = stacReadCoords(starFile); // Array of star coordinates
     113        psPlaneTransform *starMap = stacReadMap(starMapFile); // Transformation for star coordinates
    112114
    113115        // Transform the stellar positions to match the transformed reference frame
    114116        psArray *starCoordsTransformed = psArrayAlloc(starCoords->n); // Transformed positions
    115117        // 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;
    118120        for (int i = 0; i < starCoords->n; i++) {
    119121            starCoordsTransformed->data[i] = psPlaneTransformApply(NULL, starMap, starCoords->data[i]);
     
    139141                psPlane *coords = starCoordsTransformed->data[j]; // The coordinates of the star
    140142               
    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) {
    144146                    mask->data.U8[j] = 1;
    145147                } else {
     
    147149                    float sum = 0.0;
    148150                    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++) {
    154156                            if (SQUARE((float)x + 0.5 - coords->x) + SQUARE((float)y + 0.5 - coords->y) <=
    155157                                aper2) {
     
    198200    }
    199201
    200     // Change the saturation and bad values
    201     psVector *saturated = config->saturated; // Saturation limits
    202     psVector *bad = config->bad;        // Bad limits
    203     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 
    208202    return true;
    209203}
Note: See TracChangeset for help on using the changeset viewer.