Changeset 36474
- Timestamp:
- Feb 5, 2014, 6:09:47 AM (12 years ago)
- Location:
- branches/eam_branches/ipp-20131211/Ohana/src
- Files:
-
- 10 edited
-
addstar/src/findskycell.c (modified) (9 diffs)
-
libdvo/include/dvo.h (modified) (1 diff)
-
libdvo/src/TessellationTable.c (modified) (14 diffs)
-
relphot/include/relphot.h (modified) (2 diffs)
-
relphot/src/BoundaryTreeOps.c (modified) (4 diffs)
-
relphot/src/ImageOps.c (modified) (8 diffs)
-
relphot/src/ImageSubset.c (modified) (9 diffs)
-
relphot/src/StarOps.c (modified) (2 diffs)
-
relphot/src/args.c (modified) (2 diffs)
-
relphot/src/setMrelCatalog.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20131211/Ohana/src/addstar/src/findskycell.c
r36473 r36474 41 41 int skycellIDoff = -1; 42 42 43 int APPEND = FALSE; 44 43 45 int main (int argc, char **argv) { 44 46 … … 55 57 if (get_argument (argc, argv, "-h")) usage (); 56 58 57 NX_SUB = NY_SUB = 1;58 59 if ((N = get_argument (argc, argv, "-nx"))) { 59 60 remove_argument (N, &argc, argv); … … 68 69 69 70 /* pixel scale (arcsec/pixel) */ 70 SCALE = 1.0;71 71 if ((N = get_argument (argc, argv, "-scale"))) { 72 72 remove_argument (N, &argc, argv); 73 73 SCALE = atof (argv[N]); 74 74 remove_argument (N, &argc, argv); 75 } 76 77 /* pixel scale (arcsec/pixel) */ 78 if ((N = get_argument (argc, argv, "-append"))) { 79 remove_argument (N, &argc, argv); 80 APPEND = TRUE; 75 81 } 76 82 … … 410 416 MARKTIME("-- test %d pts: %f sec\n", Npts, dtime); 411 417 412 BoundaryTreeSave (treefile, &tree); 418 if (APPEND) { 419 int Ntess = 0; 420 TessellationTable *tess = TessellationTableLoad (treefile, &Ntess); 421 REALLOCATE (tess, TessellationTable, Ntess + 1); 422 TessellationTableInit (&tess[Ntess], 1); 423 tess[Ntess].tree = &tree; 424 tess[Ntess].type = TESS_RINGS; 425 tess[Ntess].Rmin = 0; 426 tess[Ntess].Rmax = 360; 427 tess[Ntess].Dmin = -90; 428 tess[Ntess].Dmax = +90; 429 430 if (BASENAME) { 431 tess[Ntess].Nbasename = strlen(BASENAME); 432 tess[Ntess].basename = strcreate(BASENAME); 433 tess[Ntess].projectIDoff = projectIDoff; 434 tess[Ntess].skycellIDoff = skycellIDoff; 435 } 436 437 // add basename an related here... 438 Ntess ++; 439 TessellationTableSave (treefile, tess, Ntess); 440 } else { 441 BoundaryTreeSave (treefile, &tree); 442 } 413 443 414 444 return TRUE; … … 416 446 417 447 int apply_tree (char *treefile, char *datafile) { 448 449 int Ntess = 0; 450 TessellationTable *tess = TessellationTableLoad (treefile, &Ntess); 451 if (!tess) { 452 fprintf (stderr, "error loading tessellation table file %s\n", treefile); 453 exit (2); 454 } 455 456 FILE *f = fopen (datafile, "r"); 457 if (!f) { 458 fprintf (stderr, "error opening data file %s\n", datafile); 459 exit (3); 460 } 461 462 double ra, dec; 463 int Nvalue = 0; 464 while ((Nvalue = fscanf (f, "%lf %lf", &ra, &dec)) != EOF) { 465 466 int tessID, projID, skycellID; 467 468 if (!TessellationPrimaryCellIDs (tess, Ntess, &tessID, &projID, &skycellID, ra, dec)) { 469 fprintf (stderr, "error finding cell for %f,%f\n", ra, dec); 470 continue; 471 } 472 473 fprintf (stdout, "%10.6f %10.6f : %2d %04d %03d : %s\n", ra, dec, tessID, projID, skycellID, tess[tessID].basename); 474 } 475 476 exit (0); 477 } 478 479 int apply_tree_old (char *treefile, char *datafile) { 418 480 419 481 BoundaryTree *tree = BoundaryTreeLoad (treefile); … … 479 541 int mklocal (char *treefile, char *catdir) { 480 542 481 int i, status;543 int i, j, status; 482 544 FITS_DB db; 483 545 Image *image; … … 515 577 516 578 // generate an empty BoundaryTree 517 int Ntess = Nimage;518 579 TessellationTable *tess = NULL; 519 ALLOCATE (tess, TessellationTable, Ntess); 520 580 581 int NtessDisk = 0; 582 if (APPEND) { 583 tess = TessellationTableLoad (treefile, &NtessDisk); 584 REALLOCATE (tess, TessellationTable, Nimage + NtessDisk); 585 } else { 586 ALLOCATE (tess, TessellationTable, Nimage + NtessDisk); 587 } 588 589 TessellationTableInit (&tess[NtessDisk], Nimage); 590 521 591 // find the RA,DEC of the image centers & assign to cells 522 for (i = 0; i < Ntess; i++) { 592 int Ntess = NtessDisk; 593 for (i = 0; i < Nimage; i++) { 523 594 // user supplied values, do not try to derive from Image.dat 524 tess[ i].NX_SUB = NX_SUB;525 tess[ i].NY_SUB = NY_SUB;526 tess[ i].dPix = SCALE/3600.0;595 tess[Ntess].NX_SUB = NX_SUB; 596 tess[Ntess].NY_SUB = NY_SUB; 597 tess[Ntess].dPix = SCALE/3600.0; 527 598 528 599 x = 0.5*image[i].NX; … … 530 601 XY_to_RD (&ra, &dec, x, y, &image[i].coords); 531 602 532 tess[ i].Ro = ra;533 tess[ i].Do = dec;534 tess[ i].Xo = x;535 tess[ i].Yo = y;536 tess[ i].dX = image[i].NX / NX_SUB;537 tess[ i].dY = image[i].NY / NY_SUB;603 tess[Ntess].Ro = ra; 604 tess[Ntess].Do = dec; 605 tess[Ntess].Xo = x; 606 tess[Ntess].Yo = y; 607 tess[Ntess].dX = image[i].NX / NX_SUB; 608 tess[Ntess].dY = image[i].NY / NY_SUB; 538 609 539 610 // find the minimum or maximum containing region … … 547 618 548 619 if (REGION_OPTION == REGION_MIN) { 549 for ( i = 0; i < 4; i++) {550 R_MIN = (R[ i] < ra) ? (isfinite(R_MIN) ? MAX(R_MIN, R[i]) : R[i]) : R_MIN;551 R_MAX = (R[ i] > ra) ? (isfinite(R_MAX) ? MIN(R_MAX, R[i]) : R[i]) : R_MAX;552 D_MIN = (D[ i] < dec) ? (isfinite(D_MIN) ? MAX(D_MIN, D[i]) : D[i]) : D_MIN;553 D_MAX = (D[ i] > dec) ? (isfinite(D_MAX) ? MIN(D_MAX, D[i]) : D[i]) : D_MAX;620 for (j = 0; j < 4; j++) { 621 R_MIN = (R[j] < ra) ? (isfinite(R_MIN) ? MAX(R_MIN, R[j]) : R[j]) : R_MIN; 622 R_MAX = (R[j] > ra) ? (isfinite(R_MAX) ? MIN(R_MAX, R[j]) : R[j]) : R_MAX; 623 D_MIN = (D[j] < dec) ? (isfinite(D_MIN) ? MAX(D_MIN, D[j]) : D[j]) : D_MIN; 624 D_MAX = (D[j] > dec) ? (isfinite(D_MAX) ? MIN(D_MAX, D[j]) : D[j]) : D_MAX; 554 625 } 555 626 } else { 556 for ( i = 0; i < 4; i++) {557 R_MIN = (R[ i] < ra) ? (isfinite(R_MIN) ? MIN(R_MIN, R[i]) : R[i]) : R_MIN;558 R_MAX = (R[ i] > ra) ? (isfinite(R_MAX) ? MAX(R_MAX, R[i]) : R[i]) : R_MAX;559 D_MIN = (D[ i] < dec) ? (isfinite(D_MIN) ? MIN(D_MIN, D[i]) : D[i]) : D_MIN;560 D_MAX = (D[ i] > dec) ? (isfinite(D_MAX) ? MAX(D_MAX, D[i]) : D[i]) : D_MAX;627 for (j = 0; j < 4; j++) { 628 R_MIN = (R[j] < ra) ? (isfinite(R_MIN) ? MIN(R_MIN, R[j]) : R[j]) : R_MIN; 629 R_MAX = (R[j] > ra) ? (isfinite(R_MAX) ? MAX(R_MAX, R[j]) : R[j]) : R_MAX; 630 D_MIN = (D[j] < dec) ? (isfinite(D_MIN) ? MIN(D_MIN, D[j]) : D[j]) : D_MIN; 631 D_MAX = (D[j] > dec) ? (isfinite(D_MAX) ? MAX(D_MAX, D[j]) : D[j]) : D_MAX; 561 632 } 562 633 } 563 634 } 564 tess[ i].Rmin = R_MIN;565 tess[ i].Rmax = R_MAX;566 tess[ i].Dmin = D_MIN;567 tess[ i].Dmax = D_MAX;568 569 tess[ i].type = TESS_LOCAL;635 tess[Ntess].Rmin = R_MIN; 636 tess[Ntess].Rmax = R_MAX; 637 tess[Ntess].Dmin = D_MIN; 638 tess[Ntess].Dmax = D_MAX; 639 640 tess[Ntess].type = TESS_LOCAL; 570 641 571 642 // XXX I don't really want to do the work of discovering the rule... 572 tess[i].Nbasename = strlen(BASENAME); 573 tess[i].basename = strcreate(BASENAME); 574 575 tess[i].projectIDoff = projectIDoff; 576 tess[i].skycellIDoff = skycellIDoff; 643 tess[Ntess].Nbasename = strlen(BASENAME); 644 tess[Ntess].basename = strcreate(BASENAME); 645 646 tess[Ntess].projectIDoff = projectIDoff; 647 tess[Ntess].skycellIDoff = skycellIDoff; 648 649 Ntess ++; 577 650 } 578 651 -
branches/eam_branches/ipp-20131211/Ohana/src/libdvo/include/dvo.h
r36472 r36474 810 810 TessellationTable *TessellationTableLoad(char *filename, int *Ntess); 811 811 int TessellationTableSave(char *filename, TessellationTable *tess, int Ntess); 812 int TessellationPrimaryCellIDs (TessellationTable *tess, int Ntess, int *tessID, int *projID, int *skycellID, double ra, double dec); 813 void TessellationTableInit (TessellationTable *tess, int Ntess); 812 814 813 815 void dvo_average_init (Average *average); -
branches/eam_branches/ipp-20131211/Ohana/src/libdvo/src/TessellationTable.c
r36472 r36474 10 10 11 11 # define DEBUG 0 12 13 void TessellationTableInit (TessellationTable *tess, int Ntess) { 14 15 int i; 16 17 for (i = 0; i < Ntess; i++) { 18 tess[i].Rmin = NAN; 19 tess[i].Rmax = NAN; 20 tess[i].Dmin = NAN; 21 tess[i].Dmax = NAN; 22 23 tess[i].Xo = NAN; 24 tess[i].Yo = NAN; 25 tess[i].Ro = NAN; 26 tess[i].Do = NAN; 27 28 tess[i].dPix = NAN; 29 30 tess[i].dX = 0; 31 tess[i].dY = 0; 32 33 tess[i].NX_SUB = 0; 34 tess[i].NY_SUB = 0; 35 36 tess[i].basename = NULL; 37 tess[i].Nbasename = 0; 38 39 tess[i].projectIDoff = 0; 40 tess[i].skycellIDoff = 0; 41 42 tess[i].type = TESS_NONE; 43 tess[i].tree = NULL; 44 } 45 return; 46 } 12 47 13 48 // backwards compatible load : if the first table is a BoundaryTree, not a TessellationTable, just load that. … … 64 99 65 100 ALLOCATE (tess, TessellationTable, 1); 101 TessellationTableInit (tess, 1); 66 102 tess[0].tree = tree; 67 103 tess[0].type = TESS_RINGS; 104 tess[0].Rmin = 0; 105 tess[0].Rmax = 360; 106 tess[0].Dmin = -90; 107 tess[0].Dmax = +90; 68 108 *Ntess = 1; 69 109 return tess; … … 86 126 GET_COLUMN_NEW(dY, "Y_GRID", int); 87 127 GET_COLUMN_NEW(Rmin, "R_MIN", double); 88 GET_COLUMN_NEW(Rmax, "R_M IN", double);128 GET_COLUMN_NEW(Rmax, "R_MAX", double); 89 129 GET_COLUMN_NEW(Dmin, "D_MIN", double); 90 130 GET_COLUMN_NEW(Dmax, "D_MAX", double); … … 92 132 GET_COLUMN_NEW(NX_SUB, "NX_SUB", int); 93 133 GET_COLUMN_NEW(NY_SUB, "NY_SUB", int); 134 GET_COLUMN_NEW(TYPE, "TYPE", int); 135 136 GET_COLUMN_NEW(PROJECT_ID_OFF, "PROJECT_ID_OFF", int); 137 GET_COLUMN_NEW(SKYCELL_ID_OFF, "SKYCELL_ID_OFF", int); 138 139 GET_COLUMN_NEW(BASENAME, "BASENAME", char); 94 140 95 141 *Ntess = Nrow; … … 109 155 tess[i].NX_SUB = NX_SUB[i]; 110 156 tess[i].NY_SUB = NY_SUB[i]; 111 tess[i].type = TESS_LOCAL; 157 tess[i].type = TYPE[i]; 158 159 tess[i].projectIDoff = PROJECT_ID_OFF[i]; 160 tess[i].skycellIDoff = SKYCELL_ID_OFF[i]; 161 162 ALLOCATE (tess[i].basename, char, BOUNDARY_TREE_NAME_LENGTH); 163 memcpy (tess[i].basename, &BASENAME[i*BOUNDARY_TREE_NAME_LENGTH], BOUNDARY_TREE_NAME_LENGTH); 164 tess[i].Nbasename = strlen (tess[i].basename); 165 112 166 tess[i].tree = NULL; 113 167 } … … 126 180 free(NX_SUB); 127 181 free(NY_SUB); 182 free(TYPE); 183 184 free(PROJECT_ID_OFF); 185 free(SKYCELL_ID_OFF); 128 186 129 187 gfits_free_header (&theader); … … 134 192 /*** check for a RINGS entry ***/ 135 193 194 // find the RINGS tessellation (if present) 195 TessellationTable *rings = NULL; 196 for (i = 0; i < *Ntess; i++) { 197 if (tess[i].type == TESS_LOCAL) continue; 198 if (tess[i].type != TESS_RINGS) continue; 199 rings = &tess[i]; 200 } 201 202 if (!rings) { 203 fclose (f); 204 gfits_free_header (&header); 205 gfits_free_matrix (&matrix); 206 return (tess); 207 } 208 136 209 // load data for this header, or exit 137 210 if (!gfits_load_header (f, &theader)) { 211 fprintf (stderr, "warning : RINGS tessellation listed in table but not present\n"); 212 gfits_free_header (&header); 213 gfits_free_matrix (&matrix); 138 214 return tess; 139 215 } … … 142 218 gfits_scan (&theader, "EXTNAME", "%s", 1, extname); 143 219 144 // is this a BoundaryTree? if so, it must be stand-alone: load just that and generate a 145 // containing TessellationTable. 146 if (!strcmp(extname, "ZONE_DATA")) { 147 BoundaryTree *tree = BoundaryTreeRead (&header, &theader, f); 220 if (strcmp(extname, "ZONE_DATA")) { 221 fprintf (stderr, "warning : RINGS tessellation listed in table but not present\n"); 148 222 gfits_free_header (&theader); 149 223 gfits_free_header (&header); 150 224 gfits_free_matrix (&matrix); 151 fclose (f);152 153 (*Ntess) ++;154 REALLOCATE (tess, TessellationTable, *Ntess);155 tess[(*Ntess - 1)].tree = tree;156 tess[(*Ntess - 1)].type = TESS_RINGS;157 225 return tess; 158 226 } 159 227 228 // is this a BoundaryTree? if so, it must be stand-alone: load just that and generate a 229 // containing TessellationTable. 230 BoundaryTree *tree = BoundaryTreeRead (&header, &theader, f); 160 231 gfits_free_header (&theader); 161 232 gfits_free_header (&header); 162 233 gfits_free_matrix (&matrix); 163 234 fclose (f); 164 235 236 rings->tree = tree; 165 237 return tess; 166 238 … … 237 309 gfits_define_bintable_column (&theader, "J", "NX_SUB", "skycell subdivision in x", "none", 1.0, 0.0); 238 310 gfits_define_bintable_column (&theader, "J", "NY_SUB", "skycell subdivision in y", "none", 1.0, 0.0); 311 gfits_define_bintable_column (&theader, "J", "TYPE", "type of tessellation", "none", 1.0, 0.0); 312 313 gfits_define_bintable_column (&theader, "J", "PROJECT_ID_OFF", "offset in image name to projection cell ID", "none", 1.0, 0.0); 314 gfits_define_bintable_column (&theader, "J", "SKYCELL_ID_OFF", "offset in image name to skycell ID", "none", 1.0, 0.0); 315 316 char fmt[16]; 317 snprintf (fmt, 16, "%dA", BOUNDARY_TREE_NAME_LENGTH); 318 gfits_define_bintable_column (&theader, fmt, "BASENAME", "image base name", "none", 1.0, 0.0); 239 319 240 320 // generate the output array that carries the data 241 321 gfits_create_table (&theader, &ftable); 242 322 243 int Nout = (rings == NULL) ? Ntess : Ntess - 1; 323 // int Nout = (rings == NULL) ? Ntess : Ntess - 1; 324 int Nout = Ntess; 244 325 245 326 // create intermediate storage arrays … … 258 339 int *NX_SUB ; ALLOCATE (NX_SUB, int, Nout); 259 340 int *NY_SUB ; ALLOCATE (NY_SUB, int, Nout); 341 int *TYPE ; ALLOCATE (TYPE, int, Nout); 342 343 int *PROJECT_ID_OFF; ALLOCATE (PROJECT_ID_OFF, int, Nout); 344 int *SKYCELL_ID_OFF; ALLOCATE (SKYCELL_ID_OFF, int, Nout); 345 346 char *BASENAME ; ALLOCATE (BASENAME, char, Nout*BOUNDARY_TREE_NAME_LENGTH); 347 memset (BASENAME, 0, Nout*BOUNDARY_TREE_NAME_LENGTH); 260 348 261 349 // assign the storage arrays 350 // XXX I was not writing out the RINGS tess entry, but that probably is not useful (drop 351 // N vs i in future?) 262 352 int N = 0; 263 353 for (i = 0; i < Ntess; i++) { 264 if (tess->type != TESS_LOCAL) continue;354 // if (tess->type != TESS_LOCAL) continue; 265 355 Ro[N] = tess[i].Ro; 266 356 Do[N] = tess[i].Do; … … 276 366 NX_SUB[N] = tess[i].NX_SUB; 277 367 NY_SUB[N] = tess[i].NY_SUB; 368 TYPE[N] = tess[i].type; 369 370 PROJECT_ID_OFF[N] = tess[i].projectIDoff; 371 SKYCELL_ID_OFF[N] = tess[i].skycellIDoff; 372 373 if (tess[i].basename) { 374 memcpy(&BASENAME[N*BOUNDARY_TREE_NAME_LENGTH], tess[i].basename, BOUNDARY_TREE_NAME_LENGTH); 375 } 376 278 377 N++; 279 378 } … … 293 392 gfits_set_bintable_column (&theader, &ftable, "NX_SUB", NX_SUB, Nout); 294 393 gfits_set_bintable_column (&theader, &ftable, "NY_SUB", NY_SUB, Nout); 394 gfits_set_bintable_column (&theader, &ftable, "TYPE", TYPE, Nout); 395 396 gfits_set_bintable_column (&theader, &ftable, "PROJECT_ID_OFF", PROJECT_ID_OFF, Nout); 397 gfits_set_bintable_column (&theader, &ftable, "SKYCELL_ID_OFF", SKYCELL_ID_OFF, Nout); 398 gfits_set_bintable_column (&theader, &ftable, "BASENAME", BASENAME, Nout); 295 399 296 400 free (Ro ); … … 307 411 free (NX_SUB); 308 412 free (NY_SUB); 413 free (TYPE); 414 415 free (PROJECT_ID_OFF); 416 free (SKYCELL_ID_OFF); 417 free (BASENAME); 309 418 310 419 gfits_fwrite_Theader (f, &theader); … … 321 430 return TRUE; 322 431 } 432 433 int TessellationLocalProjection (double *x, double *y, double r, double d, TessellationTable *tess) { 434 435 double Xo = tess->Xo; 436 double Yo = tess->Yo; 437 double Ro = tess->Ro; 438 double Do = tess->Do; 439 double dPix = tess->dPix; 440 441 // this block only depends on Ro, Do 442 443 double sdp = sin(RAD_DEG*Do); 444 double cdp = cos(RAD_DEG*Do); 445 double salp = sin(RAD_DEG*(r - Ro)); 446 double calp = cos(RAD_DEG*(r - Ro)); 447 double sdel = sin(RAD_DEG*d); 448 double cdel = cos(RAD_DEG*d); 449 450 double stht = sdel*sdp + cdel*cdp*calp; /* sin(theta) */ 451 double sphi = cdel*salp; /* = cos(theta)*sin(phi) */ 452 double cphi = cdel*sdp*calp - sdel*cdp; /* = cos(theta)*cos(phi) */ 453 454 // defines the TAN projection (one of zenithal projections available, libdvo/src/coordops.c 455 // R = cot (theta) = cos(theta) / sin(theta) 456 double L, M; 457 if (stht == 0) { 458 double Rc = hypot(sphi, cphi); 459 L = 180.0 * sphi / Rc; 460 M = 180.0 * cphi / Rc; 461 } else { 462 L = +DEG_RAD * sphi / stht; 463 M = -DEG_RAD * cphi / stht; 464 } 465 466 // scale, rotation, parity: 467 // rotation == 0.0 (pc1_1 == pc2_2 == 1.0, pc1_2 = pc2_1 = 0.0) 468 469 // if there were rotation or parity: 470 // Ro = (coords[0].pc1_1*coords[0].pc2_2 - coords[0].pc1_2*coords[0].pc2_1); 471 // Xo = (coords[0].pc2_2*L - coords[0].pc1_2*M) / Ro; 472 // Yo = (coords[0].pc1_1*M - coords[0].pc2_1*L) / Ro; 473 474 double X = L; 475 double Y = M; 476 477 // scale is dPix 478 479 *x = Xo - X / dPix; 480 *y = Yo + Y / dPix; 481 482 return TRUE; 483 } 484 485 static int Nfail = 0; 486 487 // for the given ra,dec : find the valid tessellation and the containing projection / skycell IDs 488 int TessellationPrimaryCellIDs (TessellationTable *tess, int Ntess, int *tessID, int *projID, int *skycellID, double ra, double dec) { 489 490 int i, zone, band; 491 492 *tessID = -1; 493 *projID = -1; 494 *skycellID = -1; 495 496 if (!tess) return FALSE; 497 498 // find the tessellation which includes this location 499 int myTess = -1; 500 for (i = 0; i < Ntess; i++) { 501 if (ra < tess[i].Rmin) continue; 502 if (ra >= tess[i].Rmax) continue; 503 if (dec < tess[i].Dmin) continue; 504 if (dec >= tess[i].Dmax) continue; 505 myTess = i; 506 break; 507 } 508 if (myTess < 0) { 509 if (Nfail < 100) { 510 fprintf (stderr, "no matching tessellation @ %f,%f\n", ra, dec); 511 } 512 Nfail ++; 513 return FALSE; 514 } 515 516 if (tess[myTess].type == TESS_NONE) { 517 if (Nfail < 100) { 518 fprintf (stderr, "tess has invalid type\n"); 519 Nfail ++; 520 } 521 return FALSE; 522 } 523 524 if (tess[myTess].type == TESS_LOCAL) { 525 // I have ra, dec, and the primary projection cell. In order to choose the primary skycell, 526 // I just need to project to ra,dec to X,Y based on the center of the cell and then get the subdivision right. 527 528 double x = 0.0; 529 double y = 0.0; 530 TessellationLocalProjection (&x, &y, ra, dec, &tess[myTess]); 531 532 int xi = x / tess[myTess].dX; 533 int yi = y / tess[myTess].dY; 534 int N = xi + tess[myTess].NX_SUB * yi; 535 536 *tessID = myTess; 537 *projID = 0; 538 *skycellID = N; 539 540 // *projID = tess[myTess].projID :: NOTE : The projection cell may be non-zero like eg 541 // STS. However, I'm not certain we are going to implement it like this. 542 543 return TRUE; 544 } 545 546 if (tess[myTess].type == TESS_RINGS) { 547 if (!BoundaryTreeCellCoords (tess[myTess].tree, &zone, &band, ra, dec)) { 548 fprintf (stderr, "mismatch!\n"); 549 return FALSE; 550 } 551 552 // I have ra, dec, and the primary projection cell. In order to choose the primary skycell, 553 // I just need to project to ra,dec to X,Y based on the center of the cell and then get the subdivision right. 554 555 double x = 0.0; 556 double y = 0.0; 557 BoundaryTreeProjection (&x, &y, ra, dec, tess[myTess].tree, zone, band); 558 559 int xi = x / tess[myTess].tree->dX[zone][band]; 560 int yi = y / tess[myTess].tree->dY[zone][band]; 561 int N = xi + tess[myTess].tree->NX_SUB * yi; 562 563 *tessID = myTess; 564 *projID = tess[myTess].tree->projID[zone][band]; 565 *skycellID = N; 566 567 return TRUE; 568 } 569 570 fprintf (stderr, "invalid tessellation type!\n"); 571 return FALSE; 572 } 573 -
branches/eam_branches/ipp-20131211/Ohana/src/relphot/include/relphot.h
r35806 r36474 116 116 unsigned int photom_map_id; 117 117 unsigned int flags; 118 int tessID; 118 119 int projID; 119 120 int skycellID; … … 401 402 402 403 int MatchImageName (off_t meas, int cat, char *name); 403 int MatchImageSkycellID (off_t meas, int cat, int myProjectionID, int mySkycellID); 404 405 int load_tree (char *treefile); 406 int BoundaryTreePrimaryCell (char *primaryCellName, double ra, double dec); 407 int BoundaryTreePrimaryCellIDs (int *projID, int *skycellID, double ra, double dec); 404 int MatchImageSkycellID (off_t meas, int cat, int myTessID, int myProjectionID, int mySkycellID); 405 406 int load_tess (char *treefile); 407 int get_tess_ids (int *tessID, int *projID, int *skycellID, double ra, double dec); 408 int TessellationIDsByImageName (int *tessID, int *projID, int *skycellID, char *name); 409 410 // int BoundaryTreePrimaryCell (char *primaryCellName, double ra, double dec); 411 // int BoundaryTreePrimaryCellIDs (int *projID, int *skycellID, double ra, double dec); 408 412 409 413 int print_measure_set_alt (Average *average, SecFilt *secfilt, Measure *measure); -
branches/eam_branches/ipp-20131211/Ohana/src/relphot/src/BoundaryTreeOps.c
r36466 r36474 1 1 # include "relphot.h" 2 2 3 static int Nfail = 0;4 3 static int Ntess = 0; 5 static Tess llationBoundary*tess = NULL;4 static TessellationTable *tess = NULL; 6 5 7 // for the given ra,dec : find the valid tessallation and the containing projection / skycell IDs 8 int TessallationPrimaryCellIDs (int *tessID, int *projID, int *skycellID, double ra, double dec) { 6 int TessellationIDsByImageName (int *tessID, int *projID, int *skycellID, char *name) { 9 7 10 int zone, band; 11 12 *tessID = -1; 13 *projID = -1; 14 *skycellID = -1; 15 16 if (!tess) return FALSE; 17 18 // find the tessellation which includes this location 19 int myTess = -1; 20 for (i = 0; i < Ntess; i++) { 21 if (ra < tess[i].Rmin) continue; 22 if (ra >= tess[i].Rmax) continue; 23 if (dec < tess[i].Dmin) continue; 24 if (dec >= tess[i].Dmax) continue; 25 myTess = i; 26 break; 27 } 28 if (myTess < 0) { 29 if (Nfail < 100) { 30 fprintf (stderr, "no matching tessallation @ %f,%f\n", ra, dec); 31 } 32 Nfail ++; 33 return FALSE; 34 } 35 36 if (tess[myTess].type == TESS_NONE) { 37 if (Nfail < 100) { 38 fprintf (stderr, "tess has invalid type\n"); 39 Nfail ++; 40 } 41 return FALSE; 42 } 43 44 if (tess[myTess].type == TESS_LOCAL) { 45 // I have ra, dec, and the primary projection cell. In order to choose the primary skycell, 46 // I just need to project to ra,dec to X,Y based on the center of the cell and then get the subdivision right. 47 48 double x = 0.0; 49 double y = 0.0; 50 TessallationLocalProjection (&x, &y, ra, dec, &tess[myTess]); 51 52 int xi = x / tess[myTess].dX; 53 int yi = y / tess[myTess].dY; 54 int N = xi + tess[myTess].NX_SUB * yi; 55 56 *tessID = myTess; 57 *projID = tess[myTess].projID; 58 *skycellID = N; 59 60 return TRUE; 61 } 62 63 if (tess[myTess].type == TESS_RINGS) { 64 if (!BoundaryTreeCellCoords (tess[myTess].tree, &zone, &band, ra, dec)) { 65 fprintf (stderr, "mismatch!\n"); 66 return FALSE; 67 } 68 69 // I have ra, dec, and the primary projection cell. In order to choose the primary skycell, 70 // I just need to project to ra,dec to X,Y based on the center of the cell and then get the subdivision right. 71 72 double x = 0.0; 73 double y = 0.0; 74 BoundaryTreeProjection (&x, &y, ra, dec, tess[myTess].tree, zone, band); 75 76 int xi = x / tess[myTess].tree->dX[zone][band]; 77 int yi = y / tess[myTess].tree->dY[zone][band]; 78 int N = xi + tess[myTess].tree->NX_SUB * yi; 79 80 *tessID = myTess; 81 *projID = tess[myTess].tree->projID[zone][band]; 82 *skycellID = N; 83 84 return TRUE; 85 } 86 } 87 88 int TessallationIDsByImageName (int *tessID, int *projID, int *skycellID, char *name) { 8 int i; 89 9 90 10 *tessID = -1; … … 98 18 if (!strncmp (name, tess[i].basename, tess[i].Nbasename)) { 99 19 *tessID = i; 100 *projID = atoi(&name[tess[i].projectIDoff]); 101 *skycellID = atoi(&name[tess[i].skycellIDoff]); 20 if (tess[i].projectIDoff >= 0) { 21 *projID = atoi(&name[tess[i].projectIDoff]); 22 } else { 23 *projID = 0; 24 } 25 if (tess[i].skycellIDoff >= 0) { 26 *skycellID = atoi(&name[tess[i].skycellIDoff]); 27 } else { 28 *skycellID = 0; 29 } 102 30 return TRUE; 103 31 } … … 108 36 int load_tess (char *tessfile) { 109 37 110 tess = Tess BoundaryLoad (tessfile, &Ntess);38 tess = TessellationTableLoad (tessfile, &Ntess); 111 39 if (!tess) { 112 fprintf (stderr, "failed to load tess allation boundary file %s\n", tessfile);40 fprintf (stderr, "failed to load tessellation boundary file %s\n", tessfile); 113 41 exit (2); 114 42 } … … 116 44 return TRUE; 117 45 } 46 47 int get_tess_ids (int *tessID, int *projID, int *skycellID, double ra, double dec) { 48 49 int status; 50 51 if (!tess) return FALSE; 52 53 status = TessellationPrimaryCellIDs(tess, Ntess, tessID, projID, skycellID, ra, dec); 54 return status; 55 } -
branches/eam_branches/ipp-20131211/Ohana/src/relphot/src/ImageOps.c
r36466 r36474 48 48 // stack image. for now, we generate these ID arrays based on the image names when we load in the image table (initImages). 49 49 // When we pass data to the remote clients via the ImageSubset, the projID/skycellID values are carried directly in the table. 50 int *tessID = NULL; 50 51 int *projectID = NULL; 51 52 int *skycellID = NULL; … … 81 82 82 83 // for stack images, assign projection cell ID and skycell ID based on filenames 84 ALLOCATE (tessID, int, Nimage); 83 85 ALLOCATE (projectID, int, Nimage); 84 86 ALLOCATE (skycellID, int, Nimage); … … 88 90 imageIDs[i] = image[i].imageID; 89 91 90 tessID[i] = -1;92 tessID[i] = -1; 91 93 projectID[i] = -1; 92 94 skycellID[i] = -1; 93 95 94 Tess allationIDsByImageName (&tessID[i], &projectID[i], &skycellID[i], image[i].name);96 TessellationIDsByImageName (&tessID[i], &projectID[i], &skycellID[i], image[i].name); 95 97 } 96 98 … … 107 109 // create full a Image array and save the needed values 108 110 ALLOCATE (image, Image, N); 111 112 ALLOCATE (tessID, int, N); 109 113 ALLOCATE (projectID, int, N); 110 114 ALLOCATE (skycellID, int, N); … … 119 123 image[i].trate = input[i].trate ; 120 124 image[i].ubercalDist = input[i].ubercalDist ; 125 tessID[i] = input[i].tessID ; 121 126 projectID[i] = input[i].projID ; 122 127 skycellID[i] = input[i].skycellID ; … … 154 159 subset[i].trate = image[i].trate ; 155 160 subset[i].ubercalDist = image[i].ubercalDist ; 161 subset[i].tessID = tessID[i]; 156 162 subset[i].projID = projectID[i]; 157 163 subset[i].skycellID = skycellID[i]; … … 462 468 463 469 // returns image.Mcal - ff(x,y) 464 int MatchImageSkycellID (off_t meas, int cat, int my ProjectionID, int mySkycellID) {470 int MatchImageSkycellID (off_t meas, int cat, int myTessID, int myProjectionID, int mySkycellID) { 465 471 466 472 off_t i; … … 471 477 if (i == -1) return FALSE; 472 478 479 if (tessID[i] == -1) return FALSE; 473 480 if (projectID[i] == -1) return FALSE; 474 481 if (skycellID[i] == -1) return FALSE; 475 482 483 if (tessID[i] != myTessID) return FALSE; 476 484 if (projectID[i] != myProjectionID) return FALSE; 477 485 if (skycellID[i] != mySkycellID) return FALSE; -
branches/eam_branches/ipp-20131211/Ohana/src/relphot/src/ImageSubset.c
r35759 r36474 63 63 GET_COLUMN (map, "PHOTOM_MAP", int); 64 64 GET_COLUMN (flags, "FLAGS", int); 65 GET_COLUMN (tessID, "TESS_ID", int); 65 66 GET_COLUMN (projID, "PROJ_ID", int); 66 67 GET_COLUMN (skycellID, "SKYCELL_ID", int); … … 78 79 image[i].photom_map_id = map[i]; 79 80 image[i].flags = flags[i]; 81 image[i].tessID = tessID[i]; 80 82 image[i].projID = projID[i]; 81 83 image[i].skycellID = skycellID[i]; … … 91 93 free (map); 92 94 free (flags); 95 free (tessID); 93 96 free (projID); 94 97 free (skycellID); … … 130 133 gfits_define_bintable_column (&theader, "J", "FLAGS", "flags", NULL, 1.0, 1.0*0x8000); 131 134 135 gfits_define_bintable_column (&theader, "J", "TESS_ID", "ID", NULL, 1.0, 0.0); 132 136 gfits_define_bintable_column (&theader, "J", "PROJ_ID", "ID", NULL, 1.0, 0.0); 133 137 gfits_define_bintable_column (&theader, "J", "SKYCELL_ID", "ID", NULL, 1.0, 0.0); … … 143 147 float *Mcal, *dMcal; 144 148 unsigned int *imageID, *map, *flags, *tzero; 145 int * projID, *skycellID;149 int *tessID, *projID, *skycellID; 146 150 unsigned short *trate; 147 151 short *ucdist; … … 153 157 ALLOCATE (map, unsigned int, Nimage); 154 158 ALLOCATE (flags, unsigned int, Nimage); 159 ALLOCATE (tessID, int, Nimage); 155 160 ALLOCATE (projID, int, Nimage); 156 161 ALLOCATE (skycellID, int, Nimage); … … 169 174 trate[i] = image[i].trate; 170 175 ucdist[i] = image[i].ubercalDist; 176 tessID[i] = image[i].tessID; 171 177 projID[i] = image[i].projID; 172 178 skycellID[i] = image[i].skycellID; … … 179 185 gfits_set_bintable_column (&theader, &ftable, "PHOTOM_MAP", map, Nimage); 180 186 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags, Nimage); 187 gfits_set_bintable_column (&theader, &ftable, "TESS_ID", tessID, Nimage); 181 188 gfits_set_bintable_column (&theader, &ftable, "PROJ_ID", projID, Nimage); 182 189 gfits_set_bintable_column (&theader, &ftable, "SKYCELL_ID", skycellID, Nimage); … … 190 197 free (map); 191 198 free (flags); 199 free (tessID); 192 200 free (projID); 193 201 free (skycellID); -
branches/eam_branches/ipp-20131211/Ohana/src/relphot/src/StarOps.c
r35759 r36474 328 328 int setMrel_catalog (Catalog *catalog, int Nc, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, int Nsecfilt) { 329 329 330 fprintf (stderr, "??? should you still be using the old version of setMrel_catalog??\n"); 331 exit (3); 332 330 333 off_t j, k, m, ID; 331 334 int N; … … 366 369 if (isSetMrelFinal) { 367 370 // set the name of the primary skycell (this is used in a strcmp to match the skycells in stack detections) 368 BoundaryTreePrimaryCell(primaryCell, catalog[Nc].average[j].R, catalog[Nc].average[j].D); 371 // XXX : this whole function is deprecated 372 // BoundaryTreePrimaryCell(primaryCell, catalog[Nc].average[j].R, catalog[Nc].average[j].D); 369 373 } 370 374 -
branches/eam_branches/ipp-20131211/Ohana/src/relphot/src/args.c
r36466 r36474 223 223 remove_argument (N, &argc, argv); 224 224 BOUNDARY_TREE = strcreate(argv[N]); 225 load_t ree(BOUNDARY_TREE);225 load_tess (BOUNDARY_TREE); 226 226 remove_argument (N, &argc, argv); 227 227 } … … 426 426 remove_argument (N, &argc, argv); 427 427 BOUNDARY_TREE = strcreate(argv[N]); 428 load_t ree(BOUNDARY_TREE);428 load_tess (BOUNDARY_TREE); 429 429 remove_argument (N, &argc, argv); 430 430 } -
branches/eam_branches/ipp-20131211/Ohana/src/relphot/src/setMrelCatalog.c
r36466 r36474 409 409 int projectID = -1; 410 410 int skycellID = -1; 411 TessallationTreePrimaryCellIDs(&tessID, &projectID, &skycellID, average[0].R, average[0].D);411 get_tess_ids(&tessID, &projectID, &skycellID, average[0].R, average[0].D); 412 412 413 413 int NstackGood = 0; … … 477 477 // which stack image should we use for the mean value? 478 478 // if we request the primary (USE_TREE_FOR_PRIMARY), then find the min distances for data from the primary cell 479 if (MatchImageSkycellID (meas, cat, projectID, skycellID)) {479 if (MatchImageSkycellID (meas, cat, tessID, projectID, skycellID)) { 480 480 float stackPrimaryOffset = getCenterOffset (meas, cat, &measure[k], &stackImageID); 481 481 if (stackPrimaryOffset < stackPrimaryOffsetMin) {
Note:
See TracChangeset
for help on using the changeset viewer.
