Changeset 21048 for trunk/Ohana
- Timestamp:
- Dec 21, 2008, 11:02:16 AM (18 years ago)
- Location:
- trunk/Ohana/src/addstar
- Files:
-
- 4 edited
-
include/skycells.h (modified) (3 diffs)
-
src/args_skycells.c (modified) (4 diffs)
-
src/sky_tessalation.c (modified) (6 diffs)
-
src/skycells.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/include/skycells.h
r15997 r21048 12 12 # include <glob.h> 13 13 14 enum {SQUARES, TRIANGLES}; 14 enum {SQUARES, TRIANGLES, LOCAL}; 15 enum {TETRAHEDRON, CUBE, OCTOHEDRON, DODECAHEDRON, ICOSAHEDRON}; 15 16 16 17 typedef struct { … … 60 61 int VERBOSE; 61 62 int MODE; 63 int SOLID; 62 64 int FIX_NS; 63 65 int NMAX; … … 65 67 double SCALE; 66 68 double PADDING; 69 int LEVEL; 70 71 double CENTER_RA, CENTER_DEC; 72 double RANGE_RA, RANGE_DEC; 67 73 68 74 double EULER_A; 69 75 double EULER_B; 70 76 71 void SetProtect PROTO((int mode));72 int SetSignals PROTO(());73 int Shutdown PROTO((char *message, ...); )74 void TrapSignal PROTO((int sig));77 void SetProtect PROTO((int mode)); 78 int SetSignals PROTO(()); 79 int Shutdown PROTO((char *message, ...); ) 80 void TrapSignal PROTO((int sig)); 75 81 76 int args_skycells PROTO((int argc, char **argv)); 77 int ConfigInit_skycells PROTO((int *argc, char **argv)); 78 int sky_tessalation PROTO((FITS_DB *db, int level, int Nmax, int mode, double scale)); 79 int sky_tessalation_init PROTO((double scale)); 80 int sky_tessalation_triangles PROTO((FITS_DB *db, int level, int Nmax)); 81 int sky_tessalation_squares PROTO((FITS_DB *db, int level, int Nmax)); 82 int sky_triangle_to_image PROTO((Image *image, SkyTriangle *triangle)); 83 int sky_triangle_to_rectangle PROTO((SkyRectangle *image, SkyTriangle *triangle)); 84 int sky_subdivide_image PROTO((Image *output, SkyRectangle *input, int Nx, int Ny)); 85 int sky_triangle_coords PROTO((SkyTriangle *triangle)); 86 SkyTriangle *sky_divide_triangles PROTO((SkyTriangle *in, int *ntriangles)); 87 SkyTriangle *sky_base_triangles PROTO((int *ntriangles)); 88 int sky_base_rotation PROTO((SkyTriangle *base, int Nbase)); 89 Point sky_divide_edge PROTO((Point v1, Point v2)); 82 int args_skycells PROTO((int argc, char **argv)); 83 int ConfigInit_skycells PROTO((int *argc, char **argv)); 84 int sky_tessellation PROTO((FITS_DB *db, int level, int Nmax, int mode, double scale)); 85 int sky_tessellation_init PROTO((double scale)); 86 int sky_tessellation_local PROTO((FITS_DB *db, int level, int Nmax)); 87 int sky_tessellation_triangles PROTO((FITS_DB *db, int level, int Nmax)); 88 int sky_tessellation_squares PROTO((FITS_DB *db, int level, int Nmax)); 89 int sky_triangle_to_image PROTO((Image *image, SkyTriangle *triangle)); 90 int sky_triangle_to_rectangle PROTO((SkyRectangle *image, SkyTriangle *triangle)); 91 int sky_rectangle_local PROTO((SkyRectangle *rectangle)); 92 int sky_subdivide_image PROTO((Image *output, SkyRectangle *input, int Nx, int Ny)); 93 int sky_triangle_coords PROTO((SkyTriangle *triangle)); 94 SkyTriangle *sky_divide_triangles PROTO((SkyTriangle *in, int *ntriangles)); 95 SkyTriangle *sky_base_triangles PROTO((int *ntriangles)); 96 SkyTriangle *sky_base_triangles_icosahedron PROTO((int *ntriangles)); 97 int sky_base_rotation PROTO((SkyTriangle *base, int Nbase)); 98 Point sky_divide_edge PROTO((Point v1, Point v2)); 90 99 91 100 // XXX migrate to libdvo eventually -
trunk/Ohana/src/addstar/src/args_skycells.c
r15997 r21048 6 6 int N; 7 7 char *ptr; 8 9 if (argc == 1) goto escape; 8 10 9 11 /* check for help request */ … … 22 24 /* what type of output files? */ 23 25 MODE = SQUARES; 24 if ((N = get_argument (argc, argv, "-triangles"))) { 25 MODE = TRIANGLES; 26 if ((N = get_argument (argc, argv, "-mode"))) { 26 27 remove_argument (N, &argc, argv); 28 if (!strcasecmp (argv[N], "squares")) { 29 MODE = SQUARES; 30 } 31 if (!strcasecmp (argv[N], "triangles")) { 32 MODE = SQUARES; 33 } 34 if (!strcasecmp (argv[N], "local")) { 35 MODE = LOCAL; 36 } 37 remove_argument (N, &argc, argv); 38 } 39 40 /* what base solid? */ 41 SOLID = ICOSAHEDRON; 42 if ((N = get_argument (argc, argv, "-solid"))) { 43 remove_argument (N, &argc, argv); 44 if (!strncasecmp (argv[N], "TETRAHEDRON", MIN(4, strlen(argv[N])))) { 45 SOLID = TETRAHEDRON; 46 } 47 if (!strncasecmp (argv[N], "CUBE", MIN(4, strlen(argv[N])))) { 48 SOLID = CUBE; 49 } 50 if (!strncasecmp (argv[N], "OCTOHEDRON", MIN(4, strlen(argv[N])))) { 51 SOLID = OCTOHEDRON; 52 } 53 if (!strncasecmp (argv[N], "DODECAHEDRON", MIN(4, strlen(argv[N])))) { 54 SOLID = DODECAHEDRON; 55 } 56 if (!strncasecmp (argv[N], "ICOSAHEDRON", MIN(4, strlen(argv[N])))) { 57 SOLID = ICOSAHEDRON; 58 } 59 remove_argument (N, &argc, argv); 60 } 61 62 if (MODE == LOCAL) { 63 // for local mode, need to define the center and range 64 if ((N = get_argument (argc, argv, "-center"))) { 65 remove_argument (N, &argc, argv); 66 CENTER_RA = atof (argv[N]); 67 remove_argument (N, &argc, argv); 68 CENTER_DEC = atof (argv[N]); 69 remove_argument (N, &argc, argv); 70 } else { 71 fprintf (stderr, "missing -center RA DEC for LOCAL mode\n"); 72 help (); 73 } 74 // for local mode, need to define the center and range 75 if ((N = get_argument (argc, argv, "-size"))) { 76 remove_argument (N, &argc, argv); 77 RANGE_RA = atof (argv[N]); 78 remove_argument (N, &argc, argv); 79 RANGE_DEC = atof (argv[N]); 80 remove_argument (N, &argc, argv); 81 } else { 82 fprintf (stderr, "missing -size dRA dDEC for LOCAL mode\n"); 83 help (); 84 } 27 85 } 28 86 … … 81 139 } 82 140 83 if (argc == 2) { 84 strtol (argv[1], &ptr, 10); 85 if (*ptr == 0) return (TRUE); 141 LEVEL = 8; 142 if ((MODE != LOCAL) && (N = get_argument (argc, argv, "-level"))) { 143 remove_argument (N, &argc, argv); 144 LEVEL = strtol (argv[N], &ptr, 10); 145 remove_argument (N, &argc, argv); 146 if ((*ptr != 0) || (LEVEL < 0)) { 147 fprintf (stderr, "-level requires an integer (>= 0) argument\n"); 148 help (); 149 } 86 150 } 87 151 88 fprintf (stderr, "USAGE: skycells (level) [-scale arcsec/pix] [-nx (Nx cells)] [-ny (Ny cells)]\n"); 152 if (argc != 1) goto escape; 153 154 return (TRUE); 155 156 escape: 157 fprintf (stderr, "USAGE: skycells [-mode mode] [-level level] [-scale arcsec/pix] [-nx (Nx cells)] [-ny (Ny cells)]\n"); 89 158 fprintf (stderr, " [-h for details and other options]\n"); 90 159 exit (2); … … 96 165 fprintf (stderr, " skycells\n\n"); 97 166 98 fprintf (stderr, " -v : verbose mode\n"); 167 fprintf (stderr, " -mode (name) : define the type of tessellation. available options are:\n"); 168 fprintf (stderr, " SQUARE : generate rectangular skycells using icosahedron base solid (default)\n"); 169 fprintf (stderr, " TRIANGLE : generate triangular skycells using icosahedron base solid\n"); 170 fprintf (stderr, " LOCAL : generate a local tessellation around a spot on the sky\n"); 171 fprintf (stderr, " (Note that this tessellation does not cover the full sky)\n"); 172 fprintf (stderr, " -solid (name) : specify the base solid\n"); 173 fprintf (stderr, " value may be one of: TETRAHEDRON, CUBE, OCTOHEDRON, DODECAHEDRON, ICOSAHEDRON\n"); 174 fprintf (stderr, " for convenience, only the first 4 characters are required\n"); 175 fprintf (stderr, " -v : verbose mode\n"); 99 176 fprintf (stderr, " -triangles : save base triangles instead of skycells\n"); 100 177 fprintf (stderr, " -fix-ns : orient skycells with y-axis aligned with Dec\n"); 101 fprintf (stderr, " -scale : set pixel scale (default 1.0 arcsec / pixel)\n"); 102 fprintf (stderr, " -padding : pad skycells by this fraction in each dimension\n"); 103 fprintf (stderr, " -nmax : only keep nmax skycells in memory\n"); 104 fprintf (stderr, " -nx : subdivide skycell projection in x\n"); 105 fprintf (stderr, " -ny : subdivide skycell projection in y\n"); 106 fprintf (stderr, " -help : this list\n"); 107 fprintf (stderr, " -h : this list\n\n"); 178 fprintf (stderr, " -scale (scale) : set pixel scale in arcsec (default 1.0 arcsec / pixel)\n"); 179 fprintf (stderr, " -euler (A) (B) : define Euler A and B rotation angles (degrees)\n"); 180 fprintf (stderr, " -padding (fraction) : pad skycells by this fraction in each dimension\n"); 181 fprintf (stderr, " -nmax Nmax : only keep Nmax skycells in memory\n"); 182 fprintf (stderr, " -nx Nx : subdivide skycell projection in x by Nx\n"); 183 fprintf (stderr, " -ny Ny : subdivide skycell projection in y by Ny\n"); 184 fprintf (stderr, " -help : this list\n"); 185 fprintf (stderr, " -h : this list\n\n"); 108 186 exit (2); 109 187 } -
trunk/Ohana/src/addstar/src/sky_tessalation.c
r19259 r21048 7 7 static Coords *refcoords = NULL; 8 8 9 int sky_tess alation (FITS_DB *db, int level, int Nmax, int mode, double scale) {10 11 sky_tess alation_init (scale);9 int sky_tessellation (FITS_DB *db, int level, int Nmax, int mode, double scale) { 10 11 sky_tessellation_init (scale); 12 12 13 13 if (mode == SQUARES) { 14 sky_tess alation_squares (db, level, Nmax);14 sky_tessellation_squares (db, level, Nmax); 15 15 return TRUE; 16 16 } 17 17 18 18 if (mode == TRIANGLES) { 19 sky_tess alation_triangles (db, level, Nmax);19 sky_tessellation_triangles (db, level, Nmax); 20 20 return TRUE; 21 21 } 22 22 23 if (mode == LOCAL) { 24 sky_tessellation_local (db, level, Nmax); 25 return TRUE; 26 } 27 23 28 return FALSE; 24 29 } 25 30 26 int sky_tess alation_triangles (FITS_DB *db, int level, int Nmax) {31 int sky_tessellation_triangles (FITS_DB *db, int level, int Nmax) { 27 32 28 33 int i, j, Ndigit, Ntriangles, Nbase, Ntotal, Ltop, Nout, Nimages; … … 96 101 } 97 102 98 int sky_tess alation_squares (FITS_DB *db, int level, int Nmax) {103 int sky_tessellation_squares (FITS_DB *db, int level, int Nmax) { 99 104 100 105 int i, j, Nname, Ndigit, Ntriangles, Nbase, Nimage, Ntotal, Ntop, Ltop, Nsubset, Nx, Ny; … … 186 191 free (tri); 187 192 } 193 return (TRUE); 194 } 195 196 // use CENTER_RA and CENTER_DEC as the starting point. generate a single projection 197 // of size RANGE_RA and RANGE_DEC, and subdivide as specified. This pseudo-tessellation may be used 198 // for local projects such as the PS1 Medium Deep fields 199 int sky_tessellation_local (FITS_DB *db, int level, int Nmax) { 200 201 int Nimage; 202 SkyRectangle rectangle; 203 Image *image; 204 205 // this tessellation consists of a single projection center with Nx * Ny cells 206 sky_rectangle_local (&rectangle); 207 strcpy (rectangle.name, "skycell"); 208 209 // subdivide each image (Nx x Ny subcells) 210 Nimage = NX_SUB*NY_SUB; 211 ALLOCATE (image, Image, Nimage); 212 213 // convert the SkyRectangle to Images for output 214 sky_subdivide_image (image, &rectangle, NX_SUB, NY_SUB); 215 216 /* add the new images and save */ 217 dvo_image_addrows (db, image, Nimage); 218 SetProtect (TRUE); 219 dvo_image_update (db, VERBOSE); 220 SetProtect (FALSE); 221 dvo_image_clear_vtable (db); 222 223 free (image); 188 224 return (TRUE); 189 225 } … … 402 438 } 403 439 440 // define the parameters of a single sky projection center 441 int sky_rectangle_local (SkyRectangle *rectangle) { 442 443 int NX, NY; 444 float angle; 445 446 memset (rectangle, 0, sizeof(SkyRectangle)); 447 rectangle[0].coords.crval1 = CENTER_RA; 448 rectangle[0].coords.crval2 = CENTER_DEC; 449 450 // we will add this as an option later 451 angle = 0.0; 452 if (FIX_NS) { 453 rectangle[0].coords.pc1_1 = +1.0; 454 rectangle[0].coords.pc1_2 = +0.0; 455 rectangle[0].coords.pc2_1 = -0.0; 456 rectangle[0].coords.pc2_2 = +1.0; 457 } else { 458 rectangle[0].coords.pc1_1 = +cos(angle); 459 rectangle[0].coords.pc1_2 = +sin(angle); 460 rectangle[0].coords.pc2_1 = -sin(angle); 461 rectangle[0].coords.pc2_2 = +cos(angle); 462 } 463 464 // range values are in projected degrees 465 NX = RANGE_RA * 3600.0 / SCALE; 466 NY = RANGE_DEC * 3600.0 / SCALE; 467 468 // crpix1,crpix2 is the projection center 469 rectangle[0].coords.crpix1 = 0.5*NX; 470 rectangle[0].coords.crpix2 = 0.5*NY; 471 472 rectangle[0].coords.cdelt1 = SCALE / 3600.0; 473 rectangle[0].coords.cdelt2 = SCALE / 3600.0; 474 475 strcpy (rectangle[0].coords.ctype, "DEC--TAN"); 476 477 rectangle[0].NX = NX; 478 rectangle[0].NY = NY; 479 rectangle[0].code = 1; // this needs to be set more sensibly 480 481 return (TRUE); 482 } 483 404 484 // an allocated image set is supplied, we fill in the values 405 485 int sky_subdivide_image (Image *output, SkyRectangle *input, int Nx, int Ny) { … … 517 597 } 518 598 599 SkyTriangle *sky_base_triangles (int *ntriangles) { 600 601 SkyTriangle *tri; 602 603 switch (SOLID) { 604 case TETRAHEDRON: 605 fprintf (stderr, "TETRAHEDRON is not yet defined\n"); 606 exit (2); 607 break; 608 case CUBE: 609 fprintf (stderr, "CUBE is not yet defined\n"); 610 exit (2); 611 break; 612 case OCTOHEDRON: 613 fprintf (stderr, "OCTOHEDRON is not yet defined\n"); 614 exit (2); 615 break; 616 case DODECAHEDRON: 617 fprintf (stderr, "DODECAHEDRON is not yet defined\n"); 618 exit (2); 619 break; 620 case ICOSAHEDRON: 621 tri = sky_base_triangles_icosahedron (ntriangles); 622 } 623 624 return tri; 625 626 } 627 519 628 # define THETA RAD_DEG*26.565 520 629 # define D_PSI RAD_DEG*360.0/5.0 521 630 522 SkyTriangle *sky_base_triangles (int *ntriangles) {631 SkyTriangle *sky_base_triangles_icosahedron (int *ntriangles) { 523 632 524 633 int i; … … 642 751 } 643 752 644 int sky_tess alation_init (double scale) {753 int sky_tessellation_init (double scale) { 645 754 646 755 ALLOCATE (refcoords, Coords, 1); -
trunk/Ohana/src/addstar/src/skycells.c
r16061 r21048 3 3 int main (int argc, char **argv) { 4 4 5 int status , level;5 int status; 6 6 FITS_DB db; 7 7 … … 9 9 ConfigInit_skycells (&argc, argv); 10 10 args_skycells (argc, argv); 11 level = atoi (argv[1]); 12 11 13 12 /*** update the image table ***/ 14 13 /* setup image table format and lock */ … … 28 27 } 29 28 30 // we have to put the database update calls deep down in the sky_tess alation code so we29 // we have to put the database update calls deep down in the sky_tessellation code so we 31 30 // can write out the skycells in limited-sized chunks. 32 sky_tess alation (&db, level, NMAX, MODE, SCALE);31 sky_tessellation (&db, LEVEL, NMAX, MODE, SCALE); 33 32 34 33 dvo_image_unlock (&db);
Note:
See TracChangeset
for help on using the changeset viewer.
