Changeset 26258
- Timestamp:
- Nov 22, 2009, 2:54:39 PM (16 years ago)
- Location:
- trunk/Ohana/src
- Files:
-
- 6 edited
-
addstar/src/MatchHeaders.c (modified) (2 diffs)
-
getstar/src/getstar.c (modified) (1 diff)
-
opihi/cmd.astro/cgrid.c (modified) (3 diffs)
-
opihi/cmd.data/grid.c (modified) (3 diffs)
-
opihi/dvo/dbExtractMeasures.c (modified) (1 diff)
-
opihi/include/data.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/src/MatchHeaders.c
r25910 r26258 6 6 7 7 int i, j, Nimage, NIMAGE; 8 char extname[80], exttype[80], exthead[80] ;8 char extname[80], exttype[80], exthead[80], xtension[80]; 9 9 HeaderSet *headerSets; 10 10 … … 46 46 extsize[0][i] = headers[i][0].size + gfits_data_size (headers[i]); 47 47 } 48 49 // is this a fits table? (otherwise we skip it) 50 if (!gfits_scan (headers[i], "XTENSION", "%s", 1, xtension)) continue; 51 if (strcmp (xtension, "BINTABLE")) continue; 48 52 49 53 if (!gfits_scan (headers[i], "EXTTYPE", "%s", 1, exttype)) continue; -
trunk/Ohana/src/getstar/src/getstar.c
r25757 r26258 74 74 /* skip empty catalogs */ 75 75 select_by_region (&output, &catalog, ®ION, 0, 0); 76 dvo_catalog_free (&catalog); 76 77 } 77 78 break; -
trunk/Ohana/src/opihi/cmd.astro/cgrid.c
r25757 r26258 1 1 # include "astro.h" 2 # define CHECKELEMENTS \ 3 if (N == NELEMENTS) { \ 4 NELEMENTS +=200; \ 5 REALLOCATE (Xvec.elements.Flt, opihi_flt, NELEMENTS); \ 6 REALLOCATE (Yvec.elements.Flt, opihi_flt, NELEMENTS); \ 2 3 # define GRID_SPACING 0.002 4 5 # define CHECKELEMENTS \ 6 if (N == NELEMENTS) { \ 7 NELEMENTS +=200; \ 8 REALLOCATE (Xvec.elements.Flt, opihi_flt, NELEMENTS); \ 9 REALLOCATE (Yvec.elements.Flt, opihi_flt, NELEMENTS); \ 10 } 11 12 # define ADD_COORDINATE(RA,DEC) \ 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) { \ 16 N++; \ 17 CHECKELEMENTS; \ 18 OnPic = TRUE; \ 19 if (!First) { \ 20 Xvec.elements.Flt[N] = Xvec.elements.Flt[N-1]; \ 21 Yvec.elements.Flt[N] = Yvec.elements.Flt[N-1]; \ 22 N++; \ 23 CHECKELEMENTS; \ 24 } else { \ 25 if (N > 1) { \ 26 Xvec.elements.Flt[N-2] = Xvec.elements.Flt[N-1]; \ 27 Yvec.elements.Flt[N-2] = Yvec.elements.Flt[N-1]; \ 28 N--; \ 29 } \ 30 First = FALSE; \ 31 } \ 32 } else { \ 33 LOnPic = FALSE; \ 34 First = TRUE; \ 35 } 36 37 # define ADD_DEC_LINE(RA) \ 38 /* first, DEC increasing */ \ 39 LOnPic = TRUE; \ 40 OnPic = FALSE; \ 41 First = TRUE; \ 42 for (d = firstDEC; (d < 90 + dD) && (LOnPic || NorthPole || SouthPole); d += dD) { \ 43 D = MAX (-90, MIN(90, d)); \ 44 ADD_COORDINATE((RA), D); \ 45 } \ 46 /* next, DEC decreasing */ \ 47 First = TRUE; \ 48 LOnPic = TRUE; \ 49 for (d = firstDEC; (d > -90 - dD) && (LOnPic || NorthPole || SouthPole); d -= dD) { \ 50 D = MAX (-90, MIN(90, d)); \ 51 ADD_COORDINATE((RA), D); \ 52 } 53 54 # define ADD_RA_LINE(DEC) \ 55 D = MAX (-90, MIN(90, (DEC))); \ 56 /* first, RA increasing */ \ 57 LOnPic = TRUE; \ 58 OnPic = FALSE; \ 59 First = TRUE; \ 60 lastRA = graphmode.coords.crval1 + 180.0; \ 61 for (r = firstRA; (r < lastRA + dR) && (LOnPic || NorthPole || SouthPole); r += dR) { \ 62 R = MIN (r, lastRA); \ 63 ADD_COORDINATE(R, D); \ 64 } \ 65 /* next, RA decreasing */ \ 66 First = TRUE; \ 67 LOnPic = TRUE; \ 68 lastRA = graphmode.coords.crval1 - 180.0; \ 69 for (r = firstRA; (r > lastRA - dR) && (LOnPic || NorthPole || SouthPole); r -= dR) { \ 70 R = MAX (r, lastRA); \ 71 ADD_COORDINATE(R, D); \ 7 72 } 8 73 9 74 int cgrid (int argc, char **argv) { 10 75 11 double range, lrange, factor, mantis, power, fmantis;12 double firstRA, firstDEC, minorRA, minorDEC;13 double r, d, dR, dD, D;76 double range, minor, major; 77 double firstRA, lastRA, firstDEC, minorRA, minorDEC; 78 double r, d, dR, dD, R, D; 14 79 double x, y; 15 80 Vector Xvec, Yvec; 16 int kapa, NorthPole, SouthPole, N, OnPic, LOnPic, status, NELEMENTS, First; 81 int kapa, NorthPole, SouthPole, N, OnPic, LOnPic, status, NELEMENTS; 82 int First, RAbyHour, Labels; 17 83 Graphdata graphmode; 84 85 RAbyHour = FALSE; 86 if ((N = get_argument (argc, argv, "-ra-by-hour"))) { 87 remove_argument (N, &argc, argv); 88 RAbyHour = TRUE; 89 } 90 91 Labels = FALSE; 92 if ((N = get_argument (argc, argv, "-labels"))) { 93 remove_argument (N, &argc, argv); 94 Labels = TRUE; 95 } 18 96 19 97 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; … … 39 117 range = MIN (fabs(graphmode.coords.cdelt1*(graphmode.xmax-graphmode.xmin)), fabs(graphmode.coords.cdelt2*(graphmode.ymax-graphmode.ymin))); 40 118 if (NorthPole || SouthPole) range = 360; 41 lrange = log10(MAX(fabs(range), 1e-30)); 42 factor = (int) (lrange); 43 if (lrange < 0) { factor -= 1; } 44 mantis = lrange - factor; 45 power = pow(10.0, factor); 46 fmantis = pow(10.0, mantis); 47 if ((fmantis >= 1.0) && (fmantis <= 2.0)) { 48 minorRA = 0.1 * power; 49 } 50 if ((fmantis > 2.0) && (fmantis <= 4.0)) { 51 minorRA = 0.2 * power; 52 } 53 if ((fmantis > 4.0) && (fmantis <= 6.0)) { 54 minorRA = 0.5 * power; 55 } 56 if ((fmantis > 6.0) && (fmantis <= 10.0)) { 57 minorRA = 0.5 * power; 58 } 59 dR = range / 100.0; 119 120 if (RAbyHour) { 121 SetGridScales (&major, &minor, range / 15.0); 122 minorRA = minor * 15.0; 123 } else { 124 SetGridScales (&major, &minor, range); 125 minorRA = minor; 126 } 127 dR = range * GRID_SPACING; 60 128 61 129 /* set spacings for DEC */ 62 130 range = MIN (fabs(graphmode.coords.cdelt1*(graphmode.xmax-graphmode.xmin)), fabs(graphmode.coords.cdelt2*(graphmode.ymax-graphmode.ymin))); 63 lrange = log10(MAX(fabs(range), 1e-30)); 64 factor = (int) (lrange); 65 if (lrange < 0) { factor -= 1; } 66 mantis = lrange - factor; 67 power = pow(10.0, factor); 68 fmantis = pow(10.0, mantis); 69 if ((fmantis >= 1.0) && (fmantis <= 2.0)) { 70 minorDEC = 0.1 * power; 71 } 72 if ((fmantis > 2.0) && (fmantis <= 4.0)) { 73 minorDEC = 0.2 * power; 74 } 75 if ((fmantis > 4.0) && (fmantis <= 6.0)) { 76 minorDEC = 0.5 * power; 77 } 78 if ((fmantis > 6.0) && (fmantis <= 10.0)) { 79 minorDEC = 0.5 * power; 80 } 81 dD = range / 100.0; 131 SetGridScales (&major, &minor, range); 132 minorDEC = minor; 133 dD = range * GRID_SPACING; 82 134 83 135 /* choose a starting point */ … … 103 155 /*** do consecutive RA lines, first increasing **/ 104 156 OnPic = TRUE; 105 for (r = firstRA; (r <= firstRA + 180) && (OnPic); r += minorRA) { 106 /* first, DEC increasing */ 107 LOnPic = TRUE; 108 OnPic = FALSE; 109 First = TRUE; 110 for (d = firstDEC; (d < 90 + dD) && (LOnPic || NorthPole || SouthPole); d += dD) { 111 D = MAX (-90, MIN(90, d)); 112 status = RD_to_XY (&Xvec.elements.Flt[N], &Yvec.elements.Flt[N], r, D, &graphmode.coords); 113 /* 114 if ((fabs(Xvec.elements.Flt[N] - Xvec.elements.Flt[N-1]) > 10) && (fabs(Yvec.elements.Flt[N] - Yvec.elements.Flt[N-1]) > 10)) 115 First = TRUE; 116 */ 117 if ((Xvec.elements.Flt[N] >= graphmode.xmin) && (Xvec.elements.Flt[N] <= graphmode.xmax) && 118 (Yvec.elements.Flt[N] >= graphmode.ymin) && (Yvec.elements.Flt[N] <= graphmode.ymax) && status) { 119 N++; 120 CHECKELEMENTS; 121 OnPic = TRUE; 122 if (!First) { 123 Xvec.elements.Flt[N] = Xvec.elements.Flt[N-1]; 124 Yvec.elements.Flt[N] = Yvec.elements.Flt[N-1]; 125 N++; 126 CHECKELEMENTS; 127 } else { 128 if (N > 1) { 129 Xvec.elements.Flt[N-2] = Xvec.elements.Flt[N-1]; 130 Yvec.elements.Flt[N-2] = Yvec.elements.Flt[N-1]; 131 N--; 132 } 133 First = FALSE; 134 } 157 lastRA = graphmode.coords.crval1 + 180.0; 158 for (r = firstRA; (r <= lastRA) && (OnPic); r += minorRA) { 159 ADD_DEC_LINE (r); 160 } 161 if (r != lastRA) { 162 ADD_DEC_LINE (lastRA); 163 } 164 165 /*** do consecutive RA lines, decreasing **/ 166 OnPic = TRUE; 167 lastRA = graphmode.coords.crval1 - 180.0; 168 for (r = firstRA; (r >= lastRA) && (OnPic); r -= minorRA) { 169 ADD_DEC_LINE (r); 170 } 171 if (r != lastRA) { 172 ADD_DEC_LINE (lastRA); 173 } 174 175 /*** do consecutive DEC lines, first increasing **/ 176 OnPic = TRUE; 177 for (d = firstDEC; (d < 90 + dD) && (OnPic); d += minorDEC) { 178 ADD_RA_LINE (d); 179 } 180 181 /*** do consecutive DEC lines, decreasing **/ 182 OnPic = TRUE; 183 for (d = firstDEC; (d > -90 - dD) && (OnPic); d -= minorDEC) { 184 ADD_RA_LINE (d); 185 } 186 187 // add labels for center lines: 188 if (Labels) { 189 char line[16], format[8]; 190 double xt, yt, dx, dy, frac; 191 dx = +0.01 * (graphmode.xmax - graphmode.xmin); 192 dy = -0.02 * (graphmode.ymax - graphmode.ymin); 193 194 for (r = firstRA; r <= graphmode.coords.crval1 + 180.0; r += minorRA) { 195 status = RD_to_XY (&xt, &yt, r, graphmode.coords.crval2, &graphmode.coords); 196 if (!status) continue; 197 if (xt < graphmode.xmin) continue; 198 if (xt > graphmode.xmax) continue; 199 if (yt < graphmode.ymin) continue; 200 if (yt > graphmode.ymax) continue; 201 frac = -1.0 * log10(minorRA); 202 if (frac != (int)frac) { 203 frac += 1.0; 204 } 205 if (frac <= 0.0) frac = 0.0; 206 snprintf (format, 8, "%%.%df", (int) frac); 207 if (RAbyHour) { 208 snprintf (line, 16, format, r / 15.0); 135 209 } else { 136 LOnPic = FALSE; 137 First = TRUE; 138 } 139 } 140 /* next, DEC decreasing */ 141 First = TRUE; 142 LOnPic = TRUE; 143 for (d = firstDEC; (d > -90 - dD) && (LOnPic || NorthPole || SouthPole); d -= dD) { 144 D = MAX (-90, MIN(90, d)); 145 status = RD_to_XY (&Xvec.elements.Flt[N], &Yvec.elements.Flt[N], r, D, &graphmode.coords); 146 /* 147 if ((fabs(Xvec.elements.Flt[N] - Xvec.elements.Flt[N-1]) > 10) && (fabs(Yvec.elements.Flt[N] - Yvec.elements.Flt[N-1]) > 10)) 148 First = TRUE; 149 */ 150 if ((Xvec.elements.Flt[N] >= graphmode.xmin) && (Xvec.elements.Flt[N] <= graphmode.xmax) && 151 (Yvec.elements.Flt[N] >= graphmode.ymin) && (Yvec.elements.Flt[N] <= graphmode.ymax) && status) { 152 N++; 153 CHECKELEMENTS; 154 OnPic = TRUE; 155 if (!First) { 156 Xvec.elements.Flt[N] = Xvec.elements.Flt[N-1]; 157 Yvec.elements.Flt[N] = Yvec.elements.Flt[N-1]; 158 N++; 159 CHECKELEMENTS; 160 } else { 161 if (N > 1) { 162 Xvec.elements.Flt[N-2] = Xvec.elements.Flt[N-1]; 163 Yvec.elements.Flt[N-2] = Yvec.elements.Flt[N-1]; 164 N--; 165 } 166 First = FALSE; 167 } 210 snprintf (line, 16, format, r); 211 } 212 KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0); 213 } 214 for (r = firstRA; r >= graphmode.coords.crval1 - 180.0; r -= minorRA) { 215 status = RD_to_XY (&xt, &yt, r, graphmode.coords.crval2, &graphmode.coords); 216 if (!status) continue; 217 if (xt < graphmode.xmin) continue; 218 if (xt > graphmode.xmax) continue; 219 if (yt < graphmode.ymin) continue; 220 if (yt > graphmode.ymax) continue; 221 frac = -1.0 * log10(minorRA); 222 if (frac != (int)frac) { 223 frac += 1.0; 224 } 225 if (frac <= 0.0) frac = 0.0; 226 snprintf (format, 8, "%%.%df", (int) frac); 227 if (RAbyHour) { 228 snprintf (line, 16, format, r / 15.0); 168 229 } else { 169 LOnPic = FALSE; 170 First = TRUE; 171 } 172 } 173 } 174 175 /*** do consecutive RA lines, decreasing **/ 176 OnPic = TRUE; 177 for (r = firstRA; (r >= firstRA - 180) && (OnPic); r -= minorRA) { 178 /* first, DEC increasing */ 179 First = TRUE; 180 LOnPic = TRUE; 181 OnPic = FALSE; 182 for (d = firstDEC; (d < 90 + dD) && (LOnPic || NorthPole || SouthPole); d += dD) { 183 D = MAX (-90, MIN(90, d)); 184 status = RD_to_XY (&Xvec.elements.Flt[N], &Yvec.elements.Flt[N], r, D, &graphmode.coords); 185 /* 186 if ((fabs(Xvec.elements.Flt[N] - Xvec.elements.Flt[N-1]) > 10) && (fabs(Yvec.elements.Flt[N] - Yvec.elements.Flt[N-1]) > 10)) 187 First = TRUE; 188 */ 189 if ((Xvec.elements.Flt[N] >= graphmode.xmin) && (Xvec.elements.Flt[N] <= graphmode.xmax) && 190 (Yvec.elements.Flt[N] >= graphmode.ymin) && (Yvec.elements.Flt[N] <= graphmode.ymax) && status) { 191 N++; 192 CHECKELEMENTS; 193 OnPic = TRUE; 194 if (!First) { 195 Xvec.elements.Flt[N] = Xvec.elements.Flt[N-1]; 196 Yvec.elements.Flt[N] = Yvec.elements.Flt[N-1]; 197 N++; 198 CHECKELEMENTS; 199 } else { 200 if (N > 1) { 201 Xvec.elements.Flt[N-2] = Xvec.elements.Flt[N-1]; 202 Yvec.elements.Flt[N-2] = Yvec.elements.Flt[N-1]; 203 N--; 204 } 205 First = FALSE; 206 } 207 } else { 208 LOnPic = FALSE; 209 First = TRUE; 210 } 211 } 212 /* next, DEC decreasing */ 213 First = TRUE; 214 LOnPic = TRUE; 215 for (d = firstDEC; (d > -90 - dD) && (LOnPic || NorthPole || SouthPole); d -= dD) { 216 D = MAX (-90, MIN(90, d)); 217 status = RD_to_XY (&Xvec.elements.Flt[N], &Yvec.elements.Flt[N], r, D, &graphmode.coords); 218 /* 219 if ((fabs(Xvec.elements.Flt[N] - Xvec.elements.Flt[N-1]) > 10) && (fabs(Yvec.elements.Flt[N] - Yvec.elements.Flt[N-1]) > 10)) 220 First = TRUE; 221 */ 222 if ((Xvec.elements.Flt[N] >= graphmode.xmin) && (Xvec.elements.Flt[N] <= graphmode.xmax) && 223 (Yvec.elements.Flt[N] >= graphmode.ymin) && (Yvec.elements.Flt[N] <= graphmode.ymax) && status) { 224 N++; 225 CHECKELEMENTS; 226 OnPic = TRUE; 227 if (!First) { 228 Xvec.elements.Flt[N] = Xvec.elements.Flt[N-1]; 229 Yvec.elements.Flt[N] = Yvec.elements.Flt[N-1]; 230 N++; 231 CHECKELEMENTS; 232 } else { 233 if (N > 1) { 234 Xvec.elements.Flt[N-2] = Xvec.elements.Flt[N-1]; 235 Yvec.elements.Flt[N-2] = Yvec.elements.Flt[N-1]; 236 N--; 237 } 238 First = FALSE; 239 } 240 } else { 241 LOnPic = FALSE; 242 First = TRUE; 243 } 244 } 245 } 246 247 /*** do consecutive DEC lines, first increasing **/ 248 OnPic = TRUE; 249 for (d = firstDEC; (d < 90 + dD) && (OnPic); d += minorDEC) { 250 D = MAX (-90, MIN(90, d)); 251 /* first, RA increasing */ 252 LOnPic = TRUE; 253 OnPic = FALSE; 254 First = TRUE; 255 for (r = firstRA; (r < firstRA + 180) && (LOnPic || NorthPole || SouthPole); r += dR) { 256 status = RD_to_XY (&Xvec.elements.Flt[N], &Yvec.elements.Flt[N], r, D, &graphmode.coords); 257 /* 258 if ((fabs(Xvec.elements.Flt[N] - Xvec.elements.Flt[N-1]) > 10) && (fabs(Yvec.elements.Flt[N] - Yvec.elements.Flt[N-1]) > 10)) 259 First = TRUE; 260 */ 261 if ((Xvec.elements.Flt[N] >= graphmode.xmin) && (Xvec.elements.Flt[N] <= graphmode.xmax) && 262 (Yvec.elements.Flt[N] >= graphmode.ymin) && (Yvec.elements.Flt[N] <= graphmode.ymax) && status) { 263 N++; 264 CHECKELEMENTS; 265 OnPic = TRUE; 266 if (!First) { 267 Xvec.elements.Flt[N] = Xvec.elements.Flt[N-1]; 268 Yvec.elements.Flt[N] = Yvec.elements.Flt[N-1]; 269 N++; 270 CHECKELEMENTS; 271 } else { 272 if (N > 1) { 273 Xvec.elements.Flt[N-2] = Xvec.elements.Flt[N-1]; 274 Yvec.elements.Flt[N-2] = Yvec.elements.Flt[N-1]; 275 N--; 276 } 277 First = FALSE; 278 } 279 } else { 280 LOnPic = FALSE; 281 First = TRUE; 282 } 283 } 284 /* next, RA decreasing */ 285 First = TRUE; 286 LOnPic = TRUE; 287 for (r = firstRA; (r > firstRA - 180) && (LOnPic || NorthPole || SouthPole); r -= dR) { 288 status = RD_to_XY (&Xvec.elements.Flt[N], &Yvec.elements.Flt[N], r, D, &graphmode.coords); 289 /* 290 if ((fabs(Xvec.elements.Flt[N] - Xvec.elements.Flt[N-1]) > 10) && (fabs(Yvec.elements.Flt[N] - Yvec.elements.Flt[N-1]) > 10)) 291 First = TRUE; 292 */ 293 if ((Xvec.elements.Flt[N] >= graphmode.xmin) && (Xvec.elements.Flt[N] <= graphmode.xmax) && 294 (Yvec.elements.Flt[N] >= graphmode.ymin) && (Yvec.elements.Flt[N] <= graphmode.ymax) && status) { 295 N++; 296 CHECKELEMENTS; 297 OnPic = TRUE; 298 if (!First) { 299 Xvec.elements.Flt[N] = Xvec.elements.Flt[N-1]; 300 Yvec.elements.Flt[N] = Yvec.elements.Flt[N-1]; 301 N++; 302 CHECKELEMENTS; 303 } else { 304 if (N > 1) { 305 Xvec.elements.Flt[N-2] = Xvec.elements.Flt[N-1]; 306 Yvec.elements.Flt[N-2] = Yvec.elements.Flt[N-1]; 307 N--; 308 } 309 First = FALSE; 310 } 311 } else { 312 LOnPic = FALSE; 313 First = TRUE; 314 } 315 } 316 } 317 318 /*** do consecutive DEC lines, decreasing **/ 319 OnPic = TRUE; 320 for (d = firstDEC; (d > -90 - dD) && (OnPic); d -= minorDEC) { 321 D = MAX (-90, MIN(90, d)); 322 /* first, RA increasing */ 323 LOnPic = TRUE; 324 OnPic = FALSE; 325 First = TRUE; 326 for (r = firstRA; (r < firstRA + 180) && (LOnPic || NorthPole || SouthPole); r += dR) { 327 status = RD_to_XY (&Xvec.elements.Flt[N], &Yvec.elements.Flt[N], r, D, &graphmode.coords); 328 /* 329 if ((fabs(Xvec.elements.Flt[N] - Xvec.elements.Flt[N-1]) > 10) && (fabs(Yvec.elements.Flt[N] - Yvec.elements.Flt[N-1]) > 10)) 330 First = TRUE; 331 */ 332 if ((Xvec.elements.Flt[N] >= graphmode.xmin) && (Xvec.elements.Flt[N] <= graphmode.xmax) && 333 (Yvec.elements.Flt[N] >= graphmode.ymin) && (Yvec.elements.Flt[N] <= graphmode.ymax) && status) { 334 N++; 335 CHECKELEMENTS; 336 OnPic = TRUE; 337 if (!First) { 338 Xvec.elements.Flt[N] = Xvec.elements.Flt[N-1]; 339 Yvec.elements.Flt[N] = Yvec.elements.Flt[N-1]; 340 N++; 341 CHECKELEMENTS; 342 } else { 343 if (N > 1) { 344 Xvec.elements.Flt[N-2] = Xvec.elements.Flt[N-1]; 345 Yvec.elements.Flt[N-2] = Yvec.elements.Flt[N-1]; 346 N--; 347 } 348 First = FALSE; 349 } 350 } else { 351 LOnPic = FALSE; 352 First = TRUE; 353 } 354 } 355 /* next, RA decreasing */ 356 First = TRUE; 357 LOnPic = TRUE; 358 for (r = firstRA; (r > firstRA - 180) && (LOnPic || NorthPole || SouthPole); r -= dR) { 359 status = RD_to_XY (&Xvec.elements.Flt[N], &Yvec.elements.Flt[N], r, D, &graphmode.coords); 360 /* 361 if ((fabs(Xvec.elements.Flt[N] - Xvec.elements.Flt[N-1]) > 10) && (fabs(Yvec.elements.Flt[N] - Yvec.elements.Flt[N-1]) > 10)) 362 First = TRUE; 363 */ 364 if ((Xvec.elements.Flt[N] >= graphmode.xmin) && (Xvec.elements.Flt[N] <= graphmode.xmax) && 365 (Yvec.elements.Flt[N] >= graphmode.ymin) && (Yvec.elements.Flt[N] <= graphmode.ymax) && status) { 366 N++; 367 CHECKELEMENTS; 368 OnPic = TRUE; 369 if (!First) { 370 Xvec.elements.Flt[N] = Xvec.elements.Flt[N-1]; 371 Yvec.elements.Flt[N] = Yvec.elements.Flt[N-1]; 372 N++; 373 CHECKELEMENTS; 374 } else { 375 if (N > 1) { 376 Xvec.elements.Flt[N-2] = Xvec.elements.Flt[N-1]; 377 Yvec.elements.Flt[N-2] = Yvec.elements.Flt[N-1]; 378 N--; 379 } 380 First = FALSE; 381 } 382 } else { 383 LOnPic = FALSE; 384 First = TRUE; 385 } 386 } 387 } 388 230 snprintf (line, 16, format, r); 231 } 232 KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0); 233 } 234 for (d = firstDEC; d <= graphmode.coords.crval2 + 90.0; d += minorDEC) { 235 status = RD_to_XY (&xt, &yt, graphmode.coords.crval1, d, &graphmode.coords); 236 if (!status) continue; 237 if (xt < graphmode.xmin) continue; 238 if (xt > graphmode.xmax) continue; 239 if (yt < graphmode.ymin) continue; 240 if (yt > graphmode.ymax) continue; 241 frac = -1.0 * log10(minorDEC); 242 if (frac != (int)frac) { 243 frac += 1.0; 244 } 245 if (frac <= 0.0) frac = 0.0; 246 snprintf (format, 8, "%%.%df", (int) frac); 247 snprintf (line, 16, format, d); 248 KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0); 249 } 250 for (d = firstDEC; d >= graphmode.coords.crval2 - 90.0; d -= minorDEC) { 251 status = RD_to_XY (&xt, &yt, graphmode.coords.crval1, d, &graphmode.coords); 252 if (!status) continue; 253 if (xt < graphmode.xmin) continue; 254 if (xt > graphmode.xmax) continue; 255 if (yt < graphmode.ymin) continue; 256 if (yt > graphmode.ymax) continue; 257 frac = -1.0 * log10(minorDEC); 258 if (frac != (int)frac) { 259 frac += 1.0; 260 } 261 if (frac <= 0.0) frac = 0.0; 262 snprintf (format, 8, "%%.%df", (int) frac); 263 snprintf (line, 16, format, d); 264 KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0); 265 } 266 } 267 389 268 /* send the line segments as connect-points */ 390 269 Xvec.Nelements = Yvec.Nelements = N; -
trunk/Ohana/src/opihi/cmd.data/grid.c
r20936 r26258 1 1 # include "data.h" 2 3 int SetGridScales (double *major, double *minor, double range) { 4 5 double lrange, factor, mantis, fmantis, power; 6 7 lrange = log10(MAX(fabs(range), 1e-30)); 8 factor = (int) (lrange); 9 if (lrange < 0) { factor -= 1; } 10 mantis = lrange - factor; 11 power = pow(10.0, factor); 12 fmantis = pow(10.0, mantis); 13 if ((fmantis >= 1.0) && (fmantis <= 2.0)) { 14 *major = 0.5 * power; 15 *minor = 0.1 * power; 16 } 17 if ((fmantis > 2.0) && (fmantis <= 4.0)) { 18 *major = 1.0 * power; 19 *minor = 0.2 * power; 20 } 21 if ((fmantis > 4.0) && (fmantis <= 6.0)) { 22 *major = 1.0 * power; 23 *minor = 0.5 * power; 24 } 25 if ((fmantis > 6.0) && (fmantis <= 10.0)) { 26 *major = 2.0 * power; 27 *minor = 0.5 * power; 28 } 29 return TRUE; 30 } 2 31 3 32 int grid (int argc, char **argv) { 4 33 34 double range, major, minor, first, next; 5 35 int j, kapa, N, MinorTick, MajorTick; 6 36 Vector Xvec, Yvec; 7 double range, lrange, factor, mantis, fmantis, power, major, minor, first, next;8 37 Graphdata graphmode; 9 38 … … 28 57 major = minor = 1; 29 58 range = graphmode.xmax - graphmode.xmin; 30 lrange = log10(MAX(fabs(range), 1e-30)); 31 factor = (int) (lrange); 32 if (lrange < 0) { factor -= 1; } 33 mantis = lrange - factor; 34 power = pow(10.0, factor); 35 fmantis = pow(10.0, mantis); 36 if ((fmantis >= 1.0) && (fmantis <= 2.0)) { 37 major = 0.5 * power; 38 minor = 0.1 * power; 39 } 40 if ((fmantis > 2.0) && (fmantis <= 4.0)) { 41 major = 1.0 * power; 42 minor = 0.2 * power; 43 } 44 if ((fmantis > 4.0) && (fmantis <= 6.0)) { 45 major = 1.0 * power; 46 minor = 0.5 * power; 47 } 48 if ((fmantis > 6.0) && (fmantis <= 10.0)) { 49 major = 2.0 * power; 50 minor = 0.5 * power; 51 } 59 SetGridScales (&major, &minor, range); 52 60 if (graphmode.xmin > 0) 53 61 first = minor + minor*((int)(graphmode.xmin/minor)); … … 108 116 109 117 range = graphmode.ymax - graphmode.ymin; 110 lrange = log10(MAX(fabs(range), 1e-30)); 111 factor = (int) (lrange); 112 if (lrange < 0) { factor -= 1; } 113 mantis = lrange - factor; 114 power = pow(10.0, factor); 115 fmantis = pow(10.0, mantis); 116 if ((fmantis >= 1.0) && (fmantis <= 2.0)) { 117 major = 0.5 * power; 118 minor = 0.1 * power; 119 } 120 if ((fmantis > 2.0) && (fmantis <= 4.0)) { 121 major = 1.0 * power; 122 minor = 0.2 * power; 123 } 124 if ((fmantis > 4.0) && (fmantis <= 6.0)) { 125 major = 1.0 * power; 126 minor = 0.5 * power; 127 } 128 if ((fmantis > 6.0) && (fmantis <= 10.0)) { 129 major = 2.0 * power; 130 minor = 0.5 * power; 131 } 118 SetGridScales (&major, &minor, range); 132 119 if (graphmode.ymin > 0) 133 120 first = minor + minor*((int)(graphmode.ymin/minor)); -
trunk/Ohana/src/opihi/dvo/dbExtractMeasures.c
r25056 r26258 298 298 case MEAS_PHOTCODE_EQUIV: /* OK */ 299 299 value.Int = GetPhotcodeEquivCodebyCode (measure[0].photcode); 300 break; 301 case MEAS_PHOTCODE: /* OK */ 302 value.Int = measure[0].photcode; 300 303 break; 301 304 case MEAS_TIME: /* OK */ -
trunk/Ohana/src/opihi/include/data.h
r21153 r26258 143 143 double get_epoch (char *in_epoch, char mode); 144 144 145 int SetGridScales (double *major, double *minor, double range); 146 145 147 /* graphtools.c */ 146 148 void SetLimits PROTO((Vector *xvec, Vector *yvec, Graphdata *graphmode));
Note:
See TracChangeset
for help on using the changeset viewer.
