IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6899


Ignore:
Timestamp:
Apr 18, 2006, 8:31:55 PM (20 years ago)
Author:
magnier
Message:

fixed handling of masks, fixed negative-radius errors in models

Location:
branches/rel10_ifa/psModules/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/astrom/Makefile.am

    r6859 r6899  
    77        pmFPAConstruct.c \
    88        pmFPACopy.c \
    9         pmFPAMaskWeight.c \
    109        pmFPARead.c \
    1110        pmFPAUtils.c \
     
    2221        pmFPAfile.c
    2322
     23#       pmFPAMaskWeight.c \
    2424#       pmFPAAstrometry.c
    2525#       pmAstrometryObjects.c
     
    3131        pmFPAConstruct.h \
    3232        pmFPACopy.h \
    33         pmFPAMaskWeight.h \
    3433        pmFPARead.h \
    3534        pmFPAUtils.h \
     
    4645        pmFPAfile.h
    4746
     47#       pmFPAMaskWeight.h \
    4848#       pmFPAAstrometry.h
    4949#       pmAstrometryObjects.h
  • branches/rel10_ifa/psModules/src/astrom/pmReadout.c

    r6726 r6899  
    22#include "pslib.h"
    33#include "pmFPA.h"
     4#include "pmMaskBadPixels.h"
    45#include "pmHDUUtils.h"
    5 #include "pmFPAMaskWeight.h"
    66
    77// Get the bias images for a readout, using the CELL.BIASSEC
  • branches/rel10_ifa/psModules/src/detrend/pmMaskBadPixels.c

    r6554 r6899  
    2424 *  @author Ross Harman, MHPCC
    2525 *
    26  *  @version $Revision: 1.3.12.2 $ $Name: not supported by cvs2svn $
    27  *  @date $Date: 2006-03-09 03:10:27 $
     26 *  @version $Revision: 1.3.12.3 $ $Name: not supported by cvs2svn $
     27 *  @date $Date: 2006-04-19 06:31:55 $
    2828 *
    2929 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    148148            /* Pixels which satisfy growVal and within the grow radius shall be masked */                    \
    149149            if(mask->data.PS_TYPE_MASK_DATA[j][i] & growVal) {                                               \
    150                 rowMin = MAX(j-grow, 0);                                                                     \
    151                 rowMax = MIN(j+grow+1, inImage->numRows);                                                    \
    152                 colMin = MAX(i-grow, 0);                                                                     \
    153                 colMax = MIN(i+grow+1, inImage->numCols);                                                    \
     150                rowMin = PS_MAX(j-grow, 0);                                                                     \
     151                rowMax = PS_MIN(j+grow+1, inImage->numRows);                                                    \
     152                colMin = PS_MAX(i-grow, 0);                                                                     \
     153                colMax = PS_MIN(i+grow+1, inImage->numCols);                                                    \
    154154                for(jj=rowMin; jj<rowMax; jj++) {                                                            \
    155155                    for(ii=colMin; ii<colMax; ii++) {                                                        \
  • branches/rel10_ifa/psModules/src/detrend/pmMaskBadPixels.h

    r6448 r6899  
    2424 *  @author Ross Harman, MHPCC
    2525 *
    26  *  @version $Revision: 1.2.12.1 $ $Name: not supported by cvs2svn $
    27  *  @date $Date: 2006-02-17 17:13:41 $
     26 *  @version $Revision: 1.2.12.2 $ $Name: not supported by cvs2svn $
     27 *  @date $Date: 2006-04-19 06:31:55 $
    2828 *
    2929 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3333#include "pmFPA.h"
    3434
     35// these defines are necessary to yield 8-bit results (use instead of ~)
     36# define NOT_U8(A)(UCHAR_MAX-(A))
     37# define NOT_U16(A)(USHORT_MAX-(A))
     38
    3539/** Mask values */
    3640typedef enum {
    37     PM_MASK_TRAP    = 0x0001,   ///< The pixel is a charge trap.
    38     PM_MASK_BADCOL  = 0x0002,   ///< The pixel is a bad column.
    39     PM_MASK_SAT     = 0x0004,   ///< The pixel is saturated.
    40     PM_MASK_BAD     = 0x0008,   ///< The pixel is low
    41     PM_MASK_FLAT    = 0x0010    ///< The pixel is non-positive in the flat-field.
     41    PM_MASK_CLEAR   = 0x00,   ///< The pixel is a charge trap.
     42    PM_MASK_TRAP    = 0x01,   ///< The pixel is a charge trap.
     43    PM_MASK_BADCOL  = 0x02,   ///< The pixel is a bad column.
     44    PM_MASK_SAT     = 0x04,   ///< The pixel is saturated.
     45    PM_MASK_BAD     = 0x08,   ///< The pixel is low
     46    PM_MASK_FLAT    = 0x10,   ///< The pixel is non-positive in the flat-field.
     47    PM_MASK_MARK    = 0x20,   ///< The pixel is marked as temporarily ignored
     48    PM_MASK_EXT1    = 0x40,   ///< This mask value is not used
     49    PM_MASK_EXT2    = 0x80,   ///< This mask value is not used
    4250} pmMaskValue;
    4351
    44 /** Macro to find maximum of two numbers */
    45 #define MAX(A,B)((A)>=(B)?(A):(B))
    46 
    47 /** Macro to find minimum of two numbers */
    48 #define MIN(A,B)((A)<=(B)?(A):(B))
    49 
     52bool pmReadoutSetMask(pmReadout *readout // Readout for which to set mask
     53                     );
     54bool pmReadoutSetWeight(pmReadout *readout // Readout for which to set weight
     55                       );
     56bool pmCellSetMaskWeight(pmCell *cell // Cell for which to set weights
     57                        );
    5058
    5159/** Execute bad pixels module.
  • branches/rel10_ifa/psModules/src/objects/models/pmModel_QGAUSS.c

    r6864 r6899  
    2626    psF32 py = PAR[5]*Y;
    2727    psF32 z  = 0.5*PS_SQR(px) + 0.5*PS_SQR(py) + PAR[6]*X*Y;
     28    if (z <= 0) {
     29        if (deriv) {
     30            psF32 *dPAR = deriv->data.F32;
     31            dPAR[0] = 0.0;
     32            dPAR[1] = 0.0;
     33            dPAR[2] = 0.0;
     34            dPAR[3] = 0.0;
     35            dPAR[4] = 0.0;
     36            dPAR[5] = 0.0;
     37            dPAR[6] = 0.0;
     38            dPAR[7] = 0.0;
     39        }
     40        return(0.0);
     41    }
     42
    2843    psF32 zp = pow(z,1.25);
     44    if (isnan(zp))
     45        psAbort ("psMinLMM", "nan in zp");
    2946
    3047    psF32 r  = 1.0 / (1 + PAR[7]*z + z*zp);
     48    if (isnan(r))
     49        psAbort ("psMinLMM", "nan in r");
     50
    3151    // test: psF32 r  = 1.0 / (1 + PAR[7]*z + PS_SQR(z));
    3252    psF32 r1 = PAR[1]*r;
     
    111131psF64 pmModelFlux_QGAUSS(const psVector *params)
    112132{
    113     float f, norm, z;
     133    float z;
     134    float norm;
    114135
    115136    psF32 *PAR = params->data.F32;
     
    122143
    123144    // the area needs to be multiplied by the integral of f(z)
     145    // XXX this integral can be done faster and more accurately
    124146    norm = 0.0;
    125     for (z = 0.05; z < 50; z += 0.1) {
     147
     148    # define DZ 0.1
     149
     150    # if 0
     151
     152    float f;
     153for (z = 0.5*DZ; z < 50; z += DZ) {
    126154        f = 1.0 / (1 + PAR[7]*z + pow(z, 2.25));
    127155        // test: f = 1.0 / (1 + PAR[7]*z + PS_SQR(z));
    128156        norm += f;
    129157    }
    130     norm *= 0.1;
     158    norm *= DZ;
     159    # else
     160
     161        float f0 = 1.0;
     162    float f1, f2;
     163    for (z = DZ; z < 50; z += DZ) {
     164        f1 = 1.0 / (1 + PAR[7]*z + pow(z, 2.25));
     165        z += DZ;
     166        f2 = 1.0 / (1 + PAR[7]*z + pow(z, 2.25));
     167        norm += f0 + 4*f1 + f2;
     168        f0 = f2;
     169    }
     170    norm *= DZ / 3.0;
     171    # endif
    131172
    132173    psF64 Flux = PAR[1] * Area * norm;
  • branches/rel10_ifa/psModules/src/objects/pmModelGroup.c

    r6556 r6899  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.2.4.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-03-09 03:14:23 $
     8 *  @version $Revision: 1.2.4.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-04-19 06:31:55 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  • branches/rel10_ifa/psModules/src/objects/pmPSFtry.c

    r6848 r6899  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.4.4.4 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-04-13 06:18:46 $
     7 *  @version $Revision: 1.4.4.5 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-04-19 06:31:55 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1515#include "pmHDU.h"
    1616#include "pmFPA.h"
     17#include "pmMaskBadPixels.h"
    1718#include "pmPeaks.h"
    1819#include "pmMoments.h"
     
    112113        // fit model as EXT, not PSF
    113114
    114         psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PM_SOURCE_MASK_MARKED);
     115        psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PM_MASK_MARK);
    115116        status = pmSourceFitModel (source, model, PM_SOURCE_FIT_EXT);
    116         psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PM_SOURCE_MASK_MARKED);
     117        psImageKeepCircle (source->mask, x, y, RADIUS, "AND", NOT_U8(PM_MASK_MARK));
    117118
    118119        // exclude the poor fits
     
    146147        y = source->peak->y;
    147148
    148         psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PM_SOURCE_MASK_MARKED);
     149        psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PM_MASK_MARK);
    149150        status = pmSourceFitModel (source, modelPSF, PM_SOURCE_FIT_PSF);
    150151
     
    176177
    177178next_source:
    178         psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PM_SOURCE_MASK_MARKED);
     179        psImageKeepCircle (source->mask, x, y, RADIUS, "AND", NOT_U8(PM_MASK_MARK));
    179180
    180181    }
  • branches/rel10_ifa/psModules/src/objects/pmSource.c

    r6859 r6899  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-04-14 21:43:59 $
     8 *  @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-04-19 06:31:55 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1919#include "pmHDU.h"
    2020#include "pmFPA.h"
     21#include "pmMaskBadPixels.h"
    2122#include "pmPeaks.h"
    2223#include "pmMoments.h"
     
    141142    psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
    142143
    143     # define NPIX 10
     144    // XXX SCALE is the bin size in pixels for the PSF clump search
    144145    # define SCALE 0.1
    145146
     
    164165        if (!status)
    165166            SY_MAX = 10.0;
     167        psF32 AR_MAX = psMetadataLookupF32 (&status, metadata, "MOMENTS_AR_MAX");
     168        if (!status)
     169            AR_MAX = 10.0;
     170        psF32 AR_MIN = 1.0 / AR_MAX;
    166171
    167172        // construct a sigma-plane image
     
    185190
    186191            // Sx,Sy are limited at 0.  a peak at 0,0 is artificial
    187             if ((fabs(tmpSrc->moments->Sx) < FLT_EPSILON) && (fabs(tmpSrc->moments->Sy) < FLT_EPSILON)) {
     192            if (fabs(tmpSrc->moments->Sx) < 0.05) {
     193                continue;
     194            }
     195            if (fabs(tmpSrc->moments->Sy) < 0.05) {
     196                continue;
     197            }
     198            if ((tmpSrc->moments->Sx / tmpSrc->moments->Sy) > AR_MAX) {
     199                continue;
     200            }
     201            if ((tmpSrc->moments->Sx / tmpSrc->moments->Sy) < AR_MIN) {
    188202                continue;
    189203            }
     
    341355        // inner = psRegionForSquare (tmpSrc->peak->x - tmpSrc->mask->col0, tmpSrc->peak->y - tmpSrc->mask->row0, 2);
    342356        inner = psRegionForSquare (tmpSrc->peak->x, tmpSrc->peak->y, 2);
    343         int Nsatpix = psImageCountPixelMask (tmpSrc->mask, inner, PM_SOURCE_MASK_SATURATED);
     357        int Nsatpix = psImageCountPixelMask (tmpSrc->mask, inner, PM_MASK_SAT);
    344358
    345359        // saturated star (size consistent with PSF or larger)
  • branches/rel10_ifa/psModules/src/objects/pmSource.h

    r6859 r6899  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-04-14 21:43:59 $
     5 *  @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-04-19 06:31:55 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2121 * values with specific meanings that other functions can add to or define?
    2222 */
     23
     24/*
    2325typedef enum {
    2426    PM_SOURCE_MASK_CLEAR     = 0x00,
     
    2729    PM_SOURCE_MASK_MARKED    = 0x08,
    2830} psphotMaskValues;
     31*/
    2932
    3033/** pmSourceType enumeration
  • branches/rel10_ifa/psModules/src/objects/pmSourcePhotometry.c

    r6864 r6899  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-04-17 17:10:08 $
     5 *  @version $Revision: 1.1.2.6 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-04-19 06:31:55 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1616#include "pmHDU.h"
    1717#include "pmFPA.h"
     18#include "pmMaskBadPixels.h"
    1819#include "pmPeaks.h"
    1920#include "pmMoments.h"
     
    117118
    118119    // set aperture mask circle to model radius
    119     psImageKeepCircle (source->mask, x, y, model->radiusTMP, "OR", PM_SOURCE_MASK_MARKED);
     120    psImageKeepCircle (source->mask, x, y, model->radiusTMP, "OR", PM_MASK_MARK);
    120121
    121122    // measure the weight of included pixels
     
    139140
    140141    // unmask aperture
    141     psImageKeepCircle (source->mask, x, y, model->radiusTMP, "AND", ~PM_SOURCE_MASK_MARKED);
     142    psImageKeepCircle (source->mask, x, y, model->radiusTMP, "AND", NOT_U8(PM_MASK_MARK));
    142143
    143144    // subtract object, leave local sky
  • branches/rel10_ifa/psModules/src/objects/pmSourceSky.c

    r6556 r6899  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-03-09 03:14:23 $
     8 *  @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-04-19 06:31:55 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1919#include "pmHDU.h"
    2020#include "pmFPA.h"
     21#include "pmMaskBadPixels.h"
    2122#include "pmPeaks.h"
    2223#include "pmMoments.h"
     
    5657    srcRegion = psRegionForImage(mask, srcRegion);
    5758
    58     psImageMaskRegion(mask, srcRegion, "OR", PM_SOURCE_MASK_MARKED);
     59    psImageMaskRegion(mask, srcRegion, "OR", PM_MASK_MARK);
    5960    psStats *myStats = psStatsAlloc(statsOptions);
    6061    myStats = psImageStats(myStats, image, mask, 0xff);
    61     psImageMaskRegion(mask, srcRegion, "AND", ~PM_SOURCE_MASK_MARKED);
     62    psImageMaskRegion(mask, srcRegion, "AND", NOT_U8(PM_MASK_EXT2));
     63
    6264
    6365    psF64 tmpF64;
     
    99101    srcRegion = psRegionForImage(mask, srcRegion);
    100102
    101     psImageMaskRegion(mask, srcRegion, "OR", PM_SOURCE_MASK_MARKED);
     103    psImageMaskRegion(mask, srcRegion, "OR", PM_MASK_MARK);
    102104    psStats *myStats = psStatsAlloc(statsOptions);
    103105    myStats = psImageStats(myStats, image, mask, 0xff);
    104     psImageMaskRegion(mask, srcRegion, "AND", ~PM_SOURCE_MASK_MARKED);
     106    psImageMaskRegion(mask, srcRegion, "AND", NOT_U8(PM_MASK_MARK));
    105107
    106108    psF64 tmpF64;
Note: See TracChangeset for help on using the changeset viewer.