IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33737


Ignore:
Timestamp:
Apr 9, 2012, 2:07:40 PM (14 years ago)
Author:
eugene
Message:

add -min-time, -max-time to skycoverage; add several stats options to vgroup

Location:
branches/eam_branches/ipp-20120405/Ohana/src/opihi
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120405/Ohana/src/opihi/cmd.data/vgroup.c

    r25757 r33737  
    11# include "data.h"
     2
     3enum {USE_MEDIAN, USE_COUNT, USE_SUM, USE_MEAN};
    24
    35int vgroup (int argc, char **argv) {
     
    2325  // }
    2426
     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
    2544  if (argc != 5) {
    26     gprint (GP_ERR, "USAGE: vbin <xin> <yin> <xout> <yout>\n");
     45    gprint (GP_ERR, "USAGE: vgroup <xin> <yin> <xout> <yout>\n");
    2746    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");
    2851    return (FALSE);
    2952  }
    3053
    3154  if ((xin  = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
    32   if ((yin  = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE);
    3355  if ((xout = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) return (FALSE);
    3456  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  }
    3565
    3666  // re-binning creates a float vector
     
    4171
    4272  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    }
    4580
    4681    N = 0;
     
    4883      if (xin[0].elements.Flt[j] < xmin) continue;
    4984      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      }
    5188      N++;
    5289    }
    5390   
    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;
    59120    }
    60 
    61     // measure the stat for this bin
    62     // sum = 0.0;
    63     // for (j = 0; j < N; j++) {
    64     //   sum += values[j];
    65     // }
    66     // sum /= N;
    67121    yout[0].elements.Flt[i] = sum;
    68122  }
  • branches/eam_branches/ipp-20120405/Ohana/src/opihi/dvo/skycoverage.c

    r33662 r33737  
    22
    33// enum to define possible modes
    4 enum {COVERAGE, DENSITY, MIN_UBERCAL, MIN_DMAG_SYS, MIN_MCAL, MAX_MCAL};
     4enum {COVERAGE, DENSITY, MIN_UBERCAL, MIN_DMAG_SYS, MIN_MCAL, MAX_MCAL, MIN_TIME, MAX_TIME};
    55
    66int wordhash (char *word);
     
    2323  PhotCode *PhotcodeValue;
    2424
     25  time_t TimeReference;
     26  int TimeFormat;
     27
     28  GetTimeFormat (&TimeReference, &TimeFormat);
     29
    2530  WITH_MOSAIC = FALSE;
    2631  if ((N = get_argument (argc, argv, "+mosaic"))) {
     
    7176    remove_argument (N, &argc, argv);
    7277    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;
    7386  }
    7487  if ((N = get_argument (argc, argv, "-min-dmag-sys"))) {
     
    231244          case MIN_DMAG_SYS:
    232245          case MIN_MCAL:
    233             V[ys*Nx + xs] = 1E6;
     246          case MIN_TIME:
     247            V[ys*Nx + xs] = 1E9;
    234248            break;
    235249          case MAX_MCAL:
    236             V[ys*Nx + xs] = -1E6;
     250          case MAX_TIME:
     251            V[ys*Nx + xs] = -1E9;
    237252            break;
    238253        }
     
    247262          case MIN_MCAL:
    248263          case MAX_MCAL:
     264          case MIN_TIME:
     265          case MAX_TIME:
    249266            V[ys*Nx + xs] = NAN;
    250267            break;
     
    323340              V[ys*Nx + xs] = MAX(V[ys*Nx + xs], image[i].Mcal);
    324341              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; }
    325350          }
    326351        }
Note: See TracChangeset for help on using the changeset viewer.