Changeset 31261
- Timestamp:
- Apr 10, 2011, 4:42:40 PM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110404/Ohana/src/relphot
- Files:
-
- 11 edited
-
include/relphot.h (modified) (1 diff)
-
src/GridOps.c (modified) (10 diffs)
-
src/ImageOps.c (modified) (5 diffs)
-
src/MosaicOps.c (modified) (5 diffs)
-
src/StarOps.c (modified) (19 diffs)
-
src/bcatalog.c (modified) (7 diffs)
-
src/initialize.c (modified) (2 diffs)
-
src/plot_scatter.c (modified) (1 diff)
-
src/select_images.c (modified) (1 diff)
-
src/setExclusions.c (modified) (2 diffs)
-
src/setMrelFinal.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110404/Ohana/src/relphot/include/relphot.h
r31260 r31261 85 85 int RELPHOT_GRID_BINNING; 86 86 87 PhotCode *photcode; 88 int PhotNsec; 89 int PhotSec; 87 int *photseclist; 88 int Nphotcodes; 89 PhotCode **photcodes; 90 // int PhotSec; 91 // int PhotNsec; 90 92 91 93 PhotCode *refPhotcode; -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/GridOps.c
r28241 r31261 410 410 // select the color- and airmass-corrected observed magnitude for this star 411 411 // XXX need to be able to turn off the color-correction until initial average mags are found 412 // Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*PhotNsec]);413 412 Msys = PhotCat (&catalog[c].measure[m]); 414 413 if (isnan(Msys)) { … … 528 527 if (!USE_GRID) return; 529 528 529 int Nsecfilt = GetPhotcodeNsecfilt (); 530 530 531 Nmax = Nlist[0]; 531 532 for (i = 0; i < Ngrid; i++) { … … 566 567 567 568 n = catalog[c].measure[m].averef; 568 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n* PhotNsec]);569 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*Nsecfilt]); 569 570 if (isnan(Msys)) { 570 571 Nsys++; … … 612 613 613 614 if (!USE_GRID) return; 615 616 int Nsecfilt = GetPhotcodeNsecfilt (); 614 617 615 618 N = 0; … … 642 645 643 646 n = catalog[c].measure[m].averef; 644 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n* PhotNsec]);647 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*Nsecfilt]); 645 648 646 649 xlist[N] = Xmeas[c][m]; … … 704 707 gfits_create_matrix (&header, &matrix); 705 708 gfits_modify (&header, "NEXTEND", OFF_T_FMT, 1, Nimage + 3); 706 gfits_modify (&header, "FILTER", "%s", 1, photcode [0].name);709 gfits_modify (&header, "FILTER", "%s", 1, photcodes[0][0].name); // XXXX note that this expects a single photcode, enforced in initialize.d 707 710 gfits_modify_alt (&header, "COMMENT", "%S", 1, "Mosaic Photometry Grid Analysis"); 708 711 … … 727 730 theader.bitpix = -32; 728 731 gfits_create_Theader (&theader, "IMAGE"); 729 gfits_modify (&theader, "FILTER", "%s", 1, photcode [0].name);732 gfits_modify (&theader, "FILTER", "%s", 1, photcodes[0][0].name); 730 733 gfits_modify (&theader, "EXTNAME", "%s", 1, "MAG_OFFSET"); 731 734 gfits_create_matrix (&theader, &matrix); … … 742 745 /* save grid Nmeas values */ 743 746 gfits_modify (&theader, "EXTNAME", "%s", 1, "NMEAS"); 744 gfits_modify (&theader, "FILTER", "%s", 1, photcode [0].name);747 gfits_modify (&theader, "FILTER", "%s", 1, photcodes[0][0].name); 745 748 gfits_create_matrix (&theader, &matrix); 746 749 for (i = 0; i < gridX; i++) { … … 756 759 /* save grid sigma values */ 757 760 gfits_modify (&theader, "EXTNAME", "%s", 1, "SIGMA"); 758 gfits_modify (&theader, "FILTER", "%s", 1, photcode [0].name);761 gfits_modify (&theader, "FILTER", "%s", 1, photcodes[0][0].name); 759 762 gfits_create_matrix (&theader, &matrix); 760 763 for (i = 0; i < gridX; i++) { … … 776 779 777 780 gfits_modify (&theader, "EXTNAME", "%s", 1, camera.ccdname[N]); 778 gfits_modify (&theader, "FILTER", "%s", 1, photcode [0].name);781 gfits_modify (&theader, "FILTER", "%s", 1, photcodes[0][0].name); 779 782 gfits_modify (&theader, "NX", "%d", 1, camera.Nx); 780 783 gfits_modify (&theader, "NY", "%d", 1, camera.Ny); -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/ImageOps.c
r30616 r31261 128 128 } 129 129 130 /* select all image equivalent to the current photcode*/130 /* select all image equivalent to the active photcode set */ 131 131 void findImages (Catalog *catalog, int Ncatalog) { 132 132 133 133 off_t j; 134 int i, ecode ;135 136 for (i = 0; i < Ncatalog; i++) {134 int i, ecode, Ns, found; 135 136 for (i = 0; i < Ncatalog; i++) { 137 137 for (j = 0; j < catalog[i].Nmeasure; j++) { 138 138 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[j].photcode); 139 if (photcode[0].code != ecode) continue; 139 found = FALSE; 140 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { 141 if (ecode == photcodes[Ns][0].code) found = TRUE; 142 } 143 if (!found) continue; 140 144 matchImage (catalog, j, i); 141 145 } … … 145 149 int findCCD (off_t idx, off_t meas, int cat, Measure *measure) { 146 150 147 int ccdnum ;151 int ccdnum, found, Ns, ecode; 148 152 double X, Y; 149 153 char *pname, *filter, *p, base[256]; … … 151 155 /* identify the ccd on the basis of the photcode name */ 152 156 pname = GetPhotcodeNamebyCode (image[idx].photcode); 153 filter = photcode[0].name; 157 158 // XXX this seems quite terrible... 159 ecode = GetPhotcodeEquivCodebyCode (measure[0].photcode); 160 found = FALSE; 161 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { 162 if (ecode == photcodes[Ns][0].code) found = TRUE; 163 } 164 if (!found) return (FALSE); 165 166 filter = photcodes[Ns][0].name; 154 167 sprintf (base, "%s.%s.", MOSAICNAME, filter); 155 168 if (strncmp (pname, base, strlen (base))) return (FALSE); … … 307 320 308 321 if (FREEZE_IMAGES) return; 322 323 int Nsecfilt = GetPhotcodeNsecfilt (); 309 324 310 325 if (PoorImages) { … … 360 375 361 376 n = catalog[c].measure[m].averef; 362 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n* PhotNsec]);377 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*Nsecfilt]); 363 378 if (isnan(Msys)) { 364 379 Nsys++; -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/MosaicOps.c
r31260 r31261 262 262 int findMosaics (Catalog *catalog, int Ncatalog) { 263 263 264 int i, ecode ;264 int i, ecode, found, Ns; 265 265 off_t j; 266 266 … … 274 274 } 275 275 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[j].photcode); 276 if (photcode[0].code != ecode) continue; 276 found = FALSE; 277 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { 278 if (ecode == photcodes[Ns][0].code) found = TRUE; 279 } 280 if (!found) continue; 277 281 matchMosaics (catalog, j, i); 278 282 } … … 387 391 388 392 off_t i, j, m, c, N, Nmax; 389 int n, mark, bad, Nfew, Nbad, Ncal, Nrel, Ngrid, Nsys ;393 int n, mark, bad, Nfew, Nbad, Ncal, Nrel, Ngrid, Nsys, Nsecfilt; 390 394 float Msys, Mrel, Mcal, Mgrid; 391 395 double *list, *dlist, *Mlist, *dMlist; … … 397 401 398 402 image = getimages (&N); 403 404 Nsecfilt = GetPhotcodeNsecfilt (); 399 405 400 406 if (PoorImages) { … … 448 454 449 455 n = catalog[c].measure[m].averef; 450 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n* PhotNsec]);456 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*Nsecfilt]); 451 457 if (isnan(Msys)) { 452 458 Nsys++; -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/StarOps.c
r31258 r31261 29 29 float getMrel (Catalog *catalog, off_t meas, int cat) { 30 30 31 int Nsec, Nsecfilt, code; 31 32 int ave; 32 33 float value; 33 34 34 35 ave = catalog[cat].measure[meas].averef; 36 code = catalog[cat].measure[meas].photcode; 37 38 // XXX DEP : this should use a flag associated with secfilt 35 39 if (catalog[cat].average[ave].flags & STAR_BAD) return (NAN); 36 40 37 value = catalog[cat].secfilt[PhotNsec*ave+PhotSec].M; 41 Nsec = GetPhotcodeNsec(code); 42 Nsecfilt = GetPhotcodeNsecfilt (); 43 44 value = catalog[cat].secfilt[Nsecfilt*ave+Nsec].M; 38 45 return (value); 39 46 } … … 45 52 float Msys, Mcal, Mmos, Mgrid; 46 53 StatType stats; 47 54 int Nsec, Nsecfilt, ecode; 55 56 Nsecfilt = GetPhotcodeNsecfilt (); 48 57 Nfew = Nsys = Nbad = Ncal = Nmos = Ngrid = 0; 49 58 … … 51 60 for (j = 0; j < catalog[i].Naverage; j++) { 52 61 53 /* calculate the average value for a single star */54 if (catalog[i].average[j].flags & STAR_BAD) continue;55 m = catalog[i].average[j].measureOffset; 56 57 N = 0;58 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 59 if (catalog[i].measure[m].dbFlags & MEAS_BAD) {60 Nbad ++;61 continue;62 }63 // XXX allow REF stars (no Image Entry) to be included in the calculation this 64 // should be optionally set, and should allow for REF stars to be downweighted by65 // more than their reported errors. how such info is carried is unclear...66 if (getImageEntry (m, i) < 0) {67 Mcal = Mmos = Mgrid = 0;68 } else {69 Mcal = getMcal (m, i); 70 if ( isnan(Mcal)) {71 N cal++;62 int Ns; 63 for (Ns = 0; Ns < Nphotcodes; Ns++) { 64 65 int thisCode = photcodes[Ns][0].code; 66 Nsec = GetPhotcodeNsec(thisCode); 67 68 /* calculate the average value for a single star */ 69 // XXX this flag should be set by secfilt, not average 70 if (catalog[i].average[j].flags & STAR_BAD) continue; 71 m = catalog[i].average[j].measureOffset; 72 73 N = 0; 74 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 75 // skip measurements that do not match the current photcode 76 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[m].photcode); 77 if (ecode != thisCode) { continue; } 78 79 if (catalog[i].measure[m].dbFlags & MEAS_BAD) { 80 Nbad ++; 72 81 continue; 73 82 } 74 Mmos = getMmos (m, i); 75 if (isnan(Mmos)) { 76 Nmos ++; 83 // XXX allow REF stars (no Image Entry) to be included in the calculation this 84 // should be optionally set, and should allow for REF stars to be downweighted by 85 // more than their reported errors. how such info is carried is unclear... 86 if (getImageEntry (m, i) < 0) { 87 Mcal = Mmos = Mgrid = 0; 88 } else { 89 Mcal = getMcal (m, i); 90 if (isnan(Mcal)) { 91 Ncal ++; 92 continue; 93 } 94 Mmos = getMmos (m, i); 95 if (isnan(Mmos)) { 96 Nmos ++; 97 continue; 98 } 99 Mgrid = getMgrid (m, i); 100 if (isnan(Mgrid)) { 101 Ngrid++; 102 continue; 103 } 104 } 105 106 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 107 if (isnan(Msys)) { 108 Nsys++; 77 109 continue; 78 110 } 79 Mgrid = getMgrid (m, i); 80 if (isnan(Mgrid)) { 81 Ngrid++; 82 continue; 111 list[N] = Msys - Mcal - Mmos - Mgrid; 112 dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR); 113 114 // tie down reference photometry if the -refcode (code) option is selected 115 if (refPhotcode) { 116 if (GetPhotcodeEquivCodebyCode(catalog[i].measure[m].photcode) == refPhotcode[0].equiv) { 117 // increase the weight by a factor of 100: 118 dlist[N] = 0.01*catalog[i].measure[m].dM; 119 } 83 120 } 84 } 85 86 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]); 87 if (isnan(Msys)) { 88 Nsys++; 89 continue; 90 } 91 list[N] = Msys - Mcal - Mmos - Mgrid; 92 dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR); 93 94 if (refPhotcode) { 95 if (GetPhotcodeEquivCodebyCode(catalog[i].measure[m].photcode) == refPhotcode[0].equiv) { 96 // increase the weight by a factor of 100: 97 dlist[N] = 0.01*catalog[i].measure[m].dM; 98 } 99 } 100 N++; 101 } 102 103 // when performing the grid analysis, STAR_TOOFEW will be set to 1; 104 105 if (N <= STAR_TOOFEW) { /* too few measurements */ 106 catalog[i].average[j].flags |= ID_STAR_FEW; 107 Nfew ++; 108 } else { 109 catalog[i].average[j].flags &= ~ID_STAR_FEW; 110 } 111 112 liststats (list, dlist, N, &stats); 113 114 catalog[i].secfilt[PhotNsec*j+PhotSec].M = stats.mean; 115 catalog[i].secfilt[PhotNsec*j+PhotSec].dM = stats.sigma; 116 catalog[i].secfilt[PhotNsec*j+PhotSec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NAN_S_SHORT; 121 N++; 122 } 123 124 // when performing the grid analysis, STAR_TOOFEW will be set to 1; 125 // XXX DEP this makes no sense: need a separate flag for each secfilt 126 if (N <= STAR_TOOFEW) { /* too few measurements */ 127 catalog[i].average[j].flags |= ID_STAR_FEW; 128 Nfew ++; 129 } else { 130 catalog[i].average[j].flags &= ~ID_STAR_FEW; 131 } 132 133 liststats (list, dlist, N, &stats); 134 135 catalog[i].secfilt[Nsecfilt*j+Nsec].M = stats.mean; 136 catalog[i].secfilt[Nsecfilt*j+Nsec].dM = stats.sigma; 137 catalog[i].secfilt[Nsecfilt*j+Nsec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NAN_S_SHORT; 138 } 117 139 } 118 140 } … … 129 151 double *list, *dlist; 130 152 StatType stats; 153 int Nsec, Nsecfilt, ecode; 154 155 Nsecfilt = GetPhotcodeNsecfilt (); 131 156 132 157 /* Nmeasure is now different, need to reallocate */ … … 142 167 for (i = 0; i < Ncatalog; i++) { 143 168 for (j = 0; j < catalog[i].Naverage; j++) { 144 145 169 /* skip stars already calibrated */ 146 170 if (catalog[i].found[j]) continue; 147 171 148 N = 0; 149 m = catalog[i].average[j].measureOffset; 150 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 151 if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; 152 // XXX allow REF stars (no Image Entry) to be included in the calculation this 153 // should be optionally set, and should allow for REF stars to be downweighted by 154 // more than their reported errors. how such info is carried is unclear... 155 if (getImageEntry (m, i) < 0) { 156 Mcal = Mmos = Mgrid = 0; 157 } else { 158 Mcal = getMcal (m, i); 159 if (isnan(Mcal)) continue; 160 Mmos = getMmos (m, i); 161 if (isnan(Mmos)) continue; 162 Mgrid = getMgrid (m, i); 163 if (isnan(Mgrid)) continue; 164 } 165 166 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]); 167 list[N] = Msys - Mcal - Mmos - Mgrid; 168 dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR); 169 N++; 170 } 171 if (N < 1) continue; 172 173 liststats (list, dlist, N, &stats); 174 if (mark) catalog[i].found[j] = TRUE; 175 176 /* use sigma or error in dM for output? */ 177 catalog[i].secfilt[PhotNsec*j+PhotSec].M = stats.mean; 178 catalog[i].secfilt[PhotNsec*j+PhotSec].dM = MAX (stats.error, stats.sigma); 179 catalog[i].secfilt[PhotNsec*j+PhotSec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NAN_S_SHORT; 172 int Ns; 173 for (Ns = 0; Ns < Nphotcodes; Ns++) { 174 int thisCode = photcodes[Ns][0].code; 175 Nsec = GetPhotcodeNsec(thisCode); 176 177 N = 0; 178 m = catalog[i].average[j].measureOffset; 179 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 180 // skip measurements that do not match the current photcode 181 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[m].photcode); 182 if (ecode != thisCode) { continue; } 183 184 if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; 185 186 // XXX allow REF stars (no Image Entry) to be included in the calculation this 187 // should be optionally set, and should allow for REF stars to be downweighted by 188 // more than their reported errors. how such info is carried is unclear... 189 if (getImageEntry (m, i) < 0) { 190 Mcal = Mmos = Mgrid = 0; 191 } else { 192 Mcal = getMcal (m, i); 193 if (isnan(Mcal)) continue; 194 Mmos = getMmos (m, i); 195 if (isnan(Mmos)) continue; 196 Mgrid = getMgrid (m, i); 197 if (isnan(Mgrid)) continue; 198 } 199 200 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 201 list[N] = Msys - Mcal - Mmos - Mgrid; 202 dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR); 203 N++; 204 } 205 if (N < 1) continue; 206 207 liststats (list, dlist, N, &stats); 208 if (mark) catalog[i].found[j] = TRUE; 209 210 /* use sigma or error in dM for output? */ 211 catalog[i].secfilt[Nsecfilt*j+Nsec].M = stats.mean; 212 catalog[i].secfilt[Nsecfilt*j+Nsec].dM = MAX (stats.error, stats.sigma); 213 catalog[i].secfilt[Nsecfilt*j+Nsec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NAN_S_SHORT; 214 } 180 215 } 181 216 } … … 209 244 ALLOCATE (dlist, double, MAX (1, Nmax)); 210 245 211 Nsecfilt = catalog[0].Nsecfilt;246 Nsecfilt = GetPhotcodeNsecfilt (); 212 247 213 248 # define PSFQUALSTATS 1 … … 227 262 if (GetPhotcodeEquivCodebyCode (catalog[i].measure[m].photcode) != Nc) continue; 228 263 229 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j* PhotNsec]);264 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 230 265 if (isnan(Msys)) continue; 231 266 … … 346 381 void clean_stars (Catalog *catalog, int Ncatalog) { 347 382 348 int i, j, Ndel, Nave, Ntot, mark ;383 int i, j, Ndel, Nave, Ntot, mark, Ns; 349 384 float dM, Xm; 350 385 double Chisq, MaxScatter, MaxChisq; … … 361 396 ALLOCATE (slist, double, Ntot); 362 397 ALLOCATE (dlist, double, Ntot); 363 for (i = Ntot = 0; i < Ncatalog; i++) { 364 for (j = 0; j < catalog[i].Naverage; j++) { 365 if (catalog[i].average[j].flags & STAR_BAD) continue; 366 Xm = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm; 367 if (Xm == -1) continue; 368 Chisq = pow (10.0, 0.01*Xm); 369 xlist[Ntot] = Chisq; 370 slist[Ntot] = catalog[i].secfilt[PhotNsec*j+PhotSec].dM; 371 dlist[Ntot] = 1; 372 Ntot ++; 373 } 374 } 398 399 int Nsecfilt = GetPhotcodeNsecfilt (); 400 401 // eliminate bad stars using the stats for a single secfilt at a time 402 // XXX DEP replace average.flags with secfilt flags 403 for (Ns = 0; Ns < Nphotcodes; Ns ++) { 404 405 int thisCode = photcodes[Ns][0].code; 406 int Nsec = GetPhotcodeNsec(thisCode); 407 408 for (i = Ntot = 0; i < Ncatalog; i++) { 409 for (j = 0; j < catalog[i].Naverage; j++) { 410 if (catalog[i].average[j].flags & STAR_BAD) continue; 411 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm; 412 if (Xm == -1) continue; 413 Chisq = pow (10.0, 0.01*Xm); 414 xlist[Ntot] = Chisq; 415 slist[Ntot] = catalog[i].secfilt[Nsecfilt*j+Nsec].dM; 416 dlist[Ntot] = 1; 417 Ntot ++; 418 } 419 } 375 420 376 initstats ("MEAN"); 377 liststats (xlist, dlist, Ntot, &stats); 378 MaxChisq = MAX (STAR_CHISQ, 2*stats.median); 379 liststats (slist, dlist, Ntot, &stats); 380 MaxScatter = MAX (STAR_SCATTER, 2*stats.median); 381 fprintf (stderr, "Max Scatter: %f, Max Chisq: %f\n", MaxScatter, MaxChisq); 382 383 Ndel = Nave = 0; 384 for (i = 0; i < Ncatalog; i++) { 385 for (j = 0; j < catalog[i].Naverage; j++) { 386 dM = catalog[i].secfilt[PhotNsec*j+PhotSec].dM; 387 Xm = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm; 388 Chisq = pow (10.0, 0.01*Xm); 389 mark = (dM > MaxScatter) || (Xm == NAN_S_SHORT) || (Chisq > MaxChisq); 390 if (mark) { 391 catalog[i].average[j].flags |= ID_STAR_POOR; 392 Ndel ++; 393 } else { 394 catalog[i].average[j].flags &= ~ID_STAR_POOR; 395 } 396 Nave ++; 397 } 398 } 399 fprintf (stderr, "%d stars marked variable, %d total\n", Ndel, Nave); 400 initstats (STATMODE); 421 initstats ("MEAN"); 422 liststats (xlist, dlist, Ntot, &stats); 423 MaxChisq = MAX (STAR_CHISQ, 2*stats.median); 424 liststats (slist, dlist, Ntot, &stats); 425 MaxScatter = MAX (STAR_SCATTER, 2*stats.median); 426 fprintf (stderr, "Max Scatter: %f, Max Chisq: %f\n", MaxScatter, MaxChisq); 427 428 Ndel = Nave = 0; 429 for (i = 0; i < Ncatalog; i++) { 430 for (j = 0; j < catalog[i].Naverage; j++) { 431 dM = catalog[i].secfilt[Nsecfilt*j+Nsec].dM; 432 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm; 433 Chisq = pow (10.0, 0.01*Xm); 434 mark = (dM > MaxScatter) || (Xm == NAN_S_SHORT) || (Chisq > MaxChisq); 435 if (mark) { 436 catalog[i].average[j].flags |= ID_STAR_POOR; 437 Ndel ++; 438 } else { 439 catalog[i].average[j].flags &= ~ID_STAR_POOR; 440 } 441 Nave ++; 442 } 443 } 444 fprintf (stderr, "%d stars marked variable, %d total\n", Ndel, Nave); 445 initstats (STATMODE); 446 } 401 447 free (xlist); 402 448 free (slist); … … 416 462 int Ncal, Nmos, Ngrid, Nfew; 417 463 464 int Nsecfilt = GetPhotcodeNsecfilt (); 465 418 466 if (VERBOSE) fprintf (stderr, "marking poor measures\n"); 419 467 /* Nmeasure is now different, need to reallocate */ … … 437 485 for (j = 0; j < catalog[i].Naverage; j++) { 438 486 439 /* skip bad stars to prevent them from becoming good (on inner sample) */ 440 if (catalog[i].average[j].flags & STAR_BAD) continue; 441 442 /* on final processing, skip stars already measured */ 443 if (final && catalog[i].found[j]) continue; 444 445 /* accumulate list of valid measurements */ 446 m = catalog[i].average[j].measureOffset; 447 N = 0; 448 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 449 /* if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; */ 450 Mcal = getMcal (m, i); 451 if (isnan(Mcal)) { Ncal ++; continue; } 452 Mmos = getMmos (m, i); 453 if (isnan(Mmos)) { Nmos ++; continue; } 454 Mgrid = getMgrid (m, i); 455 if (isnan(Mgrid)) { Ngrid ++; continue; } 456 457 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]); 458 list[N] = Msys - Mcal - Mmos - Mgrid; 459 dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR); 460 N++; 461 } 462 if (N <= TOOFEW) { Nfew ++; continue; } 463 464 /* 3-sigma clip based on stats of inner 50% */ 465 466 // calculated mean of inner 50% 467 initstats ("INNER_MEAN"); 468 liststats (list, dlist, N, &stats); 469 stats.sigma = MAX (MIN_ERROR, stats.sigma); /* if measurements agree too well, sigma -> 0.0 */ 470 471 // ignore entries > 3sigma from inner mean 472 for (k = m = 0; k < N; k++) { 473 if (fabs (list[k] - stats.median) < NSIGMA_CLIP*stats.sigma) { 474 list[m] = list[k]; 475 m++; 476 } 477 } 478 // recalculate the mean & sigma of the accepted measurements 479 initstats ("MEAN"); 480 liststats (list, dlist, m, &stats); 481 stats.sigma = MAX (MIN_ERROR, stats.sigma); 482 483 /* apply to list of all relevant measurements, including IMAGE_POOR & IMAGE_FEW */ 484 image_bad = IMAGE_BAD; 485 IMAGE_BAD = ID_IMAGE_PHOTOM_NOCAL; 486 m = catalog[i].average[j].measureOffset; 487 N = 0; 488 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 489 /* if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; */ 490 Mcal = getMcal (m, i); 491 if (isnan(Mcal)) continue; 492 Mmos = getMmos (m, i); 493 if (isnan(Mmos)) continue; 494 Mgrid = getMgrid (m, i); 495 if (isnan(Mgrid)) continue; 496 497 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]); 498 list[N] = Msys - Mcal - Mmos - Mgrid; 499 dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR); 500 ilist[N] = m; 501 N++; 502 Nave ++; 503 } 504 if (N < TOOFEW) continue; 505 506 /* mark bad measures (> 3 sigma deviant) */ 507 for (k = 0; k < N; k++) { 508 if (fabs (list[k] - stats.median) > NSIGMA_REJECT*stats.sigma) { 509 catalog[i].measure[ilist[k]].dbFlags |= ID_MEAS_POOR_PHOTOM; 510 Ndel ++; 511 } 512 } 513 IMAGE_BAD = image_bad; 487 int Ns; 488 for (Ns = 0; Ns < Nphotcodes; Ns++) { 489 490 /* on final processing, skip stars already measured */ 491 if (final && catalog[i].found[j]) continue; 492 493 int thisCode = photcodes[Ns][0].code; 494 495 /* skip bad stars to prevent them from becoming good (on inner sample) */ 496 if (catalog[i].average[j].flags & STAR_BAD) continue; 497 498 /* accumulate list of valid measurements */ 499 m = catalog[i].average[j].measureOffset; 500 N = 0; 501 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 502 // skip measurements that do not match the current photcode 503 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[m].photcode); 504 if (ecode != thisCode) { continue; } 505 506 /* if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; */ 507 Mcal = getMcal (m, i); 508 if (isnan(Mcal)) { Ncal ++; continue; } 509 Mmos = getMmos (m, i); 510 if (isnan(Mmos)) { Nmos ++; continue; } 511 Mgrid = getMgrid (m, i); 512 if (isnan(Mgrid)) { Ngrid ++; continue; } 513 514 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 515 list[N] = Msys - Mcal - Mmos - Mgrid; 516 dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR); 517 N++; 518 } 519 if (N <= TOOFEW) { Nfew ++; continue; } 520 521 /* 3-sigma clip based on stats of inner 50% */ 522 523 // calculated mean of inner 50% 524 initstats ("INNER_MEAN"); 525 liststats (list, dlist, N, &stats); 526 stats.sigma = MAX (MIN_ERROR, stats.sigma); /* if measurements agree too well, sigma -> 0.0 */ 527 528 // ignore entries > 3sigma from inner mean 529 for (k = m = 0; k < N; k++) { 530 if (fabs (list[k] - stats.median) < NSIGMA_CLIP*stats.sigma) { 531 list[m] = list[k]; 532 m++; 533 } 534 } 535 // recalculate the mean & sigma of the accepted measurements 536 initstats ("MEAN"); 537 liststats (list, dlist, m, &stats); 538 stats.sigma = MAX (MIN_ERROR, stats.sigma); 539 540 /* apply to list of all relevant measurements, including IMAGE_POOR & IMAGE_FEW */ 541 image_bad = IMAGE_BAD; 542 IMAGE_BAD = ID_IMAGE_PHOTOM_NOCAL; 543 m = catalog[i].average[j].measureOffset; 544 N = 0; 545 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 546 // skip measurements that do not match the current photcode 547 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[m].photcode); 548 if (ecode != thisCode) { continue; } 549 550 /* if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; */ 551 Mcal = getMcal (m, i); 552 if (isnan(Mcal)) continue; 553 Mmos = getMmos (m, i); 554 if (isnan(Mmos)) continue; 555 Mgrid = getMgrid (m, i); 556 if (isnan(Mgrid)) continue; 557 558 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 559 list[N] = Msys - Mcal - Mmos - Mgrid; 560 dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR); 561 ilist[N] = m; 562 N++; 563 Nave ++; 564 } 565 if (N < TOOFEW) continue; 566 567 /* mark bad measures (> 3 sigma deviant) */ 568 for (k = 0; k < N; k++) { 569 if (fabs (list[k] - stats.median) > NSIGMA_REJECT*stats.sigma) { 570 catalog[i].measure[ilist[k]].dbFlags |= ID_MEAS_POOR_PHOTOM; 571 Ndel ++; 572 } 573 } 574 IMAGE_BAD = image_bad; 575 } 514 576 } 515 577 } … … 567 629 } 568 630 631 // XXXX do this for all secfilt at once or one at a time? 569 632 StatType statsStarX (Catalog *catalog, int Ncatalog) { 570 633 … … 574 637 StatType stats; 575 638 639 int Nsecfilt = GetPhotcodeNsecfilt (); 640 576 641 Ntot = 0; 577 642 for (i = 0; i < Ncatalog; i++) { … … 586 651 for (j = 0; j < catalog[i].Naverage; j++) { 587 652 588 /* calculate the average value for a single star */ 589 if (catalog[i].average[j].flags & STAR_BAD) continue; 590 591 Xm = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm; 592 if (Xm == NAN_S_SHORT) continue; 593 list[n] = pow (10.0, 0.01*Xm); 594 dlist[n] = 1; 595 n++; 653 int Ns; 654 for (Ns = 0; Ns < Nphotcodes; Ns++) { 655 656 int thisCode = photcodes[Ns][0].code; 657 int Nsec = GetPhotcodeNsec(thisCode); 658 659 /* calculate the average value for a single star */ 660 if (catalog[i].average[j].flags & STAR_BAD) continue; 661 662 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm; 663 if (Xm == NAN_S_SHORT) continue; 664 list[n] = pow (10.0, 0.01*Xm); 665 dlist[n] = 1; 666 n++; 667 } 596 668 } 597 669 } … … 611 683 StatType stats; 612 684 685 int Nsecfilt = GetPhotcodeNsecfilt (); 686 613 687 Ntot = 0; 614 688 for (i = 0; i < Ncatalog; i++) { … … 623 697 for (j = 0; j < catalog[i].Naverage; j++) { 624 698 625 /* calculate the average value for a single star */ 626 if (catalog[i].average[j].flags & STAR_BAD) continue; 627 628 dM = catalog[i].secfilt[PhotNsec*j+PhotSec].dM; 629 list[n] = dM; 630 dlist[n] = 1; 631 n++; 699 int Ns; 700 for (Ns = 0; Ns < Nphotcodes; Ns++) { 701 702 int thisCode = photcodes[Ns][0].code; 703 int Nsec = GetPhotcodeNsec(thisCode); 704 705 /* calculate the average value for a single star */ 706 if (catalog[i].average[j].flags & STAR_BAD) continue; 707 708 dM = catalog[i].secfilt[Nsecfilt*j+Nsec].dM; 709 list[n] = dM; 710 dlist[n] = 1; 711 n++; 712 } 632 713 } 633 714 } … … 651 732 ALLOCATE (Mlist, double, NBIN); 652 733 653 for (i = 0; i < NBIN; i++) xlist[i] = 0.00025*i; 654 bzero (Mlist, NBIN*sizeof(double)); 655 for (i = 0; i < Ncatalog; i++) { 656 for (j = 0; j < catalog[i].Naverage; j++) { 657 if (catalog[i].average[j].flags & STAR_BAD) continue; 658 dMrel = catalog[i].secfilt[PhotNsec*j+PhotSec].dM; 659 bin = dMrel / 0.00025; 660 bin = MAX (0, MIN (NBIN-1, bin)); 661 Mlist[bin] += 1.0; 662 } 663 } 664 665 plot_defaults (&graphdata); 666 graphdata.style = 1; 667 plot_list (&graphdata, xlist, Mlist, NBIN, "dMrel hist", "%s.dMhist.png", OUTROOT); 668 734 int Nsecfilt = GetPhotcodeNsecfilt (); 735 736 int Ns; 737 for (Ns = 0; Ns < Nphotcodes; Ns++) { 738 739 int thisCode = photcodes[Ns][0].code; 740 int Nsec = GetPhotcodeNsec(thisCode); 741 742 for (i = 0; i < NBIN; i++) xlist[i] = 0.00025*i; 743 bzero (Mlist, NBIN*sizeof(double)); 744 for (i = 0; i < Ncatalog; i++) { 745 for (j = 0; j < catalog[i].Naverage; j++) { 746 if (catalog[i].average[j].flags & STAR_BAD) continue; 747 dMrel = catalog[i].secfilt[Nsecfilt*j+Nsec].dM; 748 bin = dMrel / 0.00025; 749 bin = MAX (0, MIN (NBIN-1, bin)); 750 Mlist[bin] += 1.0; 751 } 752 } 753 754 plot_defaults (&graphdata); 755 graphdata.style = 1; 756 plot_list (&graphdata, xlist, Mlist, NBIN, "dMrel hist", "%s.dMhist.png", OUTROOT); 757 } 669 758 free (xlist); 670 759 free (Mlist); … … 678 767 Graphdata graphdata; 679 768 769 int Nsecfilt = GetPhotcodeNsecfilt (); 770 680 771 Ntotal = 0; 681 772 for (i = 0; i < Ncatalog; i++) Ntotal += catalog[i].Naverage; … … 684 775 ALLOCATE (ylist, double, Ntotal); 685 776 686 N = 0; 687 for (i = 0; i < Ncatalog; i++) { 688 for (j = 0; j < catalog[i].Naverage; j++) { 689 if (catalog[i].average[j].flags & STAR_BAD) continue; 690 xlist[N] = catalog[i].secfilt[PhotNsec*j+PhotSec].M; 691 value = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm; 692 if (value == NAN_S_SHORT) continue; 693 ylist[N] = 0.01*value; 694 N++; 695 } 696 } 697 698 plot_defaults (&graphdata); 699 graphdata.ymin = -3.0; 700 plot_list (&graphdata, xlist, ylist, N, "chisq", "%s.chisq.png", OUTROOT); 777 int Ns; 778 for (Ns = 0; Ns < Nphotcodes; Ns++) { 779 780 int thisCode = photcodes[Ns][0].code; 781 int Nsec = GetPhotcodeNsec(thisCode); 782 783 N = 0; 784 for (i = 0; i < Ncatalog; i++) { 785 for (j = 0; j < catalog[i].Naverage; j++) { 786 if (catalog[i].average[j].flags & STAR_BAD) continue; 787 xlist[N] = catalog[i].secfilt[Nsecfilt*j+Nsec].M; 788 value = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm; 789 if (value == NAN_S_SHORT) continue; 790 ylist[N] = 0.01*value; 791 N++; 792 } 793 } 794 795 plot_defaults (&graphdata); 796 graphdata.ymin = -3.0; 797 plot_list (&graphdata, xlist, ylist, N, "chisq", "%s.chisq.png", OUTROOT); 798 } 799 701 800 free (xlist); 702 801 free (ylist); -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/bcatalog.c
r31258 r31261 6 6 7 7 off_t i, j, offset; 8 int ecode ;8 int ecode, found, Ns; 9 9 off_t NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm; 10 10 float mag; 11 11 int Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Nfew, Ngalaxy, Npsfqf; 12 12 13 // XXX PhotNsec as a global is a bad idea; either get it from catalog 14 // or get it from: 15 // Nsecfilt = GetPhotcodeNsecfilt (); 16 // assert (catalog[0].Nsecfilt == Nsecfilt); 13 int Nsecfilt = GetPhotcodeNsecfilt (); 14 assert (Nsecfilt == catalog[0].Nsecfilt); 17 15 18 16 /* we are moving only the subset of measurements from catalog[0] to subcatalog[0] */ … … 21 19 NMEASURE = 1000; 22 20 ALLOCATE (subcatalog[0].average, Average, NAVERAGE); 23 ALLOCATE (subcatalog[0].secfilt, SecFilt, NAVERAGE* PhotNsec);21 ALLOCATE (subcatalog[0].secfilt, SecFilt, NAVERAGE*Nsecfilt); 24 22 ALLOCATE (subcatalog[0].measure, Measure, NMEASURE); 25 23 Nmeasure = Naverage = 0; … … 34 32 subcatalog[0].average[Naverage] = catalog[0].average[i]; 35 33 subcatalog[0].average[Naverage].measureOffset = Nmeasure; 36 for (j = 0; j < PhotNsec; j++) {37 subcatalog[0].secfilt[ PhotNsec*Naverage+j] = catalog[0].secfilt[PhotNsec*i+j];34 for (j = 0; j < Nsecfilt; j++) { 35 subcatalog[0].secfilt[Nsecfilt*Naverage+j] = catalog[0].secfilt[Nsecfilt*i+j]; 38 36 } 39 37 40 38 if (RESET) { 41 subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].M = NAN; 42 subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].dM = NAN; 43 subcatalog[0].average[Naverage].flags &= ~ID_STAR_FEW; 44 subcatalog[0].average[Naverage].flags &= ~ID_STAR_POOR; 39 int Ns; 40 for (Ns = 0; Ns < Nphotcodes; Ns++) { 41 42 int thisCode = photcodes[Ns][0].code; 43 int Nsec = GetPhotcodeNsec(thisCode); 44 45 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].M = NAN; 46 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].dM = NAN; 47 subcatalog[0].average[Naverage].flags &= ~ID_STAR_FEW; 48 subcatalog[0].average[Naverage].flags &= ~ID_STAR_POOR; 49 } 45 50 } 46 51 … … 54 59 /* select measurements by photcode */ 55 60 ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[offset].photcode); 56 if (ecode != photcode[0].code) { Ncode ++; continue; } 61 found = FALSE; 62 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { 63 if (ecode == photcodes[Ns][0].code) found = TRUE; 64 } 65 if (!found) { 66 Ncode ++; 67 continue; 68 } 57 69 58 70 /* select measurements by time */ … … 129 141 NAVERAGE += 50; 130 142 REALLOCATE (subcatalog[0].average, Average, NAVERAGE); 131 REALLOCATE (subcatalog[0].secfilt, SecFilt, NAVERAGE* PhotNsec);143 REALLOCATE (subcatalog[0].secfilt, SecFilt, NAVERAGE*Nsecfilt); 132 144 } 133 145 } 134 146 REALLOCATE (subcatalog[0].average, Average, MAX (Naverage, 1)); 135 147 REALLOCATE (subcatalog[0].measure, Measure, MAX (Nmeasure, 1)); 136 REALLOCATE (subcatalog[0].secfilt, SecFilt, PhotNsec*MAX (Naverage, 1));148 REALLOCATE (subcatalog[0].secfilt, SecFilt, Nsecfilt*MAX (Naverage, 1)); 137 149 subcatalog[0].Naverage = Naverage; 138 150 subcatalog[0].Nmeasure = Nmeasure; 139 151 subcatalog[0].Nsecfilt = catalog[0].Nsecfilt; 140 152 subcatalog[0].Nsecf_mem = Naverage * catalog[0].Nsecfilt; 141 assert (PhotNsec == catalog[0].Nsecfilt);142 153 143 154 // limit the total number of stars in the catalog … … 161 172 double Rmin, Rmax, Dmin, Dmax; 162 173 174 int Nsecfilt = GetPhotcodeNsecfilt (); 175 163 176 gfits_scan (&catalog[0].header, "RA0", "%lf", 1, &Rmin); 164 177 gfits_scan (&catalog[0].header, "DEC0", "%lf", 1, &Dmin); … … 205 218 // allocate the output data 206 219 ALLOCATE (tmpcatalog.average, Average, Nmax); 207 ALLOCATE (tmpcatalog.secfilt, SecFilt, Nmax * PhotNsec);220 ALLOCATE (tmpcatalog.secfilt, SecFilt, Nmax * Nsecfilt); 208 221 ALLOCATE (tmpcatalog.measure, Measure, NMEASURE); 209 222 -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/initialize.c
r31258 r31261 13 13 N = UserPatchSelect ? 1 : 2; 14 14 15 # if (0) 16 // XXX DEP 15 17 if ((photcode = GetPhotcodebyName (argv[N])) == NULL) { 16 18 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]); … … 21 23 exit (1); 22 24 } 25 // PhotSec is used to select the single average photcode being processed 23 26 PhotSec = GetPhotcodeNsec (photcode[0].code); 27 # endif 28 29 Nphotcodes = 0; 30 photcodes = NULL; 31 int NPHOTCODES = 10; 32 ALLOCATE (photcodes, PhotCode *, NPHOTCODES); 33 34 /* parse the comma-separated list of photcodesKeep */ 35 char *myList = strcreate(argv[N]); 36 char *list = myList; 37 char *codename = NULL; 38 char *ptr = NULL; 39 while ((codename = strtok_r (list, ",", &ptr)) != NULL) { 40 list = NULL; // pass NULL on successive strtok_r calls 41 fprintf (stderr, "PHOTCODE LIST: %s\n", myList); 42 fprintf (stderr, "codename: %s\n", codename); 43 if ((photcodes[Nphotcodes] = GetPhotcodebyName (codename)) == NULL) { 44 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename); 45 exit (1); 46 } 47 if (photcodes[Nphotcodes][0].type != PHOT_SEC) { 48 fprintf (stderr, "photcode %s is not an filter type (SEC)\n", codename); 49 exit (1); 50 } 51 Nphotcodes ++; 52 CHECK_REALLOCATE (photcodes, PhotCode *, NPHOTCODES, Nphotcodes, 10); 53 } 24 54 } 25 26 PhotNsec = GetPhotcodeNsecfilt (); 55 // XXX DEP PhotNsec = GetPhotcodeNsecfilt (); 56 if (USE_GRID && (Nphotcodes > 1)) { 57 fprintf (stderr, "grid correction analysis currently can only operate on a single photcode\n"); 58 exit (1); 59 } 27 60 28 61 initstats (STATMODE); -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/plot_scatter.c
r27435 r31261 18 18 ALLOCATE (ilist, double, Ntot); 19 19 20 N = 0; 21 for (i = 0; i < Ncatalog; i++) { 22 for (j = 0; j < catalog[i].Naverage; j++) { 20 int Nsecfilt = GetPhotcodeNsecfilt (); 23 21 24 /* calculate the average value for a single star */ 25 if (catalog[i].average[j].flags & STAR_BAD) continue; 26 m = catalog[i].average[j].measureOffset; 22 int Ns; 23 for (Ns = 0; Ns < Nphotcodes; Ns++) { 27 24 28 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 29 if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; 30 Mcal = getMcal (m, i); 31 if (isnan(Mcal)) continue; 32 Mmos = getMmos (m, i); 33 if (isnan(Mmos)) continue; 34 Mgrid = getMgrid (m, i); 35 if (isnan(Mgrid)) continue; 25 int thisCode = photcodes[Ns][0].code; 26 int Nsec = GetPhotcodeNsec(thisCode); 36 27 37 Mrel = catalog[i].secfilt[PhotNsec*j+PhotSec].M; 38 xlist[N] = Mrel; 39 ylist[N] = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]) - Mcal - Mmos - Mgrid - Mrel; 40 ilist[N] = PhotInst (&catalog[i].measure[m]); 41 N++; 42 } 28 N = 0; 29 for (i = 0; i < Ncatalog; i++) { 30 for (j = 0; j < catalog[i].Naverage; j++) { 31 32 /* calculate the average value for a single star */ 33 if (catalog[i].average[j].flags & STAR_BAD) continue; 34 m = catalog[i].average[j].measureOffset; 35 36 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 37 // skip measurements that do not match the current photcode 38 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[m].photcode); 39 if (ecode != thisCode) { continue; } 40 41 if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; 42 Mcal = getMcal (m, i); 43 if (isnan(Mcal)) continue; 44 Mmos = getMmos (m, i); 45 if (isnan(Mmos)) continue; 46 Mgrid = getMgrid (m, i); 47 if (isnan(Mgrid)) continue; 48 49 Mrel = catalog[i].secfilt[Nsecfilt*j+Nsec].M; 50 xlist[N] = Mrel; 51 ylist[N] = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]) - Mcal - Mmos - Mgrid - Mrel; 52 ilist[N] = PhotInst (&catalog[i].measure[m]); 53 N++; 54 } 55 } 43 56 } 57 58 plot_defaults (&graphdata); 59 graphdata.xmin = PlotMmin; 60 graphdata.xmax = PlotMmax; 61 graphdata.ymin = PlotdMmin; 62 graphdata.ymax = PlotdMmax; 63 plot_list (&graphdata, xlist, ylist, N, "mag vs dmag", "%s.Mag.png", OUTROOT); 64 65 plot_defaults (&graphdata); 66 graphdata.ymin = PlotdMmin; 67 graphdata.ymax = PlotdMmax; 68 plot_list (&graphdata, ilist, ylist, N, "imag vs dmag", "%s.iMag.png", OUTROOT); 44 69 } 45 46 plot_defaults (&graphdata);47 graphdata.xmin = PlotMmin;48 graphdata.xmax = PlotMmax;49 graphdata.ymin = PlotdMmin;50 graphdata.ymax = PlotdMmax;51 plot_list (&graphdata, xlist, ylist, N, "mag vs dmag", "%s.Mag.png", OUTROOT);52 53 plot_defaults (&graphdata);54 graphdata.ymin = PlotdMmin;55 graphdata.ymax = PlotdMmax;56 plot_list (&graphdata, ilist, ylist, N, "imag vs dmag", "%s.iMag.png", OUTROOT);57 70 free (xlist); 58 71 free (ylist); -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/select_images.c
r31258 r31261 119 119 /* exclude images by photcode */ 120 120 ecode = GetPhotcodeEquivCodebyCode (timage[i].photcode); 121 if (ecode != photcode[0].code) continue; 121 found = FALSE; 122 int Ns; 123 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { 124 if (ecode == photcodes[Ns][0].code) found = TRUE; 125 } 126 if (!found) continue; 122 127 123 128 /* exclude images by time */ -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/setExclusions.c
r28241 r31261 4 4 5 5 off_t i, j, k, m, Narea, Nnocal, Ngood; 6 int ecode ;6 int ecode, found, Ns; 7 7 Coords *coords; 8 8 double r, d, x, y; … … 16 16 /* select measurements by photcode */ 17 17 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[m].photcode); 18 if (ecode != photcode[0].code) goto mark_nocal; 18 found = FALSE; 19 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { 20 if (ecode == photcodes[Ns][0].code) found = TRUE; 21 } 22 if (!found) goto mark_nocal; 19 23 20 24 /* select measurements by time */ -
branches/eam_branches/ipp-20110404/Ohana/src/relphot/src/setMrelFinal.c
r29001 r31261 9 9 if (RESET) { 10 10 11 for (i = 0; i < catalog[0].Naverage; i++) { 12 catalog[0].secfilt[PhotNsec*i+PhotSec].M = NAN; 13 catalog[0].secfilt[PhotNsec*i+PhotSec].dM = NAN; 14 catalog[0].secfilt[PhotNsec*i+PhotSec].Xm = NAN_S_SHORT; 11 int Nsecfilt = GetPhotcodeNsecfilt (); 15 12 16 m = catalog[0].average[i].measureOffset;17 for (j = 0; j < catalog[0].average[i].Nmeasure; j++, m++) {13 int Ns; 14 for (Ns = 0; Ns < Nphotcodes; Ns++) { 18 15 19 /* select measurements by photcode */ 20 ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[m].photcode); 21 if (ecode != photcode[0].code) continue; 16 int thisCode = photcodes[Ns][0].code; 17 int Nsec = GetPhotcodeNsec(thisCode); 18 19 for (i = 0; i < catalog[0].Naverage; i++) { 20 catalog[0].secfilt[Nsecfilt*i+Nsec].M = NAN; 21 catalog[0].secfilt[Nsecfilt*i+Nsec].dM = NAN; 22 catalog[0].secfilt[Nsecfilt*i+Nsec].Xm = NAN_S_SHORT; 23 24 m = catalog[0].average[i].measureOffset; 25 for (j = 0; j < catalog[0].average[i].Nmeasure; j++, m++) { 22 26 23 /* select measurements by time */ 24 if (TimeSelect) { 25 if (catalog[0].measure[m].t < TSTART) continue; 26 if (catalog[0].measure[m].t > TSTOP) continue; 27 // skip measurements that do not match the current photcode 28 ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[m].photcode); 29 if (ecode != thisCode) { continue; } 30 31 /* select measurements by time */ 32 if (TimeSelect) { 33 if (catalog[0].measure[m].t < TSTART) continue; 34 if (catalog[0].measure[m].t > TSTOP) continue; 35 } 36 37 catalog[0].measure[m].Mcal = 0; 38 catalog[0].measure[m].dbFlags &= 0xff00; 39 catalog[0].measure[m].dbFlags &= ~ID_MEAS_POOR_PHOTOM; 40 catalog[0].measure[m].dbFlags &= ~ID_MEAS_SKIP_PHOTOM; 41 catalog[0].measure[m].dbFlags &= ~ID_MEAS_AREA; 42 catalog[0].measure[m].dbFlags &= ~ID_MEAS_NOCAL; 27 43 } 28 29 catalog[0].measure[m].Mcal = 0;30 catalog[0].measure[m].dbFlags &= 0xff00;31 catalog[0].measure[m].dbFlags &= ~ID_MEAS_POOR_PHOTOM;32 catalog[0].measure[m].dbFlags &= ~ID_MEAS_SKIP_PHOTOM;33 catalog[0].measure[m].dbFlags &= ~ID_MEAS_AREA;34 catalog[0].measure[m].dbFlags &= ~ID_MEAS_NOCAL;35 44 } 36 45 } … … 68 77 69 78 off_t i, k, m; 70 int ecode ;79 int ecode, found, Ns; 71 80 off_t Ntot, Ntry, Nkeep, Nskip; 72 81 float mag; … … 95 104 /* skipped via NOCAL, don't mark as skipped */ 96 105 ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[m].photcode); 97 if (ecode != photcode[0].code) continue; 106 found = FALSE; 107 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { 108 if (ecode == photcodes[Ns][0].code) found = TRUE; 109 } 110 if (!found) continue; 98 111 99 112 /* skip measurements by time range */
Note:
See TracChangeset
for help on using the changeset viewer.
