IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5850


Ignore:
Timestamp:
Dec 27, 2005, 3:21:40 PM (20 years ago)
Author:
eugene
Message:

substantial work to move kii/kapa call into libkapa

Location:
trunk/Ohana/src/opihi
Files:
34 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.astro/gauss.c

    r5846 r5850  
    5454  for (i = 0; (i < Nspot) || (Nspot == 0); i++) {
    5555    KiiCursorRead (Ximage, &X, &Y, key);
    56 
    5756    if (!strcasecmp (key, "Q")) break;
    58 
    5957    Z = get_aperture_stats (&buf[0].matrix, (int)(X+0.5), (int)(Y+0.5), Npix, Nborder, max);
    6058  }
  • trunk/Ohana/src/opihi/cmd.astro/region.c

    r5386 r5850  
    33int region (int argc, char **argv) {
    44 
    5   char buffer[65], string[256];
     5  char string[256];
    66  double Ra, Dec, Radius;
    77  double dx, dy;
     
    6060 
    6161  /* ask kapa for coordinate limits, so get the right aspect ratio */
    62   SendGraphCommand (Xgraph, 4, "LIMS");
    63   read (Xgraph, buffer, 30);
    64   sscanf (buffer, "%*s %lf %lf", &dx, &dy);
     62  KiiSendCommand (Xgraph, 4, "LIMS");
     63  KiiScanMessage (Xgraph, "%lf %lf", &dx, &dy);
    6564  dx = fabs (dx);
    6665  dy = fabs (dy);
     
    102101  graphmode.coords.cdelt1 = graphmode.coords.cdelt2 = 1.0;
    103102
    104   SendGraphCommand (Xgraph, 4, "ERAS");
    105   SendGraphCommand (Xgraph, 4, "SLIM");
    106   SendGraphMessage (Xgraph, "%f %f %f %f", graphmode.xmin, graphmode.xmax, graphmode.ymin, graphmode.ymax);
     103  KapaClear (Xgraph, FALSE);
     104  KapaSetLimits (Xgraph, &graphmode);
    107105
     106  /* drop this? */
    108107  sprintf (string, "%8.4f %8.4f (%f)", Ra, Dec, Radius);
    109   SendLabel (string, Xgraph, 2);
     108  KapaSendLabel (Xgraph, string, 2);
    110109
    111110  SetGraph (graphmode);
    112 
    113111  return (TRUE);
    114 
    115112}
    116113
  • trunk/Ohana/src/opihi/cmd.data/box.c

    r5849 r5850  
    44 
    55  int i, N, Ngraph, Xgraph;
    6   char Ticks[16], Axis[16], Labels[16];
    76  Graphdata graphmode;
    87 
    9   strcpy (Ticks, "2222");
     8  if (!GetGraph (&graphmode, &Xgraph, &Ngraph)) return (FALSE);
     9
     10  strcpy (graphmode.ticks, "2222");
    1011  if ((N = get_argument (argc, argv, "-ticks"))) {
    1112    remove_argument (N, &argc, argv);
    12     strcpy (Ticks, argv[N]);
     13    strcpy (graphmode.ticks, argv[N]);
    1314    remove_argument (N, &argc, argv);
    14     if (strlen (Ticks) != 4) { goto usage; }
    15     for (i = 0; i < strlen (Ticks); i++) {
    16       if ((Ticks[i] != '0') && (Ticks[i] != '1') && (Ticks[i] != '2')) { goto usage; }
     15    if (strlen (graphmode.ticks) != 4) { goto usage; }
     16    for (i = 0; i < strlen (graphmode.ticks); i++) {
     17      if ((graphmode.ticks[i] != '0') && (graphmode.ticks[i] != '1') && (graphmode.ticks[i] != '2')) { goto usage; }
    1718    }
    1819  }
    1920 
    20   strcpy (Labels, "2222");
     21  strcpy (graphmode.labels, "2222");
    2122  if ((N = get_argument (argc, argv, "-labels"))) {
    2223    remove_argument (N, &argc, argv);
    23     strcpy (Labels, argv[N]);
     24    strcpy (graphmode.labels, argv[N]);
    2425    remove_argument (N, &argc, argv);
    25     if (strlen (Labels) != 4) { goto usage; }
    26     for (i = 0; i < strlen (Labels); i++) {
    27       if ((Labels[i] != '0') && (Labels[i] != '1') && (Labels[i] != '2')) { goto usage; }
     26    if (strlen (graphmode.labels) != 4) { goto usage; }
     27    for (i = 0; i < strlen (graphmode.labels); i++) {
     28      if ((graphmode.labels[i] != '0') && (graphmode.labels[i] != '1') && (graphmode.labels[i] != '2')) { goto usage; }
    2829    }
    2930  }
    3031
    31   strcpy (Axis, "2222");
     32  strcpy (graphmode.axis, "2222");
    3233  if ((N = get_argument (argc, argv, "-axis"))) {
    3334    remove_argument (N, &argc, argv);
    34     strcpy (Axis, argv[N]);
     35    strcpy (graphmode.axis, argv[N]);
    3536    remove_argument (N, &argc, argv);
    36     if (strlen (Axis) != 4) { goto usage; }
    37     for (i = 0; i < strlen (Axis); i++) {
    38       if ((Axis[i] != '0') && (Axis[i] != '1') && (Axis[i] != '2')) { goto usage; }
     37    if (strlen (graphmode.axis) != 4) { goto usage; }
     38    for (i = 0; i < strlen (graphmode.axis); i++) {
     39      if ((graphmode.axis[i] != '0') && (graphmode.axis[i] != '1') && (graphmode.axis[i] != '2')) { goto usage; }
    3940    }
    4041  }
     
    4647    remove_argument (N, &argc, argv);
    4748  }
    48   if (!GetGraph (&graphmode, &Xgraph, &Ngraph)) return (FALSE);
    4949
    5050  if (argc != 1) goto usage;
    5151
    52   KapaBox (Xgraph, &graphmode, Axis, Labels, Ticks);
     52  KapaBox (Xgraph, &graphmode);
    5353  return (TRUE);
    5454     
     
    7373   -labels 1100
    7474   -ticks 1111
    75    
    76 
    7775
    7876   messages to kapa:
  • trunk/Ohana/src/opihi/cmd.data/clear.c

    r3692 r5850  
    2525  }
    2626
    27   if (ClearSection) {
    28     SendGraphCommand (Xgraph, 4, "ERAS");
    29   } else {
    30     SendGraphCommand (Xgraph, 4, "ERSS");
    31   }
     27  KapaClear (Xgraph, ClearSection);
    3228  return (TRUE);
    3329}
  • trunk/Ohana/src/opihi/cmd.data/dot.c

    r4689 r5850  
    4747  if ((N = get_argument (argc, argv, "-c"))) {
    4848    remove_argument (N, &argc, argv);
    49     graphmode.color = GetColor (argv[N]);
     49    graphmode.color = KapaColorByName (argv[N]);
    5050    if (graphmode.color == -1) return (FALSE);
    5151    remove_argument (N, &argc, argv);
    5252  }
    53   /* only -x 2 makes sense here
    54   if ((N = get_argument (argc, argv, "-x"))) {
    55     remove_argument (N, &argc, argv);
    56     graphmode.style = atof(argv[N]);
    57     remove_argument (N, &argc, argv);
    58   }
    59   */
    6053  graphmode.style = 2;
    6154
  • trunk/Ohana/src/opihi/cmd.data/fit2d.c

    r4689 r5850  
    160160    }
    161161
     162    fprintf (stderr, "matrix:\n");
     163    for (k = 0; k < wterm; k++) {
     164        for (K = 0; K < wterm; K++) {
     165            fprintf (stderr, "%f ", c[k][K]);
     166        }
     167        fprintf (stderr, "\n");
     168    }
     169
    162170    gaussj (c, wterm, b, 1);
     171
     172    fprintf (stderr, "inverse:\n");
     173    for (k = 0; k < wterm; k++) {
     174        for (K = 0; K < wterm; K++) {
     175            fprintf (stderr, "%f ", c[k][K]);
     176        }
     177        fprintf (stderr, "\n");
     178    }
    163179
    164180    /** test print **/
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r4714 r5850  
    144144  {"interpolate",  interpolate,      "interpolate between vector pairs"},
    145145  {"jpeg",         jpeg,             "write text line on graph"},
     146  {"png",          jpeg,             "write text line on graph"},
     147  {"ppm",          jpeg,             "write text line on graph"},
    146148  {"kern",         kern,             "convolve with 3x3 kernel"},
    147149  {"keyword",      keyword,          "extract a FITS keyword from buffer header"},
  • trunk/Ohana/src/opihi/cmd.data/interpolate.c

    r2598 r5850  
    4343        yout[0].elements[i] = (dy/dx)*(xout[0].elements[i] - x0) + y0;
    4444      }
    45       if ((j == xin[0].Nelements - 2) && (xout[0].elements[i] > x1)) {
     45      if ((j == xin[0].Nelements - 2) && (xout[0].elements[i] >= x1)) {
    4646        yout[0].elements[i] = (dy/dx)*(xout[0].elements[i] - x0) + y0;
    4747      }
  • trunk/Ohana/src/opihi/cmd.data/jpeg.c

    r5846 r5850  
    33int jpeg (int argc, char **argv) {
    44
    5   char filename[1024], buffer[20], type[16];
    6   int N, Source, Nsource, IsImage;
     5  char filename[1024];
     6  int N, Source, Nsource, IsImage, IsPNG;
    77 
    88  if ((N = get_argument (argc, argv, "--help"))) {
     
    1212
    1313  /* image type */
    14   strcpy (type, "PNGF");
     14  IsPNG = TRUE;
    1515  if ((N = get_argument (argc, argv, "-ppm"))) {
    1616    remove_argument (N, &argc, argv);
    17     strcpy (type, "PPMF");
     17    IsPNG = FALSE;
    1818  }
    1919
     
    4545    if (!GetImage (&Source, &Nsource)) return (FALSE);
    4646    if (!filename[0]) strcpy (filename, "Ximage.jpg");
    47     strcpy (type, "JPEG");
    48     KiiJpeg (Source, filename);
     47    KiiJPEG (Source, filename);
    4948  } else {
    5049    if (!GetGraph (NULL, &Source, &Nsource)) return (FALSE);
    5150    if (!filename[0]) strcpy (filename, "Xgraph.png");
    52     SendGraphCommand (Source, 4, type);
    53     SendGraphCommand (Source, 16, "LEN: %11d", strlen(filename));
    54     write (Source, filename, strlen(filename));
    55     read (Source, buffer, 4);
     51    if (IsPNG) {
     52      KapaPNG (Source, filename);
     53    } else {
     54      KapaPPM (Source, filename);
     55    }
    5656  }
    5757  return (TRUE);
    5858}
    5959
    60 /* jpeg -g converts graph to png
     60/* jpeg converts graph to png or ppm
    6161   jpeg converts image to jpeg */
  • trunk/Ohana/src/opihi/cmd.data/labels.c

    r3692 r5850  
    3636    size = atof (argv[N]);
    3737    remove_argument (N, &argc, argv);
    38     SendGraphCommand (Xgraph, 4, "FONT");
    39     SendGraphCommand (Xgraph, 16, "%s", name);
    40     SendGraphCommand (Xgraph, 16, "%d", size);
     38    KapaSetFont (Xgraph, name, size);
    4139  }
    4240
    4341  if ((N = get_argument (argc, argv, "-x"))) {
    4442    remove_argument (N, &argc, argv);
    45     SendLabel (argv[N], Xgraph, 0);
     43    KapaSendLabel (Xgraph, argv[N], 0);
    4644    remove_argument (N, &argc, argv);
    4745  }
     
    4947  if ((N = get_argument (argc, argv, "-y"))) {
    5048    remove_argument (N, &argc, argv);
    51     SendLabel (argv[N], Xgraph, 1);
     49    KapaSendLabel (Xgraph, argv[N], 1);
    5250    remove_argument (N, &argc, argv);
    5351  }
     
    5553  if ((N = get_argument (argc, argv, "+x"))) {
    5654    remove_argument (N, &argc, argv);
    57     SendLabel (argv[N], Xgraph, 2);
     55    KapaSendLabel (Xgraph, argv[N], 2);
    5856    remove_argument (N, &argc, argv);
    5957  }
     
    6159  if ((N = get_argument (argc, argv, "+y"))) {
    6260    remove_argument (N, &argc, argv);
    63     SendLabel (argv[N], Xgraph, 3);
     61    KapaSendLabel (Xgraph, argv[N], 3);
    6462    remove_argument (N, &argc, argv);
    6563  }
     
    6765  if ((N = get_argument (argc, argv, "-ul"))) {
    6866    remove_argument (N, &argc, argv);
    69     SendLabel (argv[N], Xgraph, 4);
     67    KapaSendLabel (Xgraph, argv[N], 4);
    7068    remove_argument (N, &argc, argv);
    7169  }
     
    7371  if ((N = get_argument (argc, argv, "-ur"))) {
    7472    remove_argument (N, &argc, argv);
    75     SendLabel (argv[N], Xgraph, 5);
     73    KapaSendLabel (Xgraph, argv[N], 5);
    7674    remove_argument (N, &argc, argv);
    7775  }
     
    7977  if ((N = get_argument (argc, argv, "-ll"))) {
    8078    remove_argument (N, &argc, argv);
    81     SendLabel (argv[N], Xgraph, 6);
     79    KapaSendLabel (Xgraph, argv[N], 6);
    8280    remove_argument (N, &argc, argv);
    8381  }
     
    8583  if ((N = get_argument (argc, argv, "-lr"))) {
    8684    remove_argument (N, &argc, argv);
    87     SendLabel (argv[N], Xgraph, 7);
     85    KapaSendLabel (Xgraph, argv[N], 7);
    8886    remove_argument (N, &argc, argv);
    8987  }
  • trunk/Ohana/src/opihi/cmd.data/limits.c

    r2843 r5850  
    7171 success:
    7272  SetLimits (xvec, yvec, &graphmode);
    73   ApplyLimits (Xgraph, &graphmode, APPLY);
     73  if (APPLY) KapaSetLimits (Xgraph, &graphmode);
    7474  return (TRUE);
    75 
    7675}
  • trunk/Ohana/src/opihi/cmd.data/line.c

    r2843 r5850  
    4747  if ((N = get_argument (argc, argv, "-c"))) {
    4848    remove_argument (N, &argc, argv);
    49     graphmode.color = GetColor (argv[N]);
     49    graphmode.color = KapaColorByName (argv[N]);
    5050    if (graphmode.color == -1) return (FALSE);
    5151    remove_argument (N, &argc, argv);
  • trunk/Ohana/src/opihi/cmd.data/plot.c

    r3105 r5850  
    4747  if ((N = get_argument (argc, argv, "-c"))) {
    4848    remove_argument (N, &argc, argv);
    49     graphmode.color = GetColor (argv[N]);
     49    graphmode.color = KapaColorByName (argv[N]);
    5050    if (graphmode.color == -1) return (FALSE);
    5151    remove_argument (N, &argc, argv);
  • trunk/Ohana/src/opihi/cmd.data/ps.c

    r5846 r5850  
    66  int N, Source, Nsource, RawImage, NoScale, IsImage;
    77 
    8   if ((N = get_argument (argc, argv, "--help"))) {
    9     fprintf (stderr, "USAGE: ps [-name file.ps] [-g | -i] [-n device] [-raw] [-scale]\n");
    10     return (FALSE);
    11   }
     8  if ((N = get_argument (argc, argv, "--help"))) goto help;
     9  if ((N = get_argument (argc, argv, "-h"))) goto help;
    1210
    1311  /* raw image? */
     
    5856  KiiPS (Source, NoScale, RawImage, filename);
    5957  return (TRUE);
     58
     59help:
     60  fprintf (stderr, "USAGE: ps [-name file.ps] [-g | -i] [-n device] [-raw] [-scale]\n");
     61  return (FALSE);
    6062}
    6163
  • trunk/Ohana/src/opihi/cmd.data/section.c

    r4689 r5850  
    66  int Ngraph, Xgraph;
    77  Graphdata graphmode;
     8  KapaSection section;
    89
    910  List = FALSE;
     
    2122  if (!GetGraph (&graphmode, &Xgraph, &Ngraph)) return (FALSE);
    2223
     24  /* list sections */
    2325  if (argc == 1) {
    24     /* list section */
    25     SendGraphCommand (Xgraph, 4, "LSEC");
    26     SendGraphMessage (Xgraph, "* %s", argv[1]);
     26    KapaGetSection (Xgraph, "*");
    2727    fprintf (stderr, "USAGE: section name [x y dx dy]\n");
    2828    return (TRUE);
     
    3030 
    3131  if (argc == 2) {
    32     /* set section */
     32    /* select / show section */
    3333    if (List) {
    34       SendGraphCommand (Xgraph, 4, "LSEC");
     34      KapaGetSection (Xgraph, argv[1]);
    3535    } else {
    36       SendGraphCommand (Xgraph, 4, "SSEC");
     36      KapaSelectSection (Xgraph, argv[1]);
    3737    }
    38     SendGraphMessage (Xgraph, "%s", argv[1]);
    3938    return (TRUE);
    4039  }
    4140 
    4241  if (argc == 6) {
    43     /* define section */
    44     SendGraphCommand (Xgraph, 4, "DSEC");
    45     SendGraphMessage (Xgraph, "%s %6.3f %6.3f %6.3f %6.3f", argv[1], atof (argv[2]), atof (argv[3]), atof (argv[4]), atof (argv[5]));
     42    /* set section */
     43    section.name = argv[1];
     44    section.x = atof (argv[2]);
     45    section.y = atof (argv[3]);
     46    section.dx = atof (argv[4]);
     47    section.dy = atof (argv[5]);
     48    KapaSetSection (Xgraph, &section);
    4649    return (TRUE);
    4750  }
     
    5053}
    5154
    52     /* should do some range checking on x y dx dy
    53        should be between 0.0 and 1.0, precision of 0.001
    54        is sufficient
    55     */
     55/* should do some range checking on x y dx dy
     56   should be between 0.0 and 1.0, precision of 0.001
     57   is sufficient
     58*/
  • trunk/Ohana/src/opihi/cmd.data/style.c

    r2843 r5850  
    2929    remove_argument (N, &argc, argv);
    3030  }
    31 
    3231  if ((N = get_argument (argc, argv, "-lw"))) {
    3332    remove_argument (N, &argc, argv);
     
    3534    remove_argument (N, &argc, argv);
    3635  }
    37 
    3836  if ((N = get_argument (argc, argv, "-pt"))) {
    3937    remove_argument (N, &argc, argv);
     
    4139    remove_argument (N, &argc, argv);
    4240  }
    43 
    4441  if ((N = get_argument (argc, argv, "+eb"))) {
    4542    remove_argument (N, &argc, argv);
    4643    graphmode.ebar = TRUE;
    4744  }
    48 
    4945  if ((N = get_argument (argc, argv, "-eb"))) {
    5046    remove_argument (N, &argc, argv);
    5147    graphmode.ebar = FALSE;
    5248  }
    53 
    5449  if ((N = get_argument (argc, argv, "-sz"))) {
    5550    remove_argument (N, &argc, argv);
     
    5752    remove_argument (N, &argc, argv);
    5853  }
    59 
    6054  if ((N = get_argument (argc, argv, "-c"))) {
    6155    remove_argument (N, &argc, argv);
    62     graphmode.color = GetColor (argv[N]);
     56    graphmode.color = KapaColorByName (argv[N]);
    6357    if (graphmode.color == -1) return (FALSE);
    6458    remove_argument (N, &argc, argv);
    6559  }
    66 
    6760  if ((N = get_argument (argc, argv, "-x"))) {
    6861    remove_argument (N, &argc, argv);
  • trunk/Ohana/src/opihi/cmd.data/textline.c

    r4689 r5850  
    2323    size = atof (argv[N]);
    2424    remove_argument (N, &argc, argv);
    25     SendGraphCommand (Xgraph, 4, "FONT");
    26     SendGraphCommand (Xgraph, 16, "%s", name);
    27     SendGraphCommand (Xgraph, 16, "%d", size);
     25    KapaSetFont (Xgraph, name, size);
    2826  }
    2927
     
    6058  }   
    6159
    62   /* WARNING: this is a bit dangerous - convert to SendGraphMessage format */
    63   SendGraphCommand (Xgraph, 4, "PTXT");
    64   SendGraphCommand (Xgraph, 16, "%f", x);
    65   SendGraphCommand (Xgraph, 16, "%f", y);
    66   SendGraphCommand (Xgraph, 16, "%f", angle);
    67   SendGraphCommand (Xgraph, 128, "%s", argv[3]);
     60  KapaSendTextline (Xgraph, argv[3], x, y, angle);
    6861  return (TRUE);
    6962}
  • trunk/Ohana/src/opihi/cmd.data/vbin.c

    r4689 r5850  
    33int vbin (int argc, char **argv) {
    44 
    5   int i, j, status, ExactScale;
    6   int n, nx, ny, Nx, Ny, x, y, N, Normalize, *Npix, *Vn;
    7   int Ignore, IgnoreValue, VERBOSE;
    8   float *Vout, *Vin, *Out, *In;
    9   double scale, scale2, fx, fy, dX, dY;
    10   char temp[1024];
    11   Buffer *in, *out;
     5  int i, j, n, N, Nin, Nout;
     6  int Normalize, Ignore;
     7  float *Vout, *Vin, IgnoreValue;
     8  double scale;
     9  Vector *in, *out;
    1210
    13   Npix = NULL;
    14   Vn = NULL;
    1511  Normalize = FALSE;
    1612  if ((N = get_argument (argc, argv, "-norm"))) {
    1713    remove_argument (N, &argc, argv);
    1814    Normalize = TRUE;
    19   }
    20 
    21   VERBOSE = FALSE;
    22   if ((N = get_argument (argc, argv, "-v"))) {
    23     remove_argument (N, &argc, argv);
    24     VERBOSE = TRUE;
    2515  }
    2616
     
    4030  }
    4131
    42   if ((in  = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) return (FALSE);
    43   if ((out = SelectBuffer (argv[2], ANYBUFFER, TRUE)) == NULL) return (FALSE);
    44   fits_free_matrix (&out[0].matrix);
    45   fits_free_header (&out[0].header);
     32  if ((in  = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
     33  if ((out = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) return (FALSE);
    4634
    4735  scale  = atof (argv[3]);
    48   if ((scale == (int) scale) || ((1.0/scale) == (int)(1.0/scale))) {
    49     ExactScale = TRUE;
    50     if (scale > 0) {
    51       nx = in[0].header.Naxis[0] / scale;
    52       ny = in[0].header.Naxis[1] / scale;
    53     } else {
    54       nx = in[0].header.Naxis[0] * fabs(scale);
    55       ny = in[0].header.Naxis[1] * fabs(scale);
    56     }   
    57   } else {
    58     ExactScale = FALSE;
    59     if (scale > 0) {
    60       nx = (int) (in[0].header.Naxis[0] / scale) + 1;
    61       ny = (int) (in[0].header.Naxis[1] / scale) + 1;
    62     } else {
    63       nx = (int) (in[0].header.Naxis[0] * fabs(scale)) + 1;
    64       ny = (int) (in[0].header.Naxis[1] * fabs(scale)) + 1;
    65     }     
    66   }
    67   if (VERBOSE) fprintf (GetOutfile(), "rebin %s to %s (%d,%d to %d,%d)\n", argv[1], argv[2], in[0].header.Naxis[0], in[0].header.Naxis[1], nx, ny);
    68 
    69   Nx = in[0].header.Naxis[0];
    70   Ny = in[0].header.Naxis[1];
    71   out[0].bitpix = in[0].bitpix;
    72   out[0].unsign = in[0].unsign;
    73   out[0].bscale = in[0].bscale;
    74   out[0].bzero  = in[0].bzero;
    75   fits_copy_header (&in[0].header, &out[0].header);
    76   fits_modify (&out[0].header, "NAXIS1", "%d", 1, nx);
    77   fits_modify (&out[0].header, "NAXIS2", "%d", 1, ny);
    78 
    79   status =  fits_scan (&out[0].header, "CDELT1", "%lf", 1, &dX);
    80   status &= fits_scan (&out[0].header, "CDELT2", "%lf", 1, &dY);
    81   if (scale > 0) {
    82     dX *= scale;
    83     dY *= scale;
    84   } else {
    85     dX /= fabs(scale);
    86     dY /= fabs(scale);
    87   }   
    88   if (status) {
    89     fits_modify (&out[0].header, "CDELT1", "%lf", 1, dX);
    90     fits_modify (&out[0].header, "CDELT2", "%lf", 1, dY);
     36  if ((int)(scale) != scale) {
     37    fprintf (stderr, "integer binning only, please\n");
     38    return (FALSE);
    9139  }
    9240
    93   status =  fits_scan (&out[0].header, "CRPIX1", "%lf", 1, &dX);
    94   status &= fits_scan (&out[0].header, "CRPIX2", "%lf", 1, &dY);
    95   if (scale > 0) {
    96     dX /= scale;
    97     dY /= scale;
    98   } else {
    99     dX *= fabs(scale);
    100     dY *= fabs(scale);
    101   }   
    102   if (status) {
    103     fits_modify (&out[0].header, "CRPIX1", "%lf", 1, dX);
    104     fits_modify (&out[0].header, "CRPIX2", "%lf", 1, dY);
    105   }
     41  Nin  = in[0].Nelements;
     42  Nout = Nin / scale;
    10643
    107   out[0].header.Naxis[0] = nx;
    108   out[0].header.Naxis[1] = ny;
    109   fits_create_matrix (&out[0].header, &out[0].matrix);
    110   temp[0] = 0;
    111   if ((in[0].file[0] != '*') && (in[0].file[0] != '(')) {
    112     strcpy (temp, "*");
    113   }
    114   strcat (temp, in[0].file);
    115   strcpy (out[0].file, temp);
     44  REALLOCATE (out[0].elements, float, Nout);
     45  out[0].Nelements = Nout;
    11646
    117   if (Normalize) {
    118     ALLOCATE (Npix, int, nx*ny);
    119     bzero (Npix, nx*ny*sizeof(int));
    120   }
    121 
    122   if (ExactScale) {
    123     n = scale;
    124     if (n > 0) {
    125       for (j = 0; j < ny; j++) {
    126         for (y = 0; y < n; y++) {
    127           Vout = (float *)(out[0].matrix.buffer) + j*nx;
    128           Vin  = (float *)(in[0].matrix.buffer)  + (j*n + y)*in[0].header.Naxis[0];
    129           if (Normalize) { Vn = Npix + j*nx; }
    130           for (i = 0; i < nx; i++, Vout++) {
    131             for (x = 0; x < n; x++, Vin++) {
    132               if (Ignore && (*Vin == IgnoreValue)) continue;
    133               *Vout += *Vin;
    134               if (Normalize) {(*Vn) ++;}
    135             }
    136             if (Normalize) {Vn ++;}
    137           }
    138         }
    139       }
    140     } else {
    141       n = fabs (n);
    142       for (j = 0; j < in[0].header.Naxis[1]; j++) {
    143         for (y = 0; y < n; y++) {
    144           Vout = (float *)(out[0].matrix.buffer) + (j*n + y)*nx;
    145           Vin  = (float *)(in[0].matrix.buffer)  + j*in[0].header.Naxis[0];
    146           if (Normalize) { Vn = Npix + j*nx; }
    147           for (i = 0; i < in[0].header.Naxis[0]; i++, Vin++) {
    148             if (Ignore && (*Vin == IgnoreValue)) {
    149               Vout += n;
    150               if (Normalize) Vn += n;
    151               continue;
    152             }
    153             for (x = 0; x < n; x++, Vout++) {
    154               *Vout = *Vin;
    155               if (Normalize) {(*Vn) ++; Vn ++;}
    156             }
    157           }
    158         }
    159       }
    160     }
     47  Vin  = in[0].elements;
     48  Vout = out[0].elements;
     49  for (n = j = 0; j < Nout; j++, Vout++) {
     50    *Vout = 0;
     51    for (N = i = 0; (i < scale) && (n < Nin); n++, i++, Vin++) {
     52      if (!finite (*Vin)) continue;
     53      if (Ignore && (*Vin == IgnoreValue)) continue;
     54      *Vout += *Vin;
     55      N ++;
     56    }
    16157    if (Normalize) {
    162       Vn = Npix;
    163       Vout = (float *)out[0].matrix.buffer;
    164       for (i = 0; i < nx*ny; i++, Vout++, Vn++) {
    165         if (*Vn) {
    166           *Vout /= *Vn;
    167         } else {
    168           *Vout = 0;
    169         }
    170       }
    171     }
    172   } else {
    173    
    174     if (Normalize) { fprintf (stderr, "normalize not enabled for fractional scaling\n"); }
    175 
    176     if (scale < 0) scale = 1.0 / fabs(scale);
    177     In = (float *)in[0].matrix.buffer;
    178     Out = (float *)out[0].matrix.buffer;
    179     scale2 = scale*scale;
    180     if (scale > 1) {
    181       for (i = 0; i < Ny; i++) {
    182         y = 0.5 + (i - 0.5) / scale;
    183         fy = 0.5 + MIN (0.5, (y + 0.5) * scale - i);
    184         for (j = 0; j < Nx; j++, In++) {
    185           x = 0.5 + (j - 0.5) / scale;
    186           fx = 0.5 + MIN (0.5, (x + 0.5) * scale - j);
    187           Vout = Out + y*nx + x;
    188           *Vout += fx*fy*(*In);
    189           if (fx < 1) {
    190             *(Vout+1)    += (1-fx)*fy*(*In);
    191           }
    192           if (fy < 1) {
    193             *(Vout+nx) += fx*(1-fy)*(*In);
    194           }
    195           if ((fx < 1) && (fy < 1)) {
    196             *(Vout+1+nx) += (1-fx)*(1-fy)*(*In);
    197           }
    198         }
    199       }
    200     } else {
    201       for (i = 0; i < ny; i++) {
    202         y = 0.5 + (i - 0.5) * scale;
    203         fy = 0.5 + MIN (0.5, (y + 0.5) / scale - i);
    204         for (j = 0; j < nx; j++, Out++) {
    205           x = 0.5 + (j - 0.5) * scale;
    206           fx = 0.5 + MIN (0.5, (x + 0.5) / scale - j);
    207           Vin = In + y*Nx + x;
    208           *Out += *Vin*fx*fy;
    209           if (fx < 1) {
    210             *Out += *(Vin+1)*(1-fx)*fy;
    211           }
    212           if (fy < 1) {
    213             *Out += *(Vin+Nx)*fx*(1-fy);
    214           }
    215           if ((fx < 1) && (fy < 1)) {
    216             *Out += *(Vin+1+Nx)*(1-fx)*(1-fy);
    217           }
    218           *Out = *Out * scale2;
    219         }
     58      if (N > 0) {
     59        *Vout /= (float) N;
     60      } else {
     61        *Vout = 0;
    22062      }
    22163    }
    22264  }
    223 
    224   if (Normalize) free (Npix);
    225 
    22665  return (TRUE);
    227 
    22866}
    229 
  • trunk/Ohana/src/opihi/dvo/Makefile

    r5451 r5850  
    1515INCS    =       -I$(INC) -I$(LINC) -I$(XINC)
    1616LFLAGS  =       -L$(LLIB) -L$(LIB)
    17 LIBS1   =       -lsocket -lnsl -lreadline -ltermcap -ldvo -lFITS -lohana -lm
     17LIBS1   =       -lsocket -lnsl -lreadline -ltermcap -ldvo -lkapa -lFITS -lohana -lX11 -lm
    1818LIBS2   =       -lbasiccmd -ldatacmd -lastrocmd -lshell -ldata
    1919LIBS    =       $(LIBS2) $(LIBS1)
  • trunk/Ohana/src/opihi/dvo/cmpload.c

    r5846 r5850  
    66int cmpload (int argc, char **argv) {
    77 
    8   int i, Noverlay, N, Nin, Nextra, n, Objtype, type;
     8  int i, Noverlay, NOVERLAY, Nstar, N, Nin, Nextra, Objtype, type;
    99  int doneread, done, Nskip, Nbytes, nbytes, Ninstar;
    1010  char *c, *c2;
    11   double *X, *Y, *M;
    1211  double dtmp;
    1312  FILE *f;
    14   char *buffer, *buffer2;
     13  char *buffer;
    1514  int Ximage, Nimage;
    1615  Header header;
     
    4342
    4443  /* find expected number of stars */
    45   fits_scan (&header, "NSTARS", "%d", 1, &nstar);
    46   if (nstar == 0) {
     44  fits_scan (&header, "NSTARS", "%d", 1, &Nstar);
     45  if (Nstar == 0) {
    4746    fprintf (stderr, "ERROR: can't get NSTARS from header\n");
    4847    fits_free_header (&header);
     
    121120      # endif
    122121
    123       dparse (&overlay[Noverlay].x,  1, &buffer[i*BYTES_STAR]);
    124       dparse (&overlay[Noverlay].y,  2, &buffer[i*BYTES_STAR]);
     122      fparse (&overlay[Noverlay].x,  1, &buffer[i*BYTES_STAR]);
     123      fparse (&overlay[Noverlay].y,  2, &buffer[i*BYTES_STAR]);
    125124      overlay[Noverlay].type = KII_OVERLAY_BOX;
    126125      overlay[Noverlay].dx = 5.0;
  • trunk/Ohana/src/opihi/dvo/detrend.c

    r4849 r5850  
    99  int i, Nimage, status, N, TimeSelect;
    1010  char DataBase[256];
    11   unsigned long int tzero, tend;
     11  time_t tzero, tend;
    1212  double trange;
    1313  int TypeSelect, CCDSelect, FilterSelect;
  • trunk/Ohana/src/opihi/dvo/imdata.c

    r5451 r5850  
    88  int *subset, Nsubset;
    99  double trange;
    10   unsigned long tzero, start, stop, TimeReference;
     10  time_t tzero, start, stop, TimeReference;
    1111  Image *image;
    1212  Catalog catalog;
  • trunk/Ohana/src/opihi/dvo/imphot.c

    r5014 r5850  
    33int imphot (int argc, char **argv) {
    44 
    5   unsigned long int tzero;
     5  time_t tzero;
    66  double trange;
    77  int N, GreyScale;
  • trunk/Ohana/src/opihi/dvo/imrough.c

    r4849 r5850  
    1414  double trange;
    1515  float *Vec;
    16   unsigned long tzero, tend, TimeReference;
     16  time_t tzero, tend, TimeReference;
    1717  RegImage *image;
    1818  Vector *vec;
  • trunk/Ohana/src/opihi/dvo/imsearch.c

    r4849 r5850  
    1111  char *Filter, *obstime;
    1212  int Type, Mode, CCD;
    13   unsigned long int tzero;
     13  time_t tzero;
    1414  double trange;
    1515   
  • trunk/Ohana/src/opihi/dvo/lcurve.c

    r5451 r5850  
    177177           timeptr[0].tm_year, timeptr[0].tm_mon+1, timeptr[0].tm_mday);
    178178  free (p);
    179   SendLabel (string, Xgraph, 0);
     179  KapaSendLabel (Xgraph, string, 0);
    180180
    181181  free (RA);
  • trunk/Ohana/src/opihi/include/display.h

    r5846 r5850  
    55# define DISPLAY_H
    66
     7# if (0)
    78typedef struct {
    89  double xmin, xmax, ymin, ymax;
     
    1112  Coords coords;
    1213  int flipeast, flipnorth;
     14  char axis[8], labels[8], ticks[8];
    1315} Graphdata;
     16# endif
    1417
    1518/*** plotting functions ***/
  • trunk/Ohana/src/opihi/lib.data/PlotVectors.c

    r4689 r5850  
    88 
    99  /* tell kapa to look for the incoming image */
    10   SendGraphCommand (Xgraph, 4, "PLOT");
    11 
     10  KiiSendCommand (Xgraph, 4, "PLOT");
     11 
    1212  /* send Xgraph the plot details */
    13   SendGraphMessage (Xgraph, "%8d %8d %d %d %d %d %d %f %f",
    14                     Npts, graphmode[0].style,
    15                     graphmode[0].ptype, graphmode[0].ltype,
    16                     graphmode[0].etype, graphmode[0].ebar, graphmode[0].color,
    17                     graphmode[0].lweight, graphmode[0].size);
    18   SendGraphMessage (Xgraph, "%g %g %g %g",
    19                     graphmode[0].xmin, graphmode[0].xmax,
    20                     graphmode[0].ymin, graphmode[0].ymax);
     13  KiiSendMessage (Xgraph, "%8d %8d %d %d %d %d %d %f %f",
     14                  Npts, graphmode[0].style,
     15                  graphmode[0].ptype, graphmode[0].ltype,
     16                  graphmode[0].etype, graphmode[0].ebar, graphmode[0].color,
     17                  graphmode[0].lweight, graphmode[0].size);
     18  KiiSendMessage (Xgraph, "%g %g %g %g",
     19                  graphmode[0].xmin, graphmode[0].xmax,
     20                  graphmode[0].ymin, graphmode[0].ymax);
    2121  return (TRUE);
    2222}
  • trunk/Ohana/src/opihi/lib.data/graphtools.c

    r4689 r5850  
    4040  set_variable ("YMAX", graphmode[0].ymax);
    4141}
    42 
    43 void ApplyLimits (int Xgraph, Graphdata *graphmode, int apply) {
    44 
    45   if (!apply) return;
    46 
    47   SendGraphCommand (Xgraph, 4, "SLIM");
    48   SendGraphMessage (Xgraph, "%g %g %g %g ", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax);
    49 }
  • trunk/Ohana/src/opihi/lib.data/open_graph.c

    r4689 r5850  
    22# define DEBUG 0
    33
    4 /** this list must match the one in kapa/include/structures.h, and equiv */
    5 # define NGRAPHCOLORS 23
    6 static char GRAPHCOLORS[NGRAPHCOLORS][2][15] = {
    7   {"black",    "0.00 0.00 0.00"},
    8   {"white",    "1.00 1.00 1.00"},
    9   {"red",      "1.00 0.00 0.00"},
    10   {"pink",     "1.00 0.75 0.80"},
    11   {"orange",   "1.00 0.65 0.00"},
    12   {"yellow",   "1.00 1.00 0.00"},
    13   {"wheat",    "0.96 0.87 0.70"},
    14   {"gold",     "1.00 0.84 0.00"},
    15   {"green",    "0.00 1.00 0.00"},
    16   {"darkgreen","0.00 0.40 0.00"},
    17   {"blue",     "0.00 0.00 1.00"},
    18   {"skyblue",  "0.53 0.81 0.92"},
    19   {"indigo",   "0.56 0.16 0.87"},
    20   {"violet",   "1.00 0.00 0.00"},
    21   {"grey10",   "0.10 0.10 0.10"},
    22   {"grey20",   "0.20 0.20 0.20"},
    23   {"grey30",   "0.30 0.30 0.30"},
    24   {"grey40",   "0.40 0.40 0.40"},
    25   {"grey50",   "0.50 0.50 0.50"},
    26   {"grey60",   "0.60 0.60 0.60"},
    27   {"grey70",   "0.70 0.70 0.70"},
    28   {"grey80",   "0.80 0.80 0.80"},
    29   {"grey90",   "0.90 0.90 0.90"}};
    30 
    31   /* we have space for several kapa windows */
     4/* we have space for several kapa windows */
    325# define NXGRAPH 5
    336
     
    5023 
    5124  for (i = 0; i < NXGRAPH; i++) {
    52     if (Xgraph[i] > 0) {
    53       SendGraphCommand (Xgraph[i], 4, "QUIT");
    54     }
     25    KiiClose (Xgraph[i]);
    5526  }
    5627}
     
    8152    graphdata[i].flipeast = TRUE;
    8253    graphdata[i].flipnorth = FALSE;
     54    strcpy (graphdata[i].axis, "2222");
     55    strcpy (graphdata[i].ticks, "2222");
     56    strcpy (graphdata[i].labels, "2222");
    8357  }
    8458}
     
    9468int open_graph (int N) {
    9569
    96   int InitSocket, status, addreslen, Ntry, fd;
    97   char temp[128], socket_name[64], *kapa_exec;
    98   struct sockaddr_un Address;
     70  int fd;
     71  char *kapa_exec;
    9972 
    10073  kapa_exec = get_variable ("KAPA");
     
    10477  }
    10578
    106   sprintf (socket_name, "/tmp/Kapa.XXXXXX");
    107   if ((fd = mkstemp (socket_name)) == -1) {
     79  fd = KiiOpen (kapa_exec, NULL);
     80
     81  if (fd < 0) {
    10882    fprintf (stderr, "error starting kapa\n");
    10983    return (FALSE);
    110   }
    111   close (fd);
    112   unlink (socket_name);
     84  }
    11385
    114   strcpy (Address.sun_path, socket_name);
    115   Address.sun_family = AF_UNIX;
    116   InitSocket = socket (AF_UNIX, SOCK_STREAM, 0);
    117   status = bind (InitSocket, (struct sockaddr *) &Address, sizeof (Address));
    118   status = listen (InitSocket, 1);
    119  
    120   sprintf (temp, "%s %s &", kapa_exec, socket_name);
    121   free (kapa_exec);
    122 
    123 # if DEBUG
    124   fprintf (stderr, "start kapa, press return: %s\n", temp);
    125   fscanf (stdin, "%d", &i);
    126 # else 
    127   system (temp);
    128 # endif
    129  
    130   addreslen =  sizeof (Address);
    131   fcntl (InitSocket, F_SETFL, O_NONBLOCK);
    132 
    133 # define NTRY 200
    134   Ntry = 0;
    135   while (Ntry < NTRY) {
    136     Xgraph[N] = accept (InitSocket, (struct sockaddr *)&Address, &addreslen);
    137     if (Xgraph[N] == -1) {
    138       if (errno == EAGAIN) {
    139         usleep (10000);
    140         Ntry ++;
    141       } else {
    142         Ntry = NTRY;
    143       }
    144     } else {
    145       Ntry = NTRY;
    146     }
    147   }
    148   if (Xgraph[N] < 0) {
    149     fprintf (stderr, "error starting kapa\n");
    150     return (FALSE);
    151   } else {
    152     fcntl (Xgraph[N], F_SETFL, !O_NONBLOCK);
    153     return (TRUE);
    154   }
    155  
     86  Xgraph[N] = fd;
     87  return (TRUE);
    15688}
    15789
     
    226158  graphdata[Active] = data;
    227159}
    228 
    229 int GetColor (char *name) {
    230 
    231   int i;
    232  
    233   for (i = 0; i < NGRAPHCOLORS; i++) {
    234     if (!strcmp (name, GRAPHCOLORS[i][0])) {
    235       return (i);
    236     }   
    237   }
    238   fprintf (stderr, "color may be one of:\n");
    239   for (i = 0; i < NGRAPHCOLORS; i++) {
    240     fprintf (stderr, "  %s\n", GRAPHCOLORS[i][0]);
    241   }
    242   return (-1);
    243 }       
    244 
    245 int SendLabel (char *string, int Xgraph, int mode) {
    246 
    247   SendGraphCommand (Xgraph, 4, "LABL");
    248   SendGraphCommand (Xgraph, 16, "%6d %6d", strlen (string), mode);
    249   write (Xgraph, string, strlen (string));
    250   return (TRUE);
    251 }
    252 
    253 /* send a message of arbitrary size, sending the size first */
    254 int SendGraphMessage (int device, char *format, ...) {
    255 
    256   int Nbyte, status;
    257   char tmp;
    258   va_list argp; 
    259 
    260   va_start (argp, format);
    261   Nbyte = vsnprintf (&tmp, 0, format, argp);
    262   va_end (argp);
    263 
    264   if (!Nbyte) return (FALSE);
    265 
    266   va_start (argp, format);
    267   SendGraphCommand (device, 16, "NBYTES: %6d", Nbyte);
    268   status = SendGraphCommandV (device, Nbyte, format, argp);
    269   va_end (argp);
    270   return (status);
    271 }
    272 
    273 int SendGraphCommand (int device, int length, char *format, ...) {
    274 
    275   int status;
    276   va_list argp; 
    277 
    278   va_start (argp, format);
    279   status = SendGraphCommandV (device, length, format, argp);
    280   va_end (argp);
    281   return (status);
    282 }
    283  
    284 int SendGraphCommandV (int device, int length, char *format, va_list argp) {
    285 
    286   char *string;
    287 
    288   /* I allocated and zero 1 extra byte */
    289   ALLOCATE (string, char, length + 1);
    290   memset (string, 0, length + 1);
    291   vsnprintf (string, length + 1, format, argp);
    292 
    293   /* fprintf (stderr, "msg: %s\n", string); */
    294   write (device, string, length);
    295   free (string);
    296   return (TRUE);
    297 }
  • trunk/Ohana/src/opihi/mana/Makefile

    r5846 r5850  
    1515INCS    =       -I$(INC) -I$(LINC) -I$(XINC)
    1616LFLAGS  =       -L$(LLIB) -L$(LIB)
    17 LIBS1   =       -lsocket -lnsl -lreadline -ltermcap -ldvo -lkapa -lFITS -lohana -lm
     17LIBS1   =       -lsocket -lnsl -lreadline -ltermcap -ldvo -lkapa -lFITS -lohana -lX11 -lm
    1818LIBS2   =       -lbasiccmd -ldatacmd -lastrocmd -lshell -ldata
    1919LIBS    =       $(LIBS2) $(LIBS1)
  • trunk/Ohana/src/opihi/pantasks/Makefile

    r5242 r5850  
    1515INCS    =       -I$(INC) -I$(LINC) -I$(XINC)
    1616LFLAGS  =       -L$(LLIB) -L$(LIB)
    17 LIBS1   =       -lsocket -lnsl -lreadline -ltermcap -ldvo -lFITS -lohana -lm
     17LIBS1   =       -lsocket -lnsl -lreadline -ltermcap -ldvo -lkapa -lFITS -lohana -lX11 -lm
    1818LIBS2   =       -lbasiccmd -ldatacmd -lastrocmd -lshell -ldata
    1919LIBS    =       $(LIBS2) $(LIBS1)
  • trunk/Ohana/src/opihi/pclient/Makefile

    r5242 r5850  
    1515INCS    =       -I$(INC) -I$(LINC) -I$(XINC)
    1616LFLAGS  =       -L$(LLIB) -L$(LIB)
    17 LIBS1   =       -lsocket -lnsl -lreadline -ltermcap -lFITS -lohana -lm
     17LIBS1   =       -lsocket -lnsl -lreadline -ltermcap -lkapa -lFITS -lohana -lX11 -lm
    1818LIBS2   =       -lbasiccmd -lshell -ldata
    1919LIBS    =       $(LIBS2) $(LIBS1)
  • trunk/Ohana/src/opihi/pcontrol/Makefile

    r5242 r5850  
    1515INCS    =       -I$(INC) -I$(LINC) -I$(XINC)
    1616LFLAGS  =       -L$(LLIB) -L$(LIB)
    17 LIBS1   =       -lsocket -lnsl -lreadline -ltermcap -lFITS -lohana -lm
     17LIBS1   =       -lsocket -lnsl -lreadline -ltermcap -lkapa -lFITS -lohana -lX11 -lm
    1818LIBS2   =       -lbasiccmd -lshell -ldata
    1919LIBS    =       $(LIBS2) $(LIBS1)
Note: See TracChangeset for help on using the changeset viewer.