- Timestamp:
- Sep 19, 2014, 4:05:27 PM (12 years ago)
- Location:
- branches/eam_branches/ps2-tc3-20130727
- Files:
-
- 75 edited
- 1 copied
-
. (modified) (1 prop)
-
psModules/src/objects (modified) (1 prop)
-
psModules/src/objects/Makefile.am (modified) (4 diffs)
-
psModules/src/objects/mksource.pl (modified) (1 diff)
-
psModules/src/objects/models/fwhm.sh (copied) (copied from trunk/psModules/src/objects/models/fwhm.sh )
-
psModules/src/objects/models/pmModel_DEV.c (modified) (6 diffs)
-
psModules/src/objects/models/pmModel_DEV.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_EXP.c (modified) (5 diffs)
-
psModules/src/objects/models/pmModel_EXP.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_GAUSS.c (modified) (5 diffs)
-
psModules/src/objects/models/pmModel_GAUSS.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_PGAUSS.c (modified) (5 diffs)
-
psModules/src/objects/models/pmModel_PGAUSS.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_PS1_V1.c (modified) (5 diffs)
-
psModules/src/objects/models/pmModel_PS1_V1.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_QGAUSS.c (modified) (5 diffs)
-
psModules/src/objects/models/pmModel_QGAUSS.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_RGAUSS.c (modified) (5 diffs)
-
psModules/src/objects/models/pmModel_RGAUSS.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_SERSIC.c (modified) (6 diffs)
-
psModules/src/objects/models/pmModel_SERSIC.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_TRAIL.c (modified) (5 diffs)
-
psModules/src/objects/models/pmModel_TRAIL.h (modified) (1 diff)
-
psModules/src/objects/pmDetEff.c (modified) (1 diff)
-
psModules/src/objects/pmGrowthCurve.c (modified) (1 diff)
-
psModules/src/objects/pmGrowthCurveGenerate.c (modified) (1 diff)
-
psModules/src/objects/pmModel.c (modified) (5 diffs)
-
psModules/src/objects/pmModel.h (modified) (1 diff)
-
psModules/src/objects/pmModelClass.c (modified) (2 diffs)
-
psModules/src/objects/pmModelClass.h (modified) (1 diff)
-
psModules/src/objects/pmModelFuncs.h (modified) (1 diff)
-
psModules/src/objects/pmModelUtils.c (modified) (6 diffs)
-
psModules/src/objects/pmPCM_MinimizeChisq.c (modified) (2 diffs)
-
psModules/src/objects/pmPCMdata.c (modified) (6 diffs)
-
psModules/src/objects/pmPSF.c (modified) (6 diffs)
-
psModules/src/objects/pmPSF.h (modified) (1 diff)
-
psModules/src/objects/pmPSF_IO.c (modified) (2 diffs)
-
psModules/src/objects/pmPSFtry.c (modified) (1 diff)
-
psModules/src/objects/pmPSFtryFitEXT.c (modified) (1 diff)
-
psModules/src/objects/pmPSFtryFitPSF.c (modified) (1 diff)
-
psModules/src/objects/pmPSFtryMakePSF.c (modified) (3 diffs)
-
psModules/src/objects/pmPSFtryMetric.c (modified) (1 diff)
-
psModules/src/objects/pmPSFtryModel.c (modified) (1 diff)
-
psModules/src/objects/pmPhotObj.c (modified) (1 diff)
-
psModules/src/objects/pmSource.c (modified) (6 diffs)
-
psModules/src/objects/pmSource.h (modified) (4 diffs)
-
psModules/src/objects/pmSourceContour.c (modified) (1 diff)
-
psModules/src/objects/pmSourceExtendedPars.h (modified) (1 diff)
-
psModules/src/objects/pmSourceFitModel.c (modified) (5 diffs)
-
psModules/src/objects/pmSourceFitPCM.c (modified) (3 diffs)
-
psModules/src/objects/pmSourceFitSet.c (modified) (3 diffs)
-
psModules/src/objects/pmSourceGroups.c (modified) (1 diff)
-
psModules/src/objects/pmSourceIO.c (modified) (12 diffs)
-
psModules/src/objects/pmSourceIO.h (modified) (2 diffs)
-
psModules/src/objects/pmSourceIO_CFF.c (modified) (9 diffs)
-
psModules/src/objects/pmSourceIO_CMF.c.in (modified) (28 diffs)
-
psModules/src/objects/pmSourceIO_CMP.c (modified) (3 diffs)
-
psModules/src/objects/pmSourceIO_MatchedRefs.c (modified) (3 diffs)
-
psModules/src/objects/pmSourceIO_OBJ.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceIO_PS1_CAL_0.c (modified) (4 diffs)
-
psModules/src/objects/pmSourceIO_PS1_DEV_0.c (modified) (3 diffs)
-
psModules/src/objects/pmSourceIO_PS1_DEV_1.c (modified) (4 diffs)
-
psModules/src/objects/pmSourceIO_RAW.c (modified) (1 diff)
-
psModules/src/objects/pmSourceIO_SMPDATA.c (modified) (3 diffs)
-
psModules/src/objects/pmSourceIO_SX.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceMatch.c (modified) (1 diff)
-
psModules/src/objects/pmSourceMoments.c (modified) (1 diff)
-
psModules/src/objects/pmSourceOutputs.c (modified) (3 diffs)
-
psModules/src/objects/pmSourceOutputs.h (modified) (1 diff)
-
psModules/src/objects/pmSourcePhotometry.c (modified) (5 diffs)
-
psModules/src/objects/pmSourcePlotApResid.c (modified) (1 diff)
-
psModules/src/objects/pmSourcePlotMoments.c (modified) (1 diff)
-
psModules/src/objects/pmSourcePlotPSFModel.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceSky.c (modified) (1 diff)
-
psModules/src/objects/pmSourceUtils.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceVisual.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ps2-tc3-20130727
- Property svn:mergeinfo changed
-
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects
- Property svn:ignore
-
old new 15 15 pmSourceIO_CMF_PS1_SV1.c 16 16 pmSourceIO_CMF_PS1_SV2.c 17 pmSourceIO_CMF_PS1_SV3.c 18 pmSourceIO_CMF_PS1_SV4.c 17 19 pmSourceIO_CMF_PS1_DV1.c 18 20 pmSourceIO_CMF_PS1_DV2.c 19 21 pmSourceIO_CMF_PS1_DV3.c 22 pmSourceIO_CMF_PS1_DV4.c 20 23
-
- Property svn:ignore
-
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/Makefile.am
r36680 r37403 52 52 pmSourceIO_CMF_PS1_SV1.c \ 53 53 pmSourceIO_CMF_PS1_SV2.c \ 54 pmSourceIO_CMF_PS1_SV3.c \ 55 pmSourceIO_CMF_PS1_SV4.c \ 54 56 pmSourceIO_CMF_PS1_DV1.c \ 55 57 pmSourceIO_CMF_PS1_DV2.c \ 56 58 pmSourceIO_CMF_PS1_DV3.c \ 59 pmSourceIO_CMF_PS1_DV4.c \ 57 60 pmSourceIO_MatchedRefs.c \ 58 61 pmSourcePlots.c \ … … 152 155 pmSourceIO_CMF_PS1_DV2.c \ 153 156 pmSourceIO_CMF_PS1_DV3.c \ 157 pmSourceIO_CMF_PS1_DV4.c \ 154 158 pmSourceIO_CMF_PS1_SV1.c \ 155 pmSourceIO_CMF_PS1_SV2.c 159 pmSourceIO_CMF_PS1_SV2.c \ 160 pmSourceIO_CMF_PS1_SV3.c \ 161 pmSourceIO_CMF_PS1_SV4.c 156 162 157 163 pmSourceIO_CMF_PS1_V1.c : pmSourceIO_CMF.c.in mksource.pl … … 179 185 mksource.pl pmSourceIO_CMF.c.in PS1_DV3 pmSourceIO_CMF_PS1_DV3.c 180 186 187 pmSourceIO_CMF_PS1_DV4.c : pmSourceIO_CMF.c.in mksource.pl 188 mksource.pl pmSourceIO_CMF.c.in PS1_DV4 pmSourceIO_CMF_PS1_DV4.c 189 181 190 pmSourceIO_CMF_PS1_SV1.c : pmSourceIO_CMF.c.in mksource.pl 182 191 mksource.pl pmSourceIO_CMF.c.in PS1_SV1 pmSourceIO_CMF_PS1_SV1.c … … 185 194 mksource.pl pmSourceIO_CMF.c.in PS1_SV2 pmSourceIO_CMF_PS1_SV2.c 186 195 196 pmSourceIO_CMF_PS1_SV3.c : pmSourceIO_CMF.c.in mksource.pl 197 mksource.pl pmSourceIO_CMF.c.in PS1_SV3 pmSourceIO_CMF_PS1_SV3.c 198 199 pmSourceIO_CMF_PS1_SV4.c : pmSourceIO_CMF.c.in mksource.pl 200 mksource.pl pmSourceIO_CMF.c.in PS1_SV4 pmSourceIO_CMF_PS1_SV4.c 201 187 202 # EXTRA_DIST = pmErrorCodes.h.in pmErrorCodes.dat pmErrorCodes.c.in -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/mksource.pl
r36680 r37403 24 24 "PS1_DV2", 2, 25 25 "PS1_DV3", 3, 26 "PS1_DV4", 4, 26 27 ); 27 28 %cmfmodes_sv = ("PS1_SV1", 1, 28 29 "PS1_SV2", 2, 30 "PS1_SV3", 3, 31 "PS1_SV4", 4, 29 32 ); 30 33 -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_DEV.c
r36680 r37403 36 36 #include "pmMoments.h" 37 37 #include "pmModelFuncs.h" 38 #include "pmModelClass.h" 38 39 #include "pmModel.h" 39 40 #include "pmModelUtils.h" 40 #include "pmModelClass.h"41 41 #include "pmSourceMasks.h" 42 42 #include "pmSourceExtendedPars.h" … … 59 59 # define PM_MODEL_LIMITS pmModelLimits_DEV 60 60 # define PM_MODEL_RADIUS pmModelRadius_DEV 61 # define PM_MODEL_SET_FWHM pmModelSetFWHM_DEV 61 62 # define PM_MODEL_FROM_PSF pmModelFromPSF_DEV 62 63 # define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_DEV … … 123 124 if (radius <= 1.5) { 124 125 // Nsub ~ 10*index^2 + 1 125 psEllipseAxes axes = pmPSF_ModelToAxes(PAR, pmModelClassGetType ("PS_MODEL_DEV"));126 psEllipseAxes axes = pmPSF_ModelToAxes(PAR, true); // DEV uses Reff 126 127 int Nsub = 2 * ((int)(25 / axes.minor)) + 1; 127 128 Nsub = PS_MIN (Nsub, 121); … … 336 337 } 337 338 339 psF64 PM_MODEL_SET_FWHM (const psVector *params, psF64 sigma) { 340 return (NAN); 341 } 342 338 343 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf) 339 344 { … … 357 362 // the 2D PSF model fits polarization terms (E0,E1,E2) 358 363 // convert to shape terms (SXX,SYY,SXY) 359 bool useReff = pmModelUseReff (modelPSF->type);364 bool useReff = modelPSF->class->useReff; 360 365 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 361 366 psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); … … 411 416 // convert to shape terms (SXX,SYY,SXY) 412 417 // XXX user-defined value for limit? 413 bool useReff = pmModelUseReff (model->type);418 bool useReff = model->class->useReff; 414 419 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 415 420 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_DEV.h
r35560 r37403 8 8 psF64 pmModelFlux_DEV(const psVector *params); 9 9 psF64 pmModelRadius_DEV(const psVector *params, psF64 flux); 10 psF64 pmModelSetFWHM_DEV(const psVector *params, psF64 flux); 10 11 bool pmModelFromPSF_DEV(pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf); 11 12 bool pmModelParamsFromPSF_DEV(pmModel *model, const pmPSF *psf, float Xo, float Yo, float Io); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_EXP.c
r36680 r37403 33 33 #include "pmMoments.h" 34 34 #include "pmModelFuncs.h" 35 #include "pmModelClass.h" 35 36 #include "pmModel.h" 36 37 #include "pmModelUtils.h" 37 #include "pmModelClass.h"38 38 #include "pmSourceMasks.h" 39 39 #include "pmSourceExtendedPars.h" … … 56 56 # define PM_MODEL_LIMITS pmModelLimits_EXP 57 57 # define PM_MODEL_RADIUS pmModelRadius_EXP 58 # define PM_MODEL_SET_FWHM pmModelSetFWHM_EXP 58 59 # define PM_MODEL_FROM_PSF pmModelFromPSF_EXP 59 60 # define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_EXP … … 343 344 } 344 345 346 psF64 PM_MODEL_SET_FWHM (const psVector *params, psF64 sigma) { 347 return (NAN); 348 } 349 345 350 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf) 346 351 { … … 364 369 // the 2D PSF model fits polarization terms (E0,E1,E2) 365 370 // convert to shape terms (SXX,SYY,SXY) 366 bool useReff = pmModelUseReff (modelPSF->type);371 bool useReff = modelPSF->class->useReff; 367 372 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 368 373 psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); … … 418 423 // convert to shape terms (SXX,SYY,SXY) 419 424 // XXX user-defined value for limit? 420 bool useReff = pmModelUseReff (model->type);425 bool useReff = model->class->useReff; 421 426 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 422 427 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_EXP.h
r35560 r37403 8 8 psF64 pmModelFlux_EXP(const psVector *params); 9 9 psF64 pmModelRadius_EXP(const psVector *params, psF64 flux); 10 psF64 pmModelSetFWHM_EXP(const psVector *params, psF64 flux); 10 11 bool pmModelFromPSF_EXP(pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf); 11 12 bool pmModelParamsFromPSF_EXP(pmModel *model, const pmPSF *psf, float Xo, float Yo, float Io); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_GAUSS.c
r36680 r37403 33 33 #include "pmMoments.h" 34 34 #include "pmModelFuncs.h" 35 #include "pmModelClass.h" 35 36 #include "pmModel.h" 36 37 #include "pmModelUtils.h" 37 #include "pmModelClass.h"38 38 #include "pmSourceMasks.h" 39 39 #include "pmSourceExtendedPars.h" … … 54 54 # define PM_MODEL_GUESS pmModelGuess_GAUSS 55 55 # define PM_MODEL_LIMITS pmModelLimits_GAUSS 56 # define PM_MODEL_SET_FWHM pmModelSetFWHM_GAUSS 56 57 # define PM_MODEL_RADIUS pmModelRadius_GAUSS 57 58 # define PM_MODEL_FROM_PSF pmModelFromPSF_GAUSS … … 257 258 } 258 259 260 psF64 PM_MODEL_SET_FWHM (const psVector *params, psF64 sigma) { 261 return (2.35482004503*sigma); 262 } 263 259 264 // construct the PSF model from the FLT model and the psf 260 265 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf) … … 279 284 // the 2D PSF model fits polarization terms (E0,E1,E2) 280 285 // convert to shape terms (SXX,SYY,SXY) 281 bool useReff = pmModelUseReff (modelPSF->type);286 bool useReff = modelPSF->class->useReff; 282 287 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 283 288 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); … … 331 336 // the 2D PSF model fits polarization terms (E0,E1,E2) 332 337 // convert to shape terms (SXX,SYY,SXY) 333 bool useReff = pmModelUseReff (model->type);338 bool useReff = model->class->useReff; 334 339 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 335 340 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_GAUSS.h
r35560 r37403 8 8 psF64 pmModelFlux_GAUSS(const psVector *params); 9 9 psF64 pmModelRadius_GAUSS(const psVector *params, psF64 flux); 10 psF64 pmModelSetFWHM_GAUSS(const psVector *params, psF64 flux); 10 11 bool pmModelFromPSF_GAUSS(pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf); 11 12 bool pmModelParamsFromPSF_GAUSS(pmModel *model, const pmPSF *psf, float Xo, float Yo, float Io); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_PGAUSS.c
r36680 r37403 33 33 #include "pmMoments.h" 34 34 #include "pmModelFuncs.h" 35 #include "pmModelClass.h" 35 36 #include "pmModel.h" 36 37 #include "pmModelUtils.h" 37 #include "pmModelClass.h"38 38 #include "pmSourceMasks.h" 39 39 #include "pmSourceExtendedPars.h" … … 55 55 # define PM_MODEL_LIMITS pmModelLimits_PGAUSS 56 56 # define PM_MODEL_RADIUS pmModelRadius_PGAUSS 57 # define PM_MODEL_SET_FWHM pmModelSetFWHM_PGAUSS 57 58 # define PM_MODEL_FROM_PSF pmModelFromPSF_PGAUSS 58 59 # define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_PGAUSS … … 324 325 } 325 326 327 // scale factor is constant for PGAUSS, I found it with the fwhm.sh script 328 psF64 PM_MODEL_SET_FWHM (const psVector *params, psF64 sigma) { 329 return (3.0063103*sigma); 330 } 331 326 332 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf) 327 333 { … … 344 350 // the 2D PSF model fits polarization terms (E0,E1,E2) 345 351 // convert to shape terms (SXX,SYY,SXY) 346 bool useReff = pmModelUseReff (modelPSF->type);352 bool useReff = modelPSF->class->useReff; 347 353 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 348 354 psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); … … 396 402 // the 2D PSF model fits polarization terms (E0,E1,E2) 397 403 // convert to shape terms (SXX,SYY,SXY) 398 bool useReff = pmModelUseReff (model->type);404 bool useReff = model->class->useReff; 399 405 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 400 406 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_PGAUSS.h
r35560 r37403 8 8 psF64 pmModelFlux_PGAUSS(const psVector *params); 9 9 psF64 pmModelRadius_PGAUSS(const psVector *params, psF64 flux); 10 psF64 pmModelSetFWHM_PGAUSS(const psVector *params, psF64 flux); 10 11 bool pmModelFromPSF_PGAUSS(pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf); 11 12 bool pmModelParamsFromPSF_PGAUSS(pmModel *model, const pmPSF *psf, float Xo, float Yo, float Io); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_PS1_V1.c
r36680 r37403 35 35 #include "pmMoments.h" 36 36 #include "pmModelFuncs.h" 37 #include "pmModelClass.h" 37 38 #include "pmModel.h" 38 39 #include "pmModelUtils.h" 39 #include "pmModelClass.h"40 40 #include "pmSourceMasks.h" 41 41 #include "pmSourceExtendedPars.h" … … 57 57 # define PM_MODEL_LIMITS pmModelLimits_PS1_V1 58 58 # define PM_MODEL_RADIUS pmModelRadius_PS1_V1 59 # define PM_MODEL_SET_FWHM pmModelSetFWHM_PS1_V1 59 60 # define PM_MODEL_FROM_PSF pmModelFromPSF_PS1_V1 60 61 # define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_PS1_V1 … … 336 337 } 337 338 339 // I used the script in models/fwhm.sh to generate the trend of FWHM scaling vs the K value 340 // FWHM = Scale * Sigma (not that PAR[PM_PAR_SXX] = sigma * sqrt(2) 341 // K : z_hm : FWHM 342 // 0 : 1.000 : 2.83 343 // 1 : 0.597 : 2.19 344 // 2 : 0.396 : 1.78 345 // 3 : 0.291 : 1.53 346 // 4 : 0.232 : 1.36 347 // 5 : 0.198 : 1.26 348 // 6 : 0.169 : 1.16 349 // 7 : 0.142 : 1.07 350 // 8 : 0.124 : 0.99 351 // 9 : 0.118 : 0.97 352 // 10 : 0.106 : 0.92 353 // 11 : 0.092 : 0.86 354 // 12 : 0.091 : 0.85 355 // 13 : 0.080 : 0.80 356 // 14 : 0.078 : 0.79 357 // 15 : 0.073 : 0.76 358 // 16 : 0.063 : 0.71 359 // 17 : 0.068 : 0.74 360 // 18 : 0.056 : 0.67 361 // 19 : 0.058 : 0.68 362 363 // static float PS1_V1_Core[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0}; 364 static float PS1_V1_Scale[] = {2.83, 2.19, 1.78, 1.53, 1.36, 1.26, 1.16, 1.07, 0.99, 0.97, 0.92, 0.86, 0.85, 0.80, 0.79, 0.76, 0.71, 0.74, 0.67, 0.68}; 365 366 psF64 PM_MODEL_SET_FWHM (const psVector *params, psF64 sigma) { 367 368 psF32 *PAR = params->data.F32; 369 370 float core = PAR[PM_PAR_7]; 371 372 if (!isfinite(core)) return (2.0*M_SQRT2*sigma); 373 374 // if PS1_V1_Core is defined as a set of integer steps, so we can simplify: 375 int binCore = MAX(0, MIN (19, (int)core)); 376 377 float scale = NAN; 378 if (binCore == 0) { 379 scale = (core - binCore + 0) * (PS1_V1_Scale[binCore + 1] - PS1_V1_Scale[binCore + 0]) + PS1_V1_Scale[binCore + 0]; 380 } else { 381 scale = (core - binCore - 1) * (PS1_V1_Scale[binCore + 0] - PS1_V1_Scale[binCore - 1]) + PS1_V1_Scale[binCore - 1]; 382 } 383 384 return (scale * sigma); 385 } 386 338 387 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf) 339 388 { 340 341 389 psF32 *out = modelPSF->params->data.F32; 342 390 psF32 *in = modelFLT->params->data.F32; … … 357 405 // the 2D PSF model fits polarization terms (E0,E1,E2) 358 406 // convert to shape terms (SXX,SYY,SXY) 359 bool useReff = pmModelUseReff (modelPSF->type);407 bool useReff = modelPSF->class->useReff; 360 408 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 361 409 psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); … … 411 459 // convert to shape terms (SXX,SYY,SXY) 412 460 // XXX user-defined value for limit? 413 bool useReff = pmModelUseReff (model->type);461 bool useReff = model->class->useReff; 414 462 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 415 463 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_PS1_V1.h
r35560 r37403 8 8 psF64 pmModelFlux_PS1_V1(const psVector *params); 9 9 psF64 pmModelRadius_PS1_V1(const psVector *params, psF64 flux); 10 psF64 pmModelSetFWHM_PS1_V1(const psVector *params, psF64 flux); 10 11 bool pmModelFromPSF_PS1_V1(pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf); 11 12 bool pmModelParamsFromPSF_PS1_V1(pmModel *model, const pmPSF *psf, float Xo, float Yo, float Io); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_QGAUSS.c
r36680 r37403 35 35 #include "pmMoments.h" 36 36 #include "pmModelFuncs.h" 37 #include "pmModelClass.h" 37 38 #include "pmModel.h" 38 39 #include "pmModelUtils.h" 39 #include "pmModelClass.h"40 40 #include "pmSourceMasks.h" 41 41 #include "pmSourceExtendedPars.h" … … 57 57 # define PM_MODEL_LIMITS pmModelLimits_QGAUSS 58 58 # define PM_MODEL_RADIUS pmModelRadius_QGAUSS 59 # define PM_MODEL_SET_FWHM pmModelSetFWHM_QGAUSS 59 60 # define PM_MODEL_FROM_PSF pmModelFromPSF_QGAUSS 60 61 # define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_QGAUSS … … 337 338 } 338 339 340 // I used the script in models/fwhm.sh to generate the trend of FWHM scaling vs the K value 341 // FWHM = Scale * Sigma (not that PAR[PM_PAR_SXX] = sigma * sqrt(2) 342 // K : z_hm : FWHM 343 // 0 : 1.000 : 2.83 344 // 1 : 0.648 : 2.28 345 // 2 : 0.430 : 1.85 346 // 3 : 0.310 : 1.58 347 // 4 : 0.244 : 1.40 348 // 5 : 0.200 : 1.26 349 // 6 : 0.165 : 1.15 350 // 7 : 0.149 : 1.09 351 // 8 : 0.125 : 1.00 352 // 9 : 0.116 : 0.96 353 // 10 : 0.101 : 0.90 354 // 11 : 0.095 : 0.87 355 // 12 : 0.083 : 0.82 356 // 13 : 0.082 : 0.81 357 // 14 : 0.080 : 0.80 358 // 15 : 0.074 : 0.77 359 // 16 : 0.064 : 0.71 360 // 17 : 0.068 : 0.74 361 // 18 : 0.057 : 0.67 362 // 19 : 0.058 : 0.68 363 364 // static float QGAUSS_Core[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0}; 365 static float QGAUSS_Scale[] = {2.83, 2.28, 1.85, 1.58, 1.40, 1.26, 1.15, 1.09, 1.00, 0.96, 0.90, 0.87, 0.82, 0.81, 0.80, 0.77, 0.71, 0.74, 0.67, 0.68}; 366 367 psF64 PM_MODEL_SET_FWHM (const psVector *params, psF64 sigma) { 368 369 psF32 *PAR = params->data.F32; 370 371 float core = PAR[PM_PAR_7]; 372 373 if (!isfinite(core)) return (2.0*M_SQRT2*sigma); 374 375 // QGAUSS_Core is defined as a set of integer steps, so we can simplify: 376 int binCore = MAX(0, MIN (19, (int)core)); 377 378 float scale = NAN; 379 if (binCore == 0) { 380 scale = (core - binCore + 0) * (QGAUSS_Scale[binCore + 1] - QGAUSS_Scale[binCore + 0]) + QGAUSS_Scale[binCore + 0]; 381 } else { 382 scale = (core - binCore - 1) * (QGAUSS_Scale[binCore + 0] - QGAUSS_Scale[binCore - 1]) + QGAUSS_Scale[binCore - 1]; 383 } 384 385 return (scale * sigma); 386 } 387 339 388 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf) 340 389 { … … 358 407 // the 2D PSF model fits polarization terms (E0,E1,E2) 359 408 // convert to shape terms (SXX,SYY,SXY) 360 bool useReff = pmModelUseReff (modelPSF->type);409 bool useReff = modelPSF->class->useReff; 361 410 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 362 411 psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); … … 416 465 // the 2D PSF model fits polarization terms (E0,E1,E2) 417 466 // convert to shape terms (SXX,SYY,SXY) 418 bool useReff = pmModelUseReff (model->type);467 bool useReff = model->class->useReff; 419 468 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 420 469 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_QGAUSS.h
r35560 r37403 8 8 psF64 pmModelFlux_QGAUSS(const psVector *params); 9 9 psF64 pmModelRadius_QGAUSS(const psVector *params, psF64 flux); 10 psF64 pmModelSetFWHM_QGAUSS(const psVector *params, psF64 flux); 10 11 bool pmModelFromPSF_QGAUSS(pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf); 11 12 bool pmModelParamsFromPSF_QGAUSS(pmModel *model, const pmPSF *psf, float Xo, float Yo, float Io); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_RGAUSS.c
r36680 r37403 34 34 #include "pmMoments.h" 35 35 #include "pmModelFuncs.h" 36 #include "pmModelClass.h" 36 37 #include "pmModel.h" 37 38 #include "pmModelUtils.h" 38 #include "pmModelClass.h"39 39 #include "pmSourceMasks.h" 40 40 #include "pmSourceExtendedPars.h" … … 56 56 # define PM_MODEL_LIMITS pmModelLimits_RGAUSS 57 57 # define PM_MODEL_RADIUS pmModelRadius_RGAUSS 58 # define PM_MODEL_SET_FWHM pmModelSetFWHM_RGAUSS 58 59 # define PM_MODEL_FROM_PSF pmModelFromPSF_RGAUSS 59 60 # define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_RGAUSS … … 330 331 } 331 332 333 psF64 PM_MODEL_SET_FWHM (const psVector *params, psF64 sigma) { 334 return (NAN); 335 } 336 332 337 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf) 333 338 { … … 351 356 // the 2D PSF model fits polarization terms (E0,E1,E2) 352 357 // convert to shape terms (SXX,SYY,SXY) 353 bool useReff = pmModelUseReff (modelPSF->type);358 bool useReff = modelPSF->class->useReff; 354 359 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 355 360 psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); … … 404 409 // the 2D PSF model fits polarization terms (E0,E1,E2) 405 410 // convert to shape terms (SXX,SYY,SXY) 406 bool useReff = pmModelUseReff (model->type);411 bool useReff = model->class->useReff; 407 412 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 408 413 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_RGAUSS.h
r35560 r37403 8 8 psF64 pmModelFlux_RGAUSS(const psVector *params); 9 9 psF64 pmModelRadius_RGAUSS(const psVector *params, psF64 flux); 10 psF64 pmModelSetFWHM_RGAUSS(const psVector *params, psF64 flux); 10 11 bool pmModelFromPSF_RGAUSS(pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf); 11 12 bool pmModelParamsFromPSF_RGAUSS(pmModel *model, const pmPSF *psf, float Xo, float Yo, float Io); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_SERSIC.c
r36680 r37403 43 43 #include "pmMoments.h" 44 44 #include "pmModelFuncs.h" 45 #include "pmModelClass.h" 45 46 #include "pmModel.h" 46 47 #include "pmModelUtils.h" 47 #include "pmModelClass.h"48 48 #include "pmSourceMasks.h" 49 49 #include "pmSourceExtendedPars.h" … … 66 66 # define PM_MODEL_LIMITS pmModelLimits_SERSIC 67 67 # define PM_MODEL_RADIUS pmModelRadius_SERSIC 68 # define PM_MODEL_SET_FWHM pmModelSetFWHM_SERSIC 68 69 # define PM_MODEL_FROM_PSF pmModelFromPSF_SERSIC 69 70 # define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_SERSIC … … 124 125 if (radius <= 1.5) { 125 126 // Nsub ~ 10*index^2 + 1 126 psEllipseAxes axes = pmPSF_ModelToAxes(PAR, pmModelClassGetType ("PS_MODEL_SERSIC"));127 psEllipseAxes axes = pmPSF_ModelToAxes(PAR, true); // SERSIC model uses Reff 127 128 int Nsub = 2 * ((int)(6.0*Sindex / axes.minor)) + 1; 128 129 Nsub = PS_MIN (Nsub, 121); … … 357 358 } 358 359 360 psF64 PM_MODEL_SET_FWHM (const psVector *params, psF64 sigma) { 361 return (NAN); 362 } 363 359 364 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf) 360 365 { … … 378 383 // the 2D PSF model fits polarization terms (E0,E1,E2) 379 384 // convert to shape terms (SXX,SYY,SXY) 380 bool useReff = pmModelUseReff (modelPSF->type);385 bool useReff = modelPSF->class->useReff; 381 386 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 382 387 psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); … … 432 437 // convert to shape terms (SXX,SYY,SXY) 433 438 // XXX user-defined value for limit? 434 bool useReff = pmModelUseReff (model->type);439 bool useReff = model->class->useReff; 435 440 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 436 441 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_SERSIC.h
r35560 r37403 8 8 psF64 pmModelFlux_SERSIC(const psVector *params); 9 9 psF64 pmModelRadius_SERSIC(const psVector *params, psF64 flux); 10 psF64 pmModelSetFWHM_SERSIC(const psVector *params, psF64 flux); 10 11 bool pmModelFromPSF_SERSIC(pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf); 11 12 bool pmModelParamsFromPSF_SERSIC(pmModel *model, const pmPSF *psf, float Xo, float Yo, float Io); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_TRAIL.c
r36680 r37403 5 5 * The meaning of the parameters may thus vary depending on the specifics of the model. 6 6 * All models which are used as a PSF representations share a few parameters, for which # 7 #include "pmModelClass.h" 7 8 * define names are listed in pmModel.h: 8 9 … … 33 34 #include "pmMoments.h" 34 35 #include "pmModelFuncs.h" 36 #include "pmModelClass.h" 35 37 #include "pmModel.h" 36 38 #include "pmModelUtils.h" 37 #include "pmModelClass.h"38 39 #include "pmSourceMasks.h" 39 40 #include "pmSourceExtendedPars.h" … … 55 56 # define PM_MODEL_LIMITS pmModelLimits_TRAIL 56 57 # define PM_MODEL_RADIUS pmModelRadius_TRAIL 58 # define PM_MODEL_SET_FWHM pmModelSetFWHM_TRAIL 57 59 # define PM_MODEL_FROM_PSF pmModelFromPSF_TRAIL 58 60 # define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_TRAIL … … 352 354 353 355 psF32 *psfPAR = source->modelPSF->params->data.F32; 354 bool useReff = pmModelUseReff (source->modelPSF->type);356 bool useReff = source->modelPSF->class->useReff; 355 357 356 358 psEllipseAxes psfAxes; … … 413 415 // PAR_LENGTH is the unconvolved length. add a bit for safety 414 416 return (0.5*PAR[PM_PAR_LENGTH] + 2); 417 } 418 419 psF64 PM_MODEL_SET_FWHM (const psVector *params, psF64 sigma) { 420 return (NAN); 415 421 } 416 422 -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/models/pmModel_TRAIL.h
r35560 r37403 8 8 psF64 pmModelFlux_TRAIL(const psVector *params); 9 9 psF64 pmModelRadius_TRAIL(const psVector *params, psF64 flux); 10 psF64 pmModelSetFWHM_TRAIL(const psVector *params, psF64 flux); 10 11 bool pmModelFromPSF_TRAIL(pmModel *modelPSF, pmModel *modelFLT, const pmPSF *psf); 11 12 bool pmModelParamsFromPSF_TRAIL(pmModel *model, const pmPSF *psf, float Xo, float Yo, float Io); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmDetEff.c
r36680 r37403 17 17 #include "pmMoments.h" 18 18 #include "pmModelFuncs.h" 19 #include "pmModelClass.h" 19 20 #include "pmModel.h" 20 21 #include "pmModelUtils.h" 21 #include "pmModelClass.h"22 22 #include "pmSourceMasks.h" 23 23 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmGrowthCurve.c
r36680 r37403 30 30 #include "pmMoments.h" 31 31 #include "pmModelFuncs.h" 32 #include "pmModelClass.h" 32 33 #include "pmModel.h" 33 34 #include "pmModelUtils.h" 34 #include "pmModelClass.h"35 35 #include "pmSourceMasks.h" 36 36 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmGrowthCurveGenerate.c
r36680 r37403 37 37 #include "pmMoments.h" 38 38 #include "pmModelFuncs.h" 39 #include "pmModelClass.h" 39 40 #include "pmModel.h" 40 41 #include "pmModelUtils.h" 41 #include "pmModelClass.h"42 42 #include "pmSourceMasks.h" 43 43 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmModel.c
r36680 r37403 33 33 #include "pmMoments.h" 34 34 #include "pmModelFuncs.h" 35 #include "pmModelClass.h" 35 36 #include "pmModel.h" 36 #include "pmModelClass.h"37 37 38 38 static void modelFree(pmModel *tmp) 39 39 { 40 40 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 41 if (!tmp) return; 42 41 43 psFree(tmp->params); 42 44 psFree(tmp->dparams); … … 90 92 } 91 93 92 tmp->modelFunc = class->modelFunc; 93 tmp->modelFlux = class->modelFlux; 94 tmp->modelRadius = class->modelRadius; 95 tmp->modelLimits = class->modelLimits; 96 tmp->modelGuess = class->modelGuess; 97 tmp->modelFromPSF = class->modelFromPSF; 98 tmp->modelParamsFromPSF = class->modelParamsFromPSF; 99 tmp->modelFitStatus = class->modelFitStatus; 100 tmp->modelSetLimits = class->modelSetLimits; 94 tmp->class = class; 95 96 // tmp->modelFunc = class->modelFunc; 97 // tmp->modelFlux = class->modelFlux; 98 // tmp->modelRadius = class->modelRadius; 99 // tmp->modelLimits = class->modelLimits; 100 // tmp->modelGuess = class->modelGuess; 101 // tmp->modelFromPSF = class->modelFromPSF; 102 // tmp->modelParamsFromPSF = class->modelParamsFromPSF; 103 // tmp->modelFitStatus = class->modelFitStatus; 104 // tmp->modelSetLimits = class->modelSetLimits; 101 105 102 106 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); … … 156 160 psF32 tmpF; 157 161 158 tmpF = model-> modelFunc (NULL, model->params, x);162 tmpF = model->class->modelFunc (NULL, model->params, x); 159 163 psFree(x); 160 164 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); … … 176 180 psF32 tmpF; 177 181 178 tmpF = model-> modelFunc (NULL, model->params, x);182 tmpF = model->class->modelFunc (NULL, model->params, x); 179 183 psFree(x); 180 184 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); … … 283 287 // add in the desired components for this coordinate 284 288 if (mode & PM_MODEL_OP_FUNC) { 285 pixelValue += model-> modelFunc (NULL, params, x);289 pixelValue += model->class->modelFunc (NULL, params, x); 286 290 } 287 291 -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmModel.h
r31153 r37403 47 47 bool isPCM; ///< is this model fitted with PSF-convolution? 48 48 49 pmModelClass *class; 50 49 51 // functions for this model which depend on the model class 50 pmModelFunc modelFunc; 51 pmModelFlux modelFlux; 52 pmModelRadius modelRadius; 53 pmModelLimits modelLimits; 54 pmModelGuessFunc modelGuess; 55 pmModelFromPSFFunc modelFromPSF; 56 pmModelParamsFromPSF modelParamsFromPSF; 57 pmModelFitStatusFunc modelFitStatus; 58 pmModelSetLimitsFunc modelSetLimits; 52 53 // pmModelFunc modelFunc; 54 // pmModelFlux modelFlux; 55 // pmModelRadius modelRadius; 56 // pmModelLimits modelLimits; 57 // pmModelGuessFunc modelGuess; 58 // pmModelFromPSFFunc modelFromPSF; 59 // pmModelParamsFromPSF modelParamsFromPSF; 60 // pmModelFitStatusFunc modelFitStatus; 61 // pmModelSetLimitsFunc modelSetLimits; 59 62 }; 60 63 -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmModelClass.c
r36680 r37403 33 33 #include "pmMoments.h" 34 34 #include "pmModelFuncs.h" 35 #include "pmModelClass.h" 35 36 #include "pmModel.h" 36 37 #include "pmModelUtils.h" 37 #include "pmModelClass.h"38 38 39 39 #include "pmErrorCodes.h" … … 54 54 55 55 static pmModelClass defaultModels[] = { 56 {"PS_MODEL_GAUSS", 7, (pmModelFunc)pmModelFunc_GAUSS, (pmModelFlux)pmModelFlux_GAUSS, (pmModelRadius)pmModelRadius_GAUSS, (pmModelLimits)pmModelLimits_GAUSS, (pmModelGuessFunc)pmModelGuess_GAUSS, (pmModelFromPSFFunc)pmModelFromPSF_GAUSS, (pmModelParamsFromPSF)pmModelParamsFromPSF_GAUSS, (pmModelFitStatusFunc)pmModelFitStatus_GAUSS, (pmModelSetLimitsFunc)pmModelSetLimits_GAUSS },57 {"PS_MODEL_PGAUSS", 7, (pmModelFunc)pmModelFunc_PGAUSS, (pmModelFlux)pmModelFlux_PGAUSS, (pmModelRadius)pmModelRadius_PGAUSS, (pmModelLimits)pmModelLimits_PGAUSS, (pmModelGuessFunc)pmModelGuess_PGAUSS, (pmModelFromPSFFunc)pmModelFromPSF_PGAUSS, (pmModelParamsFromPSF)pmModelParamsFromPSF_PGAUSS, (pmModelFitStatusFunc)pmModelFitStatus_PGAUSS, (pmModelSetLimitsFunc)pmModelSetLimits_PGAUSS },58 {"PS_MODEL_QGAUSS", 8, (pmModelFunc)pmModelFunc_QGAUSS, (pmModelFlux)pmModelFlux_QGAUSS, (pmModelRadius)pmModelRadius_QGAUSS, (pmModelLimits)pmModelLimits_QGAUSS, (pmModelGuessFunc)pmModelGuess_QGAUSS, (pmModelFromPSFFunc)pmModelFromPSF_QGAUSS, (pmModelParamsFromPSF)pmModelParamsFromPSF_QGAUSS, (pmModelFitStatusFunc)pmModelFitStatus_QGAUSS, (pmModelSetLimitsFunc)pmModelSetLimits_QGAUSS },59 {"PS_MODEL_PS1_V1", 8, (pmModelFunc)pmModelFunc_PS1_V1, (pmModelFlux)pmModelFlux_PS1_V1, (pmModelRadius)pmModelRadius_PS1_V1, (pmModelLimits)pmModelLimits_PS1_V1, (pmModelGuessFunc)pmModelGuess_PS1_V1, (pmModelFromPSFFunc)pmModelFromPSF_PS1_V1, (pmModelParamsFromPSF)pmModelParamsFromPSF_PS1_V1, (pmModelFitStatusFunc)pmModelFitStatus_PS1_V1, (pmModelSetLimitsFunc)pmModelSetLimits_PS1_V1 },60 {"PS_MODEL_RGAUSS", 8, (pmModelFunc)pmModelFunc_RGAUSS, (pmModelFlux)pmModelFlux_RGAUSS, (pmModelRadius)pmModelRadius_RGAUSS, (pmModelLimits)pmModelLimits_RGAUSS, (pmModelGuessFunc)pmModelGuess_RGAUSS, (pmModelFromPSFFunc)pmModelFromPSF_RGAUSS, (pmModelParamsFromPSF)pmModelParamsFromPSF_RGAUSS, (pmModelFitStatusFunc)pmModelFitStatus_RGAUSS, (pmModelSetLimitsFunc)pmModelSetLimits_RGAUSS },61 {"PS_MODEL_SERSIC", 8, (pmModelFunc)pmModelFunc_SERSIC, (pmModelFlux)pmModelFlux_SERSIC, (pmModelRadius)pmModelRadius_SERSIC, (pmModelLimits)pmModelLimits_SERSIC, (pmModelGuessFunc)pmModelGuess_SERSIC, (pmModelFromPSFFunc)pmModelFromPSF_SERSIC, (pmModelParamsFromPSF)pmModelParamsFromPSF_SERSIC, (pmModelFitStatusFunc)pmModelFitStatus_SERSIC, (pmModelSetLimitsFunc)pmModelSetLimits_SERSIC },62 {"PS_MODEL_EXP", 7, (pmModelFunc)pmModelFunc_EXP, (pmModelFlux)pmModelFlux_EXP, (pmModelRadius)pmModelRadius_EXP, (pmModelLimits)pmModelLimits_EXP, (pmModelGuessFunc)pmModelGuess_EXP, (pmModelFromPSFFunc)pmModelFromPSF_EXP, (pmModelParamsFromPSF)pmModelParamsFromPSF_EXP, (pmModelFitStatusFunc)pmModelFitStatus_EXP, (pmModelSetLimitsFunc)pmModelSetLimits_EXP },63 {"PS_MODEL_DEV", 7, (pmModelFunc)pmModelFunc_DEV, (pmModelFlux)pmModelFlux_DEV, (pmModelRadius)pmModelRadius_DEV, (pmModelLimits)pmModelLimits_DEV, (pmModelGuessFunc)pmModelGuess_DEV, (pmModelFromPSFFunc)pmModelFromPSF_DEV, (pmModelParamsFromPSF)pmModelParamsFromPSF_DEV, (pmModelFitStatusFunc)pmModelFitStatus_DEV, (pmModelSetLimitsFunc)pmModelSetLimits_DEV },64 {"PS_MODEL_TRAIL", 7, (pmModelFunc)pmModelFunc_TRAIL, (pmModelFlux)pmModelFlux_TRAIL, (pmModelRadius)pmModelRadius_TRAIL, (pmModelLimits)pmModelLimits_TRAIL, (pmModelGuessFunc)pmModelGuess_TRAIL, (pmModelFromPSFFunc)pmModelFromPSF_TRAIL, (pmModelParamsFromPSF)pmModelParamsFromPSF_TRAIL, (pmModelFitStatusFunc)pmModelFitStatus_TRAIL, (pmModelSetLimitsFunc)pmModelSetLimits_TRAIL },56 {"PS_MODEL_GAUSS", 7, 0, (pmModelFunc)pmModelFunc_GAUSS, (pmModelFlux)pmModelFlux_GAUSS, (pmModelRadius)pmModelRadius_GAUSS, (pmModelSetFWHM)pmModelSetFWHM_GAUSS, (pmModelLimits)pmModelLimits_GAUSS, (pmModelGuessFunc)pmModelGuess_GAUSS, (pmModelFromPSFFunc)pmModelFromPSF_GAUSS, (pmModelParamsFromPSF)pmModelParamsFromPSF_GAUSS, (pmModelFitStatusFunc)pmModelFitStatus_GAUSS, (pmModelSetLimitsFunc)pmModelSetLimits_GAUSS }, 57 {"PS_MODEL_PGAUSS", 7, 0, (pmModelFunc)pmModelFunc_PGAUSS, (pmModelFlux)pmModelFlux_PGAUSS, (pmModelRadius)pmModelRadius_PGAUSS, (pmModelSetFWHM)pmModelSetFWHM_PGAUSS, (pmModelLimits)pmModelLimits_PGAUSS, (pmModelGuessFunc)pmModelGuess_PGAUSS, (pmModelFromPSFFunc)pmModelFromPSF_PGAUSS, (pmModelParamsFromPSF)pmModelParamsFromPSF_PGAUSS, (pmModelFitStatusFunc)pmModelFitStatus_PGAUSS, (pmModelSetLimitsFunc)pmModelSetLimits_PGAUSS }, 58 {"PS_MODEL_QGAUSS", 8, 0, (pmModelFunc)pmModelFunc_QGAUSS, (pmModelFlux)pmModelFlux_QGAUSS, (pmModelRadius)pmModelRadius_QGAUSS, (pmModelSetFWHM)pmModelSetFWHM_QGAUSS, (pmModelLimits)pmModelLimits_QGAUSS, (pmModelGuessFunc)pmModelGuess_QGAUSS, (pmModelFromPSFFunc)pmModelFromPSF_QGAUSS, (pmModelParamsFromPSF)pmModelParamsFromPSF_QGAUSS, (pmModelFitStatusFunc)pmModelFitStatus_QGAUSS, (pmModelSetLimitsFunc)pmModelSetLimits_QGAUSS }, 59 {"PS_MODEL_PS1_V1", 8, 0, (pmModelFunc)pmModelFunc_PS1_V1, (pmModelFlux)pmModelFlux_PS1_V1, (pmModelRadius)pmModelRadius_PS1_V1, (pmModelSetFWHM)pmModelSetFWHM_PS1_V1, (pmModelLimits)pmModelLimits_PS1_V1, (pmModelGuessFunc)pmModelGuess_PS1_V1, (pmModelFromPSFFunc)pmModelFromPSF_PS1_V1, (pmModelParamsFromPSF)pmModelParamsFromPSF_PS1_V1, (pmModelFitStatusFunc)pmModelFitStatus_PS1_V1, (pmModelSetLimitsFunc)pmModelSetLimits_PS1_V1 }, 60 {"PS_MODEL_RGAUSS", 8, 0, (pmModelFunc)pmModelFunc_RGAUSS, (pmModelFlux)pmModelFlux_RGAUSS, (pmModelRadius)pmModelRadius_RGAUSS, (pmModelSetFWHM)pmModelSetFWHM_RGAUSS, (pmModelLimits)pmModelLimits_RGAUSS, (pmModelGuessFunc)pmModelGuess_RGAUSS, (pmModelFromPSFFunc)pmModelFromPSF_RGAUSS, (pmModelParamsFromPSF)pmModelParamsFromPSF_RGAUSS, (pmModelFitStatusFunc)pmModelFitStatus_RGAUSS, (pmModelSetLimitsFunc)pmModelSetLimits_RGAUSS }, 61 {"PS_MODEL_SERSIC", 8, 1, (pmModelFunc)pmModelFunc_SERSIC, (pmModelFlux)pmModelFlux_SERSIC, (pmModelRadius)pmModelRadius_SERSIC, (pmModelSetFWHM)pmModelSetFWHM_SERSIC, (pmModelLimits)pmModelLimits_SERSIC, (pmModelGuessFunc)pmModelGuess_SERSIC, (pmModelFromPSFFunc)pmModelFromPSF_SERSIC, (pmModelParamsFromPSF)pmModelParamsFromPSF_SERSIC, (pmModelFitStatusFunc)pmModelFitStatus_SERSIC, (pmModelSetLimitsFunc)pmModelSetLimits_SERSIC }, 62 {"PS_MODEL_EXP", 7, 1, (pmModelFunc)pmModelFunc_EXP, (pmModelFlux)pmModelFlux_EXP, (pmModelRadius)pmModelRadius_EXP, (pmModelSetFWHM)pmModelSetFWHM_EXP, (pmModelLimits)pmModelLimits_EXP, (pmModelGuessFunc)pmModelGuess_EXP, (pmModelFromPSFFunc)pmModelFromPSF_EXP, (pmModelParamsFromPSF)pmModelParamsFromPSF_EXP, (pmModelFitStatusFunc)pmModelFitStatus_EXP, (pmModelSetLimitsFunc)pmModelSetLimits_EXP }, 63 {"PS_MODEL_DEV", 7, 1, (pmModelFunc)pmModelFunc_DEV, (pmModelFlux)pmModelFlux_DEV, (pmModelRadius)pmModelRadius_DEV, (pmModelSetFWHM)pmModelSetFWHM_DEV, (pmModelLimits)pmModelLimits_DEV, (pmModelGuessFunc)pmModelGuess_DEV, (pmModelFromPSFFunc)pmModelFromPSF_DEV, (pmModelParamsFromPSF)pmModelParamsFromPSF_DEV, (pmModelFitStatusFunc)pmModelFitStatus_DEV, (pmModelSetLimitsFunc)pmModelSetLimits_DEV }, 64 {"PS_MODEL_TRAIL", 7, 0, (pmModelFunc)pmModelFunc_TRAIL, (pmModelFlux)pmModelFlux_TRAIL, (pmModelRadius)pmModelRadius_TRAIL, (pmModelSetFWHM)pmModelSetFWHM_TRAIL, (pmModelLimits)pmModelLimits_TRAIL, (pmModelGuessFunc)pmModelGuess_TRAIL, (pmModelFromPSFFunc)pmModelFromPSF_TRAIL, (pmModelParamsFromPSF)pmModelParamsFromPSF_TRAIL, (pmModelFitStatusFunc)pmModelFitStatus_TRAIL, (pmModelSetLimitsFunc)pmModelSetLimits_TRAIL }, 65 65 }; 66 66 -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmModelClass.h
r36680 r37403 35 35 char *name; 36 36 int nParams; 37 bool useReff; 37 38 pmModelFunc modelFunc; 38 39 pmModelFlux modelFlux; 39 40 pmModelRadius modelRadius; 41 pmModelSetFWHM modelSetFWHM; 40 42 pmModelLimits modelLimits; 41 43 pmModelGuessFunc modelGuess; -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmModelFuncs.h
r36680 r37403 110 110 typedef psF64 (*pmModelRadius)(const psVector *params, double flux); 111 111 112 // This function returns the FWHM given the supplied sigma (major or minor) 113 typedef psF64 (*pmModelSetFWHM)(const psVector *params, double sigma); 114 112 115 // This function provides the model guess parameters based on the details of 113 116 // the given source. -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmModelUtils.c
r36680 r37403 32 32 #include "pmMoments.h" 33 33 #include "pmModelFuncs.h" 34 #include "pmModelClass.h" 34 35 #include "pmModel.h" 35 36 #include "pmModelUtils.h" 36 #include "pmModelClass.h"37 37 #include "pmSourceMasks.h" 38 38 #include "pmSourceExtendedPars.h" … … 46 46 #include "pmErrorCodes.h" 47 47 48 // XX static bool useModelVar = false;49 // XX50 // XX void pmModelSetModelVarOption (bool option) {51 // XX useModelVar = option;52 // XX }53 // XX bool pmModelGetModelVarOption (void) {54 // XX return useModelVar;55 // XX }56 57 48 /***************************************************************************** 58 49 pmModelFromPSF (*modelEXT, *psf): use the model position parameters to … … 68 59 69 60 // set model parameters for this source based on PSF information 70 if (!modelEXT-> modelFromPSF (modelPSF, modelEXT, psf)) {61 if (!modelEXT->class->modelFromPSF (modelPSF, modelEXT, psf)) { 71 62 psTrace ("psModules.objects", 3, "Failed to set model params from PSF"); 72 63 psFree(modelPSF); … … 89 80 90 81 // set model parameters for this source based on PSF information 91 if (!modelPSF-> modelParamsFromPSF (modelPSF, psf, Xo, Yo, Io)) {82 if (!modelPSF->class->modelParamsFromPSF (modelPSF, psf, Xo, Yo, Io)) { 92 83 psFree(modelPSF); 93 84 return NULL; … … 109 100 110 101 // determine the normalized flux 111 float normFlux = model-> modelFlux (model->params);102 float normFlux = model->class->modelFlux (model->params); 112 103 assert (isfinite(normFlux)); 113 104 assert (normFlux > 0); … … 120 111 121 112 bool pmModelUseReff (pmModelType type) { 122 bool useReff = false; 123 useReff |= (type == pmModelClassGetType ("PS_MODEL_SERSIC"));124 useReff |= (type == pmModelClassGetType ("PS_MODEL_DEV"));125 useReff |= (type == pmModelClassGetType ("PS_MODEL_EXP"));113 114 pmModelClass *class = pmModelClassSelect (type); 115 psAssert (class, "undefined model class?"); 116 bool useReff = class->useReff; 126 117 return useReff; 127 118 } -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmPCM_MinimizeChisq.c
r36680 r37403 31 31 #include "pmMoments.h" 32 32 #include "pmModelFuncs.h" 33 #include "pmModelClass.h" 33 34 #include "pmModel.h" 34 35 #include "pmModelUtils.h" 35 #include "pmModelClass.h"36 36 #include "pmSourceMasks.h" 37 37 #include "pmSourceExtendedPars.h" … … 455 455 coord->data.F32[1] = (psF32) (i + 0.5 + source->pixels->row0); 456 456 457 pcm->modelFlux->data.F32[i][j] = pcm->modelConv-> modelFunc (deriv, params, coord);457 pcm->modelFlux->data.F32[i][j] = pcm->modelConv->class->modelFunc (deriv, params, coord); 458 458 459 459 for (int n = 0; n < params->n; n++) { -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmPCMdata.c
r36680 r37403 31 31 #include "pmMoments.h" 32 32 #include "pmModelFuncs.h" 33 #include "pmModelClass.h" 33 34 #include "pmModel.h" 34 35 #include "pmModelUtils.h" 35 #include "pmModelClass.h"36 36 #include "pmSourceMasks.h" 37 37 #include "pmSourceExtendedPars.h" … … 293 293 294 294 psEllipseAxes axes; 295 bool useReff = pmModelUseReff (modelPSF->type);295 bool useReff = modelPSF->class->useReff; 296 296 psF32 *PAR = modelPSF->params->data.F32; 297 297 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], useReff); … … 302 302 // XXX need to do this more carefully 303 303 if (modelPSF->type == modelType_GAUSS) { 304 float FWHM_MAJOR = 2*modelPSF-> modelRadius (modelPSF->params, 0.5*PAR[PM_PAR_I0]);304 float FWHM_MAJOR = 2*modelPSF->class->modelRadius (modelPSF->params, 0.5*PAR[PM_PAR_I0]); 305 305 float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major); 306 306 *sigma = 0.50 * (FWHM_MAJOR + FWHM_MINOR) / 2.35; … … 330 330 331 331 psEllipseAxes axes; 332 bool useReff = pmModelUseReff (modelPSF->type);332 bool useReff = modelPSF->class->useReff; 333 333 psF32 *PAR = modelPSF->params->data.F32; 334 334 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], useReff); … … 339 339 // XXX need to do this more carefully 340 340 if (modelPSF->type == modelType_GAUSS) { 341 float FWHM_MAJOR = 2*modelPSF-> modelRadius (modelPSF->params, 0.5*PAR[PM_PAR_I0]);341 float FWHM_MAJOR = 2*modelPSF->class->modelRadius (modelPSF->params, 0.5*PAR[PM_PAR_I0]); 342 342 float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major); 343 343 *sigma = 0.50 * (FWHM_MAJOR + FWHM_MINOR) / 2.35; … … 393 393 psMinConstraint *constraint = psMinConstraintAlloc(); 394 394 constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_VECTOR_MASK); 395 constraint->checkLimits = model-> modelLimits;395 constraint->checkLimits = model->class->modelLimits; 396 396 397 397 int nParams = pmPCMsetParams (constraint, fitOptions->mode); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmPSF.c
r36680 r37403 37 37 #include "pmMoments.h" 38 38 #include "pmModelFuncs.h" 39 #include "pmModelClass.h" 39 40 #include "pmModel.h" 40 41 #include "pmModelUtils.h" 41 #include "pmModelClass.h"42 42 #include "pmSourceMasks.h" 43 43 #include "pmSourceExtendedPars.h" … … 329 329 // convert the parameters used in the fitted source model to the psEllipseAxes representation 330 330 // (major,minor,theta) 331 psEllipseAxes pmPSF_ModelToAxes (psF32 *modelPar, pmModelType type)331 psEllipseAxes pmPSF_ModelToAxes (psF32 *modelPar, bool useReff) 332 332 { 333 333 psEllipseAxes axes; … … 338 338 PS_ASSERT_PTR_NON_NULL(modelPar, axes); 339 339 340 bool useReff = pmModelUseReff (type);341 340 pmModelParamsToAxes (&axes, modelPar[PM_PAR_SXX], modelPar[PM_PAR_SXY], modelPar[PM_PAR_SYY], useReff); 342 341 return axes; … … 345 344 // convert the psEllipseAxes representation (major,minor,theta) to the parameters used in the 346 345 // fitted source model 347 bool pmPSF_AxesToModel (psF32 *modelPar, psEllipseAxes axes, pmModelType type)346 bool pmPSF_AxesToModel (psF32 *modelPar, psEllipseAxes axes, bool useReff) 348 347 { 349 348 PS_ASSERT_PTR_NON_NULL(modelPar, false); … … 357 356 } 358 357 359 bool useReff = pmModelUseReff (type);360 358 pmModelAxesToParams (&modelPar[PM_PAR_SXX], &modelPar[PM_PAR_SXY], &modelPar[PM_PAR_SYY], axes, useReff); 361 359 return true; … … 420 418 421 419 // get the model full-width at half-max 422 float fwhmMajor = 2*model-> modelRadius (model->params, 0.5);420 float fwhmMajor = 2*model->class->modelRadius (model->params, 0.5); 423 421 424 422 # if (0) 425 423 psF32 *params = model->params->data.F32; // Model parameters 426 psEllipseAxes axes = pmPSF_ModelToAxes(params, MAX_AXIS_RATIO, model-> type); // Ellipse axes424 psEllipseAxes axes = pmPSF_ModelToAxes(params, MAX_AXIS_RATIO, model->class->useReff); // Ellipse axes 427 425 428 426 // Curiously, the minor axis can be larger than the major axis, so need to check. -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmPSF.h
r35768 r37403 106 106 pmPSF *pmPSFBuildSimple (char *typeName, float sxx, float syy, float sxy, ...); 107 107 108 bool pmPSF_AxesToModel (psF32 *modelPar, psEllipseAxes axes, pmModelType type);108 bool pmPSF_AxesToModel (psF32 *modelPar, psEllipseAxes axes, bool useReff); 109 109 bool pmPSF_FitToModel (psF32 *fittedPar, float minMinorAxis, bool useReff); 110 110 111 111 psEllipsePol pmPSF_ModelToFit (psF32 *modelPar, bool useReff); 112 psEllipseAxes pmPSF_ModelToAxes (psF32 *modelPar, pmModelType type);112 psEllipseAxes pmPSF_ModelToAxes (psF32 *modelPar, bool useReff); 113 113 114 114 /// Calculate FWHM value from a PSF -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmPSF_IO.c
r36680 r37403 47 47 #include "pmMoments.h" 48 48 #include "pmModelFuncs.h" 49 #include "pmModelClass.h" 49 50 #include "pmModel.h" 50 51 #include "pmModelUtils.h" 51 #include "pmModelClass.h"52 52 #include "pmSourceMasks.h" 53 53 #include "pmSourceExtendedPars.h" … … 511 511 psMetadataAddF32 (header, PS_LIST_TAIL, "SKY_BIAS", PS_DATA_F32, "sky bias level", psf->skyBias); 512 512 513 float PSF_APERTURE = psMetadataLookupF32(&status, roAnalysis, "PSF_APERTURE"); 514 if (status) { 513 if (roAnalysis) { 514 float PSF_APERTURE = psMetadataLookupF32(&status, roAnalysis, "PSF_APERTURE"); 515 if (status) { 515 516 psMetadataAddF32 (header, PS_LIST_TAIL, "PSF_APERTURE", PS_DATA_F32, "aperture for psf objects", PSF_APERTURE); 516 }517 float PSF_FIT_RADIUS = psMetadataLookupF32(&status, roAnalysis, "PSF_FIT_RADIUS");518 if (status) {517 } 518 float PSF_FIT_RADIUS = psMetadataLookupF32(&status, roAnalysis, "PSF_FIT_RADIUS"); 519 if (status) { 519 520 psMetadataAddF32 (header, PS_LIST_TAIL, "PSF_FIT_RADIUS", PS_DATA_F32, "aperture for psf objects", PSF_FIT_RADIUS); 521 } 520 522 } 521 523 -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmPSFtry.c
r36680 r37403 29 29 #include "pmMoments.h" 30 30 #include "pmModelFuncs.h" 31 #include "pmModelClass.h" 31 32 #include "pmModel.h" 32 33 #include "pmModelUtils.h" 33 #include "pmModelClass.h"34 34 #include "pmSourceMasks.h" 35 35 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmPSFtryFitEXT.c
r36680 r37403 29 29 #include "pmMoments.h" 30 30 #include "pmModelFuncs.h" 31 #include "pmModelClass.h" 31 32 #include "pmModel.h" 32 33 #include "pmModelUtils.h" 33 #include "pmModelClass.h"34 34 #include "pmSourceMasks.h" 35 35 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmPSFtryFitPSF.c
r36680 r37403 27 27 #include "pmMoments.h" 28 28 #include "pmModelFuncs.h" 29 #include "pmModelClass.h" 29 30 #include "pmModel.h" 30 31 #include "pmModelUtils.h" 31 #include "pmModelClass.h"32 32 #include "pmSourceMasks.h" 33 33 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmPSFtryMakePSF.c
r36680 r37403 28 28 #include "pmMoments.h" 29 29 #include "pmModelFuncs.h" 30 #include "pmModelClass.h" 30 31 #include "pmModel.h" 31 32 #include "pmModelUtils.h" 32 #include "pmModelClass.h"33 33 #include "pmSourceMasks.h" 34 34 #include "pmSourceExtendedPars.h" … … 212 212 assert (source->modelEXT); // all unmasked sources should have modelEXT 213 213 214 bool useReff = pmModelUseReff (source->modelEXT->type);214 bool useReff = source->modelEXT->class->useReff; 215 215 psEllipsePol pol = pmPSF_ModelToFit (source->modelEXT->params->data.F32, useReff); 216 216 … … 218 218 e1->data.F32[i] = pol.e1; 219 219 e2->data.F32[i] = pol.e2; 220 } 221 222 // weed out extreme e0 outliers here: find the median and exclude points not in the 223 // range MEDIAN / 5 < e0 < 5 * MEDIAN 224 { 225 psStats *e0stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN); 226 if (psVectorStats (e0stats, e0, NULL, srcMask, 0xff)) { 227 float e0med = e0stats->sampleMedian; 228 229 for (int i = 0; i < sources->n; i++) { 230 // skip any masked sources (failed to fit one of the model steps or get a magnitude) 231 if (srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 232 233 if (e0->data.F32[i] < 0.2*e0med) { 234 srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_OUTLIER; 235 } 236 if (e0->data.F32[i] > 5.0*e0med) { 237 srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_OUTLIER; 238 } 239 } 240 } 241 psFree (e0stats); 220 242 } 221 243 -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmPSFtryMetric.c
r36680 r37403 28 28 #include "pmMoments.h" 29 29 #include "pmModelFuncs.h" 30 #include "pmModelClass.h" 30 31 #include "pmModel.h" 31 32 #include "pmModelUtils.h" 32 #include "pmModelClass.h"33 33 #include "pmSourceMasks.h" 34 34 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmPSFtryModel.c
r36680 r37403 29 29 #include "pmMoments.h" 30 30 #include "pmModelFuncs.h" 31 #include "pmModelClass.h" 31 32 #include "pmModel.h" 32 33 #include "pmModelUtils.h" 33 #include "pmModelClass.h"34 34 #include "pmSourceMasks.h" 35 35 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmPhotObj.c
r36680 r37403 29 29 #include "pmMoments.h" 30 30 #include "pmModelFuncs.h" 31 #include "pmModelClass.h" 31 32 #include "pmModel.h" 32 33 #include "pmModelUtils.h" 33 #include "pmModelClass.h"34 34 #include "pmSourceMasks.h" 35 35 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSource.c
r36680 r37403 33 33 #include "pmMoments.h" 34 34 #include "pmModelFuncs.h" 35 #include "pmModelClass.h" 35 36 #include "pmModel.h" 36 37 #include "pmModelUtils.h" 37 #include "pmModelClass.h"38 38 #include "pmSourceMasks.h" 39 39 #include "pmSourceExtendedPars.h" … … 146 146 source->apMagRaw = NAN; 147 147 source->apRadius = NAN; 148 source->apNpixels = 0; 148 149 source->apFlux = NAN; 149 150 source->apFluxErr = NAN; … … 162 163 source->sky = NAN; 163 164 source->skyErr = NAN; 165 source->extSN = NAN; 164 166 165 167 source->region = psRegionSet(NAN, NAN, NAN, NAN); … … 174 176 source->parent = NULL; 175 177 source->tmpPtr = NULL; 178 source->chipNum = -1; 179 source->chipX = -1000; 180 source->chipY = -1000; 176 181 source->imageID = -1; 177 182 source->nFrames = 0; … … 236 241 source->apMagRaw = in->apMagRaw; 237 242 source->apRadius = in->apRadius; 243 source->apNpixels = in->apNpixels; 238 244 source->apFlux = in->apFlux; 239 245 source->apFluxErr = in->apFluxErr; … … 986 992 if (!isfinite(oldI0)) return false; 987 993 988 bool useReff = pmModelUseReff (model->type);994 bool useReff = model->class->useReff; 989 995 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], useReff); 990 996 -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSource.h
r36680 r37403 97 97 float apMagRaw; ///< raw mag in given aperture 98 98 float apRadius; ///< radius for aperture magnitude 99 int apNpixels; ///< number of unmasked pixels in aperture 99 100 float apFlux; ///< apFlux corresponding to psfMag or extMag (depending on type) 100 101 float apFluxErr; ///< apFluxErr corresponding to psfMag or extMag (depending on type) … … 113 114 float sky; ///< The sky at the center of the object 114 115 float skyErr; ///< The sky error at the center of the object 116 float extSN; ///< for externally supplied source the kron signal to noise (used by full force) 115 117 116 118 psRegion region; ///< area on image covered by selected pixels … … 119 121 pmSourceExtendedPars *extpars; ///< extended source parameters 120 122 pmSourceDiffStats *diffStats; ///< extra parameters for difference detections 121 p mSourceGalaxyFits *galaxyFits;///< fits to galaxy models (psphotFullForce only)123 psArray *galaxyFits; ///< fits to galaxy models (psphotFullForce only) 122 124 pmSourceLensing *lensingOBJ; ///< lensing moments parameters (per object) 123 125 pmSourceLensing *lensingPSF; ///< lensing moments parameters (psf, interpolated) … … 125 127 pmSource *parent; ///< reference to the master source from which this is derived 126 128 psPtr *tmpPtr; ///< pointer that may be used to store data in a particular module. e.g. psphotKronIterate. 129 short chipNum; ///< camera dependent of chip suppling pixels for fullforce source 130 short chipX; ///< chip space X coord of fullforce source 131 short chipY; ///< chip space Y coord of fullforce source 127 132 int imageID; 128 133 psU16 nFrames; -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceContour.c
r36680 r37403 33 33 #include "pmMoments.h" 34 34 #include "pmModelFuncs.h" 35 #include "pmModelClass.h" 35 36 #include "pmModel.h" 36 37 #include "pmModelUtils.h" 37 #include "pmModelClass.h"38 38 #include "pmSourceMasks.h" 39 39 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceExtendedPars.h
r36680 r37403 83 83 84 84 typedef struct { 85 int modelType; 85 86 psVector *Flux; 86 87 psVector *dFlux; 87 88 psVector *chisq; 88 int nPix; 89 int nPix; 90 bool reducedTrials; 91 float fRmajorMin; 92 float fRmajorMax; 93 float fRmajorDel; 94 float fRminorMin; 95 float fRminorMax; 96 float fRminorDel; 89 97 } pmSourceGalaxyFits; 90 98 -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceFitModel.c
r36680 r37403 33 33 #include "pmMoments.h" 34 34 #include "pmModelFuncs.h" 35 #include "pmModelClass.h" 35 36 #include "pmModel.h" 36 37 #include "pmModelUtils.h" 37 #include "pmModelClass.h"38 38 #include "pmSourceMasks.h" 39 39 #include "pmSourceExtendedPars.h" … … 170 170 psMinConstraint *constraint = psMinConstraintAlloc(); 171 171 constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_VECTOR_MASK); 172 constraint->checkLimits = model-> modelLimits;172 constraint->checkLimits = model->class->modelLimits; 173 173 174 174 // set parameter mask based on fitting mode … … 233 233 // force the floating parameters to fall within the contraint ranges 234 234 for (int i = 0; i < params->n; i++) { 235 model-> modelLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL);236 model-> modelLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL);235 model->class->modelLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL); 236 model->class->modelLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL); 237 237 } 238 238 … … 254 254 psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32); 255 255 256 fitStatus = psMinimizeLMChi2(myMin, covar, params, constraint, x, y, yErr, model-> modelFunc);256 fitStatus = psMinimizeLMChi2(myMin, covar, params, constraint, x, y, yErr, model->class->modelFunc); 257 257 for (int i = 0; i < dparams->n; i++) { 258 258 if ((constraint->paramMask != NULL) && constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) … … 306 306 altmask->data.PS_TYPE_VECTOR_MASK_DATA[i] = (constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) ? 0 : 1; 307 307 } 308 psMinimizeGaussNewtonDelta(delta, params, altmask, x, y, yErr, model-> modelFunc);308 psMinimizeGaussNewtonDelta(delta, params, altmask, x, y, yErr, model->class->modelFunc); 309 309 310 310 for (int i = 0; i < dparams->n; i++) { -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceFitPCM.c
r36680 r37403 31 31 #include "pmMoments.h" 32 32 #include "pmModelFuncs.h" 33 #include "pmModelClass.h" 33 34 #include "pmModel.h" 34 35 #include "pmModelUtils.h" 35 #include "pmModelClass.h"36 36 #include "pmSourceMasks.h" 37 37 #include "pmSourceExtendedPars.h" … … 63 63 // force the floating parameters to fall within the contraint ranges 64 64 for (int i = 0; i < params->n; i++) { 65 pcm->modelConv-> modelLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL);66 pcm->modelConv-> modelLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL);65 pcm->modelConv->class->modelLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL); 66 pcm->modelConv->class->modelLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL); 67 67 } 68 68 … … 165 165 bool pmSourceModelGuessPCM (pmPCMdata *pcm, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) { 166 166 167 if (!pcm->modelConv-> modelGuess(pcm->modelConv, source, maskVal, markVal)) {167 if (!pcm->modelConv->class->modelGuess(pcm->modelConv, source, maskVal, markVal)) { 168 168 return false; 169 169 } -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceFitSet.c
r36680 r37403 32 32 #include "pmMoments.h" 33 33 #include "pmModelFuncs.h" 34 #include "pmModelClass.h" 34 35 #include "pmModel.h" 35 36 #include "pmModelUtils.h" 36 #include "pmModelClass.h"37 37 #include "pmSourceMasks.h" 38 38 #include "pmSourceExtendedPars.h" … … 223 223 float *paramOne = params + nParamBase; 224 224 float *betaOne = betas + nParamBase; 225 bool status = model-> modelLimits (mode, nParamOne, paramOne, betaOne);225 bool status = model->class->modelLimits (mode, nParamOne, paramOne, betaOne); 226 226 return status; 227 227 } … … 388 388 psVector *derivOne = thisSet->derivSet->data[i]; 389 389 390 chisqOne = model-> modelFunc (derivOne, paramOne, x);390 chisqOne = model->class->modelFunc (derivOne, paramOne, x); 391 391 chisqSum += chisqOne; 392 392 } -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceGroups.c
r36680 r37403 18 18 #include "pmMoments.h" 19 19 #include "pmModelFuncs.h" 20 #include "pmModelClass.h" 20 21 #include "pmModel.h" 21 22 #include "pmModelUtils.h" 22 #include "pmModelClass.h"23 23 #include "pmSourceMasks.h" 24 24 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceIO.c
r36680 r37403 40 40 #include "pmMoments.h" 41 41 #include "pmModelFuncs.h" 42 #include "pmModelClass.h" 42 43 #include "pmModel.h" 43 44 #include "pmModelUtils.h" 44 #include "pmModelClass.h"45 45 #include "pmSourceMasks.h" 46 46 #include "pmSourceExtendedPars.h" … … 365 365 # define PM_SOURCES_WRITE(NAME,TYPE) \ 366 366 if (!strcmp (exttype, NAME)) { \ 367 status &= pmSourcesWrite_##TYPE(file->fits, readout, sources, file->header, outhead, dataname, recipe); \367 status = pmSourcesWrite_##TYPE(file->fits, readout, sources, file->header, outhead, dataname, recipe); \ 368 368 if (xsrcname) { \ 369 369 status &= pmSourcesWrite_##TYPE##_XSRC(file->fits, readout, sources, file->header, xsrcname, recipe); \ … … 589 589 590 590 // these are case-sensitive since the EXTYPE is case-sensitive 591 status = true;591 status = false; 592 592 PM_SOURCES_WRITE("SMPDATA", SMPDATA); 593 593 PM_SOURCES_WRITE("PS1_DEV_0", PS1_DEV_0); … … 601 601 PM_SOURCES_WRITE("PS1_SV1", CMF_PS1_SV1); 602 602 PM_SOURCES_WRITE("PS1_SV2", CMF_PS1_SV2); 603 PM_SOURCES_WRITE("PS1_SV3", CMF_PS1_SV3); 604 PM_SOURCES_WRITE("PS1_SV4", CMF_PS1_SV4); 603 605 PM_SOURCES_WRITE("PS1_DV1", CMF_PS1_DV1); 604 606 PM_SOURCES_WRITE("PS1_DV2", CMF_PS1_DV2); 605 607 PM_SOURCES_WRITE("PS1_DV3", CMF_PS1_DV3); 608 PM_SOURCES_WRITE("PS1_DV4", CMF_PS1_DV4); 606 609 607 610 psFree (outhead); … … 1121 1124 PM_SOURCES_READ_PSF("PS1_SV1", CMF_PS1_SV1); 1122 1125 PM_SOURCES_READ_PSF("PS1_SV2", CMF_PS1_SV2); 1126 PM_SOURCES_READ_PSF("PS1_SV3", CMF_PS1_SV3); 1127 PM_SOURCES_READ_PSF("PS1_SV4", CMF_PS1_SV4); 1123 1128 PM_SOURCES_READ_PSF("PS1_DV1", CMF_PS1_DV1); 1124 1129 PM_SOURCES_READ_PSF("PS1_DV2", CMF_PS1_DV2); 1125 1130 PM_SOURCES_READ_PSF("PS1_DV3", CMF_PS1_DV3); 1131 PM_SOURCES_READ_PSF("PS1_DV4", CMF_PS1_DV4); 1132 1133 if (!sources) { 1134 psError(PS_ERR_IO, false, "reading CMF data from %s with format %s\n", file->filename, exttype); 1135 return false; 1136 } 1126 1137 1127 1138 long *sourceIndex = NULL; … … 1202 1213 break; 1203 1214 1204 case PM_FPA_FILE_CFF: 1215 case PM_FPA_FILE_CFF: { 1216 // determine the output table format 1217 psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT"); 1218 if (!status) { 1219 psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data"); 1220 return false; 1221 } 1205 1222 // read in header, if not yet loaded 1206 1223 hdu = pmFPAviewThisHDU (view, file->fpa); … … 1244 1261 } 1245 1262 1246 sources = pmSourcesRead_CFF(file->fits, hdu->header );1263 sources = pmSourcesRead_CFF(file->fits, hdu->header, recipe); 1247 1264 1248 1265 psTrace("psModules.objects", 6, "read CMF table from %s : %s : %s", file->filename, headname, dataname); … … 1250 1267 psFree (dataname); 1251 1268 psFree (tableHeader); 1269 } 1252 1270 break; 1253 1271 … … 1395 1413 PM_SOURCES_READ_XSRC("PS1_SV1", CMF_PS1_SV1); 1396 1414 PM_SOURCES_READ_XSRC("PS1_SV2", CMF_PS1_SV2); 1415 PM_SOURCES_READ_XSRC("PS1_SV3", CMF_PS1_SV3); 1416 PM_SOURCES_READ_XSRC("PS1_SV4", CMF_PS1_SV4); 1397 1417 PM_SOURCES_READ_XSRC("PS1_DV1", CMF_PS1_DV1); 1398 1418 PM_SOURCES_READ_XSRC("PS1_DV2", CMF_PS1_DV2); 1399 1419 PM_SOURCES_READ_XSRC("PS1_DV3", CMF_PS1_DV3); 1420 PM_SOURCES_READ_XSRC("PS1_DV4", CMF_PS1_DV4); 1400 1421 } 1401 1422 psFree(tableHeader); … … 1435 1456 PM_SOURCES_READ_XFIT("PS1_SV1", CMF_PS1_SV1); 1436 1457 PM_SOURCES_READ_XFIT("PS1_SV2", CMF_PS1_SV2); 1458 PM_SOURCES_READ_XFIT("PS1_SV3", CMF_PS1_SV3); 1459 PM_SOURCES_READ_XFIT("PS1_SV4", CMF_PS1_SV4); 1437 1460 PM_SOURCES_READ_XFIT("PS1_DV1", CMF_PS1_DV1); 1438 1461 PM_SOURCES_READ_XFIT("PS1_DV2", CMF_PS1_DV2); 1439 1462 PM_SOURCES_READ_XFIT("PS1_DV3", CMF_PS1_DV3); 1463 PM_SOURCES_READ_XFIT("PS1_DV4", CMF_PS1_DV4); 1440 1464 } 1441 1465 psFree(tableHeader); … … 1474 1498 PM_SOURCES_READ_XRAD("PS1_SV1", CMF_PS1_SV1); 1475 1499 PM_SOURCES_READ_XRAD("PS1_SV2", CMF_PS1_SV2); 1500 PM_SOURCES_READ_XRAD("PS1_SV3", CMF_PS1_SV3); 1501 PM_SOURCES_READ_XRAD("PS1_SV4", CMF_PS1_SV4); 1476 1502 PM_SOURCES_READ_XRAD("PS1_DV1", CMF_PS1_DV1); 1477 1503 PM_SOURCES_READ_XRAD("PS1_DV2", CMF_PS1_DV2); 1478 1504 PM_SOURCES_READ_XRAD("PS1_DV3", CMF_PS1_DV3); 1505 PM_SOURCES_READ_XRAD("PS1_DV4", CMF_PS1_DV4); 1479 1506 } 1480 1507 psFree(tableHeader); … … 1513 1540 PM_SOURCES_READ_XGAL("PS1_SV1", CMF_PS1_SV1); 1514 1541 PM_SOURCES_READ_XGAL("PS1_SV2", CMF_PS1_SV2); 1542 PM_SOURCES_READ_XGAL("PS1_SV3", CMF_PS1_SV3); 1543 PM_SOURCES_READ_XGAL("PS1_SV4", CMF_PS1_SV4); 1515 1544 PM_SOURCES_READ_XGAL("PS1_DV1", CMF_PS1_DV1); 1516 1545 PM_SOURCES_READ_XGAL("PS1_DV2", CMF_PS1_DV2); 1517 1546 PM_SOURCES_READ_XGAL("PS1_DV3", CMF_PS1_DV3); 1547 PM_SOURCES_READ_XGAL("PS1_DV4", CMF_PS1_DV4); 1518 1548 } 1519 1549 psFree(tableHeader); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceIO.h
r36680 r37403 40 40 MK_PROTO(CMF_PS1_SV1); 41 41 MK_PROTO(CMF_PS1_SV2); 42 MK_PROTO(CMF_PS1_SV3); 43 MK_PROTO(CMF_PS1_SV4); 42 44 MK_PROTO(CMF_PS1_DV1); 43 45 MK_PROTO(CMF_PS1_DV2); 44 46 MK_PROTO(CMF_PS1_DV3); 47 MK_PROTO(CMF_PS1_DV4); 45 48 46 49 int pmSourceGetDophotType (pmSource *source); … … 55 58 56 59 psArray *pmSourcesReadCMP (char *filename, psMetadata *header); 57 psArray *pmSourcesRead_CFF (psFits *fits, psMetadata *header );60 psArray *pmSourcesRead_CFF (psFits *fits, psMetadata *header, psMetadata *recipe); 58 61 bool pmSourcesWrite_CFF (pmReadout *readout, psFits *fits, psArray *sources, psMetadata *header, psMetadata *recipe); 59 62 -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceIO_CFF.c
r36680 r37403 37 37 #include "pmMoments.h" 38 38 #include "pmModelFuncs.h" 39 #include "pmModelClass.h" 39 40 #include "pmModel.h" 40 41 #include "pmModelUtils.h" 41 #include "pmModelClass.h"42 42 #include "pmSourceMasks.h" 43 43 #include "pmSourceExtendedPars.h" … … 53 53 #include "pmSourceOutputs.h" 54 54 55 // read in a readout from thefits file56 psArray *pmSourcesRead_CFF (psFits *fits, psMetadata *header )55 // read in sources readout from a cff fits file 56 psArray *pmSourcesRead_CFF (psFits *fits, psMetadata *header, psMetadata *recipe) 57 57 { 58 58 PS_ASSERT_PTR_NON_NULL(fits, false); … … 75 75 PS_ASSERT_INT_NONNEGATIVE(modelType, NULL); 76 76 77 pmModelType sersicModelType = pmModelClassGetType("PS_MODEL_SERSIC"); 78 pmModelType devModelType = pmModelClassGetType("PS_MODEL_DEV"); 79 80 psString modelForce = psMetadataLookupStr(&status, recipe, "EXT_MODEL_TYPE_FORCE"); 81 psF32 forceDevSersicMin = NAN; 82 bool forceAll = false; 83 int modelTypeForce = 0; 84 if (!strcmp(modelForce, "ALL")) { 85 forceAll = true; 86 } else if (!strcmp(modelForce, "PS_MODEL_SERSIC")) { 87 modelTypeForce = sersicModelType; 88 forceDevSersicMin = psMetadataLookupF32(&status, recipe, "EXT_MODEL_FORCE_DEV_SERSIC_MIN"); 89 } else { 90 modelTypeForce = pmModelClassGetType(modelForce); 91 PS_ASSERT_INT_NONNEGATIVE(modelTypeForce, NULL); 92 } 93 94 // skip extended model types for likely stars 95 // max value of KronMag - psfMag to keep ... 96 psF32 starCut = psMetadataLookupF32(&status, recipe, "EXT_MODEL_FORCE_MAGDIFF_MAX"); 97 if (!status) { 98 starCut = 0; 99 } 100 // ... unless SN is less than this value 101 psF32 SNMinForCut = psMetadataLookupF32(&status, recipe, "EXT_MODEL_FORCE_CUT_SN_MIN"); 102 if (!status) { 103 SNMinForCut = 10; 104 } 105 77 106 // We get the size of the table, and allocate the array of sources first because the table 78 107 // is large and ephemeral --- when the table gets blown away, whatever is allocated after 79 108 // the table is read blocks the free. In fact, it's better to read the table row by row. 80 long numSources = psFitsTableSize(fits); // Number of sources in table 81 psArray *sources = psArrayAlloc(numSources); // Array of sources, to return 82 83 // convert the table to the pmSource entriesa 84 for (int i = 0; i < numSources; i++) { 109 long numRows = psFitsTableSize(fits); // Number of rows in table 110 psArray *sources = psArrayAllocEmpty(numRows); // Array of sources, to return 111 112 // convert the table to the pmSource entries 113 pmSource *source = NULL; 114 for (int i = 0; i < numRows; i++) { 85 115 psMetadata *row = psFitsReadTableRow(fits, i); // Table row 86 116 if (!row) { … … 108 138 float kronRadius = psMetadataLookupF32 (&status, row, "KRON_RADIUS"); 109 139 float petRadius = psMetadataLookupF32 (&status, row, "PETRO_RADIUS"); 140 float SN = psMetadataLookupF32 (&status, row, "SN"); 110 141 bool fitGalaxy = psMetadataLookupU8 (&status, row, "FIT_GALAXY"); 111 142 bool psfStar = psMetadataLookupU8 (&status, row, "PSF_STAR"); … … 114 145 float Rminor = psMetadataLookupF32 (&status, row, "R_MINOR"); 115 146 float theta = psMetadataLookupF32 (&status, row, "THETA"); 147 float chisq = psMetadataLookupF32 (&status, row, "CHISQ"); 148 float nDOF = psMetadataLookupF32 (&status, row, "NDOF"); 149 float magDiff = psMetadataLookupF32 (&status, row, "MAG_DIFF"); 150 psS16 modelFlags = psMetadataLookupS32 (&status, row, "MODEL_FLAGS"); 116 151 117 152 int galaxyModelType = psMetadataLookupS32(&status, row, "MODEL_TYPE"); 118 if (status ) {153 if (status && galaxyModelType >= 0) { 119 154 galaxyModelType = pmModelClassGetLocalType(galaxyModelType); 120 155 } else { … … 123 158 float Sindex = psMetadataLookupF32 (&status, row, "INDEX"); // Should this be PAR_07 not sersic index 124 159 125 pmSource *source = pmSourceAlloc (); 126 pmModel *model = pmModelAlloc (modelType); 127 source->modelPSF = model; 128 // RoughClass wants source type to be unknown 129 // source->type = PM_SOURCE_TYPE_STAR; // XXX this should be added to the flags 130 source->type = PM_SOURCE_TYPE_UNKNOWN; 131 132 // XXX we can set this in general, but for a specific image, we need to weed out SATSTARS and 133 // stars that are masked 134 if (psfStar) { 135 source->tmpFlags |= PM_SOURCE_TMPF_CANDIDATE_PSFSTAR; 136 } 137 138 // NOTE: A SEGV here because "model" is NULL is probably caused by not initialising the models. 139 psF32 *PAR = model->params->data.F32; 140 psF32 *dPAR = model->dparams->data.F32; 141 142 source->seq = ID; 143 PAR[PM_PAR_XPOS] = X; 144 PAR[PM_PAR_YPOS] = Y; 145 146 dPAR[PM_PAR_XPOS] = 0.0; 147 dPAR[PM_PAR_YPOS] = 0.0; 148 149 PAR[PM_PAR_SKY] = 0.0; 150 dPAR[PM_PAR_SKY] = 0.0; 151 152 PAR[PM_PAR_I0] = 1.0; 153 dPAR[PM_PAR_I0] = 0.0; 154 155 source->sky = PAR[PM_PAR_SKY]; 156 source->skyErr = dPAR[PM_PAR_SKY]; 157 158 source->psfMag = 0.0; 159 source->psfMagErr = 0.0; 160 source->apMag = 0.0; 161 source->apRadius = apRadius; 162 163 // we generate a somewhat fake PSF model here -- 164 // in most (all?) contexts, we will replace this with a measured psf model 165 // elsewhere 166 axes.major = 1.0; 167 axes.minor = 1.0; 168 axes.theta = 0.0; 169 pmPSF_AxesToModel (PAR, axes, modelType); 170 171 // peak->detValue, rawFlux, smoothFlux are all set to the flux argument which is counts per second 172 source->peak = pmPeakAlloc(X, Y, flux, PM_PEAK_LONE); 173 source->peak->xf = X; // pmPeakAlloc converts X,Y to int, so reset here 174 source->peak->yf = Y; // pmPeakAlloc converts X,Y to int, so reset here 175 source->peak->dx = 0.0; 176 source->peak->dy = 0.0; 177 178 source->moments = pmMomentsAlloc (); 179 source->moments->Mx = X; 180 source->moments->My = Y; 181 source->moments->Mrf = kronRadius * 0.4; // kronRadius is 2.5 * first radial moment 182 183 // Don't mark the moments as measured because that causes many fields to be left blank. 184 // The moments code knows not to change the position or the Mrf for external sources 185 // source->tmpFlags |= PM_SOURCE_TMPF_MOMENTS_MEASURED; 186 187 if (isfinite(petRadius)) { 188 source->extpars = pmSourceExtendedParsAlloc (); 189 source->extpars->petrosianRadius = petRadius; 190 } 191 160 if (!source || ID != source->seq) { 161 if (source) { 162 psArrayAdd (sources, 1, source); 163 psFree(source); 164 } 165 source = pmSourceAlloc (); 166 pmModel *model = pmModelAlloc (modelType); 167 source->modelPSF = model; 168 // RoughClass wants source type to be unknown 169 // source->type = PM_SOURCE_TYPE_STAR; // XXX this should be added to the flags 170 source->type = PM_SOURCE_TYPE_UNKNOWN; 171 172 // XXX we can set this in general, but for a specific image, we need to weed out SATSTARS and 173 // stars that are masked 174 if (psfStar) { 175 source->tmpFlags |= PM_SOURCE_TMPF_CANDIDATE_PSFSTAR; 176 } 177 178 // NOTE: A SEGV here because "model" is NULL is probably caused by not initialising the models. 179 psF32 *PAR = model->params->data.F32; 180 psF32 *dPAR = model->dparams->data.F32; 181 182 source->seq = ID; 183 184 PAR[PM_PAR_XPOS] = X; 185 PAR[PM_PAR_YPOS] = Y; 186 187 dPAR[PM_PAR_XPOS] = 0.0; 188 dPAR[PM_PAR_YPOS] = 0.0; 189 190 PAR[PM_PAR_SKY] = 0.0; 191 dPAR[PM_PAR_SKY] = 0.0; 192 193 PAR[PM_PAR_I0] = 1.0; 194 dPAR[PM_PAR_I0] = 0.0; 195 196 source->sky = PAR[PM_PAR_SKY]; 197 source->skyErr = dPAR[PM_PAR_SKY]; 198 199 source->psfMag = 0.0; 200 source->psfMagErr = 0.0; 201 source->apMag = 0.0; 202 source->apRadius = apRadius; 203 204 // we generate a somewhat fake PSF model here -- 205 // in most (all?) contexts, we will replace this with a measured psf model 206 // elsewhere 207 axes.major = 1.0; 208 axes.minor = 1.0; 209 axes.theta = 0.0; 210 pmPSF_AxesToModel (PAR, axes, model->class->useReff); 211 212 // peak->detValue, rawFlux, smoothFlux are all set to the flux argument which is counts per second 213 source->peak = pmPeakAlloc(X, Y, flux, PM_PEAK_LONE); 214 source->peak->xf = X; // pmPeakAlloc converts X,Y to int, so reset here 215 source->peak->yf = Y; // pmPeakAlloc converts X,Y to int, so reset here 216 source->peak->dx = 0.0; 217 source->peak->dy = 0.0; 218 219 source->extSN = SN; 220 221 source->moments = pmMomentsAlloc (); 222 source->moments->Mx = X; 223 source->moments->My = Y; 224 source->moments->Mrf = kronRadius * 0.4; // kronRadius is 2.5 * first radial moment 225 226 // Don't mark the moments as measured because that causes many fields to be left blank. 227 // The moments code knows not to change the position or the Mrf for external sources 228 // source->tmpFlags |= PM_SOURCE_TMPF_MOMENTS_MEASURED; 229 230 if (isfinite(petRadius)) { 231 source->extpars = pmSourceExtendedParsAlloc (); 232 source->extpars->petrosianRadius = petRadius; 233 } 234 235 } 236 bool saveExtModelParams = false; 192 237 if (fitGalaxy && galaxyModelType >= 0) { 193 source->modelFits = psArrayAllocEmpty (1); 194 pmModel *model = pmModelAlloc(galaxyModelType); 195 psF32 *xPAR = model->params->data.F32; 196 197 xPAR[PM_PAR_SKY] = 0.0; 198 xPAR[PM_PAR_I0] = 1.0; 199 xPAR[PM_PAR_XPOS] = X; 238 // skip likely stars 239 if (magDiff < starCut || SN < SNMinForCut) { 240 if (forceAll) { 241 saveExtModelParams = true; 242 } else if (galaxyModelType == modelTypeForce) { 243 // This is the model type that we are looking for 244 // proceed 245 saveExtModelParams = true; 246 } else if (modelTypeForce == sersicModelType && galaxyModelType == devModelType) { 247 // We're doing sersic models, if sersic index is greater than the recipe's minimum index 248 // do dev model as well 249 if (isfinite(forceDevSersicMin) || Sindex >= forceDevSersicMin) { 250 saveExtModelParams = true; 251 } 252 } else { 253 // not interested in this model 254 } 255 } 256 } 257 258 if (saveExtModelParams) { 259 if (!source->modelFits) { 260 source->modelFits = psArrayAllocEmpty (1); 261 } 262 pmModel *model = pmModelAlloc(galaxyModelType); 263 psF32 *xPAR = model->params->data.F32; 264 265 xPAR[PM_PAR_SKY] = 0.0; 266 xPAR[PM_PAR_I0] = 1.0; 267 xPAR[PM_PAR_XPOS] = X; 200 268 xPAR[PM_PAR_YPOS] = Y; 201 269 … … 205 273 galaxyAxes.theta = theta * PS_RAD_DEG; 206 274 207 pmPSF_AxesToModel (xPAR, galaxyAxes, galaxyModelType);275 pmPSF_AxesToModel (xPAR, galaxyAxes, model->class->useReff); 208 276 if (model->params->n > 7) { 209 277 xPAR[PM_PAR_7] = 0.5 / Sindex; 210 278 } 211 279 280 model->chisq = chisq; 281 model->nDOF = nDOF; 282 model->flags = modelFlags; 283 212 284 psArrayAdd (source->modelFits, 1, model); 213 285 214 #ifdef notyet215 // XXX: set source->modelEXT to this model and flag as extended so that we have a better216 // shot at subtracting extended sources?217 218 // This doesn't work right. Need to do some more work to flesh out the model before it can be219 // used in subtaction. Better idea might be to do 2 passes in psphotFullForceReadout to220 // First find the best extended models and then do everything else.221 source->modelEXT = psMemIncrRefCounter(model);222 // is this safe? (no see above)223 source->type = PM_SOURCE_TYPE_EXTENDED;224 source->mode |= PM_SOURCE_MODE_EXTMODEL;225 #endif226 227 286 psFree (model); 228 287 } 229 288 230 sources->data[i] = source;231 289 psFree(row); 290 } 291 if (source) { 292 // close out last source 293 psArrayAdd (sources, 1, source); 294 psFree(source); 232 295 } 233 296 … … 250 313 251 314 pmModelType sersicModelType = pmModelClassGetType("PS_MODEL_SERSIC"); 315 pmModelType devModelType = pmModelClassGetType("PS_MODEL_DEV"); 316 pmModelType selectedModelType = -1; 317 bool chooseBest = false; 318 bool chooseAll = false; 252 319 253 320 psString modelToChoose = psMetadataLookupStr(&mdok, recipe, "EXT_MODEL_TYPE_FOR_CFF"); 254 pmModelType selectedModelType = -1; 321 255 322 if (mdok && modelToChoose != NULL) { 256 if (strcmp(modelToChoose, "BEST")) { 323 if (!strcmp(modelToChoose, "BEST")) { 324 chooseBest = true; 325 } else if (!strcmp(modelToChoose, "ALL")) { 326 chooseAll = true; 327 } else if (strcmp(modelToChoose, "PS_MODEL_SERSIC")) { 328 // We have selected a model type other than Sersic. 329 // Save it's type for use below. Sersic is handled specially 257 330 selectedModelType = pmModelClassGetType(modelToChoose); 258 331 } 259 332 } 333 334 // minimum sersic index to force devModel 335 psF32 sersicMinDev = psMetadataLookupF32(&mdok, recipe, "EXT_MODEL_FORCE_DEV_SERSIC_MIN"); 336 if (!mdok) { 337 sersicMinDev = NAN; 338 } 339 340 sources = psArraySort (sources, pmSourceSortBySeq); 260 341 261 342 for (int i = 0; i < sources->n; i++) { … … 263 344 pmSource *source = thisSource->parent ? thisSource->parent : thisSource; 264 345 265 psF32 xPos, yPos, flux, rMajor, rMinor, theta; 266 psS32 modelType = 0; 346 #define MAX_ROWS_PER_SRC 10 347 psF32 xPos[MAX_ROWS_PER_SRC], yPos[MAX_ROWS_PER_SRC], flux[MAX_ROWS_PER_SRC]; 348 psF32 rMajor[MAX_ROWS_PER_SRC], rMinor[MAX_ROWS_PER_SRC], theta[MAX_ROWS_PER_SRC]; 349 psF32 chisq[MAX_ROWS_PER_SRC], nDOF[MAX_ROWS_PER_SRC]; 350 psS32 modelFlags[MAX_ROWS_PER_SRC]; 351 psS32 modelType[MAX_ROWS_PER_SRC]; 352 psF32 sersicIndex = NAN; 267 353 bool fitGalaxy = false; 268 354 bool psfStar = (source->mode & PM_SOURCE_MODE_PSFSTAR) ? true : false; 269 psF32 sersicIndex = 0; 270 // For now only perform galaxy fits on extended objects 271 if (source->modelEXT == NULL) { 272 pmModel *model = source->modelPSF; 273 if (model == NULL) continue; 274 psF32 *PAR = model->params->data.F32; 275 if (!isfinite(PAR[PM_PAR_SXX]) || !isfinite(PAR[PM_PAR_SYY]) || !isfinite(PAR[PM_PAR_SXY]) || 276 !isfinite(source->psfFlux)) { 277 continue; 278 } 279 280 xPos = model->params->data.F32[PM_PAR_XPOS]; 281 yPos = model->params->data.F32[PM_PAR_YPOS]; 282 flux = source->psfFlux; 283 rMajor = 0; 284 rMinor = 0; 285 theta = 0; 286 } else { 287 // Find the model with the selected type. If selected type is -1 choose the one selected ad 288 // modelEXT which was the best 289 int iModel = -1; 290 if (source->modelEXT) { 291 pmModelType ext_model_type = selectedModelType != -1 ? selectedModelType : source->modelEXT->type; 355 int n_rows = 0; 356 357 psF32 kronFlux = source->moments->KronFlux; 358 psF32 SN = NAN; 359 psF32 magDiff = NAN; 360 if (isfinite(kronFlux) && isfinite(source->moments->KronFluxErr) && isfinite(source->psfMag)) { 361 SN = kronFlux/source->moments->KronFluxErr; 362 // kronMag - psfMag for use as star/glaxy separator 363 magDiff = -2.5 * log10(kronFlux) - source->psfMag ; 364 } 365 366 // start with psf model 367 pmModel *model = source->modelPSF; 368 if (model == NULL) continue; 369 psF32 *PAR = model->params->data.F32; 370 if (!isfinite(PAR[PM_PAR_SXX]) || !isfinite(PAR[PM_PAR_SYY]) || !isfinite(PAR[PM_PAR_SXY]) || 371 !isfinite(source->psfFlux)) { 372 continue; 373 } 374 375 // save the PSF model parameters for each object as the first entry 376 xPos[0] = model->params->data.F32[PM_PAR_XPOS]; 377 yPos[0] = model->params->data.F32[PM_PAR_YPOS]; 378 flux[0] = source->psfFlux; 379 rMajor[0] = 0; 380 rMinor[0] = 0; 381 theta[0] = 0; 382 modelType[0] = -1; 383 sersicIndex = NAN; 384 chisq[0] = NAN; 385 nDOF[0] = NAN; 386 modelFlags[0] = 0; 387 n_rows ++; 388 389 if (source->modelFits != NULL) { 390 // figure out which models to use based on recipe paramters 391 if (chooseAll) { 392 // Save parameters for all valid extended models 393 394 // but make sure we aren't going to overflow our arrays 395 assert (source->modelFits->n < MAX_ROWS_PER_SRC); 396 292 397 for (int j=0; j<source->modelFits->n; j++) { 293 pmModel *aModel = source->modelFits->data[j]; 294 if (aModel->type == ext_model_type) { 295 iModel = j; 296 break; 398 pmModel *model = source->modelFits->data[j]; 399 psF32 *PAR = model->params->data.F32; 400 401 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SYY]) && isfinite(PAR[PM_PAR_SXY]) && 402 isfinite(model->mag)) { 403 404 xPos[n_rows] = PAR[PM_PAR_XPOS]; 405 yPos[n_rows] = PAR[PM_PAR_YPOS]; 406 407 psEllipseAxes axes = pmPSF_ModelToAxes (PAR, model->class->useReff); 408 rMajor[n_rows] = axes.major; 409 rMinor[n_rows] = axes.minor; 410 theta[n_rows] = axes.theta*PS_DEG_RAD; 411 flux[n_rows] = pow(10.0, -0.4*model->mag); 412 modelType[n_rows] = model->type; 413 chisq[n_rows] = model->chisq; 414 nDOF[n_rows] = model->nDOF; 415 modelFlags[n_rows] = model->flags; 416 fitGalaxy = true; 417 if (model->params->n == 8) { 418 // this will save the sersic index in all models but that might 419 // be useful 420 sersicIndex = 0.5 / PAR[PM_PAR_7]; 421 } else { 422 sersicIndex = NAN; 423 } 424 425 n_rows++; 426 } 427 } 428 } else { 429 int jModelSersic = -1; 430 int jModelDev = -1; 431 int jModelSelected = -1; 432 psF32 minChisq = NAN; 433 for (int j=0; j<source->modelFits->n; j++) { 434 pmModel *model = source->modelFits->data[j]; 435 if (chooseBest) { 436 // choose the model with lowest chisq 437 if (isfinite(model->chisq) && (!isfinite(minChisq) || model->chisq < minChisq)) { 438 jModelSelected = j; 439 minChisq = model->chisq; 440 } 441 } else { 442 // find the index of models of interest 443 if (model->type == selectedModelType) { 444 jModelSelected = j; 445 } else if (model->type == sersicModelType) { 446 jModelSersic = j; 447 } else if (model->type == devModelType) { 448 jModelDev = j; 449 } 450 } 451 } 452 if (jModelSelected >= 0 || jModelSersic >= 0) { 453 // If a specific non-sersic model we take paramers from that one. 454 // Otherwise we do the sersic model. 455 pmModel *model = jModelSelected >= 0 ? source->modelFits->data[jModelSelected] : 456 source->modelFits->data[jModelSersic]; 457 psF32 *PAR = model->params->data.F32; 458 459 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SYY]) && isfinite(PAR[PM_PAR_SXY]) && 460 isfinite(model->mag)) { 461 462 xPos[0] = PAR[PM_PAR_XPOS]; 463 yPos[0] = PAR[PM_PAR_YPOS]; 464 465 psEllipseAxes axes = pmPSF_ModelToAxes (PAR, model->class->useReff); 466 rMajor[0] = axes.major; 467 rMinor[0] = axes.minor; 468 theta[0] = axes.theta*PS_DEG_RAD; 469 flux[0] = pow(10.0, -0.4*model->mag); 470 modelType[0] = model->type; 471 chisq[0] = model->chisq; 472 nDOF[0] = model->nDOF; 473 modelFlags[0] = model->flags; 474 fitGalaxy = true; 475 if (model->type == sersicModelType) { 476 PS_ASSERT_FLOAT_LARGER_THAN(PAR[PM_PAR_7], 0.0, false); 477 sersicIndex = 0.5 / PAR[PM_PAR_7]; 478 } 479 480 n_rows = 1; 481 482 // Unless a specific non-sersic model type was selected do dev model for sources with 483 // sersic index above the recipe limit. 484 if (jModelSelected == -1 && jModelDev >= 0 && isfinite(sersicMinDev) && 485 sersicIndex > sersicMinDev) { 486 487 model = source->modelFits->data[jModelDev]; 488 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SYY]) && isfinite(PAR[PM_PAR_SXY]) && 489 isfinite(model->mag)) { 490 491 xPos[1] = PAR[PM_PAR_XPOS]; 492 yPos[1] = PAR[PM_PAR_YPOS]; 493 494 psEllipseAxes axes = pmPSF_ModelToAxes (PAR, model->class->useReff); 495 rMajor[1] = axes.major; 496 rMinor[1] = axes.minor; 497 theta[1] = axes.theta*PS_DEG_RAD; 498 flux[1] = pow(10.0, -0.4*model->mag); 499 modelType[1] = model->type; 500 sersicIndex = NAN; 501 chisq[1] = model->chisq; 502 nDOF[1] = model->nDOF; 503 modelFlags[1] = model->flags; 504 n_rows = 2; 505 } 506 } 297 507 } 298 508 } 299 509 } 300 if (iModel == -1) { 301 // Can this happen? perhaps if model type is qgauss (extended but below s/n for model fits? 302 // XXX: Should this be an assert? 303 continue; 304 } 305 pmModel *model = source->modelFits->data[iModel]; 306 psF32 *PAR = model->params->data.F32; 307 xPos = PAR[PM_PAR_XPOS]; 308 yPos = PAR[PM_PAR_YPOS]; 309 if (model->type == pmModelClassGetType("PS_MODEL_TRAIL")) { 310 // XXX: do we need to handle this type 311 continue; 312 } else { 313 if (!isfinite(PAR[PM_PAR_SXX]) || !isfinite(PAR[PM_PAR_SYY]) || !isfinite(PAR[PM_PAR_SXY]) || 314 !isfinite(model->mag)) { 315 // bad model 316 continue; 317 } 318 psEllipseAxes axes = pmPSF_ModelToAxes (PAR, model->type); 319 rMajor = axes.major; 320 rMinor = axes.minor; 321 theta = axes.theta*PS_DEG_RAD; 322 flux = pow(10.0, -0.4*model->mag); 323 fitGalaxy = true; 324 } 325 modelType = model->type; 326 if (modelType == sersicModelType) { 327 PS_ASSERT_FLOAT_LARGER_THAN(PAR[PM_PAR_7], 0.0, false); 328 sersicIndex = 0.5 / PAR[PM_PAR_7]; 329 } 330 } 331 psMetadata *row = psMetadataAlloc(); 332 psMetadataAddU32 (row, PS_LIST_TAIL, "ID", 0, "IPP detection identifier", source->seq); 333 psMetadataAddF32 (row, PS_LIST_TAIL, "X", 0, "x coordinate", xPos); 334 psMetadataAddF32 (row, PS_LIST_TAIL, "Y", 0, "y coordinate", yPos); 335 psMetadataAddF32 (row, PS_LIST_TAIL, "FLUX", 0, "flux per second", flux/exptime); 336 psMetadataAddF32 (row, PS_LIST_TAIL, "AP_RADIUS", 0, "aperture radius", source->apRadius); 337 psMetadataAddF32 (row, PS_LIST_TAIL, "KRON_RADIUS", 0, "Kron radius", source->moments->Mrf * 2.5); 338 psMetadataAddF32 (row, PS_LIST_TAIL, "PETRO_RADIUS", 0, "Petrosian Radius", source->extpars ? source->extpars->petrosianRadius : NAN); 339 psMetadataAddBool (row, PS_LIST_TAIL, "FIT_GALAXY", 0, "source has xfit", fitGalaxy); 340 psMetadataAddBool (row, PS_LIST_TAIL, "PSF_STAR", 0, "source was psf star", psfStar); 341 psMetadataAddF32 (row, PS_LIST_TAIL, "R_MAJOR", 0, "radius of major axis", rMajor); 342 psMetadataAddF32 (row, PS_LIST_TAIL, "R_MINOR", 0, "radius of minor axis", rMinor); 343 psMetadataAddF32 (row, PS_LIST_TAIL, "THETA", 0, "theta", theta); 344 psMetadataAddS32 (row, PS_LIST_TAIL, "MODEL_TYPE", 0, "model type", modelType); 345 psMetadataAddF32 (row, PS_LIST_TAIL, "INDEX", 0, "sersic index", sersicIndex); 346 347 psArrayAdd(table, 100, row); 348 psFree(row); 510 } 511 512 for (int j = 0; j < n_rows; j++) { 513 psMetadata *row = psMetadataAlloc(); 514 psMetadataAddU32 (row, PS_LIST_TAIL, "ID", 0, "IPP detection identifier", source->seq); 515 psMetadataAddF32 (row, PS_LIST_TAIL, "X", 0, "x coordinate", xPos[j]); 516 psMetadataAddF32 (row, PS_LIST_TAIL, "Y", 0, "y coordinate", yPos[j]); 517 psMetadataAddF32 (row, PS_LIST_TAIL, "FLUX", 0, "flux per second", flux[j]/exptime); 518 psMetadataAddF32 (row, PS_LIST_TAIL, "SN", 0, "kron flux signal to noise", SN); 519 psMetadataAddF32 (row, PS_LIST_TAIL, "MAG_DIFF", 0, "psf mag - kron mag", magDiff); 520 psMetadataAddF32 (row, PS_LIST_TAIL, "AP_RADIUS", 0, "aperture radius", source->apRadius); 521 psMetadataAddF32 (row, PS_LIST_TAIL, "KRON_RADIUS", 0, "Kron radius", source->moments->Mrf * 2.5); 522 psMetadataAddF32 (row, PS_LIST_TAIL, "PETRO_RADIUS", 0, "Petrosian Radius", source->extpars ? source->extpars->petrosianRadius : NAN); 523 psMetadataAddBool (row, PS_LIST_TAIL, "FIT_GALAXY", 0, "source has xfit", fitGalaxy); 524 psMetadataAddBool (row, PS_LIST_TAIL, "PSF_STAR", 0, "source was psf star", psfStar); 525 psMetadataAddF32 (row, PS_LIST_TAIL, "R_MAJOR", 0, "radius of major axis", rMajor[j]); 526 psMetadataAddF32 (row, PS_LIST_TAIL, "R_MINOR", 0, "radius of minor axis", rMinor[j]); 527 psMetadataAddF32 (row, PS_LIST_TAIL, "THETA", 0, "theta", theta[j]); 528 psMetadataAddS32 (row, PS_LIST_TAIL, "MODEL_TYPE", 0, "model type", modelType[j]); 529 psMetadataAddF32 (row, PS_LIST_TAIL, "INDEX", 0, "sersic index", sersicIndex); 530 psMetadataAddF32 (row, PS_LIST_TAIL, "CHISQ", 0, "chisq", chisq[j]); 531 psMetadataAddF32 (row, PS_LIST_TAIL, "NDOF", 0, "n degrees of freedom", nDOF[j]); 532 psMetadataAddS32 (row, PS_LIST_TAIL, "MODEL_FLAGS", 0, "model flags", modelFlags[j]); 533 534 psArrayAdd(table, 100, row); 535 psFree(row); 536 } 349 537 } 350 538 -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceIO_CMF.c.in
r36680 r37403 37 37 #include "pmMoments.h" 38 38 #include "pmModelFuncs.h" 39 #include "pmModelClass.h" 39 40 #include "pmModel.h" 40 41 #include "pmModelUtils.h" 41 #include "pmModelClass.h"42 42 #include "pmSourceMasks.h" 43 43 #include "pmSourceExtendedPars.h" … … 142 142 @ALL@ psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG", PS_DATA_F32, "magnitude in standard aperture", source->apMag); 143 143 @>PS1_V2,PS1_SV?,>PS1_DV1@ psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RAW", PS_DATA_F32, "magnitude in reported aperture", source->apMagRaw); 144 @ALL@ psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS", PS_DATA_F32, "radius used for aperture mags", outputs.apRadius);144 @ALL@ psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS", PS_DATA_F32, "radius used for aperture mags", source->apRadius); 145 145 @>PS1_DV1,>PS1_V3,>PS1_SV1@ psMetadataAdd (row, PS_LIST_TAIL, "AP_FLUX", PS_DATA_F32, "instrumental flux in standard aperture", source->apFlux); 146 146 @>PS1_DV1,>PS1_V3,>PS1_SV1@ psMetadataAdd (row, PS_LIST_TAIL, "AP_FLUX_SIG", PS_DATA_F32, "aperture flux error", source->apFluxErr); 147 @>PS1_V4,>PS1_SV2,>PS1_DV3@ psMetadataAdd (row, PS_LIST_TAIL, "AP_NPIX", PS_DATA_S32, "aperture unmasked pixels", source->apNpixels); 147 148 148 149 @<PS1_V3,PS1_SV1,PS1_DV?@ psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude", outputs.peakMag); … … 163 164 @ALL@ psMetadataAdd (row, PS_LIST_TAIL, "EXT_NSIGMA", PS_DATA_F32, "Nsigma deviations from PSF to EXT", source->extNsigma); 164 165 166 // PSF shape parameters: 165 167 @ALL@ psMetadataAdd (row, PS_LIST_TAIL, "PSF_MAJOR", PS_DATA_F32, "PSF width (major axis)", outputs.psfMajor); 166 168 @ALL@ psMetadataAdd (row, PS_LIST_TAIL, "PSF_MINOR", PS_DATA_F32, "PSF width (minor axis)", outputs.psfMinor); 167 169 @ALL@ psMetadataAdd (row, PS_LIST_TAIL, "PSF_THETA", PS_DATA_F32, "PSF orientation angle", outputs.psfTheta); 170 @>PS1_V4,>PS1_SV2,>PS1_DV3@ psMetadataAdd (row, PS_LIST_TAIL, "PSF_CORE", PS_DATA_F32, "k term if defined", outputs.psfCore); 171 172 // I use a look-up table and linear interpolation to map PSF_MAJOR,PSF_MINOR + PSF_CORE to FWHM values 173 @>PS1_V4,>PS1_SV2,>PS1_DV3@ psMetadataAdd (row, PS_LIST_TAIL, "PSF_FWHM_MAJ", PS_DATA_F32, "PSF FWHM (major axis)", outputs.psfMajorFWHM); 174 @>PS1_V4,>PS1_SV2,>PS1_DV3@ psMetadataAdd (row, PS_LIST_TAIL, "PSF_FWHM_MIN", PS_DATA_F32, "PSF FWHM (minor axis)", outputs.psfMinorFWHM); 175 176 // psf data quality 168 177 @ALL@ psMetadataAdd (row, PS_LIST_TAIL, "PSF_QF", PS_DATA_F32, "PSF coverage/quality factor (bad)", source->pixWeightNotBad); 169 178 @>PS1_V2,PS1_SV?,>PS1_DV1@ psMetadataAdd (row, PS_LIST_TAIL, "PSF_QF_PERFECT", PS_DATA_F32, "PSF coverage/quality factor (poor)", source->pixWeightNotPoor); … … 197 206 } 198 207 199 if (source->lensing OBJ&& source->lensingPSF->smear) {208 if (source->lensingPSF && source->lensingPSF->smear) { 200 209 @>PS1_V4@ psMetadataAdd (row, PS_LIST_TAIL, "LENS_X11_SM_PSF", PS_DATA_F32, "smear polarizability element (objects)", source->lensingPSF->smear->X11); 201 210 @>PS1_V4@ psMetadataAdd (row, PS_LIST_TAIL, "LENS_X12_SM_PSF", PS_DATA_F32, "smear polarizability element (objects)", source->lensingPSF->smear->X12); … … 205 214 } 206 215 207 if (source->lensing OBJ&& source->lensingPSF->shear) {216 if (source->lensingPSF && source->lensingPSF->shear) { 208 217 @>PS1_V4@ psMetadataAdd (row, PS_LIST_TAIL, "LENS_X11_SH_PSF", PS_DATA_F32, "shear polarizability element (objects)", source->lensingPSF->shear->X11); 209 218 @>PS1_V4@ psMetadataAdd (row, PS_LIST_TAIL, "LENS_X12_SH_PSF", PS_DATA_F32, "shear polarizability element (objects)", source->lensingPSF->shear->X12); … … 212 221 @>PS1_V4@ psMetadataAdd (row, PS_LIST_TAIL, "LENS_E2_SH_PSF", PS_DATA_F32, "shear polarizability element (objects)", source->lensingPSF->shear->e2); 213 222 } 223 224 // if lensing params exist also include the backmapped chipID and chip coordinates 225 if (source->lensingPSF && source->lensingPSF->shear) { 226 @>PS1_V4@ psMetadataAdd (row, PS_LIST_TAIL, "SRC_CHIP_NUM", PS_DATA_S16, "id of warp input chip", source->chipNum); 227 @>PS1_V4@ psMetadataAdd (row, PS_LIST_TAIL, "SRC_CHIP_X", PS_DATA_S16, "x coord in warp input chip", source->chipX); 228 @>PS1_V4@ psMetadataAdd (row, PS_LIST_TAIL, "SRC_CHIP_Y", PS_DATA_S16, "y coord in warp input chip", source->chipY); 229 @>PS1_V4@ psMetadataAdd (row, PS_LIST_TAIL, "PADDING3", PS_DATA_S16, "more padding", 0); 230 } 214 231 215 232 @>PS1_V2,PS1_SV?,>PS1_DV1@ psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_R1", PS_DATA_F32, "first radial moment", moments.Mrf); … … 302 319 303 320 // define PSF model type 304 // XXX need to carry the extra model parameters305 321 int modelType = pmModelClassGetType ("PS_MODEL_GAUSS"); 306 322 307 char *PSF_NAME = psMetadataLookupStr (&status, header, "PSF_NAME"); 323 // if header does not define the model, default to a gaussian 324 char *PSF_NAME = psMetadataLookupStr (&status, header, "PSFMODEL"); 308 325 if (PSF_NAME != NULL) { 309 326 modelType = pmModelClassGetType (PSF_NAME); 310 327 } 311 328 assert (modelType > -1); 329 330 // do we expect to find lensing parameters? 331 bool haveLensOBJ = psMetadataLookupBool (&status, header, "LENS_OBJ"); 332 bool haveLensPSF = psMetadataLookupBool (&status, header, "LENS_PSF"); 312 333 313 334 // We get the size of the table, and allocate the array of sources first because the table … … 344 365 @ALL@ axes.theta = psMetadataLookupF32 (&status, row, "PSF_THETA"); 345 366 @ALL@ axes.theta = axes.theta * PS_RAD_DEG; 367 368 @>PS1_V4,>PS1_SV2,>PS1_DV3@ if (model->params->n > PM_PAR_7) { 369 @>PS1_V4,>PS1_SV2,>PS1_DV3@ PAR[PM_PAR_7] = psMetadataLookupF32 (&status, row, "PSF_CORE"); 370 @>PS1_V4,>PS1_SV2,>PS1_DV3@ } 346 371 347 372 @ALL@ PAR[PM_PAR_SKY] = psMetadataLookupF32 (&status, row, "SKY"); … … 355 380 @ALL@ source->apMag = psMetadataLookupF32 (&status, row, "AP_MAG"); 356 381 @>PS1_V2,PS1_SV?,>PS1_DV1@ source->apMagRaw = psMetadataLookupF32 (&status, row, "AP_MAG_RAW"); 382 @>PS1_DV1,>PS1_V3,>PS1_SV1@ source->apFlux = psMetadataLookupF32 (&status, row, "AP_FLUX"); 383 @>PS1_DV1,>PS1_V3,>PS1_SV1@ source->apFluxErr = psMetadataLookupF32 (&status, row, "AP_FLUX_SIG"); 357 384 358 385 // XXX use these to determine PAR[PM_PAR_I0] if they exist? … … 365 392 @ALL@ dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN; 366 393 367 pmPSF_AxesToModel (PAR, axes, model Type);394 pmPSF_AxesToModel (PAR, axes, model->class->useReff); 368 395 369 396 @ALL@ float peakMag = psMetadataLookupF32 (&status, row, "PEAK_FLUX_AS_MAG"); … … 383 410 @ALL@ source->crNsigma = psMetadataLookupF32 (&status, row, "CR_NSIGMA"); 384 411 @ALL@ source->extNsigma = psMetadataLookupF32 (&status, row, "EXT_NSIGMA"); 385 @ALL@ source->apRadius = psMetadataLookupS32 (&status, row, "AP_MAG_RADIUS"); 412 @ALL@ source->apRadius = psMetadataLookupF32 (&status, row, "AP_MAG_RADIUS"); 413 @>PS1_V4,>PS1_SV2,>PS1_DV3@ source->apNpixels = psMetadataLookupS32 (&status, row, "AP_NPIX"); 386 414 387 415 // note that some older versions used PSF_PROBABILITY: this was not well defined. … … 410 438 @>PS1_V2,PS1_SV?@ source->moments->Mxyyy = -0.25 * psMetadataLookupF32 (&status, row, "MOMENTS_M4S"); 411 439 @>PS1_V2,PS1_SV?@ source->moments->Myyyy = 0.0; 440 441 // Lensing parameters (on read if PS1_V5+) 442 if (haveLensOBJ) { 443 source->lensingOBJ = pmSourceLensingAlloc (); 444 source->lensingOBJ->smear = pmLensingParsAlloc(); 445 source->lensingOBJ->shear = pmLensingParsAlloc(); 446 447 @>PS1_V4@ source->lensingOBJ->smear->X11 = psMetadataLookupF32 (&status, row, "LENS_X11_SM_OBJ"); 448 @>PS1_V4@ source->lensingOBJ->smear->X12 = psMetadataLookupF32 (&status, row, "LENS_X12_SM_OBJ"); 449 @>PS1_V4@ source->lensingOBJ->smear->X22 = psMetadataLookupF32 (&status, row, "LENS_X22_SM_OBJ"); 450 @>PS1_V4@ source->lensingOBJ->smear->e1 = psMetadataLookupF32 (&status, row, "LENS_E1_SM_OBJ"); 451 @>PS1_V4@ source->lensingOBJ->smear->e2 = psMetadataLookupF32 (&status, row, "LENS_E2_SM_OBJ"); 452 @>PS1_V4@ source->lensingOBJ->shear->X11 = psMetadataLookupF32 (&status, row, "LENS_X11_SH_OBJ"); 453 @>PS1_V4@ source->lensingOBJ->shear->X12 = psMetadataLookupF32 (&status, row, "LENS_X12_SH_OBJ"); 454 @>PS1_V4@ source->lensingOBJ->shear->X22 = psMetadataLookupF32 (&status, row, "LENS_X22_SH_OBJ"); 455 @>PS1_V4@ source->lensingOBJ->shear->e1 = psMetadataLookupF32 (&status, row, "LENS_E1_SH_OBJ"); 456 @>PS1_V4@ source->lensingOBJ->shear->e2 = psMetadataLookupF32 (&status, row, "LENS_E2_SH_OBJ"); 457 } 458 459 if (haveLensPSF) { 460 source->lensingPSF = pmSourceLensingAlloc (); 461 source->lensingPSF->smear = pmLensingParsAlloc(); 462 source->lensingPSF->shear = pmLensingParsAlloc(); 463 464 @>PS1_V4@ source->lensingPSF->smear->X11 = psMetadataLookupF32 (&status, row, "LENS_X11_SM_PSF"); 465 @>PS1_V4@ source->lensingPSF->smear->X12 = psMetadataLookupF32 (&status, row, "LENS_X12_SM_PSF"); 466 @>PS1_V4@ source->lensingPSF->smear->X22 = psMetadataLookupF32 (&status, row, "LENS_X22_SM_PSF"); 467 @>PS1_V4@ source->lensingPSF->smear->e1 = psMetadataLookupF32 (&status, row, "LENS_E1_SM_PSF"); 468 @>PS1_V4@ source->lensingPSF->smear->e2 = psMetadataLookupF32 (&status, row, "LENS_E2_SM_PSF"); 469 @>PS1_V4@ source->lensingPSF->shear->X11 = psMetadataLookupF32 (&status, row, "LENS_X11_SH_PSF"); 470 @>PS1_V4@ source->lensingPSF->shear->X12 = psMetadataLookupF32 (&status, row, "LENS_X12_SH_PSF"); 471 @>PS1_V4@ source->lensingPSF->shear->X22 = psMetadataLookupF32 (&status, row, "LENS_X22_SH_PSF"); 472 @>PS1_V4@ source->lensingPSF->shear->e1 = psMetadataLookupF32 (&status, row, "LENS_E1_SH_PSF"); 473 @>PS1_V4@ source->lensingPSF->shear->e2 = psMetadataLookupF32 (&status, row, "LENS_E2_SH_PSF"); 474 } 412 475 413 476 @>PS1_V2,PS1_SV?,>PS1_DV1@ source->moments->Mrf = psMetadataLookupF32 (&status, row, "MOMENTS_R1"); … … 482 545 } 483 546 547 #ifdef SORT_EXTENSIONS_BY_FLUX 484 548 // let's write these out in S/N order 485 549 sources = psArraySort (sources, pmSourceSortByFlux); 550 #endif 486 551 487 552 table = psArrayAllocEmpty (sources->n); … … 563 628 // XXX note that this mag is either calibrated or instrumental depending on existence of zero point 564 629 float mag = (extpars->petrosianFlux > 0.0) ? -2.5*log10(extpars->petrosianFlux) + magOffset : NAN; // XXX zero point 630 // XXX NOTE EAM 20140806 : PETRO_MAG_ERR is inverted!! oops!! 565 631 float magErr = (extpars->petrosianFlux > 0.0) ? extpars->petrosianFlux / extpars->petrosianFluxErr : NAN; // XXX zero point 566 632 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG", PS_DATA_F32, "Petrosian Magnitude", mag); … … 821 887 psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "xsrc table extension", extname); 822 888 889 #ifdef SORT_EXTENSIONS_BY_FLUX 823 890 // let's write these out in S/N order 824 891 sources = psArraySort (sources, pmSourceSortByFlux); 892 #endif 825 893 826 894 float magOffset; … … 847 915 } 848 916 849 @>PS1_DV2 @ pmChip *chip = readout->parent->parent;917 @>PS1_DV2,>PS1_SV3@ pmChip *chip = readout->parent->parent; 850 918 851 919 pmModelStatus badModel = PM_MODEL_STATUS_NONE; … … 906 974 } 907 975 908 @>PS1_DV2 @ psSphere ptSky = {0.0, 0.0, 0.0, 0.0};909 @>PS1_DV2 @ float posAngle = 0.0;910 @>PS1_DV2 @ float pltScale = 0.0;911 @>PS1_DV2 @ pmSourceLocalAstrometry (&ptSky, &posAngle, &pltScale, chip, xPos, yPos);912 @>PS1_DV2 @ double raPos = ptSky.r*PS_DEG_RAD;913 @>PS1_DV2 @ double decPos = ptSky.d*PS_DEG_RAD;914 @>PS1_DV2 @ posAngle *= PS_DEG_RAD;915 @>PS1_DV2 @ pltScale *= PS_DEG_RAD*3600.0;976 @>PS1_DV2,>PS1_SV3@ psSphere ptSky = {0.0, 0.0, 0.0, 0.0}; 977 @>PS1_DV2,>PS1_SV3@ float posAngle = 0.0; 978 @>PS1_DV2,>PS1_SV3@ float pltScale = 0.0; 979 @>PS1_DV2,>PS1_SV3@ pmSourceLocalAstrometry (&ptSky, &posAngle, &pltScale, chip, xPos, yPos); 980 @>PS1_DV2,>PS1_SV3@ double raPos = ptSky.r*PS_DEG_RAD; 981 @>PS1_DV2,>PS1_SV3@ double decPos = ptSky.d*PS_DEG_RAD; 982 @>PS1_DV2,>PS1_SV3@ posAngle *= PS_DEG_RAD; 983 @>PS1_DV2,>PS1_SV3@ pltScale *= PS_DEG_RAD*3600.0; 916 984 917 985 float kronFlux = source->moments ? source->moments->KronFlux : NAN; … … 927 995 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT_SIG", 0, "Sigma in EXT x coordinate", xErr); 928 996 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT_SIG", 0, "Sigma in EXT y coordinate", yErr); 929 @>PS1_DV2 @ psMetadataAddF32 (row, PS_LIST_TAIL, "RA_EXT", 0, "EXT model ra coordinate", raPos);930 @>PS1_DV2 @ psMetadataAddF32 (row, PS_LIST_TAIL, "DEC_EXT", 0, "EXT model dec coordinate", decPos);997 @>PS1_DV2,>PS1_SV3@ psMetadataAddF32 (row, PS_LIST_TAIL, "RA_EXT", 0, "EXT model ra coordinate", raPos); 998 @>PS1_DV2,>PS1_SV3@ psMetadataAddF32 (row, PS_LIST_TAIL, "DEC_EXT", 0, "EXT model dec coordinate", decPos); 931 999 @>PS1_DV2@ float instFlux = isfinite(model->mag) ? pow(10.0, -0.4*model->mag) : NAN; 932 1000 @>PS1_DV2@ psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_FLUX", 0, "EXT fit instrumental counts", instFlux); … … 942 1010 943 1011 // EAM : adding for PV2 outputs: 944 @>PS1_SV1@ psMetadataAdd (row, PS_LIST_TAIL, "EXT_FLAGS", PS_DATA_S16, "model fit flags (pmModelStatus)", source->modelEXT ? source->modelEXT->flags : 0);1012 @>PS1_SV1@ psMetadataAdd (row, PS_LIST_TAIL, "EXT_FLAGS", PS_DATA_S16, "model fit flags (pmModelStatus)", model->flags); 945 1013 946 1014 @>PS1_DV2@ psMetadataAddF32 (row, PS_LIST_TAIL, "POSANGLE", 0, "position angle at source (degrees)", posAngle); … … 978 1046 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_THETA_ERR", 0, "EXT angle err (SXY, isnan)", dPAR[PM_PAR_SXY]); 979 1047 } else { 980 psEllipseAxes axes = pmPSF_ModelToAxes (PAR, model-> type);1048 psEllipseAxes axes = pmPSF_ModelToAxes (PAR, model->class->useReff); 981 1049 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MAJ", 0, "EXT width (major axis), length for trail", axes.major); 982 1050 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MIN", 0, "EXT width (minor axis), sigma for trail", axes.minor); … … 1109 1177 model->chisq = psMetadataLookupF32(&status, row, "EXT_CHISQ"); 1110 1178 model->nDOF = psMetadataLookupF32(&status, row, "EXT_NDOF"); 1179 model->flags = psMetadataLookupS16(&status, row, "EXT_FLAGS"); 1111 1180 1112 1181 // EXT_MODEL_TYPE gives the model chosen by psphot as the best. … … 1127 1196 axes.minor = psMetadataLookupF32(&status, row, "EXT_WIDTH_MIN"); 1128 1197 axes.theta = psMetadataLookupF32(&status, row, "EXT_THETA"); 1129 if (!pmPSF_AxesToModel(PAR, axes, model Type)) {1198 if (!pmPSF_AxesToModel(PAR, axes, model->class->useReff)) { 1130 1199 // Do we need to fail here or can this happen? 1131 1200 psError(PS_ERR_UNKNOWN, false, "Failed to convert psf axes to model"); … … 1225 1294 psVector *fwhmValues = psMetadataLookupVector(&status, readout->analysis, "STACK.PSF.FWHM.VALUES"); 1226 1295 1296 #ifdef SORT_EXTENSIONS_BY_FLUX 1227 1297 // let's write these out in S/N order 1228 1298 sources = psArraySort (sources, pmSourceSortByFlux); 1299 #endif 1229 1300 1230 1301 table = psArrayAllocEmpty (sources->n); … … 1439 1510 psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "galaxy table extension", extname); 1440 1511 1441 psMetadataAddStr (outhead, PS_LIST_TAIL, "HI", PS_META_REPLACE, "does this get through?", "THERE"); 1442 1443 // let's write these out in S/N order 1444 sources = psArraySort (sources, pmSourceSortByFlux); 1512 psF32 Q = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_Q"); 1513 psMetadataAddF32 (outhead, PS_LIST_TAIL, "GALAXY_SHAPES_Q", PS_META_REPLACE, "", Q); 1514 1515 psF32 NSigma = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_NSIGMA"); 1516 psMetadataAddF32 (outhead, PS_LIST_TAIL, "GALAXY_SHAPES_NSIGMA", PS_META_REPLACE, "", NSigma); 1517 1518 psF32 clampSN = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_CLAMP_SN"); 1519 psMetadataAddF32 (outhead, PS_LIST_TAIL, "GALAXY_SHAPES_CLAMP_SN", PS_META_REPLACE, "", clampSN); 1520 1521 // They are probably already in this order but ... 1522 sources = psArraySort (sources, pmSourceSortBySeq); 1445 1523 1446 1524 psArray *table = psArrayAllocEmpty (sources->n); … … 1459 1537 if (source->galaxyFits == NULL) continue; 1460 1538 1461 pmModel *model = source->modelFits->data[0]; 1462 if (!model) return false; 1463 1464 // X,Y coordinates are stored with the model parameters 1465 psF32 *PAR = model->params->data.F32; 1466 1467 psMetadata *row = psMetadataAlloc (); 1468 1469 // we write out the x,y positions so people can link to the psf either way (position or ID) 1470 psMetadataAddU32 (row, PS_LIST_TAIL, "IPP_IDET", 0, "IPP detection identifier index", source->seq); 1471 psMetadataAddF32 (row, PS_LIST_TAIL, "X_FIT", 0, "model x coordinate", PAR[PM_PAR_XPOS]); 1472 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_FIT", 0, "model y coordinate", PAR[PM_PAR_YPOS]); 1473 psMetadataAddF32 (row, PS_LIST_TAIL, "NPIX", 0, "number of pixels for fits", source->galaxyFits->nPix); 1474 1475 psVector *Flux = source->galaxyFits->Flux; 1476 psVector *dFlux = source->galaxyFits->dFlux; 1477 psVector *chisq = source->galaxyFits->chisq; 1478 1479 psMetadataAddVector (row, PS_LIST_TAIL, "GAL_FLUX", PS_META_REPLACE, "normalization for galaxy flux", Flux); 1480 psMetadataAddVector (row, PS_LIST_TAIL, "GAL_FLUX_ERR", PS_META_REPLACE, "error on normalization", dFlux); 1481 psMetadataAddVector (row, PS_LIST_TAIL, "GAL_CHISQ", PS_META_REPLACE, "galaxy fit chisq", chisq); 1482 1483 psArrayAdd (table, 100, row); 1484 psFree (row); 1539 for (int iModel = 0; iModel < source->modelFits->n; iModel++) { 1540 pmModel *model = source->modelFits->data[iModel]; 1541 if (!model) continue; 1542 1543 pmSourceGalaxyFits *galaxyFits = NULL; 1544 for (int iFit = 0; iFit < source->galaxyFits->n; iFit++) { 1545 galaxyFits = source->galaxyFits->data[iFit]; 1546 if (model->type == galaxyFits->modelType) break; 1547 galaxyFits = NULL; 1548 } 1549 1550 if (!galaxyFits) continue; 1551 1552 // X,Y coordinates are stored with the model parameters 1553 psF32 *PAR = model->params->data.F32; 1554 1555 psMetadata *row = psMetadataAlloc (); 1556 1557 // we write out the x,y positions so people can link to the psf either way (position or ID) 1558 psMetadataAddU32 (row, PS_LIST_TAIL, "IPP_IDET", 0, "IPP detection identifier index", source->seq); 1559 psMetadataAddS32 (row, PS_LIST_TAIL, "MODEL_TYPE", 0, "model type", galaxyFits->modelType); 1560 psMetadataAddF32 (row, PS_LIST_TAIL, "X_FIT", 0, "model x coordinate", PAR[PM_PAR_XPOS]); 1561 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_FIT", 0, "model y coordinate", PAR[PM_PAR_YPOS]); 1562 psMetadataAddF32 (row, PS_LIST_TAIL, "NPIX", 0, "number of pixels for fits", galaxyFits->nPix); 1563 // psMetadataAddS32 (row, PS_LIST_TAIL, "REDUCED_TRIALS", 0, "source has reduced number of trials", galaxyFits->reducedTrials); 1564 1565 psVector *Flux = galaxyFits->Flux; 1566 psVector *dFlux = galaxyFits->dFlux; 1567 psVector *chisq = galaxyFits->chisq; 1568 1569 psMetadataAddVector (row, PS_LIST_TAIL, "GAL_FLUX", PS_META_REPLACE, "normalization for galaxy flux", Flux); 1570 psMetadataAddVector (row, PS_LIST_TAIL, "GAL_FLUX_ERR", PS_META_REPLACE, "error on normalization", dFlux); 1571 psMetadataAddVector (row, PS_LIST_TAIL, "GAL_CHISQ", PS_META_REPLACE, "galaxy fit chisq", chisq); 1572 1573 psMetadataAddF32 (row, PS_LIST_TAIL, "FR_MAJOR_MIN", 0, "fractional major axis min", galaxyFits->fRmajorMin); 1574 psMetadataAddF32 (row, PS_LIST_TAIL, "FR_MAJOR_MAX", 0, "fractional major axis max", galaxyFits->fRmajorMax); 1575 psMetadataAddF32 (row, PS_LIST_TAIL, "FR_MAJOR_DEL", 0, "fractional major axis max", galaxyFits->fRmajorDel); 1576 psMetadataAddF32 (row, PS_LIST_TAIL, "FR_MINOR_MIN", 0, "fractional minor axis min", galaxyFits->fRminorMin); 1577 psMetadataAddF32 (row, PS_LIST_TAIL, "FR_MINOR_MAX", 0, "fractional minor axis max", galaxyFits->fRminorMax); 1578 psMetadataAddF32 (row, PS_LIST_TAIL, "FR_MINOR_DEL", 0, "fractional minor axis max", galaxyFits->fRminorDel); 1579 1580 psArrayAdd (table, 100, row); 1581 psFree (row); 1582 } 1485 1583 } 1486 1584 … … 1520 1618 return false; 1521 1619 } 1620 if (!readout->analysis) { 1621 readout->analysis = psMetadataAlloc(); 1622 } 1623 psF32 Q = psMetadataLookupF32(&status, tableHeader, "GALAXY_SHAPES_Q"); 1624 // XXX: turn this into an assert once we're done 1625 if (status) { 1626 psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "GALAXY_SHAPES_Q", PS_META_REPLACE, "", Q); 1627 1628 psF32 NSigma = psMetadataLookupF32(&status, tableHeader, "GALAXY_SHAPES_NSIGMA"); 1629 psAssert(status, "missing GALAXY_SHAPES_NSIGMA"); 1630 psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "GALAXY_SHAPES_NSIGMA", PS_META_REPLACE, "", NSigma); 1631 1632 psF32 clampSN = psMetadataLookupF32(&status, tableHeader, "GALAXY_SHAPES_CLAMP_SN"); 1633 psAssert(status, "missing GALAXY_SHAPES_CLAMP_SN"); 1634 psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "GALAXY_SHAPES_CLAMP_SN", PS_META_REPLACE, "", clampSN); 1635 } 1522 1636 1523 1637 for (long i = 0; i < numSources; i++) { … … 1541 1655 } 1542 1656 1657 int modelType = psMetadataLookupS32 (&status, row, "MODEL_TYPE"); 1543 1658 psVector *Flux = psMetadataLookupVector(&status, row, "GAL_FLUX"); 1544 1659 psVector *dFlux = psMetadataLookupVector(&status, row, "GAL_FLUX_ERR"); … … 1546 1661 1547 1662 if (Flux && Flux->n > 0) { 1548 psFree(source->galaxyFits); 1549 source->galaxyFits = pmSourceGalaxyFitsAlloc(); 1550 source->galaxyFits->nPix = psMetadataLookupF32(&status, row, "NPIX"); 1551 1552 psFree(source->galaxyFits->Flux); 1553 source->galaxyFits->Flux = psMemIncrRefCounter(Flux); 1554 psFree(source->galaxyFits->dFlux); 1555 source->galaxyFits->dFlux = psMemIncrRefCounter(dFlux); 1556 psFree(source->galaxyFits->chisq); 1557 source->galaxyFits->chisq = psMemIncrRefCounter(chisq); 1663 if (!source->galaxyFits) { 1664 source->galaxyFits = psArrayAllocEmpty(1); 1665 } 1666 1667 pmSourceGalaxyFits *galaxyFits = pmSourceGalaxyFitsAlloc(); 1668 1669 psArrayAdd(source->galaxyFits, 1, galaxyFits); 1670 1671 psFree(galaxyFits); 1672 galaxyFits->modelType = modelType; 1673 galaxyFits->nPix = psMetadataLookupF32(&status, row, "NPIX"); 1674 1675 galaxyFits->fRmajorMin = psMetadataLookupF32(&status, row, "FR_MAJOR_MIN"); 1676 galaxyFits->fRmajorMax = psMetadataLookupF32(&status, row, "FR_MAJOR_MAX"); 1677 galaxyFits->fRmajorDel = psMetadataLookupF32(&status, row, "FR_MAJOR_DEL"); 1678 galaxyFits->fRminorMin = psMetadataLookupF32(&status, row, "FR_MINOR_MIN"); 1679 galaxyFits->fRminorMax = psMetadataLookupF32(&status, row, "FR_MINOR_MAX"); 1680 galaxyFits->fRminorDel = psMetadataLookupF32(&status, row, "FR_MINOR_DEL"); 1681 1682 psFree(galaxyFits->Flux); 1683 galaxyFits->Flux = psMemIncrRefCounter(Flux); 1684 psFree(galaxyFits->dFlux); 1685 galaxyFits->dFlux = psMemIncrRefCounter(dFlux); 1686 psFree(galaxyFits->chisq); 1687 galaxyFits->chisq = psMemIncrRefCounter(chisq); 1558 1688 } 1559 1689 -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceIO_CMP.c
r36680 r37403 37 37 #include "pmMoments.h" 38 38 #include "pmModelFuncs.h" 39 #include "pmModelClass.h" 39 40 #include "pmModel.h" 40 41 #include "pmModelUtils.h" 41 #include "pmModelClass.h"42 42 #include "pmSourceMasks.h" 43 43 #include "pmSourceExtendedPars.h" … … 136 136 lsky = (source->sky < 1.0) ? 0.0 : log10(source->sky); 137 137 138 axes = pmPSF_ModelToAxes (PAR, model-> type);138 axes = pmPSF_ModelToAxes (PAR, model->class->useReff); 139 139 140 140 float psfMagErr = isfinite(source->psfMagErr) ? source->psfMagErr : 999; … … 293 293 goto skip_source; 294 294 295 pmPSF_AxesToModel (PAR, axes, modelType);295 pmPSF_AxesToModel (PAR, axes, source->modelPSF->class->useReff); 296 296 297 297 psArrayAdd (sources, 100, source); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceIO_MatchedRefs.c
r36680 r37403 37 37 #include "pmMoments.h" 38 38 #include "pmModelFuncs.h" 39 #include "pmModelClass.h" 39 40 #include "pmModel.h" 40 41 #include "pmModelUtils.h" 41 #include "pmModelClass.h"42 42 #include "pmSourceMasks.h" 43 43 #include "pmSourceExtendedPars.h" … … 99 99 100 100 // select the raw objects for this readout 101 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS ");101 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS.SUBSET"); 102 102 if (rawstars == NULL) continue; 103 103 104 104 // select the raw objects for this readout 105 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS ");105 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS.SUBSET"); 106 106 if (refstars == NULL) continue; 107 107 psTrace ("psastro", 4, "Trying %ld refstars\n", refstars->n); 108 109 # if (0)110 // XXX test111 FILE *outfile = fopen ("refstars.dat", "w");112 assert (outfile);113 for (int nn = 0; nn < refstars->n; nn++) {114 pmAstromObj *ref = refstars->data[nn];115 fprintf (outfile, "%lf %lf\n", ref->sky->r*PS_DEG_RAD, ref->sky->d*PS_DEG_RAD);116 }117 fclose (outfile);118 # endif119 108 120 109 psArray *matches = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.MATCH"); … … 128 117 129 118 psMetadata *row = psMetadataAlloc (); 130 psMetadataAdd (row, PS_LIST_TAIL, "RA", PS_DATA_F64, "right ascension (deg, J2000)", PM_DEG_RAD*ref->sky->r); 131 psMetadataAdd (row, PS_LIST_TAIL, "DEC", PS_DATA_F64, "declination (deg, J2000)", PM_DEG_RAD*ref->sky->d); 132 psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP", PS_DATA_F32, "x coord on chip", raw->chip->x); 133 psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP", PS_DATA_F32, "y coord on chip", raw->chip->y); 134 psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP_FIT",PS_DATA_F32, "x fitted coord on chip", ref->chip->x); 135 psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP_FIT",PS_DATA_F32, "y fitted coord on chip", ref->chip->y); 136 psMetadataAdd (row, PS_LIST_TAIL, "X_FPA", PS_DATA_F32, "x coord on focal plane", raw->FP->x); 137 psMetadataAdd (row, PS_LIST_TAIL, "Y_FPA", PS_DATA_F32, "y coord on focal plane", raw->FP->y); 138 psMetadataAdd (row, PS_LIST_TAIL, "MAG_INST", PS_DATA_F32, "instrumental magnitude", raw->Mag); 139 psMetadataAdd (row, PS_LIST_TAIL, "MAG_REF", PS_DATA_F32, "reference star magnitude", ref->Mag); 140 psMetadataAdd (row, PS_LIST_TAIL, "COLOR_REF",PS_DATA_F32, "reference star color", ref->Color); 141 psMetadataAdd (row, PS_LIST_TAIL, "CHIP_ID", PS_DATA_STRING, "chip identifier", chipName); 119 psMetadataAdd (row, PS_LIST_TAIL, "RA_REF", PS_DATA_F64, "right ascension (deg, J2000)", PM_DEG_RAD*ref->sky->r); 120 psMetadataAdd (row, PS_LIST_TAIL, "DEC_REF", PS_DATA_F64, "declination (deg, J2000)", PM_DEG_RAD*ref->sky->d); 121 psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP_REF", PS_DATA_F32, "x fitted coord on chip", ref->chip->x); 122 psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP_REF", PS_DATA_F32, "y fitted coord on chip", ref->chip->y); 123 psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP_RAW", PS_DATA_F32, "x coord on chip", raw->chip->x); 124 psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP_RAW", PS_DATA_F32, "y coord on chip", raw->chip->y); 125 psMetadataAdd (row, PS_LIST_TAIL, "X_FPA_RAW", PS_DATA_F32, "x coord on focal plane", raw->FP->x); 126 psMetadataAdd (row, PS_LIST_TAIL, "Y_FPA_RAW", PS_DATA_F32, "y coord on focal plane", raw->FP->y); 127 psMetadataAdd (row, PS_LIST_TAIL, "X_TPA_RAW", PS_DATA_F32, "x coord on focal plane", raw->TP->x); 128 psMetadataAdd (row, PS_LIST_TAIL, "Y_TPA_RAW", PS_DATA_F32, "y coord on focal plane", raw->TP->y); 129 psMetadataAdd (row, PS_LIST_TAIL, "MAG_INST", PS_DATA_F32, "instrumental magnitude", raw->Mag); 130 psMetadataAdd (row, PS_LIST_TAIL, "MAG_REF", PS_DATA_F32, "reference star magnitude", ref->Mag); 131 psMetadataAdd (row, PS_LIST_TAIL, "COLOR_REF", PS_DATA_F32, "reference star color", ref->Color); 132 psMetadataAdd (row, PS_LIST_TAIL, "CHIP_ID", PS_DATA_STRING, "chip identifier", chipName); 142 133 // XXX need to add the reference color, but this needs getstar / dvo.photcodes for the reference to be refined. 143 134 -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceIO_OBJ.c
r36680 r37403 37 37 #include "pmMoments.h" 38 38 #include "pmModelFuncs.h" 39 #include "pmModelClass.h" 39 40 #include "pmModel.h" 40 41 #include "pmModelUtils.h" 41 #include "pmModelClass.h"42 42 #include "pmSourceMasks.h" 43 43 #include "pmSourceExtendedPars.h" … … 93 93 } 94 94 95 axes = pmPSF_ModelToAxes (PAR, model-> type);95 axes = pmPSF_ModelToAxes (PAR, model->class->useReff); 96 96 97 97 psLineInit (line); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceIO_PS1_CAL_0.c
r36680 r37403 37 37 #include "pmMoments.h" 38 38 #include "pmModelFuncs.h" 39 #include "pmModelClass.h" 39 40 #include "pmModel.h" 40 41 #include "pmModelUtils.h" 41 #include "pmModelClass.h"42 42 #include "pmSourceMasks.h" 43 43 #include "pmSourceExtendedPars.h" … … 115 115 yErr = dPAR[PM_PAR_YPOS]; 116 116 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX])) { 117 axes = pmPSF_ModelToAxes (PAR, model-> type);117 axes = pmPSF_ModelToAxes (PAR, model->class->useReff); 118 118 } else { 119 119 axes.major = NAN; … … 290 290 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN; 291 291 292 pmPSF_AxesToModel (PAR, axes, model Type);292 pmPSF_AxesToModel (PAR, axes, model->class->useReff); 293 293 294 294 float peakMag = psMetadataLookupF32 (&status, row, "PEAK_FLUX_AS_MAG"); … … 624 624 yErr = dPAR[PM_PAR_YPOS]; 625 625 626 axes = pmPSF_ModelToAxes (PAR, model-> type);626 axes = pmPSF_ModelToAxes (PAR, model->class->useReff); 627 627 628 628 // generate RA,DEC -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceIO_PS1_DEV_0.c
r36680 r37403 37 37 #include "pmMoments.h" 38 38 #include "pmModelFuncs.h" 39 #include "pmModelClass.h" 39 40 #include "pmModel.h" 40 41 #include "pmModelUtils.h" 41 #include "pmModelClass.h"42 42 #include "pmSourceMasks.h" 43 43 #include "pmSourceExtendedPars.h" … … 91 91 yErr = dPAR[PM_PAR_YPOS]; 92 92 93 axes = pmPSF_ModelToAxes (PAR, model-> type);93 axes = pmPSF_ModelToAxes (PAR, model->class->useReff); 94 94 } else { 95 95 // XXX: This code seg faults if source->peak is NULL. … … 216 216 source->psfMagErr = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 217 217 218 pmPSF_AxesToModel (PAR, axes, model Type);218 pmPSF_AxesToModel (PAR, axes, model->class->useReff); 219 219 220 220 float peakMag = psMetadataLookupF32 (&status, row, "PEAK_FLUX_AS_MAG"); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceIO_PS1_DEV_1.c
r36680 r37403 37 37 #include "pmMoments.h" 38 38 #include "pmModelFuncs.h" 39 #include "pmModelClass.h" 39 40 #include "pmModel.h" 40 41 #include "pmModelUtils.h" 41 #include "pmModelClass.h"42 42 #include "pmSourceMasks.h" 43 43 #include "pmSourceExtendedPars.h" … … 97 97 yErr = dPAR[PM_PAR_YPOS]; 98 98 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX])) { 99 axes = pmPSF_ModelToAxes (PAR, model-> type);99 axes = pmPSF_ModelToAxes (PAR, model->class->useReff); 100 100 } else { 101 101 axes.major = NAN; … … 259 259 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN; 260 260 261 pmPSF_AxesToModel (PAR, axes, model Type);261 pmPSF_AxesToModel (PAR, axes, model->class->useReff); 262 262 263 263 float peakMag = psMetadataLookupF32 (&status, row, "PEAK_FLUX_AS_MAG"); … … 524 524 yErr = dPAR[PM_PAR_YPOS]; 525 525 526 axes = pmPSF_ModelToAxes (PAR, model-> type);526 axes = pmPSF_ModelToAxes (PAR, model->class->useReff); 527 527 528 528 row = psMetadataAlloc (); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceIO_RAW.c
r36680 r37403 37 37 #include "pmMoments.h" 38 38 #include "pmModelFuncs.h" 39 #include "pmModelClass.h" 39 40 #include "pmModel.h" 40 41 #include "pmModelUtils.h" 41 #include "pmModelClass.h"42 42 #include "pmSourceMasks.h" 43 43 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceIO_SMPDATA.c
r36680 r37403 37 37 #include "pmMoments.h" 38 38 #include "pmModelFuncs.h" 39 #include "pmModelClass.h" 39 40 #include "pmModel.h" 40 41 #include "pmModelUtils.h" 41 #include "pmModelClass.h"42 42 #include "pmSourceMasks.h" 43 43 #include "pmSourceExtendedPars.h" … … 93 93 lsky = (source->sky < 1.0) ? 0.0 : log10(source->sky); 94 94 95 axes = pmPSF_ModelToAxes (PAR, model-> type);95 axes = pmPSF_ModelToAxes (PAR, model->class->useReff); 96 96 97 97 } else { … … 190 190 axes.theta = psMetadataLookupF32 (&status, row, "THETA"); 191 191 192 pmPSF_AxesToModel (PAR, axes, model Type);192 pmPSF_AxesToModel (PAR, axes, model->class->useReff); 193 193 194 194 source->psfMag = psMetadataLookupF32 (&status, row, "MAG_RAW") - ZERO_POINT; -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceIO_SX.c
r36680 r37403 37 37 #include "pmMoments.h" 38 38 #include "pmModelFuncs.h" 39 #include "pmModelClass.h" 39 40 #include "pmModel.h" 40 41 #include "pmModelUtils.h" 41 #include "pmModelClass.h"42 42 #include "pmSourceMasks.h" 43 43 #include "pmSourceExtendedPars.h" … … 82 82 // pmSourceSextractType (source, &type, &flags); 83 83 84 axes = pmPSF_ModelToAxes (PAR, model-> type);84 axes = pmPSF_ModelToAxes (PAR, model->class->useReff); 85 85 86 86 psLineInit (line); -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceMatch.c
r36680 r37403 18 18 #include "pmMoments.h" 19 19 #include "pmModelFuncs.h" 20 #include "pmModelClass.h" 20 21 #include "pmModel.h" 21 22 #include "pmModelUtils.h" 22 #include "pmModelClass.h"23 23 #include "pmSourceMasks.h" 24 24 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceMoments.c
r36680 r37403 35 35 #include "pmMoments.h" 36 36 #include "pmModelFuncs.h" 37 #include "pmModelClass.h" 37 38 #include "pmModel.h" 38 39 #include "pmModelUtils.h" 39 #include "pmModelClass.h"40 40 #include "pmSourceMasks.h" 41 41 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceOutputs.c
r36680 r37403 26 26 #include "pmMoments.h" 27 27 #include "pmModelFuncs.h" 28 #include "pmModelClass.h" 28 29 #include "pmModel.h" 29 30 #include "pmModelUtils.h" 30 #include "pmModelClass.h"31 31 #include "pmSourceMasks.h" 32 32 #include "pmSourceExtendedPars.h" … … 108 108 } 109 109 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXY]) && isfinite(PAR[PM_PAR_SYY])) { 110 axes = pmPSF_ModelToAxes (PAR, model-> type);110 axes = pmPSF_ModelToAxes (PAR, model->class->useReff); 111 111 outputs->psfMajor = axes.major; 112 112 outputs->psfMinor = axes.minor; 113 113 outputs->psfTheta = axes.theta*PS_DEG_RAD; 114 115 // some models (PS1_V1, QGAUSS) have an extra 'core' parameter 116 outputs->psfCore = NAN; 117 if (model->type == pmModelClassGetType ("PS_MODEL_PS1_V1")) { 118 outputs->psfCore = PAR[PM_PAR_7]; 119 } 120 if (model->type == pmModelClassGetType ("PS_MODEL_QGAUSS")) { 121 outputs->psfCore = PAR[PM_PAR_7]; 122 } 123 124 outputs->psfMajorFWHM = model->class->modelSetFWHM(model->params, axes.major); 125 outputs->psfMinorFWHM = model->class->modelSetFWHM(model->params, axes.minor); 114 126 } else { 115 127 outputs->psfMajor = NAN; 116 128 outputs->psfMinor = NAN; 117 129 outputs->psfTheta = NAN; 130 outputs->psfCore = NAN; 118 131 } 119 132 outputs->chisq = model->chisq; 120 133 outputs->nDOF = model->nDOF; 121 134 outputs->nPix = model->nPix; 122 outputs->apRadius = source->apRadius;123 135 } else { 124 136 bool useMoments = pmSourcePositionUseMoments(source); … … 138 150 outputs->psfMinor = NAN; 139 151 outputs->psfTheta = NAN; 152 outputs->psfCore = NAN; 140 153 outputs->chisq = NAN; 141 154 outputs->nDOF = 0; 142 155 outputs->nPix = 0; 143 outputs->apRadius = NAN;144 156 } 145 157 -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceOutputs.h
r33690 r37403 26 26 float psfMinor; 27 27 float psfTheta; 28 float psfCore; 29 float psfMajorFWHM; 30 float psfMinorFWHM; 28 31 float chisq; 29 float apRadius;30 32 int nPix; 31 33 int nDOF; -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourcePhotometry.c
r36680 r37403 33 33 #include "pmMoments.h" 34 34 #include "pmModelFuncs.h" 35 #include "pmModelClass.h" 35 36 #include "pmModel.h" 36 37 #include "pmModelUtils.h" 37 #include "pmModelClass.h"38 38 #include "pmSourceMasks.h" 39 39 #include "pmSourceExtendedPars.h" … … 330 330 331 331 // measure fitMag 332 flux = model-> modelFlux (model->params);332 flux = model->class->modelFlux (model->params); 333 333 if (flux > 0) { 334 334 mag = -2.5*log10(flux); … … 359 359 360 360 bool status; 361 int nPix = 0; 362 status = pmSourcePhotometryAper(&nPix, &source->apMagRaw, &source->apFlux, &source->apFluxErr, model, image, variance, mask, maskVal); 361 status = pmSourcePhotometryAper(&source->apNpixels, &source->apMagRaw, &source->apFlux, &source->apFluxErr, model, image, variance, mask, maskVal); 363 362 if (status) { 364 363 source->mode |= PM_SOURCE_MODE_AP_MAGS; … … 490 489 491 490 // for the full model, add all points 492 value = fabs(model-> modelFunc (NULL, params, coord) - sky);491 value = fabs(model->class->modelFunc (NULL, params, coord) - sky); 493 492 modelSum += value; 494 493 … … 893 892 894 893 // for the full model, add all points 895 float value = model-> modelFunc (NULL, params, coord);894 float value = model->class->modelFunc (NULL, params, coord); 896 895 897 896 // fprintf (stderr, "%d, %d : %f, %f : %f - %f : %f\n", -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourcePlotApResid.c
r36680 r37403 35 35 #include "pmMoments.h" 36 36 #include "pmModelFuncs.h" 37 #include "pmModelClass.h" 37 38 #include "pmModel.h" 38 39 #include "pmModelUtils.h" 39 #include "pmModelClass.h"40 40 #include "pmSourceMasks.h" 41 41 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourcePlotMoments.c
r36680 r37403 38 38 #include "pmMoments.h" 39 39 #include "pmModelFuncs.h" 40 #include "pmModelClass.h" 40 41 #include "pmModel.h" 41 42 #include "pmModelUtils.h" 42 #include "pmModelClass.h"43 43 #include "pmSourceMasks.h" 44 44 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourcePlotPSFModel.c
r36680 r37403 39 39 #include "pmMoments.h" 40 40 #include "pmModelFuncs.h" 41 #include "pmModelClass.h" 41 42 #include "pmModel.h" 42 43 #include "pmModelUtils.h" 43 #include "pmModelClass.h"44 44 #include "pmSourceMasks.h" 45 45 #include "pmSourceExtendedPars.h" … … 147 147 // force the axis ratio to be < 20.0 148 148 psEllipseAxes axes_mnt = psEllipseMomentsToAxes (moments, 20.0); 149 psEllipseAxes axes_psf = pmPSF_ModelToAxes (PAR, model-> type);149 psEllipseAxes axes_psf = pmPSF_ModelToAxes (PAR, model->class->useReff); 150 150 151 151 // moments major axis -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceSky.c
r36680 r37403 34 34 #include "pmMoments.h" 35 35 #include "pmModelFuncs.h" 36 #include "pmModelClass.h" 36 37 #include "pmModel.h" 37 38 #include "pmModelUtils.h" 38 #include "pmModelClass.h"39 39 #include "pmSourceMasks.h" 40 40 #include "pmSourceExtendedPars.h" -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceUtils.c
r36680 r37403 34 34 #include "pmMoments.h" 35 35 #include "pmModelFuncs.h" 36 #include "pmModelClass.h" 36 37 #include "pmModel.h" 37 38 #include "pmModelUtils.h" 38 #include "pmModelClass.h"39 39 #include "pmSourceMasks.h" 40 40 #include "pmSourceExtendedPars.h" … … 65 65 pmModel *model = pmModelAlloc(modelType); 66 66 67 if (!model-> modelGuess(model, source, maskVal, markVal)) {67 if (!model->class->modelGuess(model, source, maskVal, markVal)) { 68 68 psFree (model); 69 69 return NULL; -
branches/eam_branches/ps2-tc3-20130727/psModules/src/objects/pmSourceVisual.c
r36680 r37403 16 16 #include "pmMoments.h" 17 17 #include "pmModelFuncs.h" 18 #include "pmModelClass.h" 18 19 #include "pmModel.h" 19 20 #include "pmModelUtils.h" 20 #include "pmModelClass.h"21 21 #include "pmSourceMasks.h" 22 22 #include "pmSourceExtendedPars.h" … … 545 545 psFree (model); 546 546 547 bool dumpData = false; 548 547 549 // pause and wait for user input: 548 550 // continue, save (provide name), ?? 549 pmVisualAskUser(&plotPSF); 551 retry: 552 pmVisualAskUserOrDump(&plotPSF, &dumpData); 553 if (dumpData) { 554 char name[128]; 555 fprintf (stderr, "filename: "); 556 int status = fscanf (stdin, "%127s", name); 557 if (status != 1) { 558 fprintf (stderr, "odd response\n"); 559 goto retry; 560 } 561 562 FILE *f = fopen (name, "w"); 563 if (!f) { 564 fprintf (stderr, "cannot open %s for output\n", name); 565 goto retry; 566 } 567 for (int i = 0; i < x->n; i++) { 568 float vModel = pmTrend2DEval (trend, x->data.F32[i], y->data.F32[i]); 569 fprintf (f, "%f %f %f %f %d\n", x->data.F32[i], y->data.F32[i], param->data.F32[i], vModel, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 570 } 571 fclose (f); 572 goto retry; 573 } 550 574 551 575 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
