IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5462


Ignore:
Timestamp:
Nov 2, 2005, 3:30:32 PM (21 years ago)
Author:
Paul Price
Message:

Working with release 8. Overscan, bias, flat-fielding all working.

Location:
trunk/archive/scripts/src/phase2
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/scripts/src/phase2/papPhase2.c

    r5371 r5462  
    250250            overscanFitType = PM_FIT_SPLINE;
    251251            int order = psMetadataLookupS32(NULL, recipe, "OVERSCAN.ORDER"); // Order of polynomial fit
    252 //          overscanFit = psSpline1DAlloc(order, PS_POLYNOMIAL_ORD);
     252            overscanFit = NULL;
     253//          overscanFit = psSpline1DAlloc();
    253254        } else if (strcasecmp(fit, "NONE") != 0) {
    254255            psLogMsg("phase2", PS_LOG_WARN, "OVERSCAN.FIT (%s) is not one of NONE, POLYNOMIAL, or SPLINE:"
     
    292293
    293294    // Read in the input pixels
     295    psLogMsg("phase2", PS_LOG_INFO, "Opening input image: %s\n", inputName);
    294296    if (! pmFPARead(input, inputFile, header, database)) {
    295297        psErrorStackPrint(stderr, "Unable to populate camera from FITS file: %s\n", inputName);
     
    316318            exit(EXIT_FAILURE);
    317319        }
     320        psLogMsg("phase2", PS_LOG_INFO, "Opening bias image: %s\n", biasName);
     321        if (! pmFPARead(bias, biasFile, biasHeader, database)) {
     322            psErrorStackPrint(stderr, "Unable to populate bias camera from fits FITS: %s\n", biasName);
     323            exit(EXIT_FAILURE);
     324        }
    318325        psFree(biasHeader);
    319         if (! pmFPARead(bias, biasFile, NULL, database)) {
    320             psErrorStackPrint(stderr, "Unable to populate bias camera from fits FITS: %s\n", biasName);
    321             exit(EXIT_FAILURE);
    322         }
    323326#ifdef PRODUCTION
    324327        psFitsClose(biasFile);
     
    339342            exit(EXIT_FAILURE);
    340343        }
     344        psLogMsg("phase2", PS_LOG_INFO, "Opening dark image: %s\n", darkName);
     345        if (! pmFPARead(dark, darkFile, darkHeader, database)) {
     346            psErrorStackPrint(stderr, "Unable to populate dark camera from fits FITS: %s\n", darkName);
     347            exit(EXIT_FAILURE);
     348        }
    341349        psFree(darkHeader);
    342         if (! pmFPARead(dark, darkFile, NULL, database)) {
    343             psErrorStackPrint(stderr, "Unable to populate dark camera from fits FITS: %s\n", darkName);
    344             exit(EXIT_FAILURE);
    345         }
    346350#ifdef PRODUCTION
    347351        psFitsClose(darkFile);
     
    362366            exit(EXIT_FAILURE);
    363367        }
     368        psLogMsg("phase2", PS_LOG_INFO, "Opening mask image: %s\n", maskName);
     369        if (! pmFPARead(mask, maskFile, maskHeader, database)) {
     370            psErrorStackPrint(stderr, "Unable to populate mask camera from fits FITS: %s\n", maskName);
     371            exit(EXIT_FAILURE);
     372        }
    364373        psFree(maskHeader);
    365         if (! pmFPARead(mask, maskFile, NULL, database)) {
    366             psErrorStackPrint(stderr, "Unable to populate mask camera from fits FITS: %s\n", maskName);
    367             exit(EXIT_FAILURE);
    368         }
     374
    369375#ifdef PRODUCTION
    370376        psFitsClose(maskFile);
     
    380386        psFits *flatFile = psFitsAlloc(flatName);
    381387#endif
     388        if (! flatFile) {
     389            psErrorStackPrint(stderr, "Can't open flat image: %s\n", flatName);
     390            exit(EXIT_FAILURE);
     391        }
    382392        psMetadata *flatHeader = psFitsReadHeader(NULL, flatFile); // FITS header for flat
    383393        if (! pmConfigValidateCamera(camera, flatHeader)) {
     
    385395            exit(EXIT_FAILURE);
    386396        }
     397        psLogMsg("phase2", PS_LOG_INFO, "Opening flat image: %s\n", flatName);
     398        if (! pmFPARead(flat, flatFile, flatHeader, database)) {
     399            psErrorStackPrint(stderr, "Unable to populate flat camera from fits FITS: %s\n", flatName);
     400            exit(EXIT_FAILURE);
     401        }
    387402        psFree(flatHeader);
    388         if (! pmFPARead(flat, flatFile, NULL, database)) {
    389             psErrorStackPrint(stderr, "Unable to populate flat camera from fits FITS: %s\n", flatName);
    390             exit(EXIT_FAILURE);
    391         }
    392403#ifdef PRODUCTION
    393404        psFitsClose(flatFile);
     
    499510                    } else {
    500511                        switch (dataItem->type) {
    501                           case PS_META_VEC:
     512                          case PS_DATA_VECTOR:
    502513                            {
    503514                                // These are the polynomial coefficients
     
    518529                            }
    519530                            break;
    520                           case PS_META_STR:
     531                          case PS_DATA_STRING:
    521532                            {
    522533                                // This is a filename
     
    536547                            }
    537548                            break;
    538                           case PS_META_META:
     549                          case PS_DATA_METADATA:
    539550                            {
    540551                                // This is a menu
     
    550561                                        psLogMsg("phase2", PS_LOG_WARN, "Unable to find value of concept %s "
    551562                                                 "for non-linearity correction --- ignored.\n", concept);
    552                                     } else if (conceptValueItem->type != PS_META_STR) {
     563                                    } else if (conceptValueItem->type != PS_DATA_STRING) {
    553564                                        psLogMsg("phase2", PS_LOG_WARN, "Type for concept %s isn't STRING, as"
    554565                                                 " expected for non-linearity correction --- ignored.\n",
     
    561572                                            psLogMsg("phase2", PS_LOG_WARN, "Unable to find %s in NONLIN.DATA"
    562573                                                     " --- ignored.\n", conceptValue);
    563                                         } else if (optionItem->type == PS_META_VEC) {
     574                                        } else if (optionItem->type == PS_DATA_VECTOR) {
    564575                                            // These are the polynomial coefficients
    565576                                            psVector *coeff = optionItem->data.V; // The coefficient vector
     
    578589                                            psFree(coeff);
    579590                                            psFree(correction);
    580                                         } else if (optionItem->type == PS_META_STR) {
     591                                        } else if (optionItem->type == PS_DATA_STRING) {
    581592                                            // This is a filename
    582593                                            psString tableName = optionItem->data.V; // The filename
     
    673684                    // Output overscan fit results, if required
    674685                    if (doOverscan) {
    675                         switch (overscanFitType) {
    676                           case PM_FIT_POLYNOMIAL:
    677                             {
    678                                 psPolynomial1D *poly = (psPolynomial1D*)overscanFit;    // The polynomial
    679                                 psString coeffs = NULL; // String containing the coefficients
    680                                 for (int i = 0; i < poly->n; i++) {
    681                                     psStringAppend(&coeffs, "%e ", poly->coeff[i]);
    682                                 }
    683                                 psLogMsg("phase2", PS_LOG_INFO, "Overscan polynomial coefficients:\n%s\n",
    684                                          coeffs);
    685                                 psFree(coeffs);
    686                             }
    687                             break;
    688                           case PM_FIT_SPLINE:
    689                             {
    690                                 psSpline1D *spline = (psSpline1D*)overscanFit; // The spline
    691                                 psString coeffs = NULL; // String containing the coefficients
    692                                 for (int i = 0; i < spline->n; i++) {
    693                                     psPolynomial1D *poly = spline->spline[i]; // i-th polynomial
    694                                     psStringAppend(&coeffs, "%d: ", i);
    695                                     for (int j = 0; j < poly->n; j++) {
     686                        if (! overscanFit) {
     687                            psLogMsg("phase2", PS_LOG_WARN, "No fit generated!\n");
     688                        } else {
     689                            switch (overscanFitType) {
     690                              case PM_FIT_POLYNOMIAL:
     691                                {
     692                                    psPolynomial1D *poly = (psPolynomial1D*)overscanFit; // The polynomial
     693                                    psString coeffs = NULL;     // String containing the coefficients
     694                                    for (int i = 0; i < poly->nX; i++) {
    696695                                        psStringAppend(&coeffs, "%e ", poly->coeff[i]);
    697696                                    }
    698                                     psStringAppend(&coeffs, "\n");
     697                                    psLogMsg("phase2", PS_LOG_INFO, "Overscan polynomial coefficients:\n%s\n",
     698                                             coeffs);
     699                                    psFree(coeffs);
    699700                                }
    700                                 psLogMsg("phase2", PS_LOG_INFO, "Overscan spline coefficients:\n%s\n",
    701                                          coeffs);
    702                                 psFree(coeffs);
     701                                break;
     702                              case PM_FIT_SPLINE:
     703                                {
     704                                    psSpline1D *spline = (psSpline1D*)overscanFit; // The spline
     705                                    psString coeffs = NULL;     // String containing the coefficients
     706                                    for (int i = 0; i < spline->n; i++) {
     707                                        psPolynomial1D *poly = spline->spline[i]; // i-th polynomial
     708                                        psStringAppend(&coeffs, "%d: ", i);
     709                                        for (int j = 0; j < poly->nX; j++) {
     710                                            psStringAppend(&coeffs, "%e ", poly->coeff[i]);
     711                                        }
     712                                        psStringAppend(&coeffs, "\n");
     713                                    }
     714                                    psLogMsg("phase2", PS_LOG_INFO, "Overscan spline coefficients:\n%s\n",
     715                                             coeffs);
     716                                    psFree(coeffs);
     717                                }
     718                                break;
     719                              case PM_FIT_NONE:
     720                                break;
     721                              default:
     722                                psAbort(__func__, "Should never get here!!!\n");
    703723                            }
    704                             break;
    705                           case PM_FIT_NONE:
    706                             break;
    707                           default:
    708                             psAbort(__func__, "Should never get here!!!\n");
    709724                        }
    710725                    }
    711726                }
    712727
     728                // Trim, so that flat, fringe etc computations are faster.
     729                psRegion *trimRegion = psMetadataLookupPtr(NULL, inputCell->concepts, "CELL.TRIMSEC");
     730                psImage *trimmed = psImageSubset(inputReadout->image, *trimRegion);
     731                psFree(inputReadout->image);
     732                inputReadout->image = trimmed;
     733
    713734                // Flat-field correction
    714735                if (doFlat) {
    715                     (void)pmFlatField(inputReadout, flatReadout);
     736                    psLogMsg("phase2", PS_LOG_INFO, "Performing flat field.\n");
     737#ifndef PRODUCTION
     738                    psImage *dummyImage = psImageAlloc(inputReadout->image->numCols,
     739                                                       inputReadout->image->numRows,
     740                                                       PS_TYPE_U8);
     741                    pmReadout *dummyMask = pmReadoutAlloc(NULL, dummyImage, NULL, 0, 0, 1, 1, 1, 1);
     742                    (void)pmFlatField(inputReadout, dummyMask, flatReadout);
     743                    psFree(dummyMask);
     744                    psFree(dummyImage);
     745#endif
    716746                }
    717747
  • trunk/archive/scripts/src/phase2/phase2.config

    r5371 r5462  
    33# List of tasks to perform
    44MASK            BOOL    FALSE           # Mask bad pixels
    5 NONLIN          BOOL    FALSE           # Non-linearity correction
     5NONLIN          BOOL    TRUE            # Non-linearity correction
    66BIAS            BOOL    FALSE           # Bias subtraction
    77DARK            BOOL    FALSE           # Dark subtraction
    8 OVERSCAN        BOOL    TRUE            # Overscan subtraction
     8OVERSCAN        BOOL    FALSE           # Overscan subtraction
    99FLAT            BOOL    FALSE           # Flat-field normalisation
    1010FRINGE          BOOL    FALSE           # Fringe subtraction
     
    5858# Overscan subtraction
    5959OVERSCAN.MODE           STR     INDIVIDUAL      # NONE | INDIVIDUAL | ALL
    60 OVERSCAN.FIT            STR     SPLINE          # NONE | POLYNOMIAL | SPLINE
    61 OVERSCAN.ORDER          S32     10              # Order of polynomial fit
     60#OVERSCAN.FIT           STR     SPLINE          # NONE | POLYNOMIAL | SPLINE
     61OVERSCAN.FIT            STR     POLYNOMIAL      # NONE | POLYNOMIAL | SPLINE
     62OVERSCAN.ORDER          S32     5               # Order of polynomial fit
    6263OVERSCAN.BIN            S32     0               # Number of pixels per bin
    6364OVERSCAN.STAT           STR     MEAN            # MEAN | MEDIAN
  • trunk/archive/scripts/src/phase2/pmConfig.c

    r5104 r5462  
    141141        psMetadataItem *traceItem = NULL; // Item from MD iteration
    142142        while (traceItem = psMetadataGetAndIncrement(traceIter)) {
    143             if (traceItem->type != PS_META_S32) {
     143            if (traceItem->type != PS_DATA_S32) {
    144144                psLogMsg(__func__, PS_LOG_WARN, "The level for trace component %s is not of type S32 (%x)\n",
    145145                         traceItem->name, traceItem->type);
     
    181181        // Check to see if the rule works
    182182        switch (ruleItem->type) {
    183           case PS_META_STR:
     183          case PS_DATA_STRING:
    184184            psTrace(__func__, 8, "Matching %s: '%s' vs '%s'\n", ruleItem->name,
    185185                    ruleItem->data.V, headerItem->data.V);
     
    247247                cameraItem->comment);
    248248        psMetadata *camera = NULL;      // The camera metadata
    249         if (cameraItem->type == PS_META_META) {
     249        if (cameraItem->type == PS_DATA_METADATA) {
    250250            camera = psMemIncrRefCounter(cameraItem->data.md);
    251         } else if (cameraItem->type == PS_META_STR) {
     251        } else if (cameraItem->type == PS_DATA_STRING) {
    252252            psTrace(__func__, 5, "Reading camera configuration for %s...\n", cameraItem->name);
    253253            int badLines = 0;           // Number of bad lines in reading camera configuration
  • trunk/archive/scripts/src/phase2/pmFPA.c

    r5371 r5462  
    202202    pmReadout *readout = psAlloc(sizeof(pmReadout));
    203203    psMemSetDeallocator(readout, (psFreeFunc)p_pmReadoutFree);
    204     cell->readouts = psArrayAdd(cell->readouts, 0, readout);
     204    if (cell) {
     205        cell->readouts = psArrayAdd(cell->readouts, 0, readout);
     206    }
    205207   
    206208    // Set the components
  • trunk/archive/scripts/src/phase2/pmFPA.h

    r5371 r5462  
    66
    77// Temporary metadata types
    8 #define PS_META_CHIP PS_META_UNKNOWN
    9 #define PS_META_CELL PS_META_UNKNOWN
     8//#define PS_META_CHIP PS_DATA_UNKNOWN
     9//#define PS_META_CELL PS_DATA_UNKNOWN
    1010
    1111typedef struct {
  • trunk/archive/scripts/src/phase2/pmFPAConceptsGet.c

    r5371 r5462  
    100100    psMetadataItem *defItem = psMetadataLookup(defaults, concept);
    101101    if (defItem) {
    102         if (defItem->type == PS_META_META) {
     102        if (defItem->type == PS_DATA_METADATA) {
    103103            // A dependent default
    104104            psTrace(__func__, 7, "Evaluating dependent default....\n");
     
    122122                return NULL;
    123123            }
    124             if (depItem->type != PS_META_STR) {
     124            if (depItem->type != PS_DATA_STRING) {
    125125                psError(PS_ERR_IO, true, "Value of %s is not of type string, as required for dependency"
    126126                        " --- ignored.\n", dependsOn);
     
    270270    if (item) {
    271271        switch (item->type) {
    272           case PS_META_F32:
     272          case PS_DATA_F32:
    273273            value = item->data.F32;
    274274            break;
    275           case PS_META_F64:
     275          case PS_DATA_F64:
    276276            // Assume it's OK to truncate to floating point from double
    277277            value = (float)item->data.F64;
    278278            break;
    279           case PS_META_S32:
     279          case PS_DATA_S32:
    280280            // Promote to float
    281281            value = (float)item->data.S32;
     
    370370    if (item) {
    371371        switch (item->type) {
    372           case PS_META_STR:
     372          case PS_DATA_STRING:
    373373            value = item->data.V;
    374374            break;
     
    383383    psTrace(__func__, 7, "Adding %s (%s): %s\n", name, comment, value);
    384384
    385     psMetadataAdd(concepts, PS_LIST_TAIL, name, PS_META_STR, comment, value);
     385    psMetadataAdd(concepts, PS_LIST_TAIL, name, PS_DATA_STRING, comment, value);
    386386}
    387387
     
    428428                ra = raItem->data.F64;
    429429                break;
    430               case PS_META_STR:
     430              case PS_DATA_STRING:
    431431                // Sexagesimal format
    432432                {
     
    480480        }
    481481
    482         psMetadataAdd(fpa->concepts, PS_LIST_TAIL, "FPA.RA", PS_META_F64,
     482        psMetadataAdd(fpa->concepts, PS_LIST_TAIL, "FPA.RA", PS_DATA_F64,
    483483                      "Right Ascension of the boresight (radians)", ra);
    484484
     
    497497                dec = decItem->data.F64;
    498498                break;
    499               case PS_META_STR:
     499              case PS_DATA_STRING:
    500500                // Sexagesimal format
    501501                {
     
    549549        }
    550550
    551         psMetadataAdd(fpa->concepts, PS_LIST_TAIL, "FPA.DEC", PS_META_F64,
     551        psMetadataAdd(fpa->concepts, PS_LIST_TAIL, "FPA.DEC", PS_DATA_F64,
    552552                      "Declination of the boresight (radians)", dec);
    553553
     
    633633            psError(PS_ERR_IO, false, "Couldn't find CELL.TRIMSEC.\n");
    634634            *trimsec = psRegionSet(0.0, 0.0, 0.0, 0.0);
    635         } else if (secItem->type != PS_META_STR) {
     635        } else if (secItem->type != PS_DATA_STRING) {
    636636            psError(PS_ERR_IO, true, "CELL.TRIMSEC is not of type STR (%x)\n", secItem->type);
    637637            *trimsec = psRegionSet(0.0, 0.0, 0.0, 0.0);
     
    643643                psError(PS_ERR_IO, false, "Couldn't find CELL.TRIMSEC.SOURCE.\n");
    644644                *trimsec = psRegionSet(0.0, 0.0, 0.0, 0.0);
    645             } else if (sourceItem->type != PS_META_STR) {
     645            } else if (sourceItem->type != PS_DATA_STRING) {
    646646                psError(PS_ERR_IO, true, "CELL.TRIMSEC.SOURCE is not of type STR (%x)\n", sourceItem->type);
    647647                *trimsec = psRegionSet(0.0, 0.0, 0.0, 0.0);
     
    681681        } // Looking up CELL.TRIMSEC
    682682
    683         psMetadataAdd(cell->concepts, PS_LIST_TAIL, "CELL.TRIMSEC", PS_META_UNKNOWN,
     683        psMetadataAdd(cell->concepts, PS_LIST_TAIL, "CELL.TRIMSEC", PS_DATA_UNKNOWN,
    684684                      "Trim section", trimsec);
    685685        psFree(trimsec);
     
    693693        if (! secItem) {
    694694            psError(PS_ERR_IO, false, "Couldn't find CELL.BIASSEC.\n");
    695         } else if (secItem->type != PS_META_STR) {
     695        } else if (secItem->type != PS_DATA_STRING) {
    696696            psError(PS_ERR_IO, true, "CELL.BIASSEC is not of type STR (%x)\n", secItem->type);
    697697        } else {
     
    701701            if (! sourceItem) {
    702702                psError(PS_ERR_IO, false, "Couldn't find CELL.BIASSEC.SOURCE.\n");
    703             } else if (sourceItem->type != PS_META_STR) {
     703            } else if (sourceItem->type != PS_DATA_STRING) {
    704704                psError(PS_ERR_IO, true, "CELL.BIASSEC.SOURCE is not of type STR (%x)\n", sourceItem->type);
    705705            } else {
     
    752752        } // Looking up CELL.BIASSEC
    753753
    754         psMetadataAdd(cell->concepts, PS_LIST_TAIL, "CELL.BIASSEC", PS_META_LIST, "Bias sections", biassecs);
     754        psMetadataAdd(cell->concepts, PS_LIST_TAIL, "CELL.BIASSEC", PS_DATA_LIST, "Bias sections", biassecs);
    755755        psFree(biassecs);
    756756    }
     
    762762        if (! binItem) {
    763763            psError(PS_ERR_IO, false, "Couldn't find CELL.XBIN.\n");
    764         } else if (binItem->type == PS_META_STR) {
     764        } else if (binItem->type == PS_DATA_STRING) {
    765765            psString binString = binItem->data.V; // The string containing the binning
    766766            if (sscanf(binString, "%d %*d", &xBin) != 1 &&
     
    784784        if (! binItem) {
    785785            psError(PS_ERR_IO, false, "Couldn't find CELL.YBIN.\n");
    786         } else if (binItem->type == PS_META_STR) {
     786        } else if (binItem->type == PS_DATA_STRING) {
    787787            psString binString = binItem->data.V; // The string containing the binning
    788788            if (sscanf(binString, "%*d %d", &yBin) != 1 &&
     
    809809        if (! sysItem) {
    810810            psError(PS_ERR_IO, true, "Couldn't find CELL.TIMESYS --- assuming UTC.\n");
    811         } else if (sysItem->type != PS_META_STR) {
     811        } else if (sysItem->type != PS_DATA_STRING) {
    812812            psError(PS_ERR_IO, true, "CELL.TIMESYS isn't of type STRING --- assuming UTC.\n");
    813813        } else {
     
    839839                if (mdok && strlen(timeFormat) > 0) {
    840840                    switch (timeItem->type) {
    841                       case PS_META_STR:
     841                      case PS_DATA_STRING:
    842842                        {
    843843                            psString timeString = timeItem->data.V;     // String with the time
     
    887887                                            psError(PS_ERR_IO, false, "Unable to find time header: %s\n",
    888888                                                    timeName);
    889                                         } else if (timeItem->type == PS_META_STR) {
     889                                        } else if (timeItem->type == PS_DATA_STRING) {
    890890                                            // Time is a string, in the usual way:
    891891                                            psStringAppend(&dateString, "T%s", timeItem->data.V);
     
    965965        } // Getting CELL.TIME
    966966
    967         psMetadataAdd(cell->concepts, PS_LIST_TAIL, "CELL.TIME", PS_META_UNKNOWN, "Time of exposure", time);
     967        psMetadataAdd(cell->concepts, PS_LIST_TAIL, "CELL.TIME", PS_DATA_UNKNOWN, "Time of exposure", time);
    968968        psFree(time);
    969969    }
  • trunk/archive/scripts/src/phase2/pmFPAConceptsSet.c

    r5371 r5462  
    6868        }
    6969        return (item1->data.F64 == item2->data.F64) ? true : false;
    70       case PS_META_STR:
    71         if (item2->type != PS_META_STR) {
     70      case PS_DATA_STRING:
     71        if (item2->type != PS_DATA_STRING) {
    7272            return false;
    7373        }
     
    112112        // XXX: Need to expand range of types
    113113        switch (concept->type) {
    114           case PS_META_STR:
     114          case PS_DATA_STRING:
    115115            headerItem = psMetadataItemAllocStr(keyword, concept->comment, concept->data.V);
    116116            break;
    117           case PS_META_S32:
     117          case PS_DATA_S32:
    118118            headerItem = psMetadataItemAllocS32(keyword, concept->comment, concept->data.S32);
    119119            break;
    120           case PS_META_F32:
     120          case PS_DATA_F32:
    121121            headerItem = psMetadataItemAllocF32(keyword, concept->comment, concept->data.F32);
    122122            break;
    123           case PS_META_F64:
     123          case PS_DATA_F64:
    124124            headerItem = psMetadataItemAllocF64(keyword, concept->comment, concept->data.F64);
    125125            break;
     
    183183    psMetadataItem *defItem = psMetadataLookup(defaults, concept->name);
    184184    if (defItem) {
    185         if (defItem->type == PS_META_META) {
     185        if (defItem->type == PS_DATA_METADATA) {
    186186            // A dependent default
    187187            psTrace(__func__, 7, "Evaluating dependent default....\n");
     
    205205                return false;
    206206            }
    207             if (depItem->type != PS_META_STR) {
     207            if (depItem->type != PS_DATA_STRING) {
    208208                psError(PS_ERR_IO, true, "Value of %s is not of type string, as required for dependency"
    209209                        " --- ignored.\n", dependsOn);
     
    555555        if (! sourceItem) {
    556556            psError(PS_ERR_IO, false, "Couldn't find CELL.TRIMSEC.SOURCE.\n");
    557         } else if (sourceItem->type != PS_META_STR) {
     557        } else if (sourceItem->type != PS_DATA_STRING) {
    558558            psError(PS_ERR_IO, true, "CELL.TRIMSEC.SOURCE is not of type STR (%x)\n", sourceItem->type);
    559559        } else {
     
    596596        if (! sourceItem) {
    597597            psError(PS_ERR_IO, false, "Couldn't find CELL.BIASSEC.SOURCE.\n");
    598         } else if (sourceItem->type != PS_META_STR) {
     598        } else if (sourceItem->type != PS_DATA_STRING) {
    599599            psError(PS_ERR_IO, true, "CELL.BIASSEC.SOURCE is not of type STR (%x)\n", sourceItem->type);
    600600        } else {
     
    668668                            psRegion *biassec = psListGetAndIncrement(biassecsIter);
    669669                            psString biassecString = psRegionToString(*biassec);
    670                             psMetadataAdd(header, PS_LIST_TAIL, keyword, PS_META_STR | PS_META_REPLACE,
     670                            psMetadataAdd(header, PS_LIST_TAIL, keyword, PS_DATA_STRING | PS_META_REPLACE,
    671671                                          "Bias section", biassecString);
    672672                            psFree(biassecString);
  • trunk/archive/scripts/src/phase2/pmFPAConstruct.c

    r5371 r5462  
    3737    psMetadataItem *item = NULL;        // Item from iteration
    3838    while (item = psMetadataGetAndIncrement(iter)) {
    39         if (item->type == PS_META_MULTI || item->type == PS_META_META) {
    40             psLogMsg(__func__, PS_LOG_WARN, "PS_META_MULTI and PS_META_META are not supported in a cell "
    41                      "definition --- %s ignored.\n", item->name);
     39        if (item->type == PS_DATA_METADATA_MULTI || item->type == PS_DATA_METADATA) {
     40            psLogMsg(__func__, PS_LOG_WARN, "PS_DATA_METADATA_MULTI and PS_DATA_METADATA are not supported "
     41                     "in a cell definition --- %s ignored.\n", item->name);
    4242            continue;
    4343        }
     
    8989                pmChip *chip = pmChipAlloc(fpa, extName); // The chip
    9090                chip->data = pmPixelDataAlloc(extName); // Prepare chip to receive FITS data
    91                 if (contentItem->type != PS_META_STR) {
     91                if (contentItem->type != PS_DATA_STRING) {
    9292                    psLogMsg(__func__, PS_LOG_WARN, "Type of content item (%x) is not string: ignored\n",
    9393                             contentItem->type);
     
    117117                psTrace(__func__, 1, "Getting %s....\n", extName);
    118118
    119                 if (contentItem->type != PS_META_STR) {
     119                if (contentItem->type != PS_DATA_STRING) {
    120120                    psLogMsg(__func__, PS_LOG_WARN, "Type of content item (%x) is not string: ignored\n",
    121121                             contentItem->type);
     
    136136                    if (! chipItem) {
    137137                        chip = pmChipAlloc(fpa, chipName);
    138                         psMetadataAdd(chips, PS_LIST_TAIL, chipName, PS_META_CHIP, "", chip);
     138                        psMetadataAdd(chips, PS_LIST_TAIL, chipName, PS_DATA_UNKNOWN, "", chip);
    139139                    } else {
    140140                        chip = psMemIncrRefCounter(chipItem->data.V);
     
    161161                psString chipName = contentItem->name; // The name of the chip
    162162
    163                 if (contentItem->type != PS_META_STR) {
     163                if (contentItem->type != PS_DATA_STRING) {
    164164                    psLogMsg(__func__, PS_LOG_WARN, "Type of content item (%x) is not string: ignored\n",
    165165                             contentItem->type);
     
    234234                psString extName = contentItem->name; // The name of the extension
    235235                // Content is a cell type
    236                 if (contentItem->type != PS_META_STR) {
     236                if (contentItem->type != PS_DATA_STRING) {
    237237                    psLogMsg(__func__, PS_LOG_WARN,
    238238                             "CONTENT metadata for extension %s is not of type string, but %x --- ignored\n",
  • trunk/archive/scripts/src/phase2/pmFlatField.c

    r5107 r5462  
    1818 *  @author Ross Harman, MHPCC
    1919 *
    20  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    21  *  @date $Date: 2005-09-23 02:58:30 $
     20 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     21 *  @date $Date: 2005-11-03 01:30:32 $
    2222 *
    2323 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    2424 */
    2525
    26 #include <stdio.h>
     26#if HAVE_CONFIG_H
     27#include <config.h>
     28#endif
     29
     30#include<stdio.h>
     31#include<math.h>
    2732#include <string.h>
     33
    2834#include "pslib.h"
    29 
    30 #include "pmFPA.h"
    3135#include "pmFlatField.h"
    3236#include "pmMaskBadPixels.h"
     
    3438
    3539
    36 bool pmFlatField(pmReadout *in, const pmReadout *flat)
     40bool pmFlatField(pmReadout *in, pmReadout *mask, const pmReadout *flat)
    3741{
     42    // XXX: Not sure if this is correct.  Must consult with IfA.
     43    PS_ASSERT_PTR_NON_NULL(mask, false);
    3844    int i = 0;
    3945    int j = 0;
     
    6773                 PS_ERRORTEXT_pmFlatField_NULL_FLAT_IMAGE);
    6874        return false;
    69     } else if(in->mask == NULL) {
    70         in->mask = psImageAlloc(inImage->numCols, inImage->numRows, PS_TYPE_MASK);
    71         memset(in->mask->data.V[0], 0, inImage->numCols*inImage->numRows*PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
    7275    }
    73     inMask = in->mask;
     76    inMask = mask->image;
    7477
    7578    // Check input image and its mask are not larger than flat image
    76     if(inImage->numRows>flatImage->numRows || inImage->numCols>flatImage->numCols) {
     79
     80    if (inImage->numRows>flatImage->numRows || inImage->numCols>flatImage->numCols) {
    7781        psError( PS_ERR_BAD_PARAMETER_SIZE, true,
    7882                 PS_ERRORTEXT_pmFlatField_SIZE_INPUT_IMAGE,
    7983                 inImage->numRows, inImage->numCols, flatImage->numRows, flatImage->numCols);
    8084        return false;
    81     } else if(inMask->numRows>flatImage->numRows || inMask->numCols > flatImage->numCols) {
     85    }
     86    if (inMask->numRows > flatImage->numRows || inMask->numCols > flatImage->numCols) {
    8287        psError( PS_ERR_BAD_PARAMETER_SIZE, true,
    8388                 PS_ERRORTEXT_pmFlatField_SIZE_MASK_IMAGE,
  • trunk/archive/scripts/src/phase2/pmFlatField.h

    r5107 r5462  
    1818 *  @author Ross Harman, MHPCC
    1919 *
    20  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    21  *  @date $Date: 2005-09-23 02:58:30 $
     20 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     21 *  @date $Date: 2005-11-03 01:30:32 $
    2222 *
    2323 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    2424 */
     25
     26#include "pslib.h"
     27#include "pmFPA.h" // #include "pmAstrometry.h"
     28
    2529
    2630/** Execute flat field module.
     
    3135 *  @return  bool: True or false for success or failure
    3236 */
    33 
    34 #include "pmFPA.h"
    35 
    3637bool pmFlatField(
    37     pmReadout *in,          ///< Redout with input image and mask
     38    pmReadout *in,          ///< Readout with input image
     39    pmReadout *mask,        ///< Input image mask
    3840    const pmReadout *flat   ///< Readout with flat image
    3941);
  • trunk/archive/scripts/src/phase2/pmFlatFieldErrors.h

    r5107 r5462  
    77 *  @author Ross Harman, MHPCC
    88 *
    9  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-09-23 02:59:05 $
     9 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-11-03 01:30:32 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  • trunk/archive/scripts/src/phase2/pmSubtractBias.c

    r5107 r5462  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-09-23 02:58:30 $
     8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-11-03 01:30:32 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2222#define PM_SUBTRACT_BIAS_SPLINE_ORDER 3
    2323
     24// XXX: put these in psConstants.h
     25void PS_POLY1D_PRINT(psPolynomial1D *poly)
     26{
     27    printf("-------------- PS_POLY1D_PRINT() --------------\n");
     28    printf("poly->nX is %d\n", poly->nX);
     29    for (psS32 i = 0 ; i < (1 + poly->nX) ; i++) {
     30        printf("poly->coeff[%d] is %f\n", i, poly->coeff[i]);
     31    }
     32}
     33
     34void PS_PRINT_SPLINE(psSpline1D *mySpline)
     35{
     36    printf("-------------- PS_PRINT_SPLINE() --------------\n");
     37    printf("mySpline->n is %d\n", mySpline->n);
     38    for (psS32 i = 0 ; i < mySpline->n ; i++) {
     39        PS_POLY1D_PRINT(mySpline->spline[i]);
     40    }
     41    PS_VECTOR_PRINT_F32(mySpline->knots);
     42}
     43
     44#define PS_IMAGE_PRINT_F32_HIDEF(NAME) \
     45printf("======== printing %s ========\n", #NAME); \
     46for (int i = 0 ; i < (NAME)->numRows ; i++) { \
     47    for (int j = 0 ; j < (NAME)->numCols ; j++) { \
     48        printf("%.5f ", (NAME)->data.F32[i][j]); \
     49    } \
     50    printf("\n"); \
     51}\
     52
    2453/******************************************************************************
    2554psSubtractFrame(): this routine will take as input a readout for the input
    2655image and a readout for the bias image.  The bias image is subtracted in
    2756place from the input image.
    28  *****************************************************************************/
     57*****************************************************************************/
    2958static pmReadout *SubtractFrame(pmReadout *in,
    3059                                const pmReadout *bias)
     
    143172    return(opt);
    144173}
     174
     175
    145176
    146177/******************************************************************************
     
    161192    psTrace(".psModule.pmSubtracBias.ScaleOverscanVector", 4,
    162193            "---- ScaleOverscanVector() begin (%d -> %d) ----\n", overscanVector->n, n);
     194    //    PS_VECTOR_PRINT_F32(overscanVector);
    163195
    164196    if (NULL == overscanVector) {
     
    182214    psF32 x;
    183215    psS32 i;
    184 
     216    printf("Got here\n");
    185217    if (fit == PM_FIT_POLYNOMIAL) {
    186218        // Fit a polynomial to the old overscan vector.
     
    204236        // Fit a spline to the old overscan vector.
    205237        mySpline = (psSpline1D *) fitSpec;
     238        // XXX: Does it make any sense to have a psSpline argument?
    206239        if (mySpline == NULL) {
    207240            mustFreeSpline = 1;
     
    210243        //
    211244        // NOTE: Since the X arg in the psVectorFitSpline1D() function is NULL,
    212         // splines enpoints will be from 0.0 to overscanVector->n-1.  Must scale
     245        // splines endpoints will be from 0.0 to overscanVector->n-1.  Must scale
    213246        // properly when doing the spline eval.
    214247        //
    215         mySpline = psVectorFitSpline1D(mySpline, NULL, overscanVector, NULL);
     248        //        mySpline = psVectorFitSpline1D(mySpline, NULL, overscanVector, NULL);
     249        mySpline = psVectorFitSpline1D(NULL, overscanVector);
    216250        if (mySpline == NULL) {
    217251            psError(PS_ERR_UNKNOWN, false, "ScaleOverscanVector()(2): Could not fit a spline to the psVector.\n");
    218252            return(NULL);
    219253        }
     254        //        PS_PRINT_SPLINE(mySpline);
    220255
    221256        // For each element of the new vector, convert the x-ordinate to that
     
    230265            psFree(mySpline);
    231266        }
     267        //        PS_VECTOR_PRINT_F32(newVec);
     268
    232269
    233270    } else {
     
    376413    tmpOverscan = (psListElem *) overscans->head;
    377414    while (NULL != tmpOverscan) {
     415        //        PS_IMAGE_PRINT_F32_HIDEF(in->image);
    378416        myOverscanImage = (psImage *) tmpOverscan->data;
    379417
     
    557595                }
    558596            } else if (fit == PM_FIT_SPLINE) {
     597                // XXX: This makes no sense
     598                // XXX: must free mySpline?
    559599                mySpline = (psSpline1D *) fitSpec;
    560                 mySpline = psVectorFitSpline1D(mySpline, NULL, overscanVector, NULL);
     600                mySpline = psVectorFitSpline1D(NULL, overscanVector);
    561601                if (mySpline == NULL) {
    562602                    psError(PS_ERR_UNKNOWN, false, "Could not fit a spline to overscan vector.  Returning in image.\n");
  • trunk/archive/scripts/src/phase2/pmSubtractBias.h

    r5107 r5462  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-09-23 02:58:30 $
     8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-11-03 01:30:32 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2323#include<math.h>
    2424#include "pslib.h"
    25 #include "pmFPA.h"
     25
     26#include "pmFPA.h"   //#include "pmAstrometry.h"
    2627
    2728typedef enum {
  • trunk/archive/scripts/src/phase2/psAdditionals.c

    r5104 r5462  
    1515            psError(PS_ERR_IO, true, "Couldn't find %s in the metadata.\n");
    1616        }
    17     } else if (item->type != PS_META_META) {
     17    } else if (item->type != PS_DATA_METADATA) {
    1818        // The value at the key isn't metadata
    1919        if (status) {
    2020            *status = false;
    2121        } else {
    22             psLogMsg(__func__, PS_LOG_WARN, "%s isn't of type PS_META_META, as expected.\n");
     22            psLogMsg(__func__, PS_LOG_WARN, "%s isn't of type PS_DATA_METADATA, as expected.\n");
    2323        }
    2424        value = NULL;
     
    4545            psError(PS_ERR_IO, true, "Couldn't find %s in the metadata.\n");
    4646        }
    47     } else if (item->type != PS_META_STR) {
     47    } else if (item->type != PS_DATA_STRING) {
    4848        // The value at the key isn't of the desired type
    4949        if (status) {
    5050            *status = false;
    5151        } else {
    52             psLogMsg(__func__, PS_LOG_WARN, "%s isn't of type PS_META_STR, as expected.\n");
     52            psLogMsg(__func__, PS_LOG_WARN, "%s isn't of type PS_DATA_STRING, as expected.\n");
    5353        }
    5454        value = NULL;
     
    7979        printf(": ");
    8080        switch (item->type) {
    81           case PS_META_STR:
     81          case PS_DATA_STRING:
    8282            printf("%s", item->data.V);
    8383            break;
    84           case PS_META_BOOL:
     84          case PS_DATA_BOOL:
    8585            if (item->data.B) {
    8686                printf("True");
     
    8989            }
    9090            break;
    91           case PS_META_S32:
     91          case PS_DATA_S32:
    9292            printf("%d", item->data.S32);
    9393            break;
    94           case PS_META_F32:
     94          case PS_DATA_F32:
    9595            printf("%f", item->data.F32);
    9696            break;
    97           case PS_META_F64:
     97          case PS_DATA_F64:
    9898            printf("%f", item->data.F64);
    9999            break;
    100           case PS_META_META:
     100          case PS_DATA_METADATA:
    101101            printf("\n");
    102102            psMetadataPrint(item->data.V, level + 1);
     
    200200    switch(item->type) {
    201201        // Only doing a representative set of types
    202       case PS_META_S32:
     202      case PS_DATA_S32:
    203203        newItem = psMetadataItemAlloc(item->name, item->type, item->comment, atoi(argv[argnum]));
    204204        psArgumentRemove(argnum, argc, argv);
    205205        break;
    206       case PS_META_F32:
     206      case PS_DATA_F32:
    207207        newItem = psMetadataItemAlloc(item->name, item->type, item->comment, atof(argv[argnum]));
    208208        psArgumentRemove(argnum, argc, argv);
    209209        break;
    210       case PS_META_BOOL:
     210      case PS_DATA_BOOL:
    211211        // Turn option on; no optional argument to remove
    212212        newItem = psMetadataItemAlloc(item->name, item->type, item->comment, true);
    213213        break;
    214214        // XXX: Include the other numerical types
    215       case PS_META_STR:
     215      case PS_DATA_STRING:
    216216        {
    217217            //psString string = psStringCopy(argv[argnum]);     // Get the argument into PS memory management
     
    250250        if (argItem) {
    251251            psArgumentRemove(i, argc, argv); // Remove the switch
    252             if (argItem->type != PS_META_MULTI) {
    253                 if (argItem->type != PS_META_BOOL && *argc < i + 1) {
     252            if (argItem->type != PS_DATA_METADATA_MULTI) {
     253                if (argItem->type != PS_DATA_BOOL && *argc < i + 1) {
    254254                    psError(PS_ERR_IO, true, "Required argument for %s is missing.\n", argItem->name);
    255255                    // XXX: Cleanup before returning
     
    318318        switch (oldItem->type) {
    319319            // Only doing a representative set of types
    320           case PS_META_S32:
     320          case PS_DATA_S32:
    321321            oldItem->data.S32 = newItem->data.S32;
    322322            break;
    323           case PS_META_F32:
     323          case PS_DATA_F32:
    324324            oldItem->data.F32 = newItem->data.F32;
    325325            break;
    326           case PS_META_BOOL:
     326          case PS_DATA_BOOL:
    327327            oldItem->data.B = newItem->data.B;
    328328            break;
    329329            // XXX: Include the other numerical types
    330           case PS_META_STR:
     330          case PS_DATA_STRING:
    331331            psFree(oldItem->data.V);
    332332            oldItem->data.V = psMemIncrRefCounter(newItem->data.V);
    333333            break;
    334           case PS_META_MULTI:
     334          case PS_DATA_METADATA_MULTI:
    335335            {
    336336                psList *newMulti = psMemIncrRefCounter(newItem->data.V);        // The new list of MULTI
     
    347347                    switch (oldMultiItem->type) {
    348348                        // Only doing a representative set of types
    349                       case PS_META_S32:
     349                      case PS_DATA_S32:
    350350                        oldItem->data.S32 = newItem->data.S32;
    351351                        break;
    352                       case PS_META_F32:
     352                      case PS_DATA_F32:
    353353                        oldItem->data.F32 = newItem->data.F32;
    354354                        break;
    355355                        // XXX: Include the other numerical types
    356                       case PS_META_STR:
     356                      case PS_DATA_STRING:
    357357                        psFree(oldItem->data.V);
    358358                        oldItem->data.V = psMemIncrRefCounter(newItem->data.V);
     
    385385    switch (arg->type) {
    386386        // Only doing a representative set of types
    387       case PS_META_S32:
     387      case PS_DATA_S32:
    388388        return arg->data.S32 >= 0 ? (int)log10f((float)arg->data.S32) + 1 :
    389389            (int)log10f(-(float)arg->data.S32) + 2;
    390390        // XXX: Other numerical types
    391       case PS_META_F32:
     391      case PS_DATA_F32:
    392392        return arg->data.F32 >= 0 ? 12 : 13; // -d.dddddde?dd
    393       case PS_META_F64:
     393      case PS_DATA_F64:
    394394        return arg->data.F64 >= 0 ? 12 : 13; // -d.dddddde?dd
    395       case PS_META_BOOL:
     395      case PS_DATA_BOOL:
    396396        return arg->data.B ? 4 : 5;
    397       case PS_META_STR:
     397      case PS_DATA_STRING:
    398398        return strlen(arg->data.V);
    399399      default:
     
    450450        switch (argItem->type) {
    451451            // Only doing a representative set of types
    452           case PS_META_S32:
     452          case PS_DATA_S32:
    453453            printf("%d", argItem->data.S32);
    454454            break;
    455455            // XXX: Other numerical types
    456           case PS_META_F32:
     456          case PS_DATA_F32:
    457457            printf("%.6e", argItem->data.F32);
    458458            break;
    459           case PS_META_F64:
     459          case PS_DATA_F64:
    460460            printf("%.6e", argItem->data.F64);
    461461            break;
    462           case PS_META_BOOL:
     462          case PS_DATA_BOOL:
    463463            if (argItem->data.B) {
    464464                printf("TRUE");
     
    467467            }
    468468            break;
    469           case PS_META_STR:
     469          case PS_DATA_STRING:
    470470            printf("%s", argItem->data.V);
    471471            break;
Note: See TracChangeset for help on using the changeset viewer.