IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 22, 2009, 10:43:26 AM (17 years ago)
Author:
eugene
Message:

lots of very minor API mods to satisfy some pickier compilers (supply void to prototypes for argument-less functions)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/dvo/skycoverage.c

    r19823 r21153  
    11# include "dvoshell.h"
     2
     3int wordhash (char *word);
    24
    35int skycoverage (int argc, char **argv) {
    46
     7  int WITH_MOSAIC, SOLO_MOSAIC;
    58  int i, N, Nimage, status, TimeSelect, ByName, xs, ys;
    69  time_t tzero, tend;
    7   double pixscale, dPix, r, d, Xi, Yi, Xs, Ys, x[2], y[2], trange;
     10  double pixscale, dX, dY, Npts, r, d, Xi, Yi, Xs, Ys, x[2], y[2], trange, RaCenter;
    811  Image *image;
    912  char name[256];
     
    1215  Buffer *buf;
    1316  Coords coords;
     17  int typehash;
     18
     19  WITH_MOSAIC = FALSE;
     20  if ((N = get_argument (argc, argv, "+mosaic"))) {
     21    remove_argument (N, &argc, argv);
     22    WITH_MOSAIC = TRUE;
     23  }
     24
     25  SOLO_MOSAIC = FALSE;
     26  if ((N = get_argument (argc, argv, "-mosaic"))) {
     27    remove_argument (N, &argc, argv);
     28    SOLO_MOSAIC = TRUE;
     29    WITH_MOSAIC = TRUE;
     30  }
     31
     32  RaCenter = 0.0;
     33  if ((N = get_argument (argc, argv, "-ra-center"))) {
     34    remove_argument (N, &argc, argv);
     35    RaCenter = atof (argv[N]);
     36    remove_argument (N, &argc, argv);
     37  }
    1438
    1539  ByName = FALSE;
     
    6185 
    6286  if (argc != 4) {
    63     gprint (GP_ERR, "USAGE: skycoverage (buffer) (pixscale) (dPix) [-time start range] [-name name]\n");
     87    gprint (GP_ERR, "USAGE: skycoverage (buffer) (pixscale) (Npts) [-time start range] [-name name]\n");
    6488    gprint (GP_ERR, "       (buffer) saves bitmapped AIT plot\n");
    6589    gprint (GP_ERR, "       (pixscale) specifies the pixel size in degrees\n");
     90    gprint (GP_ERR, "       (Npts) gives the number of test points per image in each dimension\n");
    6691    gprint (GP_ERR, "       note: we need 64800 / (pixscale)^2 pixels to represent the sky\n");
    6792    return (FALSE);
     
    7095  if ((buf = SelectBuffer (argv[1], ANYBUFFER, TRUE)) == NULL) return (FALSE);
    7196  pixscale = atof(argv[2]);
    72   dPix     = atof(argv[3]);
     97  Npts     = atof(argv[3]);
    7398
    7499  Nx = 360/pixscale;
     
    80105  strcpy (buf[0].file, "(empty)");
    81106
    82   coords.crval1 = 180;
     107  coords.crval1 = RaCenter;
    83108  coords.crval2 = 0;
    84109  coords.crpix1 = 0.5*Nx;
    85110  coords.crpix2 = 0.5*Ny;
    86111  strcpy (coords.ctype, "DEC--AIT");
    87   coords.pc1_1 = coords.pc2_2 = 1;
    88   coords.pc1_2 = coords.pc2_1 = 0;
     112  coords.pc1_1 = -1.0;
     113  coords.pc2_2 = +1.0;
     114  coords.pc1_2 =  0.0;
     115  coords.pc2_1 =  0.0;
    89116  coords.cdelt1 = coords.cdelt2 = pixscale;
    90117  coords.Npolyterms = 0;
     
    109136  }
    110137
     138  int DistortImage = wordhash ("-DIS");
     139
    111140  for (i = 0; i < Nimage; i++) {
    112141    if (ByName && strcmp (name, image[i].name)) continue;
    113142    if (TimeSelect && ((image[i].tzero < tzero) || (image[i].tzero+image[i].trate*image[i].NY > tzero + trange))) continue;
    114143    if (!FindMosaicForImage (image, Nimage, i)) continue;
     144
     145    typehash = wordhash (&image[i].coords.ctype[4]);
     146
     147    /* DIS images represent a field, not a chip */
     148    if ((typehash == DistortImage) && !WITH_MOSAIC) continue;
     149    if ((typehash != DistortImage) &&  SOLO_MOSAIC) continue;
    115150
    116151    /* project this image to screen display coords */
     
    125160    status = FALSE;
    126161   
    127     for (Yi = y[0] + 0.5*dPix; Yi < y[1]; Yi += dPix) {
    128       for (Xi = x[0] + 0.5*dPix; Xi < x[1]; Xi += dPix) {
     162    dX = (x[1] - x[0]) / Npts;
     163    dY = (y[1] - y[0]) / Npts;
     164   
     165    for (Yi = y[0] + 0.5*dY; Yi < y[1]; Yi += dY) {
     166      for (Xi = x[0] + 0.5*dX; Xi < x[1]; Xi += dX) {
    129167        XY_to_RD (&r, &d, Xi, Yi, &image[i].coords);
    130168        r = ohana_normalize_angle (r);
    131169        status = RD_to_XY (&Xs, &Ys, r, d, &coords);
     170        if (Xs < 0) continue;
     171        if (Ys < 0) continue;
     172        if (Xs >= Nx) continue;
     173        if (Ys >= Ny) continue;
    132174        if (status) {
    133175          xs = (int)Xs;
Note: See TracChangeset for help on using the changeset viewer.