IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 13, 2011, 11:52:31 AM (15 years ago)
Author:
eugene
Message:

some reorganization: create ppStackUpdateHeader, ppStackStats, ppStackJPEG functions to clean up ppStackLoop; plug some leaks; cleanup include sections; create ppStackCleanup for end of processing (renamed old ppStackCleanup to ppStackCleanupFiles); move jpeg creation from ppStackCleanupFiles to ppStackJPEG; same for stats; adjust kernel auto-scaling to take place after we have measured the source sizes; update headers with stack_id, skycell_id, tess_id (optional)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStackFiles.c

    r28253 r30620  
    1 #ifdef HAVE_CONFIG_H
    2 #include <config.h>
    3 #endif
    4 
    5 #include <stdio.h>
    6 #include <unistd.h>
    7 #include <pslib.h>
    8 #include <psmodules.h>
    9 
    101#include "ppStack.h"
    112
    12 
    133// Here follows lists of files for activation/deactivation at various stages.  Each must be NULL-terminated.
     4
     5/// NOP list
     6static char *filesNOP[] = { NULL };
    147
    158/// Files required in preparation for convolution
     
    4134{
    4235    switch (list) {
     36      case PPSTACK_FILES_NONE:     return filesNOP;
    4337      case PPSTACK_FILES_PREPARE:  return filesPrepare;
    4438      case PPSTACK_FILES_TARGET:   return filesTarget;
     
    206200    return true;
    207201}
     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.