Changeset 38219
- Timestamp:
- Apr 30, 2015, 8:32:11 AM (11 years ago)
- Location:
- branches/eam_branches/ohana.20150429/src/libdvo/src
- Files:
-
- 3 edited
-
dvo_catalog_mef.c (modified) (2 diffs)
-
dvo_convert.c (modified) (1 diff)
-
dvo_convert_PS1_V5.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libdvo/src/dvo_catalog_mef.c
r37807 r38219 41 41 42 42 /* get the components and sizes from the header */ 43 GET_TABLE_SIZES ("NSTARS", average, Naves_disk, TRUE); 44 GET_TABLE_SIZES ("NMEAS", measure, Nmeas_disk, TRUE); 45 GET_TABLE_SIZES ("NMISS", missing, Nmiss_disk, FALSE); 46 GET_TABLE_SIZES ("NLENSING", lensing, Nlensing_disk, FALSE); 47 GET_TABLE_SIZES ("NLENSOBJ", lensobj, Nlensobj_disk, FALSE); 48 GET_TABLE_SIZES ("NSTARPAR", starpar, Nstarpar_disk, FALSE); 43 GET_TABLE_SIZES ("NSTARS", average, Naves_disk, TRUE); 44 GET_TABLE_SIZES ("NMEAS", measure, Nmeas_disk, TRUE); 45 GET_TABLE_SIZES ("NMISS", missing, Nmiss_disk, FALSE); 46 GET_TABLE_SIZES ("NLENSING", lensing, Nlensing_disk, FALSE); 47 GET_TABLE_SIZES ("NLENSOBJ", lensobj, Nlensobj_disk, FALSE); 48 GET_TABLE_SIZES ("NSTARPAR", starpar, Nstarpar_disk, FALSE); 49 GET_TABLE_SIZES ("NGALSHAPE", galshape, Ngalshape_disk, FALSE); 49 50 50 51 /** Nsecfilt is unusual: it does not list the number of data items in the table … … 279 280 } 280 281 282 /* read GalShape table header */ 283 if (!gfits_fread_header (catalog[0].f, &header)) { 284 if (VERBOSE) fprintf (stderr, "can't read table galshape header"); 285 return (FALSE); 286 } 287 /* read GalShape table data */ 288 if (catalog[0].catflags & LOAD_GALSHAPE) { 289 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 290 if (VERBOSE) fprintf (stderr, "can't read table galshape data"); 291 return (FALSE); 292 } 293 catalog[0].galshape = FtableToGalShape (&ftable, &catalog[0].Ngalshape, &catalog[0].catformat); 294 if (Ngalshape != catalog[0].Ngalshape_disk) { 295 fprintf (stderr, "Warning: mismatch between Ngalshape in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensing, catalog[0].Nlensing_disk); 296 } 297 catalog[0].Nlensing = catalog[0].Nlensing_disk; 298 catalog[0].Nlensing_off = 0; 299 } else { 300 Nbytes = gfits_data_size (&header); 301 fseeko (catalog[0].f, Nbytes, SEEK_CUR); 302 ALLOCATE (catalog[0].lensing, Lensing, 1); 303 catalog[0].Nlensing = 0; 304 catalog[0].Nlensing_off = catalog[0].Nlensing_disk; 305 } 306 281 307 return (TRUE); 282 308 } -
branches/eam_branches/ohana.20150429/src/libdvo/src/dvo_convert.c
r38153 r38219 771 771 default: 772 772 fprintf (stderr, "table format unknown (starpar)\n"); 773 return (FALSE); 774 } 775 return (TRUE); 776 } 777 778 /*** GalShape / FTable conversion functions ***/ 779 780 GalShape *FtableToGalShape (FTable *ftable, off_t *Ngalshape, char *format) { 781 782 GalShape *galshape; 783 char extname[80]; 784 785 /* convert to the internal format */ 786 if (!gfits_scan (ftable[0].header, "EXTNAME", "%s", 1, extname)) { 787 fprintf (stderr, "EXTNAME missing for galshape table\n"); 788 return (FALSE); 789 } 790 791 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 792 if (!strcmp (extname, NAME)) { \ 793 fprintf (stderr, "ERROR: format %s not defined for galshape, skipping\n", NAME); \ 794 *Ngalshape = 0; \ 795 return NULL; \ 796 } 797 798 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 799 if (!strcmp (extname, NAME)) { \ 800 GalShape_##TYPE *tmpGalShape; \ 801 tmpGalShape = gfits_table_get_GalShape_##TYPE (ftable, Ngalshape, NULL); \ 802 if (!tmpGalShape) { \ 803 fprintf (stderr, "ERROR: failed to read galshapes\n"); \ 804 exit (2); \ 805 } \ 806 galshape = GalShape_##TYPE##_ToInternal (tmpGalShape, *Ngalshape); \ 807 free (tmpGalShape); \ 808 *format = DVO_FORMAT_##FORMAT; \ 809 return (galshape); } 810 811 if (!strcmp (extname, "DVO_GALSHAPE")) { 812 galshape = gfits_table_get_GalShape (ftable, Ngalshape, NULL); 813 if (!galshape) { 814 fprintf (stderr, "ERROR: failed to read galshapes\n"); 815 exit (2); 816 } 817 *format = DVO_FORMAT_INTERNAL; 818 return (galshape); 819 } 820 821 SKIPPING_FORMAT ("DVO_GALSHAPE_PS1_REF", PS1_REF, PS1_REF); 822 SKIPPING_FORMAT ("DVO_GALSHAPE_ELIXIR", ELIXIR, Elixir); 823 SKIPPING_FORMAT ("DVO_GALSHAPE_LONEOS", LONEOS, Loneos); 824 SKIPPING_FORMAT ("DVO_GALSHAPE_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0); 825 SKIPPING_FORMAT ("DVO_GALSHAPE_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1); 826 SKIPPING_FORMAT ("DVO_GALSHAPE_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 827 SKIPPING_FORMAT ("DVO_GALSHAPE_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 828 SKIPPING_FORMAT ("DVO_GALSHAPE_PS1_V1", PS1_V1, PS1_V1); 829 SKIPPING_FORMAT ("DVO_GALSHAPE_PS1_V2", PS1_V2, PS1_V2); 830 SKIPPING_FORMAT ("DVO_GALSHAPE_PS1_V3", PS1_V3, PS1_V3); 831 SKIPPING_FORMAT ("DVO_GALSHAPE_PS1_V4", PS1_V4, PS1_V4); 832 CONVERT_FORMAT ("DVO_GALSHAPE_PS1_V5", PS1_V5, PS1_V5); 833 SKIPPING_FORMAT ("DVO_GALSHAPE_PS1_SIM", PS1_SIM, PS1_SIM); 834 # undef CONVERT_FORMAT 835 # undef SKIPPING_FORMAT 836 837 fprintf (stderr, "table format unknown: %s\n", extname); 838 839 *Ngalshape = 0; 840 return (NULL); 841 } 842 843 // GalShapeToFtable needs the Average since old formats stored galshape.dR,dD only 844 int GalShapeToFtable (FTable *ftable, GalShape *galshape, off_t Ngalshape, char format) { 845 846 # define FORMAT_CASE(FORMAT, TYPE) \ 847 case DVO_FORMAT_##FORMAT: { \ 848 GalShape_##TYPE *tmpGalShape; \ 849 tmpGalShape = GalShapeInternalTo_##TYPE (galshape, Ngalshape); \ 850 gfits_table_set_GalShape_##TYPE (ftable, tmpGalShape, Ngalshape); \ 851 free (tmpGalShape); \ 852 break; } 853 854 /* convert from the internal format */ 855 switch (format) { 856 case DVO_FORMAT_INTERNAL: { 857 gfits_table_set_GalShape (ftable, galshape, Ngalshape); 858 break; } 859 860 // FORMAT_CASE (PS1_REF, PS1_REF); 861 // FORMAT_CASE (ELIXIR, Elixir); 862 // FORMAT_CASE (LONEOS, Loneos); 863 // FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 864 // FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 865 // FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 866 // FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 867 // FORMAT_CASE (PS1_V1, PS1_V1); 868 // FORMAT_CASE (PS1_V2, PS1_V2); 869 // FORMAT_CASE (PS1_V3, PS1_V3); 870 // FORMAT_CASE (PS1_V4, PS1_V4); 871 FORMAT_CASE (PS1_V5, PS1_V5); 872 # undef FORMAT_CASE 873 874 default: 875 fprintf (stderr, "table format unknown (galshape)\n"); 773 876 return (FALSE); 774 877 } -
branches/eam_branches/ohana.20150429/src/libdvo/src/dvo_convert_PS1_V5.c
r38153 r38219 196 196 out[i].Nlensobj = in[i].Nlensobj; 197 197 out[i].Nstarpar = in[i].Nstarpar; 198 out[i].N extend = in[i].Nextend;198 out[i].Ngalshape = in[i].Ngalshape; 199 199 200 200 out[i].measureOffset = in[i].measureOffset; … … 203 203 out[i].lensobjOffset = in[i].lensobjOffset; 204 204 out[i].starparOffset = in[i].starparOffset; 205 out[i]. extendOffset = in[i].extendOffset;205 out[i].galshapeOffset = in[i].galshapeOffset; 206 206 207 207 out[i].refColorBlue = in[i].refColorBlue; … … 264 264 out[i].Nlensobj = in[i].Nlensobj; 265 265 out[i].Nstarpar = in[i].Nstarpar; 266 out[i].N extend = in[i].Nextend;266 out[i].Ngalshape = in[i].Ngalshape; 267 267 268 268 out[i].measureOffset = in[i].measureOffset; … … 271 271 out[i].lensobjOffset = in[i].lensobjOffset; 272 272 out[i].starparOffset = in[i].starparOffset; 273 out[i]. extendOffset = in[i].extendOffset;273 out[i].galshapeOffset = in[i].galshapeOffset; 274 274 275 275 out[i].refColorBlue = in[i].refColorBlue; … … 975 975 out[i].objID = in[i].objID ; 976 976 out[i].catID = in[i].catID ; 977 } 978 return (out); 979 } 980 981 GalShape *GalShape_PS1_V5_ToInternal (GalShape_PS1_V5 *in, off_t Nvalues) { 982 983 off_t i; 984 GalShape *out; 985 986 ALLOCATE_ZERO (out, GalShape, Nvalues); 987 988 for (i = 0; i < Nvalues; i++) { 989 dvo_galshape_init (&out[i]); 990 991 out[i].Xfit = in[i].Xfit; 992 out[i]. Yfit = in[i]. Yfit; 993 out[i]. mag = in[i]. mag; 994 out[i]. magErr = in[i]. magErr; 995 out[i]. majorAxis = in[i]. majorAxis; 996 out[i]. minorAxis = in[i]. minorAxis; 997 out[i]. majorAxisErr = in[i]. majorAxisErr; 998 out[i]. minorAxisErr = in[i]. minorAxisErr; 999 out[i]. theta = in[i]. theta; 1000 out[i]. theta_err = in[i]. theta_err; 1001 out[i]. index = in[i]. index; 1002 out[i]. chisq = in[i]. chisq; 1003 out[i]. Npix = in[i]. Npix; 1004 out[i]. objID = in[i]. objID; 1005 out[i]. catID = in[i]. catID; 1006 out[i]. detID = in[i]. detID; 1007 out[i]. imageID = in[i]. imageID; 1008 out[i]. photcode = in[i]. photcode; 1009 out[i]. modelType = in[i]. modelType; 1010 } 1011 return (out); 1012 } 1013 1014 GalShape_PS1_V5 *GalShapeInternalTo_PS1_V5 (GalShape *in, off_t Nvalues) { 1015 1016 off_t i; 1017 GalShape_PS1_V5 *out; 1018 1019 ALLOCATE_ZERO (out, GalShape_PS1_V5, Nvalues); 1020 1021 for (i = 0; i < Nvalues; i++) { 1022 out[i].Xfit = in[i].Xfit; 1023 out[i].Yfit = in[i].Yfit; 1024 out[i].mag = in[i].mag; 1025 out[i].magErr = in[i].magErr; 1026 out[i].majorAxis = in[i].majorAxis; 1027 out[i].minorAxis = in[i].minorAxis; 1028 out[i].majorAxisErr = in[i].majorAxisErr; 1029 out[i].minorAxisErr = in[i].minorAxisErr; 1030 out[i].theta = in[i].theta; 1031 out[i].theta_err = in[i].theta_err; 1032 out[i].index = in[i].index; 1033 out[i].chisq = in[i].chisq; 1034 out[i].Npix = in[i].Npix; 1035 out[i].objID = in[i].objID; 1036 out[i].catID = in[i].catID; 1037 out[i].detID = in[i].detID; 1038 out[i].imageID = in[i].imageID; 1039 out[i].photcode = in[i].photcode; 1040 out[i].modelType = in[i].modelType; 977 1041 } 978 1042 return (out); … … 1234 1298 out[i].Nlensing = in[i].Nlensing; 1235 1299 out[i].Nlensobj = in[i].Nlensobj; 1236 out[i].N extend = in[i].Nextend;1300 out[i].Ngalshape = in[i].Ngalshape; 1237 1301 1238 1302 out[i].measureOffset = in[i].measureOffset; … … 1241 1305 out[i].lensobjOffset = in[i].lensobjOffset; 1242 1306 out[i].starparOffset = in[i].starparOffset; 1243 out[i]. extendOffset = in[i].extendOffset;1307 out[i].galshapeOffset = in[i].galshapeOffset; 1244 1308 1245 1309 out[i].refColorBlue = in[i].refColorBlue; … … 1302 1366 SWAP_BYTE (110); // NLENSING 1303 1367 SWAP_BYTE (112); // NLENSOBJ 1304 SWAP_BYTE (114); // N EXTEND1368 SWAP_BYTE (114); // NGALSHAPE 1305 1369 SWAP_WORD (116); // OFF_MEASURE 1306 1370 SWAP_WORD (120); // OFF_MISSING 1307 1371 SWAP_WORD (124); // OFF_LENSING 1308 1372 SWAP_WORD (128); // OFF_LENSOBJ 1309 SWAP_WORD (132); // OFF_ EXTEND1373 SWAP_WORD (132); // OFF_GALSHAPE 1310 1374 SWAP_WORD (136); // OFF_PARAMS 1311 1375 SWAP_WORD (140); // REF_COLOR_BLUE
Note:
See TracChangeset
for help on using the changeset viewer.
