IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 5, 2005, 1:25:25 PM (22 years ago)
Author:
gusciora
Message:

Added tests to for various input parameters being NULL, or of incorrect
length.

File:
1 edited

Legend:

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

    r2857 r2915  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-12-30 22:22:00 $
     7 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-01-05 23:25:24 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     11 *
     12 *  XXX: The SDR is silent about image types.  Only F32 was implemented.
    1113 *
    1214 */
     
    2830 *****************************************************************************/
    2931
    30 psReadout *pmNonLinearityPolynomial(psReadout *in,
    31                                     const psPolynomial1D *coeff)
     32psReadout *pmNonLinearityPolynomial(psReadout *inputReadout,
     33                                    const psPolynomial1D *input1DPoly)
    3234{
    33     PS_PTR_CHECK_NULL(in,NULL);
    34     PS_PTR_CHECK_NULL(in->image, NULL);
    35     PS_PTR_CHECK_NULL(coeff,NULL);
     35    PS_PTR_CHECK_NULL(inputReadout, NULL);
     36    PS_PTR_CHECK_NULL(inputReadout->image, NULL);
     37    PS_PTR_CHECK_NULL(input1DPoly, NULL);
    3638
    3739    psS32 i;
    3840    psS32 j;
    3941
    40     for (i=0;i<(in->image)->numRows;i++) {
    41         for (j=0;j<(in->image)->numCols;j++) {
    42             (in->image)->data.F32[i][j] = psPolynomial1DEval(coeff, (in->image)->data.F32[i][j]);
     42    for (i=0;i<(inputReadout->image)->numRows;i++) {
     43        for (j=0;j<(inputReadout->image)->numCols;j++) {
     44            (inputReadout->image)->data.F32[i][j] = psPolynomial1DEval(input1DPoly, (inputReadout->image)->data.F32[i][j]);
    4345        }
    4446    }
    45     return(in);
     47    return(inputReadout);
    4648}
    4749
     
    5456be set to the value from outFlux.
    5557 *****************************************************************************/
    56 psReadout *pmNonLinearityLookup(psReadout *in,
     58psReadout *pmNonLinearityLookup(psReadout *inputReadout,
    5759                                const psVector *inFlux,
    5860                                const psVector *outFlux)
    5961{
    60     PS_PTR_CHECK_NULL(in,NULL);
    61     PS_PTR_CHECK_NULL(in->image,NULL);
     62    PS_PTR_CHECK_NULL(inputReadout,NULL);
     63    PS_PTR_CHECK_NULL(inputReadout->image,NULL);
    6264    PS_PTR_CHECK_NULL(inFlux,NULL);
     65    psS32 tableSize = inFlux->n;
     66    if (inFlux->n < 2) {
     67        psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): input vector less than 2 elements.  Returning inputReadout image.");
     68        return(inputReadout);
     69    }
    6370    PS_PTR_CHECK_NULL(outFlux,NULL);
     71    if (inFlux->n != outFlux->n) {
     72        tableSize = PS_MIN(inFlux->n, outFlux->n);
     73        psLogMsg(__func__, PS_LOG_WARN,
     74                 "WARNING: pmNonLinear.c: pmNonLinearityLookup(): input vectors have different sizes (%d, %d)\n", inFlux->n, outFlux->n);
     75    }
    6476
    6577    psS32 i;
    6678    psS32 j;
    67     psS32 tableSize = inFlux->n;
    6879    psS32 binNum;
    6980    psScalar x;
     
    7283
    7384    x.type.type = PS_TYPE_F32;
    74     if (inFlux->n != outFlux->n) {
    75         tableSize = PS_MIN(inFlux->n, outFlux->n);
    76         psLogMsg(__func__, PS_LOG_WARN,
    77                  "WARNING: pmNonLinear.c: pmNonLinearityLookup(): input vectors have different sizes (%d, %d)\n", inFlux->n, outFlux->n);
    78     }
    79     if (inFlux->n < 2) {
    80         psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): input vector less than 2 elements.  Returning in image.");
    81         return(in);
    82     }
    83     for (i=0;i<(in->image)->numRows;i++) {
    84         for (j=0;j<(in->image)->numCols;j++) {
    85             x.data.F32 = (in->image)->data.F32[i][j];
     85    for (i=0;i<(inputReadout->image)->numRows;i++) {
     86        for (j=0;j<(inputReadout->image)->numCols;j++) {
     87            x.data.F32 = (inputReadout->image)->data.F32[i][j];
    8688
    8789            binNum = p_psVectorBinDisect((psVector *)inFlux, &x);
     
    8991            if (binNum == -2) {
    9092                // We get here if x is below the table lookup range.
    91                 (in->image)->data.F32[i][j] = outFlux->data.F32[0];
     93                (inputReadout->image)->data.F32[i][j] = outFlux->data.F32[0];
    9294                numPixels++;
    9395
    9496            } else if (binNum == -1) {
    9597                // We get here if x is above the table lookup range.
    96                 (in->image)->data.F32[i][j] = outFlux->data.F32[tableSize-1];
     98                (inputReadout->image)->data.F32[i][j] = outFlux->data.F32[tableSize-1];
    9799
    98100                numPixels++;
    99101            } else if (binNum < -2) {
    100102                // We get here if there was some other problem.
    101                 psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): Could not perform p_psVectorBinDisect().  Returning in image.");
    102                 return(in);
     103                psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): Could not perform p_psVectorBinDisect().  Returning inputReadout image.");
     104                return(inputReadout);
    103105                numPixels++;
    104106            } else {
     
    106108                slope = (outFlux->data.F32[binNum+1] - outFlux->data.F32[binNum]) /
    107109                        (inFlux->data.F32[binNum+1]  - inFlux->data.F32[binNum]);
    108                 (in->image)->data.F32[i][j] = outFlux->data.F32[binNum] +
    109                                               ((x.data.F32 - inFlux->data.F32[binNum]) * slope);
     110                (inputReadout->image)->data.F32[i][j] = outFlux->data.F32[binNum] +
     111                                                        ((x.data.F32 - inFlux->data.F32[binNum]) * slope);
    110112            }
    111113        }
     
    115117                 "WARNING: pmNonLinear.c: pmNonLinearityLookup(): %d pixels outside table.", numPixels);
    116118    }
    117     return(in);
     119    return(inputReadout);
    118120}
Note: See TracChangeset for help on using the changeset viewer.