IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 31, 2013, 5:31:39 AM (13 years ago)
Author:
eugene
Message:

merge changes from EAM branch (medianfilter list error; handle empty kapa message; add join and vlist cmds, match2d help, excel-style lists: foo:A equiv to foo:0, time-based dvo temp-file purging, fix avmatch parallel coordlist bug, sub-pixel resolve sersic model, dgaussjordan needs larger dynamic range, avextract psfqf, psfqfperf, stargal)

Location:
trunk/Ohana
Files:
13 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/opihi

  • trunk/Ohana/src/opihi/cmd.astro

  • trunk/Ohana/src/opihi/cmd.astro/Makefile

    r35416 r36084  
    6060$(SRC)/scale.$(ARCH).o             \
    6161$(SRC)/sexigesimal.$(ARCH).o       \
     62$(SRC)/sersic.$(ARCH).o    \
    6263$(SRC)/spec.$(ARCH).o              \
    6364$(SRC)/specpairfit.$(ARCH).o       \
  • trunk/Ohana/src/opihi/cmd.astro/init.c

    r35757 r36084  
    4949int scale                   PROTO((int, char **));
    5050int sexigesimal             PROTO((int, char **));
     51int sersic                  PROTO((int, char **));
    5152int spec                    PROTO((int, char **));
    5253int specpairfit             PROTO((int, char **));
     
    107108  {1, "scale",       scale,        "get / set real bzero / bscale values"},
    108109  {1, "sexigesimal", sexigesimal,  "convert to/from sexigesimal/decimal"},
     110  {1, "sersic",      sersic,       "generate sub-pixel resolved sersic model"},
    109111  {1, "spec",        spec,         "extract a spectrum"},
    110112  {1, "specpairfit", specpairfit,  "fit spectrum to another spectrum"},
  • trunk/Ohana/src/opihi/cmd.basic/list.c

    r33662 r36084  
    22# define D_NLINES 100
    33static char prompt[] = ">> ";
     4
     5static int set_list_varname (char *line, char *base, int N, int excelStyle);
    46
    57int list (int argc, char **argv) {
     
    2123  }
    2224
     25  int EXCEL_STYLE = FALSE;
     26  if ((N = get_argument (argc, argv, "-excel-style"))) {
     27    remove_argument (N, &argc, argv);
     28    EXCEL_STYLE = TRUE;
     29  }
     30  if ((N = get_argument (argc, argv, "-excel"))) {
     31    remove_argument (N, &argc, argv);
     32    EXCEL_STYLE = TRUE;
     33  }
     34
    2335  if ((N = get_argument (argc, argv, "-vectors"))) {
    2436    remove_argument (N, &argc, argv);
     
    4961   
    5062    for (i = 0; i < argc - 3; i++) {
    51       sprintf (line, "%s:%d", argv[1], i);
     63      set_list_varname (line, argv[1], i, EXCEL_STYLE);
    5264      set_str_variable (line, argv[i+3]);
    5365    }
     
    8395        if (!word) break;
    8496       
    85         sprintf (line, "%s:%d", argv[1], nWords);
     97        // sprintf (line, "%s:%d", argv[1], nWords);
     98        set_list_varname (line, argv[1], nWords, EXCEL_STYLE);
     99
    86100        set_str_variable (line, word);
    87101        FREE (word);
     
    120134      sprintf (line, "%s:%d", argv[3], i);
    121135      value = get_variable (line);
    122       sprintf (line, "%s:%d", argv[1], i);
     136      // sprintf (line, "%s:%d", argv[1], i);
     137      set_list_varname (line, argv[1], i, EXCEL_STYLE);
    123138      set_str_variable (line, value);
    124139    }
     
    136151    N = get_int_variable (line, &found);
    137152    for (i = 0; i < argc - 3; i++) {
    138       sprintf (line, "%s:%d", argv[1], N + i);
     153      // sprintf (line, "%s:%d", argv[1], N + i);
     154      set_list_varname (line, argv[1], N + i, EXCEL_STYLE);
    139155      set_str_variable (line, argv[i+3]);
    140156    }
     
    159175    N = get_int_variable (line, &found);
    160176    for (i = 0; i < N; i++) {
    161       sprintf (line, "%s:%d", argv[1], i);
     177      // sprintf (line, "%s:%d", argv[1], i);
     178      set_list_varname (line, argv[1], i, EXCEL_STYLE);
    162179      value = get_variable (line);
    163180      if (value == NULL) continue;
     
    165182        free (value);
    166183        for (j = i + 1; j < N; j++) {
    167           sprintf (line2, "%s:%d", argv[1], j);
     184          // sprintf (line2, "%s:%d", argv[1], j);
     185          set_list_varname (line2, argv[1], j, EXCEL_STYLE);
    168186          next_value = get_variable (line2);
    169187          set_str_variable (line, next_value);
     
    235253      if (B != (char *) NULL) { *B = 0; }
    236254      if (*A != 0) {
    237         sprintf (line, "%s:%d", argv[1], i);
     255        // sprintf (line, "%s:%d", argv[1], i);
     256        set_list_varname (line, argv[1], i, EXCEL_STYLE);
    238257        set_str_variable (line, A);
    239258        A = B + 1;
     
    283302
    284303    if (*input) {
    285       sprintf (line, "%s:%d", argv[1], i);
     304      // sprintf (line, "%s:%d", argv[1], i);
     305      set_list_varname (line, argv[1], i, EXCEL_STYLE);
    286306      set_str_variable (line, input);
    287307      free (input);
    288308      i++;
    289    }
     309    }
    290310  }
    291311  return (TRUE);
    292312}
     313
     314static int set_list_varname (char *line, char *base, int N, int excelStyle) {
     315
     316  int i;
     317   
     318  // A-Z correspond to 0 - 25
     319
     320  if (excelStyle) {
     321    float f = log(26.0);
     322    float g = (N == 0) ? 0.0 : log(1.0*N);
     323    int Ndigit = (int) (g / f) + 1;
     324    if (Ndigit > 10) {
     325      sprintf (line, "%s:ZZZZZZZZZZ", base);
     326      return FALSE;
     327    }
     328    char name[12];
     329    memset (name, 0, 12);
     330    for (i = 0; i < Ndigit; i++) {
     331      float Npow = Ndigit - i - 1;
     332      float g = pow(26.0, Npow);
     333      int V = (int) (N / g);
     334      name[i] = (Npow == 0.0) ? 'A' + V : 'A' + V - 1;
     335      N -= V * g;
     336    }
     337    sprintf (line, "%s:%s", base, name);
     338  } else {
     339    sprintf (line, "%s:%d", base, N);
     340  }
     341  return TRUE;
     342}
  • trunk/Ohana/src/opihi/cmd.data

  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r35416 r36084  
    6666$(SRC)/integrate.$(ARCH).o      \
    6767$(SRC)/interpolate.$(ARCH).o    \
     68$(SRC)/join.$(ARCH).o           \
    6869$(SRC)/jpeg.$(ARCH).o           \
    6970$(SRC)/kern.$(ARCH).o           \
     
    143144$(SRC)/vmaxwell.$(ARCH).o          \
    144145$(SRC)/vgrid.$(ARCH).o             \
     146$(SRC)/vlist.$(ARCH).o             \
    145147$(SRC)/vload.$(ARCH).o             \
    146148$(SRC)/vzload.$(ARCH).o            \
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r35416 r36084  
    5555int integrate        PROTO((int, char **));
    5656int interpolate      PROTO((int, char **));
     57int join             PROTO((int, char **));
    5758int jpeg             PROTO((int, char **));
    5859int kern             PROTO((int, char **));
     
    133134int vmaxwell         PROTO((int, char **));
    134135int vload            PROTO((int, char **));
     136int vlist            PROTO((int, char **));
    135137int vzload           PROTO((int, char **));
    136138int vstats           PROTO((int, char **));
     
    209211  {1, "integrate",    integrate,        "integrate a vector"},
    210212  {1, "interpolate",  interpolate,      "interpolate between vector pairs"},
     213  {1, "join",         join,             "find the join of two ID vectors"},
    211214  {1, "jpeg",         jpeg,             "convert display image to JPEG"},
    212215  {1, "kern",         kern,             "convolve with 3x3 kernel"},
     
    290293  {1, "vgrid",        vgrid,            "generate an image from a triplet of vectors"},
    291294  {1, "vhistogram",   histogram,        "generate histogram from vector"},
     295  {1, "vlist",        vlist,            "append values to a vector from command line"},
    292296  {1, "vload",        vload,            "load vectors as overlay on image display"},
    293297  {1, "vmaxwell",     vmaxwell,         "fit a Maxwellian to a vector"},
  • trunk/Ohana/src/opihi/cmd.data/match2d.c

    r33963 r36084  
    1414  Vector *index1, *index2;
    1515
     16  if ((N = get_argument (argc, argv, "-h"))) goto usage;
     17  if ((N = get_argument (argc, argv, "--help"))) goto usage;
     18
    1619  CLOSEST = FALSE;
    1720  if ((N = get_argument (argc, argv, "-closest"))) {
     
    3841  if (argc != 6) {
    3942    gprint (GP_ERR, "USAGE: match2d X1 Y1 X2 Y2 Radius [-index1 (index1)] [-index2 (index2)] [-closest]\n");
    40     gprint (GP_ERR, "  if -closest is provided, index1 & index2 will have the same length as X1 and X2 (respectively)\n");
    41     gprint (GP_ERR, "    with either the index of the match or a value of -1 for non-matches\n");
     43    gprint (GP_ERR, "  use -h or --help for more detail\n");
    4244    return (FALSE);
    4345  }
     
    9092
    9193  return (TRUE);
     94
     95usage:
     96  gprint (GP_ERR, "we have two modes of operation:\n\n");
     97
     98  gprint (GP_ERR, "without -closest, we are finding all matched pairs within the match radius.  in this\n");
     99  gprint (GP_ERR, "case, the two index vectors have the same length, one entry per matched pair.\n");
     100  gprint (GP_ERR, "x1[index1],y1[index1] matches to x2[index2],y2[index2].\n\n");
     101
     102  gprint (GP_ERR, "with -closest selected, we are finding the closest element of set 1 to each of set 2\n");
     103  gprint (GP_ERR, "and vice versa.  in this case, index1 is always the same length as x1,y1, while index2\n");
     104  gprint (GP_ERR, "is the same lengths as x2,y2.  x2[index1],y2[index1] matches x1,y1 while\n");
     105  gprint (GP_ERR, "x1[index2],y1[index2] matches x2,y2\n\n");
     106
     107  gprint (GP_ERR, "if -index1 or -index2 is not supplied, the vectors are created with names index1 or index2\n");
     108  gprint (GP_ERR, "use 'reindex' to generate new vectors based on these index vectors\n");
     109
     110  return FALSE;
    92111}
    93112
  • trunk/Ohana/src/opihi/dvo/avmatch.c

    r35416 r36084  
    7070  dbExtractAveragesInit ();
    7171
    72   // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
    7372  RAvec  = NULL;
    7473  DECvec = NULL;
    75   if (PARALLEL && !HOST_ID) {
    76     if (!CoordsFile) {
    77       // get vectors corresponding to coordinates of interest
    78       if ((RAvec  = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto help;
    79       if ((DECvec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) goto help;
    80      
    81       ALLOCATE (vec, Vector *, 2);
    82       vec[0] = RAvec;
    83       vec[1] = DECvec;
    84 
    85       CoordsFile = abspath("coords.fits", 1024);
    86       int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL);
    87       if (!status) goto escape;
    88     }
    89 
    90     char *targv1 = argv[1];
    91     char *targv2 = argv[2];
    92     argv[1] = strcreate ("-coords");
    93     argv[2] = strcreate (CoordsFile);
    94     free (CoordsFile);
    95 
    96     // I need to pass the RA & DEC vectors to the remote clients...
    97     int status = HostTableParallelOps (skylist, argc, argv, RESULT_FILE, TRUE, RAvec->Nelements, VERBOSE);
    98     if (vec) free (vec);
    99    
    100     free (argv[1]);
    101     free (argv[2]);
    102     argv[1] = targv1;
    103     argv[2] = targv2;
    104 
    105     return status;
    106   }
    107 
    10874  // get vectors corresponding to coordinates of interest
    10975  if (CoordsFile) {
     
    12086    remove_argument (1, &argc, argv);
    12187  }
     88
     89  /* load regions which contain all supplied RA,DEC coordinates */
     90  if ((skylist = SelectRegionsByCoordVectors (RAvec, DECvec)) == NULL) goto escape;
     91
     92  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
     93  if (PARALLEL && !HOST_ID) {
     94
     95    // We need to copy the args to a temp array and modify them so that we send the
     96    // correct set to the remote client.  The args list looks like this:
     97    // if (!CoordsFile) : avmatch (RADIUS) field, ... [we removed RA & DEC above]
     98    // if ( CoordsFile) : avmatch (RADIUS) field, ... [because we stripped off the -coords filename elements]
     99
     100    // allocate the temp array and copy all but (RA) (DEC)
     101    int targc = 0;
     102    char **targv = NULL;
     103    ALLOCATE (targv, char *, argc + 2);
     104    for (i = 0; i < argc; i++) {
     105      targv[targc] = strcreate (argv[i]);
     106      targc ++;
     107    }
     108
     109    // if not specified, create the coords.fits input file
     110    // NOTE: RAvec, DECvec were set above
     111    if (!CoordsFile) {
     112      ALLOCATE (vec, Vector *, 2);
     113      vec[0] = RAvec;
     114      vec[1] = DECvec;
     115
     116      CoordsFile = abspath("coords.fits", 1024);
     117      int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL);
     118      if (!status) goto escape;
     119    }
     120
     121    // add the coords file to the args list
     122    targv[targc+0] = strcreate ("-coords");
     123    targv[targc+1] = CoordsFile; // this gets freed with targv
     124    targc += 2;
     125   
     126    // I need to pass the RA & DEC vectors to the remote clients...
     127    int status = HostTableParallelOps (skylist, targc, targv, RESULT_FILE, TRUE, RAvec->Nelements, VERBOSE);
     128    if (vec) free (vec);
     129   
     130    // free up targv
     131    for (i = 0; i < targc; i++) {
     132      free (targv[i]);
     133    }
     134    free (targv);
     135
     136    return status;
     137  }
     138
    122139  RADIUS = atof (argv[1]);
    123140  remove_argument (1, &argc, argv);
     
    140157    if (fields[i].photcode[0].type == PHOT_DEP) needMeasures = TRUE;
    141158  }
    142 
    143   /* load regions which contain all supplied RA,DEC coordinates */
    144   if ((skylist = SelectRegionsByCoordVectors (RAvec, DECvec)) == NULL) goto escape;
    145159
    146160  /* create output storage vectors */
  • trunk/Ohana/src/opihi/dvo/hosts.c

    r35757 r36084  
    1212    gprint (GP_ERR, "  commands:\n");
    1313    gprint (GP_ERR, "    purge-temp : delete all tempfiles for this shell\n");
    14     gprint (GP_ERR, "               : [-old-pid] [-all-pid] [-v] [-verbose] [-commit] [-type type]\n");
     14    gprint (GP_ERR, "               : [-old-pid] [-all-pid] [-v] [-verbose] [-commit] [-type type] [-age hours]\n");
    1515    gprint (GP_ERR, "    get-results : determine name of RESULTS file\n");
    1616    return FALSE;
     
    3333    }
    3434   
     35    struct timeval now;
     36    gettimeofday (&now, NULL);
     37
     38    float AGE = 0;
     39    int NOW = now.tv_sec;
     40    if ((N = get_argument (argc, argv, "-age"))) {
     41      remove_argument (N, &argc, argv);
     42      AGE = atof(argv[N]);
     43      remove_argument (N, &argc, argv);
     44    }
     45
    3546    int VERBOSE = FALSE;
    3647    if ((N = get_argument (argc, argv, "-v"))) {
     
    121132      glob (name, 0, NULL, &pglob);
    122133      int j;
     134      struct stat filestats;
    123135      for (j = 0; j < pglob.gl_pathc; j++) {
     136        if (AGE > 0) {
     137          if (stat(pglob.gl_pathv[j], &filestats)) {
     138            gprint (GP_ERR, "failed to get stats for %s\n", pglob.gl_pathv[j]);
     139            continue;
     140          }
     141          float myAge = (NOW - filestats.st_mtime) / 3600.0;
     142          if (myAge < AGE) continue;
     143        }
    124144        if (VERBOSE) gprint (GP_ERR, "unlink %s\n", pglob.gl_pathv[j]);
    125145        if (!DRYRUN) unlink (pglob.gl_pathv[j]);
  • trunk/Ohana/src/opihi/lib.shell/ListOps.c

    r33963 r36084  
    189189int is_list_data (char *line) {
    190190
    191   char *comm, *temp;
    192 
    193   temp = thisword (nextword (nextword (line)));
    194   comm = thisword (line);
    195 
     191  char *comm = NULL;
     192  char *temp = NULL;
     193  char *ptr  = NULL;
     194
     195  comm = thisword (line);
    196196  if (comm == NULL) goto escape;
    197 
    198197  if (strcmp (comm, "list")) goto escape;
     198
     199  ptr = nextword (line);
     200  if (!strncmp("-excel", ptr, strlen("-excel"))) ptr = nextword (ptr);
     201  if (!strncmp("-excel-style", ptr, strlen("-excel-style"))) ptr = nextword (ptr);
     202  ptr = nextword (ptr);
     203  if (!strncmp("-excel", ptr, strlen("-excel"))) ptr = nextword (ptr);
     204  if (!strncmp("-excel-style", ptr, strlen("-excel-style"))) ptr = nextword (ptr);
     205  temp = thisword (ptr);
    199206
    200207  /* if (cond) (command) does not define a complete block */
Note: See TracChangeset for help on using the changeset viewer.