IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 23, 2009, 3:05:43 PM (17 years ago)
Author:
bills
Message:

Fixes to destreaking of raw images

Location:
trunk/magic/remove/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/magic/remove/src

    • Property svn:ignore
      •  

        old new  
        22streaksreplace
        33streakscompare
         4streaksrelease
  • trunk/magic/remove/src/streaksastrom.c

    r20842 r21156  
    1717
    1818    if (fromCell) {
    19         // The metadata is the cell concepts
     19        // XXX: I think that this is not needed
     20        // We are only asked to get the concepts from the cell when we're reading from a pmfile (skycell)
     21        // In that case we (x0,y0) = (0,0) and the parirties are positive
     22        // If the x0, y0 are not zero they are probably in the FITS unity based array format
     23        // We should probably assert that these are zero
    2024        cell_x0 =  psMetadataLookupS32(&mdok, md, "CELL.X0");
    2125        if (!mdok) {
     
    2832            return NULL;
    2933        }
    30 
    3134        xParityCell = psMetadataLookupS32(&mdok, md, "CELL.XPARITY");
    3235        if (!mdok || (xParityCell != 1 && xParityCell != -1)) {
     
    6568            return false;
    6669        }
    67 
    6870    } else {
    6971        // no metadata regular cell
     72        // used by warpedpixels
    7073        cell_x0 = 0;
    7174        cell_y0 = 0;
     
    8992}
    9093
     94void
     95chipToCell(double *xCell, double *yCell, strkAstrom *astrom, double xChip, double yChip)
     96{
     97    // convert from chip to cell
     98    if (astrom->xParity > 0) {
     99        *xCell = xChip - astrom->cell_x0;
     100    } else {
     101        *xCell = astrom->cell_x0 - 1 - xChip;
     102    }
     103    if (astrom->yParity > 0) {
     104        *yCell = yChip - astrom->cell_y0;
     105    } else {
     106        *yCell = astrom->cell_y0 - 1 - yChip;
     107    }
     108}
     109
     110void
     111cellToChip(double *xChip, double *yChip, strkAstrom *astrom, double xCell, double yCell)
     112{
     113    if (astrom->xParity > 0) {
     114        *xChip = xCell + astrom->cell_x0;
     115    } else {
     116        *xChip = astrom->cell_x0 - 1 - xCell;
     117    }
     118    if (astrom->yParity > 0) {
     119        *yChip = yCell + astrom->cell_y0;
     120    } else {
     121        *yChip =  astrom->cell_y0 - 1 - yCell;
     122    }
     123}
     124
     125void
     126cellToChipInt(int *xChip, int *yChip, strkAstrom *astrom, int xCell, int yCell)
     127{
     128    if (astrom->xParity > 0) {
     129        *xChip = xCell + astrom->cell_x0;
     130    } else {
     131        *xChip = astrom->cell_x0 - 1 - xCell;
     132    }
     133    if (astrom->yParity > 0) {
     134        *yChip = yCell + astrom->cell_y0;
     135    } else {
     136        *yChip =  astrom->cell_y0 - 1 - yCell;
     137    }
     138}
     139 
    91140bool
    92141skyToCell(strkPt *outPt, strkAstrom *astrom, double ra, double dec)
     
    107156    psPlaneTransformApply(pt->chip, chip->fromFPA, pt->FP);
    108157
    109     // convert from chip to cell
    110     outPt->x = (pt->chip->x - astrom->cell_x0) * astrom->xParity;
    111     outPt->y = (pt->chip->y - astrom->cell_y0) * astrom->yParity;
     158    chipToCell(&outPt->x, &outPt->y, astrom, pt->chip->x, pt->chip->y);
    112159
    113160//    printf("cell: %f %f chip: %f %f\n", outPt->x, outPt->y, pt->chip->x, pt->chip->y);
     
    115162    return true;
    116163}
    117  
     164
    118165bool
    119166cellToSky(strkPt *outPt, strkAstrom *astrom, double x, double y)
     
    123170    pmAstromObj *pt = (pmAstromObj *) astrom->pt;
    124171   
    125     // XXX: TODO: confirm that this cell to chip transformation is correct
    126     pt->chip->x = (x * astrom->xParity) + astrom->cell_x0;
    127     pt->chip->y = (y * astrom->yParity) + astrom->cell_y0;
     172    cellToChip(&pt->chip->x, &pt->chip->y, astrom, x, y);
    128173
    129174    pt->chip->xErr = 0;  // Is setting these errors to zero the right thing to do?
     
    142187}
    143188
    144 void
    145 cellToChip(PixelPos *chip, strkAstrom *astrom, PixelPos *cell)
    146 {
    147     // TODO: do I need to worry about going from int to float and back again here?
    148     chip->x = (cell->x * astrom->xParity) + astrom->cell_x0;
    149     chip->y = (cell->y * astrom->yParity) + astrom->cell_y0;
    150 }
    151189 
    152190static bool
     
    166204    PS_ASSERT_PTR_NON_NULL(hdu->header, 1)
    167205    if (sf->bilevelAstrometry) {
    168         // Do we get here for GPC1 ? I don't necessarily have an fpa for the input image
    169206        if (!pmAstromReadBilevelMosaic(sf->inAstrom->fpa, phu->header)) {
    170207            psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel mosaic astrometry for input FPA.");
     
    232269    }
    233270}
     271
     272void
     273linearizeTransforms(strkAstrom *astrom)
     274{
     275    if (!pmAstromLinearizeTransforms((pmFPA *) astrom->fpa, (pmChip *) astrom->chip)) {
     276        streaksExit("linear fit to astrometry failed\n", PS_EXIT_UNKNOWN_ERROR);
     277    }
     278}
Note: See TracChangeset for help on using the changeset viewer.