IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13016


Ignore:
Timestamp:
Apr 24, 2007, 5:17:52 PM (19 years ago)
Author:
Paul Price
Message:

Putting WCS in at each header level.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSim/src/ppSimLoop.c

    r13015 r13016  
    234234}
    235235
     236// Generate a header containing WCS keywords
     237static psMetadata *wcsHeader(float ra0, float dec0, // Boresight (radians)
     238                             float pa,// Position angle (radians)
     239                             float scale, // Pixel scale (radians/pix)
     240                             float x0, float y0, // Position of 0,0 on the FPA
     241                             int xParity, int yParity // Parity in x and y
     242                             )
     243{
     244    psMetadata *header = psMetadataAlloc(); // Header, to return
     245    pmAstromWCS *wcs = pmAstromWCSAlloc(1, 1); // WCS structure
     246    wcs->toSky = psProjectionAlloc(ra0, dec0, scale * xParity, scale * yParity, PS_PROJ_TAN);
     247    wcs->cdelt1 = scale * PM_DEG_RAD * xParity;
     248    wcs->cdelt2 = scale * PM_DEG_RAD * yParity;
     249    wcs->crpix1 = x0;
     250    wcs->crpix2 = y0;
     251    wcs->trans->x->coeff[1][0] = cos(pa) * wcs->cdelt1;
     252    wcs->trans->x->coeff[0][1] = -sin(pa) * wcs->cdelt1;
     253    wcs->trans->y->coeff[1][0] = sin(pa) * wcs->cdelt2;
     254    wcs->trans->y->coeff[0][1] = cos(pa) * wcs->cdelt2;
     255    // These aren't used by pmAstromWCStoHeader, but set them anyway
     256    wcs->trans->x->coeff[0][0] = ra0;
     257    wcs->trans->y->coeff[0][0] = dec0;
     258    wcs->trans->x->coeff[1][1] = 0.0;
     259    wcs->trans->y->coeff[1][1] = 0.0;
     260
     261    pmAstromWCStoHeader(header, wcs);
     262    psFree(wcs);
     263
     264    return header;
     265}
    236266
    237267
     
    650680                             "Binning in y", binning);
    651681
    652             // Set up WCS in header
    653             pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell);
    654             if (!hdu->header) {
    655                 hdu->header = psMetadataAlloc();
    656             }
    657             pmAstromWCS *wcs = pmAstromWCSAlloc(1, 1); // WCS structure
    658             wcs->toSky = psProjectionAlloc(ra0, dec0, scale * xParityChip, scale * yParityChip, PS_PROJ_TAN);
    659             wcs->cdelt1 = scale * PM_DEG_RAD * xParityChip;
    660             wcs->cdelt2 = scale * PM_DEG_RAD * yParityChip;
    661             wcs->crpix1 = fpa2cell(0.0, x0Cell, xParityCell, binning, x0Chip, xParityChip);
    662             wcs->crpix2 = fpa2cell(0.0, y0Cell, yParityCell, binning, y0Chip, yParityChip);
    663             wcs->trans->x->coeff[1][0] = cos(pa) * wcs->cdelt1;
    664             wcs->trans->x->coeff[0][1] = -sin(pa) * wcs->cdelt1;
    665             wcs->trans->y->coeff[1][0] = sin(pa) * wcs->cdelt2;
    666             wcs->trans->y->coeff[0][1] = cos(pa) * wcs->cdelt2;
    667             // These aren't used by pmAstromWCStoHeader, but set them anyway
    668             wcs->trans->x->coeff[0][0] = ra0;
    669             wcs->trans->y->coeff[0][0] = dec0;
    670             wcs->trans->x->coeff[1][1] = 0.0;
    671             wcs->trans->y->coeff[1][1] = 0.0;
    672 
    673             pmAstromWCStoHeader(hdu->header, wcs);
    674             psFree(wcs);
     682            if (cell->hdu) {
     683                cell->hdu->header = wcsHeader(ra0, dec0, pa, scale * binning,
     684                                              fpa2cell(0.0, x0Cell, xParityCell, binning,
     685                                                       x0Chip, xParityChip),
     686                                              fpa2cell(0.0, y0Cell, yParityCell, binning,
     687                                                       y0Chip, yParityChip),
     688                                              xParityCell * xParityChip, yParityCell * yParityChip);
     689            }
    675690
    676691            if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
     
    683698        }
    684699
     700        if (chip->hdu) {
     701            chip->hdu->header = wcsHeader(ra0, dec0, pa, scale * binning,
     702                                          fpa2cell(0.0, 0, 1, binning, x0Chip, xParityChip),
     703                                          fpa2cell(0.0, 0, 1, binning, y0Chip, yParityChip),
     704                                          xParityChip, yParityChip);
     705        }
     706
    685707        if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    686708            psError(PS_ERR_IO, false, "Unable to write file.");
     
    693715    }
    694716
     717    if (chip->hdu) {
     718        fpa->hdu->header = wcsHeader(ra0, dec0, pa, scale * binning, 0.0, 0.0, 1, 1);
     719    }
     720
    695721    if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    696722        psError(PS_ERR_IO, false, "Unable to write file.");
Note: See TracChangeset for help on using the changeset viewer.