Changeset 33737
- Timestamp:
- Apr 9, 2012, 2:07:40 PM (14 years ago)
- Location:
- branches/eam_branches/ipp-20120405/Ohana/src/opihi
- Files:
-
- 2 edited
-
cmd.data/vgroup.c (modified) (4 diffs)
-
dvo/skycoverage.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120405/Ohana/src/opihi/cmd.data/vgroup.c
r25757 r33737 1 1 # include "data.h" 2 3 enum {USE_MEDIAN, USE_COUNT, USE_SUM, USE_MEAN}; 2 4 3 5 int vgroup (int argc, char **argv) { … … 23 25 // } 24 26 27 int mode = USE_MEDIAN; 28 if ((N = get_argument (argc, argv, "-sum"))) { 29 remove_argument (N, &argc, argv); 30 mode = USE_SUM; 31 } 32 if ((N = get_argument (argc, argv, "-mean"))) { 33 remove_argument (N, &argc, argv); 34 mode = USE_MEAN; 35 } 36 37 float binsize = NAN; 38 if ((N = get_argument (argc, argv, "-binsize"))) { 39 remove_argument (N, &argc, argv); 40 binsize = atof(argv[N]); 41 remove_argument (N, &argc, argv); 42 } 43 25 44 if (argc != 5) { 26 gprint (GP_ERR, "USAGE: v bin<xin> <yin> <xout> <yout>\n");45 gprint (GP_ERR, "USAGE: vgroup <xin> <yin> <xout> <yout>\n"); 27 46 gprint (GP_ERR, " group x,y values in bins defined by <xout>\n"); 47 gprint (GP_ERR, " by default, yout has the median of the associated input values\n"); 48 gprint (GP_ERR, " use -sum to add values in the bin\n"); 49 gprint (GP_ERR, " use <yin> = histogram count matching values\n"); 50 gprint (GP_ERR, " use -binsize to specify a fixed bin width (<xout> will define the bin center)\n"); 28 51 return (FALSE); 29 52 } 30 53 31 54 if ((xin = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE); 32 if ((yin = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE);33 55 if ((xout = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) return (FALSE); 34 56 if ((yout = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE); 57 yin = NULL; 58 59 // this should conflict with the -sum option... 60 if (!strcmp(argv[2], "histogram")) { 61 mode = USE_COUNT; 62 } else { 63 if ((yin = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE); 64 } 35 65 36 66 // re-binning creates a float vector … … 41 71 42 72 for (i = 0; i < xout[0].Nelements - 1; i++) { 43 xmin = xout[0].elements.Flt[i]; 44 xmax = xout[0].elements.Flt[i+1]; 73 if (isnan(binsize)) { 74 xmin = xout[0].elements.Flt[i]; 75 xmax = xout[0].elements.Flt[i+1]; 76 } else { 77 xmin = xout[0].elements.Flt[i] - 0.5*binsize; 78 xmax = xout[0].elements.Flt[i] + 0.5*binsize; 79 } 45 80 46 81 N = 0; … … 48 83 if (xin[0].elements.Flt[j] < xmin) continue; 49 84 if (xin[0].elements.Flt[j] > xmax) continue; 50 values[N] = yin[0].elements.Flt[j]; 85 if (yin) { 86 values[N] = yin[0].elements.Flt[j]; 87 } 51 88 N++; 52 89 } 53 90 54 dsort (values, N); 55 if (N > 1) { 56 sum = (N % 2) ? values[(int)(0.5*N)] : 0.5*(values[N/2] + values[N/2 + 1]); 57 } else { 58 sum = values[0]; 91 sum = NAN; 92 switch (mode) { 93 case USE_MEDIAN: 94 dsort (values, N); 95 if (N > 1) { 96 sum = (N % 2) ? values[(int)(0.5*N)] : 0.5*(values[N/2] + values[N/2 + 1]); 97 } else { 98 sum = values[0]; 99 } 100 break; 101 102 case USE_SUM: 103 sum = 0.0; 104 for (j = 0; j < N; j++) { 105 sum += values[j]; 106 } 107 break; 108 109 case USE_COUNT: 110 sum = N; 111 break; 112 113 case USE_MEAN: 114 sum = 0.0; 115 for (j = 0; j < N; j++) { 116 sum += values[j]; 117 } 118 sum /= N; 119 break; 59 120 } 60 61 // measure the stat for this bin62 // sum = 0.0;63 // for (j = 0; j < N; j++) {64 // sum += values[j];65 // }66 // sum /= N;67 121 yout[0].elements.Flt[i] = sum; 68 122 } -
branches/eam_branches/ipp-20120405/Ohana/src/opihi/dvo/skycoverage.c
r33662 r33737 2 2 3 3 // enum to define possible modes 4 enum {COVERAGE, DENSITY, MIN_UBERCAL, MIN_DMAG_SYS, MIN_MCAL, MAX_MCAL };4 enum {COVERAGE, DENSITY, MIN_UBERCAL, MIN_DMAG_SYS, MIN_MCAL, MAX_MCAL, MIN_TIME, MAX_TIME}; 5 5 6 6 int wordhash (char *word); … … 23 23 PhotCode *PhotcodeValue; 24 24 25 time_t TimeReference; 26 int TimeFormat; 27 28 GetTimeFormat (&TimeReference, &TimeFormat); 29 25 30 WITH_MOSAIC = FALSE; 26 31 if ((N = get_argument (argc, argv, "+mosaic"))) { … … 71 76 remove_argument (N, &argc, argv); 72 77 mode = MIN_UBERCAL; 78 } 79 if ((N = get_argument (argc, argv, "-min-time"))) { 80 remove_argument (N, &argc, argv); 81 mode = MIN_TIME; 82 } 83 if ((N = get_argument (argc, argv, "-max-time"))) { 84 remove_argument (N, &argc, argv); 85 mode = MAX_TIME; 73 86 } 74 87 if ((N = get_argument (argc, argv, "-min-dmag-sys"))) { … … 231 244 case MIN_DMAG_SYS: 232 245 case MIN_MCAL: 233 V[ys*Nx + xs] = 1E6; 246 case MIN_TIME: 247 V[ys*Nx + xs] = 1E9; 234 248 break; 235 249 case MAX_MCAL: 236 V[ys*Nx + xs] = -1E6; 250 case MAX_TIME: 251 V[ys*Nx + xs] = -1E9; 237 252 break; 238 253 } … … 247 262 case MIN_MCAL: 248 263 case MAX_MCAL: 264 case MIN_TIME: 265 case MAX_TIME: 249 266 V[ys*Nx + xs] = NAN; 250 267 break; … … 323 340 V[ys*Nx + xs] = MAX(V[ys*Nx + xs], image[i].Mcal); 324 341 break; 342 case MIN_TIME: { 343 double timeVal = TimeValue (image[i].tzero, TimeReference, TimeFormat); 344 V[ys*Nx + xs] = MIN(V[ys*Nx + xs], timeVal); 345 break; } 346 case MAX_TIME: { 347 double timeVal = TimeValue (image[i].tzero, TimeReference, TimeFormat); 348 V[ys*Nx + xs] = MAX(V[ys*Nx + xs], timeVal); 349 break; } 325 350 } 326 351 }
Note:
See TracChangeset
for help on using the changeset viewer.
