IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

updates from eam_branches/20091201

Location:
trunk/Ohana/src/opihi
Files:
14 edited
9 copied

Legend:

Unmodified
Added
Removed
  • 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.