IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33574


Ignore:
Timestamp:
Mar 21, 2012, 6:42:08 AM (14 years ago)
Author:
eugene
Message:

moving ParsePhotcodeList to libdvo; adding photdbc parallel mode

Location:
branches/eam_branches/ipp-20111122/Ohana/src
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/libdvo/Makefile

    r33446 r33574  
    4444$(SRC)/dvosorts.$(ARCH).o        \
    4545$(SRC)/dvo_photcode_ops.$(ARCH).o \
     46$(SRC)/dvo_photcode_utils.$(ARCH).o \
    4647$(SRC)/LoadPhotcodes.$(ARCH).o   \
    4748$(SRC)/LoadPhotcodesText.$(ARCH).o   \
  • branches/eam_branches/ipp-20111122/Ohana/src/libdvo/include/dvo.h

    r33564 r33574  
    470470int PhotColorTiny (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, int c1, int c2, double *color);
    471471
    472 
    473472PhotCodeData *GetPhotcodeTable (void);
    474473void SetPhotcodeTable (PhotCodeData *);
    475474
    476475int *GetSecFiltMap(PhotCodeData *ouput, PhotCodeData* input);
     476PhotCode **ParsePhotcodeList (char *rawlist, int *nphotcodes, int needAve);
    477477
    478478int LoadPhotcodes (char *catdir_file, char *master_file, int readwrite);
  • branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/dvo_photcode_ops.c

    r31450 r33574  
    857857/***********************************************/
    858858
    859 // Create a map between the secfilt values from one photcode table to another
    860 int *GetSecFiltMap(PhotCodeData *output, PhotCodeData *input) {
    861   int i, j;
    862   int NsecfiltIn  = input[0].Nsecfilt;
    863   int NsecfiltOut = output[0].Nsecfilt;
    864   int *map;
    865   ALLOCATE(map, int, NsecfiltIn);
    866 
    867   // loop over entries in the input table
    868   for (i = 0; i < NsecfiltIn; i++) {
    869     int code  = input[0].codeNsec[i];
    870     int entry = -1;
    871     // find the matching entry in the output table
    872     for (j = 0; j < NsecfiltOut; j++) {
    873       int outcode = output[0].codeNsec[j];
    874       if (code == outcode) {
    875          entry = j;
    876          break;
    877       }
    878     }
    879     // if (entry == -1) {
    880     //   // entry is missing fail (no printfs in this file)
    881     //   free(map);
    882     //   return(FALSE);
    883     // }
    884 
    885     // if entry is still -1, we will skip this one (not map into the output db)
    886     map[i] = entry;
    887   }
    888 
    889   return map;
    890 }
    891859
    892860/* photcode table should have the following format:
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/Makefile

    r33518 r33574  
    2323PHOTDBC = \
    2424$(SRC)/photdbc.$(ARCH).o           \
     25$(SRC)/photdbc_catalogs.$(ARCH).o  \
    2526$(SRC)/initialize.$(ARCH).o        \
    2627$(SRC)/ConfigInit.$(ARCH).o        \
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/include/photdbc.h

    r31635 r33574  
    2020  int    Nmeas;
    2121} StatType;
     22
     23int    PARALLEL;
     24int    PARALLEL_MANUAL;
     25int    PARALLEL_SERIAL;
     26
     27int          HOST_ID;
     28char        *HOSTDIR;
    2229
    2330// need to get RADIUS from Config
     
    124131int copy_images (char *outdir);
    125132void usage();
     133
     134int photdbc_catalogs (SkyList *skylist, int hostID);
     135int photdbc_parallel (SkyList *skylist);
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/args.c

    r30616 r33574  
    8383  }
    8484
     85  // XXX for the moment, make this selection manual.  it needs to be automatic
     86  // based on the state of the SkyTable
     87  PARALLEL = FALSE;
     88  if ((N = get_argument (argc, argv, "-parallel"))) {
     89    PARALLEL = TRUE;
     90    remove_argument (N, &argc, argv);
     91  }
     92  // this is a test mode : rather than launching the remote jobs and waiting for completion,
     93  // relphot will simply list the remote command and wait for the user to signal completion
     94  PARALLEL_MANUAL = FALSE;
     95  if ((N = get_argument (argc, argv, "-parallel-manual"))) {
     96    PARALLEL = TRUE; // -parallel-manual implies -parallel
     97    PARALLEL_MANUAL = TRUE;
     98    remove_argument (N, &argc, argv);
     99  }
     100  // this is a test mode : rather than launching the relphot_client jobs remotely, they are
     101  // run in serial via 'system'
     102  PARALLEL_SERIAL = FALSE;
     103  if ((N = get_argument (argc, argv, "-parallel-serial"))) {
     104    if (PARALLEL_MANUAL) {
     105      fprintf (stderr, "ERROR: cannot mix -parallel-manual and -parallel-serial\n");
     106      exit (1);
     107    }
     108    PARALLEL = TRUE; // -parallel-serial implies -parallel
     109    PARALLEL_SERIAL = TRUE;
     110    remove_argument (N, &argc, argv);
     111  }
     112
    85113  if (argc != 2) usage();
    86114
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/initialize.c

    r33569 r33574  
    22
    33void initialize (int argc, char **argv) {
    4 
    5   int NPHOTCODES;
    6   char *codename, *ptr, *list;
    74
    85  /* are these set correctly? */
     
    1512  args (argc, argv);
    1613
    17   NphotcodesDrop = 0;
    18   photcodesDrop = NULL;
    19   ptr = NULL;
    20   if (PHOTCODE_DROP_LIST != NULL) {
    21     NPHOTCODES = 10;
    22     ALLOCATE (photcodesDrop, PhotCode *, NPHOTCODES);
    23 
    24     /* parse the comma-separated list of photcodesDrop */
    25     list = PHOTCODE_DROP_LIST;
    26     while ((codename = strtok_r (list, ",", &ptr)) != NULL) {
    27       list = NULL; // pass NULL on successive strtok_r calls
    28       fprintf (stderr, "PHOTCODE_LIST: %s\n", PHOTCODE_DROP_LIST);
    29       fprintf (stderr, "codename: %s\n", codename);
    30       if ((photcodesDrop[NphotcodesDrop] = GetPhotcodebyName (codename)) == NULL) {
    31         fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename);
    32         exit (1);
    33       }
    34       NphotcodesDrop ++;
    35       CHECK_REALLOCATE (photcodesDrop, PhotCode *, NPHOTCODES, NphotcodesDrop, 10);
    36     }
    37   }
    38 
    39   NphotcodesSkip = 0;
    40   photcodesSkip = NULL;
    41   if (PHOTCODE_SKIP_LIST != NULL) {
    42     NPHOTCODES = 10;
    43     ALLOCATE (photcodesSkip, PhotCode *, NPHOTCODES);
    44 
    45     /* parse the comma-separated list of photcodesSkip */
    46     list = PHOTCODE_SKIP_LIST;
    47     while ((codename = strtok_r (list, ",", &ptr)) != NULL) {
    48       list = NULL; // pass NULL on successive strtok_r calls
    49       fprintf (stderr, "PHOTCODE_LIST: %s\n", PHOTCODE_SKIP_LIST);
    50       fprintf (stderr, "codename: %s\n", codename);
    51       if ((photcodesSkip[NphotcodesSkip] = GetPhotcodebyName (codename)) == NULL) {
    52         fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename);
    53         exit (1);
    54       }
    55       NphotcodesSkip ++;
    56       CHECK_REALLOCATE (photcodesSkip, PhotCode *, NPHOTCODES, NphotcodesSkip, 10);
    57     }
    58   }
     14  photcodesDrop = ParsePhotcodeList (PHOTCODE_DROP_LIST, &NphotcodeDrop, FALSE);
     15  photcodesSkip = ParsePhotcodeList (PHOTCODE_SKIP_LIST, &NphotcodeSkip, FALSE);
    5916
    6017  if (SHOW_PARAMS) {
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/photdbc.c

    r33218 r33574  
    33int main (int argc, char **argv) {
    44
    5   int i;
    6   char *skyfile;
    7   Catalog incatalog;
    8   Catalog outcatalog;
    95  SkyTable *sky;
    106  SkyList *skylist;
     
    2016  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2117  skylist = SkyListByPatch (sky, -1, &REGION);
    22   for (i = 0; i < skylist[0].Nregions; i++) {
    23     if (VERBOSE) fprintf (stderr, "%s\n", skylist[0].regions[i][0].name);
    2418
    25     // set the parameters which guide catalog open/load/create
    26     incatalog.filename = skylist[0].filename[i];
    27     incatalog.Nsecfilt = GetPhotcodeNsecfilt ();
    28     incatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    29 
    30     // an error exit status here is a significant error
    31     if (!dvo_catalog_open (&incatalog, skylist[0].regions[i], VERBOSE, "r")) {
    32       fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", incatalog.filename);
    33       exit (2);
    34     }
    35     // skip empty input catalogs
    36     if (!incatalog.Naves_disk) {
    37       dvo_catalog_unlock (&incatalog);
    38       dvo_catalog_free (&incatalog);
    39       continue;
    40     }
    41 
    42     // create output catalog filename
    43     outcatalog.filename = strsubs (incatalog.filename, CATDIR, argv[1]);
    44     if (outcatalog.filename == NULL) Shutdown ("error with input catalog name");
    45 
    46     // define outcatalog open parameters
    47     outcatalog.catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
    48     outcatalog.catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
    49     outcatalog.Nsecfilt  = incatalog.Nsecfilt;                 // inherit from the incatalog
    50     outcatalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
    51 
    52     // output catalogs always represent the same skyregions as the input catalogs
    53     if (!dvo_catalog_open (&outcatalog, skylist[0].regions[i], VERBOSE, "w")) {
    54       fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", outcatalog.filename);
    55       exit (2);
    56     }
    57 
    58     // the output catalog needs to have the same values for 'objID' and 'sorted' as the input
    59     outcatalog.objID = incatalog.objID;
    60     outcatalog.sorted = incatalog.sorted;
    61     if (!incatalog.sorted) {
    62       fprintf (stderr, "ERROR: input db must be sorted: %s\n", incatalog.filename);
    63       exit (2);
    64     }
    65 
    66     /* limit number of measures based on selections */
    67     make_subcatalog (&outcatalog, &incatalog, skylist[0].regions[i]);
    68        
    69     // XXX add other filters here:
    70     // join_stars (&outcatalog);
    71     // unique_measures (catalog);
    72     // flag_measures (&db, catalog);
    73     // get_mags (catalog);
    74 
    75     dvo_catalog_save (&outcatalog, VERBOSE);
    76     dvo_catalog_unlock (&outcatalog);
    77     dvo_catalog_free (&outcatalog);
    78 
    79     dvo_catalog_unlock (&incatalog);
    80     dvo_catalog_free (&incatalog);
    81   }
    82 
    83   skyfile = SkyTableFilename (argv[1]);
    84   SkyTableSave (sky, skyfile);
     19  // hostID is 0 for master program
     20  photdbc_catalogs (skylist, 0);
    8521  exit (0);
    8622}
  • branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/initialize.c

    r33532 r33574  
    6363}
    6464
    65 PhotCode **ParsePhotcodeList (char *rawlist, int *nphotcodes, int needAve) {
    66 
    67   *nphotcodes = 0;
    68   if (!rawlist) return NULL;
    69 
    70   int Nphotcodes = 0;
    71   int NPHOTCODES = 10;
    72   PhotCode **photcodes = NULL;
    73   ALLOCATE (photcodes, PhotCode *, NPHOTCODES);
    74 
    75   /* parse the comma-separated list of photcodes */
    76   char *myList = strcreate(rawlist);
    77   char *list = myList;
    78   char *codename = NULL;
    79   char *ptr = NULL;
    80   while ((codename = strtok_r (list, ",", &ptr)) != NULL) {
    81     list = NULL; // pass NULL on successive strtok_r calls
    82     if ((photcodes[Nphotcodes] = GetPhotcodebyName (codename)) == NULL) {
    83       fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename);
    84       exit (1);
    85     }
    86     if (needAve && (photcodes[Nphotcodes][0].type != PHOT_SEC)) {
    87       fprintf (stderr, "photcode %s is not an filter type (SEC)\n", codename);
    88       exit (1);
    89     }
    90     Nphotcodes ++;
    91     CHECK_REALLOCATE (photcodes, PhotCode *, NPHOTCODES, Nphotcodes, 10);
    92   }
    93   free (myList);
    94 
    95   *nphotcodes = Nphotcodes;
    96   return photcodes;
    97 }
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/initialize.c

    r33472 r33574  
    11# include "relphot.h"
    2 
    3 void ParsePhotcodeList (char *word);
    42
    53void initialize (int argc, char **argv) {
     
    1311    // only a single remaining argument in this mode (the list of photcodes, eg g,r,i)
    1412    PhotcodeList = strcreate (argv[1]);
    15     ParsePhotcodeList (PhotcodeList);
     13    photcodes = ParsePhotcodeList (PhotcodeList, &Nphotcodes, TRUE); // require SEC photcodes
    1614  }
    1715  if (USE_GRID && (Nphotcodes > 1)) {
     
    6967  // load the list of photcodes into the globals (photcodes, Nphotcodes)
    7068  PhotcodeList = strcreate (argv[1]);
    71   ParsePhotcodeList (PhotcodeList);
     69  photcodes = ParsePhotcodeList (PhotcodeList, &Nphotcodes, TRUE); // require SEC photcodes
    7270}
    7371
    74 void ParsePhotcodeList (char *word) {
     72void ParsePhotcodeList_old (char *word) {
    7573
    7674  Nphotcodes = 0;
Note: See TracChangeset for help on using the changeset viewer.