Changeset 10794
- Timestamp:
- Dec 16, 2006, 11:58:24 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/dvo/pmeasure.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/pmeasure.c
r8649 r10794 1 1 # include "dvoshell.h" 2 // XXX this function is inefficient if it needs to plot stars for many catalog files 3 // it would be better to accumulate the vectors and occasionally send them to the 4 // screen if the number of points exceeds some limit (say 10k - 100k) 2 # define NCHUNK 10000 5 3 6 4 int pmeasure (int argc, char **argv) { 7 5 8 6 FILE *f; 9 int i, j, k, m, N , status, VERBOSE;7 int i, j, k, m, Narg, Npts, NPTS, status, VERBOSE; 10 8 double Mz, Mr, mag; 11 9 double Radius, Rmin, Rmax, R, D; … … 13 11 unsigned FlagChoice, FlagClip, flags; 14 12 int PhotcodeClip; 13 float *Xvec, *Yvec, *Zvec; 15 14 16 15 SkyTable *sky; … … 18 17 Catalog catalog; 19 18 Graphdata graphmode; 20 Vector Xvec, Yvec, Zvec;21 19 22 20 if (!InitPhotcodes ()) return (FALSE); … … 30 28 31 29 PhotcodeClip = -1; 32 if ((N = get_argument (argc, argv, "-p"))) {33 remove_argument (N , &argc, argv);34 PhotcodeClip = GetPhotcodeCodebyName (argv[N ]);35 remove_argument (N , &argc, argv);30 if ((Narg = get_argument (argc, argv, "-p"))) { 31 remove_argument (Narg, &argc, argv); 32 PhotcodeClip = GetPhotcodeCodebyName (argv[Narg]); 33 remove_argument (Narg, &argc, argv); 36 34 } 37 35 IDchoice = 0; 38 36 IDclip = FALSE; 39 if ((N = get_argument (argc, argv, "-ID"))) {40 remove_argument (N , &argc, argv);41 IDchoice = atoi(argv[N ]);42 remove_argument (N , &argc, argv);37 if ((Narg = get_argument (argc, argv, "-ID"))) { 38 remove_argument (Narg, &argc, argv); 39 IDchoice = atoi(argv[Narg]); 40 remove_argument (Narg, &argc, argv); 43 41 IDclip = TRUE; 44 42 } 45 43 FlagChoice = 0; 46 44 FlagClip = FALSE; 47 if ((N = get_argument (argc, argv, "-flag"))) {48 remove_argument (N , &argc, argv);49 FlagChoice = atoi(argv[N ]);50 remove_argument (N , &argc, argv);45 if ((Narg = get_argument (argc, argv, "-flag"))) { 46 remove_argument (Narg, &argc, argv); 47 FlagChoice = atoi(argv[Narg]); 48 remove_argument (Narg, &argc, argv); 51 49 FlagClip = TRUE; 52 50 } 53 51 54 52 LimExclude = FALSE; 55 if ((N = get_argument (argc, argv, "-x"))) {56 remove_argument (N , &argc, argv);53 if ((Narg = get_argument (argc, argv, "-x"))) { 54 remove_argument (Narg, &argc, argv); 57 55 LimExclude = TRUE; 58 56 } 59 57 60 58 VERBOSE = FALSE; 61 if ((N = get_argument (argc, argv, "-v"))) {62 remove_argument (N , &argc, argv);59 if ((Narg = get_argument (argc, argv, "-v"))) { 60 remove_argument (Narg, &argc, argv); 63 61 VERBOSE = TRUE; 64 62 } 65 63 66 if ((N = get_argument (argc, argv, "-m"))) {67 remove_argument (N , &argc, argv);68 Mr = atof(argv[N ]);69 remove_argument (N , &argc, argv);70 Mz = atof(argv[N ]);64 if ((Narg = get_argument (argc, argv, "-m"))) { 65 remove_argument (Narg, &argc, argv); 66 Mr = atof(argv[Narg]); 67 remove_argument (Narg, &argc, argv); 68 Mz = atof(argv[Narg]); 71 69 Mr = Mr - Mz; 72 remove_argument (N , &argc, argv);70 remove_argument (Narg, &argc, argv); 73 71 } 74 72 … … 78 76 } 79 77 SetGraph (graphmode); 78 graphmode.style = 2; /* set style to points */ 79 graphmode.size = -1; /* point size determined by Zvec */ 80 graphmode.etype = 0; /* no errorbars */ 80 81 81 82 Radius = MAX (fabs(graphmode.xmax), fabs(graphmode.ymax)); … … 85 86 skylist = SkyListByRadius (sky, -1, graphmode.coords.crval1, graphmode.coords.crval2, Radius); 86 87 88 /* storage for plotting the points */ 89 Npts = 0; 90 NPTS = 1000; 91 ALLOCATE (Xvec, float, NPTS); 92 ALLOCATE (Yvec, float, NPTS); 93 ALLOCATE (Zvec, float, NPTS); 94 87 95 for (j = 0; j < skylist[0].Nregions; j++) { 88 96 catalog.filename = skylist[0].filename[j]; … … 97 105 dvo_catalog_unlock (&catalog); 98 106 99 /* data has been loaded, get ready to plot it */100 Xvec.Nelements = catalog.Nmeasure;101 Yvec.Nelements = catalog.Nmeasure;102 Zvec.Nelements = catalog.Nmeasure;103 ALLOCATE (Xvec.elements, float, Xvec.Nelements);104 ALLOCATE (Yvec.elements, float, Yvec.Nelements);105 ALLOCATE (Zvec.elements, float, Zvec.Nelements);106 107 107 /* project stars to screen display coords */ 108 Xvec.Nelements = 0; 109 for (N = i = 0; i < catalog.Naverage; i++) { 108 for (i = 0; i < catalog.Naverage; i++) { 110 109 if (IDclip && (catalog.average[i].code != IDchoice)) continue; 111 110 while (catalog.average[i].R < Rmin) catalog.average[i].R += 360.0; … … 119 118 if ((PhotcodeClip != -1) && (catalog.measure[m+k].source != PhotcodeClip)) continue; 120 119 mag = PhotCat (&catalog.measure[m+k]); 121 Zvec .elements[N] = MIN (1.0, MAX (0.01, (mag - Mz) / Mr));122 if (LimExclude && (Zvec .elements[N] > 0.99)) continue;123 if (Zvec .elements[N] < 0.011) continue;120 Zvec[Npts] = MIN (1.0, MAX (0.01, (mag - Mz) / Mr)); 121 if (LimExclude && (Zvec[Npts] > 0.99)) continue; 122 if (Zvec[Npts] < 0.011) continue; 124 123 R = catalog.average[i].R - catalog.measure[m+k].dR_PS/3600.0; 125 124 D = catalog.average[i].D - catalog.measure[m+k].dD_PS/3600.0; … … 131 130 free (date); 132 131 } 133 status = fRD_to_XY (&Xvec .elements[N], &Yvec.elements[N], R, D, &graphmode.coords);132 status = fRD_to_XY (&Xvec[Npts], &Yvec[Npts], R, D, &graphmode.coords); 134 133 if (!status) { 135 134 fprintf (stderr, "."); 136 135 continue; 137 136 } 138 N ++; 137 Npts ++; 138 139 if (Npts == NPTS - 1) { 140 NPTS += 1000; 141 REALLOCATE (Xvec, float, NPTS); 142 REALLOCATE (Yvec, float, NPTS); 143 REALLOCATE (Zvec, float, NPTS); 144 } 145 if (Npts > NCHUNK) { 146 PlotVectorTriplet (Npts, Xvec, Yvec, Zvec, &graphmode); 147 Npts = 0; 148 } 139 149 } 140 150 } 141 Zvec.Nelements = Yvec.Nelements = Xvec.Nelements = N;142 143 graphmode.style = 2; /* set style to points */144 graphmode.size = -1; /* point size determined by Zvec */145 graphmode.etype = 0; /* no errorbars */146 PrepPlotting (N, &graphmode);147 148 PlotVector (N, Xvec.elements);149 PlotVector (N, Yvec.elements);150 PlotVector (N, Zvec.elements);151 152 free (Xvec.elements);153 free (Yvec.elements);154 free (Zvec.elements);155 156 151 dvo_catalog_free (&catalog); 157 152 } 153 if (Npts > 0) PlotVectorTriplet (Npts, Xvec, Yvec, Zvec, &graphmode); 154 155 free (Xvec); 156 free (Yvec); 157 free (Zvec); 158 158 159 return (TRUE); 159 160
Note:
See TracChangeset
for help on using the changeset viewer.
