IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14936


Ignore:
Timestamp:
Sep 20, 2007, 2:05:57 PM (19 years ago)
Author:
eugene
Message:

adding pmTrend2D as part of the pmPSF model (ApResid)

Location:
trunk/psModules/src/objects
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmPSF.c

    r14652 r14936  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-08-24 00:11:02 $
     8 *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-09-21 00:05:35 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2929#include "pmResiduals.h"
    3030#include "pmGrowthCurve.h"
     31#include "pmTrend2D.h"
    3132#include "pmPSF.h"
    3233#include "pmModel.h"
     
    108109    psf->poissonErrors = poissonErrors;
    109110
    110     // the ApTrend components are (x, y, r2rflux, flux)
    111     // the ApTrend order is defined by the masking
    112     // initially we set it to SKYBIAS (no X,Y variation)
    113     // this is adjusted in psphotApResid based on the user's choices
    114     psf->ApTrend = psPolynomial4DAlloc (PS_POLYNOMIAL_ORD, 2, 2, 1, 1);
    115     pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS);
     111    // the ApTrend components are (x, y).  It may be represented with a polynomial or with a
     112    // psImageMap.  We set it initially to NULL. the user must allocate it before using.
     113    // psf->ApTrend = pmTrend2DAlloc (PM_TREND_MAP, Nx, Ny, 1, 1, stats);
     114    psf->ApTrend = NULL;
    116115
    117116    if (psf->poissonErrors) {
     
    166165}
    167166
    168 // zero and mask out all terms:
    169 static bool maskAllApTerms (psPolynomial4D *trend)
    170 {
    171 
    172     for (int i = 0; i < trend->nX + 1; i++) {
    173         for (int j = 0; j < trend->nY + 1; j++) {
    174             for (int k = 0; k < trend->nZ + 1; k++) {
    175                 for (int m = 0; m < trend->nT + 1; m++) {
    176                     trend->mask[i][j][k][m] = 1;  // mask coeff
    177                     trend->coeff[i][j][k][m] = 0;  // zero coeff
    178                 }
    179             }
    180         }
    181     }
    182     return true;
    183 }
    184 
    185167// the PSF models the \sigma_{xy} variation of the elliptical contour as a function of position in the image with a
    186168// polynomial.  an individual object has a contour of the form (x^2/2sx^2) + (y^2/2sy^2) + sxy*x*y
     
    344326}
    345327
    346 /***********************************************
    347  * this function masks the psf.ApTrend polynomial
    348  * to enable the specific subset of the coefficients
    349  **********************************************/
    350 bool pmPSFMaskApTrend (psPolynomial4D *trend,
    351                        pmPSFApTrendOptions option)
    352 {
    353 
    354     switch (option) {
    355     case PM_PSF_APTREND_NONE:
    356         maskAllApTerms (trend);
    357         return true;
    358 
    359     case PM_PSF_APTREND_CONSTANT:
    360         maskAllApTerms (trend);
    361         trend->mask[0][0][0][0] = 0;  // unmask constant
    362         return true;
    363 
    364     case PM_PSF_APTREND_SKYBIAS:
    365         maskAllApTerms (trend);
    366         trend->mask[0][0][0][0] = 0;  // unmask constant
    367         trend->mask[0][0][1][0] = 0;  // unmask skybias
    368         return true;
    369 
    370     case PM_PSF_APTREND_SKYSAT:
    371         maskAllApTerms (trend);
    372         trend->mask[0][0][0][0] = 0;  // unmask constant
    373         trend->mask[0][0][1][0] = 0;  // unmask skybias
    374         trend->mask[0][0][0][1] = 0;  // unmask skysat
    375         return true;
    376 
    377     case PM_PSF_APTREND_XY_LIN:
    378         maskAllApTerms (trend);
    379         trend->mask[0][0][0][0] = 0;  // unmask constant
    380         trend->mask[1][0][0][0] = 0;  // unmask x
    381         trend->mask[0][1][0][0] = 0;  // unmask y
    382         return true;
    383 
    384     case PM_PSF_APTREND_XY_QUAD:
    385         maskAllApTerms (trend);
    386         trend->mask[0][0][0][0] = 0;  // unmask constant
    387         trend->mask[1][0][0][0] = 0;  // unmask x
    388         trend->mask[2][0][0][0] = 0;  // unmask x^2
    389         trend->mask[1][1][0][0] = 0;  // unmask x y
    390         trend->mask[0][1][0][0] = 0;  // unmask y
    391         trend->mask[0][2][0][0] = 0;  // unmask y^2
    392         return true;
    393 
    394     case PM_PSF_APTREND_SKY_XY_LIN:
    395         maskAllApTerms (trend);
    396         trend->mask[0][0][0][0] = 0;  // unmask constant
    397         trend->mask[1][0][0][0] = 0;  // unmask x
    398         trend->mask[0][1][0][0] = 0;  // unmask y
    399         trend->mask[0][0][1][0] = 0;  // unmask skybias
    400         return true;
    401 
    402     case PM_PSF_APTREND_SKYSAT_XY_LIN:
    403         maskAllApTerms (trend);
    404         trend->mask[0][0][0][0] = 0;  // unmask constant
    405         trend->mask[1][0][0][0] = 0;  // unmask x
    406         trend->mask[0][1][0][0] = 0;  // unmask y
    407         trend->mask[0][0][1][0] = 0;  // unmask skybias
    408         trend->mask[0][0][0][1] = 0;  // unmask skysat
    409         return true;
    410 
    411     case PM_PSF_APTREND_ALL:
    412     default:
    413         maskAllApTerms (trend);
    414         trend->mask[0][0][0][0] = 0;  // unmask constant
    415         trend->mask[0][0][1][0] = 0;  // unmask skybias
    416         trend->mask[0][0][0][1] = 0;  // unmask skysat
    417 
    418         trend->mask[1][0][0][0] = 0;  // unmask x
    419         trend->mask[2][0][0][0] = 0;  // unmask x^2
    420         trend->mask[1][1][0][0] = 0;  // unmask x y
    421         trend->mask[0][1][0][0] = 0;  // unmask y
    422         trend->mask[0][2][0][0] = 0;  // unmask y^2
    423         return true;
    424     }
    425     return false;
    426 }
    427 
    428 pmPSFApTrendOptions pmPSFApTrendOptionFromName (char *name)
    429 {
    430 
    431     // no correction
    432     if (!strcasecmp (name, "NONE"))
    433         return PM_PSF_APTREND_NONE;
    434     if (!strcasecmp (name, "CONSTANT"))
    435         return PM_PSF_APTREND_CONSTANT;
    436     if (!strcasecmp (name, "SKYBIAS"))
    437         return PM_PSF_APTREND_SKYBIAS;
    438     if (!strcasecmp (name, "SKYSAT"))
    439         return PM_PSF_APTREND_SKYSAT;
    440     if (!strcasecmp (name, "XY_LIN"))
    441         return PM_PSF_APTREND_XY_LIN;
    442     if (!strcasecmp (name, "XY_QUAD"))
    443         return PM_PSF_APTREND_XY_QUAD;
    444     if (!strcasecmp (name, "SKY_XY_LIN"))
    445         return PM_PSF_APTREND_SKY_XY_LIN;
    446     if (!strcasecmp (name, "SKYSAT_XY_LIN"))
    447         return PM_PSF_APTREND_SKYSAT_XY_LIN;
    448     if (!strcasecmp (name, "ALL"))
    449         return PM_PSF_APTREND_ALL;
    450 
    451     psError(PS_ERR_UNKNOWN, true, "Unknown APTREND value: %s", name);
    452     return PM_PSF_APTREND_ERROR;
    453 }
    454 
    455328// we generate the growth curve for the center of the image with the specified psf model
    456329bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType mark)
  • trunk/psModules/src/objects/pmPSF.h

    r14652 r14936  
    66 * @author EAM, IfA
    77 *
    8  * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2007-08-24 00:11:02 $
     8 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2007-09-21 00:05:35 $
    1010 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1111 */
     
    4949    pmModelType type;                   ///< PSF Model in use
    5050    psArray *params;                    ///< Model parameters (psPolynomial2D)
    51     psPolynomial1D *ChiTrend;         ///< Chisq vs flux fit (correction for systematic errors)
    52     psPolynomial4D *ApTrend;            ///< ApResid vs (x,y,rflux) (rflux = ten(0.4*mInst))
     51    psPolynomial1D *ChiTrend;           ///< Chisq vs flux fit (correction for systematic errors)
     52    pmTrend2D *ApTrend;                 ///< ApResid vs (x,y)
     53    pmTrend2D *FluxScale;               ///< Flux for PSF at (x,y) for normalization = 1.0
    5354    float ApResid;                      ///< apMag - psfMag (for PSF stars)
    5455    float dApResid;                     ///< scatter of ApResid
  • trunk/psModules/src/objects/pmPSF_IO.c

    r14652 r14936  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-08-24 00:11:02 $
     8 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-09-21 00:05:57 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4040#include "pmGrowthCurve.h"
    4141#include "pmResiduals.h"
     42#include "pmTrend2D.h"
    4243#include "pmPSF.h"
    4344#include "pmModel.h"
     
    354355
    355356    // XXX save the growth curve
    356     // XXX save the ApResid fit
     357    // XXX save ApTrend (as image?)
    357358
    358359# if (0)
     
    636637        psPolynomial2DtoMetadata (metadata, poly, "PSF_PAR%02d", i);
    637638    }
    638     psPolynomial4DtoMetadata (metadata, psf->ApTrend, "APTREND");
     639
     640    // XXX fix this
     641    psWarning ("APTREND is currently missing");
     642    // psPolynomial4DtoMetadata (metadata, psf->ApTrend, "APTREND");
    639643
    640644    psMetadataAdd (metadata, PS_LIST_TAIL, "PSF_AP_RESID", PS_DATA_F32, "aperture residual", psf->ApResid);
     
    681685        psf->params->data[i] = poly;
    682686    }
     687
     688    // load the APTREND data
     689    // XXX fix this to work with pmTrend2D
     690    psWarning ("APTREND is not being read");
     691    # if (0)
    683692    sprintf (keyword, "APTREND");
    684693    psMetadata *folder = psMetadataLookupPtr (&status, metadata, keyword);
     
    686695    psFree (psf->ApTrend);
    687696    psf->ApTrend = poly;
     697    # endif
    688698
    689699    psf->ApResid = psMetadataLookupF32 (&status, metadata, "PSF_AP_RESID");
Note: See TracChangeset for help on using the changeset viewer.