IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 27, 2008, 5:38:21 PM (18 years ago)
Author:
Paul Price
Message:

Adding recipe options to choose the suffix for temporary files.

File:
1 edited

Legend:

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

    r16693 r16704  
    44
    55#include <stdio.h>
     6#include <unistd.h>
    67#include <string.h>
    78#include <pslib.h>
     
    1112#include "ppStack.h"
    1213
    13 #define TESTING
     14//#define TESTING
    1415
    1516// Here follows lists of files for activation/deactivation at various stages.  Each must be NULL-terminated.
     
    185186    assert(config);
    186187
     188    bool mdok;                          // Status of MD lookup
    187189    psMaskType maskBlank = psMetadataLookupU8(NULL, config->arguments, "MASK.BLANK"); // Mask for blank reg.
    188 
    189     bool mdok;                          // Status of MD lookup
     190    bool tempDelete = psMetadataLookupBool(&mdok, config->arguments, "TEMP.DELETE"); // Delete temporary files?
     191    const char *tempImage = psMetadataLookupStr(NULL, config->arguments, "TEMP.IMAGE"); // Suffix for temporary images
     192    const char *tempMask = psMetadataLookupStr(NULL, config->arguments, "TEMP.MASK"); // Suffix for temporary masks
     193    const char *tempWeight = psMetadataLookupStr(NULL, config->arguments, "TEMP.WEIGHT"); // Suffix for temporary weight (variance) maps
     194    if (!tempImage || !tempMask || !tempWeight) {
     195        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find TEMP.IMAGE, TEMP.MASK and TEMP.WEIGHT");
     196        return false;
     197    }
     198
    190199    const char *statsName = psMetadataLookupStr(&mdok, config->arguments, "STATS"); // Filename for statistics
    191200    psMetadata *stats = NULL;           // Container for statistics
     
    286295    }
    287296
    288     const char *suffix = "conv.fits";   // Suffix for convolved images; ultimately this will be from recipe
    289297    const char *outName = psMetadataLookupStr(NULL, config->arguments, "OUTPUT"); // Output root
    290298    assert(outName);
     
    294302    for (int i = 0; i < num; i++) {
    295303        psString imageName = NULL, maskName = NULL, weightName = NULL; // Names for convolved images
    296         psStringAppend(&imageName, "%s.im-%d.%s", outName, i, suffix);
    297         psStringAppend(&maskName, "%s.mk-%d.%s", outName, i, suffix);
    298         psStringAppend(&weightName, "%s.wt-%d.%s", outName, i, suffix);
     304        psStringAppend(&imageName, "%s.%d.%s", outName, i, tempImage);
     305        psStringAppend(&maskName, "%s.%d.%s", outName, i, tempMask);
     306        psStringAppend(&weightName, "%s.%d.%s", outName, i, tempWeight);
    299307        imageNames->data[i] = imageName;
    300308        maskNames->data[i] = maskName;
     
    508516            psFitsClose(maskFits->data[i]);
    509517            psFitsClose(weightFits->data[i]);
     518            if (tempDelete && (unlink(imageNames->data[i]) || unlink(maskNames->data[i]) ||
     519                               unlink(weightNames->data[i]))) {
     520                psWarning("Unable to delete temporary files for image %d", i);
     521            }
    510522        }
    511523
Note: See TracChangeset for help on using the changeset viewer.