Changeset 25754 for trunk/psModules/src/objects/pmSourceExtendedPars.c
- Timestamp:
- Oct 2, 2009, 3:11:32 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourceExtendedPars.c
r23487 r25754 17 17 #endif 18 18 19 #include <stdio.h>20 #include <math.h>21 #include <string.h>19 // #include <stdio.h> 20 // #include <math.h> 21 // #include <string.h> 22 22 #include <pslib.h> 23 #include "pmHDU.h" 24 #include "pmFPA.h" 25 #include "pmFPAMaskWeight.h" 26 #include "pmSpan.h" 27 #include "pmFootprint.h" 28 #include "pmPeaks.h" 29 #include "pmMoments.h" 30 #include "pmResiduals.h" 31 #include "pmGrowthCurve.h" 32 #include "pmTrend2D.h" 33 #include "pmPSF.h" 34 #include "pmModel.h" 35 #include "pmSource.h" 36 23 // #include "pmHDU.h" 24 // #include "pmFPA.h" 25 // #include "pmFPAMaskWeight.h" 26 // #include "pmSpan.h" 27 // #include "pmFootprint.h" 28 // #include "pmPeaks.h" 29 // #include "pmMoments.h" 30 // #include "pmResiduals.h" 31 // #include "pmGrowthCurve.h" 32 // #include "pmTrend2D.h" 33 // #include "pmPSF.h" 34 // #include "pmModel.h" 35 // #include "pmSource.h" 36 #include "pmSourceExtendedPars.h" 37 38 // *** pmSourceRadialProfile describes the radial profile of a source in elliptical contours, and 39 // intermediate data used to measure the profile 40 static void pmSourceRadialProfileFree(pmSourceRadialProfile *profile) 41 { 42 if (!profile) { 43 return; 44 } 45 psFree(profile->radii); 46 psFree(profile->fluxes); 47 psFree(profile->theta); 48 psFree(profile->isophotalRadii); 49 50 psFree(profile->radiusElliptical); 51 psFree(profile->fluxElliptical); 52 53 psFree(profile->binSB); 54 psFree(profile->binSBstdev); 55 psFree(profile->binSBerror); 56 57 psFree(profile->radialBins); 58 psFree(profile->area); 59 } 60 61 pmSourceRadialProfile *pmSourceRadialProfileAlloc() 62 { 63 pmSourceRadialProfile *profile = (pmSourceRadialProfile *)psAlloc(sizeof(pmSourceRadialProfile)); 64 psMemSetDeallocator(profile, (psFreeFunc) pmSourceRadialProfileFree); 65 66 profile->radii = NULL; 67 profile->fluxes = NULL; 68 profile->theta = NULL; 69 profile->isophotalRadii = NULL; 70 71 profile->radiusElliptical = NULL; 72 profile->fluxElliptical = NULL; 73 74 profile->binSB = NULL; 75 profile->binSBstdev = NULL; 76 profile->binSBerror = NULL; 77 78 profile->radialBins = NULL; 79 profile->area = NULL; 80 81 return profile; 82 } 83 84 bool psMemCheckSourceRadialProfile(psPtr ptr) 85 { 86 PS_ASSERT_PTR(ptr, false); 87 return ( psMemGetDeallocator(ptr) == (psFreeFunc) pmSourceRadialProfileFree); 88 } 89 90 91 // *** pmSourceRadialProfileFreeVectors frees the intermediate data values 92 bool pmSourceRadialProfileFreeVectors(pmSourceRadialProfile *profile) { 93 94 psFree(profile->radii); 95 psFree(profile->fluxes); 96 psFree(profile->theta); 97 psFree(profile->isophotalRadii); 98 99 psFree(profile->radiusElliptical); 100 psFree(profile->fluxElliptical); 101 102 // psFree(profile->binSB); 103 // psFree(profile->binSBstdev); 104 // psFree(profile->binSBerror); 105 106 // psFree(profile->radialBins); 107 psFree(profile->area); 108 109 profile->radii = NULL; 110 profile->fluxes = NULL; 111 profile->theta = NULL; 112 profile->isophotalRadii = NULL; 113 114 profile->radiusElliptical = NULL; 115 profile->fluxElliptical = NULL; 116 117 // profile->binSB = NULL; 118 // profile->binSBstdev = NULL; 119 // profile->binSBerror = NULL; 120 121 // profile->radialBins = NULL; 122 profile->area = NULL; 123 124 return true; 125 } 126 127 // *** pmSourceRadialProfileSortPair is a utility function for sorting a pair of vectors 128 # define COMPARE_INDEX(A,B) (index->data.F32[A] < index->data.F32[B]) 129 # define SWAP_INDEX(TYPE,A,B) { \ 130 float tmp; \ 131 if (A != B) { \ 132 tmp = index->data.F32[A]; \ 133 index->data.F32[A] = index->data.F32[B]; \ 134 index->data.F32[B] = tmp; \ 135 tmp = extra->data.F32[A]; \ 136 extra->data.F32[A] = extra->data.F32[B]; \ 137 extra->data.F32[B] = tmp; \ 138 } \ 139 } 140 141 bool pmSourceRadialProfileSortPair (psVector *index, psVector *extra) { 142 143 // sort the vector set by the radius 144 PSSORT (index->n, COMPARE_INDEX, SWAP_INDEX, NONE); 145 return true; 146 } 147 148 // *** pmSourceExtendedPars describes the possible collection of extended flux measurements for a source 37 149 static void pmSourceExtendedParsFree (pmSourceExtendedPars *pars) { 38 150 if (!pars) return; 39 151 40 152 psFree(pars->profile); 41 psFree(pars->annuli); 42 psFree(pars->isophot); 43 psFree(pars->petrosian); 44 psFree(pars->kron); 153 psFree(pars->petrosian_50); 154 psFree(pars->petrosian_80); 45 155 return; 46 156 } … … 51 161 52 162 pars->profile = NULL; 53 pars->annuli = NULL; 54 pars->isophot = NULL; 55 pars->petrosian = NULL; 56 pars->kron = NULL; 163 pars->petrosian_50 = NULL; 164 pars->petrosian_80 = NULL; 57 165 58 166 return pars; … … 66 174 67 175 68 static void pmSourceRadialProfileFree (pmSourceRadialProfile *profile) { 69 if (!profile) return; 70 71 psFree(profile->radius); 72 psFree(profile->flux); 73 psFree(profile->variance); 176 // *** pmSourceExtendedFlux describes the flux within an elliptical aperture of some kind 177 static void pmSourceExtendedFluxFree (pmSourceExtendedFlux *flux) { 178 if (!flux) return; 74 179 return; 75 180 } 76 181 77 pmSourceRadialProfile *pmSourceRadialProfileAlloc (void) { 78 79 pmSourceRadialProfile *profile = (pmSourceRadialProfile *) psAlloc(sizeof(pmSourceRadialProfile)); 80 psMemSetDeallocator(profile, (psFreeFunc) pmSourceRadialProfileFree); 81 82 profile->radius = NULL; 83 profile->flux = NULL; 84 profile->variance = NULL; 85 86 return profile; 87 } 88 89 bool psMemCheckSourceRadialProfile(psPtr ptr) 182 pmSourceExtendedFlux *pmSourceExtendedFluxAlloc (void) { 183 184 pmSourceExtendedFlux *flux = (pmSourceExtendedFlux *) psAlloc(sizeof(pmSourceExtendedFlux)); 185 psMemSetDeallocator(flux, (psFreeFunc) pmSourceExtendedFluxFree); 186 187 flux->flux = 0.0; 188 flux->fluxErr = 0.0; 189 flux->radius = 0.0; 190 flux->radiusErr = 0.0; 191 192 return flux; 193 } 194 195 196 bool psMemCheckSourceExtendedFlux(psPtr ptr) 90 197 { 91 198 PS_ASSERT_PTR(ptr, false); 92 return ( psMemGetDeallocator(ptr) == (psFreeFunc) pmSourceRadialProfileFree); 93 } 94 95 96 static void pmSourceIsophotalValuesFree (pmSourceIsophotalValues *isophot) { 97 if (!isophot) return; 98 return; 99 } 100 101 pmSourceIsophotalValues *pmSourceIsophotalValuesAlloc (void) { 102 103 pmSourceIsophotalValues *isophot = (pmSourceIsophotalValues *) psAlloc(sizeof(pmSourceIsophotalValues)); 104 psMemSetDeallocator(isophot, (psFreeFunc) pmSourceIsophotalValuesFree); 105 106 isophot->mag = 0.0; 107 isophot->magErr = 0.0; 108 isophot->rad = 0.0; 109 isophot->radErr = 0.0; 110 111 return isophot; 112 } 113 114 115 bool psMemCheckSourceIsophotalValues(psPtr ptr) 116 { 117 PS_ASSERT_PTR(ptr, false); 118 return ( psMemGetDeallocator(ptr) == (psFreeFunc) pmSourceIsophotalValuesFree); 119 } 120 121 122 static void pmSourcePetrosianValuesFree (pmSourcePetrosianValues *petrosian) { 123 if (!petrosian) return; 124 return; 125 } 126 127 pmSourcePetrosianValues *pmSourcePetrosianValuesAlloc (void) { 128 129 pmSourcePetrosianValues *petrosian = (pmSourcePetrosianValues *) psAlloc(sizeof(pmSourcePetrosianValues)); 130 psMemSetDeallocator(petrosian, (psFreeFunc) pmSourcePetrosianValuesFree); 131 132 petrosian->mag = 0.0; 133 petrosian->magErr = 0.0; 134 petrosian->rad = 0.0; 135 petrosian->radErr = 0.0; 136 137 return petrosian; 138 } 139 140 141 bool psMemCheckSourcePetrosianValues(psPtr ptr) 142 { 143 PS_ASSERT_PTR(ptr, false); 144 return ( psMemGetDeallocator(ptr) == (psFreeFunc) pmSourcePetrosianValuesFree); 145 } 146 147 static void pmSourceKronValuesFree (pmSourceKronValues *kron) { 148 if (!kron) return; 149 return; 150 } 151 152 pmSourceKronValues *pmSourceKronValuesAlloc (void) { 153 154 pmSourceKronValues *kron = (pmSourceKronValues *) psAlloc(sizeof(pmSourceKronValues)); 155 psMemSetDeallocator(kron, (psFreeFunc) pmSourceKronValuesFree); 156 157 kron->mag = 0.0; 158 kron->magErr = 0.0; 159 kron->rad = 0.0; 160 kron->radErr = 0.0; 161 162 return kron; 163 } 164 165 166 bool psMemCheckSourceKronValues(psPtr ptr) 167 { 168 PS_ASSERT_PTR(ptr, false); 169 return ( psMemGetDeallocator(ptr) == (psFreeFunc) pmSourceKronValuesFree); 170 } 171 172 173 static void pmSourceAnnuliFree (pmSourceAnnuli *annuli) { 174 if (!annuli) return; 175 176 psFree (annuli->flux); 177 psFree (annuli->fluxErr); 178 psFree (annuli->fluxVar); 179 180 return; 181 } 182 183 pmSourceAnnuli *pmSourceAnnuliAlloc (void) { 184 185 pmSourceAnnuli *annuli = (pmSourceAnnuli *) psAlloc(sizeof(pmSourceAnnuli)); 186 psMemSetDeallocator(annuli, (psFreeFunc) pmSourceAnnuliFree); 187 188 annuli->flux = NULL; 189 annuli->fluxErr = NULL; 190 annuli->fluxVar = NULL; 191 192 return annuli; 193 } 194 195 196 bool psMemCheckSourceAnnuli(psPtr ptr) 197 { 198 PS_ASSERT_PTR(ptr, false); 199 return ( psMemGetDeallocator(ptr) == (psFreeFunc) pmSourceAnnuliFree); 200 } 199 return ( psMemGetDeallocator(ptr) == (psFreeFunc) pmSourceExtendedFluxFree); 200 }
Note:
See TracChangeset
for help on using the changeset viewer.
