IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 20, 2005, 1:06:24 PM (21 years ago)
Author:
gusciora
Message:

....

Location:
trunk/psModules/src/detrend
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmFlatField.c

    r5170 r5435  
    1818 *  @author Ross Harman, MHPCC
    1919 *
    20  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    21  *  @date $Date: 2005-09-28 20:43:52 $
     20 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     21 *  @date $Date: 2005-10-20 23:06:24 $
    2222 *
    2323 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3838
    3939
    40 bool pmFlatField(pmReadout *in, pmReadout *mask, const pmReadout *flat)
     40bool pmFlatField(
     41    pmReadout *in,
     42    const pmReadout *flat)
    4143{
    4244    // XXX: Not sure if this is correct.  Must consult with IfA.
    43     PS_ASSERT_PTR_NON_NULL(mask, false);
     45    PS_ASSERT_PTR_NON_NULL(in->mask, false);
    4446    int i = 0;
    4547    int j = 0;
     
    5658    // Check for nulls
    5759    if (in == NULL) {
    58         return true;       // Readout may not have data in it
     60        return true;       // Readout might have data in it
    5961    } else if(flat==NULL) {
    6062        psError( PS_ERR_BAD_PARAMETER_NULL, true,
     
    7476        return false;
    7577    }
    76     inMask = mask->image;
     78    inMask = in->mask;
    7779
    7880    // Check input image and its mask are not larger than flat image
  • trunk/psModules/src/detrend/pmFlatField.h

    r5170 r5435  
    1818 *  @author Ross Harman, MHPCC
    1919 *
    20  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    21  *  @date $Date: 2005-09-28 20:43:52 $
     20 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     21 *  @date $Date: 2005-10-20 23:06:24 $
    2222 *
    2323 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3737bool pmFlatField(
    3838    pmReadout *in,          ///< Readout with input image
    39     pmReadout *mask,        ///< Input image mask
    4039    const pmReadout *flat   ///< Readout with flat image
    4140);
  • trunk/psModules/src/detrend/pmNonLinear.c

    r5170 r5435  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-09-28 20:43:52 $
     7 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-10-20 23:06:24 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5656inFluxe, and the corresponding value in outFlux.  The image pixel will then
    5757be set to the value from outFlux.
     58 
     59XXX: Must assert that filename exists.  This should probably happen in
     60the lookup files.
    5861 *****************************************************************************/
    59 pmReadout *pmNonLinearityLookup(pmReadout *inputReadout,
    60                                 const psVector *inFlux,
    61                                 const psVector *outFlux)
     62pmReadout *pmNonLinearityLookup(
     63    pmReadout *inputReadout,
     64    const char *filename
     65)
    6266{
    6367    PS_ASSERT_PTR_NON_NULL(inputReadout,NULL);
    6468    PS_ASSERT_PTR_NON_NULL(inputReadout->image,NULL);
    6569    PS_ASSERT_IMAGE_TYPE(inputReadout->image, PS_TYPE_F32, NULL);
    66     PS_ASSERT_PTR_NON_NULL(inFlux,NULL);
    67     if (inFlux->n < 2) {
    68         psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): input vector less than 2 elements.  Returning inputReadout image.");
    69         return(inputReadout);
    70     }
    71     PS_ASSERT_PTR_NON_NULL(outFlux,NULL);
    72     psS32 tableSize = inFlux->n;
    73     if (inFlux->n != outFlux->n) {
    74         tableSize = PS_MIN(inFlux->n, outFlux->n);
     70    psLookupTable *tmpLT = psLookupTableAlloc(filename, "%f %f", 0);
     71    psS32 numLines = psLookupTableRead(tmpLT);
     72    psS32 numPixels = 0;
     73    if (numLines < 2) {
    7574        psLogMsg(__func__, PS_LOG_WARN,
    76                  "WARNING: pmNonLinear.c: pmNonLinearityLookup(): input vectors have different sizes (%d, %d)\n", inFlux->n, outFlux->n);
    77     }
    78     PS_ASSERT_VECTOR_TYPE(inFlux, PS_TYPE_F32, NULL);
    79     PS_ASSERT_VECTOR_TYPE(outFlux, PS_TYPE_F32, NULL);
    80 
    81     psS32 i;
    82     psS32 j;
    83     psS32 binNum;
    84     psScalar x;
    85     psS32 numPixels = 0;
    86     psF32 slope;
    87 
    88     x.type.type = PS_TYPE_F32;
    89     for (i=0;i<inputReadout->image->numRows;i++) {
    90         for (j=0;j<inputReadout->image->numCols;j++) {
    91             x.data.F32 = inputReadout->image->data.F32[i][j];
    92             binNum = p_psVectorBinDisect((psVector *)inFlux, &x);
    93 
    94             if (binNum == -2) {
    95                 // We get here if x is below the table lookup range.
    96                 inputReadout->image->data.F32[i][j] = outFlux->data.F32[0];
    97                 numPixels++;
    98 
    99             } else if (binNum == -1) {
    100                 // We get here if x is above the table lookup range.
    101                 inputReadout->image->data.F32[i][j] = outFlux->data.F32[tableSize-1];
    102                 numPixels++;
    103 
    104             } else if (binNum < -2) {
    105                 // We get here if there was some other problem.
    106                 psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): Could not perform p_psVectorBinDisect().  Returning inputReadout image.");
    107                 return(inputReadout);
    108                 numPixels++;
    109             } else {
    110                 // Perform linear interpolation.
    111                 slope = (outFlux->data.F32[binNum+1] - outFlux->data.F32[binNum]) /
    112                         (inFlux->data.F32[binNum+1]  - inFlux->data.F32[binNum]);
    113                 inputReadout->image->data.F32[i][j] = outFlux->data.F32[binNum] +
    114                                                       ((x.data.F32 - inFlux->data.F32[binNum]) * slope);
     75                 "WARNING: Lookup Table is too small.  Returning original pmReadout.\n");
     76    } else {
     77        for (psS32 i=0;i<inputReadout->image->numRows;i++) {
     78            for (psS32 j=0;j<inputReadout->image->numCols;j++) {
     79                psF64 tmpD = psLookupTableInterpolate(tmpLT, inputReadout->image->data.F32[i][j], 1);
     80                if (!isnan(tmpD)) {
     81                    inputReadout->image->data.F32[i][j] = tmpD;
     82                } else {
     83                    numPixels++;
     84                }
    11585            }
    11686        }
     87        if (numPixels > 0) {
     88            psLogMsg(__func__, PS_LOG_WARN,
     89                     "WARNING: pmNonLinear.c: pmNonLinearityLookup(): %d pixels outside table.", numPixels);
     90        }
    11791    }
    118     if (numPixels > 0) {
    119         psLogMsg(__func__, PS_LOG_WARN,
    120                  "WARNING: pmNonLinear.c: pmNonLinearityLookup(): %d pixels outside table.", numPixels);
    121     }
     92
    12293    return(inputReadout);
    12394}
  • trunk/psModules/src/detrend/pmNonLinear.h

    r5170 r5435  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-09-28 20:43:52 $
     7 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-10-20 23:06:24 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1818#include "pmAstrometry.h"
    1919
    20 pmReadout *pmNonLinearityPolynomial(pmReadout *in,
    21                                     const psPolynomial1D *coeff);
     20pmReadout *pmNonLinearityPolynomial(
     21    pmReadout *in,
     22    const psPolynomial1D *coeff
     23);
    2224
    23 pmReadout *pmNonLinearityLookup(pmReadout *in,
    24                                 const psVector *inFlux,
    25                                 const psVector *outFlux);
     25pmReadout *pmNonLinearityLookup(
     26    pmReadout *in,
     27    const char *filename
     28);
    2629
    2730#endif
Note: See TracChangeset for help on using the changeset viewer.