Changeset 8886
- Timestamp:
- Sep 22, 2006, 11:35:34 AM (20 years ago)
- Location:
- trunk/psModules/src
- Files:
-
- 4 edited
-
detrend/pmShutterCorrection.c (modified) (8 diffs)
-
objects/Makefile.am (modified) (2 diffs)
-
objects/pmGrowthCurve.c (modified) (3 diffs)
-
psmodules.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmShutterCorrection.c
r8884 r8886 61 61 62 62 #include "pmShutterCorrection.h" 63 #include "psVectorBracket.h" 63 64 64 65 static void pmShutterCorrParsFree (pmShutterCorrPars *pars) … … 89 90 90 91 pmShutterCorrPars *pars = pmShutterCorrParsAlloc (); 91 92 N = exptime->n; 92 psPolynomial1D *line = psPolynomial1DAlloc (PS_POLYNOMIAL_ORD, 1); 93 94 int N = exptime->n; 93 95 // ASSERT (N >> 5) 94 96 … … 111 113 112 114 // fit a line and extrapolate the fit to 0.0 113 psPolynomial1D *line = psPolynomial1DAlloc (PS_POLYNOMIAL_ORD, 1); 114 line = psVectorFitPolynomial1D (line, NULL, 0, tmpY, NULL, tmpX); 115 ratio = psPolynomial1DEval (line, 0.0) / pars->scale; 115 psVectorFitPolynomial1D (line, NULL, 0, tmpY, NULL, tmpX); 116 float ratio = psPolynomial1DEval (line, 0.0) / pars->scale; 116 117 117 118 // XXX we need a sanity check: … … 122 123 123 124 // find two points bracketing the value counts = A (1 + dTk/dTo) / 2 = pars->scale (1 + ratio) / 2 124 value = pars->scale * (1 + ratio) / 2.0;125 126 Nm = psVectorBracket (exptime, value, (ratio < 1.0));127 Np = (Nm == N - 1) ? Nm - 1 : Nm + 1;125 float value = pars->scale * (1 + ratio) / 2.0; 126 127 int Nm = psVectorBracket (exptime, value, (ratio < 1.0)); 128 int Np = (Nm == N - 1) ? Nm - 1 : Nm + 1; 128 129 129 130 tmpX->data.F64[0] = counts->data.F64[Nm]; … … 133 134 134 135 // fit a line and extrapolate the fit to counts = A (1 + dTk/dTo) : exptime = dTo 135 psPolynomial1D *line = psPolynomial1DAlloc (PS_POLYNOMIAL_ORD, 1);136 136 line = psVectorFitPolynomial1D (line, NULL, 0, tmpY, NULL, tmpX); 137 137 pars->offref = psPolynomial1DEval (line, value); … … 154 154 155 155 for (int i = 0; i < exptime->n; i++) { 156 value = 1.0 / (exptime->data.F32[i] + offref);156 float value = 1.0 / (exptime->data.F32[i] + offref); 157 157 x->data.F32[i] = exptime->data.F32[i] * value; 158 158 y->data.F32[i] = value; … … 171 171 pmShutterCorrPars *pars = pmShutterCorrParsAlloc (); 172 172 173 pars->offref = guess->offref;173 pars->offref = offref; 174 174 pars->scale = line->coeff[1][0]; 175 175 pars->offset = line->coeff[0][1] / line->coeff[1][0]; … … 235 235 } 236 236 237 fitStatus =psMinimizeLMChi2(myMin, covar, params, constrain, x, y, yErr, pmShutterCorrectionModel);237 psMinimizeLMChi2(myMin, covar, params, constrain, x, y, yErr, pmShutterCorrectionModel); 238 238 239 239 pmShutterCorrPars *pars = pmShutterCorrParsAlloc (); -
trunk/psModules/src/objects/Makefile.am
r8569 r8886 22 22 pmPSF_IO.c \ 23 23 pmPSFtry.c \ 24 pmGrowthCurve.c 24 pmGrowthCurve.c \ 25 psVectorBracket.c 25 26 26 27 EXTRA_DIST = \ … … 45 46 pmPSF_IO.h \ 46 47 pmPSFtry.h \ 47 pmGrowthCurve.h 48 pmGrowthCurve.h \ 49 psVectorBracket.h 48 50 49 51 CLEANFILES = *~ -
trunk/psModules/src/objects/pmGrowthCurve.c
r8815 r8886 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $8 * @date $Date: 2006-09- 15 09:49:01$7 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2006-09-22 21:35:34 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 18 18 #include <pslib.h> 19 19 #include "pmGrowthCurve.h" 20 #include "psVectorBracket.h" 20 21 21 22 static void pmGrowthCurveFree (pmGrowthCurve *growth) … … 57 58 } 58 59 59 // return the last entry below or first entry above key value60 int psVectorBracket (psVector *index, psF32 key, bool above)61 {62 63 int N;64 int Nlo = 0;65 int Nhi = index->n;66 67 if (above) {68 while (Nhi - Nlo > 10) {69 N = 0.5*(Nlo + Nhi);70 if (index->data.F32[N] > key) {71 Nhi = N;72 } else {73 Nlo = N - 1;74 }75 }76 // at this point, index[Nhi] > key >= index[Nlo]77 N = Nlo;78 while ((index->data.F32[N] <= key) && (N < Nhi)) {79 N++;80 }81 return (N);82 }83 while (Nhi - Nlo > 10) {84 N = 0.5*(Nlo + Nhi);85 if (index->data.F32[N] < key) {86 Nlo = N;87 } else {88 Nhi = N + 1;89 }90 }91 // at this point, index[Nhi] >= key > index[Nlo]92 N = Nhi;93 while ((index->data.F32[N] >= key) && (N > Nlo)) {94 N--;95 }96 return (N);97 }98 99 // search for the bins bounding key in index, interpolate the corresponding values100 psF32 psVectorInterpolate (psVector *index, psVector *value, psF32 key)101 {102 103 int n0 = 0;104 int n1 = 0;105 106 // extrapolate at ends107 if (key < index->data.F32[0]) {108 n0 = 0;109 n1 = 1;110 }111 112 // extrapolate at ends113 if (key > index->data.F32[index->n-1]) {114 n0 = index->n-2;115 n1 = index->n-1;116 }117 118 if (n1 == 0) {119 n0 = psVectorBracket (index, key, FALSE);120 n1 = n0 + 1;121 }122 123 if (n0 == index->n-1) {124 n1 = n0;125 n0 = n1 - 1;126 }127 128 float dy = value->data.F32[n1] - value->data.F32[n0];129 float dx = index->data.F32[n1] - index->data.F32[n0];130 float dX = key - index->data.F32[n0];131 float dY = dX * (dy/dx);132 float result = value->data.F32[n0] + dY;133 return result;134 }135 -
trunk/psModules/src/psmodules.h
r7679 r8886 44 44 #include <pmSubtractBias.h> 45 45 #include <pmDetrendDB.h> 46 #include <pmShutterCorrection.h> 46 47 // #include <pmSubtractSky.h> 47 48 … … 70 71 #include <pmModelGroup.h> 71 72 #include <pmSourcePhotometry.h> 73 #include <psVectorBracket.h> 72 74 73 75 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
