Changeset 35421 for branches/eam_branches/ipp-20130419/psModules
- Timestamp:
- Apr 19, 2013, 4:45:57 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130419
- Files:
-
- 34 edited
-
. (modified) (1 prop)
-
psModules (modified) (1 prop)
-
psModules/src/astrom/pmAstrometryUtils.c (modified) (4 diffs)
-
psModules/src/camera/pmFPAMaskWeight.c (modified) (1 diff)
-
psModules/src/camera/pmFPAfileDefine.c (modified) (16 diffs)
-
psModules/src/camera/pmFPAfileDefine.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_DEV.c (modified) (1 diff)
-
psModules/src/objects/models/pmModel_DEV.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_EXP.c (modified) (1 diff)
-
psModules/src/objects/models/pmModel_EXP.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_GAUSS.c (modified) (1 diff)
-
psModules/src/objects/models/pmModel_GAUSS.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_PGAUSS.c (modified) (1 diff)
-
psModules/src/objects/models/pmModel_PGAUSS.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_PS1_V1.c (modified) (1 diff)
-
psModules/src/objects/models/pmModel_PS1_V1.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_QGAUSS.c (modified) (1 diff)
-
psModules/src/objects/models/pmModel_QGAUSS.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_RGAUSS.c (modified) (1 diff)
-
psModules/src/objects/models/pmModel_RGAUSS.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_SERSIC.c (modified) (1 diff)
-
psModules/src/objects/models/pmModel_SERSIC.h (modified) (1 diff)
-
psModules/src/objects/models/pmModel_TRAIL.c (modified) (4 diffs)
-
psModules/src/objects/models/pmModel_TRAIL.h (modified) (1 diff)
-
psModules/src/objects/pmModelFuncs.h (modified) (1 diff)
-
psModules/src/objects/pmPSF.c (modified) (2 diffs)
-
psModules/src/objects/pmPSFtryFitEXT.c (modified) (1 diff)
-
psModules/src/objects/pmSourceFitModel.c (modified) (4 diffs)
-
psModules/src/objects/pmSourceFitPCM.c (modified) (1 diff)
-
psModules/src/objects/pmSourceIO.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceMoments.c (modified) (3 diffs)
-
psModules/src/objects/pmSourceSky.c (modified) (1 diff)
-
psModules/src/objects/pmSourceUtils.c (modified) (3 diffs)
-
psModules/src/objects/pmSourceUtils.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130419
-
branches/eam_branches/ipp-20130419/psModules
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20130307/psModules (added) merged: 35321,35341,35343,35348,35350,35375-35376,35379,35381,35413
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20130419/psModules/src/astrom/pmAstrometryUtils.c
r24096 r35421 23 23 #include "pmAstrometryUtils.h" 24 24 25 // this is used by the test output block 26 static int Nout = 0; 27 25 28 // given a 2D transformation -- L(x,y),M(x,y) -- find the coordinates x,y 26 29 // for which L,M = 0,0. tol is the allowed error on x,y. … … 33 36 double Xo = (trans->y->coeff[0][0]*trans->x->coeff[0][1] - trans->x->coeff[0][0]*trans->y->coeff[0][1])/R; 34 37 double Yo = (trans->x->coeff[0][0]*trans->y->coeff[1][0] - trans->y->coeff[0][0]*trans->x->coeff[1][0])/R; 38 39 if (0) { 40 // this is a test output block, not used in normal operations 41 char filename[64]; 42 snprintf (filename, 64, "trans.%03d.md", Nout); 43 FILE *f = fopen (filename, "w"); 44 45 psMetadata *md = psMetadataAlloc(); 46 47 psPolynomial2DtoMetadata (md, trans->x, "X"); 48 psPolynomial2DtoMetadata (md, trans->y, "Y"); 49 psMetadataConfigPrint (f, md); 50 psFree (md); 51 fclose (f); 52 Nout ++; 53 } 35 54 36 55 // iterate to actual solution: requires small non-linear terms … … 52 71 for (int i = 0; (dPos > tol) && (i < 20); i++) { 53 72 // NOTE: order for Alpha is: [y][x] 73 // original Alpha->data.F32[1][0] = psPolynomial2DEval (XdY, Xo, Yo); 74 // original Alpha->data.F32[0][1] = psPolynomial2DEval (YdX, Xo, Yo); 54 75 Alpha->data.F32[0][0] = psPolynomial2DEval (XdX, Xo, Yo); 55 Alpha->data.F32[ 1][0] = psPolynomial2DEval (XdY, Xo, Yo);56 Alpha->data.F32[ 0][1] = psPolynomial2DEval (YdX, Xo, Yo);76 Alpha->data.F32[0][1] = psPolynomial2DEval (XdY, Xo, Yo); 77 Alpha->data.F32[1][0] = psPolynomial2DEval (YdX, Xo, Yo); 57 78 Alpha->data.F32[1][1] = psPolynomial2DEval (YdY, Xo, Yo); 58 79 59 Beta->data.F32[0] = psPolynomial2DEval (trans->x, Xo, Yo);60 Beta->data.F32[1] = psPolynomial2DEval (trans->y, Xo, Yo);80 Beta->data.F32[0] = -1.0 * psPolynomial2DEval (trans->x, Xo, Yo); 81 Beta->data.F32[1] = -1.0 * psPolynomial2DEval (trans->y, Xo, Yo); 61 82 62 83 if (!psMatrixGJSolve (Alpha, Beta)) { … … 71 92 } 72 93 73 Xo -= Beta->data.F32[0];74 Yo -= Beta->data.F32[1];94 Xo += Beta->data.F32[0]; 95 Yo += Beta->data.F32[1]; 75 96 dPos = hypot(Beta->data.F32[0], Beta->data.F32[1]); 76 97 psTrace ("psastro", 5, "i: %d, Xo,Yo : %f %f dX, dY: %f %f dPos: %f\n", i, Xo, Yo, Beta->data.F32[0], Beta->data.F32[1], dPos); 77 98 } 78 99 psFree (Alpha); -
branches/eam_branches/ipp-20130419/psModules/src/camera/pmFPAMaskWeight.c
r35038 r35421 301 301 psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); // Trim section 302 302 if (!mdok || psRegionIsNaN(*trimsec)) { 303 psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set --- unable to set variance.\n"); 304 return false; 303 // if trimsec is not defined, use the full image 304 trimsec = psRegionAlloc(0,0,0,0); 305 // psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set --- unable to set variance.\n"); 306 // return false; 305 307 } 306 308 -
branches/eam_branches/ipp-20130419/psModules/src/camera/pmFPAfileDefine.c
r34085 r35421 446 446 } 447 447 448 // given a filename, convert to UNIX namespace and read the PHU 449 psMetadata *readPHUfromFilename (char *filename, pmConfig *config) { 450 451 // Need to generate an FPA 452 psString realName = pmConfigConvertFilename(filename, config, false, false); 453 if (!realName) { 454 psError(psErrorCodeLast(), false, "Failed to convert file name %s", filename); 455 return NULL; 456 } 457 458 // load the header of the first image 459 // EXTWORD (fits->extword) is not relevant to the PHU 460 psFits *fits = psFitsOpen(realName, "r"); // FITS file 461 if (!fits) { 462 psError(psErrorCodeLast(), false, "Failed to open file %s", realName); 463 psFree(realName); 464 return NULL; 465 } 466 467 psMetadata *phu = psFitsReadHeader (NULL, fits); // Primary header 468 if (!phu) { 469 psError(psErrorCodeLast(), false, "Failed to read file header %s", realName); 470 psFree(realName); 471 return NULL; 472 } 473 474 if (!psFitsClose(fits)) { 475 psError(psErrorCodeLast(), false, "Failed to close file %s", realName); 476 psFree(realName); 477 psFree(phu); 478 return NULL; 479 } 480 481 return phu; 482 } 483 484 // this this function wants to return: 485 // pmFPA, PHU, fileLevel, outConfig 486 // camera, cameraName, formatName 487 typedef struct { 488 pmFPA *fpa; 489 psMetadata *phu; 490 psMetadata *format; 491 pmFPALevel fileLevel; 492 psString cameraName; 493 psString formatName; 494 } pmFPAfromFilenameOutput; 495 496 // for the given filename, read PHU and determine camera format; build an FPA for the file 497 bool pmFPAfromFilename (pmFPAfromFilenameOutput *output, pmConfig **outConfig, pmConfig *sysConfig, char *filename){ 498 499 // Need to generate an FPA 500 psMetadata *phu = readPHUfromFilename (filename, sysConfig); 501 if (!phu) { 502 psError(psErrorCodeLast(), false, "Failed to read PHU for %s", filename); 503 return false; 504 } 505 506 // if we expect the loaded FPA to differ in configuration from the current system configuration 507 // generate an output config for this FPA 508 pmConfig *config = NULL; 509 if (outConfig) { 510 config = pmConfigAlloc(); 511 config->user = psMemIncrRefCounter(sysConfig->user); 512 config->system = psMemIncrRefCounter(sysConfig->system); 513 514 psFree (config->files); 515 config->files = psMemIncrRefCounter(sysConfig->files); 516 psFree (config->arguments); 517 config->arguments = psMemIncrRefCounter(sysConfig->arguments); 518 519 *outConfig = config; 520 } else { 521 config = sysConfig; 522 } 523 524 // values which are returned to calling function 525 psString formatName = NULL; // Name of camera format 526 psString cameraName = NULL; // Name of camera 527 psMetadata *camera = NULL; // Camera configuration 528 529 // Determine the current format from the header; determine camera if not specified already. 530 psMetadata *format = pmConfigCameraFormatFromHeader(&camera, &cameraName, &formatName, config, phu, true); 531 if (!format) { 532 psError(psErrorCodeLast(), false, "Failed to determine camera format for %s", filename); 533 psFree(camera); 534 psFree(formatName); 535 psFree(phu); 536 return false; 537 } 538 539 pmFPALevel fileLevel = pmFPAPHULevel(format); 540 if (fileLevel == PM_FPA_LEVEL_NONE) { 541 psError(PM_ERR_CONFIG, true, "Unable to determine file level for %s", filename); 542 psFree(camera); 543 psFree(formatName); 544 psFree(phu); 545 return false; 546 } 547 548 // build the template fpa, set up the basic view 549 // we supply the metaCamera name (if NULL, baseCamera name is used) 550 pmFPA *fpa = pmFPAConstruct(camera, cameraName); 551 psFree(camera); 552 553 if (!fpa) { 554 psError(psErrorCodeLast(), false, "Failed to construct FPA from %s", filename); 555 psFree(formatName); 556 psFree(format); 557 psFree(phu); 558 return NULL; 559 } 560 561 output->fpa = fpa; 562 output->phu = phu; 563 output->format = format; 564 output->fileLevel = fileLevel; 565 output->cameraName = cameraName; 566 output->formatName = formatName; 567 568 return true; 569 570 } 448 571 449 572 /// Define a file from an array of filenames 450 static pmFPAfile *fpaFileDefineFromArray(pmConfig *config, // Configuration 573 static pmFPAfile *fpaFileDefineFromArray(pmConfig **outConfig, // output configuration 574 pmConfig *sysConfig, // global configuration 451 575 pmFPAfile *bind, // File to bind to, or NULL 452 576 const char *name, // Name of file … … 454 578 ) 455 579 { 456 PS_ASSERT_PTR_NON_NULL( config, NULL);580 PS_ASSERT_PTR_NON_NULL(sysConfig, NULL); 457 581 PS_ASSERT_STRING_NON_EMPTY(name, NULL); 458 582 … … 463 587 pmFPALevel fileLevel = PM_FPA_LEVEL_NONE; // Level for files 464 588 psMetadata *phu = NULL; // Primary header 589 465 590 if (bind) { 466 591 // Use the FPA we're binding to … … 468 593 fileLevel = bind->fileLevel; 469 594 } else { 470 // Need to generate an FPA 471 psString realName = pmConfigConvertFilename(filenames->data[0], config, false, false); 472 if (!realName) { 473 psError(psErrorCodeLast(), false, "Failed to convert file name %s", (char *)filenames->data[0]); 474 return NULL; 475 } 476 477 // load the header of the first image 478 // EXTWORD (fits->extword) is not relevant to the PHU 479 psFits *fits = psFitsOpen(realName, "r"); // FITS file 480 if (!fits) { 481 psError(psErrorCodeLast(), false, "Failed to open file %s", realName); 482 psFree(realName); 483 return NULL; 484 } 485 phu = psFitsReadHeader (NULL, fits); // Primary header 486 if (!phu) { 487 psError(psErrorCodeLast(), false, "Failed to read file header %s", realName); 488 psFree(realName); 489 return NULL; 490 } 491 if (!psFitsClose(fits)) { 492 psError(psErrorCodeLast(), false, "Failed to close file %s", realName); 493 psFree(realName); 494 return NULL; 495 } 496 497 // Determine the current format from the header; determine camera if not specified already. 498 psMetadata *camera = NULL; // Camera configuration 499 format = pmConfigCameraFormatFromHeader(&camera, &cameraName, &formatName, config, phu, true); 500 if (!format) { 501 psError(psErrorCodeLast(), false, "Failed to determine camera format for %s", realName); 502 psFree(camera); 503 psFree(formatName); 504 psFree(realName); 505 psFree(phu); 506 return NULL; 507 } 508 509 fileLevel = pmFPAPHULevel(format); 510 if (fileLevel == PM_FPA_LEVEL_NONE) { 511 psError(PM_ERR_CONFIG, true, "Unable to determine file level for %s", realName); 512 psFree(camera); 513 psFree(formatName); 514 psFree(realName); 515 psFree(phu); 516 return NULL; 517 } 518 519 // build the template fpa, set up the basic view 520 // XXX do we want this to be the baseCamera name or the metaCamera name? 521 fpa = pmFPAConstruct(camera, cameraName); 522 psFree(camera); 523 if (!fpa) { 524 psError(psErrorCodeLast(), false, "Failed to construct FPA from %s", realName); 525 psFree(formatName); 526 psFree(realName); 527 psFree(format); 528 psFree(phu); 529 return NULL; 530 } 531 psFree(realName); 532 } 595 pmFPAfromFilenameOutput output; 596 if (!pmFPAfromFilename (&output, outConfig, sysConfig, filenames->data[0])) { 597 return NULL; 598 } 599 fpa = output.fpa; 600 phu = output.phu; 601 format = output.format; 602 fileLevel = output.fileLevel; 603 cameraName = output.cameraName; 604 formatName = output.formatName; 605 } 606 607 pmConfig *config = outConfig ? *outConfig : sysConfig; 533 608 534 609 // load the given filerule (from config->camera) and bind it to the fpa … … 561 636 // Check that the file corresponds to the same camera and format 562 637 if (!phu) { 563 psString realName = pmConfigConvertFilename(filenames->data[i], config, false, false);564 if (! realName) {565 psError(psErrorCodeLast(), false, "Failed to convert file name %s", (char*)filenames->data[i]);638 phu = readPHUfromFilename (filenames->data[i], config); 639 if (!phu) { 640 psError(psErrorCodeLast(), false, "Failed to read PHU for %s", (char *)filenames->data[i]); 566 641 return NULL; 567 642 } 568 psFits *fits = psFitsOpen(realName, "r"); // FITS file569 if (!fits) {570 psError(psErrorCodeLast(), false, "Failed to open file %s", realName);571 psFree(realName);572 return NULL;573 }574 phu = psFitsReadHeader(NULL, fits);575 if (!psFitsClose(fits)) {576 psError(psErrorCodeLast(), false, "Failed to close file %s", realName);577 psFree(realName);578 return NULL;579 }580 if (!phu) {581 psError(psErrorCodeLast(), false, "Failed to read file header %s", realName);582 psFree(realName);583 return NULL;584 }585 psFree(realName);586 643 } 587 644 … … 651 708 } 652 709 653 654 pmFPAfile *pmFPAfileDefineFromArgs(bool *success, pmConfig *config, 655 const char *filename, const char *argname) 710 // find the file associated with the argname & generate a pmFPAfile for it based on the filerule 711 pmFPAfile *pmFPAfileDefineFromArgs(bool *success, pmConfig *config, const char *filename, const char *argname) 656 712 { 657 713 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 676 732 } 677 733 678 pmFPAfile *file = fpaFileDefineFromArray( config, NULL, filename, filenames); // File of interest734 pmFPAfile *file = fpaFileDefineFromArray(NULL, config, NULL, filename, filenames); // File of interest 679 735 680 736 if (success) { … … 685 741 } 686 742 687 pmFPAfile *pmFPAfileBindFromArgs(bool *success, pmFPAfile *input, pmConfig *config, 688 const char *filename, const char *argname)743 // find the file associated with the argname & bind it to the given pmFPAfile for it based on the filerule 744 pmFPAfile *pmFPAfileBindFromArgs(bool *success, pmFPAfile *input, pmConfig *config, const char *filename, const char *argname) 689 745 { 690 746 PS_ASSERT_PTR_NON_NULL(input, NULL); … … 710 766 } 711 767 712 pmFPAfile *file = fpaFileDefineFromArray( config, input, filename, filenames); // File of interest768 pmFPAfile *file = fpaFileDefineFromArray(NULL, config, input, filename, filenames); // File of interest 713 769 714 770 if (success) { … … 719 775 } 720 776 721 pmFPAfile *pmFPAfileDefineSingleFromArgs(bool *success, pmConfig *config, const char *filename, 722 const char *argname, int entry)777 // find the specific file associated with the argname & generate a pmFPAfile for it based on the filerule 778 pmFPAfile *pmFPAfileDefineSingleFromArgs(bool *success, pmConfig *config, const char *filename, const char *argname, int entry) 723 779 { 724 780 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 746 802 psArray *single = psArrayAlloc(1); // Array of single filename of interest 747 803 single->data[0] = psMemIncrRefCounter(filenames->data[entry]); 748 pmFPAfile *file = fpaFileDefineFromArray( config, NULL, filename, single); // File of interest804 pmFPAfile *file = fpaFileDefineFromArray(NULL, config, NULL, filename, single); // File of interest 749 805 psFree(single); 750 806 … … 756 812 } 757 813 814 // find the file in the config list & generate a pmFPAfile for it based on the filerule 758 815 pmFPAfile *pmFPAfileDefineFromRun(bool *success, pmFPAfile *bind, pmConfig *config, const char *filename) 759 816 { … … 769 826 } 770 827 771 pmFPAfile *file = fpaFileDefineFromArray( config, bind, filename, filenames); // File of interest828 pmFPAfile *file = fpaFileDefineFromArray(NULL, config, bind, filename, filenames); // File of interest 772 829 psFree(filenames); 773 830 … … 779 836 } 780 837 838 // find the files in the config list & generate an array of pmFPAfiles for them based on the filerule 781 839 psArray *pmFPAfileDefineMultipleFromRun(bool *success, psArray *bind, pmConfig *config, const char *filename) 782 840 { … … 808 866 dummy->data[0] = files->data[i]; 809 867 pmFPAfile *bindFile = bind ? bind->data[i] : NULL; // File to which to bind 810 files->data[i] = psMemIncrRefCounter(fpaFileDefineFromArray( config, bindFile, filename, dummy));868 files->data[i] = psMemIncrRefCounter(fpaFileDefineFromArray(NULL, config, bindFile, filename, dummy)); 811 869 if (!files->data[i]) { 812 870 psError(psErrorCodeLast(), false, "Unable to define file %s %d", filename, i); … … 823 881 824 882 return files; 883 } 884 885 // find the file associated with the argname & generate a pmFPAfile for it based on the filerule 886 pmFPAfile *pmFPAfileDefineNewConfig(bool *success, pmConfig **outConfig, pmConfig *sysConfig, const char *filename, const char *argname) 887 { 888 PS_ASSERT_PTR_NON_NULL(outConfig, NULL); 889 PS_ASSERT_PTR_NON_NULL(sysConfig, NULL); 890 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 891 PS_ASSERT_STRING_NON_EMPTY(argname, NULL); 892 893 // Search the argument data for the named fileset (argname) 894 bool status; // Status of MD lookup 895 psArray *filenames = psMetadataLookupPtr(&status, sysConfig->arguments, argname); // Filenames for file 896 if (!status) { 897 if (success) { 898 *success = true; 899 } 900 return NULL; 901 } 902 if (filenames->n == 0) { 903 psError(PM_ERR_CONFIG, true, "No files in array in %s in arguments", argname); 904 if (success) { 905 *success = false; 906 } 907 return NULL; 908 } 909 910 pmFPAfile *file = fpaFileDefineFromArray(outConfig, sysConfig, NULL, filename, filenames); // File of interest 911 912 if (success) { 913 *success = file ? true : false; 914 } 915 916 return file; 825 917 } 826 918 -
branches/eam_branches/ipp-20130419/psModules/src/camera/pmFPAfileDefine.h
r27657 r35421 81 81 const char *filename ///< Name of file 82 82 ); 83 84 // find the file associated with the argname & generate a pmFPAfile for it based on the filerule 85 pmFPAfile *pmFPAfileDefineNewConfig( 86 bool *success, ///< Found files? 87 pmConfig **outConfig, ///< output configuration for this file 88 pmConfig *sysConfig, ///< existing system config info 89 const char *filename, ///< name of filerule 90 const char *argname ///< argument entry 91 ); 92 83 93 84 94 // look for the given argname on the argument list. find the give filename from the file rules -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_DEV.c
r34403 r35421 295 295 // make an initial guess for parameters 296 296 // 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters 297 bool PM_MODEL_GUESS (pmModel *model, pmSource *source )297 bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 298 298 { 299 299 psF32 *PAR = model->params->data.F32; -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_DEV.h
r29004 r35421 5 5 psF32 pmModelFunc_DEV(psVector *deriv, const psVector *params, const psVector *pixcoord); 6 6 bool pmModelLimits_DEV(psMinConstraintMode mode, int nParam, float *params, float *beta); 7 bool pmModelGuess_DEV(pmModel *model, pmSource *source );7 bool pmModelGuess_DEV(pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal); 8 8 psF64 pmModelFlux_DEV(const psVector *params); 9 9 psF64 pmModelRadius_DEV(const psVector *params, psF64 flux); -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_EXP.c
r34403 r35421 287 287 // make an initial guess for parameters 288 288 // 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters 289 bool PM_MODEL_GUESS (pmModel *model, pmSource *source )289 bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 290 290 { 291 291 psF32 *PAR = model->params->data.F32; -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_EXP.h
r29004 r35421 5 5 psF32 pmModelFunc_EXP(psVector *deriv, const psVector *params, const psVector *pixcoord); 6 6 bool pmModelLimits_EXP(psMinConstraintMode mode, int nParam, float *params, float *beta); 7 bool pmModelGuess_EXP(pmModel *model, pmSource *source );7 bool pmModelGuess_EXP(pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal); 8 8 psF64 pmModelFlux_EXP(const psVector *params); 9 9 psF64 pmModelRadius_EXP(const psVector *params, psF64 flux); -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_GAUSS.c
r34403 r35421 192 192 // make an initial guess for parameters 193 193 // 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters 194 bool PM_MODEL_GUESS (pmModel *model, pmSource *source )194 bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 195 195 { 196 196 psF32 *PAR = model->params->data.F32; -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_GAUSS.h
r25738 r35421 5 5 psF32 pmModelFunc_GAUSS(psVector *deriv, const psVector *params, const psVector *pixcoord); 6 6 bool pmModelLimits_GAUSS(psMinConstraintMode mode, int nParam, float *params, float *beta); 7 bool pmModelGuess_GAUSS(pmModel *model, pmSource *source );7 bool pmModelGuess_GAUSS(pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal); 8 8 psF64 pmModelFlux_GAUSS(const psVector *params); 9 9 psF64 pmModelRadius_GAUSS(const psVector *params, psF64 flux); -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_PGAUSS.c
r34403 r35421 193 193 // make an initial guess for parameters 194 194 // 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters 195 bool PM_MODEL_GUESS (pmModel *model, pmSource *source )195 bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 196 196 { 197 197 psF32 *PAR = model->params->data.F32; -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_PGAUSS.h
r25738 r35421 5 5 psF32 pmModelFunc_PGAUSS(psVector *deriv, const psVector *params, const psVector *pixcoord); 6 6 bool pmModelLimits_PGAUSS(psMinConstraintMode mode, int nParam, float *params, float *beta); 7 bool pmModelGuess_PGAUSS(pmModel *model, pmSource *source );7 bool pmModelGuess_PGAUSS(pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal); 8 8 psF64 pmModelFlux_PGAUSS(const psVector *params); 9 9 psF64 pmModelRadius_PGAUSS(const psVector *params, psF64 flux); -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_PS1_V1.c
r34403 r35421 212 212 // make an initial guess for parameters 213 213 // 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters 214 bool PM_MODEL_GUESS (pmModel *model, pmSource *source )214 bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 215 215 { 216 216 psF32 *PAR = model->params->data.F32; -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_PS1_V1.h
r25738 r35421 5 5 psF32 pmModelFunc_PS1_V1(psVector *deriv, const psVector *params, const psVector *pixcoord); 6 6 bool pmModelLimits_PS1_V1(psMinConstraintMode mode, int nParam, float *params, float *beta); 7 bool pmModelGuess_PS1_V1(pmModel *model, pmSource *source );7 bool pmModelGuess_PS1_V1(pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal); 8 8 psF64 pmModelFlux_PS1_V1(const psVector *params); 9 9 psF64 pmModelRadius_PS1_V1(const psVector *params, psF64 flux); -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_QGAUSS.c
r34403 r35421 213 213 // make an initial guess for parameters 214 214 // 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters 215 bool PM_MODEL_GUESS (pmModel *model, pmSource *source )215 bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 216 216 { 217 217 psF32 *PAR = model->params->data.F32; -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_QGAUSS.h
r25738 r35421 5 5 psF32 pmModelFunc_QGAUSS(psVector *deriv, const psVector *params, const psVector *pixcoord); 6 6 bool pmModelLimits_QGAUSS(psMinConstraintMode mode, int nParam, float *params, float *beta); 7 bool pmModelGuess_QGAUSS(pmModel *model, pmSource *source );7 bool pmModelGuess_QGAUSS(pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal); 8 8 psF64 pmModelFlux_QGAUSS(const psVector *params); 9 9 psF64 pmModelRadius_QGAUSS(const psVector *params, psF64 flux); -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_RGAUSS.c
r34403 r35421 202 202 // make an initial guess for parameters 203 203 // 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters 204 bool PM_MODEL_GUESS (pmModel *model, pmSource *source )204 bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 205 205 { 206 206 psF32 *PAR = model->params->data.F32; -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_RGAUSS.h
r25738 r35421 5 5 psF32 pmModelFunc_RGAUSS(psVector *deriv, const psVector *params, const psVector *pixcoord); 6 6 bool pmModelLimits_RGAUSS(psMinConstraintMode mode, int nParam, float *params, float *beta); 7 bool pmModelGuess_RGAUSS(pmModel *model, pmSource *source );7 bool pmModelGuess_RGAUSS(pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal); 8 8 psF64 pmModelFlux_RGAUSS(const psVector *params); 9 9 psF64 pmModelRadius_RGAUSS(const psVector *params, psF64 flux); -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_SERSIC.c
r34403 r35421 307 307 // make an initial guess for parameters 308 308 // 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters 309 bool PM_MODEL_GUESS (pmModel *model, pmSource *source )309 bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 310 310 { 311 311 pmMoments *moments = source->moments; -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_SERSIC.h
r25738 r35421 5 5 psF32 pmModelFunc_SERSIC(psVector *deriv, const psVector *params, const psVector *pixcoord); 6 6 bool pmModelLimits_SERSIC(psMinConstraintMode mode, int nParam, float *params, float *beta); 7 bool pmModelGuess_SERSIC(pmModel *model, pmSource *source );7 bool pmModelGuess_SERSIC(pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal); 8 8 psF64 pmModelFlux_SERSIC(const psVector *params); 9 9 psF64 pmModelRadius_SERSIC(const psVector *params, psF64 flux); -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_TRAIL.c
r35215 r35421 168 168 dPAR[PM_PAR_THETA] = PAR[PM_PAR_I0] * dPdT; 169 169 dPAR[PM_PAR_SIGMA] = 0; // we don't actually allow this to vary, so we do not need to calculate it 170 171 for (int i = 0; i < 7; i++) { 172 if (isnan(dPAR[i])) { 173 fprintf (stderr, "*"); 174 } 175 } 176 } 177 if (isnan(f)) { 178 fprintf (stderr, "!"); 170 179 } 171 180 return(f); … … 228 237 } 229 238 239 # define NA 21 240 # define NR 21 241 static float flux[NA][NR]; 242 static float npix[NA][NR]; 243 244 bool pmTrailGetAngle (float *To, float *Io, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal, float sigma) { 245 246 float Xo, Yo; 247 if (!pmModelSetPosition(&Xo, &Yo, source)) return false; 248 249 psImage *image = source->pixels; 250 psImage *mask = source->maskObj; 251 psF32 **imData = image->data.F32; 252 psImageMaskType **mkData = mask->data.PS_TYPE_IMAGE_MASK_DATA; 253 254 // do a loop over the pixels, generating (dX,dY) dot (cos(theta),sin(theta)) 255 int dP; 256 int dX = Xo - mask->col0; 257 dP = mask->numCols - dX; 258 int DX = PS_MAX(dP, dX); 259 int NX = mask->numCols; 260 261 int dY = Yo - mask->row0; 262 dP = mask->numRows - dY; 263 int DY = PS_MAX(dP, dY); 264 int NY = mask->numRows; 265 266 // just hard wire this for now... 267 float radius = 10.0; 268 float radius2 = PS_SQR(radius); 269 270 // we have an array of Angles x Radii 271 float dT = M_PI / NA; 272 for (int na = 0; na < NA; na++) { 273 memset (flux[na], 0, NR*sizeof(float)); 274 memset (npix[na], 0, NR*sizeof(float)); 275 } 276 277 // we skip any pixels [real or virtual] outside of the specified radius (nominally the aperture radius) 278 // ix and iy track pixels relative to the centroid 279 for (int ix = -DX; ix < DX + 1; ix++) { 280 if (ix > radius) continue; 281 int mx = ix + dX; 282 for (int iy = -DY; iy < DY + 1; iy++) { 283 if (iy > radius) continue; 284 if (ix*ix + iy*iy > radius2) continue; 285 int my = iy + dY; 286 287 // include count only the unmasked pixels within the image area 288 if (mx < 0) continue; 289 if (my < 0) continue; 290 if (mx >= NX) continue; 291 if (my >= NY) continue; 292 293 // count pixels which are masked only with bad pixels 294 if (mkData[my][mx] & maskVal)continue; 295 296 // we have defined NA to be 21 297 int na = 0; 298 for (float angle = 0.0; na < NA; angle += dT, na ++) { 299 300 // XXX optimization : pre-compute the angle sines and cosines 301 float Rad = (ix * cos(angle)) + (iy * sin(angle)); 302 int nr = PS_MAX (PS_MIN (NR, Rad + 0.5*NR), 0); 303 304 flux[na][nr] += imData[my][mx]; 305 npix[na][nr] ++; 306 } 307 } 308 } 309 310 // generate a psf model (with integral of 1.0) 311 float Ao = 1.0 / sqrt(2*M_PI) / sigma; 312 float psf[NR]; 313 for (int nr = 0; nr < NR; nr++) { 314 psf[nr] = Ao*exp(-0.5*PS_SQR((nr - 0.5*NR)/sigma)); 315 } 316 317 float fangle[NA]; 318 for (int na = 0; na < NA; na++) { 319 float fpsf = 0.0; 320 for (int nr = 0; nr < NR; nr++) { 321 fpsf += psf[nr]*flux[na][nr]; 322 } 323 fangle[na] = fpsf; 324 // fprintf (stderr, "fpsf: %f, theta = %f\n", fpsf, PS_DEG_RAD*dT*na); 325 } 326 327 float peak = fangle[0]; 328 int pbin = 0; 329 for (int na = 0; na < NA; na++) { 330 if (fangle[na] > peak) { 331 peak = fangle[na]; 332 pbin = na; 333 } 334 } 335 336 // result is peak, pbin -> angle 337 *To = dT * pbin; 338 *Io = peak * Ao; 339 340 return true; 341 } 342 230 343 // make an initial guess for parameters 231 344 // 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters 232 bool PM_MODEL_GUESS (pmModel *model, pmSource *source )345 bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 233 346 { 234 347 psF32 *PAR = model->params->data.F32; … … 260 373 //else { size = psfAxes.major; } 261 374 375 float theta, peak; 376 pmTrailGetAngle (&theta, &peak, source, maskVal, markVal, psfAxes.major); 377 262 378 // axes.major is a sigma in the major direction; scale to 263 379 PAR[PM_PAR_LENGTH] = 1.5*2.35*size; // a tophat of length L has L = 1.5 * 2.35 * sigma … … 266 382 267 383 // set the model normalization 268 if (!pmModelSetNorm(&PAR[PM_PAR_I0], source)) { 269 return false; 270 } 384 // if (!pmModelSetNorm(&PAR[PM_PAR_I0], source)) { 385 // return false; 386 // } 387 PAR[PM_PAR_I0] = peak; 271 388 272 389 // set the model position -
branches/eam_branches/ipp-20130419/psModules/src/objects/models/pmModel_TRAIL.h
r34259 r35421 5 5 psF32 pmModelFunc_TRAIL(psVector *deriv, const psVector *params, const psVector *pixcoord); 6 6 bool pmModelLimits_TRAIL(psMinConstraintMode mode, int nParam, float *params, float *beta); 7 bool pmModelGuess_TRAIL(pmModel *model, pmSource *source );7 bool pmModelGuess_TRAIL(pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal); 8 8 psF64 pmModelFlux_TRAIL(const psVector *params); 9 9 psF64 pmModelRadius_TRAIL(const psVector *params, psF64 flux); -
branches/eam_branches/ipp-20130419/psModules/src/objects/pmModelFuncs.h
r34259 r35421 107 107 // This function provides the model guess parameters based on the details of 108 108 // the given source. 109 typedef bool (*pmModelGuessFunc)(pmModel *model, pmSource *source );109 typedef bool (*pmModelGuessFunc)(pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal); 110 110 111 111 // This function constructs the PSF model for the given source based on the -
branches/eam_branches/ipp-20130419/psModules/src/objects/pmPSF.c
r34403 r35421 350 350 shape.sx = modelPar[PM_PAR_SXX]; 351 351 shape.sy = modelPar[PM_PAR_SYY]; 352 shape.sxy = modelPar[PM_PAR_SXY]; 352 shape.sxy = modelPar[PM_PAR_SXY] / 2.0; 353 // XXX I *think* dividing by 2.0 is the right direction, but this 354 // needs to be checked with a real test 353 355 } else { 354 356 shape.sx = modelPar[PM_PAR_SXX] / M_SQRT2; … … 392 394 modelPar[PM_PAR_SXX] = shape.sx; 393 395 modelPar[PM_PAR_SYY] = shape.sy; 394 modelPar[PM_PAR_SXY] = shape.sxy; 396 modelPar[PM_PAR_SXY] = shape.sxy; // XXX NEED factor of 2 here for correct angle conversion 395 397 } else { 396 398 modelPar[PM_PAR_SXX] = shape.sx * M_SQRT2; -
branches/eam_branches/ipp-20130419/psModules/src/objects/pmPSFtryFitEXT.c
r34403 r35421 83 83 } 84 84 85 source->modelEXT = pmSourceModelGuess (source, options->type );85 source->modelEXT = pmSourceModelGuess (source, options->type, maskVal, markVal); 86 86 if (source->modelEXT == NULL) { 87 87 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : failed to generate model guess\n", i, source->peak->x, source->peak->y); -
branches/eam_branches/ipp-20130419/psModules/src/objects/pmSourceFitModel.c
r34403 r35421 75 75 PS_ASSERT_PTR_NON_NULL(source->pixels, false); 76 76 PS_ASSERT_PTR_NON_NULL(source->maskObj, false); 77 PS_ASSERT_PTR_NON_NULL(source->variance, false); 77 78 // XXX if variance is NULL, use pixels instead (wrong, but not badly wrong) 79 // PS_ASSERT_PTR_NON_NULL(source->variance, false); 78 80 79 81 psBool fitStatus = true; … … 93 95 float Xo = model->params->data.F32[PM_PAR_XPOS]; 94 96 float Yo = model->params->data.F32[PM_PAR_YPOS]; 97 98 // if variance is NULL, we pretend pixels == variance 99 float **vWgt = source->variance ? source->variance->data.F32 : source->pixels->data.F32; 95 100 96 101 // fill in the coordinate and value entries … … 103 108 } 104 109 // skip zero-variance points 105 if ( source->variance->data.F32[i][j] == 0) {110 if (vWgt[i][j] == 0) { 106 111 continue; 107 112 } 108 113 // skip nan values in image 109 114 if (!isfinite(source->pixels->data.F32[i][j])) { 115 fprintf (stderr, "WARNING: unmasked nan in image : %x vs %x\n", source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j], maskVal); 110 116 continue; 111 117 } 112 118 113 119 // skip nan values in image 114 if (!isfinite( source->variance->data.F32[i][j])) {115 fprintf (stderr, " impossible!%x vs %x\n", source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j], maskVal);120 if (!isfinite(vWgt[i][j])) { 121 fprintf (stderr, "WARNING: unmasked nan in variance : %x vs %x\n", source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j], maskVal); 116 122 continue; 117 123 } … … 140 146 // source sky variance 141 147 if (options->poissonErrors) { 142 yErr->data.F32[nPix] = 1.0 / source->variance->data.F32[i][j];148 yErr->data.F32[nPix] = 1.0 / vWgt[i][j]; 143 149 } else { 144 150 yErr->data.F32[nPix] = 1.0 / options->weight; -
branches/eam_branches/ipp-20130419/psModules/src/objects/pmSourceFitPCM.c
r34403 r35421 145 145 bool pmSourceModelGuessPCM (pmPCMdata *pcm, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) { 146 146 147 if (!pcm->modelConv->modelGuess(pcm->modelConv, source)) {147 if (!pcm->modelConv->modelGuess(pcm->modelConv, source, maskVal, markVal)) { 148 148 return false; 149 149 } -
branches/eam_branches/ipp-20130419/psModules/src/objects/pmSourceIO.c
r34720 r35421 980 980 return false; 981 981 } 982 982 983 // if this is not TRUE, the output files only contain the psf measurements. 983 984 bool XSRC_OUTPUT = psMetadataLookupBool(&status, recipe, "EXTENDED_SOURCE_ANALYSIS"); … … 1005 1006 hdu->header = psFitsReadHeader (NULL, file->fits); 1006 1007 } 1008 1009 // "WCS" is CMF without detected objects 1010 if (file->type == PM_FPA_FILE_WCS) { 1011 psTrace("psModules.objects", 6, "read CMF table from %s : %s : %s", file->filename, headname, dataname); 1012 psFree (headname); 1013 psFree (dataname); 1014 psFree (deteffname); 1015 break; 1016 } 1017 1018 // EXTDATA is the PSF data associated with this image header 1007 1019 1008 1020 // we need to find the corresponding table EXTNAME. -
branches/eam_branches/ipp-20130419/psModules/src/objects/pmSourceMoments.c
r34403 r35421 151 151 152 152 float *vPix = source->pixels->data.F32[row]; 153 float *vWgt = source->variance ->data.F32[row];153 float *vWgt = source->variance ? source->variance->data.F32[row] : source->pixels->data.F32[row]; 154 154 155 155 psImageMaskType *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row]; … … 266 266 267 267 float **vPix = source->pixels->data.F32; 268 float **vWgt = source->variance ->data.F32;269 psImageMaskType **vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA;268 float **vWgt = source->variance ? source->variance->data.F32 : source->pixels->data.F32; 269 psImageMaskType **vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA; 270 270 271 271 float RF = 0.0; … … 467 467 468 468 float *vPix = source->pixels->data.F32[row]; 469 float *vWgt = source->variance ->data.F32[row];469 float *vWgt = source->variance ? source->variance->data.F32[row] : source->pixels->data.F32[row]; 470 470 471 471 psImageMaskType *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row]; -
branches/eam_branches/ipp-20130419/psModules/src/objects/pmSourceSky.c
r34403 r35421 122 122 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 123 123 PS_ASSERT_PTR_NON_NULL(source, false); 124 PS_ASSERT_IMAGE_NON_NULL(source->variance, false);125 124 PS_ASSERT_IMAGE_NON_NULL(source->maskObj, false); 126 125 PS_ASSERT_PTR_NON_NULL(source->peak, false); 127 126 PS_ASSERT_INT_POSITIVE(Radius, false); 127 128 if (source->variance == NULL) { 129 // XXX this is needed so psphotCheckRadiusPSF has a real value 130 source->moments->dSky = 1.0; 131 return true; 132 } 128 133 129 134 // maskVal is used to test for rejected pixels, and must include markVal -
branches/eam_branches/ipp-20130419/psModules/src/objects/pmSourceUtils.c
r34403 r35421 46 46 47 47 /****************************************************************************** 48 pmSourceModelGuess(source, model ): This function allocates a new49 pmModel structure based on the given modelType specified in the argument list. 50 The corresponding pmModelGuess function is returned, and used to51 supply the values of theparams array in the pmModel structure.48 pmSourceModelGuess(source, model, maskVal, markVal): This function allocates a new 49 pmModel structure based on the given modelType specified in the argument list. The 50 corresponding pmModelGuess function is returned, and used to supply the values of the 51 params array in the pmModel structure. 52 52 53 53 XXX: Many parameters are based on the src->moments structure, which is in … … 55 55 functions will be in image, not subImage coords. Remember this. 56 56 *****************************************************************************/ 57 pmModel *pmSourceModelGuess(pmSource *source, 58 pmModelType modelType) 57 pmModel *pmSourceModelGuess(pmSource *source, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal) 59 58 { 60 59 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); … … 65 64 pmModel *model = pmModelAlloc(modelType); 66 65 67 if (!model->modelGuess(model, source )) {66 if (!model->modelGuess(model, source, maskVal, markVal)) { 68 67 psFree (model); 69 68 return NULL; -
branches/eam_branches/ipp-20130419/psModules/src/objects/pmSourceUtils.h
r31451 r35421 27 27 pmModel *pmSourceModelGuess( 28 28 pmSource *source, ///< The input pmSource 29 pmModelType model ///< The type of model to be created. 29 pmModelType model, ///< The type of model to be created. 30 psImageMaskType maskVal, 31 psImageMaskType markVal 30 32 ); 31 33
Note:
See TracChangeset
for help on using the changeset viewer.
