Changeset 38486
- Timestamp:
- Jun 17, 2015, 5:33:20 AM (11 years ago)
- Location:
- branches/eam_branches/ipp-20150616/Ohana/src/addstar
- Files:
-
- 4 edited
-
include/loadgalphot.h (modified) (1 diff)
-
src/loadgalphot_catalog.c (modified) (1 diff)
-
src/loadgalphot_fit2d.c (modified) (5 diffs)
-
src/loadgalphot_readstars.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150616/Ohana/src/addstar/include/loadgalphot.h
r38483 r38486 48 48 void fit2d_free (Fit2D *fit); 49 49 int fit2d (Fit2D *fit, float *xval, float *yval, float *zval, float *zfit, char *mask, int Npts); 50 int fit2d_reset (Fit2D *fit); -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_catalog.c
r38483 r38486 7 7 8 8 // now we have all of the loaded stars in this catalog 9 dvo_catalog_init (&catalog, TRUE); 9 10 catalog.filename = filename; 10 11 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_fit2d.c
r38483 r38486 7 7 8 8 Fit2D *fit; 9 ALLOCATE (fit, Fit2D, 1);9 ALLOCATE_ZERO (fit, Fit2D, 1); 10 10 11 11 // allocate static arrays 12 fit->order = order; 12 13 fit->nterm = order + 1; 13 14 fit->wterm = fit->nterm*(fit->nterm + 1)/2; … … 19 20 ALLOCATE (fit->c, double *, fit->wterm); 20 21 for (i = 0; i < fit->wterm; i++) { 21 ALLOCATE (fit->c[i], double, fit->wterm);22 ALLOCATE (fit->b[i], double, 1);22 ALLOCATE_ZERO (fit->c[i], double, fit->wterm); 23 ALLOCATE_ZERO (fit->b[i], double, 1); 23 24 } 24 25 for (i = 0; i < fit->mterm; i++) { 25 ALLOCATE (fit->s[i], double, fit->mterm); 26 } 26 ALLOCATE_ZERO (fit->s[i], double, fit->mterm); 27 } 28 ALLOCATE_ZERO (fit->Cii, double, fit->wterm); 27 29 return fit; 30 } 31 32 int fit2d_reset (Fit2D *fit) { 33 34 int i; 35 36 for (i = 0; i < fit->wterm; i++) { 37 memset (fit->c[i], 0, fit->wterm*sizeof(double)); 38 memset (fit->b[i], 0, sizeof(double)); 39 } 40 for (i = 0; i < fit->mterm; i++) { 41 memset (fit->s[i], 0, fit->mterm*sizeof(double)); 42 } 43 return TRUE; 28 44 } 29 45 … … 49 65 int fit2d (Fit2D *fit, float *xval, float *yval, float *zval, float *zfit, char *mask, int Npts) { 50 66 51 int N, i, j, nx, ny, K, k, n, Npt ;67 int N, i, j, nx, ny, K, k, n, Npt, status; 52 68 53 69 double mean, sigma, maxsigma; … … 59 75 60 76 for (N = 0; N < ClipNiter; N++) { 61 /* init registers for current pass */ 62 for (i = 0; i < fit->wterm; i++) { 63 memset (fit->c[i], 0, fit->wterm*sizeof(double)); 64 memset (fit->b[i], 0, sizeof(double)); 65 } 66 for (i = 0; i < fit->mterm; i++) { 67 memset (fit->s[i], 0, fit->mterm*sizeof(double)); 68 } 77 fit2d_reset (fit); 69 78 70 79 // pointers which loop over datapoints … … 120 129 121 130 // invert the c,b matrix equation 122 dgaussjordan (fit->c, fit->b, fit->wterm, 1); 131 status = dgaussjordan (fit->c, fit->b, fit->wterm, 1); 132 if (!status) return FALSE; 123 133 124 134 /* the b[][0] terms are in the following order: -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_readstars.c
r38483 r38486 93 93 Fit2D *fit = fit2d_init (2); 94 94 95 int Nbad = 0; 95 96 for (i = 0; i < Nrow; i++) { 96 97 … … 117 118 // I need to find the minimum position (interpolated) in this 2D space 118 119 119 FitChisqMinimum (fit, &stars[i].galphot, &GAL_CHISQ[Nsample*i], &GAL_FLUX[Nsample*i], &GAL_FLUX_ERR[Nsample*i], Nsample, FR_MAJOR_MIN[i], FR_MAJOR_MAX[i], FR_MAJOR_DEL[i], FR_MINOR_MIN[i], FR_MINOR_MAX[i], FR_MINOR_DEL[i]); 120 if (!FitChisqMinimum (fit, &stars[i].galphot, &GAL_CHISQ[Nsample*i], &GAL_FLUX[Nsample*i], &GAL_FLUX_ERR[Nsample*i], Nsample, FR_MAJOR_MIN[i], FR_MAJOR_MAX[i], FR_MAJOR_DEL[i], FR_MINOR_MIN[i], FR_MINOR_MAX[i], FR_MINOR_DEL[i])) { 121 Nbad ++; 122 } 120 123 } 121 124 … … 129 132 fit2d_free (fit); 130 133 134 fprintf (stderr, "Nbad: %d of %d\n", Nbad, (int) Nrow); 135 131 136 *nstars = Nrow; 132 137 return (stars); … … 155 160 // validate the square dimensions?? 156 161 157 int Nx = (MajorMax - MajorMin) / MajorDel;158 int Ny = (MinorMax - MinorMin) / MinorDel;162 int Nx = nearbyint((MajorMax - MajorMin) / MajorDel) + 1; 163 int Ny = nearbyint((MinorMax - MinorMin) / MinorDel) + 1; 159 164 myAssert (Nx*Ny == Npts, "inconsistent grid"); 160 165 … … 193 198 galphot->majorAxisErr = MajorDel; 194 199 galphot->minorAxisErr = MinorDel; 195 return TRUE;200 return FALSE; 196 201 } 197 202 … … 217 222 218 223 // fit the inner 9 points 219 fit2d (fit, Xpt, Ypt, chisq, chisqFit, mask, Npts); 224 if (!fit2d (fit, Xpt, Ypt, chisq, chisqFit, mask, Npts)) { 225 // raise a flag? 226 galphot->majorAxis = Xpt[iMin]; 227 galphot->minorAxis = Ypt[iMin]; 228 galphot->majorAxisErr = MajorDel; 229 galphot->minorAxisErr = MinorDel; 230 return FALSE; 231 } 220 232 221 233 // exclude any extreme outliers … … 230 242 231 243 // re-fit all except the most extreme set 232 fit2d (fit, Xpt, Ypt, chisq, chisqFit, mask, Npts); 244 if (!fit2d (fit, Xpt, Ypt, chisq, chisqFit, mask, Npts)) { 245 // raise a flag? 246 galphot->majorAxis = Xpt[iMin]; 247 galphot->minorAxis = Ypt[iMin]; 248 galphot->majorAxisErr = MajorDel; 249 galphot->minorAxisErr = MinorDel; 250 return FALSE; 251 } 233 252 234 253 // get X,Y for the chisq min from the fit: … … 269 288 galphot->magErr = -2.5*log10(fluxErr[iMin]); // correct for exptime? 270 289 galphot->chisq = chisqMin; 271 272 290 273 291 return TRUE;
Note:
See TracChangeset
for help on using the changeset viewer.
