Changeset 38515 for trunk/psphot/src/psphotMergeSources.c
- Timestamp:
- Jun 22, 2015, 3:23:53 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotMergeSources.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotMergeSources.c
r38389 r38515 853 853 // array containing the child sources. XXX currently, this is only used by psphotStackReadout 854 854 // (sources go on allSources so that psphotChoosePSF can be called repeatedly) 855 psArray *psphotSourceChildrenByObject (pmConfig *config, const pmFPAview *view, const char *filerule , psArray *objectsSrc, bool sourcesSubtracted) {855 psArray *psphotSourceChildrenByObject (pmConfig *config, const pmFPAview *view, const char *fileruleOut, const char *fileruleSrc, psArray *objectsSrc, bool sourcesSubtracted) { 856 856 857 857 bool status; 858 858 859 int nImages = psphotFileruleCount(config, filerule );859 int nImages = psphotFileruleCount(config, fileruleOut); 860 860 861 861 // generate look-up arrays for detections and readouts 862 862 psArray *detArrays = psArrayAlloc(nImages); 863 863 psArray *readouts = psArrayAlloc(nImages); 864 psArray *fitOptionsArray = psArrayAlloc(nImages); 865 866 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 867 assert (recipe); 868 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); 869 assert (maskVal); 870 int psfSize = psMetadataLookupS32 (&status, recipe, "PCM_BOX_SIZE"); 871 assert (status); 864 872 865 873 for (int i = 0; i < nImages; i++) { 866 874 867 875 // find the currently selected readout 868 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule , i); // File of interest876 pmFPAfile *file = pmFPAfileSelectSingle(config->files, fileruleOut, i); // File of interest 869 877 psAssert (file, "missing file?"); 870 878 871 879 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 872 880 psAssert (readout, "missing readout?"); 881 882 pmFPAfile *fileSrc = pmFPAfileSelectSingle(config->files, fileruleSrc, i); // File of interest 883 psAssert (file, "missing file?"); 884 885 pmReadout *readoutSrc = pmFPAviewThisReadout(view, fileSrc->fpa); 886 psAssert (readoutSrc, "missing readout?"); 887 873 888 874 889 // create DETECTIONS containers for each image, in case one lacks it … … 886 901 psAssert (detections, "missing detections?"); 887 902 } 903 pmSourceFitOptions *fitOptions = psMetadataLookupPtr (&status, readoutSrc->analysis, "PCM_FIT_OPTIONS"); 904 psAssert (fitOptions, "missing pcm fit options"); 905 psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PCM_FIT_OPTIONS", PS_DATA_UNKNOWN | PS_META_REPLACE, "pcm fit options", fitOptions); 888 906 889 907 // we need to save the new sources on the detection arrays of the appropriate image 890 908 detArrays->data[i] = psMemIncrRefCounter(detections); 891 909 readouts->data[i] = psMemIncrRefCounter(readout); 910 fitOptionsArray->data[i] = psMemIncrRefCounter(fitOptions); 892 911 } 893 912 … … 932 951 // does this copy all model data? (NO) 933 952 sourceOut->modelPSF = pmModelCopy(sourceSrc->modelPSF); 934 sourceOut->modelEXT = pmModelCopy(sourceSrc->modelEXT); 935 953 954 bool foundModelEXT = false; 936 955 if (sourceSrc->modelFits) { 937 956 sourceOut->modelFits = psArrayAlloc(sourceSrc->modelFits->n); 938 957 for (int j = 0; j < sourceSrc->modelFits->n; j++) { 939 sourceOut->modelFits->data[j] = pmModelCopy(sourceSrc->modelFits->data[j]); 940 } 958 pmModel *modelSrc = sourceSrc->modelFits->data[j]; 959 pmModel *modelOut = sourceOut->modelFits->data[j] = pmModelCopy(modelSrc); 960 if (modelSrc == sourceSrc->modelEXT) { 961 foundModelEXT = true; 962 sourceOut->modelEXT = psMemIncrRefCounter (modelOut); 963 } 964 modelOut->isPCM = modelSrc->isPCM; 965 } 941 966 } 967 if (!foundModelEXT && sourceSrc->modelEXT) { 968 // Will this ever happen? 969 sourceOut->modelEXT = pmModelCopy(sourceSrc->modelEXT); 970 } 942 971 943 972 // drop the references to the original image pixels: … … 949 978 pmReadout *readout = readouts->data[index]; 950 979 980 pmSourceFitOptions *fitOptions = fitOptionsArray->data[index]; 981 951 982 // allocate image, weight, mask for the new image for each peak 952 983 if (sourceOut->modelPSF) { 953 984 pmSourceRedefinePixels (sourceOut, readout, sourceOut->peak->x, sourceOut->peak->y, 954 source Out->modelPSF->fitRadius);985 sourceSrc->windowRadius); 955 986 } else { 956 987 // if we have no pixels we can't use it to determine the psf so make sure this bit is off … … 965 996 if (!sourcesSubtracted) { 966 997 sourceOut->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; 967 } 998 } else { 999 if (sourceSrc->modelFlux) { 1000 bool isPSF = false; 1001 pmModel *model = pmSourceGetModel (&isPSF, sourceOut); 1002 if (model->isPCM) { 1003 pmPCMdata *pcm = pmPCMinit (sourceOut, fitOptions, model, maskVal, psfSize); 1004 if (pcm) { 1005 // pmPCMMakeModel (sourceOut, model, pcm->nsigma, maskVal, psfSize); 1006 pmPCMCacheModel (sourceOut, maskVal, psfSize, pcm->nsigma); 1007 psFree(pcm); 1008 } else { 1009 // What to do here? 1010 psAssert (pcm, "pmPCMinit failed!"); 1011 } 1012 } else { 1013 pmSourceCacheModel (sourceOut, maskVal); 1014 } 1015 } 1016 } 968 1017 969 1018 // set the output detections: … … 981 1030 psFree (detArrays); 982 1031 psFree (readouts); 1032 psFree (fitOptionsArray); 983 1033 984 1034 return objectsOut;
Note:
See TracChangeset
for help on using the changeset viewer.
