IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42082


Ignore:
Timestamp:
Feb 28, 2022, 12:17:32 PM (4 years ago)
Author:
eugene
Message:

add imresample, imcollapse functions; more usage documentation; option to catch failures in command when loading from shell command into queue; better handling of errors reading FITS table

Location:
trunk/Ohana/src/opihi/cmd.data
Files:
9 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r41891 r42082  
    7878$(SRC)/imsmooth.2d.$(ARCH).o    \
    7979$(SRC)/imconvolve.$(ARCH).o     \
     80$(SRC)/imresample.$(ARCH).o     \
     81$(SRC)/imcollapse.$(ARCH).o     \
    8082$(SRC)/integrate.$(ARCH).o      \
    8183$(SRC)/interpolate.$(ARCH).o    \
  • trunk/Ohana/src/opihi/cmd.data/cut.c

    r41341 r42082  
    9696  if (argc != 9) {
    9797    gprint (GP_ERR, "USAGE: cut <buffer> <X vector> <Y vector> <X|Y> sx sy nx ny\n");
     98    gprint (GP_ERR, "  extract a vector in the X or Y direction based on the pixel values in window\n");
    9899    return (FALSE);
    99100  }
  • trunk/Ohana/src/opihi/cmd.data/imcut.c

    r33662 r42082  
    99  float *V;
    1010
    11   if (argc != 8) {
    12     gprint (GP_ERR, "USAGE: cut <buffer> <X vector> <Y vector> xs ys xe ye\n");
    13     return (FALSE);
    14   }
     11  if (argc != 8) goto usage;
    1512
    1613  if ((buf  = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) goto missed;
     
    5148
    5249 usage:
    53   gprint (GP_ERR, "USAGE: circstats <buffer> x y radius\n");
     50  gprint (GP_ERR, "USAGE: imcut <buffer> <X vector> <Y vector> xs ys xe ye\n");
     51  gprint (GP_ERR, " extract pixels along the line from (xs,ys) to (xe,ye)\n");
     52  gprint (GP_ERR, " (see also imvector)\n");
    5453  return (FALSE);
    5554
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r41891 r42082  
    1818int clear            PROTO((int, char **));
    1919int clip             PROTO((int, char **));
    20 int imclip           PROTO((int, char **));
    2120int close_device     PROTO((int, char **));
    2221int concat           PROTO((int, char **));
     
    6160int hermitian2d      PROTO((int, char **));
    6261int idxread          PROTO((int, char **));
     62int imclip           PROTO((int, char **));
    6363int imcut            PROTO((int, char **));
    6464int imhist           PROTO((int, char **));
     
    6868int imsmooth_2d      PROTO((int, char **));
    6969int imconvolve       PROTO((int, char **));
     70int imresample       PROTO((int, char **));
     71int imcollapse       PROTO((int, char **));
    7072int integrate        PROTO((int, char **));
    7173int interpolate      PROTO((int, char **));
     
    266268  {1, "imclip",       imclip,           "clip values in an image to be within a range"},
    267269  {1, "imcut",        imcut,            "linear image cut between arbitrary coords"},
     270  {1, "imresample",   imresample,       "extract arbitrary window from image"},
     271  {1, "imcollapse",   imcollapse,       "collapse to histogram along axis"},
    268272  {1, "imhistogram",  imhist,           "histogram of an image region"},
    269273  {1, "impeaks",      impeaks,          "find peaks in an image (return vectors)"},
  • trunk/Ohana/src/opihi/cmd.data/match2d.c

    r40650 r42082  
    140140  gprint (GP_ERR, "if -index1 or -index2 is not supplied, the vectors are created with names index1 or index2\n");
    141141  gprint (GP_ERR, "use 'reindex' to generate new vectors based on these index vectors\n");
     142
     143  gprint (GP_ERR, "examples:\n");
     144  gprint (GP_ERR, " for 'match2d x1 y1 x2 y2 radius -closest'\n");
     145  gprint (GP_ERR, " use 'reindex x2m = x2 using index1 -keep-unmatched'\n");
     146  gprint (GP_ERR, "   x2m will have values which correspond to x1 (or NAN if not matched)\n"); 
     147  gprint (GP_ERR, " \n"); 
     148  gprint (GP_ERR, " for 'match2d x1 y1 x2 y2 radius'\n");
     149  gprint (GP_ERR, " use 'reindex x1m = x1 using index1'\n");
     150  gprint (GP_ERR, " use 'reindex x2m = x2 using index2'\n");
     151  gprint (GP_ERR, "   x1m will have values which correspond to x2m\n"); 
     152  gprint (GP_ERR, " \n"); 
    142153
    143154  gprint (GP_ERR, "if -sphere or -sky is supplied, (x1,y1) and (x2,y2) are treaded as (ra,dec) or (long,lat) pairs in degrees\n");
  • trunk/Ohana/src/opihi/cmd.data/medacc.c

    r20936 r42082  
    1010  if ((argc != 6) && (argc != 7)) {
    1111    gprint (GP_ERR, "USAGE: medacc <value> <vector> <key> start end [delta]\n");
     12    gprint (GP_ERR, "  value and key are vectors of the same length\n");
     13    gprint (GP_ERR, "  the output vector bins correspond to values ranging from start to end in steps of delta (default 1)\n");
     14    gprint (GP_ERR, "  for a given output bin, all input values for which the key matches the output bin are averaged\n");
     15
    1216    return (FALSE);
    1317  }
  • trunk/Ohana/src/opihi/cmd.data/queueload.c

    r12332 r42082  
    33int queueload (int argc, char **argv) {
    44 
    5   char *A, *B, *val;
    6   int i, status;
    7   int Nread, Nbytes, NBYTES;
    8   FILE *f;
    9   Queue *queue;
     5  int N;
     6
     7  // variable name to save the value
     8  int TrapFailure = FALSE;
     9  if ((N = get_argument (argc, argv, "-trap-failure"))) {
     10    remove_argument (N, &argc, argv);
     11    TrapFailure = TRUE;
     12  }
     13  if ((N = get_argument (argc, argv, "-trap"))) {
     14    remove_argument (N, &argc, argv);
     15    TrapFailure = TRUE;
     16  }
    1017
    1118  if (argc != 4) goto usage;
     
    1320 
    1421  /* will create a queue if none exists */
    15   queue = CreateQueue (argv[1]);
     22  Queue *queue = CreateQueue (argv[1]);
    1623
    1724  /* val will hold the result of the command */
    18   NBYTES = 1024;
    19   ALLOCATE (val, char, NBYTES);
     25  int NBYTES = 1024;
     26  ALLOCATE_PTR (val, char, NBYTES);
    2027   
    2128  /* loop until command produces no more output,  REALLOCATE as needed. */
    22   f = popen (argv[3], "r");
    23   Nbytes = 0;
    24   Nread = 1;
     29  FILE *f = popen (argv[3], "r");
     30
     31  int Nbytes = 0;
     32  int Nread = 1;
    2533  while (Nread > 0) {
    2634    Nread = fread (&val[Nbytes], 1, 1023, f);
     
    3543  }
    3644  val[Nbytes] = 0;
    37   status = pclose (f);
     45  int status = pclose (f);
    3846   
     47  // XXX
    3948  if (status) {
    4049    gprint (GP_ERR, "warning: exit status of command %d\n", status);
     50    if (TrapFailure) { free (val); return FALSE; }
    4151  }
    4252     
    43   A = B = val;
    44   for (i = 0; B != (char *) NULL;) {
     53  char *A = val, *B = val;
     54  for (int i = 0; B != (char *) NULL;) {
    4555    while (isspace (*A) && (*A != 0)) A++;
    4656    B = strchr (A, '\n');
  • trunk/Ohana/src/opihi/cmd.data/read_vectors.c

    r41673 r42082  
    629629  }
    630630  if (listFields) {
    631     read_table_fields (&header, IsCompressed, VERBOSE);
     631    int tstatus = read_table_fields (&header, IsCompressed, VERBOSE);
    632632    if (CCDKeyword != NULL) free (CCDKeyword);
    633633    gfits_free_header (&header);
    634     return TRUE;
     634    if (!tstatus) { gprint (GP_ERR, "error reading table fields\n"); }
     635    return tstatus;
    635636  }
    636637  if (IsCompressed) {
     
    855856  char field[32], varname[32], type[80], comment[80], format[80], unit[80], null[80], nval[80];
    856857
    857   gfits_scan (header, "TFIELDS", "%d", 1, &Nfields);
    858 
     858  if (!gfits_scan (header, "TFIELDS", "%d", 1, &Nfields)) {
     859    if (VERBOSE) gprint (GP_ERR, "cannot read TFIELDS from header\n");
     860    set_int_variable ("table:Nx", header->Naxis[0]);
     861    set_int_variable ("table:Ny", header->Naxis[1]);
     862    set_int_variable ("table:Nfields", 0);
     863    set_int_variable ("tfields:n", 0);
     864    return TRUE;
     865  }
     866   
    859867  set_int_variable ("table:Nx", header->Naxis[0]);
    860868  set_int_variable ("table:Ny", header->Naxis[1]);
     
    872880
    873881    snprintf (field, 32, "TTYPE%d", i);
    874     gfits_scan (header, field, "%s", 1, type);
     882    if (!gfits_scan (header, field, "%s", 1, type)) {
     883      if (VERBOSE) gprint (GP_ERR, "cannot read %s from header\n", field);
     884    }
    875885   
    876886    snprintf (varname, 32, "tfields:%d", i - 1);
    877887    set_str_variable (varname, type);
    878888
    879     gfits_scan_alt (header, field, "%C", 1, comment);
     889    gfits_scan_alt (header, field, "%C", 1, comment); 
    880890
    881891    if (!isCompressed) {
     
    884894      snprintf (field, 32, "ZFORM%d", i);
    885895    }
    886     gfits_scan (header, field, "%s", 1, format);
     896    if (!gfits_scan (header, field, "%s", 1, format)) {
     897      if (VERBOSE) gprint (GP_ERR, "cannot read %s from header\n", field);
     898    }
    887899
    888900    snprintf (field, 32, "TUNIT%d", i);
     
    895907    if (VERBOSE) gprint (GP_LOG, "%-18s %-15s %-18s %-6s %-8s %-8s %-32s\n", type, varname, unit, format, null, nval, comment);
    896908  }
    897 
    898 
    899909  return TRUE;
    900910}
  • trunk/Ohana/src/opihi/cmd.data/reindex.c

    r40291 r42082  
    6262      if (*vx < 0) {
    6363        if (KEEP_UNMATCH) {
    64           ovec[0].elements.Flt[Npts] = -1;
     64          ovec[0].elements.Int[Npts] = -4096; // XXX use a different or a specified value?
    6565          Npts++;
    6666        }
Note: See TracChangeset for help on using the changeset viewer.