Changeset 33963 for trunk/Ohana/src/libdvo
- Timestamp:
- May 30, 2012, 1:46:12 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
-
. (modified) (1 prop)
-
Ohana/src/libdvo/include/dvo.h (modified) (3 diffs)
-
Ohana/src/libdvo/include/dvodb.h (modified) (3 diffs)
-
Ohana/src/libdvo/src/HostTable.c (modified) (7 diffs)
-
Ohana/src/libdvo/src/dbExtractAverages.c (modified) (3 diffs)
-
Ohana/src/libdvo/src/dbFields.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_catalog.c (modified) (3 diffs)
-
Ohana/src/libdvo/src/dvo_catalog_split.c (modified) (3 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_convert_PS1_REF.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_convert_PS1_V1.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_convert_PS1_V2.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_convert_PS1_V3.c (modified) (2 diffs)
-
Ohana/src/libdvo/src/dvo_convert_elixir.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_convert_loneos.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_photcode_ops.c (modified) (1 diff)
-
Ohana/src/libdvo/src/flatcorr_io.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
trunk/Ohana/src/libdvo/include/dvo.h
r33779 r33963 69 69 NAN_U_INT = (signed int) 0xffffffff, 70 70 } DVO_INT_NAN; 71 72 // max path length 73 # define DVO_MAX_PATH 1024 71 74 72 75 /* RegImage.flag values */ … … 453 456 float PhotdM (PhotCode *code, Average *average, SecFilt *secfilt); 454 457 458 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt); 459 float PhotM20 (PhotCode *code, Average *average, SecFilt *secfilt); 460 float PhotM80 (PhotCode *code, Average *average, SecFilt *secfilt); 461 float PhotUCdist (PhotCode *code, Average *average, SecFilt *secfilt); 462 455 463 float PhotColorForCode (Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code); 456 464 int PhotColor (Average *average, SecFilt *secfilt, Measure *measure, int c1, int c2, double *color); … … 516 524 void dvo_catalog_test (Catalog *catalog, int halt); 517 525 526 int dvo_catalog_backup (Catalog *catalog, int primary); 527 int dvo_catalog_unlink_backup (Catalog *catalog, int primary); 528 518 529 /* catmode-specific APIs */ 519 530 int dvo_catalog_load_raw (Catalog *catalog, int VERBOSE); -
trunk/Ohana/src/libdvo/include/dvodb.h
r33649 r33963 32 32 MAG_REF, 33 33 MAG_ERR, 34 MAG_STDEV, 34 35 MAG_AVE_ERR, 35 36 MAG_PHOT_FLAGS, … … 37 38 MAG_NCODE, 38 39 MAG_NPHOT, 40 MAG_20, 41 MAG_80, 42 MAG_UC_DIST, 39 43 }; 40 44 … … 327 331 328 332 int dbExtractAveragesInitTransform (CoordTransformSystem target); 333 int dbExtractAveragesInitAve (void); 329 334 int dbExtractAveragesInit (void); 330 335 -
trunk/Ohana/src/libdvo/src/HostTable.c
r33779 r33963 125 125 126 126 for (i = 0; i < table->Nhosts; i++) { 127 if (table->index[table->hosts[i].hostID] == -1) {127 if (table->index[table->hosts[i].hostID] != -1) { 128 128 fprintf (stderr, "error: duplicate hostID %d\n", table->hosts[i].hostID); 129 129 exit (1); … … 168 168 169 169 // find the host which has finished 170 int j;170 int Nout, j; 171 171 int found = FALSE; 172 172 for (j = 0; j < table->Nhosts; j++) { … … 180 180 EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[HOST_STDOUT]); 181 181 fprintf (stderr, "--- stdout from %s ---\n", table->hosts[j].hostname); 182 write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer); 182 Nout = write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer); 183 if (Nout != buffer.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); } 183 184 fprintf (stderr, "\n"); 184 185 … … 186 187 EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[HOST_STDERR]); 187 188 fprintf (stderr, "--- stderr from %s ---\n", table->hosts[j].hostname); 188 write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer); 189 Nout = write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer); 190 if (Nout != buffer.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); } 189 191 fprintf (stderr, "\n"); 190 192 if (WIFEXITED(status)) { … … 271 273 // if (table->hosts[i].stdout.Nbuffer > 0x10000) { 272 274 if (table->hosts[i].stdout.Nbuffer > 0x1000) { 273 int printHead = VERBOSE || table->hosts[i].stdout.Nbuffer; 274 if (printHead) fprintf (stdout, "--- stdout from %s ---\n", table->hosts[i].hostname); 275 write (STDOUT_FILENO, table->hosts[i].stdout.buffer, table->hosts[i].stdout.Nbuffer); 275 int printHead = VERBOSE || (table->hosts[i].stdout.Nbuffer > 0); 276 if (printHead) fprintf (stdout, "--- stdout from %s --- (%d bytes, v1)\n", table->hosts[i].hostname, table->hosts[i].stdout.Nbuffer); 277 int Nout = write (STDOUT_FILENO, table->hosts[i].stdout.buffer, table->hosts[i].stdout.Nbuffer); 278 if (Nout != table->hosts[i].stdout.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); } 276 279 FlushIOBuffer (&table->hosts[i].stdout); 277 280 if (printHead) fprintf (stdout, "\n"); … … 284 287 // if (table->hosts[i].stderr.Nbuffer > 0x10000) { 285 288 if (table->hosts[i].stderr.Nbuffer > 0x1000) { 286 int printHead = VERBOSE || table->hosts[i].stderr.Nbuffer; 287 if (printHead) fprintf (stdout, "--- stderr from %s ---\n", table->hosts[i].hostname); 288 write (STDOUT_FILENO, table->hosts[i].stderr.buffer, table->hosts[i].stderr.Nbuffer); 289 int printHead = VERBOSE || (table->hosts[i].stderr.Nbuffer > 0); 290 if (printHead) fprintf (stdout, "--- stderr from %s --- (%d bytes, v1)\n", table->hosts[i].hostname, table->hosts[i].stderr.Nbuffer); 291 int Nout = write (STDOUT_FILENO, table->hosts[i].stderr.buffer, table->hosts[i].stderr.Nbuffer); 292 if (Nout != table->hosts[i].stderr.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); } 289 293 FlushIOBuffer (&table->hosts[i].stderr); 290 294 if (printHead) fprintf (stdout, "\n"); … … 321 325 // read stdout 322 326 int printHead; 323 printHead = VERBOSE || host->stdout.Nbuffer;327 printHead = VERBOSE || (host->stdout.Nbuffer > 0); 324 328 EmptyIOBuffer (&host->stdout, 100, host->stdio[HOST_STDOUT]); 325 if (printHead) fprintf (stdout, "--- stdout from %s ---\n", host->hostname); 326 write (STDOUT_FILENO, host->stdout.buffer, host->stdout.Nbuffer); 329 if (printHead) fprintf (stdout, "--- stdout from %s --- (%d bytes, v2)\n", host->hostname, host->stdout.Nbuffer); 330 int Nout = write (STDOUT_FILENO, host->stdout.buffer, host->stdout.Nbuffer); 331 if (Nout != host->stdout.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); } 327 332 FlushIOBuffer (&host->stdout); 328 333 if (printHead) fprintf (stdout, "\n"); 329 334 330 335 // read stderr 331 printHead = VERBOSE || host->stderr.Nbuffer;336 printHead = VERBOSE || (host->stderr.Nbuffer > 0); 332 337 EmptyIOBuffer (&host->stderr, 100, host->stdio[HOST_STDERR]); 333 if (printHead) fprintf (stdout, "--- stderr from %s ---\n", host->hostname); 334 write (STDOUT_FILENO, host->stderr.buffer, host->stderr.Nbuffer); 338 if (printHead) fprintf (stdout, "--- stderr from %s --- (%d bytes, v2)\n", host->hostname, host->stderr.Nbuffer); 339 Nout = write (STDOUT_FILENO, host->stderr.buffer, host->stderr.Nbuffer); 340 if (Nout != host->stderr.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); } 335 341 FlushIOBuffer (&host->stderr); 336 342 if (printHead) fprintf (stdout, "\n"); -
trunk/Ohana/src/libdvo/src/dbExtractAverages.c
r33649 r33963 40 40 int dbExtractAveragesInit () { 41 41 GetTimeFormat (&TimeReference, &TimeFormat); 42 return (TRUE); 43 } 44 45 int dbExtractAveragesInitAve () { 42 46 haveGalactic = FALSE; 43 47 haveEcliptic = FALSE; … … 200 204 } 201 205 break; 206 case MAG_STDEV: 207 value.Flt = PhotMstdev (field->photcode, average, secfilt); 208 break; 202 209 case MAG_PHOT_FLAGS: 203 210 if ((field->photcode->type == PHOT_REF) || (field->photcode->type == PHOT_DEP)) { … … 226 233 break; 227 234 235 case MAG_20: 236 value.Flt = PhotM20 (field->photcode, average, secfilt); 237 break; 238 case MAG_80: 239 value.Flt = PhotM80 (field->photcode, average, secfilt); 240 break; 241 case MAG_UC_DIST: 242 value.Flt = PhotUCdist (field->photcode, average, secfilt); 243 break; 228 244 } 229 245 break; -
trunk/Ohana/src/libdvo/src/dbFields.c
r33649 r33963 46 46 if (!strcasecmp (string, "ncode")) return (MAG_NCODE); 47 47 if (!strcasecmp (string, "nphot")) return (MAG_NPHOT); 48 if (!strcasecmp (string, "stdev")) return (MAG_STDEV); 49 if (!strcasecmp (string, "20")) return (MAG_20); 50 if (!strcasecmp (string, "80")) return (MAG_80); 51 if (!strcasecmp (string, "ucdist")) return (MAG_UC_DIST); 48 52 return (MAG_NONE); 49 53 } -
trunk/Ohana/src/libdvo/src/dvo_catalog.c
r33649 r33963 211 211 212 212 if (!check_file_access (catalog[0].filename, BACKUP, READWRITE, VERBOSE)) { 213 if (VERBOSE)fprintf (stderr, "no permission to access %s\n", catalog[0].filename);213 fprintf (stderr, "no permission to access %s\n", catalog[0].filename); 214 214 return (FALSE); 215 215 } … … 219 219 switch (dvo_catalog_lock (catalog, catalog[0].lockmode)) { 220 220 case DVO_CAT_OPEN_FAIL: 221 if (VERBOSE)fprintf (stderr, "can't lock file %s\n", catalog[0].filename);221 fprintf (stderr, "can't lock file %s\n", catalog[0].filename); 222 222 return (FALSE); 223 223 case DVO_CAT_OPEN_OK: 224 224 if (!dvo_catalog_load (catalog, VERBOSE)) { 225 if (VERBOSE)fprintf (stderr, "failure loading catalog\n");225 fprintf (stderr, "failure loading catalog\n"); 226 226 return (FALSE); 227 227 } 228 228 if (!dvo_catalog_check (catalog, Nsecfilt, TRUE)) { 229 if (VERBOSE)fprintf (stderr, "can't reduce number of secondary filters\n");229 fprintf (stderr, "can't reduce number of secondary filters\n"); 230 230 return (FALSE); 231 231 } … … 499 499 } 500 500 501 // make a backup of this catalog (including the measure, secfilt, and missing tables as needed) 502 int dvo_catalog_backup (Catalog *catalog, int primary) { 503 504 // skip empty cpt files 505 if (primary && !catalog->Naves_disk) { 506 return TRUE; 507 } 508 509 char tmpfilename[DVO_MAX_PATH]; 510 int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s~", catalog->filename); 511 if (status >= DVO_MAX_PATH) { 512 fprintf (stderr, "path name too long: %s\n", catalog->filename); 513 return FALSE; 514 } 515 516 // unlock the catalog here (closes file as well) (also closes subcat files Measure, Secfilt, Missing) 517 if (primary) { 518 status = dvo_catalog_unlock (catalog); 519 if (!status) { 520 fprintf (stderr, "failed to unlock catalog %s\n", catalog->filename); 521 return FALSE; 522 } 523 } 524 525 status = rename (catalog->filename, tmpfilename); 526 if (status) { 527 fprintf (stderr, "failed to rename catalog %s\n", catalog->filename); 528 return FALSE; 529 } 530 531 // keep the same lockmode 532 int lockmode = catalog->lockmode; 533 534 // lock the new catalog file here (re-opens file as well) (does NOT open/lock the subcat files) 535 status = dvo_catalog_lock (catalog, lockmode); 536 if (!status) { 537 fprintf (stderr, "failed to lock new catalog file %s\n", catalog->filename); 538 return FALSE; 539 } 540 541 if (catalog[0].catmode == DVO_MODE_SPLIT) { 542 if (catalog[0].measure_catalog != NULL) { 543 if (!dvo_catalog_backup (catalog[0].measure_catalog, FALSE)) { 544 return FALSE; 545 } 546 } 547 if (catalog[0].missing_catalog != NULL) { 548 if (!dvo_catalog_backup (catalog[0].missing_catalog, FALSE)) { 549 return FALSE; 550 } 551 } 552 if (catalog[0].secfilt_catalog != NULL) { 553 if (!dvo_catalog_backup (catalog[0].secfilt_catalog, FALSE)) { 554 return FALSE; 555 } 556 } 557 } 558 return TRUE; 559 } 560 561 // make a backup of this catalog (including the measure, secfilt, and missing tables as needed) 562 int dvo_catalog_unlink_backup (Catalog *catalog, int primary) { 563 564 if (primary && !catalog->Naves_disk) { 565 // skip empty files (empty when read, but output may not be empty) 566 return TRUE; 567 } 568 569 char tmpfilename[DVO_MAX_PATH]; 570 int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s~", catalog->filename); 571 if (status >= DVO_MAX_PATH) { 572 fprintf (stderr, "path name too long: %s\n", catalog->filename); 573 return FALSE; 574 } 575 576 status = unlink (tmpfilename); 577 if (status) { 578 fprintf (stderr, "failed to unlink catalog %s\n", catalog->filename); 579 return FALSE; 580 } 581 582 if (catalog[0].catmode == DVO_MODE_SPLIT) { 583 if (catalog[0].measure_catalog != NULL) { 584 if (!dvo_catalog_unlink_backup (catalog[0].measure_catalog, FALSE)) { 585 return FALSE; 586 } 587 } 588 if (catalog[0].missing_catalog != NULL) { 589 if (!dvo_catalog_unlink_backup (catalog[0].missing_catalog, FALSE)) { 590 return FALSE; 591 } 592 } 593 if (catalog[0].secfilt_catalog != NULL) { 594 if (!dvo_catalog_unlink_backup (catalog[0].secfilt_catalog, FALSE)) { 595 return FALSE; 596 } 597 } 598 } 599 return TRUE; 600 } 601 -
trunk/Ohana/src/libdvo/src/dvo_catalog_split.c
r33649 r33963 80 80 // write PHU header 81 81 if (!gfits_fwrite_header (catalog->f, &catalog->header)) { 82 fprintf (stderr, "can't write primary header ");82 fprintf (stderr, "can't write primary header\n"); 83 83 return (FALSE); 84 84 } … … 87 87 gfits_create_matrix (&catalog->header, &matrix); 88 88 if (!gfits_fwrite_matrix (catalog->f, &matrix)) { 89 fprintf (stderr, "can't write primary matrix ");89 fprintf (stderr, "can't write primary matrix\n"); 90 90 gfits_free_matrix (&matrix); 91 91 return (FALSE); … … 95 95 // write the table data 96 96 if (!gfits_fwrite_ftable_range (catalog->f, ftable, start, Nrows, Ndisk, Ntotal)) { 97 fprintf (stderr, "can't write table data ");97 fprintf (stderr, "can't write table data\n"); 98 98 return (FALSE); 99 99 } -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c
r33649 r33963 213 213 // added in PS1_V3 214 214 out[i].Map = 0; 215 out[i].Mstdev = 0; 215 216 out[i].ubercalDist = 0; 216 217 } -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c
r33649 r33963 207 207 // added in PS1_V3 208 208 out[i].Map = 0; 209 out[i].Mstdev = 0; 209 210 out[i].ubercalDist = 0; 210 211 } -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_REF.c
r33649 r33963 167 167 // added in PS1_V3 168 168 out[i].Map = 0; 169 out[i].Mstdev = 0; 169 170 out[i].ubercalDist = 0; 170 171 } -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V1.c
r33649 r33963 211 211 // added in PS1_V3 212 212 out[i].Map = 0; 213 out[i].Mstdev = 0; 213 214 out[i].ubercalDist = 0; 214 215 } -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V2.c
r33649 r33963 214 214 // added in PS1_V3 215 215 out[i].Map = 0; 216 out[i].Mstdev = 0; 216 217 out[i].ubercalDist = 0; 217 218 } -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V3.c
r33649 r33963 212 212 out[i].M_20 = in[i].M_20; 213 213 out[i].M_80 = in[i].M_80; 214 out[i].Mstdev = in[i].Mstdev; 214 215 out[i].ubercalDist = in[i].ubercalDist; 215 216 } … … 234 235 out[i].M_20 = in[i].M_20; 235 236 out[i].M_80 = in[i].M_80; 237 out[i].Mstdev = in[i].Mstdev; 236 238 out[i].ubercalDist = in[i].ubercalDist; 237 239 } -
trunk/Ohana/src/libdvo/src/dvo_convert_elixir.c
r33649 r33963 222 222 // added in PS1_V3 223 223 out[i].Map = 0; 224 out[i].Mstdev = 0; 224 225 out[i].ubercalDist = 0; 225 226 } -
trunk/Ohana/src/libdvo/src/dvo_convert_loneos.c
r33649 r33963 215 215 // added in PS1_V3 216 216 out[i].Map = 0; 217 out[i].Mstdev = 0; 217 218 out[i].ubercalDist = 0; 218 219 } -
trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c
r33649 r33963 222 222 // added in PS1_V3 223 223 out[i].Map = 0; 224 out[i].Mstdev = 0; 224 225 out[i].ubercalDist = 0; 225 226 } -
trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c
r33649 r33963 222 222 // added in PS1_V3 223 223 out[i].Map = 0; 224 out[i].Mstdev = 0; 224 225 out[i].ubercalDist = 0; 225 226 } -
trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c
r33649 r33963 476 476 } 477 477 478 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt) { 479 480 int Ns; 481 float Mstdev; 482 483 if (code == NULL) return NAN; 484 485 Ns = photcodes[0].hashNsec[code[0].code]; 486 Mstdev = (Ns == -1) ? NAN : 0.001*secfilt[Ns].Mstdev; 487 return (Mstdev); 488 } 489 490 float PhotM20 (PhotCode *code, Average *average, SecFilt *secfilt) { 491 492 int Ns; 493 float M20; 494 495 if (code == NULL) return NAN; 496 497 Ns = photcodes[0].hashNsec[code[0].code]; 498 M20 = (Ns == -1) ? NAN : 0.001*secfilt[Ns].M_20; 499 return (M20); 500 } 501 502 float PhotM80 (PhotCode *code, Average *average, SecFilt *secfilt) { 503 504 int Ns; 505 float M80; 506 507 if (code == NULL) return NAN; 508 509 Ns = photcodes[0].hashNsec[code[0].code]; 510 M80 = (Ns == -1) ? NAN : 0.001*secfilt[Ns].M_80; 511 return (M80); 512 } 513 514 float PhotUCdist (PhotCode *code, Average *average, SecFilt *secfilt) { 515 516 int Ns; 517 float Muc; 518 519 if (code == NULL) return NAN; 520 521 Ns = photcodes[0].hashNsec[code[0].code]; 522 Muc = (Ns == -1) ? NAN : secfilt[Ns].ubercalDist; 523 return (Muc); 524 } 525 478 526 // XXX return NAN or NAN_S_SHORT? (secfilt->Xm is short) 479 527 float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt) { -
trunk/Ohana/src/libdvo/src/flatcorr_io.c
r33649 r33963 185 185 float FlatCorrectionOffset (FlatCorrectionTable *flatcorr, int ID, int X, int Y) { 186 186 187 if (!flatcorr) return 0.0; 188 187 189 // validate the flat_id (not out of range?) 188 190 int seq = flatcorr->IDtoSeq[ID];
Note:
See TracChangeset
for help on using the changeset viewer.
