Changeset 38062 for trunk/Ohana/src/opihi
- Timestamp:
- Mar 29, 2015, 6:52:41 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 21 edited
- 6 copied
-
. (modified) (1 prop)
-
Ohana (modified) (1 prop)
-
Ohana/src/opihi/cmd.astro/Makefile (modified) (1 diff)
-
Ohana/src/opihi/cmd.astro/cdensify.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.astro/cdhistogram.c (copied) (copied from branches/eam_branches/ipp-20150112/Ohana/src/opihi/cmd.astro/cdhistogram.c )
-
Ohana/src/opihi/cmd.astro/init.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.data/Makefile (modified) (3 diffs)
-
Ohana/src/opihi/cmd.data/init.c (modified) (6 diffs)
-
Ohana/src/opihi/cmd.data/interpolate.c (modified) (3 diffs)
-
Ohana/src/opihi/cmd.data/mcreate.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/mget3d.c (copied) (copied from branches/eam_branches/ipp-20150112/Ohana/src/opihi/cmd.data/mget3d.c )
-
Ohana/src/opihi/cmd.data/rd.c (modified) (10 diffs)
-
Ohana/src/opihi/cmd.data/read_vectors.c (modified) (6 diffs)
-
Ohana/src/opihi/cmd.data/squash3d.c (copied) (copied from branches/eam_branches/ipp-20150112/Ohana/src/opihi/cmd.data/squash3d.c )
-
Ohana/src/opihi/cmd.data/tdhistogram.c (copied) (copied from branches/eam_branches/ipp-20150112/Ohana/src/opihi/cmd.data/tdhistogram.c )
-
Ohana/src/opihi/cmd.data/tv.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.data/wd.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/zplot.c (modified) (4 diffs)
-
Ohana/src/opihi/doc/BufferMath.txt (copied) (copied from branches/eam_branches/ipp-20150112/Ohana/src/opihi/doc/BufferMath.txt )
-
Ohana/src/opihi/dvo/avextract.c (modified) (1 diff)
-
Ohana/src/opihi/include/dvomath.h (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/BufferOps.c (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/check_stack.c (modified) (2 diffs)
-
Ohana/src/opihi/lib.shell/convert_to_RPN.c (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/evaluate_stack.c (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/stack_math.c (modified) (16 diffs)
-
Ohana/src/opihi/test/ellipse.sh (copied) (copied from branches/eam_branches/ipp-20150112/Ohana/src/opihi/test/ellipse.sh )
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
-
trunk/Ohana
- Property svn:mergeinfo deleted
-
trunk/Ohana/src/opihi/cmd.astro/Makefile
r37807 r38062 29 29 $(SRC)/czplot.$(ARCH).o \ 30 30 $(SRC)/cdensify.$(ARCH).o \ 31 $(SRC)/cdhistogram.$(ARCH).o \ 31 32 $(SRC)/drizzle.$(ARCH).o \ 32 33 $(SRC)/flux.$(ARCH).o \ -
trunk/Ohana/src/opihi/cmd.astro/cdensify.c
r37807 r38062 111 111 switch (PSFTYPE) { 112 112 case IS_DOT: 113 RD_to_XY (&x, &y, rn, *d, &graphmode.coords);114 Xb = (x - Xmin) / dX;115 Yb = (y - Ymin) / dY;116 117 113 RD_to_XY (&x, &y, rn, *d, &newcoords); 118 114 Xb = (int) x; -
trunk/Ohana/src/opihi/cmd.astro/init.c
r37807 r38062 14 14 int czcplot PROTO((int, char **)); 15 15 int cdensify PROTO((int, char **)); 16 int cdhistogram PROTO((int, char **)); 16 17 int drizzle PROTO((int, char **)); 17 18 int flux PROTO((int, char **)); … … 77 78 {1, "czplot", czplot, "plot scaled vectors in sky coordinates"}, 78 79 {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"}, 80 82 {1, "drizzle", drizzle, "transform image to image"}, 81 83 {1, "flux", flux, "flux in a convex contour"}, -
trunk/Ohana/src/opihi/cmd.data/Makefile
r37807 r38062 61 61 $(SRC)/ungridify.$(ARCH).o \ 62 62 $(SRC)/histogram.$(ARCH).o \ 63 $(SRC)/tdhistogram.$(ARCH).o \ 63 64 $(SRC)/hermitian1d.$(ARCH).o \ 64 65 $(SRC)/hermitian2d.$(ARCH).o \ … … 89 90 $(SRC)/medacc.$(ARCH).o \ 90 91 $(SRC)/mget.$(ARCH).o \ 92 $(SRC)/mget3d.$(ARCH).o \ 91 93 $(SRC)/minterpolate.$(ARCH).o \ 92 94 $(SRC)/medimage.$(ARCH).o \ … … 130 132 $(SRC)/imspline_apply.$(ARCH).o \ 131 133 $(SRC)/imspline_construct.$(ARCH).o \ 134 $(SRC)/squash3d.$(ARCH).o \ 132 135 $(SRC)/imstats.$(ARCH).o \ 133 136 $(SRC)/style.$(ARCH).o \ -
trunk/Ohana/src/opihi/cmd.data/init.c
r37807 r38062 51 51 int ungridify PROTO((int, char **)); 52 52 int histogram PROTO((int, char **)); 53 int tdhistogram PROTO((int, char **)); 53 54 int hermitian1d PROTO((int, char **)); 54 55 int hermitian2d PROTO((int, char **)); … … 80 81 int medacc PROTO((int, char **)); 81 82 int mget PROTO((int, char **)); 83 int mget3d PROTO((int, char **)); 82 84 int minterp PROTO((int, char **)); 83 85 int medimage_command PROTO((int, char **)); … … 117 119 int imspline_apply PROTO((int, char **)); 118 120 int imspline_construct PROTO((int, char **)); 121 int squash3d PROTO((int, char **)); 119 122 int stats PROTO((int, char **)); 120 123 int imstats PROTO((int, char **)); … … 217 220 {1, "header", header, "print image header"}, 218 221 {1, "histogram", histogram, "generate histogram from vector"}, 222 {1, "tdhistogram", tdhistogram, "generate 2D histogram image from vector set"}, 219 223 {1, "hermitian1d", hermitian1d, "generate 1-D Hermitian Polynomial"}, 220 224 {1, "hermitian2d", hermitian2d, "generate 2-D Hermitian Polynomial"}, … … 243 247 {1, "medacc", medacc, "accumulate vector values in another vector"}, 244 248 {1, "mget", mget, "extract a vector from an image"}, 249 {1, "mget3d", mget3d, "extract a vector from a 3D image"}, 245 250 {1, "imget", mget, "extract a vector from an image"}, 246 251 {1, "minterp", minterp, "interpolate image pixels"}, … … 289 294 {1, "imspline.apply", imspline_apply, "apply spline fit to generate an image"}, 290 295 {1, "imspline.const", imspline_construct, "create spline 2nd deriv. terms"}, 296 {1, "squash3d", squash3d, "squash 3d buffer to 2d"}, 291 297 {1, "stats", imstats, "statistics on a portion of an image"}, 292 298 {1, "style", style, "set the style for graph plots"}, -
trunk/Ohana/src/opihi/cmd.data/interpolate.c
r20936 r38062 1 1 # include "data.h" 2 2 3 // XXX use 'threshold' to interpolate to a value 3 4 int interpolate (int argc, char **argv) { 4 5 … … 11 12 gprint (GP_ERR, "USAGE: interpolate Xi Yi Xo Yo\n"); 12 13 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"); 15 17 return (FALSE); 16 18 } … … 18 20 if ((xin = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE); 19 21 if ((yin = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE); 22 23 // target positions are a vector 20 24 if ((xout = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) return (FALSE); 21 25 if ((yout = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE); -
trunk/Ohana/src/opihi/cmd.data/mcreate.c
r9275 r38062 3 3 int mcreate (int argc, char **argv) { 4 4 5 int N x, Ny;5 int N; 6 6 Buffer *buf; 7 7 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 8 15 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"); 10 17 return (FALSE); 11 18 } 12 19 13 20 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]); 16 23 17 24 /* I should encapsulate this in a create_default_buffer */ 18 25 gfits_free_matrix (&buf[0].matrix); 19 26 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 } 21 33 return (TRUE); 22 34 } -
trunk/Ohana/src/opihi/cmd.data/rd.c
r29938 r38062 4 4 int rd (int argc, char **argv) { 5 5 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]; 10 9 Buffer *buf; 11 10 12 JustHead = FALSE;11 int JustHead = FALSE; 13 12 if ((N = get_argument (argc, argv, "-head"))) { 14 13 remove_argument (N, &argc, argv); … … 16 15 } 17 16 18 plane =1;17 int plane = -1; 19 18 if ((N = get_argument (argc, argv, "-plane"))) { 20 19 remove_argument (N, &argc, argv); … … 23 22 } 24 23 25 extend = FALSE;26 Nextend = -1;24 int extend = FALSE; 25 int Nextend = -1; 27 26 if ((N = get_argument (argc, argv, "-x"))) { 28 27 remove_argument (N, &argc, argv); … … 32 31 } 33 32 34 ccdsel = FALSE;35 c cdid = (char *)NULL;33 int ccdsel = FALSE; 34 char *ccdid = NULL; 36 35 if ((N = get_argument (argc, argv, "-n"))) { 37 36 remove_argument (N, &argc, argv); … … 52 51 53 52 /* test if file exists */ 54 f = fopen (argv[2], "r");53 FILE *f = fopen (argv[2], "r"); 55 54 if (f == (FILE *) NULL) { 56 55 gprint (GP_ERR, "file %s not found\n", argv[2]); … … 67 66 68 67 /* save file name */ 69 filename = filebasename (argv[2]);68 char *filename = filebasename (argv[2]); 70 69 strcpy (buf[0].file, filename); 71 70 free (filename); 72 71 73 status = FALSE;74 IsCompressed = FALSE;72 int status = FALSE; 73 int IsCompressed = FALSE; 75 74 76 75 /*** advance to the correct FITS extension ***/ … … 168 167 169 168 /* 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 } 177 179 } 178 180 179 181 /* load matrix data */ 180 182 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 } 181 189 FTable ftable; 182 190 Header theader; … … 191 199 // XXX this currently does not work for a cube (we get a cube back, not a specific plane) 192 200 } 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 } 195 212 } 196 213 fclose (f); … … 200 217 DeleteBuffer (buf); 201 218 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);210 219 } 211 220 … … 215 224 buf[0].header.Naxis[1] = 1; 216 225 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); 217 228 } 218 229 -
trunk/Ohana/src/opihi/cmd.data/read_vectors.c
r37807 r38062 372 372 } 373 373 374 int VERBOSE = FALSE; 375 if ((N = get_argument (argc, argv, "-v"))) { 376 remove_argument (N, &argc, argv); 377 VERBOSE = TRUE; 378 } 379 374 380 int start = 0; 375 381 int Nrows = -1; // -1 : read entire table … … 399 405 // } 400 406 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"); 402 409 403 410 if (f == NULL) ESCAPE ("file not found\n"); … … 436 443 if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]); 437 444 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 } 439 450 440 451 // Ny = 100, start = 0, Nrows = -1 -> Nrows => 100 … … 472 483 } 473 484 485 if (getSizes) { 486 read_table_sizes (&header); 487 if (CCDKeyword != NULL) free (CCDKeyword); 488 gfits_free_header (&header); 489 return TRUE; 490 } 491 474 492 if (Nrows == -1) { 475 493 Nrows = header.Naxis[1] - start; … … 478 496 if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]); 479 497 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 } 481 503 482 504 if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend); … … 603 625 604 626 set_int_variable ("table:Nx", header->Naxis[0]); 605 set_int_variable ("table:N x", header->Naxis[0]);627 set_int_variable ("table:Ny", header->Naxis[1]); 606 628 set_int_variable ("table:Nfields", Nfields); 607 629 -
trunk/Ohana/src/opihi/cmd.data/tv.c
r37807 r38062 28 28 } 29 29 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 30 41 /* shell exits on pipe close, FIX */ 31 42 if ((N = get_argument (argc, argv, "-kill"))) { … … 55 66 GetCoords (&coords, &buf[0].header); 56 67 57 image.data1d = (float *) buf[0].matrix.buffer;58 68 image.Nx = buf[0].matrix.Naxis[0]; 59 69 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]; 60 80 61 81 // send only the root of the file, not the full path -
trunk/Ohana/src/opihi/cmd.data/wd.c
r27435 r38062 81 81 memcpy (temp_header.buffer, buf[0].header.buffer, temp_header.datasize); 82 82 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); 92 84 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... 93 88 if (Extend) { 94 89 Header Xhead; -
trunk/Ohana/src/opihi/cmd.data/zplot.c
r34613 r38062 4 4 5 5 char *outname = NULL; 6 int i, kapa, valid, size;6 int i, N, kapa, valid, size; 7 7 opihi_flt *out; 8 8 double min, range; 9 9 Graphdata graphmode; 10 Vector *xvec, *yvec, *zvec, Zvec;10 Vector *xvec, *yvec, *zvec, *dxmvec, *dxpvec, *dymvec, *dypvec, Zvec; 11 11 12 12 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 } 13 36 14 37 valid = (argc == 6); … … 40 63 } 41 64 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 42 74 /* find vectors */ 43 75 if ((xvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE); … … 56 88 return (FALSE); 57 89 } 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 58 95 SetVector (&Zvec, OPIHI_FLT, zvec[0].Nelements); 59 96 out = Zvec.elements.Flt; 60 97 98 // note actual size is 3.3x plot -sz sizes. (DrawObjects.c:399) 61 99 if (zvec[0].type == OPIHI_FLT) { 62 100 opihi_flt *in = zvec[0].elements.Flt; … … 81 119 graphmode.style = 2; /* plot points */ 82 120 graphmode.size = -1; /* point size determined by Zvec */ 83 graphmode.etype = 0; /* no errorbars */84 121 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 } 85 130 86 131 free (Zvec.elements.Ptr); 87 132 if (mask) free (mask); 88 DeleteNamedVector (outname); 133 134 if (outname) { 135 DeleteNamedVector (outname); 136 free (outname); 137 } 89 138 90 139 return (TRUE); 91 140 141 mismatch: 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); 92 148 } 93 149 -
trunk/Ohana/src/opihi/dvo/avextract.c
r37807 r38062 221 221 222 222 for (n = 0; n < Nfields; n++) { 223 // we are passing in the *first* measure, but average->Nmeasure gives the count 223 224 values[n] = dbExtractAverages (average, secfilt, measure, lensobj, starpar, &fields[n]); 224 225 } -
trunk/Ohana/src/opihi/include/dvomath.h
r37807 r38062 187 187 int ListBuffersToList PROTO((char *name)); 188 188 int CreateBuffer PROTO((Buffer *buf, int Nx, int Ny, int bitpix, float bzero, float bscale)); 189 int CreateBuffer3D PROTO((Buffer *buf, int Nx, int Ny, int Nz, int bitpix, float bzero, float bscale)); 189 190 int ResetBuffer PROTO((Buffer *buf, int Nx, int Ny, int bitpix, float bzero, float bscale)); 190 191 Buffer *SelectBuffer PROTO((char *name, int mode, int verbose)); -
trunk/Ohana/src/opihi/lib.shell/BufferOps.c
r37807 r38062 120 120 } 121 121 122 // buffer is 1D array referenced in the order: 123 // buffer[x + Nx*y + Nx*Ny*z + ...] 124 int 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 122 149 /* copy data from in to out - new memory space */ 123 150 int CopyNamedBuffer (char *out, char *in) { -
trunk/Ohana/src/opihi/lib.shell/check_stack.c
r36375 r38062 6 6 int check_stack (StackVar *stack, int Nstack, int validsize) { 7 7 8 int i, Nx, Ny, N v, size;8 int i, Nx, Ny, Nz, Nv, size; 9 9 char *c1, *c2; 10 10 11 Nv = Nx = Ny = -1;11 Nv = Nx = Ny = Nz = -1; 12 12 13 13 for (i = 0; i < Nstack; i++) { … … 46 46 Nx = stack[i].buffer[0].matrix.Naxis[0]; 47 47 Ny = stack[i].buffer[0].matrix.Naxis[1]; 48 Nz = stack[i].buffer[0].matrix.Naxis[2]; 48 49 } 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])) { 50 53 push_error ("dimensions don't match"); 51 54 return (-1); -
trunk/Ohana/src/opihi/lib.shell/convert_to_RPN.c
r36679 r38062 60 60 if (!strcmp (argv[i], "xramp")) { type = ST_UNARY; goto gotit; } 61 61 if (!strcmp (argv[i], "yramp")) { type = ST_UNARY; goto gotit; } 62 if (!strcmp (argv[i], "zramp")) { type = ST_UNARY; goto gotit; } 62 63 if (!strcmp (argv[i], "ramp")) { type = ST_UNARY; goto gotit; } 63 64 if (!strcmp (argv[i], "zero")) { type = ST_UNARY; goto gotit; } -
trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c
r36375 r38062 121 121 got_three_op: 122 122 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); 124 124 push_error (line); 125 125 clear_stack (&tmp_stack); -
trunk/Ohana/src/opihi/lib.shell/stack_math.c
r36528 r38062 80 80 break; \ 81 81 } \ 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 } \ 82 148 if ((V1->vector->type == OPIHI_INT) && (V2->vector->type == OPIHI_INT) && (V3->vector->type == OPIHI_INT)) { \ 83 149 CopyVector (OUT[0].vector, V1[0].vector); \ … … 127 193 int MMM_trinary (StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op) { 128 194 129 int i , Nx, Ny;195 int i; 130 196 float *out, *M1, *M2, *M3; 131 197 char line[512]; // this is only used to report an error 132 198 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 136 201 if (V1[0].type == ST_MATRIX_TMP) { /** use V1 as temp buffer **/ 137 202 OUT[0].buffer = V1[0].buffer; … … 154 219 155 220 # define MMM_FUNC(OP) \ 156 for (i = 0; i < N x*Ny; i++, out++, M1++, M2++, M3++) { \221 for (i = 0; i < Npix; i++, out++, M1++, M2++, M3++) { \ 157 222 *out = OP; \ 158 223 } \ … … 531 596 } 532 597 533 // the vector is applied to each column 598 // the vector is applied to each column (currently only valid for 2D matrix) 534 599 int MV_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 535 600 … … 626 691 } 627 692 628 // the vector is applied to each row 693 // the vector is applied to each row (currently only valid for 2D matrix) 629 694 int VM_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 630 695 … … 722 787 int MM_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 723 788 724 int i , Nx, Ny;789 int i; 725 790 float *out, *M1, *M2; 726 791 char line[512]; // this is only used to report an error 727 792 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 731 795 if (V1[0].type == ST_MATRIX_TMP) { /** use V1 as temp buffer **/ 732 796 OUT[0].buffer = V1[0].buffer; … … 748 812 749 813 # define MM_FUNC(OP) \ 750 for (i = 0; i < N x*Ny; i++, out++, M1++, M2++) { \814 for (i = 0; i < Npix; i++, out++, M1++, M2++) { \ 751 815 *out = OP; \ 752 816 } \ … … 803 867 int MS_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 804 868 805 int i , Nx, Ny;869 int i; 806 870 char line[512]; // this is only used to report an error 807 871 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); 810 873 811 874 /* if possible, use V1 as temp buffer, otherwise create new one */ … … 825 888 if (V2->type == ST_SCALAR_FLT) { \ 826 889 opihi_flt M2 = V2[0].FltValue; \ 827 for (i = 0; i < N x*Ny; i++, out++, M1++) { \890 for (i = 0; i < Npix; i++, out++, M1++) { \ 828 891 *out = OP; \ 829 892 } \ … … 832 895 if (V2->type == ST_SCALAR_INT) { \ 833 896 opihi_int M2 = V2[0].IntValue; \ 834 for (i = 0; i < N x*Ny; i++, out++, M1++) { \897 for (i = 0; i < Npix; i++, out++, M1++) { \ 835 898 *out = OP; \ 836 899 } \ … … 881 944 int SM_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 882 945 883 int i , Nx, Ny;946 int i; 884 947 char line[512]; // this is only used to report an error 885 948 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 889 951 if (V2[0].type == ST_MATRIX_TMP) { /* V2[0] is NOT temporary, we can't use it for storage */ 890 952 OUT[0].buffer = V2[0].buffer; … … 902 964 if (V1->type == ST_SCALAR_FLT) { \ 903 965 opihi_flt M1 = V1[0].FltValue; \ 904 for (i = 0; i < N x*Ny; i++, out++, M2++) { \966 for (i = 0; i < Npix; i++, out++, M2++) { \ 905 967 *out = OP; \ 906 968 } \ … … 909 971 if (V1->type == ST_SCALAR_INT) { \ 910 972 opihi_int M1 = V1[0].IntValue; \ 911 for (i = 0; i < N x*Ny; i++, out++, M2++) { \973 for (i = 0; i < Npix; i++, out++, M2++) { \ 912 974 *out = OP; \ 913 975 } \ … … 1240 1302 if (!strcmp (op, "xramp")) V_FUNC(i, ST_SCALAR_INT); 1241 1303 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 */ 1243 1306 1244 1307 # undef V_FUNC … … 1259 1322 int M_unary (StackVar *OUT, StackVar *V1, char *op) { 1260 1323 1261 int i, j, Nx, Ny;1324 int i, j, k; 1262 1325 float *out, *M1; 1263 1326 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 1267 1329 if (V1[0].type == ST_MATRIX_TMP) { 1268 1330 OUT[0].buffer = V1[0].buffer; … … 1277 1339 1278 1340 if (!strcmp (op, "=")) { } 1279 if (!strcmp (op, "abs")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = fabs(*M1); }}1280 if (!strcmp (op, "int")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = (opihi_flt)(long long)(*M1); }}1281 1282 if (!strcmp (op, "floor")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = floor (*M1); }}1283 if (!strcmp (op, "ceil")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = ceil (*M1); }}1284 // if (!strcmp (op, "rint")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = nearbyint (*M1); }}1285 1286 if (!strcmp (op, "exp")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = exp(*M1); }}1287 if (!strcmp (op, "ten")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = pow(10.0,*M1); }}1288 if (!strcmp (op, "log")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = log10(*M1); }}1289 if (!strcmp (op, "ln")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = log(*M1); }}1290 if (!strcmp (op, "sqrt")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = sqrt(*M1); }}1291 if (!strcmp (op, "erf")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = erf(*M1); }}1292 1293 if (!strcmp (op, "sinh")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = sinh(*M1); }}1294 if (!strcmp (op, "cosh")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = cosh(*M1); }}1295 if (!strcmp (op, "asinh")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = asinh(*M1); }}1296 if (!strcmp (op, "acosh")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = acosh(*M1); }}1297 if (!strcmp (op, "lgamma")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = lgamma(*M1); }}1298 1299 if (!strcmp (op, "sin")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = sin(*M1); }}1300 if (!strcmp (op, "cos")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = cos(*M1); }}1301 if (!strcmp (op, "tan")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = tan(*M1); }}1302 if (!strcmp (op, "dsin")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = sin(*M1*RAD_DEG); }}1303 if (!strcmp (op, "dcos")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = cos(*M1*RAD_DEG); }}1304 if (!strcmp (op, "dtan")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = tan(*M1*RAD_DEG); }}1305 if (!strcmp (op, "asin")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = asin(*M1); }}1306 if (!strcmp (op, "acos")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = acos(*M1); }}1307 if (!strcmp (op, "atan")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = atan(*M1); }}1308 if (!strcmp (op, "dasin")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = asin(*M1)*DEG_RAD; }}1309 if (!strcmp (op, "dacos")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = acos(*M1)*DEG_RAD; }}1310 if (!strcmp (op, "datan")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = atan(*M1)*DEG_RAD; }}1311 if (!strcmp (op, "not")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = !(*M1); }}1312 if (!strcmp (op, "--")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = -(*M1); }}1313 if (!strcmp (op, "rnd")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = drand48(); }}1314 if (!strcmp (op, "ramp")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = i; }}1315 if (!strcmp (op, "zero")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = 0; }}1316 if (!strcmp (op, "isinf")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = !finite(*M1); }}1317 if (!strcmp (op, "isnan")) { for (i = 0; i < N x*Ny; i++, out++, M1++) { *out = isnan(*M1); }}1318 1319 /* xrm and yrm only make sense in formatrices. 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 */ 1320 1382 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 } 1324 1391 } 1325 1392 } 1326 1393 } 1327 1394 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 } 1331 1415 } 1332 1416 }
Note:
See TracChangeset
for help on using the changeset viewer.
