Changeset 42942
- Timestamp:
- Nov 12, 2025, 5:00:47 PM (8 months ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 6 edited
-
cmd.astro/cdhistogram.c (modified) (1 diff)
-
cmd.astro/cgrid.c (modified) (9 diffs)
-
cmd.astro/region.c (modified) (2 diffs)
-
cmd.basic/quit.c (modified) (2 diffs)
-
cmd.data/section.c (modified) (5 diffs)
-
cmd.data/tdhistogram.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.astro/cdhistogram.c
r41341 r42942 40 40 41 41 if (argc != 7) { 42 gprint (GP_ERR, "USAGE: cdhistogram buffer R D value (min) (max) [-delta dval] \n");42 gprint (GP_ERR, "USAGE: cdhistogram buffer R D value (min) (max) [-delta dval] [-range vec] [-binning N]\n"); 43 43 gprint (GP_ERR, " output buffer is 3D\n"); 44 44 return (FALSE); -
trunk/Ohana/src/opihi/cmd.astro/cgrid.c
r41515 r42942 12 12 # define ADD_COORDINATE(RA,DEC) \ 13 13 status = RD_to_XY (&Xvec.elements.Flt[N], &Yvec.elements.Flt[N], (RA), (DEC), &graphmode.coords); \ 14 if ((Xvec.elements.Flt[N] >= graphmode.xmin) && (Xvec.elements.Flt[N] <= graphmode.xmax) && \15 (Yvec.elements.Flt[N] >= graphmode.ymin) && (Yvec.elements.Flt[N] <= graphmode.ymax) && status) { \14 if ((Xvec.elements.Flt[N] >= Xmin) && (Xvec.elements.Flt[N] <= Xmax) && \ 15 (Yvec.elements.Flt[N] >= Ymin) && (Yvec.elements.Flt[N] <= Ymax) && status) { \ 16 16 N++; \ 17 17 CHECKELEMENTS; \ … … 154 154 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 155 155 156 // we need to rationalize graphmode.xmin,xmax (can be flipped) 157 int Xmin = MIN(graphmode.xmin,graphmode.xmax); 158 int Xmax = MAX(graphmode.xmin,graphmode.xmax); 159 int Ymin = MIN(graphmode.ymin,graphmode.ymax); 160 int Ymax = MAX(graphmode.ymin,graphmode.ymax); 161 156 162 if (argc != 1) goto usage; 157 163 … … 159 165 NorthPole = SouthPole = FALSE; 160 166 status = RD_to_XY (&x, &y, 0.0, 90.0, &graphmode.coords); 161 if ((x >= graphmode.xmin) && (x <= graphmode.xmax) && 162 (y >= graphmode.ymin) && (y <= graphmode.ymax) && status) 167 // if the parity is flipped in either direction, xmin > xmax or ymin > ymax 168 if ((x >= Xmin) && (x <= Xmax) && 169 (y >= Ymin) && (y <= Ymax) && status) 163 170 NorthPole = TRUE; 164 171 status = RD_to_XY (&x, &y, 0.0, -90.0, &graphmode.coords); 165 if ((x >= graphmode.xmin) && (x <= graphmode.xmax) &&166 (y >= graphmode.ymin) && (y <= graphmode.ymax) && status)172 if ((x >= Xmin) && (x <= Xmax) && 173 (y >= Ymin) && (y <= Ymax) && status) 167 174 SouthPole = TRUE; 168 175 … … 173 180 if (mode == PROJ_MODE_PSEUDOCYL) { 174 181 // for PSEUDOCYL, the ra range is 360 if the corners are invalid 175 InvalidCorner |= XY_to_RD (&r, &d, graphmode.xmin, graphmode.ymin, &graphmode.coords);176 InvalidCorner |= XY_to_RD (&r, &d, graphmode.xmax, graphmode.ymin, &graphmode.coords);177 InvalidCorner |= XY_to_RD (&r, &d, graphmode.xmax, graphmode.ymax, &graphmode.coords);178 InvalidCorner |= XY_to_RD (&r, &d, graphmode.xmin, graphmode.ymax, &graphmode.coords);182 InvalidCorner |= XY_to_RD (&r, &d, Xmin, Ymin, &graphmode.coords); 183 InvalidCorner |= XY_to_RD (&r, &d, Xmax, Ymin, &graphmode.coords); 184 InvalidCorner |= XY_to_RD (&r, &d, Xmax, Ymax, &graphmode.coords); 185 InvalidCorner |= XY_to_RD (&r, &d, Xmin, Ymax, &graphmode.coords); 179 186 } 180 187 181 range = MIN (fabs(graphmode.coords.cdelt1*( graphmode.xmax-graphmode.xmin)), fabs(graphmode.coords.cdelt2*(graphmode.ymax-graphmode.ymin)));188 range = MIN (fabs(graphmode.coords.cdelt1*(Xmax-Xmin)), fabs(graphmode.coords.cdelt2*(Ymax-Ymin))); 182 189 if (NorthPole || SouthPole || InvalidCorner) range = 360; 183 190 dR = range * GRID_SPACING; … … 266 273 char line[16], format[16]; 267 274 double xt, yt, frac; 268 // dx = +0.01 * ( graphmode.xmax - graphmode.xmin);269 // dy = -0.02 * ( graphmode.ymax - graphmode.ymin);275 // dx = +0.01 * (Xmax - Xmin); 276 // dy = -0.02 * (Ymax - Ymin); 270 277 271 278 if (isnan(LabelRA)) LabelRA = graphmode.coords.crval1; … … 274 281 status = RD_to_XY (&xt, &yt, r, LabelDEC, &graphmode.coords); 275 282 if (!status) continue; 276 if (xt < graphmode.xmin) continue;277 if (xt > graphmode.xmax) continue;278 if (yt < graphmode.ymin) continue;279 if (yt > graphmode.ymax) continue;283 if (xt < Xmin) continue; 284 if (xt > Xmax) continue; 285 if (yt < Ymin) continue; 286 if (yt > Ymax) continue; 280 287 frac = -1.0 * log10(minorRA); 281 288 if (frac != (int)frac) { … … 295 302 status = RD_to_XY (&xt, &yt, r, LabelDEC, &graphmode.coords); 296 303 if (!status) continue; 297 if (xt < graphmode.xmin) continue;298 if (xt > graphmode.xmax) continue;299 if (yt < graphmode.ymin) continue;300 if (yt > graphmode.ymax) continue;304 if (xt < Xmin) continue; 305 if (xt > Xmax) continue; 306 if (yt < Ymin) continue; 307 if (yt > Ymax) continue; 301 308 frac = -1.0 * log10(minorRA); 302 309 if (frac != (int)frac) { … … 316 323 status = RD_to_XY (&xt, &yt, LabelRA, d, &graphmode.coords); 317 324 if (!status) continue; 318 if (xt < graphmode.xmin) continue;319 if (xt > graphmode.xmax) continue;320 if (yt < graphmode.ymin) continue;321 if (yt > graphmode.ymax) continue;325 if (xt < Xmin) continue; 326 if (xt > Xmax) continue; 327 if (yt < Ymin) continue; 328 if (yt > Ymax) continue; 322 329 frac = -1.0 * log10(minorDEC); 323 330 if (frac != (int)frac) { … … 332 339 status = RD_to_XY (&xt, &yt, LabelRA, d, &graphmode.coords); 333 340 if (!status) continue; 334 if (xt < graphmode.xmin) continue;335 if (xt > graphmode.xmax) continue;336 if (yt < graphmode.ymin) continue;337 if (yt > graphmode.ymax) continue;341 if (xt < Xmin) continue; 342 if (xt > Xmax) continue; 343 if (yt < Ymin) continue; 344 if (yt > Ymax) continue; 338 345 frac = -1.0 * log10(minorDEC); 339 346 if (frac != (int)frac) { -
trunk/Ohana/src/opihi/cmd.astro/region.c
r42821 r42942 35 35 KapaGetImageCoords (kapa, &graphmode.coords); 36 36 KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin, &dXpix, &dYpix); 37 // XXX here (xmin,xmax),(ymin,ymax) are ??? 38 // below, (xmin,xmax),(ymin,ymax) are set to put 0,0 in the graph center (-dx to +dx) 37 39 38 40 set_variable ("XMIN", graphmode.xmin); … … 40 42 set_variable ("YMIN", graphmode.ymin); 41 43 set_variable ("YMAX", graphmode.ymax); 42 44 // XXX Ra,Dec not defined at this point 43 45 set_variable ("RMIN", Ra + graphmode.xmin); 44 46 set_variable ("RMAX", Ra + graphmode.xmax); -
trunk/Ohana/src/opihi/cmd.basic/quit.c
r14449 r42942 3 3 int quit (int argc, char **argv) { 4 4 5 int state; 5 int N, state; 6 7 int VERBOSE = FALSE; 8 if ((N = get_argument (argc, argv, "-verbose"))) { 9 remove_argument (N, &argc, argv); 10 VERBOSE = TRUE; 11 } 12 if ((N = get_argument (argc, argv, "-v"))) { 13 remove_argument (N, &argc, argv); 14 VERBOSE = TRUE; 15 } 6 16 7 17 cleanup (); … … 18 28 # endif 19 29 30 if (VERBOSE) { 31 ohana_memcheck (TRUE); 32 ohana_memdump (TRUE); 33 ohana_memdump_strings_file (stderr, TRUE); 34 } 35 20 36 exit (state); 37 } 21 38 22 } 39 /* values which cannot be freed on quit: 40 41 parse.c:329 (reallocated command line) 42 parse_commands.c:33 (command argv array) 43 command.c:52 (command targv array) 44 command.c:15 (copy of command line) 45 46 */ -
trunk/Ohana/src/opihi/cmd.data/section.c
r31160 r42942 1 1 # include "data.h" 2 2 3 enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL, BG, IMAGE };3 enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL, BG, IMAGE, IMCENTER}; 4 4 5 5 int section (int argc, char **argv) { … … 17 17 } 18 18 if ((N = get_argument (argc, argv, "-up"))) { 19 if (action != NONE) goto escape; 19 20 action = UP; 20 21 remove_argument (N, &argc, argv); 21 22 } 22 23 if ((N = get_argument (argc, argv, "-down"))) { 24 if (action != NONE) goto escape; 23 25 action = DOWN; 24 26 remove_argument (N, &argc, argv); 25 27 } 26 28 if ((N = get_argument (argc, argv, "-top"))) { 29 if (action != NONE) goto escape; 27 30 action = TOP; 28 31 remove_argument (N, &argc, argv); 29 32 } 30 33 if ((N = get_argument (argc, argv, "-bottom"))) { 34 if (action != NONE) goto escape; 31 35 action = BOTTOM; 32 36 remove_argument (N, &argc, argv); 33 37 } 34 38 if ((N = get_argument (argc, argv, "-imtool"))) { 39 if (action != NONE) goto escape; 35 40 action = TOOL; 36 41 remove_argument (N, &argc, argv); … … 41 46 background = -1; // invisible 42 47 if ((N = get_argument (argc, argv, "-bg"))) { 48 if (action != NONE) goto escape; 43 49 remove_argument (N, &argc, argv); 44 50 if (!strcasecmp (argv[N], "NONE")) { … … 52 58 53 59 if ((N = get_argument (argc, argv, "-image"))) { 60 if (action != NONE) goto escape; 54 61 remove_argument (N, &argc, argv); 55 62 action = IMAGE; 63 } 64 65 if ((N = get_argument (argc, argv, "-imcenter"))) { 66 if (action != NONE) goto escape; 67 remove_argument (N, &argc, argv); 68 action = IMCENTER; 56 69 } 57 70 … … 65 78 FREE (name); 66 79 67 /* list sections */ 68 if ((argc == 1) && (action == NONE)) { 69 KapaGetSection (kapa, "*"); 70 gprint (GP_ERR, "USAGE: section name [x y dx dy] or [options]\n"); 71 gprint (GP_ERR, "OPTIONS: -list : show properties of all sections\n"); 72 gprint (GP_ERR, " -up : move section up in display stack\n"); 73 gprint (GP_ERR, " -down : move section down in display stack\n"); 74 gprint (GP_ERR, " -top : move section to top of display stack\n"); 75 gprint (GP_ERR, " -bottom : move section to bottom of display stack\n"); 76 gprint (GP_ERR, " -imtool (position) : set location of image zoom / status box\n"); 77 gprint (GP_ERR, " (position may be: -x, +x, -y, +y, none)\n"); 78 gprint (GP_ERR, " -image : define section upper-right corner so image fills the section\n"); 79 gprint (GP_ERR, " -bg (color) : set background color (see style -c help for color choices)\n"); 80 81 return (TRUE); 82 } 83 84 if ((argc != 2) && (action != NONE)) { 85 gprint (GP_ERR, "can only use dash options without numbers\n"); 80 // deal with these cases first 81 if (action == NONE) { 82 if (argc == 1) { // command: section 83 gprint (GP_ERR, "USAGE: section name x y dx dy\n"); 84 gprint (GP_ERR, " section name -image x y\n"); 85 gprint (GP_ERR, " section name [options]\n"); 86 gprint (GP_ERR, "OPTIONS: -list : show properties of all sections\n"); 87 gprint (GP_ERR, " -up : move section up in display stack\n"); 88 gprint (GP_ERR, " -down : move section down in display stack\n"); 89 gprint (GP_ERR, " -top : move section to top of display stack\n"); 90 gprint (GP_ERR, " -bottom : move section to bottom of display stack\n"); 91 gprint (GP_ERR, " -imtool (position) : set location of image zoom / status box\n"); 92 gprint (GP_ERR, " (position may be: -x, +x, -y, +y, none)\n"); 93 gprint (GP_ERR, " -image : define section upper-right corner so image fills the section\n"); 94 gprint (GP_ERR, " -bg (color) : set background color (see style -c help for color choices or use NONE)\n"); 95 return (TRUE); 96 } 97 if (argc == 2) { // command: section name 98 KapaSelectSection (kapa, argv[1]); 99 return TRUE; 100 } 101 if (argc == 6) { // command: section name x y dx dy 102 /* set section */ 103 section.name = argv[1]; 104 section.x = atof (argv[2]); 105 section.y = atof (argv[3]); 106 section.dx = atof (argv[4]); 107 section.dy = atof (argv[5]); 108 section.bg = -2; // bg must be set on its own 109 KapaSetSection (kapa, §ion); 110 return (TRUE); 111 } 112 goto escape; 113 } 114 115 // list properties of the specified section, or all sections 116 if (action == LIST) { 117 if (argc == 1) { 118 KapaGetSection (kapa, "*"); 119 return TRUE; 120 } 121 if (argc == 2) { 122 KapaGetSection (kapa, argv[1]); 123 KapaSelectSection (kapa, argv[1]); 124 return TRUE; 125 } 126 goto escape; 127 } 128 129 if ((action == IMAGE) || (action == IMCENTER)) { 130 if (argc != 4) goto escape; 131 } else { 132 if (argc != 2) goto escape; 133 } 134 135 /* select / show section */ 136 switch (action) { 137 case UP: 138 KapaMoveSection (kapa, argv[1], "up"); 139 break; 140 case DOWN: 141 KapaMoveSection (kapa, argv[1], "down"); 142 break; 143 case TOP: 144 KapaMoveSection (kapa, argv[1], "top"); 145 break; 146 case BOTTOM: 147 KapaMoveSection (kapa, argv[1], "bottom"); 148 break; 149 150 case BG: 151 KapaSectionBG (kapa, argv[1], background); 152 break; 153 154 case TOOL: 155 KapaSelectSection (kapa, argv[1]); 156 if (!strcmp(location, "-x")) { 157 KapaSetToolbox (kapa, 1); 158 break; 159 } 160 if (!strcmp(location, "+x")) { 161 KapaSetToolbox (kapa, 3); 162 break; 163 } 164 if (!strcmp(location, "-y")) { 165 KapaSetToolbox (kapa, 2); 166 break; 167 } 168 if (!strcmp(location, "+y")) { 169 KapaSetToolbox (kapa, 4); 170 break; 171 } 172 if (!strcmp(location, "none")) { 173 KapaSetToolbox (kapa, 0); 174 break; 175 } 176 gprint (GP_ERR, "unknown toolbox location %s\n", location); 177 gprint (GP_ERR, "valid values: -x, +x, -y, +y, none\n"); 86 178 return (FALSE); 87 } 88 89 if (argc == 2) { 90 /* select / show section */ 91 switch (action) { 92 case NONE: 93 KapaSelectSection (kapa, argv[1]); 94 break; 95 96 case UP: 97 KapaMoveSection (kapa, argv[1], "up"); 98 break; 99 case DOWN: 100 KapaMoveSection (kapa, argv[1], "down"); 101 break; 102 case TOP: 103 KapaMoveSection (kapa, argv[1], "top"); 104 break; 105 case BOTTOM: 106 KapaMoveSection (kapa, argv[1], "bottom"); 107 break; 108 109 case BG: 110 KapaSectionBG (kapa, argv[1], background); 111 break; 112 113 case TOOL: 114 if (!strcmp(location, "-x")) { 115 KapaSetToolbox (kapa, 1); 116 break; 117 } 118 if (!strcmp(location, "+x")) { 119 KapaSetToolbox (kapa, 3); 120 break; 121 } 122 if (!strcmp(location, "-y")) { 123 KapaSetToolbox (kapa, 2); 124 break; 125 } 126 if (!strcmp(location, "+y")) { 127 KapaSetToolbox (kapa, 4); 128 break; 129 } 130 if (!strcmp(location, "none")) { 131 KapaSetToolbox (kapa, 0); 132 break; 133 } 134 gprint (GP_ERR, "unknown toolbox location %s\n", location); 135 gprint (GP_ERR, "valid values: -x, +x, -y, +y, none\n"); 136 return (FALSE); 137 138 case LIST: 139 KapaGetSection (kapa, argv[1]); 140 break; 141 } 142 return (TRUE); 143 } 144 145 if (argc == 4) { 146 /* set section */ 147 section.name = argv[1]; 148 section.x = atof (argv[2]); 149 section.y = atof (argv[3]); 150 section.bg = background; 151 KapaSetSectionByImage (kapa, §ion); 152 return (TRUE); 153 } 154 155 if (argc == 6) { 156 /* set section */ 157 section.name = argv[1]; 158 section.x = atof (argv[2]); 159 section.y = atof (argv[3]); 160 section.dx = atof (argv[4]); 161 section.dy = atof (argv[5]); 162 section.bg = background; 163 KapaSetSection (kapa, §ion); 164 return (TRUE); 165 } 166 gprint (GP_ERR, "USAGE: section name [x y dx dy]\n"); 167 gprint (GP_ERR, "USAGE: section name [-image x y] : width based on current image\n"); 168 gprint (GP_ERR, "USAGE: section name [-list] [-up] [-down] [-top] [-bottom]\n"); 179 180 case IMAGE: 181 /* set section */ 182 section.name = argv[1]; 183 section.x = atof (argv[2]); 184 section.y = atof (argv[3]); 185 section.bg = -2; 186 KapaSetSectionByImage (kapa, §ion); 187 return (TRUE); 188 189 case IMCENTER: 190 /* set section */ 191 section.name = argv[1]; 192 section.x = atof (argv[2]); 193 section.y = atof (argv[3]); 194 KapaSetSectionCenterByImage (kapa, §ion); 195 return (TRUE); 196 197 case NONE: 198 case LIST: 199 default: 200 gprint (GP_ERR, "oops, programming error in section.c:171\n"); 201 break; 202 } 203 return (TRUE); 204 205 escape: 206 gprint (GP_ERR, "USAGE: section name : select the section\n"); 207 gprint (GP_ERR, "USAGE: section name x y dx dy : define section location\n"); 208 gprint (GP_ERR, "USAGE: section name -image x y : width based on current image\n"); 209 gprint (GP_ERR, "USAGE: section name -imtool (position) : width based on current image\n"); 210 gprint (GP_ERR, "USAGE: section name [-list] [-up] [-down] [-top] [-bottom] [-bg color]\n"); 211 gprint (GP_ERR, " only one -OPTION at a time\n"); 169 212 return (FALSE); 170 213 } -
trunk/Ohana/src/opihi/cmd.data/tdhistogram.c
r41891 r42942 5 5 int tdhistogram (int argc, char **argv) { 6 6 7 int i, N x, Ny, Nz, N;7 int i, N; 8 8 float *val; 9 9 Buffer *bf; 10 10 Vector *vx, *vy, *vz, *range; 11 11 opihi_flt *x, *y, *z; 12 int kapa; 13 Graphdata graphmode; 14 15 int useGraph = FALSE; 16 if ((N = get_argument (argc, argv, "-graph"))) { 17 remove_argument (N, &argc, argv); 18 useGraph = TRUE; 19 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 20 } 12 21 13 22 int reuse = FALSE; 14 23 if ((N = get_argument (argc, argv, "-reuse"))) { 24 if (useGraph) { gprint (GP_ERR, "-reuse and -graph are incompatible\n"); return FALSE; } 15 25 remove_argument (N, &argc, argv); 16 26 reuse = TRUE; 27 } 28 29 int Nx = 100; 30 double dx = NAN; 31 if ((N = get_argument (argc, argv, "-dx"))) { 32 if (useGraph) { gprint (GP_ERR, "-dx and -graph are incompatible\n"); return FALSE; } 33 remove_argument (N, &argc, argv); 34 dx = atof(argv[N]); 35 remove_argument (N, &argc, argv); 36 } 37 if ((N = get_argument (argc, argv, "-Nx"))) { 38 if (useGraph) { gprint (GP_ERR, "-Nx and -graph are incompatible\n"); return FALSE; } 39 if (isfinite(dx)) { gprint (GP_ERR, "-Nx and -dx are incompatible\n"); return FALSE; } 40 remove_argument (N, &argc, argv); 41 Nx = atoi(argv[N]); 42 remove_argument (N, &argc, argv); 43 } 44 45 int Ny = 100; 46 double dy = NAN; 47 if ((N = get_argument (argc, argv, "-dy"))) { 48 if (useGraph) { gprint (GP_ERR, "-dx and -graph are incompatible\n"); return FALSE; } 49 remove_argument (N, &argc, argv); 50 dy = atof(argv[N]); 51 remove_argument (N, &argc, argv); 52 } 53 if ((N = get_argument (argc, argv, "-Ny"))) { 54 if (useGraph) { gprint (GP_ERR, "-Ny and -graph are incompatible\n"); return FALSE; } 55 if (isfinite(dy)) { gprint (GP_ERR, "-Ny and -dy are incompatible\n"); return FALSE; } 56 remove_argument (N, &argc, argv); 57 Ny = atoi(argv[N]); 58 remove_argument (N, &argc, argv); 59 } 60 61 int Nz = 100; 62 double dz = NAN; 63 if ((N = get_argument (argc, argv, "-dz"))) { 64 remove_argument (N, &argc, argv); 65 dz = atof(argv[N]); 66 remove_argument (N, &argc, argv); 67 } 68 if ((N = get_argument (argc, argv, "-Nz"))) { 69 if (useGraph) { gprint (GP_ERR, "-Nz and -graph are incompatible\n"); return FALSE; } 70 if (isfinite(dz)) { gprint (GP_ERR, "-Nz and -dz are incompatible\n"); return FALSE; } 71 remove_argument (N, &argc, argv); 72 Nz = atoi(argv[N]); 73 remove_argument (N, &argc, argv); 74 } 75 76 int binning = 1; 77 if ((N = get_argument (argc, argv, "-binning"))) { 78 if (!useGraph) { gprint (GP_ERR, "-binning requires -graph\n"); return FALSE; } 79 remove_argument (N, &argc, argv); 80 binning = atoi(argv[N]); 81 remove_argument (N, &argc, argv); 17 82 } 18 83 … … 24 89 } 25 90 26 double dx = NAN; 27 if ((N = get_argument (argc, argv, "-dx"))) { 28 remove_argument (N, &argc, argv); 29 dx = atof(argv[N]); 30 remove_argument (N, &argc, argv); 31 } 32 double dy = NAN; 33 if ((N = get_argument (argc, argv, "-dy"))) { 34 remove_argument (N, &argc, argv); 35 dy = atof(argv[N]); 36 remove_argument (N, &argc, argv); 37 } 38 double dz = NAN; 39 if ((N = get_argument (argc, argv, "-dz"))) { 40 remove_argument (N, &argc, argv); 41 dz = atof(argv[N]); 42 remove_argument (N, &argc, argv); 43 } 44 45 int valid = (!reuse && (argc == 11)) || (reuse && (argc == 5)); 91 int valid = (reuse && (argc == 5)) || (useGraph && (argc == 7)) || (argc == 11); 46 92 if (!valid) { 47 93 gprint (GP_ERR, "USAGE: tdhistogram buffer x y z (Xmin) (Xmax) (Ymin) (Ymax) (Zmin) (Zmax) [-dx dx] [-dy dy] [-dz dz] [-range range]\n"); 94 gprint (GP_ERR, "USAGE: tdhistogram buffer x y z (Zmin) (Zmax) -graph [-binning N] [-dz dz] [-range range]\n"); 48 95 gprint (GP_ERR, " OR: tdhistogram buffer x y z -reuse\n"); 49 96 gprint (GP_ERR, " -dx, -dy, -dy specify the bin size in these directions\n"); 50 97 gprint (GP_ERR, " -range : generate an output vector corresponding to the elements in the z-direction\n"); 98 gprint (GP_ERR, " -graph : use X,Y range from active graph\n"); 99 gprint (GP_ERR, " -binning N : use binning to define bin sizes relative to graph\n"); 51 100 gprint (GP_ERR, " output buffer is 3D\n"); 52 101 return (FALSE); … … 63 112 double Xmin, Xmax, Ymin, Ymax, Zmin, Zmax; 64 113 65 if (!reuse) { 66 Xmin = atof(argv[5]); 67 Xmax = atof(argv[6]); 68 if (!isfinite(dx)) { 69 Nx = 100; 70 dx = (Xmax - Xmin) / (Nx - 1); 71 } else { 72 Nx = (Xmax - Xmin) / dx + 1; 73 } 74 if (dx < 0) { 75 gprint (GP_ERR, "invalid value for delta: %f\n", dx); 76 return (FALSE); 77 } 78 Ymin = atof(argv[7]); 79 Ymax = atof(argv[8]); 80 if (!isfinite(dy)) { 81 Ny = 100; 82 dy = (Ymax - Ymin) / (Ny - 1); 83 } else { 84 Ny = (Ymax - Ymin) / dy + 1; 85 } 86 if (dy < 0) { 87 gprint (GP_ERR, "invalid value for delta: %f\n", dy); 88 return (FALSE); 89 } 90 Zmin = atof(argv[9]); 91 Zmax = atof(argv[10]); 92 if (!isfinite(dz)) { 93 Nz = 100; 94 dz = (Zmax - Zmin) / (Nz - 1); 95 } else { 96 Nz = (Zmax - Zmin) / dz + 1; 97 } 98 if (dz < 0) { 99 gprint (GP_ERR, "invalid value for delta: %f\n", dz); 100 return (FALSE); 101 } 102 103 if (Nz > 1000) { 104 gprint (GP_ERR, "warning: delta of %f will result in %d histogram bins\n", dz, Nz); 105 return (FALSE); 106 } 107 } else { 114 if (reuse) { 108 115 gfits_scan (&bf[0].header, "XMIN", "%lf", 1, &Xmin); 109 116 gfits_scan (&bf[0].header, "XMAX", "%lf", 1, &Xmax); … … 118 125 Ny = bf[0].header.Naxis[1]; 119 126 Nz = bf[0].header.Naxis[2]; 120 } 121 127 goto got_range; 128 } 129 130 if (useGraph) { 131 int Xpix, Ypix; 132 KapaGetImageRange (kapa, &Xmin, &Xmax, &Ymax, &Ymin, &Xpix, &Ypix); 133 Xmax = graphmode.xmax; 134 Xmin = graphmode.xmin; 135 Ymax = graphmode.ymax; 136 Ymin = graphmode.ymin; 137 138 // (dX, dY) are the pixel scale of the output image (output pixels / input pixels) 139 140 dx = binning * (Xmax - Xmin) / (Xpix - 1); 141 dy = binning * (Ymax - Ymin) / (Ypix - 1); 142 143 Nx = abs((Xmax - Xmin) / dx) + 1; 144 Ny = abs((Ymax - Ymin) / dy) + 1; 145 146 // XXX : note that Zmin and Zmax have a different argv location in useGraph 147 Zmin = atof(argv[5]); 148 Zmax = atof(argv[6]); 149 150 goto set_Zvalues; 151 } 152 153 // This section is only used if !reuse and !useGraph 154 Xmin = atof(argv[5]); 155 Xmax = atof(argv[6]); 156 if (!isfinite(dx)) { 157 dx = (Xmax - Xmin) / (Nx - 1); 158 } else { 159 Nx = (Xmax - Xmin) / dx + 1; 160 } 161 if (dx < 0) { 162 gprint (GP_ERR, "invalid value for delta: %f\n", dx); 163 return (FALSE); 164 } 165 Ymin = atof(argv[7]); 166 Ymax = atof(argv[8]); 167 if (!isfinite(dy)) { 168 dy = (Ymax - Ymin) / (Ny - 1); 169 } else { 170 Ny = (Ymax - Ymin) / dy + 1; 171 } 172 if (dy < 0) { 173 gprint (GP_ERR, "invalid value for delta: %f\n", dy); 174 return (FALSE); 175 } 176 // XXX : note that Zmin and Zmax have a different argv location in useGraph 177 Zmin = atof(argv[9]); 178 Zmax = atof(argv[10]); 179 180 set_Zvalues: 181 if (!isfinite(dz)) { 182 dz = (Zmax - Zmin) / (Nz - 1); 183 } else { 184 Nz = (Zmax - Zmin) / dz + 1; 185 } 186 if (dz < 0) { 187 gprint (GP_ERR, "invalid value for delta: %f\n", dz); 188 return (FALSE); 189 } 190 if (Nz > 1000) { 191 gprint (GP_ERR, "warning: delta of %f will result in %d histogram bins\n", dz, Nz); 192 return (FALSE); 193 } 194 195 got_range: 122 196 REQUIRE_VECTOR_FLT (vx, FALSE); 123 197 REQUIRE_VECTOR_FLT (vy, FALSE);
Note:
See TracChangeset
for help on using the changeset viewer.
