IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33274


Ignore:
Timestamp:
Feb 15, 2012, 2:30:58 PM (14 years ago)
Author:
eugene
Message:

deprecate the old relphot command of the form: relphot (catalog) (photcode); fix the BrightCatalog I/O; add parallel-manual option for testing

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

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/include/relphot.h

    r33254 r33274  
    4141
    4242typedef struct {
    43     AverageTiny *average;
    44     MeasureTiny *measure;
    45     SecFilt     *secfilt;
    46     off_t Naverage;
    47     off_t Nmeasure;
     43  AverageTiny *average;       // array of (minimal) average data
     44  MeasureTiny *measure;       // array of (minimal) measure data
     45  SecFilt     *secfilt;       // array of secfilt data (matched to average by Nsecfilt)
     46  off_t      Naverage;
     47  off_t      Nmeasure;
    4848} BrightCatalog;
    4949
     
    5757  unsigned char trate;
    5858} ImageSubset;
     59
     60typedef struct {
     61  Catalog *catalog;           // array of catalogs generated
     62  int NCATALOG;               // number of catalogs allocated
     63  int Ncatalog;               // number of catalogs generated
     64  int Nsecfilt;               // number of catalogs generated
     65  off_t *NAVERAGE;            // allocated Averages per catalog
     66  off_t *NMEASURE;            // allocated Measures per catalog
     67  int   *index;               // lookup table catID -> catalog[i]
     68  int   *catIDs;              // lookup table catID <- catalog[i]
     69  int    maxID;               // max catID value to date
     70} CatalogSplitter;
    5971
    6072/* global variables set in parameter file */
     
    8597double IMFIT_SYS_SIGMA_LIM;
    8698double CLOUD_TOLERANCE;
     99
     100int    PARALLEL;
     101int    PARALLEL_MANUAL;
    87102
    88103int    VERBOSE;
     
    144159
    145160SkyRegion UserPatch;
    146 int UserPatchSelect;
     161char *UserCatalog;
    147162
    148163int USE_BASIC_CHECK;
     
    214229Catalog      *load_catalogs_parallel PROTO((SkyList *sky, int *Ncatalog));
    215230
    216 SkyList      *load_images         PROTO((FITS_DB *db, char *regionName, SkyRegion *region, int RegionSelect));
     231SkyList      *load_images         PROTO((FITS_DB *db, char *regionName, SkyRegion *region));
    217232Image        *select_images       PROTO((SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage));
    218233
     
    285300int BrightCatalogSave(char *filename, BrightCatalog *catalog);
    286301BrightCatalog *BrightCatalogMerge (Catalog *catalog, int Ncatalog);
     302CatalogSplitter *BrightCatalogSplitInit (int Nsecfilt);
     303int BrightCatalogSplitFree (CatalogSplitter *catalogs);
     304int BrightCatalogSplit (CatalogSplitter *catalogs, BrightCatalog *bcatalog);
    287305
    288306int ImageSubsetSave(char *filename, ImageSubset *image, off_t Nimage);
     
    291309int CopyAverageTiny (AverageTiny *averageT, Average *average);
    292310int CopyMeasureTiny (MeasureTiny *measureT, Measure *measure);
     311
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/BrightCatalog.c

    r33270 r33274  
    241241    gfits_create_table_header (&theader, "BINTABLE", "MEASURE_TINY");
    242242
    243     gfits_define_bintable_column (&theader, "E", "RA_OFF",   "ra offset",              "arcsec", 1.0, 0.0);
    244     gfits_define_bintable_column (&theader, "E", "DEC_OFF",  "dec offset",             "arcsec", 1.0, 0.0);
    245     gfits_define_bintable_column (&theader, "E", "MAG_SYS",  "magnitude (sys)",                NULL,    1.0, 0.0);
    246     gfits_define_bintable_column (&theader, "E", "MAG_CAL",  "magnitude (cal)",                NULL,    1.0, 0.0);
    247     gfits_define_bintable_column (&theader, "E", "MAG_ERR",  "magnitude (err)",                NULL,    1.0, 0.0);
    248     gfits_define_bintable_column (&theader, "E", "AIRMASS",  "airmass",                  NULL,  1.0, 0.0);
    249     gfits_define_bintable_column (&theader, "E", "X_CCD",    "ccd x coord",            "pix",    1.0, 0.0);
    250     gfits_define_bintable_column (&theader, "E", "Y_CCD",    "ccd y coord",            "pix",    1.0, 0.0);
    251     gfits_define_bintable_column (&theader, "E", "EXPTIME",  "-2.5 * log (exposure time)", "sec",        1.0, 0.0);
    252     gfits_define_bintable_column (&theader, "J", "TIME",     "time of exp",              "sec",          1.0, 1.0*0x8000);
    253     gfits_define_bintable_column (&theader, "J", "AVE_REF",  "pointer to average table", NULL,  1.0, 1.0*0x8000);
    254     gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image",                          NULL,    1.0, 1.0*0x8000);
    255     gfits_define_bintable_column (&theader, "J", "DB_FLAGS", "flags",                          NULL,    1.0, 1.0*0x8000);
    256     gfits_define_bintable_column (&theader, "J", "CAT_ID",   "catalog",                        NULL,     1.0, 0.0);
    257     gfits_define_bintable_column (&theader, "K", "PHOTCODE", "photcode",                       NULL,     1.0, 0.0);
     243    gfits_define_bintable_column (&theader, "E", "RA_OFF",   "ra offset",                  "arcsec", 1.0, 0.0);
     244    gfits_define_bintable_column (&theader, "E", "DEC_OFF",  "dec offset",                 "arcsec", 1.0, 0.0);
     245    gfits_define_bintable_column (&theader, "E", "MAG_SYS",  "magnitude (sys)",             NULL,    1.0, 0.0);
     246    gfits_define_bintable_column (&theader, "E", "MAG_CAL",  "magnitude (cal)",             NULL,    1.0, 0.0);
     247    gfits_define_bintable_column (&theader, "E", "MAG_ERR",  "magnitude (err)",             NULL,    1.0, 0.0);
     248    gfits_define_bintable_column (&theader, "E", "AIRMASS",  "airmass",                     NULL,    1.0, 0.0);
     249    gfits_define_bintable_column (&theader, "E", "X_CCD",    "ccd x coord",                "pix",    1.0, 0.0);
     250    gfits_define_bintable_column (&theader, "E", "Y_CCD",    "ccd y coord",                "pix",    1.0, 0.0);
     251    gfits_define_bintable_column (&theader, "E", "EXPTIME",  "-2.5 * log (exposure time)", "sec",    1.0, 0.0);
     252    gfits_define_bintable_column (&theader, "J", "TIME",     "time of exp",                "sec",    1.0, 1.0*0x8000);
     253    gfits_define_bintable_column (&theader, "J", "AVE_REF",  "pointer to average table",    NULL,    1.0, 1.0*0x8000);
     254    gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image",                       NULL,    1.0, 1.0*0x8000);
     255    gfits_define_bintable_column (&theader, "J", "DB_FLAGS", "flags",                       NULL,    1.0, 1.0*0x8000);
     256    gfits_define_bintable_column (&theader, "J", "CAT_ID",   "catalog",                     NULL,    1.0, 1.0*0x8000);
     257    gfits_define_bintable_column (&theader, "I", "PHOTCODE", "photcode",                    NULL,    1.0, 1.0*0x80);
    258258
    259259    // generate the output array that carries the data
     
    340340    gfits_create_table_header (&theader, "BINTABLE", "AVERAGE_TINY");
    341341
    342     gfits_define_bintable_column (&theader, "D", "RA",                "ra (J2000)",            "degree", 1.0, 0.0);
    343     gfits_define_bintable_column (&theader, "D", "DEC",               "dec (J2000)",           "degree", 1.0, 0.0);
    344     gfits_define_bintable_column (&theader, "J", "NMEAS",       "number of measures",     NULL,         1.0, 0.0);
    345     gfits_define_bintable_column (&theader, "J", "MEASURE_OFF", "index to measurements",  NULL,         1.0, 0.0);
    346     gfits_define_bintable_column (&theader, "J", "FLAGS",       "flags",                  NULL,         1.0, 0.0);
    347     gfits_define_bintable_column (&theader, "J", "CAT_ID",      "catalog ref",            NULL,         1.0, 0.0);
     342    gfits_define_bintable_column (&theader, "D", "RA",          "ra (J2000)",            "degree", 1.0, 0.0);
     343    gfits_define_bintable_column (&theader, "D", "DEC",         "dec (J2000)",           "degree", 1.0, 0.0);
     344    gfits_define_bintable_column (&theader, "J", "NMEAS",       "number of measures",     NULL,   1.0, 0.0);
     345    gfits_define_bintable_column (&theader, "J", "MEASURE_OFF", "index to measurements",  NULL,   1.0, 0.0);
     346    gfits_define_bintable_column (&theader, "J", "FLAGS",       "flags",                  NULL,   1.0, 0.0);
     347    gfits_define_bintable_column (&theader, "J", "CAT_ID",      "catalog ref",            NULL,   1.0, 0.0);
    348348
    349349    // generate the output array that carries the data
     
    396396    gfits_define_bintable_column (&theader, "E", "MAG",      "ra offset",                "arcsec", 1.0, 0.0);
    397397    gfits_define_bintable_column (&theader, "E", "MAG_ERR",  "dec offset",               "arcsec", 1.0, 0.0);
    398     gfits_define_bintable_column (&theader, "E", "MAG_CHI",  "magnitude (sys)",          NULL,     1.0, 0.0);
    399     gfits_define_bintable_column (&theader, "J", "FLAGS",    "magnitude (cal)",          NULL,     1.0, 0.0);
    400     gfits_define_bintable_column (&theader, "I", "NCODE",    "magnitude (err)",          NULL,     1.0, 0.0);
    401     gfits_define_bintable_column (&theader, "I", "NUSED",    "airmass",                  NULL,     1.0, 0.0);
     398    gfits_define_bintable_column (&theader, "E", "MAG_CHI",  "magnitude (sys)",           NULL,    1.0, 0.0);
     399    gfits_define_bintable_column (&theader, "J", "FLAGS",    "magnitude (cal)",           NULL,    1.0, 0.0);
     400    gfits_define_bintable_column (&theader, "I", "NCODE",    "magnitude (err)",           NULL,    1.0, 0.0);
     401    gfits_define_bintable_column (&theader, "I", "NUSED",    "airmass",                   NULL,    1.0, 0.0);
    402402    gfits_define_bintable_column (&theader, "I", "MAG_20",   "ccd x coord",              "pix",    1.0, 0.0);
    403403    gfits_define_bintable_column (&theader, "I", "MAG_80",   "ccd y coord",              "pix",    1.0, 0.0);
     
    460460}
    461461
     462// merge a list of catalogs into a single BrightCatalog array set
    462463BrightCatalog *BrightCatalogMerge (Catalog *catalog, int Ncatalog) {
    463464
     
    507508  return bcatalog;
    508509}
     510
     511// distribute a bright catalog across separate catalogs
     512CatalogSplitter *BrightCatalogSplitInit (int Nsecfilt) {
     513
     514  int i;
     515
     516  CatalogSplitter *catalogs = NULL;
     517
     518  ALLOCATE (catalogs, CatalogSplitter, 1);
     519
     520  // as we see new BrightCatalogs, we will update maxID and extend this array
     521  catalogs->maxID = 0;
     522  ALLOCATE (catalogs->index, int, catalogs->maxID + 1);
     523  for (i = 0; i <= catalogs->maxID; i++) catalogs->index[i] = -1;
     524
     525  catalogs->Nsecfilt = Nsecfilt;
     526
     527  catalogs->Ncatalog =  0;
     528  catalogs->NCATALOG = 16;
     529  catalogs->catalog = NULL;
     530  ALLOCATE (catalogs->catalog, Catalog, catalogs->NCATALOG);
     531
     532  ALLOCATE (catalogs->catIDs,   int,   catalogs->NCATALOG);
     533  ALLOCATE (catalogs->NAVERAGE, off_t, catalogs->NCATALOG);
     534  ALLOCATE (catalogs->NMEASURE, off_t, catalogs->NCATALOG);
     535
     536  for (i = 0; i < catalogs->NCATALOG; i++) {
     537    catalogs->catIDs[i] = 0;
     538    catalogs->NAVERAGE[i] = 100;
     539    catalogs->NMEASURE[i] = 100;
     540    catalogs->catalog[i].Naverage = 0;
     541    catalogs->catalog[i].Nmeasure = 0;
     542    ALLOCATE (catalogs->catalog[i].averageT, AverageTiny, catalogs->NAVERAGE[i]);
     543    ALLOCATE (catalogs->catalog[i].measureT, MeasureTiny, catalogs->NMEASURE[i]);
     544    ALLOCATE (catalogs->catalog[i].secfilt,  SecFilt,     catalogs->NAVERAGE[i]*Nsecfilt);
     545  }
     546  return catalogs;
     547}
     548
     549// distribute a bright catalog across separate catalogs
     550int BrightCatalogSplitFree (CatalogSplitter *catalogs) {
     551
     552  // XXX don't free the catalogs :
     553  // for (i = 0; i < NCATALOG; i++) {
     554  //   free (catalogs->catalog[i].averageT);
     555  //   free (catalogs->catalog[i].measureT);
     556  //   free (catalogs->catalog[i].secfilt);
     557  // }
     558  // free (catalogs->catalog);
     559
     560  free (catalogs->catIDs);
     561  free (catalogs->NAVERAGE);
     562  free (catalogs->NMEASURE);
     563  free (catalogs->index);
     564  free (catalogs);
     565  return TRUE;
     566}
     567
     568// distribute a bright catalog across separate catalogs
     569int BrightCatalogSplit (CatalogSplitter *catalogs, BrightCatalog *bcatalog) {
     570
     571  int i;
     572
     573  int Nsecfilt = catalogs->Nsecfilt;
     574
     575  // find the max value of catID in this BrightCatalog
     576  int catIDmax = 0;
     577  for (i = 0; i < bcatalog->Naverage; i++) {
     578    catIDmax = MAX(catIDmax, bcatalog->average[i].catID);
     579  }
     580  // XXX validate the measure ID range here
     581   
     582  int maxIDold = catalogs->maxID;
     583  catalogs->maxID = MAX (maxIDold, catIDmax);
     584   
     585  // extend the index array and init
     586  REALLOCATE (catalogs->index, int, catalogs->maxID + 1);
     587  for (i = maxIDold + 1; i <= catalogs->maxID; i++) catalogs->index[i] = -1;
     588
     589  // identify the new catID values
     590  for (i = 0; i < bcatalog->Naverage; i++) {
     591    int catID = bcatalog->average[i].catID;
     592    assert (catID > 0);
     593    assert (catID < catalogs->maxID + 1);
     594    int idx = catalogs->index[catID];
     595    if (idx != -1) continue; // already have seen this one
     596
     597    // a new catID value
     598    int Ncat = catalogs->Ncatalog; // the next available slot
     599    catalogs->catIDs[Ncat] = catID;
     600    assert (Ncat >= 0);
     601    assert (Ncat < catalogs->NCATALOG);
     602
     603    catalogs->index[catID] = Ncat;
     604    assert (catID > 0);
     605    assert (catID < catalogs->maxID + 1);
     606
     607    catalogs->Ncatalog ++;
     608
     609    if (catalogs->Ncatalog >= catalogs->NCATALOG) {
     610      catalogs->NCATALOG += 16;
     611      fprintf (stderr, "realloc catalogs->catalog: old: %llx  ", (long long) catalogs->catalog);
     612      REALLOCATE (catalogs->catalog, Catalog, catalogs->NCATALOG);
     613      fprintf (stderr, "new: %llx  -  %llx\n", (long long) catalogs->catalog, (long long) (catalogs->catalog + sizeof(Catalog)*catalogs->NCATALOG));
     614
     615      fprintf (stderr, "realloc catalogs->NAVERAGE: old: %llx  ", (long long) catalogs->NAVERAGE);
     616      REALLOCATE (catalogs->NAVERAGE, off_t,  catalogs->NCATALOG);
     617      fprintf (stderr, "new: %llx  -  %llx\n", (long long) catalogs->NAVERAGE, (long long) (catalogs->NAVERAGE + sizeof(off_t)*catalogs->NCATALOG));
     618
     619      fprintf (stderr, "realloc catalogs->NMEASURE: old: %llx  ", (long long) catalogs->NMEASURE);
     620      REALLOCATE (catalogs->NMEASURE, off_t,  catalogs->NCATALOG);
     621      fprintf (stderr, "new: %llx  -  %llx\n", (long long) catalogs->NMEASURE, (long long) (catalogs->NMEASURE + sizeof(off_t)*catalogs->NCATALOG));
     622
     623      REALLOCATE (catalogs->catIDs,   int,   catalogs->NCATALOG);
     624
     625      int j;
     626      for (j = catalogs->NCATALOG - 16; j < catalogs->NCATALOG; j++) {
     627        // XXX call the catalog init function in libdvo?
     628        catalogs->catIDs[j] = 0;
     629        catalogs->NAVERAGE[j] = 100;
     630        catalogs->NMEASURE[j] = 100;
     631        catalogs->catalog[j].Naverage = 0;
     632        catalogs->catalog[j].Nmeasure = 0;
     633        ALLOCATE (catalogs->catalog[j].averageT, AverageTiny, catalogs->NAVERAGE[j]);
     634        ALLOCATE (catalogs->catalog[j].measureT, MeasureTiny, catalogs->NMEASURE[j]);
     635        ALLOCATE (catalogs->catalog[j].secfilt,  SecFilt,     catalogs->NAVERAGE[j]*Nsecfilt);
     636      }
     637    }
     638  }
     639
     640  // each bcatalog (from each host) has a different set of catID ranges
     641  // they also (probably) have contiguous ranges.  But, it is a bit tricky to be sure I
     642  // can use that info, so perhaps ignore it
     643
     644  // assign the averages to the corresponding catalog
     645  for (i = 0; i < bcatalog->Naverage; i++) {
     646    int ID = bcatalog->average[i].catID;
     647    int Nc = catalogs->index[ID];
     648    assert (Nc > -1);
     649    assert (Nc < catalogs->NCATALOG);
     650
     651    int Na = catalogs->catalog[Nc].Naverage;
     652    catalogs->catalog[Nc].averageT[Na] = bcatalog->average[i];
     653
     654    // secfilt entries are grouped in blocks for each average
     655    int k;
     656    for (k = 0; k < Nsecfilt; k++) {
     657      catalogs->catalog[Nc].secfilt[Na*Nsecfilt + k] = bcatalog->secfilt[i*Nsecfilt + k];
     658    }     
     659
     660    catalogs->catalog[Nc].Naverage ++;
     661    if (catalogs->catalog[Nc].Naverage >= catalogs->NAVERAGE[Nc]) {
     662      catalogs->NAVERAGE[Nc] += 100;
     663      REALLOCATE (catalogs->catalog[Nc].averageT, AverageTiny, catalogs->NAVERAGE[Nc]);
     664      REALLOCATE (catalogs->catalog[Nc].secfilt,  SecFilt,     catalogs->NAVERAGE[Nc]*Nsecfilt);
     665    }         
     666  }
     667
     668  // assign the measures to the corresponding catalog
     669  // XXX what about averef and related links?  Do I need them?
     670  for (i = 0; i < bcatalog->Nmeasure; i++) {
     671    int ID = bcatalog->measure[i].catID;
     672    int Nc = catalogs->index[ID];
     673    assert (Nc > -1);
     674    assert (Nc < catalogs->NCATALOG);
     675    int Na = catalogs->catalog[Nc].Nmeasure;
     676    catalogs->catalog[Nc].measureT[Na] = bcatalog->measure[i];
     677    catalogs->catalog[Nc].Nmeasure ++;
     678    if (catalogs->catalog[Nc].Nmeasure >= catalogs->NMEASURE[Nc]) {
     679      catalogs->NMEASURE[Nc] += 100;
     680      REALLOCATE (catalogs->catalog[Nc].measureT, MeasureTiny, catalogs->NMEASURE[Nc]);
     681    }         
     682  }
     683
     684  return TRUE;
     685}
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/args.c

    r33270 r33274  
    3838  UserPatch.Dmin = -90;
    3939  UserPatch.Dmax = +90;
    40   UserPatchSelect = FALSE;
    4140  if ((N = get_argument (argc, argv, "-region"))) {
    4241    remove_argument (N, &argc, argv);
     
    4948    UserPatch.Dmax = atof (argv[N]);
    5049    remove_argument (N, &argc, argv);
    51     UserPatchSelect = TRUE;
     50  }
     51
     52  /* specify region file by name (eg n0000/0000.00) */
     53  UserCatalog = NULL;
     54  if ((N = get_argument (argc, argv, "-catalog"))) {
     55    remove_argument (N, &argc, argv);
     56    UserCatalog = strcreate (argv[N]);
     57    remove_argument (N, &argc, argv);
    5258  }
    5359
     
    6571  if ((N = get_argument (argc, argv, "-vv"))) {
    6672    VERBOSE2 = VERBOSE = TRUE;
     73    remove_argument (N, &argc, argv);
     74  }
     75
     76  // XXX for the moment, make this selection manual.  it needs to be automatic
     77  // based on the state of the SkyTable
     78  PARALLEL = FALSE;
     79  if ((N = get_argument (argc, argv, "-parallel"))) {
     80    PARALLEL = TRUE;
     81    remove_argument (N, &argc, argv);
     82  }
     83  // this is a test mode : rather than launching the remote jobs and waiting for completion,
     84  // relphot will simply list the remote command and wait for the user to signal completion
     85  PARALLEL_MANUAL = FALSE;
     86  if ((N = get_argument (argc, argv, "-parallel-manual"))) {
     87    PARALLEL = TRUE; // -parallel-manual implies -parallel
     88    PARALLEL_MANUAL = TRUE;
    6789    remove_argument (N, &argc, argv);
    6890  }
     
    260282
    261283  if (UpdateAverages && (argc == 1)) return TRUE;
    262   if (UserPatchSelect && (argc == 2)) return TRUE;
    263   if (argc != 3) relphot_usage ();
     284  if (argc != 2) relphot_usage ();
    264285
    265286  return TRUE;
     
    269290
    270291  int N;
     292
     293  // by definition, the client is not parallel
     294  PARALLEL = FALSE;
    271295
    272296  if ((N = get_argument (argc, argv, "-v"))) {
     
    325349  UserPatch.Dmin = -90;
    326350  UserPatch.Dmax = +90;
    327   UserPatchSelect = FALSE;
    328351  if ((N = get_argument (argc, argv, "-region"))) {
    329352    remove_argument (N, &argc, argv);
     
    336359    UserPatch.Dmax = atof (argv[N]);
    337360    remove_argument (N, &argc, argv);
    338     UserPatchSelect = TRUE;
    339361  }
    340362
     
    343365  return TRUE;
    344366}
     367
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/bcatalog.c

    r31668 r33274  
    5757
    5858  Ncode = Ntime = Ndophot = Nmag = Nsigma = Nimag = Nfew = Npsfqf = Ngalaxy = 0;
     59
     60  // copy the following fields to the subcatalog:
     61  subcatalog[0].catID = catalog[0].catID;
     62  subcatalog[0].filename = catalog[0].filename;
    5963
    6064  /* exclude stars not in range or with too few measurements */
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/help.c

    r33270 r33274  
    22
    33void relphot_usage (void) {
    4   fprintf (stderr, "ERROR: USAGE: relphot (region) (photcode)\n");
    5   fprintf (stderr, "       or:    relphot (photcode) -region RA RA DEC DEC\n");
     4  fprintf (stderr, "ERROR: USAGE: relphot (photcodes) -region RA RA DEC DEC\n");
     5  fprintf (stderr, "       or:    relphot (photcodes) -catalog (name)\n");
    66  fprintf (stderr, "       or:    relphot -averages -region RA RA DEC DEC\n");
    77  fprintf (stderr, "  use -h for more usage information\n");
     
    1818
    1919show_help:
    20   fprintf (stderr, "ERROR: USAGE: relphot (region) (photcode)\n");
    21   fprintf (stderr, "       or:    relphot (photcode) -region RA RA DEC DEC\n");
     20  fprintf (stderr, "ERROR: USAGE: relphot (photcode) -region RA RA DEC DEC\n");
     21  fprintf (stderr, "       or:    relphot (photcode) -catalog (name)\n");
    2222  fprintf (stderr, "       or:    relphot -averages -region RA RA DEC DEC\n");
    2323  fprintf (stderr, "  options: \n");
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/initialize.c

    r33270 r33274  
    11# include "relphot.h"
    22
    3 void ParsePhotcodeList (char *word) {
    4 
    5   Nphotcodes = 0;
    6   photcodes = NULL;
    7   int NPHOTCODES = 10;
    8   ALLOCATE (photcodes, PhotCode *, NPHOTCODES);
    9 
    10   /* parse the comma-separated list of photcodesKeep */
    11   char *myList = strcreate(word);
    12   char *list = myList;
    13   char *codename = NULL;
    14   char *ptr = NULL;
    15   while ((codename = strtok_r (list, ",", &ptr)) != NULL) {
    16     list = NULL; // pass NULL on successive strtok_r calls
    17     fprintf (stderr, "PHOTCODE LIST: %s\n", myList);
    18     fprintf (stderr, "codename: %s\n", codename);
    19     if ((photcodes[Nphotcodes] = GetPhotcodebyName (codename)) == NULL) {
    20       fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename);
    21       exit (1);
    22     }
    23     if (photcodes[Nphotcodes][0].type != PHOT_SEC) {
    24       fprintf (stderr, "photcode %s is not an filter type (SEC)\n", codename);
    25       exit (1);
    26     }
    27     Nphotcodes ++;
    28     CHECK_REALLOCATE (photcodes, PhotCode *, NPHOTCODES, Nphotcodes, 10);
    29   }
    30 }
     3void ParsePhotcodeList (char *word);
    314
    325void initialize (int argc, char **argv) {
    33 
    34   int N;
    356
    367  relphot_help (argc, argv);
     
    3910
    4011  if (!UpdateAverages) {
    41 
    42     N = UserPatchSelect ? 1 : 2;
    43 
    44 # if (0)
    45     // XXX DEP
    46     if ((photcode = GetPhotcodebyName (argv[N])) == NULL) {
    47       fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]);
    48       exit (1);
    49     }
    50     if (photcode[0].type != PHOT_SEC) {
    51       fprintf (stderr, "photcode %s is not a primary or secondary filter\n", argv[N]);
    52       exit (1);
    53     }
    54     // PhotSec is used to select the single average photcode being processed
    55     PhotSec = GetPhotcodeNsec (photcode[0].code);
    56 # endif
    57 
    5812    // load the list of photcodes into the globals (photcodes, Nphotcodes)
    59     ParsePhotcodeList (argv[N]);
     13    // only a single remaining argument in this mode (the list of photcodes, eg g,r,i)
     14    ParsePhotcodeList (argv[1]);
    6015  }
    61   // XXX DEP PhotNsec = GetPhotcodeNsecfilt ();
    6216  if (USE_GRID && (Nphotcodes > 1)) {
    6317    fprintf (stderr, "grid correction analysis currently can only operate on a single photcode\n");
     
    11165  ParsePhotcodeList (argv[1]);
    11266}
     67
     68void ParsePhotcodeList (char *word) {
     69
     70  Nphotcodes = 0;
     71  photcodes = NULL;
     72  int NPHOTCODES = 10;
     73  ALLOCATE (photcodes, PhotCode *, NPHOTCODES);
     74
     75  /* parse the comma-separated list of photcodesKeep */
     76  char *myList = strcreate(word);
     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    fprintf (stderr, "PHOTCODE LIST: %s\n", myList);
     83    fprintf (stderr, "codename: %s\n", codename);
     84    if ((photcodes[Nphotcodes] = GetPhotcodebyName (codename)) == NULL) {
     85      fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename);
     86      exit (1);
     87    }
     88    if (photcodes[Nphotcodes][0].type != PHOT_SEC) {
     89      fprintf (stderr, "photcode %s is not an filter type (SEC)\n", codename);
     90      exit (1);
     91    }
     92    Nphotcodes ++;
     93    CHECK_REALLOCATE (photcodes, PhotCode *, NPHOTCODES, Nphotcodes, 10);
     94  }
     95}
     96
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/load_catalogs.c

    r33254 r33274  
    1616
    1717  // XXX need to decide how to determine PARALLEL mode...
    18 # define PARALLEL 1
    1918  if (PARALLEL & !hostID) {
    2019    catalog = load_catalogs_parallel (skylist, Ncatalog);
     
    114113    fprintf (stderr, "command: %s\n", command);
    115114
    116     // launch the job on the remote machine (no handshake)
    117     int errorInfo = 0;
    118     int pid = rconnect ("ssh", table->hosts[i].hostname, command, table->hosts[i].stdio, &errorInfo, FALSE);
    119     if (!pid) {
    120       if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", table->hosts[i].hostname, errorInfo);
    121       exit (1);
     115    if (!PARALLEL_MANUAL) {
     116      // launch the job on the remote machine (no handshake)
     117      int errorInfo = 0;
     118      int pid = rconnect ("ssh", table->hosts[i].hostname, command, table->hosts[i].stdio, &errorInfo, FALSE);
     119      if (!pid) {
     120        if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", table->hosts[i].hostname, errorInfo);
     121        exit (1);
     122      }
     123      table->hosts[i].pid = pid; // save for future reference
     124      // check that all hosts started OK?
    122125    }
    123     table->hosts[i].pid = pid; // save for future reference
    124 
    125     // check that all hosts started OK?
    126126  }
    127127
    128   // watch for stdout / stderr from those jobs...
    129   // wait for all of them to complete...
     128  if (PARALLEL_MANUAL) {
     129    fprintf (stderr, "run the relphot_client commands above.  when these are done, hit return\n");
     130    getchar();
     131  } else {
     132    // watch for stdout / stderr from those jobs...
     133    // wait for all of them to complete...
     134  }
    130135
    131   // each host generates a BrightCatalog structure, with the measure, average, etc value loaded into a single
    132   // set of arrays (of MeasureTiny, AverageTiny, Secfilt).  I need to split out the
    133   // per-catalog measurements into separate catalog entries.
     136  // each host generates a BrightCatalog structure, with the measure, average, etc value
     137  // loaded into a single set of arrays (of MeasureTiny, AverageTiny, Secfilt).  I need to
     138  // split out the per-catalog measurements into separate catalog entries.
    134139
    135   // we don't know how many catalogs we actually need.  allocate a single entry, then
    136   // below we will allocate the max number needed after the BrightCatalog is loaded
    137   int NCATALOG = 1;
    138   Catalog *catalog = NULL;
    139   ALLOCATE (catalog, Catalog, NCATALOG);
    140 
    141   int *NAVERAGE;
    142   int *NMEASURE;
    143   ALLOCATE (NAVERAGE, int, NCATALOG);
    144   ALLOCATE (NMEASURE, int, NCATALOG);
    145   for (i = 0; i < NCATALOG; i++) {
    146     NAVERAGE[i] = 100;
    147     NMEASURE[i] = 100;
    148     catalog[i].Naverage = 0;
    149     catalog[i].Nmeasure = 0;
    150     ALLOCATE (catalog[i].averageT, AverageTiny, NAVERAGE[i]);
    151     ALLOCATE (catalog[i].measureT, MeasureTiny, NMEASURE[i]);
    152     ALLOCATE (catalog[i].secfilt, SecFilt, Nsecfilt*NAVERAGE[i]);
    153   }
     140  // set up an initial array of catalogs
     141  CatalogSplitter *catalogs = BrightCatalogSplitInit (Nsecfilt);
    154142
    155143  for (i = 0; i < table->Nhosts; i++) {
     
    162150    assert (bcatalog);
    163151   
    164     // XXX this is wrong : I need to distinguish between the array of catalogs
    165     // and the range of catID values.
     152    BrightCatalogSplit (catalogs, bcatalog);
    166153
    167     // I need to determine the set of unique catID values and count them,
    168     // I'll also need a lookup table from catID -> index.
     154    free (bcatalog->average);
     155    free (bcatalog->measure);
     156    free (bcatalog->secfilt);
     157    free (bcatalog);
     158  }
    169159
    170     // XXX put the code below into a function equivalent to BrightCatalogMerge?
     160  Catalog *catalog = catalogs->catalog;
     161  *Ncatalog = catalogs->Ncatalog;
     162  BrightCatalogSplitFree (catalogs);
    171163
    172     // find the max value of catID and realloc to match that (check measure & average or
    173     // just average?)
    174     int catIDmax = 0;
    175     int j;
    176     for (j = 0; j < bcatalog->Naverage; j++) {
    177       catIDmax = MAX(catIDmax, bcatalog->average[j].catID);
    178     }
    179     // XXX validate the measure ID range here
    180    
    181     int NCATALOG_OLD = NCATALOG;
    182     NCATALOG = MAX (NCATALOG, catIDmax);
    183     REALLOCATE (catalog, Catalog, NCATALOG);
    184    
    185     REALLOCATE (NAVERAGE, int, NCATALOG);
    186     REALLOCATE (NMEASURE, int, NCATALOG);
    187     for (j = NCATALOG_OLD; j < NCATALOG; j++) {
    188       NAVERAGE[j] = 100;
    189       NMEASURE[j] = 100;
    190       catalog[j].Naverage = 0;
    191       catalog[j].Nmeasure = 0;
    192       ALLOCATE (catalog[j].averageT, AverageTiny, NAVERAGE[j]);
    193       ALLOCATE (catalog[j].measureT, MeasureTiny, NMEASURE[j]);
    194       ALLOCATE (catalog[j].secfilt, SecFilt, Nsecfilt*NAVERAGE[j]);
    195     }
    196 
    197     // each bcatalog (from each host) has a different set of catID ranges
    198     // they also (probably) have contiguous ranges.  But, it is a bit tricky to be sure I
    199     // can use that info, so perhaps ignore it
    200 
    201     // assign the averages to the corresponding catalog
    202     for (j = 0; j < bcatalog->Naverage; j++) {
    203       int Nc = bcatalog->average[j].catID;
    204       assert (Nc < NCATALOG);
    205       int Na = catalog[Nc].Naverage;
    206       catalog[Nc].averageT[Na] = bcatalog->average[j];
    207 
    208       // secfilt entries are grouped in blocks for each average
    209       int k;
    210       for (k = 0; k < Nsecfilt; k++) {
    211         catalog[Nc].secfilt[Na*Nsecfilt + k] = bcatalog->secfilt[j*Nsecfilt + k];
    212       }     
    213 
    214       catalog[Nc].Naverage ++;
    215       if (catalog[Nc].Naverage >= NAVERAGE[Nc]) {
    216         NAVERAGE[Nc] += 100;
    217         REALLOCATE (catalog[Nc].averageT, AverageTiny, NAVERAGE[Nc]);
    218         REALLOCATE (catalog[Nc].secfilt, SecFilt, Nsecfilt*NAVERAGE[Nc]);
    219       }       
    220     }
    221 
    222     // assign the measures to the corresponding catalog
    223     // XXX what about averef and related links?  Do I need them?
    224     for (j = 0; j < bcatalog->Nmeasure; j++) {
    225       int Nc = bcatalog->measure[j].catID;
    226       assert (Nc < NCATALOG);
    227       int Na = catalog[Nc].Nmeasure;
    228       catalog[Nc].measureT[Na] = bcatalog->measure[j];
    229       catalog[Nc].Nmeasure ++;
    230       if (catalog[Nc].Nmeasure >= NMEASURE[Nc]) {
    231         NMEASURE[Nc] += 100;
    232         REALLOCATE (catalog[Nc].measureT, MeasureTiny, NMEASURE[Nc]);
    233       }       
    234     }
    235     // XXX free the input bcatalog entries
    236   }
    237   *Ncatalog = NCATALOG;
    238164  return (catalog);
    239165}     
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/load_images.c

    r32346 r33274  
    99// This function generates a subset of the images based on selections.  Input db has already
    1010// been loaded with the raw fits table data
    11 SkyList *load_images (FITS_DB *db, char *regionName, SkyRegion *region, int RegionSelect) {
     11SkyList *load_images (FITS_DB *db, char *regionName, SkyRegion *region) {
    1212
    1313  Image     *image, *subset;
     
    3535
    3636  // determine the populated SkyRegions overlapping the requested area
    37   if (RegionSelect) {
     37
     38  // if the user selects a specific catalog, do that one;
     39  // otherwise limit to the selection region
     40  if (regionName) {
     41    Nchar = strlen(regionName);
     42    if (!strcmp (&regionName[Nchar-4], ".cpt")) regionName[Nchar-4] = 0;
     43    skylist = SkyListByName (sky, regionName);
     44
     45    // select the images which overlap the selected sky regions
     46    // 'subset' points to a new copy of the data (different from 'image')
     47    subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset);
     48    MARKTIME("selected %d overlapping images: %f sec\n", (int) Nsubset, dtime);
     49  } else {
    3850    if (region[0].Rmin > region[0].Rmax) {
    3951      SkyRegion subregion;
     
    7486      MARKTIME("selected %d overlapping images: %f sec\n", (int) Nsubset, dtime);
    7587    }
    76   } else {
    77     Nchar = strlen(regionName);
    78     if (!strcmp (&regionName[Nchar-4], ".cpt")) regionName[Nchar-4] = 0;
    79     skylist = SkyListByName (sky, regionName);
    80 
    81     // select the images which overlap the selected sky regions
    82     // 'subset' points to a new copy of the data (different from 'image')
    83     subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset);
    84     MARKTIME("selected %d overlapping images: %f sec\n", (int) Nsubset, dtime);
    85   }
     88  }
    8689
    8790  // save the subset of images in the static reference in ImageOps, set up indexes
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/reload_catalogs.c

    r33254 r33274  
    2828
    2929  // XXX need to decide how to determine PARALLEL mode...
    30 # define PARALLEL 1
    3130  if (PARALLEL & !hostID) {
    3231    reload_catalogs_parallel (skylist);
     
    140139    fprintf (stderr, "command: %s\n", command);
    141140
    142     // launch the job on the remote machine (no handshake)
    143     int errorInfo = 0;
    144     int pid = rconnect ("ssh", table->hosts[i].hostname, command, table->hosts[i].stdio, &errorInfo, FALSE);
    145     if (!pid) {
    146       if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", table->hosts[i].hostname, errorInfo);
    147       exit (1);
     141    if (!PARALLEL_MANUAL) {
     142      // launch the job on the remote machine (no handshake)
     143      int errorInfo = 0;
     144      int pid = rconnect ("ssh", table->hosts[i].hostname, command, table->hosts[i].stdio, &errorInfo, FALSE);
     145      if (!pid) {
     146        if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", table->hosts[i].hostname, errorInfo);
     147        exit (1);
     148      }
     149      table->hosts[i].pid = pid; // save for future reference
     150      // check that all hosts started OK?
    148151    }
    149     table->hosts[i].pid = pid; // save for future reference
    150 
    151     // check that all hosts started OK?
    152152  }
    153153
    154   // watch for stdout / stderr from those jobs...
    155   // wait for all of them to complete...
     154  if (PARALLEL_MANUAL) {
     155    fprintf (stderr, "run the relphot_client commands above.  when these are done, hit return\n");
     156    getchar();
     157  } else {
     158    // watch for stdout / stderr from those jobs...
     159    // wait for all of them to complete...
     160  }
    156161
    157162  return (TRUE);
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/relphot.c

    r33270 r33274  
    5454  MARKTIME("-- load image data: %f sec\n", dtime);
    5555
    56   /* load regions and images based on specified sky patch */
    57   // XXX need to mimic old-style load by passing patch name
    58   // XXX need to reduce number of global variables in use.
    59   // XXX this is fairly lame: argv[1] is photcode if UserPatchSelect is true
    60   // XXX clean this up: deprecate region-name here (can be optional if desired)
    61   skylist = load_images (&db, argv[1], &UserPatch, UserPatchSelect);
     56  /* load regions and images based on specified sky patch and/or catalog */
     57  skylist = load_images (&db, UserCatalog, &UserPatch);
    6258  MARKTIME("-- load images: %f sec\n", dtime);
    6359
Note: See TracChangeset for help on using the changeset viewer.