Changeset 38447
- Timestamp:
- Jun 12, 2015, 9:44:51 PM (11 years ago)
- Location:
- branches/eam_branches/ipp-20150419/Ohana/src
- Files:
-
- 195 edited
- 11 copied
-
. (modified) (1 prop)
-
checkastro/src/bcatalog.c (modified) (3 diffs)
-
checkastro/src/checkastro_images.c (modified) (1 diff)
-
checkastro/src/load_catalogs.c (modified) (2 diffs)
-
checkastro/src/load_images.c (modified) (1 diff)
-
delstar/src/delete_duplicate_images.c (modified) (4 diffs)
-
delstar/src/delete_duplicate_measures.c (modified) (2 diffs)
-
delstar/src/delete_fix_LAP.c (modified) (2 diffs)
-
delstar/src/delete_fix_LAP_edges.c (modified) (2 diffs)
-
delstar/src/delete_fix_LAP_edges_delete.c (modified) (2 diffs)
-
delstar/src/delete_image_photcodes.c (modified) (2 diffs)
-
delstar/src/delete_imagefile.c (modified) (2 diffs)
-
delstar/src/delete_imagename.c (modified) (4 diffs)
-
delstar/src/delete_orphans.c (modified) (1 diff)
-
delstar/src/delete_photcodes.c (modified) (2 diffs)
-
delstar/src/delete_photcodes_single.c (modified) (2 diffs)
-
delstar/src/delete_times.c (modified) (3 diffs)
-
delstar/src/delstar.c (modified) (3 diffs)
-
delstar/src/find_image_db.c (modified) (3 diffs)
-
delstar/src/find_matches.c (modified) (1 diff)
-
dvolens/src/update_objects.c (modified) (2 diffs)
-
dvopsps/src/insert_FWobjects_dvopsps.c (modified) (2 diffs)
-
dvopsps/src/insert_detections_dvopsps.c (modified) (3 diffs)
-
dvopsps/src/insert_detections_dvopsps_catalog.c (modified) (1 diff)
-
dvopsps/src/insert_diffobj_dvopsps.c (modified) (3 diffs)
-
dvopsps/src/insert_objects_dvopsps.c (modified) (3 diffs)
-
dvosplit/src/dvosplit.c (modified) (2 diffs)
-
dvosplit/src/open_output_catalogs.c (modified) (1 diff)
-
dvosplit/src/split_averages.c (modified) (8 diffs)
-
dvosplit/src/split_measures.c (modified) (4 diffs)
-
dvosplit/src/split_missings.c (modified) (2 diffs)
-
fakeastro/include/fakeastro.h (modified) (1 diff)
-
fakeastro/src/fakeastro_2mass.c (modified) (2 diffs)
-
fakeastro/src/fakeastro_images.c (modified) (1 diff)
-
fakeastro/src/fakestar_catalog.c (modified) (1 diff)
-
fakeastro/src/insert_fakestar.c (modified) (1 diff)
-
fakeastro/src/load_fake_stars.c (modified) (2 diffs)
-
fakeastro/src/load_template_images.c (modified) (2 diffs)
-
fakeastro/src/match_fake_stars.c (modified) (1 diff)
-
fakeastro/src/save_fake_stars.c (modified) (1 diff)
-
fakeastro/src/save_fakestars.c (modified) (2 diffs)
-
gastro/src/getptolemy.c (modified) (2 diffs)
-
gastro2/src/getptolemy.c (modified) (2 diffs)
-
gastro2/src/rfits.c (modified) (1 diff)
-
getstar/src/WriteImageFITS.c (modified) (1 diff)
-
getstar/src/dvoImageExtract.c (modified) (2 diffs)
-
getstar/src/dvoImageOverlaps.c (modified) (2 diffs)
-
getstar/src/dvoImagesAtCoords.c (modified) (2 diffs)
-
getstar/src/getstar.c (modified) (5 diffs)
-
getstar/src/select_by_region.c (modified) (1 diff)
-
getstar/src/write_getstar_ps1_dev_0.c (modified) (1 diff)
-
getstar/src/write_getstar_ps1_dev_1.c (modified) (1 diff)
-
getstar/src/write_getstar_ps1_dev_2.c (modified) (1 diff)
-
imclean/src/wfits.c (modified) (1 diff)
-
imregister/detrend/delete.c (modified) (1 diff)
-
imregister/detrend/output.c (modified) (1 diff)
-
imregister/imphot/dumpfits.c (modified) (1 diff)
-
imregister/imreg/delete.c (modified) (1 diff)
-
imregister/imreg/imregclient.c (modified) (2 diffs)
-
imregister/imreg/output.c (modified) (1 diff)
-
imregister/photreg/delete.c (modified) (1 diff)
-
imregister/photreg/output.c (modified) (1 diff)
-
imregister/spreg/delete.c (modified) (1 diff)
-
imregister/spreg/output.c (modified) (2 diffs)
-
imregister/src/detregister.c (modified) (2 diffs)
-
imregister/src/detsearch.c (modified) (2 diffs)
-
imregister/src/imphotsearch.c (modified) (2 diffs)
-
imregister/src/imregister.c (modified) (2 diffs)
-
imregister/src/imregtable.c (modified) (3 diffs)
-
imregister/src/imsearch.c (modified) (2 diffs)
-
imregister/src/imstatreg.c (modified) (3 diffs)
-
imregister/src/photreg.c (modified) (2 diffs)
-
imregister/src/photsearch.c (modified) (3 diffs)
-
imregister/src/spregister.c (modified) (2 diffs)
-
imregister/src/spsearch.c (modified) (2 diffs)
-
libautocode/Makefile.Targets (modified) (2 diffs)
-
libautocode/def/autocode.c (modified) (3 diffs)
-
libautocode/def/autocode.h (modified) (1 diff)
-
libautocode/def/average-ps1-v1.d (modified) (1 diff)
-
libautocode/def/average-ps1-v2.d (modified) (1 diff)
-
libautocode/def/average-ps1-v3.d (modified) (1 diff)
-
libautocode/def/average-ps1-v4.d (modified) (1 diff)
-
libautocode/def/average-ps1-v5.d (modified) (1 diff)
-
libautocode/def/average.d (modified) (1 diff)
-
libautocode/def/galshape-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/galshape-ps1-v5.d )
-
libautocode/def/galshape.d (copied) (copied from trunk/Ohana/src/libautocode/def/galshape.d )
-
libdvo/Makefile (modified) (2 diffs)
-
libdvo/include/dvo.h (modified) (14 diffs)
-
libdvo/include/ps1_v5_defs.h (modified) (1 diff)
-
libdvo/src/AstromOffsetMapIO.c (modified) (2 diffs)
-
libdvo/src/HostTable.c (modified) (2 diffs)
-
libdvo/src/LoadImages.c (modified) (1 diff)
-
libdvo/src/LoadPhotcodesFITS.c (modified) (2 diffs)
-
libdvo/src/SavePhotcodesFITS.c (modified) (2 diffs)
-
libdvo/src/dvo_catalog.c (modified) (19 diffs)
-
libdvo/src/dvo_catalog_create.c (modified) (7 diffs)
-
libdvo/src/dvo_catalog_mef.c (modified) (27 diffs)
-
libdvo/src/dvo_catalog_raw.c (modified) (7 diffs)
-
libdvo/src/dvo_catalog_split.c (modified) (80 diffs)
-
libdvo/src/dvo_convert.c (modified) (45 diffs)
-
libdvo/src/dvo_convert_PS1_DEV_2.c (modified) (2 diffs)
-
libdvo/src/dvo_convert_PS1_V1.c (modified) (2 diffs)
-
libdvo/src/dvo_convert_PS1_V2.c (modified) (2 diffs)
-
libdvo/src/dvo_convert_PS1_V3.c (modified) (2 diffs)
-
libdvo/src/dvo_convert_PS1_V4.c (modified) (3 diffs)
-
libdvo/src/dvo_convert_PS1_V5.c (modified) (8 diffs)
-
libdvo/src/dvo_image.c (modified) (6 diffs)
-
libdvo/src/dvo_image_raw.c (modified) (1 diff)
-
libdvo/src/dvo_util.c (modified) (2 diffs)
-
libdvo/src/fits_db.c (modified) (2 diffs)
-
libdvo/src/flatcorr_io.c (modified) (4 diffs)
-
libdvo/src/skyregion_io.c (modified) (2 diffs)
-
libfits/Makefile (modified) (5 diffs)
-
libfits/doc/notes-compress.txt (modified) (1 diff)
-
libfits/extern/gzip.c (modified) (5 diffs)
-
libfits/header/F_copy_H.c (modified) (1 diff)
-
libfits/header/F_modify.c (modified) (4 diffs)
-
libfits/include/gfitsio.h (modified) (12 diffs)
-
libfits/matrix/F_compress_M.c (copied) (copied from trunk/Ohana/src/libfits/matrix/F_compress_M.c )
-
libfits/matrix/F_compress_data.c (copied) (copied from trunk/Ohana/src/libfits/matrix/F_compress_data.c )
-
libfits/matrix/F_compress_utils.c (copied) (copied from trunk/Ohana/src/libfits/matrix/F_compress_utils.c )
-
libfits/matrix/F_matrix.c (modified) (4 diffs)
-
libfits/matrix/F_swap_raw.c (copied) (copied from trunk/Ohana/src/libfits/matrix/F_swap_raw.c )
-
libfits/matrix/F_uncompress_M.c (copied) (copied from trunk/Ohana/src/libfits/matrix/F_uncompress_M.c )
-
libfits/matrix/F_uncompress_data.c (modified) (2 diffs)
-
libfits/table/F_compress_T.c (copied) (copied from trunk/Ohana/src/libfits/table/F_compress_T.c )
-
libfits/table/F_copy_T.c (modified) (2 diffs)
-
libfits/table/F_create_T.c (modified) (3 diffs)
-
libfits/table/F_define_column.c (modified) (1 diff)
-
libfits/table/F_get_column.c (modified) (7 diffs)
-
libfits/table/F_read_T.c (modified) (5 diffs)
-
libfits/table/F_set_column.c (modified) (41 diffs)
-
libfits/table/F_table_format.c (modified) (4 diffs)
-
libfits/table/F_table_row.c (modified) (3 diffs)
-
libfits/table/F_table_varlength.c (modified) (5 diffs)
-
libfits/table/F_uncompress_T.c (copied) (copied from trunk/Ohana/src/libfits/table/F_uncompress_T.c )
-
libfits/table/F_write_T.c (modified) (9 diffs)
-
libfits/table/F_write_TH.c (modified) (2 diffs)
-
libfits/test (copied) (copied from trunk/Ohana/src/libfits/test )
-
libohana/Makefile (modified) (5 diffs)
-
libohana/include/ohana.h (modified) (3 diffs)
-
libohana/include/ohana_allocate.h (modified) (2 diffs)
-
libohana/src/ohana_allocate.c (modified) (2 diffs)
-
libohana/src/string.c (modified) (1 diff)
-
libohana/test (modified) (1 prop)
-
libohana/test/string.c (modified) (2 diffs)
-
libohana/test/typetest.c (modified) (2 diffs)
-
libtap/tapcheck.pl (copied) (copied from trunk/Ohana/src/libtap/tapcheck.pl )
-
markrock/src/markrock.c (modified) (2 diffs)
-
markstar/src/find_images.c (modified) (1 diff)
-
markstar/src/markstar.c (modified) (2 diffs)
-
mosastro/src/getptolemy.c (modified) (2 diffs)
-
mosastro/src/rfits.c (modified) (1 diff)
-
mosastro/src/wfits.c (modified) (1 diff)
-
photdbc/include/photdbc.h (modified) (1 diff)
-
photdbc/src/ConfigInit.c (modified) (1 diff)
-
photdbc/src/Shutdown_dvodist.c (modified) (1 diff)
-
photdbc/src/args.c (modified) (3 diffs)
-
photdbc/src/copy_images.c (modified) (3 diffs)
-
photdbc/src/find_images.c (modified) (1 diff)
-
photdbc/src/flag_measures.c (modified) (1 diff)
-
photdbc/src/join_stars.c (modified) (1 diff)
-
photdbc/src/make_subcatalog.c (modified) (1 diff)
-
photdbc/src/photdbc_catalogs.c (modified) (6 diffs)
-
relastro/include/relastro.h (modified) (2 diffs)
-
relastro/src/BrightCatalog.c (modified) (8 diffs)
-
relastro/src/ImageTable.c (modified) (3 diffs)
-
relastro/src/UpdateObjectOffsets.c (modified) (5 diffs)
-
relastro/src/args.c (modified) (1 diff)
-
relastro/src/assign_images.c (modified) (1 diff)
-
relastro/src/bcatalog.c (modified) (3 diffs)
-
relastro/src/high_speed_catalogs.c (modified) (4 diffs)
-
relastro/src/high_speed_objects.c (modified) (2 diffs)
-
relastro/src/hpm_catalogs.c (modified) (4 diffs)
-
relastro/src/hpm_objects.c (modified) (2 diffs)
-
relastro/src/launch_region_hosts.c (modified) (2 diffs)
-
relastro/src/load_catalogs.c (modified) (4 diffs)
-
relastro/src/load_images.c (modified) (1 diff)
-
relastro/src/relastro_client.c (modified) (1 diff)
-
relastro/src/relastro_images.c (modified) (1 diff)
-
relastro/src/relastro_merge_source.c (modified) (2 diffs)
-
relastro/src/relastro_objects.c (modified) (3 diffs)
-
relastro/src/relastro_parallel_regions.c (modified) (1 diff)
-
tools/src/fields.c (modified) (2 diffs)
-
uniphot/src/find_image_sgroups.c (modified) (1 diff)
-
uniphot/src/find_image_tgroups.c (modified) (1 diff)
-
uniphot/src/fiximids.c (modified) (1 diff)
-
uniphot/src/fixstkids.c (modified) (1 diff)
-
uniphot/src/load_images.c (modified) (1 diff)
-
uniphot/src/load_images_fiximids.c (modified) (1 diff)
-
uniphot/src/load_images_fixstkids.c (modified) (1 diff)
-
uniphot/src/load_images_setphot.c (modified) (1 diff)
-
uniphot/src/load_images_setposangle.c (modified) (1 diff)
-
uniphot/src/setfwhm.c (modified) (1 diff)
-
uniphot/src/setphot.c (modified) (1 diff)
-
uniphot/src/setposangle.c (modified) (1 diff)
-
uniphot/src/subset_images.c (modified) (1 diff)
-
uniphot/src/uniphot.c (modified) (1 diff)
-
uniphot/src/update_dvo_ckids.c (modified) (3 diffs)
-
uniphot/src/update_dvo_fiximids.c (modified) (4 diffs)
-
uniphot/src/update_dvo_fixstkids.c (modified) (4 diffs)
-
uniphot/src/update_dvo_setastrom.c (modified) (3 diffs)
-
uniphot/src/update_dvo_setgalmodel.c (modified) (3 diffs)
-
uniphot/src/update_dvo_setphot.c (modified) (3 diffs)
-
uniphot/src/update_dvo_setposangle.c (modified) (3 diffs)
-
uniphot/src/update_dvo_uniphot.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150419/Ohana/src
-
Property svn:mergeinfo
set to
/branches/eam_branches/ipp-20150112/Ohana/src merged eligible /branches/eam_branches/ipp-20150405/Ohana/src merged eligible /trunk/Ohana/src merged eligible
-
Property svn:mergeinfo
set to
-
branches/eam_branches/ipp-20150419/Ohana/src/checkastro/src/bcatalog.c
r37807 r38447 408 408 subcatalog[0].Nmeasure = Nmeasure; 409 409 subcatalog[0].Nsecfilt = oldcatalog[0].Nsecfilt; 410 subcatalog[0].Nsecf _mem = Naverage * oldcatalog[0].Nsecfilt;410 subcatalog[0].Nsecfilt_mem = Naverage * oldcatalog[0].Nsecfilt; 411 411 412 412 return (TRUE); … … 515 515 subcatalog[0].Nmeasure = Nmeasure; 516 516 subcatalog[0].Nsecfilt = oldcatalog[0].Nsecfilt; 517 subcatalog[0].Nsecf _mem = Naverage * oldcatalog[0].Nsecfilt;517 subcatalog[0].Nsecfilt_mem = Naverage * oldcatalog[0].Nsecfilt; 518 518 519 519 return (TRUE); … … 609 609 subcatalog[0].Nmeasure = Nmeasure; 610 610 subcatalog[0].Nsecfilt = catalog[0].Nsecfilt; 611 subcatalog[0].Nsecf _mem = Naverage * catalog[0].Nsecfilt;611 subcatalog[0].Nsecfilt_mem = Naverage * catalog[0].Nsecfilt; 612 612 613 613 return (TRUE); -
branches/eam_branches/ipp-20150419/Ohana/src/checkastro/src/checkastro_images.c
r36833 r38447 11 11 /* register database handle with shutdown procedure */ 12 12 set_db (&db); 13 gfits_db_init (&db); 13 14 14 15 /* lock and load the image db table */ -
branches/eam_branches/ipp-20150419/Ohana/src/checkastro/src/load_catalogs.c
r36833 r38447 35 35 pcatalog->catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 36 36 pcatalog->catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 37 pcatalog->catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF; // don't need to load all data at this point37 pcatalog->catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; // don't need to load all data at this point 38 38 pcatalog->Nsecfilt = GetPhotcodeNsecfilt (); 39 39 … … 43 43 exit (1); 44 44 } 45 if (!pcatalog[0].Nave s_disk) {45 if (!pcatalog[0].Naverage_disk) { 46 46 if (VERBOSE2) fprintf (stderr, "no data in %s, skipping\n", pcatalog[0].filename); 47 47 dvo_catalog_unlock (pcatalog); -
branches/eam_branches/ipp-20150419/Ohana/src/checkastro/src/load_images.c
r37807 r38447 10 10 11 11 // convert database table to internal structure 12 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);12 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 13 13 if (!image) { 14 14 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/delete_duplicate_images.c
r36833 r38447 16 16 Image *image, *outimage; 17 17 18 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);18 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 19 19 if (!image) { 20 20 fprintf (stderr, "ERROR: failed to read images\n"); … … 61 61 62 62 fprintf (stderr, "removing "OFF_T_FMT" images (leaving "OFF_T_FMT" of "OFF_T_FMT")\n", Nimage - Noutimage, Noutimage, Nimage); 63 // gfits_table_set_Image (&db[0].ftable, outimage, Noutimage );63 // gfits_table_set_Image (&db[0].ftable, outimage, Noutimage, TRUE); 64 64 65 65 gfits_modify (&db[0].theader, "NAXIS2", OFF_T_FMT, 1, Noutimage); … … 110 110 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 111 111 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 112 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;112 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 113 113 114 114 if (VERBOSE) fprintf (stderr, "deleting from %s\n", catalog.filename); … … 119 119 exit (2); 120 120 } 121 if (!catalog.Nave s_disk) {121 if (!catalog.Naverage_disk) { 122 122 if (VERBOSE2) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 123 123 dvo_catalog_unlock (&catalog); -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/delete_duplicate_measures.c
r37807 r38447 45 45 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 46 46 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 47 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;47 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 48 48 49 49 if (VERBOSE) fprintf (stderr, "deleting from %s\n", catalog.filename); … … 54 54 exit (2); 55 55 } 56 if (!catalog.Nave s_disk) {56 if (!catalog.Naverage_disk) { 57 57 if (VERBOSE2) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 58 58 dvo_catalog_unlock (&catalog); -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/delete_fix_LAP.c
r35807 r38447 43 43 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 44 44 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 45 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;45 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 46 46 47 47 if (VERBOSE) fprintf (stderr, "deleting from %s\n", catalog.filename); … … 52 52 exit (2); 53 53 } 54 if (!catalog.Nave s_disk) {54 if (!catalog.Naverage_disk) { 55 55 if (VERBOSE2) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 56 56 dvo_catalog_unlock (&catalog); -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/delete_fix_LAP_edges.c
r37040 r38447 51 51 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 52 52 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 53 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;53 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 54 54 55 55 if (VERBOSE) fprintf (stderr, "deleting from %s\n", catalog.filename); … … 60 60 exit (2); 61 61 } 62 if (!catalog.Nave s_disk) {62 if (!catalog.Naverage_disk) { 63 63 if (VERBOSE2) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 64 64 dvo_catalog_unlock (&catalog); -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/delete_fix_LAP_edges_delete.c
r35805 r38447 91 91 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 92 92 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 93 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;93 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 94 94 95 95 if (VERBOSE) fprintf (stderr, "deleting from %s\n", catalog.filename); … … 100 100 exit (2); 101 101 } 102 if (!catalog.Nave s_disk) {102 if (!catalog.Naverage_disk) { 103 103 if (VERBOSE2) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 104 104 dvo_catalog_unlock (&catalog); -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/delete_image_photcodes.c
r34749 r38447 12 12 PhotCode **photcodes = ParsePhotcodeList (PHOTCODE_LIST, &Nphotcodes, FALSE); 13 13 14 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);14 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 15 15 if (!image) { 16 16 fprintf (stderr, "ERROR: failed to read images\n"); … … 33 33 34 34 if (VERBOSE) fprintf (stderr, "removing "OFF_T_FMT" images (leaving "OFF_T_FMT" of "OFF_T_FMT")\n", Nimage - Noutimage, Noutimage, Nimage); 35 // gfits_table_set_Image (&db[0].ftable, outimage, Noutimage );35 // gfits_table_set_Image (&db[0].ftable, outimage, Noutimage, TRUE); 36 36 37 37 gfits_modify (&db[0].theader, "NAXIS2", OFF_T_FMT, 1, Noutimage); -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/delete_imagefile.c
r34749 r38447 26 26 catalog.filename = sky[0].filename[i]; /* don't free region before catalog! */ 27 27 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 28 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;28 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 29 29 30 30 // an error exit status here is a significant error … … 33 33 exit (2); 34 34 } 35 if (!catalog.Nave s_disk) {35 if (!catalog.Naverage_disk) { 36 36 dvo_catalog_unlock (&catalog); 37 37 dvo_catalog_free (&catalog); -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/delete_imagename.c
r37807 r38447 18 18 SkyTableSetFilenames (sky, CATDIR, "cpt"); 19 19 20 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);20 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 21 21 if (!image) { 22 22 fprintf (stderr, "ERROR: failed to read images\n"); … … 41 41 catalog.filename = skylist[0].filename[i]; /* don't free region before catalog! */ 42 42 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 43 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;43 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 44 44 45 45 // an error exit status here is a significant error … … 48 48 exit (2); 49 49 } 50 if (!catalog.Nave s_disk) {50 if (!catalog.Naverage_disk) { 51 51 dvo_catalog_unlock (&catalog); 52 52 dvo_catalog_free (&catalog); … … 82 82 83 83 if (VERBOSE) fprintf (stderr, "removing "OFF_T_FMT" images (leaving "OFF_T_FMT" of "OFF_T_FMT")\n", Nimlist, Noutimage, Nimage); 84 // gfits_table_set_Image (&db[0].ftable, outimage, Noutimage );84 // gfits_table_set_Image (&db[0].ftable, outimage, Noutimage, TRUE); 85 85 86 86 gfits_modify (&db[0].theader, "NAXIS2", OFF_T_FMT, 1, Noutimage); -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/delete_orphans.c
r27435 r38447 252 252 catalog.Nmeasure = Nmeas; 253 253 catalog.Nmissing = Nmiss; 254 catalog.Nsecf _mem = Nave*Nsecfilt;254 catalog.Nsecfilt_mem = Nave*Nsecfilt; 255 255 256 256 if (VERBOSE) fprintf (stderr, " ending with Nave, Nmeas, Nmiss: %d %d %d\n", Nave, Nmeas, Nmiss); -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/delete_photcodes.c
r35758 r38447 41 41 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 42 42 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 43 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;43 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 44 44 45 45 if (VERBOSE) fprintf (stderr, "deleting from %s\n", catalog.filename); … … 50 50 exit (2); 51 51 } 52 if (!catalog.Nave s_disk) {52 if (!catalog.Naverage_disk) { 53 53 if (VERBOSE2) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 54 54 dvo_catalog_unlock (&catalog); -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/delete_photcodes_single.c
r35107 r38447 10 10 catalog.filename = cptname; 11 11 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 12 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;12 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 13 13 14 14 if (VERBOSE) fprintf (stderr, "deleting from %s\n", catalog.filename); … … 19 19 return FALSE; 20 20 } 21 if (!catalog.Nave s_disk) {21 if (!catalog.Naverage_disk) { 22 22 if (VERBOSE2) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 23 23 dvo_catalog_unlock (&catalog); -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/delete_times.c
r37807 r38447 25 25 skylist[0].ownElements = FALSE; // free these elements when freeing the list 26 26 27 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);27 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 28 28 if (!image) { 29 29 fprintf (stderr, "ERROR: failed to read images\n"); … … 62 62 catalog.filename = skylist[0].filename[i]; /* don't free region before catalog! */ 63 63 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 64 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;64 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 65 65 66 66 // an error exit status here is a significant error … … 69 69 exit (2); 70 70 } 71 if (!catalog.Nave s_disk) {71 if (!catalog.Naverage_disk) { 72 72 dvo_catalog_unlock (&catalog); 73 73 dvo_catalog_free (&catalog); -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/delstar.c
r35837 r38447 12 12 if (!SKIP_IMAGES) { 13 13 set_db (&db); 14 gfits_db_init (&db); 14 15 status = dvo_image_lock (&db, ImageCat, 60.0, LCK_XCLD); /* XCLD */ 15 16 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); … … 30 31 case MODE_FIX_LAP: { 31 32 off_t Nimage; 32 Image *image = gfits_table_get_Image (&db.ftable, &Nimage, &db.s wapped);33 Image *image = gfits_table_get_Image (&db.ftable, &Nimage, &db.scaledValue, &db.nativeOrder); 33 34 if (!image) { 34 35 fprintf (stderr, "ERROR: failed to read images\n"); … … 67 68 case MODE_FIX_LAP_STATS: { 68 69 off_t Nimage; 69 Image *image = gfits_table_get_Image (&db.ftable, &Nimage, &db.s wapped);70 Image *image = gfits_table_get_Image (&db.ftable, &Nimage, &db.scaledValue, &db.nativeOrder); 70 71 if (!image) { 71 72 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/find_image_db.c
r29001 r38447 16 16 } 17 17 18 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);18 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 19 19 if (!image) { 20 20 fprintf (stderr, "ERROR: failed to read images\n"); … … 46 46 int code; 47 47 48 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);48 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 49 49 50 50 start = timage[0].tzero - MAX(0.01*timage[0].trate*timage[0].NY, 1); … … 76 76 Image *image; 77 77 78 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);78 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 79 79 80 80 Nlist = 0; -
branches/eam_branches/ipp-20150419/Ohana/src/delstar/src/find_matches.c
r34088 r38447 245 245 catalog[0].Nmeasure = Nmeas; 246 246 catalog[0].Nmissing = Nmiss; 247 catalog[0].Nsecf _mem = Nave*Nsecfilt;247 catalog[0].Nsecfilt_mem = Nave*Nsecfilt; 248 248 249 249 if (VERBOSE) fprintf (stderr, " ending with Nave, Nmeas, Nmiss: "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT"\n", Nave, Nmeas, Nmiss); -
branches/eam_branches/ipp-20150419/Ohana/src/dvolens/src/update_objects.c
r37358 r38447 61 61 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 62 62 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 63 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF | LOAD_LENSING |LOAD_LENSOBJ;63 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ; 64 64 catalog.Nsecfilt = GetPhotcodeNsecfilt (); // set the desired number in case we need to create the catalog 65 65 … … 68 68 exit (1); 69 69 } 70 if (VERBOSE && (catalog.Nave s_disk == 0)) {70 if (VERBOSE && (catalog.Naverage_disk == 0)) { 71 71 fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 72 72 dvo_catalog_unlock (&catalog); -
branches/eam_branches/ipp-20150419/Ohana/src/dvopsps/src/insert_FWobjects_dvopsps.c
r37672 r38447 53 53 catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs 54 54 catalog.catmode = DVO_MODE_UNDEF; // not needed since we skip empty catalogs 55 catalog.catflags = LOAD_AVES | LOAD_SECF |LOAD_LENSOBJ;55 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT | DVO_LOAD_LENSOBJ; 56 56 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 57 57 … … 60 60 exit (1); 61 61 } 62 if (!catalog.Nave s_disk) {62 if (!catalog.Naverage_disk) { 63 63 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 64 64 dvo_catalog_unlock (&catalog); -
branches/eam_branches/ipp-20150419/Ohana/src/dvopsps/src/insert_detections_dvopsps.c
r37361 r38447 65 65 catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs 66 66 catalog.catmode = DVO_MODE_UNDEF; // not needed since we skip empty catalogs 67 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;67 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 68 68 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 69 69 … … 72 72 exit (1); 73 73 } 74 if (!catalog.Nave s_disk) {74 if (!catalog.Naverage_disk) { 75 75 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 76 76 dvo_catalog_unlock (&catalog); … … 138 138 } 139 139 140 char command[1024];141 s nprintf (command, 1024, "dvopsps_client detections -hostID %d -catdir %s -hostdir %s -region %f %f %f %f",140 char *command = NULL; 141 strextend (&command, "dvopsps_client detections -hostID %d -catdir %s -hostdir %s -region %f %f %f %f", 142 142 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, 143 143 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 144 144 145 char tmpline[1024]; 146 snprintf (tmpline, 1024, "%s -dbhost %s", command, DATABASE_HOST); strcpy (command, tmpline); 147 snprintf (tmpline, 1024, "%s -dbuser %s", command, DATABASE_USER); strcpy (command, tmpline); 148 snprintf (tmpline, 1024, "%s -dbpass %s", command, DATABASE_PASS); strcpy (command, tmpline); 149 snprintf (tmpline, 1024, "%s -dbname %s", command, DATABASE_NAME); strcpy (command, tmpline); 150 151 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 152 if (SAVE_REMOTE) { snprintf (tmpline, 1024, "%s -save %s", command, table->hosts[i].results); strcpy (command, tmpline); } 145 strextend (&command, "-dbhost %s", DATABASE_HOST); 146 strextend (&command, "-dbuser %s", DATABASE_USER); 147 strextend (&command, "-dbpass %s", DATABASE_PASS); 148 strextend (&command, "-dbname %s", DATABASE_NAME); 149 150 if (VERBOSE) { strextend (&command, "-v");} 151 if (SAVE_REMOTE) { strextend (&command, "-save %s", table->hosts[i].results);} 153 152 154 153 // some filters -- these are the detections we skip 155 if (TIME_START) { s nprintf (tmpline, 1024, "%s -time-start %s", command, TIME_START); strcpy (command, tmpline); }156 if (TIME_END) { s nprintf (tmpline, 1024, "%s -time-end %s", command, TIME_END); strcpy (command, tmpline); }154 if (TIME_START) { strextend (&command, "-time-start %s", TIME_START);} 155 if (TIME_END) { strextend (&command, "-time-end %s", TIME_END);} 157 156 158 if (PHOTCODE_START > 0) { s nprintf (tmpline, 1024, "%s -photcode-start %d", command, PHOTCODE_START); strcpy (command, tmpline); }159 if (PHOTCODE_END <= INT_MAX) { s nprintf (tmpline, 1024, "%s -photcode-end %d", command, PHOTCODE_END); strcpy (command, tmpline); }157 if (PHOTCODE_START > 0) { strextend (&command, "-photcode-start %d", PHOTCODE_START);} 158 if (PHOTCODE_END <= INT_MAX) { strextend (&command, "-photcode-end %d", PHOTCODE_END);} 160 159 161 160 fprintf (stderr, "command: %s\n", command); -
branches/eam_branches/ipp-20150419/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c
r37807 r38447 215 215 fprintf (stderr, "%s\n", mysql_error(mysql)); 216 216 fprintf (stderr, "Nbuffer: %d\n", buffer->Nbuffer); 217 if (DEBUG) fprintf (stderr, "%s\n", buffer->buffer); 217 if (DEBUG) { 218 FILE *f = fopen ("dvopsps.dump.sql", "w"); 219 fprintf (f, "%s\n", buffer->buffer); 220 fclose (f); 221 } 218 222 status = FALSE; 219 223 } -
branches/eam_branches/ipp-20150419/Ohana/src/dvopsps/src/insert_diffobj_dvopsps.c
r37923 r38447 53 53 catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs 54 54 catalog.catmode = DVO_MODE_UNDEF; // not needed since we skip empty catalogs 55 catalog.catflags = LOAD_AVES | LOAD_SECF;55 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 56 56 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 57 57 … … 60 60 exit (1); 61 61 } 62 if (!catalog.Nave s_disk) {62 if (!catalog.Naverage_disk) { 63 63 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 64 64 dvo_catalog_unlock (&catalog); … … 126 126 table->hosts[i].pathname = tmppath; 127 127 128 char command[1024];129 s nprintf (command, 1024, "dvopsps_client diffobj -hostID %d -catdir %s -hostdir %s -region %f %f %f %f",128 char *command = NULL; 129 strextend (&command, "dvopsps_client diffobj -hostID %d -catdir %s -hostdir %s -region %f %f %f %f", 130 130 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, 131 131 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 132 132 133 char tmpline[1024]; 134 snprintf (tmpline, 1024, "%s -dbhost %s", command, DATABASE_HOST); strcpy (command, tmpline); 135 snprintf (tmpline, 1024, "%s -dbuser %s", command, DATABASE_USER); strcpy (command, tmpline); 136 snprintf (tmpline, 1024, "%s -dbpass %s", command, DATABASE_PASS); strcpy (command, tmpline); 137 snprintf (tmpline, 1024, "%s -dbname %s", command, DATABASE_NAME); strcpy (command, tmpline); 133 strextend (&command, "-dbhost %s", DATABASE_HOST); 134 strextend (&command, "-dbuser %s", DATABASE_USER); 135 strextend (&command, "-dbpass %s", DATABASE_PASS); 136 strextend (&command, "-dbname %s", DATABASE_NAME); 138 137 139 if (VERBOSE) { s nprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); }140 if (SINGLE_CPT) { s nprintf (tmpline, 1024, "%s -cpt %s", command, SINGLE_CPT); strcpy (command, tmpline); }138 if (VERBOSE) { strextend (&command, "-v"); } 139 if (SINGLE_CPT) { strextend (&command, "-cpt %s", SINGLE_CPT); } 141 140 142 141 fprintf (stderr, "command: %s\n", command); -
branches/eam_branches/ipp-20150419/Ohana/src/dvopsps/src/insert_objects_dvopsps.c
r37361 r38447 53 53 catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs 54 54 catalog.catmode = DVO_MODE_UNDEF; // not needed since we skip empty catalogs 55 catalog.catflags = LOAD_AVES | LOAD_SECF;55 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 56 56 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 57 57 … … 60 60 exit (1); 61 61 } 62 if (!catalog.Nave s_disk) {62 if (!catalog.Naverage_disk) { 63 63 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 64 64 dvo_catalog_unlock (&catalog); … … 126 126 table->hosts[i].pathname = tmppath; 127 127 128 char command[1024];129 s nprintf (command, 1024, "dvopsps_client objects -hostID %d -catdir %s -hostdir %s -region %f %f %f %f",128 char *command = NULL; 129 strextend (&command, "dvopsps_client objects -hostID %d -catdir %s -hostdir %s -region %f %f %f %f", 130 130 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, 131 131 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 132 132 133 char tmpline[1024]; 134 snprintf (tmpline, 1024, "%s -dbhost %s", command, DATABASE_HOST); strcpy (command, tmpline); 135 snprintf (tmpline, 1024, "%s -dbuser %s", command, DATABASE_USER); strcpy (command, tmpline); 136 snprintf (tmpline, 1024, "%s -dbpass %s", command, DATABASE_PASS); strcpy (command, tmpline); 137 snprintf (tmpline, 1024, "%s -dbname %s", command, DATABASE_NAME); strcpy (command, tmpline); 133 strextend (&command, "-dbhost %s", DATABASE_HOST); 134 strextend (&command, "-dbuser %s", DATABASE_USER); 135 strextend (&command, "-dbpass %s", DATABASE_PASS); 136 strextend (&command, "-dbname %s", DATABASE_NAME); 138 137 139 if (VERBOSE) { s nprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); }140 if (SINGLE_CPT) { s nprintf (tmpline, 1024, "%s -cpt %s", command, SINGLE_CPT); strcpy (command, tmpline); }138 if (VERBOSE) { strextend (&command, "-v"); } 139 if (SINGLE_CPT) { strextend (&command, "-cpt %s", SINGLE_CPT); } 141 140 142 141 fprintf (stderr, "command: %s\n", command); -
branches/eam_branches/ipp-20150419/Ohana/src/dvosplit/src/dvosplit.c
r37043 r38447 80 80 incatalog.filename = skylist[0].filename[i]; 81 81 incatalog.Nsecfilt = GetPhotcodeNsecfilt (); 82 incatalog.catflags = LOAD_NONE;82 incatalog.catflags = DVO_LOAD_NONE; 83 83 84 84 // an error exit status here is a significant error … … 89 89 90 90 // skip empty input catalogs 91 if (!incatalog.Nave s_disk) {91 if (!incatalog.Naverage_disk) { 92 92 dvo_catalog_unlock (&incatalog); 93 93 dvo_catalog_free (&incatalog); -
branches/eam_branches/ipp-20150419/Ohana/src/dvosplit/src/open_output_catalogs.c
r33656 r38447 14 14 outcatalogs[i].filename = outlist[0].filename[i]; 15 15 outcatalogs[i].Nsecfilt = GetPhotcodeNsecfilt (); 16 outcatalogs[i].catflags = LOAD_NONE;16 outcatalogs[i].catflags = DVO_LOAD_NONE; 17 17 outcatalogs[i].catformat = CATFORMAT ? dvo_catalog_catformat (CATFORMAT) : catformat; // set the default catformat from config data 18 18 outcatalogs[i].catmode = CATMODE ? dvo_catalog_catmode (CATMODE) : catmode; // set the default catmode from config data -
branches/eam_branches/ipp-20150419/Ohana/src/dvosplit/src/split_averages.c
r37807 r38447 10 10 AveLinks *avelinks; 11 11 12 ALLOCATE (outref, int, incatalog[0].Nave s_disk);13 ALLOCATE (outcat, int, incatalog[0].Nave s_disk);12 ALLOCATE (outref, int, incatalog[0].Naverage_disk); 13 ALLOCATE (outcat, int, incatalog[0].Naverage_disk); 14 14 ALLOCATE (outmem, int, outlist[0].Nregions); 15 15 … … 25 25 26 26 // split out the average & secfilt entries: 27 incatalog[0].catflags = LOAD_AVES | LOAD_SECF;27 incatalog[0].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 28 28 29 29 if ((incatalog[0].catmode == DVO_MODE_SPLIT) && !FULL_TABLE) { 30 Nblocks = incatalog[0].Nave s_disk / NROWS;31 if (incatalog[0].Nave s_disk % NROWS) Nblocks ++;30 Nblocks = incatalog[0].Naverage_disk / NROWS; 31 if (incatalog[0].Naverage_disk % NROWS) Nblocks ++; 32 32 } else { 33 33 Nblocks = 1; … … 40 40 dvo_catalog_load_segment (incatalog, VERBOSE, block*NROWS, NROWS); 41 41 fprintf (stderr, "splitting %s (averages) .. %d of %d\n", incatalog[0].filename, block, Nblocks); 42 assert (block*NROWS == incatalog[0].Nave s_off);42 assert (block*NROWS == incatalog[0].Naverage_off); 43 43 } else { 44 44 dvo_catalog_load (incatalog, VERBOSE); … … 48 48 // distribute data to the output catalogs 49 49 for (ave = 0; ave < incatalog[0].Naverage; ave++) { 50 averef = ave + incatalog[0].Nave s_off;50 averef = ave + incatalog[0].Naverage_off; 51 51 52 52 inR = incatalog[0].average[ave].R; … … 75 75 76 76 Nout = outcatalogs[Ncat].Naverage; 77 outref[averef] = Nout + outcatalogs[Ncat].Nave s_off;77 outref[averef] = Nout + outcatalogs[Ncat].Naverage_off; 78 78 outcat[averef] = Ncat; 79 79 … … 85 85 for (n = 0; n < Nsecfilt; n++) { 86 86 outcatalogs[Ncat].secfilt[Nout*Nsecfilt + n] = incatalog[0].secfilt[ave*Nsecfilt + n]; 87 outcatalogs[Ncat].Nsecf _mem++;87 outcatalogs[Ncat].Nsecfilt_mem++; 88 88 } 89 89 … … 96 96 dvo_catalog_free_data (incatalog); 97 97 98 // double check the values of Naverage, Nsecf _mem?98 // double check the values of Naverage, Nsecfilt_mem? 99 99 100 100 // XXX for output.catformat == MEF, we probably need to skip this stuff and the free below … … 103 103 if (!FULL_TABLE) { 104 104 for (cat = 0; cat < outlist[0].Nregions; cat++) { 105 outcatalogs[cat].catflags = LOAD_AVES | LOAD_SECF;105 outcatalogs[cat].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 106 106 107 107 dvo_catalog_save (&outcatalogs[cat], VERBOSE); 108 // fprintf (stderr, "secfilt: %d %d %d %d\n", outcatalogs[cat].Nsecf _mem, outcatalogs[cat].Nsecf_disk, outcatalogs[cat].Nsecf_off, outcatalogs[cat].Naverage, outcatalogs[cat].Nsecfilt);108 // fprintf (stderr, "secfilt: %d %d %d %d\n", outcatalogs[cat].Nsecfilt_mem, outcatalogs[cat].Nsecfilt_disk, outcatalogs[cat].Nsecfilt_off, outcatalogs[cat].Naverage, outcatalogs[cat].Nsecfilt); 109 109 110 110 // advance the pointers and free the current data 111 111 // XXX these should be done within save segment: 112 outcatalogs[cat].Nave s_disk += outcatalogs[cat].Naverage;113 outcatalogs[cat].Nave s_off += outcatalogs[cat].Naverage;114 outcatalogs[cat].Nsecf _disk += outcatalogs[cat].Nsecfilt * outcatalogs[cat].Naverage;115 outcatalogs[cat].Nsecf _off += outcatalogs[cat].Nsecfilt * outcatalogs[cat].Naverage;112 outcatalogs[cat].Naverage_disk += outcatalogs[cat].Naverage; 113 outcatalogs[cat].Naverage_off += outcatalogs[cat].Naverage; 114 outcatalogs[cat].Nsecfilt_disk += outcatalogs[cat].Nsecfilt * outcatalogs[cat].Naverage; 115 outcatalogs[cat].Nsecfilt_off += outcatalogs[cat].Nsecfilt * outcatalogs[cat].Naverage; 116 116 outcatalogs[cat].Nsecfilt = Nsecfilt; 117 117 118 118 outcatalogs[cat].Naverage = 0; 119 outcatalogs[cat].Nsecf _mem = 0;119 outcatalogs[cat].Nsecfilt_mem = 0; 120 120 } 121 121 } -
branches/eam_branches/ipp-20150419/Ohana/src/dvosplit/src/split_measures.c
r37807 r38447 19 19 20 20 // split out the measure entries: 21 incatalog[0].catflags = LOAD_MEAS | LOAD_AVES | LOAD_SECF;21 incatalog[0].catflags = DVO_LOAD_MEASURE | DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 22 22 23 23 // if ((incatalog[0].catformat == DVO_FORMAT_ELIXIR) || (incatalog[0].catformat == DVO_FORMAT_LONEOS)) { 24 24 // // for these two formats, we need the average and secfilt values around until we do the measures... 25 25 // // XXX I am loading these 2x -- perhaps I can make the API smarter about reloading? 26 // incatalog[0].catflags |= LOAD_AVES | LOAD_SECF;26 // incatalog[0].catflags |= DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 27 27 // } 28 28 29 29 if ((incatalog[0].catmode == DVO_MODE_SPLIT) && !FULL_TABLE) { 30 Nblocks = incatalog[0].Nmeas _disk / NROWS;31 if (incatalog[0].Nmeas _disk % NROWS) Nblocks ++;30 Nblocks = incatalog[0].Nmeasure_disk / NROWS; 31 if (incatalog[0].Nmeasure_disk % NROWS) Nblocks ++; 32 32 } else { 33 33 Nblocks = 1; … … 40 40 dvo_catalog_load_segment (incatalog, VERBOSE, block*NROWS, NROWS); 41 41 fprintf (stderr, "splitting %s (measures) .. %d of %d\n", incatalog[0].filename, block, Nblocks); 42 assert (block*NROWS == incatalog[0].Nmeas _off);42 assert (block*NROWS == incatalog[0].Nmeasure_off); 43 43 } else { 44 44 dvo_catalog_load (incatalog, VERBOSE); … … 72 72 if (!FULL_TABLE) { 73 73 for (cat = 0; cat < outlist[0].Nregions; cat++) { 74 outcatalogs[cat].catflags = LOAD_MEAS;74 outcatalogs[cat].catflags = DVO_LOAD_MEASURE; 75 75 dvo_catalog_save (&outcatalogs[cat], VERBOSE); 76 76 77 outcatalogs[cat].Nmeas _disk += outcatalogs[cat].Nmeasure;78 outcatalogs[cat].Nmeas _off += outcatalogs[cat].Nmeasure;77 outcatalogs[cat].Nmeasure_disk += outcatalogs[cat].Nmeasure; 78 outcatalogs[cat].Nmeasure_off += outcatalogs[cat].Nmeasure; 79 79 outcatalogs[cat].Nmeasure = 0; 80 80 } … … 84 84 if (FULL_TABLE) { 85 85 for (cat = 0; cat < outlist[0].Nregions; cat++) { 86 outcatalogs[cat].catflags = LOAD_AVES | LOAD_SECF | LOAD_MEAS;86 outcatalogs[cat].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT | DVO_LOAD_MEASURE; 87 87 dvo_catalog_save (&outcatalogs[cat], VERBOSE); 88 88 } -
branches/eam_branches/ipp-20150419/Ohana/src/dvosplit/src/split_missings.c
r15743 r38447 15 15 16 16 // split out the missing entries: 17 incatalog[0].catflags = LOAD_MISS;18 Nblocks = incatalog[0].Nmiss _disk / NROWS;19 if (incatalog[0].Nmiss _disk % NROWS) Nblocks ++;17 incatalog[0].catflags = DVO_LOAD_MISSING; 18 Nblocks = incatalog[0].Nmissing_disk / NROWS; 19 if (incatalog[0].Nmissing_disk % NROWS) Nblocks ++; 20 20 for (block = 0; block < Nblocks; block++) { 21 21 … … 35 35 36 36 for (cat = 0; cat < outlist[0].Nregions; cat++) { 37 outcatalogs[cat].catflags = LOAD_MISS;37 outcatalogs[cat].catflags = DVO_LOAD_MISSING; 38 38 dvo_catalog_save_segment (&outcatalog[cat], VERBOSE); 39 39 40 outcatalog[cat].Nmiss _disk += outcatalog[cat].Nmissing;41 outcatalog[cat].Nmiss _off += outcatalog[cat].Nmissing;40 outcatalog[cat].Nmissing_disk += outcatalog[cat].Nmissing; 41 outcatalog[cat].Nmissing_off += outcatalog[cat].Nmissing; 42 42 outcatalog[cat].Nmissing = 0; 43 43 -
branches/eam_branches/ipp-20150419/Ohana/src/fakeastro/include/fakeastro.h
r37807 r38447 149 149 double int_gauss (int i); 150 150 151 int strextend (char *input, char *format,...);152 153 151 int fakeastro_images (); 154 152 Image *load_template_images (int *nimage); -
branches/eam_branches/ipp-20150419/Ohana/src/fakeastro/src/fakeastro_2mass.c
r37807 r38447 21 21 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 22 22 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 23 catalog.catflags = LOAD_AVES | LOAD_SECF | LOAD_MEAS |LOAD_STARPAR;23 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT | DVO_LOAD_MEASURE | DVO_LOAD_STARPAR; 24 24 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 25 25 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) { … … 27 27 exit (1); 28 28 } 29 if (!catalog.Nave s_disk) {29 if (!catalog.Naverage_disk) { 30 30 if (VERBOSE2) { fprintf (stderr, "no data in %s, skipping\n", catalog.filename); } 31 31 dvo_catalog_unlock (&catalog); -
branches/eam_branches/ipp-20150419/Ohana/src/fakeastro/src/fakeastro_images.c
r37807 r38447 67 67 68 68 /* setup image table format and lock */ 69 gfits_db_init (db); 69 70 db->mode = dvo_catalog_catmode (CATMODE); 70 71 db->format = dvo_catalog_catformat (CATFORMAT); -
branches/eam_branches/ipp-20150419/Ohana/src/fakeastro/src/fakestar_catalog.c
r37807 r38447 9 9 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 10 10 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 11 catalog.catflags = LOAD_AVES | LOAD_SECF |LOAD_STARPAR;11 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT | DVO_LOAD_STARPAR; 12 12 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 13 13 -
branches/eam_branches/ipp-20150419/Ohana/src/fakeastro/src/insert_fakestar.c
r38319 r38447 118 118 catalog[0].Naverage = Nave; 119 119 catalog[0].Nstarpar = Nstarpar; 120 catalog[0].Nsecf _mem = Nave*Nsecfilt;120 catalog[0].Nsecfilt_mem = Nave*Nsecfilt; 121 121 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nstarpar: %d "OFF_T_FMT" "OFF_T_FMT" ("OFF_T_FMT" matches)\n", Nstars, Nave, Nstarpar, Nmatch); 122 122 -
branches/eam_branches/ipp-20150419/Ohana/src/fakeastro/src/load_fake_stars.c
r37807 r38447 15 15 catalog[i].catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 16 16 catalog[i].catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 17 catalog[i].catflags = LOAD_AVES | LOAD_SECF |LOAD_STARPAR;17 catalog[i].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT | DVO_LOAD_STARPAR; 18 18 catalog[i].Nsecfilt = GetPhotcodeNsecfilt (); 19 19 if (!dvo_catalog_open (&catalog[i], skylist[0].regions[i], VERBOSE, "r")) { … … 23 23 dvo_catalog_unlock (&catalog[i]); 24 24 25 if (!catalog[i].Nave s_disk) {25 if (!catalog[i].Naverage_disk) { 26 26 if (VERBOSE2) { fprintf (stderr, "no data in %s, skipping\n", catalog[i].filename); } 27 27 dvo_catalog_free (&catalog[i]); -
branches/eam_branches/ipp-20150419/Ohana/src/fakeastro/src/load_template_images.c
r37807 r38447 5 5 FITS_DB db; 6 6 7 gfits_db_init (&db); 7 8 db.mode = dvo_catalog_catmode (CATMODE); 8 9 db.format = dvo_catalog_catformat (CATFORMAT); … … 24 25 25 26 off_t Nimage; 26 Image *image = gfits_table_get_Image (&db.ftable, &Nimage, &db.s wapped);27 Image *image = gfits_table_get_Image (&db.ftable, &Nimage, &db.scaledValue, &db.nativeOrder); 27 28 if (!image) { 28 29 fprintf (stderr, "ERROR: no template images in %s (though db exists)\n", IMAGES_INPUT); -
branches/eam_branches/ipp-20150419/Ohana/src/fakeastro/src/match_fake_stars.c
r38319 r38447 282 282 catalog[0].Nmeasure = Nmeas; 283 283 catalog[0].Nstarpar = Nstarpar; 284 catalog[0].Nsecf _mem = Nave*Nsecfilt;284 catalog[0].Nsecfilt_mem = Nave*Nsecfilt; 285 285 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas, Nmatch); 286 286 -
branches/eam_branches/ipp-20150419/Ohana/src/fakeastro/src/save_fake_stars.c
r37807 r38447 23 23 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 24 24 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 25 // catalog.catflags = LOAD_AVES | LOAD_SECF | LOAD_MEAS |LOAD_STARPAR; // use this for non-update mode26 catalog.catflags = LOAD_AVES | LOAD_SECF |LOAD_STARPAR;25 // catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT | DVO_LOAD_MEASURE | DVO_LOAD_STARPAR; // use this for non-update mode 26 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT | DVO_LOAD_STARPAR; 27 27 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 28 28 -
branches/eam_branches/ipp-20150419/Ohana/src/fakeastro/src/save_fakestars.c
r37807 r38447 48 48 49 49 // need to generate the remote command 50 char command[1024];51 s nprintf (command, 1024, "fakestar_client");52 strextend ( command, "-galaxy");53 strextend ( command, "-hostID %d", host->hostID);54 strextend ( command, "-D CATDIR %s", CATDIR);55 strextend ( command, "-hostdir %s", host->pathname);56 strextend ( command, "-cpt %s", region->name);57 strextend ( command, "-input %s", filename);50 char *command = NULL; 51 strextend (&command, "fakestar_client"); 52 strextend (&command, "-galaxy"); 53 strextend (&command, "-hostID %d", host->hostID); 54 strextend (&command, "-D CATDIR %s", CATDIR); 55 strextend (&command, "-hostdir %s", host->pathname); 56 strextend (&command, "-cpt %s", region->name); 57 strextend (&command, "-input %s", filename); 58 58 59 59 // launch the job on the remote machine (no handshake) … … 70 70 return TRUE; 71 71 } 72 73 int strextend (char *input, char *format,...) {74 75 char tmpextra[1024], tmpline[1024];76 va_list argp;77 78 va_start (argp, format);79 vsnprintf (tmpextra, 1024, format, argp);80 snprintf (tmpline, 1024, "%s %s", input, tmpextra);81 strcpy (input, tmpline);82 83 return TRUE;84 } -
branches/eam_branches/ipp-20150419/Ohana/src/gastro/src/getptolemy.c
r25757 r38447 26 26 // set the parameters which guide catalog open/load/create 27 27 catalog.filename = skylist[0].filename[i]; 28 catalog.catflags = LOAD_AVES | LOAD_MEAS;28 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE; 29 29 catalog.Nsecfilt = 0; 30 30 … … 36 36 dvo_catalog_unlock (&catalog); 37 37 38 // Nave s_disk == 0 implies an empty catalog file38 // Naverage_disk == 0 implies an empty catalog file 39 39 // for only_match, skip empty catalogs 40 if (!catalog.Nave s_disk) {40 if (!catalog.Naverage_disk) { 41 41 dvo_catalog_free (&catalog); 42 42 continue; -
branches/eam_branches/ipp-20150419/Ohana/src/gastro2/src/getptolemy.c
r25757 r38447 28 28 // set the parameters which guide catalog open/load/create 29 29 catalog.filename = skylist[0].filename[i]; 30 catalog.catflags = LOAD_AVES | LOAD_MEAS;30 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE; 31 31 catalog.Nsecfilt = 0; 32 32 … … 38 38 dvo_catalog_unlock (&catalog); 39 39 40 // Nave s_disk == 0 implies an empty catalog file40 // Naverage_disk == 0 implies an empty catalog file 41 41 // for only_match, skip empty catalogs 42 if (!catalog.Nave s_disk) {42 if (!catalog.Naverage_disk) { 43 43 dvo_catalog_free (&catalog); 44 44 continue; -
branches/eam_branches/ipp-20150419/Ohana/src/gastro2/src/rfits.c
r29001 r38447 14 14 if (!gfits_fread_ftable (f, &table, "SMPFILE")) goto escape; 15 15 16 stars = gfits_table_get_SMPData (&table, &Nstars, NULL );16 stars = gfits_table_get_SMPData (&table, &Nstars, NULL, NULL); 17 17 if (!stars) { 18 18 fprintf (stderr, "ERROR: failed to read stars\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/getstar/src/WriteImageFITS.c
r14590 r38447 36 36 37 37 table.header = &theader; 38 gfits_table_set_SMPData (&table, NULL, Nstars );38 gfits_table_set_SMPData (&table, NULL, Nstars, TRUE); 39 39 gfits_fwrite_Theader (f, &theader); 40 40 gfits_fwrite_table (f, &table); -
branches/eam_branches/ipp-20150419/Ohana/src/getstar/src/dvoImageExtract.c
r29001 r38447 14 14 /*** update the image table ***/ 15 15 /* setup image table format and lock */ 16 gfits_db_init (&db); 16 17 db.mode = dvo_catalog_catmode (CATMODE); 17 18 db.format = dvo_catalog_catformat (CATFORMAT); … … 31 32 32 33 // convert database table to internal structure 33 images = gfits_table_get_Image (&db.ftable, &Nimages, &db.s wapped);34 images = gfits_table_get_Image (&db.ftable, &Nimages, &db.scaledValue, &db.nativeOrder); 34 35 if (!images) { 35 36 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/getstar/src/dvoImageOverlaps.c
r29001 r38447 17 17 /*** update the image table ***/ 18 18 /* setup image table format and lock */ 19 gfits_db_init (&db); 19 20 db.mode = dvo_catalog_catmode (CATMODE); 20 21 db.format = dvo_catalog_catformat (CATFORMAT); … … 34 35 35 36 // convert database table to internal structure 36 dbImages = gfits_table_get_Image (&db.ftable, &NdbImages, &db.s wapped);37 dbImages = gfits_table_get_Image (&db.ftable, &NdbImages, &db.scaledValue, &db.nativeOrder); 37 38 if (!dbImages) { 38 39 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/getstar/src/dvoImagesAtCoords.c
r36131 r38447 43 43 /*** update the image table ***/ 44 44 /* setup image table format and lock */ 45 gfits_db_init (&db); 45 46 db.mode = dvo_catalog_catmode (CATMODE); 46 47 db.format = dvo_catalog_catformat (CATFORMAT); … … 60 61 61 62 // convert database table to internal structure 62 dbImages = gfits_table_get_Image (&db.ftable, &NdbImages, &db.s wapped);63 dbImages = gfits_table_get_Image (&db.ftable, &NdbImages, &db.scaledValue, &db.nativeOrder); 63 64 if (!dbImages) { 64 65 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/getstar/src/getstar.c
r37359 r38447 28 28 output.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 29 29 output.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 30 output.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;30 output.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 31 31 output.Nsecfilt = GetPhotcodeNsecfilt (); 32 32 … … 63 63 catalog.filename = skylist[0].filename[i]; 64 64 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 65 catalog.catflags = LOAD_AVES | LOAD_SECF;66 catalog.catflags |= needMeas ? LOAD_MEAS : SKIP_MEAS;65 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 66 catalog.catflags |= needMeas ? DVO_LOAD_MEASURE : DVO_SKIP_MEASURE; 67 67 68 68 // an error exit status here is a significant error … … 71 71 exit (2); 72 72 } 73 if (!catalog.Nave s_disk) {73 if (!catalog.Naverage_disk) { 74 74 dvo_catalog_unlock (&catalog); 75 75 dvo_catalog_free (&catalog); … … 95 95 catalog.filename = skylist[0].filename[i]; 96 96 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 97 catalog.catflags = LOAD_AVES | LOAD_SECF;98 catalog.catflags |= needMeas ? LOAD_MEAS : SKIP_MEAS;97 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 98 catalog.catflags |= needMeas ? DVO_LOAD_MEASURE : DVO_SKIP_MEASURE; 99 99 100 100 // an error exit status here is a significant error … … 104 104 } 105 105 /* skip empty catalogs */ 106 if (!catalog.Nave s_disk) continue;106 if (!catalog.Naverage_disk) continue; 107 107 stars = select_by_image (&catalog, &image, 0, 0, stars, &Nstars); 108 108 } -
branches/eam_branches/ipp-20150419/Ohana/src/getstar/src/select_by_region.c
r37044 r38447 162 162 output[0].Naverage = Nave; 163 163 output[0].Nmeasure = Nmeas; 164 output[0].Nsecf _mem = Nave*Nsecfilt;164 output[0].Nsecfilt_mem = Nave*Nsecfilt; 165 165 166 166 fprintf (stderr, "output catalog has "OFF_T_FMT" stars ("OFF_T_FMT" measures, %d secfilt)\n", -
branches/eam_branches/ipp-20150419/Ohana/src/getstar/src/write_getstar_ps1_dev_0.c
r37044 r38447 111 111 112 112 ftable.header = &theader; 113 gfits_table_set_Getstar_PS1_DEV_0 (&ftable, output, Noutput );113 gfits_table_set_Getstar_PS1_DEV_0 (&ftable, output, Noutput, TRUE); 114 114 115 115 gfits_fwrite_header (f, &header); -
branches/eam_branches/ipp-20150419/Ohana/src/getstar/src/write_getstar_ps1_dev_1.c
r37044 r38447 114 114 115 115 ftable.header = &theader; 116 gfits_table_set_Getstar_PS1_DEV_1 (&ftable, output, Noutput );116 gfits_table_set_Getstar_PS1_DEV_1 (&ftable, output, Noutput, TRUE); 117 117 118 118 gfits_fwrite_header (f, &header); -
branches/eam_branches/ipp-20150419/Ohana/src/getstar/src/write_getstar_ps1_dev_2.c
r37044 r38447 120 120 121 121 ftable.header = &theader; 122 gfits_table_set_Getstar_PS1_DEV_2 (&ftable, output, Noutput );122 gfits_table_set_Getstar_PS1_DEV_2 (&ftable, output, Noutput, TRUE); 123 123 124 124 gfits_fwrite_header (f, &header); -
branches/eam_branches/ipp-20150419/Ohana/src/imclean/src/wfits.c
r27435 r38447 19 19 20 20 table.header = &theader; 21 gfits_table_set_SMPData (&table, stars, Nstars );21 gfits_table_set_SMPData (&table, stars, Nstars, TRUE); 22 22 23 23 gfits_write_header (filename, header); -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/detrend/delete.c
r28241 r38447 41 41 /** we may later want to pull this out and put it elsewhere **/ 42 42 /** free db[0].theader, db[0].table.buffer? **/ 43 gfits_table_set_DetReg (&db[0].ftable, subset, Nsubset );43 gfits_table_set_DetReg (&db[0].ftable, subset, Nsubset, TRUE); 44 44 gfits_db_save (db); 45 45 gfits_db_close (db); -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/detrend/output.c
r27435 r38447 50 50 51 51 ftable.header = &theader; 52 gfits_table_set_DetReg (&ftable, subset, Nmatch );52 gfits_table_set_DetReg (&ftable, subset, Nmatch, TRUE); 53 53 54 54 gfits_fwrite_header (f, &header); -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/imphot/dumpfits.c
r37807 r38447 34 34 35 35 ftable.header = &theader; 36 // gfits_table_set_Image (&ftable, subset, Nmatch );36 // gfits_table_set_Image (&ftable, subset, Nmatch, TRUE); 37 37 38 38 gfits_fwrite_header (f, &header); -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/imreg/delete.c
r28241 r38447 41 41 /** we may later want to pull this out and put it elsewhere **/ 42 42 /** free db[0].theader, db[0].table.buffer? **/ 43 gfits_table_set_RegImage (&db[0].ftable, subset, Nsubset );43 gfits_table_set_RegImage (&db[0].ftable, subset, Nsubset, TRUE); 44 44 gfits_db_save (db); 45 45 gfits_db_close (db); -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/imreg/imregclient.c
r34088 r38447 66 66 if (NoReg) dump_data (image, Nentry); 67 67 68 gfits_db_init (&db); 68 69 db.lockstate = LCK_HARD; 69 70 db.timeout = 300.0; 70 gfits_db_init (&db);71 71 72 72 if (!gfits_db_lock (&db, TempDB)) { … … 77 77 if (db.dbstate == LCK_EMPTY) { 78 78 gfits_db_create (&db); 79 gfits_table_set_RegImage (&db.ftable, NULL, 0 );79 gfits_table_set_RegImage (&db.ftable, NULL, 0, TRUE); 80 80 } else { 81 81 if (!gfits_db_load (&db)) { -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/imreg/output.c
r27435 r38447 77 77 78 78 ftable.header = &theader; 79 gfits_table_set_RegImage (&ftable, subset, Nmatch );79 gfits_table_set_RegImage (&ftable, subset, Nmatch, TRUE); 80 80 81 81 gfits_fwrite_header (f, &header); -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/photreg/delete.c
r28241 r38447 38 38 } 39 39 40 gfits_table_set_PhotPars (&db[0].ftable, subset, Nsubset );40 gfits_table_set_PhotPars (&db[0].ftable, subset, Nsubset, TRUE); 41 41 gfits_db_save (db); 42 42 gfits_db_close (db); -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/photreg/output.c
r27435 r38447 55 55 56 56 ftable.header = &theader; 57 gfits_table_set_PhotPars (&ftable, subset, Nmatch );57 gfits_table_set_PhotPars (&ftable, subset, Nmatch, TRUE); 58 58 59 59 /* EXTNAME is set to ZERO_POINTS_3.0 by default */ -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/spreg/delete.c
r28241 r38447 39 39 /** we may later want to pull this out and put it elsewhere **/ 40 40 /** free db[0].theader, db[0].table.buffer? **/ 41 gfits_table_set_Spectrum (&db[0].ftable, subset, Nsubset );41 gfits_table_set_Spectrum (&db[0].ftable, subset, Nsubset, TRUE); 42 42 gfits_db_save (db); 43 43 gfits_db_close (db); -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/spreg/output.c
r27435 r38447 61 61 62 62 ftable.header = &theader; 63 gfits_table_set_Spectrum (&ftable, subset, Nmatch );63 gfits_table_set_Spectrum (&ftable, subset, Nmatch, TRUE); 64 64 65 65 gfits_fwrite_header (f, &header); … … 96 96 /* create an empty table which we will fill in by hand */ 97 97 ftable.header = &theader; 98 gfits_table_set_SpectrumASCII (&ftable, NULL, 0 );98 gfits_table_set_SpectrumASCII (&ftable, NULL, 0, TRUE); 99 99 100 100 /* add data to table */ -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/src/detregister.c
r7080 r38447 17 17 SaveEntry (argv[1], &newdata, descriptor.imageID); 18 18 19 gfits_db_init (&db); 19 20 db.lockstate = LCK_HARD; 20 21 db.timeout = 300.0; 21 gfits_db_init (&db);22 22 23 23 dBFile = set_dBFile (); … … 29 29 if (db.dbstate == LCK_EMPTY) { 30 30 gfits_db_create (&db); 31 gfits_table_set_DetReg (&db.ftable, NULL, 0 );31 gfits_table_set_DetReg (&db.ftable, NULL, 0, TRUE); 32 32 } else { 33 33 if (!gfits_db_load (&db)) { -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/src/detsearch.c
r29001 r38447 17 17 if (output.Criteria) PrintCriteria (); 18 18 19 gfits_db_init (&db); 19 20 db.lockstate = (output.Modify || output.Delete) ? LCK_HARD : LCK_SOFT; 20 21 db.timeout = 300.0; 21 gfits_db_init (&db);22 22 23 23 dBFile = set_dBFile (); … … 35 35 36 36 if (!output.Modify && !output.Delete && !output.Altpath) gfits_db_close (&db); 37 detrend = gfits_table_get_DetReg (&db.ftable, &Ndetrend, &db.s wapped);37 detrend = gfits_table_get_DetReg (&db.ftable, &Ndetrend, &db.scaledValue, &db.nativeOrder); 38 38 if (!detrend) { 39 39 fprintf (stderr, "ERROR: failed to read detrend info\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/src/imphotsearch.c
r29001 r38447 14 14 args (argc, argv); 15 15 16 gfits_db_init (&db); 16 17 db.lockstate = (options.modify) ? LCK_HARD : LCK_SOFT; 17 18 db.timeout = 300.0; 18 gfits_db_init (&db);19 19 20 20 /* don't create a new image table if not available */ … … 32 32 if (!options.modify) gfits_db_close (&db); 33 33 34 image = gfits_table_get_Image (&db.ftable, &Nimage, &db.s wapped);34 image = gfits_table_get_Image (&db.ftable, &Nimage, &db.scaledValue, &db.nativeOrder); 35 35 if (!image) { 36 36 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/src/imregister.c
r27435 r38447 17 17 if (NoReg) goto skip_reg; 18 18 19 gfits_db_init (&db); 19 20 db.lockstate = LCK_HARD; 20 21 db.timeout = 300.0; 21 gfits_db_init (&db);22 22 23 23 if (!gfits_db_lock (&db, ImageDB)) { … … 28 28 if (db.dbstate == LCK_EMPTY) { 29 29 gfits_db_create (&db); 30 gfits_table_set_RegImage (&db.ftable, NULL, 0 );30 gfits_table_set_RegImage (&db.ftable, NULL, 0, TRUE); 31 31 } else { 32 32 if (!gfits_db_load (&db)) { -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/src/imregtable.c
r29001 r38447 33 33 gfits_read_ftable (infile, &ftable, "IMAGE_DATABASE"); 34 34 35 image = gfits_table_get_RegImage (&ftable, &Nimage, NULL );35 image = gfits_table_get_RegImage (&ftable, &Nimage, NULL, NULL); 36 36 if (!image) { 37 37 fprintf (stderr, "ERROR: failed to read images\n"); … … 40 40 41 41 /* load database table */ 42 gfits_db_init (&db); 42 43 db.lockstate = LCK_HARD; 43 44 db.timeout = 300.0; 44 gfits_db_init (&db);45 45 46 46 if (!gfits_db_lock (&db, ImageDB)) { … … 51 51 if (db.dbstate == LCK_EMPTY) { 52 52 gfits_db_create (&db); 53 gfits_table_set_RegImage (&db.ftable, NULL, 0 );53 gfits_table_set_RegImage (&db.ftable, NULL, 0, TRUE); 54 54 } else { 55 55 if (!gfits_db_load (&db)) { -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/src/imsearch.c
r29001 r38447 12 12 args (argc, argv); 13 13 14 gfits_db_init (&db); 14 15 db.lockstate = (output.modify || output.delete) ? LCK_HARD : LCK_SOFT; 15 16 db.timeout = 300.0; 16 gfits_db_init (&db);17 17 18 18 if (!gfits_db_lock (&db, ImageDB)) { … … 29 29 if (!output.modify && !output.delete) gfits_db_close (&db); 30 30 31 image = gfits_table_get_RegImage (&db.ftable, &Nimage, &db.s wapped);31 image = gfits_table_get_RegImage (&db.ftable, &Nimage, &db.scaledValue, &db.nativeOrder); 32 32 if (!image) { 33 33 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/src/imstatreg.c
r29001 r38447 40 40 } 41 41 42 gfits_db_init (&image_db); 42 43 image_db.lockstate = LCK_HARD; 43 44 image_db.timeout = 300.0; 44 gfits_db_init (&image_db);45 45 46 46 temp_db.lockstate = LCK_HARD; … … 66 66 exit (1); 67 67 } 68 subset = gfits_table_get_RegImage (&temp_db.ftable, &Nsubset, &temp_db.s wapped);68 subset = gfits_table_get_RegImage (&temp_db.ftable, &Nsubset, &temp_db.scaledValue, &temp_db.nativeOrder); 69 69 if (!subset) { 70 70 fprintf (stderr, "ERROR: failed to read images\n"); … … 96 96 we will just drop the temp db data */ 97 97 } 98 image = gfits_table_get_RegImage (&image_db.ftable, &Nimage, &image_db.s wapped);98 image = gfits_table_get_RegImage (&image_db.ftable, &Nimage, &image_db.scaledValue, &image_db.nativeOrder); 99 99 if (!image) { 100 100 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/src/photreg.c
r7080 r38447 12 12 regargs (argc, argv, &newdata); 13 13 14 gfits_db_init (&db); 14 15 db.lockstate = LCK_HARD; 15 16 db.timeout = 300.0; 16 gfits_db_init (&db);17 17 18 18 filename = PhotDB; … … 26 26 if (db.dbstate == LCK_EMPTY) { 27 27 gfits_db_create (&db); 28 gfits_table_set_PhotPars (&db.ftable, NULL, 0 );28 gfits_table_set_PhotPars (&db.ftable, NULL, 0, TRUE); 29 29 /* EXTNAME is set to ZERO_POINTS_3.0 by default */ 30 30 if (!strcmp (output.db, "trans")) { -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/src/photsearch.c
r29001 r38447 15 15 args (argc, argv); 16 16 17 gfits_db_init (&db); 17 18 db.lockstate = (output.modify || output.delete) ? LCK_HARD : LCK_SOFT; 18 19 db.timeout = 300.0; 19 gfits_db_init (&db);20 20 21 21 if (!strcmp (output.db, "phot")) { … … 41 41 /* add test to EXTNAME? */ 42 42 if (output.convert) { 43 photpars_old = gfits_table_get_PhotParsOld (&db.ftable, &Nphotpars, &db.s wapped);43 photpars_old = gfits_table_get_PhotParsOld (&db.ftable, &Nphotpars, &db.scaledValue, &db.nativeOrder); 44 44 if (!photpars_old) { 45 45 fprintf (stderr, "ERROR: failed to read photometry parameters\n"); … … 48 48 photpars = PhotParsOld_to_PhotPars (photpars_old, Nphotpars); 49 49 } else { 50 photpars = gfits_table_get_PhotPars (&db.ftable, &Nphotpars, &db.s wapped);50 photpars = gfits_table_get_PhotPars (&db.ftable, &Nphotpars, &db.scaledValue, &db.nativeOrder); 51 51 if (!photpars) { 52 52 fprintf (stderr, "ERROR: failed to read photometry parameters\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/src/spregister.c
r7080 r38447 17 17 if (NoReg) exit (0); 18 18 19 gfits_db_init (&db); 19 20 db.lockstate = LCK_HARD; 20 21 db.timeout = 300.0; 21 gfits_db_init (&db);22 22 23 23 if (!gfits_db_lock (&db, SpectrumDB)) { … … 28 28 if (db.dbstate == LCK_EMPTY) { 29 29 gfits_db_create (&db); 30 gfits_table_set_Spectrum (&db.ftable, NULL, 0 );30 gfits_table_set_Spectrum (&db.ftable, NULL, 0, TRUE); 31 31 } else { 32 32 if (!gfits_db_load (&db)) { -
branches/eam_branches/ipp-20150419/Ohana/src/imregister/src/spsearch.c
r29001 r38447 12 12 args (argc, argv); 13 13 14 gfits_db_init (&db); 14 15 db.lockstate = (output.modify || output.delete) ? LCK_HARD : LCK_SOFT; 15 16 db.timeout = 300.0; 16 gfits_db_init (&db);17 17 18 18 if (!gfits_db_lock (&db, SpectrumDB)) { … … 29 29 if (!output.modify && !output.delete) gfits_db_close (&db); 30 30 31 spectrum = gfits_table_get_Spectrum (&db.ftable, &Nspectrum, &db.s wapped);31 spectrum = gfits_table_get_Spectrum (&db.ftable, &Nspectrum, &db.scaledValue, &db.nativeOrder); 32 32 if (!spectrum) { 33 33 fprintf (stderr, "ERROR: failed to read spectrum\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/libautocode/Makefile.Targets
r38153 r38447 55 55 $(ASRC)/starpar-ps1-v5.$(ARCH).o \ 56 56 $(ASRC)/starpar-ps1-sim.$(ARCH).o \ 57 $(ASRC)/galshape.$(ARCH).o \ 58 $(ASRC)/galshape-ps1-v5.$(ARCH).o \ 57 59 $(ASRC)/missing.$(ARCH).o \ 58 60 $(ASRC)/photcode.$(ARCH).o \ … … 165 167 $(AINC)/starpar-ps1-v5.h \ 166 168 $(AINC)/starpar-ps1-sim.h \ 169 $(AINC)/galshape.h \ 170 $(AINC)/galshape-ps1-v5.h \ 167 171 $(AINC)/missing.h \ 168 172 $(AINC)/photcode.h \ -
branches/eam_branches/ipp-20150419/Ohana/src/libautocode/def/autocode.c
r29537 r38447 27 27 /*** add test of EXTNAME and header-defined columns? ***/ 28 28 /* return internal structure representation */ 29 $STRUCT *gfits_table_get_$STRUCT (FTable *ftable, off_t *Ndata, char *swapped) { 29 /* scaledData & nativeBytes describe the current state of the ftable.buffer */ 30 $STRUCT *gfits_table_get_$STRUCT (FTable *ftable, off_t *Ndata, char *scaledValue, char *nativeOrder) { 30 31 31 32 int Ncols; … … 40 41 *Ndata = ftable[0].header[0].Naxis[1]; 41 42 data = ($STRUCT *) ftable[0].buffer; 42 if ((swapped == NULL) || (*swapped == FALSE)) { 43 44 // if the pointer is not passed, we need to swap 45 if (!nativeOrder || !*nativeOrder) { 43 46 if (!gfits_convert_$STRUCT (data, sizeof ($STRUCT), *Ndata)) { 44 47 return NULL; 45 48 } 49 if (nativeOrder) *nativeOrder = TRUE; 50 } 51 // if the pointer is not passed, we need to scale 52 if (!scaledValue || !*scaledValue) { 46 53 gfits_table_scale_data (ftable); 47 if (s wapped != NULL) *swapped= TRUE;54 if (scaledValue) *scaledValue = TRUE; 48 55 } 49 56 return (data); 50 57 } 51 58 52 int gfits_table_set_$STRUCT (FTable *ftable, $STRUCT *data, off_t Ndata ) {59 int gfits_table_set_$STRUCT (FTable *ftable, $STRUCT *data, off_t Ndata, int swapFromNative) { 53 60 54 61 Header *header; … … 67 74 /* add data values */ 68 75 if (!gfits_table_scale_data (ftable)) return (FALSE); 69 if (!gfits_convert_$STRUCT (data, sizeof ($STRUCT), Ndata)) return (FALSE); 76 if (swapFromNative) { 77 if (!gfits_convert_$STRUCT (data, sizeof ($STRUCT), Ndata)) return (FALSE); 78 } 70 79 if (!gfits_add_rows (ftable, (char *) data, Ndata, sizeof ($STRUCT))) return (FALSE); 71 80 -
branches/eam_branches/ipp-20150419/Ohana/src/libautocode/def/autocode.h
r27435 r38447 2 2 /** STRUCT DEFINITION **/ 3 3 4 $STRUCT *gfits_table_get_$STRUCT (FTable *table, off_t *Ndata, char *s wapped);5 int gfits_table_set_$STRUCT (FTable *ftable, $STRUCT *data, off_t Ndata );4 $STRUCT *gfits_table_get_$STRUCT (FTable *table, off_t *Ndata, char *scaledValue, char *nativeOrder); 5 int gfits_table_set_$STRUCT (FTable *ftable, $STRUCT *data, off_t Ndata, int swapFromNative); 6 6 int gfits_table_mkheader_$STRUCT (Header *header); 7 7 int gfits_convert_$STRUCT ($STRUCT *data, off_t size, off_t nitems); -
branches/eam_branches/ipp-20150419/Ohana/src/libautocode/def/average-ps1-v1.d
r36833 r38447 26 26 FIELD Nmeasure, NMEASURE, unsigned short, number of psf measurements 27 27 FIELD Nmissing, NMISSING, unsigned short, number of missings 28 FIELD N extend, NEXTEND, unsigned short, number of extendedmeasurements28 FIELD Ngalphot, NGALPHOT, unsigned short, number of galphot measurements 29 29 30 30 FIELD measureOffset, OFF_MEASURE, uint32_t, offset to first psf measurement -
branches/eam_branches/ipp-20150419/Ohana/src/libautocode/def/average-ps1-v2.d
r36833 r38447 31 31 FIELD Nmeasure, NMEASURE, unsigned short, number of psf measurements 32 32 FIELD Nmissing, NMISSING, unsigned short, number of missings 33 FIELD N extend, NEXTEND, unsigned short, number of extendedmeasurements33 FIELD Ngalphot, NGALPHOT, unsigned short, number of galphot measurements 34 34 35 35 FIELD measureOffset, OFF_MEASURE, uint32_t, offset to first psf measurement -
branches/eam_branches/ipp-20150419/Ohana/src/libautocode/def/average-ps1-v3.d
r36833 r38447 31 31 FIELD Nmeasure, NMEASURE, unsigned short, number of psf measurements 32 32 FIELD Nmissing, NMISSING, unsigned short, number of missings 33 FIELD N extend, NEXTEND, unsigned short, number of extendedmeasurements33 FIELD Ngalphot, NGALPHOT, unsigned short, number of galphot measurements 34 34 35 35 FIELD measureOffset, OFF_MEASURE, uint32_t, offset to first psf measurement -
branches/eam_branches/ipp-20150419/Ohana/src/libautocode/def/average-ps1-v4.d
r36833 r38447 34 34 FIELD Nmeasure, NMEASURE, unsigned short, number of psf measurements 35 35 FIELD Nmissing, NMISSING, unsigned short, number of missings 36 FIELD N extend, NEXTEND, unsigned short, number of extended measurements36 FIELD Ngalphot, NGALPHOT, unsigned short, number of galphotd measurements 37 37 38 38 FIELD measureOffset, OFF_MEASURE, uint32_t, offset to first psf measurement -
branches/eam_branches/ipp-20150419/Ohana/src/libautocode/def/average-ps1-v5.d
r37807 r38447 41 41 FIELD Nlensing, NLENSING, unsigned short, number of lensing measurements 42 42 FIELD Nlensobj, NLENSOBJ, unsigned short, number of lensing measurements 43 FIELD N extend, NEXTEND, unsigned short, number of extendedmeasurements43 FIELD Ngalphot, NGALPHOT, unsigned short, number of galphot measurements 44 44 45 FIELD measureOffset, OFF_MEASURE, int, offset to first psf measurement46 FIELD missingOffset, OFF_MISSING, int, offset to first missing obs47 FIELD lensingOffset, OFF_LENSING, int, offset to first lensing obs48 FIELD lensobjOffset, OFF_LENSOBJ, int, offset to mean lensing data49 FIELD starparOffset, OFF_STARPAR, int, offset to stellar parameter data50 FIELD extendOffset, OFF_EXTEND, int, offset to extendedobject entry45 FIELD measureOffset, OFF_MEASURE, int, offset to first psf measurement 46 FIELD missingOffset, OFF_MISSING, int, offset to first missing obs 47 FIELD lensingOffset, OFF_LENSING, int, offset to first lensing obs 48 FIELD lensobjOffset, OFF_LENSOBJ, int, offset to mean lensing data 49 FIELD starparOffset, OFF_STARPAR, int, offset to stellar parameter data 50 FIELD galphotOffset, OFF_GALPHOT, int, offset to galphot object entry 51 51 52 52 FIELD refColorBlue, REF_COLOR_BLUE, float, color of astrometry ref stars -
branches/eam_branches/ipp-20150419/Ohana/src/libautocode/def/average.d
r37807 r38447 41 41 FIELD Nlensing, NLENSING, unsigned short, number of lensing measurements 42 42 FIELD Nlensobj, NLENSOBJ, unsigned short, number of lensing measurements 43 FIELD N extend, NEXTEND, unsigned short, number of extendedmeasurements43 FIELD Ngalphot, NGALPHOT, unsigned short, number of galphot measurements 44 44 45 FIELD measureOffset, OFF_MEASURE, int, offset to first psf measurement46 FIELD missingOffset, OFF_MISSING, int, offset to first missing obs47 FIELD lensingOffset, OFF_LENSING, int, offset to first lensing obs48 FIELD lensobjOffset, OFF_LENSOBJ, int, offset to mean lensing data49 FIELD starparOffset, OFF_STARPAR, int, offset to stellar parameter data50 FIELD extendOffset, OFF_EXTEND,int, offset to extended object entry45 FIELD measureOffset, OFF_MEASURE, int, offset to first psf measurement 46 FIELD missingOffset, OFF_MISSING, int, offset to first missing obs 47 FIELD lensingOffset, OFF_LENSING, int, offset to first lensing obs 48 FIELD lensobjOffset, OFF_LENSOBJ, int, offset to mean lensing data 49 FIELD starparOffset, OFF_STARPAR, int, offset to stellar parameter data 50 FIELD galphotOffset, OFF_GALPHOT, int, offset to extended object entry 51 51 52 52 FIELD refColorBlue, REF_COLOR_BLUE, float, color of astrometry ref stars -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/Makefile
r37992 r38447 10 10 MAN = $(HOME)/doc 11 11 INC = $(HOME)/include 12 TEST = $(HOME)/test 13 TESTBIN = $(HOME)/test 12 14 ASRC = $(AUTO)/src 13 15 AINC = $(AUTO)/include … … 153 155 rm -f $@ 154 156 cp $< $@ 157 echo "done making autocode.h" 155 158 156 159 $(AINC)/autocode.h: $(AINCS) $(ADEF)/autocode.h $(ADEF)/common.h -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/include/dvo.h
r38318 r38447 10 10 11 11 /* DVO table modes */ 12 typedef enum {DVO_MODE_UNDEF, DVO_MODE_RAW, DVO_MODE_MEF, DVO_MODE_SPLIT, DVO_MODE_MYSQL} DVOTableMode; 12 typedef enum {DVO_MODE_UNDEF = 0, DVO_MODE_RAW, DVO_MODE_MEF, DVO_MODE_SPLIT, DVO_MODE_MYSQL} DVOCatMode; 13 14 /* DVO table modes */ 15 typedef enum {DVO_COMPRESS_NONE = 0, DVO_COMPRESS_NONE_1, DVO_COMPRESS_NONE_2, DVO_COMPRESS_AUTO, DVO_COMPRESS_GZIP_1, DVO_COMPRESS_GZIP_2, DVO_COMPRESS_RICE_1} DVOCatCompress; // 13 16 14 17 /* DVO table formats */ 15 18 typedef enum { 16 DVO_FORMAT_UNDEF ,19 DVO_FORMAT_UNDEF = 0, 17 20 DVO_FORMAT_INTERNAL, 18 21 DVO_FORMAT_ELIXIR, … … 30 33 DVO_FORMAT_PS1_V4, 31 34 DVO_FORMAT_PS1_V5, 32 } DVOTableFormat; 35 } DVOCatFormat; 36 37 typedef enum {DVO_CAT_OPEN_FAIL, DVO_CAT_OPEN_OK, DVO_CAT_OPEN_EMPTY} DVOCatalogOpenModes; 38 39 /* catalog values to be loaded */ 40 typedef enum { 41 DVO_LOAD_NONE = 0x0000, 42 DVO_LOAD_AVERAGE = 0x0001, 43 DVO_LOAD_MEASURE = 0x0002, 44 DVO_LOAD_MISSING = 0x0004, 45 DVO_LOAD_SECFILT = 0x0008, 46 DVO_SKIP_AVERAGE = 0x0010, 47 DVO_SKIP_MEASURE = 0x0020, 48 DVO_SKIP_MISSING = 0x0040, 49 DVO_SKIP_SECFILT = 0x0080, 50 DVO_LOAD_LENSING = 0x0100, 51 DVO_LOAD_LENSOBJ = 0x0200, 52 DVO_SKIP_LENSING = 0x0400, 53 DVO_SKIP_LENSOBJ = 0x0800, 54 DVO_LOAD_STARPAR = 0x1000, 55 DVO_SKIP_STARPAR = 0x2000, 56 DVO_LOAD_GALPHOT = 0x4000, 57 DVO_SKIP_GALPHOT = 0x8000, 58 } DVOCatFlags; 33 59 34 60 /* image data modes in RegImage */ 35 61 typedef enum {T_UNDEF = -1, T_NONE, T_OBJECT, T_DARK, T_BIAS, T_FLAT, T_MASK, T_FRINGE, T_SCATTER, T_MODES, T_FRINGEPTS, T_ANY, N_TYPE} ElixirDetrendTypes; 36 62 typedef enum {M_UNDEF = -1, M_NONE, M_MEF, M_SPLIT, M_SINGLE, M_CUBE, M_SLICE, M_MODES, N_MODE} ElixirDetrendModes; 37 38 typedef enum {DVO_CAT_OPEN_FAIL, DVO_CAT_OPEN_OK, DVO_CAT_OPEN_EMPTY} DVOCatalogOpenModes;39 63 40 64 // these are used as NAN for types of int values … … 62 86 # define IMREG_DIST 0x01 /* image distributed, only imregister-3.0 */ 63 87 64 /* catalog values to be loaded */65 # define LOAD_NONE 0x000066 # define LOAD_AVES 0x000167 # define LOAD_MEAS 0x000268 # define LOAD_MISS 0x000469 # define LOAD_SECF 0x000870 # define SKIP_AVES 0x001071 # define SKIP_MEAS 0x002072 # define SKIP_MISS 0x004073 # define SKIP_SECF 0x008074 # define LOAD_LENSING 0x010075 # define LOAD_LENSOBJ 0x020076 # define SKIP_LENSING 0x040077 # define SKIP_LENSOBJ 0x080078 # define LOAD_STARPAR 0x100079 # define SKIP_STARPAR 0x200080 81 88 /* photometry code types */ 82 89 // # define PHOT_PRI 0x01 83 # define PHOT_SEC 0x02 84 # define PHOT_DEP 0x03 85 # define PHOT_REF 0x04 86 # define PHOT_ALT 0x05 /* never stored, only for look-ups */ 87 # define PHOT_MAG 0x06 /* generic magnitude; never stored */ 90 typedef enum { 91 PHOT_SEC = 0x02, 92 PHOT_DEP = 0x03, 93 PHOT_REF = 0x04, 94 PHOT_ALT = 0x05, /* never stored, only for look-ups */ 95 PHOT_MAG = 0x06, /* generic magnitude; never stored */ 96 } DVOPhotCodeTypes; 88 97 89 98 /* Image.code values -- these values are 32 bit (as of PS1_V1) */ … … 238 247 char lockstate; 239 248 char mode; /* what data storage mode is used for disk file? */ 240 char format;/* what data format is used for disk file? */249 DVOCatFormat format; /* what data format is used for disk file? */ 241 250 char virtual; /* is table in ftable or vtable? */ 242 char swapped; /* is table in internal byte-order? */ 251 char nativeOrder; /* is table in internal byte-order? */ 252 char scaledValue; /* is table in internal byte-order? */ 243 253 } FITS_DB; 244 254 … … 500 510 unsigned short Nmeasure; // number of psf measurements 501 511 unsigned short Nmissing; // number of missings 502 unsigned short N extend;// number of extended measurements512 unsigned short Ngalphot; // number of extended measurements 503 513 uint32_t measureOffset; // offset to first psf measurement 504 514 uint32_t missingOffset; // offset to first missing obs … … 720 730 unsigned short Nlensing; // number of lensing measurements 721 731 unsigned short Nlensobj; // number of lensing measurements 722 unsigned short N extend; // number of extendedmeasurements732 unsigned short Ngalphot; // number of galphot measurements 723 733 int measureOffset; // offset to first psf measurement 724 734 int missingOffset; // offset to first missing obs 725 735 int lensingOffset; // offset to first lensing obs 726 736 int lensobjOffset; // offset to mean lensing data 727 int extendOffset;// offset to extended object entry737 int galphotOffset; // offset to extended object entry 728 738 int starparOffset; // offset to stellar parameter data 729 739 float refColorBlue; // color of astrometry ref stars … … 758 768 759 769 // lensing data (optional?) 760 Lensing *lensing; 761 Lensobj *lensobj; 762 StarPar *starpar; 770 Lensing *lensing; 771 Lensobj *lensobj; 772 StarPar *starpar; 773 GalPhot *galphot; 763 774 764 775 int Nsecfilt; /* number of secfilt entries for each average entry */ 765 off_t Naverage, Nmeasure, Nmissing, Nlensing, Nlensobj, Nstarpar, Nsecf_mem; /* current number of each component in memory */766 off_t Nave s_disk, Nmeas_disk, Nmiss_disk, Nlensing_disk, Nlensobj_disk, Nstarpar_disk, Nsecf_disk; /* current number of each component on disk */767 off_t Nave s_off, Nmeas_off, Nmiss_off, Nlensing_off, Nlensobj_off, Nstarpar_off, Nsecf_off; /* index of first loaded data value */776 off_t Naverage, Nmeasure, Nmissing, Nlensing, Nlensobj, Nstarpar, Ngalphot, Nsecfilt_mem; /* current number of each component in memory */ 777 off_t Naverage_disk, Nmeasure_disk, Nmissing_disk, Nlensing_disk, Nlensobj_disk, Nstarpar_disk, Ngalphot_disk, Nsecfilt_disk; /* current number of each component on disk */ 778 off_t Naverage_off, Nmeasure_off, Nmissing_off, Nlensing_off, Nlensobj_off, Nstarpar_off, Ngalphot_off, Nsecfilt_off; /* index of first loaded data value */ 768 779 769 780 // note that we use these for the full-sky relphot analysis … … 781 792 782 793 /* pointers to split data files */ 783 struct Catalog *measure_catalog; /* measure catalog data (split) */ 784 struct Catalog *missing_catalog; /* missing catalog data (split) */ 785 struct Catalog *secfilt_catalog; /* secfilt catalog data (split) */ 786 struct Catalog *lensing_catalog; /* lensing catalog data (split) */ 787 struct Catalog *lensobj_catalog; /* lensobj catalog data (split) */ 788 struct Catalog *starpar_catalog; /* starpar catalog data (split) */ 794 struct Catalog *measure_catalog; /* measure catalog data (split) */ 795 struct Catalog *missing_catalog; /* missing catalog data (split) */ 796 struct Catalog *secfilt_catalog; /* secfilt catalog data (split) */ 797 struct Catalog *lensing_catalog; /* lensing catalog data (split) */ 798 struct Catalog *lensobj_catalog; /* lensobj catalog data (split) */ 799 struct Catalog *starpar_catalog; /* starpar catalog data (split) */ 800 struct Catalog *galphot_catalog; /* galphot catalog data (split) */ 789 801 790 802 unsigned int objID; … … 793 805 /* extra catalog information */ 794 806 char lockmode; 795 char catmode; /* storage mode (raw, mef, split, mysql) */ 796 char catformat; /* storage format (elixir, panstarrs, etc) */ 807 DVOCatMode catmode; /* storage mode (raw, mef, split, mysql) */ 808 DVOCatFormat catformat; /* storage format (elixir, panstarrs, etc) */ 809 DVOCatCompress catcompress; // output compress mode 810 DVOCatFlags catflags; /* choices to be loaded */ 811 797 812 int sorted; /* is measure table average-sorted? (NOTE this is an int only because gfits_scan %t requires it) */ 798 799 short catflags; /* choices to be loaded */ 813 800 814 801 815 /* pointers for data manipulation */ … … 946 960 int dvo_catalog_save_complete (Catalog *catalog, char VERBOSE); 947 961 int dvo_catalog_update (Catalog *catalog, char VERBOSE); 948 int dvo_catalog_catformat (char *catformat); 949 int dvo_catalog_catmode (char *catmode); 962 DVOCatFormat dvo_catalog_catformat (char *catformat); 963 DVOCatMode dvo_catalog_catmode (char *catmode); 964 DVOCatCompress dvo_catalog_catcompress (char *catcompress); 965 char *dvo_catalog_compress_string (DVOCatCompress catcompress); 950 966 void dvo_catalog_test (Catalog *catalog, int halt); 951 967 … … 974 990 int WriteRawSecFilt (FILE *f, SecFilt *secfilt, off_t Nsecfilt, char format); 975 991 976 DVOTableFormat FtableGetFormat (FTable *ftable); 977 978 Average *FtableToAverage (FTable *ftable, off_t *Naverage, char *format, SecFilt **primary); 979 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, char *format); 980 SecFilt *FtableToSecFilt (FTable *ftable, off_t *Nsecfilt, char *format); 981 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, char *format); 982 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, char *format); 983 StarPar *FtableToStarPar (FTable *ftable, off_t *Nstarpar, char *format); 984 int FtableToImage (FTable *ftable, Header *theader, char *format); 985 986 int AverageToFtable (FTable *ftable, Average *average, off_t Naverage, char format, SecFilt *primary); 987 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, char format); 988 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, char format); 989 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, char format); 990 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, char format); 991 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, char format); 992 int ImageToFtable (FTable *ftable, Header *theader, char format); 993 int ImageToVtable (VTable *vtable, Header *theader, char format); 992 DVOCatFormat FtableGetFormat (FTable *ftable); 993 994 Average *FtableToAverage (FTable *ftable, off_t *Naverage, DVOCatFormat *format, SecFilt **primary, char nativeOrder); 995 996 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, DVOCatFormat *format, char nativeOrder); 997 Missing *FtableToMissing (FTable *ftable, Average *average, off_t *Nmissing, DVOCatFormat *format, char nativeBytes); 998 SecFilt *FtableToSecFilt (FTable *ftable, Average *average, off_t *Nsecfilt, DVOCatFormat *format, char nativeOrder); 999 Lensing *FtableToLensing (FTable *ftable, Average *average, off_t *Nlensing, DVOCatFormat *format, char nativeOrder); 1000 Lensobj *FtableToLensobj (FTable *ftable, Average *average, off_t *Nlensobj, DVOCatFormat *format, char nativeOrder); 1001 StarPar *FtableToStarPar (FTable *ftable, Average *average, off_t *Nstarpar, DVOCatFormat *format, char nativeOrder); 1002 GalPhot *FtableToGalPhot (FTable *ftable, Average *average, off_t *Ngalphot, DVOCatFormat *format, char nativeOrder); 1003 1004 int FtableToImage (FTable *ftable, Header *theader, DVOCatFormat *format); 1005 1006 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, DVOCatFormat format, int swapFromNative); 1007 int AverageToFtable (FTable *ftable, Average *average, off_t Naverage, DVOCatFormat format, SecFilt *primary, int swapFromNative); 1008 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, DVOCatFormat format, int swapFromNative); 1009 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, DVOCatFormat format, int swapFromNative); 1010 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, DVOCatFormat format, int swapFromNative); 1011 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, DVOCatFormat format, int swapFromNative); 1012 int GalPhotToFtable (FTable *ftable, GalPhot *galphot, off_t Ngalphot, DVOCatFormat format, int swapFromNative); 1013 1014 int ImageToFtable (FTable *ftable, Header *theader, DVOCatFormat format); 1015 int ImageToVtable (VTable *vtable, Header *theader, DVOCatFormat format); 994 1016 995 1017 # include "loneos_defs.h" … … 1023 1045 int gfits_table_set_Image (FTable *ftable); 1024 1046 int gfits_table_mkheader_Image (Header *header); 1025 Image *gfits_table_get_Image (FTable *ftable, off_t *Ndata, char *s wapped);1047 Image *gfits_table_get_Image (FTable *ftable, off_t *Ndata, char *scaledValue, char *nativeOrder); 1026 1048 1027 1049 /* flatcorr APIs */ … … 1087 1109 void InitHost (HostInfo *host); 1088 1110 1089 HostTableGroup *HostTableGroups (HostTable *table, int *ngroups); 1111 HostTableGroup *HostTableGroupsUniqueMachines (HostTable *table, int *ngroups); 1112 HostTableGroup *HostTableGroupsMaxNumber (HostTable *table, int *ngroups, int Nmax); 1113 1090 1114 int HostTableGroupWaitJobsGetIO (HostTableGroup *table, char *file, int lineno, int VERBOSE); 1091 1115 … … 1124 1148 void dvo_lensobj_init (Lensobj *lensobj, int toZero); 1125 1149 void dvo_starpar_init (StarPar *starpar); 1150 void dvo_galphot_init (GalPhot *galphot); 1126 1151 1127 1152 void InitRegionHosts (RegionHostInfo *hosts, int Nhosts, int NHOSTS); -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/include/ps1_v5_defs.h
r38153 r38447 23 23 StarPar_PS1_V5 *StarParInternalTo_PS1_V5 (StarPar *in, off_t Nvalues); 24 24 25 GalPhot *GalPhot_PS1_V5_ToInternal (GalPhot_PS1_V5 *in, off_t Nvalues); 26 GalPhot_PS1_V5 *GalPhotInternalTo_PS1_V5 (GalPhot *in, off_t Nvalues); 27 25 28 PhotCode *PhotCode_PS1_V5_To_Internal (PhotCode_PS1_V5 *in, off_t Nvalues); 26 29 PhotCode_PS1_V5 *PhotCode_Internal_To_PS1_V5 (PhotCode *in, off_t Nvalues); -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/AstromOffsetMapIO.c
r37807 r38447 39 39 return (NULL); 40 40 } 41 AstromOffsetMap_Disk_6x6 *map_disk = gfits_table_get_AstromOffsetMap_Disk_6x6 (&ftable, &Nmap, NULL );41 AstromOffsetMap_Disk_6x6 *map_disk = gfits_table_get_AstromOffsetMap_Disk_6x6 (&ftable, &Nmap, NULL, NULL); 42 42 if (!map_disk) { 43 43 fprintf (stderr, "ERROR: failed to read Astrom Offset Map\n"); … … 78 78 79 79 ftable.header = &theader; 80 gfits_table_set_AstromOffsetMap_Disk_6x6 (&ftable, map_disk, Nmap );80 gfits_table_set_AstromOffsetMap_Disk_6x6 (&ftable, map_disk, Nmap, TRUE); 81 81 82 82 f = fopen (filename, "w"); -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/HostTable.c
r37807 r38447 155 155 156 156 // split a host table into Ngroups, each with a unique set of hosts 157 HostTableGroup *HostTableGroups (HostTable *table, int *ngroups) {157 HostTableGroup *HostTableGroupsUniqueMachines (HostTable *table, int *ngroups) { 158 158 159 159 // identify the unique host names and the number of times they each exist … … 210 210 foundHost[k] = TRUE; 211 211 } 212 } 213 } 214 *ngroups = Ngroups; 215 return groups; 216 } 217 218 // split a host table into Ngroups, each with a unique set of hosts 219 HostTableGroup *HostTableGroupsMaxNumber (HostTable *table, int *ngroups, int Nmax) { 220 221 int i, j; 222 223 int Ngroups = (table->Nhosts % Nmax) ? (int)(table->Nhosts / Nmax + 1) : table->Nhosts / Nmax; 224 225 HostTableGroup *groups = NULL; 226 ALLOCATE (groups, HostTableGroup, Ngroups); 227 228 // in each group, attempt to add one of each unique host 229 int k = 0; 230 for (i = 0; i < Ngroups; i++) { 231 groups[i].Nhosts = 0; 232 ALLOCATE (groups[i].hosts, HostInfo *, Nmax); 233 for (j = 0; j < Nmax; j++) { 234 groups[i].hosts[groups[i].Nhosts] = &table->hosts[k]; 235 groups[i].Nhosts ++; 236 k++; 212 237 } 213 238 } -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/LoadImages.c
r37807 r38447 65 65 } 66 66 67 image = gfits_table_get_Image (&db.ftable, Nimage, &db.s wapped);67 image = gfits_table_get_Image (&db.ftable, Nimage, &db.scaledValue, &db.nativeOrder); 68 68 if (!image) { 69 69 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/LoadPhotcodesFITS.c
r37035 r38447 15 15 16 16 /* XXX choose more sensible lock timeouts! */ 17 gfits_db_init (&db); 17 18 db.timeout = 60.0; 18 19 db.lockstate = LCK_SOFT; 19 gfits_db_init (&db);20 20 21 21 /* does this mean the db is empty, non-existent, or has access errors? */ … … 43 43 # define CONVERT_FORMAT(NAME, FORMAT) \ 44 44 if (!strcmp (extname, NAME)) { \ 45 PhotCode_##FORMAT *photcode_input = gfits_table_get_PhotCode_##FORMAT (&db.ftable, &Ncode, &db.s wapped); \45 PhotCode_##FORMAT *photcode_input = gfits_table_get_PhotCode_##FORMAT (&db.ftable, &Ncode, &db.scaledValue, &db.nativeOrder); \ 46 46 if (!photcode_input) { \ 47 47 fprintf (stderr, "ERROR: failed to read photcodes in LoadPhotcodesFITS.c\n"); \ -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/SavePhotcodesFITS.c
r37035 r38447 17 17 18 18 /* XXX choose more sensible lock timeouts! */ 19 gfits_db_init (&db); 19 20 db.lockstate = LCK_XCLD; 20 21 db.timeout = 10.0; 21 gfits_db_init (&db);22 22 23 23 /* does this mean the db is empty, non-existent, or has access errors? */ … … 34 34 /* convert FITS format data to internal format (byteswaps & EXTNAME) */ 35 35 if (!gfits_db_create (&db)) return (FALSE); 36 if (!gfits_table_set_PhotCode_PS1_V5 (&db.ftable, photcode_output, table[0].Ncode )) return (FALSE);36 if (!gfits_table_set_PhotCode_PS1_V5 (&db.ftable, photcode_output, table[0].Ncode, TRUE)) return (FALSE); 37 37 if (!gfits_db_save (&db)) return (FALSE); 38 38 if (!gfits_db_close (&db)) return (FALSE); -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_catalog.c
r38318 r38447 42 42 } 43 43 44 int dvo_catalog_catformat (char *catformat) {44 DVOCatFormat dvo_catalog_catformat (char *catformat) { 45 45 46 46 /* set the specified CATFORMAT */ … … 62 62 } 63 63 64 intdvo_catalog_catmode (char *catmode) {64 DVOCatMode dvo_catalog_catmode (char *catmode) { 65 65 66 66 /* set the specified CATMODE */ … … 69 69 if (!strcasecmp (catmode, "SPLIT")) return (DVO_MODE_SPLIT); 70 70 return (DVO_MODE_UNDEF); 71 } 72 73 DVOCatCompress dvo_catalog_catcompress (char *catcompress) { 74 75 /* set the specified CATMODE */ 76 if (!strcasecmp (catcompress, "NONE")) return (DVO_COMPRESS_NONE); 77 if (!strcasecmp (catcompress, "AUTO")) return (DVO_COMPRESS_AUTO); 78 if (!strcasecmp (catcompress, "NONE_1")) return (DVO_COMPRESS_NONE_1); 79 if (!strcasecmp (catcompress, "NONE_2")) return (DVO_COMPRESS_NONE_2); 80 if (!strcasecmp (catcompress, "GZIP_1")) return (DVO_COMPRESS_GZIP_1); 81 if (!strcasecmp (catcompress, "GZIP_2")) return (DVO_COMPRESS_GZIP_2); 82 if (!strcasecmp (catcompress, "RICE_1")) return (DVO_COMPRESS_RICE_1); 83 return (DVO_COMPRESS_NONE); 84 } 85 86 // we can return a static string here unless we run multiple outputs threads at once 87 static char compress_string[16]; 88 char *dvo_catalog_compress_string (DVOCatCompress catcompress) { 89 90 switch (catcompress) { 91 case DVO_COMPRESS_NONE: 92 strcpy (compress_string, "NONE"); 93 break; 94 case DVO_COMPRESS_AUTO: 95 strcpy (compress_string, "AUTO"); 96 break; 97 case DVO_COMPRESS_GZIP_1: 98 strcpy (compress_string, "GZIP_1"); 99 break; 100 case DVO_COMPRESS_GZIP_2: 101 strcpy (compress_string, "GZIP_2"); 102 break; 103 case DVO_COMPRESS_NONE_1: 104 strcpy (compress_string, "NONE_1"); 105 break; 106 case DVO_COMPRESS_NONE_2: 107 strcpy (compress_string, "NONE_2"); 108 break; 109 case DVO_COMPRESS_RICE_1: 110 strcpy (compress_string, "RICE_1"); 111 break; 112 default: 113 myAbort ("error in compress option"); 114 } 115 return compress_string; 71 116 } 72 117 … … 131 176 average->Nlensobj = 0; 132 177 average->Nstarpar = 0; 133 average->N extend= 0;178 average->Ngalphot = 0; 134 179 135 180 average->measureOffset = -1; … … 138 183 average->lensobjOffset = -1; 139 184 average->starparOffset = -1; 140 average-> extendOffset= -1;185 average->galphotOffset = -1; 141 186 142 187 average->refColorBlue = NAN; … … 477 522 478 523 // init all data, or just catalog data 524 void dvo_galphot_init (GalPhot *galphot) { 525 galphot->Xfit = NAN; 526 galphot->Yfit = NAN; 527 galphot->mag = NAN; 528 galphot->magErr = NAN; 529 galphot->majorAxis = NAN; 530 galphot->minorAxis = NAN; 531 galphot->majorAxisErr = NAN; 532 galphot->minorAxisErr = NAN; 533 galphot->theta = NAN; 534 galphot->theta_err = NAN; 535 galphot->index = NAN; 536 galphot->chisq = NAN; 537 galphot->Npix = 0; 538 539 galphot->detID = -1; 540 galphot->objID = -1; 541 galphot->catID = -1; 542 galphot->imageID = -1; 543 544 galphot->photcode = 0; 545 galphot->modelType = 0; 546 } 547 548 # define INIT_TABLE(TABLE) \ 549 catalog[0].TABLE = NULL; \ 550 catalog[0].N##TABLE = 0; \ 551 catalog[0].N##TABLE##_disk = 0; \ 552 catalog[0].N##TABLE##_off = 0; \ 553 catalog[0].TABLE##_catalog = NULL; 554 555 // init all data, or just catalog data 479 556 void dvo_catalog_init (Catalog *catalog, int complete) { 480 557 … … 484 561 catalog[0].filename = NULL; 485 562 486 catalog[0].lockmode = 0; 487 catalog[0].catmode = 0; 488 catalog[0].catformat = 0; 489 catalog[0].catflags = 0; 490 catalog[0].Nsecfilt = 0; 563 catalog[0].lockmode = 0; 564 catalog[0].catmode = DVO_MODE_UNDEF; 565 catalog[0].catformat = DVO_FORMAT_UNDEF; 566 catalog[0].catcompress = DVO_COMPRESS_NONE; 567 catalog[0].catflags = DVO_LOAD_NONE; 568 catalog[0].Nsecfilt = 0; 491 569 } 492 570 493 571 gfits_init_header (&catalog[0].header); 494 572 495 573 // the following describe the catalog files on disk 496 574 catalog[0].average = NULL; 497 catalog[0].measure = NULL; 498 catalog[0].missing = NULL; 575 catalog[0].Naverage = 0; 576 catalog[0].Naverage_disk = 0; 577 catalog[0].Naverage_off = 0; 578 // average lacks average_catalog 579 499 580 catalog[0].secfilt = NULL; 500 501 catalog[0]. lensing = NULL;502 catalog[0]. lensobj = NULL;503 504 catalog[0].starpar = NULL;581 catalog[0].Nsecfilt_mem = 0; 582 catalog[0].Nsecfilt_disk = 0; 583 catalog[0].Nsecfilt_off = 0; 584 catalog[0].secfilt_catalog = NULL; 585 // secfilt uses Nsecfilt_mem not Nsecfilt 505 586 506 587 catalog[0].averageT = NULL; 507 588 catalog[0].measureT = NULL; 589 590 INIT_TABLE(measure); 591 INIT_TABLE(missing); 592 INIT_TABLE(lensing); 593 INIT_TABLE(lensobj); 594 INIT_TABLE(starpar); 595 INIT_TABLE(galphot); 508 596 509 597 catalog[0].objID = 0; 510 598 catalog[0].catID = 0; 511 599 catalog[0].sorted = 0; 512 513 catalog[0].Naverage = 0;514 catalog[0].Nmeasure = 0;515 catalog[0].Nmissing = 0;516 catalog[0].Nsecf_mem = 0;517 518 catalog[0].Nlensing = 0;519 catalog[0].Nlensobj = 0;520 521 catalog[0].Nstarpar = 0;522 523 catalog[0].Naves_disk = 0;524 catalog[0].Nmeas_disk = 0;525 catalog[0].Nmiss_disk = 0;526 catalog[0].Nsecf_disk = 0;527 528 catalog[0].Nlensing_disk = 0;529 catalog[0].Nlensobj_disk = 0;530 531 catalog[0].Nstarpar_disk = 0;532 533 catalog[0].Naves_off = 0;534 catalog[0].Nmeas_off = 0;535 catalog[0].Nmiss_off = 0;536 catalog[0].Nsecf_off = 0;537 538 catalog[0].Nlensing_off = 0;539 catalog[0].Nlensobj_off = 0;540 541 catalog[0].Nstarpar_off = 0;542 543 /* pointers to SPLIT data files */544 catalog[0].measure_catalog = NULL;545 catalog[0].missing_catalog = NULL;546 catalog[0].secfilt_catalog = NULL;547 catalog[0].lensing_catalog = NULL;548 catalog[0].lensobj_catalog = NULL;549 catalog[0].starpar_catalog = NULL;550 600 551 601 /* pointers for data manipulation */ … … 579 629 if (catalog[0].f == NULL) return (DVO_CAT_OPEN_FAIL); 580 630 581 fseeko (catalog[0].f, 0, SEEK_SET); 631 if (fseeko (catalog[0].f, 0, SEEK_SET)) { 632 perror ("fseeko: "); 633 exit (1); 634 } 582 635 return (DVO_CAT_OPEN_OK); 583 636 } … … 591 644 592 645 if (fflush (catalog[0].f)) { 593 fprintf (stderr, "failed to flush file\n"); 646 perror ("fflush: "); 647 fprintf (stderr, "failed to flush file %s\n", catalog[0].filename); 594 648 return FALSE; 595 649 } … … 618 672 if (catalog[0].lensobj_catalog) { if (!dvo_catalog_unlock (catalog[0].lensobj_catalog)) { fprintf (stderr, "failed to unlock lensobj\n"); return (0); }} 619 673 if (catalog[0].starpar_catalog) { if (!dvo_catalog_unlock (catalog[0].starpar_catalog)) { fprintf (stderr, "failed to unlock starpar\n"); return (0); }} 674 if (catalog[0].galphot_catalog) { if (!dvo_catalog_unlock (catalog[0].galphot_catalog)) { fprintf (stderr, "failed to unlock galphot\n"); return (0); }} 620 675 } 621 676 return (1); … … 860 915 catalog[0].secfilt = outsec; 861 916 catalog[0].Nsecfilt = Nsecfilt; 862 catalog[0].Nsecf _mem = Nsecfilt * catalog[0].Naverage;917 catalog[0].Nsecfilt_mem = Nsecfilt * catalog[0].Naverage; 863 918 } 864 919 return (TRUE); … … 898 953 dvo_catalog_free (catalog[0].starpar_catalog); 899 954 free (catalog[0].starpar_catalog); 955 } 956 if (catalog[0].galphot_catalog) { 957 free (catalog[0].galphot_catalog[0].filename); 958 dvo_catalog_free (catalog[0].galphot_catalog); 959 free (catalog[0].galphot_catalog); 900 960 } 901 961 } … … 925 985 if (catalog[0].secfilt) { 926 986 free (catalog[0].secfilt); 927 catalog[0].Nsecf _mem = 0;987 catalog[0].Nsecfilt_mem = 0; 928 988 catalog[0].secfilt = NULL; 929 989 } … … 943 1003 catalog[0].starpar = NULL; 944 1004 } 1005 if (catalog[0].galphot) { 1006 free (catalog[0].galphot); 1007 catalog[0].Ngalphot = 0; 1008 catalog[0].galphot = NULL; 1009 } 945 1010 if (catalog[0].nOwn_t) { free (catalog[0].nOwn_t); catalog[0].nOwn_t = NULL; } 946 1011 if (catalog[0].found_t) { free (catalog[0].found_t); catalog[0].found_t = NULL; } … … 949 1014 950 1015 /* 951 mode : items to read ( LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF)1016 mode : items to read (DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT) 952 1017 format : what table structure on disk (INTERNAL, LONEOS, etc, ) 953 1018 style : raw, mef, split, mysql … … 982 1047 983 1048 // skip empty cpt files 984 if (primary && !catalog->Nave s_disk) {1049 if (primary && !catalog->Naverage_disk) { 985 1050 return TRUE; 986 1051 } … … 1064 1129 } 1065 1130 } 1131 if (catalog[0].galphot_catalog != NULL) { 1132 if (catalog[0].Ngalphot_disk == 0) { 1133 // need to relock (and re-open) file for close elsewhere 1134 status = dvo_catalog_lock (catalog[0].galphot_catalog, lockmode); 1135 } else { 1136 if (!dvo_catalog_backup (catalog[0].galphot_catalog, FALSE)) { 1137 return FALSE; 1138 } 1139 } 1140 } 1066 1141 } 1067 1142 return TRUE; … … 1071 1146 int dvo_catalog_unlink_backup (Catalog *catalog, int primary) { 1072 1147 1073 if (primary && !catalog->Nave s_disk) {1148 if (primary && !catalog->Naverage_disk) { 1074 1149 // skip empty files (empty when read, but output may not be empty) 1075 1150 return TRUE; … … 1120 1195 } 1121 1196 } 1197 if ((catalog[0].galphot_catalog != NULL) && (catalog[0].Ngalphot_disk > 0)) { 1198 if (!dvo_catalog_unlink_backup (catalog[0].galphot_catalog, FALSE)) { 1199 return FALSE; 1200 } 1201 } 1122 1202 } 1123 1203 return TRUE; -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_catalog_create.c
r37807 r38447 1 1 # include <dvo.h> 2 2 # define DEBUG 0 3 4 Catalog *dvo_catalog_create_subcat (Catalog *catalog, char *ext, char *tablename); 3 5 4 6 // create a new dvo catalog file (if split, lock extra files as well?) … … 9 11 // catalog[0].lockmode 10 12 void dvo_catalog_create (SkyRegion *region, Catalog *catalog) { 11 12 int length;13 char *path, *root, *file, *line;14 time_t now;15 13 16 14 if (DEBUG) fprintf (stderr, "new catalog file: %s\n", catalog[0].filename); … … 29 27 30 28 if (catalog[0].catmode == DVO_MODE_SPLIT) { 31 path = pathname (catalog[0].filename); 32 root = filerootname (catalog[0].filename); 33 length = strlen(path) + strlen(root) + 6; 34 35 /* define measure catalog file */ 36 ALLOCATE (catalog[0].measure_catalog, Catalog, 1); 37 dvo_catalog_init (catalog[0].measure_catalog, TRUE); 38 39 /* create basic data for measure catalog file */ 40 gfits_create_header (&catalog[0].measure_catalog[0].header); 41 42 ALLOCATE (catalog[0].measure_catalog[0].filename, char, length); 43 44 sprintf (catalog[0].measure_catalog[0].filename, "%s/%s.cpm", path, root); 45 file = filebasename (catalog[0].measure_catalog[0].filename); 46 gfits_modify (&catalog[0].header, "MEASURE", "%s", 1, file); 47 free (file); 48 49 /* define missing catalog file */ 50 ALLOCATE (catalog[0].missing_catalog, Catalog, 1); 51 dvo_catalog_init (catalog[0].missing_catalog, TRUE); 52 53 /* create basic data for missing catalog file */ 54 gfits_create_header (&catalog[0].missing_catalog[0].header); 55 ALLOCATE (catalog[0].missing_catalog[0].filename, char, length); 56 sprintf (catalog[0].missing_catalog[0].filename, "%s/%s.cpn", path, root); 57 file = filebasename (catalog[0].missing_catalog[0].filename); 58 gfits_modify (&catalog[0].header, "MISSING", "%s", 1, file); 59 free (file); 60 61 /* define secfilt catalog file */ 62 ALLOCATE (catalog[0].secfilt_catalog, Catalog, 1); 63 dvo_catalog_init (catalog[0].secfilt_catalog, TRUE); 64 65 /* create basic data for secfilt catalog file */ 66 gfits_create_header (&catalog[0].secfilt_catalog[0].header); 67 ALLOCATE (catalog[0].secfilt_catalog[0].filename, char, length); 68 sprintf (catalog[0].secfilt_catalog[0].filename, "%s/%s.cps", path, root); 69 file = filebasename (catalog[0].secfilt_catalog[0].filename); 70 gfits_modify (&catalog[0].header, "SECFILT", "%s", 1, file); 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 97 /* define starpar catalog file */ 98 ALLOCATE (catalog[0].starpar_catalog, Catalog, 1); 99 dvo_catalog_init (catalog[0].starpar_catalog, TRUE); 100 101 /* create basic data for starpar catalog file */ 102 gfits_create_header (&catalog[0].starpar_catalog[0].header); 103 ALLOCATE (catalog[0].starpar_catalog[0].filename, char, length); 104 sprintf (catalog[0].starpar_catalog[0].filename, "%s/%s.cpz", path, root); 105 file = filebasename (catalog[0].starpar_catalog[0].filename); 106 gfits_modify (&catalog[0].header, "STARPAR", "%s", 1, file); 107 free (file); 108 109 free (path); 110 free (root); 29 catalog[0].measure_catalog = dvo_catalog_create_subcat (catalog, "cpm", "MEASURE"); 30 catalog[0].missing_catalog = dvo_catalog_create_subcat (catalog, "cpn", "MISSING"); 31 catalog[0].secfilt_catalog = dvo_catalog_create_subcat (catalog, "cps", "SECFILT"); 32 catalog[0].lensing_catalog = dvo_catalog_create_subcat (catalog, "cpx", "LENSING"); 33 catalog[0].lensobj_catalog = dvo_catalog_create_subcat (catalog, "cpy", "LENSOBJ"); 34 catalog[0].starpar_catalog = dvo_catalog_create_subcat (catalog, "cpz", "STARPAR"); 35 catalog[0].galphot_catalog = dvo_catalog_create_subcat (catalog, "cpq", "GALPHOT"); 111 36 112 37 // lock the additional split files … … 136 61 exit (2); 137 62 } 63 if (dvo_catalog_lock (catalog[0].galphot_catalog, catalog[0].lockmode) != DVO_CAT_OPEN_EMPTY) { 64 fprintf (stderr, "error with file lock\n"); 65 exit (2); 66 } 138 67 } 139 68 … … 150 79 151 80 /* write creation date in header */ 81 time_t now; 152 82 ohana_str_to_time ("now", &now); 153 line = ohana_sec_to_date (now);83 char *line = ohana_sec_to_date (now); 154 84 gfits_modify (&catalog[0].header, "DATE", "%s", 1, line); 155 85 free (line); … … 163 93 ALLOCATE (catalog[0].lensobj, Lensobj, 1); 164 94 ALLOCATE (catalog[0].starpar, StarPar, 1); 95 ALLOCATE (catalog[0].galphot, GalPhot, 1); 165 96 166 97 /* setup secondary filters to match photcodes: … … 170 101 } 171 102 103 Catalog *dvo_catalog_create_subcat (Catalog *catalog, char *ext, char *tablename) { 104 105 char *path = pathname (catalog[0].filename); 106 char *root = filerootname (catalog[0].filename); 107 int length = strlen(path) + strlen(root) + 6; 108 109 Catalog *subcat; 110 111 /* define subcat catalog file */ 112 ALLOCATE (subcat, Catalog, 1); 113 dvo_catalog_init (subcat, TRUE); 114 115 /* create basic data for measure catalog file */ 116 gfits_create_header (&subcat->header); 117 118 subcat->catcompress = catalog->catcompress; 119 120 ALLOCATE (subcat->filename, char, length); 121 122 sprintf (subcat->filename, "%s/%s.%s", path, root, ext); 123 124 char *file = filebasename (subcat->filename); 125 gfits_modify (&catalog[0].header, tablename, "%s", 1, file); 126 127 free (file); 128 free (path); 129 free (root); 130 131 return subcat; 132 } 133 172 134 int dvo_catalog_set_range (Catalog *catalog) { 173 135 -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_catalog_mef.c
r37807 r38447 26 26 } 27 27 28 // NSTARS, average, Nave s_disk28 // NSTARS, average, Naverage_disk 29 29 30 30 # define GET_TABLE_SIZES(HFIELD, CFIELD, DFIELD, REQUIRED) \ … … 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, Naverage_disk, TRUE); 44 GET_TABLE_SIZES ("NMEAS", measure, Nmeasure_disk, TRUE); 45 GET_TABLE_SIZES ("NMISS", missing, Nmissing_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 ("NGALPHOT", galphot, Ngalphot_disk, FALSE); 49 50 50 51 /** Nsecfilt is unusual: it does not list the number of data items in the table … … 53 54 if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0; 54 55 catalog[0].Nsecfilt = Nsecfilt; 55 catalog[0].Nsecf _disk = Naverage * Nsecfilt;56 catalog[0].Nsecfilt_disk = Naverage * Nsecfilt; 56 57 catalog[0].secfilt = NULL; 57 58 … … 70 71 71 72 /* read Average table data (or skip) */ 72 if (catalog[0].catflags & LOAD_AVES) {73 if (catalog[0].catflags & DVO_LOAD_AVERAGE) { 73 74 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 74 75 if (VERBOSE) fprintf (stderr, "can't read table average data"); … … 76 77 } 77 78 /* old versions of DVO stored one of the average magnitudes in Average. we save this if needed */ 78 catalog[0].average = FtableToAverage (&ftable, &Naverage, &catalog[0].catformat, &primary );79 if (Naverage != catalog[0].Nave s_disk) {80 fprintf (stderr, "Warning: mismatch between Naverage in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Naverage, catalog[0].Nave s_disk);81 } 82 catalog[0].Naverage = catalog[0].Nave s_disk;83 catalog[0].Nave s_off = 0;79 catalog[0].average = FtableToAverage (&ftable, &Naverage, &catalog[0].catformat, &primary, FALSE); 80 if (Naverage != catalog[0].Naverage_disk) { 81 fprintf (stderr, "Warning: mismatch between Naverage in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Naverage, catalog[0].Naverage_disk); 82 } 83 catalog[0].Naverage = catalog[0].Naverage_disk; 84 catalog[0].Naverage_off = 0; 84 85 } else { 85 86 catalog[0].catformat = FtableGetFormat (&ftable); … … 88 89 ALLOCATE (catalog[0].average, Average, 1); 89 90 catalog[0].Naverage = 0; 90 catalog[0].Nave s_off = catalog[0].Naves_disk;91 catalog[0].Naverage_off = catalog[0].Naverage_disk; 91 92 } 92 93 gfits_free_header (&header); … … 99 100 } 100 101 /* read Measure table data */ 101 if (catalog[0].catflags & LOAD_MEAS) {102 if (catalog[0].catflags & DVO_LOAD_MEASURE) { 102 103 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 103 104 if (VERBOSE) fprintf (stderr, "can't read table measure data"); 104 105 return (FALSE); 105 106 } 106 catalog[0].measure = FtableToMeasure (&ftable, catalog[0].average, &catalog[0].Nmeasure, &catalog[0].catformat );107 if (Nmeasure != catalog[0].Nmeas _disk) {108 fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nmeasure, catalog[0].Nmeas _disk);109 } 110 catalog[0].Nmeasure = catalog[0].Nmeas _disk;111 catalog[0].Nmeas _off = 0;107 catalog[0].measure = FtableToMeasure (&ftable, catalog[0].average, &catalog[0].Nmeasure, &catalog[0].catformat, FALSE); 108 if (Nmeasure != catalog[0].Nmeasure_disk) { 109 fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nmeasure, catalog[0].Nmeasure_disk); 110 } 111 catalog[0].Nmeasure = catalog[0].Nmeasure_disk; 112 catalog[0].Nmeasure_off = 0; 112 113 } else { 113 114 Nbytes = gfits_data_size (&header); … … 115 116 ALLOCATE (catalog[0].measure, Measure, 1); 116 117 catalog[0].Nmeasure = 0; 117 catalog[0].Nmeas _off = catalog[0].Nmeas_disk;118 catalog[0].Nmeasure_off = catalog[0].Nmeasure_disk; 118 119 } 119 120 … … 124 125 } 125 126 /* read Missing table data */ 126 if (catalog[0].catflags & LOAD_MISS) {127 if (catalog[0].catflags & DVO_LOAD_MISSING) { 127 128 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 128 129 if (VERBOSE) fprintf (stderr, "can't read table missing data"); … … 130 131 } 131 132 /* no conversions currently defined */ 132 catalog[0].missing = gfits_table_get_Missing (&ftable, &catalog[0].Nmissing, NULL );133 catalog[0].missing = gfits_table_get_Missing (&ftable, &catalog[0].Nmissing, NULL, NULL); 133 134 if (!catalog[0].missing) { 134 135 fprintf (stderr, "ERROR: failed to read missing\n"); 135 136 exit (2); 136 137 } 137 if (Nmissing != catalog[0].Nmiss _disk) {138 fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nmissing, catalog[0].Nmiss _disk);139 } 140 catalog[0].Nmissing = catalog[0].Nmiss _disk;141 catalog[0].Nmiss _off = 0;138 if (Nmissing != catalog[0].Nmissing_disk) { 139 fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nmissing, catalog[0].Nmissing_disk); 140 } 141 catalog[0].Nmissing = catalog[0].Nmissing_disk; 142 catalog[0].Nmissing_off = 0; 142 143 } else { 143 144 Nbytes = gfits_data_size (&header); … … 145 146 ALLOCATE (catalog[0].missing, Missing, 1); 146 147 catalog[0].Nmissing = 0; 147 catalog[0].Nmiss _off = catalog[0].Nmiss_disk;148 catalog[0].Nmissing_off = catalog[0].Nmissing_disk; 148 149 } 149 150 … … 154 155 } 155 156 /* read secfilt table data */ 156 if (catalog[0].catflags & LOAD_SECF) {157 if (catalog[0].catflags & DVO_LOAD_SECFILT) { 157 158 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 158 159 if (VERBOSE) fprintf (stderr, "can't read table secfilt data"); … … 162 163 /* how many entries do we expect from the secfilt table? */ 163 164 Nexpect = catalog[0].Nsecfilt * catalog[0].Naverage; 164 catalog[0].secfilt = FtableToSecFilt (&ftable, &Nitems, &catalog[0].catformat);165 catalog[0].secfilt = FtableToSecFilt (&ftable, catalog[0].average, &Nitems, &catalog[0].catformat, FALSE); 165 166 if (Nexpect != Nitems) { 166 167 fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nexpect, Nitems); … … 175 176 Ntmpfilt = catalog[0].Nsecfilt; 176 177 Nsecfilt = catalog[0].Nsecfilt + 1; 177 Ntotal = Nsecfilt * catalog[0].Nave s_disk;178 Ntotal = Nsecfilt * catalog[0].Naverage_disk; 178 179 ALLOCATE (catalog[0].secfilt, SecFilt, Ntotal); 179 for (i = 0; i < catalog[0].Nave s_disk; i++) {180 for (i = 0; i < catalog[0].Naverage_disk; i++) { 180 181 catalog[0].secfilt[i*Nsecfilt + 0] = primary[i]; 181 182 for (j = 0; j < Ntmpfilt; j++) { … … 184 185 } 185 186 catalog[0].Nsecfilt = Nsecfilt; 186 catalog[0].Nsecf _disk = Ntotal;187 catalog[0].Nsecfilt_disk = Ntotal; 187 188 free (tmpfilt); 188 189 free (primary); 189 190 } 190 catalog[0].Nsecf _mem = catalog[0].Nsecf_disk;191 catalog[0].Nsecf _off = 0;191 catalog[0].Nsecfilt_mem = catalog[0].Nsecfilt_disk; 192 catalog[0].Nsecfilt_off = 0; 192 193 } else { 193 194 /* no real need to skip the data array here... */ … … 197 198 free (primary); 198 199 catalog[0].Nsecfilt ++; 199 catalog[0].Nsecf _disk = catalog[0].Nsecfilt * catalog[0].Naves_disk;200 catalog[0].Nsecfilt_disk = catalog[0].Nsecfilt * catalog[0].Naverage_disk; 200 201 } 201 202 ALLOCATE (catalog[0].secfilt, SecFilt, 1); 202 catalog[0].Nsecf _mem = 0;203 catalog[0].Nsecf _off = catalog[0].Nsecf_disk;203 catalog[0].Nsecfilt_mem = 0; 204 catalog[0].Nsecfilt_off = catalog[0].Nsecfilt_disk; 204 205 } 205 206 … … 210 211 } 211 212 /* read Lensing table data */ 212 if (catalog[0].catflags & LOAD_LENSING) {213 if (catalog[0].catflags & DVO_LOAD_LENSING) { 213 214 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 214 215 if (VERBOSE) fprintf (stderr, "can't read table lensing data"); 215 216 return (FALSE); 216 217 } 217 catalog[0].lensing = FtableToLensing (&ftable, &catalog[0].Nlensing, &catalog[0].catformat);218 catalog[0].lensing = FtableToLensing (&ftable, catalog[0].average, &catalog[0].Nlensing, &catalog[0].catformat, FALSE); 218 219 if (Nlensing != catalog[0].Nlensing_disk) { 219 220 fprintf (stderr, "Warning: mismatch between Nlensing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensing, catalog[0].Nlensing_disk); … … 235 236 } 236 237 /* read Lensobj table data */ 237 if (catalog[0].catflags & LOAD_LENSOBJ) {238 if (catalog[0].catflags & DVO_LOAD_LENSOBJ) { 238 239 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 239 240 if (VERBOSE) fprintf (stderr, "can't read table lensobj data"); 240 241 return (FALSE); 241 242 } 242 catalog[0].lensobj = FtableToLensobj (&ftable, &catalog[0].Nlensobj, &catalog[0].catformat);243 catalog[0].lensobj = FtableToLensobj (&ftable, catalog[0].average, &catalog[0].Nlensobj, &catalog[0].catformat, FALSE); 243 244 if (Nlensobj != catalog[0].Nlensobj_disk) { 244 245 fprintf (stderr, "Warning: mismatch between Nlensobj in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensobj, catalog[0].Nlensobj_disk); … … 260 261 } 261 262 /* read StarPar table data */ 262 if (catalog[0].catflags & LOAD_STARPAR) {263 if (catalog[0].catflags & DVO_LOAD_STARPAR) { 263 264 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 264 265 if (VERBOSE) fprintf (stderr, "can't read table starpar data"); 265 266 return (FALSE); 266 267 } 267 catalog[0].starpar = FtableToStarPar (&ftable, &catalog[0].Nstarpar, &catalog[0].catformat);268 catalog[0].starpar = FtableToStarPar (&ftable, catalog[0].average, &catalog[0].Nstarpar, &catalog[0].catformat, FALSE); 268 269 if (Nstarpar != catalog[0].Nstarpar_disk) { 269 270 fprintf (stderr, "Warning: mismatch between Nstarpar in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nstarpar, catalog[0].Nstarpar_disk); … … 277 278 catalog[0].Nstarpar = 0; 278 279 catalog[0].Nstarpar_off = catalog[0].Nstarpar_disk; 280 } 281 282 /* read GalPhot table header */ 283 if (!gfits_fread_header (catalog[0].f, &header)) { 284 if (VERBOSE) fprintf (stderr, "can't read table galphot header"); 285 return (FALSE); 286 } 287 /* read GalPhot table data */ 288 if (catalog[0].catflags & DVO_LOAD_GALPHOT) { 289 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 290 if (VERBOSE) fprintf (stderr, "can't read table galphot data"); 291 return (FALSE); 292 } 293 catalog[0].galphot = FtableToGalPhot (&ftable, catalog[0].average, &catalog[0].Ngalphot, &catalog[0].catformat, FALSE); 294 if (Ngalphot != catalog[0].Ngalphot_disk) { 295 fprintf (stderr, "Warning: mismatch between Ngalphot in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Ngalphot, catalog[0].Ngalphot_disk); 296 } 297 catalog[0].Ngalphot = catalog[0].Ngalphot_disk; 298 catalog[0].Ngalphot_off = 0; 299 } else { 300 Nbytes = gfits_data_size (&header); 301 fseeko (catalog[0].f, Nbytes, SEEK_CUR); 302 ALLOCATE (catalog[0].galphot, GalPhot, 1); 303 catalog[0].Ngalphot = 0; 304 catalog[0].Ngalphot_off = catalog[0].Ngalphot_disk; 279 305 } 280 306 … … 330 356 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, catalog[0].Nlensobj); 331 357 gfits_modify (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, catalog[0].Nstarpar); 358 gfits_modify (&catalog[0].header, "NGALPHOT", OFF_T_FMT, 1, catalog[0].Ngalphot); 359 332 360 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 333 361 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 357 385 358 386 /* write out Average table (convert to FITS table format) */ 359 AverageToFtable (&ftable, catalog[0].average, catalog[0].Naverage, catalog[0].catformat, primary );387 AverageToFtable (&ftable, catalog[0].average, catalog[0].Naverage, catalog[0].catformat, primary, TRUE); 360 388 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 361 389 fprintf (stderr, "can't write table header"); … … 370 398 371 399 /* write out Measure table (convert to FITS table format) */ 372 MeasureToFtable (&ftable, catalog[0].average, catalog[0].measure, catalog[0].Nmeasure, catalog[0].catformat );400 MeasureToFtable (&ftable, catalog[0].average, catalog[0].measure, catalog[0].Nmeasure, catalog[0].catformat, TRUE); 373 401 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 374 402 fprintf (stderr, "can't write table header"); … … 383 411 384 412 /* write out Missing table (convert to FITS table format) */ 385 gfits_table_set_Missing (&ftable, catalog[0].missing, catalog[0].Nmissing );413 gfits_table_set_Missing (&ftable, catalog[0].missing, catalog[0].Nmissing, TRUE); 386 414 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 387 415 fprintf (stderr, "can't write table header"); … … 397 425 /* write out SecFilt table (convert to FITS table format) */ 398 426 Nitems = catalog[0].Naverage * Nsecfilt; 399 SecFiltToFtable (&ftable, secfilt, Nitems, catalog[0].catformat );427 SecFiltToFtable (&ftable, secfilt, Nitems, catalog[0].catformat, TRUE); 400 428 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 401 429 fprintf (stderr, "can't write table header"); … … 410 438 411 439 /* write out Lensing table (convert to FITS table format) */ 412 LensingToFtable (&ftable, catalog[0].lensing, catalog[0].Nlensing, catalog[0].catformat );440 LensingToFtable (&ftable, catalog[0].lensing, catalog[0].Nlensing, catalog[0].catformat, TRUE); 413 441 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 414 442 fprintf (stderr, "can't write table header"); … … 423 451 424 452 /* write out Lensobj table (convert to FITS table format) */ 425 LensobjToFtable (&ftable, catalog[0].lensobj, catalog[0].Nlensobj, catalog[0].catformat); 426 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 427 fprintf (stderr, "can't write table header"); 428 goto failure; 429 } 430 if (!gfits_fwrite_table (catalog[0].f, &ftable)) { 431 fprintf (stderr, "can't write table data"); 432 goto failure; 433 } 434 gfits_free_table (&ftable); 435 gfits_free_header (&header); 436 437 /* free temp storage */ 438 if (primary != NULL) { 439 free (primary); 440 free (secfilt); 441 } 442 return (TRUE); 453 LensobjToFtable (&ftable, catalog[0].lensobj, catalog[0].Nlensobj, catalog[0].catformat, TRUE); 454 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 455 fprintf (stderr, "can't write table header"); 456 goto failure; 457 } 458 if (!gfits_fwrite_table (catalog[0].f, &ftable)) { 459 fprintf (stderr, "can't write table data"); 460 goto failure; 461 } 462 gfits_free_table (&ftable); 463 gfits_free_header (&header); 443 464 444 465 /* write out StarPar table (convert to FITS table format) */ 445 StarParToFtable (&ftable, catalog[0].starpar, catalog[0].Nstarpar, catalog[0].catformat); 466 StarParToFtable (&ftable, catalog[0].starpar, catalog[0].Nstarpar, catalog[0].catformat, TRUE); 467 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 468 fprintf (stderr, "can't write table header"); 469 goto failure; 470 } 471 if (!gfits_fwrite_table (catalog[0].f, &ftable)) { 472 fprintf (stderr, "can't write table data"); 473 goto failure; 474 } 475 gfits_free_table (&ftable); 476 gfits_free_header (&header); 477 478 /* write out GalPhot table (convert to FITS table format) */ 479 GalPhotToFtable (&ftable, catalog[0].galphot, catalog[0].Ngalphot, catalog[0].catformat, TRUE); 446 480 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 447 481 fprintf (stderr, "can't write table header"); -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_catalog_raw.c
r37807 r38447 136 136 /* read and convert the averages (use a macro to clean this up?) */ 137 137 /* old versions of DVO stored one of the average magnitudes in Average. we save this if needed */ 138 if (catalog[0].catflags & LOAD_AVES) {138 if (catalog[0].catflags & DVO_LOAD_AVERAGE) { 139 139 catalog[0].average = ReadRawAverage (catalog[0].f, catalog[0].Naverage, catalog[0].catformat, &primary); 140 140 } else { … … 145 145 146 146 /* read and convert the measures (use a macro to clean this up?) */ 147 if (catalog[0].catflags & LOAD_MEAS) {147 if (catalog[0].catflags & DVO_LOAD_MEASURE) { 148 148 catalog[0].measure = ReadRawMeasure (catalog[0].f, catalog[0].average, catalog[0].Nmeasure, catalog[0].catformat); 149 149 } else { … … 154 154 155 155 /* read and convert missing */ 156 if (catalog[0].catflags & LOAD_MISS) {156 if (catalog[0].catflags & DVO_LOAD_MISSING) { 157 157 ALLOCATE (catalog[0].missing, Missing, MAX (catalog[0].Nmissing, 1)); 158 158 Nitems = catalog[0].Nmissing; … … 170 170 171 171 /* read and convert secfilt */ 172 if (catalog[0].catflags & LOAD_SECF) {172 if (catalog[0].catflags & DVO_LOAD_SECFILT) { 173 173 Nitems = catalog[0].Naverage * catalog[0].Nsecfilt; 174 174 catalog[0].secfilt = ReadRawSecFilt (catalog[0].f, Nitems, catalog[0].catformat); … … 191 191 } 192 192 catalog[0].Nsecfilt = Nsecfilt; 193 catalog[0].Nsecf _mem = Ntotal;193 catalog[0].Nsecfilt_mem = Ntotal; 194 194 free (primary); 195 195 } … … 210 210 211 211 /* check data integrity */ 212 if (catalog[0].catflags & LOAD_AVES) {212 if (catalog[0].catflags & DVO_LOAD_AVERAGE) { 213 213 for (i = Nmeas = Nmiss = 0; i < catalog[0].Naverage; i++) { 214 214 Nmeas += catalog[0].average[i].Nmeasure; … … 226 226 227 227 /* save the current number so we can do partial updates */ 228 catalog[0].Nave s_disk = catalog[0].Naverage;229 catalog[0].Nmeas _disk = catalog[0].Nmeasure;230 catalog[0].Nmiss _disk = catalog[0].Nmissing;228 catalog[0].Naverage_disk = catalog[0].Naverage; 229 catalog[0].Nmeasure_disk = catalog[0].Nmeasure; 230 catalog[0].Nmissing_disk = catalog[0].Nmissing; 231 231 232 232 return (TRUE); -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_catalog_split.c
r38153 r38447 1 1 # include <dvo.h> 2 # define OHANA_MEMCHECK 0 2 3 3 4 // return options: … … 6 7 // * ok 7 8 9 // utility function to see if we should compress this table) 10 int output_is_compressed (int start, int Nrows, int Ntotal, DVOCatCompress catcompress) { 11 int fullWrite = (start == 0) && (Nrows == Ntotal); 12 if (fullWrite && catcompress) return TRUE; // we want to compress, so do not swap 13 return FALSE; 14 } 15 16 int byteswap_varlength_ftable (Header *header, FTable *table) { 17 int i, Nfields; 18 if (!gfits_scan (header, "TFIELDS", "%d", 1, &Nfields)) return FALSE; 19 for (i = 0; i < Nfields; i++) { 20 if (!gfits_byteswap_varlength_column (table, i+1)) return FALSE; 21 } 22 return TRUE; 23 } 24 8 25 int dvo_catalog_secfilt_to_primary (Catalog *catalog, SecFilt **myPrimary, SecFilt **mySecfilt, int *myNsecfilt) { 9 26 … … 20 37 21 38 // XXX this translation only works if we have loaded / created a matched average/secfilt set 22 assert (catalog[0].Nsecf _mem == catalog[0].Nsecfilt*catalog[0].Naverage);39 assert (catalog[0].Nsecfilt_mem == catalog[0].Nsecfilt*catalog[0].Naverage); 23 40 24 41 Nallfilt = catalog[0].Nsecfilt; … … 35 52 } 36 53 catalog[0].Nsecfilt --; 37 catalog[0].Nsecf _mem = catalog[0].Naverage*catalog[0].Nsecfilt;54 catalog[0].Nsecfilt_mem = catalog[0].Naverage*catalog[0].Nsecfilt; 38 55 39 56 *myPrimary = primary; … … 51 68 Ntmpfilt = catalog[0].Nsecfilt; 52 69 53 // we do NOT modify Nsecf _disk; this operation only modifies in in-memory values70 // we do NOT modify Nsecfilt_disk; this operation only modifies in in-memory values 54 71 55 72 catalog[0].Nsecfilt ++; … … 57 74 Ntotal = Nsecfilt * Naves; 58 75 59 catalog[0].Nsecf _mem = Ntotal;76 catalog[0].Nsecfilt_mem = Ntotal; 60 77 61 78 ALLOCATE (catalog[0].secfilt, SecFilt, Ntotal); … … 74 91 75 92 Matrix matrix; 76 77 // ohana_memcheck_func (TRUE);78 93 79 80 if (0) { 81 // XXX a TEST : is the data corrupted or the file? 82 char name[1024]; 83 snprintf (name, 1024, "%s.phu.v2", catalog->filename); 84 FILE *f = fopen (name, "w"); 85 fwrite (catalog->header.buffer, sizeof(char), catalog->header.datasize, f); 86 // fprintf (stderr, "save %d bytes in %s (%zx)\n", (int) catalog->header.datasize, name, (size_t) catalog->header.buffer); 87 // fprintf (stderr, "first bytes are %c%c%c%c%c%c%c%c\n", 88 // catalog->header.buffer[0], catalog->header.buffer[1], catalog->header.buffer[2], catalog->header.buffer[3], 89 // catalog->header.buffer[4], catalog->header.buffer[5], catalog->header.buffer[6], catalog->header.buffer[7]); 90 fclose (f); 91 } 92 if (0) { 93 // XXX a TEST : is the data corrupted or the file? 94 char name[1024]; 95 snprintf (name, 1024, "%s.phu", catalog->filename); 96 FILE *f = fopen (name, "w"); 97 fwrite (catalog->header.buffer, sizeof(char), catalog->header.datasize, f); 98 // fprintf (stderr, "save %d bytes in %s (%zx)\n", (int) catalog->header.datasize, name, (size_t) catalog->header.buffer); 99 // fprintf (stderr, "first bytes are %c%c%c%c%c%c%c%c\n", 100 // catalog->header.buffer[0], catalog->header.buffer[1], catalog->header.buffer[2], catalog->header.buffer[3], 101 // catalog->header.buffer[4], catalog->header.buffer[5], catalog->header.buffer[6], catalog->header.buffer[7]); 102 fclose (f); 103 } 104 # if (0) 105 { 106 // XXX a TEST : is the data corrupted or the file? 107 char name[1024]; 108 snprintf (name, 1024, "%s.phu.v2", catalog->filename); 109 FILE *f = fopen (name, "w"); 110 fwrite (catalog->header.buffer, sizeof(char), catalog->header.datasize, f); 111 fprintf (stderr, "save %d bytes in %s (%zx)\n", (int) catalog->header.datasize, name, (size_t) catalog->header.buffer); 112 fprintf (stderr, "first bytes are %c%c%c%c%c%c%c%c\n", 113 catalog->header.buffer[0], catalog->header.buffer[1], catalog->header.buffer[2], catalog->header.buffer[3], 114 catalog->header.buffer[4], catalog->header.buffer[5], catalog->header.buffer[6], catalog->header.buffer[7]); 115 fclose (f); 116 } 117 { 118 // XXX a TEST : is the data corrupted or the file? 119 char name[1024]; 120 snprintf (name, 1024, "%s.phu.v3", catalog->filename); 121 FILE *f = fopen (name, "w"); 122 fwrite (catalog->header.buffer, sizeof(char), catalog->header.datasize, f); 123 fprintf (stderr, "save %d bytes in %s (%zx)\n", (int) catalog->header.datasize, name, (size_t) catalog->header.buffer); 124 fprintf (stderr, "first bytes are %c%c%c%c%c%c%c%c\n", 125 catalog->header.buffer[0], catalog->header.buffer[1], catalog->header.buffer[2], catalog->header.buffer[3], 126 catalog->header.buffer[4], catalog->header.buffer[5], catalog->header.buffer[6], catalog->header.buffer[7]); 127 fclose (f); 128 } 129 # endif 94 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 95 130 96 /* rewind file pointers and truncate (file is still open) */ 131 97 if (fseeko (catalog->f, 0LL, SEEK_SET)) { 132 98 perror ("dvo_catalog_save_subset: "); 133 99 fprintf (stderr, "failed to seek to beginning\n"); 100 return FALSE; 134 101 } 135 102 … … 151 118 gfits_free_matrix (&matrix); 152 119 120 FTable *outtable = ftable; 121 FTable cmptable; 122 Header cmpheader; 123 gfits_init_header (&cmpheader); 124 gfits_init_table (&cmptable); 125 cmptable.header = &cmpheader; 126 127 int fullWrite = (start == 0) && (Nrows == Ntotal); 128 int isCompressed = output_is_compressed (start, Nrows, Ntotal, catalog->catcompress); 129 130 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 131 132 if (isCompressed) { 133 // fprintf (stderr, "compress %s\n", catalog->filename); 134 char *compressMode = dvo_catalog_compress_string (catalog->catcompress); 135 // I should test how Ntile affects fpack/funpack and speed 136 if (!gfits_compress_table (ftable, &cmptable, 1000, compressMode)) { 137 fprintf (stderr, "compression failure\n"); 138 return (FALSE); 139 } 140 if (!byteswap_varlength_ftable (&cmpheader, &cmptable)) { 141 fprintf (stderr, "failed to swap varlength column\n"); 142 return FALSE; 143 } 144 if (!gfits_modify (cmptable.header, "DVO_CMP", "%s", 1, compressMode)) { 145 fprintf (stderr, "can't save compression mode\n"); 146 return (FALSE); 147 } 148 outtable = &cmptable; 149 } 150 151 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 152 153 153 // write the table data 154 if (!gfits_fwrite_ftable_range (catalog->f, ftable, start, Nrows, Ndisk, Ntotal)) { 155 fprintf (stderr, "can't write table data\n"); 156 return (FALSE); 157 } 158 fullsize += ftable->datasize + ftable->header->datasize; 154 if (fullWrite) { 155 if (!gfits_fwrite_Theader (catalog->f, outtable->header)) { 156 fprintf (stderr, "can't write table header\n"); 157 return (FALSE); 158 } 159 if (!gfits_fwrite_table (catalog->f, outtable)) { 160 fprintf (stderr, "can't write table data\n"); 161 return (FALSE); 162 } 163 } else { 164 if (!gfits_fwrite_ftable_range (catalog->f, outtable, start, Nrows, Ndisk, Ntotal)) { 165 fprintf (stderr, "can't write table data (range)\n"); 166 return (FALSE); 167 } 168 } 169 fullsize += outtable->datasize + outtable->header->datasize; 170 171 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 172 173 // since we init'ed the structures above, these operations are safe whether or not we compressed the table 174 gfits_free_header (&cmpheader); 175 gfits_free_table (&cmptable); 159 176 160 177 // if the output file will be completely re-written, truncate to total datasize 161 if ( (start == 0) && (Nrows == Ntotal)) {178 if (fullWrite) { 162 179 int fd = fileno (catalog->f); 163 180 if (ftruncate (fd, fullsize)) { … … 192 209 // databases created prior to ~2014.07.01 did not have the LENSING, LENSOBJ, STARPAR paths in their headers. 193 210 // in these cases, we do not try to lock or open the relevant file 194 if (!strcmp (name, "LENSING")) return (DVO_CAT_OPEN_EMPTY); 195 if (!strcmp (name, "LENSOBJ")) return (DVO_CAT_OPEN_EMPTY); 196 if (!strcmp (name, "STARPAR")) return (DVO_CAT_OPEN_EMPTY); 211 if (!strcmp (name, "LENSING")) return (DVO_CAT_OPEN_EMPTY); 212 if (!strcmp (name, "LENSOBJ")) return (DVO_CAT_OPEN_EMPTY); 213 if (!strcmp (name, "STARPAR")) return (DVO_CAT_OPEN_EMPTY); 214 if (!strcmp (name, "GALPHOT")) return (DVO_CAT_OPEN_EMPTY); 197 215 return (DVO_CAT_OPEN_FAIL); 198 216 } … … 200 218 sprintf (subcat[0].filename, "%s/%s", path, string); 201 219 free (path); 220 221 // inherit compression mode for this subcat; 222 subcat->catcompress = catalog->catcompress; 202 223 203 224 /* lock & open catalog file */ … … 220 241 } 221 242 Nskip = gfits_data_size (&subcat[0].header); 222 fseeko (subcat[0].f, Nskip, SEEK_CUR);243 if (fseeko (subcat[0].f, Nskip, SEEK_CUR)) { perror ("fseeko: "); exit (1); } 223 244 224 245 /* read table header */ … … 230 251 return (DVO_CAT_OPEN_OK); 231 252 } 253 254 // ftable must already exist and have a valid, loaded header 255 int gfits_fread_uncompressed (Catalog *catalog, FTable *ftable, char *nativeOrder, char VERBOSE) { 256 257 // fread_ftable_data requires the header 258 259 *nativeOrder = FALSE; 260 if (!gfits_fread_ftable_data (catalog->f, ftable, FALSE)) { 261 if (VERBOSE) fprintf (stderr, "can't read table data\n"); 262 return FALSE; 263 } 264 // NOTE: fread_ftable returns an unswapped table; uncompress swaps the bytes into native order 265 266 if (gfits_extension_is_compressed_table (ftable->header)) { 267 FTable rawtable; 268 Header rawheader; 269 gfits_init_table (&rawtable); 270 gfits_init_header (&rawheader); 271 rawtable.header = &rawheader; 272 273 // NOTE: uncompress swaps the data bytes into native order, but needs the varlength columns native 274 if (!byteswap_varlength_ftable (ftable->header, ftable)) { 275 fprintf (stderr, "failed to swap varlength column\n"); 276 return FALSE; 277 } 278 if (!gfits_uncompress_table (ftable, &rawtable)) { 279 if (VERBOSE) fprintf (stderr, "failed to uncompress table\n"); 280 gfits_free_table (ftable); 281 return FALSE; 282 } 283 284 char compressMode[80]; 285 if (!gfits_scan (ftable->header, "DVO_CMP", "%s", 1, compressMode)) { 286 strcpy (compressMode, "AUTO"); 287 } 288 catalog->catcompress = dvo_catalog_catcompress (compressMode); // if any table is compressed, set all to a compress state? 289 290 // free the buffers 291 gfits_free_header (ftable->header); 292 gfits_free_table (ftable); 293 294 // copies values but does not allocate new memory 295 Header *outheader = ftable->header; 296 gfits_copy_header_ptr (&rawheader, outheader); 297 gfits_copy_ftable_ptr (&rawtable, ftable); // this replaces ftable->header 298 ftable->header = outheader; 299 *nativeOrder = TRUE; 300 } 301 return TRUE; 302 } 303 304 // LOAD_SUBCAT(measure,MEASURE,Measure) 305 306 # define LOAD_SUBCAT(FIELD, NAME, STRUCT) \ 307 { \ 308 Header header; \ 309 FTable ftable; \ 310 off_t Nitems; \ 311 gfits_init_table (&ftable); \ 312 gfits_init_header (&header); \ 313 ftable.header = &header; \ 314 int status = DVO_CAT_OPEN_EMPTY; \ 315 if (!(catalog[0].catflags & DVO_SKIP_##NAME)) { \ 316 status = dvo_catalog_open_subcat (catalog, &catalog[0].FIELD##_catalog, ftable.header, #NAME, VERBOSE); \ 317 if (status == DVO_CAT_OPEN_FAIL) { \ 318 return (FALSE); \ 319 } \ 320 if ((status == DVO_CAT_OPEN_EMPTY) && (catalog[0].N##FIELD##_disk > 0)) { \ 321 return (FALSE); \ 322 } \ 323 } \ 324 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & DVO_LOAD_##NAME)) { \ 325 char nativeOrder = FALSE; \ 326 /* read table data */ \ 327 if (!gfits_fread_uncompressed (catalog[0].FIELD##_catalog, &ftable, &nativeOrder, VERBOSE)) { \ 328 if (VERBOSE) fprintf (stderr, "can't read table %s data\n", #FIELD); \ 329 gfits_free_header (&header); \ 330 return (FALSE); \ 331 } \ 332 /* convert data format to internal : returns number of row read in Nvalues */ \ 333 catalog[0].FIELD = FtableTo##STRUCT (&ftable, catalog[0].average, &Nitems, &catalog[0].catformat, nativeOrder); \ 334 if (Nitems != catalog[0].N##FIELD##_disk) { \ 335 fprintf (stderr, "Warning: mismatch between N%s in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", #FIELD, Nitems, catalog[0].N##FIELD##_disk); \ 336 } \ 337 catalog[0].N##FIELD = catalog[0].N##FIELD##_disk; \ 338 catalog[0].N##FIELD##_off = 0; \ 339 } else { \ 340 if (catalog[0].FIELD##_catalog) { \ 341 gfits_free_header (&catalog[0].FIELD##_catalog[0].header); \ 342 } else { \ 343 ALLOCATE (catalog[0].FIELD##_catalog, Catalog, 1); \ 344 dvo_catalog_init (catalog[0].FIELD##_catalog, TRUE); \ 345 } \ 346 gfits_create_header (&catalog[0].FIELD##_catalog[0].header); \ 347 ALLOCATE (catalog[0].FIELD, STRUCT, 1); \ 348 catalog[0].N##FIELD = 0; \ 349 catalog[0].N##FIELD##_off = catalog[0].N##FIELD##_disk; \ 350 } \ 351 gfits_free_header (&header); \ 352 } 232 353 233 354 int dvo_catalog_load_split (Catalog *catalog, int VERBOSE) { … … 240 361 off_t Nlensobj; 241 362 off_t Nstarpar; 242 off_t Nitems; 243 int status, Nsecfilt; 244 Header header; 245 FTable ftable; 363 off_t Ngalphot; 364 int Nsecfilt; 246 365 SecFilt *primary; 247 366 248 /* ftable header storage for below */249 ftable.header = &header;250 ftable.buffer = NULL;251 header.buffer = NULL;252 367 primary = NULL; 253 status = FALSE;254 368 255 369 /* get the components from the header - these duplicate information in the split files (NAXIS2) */ 256 // NSTARS, NMEAS, NMISS are required; NLENSING, NLENSOBJ, NSTARPAR are not (0 if not found) 257 if (!gfits_scan (&catalog[0].header, "NSTARS", OFF_T_FMT, 1, &Naverage)) return (FALSE); 258 if (!gfits_scan (&catalog[0].header, "NMEAS", OFF_T_FMT, 1, &Nmeasure)) return (FALSE); 259 if (!gfits_scan (&catalog[0].header, "NMISS", OFF_T_FMT, 1, &Nmissing)) return (FALSE); 260 if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0; 261 if (!gfits_scan (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, &Nlensing)) Nlensing = 0; 262 if (!gfits_scan (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, &Nlensobj)) Nlensobj = 0; 263 if (!gfits_scan (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, &Nstarpar)) Nstarpar = 0; 370 // NSTARS, NMEAS, NMISS are required; NLENSING, NLENSOBJ, NSTARPAR, NGALPHOT are not (0 if not found) 371 if (!gfits_scan (&catalog[0].header, "NSTARS", OFF_T_FMT, 1, &Naverage)) return (FALSE); 372 if (!gfits_scan (&catalog[0].header, "NMEAS", OFF_T_FMT, 1, &Nmeasure)) return (FALSE); 373 if (!gfits_scan (&catalog[0].header, "NMISS", OFF_T_FMT, 1, &Nmissing)) return (FALSE); 374 if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0; 375 if (!gfits_scan (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, &Nlensing)) Nlensing = 0; 376 if (!gfits_scan (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, &Nlensobj)) Nlensobj = 0; 377 if (!gfits_scan (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, &Nstarpar)) Nstarpar = 0; 378 if (!gfits_scan (&catalog[0].header, "NGALPHOT", OFF_T_FMT, 1, &Ngalphot)) Ngalphot = 0; 264 379 265 380 /* the OBJID is a counter that uniquely defines an average entry and never changes. if … … 276 391 277 392 /* save the current number so we can do partial updates */ 278 catalog[0].Naves_disk = Naverage; 279 catalog[0].Nmeas_disk = Nmeasure; 280 catalog[0].Nmiss_disk = Nmissing; 281 catalog[0].Nsecf_disk = Naverage * Nsecfilt; 282 catalog[0].Nlensing_disk = Nlensing; 283 catalog[0].Nlensobj_disk = Nlensobj; 284 catalog[0].Nstarpar_disk = Nstarpar; 285 286 /** Nsecfilt is unusual: it does not list the number of data items in the table 287 instead, the number of items is Nsecfilt * Naverage. **/ 288 catalog[0].Nsecfilt = Nsecfilt; 393 catalog[0].Naverage_disk = Naverage; 394 catalog[0].Nmeasure_disk = Nmeasure; 395 catalog[0].Nmissing_disk = Nmissing; 396 catalog[0].Nsecfilt_disk = Naverage * Nsecfilt; 397 catalog[0].Nlensing_disk = Nlensing; 398 catalog[0].Nlensobj_disk = Nlensobj; 399 catalog[0].Nstarpar_disk = Nstarpar; 400 catalog[0].Ngalphot_disk = Ngalphot; 289 401 290 402 /* default values, but we will assign these a valid value before we exit (even if empty) */ 291 catalog[0].average = NULL; 292 catalog[0].measure = NULL; 293 catalog[0].missing = NULL; 294 catalog[0].secfilt = NULL; 295 catalog[0].lensing = NULL; 296 catalog[0].lensobj = NULL; 297 catalog[0].starpar = NULL; 403 catalog[0].average = NULL; 404 catalog[0].measure = NULL; 405 catalog[0].missing = NULL; 406 catalog[0].secfilt = NULL; 407 catalog[0].lensing = NULL; 408 catalog[0].lensobj = NULL; 409 catalog[0].starpar = NULL; 410 catalog[0].galphot = NULL; 298 411 299 412 /*** Average Table ***/ … … 302 415 /* move pointer past PHU header -- must be already read (load_catalog) */ 303 416 Nbytes = catalog[0].header.datasize + gfits_data_size (&catalog[0].header); 304 fseeko (catalog[0].f, Nbytes, SEEK_SET); 417 if (fseeko (catalog[0].f, Nbytes, SEEK_SET)) { perror ("fseeko: "); exit (1); } 418 419 /* ftable header storage for below */ 420 char nativeOrder; 421 Header header; 422 FTable ftable; 423 gfits_init_table (&ftable); 424 gfits_init_header (&header); 425 ftable.header = &header; 305 426 306 427 /* read Average table header */ 307 428 if (!gfits_fread_header (catalog[0].f, &header)) { 308 if (VERBOSE) fprintf (stderr, "can't read table average header ");429 if (VERBOSE) fprintf (stderr, "can't read table average header\n"); 309 430 return (FALSE); 310 431 } 311 if (catalog[0].catflags & LOAD_AVES) { 312 /* read Average table data : format is irrelevant here */ 313 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 314 if (VERBOSE) fprintf (stderr, "can't read table average data"); 315 return (FALSE); 316 } 317 /* convert the saved version of the table to the internal version. Old versions of DVO stored 432 if (catalog[0].catflags & DVO_LOAD_AVERAGE) { 433 if (!gfits_fread_uncompressed (catalog, &ftable, &nativeOrder, VERBOSE)) { 434 if (VERBOSE) fprintf (stderr, "can't read Average table\n"); 435 gfits_free_header (&header); 436 return FALSE; 437 } 438 439 /* convert the disk version of the table to the internal version. Old versions of DVO stored 318 440 * one of the average magnitudes in Average. We save this in case it is needed below. NOTE: 319 441 * primary is only used if we read in the secfilt table, otherwise it should be freed */ 320 catalog[0].average = FtableToAverage (&ftable, &Naverage, &catalog[0].catformat, &primary); 321 if (Naverage != catalog[0].Naves_disk) { 322 fprintf (stderr, "Warning: mismatch between Naverage in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Naverage, catalog[0].Naves_disk); 323 } 324 gfits_free_header (&header); 325 catalog[0].Naverage = catalog[0].Naves_disk; 326 catalog[0].Naves_off = 0; 442 catalog[0].average = FtableToAverage (&ftable, &Naverage, &catalog[0].catformat, &primary, nativeOrder); 443 if (Naverage != catalog[0].Naverage_disk) { 444 fprintf (stderr, "Warning: mismatch between Naverage in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Naverage, catalog[0].Naverage_disk); 445 } 446 catalog[0].Naverage = catalog[0].Naverage_disk; 447 catalog[0].Naverage_off = 0; 327 448 } else { 328 449 catalog[0].catformat = FtableGetFormat (&ftable); 329 450 ALLOCATE (catalog[0].average, Average, 1); 330 451 catalog[0].Naverage = 0; 331 catalog[0].Naves_off = catalog[0].Naves_disk; 332 } 452 catalog[0].Naverage_off = catalog[0].Naverage_disk; 453 } 454 gfits_free_header (&header); 333 455 334 456 /*** Measure Table ***/ 335 if (!(catalog[0].catflags & SKIP_MEAS)) { 336 // unless we specify 'skip', we still need to load the 337 status = dvo_catalog_open_subcat (catalog, &catalog[0].measure_catalog, ftable.header, "MEASURE", VERBOSE); 338 if (status == DVO_CAT_OPEN_FAIL) { 339 return (FALSE); 340 } 341 if ((status == DVO_CAT_OPEN_EMPTY) && (catalog[0].Nmeas_disk > 0)) { 342 return (FALSE); 343 } 344 } 345 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_MEAS)) { 346 // XXX this allows an empty Measure catalog with non-empty Average catalog : is that OK? 347 /* read Measure table data */ 348 if (!gfits_fread_ftable_data (catalog[0].measure_catalog[0].f, &ftable, FALSE)) { 349 if (VERBOSE) fprintf (stderr, "can't read table measure data\n"); 350 return (FALSE); 351 } 352 /* convert data format to internal : returns number of row read in Nmeasure */ 353 catalog[0].measure = FtableToMeasure (&ftable, catalog[0].average, &Nmeasure, &catalog[0].catformat); 354 if (Nmeasure != catalog[0].Nmeas_disk) { 355 fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nmeasure, catalog[0].Nmeas_disk); 356 } 357 catalog[0].Nmeasure = catalog[0].Nmeas_disk; 358 catalog[0].Nmeas_off = 0; 359 } else { 360 // XXX is it necessary to generate a template header here? 361 // XXX this is a memory leak, right? 362 if (catalog[0].measure_catalog) { 363 gfits_free_header (&catalog[0].measure_catalog[0].header); 457 458 LOAD_SUBCAT(measure,MEASURE,Measure); 459 LOAD_SUBCAT(missing,MISSING,Missing); 460 LOAD_SUBCAT(secfilt,SECFILT,SecFilt); 461 LOAD_SUBCAT(lensing,LENSING,Lensing); 462 LOAD_SUBCAT(lensobj,LENSOBJ,Lensobj); 463 LOAD_SUBCAT(starpar,STARPAR,StarPar); 464 LOAD_SUBCAT(galphot,GALPHOT,GalPhot); 465 466 /** catalog->Nsecfilt is unusual: it does not list the number of data items in the 467 table instead, the number of items is Nsecfilt * Naverage, and is stored in 468 Nsecfilt_mem. fix these below **/ 469 470 catalog[0].Nsecfilt_mem = catalog[0].Nsecfilt; 471 catalog[0].Nsecfilt = Nsecfilt; 472 473 /** some old formats stored one of the secfilt values in the average table. 474 repair this below **/ 475 476 if (primary) { 477 if (catalog[0].Nsecfilt_mem) { 478 dvo_catalog_primary_to_secfilt (catalog, primary, catalog[0].Naverage_disk); 364 479 } else { 365 ALLOCATE (catalog[0].measure_catalog, Catalog, 1);366 dvo_catalog_init (catalog[0].measure_catalog, TRUE);367 }368 gfits_create_header (&catalog[0].measure_catalog[0].header);369 ALLOCATE (catalog[0].measure, Measure, 1);370 catalog[0].Nmeasure = 0;371 catalog[0].Nmeas_off = catalog[0].Nmeas_disk;372 }373 gfits_free_header (&header);374 375 /*** Missing Table ***/376 status = dvo_catalog_open_subcat (catalog, &catalog[0].missing_catalog, ftable.header, "MISSING", VERBOSE);377 if (status == DVO_CAT_OPEN_FAIL) {378 return (FALSE);379 }380 if ((status == DVO_CAT_OPEN_EMPTY) && (catalog[0].Nmiss_disk > 0)) {381 return (FALSE);382 }383 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_MISS)) {384 /* read Missing table data */385 if (!gfits_fread_ftable_data (catalog[0].missing_catalog[0].f, &ftable, FALSE)) {386 if (VERBOSE) fprintf (stderr, "can't read table missing data\n");387 return (FALSE);388 }389 /* no conversions currently defined : this just does the byte swap */390 catalog[0].missing = gfits_table_get_Missing (&ftable, &Nmissing, NULL);391 if (!catalog[0].missing) {392 fprintf (stderr, "ERROR: failed to read missing\n");393 exit (2);394 }395 if (Nmissing != catalog[0].Nmiss_disk) {396 fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nmissing, catalog[0].Nmiss_disk);397 }398 catalog[0].Nmissing = catalog[0].Nmiss_disk;399 catalog[0].Nmiss_off = 0;400 } else {401 // XXX is it necessary to generate a template header here?402 gfits_create_header (&catalog[0].missing_catalog[0].header);403 ALLOCATE (catalog[0].missing, Missing, 1);404 catalog[0].Nmissing = 0;405 catalog[0].Nmiss_off = catalog[0].Nmiss_disk;406 }407 gfits_free_header (ftable.header);408 409 /*** Secfilt Table ***/410 status = dvo_catalog_open_subcat (catalog, &catalog[0].secfilt_catalog, ftable.header, "SECFILT", VERBOSE);411 // fprintf (stderr, "secfilt header %s : %zx\n", catalog[0].secfilt_catalog[0].filename, (size_t) catalog[0].secfilt_catalog[0].header.buffer);412 if (status == DVO_CAT_OPEN_FAIL) {413 return (FALSE);414 }415 if ((status == DVO_CAT_OPEN_EMPTY) && (catalog[0].Nsecf_disk > 0)) {416 return (FALSE);417 }418 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_SECF)) {419 /* read secfilt table data */420 if (!gfits_fread_ftable_data (catalog[0].secfilt_catalog[0].f, &ftable, FALSE)) {421 if (VERBOSE) fprintf (stderr, "can't read table secfilt data\n");422 return (FALSE);423 }424 catalog[0].secfilt = FtableToSecFilt (&ftable, &Nitems, &catalog[0].catformat);425 if (Nitems != catalog[0].Nsecf_disk) {426 fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nitems, catalog[0].Nsecf_disk);427 }428 catalog[0].Nsecf_mem = catalog[0].Nsecf_disk;429 catalog[0].Nsecf_off = 0;430 431 /* if primary is defined, we were supplied with one additional average magnitude from Average432 we need to interleave these magnitudes with the secfilt entries just loaded */433 if (primary != NULL) {434 // this modifies catalog.Nsecf_mem,Nsecfilt435 dvo_catalog_primary_to_secfilt (catalog, primary, catalog[0].Naves_disk);436 }437 } else {438 if (primary != NULL) {439 480 free (primary); 440 481 catalog[0].Nsecfilt ++; 441 482 } 442 gfits_create_header (&catalog[0].secfilt_catalog[0].header); 443 ALLOCATE (catalog[0].secfilt, SecFilt, 1); 444 catalog[0].Nsecf_mem = 0; 445 catalog[0].Nsecf_off = catalog[0].Nsecf_disk; 446 } 447 gfits_free_header (ftable.header); 448 449 /*** Lensing Table ***/ 450 if (!(catalog[0].catflags & SKIP_LENSING)) { 451 // unless we specify 'skip', we still need to load the Lensing table 452 status = dvo_catalog_open_subcat (catalog, &catalog[0].lensing_catalog, ftable.header, "LENSING", VERBOSE); 453 if (status == DVO_CAT_OPEN_FAIL) { 454 return (FALSE); 455 } 456 // the Lensing file need not exist, unless we expect data to exist 457 if ((status == DVO_CAT_OPEN_EMPTY) && (catalog[0].Nlensing_disk > 0)) { 458 return (FALSE); 459 } 460 } 461 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_LENSING)) { 462 // only read the Lensing table if the file actually exists 463 /* read Lensing table data */ 464 if (!gfits_fread_ftable_data (catalog[0].lensing_catalog[0].f, &ftable, FALSE)) { 465 if (VERBOSE) fprintf (stderr, "can't read table lensing data\n"); 466 return (FALSE); 467 } 468 /* convert data format to internal : returns number of row read in Nlensing */ 469 catalog[0].lensing = FtableToLensing (&ftable, &Nlensing, &catalog[0].catformat); 470 if (Nlensing != catalog[0].Nlensing_disk) { 471 fprintf (stderr, "Warning: mismatch between Nlensing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensing, catalog[0].Nlensing_disk); 472 } 473 catalog[0].Nlensing = catalog[0].Nlensing_disk; 474 catalog[0].Nlensing_off = 0; 475 } else { 476 if (catalog[0].lensing_catalog) { 477 gfits_free_header (&catalog[0].lensing_catalog[0].header); 478 } else { 479 ALLOCATE (catalog[0].lensing_catalog, Catalog, 1); 480 dvo_catalog_init (catalog[0].lensing_catalog, TRUE); 481 } 482 gfits_create_header (&catalog[0].lensing_catalog[0].header); 483 ALLOCATE (catalog[0].lensing, Lensing, 1); 484 catalog[0].Nlensing = 0; 485 catalog[0].Nlensing_off = catalog[0].Nlensing_disk; 486 } 487 gfits_free_header (&header); 488 489 /*** Lensobj Table ***/ 490 if (!(catalog[0].catflags & SKIP_LENSOBJ)) { 491 // unless we specify 'skip', we still need to load the 492 status = dvo_catalog_open_subcat (catalog, &catalog[0].lensobj_catalog, ftable.header, "LENSOBJ", VERBOSE); 493 if (status == DVO_CAT_OPEN_FAIL) { 494 return (FALSE); 495 } 496 // the Lensobj file need not exist, unless we expect data to exist 497 if ((status == DVO_CAT_OPEN_EMPTY) && (catalog[0].Nlensobj_disk > 0)) { 498 return (FALSE); 499 } 500 } 501 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_LENSOBJ)) { 502 // only read the Lensobj table if the file actually exists 503 /* read Lensobj table data */ 504 if (!gfits_fread_ftable_data (catalog[0].lensobj_catalog[0].f, &ftable, FALSE)) { 505 if (VERBOSE) fprintf (stderr, "can't read table lensobj data\n"); 506 return (FALSE); 507 } 508 /* convert data format to internal : returns number of row read in Nlensobj */ 509 catalog[0].lensobj = FtableToLensobj (&ftable, &Nlensobj, &catalog[0].catformat); 510 if (Nlensobj != catalog[0].Nlensobj_disk) { 511 fprintf (stderr, "Warning: mismatch between Nlensobj in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensobj, catalog[0].Nlensobj_disk); 512 } 513 catalog[0].Nlensobj = catalog[0].Nlensobj_disk; 514 catalog[0].Nlensobj_off = 0; 515 } else { 516 if (catalog[0].lensobj_catalog) { 517 gfits_free_header (&catalog[0].lensobj_catalog[0].header); 518 } else { 519 ALLOCATE (catalog[0].lensobj_catalog, Catalog, 1); 520 dvo_catalog_init (catalog[0].lensobj_catalog, TRUE); 521 } 522 gfits_create_header (&catalog[0].lensobj_catalog[0].header); 523 ALLOCATE (catalog[0].lensobj, Lensobj, 1); 524 catalog[0].Nlensobj = 0; 525 catalog[0].Nlensobj_off = catalog[0].Nlensobj_disk; 526 } 527 gfits_free_header (&header); 528 529 /*** StarPar Table ***/ 530 if (!(catalog[0].catflags & SKIP_STARPAR)) { 531 // unless we specify 'skip', we still need to load the 532 status = dvo_catalog_open_subcat (catalog, &catalog[0].starpar_catalog, ftable.header, "STARPAR", VERBOSE); 533 if (status == DVO_CAT_OPEN_FAIL) { 534 return (FALSE); 535 } 536 // the StarPar file need not exist, unless we expect data to exist 537 if ((status == DVO_CAT_OPEN_EMPTY) && (catalog[0].Nstarpar_disk > 0)) { 538 return (FALSE); 539 } 540 } 541 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_STARPAR)) { 542 // only read the StarPar table if the file actually exists 543 /* read StarPar table data */ 544 if (!gfits_fread_ftable_data (catalog[0].starpar_catalog[0].f, &ftable, FALSE)) { 545 if (VERBOSE) fprintf (stderr, "can't read table starpar data\n"); 546 return (FALSE); 547 } 548 /* convert data format to internal : returns number of row read in Nstarpar */ 549 catalog[0].starpar = FtableToStarPar (&ftable, &Nstarpar, &catalog[0].catformat); 550 if (Nstarpar != catalog[0].Nstarpar_disk) { 551 fprintf (stderr, "Warning: mismatch between Nstarpar in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nstarpar, catalog[0].Nstarpar_disk); 552 } 553 catalog[0].Nstarpar = catalog[0].Nstarpar_disk; 554 catalog[0].Nstarpar_off = 0; 555 } else { 556 if (catalog[0].starpar_catalog) { 557 gfits_free_header (&catalog[0].starpar_catalog[0].header); 558 } else { 559 ALLOCATE (catalog[0].starpar_catalog, Catalog, 1); 560 dvo_catalog_init (catalog[0].starpar_catalog, TRUE); 561 } 562 gfits_create_header (&catalog[0].starpar_catalog[0].header); 563 ALLOCATE (catalog[0].starpar, StarPar, 1); 564 catalog[0].Nstarpar = 0; 565 catalog[0].Nstarpar_off = catalog[0].Nstarpar_disk; 566 } 567 gfits_free_header (&header); 483 } 568 484 569 485 return (TRUE); … … 575 491 576 492 off_t Nbytes; 577 off_t Naverage, Nexpect, Nitems, Nmeasure, Nmissing, Nlensing, Nlensobj, Nstarpar ;493 off_t Naverage, Nexpect, Nitems, Nmeasure, Nmissing, Nlensing, Nlensobj, Nstarpar, Ngalphot; 578 494 Header header; 579 495 FTable ftable; … … 587 503 588 504 /*** Average (& SecFilt) Table ***/ 589 if (catalog[0].catflags & LOAD_AVES) {505 if (catalog[0].catflags & DVO_LOAD_AVERAGE) { 590 506 591 507 /*** load the Average data ***/ 592 508 /* move pointer past header and matrix -- must be already read (load_catalog) */ 593 509 Nbytes = catalog[0].header.datasize + gfits_data_size (&catalog[0].header); 594 fseeko (catalog[0].f, Nbytes, SEEK_SET); 510 if (fseeko (catalog[0].f, Nbytes, SEEK_SET)) { perror ("fseeko: "); exit (1); } 511 595 512 /* read Average table header */ 596 513 if (!gfits_fread_header (catalog[0].f, &header)) { … … 607 524 * one of the average magnitudes in Average. We save this in case it is needed below. NOTE: 608 525 * primary is only used if we read in the secfilt table, otherwise it should be freed */ 609 catalog[0].average = FtableToAverage (&ftable, &Naverage, &catalog[0].catformat, &primary );526 catalog[0].average = FtableToAverage (&ftable, &Naverage, &catalog[0].catformat, &primary, FALSE); 610 527 if (Naverage != Nrows) { 611 528 // XXX this condition denotes the eof has been reached; not an error or a warning … … 614 531 gfits_free_header (&header); 615 532 catalog[0].Naverage = Naverage; 616 catalog[0].Nave s_off = start;533 catalog[0].Naverage_off = start; 617 534 618 535 /*** load the secfilt data ***/ … … 621 538 /* move pointer past header -- must be already read (load_catalog) */ 622 539 Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header); 623 fseeko (subcat[0].f, Nbytes, SEEK_SET);540 if (fseeko (subcat[0].f, Nbytes, SEEK_SET)) { perror ("fseeko: "); exit (1); } 624 541 625 542 /* read Secfilt table header */ … … 635 552 636 553 Nexpect = catalog[0].Naverage * catalog[0].Nsecfilt; 637 catalog[0].secfilt = FtableToSecFilt (&ftable, &Nitems, &catalog[0].catformat);554 catalog[0].secfilt = FtableToSecFilt (&ftable, catalog[0].average, &Nitems, &catalog[0].catformat, FALSE); 638 555 if (Nitems != Nexpect) { 639 556 fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nitems, Nexpect); 640 557 } 641 catalog[0].Nsecf _mem = catalog[0].Naverage * catalog[0].Nsecfilt;642 catalog[0].Nsecf _off = start * catalog[0].Nsecfilt;558 catalog[0].Nsecfilt_mem = catalog[0].Naverage * catalog[0].Nsecfilt; 559 catalog[0].Nsecfilt_off = start * catalog[0].Nsecfilt; 643 560 644 561 /* if primary is defined, we were supplied with one additional average magnitude from Average … … 651 568 652 569 // XXX check the open status of the catalog 653 if (catalog[0].catflags & LOAD_MEAS) {570 if (catalog[0].catflags & DVO_LOAD_MEASURE) { 654 571 655 572 Catalog *subcat = catalog[0].measure_catalog; … … 657 574 /* move pointer past header -- must be already read (load_catalog) */ 658 575 Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header); 659 fseeko (subcat[0].f, Nbytes, SEEK_SET);576 if (fseeko (subcat[0].f, Nbytes, SEEK_SET)) { perror ("fseeko: "); exit (1); } 660 577 661 578 /* read Measure table header */ … … 671 588 672 589 /* convert data format to internal : returns number of row read in Nmeasure */ 673 catalog[0].measure = FtableToMeasure (&ftable, catalog[0].average, &Nmeasure, &catalog[0].catformat );590 catalog[0].measure = FtableToMeasure (&ftable, catalog[0].average, &Nmeasure, &catalog[0].catformat, FALSE); 674 591 if (Nmeasure != Nrows) { 675 592 // XXX this condition denotes the eof has been reached; not an error or a warning … … 678 595 gfits_free_header (&header); 679 596 catalog[0].Nmeasure = Nmeasure; 680 catalog[0].Nmeas _off = start;597 catalog[0].Nmeasure_off = start; 681 598 } 682 599 683 600 // XXX check the open status of the catalog? 684 if (catalog[0].catflags & LOAD_MISS) {601 if (catalog[0].catflags & DVO_LOAD_MISSING) { 685 602 686 603 Catalog *subcat = catalog[0].missing_catalog; … … 688 605 /* move pointer past header -- must be already read (load_catalog) */ 689 606 Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header); 690 fseeko (subcat[0].f, Nbytes, SEEK_SET);607 if (fseeko (subcat[0].f, Nbytes, SEEK_SET)) { perror ("fseeko: "); exit (1); } 691 608 692 609 /* read Missing table header */ … … 702 619 703 620 /* no conversions currently defined : this just does the byte swap */ 704 catalog[0].missing = gfits_table_get_Missing (&ftable, &Nmissing, NULL );621 catalog[0].missing = gfits_table_get_Missing (&ftable, &Nmissing, NULL, NULL); 705 622 if (!catalog[0].missing) { 706 623 fprintf (stderr, "ERROR: failed to read missing\n"); … … 712 629 gfits_free_header (&header); 713 630 catalog[0].Nmissing = Nmissing; 714 catalog[0].Nmiss _off = start;631 catalog[0].Nmissing_off = start; 715 632 } 716 633 717 634 // XXX check the open status of the catalog 718 if (catalog[0].catflags & LOAD_LENSING) {635 if (catalog[0].catflags & DVO_LOAD_LENSING) { 719 636 720 637 Catalog *subcat = catalog[0].lensing_catalog; … … 722 639 /* move pointer past header -- must be already read (load_catalog) */ 723 640 Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header); 724 fseeko (subcat[0].f, Nbytes, SEEK_SET);641 if (fseeko (subcat[0].f, Nbytes, SEEK_SET)) { perror ("fseeko: "); exit (1); } 725 642 726 643 /* read Lensing table header */ … … 736 653 737 654 /* convert data format to internal : returns number of row read in Nlensing */ 738 catalog[0].lensing = FtableToLensing (&ftable, &Nlensing, &catalog[0].catformat);655 catalog[0].lensing = FtableToLensing (&ftable, catalog[0].average, &Nlensing, &catalog[0].catformat, FALSE); 739 656 if (Nlensing != Nrows) { 740 657 // XXX this condition denotes the eof has been reached; not an error or a warning … … 747 664 748 665 // XXX check the open status of the catalog 749 if (catalog[0].catflags & LOAD_LENSOBJ) {666 if (catalog[0].catflags & DVO_LOAD_LENSOBJ) { 750 667 751 668 Catalog *subcat = catalog[0].lensobj_catalog; … … 753 670 /* move pointer past header -- must be already read (load_catalog) */ 754 671 Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header); 755 fseeko (subcat[0].f, Nbytes, SEEK_SET);672 if (fseeko (subcat[0].f, Nbytes, SEEK_SET)) { perror ("fseeko: "); exit (1); } 756 673 757 674 /* read Lensobj table header */ … … 767 684 768 685 /* convert data format to internal : returns number of row read in Nlensobj */ 769 catalog[0].lensobj = FtableToLensobj (&ftable, &Nlensobj, &catalog[0].catformat);686 catalog[0].lensobj = FtableToLensobj (&ftable, catalog[0].average, &Nlensobj, &catalog[0].catformat, FALSE); 770 687 if (Nlensobj != Nrows) { 771 688 // XXX this condition denotes the eof has been reached; not an error or a warning … … 778 695 779 696 // XXX check the open status of the catalog 780 if (catalog[0].catflags & LOAD_STARPAR) {697 if (catalog[0].catflags & DVO_LOAD_STARPAR) { 781 698 782 699 Catalog *subcat = catalog[0].starpar_catalog; … … 784 701 /* move pointer past header -- must be already read (load_catalog) */ 785 702 Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header); 786 fseeko (subcat[0].f, Nbytes, SEEK_SET);703 if (fseeko (subcat[0].f, Nbytes, SEEK_SET)) { perror ("fseeko: "); exit (1); } 787 704 788 705 /* read StarPar table header */ … … 798 715 799 716 /* convert data format to internal : returns number of row read in Nstarpar */ 800 catalog[0].starpar = FtableToStarPar (&ftable, &Nstarpar, &catalog[0].catformat);717 catalog[0].starpar = FtableToStarPar (&ftable, catalog[0].average, &Nstarpar, &catalog[0].catformat, FALSE); 801 718 if (Nstarpar != Nrows) { 802 719 // XXX this condition denotes the eof has been reached; not an error or a warning … … 808 725 } 809 726 727 // XXX check the open status of the catalog 728 if (catalog[0].catflags & DVO_LOAD_GALPHOT) { 729 730 Catalog *subcat = catalog[0].galphot_catalog; 731 732 /* move pointer past header -- must be already read (load_catalog) */ 733 Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header); 734 if (fseeko (subcat[0].f, Nbytes, SEEK_SET)) { perror ("fseeko: "); exit (1); } 735 736 /* read GalPhot table header */ 737 if (!gfits_fread_header (subcat[0].f, &header)) { 738 if (VERBOSE) fprintf (stderr, "can't read table galphot header"); 739 return (FALSE); 740 } 741 /* read GalPhot table data : format is irrelevant here */ 742 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) { 743 if (VERBOSE) fprintf (stderr, "can't read table galphot data"); 744 return (FALSE); 745 } 746 747 /* convert data format to internal : returns number of row read in Ngalphot */ 748 catalog[0].galphot = FtableToGalPhot (&ftable, catalog[0].average, &Ngalphot, &catalog[0].catformat, FALSE); 749 if (Ngalphot != Nrows) { 750 // XXX this condition denotes the eof has been reached; not an error or a warning 751 // fprintf (stderr, "Warning: mismatch between Ngalphot in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Ngalphot, Nrows); 752 } 753 gfits_free_header (&header); 754 catalog[0].Ngalphot = Ngalphot; 755 catalog[0].Ngalphot_off = start; 756 } 757 810 758 return (TRUE); 811 759 } … … 814 762 int dvo_catalog_save_split (Catalog *catalog, char VERBOSE) { 815 763 816 off_t Nitems;817 764 Header header; 818 765 FTable ftable; 819 766 SecFilt *primary, *secfilt; 820 767 int Nsecfilt; 821 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new, Nstarpar_disk_new; 822 off_t first, start, Nrows; 768 off_t Naverage_disk_new, Nmeasure_disk_new, Nmissing_disk_new, Nsecfilt_disk_new, Nlensing_disk_new, Nlensobj_disk_new, Nstarpar_disk_new, Ngalphot_disk_new; 823 769 824 770 ftable.header = &header; … … 828 774 829 775 // skip empty catalogs: it is illegal to have Measures without corresponding Averages 830 Nave s_disk_new = MAX (catalog[0].Naves_disk, catalog[0].Naverage + catalog[0].Naves_off);831 if (Nave s_disk_new == 0) {776 Naverage_disk_new = MAX (catalog[0].Naverage_disk, catalog[0].Naverage + catalog[0].Naverage_off); 777 if (Naverage_disk_new == 0) { 832 778 if (VERBOSE) fprintf (stderr, "no stars in catalog, skipping\n"); 833 779 return (TRUE); … … 847 793 } 848 794 849 Nmeas _disk_new = MAX (catalog[0].Nmeas_disk, catalog[0].Nmeasure + catalog[0].Nmeas_off);850 Nmiss _disk_new = MAX (catalog[0].Nmiss_disk, catalog[0].Nmissing + catalog[0].Nmiss_off);851 Nsecf _disk_new = MAX (catalog[0].Nsecf_disk, catalog[0].Naverage*Nsecfilt + catalog[0].Nsecf_off);795 Nmeasure_disk_new = MAX (catalog[0].Nmeasure_disk, catalog[0].Nmeasure + catalog[0].Nmeasure_off); 796 Nmissing_disk_new = MAX (catalog[0].Nmissing_disk, catalog[0].Nmissing + catalog[0].Nmissing_off); 797 Nsecfilt_disk_new = MAX (catalog[0].Nsecfilt_disk, catalog[0].Naverage*Nsecfilt + catalog[0].Nsecfilt_off); 852 798 Nlensing_disk_new = MAX (catalog[0].Nlensing_disk, catalog[0].Nlensing + catalog[0].Nlensing_off); 853 799 Nlensobj_disk_new = MAX (catalog[0].Nlensobj_disk, catalog[0].Nlensobj + catalog[0].Nlensobj_off); 854 800 Nstarpar_disk_new = MAX (catalog[0].Nstarpar_disk, catalog[0].Nstarpar + catalog[0].Nstarpar_off); 801 Ngalphot_disk_new = MAX (catalog[0].Ngalphot_disk, catalog[0].Ngalphot + catalog[0].Ngalphot_off); 855 802 856 803 /* make sure header is consistent with data */ 857 gfits_modify (&catalog[0].header, "NSTARS", OFF_T_FMT, 1, Naves_disk_new); 858 gfits_modify (&catalog[0].header, "NMEAS", OFF_T_FMT, 1, Nmeas_disk_new); 859 gfits_modify (&catalog[0].header, "NMISS", OFF_T_FMT, 1, Nmiss_disk_new); 860 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 861 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 862 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 863 gfits_modify (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, Nstarpar_disk_new); 804 gfits_modify (&catalog[0].header, "NSTARS", OFF_T_FMT, 1, Naverage_disk_new); 805 gfits_modify (&catalog[0].header, "NMEAS", OFF_T_FMT, 1, Nmeasure_disk_new); 806 gfits_modify (&catalog[0].header, "NMISS", OFF_T_FMT, 1, Nmissing_disk_new); 807 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 808 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 809 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 810 gfits_modify (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, Nstarpar_disk_new); 811 gfits_modify (&catalog[0].header, "NGALPHOT", OFF_T_FMT, 1, Ngalphot_disk_new); 812 864 813 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 865 814 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 868 817 869 818 /*** Average Table ***/ 870 if ((catalog[0].catflags & LOAD_AVES) && (catalog[0].average != NULL)) {871 872 first = 0; // first row in memory to write873 start = catalog[0].Naves_off; // first disk row to write874 Nrows = catalog[0].Naverage - first;819 if ((catalog[0].catflags & DVO_LOAD_AVERAGE) && (catalog[0].average != NULL)) { 820 821 off_t first = 0; // first row in memory to write 822 off_t start = catalog[0].Naverage_off; // first disk row to write 823 off_t Nrows = catalog[0].Naverage - first; 875 824 876 825 assert (Nrows >= 0); 877 826 assert (first >= 0); 878 827 assert (first <= catalog[0].Naverage); 879 assert (catalog[0].Naves_disk >= catalog[0].Naves_off); 880 881 /* convert internal to external format */ 882 if (!AverageToFtable (&ftable, &catalog[0].average[first], Nrows, catalog[0].catformat, primary)) { 883 fprintf (stderr, "trouble converting format\n"); 884 goto failure; 885 } 886 887 if (!dvo_catalog_save_subcat (catalog, &ftable, start, Nrows, catalog[0].Naves_disk, Naves_disk_new)) { 828 assert (catalog[0].Naverage_disk >= catalog[0].Naverage_off); 829 830 /* convert internal to external format : also results in a byte-swapped, scaled output 831 table. Note that ftable is newly allocated. 832 */ 833 834 // if we are going to compress, we need to receive unswapped data -- 835 int swapFromNative = !output_is_compressed (start, Nrows, Naverage_disk_new, catalog->catcompress); 836 837 // convert to external table format 838 if (!AverageToFtable (&ftable, &catalog[0].average[first], Nrows, catalog[0].catformat, primary, swapFromNative)) { 839 fprintf (stderr, "trouble converting format\n"); 840 goto failure; 841 } 842 843 if (!dvo_catalog_save_subcat (catalog, &ftable, start, Nrows, catalog[0].Naverage_disk, Naverage_disk_new)) { 888 844 fprintf (stderr, "failure writing Average table\n"); 889 845 goto failure; … … 894 850 // even if we do not save the average table, we need to keep the header in sync 895 851 /* rewind file pointers and truncate (file is still open) */ 896 fseeko (catalog[0].f, 0, SEEK_SET);852 if (fseeko (catalog[0].f, 0, SEEK_SET)) { perror ("fseeko: "); exit (1); } 897 853 898 854 /* write table PHU header - always write this out */ … … 905 861 906 862 /*** Measure Table ***/ 907 if ((catalog[0].catflags & LOAD_MEAS) && (catalog[0].measure != NULL)) { 863 if ((catalog[0].catflags & DVO_LOAD_MEASURE) && (catalog[0].measure != NULL)) { 864 865 off_t first = 0; // first row in memory to write 866 off_t start = catalog[0].Nmeasure_off; // first disk row to write 867 off_t Nrows = catalog[0].Nmeasure - first; 868 869 assert (Nrows >= 0); 870 assert (first >= 0); 871 assert (first <= catalog[0].Nmeasure); 872 assert (catalog[0].Nmeasure_disk >= catalog[0].Nmeasure_off); 873 874 // if we are going to compress, we need to receive unswapped data -- 875 int swapFromNative = !output_is_compressed (start, Nrows, Nmeasure_disk_new, catalog->catcompress); 876 877 // convert to external table format 878 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat, swapFromNative)) { 879 fprintf (stderr, "trouble converting format\n"); 880 goto failure; 881 } 882 883 // write out Measure table 884 catalog->measure_catalog->catcompress = catalog->catcompress; // XXX this is a bit of a hack, should be done in an api 885 if (!dvo_catalog_save_subcat (catalog[0].measure_catalog, &ftable, start, Nrows, catalog[0].Nmeasure_disk, Nmeasure_disk_new)) { 886 fprintf (stderr, "trouble writing Measure table\n"); 887 goto failure; 888 } 889 gfits_free_header (&header); 890 gfits_free_table (&ftable); 891 } 892 893 /*** Missing Table ***/ 894 if ((catalog[0].catflags & DVO_LOAD_MISSING) && (catalog[0].missing != NULL)) { 895 896 if (catalog[0].Nmissing_off != 0) { 897 fprintf (stderr, "inconsistency: Missing table cannot be written in segments\n"); 898 goto failure; 899 } 900 901 // if we are going to compress, we need to receive unswapped data -- 902 int swapFromNative = !output_is_compressed (catalog[0].Nmissing_off, catalog[0].Nmissing, Nmissing_disk_new, catalog->catcompress); 903 904 // convert to external table format 905 if (!gfits_table_set_Missing (&ftable, catalog[0].missing, catalog[0].Nmissing, swapFromNative)) { 906 fprintf (stderr, "trouble converting format\n"); 907 goto failure; 908 } 909 910 // write out Missing table (must write out entire table) 911 catalog->missing_catalog->catcompress = catalog->catcompress; // XXX this is a bit of a hack, should be done in an api 912 if (!dvo_catalog_save_subcat (catalog[0].missing_catalog, &ftable, 0, catalog[0].Nmissing, catalog[0].Nmissing, catalog[0].Nmissing)) { 913 fprintf (stderr, "trouble writing Missing Table\n"); 914 goto failure; 915 } 916 gfits_free_header (&header); 917 gfits_free_table (&ftable); 918 } 919 920 /*** Secfilt Table ***/ 921 if ((catalog[0].catflags & DVO_LOAD_SECFILT) && (catalog[0].secfilt != NULL)) { 922 923 off_t first = 0; // first row in memory to write 924 off_t start = catalog[0].Nsecfilt_off; // first disk row to write 925 off_t Nitems = catalog[0].Naverage*Nsecfilt; 926 off_t Nrows = Nitems - first; 927 928 assert (Nrows >= 0); 929 assert (first >= 0); 930 assert (first <= Nitems); 931 assert (catalog[0].Nsecfilt_disk >= catalog[0].Nsecfilt_off); 932 // XXX check these for consistency... 933 934 // if we are going to compress, we need to receive unswapped data -- 935 int swapFromNative = !output_is_compressed (start, Nrows, Nsecfilt_disk_new, catalog->catcompress); 936 937 // convert to external table format 938 if (!SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat, swapFromNative)) { 939 fprintf (stderr, "trouble converting format\n"); 940 goto failure; 941 } 942 943 // write out SecFilt table 944 catalog->secfilt_catalog->catcompress = catalog->catcompress; // XXX this is a bit of a hack, should be done in an api 945 if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecfilt_disk, Nsecfilt_disk_new)) { 946 fprintf (stderr, "failure writing SecFilt table\n"); 947 goto failure; 948 } 949 gfits_free_header (&header); 950 gfits_free_table (&ftable); 951 } 952 953 /*** Lensing Table ***/ 954 if ((catalog[0].catflags & DVO_LOAD_LENSING) && (catalog[0].lensing != NULL)) { 955 956 off_t first = 0; // first row in memory to write 957 off_t start = catalog[0].Nlensing_off; // first disk row to write 958 off_t Nrows = catalog[0].Nlensing - first; 959 960 assert (Nrows >= 0); 961 assert (first >= 0); 962 assert (first <= catalog[0].Nlensing); 963 assert (catalog[0].Nlensing_disk >= catalog[0].Nlensing_off); 964 965 // if we are going to compress, we need to receive unswapped data -- 966 int swapFromNative = !output_is_compressed (start, Nrows, Nlensing_disk_new, catalog->catcompress); 967 968 // convert to external table format 969 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat, swapFromNative)) { 970 fprintf (stderr, "trouble converting format\n"); 971 goto failure; 972 } 973 974 // write out Lensing table 975 catalog->lensing_catalog->catcompress = catalog->catcompress; // XXX this is a bit of a hack, should be done in an api 976 if (!dvo_catalog_save_subcat (catalog[0].lensing_catalog, &ftable, start, Nrows, catalog[0].Nlensing_disk, Nlensing_disk_new)) { 977 fprintf (stderr, "trouble writing Lensing table\n"); 978 goto failure; 979 } 980 gfits_free_header (&header); 981 gfits_free_table (&ftable); 982 } 983 984 /*** Lensobj Table ***/ 985 if ((catalog[0].catflags & DVO_LOAD_LENSOBJ) && (catalog[0].lensobj != NULL)) { 986 987 off_t first = 0; // first row in memory to write 988 off_t start = catalog[0].Nlensobj_off; // first disk row to write 989 off_t Nrows = catalog[0].Nlensobj - first; 990 991 assert (Nrows >= 0); 992 assert (first >= 0); 993 assert (first <= catalog[0].Nlensobj); 994 assert (catalog[0].Nlensobj_disk >= catalog[0].Nlensobj_off); 995 996 // if we are going to compress, we need to receive unswapped data -- 997 int swapFromNative = !output_is_compressed (start, Nrows, Nlensobj_disk_new, catalog->catcompress); 998 999 // convert to external table format 1000 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat, swapFromNative)) { 1001 fprintf (stderr, "trouble converting format\n"); 1002 goto failure; 1003 } 1004 1005 // write out Lensobj table 1006 catalog->lensobj_catalog->catcompress = catalog->catcompress; // XXX this is a bit of a hack, should be done in an api 1007 if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) { 1008 fprintf (stderr, "trouble writing Lensobj table\n"); 1009 goto failure; 1010 } 1011 gfits_free_header (&header); 1012 gfits_free_table (&ftable); 1013 } 1014 1015 /*** StarPar Table ***/ 1016 if ((catalog[0].catflags & DVO_LOAD_STARPAR) && (catalog[0].starpar != NULL)) { 1017 1018 off_t first = 0; // first row in memory to write 1019 off_t start = catalog[0].Nstarpar_off; // first disk row to write 1020 off_t Nrows = catalog[0].Nstarpar - first; 1021 1022 assert (Nrows >= 0); 1023 assert (first >= 0); 1024 assert (first <= catalog[0].Nstarpar); 1025 assert (catalog[0].Nstarpar_disk >= catalog[0].Nstarpar_off); 1026 1027 // if we are going to compress, we need to receive unswapped data -- 1028 int swapFromNative = !output_is_compressed (start, Nrows, Nstarpar_disk_new, catalog->catcompress); 1029 1030 // convert to external table format 1031 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat, swapFromNative)) { 1032 fprintf (stderr, "trouble converting format\n"); 1033 goto failure; 1034 } 1035 1036 // write out StarPar table 1037 catalog->starpar_catalog->catcompress = catalog->catcompress; // XXX this is a bit of a hack, should be done in an api 1038 if (!dvo_catalog_save_subcat (catalog[0].starpar_catalog, &ftable, start, Nrows, catalog[0].Nstarpar_disk, Nstarpar_disk_new)) { 1039 fprintf (stderr, "trouble writing StarPar table\n"); 1040 goto failure; 1041 } 1042 gfits_free_header (&header); 1043 gfits_free_table (&ftable); 1044 } 1045 1046 /*** GalPhot Table ***/ 1047 if ((catalog[0].catflags & DVO_LOAD_GALPHOT) && (catalog[0].galphot != NULL)) { 1048 1049 off_t first = 0; // first row in memory to write 1050 off_t start = catalog[0].Ngalphot_off; // first disk row to write 1051 off_t Nrows = catalog[0].Ngalphot - first; 1052 1053 assert (Nrows >= 0); 1054 assert (first >= 0); 1055 assert (first <= catalog[0].Ngalphot); 1056 assert (catalog[0].Ngalphot_disk >= catalog[0].Ngalphot_off); 1057 1058 // if we are going to compress, we need to receive unswapped data -- 1059 int swapFromNative = !output_is_compressed (start, Nrows, Ngalphot_disk_new, catalog->catcompress); 1060 1061 // convert to external table format 1062 if (!GalPhotToFtable (&ftable, &catalog[0].galphot[first], Nrows, catalog[0].catformat, swapFromNative)) { 1063 fprintf (stderr, "trouble converting format\n"); 1064 goto failure; 1065 } 1066 1067 // write out GalPhot table 1068 catalog->galphot_catalog->catcompress = catalog->catcompress; // XXX this is a bit of a hack, should be done in an api 1069 if (!dvo_catalog_save_subcat (catalog[0].galphot_catalog, &ftable, start, Nrows, catalog[0].Ngalphot_disk, Ngalphot_disk_new)) { 1070 fprintf (stderr, "trouble writing GalPhot table\n"); 1071 goto failure; 1072 } 1073 gfits_free_header (&header); 1074 gfits_free_table (&ftable); 1075 } 1076 1077 /* free temp storage */ 1078 if (primary != NULL) { 1079 free (primary); 1080 free (secfilt); 1081 } 1082 return (TRUE); 1083 1084 failure: 1085 /* free temp storage */ 1086 gfits_free_header (&header); 1087 gfits_free_table (&ftable); 1088 if (primary != NULL) { 1089 free (primary); 1090 free (secfilt); 1091 } 1092 return (FALSE); 1093 } 1094 1095 /* update_catalog_split only writes new lines to file. */ 1096 int dvo_catalog_update_split (Catalog *catalog, char VERBOSE) { 1097 1098 off_t Nitems; 1099 Header header; 1100 FTable ftable; 1101 SecFilt *primary, *secfilt; 1102 int Nsecfilt; 1103 off_t Naverage_disk_new, Nmeasure_disk_new, Nmissing_disk_new, Nsecfilt_disk_new, Nlensing_disk_new, Nlensobj_disk_new, Nstarpar_disk_new, Ngalphot_disk_new; 1104 off_t first, start, Nrows; 1105 1106 ftable.header = &header; 1107 ftable.buffer = NULL; 1108 header.buffer = NULL; 1109 1110 // skip empty catalogs: it is illegal to have Measures without corresponding Averages 1111 Naverage_disk_new = MAX (catalog[0].Naverage_disk, catalog[0].Naverage + catalog[0].Naverage_off); 1112 if (Naverage_disk_new == 0) { 1113 if (VERBOSE) fprintf (stderr, "no stars in catalog, skipping\n"); 1114 return (TRUE); 1115 } 1116 1117 // for the appropriate types, pull out the first secfilt and pass to AverageToFtable as primary 1118 switch (catalog[0].catformat) { 1119 case DVO_FORMAT_ELIXIR: // special case for ELIXIR 1120 case DVO_FORMAT_LONEOS: // special case for LONEOS 1121 dvo_catalog_secfilt_to_primary (catalog, &primary, &secfilt, &Nsecfilt); 1122 break; 1123 default: 1124 primary = NULL; 1125 secfilt = catalog[0].secfilt; 1126 Nsecfilt = catalog[0].Nsecfilt; 1127 break; 1128 } 1129 1130 Nmeasure_disk_new = MAX (catalog[0].Nmeasure_disk, catalog[0].Nmeasure + catalog[0].Nmeasure_off); 1131 Nmissing_disk_new = MAX (catalog[0].Nmissing_disk, catalog[0].Nmissing + catalog[0].Nmissing_off); 1132 Nsecfilt_disk_new = MAX (catalog[0].Nsecfilt_disk, catalog[0].Naverage*Nsecfilt + catalog[0].Nsecfilt_off); 1133 Nlensing_disk_new = MAX (catalog[0].Nlensing_disk, catalog[0].Nlensing + catalog[0].Nlensing_off); 1134 Nlensobj_disk_new = MAX (catalog[0].Nlensobj_disk, catalog[0].Nlensobj + catalog[0].Nlensobj_off); 1135 Nstarpar_disk_new = MAX (catalog[0].Nstarpar_disk, catalog[0].Nstarpar + catalog[0].Nstarpar_off); 1136 Ngalphot_disk_new = MAX (catalog[0].Ngalphot_disk, catalog[0].Ngalphot + catalog[0].Ngalphot_off); 1137 1138 /* make sure header is consistent with data */ 1139 gfits_modify (&catalog[0].header, "NSTARS", OFF_T_FMT, 1, Naverage_disk_new); 1140 gfits_modify (&catalog[0].header, "NMEAS", OFF_T_FMT, 1, Nmeasure_disk_new); 1141 gfits_modify (&catalog[0].header, "NMISS", OFF_T_FMT, 1, Nmissing_disk_new); 1142 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 1143 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 1144 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 1145 gfits_modify (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, Nstarpar_disk_new); 1146 gfits_modify (&catalog[0].header, "NGALPHOT", OFF_T_FMT, 1, Ngalphot_disk_new); 1147 1148 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 1149 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); 1150 1151 /* in split mode, we can save only part of the data */ 1152 1153 /*** Average Table ***/ 1154 if (catalog[0].average != NULL) { 1155 1156 first = catalog[0].Naverage_disk - catalog[0].Naverage_off; // first row to write (memory) 1157 start = catalog[0].Naverage_disk; // first row to write (disk) 1158 Nrows = catalog[0].Naverage - first; 1159 1160 assert (Nrows >= 0); 1161 assert (first >= 0); 1162 assert (first <= catalog[0].Naverage); 1163 assert (catalog[0].Naverage_disk >= catalog[0].Naverage_off); 1164 1165 /* convert internal to external format */ 1166 if (!AverageToFtable (&ftable, &catalog[0].average[first], Nrows, catalog[0].catformat, primary, TRUE)) { 1167 fprintf (stderr, "trouble converting format\n"); 1168 goto failure; 1169 } 1170 1171 if (!dvo_catalog_save_subcat (catalog, &ftable, start, Nrows, catalog[0].Naverage_disk, Naverage_disk_new)) { 1172 fprintf (stderr, "failure writing Average table\n"); 1173 goto failure; 1174 } 1175 gfits_free_header (&header); 1176 gfits_free_table (&ftable); 1177 } else { 1178 // even if we do not save the average table, we need to keep the header in sync 1179 /* rewind file pointers and truncate (file is still open) */ 1180 if (fseeko (catalog[0].f, 0, SEEK_SET)) { perror ("fseeko: "); exit (1); } 1181 1182 /* write table PHU header - always write this out */ 1183 /* XXX EAM : check if disk file size has changed */ 1184 if (!gfits_fwrite_header (catalog[0].f, &catalog[0].header)) { 1185 fprintf (stderr, "can't write primary header"); 1186 goto failure; 1187 } 1188 } 1189 1190 /*** Measure Table ***/ 1191 if ((catalog[0].catflags & DVO_LOAD_MEASURE) && (catalog[0].measure != NULL)) { 908 1192 909 1193 first = 0; // first row in memory to write 910 start = catalog[0].Nmeas _off; // first disk row to write1194 start = catalog[0].Nmeasure_off; // first disk row to write 911 1195 Nrows = catalog[0].Nmeasure - first; 912 1196 … … 914 1198 assert (first >= 0); 915 1199 assert (first <= catalog[0].Nmeasure); 916 assert (catalog[0].Nmeas _disk >= catalog[0].Nmeas_off);1200 assert (catalog[0].Nmeasure_disk >= catalog[0].Nmeasure_off); 917 1201 918 1202 // convert to external table format (note that the block above does not damage or free catalog.average) 919 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat )) {1203 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat, TRUE)) { 920 1204 fprintf (stderr, "trouble converting format\n"); 921 1205 goto failure; … … 923 1207 924 1208 // write out Measure table 925 if (!dvo_catalog_save_subcat (catalog[0].measure_catalog, &ftable, start, Nrows, catalog[0].Nmeas _disk, Nmeas_disk_new)) {1209 if (!dvo_catalog_save_subcat (catalog[0].measure_catalog, &ftable, start, Nrows, catalog[0].Nmeasure_disk, Nmeasure_disk_new)) { 926 1210 fprintf (stderr, "trouble writing Measure table\n"); 927 1211 goto failure; … … 932 1216 933 1217 /*** Missing Table ***/ 934 if ((catalog[0].catflags & LOAD_MISS) && (catalog[0].missing != NULL)) {935 936 if (catalog[0].Nmiss _off != 0) {1218 if ((catalog[0].catflags & DVO_LOAD_MISSING) && (catalog[0].missing != NULL)) { 1219 1220 if (catalog[0].Nmissing_off != 0) { 937 1221 fprintf (stderr, "inconsistency: Missing table cannot be written in segments\n"); 938 1222 goto failure; … … 940 1224 941 1225 // convert to external table format 942 if (!gfits_table_set_Missing (&ftable, catalog[0].missing, catalog[0].Nmissing )) {1226 if (!gfits_table_set_Missing (&ftable, catalog[0].missing, catalog[0].Nmissing, TRUE)) { 943 1227 fprintf (stderr, "trouble converting format\n"); 944 1228 goto failure; … … 955 1239 956 1240 /*** Secfilt Table ***/ 957 if ((catalog[0].catflags & LOAD_SECF) && (catalog[0].secfilt != NULL)) {1241 if ((catalog[0].catflags & DVO_LOAD_SECFILT) && (catalog[0].secfilt != NULL)) { 958 1242 959 1243 first = 0; // first row in memory to write 960 start = catalog[0].Nsecf _off; // first disk row to write961 Nitems = catalog[0].Nsecf _mem;1244 start = catalog[0].Nsecfilt_off; // first disk row to write 1245 Nitems = catalog[0].Nsecfilt_mem; 962 1246 Nrows = Nitems - first; 963 1247 … … 965 1249 assert (first >= 0); 966 1250 assert (first <= Nitems); 967 assert (catalog[0].Nsecf _disk >= catalog[0].Nsecf_off);1251 assert (catalog[0].Nsecfilt_disk >= catalog[0].Nsecfilt_off); 968 1252 // XXX check these for consistency... 969 1253 970 1254 // convert to external table format 971 SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat); 1255 if (!SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat, TRUE)) { 1256 fprintf (stderr, "trouble converting format\n"); 1257 goto failure; 1258 } 972 1259 973 1260 // write out SecFilt table 974 if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecf _disk, Nsecf_disk_new)) {1261 if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecfilt_disk, Nsecfilt_disk_new)) { 975 1262 fprintf (stderr, "failure writing SecFilt table\n"); 976 1263 goto failure; … … 981 1268 982 1269 /*** Lensing Table (optional, do not save if not loaded) ***/ 983 if ((catalog[0].catflags & LOAD_LENSING) && catalog[0].lensing_catalog->f && catalog[0].lensing) {1270 if ((catalog[0].catflags & DVO_LOAD_LENSING) && catalog[0].lensing_catalog->f && catalog[0].lensing) { 984 1271 985 1272 first = 0; // first row in memory to write … … 994 1281 if (catalog[0].Nlensing) { 995 1282 // convert to external table format (note that the block above does not damage or free catalog.average) 996 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat )) {1283 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat, TRUE)) { 997 1284 fprintf (stderr, "trouble converting format\n"); 998 1285 goto failure; … … 1010 1297 1011 1298 /*** Lensobj Table (optional, do not save if not loaded) ***/ 1012 if ((catalog[0].catflags & LOAD_LENSOBJ) && catalog[0].lensobj_catalog->f && catalog[0].lensobj) {1299 if ((catalog[0].catflags & DVO_LOAD_LENSOBJ) && catalog[0].lensobj_catalog->f && catalog[0].lensobj) { 1013 1300 1014 1301 first = 0; // first row in memory to write … … 1023 1310 if (catalog[0].Nlensobj) { 1024 1311 // convert to external table format (note that the block above does not damage or free catalog.average) 1025 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat )) {1312 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat, TRUE)) { 1026 1313 fprintf (stderr, "trouble converting format\n"); 1027 1314 goto failure; … … 1039 1326 1040 1327 /*** StarPar Table (optional, do not save if not loaded) ***/ 1041 if ((catalog[0].catflags &LOAD_STARPAR) && catalog[0].starpar_catalog->f && catalog[0].starpar) {1328 if ((catalog[0].catflags & DVO_LOAD_STARPAR) && catalog[0].starpar_catalog->f && catalog[0].starpar) { 1042 1329 1043 1330 first = 0; // first row in memory to write … … 1052 1339 if (catalog[0].Nstarpar) { 1053 1340 // convert to external table format (note that the block above does not damage or free catalog.average) 1054 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat )) {1341 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat, TRUE)) { 1055 1342 fprintf (stderr, "trouble converting format\n"); 1056 1343 goto failure; … … 1067 1354 } 1068 1355 1356 /*** GalPhot Table (optional, do not save if not loaded) ***/ 1357 if ((catalog[0].catflags & DVO_LOAD_GALPHOT) && catalog[0].galphot_catalog->f && catalog[0].galphot) { 1358 1359 first = 0; // first row in memory to write 1360 start = catalog[0].Ngalphot_off; // first disk row to write 1361 Nrows = catalog[0].Ngalphot - first; 1362 1363 assert (Nrows >= 0); 1364 assert (first >= 0); 1365 assert (first <= catalog[0].Ngalphot); 1366 assert (catalog[0].Ngalphot_disk >= catalog[0].Ngalphot_off); 1367 1368 if (catalog[0].Ngalphot) { 1369 // convert to external table format (note that the block above does not damage or free catalog.average) 1370 if (!GalPhotToFtable (&ftable, &catalog[0].galphot[first], Nrows, catalog[0].catformat, TRUE)) { 1371 fprintf (stderr, "trouble converting format\n"); 1372 goto failure; 1373 } 1374 1375 // write out GalPhot table 1376 if (!dvo_catalog_save_subcat (catalog[0].galphot_catalog, &ftable, start, Nrows, catalog[0].Ngalphot_disk, Ngalphot_disk_new)) { 1377 fprintf (stderr, "trouble writing GalPhot table\n"); 1378 goto failure; 1379 } 1380 gfits_free_header (&header); 1381 gfits_free_table (&ftable); 1382 } 1383 } 1384 1069 1385 /* free temp storage */ 1070 1386 if (primary != NULL) { … … 1074 1390 return (TRUE); 1075 1391 1076 failure:1392 failure: 1077 1393 /* free temp storage */ 1078 1394 gfits_free_header (&header); … … 1088 1404 int dvo_catalog_save_split_complete (Catalog *catalog, char VERBOSE) { 1089 1405 1090 off_t Nitems;1091 1406 Header header; 1092 1407 FTable ftable; 1093 1408 SecFilt *primary, *secfilt; 1094 1409 int Nsecfilt; 1095 off_t Nave s_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new, Nstarpar_disk_new;1410 off_t Naverage_disk_new, Nmeasure_disk_new, Nmissing_disk_new, Nsecfilt_disk_new, Nlensing_disk_new, Nlensobj_disk_new, Nstarpar_disk_new, Ngalphot_disk_new; 1096 1411 off_t first, start, Nrows; 1097 1412 … … 1102 1417 1103 1418 // skip empty catalogs: it is illegal to have Measures without corresponding Averages 1104 if (catalog[0].Nave s_off > 0) {1419 if (catalog[0].Naverage_off > 0) { 1105 1420 fprintf (stderr, "ERROR: only partial catalog (Average) was loaded\n"); 1106 1421 goto failure; 1107 1422 } 1108 if (catalog[0].Nmeas _off > 0) {1423 if (catalog[0].Nmeasure_off > 0) { 1109 1424 fprintf (stderr, "ERROR: only partial catalog (Measure) was loaded\n"); 1110 1425 goto failure; 1111 1426 } 1112 if (catalog[0].Nmiss _off > 0) {1427 if (catalog[0].Nmissing_off > 0) { 1113 1428 fprintf (stderr, "ERROR: only partial catalog (Missing) was loaded\n"); 1114 1429 goto failure; 1115 1430 } 1116 if (catalog[0].Nsecf _off > 0) {1431 if (catalog[0].Nsecfilt_off > 0) { 1117 1432 fprintf (stderr, "ERROR: only partial catalog (Secfilt) was loaded\n"); 1118 1433 goto failure; … … 1130 1445 goto failure; 1131 1446 } 1132 1133 Naves_disk_new = catalog[0].Naverage; 1134 if (Naves_disk_new == 0) { 1447 if (catalog[0].Ngalphot_off > 0) { 1448 fprintf (stderr, "ERROR: only partial catalog (GalPhot) was loaded\n"); 1449 goto failure; 1450 } 1451 1452 Naverage_disk_new = catalog[0].Naverage; 1453 if (Naverage_disk_new == 0) { 1135 1454 if (VERBOSE) fprintf (stderr, "resulting catalog is empty; delete it\n"); 1136 1455 // unlink (); … … 1151 1470 } 1152 1471 1153 Nmeas _disk_new = catalog[0].Nmeasure;1154 Nmiss _disk_new = catalog[0].Nmissing;1155 Nsecf _disk_new = catalog[0].Naverage*Nsecfilt;1472 Nmeasure_disk_new = catalog[0].Nmeasure; 1473 Nmissing_disk_new = catalog[0].Nmissing; 1474 Nsecfilt_disk_new = catalog[0].Naverage*Nsecfilt; 1156 1475 Nlensing_disk_new = catalog[0].Nlensing; 1157 1476 Nlensobj_disk_new = catalog[0].Nlensobj; 1158 1477 Nstarpar_disk_new = catalog[0].Nstarpar; 1478 Ngalphot_disk_new = catalog[0].Ngalphot; 1159 1479 1160 1480 /* make sure header is consistent with data */ 1161 gfits_modify (&catalog[0].header, "NSTARS", OFF_T_FMT, 1, Nave s_disk_new);1162 gfits_modify (&catalog[0].header, "NMEAS", OFF_T_FMT, 1, Nmeas _disk_new);1163 gfits_modify (&catalog[0].header, "NMISS", OFF_T_FMT, 1, Nmiss _disk_new);1481 gfits_modify (&catalog[0].header, "NSTARS", OFF_T_FMT, 1, Naverage_disk_new); 1482 gfits_modify (&catalog[0].header, "NMEAS", OFF_T_FMT, 1, Nmeasure_disk_new); 1483 gfits_modify (&catalog[0].header, "NMISS", OFF_T_FMT, 1, Nmissing_disk_new); 1164 1484 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 1165 1485 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 1166 1486 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 1167 1487 gfits_modify (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, Nstarpar_disk_new); 1488 gfits_modify (&catalog[0].header, "NGALPHOT", OFF_T_FMT, 1, Ngalphot_disk_new); 1168 1489 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 1169 1490 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 1172 1493 1173 1494 /*** Average Table ***/ 1174 if ((catalog[0].catflags & LOAD_AVES) && (catalog[0].average != NULL)) {1495 if ((catalog[0].catflags & DVO_LOAD_AVERAGE) && (catalog[0].average != NULL)) { 1175 1496 1176 1497 first = 0; // first row in memory to write 1177 start = catalog[0].Nave s_off; // first disk row to write1498 start = catalog[0].Naverage_off; // first disk row to write 1178 1499 Nrows = catalog[0].Naverage - first; 1179 1500 … … 1181 1502 assert (first >= 0); 1182 1503 assert (first <= catalog[0].Naverage); 1183 assert (catalog[0].Nave s_disk >= catalog[0].Naves_off);1504 assert (catalog[0].Naverage_disk >= catalog[0].Naverage_off); 1184 1505 1185 1506 /* convert internal to external format */ 1186 if (!AverageToFtable (&ftable, &catalog[0].average[first], Nrows, catalog[0].catformat, primary )) {1187 fprintf (stderr, "trouble converting format\n"); 1188 goto failure; 1189 } 1190 1191 if (!dvo_catalog_save_subcat (catalog, &ftable, start, Nrows, catalog[0].Nave s_disk, Naves_disk_new)) {1507 if (!AverageToFtable (&ftable, &catalog[0].average[first], Nrows, catalog[0].catformat, primary, TRUE)) { 1508 fprintf (stderr, "trouble converting format\n"); 1509 goto failure; 1510 } 1511 1512 if (!dvo_catalog_save_subcat (catalog, &ftable, start, Nrows, catalog[0].Naverage_disk, Naverage_disk_new)) { 1192 1513 fprintf (stderr, "failure writing Average table\n"); 1193 1514 goto failure; … … 1198 1519 // even if we do not save the average table, we need to keep the header in sync 1199 1520 /* rewind file pointers and truncate (file is still open) */ 1200 fseeko (catalog[0].f, 0, SEEK_SET);1521 if (fseeko (catalog[0].f, 0, SEEK_SET)) { perror ("fseeko: "); exit (1); } 1201 1522 1202 1523 /* write table PHU header - always write this out */ … … 1209 1530 1210 1531 /*** Measure Table ***/ 1211 if ( (catalog[0].catflags & LOAD_MEAS) && (catalog[0].measure != NULL)) {1212 1213 first = 0;// first row in memory to write1214 start = catalog[0].Nmeas _off; // first disk row to write1532 if (catalog[0].measure != NULL) { 1533 1534 first = catalog[0].Nmeasure_disk - catalog[0].Nmeasure_off; // first row in memory to write 1535 start = catalog[0].Nmeasure_disk; // first disk row to write 1215 1536 Nrows = catalog[0].Nmeasure - first; 1216 1537 … … 1218 1539 assert (first >= 0); 1219 1540 assert (first <= catalog[0].Nmeasure); 1220 assert (catalog[0].Nmeas _disk >= catalog[0].Nmeas_off);1541 assert (catalog[0].Nmeasure_disk >= catalog[0].Nmeasure_off); 1221 1542 1222 1543 // convert to external table format 1223 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat)) { 1544 // XXX does catalog.measure have averef correctly set up? 1545 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat, TRUE)) { 1224 1546 fprintf (stderr, "trouble converting format\n"); 1225 1547 goto failure; … … 1227 1549 1228 1550 // write out Measure table 1229 if (!dvo_catalog_save_subcat (catalog[0].measure_catalog, &ftable, start, Nrows, catalog[0].Nmeas _disk, Nmeas_disk_new)) {1551 if (!dvo_catalog_save_subcat (catalog[0].measure_catalog, &ftable, start, Nrows, catalog[0].Nmeasure_disk, Nmeasure_disk_new)) { 1230 1552 fprintf (stderr, "trouble writing Measure table\n"); 1231 1553 goto failure; … … 1235 1557 } 1236 1558 1559 /* missing table CANNOT be written unsorted, thus it is always written 1560 out in full */ 1561 1237 1562 /*** Missing Table ***/ 1238 if ((catalog[0].catflags & LOAD_MISS) && (catalog[0].missing != NULL)) { 1239 1240 if (catalog[0].Nmiss_off != 0) { 1563 1564 if (catalog[0].missing != NULL) { 1565 1566 if (catalog[0].Nmissing_off != 0) { 1241 1567 fprintf (stderr, "inconsistency: Missing table cannot be written in segments\n"); 1242 1568 goto failure; … … 1244 1570 1245 1571 // convert to external table format 1246 if (!gfits_table_set_Missing (&ftable, catalog[0].missing, catalog[0].Nmissing )) {1572 if (!gfits_table_set_Missing (&ftable, catalog[0].missing, catalog[0].Nmissing, TRUE)) { 1247 1573 fprintf (stderr, "trouble converting format\n"); 1248 1574 goto failure; … … 1259 1585 1260 1586 /*** Secfilt Table ***/ 1261 if ((catalog[0].catflags & LOAD_SECF) && (catalog[0].secfilt != NULL)) { 1262 1263 first = 0; // first row in memory to write 1264 start = catalog[0].Nsecf_off; // first disk row to write 1265 Nitems = catalog[0].Naverage*Nsecfilt; 1266 Nrows = Nitems - first; 1267 1268 assert (Nrows >= 0); 1269 assert (first >= 0); 1270 assert (first <= Nitems); 1271 assert (catalog[0].Nsecf_disk >= catalog[0].Nsecf_off); 1272 // XXX check these for consistency... 1587 if (catalog[0].secfilt != NULL) { 1588 1589 first = catalog[0].Nsecfilt_disk - catalog[0].Nsecfilt_off; // first row in memory to write 1590 start = catalog[0].Nsecfilt_disk; // first disk row to write 1591 Nrows = catalog[0].Nsecfilt_mem - first; 1592 1593 assert (Nrows >= 0); 1594 assert (first >= 0); 1595 assert (catalog[0].Nsecfilt_disk >= catalog[0].Nsecfilt_off); 1273 1596 1274 1597 // convert to external table format 1275 SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat); 1598 if (!SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat, TRUE)) { 1599 fprintf (stderr, "trouble converting format\n"); 1600 goto failure; 1601 } 1276 1602 1277 1603 // write out SecFilt table 1278 if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecf _disk, Nsecf_disk_new)) {1604 if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecfilt_disk, Nsecfilt_disk_new)) { 1279 1605 fprintf (stderr, "failure writing SecFilt table\n"); 1280 1606 goto failure; … … 1285 1611 1286 1612 /*** Lensing Table ***/ 1287 if ( (catalog[0].catflags & LOAD_LENSING) && (catalog[0].lensing != NULL)) {1288 1289 first = 0;// first row in memory to write1290 start = catalog[0].Nlensing_ off; // first disk row to write1613 if (catalog[0].lensing != NULL) { 1614 1615 first = catalog[0].Nlensing_disk - catalog[0].Nlensing_off; // first row in memory to write 1616 start = catalog[0].Nlensing_disk; // first disk row to write 1291 1617 Nrows = catalog[0].Nlensing - first; 1292 1618 … … 1297 1623 1298 1624 // convert to external table format 1299 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat)) { 1625 // XXX does catalog.lensing have averef correctly set up? 1626 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat, TRUE)) { 1300 1627 fprintf (stderr, "trouble converting format\n"); 1301 1628 goto failure; … … 1312 1639 1313 1640 /*** Lensobj Table ***/ 1314 if ( (catalog[0].catflags & LOAD_LENSOBJ) && (catalog[0].lensobj != NULL)) {1315 1316 first = 0;// first row in memory to write1317 start = catalog[0].Nlensobj_ off; // first disk row to write1641 if (catalog[0].lensobj != NULL) { 1642 1643 first = catalog[0].Nlensobj_disk - catalog[0].Nlensobj_off; // first row in memory to write 1644 start = catalog[0].Nlensobj_disk; // first disk row to write 1318 1645 Nrows = catalog[0].Nlensobj - first; 1319 1646 … … 1324 1651 1325 1652 // convert to external table format 1326 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat)) { 1653 // XXX does catalog.lensobj have averef correctly set up? 1654 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat, TRUE)) { 1327 1655 fprintf (stderr, "trouble converting format\n"); 1328 1656 goto failure; … … 1339 1667 1340 1668 /*** StarPar Table ***/ 1341 if ( (catalog[0].catflags & LOAD_STARPAR) && (catalog[0].starpar != NULL)) {1342 1343 first = 0;// first row in memory to write1344 start = catalog[0].Nstarpar_ off; // first disk row to write1669 if (catalog[0].starpar != NULL) { 1670 1671 first = catalog[0].Nstarpar_disk - catalog[0].Nstarpar_off; // first row in memory to write 1672 start = catalog[0].Nstarpar_disk; // first disk row to write 1345 1673 Nrows = catalog[0].Nstarpar - first; 1346 1674 … … 1351 1679 1352 1680 // convert to external table format 1353 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat)) { 1681 // XXX does catalog.starpar have averef correctly set up? 1682 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat, TRUE)) { 1354 1683 fprintf (stderr, "trouble converting format\n"); 1355 1684 goto failure; … … 1359 1688 if (!dvo_catalog_save_subcat (catalog[0].starpar_catalog, &ftable, start, Nrows, catalog[0].Nstarpar_disk, Nstarpar_disk_new)) { 1360 1689 fprintf (stderr, "trouble writing StarPar table\n"); 1690 goto failure; 1691 } 1692 gfits_free_header (&header); 1693 gfits_free_table (&ftable); 1694 } 1695 1696 /*** GalPhot Table ***/ 1697 if (catalog[0].galphot != NULL) { 1698 1699 first = catalog[0].Ngalphot_disk - catalog[0].Ngalphot_off; // first row in memory to write 1700 start = catalog[0].Ngalphot_disk; // first disk row to write 1701 Nrows = catalog[0].Ngalphot - first; 1702 1703 assert (Nrows >= 0); 1704 assert (first >= 0); 1705 assert (first <= catalog[0].Ngalphot); 1706 assert (catalog[0].Ngalphot_disk >= catalog[0].Ngalphot_off); 1707 1708 // convert to external table format 1709 // XXX does catalog.galphot have averef correctly set up? 1710 if (!GalPhotToFtable (&ftable, &catalog[0].galphot[first], Nrows, catalog[0].catformat, TRUE)) { 1711 fprintf (stderr, "trouble converting format\n"); 1712 goto failure; 1713 } 1714 1715 // write out GalPhot table 1716 if (!dvo_catalog_save_subcat (catalog[0].galphot_catalog, &ftable, start, Nrows, catalog[0].Ngalphot_disk, Ngalphot_disk_new)) { 1717 fprintf (stderr, "trouble writing GalPhot table\n"); 1361 1718 goto failure; 1362 1719 } … … 1370 1727 free (secfilt); 1371 1728 } 1729 1372 1730 return (TRUE); 1373 1731 1374 failure: 1375 /* free temp storage */ 1376 gfits_free_header (&header); 1377 gfits_free_table (&ftable); 1378 if (primary != NULL) { 1379 free (primary); 1380 free (secfilt); 1381 } 1382 return (FALSE); 1383 } 1384 1385 /* update_catalog_split only writes new lines to file. */ 1386 int dvo_catalog_update_split (Catalog *catalog, char VERBOSE) { 1387 1388 Header header; 1389 FTable ftable; 1390 SecFilt *primary, *secfilt; 1391 int Nsecfilt; 1392 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new, Nstarpar_disk_new; 1393 off_t first, start, Nrows; 1394 1395 ftable.header = &header; 1396 ftable.buffer = NULL; 1397 header.buffer = NULL; 1398 1399 // skip empty catalogs: it is illegal to have Measures without corresponding Averages 1400 Naves_disk_new = MAX (catalog[0].Naves_disk, catalog[0].Naverage + catalog[0].Naves_off); 1401 if (Naves_disk_new == 0) { 1402 if (VERBOSE) fprintf (stderr, "no stars in catalog, skipping\n"); 1403 return (TRUE); 1404 } 1405 1406 // for the appropriate types, pull out the first secfilt and pass to AverageToFtable as primary 1407 switch (catalog[0].catformat) { 1408 case DVO_FORMAT_ELIXIR: // special case for ELIXIR 1409 case DVO_FORMAT_LONEOS: // special case for LONEOS 1410 dvo_catalog_secfilt_to_primary (catalog, &primary, &secfilt, &Nsecfilt); 1411 break; 1412 default: 1413 primary = NULL; 1414 secfilt = catalog[0].secfilt; 1415 Nsecfilt = catalog[0].Nsecfilt; 1416 break; 1417 } 1418 1419 Nmeas_disk_new = MAX (catalog[0].Nmeas_disk, catalog[0].Nmeasure + catalog[0].Nmeas_off); 1420 Nmiss_disk_new = MAX (catalog[0].Nmiss_disk, catalog[0].Nmissing + catalog[0].Nmiss_off); 1421 Nsecf_disk_new = MAX (catalog[0].Nsecf_disk, catalog[0].Naverage*Nsecfilt + catalog[0].Nsecf_off); 1422 Nlensing_disk_new = MAX (catalog[0].Nlensing_disk, catalog[0].Nlensing + catalog[0].Nlensing_off); 1423 Nlensobj_disk_new = MAX (catalog[0].Nlensobj_disk, catalog[0].Nlensobj + catalog[0].Nlensobj_off); 1424 Nstarpar_disk_new = MAX (catalog[0].Nstarpar_disk, catalog[0].Nstarpar + catalog[0].Nstarpar_off); 1425 1426 /* make sure header is consistent with data */ 1427 gfits_modify (&catalog[0].header, "NSTARS", OFF_T_FMT, 1, Naves_disk_new); 1428 gfits_modify (&catalog[0].header, "NMEAS", OFF_T_FMT, 1, Nmeas_disk_new); 1429 gfits_modify (&catalog[0].header, "NMISS", OFF_T_FMT, 1, Nmiss_disk_new); 1430 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 1431 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 1432 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 1433 gfits_modify (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, Nstarpar_disk_new); 1434 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 1435 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); 1436 1437 /* in split mode, we can save only part of the data */ 1438 1439 /*** Average Table ***/ 1440 if (catalog[0].average != NULL) { 1441 1442 first = catalog[0].Naves_disk - catalog[0].Naves_off; // first row to write (memory) 1443 start = catalog[0].Naves_disk; // first row to write (disk) 1444 Nrows = catalog[0].Naverage - first; 1445 1446 assert (Nrows >= 0); 1447 assert (first >= 0); 1448 assert (first <= catalog[0].Naverage); 1449 assert (catalog[0].Naves_disk >= catalog[0].Naves_off); 1450 1451 /* convert internal to external format */ 1452 if (!AverageToFtable (&ftable, &catalog[0].average[first], Nrows, catalog[0].catformat, primary)) { 1453 fprintf (stderr, "trouble converting format\n"); 1454 goto failure; 1455 } 1456 1457 if (!dvo_catalog_save_subcat (catalog, &ftable, start, Nrows, catalog[0].Naves_disk, Naves_disk_new)) { 1458 fprintf (stderr, "failure writing Average table\n"); 1459 goto failure; 1460 } 1461 gfits_free_header (&header); 1462 gfits_free_table (&ftable); 1463 } else { 1464 // even if we do not save the average table, we need to keep the header in sync 1465 /* rewind file pointers and truncate (file is still open) */ 1466 fseeko (catalog[0].f, 0, SEEK_SET); 1467 1468 /* write table PHU header - always write this out */ 1469 /* XXX EAM : check if disk file size has changed */ 1470 if (!gfits_fwrite_header (catalog[0].f, &catalog[0].header)) { 1471 fprintf (stderr, "can't write primary header"); 1472 goto failure; 1473 } 1474 } 1475 1476 /*** Measure Table ***/ 1477 if (catalog[0].measure != NULL) { 1478 1479 first = catalog[0].Nmeas_disk - catalog[0].Nmeas_off; // first row in memory to write 1480 start = catalog[0].Nmeas_disk; // first disk row to write 1481 Nrows = catalog[0].Nmeasure - first; 1482 1483 assert (Nrows >= 0); 1484 assert (first >= 0); 1485 assert (first <= catalog[0].Nmeasure); 1486 assert (catalog[0].Nmeas_disk >= catalog[0].Nmeas_off); 1487 1488 // convert to external table format 1489 // XXX does catalog.measure have averef correctly set up? 1490 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat)) { 1491 fprintf (stderr, "trouble converting format\n"); 1492 goto failure; 1493 } 1494 1495 // write out Measure table 1496 if (!dvo_catalog_save_subcat (catalog[0].measure_catalog, &ftable, start, Nrows, catalog[0].Nmeas_disk, Nmeas_disk_new)) { 1497 fprintf (stderr, "trouble writing Measure table\n"); 1498 goto failure; 1499 } 1500 gfits_free_header (&header); 1501 gfits_free_table (&ftable); 1502 } 1503 1504 /* missing table CANNOT be written unsorted, thus it is always written 1505 out in full */ 1506 1507 /*** Missing Table ***/ 1508 1509 if (catalog[0].missing != NULL) { 1510 1511 if (catalog[0].Nmiss_off != 0) { 1512 fprintf (stderr, "inconsistency: Missing table cannot be written in segments\n"); 1513 goto failure; 1514 } 1515 1516 // convert to external table format 1517 if (!gfits_table_set_Missing (&ftable, catalog[0].missing, catalog[0].Nmissing)) { 1518 fprintf (stderr, "trouble converting format\n"); 1519 goto failure; 1520 } 1521 1522 // write out Missing table (must write out entire table) 1523 if (!dvo_catalog_save_subcat (catalog[0].missing_catalog, &ftable, 0, catalog[0].Nmissing, catalog[0].Nmissing, catalog[0].Nmissing)) { 1524 fprintf (stderr, "trouble writing Missing Table\n"); 1525 goto failure; 1526 } 1527 gfits_free_header (&header); 1528 gfits_free_table (&ftable); 1529 } 1530 1531 /*** Secfilt Table ***/ 1532 if (catalog[0].secfilt != NULL) { 1533 1534 first = catalog[0].Nsecf_disk - catalog[0].Nsecf_off; // first row in memory to write 1535 start = catalog[0].Nsecf_disk; // first disk row to write 1536 Nrows = catalog[0].Nsecf_mem - first; 1537 1538 assert (Nrows >= 0); 1539 assert (first >= 0); 1540 assert (catalog[0].Nsecf_disk >= catalog[0].Nsecf_off); 1541 1542 // convert to external table format 1543 SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat); 1544 1545 // write out SecFilt table 1546 if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecf_disk, Nsecf_disk_new)) { 1547 fprintf (stderr, "failure writing SecFilt table\n"); 1548 goto failure; 1549 } 1550 gfits_free_header (&header); 1551 gfits_free_table (&ftable); 1552 } 1553 1554 /*** Lensing Table ***/ 1555 if (catalog[0].lensing != NULL) { 1556 1557 first = catalog[0].Nlensing_disk - catalog[0].Nlensing_off; // first row in memory to write 1558 start = catalog[0].Nlensing_disk; // first disk row to write 1559 Nrows = catalog[0].Nlensing - first; 1560 1561 assert (Nrows >= 0); 1562 assert (first >= 0); 1563 assert (first <= catalog[0].Nlensing); 1564 assert (catalog[0].Nlensing_disk >= catalog[0].Nlensing_off); 1565 1566 // convert to external table format 1567 // XXX does catalog.lensing have averef correctly set up? 1568 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat)) { 1569 fprintf (stderr, "trouble converting format\n"); 1570 goto failure; 1571 } 1572 1573 // write out Lensing table 1574 if (!dvo_catalog_save_subcat (catalog[0].lensing_catalog, &ftable, start, Nrows, catalog[0].Nlensing_disk, Nlensing_disk_new)) { 1575 fprintf (stderr, "trouble writing Lensing table\n"); 1576 goto failure; 1577 } 1578 gfits_free_header (&header); 1579 gfits_free_table (&ftable); 1580 } 1581 1582 /*** Lensobj Table ***/ 1583 if (catalog[0].lensobj != NULL) { 1584 1585 first = catalog[0].Nlensobj_disk - catalog[0].Nlensobj_off; // first row in memory to write 1586 start = catalog[0].Nlensobj_disk; // first disk row to write 1587 Nrows = catalog[0].Nlensobj - first; 1588 1589 assert (Nrows >= 0); 1590 assert (first >= 0); 1591 assert (first <= catalog[0].Nlensobj); 1592 assert (catalog[0].Nlensobj_disk >= catalog[0].Nlensobj_off); 1593 1594 // convert to external table format 1595 // XXX does catalog.lensobj have averef correctly set up? 1596 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat)) { 1597 fprintf (stderr, "trouble converting format\n"); 1598 goto failure; 1599 } 1600 1601 // write out Lensobj table 1602 if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) { 1603 fprintf (stderr, "trouble writing Lensobj table\n"); 1604 goto failure; 1605 } 1606 gfits_free_header (&header); 1607 gfits_free_table (&ftable); 1608 } 1609 1610 /*** StarPar Table ***/ 1611 if (catalog[0].starpar != NULL) { 1612 1613 first = catalog[0].Nstarpar_disk - catalog[0].Nstarpar_off; // first row in memory to write 1614 start = catalog[0].Nstarpar_disk; // first disk row to write 1615 Nrows = catalog[0].Nstarpar - first; 1616 1617 assert (Nrows >= 0); 1618 assert (first >= 0); 1619 assert (first <= catalog[0].Nstarpar); 1620 assert (catalog[0].Nstarpar_disk >= catalog[0].Nstarpar_off); 1621 1622 // convert to external table format 1623 // XXX does catalog.starpar have averef correctly set up? 1624 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat)) { 1625 fprintf (stderr, "trouble converting format\n"); 1626 goto failure; 1627 } 1628 1629 // write out StarPar table 1630 if (!dvo_catalog_save_subcat (catalog[0].starpar_catalog, &ftable, start, Nrows, catalog[0].Nstarpar_disk, Nstarpar_disk_new)) { 1631 fprintf (stderr, "trouble writing StarPar table\n"); 1632 goto failure; 1633 } 1634 gfits_free_header (&header); 1635 gfits_free_table (&ftable); 1636 } 1637 1638 /* free temp storage */ 1639 if (primary != NULL) { 1640 free (primary); 1641 free (secfilt); 1642 } 1643 1644 return (TRUE); 1645 1646 failure: 1732 failure: 1647 1733 /* free temp storage */ 1648 1734 if (primary != NULL) { … … 1662 1748 1663 1749 /* XXX EAM : update is not efficient. MeasureToFtable should only 1664 convert the new rows (Nmeas _disk to Nmeasure). the resulting1750 convert the new rows (Nmeasure_disk to Nmeasure). the resulting 1665 1751 table represents the end rows of the ftable. we need to define 1666 1752 the vtable based on the ftable, but with Ny = Nmeasure */ … … 1668 1754 1669 1755 1670 // * convert to an ftable1671 // * optionally write the PHU header/matrix1672 // * advance to the start of the output data block:1673 // ** Nx * catalog[0].Nmeas_off1674 // * write out the ftable data block1675 // * if Nmeas_off + Nmeasure >= Nmeas_disk, update padding1676 // ** start = Nmeas_off1677 // ** Nrows = Nmeasure1678 1756 // * convert to an ftable 1757 // * optionally write the PHU header/matrix 1758 // * advance to the start of the output data block: 1759 // ** Nx * catalog[0].Nmeasure_off 1760 // * write out the ftable data block 1761 // * if Nmeasure_off + Nmeasure >= Nmeasure_disk, update padding 1762 // ** start = Nmeasure_off 1763 // ** Nrows = Nmeasure 1764 -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_convert.c
r38153 r38447 11 11 constructions below **/ 12 12 13 DVO TableFormat FtableGetFormat (FTable *ftable) {14 15 DVO TableFormat format;13 DVOCatFormat FtableGetFormat (FTable *ftable) { 14 15 DVOCatFormat format; 16 16 char extname[80]; 17 17 … … 52 52 /*** Average / FTable conversion functions ***/ 53 53 54 Average *FtableToAverage (FTable *ftable, off_t *Naverage, char *format, SecFilt **primary) {54 Average *FtableToAverage (FTable *ftable, off_t *Naverage, DVOCatFormat *format, SecFilt **primary, char nativeBytes) { 55 55 56 56 Average *average; … … 98 98 if (!strcmp (extname, NAME)) { \ 99 99 Average_##TYPE *tmpAverage; \ 100 tmpAverage = gfits_table_get_Average_##TYPE (ftable, Naverage, NULL); \100 tmpAverage = gfits_table_get_Average_##TYPE (ftable, Naverage, NULL, &nativeBytes); \ 101 101 if (!tmpAverage) { \ 102 102 fprintf (stderr, "ERROR: failed to read averages\n"); \ … … 109 109 110 110 if (!strcmp (extname, "DVO_AVERAGE")) { 111 average = gfits_table_get_Average (ftable, Naverage, NULL );111 average = gfits_table_get_Average (ftable, Naverage, NULL, &nativeBytes); 112 112 if (!average) { 113 113 fprintf (stderr, "ERROR: failed to read averages\n"); … … 139 139 } 140 140 141 int AverageToFtable (FTable *ftable, Average *average, off_t Naverage, char format, SecFilt *primary) {142 143 # define FORMAT_CASE(FORMAT, TYPE) \144 case DVO_FORMAT_##FORMAT: {\145 Average_##TYPE *tmpAverage;\141 int AverageToFtable (FTable *ftable, Average *average, off_t Naverage, DVOCatFormat format, SecFilt *primary, int swapFromNative) { 142 143 # define FORMAT_CASE(FORMAT, TYPE) \ 144 case DVO_FORMAT_##FORMAT: { \ 145 Average_##TYPE *tmpAverage; \ 146 146 tmpAverage = AverageInternalTo_##TYPE (average, Naverage, primary); \ 147 gfits_table_set_Average_##TYPE (ftable, tmpAverage, Naverage); \148 free (tmpAverage);\149 break; }150 147 gfits_table_set_Average_##TYPE (ftable, tmpAverage, Naverage, swapFromNative); \ 148 free (tmpAverage); \ 149 break; } 150 151 151 /* convert from the internal format */ 152 152 switch (format) { 153 153 case DVO_FORMAT_INTERNAL: { 154 gfits_table_set_Average (ftable, average, Naverage );154 gfits_table_set_Average (ftable, average, Naverage, swapFromNative); 155 155 break; } 156 156 … … 180 180 181 181 // FtableToMeasure needs the Average since old formats stored measure.dR,dD only 182 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, char *format) { 182 // other FtableToFOO conversions accept the average argument for macro construction 183 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, DVOCatFormat *format, char nativeBytes) { 183 184 184 185 Measure *measure; … … 226 227 if (!strcmp (extname, NAME)) { \ 227 228 Measure_##TYPE *tmpMeasure; \ 228 tmpMeasure = gfits_table_get_Measure_##TYPE (ftable, Nmeasure, NULL); \229 if (!tmpMeasure) {\230 fprintf (stderr, "ERROR: failed to read measures\n"); \231 exit (2);\232 }\233 myAssert (ABS_COORDS || average, "conversion to internal needs average table"); \229 tmpMeasure = gfits_table_get_Measure_##TYPE (ftable, Nmeasure, NULL, &nativeBytes); \ 230 if (!tmpMeasure) { \ 231 fprintf (stderr, "ERROR: failed to read measures\n"); \ 232 exit (2); \ 233 } \ 234 myAssert (ABS_COORDS || average, "conversion to internal needs average table"); \ 234 235 measure = Measure_##TYPE##_ToInternal (average, tmpMeasure, *Nmeasure); \ 235 236 free (tmpMeasure); \ … … 238 239 239 240 if (!strcmp (extname, "DVO_MEASURE")) { 240 measure = gfits_table_get_Measure (ftable, Nmeasure, NULL );241 measure = gfits_table_get_Measure (ftable, Nmeasure, NULL, &nativeBytes); 241 242 if (!measure) { 242 243 fprintf (stderr, "ERROR: failed to read measures\n"); … … 269 270 270 271 // MeasureToFtable needs the Average since old formats stored measure.dR,dD only 271 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, char format) {272 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, DVOCatFormat format, int swapFromNative) { 272 273 273 274 # define FORMAT_CASE(FORMAT, TYPE, ABS_COORDS) \ … … 276 277 myAssert (ABS_COORDS || average, "conversion from internal needs average table"); \ 277 278 tmpMeasure = MeasureInternalTo_##TYPE (average, measure, Nmeasure); \ 278 gfits_table_set_Measure_##TYPE (ftable, tmpMeasure, Nmeasure); \279 gfits_table_set_Measure_##TYPE (ftable, tmpMeasure, Nmeasure, swapFromNative); \ 279 280 free (tmpMeasure); \ 280 281 break; } … … 283 284 switch (format) { 284 285 case DVO_FORMAT_INTERNAL: { 285 gfits_table_set_Measure (ftable, measure, Nmeasure );286 gfits_table_set_Measure (ftable, measure, Nmeasure, swapFromNative); 286 287 break; } 287 288 … … 308 309 } 309 310 311 /*** Missing / FTable conversion functions ***/ 312 313 Missing *FtableToMissing (FTable *ftable, Average *average, off_t *Nmissing, DVOCatFormat *format, char nativeBytes) { 314 315 Missing *missing; 316 char extname[80]; 317 318 /* convert to the internal format */ 319 if (!gfits_scan (ftable[0].header, "EXTNAME", "%s", 1, extname)) { 320 fprintf (stderr, "EXTNAME missing for missing table\n"); 321 return (FALSE); 322 } 323 324 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 325 if (!strcmp (extname, NAME)) { \ 326 fprintf (stderr, "ERROR: format %s not defined for missing, skipping\n", NAME); \ 327 *Nmissing = 0; \ 328 return NULL; \ 329 } 330 331 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 332 if (!strcmp (extname, NAME)) { \ 333 Missing_##TYPE *tmpMissing; \ 334 tmpMissing = gfits_table_get_Missing_##TYPE (ftable, Nmissing, NULL, &nativeBytes); \ 335 if (!tmpMissing) { \ 336 fprintf (stderr, "ERROR: failed to read missing\n"); \ 337 exit (2); \ 338 } \ 339 missing = Missing_##TYPE##_ToInternal (tmpMissing, *Nmissing); \ 340 free (tmpMissing); \ 341 *format = DVO_FORMAT_##FORMAT; \ 342 return (missing); } 343 344 // XXX the structure is here for future expansion, but no transformations are currently defined 345 if (TRUE) { 346 missing = gfits_table_get_Missing (ftable, Nmissing, NULL, &nativeBytes); 347 if (!missing) { 348 fprintf (stderr, "ERROR: failed to read missing\n"); 349 exit (2); 350 } 351 *format = DVO_FORMAT_INTERNAL; 352 return (missing); 353 } 354 355 if (!strcmp (extname, "DVO_MISSING")) { 356 missing = gfits_table_get_Missing (ftable, Nmissing, NULL, &nativeBytes); 357 if (!missing) { 358 fprintf (stderr, "ERROR: failed to read missing\n"); 359 exit (2); 360 } 361 *format = DVO_FORMAT_INTERNAL; 362 return (missing); 363 } 364 365 SKIPPING_FORMAT ("DVO_MISSING_PS1_SIM", PS1_SIM, PS1_SIM); 366 SKIPPING_FORMAT ("DVO_MISSING_PS1_REF", PS1_REF, PS1_REF); 367 SKIPPING_FORMAT ("DVO_MISSING_ELIXIR", ELIXIR, Elixir); 368 SKIPPING_FORMAT ("DVO_MISSING_LONEOS", LONEOS, Loneos); 369 SKIPPING_FORMAT ("DVO_MISSING_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0); 370 SKIPPING_FORMAT ("DVO_MISSING_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1); 371 SKIPPING_FORMAT ("DVO_MISSING_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 372 SKIPPING_FORMAT ("DVO_MISSING_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 373 SKIPPING_FORMAT ("DVO_MISSING_PS1_V1", PS1_V1, PS1_V1); 374 SKIPPING_FORMAT ("DVO_MISSING_PS1_V2", PS1_V2, PS1_V2); 375 SKIPPING_FORMAT ("DVO_MISSING_PS1_V3", PS1_V3, PS1_V3); 376 SKIPPING_FORMAT ("DVO_MISSING_PS1_V4", PS1_V4, PS1_V4); 377 SKIPPING_FORMAT ("DVO_MISSING_PS1_V5", PS1_V5, PS1_V5); 378 # undef CONVERT_FORMAT 379 # undef SKIPPING_FORMAT 380 381 fprintf (stderr, "table format unknown: %s\n", extname); 382 383 *Nmissing = 0; 384 return (NULL); 385 } 386 310 387 /*** SecFilt / FTable conversion functions ***/ 311 388 312 SecFilt *FtableToSecFilt (FTable *ftable, off_t *Nsecfilt, char *format) {389 SecFilt *FtableToSecFilt (FTable *ftable, Average *average, off_t *Nsecfilt, DVOCatFormat *format, char nativeBytes) { 313 390 314 391 SecFilt *secfilt; … … 339 416 if (!strcmp (extname, NAME)) { \ 340 417 SecFilt_##TYPE *tmpSecFilt; \ 341 tmpSecFilt = gfits_table_get_SecFilt_##TYPE (ftable, Nsecfilt, NULL ); \418 tmpSecFilt = gfits_table_get_SecFilt_##TYPE (ftable, Nsecfilt, NULL, &nativeBytes); \ 342 419 if (!tmpSecFilt) { \ 343 420 fprintf (stderr, "ERROR: failed to read secfilts\n"); \ … … 350 427 351 428 if (!strcmp (extname, "DVO_SECFILT")) { 352 secfilt = gfits_table_get_SecFilt (ftable, Nsecfilt, NULL );429 secfilt = gfits_table_get_SecFilt (ftable, Nsecfilt, NULL, &nativeBytes); 353 430 if (!secfilt) { 354 431 fprintf (stderr, "ERROR: failed to read secfilts\n"); … … 380 457 } 381 458 382 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, char format) {459 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, DVOCatFormat format, int swapFromNative) { 383 460 384 461 # define FORMAT_CASE(FORMAT, TYPE) \ … … 386 463 SecFilt_##TYPE *tmpSecFilt; \ 387 464 tmpSecFilt = SecFiltInternalTo_##TYPE (secfilt, Nsecfilt); \ 388 gfits_table_set_SecFilt_##TYPE (ftable, tmpSecFilt, Nsecfilt); \465 gfits_table_set_SecFilt_##TYPE (ftable, tmpSecFilt, Nsecfilt, swapFromNative); \ 389 466 free (tmpSecFilt); \ 390 467 break; } … … 393 470 switch (format) { 394 471 case DVO_FORMAT_INTERNAL: { 395 gfits_table_set_SecFilt (ftable, secfilt, Nsecfilt );472 gfits_table_set_SecFilt (ftable, secfilt, Nsecfilt, swapFromNative); 396 473 break; } 397 474 … … 420 497 /*** Lensing / FTable conversion functions ***/ 421 498 422 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, char *format) {499 Lensing *FtableToLensing (FTable *ftable, Average *average, off_t *Nlensing, DVOCatFormat *format, char nativeBytes) { 423 500 424 501 Lensing *lensing; … … 433 510 if (!strcmp (extname, "DVO_LENSING_PS1_V5") && (ftable[0].header[0].Naxis[0] == 128)) { 434 511 Lensing_PS1_V5_R0 *tmpLensing; 435 tmpLensing = gfits_table_get_Lensing_PS1_V5_R0 (ftable, Nlensing, NULL );512 tmpLensing = gfits_table_get_Lensing_PS1_V5_R0 (ftable, Nlensing, NULL, &nativeBytes); 436 513 if (!tmpLensing) { 437 514 fprintf (stderr, "ERROR: failed to read lensings\n"); … … 445 522 if (!strcmp (extname, "DVO_LENSING_PS1_V5") && (ftable[0].header[0].Naxis[0] == 136)) { 446 523 Lensing_PS1_V5_R1 *tmpLensing; 447 tmpLensing = gfits_table_get_Lensing_PS1_V5_R1 (ftable, Nlensing, NULL );524 tmpLensing = gfits_table_get_Lensing_PS1_V5_R1 (ftable, Nlensing, NULL, &nativeBytes); 448 525 if (!tmpLensing) { 449 526 fprintf (stderr, "ERROR: failed to read lensings\n"); … … 457 534 if (!strcmp (extname, "DVO_LENSING_PS1_V5") && (ftable[0].header[0].Naxis[0] == 144)) { 458 535 Lensing_PS1_V5_R2 *tmpLensing; 459 tmpLensing = gfits_table_get_Lensing_PS1_V5_R2 (ftable, Nlensing, NULL );536 tmpLensing = gfits_table_get_Lensing_PS1_V5_R2 (ftable, Nlensing, NULL, &nativeBytes); 460 537 if (!tmpLensing) { 461 538 fprintf (stderr, "ERROR: failed to read lensings\n"); … … 477 554 if (!strcmp (extname, NAME)) { \ 478 555 Lensing_##TYPE *tmpLensing; \ 479 tmpLensing = gfits_table_get_Lensing_##TYPE (ftable, Nlensing, NULL ); \556 tmpLensing = gfits_table_get_Lensing_##TYPE (ftable, Nlensing, NULL, &nativeBytes); \ 480 557 if (!tmpLensing) { \ 481 558 fprintf (stderr, "ERROR: failed to read lensings\n"); \ … … 488 565 489 566 if (!strcmp (extname, "DVO_LENSING")) { 490 lensing = gfits_table_get_Lensing (ftable, Nlensing, NULL );567 lensing = gfits_table_get_Lensing (ftable, Nlensing, NULL, &nativeBytes); 491 568 if (!lensing) { 492 569 fprintf (stderr, "ERROR: failed to read lensings\n"); … … 520 597 521 598 // LensingToFtable needs the Average since old formats stored lensing.dR,dD only 522 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, char format) {599 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, DVOCatFormat format, int swapFromNative) { 523 600 524 601 # define FORMAT_CASE(FORMAT, TYPE) \ … … 526 603 Lensing_##TYPE *tmpLensing; \ 527 604 tmpLensing = LensingInternalTo_##TYPE (lensing, Nlensing); \ 528 gfits_table_set_Lensing_##TYPE (ftable, tmpLensing, Nlensing); \605 gfits_table_set_Lensing_##TYPE (ftable, tmpLensing, Nlensing, swapFromNative); \ 529 606 free (tmpLensing); \ 530 607 break; } … … 533 610 switch (format) { 534 611 case DVO_FORMAT_INTERNAL: { 535 gfits_table_set_Lensing (ftable, lensing, Nlensing );612 gfits_table_set_Lensing (ftable, lensing, Nlensing, swapFromNative); 536 613 break; } 537 614 … … 559 636 /*** Lensobj / FTable conversion functions ***/ 560 637 561 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, char *format) {638 Lensobj *FtableToLensobj (FTable *ftable, Average *average, off_t *Nlensobj, DVOCatFormat *format, char nativeBytes) { 562 639 563 640 Lensobj *lensobj; … … 572 649 if (!strcmp (extname, "DVO_LENSOBJ_PS1_V5") && (ftable[0].header[0].Naxis[0] == 136)) { 573 650 Lensobj_PS1_V5_R0 *tmpLensobj; 574 tmpLensobj = gfits_table_get_Lensobj_PS1_V5_R0 (ftable, Nlensobj, NULL );651 tmpLensobj = gfits_table_get_Lensobj_PS1_V5_R0 (ftable, Nlensobj, NULL, &nativeBytes); 575 652 if (!tmpLensobj) { 576 653 fprintf (stderr, "ERROR: failed to read lensobjs\n"); … … 592 669 if (!strcmp (extname, NAME)) { \ 593 670 Lensobj_##TYPE *tmpLensobj; \ 594 tmpLensobj = gfits_table_get_Lensobj_##TYPE (ftable, Nlensobj, NULL ); \671 tmpLensobj = gfits_table_get_Lensobj_##TYPE (ftable, Nlensobj, NULL, &nativeBytes); \ 595 672 if (!tmpLensobj) { \ 596 673 fprintf (stderr, "ERROR: failed to read lensobjs\n"); \ … … 603 680 604 681 if (!strcmp (extname, "DVO_LENSOBJ")) { 605 lensobj = gfits_table_get_Lensobj (ftable, Nlensobj, NULL );682 lensobj = gfits_table_get_Lensobj (ftable, Nlensobj, NULL, &nativeBytes); 606 683 if (!lensobj) { 607 684 fprintf (stderr, "ERROR: failed to read lensobjs\n"); … … 635 712 636 713 // LensobjToFtable needs the Average since old formats stored lensobj.dR,dD only 637 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, char format) {714 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, DVOCatFormat format, int swapFromNative) { 638 715 639 716 # define FORMAT_CASE(FORMAT, TYPE) \ … … 641 718 Lensobj_##TYPE *tmpLensobj; \ 642 719 tmpLensobj = LensobjInternalTo_##TYPE (lensobj, Nlensobj); \ 643 gfits_table_set_Lensobj_##TYPE (ftable, tmpLensobj, Nlensobj); \720 gfits_table_set_Lensobj_##TYPE (ftable, tmpLensobj, Nlensobj, swapFromNative); \ 644 721 free (tmpLensobj); \ 645 722 break; } … … 648 725 switch (format) { 649 726 case DVO_FORMAT_INTERNAL: { 650 gfits_table_set_Lensobj (ftable, lensobj, Nlensobj );727 gfits_table_set_Lensobj (ftable, lensobj, Nlensobj, swapFromNative); 651 728 break; } 652 729 … … 674 751 /*** StarPar / FTable conversion functions ***/ 675 752 676 StarPar *FtableToStarPar (FTable *ftable, off_t *Nstarpar, char *format) {753 StarPar *FtableToStarPar (FTable *ftable, Average *average, off_t *Nstarpar, DVOCatFormat *format, char nativeBytes) { 677 754 678 755 StarPar *starpar; … … 695 772 if (!strcmp (extname, NAME)) { \ 696 773 StarPar_##TYPE *tmpStarPar; \ 697 tmpStarPar = gfits_table_get_StarPar_##TYPE (ftable, Nstarpar, NULL ); \774 tmpStarPar = gfits_table_get_StarPar_##TYPE (ftable, Nstarpar, NULL, &nativeBytes); \ 698 775 if (!tmpStarPar) { \ 699 776 fprintf (stderr, "ERROR: failed to read starpar\n"); \ … … 706 783 707 784 if (!strcmp (extname, "DVO_STARPAR")) { 708 starpar = gfits_table_get_StarPar (ftable, Nstarpar, NULL );785 starpar = gfits_table_get_StarPar (ftable, Nstarpar, NULL, &nativeBytes); 709 786 if (!starpar) { 710 787 fprintf (stderr, "ERROR: failed to read starpar\n"); … … 738 815 739 816 // StarParToFtable needs the Average since old formats stored starpar.dR,dD only 740 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, char format) {817 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, DVOCatFormat format, int swapFromNative) { 741 818 742 819 # define FORMAT_CASE(FORMAT, TYPE) \ … … 744 821 StarPar_##TYPE *tmpStarPar; \ 745 822 tmpStarPar = StarParInternalTo_##TYPE (starpar, Nstarpar); \ 746 gfits_table_set_StarPar_##TYPE (ftable, tmpStarPar, Nstarpar); \823 gfits_table_set_StarPar_##TYPE (ftable, tmpStarPar, Nstarpar, swapFromNative); \ 747 824 free (tmpStarPar); \ 748 825 break; } … … 751 828 switch (format) { 752 829 case DVO_FORMAT_INTERNAL: { 753 gfits_table_set_StarPar (ftable, starpar, Nstarpar );830 gfits_table_set_StarPar (ftable, starpar, Nstarpar, swapFromNative); 754 831 break; } 755 832 … … 776 853 } 777 854 855 /*** GalPhot / FTable conversion functions ***/ 856 857 GalPhot *FtableToGalPhot (FTable *ftable, Average *average, off_t *Ngalphot, DVOCatFormat *format, char nativeBytes) { 858 859 GalPhot *galphot; 860 char extname[80]; 861 862 /* convert to the internal format */ 863 if (!gfits_scan (ftable[0].header, "EXTNAME", "%s", 1, extname)) { 864 fprintf (stderr, "EXTNAME missing for galphot table\n"); 865 return (FALSE); 866 } 867 868 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 869 if (!strcmp (extname, NAME)) { \ 870 fprintf (stderr, "ERROR: format %s not defined for galphot, skipping\n", NAME); \ 871 *Ngalphot = 0; \ 872 return NULL; \ 873 } 874 875 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 876 if (!strcmp (extname, NAME)) { \ 877 GalPhot_##TYPE *tmpGalPhot; \ 878 tmpGalPhot = gfits_table_get_GalPhot_##TYPE (ftable, Ngalphot, NULL, &nativeBytes); \ 879 if (!tmpGalPhot) { \ 880 fprintf (stderr, "ERROR: failed to read galphots\n"); \ 881 exit (2); \ 882 } \ 883 galphot = GalPhot_##TYPE##_ToInternal (tmpGalPhot, *Ngalphot); \ 884 free (tmpGalPhot); \ 885 *format = DVO_FORMAT_##FORMAT; \ 886 return (galphot); } 887 888 if (!strcmp (extname, "DVO_GALPHOT")) { 889 galphot = gfits_table_get_GalPhot (ftable, Ngalphot, NULL, &nativeBytes); 890 if (!galphot) { 891 fprintf (stderr, "ERROR: failed to read galphots\n"); 892 exit (2); 893 } 894 *format = DVO_FORMAT_INTERNAL; 895 return (galphot); 896 } 897 898 SKIPPING_FORMAT ("DVO_GALPHOT_PS1_REF", PS1_REF, PS1_REF); 899 SKIPPING_FORMAT ("DVO_GALPHOT_ELIXIR", ELIXIR, Elixir); 900 SKIPPING_FORMAT ("DVO_GALPHOT_LONEOS", LONEOS, Loneos); 901 SKIPPING_FORMAT ("DVO_GALPHOT_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0); 902 SKIPPING_FORMAT ("DVO_GALPHOT_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1); 903 SKIPPING_FORMAT ("DVO_GALPHOT_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 904 SKIPPING_FORMAT ("DVO_GALPHOT_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 905 SKIPPING_FORMAT ("DVO_GALPHOT_PS1_V1", PS1_V1, PS1_V1); 906 SKIPPING_FORMAT ("DVO_GALPHOT_PS1_V2", PS1_V2, PS1_V2); 907 SKIPPING_FORMAT ("DVO_GALPHOT_PS1_V3", PS1_V3, PS1_V3); 908 SKIPPING_FORMAT ("DVO_GALPHOT_PS1_V4", PS1_V4, PS1_V4); 909 CONVERT_FORMAT ("DVO_GALPHOT_PS1_V5", PS1_V5, PS1_V5); 910 SKIPPING_FORMAT ("DVO_GALPHOT_PS1_SIM", PS1_SIM, PS1_SIM); 911 # undef CONVERT_FORMAT 912 # undef SKIPPING_FORMAT 913 914 fprintf (stderr, "table format unknown: %s\n", extname); 915 916 *Ngalphot = 0; 917 return (NULL); 918 } 919 920 // GalPhotToFtable needs the Average since old formats stored galphot.dR,dD only 921 int GalPhotToFtable (FTable *ftable, GalPhot *galphot, off_t Ngalphot, DVOCatFormat format, int swapFromNative) { 922 923 # define FORMAT_CASE(FORMAT, TYPE) \ 924 case DVO_FORMAT_##FORMAT: { \ 925 GalPhot_##TYPE *tmpGalPhot; \ 926 tmpGalPhot = GalPhotInternalTo_##TYPE (galphot, Ngalphot); \ 927 gfits_table_set_GalPhot_##TYPE (ftable, tmpGalPhot, Ngalphot, swapFromNative); \ 928 free (tmpGalPhot); \ 929 break; } 930 931 /* convert from the internal format */ 932 switch (format) { 933 case DVO_FORMAT_INTERNAL: { 934 gfits_table_set_GalPhot (ftable, galphot, Ngalphot, swapFromNative); 935 break; } 936 937 // FORMAT_CASE (PS1_REF, PS1_REF); 938 // FORMAT_CASE (ELIXIR, Elixir); 939 // FORMAT_CASE (LONEOS, Loneos); 940 // FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 941 // FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 942 // FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 943 // FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 944 // FORMAT_CASE (PS1_V1, PS1_V1); 945 // FORMAT_CASE (PS1_V2, PS1_V2); 946 // FORMAT_CASE (PS1_V3, PS1_V3); 947 // FORMAT_CASE (PS1_V4, PS1_V4); 948 FORMAT_CASE (PS1_V5, PS1_V5); 949 # undef FORMAT_CASE 950 951 default: 952 fprintf (stderr, "table format unknown (galphot)\n"); 953 return (FALSE); 954 } 955 return (TRUE); 956 } 957 778 958 /*** Image Conversions ***/ 779 959 780 960 // I have loaded the disk db table and now I want to convert to the internal format 781 961 // (Image structure), but I onyl 782 int FtableToImage (FTable *ftable, Header *theader, char*format) {962 int FtableToImage (FTable *ftable, Header *theader, DVOCatFormat *format) { 783 963 784 964 off_t Nimage; … … 788 968 if (*format == DVO_FORMAT_ELIXIR) { // special case for ELIXIR 789 969 Image_Elixir *tmpimage; 790 tmpimage = gfits_table_get_Image_Elixir (ftable, &Nimage, NULL );970 tmpimage = gfits_table_get_Image_Elixir (ftable, &Nimage, NULL, NULL); 791 971 if (!tmpimage) { 792 972 fprintf (stderr, "ERROR: failed to read images\n"); … … 814 994 Image_##TYPE *tmpimage; \ 815 995 *format = DVO_FORMAT_##FORMAT; \ 816 tmpimage = gfits_table_get_Image_##TYPE (ftable, &Nimage, NULL ); \996 tmpimage = gfits_table_get_Image_##TYPE (ftable, &Nimage, NULL, NULL); \ 817 997 if (!tmpimage) { \ 818 998 fprintf (stderr, "ERROR: failed to read images\n"); \ … … 849 1029 } 850 1030 851 int ImageToFtable (FTable *ftable, Header *theader, charformat) {1031 int ImageToFtable (FTable *ftable, Header *theader, DVOCatFormat format) { 852 1032 853 1033 off_t Nimage; … … 860 1040 tmpImage = ImageInternalTo_##TYPE ((Image *) ftable[0].buffer, Nimage); \ 861 1041 free (ftable[0].buffer); \ 862 gfits_table_set_Image_##TYPE (ftable, tmpImage, Nimage ); \1042 gfits_table_set_Image_##TYPE (ftable, tmpImage, Nimage, TRUE); \ 863 1043 free (tmpImage); \ 864 1044 break; } … … 889 1069 } 890 1070 891 int ImageToVtable (VTable *vtable, Header *theader, charformat) {1071 int ImageToVtable (VTable *vtable, Header *theader, DVOCatFormat format) { 892 1072 893 1073 off_t i, Nrow, Nimage; -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c
r38318 r38447 118 118 out[i].Nmeasure = in[i].Nmeasure; 119 119 out[i].Nmissing = in[i].Nmissing; 120 out[i].N extend= in[i].Nextend;120 out[i].Ngalphot = in[i].Nextend; 121 121 out[i].measureOffset = in[i].measureOffset; 122 122 out[i].missingOffset = in[i].missingOffset; … … 152 152 out[i].Nmeasure = in[i].Nmeasure; 153 153 out[i].Nmissing = in[i].Nmissing; 154 out[i].Nextend = in[i].N extend;154 out[i].Nextend = in[i].Ngalphot; 155 155 out[i].measureOffset = in[i].measureOffset; 156 156 out[i].missingOffset = in[i].missingOffset; -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_convert_PS1_V1.c
r38318 r38447 138 138 out[i].Nmeasure = in[i].Nmeasure; 139 139 out[i].Nmissing = in[i].Nmissing; 140 out[i].N extend = in[i].Nextend;140 out[i].Ngalphot = in[i].Ngalphot; 141 141 out[i].measureOffset = in[i].measureOffset; 142 142 out[i].missingOffset = in[i].missingOffset; … … 173 173 out[i].Nmeasure = in[i].Nmeasure; 174 174 out[i].Nmissing = in[i].Nmissing; 175 out[i].N extend = in[i].Nextend;175 out[i].Ngalphot = in[i].Ngalphot; 176 176 out[i].measureOffset = in[i].measureOffset; 177 177 out[i].missingOffset = in[i].missingOffset; -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_convert_PS1_V2.c
r38318 r38447 143 143 out[i].Nmeasure = in[i].Nmeasure; 144 144 out[i].Nmissing = in[i].Nmissing; 145 out[i].N extend = in[i].Nextend;145 out[i].Ngalphot = in[i].Ngalphot; 146 146 out[i].measureOffset = in[i].measureOffset; 147 147 out[i].missingOffset = in[i].missingOffset; … … 182 182 out[i].Nmeasure = in[i].Nmeasure; 183 183 out[i].Nmissing = in[i].Nmissing; 184 out[i].N extend = in[i].Nextend;184 out[i].Ngalphot = in[i].Ngalphot; 185 185 out[i].measureOffset = in[i].measureOffset; 186 186 out[i].missingOffset = in[i].missingOffset; -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_convert_PS1_V3.c
r38318 r38447 143 143 out[i].Nmeasure = in[i].Nmeasure; 144 144 out[i].Nmissing = in[i].Nmissing; 145 out[i].N extend = in[i].Nextend;145 out[i].Ngalphot = in[i].Ngalphot; 146 146 out[i].measureOffset = in[i].measureOffset; 147 147 out[i].missingOffset = in[i].missingOffset; … … 184 184 out[i].Nmeasure = in[i].Nmeasure; 185 185 out[i].Nmissing = in[i].Nmissing; 186 out[i].N extend = in[i].Nextend;186 out[i].Ngalphot = in[i].Ngalphot; 187 187 out[i].measureOffset = in[i].measureOffset; 188 188 out[i].missingOffset = in[i].missingOffset; -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_convert_PS1_V4.c
r38318 r38447 164 164 out[i].Nmeasure = in[i].Nmeasure; 165 165 out[i].Nmissing = in[i].Nmissing; 166 out[i].N extend = in[i].Nextend;166 out[i].Ngalphot = in[i].Ngalphot; 167 167 out[i].measureOffset = in[i].measureOffset; 168 168 out[i].missingOffset = in[i].missingOffset; … … 208 208 out[i].Nmeasure = in[i].Nmeasure; 209 209 out[i].Nmissing = in[i].Nmissing; 210 out[i].N extend = in[i].Nextend;210 out[i].Ngalphot = in[i].Ngalphot; 211 211 out[i].measureOffset = in[i].measureOffset; 212 212 out[i].missingOffset = in[i].missingOffset; … … 690 690 out[i].Nmeasure = in[i].Nmeasure; 691 691 out[i].Nmissing = in[i].Nmissing; 692 out[i].N extend = in[i].Nextend;692 out[i].Ngalphot = in[i].Ngalphot; 693 693 out[i].measureOffset = in[i].measureOffset; 694 694 out[i].missingOffset = in[i].missingOffset; -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c
r38318 r38447 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].Ngalphot = in[i].Ngalphot; 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].galphotOffset = in[i].galphotOffset; 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].Ngalphot = in[i].Ngalphot; 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].galphotOffset = in[i].galphotOffset; 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 GalPhot *GalPhot_PS1_V5_ToInternal (GalPhot_PS1_V5 *in, off_t Nvalues) { 982 983 off_t i; 984 GalPhot *out; 985 986 ALLOCATE_ZERO (out, GalPhot, Nvalues); 987 988 for (i = 0; i < Nvalues; i++) { 989 dvo_galphot_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 GalPhot_PS1_V5 *GalPhotInternalTo_PS1_V5 (GalPhot *in, off_t Nvalues) { 1015 1016 off_t i; 1017 GalPhot_PS1_V5 *out; 1018 1019 ALLOCATE_ZERO (out, GalPhot_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].Ngalphot = in[i].Ngalphot; 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].galphotOffset = in[i].galphotOffset; 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); // NGALPHOT 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_GALPHOT 1310 1374 SWAP_WORD (136); // OFF_PARAMS 1311 1375 SWAP_WORD (140); // REF_COLOR_BLUE -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_image.c
r37807 r38447 19 19 db[0].lockstate = lockstate; 20 20 db[0].timeout = timeout; 21 gfits_db_init (db);22 21 23 22 if (!gfits_db_lock (db, filename)) { … … 89 88 // so when we later do a gfits_copy_ftable, we stomp on bad memory 90 89 FtableToImage (&db[0].ftable, &db[0].theader, &db[0].format); 91 db[0].swapped = TRUE; /* table has internal byte-order */ 90 db[0].nativeOrder = TRUE; /* table has internal byte-order */ 91 db[0].scaledValue = TRUE; /* table has internal byte-order */ 92 92 return (TRUE); 93 93 } … … 100 100 /* convert from internal to requested external format */ 101 101 ImageToFtable (&db[0].ftable, &db[0].theader, db[0].format); 102 db[0].swapped = FALSE; 102 db[0].nativeOrder = FALSE; 103 db[0].scaledValue = FALSE; 103 104 104 105 /* write data in appropriate mode */ … … 149 150 /* theader is modified to match output format */ 150 151 ImageToVtable (&db[0].vtable, &db[0].theader, db[0].format); 151 db[0].swapped = FALSE; 152 db[0].scaledValue = FALSE; 153 db[0].nativeOrder = FALSE; 152 154 153 155 /* write data in appropriate mode */ … … 363 365 364 366 /* return internal structure representation */ 365 Image *gfits_table_get_Image (FTable *ftable, off_t *Ndata, char *s wapped) {367 Image *gfits_table_get_Image (FTable *ftable, off_t *Ndata, char *scaledValue, char *nativeOrder) { 366 368 367 369 int Ncols; … … 377 379 data = (Image *) ftable[0].buffer; 378 380 379 if (!swapped) { 380 myAbort ("invalid to call this without suppying 'swapped'"); 381 } 382 if (*swapped == FALSE) { 383 myAbort ("invalid for table to be swapped"); 381 if (!scaledValue) { 382 myAbort ("invalid to call this without suppying 'scaledValue'"); 383 } 384 if (*scaledValue == FALSE) { 385 myAbort ("invalid for table NOT to be scaledValue"); 386 } 387 if (!nativeOrder) { 388 myAbort ("invalid to call this without suppying 'nativeOrder'"); 389 } 390 if (*nativeOrder == FALSE) { 391 myAbort ("invalid for table NOT to be nativeOrder"); 384 392 } 385 393 -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_image_raw.c
r37807 r38447 107 107 db[0].theader.Naxis[1] = Nimage; 108 108 db[0].ftable.datasize = gfits_data_size (&db[0].theader); 109 db[0].swapped = FALSE; /* table does not have internal byte-order */ 109 110 db[0].nativeOrder = FALSE; /* table does not have internal byte-order */ 111 db[0].scaledValue = FALSE; /* table does not have internal byte-order */ 110 112 return (TRUE); 111 113 } -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/dvo_util.c
r37807 r38447 127 127 } 128 128 129 dvoConfig->images = gfits_table_get_Image (&dvoConfig->imageDB.ftable, &dvoConfig->nImages, &dvoConfig->imageDB.s wapped);129 dvoConfig->images = gfits_table_get_Image (&dvoConfig->imageDB.ftable, &dvoConfig->nImages, &dvoConfig->imageDB.scaledValue, &dvoConfig->imageDB.nativeOrder); 130 130 if (!dvoConfig->images) { 131 131 fprintf (stderr, "problem loading images\n"); … … 207 207 Catalog catalog; 208 208 catalog.filename = skylist->filename[reg]; 209 catalog.catflags = GetMeasures ? LOAD_AVES | LOAD_MEAS | LOAD_SECF : LOAD_AVES | LOAD_SECF;209 catalog.catflags = GetMeasures ? DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT : DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 210 210 catalog.Nsecfilt = 0; 211 211 -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/fits_db.c
r35755 r38447 6 6 db[0].f = NULL; 7 7 db[0].filename = NULL; 8 db[0].dbstate = 0; 9 db[0].lockstate = 0; 10 db[0].mode = 0; 11 db[0].format = 0; 12 db[0].virtual = 0; 13 db[0].nativeOrder = 0; 14 db[0].scaledValue = 0; 8 15 9 # if (1)10 16 gfits_init_header (&db->header); 11 17 gfits_init_matrix (&db->matrix); 12 18 gfits_init_header (&db->theader); 13 gfits_init_table (&db->ftable);19 gfits_init_table (&db->ftable); 14 20 db->ftable.header = &db->theader; 15 21 gfits_init_vtable (&db->vtable); 16 # else17 db[0].header.buffer = NULL;18 db[0].matrix.buffer = NULL;19 db[0].theader.buffer = NULL;20 db[0].ftable.buffer = NULL;21 db[0].ftable.header = &db[0].theader;22 db[0].vtable.header = NULL;23 db[0].vtable.buffer = NULL;24 db[0].vtable.row = NULL;25 # endif26 22 return (TRUE); 27 23 } … … 97 93 return (FALSE); 98 94 } 99 db[0].swapped = FALSE; /* table does not have internal byte-order */ 95 db[0].nativeOrder = FALSE; /* table does not have internal byte-order */ 96 db[0].scaledValue = FALSE; /* table has not been scaled by BZERO,BSCALE */ 100 97 return (TRUE); 101 98 } -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/flatcorr_io.c
r37807 r38447 49 49 return (NULL); 50 50 } 51 flatcorrTable->image = gfits_table_get_FlatCorrectionImage (&ftable, &flatcorrTable->Nimage, NULL );51 flatcorrTable->image = gfits_table_get_FlatCorrectionImage (&ftable, &flatcorrTable->Nimage, NULL, NULL); 52 52 if (!flatcorrTable->image) { 53 53 fprintf (stderr, "ERROR: failed to read Flat Correction Images\n"); … … 64 64 return (NULL); 65 65 } 66 flatcorrTable->corr = gfits_table_get_FlatCorrection (&ftable, &flatcorrTable->Ncorr, NULL );66 flatcorrTable->corr = gfits_table_get_FlatCorrection (&ftable, &flatcorrTable->Ncorr, NULL, NULL); 67 67 if (!flatcorrTable->corr) { 68 68 fprintf (stderr, "ERROR: failed to read Flat Corrections\n"); … … 93 93 for (j = 0; j < flatcorrTable->image[i].Nx; j++) { 94 94 ALLOCATE (flatcorrTable->offset[i][j], float, flatcorrTable->image[i].Ny); 95 memset (flatcorrTable->offset[i][j], 0 .0, flatcorrTable->image[i].Ny*sizeof(float));95 memset (flatcorrTable->offset[i][j], 0, flatcorrTable->image[i].Ny*sizeof(float)); 96 96 } 97 97 } … … 161 161 162 162 ftableImage.header = &theaderImage; 163 gfits_table_set_FlatCorrectionImage (&ftableImage, image, flatcorrTable->Nimage );163 gfits_table_set_FlatCorrectionImage (&ftableImage, image, flatcorrTable->Nimage, TRUE); 164 164 165 165 ftableCorr.header = &theaderCorr; 166 gfits_table_set_FlatCorrection (&ftableCorr, corr, flatcorrTable->Ncorr );166 gfits_table_set_FlatCorrection (&ftableCorr, corr, flatcorrTable->Ncorr, TRUE); 167 167 168 168 f = fopen (filename, "w"); -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/skyregion_io.c
r36833 r38447 40 40 ALLOCATE (skytable, SkyTable, 1); 41 41 memset (skytable->hosts, 0, 80); 42 skytable[0].regions = gfits_table_get_SkyRegion (&ftable, &skytable[0].Nregions, NULL );42 skytable[0].regions = gfits_table_get_SkyRegion (&ftable, &skytable[0].Nregions, NULL, NULL); 43 43 if (!skytable[0].regions) { 44 44 fprintf (stderr, "ERROR: failed to read sky regions\n"); … … 99 99 gfits_print (&header, "HOSTS", "%s", 1, skytable->hosts); 100 100 101 gfits_table_set_SkyRegion (&ftable, skytable[0].regions, skytable[0].Nregions );101 gfits_table_set_SkyRegion (&ftable, skytable[0].regions, skytable[0].Nregions, TRUE); 102 102 103 103 f = fopen (filename, "w"); -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/Makefile
r37807 r38447 1 1 default: install 2 2 help: 3 @echo "make options: install libfits man clean dist "3 @echo "make options: install libfits man clean dist test test.verbose test.clean" 4 4 5 5 include ../../Makefile.System … … 13 13 INC = $(HOME)/include 14 14 MAN = $(HOME)/doc 15 TESTDIR = $(HOME)/test 16 TESTBIN = $(HOME)/test 15 17 include ../../Makefile.Common 16 18 … … 19 21 FULL_CPPFLAGS = $(BASE_CPPFLAGS) -I$(EXT) 20 22 FULL_LDFLAGS = $(BASE_LDFLAGS) -lohana 23 24 TEST_CFLAGS = $(BASE_CFLAGS) 25 TEST_CPPFLAGS = $(BASE_CPPFLAGS) 26 TEST_LDFLAGS = $(BASE_LDFLAGS) -lFITS -lohana -ltap_ohana 27 28 29 TESTXTRA = tcomptiming 30 TESTPROG = zlib ricetest imagecomp tablecomp 31 $(TESTPROG) : % : $(TESTBIN)/% 32 $(TESTXTRA) : % : $(TESTBIN)/% 33 test: $(TESTPROG) 34 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 | $(TESTHARNESS); done 35 test.verbose: $(TESTPROG) 36 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 | $(TESTHARNESS) -v; done 21 37 22 38 install: $(DESTLIB)/libFITS.a $(DESTLIB)/libFITS.$(DLLTYPE) $(DESTMAN)/fits.1 … … 37 53 38 54 MATRIX_OBJ = \ 39 $(MATR)/F_add_M_value.$(ARCH).o $(MATR)/F_add_M.$(ARCH).o \ 40 $(MATR)/F_create_M.$(ARCH).o $(MATR)/F_divide_M.$(ARCH).o \ 41 $(MATR)/F_free_M.$(ARCH).o $(MATR)/F_copy_M.$(ARCH).o \ 42 $(MATR)/F_write_M.$(ARCH).o $(MATR)/F_get_M_value.$(ARCH).o \ 43 $(MATR)/F_multiply_M.$(ARCH).o $(MATR)/F_read_M.$(ARCH).o \ 44 $(MATR)/F_insert_M.$(ARCH).o $(MATR)/F_set_M_value.$(ARCH).o \ 45 $(MATR)/F_convert_format.$(ARCH).o $(MATR)/F_read_segment.$(ARCH).o \ 46 $(MATR)/F_read_portion.$(ARCH).o $(MATR)/F_load_M.$(ARCH).o \ 47 $(MATR)/F_matrix.$(ARCH).o $(MATR)/F_compress_M.$(ARCH).o \ 48 $(MATR)/F_uncompress_data.$(ARCH).o 55 $(MATR)/F_add_M_value.$(ARCH).o $(MATR)/F_add_M.$(ARCH).o \ 56 $(MATR)/F_create_M.$(ARCH).o $(MATR)/F_divide_M.$(ARCH).o \ 57 $(MATR)/F_free_M.$(ARCH).o $(MATR)/F_copy_M.$(ARCH).o \ 58 $(MATR)/F_write_M.$(ARCH).o $(MATR)/F_get_M_value.$(ARCH).o \ 59 $(MATR)/F_multiply_M.$(ARCH).o $(MATR)/F_read_M.$(ARCH).o \ 60 $(MATR)/F_insert_M.$(ARCH).o $(MATR)/F_set_M_value.$(ARCH).o \ 61 $(MATR)/F_convert_format.$(ARCH).o $(MATR)/F_read_segment.$(ARCH).o \ 62 $(MATR)/F_read_portion.$(ARCH).o $(MATR)/F_load_M.$(ARCH).o \ 63 $(MATR)/F_matrix.$(ARCH).o $(MATR)/F_compress_utils.$(ARCH).o \ 64 $(MATR)/F_compress_M.$(ARCH).o $(MATR)/F_compress_data.$(ARCH).o \ 65 $(MATR)/F_uncompress_M.$(ARCH).o $(MATR)/F_uncompress_data.$(ARCH).o \ 66 $(MATR)/F_swap_raw.$(ARCH).o 49 67 50 68 TABLE_OBJ = \ … … 55 73 $(TABL)/F_set_column.$(ARCH).o $(TABL)/F_get_column.$(ARCH).o \ 56 74 $(TABL)/F_table_row.$(ARCH).o $(TABL)/F_free_T.$(ARCH).o \ 57 $(TABL)/F_table_varlength.$(ARCH).o $(TABL)/F_copy_T.$(ARCH).o 75 $(TABL)/F_table_varlength.$(ARCH).o $(TABL)/F_copy_T.$(ARCH).o \ 76 $(TABL)/F_compress_T.$(ARCH).o $(TABL)/F_uncompress_T.$(ARCH).o 58 77 59 78 EXTERN_OBJ = \ -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/doc/notes-compress.txt
r15487 r38447 1 2 20150525 : 3 4 uncompression steps: 5 6 * read in a table: gfits_fread_ftable_data (f, &ftable, FALSE); (no byte swap) 7 * uncompress the image: gfits_uncompress_image (&buf[0].header, &buf[0].matrix, &ftable); 8 * get ZIMAGE from heaer & delete 9 * get ZCMPTYPE 10 * get ZBITPIX, ZNAXIS, ZNAXISnn 11 * get ZTILEn (if missing ZTILE1 = Nx, others 1) 12 * get ZNAME, ZVAL 13 * ZSIMPLE, ZTENSION, ZEXTEND, ZBLOCKED, ZPCOUNT, ZGCOUNT, etc 14 * ZSCALE, ZBLANK, OBLANK, ZZERO 15 16 * data is stored in fits table COMPRESSED_DATA (1PB, 1PI, 1PJ) 17 18 ------------------------------------------------ 1 19 2 20 TFORMn : rPt(e_max) -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/extern/gzip.c
r23816 r38447 2 2 # include <gfitsio.h> 3 3 # include <zlib.h> 4 # define EXTRA_VERBOSE 0 4 5 5 6 /** the two functions in this file re-implement the uncompress function of zlib. … … 10 11 11 12 /* zlib.h -- interface of the 'zlib' general purpose compression library 12 version 1.2.3, July 18th, 200513 14 Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler15 16 This software is provided 'as-is', without any express or implied17 warranty. In no event will the authors be held liable for any damages18 arising from the use of this software.19 20 Permission is granted to anyone to use this software for any purpose,21 including commercial applications, and to alter it and redistribute it22 freely, subject to the following restrictions:23 24 1. The origin of this software must not be misrepresented; you must not25 claim that you wrote the original software. If you use this software26 in a product, an acknowledgment in the product documentation would be27 appreciated but is not required.28 2. Altered source versions must be plainly marked as such, and must not be29 misrepresented as being the original software.30 3. This notice may not be removed or altered from any source distribution.31 32 Jean-loup Gailly Mark Adler33 jloup@gzip.org madler@alumni.caltech.edu34 35 36 The data format used by the zlib library is described by RFCs (Request for37 Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt38 (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).13 version 1.2.3, July 18th, 2005 14 15 Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler 16 17 This software is provided 'as-is', without any express or implied 18 warranty. In no event will the authors be held liable for any damages 19 arising from the use of this software. 20 21 Permission is granted to anyone to use this software for any purpose, 22 including commercial applications, and to alter it and redistribute it 23 freely, subject to the following restrictions: 24 25 1. The origin of this software must not be misrepresented; you must not 26 claim that you wrote the original software. If you use this software 27 in a product, an acknowledgment in the product documentation would be 28 appreciated but is not required. 29 2. Altered source versions must be plainly marked as such, and must not be 30 misrepresented as being the original software. 31 3. This notice may not be removed or altered from any source distribution. 32 33 Jean-loup Gailly Mark Adler 34 jloup@gzip.org madler@alumni.caltech.edu 35 36 37 The data format used by the zlib library is described by RFCs (Request for 38 Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt 39 (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). 39 40 */ 40 41 41 42 /* 42 The 'zlib' compression library provides in-memory compression and43 The 'zlib' compression library provides in-memory compression and 43 44 decompression functions, including integrity checks of the uncompressed 44 45 data. This version of the library supports only one compression method … … 46 47 stream interface. 47 48 48 Compression can be done in a single step if the buffers are large49 Compression can be done in a single step if the buffers are large 49 50 enough (for example if an input file is mmap'ed), or can be done by 50 51 repeated calls of the compression function. In the latter case, the … … 52 53 (providing more output space) before each call. 53 54 54 The compressed data format used by default by the in-memory functions is55 The compressed data format used by default by the in-memory functions is 55 56 the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped 56 57 around a deflate stream, which is itself documented in RFC 1951. 57 58 58 The library also supports reading and writing files in gzip (.gz) format59 The library also supports reading and writing files in gzip (.gz) format 59 60 with an interface similar to that of stdio using the functions that start 60 61 with "gz". The gzip format is different from the zlib format. gzip is a 61 62 gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. 62 63 63 This library can optionally read and write gzip streams in memory as well.64 65 The zlib format was designed to be compact and fast for use in memory64 This library can optionally read and write gzip streams in memory as well. 65 66 The zlib format was designed to be compact and fast for use in memory 66 67 and on communications channels. The gzip format was designed for single- 67 68 file compression on file systems, has a larger header than zlib to maintain 68 69 directory information, and uses a different, slower check method than zlib. 69 70 70 The library does not install any signal handler. The decoder checks71 The library does not install any signal handler. The decoder checks 71 72 the consistency of the compressed data, so the library should never 72 73 crash even in case of corrupted input. … … 116 117 } 117 118 118 // XXX ??? is cfitsio writing data which is incompatible with zlib ??? 119 int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) 120 { 121 z_stream stream; 122 int err; 123 124 stream.next_in = (Bytef*)source; 125 stream.avail_in = (uInt)sourceLen; 126 /* Check for source > 64K on 16-bit machine: */ 127 if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 128 129 stream.next_out = dest; 130 stream.avail_out = (uInt)*destLen; 131 if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 132 133 stream.zalloc = (alloc_func)0; 134 stream.zfree = (free_func)0; 135 136 // MAX_WBITS = 15 137 err = inflateInit2(&stream, -15); 138 if (err != Z_OK) return err; 139 140 err = inflate(&stream, Z_FINISH); 141 if (err != Z_STREAM_END) { 142 inflateEnd(&stream); 143 if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 144 return Z_DATA_ERROR; 145 return err; 146 } 147 assert (stream.total_out <= *destLen); 148 *destLen = stream.total_out; 149 150 err = inflateEnd(&stream); 151 return err; 119 # define ESCAPE(RET) { fprintf (stderr, "gzip error in %s @ %s:%d\n", __func__, __FILE__, __LINE__); return (RET); } 120 121 int gfits_compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) { 122 123 z_stream stream; 124 int i, err; 125 126 stream.next_in = (Bytef*)source; 127 stream.avail_in = (uInt)sourceLen; 128 129 /* Check for source > 64K on 16-bit machine: */ 130 if ((uLong)stream.avail_in != sourceLen) ESCAPE (Z_BUF_ERROR); 131 132 stream.next_out = dest; 133 stream.avail_out = (uInt)*destLen; // allocated space 134 if ((uLong)stream.avail_out != *destLen) ESCAPE (Z_BUF_ERROR); 135 136 stream.zalloc = Z_NULL; 137 stream.zfree = Z_NULL; 138 stream.opaque = Z_NULL; 139 140 if (EXTRA_VERBOSE) { 141 fprintf (stderr, "inp cmp: "); 142 for (i = 0; i < sourceLen; i++) { 143 fprintf (stderr, "0x%02hhx ", source[i]); 144 } 145 fprintf (stderr, "\n"); 146 } 147 148 // the '1' is the compression level: make this a user argument 149 // NOTE: cfitsio uses a fixed value of 1 150 // I am using deflateInit2 because cfitsio expects gzip, not just zlib 151 // windowBits = 31 = (15 + 16) = (2^15 window bits) + (create a gzip stream) 152 err = deflateInit2(&stream, 1, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY); 153 if (0) fprintf (stderr, "inp buffers cmp 0: %d => %d => %d\n", stream.avail_in, stream.avail_out, (int) stream.total_out); 154 155 if (err != Z_OK) ESCAPE(err); 156 157 // XXX this is written to do the compression in a single pass. it could be re-done to have 158 // the compression occur in a series of steps 159 err = deflate(&stream, Z_FINISH); 160 if (err != Z_STREAM_END) { 161 err = deflateEnd(&stream); 162 ESCAPE (Z_BUF_ERROR); 163 } 164 165 if (EXTRA_VERBOSE) { 166 fprintf (stderr, "out cmp: "); 167 for (i = 0; i < stream.total_out; i++) { 168 fprintf (stderr, "0x%02hhx ", dest[i]); 169 } 170 fprintf (stderr, "\n"); 171 } 172 173 assert (stream.total_out <= *destLen); 174 *destLen = stream.total_out; 175 176 err = deflateEnd(&stream); 177 return err; 152 178 } 179 180 // NOTE: CFITSIO uses gzip format, not just zlib 181 int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) { 182 183 z_stream stream; 184 int i, err; 185 186 stream.next_in = (Bytef*)source; 187 stream.avail_in = (uInt)sourceLen; 188 189 /* Check for source > 64K on 16-bit machine: */ 190 if ((uLong)stream.avail_in != sourceLen) ESCAPE (Z_BUF_ERROR); 191 192 stream.next_out = dest; 193 stream.avail_out = (uInt)*destLen; 194 if ((uLong)stream.avail_out != *destLen) ESCAPE (Z_BUF_ERROR); 195 196 stream.zalloc = Z_NULL; 197 stream.zfree = Z_NULL; 198 stream.opaque = Z_NULL; 199 200 if (EXTRA_VERBOSE) { 201 fprintf (stderr, "inp unc: "); 202 for (i = 0; i < sourceLen; i++) { 203 fprintf (stderr, "0x%02hhx ", source[i]); 204 } 205 fprintf (stderr, "\n"); 206 } 207 208 // windowBits = 47 = (15 + 32) = (2^15 window bits) + (test for either gzip or zlib 209 // streams). NOTE: modern versions of zlib (version > 1.2.3.4) allow for windowBits = 0 210 // (or 16 or 32) to use the compressed stream windowBits value. IPP cluster still has 211 // zlib version = 1.2.3, so we cannot use this feature. 212 err = inflateInit2(&stream, 47); 213 if (err != Z_OK) ESCAPE (err); 214 215 err = inflate(&stream, Z_FINISH); 216 if (err != Z_STREAM_END) { 217 inflateEnd(&stream); 218 if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) ESCAPE (Z_DATA_ERROR); 219 ESCAPE(err); 220 } 221 222 if (EXTRA_VERBOSE) { 223 fprintf (stderr, "out unc: "); 224 for (i = 0; i < stream.total_out; i++) { 225 fprintf (stderr, "0x%02hhx ", dest[i]); 226 } 227 fprintf (stderr, "\n"); 228 } 229 230 assert (stream.total_out <= *destLen); 231 *destLen = stream.total_out; 232 233 err = inflateEnd(&stream); 234 return err; 235 } 236 -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/header/F_copy_H.c
r27435 r38447 30 30 return (TRUE); 31 31 } 32 33 int gfits_copy_header_ptr (Header *in, Header *out) { 34 35 int i; 36 37 if (!in) return FALSE; 38 if (!out) return FALSE; 39 40 out[0].simple = in[0].simple; 41 out[0].unsign = in[0].unsign; 42 out[0].extend = in[0].extend; 43 out[0].bitpix = in[0].bitpix; 44 45 out[0].Naxes = in[0].Naxes; 46 for (i = 0; i < FT_MAX_NAXES; i++) 47 out[0].Naxis[i] = in[0].Naxis[i]; 48 49 out[0].datasize = in[0].datasize; 50 51 out[0].pcount = in[0].pcount; 52 out[0].gcount = in[0].gcount; 53 out[0].bzero = in[0].bzero; 54 out[0].bscale = in[0].bscale; 55 56 out[0].buffer = in[0].buffer; 57 58 return (TRUE); 59 } -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/header/F_modify.c
r34577 r38447 48 48 strncpy (comment, qe, p + 80 - qe); 49 49 } 50 gfits_pad_ending (comment, ' ', 82); /* comment must contain spaces to the end */50 gfits_pad_ending (comment, 0x20, 82); /* comment must contain spaces to the end */ 51 51 52 52 /* write the numeric modes */ … … 134 134 strncpy (comment, qe, p + 80 - qe); 135 135 } 136 gfits_pad_ending (comment, ' ', 82); /* comment must contain spaces to the end */136 gfits_pad_ending (comment, 0x20, 82); /* comment must contain spaces to the end */ 137 137 138 138 /* write the boolean mode */ … … 166 166 if (!ptr) goto invalid; 167 167 strncpy (comment, ptr, 80); 168 gfits_pad_ending (comment, ' ', 82); /* comment must contain spaces to the end */168 gfits_pad_ending (comment, 0x20, 82); /* comment must contain spaces to the end */ 169 169 snprintf (string, 81, "%-8s= %s / %-s", field, data, comment); 170 170 /* this will keep the original line, but truncate the comment */ … … 296 296 */ 297 297 298 // XXX this is an absurd patch on a gcc bug: memset has a problem is value != 0 and N is constant 299 void myMemset (char *ptr, int value, size_t N) { 300 301 char *p = ptr; 302 303 size_t i = 0; 304 for (i = 0; i < N; i++, p++) { 305 *p = value; 306 } 307 } 308 298 309 /* fill 'line' with Nbyte space from first NULL to last byte with value */ 299 310 void gfits_pad_ending (char *line, char value, int Nbyte) { 300 301 char *p;302 int N;303 311 304 312 line[Nbyte-1] = 0; 305 313 306 p = line + strlen (line);307 N = MAX (Nbyte - strlen (line) - 1, 0);308 m emset (p, value, N);314 char *p = line + strlen (line); 315 size_t N = MAX (Nbyte - strlen (line) - 1, 0); 316 myMemset (p, value, N); 309 317 } 310 318 -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/include/gfitsio.h
r38062 r38447 73 73 off_t datasize; // size of the buffer (including block padding at the end) 74 74 off_t validsize; // size of the valid portion of the table (< validsize if file is short) 75 off_t heap_start; // byte offset to start of HEAP 75 76 } FTable; 76 77 … … 85 86 } VTable; 86 87 87 typedef struct { 88 int maxlen; // max size of all table rows 89 int nbytes; // number of bytes per column element 90 int Nstart; // byte offset of this column relative to first column 91 off_t heap_start; // byte offset to start of HEAP 92 char format; // data format character (one of: XLABIJEDCM) 93 char mode; // access data pointer type (one of P or Q) 88 // description / metadata needed for a single varlength column. A varlength column has a 89 // 2-element array giving the (length,offset) of data in the heap. Below, 'real data' are 90 // the values in the heap; 'metadata' are the values in the main table. 91 typedef struct { 92 int column; // field number (of the metadata) 93 char format; // format character for real data (one of: XLABIJKEDCM) 94 char mode; // format character for metadata (one of P [float] or Q [double]) 95 int maxlen; // max size of all table rows for this column 96 int nbytes; // number of bytes per real data column element 97 int offset; // byte offset of the metadata column relative to first column 94 98 } VarLengthColumn; 99 100 typedef struct { 101 char ttype[16]; // TTYPE field of original table 102 char ttype_cmt[80]; // comment associated with TTYPE 103 char tunit[16]; // TUNIT field of original table 104 char tunit_cmt[80]; // comment associated with TUNIT 105 char tformat[16]; // TFORM field of original table 106 char tformat_cmt[80]; // comment associated with TFORM 107 char zctype[80]; // compression type for this field 108 VarLengthColumn zdef; // description of the output variable length column 109 110 char datatype[80]; // named data type associated with ttype (eg, 18J -> int, 18D -> double) 111 int Nvalues; // number of values per row (eg 18J -> 18 int values) 112 int pixsize; // number of bytes per value of this row (eg, 18J -> 4 bytes) 113 int rowsize; // number of bytes for a full row (Nvalues * pixsize) 114 int offset; // byte offset of the real data column relative to first column 115 } TableField; 95 116 96 117 # ifndef PROTO … … 106 127 char *gfits_keyword_end PROTO((char *line)); 107 128 int gfits_copy_header PROTO((Header *in, Header *out)); 129 int gfits_copy_header_ptr PROTO((Header *in, Header *out)); 108 130 int gfits_create_header PROTO((Header *header)); 109 131 int gfits_delete PROTO((Header *header, char *field, int N)); … … 117 139 int gfits_modify PROTO((Header *header, char *field, char *mode, int N,...)) OHANA_FORMAT(printf, 3, 5); 118 140 int gfits_print PROTO((Header *header, char *field, char *mode, int N,...)) OHANA_FORMAT(printf, 3, 5); 119 int gfits_modify_alt PROTO((Header *header, char *field, char *mode, int N,...)); 120 int gfits_print_alt PROTO((Header *header, char *field, char *mode, int N,...)); 141 int gfits_modify_alt PROTO((Header *header, char *field, char *mode, int N,...)); // do not use a FORMAT: non-standard fmt chars 142 int gfits_print_alt PROTO((Header *header, char *field, char *mode, int N,...)); // do not use a FORMAT: non-standard fmt chars 121 143 int gfits_find_Xheader PROTO((FILE *f, Header *header, char *extname)); 122 144 int gfits_read_Xheader PROTO((char *filename, Header *header, int N)); … … 124 146 int gfits_save_header PROTO((FILE *f, Header *header)); 125 147 int gfits_scan PROTO((Header *header, char *field, char *mode, int N,...)) OHANA_FORMAT(scanf, 3, 5); 126 int gfits_scan_alt PROTO((Header *header, char *field, char *mode, int N,...)); 148 int gfits_scan_alt PROTO((Header *header, char *field, char *mode, int N,...)); // do not use a FORMAT: non-standard fmt chars 127 149 int gfits_set_unsign_mode PROTO((int mode)); 128 150 int gfits_stripwhite PROTO((char *string)); … … 133 155 off_t gfits_data_min_size PROTO((Header *header)); 134 156 off_t gfits_data_pad_size PROTO((off_t rawsize)); 157 off_t gfits_heap_start PROTO((Header *header)); 135 158 int gfits_extended_to_primary PROTO((Header *header, int simple, char *comment)); 136 159 int gfits_primary_to_extended PROTO((Header *header, char *exttype, char *comment)); … … 166 189 void gfits_set_matrix_value PROTO((Matrix *matrix, off_t x, off_t y, double value)); 167 190 int gfits_write_matrix PROTO((char *filename, Matrix *matrix)); 191 168 192 int gfits_uncompress_image PROTO((Header *header, Matrix *matrix, FTable *ftable)); 169 int gfits_uncompress_data PROTO((char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int out_pixsize)); 170 int gfits_distribute_data PROTO((Matrix *matrix, int bitpix, char *data, int Ndata, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero)); 171 int gfits_byteswap_zdata PROTO((char *zdata, int Nzdata, int bitpix)); 172 int gfits_extension_is_compressed PROTO((Header *header)); 193 int gfits_uncompress_data PROTO((char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int Nout_alloc, int out_pixsize)); 194 int gfits_distribute_data PROTO((Matrix *matrix, char *data, int Ndata, int bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero)); 195 196 int gfits_compress_data PROTO((char *zdata, int *Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *rawdata, int Nraw, int raw_pixsize, int Nx, int Ny)); 197 int gfits_compress_image PROTO((Header *header, Matrix *matrix, FTable *ftable, int *Ztile, char *zcmptype)); 198 int gfits_collect_data PROTO((Matrix *matrix, char *raw, int Nraw, int raw_pixsize, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero)); 199 200 int gfits_copy_keywords_compress PROTO((Header *srchead, Header *tgthead)); 201 int gfits_swap_raw PROTO((Matrix *matrix)); 202 173 203 off_t gfits_tile_size PROTO((Matrix *matrix, int *otile, int *ztile)); 204 int gfits_imtile_maxsize PROTO((Matrix *matrix, int *ztile)); 205 int gfits_imtile_count PROTO((Matrix *matrix, int *ztile, int *ntile)); 206 int gfits_imtile_start PROTO((Matrix *matrix, int *otile)); 207 int gfits_imtile_next PROTO((Matrix *matrix, int *ztile, int *ntile, int *otile)); 208 209 int gfits_extension_is_compressed_image PROTO((Header *header)); 210 int gfits_extension_is_compressed_table PROTO((Header *header)); 211 int gfits_byteswap_zdata PROTO((char *zdata, int Nzdata, int pixsize)); 212 int gfits_compressed_data_pixsize PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions)); 174 213 int gfits_uncompressed_data_pixsize PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions)); 175 int gfits_vartable_heap_pixsize PROTO((char format)); 214 int gfits_uncompressed_data_bitpix PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions)); 215 int gfits_vartable_heap_pixsize PROTO((char format)); 216 int gfits_cmptype_valid PROTO((char *cmptype)); 217 218 int gfits_varlength_column_add_data PROTO((FTable *table, char *data, off_t Ndata, int row, VarLengthColumn *column)); 219 void *gfits_varlength_column_pointer PROTO((FTable *ftable, VarLengthColumn *column, off_t row, off_t *length)); 220 int gfits_varlength_column_define PROTO((FTable *ftable, VarLengthColumn *def, int column)); 221 int gfits_varlength_column_finish PROTO((FTable *ftable, VarLengthColumn *def)); 222 int gfits_byteswap_varlength_column PROTO((FTable *ftable, int column)); 176 223 177 224 /******************************* Table functions *************/ … … 182 229 char *gfits_table_print PROTO((FTable *ftable,...)); 183 230 int gfits_add_rows PROTO((FTable *ftable, char *data, off_t Nrow, off_t Nbytes)); 231 int gfits_set_table_rows PROTO((Header *header, FTable *table, off_t Nrows)); 184 232 int gfits_bintable_format PROTO((char *format, char *type, int *Nval, int *Nbytes)); 185 233 int gfits_create_table PROTO((Header *header, FTable *ftable)); … … 198 246 int gfits_fwrite_ftable_range PROTO((FILE *f, FTable *table, off_t start, off_t Nrows, off_t Ndisk, off_t Ntotal)); 199 247 int gfits_get_bintable_column PROTO((Header *header, FTable *table, char *label, void **data)); 248 int gfits_get_bintable_column_raw PROTO((Header *header, FTable *table, char *label, void **data, char nativeOrder)); 200 249 int gfits_get_bintable_column_type PROTO((Header *header, char *label, char *type, int *Nval)); 250 void *gfits_get_bintable_column_data PROTO((Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol)); 201 251 int gfits_get_bintable_column_type_by_N PROTO((Header *header, int N, char *type, int *Nval)); 202 void *gfits_get_bintable_column_data PROTO((Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol));252 void *gfits_get_bintable_column_data_raw PROTO((Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol, char nativeOrder)); 203 253 int gfits_get_table_column PROTO((Header *header, FTable *table, char *label, void **data)); 204 254 int gfits_get_table_column_type PROTO((Header *header, char *label, char *type)); … … 206 256 int gfits_read_table PROTO((char *filename, FTable *ftable)); 207 257 int gfits_set_bintable_column PROTO((Header *header, FTable *table, char *label, void *data, off_t Nrow)); 208 int gfits_set_bintable_column_reformat PROTO((Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow ));258 int gfits_set_bintable_column_reformat PROTO((Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow, char nativeOrder)); 209 259 int gfits_set_table_column PROTO((Header *header, FTable *table, char *label, void *data, off_t Nrow)); 210 260 int gfits_table_column PROTO((FTable *ftable, char *field, char *mode,...)) OHANA_FORMAT(printf, 3, 4); … … 218 268 int gfits_copy_ftable PROTO((FTable *in, FTable *out)); 219 269 int gfits_copy_vtable PROTO((VTable *in, VTable *out)); 270 int gfits_copy_ftable_ptr PROTO((FTable *in, FTable *out)); 220 271 221 272 int gfits_create_Theader PROTO((Header *header, char *type)); … … 226 277 int gfits_write_Theader PROTO((char *filename, Header *header)); 227 278 228 int gfits_varlength_column_define PROTO((FTable *ftable, VarLengthColumn *def, int column)); 229 void *gfits_varlength_column_pointer PROTO((FTable *ftable, VarLengthColumn *column, off_t row, off_t *length)); 279 int gfits_compress_table PROTO((FTable *srctable, FTable *tgttable, int ztilelen, char *zcmptype)); 280 int gfits_uncompress_table PROTO((FTable *srctable, FTable *tgttable)); 281 282 // XXX EAM for testing 283 int gfits_dump_raw_table (FTable *table, char *message); 284 int gfits_dump_cmp_table (FTable *table, char *message); 285 230 286 231 287 #endif /* FITSIO */ -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/matrix/F_matrix.c
r35164 r38447 2 2 # include <gfitsio.h> 3 3 4 off_t gfits_data_size (Header *header) { 5 6 int i; 7 off_t Nrec, size; 8 9 if (header[0].Naxes == 0) return (0); 10 11 size = abs(header[0].bitpix / 8); 12 13 for (i = 0; i < header[0].Naxes; i++) 14 size *= header[0].Naxis[i]; 15 16 // XXX do I multiply this times gcount? 17 size += header[0].pcount; 18 19 /* round up to next complete block */ 20 if (size % FT_RECORD_SIZE) { 21 Nrec = 1 + (int) (size / FT_RECORD_SIZE); 22 size = FT_RECORD_SIZE * Nrec; 23 } 24 25 return (size); 26 } 27 28 off_t gfits_data_min_size (Header *header) { 4 off_t gfits_heap_start (Header *header) { 29 5 30 6 int i; … … 38 14 size *= header[0].Naxis[i]; 39 15 40 // XXX do I multiply this times gcount? 16 return (size); 17 } 18 19 off_t gfits_data_min_size (Header *header) { 20 21 off_t size = gfits_heap_start (header); 41 22 size += header[0].pcount; 23 24 // XXX what do I do with gcount? 42 25 43 26 return (size); … … 46 29 off_t gfits_data_pad_size (off_t rawsize) { 47 30 48 off_t Nrec, size; 49 50 size = rawsize; 31 off_t size = rawsize; 51 32 52 33 /* round up to next complete block */ 53 34 if (rawsize % FT_RECORD_SIZE) { 54 Nrec = 1 + (int) (rawsize / FT_RECORD_SIZE);35 off_t Nrec = 1 + (int) (rawsize / FT_RECORD_SIZE); 55 36 size = FT_RECORD_SIZE * Nrec; 56 37 } … … 58 39 return (size); 59 40 } 41 42 off_t gfits_data_size (Header *header) { 43 off_t rawsize = gfits_data_min_size(header); 44 off_t size = gfits_data_pad_size (rawsize); 45 46 return (size); 47 } 48 -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/matrix/F_uncompress_data.c
r23815 r38447 26 26 int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); 27 27 28 int gfits_uncompress_data (char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int out_pixsize) { 28 # define ESCAPE(RET) { fprintf (stderr, "gzip error in %s @ %s:%d\n", __func__, __FILE__, __LINE__); return (RET); } 29 30 int gfits_uncompress_data (char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int Nout_alloc, int out_pixsize) { 29 31 30 32 int status; 31 static int Ninsum = 0;32 static int Noutsum = 0;33 33 34 if (!strcasecmp(cmptype, "GZIP_1")) { 35 unsigned long tNout = *Nout * out_pixsize; 34 // do not actually uncompress : this is used for testing 35 if (!strcasecmp(cmptype, "NONE") || !strcasecmp(cmptype, "NONE_1") || !strcasecmp(cmptype, "NONE_2")) { 36 memcpy (outdata, zdata, Nzdata); 37 myAssert (*Nout == Nzdata, "invalid size"); 38 *Nout = Nzdata / out_pixsize; 39 return (TRUE); 40 } 41 42 if (!strcasecmp(cmptype, "GZIP_1") || !strcasecmp(cmptype, "GZIP_2")) { 43 // unsigned long tNout = *Nout * out_pixsize; 44 // input value of *Nout is number of BYTES 45 unsigned long tNout = Nout_alloc; 36 46 37 47 // for GZIP data, I need to check for and remove the header on the first block: 38 gfits_gz_stripheader ((unsigned char *)zdata, &Nzdata); 48 // XXX maybe not anymore 49 // gfits_gz_stripheader ((unsigned char *)zdata, &Nzdata); 39 50 40 51 // uncompress does not require us to know the expected number of pixel; it tells us the number 52 // XXX shouldn't we validate the result : we think we know the size 41 53 status = gfits_uncompress ((Bytef *) outdata, &tNout, (Bytef *) zdata, Nzdata); 42 if (status != Z_OK) { 43 fprintf (stderr, "error in uncompress (GZIP)\n"); 44 return (FALSE); 45 } 54 if (status != Z_OK) ESCAPE(FALSE); 55 myAssert (*Nout == tNout, "uncompressed size mismatch"); 46 56 *Nout = tNout / out_pixsize; 57 // output value of *Nout is number of PIXELS 47 58 48 59 // the resulting uncompressed data is byteswapped 49 if (!gfits_byteswap_zdata (outdata, *Nout, out_pixsize)) return (FALSE);60 // if (!gfits_byteswap_zdata (outdata, *Nout, out_pixsize)) return (FALSE); 50 61 51 62 return (TRUE); 52 63 } 53 64 54 if (!strcasecmp(cmptype, "RICE_1") ) {65 if (!strcasecmp(cmptype, "RICE_1") || !strcasecmp(cmptype, "RICE_ONE")) { 55 66 int i, blocksize; 56 67 // look for the BLOCKSIZE … … 66 77 } 67 78 68 int Npix; 69 // Npix = *Nout * (out_pixsize / 4.0); 70 Npix = *Nout; 71 72 Ninsum += Nzdata; 73 Noutsum += *Nout; 74 // fprintf (stderr, "%d comp bytes; %d uncomp 'pixels', totals: %d %d\n", Nzdata, Npix, Ninsum, Noutsum); 79 int status = FALSE; 80 int Npix = *Nout / out_pixsize; 81 int k; 75 82 76 83 switch (out_pixsize) { 77 84 case 4: 78 85 // rice decompression from the CFITSIO source tree : we need to tell it the expected number of pixels 79 // is also REQUIRES 4byte output, which is fairly stupid. 80 if (fits_rdecomp ((unsigned char *) zdata, Nzdata, (unsigned int *) outdata, Npix, blocksize)) { 81 fprintf (stderr, "error in rice decompression\n"); 82 return (FALSE); 86 status = fits_rdecomp ((unsigned char *) zdata, Nzdata, (unsigned int *) outdata, Npix, blocksize); 87 break; 88 case 2: 89 if (0) { 90 fprintf (stderr, "Nout: %d, Nrawpix: %d\n", Nzdata, Npix); 91 fprintf (stderr, "cmp out: "); 92 for (k = 0; k < Nzdata; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); } 93 fprintf (stderr, "\n"); 83 94 } 84 return (TRUE); 85 86 case 2: 87 if (fits_rdecomp_short ((unsigned char *) zdata, Nzdata, (unsigned short *) outdata, Npix, blocksize)) { 88 fprintf (stderr, "error in rice decompression\n"); 89 return (FALSE); 90 } 91 return (TRUE); 92 95 status = fits_rdecomp_short ((unsigned char *) zdata, Nzdata, (unsigned short *) outdata, Npix, blocksize); 96 break; 93 97 case 1: 94 if (fits_rdecomp_byte ((unsigned char *) zdata, Nzdata, (unsigned char *) outdata, Npix, blocksize)) { 95 fprintf (stderr, "error in rice decompression\n"); 96 return (FALSE); 97 } 98 return (TRUE); 99 98 status = fits_rdecomp_byte ((unsigned char *) zdata, Nzdata, (unsigned char *) outdata, Npix, blocksize); 99 break; 100 100 default: 101 101 fprintf (stderr, "invalid output pixel size %d\n", out_pixsize); 102 return (FALSE); 102 status = FALSE; 103 break; 103 104 } 104 105 if (status) { 106 *Nout = 0; 107 return FALSE; 108 } 109 *Nout = Npix; 110 return TRUE; 105 111 } 106 112 -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/table/F_copy_T.c
r34088 r38447 6 6 7 7 /* find buffer size */ 8 out[0].validsize = in[0].validsize; 9 out[0].datasize = in[0].datasize; 8 out[0].validsize = in[0].validsize; 9 out[0].datasize = in[0].datasize; 10 out[0].heap_start = in[0].heap_start; 10 11 11 12 ALLOCATE (out[0].buffer, char, out[0].datasize); 12 13 memcpy (out[0].buffer, in[0].buffer, out[0].datasize); 14 return (TRUE); 15 } 16 17 /*********************** copy ftable pointers (does not copy memory) ***********************************/ 18 int gfits_copy_ftable_ptr (FTable *in, FTable *out) { 19 20 if (!in) return FALSE; 21 if (!out) return FALSE; 22 23 /* find buffer size */ 24 out[0].validsize = in[0].validsize; 25 out[0].datasize = in[0].datasize; 26 out[0].heap_start = in[0].heap_start; 27 out[0].header = in[0].header; 28 out[0].buffer = in[0].buffer; 13 29 return (TRUE); 14 30 } … … 28 44 29 45 /* find buffer size */ 30 out[0].datasize = in[0].datasize; 31 out[0].pad = in[0].pad; 32 out[0].Nrow = in[0].Nrow; 46 out[0].datasize = in[0].datasize; 47 // out[0].heap_start = in[0].heap_start; 48 out[0].pad = in[0].pad; 49 out[0].Nrow = in[0].Nrow; 33 50 34 51 off_t Nrows = out[0].Nrow; -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/table/F_create_T.c
r35756 r38447 4 4 /*********************** fits init table *******************************/ 5 5 int gfits_init_table (FTable *table) { 6 table[0].header = NULL; 7 table[0].buffer = NULL; 8 table[0].datasize = 0; 9 table[0].validsize = 0; 6 table[0].header = NULL; 7 table[0].buffer = NULL; 8 table[0].datasize = 0; 9 table[0].heap_start = 0; 10 table[0].validsize = 0; 10 11 return (TRUE); 11 12 … … 42 43 } 43 44 table[0].datasize = Nbytes; 45 table[0].heap_start = gfits_heap_start (header); 44 46 return (TRUE); 45 47 48 } 49 50 /*********************** fits create table *******************************/ 51 int gfits_set_table_rows (Header *header, FTable *table, off_t Nrows) { 52 53 header[0].Naxis[1] = Nrows; 54 gfits_modify (header, "NAXIS2", OFF_T_FMT, 1, Nrows); 55 56 off_t Nbytes = gfits_data_size (header); 57 REALLOCATE (table[0].buffer, char, Nbytes); 58 bzero (table[0].buffer, Nbytes); 59 table[0].datasize = Nbytes; 60 table[0].heap_start = gfits_heap_start (header); 61 return (TRUE); 46 62 } 47 63 … … 60 76 Ny = table[0].header[0].Naxis[0]; 61 77 table[0].datasize = gfits_data_size (header); 78 // table[0].heap_start = gfits_heap_start (header); 62 79 table[0].pad = table[0].datasize - Nx*Ny; 63 80 -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/table/F_define_column.c
r35756 r38447 66 66 sprintf (field, "TTYPE%d", Nfields); 67 67 gfits_modify (header, field, "%s", 1, label); 68 gfits_modify_alt (header, field, "%C", 1, comment); 69 sprintf (field, "TUNIT%d", Nfields); 70 gfits_modify (header, field, "%s", 1, unit); 68 if (comment) { 69 gfits_modify_alt (header, field, "%C", 1, comment); 70 } 71 if (unit) { 72 sprintf (field, "TUNIT%d", Nfields); 73 gfits_modify (header, field, "%s", 1, unit); 74 } 71 75 sprintf (field, "TFORM%d", Nfields); 72 76 gfits_modify (header, field, "%s", 1, format); -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/table/F_get_column.c
r37039 r38447 17 17 18 18 void *gfits_get_bintable_column_data (Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol) { 19 void *data = gfits_get_bintable_column_data_raw (header, table, label, type, Nrow, Ncol, FALSE); 20 return data; 21 } 22 23 void *gfits_get_bintable_column_data_raw (Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol, char nativeOrder) { 19 24 20 25 off_t Nx, Ny; … … 71 76 } 72 77 73 /* convert data in-situ with correct type, byte swap and Bzero/Bscale */ 78 // NOTE: we have already copied the data to 'array', so the blocks below 79 // only need to swap if this is a direct copy 74 80 Pin = array; 75 81 Pout = array; 82 int directCopy = (Bzero == 0.0) && (Bscale == 1.0); 83 84 /* convert data in-situ with correct type, byte swap and Bzero/Bscale */ 76 85 if (!strcmp (type, "char")) { 77 86 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 78 *(char *)Pout = *(char *)Pin*Bscale + Bzero;87 if (!directCopy) { *(char *)Pout = *(char *)Pin*Bscale + Bzero; } 79 88 } 80 89 } 81 90 if (!strcmp (type, "byte")) { 82 91 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 83 *(char *)Pout = *(char *)Pin*Bscale + Bzero;92 if (!directCopy) { *(char *)Pout = *(char *)Pin*Bscale + Bzero; } 84 93 } 85 94 } … … 87 96 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 88 97 # ifdef BYTE_SWAP 89 SWAP_BYTE;90 # endif 91 *(short *)Pout = *(short *)Pin*Bscale + Bzero;98 if (!nativeOrder) { SWAP_BYTE; } 99 # endif 100 if (!directCopy) { *(short *)Pout = *(short *)Pin*Bscale + Bzero; } 92 101 } 93 102 } … … 95 104 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 96 105 # ifdef BYTE_SWAP 97 SWAP_WORD;98 # endif 99 *(int *)Pout = *(int *)Pin*Bscale + Bzero;106 if (!nativeOrder) { SWAP_WORD; } 107 # endif 108 if (!directCopy) { *(int *)Pout = *(int *)Pin*Bscale + Bzero; } 100 109 } 101 110 } 102 111 if (!strcmp (type, "int64_t")) { 103 if ((Bzero == 0.0) && (Bscale == 1.0)) { 104 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 105 # ifdef BYTE_SWAP 106 SWAP_DBLE; 107 # endif 108 *(int64_t *)Pout = *(int64_t *)Pin; 109 } 110 } else { 111 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 112 # ifdef BYTE_SWAP 113 SWAP_DBLE; 114 # endif 115 *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; 116 } 112 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 113 # ifdef BYTE_SWAP 114 if (!nativeOrder) { SWAP_DBLE; } 115 # endif 116 if (!directCopy) { *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; } 117 117 } 118 118 } … … 120 120 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 121 121 # ifdef BYTE_SWAP 122 SWAP_WORD;123 # endif 124 *(float *)Pout = *(float *)Pin*Bscale + Bzero;122 if (!nativeOrder) { SWAP_WORD; } 123 # endif 124 if (!directCopy) { *(float *)Pout = *(float *)Pin*Bscale + Bzero; } 125 125 } 126 126 } … … 128 128 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 129 129 # ifdef BYTE_SWAP 130 SWAP_DBLE; 131 # endif 132 *(double *)Pout = *(double *)Pin*Bscale + Bzero; 133 } 134 } 130 if (!nativeOrder) { SWAP_DBLE; } 131 # endif 132 if (!directCopy) { *(double *)Pout = *(double *)Pin*Bscale + Bzero; } 133 } 134 } 135 136 // check that we supplied a valid type 135 137 136 138 *Ncol = Nval; … … 174 176 if (!gfits_get_bintable_column_type_by_N (header, N, type, Nval)) return FALSE; 175 177 return (TRUE); 178 } 179 180 /***********************/ 181 int gfits_get_bintable_column_raw (Header *header, FTable *table, char *label, void **data, char nativeOrder) { 182 183 char type[16]; 184 off_t Nrow; 185 int Ncol; 186 187 char *array = gfits_get_bintable_column_data_raw (header, table, label, type, &Nrow, &Ncol, nativeOrder); 188 if (array == NULL) return (FALSE); 189 190 *data = array; 191 return TRUE; 176 192 } 177 193 -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/table/F_read_T.c
r37807 r38447 45 45 if (Nread < gfits_data_min_size (table[0].header)) { 46 46 fprintf (stderr, "error: fits read error in %s, read "OFF_T_FMT", need "OFF_T_FMT"\n", __func__, Nread, gfits_data_min_size (table[0].header)); 47 if (padIfShort) { 48 memset (&table[0].buffer[Nread], 0, Nbytes - Nread); 49 fprintf (stderr, "warning: file missing data, padding with zeros: USE AT YOUR OWN RISK!\n"); 50 table[0].validsize = Nread; 51 table[0].datasize = Nbytes; 52 return (TRUE); 53 } else { 54 gfits_free_table (table); 47 if (!padIfShort) { 48 gfits_free_table (table); 55 49 return (FALSE); 56 50 } 57 } 58 fprintf (stderr, "warning: file missing pad\n"); 51 memset (&table[0].buffer[Nread], 0, Nbytes - Nread); 52 fprintf (stderr, "warning: file missing data, padding with zeros: USE AT YOUR OWN RISK!\n"); 53 } else { 54 fprintf (stderr, "warning: file missing pad\n"); 55 } 59 56 } 60 57 table[0].validsize = Nread; 61 58 table[0].datasize = Nbytes; 59 table[0].heap_start = gfits_heap_start (table->header); 62 60 return (TRUE); 63 61 } … … 93 91 } 94 92 fprintf (stderr, "error: fits read error in %s, read "OFF_T_FMT", need "OFF_T_FMT"\n", __func__, Nread, Nbytes); 95 if (padIfShort) { 96 memset (&table[0].buffer[Nread], 0, Nbytes - Nread); 97 fprintf (stderr, "warning: file missing data, padding with zeros: USE AT YOUR OWN RISK!\n"); 98 table[0].validsize = Nread; 99 table[0].datasize = Nbytes; 100 } else { 93 if (!padIfShort) { 101 94 free (table[0].buffer); 102 95 return (FALSE); 103 96 } 97 memset (&table[0].buffer[Nread], 0, Nbytes - Nread); 98 fprintf (stderr, "warning: file missing data, padding with zeros: USE AT YOUR OWN RISK!\n"); 104 99 } 105 100 … … 107 102 table[0].header[0].Naxis[1] = Nrows; 108 103 gfits_modify (table[0].header, "NAXIS2", OFF_T_FMT, 1, Nrows); 109 table[0].datasize = gfits_data_size (table[0].header); 104 table[0].validsize = Nread; 105 table[0].datasize = Nbytes; 106 table[0].heap_start = gfits_heap_start (table->header); 110 107 111 108 return (TRUE); … … 122 119 Ny = table[0].header[0].Naxis[1]; 123 120 table[0].datasize = gfits_data_size (table[0].header); 121 // table[0].heap_start = gfits_heap_start (table[0].header); 124 122 table[0].pad = table[0].datasize - Nx*Ny; 125 123 … … 206 204 for (i = 0; i < Nrow; i++) table[0].row[i] = row[i]; 207 205 table[0].datasize = gfits_data_size (table[0].header); 206 // table[0].heap_start = gfits_heap_start (table[0].header); 208 207 table[0].pad = table[0].datasize - Nx*Ny; 209 208 return (TRUE); -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/table/F_set_column.c
r37039 r38447 1 1 # include <ohana.h> 2 2 # include <gfitsio.h> 3 4 # define SWAP_NONE 5 6 # ifdef BYTE_SWAP 3 7 # define SWAP_BYTE { \ 4 8 char tmp; \ … … 14 18 tmp = Pout[2]; Pout[2] = Pout[5]; Pout[5] = tmp; \ 15 19 tmp = Pout[3]; Pout[3] = Pout[4]; Pout[4] = tmp; } 20 # else 21 # define SWAP_BYTE 22 # define SWAP_WORD 23 # define SWAP_DBLE 24 # endif 16 25 17 26 /***********************/ 18 27 int gfits_set_bintable_column (Header *header, FTable *table, char *label, void *data, off_t Nrow) { 19 28 20 off_t Nx, Ny , nbytes;29 off_t Nx, Ny; 21 30 int i, N, Nfields; 22 31 int Nval, Nbytes, Nstart, Nv, Nb; … … 55 64 gfits_scan (header, "NAXIS1", OFF_T_FMT, 1, &Nx); 56 65 gfits_scan (header, "NAXIS2", OFF_T_FMT, 1, &Ny); 66 67 // if no rows have yet been assigned, we need to allocate the full data buffer 57 68 if (Ny == 0) { 58 69 Ny = Nrow; 59 header[0].Naxis[1] = Ny; 60 gfits_modify (header, "NAXIS2", OFF_T_FMT, 1, Ny); 61 62 nbytes = gfits_data_size (header); 63 REALLOCATE (table[0].buffer, char, MAX (nbytes, 1)); 64 bzero (table[0].buffer, nbytes); 65 table[0].datasize = nbytes; 70 gfits_set_table_rows (header, table, Ny); 66 71 } 67 72 if (Ny != Nrow) return (FALSE); … … 143 148 } 144 149 150 if (!strcmp (type, "var")) { 151 for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) { 152 *(int *)Pout = *(int *)Pin; 153 # ifdef BYTE_SWAP 154 SWAP_WORD; 155 # endif 156 } 157 } 158 159 if (!strcmp (type, "var64")) { 160 for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) { 161 *(int *)Pout = *(int *)Pin; 162 # ifdef BYTE_SWAP 163 SWAP_DBLE; 164 # endif 165 } 166 } 167 145 168 /* check array space */ 146 169 if (Nx*Ny < Nx*(Nrow - 1) + Nstart + Nval*Nbytes) { … … 161 184 162 185 /***********************/ 163 int gfits_set_bintable_column_reformat (Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow) { 164 165 off_t Nx, Ny, nbytes; 186 // convert the input data array (of the specified intype) to the desired table data type. swap unless nativeOrder is requested 187 int gfits_set_bintable_column_reformat (Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow, char nativeOrder) { 188 189 off_t Nx, Ny; 166 190 int i, N, Nfields; 167 191 int Nval, NbytesOut, Nstart, Nv, Nb; … … 202 226 if (Ny == 0) { 203 227 Ny = Nrow; 204 header[0].Naxis[1] = Ny; 205 gfits_modify (header, "NAXIS2", OFF_T_FMT, 1, Ny); 206 207 nbytes = gfits_data_size (header); 208 REALLOCATE (table[0].buffer, char, MAX (nbytes, 1)); 209 bzero (table[0].buffer, nbytes); 210 table[0].datasize = nbytes; 228 gfits_set_table_rows (header, table, Ny); 211 229 } 212 230 if (Ny != Nrow) return (FALSE); … … 230 248 // if (!strcmp (intype, #ITYPE)) { 231 249 250 int directCopy = (Bzero == 0.0) && (Bscale == 1.0); 251 252 # define SET_VALUES(OUTNAME, OUTTYPE, INNAME, INTYPE, SWAP_OP, NBYTES_IN) \ 253 if (!strcmp (outtype, OUTNAME) && !strcmp (intype, INNAME)) { \ 254 int NbytesIn = NBYTES_IN; \ 255 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { \ 256 if (directCopy) { \ 257 *(OUTTYPE *)Pout = *(INTYPE *)Pin; \ 258 } else { \ 259 *(OUTTYPE *)Pout = (*(INTYPE *)Pin - Bzero) / Bscale; \ 260 } \ 261 if (!nativeOrder) { SWAP_OP; }}} 262 263 SET_VALUES("char", char, "char", char, SWAP_NONE, 1); 264 SET_VALUES("byte", char, "char", char, SWAP_NONE, 1); 265 SET_VALUES("short", short, "char", char, SWAP_BYTE, 1); 266 SET_VALUES("int", int, "char", char, SWAP_WORD, 1); 267 SET_VALUES("int64_t", int64_t, "char", char, SWAP_DBLE, 1); 268 SET_VALUES("float", float, "char", char, SWAP_WORD, 1); 269 SET_VALUES("double", double, "char", char, SWAP_DBLE, 1); 270 271 SET_VALUES("char", char, "byte", char, SWAP_NONE, 1); 272 SET_VALUES("byte", char, "byte", char, SWAP_NONE, 1); 273 SET_VALUES("short", short, "byte", char, SWAP_BYTE, 1); 274 SET_VALUES("int", int, "byte", char, SWAP_WORD, 1); 275 SET_VALUES("int64_t", int64_t, "byte", char, SWAP_DBLE, 1); 276 SET_VALUES("float", float, "byte", char, SWAP_WORD, 1); 277 SET_VALUES("double", double, "byte", char, SWAP_DBLE, 1); 278 279 SET_VALUES("char", char, "short", short, SWAP_NONE, 2); 280 SET_VALUES("byte", char, "short", short, SWAP_NONE, 2); 281 SET_VALUES("short", short, "short", short, SWAP_BYTE, 2); 282 SET_VALUES("int", int, "short", short, SWAP_WORD, 2); 283 SET_VALUES("int64_t", int64_t, "short", short, SWAP_DBLE, 2); 284 SET_VALUES("float", float, "short", short, SWAP_WORD, 2); 285 SET_VALUES("double", double, "short", short, SWAP_DBLE, 2); 286 287 SET_VALUES("char", char, "int", int, SWAP_NONE, 4); 288 SET_VALUES("byte", char, "int", int, SWAP_NONE, 4); 289 SET_VALUES("short", short, "int", int, SWAP_BYTE, 4); 290 SET_VALUES("int", int, "int", int, SWAP_WORD, 4); 291 SET_VALUES("int64_t", int64_t, "int", int, SWAP_DBLE, 4); 292 SET_VALUES("float", float, "int", int, SWAP_WORD, 4); 293 SET_VALUES("double", double, "int", int, SWAP_DBLE, 4); 294 295 SET_VALUES("char", char, "int64_t", int64_t, SWAP_NONE, 8); 296 SET_VALUES("byte", char, "int64_t", int64_t, SWAP_NONE, 8); 297 SET_VALUES("short", short, "int64_t", int64_t, SWAP_BYTE, 8); 298 SET_VALUES("int", int, "int64_t", int64_t, SWAP_WORD, 8); 299 SET_VALUES("int64_t", int64_t, "int64_t", int64_t, SWAP_DBLE, 8); 300 SET_VALUES("float", float, "int64_t", int64_t, SWAP_WORD, 8); 301 SET_VALUES("double", double, "int64_t", int64_t, SWAP_DBLE, 8); 302 303 SET_VALUES("char", char, "float", float, SWAP_NONE, 4); 304 SET_VALUES("byte", char, "float", float, SWAP_NONE, 4); 305 SET_VALUES("short", short, "float", float, SWAP_BYTE, 4); 306 SET_VALUES("int", int, "float", float, SWAP_WORD, 4); 307 SET_VALUES("int64_t", int64_t, "float", float, SWAP_DBLE, 4); 308 SET_VALUES("float", float, "float", float, SWAP_WORD, 4); 309 SET_VALUES("double", double, "float", float, SWAP_DBLE, 4); 310 311 SET_VALUES("char", char, "double", double, SWAP_NONE, 8); 312 SET_VALUES("byte", char, "double", double, SWAP_NONE, 8); 313 SET_VALUES("short", short, "double", double, SWAP_BYTE, 8); 314 SET_VALUES("int", int, "double", double, SWAP_WORD, 8); 315 SET_VALUES("int64_t", int64_t, "double", double, SWAP_DBLE, 8); 316 SET_VALUES("float", float, "double", double, SWAP_WORD, 8); 317 SET_VALUES("double", double, "double", double, SWAP_DBLE, 8); 318 319 # if (0) 232 320 /** input == char **/ 233 321 if (!strcmp (outtype, "char") && !strcmp (intype, "char")) { 234 322 int NbytesIn = 1; 235 323 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) { 236 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 324 if (directCopy) { *(char *)Pout = *(char *)Pin; } else { 325 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 326 } 237 327 } 238 328 } 239 329 if (!strcmp (outtype, "byte") && !strcmp (intype, "char")) { 330 int NbytesIn = 1; 331 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) { 332 if (directCopy) { *(char *)Pout = *(char *)Pin; } else { 333 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 334 } 335 } 336 } 337 if (!strcmp (outtype, "short") && !strcmp (intype, "char")) { 338 int NbytesIn = 1; 339 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 340 if (directCopy) { *(short *)Pout = *(char *)Pin; } else { 341 *(short *)Pout = (*(char *)Pin - Bzero) / Bscale; 342 } 343 # ifdef BYTE_SWAP 344 if (!nativeOrder) { SWAP_BYTE; } 345 # endif 346 } 347 } 348 if (!strcmp (outtype, "int") && !strcmp (intype, "char")) { 349 int NbytesIn = 1; 350 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 351 *(int *)Pout = (*(char *)Pin - Bzero) / Bscale; 352 # ifdef BYTE_SWAP 353 if (!nativeOrder) { SWAP_WORD; } 354 # endif 355 } 356 } 357 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "char")) { 358 int NbytesIn = 1; 359 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 360 *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale; 361 # ifdef BYTE_SWAP 362 if (!nativeOrder) { SWAP_DBLE; } 363 # endif 364 } 365 } 366 if (!strcmp (outtype, "float") && !strcmp (intype, "char")) { 367 int NbytesIn = 1; 368 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 369 *(float *)Pout = (*(char *)Pin - Bzero) / Bscale; 370 # ifdef BYTE_SWAP 371 if (!nativeOrder) { SWAP_WORD; } 372 # endif 373 } 374 } 375 if (!strcmp (outtype, "double") && !strcmp (intype, "char")) { 376 int NbytesIn = 1; 377 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 378 *(double *)Pout = (*(char *)Pin - Bzero) / Bscale; 379 # ifdef BYTE_SWAP 380 if (!nativeOrder) { SWAP_DBLE; } 381 # endif 382 } 383 } 384 385 /** input == byte **/ 386 if (!strcmp (outtype, "char") && !strcmp (intype, "byte")) { 240 387 int NbytesIn = 1; 241 388 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) { … … 243 390 } 244 391 } 245 if (!strcmp (outtype, "short") && !strcmp (intype, "char")) { 246 int NbytesIn = 1; 247 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 248 *(short *)Pout = (*(char *)Pin - Bzero) / Bscale; 249 # ifdef BYTE_SWAP 250 SWAP_BYTE; 251 # endif 252 } 253 } 254 if (!strcmp (outtype, "int") && !strcmp (intype, "char")) { 255 int NbytesIn = 1; 256 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 257 *(int *)Pout = (*(char *)Pin - Bzero) / Bscale; 258 # ifdef BYTE_SWAP 259 SWAP_WORD; 260 # endif 261 } 262 } 263 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "char")) { 264 int NbytesIn = 1; 265 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 266 *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale; 267 # ifdef BYTE_SWAP 268 SWAP_DBLE; 269 # endif 270 } 271 } 272 if (!strcmp (outtype, "float") && !strcmp (intype, "char")) { 273 int NbytesIn = 1; 274 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 275 *(float *)Pout = (*(char *)Pin - Bzero) / Bscale; 276 # ifdef BYTE_SWAP 277 SWAP_WORD; 278 # endif 279 } 280 } 281 if (!strcmp (outtype, "double") && !strcmp (intype, "char")) { 282 int NbytesIn = 1; 283 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 284 *(double *)Pout = (*(char *)Pin - Bzero) / Bscale; 285 # ifdef BYTE_SWAP 286 SWAP_DBLE; 287 # endif 288 } 289 } 290 291 /** input == byte **/ 292 if (!strcmp (outtype, "char") && !strcmp (intype, "byte")) { 392 if (!strcmp (outtype, "byte") && !strcmp (intype, "byte")) { 293 393 int NbytesIn = 1; 294 394 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) { … … 296 396 } 297 397 } 298 if (!strcmp (outtype, "byte") && !strcmp (intype, "byte")) {299 int NbytesIn = 1;300 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) {301 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale;302 }303 }304 398 if (!strcmp (outtype, "short") && !strcmp (intype, "byte")) { 305 399 int NbytesIn = 1; … … 307 401 *(short *)Pout = (*(char *)Pin - Bzero) / Bscale; 308 402 # ifdef BYTE_SWAP 309 SWAP_BYTE;403 if (!nativeOrder) { SWAP_BYTE; } 310 404 # endif 311 405 } … … 316 410 *(int *)Pout = (*(char *)Pin - Bzero) / Bscale; 317 411 # ifdef BYTE_SWAP 318 SWAP_WORD;412 if (!nativeOrder) { SWAP_WORD; } 319 413 # endif 320 414 } … … 325 419 *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale; 326 420 # ifdef BYTE_SWAP 327 SWAP_DBLE;421 if (!nativeOrder) { SWAP_DBLE; } 328 422 # endif 329 423 } … … 334 428 *(float *)Pout = (*(char *)Pin - Bzero) / Bscale; 335 429 # ifdef BYTE_SWAP 336 SWAP_WORD;430 if (!nativeOrder) { SWAP_WORD; } 337 431 # endif 338 432 } … … 343 437 *(double *)Pout = (*(char *)Pin - Bzero) / Bscale; 344 438 # ifdef BYTE_SWAP 345 SWAP_DBLE;439 if (!nativeOrder) { SWAP_DBLE; } 346 440 # endif 347 441 } … … 366 460 *(short *)Pout = (*(short *)Pin - Bzero) / Bscale; 367 461 # ifdef BYTE_SWAP 368 SWAP_BYTE;462 if (!nativeOrder) { SWAP_BYTE; } 369 463 # endif 370 464 } … … 375 469 *(int *)Pout = (*(short *)Pin - Bzero) / Bscale; 376 470 # ifdef BYTE_SWAP 377 SWAP_WORD;471 if (!nativeOrder) { SWAP_WORD; } 378 472 # endif 379 473 } … … 384 478 *(int64_t *)Pout = (*(short *)Pin - Bzero) / Bscale; 385 479 # ifdef BYTE_SWAP 386 SWAP_DBLE;480 if (!nativeOrder) { SWAP_DBLE; } 387 481 # endif 388 482 } … … 393 487 *(float *)Pout = (*(short *)Pin - Bzero) / Bscale; 394 488 # ifdef BYTE_SWAP 395 SWAP_WORD;489 if (!nativeOrder) { SWAP_WORD; } 396 490 # endif 397 491 } … … 402 496 *(double *)Pout = (*(short *)Pin - Bzero) / Bscale; 403 497 # ifdef BYTE_SWAP 404 SWAP_DBLE;498 if (!nativeOrder) { SWAP_DBLE; } 405 499 # endif 406 500 } … … 425 519 *(short *)Pout = (*(int *)Pin - Bzero) / Bscale; 426 520 # ifdef BYTE_SWAP 427 SWAP_BYTE;521 if (!nativeOrder) { SWAP_BYTE; } 428 522 # endif 429 523 } … … 434 528 *(int *)Pout = (*(int *)Pin - Bzero) / Bscale; 435 529 # ifdef BYTE_SWAP 436 SWAP_WORD;530 if (!nativeOrder) { SWAP_WORD; } 437 531 # endif 438 532 } … … 443 537 *(int64_t *)Pout = (*(int *)Pin - Bzero) / Bscale; 444 538 # ifdef BYTE_SWAP 445 SWAP_DBLE;539 if (!nativeOrder) { SWAP_DBLE; } 446 540 # endif 447 541 } … … 452 546 *(float *)Pout = (*(int *)Pin - Bzero) / Bscale; 453 547 # ifdef BYTE_SWAP 454 SWAP_WORD;548 if (!nativeOrder) { SWAP_WORD; } 455 549 # endif 456 550 } … … 461 555 *(double *)Pout = (*(int *)Pin - Bzero) / Bscale; 462 556 # ifdef BYTE_SWAP 463 SWAP_DBLE;557 if (!nativeOrder) { SWAP_DBLE; } 464 558 # endif 465 559 } … … 484 578 *(short *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 485 579 # ifdef BYTE_SWAP 486 SWAP_BYTE;580 if (!nativeOrder) { SWAP_BYTE; } 487 581 # endif 488 582 } … … 493 587 *(int *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 494 588 # ifdef BYTE_SWAP 495 SWAP_WORD;589 if (!nativeOrder) { SWAP_WORD; } 496 590 # endif 497 591 } … … 502 596 *(int64_t *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 503 597 # ifdef BYTE_SWAP 504 SWAP_DBLE;598 if (!nativeOrder) { SWAP_DBLE; } 505 599 # endif 506 600 } … … 511 605 *(float *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 512 606 # ifdef BYTE_SWAP 513 SWAP_WORD;607 if (!nativeOrder) { SWAP_WORD; } 514 608 # endif 515 609 } … … 520 614 *(double *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 521 615 # ifdef BYTE_SWAP 522 SWAP_DBLE;616 if (!nativeOrder) { SWAP_DBLE; } 523 617 # endif 524 618 } … … 543 637 *(short *)Pout = (*(float *)Pin - Bzero) / Bscale; 544 638 # ifdef BYTE_SWAP 545 SWAP_BYTE;639 if (!nativeOrder) { SWAP_BYTE; } 546 640 # endif 547 641 } … … 552 646 *(int *)Pout = (*(float *)Pin - Bzero) / Bscale; 553 647 # ifdef BYTE_SWAP 554 SWAP_WORD;648 if (!nativeOrder) { SWAP_WORD; } 555 649 # endif 556 650 } … … 561 655 *(int64_t *)Pout = (*(float *)Pin - Bzero) / Bscale; 562 656 # ifdef BYTE_SWAP 563 SWAP_DBLE;657 if (!nativeOrder) { SWAP_DBLE; } 564 658 # endif 565 659 } … … 570 664 *(float *)Pout = (*(float *)Pin - Bzero) / Bscale; 571 665 # ifdef BYTE_SWAP 572 SWAP_WORD;666 if (!nativeOrder) { SWAP_WORD; } 573 667 # endif 574 668 } … … 579 673 *(double *)Pout = (*(float *)Pin - Bzero) / Bscale; 580 674 # ifdef BYTE_SWAP 581 SWAP_DBLE;675 if (!nativeOrder) { SWAP_DBLE; } 582 676 # endif 583 677 } … … 602 696 *(short *)Pout = (*(double *)Pin - Bzero) / Bscale; 603 697 # ifdef BYTE_SWAP 604 SWAP_BYTE;698 if (!nativeOrder) { SWAP_BYTE; } 605 699 # endif 606 700 } … … 611 705 *(int *)Pout = (*(double *)Pin - Bzero) / Bscale; 612 706 # ifdef BYTE_SWAP 613 SWAP_WORD;707 if (!nativeOrder) { SWAP_WORD; } 614 708 # endif 615 709 } … … 620 714 *(int64_t *)Pout = (*(double *)Pin - Bzero) / Bscale; 621 715 # ifdef BYTE_SWAP 622 SWAP_DBLE;716 if (!nativeOrder) { SWAP_DBLE; } 623 717 # endif 624 718 } … … 629 723 *(float *)Pout = (*(double *)Pin - Bzero) / Bscale; 630 724 # ifdef BYTE_SWAP 631 SWAP_WORD;725 if (!nativeOrder) { SWAP_WORD; } 632 726 # endif 633 727 } … … 638 732 *(double *)Pout = (*(double *)Pin - Bzero) / Bscale; 639 733 # ifdef BYTE_SWAP 640 SWAP_DBLE; 641 # endif 642 } 643 } 734 if (!nativeOrder) { SWAP_DBLE; } 735 # endif 736 } 737 } 738 # endif 644 739 645 740 /* check array space */ … … 683 778 int gfits_set_table_column (Header *header, FTable *table, char *label, void *data, off_t Nrow) { 684 779 685 off_t Nx, Ny , nbytes;780 off_t Nx, Ny; 686 781 int i, N, Nfields, Nval, Nbytes, Nstart, Nv, Nb; 687 782 char tlabel[80], field[80], format[80], cformat[80], type[16], tmp[16]; … … 713 808 if (Ny == 0) { 714 809 Ny = Nrow; 715 header[0].Naxis[1] = Ny; 716 gfits_modify (header, "NAXIS2", OFF_T_FMT, 1, Ny); 717 718 nbytes = gfits_data_size (header); 719 REALLOCATE (table[0].buffer, char, MAX (nbytes, 1)); 720 bzero (table[0].buffer, nbytes); 721 table[0].datasize = nbytes; 810 gfits_set_table_rows (header, table, Ny); 722 811 } 723 812 if (Ny != Nrow) return (FALSE); -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/table/F_table_format.c
r37039 r38447 8 8 int gfits_bintable_format (char *format, char *type, int *Nval, int *Nbytes) { 9 9 10 char *Lchar, *Fchar; 11 int Nv; 12 13 if (format == (char *) NULL) return (FALSE); 14 if (format[0] == 0) return (FALSE); 15 Lchar = &format[strlen(format) - 1]; 16 17 Nv = strtol (format, &Fchar, 10); 18 if (Fchar != Lchar) return (FALSE); 10 char *Fchar; 11 12 if (format == (char *) NULL) return (FALSE); // format must be defined 13 if (format[0] == 0) return (FALSE); // format must not be empty string 14 // char *Lchar = &format[strlen(format) - 1]; // last-char pointer 15 16 int Nv = strtol (format, &Fchar, 10); // Fchar points at end of leading number 17 // if (Fchar != Lchar) return (FALSE); -- this test is invalid for eg 1PB(nn) 19 18 if ((Nv == 0) && (Fchar == format)) Nv = 1; 20 19 … … 51 50 { *Nbytes = 8; strcpy (type, "double"); *Nval = Nv; } 52 51 break; 53 case 'P':54 { *Nbytes = 8; strcpy (type, "var"); *Nval = 2*Nv; }55 break;56 52 case 'C': 57 53 { *Nbytes = 8; strcpy (type, "float"); *Nval = 2*Nv; } … … 59 55 case 'M': 60 56 { *Nbytes = 16; strcpy (type, "double"); *Nval = 2*Nv; } 57 break; 58 case 'P': 59 { *Nbytes = 4; strcpy (type, "var"); *Nval = 2*Nv; } 60 break; 61 case 'Q': 62 { *Nbytes = 8; strcpy (type, "var64"); *Nval = 2*Nv; } 61 63 break; 62 64 default: … … 80 82 C - complex float 81 83 M - complex double 82 P - var length array descrpt (64 bit) 84 P - var length array descrpt (32 bit pointer) 85 Q - var length array descrpt (64 bit pointer) 83 86 84 87 all can be preceeded by integer N which specified number 85 88 of entries in array 86 87 89 */ 88 90 -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/table/F_table_row.c
r28241 r38447 28 28 REALLOCATE (table[0].buffer, char, MAX (nbytes, 1)); 29 29 table[0].datasize = nbytes; 30 table[0].heap_start = gfits_heap_start (header); 30 31 31 32 memcpy (&table[0].buffer[Nstart], data, Nbytes*Nrow); … … 67 68 68 69 table[0].datasize = gfits_data_size (table[0].header); 70 // table[0].heap_start = gfits_heap_start (header); 69 71 table[0].pad = table[0].datasize - Nx*Ny; 70 72 … … 102 104 REALLOCATE (table[0].buffer, char, MAX (nbytes, 1)); 103 105 table[0].datasize = nbytes; 106 table[0].heap_start = gfits_heap_start (header); 104 107 return (TRUE); 105 108 } -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/table/F_table_varlength.c
r28241 r38447 2 2 # include <gfitsio.h> 3 3 4 // fills the column definition structure for a specific column based on a given table. 4 5 int gfits_varlength_column_define (FTable *ftable, VarLengthColumn *def, int column) { 5 6 … … 14 15 snprintf (field, 80, "TFORM%d", column); 15 16 if (!gfits_scan (ftable->header, field, "%s", 1, format)) return (FALSE); 17 18 def->column = column; 16 19 17 20 // find and remove the max field length element … … 48 51 if (*p1 == 'I') { def->nbytes = 2; def->format = *p1; } 49 52 if (*p1 == 'J') { def->nbytes = 4; def->format = *p1; } 53 if (*p1 == 'K') { def->nbytes = 8; def->format = *p1; } 50 54 if (*p1 == 'E') { def->nbytes = 4; def->format = *p1; } 51 55 if (*p1 == 'D') { def->nbytes = 8; def->format = *p1; } … … 54 58 if (!def->nbytes) { return (FALSE); } 55 59 56 /* scan columns to find column offset */57 def-> Nstart = 0;60 /* scan columns to find column offset for metadata column*/ 61 def->offset = 0; 58 62 for (i = 1; i < column; i++) { 59 63 sprintf (field, "TFORM%d", i); 60 64 gfits_scan (ftable->header, field, "%s", 1, format); 61 65 gfits_bintable_format (format, tmpline, &Nv, &Nb); 62 def-> Nstart += Nv*Nb;66 def->offset += Nv*Nb; 63 67 } 64 68 65 69 // heap_start must be long long so file may be very large 66 if (!gfits_scan (ftable->header, "THEAP", OFF_T_FMT, 1, &def->heap_start)) { 67 def->heap_start = ftable->header->Naxis[0]*ftable->header->Naxis[1]; 68 } 69 70 // confirm that ftable->heap_start is correctly set? 71 72 return TRUE; 73 } 74 75 # define SWAP_WORD \ 76 tmp = pchar[0]; pchar[0] = pchar[3]; pchar[3] = tmp; \ 77 tmp = pchar[1]; pchar[1] = pchar[2]; pchar[2] = tmp; 78 79 # define SWAP_DBLE \ 80 tmp = pchar[0]; pchar[0] = pchar[7]; pchar[7] = tmp; \ 81 tmp = pchar[1]; pchar[1] = pchar[6]; pchar[6] = tmp; \ 82 tmp = pchar[2]; pchar[2] = pchar[5]; pchar[5] = tmp; \ 83 tmp = pchar[3]; pchar[3] = pchar[4]; pchar[4] = tmp; 84 85 int gfits_byteswap_varlength_column (FTable *ftable, int column) { 86 87 # ifdef BYTE_SWAP 88 VarLengthColumn zdef; 89 if (!gfits_varlength_column_define (ftable, &zdef, column)) return FALSE; 90 91 char *bufstart = &ftable->buffer[zdef.offset]; 92 93 int i; 94 char *pchar, tmp; 95 96 off_t Nx = ftable->header->Naxis[0]; 97 98 for (i = 0; i < ftable->header->Naxis[1]; i++) { 99 if (zdef.mode == 'P') { 100 pchar = &bufstart[i*Nx]; 101 SWAP_WORD; 102 pchar = &bufstart[i*Nx + 4]; 103 SWAP_WORD; 104 } 105 if (zdef.mode == 'Q') { 106 char *pchar, tmp; 107 pchar = &bufstart[i*Nx]; 108 SWAP_DBLE; 109 pchar = &bufstart[i*Nx + 8]; 110 SWAP_DBLE; 111 } 112 } 113 # endif 70 114 return TRUE; 71 115 } … … 75 119 void *gfits_varlength_column_pointer (FTable *ftable, VarLengthColumn *column, off_t row, off_t *length) { 76 120 77 void *result;78 off_t offset, Nx;79 80 121 if ((column->mode != 'P') && (column->mode != 'Q')) abort(); 81 122 82 123 // find the values for the specified row 83 124 // the values in the main table for this row and varlength column: 84 Nx = ftable->header->Naxis[0]; 85 86 # define SWAP_WORD \ 87 tmp = pchar[0]; pchar[0] = pchar[3]; pchar[3] = tmp; \ 88 tmp = pchar[1]; pchar[1] = pchar[2]; pchar[2] = tmp; 89 90 # ifdef BYTE_SWAP 91 char *pchar, tmp; 92 pchar = &ftable->buffer[row*Nx + column->Nstart]; 93 SWAP_WORD; 94 pchar = &ftable->buffer[row*Nx + column->Nstart + 4]; 95 SWAP_WORD; 96 # endif 125 off_t Nx = ftable->header->Naxis[0]; 126 off_t offset = 0; 97 127 98 128 if (column->mode == 'P') { 99 129 int *ptr; 100 ptr = (int *) &ftable->buffer[row*Nx + column-> Nstart];130 ptr = (int *) &ftable->buffer[row*Nx + column->offset]; 101 131 *length = ptr[0]; 102 132 offset = ptr[1]; 103 } else if (column->mode == 'Q') { 133 } 134 if (column->mode == 'Q') { 104 135 off_t *ptr; 105 ptr = (off_t *) &ftable->buffer[row*Nx + column-> Nstart];136 ptr = (off_t *) &ftable->buffer[row*Nx + column->offset]; 106 137 *length = ptr[0]; 107 138 offset = ptr[1]; 108 } else { 109 // this was actually trapped above 110 abort(); 111 } 112 113 result = (void *) (ftable->buffer + column->heap_start + offset); 139 } 140 141 // fprintf (stderr, "length: %d, offset: %d\n", (int) *length, (int) offset); 142 143 void *result = (void *) (ftable->buffer + ftable->heap_start + offset); 114 144 return result; 115 145 } 146 147 // to generate a compressed image or a compressed table, we need to be able to add data 148 // for varlength columns to the heap. To start, assume we have defined the cartesian 149 // portion of the table correctly, and are only extending the heap. 150 151 int gfits_varlength_column_add_data (FTable *table, char *data, off_t Ndata, int row, VarLengthColumn *column) { 152 153 // find the current starting point for new data (end of current buffer main data + current heap 154 off_t heap_offset = gfits_data_min_size (table->header); 155 156 // extend the buffer size to add the new data 157 off_t Nbytes = gfits_data_pad_size (heap_offset + Ndata); 158 REALLOCATE (table->buffer, char, Nbytes); 159 160 char *heap_ptr = table->buffer + heap_offset; 161 162 // add the new data to the table buffer 163 memcpy (heap_ptr, data, Ndata); 164 165 // *** now we add the data description to the table *** 166 167 if ((column->mode != 'P') && (column->mode != 'Q')) abort(); 168 169 // find the cell for the specified row & column 170 // the values in the main table for this row and varlength column: 171 int Nx = table->header->Naxis[0]; 172 173 // set the cell values 174 if (column->mode == 'P') { 175 int *ptr; 176 ptr = (int *) &table->buffer[row*Nx + column->offset]; 177 ptr[0] = Ndata; 178 ptr[1] = heap_offset - table->heap_start; 179 } 180 if (column->mode == 'Q') { 181 off_t *ptr; 182 ptr = (off_t *) &table->buffer[row*Nx + column->offset]; 183 ptr[0] = Ndata; 184 ptr[1] = heap_offset - table->heap_start; 185 } 186 187 // update maxlen 188 // fprintf (stderr, "row: %d, Ndata: %d, maxlen: %d\n", (int) row, (int) Ndata, (int) column->maxlen); 189 column->maxlen = MAX (column->maxlen, Ndata); 190 191 off_t pcount; 192 gfits_scan (table->header, "PCOUNT", OFF_T_FMT, 1, &pcount); 193 194 pcount += Ndata; 195 gfits_modify (table->header, "PCOUNT", OFF_T_FMT, 1, pcount); 196 table->header->pcount = pcount; 197 table->datasize = gfits_data_size (table->header); 198 myAssert (table->datasize == Nbytes, "inconsistent header and data"); 199 200 return TRUE; 201 } 202 203 // update the header TFORM value for this entry 204 int gfits_varlength_column_finish (FTable *ftable, VarLengthColumn *def) { 205 206 char field[81]; 207 char format[81]; 208 209 // grab the value of TFORMn for this column 210 snprintf (field, 80, "TFORM%d", def->column); 211 if (!gfits_scan (ftable->header, field, "%s", 1, format)) return FALSE; 212 213 // find and update the max field length element 214 char *p1 = strchr (format, '('); 215 if (!p1) return (FALSE); // not a valid varlength column -- missing (e_max) 216 217 p1 ++; 218 *p1 = 0; 219 220 snprintf (p1, 80 - (p1 - format), "%d)", def->maxlen); 221 if (!gfits_modify (ftable->header, field, "%s", 1, format)) return FALSE; 222 223 return TRUE; 224 } -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/table/F_write_T.c
r37807 r38447 14 14 15 15 status = fseeko (f, 0LL, SEEK_END); /* write table to end of file! */ 16 if (status) { perror ("fseeko: "); return (FALSE); } 16 17 status = gfits_fwrite_table (f, table); 17 18 … … 26 27 27 28 Nbytes = fwrite (table[0].buffer, sizeof(char), table[0].datasize, f); 28 29 if (Nbytes != table[0].datasize) return (FALSE); 29 if (Nbytes != table[0].datasize) { perror ("fwrite: "); return (FALSE); } 30 30 return (TRUE); 31 31 } … … 45 45 /* file pointer is at beginning of desired table data */ 46 46 start = ftello (f); 47 if (start < 0) { perror ("ftello: "); return FALSE; } 47 48 48 49 for (i = 0; i < Nrow; i++) { … … 50 51 fseeko (f, offset, SEEK_SET); 51 52 Nbytes = fwrite (table[0].buffer[i], sizeof (char), Nx, f); 52 if (Nbytes != Nx) { return (FALSE); }53 if (Nbytes != Nx) { perror ("fwrite: "); return (FALSE); } 53 54 } 54 55 … … 58 59 59 60 offset = start + Nx*Ny; 60 fseeko (f, offset, SEEK_SET); 61 int status = fseeko (f, offset, SEEK_SET); 62 if (status) { perror ("fseeko: "); return FALSE; } 63 61 64 Nbytes = fwrite (pad, sizeof (char), Npad, f); 62 if (Nbytes != Npad) { return (FALSE); }65 if (Nbytes != Npad) { perror ("fwrite: "); return (FALSE); } 63 66 free (pad); 64 67 … … 84 87 Nx = ftable[0].header[0].Naxis[0]; // final output table size on disk 85 88 ftable[0].datasize = gfits_data_size (ftable[0].header); 89 ftable[0].heap_start = gfits_heap_start (ftable[0].header); 86 90 87 91 Nskip = start * Nx; … … 96 100 // cursor must be at start of the table (after table header) 97 101 if (fseeko (f, Nskip, SEEK_CUR)) { 102 perror ("fseeko: "); 98 103 fprintf (stderr, "can't seek table start\n"); 99 104 return (FALSE); … … 101 106 102 107 Nwrite = fwrite (ftable[0].buffer, sizeof (char), Nbytes, f); 103 if (Nwrite != Nbytes) { 104 return (FALSE); 105 } 108 if (Nwrite != Nbytes) { perror ("fwrite: "); return (FALSE); } 106 109 107 110 if (Ntotal >= Ndisk) { … … 112 115 free (pad); 113 116 114 if (Nbytes != Npad) return (FALSE);117 if (Nbytes != Npad) { perror ("fwrite: "); return (FALSE); } 115 118 } 116 119 -
branches/eam_branches/ipp-20150419/Ohana/src/libfits/table/F_write_TH.c
r27435 r38447 14 14 15 15 status = fseeko (f, 0LL, SEEK_END); /* write header to end of file! */ 16 if (status) { perror ("fseeko: "); return (FALSE); } 16 17 status = gfits_fwrite_Theader (f, header); 17 18 … … 26 27 27 28 Nbytes = fwrite (header[0].buffer, sizeof(char), header[0].datasize, f); 29 if (Nbytes != header[0].datasize) { perror ("fwrite: "); return (FALSE); } 28 30 29 if (Nbytes != header[0].datasize) return (FALSE);30 31 return (TRUE); 31 32 } -
branches/eam_branches/ipp-20150419/Ohana/src/libohana/Makefile
r38286 r38447 1 1 default: install 2 2 help: 3 @echo "make options: install libohana clean dist test t ypetest"3 @echo "make options: install libohana clean dist test test.clean" 4 4 5 5 include ../../Makefile.System … … 10 10 MAN = $(HOME)/doc 11 11 INC = $(HOME)/include 12 TESTDIR = $(HOME)/test 12 TESTDIR = $(HOME)/test 13 TESTBIN = $(HOME)/test 13 14 include ../../Makefile.Common 14 15 … … 17 18 FULL_CPPFLAGS = $(BASE_CPPFLAGS) 18 19 FULL_LDFLAGS = $(BASE_LDFLAGS) 19 TFLAGS = $(FULL_CFLAGS) $(FULL_CPPFLAGS) $(FULL_LDFLAGS) -lohana -ltap_ohana20 20 21 install: $(DESTLIB)/libohana.a $(DESTLIB)/libohana.$(DLLTYPE) typetest 21 TEST_CFLAGS = $(BASE_CFLAGS) 22 TEST_CPPFLAGS = $(BASE_CPPFLAGS) 23 TEST_LDFLAGS = $(BASE_LDFLAGS) -lohana -ltap_ohana 24 25 install: $(DESTLIB)/libohana.a $(DESTLIB)/libohana.$(DLLTYPE) 22 26 libohana: $(LIB)/libohana.$(ARCH).a $(LIB)/libohana.$(ARCH).$(DLLTYPE) 23 27 … … 52 56 # $(SRC)/gsl_utils.$(ARCH).o \ 53 57 54 TYPETEST = \55 $(TESTDIR)/typetest.$(ARCH)56 57 $(TYPETEST) : $(LIB)/libohana.$(ARCH).a58 59 typetest: $(TYPETEST)60 for i in $(TYPETEST); do $$i || exit 1; done61 62 TEST = \63 $(TESTDIR)/memtest.$(ARCH)64 # $(TESTDIR)/string.$(ARCH)65 66 testcode: install $(TEST)67 test:68 $(MAKE) testcode69 for i in $(TEST); do $$i; done70 71 quicktest:72 for i in $(TEST); do $$i; done73 74 58 $(OBJS): $(INCS) 75 59 … … 80 64 $(DESTLIB)/libohana.$(DLLTYPE): $(LIB)/libohana.$(ARCH).$(DLLTYPE) 81 65 82 $(TESTDIR)/%.$(ARCH) : $(TESTDIR)/%.c 83 $(CC) $^ -o $@ $(TFLAGS) 84 85 .PHONY: test 86 66 TESTPROG = memtest typetest string 67 $(TESTPROG) : % : $(TESTBIN)/% $(OBJS) 68 test: $(TESTPROG) 69 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 | $(TESTHARNESS); done 70 test.verbose: $(TESTPROG) 71 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 |& $(TESTHARNESS) -v; done -
branches/eam_branches/ipp-20150419/Ohana/src/libohana/include/ohana.h
r38282 r38447 286 286 char *strcreate PROTO((char *string)); 287 287 char *strncreate PROTO((char *string, int n)); 288 int strextend PROTO((char **input, char *format,...)) OHANA_FORMAT(printf, 2, 3); 288 289 int scan_line PROTO((FILE *f, char *line)); 289 290 int scan_line_maxlen PROTO((FILE *f, char *line, int maxlen)); … … 393 394 394 395 char *memstr PROTO((char *m1, char *m2, int n)); 395 int write_fmt PROTO((int fd, char *format, ...)) ;396 int write_fmt PROTO((int fd, char *format, ...)) OHANA_FORMAT(printf, 2, 3); 396 397 397 398 char **isolate_elements PROTO((int argc, char **argv, int *nstack)); … … 403 404 404 405 // gprint gets a stub implementation in libohana. opihi implements the real one. 405 int gprint (gpDest dest, char *format, ...);406 int gprint PROTO((gpDest dest, char *format, ...) OHANA_FORMAT(printf, 2, 3)); 406 407 407 408 // rconnect is used to run remote programs with a pipe for communication -
branches/eam_branches/ipp-20150419/Ohana/src/libohana/include/ohana_allocate.h
r33646 r38447 26 26 void ohana_free (const char *file, int line, const char *func, void *in); 27 27 void ohana_memdump_func (int mode); 28 voidohana_memcheck_func (int mode);28 int ohana_memcheck_func (int mode); 29 29 void real_free (void *in); 30 30 … … 56 56 # else /* below: not OHANA_MEMORY */ 57 57 58 # define ohana_memcheck(X) /* NOP */58 # define ohana_memcheck(X) TRUE 59 59 # define ohana_memdump(X) /* NOP */ 60 60 void real_free (void *in); -
branches/eam_branches/ipp-20150419/Ohana/src/libohana/src/ohana_allocate.c
r37807 r38447 207 207 } 208 208 209 voidohana_memcheck_func (int allmemory) {209 int ohana_memcheck_func (int allmemory) { 210 210 211 211 if (!lastBlock) { 212 212 fprintf (stderr, "no memory allocated\n"); 213 return ;213 return TRUE; 214 214 } 215 215 … … 253 253 fprintf (stderr, "%zd memory blocks allocated (%zd bytes total), %zd good, %zd bad\n", Ntotal, Nbytes, Ngood, Nbad); 254 254 255 return; 255 if (Nbad) return FALSE; 256 return TRUE; 256 257 } 257 258 -
branches/eam_branches/ipp-20150419/Ohana/src/libohana/src/string.c
r37033 r38447 65 65 } 66 66 67 // extend input as needed to add the formatted pieces 68 // if input is NULL, allocate a new line 69 // the result of the format must be < 1024 bytes 70 int strextend (char **input, char *format,...) { 71 72 int Nchar; 73 char tmpextra[1024], tmpline, *output; 74 va_list argp; 75 76 va_start (argp, format); 77 Nchar = vsnprintf (tmpextra, 1024, format, argp); 78 if (Nchar > 1024 - 1) return FALSE; 79 80 if (*input) { 81 Nchar = snprintf (&tmpline, 0, "%s %s", *input, tmpextra); 82 ALLOCATE (output, char, Nchar + 1); 83 snprintf (output, Nchar + 1, "%s %s", *input, tmpextra); 84 free (*input); 85 } else { 86 Nchar = strlen(tmpextra) + 1; 87 ALLOCATE (output, char, Nchar); 88 strcpy (output, tmpextra); 89 } 90 *input = output; 91 92 return TRUE; 93 } 94 67 95 // replace a single entry of 'match' in the string with 'with' 68 96 // (quick-and-dirty regex for a common case...) -
branches/eam_branches/ipp-20150419/Ohana/src/libohana/test
- Property svn:ignore
-
old new 4 4 *.darwin_x86 5 5 *.dSYM 6 memtest 7 string 8 typetest
-
- Property svn:ignore
-
branches/eam_branches/ipp-20150419/Ohana/src/libohana/test/string.c
r10313 r38447 4 4 int main (void) { 5 5 6 plan_tests ( 16);6 plan_tests (20); 7 7 8 8 diag ("libohana string.c tests"); … … 67 67 skip_end(); 68 68 } 69 70 /*** strextend ***/ 71 { 72 int status; 73 char *string = NULL; 74 75 status = strextend(&string, "hello %s", "there"); 76 ok (status, "strextend for NULL input"); 77 ok (!strcmp(string, "hello there"), "strextend format"); 78 79 status = strextend(&string, "more words %d", 2); 80 ok (status, "strextend for non-NULL input"); 81 ok (!strcmp(string, "hello there more words 2"), "strextend format"); 82 } 69 83 return exit_status(); 70 84 } -
branches/eam_branches/ipp-20150419/Ohana/src/libohana/test/typetest.c
r31663 r38447 1 1 # include "ohana.h" 2 # include "tap_ohana.h" 2 3 3 4 enum 4 {5 { 5 6 OHANA_LITTLE_ENDIAN = 0x03020100ul, 6 7 OHANA_BIG_ENDIAN = 0x00010203ul, 7 };8 }; 8 9 9 10 static const union { 10 unsigned char bytes[4];11 int value;11 unsigned char bytes[4]; 12 int value; 12 13 } ohana_host_order = { { 0, 1, 2, 3 } }; 13 14 … … 15 16 16 17 // we need to verify some type-related issues: 17 int main ( int argc, char **argv) {18 int main (void) { 18 19 19 int status;20 plan_tests (4); 20 21 21 status = 0;22 diag ("libohana typetest.c tests"); 22 23 23 // 1) have we defined BYTE_SWAP correctly? 24 int status = 0; 25 26 // 1) have we defined BYTE_SWAP correctly? 24 27 25 28 # ifdef BYTE_SWAP 26 if (OHANA_HOST_ORDER == OHANA_BIG_ENDIAN) { 27 fprintf (stderr, "ERROR: BYTE_SWAP is defined on a big endian machine\n"); 28 fprintf (stderr, "(see libohana/include/ohana.h)\n"); 29 status = 1; 30 } else { 31 fprintf (stderr, "BYTE_SWAP is small endian\n"); 32 } 29 ok (OHANA_HOST_ORDER == OHANA_LITTLE_ENDIAN, "BYTE_SWAP defined on small endian hardware (see libohana/include/ohana.h)"); 33 30 # else 34 if (OHANA_HOST_ORDER == OHANA_BIG_ENDIAN) { 35 fprintf (stderr, "NOT_BYTE_SWAP is big endian\n"); 36 } else { 37 fprintf (stderr, "ERROR: BYTE_SWAP not defined on a small endian machine\n"); 38 fprintf (stderr, "(see libohana/include/ohana.h)\n"); 39 status = 1; 40 } 31 ok (OHANA_HOST_ORDER == OHANA_BIG_ENDIAN, "BYTE_SWAP NOT defined on big endian hardware (see libohana/include/ohana.h)"); 41 32 # endif 42 33 43 // 2) have we defined NAN correctly?44 {45 float fvalue;46 double dvalue;34 // 2) have we defined NAN correctly? 35 { 36 float fvalue; 37 double dvalue; 47 38 48 fvalue = NAN;49 dvalue = NAN;39 fvalue = NAN; 40 dvalue = NAN; 50 41 51 if (isfinite(fvalue)) { 52 fprintf (stderr, "ERROR: NAN definition fails for float\n"); 53 fprintf (stderr, "fvalue: %e\n", fvalue); 54 status = 1; 55 } 56 if (isfinite(dvalue)) { 57 fprintf (stderr, "ERROR: NAN definition fails for double\n"); 58 fprintf (stderr, "dvalue: %e\n", dvalue); 59 status = 1; 60 } 61 62 fprintf (stderr, "fvalue: %e (isfinite: %d)\n", fvalue, isfinite(fvalue)); 63 fprintf (stderr, "dvalue: %e (isfinite: %d)\n", dvalue, isfinite(dvalue)); 42 ok (isnan(fvalue), "float NAN correctly defined"); 43 ok (isnan(dvalue), "double NAN correctly defined"); 64 44 65 45 # ifdef __STDC_VERSION__ 66 fprintf (stderr,"STDC_VERSION: %ld\n", __STDC_VERSION__);46 diag ("STDC_VERSION: %ld\n", __STDC_VERSION__); 67 47 # else 68 fprintf (stderr, "STDC_VERSION is not set\n");48 diag ("STDC_VERSION is not set"); 69 49 # endif 70 }50 } 71 51 72 // 3) have we defined OFF_T_FMT correctly?73 off_t big_value;52 // 3) have we defined OFF_T_FMT correctly? this test should actually raise a compile-time error 53 off_t big_value = 10; 74 54 75 big_value = 10; 76 fprintf (stderr, "this is a big int: "OFF_T_FMT" n'est pas?\n", big_value); 55 char line[80]; 56 status = snprintf (line, 80, "this is a big int: "OFF_T_FMT" n'est pas?", big_value); 57 // 1234567890123456789 0123456789012 58 ok (status == 32, "correctly formatted an off_t int with %d chars", status); 77 59 78 // we could move the % out of the FMT and allow constructions like this:79 // # define OFF_T_FMT "jd"80 // fprintf (stderr, "this is a big int: %06"OFF_T_FMT_ALT" n'est pas?\n", big_value);81 // still kind of ugly...60 // we could move the % out of the FMT and allow constructions like this: 61 // # define OFF_T_FMT "jd" 62 // fprintf (stderr, "this is a big int: %06"OFF_T_FMT_ALT" n'est pas?\n", big_value); 63 // still kind of ugly... 82 64 83 exit (status); 65 fprintf (stderr, "max float: %e\n", FLT_MAX); 66 fprintf (stderr, "max double: %e\n", DBL_MAX); 67 fprintf (stderr, "min float: %e\n", FLT_MIN); 68 fprintf (stderr, "min double: %e\n", DBL_MIN); 69 70 return exit_status(); 84 71 } -
branches/eam_branches/ipp-20150419/Ohana/src/markrock/src/markrock.c
r25757 r38447 38 38 catalog.filename = argv[1]; 39 39 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 40 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;40 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 41 41 42 42 // an error exit status here is a significant error … … 45 45 exit (2); 46 46 } 47 if (catalog.Nave s_disk) {47 if (catalog.Naverage_disk) { 48 48 dvo_catalog_unlock (&catalog); 49 49 dvo_catalog_free (&catalog); -
branches/eam_branches/ipp-20150419/Ohana/src/markstar/src/find_images.c
r29001 r38447 25 25 } 26 26 27 timage = gfits_table_get_Image (&db[0].ftable, &Ntimage, &db[0].s wapped);27 timage = gfits_table_get_Image (&db[0].ftable, &Ntimage, &db[0].scaledValue, &db[0].nativeOrder); 28 28 if (!timage) { 29 29 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/markstar/src/markstar.c
r15743 r38447 37 37 38 38 set_db (&db); 39 gfits_db_init (&db); 39 40 dvo_image_lock (&db, ImageCat, 3600.0, LCK_XCLD); 40 41 41 42 catalog.filename = argv[1]; 42 43 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 43 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;44 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 44 45 45 46 // an error exit status here is a significant error … … 48 49 exit (2); 49 50 } 50 if (!catalog.Nave s_disk) {51 if (!catalog.Naverage_disk) { 51 52 dvo_catalog_unlock (&catalog); 52 53 dvo_catalog_free (&catalog); -
branches/eam_branches/ipp-20150419/Ohana/src/mosastro/src/getptolemy.c
r25757 r38447 26 26 // set the parameters which guide catalog open/load/create 27 27 catalog.filename = skylist[0].filename[i]; 28 catalog.catflags = LOAD_AVES | LOAD_MEAS;28 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE; 29 29 catalog.Nsecfilt = 0; 30 30 … … 36 36 dvo_catalog_unlock (&catalog); 37 37 38 // Nave s_disk == 0 implies an empty catalog file38 // Naverage_disk == 0 implies an empty catalog file 39 39 // for only_match, skip empty catalogs 40 if (!catalog.Nave s_disk) {40 if (!catalog.Naverage_disk) { 41 41 dvo_catalog_free (&catalog); 42 42 continue; -
branches/eam_branches/ipp-20150419/Ohana/src/mosastro/src/rfits.c
r29001 r38447 31 31 32 32 off_t Nstars; 33 stars = gfits_table_get_SMPData (&table, &Nstars, NULL );33 stars = gfits_table_get_SMPData (&table, &Nstars, NULL, NULL); 34 34 if (!stars) { 35 35 fprintf (stderr, "ERROR: failed to read stars\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/mosastro/src/wfits.c
r27435 r38447 19 19 20 20 table.header = &theader; 21 gfits_table_set_SMPData (&table, stars, Nstars );21 gfits_table_set_SMPData (&table, stars, Nstars, TRUE); 22 22 23 23 gfits_write_header (filename, header); -
branches/eam_branches/ipp-20150419/Ohana/src/photdbc/include/photdbc.h
r37807 r38447 54 54 char *CATMODE; /* raw, mef, split, mysql */ 55 55 char *CATFORMAT; /* internal, elixir, loneos, panstarrs */ 56 char *CATCOMPRESS; /* ?? */ 56 57 char PhotCodeFile[DVO_MAX_PATH]; 57 58 -
branches/eam_branches/ipp-20150419/Ohana/src/photdbc/src/ConfigInit.c
r34749 r38447 63 63 WarnConfig (config, "ZERO_PT", "%lf", 0, &ZERO_POINT); 64 64 65 // NOTE: in this program, CATFORMAT, CATMODE, CATCOMPRESS may only be set 66 // as command-line options, eg: -set-format PS1_V5 67 65 68 if (!success) { 66 69 fprintf (stderr, "missing config parameter\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/photdbc/src/Shutdown_dvodist.c
r33655 r38447 11 11 12 12 // lock the image db table 13 gfits_db_init (&db); 13 14 int status = dvo_image_lock (&db, ImageCat, 60.0, LCK_XCLD); 14 15 if (!status) { -
branches/eam_branches/ipp-20150419/Ohana/src/photdbc/src/args.c
r37807 r38447 71 71 remove_argument (N, &argc, argv); 72 72 CATMODE = strcreate (argv[N]); 73 remove_argument (N, &argc, argv); 74 } 75 76 // override input catalog format (PS1_V1, PS1_REF, etc) 77 CATCOMPRESS = NULL; 78 if ((N = get_argument (argc, argv, "-set-compress"))) { 79 remove_argument (N, &argc, argv); 80 CATCOMPRESS = strcreate (argv[N]); 73 81 remove_argument (N, &argc, argv); 74 82 } … … 257 265 } 258 266 267 // override input catalog format (PS1_V1, PS1_REF, etc) 268 CATCOMPRESS = NULL; 269 if ((N = get_argument (argc, argv, "-set-compress"))) { 270 remove_argument (N, &argc, argv); 271 CATCOMPRESS = strcreate (argv[N]); 272 remove_argument (N, &argc, argv); 273 } 274 259 275 /* specify portion of the sky */ 260 276 REGION.Rmin = 0; … … 344 360 fprintf (stderr, " -skip-images\n"); 345 361 fprintf (stderr, " -only-images\n"); 346 fprintf (stderr, " -set-format (catformat)\n"); 362 fprintf (stderr, " -set-compress (catcompress) : NONE, GZIP_1, GZIP_2, RICE_1, AUTO\n"); 363 fprintf (stderr, " -set-format (catmode)\n"); 347 364 fprintf (stderr, " -set-mode (catmode)\n"); 348 365 -
branches/eam_branches/ipp-20150419/Ohana/src/photdbc/src/copy_images.c
r37807 r38447 19 19 if (status == -1) Shutdown ("ERROR: CATDIR %s does not exist, no data in database", path); 20 20 21 gfits_db_init (&in); 21 22 status = dvo_image_lock (&in, ImageCat, 60.0, LCK_SOFT); 22 23 if (!status) { … … 38 39 39 40 // lock the output catalog 41 gfits_db_init (&out); 40 42 status = dvo_image_lock (&out, ImageOut, 60.0, LCK_XCLD); 41 43 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", ImageOut); … … 46 48 dvo_image_create (&out, ZERO_POINT); 47 49 48 image = gfits_table_get_Image (&in.ftable, &Nimage, &in.s wapped);50 image = gfits_table_get_Image (&in.ftable, &Nimage, &in.scaledValue, &in.nativeOrder); 49 51 if (!image) { 50 52 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/photdbc/src/find_images.c
r37807 r38447 24 24 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 25 25 26 timage = gfits_table_get_Image (&db[0].ftable, &Ntimage, &db[0].s wapped);26 timage = gfits_table_get_Image (&db[0].ftable, &Ntimage, &db[0].scaledValue, &db[0].nativeOrder); 27 27 if (!timage) { 28 28 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/photdbc/src/flag_measures.c
r29001 r38447 15 15 if (VERBOSE) fprintf (stderr, "flagging bad measurements\n"); 16 16 17 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);17 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 18 18 if (!image) { 19 19 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/photdbc/src/join_stars.c
r37807 r38447 224 224 catalog[0].Naverage = Naves; 225 225 catalog[0].Nmeasure = Nmeas; 226 catalog[0].Nsecf _mem = Naves*catalog[0].Nsecfilt;226 catalog[0].Nsecfilt_mem = Naves*catalog[0].Nsecfilt; 227 227 228 228 return; -
branches/eam_branches/ipp-20150419/Ohana/src/photdbc/src/make_subcatalog.c
r37045 r38447 190 190 subcatalog[0].Nmeasure = Nmeasure; 191 191 subcatalog[0].Nsecfilt = Nsecfilt; 192 subcatalog[0].Nsecf _mem = Naverage * Nsecfilt;192 subcatalog[0].Nsecfilt_mem = Naverage * Nsecfilt; 193 193 194 194 // XXX for now, don't copy the missing entries (these should be re-computed) -
branches/eam_branches/ipp-20150419/Ohana/src/photdbc/src/photdbc_catalogs.c
r37807 r38447 24 24 incatalog.filename = hostID ? hostfile : skylist[0].filename[i]; 25 25 incatalog.Nsecfilt = GetPhotcodeNsecfilt (); 26 incatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;26 incatalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 27 27 28 28 // an error exit status here is a significant error … … 32 32 } 33 33 // skip empty input catalogs 34 if (!incatalog.Nave s_disk) {34 if (!incatalog.Naverage_disk) { 35 35 dvo_catalog_unlock (&incatalog); 36 36 dvo_catalog_free (&incatalog); … … 51 51 52 52 // define outcatalog open parameters 53 outcatalog.catformat = CATFORMAT ? dvo_catalog_catformat (CATFORMAT) : incatalog.catformat; 54 outcatalog.catmode = CATMODE ? dvo_catalog_catmode (CATMODE) : incatalog.catmode; 55 outcatalog.Nsecfilt = incatalog.Nsecfilt; // inherit from the incatalog 56 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 53 outcatalog.catformat = CATFORMAT ? dvo_catalog_catformat (CATFORMAT) : incatalog.catformat; 54 outcatalog.catmode = CATMODE ? dvo_catalog_catmode (CATMODE) : incatalog.catmode; 55 outcatalog.catcompress = CATCOMPRESS ? dvo_catalog_catcompress (CATCOMPRESS) : incatalog.catcompress; // set the default catcompress from config data 56 outcatalog.Nsecfilt = incatalog.Nsecfilt; // inherit from the incatalog 57 outcatalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 57 58 58 59 // output catalogs always represent the same skyregions as the input catalogs … … 121 122 122 123 // options / arguments that can affect relastro_client -update-objects: 123 char command[DVO_MAX_PATH];124 s nprintf (command, DVO_MAX_PATH, "photdbc_client %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -D NMEAS_MIN %d -D NMEAS_MIN_FILTERED %d -D AVE_SIGMA_LIM %f -D SIGMA_MAX %f",124 char *command = NULL; 125 strextend (&command, "photdbc_client %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -D NMEAS_MIN %d -D NMEAS_MIN_FILTERED %d -D AVE_SIGMA_LIM %f -D SIGMA_MAX %f", 125 126 tmproot, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, 126 127 REGION.Rmin, REGION.Rmax, REGION.Dmin, REGION.Dmax, … … 128 129 ); 129 130 130 char tmpline[DVO_MAX_PATH];131 if ( VERBOSE) { snprintf (tmpline, DVO_MAX_PATH, "%s -v", command); strcpy (command, tmpline); }132 if (ExcludeBy InstMag) { snprintf (tmpline, DVO_MAX_PATH, "%s -instmag %f %f", command, INST_MAG_MIN, INST_MAG_MAX); strcpy (command, tmpline); }133 if (ExcludeByM inSigma) { snprintf (tmpline, DVO_MAX_PATH, "%s -min-sigma %f", command, SIGMA_MIN_KEEP); strcpy (command, tmpline); }134 if ( ExcludeByMaxMinMag) { snprintf (tmpline, DVO_MAX_PATH, "%s -maxminmag %f", command, MAX_MIN_MAG); strcpy (command, tmpline); }135 if (PHOTCODE_ DROP_LIST) { snprintf (tmpline, DVO_MAX_PATH, "%s -photcode-drop %s", command, PHOTCODE_DROP_LIST); strcpy (command, tmpline); }136 if ( PHOTCODE_KEEP_LIST) { snprintf (tmpline, DVO_MAX_PATH, "%s -photcode-keep %s", command, PHOTCODE_KEEP_LIST); strcpy (command, tmpline); }137 if (CATFORMAT) { s nprintf (tmpline, DVO_MAX_PATH, "%s -set-format %s", command, CATFORMAT); strcpy (command, tmpline); }138 if (CATMODE) { s nprintf (tmpline, DVO_MAX_PATH, "%s -set-mode %s", command, CATMODE); strcpy (command, tmpline); }131 if (VERBOSE) { strextend (&command, "-v"); } 132 if (ExcludeByInstMag) { strextend (&command, "-instmag %f %f", INST_MAG_MIN, INST_MAG_MAX); } 133 if (ExcludeByMinSigma) { strextend (&command, "-min-sigma %f", SIGMA_MIN_KEEP); } 134 if (ExcludeByMaxMinMag) { strextend (&command, "-maxminmag %f", MAX_MIN_MAG); } 135 if (PHOTCODE_DROP_LIST) { strextend (&command, "-photcode-drop %s", PHOTCODE_DROP_LIST); } 136 if (PHOTCODE_KEEP_LIST) { strextend (&command, "-photcode-keep %s", PHOTCODE_KEEP_LIST); } 137 if (CATCOMPRESS) { strextend (&command, "-set-compress %s", CATCOMPRESS); } 138 if (CATFORMAT) { strextend (&command, "-set-format %s", CATFORMAT); } 139 if (CATMODE) { strextend (&command, "-set-mode %s", CATMODE); } 139 140 140 141 if (PARALLEL_OUTHOSTS) { … … 142 143 free (table_output->hosts[i].pathname); 143 144 table_output->hosts[i].pathname = tmppath; 144 s nprintf (tmpline, DVO_MAX_PATH, "%s -hostdir-output %s", command, table_output->hosts[i].pathname); strcpy (command, tmpline);145 strextend (&command, "-hostdir-output %s", table_output->hosts[i].pathname); 145 146 } 146 147 -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/include/relastro.h
r38062 r38447 539 539 int hpm_objects (SkyRegion *region, Catalog *catalog); 540 540 541 int strextend (char *input, char *format,...);542 541 int launch_region_hosts (RegionHostTable *regionHosts); 543 542 … … 591 590 float getColorBlue (off_t meas, int cat); 592 591 float getColorRed (off_t meas, int cat); 593 594 int strextend (char *input, char *format,...);595 592 596 593 int areImagesLoaded (); -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/BrightCatalog.c
r38062 r38447 172 172 GET_COLUMN(Nmeasure, "NMEASURE", short); 173 173 GET_COLUMN(Nmissing, "NMISSING", short); 174 GET_COLUMN(N extend, "NEXTEND",short);174 GET_COLUMN(Ngalphot, "NGALPHOT", short); 175 175 GET_COLUMN(measureOffset, "OFF_MEASURE", int); 176 176 GET_COLUMN(missingOffset, "OFF_MISSING", int); … … 208 208 average[i].Nmeasure = Nmeasure[i] ; 209 209 average[i].Nmissing = Nmissing[i] ; 210 average[i].N extend = Nextend[i] ;210 average[i].Ngalphot = Ngalphot[i] ; 211 211 average[i].measureOffset = measureOffset[i] ; 212 212 average[i].missingOffset = missingOffset[i] ; … … 241 241 free (Nmeasure); 242 242 free (Nmissing); 243 free (N extend);243 free (Ngalphot); 244 244 free (measureOffset); 245 245 free (missingOffset); … … 502 502 gfits_define_bintable_column (&theader, "I", "NMEASURE", "number of psf measurements", "", 1.0, 0.0); 503 503 gfits_define_bintable_column (&theader, "I", "NMISSING", "number of missings", "", 1.0, 0.0); 504 gfits_define_bintable_column (&theader, "I", "N EXTEND", "number of extended measurements","", 1.0, 0.0);504 gfits_define_bintable_column (&theader, "I", "NGALPHOT", "number of galaxy shape measurements", "", 1.0, 0.0); 505 505 gfits_define_bintable_column (&theader, "J", "OFF_MEASURE", "offset to first psf measurement", "", 1.0, 0.0); 506 506 gfits_define_bintable_column (&theader, "J", "OFF_MISSING", "offset to first missing obs", "", 1.0, 0.0); … … 537 537 short *Nmeasure ; ALLOCATE (Nmeasure , short , catalog->Naverage); 538 538 short *Nmissing ; ALLOCATE (Nmissing , short , catalog->Naverage); 539 short *N extend ; ALLOCATE (Nextend, short , catalog->Naverage);539 short *Ngalphot ; ALLOCATE (Ngalphot , short , catalog->Naverage); 540 540 int *measureOffset ; ALLOCATE (measureOffset , int , catalog->Naverage); 541 541 int *missingOffset ; ALLOCATE (missingOffset , int , catalog->Naverage); … … 571 571 Nmeasure[i] = average[i].Nmeasure ; 572 572 Nmissing[i] = average[i].Nmissing ; 573 N extend[i] = average[i].Nextend;573 Ngalphot[i] = average[i].Ngalphot ; 574 574 measureOffset[i] = average[i].measureOffset ; 575 575 missingOffset[i] = average[i].missingOffset ; … … 604 604 gfits_set_bintable_column (&theader, &ftable, "NMEASURE", Nmeasure, catalog->Naverage); 605 605 gfits_set_bintable_column (&theader, &ftable, "NMISSING", Nmissing, catalog->Naverage); 606 gfits_set_bintable_column (&theader, &ftable, "N EXTEND", Nextend,catalog->Naverage);606 gfits_set_bintable_column (&theader, &ftable, "NGALPHOT", Ngalphot, catalog->Naverage); 607 607 gfits_set_bintable_column (&theader, &ftable, "OFF_MEASURE", measureOffset, catalog->Naverage); 608 608 gfits_set_bintable_column (&theader, &ftable, "OFF_MISSING", missingOffset, catalog->Naverage); … … 635 635 free (Nmeasure); 636 636 free (Nmissing); 637 free (N extend);637 free (Ngalphot); 638 638 free (measureOffset); 639 639 free (missingOffset); -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/ImageTable.c
r36630 r38447 7 7 FITS_DB db; 8 8 9 gfits_db_init (&db); 9 10 db.mode = dvo_catalog_catmode (CATMODE); 10 11 db.format = dvo_catalog_catformat (CATFORMAT); … … 27 28 // convert database table to internal structure (binary to Image) 28 29 // 'image' points to the same memory as db->ftable->buffer 29 Image *image = gfits_table_get_Image (&db.ftable, &Nimage, &db.s wapped);30 Image *image = gfits_table_get_Image (&db.ftable, &Nimage, &db.scaledValue, &db.nativeOrder); 30 31 if (!image) { 31 32 Shutdown ("ERROR: failed to read images"); … … 42 43 43 44 // setup image table format and lock 45 gfits_db_init (&db); 44 46 db.mode = dvo_catalog_catmode (CATMODE); 45 47 db.format = dvo_catalog_catformat (CATFORMAT); -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/UpdateObjectOffsets.c
r37807 r38447 34 34 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 35 35 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 36 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;36 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 37 37 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 38 38 … … 41 41 exit (1); 42 42 } 43 if (!catalog.Nave s_disk) {43 if (!catalog.Naverage_disk) { 44 44 if (VERBOSE2) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 45 45 dvo_catalog_unlock (&catalog); … … 102 102 103 103 int Ngroups; 104 HostTableGroup *groups = HostTableGroups (table, &Ngroups);104 HostTableGroup *groups = HostTableGroupsUniqueMachines (table, &Ngroups); 105 105 // split the table into Ngroups, each with a unique set of machines (this avoids overloading the remote host machines) 106 106 … … 152 152 // MaxDensityUse, MaxDensityValue 153 153 154 char command[1024];155 s nprintf (command, 1024, "relastro_client -update-offsets -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -minerror %f",154 char *command = NULL; 155 strextend (&command, "relastro_client -update-offsets -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -minerror %f", 156 156 group->hosts[i][0].hostID, CATDIR, group->hosts[i][0].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, MIN_ERROR); 157 157 158 if (FIT_MODE == FIT_PM_ONLY) strextend ( command, "-pm");159 if (FIT_MODE == FIT_PAR_ONLY) strextend ( command, "-par");160 if (FIT_MODE == FIT_PM_AND_PAR) strextend ( command, "-pmpar");161 162 if (VERBOSE) strextend ( command, "-v");163 if (VERBOSE2) strextend ( command, "-vv");164 if (RESET) strextend ( command, "-reset");165 if (UPDATE) strextend ( command, "-update");166 167 if (RESET_BAD_IMAGES) strextend ( command, "-reset-bad-images");168 169 if (ImagSelect) strextend ( command, "-instmag %f %f", ImagMin, ImagMax);170 if (MaxDensityUse) strextend ( command, "-max-density %f", MaxDensityValue);171 172 if (USE_BASIC_CHECK) strextend ( command, "-basic-image-search");173 if (FlagOutlier) strextend ( command, "-clip %d", CLIP_THRESH);174 if (ExcludeBogus) strextend ( command, "-exclude-bogus %f", ExcludeBogusRadius);175 176 if (USE_FIXED_PIXCOORDS) strextend ( command, "-D USE_FIXED_PIXCOORDS 1");177 178 if (PHOTCODE_KEEP_LIST) strextend ( command, "+photcode %s", PHOTCODE_KEEP_LIST);179 if (PHOTCODE_SKIP_LIST) strextend ( command, "-photcode %s", PHOTCODE_SKIP_LIST);180 if (PhotFlagSelect) strextend ( command, "+photflags");181 if (PhotFlagBad) strextend ( command, "+photflagbad %d", PhotFlagBad);182 if (PhotFlagPoor) strextend ( command, "+photflagpoor %d", PhotFlagPoor);158 if (FIT_MODE == FIT_PM_ONLY) strextend (&command, "-pm"); 159 if (FIT_MODE == FIT_PAR_ONLY) strextend (&command, "-par"); 160 if (FIT_MODE == FIT_PM_AND_PAR) strextend (&command, "-pmpar"); 161 162 if (VERBOSE) strextend (&command, "-v"); 163 if (VERBOSE2) strextend (&command, "-vv"); 164 if (RESET) strextend (&command, "-reset"); 165 if (UPDATE) strextend (&command, "-update"); 166 167 if (RESET_BAD_IMAGES) strextend (&command, "-reset-bad-images"); 168 169 if (ImagSelect) strextend (&command, "-instmag %f %f", ImagMin, ImagMax); 170 if (MaxDensityUse) strextend (&command, "-max-density %f", MaxDensityValue); 171 172 if (USE_BASIC_CHECK) strextend (&command, "-basic-image-search"); 173 if (FlagOutlier) strextend (&command, "-clip %d", CLIP_THRESH); 174 if (ExcludeBogus) strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius); 175 176 if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1"); 177 178 if (PHOTCODE_KEEP_LIST) strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST); 179 if (PHOTCODE_SKIP_LIST) strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST); 180 if (PhotFlagSelect) strextend (&command, "+photflags"); 181 if (PhotFlagBad) strextend (&command, "+photflagbad %d", PhotFlagBad); 182 if (PhotFlagPoor) strextend (&command, "+photflagpoor %d", PhotFlagPoor); 183 183 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 184 184 185 185 if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) { 186 strextend ( command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);186 strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG); 187 187 } 188 188 if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) { 189 strextend ( command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);190 } 191 192 if (MinBadQF > 0.0) strextend ( command, "-min-bad-psfqf %f", MinBadQF);193 if (MaxMeanOffset != 10.0) strextend ( command, "-max-mean-offset %f", MaxMeanOffset);189 strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG); 190 } 191 192 if (MinBadQF > 0.0) strextend (&command, "-min-bad-psfqf %f", MinBadQF); 193 if (MaxMeanOffset != 10.0) strextend (&command, "-max-mean-offset %f", MaxMeanOffset); 194 194 195 195 if (TimeSelect) { 196 196 char *tstart = ohana_sec_to_date (TSTART); 197 197 char *tstop = ohana_sec_to_date (TSTOP); 198 strextend ( command, "-time %s %s", tstart, tstop);198 strextend (&command, "-time %s %s", tstart, tstop); 199 199 free (tstart); 200 200 free (tstop); … … 270 270 // MaxDensityUse, MaxDensityValue 271 271 272 char command[1024];273 s nprintf (command, 1024, "relastro_client -update-offsets -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -minerror %f",272 char *command = NULL; 273 strextend (&command, "relastro_client -update-offsets -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -minerror %f", 274 274 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, MIN_ERROR); 275 275 276 if (FIT_MODE == FIT_PM_ONLY) strextend ( command, "-pm");277 if (FIT_MODE == FIT_PAR_ONLY) strextend ( command, "-par");278 if (FIT_MODE == FIT_PM_AND_PAR) strextend ( command, "-pmpar");279 280 if (VERBOSE) strextend ( command, "-v");281 if (VERBOSE2) strextend ( command, "-vv");282 if (RESET) strextend ( command, "-reset");283 if (UPDATE) strextend ( command, "-update");284 285 if (RESET_BAD_IMAGES) strextend ( command, "-reset-bad-images");286 287 if (ImagSelect) strextend ( command, "-instmag %f %f", ImagMin, ImagMax);288 if (MaxDensityUse) strextend ( command, "-max-density %f", MaxDensityValue);289 290 if (USE_BASIC_CHECK) strextend ( command, "-basic-image-search");291 if (FlagOutlier) strextend ( command, "-clip %d", CLIP_THRESH);292 if (ExcludeBogus) strextend ( command, "-exclude-bogus %f", ExcludeBogusRadius);293 294 if (USE_FIXED_PIXCOORDS) strextend ( command, "-D USE_FIXED_PIXCOORDS 1");295 296 if (PHOTCODE_KEEP_LIST) strextend ( command, "+photcode %s", PHOTCODE_KEEP_LIST);297 if (PHOTCODE_SKIP_LIST) strextend ( command, "-photcode %s", PHOTCODE_SKIP_LIST);298 if (PhotFlagSelect) strextend ( command, "+photflags");299 if (PhotFlagBad) strextend ( command, "+photflagbad %d", PhotFlagBad);300 if (PhotFlagPoor) strextend ( command, "+photflagpoor %d", PhotFlagPoor);276 if (FIT_MODE == FIT_PM_ONLY) strextend (&command, "-pm"); 277 if (FIT_MODE == FIT_PAR_ONLY) strextend (&command, "-par"); 278 if (FIT_MODE == FIT_PM_AND_PAR) strextend (&command, "-pmpar"); 279 280 if (VERBOSE) strextend (&command, "-v"); 281 if (VERBOSE2) strextend (&command, "-vv"); 282 if (RESET) strextend (&command, "-reset"); 283 if (UPDATE) strextend (&command, "-update"); 284 285 if (RESET_BAD_IMAGES) strextend (&command, "-reset-bad-images"); 286 287 if (ImagSelect) strextend (&command, "-instmag %f %f", ImagMin, ImagMax); 288 if (MaxDensityUse) strextend (&command, "-max-density %f", MaxDensityValue); 289 290 if (USE_BASIC_CHECK) strextend (&command, "-basic-image-search"); 291 if (FlagOutlier) strextend (&command, "-clip %d", CLIP_THRESH); 292 if (ExcludeBogus) strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius); 293 294 if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1"); 295 296 if (PHOTCODE_KEEP_LIST) strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST); 297 if (PHOTCODE_SKIP_LIST) strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST); 298 if (PhotFlagSelect) strextend (&command, "+photflags"); 299 if (PhotFlagBad) strextend (&command, "+photflagbad %d", PhotFlagBad); 300 if (PhotFlagPoor) strextend (&command, "+photflagpoor %d", PhotFlagPoor); 301 301 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 302 302 303 303 if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) { 304 strextend ( command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);304 strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG); 305 305 } 306 306 if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) { 307 strextend ( command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);308 } 309 310 if (MinBadQF > 0.0) strextend ( command, "-min-bad-psfqf %f", MinBadQF);311 if (MaxMeanOffset != 10.0) strextend ( command, "-max-mean-offset %f", MaxMeanOffset);307 strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG); 308 } 309 310 if (MinBadQF > 0.0) strextend (&command, "-min-bad-psfqf %f", MinBadQF); 311 if (MaxMeanOffset != 10.0) strextend (&command, "-max-mean-offset %f", MaxMeanOffset); 312 312 313 313 if (TimeSelect) { 314 314 char *tstart = ohana_sec_to_date (TSTART); 315 315 char *tstop = ohana_sec_to_date (TSTOP); 316 strextend ( command, "-time %s %s", tstart, tstop);316 strextend (&command, "-time %s %s", tstart, tstop); 317 317 free (tstart); 318 318 free (tstop); -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/args.c
r37807 r38447 959 959 } 960 960 961 int strextend (char *input, char *format,...) {962 963 char tmpextra[1024], tmpline[1024];964 va_list argp;965 966 va_start (argp, format);967 vsnprintf (tmpextra, 1024, format, argp);968 snprintf (tmpline, 1024, "%s %s", input, tmpextra);969 strcpy (input, tmpline);970 971 return TRUE;972 } -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/assign_images.c
r37807 r38447 11 11 // convert database table to internal structure (binary to Image) 12 12 // 'image' points to the same memory as db->ftable->buffer 13 Image *image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);13 Image *image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 14 14 if (!image) { 15 15 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/bcatalog.c
r37807 r38447 521 521 subcatalog[0].Nmeasure = Nmeasure; 522 522 subcatalog[0].Nsecfilt = oldcatalog[0].Nsecfilt; 523 subcatalog[0].Nsecf _mem = Naverage * oldcatalog[0].Nsecfilt;523 subcatalog[0].Nsecfilt_mem = Naverage * oldcatalog[0].Nsecfilt; 524 524 525 525 return (TRUE); … … 628 628 subcatalog[0].Nmeasure = Nmeasure; 629 629 subcatalog[0].Nsecfilt = oldcatalog[0].Nsecfilt; 630 subcatalog[0].Nsecf _mem = Naverage * oldcatalog[0].Nsecfilt;630 subcatalog[0].Nsecfilt_mem = Naverage * oldcatalog[0].Nsecfilt; 631 631 632 632 return (TRUE); … … 722 722 subcatalog[0].Nmeasure = Nmeasure; 723 723 subcatalog[0].Nsecfilt = catalog[0].Nsecfilt; 724 subcatalog[0].Nsecf _mem = Naverage * catalog[0].Nsecfilt;724 subcatalog[0].Nsecfilt_mem = Naverage * catalog[0].Nsecfilt; 725 725 726 726 return (TRUE); -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/high_speed_catalogs.c
r35763 r38447 31 31 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 32 32 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 33 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;33 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 34 34 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 35 35 … … 38 38 exit (1); 39 39 } 40 if (!catalog.Nave s_disk) {40 if (!catalog.Naverage_disk) { 41 41 if (VERBOSE2) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 42 42 dvo_catalog_unlock (&catalog); … … 147 147 } 148 148 149 char command[1024];150 s nprintf (command, 1024, "relastro_client -high-speed %s %s %f %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f",149 char *command = NULL; 150 strextend (&command, "relastro_client -high-speed %s %s %f %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f", 151 151 PHOTCODE_A_LIST, PHOTCODE_B_LIST, RADIUS, outputDir, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 152 152 … … 154 154 155 155 // options / arguments that can affect relastro_client -high-speed 156 char tmpline[1024]; 157 if (FIT_MODE == FIT_PM_ONLY) { snprintf (tmpline, 1024, "%s -pm", command); strcpy (command, tmpline); } 158 if (FIT_MODE == FIT_PAR_ONLY) { snprintf (tmpline, 1024, "%s -par", command); strcpy (command, tmpline); } 159 if (FIT_MODE == FIT_PM_AND_PAR) { snprintf (tmpline, 1024, "%s -pmpar", command); strcpy (command, tmpline); } 160 161 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 162 if (VERBOSE2) { snprintf (tmpline, 1024, "%s -vv", command); strcpy (command, tmpline); } 163 if (RESET) { snprintf (tmpline, 1024, "%s -reset", command); strcpy (command, tmpline); } 164 if (ImagSelect) { snprintf (tmpline, 1024, "%s -instmag %f %f", command, ImagMin, ImagMax); strcpy (command, tmpline); } 165 if (MaxDensityUse) { snprintf (tmpline, 1024, "%s -max-density %f", command, MaxDensityValue); strcpy (command, tmpline); } 156 if (FIT_MODE == FIT_PM_ONLY) { strextend (&command, "-pm"); } 157 if (FIT_MODE == FIT_PAR_ONLY) { strextend (&command, "-par"); } 158 if (FIT_MODE == FIT_PM_AND_PAR) { strextend (&command, "-pmpar"); } 159 160 if (VERBOSE) { strextend (&command, "-v"); } 161 if (VERBOSE2) { strextend (&command, "-vv"); } 162 if (RESET) { strextend (&command, "-reset"); } 163 if (ImagSelect) { strextend (&command, "-instmag %f %f", ImagMin, ImagMax); } 164 if (MaxDensityUse) { strextend (&command, "-max-density %f", MaxDensityValue); } 166 165 167 if (USE_BASIC_CHECK) { snprintf (tmpline, 1024, "%s -basic-image-search", command); strcpy (command, tmpline); } 168 169 if (FlagOutlier) { snprintf (tmpline, 1024, "%s -clip %d", command, CLIP_THRESH); strcpy (command, tmpline); } 170 171 if (USE_FIXED_PIXCOORDS) { snprintf (tmpline, 1024, "%s -D USE_FIXED_PIXCOORDS 1", command); strcpy (command, tmpline); } 172 173 if (PHOTCODE_KEEP_LIST) { snprintf (tmpline, 1024, "%s +photcode %s", command, PHOTCODE_KEEP_LIST); strcpy (command, tmpline); } 174 if (PHOTCODE_SKIP_LIST) { snprintf (tmpline, 1024, "%s -photcode %s", command, PHOTCODE_SKIP_LIST); strcpy (command, tmpline); } 175 if (PhotFlagSelect) { snprintf (tmpline, 1024, "%s +photflags", command); strcpy (command, tmpline); } 176 if (PhotFlagBad) { snprintf (tmpline, 1024, "%s +photflagbad %d", command, PhotFlagBad); strcpy (command, tmpline); } 177 if (PhotFlagPoor) { snprintf (tmpline, 1024, "%s +photflagpoor %d", command, PhotFlagPoor); strcpy (command, tmpline); } 166 if (USE_BASIC_CHECK) { strextend (&command, "-basic-image-search"); } 167 if (FlagOutlier) { strextend (&command, "-clip %d", CLIP_THRESH); } 168 if (USE_FIXED_PIXCOORDS) { strextend (&command, "-D USE_FIXED_PIXCOORDS 1"); } 169 if (PHOTCODE_KEEP_LIST) { strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST); } 170 if (PHOTCODE_SKIP_LIST) { strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST); } 171 if (PhotFlagSelect) { strextend (&command, "+photflags"); } 172 if (PhotFlagBad) { strextend (&command, "+photflagbad %d", PhotFlagBad); } 173 if (PhotFlagPoor) { strextend (&command, "+photflagpoor %d", PhotFlagPoor); } 178 174 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 179 175 180 if (MinBadQF > 0.0) { snprintf (tmpline, 1024, "%s -min-bad-psfqf %f", command, MinBadQF); strcpy (command, tmpline); }181 if (MaxMeanOffset != 10.0) { s nprintf (tmpline, 1024, "%s -max-mean-offset %f", command, MaxMeanOffset); strcpy (command, tmpline); }182 183 if (WHERE_A[0]) { s nprintf (tmpline, 1024, "%s -D WHERE_A \"%s\"", command, WHERE_A); strcpy (command, tmpline); }184 if (WHERE_B[0]) { s nprintf (tmpline, 1024, "%s -D WHERE_B \"%s\"", command, WHERE_B); strcpy (command, tmpline); }176 if (MinBadQF > 0.0) { strextend (&command, "-min-bad-psfqf %f", MinBadQF); } 177 if (MaxMeanOffset != 10.0) { strextend (&command, "-max-mean-offset %f", MaxMeanOffset); } 178 179 if (WHERE_A[0]) { strextend (&command, "-D WHERE_A \"%s\"", WHERE_A); } 180 if (WHERE_B[0]) { strextend (&command, "-D WHERE_B \"%s\"", WHERE_B); } 185 181 186 182 if (TimeSelect) { 187 183 char *tstart = ohana_sec_to_date (TSTART); 188 184 char *tstop = ohana_sec_to_date (TSTOP); 189 s nprintf (tmpline, 1024, "%s -time %s %s", command, tstart, tstop);185 strextend (&command, "-time %s %s", tstart, tstop); 190 186 free (tstart); 191 187 free (tstop); 192 strcpy (command, tmpline);193 188 } 194 189 -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/high_speed_objects.c
r37807 r38447 32 32 catalogOut.filename = filename; // based on the input name, need to keep everything below the catdir portion 33 33 catalogOut.Nsecfilt = Nsecfilt; 34 catalogOut.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; // load all data34 catalogOut.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; // load all data 35 35 36 36 catalogOut.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data … … 263 263 catalogOut.Nmeasure=Nmatchmeas; 264 264 catalogOut.Nsecfilt=Nsecfilt; 265 catalogOut.Nsecf _mem=Nmatch*Nsecfilt;265 catalogOut.Nsecfilt_mem=Nmatch*Nsecfilt; 266 266 267 267 populate_tiny_values (&catalogOut, DVO_TV_MEASURE); -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/hpm_catalogs.c
r35763 r38447 29 29 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 30 30 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 31 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;31 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 32 32 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 33 33 … … 36 36 exit (1); 37 37 } 38 if (!catalog.Nave s_disk) {38 if (!catalog.Naverage_disk) { 39 39 if (VERBOSE2) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 40 40 dvo_catalog_unlock (&catalog); … … 145 145 } 146 146 147 char command[1024];148 s nprintf (command, 1024, "relastro_client -hpm %f %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f",147 char *command = NULL; 148 strextend (&command, "relastro_client -hpm %f %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f", 149 149 RADIUS, outputDir, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 150 150 … … 152 152 153 153 // options / arguments that can affect relastro_client -high-speed 154 char tmpline[1024]; 155 if (FIT_MODE == FIT_PM_ONLY) { snprintf (tmpline, 1024, "%s -pm", command); strcpy (command, tmpline); } 156 if (FIT_MODE == FIT_PAR_ONLY) { snprintf (tmpline, 1024, "%s -par", command); strcpy (command, tmpline); } 157 if (FIT_MODE == FIT_PM_AND_PAR) { snprintf (tmpline, 1024, "%s -pmpar", command); strcpy (command, tmpline); } 158 159 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 160 if (VERBOSE2) { snprintf (tmpline, 1024, "%s -vv", command); strcpy (command, tmpline); } 161 if (RESET) { snprintf (tmpline, 1024, "%s -reset", command); strcpy (command, tmpline); } 162 if (ImagSelect) { snprintf (tmpline, 1024, "%s -instmag %f %f", command, ImagMin, ImagMax); strcpy (command, tmpline); } 163 if (MaxDensityUse) { snprintf (tmpline, 1024, "%s -max-density %f", command, MaxDensityValue); strcpy (command, tmpline); } 154 if (FIT_MODE == FIT_PM_ONLY) { strextend (&command, "-pm"); } 155 if (FIT_MODE == FIT_PAR_ONLY) { strextend (&command, "-par"); } 156 if (FIT_MODE == FIT_PM_AND_PAR) { strextend (&command, "-pmpar"); } 157 158 if (VERBOSE) { strextend (&command, "-v"); } 159 if (VERBOSE2) { strextend (&command, "-vv"); } 160 if (RESET) { strextend (&command, "-reset"); } 161 if (ImagSelect) { strextend (&command, "-instmag %f %f", ImagMin, ImagMax); } 162 if (MaxDensityUse) { strextend (&command, "-max-density %f", MaxDensityValue); } 164 163 165 if (USE_BASIC_CHECK) { snprintf (tmpline, 1024, "%s -basic-image-search", command); strcpy (command, tmpline); } 166 167 if (FlagOutlier) { snprintf (tmpline, 1024, "%s -clip %d", command, CLIP_THRESH); strcpy (command, tmpline); } 168 169 if (USE_FIXED_PIXCOORDS) { snprintf (tmpline, 1024, "%s -D USE_FIXED_PIXCOORDS 1", command); strcpy (command, tmpline); } 170 171 if (PHOTCODE_KEEP_LIST) { snprintf (tmpline, 1024, "%s +photcode %s", command, PHOTCODE_KEEP_LIST); strcpy (command, tmpline); } 172 if (PHOTCODE_SKIP_LIST) { snprintf (tmpline, 1024, "%s -photcode %s", command, PHOTCODE_SKIP_LIST); strcpy (command, tmpline); } 173 if (PhotFlagSelect) { snprintf (tmpline, 1024, "%s +photflags", command); strcpy (command, tmpline); } 174 if (PhotFlagBad) { snprintf (tmpline, 1024, "%s +photflagbad %d", command, PhotFlagBad); strcpy (command, tmpline); } 175 if (PhotFlagPoor) { snprintf (tmpline, 1024, "%s +photflagpoor %d", command, PhotFlagPoor); strcpy (command, tmpline); } 164 if (USE_BASIC_CHECK) { strextend (&command, "-basic-image-search"); } 165 if (FlagOutlier) { strextend (&command, "-clip %d", CLIP_THRESH); } 166 if (USE_FIXED_PIXCOORDS) { strextend (&command, "-D USE_FIXED_PIXCOORDS 1"); } 167 if (PHOTCODE_KEEP_LIST) { strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST); } 168 if (PHOTCODE_SKIP_LIST) { strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST); } 169 if (PhotFlagSelect) { strextend (&command, "+photflags"); } 170 if (PhotFlagBad) { strextend (&command, "+photflagbad %d", PhotFlagBad); } 171 if (PhotFlagPoor) { strextend (&command, "+photflagpoor %d", PhotFlagPoor); } 176 172 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 177 173 178 if (MinBadQF > 0.0) { snprintf (tmpline, 1024, "%s -min-bad-psfqf %f", command, MinBadQF); strcpy (command, tmpline); }179 if (MaxMeanOffset != 10.0) { s nprintf (tmpline, 1024, "%s -max-mean-offset %f", command, MaxMeanOffset); strcpy (command, tmpline); }174 if (MinBadQF > 0.0) { strextend (&command, "-min-bad-psfqf %f", MinBadQF); } 175 if (MaxMeanOffset != 10.0) { strextend (&command, "-max-mean-offset %f", MaxMeanOffset); } 180 176 181 177 if (TimeSelect) { 182 178 char *tstart = ohana_sec_to_date (TSTART); 183 179 char *tstop = ohana_sec_to_date (TSTOP); 184 s nprintf (tmpline, 1024, "%s -time %s %s", command, tstart, tstop);180 strextend (&command, "-time %s %s", tstart, tstop); 185 181 free (tstart); 186 182 free (tstop); 187 strcpy (command, tmpline);188 183 } 189 184 -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/hpm_objects.c
r37807 r38447 33 33 catalogOut.filename = filename; 34 34 catalogOut.Nsecfilt = Nsecfilt; 35 catalogOut.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; // load all data35 catalogOut.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; // load all data 36 36 37 37 catalogOut.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data … … 279 279 } 280 280 catalogOut.Nsecfilt = Nsecfilt; 281 catalogOut.Nsecf _mem = Nsecfilt * catalogOut.Naverage;281 catalogOut.Nsecfilt_mem = Nsecfilt * catalogOut.Naverage; 282 282 283 283 populate_tiny_values (&catalogOut, DVO_TV_MEASURE); -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/launch_region_hosts.c
r37807 r38447 77 77 } 78 78 79 char command[1024];80 s nprintf (command, 1024, "relastro -parallel-images %s", filename);81 strextend ( command, "-region-hosts %s", REGION_FILE);82 strextend ( command, "-region-hostID %d", host->hostID);83 strextend ( command, "-D CATDIR %s", CATDIR);84 strextend ( command, "-region %f %f %f %f", host->RminCat, host->RmaxCat, host->DminCat, host->DmaxCat);85 strextend ( command, "-statmode %s", STATMODE);86 strextend ( command, "-minerror %f", MIN_ERROR);87 strextend ( command, "-nloop %d", NLOOP);88 strextend ( command, "-threads %d", NTHREADS);79 char *command = NULL; 80 strextend (&command, "relastro -parallel-images %s", filename); 81 strextend (&command, "-region-hosts %s", REGION_FILE); 82 strextend (&command, "-region-hostID %d", host->hostID); 83 strextend (&command, "-D CATDIR %s", CATDIR); 84 strextend (&command, "-region %f %f %f %f", host->RminCat, host->RmaxCat, host->DminCat, host->DmaxCat); 85 strextend (&command, "-statmode %s", STATMODE); 86 strextend (&command, "-minerror %f", MIN_ERROR); 87 strextend (&command, "-nloop %d", NLOOP); 88 strextend (&command, "-threads %d", NTHREADS); 89 89 90 90 switch (FIT_TARGET) { 91 91 case TARGET_SIMPLE: 92 strextend ( command, "-update-simple");92 strextend (&command, "-update-simple"); 93 93 break; 94 94 case TARGET_CHIPS: 95 strextend ( command, "-update-chips");95 strextend (&command, "-update-chips"); 96 96 break; 97 97 case TARGET_MOSAICS: 98 strextend ( command, "-update-mosaics");98 strextend (&command, "-update-mosaics"); 99 99 break; 100 100 case TARGET_NONE: … … 102 102 } 103 103 104 if (VERBOSE) strextend ( command, "-v");105 if (VERBOSE2) strextend ( command, "-vv");106 if (RESET) strextend ( command, "-reset");107 if (UPDATE) strextend ( command, "-update");108 if (PARALLEL) strextend ( command, "-parallel");109 if (PARALLEL_MANUAL) strextend ( command, "-parallel-manual");110 if (PARALLEL_SERIAL) strextend ( command, "-parallel-serial");111 if (PHOTCODE_KEEP_LIST) strextend ( command, "+photcode %s", PHOTCODE_KEEP_LIST);112 if (PHOTCODE_SKIP_LIST) strextend ( command, "-photcode %s", PHOTCODE_SKIP_LIST);113 if (PHOTCODE_RESET_LIST) strextend ( command, "-reset-to-photcode %s", PHOTCODE_RESET_LIST);104 if (VERBOSE) strextend (&command, "-v"); 105 if (VERBOSE2) strextend (&command, "-vv"); 106 if (RESET) strextend (&command, "-reset"); 107 if (UPDATE) strextend (&command, "-update"); 108 if (PARALLEL) strextend (&command, "-parallel"); 109 if (PARALLEL_MANUAL) strextend (&command, "-parallel-manual"); 110 if (PARALLEL_SERIAL) strextend (&command, "-parallel-serial"); 111 if (PHOTCODE_KEEP_LIST) strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST); 112 if (PHOTCODE_SKIP_LIST) strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST); 113 if (PHOTCODE_RESET_LIST) strextend (&command, "-reset-to-photcode %s", PHOTCODE_RESET_LIST); 114 114 115 if (MaxDensityUse) strextend ( command, "-max-density %f", MaxDensityValue);116 if (ImagSelect) strextend ( command, "-instmag %f %f", ImagMin, ImagMax);117 if (ExcludeBogus) strextend ( command, "-exclude-bogus %f", ExcludeBogusRadius);115 if (MaxDensityUse) strextend (&command, "-max-density %f", MaxDensityValue); 116 if (ImagSelect) strextend (&command, "-instmag %f %f", ImagMin, ImagMax); 117 if (ExcludeBogus) strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius); 118 118 119 119 if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) { 120 strextend ( command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);120 strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG); 121 121 } 122 122 if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) { 123 strextend ( command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);123 strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG); 124 124 } 125 125 126 if (PhotFlagSelect) strextend ( command, "+photflags");127 if (PhotFlagBad) strextend ( command, "+photflagbad %d", PhotFlagBad);128 if (PhotFlagPoor) strextend ( command, "+photflagpoor %d", PhotFlagPoor);126 if (PhotFlagSelect) strextend (&command, "+photflags"); 127 if (PhotFlagBad) strextend (&command, "+photflagbad %d", PhotFlagBad); 128 if (PhotFlagPoor) strextend (&command, "+photflagpoor %d", PhotFlagPoor); 129 129 130 if (CHIPMAP) strextend ( command, "-chipmap %d", CHIPMAP);131 if (RESET_IMAGES) strextend ( command, "-reset-images");130 if (CHIPMAP) strextend (&command, "-chipmap %d", CHIPMAP); 131 if (RESET_IMAGES) strextend (&command, "-reset-images"); 132 132 133 if (MinBadQF > 0.0) strextend ( command, "-min-bad-psfqf %f", MinBadQF);134 if (MaxMeanOffset != 10.0) strextend ( command, "-max-mean-offset %f", MaxMeanOffset);133 if (MinBadQF > 0.0) strextend (&command, "-min-bad-psfqf %f", MinBadQF); 134 if (MaxMeanOffset != 10.0) strextend (&command, "-max-mean-offset %f", MaxMeanOffset); 135 135 136 strextend ( command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW);137 strextend ( command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM);138 strextend ( command, "-D RELASTRO_DPOS_MAX %f", DPOS_MAX);139 strextend ( command, "-D ADDSTAR_RADIUS %f", ADDSTAR_RADIUS);136 strextend (&command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW); 137 strextend (&command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM); 138 strextend (&command, "-D RELASTRO_DPOS_MAX %f", DPOS_MAX); 139 strextend (&command, "-D ADDSTAR_RADIUS %f", ADDSTAR_RADIUS); 140 140 141 strextend ( command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL);141 strextend (&command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL); 142 142 143 strextend ( command, "-D USE_ICRF_CORRECT %d", USE_ICRF_CORRECT);144 strextend ( command, "-D USE_ICRF_LOCAL %d", USE_ICRF_LOCAL);145 strextend ( command, "-D USE_ICRF_SHFIT %d", USE_ICRF_SHFIT);146 strextend ( command, "-D USE_ICRF_POLE %d", USE_ICRF_POLE);143 strextend (&command, "-D USE_ICRF_CORRECT %d", USE_ICRF_CORRECT); 144 strextend (&command, "-D USE_ICRF_LOCAL %d", USE_ICRF_LOCAL); 145 strextend (&command, "-D USE_ICRF_SHFIT %d", USE_ICRF_SHFIT); 146 strextend (&command, "-D USE_ICRF_POLE %d", USE_ICRF_POLE); 147 147 148 if (USE_FIXED_PIXCOORDS) strextend ( command, "-D USE_FIXED_PIXCOORDS 1");148 if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1"); 149 149 150 150 if (TimeSelect) { 151 151 char *tstart = ohana_sec_to_date (TSTART); 152 152 char *tstop = ohana_sec_to_date (TSTOP); 153 strextend ( command, "-time %s %s", tstart, tstop);153 strextend (&command, "-time %s %s", tstart, tstop); 154 154 free (tstart); 155 155 free (tstop); -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/load_catalogs.c
r38062 r38447 40 40 pcatalog->catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 41 41 pcatalog->catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 42 pcatalog->catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF; // don't need to load all data at this point42 pcatalog->catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; // don't need to load all data at this point 43 43 pcatalog->Nsecfilt = GetPhotcodeNsecfilt (); 44 44 … … 48 48 exit (1); 49 49 } 50 if (!pcatalog[0].Nave s_disk) {50 if (!pcatalog[0].Naverage_disk) { 51 51 if (VERBOSE2) fprintf (stderr, "no data in %s, skipping\n", pcatalog[0].filename); 52 52 dvo_catalog_unlock (pcatalog); … … 160 160 // MaxDensityUse, MaxDensityValue 161 161 162 char command[1024];163 s nprintf (command, 1024, "relastro_client -load-objects %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -minerror %f -D RELASTRO_SIGMA_LIM %f",162 char *command = NULL; 163 strextend (&command, "relastro_client -load-objects %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -minerror %f -D RELASTRO_SIGMA_LIM %f", 164 164 table->hosts[i].results, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, MIN_ERROR, SIGMA_LIM); 165 165 166 if (FIT_MODE == FIT_PM_ONLY) strextend ( command, "-pm");167 if (FIT_MODE == FIT_PAR_ONLY) strextend ( command, "-par");168 if (FIT_MODE == FIT_PM_AND_PAR) strextend ( command, "-pmpar");169 170 if (VERBOSE) strextend ( command, "-v");171 if (VERBOSE2) strextend ( command, "-vv");172 if (RESET) strextend ( command, "-reset");173 if (ImagSelect) strextend ( command, "-instmag %f %f", ImagMin, ImagMax);174 if (MaxDensityUse) strextend ( command, "-max-density %f", MaxDensityValue);175 if (FlagOutlier) strextend ( command, "-clip %d", CLIP_THRESH);176 if (ExcludeBogus) strextend ( command, "-exclude-bogus %f", ExcludeBogusRadius);177 178 if (USE_ICRF_CORRECT) strextend ( command, "-D USE_ICRF_CORRECT %d", USE_ICRF_CORRECT);179 if (USE_GALAXY_MODEL) strextend ( command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL);166 if (FIT_MODE == FIT_PM_ONLY) strextend (&command, "-pm"); 167 if (FIT_MODE == FIT_PAR_ONLY) strextend (&command, "-par"); 168 if (FIT_MODE == FIT_PM_AND_PAR) strextend (&command, "-pmpar"); 169 170 if (VERBOSE) strextend (&command, "-v"); 171 if (VERBOSE2) strextend (&command, "-vv"); 172 if (RESET) strextend (&command, "-reset"); 173 if (ImagSelect) strextend (&command, "-instmag %f %f", ImagMin, ImagMax); 174 if (MaxDensityUse) strextend (&command, "-max-density %f", MaxDensityValue); 175 if (FlagOutlier) strextend (&command, "-clip %d", CLIP_THRESH); 176 if (ExcludeBogus) strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius); 177 178 if (USE_ICRF_CORRECT) strextend (&command, "-D USE_ICRF_CORRECT %d", USE_ICRF_CORRECT); 179 if (USE_GALAXY_MODEL) strextend (&command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL); 180 180 181 181 if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) { 182 strextend ( command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);182 strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG); 183 183 } 184 184 if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) { 185 strextend ( command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);186 } 187 188 if (USE_FIXED_PIXCOORDS) strextend ( command, "-D USE_FIXED_PIXCOORDS 1");189 if (PHOTCODE_KEEP_LIST) strextend ( command, "+photcode %s", PHOTCODE_KEEP_LIST);190 if (PHOTCODE_SKIP_LIST) strextend ( command, "-photcode %s", PHOTCODE_SKIP_LIST);191 if (PhotFlagSelect) strextend ( command, "+photflags");192 if (PhotFlagBad) strextend ( command, "+photflagbad %d", PhotFlagBad);193 if (PhotFlagPoor) strextend ( command, "+photflagpoor %d", PhotFlagPoor);185 strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG); 186 } 187 188 if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1"); 189 if (PHOTCODE_KEEP_LIST) strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST); 190 if (PHOTCODE_SKIP_LIST) strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST); 191 if (PhotFlagSelect) strextend (&command, "+photflags"); 192 if (PhotFlagBad) strextend (&command, "+photflagbad %d", PhotFlagBad); 193 if (PhotFlagPoor) strextend (&command, "+photflagpoor %d", PhotFlagPoor); 194 194 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 195 195 … … 197 197 char *tstart = ohana_sec_to_date (TSTART); 198 198 char *tstop = ohana_sec_to_date (TSTOP); 199 strextend ( command, "-time %s %s", tstart, tstop);199 strextend (&command, "-time %s %s", tstart, tstop); 200 200 free (tstart); 201 201 free (tstop); -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/load_images.c
r37807 r38447 16 16 17 17 // convert database table to internal structure 18 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);18 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 19 19 if (!image) { 20 20 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/relastro_client.c
r37807 r38447 69 69 70 70 set_db (&db); 71 gfits_db_init (&db); 71 72 72 73 /* lock and load the image db table */ -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/relastro_images.c
r37807 r38447 11 11 /* register database handle with shutdown procedure */ 12 12 set_db (&db); 13 gfits_db_init (&db); 13 14 14 15 /* lock and load the image db table */ -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/relastro_merge_source.c
r37038 r38447 45 45 catalog_src.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 46 46 catalog_src.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 47 catalog_src.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;47 catalog_src.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 48 48 catalog_src.Nsecfilt = GetPhotcodeNsecfilt (); 49 49 … … 52 52 exit (1); 53 53 } 54 if (!catalog_src.Nave s_disk) {54 if (!catalog_src.Naverage_disk) { 55 55 fprintf (stderr, "no data in %s, error in cat ID?\n", catalog_src.filename); 56 56 exit (1); -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/relastro_objects.c
r37807 r38447 44 44 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 45 45 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 46 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;46 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 47 47 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 48 48 … … 52 52 exit (1); 53 53 } 54 if (!catalog.Nave s_disk) {54 if (!catalog.Naverage_disk) { 55 55 if (VERBOSE2) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 56 56 dvo_catalog_unlock (&catalog); … … 147 147 // SRC_MEAS_TOOFEW 148 148 149 char command[1024];150 s nprintf (command, 1024, "relastro_client -update-objects -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s",149 char *command = NULL; 150 strextend (&command, "relastro_client -update-objects -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s", 151 151 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE); 152 152 153 char tmpline[1024]; 154 if (FIT_MODE == FIT_PM_ONLY) { snprintf (tmpline, 1024, "%s -pm", command); strcpy (command, tmpline); } 155 if (FIT_MODE == FIT_PAR_ONLY) { snprintf (tmpline, 1024, "%s -par", command); strcpy (command, tmpline); } 156 if (FIT_MODE == FIT_PM_AND_PAR) { snprintf (tmpline, 1024, "%s -pmpar", command); strcpy (command, tmpline); } 157 158 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 159 if (VERBOSE2) { snprintf (tmpline, 1024, "%s -vv", command); strcpy (command, tmpline); } 160 if (RESET) { snprintf (tmpline, 1024, "%s -reset", command); strcpy (command, tmpline); } 161 if (UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); } 162 163 if (ImagSelect) { snprintf (tmpline, 1024, "%s -instmag %f %f", command, ImagMin, ImagMax); strcpy (command, tmpline); } 164 if (MaxDensityUse) { snprintf (tmpline, 1024, "%s -max-density %f", command, MaxDensityValue); strcpy (command, tmpline); } 165 166 if (FlagOutlier) { snprintf (tmpline, 1024, "%s -clip %d", command, CLIP_THRESH); strcpy (command, tmpline); } 167 168 if (USE_FIXED_PIXCOORDS) { snprintf (tmpline, 1024, "%s -D USE_FIXED_PIXCOORDS 1", command); strcpy (command, tmpline); } 169 170 if (PHOTCODE_KEEP_LIST) { snprintf (tmpline, 1024, "%s +photcode %s", command, PHOTCODE_KEEP_LIST); strcpy (command, tmpline); } 171 if (PHOTCODE_SKIP_LIST) { snprintf (tmpline, 1024, "%s -photcode %s", command, PHOTCODE_SKIP_LIST); strcpy (command, tmpline); } 172 if (PhotFlagSelect) { snprintf (tmpline, 1024, "%s +photflags", command); strcpy (command, tmpline); } 173 if (PhotFlagBad) { snprintf (tmpline, 1024, "%s +photflagbad %d", command, PhotFlagBad); strcpy (command, tmpline); } 174 if (PhotFlagPoor) { snprintf (tmpline, 1024, "%s +photflagpoor %d", command, PhotFlagPoor); strcpy (command, tmpline); } 153 if (FIT_MODE == FIT_PM_ONLY) { strextend (&command, "-pm"); } 154 if (FIT_MODE == FIT_PAR_ONLY) { strextend (&command, "-par"); } 155 if (FIT_MODE == FIT_PM_AND_PAR) { strextend (&command, "-pmpar"); } 156 157 if (VERBOSE) { strextend (&command, "-v"); } 158 if (VERBOSE2) { strextend (&command, "-vv"); } 159 if (RESET) { strextend (&command, "-reset"); } 160 if (UPDATE) { strextend (&command, "-update"); } 161 if (ImagSelect) { strextend (&command, "-instmag %f %f", ImagMin, ImagMax); } 162 if (MaxDensityUse) { strextend (&command, "-max-density %f", MaxDensityValue); } 163 if (FlagOutlier) { strextend (&command, "-clip %d", CLIP_THRESH); } 164 if (USE_FIXED_PIXCOORDS) { strextend (&command, "-D USE_FIXED_PIXCOORDS 1"); } 165 if (PHOTCODE_KEEP_LIST) { strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST); } 166 if (PHOTCODE_SKIP_LIST) { strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST); } 167 if (PhotFlagSelect) { strextend (&command, "+photflags"); } 168 if (PhotFlagBad) { strextend (&command, "+photflagbad %d", PhotFlagBad); } 169 if (PhotFlagPoor) { strextend (&command, "+photflagpoor %d", PhotFlagPoor); } 175 170 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 176 171 177 if (MinBadQF > 0.0) { snprintf (tmpline, 1024, "%s -min-bad-psfqf %f", command, MinBadQF); strcpy (command, tmpline); }178 if (MaxMeanOffset != 10.0) { s nprintf (tmpline, 1024, "%s -max-mean-offset %f", command, MaxMeanOffset); strcpy (command, tmpline); }172 if (MinBadQF > 0.0) { strextend (&command, "-min-bad-psfqf %f", MinBadQF); } 173 if (MaxMeanOffset != 10.0) { strextend (&command, "-max-mean-offset %f", MaxMeanOffset); } 179 174 180 175 if (TimeSelect) { 181 176 char *tstart = ohana_sec_to_date (TSTART); 182 177 char *tstop = ohana_sec_to_date (TSTOP); 183 s nprintf (tmpline, 1024, "%s -time %s %s", command, tstart, tstop);178 strextend (&command, "-time %s %s", tstart, tstop); 184 179 free (tstart); 185 180 free (tstop); 186 strcpy (command, tmpline);187 181 } 188 182 -
branches/eam_branches/ipp-20150419/Ohana/src/relastro/src/relastro_parallel_regions.c
r37807 r38447 17 17 // register database handle with shutdown procedure 18 18 set_db (&db); 19 gfits_db_init (&db); 19 20 db.mode = dvo_catalog_catmode (CATMODE); 20 21 db.format = dvo_catalog_catformat (CATFORMAT); -
branches/eam_branches/ipp-20150419/Ohana/src/tools/src/fields.c
r27491 r38447 66 66 GotFile = TRUE; 67 67 GotField &= print_fields (filename, NULL, &header, argc, argv); 68 GotExtension = TRUE; 68 69 continue; 69 70 } … … 72 73 GotFile = TRUE; 73 74 GotField &= print_fields (filename, NULL, &header, argc, argv); 75 GotExtension = TRUE; 74 76 continue; 75 77 } -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/find_image_sgroups.c
r37807 r38447 12 12 13 13 imlink = *Imlink; 14 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);14 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 15 15 if (!image) { 16 16 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/find_image_tgroups.c
r31160 r38447 11 11 ImageLink *imlink; 12 12 13 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);13 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 14 14 if (!image) { 15 15 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/fiximids.c
r35764 r38447 11 11 12 12 set_db (&db); 13 gfits_db_init (&db); 13 14 status = dvo_image_lock (&db, ImageCat, 60.0, (UPDATE ? LCK_XCLD : LCK_SOFT)); 14 15 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/fixstkids.c
r35764 r38447 11 11 12 12 set_db (&db); 13 gfits_db_init (&db); 13 14 status = dvo_image_lock (&db, ImageCat, 60.0, (UPDATE ? LCK_XCLD : LCK_SOFT)); 14 15 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/load_images.c
r33654 r38447 21 21 22 22 /* use a vtable to keep the images to be calibrated */ 23 image = gfits_table_get_Image (&db[0].ftable, Nimage, &db[0].s wapped);23 image = gfits_table_get_Image (&db[0].ftable, Nimage, &db[0].scaledValue, &db[0].nativeOrder); 24 24 if (!image) { 25 25 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/load_images_fiximids.c
r37043 r38447 20 20 21 21 /* use a vtable to keep the images to be calibrated */ 22 image = gfits_table_get_Image (&db[0].ftable, Nimage_load, &db[0].s wapped);22 image = gfits_table_get_Image (&db[0].ftable, Nimage_load, &db[0].scaledValue, &db[0].nativeOrder); 23 23 if (!image) { 24 24 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/load_images_fixstkids.c
r37043 r38447 19 19 20 20 /* use a vtable to keep the images to be calibrated */ 21 image = gfits_table_get_Image (&db[0].ftable, Nimage_load, &db[0].s wapped);21 image = gfits_table_get_Image (&db[0].ftable, Nimage_load, &db[0].scaledValue, &db[0].nativeOrder); 22 22 if (!image) { 23 23 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/load_images_setphot.c
r33654 r38447 11 11 12 12 /* use a vtable to keep the images to be calibrated */ 13 image = gfits_table_get_Image (&db[0].ftable, Nimage, &db[0].s wapped);13 image = gfits_table_get_Image (&db[0].ftable, Nimage, &db[0].scaledValue, &db[0].nativeOrder); 14 14 if (!image) { 15 15 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/load_images_setposangle.c
r34749 r38447 19 19 20 20 /* use a vtable to keep the images to be calibrated */ 21 image = gfits_table_get_Image (&db[0].ftable, Nimage, &db[0].s wapped);21 image = gfits_table_get_Image (&db[0].ftable, Nimage, &db[0].scaledValue, &db[0].nativeOrder); 22 22 if (!image) { 23 23 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/setfwhm.c
r33654 r38447 13 13 14 14 set_db (&db); 15 gfits_db_init (&db); 15 16 status = dvo_image_lock (&db, ImageCat, 60.0, (UPDATE ? LCK_XCLD : LCK_SOFT)); 16 17 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/setphot.c
r38299 r38447 14 14 15 15 set_db (&db); 16 gfits_db_init (&db); 16 17 status = dvo_image_lock (&db, ImageCat, 60.0, (UPDATE ? LCK_XCLD : LCK_SOFT)); 17 18 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/setposangle.c
r34749 r38447 11 11 12 12 set_db (&db); 13 gfits_db_init (&db); 13 14 status = dvo_image_lock (&db, ImageCat, 60.0, (UPDATE ? LCK_XCLD : LCK_SOFT)); 14 15 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/subset_images.c
r31160 r38447 8 8 9 9 // convert from the binary I/O format to the internal structure (Image) 10 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);10 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 11 11 if (!image) { 12 12 fprintf (stderr, "ERROR: failed to read images\n"); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/uniphot.c
r33654 r38447 19 19 20 20 set_db (&db); 21 gfits_db_init (&db); 21 22 status = dvo_image_lock (&db, ImageCat, 60.0, (UPDATE ? LCK_XCLD : LCK_SOFT)); 22 23 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/update_dvo_ckids.c
r35764 r38447 46 46 catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs 47 47 catalog.catmode = DVO_MODE_UNDEF; // not needed since we skip empty catalogs 48 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;48 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 49 49 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 50 50 … … 53 53 exit (1); 54 54 } 55 if (!catalog.Nave s_disk) {55 if (!catalog.Naverage_disk) { 56 56 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 57 57 dvo_catalog_unlock (&catalog); … … 111 111 table->hosts[i].pathname = tmppath; 112 112 113 char command[1024];114 s nprintf (command, 1024, "ckids_client -hostID %d -catdir %s -hostdir %s -region %f %f %f %f",113 char *command = NULL; 114 strextend (&command, "ckids_client -hostID %d -catdir %s -hostdir %s -region %f %f %f %f", 115 115 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, 116 116 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 117 117 118 char tmpline[1024]; 119 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 120 if (SINGLE_CPT) { snprintf (tmpline, 1024, "%s -cpt %s", command, SINGLE_CPT); strcpy (command, tmpline); } 121 if (UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); } 118 if (VERBOSE) { strextend (&command, "-v"); } 119 if (SINGLE_CPT) { strextend (&command, "-cpt %s", SINGLE_CPT); } 120 if (UPDATE) { strextend (&command, "-update"); } 122 121 123 122 fprintf (stderr, "command: %s\n", command); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/update_dvo_fiximids.c
r35764 r38447 41 41 catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs 42 42 catalog.catmode = DVO_MODE_UNDEF; // not needed since we skip empty catalogs 43 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;43 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 44 44 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 45 45 … … 48 48 exit (1); 49 49 } 50 if (!catalog.Nave s_disk) {50 if (!catalog.Naverage_disk) { 51 51 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 52 52 dvo_catalog_unlock (&catalog); … … 112 112 snprintf (table->hosts[i].results, 1024, "%s/fiximids.results.%s.dat", table->hosts[i].pathname, uniquer); 113 113 114 char command[1024];115 s nprintf (command, 1024, "fiximids_client -hostID %d -catdir %s -hostdir %s -images %s -region %f %f %f %f",114 char *command = NULL; 115 strextend (&command, "fiximids_client -hostID %d -catdir %s -hostdir %s -images %s -region %f %f %f %f", 116 116 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, imageFile, 117 117 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); … … 119 119 int saveImstats = VERBOSE_IMSTATS || SUMMARY_IMSTATS; 120 120 121 char tmpline[1024]; 122 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 123 if (saveImstats) { snprintf (tmpline, 1024, "%s -imstats %s", command, table->hosts[i].results); strcpy (command, tmpline); } 124 if (SINGLE_CPT) { snprintf (tmpline, 1024, "%s -cpt %s", command, SINGLE_CPT); strcpy (command, tmpline); } 125 if (UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); } 121 if (VERBOSE) { strextend (&command, "-v"); } 122 if (saveImstats) { strextend (&command, "-imstats %s", table->hosts[i].results); } 123 if (SINGLE_CPT) { strextend (&command, "-cpt %s", SINGLE_CPT); } 124 if (UPDATE) { strextend (&command, "-update"); } 126 125 127 126 fprintf (stderr, "command: %s\n", command); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/update_dvo_fixstkids.c
r35764 r38447 41 41 catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs 42 42 catalog.catmode = DVO_MODE_UNDEF; // not needed since we skip empty catalogs 43 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;43 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 44 44 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 45 45 … … 48 48 exit (1); 49 49 } 50 if (!catalog.Nave s_disk) {50 if (!catalog.Naverage_disk) { 51 51 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 52 52 dvo_catalog_unlock (&catalog); … … 127 127 snprintf (table->hosts[i].results, 1024, "%s/fixstkids.results.%s.dat", table->hosts[i].pathname, uniquer); 128 128 129 char command[1024];130 s nprintf (command, 1024, "fixstkids_client -hostID %d -catdir %s -hostdir %s -images %s -region %f %f %f %f",129 char *command = NULL; 130 strextend (&command, "fixstkids_client -hostID %d -catdir %s -hostdir %s -images %s -region %f %f %f %f", 131 131 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, imageFile, 132 132 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); … … 134 134 int saveImstats = VERBOSE_IMSTATS || SUMMARY_IMSTATS; 135 135 136 char tmpline[1024]; 137 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 138 if (saveImstats) { snprintf (tmpline, 1024, "%s -imstats %s", command, table->hosts[i].results); strcpy (command, tmpline); } 139 if (SINGLE_CPT) { snprintf (tmpline, 1024, "%s -cpt %s", command, SINGLE_CPT); strcpy (command, tmpline); } 140 if (UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); } 136 if (VERBOSE) { strextend (&command, "-v"); } 137 if (saveImstats) { strextend (&command, "-imstats %s", table->hosts[i].results); } 138 if (SINGLE_CPT) { strextend (&command, "-cpt %s", SINGLE_CPT); } 139 if (UPDATE) { strextend (&command, "-update"); } 141 140 142 141 fprintf (stderr, "command: %s\n", command); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/update_dvo_setastrom.c
r38282 r38447 43 43 catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs 44 44 catalog.catmode = DVO_MODE_UNDEF; // not needed since we skip empty catalogs 45 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;45 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 46 46 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 47 47 … … 50 50 exit (1); 51 51 } 52 if (!catalog.Nave s_disk) {52 if (!catalog.Naverage_disk) { 53 53 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 54 54 dvo_catalog_unlock (&catalog); … … 99 99 table->hosts[i].pathname = tmppath; 100 100 101 char command[1024];102 s nprintf (command, 1024, "setastrom_client -hostID %d -catdir %s -hostdir %s -region %f %f %f %f",101 char *command = NULL; 102 strextend (&command, "setastrom_client -hostID %d -catdir %s -hostdir %s -region %f %f %f %f", 103 103 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, 104 104 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 105 105 106 char tmpline[1024]; 107 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 108 if (UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); } 109 if (KH_FILE) { snprintf (tmpline, 1024, "%s -KH %s", command, KH_FILE); strcpy (command, tmpline); } 110 if (DCR_FILE) { snprintf (tmpline, 1024, "%s -DCR %s", command, DCR_FILE); strcpy (command, tmpline); } 111 if (CAM_FILE) { snprintf (tmpline, 1024, "%s -CAM %s", command, CAM_FILE); strcpy (command, tmpline); } 112 if (UPDATE_CATFORMAT) { snprintf (tmpline, 1024, "%s -update-catformat %s", command, UPDATE_CATFORMAT); strcpy (command, tmpline); } 113 114 if (KH_RESET) { snprintf (tmpline, 1024, "%s -KH-reset", command); strcpy (command, tmpline); } 115 if (DCR_RESET) { snprintf (tmpline, 1024, "%s -DCR-reset", command); strcpy (command, tmpline); } 116 if (CAM_RESET) { snprintf (tmpline, 1024, "%s -CAM-reset", command); strcpy (command, tmpline); } 106 if (VERBOSE) { strextend (&command, "-v"); } 107 if (UPDATE) { strextend (&command, "-update"); } 108 if (KH_FILE) { strextend (&command, "-KH %s", KH_FILE); } 109 if (DCR_FILE) { strextend (&command, "-DCR %s", DCR_FILE); } 110 if (CAM_FILE) { strextend (&command, "-CAM %s", CAM_FILE); } 111 if (UPDATE_CATFORMAT) { strextend (&command, "-update-catformat %s", UPDATE_CATFORMAT); } 112 if (KH_RESET) { strextend (&command, "-KH-reset"); } 113 if (DCR_RESET) { strextend (&command, "-DCR-reset"); } 114 if (CAM_RESET) { strextend (&command, "-CAM-reset"); } 117 115 118 116 fprintf (stderr, "command: %s\n", command); -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/update_dvo_setgalmodel.c
r37807 r38447 38 38 catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs 39 39 catalog.catmode = DVO_MODE_UNDEF; // not needed since we skip empty catalogs 40 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF |LOAD_STARPAR;40 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT | DVO_LOAD_STARPAR; 41 41 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 42 42 … … 45 45 exit (1); 46 46 } 47 if (!catalog.Nave s_disk) {47 if (!catalog.Naverage_disk) { 48 48 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 49 49 dvo_catalog_unlock (&catalog); … … 91 91 table->hosts[i].pathname = tmppath; 92 92 93 char command[1024];94 s nprintf (command, 1024, "setgalmodel_client -hostID %d -catdir %s -hostdir %s -region %f %f %f %f",93 char *command = NULL; 94 strextend (&command, "setgalmodel_client -hostID %d -catdir %s -hostdir %s -region %f %f %f %f", 95 95 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, 96 96 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 97 97 98 if (VERBOSE) { strextend (&command, "-v"); } 99 if (TESTING) { strextend (&command, "-testing"); } 100 if (UPDATE) { strextend (&command, "-update"); } 101 if (UPDATE_CATFORMAT) { strextend (&command, "-update-catformat %s", UPDATE_CATFORMAT); } 102 98 103 fprintf (stderr, "command: %s\n", command); 99 100 char tmpline[1024];101 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); }102 if (TESTING) { snprintf (tmpline, 1024, "%s -testing", command); strcpy (command, tmpline); }103 if (UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); }104 if (UPDATE_CATFORMAT) { snprintf (tmpline, 1024, "%s -update-catformat %s", command, UPDATE_CATFORMAT); strcpy (command, tmpline); }105 104 106 105 if (PARALLEL_MANUAL) continue; -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/update_dvo_setphot.c
r36630 r38447 54 54 catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs 55 55 catalog.catmode = DVO_MODE_UNDEF; // not needed since we skip empty catalogs 56 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;56 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 57 57 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 58 58 … … 61 61 exit (1); 62 62 } 63 if (!catalog.Nave s_disk) {63 if (!catalog.Naverage_disk) { 64 64 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 65 65 dvo_catalog_unlock (&catalog); … … 110 110 table->hosts[i].pathname = tmppath; 111 111 112 char command[1024];113 s nprintf (command, 1024, "setphot_client -hostID %d -catdir %s -hostdir %s -images %s -region %f %f %f %f",112 char *command = NULL; 113 strextend (&command, "setphot_client -hostID %d -catdir %s -hostdir %s -images %s -region %f %f %f %f", 114 114 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, imageFile, 115 115 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 116 116 117 if (VERBOSE) { strextend (&command, "-v"); } 118 if (RESET) { strextend (&command, "-reset"); } 119 if (UPDATE) { strextend (&command, "-update"); } 120 if (UBERCAL) { strextend (&command, "-ubercal"); } 121 117 122 fprintf (stderr, "command: %s\n", command); 118 119 char tmpline[1024];120 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); }121 if (RESET) { snprintf (tmpline, 1024, "%s -reset", command); strcpy (command, tmpline); }122 if (UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); }123 if (UBERCAL) { snprintf (tmpline, 1024, "%s -ubercal", command); strcpy (command, tmpline); }124 123 125 124 if (PARALLEL_MANUAL) continue; -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/update_dvo_setposangle.c
r35103 r38447 55 55 catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs 56 56 catalog.catmode = DVO_MODE_UNDEF; // not needed since we skip empty catalogs 57 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;57 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 58 58 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 59 59 … … 62 62 exit (1); 63 63 } 64 if (!catalog.Nave s_disk) {64 if (!catalog.Naverage_disk) { 65 65 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 66 66 dvo_catalog_unlock (&catalog); … … 112 112 table->hosts[i].pathname = tmppath; 113 113 114 char command[1024];115 s nprintf (command, 1024, "setposangle_client -hostID %d -catdir %s -hostdir %s -images %s -region %f %f %f %f",114 char *command = NULL; 115 strextend (&command, "setposangle_client -hostID %d -catdir %s -hostdir %s -images %s -region %f %f %f %f", 116 116 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, imageFile, 117 117 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 118 118 119 if (VERBOSE) { strextend (&command, "-v"); } 120 if (UPDATE) { strextend (&command, "-update"); } 121 119 122 fprintf (stderr, "command: %s\n", command); 120 121 char tmpline[1024];122 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); }123 if (UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); }124 123 125 124 if (PARALLEL_MANUAL) continue; -
branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/update_dvo_uniphot.c
r37807 r38447 14 14 Coords coords; 15 15 16 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].s wapped);16 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder); 17 17 if (!image) { 18 18 fprintf (stderr, "ERROR: failed to read images\n"); … … 61 61 for (i = 0; i < pglob.gl_pathc; i++) { 62 62 catalog.filename = pglob.gl_pathv[i]; 63 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;63 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 64 64 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 65 65 … … 69 69 exit (2); 70 70 } 71 if (!catalog.Nave s_disk) {71 if (!catalog.Naverage_disk) { 72 72 dvo_catalog_unlock (&catalog); 73 73 dvo_catalog_free (&catalog);
Note:
See TracChangeset
for help on using the changeset viewer.
