Changeset 12958 for branches/eam_02_branch/psModules/src/objects/pmSource.c
- Timestamp:
- Apr 23, 2007, 8:04:18 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_02_branch/psModules/src/objects/pmSource.c
r12956 r12958 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.25.4. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-04-23 03:26:23$8 * @version $Revision: 1.25.4.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-04-23 18:04:18 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 743 743 } 744 744 745 pmModel *pmSourceSelectModel (pmSource *source)746 {747 switch (source->type) {748 case PM_SOURCE_TYPE_STAR:749 return source->modelPSF;750 751 case PM_SOURCE_TYPE_EXTENDED:752 return source->modelEXT;753 754 default:755 return NULL;756 }757 return NULL;758 }759 760 745 // construct a realization of the source model 761 746 bool pmSourceCacheModel (pmSource *source) { … … 763 748 // select appropriate model 764 749 pmModel *model = pmSourceGetModel (NULL, source); 765 if (model == NULL) continue; // model must be defined750 if (model == NULL) return false; // model must be defined 766 751 767 752 // if we already have a cached image, re-use that memory 768 if (source->modelFlux) { 769 psImageRecycle (source->modelFlux); 770 } else { 771 source->modelFlux = psImageCopy (source->pixels); 772 } 753 source->modelFlux = psImageCopy (source->modelFlux, source->pixels, PS_TYPE_F32); 773 754 psImageInit (source->modelFlux, 0.0); 774 755 … … 782 763 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add) { 783 764 765 bool status; 766 767 if (add) { 768 psTrace ("psphot", 3, "replacing object at %f,%f\n", source->peak->xf, source->peak->yf); 769 } else { 770 psTrace ("psphot", 3, "removing object at %f,%f\n", source->peak->xf, source->peak->yf); 771 } 772 784 773 pmModel *model = pmSourceGetModel (NULL, source); 785 if (model == NULL) continue; // model must be defined774 if (model == NULL) return false; // model must be defined 786 775 787 776 if (source->modelFlux) { … … 801 790 // XXX need to respect the source and model masks? 802 791 for (int iy = 0; iy < source->modelFlux->numRows; iy++) { 803 oy = iy + dY;792 int oy = iy + dY; 804 793 for (int ix = 0; ix < source->modelFlux->numCols; ix++) { 805 ox = ix + dX;794 int ox = ix + dX; 806 795 float value = Io*source->modelFlux->data.F32[iy][ix]; 807 796 if (add) { … … 812 801 } 813 802 } 803 return true; 804 } 805 806 if (add) { 807 status = pmModelAdd (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL); 814 808 } else { 815 if (add) { 816 pmModelAdd (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL); 817 } else { 818 pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL); 809 status = pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL); 810 } 811 812 return true; 813 } 814 815 bool pmSourceAdd (pmSource *source, pmModelOpMode mode) { 816 bool status = pmSourceOp (source, mode, true); 817 return status; 818 } 819 820 bool pmSourceSub (pmSource *source, pmModelOpMode mode) { 821 bool status = pmSourceOp (source, mode, false); 822 return status; 823 } 824 825 // given a source, which model is currently appropriate? 826 // choose PSF or EXT based on source->type, but fall back on PSF 827 // if the EXT model is NULL 828 pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source) 829 { 830 831 pmModel *model; 832 833 if (isPSF) { 834 *isPSF = false; 835 } 836 837 switch (source->type) { 838 case PM_SOURCE_TYPE_STAR: 839 model = source->modelPSF; 840 if (model == NULL) 841 return NULL; 842 if (isPSF) { 843 *isPSF = true; 819 844 } 820 } 821 822 if (add) { 823 psTrace ("psphot", 3, "replacing object at %f,%f\n", source->peak->xf, source->peak->yf); 824 } else { 825 psTrace ("psphot", 3, "removing object at %f,%f\n", source->peak->xf, source->peak->yf); 826 } 827 return true; 828 } 829 830 bool pmSourceAdd (pmSource *source, pmSourceOpMode mode) { 831 pmSourceOp (source, mode, true); 832 } 833 834 bool pmSourceSub (pmSource *source, pmSourceOpMode mode) { 835 pmSourceOp (source, mode, false); 836 } 845 return model; 846 847 case PM_SOURCE_TYPE_EXTENDED: 848 model = source->modelEXT; 849 if (!model && source->modelPSF) { 850 if (isPSF) { 851 *isPSF = true; 852 } 853 return source->modelPSF; 854 } 855 return (model); 856 break; 857 858 default: 859 return NULL; 860 } 861 return NULL; 862 }
Note:
See TracChangeset
for help on using the changeset viewer.
