IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23138


Ignore:
Timestamp:
Mar 3, 2009, 3:52:18 PM (17 years ago)
Author:
eugene
Message:

adding the rings mode (not quite done)

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

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/src/args_skycells.c

    r21048 r23138  
    3535      MODE = LOCAL;
    3636    }
     37    if (!strcasecmp (argv[N], "rings")) {
     38      MODE = RINGS;
     39    }
    3740    remove_argument (N, &argc, argv);
    3841  }
     
    140143
    141144  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");
     145  if ((MODE == SQUARES) || (MODE == TRIANGLES)) {
     146    if ((N = get_argument (argc, argv, "-level"))) {
     147      remove_argument (N, &argc, argv);
     148      LEVEL = strtol (argv[N], &ptr, 10);
     149      remove_argument (N, &argc, argv);
     150      if ((*ptr != 0) || (LEVEL < 0)) {
     151        fprintf (stderr, "-level requires an integer (>= 0) argument\n");
     152        help ();
     153      } 
     154    }
     155  }
     156
     157  CELLSIZE = 4.0;
     158  if ((MODE == RINGS) && (N = get_argument (argc, argv, "-cellsize"))) {
     159    remove_argument (N, &argc, argv);
     160    CELLSIZE = strtod (argv[N], &ptr);
     161    if ((*ptr != 0) || (CELLSIZE < 0.0)) {
     162      fprintf (stderr, "-level requires a floating-point argument\n");
    148163      help ();
    149164    } 
     165    remove_argument (N, &argc, argv);
    150166  }
    151167
  • trunk/Ohana/src/addstar/src/sky_tessalation.c

    r21508 r23138  
    1111  sky_tessellation_init (scale);
    1212
    13   if (mode == SQUARES) {
    14     sky_tessellation_squares (db, level, Nmax);
    15     return TRUE;
    16   }
    17 
    18   if (mode == TRIANGLES) {
    19     sky_tessellation_triangles (db, level, Nmax);
    20     return TRUE;
    21   }
    22 
    23   if (mode == LOCAL) {
    24     sky_tessellation_local (db, level, Nmax);
    25     return TRUE;
     13  switch (mode) {
     14    case SQUARES:
     15      sky_tessellation_squares (db, level, Nmax);
     16      return TRUE;
     17    case TRIANGLES:
     18      sky_tessellation_triangles (db, level, Nmax);
     19      return TRUE;
     20    case LOCAL:
     21      sky_tessellation_local (db, level, Nmax);
     22      return TRUE;
     23    case RINGS:
     24      sky_tessellation_rings (db, level, Nmax);
     25      return TRUE;
     26    default:
     27      break;
    2628  }
    2729
     
    222224
    223225  free (image);
     226  return (TRUE);
     227}
     228
     229// the RINGS tessellation uses the declination zones proposed by Tamas Budavari
     230// we generate projects on uniform rings of constant dec height
     231int sky_tessellation_rings (FITS_DB *db, int level, int Nmax) {
     232
     233  int j, nDEC, Nimage, Nring;
     234  float dec, dDEC;
     235  SkyRectangle *ring;
     236  Image *image;
     237
     238  // The tessellation has one input parameter: the approximate cell size.  Starting with
     239  // the cell size, determine the optimal projection cell height (dDEC) that results in an
     240  // integer number of dec zones between -90 and +90
     241
     242  nDEC = 180.0 / CELLSIZE;
     243  dDEC = 180.0 / nDEC;
     244
     245  // generate the a collection of rectangles for each ring
     246  for (dec = -90.0 + 0.5*dDEC; dec < +90.0; dec += dDEC) {
     247
     248    ring = sky_rectangle_ring (dec, dDEC, &Nring);
     249
     250    // subdivide each image (Nx x Ny subcells)
     251    Nimage = NX_SUB*NY_SUB*Nring;
     252    ALLOCATE (image, Image, Nimage);
     253    for (j = 0; j < Nring; j++) {
     254      // convert the SkyRectangles to Images for output
     255      sky_subdivide_image (&image[j*NX_SUB*NY_SUB], &ring[j], NX_SUB, NY_SUB);
     256    }
     257
     258    /* add the new images and save */
     259    dvo_image_addrows (db, image, Nimage);
     260    SetProtect (TRUE);
     261    dvo_image_update (db, VERBOSE);
     262    SetProtect (FALSE);
     263    dvo_image_clear_vtable (db);
     264   
     265    free (ring);
     266    free (image);
     267  }   
    224268  return (TRUE);
    225269}
     
    480524
    481525  return (TRUE);
     526}
     527
     528// define the parameters of a single sky projection center
     529SkyRectangle *sky_rectangle_ring (float dec, float dDEC, int *nring) {
     530
     531  int i, nRA, NX, NY;
     532  float dRA, decLower;
     533  SkyRectangle *ring;
     534
     535  // 'dec' is a guess at the center of the cell; in fact, we need to choose decLower and
     536  // decUpper to ensure complete overlap of the cells
     537
     538  // we can determine the 'lower' bound (bound closest to the equator):
     539  decLower = (dec > 0.0) ? dec - 0.5*dDEC : dec + 0.5*dDEC;
     540
     541  // Subdivide the 'lower' bound into an integer number of segments:
     542  nRA = cos(dec*RAD_DEG) * 360.0 / CELLSIZE; // CELLSIZE is a projection size
     543  dRA = 360.0 / nRA;                         // dRA is a size in RA degrees
     544
     545  // I think we need to return the value of dec for the next ring, but I am not sure...
     546
     547  ALLOCATE (ring, SkyRectangle, nRA);
     548
     549  for (i = 0; i < nRA; i++) {
     550    memset (&ring[i], 0, sizeof(SkyRectangle));
     551    memset (&ring[i].coords, 0, sizeof(Coords));
     552    ring[i].coords.crval1 = i*dRA;
     553    ring[i].coords.crval2 = dec;
     554
     555    ring[i].coords.pc1_1 = +1.0;
     556    ring[i].coords.pc1_2 = +0.0;
     557    ring[i].coords.pc2_1 = -0.0;
     558    ring[i].coords.pc2_2 = +1.0;
     559 
     560    // range values are in projected degrees
     561    NX = cos(dec*RAD_DEG) * dRA  * 3600.0 / SCALE;
     562    NY =                    dDEC * 3600.0 / SCALE;
     563
     564    // crpix1,crpix2 is the projection center
     565    ring[i].coords.crpix1 = 0.5*NX;
     566    ring[i].coords.crpix2 = 0.5*NY;
     567
     568    ring[i].coords.cdelt1 = SCALE / 3600.0;
     569    ring[i].coords.cdelt2 = SCALE / 3600.0;
     570
     571    strcpy (ring[i].coords.ctype, "DEC--TAN");
     572
     573    ring[i].NX = NX;
     574    ring[i].NY = NY;
     575    ring[i].photcode = 1; // this needs to be set more sensibly
     576
     577
     578    fprintf (stderr, "%f %f  : %f %f\n",
     579             ring[i].coords.crval1, ring[i].coords.crval2,
     580             ring[i].coords.crpix1, ring[i].coords.crpix2);
     581  }
     582
     583  *nring = nRA;
     584  return (ring);
    482585}
    483586
Note: See TracChangeset for help on using the changeset viewer.