IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 30, 2004, 12:22:00 PM (22 years ago)
Author:
gusciora
Message:

Added better error checking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/pmSubtractBias.c

    r2856 r2857  
    66 *  @author George Gusciora, MHPCC
    77 *
    8  *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-12-30 21:35:03 $
     8 *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-12-30 22:22:00 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3939
    4040    if (((in->image)->numRows + in->row0 - bias->row0) > (bias->image)->numRows) {
    41         psError(PS_ERR_UNKNOWN,true, "bias image does not have enough rows\n");
     41        psError(PS_ERR_UNKNOWN,true, "bias image does not have enough rows.  Returning in image\n");
    4242        return(in);
    4343    }
    4444    if (((in->image)->numCols + in->row0 - bias->row0) > (bias->image)->numCols) {
    45         psError(PS_ERR_UNKNOWN,true, "bias image does not have enough columns\n");
     45        psError(PS_ERR_UNKNOWN,true, "bias image does not have enough columns.  Returning in image\n");
    4646        return(in);
    4747    }
     
    129129
    130130    if (numOptions == 0) {
    131         psError(PS_ERR_UNKNOWN,true, "No statistics options have been specified\n");
     131        psError(PS_ERR_UNKNOWN,true, "No statistics options have been specified.\n");
    132132    }
    133133    if (numOptions != 1) {
     
    225225
    226226    } else {
    227         psError(PS_ERR_UNKNOWN, true, "unknown fit type\n");
     227        psError(PS_ERR_UNKNOWN, true, "unknown fit type.  Returning NULL.\n");
     228        psFree(newVec);
     229        return(NULL);
    228230    }
    229231
     
    251253    PS_READOUT_CHECK_TYPE(in, PS_TYPE_F32, NULL);
    252254    if ((overscans == NULL) && (overScanAxis != PM_OVERSCAN_NONE)) {
    253         psError(PS_ERR_UNKNOWN,true, "(overscans == NULL) && (overScanAxis != PM_OVERSCAN_NONE)\n");
     255        psError(PS_ERR_UNKNOWN,true, "(overscans == NULL) && (overScanAxis != PM_OVERSCAN_NONE).  Returning in image\n");
    254256        return(in);
    255257    }
     
    260262            (fit != PM_OVERSCAN_COLUMNS) &&
    261263            (fit != PM_OVERSCAN_ALL)) {
    262         psError(PS_ERR_UNKNOWN, true, "fit is unallowable (%d)\n", fit);
     264        psError(PS_ERR_UNKNOWN, true, "fit is unallowable (%d).  Returning in image.\n", fit);
    263265        return(in);
    264266    }
     
    268270            (overScanAxis != PM_OVERSCAN_COLUMNS) &&
    269271            (overScanAxis != PM_OVERSCAN_ALL)) {
    270         psError(PS_ERR_UNKNOWN, true, "overScanAxis is unallowable (%d)\n", overScanAxis);
     272        psError(PS_ERR_UNKNOWN, true, "overScanAxis is unallowable (%d).  Returning in image.\n", overScanAxis);
    271273        return(in);
    272274    }
     
    302304        if (fit != PM_FIT_NONE) {
    303305            psLogMsg(__func__, PS_LOG_WARN,
    304                      "WARNING: pmSubtractBias.(): overScanAxis equals NONE, and fit does not equal NONE\n");
     306                     "WARNING: pmSubtractBias.(): overScanAxis equals NONE, and fit does not equal NONE.  Proceeding to full fram subtraction.\n");
    305307        }
    306308
    307309        if (overscans != NULL) {
    308310            psLogMsg(__func__, PS_LOG_WARN,
    309                      "WARNING: pmSubtractBias.(): overScanAxis equals NONE and overscans does not equal NULL\n");
     311                     "WARNING: pmSubtractBias.(): overScanAxis equals NONE and overscans does not equal NULL.  Proceeding to full fram subtraction.\n");
    310312        }
    311313        return(psSubtractFrame(in, bias));
     
    314316    if ((overScanAxis == PM_OVERSCAN_ALL) && (fit != PM_FIT_NONE)) {
    315317        psLogMsg(__func__, PS_LOG_WARN,
    316                  "WARNING: pmSubtractBias.(): overScanAxis equals ALL, and fit does not equal NONE\n");
     318                 "WARNING: pmSubtractBias.(): overScanAxis equals ALL, and fit does not equal NONE.  Proceeding with the rest of the module.\n");
    317319    }
    318320
     
    321323    // We subtract each overscan region from the image data.
    322324    //
    323     // XXX: Do we generate a single stat from all the overscan regions, and
    324     // subtract that from the input image?  Or do we generate a single stat
    325     // from each overscan region, and subtract them from the input image?
    326     // The SDR is ambiguous.
    327325    if (overScanAxis == PM_OVERSCAN_ALL) {
    328326        tmpOverscan = (psListElem *) overscans->head;
    329327        while (NULL != tmpOverscan) {
    330328            myOverscanImage = (psImage *) tmpOverscan->data;
    331             psImageStats(myStats, myOverscanImage, NULL, 0xffffffff);
    332             p_psGetStatValue(myStats, &statValue);
     329            psStats *rc = psImageStats(myStats, myOverscanImage, NULL, 0xffffffff);
     330            if (rc == NULL) {
     331                psError(PS_ERR_UNKNOWN, false, "psImageStats(): could not perform requested statistical operation.  Returning in image.\n");
     332                return(in);
     333            }
     334            if (false == p_psGetStatValue(myStats, &statValue)) {
     335                psError(PS_ERR_UNKNOWN, false, "p_psGetStatValue(): could not determine result from requested statistical operation.  Returning in image.\n");
     336                return(in);
     337            }
    333338            p_psImageSubtractScalar(in->image, statValue);
    334339
     
    340345    // This check is redundant with above code.
    341346    if (!((overScanAxis == PM_OVERSCAN_ROWS) || (overScanAxis == PM_OVERSCAN_COLUMNS))) {
    342         psError(PS_ERR_UNKNOWN, true, "overScanAxis is unallowable (%d)\n", overScanAxis);
     347        psError(PS_ERR_UNKNOWN, true, "overScanAxis is unallowable (%d).\nReturning in image.\n", overScanAxis);
    343348        return(in);
    344349    }
     
    371376                    tmpRow->data.F32[j] = myOverscanImage->data.F32[j][i];
    372377                }
    373                 myStats = psVectorStats(myStats, tmpRow, NULL, NULL, 0);
    374                 p_psGetStatValue(myStats, &statValue);
     378                psStats *rc = psVectorStats(myStats, tmpRow, NULL, NULL, 0);
     379                if (rc == NULL) {
     380                    psError(PS_ERR_UNKNOWN, false, "psVectorStats(): could not perform requested statistical operation.  Returning in image.\n");
     381                    return(in);
     382                }
     383                if (false ==  p_psGetStatValue(rc, &statValue)) {
     384                    psError(PS_ERR_UNKNOWN, false, "p_psGetStatValue(): could not determine result from requested statistical operation.  Returning in image.\n");
     385                    return(in);
     386                }
    375387                overscanVector->data.F32[i] = statValue;
    376388            }
     
    383395                                                           in->image->numCols,
    384396                                                           fitSpec, fit);
     397                    if (newVec == NULL) {
     398                        psError(PS_ERR_UNKNOWN, false, "ScaleOverscanVector(): could not scale the overscan vector.  Returning in image.\n");
     399                        return(in);
     400                    }
    385401                    psFree(overscanVector);
    386402                    overscanVector = newVec;
    387403                } else {
    388                     psError(PS_ERR_UNKNOWN, true, "Don't know how to scale the overscan vector.  Set fit to PM_FIT_SPLINE or PM_FIT_POLYNOMIAL.\n");
     404                    psError(PS_ERR_UNKNOWN, true, "Don't know how to scale the overscan vector.  Set fit to PM_FIT_SPLINE or PM_FIT_POLYNOMIAL.  Returning in image.\n");
    389405                    psFree(overscanVector);
    390406                    return(in);
     
    414430                    tmpCol->data.F32[j] = myOverscanImage->data.F32[i][j];
    415431                }
    416                 myStats = psVectorStats(myStats, tmpCol, NULL, NULL, 0);
    417                 p_psGetStatValue(myStats, &statValue);
     432                psStats *rc = psVectorStats(myStats, tmpCol, NULL, NULL, 0);
     433                if (rc == NULL) {
     434                    psError(PS_ERR_UNKNOWN, false, "psVectorStats(): could not perform requested statistical operation.  Returning in image.\n");
     435                    return(in);
     436                }
     437                if (false ==  p_psGetStatValue(rc, &statValue)) {
     438                    psError(PS_ERR_UNKNOWN, false, "p_psGetStatValue(): could not determine result from requested statistical operation.  Returning in image.\n");
     439                    return(in);
     440                }
    418441                overscanVector->data.F32[i] = statValue;
    419442            }
     
    426449                                                           in->image->numRows,
    427450                                                           fitSpec, fit);
     451                    if (newVec == NULL) {
     452                        psError(PS_ERR_UNKNOWN, false, "ScaleOverscanVector(): could not scale the overscan vector.  Returning in image.\n");
     453                        return(in);
     454                    }
    428455                    psFree(overscanVector);
    429456                    overscanVector = newVec;
    430457                } else {
    431                     psError(PS_ERR_UNKNOWN, true, "Don't know how to scale the overscan vector.  Set fit to PM_FIT_SPLINE or PM_FIT_POLYNOMIAL.\n");
     458                    psError(PS_ERR_UNKNOWN, true, "Don't know how to scale the overscan vector.  Set fit to PM_FIT_SPLINE or PM_FIT_POLYNOMIAL.  Returning in image.\n");
    432459                    psFree(overscanVector);
    433460                    return(in);
     
    456483                    }
    457484                }
    458                 myStats = psVectorStats(myStats, binVec, NULL, NULL, 0);
    459                 p_psGetStatValue(myStats, &statValue);
     485                psStats *rc = psVectorStats(myStats, binVec, NULL, NULL, 0);
     486                if (rc == NULL) {
     487                    psError(PS_ERR_UNKNOWN, false, "psVectorStats(): could not perform requested statistical operation.  Returning in image.\n");
     488                    return(in);
     489                }
     490                if (false ==  p_psGetStatValue(rc, &statValue)) {
     491                    psError(PS_ERR_UNKNOWN, false, "p_psGetStatValue(): could not determine result from requested statistical operation.  Returning in image.\n");
     492                    return(in);
     493                }
    460494                myBin->data.F32[i] = statValue;
    461495            }
     
    486520                myPoly = psVectorFitPolynomial1D(myPoly, NULL, overscanVector, NULL);
    487521                if (myPoly == NULL) {
    488                     psError(PS_ERR_UNKNOWN, false, "Could not fit a polynomial to overscan vector.\n");
     522                    psError(PS_ERR_UNKNOWN, false, "Could not fit a polynomial to overscan vector.  Returning in image.\n");
    489523                    psFree(overscanVector);
    490524                    return(in);
     
    494528                mySpline = psVectorFitSpline1D(mySpline, NULL, overscanVector, NULL);
    495529                if (mySpline == NULL) {
    496                     psError(PS_ERR_UNKNOWN, false, "Could not fit a spline to overscan vector.\n");
     530                    psError(PS_ERR_UNKNOWN, false, "Could not fit a spline to overscan vector.  Returning in image.\n");
    497531                    psFree(overscanVector);
    498532                    return(in);
     
    535569            }
    536570        } else {
     571            //
    537572            // If we get here, then no polynomials were fit to the overscan
    538573            // vector.  We simply subtract it, taking into account binning,
    539574            // from the image.
     575            //
    540576
    541577            //
Note: See TracChangeset for help on using the changeset viewer.