Changeset 33274
- Timestamp:
- Feb 15, 2012, 2:30:58 PM (14 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src/relphot
- Files:
-
- 10 edited
-
include/relphot.h (modified) (7 diffs)
-
src/BrightCatalog.c (modified) (5 diffs)
-
src/args.c (modified) (8 diffs)
-
src/bcatalog.c (modified) (1 diff)
-
src/help.c (modified) (2 diffs)
-
src/initialize.c (modified) (3 diffs)
-
src/load_catalogs.c (modified) (3 diffs)
-
src/load_images.c (modified) (3 diffs)
-
src/reload_catalogs.c (modified) (2 diffs)
-
src/relphot.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/relphot/include/relphot.h
r33254 r33274 41 41 42 42 typedef struct { 43 AverageTiny *average;44 MeasureTiny *measure;45 SecFilt *secfilt;46 off_tNaverage;47 off_tNmeasure;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; 48 48 } BrightCatalog; 49 49 … … 57 57 unsigned char trate; 58 58 } ImageSubset; 59 60 typedef 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; 59 71 60 72 /* global variables set in parameter file */ … … 85 97 double IMFIT_SYS_SIGMA_LIM; 86 98 double CLOUD_TOLERANCE; 99 100 int PARALLEL; 101 int PARALLEL_MANUAL; 87 102 88 103 int VERBOSE; … … 144 159 145 160 SkyRegion UserPatch; 146 int UserPatchSelect;161 char *UserCatalog; 147 162 148 163 int USE_BASIC_CHECK; … … 214 229 Catalog *load_catalogs_parallel PROTO((SkyList *sky, int *Ncatalog)); 215 230 216 SkyList *load_images PROTO((FITS_DB *db, char *regionName, SkyRegion *region , int RegionSelect));231 SkyList *load_images PROTO((FITS_DB *db, char *regionName, SkyRegion *region)); 217 232 Image *select_images PROTO((SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage)); 218 233 … … 285 300 int BrightCatalogSave(char *filename, BrightCatalog *catalog); 286 301 BrightCatalog *BrightCatalogMerge (Catalog *catalog, int Ncatalog); 302 CatalogSplitter *BrightCatalogSplitInit (int Nsecfilt); 303 int BrightCatalogSplitFree (CatalogSplitter *catalogs); 304 int BrightCatalogSplit (CatalogSplitter *catalogs, BrightCatalog *bcatalog); 287 305 288 306 int ImageSubsetSave(char *filename, ImageSubset *image, off_t Nimage); … … 291 309 int CopyAverageTiny (AverageTiny *averageT, Average *average); 292 310 int CopyMeasureTiny (MeasureTiny *measureT, Measure *measure); 311 -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/BrightCatalog.c
r33270 r33274 241 241 gfits_create_table_header (&theader, "BINTABLE", "MEASURE_TINY"); 242 242 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); 258 258 259 259 // generate the output array that carries the data … … 340 340 gfits_create_table_header (&theader, "BINTABLE", "AVERAGE_TINY"); 341 341 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); 348 348 349 349 // generate the output array that carries the data … … 396 396 gfits_define_bintable_column (&theader, "E", "MAG", "ra offset", "arcsec", 1.0, 0.0); 397 397 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); 402 402 gfits_define_bintable_column (&theader, "I", "MAG_20", "ccd x coord", "pix", 1.0, 0.0); 403 403 gfits_define_bintable_column (&theader, "I", "MAG_80", "ccd y coord", "pix", 1.0, 0.0); … … 460 460 } 461 461 462 // merge a list of catalogs into a single BrightCatalog array set 462 463 BrightCatalog *BrightCatalogMerge (Catalog *catalog, int Ncatalog) { 463 464 … … 507 508 return bcatalog; 508 509 } 510 511 // distribute a bright catalog across separate catalogs 512 CatalogSplitter *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 550 int 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 569 int 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 38 38 UserPatch.Dmin = -90; 39 39 UserPatch.Dmax = +90; 40 UserPatchSelect = FALSE;41 40 if ((N = get_argument (argc, argv, "-region"))) { 42 41 remove_argument (N, &argc, argv); … … 49 48 UserPatch.Dmax = atof (argv[N]); 50 49 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); 52 58 } 53 59 … … 65 71 if ((N = get_argument (argc, argv, "-vv"))) { 66 72 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; 67 89 remove_argument (N, &argc, argv); 68 90 } … … 260 282 261 283 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 (); 264 285 265 286 return TRUE; … … 269 290 270 291 int N; 292 293 // by definition, the client is not parallel 294 PARALLEL = FALSE; 271 295 272 296 if ((N = get_argument (argc, argv, "-v"))) { … … 325 349 UserPatch.Dmin = -90; 326 350 UserPatch.Dmax = +90; 327 UserPatchSelect = FALSE;328 351 if ((N = get_argument (argc, argv, "-region"))) { 329 352 remove_argument (N, &argc, argv); … … 336 359 UserPatch.Dmax = atof (argv[N]); 337 360 remove_argument (N, &argc, argv); 338 UserPatchSelect = TRUE;339 361 } 340 362 … … 343 365 return TRUE; 344 366 } 367 -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/bcatalog.c
r31668 r33274 57 57 58 58 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; 59 63 60 64 /* exclude stars not in range or with too few measurements */ -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/help.c
r33270 r33274 2 2 3 3 void 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"); 6 6 fprintf (stderr, " or: relphot -averages -region RA RA DEC DEC\n"); 7 7 fprintf (stderr, " use -h for more usage information\n"); … … 18 18 19 19 show_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"); 22 22 fprintf (stderr, " or: relphot -averages -region RA RA DEC DEC\n"); 23 23 fprintf (stderr, " options: \n"); -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/initialize.c
r33270 r33274 1 1 # include "relphot.h" 2 2 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 } 3 void ParsePhotcodeList (char *word); 31 4 32 5 void initialize (int argc, char **argv) { 33 34 int N;35 6 36 7 relphot_help (argc, argv); … … 39 10 40 11 if (!UpdateAverages) { 41 42 N = UserPatchSelect ? 1 : 2;43 44 # if (0)45 // XXX DEP46 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 processed55 PhotSec = GetPhotcodeNsec (photcode[0].code);56 # endif57 58 12 // 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]); 60 15 } 61 // XXX DEP PhotNsec = GetPhotcodeNsecfilt ();62 16 if (USE_GRID && (Nphotcodes > 1)) { 63 17 fprintf (stderr, "grid correction analysis currently can only operate on a single photcode\n"); … … 111 65 ParsePhotcodeList (argv[1]); 112 66 } 67 68 void 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 16 16 17 17 // XXX need to decide how to determine PARALLEL mode... 18 # define PARALLEL 119 18 if (PARALLEL & !hostID) { 20 19 catalog = load_catalogs_parallel (skylist, Ncatalog); … … 114 113 fprintf (stderr, "command: %s\n", command); 115 114 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? 122 125 } 123 table->hosts[i].pid = pid; // save for future reference124 125 // check that all hosts started OK?126 126 } 127 127 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 } 130 135 131 // each host generates a BrightCatalog structure, with the measure, average, etc value loaded into a single132 // set of arrays (of MeasureTiny, AverageTiny, Secfilt). I need to split out the133 // 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. 134 139 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); 154 142 155 143 for (i = 0; i < table->Nhosts; i++) { … … 162 150 assert (bcatalog); 163 151 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); 166 153 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 } 169 159 170 // XXX put the code below into a function equivalent to BrightCatalogMerge? 160 Catalog *catalog = catalogs->catalog; 161 *Ncatalog = catalogs->Ncatalog; 162 BrightCatalogSplitFree (catalogs); 171 163 172 // find the max value of catID and realloc to match that (check measure & average or173 // 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 here180 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 ranges198 // they also (probably) have contiguous ranges. But, it is a bit tricky to be sure I199 // can use that info, so perhaps ignore it200 201 // assign the averages to the corresponding catalog202 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 average209 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 catalog223 // 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 entries236 }237 *Ncatalog = NCATALOG;238 164 return (catalog); 239 165 } -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/load_images.c
r32346 r33274 9 9 // This function generates a subset of the images based on selections. Input db has already 10 10 // been loaded with the raw fits table data 11 SkyList *load_images (FITS_DB *db, char *regionName, SkyRegion *region , int RegionSelect) {11 SkyList *load_images (FITS_DB *db, char *regionName, SkyRegion *region) { 12 12 13 13 Image *image, *subset; … … 35 35 36 36 // 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 (®ionName[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 { 38 50 if (region[0].Rmin > region[0].Rmax) { 39 51 SkyRegion subregion; … … 74 86 MARKTIME("selected %d overlapping images: %f sec\n", (int) Nsubset, dtime); 75 87 } 76 } else { 77 Nchar = strlen(regionName); 78 if (!strcmp (®ionName[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 } 86 89 87 90 // 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 28 28 29 29 // XXX need to decide how to determine PARALLEL mode... 30 # define PARALLEL 131 30 if (PARALLEL & !hostID) { 32 31 reload_catalogs_parallel (skylist); … … 140 139 fprintf (stderr, "command: %s\n", command); 141 140 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? 148 151 } 149 table->hosts[i].pid = pid; // save for future reference150 151 // check that all hosts started OK?152 152 } 153 153 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 } 156 161 157 162 return (TRUE); -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/relphot.c
r33270 r33274 54 54 MARKTIME("-- load image data: %f sec\n", dtime); 55 55 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); 62 58 MARKTIME("-- load images: %f sec\n", dtime); 63 59
Note:
See TracChangeset
for help on using the changeset viewer.
