IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23602


Ignore:
Timestamp:
Mar 30, 2009, 12:04:02 PM (17 years ago)
Author:
Paul Price
Message:

Realised that we need to write temporary images even when we're not convolving, since they are modified within ppStackMatch --- the normalisation and background are changed. It also makes things more consistent between the convolved and unconvolved versions.

Location:
trunk/ppStack/src
Files:
2 edited

Legend:

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

    r23575 r23602  
    112112
    113113        // Write the temporary convolved files
    114         if (options->convolve) {
    115             pmHDU *hdu = readout->parent->parent->parent->hdu; // HDU for convolved image
    116             assert(hdu);
    117             ppStackWriteImage(options->imageNames->data[i], hdu->header, readout->image, config);
    118             psMetadata *maskHeader = psMetadataCopy(NULL, hdu->header); // Copy of header, for mask
    119             pmConfigMaskWriteHeader(config, maskHeader);
    120             ppStackWriteImage(options->maskNames->data[i], maskHeader, readout->mask, config);
    121             psFree(maskHeader);
    122             psImageCovarianceTransfer(readout->variance, readout->covariance);
    123             ppStackWriteImage(options->varianceNames->data[i], hdu->header, readout->variance, config);
     114        pmHDU *hdu = readout->parent->parent->parent->hdu; // HDU for convolved image
     115        assert(hdu);
     116        ppStackWriteImage(options->imageNames->data[i], hdu->header, readout->image, config);
     117        psMetadata *maskHeader = psMetadataCopy(NULL, hdu->header); // Copy of header, for mask
     118        pmConfigMaskWriteHeader(config, maskHeader);
     119        ppStackWriteImage(options->maskNames->data[i], maskHeader, readout->mask, config);
     120        psFree(maskHeader);
     121        psImageCovarianceTransfer(readout->variance, readout->covariance);
     122        ppStackWriteImage(options->varianceNames->data[i], hdu->header, readout->variance, config);
    124123#ifdef TESTING
    125             {
    126                 psString name = NULL;
    127                 psStringAppend(&name, "covariance_%d.fits", i);
    128                 ppStackWriteImage(name, hdu->header, readout->covariance->image, config);
    129                 pmStackVisualPlotTestImage(readout->covariance->image, name);
    130                 psFree(name);
    131             }
     124        {
     125            psString name = NULL;
     126            psStringAppend(&name, "covariance_%d.fits", i);
     127            ppStackWriteImage(name, hdu->header, readout->covariance->image, config);
     128            pmStackVisualPlotTestImage(readout->covariance->image, name);
     129            psFree(name);
     130        }
    132131#endif
    133         }
    134132
    135133        pmCell *inCell = readout->parent; // Input cell
  • trunk/ppStack/src/ppStackSetup.c

    r23601 r23602  
    1212
    1313#define BUFFER 16                       // Buffer for name array
    14 
    15 // Generate an array of input filenames
    16 static psArray *stackNameArray(const ppStackOptions *options, // Stack options
    17                                pmConfig *config, // Configuration
    18                                const char *name // Name of file
    19     )
    20 {
    21     psAssert(config, "Require configuration");
    22     psAssert(config, "Require file name");
    23 
    24     psArray *array = psArrayAllocEmpty(options->num); // Array with filenames
    25     pmFPAview *view = pmFPAviewAlloc(0);// View to readout
    26     view->chip = view->cell = view->readout = -1;
    27 
    28     for (int i = 0; i < options->num; i++) {
    29         pmFPAfile *file = pmFPAfileSelectSingle(config->files, name, i); // File of interest
    30 
    31         psString filename = pmFPAfileName(file, view, config); // Filename of interest
    32         psAssert(filename, "Can't determine filename");
    33         psArrayAdd(array, array->n, filename);
    34         psFree(filename);               // Drop reference
    35     }
    36 
    37     return array;
    38 }
    3914
    4015
     
    7146
    7247    // Generate temporary names for convolved images
    73     if (options->convolve) {
    74         const char *tempDir = psMetadataLookupStr(NULL, recipe, "TEMP.DIR"); // Directory for temporary images
    75         if (!tempDir) {
    76             psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find TEMP.DIR in recipe");
    77             return false;
    78         }
     48    const char *tempDir = psMetadataLookupStr(NULL, recipe, "TEMP.DIR"); // Directory for temporary images
     49    if (!tempDir) {
     50        psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find TEMP.DIR in recipe");
     51        return false;
     52    }
    7953
    80         psString outputName = psStringCopy(psMetadataLookupStr(NULL, config->arguments,
    81                                                                "OUTPUT")); // Name for temporary files
    82         const char *tempName = basename(outputName);
    83         if (!tempName) {
    84             psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to construct basename for temporary files.");
    85             psFree(outputName);
    86             return false;
    87         }
     54    psString outputName = psStringCopy(psMetadataLookupStr(NULL, config->arguments,
     55                                                           "OUTPUT")); // Name for temporary files
     56    const char *tempName = basename(outputName);
     57    if (!tempName) {
     58        psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to construct basename for temporary files.");
     59        psFree(outputName);
     60        return false;
     61    }
    8862
    89         const char *tempImage = psMetadataLookupStr(NULL, recipe, "TEMP.IMAGE"); // Suffix for images
    90         const char *tempMask = psMetadataLookupStr(NULL, recipe, "TEMP.MASK"); // Suffix for masks
    91         const char *tempVariance = psMetadataLookupStr(NULL, recipe, "TEMP.VARIANCE"); // Suffix for var maps
    92         if (!tempImage || !tempMask || !tempVariance) {
    93             psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    94                     "Unable to find TEMP.IMAGE, TEMP.MASK and TEMP.VARIANCE in recipe");
    95             psFree(outputName);
    96             return false;
    97         }
     63    const char *tempImage = psMetadataLookupStr(NULL, recipe, "TEMP.IMAGE"); // Suffix for images
     64    const char *tempMask = psMetadataLookupStr(NULL, recipe, "TEMP.MASK"); // Suffix for masks
     65    const char *tempVariance = psMetadataLookupStr(NULL, recipe, "TEMP.VARIANCE"); // Suffix for var maps
     66    if (!tempImage || !tempMask || !tempVariance) {
     67        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     68                "Unable to find TEMP.IMAGE, TEMP.MASK and TEMP.VARIANCE in recipe");
     69        psFree(outputName);
     70        return false;
     71    }
    9872
    99         options->imageNames = psArrayAlloc(num);
    100         options->maskNames = psArrayAlloc(num);
    101         options->varianceNames = psArrayAlloc(num);
    102         for (int i = 0; i < num; i++) {
    103             psString imageName = NULL, maskName = NULL, varianceName = NULL; // Names for convolved images
    104             psStringAppend(&imageName, "%s/%s.%d.%s", tempDir, tempName, i, tempImage);
    105             psStringAppend(&maskName, "%s/%s.%d.%s", tempDir, tempName, i, tempMask);
    106             psStringAppend(&varianceName, "%s/%s.%d.%s", tempDir, tempName, i, tempVariance);
    107             psTrace("ppStack", 5, "Temporary files: %s %s %s\n", imageName, maskName, varianceName);
    108             options->imageNames->data[i] = imageName;
    109             options->maskNames->data[i] = maskName;
    110             options->varianceNames->data[i] = varianceName;
    111         }
    112         psFree(outputName);
    113     } else {
    114         options->imageNames = stackNameArray(options, config, "PPSTACK.INPUT");
    115         options->maskNames = stackNameArray(options, config, "PPSTACK.INPUT.MASK");
    116         options->varianceNames = stackNameArray(options, config, "PPSTACK.INPUT.VARIANCE");
     73    options->imageNames = psArrayAlloc(num);
     74    options->maskNames = psArrayAlloc(num);
     75    options->varianceNames = psArrayAlloc(num);
     76    for (int i = 0; i < num; i++) {
     77        psString imageName = NULL, maskName = NULL, varianceName = NULL; // Names for convolved images
     78        psStringAppend(&imageName, "%s/%s.%d.%s", tempDir, tempName, i, tempImage);
     79        psStringAppend(&maskName, "%s/%s.%d.%s", tempDir, tempName, i, tempMask);
     80        psStringAppend(&varianceName, "%s/%s.%d.%s", tempDir, tempName, i, tempVariance);
     81        psTrace("ppStack", 5, "Temporary files: %s %s %s\n", imageName, maskName, varianceName);
     82        options->imageNames->data[i] = imageName;
     83        options->maskNames->data[i] = maskName;
     84        options->varianceNames->data[i] = varianceName;
    11785    }
     86    psFree(outputName);
    11887
    11988    if (!pmConfigMaskSetBits(NULL, NULL, config)) {
Note: See TracChangeset for help on using the changeset viewer.