IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7606


Ignore:
Timestamp:
Jun 20, 2006, 11:10:29 PM (20 years ago)
Author:
Paul Price
Message:

Check X0,Y0,XBIN,YBIN,XPARITY,YPARITY for target; if these are set, mosaic to the target requirements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAMosaic.c

    r7605 r7606  
    447447    // Set up the image
    448448    // Since both upper and lower values are inclusive, we need to add one to the size
    449     float xSize = (float)(xMax - xMin + 1) / (float)xBinTarget;
     449    float xSize = (float)(xMax + 1) / (float)xBinTarget;
    450450    if (xSize - (int)xSize > 0) {
    451451        xSize += 1;
    452452    }
    453     float ySize = (float)(yMax - yMin + 1) / (float)yBinTarget;
     453    float ySize = (float)(yMax + 1) / (float)yBinTarget;
    454454    if (ySize - (int)ySize > 0) {
    455455        ySize += 1;
     
    629629                    int *xBinMin,       // The minimum x binning, returned
    630630                    int *yBinMin,       // The minimum y binning, returned
    631                     bool chipStuff      // Worry about chip stuff as well?
     631                    bool chipStuff,      // Worry about chip stuff as well?
     632                    int x0Target, int y0Target, // Target x0 and y0 offsets
     633                    int xParityTarget, int yParityTarget // Target parities
    632634                   )
    633635{
     
    743745
    744746    // Set the flips on the basis of the parity
    745     if (xParityCell * xParityChip == -1) {
     747    if (xParityCell * xParityChip == xParityTarget) {
     748        xFlip->data.U8[index] = 0;
     749    } else {
    746750        xFlip->data.U8[index] = 1;
     751    }
     752    if (yParityCell * yParityChip == yParityTarget) {
     753        yFlip->data.U8[index] = 0;
    747754    } else {
    748         xFlip->data.U8[index] = 0;
    749     }
    750     if (yParityCell * yParityChip == -1) {
    751755        yFlip->data.U8[index] = 1;
    752     } else {
    753         yFlip->data.U8[index] = 0;
    754     }
    755 
    756     x0->data.S32[index] = x0Chip + x0Cell;
    757     y0->data.S32[index] = y0Chip + y0Cell;
     756    }
     757
     758    x0->data.S32[index] = x0Chip + x0Cell - x0Target;
     759    y0->data.S32[index] = y0Chip + y0Cell - y0Target;
    758760
    759761    // Add the readout to the array of images to be mosaicked
     
    783785                       psImage **mosaicWeights, // The mosaic weights, to be returned
    784786                       int *xBinChip, int *yBinChip, // The binning in x and y, to be returned
    785                        const pmChip *chip // Chip to mosaic
     787                       const pmChip *chip, // Chip to mosaic
     788                       const pmCell *targetCell // Cell to which to mosaic
    786789                      )
    787790{
     
    789792    assert(mosaicMask);
    790793    assert(mosaicWeights);
     794    assert(xBinChip);
     795    assert(yBinChip);
    791796    assert(chip);
     797    assert(targetCell);
    792798
    793799    psArray *images = psArrayAlloc(0); // Array of images that will be mosaicked
     
    801807    psVector *yFlip = psVectorAlloc(0, PS_TYPE_U8); // Flip in y?
    802808
     809    // Get the target characteristics
     810    bool mdok = true;                   // Status of MD lookup
     811    int x0Target = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.X0");
     812    if (!mdok) {
     813        psLogMsg(__func__, PS_LOG_WARN, "CELL.X0 is not set for the target cell; assuming 0.\n");
     814    }
     815    int y0Target = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.Y0");
     816    if (!mdok) {
     817        psLogMsg(__func__, PS_LOG_WARN, "CELL.Y0 is not set for the target cell; assuming 0.\n");
     818    }
     819    int xParityTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.XPARITY");
     820    if (!mdok || (xParityTarget != -1 && xParityTarget != 1)) {
     821        psLogMsg(__func__, PS_LOG_WARN, "CELL.XPARITY is not set for the target cell; assuming 1.\n");
     822        xParityTarget = 1;
     823    }
     824    int yParityTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.YPARITY");
     825    if (!mdok || (yParityTarget != -1 && yParityTarget != 1)) {
     826        psLogMsg(__func__, PS_LOG_WARN, "CELL.YPARITY is not set for the target cell; assuming 1.\n");
     827        yParityTarget = 1;
     828    }
     829
    803830    // Binning for the mosaicked chip is the minimum binning allowed by the cells
    804831    *xBinChip = INT_MAX;
     
    814841        }
    815842        allGood |= addCell(images, masks, weights, x0, y0, xBin, yBin, xFlip, yFlip,
    816                            cell, xBinChip, yBinChip, false);
     843                           cell, xBinChip, yBinChip, false, x0Target, y0Target,
     844                           xParityTarget, yParityTarget);
     845    }
     846
     847    // Check to see if the target has a smaller binning in mind
     848    int xBinTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.XBIN");
     849    if (!mdok || xBinTarget == 0) {
     850        psLogMsg(__func__, PS_LOG_WARN, "CELL.XBIN is not set for the target cell; assuming %d.\n",*xBinChip);
     851    } else {
     852        *xBinChip = xBinTarget;
     853    }
     854    int yBinTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.YBIN");
     855    if (!mdok || yBinTarget == 0) {
     856        psLogMsg(__func__, PS_LOG_WARN, "CELL.YBIN is not set for the target cell; assuming %d.\n",*yBinChip);
     857    } else {
     858        *yBinChip = yBinTarget;
    817859    }
    818860
     
    843885                      psImage **mosaicWeights, // The mosaic weights, to be returned
    844886                      int *xBinFPA, int *yBinFPA, // The binning in x and y, to be returned
    845                       const pmFPA *fpa  // FPA to mosaic
     887                      const pmFPA *fpa,  // FPA to mosaic
     888                      const pmChip *targetChip, // Chip to which to mosaic
     889                      const pmCell *targetCell // Cell to which to mosaic
    846890                     )
    847891{
     
    849893    assert(mosaicMask);
    850894    assert(mosaicWeights);
     895    assert(xBinFPA);
     896    assert(yBinFPA);
    851897    assert(fpa);
     898    assert(targetChip);
     899    assert(targetCell);
    852900
    853901    psArray *images = psArrayAlloc(0); // Array of images that will be mosaicked
     
    861909    psVector *yFlip = psVectorAlloc(0, PS_TYPE_U8); // Flip in y?
    862910
     911    // Get the target characteristics
     912    bool mdok = true;                   // Status of MD lookup
     913    int x0Target = psMetadataLookupS32(&mdok, targetChip->concepts, "CHIP.X0");
     914    if (!mdok) {
     915        psLogMsg(__func__, PS_LOG_WARN, "CHIP.X0 is not set for the target chip; assuming 0.\n");
     916    }
     917    int y0Target = psMetadataLookupS32(&mdok, targetChip->concepts, "CHIP.Y0");
     918    if (!mdok) {
     919        psLogMsg(__func__, PS_LOG_WARN, "CHIP.Y0 is not set for the target chip; assuming 0.\n");
     920    }
     921    x0Target += psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.X0");
     922    if (!mdok) {
     923        psLogMsg(__func__, PS_LOG_WARN, "CELL.X0 is not set for the target cell; assuming 0.\n");
     924    }
     925    y0Target += psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.Y0");
     926    if (!mdok) {
     927        psLogMsg(__func__, PS_LOG_WARN, "CELL.Y0 is not set for the target cell; assuming 0.\n");
     928    }
     929    int xParityChipTarget = psMetadataLookupS32(&mdok, targetChip->concepts, "CHIP.XPARITY");
     930    if (!mdok || (xParityChipTarget != -1 && xParityChipTarget != 1)) {
     931        psLogMsg(__func__, PS_LOG_WARN, "CHIP.XPARITY is not set for the target chip; assuming 1.\n");
     932        xParityChipTarget = 1;
     933    }
     934    int yParityChipTarget = psMetadataLookupS32(&mdok, targetChip->concepts, "CHIP.YPARITY");
     935    if (!mdok || (yParityChipTarget != -1 && yParityChipTarget != 1)) {
     936        psLogMsg(__func__, PS_LOG_WARN, "CHIP.YPARITY is not set for the target chip; assuming 1.\n");
     937        yParityChipTarget = 1;
     938    }
     939    int xParityCellTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.XPARITY");
     940    if (!mdok || (xParityCellTarget != -1 && xParityCellTarget != 1)) {
     941        psLogMsg(__func__, PS_LOG_WARN, "CELL.XPARITY is not set for the target cell; assuming 1.\n");
     942        xParityCellTarget = 1;
     943    }
     944    int yParityCellTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.YPARITY");
     945    if (!mdok || (yParityCellTarget != -1 && yParityCellTarget != 1)) {
     946        psLogMsg(__func__, PS_LOG_WARN, "CELL.YPARITY is not set for the target cell; assuming 1.\n");
     947        yParityCellTarget = 1;
     948    }
     949    int xParityTarget = xParityChipTarget * xParityCellTarget;
     950    int yParityTarget = yParityChipTarget * yParityCellTarget;
     951
    863952    // Binning for the mosaicked chip is the minimum binning allowed by the cells
    864953    *xBinFPA = INT_MAX;
     
    880969            }
    881970            allGood |= addCell(images, masks, weights, x0, y0, xBin, yBin, xFlip, yFlip,
    882                                cell, xBinFPA, yBinFPA, true);
    883         }
     971                               cell, xBinFPA, yBinFPA, true, x0Target, y0Target,
     972                               xParityTarget, yParityTarget);
     973        }
     974    }
     975
     976    // Check to see if the target has a smaller binning in mind
     977    int xBinTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.XBIN");
     978    if (!mdok || xBinTarget == 0) {
     979        psLogMsg(__func__, PS_LOG_WARN, "CELL.XBIN is not set for the target cell; assuming %d.\n", *xBinFPA);
     980    } else {
     981        *xBinFPA = xBinTarget;
     982    }
     983    int yBinTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.YBIN");
     984    if (!mdok || yBinTarget == 0) {
     985        psLogMsg(__func__, PS_LOG_WARN, "CELL.YBIN is not set for the target cell; assuming %d.\n", *yBinFPA);
     986    } else {
     987        *yBinFPA = yBinTarget;
    884988    }
    885989
     
    9751079        // Case 2 --- we need to mosaic by cut and paste
    9761080        psTrace(__func__, 1, "Case 2 mosaicking: cut and paste.\n");
    977         if (!chipMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source)) {
     1081        if (!chipMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source, targetCell)) {
    9781082            psError(PS_ERR_UNKNOWN, false, "Unable to mosaic cells.\n");
    9791083            return false;
     
    10561160        // Case 2 --- we need to mosaic by cut and paste
    10571161        psTrace(__func__, 1, "Case 2 mosaicking: cut and paste.\n");
    1058         if (!fpaMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source)) {
     1162        if (!fpaMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source,
     1163                       targetChip, targetCell)) {
    10591164            psError(PS_ERR_UNKNOWN, false, "Unable to mosaic chips.\n");
    10601165            return false;
Note: See TracChangeset for help on using the changeset viewer.