IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9619


Ignore:
Timestamp:
Oct 17, 2006, 3:05:59 PM (20 years ago)
Author:
Paul Price
Message:

Documenting pmSubtractBias.h, cleaning up pmSubtractBias.c

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

Legend:

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

    r8669 r9619  
    1 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
    2 // XXX WARNING: I have completely replaced this file with an OLD VERSION (that works) instead of the
    3 // one that was being worked on.
    4 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
    5 
    6 /** @file  pmSubtractBias.c
    7  *
    8  *  This file will contain a module which will subtract the detector bias
    9  *  in place from an input image.
    10  *
    11  *  @author GLG, MHPCC
    12  *
    13  *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-08-29 21:39:44 $
    15  *
    16  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    17  *
    18  */
    19 
    201#if HAVE_CONFIG_H
    212#include <config.h>
     
    256#include <assert.h>
    267#include <pslib.h>
     8
     9#include "pmFPA.h"
    2710#include "pmSubtractBias.h"
    2811
     
    3114
    3215
    33 #define MAX(a,b) ((a) > (b) ? (a) : (b))
    34 #define MIN(a,b) ((a) < (b) ? (a) : (b))
    35 
    36 
    37 // XXX: put these in psConstants.h
    38 void PS_POLY1D_PRINT(psPolynomial1D *poly)
    39 {
    40     printf("-------------- PS_POLY1D_PRINT() --------------\n");
    41     printf("poly->nX is %d\n", poly->nX);
    42     for (psS32 i = 0 ; i < (1 + poly->nX) ; i++) {
    43         printf("poly->coeff[%d] is %f\n", i, poly->coeff[i]);
    44     }
    45 }
    46 
    47 void PS_PRINT_SPLINE(psSpline1D *mySpline)
    48 {
    49     printf("-------------- PS_PRINT_SPLINE() --------------\n");
    50     printf("mySpline->n is %d\n", mySpline->n);
    51     for (psS32 i = 0 ; i < mySpline->n ; i++) {
    52         PS_POLY1D_PRINT(mySpline->spline[i]);
    53     }
    54     PS_VECTOR_PRINT_F32(mySpline->knots);
    55 }
    56 
    57 #define PS_IMAGE_PRINT_F32_HIDEF(NAME) \
    58 printf("======== printing %s ========\n", #NAME); \
    59 for (int i = 0 ; i < (NAME)->numRows ; i++) { \
    60     for (int j = 0 ; j < (NAME)->numCols ; j++) { \
    61         printf("%.5f ", (NAME)->data.F32[i][j]); \
    62     } \
    63     printf("\n"); \
    64 }\
    65 
    66 
    67 void overscanOptionsFree(pmOverscanOptions *options)
     16static void overscanOptionsFree(pmOverscanOptions *options)
    6817{
    6918    psFree(options->stat);
     
    9140
    9241
    93 /******************************************************************************
    94 psSubtractFrame(): this routine will take as input a readout for the input
    95 image and a readout for the bias image.  The bias image is subtracted in
    96 place from the input image.
    97 *****************************************************************************/
    98 static bool SubtractFrame(pmReadout *in,// Input readout
     42// psSubtractFrame(): this routine will take as input a readout for the input image and a readout for the bias
     43// image.  The bias image is subtracted in place from the input image.
     44static bool SubtractFrame(pmReadout *in, // Input readout
    9945                          const pmReadout *sub, // Readout to be subtracted from input
    10046                          float scale   // Scale to apply before subtracting
     
    10955    psImage *subMask  = sub->mask;      // The mask for the subtraction image
    11056
     57    // Check parities
    11158    int xIpar = psMetadataLookupS32(NULL, in->parent->concepts, "CELL.XPARITY");
    11259    int xSpar = psMetadataLookupS32(NULL, sub->parent->concepts, "CELL.XPARITY");
     
    252199
    253200
    254 
    255 /******************************************************************************
    256 XXX: The SDRS does not specify type support.  F32 is implemented here.
    257  *****************************************************************************/
    258201bool pmSubtractBias(pmReadout *in, pmOverscanOptions *overscanOpts,
    259202                    const pmReadout *bias, const pmReadout *dark)
     
    280223        if (overscanOpts->fitType != PM_FIT_NONE && overscanOpts->fitType != PM_FIT_POLY_ORD &&
    281224                overscanOpts->fitType != PM_FIT_POLY_CHEBY && overscanOpts->fitType != PM_FIT_SPLINE) {
    282             psError(PS_ERR_UNKNOWN, true, "Invalid fit type (%d).  Returning original image.\n", overscanOpts->fitType);
     225            psError(PS_ERR_UNKNOWN, true, "Invalid fit type (%d).  Returning original image.\n",
     226                    overscanOpts->fitType);
    283227            return false;
    284228        }
     
    335279                while ((overscan = psListGetAndIncrement(iter))) {
    336280                    int diff = image->row0 - overscan->row0; // Offset between the two regions
    337                     for (int i = MAX(0,diff); i < MIN(image->numRows, overscan->numRows + diff); i++) {
     281                    for (int i = PS_MAX(0,diff); i < PS_MIN(image->numRows, overscan->numRows + diff); i++) {
    338282                        // i is row on overscan
    339283                        // XXX Reimplement with memcpy
     
    379323                while ((overscan = psListGetAndIncrement(iter))) {
    380324                    int diff = image->col0 - overscan->col0; // Offset between the two regions
    381                     for (int i = MAX(0,diff); i < MIN(image->numCols, overscan->numCols + diff); i++) {
     325                    for (int i = PS_MAX(0,diff); i < PS_MIN(image->numCols, overscan->numCols + diff); i++) {
    382326                        // i is column on overscan
    383327                        // XXX Reimplement with memcpy
  • trunk/psModules/src/detrend/pmSubtractBias.h

    r7589 r9619  
    1 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
    2 // XXX WARNING: I have completely replaced this file with an OLD VERSION (that works) instead of the
    3 // one that was being worked on.
    4 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
     1/// @file pmSubtractBias.h
     2///
     3/// @brief Subtract the overscan, bias and dark
     4///
     5/// @ingroup Detrend
     6///
     7/// @author George Gusciora, MHPCC
     8/// @author Paul Price, IfA
     9///
     10/// @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     11/// @date $Date: 2006-10-18 01:05:59 $
     12///
     13/// Copyright 2004--2006 Institute for Astronomy, University of Hawaii
     14///
    515
    6 /** @file  pmSubtractBias.h
    7  *
    8  *  This file will contain a module which will subtract the detector bias
    9  *  in place from an input image.
    10  *
    11  *  @author GLG, MHPCC
    12  *
    13  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-06-17 01:50:43 $
    15  *
    16  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    17  *
    18  */
    19 
    20 #if !defined(PM_SUBTRACT_BIAS_H)
     16#ifndef PM_SUBTRACT_BIAS_H
    2117#define PM_SUBTRACT_BIAS_H
    2218
    23 #if HAVE_CONFIG_H
    24 #include <config.h>
    25 #endif
    26 
    27 #include<stdio.h>
    28 #include<math.h>
    29 #include "pslib.h"
     19#include <stdio.h>
     20#include <pslib.h>
    3021
    3122#include "pmFPA.h"
    3223
    33 typedef enum {
    34     PM_OVERSCAN_NONE,                         ///< No overscan subtraction
    35     PM_OVERSCAN_EDGE,                         ///< Subtract the statistic of pixels along the to-be-determined readout direction
    36     PM_OVERSCAN_ROWS,                         ///< Subtract rows
    37     PM_OVERSCAN_COLUMNS,                      ///< Subtract columns
    38     PM_OVERSCAN_ALL                           ///< Subtract the statistic of all pixels in overscan region
    39 } pmOverscanAxis;
    40 
     24/// Type of fit to perform
    4125typedef enum {
    4226    PM_FIT_NONE,                        ///< No fit
     
    4630} pmFit;
    4731
     32/// Options for overscan subtraction
     33///
     34/// The overscan subtraction may be performed by reducing all overscan regions to a single value (e.g., if
     35/// there is no structure); or the overscan may be fit perpendicular to the read direction (usually the
     36/// columns) with a particular functional form; or a single value may be subtracted for each read/scan without
     37/// fitting (if the structure defies characterisation).  In any case, statistics are required to reduce
     38/// multiple values to a single value (either for the scan, or for the entire overscan regions).
    4839typedef struct
    4940{
    5041    // Inputs
    51     bool single;                // Reduce all overscan regions to a single value?
    52     pmFit fitType;              // Type of fit to overscan
    53     unsigned int order;         // Order of polynomial, or number of spline pieces
    54     psStats *stat;              // Statistic to use when reducing the minor direction
     42    bool single;                ///< Reduce all overscan regions to a single value?
     43    pmFit fitType;              ///< Type of fit to overscan
     44    unsigned int order;         ///< Order of polynomial, or number of spline pieces
     45    psStats *stat;              ///< Statistic to use when reducing the minor direction
    5546    // Outputs
    56     psPolynomial1D *poly;       // Result of polynomial fit
    57     psSpline1D *spline;         // Result of spline fit
     47    psPolynomial1D *poly;       ///< Result of polynomial fit
     48    psSpline1D *spline;         ///< Result of spline fit
    5849}
    5950pmOverscanOptions;
    6051
    61 pmOverscanOptions *pmOverscanOptionsAlloc(bool single, pmFit fitType, unsigned int order, psStats *stat);
     52/// Allocator for overscan options
     53pmOverscanOptions *pmOverscanOptionsAlloc(bool single, ///< Reduce all overscan regions to a single value?
     54        pmFit fitType, ///< Type of fit to overscan
     55        unsigned int order, ///< Order of polynomial, or number of splines
     56        psStats *stat ///< Statistic to use
     57                                         );
    6258
    63 bool pmSubtractBias(pmReadout *in, pmOverscanOptions *overscanOpts,
    64                     const pmReadout *bias, const pmReadout *dark);
    65 
    66 #if 0
    67 pmReadout *pmSubtractBias(pmReadout *in,                ///< The input pmReadout image
    68                           void *fitSpec,                ///< A polynomial or spline, defining the fit type.
    69                           const psList *overscans,      ///< A psList of overscan images
    70                           pmOverscanAxis overScanAxis,  ///< Defines how overscans are applied
    71                           psStats *stat,                ///< The statistic to be used in combining overscan data
    72                           int nBin,                     ///< The amount of binning to be done image pixels.
    73                           pmFit fit,                    ///< PM_FIT_SPLINE, PM_FIT_POLYNOMIAL, or PM_FIT_NONE
    74                           const pmReadout *bias);       ///< A possibly NULL bias pmReadout which is to be subtracted
    75 #endif
     59/// Subtract the overscan, bias and/or dark
     60///
     61/// Subtracts the overscan, as measured from the bias member of the input readout (if options are non-NULL),
     62/// bias (if non-NULL) and dark (if non-NULL) scaled by the CELL.DARKTIME concept.
     63bool pmSubtractBias(pmReadout *in,      ///< Input readout, to be overscan/bias/dark corrected
     64                    pmOverscanOptions *overscanOpts, ///< Options for overscan subtraction, or NULL
     65                    const pmReadout *bias, ///< Bias image to subtract, or NULL
     66                    const pmReadout *dark ///< Dark image to scale and subtract, or NULL
     67                   );
    7668
    7769#endif
Note: See TracChangeset for help on using the changeset viewer.