IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26891


Ignore:
Timestamp:
Feb 10, 2010, 7:24:46 PM (16 years ago)
Author:
eugene
Message:

updates from eam_branches/20091201

Location:
trunk/Ohana/src
Files:
26 edited
10 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/src/psps_ids.c

  • trunk/Ohana/src/kapa2/include/constants.h

    r25757 r26891  
    1111
    1212# define NCHANNELS 3
    13 # define NPIXELS_DYNAMIC 4600
     13# define NPIXELS_DYNAMIC 128
    1414
    1515// XXX for the moment, this is set to match the values in SetColorScale3D_CC
    16 # define NPIXELS_STATIC 4600
     16# define NPIXELS_STATIC 128
    1717
    1818# define PAD1  3
  • trunk/Ohana/src/kapa2/src/ColorHistogram.c

    r16061 r26891  
    174174    node->pixel = current[0];
    175175    current[0] ++;
    176     assert (current[0] <= Npixels);
     176    assert (current[0] < Npixels);
    177177    return TRUE;
    178178  }
  • trunk/Ohana/src/kapa2/src/EraseOverlay.c

    r14590 r26891  
    88  KapaImageWidget *image;
    99
     10  // We have to accept the incoming message even if we cannot perform the action
     11  KiiScanCommand (sock, 16, "%*s %d", &N);
     12
    1013  graphic = GetGraphic();
    1114  section = GetActiveSection();
    1215  image = section->image;
    1316  if (image == NULL) return (TRUE);
    14 
    15   KiiScanCommand (sock, 16, "%*s %d", &N);
    1617
    1718  if (N > NOVERLAYS) {
  • trunk/Ohana/src/kapa2/src/LoadPicture.c

    r25757 r26891  
    7373    if (status == 0) {  /* No more pipe */
    7474      fprintf (stderr, "error: pipe closed\n");
     75      fcntl (sock, F_SETFL, !O_NONBLOCK); 
    7576      return (FALSE);
    7677    }
     
    9293  SetColorScale (graphic, image);
    9394
    94   SetColorScale (graphic, image);
    95 
    9695  if (!USE_XWINDOW) return (TRUE);
    9796
  • trunk/Ohana/src/kapa2/src/PNGit.c

    r13479 r26891  
    1616
    1717  /* expect a line telling the number of bytes and a filename */
    18   status = read (sock, filename, 16);
    19   filename[16] = 0;
    20   sscanf (filename, "%*s %d", &Nbytes);
    21   status = read (sock, filename, Nbytes);
    22   filename[status] = 0; /* make the string easy to parse */
     18  KiiScanMessage (sock, "%s", filename);
    2319
    2420  f = fopen (filename, "w");
  • trunk/Ohana/src/kapa2/src/PPMit.c

    r13479 r26891  
    1313
    1414  /* expect a line telling the number of bytes and a filename */
    15   status = read (sock, filename, 16);
    16   filename[16] = 0;
    17   sscanf (filename, "%*s %d", &Nbytes);
    18   status = read (sock, filename, Nbytes);
    19   filename[status] = 0; /* make the string easy to parse */
     15  KiiScanMessage (sock, "%s", filename);
    2016
    2117  f = fopen (filename, "w");
  • trunk/Ohana/src/kapa2/src/Resize.c

    r21153 r26891  
    1111  graphic = GetGraphic();
    1212
     13  // must scan the message before possible return
    1314  KiiScanMessage (sock, "%d %d", &NX, &NY);
    1415
  • trunk/Ohana/src/kapa2/src/SaveOverlay.c

    r13479 r26891  
    99  KapaImageWidget *image;
    1010
     11  KiiScanMessage (sock, "%*s %d %s", &N, filename);
     12 
    1113  section = GetActiveSection();
    1214  image   = section->image;
    1315  if (image == NULL) return (TRUE);
    1416
    15   KiiScanMessage (sock, "%*s %d %s", &N, filename);
    16  
    1717  f = fopen (filename, "w");
    1818  if (f == NULL) {
  • trunk/Ohana/src/kapa2/src/SetColorScale.c

    r25757 r26891  
    3434  float slope;
    3535  float start;
    36   unsigned short MaxValue;
     36  unsigned short MaxValue, NANValue;
    3737  Matrix *matrix;
    3838
    3939  // define the color transform parameters
    40   MaxValue = graphic[0].Npixels - 1;
     40  NANValue = graphic[0].Npixels - 1;
     41  MaxValue = graphic[0].Npixels - 2;
    4142  if (image[0].image[0].range != 0.0) {
    42     slope = graphic[0].Npixels / image[0].image[0].range;
    43     start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;
     43    slope = (graphic[0].Npixels - 1) / image[0].image[0].range;
     44    start = slope * image[0].image[0].zero;
    4445  } else {
    4546    slope = 1.0;
     
    6364  // convert pixel data values to pixel index values (0 - Npixel)
    6465  for (i = 0; i < nPixels; i++, iData++, oData++) {
     66    if (isnan(*iData) || isinf(*iData)) {
     67      *oData = NANValue;
     68      continue;
     69    }
    6570    value = *iData * slope - start;
    66     if (value < 0) value = 0;
    67     if (value > MaxValue) value = MaxValue;
     71    if (value < 0) {
     72      *oData = 0;
     73      continue;
     74    }
     75    if (value > MaxValue) {
     76      *oData = MaxValue;
     77      continue;
     78    }
    6879    *oData = value;
    6980  }
     
    169180  if (DX != image[0].channel[KAPA_CHANNEL_BLUE].matrix.Naxis[0]) return FALSE;
    170181  if (DY != image[0].channel[KAPA_CHANNEL_BLUE].matrix.Naxis[1]) return FALSE;
     182
     183  // XXX a bit bogus: we are going to store a special color at Npixels-1 for
     184  // marking the NAN pixels. 
     185  {
     186      // XXX set pure green for now
     187      graphic[0].cmap[graphic[0].Npixels-1].red = 0;
     188      graphic[0].cmap[graphic[0].Npixels-1].green = 0xffff;
     189      graphic[0].cmap[graphic[0].Npixels-1].blue = 0;
     190  } 
    171191
    172192  // create the top-level cube
     
    214234  // convert histogram 3D values to cmap colors
    215235  Npixels = 0;
    216   CCNodeSetColorMap (cube, graphic[0].cmap, graphic[0].Npixels, &Npixels);
     236  CCNodeSetColorMap (cube, graphic[0].cmap, graphic[0].Npixels - 1, &Npixels);
    217237
    218238  // store the colors
  • trunk/Ohana/src/kapa2/src/SetColormap.c

    r25757 r26891  
    1010    VAR = tmp; \
    1111  } }   
     12
     13// the image arrives from the client program as an array of floats, stored in image->matrix.
     14// whenever we load a new image or change tv channels, we need to map the currently active
     15// image from float to pixel index (image->pixmap).  When we actually display (or change the
     16// display of) an image, we simply remap the lit pixels (in Remap32.c, etc).
    1217
    1318int SetColormap (char *name) {
     
    2631  }
    2732
     33  // XXX a bit bogus: we are going to store a special color at Npixels-1 for
     34  // marking the NAN pixels. 
     35  {
     36      // XXX set pure green for now
     37      graphic[0].cmap[graphic[0].Npixels-1].red = 0;
     38      graphic[0].cmap[graphic[0].Npixels-1].green = 0xffff;
     39      graphic[0].cmap[graphic[0].Npixels-1].blue = 0;
     40  } 
     41
    2842  // very simple color model: evenly spaced cube
    2943  if (!strcasecmp (name, "ruffcolor")) {
    3044      graphic[0].nRed  = pow (graphic[0].Npixels, 0.333);
    3145      graphic[0].nBlue = pow (graphic[0].Npixels, 0.333);
    32       graphic[0].nGreen = graphic[0].Npixels / (graphic[0].nRed * graphic[0].nBlue);
     46      graphic[0].nGreen = (graphic[0].Npixels - 1) / (graphic[0].nRed * graphic[0].nBlue);
    3347
    3448      // red,green,blue are values in range 0x0000 to 0xffff
     
    4862          }
    4963      }
     64      fprintf (stderr, "ruff Npix: %d vs %d\n", i, graphic[0].Npixels);
    5065
    5166      // all other modes are 1D: set the flag:
     
    5873
    5974  // red,green,blue are values in range 0x0000 to 0xffff
    60   scale = 0xffff / (graphic[0].Npixels - 1);
     75  scale = 0xffff / (graphic[0].Npixels - 2);
    6176
    6277  /* greyscale */
    6378  if ((!strcasecmp (name, "grayscale")) || (!strcasecmp (name, "greyscale"))) {
    64     for (i = 0; i < graphic[0].Npixels; i++) { 
     79    for (i = 0; i < graphic[0].Npixels - 1; i++) { 
    6580      SETVALUE (graphic[0].cmap[i].red,   0xffff - i*scale, 0, 0xffff);
    6681      SETVALUE (graphic[0].cmap[i].green, 0xffff - i*scale, 0, 0xffff);
     
    7287  /* -grayscale */
    7388  if ((!strcasecmp (name, "-grayscale")) || (!strcasecmp (name, "-greyscale"))) {
    74     for (i = 0; i < graphic[0].Npixels; i++) { 
     89    for (i = 0; i < graphic[0].Npixels - 1; i++) { 
    7590      SETVALUE (graphic[0].cmap[i].red,   i*scale, 0, 0xffff);
    7691      SETVALUE (graphic[0].cmap[i].green, i*scale, 0, 0xffff);
     
    102117      graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
    103118    }
    104     for (i = (int)(0.75*graphic[0].Npixels); i < graphic[0].Npixels; i++) { 
     119    for (i = (int)(0.75*graphic[0].Npixels); i < graphic[0].Npixels - 1; i++) { 
    105120      graphic[0].cmap[i].red   = 0xffff;
    106121      graphic[0].cmap[i].green = 0xffff;
     
    134149    }
    135150    blueRef  = 0.75*graphic[0].Npixels*scale*4.0;
    136     for (i = (int)(0.75*graphic[0].Npixels); i < graphic[0].Npixels; i++) { 
     151    for (i = (int)(0.75*graphic[0].Npixels); i < graphic[0].Npixels - 1; i++) { 
    137152      graphic[0].cmap[i].red   = 0xffff;
    138153      graphic[0].cmap[i].green = 0xffff;
  • trunk/Ohana/src/libkapa/src/KiiOverlay.c

    r15620 r26891  
    9292
    9393  write (fd, textdata, Ntextdata);
    94   KiiWaitAnswer (fd, "DONE");
     94  KiiWaitAnswer (fd, "DONE"); // this 'DONE' notes the end of the textdata buffer
    9595
    9696  free (buffer);
    9797  free (textdata);
    9898
    99   KiiWaitAnswer (fd, "DONE");
     99  KiiWaitAnswer (fd, "DONE"); // this 'DONE' notes the end of the command
    100100  return (TRUE);
    101101}
  • trunk/Ohana/src/opihi/cmd.astro/mkgauss.c

    r7917 r26891  
    1111  Buffer *buf;
    1212
    13   Xo = Yo = 0;
     13  // this should be Nx/2, Ny/2 if not set
     14  Xo = Yo = NAN;
    1415  if ((N = get_argument (argc, argv, "-c"))) {
    1516    remove_argument (N, &argc, argv);
     
    3031  Ny = buf[0].header.Naxis[1];
    3132 
     33  if (isnan(Xo)) Xo = Nx / 2;
     34  if (isnan(Yo)) Yo = Ny / 2;
     35
    3236  /* gaussian parameters */
    3337  Sig_x = atof (argv[2]);
  • trunk/Ohana/src/opihi/cmd.astro/profile.c

    r20936 r26891  
    3131  ResetVector (yvec, OPIHI_FLT, (int)SQ(2*N+1));
    3232
    33   bzero (yvec[0].elements.Flt, (int)SQ(2*N+1)*sizeof(opihi_flt)+1);
     33  bzero (yvec[0].elements.Flt, (int)SQ(2*N+1)*sizeof(opihi_flt));
    3434  V = (float *)(buf[0].matrix.buffer);
    3535  Npt = 0;
    3636  Nx = buf[0].matrix.Naxis[0];
    37   for (i = sx - N; i < sx + N; i++) {
    38     for (j = sy - N; j < sy + N; j++, Npt++) {
     37  for (i = sx - N; i <= sx + N; i++) {
     38    for (j = sy - N; j <= sy + N; j++, Npt++) {
    3939      yvec[0].elements.Flt[Npt] = V[i + j*Nx];
    40       xvec[0].elements.Flt[Npt] = hypot (i - sx, j - sy);
     40      xvec[0].elements.Flt[Npt] = hypot (i + 0.5 - sx, j + 0.5 - sy);
    4141    }
    4242  }
  • trunk/Ohana/src/opihi/cmd.astro/star.c

    r7917 r26891  
    2424  if ((argc != 4) && (argc != 5)) {
    2525    gprint (GP_ERR, "USAGE: star (buffer) x y [dx] [-border N] [-sat cnts]\n");
     26    gprint (GP_ERR, " dx is the aperture diameter, but is adjusted up to the next odd number\n");
    2627    return (FALSE);
    2728  }
  • trunk/Ohana/src/opihi/cmd.basic/Makefile

    r25965 r26891  
    3939$(SRC)/mkdir.$(ARCH).o     \
    4040$(SRC)/module.$(ARCH).o     \
     41$(SRC)/nop.$(ARCH).o        \
    4142$(SRC)/output.$(ARCH).o     \
    4243$(SRC)/quit.$(ARCH).o        \
  • trunk/Ohana/src/opihi/cmd.basic/init.c

    r25965 r26891  
    2525int mkdir_opihi     PROTO((int, char **));
    2626int module          PROTO((int, char **));
     27int nop             PROTO((int, char **));
    2728int output          PROTO((int, char **));
    2829int pwd             PROTO((int, char **));
     
    6667  {1, "?",             list_help,          "list commands *"},
    6768  {1, "??",            list_vars,          "list variables *"},
     69  {1, "#",             nop,                "a NOP function"},
    6870  {1, "local",         local,              "define local variables"},
    6971  {1, "macro",         macro,              "deal with the macros *"},
     
    7173  {1, "mkdir",         mkdir_opihi,        "built-in mkdir command"},
    7274  {1, "module",        module,             "load script file from the modules directories"},
     75  {1, "nop",           nop,                "a NOP function"},
    7376  {1, "output",        output,             "redirect output to file"},
    7477  {1, "pwd",           pwd,                "print current working directory"},
  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r25757 r26891  
    5353$(SRC)/ungridify.$(ARCH).o     \
    5454$(SRC)/histogram.$(ARCH).o      \
     55$(SRC)/hermitian1d.$(ARCH).o    \
     56$(SRC)/hermitian2d.$(ARCH).o    \
    5557$(SRC)/imcut.$(ARCH).o          \
    5658$(SRC)/imhist.$(ARCH).o \
     
    6971$(SRC)/load.$(ARCH).o           \
    7072$(SRC)/lookup.$(ARCH).o \
     73$(SRC)/matrix.$(ARCH).o \
    7174$(SRC)/mkrgb.$(ARCH).o  \
    7275$(SRC)/mcreate.$(ARCH).o        \
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r25757 r26891  
    4242int ungridify        PROTO((int, char **));
    4343int histogram        PROTO((int, char **));
     44int hermitian1d      PROTO((int, char **));
     45int hermitian2d      PROTO((int, char **));
    4446int imcut            PROTO((int, char **));
    4547int imhist           PROTO((int, char **));
     
    5860int load             PROTO((int, char **));
    5961int lookup           PROTO((int, char **));
     62int matrix           PROTO((int, char **));
    6063int mkrgb            PROTO((int, char **));
    6164int mcreate          PROTO((int, char **));
     
    172175  {1, "header",       header,           "print image header"},
    173176  {1, "histogram",    histogram,        "generate histogram from vector"},
     177  {1, "hermitian1d",  hermitian1d,      "generate 1-D Hermitian Polynomial"},
     178  {1, "hermitian2d",  hermitian2d,      "generate 2-D Hermitian Polynomial"},
    174179  {1, "imbin",        rebin,            "rebin image data by factor of N"},
    175180  {1, "imclip",       imclip,           "clip values in an image to be within a range"},
     
    195200  {1, "minterp",      minterp,          "interpolate image pixels"},
    196201  {1, "iminterp",     minterp,          "interpolate image pixels"},
     202  {1, "matrix",       matrix,           "matrix math operations"},
    197203  {1, "mkrgb",        mkrgb,            "convert 3 images to rgb jpeg (use Kapa for better control)"},
    198204  {1, "mset",         mset,             "insert a vector in an image"},
  • trunk/Ohana/src/opihi/cmd.data/svd.c

    r20936 r26891  
    5757  /* use a bcopy instead? */
    5858
     59  // try C.R. Bond's version -- requires matrices in the form A[row][col] not A[row*Ncol + col]
     60  if (1) {
     61      int j;
     62      double **a, **u, **v, *q;
     63      ALLOCATE (a, double *, Ny);
     64      ALLOCATE (u, double *, Ny);
     65      ALLOCATE (v, double *, Ny);
     66      for (i = 0; i < Ny; i++) {
     67          ALLOCATE (a[i], double, Nx);
     68          ALLOCATE (u[i], double, Nx);
     69          ALLOCATE (v[i], double, Nx);
     70      }   
     71      ALLOCATE (q, double, Nx);
     72
     73      for (j = 0; j < Ny; j++) {
     74          for (i = 0; i < Nx; i++) {
     75              a[j][i] = A[j*Nx + i];
     76              u[j][i] = 0;
     77              v[j][i] = 0;
     78          }
     79      }
     80      for (i = 0; i < Nx; i++) {
     81          q[i] = 0;
     82      }
     83
     84      status = svdcmp_bond_raw (Ny, Nx, 1, 1, FLT_EPSILON, 1e-6, a, q, u, v);
     85      fprintf (stderr, "status: %d\n", status);
     86
     87      // copy u q v back to U W V:
     88      for (j = 0; j < Ny; j++) {
     89          for (i = 0; i < Nx; i++) {
     90              U[j*Nx + i] = u[j][i];
     91              V[j*Nx + i] = v[j][i];
     92          }
     93      }
     94      for (i = 0; i < Nx; i++) {
     95          W[i] = q[i];
     96      }
     97
     98      for (j = 0; j < Ny; j++) {
     99          free(a[j]);
     100          free(u[j]);
     101          free(v[j]);
     102      }
     103      free (a);
     104      free (u);
     105      free (v);
     106      free (q);
     107
     108      return TRUE;
     109  }
     110
    59111  status = svdcmp (U, W, V, Nx, Ny);
    60112  if (!status) {
  • trunk/Ohana/src/opihi/include/data.h

    r26258 r26891  
    8989int svdcmp (float *a, opihi_flt *w, float *v, int Nx, int Ny);
    9090
     91/* in svdcmp_bond_raw.c */
     92int svdcmp_bond_raw(int m, int n, int withu, int withv, double eps, double tol, double **a, double *q, double **u, double **v);
     93
    9194/* mrqmin.c */
    9295opihi_flt mrqcof (opihi_flt *x, opihi_flt *y, opihi_flt *dy, int Npts,
     
    162165void FreeBooks (void);
    163166
     167/* hermitian functions */
     168double hermitian_polynomial (double x, int order);
     169double hermitian_00(double x);
     170double hermitian_01(double x);
     171double hermitian_02(double x);
     172double hermitian_03(double x);
     173double hermitian_04(double x);
     174double hermitian_05(double x);
     175double hermitian_06(double x);
     176double hermitian_07(double x);
     177double hermitian_08(double x);
     178double hermitian_09(double x);
     179double hermitian_10(double x);
     180
    164181# endif
  • trunk/Ohana/src/opihi/include/pclient.h

    r21153 r26891  
    5252void FreePclient (void);
    5353void gotsignal (int signum);
     54void pipe_signal (int signum);
     55void pipe_signal_clear(void);
    5456
    5557# define DTIME(A,B) ((A.tv_sec - B.tv_sec) + 1e-6*(A.tv_usec - B.tv_usec))
  • trunk/Ohana/src/opihi/lib.data/Makefile

    r16117 r26891  
    2020$(SDIR)/fft.$(ARCH).o                   \
    2121$(SDIR)/svdcmp.$(ARCH).o                \
     22$(SDIR)/svdcmp_bond_raw.$(ARCH).o               \
    2223$(SDIR)/convert.$(ARCH).o               \
    2324$(SDIR)/bracket.$(ARCH).o               \
     
    2728$(SDIR)/precess.$(ARCH).o               \
    2829$(SDIR)/starfuncs.$(ARCH).o             \
     30$(SDIR)/hermitian.$(ARCH).o             \
    2931$(SDIR)/gaussian.$(ARCH).o              \
    3032$(SDIR)/graphtools.$(ARCH).o            \
  • trunk/Ohana/src/opihi/lib.shell/stack_math.c

    r20936 r26891  
    628628
    629629# define MS_FUNC(OP) {                                  \
    630     if (V2->type == 's')  {                             \
     630    if (V2->type == 'S')  {                             \
    631631      opihi_flt M2 = V2[0].FltValue;                    \
    632632      for (i = 0; i < Nx*Ny; i++, out++, M1++) {        \
     
    635635      break;                                            \
    636636    }                                                   \
    637     if (V2->type == 'S')  {                             \
     637    if (V2->type == 's')  {                             \
    638638      opihi_int M2 = V2[0].IntValue;                    \
    639639      for (i = 0; i < Nx*Ny; i++, out++, M1++) {        \
     
    704704
    705705# define SM_FUNC(OP) {                                  \
    706     if (V1->type == 's')  {                             \
     706    if (V1->type == 'S')  {                             \
    707707      opihi_flt M1 = V1[0].FltValue;                    \
    708708      for (i = 0; i < Nx*Ny; i++, out++, M2++) {        \
     
    711711      break;                                            \
    712712    }                                                   \
    713     if (V1->type == 'S')  {                             \
     713    if (V1->type == 's')  {                             \
    714714      opihi_int M1 = V1[0].IntValue;                    \
    715715      for (i = 0; i < Nx*Ny; i++, out++, M2++) {        \
  • trunk/Ohana/src/opihi/pclient/ChildOps.c

    r26257 r26891  
    11# include "pclient.h"
    2 #include <sys/ioctl.h>
    3 #include <sys/types.h>
    4 #include <unistd.h>
     2# include <sys/ioctl.h>
     3# include <sys/types.h>
     4# include <unistd.h>
    55// #include <stropts.h>
    66
     
    6767    case 0:   /* pipe is closed */
    6868      /** change child state? **/
     69      pipe_signal_clear();
    6970      break;
    7071    default:  /* data in pipe */
     
    8182    case 0:   /* pipe is closed */
    8283      /** change child state? **/
     84      pipe_signal_clear();
    8385      break;
    8486    default:  /* data in pipe */
  • trunk/Ohana/src/opihi/pclient/pclient.c.in

    r18123 r26891  
    4646
    4747  /* ignore the history file.  to change this, see, eg, mana.c */
    48   signal (SIGPIPE, gotsignal);
     48
     49  /* We do not want pclient to exit just because the connection to the
     50     child process is broken.  However, if the connection to the parent
     51     process is broken, we should exit.  To handle this, we define
     52     pipe_signal() which tracks the number of times it has been called.
     53     Every time an I/O operation on the child file descriptor raises this signal,
     54     we need to manage the crashed child and then clear the count.  Signals raised by
     55     I/O to the parent do not result in clearing the count.  If the count passes a maximum,
     56     we exit pclient */
     57     
     58  signal (SIGPIPE, pipe_signal);
    4959  signal (SIGTSTP, gotsignal);
    5060  signal (SIGTTIN, gotsignal);
     
    6777}
    6878
     79static int Npipe = 0;
     80
     81void pipe_signal (int signum) {
     82  Npipe ++;
     83  if (Npipe > 100) {
     84    exit (5);
     85  }
     86  gprint (GP_ERR, "closed pipe : did child process exit unexpectedly?\n");
     87  return;
     88}
     89
     90void pipe_signal_clear(void) {
     91  Npipe = 0;
     92}
     93
    6994void gotsignal (int signum) {
    7095  gprint (GP_ERR, "got signal : %d\n", signum);
Note: See TracChangeset for help on using the changeset viewer.