IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15388


Ignore:
Timestamp:
Oct 25, 2007, 5:09:31 PM (19 years ago)
Author:
bills
Message:

Shift the transform by the stamps integer offset from the original
image.
Added ugly temporary hack to work around the megacam problem.

Location:
trunk/ppstamp/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppstamp/src/ppstamp.h

    r15363 r15388  
    7777psRegion *ppstampChipRegion(const pmChip *chip);
    7878
     79extern bool ppstampMegacamWorkaround;
    7980#endif
  • trunk/ppstamp/src/ppstampMakeStamp.c

    r15363 r15388  
    44
    55#include "ppstamp.h"
    6 #include "pmFPAAstrometry.h"
    76#include "pmAstrometryUtils.h"
    87
     
    2524    PS_ASSERT_PTR_NON_NULL(hdu->header, 1)
    2625
    27     outChip->toFPA   = psPlaneTransformSetCenter(NULL, inChip->toFPA, roi->x0, roi->y0);
     26    // Change the reference pixel to account for the change in origin between the stamp and
     27    // the original image
     28    outChip->toFPA   = psPlaneTransformSetCenter(NULL, inChip->toFPA, (int) roi->x0, (int) roi->y0);
    2829
    2930    outChip->fromFPA = psPlaneTransformInvert(NULL, outChip->toFPA, *roi, 50);
     31
     32    // remove these keys which may have been copied from the input header
     33    // XXX pmAstromWriteWCS should do this since it's the one that's inserting
     34    // the PC00* style keywords
     35    if (psMetadataLookup(outHDU->header, "CD1_1")) {
     36        psMetadataRemoveKey(outHDU->header, "CD1_1");
     37        psMetadataRemoveKey(outHDU->header, "CD1_2");
     38        psMetadataRemoveKey(outHDU->header, "CD2_1");
     39        psMetadataRemoveKey(outHDU->header, "CD2_2");
     40    }
    3041
    3142    if (!pmAstromWriteWCS(outHDU->header, outFPA, outChip, WCS_NONLIN_TOL)) {
     
    6172        outHDU->header = psMetadataAlloc();
    6273    }
     74
    6375
    6476    // If input had WCS convert it for stamp
     
    182194            break;
    183195        }
     196
     197        psRegion extractRegion = options->roi;
     198
     199        // Close your eyes while I hack around bug 986
     200        if (ppstampMegacamWorkaround) {
     201            // the coordinates of the mosaic are shifted 32 pixels from the chip
     202            extractRegion.x0 -= 32;
     203            extractRegion.x1 -= 32;
     204        }
    184205   
    185         psImage *subsetImage = psImageSubset(readout->image, options->roi);
     206        psImage *subsetImage = psImageSubset(readout->image, extractRegion);
     207
    186208        if (subsetImage) {
    187209            // make a copy since we're going to change the image's internals
  • trunk/ppstamp/src/ppstampParseCamera.c

    r15280 r15388  
    44
    55# include "ppstamp.h"
     6
     7bool ppstampMegacamWorkaround = false;
    68
    79// Set up the ppstamp output Image file
     
    5355        return NULL;
    5456    }
     57
     58    if (!strcmp(config->cameraName, "MEGACAM")) {
     59        // workaround bug 986 and related
     60        ppstampMegacamWorkaround = true;
     61    }
    5562 
    56 
    57 #ifdef notyet
    58     if (psTraceGetLevel("ppstamp.config") > 0) {
    59         // Get a look inside all the files.
    60         psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL); // Iterator
    61         psMetadataItem *item;               // Item from iteration
    62         fprintf(stderr, "Files:\n");
    63         while ((item = psMetadataGetAndIncrement(filesIter))) {
    64             pmFPAfile *file = item->data.V; // File of interest
    65             fprintf(stderr, "%s: %p %p %p (%p) %p\n", file->name,
    66                     file->src, file->fpa,
    67                     file->camera, file->fpa->camera, file->format);
    68         }
    69         psFree(filesIter);
    70     }
    71 #endif
    72 
    7363    return true;
    7464}
  • trunk/ppstamp/src/ppstampRegion.c

    r15363 r15388  
    33#include "pmHDU.h"
    44#include "pmFPA.h"
     5
     6#include "ppstamp.h"
    57
    68// Functions to calculate the image space boundaries of a given Chip or Cell
     
    2022    // This is the difference between this function and pmReadoutExtent.
    2123    // pmReadoutExtent ignores the col0, row0 of the readout
    22 
    23     int col0 = 0;
    24     int row0 = 0;
    2524   
    26 #ifdef notdef
    27     if (image->parent) {
    28         // This is wrong. I'm trying to deal with the strange megacam 'spliced' images
    29         // which appear to have inconsistant CELL.X0 and readout.col0
    30         col0 = image->col0 - image->parent->col0;
    31         row0 = image->row0 - image->parent->row0;
    32     }
    33 #endif
    34 
     25    int col0 = 0;   // should be  image->col0 - readout->col0
     26    int row0 = 0;   //            image->row0 - readout->row0
     27   
    3528    return psRegionAlloc(col0, col0 + image->numCols,
    3629                         row0, row0 + image->numRows);
     
    9992    PS_ASSERT_PTR_NON_NULL(chip, NULL);
    10093
     94    if (ppstampMegacamWorkaround) {
     95        // There is an inconsistency in the megacam parameters.
     96        // The offset to the cells is effectively contained in two
     97        // places.
     98        // The CELL.X0 for the 2 cells are 0 and 1024 while
     99        // readout->image.col0 = 32 and 1056
     100        // This fact makes it impossible to calculate the Chip bounds
     101        // in a way consistent with say gpc1
     102        // we're deferring that problem for now.
     103        // Since all chips on megacam have the same bounds, just hard code
     104        // the answer. See bug 986
     105        return psRegionAlloc(32, 2080, 0, 4612);
     106    }
     107
    101108    psArray *cells = chip->cells;       // Array of component cells
    102109    psRegion *chipExtent = psRegionAlloc(INFINITY, 0, INFINITY, 0); // Extent of chip
Note: See TracChangeset for help on using the changeset viewer.