IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 22, 2020, 11:00:22 AM (6 years ago)
Author:
eugene
Message:

add -copy option to coords; add mjdtolst; add option to control major tick spacing; add -copy option to header; add usage info to avperiodomatch

File:
1 edited

Legend:

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

    r34088 r41379  
    11# include "data.h"
     2
     3# define SKIP_HEADER(NAME) { if (!strncmp(line, NAME, strlen(NAME))) continue; }
    24
    35int header (int argc, char **argv) {
     
    1618    LOADHEAD = TRUE;
    1719  }
     20  if ((N = get_argument (argc, argv, "-file"))) {
     21    remove_argument (N, &argc, argv);
     22    strcpy (filename, argv[N]);
     23    remove_argument (N, &argc, argv);
     24    LOADHEAD = TRUE;
     25  }
     26
     27  char *COPYHEAD = NULL;
     28  if ((N = get_argument (argc, argv, "-copy"))) {
     29    if (LOADHEAD) {
     30      gprint (GP_ERR, "-copy and -w are incompatible\n");
     31      return (FALSE);
     32    }
     33    remove_argument (N, &argc, argv);
     34    COPYHEAD = strcreate (argv[N]);
     35    remove_argument (N, &argc, argv);
     36  }
    1837
    1938  if (argc != 2) {
    20     gprint (GP_ERR, "USAGE: header <buffer> [-w filename]\n");
     39    gprint (GP_ERR, "USAGE: header <buffer> [-w filename] [-file filename] [-copy buffer]\n");
     40    gprint (GP_ERR, "  -file / -w : replace buffer header with contents from file (PHU only)\n");
     41    gprint (GP_ERR, "  -copy : replace buffer header with contents of buffer\n");
    2142    return (FALSE);
    2243  }
    2344
    2445  if ((buf = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) return (FALSE);
     46
     47  if (COPYHEAD) {
     48    Buffer *src = NULL;
     49    if ((src = SelectBuffer (COPYHEAD, OLDBUFFER, TRUE)) == NULL) return (FALSE);
     50
     51    // loop over all lines in the header and copy one-by-one
     52    // skip the special words:
     53   
     54    for (int i = 0; TRUE; i++) {
     55      char *line = gfits_header_lineno (&src[0].header, i);
     56      if (!line) break;
     57
     58      // skip special keywords
     59      SKIP_HEADER ("SIMPLE");
     60      SKIP_HEADER ("SIMPLE");
     61      SKIP_HEADER ("BITPIX");
     62      SKIP_HEADER ("NAXIS");
     63      SKIP_HEADER ("EXTEND");
     64      SKIP_HEADER ("UNSIGN");
     65      SKIP_HEADER ("BSCALE");
     66      SKIP_HEADER ("BZERO");
     67      SKIP_HEADER ("NAXIS1");
     68      SKIP_HEADER ("NAXIS2");
     69      SKIP_HEADER ("NAXIS3");
     70      SKIP_HEADER ("NAXIS4");
     71      SKIP_HEADER ("NAXIS5");
     72      SKIP_HEADER ("NAXIS6");
     73      SKIP_HEADER ("NAXIS7");
     74      SKIP_HEADER ("NAXIS8");
     75      SKIP_HEADER ("NAXIS9");
     76      SKIP_HEADER ("NAXIS10");
     77      SKIP_HEADER ("PCOUNT");
     78      SKIP_HEADER ("GCOUNT");
     79
     80      gfits_header_append_line_raw (&buf[0].header, line);
     81    }
     82    return TRUE;
     83
     84  }
    2585
    2686  if (LOADHEAD) {
Note: See TracChangeset for help on using the changeset viewer.