IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 10, 2010, 7:34:39 PM (16 years ago)
Author:
eugene
Message:

updates from eam_branches/20091201 (substantially changes to the kernel matching code; updates to pmDetection container, added pmPattern, etc)

Location:
trunk/psModules/src/camera
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPA.c

    r26466 r26893  
    105105    psFree(fpa->concepts);
    106106    psFree(fpa->analysis);
    107     psFree((void *)fpa->camera);
     107    psFree(fpa->camera);
    108108    psFree(fpa->hdu);
    109109
  • trunk/psModules/src/camera/pmFPAMaskWeight.c

    r26076 r26893  
    370370
    371371    psImage *image = readout->image, *mask = readout->mask, *variance = readout->variance; // Readout parts
    372 
    373372    int numCols = image->numCols, numRows = image->numRows; // Size of image
    374     int numPix = numCols * numRows;                         // Number of pixels
    375     int num = PS_MAX(sample, numPix);                       // Number we care about
     373
     374    int xMin, xMax, yMin, yMax;         // Bounds of image
     375    if (mask) {
     376        xMin = numCols;
     377        xMax = 0;
     378        yMin = numRows;
     379        yMax = 0;
     380        for (int y = 0; y < numRows; y++) {
     381            for (int x = 0; x < numCols; x++) {
     382                if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
     383                    continue;
     384                }
     385                xMin = PS_MIN(xMin, x);
     386                xMax = PS_MAX(xMax, x);
     387                yMin = PS_MIN(yMin, y);
     388                yMax = PS_MAX(yMax, y);
     389            }
     390        }
     391    } else {
     392        xMin = 0;
     393        xMax = numCols;
     394        yMin = 0;
     395        yMax = numRows;
     396    }
     397
     398    int xNum = xMax - xMin, yNum = yMax - yMin; // Number of pixels
     399
     400    int numPix = xNum * yNum;                                  // Number of pixels
     401    int num = PS_MIN(sample, numPix);                          // Number we care about
    376402    psVector *signoise = psVectorAllocEmpty(num, PS_TYPE_F32);   // Signal-to-noise values
    377403
     
    379405        // We have an image smaller than Nsubset, so just loop over the image pixels
    380406        int index = 0;                  // Index for vector
    381         for (int y = 0; y < numRows; y++) {
    382             for (int x = 0; x < numCols; x++) {
     407        for (int y = yMin; y < yMax; y++) {
     408            for (int x = xMin; x < xMax; x++) {
    383409                if ((mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) ||
    384410                    !isfinite(image->data.F32[y][x]) || !isfinite(variance->data.F32[y][x])) {
     
    397423            // Pixel coordinates
    398424            int pixel = numPix * psRandomUniform(rng);
    399             int x = pixel % numCols;
    400             int y = pixel / numCols;
     425            int x = xMin + pixel % xNum;
     426            int y = yMin + pixel / xNum;
    401427
    402428            if ((mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) ||
     
    428454    // Check valid range of correction factor
    429455    if ((isfinite(minValid) && correction < minValid) || (isfinite(maxValid) && correction > maxValid)) {
    430         psWarning("Variance renormalisation is outside valid range: %f vs %f:%f --- no correction made",
    431                   correction, minValid, maxValid);
    432         return true;
    433     }
    434 
    435     psBinaryOp(variance, variance, "*", psScalarAlloc(PS_SQR(correction), PS_TYPE_F32));
     456        psError(PS_ERR_UNKNOWN, true, "Variance renormalisation is outside valid range: %f vs %f:%f --- no correction made", correction, minValid, maxValid);
     457        psMetadataAddF32(readout->analysis, PS_LIST_TAIL, PM_READOUT_ANALYSIS_RENORM, 0, "Renormalisation of variance", PS_SQR(correction));
     458        return false;
     459    }
     460
     461    psImage *subImage = psImageSubset(variance, psRegionSet(xMin, xMax, yMin, yMax)); // Smaller image
     462    psBinaryOp(subImage, subImage, "*", psScalarAlloc(PS_SQR(correction), PS_TYPE_F32));
     463    psFree(subImage);
    436464
    437465    pmHDU *hdu = pmHDUFromReadout(readout); // HDU for readout
  • trunk/psModules/src/camera/pmFPAMosaic.c

    r25383 r26893  
    626626    bool good = true;                   // Is everything good?
    627627
     628    const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME"); // Name of cell
     629    const char *chipName = psMetadataLookupStr(NULL, cell->parent->concepts, "CHIP.NAME"); // Name of chip
     630
    628631    // Offset of the cell on the chip
    629632    int x0Cell = psMetadataLookupS32(&mdok, cell->concepts, "CELL.X0");
    630633    if (!mdok) {
    631         psError(PS_ERR_UNKNOWN, true, "CELL.X0 for cell is not set.\n");
     634        psError(PS_ERR_UNKNOWN, true, "CELL.X0 for cell %s,%s is not set.\n", chipName, cellName);
    632635        good = false;
    633636    }
    634637    int y0Cell = psMetadataLookupS32(&mdok, cell->concepts, "CELL.Y0");
    635638    if (!mdok) {
    636         psError(PS_ERR_UNKNOWN, true, "CELL.Y0 for cell is not set.\n");
     639        psError(PS_ERR_UNKNOWN, true, "CELL.Y0 for cell %s,%s is not set.\n", chipName, cellName);
    637640        good = false;
    638641    }
    639     psTrace("psModules.camera", 5, "Cell %ld: x0=%d y0=%d\n", index, x0Cell, y0Cell);
     642    psTrace("psModules.camera", 5, "Cell %s,%s (%ld): x0=%d y0=%d\n",
     643            chipName, cellName, index, x0Cell, y0Cell);
    640644
    641645    // Offset of the chip on the FPA
     
    649653        x0Chip = psMetadataLookupS32(&mdok, chip->concepts, "CHIP.X0");
    650654        if (!mdok) {
    651             psError(PS_ERR_UNKNOWN, true, "CHIP.X0 for chip is not set.\n");
     655            psError(PS_ERR_UNKNOWN, true, "CHIP.X0 for chip %s is not set.\n", chipName);
    652656            good = false;
    653657        }
    654658        y0Chip = psMetadataLookupS32(&mdok, chip->concepts, "CHIP.Y0");
    655659        if (!mdok) {
    656             psError(PS_ERR_UNKNOWN, true, "CHIP.Y0 for chip is not set.\n");
     660            psError(PS_ERR_UNKNOWN, true, "CHIP.Y0 for chip %s is not set.\n", chipName);
    657661            good = false;
    658662        }
     
    662666    xBin->data.S32[index] = psMetadataLookupS32(&mdok, cell->concepts, "CELL.XBIN");
    663667    if (!mdok || xBin->data.S32[index] == 0) {
    664         psError(PS_ERR_UNKNOWN, true, "CELL.XBIN for cell is not set.\n");
     668        psError(PS_ERR_UNKNOWN, true, "CELL.XBIN for cell %s,%s is not set.\n", chipName, cellName);
    665669        return false;
    666670    } else if (xBin->data.S32[index] < *xBinMin) {
     
    669673    yBin->data.S32[index] = psMetadataLookupS32(&mdok, cell->concepts, "CELL.YBIN");
    670674    if (!mdok || yBin->data.S32[index] == 0) {
    671         psError(PS_ERR_UNKNOWN, true, "CELL.YBIN for cell is not set.\n");
     675        psError(PS_ERR_UNKNOWN, true, "CELL.YBIN for cell %s,%s is not set.\n", chipName, cellName);
    672676        return false;
    673677    } else if (yBin->data.S32[index] < *yBinMin) {
     
    678682    int xParityCell = psMetadataLookupS32(&mdok, cell->concepts, "CELL.XPARITY");
    679683    if (!mdok || (xParityCell != 1 && xParityCell != -1)) {
    680         psError(PS_ERR_UNKNOWN, true, "CELL.XPARITY for cell is not set.\n");
     684        psError(PS_ERR_UNKNOWN, true, "CELL.XPARITY for cell %s,%s is not set.\n", chipName, cellName);
    681685        return false;
    682686    }
    683687    int yParityCell = psMetadataLookupS32(&mdok, cell->concepts, "CELL.YPARITY");
    684688    if (!mdok || (yParityCell != 1 && yParityCell != -1)) {
    685         psError(PS_ERR_UNKNOWN, true, "CELL.YPARITY for cell is not set.\n");
     689        psError(PS_ERR_UNKNOWN, true, "CELL.YPARITY for cell %s,%s is not set.\n", chipName, cellName);
    686690        return false;
    687691    }
     
    693697        xParityChip = psMetadataLookupS32(&mdok, chip->concepts, "CHIP.XPARITY");
    694698        if (!mdok || (xParityChip != 1 && xParityChip != -1)) {
    695             psError(PS_ERR_UNKNOWN, true, "CHIP.XPARITY for chip is not set.\n");
     699            psError(PS_ERR_UNKNOWN, true, "CHIP.XPARITY for chip %s is not set.\n", chipName);
    696700            return false;
    697701        }
    698702        yParityChip = psMetadataLookupS32(&mdok, chip->concepts, "CHIP.YPARITY");
    699703        if (!mdok || (yParityChip != 1 && yParityChip != -1)) {
    700             psError(PS_ERR_UNKNOWN, true, "CHIP.YPARITY for chip is not set.\n");
     704            psError(PS_ERR_UNKNOWN, true, "CHIP.YPARITY for chip %s is not set.\n", chipName);
    701705            return false;
    702706        }
  • trunk/psModules/src/camera/pmFPAfile.c

    r23746 r26893  
    519519    if (!strcasecmp(type, "SUBKERNEL"))     {
    520520        return PM_FPA_FILE_SUBKERNEL;
     521    }
     522    if (!strcasecmp(type, "PATTERN")) {
     523        return PM_FPA_FILE_PATTERN;
    521524    }
    522525
     
    563566      case PM_FPA_FILE_SUBKERNEL:
    564567        return ("SUBKERNEL");
     568      case PM_FPA_FILE_PATTERN:
     569        return "PATTERN";
    565570      default:
    566571        return ("NONE");
  • trunk/psModules/src/camera/pmFPAfile.h

    r25979 r26893  
    4949    PM_FPA_FILE_SUBKERNEL,
    5050    PM_FPA_FILE_SRCTEXT,
     51    PM_FPA_FILE_PATTERN,
    5152} pmFPAfileType;
    5253
  • trunk/psModules/src/camera/pmFPAfileIO.c

    r25979 r26893  
    4343#include "pmFPAConstruct.h"
    4444#include "pmSubtractionIO.h"
     45#include "pmPatternIO.h"
    4546#include "pmConcepts.h"
    4647#include "pmConfigRun.h"
     
    6667
    6768        switch (place) {
    68           case PM_FPA_BEFORE:
     69          case PM_FPA_BEFORE:
    6970            if (!pmFPAfileRead (file, view, config)) {
    7071                psError(PS_ERR_IO, false, "failed READ in FPA_BEFORE block for %s", file->name);
     
    7677            }
    7778            break;
    78           case PM_FPA_AFTER:
    79             if (!pmFPAfileWrite (file, view, config)) {
     79          case PM_FPA_AFTER:
     80            if (!pmFPAfileWrite (file, view, config)) {
    8081                psError(PS_ERR_IO, false, "failed WRITE in FPA_AFTER block for %s", file->name);
    8182                goto failure;
     
    8687            }
    8788            break;
    88           default:
     89          default:
    8990            psAbort("You can't get here");
    9091        }
     
    202203        status = pmSubtractionReadKernels(view, file, config);
    203204        break;
     205      case PM_FPA_FILE_PATTERN:
     206        status = pmPatternRead(view, file, config);
     207        break;
    204208      case PM_FPA_FILE_SX:
    205209      case PM_FPA_FILE_RAW:
     
    273277      case PM_FPA_FILE_VARIANCE:
    274278      case PM_FPA_FILE_FRINGE:
    275       case PM_FPA_FILE_DARK: {
    276           // create FPA structure component based on view
    277           psMetadata *format = file->format; // Camera format configuration
    278           if (!format) {
    279               format = config->format;
    280           }
    281 
    282           pmFPA *nameSource = file->src; // Source of FPA.OBS
    283           if (!nameSource) {
    284               nameSource = file->fpa;
    285           }
    286           bool mdok;                  // Status of MD lookup
    287           const char *fpaObs = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.OBS"); // Obs. id
    288 
    289           pmFPAAddSourceFromView(file->fpa, fpaObs, view, format);
    290           psTrace ("psModules.camera", 5, "created fpa data elements for %s (%s) (%d:%d:%d)\n",
    291                    file->name, file->name, view->chip, view->cell, view->readout);
    292           break;
    293       }
     279      case PM_FPA_FILE_DARK:
     280      case PM_FPA_FILE_PATTERN:
     281        {
     282            // create FPA structure component based on view
     283            psMetadata *format = file->format; // Camera format configuration
     284            if (!format) {
     285                format = config->format;
     286            }
     287
     288            pmFPA *nameSource = file->src; // Source of FPA.OBS
     289            if (!nameSource) {
     290                nameSource = file->fpa;
     291            }
     292            bool mdok;                  // Status of MD lookup
     293            const char *fpaObs = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.OBS"); // Obs. id
     294
     295            pmFPAAddSourceFromView(file->fpa, fpaObs, view, format);
     296            psTrace ("psModules.camera", 5, "created fpa data elements for %s (%s) (%d:%d:%d)\n",
     297                     file->name, file->name, view->chip, view->cell, view->readout);
     298            break;
     299        }
    294300      case PM_FPA_FILE_HEADER:
    295301        psAbort ("Create not defined for HEADER");
     
    462468        status = pmSubtractionWriteKernels(view, file, config);
    463469        break;
     470      case PM_FPA_FILE_PATTERN:
     471        status = pmPatternWrite(view, file, config);
     472        break;
    464473      case PM_FPA_FILE_SX:
    465474      case PM_FPA_FILE_RAW:
     
    543552      case PM_FPA_FILE_DARK:
    544553      case PM_FPA_FILE_SUBKERNEL:
     554      case PM_FPA_FILE_PATTERN:
    545555      case PM_FPA_FILE_CMF:
    546556      case PM_FPA_FILE_WCS:
     
    610620        break;
    611621      case PM_FPA_FILE_SUBKERNEL:
     622      case PM_FPA_FILE_PATTERN:
    612623      case PM_FPA_FILE_SX:
    613624      case PM_FPA_FILE_RAW:
     
    771782      case PM_FPA_FILE_DARK:
    772783      case PM_FPA_FILE_SUBKERNEL:
     784      case PM_FPA_FILE_PATTERN:
    773785      case PM_FPA_FILE_CMF:
    774786      case PM_FPA_FILE_WCS:
     
    962974      case PM_FPA_FILE_SUBKERNEL:
    963975        status = pmSubtractionWritePHU(view, file, config);
     976        break;
     977      case PM_FPA_FILE_PATTERN:
     978        status = pmPatternWritePHU(view, file, config);
     979        break;
    964980      case PM_FPA_FILE_CMF:
    965981        status = pmSource_CMF_WritePHU (view, file, config);
Note: See TracChangeset for help on using the changeset viewer.