Changeset 36918
- Timestamp:
- Jun 19, 2014, 10:36:43 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140610/Ohana/src/libdvo
- Files:
-
- 8 edited
-
include/dvo.h (modified) (7 diffs)
-
include/ps1_v5_defs.h (modified) (1 diff)
-
src/dvo_catalog.c (modified) (6 diffs)
-
src/dvo_catalog_create.c (modified) (3 diffs)
-
src/dvo_catalog_mef.c (modified) (8 diffs)
-
src/dvo_catalog_split.c (modified) (21 diffs)
-
src/dvo_convert.c (modified) (1 diff)
-
src/dvo_convert_PS1_V5.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/include/dvo.h
r36917 r36918 79 79 80 80 /* catalog values to be loaded */ 81 # define LOAD_NONE 0x00 82 # define LOAD_AVES 0x01 83 # define LOAD_MEAS 0x02 84 # define LOAD_MISS 0x04 85 # define LOAD_SECF 0x08 86 # define SKIP_AVES 0x10 87 # define SKIP_MEAS 0x20 88 # define SKIP_MISS 0x40 89 # define SKIP_SECF 0x80 90 91 // # define LOAD_MEAS_META 0x100 -- is this used?? 81 # define LOAD_NONE 0x000 82 # define LOAD_AVES 0x001 83 # define LOAD_MEAS 0x002 84 # define LOAD_MISS 0x004 85 # define LOAD_SECF 0x008 86 # define SKIP_AVES 0x010 87 # define SKIP_MEAS 0x020 88 # define SKIP_MISS 0x040 89 # define SKIP_SECF 0x080 90 # define LOAD_LENSING 0x100 91 # define LOAD_LENSOBJ 0x200 92 # define SKIP_LENSING 0x400 93 # define SKIP_LENSOBJ 0x800 92 94 93 95 /* photometry code types */ … … 552 554 Measure *Measure_PS1_V4alt_ToInternal (Average *ave, Measure_PS1_V4alt *in, off_t Nvalues); 553 555 556 /* for some reason I have merged the set of tables and the file description, 557 so I need to have an internal structure to point to the separate files */ 558 554 559 /* a catalog contains this data */ 555 560 typedef struct Catalog { … … 564 569 SecFilt *secfilt; 565 570 571 // lensing data (optional?) 572 Lensing *lensing; 573 Lensobj *lensobj; 574 566 575 int Nsecfilt; /* number of secfilt entries for each average entry */ 567 off_t Naverage, Nmeasure, Nmissing, N secf_mem; /* current number of each component in memory */568 off_t Naves_disk, Nmeas_disk, Nmiss_disk, N secf_disk; /* current number of each component on disk */569 off_t Naves_off, Nmeas_off, Nmiss_off, N secf_off; /* index of first loaded data value */576 off_t Naverage, Nmeasure, Nmissing, Nlensing, Nlensobj, Nsecf_mem; /* current number of each component in memory */ 577 off_t Naves_disk, Nmeas_disk, Nmiss_disk, Nlensing_disk, Nlensobj_disk, Nsecf_disk; /* current number of each component on disk */ 578 off_t Naves_off, Nmeas_off, Nmiss_off, Nlensing_off, Nlensobj_off, Nsecf_off; /* index of first loaded data value */ 570 579 571 580 // note that we use these for the full-sky relphot analysis … … 586 595 struct Catalog *missing_catalog; /* missing catalog data (split) */ 587 596 struct Catalog *secfilt_catalog; /* secfilt catalog data (split) */ 597 struct Catalog *lensing_catalog; /* lensing catalog data (split) */ 598 struct Catalog *lensobj_catalog; /* lensobj catalog data (split) */ 588 599 589 600 unsigned int objID; … … 790 801 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, char *format); 791 802 SecFilt *FtableToSecFilt (FTable *ftable, off_t *Nsecfilt, char *format); 803 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, char *format); 804 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, char *format); 792 805 int FtableToImage (FTable *ftable, Header *theader, char *format); 793 806 … … 795 808 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, char format); 796 809 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, char format); 810 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, char format); 811 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, char format); 797 812 int ImageToFtable (FTable *ftable, Header *theader, char format); 798 813 int ImageToVtable (VTable *vtable, Header *theader, char format); … … 915 930 void dvo_measureT_init (MeasureTiny *measure); 916 931 932 void dvo_lensing_init (Lensing *lensing); 933 void dvo_lensobj_init (Lensobj *lensobj); 934 917 935 void InitRegionHosts (RegionHostInfo *hosts, int Nhosts, int NHOSTS); 918 936 void FreeRegionHosts (RegionHostInfo *hosts, int Nhosts); -
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/include/ps1_v5_defs.h
r36898 r36918 8 8 SecFilt_PS1_V5 *SecFiltInternalTo_PS1_V5 (SecFilt *in, off_t Nvalues); 9 9 10 Lensing *Lensing_PS1_V5_ToInternal (Lensing_PS1_V5 *in, off_t Nvalues); 11 Lensing_PS1_V5 *LensingInternalTo_PS1_V5 (Lensing *in, off_t Nvalues); 12 Lensobj *Lensobj_PS1_V5_ToInternal (Lensobj_PS1_V5 *in, off_t Nvalues); 13 Lensobj_PS1_V5 *LensobjInternalTo_PS1_V5 (Lensobj *in, off_t Nvalues); 14 10 15 PhotCode *PhotCode_PS1_V5_To_Internal (PhotCode_PS1_V5 *in, off_t Nvalues); 11 16 PhotCode_PS1_V5 *PhotCode_Internal_To_PS1_V5 (PhotCode *in, off_t Nvalues); -
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_catalog.c
r36917 r36918 390 390 } 391 391 392 // init all data, or just catalog data 393 void dvo_lensing_init (Lensing *lensing) { 394 lensing->X11_sm_obj = NAN; 395 lensing->X12_sm_obj = NAN; 396 lensing->X22_sm_obj = NAN; 397 lensing->E1_sm_obj = NAN; 398 lensing->E2_sm_obj = NAN; 399 400 lensing->X11_sh_obj = NAN; 401 lensing->X12_sh_obj = NAN; 402 lensing->X22_sh_obj = NAN; 403 lensing->E1_sh_obj = NAN; 404 lensing->E2_sh_obj = NAN; 405 406 lensing->X11_sm_psf = NAN; 407 lensing->X12_sm_psf = NAN; 408 lensing->X22_sm_psf = NAN; 409 lensing->E1_sm_psf = NAN; 410 lensing->E2_sm_psf = NAN; 411 412 lensing->X11_sh_psf = NAN; 413 lensing->X12_sh_psf = NAN; 414 lensing->X22_sh_psf = NAN; 415 lensing->E1_sh_psf = NAN; 416 lensing->E2_sh_psf = NAN; 417 418 lensing->F_ApR5 = NAN; 419 lensing->dF_ApR5 = NAN; 420 lensing->sF_ApR5 = NAN; 421 lensing->fF_ApR5 = NAN; 422 423 lensing->F_ApR6 = NAN; 424 lensing->dF_ApR6 = NAN; 425 lensing->sF_ApR6 = NAN; 426 lensing->fF_ApR6 = NAN; 427 428 lensing->detID = -1; 429 lensing->objID = -1; 430 lensing->catID = -1; 431 432 lensing->pad = 0; 433 } 434 435 // init all data, or just catalog data 436 void dvo_lensobj_init (Lensobj *lensobj) { 437 lensobj->X11_sm_obj = NAN; 438 lensobj->X12_sm_obj = NAN; 439 lensobj->X22_sm_obj = NAN; 440 lensobj->E1_sm_obj = NAN; 441 lensobj->E2_sm_obj = NAN; 442 443 lensobj->X11_sh_obj = NAN; 444 lensobj->X12_sh_obj = NAN; 445 lensobj->X22_sh_obj = NAN; 446 lensobj->E1_sh_obj = NAN; 447 lensobj->E2_sh_obj = NAN; 448 449 lensobj->X11_sm_psf = NAN; 450 lensobj->X12_sm_psf = NAN; 451 lensobj->X22_sm_psf = NAN; 452 lensobj->E1_sm_psf = NAN; 453 lensobj->E2_sm_psf = NAN; 454 455 lensobj->X11_sh_psf = NAN; 456 lensobj->X12_sh_psf = NAN; 457 lensobj->X22_sh_psf = NAN; 458 lensobj->E1_sh_psf = NAN; 459 lensobj->E2_sh_psf = NAN; 460 461 lensobj->F_ApR5 = NAN; 462 lensobj->dF_ApR5 = NAN; 463 lensobj->sF_ApR5 = NAN; 464 lensobj->fF_ApR5 = NAN; 465 466 lensobj->F_ApR6 = NAN; 467 lensobj->dF_ApR6 = NAN; 468 lensobj->sF_ApR6 = NAN; 469 lensobj->fF_ApR6 = NAN; 470 471 lensobj->gamma = NAN; 472 lensobj->E1 = NAN; 473 lensobj->E2 = NAN; 474 475 lensobj->objID = -1; 476 lensobj->catID = -1; 477 478 lensobj->pad = 0; 479 } 480 392 481 /* possible exit status for lock_catalog: 393 482 DVO_CAT_OPEN_FAIL - failure (including lock failure) … … 434 523 435 524 if (catalog[0].catmode == DVO_MODE_SPLIT) { 436 if (catalog[0].measure_catalog != NULL) dvo_catalog_unlock (catalog[0].measure_catalog); 437 if (catalog[0].missing_catalog != NULL) dvo_catalog_unlock (catalog[0].missing_catalog); 438 if (catalog[0].secfilt_catalog != NULL) dvo_catalog_unlock (catalog[0].secfilt_catalog); 525 if (catalog[0].measure_catalog) dvo_catalog_unlock (catalog[0].measure_catalog); 526 if (catalog[0].missing_catalog) dvo_catalog_unlock (catalog[0].missing_catalog); 527 if (catalog[0].secfilt_catalog) dvo_catalog_unlock (catalog[0].secfilt_catalog); 528 if (catalog[0].lensing_catalog) dvo_catalog_unlock (catalog[0].lensing_catalog); 529 if (catalog[0].lensobj_catalog) dvo_catalog_unlock (catalog[0].lensobj_catalog); 439 530 } 440 531 return (1); … … 702 793 free (catalog[0].secfilt_catalog); 703 794 } 795 if (catalog[0].lensing_catalog) { 796 free (catalog[0].lensing_catalog[0].filename); 797 dvo_catalog_free (catalog[0].lensing_catalog); 798 free (catalog[0].lensing_catalog); 799 } 800 if (catalog[0].lensobj_catalog) { 801 free (catalog[0].lensobj_catalog[0].filename); 802 dvo_catalog_free (catalog[0].lensobj_catalog); 803 free (catalog[0].lensobj_catalog); 804 } 704 805 } 705 806 dvo_catalog_free_data (catalog); … … 711 812 712 813 /* free, initialize data structures */ 713 if (catalog[0].average != NULL) {814 if (catalog[0].average) { 714 815 free (catalog[0].average); 715 816 catalog[0].Naverage = 0; 716 817 catalog[0].average = NULL; 717 818 } 718 if (catalog[0].measure != NULL) {819 if (catalog[0].measure) { 719 820 free (catalog[0].measure); 720 821 catalog[0].Nmeasure = 0; 721 822 catalog[0].measure = NULL; 722 823 } 723 if (catalog[0].missing != NULL) {824 if (catalog[0].missing) { 724 825 free (catalog[0].missing); 725 826 catalog[0].Nmissing = 0; 726 827 catalog[0].missing = NULL; 727 828 } 728 if (catalog[0].secfilt != NULL) {829 if (catalog[0].secfilt) { 729 830 free (catalog[0].secfilt); 730 831 catalog[0].Nsecf_mem = 0; 731 832 catalog[0].secfilt = NULL; 833 } 834 if (catalog[0].lensing) { 835 free (catalog[0].lensing); 836 catalog[0].Nlensing = 0; 837 catalog[0].lensing = NULL; 838 } 839 if (catalog[0].lensobj) { 840 free (catalog[0].lensobj); 841 catalog[0].Nlensobj = 0; 842 catalog[0].lensobj = NULL; 732 843 } 733 844 } … … 819 930 } 820 931 } 932 if (catalog[0].lensing_catalog != NULL) { 933 if (!dvo_catalog_backup (catalog[0].lensing_catalog, FALSE)) { 934 return FALSE; 935 } 936 } 937 if (catalog[0].lensobj_catalog != NULL) { 938 if (!dvo_catalog_backup (catalog[0].lensobj_catalog, FALSE)) { 939 return FALSE; 940 } 941 } 821 942 } 822 943 return TRUE; … … 860 981 } 861 982 } 983 if (catalog[0].lensing_catalog != NULL) { 984 if (!dvo_catalog_unlink_backup (catalog[0].lensing_catalog, FALSE)) { 985 return FALSE; 986 } 987 } 988 if (catalog[0].lensobj_catalog != NULL) { 989 if (!dvo_catalog_unlink_backup (catalog[0].lensobj_catalog, FALSE)) { 990 return FALSE; 991 } 992 } 862 993 } 863 994 return TRUE; -
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_catalog_create.c
r27435 r36918 70 70 gfits_modify (&catalog[0].header, "SECFILT", "%s", 1, file); 71 71 free (file); 72 73 /* define lensing catalog file */ 74 ALLOCATE (catalog[0].lensing_catalog, Catalog, 1); 75 dvo_catalog_init (catalog[0].lensing_catalog, TRUE); 76 77 /* create basic data for lensing catalog file */ 78 gfits_create_header (&catalog[0].lensing_catalog[0].header); 79 ALLOCATE (catalog[0].lensing_catalog[0].filename, char, length); 80 sprintf (catalog[0].lensing_catalog[0].filename, "%s/%s.cpx", path, root); 81 file = filebasename (catalog[0].lensing_catalog[0].filename); 82 gfits_modify (&catalog[0].header, "LENSING", "%s", 1, file); 83 free (file); 84 85 /* define lensobj catalog file */ 86 ALLOCATE (catalog[0].lensobj_catalog, Catalog, 1); 87 dvo_catalog_init (catalog[0].lensobj_catalog, TRUE); 88 89 /* create basic data for lensobj catalog file */ 90 gfits_create_header (&catalog[0].lensobj_catalog[0].header); 91 ALLOCATE (catalog[0].lensobj_catalog[0].filename, char, length); 92 sprintf (catalog[0].lensobj_catalog[0].filename, "%s/%s.cpy", path, root); 93 file = filebasename (catalog[0].lensobj_catalog[0].filename); 94 gfits_modify (&catalog[0].header, "LENSOBJ", "%s", 1, file); 95 free (file); 96 72 97 free (path); 73 98 free (root); … … 84 109 } 85 110 if (dvo_catalog_lock (catalog[0].secfilt_catalog, catalog[0].lockmode) != DVO_CAT_OPEN_EMPTY) { 111 fprintf (stderr, "error with file lock\n"); 112 exit (2); 113 } 114 if (dvo_catalog_lock (catalog[0].lensing_catalog, catalog[0].lockmode) != DVO_CAT_OPEN_EMPTY) { 115 fprintf (stderr, "error with file lock\n"); 116 exit (2); 117 } 118 if (dvo_catalog_lock (catalog[0].lensobj_catalog, catalog[0].lockmode) != DVO_CAT_OPEN_EMPTY) { 86 119 fprintf (stderr, "error with file lock\n"); 87 120 exit (2); … … 111 144 ALLOCATE (catalog[0].missing, Missing, 1); 112 145 ALLOCATE (catalog[0].secfilt, SecFilt, 1); 146 ALLOCATE (catalog[0].lensing, Lensing, 1); 147 ALLOCATE (catalog[0].lensobj, Lensobj, 1); 113 148 114 149 /* setup secondary filters to match photcodes: -
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_catalog_mef.c
r36898 r36918 7 7 off_t Nmeasure; 8 8 off_t Nmissing; 9 off_t Nlensing; 10 off_t Nlensobj; 9 11 off_t Nitems, Nexpect; 10 12 int Nsecfilt; … … 22 24 if (!gfits_scan (&catalog[0].header, "NMISS", OFF_T_FMT, 1, &Nmissing)) return (FALSE); 23 25 if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0; 26 if (!gfits_scan (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, &Nlensing)) return (FALSE); 27 if (!gfits_scan (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, &Nlensobj)) return (FALSE); 24 28 25 29 /* the OBJID is a counter that uniquely defines an average entry and never changes. if … … 40 44 catalog[0].Nmiss_disk = Nmissing; 41 45 catalog[0].Nsecf_disk = Naverage * Nsecfilt; 46 catalog[0].Nlensing_disk = Nlensing; 47 catalog[0].Nlensobj_disk = Nlensobj; 42 48 43 49 /** Nsecfilt is unusual: it does not list the number of data items in the table … … 50 56 catalog[0].missing = NULL; 51 57 catalog[0].secfilt = NULL; 58 catalog[0].lensing = NULL; 59 catalog[0].lensobj = NULL; 52 60 53 61 /* validate table mode ?*/ … … 201 209 } 202 210 211 /* read Lensing table header */ 212 if (!gfits_fread_header (catalog[0].f, &header)) { 213 if (VERBOSE) fprintf (stderr, "can't read table lensing header"); 214 return (FALSE); 215 } 216 /* read Lensing table data */ 217 if (catalog[0].catflags & LOAD_LENSING) { 218 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 219 if (VERBOSE) fprintf (stderr, "can't read table lensing data"); 220 return (FALSE); 221 } 222 catalog[0].lensing = FtableToLensing (&ftable, &catalog[0].Nlensing, &catalog[0].catformat); 223 if (Nlensing != catalog[0].Nlensing_disk) { 224 fprintf (stderr, "Warning: mismatch between Nlensing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensing, catalog[0].Nlensing_disk); 225 } 226 catalog[0].Nlensing = catalog[0].Nlensing_disk; 227 catalog[0].Nlensing_off = 0; 228 } else { 229 Nbytes = gfits_data_size (&header); 230 fseeko (catalog[0].f, Nbytes, SEEK_CUR); 231 ALLOCATE (catalog[0].lensing, Lensing, 1); 232 catalog[0].Nlensing = 0; 233 catalog[0].Nlensing_off = catalog[0].Nlensing_disk; 234 } 235 236 /* read Lensobj table header */ 237 if (!gfits_fread_header (catalog[0].f, &header)) { 238 if (VERBOSE) fprintf (stderr, "can't read table lensobj header"); 239 return (FALSE); 240 } 241 /* read Lensobj table data */ 242 if (catalog[0].catflags & LOAD_LENSOBJ) { 243 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 244 if (VERBOSE) fprintf (stderr, "can't read table lensobj data"); 245 return (FALSE); 246 } 247 catalog[0].lensobj = FtableToLensobj (&ftable, &catalog[0].Nlensobj, &catalog[0].catformat); 248 if (Nlensobj != catalog[0].Nlensobj_disk) { 249 fprintf (stderr, "Warning: mismatch between Nlensobj in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensobj, catalog[0].Nlensobj_disk); 250 } 251 catalog[0].Nlensobj = catalog[0].Nlensobj_disk; 252 catalog[0].Nlensobj_off = 0; 253 } else { 254 Nbytes = gfits_data_size (&header); 255 fseeko (catalog[0].f, Nbytes, SEEK_CUR); 256 ALLOCATE (catalog[0].lensobj, Lensobj, 1); 257 catalog[0].Nlensobj = 0; 258 catalog[0].Nlensobj_off = catalog[0].Nlensobj_disk; 259 } 260 203 261 return (TRUE); 204 262 } … … 249 307 gfits_modify (&catalog[0].header, "NMISS", OFF_T_FMT, 1, catalog[0].Nmissing); 250 308 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 309 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, catalog[0].Nlensing); 310 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, catalog[0].Nlensobj); 251 311 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 252 312 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 317 377 Nitems = catalog[0].Naverage * Nsecfilt; 318 378 SecFiltToFtable (&ftable, secfilt, Nitems, catalog[0].catformat); 379 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 380 fprintf (stderr, "can't write table header"); 381 goto failure; 382 } 383 if (!gfits_fwrite_table (catalog[0].f, &ftable)) { 384 fprintf (stderr, "can't write table data"); 385 goto failure; 386 } 387 gfits_free_table (&ftable); 388 gfits_free_header (&header); 389 390 /* write out Lensing table (convert to FITS table format) */ 391 LensingToFtable (&ftable, catalog[0].lensing, catalog[0].Nlensing, catalog[0].catformat); 392 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 393 fprintf (stderr, "can't write table header"); 394 goto failure; 395 } 396 if (!gfits_fwrite_table (catalog[0].f, &ftable)) { 397 fprintf (stderr, "can't write table data"); 398 goto failure; 399 } 400 gfits_free_table (&ftable); 401 gfits_free_header (&header); 402 403 /* write out Lensobj table (convert to FITS table format) */ 404 LensobjToFtable (&ftable, catalog[0].lensobj, catalog[0].Nlensobj, catalog[0].catformat); 319 405 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 320 406 fprintf (stderr, "can't write table header"); … … 356 442 secfilt header 357 443 secfilt table 444 lensing header 445 lensing table 446 lensobj header 447 lensobj table 358 448 */ 359 449 -
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_catalog_split.c
r36898 r36918 161 161 fseeko (subcat[0].f, Nskip, SEEK_CUR); 162 162 163 /* read Measuretable header */163 /* read table header */ 164 164 if (!gfits_fread_header (subcat[0].f, header)) { 165 165 if (VERBOSE) fprintf (stderr, "can't read %s PHU header\n", name); … … 176 176 off_t Nmeasure; 177 177 off_t Nmissing; 178 off_t Nlensing; 179 off_t Nlensobj; 178 180 off_t Nitems; 179 181 int status, Nsecfilt; … … 194 196 if (!gfits_scan (&catalog[0].header, "NMISS", OFF_T_FMT, 1, &Nmissing)) return (FALSE); 195 197 if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0; 198 if (!gfits_scan (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, &Nlensing)) return (FALSE); 199 if (!gfits_scan (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, &Nlensobj)) return (FALSE); 196 200 197 201 /* the OBJID is a counter that uniquely defines an average entry and never changes. if … … 212 216 catalog[0].Nmiss_disk = Nmissing; 213 217 catalog[0].Nsecf_disk = Naverage * Nsecfilt; 218 catalog[0].Nlensing_disk = Nlensing; 219 catalog[0].Nlensobj_disk = Nlensobj; 214 220 215 221 /** Nsecfilt is unusual: it does not list the number of data items in the table … … 222 228 catalog[0].missing = NULL; 223 229 catalog[0].secfilt = NULL; 230 catalog[0].lensing = NULL; 231 catalog[0].lensobj = NULL; 224 232 225 233 /*** Average Table ***/ … … 372 380 gfits_free_header (ftable.header); 373 381 382 /*** Lensing Table ***/ 383 if (!(catalog[0].catflags & SKIP_LENSING)) { 384 // unless we specify 'skip', we still need to load the 385 status = dvo_catalog_open_subcat (catalog, &catalog[0].lensing_catalog, ftable.header, "LENSING", VERBOSE); 386 if (status == DVO_CAT_OPEN_FAIL) { 387 return (FALSE); 388 } 389 if ((status == DVO_CAT_OPEN_EMPTY) && (catalog[0].Nlensing_disk > 0)) { 390 return (FALSE); 391 } 392 } 393 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_LENSING)) { 394 // XXX this allows an empty Lensing catalog with non-empty Average catalog : is that OK? 395 /* read Lensing table data */ 396 if (!gfits_fread_ftable_data (catalog[0].lensing_catalog[0].f, &ftable, FALSE)) { 397 if (VERBOSE) fprintf (stderr, "can't read table lensing data\n"); 398 return (FALSE); 399 } 400 /* convert data format to internal : returns number of row read in Nlensing */ 401 catalog[0].lensing = FtableToLensing (&ftable, &Nlensing, &catalog[0].catformat); 402 if (Nlensing != catalog[0].Nlensing_disk) { 403 fprintf (stderr, "Warning: mismatch between Nlensing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensing, catalog[0].Nlensing_disk); 404 } 405 catalog[0].Nlensing = catalog[0].Nlensing_disk; 406 catalog[0].Nlensing_off = 0; 407 } else { 408 // XXX is it necessary to generate a template header here? 409 // XXX this is a memory leak, right? 410 if (catalog[0].lensing_catalog) { 411 gfits_free_header (&catalog[0].lensing_catalog[0].header); 412 } else { 413 ALLOCATE (catalog[0].lensing_catalog, Catalog, 1); 414 dvo_catalog_init (catalog[0].lensing_catalog, TRUE); 415 } 416 gfits_create_header (&catalog[0].lensing_catalog[0].header); 417 ALLOCATE (catalog[0].lensing, Lensing, 1); 418 catalog[0].Nlensing = 0; 419 catalog[0].Nlensing_off = catalog[0].Nlensing_disk; 420 } 421 gfits_free_header (&header); 422 423 /*** Lensobj Table ***/ 424 if (!(catalog[0].catflags & SKIP_LENSOBJ)) { 425 // unless we specify 'skip', we still need to load the 426 status = dvo_catalog_open_subcat (catalog, &catalog[0].lensobj_catalog, ftable.header, "LENSOBJ", VERBOSE); 427 if (status == DVO_CAT_OPEN_FAIL) { 428 return (FALSE); 429 } 430 if ((status == DVO_CAT_OPEN_EMPTY) && (catalog[0].Nlensobj_disk > 0)) { 431 return (FALSE); 432 } 433 } 434 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_LENSOBJ)) { 435 // XXX this allows an empty Lensobj catalog with non-empty Average catalog : is that OK? 436 /* read Lensobj table data */ 437 if (!gfits_fread_ftable_data (catalog[0].lensobj_catalog[0].f, &ftable, FALSE)) { 438 if (VERBOSE) fprintf (stderr, "can't read table lensobj data\n"); 439 return (FALSE); 440 } 441 /* convert data format to internal : returns number of row read in Nlensobj */ 442 catalog[0].lensobj = FtableToLensobj (&ftable, &Nlensobj, &catalog[0].catformat); 443 if (Nlensobj != catalog[0].Nlensobj_disk) { 444 fprintf (stderr, "Warning: mismatch between Nlensobj in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensobj, catalog[0].Nlensobj_disk); 445 } 446 catalog[0].Nlensobj = catalog[0].Nlensobj_disk; 447 catalog[0].Nlensobj_off = 0; 448 } else { 449 // XXX is it necessary to generate a template header here? 450 // XXX this is a memory leak, right? 451 if (catalog[0].lensobj_catalog) { 452 gfits_free_header (&catalog[0].lensobj_catalog[0].header); 453 } else { 454 ALLOCATE (catalog[0].lensobj_catalog, Catalog, 1); 455 dvo_catalog_init (catalog[0].lensobj_catalog, TRUE); 456 } 457 gfits_create_header (&catalog[0].lensobj_catalog[0].header); 458 ALLOCATE (catalog[0].lensobj, Lensobj, 1); 459 catalog[0].Nlensobj = 0; 460 catalog[0].Nlensobj_off = catalog[0].Nlensobj_disk; 461 } 462 gfits_free_header (&header); 463 374 464 return (TRUE); 375 465 } … … 380 470 381 471 off_t Nbytes; 382 off_t Naverage, Nexpect, Nitems, Nmeasure, Nmissing ;472 off_t Naverage, Nexpect, Nitems, Nmeasure, Nmissing, Nlensing, Nlensobj; 383 473 Header header; 384 474 FTable ftable; … … 519 609 catalog[0].Nmiss_off = start; 520 610 } 611 612 // XXX check the open status of the catalog 613 if (catalog[0].catflags & LOAD_LENSING) { 614 615 Catalog *subcat = catalog[0].lensing_catalog; 616 617 /* move pointer past header -- must be already read (load_catalog) */ 618 Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header); 619 fseeko (subcat[0].f, Nbytes, SEEK_SET); 620 621 /* read Lensing table header */ 622 if (!gfits_fread_header (subcat[0].f, &header)) { 623 if (VERBOSE) fprintf (stderr, "can't read table lensing header"); 624 return (FALSE); 625 } 626 /* read Lensing table data : format is irrelevant here */ 627 if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) { 628 if (VERBOSE) fprintf (stderr, "can't read table lensing data"); 629 return (FALSE); 630 } 631 632 /* convert data format to internal : returns number of row read in Nlensing */ 633 catalog[0].lensing = FtableToLensing (&ftable, &Nlensing, &catalog[0].catformat); 634 if (Nlensing != Nrows) { 635 // XXX this condition denotes the eof has been reached; not an error or a warning 636 // fprintf (stderr, "Warning: mismatch between Nlensing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensing, Nrows); 637 } 638 gfits_free_header (&header); 639 catalog[0].Nlensing = Nlensing; 640 catalog[0].Nlensing_off = start; 641 } 642 643 // XXX check the open status of the catalog 644 if (catalog[0].catflags & LOAD_LENSOBJ) { 645 646 Catalog *subcat = catalog[0].lensobj_catalog; 647 648 /* move pointer past header -- must be already read (load_catalog) */ 649 Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header); 650 fseeko (subcat[0].f, Nbytes, SEEK_SET); 651 652 /* read Lensobj table header */ 653 if (!gfits_fread_header (subcat[0].f, &header)) { 654 if (VERBOSE) fprintf (stderr, "can't read table lensobj header"); 655 return (FALSE); 656 } 657 /* read Lensobj table data : format is irrelevant here */ 658 if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) { 659 if (VERBOSE) fprintf (stderr, "can't read table lensobj data"); 660 return (FALSE); 661 } 662 663 /* convert data format to internal : returns number of row read in Nlensobj */ 664 catalog[0].lensobj = FtableToLensobj (&ftable, &Nlensobj, &catalog[0].catformat); 665 if (Nlensobj != Nrows) { 666 // XXX this condition denotes the eof has been reached; not an error or a warning 667 // fprintf (stderr, "Warning: mismatch between Nlensobj in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensobj, Nrows); 668 } 669 gfits_free_header (&header); 670 catalog[0].Nlensobj = Nlensobj; 671 catalog[0].Nlensobj_off = start; 672 } 673 521 674 return (TRUE); 522 675 } … … 530 683 SecFilt *primary, *secfilt; 531 684 int Nsecfilt; 532 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new ;685 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new; 533 686 off_t first, start, Nrows; 534 687 … … 561 714 Nmiss_disk_new = MAX (catalog[0].Nmiss_disk, catalog[0].Nmissing + catalog[0].Nmiss_off); 562 715 Nsecf_disk_new = MAX (catalog[0].Nsecf_disk, catalog[0].Naverage*Nsecfilt + catalog[0].Nsecf_off); 716 Nlensing_disk_new = MAX (catalog[0].Nlensing_disk, catalog[0].Nlensing + catalog[0].Nlensing_off); 717 Nlensobj_disk_new = MAX (catalog[0].Nlensobj_disk, catalog[0].Nlensobj + catalog[0].Nlensobj_off); 563 718 564 719 /* make sure header is consistent with data */ … … 567 722 gfits_modify (&catalog[0].header, "NMISS", OFF_T_FMT, 1, Nmiss_disk_new); 568 723 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 724 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 725 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 569 726 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 570 727 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 679 836 if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecf_disk, Nsecf_disk_new)) { 680 837 fprintf (stderr, "failure writing SecFilt table\n"); 838 goto failure; 839 } 840 gfits_free_header (&header); 841 gfits_free_table (&ftable); 842 } 843 844 /*** Lensing Table ***/ 845 if ((catalog[0].catflags & LOAD_LENSING) && (catalog[0].lensing != NULL)) { 846 847 first = 0; // first row in memory to write 848 start = catalog[0].Nlensing_off; // first disk row to write 849 Nrows = catalog[0].Nlensing - first; 850 851 assert (Nrows >= 0); 852 assert (first >= 0); 853 assert (first <= catalog[0].Nlensing); 854 assert (catalog[0].Nlensing_disk >= catalog[0].Nlensing_off); 855 856 // convert to external table format (note that the block above does not damage or free catalog.average) 857 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat)) { 858 fprintf (stderr, "trouble converting format\n"); 859 goto failure; 860 } 861 862 // write out Lensing table 863 if (!dvo_catalog_save_subcat (catalog[0].lensing_catalog, &ftable, start, Nrows, catalog[0].Nlensing_disk, Nlensing_disk_new)) { 864 fprintf (stderr, "trouble writing Lensing table\n"); 865 goto failure; 866 } 867 gfits_free_header (&header); 868 gfits_free_table (&ftable); 869 } 870 871 /*** Lensobj Table ***/ 872 if ((catalog[0].catflags & LOAD_LENSOBJ) && (catalog[0].lensobj != NULL)) { 873 874 first = 0; // first row in memory to write 875 start = catalog[0].Nlensobj_off; // first disk row to write 876 Nrows = catalog[0].Nlensobj - first; 877 878 assert (Nrows >= 0); 879 assert (first >= 0); 880 assert (first <= catalog[0].Nlensobj); 881 assert (catalog[0].Nlensobj_disk >= catalog[0].Nlensobj_off); 882 883 // convert to external table format (note that the block above does not damage or free catalog.average) 884 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat)) { 885 fprintf (stderr, "trouble converting format\n"); 886 goto failure; 887 } 888 889 // write out Lensobj table 890 if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) { 891 fprintf (stderr, "trouble writing Lensobj table\n"); 681 892 goto failure; 682 893 } … … 711 922 SecFilt *primary, *secfilt; 712 923 int Nsecfilt; 713 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new ;924 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new; 714 925 off_t first, start, Nrows; 715 926 … … 734 945 if (catalog[0].Nsecf_off > 0) { 735 946 fprintf (stderr, "ERROR: only partial catalog (Secfilt) was loaded\n"); 947 goto failure; 948 } 949 if (catalog[0].Nlensing_off > 0) { 950 fprintf (stderr, "ERROR: only partial catalog (Lensing) was loaded\n"); 951 goto failure; 952 } 953 if (catalog[0].Nlensobj_off > 0) { 954 fprintf (stderr, "ERROR: only partial catalog (Lensobj) was loaded\n"); 736 955 goto failure; 737 956 } … … 760 979 Nmiss_disk_new = catalog[0].Nmissing; 761 980 Nsecf_disk_new = catalog[0].Naverage*Nsecfilt; 981 Nlensing_disk_new = catalog[0].Nlensing; 982 Nlensobj_disk_new = catalog[0].Nlensobj; 762 983 763 984 /* make sure header is consistent with data */ … … 766 987 gfits_modify (&catalog[0].header, "NMISS", OFF_T_FMT, 1, Nmiss_disk_new); 767 988 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 989 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 990 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 768 991 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 769 992 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 878 1101 if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecf_disk, Nsecf_disk_new)) { 879 1102 fprintf (stderr, "failure writing SecFilt table\n"); 1103 goto failure; 1104 } 1105 gfits_free_header (&header); 1106 gfits_free_table (&ftable); 1107 } 1108 1109 /*** Lensing Table ***/ 1110 if ((catalog[0].catflags & LOAD_LENSING) && (catalog[0].lensing != NULL)) { 1111 1112 first = 0; // first row in memory to write 1113 start = catalog[0].Nlensing_off; // first disk row to write 1114 Nrows = catalog[0].Nlensing - first; 1115 1116 assert (Nrows >= 0); 1117 assert (first >= 0); 1118 assert (first <= catalog[0].Nlensing); 1119 assert (catalog[0].Nlensing_disk >= catalog[0].Nlensing_off); 1120 1121 // convert to external table format 1122 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat)) { 1123 fprintf (stderr, "trouble converting format\n"); 1124 goto failure; 1125 } 1126 1127 // write out Lensing table 1128 if (!dvo_catalog_save_subcat (catalog[0].lensing_catalog, &ftable, start, Nrows, catalog[0].Nlensing_disk, Nlensing_disk_new)) { 1129 fprintf (stderr, "trouble writing Lensing table\n"); 1130 goto failure; 1131 } 1132 gfits_free_header (&header); 1133 gfits_free_table (&ftable); 1134 } 1135 1136 /*** Lensobj Table ***/ 1137 if ((catalog[0].catflags & LOAD_LENSOBJ) && (catalog[0].lensobj != NULL)) { 1138 1139 first = 0; // first row in memory to write 1140 start = catalog[0].Nlensobj_off; // first disk row to write 1141 Nrows = catalog[0].Nlensobj - first; 1142 1143 assert (Nrows >= 0); 1144 assert (first >= 0); 1145 assert (first <= catalog[0].Nlensobj); 1146 assert (catalog[0].Nlensobj_disk >= catalog[0].Nlensobj_off); 1147 1148 // convert to external table format 1149 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat)) { 1150 fprintf (stderr, "trouble converting format\n"); 1151 goto failure; 1152 } 1153 1154 // write out Lensobj table 1155 if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) { 1156 fprintf (stderr, "trouble writing Lensobj table\n"); 880 1157 goto failure; 881 1158 } … … 909 1186 SecFilt *primary, *secfilt; 910 1187 int Nsecfilt; 911 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new ;1188 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new; 912 1189 off_t first, start, Nrows; 913 1190 … … 939 1216 Nmiss_disk_new = MAX (catalog[0].Nmiss_disk, catalog[0].Nmissing + catalog[0].Nmiss_off); 940 1217 Nsecf_disk_new = MAX (catalog[0].Nsecf_disk, catalog[0].Naverage*Nsecfilt + catalog[0].Nsecf_off); 1218 Nlensing_disk_new = MAX (catalog[0].Nlensing_disk, catalog[0].Nlensing + catalog[0].Nlensing_off); 1219 Nlensobj_disk_new = MAX (catalog[0].Nlensobj_disk, catalog[0].Nlensobj + catalog[0].Nlensobj_off); 941 1220 942 1221 /* make sure header is consistent with data */ … … 945 1224 gfits_modify (&catalog[0].header, "NMISS", OFF_T_FMT, 1, Nmiss_disk_new); 946 1225 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 1226 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 1227 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 947 1228 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 948 1229 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 1059 1340 if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecf_disk, Nsecf_disk_new)) { 1060 1341 fprintf (stderr, "failure writing SecFilt table\n"); 1342 goto failure; 1343 } 1344 gfits_free_header (&header); 1345 gfits_free_table (&ftable); 1346 } 1347 1348 /*** Lensing Table ***/ 1349 if (catalog[0].lensing != NULL) { 1350 1351 first = catalog[0].Nlensing_disk - catalog[0].Nlensing_off; // first row in memory to write 1352 start = catalog[0].Nlensing_disk; // first disk row to write 1353 Nrows = catalog[0].Nlensing - first; 1354 1355 assert (Nrows >= 0); 1356 assert (first >= 0); 1357 assert (first <= catalog[0].Nlensing); 1358 assert (catalog[0].Nlensing_disk >= catalog[0].Nlensing_off); 1359 1360 // convert to external table format 1361 // XXX does catalog.lensing have averef correctly set up? 1362 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat)) { 1363 fprintf (stderr, "trouble converting format\n"); 1364 goto failure; 1365 } 1366 1367 // write out Lensing table 1368 if (!dvo_catalog_save_subcat (catalog[0].lensing_catalog, &ftable, start, Nrows, catalog[0].Nlensing_disk, Nlensing_disk_new)) { 1369 fprintf (stderr, "trouble writing Lensing table\n"); 1370 goto failure; 1371 } 1372 gfits_free_header (&header); 1373 gfits_free_table (&ftable); 1374 } 1375 1376 /*** Lensobj Table ***/ 1377 if (catalog[0].lensobj != NULL) { 1378 1379 first = catalog[0].Nlensobj_disk - catalog[0].Nlensobj_off; // first row in memory to write 1380 start = catalog[0].Nlensobj_disk; // first disk row to write 1381 Nrows = catalog[0].Nlensobj - first; 1382 1383 assert (Nrows >= 0); 1384 assert (first >= 0); 1385 assert (first <= catalog[0].Nlensobj); 1386 assert (catalog[0].Nlensobj_disk >= catalog[0].Nlensobj_off); 1387 1388 // convert to external table format 1389 // XXX does catalog.lensobj have averef correctly set up? 1390 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat)) { 1391 fprintf (stderr, "trouble converting format\n"); 1392 goto failure; 1393 } 1394 1395 // write out Lensobj table 1396 if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) { 1397 fprintf (stderr, "trouble writing Lensobj table\n"); 1061 1398 goto failure; 1062 1399 } -
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_convert.c
r36898 r36918 361 361 default: 362 362 fprintf (stderr, "table format unknown (secfilt)\n"); 363 return (FALSE); 364 } 365 return (TRUE); 366 } 367 368 /*** Lensing / FTable conversion functions ***/ 369 370 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, char *format) { 371 372 Lensing *lensing; 373 char extname[80]; 374 375 /* convert to the internal format */ 376 if (!gfits_scan (ftable[0].header, "EXTNAME", "%s", 1, extname)) { 377 fprintf (stderr, "EXTNAME missing for lensing table\n"); 378 return (FALSE); 379 } 380 381 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 382 if (!strcmp (extname, NAME)) { \ 383 Lensing_##TYPE *tmpLensing; \ 384 tmpLensing = gfits_table_get_Lensing_##TYPE (ftable, Nlensing, NULL); \ 385 if (!tmpLensing) { \ 386 fprintf (stderr, "ERROR: failed to read lensings\n"); \ 387 exit (2); \ 388 } \ 389 lensing = Lensing_##TYPE##_ToInternal (tmpLensing, *Nlensing); \ 390 free (tmpLensing); \ 391 *format = DVO_FORMAT_##FORMAT; \ 392 return (lensing); } 393 394 if (!strcmp (extname, "DVO_LENSING")) { 395 lensing = gfits_table_get_Lensing (ftable, Nlensing, NULL); 396 if (!lensing) { 397 fprintf (stderr, "ERROR: failed to read lensings\n"); 398 exit (2); 399 } 400 *format = DVO_FORMAT_INTERNAL; 401 return (lensing); 402 } 403 404 // CONVERT_FORMAT ("DVO_LENSING_PS1_REF", PS1_REF, PS1_REF); 405 // CONVERT_FORMAT ("DVO_LENSING_ELIXIR", ELIXIR, Elixir); 406 // CONVERT_FORMAT ("DVO_LENSING_LONEOS", LONEOS, Loneos); 407 // CONVERT_FORMAT ("DVO_LENSING_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0); 408 // CONVERT_FORMAT ("DVO_LENSING_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1); 409 // CONVERT_FORMAT ("DVO_LENSING_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 410 // CONVERT_FORMAT ("DVO_LENSING_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 411 // CONVERT_FORMAT ("DVO_LENSING_PS1_V1", PS1_V1, PS1_V1); 412 // CONVERT_FORMAT ("DVO_LENSING_PS1_V2", PS1_V2, PS1_V2); 413 // CONVERT_FORMAT ("DVO_LENSING_PS1_V3", PS1_V3, PS1_V3); 414 // CONVERT_FORMAT ("DVO_LENSING_PS1_V4", PS1_V4, PS1_V4); 415 CONVERT_FORMAT ("DVO_LENSING_PS1_V5", PS1_V5, PS1_V5); 416 # undef CONVERT_FORMAT 417 418 fprintf (stderr, "table format unknown: %s\n", extname); 419 420 *Nlensing = 0; 421 return (NULL); 422 } 423 424 // LensingToFtable needs the Average since old formats stored lensing.dR,dD only 425 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, char format) { 426 427 # define FORMAT_CASE(FORMAT, TYPE) \ 428 case DVO_FORMAT_##FORMAT: { \ 429 Lensing_##TYPE *tmpLensing; \ 430 tmpLensing = LensingInternalTo_##TYPE (lensing, Nlensing); \ 431 gfits_table_set_Lensing_##TYPE (ftable, tmpLensing, Nlensing); \ 432 free (tmpLensing); \ 433 break; } 434 435 /* convert from the internal format */ 436 switch (format) { 437 case DVO_FORMAT_INTERNAL: { 438 gfits_table_set_Lensing (ftable, lensing, Nlensing); 439 break; } 440 441 // FORMAT_CASE (PS1_REF, PS1_REF); 442 // FORMAT_CASE (ELIXIR, Elixir); 443 // FORMAT_CASE (LONEOS, Loneos); 444 // FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 445 // FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 446 // FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 447 // FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 448 // FORMAT_CASE (PS1_V1, PS1_V1); 449 // FORMAT_CASE (PS1_V2, PS1_V2); 450 // FORMAT_CASE (PS1_V3, PS1_V3); 451 // FORMAT_CASE (PS1_V4, PS1_V4); 452 FORMAT_CASE (PS1_V5, PS1_V5); 453 # undef FORMAT_CASE 454 455 default: 456 fprintf (stderr, "table format unknown (lensing)\n"); 457 return (FALSE); 458 } 459 return (TRUE); 460 } 461 462 /*** Lensobj / FTable conversion functions ***/ 463 464 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, char *format) { 465 466 Lensobj *lensobj; 467 char extname[80]; 468 469 /* convert to the internal format */ 470 if (!gfits_scan (ftable[0].header, "EXTNAME", "%s", 1, extname)) { 471 fprintf (stderr, "EXTNAME missing for lensobj table\n"); 472 return (FALSE); 473 } 474 475 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 476 if (!strcmp (extname, NAME)) { \ 477 Lensobj_##TYPE *tmpLensobj; \ 478 tmpLensobj = gfits_table_get_Lensobj_##TYPE (ftable, Nlensobj, NULL); \ 479 if (!tmpLensobj) { \ 480 fprintf (stderr, "ERROR: failed to read lensobjs\n"); \ 481 exit (2); \ 482 } \ 483 lensobj = Lensobj_##TYPE##_ToInternal (tmpLensobj, *Nlensobj); \ 484 free (tmpLensobj); \ 485 *format = DVO_FORMAT_##FORMAT; \ 486 return (lensobj); } 487 488 if (!strcmp (extname, "DVO_LENSOBJ")) { 489 lensobj = gfits_table_get_Lensobj (ftable, Nlensobj, NULL); 490 if (!lensobj) { 491 fprintf (stderr, "ERROR: failed to read lensobjs\n"); 492 exit (2); 493 } 494 *format = DVO_FORMAT_INTERNAL; 495 return (lensobj); 496 } 497 498 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_REF", PS1_REF, PS1_REF); 499 // CONVERT_FORMAT ("DVO_LENSOBJ_ELIXIR", ELIXIR, Elixir); 500 // CONVERT_FORMAT ("DVO_LENSOBJ_LONEOS", LONEOS, Loneos); 501 // CONVERT_FORMAT ("DVO_LENSOBJ_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0); 502 // CONVERT_FORMAT ("DVO_LENSOBJ_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1); 503 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 504 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 505 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V1", PS1_V1, PS1_V1); 506 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V2", PS1_V2, PS1_V2); 507 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V3", PS1_V3, PS1_V3); 508 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V4", PS1_V4, PS1_V4); 509 CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V5", PS1_V5, PS1_V5); 510 # undef CONVERT_FORMAT 511 512 fprintf (stderr, "table format unknown: %s\n", extname); 513 514 *Nlensobj = 0; 515 return (NULL); 516 } 517 518 // LensobjToFtable needs the Average since old formats stored lensobj.dR,dD only 519 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, char format) { 520 521 # define FORMAT_CASE(FORMAT, TYPE) \ 522 case DVO_FORMAT_##FORMAT: { \ 523 Lensobj_##TYPE *tmpLensobj; \ 524 tmpLensobj = LensobjInternalTo_##TYPE (lensobj, Nlensobj); \ 525 gfits_table_set_Lensobj_##TYPE (ftable, tmpLensobj, Nlensobj); \ 526 free (tmpLensobj); \ 527 break; } 528 529 /* convert from the internal format */ 530 switch (format) { 531 case DVO_FORMAT_INTERNAL: { 532 gfits_table_set_Lensobj (ftable, lensobj, Nlensobj); 533 break; } 534 535 // FORMAT_CASE (PS1_REF, PS1_REF); 536 // FORMAT_CASE (ELIXIR, Elixir); 537 // FORMAT_CASE (LONEOS, Loneos); 538 // FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 539 // FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 540 // FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 541 // FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 542 // FORMAT_CASE (PS1_V1, PS1_V1); 543 // FORMAT_CASE (PS1_V2, PS1_V2); 544 // FORMAT_CASE (PS1_V3, PS1_V3); 545 // FORMAT_CASE (PS1_V4, PS1_V4); 546 FORMAT_CASE (PS1_V5, PS1_V5); 547 # undef FORMAT_CASE 548 549 default: 550 fprintf (stderr, "table format unknown (lensobj)\n"); 363 551 return (FALSE); 364 552 } -
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c
r36917 r36918 407 407 } 408 408 409 # if (0)410 409 Lensing *Lensing_PS1_V5_ToInternal (Lensing_PS1_V5 *in, off_t Nvalues) { 411 410 … … 616 615 return (out); 617 616 } 618 # endif619 617 620 618 Image *Image_PS1_V5_ToInternal (Image_PS1_V5 *in, off_t Nvalues, off_t Nalloc) {
Note:
See TracChangeset
for help on using the changeset viewer.
