IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6838


Ignore:
Timestamp:
Apr 11, 2006, 6:10:52 PM (20 years ago)
Author:
Paul Price
Message:

Fixing X0,Y0 problems from binning when doing a copy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/astrom/pmFPACopy.c

    r6828 r6838  
    366366}
    367367
     368
     369static pmHDU *findPHU(const pmCell *cell// The cell for which to find the PHU
     370                     )
     371{
     372    if (cell->hdu && cell->hdu->phu) {
     373        return cell->hdu;
     374    }
     375    pmChip *chip = cell->parent;        // The parent chip
     376    if (chip->hdu && chip->hdu->phu) {
     377        return chip->hdu;
     378    }
     379    pmFPA *fpa = chip->parent;  // The parent FPA
     380    if (fpa->hdu && fpa->hdu->phu) {
     381        return fpa->hdu;
     382    }
     383
     384    psError(PS_ERR_IO, true, "Unable to find PHU for target cell.\n");
     385    return NULL;
     386}
     387
     388
     389static bool copyPHU(pmCell *targetCell, // The target cell
     390                    pmCell *sourceCell  // The source cell
     391                   )
     392{
     393    // Find the respective PHUs
     394    pmHDU *targetPHU = findPHU(targetCell); // The target PHU
     395    if (targetPHU->header) {
     396        return false;                   // No work required
     397    }
     398    // Copy the header over
     399    pmHDU *sourcePHU = findPHU(sourceCell); // The source PHU
     400    targetPHU->header = psMetadataCopy(NULL, sourcePHU->header);
     401    return true;
     402}
     403
     404
    368405//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    369406// File-static engine functions --- these do all the work.  Actually, cellCopy does all the work; the others
     
    371408//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    372409
    373 static int cellCopy(pmCell *target,          // The target cell
    374                     pmCell *source,           // The source cell, to be copied
    375                     bool pixels,             // Copy the pixels?
    376                     int xBin, int yBin       // (Relative) binning factors in x and y
     410static int cellCopy(pmCell *target,     // The target cell
     411                    pmCell *source,     // The source cell, to be copied
     412                    bool pixels,        // Copy the pixels?
     413                    int xBin, int yBin  // (Relative) binning factors in x and y
    377414                   )
    378415{
     
    396433        hdu->header = psMetadataAlloc();
    397434    }
     435    // Copy the PHU over as well, if required
     436    copyPHU(target, source);
    398437
    399438    // Need to check/change CELL.XPARITY and CELL.YPARITY
     
    485524        int xZero = psMetadataLookupS32(NULL, source->concepts, "CELL.X0"); // CELL.X0 from source
    486525        int xParity = psMetadataLookupS32(NULL, target->concepts, "CELL.XPARITY"); // Parity in x
    487         pmReadout *readout = target->readouts->data[0]; // A representative readout
     526        int xBin = psMetadataLookupS32(NULL, source->concepts, "CELL.XBIN"); // CELL.XBIN from source
     527        pmReadout *readout = source->readouts->data[0]; // A representative readout
    488528        psTrace(__func__, 3, "CELL.X0: Before: %d After: %d\n", xZero,
    489                 xZero - (readout->image->numCols - 1) * xParity);
    490         xZero -= (readout->image->numCols - 1) * xParity; // Change the parity on the X0 position
     529                xZero - (readout->image->numCols - 1) * xParity * xBin);
     530        psTrace(__func__, 9, "(xParity: %d xBin: %d numCols: %d)\n", xParity, xBin, readout->image->numCols);
     531        xZero -= (readout->image->numCols - 1) * xParity * xBin; // Change the parity on the X0 position
    491532        psMetadataItem *newItem = psMetadataLookup(target->concepts, "CELL.X0"); // CELL.X0 from target
    492533        newItem->data.S32 = xZero;
     
    495536        int yZero = psMetadataLookupS32(NULL, source->concepts, "CELL.Y0"); // CELL.Y0 from source
    496537        int yParity = psMetadataLookupS32(NULL, target->concepts, "CELL.YPARITY"); // Parity in y
    497         pmReadout *readout = target->readouts->data[0]; // A representative readout
     538        int yBin = psMetadataLookupS32(NULL, source->concepts, "CELL.YBIN"); // Parity in y
     539        pmReadout *readout = source->readouts->data[0]; // A representative readout
    498540        psTrace(__func__, 3, "CELL.Y0: Before: %d After: %d\n", yZero,
    499                 yZero - (readout->image->numCols - 1) * yParity);
    500         yZero -= (readout->image->numCols - 1) * yParity; // Change the parity on the Y0 position
     541                yZero - (readout->image->numRows - 1) * yParity * yBin);
     542        psTrace(__func__, 9, "(yParity: %d yBin: %d numRows: %d)\n", yParity, yBin, readout->image->numRows);
     543        yZero -= (readout->image->numRows - 1) * yParity * yBin; // Change the parity on the Y0 position
    501544        psMetadataItem *newItem = psMetadataLookup(target->concepts, "CELL.Y0"); // CELL.Y0 from target
    502545        newItem->data.S32 = yZero;
Note: See TracChangeset for help on using the changeset viewer.