IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 28, 2009, 6:49:00 PM (17 years ago)
Author:
Paul Price
Message:

Can write FITS images.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSkycell/src/ppSkycellLoop.c

    r23992 r23996  
    1010
    1111#define BUFFER 16                       // Size of buffer for projections
    12 
    13 // List of input files
    14 static const char *inFiles[] = { "PPSKYCELL.IMAGE", "PPSKYCELL.MASK", NULL };
    15 
    16 // List of output files
    17 //static const char *outFiles[] = { "PPSKYCELL.JPEG1", "PPSKYCELL.JPEG2", NULL };
    18 
    1912
    2013static void regionMinMax(psRegion *base,// Base region; modified
     
    4134    fromCoords->y = (Y); \
    4235    psPlaneTransformApply(toCoords, wcs->trans, fromCoords); \
     36    toCoords->x /= wcs->cdelt1; \
     37    toCoords->y /= wcs->cdelt2; \
    4338    toCoords->x += wcs->crpix1; \
    4439    toCoords->y += wcs->crpix2; \
     
    137132
    138133    for (int i = 0; i < data->numInputs; i++) {
    139         pmFPAfile *file = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.INPUT", i); // File to examine
     134        pmFPAfile *file = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.IMAGE", i); // File to examine
    140135        // Header in the FPA should have been read as a part of defining the file...
    141136#if 0
     
    157152
    158153        psRegion *region = imageRegions->data[i] = skycellRegion(wcs, numCols, numRows); // Region of image
     154        psTrace("ppSkycell", 5, "Image region %d is: [%.0f:%.0f,%.0f:%.0f]\n",
     155                i, region->x0, region->x1, region->y0, region->y1);
    159156
    160157        bool found = false;             // Found a projection?
    161158        for (int j = 0; j < numProj && !found; j++) {
    162             if (wcs->crval1 == crval1->data.F64[j] &&
    163                 wcs->crval2 == crval2->data.F64[j] &&
    164                 wcs->cdelt1 == cdelt1->data.F64[j] &&
    165                 wcs->cdelt2 == cdelt1->data.F64[j]) {
     159            if (wcs->crval1 == crval1->data.F64[j] && wcs->crval2 == crval2->data.F64[j] &&
     160                wcs->cdelt1 == cdelt1->data.F64[j] && wcs->cdelt2 == cdelt1->data.F64[j]) {
    166161                regionMinMax(projRegions->data[j], region);
    167162                target->data.S32[i] = j;
    168                 skycellRegion(wcs, numCols, numRows);
    169163                found = true;
     164                psTrace("ppSkycell", 3, "Image %d uses projection %d\n", i, j);
    170165            }
    171166        }
     
    176171            psVectorAppend(cdelt1, wcs->cdelt1);
    177172            psVectorAppend(cdelt2, wcs->cdelt2);
    178             psArrayAdd(projRegions, projRegions->n, region);
     173            psRegion *projRegion = psRegionAlloc(region->x0, region->x1, region->y0, region->y1);
     174            psArrayAdd(projRegions, projRegions->n, projRegion);
     175            psFree(projRegion);
    179176            target->data.S32[i] = numProj;
     177            psTrace("ppSkycell", 3, "Image %d uses new projection\n", i);
    180178
    181179            numProj++;
     
    187185    for (int i = 0; i < numProj; i++) {
    188186        psRegion *projRegion = projRegions->data[i]; // Region for skycell projection
    189         int xSize = projRegion->x1 - projRegion->x0; // Size of unbinned image
    190         int ySize = projRegion->y1 - projRegion->y0; // Size of unbinned image
     187        int xSize = projRegion->x1 - projRegion->x0 + 1; // Size of unbinned image
     188        int ySize = projRegion->y1 - projRegion->y0 + 1; // Size of unbinned image
    191189        // Size of binned image 1
    192         int numCols1 = xSize / (float)data->bin1 + 0.5, numRows1 = ySize / (float)data->bin1 + 0.5;
     190        int numCols1 = xSize / (float)data->bin1 + 1.5, numRows1 = ySize / (float)data->bin1 + 1.5;
    193191        // Size of binned image 2
    194         int numCols2 = numCols1 / (float)data->bin2 + 0.5, numRows2 = numRows2 / (float)data->bin1 + 0.5;
     192        int numCols2 = numCols1 / (float)data->bin2 + 1.5, numRows2 = numRows1 / (float)data->bin2 + 1.5;
    195193
    196194        psImage *image1 = psImageAlloc(numCols1, numRows1, PS_TYPE_F32); // Binned image
     
    204202            }
    205203
    206             fileActivationSingle(data->config, inFiles, true, j);
     204            pmFPAfileActivateSingle(data->config->files, true, "PPSKYCELL.IMAGE", j);
     205            if (data->masksName) {
     206                pmFPAfileActivateSingle(data->config->files, true, "PPSKYCELL.MASK", j);
     207            }
     208
    207209            pmFPAview *view = filesIterateDown(data->config); // View to readout
    208210            if (!view) {
     
    230232            psRegion *imageRegion = imageRegions->data[j]; // Region for image
    231233            // Offsets for image on skycell
    232             int xOffset1 = (imageRegion->x0 - projRegion->x0) / (float)data->bin1 + 0.5;
    233             int yOffset1 = (imageRegion->y0 - projRegion->y0) / (float)data->bin1 + 0.5;
    234             int xOffset2 = xOffset1 / (float)data->bin2 + 0.5, yOffset2 = yOffset1 / (float)data->bin2 + 0.5;
     234            int xOffset1 = (imageRegion->x0 - projRegion->x0) / (float)data->bin1;
     235            int yOffset1 = (imageRegion->y0 - projRegion->y0) / (float)data->bin1;
     236            int xOffset2 = xOffset1 / (float)data->bin2, yOffset2 = yOffset1 / (float)data->bin2;
    235237
    236238            // XXX Completely neglecting rotations
     
    242244            psFree(bin2RO);
    243245            filesIterateUp(data->config);
     246            psFree(file->fpa);
     247            file->fpa = NULL;
     248            pmFPAfileActivate(data->config->files, false, NULL);
     249
     250            psTrace("ppSkycell", 10, "Blah blah blah\n");
    244251        }
    245252
Note: See TracChangeset for help on using the changeset viewer.