Changeset 36630 for trunk/Ohana/src/relphot
- Timestamp:
- Apr 1, 2014, 12:03:17 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
- 11 copied
-
. (modified) (1 prop)
-
Ohana/src/relphot/Makefile (modified) (1 diff)
-
Ohana/src/relphot/doc/parallel.txt (modified) (1 diff)
-
Ohana/src/relphot/include/relphot.h (modified) (8 diffs)
-
Ohana/src/relphot/src/BrightCatalog.c (modified) (9 diffs)
-
Ohana/src/relphot/src/ImageMagIO.c (copied) (copied from branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/ImageMagIO.c )
-
Ohana/src/relphot/src/ImageOps.c (modified) (3 diffs)
-
Ohana/src/relphot/src/ImageTable.c (copied) (copied from branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/ImageTable.c )
-
Ohana/src/relphot/src/MeanMagIO.c (copied) (copied from branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/MeanMagIO.c )
-
Ohana/src/relphot/src/MosaicOps.c (modified) (4 diffs)
-
Ohana/src/relphot/src/StarOps.c (modified) (1 diff)
-
Ohana/src/relphot/src/args.c (modified) (4 diffs)
-
Ohana/src/relphot/src/assign_images.c (copied) (copied from branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/assign_images.c )
-
Ohana/src/relphot/src/client_logger.c (modified) (2 diffs)
-
Ohana/src/relphot/src/help.c (modified) (2 diffs)
-
Ohana/src/relphot/src/indexCatalog.c (copied) (copied from branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/indexCatalog.c )
-
Ohana/src/relphot/src/initialize.c (modified) (2 diffs)
-
Ohana/src/relphot/src/launch_region_hosts.c (copied) (copied from branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/launch_region_hosts.c )
-
Ohana/src/relphot/src/load_catalogs.c (modified) (3 diffs)
-
Ohana/src/relphot/src/reload_catalogs.c (modified) (1 diff)
-
Ohana/src/relphot/src/relphot.c (modified) (1 diff)
-
Ohana/src/relphot/src/relphot_client.c (modified) (1 diff)
-
Ohana/src/relphot/src/relphot_images.c (modified) (1 diff)
-
Ohana/src/relphot/src/relphot_parallel_images.c (copied) (copied from branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_images.c )
-
Ohana/src/relphot/src/relphot_parallel_regions.c (copied) (copied from branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_regions.c )
-
Ohana/src/relphot/src/setMrelCatalog.c (modified) (3 diffs)
-
Ohana/src/relphot/src/share_image_mags.c (copied) (copied from branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/share_image_mags.c )
-
Ohana/src/relphot/src/share_mean_mags.c (copied) (copied from branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/share_mean_mags.c )
-
Ohana/src/relphot/src/syncfile.c (copied) (copied from branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/syncfile.c )
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
trunk/Ohana/src/relphot/Makefile
r35416 r36630 47 47 $(SRC)/relphot_images.$(ARCH).o \ 48 48 $(SRC)/relphot_objects.$(ARCH).o \ 49 $(SRC)/relphot_parallel_regions.$(ARCH).o \ 50 $(SRC)/relphot_parallel_images.$(ARCH).o \ 49 51 $(SRC)/select_images.$(ARCH).o \ 52 $(SRC)/assign_images.$(ARCH).o \ 53 $(SRC)/launch_region_hosts.$(ARCH).o \ 54 $(SRC)/ImageTable.$(ARCH).o \ 55 $(SRC)/ImageMagIO.$(ARCH).o \ 56 $(SRC)/syncfile.$(ARCH).o \ 57 $(SRC)/share_image_mags.$(ARCH).o \ 58 $(SRC)/share_mean_mags.$(ARCH).o \ 59 $(SRC)/MeanMagIO.$(ARCH).o \ 60 $(SRC)/indexCatalog.$(ARCH).o \ 50 61 $(SRC)/client_logger.$(ARCH).o \ 51 62 $(SRC)/setExclusions.$(ARCH).o \ -
trunk/Ohana/src/relphot/doc/parallel.txt
r33651 r36630 1 2 2014.02.15 3 4 Nearly done with the relphot mods. some outstanding questions; 5 6 * image vs mosaic? 7 * how do decide which images need to be shared? 8 9 2014.02.14 10 11 more relphot notes: 12 13 * I load the catalogs, with a 14 15 2014.02.12 16 17 I am making progess on the relphot -parallel-regions implementation. some things I need to deal with: 18 19 * assign_images: select mosaics for all images saved for a given host (need to supply them as well) 20 ** I need to decide on the Image / Mosaic split. If I am calibrating by image, then the image center defines ownership 21 ** if I am calibrating by exposure, then the mosaic center must define ownership 22 o determine SkyList covering the images for region host 23 o tag detections and objects which I own or do not own 24 o ImageOps.c / matchImage matches detections to images and needs to handle mine / not mine cases 25 o ditto for matchMosaics 26 o load_catalogs : I need to make my requested catalogs unique (just add uniquer to load_catalogs.c:130 27 o figure out what fields I'm saving in meanmags and how to construct it 28 -- mag, objID, catID, photcode, (dmag or other stats?) 29 * from which hosts do I slurp mean mags? 30 o function to merge a new meanmag array into the existing one 31 o how to go from (objID,catID) to a given catalog[i].average[j] 32 33 2014.02.06 34 35 ** a single region-level host owns images for which the center lands 36 in its region. 37 38 ** it owns detections which come from images which it owns 39 40 ** it owns objects which land in its region 41 42 Extending parallel relphot processing to split the sky (and images) 43 into regions, each of which runs in parallel at the same time: 44 45 Top Level (relphot -parallel-images): 46 * define regions of the sky -> hosts 47 * load images, assign to hosts 48 * launch region-level jobs on remote hosts 49 50 Region Level (relphot -parallel-images-region) 51 * load my image subset table 52 * request objects and detections for my skyregion 53 * match images & objects, etc 54 55 * update my image parameters 56 * update my detections 57 * write out detections 58 * load detections from my border hosts 59 * match to my objects 60 * update my objects 61 * write out objects 62 * load objects from my border hosts 63 * update images 64 (iterate N times) 65 * write out image parameters 66 67 Top Level 68 * read image parameters, update 69 * update objects 1 70 2 71 2012.02.13 -
trunk/Ohana/src/relphot/include/relphot.h
r36528 r36630 23 23 // # define IDX_T off_t 24 24 # define IDX_T int 25 26 typedef enum { 27 MODE_ERROR = 0, 28 UPDATE_IMAGES, 29 UPDATE_AVERAGES, 30 PARALLEL_REGIONS, 31 PARALLEL_IMAGES, 32 APPLY_OFFSETS, 33 } RelphotMode; 25 34 26 35 typedef enum { … … 108 117 109 118 typedef struct { 119 float M; 120 float dM; 121 float Xm; 122 int Nsec; 123 unsigned int objID; 124 unsigned int catID; 125 int photcode; 126 } MeanMag; 127 128 typedef struct { 129 float Mcal; 130 float dMcal; 131 float dMagSys; 132 float Xm; 133 int nFitPhotom; 134 int flags; 135 unsigned int imageID; 136 short ubercalDist; 137 } ImageMag; 138 139 typedef struct { 110 140 AverageTiny *average; // array of (minimal) average data 111 141 MeasureTiny *measure; // array of (minimal) measure data … … 155 185 int SKY_DEPTH; /** XXX EAM : depth of catalog tables, fix usage */ 156 186 187 // globals for parallel region operations 188 char *REGION_FILE; 189 char *IMAGE_TABLE; 190 int REGION_HOST_ID; 191 157 192 int HOST_ID; 158 193 char *HOSTDIR; … … 179 214 int PARALLEL_MANUAL; 180 215 int PARALLEL_SERIAL; 216 217 int PARALLEL_REGIONS_MANUAL; 181 218 182 219 int NTHREADS; … … 266 303 void InterpolateGrid PROTO((float *buffer, int Nx, int Ny, Coords *ccd, Coords *gcoords)); 267 304 off_t *SelectRefMosaic PROTO((Mosaic **refmosaic, off_t *Nimage)); 268 intargs PROTO((int argc, char **argv));305 RelphotMode args PROTO((int argc, char **argv)); 269 306 int args_client PROTO((int argc, char **argv)); 270 307 int bcatalog PROTO((Catalog *subcatalog, Catalog *catalog, int Ncat)); … … 279 316 void findImages PROTO((Catalog *catalog, int Ncatalog, int doImageList)); 280 317 int findMosaics PROTO((Catalog *catalog, int Ncatalog, int doMosaicList)); 318 319 void makeMosaics (Image *image, off_t Nimage); 320 Mosaic *getMosaicForImage (off_t im); 321 void setMosaicCenters (Image *image, off_t Nimage); 281 322 282 323 void set_db (FITS_DB *in); … … 315 356 void initMosaics PROTO((Image *subset, off_t Nsubset, Image *image, char *inSubset, off_t Nimage)); 316 357 void initMrel PROTO((Catalog *catalog, int Ncatalog)); 317 voidinitialize PROTO((int argc, char **argv));358 RelphotMode initialize PROTO((int argc, char **argv)); 318 359 void initialize_client PROTO((int argc, char **argv)); 319 360 void liststats_setmode PROTO((StatType *stats, char *strmode)); … … 426 467 int init_synthetic_mags (); 427 468 int add_synthetic_mags (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, off_t *Nmeasure, off_t *Nm); 469 470 int relphot_parallel_regions (); 471 472 int assign_images (FITS_DB *db, RegionHostTable *regionHosts); 473 int select_images_hostregion (RegionHostTable *hosts, Image *image, off_t Nimage); 474 int find_host_for_coords (RegionHostTable *regionHosts, double R, double d); 475 int calculate_image_bounds (Image *image, double *rmin, double *rmax, double *dmin, double *dmax, double Rmid); 476 477 int launch_region_hosts (RegionHostTable *regionHosts); 478 int strextend (char *input, char *format,...); 479 480 Image *ImageTableLoad(char *filename, off_t *nimage); 481 int ImageTableSave (char *filename, Image *images, off_t Nimages); 482 483 int indexCatalogs (Catalog *catalog, int Ncatalog); 484 int catID_and_objID_to_seq (int catID, int objID, int *catSeq, off_t *objSeq); 485 486 int check_sync_file (char *filename, int nloop); 487 int clear_sync_file (char *filename); 488 int update_sync_file (char *filename, int nloop); 489 char *make_filename (char *dirname, char *hostname, int hostID, char *tailname); 490 491 int share_mean_mags (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 492 int slurp_mean_mags (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 493 int set_mean_mags (MeanMag *meanmags, AverageTiny *average, SecFilt *secfilt, int Nsec); 494 MeanMag *merge_mean_mags (MeanMag *target, int *ntarget, MeanMag *source, int Nsource); 495 496 MeanMag *MeanMagLoad(char *filename, off_t *nmeanmags); 497 int MeanMagSave(char *filename, MeanMag *meanmags, off_t Nmeanmags); 498 499 int share_image_mags (RegionHostTable *regionHosts, int nloop); 500 int slurp_image_mags (RegionHostTable *regionHosts, int nloop); 501 int set_image_mags (ImageMag *image_mags, Image *image); 502 ImageMag *merge_image_mags (ImageMag *target, int *ntarget, ImageMag *source, int Nsource); 503 504 ImageMag *ImageMagLoad(char *filename, off_t *nimage_mags); 505 int ImageMagSave(char *filename, ImageMag *image_mags, off_t Nimage_mags); 506 507 int markObjects (Catalog *catalog, int Ncatalog); 508 509 int relphot_parallel_images (); 510 int relphot_parallel_regions (); -
trunk/Ohana/src/relphot/src/BrightCatalog.c
r33651 r36630 101 101 measure[i].catID = catID[i]; 102 102 measure[i].photcode = photcode[i]; 103 measure[i].myDet = FALSE; 103 104 } 104 105 fprintf (stderr, "loaded data for %lld measure\n", (long long) Nrow); … … 141 142 GET_COLUMN(flags, "FLAGS", int); 142 143 GET_COLUMN(catID, "CAT_ID", int); 144 GET_COLUMN(objID, "OBJ_ID", int); 143 145 gfits_free_header (&theader); 144 146 gfits_free_table (&ftable); … … 153 155 average[i].flags = flags[i]; 154 156 average[i].catID = catID[i]; 157 average[i].objID = objID[i]; 158 average[i].nOwn = 0; 155 159 } 156 160 fprintf (stderr, "loaded data for %lld average\n", (long long) Nrow); … … 162 166 free (flags ); 163 167 free (catID ); 168 free (objID ); 164 169 165 170 catalog->average = average; … … 370 375 gfits_define_bintable_column (&theader, "J", "FLAGS", "flags", NULL, 1.0, 0.0); 371 376 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog ref", NULL, 1.0, 0.0); 377 gfits_define_bintable_column (&theader, "J", "OBJ_ID", "object ref", NULL, 1.0, 0.0); 372 378 373 379 // generate the output array that carries the data … … 381 387 int *flags ; ALLOCATE (flags, int, catalog->Naverage); 382 388 int *catID ; ALLOCATE (catID, int, catalog->Naverage); 389 int *objID ; ALLOCATE (objID, int, catalog->Naverage); 383 390 384 391 // assign the storage arrays … … 391 398 flags[i] = average[i].flags; 392 399 catID[i] = average[i].catID; 400 objID[i] = average[i].objID; 393 401 } 394 402 … … 400 408 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags, catalog->Naverage); 401 409 gfits_set_bintable_column (&theader, &ftable, "CAT_ID", catID, catalog->Naverage); 410 gfits_set_bintable_column (&theader, &ftable, "OBJ_ID", objID, catalog->Naverage); 402 411 403 412 free (R ); … … 407 416 free (flags ); 408 417 free (catID ); 418 free (objID ); 409 419 410 420 gfits_fwrite_Theader (f, &theader); -
trunk/Ohana/src/relphot/src/ImageOps.c
r36491 r36630 244 244 245 245 int Nmatch = 0; 246 for (i = 0; i < Ncatalog; i++) {246 for (i = 0; i < Ncatalog; i++) { 247 247 for (j = 0; j < catalog[i].Nmeasure; j++) { 248 catalog[i].measureT[j].myDet = FALSE; // a detetion is not mine until proven otherwise 248 249 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[j].photcode); 250 251 // skip measurements which do not match one of the requested photcodes ( 252 // (do we not already exclude in bcatalog -- maybe needed for reload_objects? 249 253 found = FALSE; 250 254 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { … … 252 256 } 253 257 if (!found) continue; 258 259 // if we match one of our images, myDet gets set to TRUE 254 260 matchImage (catalog, j, i, doImageList); 255 261 Nmatch ++; … … 322 328 return; 323 329 } 330 catalog[cat].measureT[meas].myDet = TRUE; 324 331 325 332 if (USE_GRID) { -
trunk/Ohana/src/relphot/src/MosaicOps.c
r36491 r36630 320 320 } 321 321 322 /* find mosaic frames (unique time periods) (NOTE : we do NOT require matching photcodes but we 323 match images by MOSAICNAME. this last point is weak: it forces a single camera at a time. 324 we can extend the logic to multiple cameras if we make list of MOSAICNAMES (better to assign a camera ID) 325 */ 326 void makeMosaics (Image *image, off_t Nimage) { 327 328 off_t i, j, status, found, NMOSAIC, *MosaicN_IMAGE; 329 unsigned int start, stop, *startTimes, *startTimesMosaic; 330 char *pname; 331 332 if (!MOSAIC_ZEROPT) return; 333 334 INITTIME; 335 336 /* a 'mosaic' in relphot is (unlike relastro) a virtual concept: there is no 337 * entry in the image table that represents this mosaic. Instead, it is an 338 * internal construct that defines a group of related images 339 */ 340 341 // generate a list of all image start times 342 ALLOCATE (startTimes, unsigned int, Nimage); 343 for (i = 0; i < Nimage; i++) { 344 startTimes[i] = image[i].tzero; 345 } 346 sort_times (startTimes, Nimage); 347 MARKTIME("create array of all image obstimes: %f sec\n", dtime); 348 349 Nmosaic = 0; 350 NMOSAIC = 1000; 351 ALLOCATE (startTimesMosaic, unsigned int, NMOSAIC); 352 startTimesMosaic[0] = startTimes[0]; 353 354 // generate a list of the unique start times (these define the mosaics) 355 for (i = 0; i < Nimage; i++) { 356 if (startTimes[i] < startTimesMosaic[Nmosaic]) { 357 fprintf (stderr, "error?\n"); 358 abort(); 359 } 360 if (startTimes[i] == startTimesMosaic[Nmosaic]) continue; 361 Nmosaic ++; 362 if (Nmosaic >= NMOSAIC) { 363 NMOSAIC += 1000; 364 REALLOCATE (startTimesMosaic, unsigned int, NMOSAIC); 365 } 366 startTimesMosaic[Nmosaic] = startTimes[i]; 367 } 368 Nmosaic ++; 369 MARKTIME("create array of mosaic obstimes: %f sec\n", dtime); 370 371 // now I have a list of uniq start times, and they are in order 372 // create the mosaic arrays for these times 373 ALLOCATE (mosaic, Mosaic, Nmosaic); 374 375 ALLOCATE (MosaicToImage, off_t *, Nmosaic); 376 ALLOCATE (MosaicN_Image, off_t, Nmosaic); 377 ALLOCATE (MosaicN_IMAGE, off_t, Nmosaic); 378 379 // init the mosaic array values 380 for (i = 0; i < Nmosaic; i++) { 381 mosaic[i].start = startTimesMosaic[i]; 382 mosaic[i].stop = 0; 383 mosaic[i].Mcal = 0.0; 384 mosaic[i].dMcal = 0.0; 385 mosaic[i].dMsys = 0.0; 386 mosaic[i].Xm = 0.0; 387 mosaic[i].flags = 0; 388 mosaic[i].secz = NAN; 389 mosaic[i].photcode = 0; 390 mosaic[i].skipCal = FALSE; 391 392 memset (&mosaic[i].coords, 0, sizeof(Coords)); 393 394 MosaicN_IMAGE[i] = 10; 395 MosaicN_Image[i] = 0; 396 ALLOCATE (MosaicToImage[i], off_t, MosaicN_IMAGE[i]); 397 MosaicToImage[i][0] = -1; 398 } 399 400 ALLOCATE (ImageToMosaic, off_t, Nimage); // mosaic to which image belongs 401 402 // assign each image to a mosaic 403 for (i = 0; i < Nimage; i++) { 404 ImageToMosaic[i] = -1; 405 406 /* select valid mosaic images by photcode */ 407 pname = GetPhotcodeNamebyCode (image[i].photcode); 408 if (!pname) continue; 409 410 status = strncmp (pname, MOSAICNAME, strlen (MOSAICNAME)); 411 if (status) continue; 412 413 start = image[i].tzero; 414 stop = image[i].tzero + MAX(1.01*image[i].trate*image[i].NY, 1); 415 416 j = findMosaic(startTimesMosaic, Nmosaic, start); 417 if (j == -1) { 418 fprintf (stderr, "programming error? all image images should belong to a mosaic\n"); 419 abort(); 420 } 421 422 // add reference from image to mosaic 423 ImageToMosaic[i] = j; 424 425 // have we already found this mosaic? 426 found = (MosaicN_Image[j] > 0); 427 428 /* add image to mosaic image list */ 429 MosaicToImage[j][MosaicN_Image[j]] = i; 430 MosaicN_Image[j] ++; 431 if (MosaicN_Image[j] == MosaicN_IMAGE[j]) { 432 MosaicN_IMAGE[j] += 10; 433 REALLOCATE (MosaicToImage[j], off_t, MosaicN_IMAGE[j]); 434 } 435 if (found) continue; 436 437 /* a new mosaic, define ranges */ 438 if (mosaic[j].start != start) { 439 fprintf (stderr, "error?\n"); 440 abort(); 441 } 442 mosaic[j].stop = stop; 443 mosaic[j].Mcal = 0.0; 444 mosaic[j].dMcal = 0.0; 445 mosaic[j].Xm = 0.0; 446 mosaic[j].dMsys = image[i].flags; 447 mosaic[j].flags = image[i].flags; 448 mosaic[j].secz = image[i].secz; 449 mosaic[j].photcode = GetPhotcodeEquivCodebyCode (image[i].photcode); 450 } 451 MARKTIME("assign images to mosaic: %f sec\n", dtime); 452 453 // free this or not? 454 free (MosaicN_IMAGE); 455 free (startTimes); 456 free (startTimesMosaic); 457 458 fprintf (stderr, "matched %d images to %d mosaics\n", (int) Nimage, (int) Nmosaic); 459 460 return; 461 } 462 463 Mosaic *getMosaicForImage (off_t im) { 464 465 if (im < 0) return NULL; 466 if (!ImageToMosaic) return NULL; 467 468 off_t m = ImageToMosaic[im]; 469 if (m < 0) return NULL; 470 if (m >= Nmosaic) return NULL; 471 472 return (&mosaic[m]); 473 } 474 322 475 // use bisection to find the overlapping mosaic (returns exact match) 323 476 // startTimes is a sorted, unique list of times … … 350 503 } 351 504 return (-1); 505 } 506 507 void setMosaicCenters (Image *image, off_t Nimage) { 508 509 /* find max dR, dD range for all mosaics */ 510 /* define mosaic.coords to cover dR, dD */ 511 /* send results to initGridBins */ 512 513 off_t i, j, m, NX, NY, NC, Nc; 514 double R, D, Rmid, Dmid; 515 double Mcal, dMcal, Xm; 516 double *Rc, *Dc; 517 518 NC = 100; 519 ALLOCATE (Rc, double, NC); 520 ALLOCATE (Dc, double, NC); 521 522 for (i = 0; i < Nmosaic; i++) { 523 Nc = 0; 524 Rmid = Dmid = NAN; 525 Mcal = dMcal = Xm = 0; 526 for (j = 0; j < MosaicN_Image[i]; j++) { 527 m = MosaicToImage[i][j]; 528 529 if (!FindMosaicForImage (image, Nimage, m)) { 530 if (VERBOSE2) fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i); 531 continue; 532 } 533 534 NX = image[m].NX; 535 NY = image[m].NY; 536 XY_to_RD (&R, &D, 0.5*NX, 0.5*NY, &image[m].coords); 537 R = ohana_normalize_angle_to_midpoint (R, 180.0); 538 539 // Exclude images with crazy astrometry 540 // XXX NOTE : this is gpc1-specific 541 { 542 double dP1 = hypot(image[m].coords.pc1_1, image[m].coords.pc1_2); 543 double dP2 = hypot(image[m].coords.pc2_1, image[m].coords.pc2_2); 544 if (fabs(dP1 - 1.0) > 0.02) continue; 545 if (fabs(dP2 - 1.0) > 0.02) continue; 546 547 double X00, Y00, X10, Y10, X01, Y01; 548 XY_to_LM (&X00, &Y00, 0.0, 0.0, &image[m].coords); 549 XY_to_LM (&X10, &Y10, image[m].NX, 0.0, &image[m].coords); 550 XY_to_LM (&X01, &Y01, 0.0, image[m].NY, &image[m].coords); 551 double dS0 = hypot ((X00 - X10), (Y00 - Y10)); 552 double dS1 = hypot ((X00 - X01), (Y00 - Y01)); 553 if (dS0 > 6000) continue; 554 if (dS1 > 6500) continue; 555 } 556 557 Rc[Nc] = R; 558 Dc[Nc] = D; 559 Nc ++; 560 if (Nc >= NC) { 561 NC += 100; 562 REALLOCATE (Rc, double, NC); 563 REALLOCATE (Dc, double, NC); 564 } 565 566 Mcal += image[m].Mcal; 567 dMcal += image[m].dMcal; 568 Xm += image[m].Xm; 569 570 // for ubercal images, we (elsewhere) keep Mcal frozen 571 572 /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */ 573 image[m].Mcal = 0.0; 574 image[m].dMcal = NAN; 575 image[m].Xm = NAN_S_SHORT; 576 } 577 578 if (Nc > 0) { 579 dsort (Rc, Nc); 580 if (Rc[Nc-1] - Rc[0] > 180.0) { 581 // in our list, Rc is in the range 0.0 to 360.0. 582 // any mosaic which is close to the 0.0, 360.0 boundary may have some on 583 // one side or the other. count how many have values more than Rc[0] + 180. 584 // if more than half are at the large end, re-normalize to that range 585 int Nbig = 0; 586 for (j = 1; j < Nc; j++) { 587 if (Rc[j] - Rc[0] > 180.0) Nbig ++; 588 } 589 if (Nbig > 0.5*Nc) { 590 for (j = 0; j < Nc; j++) { 591 Rc[j] = ohana_normalize_angle_to_midpoint (Rc[j], 360.0); 592 } 593 dsort (Rc, Nc); 594 } else if (Nbig > 0) { 595 for (j = 0; j < Nc; j++) { 596 Rc[j] = ohana_normalize_angle_to_midpoint (Rc[j], 0.0); 597 } 598 dsort (Rc, Nc); 599 } 600 } 601 dsort (Dc, Nc); 602 603 Rmid = Rc[(int)(0.5*Nc)]; 604 Dmid = Dc[(int)(0.5*Nc)]; 605 } 606 607 strcpy (mosaic[i].coords.ctype, "DEC--TAN"); 608 mosaic[i].coords.crval1 = Rmid; 609 mosaic[i].coords.crval2 = Dmid; 610 mosaic[i].coords.crpix1 = 0.0; 611 mosaic[i].coords.crpix2 = 0.0; 612 mosaic[i].coords.cdelt1 = 1.0 / 3600.0; 613 mosaic[i].coords.cdelt2 = 1.0 / 3600.0; 614 mosaic[i].coords.pc1_1 = 1.0; 615 mosaic[i].coords.pc2_2 = 1.0; 616 mosaic[i].coords.pc1_2 = 0.0; 617 mosaic[i].coords.pc2_1 = 0.0; 618 619 mosaic[i].Mcal = Mcal / MosaicN_Image[i]; 620 mosaic[i].dMcal = dMcal / MosaicN_Image[i]; 621 mosaic[i].Xm = Xm / MosaicN_Image[i]; 622 } 623 return; 352 624 } 353 625 … … 527 799 528 800 if (!MOSAIC_ZEROPT) return (FALSE); 801 // if we are calibrating by mosaic, redefine myDet == on one of my mosaics 529 802 530 803 int Nmatch = 0; 531 804 for (i = 0; i < Ncatalog; i++) { 532 805 for (j = 0; j < catalog[i].Nmeasure; j++) { 806 catalog[i].measureT[j].myDet = FALSE; // a detetion is not mine until proven otherwise 807 533 808 if (TimeSelect) { 534 809 if (catalog[i].measureT[j].t < TSTART) continue; … … 582 857 } 583 858 859 // this measurement is on one of my mosaics, mark it as mine. 860 catalog[cat].measureT[meas].myDet = TRUE; 584 861 MeasureToMosaic[cat][meas] = mosID; 585 862 -
trunk/Ohana/src/relphot/src/StarOps.c
r36528 r36630 908 908 } 909 909 910 int markObjects (Catalog *catalog, int Ncatalog) { 911 912 int i, n; 913 off_t j; 914 915 // How strongly do I own this object? 916 for (i = 0; i < Ncatalog; i++) { 917 for (j = 0; j < catalog[i].Naverage; j++) { 918 int nOwn = 0; 919 int m = catalog[i].averageT[j].measureOffset; 920 for (n = 0; n < catalog[i].averageT[j].Nmeasure; n++) { 921 if (!catalog[i].measureT[m+n].myDet) continue; 922 nOwn ++; 923 } 924 catalog[i].averageT[j].nOwn = nOwn; 925 } 926 } 927 return TRUE; 928 } 929 930 int dumpObjects (char *filename, Catalog *catalog, int Ncatalog) { 931 932 int i, n; 933 off_t j; 934 935 FILE *ftest = fopen (filename, "w"); 936 937 for (i = 0; i < Ncatalog; i++) { 938 for (j = 0; j < catalog[i].Naverage; j++) { 939 int m = catalog[i].averageT[j].measureOffset; 940 for (n = 0; n < catalog[i].averageT[j].Nmeasure; n++) { 941 fprintf (ftest, "%08x %08x %10.6f %10.6f %3d %1d\n", catalog[i].averageT[j].catID, catalog[i].averageT[j].objID, catalog[i].averageT[j].R, catalog[i].averageT[j].D, catalog[i].averageT[j].Nmeasure, catalog[i].measureT[m+n].myDet); 942 } 943 } 944 } 945 fclose (ftest); 946 return TRUE; 947 } 948 910 949 void clean_stars (Catalog *catalog, int Ncatalog) { 911 950 -
trunk/Ohana/src/relphot/src/args.c
r36491 r36630 1 1 # include "relphot.h" 2 2 3 intargs (int argc, char **argv) {3 RelphotMode args (int argc, char **argv) { 4 4 5 5 int N; 6 6 double trange; 7 8 /* define time */ 9 TimeSelect = FALSE; 10 if ((N = get_argument (argc, argv, "-time"))) { 11 remove_argument (N, &argc, argv); 12 if (!ohana_str_to_time (argv[N], &TSTART)) { 13 fprintf (stderr, "ERROR: syntax error\n"); 14 return (MODE_ERROR); 15 } 16 remove_argument (N, &argc, argv); 17 if (!ohana_str_to_dtime (argv[N], &trange)) { 18 if (!ohana_str_to_time (argv[N], &TSTOP)) { 19 fprintf (stderr, "ERROR: syntax error\n"); 20 return (MODE_ERROR); 21 } 22 } else { 23 if (trange < 0) { 24 trange = fabs (trange); 25 TSTOP = TSTART; 26 TSTART -= trange; 27 } else { 28 TSTOP = TSTART + trange; 29 } 30 } 31 remove_argument (N, &argc, argv); 32 TimeSelect = TRUE; 33 } 34 35 /* specify portion of the sky */ 36 UserPatch.Rmin = 0; 37 UserPatch.Rmax = 360; 38 UserPatch.Dmin = -90; 39 UserPatch.Dmax = +90; 40 if ((N = get_argument (argc, argv, "-region"))) { 41 remove_argument (N, &argc, argv); 42 UserPatch.Rmin = atof (argv[N]); 43 remove_argument (N, &argc, argv); 44 UserPatch.Rmax = atof (argv[N]); 45 remove_argument (N, &argc, argv); 46 UserPatch.Dmin = atof (argv[N]); 47 remove_argument (N, &argc, argv); 48 UserPatch.Dmax = atof (argv[N]); 49 remove_argument (N, &argc, argv); 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); 58 } 59 60 USE_BASIC_CHECK = FALSE; 61 if ((N = get_argument (argc, argv, "-basic-image-search"))) { 62 remove_argument (N, &argc, argv); 63 USE_BASIC_CHECK = TRUE; 64 } 65 66 USE_FULL_OVERLAP = TRUE; 67 if ((N = get_argument (argc, argv, "-sloppy-image-overlap"))) { 68 remove_argument (N, &argc, argv); 69 USE_FULL_OVERLAP = FALSE; 70 } 71 72 SET_MREL_VERSION = 1; 73 if ((N = get_argument (argc, argv, "-set-mrel-version"))) { 74 remove_argument (N, &argc, argv); 75 SET_MREL_VERSION = atof(argv[N]); 76 remove_argument (N, &argc, argv); 77 } 78 79 VERBOSE = VERBOSE2 = FALSE; 80 if ((N = get_argument (argc, argv, "-v"))) { 81 VERBOSE = TRUE; 82 remove_argument (N, &argc, argv); 83 } 84 if ((N = get_argument (argc, argv, "-vv"))) { 85 VERBOSE2 = VERBOSE = TRUE; 86 remove_argument (N, &argc, argv); 87 } 88 89 NTHREADS = 0; 90 if ((N = get_argument (argc, argv, "-threads"))) { 91 remove_argument (N, &argc, argv); 92 NTHREADS = atof (argv[N]); 93 remove_argument (N, &argc, argv); 94 } 95 96 // XXX for the moment, make this selection manual. it needs to be automatic 97 // based on the state of the SkyTable 98 HOST_ID = 0; 99 PARALLEL = FALSE; 100 if ((N = get_argument (argc, argv, "-parallel"))) { 101 PARALLEL = TRUE; 102 remove_argument (N, &argc, argv); 103 } 104 // this is a test mode : rather than launching the remote jobs and waiting for completion, 105 // relphot will simply list the remote command and wait for the user to signal completion 106 PARALLEL_MANUAL = FALSE; 107 if ((N = get_argument (argc, argv, "-parallel-manual"))) { 108 PARALLEL = TRUE; // -parallel-manual implies -parallel 109 PARALLEL_MANUAL = TRUE; 110 remove_argument (N, &argc, argv); 111 } 112 // this is a test mode : rather than launching the relphot_client jobs remotely, they are 113 // run in serial via 'system' 114 PARALLEL_SERIAL = FALSE; 115 if ((N = get_argument (argc, argv, "-parallel-serial"))) { 116 if (PARALLEL_MANUAL) { 117 fprintf (stderr, "ERROR: cannot mix -parallel-manual and -parallel-serial\n"); 118 exit (1); 119 } 120 PARALLEL = TRUE; // -parallel-serial implies -parallel 121 PARALLEL_SERIAL = TRUE; 122 remove_argument (N, &argc, argv); 123 } 124 125 PLOTSTUFF = FALSE; 126 if ((N = get_argument (argc, argv, "-plot"))) { 127 PLOTSTUFF = TRUE; 128 remove_argument (N, &argc, argv); 129 } 130 131 PLOTDELAY = 500000; 132 if ((N = get_argument (argc, argv, "-plotdelay"))) { 133 remove_argument (N, &argc, argv); 134 PLOTDELAY = 1e6*atof(argv[N]); 135 PLOTSTUFF = TRUE; // always turn on plotting if i request a plot delay 136 remove_argument (N, &argc, argv); 137 } 138 139 if ((N = get_argument (argc, argv, "-outroot"))) { 140 remove_argument (N, &argc, argv); 141 OUTROOT = strcreate (argv[N]); 142 remove_argument (N, &argc, argv); 143 } else { 144 OUTROOT = strcreate ("relphot"); 145 } 146 147 strcpy (STATMODE, "WT_MEAN"); 148 if ((N = get_argument (argc, argv, "-statmode"))) { 149 remove_argument (N, &argc, argv); 150 strcpy (STATMODE, argv[N]); 151 remove_argument (N, &argc, argv); 152 } 153 154 NLOOP = 8; 155 if ((N = get_argument (argc, argv, "-n"))) { 156 remove_argument (N, &argc, argv); 157 NLOOP = atof (argv[N]); 158 remove_argument (N, &argc, argv); 159 } 160 if ((N = get_argument (argc, argv, "-nloop"))) { 161 remove_argument (N, &argc, argv); 162 NLOOP = atof (argv[N]); 163 remove_argument (N, &argc, argv); 164 } 165 166 NGRID = 8; 167 if ((N = get_argument (argc, argv, "-ngrid"))) { 168 remove_argument (N, &argc, argv); 169 NGRID = atof (argv[N]); 170 remove_argument (N, &argc, argv); 171 } 172 173 RESET = FALSE; 174 if ((N = get_argument (argc, argv, "-reset"))) { 175 remove_argument (N, &argc, argv); 176 RESET = TRUE; 177 } 178 179 RESET_ZEROPTS = FALSE; 180 if ((N = get_argument (argc, argv, "-reset-zpts"))) { 181 remove_argument (N, &argc, argv); 182 RESET_ZEROPTS = TRUE; 183 } 184 185 UPDATE = FALSE; 186 if ((N = get_argument (argc, argv, "-update"))) { 187 remove_argument (N, &argc, argv); 188 UPDATE = TRUE; 189 } 190 191 UPDATE_CATFORMAT = NULL; 192 if ((N = get_argument (argc, argv, "-update-catformat"))) { 193 remove_argument (N, &argc, argv); 194 UPDATE_CATFORMAT = strcreate (argv[N]); 195 remove_argument (N, &argc, argv); 196 } 197 198 SAVE_IMAGE_UPDATES = TRUE; 199 if ((N = get_argument (argc, argv, "-skip-image-updates"))) { 200 remove_argument (N, &argc, argv); 201 SAVE_IMAGE_UPDATES = FALSE; 202 } 203 204 MaxDensityUse = FALSE; 205 if ((N = get_argument (argc, argv, "-max-density"))) { 206 remove_argument (N, &argc, argv); 207 MaxDensityValue = atof(argv[N]); 208 remove_argument (N, &argc, argv); 209 MaxDensityUse = TRUE; 210 } 211 212 CLOUD_TOLERANCE = 0.02; 213 if ((N = get_argument (argc, argv, "-cloud-limit"))) { 214 remove_argument (N, &argc, argv); 215 CLOUD_TOLERANCE = atof(argv[N]); 216 remove_argument (N, &argc, argv); 217 } 218 219 // XXX should we load a tree from CATDIR by default? 220 // NOTE: a given catdir needs an appropriate boundary tree 221 BOUNDARY_TREE = NULL; 222 if ((N = get_argument (argc, argv, "-boundary-tree"))) { 223 remove_argument (N, &argc, argv); 224 BOUNDARY_TREE = strcreate(argv[N]); 225 load_tess (BOUNDARY_TREE); 226 remove_argument (N, &argc, argv); 227 } 228 229 SHOW_PARAMS = FALSE; 230 if ((N = get_argument (argc, argv, "-params"))) { 231 remove_argument (N, &argc, argv); 232 SHOW_PARAMS = TRUE; 233 } 234 235 PlotMmin = 10.0; PlotMmax = 20.0; PlotdMmin = -1.0; PlotdMmax = 1.0; 236 if ((N = get_argument (argc, argv, "-plrange"))) { 237 remove_argument (N, &argc, argv); 238 PlotMmin = atof (argv[N]); 239 remove_argument (N, &argc, argv); 240 PlotMmax = atof (argv[N]); 241 remove_argument (N, &argc, argv); 242 PlotdMmin = atof (argv[N]); 243 remove_argument (N, &argc, argv); 244 PlotdMmax = atof (argv[N]); 245 remove_argument (N, &argc, argv); 246 } 247 248 /* XXX this argument used to do two things: specify the camera name and tell the analysis to 249 calculate a common zero point for a single mosaic. I've moved the MOSAICNAME concept into the 250 config system, but need to use this argument to specify that the mosaic zeropoints should be 251 calculated. */ 252 MOSAIC_ZEROPT = FALSE; 253 if ((N = get_argument (argc, argv, "-mosaic"))) { 254 remove_argument (N, &argc, argv); 255 MOSAIC_ZEROPT = TRUE; 256 if (!strcasecmp (MOSAICNAME, "none")) { 257 fprintf (stderr, "mosaic astrometry selected by MOSAICNAME not defined\n"); 258 exit (2); 259 } 260 } 261 262 FREEZE_IMAGES = FALSE; 263 if ((N = get_argument (argc, argv, "-imfreeze"))) { 264 remove_argument (N, &argc, argv); 265 FREEZE_IMAGES = TRUE; 266 } 267 268 FREEZE_MOSAICS = FALSE; 269 if ((N = get_argument (argc, argv, "-mosfreeze"))) { 270 remove_argument (N, &argc, argv); 271 FREEZE_MOSAICS = TRUE; 272 } 273 274 // USE_GRID is not valid for all cases, probably should be its own mode... 275 USE_GRID = FALSE; 276 if ((N = get_argument (argc, argv, "-grid"))) { 277 remove_argument (N, &argc, argv); 278 USE_GRID = TRUE; 279 } 280 281 KEEP_UBERCAL = TRUE; 282 if ((N = get_argument (argc, argv, "-reset-ubercal"))) { 283 remove_argument (N, &argc, argv); 284 KEEP_UBERCAL = FALSE; 285 } 286 287 MIN_ERROR = 0.001; 288 if ((N = get_argument (argc, argv, "-minerror"))) { 289 remove_argument (N, &argc, argv); 290 MIN_ERROR = atof (argv[N]); 291 remove_argument (N, &argc, argv); 292 /* require MIN_ERROR > 0 */ 293 } 294 295 AreaSelect = FALSE; 296 if ((N = get_argument (argc, argv, "-area"))) { 297 remove_argument (N, &argc, argv); 298 AreaXmin = atof (argv[N]); 299 remove_argument (N, &argc, argv); 300 AreaXmax = atof (argv[N]); 301 remove_argument (N, &argc, argv); 302 AreaYmin = atof (argv[N]); 303 remove_argument (N, &argc, argv); 304 AreaYmax = atof (argv[N]); 305 remove_argument (N, &argc, argv); 306 AreaSelect = TRUE; 307 } 308 309 ImagSelect = FALSE; 310 if ((N = get_argument (argc, argv, "-instmag"))) { 311 remove_argument (N, &argc, argv); 312 ImagMin = atof (argv[N]); 313 remove_argument (N, &argc, argv); 314 ImagMax = atof (argv[N]); 315 remove_argument (N, &argc, argv); 316 ImagSelect = TRUE; 317 } 318 319 DophotSelect = FALSE; 320 if ((N = get_argument (argc, argv, "-dophot"))) { 321 remove_argument (N, &argc, argv); 322 DophotValue = atof (argv[N]); 323 remove_argument (N, &argc, argv); 324 DophotSelect = TRUE; 325 } 326 327 SyntheticPhotometry = FALSE; 328 if ((N = get_argument (argc, argv, "-synthphot"))) { 329 remove_argument (N, &argc, argv); 330 SyntheticPhotometry = TRUE; 331 init_synthetic_mags(); 332 } 333 334 refPhotcode = NULL; 335 if ((N = get_argument (argc, argv, "-refcode"))) { 336 remove_argument (N, &argc, argv); 337 refPhotcode = GetPhotcodebyName (argv[N]); 338 if (!refPhotcode) { 339 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]); 340 exit (1); 341 } 342 remove_argument (N, &argc, argv); 343 } 344 345 REGION_FILE = NULL; 346 if ((N = get_argument (argc, argv, "-region-hosts"))) { 347 remove_argument (N, &argc, argv); 348 REGION_FILE = strcreate (argv[N]); 349 remove_argument (N, &argc, argv); 350 } 351 352 REGION_HOST_ID = 0; 353 if ((N = get_argument (argc, argv, "-region-hostID"))) { 354 remove_argument (N, &argc, argv); 355 REGION_HOST_ID = atoi (argv[N]); 356 remove_argument (N, &argc, argv); 357 } 358 359 RelphotMode mode = MODE_ERROR; 360 if ((N = get_argument (argc, argv, "-images"))) { 361 remove_argument (N, &argc, argv); 362 mode = UPDATE_IMAGES; 363 } 364 if ((N = get_argument (argc, argv, "-averages"))) { 365 remove_argument (N, &argc, argv); 366 mode = UPDATE_AVERAGES; 367 } 368 if ((N = get_argument (argc, argv, "-apply-offsets"))) { 369 remove_argument (N, &argc, argv); 370 mode = APPLY_OFFSETS; 371 } 372 IMAGE_TABLE = NULL; 373 if ((N = get_argument (argc, argv, "-parallel-images"))) { 374 remove_argument (N, &argc, argv); 375 mode = PARALLEL_IMAGES; 376 if (N >= argc) relphot_usage(); 377 IMAGE_TABLE = strcreate (argv[N]); 378 remove_argument (N, &argc, argv); 379 if (!REGION_FILE) relphot_usage(); 380 } 381 382 PARALLEL_REGIONS_MANUAL = FALSE; 383 if ((N = get_argument (argc, argv, "-parallel-regions"))) { 384 remove_argument (N, &argc, argv); 385 mode = PARALLEL_REGIONS; 386 if (!REGION_FILE) relphot_usage(); 387 if ((N = get_argument (argc, argv, "-parallel-regions-manual"))) { 388 remove_argument (N, &argc, argv); 389 PARALLEL_REGIONS_MANUAL = TRUE; 390 } 391 } 392 393 switch (mode) { 394 case UPDATE_AVERAGES: 395 if (argc != 1) relphot_usage(); 396 break; 397 398 case UPDATE_IMAGES: 399 case PARALLEL_IMAGES: 400 case PARALLEL_REGIONS: 401 PhotcodeList = strcreate (argv[1]); 402 photcodes = ParsePhotcodeList (PhotcodeList, &Nphotcodes, TRUE); // require SEC photcodes 403 remove_argument (1, &argc, argv); 404 break; 405 406 default: 407 fprintf (stderr, "no valid mode selected\n"); 408 relphot_usage(); 409 break; 410 } 411 if (argc != 1) relphot_usage (); 412 413 return mode; 414 } 415 416 int args_client (int argc, char **argv) { 417 418 int N; 419 double trange; 420 421 // by definition, the client is not parallel 422 PARALLEL = FALSE; 423 PARALLEL_MANUAL = FALSE; 424 PARALLEL_SERIAL = FALSE; 425 426 HOST_ID = 0; 427 if ((N = get_argument (argc, argv, "-hostID"))) { 428 remove_argument (N, &argc, argv); 429 HOST_ID = atoi (argv[N]); 430 remove_argument (N, &argc, argv); 431 } 432 if (!HOST_ID) relphot_client_usage(); 433 434 HOSTDIR = NULL; 435 if ((N = get_argument (argc, argv, "-hostdir"))) { 436 remove_argument (N, &argc, argv); 437 HOSTDIR = strcreate (argv[N]); 438 remove_argument (N, &argc, argv); 439 } 440 if (!HOSTDIR) relphot_client_usage(); 441 442 IMAGES = NULL; // used in -update mode 443 BCATALOG = NULL; // used in -load mode 444 MODE = MODE_NONE; 445 if ((N = get_argument (argc, argv, "-load"))) { 446 MODE = MODE_LOAD; 447 remove_argument (N, &argc, argv); 448 BCATALOG = strcreate (argv[N]); 449 remove_argument (N, &argc, argv); 450 } 451 if ((N = get_argument (argc, argv, "-update-catalogs"))) { 452 if (MODE) { 453 fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n"); 454 relphot_client_usage(); 455 } 456 MODE = MODE_UPDATE; 457 remove_argument (N, &argc, argv); 458 IMAGES = strcreate (argv[N]); 459 remove_argument (N, &argc, argv); 460 } 461 if ((N = get_argument (argc, argv, "-update-objects"))) { 462 if (MODE) { 463 fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n"); 464 relphot_client_usage(); 465 } 466 MODE = MODE_UPDATE_OBJECTS; 467 remove_argument (N, &argc, argv); 468 } 469 if (!MODE) relphot_client_usage(); 470 471 strcpy (STATMODE, "WT_MEAN"); 472 if ((N = get_argument (argc, argv, "-statmode"))) { 473 remove_argument (N, &argc, argv); 474 strcpy (STATMODE, argv[N]); 475 remove_argument (N, &argc, argv); 476 } 477 478 BOUNDARY_TREE = NULL; 479 if ((N = get_argument (argc, argv, "-boundary-tree"))) { 480 remove_argument (N, &argc, argv); 481 BOUNDARY_TREE = strcreate(argv[N]); 482 load_tess (BOUNDARY_TREE); 483 remove_argument (N, &argc, argv); 484 } 485 486 /* specify portion of the sky */ 487 UserPatch.Rmin = 0; 488 UserPatch.Rmax = 360; 489 UserPatch.Dmin = -90; 490 UserPatch.Dmax = +90; 491 if ((N = get_argument (argc, argv, "-region"))) { 492 remove_argument (N, &argc, argv); 493 UserPatch.Rmin = atof (argv[N]); 494 remove_argument (N, &argc, argv); 495 UserPatch.Rmax = atof (argv[N]); 496 remove_argument (N, &argc, argv); 497 UserPatch.Dmin = atof (argv[N]); 498 remove_argument (N, &argc, argv); 499 UserPatch.Dmax = atof (argv[N]); 500 remove_argument (N, &argc, argv); 501 } 502 503 SET_MREL_VERSION = 1; 504 if ((N = get_argument (argc, argv, "-set-mrel-version"))) { 505 remove_argument (N, &argc, argv); 506 SET_MREL_VERSION = atof(argv[N]); 507 remove_argument (N, &argc, argv); 508 } 509 510 VERBOSE = VERBOSE2 = FALSE; 511 if ((N = get_argument (argc, argv, "-v"))) { 512 VERBOSE = TRUE; 513 remove_argument (N, &argc, argv); 514 } 515 if ((N = get_argument (argc, argv, "-vv"))) { 516 VERBOSE2 = VERBOSE = TRUE; 517 remove_argument (N, &argc, argv); 518 } 519 520 RESET = FALSE; 521 if ((N = get_argument (argc, argv, "-reset"))) { 522 remove_argument (N, &argc, argv); 523 RESET = TRUE; 524 } 525 526 RESET_ZEROPTS = FALSE; 527 if ((N = get_argument (argc, argv, "-reset-zpts"))) { 528 remove_argument (N, &argc, argv); 529 RESET_ZEROPTS = TRUE; 530 } 531 532 KEEP_UBERCAL = TRUE; 533 if ((N = get_argument (argc, argv, "-reset-ubercal"))) { 534 remove_argument (N, &argc, argv); 535 KEEP_UBERCAL = FALSE; 536 } 7 537 8 538 /* define time */ … … 33 563 } 34 564 35 /* specify portion of the sky */ 36 UserPatch.Rmin = 0; 37 UserPatch.Rmax = 360; 38 UserPatch.Dmin = -90; 39 UserPatch.Dmax = +90; 40 if ((N = get_argument (argc, argv, "-region"))) { 41 remove_argument (N, &argc, argv); 42 UserPatch.Rmin = atof (argv[N]); 43 remove_argument (N, &argc, argv); 44 UserPatch.Rmax = atof (argv[N]); 45 remove_argument (N, &argc, argv); 46 UserPatch.Dmin = atof (argv[N]); 47 remove_argument (N, &argc, argv); 48 UserPatch.Dmax = atof (argv[N]); 49 remove_argument (N, &argc, argv); 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); 58 } 59 60 USE_BASIC_CHECK = FALSE; 61 if ((N = get_argument (argc, argv, "-basic-image-search"))) { 62 remove_argument (N, &argc, argv); 63 USE_BASIC_CHECK = TRUE; 64 } 65 66 USE_FULL_OVERLAP = TRUE; 67 if ((N = get_argument (argc, argv, "-sloppy-image-overlap"))) { 68 remove_argument (N, &argc, argv); 69 USE_FULL_OVERLAP = FALSE; 70 } 71 72 SET_MREL_VERSION = 1; 73 if ((N = get_argument (argc, argv, "-set-mrel-version"))) { 74 remove_argument (N, &argc, argv); 75 SET_MREL_VERSION = atof(argv[N]); 76 remove_argument (N, &argc, argv); 77 } 78 79 VERBOSE = VERBOSE2 = FALSE; 80 if ((N = get_argument (argc, argv, "-v"))) { 81 VERBOSE = TRUE; 82 remove_argument (N, &argc, argv); 83 } 84 if ((N = get_argument (argc, argv, "-vv"))) { 85 VERBOSE2 = VERBOSE = TRUE; 86 remove_argument (N, &argc, argv); 87 } 88 89 NTHREADS = 0; 90 if ((N = get_argument (argc, argv, "-threads"))) { 91 remove_argument (N, &argc, argv); 92 NTHREADS = atof (argv[N]); 93 remove_argument (N, &argc, argv); 94 } 95 96 // XXX for the moment, make this selection manual. it needs to be automatic 97 // based on the state of the SkyTable 98 HOST_ID = 0; 99 PARALLEL = FALSE; 100 if ((N = get_argument (argc, argv, "-parallel"))) { 101 PARALLEL = TRUE; 102 remove_argument (N, &argc, argv); 103 } 104 // this is a test mode : rather than launching the remote jobs and waiting for completion, 105 // relphot will simply list the remote command and wait for the user to signal completion 106 PARALLEL_MANUAL = FALSE; 107 if ((N = get_argument (argc, argv, "-parallel-manual"))) { 108 PARALLEL = TRUE; // -parallel-manual implies -parallel 109 PARALLEL_MANUAL = TRUE; 110 remove_argument (N, &argc, argv); 111 } 112 // this is a test mode : rather than launching the relphot_client jobs remotely, they are 113 // run in serial via 'system' 114 PARALLEL_SERIAL = FALSE; 115 if ((N = get_argument (argc, argv, "-parallel-serial"))) { 116 if (PARALLEL_MANUAL) { 117 fprintf (stderr, "ERROR: cannot mix -parallel-manual and -parallel-serial\n"); 118 exit (1); 119 } 120 PARALLEL = TRUE; // -parallel-serial implies -parallel 121 PARALLEL_SERIAL = TRUE; 122 remove_argument (N, &argc, argv); 123 } 124 125 PLOTSTUFF = FALSE; 126 if ((N = get_argument (argc, argv, "-plot"))) { 127 PLOTSTUFF = TRUE; 128 remove_argument (N, &argc, argv); 129 } 130 131 PLOTDELAY = 500000; 132 if ((N = get_argument (argc, argv, "-plotdelay"))) { 133 remove_argument (N, &argc, argv); 134 PLOTDELAY = 1e6*atof(argv[N]); 135 PLOTSTUFF = TRUE; // always turn on plotting if i request a plot delay 136 remove_argument (N, &argc, argv); 137 } 138 139 if ((N = get_argument (argc, argv, "-outroot"))) { 140 remove_argument (N, &argc, argv); 141 OUTROOT = strcreate (argv[N]); 142 remove_argument (N, &argc, argv); 143 } else { 144 OUTROOT = strcreate ("relphot"); 145 } 146 147 strcpy (STATMODE, "WT_MEAN"); 148 if ((N = get_argument (argc, argv, "-statmode"))) { 149 remove_argument (N, &argc, argv); 150 strcpy (STATMODE, argv[N]); 151 remove_argument (N, &argc, argv); 152 } 153 154 NLOOP = 8; 155 if ((N = get_argument (argc, argv, "-n"))) { 156 remove_argument (N, &argc, argv); 157 NLOOP = atof (argv[N]); 158 remove_argument (N, &argc, argv); 159 } 160 if ((N = get_argument (argc, argv, "-nloop"))) { 161 remove_argument (N, &argc, argv); 162 NLOOP = atof (argv[N]); 163 remove_argument (N, &argc, argv); 164 } 165 166 NGRID = 8; 167 if ((N = get_argument (argc, argv, "-ngrid"))) { 168 remove_argument (N, &argc, argv); 169 NGRID = atof (argv[N]); 170 remove_argument (N, &argc, argv); 171 } 172 173 RESET = FALSE; 174 if ((N = get_argument (argc, argv, "-reset"))) { 175 remove_argument (N, &argc, argv); 176 RESET = TRUE; 177 } 178 179 RESET_ZEROPTS = FALSE; 180 if ((N = get_argument (argc, argv, "-reset-zpts"))) { 181 remove_argument (N, &argc, argv); 182 RESET_ZEROPTS = TRUE; 183 } 565 566 MIN_ERROR = 0.001; 567 if ((N = get_argument (argc, argv, "-minerror"))) { 568 remove_argument (N, &argc, argv); 569 MIN_ERROR = atof (argv[N]); 570 remove_argument (N, &argc, argv); 571 /* require MIN_ERROR > 0 */ 572 } 184 573 185 574 UPDATE = FALSE; … … 196 585 } 197 586 198 SAVE_IMAGE_UPDATES = TRUE; 199 if ((N = get_argument (argc, argv, "-skip-image-updates"))) { 200 remove_argument (N, &argc, argv); 201 SAVE_IMAGE_UPDATES = FALSE; 587 AreaSelect = FALSE; 588 if ((N = get_argument (argc, argv, "-area"))) { 589 remove_argument (N, &argc, argv); 590 AreaXmin = atof (argv[N]); 591 remove_argument (N, &argc, argv); 592 AreaXmax = atof (argv[N]); 593 remove_argument (N, &argc, argv); 594 AreaYmin = atof (argv[N]); 595 remove_argument (N, &argc, argv); 596 AreaYmax = atof (argv[N]); 597 remove_argument (N, &argc, argv); 598 AreaSelect = TRUE; 599 } 600 601 SyntheticPhotometry = FALSE; 602 if ((N = get_argument (argc, argv, "-synthphot"))) { 603 remove_argument (N, &argc, argv); 604 SyntheticPhotometry = FALSE; 605 init_synthetic_mags(); 606 } 607 608 ImagSelect = FALSE; 609 if ((N = get_argument (argc, argv, "-instmag"))) { 610 remove_argument (N, &argc, argv); 611 ImagMin = atof (argv[N]); 612 remove_argument (N, &argc, argv); 613 ImagMax = atof (argv[N]); 614 remove_argument (N, &argc, argv); 615 ImagSelect = TRUE; 616 } 617 618 DophotSelect = FALSE; 619 if ((N = get_argument (argc, argv, "-dophot"))) { 620 remove_argument (N, &argc, argv); 621 DophotValue = atof (argv[N]); 622 remove_argument (N, &argc, argv); 623 DophotSelect = TRUE; 202 624 } 203 625 … … 210 632 } 211 633 212 CLOUD_TOLERANCE = 0.02; 213 if ((N = get_argument (argc, argv, "-cloud-limit"))) { 214 remove_argument (N, &argc, argv); 215 CLOUD_TOLERANCE = atof(argv[N]); 216 remove_argument (N, &argc, argv); 217 } 218 219 // XXX should we load a tree from CATDIR by default? 220 // NOTE: a given catdir needs an appropriate boundary tree 221 BOUNDARY_TREE = NULL; 222 if ((N = get_argument (argc, argv, "-boundary-tree"))) { 223 remove_argument (N, &argc, argv); 224 BOUNDARY_TREE = strcreate(argv[N]); 225 load_tess (BOUNDARY_TREE); 226 remove_argument (N, &argc, argv); 227 } 228 229 SHOW_PARAMS = FALSE; 230 if ((N = get_argument (argc, argv, "-params"))) { 231 remove_argument (N, &argc, argv); 232 SHOW_PARAMS = TRUE; 233 } 234 235 PlotMmin = 10.0; PlotMmax = 20.0; PlotdMmin = -1.0; PlotdMmax = 1.0; 236 if ((N = get_argument (argc, argv, "-plrange"))) { 237 remove_argument (N, &argc, argv); 238 PlotMmin = atof (argv[N]); 239 remove_argument (N, &argc, argv); 240 PlotMmax = atof (argv[N]); 241 remove_argument (N, &argc, argv); 242 PlotdMmin = atof (argv[N]); 243 remove_argument (N, &argc, argv); 244 PlotdMmax = atof (argv[N]); 245 remove_argument (N, &argc, argv); 246 } 247 248 /* XXX this argument used to do two things: specify the camera name and tell the analysis to 249 calculate a common zero point for a single mosaic. I've moved the MOSAICNAME concept into the 250 config system, but need to use this argument to specify that the mosaic zeropoints should be 251 calculated. */ 252 MOSAIC_ZEROPT = FALSE; 253 if ((N = get_argument (argc, argv, "-mosaic"))) { 254 remove_argument (N, &argc, argv); 255 MOSAIC_ZEROPT = TRUE; 256 if (!strcasecmp (MOSAICNAME, "none")) { 257 fprintf (stderr, "mosaic astrometry selected by MOSAICNAME not defined\n"); 258 exit (2); 259 } 260 } 261 262 FREEZE_IMAGES = FALSE; 263 if ((N = get_argument (argc, argv, "-imfreeze"))) { 264 remove_argument (N, &argc, argv); 265 FREEZE_IMAGES = TRUE; 266 } 267 268 FREEZE_MOSAICS = FALSE; 269 if ((N = get_argument (argc, argv, "-mosfreeze"))) { 270 remove_argument (N, &argc, argv); 271 FREEZE_MOSAICS = TRUE; 272 } 273 274 USE_GRID = FALSE; 275 if ((N = get_argument (argc, argv, "-grid"))) { 276 remove_argument (N, &argc, argv); 277 USE_GRID = TRUE; 278 } 279 280 KEEP_UBERCAL = TRUE; 281 if ((N = get_argument (argc, argv, "-reset-ubercal"))) { 282 remove_argument (N, &argc, argv); 283 KEEP_UBERCAL = FALSE; 284 } 285 286 MIN_ERROR = 0.001; 287 if ((N = get_argument (argc, argv, "-minerror"))) { 288 remove_argument (N, &argc, argv); 289 MIN_ERROR = atof (argv[N]); 290 remove_argument (N, &argc, argv); 291 /* require MIN_ERROR > 0 */ 292 } 293 294 AreaSelect = FALSE; 295 if ((N = get_argument (argc, argv, "-area"))) { 296 remove_argument (N, &argc, argv); 297 AreaXmin = atof (argv[N]); 298 remove_argument (N, &argc, argv); 299 AreaXmax = atof (argv[N]); 300 remove_argument (N, &argc, argv); 301 AreaYmin = atof (argv[N]); 302 remove_argument (N, &argc, argv); 303 AreaYmax = atof (argv[N]); 304 remove_argument (N, &argc, argv); 305 AreaSelect = TRUE; 306 } 307 308 ImagSelect = FALSE; 309 if ((N = get_argument (argc, argv, "-instmag"))) { 310 remove_argument (N, &argc, argv); 311 ImagMin = atof (argv[N]); 312 remove_argument (N, &argc, argv); 313 ImagMax = atof (argv[N]); 314 remove_argument (N, &argc, argv); 315 ImagSelect = TRUE; 316 } 317 318 DophotSelect = FALSE; 319 if ((N = get_argument (argc, argv, "-dophot"))) { 320 remove_argument (N, &argc, argv); 321 DophotValue = atof (argv[N]); 322 remove_argument (N, &argc, argv); 323 DophotSelect = TRUE; 324 } 325 326 SyntheticPhotometry = FALSE; 327 if ((N = get_argument (argc, argv, "-synthphot"))) { 328 remove_argument (N, &argc, argv); 329 SyntheticPhotometry = TRUE; 330 init_synthetic_mags(); 331 } 332 333 refPhotcode = NULL; 334 if ((N = get_argument (argc, argv, "-refcode"))) { 335 remove_argument (N, &argc, argv); 336 refPhotcode = GetPhotcodebyName (argv[N]); 337 if (!refPhotcode) { 338 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]); 339 exit (1); 340 } 341 remove_argument (N, &argc, argv); 342 } 343 344 UpdateAverages = FALSE; 345 if ((N = get_argument (argc, argv, "-averages"))) { 346 remove_argument (N, &argc, argv); 347 UpdateAverages = TRUE; 348 } 349 350 ApplyOffsets = FALSE; 351 if ((N = get_argument (argc, argv, "-apply-offsets"))) { 352 remove_argument (N, &argc, argv); 353 ApplyOffsets = TRUE; 354 } 355 356 if (UpdateAverages && (argc == 1)) return TRUE; 357 if (argc != 2) relphot_usage (); 634 if ((MODE == MODE_UPDATE_OBJECTS) && (argc == 1)) return TRUE; 635 if (argc != 2) relphot_client_usage (); 358 636 359 637 return TRUE; 360 638 } 361 639 362 int args_client (int argc, char **argv) {363 364 int N;365 double trange;366 367 // by definition, the client is not parallel368 PARALLEL = FALSE;369 PARALLEL_MANUAL = FALSE;370 PARALLEL_SERIAL = FALSE;371 372 HOST_ID = 0;373 if ((N = get_argument (argc, argv, "-hostID"))) {374 remove_argument (N, &argc, argv);375 HOST_ID = atoi (argv[N]);376 remove_argument (N, &argc, argv);377 }378 if (!HOST_ID) relphot_client_usage();379 380 HOSTDIR = NULL;381 if ((N = get_argument (argc, argv, "-hostdir"))) {382 remove_argument (N, &argc, argv);383 HOSTDIR = strcreate (argv[N]);384 remove_argument (N, &argc, argv);385 }386 if (!HOSTDIR) relphot_client_usage();387 388 IMAGES = NULL; // used in -update mode389 BCATALOG = NULL; // used in -load mode390 MODE = MODE_NONE;391 if ((N = get_argument (argc, argv, "-load"))) {392 MODE = MODE_LOAD;393 remove_argument (N, &argc, argv);394 BCATALOG = strcreate (argv[N]);395 remove_argument (N, &argc, argv);396 }397 if ((N = get_argument (argc, argv, "-update-catalogs"))) {398 if (MODE) {399 fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n");400 relphot_client_usage();401 }402 MODE = MODE_UPDATE;403 remove_argument (N, &argc, argv);404 IMAGES = strcreate (argv[N]);405 remove_argument (N, &argc, argv);406 }407 if ((N = get_argument (argc, argv, "-update-objects"))) {408 if (MODE) {409 fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n");410 relphot_client_usage();411 }412 MODE = MODE_UPDATE_OBJECTS;413 remove_argument (N, &argc, argv);414 }415 if (!MODE) relphot_client_usage();416 417 strcpy (STATMODE, "WT_MEAN");418 if ((N = get_argument (argc, argv, "-statmode"))) {419 remove_argument (N, &argc, argv);420 strcpy (STATMODE, argv[N]);421 remove_argument (N, &argc, argv);422 }423 424 BOUNDARY_TREE = NULL;425 if ((N = get_argument (argc, argv, "-boundary-tree"))) {426 remove_argument (N, &argc, argv);427 BOUNDARY_TREE = strcreate(argv[N]);428 load_tess (BOUNDARY_TREE);429 remove_argument (N, &argc, argv);430 }431 432 /* specify portion of the sky */433 UserPatch.Rmin = 0;434 UserPatch.Rmax = 360;435 UserPatch.Dmin = -90;436 UserPatch.Dmax = +90;437 if ((N = get_argument (argc, argv, "-region"))) {438 remove_argument (N, &argc, argv);439 UserPatch.Rmin = atof (argv[N]);440 remove_argument (N, &argc, argv);441 UserPatch.Rmax = atof (argv[N]);442 remove_argument (N, &argc, argv);443 UserPatch.Dmin = atof (argv[N]);444 remove_argument (N, &argc, argv);445 UserPatch.Dmax = atof (argv[N]);446 remove_argument (N, &argc, argv);447 }448 449 SET_MREL_VERSION = 1;450 if ((N = get_argument (argc, argv, "-set-mrel-version"))) {451 remove_argument (N, &argc, argv);452 SET_MREL_VERSION = atof(argv[N]);453 remove_argument (N, &argc, argv);454 }455 456 VERBOSE = VERBOSE2 = FALSE;457 if ((N = get_argument (argc, argv, "-v"))) {458 VERBOSE = TRUE;459 remove_argument (N, &argc, argv);460 }461 if ((N = get_argument (argc, argv, "-vv"))) {462 VERBOSE2 = VERBOSE = TRUE;463 remove_argument (N, &argc, argv);464 }465 466 RESET = FALSE;467 if ((N = get_argument (argc, argv, "-reset"))) {468 remove_argument (N, &argc, argv);469 RESET = TRUE;470 }471 472 RESET_ZEROPTS = FALSE;473 if ((N = get_argument (argc, argv, "-reset-zpts"))) {474 remove_argument (N, &argc, argv);475 RESET_ZEROPTS = TRUE;476 }477 478 KEEP_UBERCAL = TRUE;479 if ((N = get_argument (argc, argv, "-reset-ubercal"))) {480 remove_argument (N, &argc, argv);481 KEEP_UBERCAL = FALSE;482 }483 484 /* define time */485 TimeSelect = FALSE;486 if ((N = get_argument (argc, argv, "-time"))) {487 remove_argument (N, &argc, argv);488 if (!ohana_str_to_time (argv[N], &TSTART)) {489 fprintf (stderr, "ERROR: syntax error\n");490 return (FALSE);491 }492 remove_argument (N, &argc, argv);493 if (!ohana_str_to_dtime (argv[N], &trange)) {494 if (!ohana_str_to_time (argv[N], &TSTOP)) {495 fprintf (stderr, "ERROR: syntax error\n");496 return (FALSE);497 }498 } else {499 if (trange < 0) {500 trange = fabs (trange);501 TSTOP = TSTART;502 TSTART -= trange;503 } else {504 TSTOP = TSTART + trange;505 }506 }507 remove_argument (N, &argc, argv);508 TimeSelect = TRUE;509 }510 511 512 MIN_ERROR = 0.001;513 if ((N = get_argument (argc, argv, "-minerror"))) {514 remove_argument (N, &argc, argv);515 MIN_ERROR = atof (argv[N]);516 remove_argument (N, &argc, argv);517 /* require MIN_ERROR > 0 */518 }519 520 UPDATE = FALSE;521 if ((N = get_argument (argc, argv, "-update"))) {522 remove_argument (N, &argc, argv);523 UPDATE = TRUE;524 }525 526 UPDATE_CATFORMAT = NULL;527 if ((N = get_argument (argc, argv, "-update-catformat"))) {528 remove_argument (N, &argc, argv);529 UPDATE_CATFORMAT = strcreate (argv[N]);530 remove_argument (N, &argc, argv);531 }532 533 AreaSelect = FALSE;534 if ((N = get_argument (argc, argv, "-area"))) {535 remove_argument (N, &argc, argv);536 AreaXmin = atof (argv[N]);537 remove_argument (N, &argc, argv);538 AreaXmax = atof (argv[N]);539 remove_argument (N, &argc, argv);540 AreaYmin = atof (argv[N]);541 remove_argument (N, &argc, argv);542 AreaYmax = atof (argv[N]);543 remove_argument (N, &argc, argv);544 AreaSelect = TRUE;545 }546 547 SyntheticPhotometry = FALSE;548 if ((N = get_argument (argc, argv, "-synthphot"))) {549 remove_argument (N, &argc, argv);550 SyntheticPhotometry = FALSE;551 init_synthetic_mags();552 }553 554 ImagSelect = FALSE;555 if ((N = get_argument (argc, argv, "-instmag"))) {556 remove_argument (N, &argc, argv);557 ImagMin = atof (argv[N]);558 remove_argument (N, &argc, argv);559 ImagMax = atof (argv[N]);560 remove_argument (N, &argc, argv);561 ImagSelect = TRUE;562 }563 564 DophotSelect = FALSE;565 if ((N = get_argument (argc, argv, "-dophot"))) {566 remove_argument (N, &argc, argv);567 DophotValue = atof (argv[N]);568 remove_argument (N, &argc, argv);569 DophotSelect = TRUE;570 }571 572 MaxDensityUse = FALSE;573 if ((N = get_argument (argc, argv, "-max-density"))) {574 remove_argument (N, &argc, argv);575 MaxDensityValue = atof(argv[N]);576 remove_argument (N, &argc, argv);577 MaxDensityUse = TRUE;578 }579 580 if ((MODE == MODE_UPDATE_OBJECTS) && (argc == 1)) return TRUE;581 if (argc != 2) relphot_client_usage ();582 583 return TRUE;584 }585 -
trunk/Ohana/src/relphot/src/client_logger.c
r33963 r36630 5 5 6 6 static FILE *logfile = NULL; 7 int client_logger_init ( ) {7 int client_logger_init (char *dirname) { 8 8 9 9 char filename[DVO_MAX_PATH]; 10 10 11 snprintf (filename, DVO_MAX_PATH, "%s/log.rlpc.XXXXXX", HOSTDIR);11 snprintf (filename, DVO_MAX_PATH, "%s/log.rlpc.XXXXXX", dirname); 12 12 13 13 int fd = mkstemp (filename); 14 14 if (fd == -1) { 15 fprintf (stderr, "failed to open client logger , exiting\n");15 fprintf (stderr, "failed to open client logger %s, exiting\n", filename); 16 16 exit (50); 17 17 } … … 32 32 vfprintf (logfile, format, argp); 33 33 va_end (argp); 34 35 fflush (logfile); 34 36 return TRUE; 35 37 } -
trunk/Ohana/src/relphot/src/help.c
r33651 r36630 2 2 3 3 void relphot_usage (void) { 4 fprintf (stderr, "ERROR: USAGE: relphot (photcodes) -region RA RA DEC DEC\n"); 5 fprintf (stderr, " or: relphot (photcodes) -catalog (name)\n"); 6 fprintf (stderr, " or: relphot -averages -region RA RA DEC DEC\n"); 4 fprintf (stderr, "ERROR: USAGE: relphot (photcodes) -images\n"); 5 fprintf (stderr, " or: relphot -averages\n"); 6 fprintf (stderr, " or: relphot -apply-offsets\n"); 7 fprintf (stderr, " or: relphot (photcodes) -parallel-regions -region-hosts (RegionFile)\n"); 8 fprintf (stderr, " or: relphot (photcodes) -parallel-images (ImageTable) -region-hosts (RegionFile)\n\n"); 9 fprintf (stderr, " regions: -region RA RA DEC DEC)\n"); 10 fprintf (stderr, " or: -catalog (name)\n"); 7 11 fprintf (stderr, " use -h for more usage information\n"); 8 12 exit (2); … … 18 22 19 23 show_help: 20 fprintf (stderr, "ERROR: USAGE: relphot (photcode) -region RA RA DEC DEC\n"); 21 fprintf (stderr, " or: relphot (photcode) -catalog (name)\n"); 22 fprintf (stderr, " or: relphot -averages -region RA RA DEC DEC\n"); 24 fprintf (stderr, "ERROR: USAGE: relphot (photcodes) -images\n"); 25 fprintf (stderr, " or: relphot -averages\n"); 26 fprintf (stderr, " or: relphot -apply-offsets\n"); 27 fprintf (stderr, " or: relphot (photcodes) -parallel-regions -region-hosts (RegionFile)\n"); 28 fprintf (stderr, " or: relphot (photcodes) -parallel-images (ImageTable) -region-hosts (RegionFile)\n\n"); 29 fprintf (stderr, " regions: -region RA RA DEC DEC)\n"); 30 fprintf (stderr, " or: -catalog (name)\n"); 23 31 fprintf (stderr, " options: \n"); 24 32 fprintf (stderr, " -time (start) (stop)\n"); -
trunk/Ohana/src/relphot/src/initialize.c
r34429 r36630 1 1 # include "relphot.h" 2 2 3 voidinitialize (int argc, char **argv) {3 RelphotMode initialize (int argc, char **argv) { 4 4 5 5 relphot_help (argc, argv); 6 6 ConfigInit (&argc, argv); 7 args (argc, argv); 7 RelphotMode mode = args (argc, argv); 8 if (!mode) exit (2); 8 9 9 if (!UpdateAverages) { 10 // load the list of photcodes into the globals (photcodes, Nphotcodes) 11 // only a single remaining argument in this mode (the list of photcodes, eg g,r,i) 12 PhotcodeList = strcreate (argv[1]); 13 photcodes = ParsePhotcodeList (PhotcodeList, &Nphotcodes, TRUE); // require SEC photcodes 14 } else { 10 // UPDATE_AVERAGES always operates on all photcodes? 11 if (mode == UPDATE_AVERAGES) { 15 12 char tmpline1[256]; 16 13 int Ns; … … 67 64 for (B = 0; A == time(NULL); B++); 68 65 srand48(B); 66 67 return mode; 69 68 } 70 69 -
trunk/Ohana/src/relphot/src/load_catalogs.c
r35416 r36630 89 89 90 90 fprintf (stderr, "using "OFF_T_FMT" of "OFF_T_FMT" stars ("OFF_T_FMT" of "OFF_T_FMT" measurements)\n", Nstar, Nstar_total, Nmeas, Nmeas_total); 91 if (!hostID && (Nstar < 1)) Shutdown ("%s", "ERROR: no stars match the minimum requirements; exiting \n");91 if (!hostID && !REGION_HOST_ID && (Nstar < 1)) Shutdown ("%s", "ERROR: no stars match the minimum requirements; exiting \n"); 92 92 // in regular relphot, we shutdown here; in relphot_client, we generate and return an empty table (for consistency) 93 94 93 95 94 // XXX consider only returning the populated catalogs … … 107 106 # define DEBUG 1 108 107 Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog) { 108 109 char uniquer[12]; 110 int TIME = time(NULL); 111 int PID = getpid(); 112 snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000); 109 113 110 114 int Nsecfilt = GetPhotcodeNsecfilt (); // set the desired number in case we need to create the catalog … … 128 132 129 133 ALLOCATE (table->hosts[i].results, char, 1024); 130 snprintf (table->hosts[i].results, 1024, "%s/relphot.catalog. subset.dat", table->hosts[i].pathname);134 snprintf (table->hosts[i].results, 1024, "%s/relphot.catalog.%s.dat", table->hosts[i].pathname, uniquer); 131 135 132 136 // options / arguments that can affect relphot_client -load: -
trunk/Ohana/src/relphot/src/reload_catalogs.c
r35806 r36630 156 156 // load the list of hosts 157 157 HostTable *table = HostTableLoad (CATDIR, sky->hosts); 158 if (!table) { 159 fprintf (stderr, "ERROR: problem with parallel host table\n"); 160 exit (2); 161 } 158 162 159 163 if (BOUNDARY_TREE) { -
trunk/Ohana/src/relphot/src/relphot.c
r35416 r36630 3 3 int main (int argc, char **argv) { 4 4 5 /* get configuration info, args */ 6 initialize (argc, argv); 5 // get configuration info, args 6 RelphotMode mode = initialize (argc, argv); 7 if (!mode) exit (2); 7 8 8 /* the object analysis is a separate process iterating over catalogs */ 9 if (UpdateAverages) { 10 relphot_objects (0, NULL); 11 exit (0); 9 switch (mode) { 10 case UPDATE_IMAGES: 11 relphot_images (); 12 exit (0); 13 14 case UPDATE_AVERAGES: 15 // take the current set of detections and set the mean magnitudes 16 relphot_objects (0, NULL); 17 exit (0); 18 19 case PARALLEL_REGIONS: 20 // run image updates in parallel across multiple remote machines 21 relphot_parallel_regions (); 22 exit (0); 23 24 case PARALLEL_IMAGES: 25 // operation on the remote machines in the PARALLEL_REGION mode 26 relphot_parallel_images (); 27 exit (0); 28 29 case APPLY_OFFSETS: 30 // re-run this step from a previous attempt (assumes an existing Images.subset.dat file) 31 if (!PARALLEL) { 32 fprintf (stderr, "-apply-offsets only makes sense in an parallel context\n"); 33 exit (2); 34 } 35 reload_catalogs (NULL, NULL, 0, NULL); 36 exit (0); 37 38 default: 39 fprintf (stderr, "ERROR: no valid relphot mode chosen\n"); 40 exit (2); 12 41 } 13 14 if (ApplyOffsets) { 15 // re-run this step from a previous attempt (assumes an existing Images.subset.dat file) 16 if (!PARALLEL) { 17 fprintf (stderr, "-apply-offsets only makes sense in an parallel context\n"); 18 exit (2); 19 } 20 reload_catalogs (NULL, NULL, 0, NULL); 21 exit (0); 22 } 23 24 relphot_images (); 25 26 exit (0); 42 fprintf (stderr, "IMPOSSIBLE: skipped out of switch?\n"); 43 exit (1); 27 44 } 28 -
trunk/Ohana/src/relphot/src/relphot_client.c
r33963 r36630 19 19 // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, etc) 20 20 initialize_client (argc, argv); 21 client_logger_init ( );21 client_logger_init (HOSTDIR); 22 22 23 23 // load the current sky table (layout of all SkyRegions) -
trunk/Ohana/src/relphot/src/relphot_images.c
r35806 r36630 244 244 if (!UPDATE) exit (0); 245 245 246 /* load catalog data from region files, update Mrel include all data */ 246 /* Load catalog data from region files, update Mrel include all data. In a parallel 247 context, this function writes the image parameters as a subset table for the remote 248 clients */ 247 249 reload_catalogs (skylist, flatcorr, 0, NULL); 248 250 MARKTIME("-- updated all catalogs: %f sec\n", dtime); -
trunk/Ohana/src/relphot/src/setMrelCatalog.c
r36528 r36630 255 255 256 256 // Map (Maplist) and Mkron (Mkronlist,dkronlist) are used to calculate mean mags per filter 257 float Map = PhotAper (&measure[k]);257 float Map = PhotAperCat (&measure[k]); 258 258 if (!isnan(Map)) { 259 259 Maplist[Nap] = Map - Mcal - Mmos - Mgrid; … … 263 263 } 264 264 265 float Mkron = PhotKron (&measure[k]);265 float Mkron = PhotKronCat (&measure[k]); 266 266 if (!isnan(Mkron)) { 267 267 Mkronlist[Nkron] = Mkron - Mcal - Mmos - Mgrid; … … 282 282 wpsflist[Npsf] = isUbercal ? 10.0 : 1.0; 283 283 284 // NOTE: 285 // Msys is measure[i].M + zp corrections 286 // Mcal is image[j].Mcal 287 // Mmos and Mgrid are offsets for mosaic and grid 284 288 285 289 // tie down reference photometry if the -refcode (code) option is selected
Note:
See TracChangeset
for help on using the changeset viewer.
