IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21048 for trunk/Ohana


Ignore:
Timestamp:
Dec 21, 2008, 11:02:16 AM (18 years ago)
Author:
eugene
Message:

updates to skycell: require -level, define -mode, define local mode for PR pics

Location:
trunk/Ohana/src/addstar
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/include/skycells.h

    r15997 r21048  
    1212# include <glob.h>
    1313
    14 enum {SQUARES, TRIANGLES};
     14enum {SQUARES, TRIANGLES, LOCAL};
     15enum {TETRAHEDRON, CUBE, OCTOHEDRON, DODECAHEDRON, ICOSAHEDRON};
    1516
    1617typedef struct {
     
    6061int    VERBOSE;
    6162int    MODE;
     63int    SOLID;
    6264int    FIX_NS;
    6365int    NMAX;
     
    6567double SCALE;
    6668double PADDING;
     69int    LEVEL;
     70
     71double CENTER_RA, CENTER_DEC;
     72double RANGE_RA,  RANGE_DEC;
    6773
    6874double EULER_A;
    6975double EULER_B;
    7076
    71 void         SetProtect                PROTO((int mode));
    72 int          SetSignals                PROTO(());
    73 int          Shutdown                  PROTO((char *message, ...); )
    74 void         TrapSignal                PROTO((int sig));
     77void         SetProtect                     PROTO((int mode));
     78int          SetSignals                     PROTO(());
     79int          Shutdown                       PROTO((char *message, ...); )
     80void         TrapSignal                     PROTO((int sig));
    7581
    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));
     82int          args_skycells                  PROTO((int argc, char **argv));
     83int          ConfigInit_skycells            PROTO((int *argc, char **argv));
     84int          sky_tessellation               PROTO((FITS_DB *db, int level, int Nmax, int mode, double scale));
     85int          sky_tessellation_init          PROTO((double scale));
     86int          sky_tessellation_local         PROTO((FITS_DB *db, int level, int Nmax));
     87int          sky_tessellation_triangles     PROTO((FITS_DB *db, int level, int Nmax));
     88int          sky_tessellation_squares       PROTO((FITS_DB *db, int level, int Nmax));
     89int          sky_triangle_to_image          PROTO((Image *image, SkyTriangle *triangle));
     90int          sky_triangle_to_rectangle      PROTO((SkyRectangle *image, SkyTriangle *triangle));
     91int          sky_rectangle_local            PROTO((SkyRectangle *rectangle));
     92int          sky_subdivide_image            PROTO((Image *output, SkyRectangle *input, int Nx, int Ny));
     93int          sky_triangle_coords            PROTO((SkyTriangle *triangle));
     94SkyTriangle *sky_divide_triangles           PROTO((SkyTriangle *in, int *ntriangles));
     95SkyTriangle *sky_base_triangles             PROTO((int *ntriangles));
     96SkyTriangle *sky_base_triangles_icosahedron PROTO((int *ntriangles));
     97int          sky_base_rotation              PROTO((SkyTriangle *base, int Nbase));
     98Point        sky_divide_edge                PROTO((Point v1, Point v2));
    9099
    91100// XXX migrate to libdvo eventually
  • trunk/Ohana/src/addstar/src/args_skycells.c

    r15997 r21048  
    66  int N;
    77  char *ptr;
     8
     9  if (argc == 1) goto escape;
    810
    911  /* check for help request */
     
    2224  /* what type of output files? */
    2325  MODE = SQUARES;
    24   if ((N = get_argument (argc, argv, "-triangles"))) {
    25     MODE = TRIANGLES;
     26  if ((N = get_argument (argc, argv, "-mode"))) {
    2627    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    }
    2785  }
    2886
     
    81139  }
    82140
    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    } 
    86150  }
    87151
    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
     156escape:
     157  fprintf (stderr, "USAGE: skycells [-mode mode] [-level level] [-scale arcsec/pix] [-nx (Nx cells)] [-ny (Ny cells)]\n");
    89158  fprintf (stderr, "  [-h for details and other options]\n");
    90159  exit (2);
     
    96165  fprintf (stderr, "  skycells\n\n");
    97166
    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");
    99176  fprintf (stderr, "  -triangles                  : save base triangles instead of skycells\n");
    100177  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");
    108186  exit (2);
    109187}
  • trunk/Ohana/src/addstar/src/sky_tessalation.c

    r19259 r21048  
    77static Coords *refcoords = NULL;
    88
    9 int sky_tessalation (FITS_DB *db, int level, int Nmax, int mode, double scale) {
    10 
    11   sky_tessalation_init (scale);
     9int sky_tessellation (FITS_DB *db, int level, int Nmax, int mode, double scale) {
     10
     11  sky_tessellation_init (scale);
    1212
    1313  if (mode == SQUARES) {
    14     sky_tessalation_squares (db, level, Nmax);
     14    sky_tessellation_squares (db, level, Nmax);
    1515    return TRUE;
    1616  }
    1717
    1818  if (mode == TRIANGLES) {
    19     sky_tessalation_triangles (db, level, Nmax);
     19    sky_tessellation_triangles (db, level, Nmax);
    2020    return TRUE;
    2121  }
    2222
     23  if (mode == LOCAL) {
     24    sky_tessellation_local (db, level, Nmax);
     25    return TRUE;
     26  }
     27
    2328  return FALSE;
    2429}
    2530
    26 int sky_tessalation_triangles (FITS_DB *db, int level, int Nmax) {
     31int sky_tessellation_triangles (FITS_DB *db, int level, int Nmax) {
    2732
    2833  int i, j, Ndigit, Ntriangles, Nbase, Ntotal, Ltop, Nout, Nimages;
     
    96101}
    97102
    98 int sky_tessalation_squares (FITS_DB *db, int level, int Nmax) {
     103int sky_tessellation_squares (FITS_DB *db, int level, int Nmax) {
    99104
    100105  int i, j, Nname, Ndigit, Ntriangles, Nbase, Nimage, Ntotal, Ntop, Ltop, Nsubset, Nx, Ny;
     
    186191    free (tri);
    187192  }
     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
     199int 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);
    188224  return (TRUE);
    189225}
     
    402438}
    403439
     440// define the parameters of a single sky projection center
     441int 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
    404484// an allocated image set is supplied, we fill in the values
    405485int sky_subdivide_image (Image *output, SkyRectangle *input, int Nx, int Ny) {
     
    517597}
    518598
     599SkyTriangle *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
    519628# define THETA RAD_DEG*26.565
    520629# define D_PSI RAD_DEG*360.0/5.0
    521630
    522 SkyTriangle *sky_base_triangles (int *ntriangles) {
     631SkyTriangle *sky_base_triangles_icosahedron (int *ntriangles) {
    523632
    524633  int i;
     
    642751}
    643752
    644 int sky_tessalation_init (double scale) {
     753int sky_tessellation_init (double scale) {
    645754
    646755  ALLOCATE (refcoords, Coords, 1);
  • trunk/Ohana/src/addstar/src/skycells.c

    r16061 r21048  
    33int main (int argc, char **argv) {
    44
    5   int status, level;
     5  int status;
    66  FITS_DB db;
    77
     
    99  ConfigInit_skycells (&argc, argv);
    1010  args_skycells (argc, argv);
    11   level = atoi (argv[1]);
    12  
     11
    1312  /*** update the image table ***/
    1413  /* setup image table format and lock */
     
    2827  }
    2928
    30   // we have to put the database update calls deep down in the sky_tessalation code so we
     29  // we have to put the database update calls deep down in the sky_tessellation code so we
    3130  // can write out the skycells in limited-sized chunks.
    32   sky_tessalation (&db, level, NMAX, MODE, SCALE);
     31  sky_tessellation (&db, LEVEL, NMAX, MODE, SCALE);
    3332
    3433  dvo_image_unlock (&db);
Note: See TracChangeset for help on using the changeset viewer.