IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.