Changeset 36491
- Timestamp:
- Feb 6, 2014, 12:46:42 PM (12 years ago)
- Location:
- trunk/Ohana/src/relphot
- Files:
-
- 9 edited
-
include/relphot.h (modified) (2 diffs)
-
src/BoundaryTreeOps.c (modified) (2 diffs)
-
src/ImageOps.c (modified) (8 diffs)
-
src/ImageSubset.c (modified) (9 diffs)
-
src/MosaicOps.c (modified) (1 diff)
-
src/StarOps.c (modified) (2 diffs)
-
src/args.c (modified) (2 diffs)
-
src/select_images.c (modified) (2 diffs)
-
src/setMrelCatalog.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relphot/include/relphot.h
r35806 r36491 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); -
trunk/Ohana/src/relphot/src/BoundaryTreeOps.c
r35759 r36491 1 1 # include "relphot.h" 2 2 3 // XXX for the moment, only load one boundary tree at a time 4 // XXX in fact, only allow RINGS.V3... 3 static int Ntess = 0; 4 static TessellationTable *tess = NULL; 5 5 6 static BoundaryTree *tree = NULL; 6 int TessellationIDsByImageName (int *tessID, int *projID, int *skycellID, char *name) { 7 7 8 int BoundaryTreePrimaryCell (char *primaryCellName, double ra, double dec) { 8 int i; 9 9 10 int zone, band; 11 12 if (!primaryCellName) return FALSE; 13 14 primaryCellName[0] = 0; 15 16 if (!tree) return FALSE; 17 18 if (!BoundaryTreeCellCoords (tree, &zone, &band, ra, dec)) { 19 fprintf (stderr, "mismatch!\n"); 20 return FALSE; 21 } 22 23 # define USE_PROJECTION_CELL 0 24 # if (USE_PROJECTION_CELL) 25 snprintf (primaryCellName, DVO_MAX_PATH, "RINGS.V3.%s", tree->name[zone][band]); 26 # else 27 28 // I have ra, dec, and the primary projection cell. In order to choose the primary skycell, 29 // I just need to project to ra,dec to X,Y based on the center of the cell and then get the subdivision right. 30 31 double x = 0.0; 32 double y = 0.0; 33 BoundaryTreeProjection (&x, &y, ra, dec, tree, zone, band); 34 35 int xi = x / tree->dX[zone][band]; 36 int yi = y / tree->dY[zone][band]; 37 int N = xi + tree->NX_SUB * yi; 38 39 // XXX short-circuit this for now (we should use this code if we make tree have more variable NX,NY values 40 // char format[24], skycellname[128]; 41 // int Ndigit = (int)(log10(tree->NX_SUB*tree->NY_SUB)) + 1 ; 42 // snprintf (format, 24, "%s.%%0%dd", tree->name[zone][band], Ndigit); 43 // snprintf (skycellname, 128, format, N); 44 45 snprintf (primaryCellName, DVO_MAX_PATH, "RINGS.V3.%s.%03d", tree->name[zone][band], N); 46 # endif 47 48 return TRUE; 49 } 50 51 int BoundaryTreePrimaryCellIDs (int *projID, int *skycellID, double ra, double dec) { 52 53 int zone, band; 54 10 *tessID = -1; 55 11 *projID = -1; 56 12 *skycellID = -1; 57 13 58 if (!t ree) return FALSE;14 if (!tess) return FALSE; 59 15 60 if (!BoundaryTreeCellCoords (tree, &zone, &band, ra, dec)) { 61 fprintf (stderr, "mismatch!\n"); 62 return FALSE; 16 for (i = 0; i < Ntess; i++) { 17 // do this with a strhash of some kind? 18 if (!strncmp (name, tess[i].basename, tess[i].Nbasename)) { 19 *tessID = i; 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 } 30 return TRUE; 31 } 63 32 } 64 65 // I have ra, dec, and the primary projection cell. In order to choose the primary skycell, 66 // I just need to project to ra,dec to X,Y based on the center of the cell and then get the subdivision right. 67 68 double x = 0.0; 69 double y = 0.0; 70 BoundaryTreeProjection (&x, &y, ra, dec, tree, zone, band); 71 72 int xi = x / tree->dX[zone][band]; 73 int yi = y / tree->dY[zone][band]; 74 int N = xi + tree->NX_SUB * yi; 75 76 *projID = tree->projID[zone][band]; 77 *skycellID = N; 78 79 return TRUE; 33 return FALSE; 80 34 } 81 35 82 int load_t ree (char *treefile) {36 int load_tess (char *tessfile) { 83 37 84 t ree = BoundaryTreeLoad (treefile);85 if (!t ree) {86 fprintf (stderr, "failed to load boundary tree %s\n", treefile);38 tess = TessellationTableLoad (tessfile, &Ntess); 39 if (!tess) { 40 fprintf (stderr, "failed to load tessellation boundary file %s\n", tessfile); 87 41 exit (2); 88 42 } … … 90 44 return TRUE; 91 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 } -
trunk/Ohana/src/relphot/src/ImageOps.c
r35759 r36491 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); … … 87 89 imageIdx[i] = i; 88 90 imageIDs[i] = image[i].imageID; 91 92 tessID[i] = -1; 89 93 projectID[i] = -1; 90 94 skycellID[i] = -1; 91 if (!strncmp (image[i].name, "RINGS.V3.skycell", strlen("RINGS.V3.skycell"))) { 92 projectID[i] = atoi(&image[i].name[17]); 93 skycellID[i] = atoi(&image[i].name[22]); 94 } 95 96 TessellationIDsByImageName (&tessID[i], &projectID[i], &skycellID[i], image[i].name); 95 97 } 96 98 97 99 // sort the image index by the IDs 100 // XXX does this break the imageID <-> projectID, etc match? 98 101 llsortpair (imageIDs, imageIdx, Nimage); 99 102 } … … 106 109 // create full a Image array and save the needed values 107 110 ALLOCATE (image, Image, N); 111 112 ALLOCATE (tessID, int, N); 108 113 ALLOCATE (projectID, int, N); 109 114 ALLOCATE (skycellID, int, N); … … 118 123 image[i].trate = input[i].trate ; 119 124 image[i].ubercalDist = input[i].ubercalDist ; 125 tessID[i] = input[i].tessID ; 120 126 projectID[i] = input[i].projID ; 121 127 skycellID[i] = input[i].skycellID ; … … 153 159 subset[i].trate = image[i].trate ; 154 160 subset[i].ubercalDist = image[i].ubercalDist ; 161 subset[i].tessID = tessID[i]; 155 162 subset[i].projID = projectID[i]; 156 163 subset[i].skycellID = skycellID[i]; … … 461 468 462 469 // returns image.Mcal - ff(x,y) 463 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) { 464 471 465 472 off_t i; … … 470 477 if (i == -1) return FALSE; 471 478 479 if (tessID[i] == -1) return FALSE; 472 480 if (projectID[i] == -1) return FALSE; 473 481 if (skycellID[i] == -1) return FALSE; 474 482 483 if (tessID[i] != myTessID) return FALSE; 475 484 if (projectID[i] != myProjectionID) return FALSE; 476 485 if (skycellID[i] != mySkycellID) return FALSE; -
trunk/Ohana/src/relphot/src/ImageSubset.c
r35759 r36491 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); -
trunk/Ohana/src/relphot/src/MosaicOps.c
r35806 r36491 412 412 } 413 413 dS /= MosaicN_Image[i]; 414 strcpy (mosaic[i].coords.ctype, " RA---TAN");414 strcpy (mosaic[i].coords.ctype, "DEC--TAN"); 415 415 mosaic[i].coords.crval1 = Rmin; 416 416 mosaic[i].coords.crval2 = Dmin; -
trunk/Ohana/src/relphot/src/StarOps.c
r35759 r36491 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 -
trunk/Ohana/src/relphot/src/args.c
r35806 r36491 217 217 } 218 218 219 // XXX should we load a tree from CATDIR by default? 220 // NOTE: a given catdir needs an appropriate boundary tree 219 221 BOUNDARY_TREE = NULL; 220 222 if ((N = get_argument (argc, argv, "-boundary-tree"))) { 221 223 remove_argument (N, &argc, argv); 222 224 BOUNDARY_TREE = strcreate(argv[N]); 223 load_t ree(BOUNDARY_TREE);225 load_tess (BOUNDARY_TREE); 224 226 remove_argument (N, &argc, argv); 225 227 } … … 424 426 remove_argument (N, &argc, argv); 425 427 BOUNDARY_TREE = strcreate(argv[N]); 426 load_t ree(BOUNDARY_TREE);428 load_tess (BOUNDARY_TREE); 427 429 remove_argument (N, &argc, argv); 428 430 } -
trunk/Ohana/src/relphot/src/select_images.c
r35806 r36491 40 40 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 41 41 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 42 strcpy (tcoords.ctype, " RA---TAN");42 strcpy (tcoords.ctype, "DEC--TAN"); 43 43 44 44 double RminSkyRegion = region[0].Rmin; … … 412 412 tcoords.Npolyterms = 0; 413 413 memset (tcoords.polyterms, 0, 14*sizeof(float)); 414 strcpy (tcoords.ctype, " RA---TAN");414 strcpy (tcoords.ctype, "DEC--TAN"); 415 415 416 416 /* compare with each region file */ -
trunk/Ohana/src/relphot/src/setMrelCatalog.c
r36189 r36491 405 405 float Msys = 0, Mcal= 0, Mmos = 0, Mgrid = 0; 406 406 407 // set the name of the primary skycell (this is used in a strcmp to match the skycells in stack detections)408 // XXX drop BoundaryTreePrimaryCell(primaryCell, average[0].R, average[0].D);407 // set the primary projection cell and skycell for this coordinate 408 int tessID = -1; 409 409 int projectID = -1; 410 410 int skycellID = -1; 411 BoundaryTreePrimaryCellIDs(&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.
