Changeset 36466
- Timestamp:
- Feb 1, 2014, 6:04:48 AM (12 years ago)
- Location:
- branches/eam_branches/ipp-20131211/Ohana/src/relphot/src
- Files:
-
- 4 edited
-
BoundaryTreeOps.c (modified) (1 diff)
-
ImageOps.c (modified) (1 diff)
-
args.c (modified) (1 diff)
-
setMrelCatalog.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20131211/Ohana/src/relphot/src/BoundaryTreeOps.c
r35759 r36466 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 Nfail = 0; 4 static int Ntess = 0; 5 static TessllationBoundary *tess = NULL; 5 6 6 static BoundaryTree *tree = NULL; 7 8 int BoundaryTreePrimaryCell (char *primaryCellName, double ra, double dec) { 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) { 9 9 10 10 int zone, band; 11 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 12 *tessID = -1; 55 13 *projID = -1; 56 14 *skycellID = -1; 57 15 58 if (!t ree) return FALSE;16 if (!tess) return FALSE; 59 17 60 if (!BoundaryTreeCellCoords (tree, &zone, &band, ra, dec)) { 61 fprintf (stderr, "mismatch!\n"); 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 ++; 62 33 return FALSE; 63 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]); 64 51 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. 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. 67 71 68 double x = 0.0;69 double y = 0.0;70 BoundaryTreeProjection (&x, &y, ra, dec,tree, zone, band);72 double x = 0.0; 73 double y = 0.0; 74 BoundaryTreeProjection (&x, &y, ra, dec, tess[myTess].tree, zone, band); 71 75 72 int xi = x /tree->dX[zone][band];73 int yi = y /tree->dY[zone][band];74 int N = xi +tree->NX_SUB * yi;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; 75 79 76 *projID = tree->projID[zone][band]; 77 *skycellID = N; 80 *tessID = myTess; 81 *projID = tess[myTess].tree->projID[zone][band]; 82 *skycellID = N; 78 83 79 return TRUE; 84 return TRUE; 85 } 80 86 } 81 87 82 int load_tree (char *treefile) {88 int TessallationIDsByImageName (int *tessID, int *projID, int *skycellID, char *name) { 83 89 84 tree = BoundaryTreeLoad (treefile); 85 if (!tree) { 86 fprintf (stderr, "failed to load boundary tree %s\n", treefile); 90 *tessID = -1; 91 *projID = -1; 92 *skycellID = -1; 93 94 if (!tess) return FALSE; 95 96 for (i = 0; i < Ntess; i++) { 97 // do this with a strhash of some kind? 98 if (!strncmp (name, tess[i].basename, tess[i].Nbasename)) { 99 *tessID = i; 100 *projID = atoi(&name[tess[i].projectIDoff]); 101 *skycellID = atoi(&name[tess[i].skycellIDoff]); 102 return TRUE; 103 } 104 } 105 return FALSE; 106 } 107 108 int load_tess (char *tessfile) { 109 110 tess = TessBoundaryLoad (tessfile, &Ntess); 111 if (!tess) { 112 fprintf (stderr, "failed to load tessallation boundary file %s\n", tessfile); 87 113 exit (2); 88 114 } -
branches/eam_branches/ipp-20131211/Ohana/src/relphot/src/ImageOps.c
r35759 r36466 87 87 imageIdx[i] = i; 88 88 imageIDs[i] = image[i].imageID; 89 90 tessID[i] = -1; 89 91 projectID[i] = -1; 90 92 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 } 93 94 TessallationIDsByImageName (&tessID[i], &projectID[i], &skycellID[i], image[i].name); 95 95 } 96 96 97 97 // sort the image index by the IDs 98 // XXX does this break the imageID <-> projectID, etc match? 98 99 llsortpair (imageIDs, imageIdx, Nimage); 99 100 } -
branches/eam_branches/ipp-20131211/Ohana/src/relphot/src/args.c
r35806 r36466 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"))) { -
branches/eam_branches/ipp-20131211/Ohana/src/relphot/src/setMrelCatalog.c
r36189 r36466 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 TessallationTreePrimaryCellIDs(&tessID, &projectID, &skycellID, average[0].R, average[0].D); 412 412 413 413 int NstackGood = 0;
Note:
See TracChangeset
for help on using the changeset viewer.
