- Timestamp:
- Sep 23, 2007, 5:00:44 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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");
Note:
See TracChangeset
for help on using the changeset viewer.
