IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21269


Ignore:
Timestamp:
Feb 2, 2009, 2:37:06 PM (17 years ago)
Author:
Paul Price
Message:

Reverting to writing covariance matrices per chip/cell. This allows simple visualisation of the covariance matrix, and a simpler system for reading and writing them.

Location:
branches/pap_branch_20090128/psModules/src/camera
Files:
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_20090128/psModules/src/camera/pmFPARead.c

    r21264 r21269  
    99#include <pslib.h>
    1010
     11#include "pmConfig.h"
     12#include "pmConfigMask.h"
    1113#include "pmHDU.h"
    1214#include "pmFPA.h"
     
    732734            return NULL;
    733735        }
    734 
    735         if (type == FPA_READ_TYPE_VARIANCE && hdu->covariances) {
    736             psArray *covariances = hdu->covariances; // Covariances in HDU
    737             for (int i = 0; i < covariances->n; i++) {
    738                 pmHDUCovariances *covar = covariances->data[i]; // Covariance information
    739 
    740736        psFree(readout);                // Drop reference
    741737    }
     
    11431139    PS_ASSERT_FITS_NON_NULL(fits, false);
    11441140
    1145     return cellRead(cell, fits, config, FPA_READ_TYPE_VARIANCE);
     1141    if (!cellRead(cell, fits, config, FPA_READ_TYPE_VARIANCE)) {
     1142        return false;
     1143    }
     1144    return pmCellReadCovariance(cell, fits);
    11461145}
    11471146
     
    11511150    PS_ASSERT_FITS_NON_NULL(fits, false);
    11521151
    1153     return chipRead(chip, fits, config, FPA_READ_TYPE_VARIANCE);
     1152    if (!chipRead(chip, fits, config, FPA_READ_TYPE_VARIANCE)) {
     1153        return false;
     1154    }
     1155    return pmChipReadCovariance(chip, fits);
    11541156}
    11551157
     
    11591161    PS_ASSERT_FITS_NON_NULL(fits, false);
    11601162
    1161     return fpaRead(fpa, fits, config, FPA_READ_TYPE_VARIANCE);
     1163    if (!fpaRead(fpa, fits, config, FPA_READ_TYPE_VARIANCE)) {
     1164        return false;
     1165    }
     1166    return pmFPAReadCovariance(fpa, fits);
    11621167}
    11631168
     
    12851290    return numRead;
    12861291}
     1292
     1293
     1294//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     1295// Reading covariance matrices
     1296//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     1297
     1298bool pmCellReadCovariance(pmCell *cell, psFits *fits)
     1299{
     1300    PS_ASSERT_PTR_NON_NULL(cell, false);
     1301    PS_ASSERT_FITS_NON_NULL(fits, false);
     1302
     1303    const char *chipName = psMetadataLookupStr(NULL, cell->parent->concepts, "CHIP.NAME"); // Name of chip
     1304    const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME"); // Name of cell
     1305    psString extname = NULL;            // Extension name
     1306    psStringAppend(&extname, "COVAR_%s_%s", chipName, cellName);
     1307
     1308    if (!psFitsMoveExtName(fits, extname)) {
     1309        psError(PS_ERR_IO, false, "Unable to move to extension %s\n", extname);
     1310        psFree(extname);
     1311        return false;
     1312    }
     1313    psFree(extname);
     1314
     1315    psMetadata *header = psFitsReadHeader(NULL, fits); // The FITS header
     1316    if (!header) {
     1317        psError(PS_ERR_IO, false, "Unable to read header for extension %s\n", extname);
     1318        psFree(header);
     1319        return false;
     1320    }
     1321
     1322    bool mdok;                          // Status of MD lookup
     1323    int x0 = psMetadataLookupS32(&mdok, header, "COVARIANCE.CENTRE.X"); // Centre of matrix in x
     1324    if (!mdok) {
     1325        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to read covariance centre");
     1326        psFree(header);
     1327        return false;
     1328    }
     1329    int y0 = psMetadataLookupS32(&mdok, header, "COVARIANCE.CENTRE.Y"); // Centre of matrix in y
     1330    if (!mdok) {
     1331        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to read covariance centre");
     1332        psFree(header);
     1333        return false;
     1334    }
     1335    psFree(header);
     1336
     1337    psArray *images = psFitsReadImageCube(fits, psRegionSet(0,0,0,0)); // Covariance matrices
     1338    if (!images) {
     1339        psError(PS_ERR_IO, false, "Unable to read covariance matrices for chip %s, cell %s",
     1340                chipName, cellName);
     1341        return false;
     1342    }
     1343
     1344    psArray *readouts = cell->readouts; // Readouts of cell
     1345    if (images->n != readouts->n) {
     1346        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     1347                "Number of covariance matrices (%ld) doesn't match number of readouts (%ld)",
     1348                images->n, readouts->n);
     1349        psFree(images);
     1350        return false;
     1351    }
     1352
     1353    for (int i = 0; i < readouts->n; i++) {
     1354        pmReadout *ro = readouts->data[i]; // Readout of interest
     1355        psImage *image = images->data[i]; // Image of interest
     1356        if (ro->covariance) {
     1357            psWarning("Clobbering extant covariance matrix in chip %s, cell %s, readout %d",
     1358                      chipName, cellName, i);
     1359            psFree(ro->covariance);
     1360        }
     1361        ro->covariance = psKernelAllocFromImage(image, x0, y0);
     1362    }
     1363    psFree(images);
     1364
     1365    return true;
     1366}
     1367
     1368
     1369bool pmChipReadCovariance(pmChip *chip, psFits *fits)
     1370{
     1371    PS_ASSERT_PTR_NON_NULL(chip, false);
     1372    PS_ASSERT_FITS_NON_NULL(fits, false);
     1373
     1374    psArray *cells = chip->cells;       // Array of cells
     1375    for (int i = 0; i < cells->n; i++) {
     1376        pmCell *cell = cells->data[i];  // Cell of interest
     1377        if (!pmCellReadCovariance(cell, fits)) {
     1378            return false;
     1379        }
     1380    }
     1381
     1382    return true;
     1383}
     1384
     1385
     1386bool pmFPAReadCovariance(pmFPA *fpa, psFits *fits)
     1387{
     1388    PS_ASSERT_PTR_NON_NULL(fpa, false);
     1389    PS_ASSERT_FITS_NON_NULL(fits, false);
     1390
     1391    psArray *chips = fpa->chips;        // Array of chips
     1392    for (int i = 0; i < chips->n; i++) {
     1393        pmChip *chip = chips->data[i];  // Chip of interest
     1394        if (!pmChipReadCovariance(chip, fits)) {
     1395            return false;
     1396        }
     1397    }
     1398
     1399    return true;
     1400}
  • branches/pap_branch_20090128/psModules/src/camera/pmFPARead.h

    r21211 r21269  
    44 * @author Paul Price, IfA
    55 *
    6  * @version $Revision: 1.15.44.1 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2009-01-29 00:33:51 $
     6 * @version $Revision: 1.15.44.2 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2009-02-03 00:37:06 $
    88 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    226226/// also read and included in the cell analysis metadata under "name.HEADER".
    227227int pmCellReadTable(pmCell *cell,       ///< Cell for which to read table
    228                     psFits *fits,       ///< FITS file from which the table
     228                    psFits *fits,       ///< FITS file from which to read the table
    229229                    const char *name    ///< Specifies the extension name, and target in the analysis metadata
    230230                   );
     
    233233///
    234234/// Iterates over component cells, calling pmCellReadTable.
    235 int pmChipReadTable(pmChip *chip,       ///< Cell for which to read table
    236                     psFits *fits,       ///< FITS file from which the table
     235int pmChipReadTable(pmChip *chip,       ///< Chip for which to read table
     236                    psFits *fits,       ///< FITS file from which to read the table
    237237                    const char *name    ///< Specifies the extension name, and target in the analysis metadata
    238238                   );
     
    241241///
    242242/// Iterates over component chips, calling pmChipReadTable.
    243 int pmFPAReadTable(pmFPA *fpa,          ///< Cell for which to read table
    244                    psFits *fits,        ///< FITS file from which the table
     243int pmFPAReadTable(pmFPA *fpa,          ///< FPA for which to read table
     244                   psFits *fits,        ///< FITS file from which to read the table
    245245                   const char *name     ///< Specifies the extension name, and target in the analysis metadata
    246246                  );
     247
     248/// Read covariance matrices for a cell
     249bool pmCellReadCovariance(pmCell *cell, ///< Cell for which to read covariance matrices
     250                          psFits *fits  ///< FITS file from which to read
     251    );
     252
     253/// Read covariance matrices for a chip
     254bool pmChipReadCovariance(pmChip *chip, ///< Chip for which to read covariance matrices
     255                          psFits *fits  ///< FITS file from which to read
     256    );
     257
     258/// Read covariance matrices for a cell
     259bool pmFPAReadCovariance(pmFPA *fpa,    ///< FPA for which to read covariance matrices
     260                         psFits *fits   ///< FITS file from which to read
     261    );
     262
     263
     264
    247265/// @}
    248266#endif
  • branches/pap_branch_20090128/psModules/src/camera/pmFPAWrite.c

    r21264 r21269  
    99
    1010#include "pmConfig.h"
     11#include "pmConfigMask.h"
    1112#include "pmHDU.h"
    1213#include "pmFPA.h"
     
    7475}
    7576
    76 
    77 
     77// Indicate whether a covariance matrix is defined
     78static bool readoutSearchCovariances(pmReadout *ro)
     79{
     80    return ro->covariance ? true : false;
     81}
     82
     83// Search for a covariance matrix
     84#define SEARCH_COVARIANCES(NAME, PARENT, CHILD, CHILDREN, TESTFUNC) \
     85static bool NAME(PARENT *parent) \
     86{ \
     87    if (!parent || !parent->CHILDREN) { \
     88        return false; \
     89    } \
     90    psArray *children = parent->CHILDREN; /* Array of children */ \
     91    for (int i = 0; i < children->n; i++) { \
     92        CHILD *child = children->data[i]; /* Child of interest */ \
     93        if (child && TESTFUNC(child)) { \
     94            return true; \
     95        } \
     96    } \
     97    return false; \
     98}
     99
     100SEARCH_COVARIANCES(cellSearchCovariances, pmCell, pmReadout, readouts, readoutSearchCovariances);
     101SEARCH_COVARIANCES(chipSearchCovariances, pmChip, pmCell,    cells,    cellSearchCovariances);
     102SEARCH_COVARIANCES(fpaSearchCovariances,  pmFPA,  pmChip,    chips,    chipSearchCovariances);
    78103
    79104// Some type-specific additions to the header
     
    81106                              pmChip *chip, // Chip of interest, or NULL
    82107                              pmCell *cell, // Cell of interest, or NULL
    83                               fpaWriteType type // Type to write
    84     )
     108                              fpaWriteType type, // Type to write
     109                              pmConfig *config // Configuration
     110                              )
    85111{
    86112    switch (type) {
     
    94120      }
    95121      case FPA_WRITE_TYPE_VARIANCE: {
     122          bool covar = false;           // Are covariances present?
     123          if ((cell && cellSearchCovariances(cell)) ||
     124              (!cell && ((chip && chipSearchCovariances(chip)) ||
     125                         (!chip && fpa && fpaSearchCovariances)))) {
     126              covar = true;
     127          }
     128
    96129          pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // Header being written
    97 
     130          psMetadataAddBool(hdu->header, PS_LIST_TAIL, PM_HDU_COVARIANCE_KEYWORD, PS_META_REPLACE,
     131                            "Is a covariance matrix present?", covar);
     132          break;
     133      }
     134      default:
     135        break;
     136    }
     137
     138    return true;
     139}
    98140
    99141
     
    137179            return false;
    138180        }
    139 
    140 
     181        if (!writeUpdateHeader(NULL, NULL, cell, type, config)) {
     182            psError(PS_ERR_UNKNOWN, false, "Unable to update header for writing");
     183            return false;
     184        }
    141185        if (!appropriateWriteFunc(hdu, fits, config, type)) {
    142186            psError(PS_ERR_IO, false, "Unable to write HDU for cell.\n");
     
    189233                return false;
    190234            }
     235
     236            if (!writeUpdateHeader(NULL, chip, NULL, type, config)) {
     237                psError(PS_ERR_UNKNOWN, false, "Unable to update header for writing");
     238                return false;
     239            }
     240
    191241            if (!appropriateWriteFunc(hdu, fits, config, type)) {
    192242                psError(PS_ERR_IO, false, "Unable to write HDU for chip.\n");
     
    253303                return false;
    254304            }
     305            if (!writeUpdateHeader(fpa, NULL, NULL, type, config)) {
     306                psError(PS_ERR_UNKNOWN, false, "Unable to update header for writing");
     307                return false;
     308            }
    255309            if (!appropriateWriteFunc(hdu, fits, config, type))  {
    256310                psError(PS_ERR_IO, false, "Unable to write HDU for FPA.\n");
     
    535589    return numWrite;
    536590}
     591
     592bool pmCellWriteCovariance(psFits *fits, const pmCell *cell)
     593{
     594    PS_ASSERT_PTR_NON_NULL(cell, false);
     595    PS_ASSERT_PTR_NON_NULL(fits, false);
     596
     597    int numCovar = 0;
     598    psArray *readouts = cell->readouts; // Array of readouts
     599    for (int i = 0; i < readouts->n; i++) {
     600        pmReadout *readout = readouts->data[i]; // The readout of interest
     601        if (readout && readout->covariance) {
     602            numCovar++;
     603        }
     604    }
     605    if (numCovar == 0) {
     606        return true;
     607    }
     608    if (numCovar != readouts->n) {
     609        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     610                "Number of covariances (%d) doesn't match number of readouts (%ld)",
     611                numCovar, readouts->n);
     612        return false;
     613    }
     614
     615    // Check size of covariances
     616    int xMinCovar = INT_MAX, xMaxCovar = INT_MIN, yMinCovar = INT_MAX, yMaxCovar = INT_MIN; // Size
     617    for (int i = 0; i < readouts->n; i++) {
     618        pmReadout *readout = readouts->data[i]; // The readout of interest
     619        psAssert(readout, "Should be defined.");
     620        psKernel *covar = readout->covariance; // Covariance matrix
     621        psAssert(covar, "Should be defined.");
     622        xMinCovar = PS_MIN(xMinCovar, covar->xMin);
     623        xMaxCovar = PS_MAX(xMaxCovar, covar->xMax);
     624        yMinCovar = PS_MIN(yMinCovar, covar->yMin);
     625        yMaxCovar = PS_MAX(yMaxCovar, covar->yMax);
     626    }
     627
     628    // Correct covariances to common size
     629    psArray *images = psArrayAlloc(numCovar); // Array of images
     630    for (int i = 0; i < readouts->n; i++) {
     631        pmReadout *readout = readouts->data[i]; // The readout of interest
     632        psAssert(readout, "Should be defined.");
     633        psKernel *covar = readout->covariance; // Covariance matrix
     634        psAssert(covar, "Should be defined.");
     635        int xMin = covar->xMin, xMax = covar->xMax, yMin = covar->yMin, yMax = covar->yMax;// Size
     636        if (xMin == xMinCovar && xMax == xMaxCovar && yMin == yMinCovar && yMax == yMaxCovar) {
     637            images->data[i] = psMemIncrRefCounter(covar->image);
     638        } else {
     639            psImage *new = psImageAlloc(xMaxCovar - xMinCovar + 1, yMaxCovar - yMinCovar + 1, PS_TYPE_F32);
     640            psImageInit(new, 0);
     641            psImageOverlaySection(new, covar->image, xMinCovar - xMin, yMinCovar - yMin, "=");
     642            images->data[i] = new;
     643        }
     644    }
     645
     646    // Determine extension name
     647    const char *chipName = psMetadataLookupStr(NULL, cell->parent->concepts, "CHIP.NAME"); // Name of chip
     648    const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME"); // Name of cell
     649    psString extname = NULL;            // Extension name
     650    psStringAppend(&extname, "COVAR_%s_%s", chipName, cellName);
     651
     652    // Generate header
     653    pmHDU *hdu = pmHDUFromCell(cell);   // HDU for cell
     654    psMetadata *header = psMetadataCopy(NULL, hdu->header); // Header to write
     655    psMetadataAddS32(header, PS_LIST_TAIL, "COVARIANCE.CENTRE.X", PS_META_REPLACE,
     656                     "Centre of covariance matrix in x", -xMinCovar);
     657    psMetadataAddS32(header, PS_LIST_TAIL, "COVARIANCE.CENTRE.Y", PS_META_REPLACE,
     658                     "Centre of covariance matrix in y", -yMinCovar);
     659
     660    // Write images
     661    if (!psFitsWriteImageCube(fits, header, images, extname)) {
     662        psError(PS_ERR_UNKNOWN, false, "Unable to write covariances from chip %s, cell %s to extension %s",
     663                chipName, cellName, extname);
     664        psFree(extname);
     665        psFree(header);
     666        psFree(images);
     667        return 0;
     668    }
     669    psFree(extname);
     670    psFree(header);
     671    psFree(images);
     672
     673    return true;
     674}
     675
     676
     677bool pmChipWriteCovariance(psFits *fits, const pmChip *chip)
     678{
     679    PS_ASSERT_PTR_NON_NULL(chip, false);
     680    PS_ASSERT_PTR_NON_NULL(fits, false);
     681
     682    psArray *cells = chip->cells;       // Array of cells
     683    for (int i = 0; i < cells->n; i++) {
     684        pmCell *cell = cells->data[i];  // Cell of interest
     685        if (!pmCellWriteCovariance(fits, cell)) {
     686            return false;
     687        }
     688    }
     689
     690    return true;
     691}
     692
     693
     694bool pmFPAWriteCovariance(psFits *fits, const pmFPA *fpa)
     695{
     696    PS_ASSERT_PTR_NON_NULL(fpa, false);
     697    PS_ASSERT_PTR_NON_NULL(fits, false);
     698
     699    psArray *chips = fpa->chips;        // Array of chips
     700    for (int i = 0; i < chips->n; i++) {
     701        pmChip *chip = chips->data[i];  // Chip of interest
     702        if (!pmChipWriteCovariance(fits, chip)) {
     703            return false;
     704        }
     705    }
     706
     707    return true;
     708}
  • branches/pap_branch_20090128/psModules/src/camera/pmHDU.c

    r21264 r21269  
    1212#include "pmHDU.h"
    1313#include "pmFPA.h"
    14 
    15 #define COVARIANCE_INDICATOR "PS_COVAR" // FITS keyword to indicate if covariance matrices are present
    1614
    1715//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    162160    PS_ASSERT_PTR_NON_NULL(fits, false);
    163161
    164     if (!hduRead(hdu, &hdu->variances, fits)) {
    165         return false;
    166     }
    167 
    168     return true;
     162    return hduRead(hdu, &hdu->variances, fits);
    169163}
    170164
     
    246240    PS_ASSERT_PTR_NON_NULL(fits, false);
    247241
    248     pmHDUCovariancesWriteHeader(hdu);
    249 
    250242    psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
    251     if (!hduWrite(hdu, hdu->variances, hdu->masks, maskVal, fits)) {
    252         return false;
    253     }
    254     pmHDUCovarianceClearHeader(hdu);
    255 
    256     if (!pmHDUCovarianceWrite(hdu, fits)) {
    257         psError(PS_ERR_UNKNOWN, false, "Unable to write covariance");
    258         return false;
    259     }
    260 
    261     return true;
    262 }
     243    return hduWrite(hdu, hdu->variances, hdu->masks, maskVal, fits);
     244}
  • branches/pap_branch_20090128/psModules/src/camera/pmHDU.h

    r21264 r21269  
    44 * @author Paul Price, IfA
    55 *
    6  * @version $Revision: 1.9.22.2 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2009-02-02 18:05:38 $
     6 * @version $Revision: 1.9.22.3 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2009-02-03 00:37:06 $
    88 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    1717/// @addtogroup Camera Camera Layout
    1818/// @{
     19
     20#define PM_HDU_COVARIANCE_KEYWORD "PS_COVAR" // FITS keyword to indicate presence of a covariance matrix
    1921
    2022/// An instance of the FITS Header Data Unit
     
    3032    psArray *variances;                 ///< Variance in the pixel data, or NULL
    3133    psArray *masks;                     ///< Mask for the pixel data, or NULL
    32     psArray *covariances;               ///< Covariance matrices (pmHDUCovariance), or NULL
    3334} pmHDU;
    3435
  • branches/pap_branch_20090128/psModules/src/camera/pmHDUGenerate.c

    r21264 r21269  
    356356    psElemType maskType = 0;            // Type of readout masks
    357357    psElemType varianceType = 0;        // Type of readout variances
    358     psElemType covarianceType = 0;      // Type of readout covariances
    359358    {
    360359        psListIterator *iter = psListIteratorAlloc(cells, PS_LIST_HEAD, false); // Iterator for cells
     
    385384                    varianceType = checkTypes(varianceType, readout->variance->type.type);
    386385                }
    387                 if (!hdu->covariances && readout->covariance) {
    388                     covarianceType = checkTypes(covarianceType, PS_TYPE_F32);
    389                 }
    390386            }
    391387        }
    392388        psFree(iter);
    393389    }
    394     if (numReadouts == 0 || (imageType == 0 && maskType == 0 && varianceType == 0 && covarianceType == 0)) {
     390    if (numReadouts == 0 || (imageType == 0 && maskType == 0 && varianceType == 0)) {
    395391        // Nothing from which to create an HDU
    396392        psFree(cells);
     
    432428            hdu->variances->data[i] = variance;
    433429        }
    434     }
    435     if (covarianceType) {
    436         hdu->covariances = psHashAlloc(psListLength(cells));
    437430    }
    438431
     
    456449            psArray *readouts = cell->readouts; // Array of readouts
    457450
    458             // Check size of covariances
    459             int xMinCovar = INT_MAX, xMaxCovar = INT_MIN, yMinCovar = INT_MAX, yMaxCovar = INT_MIN; // Size
    460             if (covarianceType) {
    461                 for (int i = 0; i < readouts->n; i++) {
    462                     pmReadout *readout = readouts->data[i]; // The readout of interest
    463                     if (!readout) {
    464                         continue;
    465                     }
    466                     psKernel *covar = readout->covariance; // Covariance matrix
    467                     xMinCovar = PS_MIN(xMinCovar, covar->xMin);
    468                     xMaxCovar = PS_MAX(xMaxCovar, covar->xMax);
    469                     yMinCovar = PS_MIN(yMinCovar, covar->yMin);
    470                     yMaxCovar = PS_MAX(yMaxCovar, covar->yMax);
    471                 }
    472             }
    473 
    474451            psArray *hduImages = hdu->images; // Array of images in the HDU
    475452            psArray *hduMasks = hdu->masks; // Array of masks in the HDU
    476453            psArray *hduVariances = hdu->variances; // Array of variances in the HDU
    477             psArray *covariances = (covarianceType ? psArrayAlloc(readouts->n) : NULL; // Covariance images
    478454            for (int i = 0; i < readouts->n; i++) {
    479455                pmReadout *readout = readouts->data[i]; // The readout of interest
     
    496472                    psFree(readout->variance);
    497473                    readout->variance = new;
    498                 }
    499                 if (readout->covariance) {
    500                     psKernel *covar = readout->covariance; // Covariance matrix
    501                     int xMin = covar->xMin, xMax = covar->xMax, yMin = covar->yMin, yMax = covar->yMax;// Size
    502                     if (xMin == xMinCovar && xMax == xMaxCovar && yMin == yMinCovar && yMax == yMaxCovar) {
    503                         variances->data[i] = psMemIncrRefCounter(readout->covariance);
    504                     } else {
    505                         psKernel *new = psKernelAlloc(xMinCovar, xMaxCovar, yMinCovar, yMaxCovar);// New covar
    506                         psImageInit(covar->image, 0);
    507                         psImageOverlaySection(new->image, covar->image,
    508                                               xMinCovar - xMin, yMinCovar - yMin, "=");
    509                         variances->data[i] = new;
    510                     }
    511474                }
    512475
     
    533496            }
    534497            psFree(biassecsIter);
    535 
    536             if (covariances) {
    537                 const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME"); // Name of cell
    538                 pmChip *chip = cell->parent; // Parent chip
    539                 const char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME"); // Name of chip
    540                 if (!cellName || !chipName) {
    541                     psError(PS_ERR_UNKNOWN, false, "Unable to find cell or chip name.");
    542                     return false;
    543                 }
    544                 psString name = NULL; // Name for covariance extension
    545                 psStringAppend(&name, "COVAR_%s_%s", chipName, cellName);
    546                 if (psHashLookup(hdu->covariances, name)) {
    547                     psHashRemove(hash, name);
    548                 }
    549                 psHashAdd(hdu->covariances, name, covariance);
    550                 psFree(name);
    551             }
    552498        } // Iterating over cells within the HDU
    553499        psFree(iter);
     
    636582        return false;
    637583    }
    638     if (hdu->images && hdu->masks && hdu->variances && hdu->covariances) {
     584    if (hdu->images && hdu->masks && hdu->variances) {
    639585        // It's already here!
    640586        return true;
     
    686632        return generateForCells(chip);
    687633    }
    688     if (hdu->images && hdu->masks && hdu->variances && hdu->covariances) {
     634    if (hdu->images && hdu->masks && hdu->variances) {
    689635        // It's already here!
    690636        return true;
     
    735681        return generateForChips(fpa);
    736682    }
    737     if (hdu->images && hdu->masks && hdu->variances && hdu->covariances) {
     683    if (hdu->images && hdu->masks && hdu->variances) {
    738684        // It's already here!
    739685        return true;
Note: See TracChangeset for help on using the changeset viewer.