Changeset 14989
- Timestamp:
- Sep 23, 2007, 5:00:44 PM (19 years ago)
- Location:
- branches/eam_branch_20070921/psModules/src
- Files:
-
- 12 edited
-
camera/pmFPAfileIO.c (modified) (1 diff)
-
objects/models/pmModel_GAUSS.c (modified) (2 diffs)
-
objects/models/pmModel_PGAUSS.c (modified) (2 diffs)
-
objects/models/pmModel_QGAUSS.c (modified) (2 diffs)
-
objects/models/pmModel_RGAUSS.c (modified) (2 diffs)
-
objects/models/pmModel_SERSIC.c (modified) (2 diffs)
-
objects/pmPSF.c (modified) (7 diffs)
-
objects/pmPSF.h (modified) (3 diffs)
-
objects/pmPSF_IO.c (modified) (11 diffs)
-
objects/pmSourcePhotometry.c (modified) (4 diffs)
-
objects/pmTrend2D.c (modified) (6 diffs)
-
objects/pmTrend2D.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070921/psModules/src/camera/pmFPAfileIO.c
r14938 r14989 774 774 } 775 775 pmFPAview *thisView = pmFPAAddSourceFromHeader (file->fpa, phu, file->format); 776 assert (thisView); // XXX we are having some trouble with input psf files not having the Cell and fpa names matching. 776 777 psFree (thisView); 777 778 psFree (phu); -
branches/eam_branch_20070921/psModules/src/objects/models/pmModel_GAUSS.c
r14652 r14989 274 274 out[i] = in[i]; 275 275 } else { 276 p sPolynomial2D *poly= psf->params->data[i];277 out[i] = p sPolynomial2DEval(poly, in[PM_PAR_XPOS], in[PM_PAR_YPOS]);276 pmTrend2D *trend = psf->params->data[i]; 277 out[i] = pmTrend2DEval(trend, in[PM_PAR_XPOS], in[PM_PAR_YPOS]); 278 278 } 279 279 } … … 331 331 if (i == PM_PAR_XPOS) continue; 332 332 if (i == PM_PAR_YPOS) continue; 333 psPolynomial2D *poly = psf->params->data[i]; 334 assert (poly); 335 PAR[i] = psPolynomial2DEval(poly, Xo, Yo); 333 pmTrend2D *trend = psf->params->data[i]; 334 PAR[i] = pmTrend2DEval(trend, Xo, Yo); 336 335 } 337 336 -
branches/eam_branch_20070921/psModules/src/objects/models/pmModel_PGAUSS.c
r14652 r14989 328 328 out[i] = in[i]; 329 329 } else { 330 p sPolynomial2D *poly= psf->params->data[i];331 out[i] = p sPolynomial2DEval(poly, in[PM_PAR_XPOS], in[PM_PAR_YPOS]);330 pmTrend2D *trend = psf->params->data[i]; 331 out[i] = pmTrend2DEval(trend, in[PM_PAR_XPOS], in[PM_PAR_YPOS]); 332 332 } 333 333 } … … 384 384 if (i == PM_PAR_XPOS) continue; 385 385 if (i == PM_PAR_YPOS) continue; 386 psPolynomial2D *poly = psf->params->data[i]; 387 assert (poly); 388 PAR[i] = psPolynomial2DEval(poly, Xo, Yo); 386 pmTrend2D *trend = psf->params->data[i]; 387 PAR[i] = pmTrend2DEval(trend, Xo, Yo); 389 388 } 390 389 -
branches/eam_branch_20070921/psModules/src/objects/models/pmModel_QGAUSS.c
r14652 r14989 358 358 out[i] = in[i]; 359 359 } else { 360 p sPolynomial2D *poly= psf->params->data[i];361 out[i] = p sPolynomial2DEval(poly, in[PM_PAR_XPOS], in[PM_PAR_YPOS]);360 pmTrend2D *trend = psf->params->data[i]; 361 out[i] = pmTrend2DEval(trend, in[PM_PAR_XPOS], in[PM_PAR_YPOS]); 362 362 } 363 363 } … … 412 412 if (i == PM_PAR_XPOS) continue; 413 413 if (i == PM_PAR_YPOS) continue; 414 psPolynomial2D *poly = psf->params->data[i]; 415 assert (poly); 416 PAR[i] = psPolynomial2DEval(poly, Xo, Yo); 414 pmTrend2D *trend = psf->params->data[i]; 415 PAR[i] = pmTrend2DEval(trend, Xo, Yo); 417 416 } 418 417 -
branches/eam_branch_20070921/psModules/src/objects/models/pmModel_RGAUSS.c
r14652 r14989 351 351 out[i] = in[i]; 352 352 } else { 353 p sPolynomial2D *poly= psf->params->data[i];354 out[i] = p sPolynomial2DEval(poly, in[PM_PAR_XPOS], in[PM_PAR_YPOS]);353 pmTrend2D *trend = psf->params->data[i]; 354 out[i] = pmTrend2DEval(trend, in[PM_PAR_XPOS], in[PM_PAR_YPOS]); 355 355 } 356 356 } … … 405 405 if (i == PM_PAR_XPOS) continue; 406 406 if (i == PM_PAR_YPOS) continue; 407 psPolynomial2D *poly = psf->params->data[i]; 408 assert (poly); 409 PAR[i] = psPolynomial2DEval(poly, Xo, Yo); 407 pmTrend2D *trend = psf->params->data[i]; 408 PAR[i] = pmTrend2DEval(trend, Xo, Yo); 410 409 } 411 410 -
branches/eam_branch_20070921/psModules/src/objects/models/pmModel_SERSIC.c
r14669 r14989 343 343 out[i] = in[i]; 344 344 } else { 345 p sPolynomial2D *poly= psf->params->data[i];346 out[i] = p sPolynomial2DEval(poly, in[PM_PAR_XPOS], in[PM_PAR_YPOS]);345 pmTrend2D *trend = psf->params->data[i]; 346 out[i] = pmTrend2DEval(trend, in[PM_PAR_XPOS], in[PM_PAR_YPOS]); 347 347 } 348 348 } … … 397 397 if (i == PM_PAR_XPOS) continue; 398 398 if (i == PM_PAR_YPOS) continue; 399 psPolynomial2D *poly = psf->params->data[i]; 400 assert (poly); 401 PAR[i] = psPolynomial2DEval(poly, Xo, Yo); 399 pmTrend2D *trend = psf->params->data[i]; 400 PAR[i] = pmTrend2DEval(trend, Xo, Yo); 402 401 } 403 402 -
branches/eam_branch_20070921/psModules/src/objects/pmPSF.c
r14986 r14989 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.28.2. 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-09-2 2 13:47:28$8 * @version $Revision: 1.28.2.5 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-09-24 03:00:44 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 48 48 if (!options) return; 49 49 50 psFree (options->image);51 50 psFree (options->stats); 52 51 return; … … 60 59 options->type = 0; 61 60 62 options->image = NULL;63 61 options->stats = NULL; 64 62 … … 66 64 options->psfTrendNx = 0; 67 65 options->psfTrendNy = 0; 66 options->psfFieldNx = 0; 67 options->psfFieldNy = 0; 68 options->psfFieldXo = 0; 69 options->psfFieldYo = 0; 68 70 69 71 options->poissonErrorsPhotLMM = true; … … 84 86 85 87 psFree (psf->ChiTrend); 88 psFree (psf->psfTrendStats); 86 89 psFree (psf->ApTrend); 87 90 psFree (psf->FluxScale); … … 164 167 // PM_PAR_XPOS, etc) 165 168 166 psf->Nx = options->image->numCols; 167 psf->Ny = options->image->numRows; 169 psImageBinning *binning = psImageBinningAlloc(); 170 binning->nXruff = options->psfTrendNx; 171 binning->nYruff = options->psfTrendNy; 172 binning->nXfine = options->psfFieldNx; 173 binning->nYfine = options->psfFieldNy; 174 psImageBinningSetSkipByOffset (binning, options->psfFieldXo, options->psfFieldYo); 175 176 psf->fieldNx = options->psfFieldNx; 177 psf->fieldNy = options->psfFieldNy; 178 psf->fieldXo = options->psfFieldXo; 179 psf->fieldYo = options->psfFieldYo; 168 180 169 181 // define the parameter trends … … 175 187 if (i == PM_PAR_YPOS) continue; 176 188 177 psf->params->data[i] = pmTrend2D Alloc (options->psfTrendMode, options->image, options->psfTrendNx, options->psfTrendNx, options->stats);189 psf->params->data[i] = pmTrend2DNoImageAlloc (options->psfTrendMode, binning, options->stats); 178 190 } 179 191 } 192 psFree (binning); 180 193 return psf; 181 194 } -
branches/eam_branch_20070921/psModules/src/objects/pmPSF.h
r14986 r14989 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.16.2. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-09-2 2 13:47:28$8 * @version $Revision: 1.16.2.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-09-24 03:00:44 $ 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 11 11 */ … … 47 47 int nPSFstars; ///< number of stars used to measure PSF 48 48 int nApResid; ///< number of stars used to measure ApResid 49 int Nx, Ny; ///< reference image dimensions 49 int fieldNx; 50 int fieldNy; 51 int fieldXo; 52 int fieldYo; 50 53 bool poissonErrorsPhotLMM; ///< use poission errors for non-linear model fitting 51 54 bool poissonErrorsPhotLin; ///< use poission errors for linear model fitting … … 58 61 typedef struct { 59 62 pmModelType type; 60 psImage *image; // image for which the PSF is defined61 63 psStats *stats; // psfTrend clipping stats 62 64 pmTrend2DMode psfTrendMode; 63 65 int psfTrendNx; 64 66 int psfTrendNy; 67 int psfFieldNx; 68 int psfFieldNy; 69 int psfFieldXo; 70 int psfFieldYo; 65 71 bool poissonErrorsPhotLMM; ///< use poission errors for non-linear model fitting 66 72 bool poissonErrorsPhotLin; ///< use poission errors for linear model fitting 67 73 bool poissonErrorsParams; ///< use poission errors for model parameter fitting 68 74 float radius; 69 70 75 } pmPSFOptions; 71 76 -
branches/eam_branch_20070921/psModules/src/objects/pmPSF_IO.c
r14986 r14989 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.22.2. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-09-2 2 13:47:28$8 * @version $Revision: 1.22.2.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-09-24 03:00:44 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 163 163 if (!analysis) return false; 164 164 165 // select the current recipe 166 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, "PSPHOT"); 167 if (!recipe) { 168 psError(PS_ERR_UNKNOWN, false, "missing recipe %s", "PSPHOT"); 169 return false; 170 } 171 165 172 // write a PHU? (only if input image is MEF) 166 173 // write a header? (only if this is the first readout for cell) … … 260 267 psMetadataAdd (header, PS_LIST_TAIL, "PSF_NPAR", PS_DATA_S32, "PSF model parameter count", nPar); 261 268 262 psMetadataAddS32 (header, PS_LIST_TAIL, "IMAXIS1", 0, "Image X Size", psf->Nx); 263 psMetadataAddS32 (header, PS_LIST_TAIL, "IMAXIS2", 0, "Image Y Size", psf->Ny); 269 psMetadataAddS32 (header, PS_LIST_TAIL, "IMAXIS1", 0, "Image X Size", psf->fieldNx); 270 psMetadataAddS32 (header, PS_LIST_TAIL, "IMAXIS2", 0, "Image Y Size", psf->fieldNy); 271 psMetadataAddS32 (header, PS_LIST_TAIL, "IMREF1", 0, "Image X Ref", psf->fieldXo); 272 psMetadataAddS32 (header, PS_LIST_TAIL, "IMREF2", 0, "Image Y Ref", psf->fieldYo); 273 274 // extract PSF Clump info 275 pmPSFClump psfClump; 276 277 psfClump.X = psMetadataLookupF32 (&status, recipe, "PSF.CLUMP.X"); assert (status); 278 psfClump.Y = psMetadataLookupF32 (&status, recipe, "PSF.CLUMP.Y"); assert (status); 279 psfClump.dX = psMetadataLookupF32 (&status, recipe, "PSF.CLUMP.DX"); assert (status); 280 psfClump.dY = psMetadataLookupF32 (&status, recipe, "PSF.CLUMP.DY"); assert (status); 281 282 psMetadataAddF32 (header, PS_LIST_TAIL, "PSF_CLX", 0, "psf clump center", psfClump.X); 283 psMetadataAddF32 (header, PS_LIST_TAIL, "PSF_CLY", 0, "psf clump center", psfClump.Y); 284 psMetadataAddF32 (header, PS_LIST_TAIL, "PSF_CLDX", 0, "psf clump size", psfClump.dX); 285 psMetadataAddF32 (header, PS_LIST_TAIL, "PSF_CLDY", 0, "psf clump size", psfClump.dY); 264 286 265 287 // save the dimensions of each parameter … … 306 328 // write the image components into a table: this is needed because they may each be a different size 307 329 psImageMap *map = trend->map; 308 for (int ix = 0; ix < =map->map->numCols; ix++) {309 for (int iy = 0; iy < =map->map->numRows; iy++) {330 for (int ix = 0; ix < map->map->numCols; ix++) { 331 for (int iy = 0; iy < map->map->numRows; iy++) { 310 332 psMetadata *row = psMetadataAlloc (); 311 333 psMetadataAddS32 (row, PS_LIST_TAIL, "MODEL_TERM", 0, "", i); … … 313 335 psMetadataAddS32 (row, PS_LIST_TAIL, "Y_POWER", 0, "", iy); 314 336 psMetadataAddF32 (row, PS_LIST_TAIL, "VALUE", 0, "", map->map->data.F32[iy][ix]); 315 psMetadataAddF32 (row, PS_LIST_TAIL, "ERROR", 0, "", map->error->data.F32[i x][iy]);337 psMetadataAddF32 (row, PS_LIST_TAIL, "ERROR", 0, "", map->error->data.F32[iy][ix]); 316 338 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK", 0, "", 0); // no cells are masked 317 339 … … 518 540 psTrace ("psModules.objects", 5, "read psf model for %s\n", file->filename); 519 541 542 // select the current recipe 543 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, "PSPHOT"); 544 if (!recipe) { 545 psError(PS_ERR_UNKNOWN, false, "missing recipe %s", "PSPHOT"); 546 return false; 547 } 548 520 549 // Menu of EXTNAME rules 521 550 psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES"); … … 560 589 } 561 590 591 // psf clump data 592 pmPSFClump psfClump; 593 594 psfClump.X = psMetadataLookupF32 (&status, header, "PSF_CLX" ); assert(status); 595 psfClump.Y = psMetadataLookupF32 (&status, header, "PSF_CLY" ); assert(status); 596 psfClump.dX = psMetadataLookupF32 (&status, header, "PSF_CLDX"); assert(status); 597 psfClump.dY = psMetadataLookupF32 (&status, header, "PSF_CLDY"); assert(status); 598 599 psMetadataAddF32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.X" , 0, "psf clump center", psfClump.X); 600 psMetadataAddF32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.Y" , 0, "psf clump center", psfClump.Y); 601 psMetadataAddF32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.DX", 0, "psf clump size", psfClump.dX); 602 psMetadataAddF32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.DY", 0, "psf clump size", psfClump.dY); 603 562 604 options->poissonErrorsPhotLMM = psMetadataLookupBool (&status, header, "ERR_LMM"); 563 605 options->poissonErrorsPhotLin = psMetadataLookupBool (&status, header, "ERR_LIN"); 564 606 options->poissonErrorsParams = psMetadataLookupBool (&status, header, "ERR_PAR"); 565 607 566 // XXX this is a bit ad-hoc: determine the PSF trend mode by looking at one of the parameters 567 // this could allow the psf model to use different trend modes for different parameters, but we 568 // would need to change the alloc somewhat 608 options->psfFieldNx = psMetadataLookupS32 (&status, header, "IMAXIS1"); 609 options->psfFieldNy = psMetadataLookupS32 (&status, header, "IMAXIS2"); 610 options->psfFieldXo = psMetadataLookupS32 (&status, header, "IMREF1"); 611 options->psfFieldYo = psMetadataLookupS32 (&status, header, "IMREF2"); 612 613 psImageBinning *binning = psImageBinningAlloc(); 614 binning->nXfine = options->psfFieldNx; 615 binning->nYfine = options->psfFieldNy; 569 616 570 617 // we determine the PSF parameter polynomials from the MD-defined polynomials … … 576 623 psAbort("mismatch model par count"); 577 624 578 int nXimage = psMetadataLookupS32 (&status, header, "IMAXIS1");579 int nYimage = psMetadataLookupS32 (&status, header, "IMAXIS2");580 // XXX don't require this to exist? 0,0 if not defined?581 582 625 // load the trend mode and dimensions of each parameter 583 626 for (int i = 0; i < nPar; i++) { 584 627 char name[9]; 585 628 snprintf (name, 9, "PAR%02d_NX", i); 586 int nXorder= psMetadataLookupS32 (&status, header, name);629 binning->nXruff = psMetadataLookupS32 (&status, header, name); 587 630 if (!status) continue; // not all parameters are defined 631 588 632 snprintf (name, 9, "PAR%02d_NY", i); 589 int nYorder= psMetadataLookupS32 (&status, header, name);633 binning->nYruff = psMetadataLookupS32 (&status, header, name); 590 634 if (!status) { 591 635 psError(PS_ERR_UNKNOWN, true, "inconsistent PSF header: NX defined for PAR %d, but not NY", i); 592 636 return false; 593 637 } 638 594 639 snprintf (name, 9, "PAR%02d_MD", i); 595 640 char *modeName = psMetadataLookupStr (&status, header, name); … … 599 644 } 600 645 pmTrend2DMode psfTrendMode = pmTrend2DModeFromString (modeName); 601 // XXX default to POLY_ORD if not defined? 602 603 psf->params->data[i] = pmTrend2DFieldAlloc (psfTrendMode, nXimage, nYimage, nXorder, nYorder, NULL); 604 } 646 if (psfTrendMode == PM_TREND_NONE) { 647 psfTrendMode = PM_TREND_POLY_ORD; 648 } 649 650 psImageBinningSetSkipByOffset (binning, options->psfFieldXo, options->psfFieldYo); 651 psf->params->data[i] = pmTrend2DNoImageAlloc (psfTrendMode, binning, NULL); 652 } 653 psFree (binning); 605 654 606 655 // other required information describing the PSF … … 622 671 int xPow = psMetadataLookupS32 (&status, row, "X_POWER"); 623 672 int yPow = psMetadataLookupS32 (&status, row, "Y_POWER"); 624 // XXX sanity check here625 673 626 674 pmTrend2D *trend = psf->params->data[iPar]; … … 632 680 if (trend->mode == PM_TREND_MAP) { 633 681 psImageMap *map = trend->map; 682 assert (map); 683 assert (map->map); 684 assert (map->error); 685 assert (xPow >= 0); 686 assert (yPow >= 0); 687 assert (xPow < map->map->numCols); 688 assert (yPow < map->map->numRows); 634 689 map->map->data.F32[yPow][xPow] = psMetadataLookupF32 (&status, row, "VALUE"); 635 690 map->error->data.F32[yPow][xPow] = psMetadataLookupF32 (&status, row, "ERROR"); 636 691 } else { 637 692 psPolynomial2D *poly = trend->poly; 693 assert (poly); 694 assert (xPow >= 0); 695 assert (yPow >= 0); 696 assert (xPow <= poly->nX); 697 assert (yPow <= poly->nY); 638 698 poly->coeff[xPow][yPow] = psMetadataLookupF32 (&status, row, "VALUE"); 639 699 poly->coeffErr[xPow][yPow] = psMetadataLookupF32 (&status, row, "ERROR"); -
branches/eam_branch_20070921/psModules/src/objects/pmSourcePhotometry.c
r14962 r14989 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $6 * @date $Date: 2007-09-2 1 02:46:46$5 * @version $Revision: 1.31.2.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-09-24 03:00:44 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 81 81 // we must have a valid model 82 82 model = pmSourceGetModel (&isPSF, source); 83 if (model == NULL) 84 return false; 83 if (model == NULL) { 84 psTrace ("psModules.objects", 3, "fail mag : no valid model"); 85 return false; 86 } 85 87 86 88 if (model->dparams->data.F32[PM_PAR_I0] > 0) { … … 109 111 // measure EXT model photometry 110 112 status = pmSourcePhotometryModel (&source->extMag, source->modelEXT); 113 111 114 // for PSFs, correct both apMag and psfMag to same system, consistent with infinite flux star in aperture RADIUS 112 if ((mode & PM_SOURCE_PHOT_APCORR) && isPSF && psf) { 113 // convert to the equivalent 2D model? 115 if ((mode & PM_SOURCE_PHOT_APCORR) && isPSF && psf && psf->ApTrend) { 114 116 source->psfMag += pmTrend2DEval (psf->ApTrend, x, y); 115 117 } 116 118 117 if (!isfinite(SN) || (SN < AP_MIN_SN)) 118 return false; 119 if (!isfinite(SN) || (SN < AP_MIN_SN)) { 120 psTrace ("psModules.objects", 3, "fail mag : bad SN: %f (limit: %f)", SN, AP_MIN_SN); 121 return false; 122 } 119 123 120 124 // replace source flux … … 209 213 status = pmSourcePhotometryAper (&source->apMag, model, flux, source->maskObj, maskVal); 210 214 if (!status) { 215 psTrace ("psModules.objects", 3, "fail mag : bad Ap Mag"); 211 216 psErrorCode last = psErrorCodeLast(); 212 217 if (last == PM_ERR_PHOTOM) { -
branches/eam_branch_20070921/psModules/src/objects/pmTrend2D.c
r14986 r14989 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.2.2. 3$ $Name: not supported by cvs2svn $6 * @date $Date: 2007-09-2 2 13:47:28$5 * @version $Revision: 1.2.2.4 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-09-24 03:00:44 $ 7 7 * 8 8 * Copyright 2004 Institute for Astronomy, University of Hawaii … … 32 32 { 33 33 assert (image); 34 assert (stats); 35 36 pmTrend2D *trend = (pmTrend2D *) psAlloc(sizeof(pmTrend2D)); 37 psMemSetDeallocator(trend, (psFreeFunc) pmTrend2DFree); 38 39 trend->map = NULL; 40 trend->poly = NULL; 41 trend->stats = psMemIncrRefCounter (stats); 42 trend->mode = mode; 43 44 switch (mode) { 45 case PM_TREND_POLY_ORD: 46 trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXtrend, nYtrend); 47 break; 48 49 case PM_TREND_POLY_CHEB: 50 trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_CHEB, nXtrend, nYtrend); 51 break; 52 53 case PM_TREND_MAP: { 54 // binning defines the map scale relationship 55 psImageBinning *binning = psImageBinningAlloc(); 56 binning->nXruff = nXtrend; 57 binning->nYruff = nYtrend; 58 binning->nXfine = image->numCols; 59 binning->nYfine = image->numRows; 60 61 trend->map = psImageMapAlloc (image, binning, stats); 62 psFree (binning); 63 break; 64 } 65 66 default: 67 psAbort ("error"); 68 } 69 return (trend); 70 } 71 72 pmTrend2D *pmTrend2DFieldAlloc (pmTrend2DMode mode, int nXfield, int nYfield, int nXtrend, int nYtrend, psStats *stats) 73 { 34 74 35 pmTrend2D *trend = (pmTrend2D *) psAlloc(sizeof(pmTrend2D)); 75 36 psMemSetDeallocator(trend, (psFreeFunc) pmTrend2DFree); … … 102 63 // binning defines the map scale relationship 103 64 psImageBinning *binning = psImageBinningAlloc(); 65 binning->nXruff = nXtrend; 66 binning->nYruff = nYtrend; 67 binning->nXfine = image->numCols; 68 binning->nYfine = image->numRows; 69 70 trend->map = psImageMapAlloc (image, binning, stats); 71 psFree (binning); 72 break; 73 } 74 75 default: 76 psAbort ("error"); 77 } 78 return (trend); 79 } 80 81 pmTrend2D *pmTrend2DNoImageAlloc (pmTrend2DMode mode, psImageBinning *binning, psStats *stats) 82 { 83 pmTrend2D *trend = (pmTrend2D *) psAlloc(sizeof(pmTrend2D)); 84 psMemSetDeallocator(trend, (psFreeFunc) pmTrend2DFree); 85 86 trend->map = NULL; 87 trend->poly = NULL; 88 trend->stats = psMemIncrRefCounter (stats); 89 trend->mode = mode; 90 91 switch (mode) { 92 case PM_TREND_POLY_ORD: 93 trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, binning->nXruff, binning->nYruff); 94 // set masking somehow 95 for (int nx = 0; nx < trend->poly->nX + 1; nx++) { 96 for (int ny = 0; ny < trend->poly->nY + 1; ny++) { 97 if (nx + ny >= PS_MAX (trend->poly->nX, trend->poly->nY) + 1) { 98 trend->poly->mask[nx][ny] = 1; 99 } else { 100 trend->poly->mask[nx][ny] = 0; 101 } 102 } 103 } 104 break; 105 106 case PM_TREND_POLY_CHEB: 107 trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_CHEB, binning->nXruff, binning->nYruff); 108 break; 109 110 case PM_TREND_MAP: { 111 // binning defines the map scale relationship 112 trend->map = psImageMapNoImageAlloc (binning, stats); 113 break; 114 } 115 116 default: 117 psAbort ("error"); 118 } 119 return (trend); 120 } 121 122 pmTrend2D *pmTrend2DFieldAlloc (pmTrend2DMode mode, int nXfield, int nYfield, int nXtrend, int nYtrend, psStats *stats) 123 { 124 pmTrend2D *trend = (pmTrend2D *) psAlloc(sizeof(pmTrend2D)); 125 psMemSetDeallocator(trend, (psFreeFunc) pmTrend2DFree); 126 127 trend->map = NULL; 128 trend->poly = NULL; 129 trend->stats = psMemIncrRefCounter (stats); 130 trend->mode = mode; 131 132 switch (mode) { 133 case PM_TREND_POLY_ORD: 134 trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXtrend, nYtrend); 135 // set masking somehow 136 for (int nx = 0; nx < trend->poly->nX + 1; nx++) { 137 for (int ny = 0; ny < trend->poly->nY + 1; ny++) { 138 if (nx + ny >= PS_MAX (trend->poly->nX, trend->poly->nY) + 1) { 139 trend->poly->mask[nx][ny] = 1; 140 } else { 141 trend->poly->mask[nx][ny] = 0; 142 } 143 } 144 } 145 break; 146 147 case PM_TREND_POLY_CHEB: 148 trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_CHEB, nXtrend, nYtrend); 149 break; 150 151 case PM_TREND_MAP: { 152 // binning defines the map scale relationship 153 psImageBinning *binning = psImageBinningAlloc(); 104 154 binning->nXfine = nXfield; 105 155 binning->nYfine = nYfield; … … 122 172 bool status; 123 173 174 assert (trend); 175 assert (x); 176 assert (y); 177 assert (f); 178 124 179 switch (trend->mode) { 125 180 case PM_TREND_POLY_ORD: … … 147 202 double result; 148 203 149 if (!trend) return 0.0;204 assert (trend); 150 205 151 206 switch (trend->mode) { … … 168 223 169 224 psVector *result; 225 226 assert (trend); 227 assert (x); 228 assert (y); 170 229 171 230 switch (trend->mode) { -
branches/eam_branch_20070921/psModules/src/objects/pmTrend2D.h
r14980 r14989 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.2.2. 2$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-09-2 2 02:20:11$7 * @version $Revision: 1.2.2.3 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-09-24 03:00:44 $ 9 9 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 10 10 */ … … 34 34 pmTrend2D *pmTrend2DAlloc (pmTrend2DMode mode, psImage *image, int nXtrend, int nYtrend, psStats *stats); 35 35 36 pmTrend2D *pmTrend2DNoImageAlloc (pmTrend2DMode mode, psImageBinning *binning, psStats *stats); 37 36 38 // allocate a pmTrend2D tied to an abstract field with size nXfield,nYfield 37 39 pmTrend2D *pmTrend2DFieldAlloc (pmTrend2DMode mode, int nXfield, int nYfield, int nXtrend, int nYtrend, psStats *stats);
Note:
See TracChangeset
for help on using the changeset viewer.
