IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 18, 2012, 10:04:35 AM (14 years ago)
Author:
eugene
Message:

merging changes from eam_branches/ipp-20121130

Location:
trunk/Ohana
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/addstar/src/findskycell.c

    r34291 r34844  
    1515
    1616void usage (void) {
    17   fprintf (stderr, "USAGE: findcell -mktree (tree) (catdir)\n");
     17  fprintf (stderr, "USAGE: findcell -mktree (tree) (catdir) [-nx Nx] [-ny Ny]\n");
    1818  fprintf (stderr, "USAGE: findcell -tree (tree) (datafile)\n");
    1919  fprintf (stderr, "   (datafile) should contain a list of RA,DEC pairs\n");
     
    2424int apply_tree (char *treefile, char *datafile);
    2525
     26float SCALE = 1.0;
     27int NX_SUB = 1;
     28int NY_SUB = 1;
     29
    2630int main (int argc, char **argv) {
    2731
     
    3741  if (get_argument (argc, argv, "-help")) usage ();
    3842  if (get_argument (argc, argv, "-h")) usage ();
     43
     44  NX_SUB = NY_SUB = 1;
     45  if ((N = get_argument (argc, argv, "-nx"))) {
     46    remove_argument (N, &argc, argv);
     47    NX_SUB = atof (argv[N]);
     48    remove_argument (N, &argc, argv);
     49  }
     50  if ((N = get_argument (argc, argv, "-ny"))) {
     51    remove_argument (N, &argc, argv);
     52    NY_SUB = atof (argv[N]);
     53    remove_argument (N, &argc, argv);
     54  }
     55
     56  /* pixel scale (arcsec/pixel) */
     57  SCALE = 1.0;
     58  if ((N = get_argument (argc, argv, "-scale"))) {
     59    remove_argument (N, &argc, argv);
     60    SCALE = atof (argv[N]);
     61    remove_argument (N, &argc, argv);
     62  }
    3963
    4064  /* extra error messages */
     
    109133
    110134  tree.Nzone = 46;
     135  tree.NX_SUB = NX_SUB;
     136  tree.NY_SUB = NY_SUB;
     137  tree.dPix = SCALE/3600.0;
    111138
    112139  ALLOCATE (tree.Nband, int, tree.Nzone);
     
    122149  ALLOCATE (tree.ra,   double *, tree.Nzone);
    123150  ALLOCATE (tree.dec,  double *, tree.Nzone);
     151  ALLOCATE (tree.Xo,   double *, tree.Nzone);
     152  ALLOCATE (tree.Yo,   double *, tree.Nzone);
     153  ALLOCATE (tree.dX,      int *, tree.Nzone);
     154  ALLOCATE (tree.dY,      int *, tree.Nzone);
    124155  ALLOCATE (tree.cell,    int *, tree.Nzone);
    125156  ALLOCATE (tree.name,  char **, tree.Nzone);
     
    152183    ALLOCATE (tree.ra[zone],   double, tree.NBAND[zone]);
    153184    ALLOCATE (tree.dec[zone],  double, tree.NBAND[zone]);
     185    ALLOCATE (tree.Xo[zone],   double, tree.NBAND[zone]);
     186    ALLOCATE (tree.Yo[zone],   double, tree.NBAND[zone]);
     187    ALLOCATE (tree.dX[zone],      int, tree.NBAND[zone]);
     188    ALLOCATE (tree.dY[zone],      int, tree.NBAND[zone]);
    154189    ALLOCATE (tree.cell[zone], int,    tree.NBAND[zone]);
    155190    ALLOCATE (tree.name[zone], char *, tree.NBAND[zone]);
     
    157192      tree.ra[zone][band] = NAN;
    158193      tree.dec[zone][band] = NAN;
     194      tree.Xo[zone][band] = NAN;
     195      tree.Yo[zone][band] = NAN;
     196      tree.dX[zone][band] = -1;
     197      tree.dY[zone][band] = -1;
    159198      tree.cell[zone][band] = -1;
    160199      ALLOCATE (tree.name[zone][band], char, BOUNDARY_TREE_NAME_LENGTH);
     
    179218      REALLOCATE (tree.ra[zone],   double, tree.NBAND[zone]);
    180219      REALLOCATE (tree.dec[zone],  double, tree.NBAND[zone]);
    181       REALLOCATE (tree.cell[zone], int,    tree.NBAND[zone]);
     220      REALLOCATE (tree.Xo[zone],   double, tree.NBAND[zone]);
     221      REALLOCATE (tree.Yo[zone],   double, tree.NBAND[zone]);
     222      REALLOCATE (tree.dX[zone],      int, tree.NBAND[zone]);
     223      REALLOCATE (tree.dY[zone],      int, tree.NBAND[zone]);
     224      REALLOCATE (tree.cell[zone],    int, tree.NBAND[zone]);
    182225      REALLOCATE (tree.name[zone], char *, tree.NBAND[zone]);
    183226      for (j = start; j < tree.NBAND[zone]; j++) {
    184227        tree.ra[zone][j] = NAN;
    185228        tree.dec[zone][j] = NAN;
     229        tree.Xo[zone][band] = NAN;
     230        tree.Yo[zone][band] = NAN;
     231        tree.dX[zone][band] = -1;
     232        tree.dY[zone][band] = -1;
    186233        tree.cell[zone][j] = -1;
    187234        ALLOCATE (tree.name[zone][j], char, BOUNDARY_TREE_NAME_LENGTH);
     
    190237    tree.ra[zone][band] = ra;
    191238    tree.dec[zone][band] = dec;
     239    tree.Xo[zone][band] = x;
     240    tree.Yo[zone][band] = y;
     241    tree.dX[zone][band] = image[i].NX / NX_SUB;
     242    tree.dY[zone][band] = image[i].NY / NY_SUB;
     243   
    192244    tree.cell[zone][band] = i;
    193245
     
    325377    }
    326378
    327     fprintf (stdout, "%10.6f %10.6f  %3d %3d  %s\n", ra, dec, zone, band, tree->name[zone][band]);
     379    // I know the projection cell (band,zone), but I need to find the skycell within that projection cell.
     380    // the proj cell is divided into Nx, Ny bits.
     381    // (ra,dec) for (Ro,Do) -> (x,y).  given (Xo,Yo),(dX,dY) I can find ix,iy
     382    // I currently track Ro,Do (tree->ra[zone][band], tree->dec[zone][band])
     383    // I need to have the skycell center in pixels (Xo,Yo) and the scale dX,dY
     384   
     385    // convert R,D to X,Y with hard-wired projection and scale, orientation?
     386   
     387    double x = 0.0;
     388    double y = 0.0;
     389    BoundaryTreeProjection (&x, &y, ra, dec, tree, zone, band);
     390
     391    int xi = x / tree->dX[zone][band];
     392    int yi = y / tree->dY[zone][band];
     393   
     394    char format[24], skycellname[128];
     395    int Ndigit = (int)(log10(tree->NX_SUB*tree->NY_SUB)) + 1 ;
     396    snprintf (format, 24, "%s.%%0%dd", tree->name[zone][band], Ndigit);
     397
     398    int N = xi + tree->NX_SUB * yi;
     399    snprintf (skycellname, 128, format, N);
     400
     401    fprintf (stdout, "%10.6f %10.6f  %8.3f %8.3f  %3d %3d  %s\n", ra, dec, x, y, zone, band, skycellname);
    328402  }
    329403
    330404  exit (0);
    331405}
     406
  • trunk/Ohana/src/addstar/src/sky_tessalation.c

    r34260 r34844  
    275275      // convert the SkyRectangles to Images for output
    276276      sky_subdivide_image (&image[j*NX_SUB*NY_SUB], &ring[j], NX_SUB, NY_SUB);
    277       printf("%s %8.2f %8.2f\n", ring[j].name, ring[j].coords.crval1, ring[j].coords.crval2);
     277      // printf("%s %8.2f %8.2f\n", ring[j].name, ring[j].coords.crval1, ring[j].coords.crval2);
    278278    }
    279279
     
    691691    // fprintf (stdout, "%f %f  %f  %f  %f %f  %f %f  %f %f %f\n", dec, decUpper, dRA, arg, root1, root2, theta1, theta2, r1, r2, k*r2);
    692692  }
    693   fprintf (stdout, "%f %f  %f x %f (%d)\n", dec, decUpper, dRA, theta, nRA);
     693  // fprintf (stdout, "%f %f  %f x %f (%d)\n", dec, decUpper, dRA, theta, nRA);
    694694
    695695  // I think we need to return the value of dec for the next ring, but I am not sure...
     
    776776      ring[N].coords.crval2 = (j == 0) ? dec / d2r : -dec / d2r;
    777777
    778       printf(" \t %d   %25.20f   %25.20f\n", i, ring[N].coords.crval2, ring[N].coords.crval1);
     778      // printf(" \t %d   %25.20f   %25.20f\n", i, ring[N].coords.crval2, ring[N].coords.crval1);
    779779
    780780      ring[N].coords.pc1_1 = +1.0 * X_PARITY;
Note: See TracChangeset for help on using the changeset viewer.