IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40528


Ignore:
Timestamp:
Sep 25, 2018, 10:21:11 AM (8 years ago)
Author:
eugene
Message:

added CFIS tessellation to skycells

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

Legend:

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

    r34260 r40528  
    1212# include <glob.h>
    1313
    14 enum {SQUARES, TRIANGLES, LOCAL, RINGS, TAMAS};
     14enum {SQUARES, TRIANGLES, LOCAL, RINGS, TAMAS, CFIS};
    1515enum {TETRAHEDRON, CUBE, OCTOHEDRON, DODECAHEDRON, ICOSAHEDRON};
    1616
     
    9696int          sky_tessellation_rings         PROTO((FITS_DB *db, int level, int Nmax));
    9797int          sky_tessellation_tamas         PROTO((FITS_DB *db, int level, int Nmax));
     98int          sky_tessellation_cfis          PROTO((FITS_DB *db, int level, int Nmax));
    9899
    99100int          sky_triangle_to_image          PROTO((Image *image, SkyTriangle *triangle));
     
    106107SkyRectangle *sky_rectangle_ring            PROTO((float dec, float dDEC, int *nring, char *format));
    107108SkyRectangle *sky_rectangle_tamas           PROTO((double *Dec, double dm, double halfa, double halftheta, int *nring, char *format));
     109SkyRectangle *sky_rectangle_cfis            PROTO((double dec, int *nring, char *format));
    108110
    109111SkyTriangle *sky_divide_triangles           PROTO((SkyTriangle *in, int *ntriangles));
  • trunk/Ohana/src/addstar/src/args_skycells.c

    r34260 r40528  
    4040    if (!strcasecmp (argv[N], "tamas")) {
    4141      MODE = TAMAS;
     42    }
     43    if (!strcasecmp (argv[N], "cfis")) {
     44      MODE = CFIS;
    4245    }
    4346    remove_argument (N, &argc, argv);
     
    115118  /* pixel scale (arcsec/pixel) */
    116119  SCALE = 1.0;
     120  if (MODE == CFIS) {
     121    SCALE = 0.185768447409; // default CFIS value
     122  }
    117123  if ((N = get_argument (argc, argv, "-scale"))) {
    118124    remove_argument (N, &argc, argv);
     
    174180
    175181  CELLSIZE = 4.0;
    176   if ((MODE == RINGS) && (N = get_argument (argc, argv, "-cellsize"))) {
     182  if (MODE == TAMAS) CELLSIZE = 3.955;
     183  if (MODE == CFIS) CELLSIZE = 0.5;
     184
     185  int checkCellsize = (MODE == RINGS) || (MODE == TAMAS) || (MODE == CFIS);
     186
     187  if (checkCellsize && (N = get_argument (argc, argv, "-cellsize"))) {
    177188    remove_argument (N, &argc, argv);
    178189    CELLSIZE = strtod (argv[N], &ptr);
     
    183194    remove_argument (N, &argc, argv);
    184195  }
    185   if (MODE == TAMAS) {
    186     CELLSIZE = 3.955;
    187     if ((N = get_argument (argc, argv, "-cellsize"))) {
    188       remove_argument (N, &argc, argv);
    189       CELLSIZE = strtod (argv[N], &ptr);
    190       if ((*ptr != 0) || (CELLSIZE < 0.0)) {
    191         fprintf (stderr, "-cellsize requires a floating-point argument\n");
    192         help ();
    193       } 
    194       remove_argument (N, &argc, argv);
    195     }
    196   }
    197196
    198197  OVERLAP_RA = 0;
     
    230229  fprintf (stderr, "     TRIANGLE                 : generate triangular skycells using icosahedron base solid\n");
    231230  fprintf (stderr, "     RINGS                    : generate rectangular skycells using declination strips\n");
     231  fprintf (stderr, "     CFIS                     : generate rectangular skycells using CFIS declination strips\n");
    232232  fprintf (stderr, "     LOCAL                    : generate a local tessellation around a spot on the sky\n");
    233233  fprintf (stderr, "                                 (Note that this tessellation does not cover the full sky)\n");
  • trunk/Ohana/src/addstar/src/sky_tessalation.c

    r40498 r40528  
    2626      sky_tessellation_tamas (db, level, Nmax);
    2727      return TRUE;
     28    case CFIS:
     29      sky_tessellation_cfis (db, level, Nmax);
     30      return TRUE;
    2831    default:
    2932      break;
     
    235238
    236239  free (image);
     240  return (TRUE);
     241}
     242
     243// the CADC / CFIS tessellation uses the constant DEC offsets and simple cos(DEC)-scaled
     244// RA offsets.  The skycell names are defined to match the RA,DEC sequence
     245int sky_tessellation_cfis (FITS_DB *db, int level, int Nmax) {
     246  OHANA_UNUSED_PARAM(level);
     247  OHANA_UNUSED_PARAM(Nmax);
     248
     249  char format[32];
     250
     251  int Ndec = 0;
     252
     253  // generate the a collection of rectangles for each ring
     254  for (double dec = -90.0; dec < +90.01; dec += CELLSIZE, Ndec ++) {
     255
     256    snprintf (format, 32, "skycell.%%03d.%03d", Ndec);
     257
     258    int Nring;
     259    SkyRectangle *ring = sky_rectangle_cfis (dec, &Nring, format);
     260    if (!ring) continue;
     261
     262    // nominal CFIS uses a single skycell per projection center
     263
     264    // subdivide each image (Nx x Ny subcells)
     265    int Nimage = NX_SUB*NY_SUB*Nring;
     266    ALLOCATE_PTR (image, Image, Nimage);
     267    for (int j = 0; j < Nring; j++) {
     268      // convert the SkyRectangles to Images for output
     269      sky_subdivide_image (&image[j*NX_SUB*NY_SUB], &ring[j], NX_SUB, NY_SUB);
     270      // printf("%s %8.2f %8.2f\n", ring[j].name, ring[j].coords.crval1, ring[j].coords.crval2);
     271    }
     272
     273    /* add the new images and save */
     274    dvo_image_addrows (db, image, Nimage);
     275    SetProtect (TRUE);
     276    dvo_image_update (db, VERBOSE);
     277    SetProtect (FALSE);
     278    dvo_image_clear_vtable (db);
     279   
     280    free (ring);
     281    free (image);
     282  }   
    237283  return (TRUE);
    238284}
     
    623669
    624670  return (TRUE);
     671}
     672
     673// define the parameters of a projection centers for this DEC band
     674// dec : ~ center of band in Dec
     675// dDEC : approximate height
     676// nring : number of cells generated for this ring
     677// format : guide to generate the filenames (c-type string format)
     678
     679// for skycell xxx.yyy, Dcenter = (yyy / 2 - 900), Rcenter = (xxx / 2 / dcos(Dcenter))
     680
     681SkyRectangle *sky_rectangle_cfis (double dec, int *nring, char *format) {
     682
     683  int i;
     684
     685  // Subdivide the DEC center line into an integer number of segments:
     686  float dRA = CELLSIZE / cos(RAD_DEG*dec); // dRA is a size in RA degrees == \alpha_n
     687  int nRA = (360.0 + 2*CELLSIZE) / dRA;      // CELLSIZE is projection center spacing (DEC-direction)
     688
     689  ALLOCATE_PTR (ring, SkyRectangle, nRA);
     690
     691  for (i = 0; i < nRA; i++) {
     692    memset (&ring[i], 0, sizeof(SkyRectangle));
     693
     694    InitCoords (&ring[i].coords, "DEC--TAN");
     695    ring[i].coords.crval1 = i*dRA;
     696    ring[i].coords.crval2 = dec;
     697
     698    ring[i].coords.pc1_1 = +1.0 * X_PARITY;
     699 
     700    // we need to make this a user-defined option
     701    // for the default CFIS cells, PADDING is 0 (hard-wired into NX,NY = 10000)
     702    // ring[i].NX = NX*(1.0 + PADDING);
     703    // ring[i].NY = NY*(1.0 + PADDING);
     704    ring[i].NX = 10000;
     705    ring[i].NY = 10000;
     706    ring[i].photcode = 1; // this needs to be set more sensibly
     707
     708    // crpix1,crpix2 is the projection center
     709    ring[i].coords.crpix1 = 0.5*ring[i].NX;
     710    ring[i].coords.crpix2 = 0.5*ring[i].NY;
     711
     712    // user-supplied pixel scale
     713    ring[i].coords.cdelt1 = SCALE / 3600.0;
     714    ring[i].coords.cdelt2 = SCALE / 3600.0;
     715
     716    // CFIS uses names with centers based on ra,dec
     717    // format = skycell.%03d.%03d
     718    snprintf (ring[i].name, DVO_IMAGE_NAME_LEN, format, i);
     719  }
     720
     721  *nring = nRA;
     722  return (ring);
    625723}
    626724
Note: See TracChangeset for help on using the changeset viewer.