IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 9, 2011, 12:46:38 PM (15 years ago)
Author:
eugene
Message:

save the covariance when writing the temporary variance images

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/ppStack/src/ppStackFiles.c

    r30015 r30228  
    200200    return true;
    201201}
     202
     203// Write an image to a FITS file
     204bool ppStackWriteVariance(const char *name, // Name of image
     205                          psMetadata *header, // Header
     206                          const psImage *variance, // Variance
     207                          const psImage *covariance, // Variance
     208                          pmConfig *config // Configuration
     209    )
     210{
     211    assert(name);
     212    assert(variance);
     213
     214    psString resolved = pmConfigConvertFilename(name, config, true, true); // Resolved file name
     215    psFits *fits = psFitsOpen(resolved, "w");
     216    if (!fits) {
     217        psError(PPSTACK_ERR_IO, false, "Unable to open FITS file %s to write image.", resolved);
     218        psFree(resolved);
     219        return false;
     220    }
     221    if (!psFitsWriteImage(fits, header, variance, 0, NULL)) {
     222        psError(PPSTACK_ERR_IO, false, "Unable to write FITS image %s.", resolved);
     223        psFitsClose(fits);
     224        psFree(resolved);
     225        return false;
     226    }
     227    if (covariance) {
     228        psMetadata *tmphead = psMetadataAlloc();
     229        psMetadataAddS32(tmphead, PS_LIST_TAIL, "COVARIANCE.CENTRE.X", PS_META_REPLACE, "center", (int)(covariance->numCols / 2));
     230        psMetadataAddS32(tmphead, PS_LIST_TAIL, "COVARIANCE.CENTRE.Y", PS_META_REPLACE, "center", (int)(covariance->numRows / 2));
     231        if (!psFitsWriteImage(fits, tmphead, covariance, 0, "COVAR_SkyChip_SkyCell")) {
     232            psError(PPSTACK_ERR_IO, false, "Unable to write FITS image %s.", resolved);
     233            psFitsClose(fits);
     234            psFree(resolved);
     235            return false;
     236        }
     237    }
     238    if (!psFitsClose(fits)) {
     239        psError(PPSTACK_ERR_IO, false, "Unable to close FITS image %s.", resolved);
     240        psFree(resolved);
     241        return false;
     242    }
     243    psFree(resolved);
     244    return true;
     245}
Note: See TracChangeset for help on using the changeset viewer.