Changeset 8002
- Timestamp:
- Jul 27, 2006, 4:51:49 PM (20 years ago)
- Location:
- trunk/Ohana/src/addstar/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/src/SEDfit.c
r7714 r8002 1 1 # include "sedstar.h" 2 3 // XXX a couple of fixes should speed this up a bit: test 2 4 3 5 int SEDfitCatalog (Catalog *outcat, Catalog *incat, SEDtable *table) { … … 7 9 unsigned short USNOred, USNOblu; 8 10 float color; 9 int *found, valid ;11 int *found, valid, *modelRow, *reqRow; 10 12 11 13 SEDtableRow sourceValue, sourceError; 12 14 SEDfit minFit, testFit; 15 16 Nmodel = Nreq = 0; 17 for (i = 0; i < table[0].Nfilter; i++) { 18 if (table[0].mode[i] == SED_REQ) Nreq ++; 19 if (table[0].mode[i] == SED_MODEL) Nmodel ++; 20 } 21 if (Nmodel < 1) { 22 fprintf (stderr, "no model filter defined\n!"); 23 exit (2); 24 } 25 if (Nreq < 1) { 26 fprintf (stderr, "no required filter defined\n!"); 27 exit (2); 28 } 29 30 ALLOCATE (modelRow, int, Nmodel); 31 for (j = i = 0; i < table[0].Nfilter; i++) { 32 if (table[0].mode[i] == SED_MODEL) { 33 modelRow[j] = i; 34 j++; 35 } 36 } 37 ALLOCATE (reqRow, int, Nreq); 38 for (j = i = 0; i < table[0].Nfilter; i++) { 39 if (table[0].mode[i] == SED_REQ) { 40 reqRow[j] = i; 41 j++; 42 } 43 } 13 44 14 45 sourceValue.mags = NULL; … … 64 95 if (Nphot < 3) continue; 65 96 97 // XXX pre-select list of REQ entries; loop over only those? 66 98 valid = TRUE; 67 for (j = 0; valid && (j < table[0].Nfilter); j++) {68 if ((table[0].mode[ j] == SED_REQ) && !found[j]) valid = FALSE;99 for (j = 0; valid && (j < Nreq); j++) { 100 if ((table[0].mode[reqRow[j]] == SED_REQ) && !found[reqRow[j]]) valid = FALSE; 69 101 } 70 102 if (!valid) continue; … … 77 109 // find tableRow within 0.1 mag of color 78 110 // XXX : check on the delta value 79 start = SEDcolorBracket (table, color );111 start = SEDcolorBracket (table, color, 0.05); 80 112 minFit = SEDchisq (table[0].row[start], &sourceValue, &sourceError, table[0].Nfilter); 81 113 minFit.row = start; … … 91 123 minFit.row = row; 92 124 } 93 if (fabs(table[0].row[row][0].color - color) > 0. 5) done = TRUE;125 if (fabs(table[0].row[row][0].color - color) > 0.25) done = TRUE; 94 126 row --; 95 127 } … … 105 137 minFit.row = row; 106 138 } 107 if (fabs(table[0].row[row][0].color - color) > 0. 5) done = TRUE;139 if (fabs(table[0].row[row][0].color - color) > 0.25) done = TRUE; 108 140 row ++; 109 141 } … … 145 177 146 178 // we now have the min chisq row. use this to supply the other filter values.... 147 for (j = 0; valid && (j < table[0].Nfilter); j++) { 148 if (table[0].mode[j] != SED_MODEL) continue; 179 // XXX pre-select the SED_MODEL rows... 180 if (Nmeas + table[0].Nfilter >= NMEAS) { 181 NMEAS += 100 + table[0].Nfilter; 182 REALLOCATE (outcat[0].measure, Measure, NMEAS); 183 } 184 185 for (j = 0; valid && (j < Nmodel; j++) { 186 n = modelRow[j]; 149 187 outcat[0].measure[Nmeas].dR_PS = 0.0; 150 188 outcat[0].measure[Nmeas].dD_PS = 0.0; 151 outcat[0].measure[Nmeas].M_PS = MIN (table[0].row[minFit.row][0].mags[ j] + minFit.Md, NO_MAG);189 outcat[0].measure[Nmeas].M_PS = MIN (table[0].row[minFit.row][0].mags[n] + minFit.Md, NO_MAG); 152 190 outcat[0].measure[Nmeas].dM_PS = 0.0; 153 191 outcat[0].measure[Nmeas].Mcal_PS = 0; 154 192 outcat[0].measure[Nmeas].t = TIMEREF; 155 193 outcat[0].measure[Nmeas].averef = Nave; 156 outcat[0].measure[Nmeas].source = table[0].code[ j];194 outcat[0].measure[Nmeas].source = table[0].code[n]; 157 195 outcat[0].measure[Nmeas].dophot = 0; 158 196 outcat[0].measure[Nmeas].flags = 0; … … 167 205 outcat[0].average[Nave].Nm++; 168 206 Nmeas ++; 169 CHECK_REALLOCATE (outcat[0].measure, Measure, NMEAS, Nmeas, 100);170 207 } 171 208 … … 180 217 outcat[0].Nmeasure = Nmeas; 181 218 219 free (sourceValue.mags); 220 free (sourceError.mags); 221 free (found); 222 182 223 SEDfitClear (); 183 224 } -
trunk/Ohana/src/addstar/src/SEDops.c
r7696 r8002 34 34 35 35 // find the first table row within 0.1 mag of the requested color (or within 10) 36 int SEDcolorBracket (SEDtable *table, float color ) {36 int SEDcolorBracket (SEDtable *table, float color, float delta) { 37 37 38 38 int Nlo, Nhi, N; … … 41 41 N = Nlo = 0; Nhi = table[0].Nrow; 42 42 tcolor = table[0].row[Nlo][0].color; 43 while ((Nhi - Nlo > 10) && (fabs(tcolor-color) > 0.1)) {43 while ((Nhi - Nlo > 10) && (fabs(tcolor-color) > delta)) { 44 44 N = 0.5*(Nlo + Nhi); 45 45 N = MAX (N, 0); -
trunk/Ohana/src/addstar/src/sedstar.c
r7696 r8002 3 3 int main (int argc, char **argv) { 4 4 5 char *root, *ext ;6 int i, N, N refcat, status;5 char *root, *ext, tmp; 6 int i, N, Nbytes, Nrefcat, status; 7 7 SkyList *skylist; 8 8 SkyTable *sky, *sky2mass; … … 42 42 43 43 ext = incatalog.filename + strlen(CATDIR); 44 ALLOCATE (outcatalog.filename, char, strlen(argv[2]) + strlen(ext) + 2); 45 sprintf (outcatalog.filename, "%s/%s", argv[2], ext); 44 while (*ext == '/') ext++; 45 46 Nbytes = snprintf (&tmp, 0, "%s/%s", argv[2], ext); 47 ALLOCATE (outcatalog.filename, char, Nbytes + 1); 48 snprintf (outcatalog.filename, Nbytes + 1, "%s/%s", argv[2], ext); 46 49 47 50 if (!check_file_access (outcatalog.filename, TRUE, TRUE)) Shutdown ("can't create output directory"); … … 56 59 unlock_catalog (&outcatalog); 57 60 free (outcatalog.filename); 61 free_catalog (&outcatalog); 58 62 59 63 unlock_catalog (&incatalog); 64 free_catalog (&incatalog); 60 65 } 61 66
Note:
See TracChangeset
for help on using the changeset viewer.
