IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13186


Ignore:
Timestamp:
May 2, 2007, 7:42:37 PM (19 years ago)
Author:
eugene
Message:

adding Nx,Ny subdivision for the rectangular sky cells

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

Legend:

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

    r13185 r13186  
    5353int    MODE;
    5454int    NMAX;
     55int    NX_SUB, NY_SUB;
    5556double SCALE;
    5657
  • trunk/Ohana/src/addstar/src/args_skycells.c

    r13185 r13186  
    4343  }
    4444
     45  /* max number of skycells kept in memory */
     46  NX_SUB = NY_SUB = 1;
     47  if ((N = get_argument (argc, argv, "-nx"))) {
     48    remove_argument (N, &argc, argv);
     49    NX_SUB = atof (argv[N]);
     50    remove_argument (N, &argc, argv);
     51  }
     52  if ((N = get_argument (argc, argv, "-ny"))) {
     53    remove_argument (N, &argc, argv);
     54    NY_SUB = atof (argv[N]);
     55    remove_argument (N, &argc, argv);
     56  }
     57
    4558  if (argc == 2) {
    4659    strtol (argv[1], &ptr, 10);
     
    4861  }
    4962
    50   fprintf (stderr, "USAGE: skycells (level) [-triangles] [-scale arcsec/pix] [-nmax Max Cells in memory]\n");
     63  fprintf (stderr, "USAGE: skycells (level) [-triangles] [-scale arcsec/pix] [-nmax Max Cells in memory] [-nx (Nx cells)] [-ny (Ny cells)]\n");
    5164  exit (2);
    5265}
  • trunk/Ohana/src/addstar/src/sky_tessalation.c

    r13185 r13186  
    9393int sky_tessalation_squares (FITS_DB *db, int level, int Nmax) {
    9494
    95   int i, j, Ndigit, Ntriangles, Nbase, Ntotal, Ntop, Ltop, Nout;
     95  int i, j, Ndigit, Ntriangles, Nbase, Ntotal, Ntop, Ltop, Nout, Nx, Ny;
    9696  double fLtop;
    9797  SkyTriangle *base, *tri, *new;
     
    9999  char format[16];
    100100
     101  Nx = NX_SUB;
     102  Ny = NY_SUB;
     103
    101104  // generate the initial base set
    102105  base = sky_base_triangles (&Nbase);
     
    108111
    109112  // to what depth do we need to go to have only Nmax foreach subcell?
    110   Ntop = Ntotal / Nmax;
     113  Ntop = Ntotal / (Nmax*Nx*Ny) ;
    111114  if (Ntop > Nbase) {
    112115    fLtop = log10(Ntotal / (double)(Ntop * Nbase)) / log10(4.0);
     
    154157    free (image);
    155158
     159    // subdivide each image (Nx x Ny subcells)
     160    if (Nx*Ny > 1) {
     161      ALLOCATE (image, Image, Nx*Ny*Nout);
     162      for (j = 0; j < Nout; j++) {
     163        sky_subdivide_image (&image[j*Nx*Ny], &out[j], Nx, Ny);
     164      }
     165      free (out);
     166      out = image;
     167      Nout *= Nx*Ny;
     168    }
     169
    156170    /* add the new images and save */
    157171    dvo_image_addrows (db, out, Nout);
     
    229243  image[0].Mxxy = xv[2];  image[0].Myyy = yv[2];
    230244
     245  return (TRUE);
     246}
     247
     248// an allocated image set is supplied, we fill in the values
     249int sky_subdivide_image (Image *output, Image *input, int Nx, int Ny) {
     250
     251  int i, j, N, NX, NY;
     252
     253  NX = input[0].NX/(double)Nx + 0.5;
     254  NY = input[0].NY/(double)Ny + 0.5;
     255
     256  N = 0;
     257  for (j = 0; j < Ny; j++) {
     258    for (i = 0; i < Nx; i++) {
     259
     260      memcpy (&output[N], &input[0], sizeof(Image));
     261
     262      // output[0].coords = input[0].coords;
     263      // strcpy (output[0].coords.ctype, input[0].coords.ctype);
     264
     265      output[N].NX = NX;
     266      output[N].NY = NY;
     267
     268      output[N].coords.crpix1 = input[0].coords.crpix1 - i*NX;
     269      output[N].coords.crpix2 = input[0].coords.crpix2 - j*NY;
     270      N++;
     271    }
     272  }
    231273  return (TRUE);
    232274}
Note: See TracChangeset for help on using the changeset viewer.