IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 29, 2015, 6:52:41 AM (11 years ago)
Author:
eugene
Message:

merge changes from ipp-20150112

Location:
trunk
Files:
21 edited
6 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Ohana

    • Property svn:mergeinfo deleted
  • trunk/Ohana/src/opihi/cmd.astro/Makefile

    r37807 r38062  
    2929$(SRC)/czplot.$(ARCH).o    \
    3030$(SRC)/cdensify.$(ARCH).o          \
     31$(SRC)/cdhistogram.$(ARCH).o       \
    3132$(SRC)/drizzle.$(ARCH).o           \
    3233$(SRC)/flux.$(ARCH).o              \
  • trunk/Ohana/src/opihi/cmd.astro/cdensify.c

    r37807 r38062  
    111111    switch (PSFTYPE) {
    112112      case IS_DOT:
    113         RD_to_XY (&x, &y, rn, *d, &graphmode.coords);
    114         Xb = (x - Xmin) / dX;
    115         Yb = (y - Ymin) / dY;
    116 
    117113        RD_to_XY (&x, &y, rn, *d, &newcoords);
    118114        Xb = (int) x;
  • trunk/Ohana/src/opihi/cmd.astro/init.c

    r37807 r38062  
    1414int czcplot                 PROTO((int, char **));
    1515int cdensify                PROTO((int, char **));
     16int cdhistogram             PROTO((int, char **));
    1617int drizzle                 PROTO((int, char **));
    1718int flux                    PROTO((int, char **));
     
    7778  {1, "czplot",      czplot,       "plot scaled vectors in sky coordinates"},
    7879  {1, "czcplot",     czcplot,      "plot color-scaled vectors in sky coordinates"},
    79   {1, "cdensify",    cdensify,      "vectors to density history on projection"},
     80  {1, "cdensify",    cdensify,     "vectors to density history on projection"},
     81  {1, "cdhistogram", cdhistogram,  "vectors to 3D histogram on projection"},
    8082  {1, "drizzle",     drizzle,      "transform image to image"},
    8183  {1, "flux",        flux,         "flux in a convex contour"},
  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r37807 r38062  
    6161$(SRC)/ungridify.$(ARCH).o     \
    6262$(SRC)/histogram.$(ARCH).o      \
     63$(SRC)/tdhistogram.$(ARCH).o    \
    6364$(SRC)/hermitian1d.$(ARCH).o    \
    6465$(SRC)/hermitian2d.$(ARCH).o    \
     
    8990$(SRC)/medacc.$(ARCH).o \
    9091$(SRC)/mget.$(ARCH).o           \
     92$(SRC)/mget3d.$(ARCH).o         \
    9193$(SRC)/minterpolate.$(ARCH).o   \
    9294$(SRC)/medimage.$(ARCH).o       \
     
    130132$(SRC)/imspline_apply.$(ARCH).o \
    131133$(SRC)/imspline_construct.$(ARCH).o \
     134$(SRC)/squash3d.$(ARCH).o          \
    132135$(SRC)/imstats.$(ARCH).o           \
    133136$(SRC)/style.$(ARCH).o             \
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r37807 r38062  
    5151int ungridify        PROTO((int, char **));
    5252int histogram        PROTO((int, char **));
     53int tdhistogram      PROTO((int, char **));
    5354int hermitian1d      PROTO((int, char **));
    5455int hermitian2d      PROTO((int, char **));
     
    8081int medacc           PROTO((int, char **));
    8182int mget             PROTO((int, char **));
     83int mget3d           PROTO((int, char **));
    8284int minterp          PROTO((int, char **));
    8385int medimage_command PROTO((int, char **));
     
    117119int imspline_apply   PROTO((int, char **));
    118120int imspline_construct PROTO((int, char **));
     121int squash3d         PROTO((int, char **));
    119122int stats            PROTO((int, char **));
    120123int imstats          PROTO((int, char **));
     
    217220  {1, "header",       header,           "print image header"},
    218221  {1, "histogram",    histogram,        "generate histogram from vector"},
     222  {1, "tdhistogram",  tdhistogram,      "generate 2D histogram image from vector set"},
    219223  {1, "hermitian1d",  hermitian1d,      "generate 1-D Hermitian Polynomial"},
    220224  {1, "hermitian2d",  hermitian2d,      "generate 2-D Hermitian Polynomial"},
     
    243247  {1, "medacc",       medacc,           "accumulate vector values in another vector"},
    244248  {1, "mget",         mget,             "extract a vector from an image"},
     249  {1, "mget3d",       mget3d,           "extract a vector from a 3D image"},
    245250  {1, "imget",        mget,             "extract a vector from an image"},
    246251  {1, "minterp",      minterp,          "interpolate image pixels"},
     
    289294  {1, "imspline.apply", imspline_apply, "apply spline fit to generate an image"},
    290295  {1, "imspline.const", imspline_construct, "create spline 2nd deriv. terms"},
     296  {1, "squash3d",     squash3d,         "squash 3d buffer to 2d"},
    291297  {1, "stats",        imstats,          "statistics on a portion of an image"},
    292298  {1, "style",        style,            "set the style for graph plots"},
  • trunk/Ohana/src/opihi/cmd.data/interpolate.c

    r20936 r38062  
    11# include "data.h"
    22
     3// XXX use 'threshold' to interpolate to a value
    34int interpolate (int argc, char **argv) {
    45
     
    1112    gprint (GP_ERR, "USAGE: interpolate Xi Yi Xo Yo\n");
    1213    gprint (GP_ERR, "  Xi Yi - sorted reference vectors\n");
    13     gprint (GP_ERR, "  Xo    - output positions\n");
    14     gprint (GP_ERR, "  Yo    - output values\n");
     14    gprint (GP_ERR, "  Xo    - output positions (vector)\n");
     15    gprint (GP_ERR, "  Yo    - output values (vector)\n");
     16    gprint (GP_ERR, "  (use 'threshold' to interpolate to a value)\n");
    1517    return (FALSE);
    1618  }
     
    1820  if ((xin  = SelectVector (argv[1],  OLDVECTOR, TRUE)) == NULL) return (FALSE);
    1921  if ((yin  = SelectVector (argv[2],  OLDVECTOR, TRUE)) == NULL) return (FALSE);
     22
     23  // target positions are a vector
    2024  if ((xout = SelectVector (argv[3],  OLDVECTOR, TRUE)) == NULL) return (FALSE);
    2125  if ((yout = SelectVector (argv[4],  ANYVECTOR, TRUE)) == NULL) return (FALSE);
  • trunk/Ohana/src/opihi/cmd.data/mcreate.c

    r9275 r38062  
    33int mcreate (int argc, char **argv) {
    44 
    5   int Nx, Ny;
     5  int N;
    66  Buffer *buf;
    77
     8  int Nz = 0;
     9  if ((N = get_argument (argc, argv, "-nz"))) {
     10    remove_argument (N, &argc, argv);
     11    Nz = atoi (argv[N]);
     12    remove_argument (N, &argc, argv);
     13  }
     14
    815  if (argc != 4) {
    9     gprint (GP_ERR, "USAGE: mcreate <buffer> Nx Ny\n");
     16    gprint (GP_ERR, "USAGE: mcreate <buffer> Nx Ny [-nz Nz]\n");
    1017    return (FALSE);
    1118  }
    1219
    1320  if ((buf = SelectBuffer (argv[1], ANYBUFFER, TRUE)) == NULL) return (FALSE);
    14   Nx = atof (argv[2]);
    15   Ny = atof (argv[3]);
     21  int Nx = atof (argv[2]);
     22  int Ny = atof (argv[3]);
    1623
    1724  /* I should encapsulate this in a create_default_buffer */
    1825  gfits_free_matrix (&buf[0].matrix);
    1926  gfits_free_header (&buf[0].header);
    20   CreateBuffer (buf, Nx, Ny, -32, 1.0, 0.0);
     27
     28  if (Nz) {
     29    CreateBuffer3D (buf, Nx, Ny, Nz, -32, 1.0, 0.0);
     30  } else {
     31    CreateBuffer (buf, Nx, Ny, -32, 1.0, 0.0);
     32  }
    2133  return (TRUE);
    2234}
  • trunk/Ohana/src/opihi/cmd.data/rd.c

    r29938 r38062  
    44int rd (int argc, char **argv) {
    55 
    6   int i, N, status, plane, Nplane, extend, Nextend, Nskip, JustHead, blank;
    7   int ccdsel, done, Nword, IsCompressed;
    8   char region[512], *ccdid, *filename;
    9   FILE *f;
     6  int i, N, Nskip, blank;
     7  int done, Nword;
     8  char region[512];
    109  Buffer *buf;
    1110
    12   JustHead = FALSE;
     11  int JustHead = FALSE;
    1312  if ((N = get_argument (argc, argv, "-head"))) {
    1413    remove_argument (N, &argc, argv);
     
    1615  }
    1716
    18   plane = 1;
     17  int plane = -1;
    1918  if ((N = get_argument (argc, argv, "-plane"))) {
    2019    remove_argument (N, &argc, argv);
     
    2322  }
    2423
    25   extend = FALSE;
    26   Nextend = -1;
     24  int extend = FALSE;
     25  int Nextend = -1;
    2726  if ((N = get_argument (argc, argv, "-x"))) {
    2827    remove_argument (N, &argc, argv);
     
    3231  }
    3332
    34   ccdsel = FALSE;
    35   ccdid = (char *) NULL;
     33  int ccdsel = FALSE;
     34  char *ccdid = NULL;
    3635  if ((N = get_argument (argc, argv, "-n"))) {
    3736    remove_argument (N, &argc, argv);
     
    5251
    5352  /* test if file exists */
    54   f = fopen (argv[2], "r");
     53  FILE *f = fopen (argv[2], "r");
    5554  if (f == (FILE *) NULL) {
    5655    gprint (GP_ERR, "file %s not found\n", argv[2]);
     
    6766
    6867  /* save file name */
    69   filename = filebasename (argv[2]);
     68  char *filename = filebasename (argv[2]);
    7069  strcpy (buf[0].file, filename);
    7170  free (filename);
    7271
    73   status = FALSE;
    74   IsCompressed = FALSE;
     72  int status = FALSE;
     73  int IsCompressed = FALSE;
    7574
    7675  /*** advance to the correct FITS extension ***/
     
    168167
    169168  /* check for valid plane */
    170   Nplane = buf[0].header.Naxis[2];
    171   if (Nplane == 0) Nplane = 1;
    172   if (plane > Nplane) {
    173     gprint (GP_ERR, "-plane is too large: %d total planes\n", Nplane);
    174     DeleteBuffer (buf);
    175     fclose (f);
    176     return (FALSE);
     169  int Nz = buf[0].header.Naxis[2];
     170  if (plane >= 0) {
     171    // we are requesting a specific plane (-1 : all data)
     172    int tooFar = Nz ? (plane >= Nz) : (plane > Nz);
     173    if (tooFar) {
     174      gprint (GP_ERR, "-plane is too large: %d total planes\n", Nz);
     175      DeleteBuffer (buf);
     176      fclose (f);
     177      return (FALSE);
     178    }
    177179  }
    178180
    179181  /* load matrix data */
    180182  if (IsCompressed) {
     183    if (plane > -1) {
     184      gprint (GP_ERR, "-plane incompatible with compressed image\n");
     185      DeleteBuffer (buf);
     186      fclose (f);
     187      return (FALSE);
     188    }
    181189    FTable ftable;
    182190    Header theader;
     
    191199    // XXX this currently does not work for a cube (we get a cube back, not a specific plane)
    192200  } else {
    193     sprintf (region, "-1 -1 -1 -1 %d %d", (plane - 1), plane);
    194     status = gfits_fread_matrix_segment (f, &buf[0].matrix, &buf[0].header, region);
     201    if (plane > -1) {
     202      // read a single plane into a 2D image
     203      sprintf (region, "-1 -1 -1 -1 %d %d", (plane - 1), plane);
     204      status = gfits_fread_matrix_segment (f, &buf[0].matrix, &buf[0].header, region);
     205      buf[0].header.Naxis[2] = 0;
     206      buf[0].header.Naxes = 2;
     207      gfits_modify (&buf[0].header, "NAXIS", "%d", 1, 2);
     208      gfits_modify (&buf[0].header, "NAXIS3", "%d", 1, 0);
     209    } else {
     210      status = gfits_fread_matrix (f, &buf[0].matrix, &buf[0].header);
     211    }
    195212  }
    196213  fclose (f);
     
    200217    DeleteBuffer (buf);
    201218    return (FALSE);
    202   }
    203 
    204   /* adjust buffer to represent 2D data */
    205   if (Nplane > 1) {
    206     buf[0].header.Naxis[2] = 0;
    207     buf[0].header.Naxes = 2;
    208     gfits_modify (&buf[0].header, "NAXIS", "%d", 1, 2);
    209     gfits_delete (&buf[0].header, "NAXIS3", 1);
    210219  }
    211220
     
    215224    buf[0].header.Naxis[1] = 1;
    216225    buf[0].matrix.Naxis[1] = 1;
     226    gfits_modify (&buf[0].header, "NAXIS", "%d", 1, 2);
     227    gfits_modify (&buf[0].header, "NAXIS2", "%d", 1, 1);
    217228  }   
    218229
  • trunk/Ohana/src/opihi/cmd.data/read_vectors.c

    r37807 r38062  
    372372  }
    373373
     374  int VERBOSE = FALSE;
     375  if ((N = get_argument (argc, argv, "-v"))) {
     376    remove_argument (N, &argc, argv);
     377    VERBOSE = TRUE;
     378  }
     379
    374380  int start = 0;
    375381  int Nrows = -1; // -1 : read entire table
     
    399405  // }
    400406
    401   if (argc < 2) ESCAPE ("USAGE: read -fits extension [-extnum] [-keyword key] name name ...\n");
     407  if ((argc < 2) && !getSizes) ESCAPE ("USAGE: read -fits extension [-extnum] [-keyword key] name name ...\n");
     408  if ((argc != 1) && getSizes) ESCAPE ("USAGE: read -sizes -fits extension [-extnum] (does not read data values)\n");
    402409
    403410  if (f == NULL) ESCAPE ("file not found\n");
     
    436443    if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]);
    437444    if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n");
    438     if (start + Nrows > header.Naxis[1]) ESCAPE ("invalid range: start + Nrows > Ny (%d)\n", header.Naxis[1]);
     445
     446    // just a warning:
     447    if (start + Nrows > header.Naxis[1]) {
     448      if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only %d rows\n", header.Naxis[1] - start);
     449    }
    439450
    440451    // Ny = 100, start = 0, Nrows = -1 -> Nrows => 100
     
    472483      }
    473484
     485      if (getSizes) {
     486        read_table_sizes (&header);
     487        if (CCDKeyword != NULL) free (CCDKeyword);
     488        gfits_free_header (&header);
     489        return TRUE;
     490      }
     491
    474492      if (Nrows == -1) {
    475493        Nrows = header.Naxis[1] - start;
     
    478496      if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]);
    479497      if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n");
    480       if (start + Nrows > header.Naxis[1]) ESCAPE ("invalid range: start + Nrows > Ny (%d)\n", header.Naxis[1]);
     498
     499      // just a warning:
     500      if (start + Nrows > header.Naxis[1]) {
     501        if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only %d rows\n", header.Naxis[1] - start);
     502      }
    481503
    482504      if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend);
     
    603625
    604626  set_int_variable ("table:Nx", header->Naxis[0]);
    605   set_int_variable ("table:Nx", header->Naxis[0]);
     627  set_int_variable ("table:Ny", header->Naxis[1]);
    606628  set_int_variable ("table:Nfields", Nfields);
    607629
  • trunk/Ohana/src/opihi/cmd.data/tv.c

    r37807 r38062  
    2828  }
    2929
     30  int plane = 0;
     31  if ((N = get_argument (argc, argv, "-plane"))) {
     32    remove_argument (N, &argc, argv);
     33    plane = atoi (argv[N]);
     34    remove_argument (N, &argc, argv);
     35  }
     36  if (plane < 0) {
     37    gprint (GP_ERR, " ERROR: -plane (plane) : cannot be negative\n");
     38    return (FALSE);
     39  }
     40
    3041  /* shell exits on pipe close, FIX */
    3142  if ((N = get_argument (argc, argv, "-kill"))) {
     
    5566  GetCoords (&coords, &buf[0].header);
    5667 
    57   image.data1d = (float *) buf[0].matrix.buffer;
    5868  image.Nx = buf[0].matrix.Naxis[0];
    5969  image.Ny = buf[0].matrix.Naxis[1];
     70
     71  int tooBig = buf[0].matrix.Naxis[2] ? (plane >= buf[0].matrix.Naxis[2]) : plane > 0;
     72  if (tooBig) {
     73    gprint (GP_ERR, " ERROR: -plane (plane) : out of bounds (%d vs %d)\n", plane, buf[0].matrix.Naxis[2]);
     74    return (FALSE);
     75  }
     76  int Npix2D = image.Nx * image.Ny;
     77
     78  float *imdata = (float *) buf[0].matrix.buffer;
     79  image.data1d = &imdata[plane*Npix2D];
    6080
    6181  // send only the root of the file, not the full path
  • trunk/Ohana/src/opihi/cmd.data/wd.c

    r27435 r38062  
    8181  memcpy (temp_header.buffer, buf[0].header.buffer, temp_header.datasize);
    8282
    83   if (temp_header.Naxes) {
    84     // the inBlank value probably does not matter: temp_matrix is float, so nan is used
    85     gfits_convert_format (&temp_header, &temp_matrix, outBitpix, outScale, outZero, 0xffff, outUnsign);
    86   } else {
    87     gfits_modify (&temp_header, "BITPIX", "%d", 1, outBitpix);
    88     gfits_modify (&temp_header, "BSCALE", "%lf", 1, outScale);
    89     gfits_modify (&temp_header, "BZERO",  "%lf", 1, outZero);
    90     gfits_modify_alt (&temp_header, "UNSIGN", "%t", 1, outUnsign);
    91   }
     83  gfits_convert_format (&temp_header, &temp_matrix, outBitpix, outScale, outZero, 0xffff, outUnsign);
    9284
     85  // Extend puts the output matrix in the first available non-PHU slot (ie, the last one)
     86  // it updates NEXTEND and set EXTEND to TRUE, and modifies the PHU header (neither should happen)
     87  // if those keywords do not exist...
    9388  if (Extend) {
    9489    Header Xhead;
  • trunk/Ohana/src/opihi/cmd.data/zplot.c

    r34613 r38062  
    44 
    55  char *outname = NULL;
    6   int i, kapa, valid, size;
     6  int i, N, kapa, valid, size;
    77  opihi_flt *out;
    88  double min, range;
    99  Graphdata graphmode;
    10   Vector *xvec, *yvec, *zvec, Zvec;
     10  Vector *xvec, *yvec, *zvec, *dxmvec, *dxpvec, *dymvec, *dypvec, Zvec;
    1111
    1212  if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE);
     13
     14  /* decide on error bars */
     15  dxmvec = dxpvec = dymvec = dypvec = NULL;
     16  if ((N = get_argument (argc, argv, "-dx"))) {
     17    remove_argument (N, &argc, argv);
     18    if ((dxmvec = SelectVector (argv[N], OLDVECTOR, TRUE)) == NULL) return (FALSE);   
     19    remove_argument (N, &argc, argv);
     20  }
     21  if ((N = get_argument (argc, argv, "+dx"))) {
     22    remove_argument (N, &argc, argv);
     23    if ((dxpvec = SelectVector (argv[N], OLDVECTOR, TRUE)) == NULL) return (FALSE);   
     24    remove_argument (N, &argc, argv);
     25  }
     26  if ((N = get_argument (argc, argv, "-dy"))) {
     27    remove_argument (N, &argc, argv);
     28    if ((dymvec = SelectVector (argv[N], OLDVECTOR, TRUE)) == NULL) return (FALSE);   
     29    remove_argument (N, &argc, argv);
     30  }
     31  if ((N = get_argument (argc, argv, "+dy"))) {
     32    remove_argument (N, &argc, argv);
     33    if ((dypvec = SelectVector (argv[N], OLDVECTOR, TRUE)) == NULL) return (FALSE);   
     34    remove_argument (N, &argc, argv);
     35  }
    1336
    1437  valid  = (argc == 6);
     
    4063  }
    4164
     65  /* set errorbar mode (these are NOT sticky) */
     66  graphmode.etype = 0;
     67  if ((dymvec != NULL) && (dypvec == NULL)) dypvec = dymvec;
     68  if ((dypvec != NULL) && (dymvec == NULL)) dymvec = dypvec;
     69  if ((dypvec != NULL) || (dymvec != NULL)) graphmode.etype |= 0x01;
     70  if ((dxmvec != NULL) && (dxpvec == NULL)) dxpvec = dxmvec;
     71  if ((dxpvec != NULL) && (dxmvec == NULL)) dxmvec = dxpvec;
     72  if ((dxpvec != NULL) || (dxmvec != NULL)) graphmode.etype |= 0x02;
     73 
    4274  /* find vectors */
    4375  if ((xvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
     
    5688    return (FALSE);
    5789  }
     90  if (dypvec && (dypvec->Nelements != xvec->Nelements)) goto mismatch;
     91  if (dymvec && (dymvec->Nelements != xvec->Nelements)) goto mismatch;
     92  if (dxpvec && (dxpvec->Nelements != xvec->Nelements)) goto mismatch;
     93  if (dxmvec && (dxmvec->Nelements != xvec->Nelements)) goto mismatch;
     94
    5895  SetVector (&Zvec, OPIHI_FLT, zvec[0].Nelements);
    5996  out = Zvec.elements.Flt;
    6097 
     98  // note actual size is 3.3x plot -sz sizes. (DrawObjects.c:399)
    6199  if (zvec[0].type == OPIHI_FLT) {
    62100    opihi_flt *in = zvec[0].elements.Flt;
     
    81119  graphmode.style = 2; /* plot points */
    82120  graphmode.size = -1; /* point size determined by Zvec */
    83   graphmode.etype = 0; /* no errorbars */
    84121  PlotVectorTriplet (kapa, xvec, yvec, &Zvec, mask, &graphmode);
     122  if (graphmode.etype & 0x01) {
     123    PlotVectorSingle (kapa, dymvec, mask, "dym");
     124    PlotVectorSingle (kapa, dypvec, mask, "dyp");
     125  }
     126  if (graphmode.etype & 0x02) {
     127    PlotVectorSingle (kapa, dxmvec, mask, "dxm");
     128    PlotVectorSingle (kapa, dxpvec, mask, "dxp");
     129  }
    85130
    86131  free (Zvec.elements.Ptr);
    87132  if (mask) free (mask);
    88   DeleteNamedVector (outname);
     133
     134  if (outname) {
     135    DeleteNamedVector (outname);
     136    free (outname);
     137  }
    89138
    90139  return (TRUE);
    91140
     141mismatch:
     142  gprint (GP_ERR, "error and data vector lengths are mismatched\n");
     143  if (outname) {
     144    DeleteNamedVector (outname);
     145    free (outname);
     146  }
     147  return (FALSE);
    92148}
    93149
  • trunk/Ohana/src/opihi/dvo/avextract.c

    r37807 r38062  
    221221
    222222      for (n = 0; n < Nfields; n++) {
     223        // we are passing in the *first* measure, but average->Nmeasure gives the count
    223224        values[n] = dbExtractAverages (average, secfilt, measure, lensobj, starpar, &fields[n]);
    224225      }
  • trunk/Ohana/src/opihi/include/dvomath.h

    r37807 r38062  
    187187int           ListBuffersToList     PROTO((char *name));
    188188int           CreateBuffer          PROTO((Buffer *buf, int Nx, int Ny, int bitpix, float bzero, float bscale));
     189int           CreateBuffer3D        PROTO((Buffer *buf, int Nx, int Ny, int Nz, int bitpix, float bzero, float bscale));
    189190int           ResetBuffer           PROTO((Buffer *buf, int Nx, int Ny, int bitpix, float bzero, float bscale));
    190191Buffer       *SelectBuffer          PROTO((char *name, int mode, int verbose));
  • trunk/Ohana/src/opihi/lib.shell/BufferOps.c

    r37807 r38062  
    120120}
    121121 
     122// buffer is 1D array referenced in the order:
     123// buffer[x + Nx*y + Nx*Ny*z + ...]
     124int CreateBuffer3D (Buffer *buf, int Nx, int Ny, int Nz, int bitpix, float bzero, float bscale) {
     125
     126  /* store the default output values */
     127  gfits_init_header (&buf[0].header);
     128
     129  /* assign the necessary internal values */
     130  buf[0].header.bitpix   = -32;
     131  buf[0].header.Naxes = 3;
     132  buf[0].header.Naxis[0] = Nx;
     133  buf[0].header.Naxis[1] = Ny;
     134  buf[0].header.Naxis[2] = Nz;
     135
     136  buf[0].bitpix = bitpix;
     137  buf[0].bzero  = bzero;
     138  buf[0].bscale = bscale;
     139 
     140  /* make some test of the validity of the values */
     141
     142  /* create the appropriate header and matrix */
     143  gfits_create_header (&buf[0].header);
     144  gfits_create_matrix (&buf[0].header, &buf[0].matrix);
     145
     146  return (TRUE);
     147}
     148 
    122149/* copy data from in to out - new memory space */
    123150int CopyNamedBuffer (char *out, char *in) {
  • trunk/Ohana/src/opihi/lib.shell/check_stack.c

    r36375 r38062  
    66int check_stack (StackVar *stack, int Nstack, int validsize) {
    77
    8   int i, Nx, Ny, Nv, size;
     8  int i, Nx, Ny, Nz, Nv, size;
    99  char *c1, *c2;
    1010
    11   Nv = Nx = Ny = -1;
     11  Nv = Nx = Ny = Nz = -1;
    1212
    1313  for (i = 0; i < Nstack; i++) {
     
    4646          Nx = stack[i].buffer[0].matrix.Naxis[0];
    4747          Ny = stack[i].buffer[0].matrix.Naxis[1];
     48          Nz = stack[i].buffer[0].matrix.Naxis[2];
    4849        }
    49         if ((Nx != stack[i].buffer[0].matrix.Naxis[0]) && (Ny != stack[i].buffer[0].matrix.Naxis[1])) {
     50        if ((Nx != stack[i].buffer[0].matrix.Naxis[0]) &&
     51            (Ny != stack[i].buffer[0].matrix.Naxis[1]) &&
     52            (Nz != stack[i].buffer[0].matrix.Naxis[2])) {
    5053          push_error ("dimensions don't match");
    5154          return (-1);
  • trunk/Ohana/src/opihi/lib.shell/convert_to_RPN.c

    r36679 r38062  
    6060    if (!strcmp (argv[i], "xramp"))  { type = ST_UNARY; goto gotit; }
    6161    if (!strcmp (argv[i], "yramp"))  { type = ST_UNARY; goto gotit; }
     62    if (!strcmp (argv[i], "zramp"))  { type = ST_UNARY; goto gotit; }
    6263    if (!strcmp (argv[i], "ramp"))   { type = ST_UNARY; goto gotit; }
    6364    if (!strcmp (argv[i], "zero"))   { type = ST_UNARY; goto gotit; }
  • trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c

    r36375 r38062  
    121121      got_three_op:
    122122        if (!status) {
    123           snprintf (line, 512, "syntax error: invalid operand for binary operation: %s or %s or %s\n", stack[i-1].name, stack[i-2].name, stack[i-3].name);
     123          snprintf (line, 512, "syntax error: invalid operand for trinary operation: %s or %s or %s\n", stack[i-1].name, stack[i-2].name, stack[i-3].name);
    124124          push_error (line);
    125125          clear_stack (&tmp_stack);
  • trunk/Ohana/src/opihi/lib.shell/stack_math.c

    r36528 r38062  
    8080      break;                                                            \
    8181    }                                                                   \
     82    if ((V1->vector->type == OPIHI_FLT) && (V2->vector->type == OPIHI_FLT) && (V3->vector->type == OPIHI_INT)) { \
     83      CopyVector (OUT[0].vector, V1[0].vector);                         \
     84      opihi_flt *M1  =  V1[0].vector[0].elements.Flt;                   \
     85      opihi_flt *M2  =  V2[0].vector[0].elements.Flt;                   \
     86      opihi_int *M3  =  V3[0].vector[0].elements.Int;                   \
     87      opihi_flt *out = OUT[0].vector[0].elements.Flt;                   \
     88      for (i = 0; i < Nx; i++, out++, M1++, M2++, M3++) {               \
     89        *out = OP;                                                      \
     90      }                                                                 \
     91      break;                                                            \
     92    }                                                                   \
     93    if ((V1->vector->type == OPIHI_FLT) && (V2->vector->type == OPIHI_INT) && (V3->vector->type == OPIHI_FLT)) { \
     94      CopyVector (OUT[0].vector, V1[0].vector);                         \
     95      opihi_flt *M1  =  V1[0].vector[0].elements.Flt;                   \
     96      opihi_int *M2  =  V2[0].vector[0].elements.Int;                   \
     97      opihi_flt *M3  =  V3[0].vector[0].elements.Flt;                   \
     98      opihi_flt *out = OUT[0].vector[0].elements.Flt;                   \
     99      for (i = 0; i < Nx; i++, out++, M1++, M2++, M3++) {               \
     100        *out = OP;                                                      \
     101      }                                                                 \
     102      break;                                                            \
     103    }                                                                   \
     104    if ((V1->vector->type == OPIHI_FLT) && (V2->vector->type == OPIHI_INT) && (V3->vector->type == OPIHI_INT)) { \
     105      CopyVector (OUT[0].vector, V2[0].vector);                         \
     106      opihi_flt *M1  =  V1[0].vector[0].elements.Flt;                   \
     107      opihi_int *M2  =  V2[0].vector[0].elements.Int;                   \
     108      opihi_int *M3  =  V3[0].vector[0].elements.Int;                   \
     109      opihi_int *out = OUT[0].vector[0].elements.Int;                   \
     110      for (i = 0; i < Nx; i++, out++, M1++, M2++, M3++) {               \
     111        *out = OP;                                                      \
     112      }                                                                 \
     113      break;                                                            \
     114    }                                                                   \
     115    if ((V1->vector->type == OPIHI_INT) && (V2->vector->type == OPIHI_FLT) && (V3->vector->type == OPIHI_FLT)) { \
     116      CopyVector (OUT[0].vector, V2[0].vector);                         \
     117      opihi_int *M1  =  V1[0].vector[0].elements.Int;                   \
     118      opihi_flt *M2  =  V2[0].vector[0].elements.Flt;                   \
     119      opihi_flt *M3  =  V3[0].vector[0].elements.Flt;                   \
     120      opihi_flt *out = OUT[0].vector[0].elements.Flt;                   \
     121      for (i = 0; i < Nx; i++, out++, M1++, M2++, M3++) {               \
     122        *out = OP;                                                      \
     123      }                                                                 \
     124      break;                                                            \
     125    }                                                                   \
     126    if ((V1->vector->type == OPIHI_INT) && (V2->vector->type == OPIHI_FLT) && (V3->vector->type == OPIHI_INT)) { \
     127      CopyVector (OUT[0].vector, V2[0].vector);                         \
     128      opihi_int *M1  =  V1[0].vector[0].elements.Int;                   \
     129      opihi_flt *M2  =  V2[0].vector[0].elements.Flt;                   \
     130      opihi_int *M3  =  V3[0].vector[0].elements.Int;                   \
     131      opihi_flt *out = OUT[0].vector[0].elements.Flt;                   \
     132      for (i = 0; i < Nx; i++, out++, M1++, M2++, M3++) {               \
     133        *out = OP;                                                      \
     134      }                                                                 \
     135      break;                                                            \
     136    }                                                                   \
     137    if ((V1->vector->type == OPIHI_INT) && (V2->vector->type == OPIHI_INT) && (V3->vector->type == OPIHI_FLT)) { \
     138      CopyVector (OUT[0].vector, V3[0].vector);                         \
     139      opihi_int *M1  =  V1[0].vector[0].elements.Int;                   \
     140      opihi_int *M2  =  V2[0].vector[0].elements.Int;                   \
     141      opihi_flt *M3  =  V3[0].vector[0].elements.Flt;                   \
     142      opihi_flt *out = OUT[0].vector[0].elements.Flt;                   \
     143      for (i = 0; i < Nx; i++, out++, M1++, M2++, M3++) {               \
     144        *out = OP;                                                      \
     145      }                                                                 \
     146      break;                                                            \
     147    }                                                                   \
    82148    if ((V1->vector->type == OPIHI_INT) && (V2->vector->type == OPIHI_INT) && (V3->vector->type == OPIHI_INT)) { \
    83149      CopyVector (OUT[0].vector, V1[0].vector);                         \
     
    127193int MMM_trinary (StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op) {
    128194
    129   int i, Nx, Ny;
     195  int i;
    130196  float *out, *M1, *M2, *M3;
    131197  char line[512]; // this is only used to report an error
    132198 
    133   Nx = V1[0].buffer[0].matrix.Naxis[0];
    134   Ny = V1[0].buffer[0].matrix.Naxis[1];
    135 
     199  int Npix = gfits_npix_matrix (&V1[0].buffer[0].matrix);
     200 
    136201  if (V1[0].type == ST_MATRIX_TMP) {  /** use V1 as temp buffer **/
    137202    OUT[0].buffer = V1[0].buffer;
     
    154219
    155220# define MMM_FUNC(OP)                                   \
    156   for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++, M3++) {        \
     221  for (i = 0; i < Npix; i++, out++, M1++, M2++, M3++) { \
    157222    *out = OP;                                          \
    158223  }                                                     \
     
    531596}
    532597
    533 // the vector is applied to each column
     598// the vector is applied to each column (currently only valid for 2D matrix)
    534599int MV_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) {
    535600
     
    626691}
    627692
    628 // the vector is applied to each row
     693// the vector is applied to each row (currently only valid for 2D matrix)
    629694int VM_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) {
    630695
     
    722787int MM_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) {
    723788
    724   int i, Nx, Ny;
     789  int i;
    725790  float *out, *M1, *M2;
    726791  char line[512]; // this is only used to report an error
    727792 
    728   Nx = V1[0].buffer[0].matrix.Naxis[0];
    729   Ny = V1[0].buffer[0].matrix.Naxis[1];
    730 
     793  int Npix = gfits_npix_matrix (&V1[0].buffer[0].matrix);
     794 
    731795  if (V1[0].type == ST_MATRIX_TMP) {  /** use V1 as temp buffer **/
    732796    OUT[0].buffer = V1[0].buffer;
     
    748812
    749813# define MM_FUNC(OP)                                    \
    750   for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) {      \
     814  for (i = 0; i < Npix; i++, out++, M1++, M2++) {       \
    751815    *out = OP;                                          \
    752816  }                                                     \
     
    803867int MS_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) {
    804868
    805   int i, Nx, Ny;
     869  int i;
    806870  char line[512]; // this is only used to report an error
    807871 
    808   Nx = V1[0].buffer[0].matrix.Naxis[0];
    809   Ny = V1[0].buffer[0].matrix.Naxis[1];
     872  int Npix = gfits_npix_matrix (&V1[0].buffer[0].matrix);
    810873
    811874  /* if possible, use V1 as temp buffer, otherwise create new one */
     
    825888    if (V2->type == ST_SCALAR_FLT)  {                           \
    826889      opihi_flt M2 = V2[0].FltValue;                    \
    827       for (i = 0; i < Nx*Ny; i++, out++, M1++) {        \
     890      for (i = 0; i < Npix; i++, out++, M1++) { \
    828891        *out = OP;                                      \
    829892      }                                                 \
     
    832895    if (V2->type == ST_SCALAR_INT)  {                           \
    833896      opihi_int M2 = V2[0].IntValue;                    \
    834       for (i = 0; i < Nx*Ny; i++, out++, M1++) {        \
     897      for (i = 0; i < Npix; i++, out++, M1++) { \
    835898        *out = OP;                                      \
    836899      }                                                 \
     
    881944int SM_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) {
    882945
    883   int i, Nx, Ny;
     946  int i;
    884947  char line[512]; // this is only used to report an error
    885948 
    886   Nx = V2[0].buffer[0].matrix.Naxis[0];
    887   Ny = V2[0].buffer[0].matrix.Naxis[1];
    888 
     949  int Npix = gfits_npix_matrix (&V2[0].buffer[0].matrix);
     950 
    889951  if (V2[0].type == ST_MATRIX_TMP) {  /* V2[0] is NOT temporary, we can't use it for storage */
    890952    OUT[0].buffer = V2[0].buffer;
     
    902964    if (V1->type == ST_SCALAR_FLT)  {                           \
    903965      opihi_flt M1 = V1[0].FltValue;                    \
    904       for (i = 0; i < Nx*Ny; i++, out++, M2++) {        \
     966      for (i = 0; i < Npix; i++, out++, M2++) { \
    905967        *out = OP;                                      \
    906968      }                                                 \
     
    909971    if (V1->type == ST_SCALAR_INT)  {                           \
    910972      opihi_int M1 = V1[0].IntValue;                    \
    911       for (i = 0; i < Nx*Ny; i++, out++, M2++) {        \
     973      for (i = 0; i < Npix; i++, out++, M2++) { \
    912974        *out = OP;                                      \
    913975      }                                                 \
     
    12401302  if (!strcmp (op, "xramp"))  V_FUNC(i, ST_SCALAR_INT);
    12411303  if (!strcmp (op, "yramp"))  V_FUNC(0, ST_SCALAR_INT);
    1242   /* xramp and yramp above only make sense for matrices. for vectors, xramp = ramp, yramp = zero */
     1304  if (!strcmp (op, "zramp"))  V_FUNC(0, ST_SCALAR_INT);
     1305  /* xramp, yramp, zramp above only make sense for matrices. for vectors, xramp = ramp, yramp = zero */
    12431306
    12441307# undef V_FUNC
     
    12591322int M_unary (StackVar *OUT, StackVar *V1, char *op) {
    12601323
    1261   int i, j, Nx, Ny;
     1324  int i, j, k;
    12621325  float *out, *M1;
    12631326 
    1264   Nx = V1[0].buffer[0].matrix.Naxis[0];
    1265   Ny = V1[0].buffer[0].matrix.Naxis[1];
    1266 
     1327  int Npix = gfits_npix_matrix (&V1[0].buffer[0].matrix);
     1328 
    12671329  if (V1[0].type == ST_MATRIX_TMP) {
    12681330    OUT[0].buffer = V1[0].buffer;
     
    12771339
    12781340  if (!strcmp (op, "="))     { }
    1279   if (!strcmp (op, "abs"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = fabs(*M1);         }}
    1280   if (!strcmp (op, "int"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = (opihi_flt)(long long)(*M1); }}
    1281 
    1282   if (!strcmp (op, "floor")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = floor (*M1); }}
    1283   if (!strcmp (op, "ceil"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = ceil (*M1); }}
    1284   // if (!strcmp (op, "rint"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = nearbyint (*M1); }}
    1285 
    1286   if (!strcmp (op, "exp"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = exp(*M1);          }}
    1287   if (!strcmp (op, "ten"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = pow(10.0,*M1);     }}
    1288   if (!strcmp (op, "log"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = log10(*M1);        }}
    1289   if (!strcmp (op, "ln"))    { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = log(*M1);          }}
    1290   if (!strcmp (op, "sqrt"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = sqrt(*M1);         }}
    1291   if (!strcmp (op, "erf"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = erf(*M1);          }}
    1292 
    1293   if (!strcmp (op, "sinh"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = sinh(*M1);         }}
    1294   if (!strcmp (op, "cosh"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = cosh(*M1);         }}
    1295   if (!strcmp (op, "asinh")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = asinh(*M1);        }}
    1296   if (!strcmp (op, "acosh")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = acosh(*M1);        }}
    1297   if (!strcmp (op, "lgamma")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = lgamma(*M1);      }}
    1298 
    1299   if (!strcmp (op, "sin"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = sin(*M1);          }}
    1300   if (!strcmp (op, "cos"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = cos(*M1);          }}
    1301   if (!strcmp (op, "tan"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = tan(*M1);          }}
    1302   if (!strcmp (op, "dsin"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = sin(*M1*RAD_DEG);  }}
    1303   if (!strcmp (op, "dcos"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = cos(*M1*RAD_DEG);  }}
    1304   if (!strcmp (op, "dtan"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = tan(*M1*RAD_DEG);  }}
    1305   if (!strcmp (op, "asin"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = asin(*M1);         }}
    1306   if (!strcmp (op, "acos"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = acos(*M1);         }}
    1307   if (!strcmp (op, "atan"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = atan(*M1);         }}
    1308   if (!strcmp (op, "dasin")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = asin(*M1)*DEG_RAD; }}
    1309   if (!strcmp (op, "dacos")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = acos(*M1)*DEG_RAD; }}
    1310   if (!strcmp (op, "datan")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = atan(*M1)*DEG_RAD; }}
    1311   if (!strcmp (op, "not"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = !(*M1);            }}
    1312   if (!strcmp (op, "--"))    { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = -(*M1);            }}
    1313   if (!strcmp (op, "rnd"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = drand48();         }}
    1314   if (!strcmp (op, "ramp"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = i;                 }}
    1315   if (!strcmp (op, "zero"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = 0;                 }}
    1316   if (!strcmp (op, "isinf")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = !finite(*M1);      }}
    1317   if (!strcmp (op, "isnan")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = isnan(*M1);        }}
    1318 
    1319   /* xrm and yrm only make sense in for matrices. see special meaning for vectors */
     1341  if (!strcmp (op, "abs"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = fabs(*M1);         }}
     1342  if (!strcmp (op, "int"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = (opihi_flt)(long long)(*M1); }}
     1343
     1344  if (!strcmp (op, "floor")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = floor (*M1); }}
     1345  if (!strcmp (op, "ceil"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = ceil (*M1); }}
     1346  // if (!strcmp (op, "rint"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = nearbyint (*M1); }}
     1347
     1348  if (!strcmp (op, "exp"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = exp(*M1);          }}
     1349  if (!strcmp (op, "ten"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = pow(10.0,*M1);     }}
     1350  if (!strcmp (op, "log"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = log10(*M1);        }}
     1351  if (!strcmp (op, "ln"))    { for (i = 0; i < Npix; i++, out++, M1++) { *out = log(*M1);          }}
     1352  if (!strcmp (op, "sqrt"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = sqrt(*M1);         }}
     1353  if (!strcmp (op, "erf"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = erf(*M1);          }}
     1354
     1355  if (!strcmp (op, "sinh"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = sinh(*M1);         }}
     1356  if (!strcmp (op, "cosh"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = cosh(*M1);         }}
     1357  if (!strcmp (op, "asinh")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = asinh(*M1);        }}
     1358  if (!strcmp (op, "acosh")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = acosh(*M1);        }}
     1359  if (!strcmp (op, "lgamma")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = lgamma(*M1);      }}
     1360
     1361  if (!strcmp (op, "sin"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = sin(*M1);          }}
     1362  if (!strcmp (op, "cos"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = cos(*M1);          }}
     1363  if (!strcmp (op, "tan"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = tan(*M1);          }}
     1364  if (!strcmp (op, "dsin"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = sin(*M1*RAD_DEG);  }}
     1365  if (!strcmp (op, "dcos"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = cos(*M1*RAD_DEG);  }}
     1366  if (!strcmp (op, "dtan"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = tan(*M1*RAD_DEG);  }}
     1367  if (!strcmp (op, "asin"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = asin(*M1);         }}
     1368  if (!strcmp (op, "acos"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = acos(*M1);         }}
     1369  if (!strcmp (op, "atan"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = atan(*M1);         }}
     1370  if (!strcmp (op, "dasin")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = asin(*M1)*DEG_RAD; }}
     1371  if (!strcmp (op, "dacos")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = acos(*M1)*DEG_RAD; }}
     1372  if (!strcmp (op, "datan")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = atan(*M1)*DEG_RAD; }}
     1373  if (!strcmp (op, "not"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = !(*M1);            }}
     1374  if (!strcmp (op, "--"))    { for (i = 0; i < Npix; i++, out++, M1++) { *out = -(*M1);            }}
     1375  if (!strcmp (op, "rnd"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = drand48();         }}
     1376  if (!strcmp (op, "ramp"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = i;                 }}
     1377  if (!strcmp (op, "zero"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = 0;                 }}
     1378  if (!strcmp (op, "isinf")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = !finite(*M1);      }}
     1379  if (!strcmp (op, "isnan")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = isnan(*M1);        }}
     1380
     1381  /* xrm and yrm only make sense for 2D matrices. see special meaning for vectors */
    13201382  if (!strcmp (op, "xramp")) {
    1321     for (j = 0; j < Ny; j++) {
    1322       for (i = 0; i < Nx; i++, out++, M1++) {
    1323         *out = i;
     1383    int Nx = V1[0].buffer[0].matrix.Naxis[0];
     1384    int Ny = V1[0].buffer[0].matrix.Naxis[1];
     1385    int Nz = MAX (1, V1[0].buffer[0].matrix.Naxis[2]);
     1386    for (k = 0; k < Nz; k++) {
     1387      for (j = 0; j < Ny; j++) {
     1388        for (i = 0; i < Nx; i++, out++, M1++) {
     1389          *out = i;
     1390        }
    13241391      }
    13251392    }
    13261393  }
    13271394  if (!strcmp (op, "yramp")) {
    1328     for (j = 0; j < Ny; j++) {
    1329       for (i = 0; i < Nx; i++, out++, M1++) {
    1330         *out = j;
     1395    int Nx = V1[0].buffer[0].matrix.Naxis[0];
     1396    int Ny = V1[0].buffer[0].matrix.Naxis[1];
     1397    int Nz = MAX (1, V1[0].buffer[0].matrix.Naxis[2]);
     1398    for (k = 0; k < Nz; k++) {
     1399      for (j = 0; j < Ny; j++) {
     1400        for (i = 0; i < Nx; i++, out++, M1++) {
     1401          *out = j;
     1402        }
     1403      }
     1404    }
     1405  }
     1406  if (!strcmp (op, "zramp")) {
     1407    int Nx = V1[0].buffer[0].matrix.Naxis[0];
     1408    int Ny = V1[0].buffer[0].matrix.Naxis[1];
     1409    int Nz = MAX (1, V1[0].buffer[0].matrix.Naxis[2]);
     1410    for (k = 0; k < Nz; k++) {
     1411      for (j = 0; j < Ny; j++) {
     1412        for (i = 0; i < Nx; i++, out++, M1++) {
     1413          *out = k;
     1414        }
    13311415      }
    13321416    }
Note: See TracChangeset for help on using the changeset viewer.