Changeset 38441
- Timestamp:
- Jun 12, 2015, 6:18:23 PM (11 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 326 edited
- 14 copied
-
. (modified) (1 prop)
-
Makefile.Common (modified) (3 diffs)
-
src/addstar/include/addstar.h (modified) (2 diffs)
-
src/addstar/src/ConfigInit.c (modified) (1 diff)
-
src/addstar/src/ReadStarsFITS.c (modified) (11 diffs)
-
src/addstar/src/SEDfit.c (modified) (1 diff)
-
src/addstar/src/UpdateDatabase_Image.c (modified) (5 diffs)
-
src/addstar/src/UpdateDatabase_Refcat.c (modified) (3 diffs)
-
src/addstar/src/UpdateDatabase_Reflist.c (modified) (3 diffs)
-
src/addstar/src/UpdateImageIDs.c (modified) (1 diff)
-
src/addstar/src/addstar.c (modified) (5 diffs)
-
src/addstar/src/addstar_create_ID.c (modified) (1 diff)
-
src/addstar/src/args.c (modified) (1 diff)
-
src/addstar/src/args_parallel_client.c (modified) (1 diff)
-
src/addstar/src/dumpskycells.c (modified) (1 diff)
-
src/addstar/src/find_matches.c (modified) (2 diffs)
-
src/addstar/src/find_matches_ICRF.c (modified) (1 diff)
-
src/addstar/src/find_matches_closest.c (modified) (2 diffs)
-
src/addstar/src/find_matches_closest_refstars.c (modified) (2 diffs)
-
src/addstar/src/find_matches_refstars.c (modified) (2 diffs)
-
src/addstar/src/find_matches_starpar.c (modified) (1 diff)
-
src/addstar/src/findskycell.c (modified) (4 diffs)
-
src/addstar/src/load2mass_as_rawdata.c (modified) (1 diff)
-
src/addstar/src/load2mass_catalog.c (modified) (1 diff)
-
src/addstar/src/loadICRF_catalog.c (modified) (1 diff)
-
src/addstar/src/loadICRF_save_remote.c (modified) (2 diffs)
-
src/addstar/src/loadICRF_table.c (modified) (1 diff)
-
src/addstar/src/loadstarpar_catalog.c (modified) (1 diff)
-
src/addstar/src/loadstarpar_save_remote.c (modified) (3 diffs)
-
src/addstar/src/loadstarpar_table.c (modified) (1 diff)
-
src/addstar/src/loadsupercos.c (modified) (1 diff)
-
src/addstar/src/loadsupercos_rawdata.c (modified) (1 diff)
-
src/addstar/src/loadwise_prelim_rawdata.c (modified) (1 diff)
-
src/addstar/src/loadwise_rawdata.c (modified) (1 diff)
-
src/addstar/src/mkcmf.c (modified) (6 diffs)
-
src/addstar/src/resort_catalogs.c (modified) (1 diff)
-
src/addstar/src/resort_threaded.c (modified) (2 diffs)
-
src/addstar/src/resort_unthreaded.c (modified) (2 diffs)
-
src/addstar/src/sedstar.c (modified) (3 diffs)
-
src/addstar/src/skycells.c (modified) (1 diff)
-
src/addstar/src/skycells_to_mdc.c (modified) (1 diff)
-
src/addstar/test (modified) (2 props)
-
src/addstar/test/GSCregions.tbl (copied) (copied from branches/eam_branches/ohana.20150429/src/addstar/test/GSCregions.tbl )
-
src/addstar/test/compress.dvo (copied) (copied from branches/eam_branches/ohana.20150429/src/addstar/test/compress.dvo )
-
src/addstar/test/dvo.config (copied) (copied from branches/eam_branches/ohana.20150429/src/addstar/test/dvo.config )
-
src/addstar/test/dvo.layout (copied) (copied from branches/eam_branches/ohana.20150429/src/addstar/test/dvo.layout )
-
src/addstar/test/relphot.dvo (modified) (2 diffs)
-
src/addstar/test/relphot.flatcorr.dvo (modified) (19 diffs)
-
src/addstar/test/simple.dvo (modified) (15 diffs)
-
src/addstar/test/tap.dvo (modified) (2 diffs)
-
src/checkastro/src/bcatalog.c (modified) (3 diffs)
-
src/checkastro/src/checkastro_images.c (modified) (1 diff)
-
src/checkastro/src/load_catalogs.c (modified) (2 diffs)
-
src/checkastro/src/load_images.c (modified) (1 diff)
-
src/delstar/src/delete_duplicate_images.c (modified) (4 diffs)
-
src/delstar/src/delete_duplicate_measures.c (modified) (2 diffs)
-
src/delstar/src/delete_fix_LAP.c (modified) (2 diffs)
-
src/delstar/src/delete_fix_LAP_edges.c (modified) (2 diffs)
-
src/delstar/src/delete_fix_LAP_edges_delete.c (modified) (2 diffs)
-
src/delstar/src/delete_image_photcodes.c (modified) (2 diffs)
-
src/delstar/src/delete_imagefile.c (modified) (2 diffs)
-
src/delstar/src/delete_imagename.c (modified) (4 diffs)
-
src/delstar/src/delete_orphans.c (modified) (1 diff)
-
src/delstar/src/delete_photcodes.c (modified) (2 diffs)
-
src/delstar/src/delete_photcodes_single.c (modified) (2 diffs)
-
src/delstar/src/delete_times.c (modified) (3 diffs)
-
src/delstar/src/delstar.c (modified) (3 diffs)
-
src/delstar/src/find_image_db.c (modified) (3 diffs)
-
src/delstar/src/find_matches.c (modified) (1 diff)
-
src/dvolens/src/update_objects.c (modified) (2 diffs)
-
src/dvomerge/Makefile (modified) (1 diff)
-
src/dvomerge/include/dvomerge.h (modified) (1 diff)
-
src/dvomerge/src/LoadCatalog.c (modified) (1 diff)
-
src/dvomerge/src/LoadImages.c (modified) (1 diff)
-
src/dvomerge/src/args.c (modified) (3 diffs)
-
src/dvomerge/src/dvo_image_merge_dbs.c (modified) (3 diffs)
-
src/dvomerge/src/dvoconvert.c (modified) (5 diffs)
-
src/dvomerge/src/dvomergeContinue.c (modified) (1 diff)
-
src/dvomerge/src/dvomergeContinue_threaded.c (modified) (1 diff)
-
src/dvomerge/src/dvomergeCreate.c (modified) (5 diffs)
-
src/dvomerge/src/dvomergeFromList.c (modified) (1 diff)
-
src/dvomerge/src/dvomergeImageIDs.c (modified) (4 diffs)
-
src/dvomerge/src/dvomergeUpdate_catalogs.c (modified) (6 diffs)
-
src/dvomerge/src/dvomergeUpdate_threaded.c (modified) (1 diff)
-
src/dvomerge/src/dvorepairCPT.c (modified) (2 diffs)
-
src/dvomerge/src/dvorepairDeleteImageList.c (modified) (5 diffs)
-
src/dvomerge/src/dvorepairDeleteImagesByExternID.c (modified) (6 diffs)
-
src/dvomerge/src/dvorepairFixCPT.c (modified) (3 diffs)
-
src/dvomerge/src/dvorepairFixImages.c (modified) (2 diffs)
-
src/dvomerge/src/dvorepairFixTables.c (modified) (4 diffs)
-
src/dvomerge/src/dvorepairImageVsMeasure.c (modified) (1 diff)
-
src/dvomerge/src/dvorepairImagesVsMeasures.c (modified) (2 diffs)
-
src/dvomerge/src/dvosecfilt_catalogs.c (modified) (4 diffs)
-
src/dvomerge/src/dvoutils_load_image_index.c (modified) (1 diff)
-
src/dvomerge/src/dvoutils_uniq_images.c (modified) (1 diff)
-
src/dvomerge/src/dvoverify_utils.c (modified) (4 diffs)
-
src/dvomerge/src/merge_catalogs.c (modified) (1 diff)
-
src/dvomerge/src/merge_catalogs_new.c (modified) (1 diff)
-
src/dvomerge/src/merge_catalogs_old.c (modified) (2 diffs)
-
src/dvopsps/src/insert_FWobjects_dvopsps.c (modified) (2 diffs)
-
src/dvopsps/src/insert_detections_dvopsps.c (modified) (3 diffs)
-
src/dvopsps/src/insert_detections_dvopsps_catalog.c (modified) (1 diff)
-
src/dvopsps/src/insert_diffobj_dvopsps.c (modified) (3 diffs)
-
src/dvopsps/src/insert_objects_dvopsps.c (modified) (3 diffs)
-
src/dvosplit/src/dvosplit.c (modified) (2 diffs)
-
src/dvosplit/src/open_output_catalogs.c (modified) (1 diff)
-
src/dvosplit/src/split_averages.c (modified) (8 diffs)
-
src/dvosplit/src/split_measures.c (modified) (4 diffs)
-
src/dvosplit/src/split_missings.c (modified) (2 diffs)
-
src/fakeastro/include/fakeastro.h (modified) (1 diff)
-
src/fakeastro/src/fakeastro_2mass.c (modified) (2 diffs)
-
src/fakeastro/src/fakeastro_images.c (modified) (1 diff)
-
src/fakeastro/src/fakestar_catalog.c (modified) (1 diff)
-
src/fakeastro/src/insert_fakestar.c (modified) (1 diff)
-
src/fakeastro/src/load_fake_stars.c (modified) (2 diffs)
-
src/fakeastro/src/load_template_images.c (modified) (2 diffs)
-
src/fakeastro/src/match_fake_stars.c (modified) (1 diff)
-
src/fakeastro/src/save_fake_stars.c (modified) (1 diff)
-
src/fakeastro/src/save_fakestars.c (modified) (2 diffs)
-
src/gastro/src/getptolemy.c (modified) (2 diffs)
-
src/gastro2/src/getptolemy.c (modified) (2 diffs)
-
src/gastro2/src/rfits.c (modified) (1 diff)
-
src/getstar/src/WriteImageFITS.c (modified) (1 diff)
-
src/getstar/src/dvoImageExtract.c (modified) (2 diffs)
-
src/getstar/src/dvoImageOverlaps.c (modified) (2 diffs)
-
src/getstar/src/dvoImagesAtCoords.c (modified) (2 diffs)
-
src/getstar/src/getstar.c (modified) (5 diffs)
-
src/getstar/src/select_by_region.c (modified) (1 diff)
-
src/getstar/src/write_getstar_ps1_dev_0.c (modified) (1 diff)
-
src/getstar/src/write_getstar_ps1_dev_1.c (modified) (1 diff)
-
src/getstar/src/write_getstar_ps1_dev_2.c (modified) (1 diff)
-
src/imclean/src/wfits.c (modified) (1 diff)
-
src/imregister/detrend/delete.c (modified) (1 diff)
-
src/imregister/detrend/output.c (modified) (1 diff)
-
src/imregister/imphot/dumpfits.c (modified) (1 diff)
-
src/imregister/imreg/delete.c (modified) (1 diff)
-
src/imregister/imreg/imregclient.c (modified) (2 diffs)
-
src/imregister/imreg/output.c (modified) (1 diff)
-
src/imregister/photreg/delete.c (modified) (1 diff)
-
src/imregister/photreg/output.c (modified) (1 diff)
-
src/imregister/spreg/delete.c (modified) (1 diff)
-
src/imregister/spreg/output.c (modified) (2 diffs)
-
src/imregister/src/detregister.c (modified) (2 diffs)
-
src/imregister/src/detsearch.c (modified) (2 diffs)
-
src/imregister/src/imphotsearch.c (modified) (2 diffs)
-
src/imregister/src/imregister.c (modified) (2 diffs)
-
src/imregister/src/imregtable.c (modified) (3 diffs)
-
src/imregister/src/imsearch.c (modified) (2 diffs)
-
src/imregister/src/imstatreg.c (modified) (3 diffs)
-
src/imregister/src/photreg.c (modified) (2 diffs)
-
src/imregister/src/photsearch.c (modified) (3 diffs)
-
src/imregister/src/spregister.c (modified) (2 diffs)
-
src/imregister/src/spsearch.c (modified) (2 diffs)
-
src/libautocode/Makefile.Targets (modified) (2 diffs)
-
src/libautocode/def/autocode.c (modified) (3 diffs)
-
src/libautocode/def/autocode.h (modified) (1 diff)
-
src/libautocode/def/average-ps1-v1.d (modified) (1 diff)
-
src/libautocode/def/average-ps1-v2.d (modified) (1 diff)
-
src/libautocode/def/average-ps1-v3.d (modified) (1 diff)
-
src/libautocode/def/average-ps1-v4.d (modified) (1 diff)
-
src/libautocode/def/average-ps1-v5.d (modified) (1 diff)
-
src/libautocode/def/average.d (modified) (1 diff)
-
src/libautocode/def/galshape-ps1-v5.d (copied) (copied from branches/eam_branches/ohana.20150429/src/libautocode/def/galshape-ps1-v5.d )
-
src/libautocode/def/galshape.d (copied) (copied from branches/eam_branches/ohana.20150429/src/libautocode/def/galshape.d )
-
src/libdvo/Makefile (modified) (2 diffs)
-
src/libdvo/include/dvo.h (modified) (14 diffs)
-
src/libdvo/include/ps1_v5_defs.h (modified) (1 diff)
-
src/libdvo/src/AstromOffsetMapIO.c (modified) (2 diffs)
-
src/libdvo/src/HostTable.c (modified) (2 diffs)
-
src/libdvo/src/LoadImages.c (modified) (1 diff)
-
src/libdvo/src/LoadPhotcodesFITS.c (modified) (2 diffs)
-
src/libdvo/src/SavePhotcodesFITS.c (modified) (2 diffs)
-
src/libdvo/src/dvo_catalog.c (modified) (19 diffs)
-
src/libdvo/src/dvo_catalog_create.c (modified) (7 diffs)
-
src/libdvo/src/dvo_catalog_mef.c (modified) (27 diffs)
-
src/libdvo/src/dvo_catalog_raw.c (modified) (7 diffs)
-
src/libdvo/src/dvo_catalog_split.c (modified) (80 diffs)
-
src/libdvo/src/dvo_convert.c (modified) (45 diffs)
-
src/libdvo/src/dvo_convert_PS1_DEV_2.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_PS1_V1.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_PS1_V2.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_PS1_V3.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_PS1_V4.c (modified) (3 diffs)
-
src/libdvo/src/dvo_convert_PS1_V5.c (modified) (8 diffs)
-
src/libdvo/src/dvo_image.c (modified) (6 diffs)
-
src/libdvo/src/dvo_image_raw.c (modified) (1 diff)
-
src/libdvo/src/dvo_util.c (modified) (2 diffs)
-
src/libdvo/src/fits_db.c (modified) (2 diffs)
-
src/libdvo/src/flatcorr_io.c (modified) (4 diffs)
-
src/libdvo/src/skyregion_io.c (modified) (2 diffs)
-
src/libfits/Makefile (modified) (5 diffs)
-
src/libfits/doc/notes-compress.txt (modified) (1 diff)
-
src/libfits/extern/gzip.c (modified) (5 diffs)
-
src/libfits/header/F_copy_H.c (modified) (1 diff)
-
src/libfits/header/F_modify.c (modified) (4 diffs)
-
src/libfits/include/gfitsio.h (modified) (12 diffs)
-
src/libfits/matrix/F_compress_M.c (copied) (copied from branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_M.c )
-
src/libfits/matrix/F_compress_data.c (copied) (copied from branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_data.c )
-
src/libfits/matrix/F_compress_utils.c (copied) (copied from branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_utils.c )
-
src/libfits/matrix/F_matrix.c (modified) (4 diffs)
-
src/libfits/matrix/F_uncompress_M.c (copied) (copied from branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_M.c )
-
src/libfits/matrix/F_uncompress_data.c (modified) (2 diffs)
-
src/libfits/table/F_compress_T.c (copied) (copied from branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c )
-
src/libfits/table/F_copy_T.c (modified) (2 diffs)
-
src/libfits/table/F_create_T.c (modified) (3 diffs)
-
src/libfits/table/F_define_column.c (modified) (1 diff)
-
src/libfits/table/F_get_column.c (modified) (7 diffs)
-
src/libfits/table/F_read_T.c (modified) (5 diffs)
-
src/libfits/table/F_set_column.c (modified) (41 diffs)
-
src/libfits/table/F_table_format.c (modified) (4 diffs)
-
src/libfits/table/F_table_row.c (modified) (3 diffs)
-
src/libfits/table/F_table_varlength.c (modified) (5 diffs)
-
src/libfits/table/F_uncompress_T.c (copied) (copied from branches/eam_branches/ohana.20150429/src/libfits/table/F_uncompress_T.c )
-
src/libfits/table/F_write_T.c (modified) (9 diffs)
-
src/libfits/table/F_write_TH.c (modified) (2 diffs)
-
src/libfits/test (copied) (copied from branches/eam_branches/ohana.20150429/src/libfits/test )
-
src/libohana/Makefile (modified) (5 diffs)
-
src/libohana/include/ohana.h (modified) (3 diffs)
-
src/libohana/include/ohana_allocate.h (modified) (2 diffs)
-
src/libohana/src/ohana_allocate.c (modified) (2 diffs)
-
src/libohana/src/string.c (modified) (1 diff)
-
src/libohana/test (modified) (1 prop)
-
src/libohana/test/string.c (modified) (2 diffs)
-
src/libohana/test/typetest.c (modified) (2 diffs)
-
src/libtap/tapcheck.pl (copied) (copied from branches/eam_branches/ohana.20150429/src/libtap/tapcheck.pl )
-
src/markrock/src/markrock.c (modified) (2 diffs)
-
src/markstar/src/find_images.c (modified) (1 diff)
-
src/markstar/src/markstar.c (modified) (2 diffs)
-
src/mosastro/src/getptolemy.c (modified) (2 diffs)
-
src/mosastro/src/rfits.c (modified) (1 diff)
-
src/mosastro/src/wfits.c (modified) (1 diff)
-
src/opihi/cmd.data (modified) (1 prop)
-
src/opihi/cmd.data/cast.c (modified) (4 diffs)
-
src/opihi/cmd.data/rd.c (modified) (5 diffs)
-
src/opihi/cmd.data/read_vectors.c (modified) (11 diffs)
-
src/opihi/cmd.data/tv.c (modified) (1 diff)
-
src/opihi/cmd.data/vstats.c (modified) (1 diff)
-
src/opihi/cmd.data/wd.c (modified) (7 diffs)
-
src/opihi/cmd.data/write_vectors.c (modified) (5 diffs)
-
src/opihi/dvo/avextract.c (modified) (2 diffs)
-
src/opihi/dvo/avmatch.c (modified) (3 diffs)
-
src/opihi/dvo/calextract.c (modified) (1 diff)
-
src/opihi/dvo/calmextract.c (modified) (1 diff)
-
src/opihi/dvo/catalog.c (modified) (1 diff)
-
src/opihi/dvo/ccd.c (modified) (1 diff)
-
src/opihi/dvo/cmatch.c (modified) (1 diff)
-
src/opihi/dvo/cmd.c (modified) (1 diff)
-
src/opihi/dvo/cmpReadFile.c (modified) (1 diff)
-
src/opihi/dvo/ddmags.c (modified) (1 diff)
-
src/opihi/dvo/dmagaves.c (modified) (1 diff)
-
src/opihi/dvo/dmagmeas.c (modified) (1 diff)
-
src/opihi/dvo/dmags.c (modified) (1 diff)
-
src/opihi/dvo/dmt.c (modified) (1 diff)
-
src/opihi/dvo/dvo_host_utils.c (modified) (1 diff)
-
src/opihi/dvo/extract.c (modified) (1 diff)
-
src/opihi/dvo/fitcolors.c (modified) (1 diff)
-
src/opihi/dvo/fitsed.c (modified) (1 diff)
-
src/opihi/dvo/gstar.c (modified) (1 diff)
-
src/opihi/dvo/imdata.c (modified) (1 diff)
-
src/opihi/dvo/lcurve.c (modified) (1 diff)
-
src/opihi/dvo/lightcurve.c (modified) (1 diff)
-
src/opihi/dvo/mextract.c (modified) (4 diffs)
-
src/opihi/dvo/mmatch.c (modified) (3 diffs)
-
src/opihi/dvo/mmextract.c (modified) (1 diff)
-
src/opihi/dvo/objectcoverage.c (modified) (1 diff)
-
src/opihi/dvo/paverage.c (modified) (1 diff)
-
src/opihi/dvo/pmeasure.c (modified) (1 diff)
-
src/opihi/dvo/subpix.c (modified) (1 diff)
-
src/opihi/include/dvomath.h (modified) (1 diff)
-
src/opihi/lib.data/SplineOps.c (modified) (1 diff)
-
src/opihi/lib.shell/VectorIO.c (modified) (9 diffs)
-
src/opihi/lib.shell/convert_to_RPN.c (modified) (1 diff)
-
src/opihi/lib.shell/evaluate_stack.c (modified) (2 diffs)
-
src/opihi/lib.shell/stack_math.c (modified) (24 diffs)
-
src/photdbc/include/photdbc.h (modified) (1 diff)
-
src/photdbc/src/ConfigInit.c (modified) (1 diff)
-
src/photdbc/src/Shutdown_dvodist.c (modified) (1 diff)
-
src/photdbc/src/args.c (modified) (3 diffs)
-
src/photdbc/src/copy_images.c (modified) (3 diffs)
-
src/photdbc/src/find_images.c (modified) (1 diff)
-
src/photdbc/src/flag_measures.c (modified) (1 diff)
-
src/photdbc/src/join_stars.c (modified) (1 diff)
-
src/photdbc/src/make_subcatalog.c (modified) (1 diff)
-
src/photdbc/src/photdbc_catalogs.c (modified) (6 diffs)
-
src/relastro/include/relastro.h (modified) (2 diffs)
-
src/relastro/src/BrightCatalog.c (modified) (8 diffs)
-
src/relastro/src/ImageTable.c (modified) (3 diffs)
-
src/relastro/src/UpdateObjectOffsets.c (modified) (5 diffs)
-
src/relastro/src/args.c (modified) (1 diff)
-
src/relastro/src/assign_images.c (modified) (1 diff)
-
src/relastro/src/bcatalog.c (modified) (3 diffs)
-
src/relastro/src/high_speed_catalogs.c (modified) (4 diffs)
-
src/relastro/src/high_speed_objects.c (modified) (2 diffs)
-
src/relastro/src/hpm_catalogs.c (modified) (4 diffs)
-
src/relastro/src/hpm_objects.c (modified) (2 diffs)
-
src/relastro/src/launch_region_hosts.c (modified) (2 diffs)
-
src/relastro/src/load_catalogs.c (modified) (4 diffs)
-
src/relastro/src/load_images.c (modified) (1 diff)
-
src/relastro/src/relastro_client.c (modified) (1 diff)
-
src/relastro/src/relastro_images.c (modified) (1 diff)
-
src/relastro/src/relastro_merge_source.c (modified) (2 diffs)
-
src/relastro/src/relastro_objects.c (modified) (3 diffs)
-
src/relastro/src/relastro_parallel_regions.c (modified) (1 diff)
-
src/relphot/include/relphot.h (modified) (2 diffs)
-
src/relphot/src/ImageTable.c (modified) (3 diffs)
-
src/relphot/src/StarOps.c (modified) (3 diffs)
-
src/relphot/src/args.c (modified) (2 diffs)
-
src/relphot/src/assign_images.c (modified) (1 diff)
-
src/relphot/src/bcatalog.c (modified) (3 diffs)
-
src/relphot/src/launch_region_hosts.c (modified) (2 diffs)
-
src/relphot/src/load_catalogs.c (modified) (4 diffs)
-
src/relphot/src/load_images.c (modified) (1 diff)
-
src/relphot/src/reload_catalogs.c (modified) (5 diffs)
-
src/relphot/src/relphot_images.c (modified) (2 diffs)
-
src/relphot/src/relphot_objects.c (modified) (3 diffs)
-
src/relphot/src/relphot_parallel_regions.c (modified) (1 diff)
-
src/relphot/src/relphot_synthphot.c (modified) (3 diffs)
-
src/tools/src/fields.c (modified) (2 diffs)
-
src/uniphot/src/find_image_sgroups.c (modified) (1 diff)
-
src/uniphot/src/find_image_tgroups.c (modified) (1 diff)
-
src/uniphot/src/fiximids.c (modified) (1 diff)
-
src/uniphot/src/fixstkids.c (modified) (1 diff)
-
src/uniphot/src/load_images.c (modified) (1 diff)
-
src/uniphot/src/load_images_fiximids.c (modified) (1 diff)
-
src/uniphot/src/load_images_fixstkids.c (modified) (1 diff)
-
src/uniphot/src/load_images_setphot.c (modified) (1 diff)
-
src/uniphot/src/load_images_setposangle.c (modified) (1 diff)
-
src/uniphot/src/setfwhm.c (modified) (1 diff)
-
src/uniphot/src/setphot.c (modified) (1 diff)
-
src/uniphot/src/setposangle.c (modified) (1 diff)
-
src/uniphot/src/subset_images.c (modified) (1 diff)
-
src/uniphot/src/uniphot.c (modified) (1 diff)
-
src/uniphot/src/update_dvo_ckids.c (modified) (3 diffs)
-
src/uniphot/src/update_dvo_fiximids.c (modified) (4 diffs)
-
src/uniphot/src/update_dvo_fixstkids.c (modified) (4 diffs)
-
src/uniphot/src/update_dvo_setastrom.c (modified) (3 diffs)
-
src/uniphot/src/update_dvo_setgalmodel.c (modified) (3 diffs)
-
src/uniphot/src/update_dvo_setphot.c (modified) (3 diffs)
-
src/uniphot/src/update_dvo_setposangle.c (modified) (3 diffs)
-
src/uniphot/src/update_dvo_uniphot.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
-
Property svn:mergeinfo
set to
/branches/eam_branches/ohana.20150429 merged eligible
-
Property svn:mergeinfo
set to
-
trunk/Ohana/Makefile.Common
r16093 r38441 9 9 BASE_CPPFLAGS = $(CPPFLAGS) -I$(INC) -I$(DESTINC) $(INCDIRS) -D$(ARCH) 10 10 BASE_LDFLAGS = $(LDFLAGS) -L$(LIB) -L$(DESTLIB) $(LIBDIRS) $(LIBFLAGS) 11 12 FULL_CFLAGS = $(BASE_CFLAGS) 13 FULL_CPPFLAGS = $(BASE_CPPFLAGS) 14 FULL_LDFLAGS = $(BASE_LDFLAGS) 15 16 TEST_CFLAGS = $(BASE_CFLAGS) 17 TEST_CPPFLAGS = $(BASE_CPPFLAGS) 18 TEST_LDFLAGS = $(BASE_LDFLAGS) 19 20 TESTHARNESS = $(ROOT)/src/libtap/tapcheck.pl 11 21 12 22 DVO_LIBS = $(DESTLIB)/libdvo.a $(DESTLIB)/libFITS.a $(DESTLIB)/libohana.a … … 34 44 $(CC) $(FULL_CFLAGS) -o $@ $^ $(FULL_LDFLAGS) 35 45 @echo "compiled $*" 46 @echo "" 47 48 $(TESTDIR)/%.$(ARCH): $(TESTDIR)/%.c 49 @echo $@ 50 @echo $* 51 @echo $< 52 @echo $^ 53 @if [ ! -d $(TESTDIR) ]; then mkdir -p $(TESTDIR); fi 54 $(CC) $(TEST_CFLAGS) -o $@ $^ $(TEST_LDFLAGS) 55 @echo "compiled $*" 56 @echo "" 57 58 $(TESTBIN)/%: $(TESTDIR)/%.$(ARCH) 59 @if [ ! -d $(TESTBIN) ]; then mkdir -p $(TESTBIN); fi 60 rm -f $(TESTBIN)/$* 61 cp $(TESTDIR)/$*.$(ARCH) $(TESTBIN)/$* 62 @echo "installed $*" 36 63 @echo "" 37 64 … … 103 130 rm -f `find . -name "#*"` 104 131 132 test.clean: 133 for i in $(TESTPROG); do rm -f $(TESTBIN)/$$i; done 134 for i in $(TESTPROG); do rm -f $(TESTDIR)/$$i.$(ARCH); done 135 105 136 dist: clean 106 137 rm -rf $(BIN) -
trunk/Ohana/src/addstar/include/addstar.h
r37807 r38441 84 84 char GSCFILE[256]; 85 85 char *CATDIR; 86 char CATMODE[16]; /* raw, mef, split, mysql */ 87 char CATFORMAT[16]; /* internal, elixir, loneos, panstarrs */ 86 char CATMODE[16]; /* raw, mef, split, mysql */ 87 char CATFORMAT[16]; /* internal, elixir, loneos, panstarrs */ 88 char CATCOMPRESS[16]; /* GZIP_1, NONE */ 88 89 char TWO_MASS_DIR_AS[256]; 89 90 char TWO_MASS_DIR_DR2[256]; … … 326 327 void *memrchr(const void *s, int c, size_t n); 327 328 int addstar_create_ID (); 328 int strextend (char *input, char *format,...);329 329 330 330 void initMosaicCoords (); -
trunk/Ohana/src/addstar/src/ConfigInit.c
r33963 r38441 134 134 ScanConfig (config, "CATMODE", "%s", 0, CATMODE); 135 135 ScanConfig (config, "CATFORMAT", "%s", 0, CATFORMAT); 136 if (!ScanConfig (config, "CATCOMPRESS", "%s", 0, CATCOMPRESS)) { 137 strcpy (CATCOMPRESS, "NONE"); 138 } 136 139 if (!ScanConfig (config, "SKY_DEPTH", "%d", 0, &SKY_DEPTH)) { 137 140 SKY_DEPTH = SKY_DEPTH_HST; -
trunk/Ohana/src/addstar/src/ReadStarsFITS.c
r37995 r38441 153 153 off_t Nstars; 154 154 unsigned int i; 155 char swapped;156 155 double ZeroPt; 157 156 Stars *stars = NULL; 158 157 SMPData *smpdata = NULL; 159 158 160 swapped = FALSE; 161 smpdata = gfits_table_get_SMPData (table, &Nstars, &swapped); 159 smpdata = gfits_table_get_SMPData (table, &Nstars, NULL, NULL); 162 160 if (!smpdata) { 163 161 fprintf (stderr, "skipping inconsistent entry\n"); … … 229 227 PS1_DEV_0 *ps1data; 230 228 231 ps1data = gfits_table_get_PS1_DEV_0 (table, &Nstars, NULL );229 ps1data = gfits_table_get_PS1_DEV_0 (table, &Nstars, NULL, NULL); 232 230 if (!ps1data) { 233 231 fprintf (stderr, "skipping inconsistent entry\n"); … … 300 298 PS1_DEV_1 *ps1data; 301 299 302 ps1data = gfits_table_get_PS1_DEV_1 (table, &Nstars, NULL );300 ps1data = gfits_table_get_PS1_DEV_1 (table, &Nstars, NULL, NULL); 303 301 if (!ps1data) { 304 302 fprintf (stderr, "skipping inconsistent entry\n"); … … 383 381 } 384 382 385 ps1data = gfits_table_get_CMF_PS1_V1 (table, &Nstars, NULL );383 ps1data = gfits_table_get_CMF_PS1_V1 (table, &Nstars, NULL, NULL); 386 384 if (!ps1data) { 387 385 fprintf (stderr, "skipping inconsistent entry\n"); … … 545 543 CMF_PS1_V2 *ps1data; 546 544 547 ps1data = gfits_table_get_CMF_PS1_V2 (table, &Nstars, NULL );545 ps1data = gfits_table_get_CMF_PS1_V2 (table, &Nstars, NULL, NULL); 548 546 if (!ps1data) { 549 547 fprintf (stderr, "skipping inconsistent entry\n"); … … 622 620 CMF_PS1_V3 *ps1data; 623 621 624 ps1data = gfits_table_get_CMF_PS1_V3 (table, &Nstars, NULL );622 ps1data = gfits_table_get_CMF_PS1_V3 (table, &Nstars, NULL, NULL); 625 623 if (!ps1data) { 626 624 fprintf (stderr, "skipping inconsistent entry\n"); … … 706 704 CMF_PS1_V4 *ps1data; 707 705 708 ps1data = gfits_table_get_CMF_PS1_V4 (table, &Nstars, NULL );706 ps1data = gfits_table_get_CMF_PS1_V4 (table, &Nstars, NULL, NULL); 709 707 if (!ps1data) { 710 708 fprintf (stderr, "skipping inconsistent entry\n"); … … 1259 1257 } 1260 1258 1261 ps1data = gfits_table_get_CMF_PS1_SV1 (table, &Nstars, NULL );1259 ps1data = gfits_table_get_CMF_PS1_SV1 (table, &Nstars, NULL, NULL); 1262 1260 if (!ps1data) { 1263 1261 fprintf (stderr, "skipping inconsistent entry\n"); … … 1423 1421 CMF_PS1_SV2 *ps1data; 1424 1422 1425 ps1data = gfits_table_get_CMF_PS1_SV2 (table, &Nstars, NULL );1423 ps1data = gfits_table_get_CMF_PS1_SV2 (table, &Nstars, NULL, NULL); 1426 1424 if (!ps1data) { 1427 1425 fprintf (stderr, "skipping inconsistent entry\n"); … … 1753 1751 CMF_PS1_DV4 *ps1data; 1754 1752 1755 ps1data = gfits_table_get_CMF_PS1_DV4 (table, &Nstars, NULL );1753 ps1data = gfits_table_get_CMF_PS1_DV4 (table, &Nstars, NULL, NULL); 1756 1754 if (!ps1data) { 1757 1755 fprintf (stderr, "skipping inconsistent entry\n"); … … 1839 1837 CMF_PS1_DV5 *ps1data; 1840 1838 1841 ps1data = gfits_table_get_CMF_PS1_DV5 (table, &Nstars, NULL );1839 ps1data = gfits_table_get_CMF_PS1_DV5 (table, &Nstars, NULL, NULL); 1842 1840 if (!ps1data) { 1843 1841 fprintf (stderr, "skipping inconsistent entry\n"); -
trunk/Ohana/src/addstar/src/SEDfit.c
r37036 r38441 198 198 outcat[0].Naverage = Nave; 199 199 outcat[0].Nmeasure = Nmeas; 200 outcat[0].Nsecf _mem = Nave*Nsec;200 outcat[0].Nsecfilt_mem = Nave*Nsec; 201 201 202 202 free (sourceValue.mags); -
trunk/Ohana/src/addstar/src/UpdateDatabase_Image.c
r37807 r38441 12 12 } 13 13 14 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;15 if (options[0].update) catalog.catflags = LOAD_AVES | LOAD_MISS | LOAD_SECF;14 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 15 if (options[0].update) catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 16 16 17 17 // XXX this is probably not needed anymore … … 47 47 catalog.filename = skylist[0].filename[i]; 48 48 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 49 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;50 if (options[0].update) catalog.catflags = LOAD_AVES | LOAD_MISS | LOAD_SECF;49 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 50 if (options[0].update) catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 51 51 52 52 // an error exit status here is a significant error … … 56 56 } 57 57 58 // Nave s_disk == 0 implies an empty catalog file58 // Naverage_disk == 0 implies an empty catalog file 59 59 // for only_match, skip empty catalogs 60 if ((catalog.Nave s_disk == 0) && options[0].only_match) {60 if ((catalog.Naverage_disk == 0) && options[0].only_match) { 61 61 dvo_catalog_unlock (&catalog); 62 62 dvo_catalog_free (&catalog); … … 73 73 SetProtect (TRUE); 74 74 if (options[0].update) { 75 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;75 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 76 76 dvo_catalog_update (&catalog, VERBOSE); 77 77 } else { … … 92 92 /*** update the image table ***/ 93 93 /* setup image table format and lock */ 94 gfits_db_init (&db); 94 95 db.mode = dvo_catalog_catmode (CATMODE); 95 96 db.format = dvo_catalog_catformat (CATFORMAT); -
trunk/Ohana/src/addstar/src/UpdateDatabase_Refcat.c
r15743 r38441 36 36 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 37 37 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 38 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;39 if (options[0].update) catalog.catflags = LOAD_AVES | LOAD_MISS | LOAD_SECF;38 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 39 if (options[0].update) catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 40 40 41 41 // an error exit status here is a significant error … … 45 45 } 46 46 47 // Nave s_disk == 0 implies an empty catalog file47 // Naverage_disk == 0 implies an empty catalog file 48 48 // for only_match, skip empty catalogs 49 if ((catalog.Nave s_disk == 0) && options[0].only_match) {49 if ((catalog.Naverage_disk == 0) && options[0].only_match) { 50 50 dvo_catalog_unlock (&catalog); 51 51 dvo_catalog_free (&catalog); … … 63 63 SetProtect (TRUE); 64 64 if (options[0].update) { 65 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;65 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 66 66 dvo_catalog_update (&catalog, VERBOSE); 67 67 } else { -
trunk/Ohana/src/addstar/src/UpdateDatabase_Reflist.c
r27435 r38441 36 36 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 37 37 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 38 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;39 if (options[0].update) catalog.catflags = LOAD_AVES | LOAD_MISS | LOAD_SECF;38 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 39 if (options[0].update) catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 40 40 41 41 // an error exit status here is a significant error … … 46 46 47 47 /* for only_match, skip empty catalogs XXX EAM : this leaves behind empty files */ 48 if ((catalog.Nave s_disk == 0) && options[0].only_match) {48 if ((catalog.Naverage_disk == 0) && options[0].only_match) { 49 49 dvo_catalog_unlock (&catalog); 50 50 dvo_catalog_free (&catalog); … … 59 59 SetProtect (TRUE); 60 60 if (options[0].update) { 61 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;61 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 62 62 dvo_catalog_update (&catalog, VERBOSE); 63 63 } else { -
trunk/Ohana/src/addstar/src/UpdateImageIDs.c
r37357 r38441 9 9 /*** update the image table ***/ 10 10 /* setup image table format and lock */ 11 gfits_db_init (&db); 11 12 db.mode = dvo_catalog_catmode (CATMODE); 12 13 db.format = dvo_catalog_catformat (CATFORMAT); -
trunk/Ohana/src/addstar/src/addstar.c
r37807 r38441 104 104 105 105 // set the parameters which guide catalog open/load/create 106 catalog.filename = skylist[0].filename[i]; 107 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 108 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 109 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF | LOAD_LENSING; 110 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 106 catalog.filename = skylist[0].filename[i]; 107 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 108 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 109 catalog.catcompress = dvo_catalog_catcompress (CATCOMPRESS); // set the default catcompress from config data 110 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT | DVO_LOAD_LENSING; 111 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 111 112 112 113 // XXX need to do something to enforce consistency. we can change options.update … … 117 118 if (catalog.catmode != DVO_MODE_SPLIT) options.update = FALSE; 118 119 119 if (options.update) catalog.catflags = LOAD_AVES | LOAD_MISS | LOAD_SECF;120 if (options.update) catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 120 121 121 122 // open as read or write, depending on desire … … 134 135 if (VERBOSE) MARKTIME ("load cpt: %f sec\n", dtime); RESETTIME; 135 136 136 // Nave s_disk == 0 implies an empty catalog file137 // Naverage_disk == 0 implies an empty catalog file 137 138 // for only_match, skip empty catalogs 138 if ((catalog.Nave s_disk == 0) && options.only_match) {139 if ((catalog.Naverage_disk == 0) && options.only_match) { 139 140 dvo_catalog_unlock (&catalog); 140 141 dvo_catalog_free (&catalog); … … 174 175 SetProtect (TRUE); 175 176 if (options.update) { 176 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF |LOAD_LENSING;177 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT | DVO_LOAD_LENSING; 177 178 dvo_catalog_update (&catalog, VERBOSE); 178 179 } else { … … 193 194 /*** update the image table ***/ 194 195 /* setup image table format and lock */ 196 gfits_db_init (&db); 195 197 db.mode = dvo_catalog_catmode (CATMODE); 196 198 db.format = dvo_catalog_catformat (CATFORMAT); -
trunk/Ohana/src/addstar/src/addstar_create_ID.c
r35760 r38441 10 10 /*** update the image table ***/ 11 11 /* setup image table format and lock */ 12 //gfits_db_init (&db);12 gfits_db_init (&db); 13 13 db.mode = dvo_catalog_catmode (CATMODE); 14 14 db.format = dvo_catalog_catformat (CATFORMAT); -
trunk/Ohana/src/addstar/src/args.c
r37807 r38441 480 480 } 481 481 482 int strextend (char *input, char *format,...) {483 484 char tmpextra[1024], tmpline[1024];485 va_list argp;486 487 va_start (argp, format);488 vsnprintf (tmpextra, 1024, format, argp);489 snprintf (tmpline, 1024, "%s %s", input, tmpextra);490 strcpy (input, tmpline);491 492 return TRUE;493 }494 495 482 /** addstar modes: 496 483 -
trunk/Ohana/src/addstar/src/args_parallel_client.c
r37116 r38441 125 125 } 126 126 127 int strextend (char *input, char *format,...) {128 129 char tmpextra[1024], tmpline[1024];130 va_list argp;131 132 va_start (argp, format);133 vsnprintf (tmpextra, 1024, format, argp);134 snprintf (tmpline, 1024, "%s %s", input, tmpextra);135 strcpy (input, tmpline);136 137 return TRUE;138 }139 -
trunk/Ohana/src/addstar/src/dumpskycells.c
r33719 r38441 46 46 /*** open the image table ***/ 47 47 /* setup image table format and lock */ 48 gfits_db_init (&db); 48 49 db.mode = dvo_catalog_catmode (CATMODE); 49 50 db.format = dvo_catalog_catformat (CATFORMAT); -
trunk/Ohana/src/addstar/src/find_matches.c
r37807 r38441 91 91 92 92 /* set up pointers for linked list of measure */ 93 if (catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeas _disk)) {93 if (catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeasure_disk)) { 94 94 next_meas = init_measure_links (catalog[0].average, Nave, catalog[0].measure, Nmeas); 95 95 } else { … … 320 320 catalog[0].Naverage = Nave; 321 321 catalog[0].Nmeasure = Nmeas; 322 catalog[0].Nsecf _mem = Nave*Nsecfilt;322 catalog[0].Nsecfilt_mem = Nave*Nsecfilt; 323 323 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); 324 324 -
trunk/Ohana/src/addstar/src/find_matches_ICRF.c
r37807 r38441 164 164 catalog[0].Naverage = Nave; 165 165 catalog[0].Nmeasure = Nmeas; 166 catalog[0].Nsecf _mem = Nave*Nsecfilt;166 catalog[0].Nsecfilt_mem = Nave*Nsecfilt; 167 167 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %d "OFF_T_FMT" "OFF_T_FMT" ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas, Nmatch); 168 168 -
trunk/Ohana/src/addstar/src/find_matches_closest.c
r37807 r38441 91 91 92 92 /* set up pointers for linked list of measure */ 93 if (catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeas _disk)) {93 if (catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeasure_disk)) { 94 94 // this version is only valid if we have done a full catalog load, and if the catalog 95 95 // is sorted while processed … … 381 381 catalog[0].Nmeasure = Nmeas; 382 382 catalog[0].Nlensing = Nlens; 383 catalog[0].Nsecf _mem = Nave*Nsecfilt;383 catalog[0].Nsecfilt_mem = Nave*Nsecfilt; 384 384 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nlens: "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas, Nlens, Nmatch); 385 385 -
trunk/Ohana/src/addstar/src/find_matches_closest_refstars.c
r37807 r38441 85 85 86 86 /* set up pointers for linked list of measure */ 87 if (catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeas _disk)) {87 if (catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeasure_disk)) { 88 88 // this version is only valid if we have done a full catalog load, and if the catalog 89 89 // is sorted while processed … … 322 322 catalog[0].Naverage = Nave; 323 323 catalog[0].Nmeasure = Nmeas; 324 catalog[0].Nsecf _mem = Nave*Nsecfilt;324 catalog[0].Nsecfilt_mem = Nave*Nsecfilt; 325 325 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); 326 326 -
trunk/Ohana/src/addstar/src/find_matches_refstars.c
r37807 r38441 70 70 71 71 /* set up pointers for linked list of measurements */ 72 if (catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeas _disk)) {72 if (catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeasure_disk)) { 73 73 // this version is only valid if we have done a full catalog load, and if the catalog 74 74 // is sorted while processed … … 298 298 catalog[0].Naverage = Nave; 299 299 catalog[0].Nmeasure = Nmeas; 300 catalog[0].Nsecf _mem = Nave*Nsecfilt;300 catalog[0].Nsecfilt_mem = Nave*Nsecfilt; 301 301 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %d "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas, Nmatch); 302 302 -
trunk/Ohana/src/addstar/src/find_matches_starpar.c
r37807 r38441 205 205 catalog[0].Naverage = Nave; 206 206 catalog[0].Nstarpar = Nstarpar; 207 catalog[0].Nsecf _mem = Nave*Nsecfilt;207 catalog[0].Nsecfilt_mem = Nave*Nsecfilt; 208 208 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nstarpar: %d "OFF_T_FMT" "OFF_T_FMT" ("OFF_T_FMT" matches)\n", Nstars, Nave, Nstarpar, Nmatch); 209 209 -
trunk/Ohana/src/addstar/src/findskycell.c
r37116 r38441 173 173 snprintf (imagefile, DVO_MAX_PATH, "%s/Images.dat", catdir); 174 174 175 gfits_db_init (&db); 175 176 status = dvo_image_lock (&db, imagefile, 2.0, LCK_XCLD); 176 177 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); … … 183 184 // convert database table to internal structure (binary to Image) 184 185 // 'image' points to the same memory as db->ftable->buffer 185 image = gfits_table_get_Image (&db.ftable, &Nimage, &db.s wapped);186 image = gfits_table_get_Image (&db.ftable, &Nimage, &db.scaledValue, &db.nativeOrder); 186 187 if (!image) { 187 188 fprintf (stderr, "ERROR: failed to read images\n"); … … 557 558 snprintf (imagefile, DVO_MAX_PATH, "%s/Images.dat", catdir); 558 559 560 gfits_db_init (&db); 559 561 status = dvo_image_lock (&db, imagefile, 2.0, LCK_XCLD); 560 562 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); … … 567 569 // convert database table to internal structure (binary to Image) 568 570 // 'image' points to the same memory as db->ftable->buffer 569 image = gfits_table_get_Image (&db.ftable, &Nimage, &db.s wapped);571 image = gfits_table_get_Image (&db.ftable, &Nimage, &db.scaledValue, &db.nativeOrder); 570 572 if (!image) { 571 573 fprintf (stderr, "ERROR: failed to read images\n"); -
trunk/Ohana/src/addstar/src/load2mass_as_rawdata.c
r34088 r38441 181 181 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 182 182 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 183 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;183 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 184 184 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 185 185 -
trunk/Ohana/src/addstar/src/load2mass_catalog.c
r37036 r38441 56 56 catalog[0].Naverage = Nave; 57 57 catalog[0].Nmeasure = Nmeas; 58 catalog[0].Nsecf _mem = Nave*Nsec;58 catalog[0].Nsecfilt_mem = Nave*Nsec; 59 59 return (TRUE); 60 60 } -
trunk/Ohana/src/addstar/src/loadICRF_catalog.c
r37807 r38441 10 10 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 11 11 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 12 catalog.catflags = LOAD_AVES | LOAD_SECF | LOAD_MEAS;12 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT | DVO_LOAD_MEASURE; 13 13 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 14 14 -
trunk/Ohana/src/addstar/src/loadICRF_save_remote.c
r37807 r38441 2 2 # include "loadICRF.h" 3 3 # define DEBUG 1 4 5 int strextend (char *input, char *format,...) {6 7 char tmpextra[1024], tmpline[1024];8 va_list argp;9 10 va_start (argp, format);11 vsnprintf (tmpextra, 1024, format, argp);12 snprintf (tmpline, 1024, "%s %s", input, tmpextra);13 strcpy (input, tmpline);14 15 return TRUE;16 }17 4 18 5 int loadICRF_save_remote (ICRF_Stars *stars, int Nstars, HostTable *hosts, SkyRegion *region, char *fullname, AddstarClientOptions *options) { … … 64 51 65 52 // need to generate the remote command 66 char command[1024];67 s nprintf (command, 1024, "loadICRF_client");68 strextend ( command, "-hostID %d", host->hostID);69 strextend ( command, "-D CATDIR %s", CATDIR);70 strextend ( command, "-hostdir %s", host->pathname);71 strextend ( command, "-cpt %s", region->name);72 strextend ( command, "-input %s", filename);73 strextend ( command, "-D ADDSTAR_RADIUS %f", options->radius);53 char *command = NULL; 54 strextend (&command, "loadICRF_client"); 55 strextend (&command, "-hostID %d", host->hostID); 56 strextend (&command, "-D CATDIR %s", CATDIR); 57 strextend (&command, "-hostdir %s", host->pathname); 58 strextend (&command, "-cpt %s", region->name); 59 strextend (&command, "-input %s", filename); 60 strextend (&command, "-D ADDSTAR_RADIUS %f", options->radius); 74 61 75 62 fprintf (stderr, "command: %s\n", command); -
trunk/Ohana/src/addstar/src/loadICRF_table.c
r37807 r38441 1 1 # include "addstar.h" 2 2 # include "loadICRF.h" 3 4 # define GET_COLUMN(OUT,NAME,TYPE) \5 TYPE *OUT = gfits_get_bintable_column_data (&theader, &ftable, NAME, type, &Nrow, &Ncol); \6 myAssert (!strcmp(type, #TYPE), "wrong column type");7 3 8 4 int loadICRF_table (SkyList *skylistInput, HostTable *hosts, char *filename, AddstarClientOptions *options) { -
trunk/Ohana/src/addstar/src/loadstarpar_catalog.c
r37807 r38441 10 10 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 11 11 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 12 catalog.catflags = LOAD_AVES | LOAD_SECF |LOAD_STARPAR;12 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT | DVO_LOAD_STARPAR; 13 13 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 14 14 -
trunk/Ohana/src/addstar/src/loadstarpar_save_remote.c
r37807 r38441 2 2 # include "loadstarpar.h" 3 3 # define DEBUG 1 4 5 int strextend (char *input, char *format,...) {6 7 char tmpextra[1024], tmpline[1024];8 va_list argp;9 10 va_start (argp, format);11 vsnprintf (tmpextra, 1024, format, argp);12 snprintf (tmpline, 1024, "%s %s", input, tmpextra);13 strcpy (input, tmpline);14 15 return TRUE;16 }17 4 18 5 int loadstarpar_save_remote (StarPar_Stars *stars, int Nstars, HostTable *hosts, SkyRegion *region, char *fullname, AddstarClientOptions *options) { … … 62 49 63 50 // need to generate the remote command 64 char command[1024];65 s nprintf (command, 1024, "loadstarpar_client");66 strextend ( command, "-hostID %d", host->hostID);67 strextend ( command, "-D CATDIR %s", CATDIR);68 strextend ( command, "-hostdir %s", host->pathname);69 strextend ( command, "-cpt %s", region->name);70 strextend ( command, "-input %s", filename);51 char *command = NULL; 52 strextend (&command, "loadstarpar_client"); 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); 71 58 72 59 // launch the job on the remote machine (no handshake) … … 78 65 } 79 66 host->pid = pid; // save for future reference 67 free (command); 80 68 81 69 save_remote_host (host); -
trunk/Ohana/src/addstar/src/loadstarpar_table.c
r37807 r38441 1 1 # include "addstar.h" 2 2 # include "loadstarpar.h" 3 4 # define GET_COLUMN(OUT,NAME,TYPE) \5 TYPE *OUT = gfits_get_bintable_column_data (&theader, &ftable, NAME, type, &Nrow, &Ncol); \6 myAssert (!strcmp(type, #TYPE), "wrong column type");7 3 8 4 int loadstarpar_table (SkyList *skylistInput, HostTable *hosts, char *filename, AddstarClientOptions *options) { -
trunk/Ohana/src/addstar/src/loadsupercos.c
r33653 r38441 47 47 48 48 // attempt to open the existing images table. if it does not exist, we will save the loaded images 49 gfits_db_init (&db); 49 50 db.mode = dvo_catalog_catmode (CATMODE); 50 51 db.format = dvo_catalog_catformat (CATFORMAT); -
trunk/Ohana/src/addstar/src/loadsupercos_rawdata.c
r33653 r38441 168 168 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 169 169 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 170 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;170 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 171 171 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 172 172 -
trunk/Ohana/src/addstar/src/loadwise_prelim_rawdata.c
r33653 r38441 186 186 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 187 187 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 188 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;188 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 189 189 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 190 190 -
trunk/Ohana/src/addstar/src/loadwise_rawdata.c
r38062 r38441 198 198 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 199 199 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 200 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;200 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 201 201 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 202 202 -
trunk/Ohana/src/addstar/src/mkcmf.c
r37995 r38441 500 500 } 501 501 502 gfits_table_set_PS1_DEV_0 (ftable, stars, Nstars );502 gfits_table_set_PS1_DEV_0 (ftable, stars, Nstars, TRUE); 503 503 gfits_modify (ftable->header, "EXTTYPE", "%s", 1, "PS1_DEV_0"); 504 504 } … … 547 547 } 548 548 549 gfits_table_set_PS1_DEV_1 (ftable, stars, Nstars );549 gfits_table_set_PS1_DEV_1 (ftable, stars, Nstars, TRUE); 550 550 gfits_modify (ftable->header, "EXTTYPE", "%s", 1, "PS1_DEV_1"); 551 551 } … … 596 596 } 597 597 598 gfits_table_set_CMF_PS1_V1 (ftable, stars, Nstars );598 gfits_table_set_CMF_PS1_V1 (ftable, stars, Nstars, TRUE); 599 599 gfits_modify (ftable->header, "EXTTYPE", "%s", 1, "PS1_V1"); 600 600 } … … 651 651 } 652 652 653 gfits_table_set_CMF_PS1_V2 (ftable, stars, Nstars );653 gfits_table_set_CMF_PS1_V2 (ftable, stars, Nstars, TRUE); 654 654 gfits_modify (ftable->header, "EXTTYPE", "%s", 1, "PS1_V2"); 655 655 } … … 710 710 } 711 711 712 gfits_table_set_CMF_PS1_V3 (ftable, stars, Nstars );712 gfits_table_set_CMF_PS1_V3 (ftable, stars, Nstars, TRUE); 713 713 gfits_modify (ftable->header, "EXTTYPE", "%s", 1, "PS1_V3"); 714 714 } … … 778 778 } 779 779 780 gfits_table_set_CMF_PS1_V4 (ftable, stars, Nstars );780 gfits_table_set_CMF_PS1_V4 (ftable, stars, Nstars, TRUE); 781 781 gfits_modify (ftable->header, "EXTTYPE", "%s", 1, "PS1_V4"); 782 782 } -
trunk/Ohana/src/addstar/src/resort_catalogs.c
r37116 r38441 74 74 table->hosts[i].pathname = tmppath; 75 75 76 char command[1024];77 s nprintf (command, 1024, "addstar_client -resort");78 strextend ( command, "-D CATDIR %s", CATDIR);79 strextend ( command, "-hostID %d", table->hosts[i].hostID);80 strextend ( command, "-hostdir %s", table->hosts[i].pathname);81 strextend ( command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);76 char *command = NULL; 77 strextend (&command, "addstar_client -resort"); 78 strextend (&command, "-D CATDIR %s", CATDIR); 79 strextend (&command, "-hostID %d", table->hosts[i].hostID); 80 strextend (&command, "-hostdir %s", table->hosts[i].pathname); 81 strextend (&command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 82 82 83 if (VERBOSE) strextend ( command, "%s-v");84 if (NTHREADS) strextend ( command, "%s-threads %d", NTHREADS);85 if (OLD_RESORT) strextend ( command, "%s-old-resort");86 if (options->nosort == 3) strextend ( command, "%s-force-sort");87 if (options->existing_regions) strextend ( command, "%s-existing-regions");83 if (VERBOSE) strextend (&command, "-v"); 84 if (NTHREADS) strextend (&command, "-threads %d", NTHREADS); 85 if (OLD_RESORT) strextend (&command, "-old-resort"); 86 if (options->nosort == 3) strextend (&command, "-force-sort"); 87 if (options->existing_regions) strextend (&command, "-existing-regions"); 88 88 89 89 fprintf (stderr, "command: %s\n", command); -
trunk/Ohana/src/addstar/src/resort_threaded.c
r37116 r38441 43 43 44 44 // set the parameters which guide catalog open/load/create 45 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 46 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 47 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_LENSING; 48 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 45 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 46 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 47 catalog.catcompress = dvo_catalog_catcompress (CATCOMPRESS); // set the default catcompress from config data 48 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_LENSING; 49 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 49 50 50 51 // an error exit status here is a significant error (disk I/O or file access) … … 57 58 } 58 59 59 // Nave s_disk == 0 implies an empty catalog file, skip empty catalogs60 if (catalog.Nave s_disk == 0) {60 // Naverage_disk == 0 implies an empty catalog file, skip empty catalogs 61 if (catalog.Naverage_disk == 0) { 61 62 dvo_catalog_unlock (&catalog); 62 63 dvo_catalog_free (&catalog); -
trunk/Ohana/src/addstar/src/resort_unthreaded.c
r37116 r38441 21 21 22 22 // set the parameters which guide catalog open/load/create 23 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 24 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 25 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_LENSING; 26 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 23 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 24 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 25 catalog.catcompress = dvo_catalog_catcompress (CATCOMPRESS); // set the default catcompress from config data 26 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_LENSING; 27 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 27 28 28 29 // an error exit status here is a significant error (disk I/O or file access) … … 32 33 } 33 34 34 // Nave s_disk == 0 implies an empty catalog file, skip empty catalogs35 if (catalog.Nave s_disk == 0) {35 // Naverage_disk == 0 implies an empty catalog file, skip empty catalogs 36 if (catalog.Naverage_disk == 0) { 36 37 dvo_catalog_unlock (&catalog); 37 38 dvo_catalog_free (&catalog); -
trunk/Ohana/src/addstar/src/sedstar.c
r25757 r38441 26 26 for (i = 0; i < skylist[0].Nregions; i++) { 27 27 incatalog.filename = skylist[0].filename[i]; 28 incatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;28 incatalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 29 29 30 30 // an error exit status here is a significant error … … 34 34 } 35 35 36 // Nave s_disk == 0 implies an empty catalog file37 if ((incatalog.Nave s_disk == 0) && options.only_match) {36 // Naverage_disk == 0 implies an empty catalog file 37 if ((incatalog.Naverage_disk == 0) && options.only_match) { 38 38 if (VERBOSE) fprintf (stderr, "skipping empty region\n"); 39 39 dvo_catalog_unlock (&incatalog); … … 54 54 outcatalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 55 55 outcatalog.Nsecfilt = GetPhotcodeNsecfilt (); 56 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;56 outcatalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 57 57 58 58 // an error exit status here is a significant error -
trunk/Ohana/src/addstar/src/skycells.c
r21048 r38441 12 12 /*** update the image table ***/ 13 13 /* setup image table format and lock */ 14 gfits_db_init (&db); 14 15 db.mode = dvo_catalog_catmode (CATMODE); 15 16 db.format = dvo_catalog_catformat (CATFORMAT); -
trunk/Ohana/src/addstar/src/skycells_to_mdc.c
r33720 r38441 5 5 // Convert FITS_DB to images structure 6 6 off_t NdbImages; 7 Image *dbImages = gfits_table_get_Image(&db->ftable, &NdbImages, &db->s wapped);7 Image *dbImages = gfits_table_get_Image(&db->ftable, &NdbImages, &db->scaledValue, &db->nativeOrder); 8 8 9 9 // If tess_id was not supplied assume that it is the basename of the CATDIR -
trunk/Ohana/src/addstar/test
- Property svn:ignore
-
old new 17 17 relphot.Mcal.dMcal.png 18 18 catdir.wise.test 19 dvo.photcodes 20 ptolemy.rc 21 tap.log
-
- Property svn:mergeinfo set to
- Property svn:ignore
-
trunk/Ohana/src/addstar/test/relphot.dvo
r35760 r38441 1 1 # -*-sh-*- 2 if (not($?VERBOSE)) set VERBOSE = 0 2 3 3 4 input tap.dvo … … 41 42 end 42 43 43 echo relphot -D CATDIR catdir.test r -region {$RA-1.0} {$RA+1.0} {$DEC-1.0} {$DEC+1.0} -update -nloop 10.0 44 exec relphot -D CATDIR catdir.test r -region {$RA-1.0} {$RA+1.0} {$DEC-1.0} {$DEC+1.0} -update -nloop 10.0 >& /dev/null 44 $output = >& /dev/null 45 if ($VERBOSE > 2) 46 $output = 47 end 48 $command = relphot -D CATDIR catdir.test -region {$RA-1.0} {$RA+1.0} {$DEC-1.0} {$DEC+1.0} -update -nloop 10.0 -images r 49 echo $command 50 exec $command $output 45 51 46 52 catdir catdir.test -
trunk/Ohana/src/addstar/test/relphot.flatcorr.dvo
r33653 r38441 14 14 # * no other mechanism to tell DVO about a flat-field correction 15 15 16 $TAP_BREAK = 1 17 $TAP_VERBOSE = 1 16 18 input tap.dvo 17 19 18 20 # set globals 19 if (not($?PLOT)) set PLOT = 0 21 if (not($?PLOT)) set PLOT = 0 22 23 $USE_CELL_OFFSETS = 1; # turn on non-zero cell offsets 24 $SET_UC_RESID = 1; # write a non-zero resid value to the ubercal table (should not have an impact) 25 $DO_2MASS = 1 26 $DO_SYNTH = 1 27 $DO_TYCHO = 1 28 $NC_CLOUDS = 0.08 29 $UC_CLOUDS = 0.02 20 30 21 31 # set various global variables 22 32 macro init 33 # generate a fake ptolemy.rc (to make this a contained test) 34 exec rm -f ptolemy.rc 35 output ptolemy.rc 36 echo "\#" 37 echo PHOTCODE_FILE dvo.photcodes 38 echo GSCFILE GSCregions.tbl 39 echo ZERO_PT 25.0 40 echo ADDSTAR_RADIUS 1.0 41 echo CATMODE SPLIT 42 echo CATFORMAT PS1_V5 43 # echo CATFORMAT PS1_V2 -- must be at least PS1_V3 for ubercaldist to work 44 echo SKY_DEPTH 4 45 echo CAMERA gpc1 46 echo CAMERA_CONFIG dvo.layout 47 echo "input dvo.config" 48 output stdout 49 50 # we need to define a photcode table consistent with the fake construction 51 $zpt_nominal:g = 24.0 52 $zpt_nominal:r = 24.5 53 54 # klam is negative, so klam*(airmass - 1) increases the zero point 55 $klam_nominal:g = -0.15 56 $klam_nominal:r = -0.10 57 58 # generate a fake dvo.photcode 59 exec rm -f dvo.photcodes 60 output dvo.photcodes 61 echo "\# code name type zero slope offset c1 c2 slope zero equiv sys scale scale sys poor bad poor bad" 62 echo "1 g sec 0.000 0.000 0.000 1 3 0.0000 0 1051 0.000 0.000 0.000 0.000 0x0000 0x0000 0x0000 0x0000" 63 echo "2 r sec 0.000 0.000 0.000 2 3 0.0000 0 1052 0.000 0.000 0.000 0.000 0x0000 0x0000 0x0000 0x0000" 64 echo "10000 GPC1.g.XY00 dep $zpt_nominal:g $klam_nominal:g 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 65 echo "10001 GPC1.g.XY01 dep $zpt_nominal:g $klam_nominal:g 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 66 echo "10010 GPC1.g.XY10 dep $zpt_nominal:g $klam_nominal:g 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 67 echo "10011 GPC1.g.XY11 dep $zpt_nominal:g $klam_nominal:g 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 68 echo "10100 GPC1.r.XY00 dep $zpt_nominal:r $klam_nominal:r 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 69 echo "10101 GPC1.r.XY01 dep $zpt_nominal:r $klam_nominal:r 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 70 echo "10110 GPC1.r.XY10 dep $zpt_nominal:r $klam_nominal:r 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 71 echo "10111 GPC1.r.XY11 dep $zpt_nominal:r $klam_nominal:r 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 72 echo "2011 2MASS_J ref 0.000 0.000 0.000 - - 0.0000 0 6 0.080 0.000 2.000 0.000 0x0000 0x0000 0x0000 0x0000" 73 echo "3001 SYNTH.g ref 0.000 0.000 0.000 - - 0.0000 0 1 nan 0.000 2.000 0.600 0x0000 0x0000 0x0000 0x0000" 74 echo "2020 TYCHO_B ref 0.000 0.000 0.000 - - 0.0000 0 - 0.000 0.000 0.000 0.000 0x0000 0x0000 0x0000 0x0000" 75 output stdout 76 23 77 $RA_CENTER = 10.0 24 78 $DEC_CENTER = 20.0 … … 32 86 $CHIP_DX = 1000 33 87 $CHIP_DY = 1000 34 35 # images are loaded into dvo with GPC1 photcodes, so we need to get the nominal zps for those filters 36 $zpt_nominal:g = 24.58 37 $zpt_nominal:r = 24.80 38 $zpt_nominal:i = 24.74 39 $zpt_nominal:z = 24.26 40 $zpt_nominal:y = 23.41 41 42 # klam is negative, so klam*(airmass - 1) increase the zero point 43 $klam_nominal:g = -0.15 44 $klam_nominal:r = -0.10 45 $klam_nominal:i = -0.04 46 $klam_nominal:z = -0.03 47 $klam_nominal:y = -0.03 88 $DEFECT_FRAC = 0.05 89 $OFFSET_FRAC_UC = 0.0 90 $OFFSET_FRAC_NC = 0.5 48 91 49 92 # we have two sets of images: ubercaled and not-ubercaled 50 93 51 # sequence to count images (only used in this function) 52 create tmpseq 0 9 53 54 $filt_uc:n = 9 55 $filt_uc:0 = g 56 $filt_uc:1 = g 57 $filt_uc:2 = g 58 $filt_uc:3 = r 59 $filt_uc:4 = r 60 $filt_uc:5 = r 61 $filt_uc:6 = i 62 $filt_uc:7 = i 63 $filt_uc:8 = i 64 65 # airmass slopes for these sequnece 94 # the number of exposures is defined by filt_uc:n 95 list filt_uc -split g g g g r r r r 96 $filt_uc:n = 4 97 98 # tmpseq is used to generate vectors in this function 99 create tmpseq 0 $filt_uc:n 100 101 # exptime and airmasses for uc images 102 set exptime_uc = 10.0 + zero(tmpseq) 103 set airmass_uc = 1.3 + zero(tmpseq) 66 104 set klam_uc = zero(tmpseq) 67 for i 0 tmpseq[] 68 klam_uc[$i] = $klam_nominal:$filt_uc:$i 69 end 70 71 # mjd and zpt values for ubercal'ed imaged 72 set exptime_uc = 10.0 + zero(tmpseq) 73 set airmass_uc = 1.3 + zero(tmpseq) 105 set zpt_uc = zero(tmpseq) 74 106 75 107 # ubercal zero points are defined as ZP_nominal + 2.5log(exptime) + K*(airmass - 1.0) 76 108 # note that K is defined as a negative value (is this sensible?) 77 set zpt_uc = 25.0 + 2.5*log(exptime_uc) + klam_uc*(airmass_uc - 1.0) + tmpseq*0.0050 - 0.0025 78 79 set mjd_uc = zero(zpt_uc) 80 mjd_uc[0] = 55000.01 81 mjd_uc[1] = 55000.02 82 mjd_uc[2] = 55000.03 83 mjd_uc[3] = 55015.01 84 mjd_uc[4] = 55015.02 85 mjd_uc[5] = 55015.03 86 mjd_uc[6] = 55025.01 87 mjd_uc[7] = 55025.02 88 mjd_uc[8] = 55025.03 109 110 # zero points and airmass slopes for these sequnece 111 for i 0 $filt_uc:n 112 klam_uc[$i] = $klam_nominal:$filt_uc:$i 113 zpt_uc[$i] = $zpt_nominal:$filt_uc:$i + 2.5*log(exptime_uc[$i]) + klam_uc[$i]*(airmass_uc[$i] - 1.0) + $UC_CLOUDS*(rnd(klam_uc[$i]) - 0.5) 114 end 115 set mjd_uc = 55000.00 + 0.01*(tmpseq % 3) + 10.0*int(tmpseq / 3) 89 116 90 117 # mjd and zpt values for not-ubercal'ed images 91 $filt_nc:n = 9 92 $filt_nc:0 = g 93 $filt_nc:1 = g 94 $filt_nc:2 = g 95 $filt_nc:3 = r 96 $filt_nc:4 = r 97 $filt_nc:5 = r 98 $filt_nc:6 = i 99 $filt_nc:7 = i 100 $filt_nc:8 = i 118 list filt_nc -split g g g g r r r r 119 $filt_nc:n = 4 120 121 # tmpseq is used to generate vectors in this function 122 create tmpseq 0 $filt_nc:n 123 124 # place this within a valid season (55000.0 - 55010.0 - 55020.0 - 55030.0) 125 set exptime_nc = 10.0 + zero(tmpseq) 126 set airmass_nc = 1.6 + zero(tmpseq) 127 set klam_nc = zero(tmpseq) 128 set zpt_nc = zero(tmpseq) 101 129 102 130 # airmass slopes for these sequnece 103 set klam_nc = zero(tmpseq)104 for i 0 tmpseq[]105 klam_nc[$i] = $klam_nominal:$filt_nc:$i131 for i 0 $filt_nc:n 132 klam_nc[$i] = $klam_nominal:$filt_nc:$i 133 zpt_nc[$i] = $zpt_nominal:$filt_nc:$i + 2.5*log(exptime_nc[$i]) + klam_nc[$i]*(airmass_nc[$i] - 1.0) + $NC_CLOUDS*(rnd(klam_nc[$i]) - 0.5) 106 134 end 107 108 # place this within a valid season (55000.0 - 55010.0 - 55020.0 - 55030.0) 109 set exptime_nc = 15.0 + zero(tmpseq) 110 set airmass_nc = 1.6 + zero(tmpseq) 111 112 # ubercal zero points are defined as ZP_nominal + 2.5log(exptime) + K*(airmass - 1.0) 113 set zpt_nc = 25.0 + 2.5*log(exptime_nc) + klam_nc*(airmass_nc - 1.0) - tmpseq*0.0050 + 0.0025 114 115 set mjd_nc = zero(zpt_nc) 116 mjd_nc[0] = 55000.11 117 mjd_nc[1] = 55000.12 118 mjd_nc[2] = 55000.13 119 mjd_nc[3] = 55015.11 120 mjd_nc[4] = 55015.12 121 mjd_nc[5] = 55015.13 122 mjd_nc[6] = 55025.11 123 mjd_nc[7] = 55025.12 124 mjd_nc[8] = 55025.13 135 set mjd_nc = 55000.10 + 0.01*(tmpseq % 3) + 10.0*int(tmpseq / 3) 136 137 delete tmpseq 125 138 end 126 139 … … 139 152 mkdir $rootdir 140 153 154 break -auto off 141 155 exec rm -rf $catdir 156 exec rm -rf $fileroot* 157 break -auto on 142 158 143 159 init 144 160 mkzptfile 145 mkstars 500 161 mkstars 1000 162 163 catdir $catdir 164 165 mk2mass $fileroot $catdir 166 ck2mass addstar 167 168 mksynth $fileroot $catdir 169 cksynth addstar 170 171 # to add a valid tycho test, I need to generate a zpt table for tycho as well 172 mktycho $fileroot $catdir 173 cktycho addstar 146 174 147 175 tapPLAN {((mjd_uc[]*4 + mjd_nc[]*4) + (mjd_uc[] + mjd_nc[]) + (mjd_uc[] + mjd_nc[])) / 3} … … 149 177 # generate the basic images and check they were correctly ingested by dvo 150 178 mksequence $fileroot $catdir 151 for i 0 mjd_uc[] 3152 ckexposure catdir.testmjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i raw153 end 154 for i 0 mjd_nc[] 3155 ckexposure catdir.testmjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i raw179 for i 0 mjd_uc[] 180 ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i raw 181 end 182 for i 0 mjd_nc[] 183 ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i raw 156 184 end 157 185 158 186 # run setphot on the db and check that the images now match the expected values 159 execsetphot -update -ubercal testzpt.fits -D CATDIR $catdir160 for i 0 mjd_uc[] 3161 ckexposure catdir.testmjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i setphot_uc162 end 163 for i 0 mjd_nc[] 3164 ckexposure catdir.testmjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i setphot_nc187 tapEXEC setphot -update -ubercal testzpt.fits -D CATDIR $catdir 188 for i 0 mjd_uc[] 189 ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i setphot_uc 190 end 191 for i 0 mjd_nc[] 192 ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i setphot_nc 165 193 end 166 194 167 195 # run relphot on the db and check that the images now match the expected values 168 exec relphot g,r,i -v -region 9.5 10.5 19.5 20.5 -D CATDIR catdir.test -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -keep-ubercal -D IMAGE_OFFSET 0.5 -update >& tmp.log 169 for i 0 mjd_uc[] 3 170 ckexposure catdir.test mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i relphot 171 end 172 for i 0 mjd_nc[] 3 173 ckexposure catdir.test mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot 174 end 196 tapEXEC relphot -images g,r -v -region 9.5 10.5 19.5 20.5 -D CATDIR $catdir -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -D IMAGE_OFFSET 0.5 -update -synthphot_zpts $fileroot.synthzpts.fits 197 for i 0 mjd_uc[] 198 ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i relphot_uc 199 end 200 for i 0 mjd_nc[] 201 ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot_nc 202 end 203 ck2mass relphot 204 cksynth relphot 205 cktycho relphot 175 206 176 207 tapDONE 208 end 209 210 macro try.relphot 211 if ($0 != 3) 212 echo "go (fileroot) (catdir)" 213 break 214 end 215 216 local i fileroot rootdir catdir 217 218 $fileroot = $1 219 $catdir = $2 220 221 # run relphot on the db and check that the images now match the expected values 222 tapEXEC relphot -images g,r -v -region 9.5 10.5 19.5 20.5 -D CATDIR $catdir -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -D IMAGE_OFFSET 0.5 -update -synthphot_zpts $fileroot.synthzpts.fits -nloop 24 223 224 for i 0 mjd_uc[] 225 # ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i relphot_uc 226 ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i relphot_uc 227 end 228 for i 0 mjd_nc[] 229 # ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot_nc 230 ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot_nc 231 end 177 232 end 178 233 … … 215 270 $AIRMASS = $5 216 271 $FILTER = $6 217 $ MODE= $7272 $FUNC_MODE = $7 218 273 219 274 # XXX need a function to extract the nominal zpt for a given filter / photcode from the db … … 235 290 236 291 skyregion {$RA_CENTER - 0.2/dcos($DEC_CENTER)} {$RA_CENTER + 0.2/dcos($DEC_CENTER)} {$DEC_CENTER - 0.2} {$DEC_CENTER + 0.2} 237 mextract ra dec mag xccd yccd where (abs(time - $MJD_IMAGE) < 0.0001)292 mextract ra dec mag xccd yccd dbflags photflags where (abs(time - $MJD_IMAGE) < 0.0001) 238 293 239 294 match2d -closest ra dec stars_ra stars_dec 0.001 -index1 index1 -index2 index2 … … 246 301 set dm = mag - stars_mag_m 247 302 303 set good_photom = (not(photflags & 0x02)) 304 foreach field dm xccd yccd 305 subset $field\_good = $field if good_photom 306 end 307 248 308 if ($PLOT) 249 309 dev -n 1 250 lim mag dm; clear; box; plot mag dm 251 end 252 253 set cell_xbin = int(xccd / ($CHIP_DX / $NCELL_X)) 254 set cell_ybin = int(yccd / ($CHIP_DY / $NCELL_Y)) 255 subset dm00 = dm if (cell_xbin == 0) && (cell_ybin == 0) 256 subset dm01 = dm if (cell_xbin == 0) && (cell_ybin == 1) 257 subset dm10 = dm if (cell_xbin == 1) && (cell_ybin == 0) 258 subset dm11 = dm if (cell_xbin == 1) && (cell_ybin == 1) 310 lim mag dm; clear; box; plot mag dm; plot -c red -pt 7 mag dm where (photflags & 0x00000002) 311 dev -n 2 312 lim xccd dm; clear; box; plot xccd dm; plot -c red -pt 7 xccd dm where (photflags & 0x00000002) 313 dev -n 3 314 lim ra dm; clear; box; plot ra dm; plot -c red -pt 7 ra dm where (photflags & 0x00000002) 315 echo "red points are known bad photometry" 316 end 317 318 # reproduce eddie's esoteric padding 319 set cell_xbin = max(0 , min(1 , int((xccd_good + 8) / ($CHIP_DX / $NCELL_X)))) 320 set cell_ybin = max(0 , min(1 , int((yccd_good + 10) / ($CHIP_DY / $NCELL_Y)))) 321 subset dm00 = dm_good if (cell_xbin == 0) && (cell_ybin == 0) 322 subset dm01 = dm_good if (cell_xbin == 0) && (cell_ybin == 1) 323 subset dm10 = dm_good if (cell_xbin == 1) && (cell_ybin == 0) 324 subset dm11 = dm_good if (cell_xbin == 1) && (cell_ybin == 1) 259 325 260 326 # uncorrected values behave like this: … … 273 339 $ZPT_REAL_NORM = $ZPT_REAL - 2.5*log($EXPTIME) - $KLAM_NOMINAL*($AIRMASS - 1.0) 274 340 275 if ("$ MODE" == "raw")341 if ("$FUNC_MODE" == "raw") 276 342 for ix 0 $NCELL_X 277 343 for iy 0 $NCELL_Y … … 280 346 281 347 set dm_adjust = dm$ix\$iy - $ZPT_NOMINAL + $ZPT_REAL_NORM + cell_off[$ix][$iy] 348 # echo set dm_adjust = dm$ix\$iy - $ZPT_NOMINAL + $ZPT_REAL_NORM + cell_off[$ix][$iy] 349 282 350 vstat -q dm_adjust 283 tapOK {abs($MEAN) < 0.005} "addstar raw ZP $MJD_IMAGE $FILTER" 351 sprintf line "addstar raw ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : cell%d%d %6.3f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA $ix $iy cell_off[$ix][$iy] dm_adjust[] 352 tapOK {abs($MEAN) < 0.005} "$line" 284 353 end 285 354 end … … 287 356 end 288 357 289 if ("$MODE" == "setphot_uc") 290 vstat -q dm 291 tapOK {abs($MEAN) < 0.005} "setphot_uc ZP $MJD_IMAGE $FILTER" 358 if ("$FUNC_MODE" == "setphot_uc") 359 vstat -q dm_good 360 sprintf line "setphot_uc ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA dm_good[] 361 tapOK {abs($MEAN) < 0.005} "$line" 362 363 subset tmp = dm if (dbflags & 0x00008000) 364 tapOK {tmp[] == dm[]} "ubercal detections have ubercal bit set" 365 366 imextract MCAL FLAGS where (abs(time - $MJD_IMAGE) < 0.0001) 367 subset tmp = FLAGS if (FLAGS & 0x0000200) 368 tapOK {tmp[] == FLAGS[]} "ubercal images have ubercal bit set" 369 292 370 return 293 371 end 294 372 295 if ("$MODE" == "setphot_nc") 296 vstat -q dm 297 tapOK {abs($MEAN - $ZPT_NOMINAL + $ZPT_REAL_NORM) < 0.005} "setphot_nc ZP $MJD_IMAGE $FILTER" 373 if ("$FUNC_MODE" == "setphot_nc") 374 vstat -q dm_good 375 sprintf line "setphot_nc ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA dm_good[] 376 tapOK {abs($MEAN - $ZPT_NOMINAL + $ZPT_REAL_NORM) < 0.005} "$line" 377 378 subset tmp = dm if (not(dbflags & 0x00008000)) 379 tapOK {tmp[] == dm[]} "non-ubercal detections do NOT have ubercal bit set" 380 381 imextract FLAGS where (abs(time - $MJD_IMAGE) < 0.0001) 382 subset tmp = FLAGS if (not(FLAGS & 0x0000200)) 383 tapOK {tmp[] == FLAGS[]} "non-ubercal images do NOT have ubercal bit set" 384 298 385 return 299 386 end 300 387 301 if ("$MODE" == "relphot") 302 vstat -q dm 303 tapOK {abs($MEAN) < 0.005} "relphot ZP $MJD_IMAGE $FILTER" 388 if (("$FUNC_MODE" == "relphot_uc") || ("$FUNC_MODE" == "relphot_nc")) 389 vstat -q dm_good 390 sprintf line "relphot ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA dm_good[] 391 392 if ("$FUNC_MODE" == "relphot_uc") 393 tapOK {abs($MEAN) < 0.001} "$line" 394 tapOK {abs($SIGMA) < 0.001} "$line" 395 end 396 if ("$FUNC_MODE" == "relphot_nc") 397 # XXX NOTE relaxed condition : bad photometry points are partly clipped but still cause a bias 398 tapOK {abs($MEAN) < 0.020} "$line" 399 tapOK {abs($SIGMA) < 0.020} "$line" 400 end 401 402 mextract ra dec mag dbflags 403 subset rs = ra if ((dbflags & 0x8000) && (mag > 13.5)) 404 subset ds = dec if ((dbflags & 0x8000) && (mag > 13.5)) 405 avmatch rs ds 0.1 $FILTER\:flags $FILTER\:uc_dist 406 407 subset tmp = rs if (($FILTER\:flags & 0x8) || ($FILTER\:flags & 0x4)) 408 tapOK {tmp[] == rs[]} "objects with ubercal detections have ubercal bit set or used SYNTH photometry (tmp[] vs rs[])" 409 410 subset tmp = rs if (($FILTER\:uc_dist < 0.1) || ($FILTER\:flags & 0x4)) 411 tapOK {tmp[] == rs[]} "objects with ubercal detections have ubercal dist of 0.0 or used SYNTH photometry" 304 412 return 305 413 end 414 415 echo "ERROR: unknown mode for ckexposure : $FUNC_MODE" 306 416 307 417 end … … 316 426 317 427 # we have defined a set of mjd and zero point values for ubercal'ed images 318 # for i 0 mjd_uc[] 319 for i 0 mjd_uc[] 3 428 for i 0 mjd_uc[] 320 429 mkexposure $1.uc.$i $RA_CENTER $DEC_CENTER zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] mjd_uc[$i] $filt_uc:$i $2 321 430 end 322 431 323 432 # we have a second set of mjd and zero point values for non-ubercal'ed images 324 # for i 0 mjd_nc[] 325 for i 0 mjd_nc[] 3 433 for i 0 mjd_nc[] 326 434 mkexposure $1.nc.$i $RA_CENTER $DEC_CENTER zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] mjd_nc[$i] $filt_nc:$i $2 327 435 end … … 334 442 end 335 443 336 local ix iy date time datetime ra dec ROOT RAo DECo ZPT MJD FILTER EXPTIME AIRMASS CATDIR 444 local ix iy date time datetime ra dec ROOT RAo DECo ZPT MJD FILTER EXPTIME AIRMASS CATDIR cmd 337 445 338 446 $ROOT = $1 … … 366 474 $options = -mjd $MJD 367 475 $options = $options -radec $ra $dec 368 $options = $options -type PS1_V2 476 477 #$options = $options -type PS1_V2 478 #$options = $options -type PS1_V3 479 #$options = $options -type PS1_V4 480 $options = $options -type PS1_V5 481 369 482 $options = $options -coords 370 483 $options = $options -photcode GPC1.$FILTER.XY$ix\$iy 371 484 $options = $options -no-noise 485 $options = $options -flags 486 $options = $options -bad-psfqf-frac $DEFECT_FRAC 372 487 $options = $options -size $CHIP_DX $CHIP_DY 373 488 $options = $options -crpix {0.5*$CHIP_DX} {0.5*$CHIP_DY} 374 489 $options = $options -airmass $AIRMASS 375 490 $options = $options -exptime $EXPTIME 376 exec mkcmf test.in.txt $ROOT.$ix.$iy.cmf $options 377 echo mkcmf test.in.txt $ROOT.$ix.$iy.cmf $options378 491 492 tapEXEC mkcmf test.in.txt $ROOT.$ix.$iy.cmf $options 493 379 494 # the fake images have inconsistent ra,dec and airmass,sidtime values 380 echo addstar $ROOT.$ix.$iy.cmf -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass 381 exec addstar $ROOT.$ix.$iy.cmf -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass >& tmp.log 495 tapEXEC addstar $ROOT.$ix.$iy.cmf -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass 382 496 end 383 497 end … … 405 519 subset stars_mr = stars_mag if valid 406 520 407 set cell_x = int(stars_x / ($CHIP_DX / $NCELL_X)) 408 set cell_y = int(stars_y / ($CHIP_DX / $NCELL_X)) 521 # note eddie's esoteric padding rule: 522 set cell_x = max(0 , min(1 , int((stars_x + 8) / ($CHIP_DX / $NCELL_X)))) 523 set cell_y = max(0 , min(1 , int((stars_y + 10) / ($CHIP_DX / $NCELL_X)))) 409 524 410 525 # eddie says: M_real = M_inst + zpt + ff_offset … … 418 533 end 419 534 420 write -f "%10.6f %10.6f %7.3f %6.1f %6.1f %7.3f" $1 stars_r stars_d stars_mr stars_x stars_y stars_mi 535 # create bad detections / detections to ignore or avoid, save to a file? 536 537 # create 3 types of things to ignore / avoid 538 # * badPhot (deviate the photometry) 539 # * badFlag (set a bad flag bit) 540 # * poorFlag (set a bad flag bit) 541 set badPhot = rnd(stars_r) < $DEFECT_FRAC 542 set badFlag = rnd(stars_r) < $DEFECT_FRAC 543 set poorFlag = rnd(stars_r) < $DEFECT_FRAC 544 545 # create deviant photometry (1%) 546 # I'm setting the flag value 0x02 (EXTMODEL) if the object is deviated. This is a simple way to pass the info 547 # note that outlier rejection only occurs for Nmeas > 5 548 set stars_mi = stars_mi + 0.2*badPhot 549 set stars_fl = zero(stars_mi) + 0x00000080*badFlag + 0x00000100*poorFlag + 0x00000002*badPhot 550 551 # bad flags that we sould respect: 552 # PM_SOURCE_MODE_FAIL = 0x00000008, ///< Fit (non-linear) failed (non-converge, off-edge, run to zero) 553 # PM_SOURCE_MODE_SATSTAR = 0x00000080, ///< Source model peak is above saturation 554 # PM_SOURCE_MODE_BADPSF = 0x00000400, ///< Failed to get good estimate of object's PSF 555 # PM_SOURCE_MODE_DEFECT = 0x00000800, ///< Source is thought to be a defect 556 # PM_SOURCE_MODE_SATURATED = 0x00001000, ///< Source is thought to be saturated pixels (bleed trail) 557 # PM_SOURCE_MODE_CR_LIMIT = 0x00002000, ///< Source has crNsigma above limit 558 # PM_SOURCE_MODE_MOMENTS_FAILURE = 0x00008000, ///< could not measure the moments 559 # PM_SOURCE_MODE_SKY_FAILURE = 0x00010000, ///< could not measure the local sky 560 # PM_SOURCE_MODE_SKYVAR_FAILURE = 0x00020000, ///< could not measure the local sky variance 561 # PM_SOURCE_MODE_SIZE_SKIPPED = 0x10000000, ///< size could not be determined 562 563 # poor flags that we should respect: 564 # PM_SOURCE_MODE_POOR = 0x00000010, ///< Fit succeeds, but low-SN, high-Chisq, or large (for PSF -- drop?) 565 # PM_SOURCE_MODE_PAIR = 0x00000020, ///< Source fitted with a double psf 566 # PM_SOURCE_MODE_BLEND = 0x00000100, ///< Source is a blend with other sources 567 # PM_SOURCE_MODE_BELOW_MOMENTS_SN = 0x00040000, ///< moments not measured due to low S/N 568 # PM_SOURCE_MODE_BLEND_FIT = 0x00400000, ///< source was fitted as a blend 569 # PM_SOURCE_MODE_ON_SPIKE = 0x20000000, ///< peak lands on diffraction spike 570 # PM_SOURCE_MODE_ON_GHOST = 0x40000000, ///< peak lands on ghost or glint 571 # PM_SOURCE_MODE_OFF_CHIP = 0x80000000, ///< peak lands off edge of chip 572 573 write -f "%10.6f %10.6f %7.3f %6.1f %6.1f %7.3f 0x%x" $1 stars_r stars_d stars_mr stars_x stars_y stars_mi stars_fl 421 574 end 422 575 … … 439 592 set stars_ra = $RA_CENTER + $RA_RANGE * (rnd(tmp) - 0.5) / 3600 / dcos ($DEC_CENTER) 440 593 set stars_dec = $DEC_CENTER + $DEC_RANGE * (rnd(tmp) - 0.5) / 3600 441 set stars_mag = 15.0 + 4.0 * rnd(tmp) 594 set stars_mag = 10.0 + 10.0 * rnd(tmp) 595 set stars_dmag = 0.02 + 0.1*rnd(tmp) 596 end 597 598 macro mk2mass 599 if ($0 != 3) 600 echo "USAGE: mk2mass (fileroot) (catdir)" 601 break 602 end 603 604 if (not($DO_2MASS)) return 605 606 local ROOT CATDIR 607 608 $ROOT = $1 609 $CATDIR = $2 610 611 set stars_flags = 0x00c00000*(rnd(stars_ra) < 0.1) + 0x7*(rnd(stars_ra) < 0.8) 612 write $ROOT.2mass.dat -f "%10.6f %10.6f %6.3f %6.3f 0x%x" stars_ra stars_dec stars_mag stars_dmag stars_flags 613 614 tapEXEC addstar -ref $ROOT.2mass.dat -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass -photcode 2MASS_J 615 616 set r_2mass = stars_ra 617 set d_2mass = stars_dec 618 set m_2mass = stars_mag 619 set dm_2mass = stars_dmag 620 set fl_2mass = stars_flags 621 end 622 623 macro ck2mass 624 if ($0 != 2) 625 echo "USAGE: ck2mass (stage)" 626 break 627 end 628 629 if (not($DO_2MASS)) return 630 631 if ("$1" == "addstar") 632 skyregion {$RA_CENTER - 0.2/dcos($DEC_CENTER)} {$RA_CENTER + 0.2/dcos($DEC_CENTER)} {$DEC_CENTER - 0.2} {$DEC_CENTER + 0.2} 633 mextract ra dec mag xccd yccd dbflags photflags where (photcode == 2011) 634 tapOK {ra[] == r_2mass[]} "read in as many 2mass stars as we generated" 635 636 match2d -closest ra dec r_2mass d_2mass 0.001 -index1 index1 -index2 index2 637 subset tmp = index1 if (index1 >= 0) 638 tapOK {tmp[] == ra[]} "2mass sources match those generated" 639 end 640 641 if ("$1" == "relphot") 642 subset rs = r_2mass if (fl_2mass & 0x00c00000) 643 subset ds = d_2mass if (fl_2mass & 0x00c00000) 644 avmatch rs ds 0.1 flags 645 subset tmp = rs if (flags & 0x02000000); # extended in 2mass 646 tapOK {tmp[] == rs[]} "2mass extended objects properly marked" 647 648 subset rs = r_2mass if (fl_2mass & 0x07) 649 subset ds = d_2mass if (fl_2mass & 0x07) 650 avmatch rs ds 0.1 flags 651 subset tmp = rs if (flags & 0x08000000); # extended in 2mass 652 tapOK {tmp[] == rs[]} "2mass good objects properly marked" 653 end 654 end 655 656 macro mksynth 657 if ($0 != 3) 658 echo "USAGE: mksynth (fileroot) (catdir)" 659 break 660 end 661 662 if (not($DO_SYNTH)) return 663 664 local ROOT CATDIR 665 666 $ROOT = $1 667 $CATDIR = $2 668 669 subset r_synth = stars_ra if (stars_mag < 17) 670 subset d_synth = stars_dec if (stars_mag < 17) 671 subset m_synth = stars_mag if (stars_mag < 17) 672 subset dm_synth = stars_dmag if (stars_mag < 17) 673 subset fl_synth = stars_flags if (stars_mag < 17) 674 675 write $ROOT.synth.dat -f "%10.6f %10.6f %6.3f %6.3f 0x%x" r_synth d_synth m_synth dm_synth fl_synth 676 677 tapEXEC addstar -ref $ROOT.synth.dat -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass -photcode SYNTH.g 678 end 679 680 macro cksynth 681 if ($0 != 2) 682 echo "USAGE: cksynth (stage)" 683 break 684 end 685 686 if (not($DO_SYNTH)) return 687 688 if ("$1" == "addstar") 689 skyregion {$RA_CENTER - 0.2/dcos($DEC_CENTER)} {$RA_CENTER + 0.2/dcos($DEC_CENTER)} {$DEC_CENTER - 0.2} {$DEC_CENTER + 0.2} 690 mextract ra dec mag xccd yccd dbflags photflags where (photcode == 3001) 691 tapOK {ra[] == r_synth[]} "read in as many synth stars as we generated" 692 693 match2d -closest ra dec r_synth d_synth 0.001 -index1 index1 -index2 index2 694 subset tmp = index1 if (index1 >= 0) 695 tapOK {tmp[] == ra[]} "synth sources match those generated" 696 end 697 698 if ("$1" == "relphot") 699 subset rs = r_synth if (m_synth < 13.5) 700 subset ds = d_synth if (m_synth < 13.5) 701 avmatch rs ds 0.1 g:flags 702 subset tmp = rs if (g:flags & 0x04); # synth used for photometry 703 tapOK {tmp[] == rs[]} "synth objects used for photometry properly marked" 704 end 705 end 706 707 macro mktycho 708 if ($0 != 3) 709 echo "USAGE: mktycho (fileroot) (catdir)" 710 break 711 end 712 713 if (not($DO_TYCHO)) return 714 715 local ROOT CATDIR 716 717 $ROOT = $1 718 $CATDIR = $2 719 720 subset r_tycho = stars_ra if (stars_mag < 12) 721 subset d_tycho = stars_dec if (stars_mag < 12) 722 subset m_tycho = stars_mag if (stars_mag < 12) 723 subset dm_tycho = stars_dmag if (stars_mag < 12) 724 subset fl_tycho = stars_flags if (stars_mag < 12) 725 726 write $ROOT.tycho.dat -f "%10.6f %10.6f %6.3f %6.3f 0x%x" r_tycho d_tycho m_tycho dm_tycho fl_tycho 727 728 tapEXEC addstar -ref $ROOT.tycho.dat -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass -photcode TYCHO_B 729 730 $KAPA = kapa -noX 731 dev -n tmpdev 732 # resize 100 100 733 resize 50 50 734 region $RA_CENTER $DEC_CENTER 0.2 735 section default -imtool none 736 # causes trouble for this to come before region... 737 create tmp 0 1 738 cdensify tmpmap tmp tmp 739 set map = zero(tmpmap) + 0.2 740 close 741 $KAPA = kapa 742 743 local filter 744 foreach filter g r i z y 745 if ("$filter" == "g") 746 wd map $ROOT.synthzpts.fits -bitpix -32 -bzero 0.0 -bscale 1.0 747 end 748 keyword map EXTNAME -w "map_$filter" 749 wd map $ROOT.synthzpts.fits -bitpix -32 -bzero 0.0 -bscale 1.0 -extend 750 end 751 end 752 753 macro cktycho 754 if ($0 != 2) 755 echo "USAGE: cktycho (stage)" 756 break 757 end 758 759 if (not($DO_TYCHO)) return 760 761 if ("$1" == "addstar") 762 skyregion {$RA_CENTER - 0.2/dcos($DEC_CENTER)} {$RA_CENTER + 0.2/dcos($DEC_CENTER)} {$DEC_CENTER - 0.2} {$DEC_CENTER + 0.2} 763 mextract ra dec mag xccd yccd dbflags photflags where (photcode == 2020) 764 tapOK {ra[] == r_tycho[]} "read in as many tycho stars as we generated" 765 766 match2d -closest ra dec r_tycho d_tycho 0.001 -index1 index1 -index2 index2 767 subset tmp = index1 if (index1 >= 0) 768 tapOK {tmp[] == ra[]} "tycho sources match those generated" 769 end 770 771 if ("$1" == "relphot") 772 subset rst = r_tycho if (m_tycho < 12) 773 subset dst = d_tycho if (m_tycho < 12) 774 # XXX : should not restrict to 'g' 775 avmatch rst dst 0.1 g:flags 776 subset tmp = rst if (g:flags & 0x40); # tycho used for photometry 777 tapOK {tmp[] == rst[]} "tycho objects used for photometry properly marked" 778 779 # non-tycho stars with synth phot should be repaired 780 subset rsn = r_synth if (m_synth > 12) && (m_synth < 13.5) 781 subset dsn = d_synth if (m_synth > 12) && (m_synth < 13.5) 782 # XXX : should not restrict to 'g' 783 avmatch rsn dsn 0.1 g:flags 784 subset tmp = rsn if (g:flags & 0x80); # synth photometry repaired 785 tapOK {tmp[] == rsn[]} "tycho objects used for photometry properly marked" 786 end 442 787 end 443 788 … … 456 801 457 802 # define the season boundaries 458 keyword phu TS0_0000 -wf 55000.0459 keyword phu TS1_0000 -wf 55010.0460 keyword phu TS0_0001 -wf 55010.0461 keyword phu TS1_0001 -wf 55020.0462 keyword phu TS0_0002 -wf 55020.0463 keyword phu TS1_0002 -wf 55030.0803 keyword phu S0_MJD0 -wf 55000.0 804 keyword phu S1_MJD0 -wf 55010.0 805 keyword phu S0_MJD1 -wf 55010.0 806 keyword phu S1_MJD1 -wf 55020.0 807 keyword phu S0_MJD2 -wf 55020.0 808 keyword phu S1_MJD2 -wf 55030.0 464 809 465 810 # create a single flat-field correction map for a single chip 466 811 mcreate cell_off 2 2 467 cell_off[0][0] = 0.01 468 cell_off[1][0] = -0.01 469 cell_off[0][1] = 0.02 470 cell_off[1][1] = -0.02 812 if ($USE_CELL_OFFSETS) 813 cell_off[0][0] = 0.05 814 cell_off[1][0] = -0.03 815 cell_off[0][1] = 0.08 816 cell_off[1][1] = -0.10 817 end 471 818 472 819 # in the correction table, we have an image of the full exposure … … 481 828 for iyc 0 $NCELL_Y 482 829 for ix 0 $NCHIP_X 830 set tcell_off = cell_off 831 if ($ix < 4) 832 rotate tcell_off 180 833 end 483 834 for ixc 0 $NCELL_X 484 concat cell_off[$ixc][$iyc] image_offset835 concat tcell_off[$ixc][$iyc] image_offset 485 836 end 486 837 end … … 498 849 set mjd_obs = mjd_uc 499 850 set zp = zpt_uc 500 set resid = 0.02*rnd(zpt_uc) - 0.01 851 852 if ($SET_UC_RESID) 853 set resid = 0.02*rnd(zpt_uc) - 0.01 854 else 855 set resid = zero(zpt_uc) 856 end 501 857 502 858 delete -q flatcorr -
trunk/Ohana/src/addstar/test/simple.dvo
r37036 r38441 10 10 test.fields PS1_V2 PS1_V1 11 11 test.fields PS1_V3 PS1_V1 12 test.fields PS1_V 4PS1_V112 test.fields PS1_V5 PS1_V1 13 13 14 14 test.fields PS1_DEV_0 PS1_V2 … … 17 17 test.fields PS1_V2 PS1_V2 18 18 test.fields PS1_V3 PS1_V2 19 test.fields PS1_V 4 PS1_V419 test.fields PS1_V5 PS1_V2 20 20 21 21 test.fields PS1_DEV_0 PS1_V3 … … 24 24 test.fields PS1_V2 PS1_V3 25 25 test.fields PS1_V3 PS1_V3 26 test.fields PS1_V 4 PS1_V426 test.fields PS1_V5 PS1_V3 27 27 28 28 test.fields PS1_DEV_0 PS1_V4 … … 31 31 test.fields PS1_V2 PS1_V4 32 32 test.fields PS1_V3 PS1_V4 33 test.fields PS1_V 4PS1_V433 test.fields PS1_V5 PS1_V4 34 34 end 35 35 … … 54 54 55 55 mkinput 56 echo mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1 $NO_NOISE 57 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1 $NO_NOISE 58 if ($TAP_VERBOSE) 59 echo exec addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass 60 exec addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass 61 else 62 echo addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass 63 exec addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass >& tmp.log 64 end 56 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1 $NO_NOISE 57 tapEXEC addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass 65 58 66 59 list testfields -copy testfields_$1 … … 79 72 if ("$name:0" == "SKIP") continue 80 73 if ("$name:2" == "SKIP") continue 74 81 75 read -fits Chip.psf $name:0 82 76 mextract $name:2 … … 92 86 set d = $name:0 - $name:2 93 87 vstat -q d 94 tapOK {abs($MEAN) < 0.001} "$name:0 vs $name:2 (MEAN )"95 tapOK {abs($SIGMA) < 0.001} "$name:0 vs $name:2 (SIGMA )"88 tapOK {abs($MEAN) < 0.001} "$name:0 vs $name:2 (MEAN = $MEAN)" 89 tapOK {abs($SIGMA) < 0.001} "$name:0 vs $name:2 (SIGMA = $SIGMA)" 96 90 97 91 # detection ID must be first for this to work: … … 142 136 if ("$name:0" == "PSF_THETA") 143 137 # echo $MEAN 144 tapOK {abs($MEAN) < 0.006} "$name:0 vs $name:2 (MEAN )"145 tapOK {abs($SIGMA) < 0.001} "$name:0 vs $name:2 (SIGMA )"138 tapOK {abs($MEAN) < 0.006} "$name:0 vs $name:2 (MEAN = $MEAN)" 139 tapOK {abs($SIGMA) < 0.001} "$name:0 vs $name:2 (SIGMA = $SIGMA)" 146 140 continue 147 141 end 148 142 149 tapOK {abs($MEAN) < 0.001} "$name:0 vs $name:2 (MEAN )"150 tapOK {abs($SIGMA) < 0.001} "$name:0 vs $name:2 (SIGMA )"143 tapOK {abs($MEAN) < 0.001} "$name:0 vs $name:2 (MEAN = $MEAN)" 144 tapOK {abs($SIGMA) < 0.001} "$name:0 vs $name:2 (SIGMA = $MEAN)" 151 145 end 152 146 … … 231 225 PSF_INST_MAG : mag:inst 232 226 PSF_INST_MAG_SIG : mag:err 233 AP_MAG_STANDARD : mag:ap # FAIL227 # AP_MAG_STANDARD : mag:ap # FAIL 234 228 AP_MAG_RADIUS : SKIP # no accessor 235 229 PEAK_FLUX_AS_MAG : SKIP # no accessor … … 237 231 CAL_PSF_MAG_SIG : SKIP # photometry is not calibrated in the cmf 238 232 SKY : sky 239 SKY_SIG : sky_err233 SKY_SIGMA : sky_err 240 234 PSF_CHISQ : psf_chisq 241 235 CR_NSIGMA : cr_nsigma … … 267 261 PSF_INST_MAG : mag:inst 268 262 PSF_INST_MAG_SIG : mag:err 269 AP_MAG_STANDARD : mag:ap # FAIL263 # AP_MAG_STANDARD : mag:ap # FAIL 270 264 AP_MAG_RADIUS : SKIP # no accessor 271 265 PEAK_FLUX_AS_MAG : SKIP # no accessor … … 273 267 CAL_PSF_MAG_SIG : SKIP # photometry is not calibrated in the cmf 274 268 SKY : sky 275 SKY_SIG : sky_err269 SKY_SIGMA : sky_err 276 270 PSF_CHISQ : psf_chisq 277 271 CR_NSIGMA : cr_nsigma … … 303 297 PSF_INST_FLUX : SKIP # not ingested into DVO 304 298 PSF_INST_FLUX_SIG : SKIP # not ingested into DVO 305 AP_MAG_STANDARD : mag:aperinst # FAIL299 # AP_MAG_STANDARD : mag:aperinst # FAIL 306 300 AP_MAG_RAW : SKIP # not ingested into DVO 307 301 AP_MAG_RADIUS : SKIP # not ingested into DVO … … 312 306 PEAK_FLUX_AS_MAG : SKIP # not ingested into DVO 313 307 SKY : sky 314 SKY_SIG : sky_err308 SKY_SIGMA : sky_err 315 309 PSF_CHISQ : psf_chisq 316 310 CR_NSIGMA : cr_nsigma … … 332 326 MOMENTS_R1 : SKIP # not ingested into DVO 333 327 MOMENTS_RH : SKIP # not ingested into DVO 334 KRON_FLUX : mag:kron inst335 KRON_FLUX_ERR : mag:kron err328 KRON_FLUX : mag:kron:inst 329 KRON_FLUX_ERR : mag:kron:err 336 330 KRON_FLUX_INNER : SKIP # not ingested into DVO 337 331 KRON_FLUX_OUTER : SKIP # not ingested into DVO -
trunk/Ohana/src/addstar/test/tap.dvo
r34405 r38441 3 3 if (not($?TAP_BREAK)) set TAP_BREAK = 0 4 4 if (not($?TAP_VERBOSE)) set TAP_VERBOSE = 0 5 6 macro tapEXEC 7 if ($0 < 3) 8 echo "USAGE: tapEXEC (command)" 9 break 10 end 11 12 local i cmd result 13 14 $cmd = "" 15 for i 1 $0 16 $cmd = $cmd $$i 17 end 18 19 if ($TAP_VERBOSE >= 2) echo $cmd 20 21 break -auto off 22 exec $cmd >& tap.log 23 $result = $STATUS 24 break -auto on 25 26 if (not($result)) 27 exec cat tap.log 28 echo "not ok : $cmd" 29 $TAP_NFAIL ++ 30 $TAP_LAST = 0 31 if ($TAP_BREAK) 32 break 33 end 34 else 35 if ($TAP_VERBOSE >= 1) echo "ok : $cmd" 36 $TAP_LAST = 1 37 end 38 $TAP_NDONE ++ 39 end 5 40 6 41 macro tapOK … … 11 46 12 47 if ($1) 13 if ($TAP_VERBOSE )48 if ($TAP_VERBOSE >= 1) 14 49 echo "ok : $2" 15 50 end -
trunk/Ohana/src/checkastro/src/bcatalog.c
r37807 r38441 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); -
trunk/Ohana/src/checkastro/src/checkastro_images.c
r36833 r38441 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 */ -
trunk/Ohana/src/checkastro/src/load_catalogs.c
r36833 r38441 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); -
trunk/Ohana/src/checkastro/src/load_images.c
r37807 r38441 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"); -
trunk/Ohana/src/delstar/src/delete_duplicate_images.c
r36833 r38441 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); -
trunk/Ohana/src/delstar/src/delete_duplicate_measures.c
r37807 r38441 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); -
trunk/Ohana/src/delstar/src/delete_fix_LAP.c
r35807 r38441 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); -
trunk/Ohana/src/delstar/src/delete_fix_LAP_edges.c
r37040 r38441 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); -
trunk/Ohana/src/delstar/src/delete_fix_LAP_edges_delete.c
r35805 r38441 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); -
trunk/Ohana/src/delstar/src/delete_image_photcodes.c
r34749 r38441 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); -
trunk/Ohana/src/delstar/src/delete_imagefile.c
r34749 r38441 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); -
trunk/Ohana/src/delstar/src/delete_imagename.c
r37807 r38441 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); -
trunk/Ohana/src/delstar/src/delete_orphans.c
r27435 r38441 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); -
trunk/Ohana/src/delstar/src/delete_photcodes.c
r35758 r38441 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); -
trunk/Ohana/src/delstar/src/delete_photcodes_single.c
r35107 r38441 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); -
trunk/Ohana/src/delstar/src/delete_times.c
r37807 r38441 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); -
trunk/Ohana/src/delstar/src/delstar.c
r35837 r38441 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"); -
trunk/Ohana/src/delstar/src/find_image_db.c
r29001 r38441 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; -
trunk/Ohana/src/delstar/src/find_matches.c
r34088 r38441 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); -
trunk/Ohana/src/dvolens/src/update_objects.c
r37358 r38441 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); -
trunk/Ohana/src/dvomerge/Makefile
r37807 r38441 164 164 $(BIN)/dvoutils.$(ARCH) : $(DVOUTILS) 165 165 166 INSTALL = dvomerge dvomerge_client dvoconvert dvosecfilt dvosecfilt_client dvorepair dvoverify dvoverify_client dvoverify 166 INSTALL = dvomerge dvomerge_client dvoconvert dvosecfilt dvosecfilt_client dvorepair dvoverify dvoverify_client dvoverify dvoutils 167 167 168 168 # dependancy rules for binary code ######################### -
trunk/Ohana/src/dvomerge/include/dvomerge.h
r37807 r38441 41 41 int REPLACE_BY_PHOTCODE; 42 42 int FORCE_MERGE; 43 int MAX_CLIENTS; 43 44 char *UPDATE_CATFORMAT; 45 char *UPDATE_CATCOMPRESS; 44 46 45 47 int MATCHED_TABLES; -
trunk/Ohana/src/dvomerge/src/LoadCatalog.c
r37807 r38441 8 8 9 9 // always load all of the data (if any exists) 10 catalog[0].catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF | LOAD_LENSING | LOAD_LENSOBJ | LOAD_STARPAR;10 catalog[0].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ | DVO_LOAD_STARPAR | DVO_LOAD_GALPHOT; 11 11 12 12 catalog[0].catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data -
trunk/Ohana/src/dvomerge/src/LoadImages.c
r29938 r38441 34 34 } 35 35 36 image = gfits_table_get_Image (&db->ftable, Nimage, &db->s wapped);36 image = gfits_table_get_Image (&db->ftable, Nimage, &db->scaledValue, &db->nativeOrder); 37 37 if (!image) { 38 38 fprintf (stderr, "ERROR: failed to read images\n"); -
trunk/Ohana/src/dvomerge/src/args.c
r38062 r38441 44 44 } 45 45 46 /* limit the impact of a dvomerge -parallel */ 47 MAX_CLIENTS = 10; 48 if ((N = get_argument (*argc, argv, "-max-clients"))) { 49 remove_argument (N, argc, argv); 50 MAX_CLIENTS = atoi(argv[N]); 51 remove_argument (N, argc, argv); 52 } 53 46 54 /* use a different photcode file to define mean values */ 47 55 if ((N = get_argument (*argc, argv, "-photcode-file"))) { … … 62 70 remove_argument (N, argc, argv); 63 71 UPDATE_CATFORMAT = strcreate (argv[N]); 72 remove_argument (N, argc, argv); 73 } 74 UPDATE_CATCOMPRESS = NULL; 75 if ((N = get_argument (*argc, argv, "-update-catcompress"))) { 76 remove_argument (N, argc, argv); 77 UPDATE_CATCOMPRESS = strcreate (argv[N]); 64 78 remove_argument (N, argc, argv); 65 79 } … … 212 226 remove_argument (N, argc, argv); 213 227 } 228 UPDATE_CATCOMPRESS = NULL; 229 if ((N = get_argument (*argc, argv, "-update-catcompress"))) { 230 remove_argument (N, argc, argv); 231 UPDATE_CATCOMPRESS = strcreate (argv[N]); 232 remove_argument (N, argc, argv); 233 } 214 234 215 235 /* replace measurement, don't duplicate */ -
trunk/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r37807 r38441 16 16 short *TgtCodes; 17 17 18 imagesSrc = gfits_table_get_Image (&src[0].ftable, &NimagesSrc, &src[0].s wapped);18 imagesSrc = gfits_table_get_Image (&src[0].ftable, &NimagesSrc, &src[0].scaledValue, &src[0].nativeOrder); 19 19 if (!imagesSrc) { 20 20 fprintf (stderr, "ERROR: failed to read images from src\n"); … … 22 22 } 23 23 24 imagesTgt = gfits_table_get_Image (&tgt[0].ftable, &NimagesTgt, &tgt[0].s wapped);24 imagesTgt = gfits_table_get_Image (&tgt[0].ftable, &NimagesTgt, &tgt[0].scaledValue, &tgt[0].nativeOrder); 25 25 if (!imagesTgt) { 26 26 fprintf (stderr, "ERROR: failed to read images from tgt\n"); … … 83 83 } 84 84 85 images = gfits_table_get_Image (&in[0].ftable, &Nimages, &in[0].s wapped);85 images = gfits_table_get_Image (&in[0].ftable, &Nimages, &in[0].scaledValue, &in[0].nativeOrder); 86 86 if (!images) { 87 87 fprintf (stderr, "ERROR: failed to read images\n"); -
trunk/Ohana/src/dvomerge/src/dvoconvert.c
r33657 r38441 82 82 83 83 // skip empty input catalogs 84 if (!incatalog.Nave s_disk) {84 if (!incatalog.Naverage_disk) { 85 85 dvo_catalog_unlock (&incatalog); 86 86 dvo_catalog_free (&incatalog); … … 93 93 SkyListFree (inlist); 94 94 95 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;95 outcatalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 96 96 dvo_catalog_save (&outcatalog, VERBOSE); 97 97 dvo_catalog_unlock (&outcatalog); … … 122 122 /*** load output/Images.dat ***/ 123 123 sprintf (ImageCat, "%s/Images.dat", output); 124 gfits_db_init (&outDB); 124 125 outDB.mode = dvo_catalog_catmode (CATMODE); 125 126 outDB.format = dvo_catalog_catformat (CATFORMAT); … … 135 136 /*** load input/Images.dat ***/ 136 137 sprintf (ImageCat, "%s/Images.dat", input); 138 gfits_db_init (&inDB); 137 139 // inDB.mode = dvo_catalog_catmode (CATMODE); 138 140 // inDB.format = dvo_catalog_catformat (CATFORMAT); … … 149 151 150 152 // convert the raw image table to Image type (byteswap if needed) 151 images = gfits_table_get_Image (&inDB.ftable, &Nimages, &inDB.s wapped);153 images = gfits_table_get_Image (&inDB.ftable, &Nimages, &inDB.scaledValue, &inDB.nativeOrder); 152 154 if (!images) { 153 155 fprintf (stderr, "ERROR: failed to read images\n"); -
trunk/Ohana/src/dvomerge/src/dvomergeContinue.c
r37116 r38441 109 109 LoadCatalog (&incatalog, &inlist[0].regions[i][0], inlist[0].filename[i], "r", NsecfiltInput); 110 110 // skip empty input catalogs 111 if (!incatalog.Nave s_disk) {111 if (!incatalog.Naverage_disk) { 112 112 dvo_catalog_unlock (&incatalog); 113 113 dvo_catalog_free (&incatalog); -
trunk/Ohana/src/dvomerge/src/dvomergeContinue_threaded.c
r37116 r38441 47 47 LoadCatalog (&incatalog, threadData->region, threadData->filename, "r", threadData->NsecfiltInput); 48 48 // skip empty input catalogs 49 if (!incatalog.Nave s_disk) {49 if (!incatalog.Naverage_disk) { 50 50 dvo_catalog_unlock (&incatalog); 51 51 dvo_catalog_free (&incatalog); -
trunk/Ohana/src/dvomerge/src/dvomergeCreate.c
r37116 r38441 145 145 146 146 // skip empty input catalogs 147 if (!incatalog.Nave s_disk) {147 if (!incatalog.Naverage_disk) { 148 148 dvo_catalog_unlock (&incatalog); 149 149 dvo_catalog_free (&incatalog); … … 166 166 167 167 // skip empty input catalogs 168 if (!incatalog.Nave s_disk) {168 if (!incatalog.Naverage_disk) { 169 169 dvo_catalog_unlock (&incatalog); 170 170 dvo_catalog_free (&incatalog); … … 204 204 /*** load output/Images.dat ***/ 205 205 sprintf (ImageCat, "%s/Images.dat", output); 206 gfits_db_init (&outDB); 206 207 outDB.mode = dvo_catalog_catmode (CATMODE); 207 208 outDB.format = dvo_catalog_catformat (CATFORMAT); … … 218 219 /*** load input1/Images.dat ***/ 219 220 sprintf (ImageCat, "%s/Images.dat", input1); 221 gfits_db_init (&in1DB); 220 222 in1DB.mode = dvo_catalog_catmode (CATMODE); 221 223 in1DB.format = dvo_catalog_catformat (CATFORMAT); … … 237 239 /*** load input2/Images.dat ***/ 238 240 sprintf (ImageCat, "%s/Images.dat", input2); 241 gfits_db_init (&in2DB); 239 242 in2DB.mode = dvo_catalog_catmode (CATMODE); 240 243 in2DB.format = dvo_catalog_catformat (CATFORMAT); -
trunk/Ohana/src/dvomerge/src/dvomergeFromList.c
r37116 r38441 113 113 114 114 // skip empty input catalogs 115 if (!incatalog.Nave s_disk) {115 if (!incatalog.Naverage_disk) { 116 116 dvo_catalog_unlock (&incatalog); 117 117 dvo_catalog_free (&incatalog); -
trunk/Ohana/src/dvomerge/src/dvomergeImageIDs.c
r36833 r38441 10 10 /*** load input1/Images.dat ***/ 11 11 sprintf (ImageCat, "%s/Images.dat", input); 12 gfits_db_init (&inDB); 12 13 inDB.mode = dvo_catalog_catmode (CATMODE); 13 14 inDB.format = dvo_catalog_catformat (CATFORMAT); 14 status = dvo_image_lock (&inDB, ImageCat, 3600.0, LCK_SOFT); // shorter timeout?15 status = dvo_image_lock (&inDB, ImageCat, 3600.0, LCK_SOFT); // shorter timeout? 15 16 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", inDB.filename); 16 17 … … 37 38 /*** load output/Images.dat ***/ 38 39 sprintf (ImageCat, "%s/Images.dat", output); 40 gfits_db_init (&outDB); 39 41 outDB.mode = dvo_catalog_catmode (CATMODE); 40 42 outDB.format = dvo_catalog_catformat (CATFORMAT); … … 93 95 /*** load input1/Images.dat ***/ 94 96 sprintf (ImageCat, "%s/Images.dat", input); 97 gfits_db_init (&inDB); 95 98 inDB.mode = dvo_catalog_catmode (CATMODE); 96 99 inDB.format = dvo_catalog_catformat (CATFORMAT); 97 status = dvo_image_lock (&inDB, ImageCat, 5400.0, LCK_XCLD); // shorter timeout?100 status = dvo_image_lock (&inDB, ImageCat, 5400.0, LCK_XCLD); // shorter timeout? 98 101 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", inDB.filename); 99 102 … … 115 118 /*** load output/Images.dat ***/ 116 119 sprintf (ImageCat, "%s/Images.dat", output); 120 gfits_db_init (&outDB); 117 121 outDB.mode = dvo_catalog_catmode (CATMODE); 118 122 outDB.format = dvo_catalog_catformat (CATFORMAT); -
trunk/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
r38062 r38441 142 142 143 143 // skip empty input catalogs 144 if (!incatalog.Nave s_disk) {144 if (!incatalog.Naverage_disk) { 145 145 dvo_catalog_unlock (&incatalog); 146 146 dvo_catalog_free (&incatalog); … … 176 176 177 177 // if no catalog already exists, use the input catalog to define the format or the specified format 178 if (outcatalog.Naves_disk == 0) { 179 if (UPDATE_CATFORMAT) { 180 outcatalog.catformat = dvo_catalog_catformat (UPDATE_CATFORMAT); 181 } else { 182 outcatalog.catformat = incatalog.catformat; 183 } 178 if (UPDATE_CATFORMAT) { 179 outcatalog.catformat = dvo_catalog_catformat (UPDATE_CATFORMAT); 180 } else { 181 outcatalog.catformat = incatalog.catformat; 182 } 183 if (UPDATE_CATCOMPRESS) { 184 outcatalog.catcompress = dvo_catalog_catcompress (UPDATE_CATCOMPRESS); 185 } else { 186 outcatalog.catcompress = incatalog.catcompress; 184 187 } 185 188 … … 227 230 return TRUE; 228 231 } 232 233 int dvomergeUpdate_parallel_group (HostTableGroup *group, char *absinput, char *absoutput); 229 234 230 235 // launch the dvomergeUpdate_client jobs to the parallel hosts … … 254 259 } 255 260 261 int Ngroups; 262 HostTableGroup *groups = HostTableGroupsMaxNumber (table, &Ngroups, MAX_CLIENTS); 263 // split the table into Ngroups, each with a unique set of machines (this avoids overloading the remote host machines) 264 256 265 int i; 257 for (i = 0; i < table->Nhosts; i++) { 266 for (i = 0; i < Ngroups; i++) { 267 // update only a max of MaxClient machines at a time 268 dvomergeUpdate_parallel_group (&groups[i], absinput, absoutput); 269 } 270 return TRUE; 271 } 272 273 int dvomergeUpdate_parallel_group (HostTableGroup *group, char *absinput, char *absoutput) { 274 275 int i; 276 for (i = 0; i < group->Nhosts; i++) { 258 277 259 278 // ensure that the paths are absolute path names 260 char *tmppath = abspath ( table->hosts[i].pathname, DVO_MAX_PATH);261 free ( table->hosts[i].pathname);262 table->hosts[i].pathname = tmppath;279 char *tmppath = abspath (group->hosts[i][0].pathname, DVO_MAX_PATH); 280 free (group->hosts[i][0].pathname); 281 group->hosts[i][0].pathname = tmppath; 263 282 264 283 // options / arguments that can affect relastro_client -update-objects: 265 284 char command[DVO_MAX_PATH]; 266 285 snprintf (command, DVO_MAX_PATH, "dvomerge_client %s into %s -hostID %d -hostdir %s -region %f %f %f %f -D ADDSTAR_RADIUS %f", 267 absinput, absoutput, table->hosts[i].hostID, table->hosts[i].pathname,286 absinput, absoutput, group->hosts[i][0].hostID, group->hosts[i][0].pathname, 268 287 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, RADIUS 269 288 ); … … 291 310 int status = system (command); 292 311 if (status) { 293 fprintf (stderr, "ERROR running photdbc_client\n");312 fprintf (stderr, "ERROR running dvomerge_client\n"); 294 313 exit (2); 295 314 } … … 297 316 // launch the job on the remote machine (no handshake) 298 317 int errorInfo = 0; 299 int pid = rconnect ("ssh", table->hosts[i].hostname, command, table->hosts[i].stdio, &errorInfo, FALSE);318 int pid = rconnect ("ssh", group->hosts[i][0].hostname, command, group->hosts[i][0].stdio, &errorInfo, FALSE); 300 319 if (!pid) { 301 if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", table->hosts[i].hostname, errorInfo);320 if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", group->hosts[i][0].hostname, errorInfo); 302 321 exit (1); 303 322 } 304 table->hosts[i].pid = pid; // save for future reference323 group->hosts[i][0].pid = pid; // save for future reference 305 324 } 306 325 } 307 326 308 327 if (PARALLEL_MANUAL) { 309 fprintf (stderr, "run the photdbc_client commands above. when these are done, hit return\n");328 fprintf (stderr, "run the dvomerge_client commands above. when these are done, hit return\n"); 310 329 getchar(); 311 330 } 312 331 if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) { 313 int status = HostTable WaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);332 int status = HostTableGroupWaitJobsGetIO (group, __FILE__, __LINE__, VERBOSE); 314 333 if (!status) { 315 334 fprintf (stderr, "error running one of the remote clients\n"); -
trunk/Ohana/src/dvomerge/src/dvomergeUpdate_threaded.c
r37116 r38441 44 44 LoadCatalog (&incatalog, threadData->region, threadData->filename, "r", threadData->NsecfiltInput); 45 45 // skip empty input catalogs 46 if (!incatalog.Nave s_disk) {46 if (!incatalog.Naverage_disk) { 47 47 dvo_catalog_unlock (&incatalog); 48 48 dvo_catalog_free (&incatalog); -
trunk/Ohana/src/dvomerge/src/dvorepairCPT.c
r37807 r38441 76 76 } 77 77 78 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat );78 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat, FALSE); 79 79 myAssert(measure, "failed to convert ftable to measure data"); 80 80 … … 156 156 gfits_modify_alt (&cptHeaderPHU, "SORTED", "%t", 1, FALSE); 157 157 158 myAbort ("test for compression"); 159 158 160 /* convert internal to external format */ 159 if (!AverageToFtable (&cptFtable, average, Naverage, catformat, NULL )) {161 if (!AverageToFtable (&cptFtable, average, Naverage, catformat, NULL, TRUE)) { 160 162 myAbort("trouble converting format"); 161 163 } -
trunk/Ohana/src/dvomerge/src/dvorepairDeleteImageList.c
r37807 r38441 46 46 FILE *cpmFile = NULL; 47 47 48 charcatformat;48 DVOCatFormat catformat; 49 49 50 50 N = get_argument (argc, argv, "-delete-image-list"); … … 246 246 gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow); 247 247 248 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat );248 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat, FALSE); 249 249 myAssert(measure, "failed to convert ftable to measure data"); 250 250 … … 284 284 285 285 // convert internal to external format 286 if (!MeasureToFtable (&cpmFtable, NULL, measureNew, NmeasureNew, catformat )) {286 if (!MeasureToFtable (&cpmFtable, NULL, measureNew, NmeasureNew, catformat, TRUE)) { 287 287 myAbort("trouble converting format"); 288 288 } … … 467 467 gfits_scan (&cptHeaderPHU, "NSECFILT", "%d", 1, &Nsecfilt); 468 468 469 myAbort ("test for compression"); 470 469 471 /* convert internal to external format */ 470 if (!AverageToFtable (&cptFtable, averageOut, NaverageOut, catformat, NULL )) {472 if (!AverageToFtable (&cptFtable, averageOut, NaverageOut, catformat, NULL, TRUE)) { 471 473 myAbort("trouble converting format"); 472 474 } … … 529 531 530 532 /* convert internal to external format */ 531 if (!SecFiltToFtable (&cpsFtable, secfilt, Nrows, catformat )) {533 if (!SecFiltToFtable (&cpsFtable, secfilt, Nrows, catformat, TRUE)) { 532 534 myAbort("trouble converting format"); 533 535 } -
trunk/Ohana/src/dvomerge/src/dvorepairDeleteImagesByExternID.c
r37807 r38441 38 38 char *imageFilename = NULL; 39 39 40 charcatformat;40 DVOCatFormat catformat; 41 41 42 42 N = get_argument (argc, argv, "-delete-images-by-extern-id"); … … 279 279 gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow); 280 280 281 myAbort ("fix compression"); 282 281 283 // this function can only handle PS1_V5 and later formats 282 284 // NOTE: FtableToMeasure (and equivalent) free the data associated with cpmFtable. 283 285 // We are left with the data in measure. 284 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat );286 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat, FALSE); 285 287 myAssert(measure, "failed to convert ftable to measure data"); 286 288 … … 331 333 332 334 // convert internal to external format 333 if (!MeasureToFtable (&cpmFtable, NULL, measureNew, NmeasureNew, catformat )) {335 if (!MeasureToFtable (&cpmFtable, NULL, measureNew, NmeasureNew, catformat, TRUE)) { 334 336 myAbort("trouble converting format"); 335 337 } … … 493 495 494 496 /* setup image table format and lock */ 497 gfits_db_init (&db); 495 498 db.mode = dvo_catalog_catmode ("SPLIT"); 496 499 db.format = dvo_catalog_catformat ("PS1_V5"); … … 658 661 gfits_scan (&cptHeaderPHU, "NSECFILT", "%d", 1, &Nsecfilt); 659 662 663 myAbort ("test for compression"); 664 660 665 /* convert internal to external format */ 661 if (!AverageToFtable (&cptFtable, averageOut, NaverageOut, catformat, NULL )) {666 if (!AverageToFtable (&cptFtable, averageOut, NaverageOut, catformat, NULL, TRUE)) { 662 667 myAbort("trouble converting format"); 663 668 } … … 727 732 728 733 /* convert internal to external format */ 729 if (!SecFiltToFtable (&cpsFtable, secfilt, Nrows, catformat )) {734 if (!SecFiltToFtable (&cpsFtable, secfilt, Nrows, catformat, TRUE)) { 730 735 myAbort("trouble converting format"); 731 736 } -
trunk/Ohana/src/dvomerge/src/dvorepairFixCPT.c
r37046 r38441 86 86 Matrix matrix; 87 87 88 charcatformat;88 DVOCatFormat catformat; 89 89 90 90 cpmFtable.header = &cpmHeaderTBL; … … 120 120 } 121 121 122 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat); 122 myAbort ("fix cpts"); 123 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat, FALSE); 123 124 myAssert(measure, "failed to convert ftable to measure data"); 124 125 … … 127 128 128 129 // convert internal to external format 129 if (!MeasureToFtable (&cpmFtable, NULL, measure, Nmeasure, catformat )) {130 if (!MeasureToFtable (&cpmFtable, NULL, measure, Nmeasure, catformat, TRUE)) { 130 131 myAbort("trouble converting format"); 131 132 } -
trunk/Ohana/src/dvomerge/src/dvorepairFixImages.c
r37807 r38441 255 255 256 256 /* setup image table format and lock */ 257 gfits_db_init (oldDB); 257 258 db.mode = oldDB->mode; 258 259 db.format = oldDB->format; … … 280 281 memset (&db.ftable.buffer[Nx*Nout], ' ', nbytes - Nx*Nout); 281 282 282 db.swapped = TRUE; // internal representation 283 db.nativeOrder = TRUE; // internal representation 284 db.scaledValue = TRUE; // internal representation 283 285 284 286 gfits_modify (&db.header, "NIMAGES", OFF_T_FMT, 1, Nout); -
trunk/Ohana/src/dvomerge/src/dvorepairFixTables.c
r37807 r38441 103 103 104 104 // convert internal to external format 105 if (!MeasureToFtable (&cpmFtable, NULL, measureNew, NmeasureNew, catformat )) {105 if (!MeasureToFtable (&cpmFtable, NULL, measureNew, NmeasureNew, catformat, TRUE)) { 106 106 myAbort("trouble converting format"); 107 107 } … … 183 183 gfits_scan(&cpmHeaderTBL, "NAXIS2", "%d", 1, &Nrows); 184 184 185 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat );185 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat, FALSE); 186 186 myAssert(measure, "failed to convert ftable to measure data"); 187 187 … … 326 326 gfits_scan (&cptHeaderPHU, "NSECFILT", "%d", 1, &Nsecfilt); 327 327 328 myAbort ("test for compression"); 329 328 330 /* convert internal to external format */ 329 if (!AverageToFtable (&cptFtable, averageOut, NaverageOut, catformat, NULL )) {331 if (!AverageToFtable (&cptFtable, averageOut, NaverageOut, catformat, NULL, TRUE)) { 330 332 myAbort("trouble converting format"); 331 333 } … … 388 390 389 391 /* convert internal to external format */ 390 if (!SecFiltToFtable (&cpsFtable, secfilt, Nrows, catformat )) {392 if (!SecFiltToFtable (&cpsFtable, secfilt, Nrows, catformat, TRUE)) { 391 393 myAbort("trouble converting format"); 392 394 } -
trunk/Ohana/src/dvomerge/src/dvorepairImageVsMeasure.c
r37046 r38441 128 128 gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow); 129 129 130 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat );130 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat, FALSE); 131 131 myAssert(measure, "failed to convert ftable to measure data"); 132 132 -
trunk/Ohana/src/dvomerge/src/dvorepairImagesVsMeasures.c
r37046 r38441 32 32 FILE *cpmFile = NULL; 33 33 34 charcatformat;34 DVOCatFormat catformat; 35 35 36 36 N = get_argument (argc, argv, "-images-vs-measures"); … … 134 134 gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow); 135 135 136 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat );136 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat, FALSE); 137 137 myAssert(measure, "failed to convert ftable to measure data"); 138 138 -
trunk/Ohana/src/dvomerge/src/dvosecfilt_catalogs.c
r35416 r38441 39 39 // always load all of the data (if any exists) 40 40 catalog.Nsecfilt = 0; 41 catalog.catflags = LOAD_SECF; // XXX this will fail for MEF version41 catalog.catflags = DVO_LOAD_SECFILT; // XXX this will fail for MEF version 42 42 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 43 43 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data … … 48 48 } 49 49 50 if (catalog.Nave s_disk == 0) {50 if (catalog.Naverage_disk == 0) { 51 51 dvo_catalog_unlock (&catalog); 52 52 dvo_catalog_free (&catalog); … … 64 64 65 65 insec = catalog.secfilt; 66 ALLOCATE (outsec, SecFilt, catalog.Nave s_disk * Nsecfilt);66 ALLOCATE (outsec, SecFilt, catalog.Naverage_disk * Nsecfilt); 67 67 68 for (k = 0; k < catalog.Nave s_disk; k++) {68 for (k = 0; k < catalog.Naverage_disk; k++) { 69 69 for (j = 0; (j < catalog.Nsecfilt) && (j < Nsecfilt); j++) { 70 70 outsec[k*Nsecfilt + j] = insec[k*NsecInput + j]; … … 77 77 catalog.secfilt = outsec; 78 78 catalog.Nsecfilt = Nsecfilt; 79 catalog.Nsecf _mem = Nsecfilt * catalog.Naves_disk;80 catalog.Nsecf _disk = Nsecfilt * catalog.Naves_disk;79 catalog.Nsecfilt_mem = Nsecfilt * catalog.Naverage_disk; 80 catalog.Nsecfilt_disk = Nsecfilt * catalog.Naverage_disk; 81 81 82 82 dvo_catalog_save (&catalog, VERBOSE); -
trunk/Ohana/src/dvomerge/src/dvoutils_load_image_index.c
r37807 r38441 87 87 88 88 off_t Nimage; 89 Image *image = gfits_table_get_Image (&db.ftable, &Nimage, &db.s wapped);89 Image *image = gfits_table_get_Image (&db.ftable, &Nimage, &db.scaledValue, &db.nativeOrder); 90 90 if (!image) { 91 91 fprintf (stderr, "ERROR: failed to read images\n"); -
trunk/Ohana/src/dvomerge/src/dvoutils_uniq_images.c
r37807 r38441 132 132 } 133 133 IDlist[n] ++; 134 if (VERBOSE && (IDlist[n] > 1)) { 135 fprintf (stderr, "duplicate ext_id %d in file %s\n", extern_id[i], imFile); 136 } 134 137 } 135 138 -
trunk/Ohana/src/dvomerge/src/dvoverify_utils.c
r37807 r38441 178 178 catalog.catformat = DVO_FORMAT_UNDEF; // read-only,do not set the catformat 179 179 catalog.catmode = DVO_MODE_UNDEF; // read-only, do not set the catmode 180 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_LENSING |LOAD_LENSOBJ;180 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ; 181 181 catalog.Nsecfilt = 0; 182 182 … … 187 187 } 188 188 189 // Nave s_disk == 0 implies an empty catalog file, skip empty catalogs190 if (catalog.Nave s_disk == 0) {189 // Naverage_disk == 0 implies an empty catalog file, skip empty catalogs 190 if (catalog.Naverage_disk == 0) { 191 191 dvo_catalog_unlock (&catalog); 192 192 dvo_catalog_free (&catalog); … … 467 467 468 468 // load the iage database table 469 gfits_db_init (&inDB); 469 470 status = dvo_image_lock (&inDB, ImageCat, 3600.0, LCK_SOFT); // shorter timeout? 470 471 if (!status) { … … 484 485 } 485 486 486 images = gfits_table_get_Image (&inDB.ftable, &Nimages, &inDB.s wapped);487 images = gfits_table_get_Image (&inDB.ftable, &Nimages, &inDB.scaledValue, &inDB.nativeOrder); 487 488 if (!images) { 488 489 fprintf (stderr, "ERROR: failed to read images from src\n"); -
trunk/Ohana/src/dvomerge/src/merge_catalogs.c
r27435 r38441 57 57 output[0].Naverage = Naverage; 58 58 output[0].Nmeasure = Nmeasure; 59 output[0].Nsecf _mem = Naverage * Nsecfilt;59 output[0].Nsecfilt_mem = Naverage * Nsecfilt; 60 60 61 61 if (VERBOSE) { -
trunk/Ohana/src/dvomerge/src/merge_catalogs_new.c
r37814 r38441 115 115 output[0].Nlensing = Nlensing; 116 116 output[0].Nstarpar = Nstarpar; 117 output[0].Nsecf _mem = Naverage * NsecfiltOut;117 output[0].Nsecfilt_mem = Naverage * NsecfiltOut; 118 118 119 119 // If we are using dvomergeCreate to split an existing catalog, then the max objID in -
trunk/Ohana/src/dvomerge/src/merge_catalogs_old.c
r37807 r38441 112 112 113 113 /* set up pointers for linked list of measure */ 114 if (output[0].sorted && (output[0].Nmeasure >= output[0].Nmeas _disk)) {114 if (output[0].sorted && (output[0].Nmeasure >= output[0].Nmeasure_disk)) { 115 115 // this version is only valid if we have done a full catalog load, and if the catalog 116 116 // is sorted while processed … … 504 504 output[0].Nlensing = Nlens; 505 505 output[0].Nstarpar = Nstar; 506 output[0].Nsecf _mem = Nave*NsecfiltOut;506 output[0].Nsecfilt_mem = Nave*NsecfiltOut; 507 507 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nlens: "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas, Nlens, Nmatch); 508 508 -
trunk/Ohana/src/dvopsps/src/insert_FWobjects_dvopsps.c
r37672 r38441 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); -
trunk/Ohana/src/dvopsps/src/insert_detections_dvopsps.c
r37361 r38441 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); -
trunk/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c
r38264 r38441 1 1 # include "dvopsps.h" 2 # define DEBUG 12 # define DEBUG 0 3 3 4 4 int Ndetections = 0; -
trunk/Ohana/src/dvopsps/src/insert_diffobj_dvopsps.c
r37923 r38441 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); -
trunk/Ohana/src/dvopsps/src/insert_objects_dvopsps.c
r37361 r38441 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); -
trunk/Ohana/src/dvosplit/src/dvosplit.c
r37043 r38441 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); -
trunk/Ohana/src/dvosplit/src/open_output_catalogs.c
r33656 r38441 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 -
trunk/Ohana/src/dvosplit/src/split_averages.c
r37807 r38441 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 } -
trunk/Ohana/src/dvosplit/src/split_measures.c
r37807 r38441 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 } -
trunk/Ohana/src/dvosplit/src/split_missings.c
r15743 r38441 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 -
trunk/Ohana/src/fakeastro/include/fakeastro.h
r37807 r38441 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); -
trunk/Ohana/src/fakeastro/src/fakeastro_2mass.c
r37807 r38441 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); -
trunk/Ohana/src/fakeastro/src/fakeastro_images.c
r37807 r38441 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); -
trunk/Ohana/src/fakeastro/src/fakestar_catalog.c
r37807 r38441 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 -
trunk/Ohana/src/fakeastro/src/insert_fakestar.c
r37814 r38441 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 -
trunk/Ohana/src/fakeastro/src/load_fake_stars.c
r37807 r38441 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]); -
trunk/Ohana/src/fakeastro/src/load_template_images.c
r37807 r38441 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); -
trunk/Ohana/src/fakeastro/src/match_fake_stars.c
r37807 r38441 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 -
trunk/Ohana/src/fakeastro/src/save_fake_stars.c
r37807 r38441 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 -
trunk/Ohana/src/fakeastro/src/save_fakestars.c
r37807 r38441 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 } -
trunk/Ohana/src/gastro/src/getptolemy.c
r25757 r38441 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; -
trunk/Ohana/src/gastro2/src/getptolemy.c
r25757 r38441 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; -
trunk/Ohana/src/gastro2/src/rfits.c
r29001 r38441 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"); -
trunk/Ohana/src/getstar/src/WriteImageFITS.c
r14590 r38441 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); -
trunk/Ohana/src/getstar/src/dvoImageExtract.c
r29001 r38441 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"); -
trunk/Ohana/src/getstar/src/dvoImageOverlaps.c
r29001 r38441 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"); -
trunk/Ohana/src/getstar/src/dvoImagesAtCoords.c
r36131 r38441 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"); -
trunk/Ohana/src/getstar/src/getstar.c
r37359 r38441 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 } -
trunk/Ohana/src/getstar/src/select_by_region.c
r37044 r38441 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", -
trunk/Ohana/src/getstar/src/write_getstar_ps1_dev_0.c
r37044 r38441 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); -
trunk/Ohana/src/getstar/src/write_getstar_ps1_dev_1.c
r37044 r38441 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); -
trunk/Ohana/src/getstar/src/write_getstar_ps1_dev_2.c
r37044 r38441 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); -
trunk/Ohana/src/imclean/src/wfits.c
r27435 r38441 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); -
trunk/Ohana/src/imregister/detrend/delete.c
r28241 r38441 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); -
trunk/Ohana/src/imregister/detrend/output.c
r27435 r38441 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); -
trunk/Ohana/src/imregister/imphot/dumpfits.c
r37807 r38441 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); -
trunk/Ohana/src/imregister/imreg/delete.c
r28241 r38441 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); -
trunk/Ohana/src/imregister/imreg/imregclient.c
r34088 r38441 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)) { -
trunk/Ohana/src/imregister/imreg/output.c
r27435 r38441 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); -
trunk/Ohana/src/imregister/photreg/delete.c
r28241 r38441 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); -
trunk/Ohana/src/imregister/photreg/output.c
r27435 r38441 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 */ -
trunk/Ohana/src/imregister/spreg/delete.c
r28241 r38441 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); -
trunk/Ohana/src/imregister/spreg/output.c
r27435 r38441 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 */ -
trunk/Ohana/src/imregister/src/detregister.c
r7080 r38441 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)) { -
trunk/Ohana/src/imregister/src/detsearch.c
r29001 r38441 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"); -
trunk/Ohana/src/imregister/src/imphotsearch.c
r29001 r38441 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"); -
trunk/Ohana/src/imregister/src/imregister.c
r27435 r38441 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)) { -
trunk/Ohana/src/imregister/src/imregtable.c
r29001 r38441 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)) { -
trunk/Ohana/src/imregister/src/imsearch.c
r29001 r38441 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"); -
trunk/Ohana/src/imregister/src/imstatreg.c
r29001 r38441 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"); -
trunk/Ohana/src/imregister/src/photreg.c
r7080 r38441 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")) { -
trunk/Ohana/src/imregister/src/photsearch.c
r29001 r38441 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"); -
trunk/Ohana/src/imregister/src/spregister.c
r7080 r38441 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)) { -
trunk/Ohana/src/imregister/src/spsearch.c
r29001 r38441 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"); -
trunk/Ohana/src/libautocode/Makefile.Targets
r38153 r38441 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 \ -
trunk/Ohana/src/libautocode/def/autocode.c
r29537 r38441 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 -
trunk/Ohana/src/libautocode/def/autocode.h
r27435 r38441 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); -
trunk/Ohana/src/libautocode/def/average-ps1-v1.d
r36833 r38441 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 -
trunk/Ohana/src/libautocode/def/average-ps1-v2.d
r36833 r38441 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 -
trunk/Ohana/src/libautocode/def/average-ps1-v3.d
r36833 r38441 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 -
trunk/Ohana/src/libautocode/def/average-ps1-v4.d
r36833 r38441 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 -
trunk/Ohana/src/libautocode/def/average-ps1-v5.d
r37807 r38441 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 -
trunk/Ohana/src/libautocode/def/average.d
r37807 r38441 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 -
trunk/Ohana/src/libdvo/Makefile
r37992 r38441 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 -
trunk/Ohana/src/libdvo/include/dvo.h
r38154 r38441 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 … … 54 78 # define IMREG_DIST 0x01 /* image distributed, only imregister-3.0 */ 55 79 56 /* catalog values to be loaded */57 # define LOAD_NONE 0x000058 # define LOAD_AVES 0x000159 # define LOAD_MEAS 0x000260 # define LOAD_MISS 0x000461 # define LOAD_SECF 0x000862 # define SKIP_AVES 0x001063 # define SKIP_MEAS 0x002064 # define SKIP_MISS 0x004065 # define SKIP_SECF 0x008066 # define LOAD_LENSING 0x010067 # define LOAD_LENSOBJ 0x020068 # define SKIP_LENSING 0x040069 # define SKIP_LENSOBJ 0x080070 # define LOAD_STARPAR 0x100071 # define SKIP_STARPAR 0x200072 73 80 /* photometry code types */ 74 81 // # define PHOT_PRI 0x01 75 # define PHOT_SEC 0x02 76 # define PHOT_DEP 0x03 77 # define PHOT_REF 0x04 78 # define PHOT_ALT 0x05 /* never stored, only for look-ups */ 79 # define PHOT_MAG 0x06 /* generic magnitude; never stored */ 82 typedef enum { 83 PHOT_SEC = 0x02, 84 PHOT_DEP = 0x03, 85 PHOT_REF = 0x04, 86 PHOT_ALT = 0x05, /* never stored, only for look-ups */ 87 PHOT_MAG = 0x06, /* generic magnitude; never stored */ 88 } DVOPhotCodeTypes; 80 89 81 90 /* Image.code values -- these values are 32 bit (as of PS1_V1) */ … … 222 231 char lockstate; 223 232 char mode; /* what data storage mode is used for disk file? */ 224 char format;/* what data format is used for disk file? */233 DVOCatFormat format; /* what data format is used for disk file? */ 225 234 char virtual; /* is table in ftable or vtable? */ 226 char swapped; /* is table in internal byte-order? */ 235 char nativeOrder; /* is table in internal byte-order? */ 236 char scaledValue; /* is table in internal byte-order? */ 227 237 } FITS_DB; 228 238 … … 484 494 unsigned short Nmeasure; // number of psf measurements 485 495 unsigned short Nmissing; // number of missings 486 unsigned short N extend;// number of extended measurements496 unsigned short Ngalphot; // number of extended measurements 487 497 uint32_t measureOffset; // offset to first psf measurement 488 498 uint32_t missingOffset; // offset to first missing obs … … 704 714 unsigned short Nlensing; // number of lensing measurements 705 715 unsigned short Nlensobj; // number of lensing measurements 706 unsigned short N extend; // number of extendedmeasurements716 unsigned short Ngalphot; // number of galphot measurements 707 717 int measureOffset; // offset to first psf measurement 708 718 int missingOffset; // offset to first missing obs 709 719 int lensingOffset; // offset to first lensing obs 710 720 int lensobjOffset; // offset to mean lensing data 711 int extendOffset;// offset to extended object entry721 int galphotOffset; // offset to extended object entry 712 722 int starparOffset; // offset to stellar parameter data 713 723 float refColorBlue; // color of astrometry ref stars … … 742 752 743 753 // lensing data (optional?) 744 Lensing *lensing; 745 Lensobj *lensobj; 746 StarPar *starpar; 754 Lensing *lensing; 755 Lensobj *lensobj; 756 StarPar *starpar; 757 GalPhot *galphot; 747 758 748 759 int Nsecfilt; /* number of secfilt entries for each average entry */ 749 off_t Naverage, Nmeasure, Nmissing, Nlensing, Nlensobj, Nstarpar, Nsecf_mem; /* current number of each component in memory */750 off_t Nave s_disk, Nmeas_disk, Nmiss_disk, Nlensing_disk, Nlensobj_disk, Nstarpar_disk, Nsecf_disk; /* current number of each component on disk */751 off_t Nave s_off, Nmeas_off, Nmiss_off, Nlensing_off, Nlensobj_off, Nstarpar_off, Nsecf_off; /* index of first loaded data value */760 off_t Naverage, Nmeasure, Nmissing, Nlensing, Nlensobj, Nstarpar, Ngalphot, Nsecfilt_mem; /* current number of each component in memory */ 761 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 */ 762 off_t Naverage_off, Nmeasure_off, Nmissing_off, Nlensing_off, Nlensobj_off, Nstarpar_off, Ngalphot_off, Nsecfilt_off; /* index of first loaded data value */ 752 763 753 764 // note that we use these for the full-sky relphot analysis … … 765 776 766 777 /* pointers to split data files */ 767 struct Catalog *measure_catalog; /* measure catalog data (split) */ 768 struct Catalog *missing_catalog; /* missing catalog data (split) */ 769 struct Catalog *secfilt_catalog; /* secfilt catalog data (split) */ 770 struct Catalog *lensing_catalog; /* lensing catalog data (split) */ 771 struct Catalog *lensobj_catalog; /* lensobj catalog data (split) */ 772 struct Catalog *starpar_catalog; /* starpar catalog data (split) */ 778 struct Catalog *measure_catalog; /* measure catalog data (split) */ 779 struct Catalog *missing_catalog; /* missing catalog data (split) */ 780 struct Catalog *secfilt_catalog; /* secfilt catalog data (split) */ 781 struct Catalog *lensing_catalog; /* lensing catalog data (split) */ 782 struct Catalog *lensobj_catalog; /* lensobj catalog data (split) */ 783 struct Catalog *starpar_catalog; /* starpar catalog data (split) */ 784 struct Catalog *galphot_catalog; /* galphot catalog data (split) */ 773 785 774 786 unsigned int objID; … … 777 789 /* extra catalog information */ 778 790 char lockmode; 779 char catmode; /* storage mode (raw, mef, split, mysql) */ 780 char catformat; /* storage format (elixir, panstarrs, etc) */ 791 DVOCatMode catmode; /* storage mode (raw, mef, split, mysql) */ 792 DVOCatFormat catformat; /* storage format (elixir, panstarrs, etc) */ 793 DVOCatCompress catcompress; // output compress mode 794 DVOCatFlags catflags; /* choices to be loaded */ 795 781 796 int sorted; /* is measure table average-sorted? (NOTE this is an int only because gfits_scan %t requires it) */ 782 783 short catflags; /* choices to be loaded */ 797 784 798 785 799 /* pointers for data manipulation */ … … 928 942 int dvo_catalog_save_complete (Catalog *catalog, char VERBOSE); 929 943 int dvo_catalog_update (Catalog *catalog, char VERBOSE); 930 int dvo_catalog_catformat (char *catformat); 931 int dvo_catalog_catmode (char *catmode); 944 DVOCatFormat dvo_catalog_catformat (char *catformat); 945 DVOCatMode dvo_catalog_catmode (char *catmode); 946 DVOCatCompress dvo_catalog_catcompress (char *catcompress); 947 char *dvo_catalog_compress_string (DVOCatCompress catcompress); 932 948 void dvo_catalog_test (Catalog *catalog, int halt); 933 949 … … 956 972 int WriteRawSecFilt (FILE *f, SecFilt *secfilt, off_t Nsecfilt, char format); 957 973 958 DVOTableFormat FtableGetFormat (FTable *ftable); 959 960 Average *FtableToAverage (FTable *ftable, off_t *Naverage, char *format, SecFilt **primary); 961 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, char *format); 962 SecFilt *FtableToSecFilt (FTable *ftable, off_t *Nsecfilt, char *format); 963 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, char *format); 964 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, char *format); 965 StarPar *FtableToStarPar (FTable *ftable, off_t *Nstarpar, char *format); 966 int FtableToImage (FTable *ftable, Header *theader, char *format); 967 968 int AverageToFtable (FTable *ftable, Average *average, off_t Naverage, char format, SecFilt *primary); 969 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, char format); 970 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, char format); 971 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, char format); 972 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, char format); 973 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, char format); 974 int ImageToFtable (FTable *ftable, Header *theader, char format); 975 int ImageToVtable (VTable *vtable, Header *theader, char format); 974 DVOCatFormat FtableGetFormat (FTable *ftable); 975 976 Average *FtableToAverage (FTable *ftable, off_t *Naverage, DVOCatFormat *format, SecFilt **primary, char nativeOrder); 977 978 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, DVOCatFormat *format, char nativeOrder); 979 Missing *FtableToMissing (FTable *ftable, Average *average, off_t *Nmissing, DVOCatFormat *format, char nativeBytes); 980 SecFilt *FtableToSecFilt (FTable *ftable, Average *average, off_t *Nsecfilt, DVOCatFormat *format, char nativeOrder); 981 Lensing *FtableToLensing (FTable *ftable, Average *average, off_t *Nlensing, DVOCatFormat *format, char nativeOrder); 982 Lensobj *FtableToLensobj (FTable *ftable, Average *average, off_t *Nlensobj, DVOCatFormat *format, char nativeOrder); 983 StarPar *FtableToStarPar (FTable *ftable, Average *average, off_t *Nstarpar, DVOCatFormat *format, char nativeOrder); 984 GalPhot *FtableToGalPhot (FTable *ftable, Average *average, off_t *Ngalphot, DVOCatFormat *format, char nativeOrder); 985 986 int FtableToImage (FTable *ftable, Header *theader, DVOCatFormat *format); 987 988 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, DVOCatFormat format, int swapFromNative); 989 int AverageToFtable (FTable *ftable, Average *average, off_t Naverage, DVOCatFormat format, SecFilt *primary, int swapFromNative); 990 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, DVOCatFormat format, int swapFromNative); 991 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, DVOCatFormat format, int swapFromNative); 992 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, DVOCatFormat format, int swapFromNative); 993 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, DVOCatFormat format, int swapFromNative); 994 int GalPhotToFtable (FTable *ftable, GalPhot *galphot, off_t Ngalphot, DVOCatFormat format, int swapFromNative); 995 996 int ImageToFtable (FTable *ftable, Header *theader, DVOCatFormat format); 997 int ImageToVtable (VTable *vtable, Header *theader, DVOCatFormat format); 976 998 977 999 # include "loneos_defs.h" … … 1005 1027 int gfits_table_set_Image (FTable *ftable); 1006 1028 int gfits_table_mkheader_Image (Header *header); 1007 Image *gfits_table_get_Image (FTable *ftable, off_t *Ndata, char *s wapped);1029 Image *gfits_table_get_Image (FTable *ftable, off_t *Ndata, char *scaledValue, char *nativeOrder); 1008 1030 1009 1031 /* flatcorr APIs */ … … 1069 1091 void InitHost (HostInfo *host); 1070 1092 1071 HostTableGroup *HostTableGroups (HostTable *table, int *ngroups); 1093 HostTableGroup *HostTableGroupsUniqueMachines (HostTable *table, int *ngroups); 1094 HostTableGroup *HostTableGroupsMaxNumber (HostTable *table, int *ngroups, int Nmax); 1095 1072 1096 int HostTableGroupWaitJobsGetIO (HostTableGroup *table, char *file, int lineno, int VERBOSE); 1073 1097 … … 1106 1130 void dvo_lensobj_init (Lensobj *lensobj, int toZero); 1107 1131 void dvo_starpar_init (StarPar *starpar); 1132 void dvo_galphot_init (GalPhot *galphot); 1108 1133 1109 1134 void InitRegionHosts (RegionHostInfo *hosts, int Nhosts, int NHOSTS); -
trunk/Ohana/src/libdvo/include/ps1_v5_defs.h
r38153 r38441 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); -
trunk/Ohana/src/libdvo/src/AstromOffsetMapIO.c
r37807 r38441 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"); -
trunk/Ohana/src/libdvo/src/HostTable.c
r37807 r38441 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 } -
trunk/Ohana/src/libdvo/src/LoadImages.c
r37807 r38441 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"); -
trunk/Ohana/src/libdvo/src/LoadPhotcodesFITS.c
r37035 r38441 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"); \ -
trunk/Ohana/src/libdvo/src/SavePhotcodesFITS.c
r37035 r38441 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); -
trunk/Ohana/src/libdvo/src/dvo_catalog.c
r38062 r38441 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; … … 466 511 467 512 // init all data, or just catalog data 513 void dvo_galphot_init (GalPhot *galphot) { 514 galphot->Xfit = NAN; 515 galphot->Yfit = NAN; 516 galphot->mag = NAN; 517 galphot->magErr = NAN; 518 galphot->majorAxis = NAN; 519 galphot->minorAxis = NAN; 520 galphot->majorAxisErr = NAN; 521 galphot->minorAxisErr = NAN; 522 galphot->theta = NAN; 523 galphot->theta_err = NAN; 524 galphot->index = NAN; 525 galphot->chisq = NAN; 526 galphot->Npix = 0; 527 528 galphot->detID = -1; 529 galphot->objID = -1; 530 galphot->catID = -1; 531 galphot->imageID = -1; 532 533 galphot->photcode = 0; 534 galphot->modelType = 0; 535 } 536 537 # define INIT_TABLE(TABLE) \ 538 catalog[0].TABLE = NULL; \ 539 catalog[0].N##TABLE = 0; \ 540 catalog[0].N##TABLE##_disk = 0; \ 541 catalog[0].N##TABLE##_off = 0; \ 542 catalog[0].TABLE##_catalog = NULL; 543 544 // init all data, or just catalog data 468 545 void dvo_catalog_init (Catalog *catalog, int complete) { 469 546 … … 473 550 catalog[0].filename = NULL; 474 551 475 catalog[0].lockmode = 0; 476 catalog[0].catmode = 0; 477 catalog[0].catformat = 0; 478 catalog[0].catflags = 0; 479 catalog[0].Nsecfilt = 0; 552 catalog[0].lockmode = 0; 553 catalog[0].catmode = DVO_MODE_UNDEF; 554 catalog[0].catformat = DVO_FORMAT_UNDEF; 555 catalog[0].catcompress = DVO_COMPRESS_NONE; 556 catalog[0].catflags = DVO_LOAD_NONE; 557 catalog[0].Nsecfilt = 0; 480 558 } 481 559 482 560 gfits_init_header (&catalog[0].header); 483 561 484 562 // the following describe the catalog files on disk 485 563 catalog[0].average = NULL; 486 catalog[0].measure = NULL; 487 catalog[0].missing = NULL; 564 catalog[0].Naverage = 0; 565 catalog[0].Naverage_disk = 0; 566 catalog[0].Naverage_off = 0; 567 // average lacks average_catalog 568 488 569 catalog[0].secfilt = NULL; 489 490 catalog[0]. lensing = NULL;491 catalog[0]. lensobj = NULL;492 493 catalog[0].starpar = NULL;570 catalog[0].Nsecfilt_mem = 0; 571 catalog[0].Nsecfilt_disk = 0; 572 catalog[0].Nsecfilt_off = 0; 573 catalog[0].secfilt_catalog = NULL; 574 // secfilt uses Nsecfilt_mem not Nsecfilt 494 575 495 576 catalog[0].averageT = NULL; 496 577 catalog[0].measureT = NULL; 578 579 INIT_TABLE(measure); 580 INIT_TABLE(missing); 581 INIT_TABLE(lensing); 582 INIT_TABLE(lensobj); 583 INIT_TABLE(starpar); 584 INIT_TABLE(galphot); 497 585 498 586 catalog[0].objID = 0; 499 587 catalog[0].catID = 0; 500 588 catalog[0].sorted = 0; 501 502 catalog[0].Naverage = 0;503 catalog[0].Nmeasure = 0;504 catalog[0].Nmissing = 0;505 catalog[0].Nsecf_mem = 0;506 507 catalog[0].Nlensing = 0;508 catalog[0].Nlensobj = 0;509 510 catalog[0].Nstarpar = 0;511 512 catalog[0].Naves_disk = 0;513 catalog[0].Nmeas_disk = 0;514 catalog[0].Nmiss_disk = 0;515 catalog[0].Nsecf_disk = 0;516 517 catalog[0].Nlensing_disk = 0;518 catalog[0].Nlensobj_disk = 0;519 520 catalog[0].Nstarpar_disk = 0;521 522 catalog[0].Naves_off = 0;523 catalog[0].Nmeas_off = 0;524 catalog[0].Nmiss_off = 0;525 catalog[0].Nsecf_off = 0;526 527 catalog[0].Nlensing_off = 0;528 catalog[0].Nlensobj_off = 0;529 530 catalog[0].Nstarpar_off = 0;531 532 /* pointers to SPLIT data files */533 catalog[0].measure_catalog = NULL;534 catalog[0].missing_catalog = NULL;535 catalog[0].secfilt_catalog = NULL;536 catalog[0].lensing_catalog = NULL;537 catalog[0].lensobj_catalog = NULL;538 catalog[0].starpar_catalog = NULL;539 589 540 590 /* pointers for data manipulation */ … … 568 618 if (catalog[0].f == NULL) return (DVO_CAT_OPEN_FAIL); 569 619 570 fseeko (catalog[0].f, 0, SEEK_SET); 620 if (fseeko (catalog[0].f, 0, SEEK_SET)) { 621 perror ("fseeko: "); 622 exit (1); 623 } 571 624 return (DVO_CAT_OPEN_OK); 572 625 } … … 580 633 581 634 if (fflush (catalog[0].f)) { 582 fprintf (stderr, "failed to flush file\n"); 635 perror ("fflush: "); 636 fprintf (stderr, "failed to flush file %s\n", catalog[0].filename); 583 637 return FALSE; 584 638 } … … 607 661 if (catalog[0].lensobj_catalog) { if (!dvo_catalog_unlock (catalog[0].lensobj_catalog)) { fprintf (stderr, "failed to unlock lensobj\n"); return (0); }} 608 662 if (catalog[0].starpar_catalog) { if (!dvo_catalog_unlock (catalog[0].starpar_catalog)) { fprintf (stderr, "failed to unlock starpar\n"); return (0); }} 663 if (catalog[0].galphot_catalog) { if (!dvo_catalog_unlock (catalog[0].galphot_catalog)) { fprintf (stderr, "failed to unlock galphot\n"); return (0); }} 609 664 } 610 665 return (1); … … 849 904 catalog[0].secfilt = outsec; 850 905 catalog[0].Nsecfilt = Nsecfilt; 851 catalog[0].Nsecf _mem = Nsecfilt * catalog[0].Naverage;906 catalog[0].Nsecfilt_mem = Nsecfilt * catalog[0].Naverage; 852 907 } 853 908 return (TRUE); … … 887 942 dvo_catalog_free (catalog[0].starpar_catalog); 888 943 free (catalog[0].starpar_catalog); 944 } 945 if (catalog[0].galphot_catalog) { 946 free (catalog[0].galphot_catalog[0].filename); 947 dvo_catalog_free (catalog[0].galphot_catalog); 948 free (catalog[0].galphot_catalog); 889 949 } 890 950 } … … 914 974 if (catalog[0].secfilt) { 915 975 free (catalog[0].secfilt); 916 catalog[0].Nsecf _mem = 0;976 catalog[0].Nsecfilt_mem = 0; 917 977 catalog[0].secfilt = NULL; 918 978 } … … 932 992 catalog[0].starpar = NULL; 933 993 } 994 if (catalog[0].galphot) { 995 free (catalog[0].galphot); 996 catalog[0].Ngalphot = 0; 997 catalog[0].galphot = NULL; 998 } 934 999 if (catalog[0].nOwn_t) { free (catalog[0].nOwn_t); catalog[0].nOwn_t = NULL; } 935 1000 if (catalog[0].found_t) { free (catalog[0].found_t); catalog[0].found_t = NULL; } … … 938 1003 939 1004 /* 940 mode : items to read ( LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF)1005 mode : items to read (DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT) 941 1006 format : what table structure on disk (INTERNAL, LONEOS, etc, ) 942 1007 style : raw, mef, split, mysql … … 971 1036 972 1037 // skip empty cpt files 973 if (primary && !catalog->Nave s_disk) {1038 if (primary && !catalog->Naverage_disk) { 974 1039 return TRUE; 975 1040 } … … 1053 1118 } 1054 1119 } 1120 if (catalog[0].galphot_catalog != NULL) { 1121 if (catalog[0].Ngalphot_disk == 0) { 1122 // need to relock (and re-open) file for close elsewhere 1123 status = dvo_catalog_lock (catalog[0].galphot_catalog, lockmode); 1124 } else { 1125 if (!dvo_catalog_backup (catalog[0].galphot_catalog, FALSE)) { 1126 return FALSE; 1127 } 1128 } 1129 } 1055 1130 } 1056 1131 return TRUE; … … 1060 1135 int dvo_catalog_unlink_backup (Catalog *catalog, int primary) { 1061 1136 1062 if (primary && !catalog->Nave s_disk) {1137 if (primary && !catalog->Naverage_disk) { 1063 1138 // skip empty files (empty when read, but output may not be empty) 1064 1139 return TRUE; … … 1109 1184 } 1110 1185 } 1186 if ((catalog[0].galphot_catalog != NULL) && (catalog[0].Ngalphot_disk > 0)) { 1187 if (!dvo_catalog_unlink_backup (catalog[0].galphot_catalog, FALSE)) { 1188 return FALSE; 1189 } 1190 } 1111 1191 } 1112 1192 return TRUE; -
trunk/Ohana/src/libdvo/src/dvo_catalog_create.c
r37807 r38441 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 -
trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c
r37807 r38441 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"); -
trunk/Ohana/src/libdvo/src/dvo_catalog_raw.c
r37807 r38441 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); -
trunk/Ohana/src/libdvo/src/dvo_catalog_split.c
r38153 r38441 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 -
trunk/Ohana/src/libdvo/src/dvo_convert.c
r38153 r38441 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; -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c
r37807 r38441 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; -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V1.c
r37807 r38441 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; -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V2.c
r37807 r38441 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; -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V3.c
r37807 r38441 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; -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V4.c
r37807 r38441 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; -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c
r38153 r38441 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 -
trunk/Ohana/src/libdvo/src/dvo_image.c
r37807 r38441 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 -
trunk/Ohana/src/libdvo/src/dvo_image_raw.c
r37807 r38441 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 } -
trunk/Ohana/src/libdvo/src/dvo_util.c
r37807 r38441 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 -
trunk/Ohana/src/libdvo/src/fits_db.c
r35755 r38441 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 } -
trunk/Ohana/src/libdvo/src/flatcorr_io.c
r37807 r38441 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"); -
trunk/Ohana/src/libdvo/src/skyregion_io.c
r36833 r38441 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"); -
trunk/Ohana/src/libfits/Makefile
r38255 r38441 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 $(MATR)/F_swap_raw.$(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 = \ -
trunk/Ohana/src/libfits/doc/notes-compress.txt
r15487 r38441 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) -
trunk/Ohana/src/libfits/extern/gzip.c
r23816 r38441 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 -
trunk/Ohana/src/libfits/header/F_copy_H.c
r27435 r38441 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 } -
trunk/Ohana/src/libfits/header/F_modify.c
r34577 r38441 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 -
trunk/Ohana/src/libfits/include/gfitsio.h
r38255 r38441 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)); 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)); 172 201 int gfits_swap_raw PROTO((Matrix *matrix)); 173 int gfits_extension_is_compressed PROTO((Header *header)); 202 174 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)); 175 213 int gfits_uncompressed_data_pixsize PROTO((char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions)); 176 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)); 177 223 178 224 /******************************* Table functions *************/ … … 183 229 char *gfits_table_print PROTO((FTable *ftable,...)); 184 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)); 185 232 int gfits_bintable_format PROTO((char *format, char *type, int *Nval, int *Nbytes)); 186 233 int gfits_create_table PROTO((Header *header, FTable *ftable)); … … 199 246 int gfits_fwrite_ftable_range PROTO((FILE *f, FTable *table, off_t start, off_t Nrows, off_t Ndisk, off_t Ntotal)); 200 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)); 201 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)); 202 251 int gfits_get_bintable_column_type_by_N PROTO((Header *header, int N, char *type, int *Nval)); 203 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)); 204 253 int gfits_get_table_column PROTO((Header *header, FTable *table, char *label, void **data)); 205 254 int gfits_get_table_column_type PROTO((Header *header, char *label, char *type)); … … 207 256 int gfits_read_table PROTO((char *filename, FTable *ftable)); 208 257 int gfits_set_bintable_column PROTO((Header *header, FTable *table, char *label, void *data, off_t Nrow)); 209 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)); 210 259 int gfits_set_table_column PROTO((Header *header, FTable *table, char *label, void *data, off_t Nrow)); 211 260 int gfits_table_column PROTO((FTable *ftable, char *field, char *mode,...)) OHANA_FORMAT(printf, 3, 4); … … 219 268 int gfits_copy_ftable PROTO((FTable *in, FTable *out)); 220 269 int gfits_copy_vtable PROTO((VTable *in, VTable *out)); 270 int gfits_copy_ftable_ptr PROTO((FTable *in, FTable *out)); 221 271 222 272 int gfits_create_Theader PROTO((Header *header, char *type)); … … 227 277 int gfits_write_Theader PROTO((char *filename, Header *header)); 228 278 229 int gfits_varlength_column_define PROTO((FTable *ftable, VarLengthColumn *def, int column)); 230 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 231 286 232 287 #endif /* FITSIO */ -
trunk/Ohana/src/libfits/matrix/F_matrix.c
r35164 r38441 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 -
trunk/Ohana/src/libfits/matrix/F_uncompress_data.c
r23815 r38441 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 -
trunk/Ohana/src/libfits/table/F_copy_T.c
r34088 r38441 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; -
trunk/Ohana/src/libfits/table/F_create_T.c
r35756 r38441 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 -
trunk/Ohana/src/libfits/table/F_define_column.c
r35756 r38441 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); -
trunk/Ohana/src/libfits/table/F_get_column.c
r37039 r38441 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 -
trunk/Ohana/src/libfits/table/F_read_T.c
r37807 r38441 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); -
trunk/Ohana/src/libfits/table/F_set_column.c
r37039 r38441 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); -
trunk/Ohana/src/libfits/table/F_table_format.c
r37039 r38441 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 -
trunk/Ohana/src/libfits/table/F_table_row.c
r28241 r38441 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 } -
trunk/Ohana/src/libfits/table/F_table_varlength.c
r28241 r38441 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 } -
trunk/Ohana/src/libfits/table/F_write_T.c
r37807 r38441 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 -
trunk/Ohana/src/libfits/table/F_write_TH.c
r27435 r38441 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 } -
trunk/Ohana/src/libohana/Makefile
r37807 r38441 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 … … 51 55 # $(SRC)/gsl_utils.$(ARCH).o \ 52 56 53 TYPETEST = \54 $(TESTDIR)/typetest.$(ARCH)55 56 $(TYPETEST) : $(LIB)/libohana.$(ARCH).a57 58 typetest: $(TYPETEST)59 for i in $(TYPETEST); do $$i || exit 1; done60 61 TEST = \62 $(TESTDIR)/memtest.$(ARCH)63 # $(TESTDIR)/string.$(ARCH)64 65 testcode: install $(TEST)66 test:67 $(MAKE) testcode68 for i in $(TEST); do $$i; done69 70 quicktest:71 for i in $(TEST); do $$i; done72 73 57 $(OBJS): $(INCS) 74 58 … … 79 63 $(DESTLIB)/libohana.$(DLLTYPE): $(LIB)/libohana.$(ARCH).$(DLLTYPE) 80 64 81 $(TESTDIR)/%.$(ARCH) : $(TESTDIR)/%.c 82 $(CC) $^ -o $@ $(TFLAGS) 83 84 .PHONY: test 85 65 TESTPROG = memtest typetest string 66 $(TESTPROG) : % : $(TESTBIN)/% $(OBJS) 67 test: $(TESTPROG) 68 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 | $(TESTHARNESS); done 69 test.verbose: $(TESTPROG) 70 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 |& $(TESTHARNESS) -v; done -
trunk/Ohana/src/libohana/include/ohana.h
r37807 r38441 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 -
trunk/Ohana/src/libohana/include/ohana_allocate.h
r33646 r38441 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); -
trunk/Ohana/src/libohana/src/ohana_allocate.c
r37807 r38441 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 -
trunk/Ohana/src/libohana/src/string.c
r37033 r38441 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...) -
trunk/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
-
trunk/Ohana/src/libohana/test/string.c
r10313 r38441 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 } -
trunk/Ohana/src/libohana/test/typetest.c
r31663 r38441 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 } -
trunk/Ohana/src/markrock/src/markrock.c
r25757 r38441 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); -
trunk/Ohana/src/markstar/src/find_images.c
r29001 r38441 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"); -
trunk/Ohana/src/markstar/src/markstar.c
r15743 r38441 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); -
trunk/Ohana/src/mosastro/src/getptolemy.c
r25757 r38441 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; -
trunk/Ohana/src/mosastro/src/rfits.c
r29001 r38441 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"); -
trunk/Ohana/src/mosastro/src/wfits.c
r27435 r38441 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); -
trunk/Ohana/src/opihi/cmd.data
- Property svn:mergeinfo changed
/branches/eam_branches/ohana.20150429/src/opihi/cmd.data (added) merged: 38330,38336,38338,38340-38341,38363,38367,38406,38410,38424,38440
- Property svn:mergeinfo changed
-
trunk/Ohana/src/opihi/cmd.data/cast.c
r36489 r38441 17 17 // out type 18 18 char outType = OPIHI_NOTYPE; 19 if (!strcasecmp(argv[5], "int")) outType = OPIHI_INT; 20 if (!strcasecmp(argv[5], "float")) outType = OPIHI_FLT; 19 if (!strcasecmp(argv[5], "int")) outType = OPIHI_INT; 20 if (!strcasecmp(argv[5], "float")) outType = OPIHI_FLT; 21 if (!strcasecmp(argv[5], "single")) outType = OPIHI_FLT; 22 if (!strcasecmp(argv[5], "int64")) outType = OPIHI_FLT; 21 23 if (outType == OPIHI_NOTYPE) goto usage; 24 25 int ForceSingle = FALSE; 26 if (!strcasecmp(argv[5], "single")) ForceSingle = TRUE; 27 28 int ForceI64 = FALSE; 29 if (!strcasecmp(argv[5], "int64")) ForceI64 = TRUE; 22 30 23 31 if ((ovec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto error; … … 32 40 opihi_flt *vo = ovec[0].elements.Flt; 33 41 for (i = 0; i < ovec[0].Nelements; i++, vi++, vo++) { 34 *vo = *vi; 42 if (ForceSingle) { 43 float tmp = *vi; 44 *vo = tmp; 45 } else if (ForceI64) { 46 int64_t tmp = *vi; 47 *vo = tmp; 48 } else { 49 *vo = *vi; 50 } 35 51 } 36 52 return (TRUE); … … 48 64 opihi_flt *vo = ovec[0].elements.Flt; 49 65 for (i = 0; i < ovec[0].Nelements; i++, vi++, vo++) { 50 *vo = *vi; 66 if (ForceSingle) { 67 float tmp = *vi; 68 *vo = tmp; 69 } else { 70 *vo = *vi; 71 } 51 72 } 52 73 return (TRUE); … … 66 87 67 88 usage: 68 gprint (GP_ERR, "SYNTAX: cast vec = vec as (int/float)\n"); 89 gprint (GP_ERR, "SYNTAX: cast vec = vec as (int/float/single)\n"); 90 gprint (GP_ERR, " note: (single) forces vector to have single precision\n"); 69 91 return (FALSE); 70 92 } -
trunk/Ohana/src/opihi/cmd.data/rd.c
r38255 r38441 9 9 Buffer *buf; 10 10 11 int VERBOSE = FALSE; 12 if ((N = get_argument (argc, argv, "-v"))) { 13 remove_argument (N, &argc, argv); 14 VERBOSE = TRUE; 15 } 16 11 17 int JustHead = FALSE; 12 18 if ((N = get_argument (argc, argv, "-head"))) { … … 91 97 return (FALSE); 92 98 } 93 if (gfits_extension_is_compressed (&buf[0].header)) {99 if (gfits_extension_is_compressed_image (&buf[0].header)) { 94 100 IsCompressed = TRUE; 95 101 } … … 124 130 Nword = 1; 125 131 IsCompressed = FALSE; 126 if (gfits_extension_is_compressed (&buf[0].header)) {132 if (gfits_extension_is_compressed_image (&buf[0].header)) { 127 133 if (!strcmp (CCDKeyword, "EXTNAME")) Nword = 1; 128 134 IsCompressed = TRUE; … … 198 204 ftable.header[0].buffer = NULL; 199 205 gfits_copy_header (&buf[0].header, ftable.header); 200 status = gfits_fread_ftable_data (f, &ftable, FALSE); // this just reads the bytes (not even a SWAP) 201 status = gfits_uncompress_image (&buf[0].header, &buf[0].matrix, &ftable); 206 207 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) { gprint (GP_ERR, "problem reading compressed image table data\n"); fclose (f); return FALSE; } 208 if (!gfits_byteswap_varlength_column (&ftable, 1)) { gprint (GP_ERR, "problem doing byteswap on compressed image metadata column\n"); fclose (f); gfits_free_table (&ftable); return FALSE; } 209 if (!gfits_uncompress_image (&buf[0].header, &buf[0].matrix, &ftable)) { gprint (GP_ERR, "problem uncompressing the image data\n"); fclose (f); gfits_free_table (&ftable); return FALSE; } 210 202 211 // uncompressing the image leaves the format as an extension 203 212 gfits_extended_to_primary (&buf[0].header, TRUE, "Standard FITS"); 204 213 gfits_free_table (&ftable); 214 215 status = TRUE; 205 216 // XXX this currently does not work for a cube (we get a cube back, not a specific plane) 206 217 } else { … … 239 250 buf[0].unsign = buf[0].header.unsign; 240 251 241 gprint (GP_LOG, "read "OFF_T_FMT" bytes from %s into buffer %s\n", 242 buf[0].header.datasize + buf[0].matrix.datasize, argv[2], argv[1]); 252 if (VERBOSE) gprint (GP_LOG, "read "OFF_T_FMT" bytes from %s into buffer %s\n", buf[0].header.datasize + buf[0].matrix.datasize, argv[2], argv[1]); 243 253 244 254 blank = 0xffff; -
trunk/Ohana/src/opihi/cmd.data/read_vectors.c
r38062 r38441 1 1 # include "data.h" 2 int dump_raw_table (FTable *table, char *message); 3 int dump_cmp_table (FTable *table, char *message); 2 4 3 5 FILE *f = (FILE *) NULL; … … 412 414 table.header = &header; 413 415 414 /* load appropriate extension (if extname is a number, use count)*/416 /**** find the appropriate extension and read header (if extname is a number, use count) ****/ 415 417 if (Nextend > -1) { 416 418 // first extension is PHU, cannot be a table. … … 429 431 } 430 432 if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension %d\n", Nextend); 431 432 if (getSizes) {433 read_table_sizes (&header);434 if (CCDKeyword != NULL) free (CCDKeyword);435 gfits_free_header (&header);436 return TRUE;437 }438 439 if (Nrows == -1) {440 Nrows = header.Naxis[1] - start;441 }442 if (start < 0) ESCAPE ("invalid range: start < 0\n");443 if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]);444 if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n");445 446 // just a warning:447 if (start + Nrows > header.Naxis[1]) {448 if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only %d rows\n", header.Naxis[1] - start);449 }450 451 // Ny = 100, start = 0, Nrows = -1 -> Nrows => 100452 // Ny = 100, start = 10, Nrows = 90453 454 if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend);455 433 } else { 456 434 if (CCDKeyword == NULL) { … … 460 438 CCDKeyword = strcreate ("EXTNAME"); 461 439 } 462 463 440 while (1) { 464 441 if (!gfits_load_header (f, &header)) { … … 469 446 return (TRUE); 470 447 } 471 472 448 Nbytes = gfits_data_size (&header); 473 449 … … 482 458 continue; 483 459 } 484 485 if (getSizes) {486 read_table_sizes (&header);487 if (CCDKeyword != NULL) free (CCDKeyword);488 gfits_free_header (&header);489 return TRUE;490 }491 492 if (Nrows == -1) {493 Nrows = header.Naxis[1] - start;494 }495 if (start < 0) ESCAPE ("invalid range: start < 0\n");496 if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]);497 if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n");498 499 // just a warning:500 if (start + Nrows > header.Naxis[1]) {501 if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only %d rows\n", header.Naxis[1] - start);502 }503 504 if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend);505 506 // if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension\n");507 508 460 break; 509 461 } 462 } 463 464 int IsCompressed = gfits_extension_is_compressed_table (&header); 465 466 if (getSizes && !IsCompressed) { 467 read_table_sizes (&header); 468 if (CCDKeyword != NULL) free (CCDKeyword); 469 gfits_free_header (&header); 470 return TRUE; 471 } 472 if (IsCompressed) { 473 if (getSizes) { 474 gprint (GP_ERR, "%s[%s] is compressed: -sizes is invalid\n", filename, extname); 475 gfits_free_header (&header); 476 return FALSE; 477 } 478 if ((start > 0) || (Nrows > -1)) { 479 gprint (GP_ERR, "%s[%s] is compressed: must read entire table\n", filename, extname); 480 gfits_free_header (&header); 481 return FALSE; 482 } 483 } 484 485 if (Nrows == -1) { 486 Nrows = header.Naxis[1] - start; 487 } 488 if (start < 0) ESCAPE ("invalid range: start < 0\n"); 489 if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny ("OFF_T_FMT")\n", header.Naxis[1]); 490 if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n"); 491 492 // just a warning: 493 if (start + Nrows > header.Naxis[1]) { 494 if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only "OFF_T_FMT" rows\n", header.Naxis[1] - start); 495 } 496 497 // Ny = 100, start = 0, Nrows = -1 -> Nrows => 100 498 // Ny = 100, start = 10, Nrows = 90 499 500 if (IsCompressed) { 501 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension %d\n", Nextend); 502 } else { 503 if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend); 510 504 } 511 505 … … 518 512 Binary = !strcmp (type, "BINTABLE"); 519 513 Ny = header.Naxis[1]; 514 515 Header *outheader = &header; 516 FTable *outtable = &table; 517 518 Header rawheader; 519 FTable rawtable; 520 if (IsCompressed) { 521 rawtable.header = &rawheader; 522 523 dump_cmp_table (&table, "rd cmp"); 524 525 int Nfields; 526 if (!gfits_scan (&header, "TFIELDS", "%d", 1, &Nfields)) ESCAPE ("cannot find TFIELDS in header\n"); 527 for (i = 0; i < Nfields; i++) { 528 gfits_byteswap_varlength_column (&table, i+1); 529 } 530 if (!gfits_uncompress_table (&table, &rawtable)) ESCAPE ("failed to uncompress table\n"); 531 dump_raw_table (&rawtable, "rd raw"); 532 533 outheader = &rawheader; 534 outtable = &rawtable; 535 gfits_free_header (&header); 536 gfits_free_table (&table); 537 Ny = rawheader.Naxis[1]; 538 } 520 539 521 540 /* find columns which match requested vectors */ … … 527 546 Nval = 0; 528 547 if (Binary) { 529 if (!gfits_get_bintable_column_type ( &header, argv[i], type, &Nval)) ESCAPE ("requested field not found");530 if (!gfits_get_bintable_column (&header, &table, argv[i], &data)) ESCAPE ("error reading data from specified field");548 if (!gfits_get_bintable_column_type (outheader, argv[i], type, &Nval)) ESCAPE ("requested field not found\n"); 549 if (!gfits_get_bintable_column_raw (outheader, outtable, argv[i], &data, IsCompressed)) ESCAPE ("error reading data from specified field\n"); 531 550 } else { 532 if (!gfits_get_table_column_type ( &header, argv[i], type)) ESCAPE ("requested field not found");533 if (!gfits_get_table_column ( &header, &table, argv[i], &data)) ESCAPE ("error reading data from specified field");534 } 535 if (Nval == 0) ESCAPE ("no data for field in table ");551 if (!gfits_get_table_column_type (outheader, argv[i], type)) ESCAPE ("requested field not found\n"); 552 if (!gfits_get_table_column (outheader, outtable, argv[i], &data)) ESCAPE ("error reading data from specified field\n"); 553 } 554 if (Nval == 0) ESCAPE ("no data for field in table\n"); 536 555 537 556 vecType = OPIHI_INT; 538 if (!strcmp (type, "double") || !strcmp (type, "float") ) {557 if (!strcmp (type, "double") || !strcmp (type, "float") || !strcmp (type, "int64_t")) { 539 558 vecType = OPIHI_FLT; 540 559 } … … 570 589 else 571 590 sprintf (name, "%s:%d", argv[i], j); 572 if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name ");591 if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name\n"); 573 592 ResetVector (vec[j], vecType, Ny); 574 593 } 575 594 576 if (!VectorAssignData (vec, type, data, Ny, Nval)) ESCAPE ("bad column type %s ", type);595 if (!VectorAssignData (vec, type, data, Ny, Nval)) ESCAPE ("bad column type %s\n", type); 577 596 578 597 } else { … … 584 603 else 585 604 sprintf (name, "%s:%d", argv[i], j); 586 if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name ");605 if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name\n"); 587 606 ResetVector (vec[j], vecType, Nval); 588 607 } 589 608 590 if (!VectorAssignDataTranspose (vec, type, data, Ny, Nval)) ESCAPE ("bad column type %s ", type);609 if (!VectorAssignDataTranspose (vec, type, data, Ny, Nval)) ESCAPE ("bad column type %s\n", type); 591 610 } 592 611 free (data); … … 594 613 } 595 614 if (CCDKeyword != NULL) free (CCDKeyword); 596 gfits_free_table ( &table);597 gfits_free_header ( &header);615 gfits_free_table (outtable); 616 gfits_free_header (outheader); 598 617 return (TRUE); 599 618 } -
trunk/Ohana/src/opihi/cmd.data/tv.c
r38062 r38441 71 71 int tooBig = buf[0].matrix.Naxis[2] ? (plane >= buf[0].matrix.Naxis[2]) : plane > 0; 72 72 if (tooBig) { 73 gprint (GP_ERR, " ERROR: -plane (plane) : out of bounds (%d vs %d)\n", plane, buf[0].matrix.Naxis[2]);73 gprint (GP_ERR, " ERROR: -plane (plane) : out of bounds (%d vs "OFF_T_FMT")\n", plane, buf[0].matrix.Naxis[2]); 74 74 return (FALSE); 75 75 } -
trunk/Ohana/src/opihi/cmd.data/vstats.c
r35109 r38441 121 121 goto skip; 122 122 } 123 // we can hit inf if pmax and pmin are close to the max range 124 if (isinf(dx)) dx = DBL_MAX / Nbin; 123 125 124 126 ALLOCATE (Nval, int, Nbin + 2); -
trunk/Ohana/src/opihi/cmd.data/wd.c
r38062 r38441 18 18 } 19 19 20 char *CompressMode = NULL; 21 if ((N = get_argument (argc, argv, "-compress-mode"))) { 22 remove_argument (N, &argc, argv); 23 CompressMode = strcreate(argv[N]); 24 remove_argument (N, &argc, argv); 25 } else if ((N = get_argument (argc, argv, "-compress"))) { 26 remove_argument (N, &argc, argv); 27 CompressMode = strcreate("GZIP_1"); 28 } 29 20 30 outZero = 0; 21 31 newZero = FALSE; … … 54 64 if (outUnsign == -1) { 55 65 gprint (GP_ERR, "-unsign options: t, f, true, false\n"); 66 FREE (CompressMode); 56 67 return (FALSE); 57 68 } … … 62 73 if (argc != 3) { 63 74 gprint (GP_ERR, "USAGE: wd <buffer> <filename> [-bitpix N] [-bscale X] [-bzero X] [-extend] [-newplane]\n"); 75 FREE (CompressMode); 64 76 return (FALSE); 65 77 } 66 78 67 if ((buf = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) return (FALSE);79 if ((buf = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) { FREE (CompressMode); return (FALSE); } 68 80 69 81 if (!newBitpix) outBitpix = buf[0].bitpix; … … 159 171 gfits_free_header (&temp_header); 160 172 gfits_free_matrix (&temp_matrix); 173 FREE (CompressMode); 161 174 return (status); 162 175 } 163 176 177 // not compatible with extend 178 if (CompressMode) { 179 Header myHeader; 180 Matrix myMatrix; 181 182 FILE *f = fopen (argv[2], "w"); 183 if (!f) { 184 fprintf (stderr, "ERROR: cannot open image subset file for output %s\n", argv[2]); 185 FREE (CompressMode); 186 return FALSE; 187 } 188 189 gfits_init_header (&myHeader); 190 myHeader.extend = TRUE; 191 gfits_create_header (&myHeader); 192 gfits_create_matrix (&myHeader, &myMatrix); 193 gfits_fwrite_header (f, &myHeader); 194 gfits_fwrite_matrix (f, &myMatrix); 195 gfits_free_header (&myHeader); 196 gfits_free_matrix (&myMatrix); 197 198 FTable ftable; 199 Header theader; 200 201 ftable.header = &theader; 202 203 gfits_compress_image (&temp_header, &temp_matrix, &ftable, NULL, CompressMode); 204 gfits_byteswap_varlength_column (&ftable, 1); 205 gfits_fwrite_Theader (f, &theader); 206 gfits_fwrite_table (f, &ftable); 207 fclose (f); 208 209 gfits_free_header (&theader); 210 gfits_free_table (&ftable); 211 FREE (CompressMode); 212 return (TRUE); 213 } 214 164 215 /* the actual write-to-disk goes here */ 165 216 if (!gfits_write_header (argv[2], &temp_header)) { … … 167 218 gfits_free_header (&temp_header); 168 219 gfits_free_matrix (&temp_matrix); 220 FREE (CompressMode); 169 221 return (FALSE); 170 222 } … … 174 226 gfits_free_header (&temp_header); 175 227 gfits_free_matrix (&temp_matrix); 228 FREE (CompressMode); 176 229 return (FALSE); 177 230 } … … 180 233 gfits_free_matrix (&temp_matrix); 181 234 235 FREE (CompressMode); 182 236 return (TRUE); 183 237 } -
trunk/Ohana/src/opihi/cmd.data/write_vectors.c
r35109 r38441 3 3 int write_vectors (int argc, char **argv) { 4 4 5 int append;6 5 int i, j, Nvec, Ne, N; 7 6 FILE *f; 8 7 char **fmtlist, *fmttype; 9 char *p0, *p1, *p2, *format , *FITS;8 char *p0, *p1, *p2, *format; 10 9 Vector **vec; 11 10 … … 34 33 35 34 /* option generate a FITS output table */ 36 FITS = NULL;35 char *FITS = NULL; 37 36 if ((N = get_argument (argc, argv, "-fits"))) { 38 37 remove_argument (N, &argc, argv); … … 58 57 } 59 58 60 append = FALSE;59 int append = FALSE; 61 60 if ((N = get_argument (argc, argv, "-append"))) { 62 61 remove_argument (N, &argc, argv); 63 62 append = TRUE; 63 } 64 65 char *compress = NULL; 66 if ((N = get_argument (argc, argv, "-compress-mode"))) { 67 remove_argument (N, &argc, argv); 68 compress = strcreate(argv[N]); 69 remove_argument (N, &argc, argv); 70 } else if ((N = get_argument (argc, argv, "-compress"))) { 71 remove_argument (N, &argc, argv); 72 compress = strcreate("GZIP_1"); 73 if (!FITS) { 74 fprintf (stderr, "NOTE: write_vectors -compress has no effect on non-FITS\n"); 75 } 64 76 } 65 77 … … 105 117 106 118 if (FITS) { 107 int status = WriteVectorTableFITS (argv[1], FITS, vec, Nvec, append, format);119 int status = WriteVectorTableFITS (argv[1], FITS, vec, Nvec, append, compress, format); 108 120 free (vec); 109 121 return status; … … 243 255 gprint (GP_ERR, " -csv : write a comma-separated values file (eg, to read in excel)\n"); 244 256 gprint (GP_ERR, " -f \"format\" : provide formatting codes for output:\n"); 245 gprint (GP_ERR, " ascii / csv : format consists of c-style format codes in form % NN.Md\n");257 gprint (GP_ERR, " ascii / csv : format consists of c-style format codes in form %%NN.Md\n"); 246 258 gprint (GP_ERR, ", the following codes are allowed\n"); 247 gprint (GP_ERR, " % e -- double,%f -- float\n");248 gprint (GP_ERR, " % d -- int, %c -- char,%x -- hex int\n");259 gprint (GP_ERR, " %%e -- double, %%f -- float\n"); 260 gprint (GP_ERR, " %%d -- int, %%c -- char, %%x -- hex int\n"); 249 261 gprint (GP_ERR, " FITS : format consists of the following FITS binary table format codes:\n"); 250 262 gprint (GP_ERR, " B : 1 byte int\n"); -
trunk/Ohana/src/opihi/dvo/avextract.c
r38062 r38441 185 185 snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name); 186 186 catalog.filename = (HOST_ID || PARALLEL_LOCAL) ? hostfile : skylist[0].filename[i]; 187 catalog.catflags = LOAD_AVES | LOAD_SECF;188 catalog.catflags |= needMeasure ? LOAD_MEAS : SKIP_MEAS;189 catalog.catflags |= needLensobj ? LOAD_LENSOBJ :SKIP_LENSOBJ;190 catalog.catflags |= needStarpar ? LOAD_STARPAR :SKIP_STARPAR;187 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 188 catalog.catflags |= needMeasure ? DVO_LOAD_MEASURE : DVO_SKIP_MEASURE; 189 catalog.catflags |= needLensobj ? DVO_LOAD_LENSOBJ : DVO_SKIP_LENSOBJ; 190 catalog.catflags |= needStarpar ? DVO_LOAD_STARPAR : DVO_SKIP_STARPAR; 191 191 catalog.Nsecfilt = 0; 192 192 … … 256 256 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 257 257 if (RESULT_FILE && !SKIP_RESULTS) { 258 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, NULL);258 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, FALSE, NULL); 259 259 if (!status) { 260 260 goto escape; -
trunk/Ohana/src/opihi/dvo/avmatch.c
r37807 r38441 115 115 116 116 CoordsFile = abspath("coords.fits", 1024); 117 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL);117 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, FALSE, NULL); 118 118 if (!status) goto escape; 119 119 } … … 190 190 snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name); 191 191 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 192 catalog.catflags = LOAD_AVES | LOAD_SECF;193 catalog.catflags |= needMeasure ? LOAD_MEAS : SKIP_MEAS;194 catalog.catflags |= needLensobj ? LOAD_LENSOBJ :SKIP_LENSOBJ;195 catalog.catflags |= needStarpar ? LOAD_STARPAR :SKIP_STARPAR;192 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 193 catalog.catflags |= needMeasure ? DVO_LOAD_MEASURE : DVO_SKIP_MEASURE; 194 catalog.catflags |= needLensobj ? DVO_LOAD_LENSOBJ : DVO_SKIP_LENSOBJ; 195 catalog.catflags |= needStarpar ? DVO_LOAD_STARPAR : DVO_SKIP_STARPAR; 196 196 catalog.Nsecfilt = 0; 197 197 … … 302 302 vec[i][0].Nelements = Nfound; 303 303 } 304 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields + 1, FALSE, NULL);304 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields + 1, FALSE, FALSE, NULL); 305 305 free (vec[Nfields]->elements.Int); 306 306 free (vec[Nfields]); -
trunk/Ohana/src/opihi/dvo/calextract.c
r34088 r38441 61 61 /* lock, load, unlock catalog */ 62 62 catalog.filename = skylist[0].filename[Nr]; 63 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;63 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 64 64 catalog.Nsecfilt = 0; 65 65 -
trunk/Ohana/src/opihi/dvo/calmextract.c
r34088 r38441 74 74 /* lock, load, unlock catalog */ 75 75 catalog.filename = skylist[0].filename[Nr]; 76 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;76 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 77 77 catalog.Nsecfilt = 0; 78 78 -
trunk/Ohana/src/opihi/dvo/catalog.c
r19823 r38441 315 315 /* lock, load, unlock catalog */ 316 316 catalog.filename = filename; 317 catalog.catflags = LOAD_AVES;317 catalog.catflags = DVO_LOAD_AVERAGE; 318 318 319 319 // an error exit status here is a significant error -
trunk/Ohana/src/opihi/dvo/ccd.c
r34088 r38441 69 69 /* lock, load, unlock catalog */ 70 70 catalog.filename = skylist[0].filename[k]; 71 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;71 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 72 72 catalog.Nsecfilt = 0; 73 73 -
trunk/Ohana/src/opihi/dvo/cmatch.c
r28241 r38441 29 29 /* load data from the photometry database file */ 30 30 catalog1.filename = filename; 31 catalog1.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;31 catalog1.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 32 32 33 33 // an error exit status here is a significant error -
trunk/Ohana/src/opihi/dvo/cmd.c
r34088 r38441 68 68 /* lock, load, unlock catalog */ 69 69 catalog.filename = skylist[0].filename[j]; 70 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;70 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 71 71 catalog.Nsecfilt = 0; 72 72 -
trunk/Ohana/src/opihi/dvo/cmpReadFile.c
r29001 r38441 19 19 if (!gfits_fread_ftable (f, &table, "SMPFILE")) goto escape; 20 20 21 smpdata = gfits_table_get_SMPData (&table, &Nstars, NULL );21 smpdata = gfits_table_get_SMPData (&table, &Nstars, NULL, NULL); 22 22 if (!smpdata) { 23 23 fprintf (stderr, "ERROR: failed to read stars\n"); -
trunk/Ohana/src/opihi/dvo/ddmags.c
r15509 r38441 66 66 /* lock, load, unlock catalog */ 67 67 catalog.filename = skylist[0].filename[k]; 68 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;68 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 69 69 catalog.Nsecfilt = 0; 70 70 -
trunk/Ohana/src/opihi/dvo/dmagaves.c
r14401 r38441 58 58 /* lock, load, unlock catalog */ 59 59 catalog.filename = skylist[0].filename[j]; 60 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;60 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 61 61 catalog.Nsecfilt = 0; 62 62 -
trunk/Ohana/src/opihi/dvo/dmagmeas.c
r15509 r38441 66 66 /* lock, load, unlock catalog */ 67 67 catalog.filename = skylist[0].filename[j]; 68 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;68 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 69 69 catalog.Nsecfilt = 0; 70 70 -
trunk/Ohana/src/opihi/dvo/dmags.c
r15509 r38441 64 64 /* lock, load, unlock catalog */ 65 65 catalog.filename = skylist[0].filename[j]; 66 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;66 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 67 67 catalog.Nsecfilt = 0; 68 68 -
trunk/Ohana/src/opihi/dvo/dmt.c
r31635 r38441 77 77 /* lock, load, unlock catalog */ 78 78 catalog.filename = skylist[0].filename[k]; 79 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;79 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 80 80 catalog.Nsecfilt = 0; 81 81 -
trunk/Ohana/src/opihi/dvo/dvo_host_utils.c
r37807 r38441 230 230 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 231 231 if (ResultFile) { 232 int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nvec, FALSE, NULL);232 int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nvec, FALSE, FALSE, NULL); 233 233 if (!status) { 234 234 gprint (GP_ERR, "failed to write result file %s\n", ResultFile); -
trunk/Ohana/src/opihi/dvo/extract.c
r31635 r38441 252 252 catalog.measure = (Measure *) NULL; 253 253 catalog.secfilt = (SecFilt *) NULL; 254 loadmode = LOAD_AVES | LOAD_SECF;254 loadmode = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 255 255 if ((mode == REF) || (mode == TYPE) || (mode == NPHOT) || (mode == NCODE)) 256 loadmode = loadmode | LOAD_MEAS;256 loadmode = loadmode | DVO_LOAD_MEASURE; 257 257 258 258 /* lock, load, unlock catalog */ -
trunk/Ohana/src/opihi/dvo/fitcolors.c
r34584 r38441 162 162 /* lock, load, unlock catalog */ 163 163 catalog[k].filename = skylist[0].filename[k]; 164 catalog[k].catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;164 catalog[k].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 165 165 catalog[k].Nsecfilt = 0; 166 166 -
trunk/Ohana/src/opihi/dvo/fitsed.c
r37049 r38441 188 188 /* lock, load, unlock catalog */ 189 189 catalog.filename = skylist[0].filename[k]; 190 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;190 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 191 191 catalog.Nsecfilt = 0; 192 192 -
trunk/Ohana/src/opihi/dvo/gstar.c
r37246 r38441 235 235 236 236 /* lock, load, unlock catalog */ 237 catalog.catflags = LOAD_AVES | LOAD_SECF;238 catalog.catflags |= GetMeasures ? LOAD_MEAS : SKIP_MEAS;237 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 238 catalog.catflags |= GetMeasures ? DVO_LOAD_MEASURE : DVO_SKIP_MEASURE; 239 239 catalog.Nsecfilt = 0; 240 240 -
trunk/Ohana/src/opihi/dvo/imdata.c
r37807 r38441 136 136 /* get file name and open */ 137 137 catalog.filename = skylist[0].filename[j]; 138 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;138 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 139 139 catalog.Nsecfilt = 0; 140 140 -
trunk/Ohana/src/opihi/dvo/lcurve.c
r37049 r38441 76 76 /* set filename, read in header */ 77 77 catalog.filename = skylist[0].filename[0]; 78 catalog.catflags = LOAD_AVES | LOAD_MEAS;78 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE; 79 79 catalog.Nsecfilt = 0; 80 80 -
trunk/Ohana/src/opihi/dvo/lightcurve.c
r37049 r38441 59 59 /* set filename, read in header */ 60 60 catalog.filename = skylist[0].filename[0]; 61 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;61 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 62 62 catalog.Nsecfilt = 0; 63 63 -
trunk/Ohana/src/opihi/dvo/mextract.c
r37807 r38441 19 19 return FALSE; 20 20 } 21 22 void gfits_uncompress_timing (); 21 23 22 24 int mextract (int argc, char **argv) { … … 229 231 snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name); 230 232 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 231 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;232 // catalog.catflags |= needLensing ? LOAD_LENSING :SKIP_LENSING;233 catalog.catflags |= needStarpar ? LOAD_STARPAR :SKIP_STARPAR;233 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 234 // catalog.catflags |= needLensing ? DVO_LOAD_LENSING : DVO_SKIP_LENSING; 235 catalog.catflags |= needStarpar ? DVO_LOAD_STARPAR : DVO_SKIP_STARPAR; 234 236 catalog.Nsecfilt = Nsecfilt; 235 237 … … 317 319 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 318 320 if (RESULT_FILE && !SKIP_RESULTS) { 319 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, NULL);321 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, FALSE, NULL); 320 322 if (!status) goto escape; 321 323 } … … 330 332 SkyListFree (skylist); 331 333 FreeSkyRegionSelection (selection); 334 335 gfits_uncompress_timing(); 332 336 333 337 // fprintf (stderr, "done extr...\n"); -
trunk/Ohana/src/opihi/dvo/mmatch.c
r37807 r38441 150 150 // XXX this is now set for both cases... 151 151 CoordsFile = abspath("coords.fits", 1024); 152 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL);152 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, FALSE, NULL); 153 153 if (!status) goto escape; 154 154 } … … 248 248 snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name); 249 249 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 250 catalog.catflags = LOAD_AVES | LOAD_SECF | LOAD_MEAS;251 catalog.catflags |= needStarpar ? LOAD_STARPAR :SKIP_STARPAR;250 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT | DVO_LOAD_MEASURE; 251 catalog.catflags |= needStarpar ? DVO_LOAD_STARPAR : DVO_SKIP_STARPAR; 252 252 catalog.Nsecfilt = Nsecfilt; 253 253 … … 349 349 vec[Nfields-1] = IDXvec; 350 350 } 351 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields, FALSE, NULL);351 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields, FALSE, FALSE, NULL); 352 352 if (!status) goto escape; 353 353 } -
trunk/Ohana/src/opihi/dvo/mmextract.c
r37807 r38441 183 183 /* lock, load, unlock catalog */ 184 184 catalog.filename = skylist[0].filename[i]; 185 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;185 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 186 186 catalog.Nsecfilt = Nsecfilt; 187 187 -
trunk/Ohana/src/opihi/dvo/objectcoverage.c
r37807 r38441 184 184 /* lock, load, unlock catalog */ 185 185 catalog.filename = skylist[0].filename[k]; 186 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;186 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 187 187 catalog.Nsecfilt = 0; 188 188 -
trunk/Ohana/src/opihi/dvo/paverage.c
r34088 r38441 105 105 for (j = 0; (j < skylist[0].Nregions) && !interrupt; j++) { 106 106 catalog.filename = skylist[0].filename[j]; 107 catalog.catflags = LOAD_AVES | LOAD_SECF;107 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 108 108 catalog.Nsecfilt = Nsecfilt; 109 109 -
trunk/Ohana/src/opihi/dvo/pmeasure.c
r37049 r38441 178 178 for (j = 0; (j < skylist[0].Nregions) && !interrupt; j++) { 179 179 catalog.filename = skylist[0].filename[j]; 180 catalog.catflags = LOAD_AVES | LOAD_MEAS;180 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE; 181 181 catalog.Nsecfilt = 0; 182 182 -
trunk/Ohana/src/opihi/dvo/subpix.c
r37807 r38441 40 40 /* lock, load, unlock catalog */ 41 41 catalog.filename = skylist[0].filename[0]; 42 catalog.catflags = LOAD_AVES | LOAD_MEAS;42 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE; 43 43 catalog.Nsecfilt = 0; 44 44 -
trunk/Ohana/src/opihi/include/dvomath.h
r38062 r38441 167 167 168 168 /* vector IO functions */ 169 int WriteVectorTableFITS PROTO((char *filename, char *extname, Vector **vec, int Nvec, int append, char * format));169 int WriteVectorTableFITS PROTO((char *filename, char *extname, Vector **vec, int Nvec, int append, char *compress, char *format)); 170 170 Vector **ReadVectorTableFITS PROTO((char *filename, char *extname, int *Nvec)); 171 171 -
trunk/Ohana/src/opihi/lib.data/SplineOps.c
r34584 r38441 178 178 gfits_create_table (&theader, &ftable); 179 179 180 gfits_set_bintable_column_reformat (&theader, &ftable, "X_KNOT", "double", myspline->xk, myspline->Nknots); 181 gfits_set_bintable_column_reformat (&theader, &ftable, "Y_KNOT", "double", myspline->yk, myspline->Nknots); 182 gfits_set_bintable_column_reformat (&theader, &ftable, "DY2_DX", "double", myspline->y2, myspline->Nknots); 180 // NOTE: if we want to compress the output table, use native byte order here (last element) 181 gfits_set_bintable_column_reformat (&theader, &ftable, "X_KNOT", "double", myspline->xk, myspline->Nknots, FALSE); 182 gfits_set_bintable_column_reformat (&theader, &ftable, "Y_KNOT", "double", myspline->yk, myspline->Nknots, FALSE); 183 gfits_set_bintable_column_reformat (&theader, &ftable, "DY2_DX", "double", myspline->y2, myspline->Nknots, FALSE); 183 184 184 185 if (!append) { -
trunk/Ohana/src/opihi/lib.shell/VectorIO.c
r37049 r38441 1 1 # include "opihi.h" 2 2 3 // write a set of vectors to a FITS file (vectors names become fits column names)4 int WriteVectorTable (Header *theader, FTable *ftable, char *extname, Vector **vec, int Nvec, char *format) {3 // write a set of vectors to a FITS FTable structure (vectors names become fits column names) 4 static int WriteVectorTable (FTable *ftable, char *extname, Vector **vec, int Nvec, char *format, char nativeOrder) { 5 5 6 6 int j; … … 8 8 char *tformat = NULL; 9 9 10 Header *theader = ftable->header; 10 11 gfits_create_table_header (theader, "BINTABLE", extname); 11 12 … … 58 59 for (j = 0; j < Nvec; j++) { 59 60 if (vec[j][0].type == OPIHI_FLT) { 60 gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "double", vec[j][0].elements.Flt, vec[j][0].Nelements );61 gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "double", vec[j][0].elements.Flt, vec[j][0].Nelements, nativeOrder); 61 62 } else { 62 gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "int", vec[j][0].elements.Int, vec[j][0].Nelements );63 gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "int", vec[j][0].elements.Int, vec[j][0].Nelements, nativeOrder); 63 64 } 64 65 } … … 70 71 } 71 72 73 # define VERBOSE 0 74 int dump_raw_table (FTable *table, char *message) { 75 # if (VERBOSE) 76 int i; 77 fprintf (stderr, "%s data: ", message); 78 for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) { 79 fprintf (stderr, "0x%02hhx ", table->buffer[i]); 80 } 81 fprintf (stderr, "\n"); 82 # endif 83 return TRUE; 84 } 85 86 int dump_cmp_table (FTable *table, char *message) { 87 # if (VERBOSE) 88 int i; 89 fprintf (stderr, "%s pntr: ", message); 90 for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) { 91 fprintf (stderr, "0x%02hhx ", table->buffer[i]); 92 } 93 fprintf (stderr, "\n"); 94 95 fprintf (stderr, "%s data: ", message); 96 for (i = 0; i < table->header->pcount; i++) { 97 fprintf (stderr, "0x%02hhx ", table->buffer[table->heap_start + i]); 98 } 99 fprintf (stderr, "\n"); 100 # endif 101 return TRUE; 102 } 103 72 104 // write a set of vectors to a FITS file (vectors names become fits column names) 73 int WriteVectorTableFITS (char *filename, char *extname, Vector **vec, int Nvec, int append, char * format) {74 75 Header header;76 Matrix matrix;77 Header theader;78 FTable ftable;105 int WriteVectorTableFITS (char *filename, char *extname, Vector **vec, int Nvec, int append, char *compress, char *format) { 106 107 Header rawheader; 108 Header cmpheader; 109 FTable rawtable; 110 FTable cmptable; 79 111 80 112 FILE *f = NULL; … … 91 123 } 92 124 93 if (!WriteVectorTable (&theader, &ftable, extname, vec, Nvec, format)) goto escape; 125 // init so free below does not fail if table is not created 126 gfits_init_header (&rawheader); 127 gfits_init_header (&cmpheader); 128 gfits_init_table (&rawtable); 129 gfits_init_table (&cmptable); 130 131 rawtable.header = &rawheader; 132 if (!WriteVectorTable (&rawtable, extname, vec, Nvec, format, (compress != NULL))) goto escape; 133 // NOTE : for compression, the table is constructed in native by order 134 135 FTable *outtable = &rawtable; 136 Header *outheader = &rawheader; 137 138 if (compress) { 139 cmptable.header = &cmpheader; 140 141 dump_raw_table (&rawtable, "wd raw"); 142 if (!gfits_compress_table (&rawtable, &cmptable, 0, compress)) goto escape; 143 144 int i, Nfields; 145 if (!gfits_scan (&cmpheader, "TFIELDS", "%d", 1, &Nfields)) goto escape; 146 for (i = 0; i < Nfields; i++) { 147 gfits_byteswap_varlength_column (&cmptable, i+1); 148 } 149 dump_cmp_table (&cmptable, "wd cmp"); 150 151 outtable = &cmptable; 152 outheader = &cmpheader; 153 } 94 154 95 155 if (!append) { 156 Header header; 157 Matrix matrix; 96 158 gfits_init_header (&header); 159 gfits_init_matrix (&matrix); 97 160 header.extend = TRUE; 98 161 gfits_create_header (&header); … … 103 166 gfits_free_matrix (&matrix); 104 167 } 105 gfits_fwrite_Theader (f, &theader); 106 gfits_fwrite_table (f, &ftable); 107 108 gfits_free_header (&theader); 109 gfits_free_table (&ftable); 168 169 // write the actual table data 170 gfits_fwrite_Theader (f, outheader); 171 gfits_fwrite_table (f, outtable); 172 173 gfits_free_header (&rawheader); 174 gfits_free_table (&rawtable); 175 176 if (compress) { 177 gfits_free_header (&cmpheader); 178 gfits_free_table (&cmptable); 179 } 110 180 111 181 fclose (f); … … 114 184 115 185 escape: 116 if (!append) { 117 gfits_free_header (&header); 118 gfits_free_matrix (&matrix); 119 } 120 gfits_free_header (&theader); 121 gfits_free_table (&ftable); 186 gfits_free_header (&rawheader); 187 gfits_free_table (&rawtable); 188 189 if (compress) { 190 gfits_free_header (&cmpheader); 191 gfits_free_table (&cmptable); 192 } 122 193 123 194 fclose (f); … … 249 320 ASSIGN_DATA(short, short, Int); 250 321 ASSIGN_DATA(int, int, Int); 251 ASSIGN_DATA(int64_t, int64_t, Int);322 ASSIGN_DATA(int64_t, int64_t, Flt); // int64_t has a problem: Int is too small, Flt is wrong precision 252 323 ASSIGN_DATA(float, float, Flt); 253 324 ASSIGN_DATA(double, double, Flt); … … 274 345 ASSIGN_DATA_TRANSPOSE(short, short, Int); 275 346 ASSIGN_DATA_TRANSPOSE(int, int, Int); 276 ASSIGN_DATA_TRANSPOSE(int64_t, int64_t, Int);347 ASSIGN_DATA_TRANSPOSE(int64_t, int64_t, Flt); 277 348 ASSIGN_DATA_TRANSPOSE(float, float, Flt); 278 349 ASSIGN_DATA_TRANSPOSE(double, double, Flt); -
trunk/Ohana/src/opihi/lib.shell/convert_to_RPN.c
r38062 r38441 58 58 if (!strcmp (argv[i], "lgamma")) { type = ST_UNARY; goto gotit; } 59 59 if (!strcmp (argv[i], "rnd")) { type = ST_UNARY; goto gotit; } 60 if (!strcmp (argv[i], "drnd")) { type = ST_UNARY; goto gotit; } 61 if (!strcmp (argv[i], "lrnd")) { type = ST_UNARY; goto gotit; } 62 if (!strcmp (argv[i], "mrnd")) { type = ST_UNARY; goto gotit; } 60 63 if (!strcmp (argv[i], "xramp")) { type = ST_UNARY; goto gotit; } 61 64 if (!strcmp (argv[i], "yramp")) { type = ST_UNARY; goto gotit; } -
trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c
r38062 r38441 115 115 116 116 /* there are no valid unary string operators */ 117 push_error ("invalid operands for trinary operator (mismatch types?)"); 117 snprintf (line, 512, "invalid operands for trinary operator %s (mismatch types?)", stack[i].name); 118 push_error (line); 118 119 clear_stack (&tmp_stack); 119 120 return (FALSE); … … 210 211 211 212 /* there are no valid unary string operators */ 212 push_error ("syntax error: no valid string unary ops"); 213 snprintf (line, 512, "invalid operand for unary operator %s (undefined value?)", stack[i].name); 214 push_error (line); 213 215 clear_stack (&tmp_stack); 214 216 return (FALSE); -
trunk/Ohana/src/opihi/lib.shell/stack_math.c
r38062 r38441 12 12 // set up the possible operations : int OP int -> int, all else yield float 13 13 // OP is the operation performed on *M1 and *M2 14 # define SSS_FUNC(OP) { \14 # define SSS_FUNC(OP) { \ 15 15 if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_FLT) && (V3->type == ST_SCALAR_FLT)) { \ 16 opihi_flt M1 = V1[0].FltValue; \17 opihi_flt M2 = V2[0].FltValue; \18 opihi_flt M3 = V3[0].FltValue; \19 OUT[0].type = ST_SCALAR_FLT; \20 OUT[0].FltValue = OP; \16 opihi_flt M1 = V1[0].FltValue; \ 17 opihi_flt M2 = V2[0].FltValue; \ 18 opihi_flt M3 = V3[0].FltValue; \ 19 OUT[0].type = ST_SCALAR_FLT; \ 20 OUT[0].FltValue = OP; \ 21 21 break; \ 22 22 } \ 23 23 if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT) && (V3->type == ST_SCALAR_INT)) { \ 24 opihi_int M1 = V1[0].IntValue; \25 opihi_int M2 = V2[0].IntValue; \26 opihi_int M3 = V3[0].IntValue; \27 OUT[0].type = ST_SCALAR_INT; \28 OUT[0].IntValue = OP; \24 opihi_int M1 = V1[0].IntValue; \ 25 opihi_int M2 = V2[0].IntValue; \ 26 opihi_int M3 = V3[0].IntValue; \ 27 OUT[0].type = ST_SCALAR_INT; \ 28 OUT[0].IntValue = OP; \ 29 29 break; \ 30 30 } \ … … 32 32 33 33 switch (op[0]) { 34 case '?': SSS_FUNC(M1 ? M2: M3);35 default:36 snprintf (line, 512, "error: op %c not defined!", op[0]);37 push_error (line);38 return (FALSE);39 }34 case '?': SSS_FUNC(M1 ? M2: M3); 35 default: 36 snprintf (line, 512, "error: op %c not defined!", op[0]); 37 push_error (line); 38 return (FALSE); 39 } 40 40 # undef SSS_FUNC 41 41 … … 68 68 // set up the possible operations : int OP int -> int, all else yield float 69 69 // OP is the operation performed on *M1 and *M2 70 # define VVV_FUNC(OP) { \70 # define VVV_FUNC(OP) { \ 71 71 if ((V1->vector->type == OPIHI_FLT) && (V2->vector->type == OPIHI_FLT) && (V3->vector->type == OPIHI_FLT)) { \ 72 72 CopyVector (OUT[0].vector, V1[0].vector); \ … … 394 394 // OP is the operation performed on *M1 and *M2 395 395 # define SV_FUNC(FTYPE,OP) { \ 396 if ((V1->type == ST_SCALAR_FLT) && (V2->vector->type == OPIHI_FLT)) { \396 if ((V1->type == ST_SCALAR_FLT) && (V2->vector->type == OPIHI_FLT)) { \ 397 397 CopyVector (OUT[0].vector, V2[0].vector); \ 398 398 opihi_flt M1 = V1[0].FltValue; \ … … 404 404 break; \ 405 405 } \ 406 if ((V1->type == ST_SCALAR_FLT) && (V2->vector->type != OPIHI_FLT)) { \406 if ((V1->type == ST_SCALAR_FLT) && (V2->vector->type != OPIHI_FLT)) { \ 407 407 MatchVector (OUT[0].vector, V2[0].vector, OPIHI_FLT); \ 408 408 opihi_flt M1 = V1[0].FltValue; \ … … 414 414 break; \ 415 415 } \ 416 if ((V1->type == ST_SCALAR_INT) && (V2->vector->type == OPIHI_FLT)) { \416 if ((V1->type == ST_SCALAR_INT) && (V2->vector->type == OPIHI_FLT)) { \ 417 417 CopyVector (OUT[0].vector, V2[0].vector); \ 418 418 opihi_int M1 = V1[0].IntValue; \ … … 434 434 break; \ 435 435 } \ 436 if ((V1->type == ST_SCALAR_INT) && (V2->vector->type != OPIHI_FLT)) { \436 if ((V1->type == ST_SCALAR_INT) && (V2->vector->type != OPIHI_FLT)) { \ 437 437 CopyVector (OUT[0].vector, V2[0].vector); \ 438 438 opihi_int M1 = V1[0].IntValue; \ … … 447 447 448 448 switch (op[0]) { 449 case '+': SV_FUNC(ST_SCALAR_INT, M1 + *M2);450 case '-': SV_FUNC(ST_SCALAR_INT, M1 - *M2);451 case '*': SV_FUNC(ST_SCALAR_INT, M1 * *M2);452 case '/': SV_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) *M2);453 case '%': SV_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) *M2);454 case '^': SV_FUNC(ST_SCALAR_FLT, pow (M1, *M2));455 case '@': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2));456 case 'a': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2));457 case 'D': SV_FUNC(ST_SCALAR_INT, MIN (M1, *M2));458 case 'U': SV_FUNC(ST_SCALAR_INT, MAX (M1, *M2));459 case '<': SV_FUNC(ST_SCALAR_INT, (M1 < *M2) ? 1 : 0);460 case '>': SV_FUNC(ST_SCALAR_INT, (M1 > *M2) ? 1 : 0);461 case '&': SV_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)*M2));462 case '|': SV_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)*M2));463 case 'E': SV_FUNC(ST_SCALAR_INT, (M1 == *M2) ? 1 : 0);464 case 'N': SV_FUNC(ST_SCALAR_INT, (M1 != *M2) ? 1 : 0);465 case 'L': SV_FUNC(ST_SCALAR_INT, (M1 <= *M2) ? 1 : 0);466 case 'G': SV_FUNC(ST_SCALAR_INT, (M1 >= *M2) ? 1 : 0);467 case 'A': SV_FUNC(ST_SCALAR_INT, (M1 && *M2) ? 1 : 0);468 case 'O': SV_FUNC(ST_SCALAR_INT, (M1 || *M2) ? 1 : 0);469 default:470 snprintf (line, 512, "error: op %c not defined!", op[0]);471 push_error (line);472 return (FALSE);473 }449 case '+': SV_FUNC(ST_SCALAR_INT, M1 + *M2); 450 case '-': SV_FUNC(ST_SCALAR_INT, M1 - *M2); 451 case '*': SV_FUNC(ST_SCALAR_INT, M1 * *M2); 452 case '/': SV_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) *M2); 453 case '%': SV_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) *M2); 454 case '^': SV_FUNC(ST_SCALAR_FLT, pow (M1, *M2)); 455 case '@': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2)); 456 case 'a': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2)); 457 case 'D': SV_FUNC(ST_SCALAR_INT, MIN (M1, *M2)); 458 case 'U': SV_FUNC(ST_SCALAR_INT, MAX (M1, *M2)); 459 case '<': SV_FUNC(ST_SCALAR_INT, (M1 < *M2) ? 1 : 0); 460 case '>': SV_FUNC(ST_SCALAR_INT, (M1 > *M2) ? 1 : 0); 461 case '&': SV_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)*M2)); 462 case '|': SV_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)*M2)); 463 case 'E': SV_FUNC(ST_SCALAR_INT, (M1 == *M2) ? 1 : 0); 464 case 'N': SV_FUNC(ST_SCALAR_INT, (M1 != *M2) ? 1 : 0); 465 case 'L': SV_FUNC(ST_SCALAR_INT, (M1 <= *M2) ? 1 : 0); 466 case 'G': SV_FUNC(ST_SCALAR_INT, (M1 >= *M2) ? 1 : 0); 467 case 'A': SV_FUNC(ST_SCALAR_INT, (M1 && *M2) ? 1 : 0); 468 case 'O': SV_FUNC(ST_SCALAR_INT, (M1 || *M2) ? 1 : 0); 469 default: 470 snprintf (line, 512, "error: op %c not defined!", op[0]); 471 push_error (line); 472 return (FALSE); 473 } 474 474 # undef SV_FUNC 475 475 476 476 /** free up any temporary buffers: **/ 477 477 if (V2[0].type == ST_VECTOR_TMP) { 478 free (V2[0].vector[0].elements.Ptr);479 free (V2[0].vector);480 }478 free (V2[0].vector[0].elements.Ptr); 479 free (V2[0].vector); 480 } 481 481 482 482 clear_stack (V1); … … 501 501 // OP is the operation performed on *M1 and *M2 502 502 # define VS_FUNC(FTYPE,OP) { \ 503 if ((V2->type == ST_SCALAR_FLT) && (V1->vector->type == OPIHI_FLT)) { \503 if ((V2->type == ST_SCALAR_FLT) && (V1->vector->type == OPIHI_FLT)) { \ 504 504 CopyVector (OUT[0].vector, V1[0].vector); \ 505 505 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ … … 511 511 break; \ 512 512 } \ 513 if ((V2->type == ST_SCALAR_FLT) && (V1->vector->type != OPIHI_FLT)) { \513 if ((V2->type == ST_SCALAR_FLT) && (V1->vector->type != OPIHI_FLT)) { \ 514 514 MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT); \ 515 515 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 521 521 break; \ 522 522 } \ 523 if ((V2->type == ST_SCALAR_INT) && (V1->vector->type == OPIHI_FLT)) { \523 if ((V2->type == ST_SCALAR_INT) && (V1->vector->type == OPIHI_FLT)) { \ 524 524 CopyVector (OUT[0].vector, V1[0].vector); \ 525 525 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ … … 541 541 break; \ 542 542 } \ 543 if ((V2->type == ST_SCALAR_INT) && (V1->vector->type != OPIHI_FLT)) { \543 if ((V2->type == ST_SCALAR_INT) && (V1->vector->type != OPIHI_FLT)) { \ 544 544 CopyVector (OUT[0].vector, V1[0].vector); \ 545 545 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 554 554 555 555 switch (op[0]) { 556 case '+': VS_FUNC(ST_SCALAR_INT, *M1 + M2);557 case '-': VS_FUNC(ST_SCALAR_INT, *M1 - M2);558 case '*': VS_FUNC(ST_SCALAR_INT, *M1 * M2);559 case '/': VS_FUNC(ST_SCALAR_FLT, *M1 / (opihi_flt) M2);560 case '%': VS_FUNC(ST_SCALAR_INT, (long long) *M1 % (long long) M2);561 case '^': VS_FUNC(ST_SCALAR_FLT, pow (*M1, M2));562 case '@': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2));563 case 'a': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2));564 case 'D': VS_FUNC(ST_SCALAR_INT, MIN (*M1, M2));565 case 'U': VS_FUNC(ST_SCALAR_INT, MAX (*M1, M2));566 case '<': VS_FUNC(ST_SCALAR_INT, (*M1 < M2) ? 1 : 0);567 case '>': VS_FUNC(ST_SCALAR_INT, (*M1 > M2) ? 1 : 0);568 case '&': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 & (long long)M2));569 case '|': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 | (long long)M2));570 case 'E': VS_FUNC(ST_SCALAR_INT, (*M1 == M2) ? 1 : 0);571 case 'N': VS_FUNC(ST_SCALAR_INT, (*M1 != M2) ? 1 : 0);572 case 'L': VS_FUNC(ST_SCALAR_INT, (*M1 <= M2) ? 1 : 0);573 case 'G': VS_FUNC(ST_SCALAR_INT, (*M1 >= M2) ? 1 : 0);574 case 'A': VS_FUNC(ST_SCALAR_INT, (*M1 && M2) ? 1 : 0);575 case 'O': VS_FUNC(ST_SCALAR_INT, (*M1 || M2) ? 1 : 0);576 default:577 snprintf (line, 512, "error: op %c not defined!", op[0]);578 push_error (line);579 return (FALSE);580 }556 case '+': VS_FUNC(ST_SCALAR_INT, *M1 + M2); 557 case '-': VS_FUNC(ST_SCALAR_INT, *M1 - M2); 558 case '*': VS_FUNC(ST_SCALAR_INT, *M1 * M2); 559 case '/': VS_FUNC(ST_SCALAR_FLT, *M1 / (opihi_flt) M2); 560 case '%': VS_FUNC(ST_SCALAR_INT, (long long) *M1 % (long long) M2); 561 case '^': VS_FUNC(ST_SCALAR_FLT, pow (*M1, M2)); 562 case '@': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2)); 563 case 'a': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2)); 564 case 'D': VS_FUNC(ST_SCALAR_INT, MIN (*M1, M2)); 565 case 'U': VS_FUNC(ST_SCALAR_INT, MAX (*M1, M2)); 566 case '<': VS_FUNC(ST_SCALAR_INT, (*M1 < M2) ? 1 : 0); 567 case '>': VS_FUNC(ST_SCALAR_INT, (*M1 > M2) ? 1 : 0); 568 case '&': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 & (long long)M2)); 569 case '|': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 | (long long)M2)); 570 case 'E': VS_FUNC(ST_SCALAR_INT, (*M1 == M2) ? 1 : 0); 571 case 'N': VS_FUNC(ST_SCALAR_INT, (*M1 != M2) ? 1 : 0); 572 case 'L': VS_FUNC(ST_SCALAR_INT, (*M1 <= M2) ? 1 : 0); 573 case 'G': VS_FUNC(ST_SCALAR_INT, (*M1 >= M2) ? 1 : 0); 574 case 'A': VS_FUNC(ST_SCALAR_INT, (*M1 && M2) ? 1 : 0); 575 case 'O': VS_FUNC(ST_SCALAR_INT, (*M1 || M2) ? 1 : 0); 576 default: 577 snprintf (line, 512, "error: op %c not defined!", op[0]); 578 push_error (line); 579 return (FALSE); 580 } 581 581 # undef VS_FUNC 582 582 … … 584 584 585 585 if (V1[0].type == ST_VECTOR_TMP) { 586 free (V1[0].vector[0].elements.Ptr);587 free (V1[0].vector);588 }586 free (V1[0].vector[0].elements.Ptr); 587 free (V1[0].vector); 588 } 589 589 590 590 clear_stack (V1); … … 885 885 float *out = (float *)OUT[0].buffer[0].matrix.buffer; 886 886 887 # define MS_FUNC(OP) { \888 if (V2->type == ST_SCALAR_FLT) { \889 opihi_flt M2 = V2[0].FltValue; \887 # define MS_FUNC(OP) { \ 888 if (V2->type == ST_SCALAR_FLT) { \ 889 opihi_flt M2 = V2[0].FltValue; \ 890 890 for (i = 0; i < Npix; i++, out++, M1++) { \ 891 *out = OP; \892 } \893 break; \894 } \895 if (V2->type == ST_SCALAR_INT) { \896 opihi_int M2 = V2[0].IntValue; \891 *out = OP; \ 892 } \ 893 break; \ 894 } \ 895 if (V2->type == ST_SCALAR_INT) { \ 896 opihi_int M2 = V2[0].IntValue; \ 897 897 for (i = 0; i < Npix; i++, out++, M1++) { \ 898 *out = OP; \899 } \900 break; \901 } \898 *out = OP; \ 899 } \ 900 break; \ 901 } \ 902 902 } 903 903 … … 961 961 float *out = (float *)OUT[0].buffer[0].matrix.buffer; 962 962 963 # define SM_FUNC(OP) { \964 if (V1->type == ST_SCALAR_FLT) { \965 opihi_flt M1 = V1[0].FltValue; \963 # define SM_FUNC(OP) { \ 964 if (V1->type == ST_SCALAR_FLT) { \ 965 opihi_flt M1 = V1[0].FltValue; \ 966 966 for (i = 0; i < Npix; i++, out++, M2++) { \ 967 *out = OP; \968 } \969 break; \970 } \971 if (V1->type == ST_SCALAR_INT) { \972 opihi_int M1 = V1[0].IntValue; \967 *out = OP; \ 968 } \ 969 break; \ 970 } \ 971 if (V1->type == ST_SCALAR_INT) { \ 972 opihi_int M1 = V1[0].IntValue; \ 973 973 for (i = 0; i < Npix; i++, out++, M2++) { \ 974 *out = OP; \975 } \976 break; \977 } \974 *out = OP; \ 975 } \ 976 break; \ 977 } \ 978 978 } 979 979 … … 1023 1023 1024 1024 # define SS_FUNC(FTYPE,OP) { \ 1025 if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_FLT)) { \1025 if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_FLT)) { \ 1026 1026 opihi_flt M1 = V1[0].FltValue; \ 1027 1027 opihi_flt M2 = V2[0].FltValue; \ 1028 OUT[0].type = ST_SCALAR_FLT; \1028 OUT[0].type = ST_SCALAR_FLT; \ 1029 1029 OUT[0].FltValue = OP; \ 1030 1030 break; \ 1031 1031 } \ 1032 if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_INT)) { \1032 if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_INT)) { \ 1033 1033 opihi_flt M1 = V1[0].FltValue; \ 1034 1034 opihi_int M2 = V2[0].IntValue; \ 1035 OUT[0].type = ST_SCALAR_FLT; \1035 OUT[0].type = ST_SCALAR_FLT; \ 1036 1036 OUT[0].FltValue = OP; \ 1037 1037 break; \ 1038 1038 } \ 1039 if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_FLT)) { \1039 if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_FLT)) { \ 1040 1040 opihi_int M1 = V1[0].IntValue; \ 1041 1041 opihi_flt M2 = V2[0].FltValue; \ 1042 OUT[0].type = ST_SCALAR_FLT; \1042 OUT[0].type = ST_SCALAR_FLT; \ 1043 1043 OUT[0].FltValue = OP; \ 1044 1044 break; \ 1045 1045 } \ 1046 if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT)) { \1046 if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT)) { \ 1047 1047 opihi_int M1 = V1[0].IntValue; \ 1048 1048 opihi_int M2 = V2[0].IntValue; \ 1049 OUT[0].type = ST_SCALAR_FLT; \1049 OUT[0].type = ST_SCALAR_FLT; \ 1050 1050 OUT[0].FltValue = OP; \ 1051 1051 break; \ 1052 1052 } \ 1053 if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT)) { \1053 if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT)) { \ 1054 1054 opihi_int M1 = V1[0].IntValue; \ 1055 1055 opihi_int M2 = V2[0].IntValue; \ 1056 OUT[0].type = ST_SCALAR_INT; \1056 OUT[0].type = ST_SCALAR_INT; \ 1057 1057 OUT[0].IntValue = OP; \ 1058 1058 break; \ … … 1061 1061 1062 1062 switch (op[0]) { 1063 case '+': SS_FUNC(ST_SCALAR_INT, M1 + M2);1064 case '-': SS_FUNC(ST_SCALAR_INT, M1 - M2);1065 case '*': SS_FUNC(ST_SCALAR_INT, M1 * M2);1066 case '/': SS_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) M2);1067 case '%': SS_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) M2);1068 case '^': SS_FUNC(ST_SCALAR_FLT, pow (M1, M2));1069 case '@': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2));1070 case 'a': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2));1071 case 'D': SS_FUNC(ST_SCALAR_INT, MIN (M1, M2));1072 case 'U': SS_FUNC(ST_SCALAR_INT, MAX (M1, M2));1073 case '<': SS_FUNC(ST_SCALAR_INT, (M1 < M2) ? 1 : 0);1074 case '>': SS_FUNC(ST_SCALAR_INT, (M1 > M2) ? 1 : 0);1075 case '&': SS_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)M2));1076 case '|': SS_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)M2));1077 case 'E': SS_FUNC(ST_SCALAR_INT, (M1 == M2) ? 1 : 0);1078 case 'N': SS_FUNC(ST_SCALAR_INT, (M1 != M2) ? 1 : 0);1079 case 'L': SS_FUNC(ST_SCALAR_INT, (M1 <= M2) ? 1 : 0);1080 case 'G': SS_FUNC(ST_SCALAR_INT, (M1 >= M2) ? 1 : 0);1081 case 'A': SS_FUNC(ST_SCALAR_INT, (M1 && M2) ? 1 : 0);1082 case 'O': SS_FUNC(ST_SCALAR_INT, (M1 || M2) ? 1 : 0);1083 default:1084 snprintf (line, 512, "error: op %c not defined!", op[0]);1085 push_error (line);1086 return (FALSE);1087 }1063 case '+': SS_FUNC(ST_SCALAR_INT, M1 + M2); 1064 case '-': SS_FUNC(ST_SCALAR_INT, M1 - M2); 1065 case '*': SS_FUNC(ST_SCALAR_INT, M1 * M2); 1066 case '/': SS_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) M2); 1067 case '%': SS_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) M2); 1068 case '^': SS_FUNC(ST_SCALAR_FLT, pow (M1, M2)); 1069 case '@': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2)); 1070 case 'a': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2)); 1071 case 'D': SS_FUNC(ST_SCALAR_INT, MIN (M1, M2)); 1072 case 'U': SS_FUNC(ST_SCALAR_INT, MAX (M1, M2)); 1073 case '<': SS_FUNC(ST_SCALAR_INT, (M1 < M2) ? 1 : 0); 1074 case '>': SS_FUNC(ST_SCALAR_INT, (M1 > M2) ? 1 : 0); 1075 case '&': SS_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)M2)); 1076 case '|': SS_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)M2)); 1077 case 'E': SS_FUNC(ST_SCALAR_INT, (M1 == M2) ? 1 : 0); 1078 case 'N': SS_FUNC(ST_SCALAR_INT, (M1 != M2) ? 1 : 0); 1079 case 'L': SS_FUNC(ST_SCALAR_INT, (M1 <= M2) ? 1 : 0); 1080 case 'G': SS_FUNC(ST_SCALAR_INT, (M1 >= M2) ? 1 : 0); 1081 case 'A': SS_FUNC(ST_SCALAR_INT, (M1 && M2) ? 1 : 0); 1082 case 'O': SS_FUNC(ST_SCALAR_INT, (M1 || M2) ? 1 : 0); 1083 default: 1084 snprintf (line, 512, "error: op %c not defined!", op[0]); 1085 push_error (line); 1086 return (FALSE); 1087 } 1088 1088 # undef SS_FUNC 1089 1089 … … 1153 1153 } 1154 1154 1155 1156 1155 int S_unary (StackVar *OUT, StackVar *V1, char *op) { 1157 1156 1158 1157 char line[512]; // this is only used to report an error 1159 1158 1160 # define S_FUNC(OP,FTYPE) { \1161 if (V1->type == ST_SCALAR_FLT) { \1162 opihi_flt M1 = V1[0].FltValue; \1163 OUT[0].type = ST_SCALAR_FLT; \1164 OUT[0].FltValue = OP; \1165 clear_stack (V1); \1166 return (TRUE); \1167 } \1159 # define S_FUNC(OP,FTYPE) { \ 1160 if (V1->type == ST_SCALAR_FLT) { \ 1161 opihi_flt M1 = V1[0].FltValue; \ 1162 OUT[0].type = ST_SCALAR_FLT; \ 1163 OUT[0].FltValue = OP; \ 1164 clear_stack (V1); \ 1165 return (TRUE); \ 1166 } \ 1168 1167 if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT)) { \ 1169 opihi_int M1 = V1[0].IntValue; \1170 OUT[0].type = ST_SCALAR_FLT; \1171 OUT[0].FltValue = OP; \1172 clear_stack (V1); \1173 return (TRUE); \1174 } \1168 opihi_int M1 = V1[0].IntValue; \ 1169 OUT[0].type = ST_SCALAR_FLT; \ 1170 OUT[0].FltValue = OP; \ 1171 clear_stack (V1); \ 1172 return (TRUE); \ 1173 } \ 1175 1174 if ((FTYPE == ST_SCALAR_INT) && (V1->type == ST_SCALAR_INT)) { \ 1176 opihi_int M1 = V1[0].IntValue; \1177 OUT[0].type = ST_SCALAR_INT; \1178 OUT[0].IntValue = OP; \1179 clear_stack (V1); \1180 return (TRUE); \1181 } \1175 opihi_int M1 = V1[0].IntValue; \ 1176 OUT[0].type = ST_SCALAR_INT; \ 1177 OUT[0].IntValue = OP; \ 1178 clear_stack (V1); \ 1179 return (TRUE); \ 1180 } \ 1182 1181 } 1183 1182 … … 1211 1210 if (!strcmp (op, "dacos")) S_FUNC(acos (M1)*DEG_RAD, ST_SCALAR_FLT); 1212 1211 if (!strcmp (op, "datan")) S_FUNC(atan (M1)*DEG_RAD, ST_SCALAR_FLT); 1213 if (!strcmp (op, "rnd")) S_FUNC(M1*0.0 + drand48(), ST_SCALAR_FLT); 1212 if (!strcmp (op, "rnd")) S_FUNC(0.0*M1 + drand48(), ST_SCALAR_FLT); 1213 if (!strcmp (op, "drnd")) S_FUNC(0.0*M1 + drand48(), ST_SCALAR_FLT); 1214 if (!strcmp (op, "lrnd")) S_FUNC(0*M1 + lrand48(), ST_SCALAR_INT); 1215 if (!strcmp (op, "mrnd")) S_FUNC(0*M1 + mrand48(), ST_SCALAR_INT); 1214 1216 if (!strcmp (op, "not")) S_FUNC(!(M1), ST_SCALAR_INT); 1215 1217 if (!strcmp (op, "--")) S_FUNC(-1*M1, ST_SCALAR_INT); // NOTE: opihi_int is signed, … … 1235 1237 OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/ 1236 1238 1237 # define V_FUNC(OP,FTYPE) { \1238 if (V1->vector->type == OPIHI_FLT) { \1239 CopyVector (OUT[0].vector, V1[0].vector); \1240 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \1241 opihi_flt *out = OUT[0].vector[0].elements.Flt; \1242 for (i = 0; i < Nx; i++, out++, M1++) { \1243 *out = OP; \1244 } \1245 goto escape; \1246 } \1239 # define V_FUNC(OP,FTYPE) { \ 1240 if (V1->vector->type == OPIHI_FLT) { \ 1241 CopyVector (OUT[0].vector, V1[0].vector); \ 1242 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ 1243 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 1244 for (i = 0; i < Nx; i++, out++, M1++) { \ 1245 *out = OP; \ 1246 } \ 1247 goto escape; \ 1248 } \ 1247 1249 if ((V1->vector->type == OPIHI_INT) && (FTYPE == ST_SCALAR_FLT)) { \ 1248 MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT); \1249 opihi_int *M1 = V1[0].vector[0].elements.Int; \1250 opihi_flt *out = OUT[0].vector[0].elements.Flt; \1251 for (i = 0; i < Nx; i++, out++, M1++) { \1252 *out = OP; \1253 } \1254 goto escape; \1255 } \1250 MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT); \ 1251 opihi_int *M1 = V1[0].vector[0].elements.Int; \ 1252 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 1253 for (i = 0; i < Nx; i++, out++, M1++) { \ 1254 *out = OP; \ 1255 } \ 1256 goto escape; \ 1257 } \ 1256 1258 if ((V1->vector->type == OPIHI_INT) && (FTYPE == ST_SCALAR_INT)) { \ 1257 CopyVector (OUT[0].vector, V1[0].vector); \1258 opihi_int *M1 = V1[0].vector[0].elements.Int; \1259 opihi_int *out = OUT[0].vector[0].elements.Int; \1260 for (i = 0; i < Nx; i++, out++, M1++) { \1261 *out = OP; \1262 } \1263 goto escape; \1259 CopyVector (OUT[0].vector, V1[0].vector); \ 1260 opihi_int *M1 = V1[0].vector[0].elements.Int; \ 1261 opihi_int *out = OUT[0].vector[0].elements.Int; \ 1262 for (i = 0; i < Nx; i++, out++, M1++) { \ 1263 *out = OP; \ 1264 } \ 1265 goto escape; \ 1264 1266 } } 1265 1267 … … 1294 1296 if (!strcmp (op, "datan")) V_FUNC(atan(*M1)*DEG_RAD, ST_SCALAR_FLT); 1295 1297 if (!strcmp (op, "rnd")) V_FUNC(drand48(), ST_SCALAR_FLT); 1298 if (!strcmp (op, "drnd")) V_FUNC(drand48(), ST_SCALAR_FLT); 1299 if (!strcmp (op, "lrnd")) V_FUNC(lrand48(), ST_SCALAR_INT); 1300 if (!strcmp (op, "mrnd")) V_FUNC(mrand48(), ST_SCALAR_INT); 1296 1301 if (!strcmp (op, "ramp")) V_FUNC(i, ST_SCALAR_INT); 1297 1302 if (!strcmp (op, "zero")) V_FUNC(0, ST_SCALAR_INT); … … 1320 1325 } 1321 1326 1327 # define M_FUNC(OP) { for (i = 0; i < Npix; i++, out++, M1++) { *out = (OP); }} 1328 1322 1329 int M_unary (StackVar *OUT, StackVar *V1, char *op) { 1323 1330 … … 1337 1344 M1 = (float *) V1[0].buffer[0].matrix.buffer; 1338 1345 out = (float *)OUT[0].buffer[0].matrix.buffer; 1339 1346 1347 // if (!strcmp (op, "rint")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = nearbyint (*M1); }} 1348 1340 1349 if (!strcmp (op, "=")) { } 1341 if (!strcmp (op, "abs")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = fabs(*M1); }} 1342 if (!strcmp (op, "int")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = (opihi_flt)(long long)(*M1); }} 1343 1344 if (!strcmp (op, "floor")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = floor (*M1); }} 1345 if (!strcmp (op, "ceil")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = ceil (*M1); }} 1346 // if (!strcmp (op, "rint")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = nearbyint (*M1); }} 1347 1348 if (!strcmp (op, "exp")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = exp(*M1); }} 1349 if (!strcmp (op, "ten")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = pow(10.0,*M1); }} 1350 if (!strcmp (op, "log")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = log10(*M1); }} 1351 if (!strcmp (op, "ln")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = log(*M1); }} 1352 if (!strcmp (op, "sqrt")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = sqrt(*M1); }} 1353 if (!strcmp (op, "erf")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = erf(*M1); }} 1354 1355 if (!strcmp (op, "sinh")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = sinh(*M1); }} 1356 if (!strcmp (op, "cosh")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = cosh(*M1); }} 1357 if (!strcmp (op, "asinh")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = asinh(*M1); }} 1358 if (!strcmp (op, "acosh")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = acosh(*M1); }} 1359 if (!strcmp (op, "lgamma")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = lgamma(*M1); }} 1360 1361 if (!strcmp (op, "sin")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = sin(*M1); }} 1362 if (!strcmp (op, "cos")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = cos(*M1); }} 1363 if (!strcmp (op, "tan")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = tan(*M1); }} 1364 if (!strcmp (op, "dsin")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = sin(*M1*RAD_DEG); }} 1365 if (!strcmp (op, "dcos")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = cos(*M1*RAD_DEG); }} 1366 if (!strcmp (op, "dtan")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = tan(*M1*RAD_DEG); }} 1367 if (!strcmp (op, "asin")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = asin(*M1); }} 1368 if (!strcmp (op, "acos")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = acos(*M1); }} 1369 if (!strcmp (op, "atan")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = atan(*M1); }} 1370 if (!strcmp (op, "dasin")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = asin(*M1)*DEG_RAD; }} 1371 if (!strcmp (op, "dacos")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = acos(*M1)*DEG_RAD; }} 1372 if (!strcmp (op, "datan")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = atan(*M1)*DEG_RAD; }} 1373 if (!strcmp (op, "not")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = !(*M1); }} 1374 if (!strcmp (op, "--")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = -(*M1); }} 1375 if (!strcmp (op, "rnd")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = drand48(); }} 1376 if (!strcmp (op, "ramp")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = i; }} 1377 if (!strcmp (op, "zero")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = 0; }} 1378 if (!strcmp (op, "isinf")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = !finite(*M1); }} 1379 if (!strcmp (op, "isnan")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = isnan(*M1); }} 1350 if (!strcmp (op, "abs")) M_FUNC(fabs(*M1)); 1351 if (!strcmp (op, "int")) M_FUNC((opihi_flt)(long long)(*M1)); 1352 if (!strcmp (op, "floor")) M_FUNC(floor (*M1)); 1353 if (!strcmp (op, "ceil")) M_FUNC(ceil (*M1)); 1354 if (!strcmp (op, "exp")) M_FUNC(exp(*M1)); 1355 if (!strcmp (op, "ten")) M_FUNC(pow(10.0,*M1)); 1356 if (!strcmp (op, "log")) M_FUNC(log10(*M1)); 1357 if (!strcmp (op, "ln")) M_FUNC(log(*M1)); 1358 if (!strcmp (op, "sqrt")) M_FUNC(sqrt(*M1)); 1359 if (!strcmp (op, "erf")) M_FUNC(erf(*M1)); 1360 if (!strcmp (op, "sinh")) M_FUNC(sinh(*M1)); 1361 if (!strcmp (op, "cosh")) M_FUNC(cosh(*M1)); 1362 if (!strcmp (op, "asinh")) M_FUNC(asinh(*M1)); 1363 if (!strcmp (op, "acosh")) M_FUNC(acosh(*M1)); 1364 if (!strcmp (op, "lgamma")) M_FUNC(lgamma(*M1)); 1365 if (!strcmp (op, "sin")) M_FUNC(sin(*M1)); 1366 if (!strcmp (op, "cos")) M_FUNC(cos(*M1)); 1367 if (!strcmp (op, "tan")) M_FUNC(tan(*M1)); 1368 if (!strcmp (op, "dsin")) M_FUNC(sin(*M1*RAD_DEG)); 1369 if (!strcmp (op, "dcos")) M_FUNC(cos(*M1*RAD_DEG)); 1370 if (!strcmp (op, "dtan")) M_FUNC(tan(*M1*RAD_DEG)); 1371 if (!strcmp (op, "asin")) M_FUNC(asin(*M1)); 1372 if (!strcmp (op, "acos")) M_FUNC(acos(*M1)); 1373 if (!strcmp (op, "atan")) M_FUNC(atan(*M1)); 1374 if (!strcmp (op, "dasin")) M_FUNC(asin(*M1)*DEG_RAD); 1375 if (!strcmp (op, "dacos")) M_FUNC(acos(*M1)*DEG_RAD); 1376 if (!strcmp (op, "datan")) M_FUNC(atan(*M1)*DEG_RAD); 1377 if (!strcmp (op, "not")) M_FUNC(!(*M1)); 1378 if (!strcmp (op, "--")) M_FUNC(-(*M1)); 1379 if (!strcmp (op, "rnd")) M_FUNC(drand48()); 1380 if (!strcmp (op, "drnd")) M_FUNC(drand48()); 1381 if (!strcmp (op, "lrnd")) M_FUNC(lrand48()); 1382 if (!strcmp (op, "mrnd")) M_FUNC(mrand48()); 1383 if (!strcmp (op, "ramp")) M_FUNC(i); 1384 if (!strcmp (op, "zero")) M_FUNC(0); 1385 if (!strcmp (op, "isinf")) M_FUNC(!finite(*M1)); 1386 if (!strcmp (op, "isnan")) M_FUNC(isnan(*M1)); 1380 1387 1381 1388 /* xrm and yrm only make sense for 2D matrices. see special meaning for vectors */ -
trunk/Ohana/src/photdbc/include/photdbc.h
r37807 r38441 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 -
trunk/Ohana/src/photdbc/src/ConfigInit.c
r34749 r38441 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"); -
trunk/Ohana/src/photdbc/src/Shutdown_dvodist.c
r33655 r38441 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) { -
trunk/Ohana/src/photdbc/src/args.c
r37807 r38441 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 -
trunk/Ohana/src/photdbc/src/copy_images.c
r37807 r38441 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"); -
trunk/Ohana/src/photdbc/src/find_images.c
r37807 r38441 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"); -
trunk/Ohana/src/photdbc/src/flag_measures.c
r29001 r38441 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"); -
trunk/Ohana/src/photdbc/src/join_stars.c
r37807 r38441 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; -
trunk/Ohana/src/photdbc/src/make_subcatalog.c
r37045 r38441 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) -
trunk/Ohana/src/photdbc/src/photdbc_catalogs.c
r37807 r38441 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 -
trunk/Ohana/src/relastro/include/relastro.h
r38062 r38441 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 (); -
trunk/Ohana/src/relastro/src/BrightCatalog.c
r38062 r38441 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); -
trunk/Ohana/src/relastro/src/ImageTable.c
r36630 r38441 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); -
trunk/Ohana/src/relastro/src/UpdateObjectOffsets.c
r37807 r38441 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); -
trunk/Ohana/src/relastro/src/args.c
r37807 r38441 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 } -
trunk/Ohana/src/relastro/src/assign_images.c
r37807 r38441 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"); -
trunk/Ohana/src/relastro/src/bcatalog.c
r37807 r38441 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); -
trunk/Ohana/src/relastro/src/high_speed_catalogs.c
r35763 r38441 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 -
trunk/Ohana/src/relastro/src/high_speed_objects.c
r37807 r38441 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); -
trunk/Ohana/src/relastro/src/hpm_catalogs.c
r35763 r38441 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 -
trunk/Ohana/src/relastro/src/hpm_objects.c
r37807 r38441 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); -
trunk/Ohana/src/relastro/src/launch_region_hosts.c
r37807 r38441 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); -
trunk/Ohana/src/relastro/src/load_catalogs.c
r38062 r38441 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); -
trunk/Ohana/src/relastro/src/load_images.c
r37807 r38441 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"); -
trunk/Ohana/src/relastro/src/relastro_client.c
r37807 r38441 69 69 70 70 set_db (&db); 71 gfits_db_init (&db); 71 72 72 73 /* lock and load the image db table */ -
trunk/Ohana/src/relastro/src/relastro_images.c
r37807 r38441 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 */ -
trunk/Ohana/src/relastro/src/relastro_merge_source.c
r37038 r38441 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); -
trunk/Ohana/src/relastro/src/relastro_objects.c
r37807 r38441 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 -
trunk/Ohana/src/relastro/src/relastro_parallel_regions.c
r37807 r38441 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); -
trunk/Ohana/src/relphot/include/relphot.h
r38062 r38441 213 213 char *BOUNDARY_TREE; 214 214 215 int SET_MREL_VERSION;215 // XXX deprecate int SET_MREL_VERSION; 216 216 int IS_DIFF_DB; 217 217 … … 494 494 495 495 int launch_region_hosts (RegionHostTable *regionHosts); 496 int strextend (char *input, char *format,...);497 496 498 497 Image *ImageTableLoad(char *filename, off_t *nimage); -
trunk/Ohana/src/relphot/src/ImageTable.c
r37807 r38441 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"); … … 45 46 46 47 // setup image table format and lock 48 gfits_db_init (&db); 47 49 db.mode = dvo_catalog_catmode (CATMODE); 48 50 db.format = dvo_catalog_catformat (CATFORMAT); 51 49 52 status = dvo_image_lock (&db, filename, 60.0, LCK_XCLD); // shorter timeout? 50 53 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); -
trunk/Ohana/src/relphot/src/StarOps.c
r37116 r38441 128 128 129 129 for (i = 0; i < Ncatalog; i++) { 130 // pass == -1 for anything other than the final pass 131 switch (SET_MREL_VERSION) { 132 case 0: 133 setMrel_catalog (catalog, i, -1, flatcorr, &results, Nsecfilt); 134 break; 135 case 1: 136 setMrel_catalog_alt (catalog, i, -1, flatcorr, &results, Nsecfilt); 137 break; 138 default: 139 fprintf (stderr, "invalid setMrel version %d (use 0 or 1)\n", SET_MREL_VERSION); 140 exit (2); 141 } 130 setMrel_catalog_alt (catalog, i, -1, flatcorr, &results, Nsecfilt); 142 131 SetMrelInfoAccum (&summary, &results); 143 132 } … … 175 164 176 165 for (i = 0; i < Ncatalog; i++) { 177 switch (SET_MREL_VERSION) { 178 // case 0: 179 // setMrel_catalog (catalog, i, pass, flatcorr, &results, Nsecfilt); 180 // break; 181 case 1: 182 setMrel_catalog_alt (catalog, i, pass, flatcorr, &results, Nsecfilt); 183 break; 184 default: 185 fprintf (stderr, "invalid setMrel version %d (use 1)\n", SET_MREL_VERSION); 186 exit (2); 187 } 166 setMrel_catalog_alt (catalog, i, pass, flatcorr, &results, Nsecfilt); 188 167 SetMrelInfoAccum (&summary, &results); 189 168 } … … 293 272 294 273 // pass == -1 for anything other than the final pass 295 switch (SET_MREL_VERSION) { 296 case 0: 297 setMrel_catalog (catalog, i, -1, flatcorr, &results, Nsecfilt); 298 break; 299 case 1: 300 setMrel_catalog_alt (catalog, i, -1, flatcorr, &results, Nsecfilt); 301 break; 302 default: 303 fprintf (stderr, "invalid setMrel version %d (use 0 or 1)\n", SET_MREL_VERSION); 304 exit (2); 305 } 274 setMrel_catalog_alt (catalog, i, -1, flatcorr, &results, Nsecfilt); 306 275 SetMrelInfoAccum (&threadinfo->summary, &results); 307 276 } -
trunk/Ohana/src/relphot/src/args.c
r38062 r38441 76 76 } 77 77 78 SET_MREL_VERSION = 1;79 if ((N = get_argument (argc, argv, "-set-mrel-version"))) {80 remove_argument (N, &argc, argv);81 SET_MREL_VERSION = atof(argv[N]);82 remove_argument (N, &argc, argv);83 }84 85 78 VERBOSE = VERBOSE2 = FALSE; 86 79 if ((N = get_argument (argc, argv, "-v"))) { … … 529 522 } 530 523 531 SET_MREL_VERSION = 1;532 if ((N = get_argument (argc, argv, "-set-mrel-version"))) {533 remove_argument (N, &argc, argv);534 SET_MREL_VERSION = atof(argv[N]);535 remove_argument (N, &argc, argv);536 }537 538 524 VERBOSE = VERBOSE2 = FALSE; 539 525 if ((N = get_argument (argc, argv, "-v"))) { -
trunk/Ohana/src/relphot/src/assign_images.c
r37807 r38441 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"); -
trunk/Ohana/src/relphot/src/bcatalog.c
r37116 r38441 245 245 subcatalog[0].Nmeasure = Nmeasure; 246 246 subcatalog[0].Nsecfilt = catalog[0].Nsecfilt; 247 subcatalog[0].Nsecf _mem = Naverage * catalog[0].Nsecfilt;247 subcatalog[0].Nsecfilt_mem = Naverage * catalog[0].Nsecfilt; 248 248 249 249 if (VERBOSE) { … … 368 368 subcatalog[0].Nmeasure = Nmeasure; 369 369 subcatalog[0].Nsecfilt = oldcatalog[0].Nsecfilt; 370 subcatalog[0].Nsecf _mem = Naverage * oldcatalog[0].Nsecfilt;370 subcatalog[0].Nsecfilt_mem = Naverage * oldcatalog[0].Nsecfilt; 371 371 372 372 return (TRUE); … … 461 461 subcatalog[0].Nmeasure = Nmeasure; 462 462 subcatalog[0].Nsecfilt = catalog[0].Nsecfilt; 463 subcatalog[0].Nsecf _mem = Naverage * catalog[0].Nsecfilt;463 subcatalog[0].Nsecfilt_mem = Naverage * catalog[0].Nsecfilt; 464 464 465 465 return (TRUE); -
trunk/Ohana/src/relphot/src/launch_region_hosts.c
r37037 r38441 1 1 # include "relphot.h" 2 2 # define DEBUG 0 3 4 int strextend (char *input, char *format,...) {5 6 char tmpextra[1024], tmpline[1024];7 va_list argp;8 9 va_start (argp, format);10 vsnprintf (tmpextra, 1024, format, argp);11 snprintf (tmpline, 1024, "%s %s", input, tmpextra);12 strcpy (input, tmpline);13 14 return TRUE;15 }16 3 17 4 int launch_region_hosts (RegionHostTable *regionHosts) { … … 54 41 ImageTableSave (filename, host->image, host->Nimage); 55 42 56 char command[1024];57 s nprintf (command, 1024, "relphot %s", PhotcodeList);58 strextend ( command, "-parallel-images %s", filename);59 strextend ( command, "-region-hosts %s", REGION_FILE);60 strextend ( command, "-region-hostID %d", host->hostID);61 strextend ( command, "-D CATDIR %s", CATDIR);62 strextend ( command, "-region %f %f %f %f", host->RminCat, host->RmaxCat, host->DminCat, host->DmaxCat);63 strextend ( command, "-statmode %s", STATMODE);64 strextend ( command, "-D CAMERA %s", CAMERA);65 strextend ( command, "-D STAR_TOOFEW %d", STAR_TOOFEW);66 strextend ( command, "-minerror %f", MIN_ERROR);67 strextend ( command, "-cloud-limit %f", CLOUD_TOLERANCE);43 char *command = NULL; 44 strextend (&command, "relphot %s", PhotcodeList); 45 strextend (&command, "-parallel-images %s", filename); 46 strextend (&command, "-region-hosts %s", REGION_FILE); 47 strextend (&command, "-region-hostID %d", host->hostID); 48 strextend (&command, "-D CATDIR %s", CATDIR); 49 strextend (&command, "-region %f %f %f %f", host->RminCat, host->RmaxCat, host->DminCat, host->DmaxCat); 50 strextend (&command, "-statmode %s", STATMODE); 51 strextend (&command, "-D CAMERA %s", CAMERA); 52 strextend (&command, "-D STAR_TOOFEW %d", STAR_TOOFEW); 53 strextend (&command, "-minerror %f", MIN_ERROR); 54 strextend (&command, "-cloud-limit %f", CLOUD_TOLERANCE); 68 55 69 if (VERBOSE) strextend ( command, "-v");70 if (VERBOSE2) strextend ( command, "-vv");71 if (RESET) strextend ( command, "-reset");72 if (RESET_ZEROPTS) strextend ( command, "-reset-zpts");73 if (!KEEP_UBERCAL) strextend ( command, "-reset-ubercal");74 if (DophotSelect) strextend ( command, "-dophot %d", DophotValue);75 if (ImagSelect) strextend ( command, "-instmag %f %f", ImagMin, ImagMax);76 if (MaxDensityUse) strextend ( command, "-max-density %f", MaxDensityValue);77 if (SyntheticPhotometry) strextend ( command, "-synthphot");56 if (VERBOSE) strextend (&command, "-v"); 57 if (VERBOSE2) strextend (&command, "-vv"); 58 if (RESET) strextend (&command, "-reset"); 59 if (RESET_ZEROPTS) strextend (&command, "-reset-zpts"); 60 if (!KEEP_UBERCAL) strextend (&command, "-reset-ubercal"); 61 if (DophotSelect) strextend (&command, "-dophot %d", DophotValue); 62 if (ImagSelect) strextend (&command, "-instmag %f %f", ImagMin, ImagMax); 63 if (MaxDensityUse) strextend (&command, "-max-density %f", MaxDensityValue); 64 if (SyntheticPhotometry) strextend (&command, "-synthphot"); 78 65 79 if (UPDATE) strextend ( command, "-update");80 if (MOSAIC_ZEROPT) strextend ( command, "-mosaic");81 if (FREEZE_IMAGES) strextend ( command, "-imfreeze");82 if (FREEZE_MOSAICS) strextend ( command, "-mosfreeze");83 if (PARALLEL) strextend ( command, "-parallel");84 if (PARALLEL_MANUAL) strextend ( command, "-parallel-manual");85 if (PARALLEL_SERIAL) strextend ( command, "-parallel-serial");66 if (UPDATE) strextend (&command, "-update"); 67 if (MOSAIC_ZEROPT) strextend (&command, "-mosaic"); 68 if (FREEZE_IMAGES) strextend (&command, "-imfreeze"); 69 if (FREEZE_MOSAICS) strextend (&command, "-mosfreeze"); 70 if (PARALLEL) strextend (&command, "-parallel"); 71 if (PARALLEL_MANUAL) strextend (&command, "-parallel-manual"); 72 if (PARALLEL_SERIAL) strextend (&command, "-parallel-serial"); 86 73 87 74 // XXX deprecate this if we are happy with the new version 88 if (SET_MREL_VERSION != 1) strextend (command, "-set-mrel-version %d", SET_MREL_VERSION);75 // if (SET_MREL_VERSION != 1) strextend (command, "-set-mrel-version %d", SET_MREL_VERSION); 89 76 90 77 fprintf (stderr, "command: %s\n", command); -
trunk/Ohana/src/relphot/src/load_catalogs.c
r37037 r38441 34 34 // XXX keep in mind that not all catalogs are loaded 35 35 dvo_catalog_init (&catalog[i], TRUE); 36 dvo_catalog_init (&tcatalog, TRUE); 36 37 37 38 // does this host ID match the desired location for the table? … … 41 42 char hostfile[1024]; 42 43 snprintf (hostfile, 1024, "%s/%s.cpt", hostpath, skylist[0].regions[i]->name); 43 tcatalog.filename = hostID ? hostfile : skylist[0].filename[i]; 44 45 tcatalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 46 tcatalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 47 tcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF; // don't need to load all data at this point 48 tcatalog.Nsecfilt = GetPhotcodeNsecfilt (); // set the desired number in case we need to create the catalog 44 tcatalog.filename = hostID ? hostfile : skylist[0].filename[i]; 45 tcatalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; // don't need to load all data at this point 46 tcatalog.Nsecfilt = GetPhotcodeNsecfilt (); // set the desired number in case we need to create the catalog 47 48 // tcatalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 49 // tcatalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 50 // tcatalog.catcompress = dvo_catalog_catcompress (CATCOMPRESS); // set the default catcompress from config data 49 51 50 52 if (!dvo_catalog_open (&tcatalog, skylist[0].regions[i], VERBOSE2, "r")) { … … 52 54 exit (1); 53 55 } 54 if (!tcatalog.Nave s_disk) {56 if (!tcatalog.Naverage_disk) { 55 57 if (VERBOSE2) { fprintf (stderr, "no data in %s, skipping\n", tcatalog.filename); } 56 58 dvo_catalog_unlock (&tcatalog); … … 153 155 // MaxDensityUse, MaxDensityValue 154 156 155 char command[1024];156 s nprintf (command, 1024, "relphot_client %s -load %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -D CAMERA %s -D MAG_LIM %f -D SIGMA_LIM %f",157 char *command = NULL; 158 strextend (&command, "relphot_client %s -load %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -D CAMERA %s -D MAG_LIM %f -D SIGMA_LIM %f", 157 159 PhotcodeList, table->hosts[i].results, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, CAMERA, MAG_LIM, SIGMA_LIM); 158 160 159 char tmpline[1024]; 160 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 161 if (VERBOSE2) { snprintf (tmpline, 1024, "%s -vv", command); strcpy (command, tmpline); } 162 if (RESET) { snprintf (tmpline, 1024, "%s -reset", command); strcpy (command, tmpline); } 163 if (RESET_ZEROPTS) { snprintf (tmpline, 1024, "%s -reset-zpts", command); strcpy (command, tmpline); } 164 if (!KEEP_UBERCAL) { snprintf (tmpline, 1024, "%s -reset-ubercal", command); strcpy (command, tmpline); } 165 if (DophotSelect) { snprintf (tmpline, 1024, "%s -dophot %d", command, DophotValue); strcpy (command, tmpline); } 166 if (ImagSelect) { snprintf (tmpline, 1024, "%s -instmag %f %f", command, ImagMin, ImagMax); strcpy (command, tmpline); } 167 if (MaxDensityUse) { snprintf (tmpline, 1024, "%s -max-density %f", command, MaxDensityValue); strcpy (command, tmpline); } 168 if (SyntheticPhotometry) { snprintf (tmpline, 1024, "%s -synthphot", command); strcpy (command, tmpline); } 161 if (VERBOSE) { strextend (&command, "-v"); } 162 if (VERBOSE2) { strextend (&command, "-vv"); } 163 if (RESET) { strextend (&command, "-reset"); } 164 if (RESET_ZEROPTS) { strextend (&command, "-reset-zpts"); } 165 if (!KEEP_UBERCAL) { strextend (&command, "-reset-ubercal"); } 166 if (DophotSelect) { strextend (&command, "-dophot %d", DophotValue); } 167 if (ImagSelect) { strextend (&command, "-instmag %f %f", ImagMin, ImagMax); } 168 if (MaxDensityUse) { strextend (&command, "-max-density %f", MaxDensityValue); } 169 if (SyntheticPhotometry) { strextend (&command, "-synthphot"); } 169 170 170 171 if (TimeSelect) { 171 172 char *tstart = ohana_sec_to_date (TSTART); 172 173 char *tstop = ohana_sec_to_date (TSTOP); 173 s nprintf (tmpline, 1024, "%s -time %s %s", command, tstart, tstop);174 strextend (&command, "-time %s %s", tstart, tstop); 174 175 free (tstart); 175 176 free (tstop); 176 strcpy (command, tmpline);177 177 } 178 178 -
trunk/Ohana/src/relphot/src/load_images.c
r37807 r38441 21 21 // convert database table to internal structure (binary to Image) 22 22 // 'image' points to the same memory as db->ftable->buffer 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"); -
trunk/Ohana/src/relphot/src/reload_catalogs.c
r37907 r38441 56 56 TIMESTAMP(time1); 57 57 58 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 59 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 60 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 61 catalog.Nsecfilt = GetPhotcodeNsecfilt (); // set the desired number in case we need to create the catalog 58 // catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 59 // catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 60 // catalog.catcompress = dvo_catalog_catcompress (CATCOMPRESS); // set the default catcompress from config data 61 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 62 catalog.Nsecfilt = GetPhotcodeNsecfilt (); // set the desired number in case we need to create the catalog 62 63 63 64 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) { … … 65 66 exit (1); 66 67 } 67 if (VERBOSE && (catalog.Nave s_disk == 0)) {68 if (VERBOSE && (catalog.Naverage_disk == 0)) { 68 69 fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 69 70 dvo_catalog_unlock (&catalog); … … 170 171 171 172 int Ngroups; 172 HostTableGroup *groups = HostTableGroups (table, &Ngroups);173 HostTableGroup *groups = HostTableGroupsUniqueMachines (table, &Ngroups); 173 174 // split the table into Ngroups, each with a unique set of machines (this avoids overloading the remote host machines) 174 175 … … 206 207 group->hosts[i][0].pathname = tmppath; 207 208 208 char command[1024]; 209 snprintf (command, 1024, "relphot_client %s -update-catalogs %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -D CAMERA %s -D STAR_TOOFEW %d -minerror %f", 210 PhotcodeList, imageFile, group->hosts[i][0].hostID, CATDIR, group->hosts[i][0].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, CAMERA, STAR_TOOFEW, MIN_ERROR); 209 char *command = NULL; 210 strextend (&command, "relphot_client %s -update-catalogs %s", PhotcodeList, imageFile); 211 strextend (&command, "-hostID %d -D CATDIR %s -hostdir %s", group->hosts[i][0].hostID, CATDIR, group->hosts[i][0].pathname); 212 strextend (&command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 213 strextend (&command, "-statmode %s", STATMODE); 214 strextend (&command, "-D CAMERA %s", CAMERA); 215 strextend (&command, "-D STAR_TOOFEW %d -minerror %f", STAR_TOOFEW, MIN_ERROR); 211 216 212 217 // options & configs which affect relphot_client -update-catalogs … … 220 225 // MIN_ERROR 221 226 222 char tmpline[1024]; 223 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 224 if (VERBOSE2) { snprintf (tmpline, 1024, "%s -vv", command); strcpy (command, tmpline); } 225 if (RESET) { snprintf (tmpline, 1024, "%s -reset", command); strcpy (command, tmpline); } 226 if (RESET_ZEROPTS) { snprintf (tmpline, 1024, "%s -reset-zpts", command); strcpy (command, tmpline); } 227 if (UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); } 228 if (IS_DIFF_DB) { snprintf (tmpline, 1024, "%s -is-diff-db", command); strcpy (command, tmpline); } 229 if (!KEEP_UBERCAL) { snprintf (tmpline, 1024, "%s -reset-ubercal", command); strcpy (command, tmpline); } 230 if (UPDATE_CATFORMAT) { snprintf (tmpline, 1024, "%s -update-catformat %s", command, UPDATE_CATFORMAT); strcpy (command, tmpline); } 231 if (BOUNDARY_TREE) { snprintf (tmpline, 1024, "%s -boundary-tree %s", command, BOUNDARY_TREE); strcpy (command, tmpline); } 232 if (SET_MREL_VERSION != 1) { snprintf (tmpline, 1024, "%s -set-mrel-version %d", command, SET_MREL_VERSION); strcpy (command, tmpline); } 233 if (AreaSelect) { snprintf (tmpline, 1024, "%s -area %f %f %f %f", command, AreaXmin, AreaXmax, AreaYmin, AreaYmax); strcpy (command, tmpline); } 227 if (VERBOSE) { strextend (&command, "-v"); } 228 if (VERBOSE2) { strextend (&command, "-vv"); } 229 if (RESET) { strextend (&command, "-reset"); } 230 if (RESET_ZEROPTS) { strextend (&command, "-reset-zpts"); } 231 if (UPDATE) { strextend (&command, "-update"); } 232 if (IS_DIFF_DB) { strextend (&command, "-is-diff-db"); } 233 if (!KEEP_UBERCAL) { strextend (&command, "-reset-ubercal"); } 234 if (UPDATE_CATFORMAT) { strextend (&command, "-update-catformat %s", UPDATE_CATFORMAT); } 235 if (BOUNDARY_TREE) { strextend (&command, "-boundary-tree %s", BOUNDARY_TREE); } 236 237 // deprecate 238 // if (SET_MREL_VERSION != 1) { snprintf (tmpline, 1024, "%s -set-mrel-version %d", SET_MREL_VERSION); } // XXXX deprecate this... 239 240 if (AreaSelect) { strextend (&command, "-area %f %f %f %f", AreaXmin, AreaXmax, AreaYmin, AreaYmax); } 234 241 if (TimeSelect) { 235 242 char *tstart = ohana_sec_to_date (TSTART); 236 243 char *tstop = ohana_sec_to_date (TSTOP); 237 s nprintf (tmpline, 1024, "%s -time %s %s", command, tstart, tstop);244 strextend (&command, "-time %s %s", tstart, tstop); 238 245 free (tstart); 239 246 free (tstop); 240 strcpy (command, tmpline);241 247 } 242 248 -
trunk/Ohana/src/relphot/src/relphot_images.c
r37037 r38441 18 18 /* register database handle with shutdown procedure */ 19 19 set_db (&db); 20 gfits_db_init (&db); 20 21 db.mode = dvo_catalog_catmode (CATMODE); 21 22 db.format = dvo_catalog_catformat (CATFORMAT); … … 185 186 // convert database table to internal structure (binary to Image) 186 187 // 'image' points to the same memory as db->ftable->buffer 187 image = gfits_table_get_Image (&db.ftable, &Nimage, &db.s wapped);188 image = gfits_table_get_Image (&db.ftable, &Nimage, &db.scaledValue, &db.nativeOrder); 188 189 if (!image) { 189 190 fprintf (stderr, "ERROR: failed to read images\n"); -
trunk/Ohana/src/relphot/src/relphot_objects.c
r37807 r38441 39 39 char hostfile[1024]; 40 40 snprintf (hostfile, 1024, "%s/%s.cpt", hostpath, skylist[0].regions[i]->name); 41 catalog.filename = hostID ? hostfile : skylist[0].filename[i]; 42 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 43 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 44 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 45 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 41 catalog.filename = hostID ? hostfile : skylist[0].filename[i]; 42 // catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 43 // catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 44 // catalog.catcompress = dvo_catalog_catcompress (CATCOMPRESS); // set the default catcompress from config data 45 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 46 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 46 47 47 48 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) { … … 49 50 exit (1); 50 51 } 51 if (!catalog.Nave s_disk) {52 if (!catalog.Naverage_disk) { 52 53 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 53 54 dvo_catalog_unlock (&catalog); … … 153 154 // MaxDensityUse, MaxDensityValue 154 155 155 char command[1024];156 s nprintf (command, 1024, "relphot_client -update-objects -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -D CAMERA %s -D STAR_TOOFEW %d -minerror %f",156 char *command = NULL; 157 strextend (&command, "relphot_client -update-objects -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -D CAMERA %s -D STAR_TOOFEW %d -minerror %f", 157 158 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, CAMERA, STAR_TOOFEW, MIN_ERROR); 158 159 159 char tmpline[1024];160 if (VERBOSE ) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); }161 if ( VERBOSE2) { snprintf (tmpline, 1024, "%s -vv", command); strcpy (command, tmpline); }162 if (RESET ) { snprintf (tmpline, 1024, "%s -reset", command); strcpy (command, tmpline); }163 if ( RESET_ZEROPTS) { snprintf (tmpline, 1024, "%s -reset-zpts", command); strcpy (command, tmpline); }164 if ( UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); }165 if (!KEEP_UBERCAL) { snprintf (tmpline, 1024, "%s -reset-ubercal", command); strcpy (command, tmpline); } 166 if (SET_MREL_VERSION != 1) { snprintf (tmpline, 1024, "%s -set-mrel-version %d", command, SET_MREL_VERSION); strcpy (command, tmpline); }160 if (VERBOSE) { strextend (&command, "-v"); } 161 if (VERBOSE2) { strextend (&command, "-vv"); } 162 if (RESET) { strextend (&command, "-reset"); } 163 if (RESET_ZEROPTS) { strextend (&command, "-reset-zpts"); } 164 if (UPDATE) { strextend (&command, "-update"); } 165 if (!KEEP_UBERCAL) { strextend (&command, "-reset-ubercal"); } 166 167 // if (SET_MREL_VERSION != 1) { strextend (&command, "-set-mrel-version %d", SET_MREL_VERSION); } 167 168 168 169 fprintf (stderr, "command: %s\n", command); -
trunk/Ohana/src/relphot/src/relphot_parallel_regions.c
r37807 r38441 23 23 // register database handle with shutdown procedure 24 24 set_db (&db); 25 gfits_db_init (&db); 25 26 db.mode = dvo_catalog_catmode (CATMODE); 26 27 db.format = dvo_catalog_catformat (CATFORMAT); -
trunk/Ohana/src/relphot/src/relphot_synthphot.c
r38062 r38441 40 40 char hostfile[1024]; 41 41 snprintf (hostfile, 1024, "%s/%s.cpt", hostpath, skylist[0].regions[i]->name); 42 catalog.filename = hostID ? hostfile : skylist[0].filename[i]; 43 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 44 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 45 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF; 46 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 42 catalog.filename = hostID ? hostfile : skylist[0].filename[i]; 43 // catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 44 // catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 45 // catalog.catcompress = dvo_catalog_catcompress (CATCOMPRESS); // set the default catcompress from config data 46 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 47 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 47 48 48 49 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) { … … 50 51 exit (1); 51 52 } 52 if (!catalog.Nave s_disk) {53 if (!catalog.Naverage_disk) { 53 54 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 54 55 dvo_catalog_unlock (&catalog); … … 109 110 // VERBOSE, VERBOSE2 110 111 111 char command[1024]; 112 snprintf (command, 1024, "relphot_client -synthphot_means %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f", 113 SYNTH_ZERO_POINTS, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 112 char *command = NULL; 113 strextend (&command, "relphot_client -synthphot_means %s", SYNTH_ZERO_POINTS); 114 strextend (&command, "-hostID %d -D CATDIR %s -hostdir %s", table->hosts[i].hostID, CATDIR, table->hosts[i].pathname); 115 strextend (&command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 114 116 115 char tmpline[1024]; 116 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 117 if (VERBOSE2) { snprintf (tmpline, 1024, "%s -vv", command); strcpy (command, tmpline); } 118 if (UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); } 117 if (VERBOSE) { strextend (&command, "-v"); } 118 if (VERBOSE2) { strextend (&command, "-vv"); } 119 if (UPDATE) { strextend (&command, "-update"); } 119 120 120 121 fprintf (stderr, "command: %s\n", command); -
trunk/Ohana/src/tools/src/fields.c
r27491 r38441 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 } -
trunk/Ohana/src/uniphot/src/find_image_sgroups.c
r37807 r38441 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"); -
trunk/Ohana/src/uniphot/src/find_image_tgroups.c
r31160 r38441 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"); -
trunk/Ohana/src/uniphot/src/fiximids.c
r35764 r38441 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); -
trunk/Ohana/src/uniphot/src/fixstkids.c
r35764 r38441 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); -
trunk/Ohana/src/uniphot/src/load_images.c
r33654 r38441 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"); -
trunk/Ohana/src/uniphot/src/load_images_fiximids.c
r37043 r38441 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"); -
trunk/Ohana/src/uniphot/src/load_images_fixstkids.c
r37043 r38441 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"); -
trunk/Ohana/src/uniphot/src/load_images_setphot.c
r33654 r38441 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"); -
trunk/Ohana/src/uniphot/src/load_images_setposangle.c
r34749 r38441 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"); -
trunk/Ohana/src/uniphot/src/setfwhm.c
r33654 r38441 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); -
trunk/Ohana/src/uniphot/src/setphot.c
r33963 r38441 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); -
trunk/Ohana/src/uniphot/src/setposangle.c
r34749 r38441 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); -
trunk/Ohana/src/uniphot/src/subset_images.c
r31160 r38441 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"); -
trunk/Ohana/src/uniphot/src/uniphot.c
r33654 r38441 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); -
trunk/Ohana/src/uniphot/src/update_dvo_ckids.c
r35764 r38441 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); -
trunk/Ohana/src/uniphot/src/update_dvo_fiximids.c
r35764 r38441 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); -
trunk/Ohana/src/uniphot/src/update_dvo_fixstkids.c
r35764 r38441 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); -
trunk/Ohana/src/uniphot/src/update_dvo_setastrom.c
r38062 r38441 42 42 catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs 43 43 catalog.catmode = DVO_MODE_UNDEF; // not needed since we skip empty catalogs 44 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; 45 45 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 46 46 … … 49 49 exit (1); 50 50 } 51 if (!catalog.Nave s_disk) {51 if (!catalog.Naverage_disk) { 52 52 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 53 53 dvo_catalog_unlock (&catalog); … … 95 95 table->hosts[i].pathname = tmppath; 96 96 97 char command[1024];98 s nprintf (command, 1024, "setastrom_client -hostID %d -catdir %s -hostdir %s -region %f %f %f %f",97 char *command = NULL; 98 strextend (&command, "setastrom_client -hostID %d -catdir %s -hostdir %s -region %f %f %f %f", 99 99 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, 100 100 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 101 101 102 char tmpline[1024]; 103 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 104 if (UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); } 105 if (KH_FILE) { snprintf (tmpline, 1024, "%s -KH %s", command, KH_FILE); strcpy (command, tmpline); } 106 if (DCR_FILE) { snprintf (tmpline, 1024, "%s -DCR %s", command, DCR_FILE); strcpy (command, tmpline); } 107 if (CAM_FILE) { snprintf (tmpline, 1024, "%s -CAM %s", command, CAM_FILE); strcpy (command, tmpline); } 108 if (UPDATE_CATFORMAT) { snprintf (tmpline, 1024, "%s -update-catformat %s", command, UPDATE_CATFORMAT); strcpy (command, tmpline); } 109 110 if (KH_RESET) { snprintf (tmpline, 1024, "%s -KH-reset", command); strcpy (command, tmpline); } 111 if (DCR_RESET) { snprintf (tmpline, 1024, "%s -DCR-reset", command); strcpy (command, tmpline); } 112 if (CAM_RESET) { snprintf (tmpline, 1024, "%s -CAM-reset", command); strcpy (command, tmpline); } 102 if (VERBOSE) { strextend (&command, "-v"); } 103 if (UPDATE) { strextend (&command, "-update"); } 104 if (KH_FILE) { strextend (&command, "-KH %s", KH_FILE); } 105 if (DCR_FILE) { strextend (&command, "-DCR %s", DCR_FILE); } 106 if (CAM_FILE) { strextend (&command, "-CAM %s", CAM_FILE); } 107 if (UPDATE_CATFORMAT) { strextend (&command, "-update-catformat %s", UPDATE_CATFORMAT); } 108 if (KH_RESET) { strextend (&command, "-KH-reset"); } 109 if (DCR_RESET) { strextend (&command, "-DCR-reset"); } 110 if (CAM_RESET) { strextend (&command, "-CAM-reset"); } 113 111 114 112 fprintf (stderr, "command: %s\n", command); -
trunk/Ohana/src/uniphot/src/update_dvo_setgalmodel.c
r37807 r38441 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; -
trunk/Ohana/src/uniphot/src/update_dvo_setphot.c
r38263 r38441 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 char tmpline[1024]; 118 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 119 if (RESET) { snprintf (tmpline, 1024, "%s -reset", command); strcpy (command, tmpline); } 120 if (UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); } 121 if (UBERCAL) { snprintf (tmpline, 1024, "%s -ubercal", command); strcpy (command, tmpline); } 117 if (VERBOSE) { strextend (&command, "-v"); } 118 if (RESET) { strextend (&command, "-reset"); } 119 if (UPDATE) { strextend (&command, "-update"); } 120 if (UBERCAL) { strextend (&command, "-ubercal"); } 122 121 123 122 fprintf (stderr, "command: %s\n", command); -
trunk/Ohana/src/uniphot/src/update_dvo_setposangle.c
r35103 r38441 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; -
trunk/Ohana/src/uniphot/src/update_dvo_uniphot.c
r37807 r38441 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.
