IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 30, 2010, 1:29:50 PM (16 years ago)
Author:
eugene
Message:

add diff stats; add flux to CMF_PS1_DV1; output PSF residual mask; more accurate calculation of radius of source model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmPSF_IO.c

    r27178 r27531  
    491491        psMetadataAddS32 (header, PS_LIST_TAIL, "YCENTER", 0, "", psf->residuals->yCenter);
    492492
    493         // write the residuals as three planes of the image
    494         // this call creates an extension with NAXIS3 = 3
     493        // write the residuals as planes of the image
     494        psArray *images = psArrayAllocEmpty (1);
     495        psArrayAdd (images, 1, psf->residuals->Ro);  // z = 0 is Ro
     496
    495497        if (psf->residuals->Rx) {
    496             // this call creates an extension with NAXIS3 = 3
    497             psArray *images = psArrayAllocEmpty (3);
    498             psArrayAdd (images, 1, psf->residuals->Ro);
    499498            psArrayAdd (images, 1, psf->residuals->Rx);
    500499            psArrayAdd (images, 1, psf->residuals->Ry);
    501 
    502             if (!psFitsWriteImageCube (file->fits, header, images, residName)) {
    503                 psError(psErrorCodeLast(), false, "Unable to write PSF residuals.");
    504                 psFree(images);
    505                 psFree(residName);
    506                 psFree(header);
    507                 return false;
    508             }
    509             psFree (images);
    510         } else {
    511             // this call creates an extension with NAXIS3 = 1
    512             if (!psFitsWriteImage(file->fits, header, psf->residuals->Ro, 0, residName)) {
    513                 psError(psErrorCodeLast(), false, "Unable to write PSF residuals.");
    514                 psFree(residName);
    515                 psFree(header);
    516                 return false;
    517             }
    518         }
     500        }
     501
     502        // note that all N plane are implicitly of the same type, so we convert the mask
     503        if (psf->residuals->mask) {
     504            psImage *mask = psImageCopy (NULL, psf->residuals->mask, psf->residuals->Ro->type.type);
     505            psArrayAdd (images, 1, mask);
     506            psFree (mask);
     507        }
     508
     509        // psFitsWriteImageCube (file->fits, header, images, residName);
     510        // psFree (images);
     511
     512        if (!psFitsWriteImageCube (file->fits, header, images, residName)) {
     513            psError(psErrorCodeLast(), false, "Unable to write PSF residuals.");
     514            psFree(images);
     515            psFree(residName);
     516            psFree(header);
     517            return false;
     518        }
     519        psFree (images);
    519520        psFree (residName);
    520521        psFree (header);
     
    10171018            return false;
    10181019        }
    1019         if (Nz > 1) {
    1020             assert (Nz == 3);
     1020
     1021        // note that all N plane are implicitly of the same type, so we convert the mask
     1022        psImage *mask = psImageCopy(NULL, psf->residuals->mask, psf->residuals->Ro->type.type);
     1023        psImageInit (psf->residuals->mask, 0);
     1024        psImageInit (psf->residuals->Rx, 0.0);
     1025        psImageInit (psf->residuals->Ry, 0.0);
     1026        switch (Nz) {
     1027          case 1: // Ro only
     1028            break;
     1029          case 2: // Ro and mask
     1030            if (!psFitsReadImageBuffer(mask, file->fits, fullImage, 1)) {
     1031                psError(psErrorCodeLast(), false, "Unable to read PSF residual image.");
     1032                return false;
     1033            }
     1034            psImageCopy (psf->residuals->mask, mask, PM_TYPE_RESID_MASK);
     1035            break;
     1036          case 3: // Ro, Rx and Ry, no mask
    10211037            if (!psFitsReadImageBuffer(psf->residuals->Rx, file->fits, fullImage, 1)) {
    10221038                psError(psErrorCodeLast(), false, "Unable to read PSF residual image.");
     
    10271043                return false;
    10281044            }
    1029         }
    1030         // XXX notice that we are not saving the resid->mask
     1045            break;
     1046          case 4: // Ro, Rx, Ry, and mask:
     1047            if (!psFitsReadImageBuffer(psf->residuals->Rx, file->fits, fullImage, 1)) {
     1048                psError(psErrorCodeLast(), false, "Unable to read PSF residual image.");
     1049                return false;
     1050            }
     1051            if (!psFitsReadImageBuffer(psf->residuals->Ry, file->fits, fullImage, 2)) {
     1052                psError(psErrorCodeLast(), false, "Unable to read PSF residual image.");
     1053                return false;
     1054            }
     1055            if (!psFitsReadImageBuffer(mask, file->fits, fullImage, 3)) {
     1056                psError(psErrorCodeLast(), false, "Unable to read PSF residual image.");
     1057                return false;
     1058            }
     1059            psImageCopy (psf->residuals->mask, mask, PM_TYPE_RESID_MASK);
     1060            break;
     1061        }
     1062        psFree (mask);
    10311063    }
    10321064
Note: See TracChangeset for help on using the changeset viewer.