IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39602 for trunk


Ignore:
Timestamp:
Jun 17, 2016, 5:00:44 PM (10 years ago)
Author:
eugene
Message:

mods for gcat, catname; add catid to get cpt info more easily

Location:
trunk/Ohana/src/opihi/dvo
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/dvo/Makefile

    r39569 r39602  
    4848$(SRC)/catdir.$(ARCH).o                 \
    4949$(SRC)/catname.$(ARCH).o                \
     50$(SRC)/catid.$(ARCH).o                  \
    5051$(SRC)/cmatch.$(ARCH).o         \
    5152$(SRC)/cmpload.$(ARCH).o                \
  • trunk/Ohana/src/opihi/dvo/catname.c

    r39457 r39602  
    11# include "dvoshell.h"
     2int gcat_listnames (SkyList *skylist, HostTable *table, int ShowFile, int ShowHost, int ShowBackup, int ShowFlags, int ShowCoords, int ShowID);
    23
    34int catname (int argc, char **argv) {
    45 
    5   int i, N;
    6   struct stat filestat;
     6  int N;
    77
     8  int ShowCoords = FALSE;
     9  if ((N = get_argument (argc, argv, "-coords"))) {
     10    remove_argument (N, &argc, argv);
     11    ShowCoords = TRUE;
     12  }
     13  int ShowID = FALSE;
     14  if ((N = get_argument (argc, argv, "-catid"))) {
     15    remove_argument (N, &argc, argv);
     16    ShowID = TRUE;
     17  }
     18  int ShowFile = FALSE;
     19  if ((N = get_argument (argc, argv, "-file"))) {
     20    remove_argument (N, &argc, argv);
     21    ShowFile = TRUE;
     22  }
    823  int ShowHost = FALSE;
    924  if ((N = get_argument (argc, argv, "-host"))) {
     
    1631    ShowBackup = TRUE;
    1732  }
    18   int FullName = FALSE;
    19   if ((N = get_argument (argc, argv, "-full-name"))) {
    20     remove_argument (N, &argc, argv);
    21     FullName = TRUE;
    22   }
    2333  int ShowFlags = FALSE;
    2434  if ((N = get_argument (argc, argv, "-flags"))) {
     
    2636    ShowFlags = TRUE;
    2737  }
    28   int PARALLEL = FALSE;
    29   if ((N = get_argument (argc, argv, "-parallel"))) {
    30     remove_argument (N, &argc, argv);
    31     PARALLEL = TRUE;
    32   }
    3338
    3439  if (argc != 2) {
    35     gprint (GP_ERR, "USAGE: catname name [-host] [-backup] [-flags]\n");
     40    gprint (GP_ERR, "USAGE: catname name [-host] [-backup] [-flags] [-file] [-coords] [-catid]\n");
    3641    return (FALSE);
    3742  }
    3843
     44  /* load sky from correct table */
    3945  char *CATDIR = GetCATDIR();
    4046  if (!CATDIR) {
     
    4753    return FALSE;
    4854  }
    49   HostTable *table = HostTableLoad (CATDIR, sky->hosts);
    50   if (!table) {
    51     gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR);
    52     return FALSE;
    53   }   
     55  HostTable *table = NULL; 
     56  if (HostTableExists (CATDIR, sky->hosts)) {
     57    table = HostTableLoad (CATDIR, sky->hosts);
     58    if (!table) {
     59      gprint (GP_ERR, "ERROR: failure reading Host Table %s for parallel database %s\n", sky->hosts, CATDIR);
     60      return FALSE;
     61    }   
     62  }
     63
    5464  SkyList *skylist = SkyListByName (sky, argv[1]);
    5565
    56   // prepare to handle interrupt signals
    57   struct sigaction *old_sigaction = SetInterrupt();
    58 
    59   for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) {
    60     char *filename = NULL;
    61     if (PARALLEL) {
    62       SkyRegion *region = skylist[0].regions[i];
    63       int hostID = (region->hostFlags & DATA_USE_BCK) ? region->backupID : region->hostID;
    64       int index = table->index[hostID];
    65    
    66       char hostfile[1024];
    67       snprintf (hostfile, 1024, "%s/%s.cpt", table->hosts[index].pathname, region->name);
    68       filename = hostfile;
    69     } else {
    70       filename = skylist[0].filename[i];
    71     }
    72 
    73     gprint (GP_ERR, "%3d %s", i, skylist[0].regions[i][0].name);
    74     if (stat (filename, &filestat) != -1) {
    75       gprint (GP_ERR, " +");
    76     } else {
    77       gprint (GP_ERR, " -");
    78     }
    79     if (ShowHost) {
    80       gprint (GP_ERR, "  %3d", skylist[0].regions[i][0].hostID);
    81     } else {
    82       gprint (GP_ERR, "     ");
    83     }
    84     if (FullName) {
    85       gprint (GP_ERR, "  %s", filename);
    86     }
    87     if (ShowBackup) {
    88       gprint (GP_ERR, "  %3d", skylist[0].regions[i][0].backupID);
    89     } else {
    90       gprint (GP_ERR, "     ");
    91     }
    92     if (ShowFlags) {
    93       gprint (GP_ERR, "  0x%04x", skylist[0].regions[i][0].hostFlags);
    94     } else {
    95       gprint (GP_ERR, "        ");
    96     }
    97     gprint (GP_ERR, "\n");
    98     set_str_variable ("CATNAME", filename);
    99   }
    100   ClearInterrupt (old_sigaction);
     66  gcat_listnames (skylist, table, ShowFile, ShowHost, ShowBackup, ShowFlags, ShowCoords, ShowID);
     67  SkyListFree (skylist);
    10168
    10269  return (TRUE);
    103   SkyListFree (skylist);
    10470}
  • trunk/Ohana/src/opihi/dvo/gcat.c

    r39457 r39602  
    11# include "dvoshell.h"
     2int gcat_listnames (SkyList *skylist, HostTable *table, int ShowFile, int ShowHost, int ShowBackup, int ShowFlags, int ShowCoords, int ShowID);
    23
    34int gcat (int argc, char **argv) {
    45 
    5   int i, N;
    6   struct stat filestat;
    7   double Ra, Dec, Radius;
    8   SkyTable *sky;
    9   SkyList *skylist;
     6  int N;
    107
     8  int ShowCoords = FALSE;
     9  if ((N = get_argument (argc, argv, "-coords"))) {
     10    remove_argument (N, &argc, argv);
     11    ShowCoords = TRUE;
     12  }
     13  int ShowID = FALSE;
     14  if ((N = get_argument (argc, argv, "-catid"))) {
     15    remove_argument (N, &argc, argv);
     16    ShowID = TRUE;
     17  }
    1118  int ShowFile = FALSE;
    1219  if ((N = get_argument (argc, argv, "-file"))) {
     
    3138
    3239  if ((argc != 3) && (argc != 4)) {
    33     gprint (GP_ERR, "USAGE: gcat RA DEC [Radius] [-host] [-backup] [-flags]\n");
     40    gprint (GP_ERR, "USAGE: gcat RA DEC [Radius] [-host] [-backup] [-flags] [-file] [-coords] [-catid]\n");
    3441    return (FALSE);
    3542  }
    3643
    3744  /* load sky from correct table */
    38   Ra = atof (argv[1]);
    39   Dec = atof (argv[2]);
    40   if (argc == 4)
    41     Radius = atof(argv[3]);
    42   else
    43     Radius = 0.0001;
    44 
    45   sky = GetSkyTable ();
    46   skylist = SkyListByRadius (sky, -1, Ra, Dec, Radius);
    47 
     45  char *CATDIR = GetCATDIR();
     46  if (!CATDIR) {
     47    gprint (GP_ERR, "CATDIR is not set\n");
     48    return FALSE;
     49  }
     50  SkyTable *sky = GetSkyTable ();
     51  if (!sky) {
     52    gprint (GP_ERR, "failed to load sky table for database\n");
     53    return FALSE;
     54  }
    4855  HostTable *table = NULL; 
    49   char *CATDIR = GetCATDIR();
    5056  if (HostTableExists (CATDIR, sky->hosts)) {
    5157    table = HostTableLoad (CATDIR, sky->hosts);
     
    5561    }   
    5662  }
     63
     64  double Ra = atof (argv[1]);
     65  double Dec = atof (argv[2]);
     66  double Radius = (argc == 4) ? atof(argv[3]) : 0.0001;
     67
     68  SkyList *skylist = SkyListByRadius (sky, -1, Ra, Dec, Radius);
     69
     70  gcat_listnames (skylist, table, ShowFile, ShowHost, ShowBackup, ShowFlags, ShowCoords, ShowID);
     71  SkyListFree (skylist);
     72
     73  return (TRUE);
     74}
     75
     76int gcat_listnames (SkyList *skylist, HostTable *table, int ShowFile, int ShowHost, int ShowBackup, int ShowFlags, int ShowCoords, int ShowID) {
     77
     78  int i;
     79  struct stat filestat;
    5780
    5881  // prepare to handle interrupt signals
     
    77100    }
    78101
     102    if (ShowCoords) {
     103      gprint (GP_ERR, " %7.3f %7.3f : %7.3f %7.3f", region->Rmin, region->Rmax, region->Dmin, region->Dmax);
     104    } else {
     105      gprint (GP_ERR, " %33s", " ");
     106    }
     107
    79108    if (stat (hostfile, &filestat) != -1) {
    80       gprint (GP_ERR, " *");
     109      gprint (GP_ERR, " +");
    81110    } else {
    82       gprint (GP_ERR, "  ");
     111      gprint (GP_ERR, " -");
    83112    }
     113    if (ShowID) {
     114      gprint (GP_ERR, " %5d", region->index);
     115    } else {
     116      gprint (GP_ERR, "%6s", " ");
     117    }
    84118    if (ShowHost) {
    85119      gprint (GP_ERR, "  %3d", region->hostID);
     
    100134    set_str_variable ("CATNAME", hostfile);
    101135  }
     136
    102137  ClearInterrupt (old_sigaction);
    103 
    104138  return (TRUE);
    105   SkyListFree (skylist);
    106139}
  • trunk/Ohana/src/opihi/dvo/init.c

    r37807 r39602  
    88int catlog          PROTO((int, char **));
    99int catname         PROTO((int, char **));
     10int catid           PROTO((int, char **));
    1011int catdir_define   PROTO((int, char **));
    1112int ccd             PROTO((int, char **));
     
    7071//  {1, "calmextract", calmextract,  "extract photometry calibration"},
    7172  {1, "catname",     catname,      "list catalog files by name"},
     73  {1, "catid",       catid,        "list catalog files by catID"},
    7274  {1, "catdir",      catdir_define,"re-define CATDIR"},
    7375//  {1, "ccd",         ccd,          "plot color-color diagram"},
Note: See TracChangeset for help on using the changeset viewer.