Changeset 37822
- Timestamp:
- Jan 12, 2015, 12:29:24 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-pv3-20140717-merge/Ohana
- Files:
-
- 1 deleted
- 345 edited
- 143 copied
-
. (modified) (1 prop)
-
Makefile.in (modified) (1 diff)
-
configure.tcsh (modified) (2 diffs)
-
src/addstar/Makefile (modified) (7 diffs)
-
src/addstar/include/WISE.h (modified) (1 diff)
-
src/addstar/include/addstar.h (modified) (5 diffs)
-
src/addstar/include/loadICRF.h (copied) (copied from trunk/Ohana/src/addstar/include/loadICRF.h )
-
src/addstar/include/loadstarpar.h (copied) (copied from trunk/Ohana/src/addstar/include/loadstarpar.h )
-
src/addstar/src/BoundaryTreeIO.c (modified) (1 diff)
-
src/addstar/src/LoadData.c (modified) (1 diff)
-
src/addstar/src/LoadDataPMM.c (modified) (2 diffs)
-
src/addstar/src/LoadStars.c (modified) (1 diff)
-
src/addstar/src/MatchHeaders.c (modified) (1 diff)
-
src/addstar/src/NewImage.c (modified) (1 diff)
-
src/addstar/src/ReadImageHeader.c (modified) (3 diffs)
-
src/addstar/src/ReadStarsFITS.c (modified) (38 diffs)
-
src/addstar/src/ReadStarsSDSS.c (modified) (1 diff)
-
src/addstar/src/UpdateDatabase_Image.c (modified) (1 diff)
-
src/addstar/src/addstar.c (modified) (9 diffs)
-
src/addstar/src/addstar_client.c (modified) (1 diff)
-
src/addstar/src/args.c (modified) (4 diffs)
-
src/addstar/src/args_client.c (modified) (1 diff)
-
src/addstar/src/args_loadICRF.c (copied) (copied from trunk/Ohana/src/addstar/src/args_loadICRF.c )
-
src/addstar/src/args_loadstarpar.c (copied) (copied from trunk/Ohana/src/addstar/src/args_loadstarpar.c )
-
src/addstar/src/args_loadwise.c (modified) (1 diff)
-
src/addstar/src/args_parallel_client.c (modified) (2 diffs)
-
src/addstar/src/build_links.c (modified) (12 diffs)
-
src/addstar/src/coord_transforms.c (copied) (copied from trunk/Ohana/src/addstar/src/coord_transforms.c )
-
src/addstar/src/fakeimage.c (modified) (5 diffs)
-
src/addstar/src/find_matches.c (modified) (2 diffs)
-
src/addstar/src/find_matches_ICRF.c (copied) (copied from trunk/Ohana/src/addstar/src/find_matches_ICRF.c )
-
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) (1 diff)
-
src/addstar/src/find_matches_starpar.c (copied) (copied from trunk/Ohana/src/addstar/src/find_matches_starpar.c )
-
src/addstar/src/find_missing.c (modified) (2 diffs)
-
src/addstar/src/findskycell.c (modified) (6 diffs)
-
src/addstar/src/loadICRF.c (copied) (copied from trunk/Ohana/src/addstar/src/loadICRF.c )
-
src/addstar/src/loadICRF_catalog.c (copied) (copied from trunk/Ohana/src/addstar/src/loadICRF_catalog.c )
-
src/addstar/src/loadICRF_client.c (copied) (copied from trunk/Ohana/src/addstar/src/loadICRF_client.c )
-
src/addstar/src/loadICRF_io.c (copied) (copied from trunk/Ohana/src/addstar/src/loadICRF_io.c )
-
src/addstar/src/loadICRF_make_subset.c (copied) (copied from trunk/Ohana/src/addstar/src/loadICRF_make_subset.c )
-
src/addstar/src/loadICRF_readstars.c (copied) (copied from trunk/Ohana/src/addstar/src/loadICRF_readstars.c )
-
src/addstar/src/loadICRF_remote_hosts.c (copied) (copied from trunk/Ohana/src/addstar/src/loadICRF_remote_hosts.c )
-
src/addstar/src/loadICRF_save_remote.c (copied) (copied from trunk/Ohana/src/addstar/src/loadICRF_save_remote.c )
-
src/addstar/src/loadICRF_table.c (copied) (copied from trunk/Ohana/src/addstar/src/loadICRF_table.c )
-
src/addstar/src/loadstarpar.c (copied) (copied from trunk/Ohana/src/addstar/src/loadstarpar.c )
-
src/addstar/src/loadstarpar_catalog.c (copied) (copied from trunk/Ohana/src/addstar/src/loadstarpar_catalog.c )
-
src/addstar/src/loadstarpar_client.c (copied) (copied from trunk/Ohana/src/addstar/src/loadstarpar_client.c )
-
src/addstar/src/loadstarpar_io.c (copied) (copied from trunk/Ohana/src/addstar/src/loadstarpar_io.c )
-
src/addstar/src/loadstarpar_make_subset.c (copied) (copied from trunk/Ohana/src/addstar/src/loadstarpar_make_subset.c )
-
src/addstar/src/loadstarpar_readstars.c (copied) (copied from trunk/Ohana/src/addstar/src/loadstarpar_readstars.c )
-
src/addstar/src/loadstarpar_remote_hosts.c (copied) (copied from trunk/Ohana/src/addstar/src/loadstarpar_remote_hosts.c )
-
src/addstar/src/loadstarpar_save_remote.c (copied) (copied from trunk/Ohana/src/addstar/src/loadstarpar_save_remote.c )
-
src/addstar/src/loadstarpar_table.c (copied) (copied from trunk/Ohana/src/addstar/src/loadstarpar_table.c )
-
src/addstar/src/loadsupercos_plates.c (modified) (3 diffs)
-
src/addstar/src/loadwise.c (modified) (1 diff)
-
src/addstar/src/loadwise_rawdata.c (modified) (2 diffs)
-
src/addstar/src/loadwise_star_full.c (modified) (1 diff)
-
src/addstar/src/mkcmf.c (modified) (5 diffs)
-
src/addstar/src/resort_catalog.c (modified) (5 diffs)
-
src/addstar/src/resort_catalogs.c (copied) (copied from trunk/Ohana/src/addstar/src/resort_catalogs.c )
-
src/addstar/src/resort_threaded.c (modified) (8 diffs)
-
src/addstar/src/resort_unthreaded.c (modified) (1 diff)
-
src/addstar/src/resort_unthreaded_catalogs.c (deleted)
-
src/addstar/src/sky_tessalation.c (modified) (8 diffs)
-
src/addstar/test/relphot.parallel.dvo (modified) (11 diffs)
-
src/checkastro/src/ImageOps.c (modified) (2 diffs)
-
src/checkastro/src/bcatalog.c (modified) (1 diff)
-
src/checkastro/src/load_images.c (modified) (1 diff)
-
src/checkastro/src/select_images.c (modified) (2 diffs)
-
src/delstar/src/ImageOpsFixLAP.c (modified) (1 diff)
-
src/delstar/src/delete_duplicate_measures.c (modified) (4 diffs)
-
src/delstar/src/delete_imagename.c (modified) (2 diffs)
-
src/delstar/src/delete_times.c (modified) (2 diffs)
-
src/dvomerge/Makefile (modified) (3 diffs)
-
src/dvomerge/include/dvomerge.h (modified) (3 diffs)
-
src/dvomerge/include/dvoutils.h (copied) (copied from trunk/Ohana/src/dvomerge/include/dvoutils.h )
-
src/dvomerge/include/dvoverify.h (modified) (1 diff)
-
src/dvomerge/src/ImageOps.c (modified) (1 diff)
-
src/dvomerge/src/LoadCatalog.c (modified) (1 diff)
-
src/dvomerge/src/ReadDeleteListExternID.c (copied) (copied from trunk/Ohana/src/dvomerge/src/ReadDeleteListExternID.c )
-
src/dvomerge/src/args.c (modified) (3 diffs)
-
src/dvomerge/src/build_links.c (modified) (13 diffs)
-
src/dvomerge/src/dvo_image_merge_dbs.c (modified) (3 diffs)
-
src/dvomerge/src/dvomergeContinue.c (modified) (1 diff)
-
src/dvomerge/src/dvomergeContinue_threaded.c (modified) (1 diff)
-
src/dvomerge/src/dvomergeCreate.c (modified) (1 diff)
-
src/dvomerge/src/dvomergeFromList.c (modified) (1 diff)
-
src/dvomerge/src/dvomergeUpdate.c (modified) (2 diffs)
-
src/dvomerge/src/dvomergeUpdate_catalogs.c (modified) (4 diffs)
-
src/dvomerge/src/dvomergeUpdate_threaded.c (modified) (5 diffs)
-
src/dvomerge/src/dvorepair.c (modified) (2 diffs)
-
src/dvomerge/src/dvorepairCPT.c (modified) (1 diff)
-
src/dvomerge/src/dvorepairDeleteImageList.c (modified) (2 diffs)
-
src/dvomerge/src/dvorepairDeleteImagesByExternID.c (copied) (copied from trunk/Ohana/src/dvomerge/src/dvorepairDeleteImagesByExternID.c )
-
src/dvomerge/src/dvorepairFixImages.c (modified) (3 diffs)
-
src/dvomerge/src/dvorepairFixTables.c (modified) (1 diff)
-
src/dvomerge/src/dvoutils.c (copied) (copied from trunk/Ohana/src/dvomerge/src/dvoutils.c )
-
src/dvomerge/src/dvoutils_args.c (copied) (copied from trunk/Ohana/src/dvomerge/src/dvoutils_args.c )
-
src/dvomerge/src/dvoutils_load_image_index.c (copied) (copied from trunk/Ohana/src/dvomerge/src/dvoutils_load_image_index.c )
-
src/dvomerge/src/dvoutils_uniq_images.c (copied) (copied from trunk/Ohana/src/dvomerge/src/dvoutils_uniq_images.c )
-
src/dvomerge/src/dvoverify_args.c (modified) (2 diffs)
-
src/dvomerge/src/dvoverify_catalogs.c (modified) (2 diffs)
-
src/dvomerge/src/dvoverify_client.c (modified) (1 diff)
-
src/dvomerge/src/dvoverify_utils.c (modified) (7 diffs)
-
src/dvomerge/src/merge_catalogs_new.c (modified) (5 diffs)
-
src/dvomerge/src/merge_catalogs_old.c (modified) (16 diffs)
-
src/dvomerge/src/myIndex.c (copied) (copied from trunk/Ohana/src/dvomerge/src/myIndex.c )
-
src/dvopsps/Makefile (modified) (2 diffs)
-
src/dvopsps/include/dvopsps.h (modified) (3 diffs)
-
src/dvopsps/src/DetectionOps.c (modified) (5 diffs)
-
src/dvopsps/src/dvopsps.c (modified) (1 diff)
-
src/dvopsps/src/dvopsps_client.c (modified) (1 diff)
-
src/dvopsps/src/initialize_dvopsps.c (modified) (1 diff)
-
src/dvopsps/src/insert_FWobjects_dvopsps.c (copied) (copied from trunk/Ohana/src/dvopsps/src/insert_FWobjects_dvopsps.c )
-
src/dvopsps/src/insert_FWobjects_dvopsps_catalog.c (copied) (copied from trunk/Ohana/src/dvopsps/src/insert_FWobjects_dvopsps_catalog.c )
-
src/dvopsps/src/insert_detections_dvopsps.c (modified) (2 diffs)
-
src/dvopsps/src/insert_detections_dvopsps_catalog.c (modified) (9 diffs)
-
src/dvopsps/src/insert_objects_dvopsps_catalog.c (modified) (5 diffs)
-
src/dvosplit/include/dvosplit.h (modified) (1 diff)
-
src/dvosplit/src/args.c (modified) (1 diff)
-
src/dvosplit/src/split_averages.c (modified) (4 diffs)
-
src/dvosplit/src/split_measures.c (modified) (4 diffs)
-
src/fakeastro (copied) (copied from trunk/Ohana/src/fakeastro )
-
src/fakeastro/Makefile (copied) (copied from trunk/Ohana/src/fakeastro/Makefile )
-
src/fakeastro/doc (copied) (copied from trunk/Ohana/src/fakeastro/doc )
-
src/fakeastro/doc/example.sh (copied) (copied from trunk/Ohana/src/fakeastro/doc/example.sh )
-
src/fakeastro/include (copied) (copied from trunk/Ohana/src/fakeastro/include )
-
src/fakeastro/include/fakeastro.h (copied) (copied from trunk/Ohana/src/fakeastro/include/fakeastro.h )
-
src/fakeastro/src (copied) (copied from trunk/Ohana/src/fakeastro/src )
-
src/fakeastro/src/AstromOffsetMapOps.c (copied) (copied from trunk/Ohana/src/fakeastro/src/AstromOffsetMapOps.c )
-
src/fakeastro/src/ConfigInit.c (copied) (copied from trunk/Ohana/src/fakeastro/src/ConfigInit.c )
-
src/fakeastro/src/SetSignals.c (copied) (copied from trunk/Ohana/src/fakeastro/src/SetSignals.c )
-
src/fakeastro/src/Shutdown.c (copied) (copied from trunk/Ohana/src/fakeastro/src/Shutdown.c )
-
src/fakeastro/src/StarOps.c (copied) (copied from trunk/Ohana/src/fakeastro/src/StarOps.c )
-
src/fakeastro/src/airmass.c (copied) (copied from trunk/Ohana/src/fakeastro/src/airmass.c )
-
src/fakeastro/src/args.c (copied) (copied from trunk/Ohana/src/fakeastro/src/args.c )
-
src/fakeastro/src/fakeastro.c (copied) (copied from trunk/Ohana/src/fakeastro/src/fakeastro.c )
-
src/fakeastro/src/fakeastro_2mass.c (copied) (copied from trunk/Ohana/src/fakeastro/src/fakeastro_2mass.c )
-
src/fakeastro/src/fakeastro_client.c (copied) (copied from trunk/Ohana/src/fakeastro/src/fakeastro_client.c )
-
src/fakeastro/src/fakeastro_galaxy.c (copied) (copied from trunk/Ohana/src/fakeastro/src/fakeastro_galaxy.c )
-
src/fakeastro/src/fakeastro_images.c (copied) (copied from trunk/Ohana/src/fakeastro/src/fakeastro_images.c )
-
src/fakeastro/src/fakeastro_images_region.c (copied) (copied from trunk/Ohana/src/fakeastro/src/fakeastro_images_region.c )
-
src/fakeastro/src/fakestar_catalog.c (copied) (copied from trunk/Ohana/src/fakeastro/src/fakestar_catalog.c )
-
src/fakeastro/src/fakestar_io.c (copied) (copied from trunk/Ohana/src/fakeastro/src/fakestar_io.c )
-
src/fakeastro/src/fit_fake_stars.c (copied) (copied from trunk/Ohana/src/fakeastro/src/fit_fake_stars.c )
-
src/fakeastro/src/fitpoly.c (copied) (copied from trunk/Ohana/src/fakeastro/src/fitpoly.c )
-
src/fakeastro/src/gaussian.c (copied) (copied from trunk/Ohana/src/fakeastro/src/gaussian.c )
-
src/fakeastro/src/get_image_patch.c (copied) (copied from trunk/Ohana/src/fakeastro/src/get_image_patch.c )
-
src/fakeastro/src/initialize.c (copied) (copied from trunk/Ohana/src/fakeastro/src/initialize.c )
-
src/fakeastro/src/insert_fakestar.c (copied) (copied from trunk/Ohana/src/fakeastro/src/insert_fakestar.c )
-
src/fakeastro/src/load_fake_stars.c (copied) (copied from trunk/Ohana/src/fakeastro/src/load_fake_stars.c )
-
src/fakeastro/src/load_template_images.c (copied) (copied from trunk/Ohana/src/fakeastro/src/load_template_images.c )
-
src/fakeastro/src/make_2mass_measures.c (copied) (copied from trunk/Ohana/src/fakeastro/src/make_2mass_measures.c )
-
src/fakeastro/src/make_fake_images.c (copied) (copied from trunk/Ohana/src/fakeastro/src/make_fake_images.c )
-
src/fakeastro/src/make_fake_stars.c (copied) (copied from trunk/Ohana/src/fakeastro/src/make_fake_stars.c )
-
src/fakeastro/src/make_fake_stars_catalog.c (copied) (copied from trunk/Ohana/src/fakeastro/src/make_fake_stars_catalog.c )
-
src/fakeastro/src/make_fakeqsos.c (copied) (copied from trunk/Ohana/src/fakeastro/src/make_fakeqsos.c )
-
src/fakeastro/src/make_fakestars.c (copied) (copied from trunk/Ohana/src/fakeastro/src/make_fakestars.c )
-
src/fakeastro/src/make_subset.c (copied) (copied from trunk/Ohana/src/fakeastro/src/make_subset.c )
-
src/fakeastro/src/match_fake_stars.c (copied) (copied from trunk/Ohana/src/fakeastro/src/match_fake_stars.c )
-
src/fakeastro/src/remote_hosts.c (copied) (copied from trunk/Ohana/src/fakeastro/src/remote_hosts.c )
-
src/fakeastro/src/save_fake_stars.c (copied) (copied from trunk/Ohana/src/fakeastro/src/save_fake_stars.c )
-
src/fakeastro/src/save_fakestars.c (copied) (copied from trunk/Ohana/src/fakeastro/src/save_fakestars.c )
-
src/fixcat/src/gcatstats.c (modified) (1 diff)
-
src/gastro/src/gfitpoly.c (modified) (2 diffs)
-
src/gastro/src/gstars.c (modified) (1 diff)
-
src/gastro2/src/gproject2.c (modified) (1 diff)
-
src/gastro2/src/gstars2.c (modified) (1 diff)
-
src/getstar (modified) (1 prop)
-
src/getstar/include/dvoImageOverlaps.h (modified) (1 diff)
-
src/getstar/src/MatchCoords.c (modified) (1 diff)
-
src/getstar/src/MatchImages.c (modified) (2 diffs)
-
src/getstar/src/ReadImageFiles.c (modified) (1 diff)
-
src/getstar/src/ReadImageHeader.c (modified) (3 diffs)
-
src/getstar/src/WriteImages.c (modified) (3 diffs)
-
src/imregister/imphot/dumpfits.c (modified) (1 diff)
-
src/imregister/imphot/modify.c (modified) (1 diff)
-
src/kapa2/include/constants.h (modified) (1 diff)
-
src/kapa2/include/structures.h (modified) (1 diff)
-
src/kapa2/src/CreatePicture.c (modified) (1 diff)
-
src/kapa2/src/CursorOps.c (modified) (2 diffs)
-
src/kapa2/src/Graphs.c (modified) (1 diff)
-
src/kapa2/src/Image.c (modified) (2 diffs)
-
src/kapa2/src/InterpretKeys.c (modified) (2 diffs)
-
src/kapa2/src/LoadPicture.c (modified) (1 diff)
-
src/kapa2/src/Reconfig.c (modified) (1 diff)
-
src/kapa2/src/Remap32.c (modified) (6 diffs)
-
src/kapa2/src/SetChannel.c (modified) (2 diffs)
-
src/kapa2/src/UpdateStatusBox.c (modified) (1 diff)
-
src/libautocode/Makefile.Targets (modified) (12 diffs)
-
src/libautocode/README (copied) (copied from trunk/Ohana/src/libautocode/README )
-
src/libautocode/def/AstromOffsetMap_Disk.d (copied) (copied from trunk/Ohana/src/libautocode/def/AstromOffsetMap_Disk.d )
-
src/libautocode/def/average-ps1-sim.d (copied) (copied from trunk/Ohana/src/libautocode/def/average-ps1-sim.d )
-
src/libautocode/def/average-ps1-v5.d (modified) (2 diffs)
-
src/libautocode/def/average.d (modified) (2 diffs)
-
src/libautocode/def/cmf-ps1-sv4.d (copied) (copied from trunk/Ohana/src/libautocode/def/cmf-ps1-sv4.d )
-
src/libautocode/def/cmf-ps1-v5-lensing-alt.d (copied) (copied from trunk/Ohana/src/libautocode/def/cmf-ps1-v5-lensing-alt.d )
-
src/libautocode/def/cmf-ps1-v5-lensing.d (modified) (2 diffs)
-
src/libautocode/def/coords-disk.d (copied) (copied from trunk/Ohana/src/libautocode/def/coords-disk.d )
-
src/libautocode/def/coords.d (modified) (1 diff)
-
src/libautocode/def/image-elixir.d (modified) (1 diff)
-
src/libautocode/def/image-loneos.d (modified) (1 diff)
-
src/libautocode/def/image-panstarrs-dev-0.d (modified) (1 diff)
-
src/libautocode/def/image-panstarrs-dev-1.d (modified) (1 diff)
-
src/libautocode/def/image-ps1-dev-1.d (modified) (1 diff)
-
src/libautocode/def/image-ps1-dev-2.d (modified) (1 diff)
-
src/libautocode/def/image-ps1-dev-3.d (modified) (1 diff)
-
src/libautocode/def/image-ps1-ref.d (modified) (1 diff)
-
src/libautocode/def/image-ps1-sim.d (copied) (copied from trunk/Ohana/src/libautocode/def/image-ps1-sim.d )
-
src/libautocode/def/image-ps1-v1.d (modified) (1 diff)
-
src/libautocode/def/image-ps1-v2.d (modified) (1 diff)
-
src/libautocode/def/image-ps1-v3.d (modified) (1 diff)
-
src/libautocode/def/image-ps1-v4.d (modified) (1 diff)
-
src/libautocode/def/image-ps1-v5.d (modified) (1 diff)
-
src/libautocode/def/image.d (modified) (4 diffs)
-
src/libautocode/def/lensing-ps1-v5-alt.d (copied) (copied from trunk/Ohana/src/libautocode/def/lensing-ps1-v5-alt.d )
-
src/libautocode/def/lensing-ps1-v5.d (modified) (1 diff)
-
src/libautocode/def/lensing.d (modified) (1 diff)
-
src/libautocode/def/lensobj-ps1-v5.d (modified) (1 diff)
-
src/libautocode/def/lensobj.d (modified) (1 diff)
-
src/libautocode/def/measure-ps1-sim.d (copied) (copied from trunk/Ohana/src/libautocode/def/measure-ps1-sim.d )
-
src/libautocode/def/measure-ps1-v5.d (modified) (1 diff)
-
src/libautocode/def/measure.d (modified) (1 diff)
-
src/libautocode/def/secfilt-ps1-sim.d (copied) (copied from trunk/Ohana/src/libautocode/def/secfilt-ps1-sim.d )
-
src/libautocode/def/secfilt-ps1-v4.d (modified) (1 diff)
-
src/libautocode/def/secfilt-ps1-v5.d (modified) (4 diffs)
-
src/libautocode/def/secfilt.d (modified) (5 diffs)
-
src/libautocode/def/starpar-ps1-sim.d (copied) (copied from trunk/Ohana/src/libautocode/def/starpar-ps1-sim.d )
-
src/libautocode/def/starpar-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/starpar-ps1-v5.d )
-
src/libautocode/def/starpar.d (copied) (copied from trunk/Ohana/src/libautocode/def/starpar.d )
-
src/libautocode/doc/autocode.txt (modified) (2 diffs)
-
src/libautocode/generate (modified) (4 diffs)
-
src/libdvo/Makefile (modified) (4 diffs)
-
src/libdvo/include/cmf-ps1-sv4.h (copied) (copied from trunk/Ohana/src/libdvo/include/cmf-ps1-sv4.h )
-
src/libdvo/include/cmf-ps1-v5-lensing-alt.h (copied) (copied from trunk/Ohana/src/libdvo/include/cmf-ps1-v5-lensing-alt.h )
-
src/libdvo/include/cmf-ps1-v5-lensing.h (modified) (1 diff)
-
src/libdvo/include/dvo.h (modified) (30 diffs)
-
src/libdvo/include/dvodb.h (modified) (7 diffs)
-
src/libdvo/include/libdvo_astro.h (modified) (2 diffs)
-
src/libdvo/include/ps1_sim_defs.h (copied) (copied from trunk/Ohana/src/libdvo/include/ps1_sim_defs.h )
-
src/libdvo/include/ps1_v5_defs.h (modified) (1 diff)
-
src/libdvo/src/AstromOffsetMapIO.c (copied) (copied from trunk/Ohana/src/libdvo/src/AstromOffsetMapIO.c )
-
src/libdvo/src/AstromOffsetMapOps.c (copied) (copied from trunk/Ohana/src/libdvo/src/AstromOffsetMapOps.c )
-
src/libdvo/src/AstromOffsetMapUtils.c (copied) (copied from trunk/Ohana/src/libdvo/src/AstromOffsetMapUtils.c )
-
src/libdvo/src/BoundaryTree.c (modified) (8 diffs)
-
src/libdvo/src/HostTable.c (modified) (9 diffs)
-
src/libdvo/src/ImageMetadata.c (modified) (1 diff)
-
src/libdvo/src/ImageMetadataSelection.c (modified) (1 diff)
-
src/libdvo/src/ImageOps.c (modified) (2 diffs)
-
src/libdvo/src/ImageSelection.c (modified) (3 diffs)
-
src/libdvo/src/LoadImages.c (modified) (4 diffs)
-
src/libdvo/src/RegionHostTable.c (modified) (1 diff)
-
src/libdvo/src/TessellationTable.c (modified) (9 diffs)
-
src/libdvo/src/astrom_maps.c (copied) (copied from trunk/Ohana/src/libdvo/src/astrom_maps.c )
-
src/libdvo/src/cmf-ps1-sv4.c (copied) (copied from trunk/Ohana/src/libdvo/src/cmf-ps1-sv4.c )
-
src/libdvo/src/cmf-ps1-v5-lensing-alt.c (copied) (copied from trunk/Ohana/src/libdvo/src/cmf-ps1-v5-lensing-alt.c )
-
src/libdvo/src/cmf-ps1-v5-lensing.c (modified) (4 diffs)
-
src/libdvo/src/cmf-ps1-v5.c (modified) (4 diffs)
-
src/libdvo/src/coord_systems.c (modified) (5 diffs)
-
src/libdvo/src/coordops.c (modified) (10 diffs)
-
src/libdvo/src/dbExtractAverages.c (modified) (9 diffs)
-
src/libdvo/src/dbExtractImages.c (modified) (9 diffs)
-
src/libdvo/src/dbExtractMeasures.c (modified) (9 diffs)
-
src/libdvo/src/dbFields.c (modified) (9 diffs)
-
src/libdvo/src/dvo_catalog.c (modified) (21 diffs)
-
src/libdvo/src/dvo_catalog_create.c (modified) (3 diffs)
-
src/libdvo/src/dvo_catalog_mef.c (modified) (7 diffs)
-
src/libdvo/src/dvo_catalog_raw.c (modified) (8 diffs)
-
src/libdvo/src/dvo_catalog_split.c (modified) (32 diffs)
-
src/libdvo/src/dvo_convert.c (modified) (20 diffs)
-
src/libdvo/src/dvo_convert_PS1_DEV_1.c (modified) (4 diffs)
-
src/libdvo/src/dvo_convert_PS1_DEV_2.c (modified) (4 diffs)
-
src/libdvo/src/dvo_convert_PS1_DEV_3.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_PS1_REF.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_PS1_SIM.c (copied) (copied from trunk/Ohana/src/libdvo/src/dvo_convert_PS1_SIM.c )
-
src/libdvo/src/dvo_convert_PS1_V1.c (modified) (4 diffs)
-
src/libdvo/src/dvo_convert_PS1_V2.c (modified) (4 diffs)
-
src/libdvo/src/dvo_convert_PS1_V3.c (modified) (4 diffs)
-
src/libdvo/src/dvo_convert_PS1_V4.c (modified) (7 diffs)
-
src/libdvo/src/dvo_convert_PS1_V5.c (modified) (15 diffs)
-
src/libdvo/src/dvo_convert_elixir.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_loneos.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_panstarrs_DEV_0.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_panstarrs_DEV_1.c (modified) (2 diffs)
-
src/libdvo/src/dvo_image.c (modified) (4 diffs)
-
src/libdvo/src/dvo_image_raw.c (modified) (2 diffs)
-
src/libdvo/src/dvo_photcode_ops.c (modified) (4 diffs)
-
src/libdvo/src/dvo_tiny_values.c (modified) (1 diff)
-
src/libdvo/src/dvo_util.c (modified) (1 diff)
-
src/libdvo/src/flatcorr_io.c (modified) (2 diffs)
-
src/libdvo/src/galaxy_model.c (copied) (copied from trunk/Ohana/src/libdvo/src/galaxy_model.c )
-
src/libdvo/src/mosaic_astrom.c (modified) (4 diffs)
-
src/libdvo/src/skyregion_gsc.c (modified) (1 diff)
-
src/libdvo/src/skyregion_ops.c (modified) (2 diffs)
-
src/libfits/Makefile (modified) (1 diff)
-
src/libfits/header/F_find_H.c (copied) (copied from trunk/Ohana/src/libfits/header/F_find_H.c )
-
src/libfits/header/F_free_H.c (modified) (1 diff)
-
src/libfits/include/gfitsio.h (modified) (3 diffs)
-
src/libfits/table/F_read_T.c (modified) (3 diffs)
-
src/libfits/table/F_write_T.c (modified) (1 diff)
-
src/libkapa/src/KapaWindow.c (modified) (1 diff)
-
src/libohana/Makefile (modified) (2 diffs)
-
src/libohana/doc/gsl.txt (copied) (copied from trunk/Ohana/src/libohana/doc/gsl.txt )
-
src/libohana/include/gsl_utils.h (copied) (copied from trunk/Ohana/src/libohana/include/gsl_utils.h )
-
src/libohana/include/ohana.h (modified) (5 diffs)
-
src/libohana/src/gaussj.c (modified) (7 diffs)
-
src/libohana/src/glockfile.c (modified) (2 diffs)
-
src/libohana/src/gsl_gamma.c (copied) (copied from trunk/Ohana/src/libohana/src/gsl_gamma.c )
-
src/libohana/src/gsl_utils.c (copied) (copied from trunk/Ohana/src/libohana/src/gsl_utils.c )
-
src/libohana/src/legendre.c (copied) (copied from trunk/Ohana/src/libohana/src/legendre.c )
-
src/libohana/src/ohana_allocate.c (modified) (1 diff)
-
src/libohana/src/spherical.c (copied) (copied from trunk/Ohana/src/libohana/src/spherical.c )
-
src/libohana/src/vstats.c (copied) (copied from trunk/Ohana/src/libohana/src/vstats.c )
-
src/markrock/src/gcatstats.c (modified) (1 diff)
-
src/markstar/src/gcatstats.c (modified) (1 diff)
-
src/mosastro/src/chips.c (modified) (1 diff)
-
src/mosastro/src/fakefield.c (modified) (2 diffs)
-
src/mosastro/src/field.c (modified) (6 diffs)
-
src/mosastro/src/fitpoly.c (modified) (2 diffs)
-
src/mosastro/src/mkobs.c (modified) (2 diffs)
-
src/mosastro/src/mkstandards.c (modified) (1 diff)
-
src/mosastro/src/testcoords.c (modified) (1 diff)
-
src/opihi/cmd.astro/Makefile (modified) (1 diff)
-
src/opihi/cmd.astro/cdensify.c (modified) (1 diff)
-
src/opihi/cmd.astro/coords.c (modified) (1 diff)
-
src/opihi/cmd.astro/cplot.c (modified) (5 diffs)
-
src/opihi/cmd.astro/csystem.c (modified) (1 diff)
-
src/opihi/cmd.astro/fitplx.c (modified) (1 diff)
-
src/opihi/cmd.astro/fitpm.c (modified) (1 diff)
-
src/opihi/cmd.astro/gauss.c (modified) (1 diff)
-
src/opihi/cmd.astro/getcoords.c (modified) (2 diffs)
-
src/opihi/cmd.astro/init.c (modified) (2 diffs)
-
src/opihi/cmd.astro/objload.c (modified) (1 diff)
-
src/opihi/cmd.astro/region.c (modified) (4 diffs)
-
src/opihi/cmd.astro/shimage.c (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/shimage.c )
-
src/opihi/cmd.astro/vshimage.c (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/vshimage.c )
-
src/opihi/cmd.data/Makefile (modified) (2 diffs)
-
src/opihi/cmd.data/center.c (modified) (1 diff)
-
src/opihi/cmd.data/dft2d.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/dft2d.c )
-
src/opihi/cmd.data/dimenup.c (modified) (1 diff)
-
src/opihi/cmd.data/erase.c (modified) (1 diff)
-
src/opihi/cmd.data/fit2d.c (modified) (1 diff)
-
src/opihi/cmd.data/init.c (modified) (5 diffs)
-
src/opihi/cmd.data/load.c (modified) (1 diff)
-
src/opihi/cmd.data/point.c (modified) (1 diff)
-
src/opihi/cmd.data/read_vectors.c (modified) (9 diffs)
-
src/opihi/cmd.data/relocate.c (modified) (1 diff)
-
src/opihi/cmd.data/resize.c (modified) (1 diff)
-
src/opihi/cmd.data/save.c (modified) (1 diff)
-
src/opihi/cmd.data/shapply.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/shapply.c )
-
src/opihi/cmd.data/shdot.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/shdot.c )
-
src/opihi/cmd.data/shfit.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/shfit.c )
-
src/opihi/cmd.data/shterms.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/shterms.c )
-
src/opihi/cmd.data/tv.c (modified) (1 diff)
-
src/opihi/cmd.data/tvchannel.c (modified) (1 diff)
-
src/opihi/cmd.data/tvcontour.c (modified) (1 diff)
-
src/opihi/cmd.data/tvgrid.c (modified) (1 diff)
-
src/opihi/cmd.data/vload.c (modified) (1 diff)
-
src/opihi/cmd.data/vsh.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/vsh.c )
-
src/opihi/cmd.data/vshfit.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/vshfit.c )
-
src/opihi/cmd.data/vzload.c (modified) (1 diff)
-
src/opihi/dvo/Makefile (modified) (1 diff)
-
src/opihi/dvo/avextract.c (modified) (5 diffs)
-
src/opihi/dvo/avmatch.c (modified) (3 diffs)
-
src/opihi/dvo/catname.c (copied) (copied from trunk/Ohana/src/opihi/dvo/catname.c )
-
src/opihi/dvo/cmpload.c (modified) (1 diff)
-
src/opihi/dvo/dvo_host_utils.c (modified) (1 diff)
-
src/opihi/dvo/find_matches.c (modified) (2 diffs)
-
src/opihi/dvo/gimages.c (modified) (3 diffs)
-
src/opihi/dvo/gstar.c (modified) (14 diffs)
-
src/opihi/dvo/images.c (modified) (5 diffs)
-
src/opihi/dvo/imbox.c (modified) (1 diff)
-
src/opihi/dvo/imdata.c (modified) (2 diffs)
-
src/opihi/dvo/imdense.c (modified) (2 diffs)
-
src/opihi/dvo/imextract.c (modified) (1 diff)
-
src/opihi/dvo/imlist.c (modified) (4 diffs)
-
src/opihi/dvo/imstats.c (modified) (2 diffs)
-
src/opihi/dvo/init.c (modified) (2 diffs)
-
src/opihi/dvo/mextract.c (modified) (3 diffs)
-
src/opihi/dvo/mmatch.c (modified) (3 diffs)
-
src/opihi/dvo/mmextract.c (modified) (2 diffs)
-
src/opihi/dvo/objectcoverage.c (modified) (2 diffs)
-
src/opihi/dvo/showtile.c (modified) (1 diff)
-
src/opihi/dvo/simage.c (modified) (1 diff)
-
src/opihi/dvo/skycoverage.c (modified) (4 diffs)
-
src/opihi/dvo/subpix.c (modified) (2 diffs)
-
src/opihi/include/astro.h (modified) (1 diff)
-
src/opihi/include/data.h (modified) (1 diff)
-
src/opihi/include/dvomath.h (modified) (1 diff)
-
src/opihi/lib.shell/BufferOps.c (modified) (1 diff)
-
src/opihi/pantasks/controller_status.c (modified) (2 diffs)
-
src/opihi/pantasks/test/runmacro.sh (copied) (copied from trunk/Ohana/src/opihi/pantasks/test/runmacro.sh )
-
src/opihi/pantasks/test/trange.sh (copied) (copied from trunk/Ohana/src/opihi/pantasks/test/trange.sh )
-
src/opihi/pcontrol/Makefile (modified) (1 diff)
-
src/opihi/pcontrol/status.c (modified) (1 diff)
-
src/photdbc/include/photdbc.h (modified) (2 diffs)
-
src/photdbc/src/CopyToHostLocation.c (modified) (1 diff)
-
src/photdbc/src/args.c (modified) (5 diffs)
-
src/photdbc/src/copy_images.c (modified) (2 diffs)
-
src/photdbc/src/find_images.c (modified) (1 diff)
-
src/photdbc/src/join_stars.c (modified) (1 diff)
-
src/photdbc/src/photdbc.c (modified) (1 diff)
-
src/photdbc/src/photdbc_catalogs.c (modified) (3 diffs)
-
src/photdbc/src/select_images.c (modified) (3 diffs)
-
src/relastro/Makefile (modified) (5 diffs)
-
src/relastro/doc/pv2.txt (modified) (1 diff)
-
src/relastro/include/relastro.h (modified) (14 diffs)
-
src/relastro/src/BrightCatalog.c (modified) (10 diffs)
-
src/relastro/src/ConfigInit.c (modified) (2 diffs)
-
src/relastro/src/FitChip.c (modified) (6 diffs)
-
src/relastro/src/FrameCorrection.c (copied) (copied from trunk/Ohana/src/relastro/src/FrameCorrection.c )
-
src/relastro/src/FrameCorrectionIO.c (copied) (copied from trunk/Ohana/src/relastro/src/FrameCorrectionIO.c )
-
src/relastro/src/FrameCorrectionUtils.c (copied) (copied from trunk/Ohana/src/relastro/src/FrameCorrectionUtils.c )
-
src/relastro/src/ICRF.c (copied) (copied from trunk/Ohana/src/relastro/src/ICRF.c )
-
src/relastro/src/ICRFobjIO.c (copied) (copied from trunk/Ohana/src/relastro/src/ICRFobjIO.c )
-
src/relastro/src/ImageOps.c (modified) (14 diffs)
-
src/relastro/src/ImagePosIO.c (modified) (7 diffs)
-
src/relastro/src/MeasPosIO.c (copied) (copied from trunk/Ohana/src/relastro/src/MeasPosIO.c )
-
src/relastro/src/ParFactor.c (modified) (1 diff)
-
src/relastro/src/StarMaps.c (modified) (1 diff)
-
src/relastro/src/UpdateChips.c (modified) (13 diffs)
-
src/relastro/src/UpdateMeasures.c (modified) (2 diffs)
-
src/relastro/src/UpdateObjectOffsets.c (modified) (3 diffs)
-
src/relastro/src/UpdateObjects.c (modified) (4 diffs)
-
src/relastro/src/args.c (modified) (5 diffs)
-
src/relastro/src/assign_images.c (modified) (4 diffs)
-
src/relastro/src/bcatalog.c (modified) (10 diffs)
-
src/relastro/src/client_logger.c (copied) (copied from trunk/Ohana/src/relastro/src/client_logger.c )
-
src/relastro/src/extra.c (copied) (copied from trunk/Ohana/src/relastro/src/extra.c )
-
src/relastro/src/fitpoly.c (modified) (5 diffs)
-
src/relastro/src/high_speed_objects.c (modified) (3 diffs)
-
src/relastro/src/high_speed_utils.c (modified) (2 diffs)
-
src/relastro/src/hpm_objects.c (modified) (4 diffs)
-
src/relastro/src/initialize.c (modified) (2 diffs)
-
src/relastro/src/launch_region_hosts.c (modified) (5 diffs)
-
src/relastro/src/liststats.c (modified) (1 diff)
-
src/relastro/src/load_catalogs.c (modified) (4 diffs)
-
src/relastro/src/load_images.c (modified) (3 diffs)
-
src/relastro/src/markObjects.c (modified) (1 diff)
-
src/relastro/src/relastroVisual.c (modified) (2 diffs)
-
src/relastro/src/relastro_client.c (modified) (1 diff)
-
src/relastro/src/relastro_images.c (modified) (7 diffs)
-
src/relastro/src/relastro_objects.c (modified) (1 diff)
-
src/relastro/src/relastro_parallel_images.c (modified) (7 diffs)
-
src/relastro/src/relastro_parallel_regions.c (modified) (3 diffs)
-
src/relastro/src/select_images.c (modified) (4 diffs)
-
src/relastro/src/share_icrf_obj.c (copied) (copied from trunk/Ohana/src/relastro/src/share_icrf_obj.c )
-
src/relastro/src/share_images_pos.c (modified) (4 diffs)
-
src/relastro/src/share_meas_pos.c (copied) (copied from trunk/Ohana/src/relastro/src/share_meas_pos.c )
-
src/relastro/src/testparallax.c (modified) (1 diff)
-
src/relphot/doc/timeline.txt (copied) (copied from trunk/Ohana/src/relphot/doc/timeline.txt )
-
src/relphot/include/relphot.h (modified) (2 diffs)
-
src/relphot/src/BoundaryTreeOps.c (modified) (1 diff)
-
src/relphot/src/ImageOps.c (modified) (5 diffs)
-
src/relphot/src/ImageTable.c (modified) (1 diff)
-
src/relphot/src/MosaicOps.c (modified) (5 diffs)
-
src/relphot/src/StarOps.c (modified) (2 diffs)
-
src/relphot/src/assign_images.c (modified) (3 diffs)
-
src/relphot/src/bcatalog.c (modified) (1 diff)
-
src/relphot/src/load_images.c (modified) (1 diff)
-
src/relphot/src/reload_catalogs.c (modified) (6 diffs)
-
src/relphot/src/relphot.c (modified) (3 diffs)
-
src/relphot/src/relphot_objects.c (modified) (1 diff)
-
src/relphot/src/relphot_parallel_regions.c (modified) (2 diffs)
-
src/relphot/src/select_images.c (modified) (5 diffs)
-
src/relphot/src/setMrelCatalog.c (modified) (21 diffs)
-
src/uniphot/Makefile (modified) (6 diffs)
-
src/uniphot/include/setastrom.h (modified) (2 diffs)
-
src/uniphot/include/setgalmodel.h (copied) (copied from trunk/Ohana/src/uniphot/include/setgalmodel.h )
-
src/uniphot/src/astrom_correction.c (modified) (1 diff)
-
src/uniphot/src/dcr_correction.c (copied) (copied from trunk/Ohana/src/uniphot/src/dcr_correction.c )
-
src/uniphot/src/find_image_sgroups.c (modified) (3 diffs)
-
src/uniphot/src/galmodel_correction.c (copied) (copied from trunk/Ohana/src/uniphot/src/galmodel_correction.c )
-
src/uniphot/src/initialize_setastrom.c (modified) (6 diffs)
-
src/uniphot/src/initialize_setgalmodel.c (copied) (copied from trunk/Ohana/src/uniphot/src/initialize_setgalmodel.c )
-
src/uniphot/src/kh_correction.c (copied) (copied from trunk/Ohana/src/uniphot/src/kh_correction.c )
-
src/uniphot/src/load_zpt_table.c (modified) (5 diffs)
-
src/uniphot/src/match_zpts_to_images.c (modified) (1 diff)
-
src/uniphot/src/setgalmodel.c (copied) (copied from trunk/Ohana/src/uniphot/src/setgalmodel.c )
-
src/uniphot/src/setgalmodel_client.c (copied) (copied from trunk/Ohana/src/uniphot/src/setgalmodel_client.c )
-
src/uniphot/src/update_catalog_setastrom.c (modified) (4 diffs)
-
src/uniphot/src/update_catalog_setastrom_dcr.c (copied) (copied from trunk/Ohana/src/uniphot/src/update_catalog_setastrom_dcr.c )
-
src/uniphot/src/update_catalog_setastrom_kh.c (copied) (copied from trunk/Ohana/src/uniphot/src/update_catalog_setastrom_kh.c )
-
src/uniphot/src/update_catalog_setgalmodel.c (copied) (copied from trunk/Ohana/src/uniphot/src/update_catalog_setgalmodel.c )
-
src/uniphot/src/update_dvo_setastrom.c (modified) (5 diffs)
-
src/uniphot/src/update_dvo_setgalmodel.c (copied) (copied from trunk/Ohana/src/uniphot/src/update_dvo_setgalmodel.c )
-
src/uniphot/src/update_dvo_uniphot.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-pv3-20140717-merge/Ohana
- Property svn:mergeinfo set to
-
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/Makefile.in
r35110 r37822 34 34 dvopsps \ 35 35 elixir \ 36 fakeastro \ 36 37 gastro \ 37 38 gastro2 \ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/configure.tcsh
r34088 r37822 240 240 set needlibs = "$needlibs X11" 241 241 set needlibs = "$needlibs pthread" 242 set needlibs = "$needlibs gsl" 243 set needlibs = "$needlibs gslcblas" 242 244 set needlibs = "$needlibs m" 243 245 … … 269 271 set needincs = "$needincs png.h" 270 272 set needincs = "$needincs pthread.h" 273 set needincs = "$needincs gsl/gsl_sf_legendre.h" 271 274 set needincs = "$needincs readline/history.h" 272 275 set needincs = "$needincs readline/readline.h" -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/Makefile
r37343 r37822 24 24 sedstar : $(BIN)/sedstar.$(ARCH) 25 25 load2mass : $(BIN)/load2mass.$(ARCH) 26 loadstarpar : $(BIN)/loadstarpar.$(ARCH) 27 loadstarpar_client : $(BIN)/loadstarpar_client.$(ARCH) 28 loadICRF : $(BIN)/loadICRF.$(ARCH) 29 loadICRF_client : $(BIN)/loadICRF_client.$(ARCH) 26 30 loadwise : $(BIN)/loadwise.$(ARCH) 27 31 dumpskycells : $(BIN)/dumpskycells.$(ARCH) … … 31 35 mkcmf : $(BIN)/mkcmf.$(ARCH) 32 36 33 all: addstar addstar_client sedstar load2mass skycells mkcmf loadwise loadsupercos dumpskycells findskycell34 35 INSTALL = addstar addstar_client sedstar load2mass skycells mkcmf loadwise loadsupercos dumpskycells findskycell37 all: addstar addstar_client sedstar load2mass loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf loadwise loadsupercos dumpskycells findskycell 38 39 INSTALL = addstar addstar_client sedstar load2mass loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf loadwise loadsupercos dumpskycells findskycell 36 40 37 41 # I need to fix the client/server version of addstar now that I have dropped Stars … … 78 82 $(SRC)/parse_time.$(ARCH).o \ 79 83 $(SRC)/replace_match.$(ARCH).o \ 80 $(SRC)/resort_catalog .$(ARCH).o \84 $(SRC)/resort_catalogs.$(ARCH).o \ 81 85 $(SRC)/resort_threaded.$(ARCH).o \ 82 86 $(SRC)/resort_unthreaded.$(ARCH).o \ 83 $(SRC)/resort_ unthreaded_catalogs.$(ARCH).o \87 $(SRC)/resort_catalog.$(ARCH).o \ 84 88 $(SRC)/StarOps.$(ARCH).o \ 85 89 $(SRC)/ReadStarsFITS.$(ARCH).o \ … … 106 110 $(SRC)/addstar_client.$(ARCH).o \ 107 111 $(SRC)/args_parallel_client.$(ARCH).o \ 108 $(SRC)/resort_catalog .$(ARCH).o \112 $(SRC)/resort_catalogs.$(ARCH).o \ 109 113 $(SRC)/resort_threaded.$(ARCH).o \ 110 114 $(SRC)/resort_unthreaded.$(ARCH).o \ 111 $(SRC)/resort_ unthreaded_catalogs.$(ARCH).o115 $(SRC)/resort_catalog.$(ARCH).o 112 116 113 117 ADDSTARD = \ … … 241 245 $(SRC)/psps_ids.$(ARCH).o 242 246 247 LOAD-STARPAR = \ 248 $(SRC)/loadstarpar.$(ARCH).o \ 249 $(SRC)/ConfigInit.$(ARCH).o \ 250 $(SRC)/SetSignals.$(ARCH).o \ 251 $(SRC)/Shutdown.$(ARCH).o \ 252 $(SRC)/SkyRegionUtils.$(ARCH).o \ 253 $(SRC)/args_loadstarpar.$(ARCH).o \ 254 $(SRC)/find_matches_starpar.$(ARCH).o \ 255 $(SRC)/loadstarpar_catalog.$(ARCH).o \ 256 $(SRC)/loadstarpar_io.$(ARCH).o \ 257 $(SRC)/loadstarpar_make_subset.$(ARCH).o \ 258 $(SRC)/loadstarpar_readstars.$(ARCH).o \ 259 $(SRC)/loadstarpar_remote_hosts.$(ARCH).o \ 260 $(SRC)/loadstarpar_save_remote.$(ARCH).o \ 261 $(SRC)/loadstarpar_table.$(ARCH).o \ 262 $(SRC)/psps_ids.$(ARCH).o 263 264 LOAD-STARPAR-CLIENT = \ 265 $(SRC)/loadstarpar_client.$(ARCH).o \ 266 $(SRC)/ConfigInit.$(ARCH).o \ 267 $(SRC)/SetSignals.$(ARCH).o \ 268 $(SRC)/Shutdown.$(ARCH).o \ 269 $(SRC)/SkyRegionUtils.$(ARCH).o \ 270 $(SRC)/args_loadstarpar.$(ARCH).o \ 271 $(SRC)/find_matches_starpar.$(ARCH).o \ 272 $(SRC)/loadstarpar_catalog.$(ARCH).o \ 273 $(SRC)/loadstarpar_io.$(ARCH).o \ 274 $(SRC)/loadstarpar_make_subset.$(ARCH).o \ 275 $(SRC)/loadstarpar_readstars.$(ARCH).o \ 276 $(SRC)/loadstarpar_remote_hosts.$(ARCH).o \ 277 $(SRC)/loadstarpar_save_remote.$(ARCH).o \ 278 $(SRC)/loadstarpar_table.$(ARCH).o \ 279 $(SRC)/psps_ids.$(ARCH).o 280 281 LOAD-ICRF = \ 282 $(SRC)/loadICRF.$(ARCH).o \ 283 $(SRC)/ConfigInit.$(ARCH).o \ 284 $(SRC)/SetSignals.$(ARCH).o \ 285 $(SRC)/Shutdown.$(ARCH).o \ 286 $(SRC)/SkyRegionUtils.$(ARCH).o \ 287 $(SRC)/args_loadICRF.$(ARCH).o \ 288 $(SRC)/find_matches_ICRF.$(ARCH).o \ 289 $(SRC)/loadICRF_catalog.$(ARCH).o \ 290 $(SRC)/loadICRF_io.$(ARCH).o \ 291 $(SRC)/loadICRF_make_subset.$(ARCH).o \ 292 $(SRC)/loadICRF_readstars.$(ARCH).o \ 293 $(SRC)/loadICRF_remote_hosts.$(ARCH).o \ 294 $(SRC)/loadICRF_save_remote.$(ARCH).o \ 295 $(SRC)/loadICRF_table.$(ARCH).o \ 296 $(SRC)/psps_ids.$(ARCH).o 297 298 LOAD-ICRF-CLIENT = \ 299 $(SRC)/loadICRF_client.$(ARCH).o \ 300 $(SRC)/ConfigInit.$(ARCH).o \ 301 $(SRC)/SetSignals.$(ARCH).o \ 302 $(SRC)/Shutdown.$(ARCH).o \ 303 $(SRC)/SkyRegionUtils.$(ARCH).o \ 304 $(SRC)/args_loadICRF.$(ARCH).o \ 305 $(SRC)/find_matches_ICRF.$(ARCH).o \ 306 $(SRC)/loadICRF_catalog.$(ARCH).o \ 307 $(SRC)/loadICRF_io.$(ARCH).o \ 308 $(SRC)/loadICRF_make_subset.$(ARCH).o \ 309 $(SRC)/loadICRF_readstars.$(ARCH).o \ 310 $(SRC)/loadICRF_remote_hosts.$(ARCH).o \ 311 $(SRC)/loadICRF_save_remote.$(ARCH).o \ 312 $(SRC)/loadICRF_table.$(ARCH).o \ 313 $(SRC)/psps_ids.$(ARCH).o 314 243 315 LOAD-WISE = \ 244 316 $(SRC)/loadwise.$(ARCH).o \ … … 309 381 $(SRC)/Shutdown.$(ARCH).o 310 382 311 $(ADDSTARC) : $(INC)/addstar.h 312 $(ADDSTARD) : $(INC)/addstar.h 313 $(ADDSTART) : $(INC)/addstar.h 314 $(ADDSTAR) : $(INC)/addstar.h 315 $(ADDSTAR_CLIENT) : $(INC)/addstar.h 316 $(SKYCELLS) : $(INC)/addstar.h 317 $(DUMPSKYCELLS) : $(INC)/addstar.h 318 $(FINDSKYCELL) : $(INC)/addstar.h 319 $(LOAD-2MASS) : $(INC)/addstar.h $(INC)/2mass.h 320 $(LOAD-WISE) : $(INC)/addstar.h $(INC)/WISE.h 321 $(MKCMF) : $(INC)/mkcmf.h 383 $(ADDSTARC) : $(INC)/addstar.h 384 $(ADDSTARD) : $(INC)/addstar.h 385 $(ADDSTART) : $(INC)/addstar.h 386 $(ADDSTAR) : $(INC)/addstar.h 387 $(ADDSTAR_CLIENT) : $(INC)/addstar.h 388 $(SKYCELLS) : $(INC)/addstar.h 389 $(DUMPSKYCELLS) : $(INC)/addstar.h 390 $(FINDSKYCELL) : $(INC)/addstar.h 391 $(LOAD-2MASS) : $(INC)/addstar.h $(INC)/2mass.h 392 $(LOAD-STARPAR) : $(INC)/addstar.h $(INC)/loadstarpar.h 393 $(LOAD-STARPAR-CLIENT) : $(INC)/addstar.h $(INC)/loadstarpar.h 394 $(LOAD-ICRF) : $(INC)/addstar.h $(INC)/loadICRF.h 395 $(LOAD-ICRF-CLIENT) : $(INC)/addstar.h $(INC)/loadICRF.h 396 $(LOAD-WISE) : $(INC)/addstar.h $(INC)/WISE.h 397 $(MKCMF) : $(INC)/mkcmf.h 322 398 323 399 $(BIN)/addstar.$(ARCH) : $(ADDSTAR) … … 330 406 $(BIN)/load2mass.$(ARCH) : $(LOAD-2MASS) 331 407 $(BIN)/loadwise.$(ARCH) : $(LOAD-WISE) 408 $(BIN)/loadstarpar.$(ARCH) : $(LOAD-STARPAR) 409 $(BIN)/loadstarpar_client.$(ARCH) : $(LOAD-STARPAR-CLIENT) 410 $(BIN)/loadICRF.$(ARCH) : $(LOAD-ICRF) 411 $(BIN)/loadICRF_client.$(ARCH): $(LOAD-ICRF-CLIENT) 332 412 $(BIN)/loadsupercos.$(ARCH) : $(LOAD-SUPERCOS) 333 413 $(BIN)/skycells.$(ARCH) : $(SKYCELLS) -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/include/WISE.h
r33963 r37822 21 21 short WISE_W1, WISE_W2, WISE_W3, WISE_W4; 22 22 23 int ALLSKY; 23 enum {MODE_NONE, MODE_ALLWISE, MODE_ALLSKY, MODE_PRELIM}; 24 int MODE; 24 25 25 26 AddstarClientOptions args_loadwise (int argc, char **argv, AddstarClientOptions options); 26 27 27 int loadwise_rawdata (SkyList *skytable, char *filename, AddstarClientOptions options , int ALLSKY);28 int loadwise_rawdata (SkyList *skytable, char *filename, AddstarClientOptions options); 28 29 29 30 int getWISE_setup (); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/include/addstar.h
r37343 r37822 20 20 # define IN_REGION(R,D) ( \ 21 21 ((D) >= region[0].Dmin) && ((D) < region[0].Dmax) && \ 22 ((R) >= region[0].Rmin) && ((R) < region[0].Rmax))22 ((R) >= region[0].Rmin) && ((R) < region[0].Rmax)) 23 23 24 24 /* grab named photcode */ … … 31 31 # define dCOS(A) ((double) cos ((double)RAD_DEG*A)) 32 32 # define dSIN(A) ((double) sin ((double)RAD_DEG*A)) 33 34 # define myAbortF(FORMAT,...) { fprintf (stderr, FORMAT, __VA_ARGS__); abort(); } 33 35 34 36 typedef struct { … … 240 242 Stars *rd_gsc PROTO((char *filename, unsigned int *nstars)); 241 243 int replace_match PROTO((Average *average, Measure *measure, Stars *star)); 242 int resort_threaded PROTO((AddstarClientOptions *options, SkyTable *sky)); 243 int resort_unthreaded PROTO((AddstarClientOptions *options, SkyTable *sky, int hostID, char *hostpath)); 244 int resort_unthreaded_catalogs PROTO((AddstarClientOptions *options, SkyList *skylist, int hostID, char *hostpath)); 244 int resort_catalogs PROTO((AddstarClientOptions *options, SkyTable *sky)); 245 int resort_catalogs_parallel PROTO((AddstarClientOptions *options, SkyList *sky)); 246 int resort_threaded PROTO((SkyList *skylist, int ForceSort)); 247 int resort_unthreaded PROTO((SkyList *skylist, int ForceSort)); 245 248 void resort_catalog PROTO((Catalog *catalog)); 246 249 void resort_catalog_old PROTO((Catalog *catalog)); 250 247 251 Stars *ReadStarsFITS PROTO((FILE *f, Header *header, Header *in_theader, unsigned int *nstars)); 248 252 Stars *ReadStarsTEXT PROTO((FILE *f, unsigned int *nstars)); … … 259 263 off_t *init_lensing_links PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing)); 260 264 off_t *init_missing_links PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing)); 261 off_t add_meas_link PROTO((Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE));262 off_t add_miss_link PROTO((Average *average, off_t *next_miss, off_t Nmissing));263 off_tadd_lens_link PROTO((Average *average, off_t *next_lens, off_t Nlensing, off_t NLENSING));265 int add_meas_link PROTO((Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE)); 266 int add_miss_link PROTO((Average *average, off_t *next_miss, off_t Nmissing)); 267 int add_lens_link PROTO((Average *average, off_t *next_lens, off_t Nlensing, off_t NLENSING)); 264 268 off_t *build_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure)); 265 269 off_t *build_lensing_links PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing)); … … 322 326 void *memrchr(const void *s, int c, size_t n); 323 327 int addstar_create_ID (); 328 int strextend (char *input, char *format,...); 329 330 void initMosaicCoords (); 331 void saveMosaicCoords (Coords *input); 332 324 333 325 334 /** -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/BoundaryTreeIO.c
r34260 r37822 1 1 # include "addstar.h" 2 3 /** this file is deprecated (functions moved to libdvo) ***/ 2 4 3 5 # define GET_COLUMN_NEW(OUT,NAME,TYPE) \ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/LoadData.c
r37343 r37822 33 33 // we need to perform that analysis here 34 34 GetZeroPointExposure (headers, headerSets, Nimages); 35 36 if (!options[0].mosaic) { 37 // we are requiring a single set of N x WRPs + 1 DIS per file set. 38 // NOTE: if the -mosaic was supplied, do not reset the mosaic coords here 39 initMosaicCoords (); 40 } 35 41 36 42 // now run through the images, interpret the headers and read the stars -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/LoadDataPMM.c
r36485 r37822 193 193 194 194 // XXX for now, we define a totally fake coordinate system centered on the plate center 195 strcpy (image[0].coords.ctype, "DEC--TAN");195 InitCoords (&image[0].coords, "DEC--TAN"); 196 196 197 197 image[0].coords.crval1 = pmm_get_ra (RA); … … 203 203 image[0].coords.crpix2 = 0.5*PLATE_NY; 204 204 image[0].coords.cdelt1 = image[0].coords.cdelt2 = 0.9 / 3600.0; 205 206 image[0].coords.pc1_1 = 0.0;207 image[0].coords.pc1_2 = 1.0;208 image[0].coords.pc2_1 = 1.0;209 image[0].coords.pc2_2 = 0.0;210 211 image[0].coords.Npolyterms = 0;212 memset (image[0].coords.polyterms, 0, 2*7*sizeof(float));213 205 214 206 image[0].NX = PLATE_NX; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/LoadStars.c
r28241 r37822 88 88 exit (1); 89 89 } 90 /* supplied photcode is incompatible with multi-chip images */ 91 if ((NheaderSets > 1) && options[0].mosaic) { 92 fprintf (stderr, "ERROR: -mosaic cannot be supplied to multiple images\n"); 93 exit (1); 94 } 90 95 91 96 // if these are SDSS data, load with SDSS-specific wrapper -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/MatchHeaders.c
r37343 r37822 64 64 if (!strcmp (exttype, "PS1_SV2")) goto keep; 65 65 if (!strcmp (exttype, "PS1_SV3")) goto keep; 66 if (!strcmp (exttype, "PS1_SV4")) goto keep; 66 67 67 68 if (!strcmp (exttype, "PS1_DV1")) goto keep; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/NewImage.c
r10939 r37822 33 33 goto reject; 34 34 } 35 saveMosaicCoords (mosaic); 35 36 } 36 37 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/ReadImageHeader.c
r37036 r37822 1 1 # include "addstar.h" 2 3 // for DIS/WRP sets, we need to save the DIS set and supply it to the WRP entries 4 static Coords *mosaic = NULL; 5 6 void initMosaicCoords () { 7 mosaic = NULL; 8 } 9 10 void saveMosaicCoords (Coords *input) { 11 ALLOCATE (mosaic, Coords, 1); 12 memcpy (mosaic, input, sizeof(Coords)); 13 } 2 14 3 15 /* read an image header corresponding to a CMF / CMP data block */ … … 54 66 /* only load astrometry, NAXIS1,2, and time if this is a MOSAIC_PHU (ctype is ....-DIS) */ 55 67 if (!strcmp (&image[0].coords.ctype[4], "-DIS")) { 56 RegisterMosaic(&image[0].coords);68 saveMosaicCoords (&image[0].coords); 57 69 return (TRUE); 58 70 } … … 79 91 } 80 92 if (!strcmp (&image[0].coords.ctype[4], "-WRP")) { 81 if (! isRegisteredMosaic()) {93 if (!mosaic) { 82 94 fprintf (stderr, "no mosaic for WRP image (use -mosaic)\n"); 83 95 return (FALSE); 84 96 } 97 image[0].coords.mosaic = mosaic; 85 98 } else { 86 99 /* force image to lie in 0-360 range */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/ReadStarsFITS.c
r37036 r37822 14 14 Stars *Convert_PS1_V5 PROTO((FTable *table, unsigned int *nstars)); 15 15 Stars *Convert_PS1_V5_Lensing PROTO((FTable *table, unsigned int *nstars)); 16 Stars *Convert_PS1_V5_Lensing_Alt PROTO((FTable *table, unsigned int *nstars)); 16 17 Stars *Convert_PS1_SV1 PROTO((FTable *table, unsigned int *nstars)); 17 18 Stars *Convert_PS1_SV1_Alt PROTO((FTable *table, unsigned int *nstars)); 18 19 Stars *Convert_PS1_SV2 PROTO((FTable *table, unsigned int *nstars)); 19 20 Stars *Convert_PS1_SV3 PROTO((FTable *table, unsigned int *nstars)); 21 Stars *Convert_PS1_SV4 PROTO((FTable *table, unsigned int *nstars)); 20 22 Stars *Convert_PS1_DV3 PROTO((FTable *table, unsigned int *nstars)); 21 23 Stars *Convert_PS1_DV4 PROTO((FTable *table, unsigned int *nstars)); … … 78 80 } 79 81 if (!strcmp (type, "PS1_V5")) { 80 if (table.header[0].Naxis[0] == 312) { 81 stars = Convert_PS1_V5_Lensing (&table, &Nstars); 82 } else { 83 stars = Convert_PS1_V5 (&table, &Nstars); 82 switch (table.header[0].Naxis[0]) { 83 case 232: 84 stars = Convert_PS1_V5 (&table, &Nstars); 85 break; 86 case 312: 87 stars = Convert_PS1_V5_Lensing_Alt (&table, &Nstars); 88 break; 89 case 320: 90 stars = Convert_PS1_V5_Lensing (&table, &Nstars); 91 break; 92 default: 93 fprintf (stderr, "invalid PS1_V5 table size %d\n", (int) table.header[0].Naxis[0]); 94 return NULL; 84 95 } 85 96 } … … 92 103 if (!strcmp (type, "PS1_SV3")) { 93 104 stars = Convert_PS1_SV3 (&table, &Nstars); 105 } 106 if (!strcmp (type, "PS1_SV4")) { 107 stars = Convert_PS1_SV4 (&table, &Nstars); 94 108 } 95 109 if (!strcmp (type, "PS1_DV3")) { … … 182 196 stars[i].measure.psfNdof = NAN_S_INT; // not provided by SMPDATA: 183 197 stars[i].measure.psfNpix = NAN_S_INT; // not provided by SMPDATA: 184 stars[i].measure.crNsigma = NAN; // not provided by SMPDATA:185 198 stars[i].measure.extNsigma = NAN; // not provided by SMPDATA: 186 199 … … 251 264 stars[i].measure.psfNdof = NAN_S_INT; // not provided by PS1_DEV_0: 252 265 stars[i].measure.psfNpix = NAN_S_INT; // not provided by PS1_DEV_0: 253 stars[i].measure.crNsigma = NAN; // not provided by PS1_DEV_0:254 266 stars[i].measure.extNsigma = NAN; // not provided by PS1_DEV_0: 255 267 … … 323 335 stars[i].measure.psfNdof = NAN_S_INT; // not provided by PS1_DEV_1: 324 336 stars[i].measure.psfNpix = NAN_S_INT; // not provided by PS1_DEV_1: 325 stars[i].measure.crNsigma = ps1data[i].crNsigma;326 337 stars[i].measure.extNsigma = ps1data[i].extNsigma; 327 338 … … 408 419 stars[i].measure.psfNdof = ps1data[i].psfNdof; 409 420 stars[i].measure.psfNpix = ps1data[i].psfNpix; 410 stars[i].measure.crNsigma = ps1data[i].crNsigma;411 421 stars[i].measure.extNsigma = ps1data[i].extNsigma; 412 422 … … 494 504 stars[i].measure.psfNdof = ps1data[i].psfNdof; 495 505 stars[i].measure.psfNpix = ps1data[i].psfNpix; 496 stars[i].measure.crNsigma = ps1data[i].crNsigma;497 506 stars[i].measure.extNsigma = ps1data[i].extNsigma; 498 507 … … 572 581 stars[i].measure.psfNdof = ps1data[i].psfNdof; 573 582 stars[i].measure.psfNpix = ps1data[i].psfNpix; 574 stars[i].measure.crNsigma = ps1data[i].crNsigma;575 583 stars[i].measure.extNsigma = ps1data[i].extNsigma; 576 584 … … 653 661 stars[i].measure.psfNdof = ps1data[i].psfNdof; 654 662 stars[i].measure.psfNpix = ps1data[i].psfNpix; 655 stars[i].measure.crNsigma = ps1data[i].crNsigma;656 663 stars[i].measure.extNsigma = ps1data[i].extNsigma; 657 664 … … 665 672 666 673 stars[i].measure.photFlags = ps1data[i].flags; 674 stars[i].measure.photFlags2 = ps1data[i].flags2; 667 675 668 676 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 738 746 stars[i].measure.psfNdof = ps1data[i].psfNdof; 739 747 stars[i].measure.psfNpix = ps1data[i].psfNpix; 740 stars[i].measure.crNsigma = ps1data[i].crNsigma;741 748 stars[i].measure.extNsigma = ps1data[i].extNsigma; 742 749 … … 750 757 751 758 stars[i].measure.photFlags = ps1data[i].flags; 759 stars[i].measure.photFlags2 = ps1data[i].flags2; 752 760 753 761 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 823 831 stars[i].measure.psfNdof = ps1data[i].psfNdof; 824 832 stars[i].measure.psfNpix = ps1data[i].psfNpix; 825 stars[i].measure.crNsigma = ps1data[i].crNsigma;826 833 stars[i].measure.extNsigma = ps1data[i].extNsigma; 827 834 … … 835 842 836 843 stars[i].measure.photFlags = ps1data[i].flags; 844 stars[i].measure.photFlags2 = ps1data[i].flags2; 837 845 838 846 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 908 916 stars[i].measure.psfNdof = ps1data[i].psfNdof; 909 917 stars[i].measure.psfNpix = ps1data[i].psfNpix; 910 stars[i].measure.crNsigma = ps1data[i].crNsigma;911 918 stars[i].measure.extNsigma = ps1data[i].extNsigma; 912 919 … … 920 927 921 928 stars[i].measure.photFlags = ps1data[i].flags; 929 stars[i].measure.photFlags2 = ps1data[i].flags2; 922 930 923 931 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 977 985 } 978 986 987 Stars *Convert_PS1_V5_Lensing_Alt (FTable *table, unsigned int *nstars) { 988 989 off_t Nstars; 990 unsigned int i; 991 double ZeroPt; 992 Stars *stars; 993 CMF_PS1_V5_Lensing_Alt *ps1data; 994 995 ps1data = gfits_table_get_CMF_PS1_V5_Lensing_Alt (table, &Nstars, NULL); 996 if (!ps1data) { 997 fprintf (stderr, "skipping inconsistent entry\n"); 998 return (NULL); 999 } 1000 ZeroPt = GetZeroPoint(); 1001 1002 ALLOCATE (stars, Stars, Nstars); 1003 for (i = 0; i < Nstars; i++) { 1004 InitStar (&stars[i]); 1005 stars[i].measure.Xccd = ps1data[i].X; 1006 stars[i].measure.Yccd = ps1data[i].Y; 1007 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX); 1008 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY); 1009 1010 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle); 1011 stars[i].measure.pltscale = ps1data[i].pltscale; 1012 1013 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1014 stars[i].measure.M = NAN; 1015 } else { 1016 stars[i].measure.M = ps1data[i].M + ZeroPt; 1017 } 1018 stars[i].measure.dM = ps1data[i].dM; 1019 stars[i].measure.dMcal = ps1data[i].dMcal; 1020 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 1021 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1022 1023 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1024 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1025 1026 // these fluxes are converted from counts to counts/sec in FilterStars.c 1027 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1028 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 1029 stars[i].measure.FluxKron = ps1data[i].kronFlux; 1030 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1031 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1032 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 1033 1034 stars[i].measure.Sky = ps1data[i].sky; 1035 stars[i].measure.dSky = ps1data[i].dSky; 1036 1037 stars[i].measure.psfChisq = ps1data[i].psfChisq; 1038 stars[i].measure.psfQF = ps1data[i].psfQF; 1039 stars[i].measure.psfQFperf = ps1data[i].psfQFperf; 1040 1041 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1042 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1043 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1044 1045 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 1046 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 1047 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 1048 1049 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx); 1050 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy); 1051 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy); 1052 1053 stars[i].measure.photFlags = ps1data[i].flags; 1054 stars[i].measure.photFlags2 = ps1data[i].flags2; 1055 1056 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1057 stars[i].measure.detID = ps1data[i].detID; 1058 1059 ALLOCATE (stars[i].lensing, Lensing, 1); 1060 dvo_lensing_init (stars[i].lensing); 1061 1062 stars[i].lensing->X11_sm_obj = ps1data[i].X11_sm_obj; 1063 stars[i].lensing->X12_sm_obj = ps1data[i].X12_sm_obj; 1064 stars[i].lensing->X22_sm_obj = ps1data[i].X22_sm_obj; 1065 stars[i].lensing->E1_sm_obj = ps1data[i].E1_sm_obj; 1066 stars[i].lensing->E2_sm_obj = ps1data[i].E2_sm_obj; 1067 1068 stars[i].lensing->X11_sh_obj = ps1data[i].X11_sh_obj; 1069 stars[i].lensing->X12_sh_obj = ps1data[i].X12_sh_obj; 1070 stars[i].lensing->X22_sh_obj = ps1data[i].X22_sh_obj; 1071 stars[i].lensing->E1_sh_obj = ps1data[i].E1_sh_obj; 1072 stars[i].lensing->E2_sh_obj = ps1data[i].E2_sh_obj; 1073 1074 stars[i].lensing->X11_sm_psf = ps1data[i].X11_sm_psf; 1075 stars[i].lensing->X12_sm_psf = ps1data[i].X12_sm_psf; 1076 stars[i].lensing->X22_sm_psf = ps1data[i].X22_sm_psf; 1077 stars[i].lensing->E1_sm_psf = ps1data[i].E1_sm_psf; 1078 stars[i].lensing->E2_sm_psf = ps1data[i].E2_sm_psf; 1079 1080 stars[i].lensing->X11_sh_psf = ps1data[i].X11_sh_psf; 1081 stars[i].lensing->X12_sh_psf = ps1data[i].X12_sh_psf; 1082 stars[i].lensing->X22_sh_psf = ps1data[i].X22_sh_psf; 1083 stars[i].lensing->E1_sh_psf = ps1data[i].E1_sh_psf; 1084 stars[i].lensing->E2_sh_psf = ps1data[i].E2_sh_psf; 1085 1086 // stars[i].lensing->F_ApR5 = ps1data[i].F_ApR5; 1087 // stars[i].lensing->dF_ApR5 = ps1data[i].dF_ApR5; 1088 // stars[i].lensing->sF_ApR5 = ps1data[i].sF_ApR5; 1089 // stars[i].lensing->fF_ApR5 = ps1data[i].fF_ApR5; 1090 // 1091 // stars[i].lensing->F_ApR6 = ps1data[i].F_ApR6; 1092 // stars[i].lensing->dF_ApR6 = ps1data[i].dF_ApR6; 1093 // stars[i].lensing->sF_ApR6 = ps1data[i].sF_ApR6; 1094 // stars[i].lensing->fF_ApR6 = ps1data[i].fF_ApR6; 1095 1096 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1097 stars[i].lensing->detID = ps1data[i].detID; 1098 1099 // the Average fields and the following Measure fields are set in FilterStars after 1100 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID. 1101 1102 // averef is set in find_matches 1103 1104 // dbFlags is zero on ingest. 1105 1106 // the following fields are currently not being set anywhere: t_msec 1107 } 1108 *nstars = Nstars; 1109 return (stars); 1110 } 1111 979 1112 Stars *Convert_PS1_SV1 (FTable *table, unsigned int *nstars) { 980 1113 … … 1038 1171 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1039 1172 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1040 stars[i].measure.crNsigma = ps1data[i].crNsigma;1041 1173 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1042 1174 … … 1050 1182 1051 1183 stars[i].measure.photFlags = ps1data[i].flags; 1184 stars[i].measure.photFlags2 = ps1data[i].flags2; 1052 1185 1053 1186 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 1120 1253 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1121 1254 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1122 stars[i].measure.crNsigma = ps1data[i].crNsigma;1123 1255 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1124 1256 … … 1132 1264 1133 1265 stars[i].measure.photFlags = ps1data[i].flags; 1266 stars[i].measure.photFlags2 = ps1data[i].flags2; 1134 1267 1135 1268 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 1202 1335 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1203 1336 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1204 stars[i].measure.crNsigma = ps1data[i].crNsigma;1205 1337 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1206 1338 … … 1214 1346 1215 1347 stars[i].measure.photFlags = ps1data[i].flags; 1348 stars[i].measure.photFlags2 = ps1data[i].flags2; 1216 1349 1217 1350 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 1284 1417 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1285 1418 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1286 stars[i].measure.crNsigma = ps1data[i].crNsigma;1287 1419 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1288 1420 … … 1296 1428 1297 1429 stars[i].measure.photFlags = ps1data[i].flags; 1430 stars[i].measure.photFlags2 = ps1data[i].flags2; 1298 1431 1299 1432 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 1310 1443 } 1311 1444 1312 Stars *Convert_PS1_ DV3(FTable *table, unsigned int *nstars) {1445 Stars *Convert_PS1_SV4 (FTable *table, unsigned int *nstars) { 1313 1446 1314 1447 off_t Nstars; … … 1316 1449 double ZeroPt; 1317 1450 Stars *stars; 1318 CMF_PS1_ DV3*ps1data;1319 1320 ps1data = gfits_table_get_CMF_PS1_ DV3(table, &Nstars, NULL);1451 CMF_PS1_SV4 *ps1data; 1452 1453 ps1data = gfits_table_get_CMF_PS1_SV4 (table, &Nstars, NULL); 1321 1454 if (!ps1data) { 1322 1455 fprintf (stderr, "skipping inconsistent entry\n"); … … 1348 1481 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1349 1482 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1350 1483 1351 1484 // these fluxes are converted from counts to counts/sec in FilterStars.c 1352 1485 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); … … 1363 1496 stars[i].measure.psfQF = ps1data[i].psfQF; 1364 1497 stars[i].measure.psfQFperf = ps1data[i].psfQFperf; 1498 1365 1499 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1366 1500 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1367 stars[i].measure.crNsigma = ps1data[i].crNsigma;1368 1501 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1369 1502 … … 1377 1510 1378 1511 stars[i].measure.photFlags = ps1data[i].flags; 1512 stars[i].measure.photFlags2 = ps1data[i].flags2; 1379 1513 1380 1514 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 1382 1516 1383 1517 // the Average fields and the following Measure fields are set in FilterStars after 1384 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID. 1385 1386 // averef is set in find_matches 1387 1388 // dbFlags is zero on ingest. 1518 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID, 1519 // averef is set in find_matches, dbFlags is zero on ingest. 1389 1520 1390 1521 // the following fields are currently not being set anywhere: t_msec … … 1394 1525 } 1395 1526 1396 Stars *Convert_PS1_DV 4(FTable *table, unsigned int *nstars) {1527 Stars *Convert_PS1_DV3 (FTable *table, unsigned int *nstars) { 1397 1528 1398 1529 off_t Nstars; … … 1400 1531 double ZeroPt; 1401 1532 Stars *stars; 1402 CMF_PS1_DV 4*ps1data;1403 1404 ps1data = gfits_table_get_CMF_PS1_DV 4(table, &Nstars, NULL);1533 CMF_PS1_DV3 *ps1data; 1534 1535 ps1data = gfits_table_get_CMF_PS1_DV3 (table, &Nstars, NULL); 1405 1536 if (!ps1data) { 1406 1537 fprintf (stderr, "skipping inconsistent entry\n"); … … 1408 1539 } 1409 1540 ZeroPt = GetZeroPoint(); 1410 1411 fprintf (stderr, "WARNING: Convert_PS1_DV4 not yet updated to match real format\n");1412 1541 1413 1542 ALLOCATE (stars, Stars, Nstars); … … 1451 1580 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1452 1581 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1453 stars[i].measure.crNsigma = ps1data[i].crNsigma;1454 1582 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1455 1583 … … 1463 1591 1464 1592 stars[i].measure.photFlags = ps1data[i].flags; 1593 stars[i].measure.photFlags2 = ps1data[i].flags2; 1465 1594 1466 1595 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 1480 1609 } 1481 1610 1482 1483 1611 Stars *Convert_PS1_DV4 (FTable *table, unsigned int *nstars) { 1612 1613 off_t Nstars; 1614 unsigned int i; 1615 double ZeroPt; 1616 Stars *stars; 1617 CMF_PS1_DV4 *ps1data; 1618 1619 ps1data = gfits_table_get_CMF_PS1_DV4 (table, &Nstars, NULL); 1620 if (!ps1data) { 1621 fprintf (stderr, "skipping inconsistent entry\n"); 1622 return (NULL); 1623 } 1624 ZeroPt = GetZeroPoint(); 1625 1626 fprintf (stderr, "WARNING: Convert_PS1_DV4 not yet updated to match real format\n"); 1627 1628 ALLOCATE (stars, Stars, Nstars); 1629 for (i = 0; i < Nstars; i++) { 1630 InitStar (&stars[i]); 1631 stars[i].measure.Xccd = ps1data[i].X; 1632 stars[i].measure.Yccd = ps1data[i].Y; 1633 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX); 1634 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY); 1635 1636 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle); 1637 stars[i].measure.pltscale = ps1data[i].pltscale; 1638 1639 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1640 stars[i].measure.M = NAN; 1641 } else { 1642 stars[i].measure.M = ps1data[i].M + ZeroPt; 1643 } 1644 stars[i].measure.dM = ps1data[i].dM; 1645 stars[i].measure.dMcal = ps1data[i].dMcal; 1646 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 1647 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1648 1649 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1650 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1651 1652 // these fluxes are converted from counts to counts/sec in FilterStars.c 1653 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1654 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 1655 stars[i].measure.FluxKron = ps1data[i].kronFlux; 1656 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1657 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1658 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 1659 1660 stars[i].measure.Sky = ps1data[i].sky; 1661 stars[i].measure.dSky = ps1data[i].dSky; 1662 1663 stars[i].measure.psfChisq = ps1data[i].psfChisq; 1664 stars[i].measure.psfQF = ps1data[i].psfQF; 1665 stars[i].measure.psfQFperf = ps1data[i].psfQFperf; 1666 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1667 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1668 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1669 1670 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 1671 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 1672 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 1673 1674 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx); 1675 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy); 1676 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy); 1677 1678 stars[i].measure.photFlags = ps1data[i].flags; 1679 stars[i].measure.photFlags2 = ps1data[i].flags2; 1680 1681 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1682 stars[i].measure.detID = ps1data[i].detID; 1683 1684 // the Average fields and the following Measure fields are set in FilterStars after 1685 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID. 1686 1687 // averef is set in find_matches 1688 1689 // dbFlags is zero on ingest. 1690 1691 // the following fields are currently not being set anywhere: t_msec 1692 } 1693 *nstars = Nstars; 1694 return (stars); 1695 } 1696 1697 1698 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/ReadStarsSDSS.c
r36485 r37822 201 201 202 202 // XXX for now, we define a totally fake coordinate system centered on the first listed star 203 strcpy (images[N].coords.ctype, "DEC--TAN"); 204 203 InitCoords (&images[N].coords, "DEC--TAN"); 205 204 images[N].coords.crval1 = stars[0].average.R; 206 205 images[N].coords.crval2 = stars[0].average.D; 207 208 206 images[N].coords.crpix1 = stars[0].measure.Xccd; 209 207 images[N].coords.crpix2 = stars[0].measure.Yccd; 210 208 images[N].coords.cdelt1 = images[N].coords.cdelt2 = 0.4 / 3600.0; 211 212 images[N].coords.pc1_1 = 0.0;213 images[N].coords.pc1_2 = 1.0;214 images[N].coords.pc2_1 = 1.0;215 images[N].coords.pc2_2 = 0.0;216 217 images[N].coords.Npolyterms = 0;218 memset (images[N].coords.polyterms, 0, 2*7*sizeof(float));219 209 220 210 images[N].NX = 2048; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/UpdateDatabase_Image.c
r27435 r37822 21 21 22 22 /* find correpsonding regions for image */ 23 RegisterMosaic (mosaic);24 23 skylist = NULL; 25 24 newlist = NULL; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/addstar.c
r37036 r37822 1 1 # include "addstar.h" 2 3 # define RESETTIME { gettimeofday (&startTimer, (void *) NULL); } 2 4 3 5 // LARGEFILES: this program currently limits Nstars (input file) to < 2^31 … … 18 20 SkyList *newlist = NULL; 19 21 20 double dtime;21 struct timeval start, stop;22 23 gettimeofday (&start, NULL);22 struct timeval startAddstar, stopAddstar; 23 gettimeofday (&startAddstar, (void *) NULL); 24 25 INITTIME; 24 26 25 27 SetSignals (); … … 40 42 41 43 if (options.mode == ADDSTAR_MODE_RESORT) { 42 if (NTHREADS == 0) { 43 resort_unthreaded (&options, sky, 0, NULL); 44 } else { 45 resort_threaded (&options, sky); 46 } 44 resort_catalogs (&options, sky); 47 45 exit (0); 48 46 } 47 48 MARKTIME ("init and config: %f sec\n", dtime); RESETTIME; 49 49 50 50 stars = NULL; … … 54 54 case ADDSTAR_MODE_IMAGE: 55 55 stars = LoadStars (argv[1], &Nstars, &images, &Nimages, &options); 56 MARKTIME ("load smf: %f sec\n", dtime); RESETTIME; 56 57 57 58 // set and update the imageID sequence … … 71 72 skylist = SkyListForStars (sky, -1, stars, Nstars); 72 73 break; 73 case ADDSTAR_MODE_RESORT:74 74 case ADDSTAR_MODE_REFCAT: 75 75 skylist = SkyListByPatch (sky, -1, &UserPatch); … … 132 132 } 133 133 } 134 if (VERBOSE) MARKTIME ("load cpt: %f sec\n", dtime); RESETTIME; 134 135 135 136 // Naves_disk == 0 implies an empty catalog file … … 161 162 if (Nsubset) free (subset); 162 163 break; 163 case ADDSTAR_MODE_RESORT: 164 if (options.nosort == 3) catalog.sorted = FALSE; 165 166 // no need to resort empty catalogs 167 if (catalog.Naves_disk == 0) { 168 dvo_catalog_unlock (&catalog); 169 dvo_catalog_free (&catalog); 170 continue; 171 } 172 173 if (OLD_RESORT) { 174 resort_catalog_old (&catalog); 175 } else { 176 resort_catalog (&catalog); 177 } 178 Nsubset = 1; 179 break; 180 } 164 } 165 if (VERBOSE) MARKTIME ("match stars: %f sec\n", dtime); RESETTIME; 166 181 167 /* report total updated values */ 182 168 Naverage += catalog.Naverage; … … 197 183 dvo_catalog_unlock (&catalog); 198 184 dvo_catalog_free (&catalog); 185 if (VERBOSE) MARKTIME ("save cpt: %f sec\n", dtime); RESETTIME; 199 186 200 187 if (options.mode == ADDSTAR_MODE_REFCAT) free (stars); … … 230 217 dvo_image_unlock (&db); /* unlock? */ 231 218 232 gettimeofday (&stop ,NULL);233 dtime = DTIME (stop, start);219 gettimeofday (&stopAddstar, (void *) NULL); 220 float dtime = DTIME (stopAddstar, startAddstar); 234 221 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for %5d stars (%5d matches), "OFF_T_FMT" average, "OFF_T_FMT" measure, "OFF_T_FMT" lensing\n", dtime, Nstars, Nmatch, Naverage, Nmeasure, Nlensing); 235 222 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/addstar_client.c
r33963 r37822 25 25 26 26 if (options.mode == ADDSTAR_MODE_RESORT) { 27 resort_ unthreaded (&options, sky, HOST_ID, HOSTDIR);27 resort_catalogs (&options, sky); 28 28 exit (0); 29 29 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/args.c
r37343 r37822 34 34 remove_argument (N, &argc, argv); 35 35 } 36 OLD_RESORT = FALSE; 37 if ((N = get_argument (argc, argv, "-old-resort"))) { 38 remove_argument (N, &argc, argv); 39 OLD_RESORT = TRUE; 40 } 41 36 42 if ((N = get_argument (argc, argv, "-create-id"))) { 37 43 options.mode = ADDSTAR_MODE_CREATE_ID; … … 169 175 exit (1); 170 176 } 171 RegisterMosaic(&MOSAIC);177 saveMosaicCoords (&MOSAIC); 172 178 remove_argument (N, &argc, argv); 173 179 gfits_free_header (&header); … … 356 362 // XXX for the moment, make this selection manual. it needs to be automatic 357 363 // based on the state of the SkyTable 364 HOST_ID = 0; 365 HOSTDIR = NULL; 358 366 PARALLEL = FALSE; 359 367 if ((N = get_argument (argc, argv, "-parallel"))) { … … 472 480 } 473 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 474 495 /** addstar modes: 475 496 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/args_client.c
r33963 r37822 83 83 exit (1); 84 84 } 85 RegisterMosaic(&MOSAIC);85 saveMosaicCoords (&MOSAIC); 86 86 remove_argument (N, &argc, argv); 87 87 gfits_free_header (&header); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/args_loadwise.c
r33963 r37822 53 53 } 54 54 55 enum {MODE_NONE, MODE_ALLWISE, MODE_ALLSKY, MODE_PRELIM}; 56 int MODE; 57 55 58 /* load the prelim data dump */ 56 ALLSKY = TRUE; 57 if ((N = get_argument (argc, argv, "-prelim"))) { 58 ALLSKY = FALSE; 59 MODE = MODE_ALLWISE; 60 if ((N = get_argument (argc, argv, "-mode"))) { 61 MODE = MODE_NONE; 62 remove_argument (N, &argc, argv); 63 if (!strcasecmp(argv[N], "allwise")) MODE = MODE_ALLWISE; 64 if (!strcasecmp(argv[N], "allsky")) MODE = MODE_ALLSKY; 65 if (!strcasecmp(argv[N], "prelim")) MODE = MODE_PRELIM; 66 if (MODE == MODE_NONE) { 67 fprintf (stderr, "invalid mode: %s\n", argv[N]); 68 exit (2); 69 } 59 70 remove_argument (N, &argc, argv); 60 71 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/args_parallel_client.c
r33963 r37822 87 87 } 88 88 89 OLD_RESORT = FALSE; 90 if ((N = get_argument (argc, argv, "-old-resort"))) { 91 remove_argument (N, &argc, argv); 92 OLD_RESORT = TRUE; 93 } 94 89 95 /* extra error messages */ 90 96 VERBOSE = FALSE; … … 118 124 exit (2); 119 125 } 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 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/build_links.c
r37036 r37822 47 47 48 48 if (N >= Nmeasure) { 49 fprintf (stderr, "overflow in init_measure_links\n"); 50 abort (); 49 myAbort ("overflow in init_measure_links\n"); 51 50 } 52 51 } … … 102 101 103 102 /* average[].measureOffset, average[].Nmeasure are valid within an addstar run */ 104 off_t add_meas_link (Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE) {103 int add_meas_link (Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE) { 105 104 106 105 off_t k, m; … … 134 133 } 135 134 136 /* Missing does not carry enough information to reconstruct the links137 we must always save the missing table, if it exists */138 139 135 Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next_meas) { 140 136 141 off_t i, k, n, N;137 int i, k, n, N; 142 138 Measure *tmpmeasure; 143 139 … … 149 145 average[i].measureOffset = N; 150 146 for (k = 0; k < average[i].Nmeasure; k++, N++) { 151 if (n == -1) abort();147 if (n == -1) myAbortF("invalid measureOffset for ave %d, measureOffset %d, measure %d\n", i, average[i].measureOffset, k); 152 148 tmpmeasure[N] = measure[n]; 153 if (measure[n].averef != i) abort();149 if (measure[n].averef != i) myAbortF("invalid averef for ave %d, measureOffset %d, measure %d, averef %d\n", i, average[i].measureOffset, k, measure[n].averef); 154 150 tmpmeasure[N].averef = i; 155 151 n = next_meas[n]; … … 159 155 return (tmpmeasure); 160 156 } 157 158 /*******************************************************************************************/ 161 159 162 160 /* build the initial links assuming the table is sorted */ … … 176 174 next_miss[N] = -1; 177 175 if (N >= Nmissing) { 178 fprintf (stderr, "overflow in init_missing_links"); 179 abort (); 176 myAbort ("overflow in init_missing_links"); 180 177 } 181 178 N++; … … 186 183 } 187 184 188 off_t add_miss_link (Average *average, off_t *next_miss, off_t Nmissing) {185 int add_miss_link (Average *average, off_t *next_miss, off_t Nmissing) { 189 186 190 187 off_t k, m; … … 205 202 } 206 203 204 /* Missing does not carry enough information to reconstruct the links 205 we must always save the missing table, if it exists */ 206 207 207 Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss) { 208 208 … … 251 251 252 252 if (N >= Nlensing) { 253 fprintf (stderr, "overflow in init_lensing_links\n"); 254 abort (); 253 myAbort ("overflow in init_lensing_links\n"); 255 254 } 256 255 N++; … … 307 306 308 307 /* average[].lensingOffset, average[].Nlensing are valid within an addstar run */ 309 off_t add_lens_link (Average *average, off_t *next_lens, off_t Nlensing, off_t NLENSING) {308 int add_lens_link (Average *average, off_t *next_lens, off_t Nlensing, off_t NLENSING) { 310 309 311 310 off_t k, m; … … 341 340 Lensing *sort_lensing (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next_lens) { 342 341 343 off_t i, k, n, N;342 int i, k, n, N; 344 343 Lensing *tmplensing; 345 344 … … 352 351 average[i].lensingOffset = N; 353 352 for (k = 0; k < average[i].Nlensing; k++, N++) { 354 if (n == -1) abort();353 if (n == -1) myAbortF("invalid lensingOffset for ave %d, lensingOffset %d, lensing %d\n", i, average[i].lensingOffset, k); 355 354 tmplensing[N] = lensing[n]; 356 if (lensing[n].averef != i) abort();355 if (lensing[n].averef != i) myAbortF("invalid averef for ave %d, lensingOffset %d, lensing %d, averef %d\n", i, average[i].lensingOffset, k, lensing[n].averef); 357 356 tmplensing[N].averef = i; 358 357 n = next_lens[n]; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/fakeimage.c
r37036 r37822 3 3 Image *fakeimage (char *rootname, off_t *Nimage, int photcode) { 4 4 5 int i, j,Nx, Ny, Nchips;5 int i, Nx, Ny, Nchips; 6 6 double pltscale, pixscale; 7 7 double Rmin, Rmax, Dmin, Dmax; … … 33 33 34 34 /* create a mosaic distortion structure */ 35 strcpy (MOSAIC.ctype, "DEC--DIS");35 InitCoords (&MOSAIC, "DEC--DIS"); 36 36 MOSAIC.crval1 = FAKE_RA; 37 37 MOSAIC.crval2 = FAKE_DEC; 38 39 MOSAIC.crpix1 = MOSAIC.crpix2 = 0.0;40 38 41 39 /* mosaic 'pixels' are millimeters */ … … 49 47 50 48 MOSAIC.Npolyterms = 3; 51 for (i = 0; i < 7; i++) {52 MOSAIC.polyterms[i][0] = 0;53 MOSAIC.polyterms[i][1] = 0;54 }55 49 ScanConfig (config, "DPLATE_X", "%lf", 0, &pltscale); 56 50 MOSAIC.polyterms[3][0] = pltscale; // L : X^3 Y^0 … … 59 53 MOSAIC.polyterms[4][1] = pltscale; // M : X^0 Y^0 60 54 MOSAIC.polyterms[6][1] = pltscale; // M : X^2 Y^0 61 62 RegisterMosaic (&MOSAIC);63 55 64 56 /* some basic data about the chisp */ … … 85 77 strcpy (image[i+1].name, name); 86 78 87 strcpy (image[i+1].coords.ctype, "DEC--WRP");79 InitCoords (&image[i+1].coords, "DEC--WRP"); 88 80 89 81 image[i+1].coords.crval1 = dX*pixscale; 90 82 image[i+1].coords.crval2 = dY*pixscale; 91 92 image[i+1].coords.crpix1 = image[i+1].coords.crpix2 = 0.0; 83 93 84 image[i+1].coords.cdelt1 = image[i+1].coords.cdelt2 = pixscale; 94 85 95 image[i+1].coords.pc1_1 = 1.0; 96 image[i+1].coords.pc1_2 = 0.0; 97 image[i+1].coords.pc2_1 = 0.0; 98 image[i+1].coords.pc2_2 = 1.0; 99 100 image[i+1].coords.Npolyterms = 0; 101 for (j = 0; j < 7; j++) { 102 image[i+1].coords.polyterms[j][0] = 0; 103 image[i+1].coords.polyterms[j][1] = 0; 104 } 86 image[i+1].coords.mosaic = &MOSAIC; 105 87 106 88 image[i+1].sidtime = 0.0; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/find_matches.c
r37036 r37822 53 53 * coordops.update.c). We use the center of the region (catalog) for crval1,2. 54 54 */ 55 InitCoords (&tcoords, "DEC--ARC"); 55 56 tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax); 56 57 if (region[0].Dmax < 90) { … … 59 60 tcoords.crval2 = 90.0; 60 61 } 61 tcoords.crpix1 = 0;62 tcoords.crpix2 = 0;63 62 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 64 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;65 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;66 tcoords.Npolyterms = 1;67 strcpy (tcoords.ctype, "DEC--ARC");68 63 69 64 /* build spatial index (RA sort) referencing input array sequence */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/find_matches_closest.c
r37036 r37822 53 53 * far from the projection pole. We use the center of the region (catalog) for crval1,2. 54 54 */ 55 InitCoords (&tcoords, "DEC--ARC"); 55 56 tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax); 56 57 if (region[0].Dmax < 90) { … … 59 60 tcoords.crval2 = 90.0; 60 61 } 61 tcoords.crpix1 = 0;62 tcoords.crpix2 = 0;63 62 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 64 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;65 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;66 tcoords.Npolyterms = 1;67 strcpy (tcoords.ctype, "DEC--ARC");68 63 69 64 /* build spatial index (RA sort) referencing input array sequence */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/find_matches_closest_refstars.c
r37036 r37822 47 47 * far from the projection pole. We use the center of the region (catalog) for crval1,2. 48 48 */ 49 InitCoords (&tcoords, "DEC--ARC"); 49 50 tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax); 50 51 if (region[0].Dmax < 90) { … … 53 54 tcoords.crval2 = 90.0; 54 55 } 55 tcoords.crpix1 = 0.0;56 tcoords.crpix2 = 0.0;57 56 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 58 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;59 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;60 tcoords.Npolyterms = 0;61 strcpy (tcoords.ctype, "DEC--ARC");62 57 63 58 /* build spatial index (RA sort) referencing input array sequence */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/find_matches_refstars.c
r37036 r37822 51 51 /* project onto rectilinear grid with 1 arcsec pixels, sort by X */ 52 52 /* reference for coords is catalog center */ 53 InitCoords (&tcoords, "DEC--ZEA"); 53 54 tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax); 54 55 tcoords.crval2 = 0.5*(region[0].Dmin + region[0].Dmax); 55 tcoords.crpix1 = tcoords.crpix2 = 0.0;56 56 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 57 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;58 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;59 strcpy (tcoords.ctype, "DEC--ZEA");60 tcoords.Npolyterms = 0;61 57 62 58 for (i = 0; i < Nstars; i++) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/find_missing.c
r10937 r37822 14 14 REALLOCATE (catalog[0].missing, Missing, NMISS); 15 15 } 16 if (!FindMosaicForImage (overlap, Noverlap, j)) continue;17 16 if (!in_image (catalog[0].average[Nave].R, catalog[0].average[Nave].D, &overlap[j])) continue; 18 17 add_miss_link (&catalog[0].average[Nave], next_miss, Nmiss); … … 27 26 /* add reference for undetected catalog stars */ 28 27 /* XXX allow this option only for single images? */ 29 if (!strcmp (&image[0].coords.ctype[4], "-WRP")) RegisterMosaic (mosaic);28 if (!strcmp (&image[0].coords.ctype[4], "-WRP")) image[0].coords = mosaic; 30 29 for (j = 0; (j < Nave) && !options.skip_missed; j++) { 31 30 n = N2[j]; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/findskycell.c
r37036 r37822 27 27 int apply_tree (char *treefile, char *datafile); 28 28 29 float SCALE = 1.0;30 int NX_SUB = 1;31 int NY_SUB = 1;29 float SCALE = 1.0; 30 float NX_SUB = 1.0; 31 float NY_SUB = 1.0; 32 32 33 33 double R_MIN = 0.0; … … 217 217 ALLOCATE (tree.Xo, double *, tree.Nzone); 218 218 ALLOCATE (tree.Yo, double *, tree.Nzone); 219 ALLOCATE (tree.dX, int *, tree.Nzone);220 ALLOCATE (tree.dY, int *, tree.Nzone);219 ALLOCATE (tree.dX, float *, tree.Nzone); 220 ALLOCATE (tree.dY, float *, tree.Nzone); 221 221 ALLOCATE (tree.cell, int *, tree.Nzone); 222 222 ALLOCATE (tree.name, char **, tree.Nzone); … … 251 251 ALLOCATE (tree.Xo[zone], double, tree.NBAND[zone]); 252 252 ALLOCATE (tree.Yo[zone], double, tree.NBAND[zone]); 253 ALLOCATE (tree.dX[zone], int, tree.NBAND[zone]);254 ALLOCATE (tree.dY[zone], int, tree.NBAND[zone]);253 ALLOCATE (tree.dX[zone], float, tree.NBAND[zone]); 254 ALLOCATE (tree.dY[zone], float, tree.NBAND[zone]); 255 255 ALLOCATE (tree.cell[zone], int, tree.NBAND[zone]); 256 256 ALLOCATE (tree.name[zone], char *, tree.NBAND[zone]); … … 260 260 tree.Xo[zone][band] = NAN; 261 261 tree.Yo[zone][band] = NAN; 262 tree.dX[zone][band] = -1;263 tree.dY[zone][band] = -1;262 tree.dX[zone][band] = NAN; 263 tree.dY[zone][band] = NAN; 264 264 tree.cell[zone][band] = -1; 265 265 ALLOCATE (tree.name[zone][band], char, BOUNDARY_TREE_NAME_LENGTH); … … 286 286 REALLOCATE (tree.Xo[zone], double, tree.NBAND[zone]); 287 287 REALLOCATE (tree.Yo[zone], double, tree.NBAND[zone]); 288 REALLOCATE (tree.dX[zone], int, tree.NBAND[zone]);289 REALLOCATE (tree.dY[zone], int, tree.NBAND[zone]);288 REALLOCATE (tree.dX[zone], float, tree.NBAND[zone]); 289 REALLOCATE (tree.dY[zone], float, tree.NBAND[zone]); 290 290 REALLOCATE (tree.cell[zone], int, tree.NBAND[zone]); 291 291 REALLOCATE (tree.name[zone], char *, tree.NBAND[zone]); … … 295 295 tree.Xo[zone][band] = NAN; 296 296 tree.Yo[zone][band] = NAN; 297 tree.dX[zone][band] = -1;298 tree.dY[zone][band] = -1;297 tree.dX[zone][band] = NAN; 298 tree.dY[zone][band] = NAN; 299 299 tree.cell[zone][j] = -1; 300 300 ALLOCATE (tree.name[zone][j], char, BOUNDARY_TREE_NAME_LENGTH); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/loadsupercos_plates.c
r36485 r37822 92 92 image[Nimage].Radius = NAN; 93 93 94 snprintf (image[Nimage].name, 121, "SCOS.%02d.%06d", survey_id, plate_id);94 snprintf (image[Nimage].name, DVO_IMAGE_NAME_LEN, "SCOS.%02d.%06d", survey_id, plate_id); 95 95 image[Nimage].imageID = Nimage + 1; 96 96 image[Nimage].externID = plate_id; … … 118 118 119 119 // for now, we define a fake coordinate system based on the boresite center 120 strcpy (image[Nimage].coords.ctype, "DEC--TAN");120 InitCoords (&image[Nimage].coords, "DEC--TAN"); 121 121 122 122 image[Nimage].coords.crval1 = RAo; … … 126 126 image[Nimage].coords.crpix2 = 0.5*image[Nimage].NY; 127 127 image[Nimage].coords.cdelt1 = image[Nimage].coords.cdelt2 = scale; 128 129 image[Nimage].coords.pc1_1 = 0.0;130 image[Nimage].coords.pc1_2 = 1.0;131 image[Nimage].coords.pc2_1 = 1.0;132 image[Nimage].coords.pc2_2 = 0.0;133 134 image[Nimage].coords.Npolyterms = 0;135 memset (image[Nimage].coords.polyterms, 0, 2*7*sizeof(float));136 128 137 129 Nimage ++; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/loadwise.c
r33963 r37822 40 40 for (i = 1; i < argc; i++) { 41 41 fprintf (stderr, "loading %s\n", argv[i]); 42 loadwise_rawdata (skylist, argv[i], options , ALLSKY);42 loadwise_rawdata (skylist, argv[i], options); 43 43 } 44 44 exit (0); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/loadwise_rawdata.c
r34088 r37822 10 10 # define DEBUG 0 11 11 12 int loadwise_rawdata (SkyList *skytable, char *filename, AddstarClientOptions options , int ALLSKY) {12 int loadwise_rawdata (SkyList *skytable, char *filename, AddstarClientOptions options) { 13 13 14 14 int i, j, verbose; … … 159 159 stars[Nstars+3][0].average.D = tstars[j].D; 160 160 161 if (ALLSKY) { 162 loadwise_star_allsky (&stars[Nstars], &buffer[offset], Nbyte - offset); 163 } else { 164 loadwise_star_prelim (&stars[Nstars], &buffer[offset], Nbyte - offset); 161 switch (MODE) { 162 case MODE_PRELIM: 163 loadwise_star_prelim (&stars[Nstars], &buffer[offset], Nbyte - offset); 164 break; 165 case MODE_ALLSKY: 166 loadwise_star_allsky (&stars[Nstars], &buffer[offset], Nbyte - offset); 167 break; 168 case MODE_ALLWISE: 169 default: 170 // loadwise_star_allwise (&stars[Nstars], &buffer[offset], Nbyte - offset); 171 break; 165 172 } 166 173 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/loadwise_star_full.c
r33963 r37822 10 10 int setWISE_sat_flag (Stars *star, char *ptr); 11 11 int setWISE_blend_flag (Stars **star, char *ptr); 12 13 // fill in the data for a WISE quad star. takes a pointer to the start of the line the 14 // RA and DEC have already been set 15 int loadwise_star_allwise (Stars **star, char *line, int Nmax) { 16 17 int i; 18 char *ptr; 19 20 if (line == NULL) Shutdown ("format error in WISE"); 21 22 ptr = line; 23 24 // I can assign dRA and dDEC to dX and dY if I can consistently set posangle and pltscale 25 star[0][0].measure.posangle = 0.0; 26 star[0][0].measure.pltscale = 1.0; 27 28 ptr = skipNbounds (ptr, '|', 3, Nmax); // skip: desig, ra, dec, 29 star[0][0].measure.dXccd = ToShortPixels(strtod (ptr, NULL)); // sig_ra 30 ptr = nextWISEfield (ptr); 31 star[0][0].measure.dYccd = ToShortPixels(strtod (ptr, NULL)); // sig_dec 32 ptr = nextWISEfield (ptr); 33 34 // we only know a single set of values for all 4 bands 35 for (i = 1; i < 4; i++) { 36 star[i][0].measure.dXccd = star[0][0].measure.dXccd; 37 star[i][0].measure.dYccd = star[0][0].measure.dYccd; 38 star[i][0].measure.posangle = star[0][0].measure.posangle; 39 star[i][0].measure.pltscale = star[0][0].measure.pltscale; 40 } 41 ptr = skipNbounds (ptr, '|', 5, Nmax); // skip: sig_radec, glon, glat, elon, elat 42 43 star[0][0].measure.Xccd = strtod (ptr, NULL); // wx 44 ptr = nextWISEfield (ptr); // skip wx 45 star[0][0].measure.Yccd = strtod (ptr, NULL); // wy 46 ptr = nextWISEfield (ptr); // skip wy 47 48 for (i = 1; i < 4; i++) { 49 star[i][0].measure.Xccd = star[0][0].measure.Xccd; 50 star[i][0].measure.Yccd = star[0][0].measure.Yccd; 51 } 52 ptr = skipNbounds (ptr, '|', 4, Nmax); // skip: cntr, source_id, coadd_id, src 53 54 // W1 55 for (i = 0; i < 4; i++) { 56 char *endpoint; 57 star[i][0].measure.M = strtod (ptr, &endpoint); // w?mpro 58 if (endpoint == ptr) { 59 star[i][0].measure.M = NAN; 60 } 61 ptr = nextWISEfield (ptr); 62 star[i][0].measure.dM = strtod (ptr, &endpoint); // w?sigmpro 63 if (endpoint == ptr) { 64 star[i][0].measure.dM = NAN; 65 } 66 ptr = skipNbounds (ptr, '|', 2, Nmax); // skip: w?sigmpro, w?snr 67 star[i][0].measure.psfChisq = strtod (ptr, NULL); // w?rchi2 68 ptr = nextWISEfield (ptr); // skip : w1rchi2 69 70 // init the photFlags field 71 star[i][0].measure.photFlags = 0; 72 } 73 74 ptr = nextWISEfield (ptr); // skip: rchi2 75 76 // set blend flags for all 4 measures 77 setWISE_blend_flag (star, ptr); // nb & na both used here 78 ptr = skipNbounds (ptr, '|', 2, Nmax); // skip: nb, na 79 80 for (i = 0; i < 4; i++) { 81 setWISE_sat_flag (star[i], ptr); // w1sat 82 ptr = nextWISEfield (ptr); 83 } 84 ptr = nextWISEfield (ptr); // skip satnum 85 86 ptr = skipNbounds (ptr, '|', 15, Nmax); // skip pm info 87 88 for (i = 0; i < 4; i++) { 89 setWISE_cc_flag (star[i], ptr[i]); // cc_flags 90 } 91 ptr = nextWISEfield (ptr); // skip cc_flags 92 ptr = nextWISEfield (ptr); // skip rel 93 94 // set ext flags for all 4 measures 95 setWISE_ext_flag_allsky (star, ptr[0]); // ext_flg 96 ptr = nextWISEfield (ptr); // skip ext_flags 97 98 for (i = 0; i < 4; i++) { 99 setWISE_var_flag_allsky (star[i], ptr[i]); // var_flg 100 } 101 ptr = nextWISEfield (ptr); // skip var_flags 102 103 for (i = 0; i < 4; i++) { 104 setWISE_ph_qual (star[i], ptr[i]); // ph_qual 105 } 106 107 ptr = skipNbounds (ptr, '|', 158, Nmax); // skip: det_bit, moon_lev, w?nm, w?m, w?cov, etc, etc. 108 // w?frtr dropped, (-4), use_src, best_use_cntr, ngrp added (+3), w?dmag dropped, w?k added, 109 110 for (i = 0; i < 4; i++) { 111 ptr = skipNbounds (ptr, '|', 8, Nmax); // skip: w?magp, w?sigp1,2, w?dmag, w?ndf, w?m1q, w?mjdmin, w?mjdmax 112 113 // double mjdmin = strtod (ptr, NULL); // mjd min 114 // ptr = nextWISEfield (ptr); // skip 115 // double mjdmax = strtod (ptr, NULL); // mjd max 116 // ptr = nextWISEfield (ptr); // skip mjd max 117 double mjdmean = strtod (ptr, NULL); // mjd mean 118 ptr = nextWISEfield (ptr); // skip mjd mean 119 120 // fprintf (stderr, "w%d mjd: %f\n", i, mjdmean); 121 122 // the release is based on data taken in the period 14 January 2010 to 29 April 2010 123 if (mjdmean == 0.0) { 124 star[i][0].measure.t = 0; 125 } else { 126 star[i][0].measure.t = ohana_mjd_to_sec (mjdmean); 127 } 128 } 129 130 star[0][0].measure.photcode = WISE_W1; 131 star[0][0].measure.detID = 0; 132 star[0][0].measure.imageID = 0; 133 134 star[1][0].measure.photcode = WISE_W2; 135 star[1][0].measure.detID = 0; 136 star[1][0].measure.imageID = 0; 137 138 star[2][0].measure.photcode = WISE_W3; 139 star[2][0].measure.detID = 0; 140 star[2][0].measure.imageID = 0; 141 142 star[3][0].measure.photcode = WISE_W4; 143 star[3][0].measure.detID = 0; 144 star[3][0].measure.imageID = 0; 145 146 return TRUE; 147 } 12 148 13 149 // there are slight format differences between the prelim data dump and the allsky data dump: -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/mkcmf.c
r37036 r37822 31 31 static Coords coords; 32 32 33 static char reserved[] = "Reserved space. This line can be used to add a new FITS card."; 34 33 35 int main (int argc, char **argv) { 34 36 … … 198 200 199 201 /* bore site center guess */ 200 strcpy (coords.ctype, "DEC--TAN");202 InitCoords (&coords, "DEC--TAN"); 201 203 coords.crval1 = RA; 202 204 coords.crval2 = DEC; … … 206 208 coords.cdelt1 = 0.25/3600.0; 207 209 coords.cdelt2 = 0.25/3600.0; 208 209 coords.pc1_1 = 1;210 coords.pc2_2 = 1;211 coords.pc1_2 = 0;212 coords.pc2_1 = 0;213 coords.Npolyterms = 1;214 210 215 211 // load stars and generate complete output fields … … 298 294 gfits_modify (&header, "NASTRO", "%d", 1, 100); 299 295 300 if (imageID == -1) imageID = 1000 .0*drand48();301 if (sourceID == -1) sourceID = 100 .0*drand48();296 if (imageID == -1) imageID = 100000.0*drand48(); 297 if (sourceID == -1) sourceID = 1000.0*drand48(); 302 298 gfits_modify (&header, "IMAGEID", "%d", 1, imageID); 303 299 gfits_modify (&header, "SOURCEID", "%d", 1, sourceID); … … 305 301 PutCoords (&coords, &header); 306 302 gfits_modify (&header, "EXTNAME", "%s", 1, exthead); 303 304 int i; 305 for (i = 1; i < 32; i++) { 306 gfits_modify_alt (&header, "COMMENT", "%C", i, reserved); 307 } 307 308 308 309 ftable.header = &theader; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/resort_catalog.c
r37036 r37822 4 4 void resort_catalog_measure (Catalog *catalog); 5 5 void resort_catalog_lensing (Catalog *catalog); 6 void resort_catalog_starpar (Catalog *catalog); 6 7 7 8 void resort_catalog_old (Catalog *catalog) { 8 9 9 off_t *next_meas ;10 off_t Naves, Nmeas ;10 off_t *next_meas, *next_lens; 11 off_t Naves, Nmeas, Nlens; 11 12 12 13 if (catalog[0].sorted == TRUE) return; … … 16 17 /* internal counters */ 17 18 Nmeas = catalog[0].Nmeasure; 19 Nlens = catalog[0].Nlensing; 18 20 Naves = catalog[0].Naverage; 19 21 20 22 /* set up pointers for linked list of measure, missing */ 21 23 next_meas = build_measure_links (catalog[0].average, Naves, catalog[0].measure, Nmeas); 24 next_lens = build_lensing_links (catalog[0].average, Naves, catalog[0].lensing, Nlens); 22 25 23 26 catalog[0].sorted = TRUE; 24 27 catalog[0].measure = sort_measure (catalog[0].average, Naves, catalog[0].measure, Nmeas, next_meas); 28 catalog[0].lensing = sort_lensing (catalog[0].average, Naves, catalog[0].lensing, Nlens, next_lens); 25 29 26 30 MARKTIME (" match time %9.4f sec for %7lld measures, %6lld average\n", dtime, (long long) Nmeas, (long long) Naves); … … 35 39 resort_catalog_measure (catalog); 36 40 resort_catalog_lensing (catalog); 41 resort_catalog_starpar (catalog); 37 42 } 38 43 … … 79 84 myAssert(average[averageSeq[i]].catID == measure[measureSeq[i]].catID, "object / detection mismatch"); 80 85 # if (1) 81 myAssert(average[averageSeq[i]].objID == measure[measureSeq[i]].objID, "object / detection mismatch"); 86 // myAssert(average[averageSeq[i]].objID == measure[measureSeq[i]].objID, "object / detection mismatch"); 87 // check if the objID is correct. if not, check if it is byte-swapped (this has happened) and repair if so. 88 // otherwise, abort 89 if (average[averageSeq[i]].objID != measure[measureSeq[i]].objID) { 90 fprintf (stderr, "object / detection mismatch average.objID = %d, measure.objID = %d, catID: %d, detID: %d", 91 average[averageSeq[i]].objID, measure[measureSeq[i]].objID, 92 measure[measureSeq[i]].catID, measure[measureSeq[i]].detID); 93 int objIDalt = measure[measureSeq[i]].objID; 94 char *byte = (char *) &objIDalt; 95 char tmp; 96 tmp = byte[0]; byte[0] = byte[3]; byte[3] = tmp; 97 tmp = byte[1]; byte[1] = byte[2]; byte[2] = tmp; 98 if (average[averageSeq[i]].objID == objIDalt) { 99 fprintf (stderr, "objID is byte-swapped, repairing\n"); 100 measure[measureSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this... 101 } else if (measure[measureSeq[i]].objID == 0) { 102 fprintf (stderr, "objID is 0, repairing\n"); 103 measure[measureSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this... 104 } else { 105 myAbort ("objID is NOT byte-swapped, aborting\n"); 106 } 107 } 82 108 # else 83 109 // for reasons I do not understand, the mini dvodbs generated on stsci1X had a handful of detections with an inconsistency between averef and objID. … … 311 337 } 312 338 339 void resort_catalog_starpar (Catalog *catalog) { 340 341 off_t Naverage, Nstarpar; 342 StarPar *starpar; 343 Average *average; 344 off_t i, j, N, currentAve; 345 346 off_t *starparSeq = NULL; 347 off_t *averageSeq = NULL; 348 StarPar *starparTMP = NULL; 349 350 // struct timeval start, stop; 351 // gettimeofday (&start, NULL); 352 353 /* internal counters */ 354 Nstarpar = catalog[0].Nstarpar; 355 Naverage = catalog[0].Naverage; 356 357 if (!Nstarpar) return; 358 359 starpar = catalog[0].starpar; 360 average = catalog[0].average; 361 362 // we have a table of average objects and an unsorted table of measurements. each measurement 363 // has a reference to the average object sequence (as well as an ID) 364 // starpar[i].averef -> average[averef] 365 // starpar[i].objID = average[averef].objID 366 // starpar[i].catID = average[averef].catID 367 368 // we want a sorted starpar array with all averef entries in sequence 369 370 ALLOCATE (starparSeq, off_t, Nstarpar); 371 ALLOCATE (averageSeq, off_t, Nstarpar); 372 373 for (i = 0; i < Nstarpar; i++) { 374 starparSeq[i] = i; 375 averageSeq[i] = starpar[i].averef; 376 377 if (catalog[0].catformat >= DVO_FORMAT_PS1_V1) { 378 // earlier formats did not carry the objID or catID, so they are not available (we could assign on load, but we don't) 379 myAssert(average[averageSeq[i]].catID == starpar[starparSeq[i]].catID, "object / detection mismatch"); 380 # if (1) 381 myAssert(average[averageSeq[i]].objID == starpar[starparSeq[i]].objID, "object / detection mismatch"); 382 # else 383 // for reasons I do not understand, the mini dvodbs generated on stsci1X had a handful of detections with an inconsistency between averef and objID. 384 // this happened for 28 detections in the dbs on /data/stsci1?.0/eugene/dvo3pi.20130616, but not at all (as far as I know) in the rest of LAP DVO 385 if (average[averageSeq[i]].objID != starpar[starparSeq[i]].objID) { 386 fprintf (stderr, "R"); 387 starpar[starparSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this... 388 } 389 # endif 390 } 391 } 392 393 // check that averageSeq is now in order 394 // for (i = 1; i < Nstarpar; i++) { 395 // if (averageSeq[i] < averageSeq[i-1]) { 396 // fprintf (stderr, "%d ", (int) i); 397 // } 398 // } 399 // fprintf (stderr, "\n"); 400 401 SortAveMatch(starparSeq, averageSeq, Nstarpar); 402 // MARKTIME("sort : %f sec\n", dtime); 403 404 // check that averageSeq is now in order 405 // for (i = 1; i < Nstarpar; i++) { 406 // if (averageSeq[i] < averageSeq[i-1]) { 407 // fprintf (stderr, "%d ", (int) i); 408 // } 409 // } 410 // fprintf (stderr, "\n"); 411 412 // copy the starpar entries in the sorted order 413 ALLOCATE (starparTMP, StarPar, Nstarpar); 414 for (i = 0; i < Nstarpar; i++) { 415 j = starparSeq[i]; 416 starparTMP[i] = starpar[j]; 417 } 418 // MARKTIME("assign starpar : %f sec\n", dtime); 419 420 // update the values of average.starparOffset and average.Nstarpar 421 FREE(starpar); 422 catalog[0].starpar = starparTMP; 423 424 N = 0; 425 currentAve = averageSeq[0]; 426 average[currentAve].starparOffset = 0; 427 for (i = 0; i < Nstarpar; i++) { 428 if (averageSeq[i] != currentAve) { 429 // we have hit the next entry in the list 430 average[currentAve].Nstarpar = N; 431 N = 0; 432 currentAve = averageSeq[i]; 433 average[currentAve].starparOffset = i; 434 } 435 N++; 436 } 437 // N++; 438 average[currentAve].Nstarpar = N; 439 // MARKTIME("update Nstarpar : %f sec\n", dtime); 440 441 int NstarparTotal = 0; 442 int starparOffsetOK = TRUE; 443 for (i = 0; i < Naverage; i++) { 444 NstarparTotal += catalog[0].average[i].Nstarpar; 445 if (VERBOSE && !(NstarparTotal <= catalog[0].Nstarpar)) { 446 fprintf (stderr, "too few starpar: %d %d %d\n", (int) i, NstarparTotal, (int) catalog[0].Nstarpar); 447 } 448 starparOffsetOK &= (catalog[0].average[i].starparOffset < catalog[0].Nstarpar); 449 if (VERBOSE && !(catalog[0].average[i].starparOffset < catalog[0].Nstarpar)) { 450 fprintf (stderr, "offset too large: %d %d %d\n", (int) i, catalog[0].average[i].Nstarpar, (int) catalog[0].Nstarpar); 451 } 452 starparOffsetOK &= (catalog[0].average[i].starparOffset + catalog[0].average[i].Nstarpar <= catalog[0].Nstarpar); 453 if (VERBOSE && !(catalog[0].average[i].starparOffset + catalog[0].average[i].Nstarpar <= catalog[0].Nstarpar)) { 454 fprintf (stderr, "orrset + Nstarpar too large: %d + %d > %d %d\n", (int) i, catalog[0].average[i].starparOffset, catalog[0].average[i].Nstarpar, (int) catalog[0].Nstarpar); 455 } 456 } 457 458 if (!starparOffsetOK) { 459 fprintf (stderr, "ERROR: catalog %s has an invalid starparOffset\n", catalog[0].filename); 460 } 461 462 if (NstarparTotal != catalog[0].Nstarpar) { 463 fprintf (stderr, "ERROR: catalog %s has an invalid Nstarpar\n", catalog[0].filename); 464 } 465 466 // MARKTIME(" match time %9.4f sec for %7lld starpars, %6lld average\n", dtime, (long long) Nstarpar, (long long) Naverage); 467 468 catalog[0].sorted = TRUE; 469 470 FREE (starparSeq); 471 FREE (averageSeq); 472 473 return; 474 } 475 313 476 // sort the measure or lensing Sequence based on the average Sequence entries 314 477 void SortAveMatch (off_t *MEAS, off_t *AVE, off_t N) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/resort_threaded.c
r37036 r37822 13 13 int iThread; 14 14 int state; 15 int nosort;15 int forcesort; 16 16 char *filename; 17 17 SkyRegion *region; … … 37 37 } 38 38 39 // chose the catalog file (local or remote?) 40 char hostfile[1024]; 41 snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, threadData->region->name); 42 catalog.filename = HOST_ID ? hostfile : threadData->filename; 43 39 44 // set the parameters which guide catalog open/load/create 40 catalog.filename = threadData->filename;41 45 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 42 46 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data … … 64 68 65 69 // this is an overloaded value to mean 'force sort' 66 if (threadData-> nosort == 3) catalog.sorted = FALSE;70 if (threadData->forcesort) catalog.sorted = FALSE; 67 71 68 72 if (OLD_RESORT) { … … 88 92 } 89 93 90 int resort_threaded ( AddstarClientOptions *options, SkyTable *sky) {94 int resort_threaded (SkyList *skylist, int ForceSort) { 91 95 92 96 int j, launched, done, Nwait, Nrun; … … 97 101 ThreadData *threadData; 98 102 pthread_t *threads; 99 100 double dtime;101 struct timeval start, stop;102 gettimeofday (&start, NULL);103 104 SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);105 106 // in these cases, limit the sky catalogs to an existing subset107 if (options->existing_regions) {108 SkyList *tmp;109 tmp = SkyListExistingSubset (skylist, CATDIR);110 SkyListFree (skylist);111 skylist = tmp;112 }113 if (VERBOSE) fprintf (stderr, "writing to "OFF_T_FMT" regions\n", skylist[0].Nregions);114 115 if (options->only_images) {116 fprintf (stderr, "-image (only images) makes no sense with -resort\n");117 exit (2);118 }119 if (options->only_match) {120 fprintf (stderr, "-only-match makes no sense with -resort\n");121 exit (2);122 }123 if (options->nosort == 1) {124 fprintf (stderr, "-nosort makes no sense with -resort\n");125 exit (2);126 }127 if (options->update) {128 fprintf (stderr, "-update makes no sense with -resort\n");129 exit (2);130 }131 if (options->calibrate) {132 fprintf (stderr, "-cal (calibrate) makes no sense with -resort\n");133 exit (2);134 }135 103 136 104 ALLOCATE(threads, pthread_t, NTHREADS); … … 148 116 Naverage = Nmeasure = 0; 149 117 for (i = 0; i < skylist[0].Nregions; i++) { 118 119 // does this host ID match the desired location for the table? 120 if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue; 150 121 151 122 launched = FALSE; … … 166 137 if (threadData[j].state == TS_FAIL) goto failure; 167 138 if (threadData[j].state != TS_WAIT) continue; 168 threadData[j]. nosort = options->nosort;139 threadData[j].forcesort = ForceSort; 169 140 threadData[j].filename = skylist[0].filename[i]; 170 141 threadData[j].region = skylist[0].regions[i]; … … 203 174 } 204 175 205 gettimeofday (&stop, NULL);206 dtime = DTIME (stop, start);207 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for, "OFF_T_FMT" average, "OFF_T_FMT" measure\n", dtime, Naverage, Nmeasure);208 209 176 // for (i = 0; i < NTHREADS; i++) { 210 177 // pthread_cancel(threads[i]); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/resort_unthreaded.c
r35142 r37822 1 1 # include "addstar.h" 2 2 3 int resort_unthreaded (AddstarClientOptions *options, SkyTable *sky, int hostID, char *hostpath) { 3 // pass in options and skylist? 4 int resort_unthreaded (SkyList *skylist, int ForceSort) { 4 5 5 double dtime; 6 struct timeval start, stop; 6 off_t i; 7 off_t Naverage, Nmeasure; 8 Catalog catalog; 7 9 8 gettimeofday (&start, NULL); 10 /* match stars to existing catalog data (or otherwise manipulate catalog data) */ 11 Naverage = Nmeasure = 0; 12 for (i = 0; i < skylist[0].Nregions; i++) { 9 13 10 SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch); 11 12 // in these cases, limit the sky catalogs to an existing subset 13 if (options->existing_regions) { 14 SkyList *tmp; 15 tmp = SkyListExistingSubset (skylist, CATDIR); 16 SkyListFree (skylist); 17 skylist = tmp; 14 // does this host ID match the desired location for the table? 15 if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue; 16 17 // chose the catalog file (local or remote?) 18 char hostfile[1024]; 19 snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name); 20 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 21 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 (); 27 28 // an error exit status here is a significant error (disk I/O or file access) 29 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) { 30 fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", catalog.filename); 31 exit (2); 32 } 33 34 // Naves_disk == 0 implies an empty catalog file, skip empty catalogs 35 if (catalog.Naves_disk == 0) { 36 dvo_catalog_unlock (&catalog); 37 dvo_catalog_free (&catalog); 38 continue; 39 } 40 41 // this is an overloaded value to mean 'force sort' 42 if (ForceSort) catalog.sorted = FALSE; 43 44 if (OLD_RESORT) { 45 resort_catalog_old (&catalog); 46 } else { 47 resort_catalog (&catalog); 48 } 49 50 // report total updated values 51 Naverage += catalog.Naverage; 52 Nmeasure += catalog.Nmeasure; 53 54 // write out catalog, if appropriate 55 SetProtect (TRUE); 56 dvo_catalog_save (&catalog, VERBOSE); 57 SetProtect (FALSE); 58 dvo_catalog_unlock (&catalog); 59 dvo_catalog_free (&catalog); 18 60 } 19 if (VERBOSE) fprintf (stderr, "writing to "OFF_T_FMT" regions\n", skylist[0].Nregions);20 21 if (options->only_images) {22 fprintf (stderr, "-image (only images) makes no sense with -resort\n");23 exit (2);24 }25 if (options->only_match) {26 fprintf (stderr, "-only-match makes no sense with -resort\n");27 exit (2);28 }29 if (options->nosort == 1) {30 fprintf (stderr, "-nosort makes no sense with -resort\n");31 exit (2);32 }33 if (options->update) {34 fprintf (stderr, "-update makes no sense with -resort\n");35 exit (2);36 }37 if (options->calibrate) {38 fprintf (stderr, "-cal (calibrate) makes no sense with -resort\n");39 exit (2);40 }41 42 resort_unthreaded_catalogs (options, skylist, hostID, hostpath);43 44 gettimeofday (&stop, NULL);45 dtime = DTIME (stop, start);46 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec\n", dtime);47 48 61 return TRUE; 49 62 } 50 63 64 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/src/sky_tessalation.c
r36485 r37822 581 581 582 582 memset (rectangle, 0, sizeof(SkyRectangle)); 583 584 InitCoords (&rectangle[0].coords, "DEC--TAN"); 585 583 586 rectangle[0].coords.crval1 = CENTER_RA; 584 587 rectangle[0].coords.crval2 = CENTER_DEC; … … 609 612 rectangle[0].coords.cdelt2 = SCALE / 3600.0; 610 613 611 strcpy (rectangle[0].coords.ctype, "DEC--TAN");612 613 614 rectangle[0].NX = NX; 614 615 rectangle[0].NY = NY; … … 699 700 for (i = 0; i < nRA; i++) { 700 701 memset (&ring[i], 0, sizeof(SkyRectangle)); 701 memset (&ring[i].coords, 0, sizeof(Coords)); 702 703 InitCoords (&ring[i].coords, "DEC--TAN"); 702 704 ring[i].coords.crval1 = i*dRA; 703 705 ring[i].coords.crval2 = dec; 704 706 705 707 ring[i].coords.pc1_1 = +1.0 * X_PARITY; 706 ring[i].coords.pc1_2 = +0.0;707 ring[i].coords.pc2_1 = -0.0;708 ring[i].coords.pc2_2 = +1.0;709 708 710 709 // range values are in projected degrees … … 718 717 ring[i].coords.cdelt1 = SCALE / 3600.0; 719 718 ring[i].coords.cdelt2 = SCALE / 3600.0; 720 721 strcpy (ring[i].coords.ctype, "DEC--TAN");722 719 723 720 ring[i].NX = NX*(1.0 + PADDING); … … 771 768 772 769 memset (&ring[N], 0, sizeof(SkyRectangle)); 773 memset (&ring[N].coords, 0, sizeof(Coords));770 InitCoords (&ring[N].coords, "DEC--TAN"); 774 771 775 772 ring[N].coords.crval1 = ra / d2r; … … 779 776 780 777 ring[N].coords.pc1_1 = +1.0 * X_PARITY; 781 ring[N].coords.pc1_2 = +0.0;782 ring[N].coords.pc2_1 = -0.0;783 ring[N].coords.pc2_2 = +1.0;784 778 785 779 // range values are in projected degrees … … 793 787 ring[N].coords.cdelt1 = SCALE / 3600.0; 794 788 ring[N].coords.cdelt2 = SCALE / 3600.0; 795 796 strcpy (ring[N].coords.ctype, "DEC--TAN");797 789 798 790 ring[N].NX = NX*(1.0 + PADDING); … … 1099 1091 1100 1092 ALLOCATE (refcoords, Coords, 1); 1101 refcoords[0].crval1 = refcoords[0].crval2 = 0.0; 1102 refcoords[0].crpix1 = refcoords[0].crpix2 = 0.0; 1093 InitCoords (refcoords, "DEC--TAN"); 1103 1094 refcoords[0].cdelt1 = refcoords[0].cdelt2 = scale / 3600; 1104 refcoords[0].pc1_1 = refcoords[0].pc2_2 = 1.0;1105 refcoords[0].pc1_2 = refcoords[0].pc2_1 = 0.0;1106 refcoords[0].Npolyterms = 0;1107 memset (refcoords[0].polyterms, 0, 14*sizeof(float));1108 strcpy (refcoords[0].ctype, "DEC--TAN");1109 1095 return (TRUE); 1110 1096 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/addstar/test/relphot.parallel.dvo
r33653 r37822 25 25 if (not($?VERBOSE)) set VERBOSE = 0 26 26 27 # images are loaded into dvo with GPC1 photcodes, so we need to get the nominal zps for those filters 28 $zpt_nominal:g = 24.58 29 $zpt_nominal:r = 24.80 30 $zpt_nominal:i = 24.74 31 $zpt_nominal:z = 24.26 32 $zpt_nominal:y = 23.41 33 34 # klam is negative, so klam*(airmass - 1) increase the zero point 35 $klam_nominal:g = -0.15 36 $klam_nominal:r = -0.10 37 $klam_nominal:i = -0.04 38 $klam_nominal:z = -0.03 39 $klam_nominal:y = -0.03 27 # images are loaded into dvo with GPC1 photcodes, so we need to get the nominal zps for those filters 28 # $zpt_nominal:g = 24.58 29 # $zpt_nominal:r = 24.80 30 # $zpt_nominal:i = 24.74 31 # $zpt_nominal:z = 24.26 32 # $zpt_nominal:y = 23.41 33 34 # klam is negative, so klam*(airmass - 1) increase the zero point 35 # $klam_nominal:g = -0.15 36 # $klam_nominal:r = -0.10 37 # $klam_nominal:i = -0.04 38 # $klam_nominal:z = -0.03 39 # $klam_nominal:y = -0.03 40 41 $zpt_nominal:g = 24.563; $klam_nominal:g = -0.147 42 $zpt_nominal:r = 24.750; $klam_nominal:r = -0.085 43 $zpt_nominal:i = 24.611; $klam_nominal:i = -0.044 44 $zpt_nominal:z = 24.250; $klam_nominal:z = -0.033 45 $zpt_nominal:y = 23.320; $klam_nominal:y = -0.073 40 46 41 47 # we have two sets of images: ubercaled and not-ubercaled … … 111 117 mksequence $fileroot $catdir 112 118 for i 0 mjd_nc[] 113 ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i raw 119 ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i raw 0 114 120 end 115 121 … … 121 127 122 128 # run relphot on the serial db and check that the images now match the expected values 123 exec relphot g,r,i -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 -keep-ubercal-D IMAGE_OFFSET 0.5 -update >& log.relphot.s0129 exec relphot -images g,r,i -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 >& log.relphot.s0 124 130 125 131 for i 0 mjd_nc[] … … 128 134 # matching the mean zp of photometric data, which we calculate in 129 135 # 'init' 130 ckexposure $catdir mjd_nc[$i] $zpt_nc_$filt_nc:$i exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot_nc 136 ckexposure $catdir mjd_nc[$i] $zpt_nc_$filt_nc:$i exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot_nc 0 131 137 end 132 138 133 139 # run relphot on the parallel db and check that the images now match the expected values 134 exec relphot -parallel g,r,i -v -region 9.5 10.5 19.5 20.5 -D CATDIR $catdir.p0 -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -keep-ubercal -D IMAGE_OFFSET 0.5 -update >& log.relphot.p0 135 136 exec dvodist -in $catdir.p0 >& log.dvodist.in 140 exec relphot -images -parallel g,r,i -v -region 9.5 10.5 19.5 20.5 -D CATDIR $catdir.p0 -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -D IMAGE_OFFSET 0.5 -update >& log.relphot.p0 137 141 138 142 for i 0 mjd_nc[] … … 141 145 # matching the mean zp of photometric data, which we calculate in 142 146 # 'init' 143 ckexposure $catdir.p0 mjd_nc[$i] $zpt_nc_$filt_nc:$i exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot_nc 147 ckexposure $catdir.p0 mjd_nc[$i] $zpt_nc_$filt_nc:$i exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot_nc 1 144 148 end 145 149 … … 148 152 149 153 macro ckexposure 150 if ($0 != 8)151 echo "ckexposure (catdir) (mjd) (zpt) (exptime) (airmass) (filter) (mode) "154 if ($0 != 9) 155 echo "ckexposure (catdir) (mjd) (zpt) (exptime) (airmass) (filter) (mode) (isParallel)" 152 156 echo " mode == raw or corr" 153 157 break … … 163 167 $FILTER = $6 164 168 $MODE = $7 169 $PARALLEL = 170 if ($8) 171 $PARALLEL = "-parallel" 172 end 165 173 166 174 # XXX need a function to extract the nominal zpt for a given filter / photcode from the db … … 182 190 183 191 skyregion {$RA_CENTER - 0.2/dcos($DEC_CENTER)} {$RA_CENTER + 0.2/dcos($DEC_CENTER)} {$DEC_CENTER - 0.2} {$DEC_CENTER + 0.2} 184 mextract ra dec mag xccd yccd where (abs(time - $MJD_IMAGE) < 0.0001)192 mextract $PARALLEL ra dec mag xccd yccd where (abs(time - $MJD_IMAGE) < 0.0001) 185 193 if (not(ra[])) 186 194 echo "no matching data for MJD = $MJD_IMAGE" … … 344 352 # the fake images have inconsistent ra,dec and airmass,sidtime values 345 353 if ($VERBOSE) echo addstar $ROOT.$ix.$iy.cmf -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass 346 exec addstar $ROOT.$ix.$iy.cmf -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass >& /dev/null354 exec addstar $ROOT.$ix.$iy.cmf -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass >& log.addstar 347 355 # costs 10/36 sec / chip 348 356 end … … 432 440 $catdir = $tmp1/$tmp2 433 441 442 if ($VERBOSE) echo rsync -auv $catdir/ $catdir.p0/ 434 443 exec rsync -auv $catdir/ $catdir.p0/ >& log.rsync 435 444 mkdir $catdir.d1 … … 442 451 exec echo "3 $hostname $catdir.d3" >> $catdir.p0/HostTable.dat 443 452 453 if ($VERBOSE) echo dvodist -out $catdir.p0 444 454 exec dvodist -out $catdir.p0 >& log.dvodist.out 445 455 end -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/checkastro/src/ImageOps.c
r36833 r37822 130 130 } 131 131 132 BuildChipMatch (image, Nimage);133 134 132 char output[128]; 135 133 snprintf (output, 128, "checkastrom.%+3.0f.%+3.0f.%03.0f.%03.0f.dat", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); … … 148 146 name = GetPhotcodeNamebyCode (image[i].photcode); 149 147 150 off_t myMosaic = FindMosaicForImage (image, Nimage, i);151 152 148 /* only check exposure center */ 153 149 double Rexp = NAN, Dexp = NAN, Rccd = NAN, Dccd = NAN; 154 150 155 if (myMosaic) { 156 myMosaic --; 157 XY_to_RD (&Rccd, &Dccd, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords); 158 XY_to_RD (&Rexp, &Dexp, 0.0, 0.0, &image[myMosaic].coords); 159 } 151 XY_to_RD (&Rccd, &Dccd, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords); 152 XY_to_RD (&Rexp, &Dexp, 0.0, 0.0, &image[i].parent->coords); 160 153 161 154 char *date = ohana_sec_to_date(image[i].tzero); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/checkastro/src/bcatalog.c
r36833 r37822 191 191 /* project coordinates to a plane centered on the object with units of arcsec */ 192 192 Coords coords; 193 InitCoords (&coords, "DEC--SIN"); 193 194 coords.crval1 = Rc; 194 195 coords.crval2 = Dc; 195 coords.crpix1 = 0;196 coords.crpix2 = 0;197 196 coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0; 198 coords.pc1_1 = coords.pc2_2 = 1.0;199 coords.pc1_2 = coords.pc2_1 = 0.0;200 coords.Npolyterms = 1;201 strcpy (coords.ctype, "DEC--SIN");202 197 203 198 // convert all average R,D values to X,Y: -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/checkastro/src/load_images.c
r36833 r37822 17 17 MARKTIME(" convert image table: %f sec\n", dtime); 18 18 19 BuildChipMatch (image, Nimage); 20 19 21 // select the images which overlap the selected sky regions 20 22 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/checkastro/src/select_images.c
r36833 r37822 43 43 44 44 if (VERBOSE) fprintf (stderr, "finding images\n"); 45 BuildChipMatch (timage, Ntimage);46 MARKTIME("build chip match: %f sec\n", dtime);47 45 48 46 nimage = 0; … … 83 81 } 84 82 85 // this adds 1.3 sec for 3M images86 off_t myMosaic = FindMosaicForImage (timage, Ntimage, i);87 if (!myMosaic) {88 fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);89 continue;90 }91 myMosaic --;92 93 83 /* only check exposure center */ 94 84 if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) { 95 85 XY_to_RD (&Rexp, &Dexp, 0.0, 0.0, &timage[i].coords); 96 86 } else { 97 XY_to_RD (&Rexp, &Dexp, 0.0, 0.0, &timage[ myMosaic].coords);87 XY_to_RD (&Rexp, &Dexp, 0.0, 0.0, &timage[i].parent->coords); 98 88 } 99 89 Rexp = ohana_normalize_angle_to_midpoint (Rexp, RmidSkyRegion); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/delstar/src/ImageOpsFixLAP.c
r37040 r37822 320 320 if ((Nimage_valid[i] + Nimage_invalid[i] == 0) || (found_ratio < 0.995)) { 321 321 double r, d; 322 if (! FindMosaicForImage (image, Nimage, i)) {323 fprintf (stderr, "failed to get astrometry for %s\n", image[i].name);322 if (!strcmp(&image[i].coords.ctype[4], "-DIS")) { 323 XY_to_RD (&r, &d, 0.0, 0.0, &image[i].coords); 324 324 } else { 325 if (!strcmp(&image[i].coords.ctype[4], "-DIS")) { 326 XY_to_RD (&r, &d, 0.0, 0.0, &image[i].coords); 327 } else { 328 XY_to_RD (&r, &d, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords); 329 } 325 XY_to_RD (&r, &d, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords); 330 326 } 331 327 char *date = ohana_sec_to_date (image[i].tzero); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/delstar/src/delete_duplicate_measures.c
r35758 r37822 61 61 } 62 62 63 delete_duplicate_measures_catalog (&catalog); 64 65 if (UPDATE) { 66 // XXX skip if nothing was deleted 67 dvo_catalog_save_complete (&catalog, VERBOSE2); 63 if (delete_duplicate_measures_catalog (&catalog)) { 64 // skip if nothing was deleted 65 if (UPDATE) { 66 if (!dvo_catalog_backup (&catalog, TRUE)) { 67 fprintf (stderr, "ERROR: failed to make backup for catalog %s\n", catalog.filename); 68 exit (1); 69 } 70 dvo_catalog_save_complete (&catalog, VERBOSE2); 71 } 68 72 } 69 73 … … 234 238 measureDrop[j] = TRUE; 235 239 off_t N = measure[j].averef; 236 fprintf (stderr, "0x%08x 0x%08x %8.4f %8.4f %5d\n", measure[j].imageID, measure[j].detID, average[N].R, average[N].D, measure[j].photcode);240 if (VERBOSE) fprintf (stderr, "0x%08x 0x%08x %8.4f %8.4f %5d\n", measure[j].imageID, measure[j].detID, average[N].R, average[N].D, measure[j].photcode); 237 241 } 238 242 … … 385 389 off_t NdelAves = Naverage - catalog[0].Naverage; 386 390 off_t NdelMeas = Nmeasure - catalog[0].Nmeasure; 391 387 392 if (NdelAves || NdelMeas) { 388 393 fprintf (stderr, "deleting "OFF_T_FMT" measures and "OFF_T_FMT" averages : %s\n", NdelMeas, NdelAves, catalog[0].filename); … … 404 409 FREE (measureAveOut); 405 410 406 return TRUE; 411 if (NdelAves || NdelMeas) return TRUE; 412 return FALSE; 407 413 } 408 414 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/delstar/src/delete_imagename.c
r34749 r37822 24 24 } 25 25 26 BuildChipMatch (image, Nimage); 27 26 28 /* find image in db by name */ 27 29 imlist = find_images_name (db, IMAGENAME, &Nimlist); … … 33 35 if (VERBOSE) fprintf (stderr, "deleting %s\n", image[j].name); 34 36 35 // XXX EAM : need to handle failure36 FindMosaicForImage (image, Nimage, j);37 37 skylist = SkyListByImage (sky, -1, &image[j]); 38 38 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/delstar/src/delete_times.c
r29001 r37822 31 31 } 32 32 33 BuildChipMatch (image, Nimage); 34 33 35 /* find images for time range, delete each image */ 34 36 imlist = find_images_time (db, START, END, PHOTCODE, &Nimlist); … … 39 41 if (VERBOSE) fprintf (stderr, "finding regions for %s\n", image[j].name); 40 42 41 // XXX EAM : need to handle failure42 FindMosaicForImage (image, Nimage, j);43 43 skyset = SkyListByImage (sky, -1, &image[j]); 44 44 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/Makefile
r35416 r37822 23 23 dvoverify_client : $(BIN)/dvoverify_client.$(ARCH) 24 24 25 all: dvomerge dvomerge_client dvoconvert dvosecfilt dvosecfilt_client dvoverify dvoverify_client 25 dvoutils : $(BIN)/dvoutils.$(ARCH) 26 27 all: dvomerge dvomerge_client dvoconvert dvosecfilt dvosecfilt_client dvorepair dvoverify dvoverify_client dvoutils 26 28 27 29 # $(SRC)/dvomergeContinue.$(ARCH).o … … 120 122 $(SRC)/dvorepairImagesVsMeasures.$(ARCH).o \ 121 123 $(SRC)/dvorepairDeleteImageList.$(ARCH).o \ 124 $(SRC)/dvorepairDeleteImagesByExternID.$(ARCH).o \ 125 $(SRC)/dvorepairDeleteImagesByExternID.$(ARCH).o \ 122 126 $(SRC)/dvorepairFixImages.$(ARCH).o \ 123 127 $(SRC)/psps_ids.$(ARCH).o \ 124 128 $(SRC)/LoadImages.$(ARCH).o \ 125 129 $(SRC)/ReadDeleteList.$(ARCH).o \ 130 $(SRC)/ReadDeleteListExternID.$(ARCH).o \ 131 $(SRC)/myIndex.$(ARCH).o \ 126 132 $(SRC)/match_image.$(ARCH).o \ 127 133 $(SRC)/help.$(ARCH).o \ … … 149 155 $(BIN)/dvoverify_client.$(ARCH) : $(DVOVERIFY_CLIENT) 150 156 151 INSTALL = dvomerge dvomerge_client dvoconvert dvosecfilt dvosecfilt_client dvorepair dvoverify dvoverify_client 157 DVOUTILS = \ 158 $(SRC)/dvoutils.$(ARCH).o \ 159 $(SRC)/dvoutils_args.$(ARCH).o \ 160 $(SRC)/dvoutils_uniq_images.$(ARCH).o \ 161 $(SRC)/dvoutils_load_image_index.$(ARCH).o 162 163 $(DVOUTILS) : $(INC)/dvoutils.h 164 $(BIN)/dvoutils.$(ARCH) : $(DVOUTILS) 165 166 INSTALL = dvomerge dvomerge_client dvoconvert dvosecfilt dvosecfilt_client dvorepair dvoverify dvoverify_client dvoverify 152 167 153 168 # dependancy rules for binary code ######################### -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/include/dvomerge.h
r35765 r37822 41 41 int REPLACE_BY_PHOTCODE; 42 42 int FORCE_MERGE; 43 char *UPDATE_CATFORMAT; 44 45 int MATCHED_TABLES; 43 46 44 47 char *SINGLE_CPT; 45 48 SkyRegion UserPatch; // used by MODE CAT 49 50 # ifndef MAX_INT 51 # define MAX_INT 2147483647 52 # endif 53 54 typedef struct { 55 int minID; 56 int maxID; 57 int *index; 58 int Nindex; 59 int NINDEX; 60 } myIndexType; 46 61 47 62 typedef struct { … … 129 144 int merge_catalogs_old PROTO((SkyRegion *region, Catalog *output, Catalog *input, double RADIUS, int *secflitMap)); 130 145 146 off_t *build_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure)); 131 147 off_t *init_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure)); 148 int add_meas_link PROTO((Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE)); 149 Measure *sort_measure PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next)); 150 151 off_t *build_lensing_links PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing)); 152 off_t *init_lensing_links PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing)); 153 int add_lens_link PROTO((Average *average, off_t *next, off_t Nlensing, off_t NLENSING)); 154 Lensing *sort_lensing PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next)); 155 156 off_t *build_starpar_links PROTO((Average *average, off_t Naverage, StarPar *starpar, off_t Nstarpar)); 157 off_t *init_starpar_links PROTO((Average *average, off_t Naverage, StarPar *starpar, off_t Nstarpar)); 158 int add_star_link PROTO((Average *average, off_t *next, off_t Nstarpar, off_t NSTARPAR)); 159 StarPar *sort_starpar PROTO((Average *average, off_t Naverage, StarPar *starpar, off_t Nstarpar, off_t *next)); 160 132 161 off_t *init_missing_links PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing)); 133 off_t *build_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure));134 int add_meas_link PROTO((Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE));135 162 int add_miss_link PROTO((Average *average, off_t *next, off_t Nmissing)); 136 Measure *sort_measure PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next));137 163 Missing *sort_missing PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss)); 138 164 … … 194 220 int dvoCreateID (char *catdir); 195 221 222 myIndexType *myIndexInit (); 223 int myIndexFree (myIndexType *myIndex); 224 int myIndexUpdateLimits (myIndexType *myIndex, int value); 225 int myIndexSetRange (myIndexType *myIndex); 226 int myIndexSetEntry (myIndexType *myIndex, int value, int entry); 227 int myIndexGetEntry (myIndexType *myIndex, int value); 228 229 int dvorepairDeleteImagesByExternID (int argc, char **argv); 230 int RepairTableCPT_V1(char *cptFilenameSrc, char *cptFilenameTgt, char *cpsFilenameSrc, char *cpsFilenameTgt, Measure *measure, off_t Nmeasure, Image *image, off_t Nimage, myIndexType *imageIDindex, char catformat); 231 int *ReadDeleteListExternID(char *filename, int *nindex); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/include/dvoverify.h
r34405 r37822 56 56 int LoadImageIDs (char *catdir); 57 57 int CheckImageID (Catalog *catalog); 58 59 int SaveImageIDsSmall(char *filename); 60 int LoadImageIDsSmall (char *filename); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/ImageOps.c
r29938 r37822 18 18 } 19 19 if (m == -1) return (NULL); 20 if (!FindMosaicForImage (image, Nimage, m)) return (NULL);21 20 return (&image[m]); 22 21 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/LoadCatalog.c
r29938 r37822 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 ;10 catalog[0].catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF | LOAD_LENSING | LOAD_LENSOBJ | LOAD_STARPAR; 11 11 12 12 catalog[0].catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/args.c
r35765 r37822 37 37 } 38 38 39 /* extra error messages */ 40 MATCHED_TABLES = FALSE; 41 if ((N = get_argument (*argc, argv, "-matched-tables"))) { 42 MATCHED_TABLES = TRUE; 43 remove_argument (N, argc, argv); 44 } 45 39 46 /* use a different photcode file to define mean values */ 40 47 if ((N = get_argument (*argc, argv, "-photcode-file"))) { … … 48 55 if ((N = get_argument (*argc, argv, "-force-merge"))) { 49 56 FORCE_MERGE = TRUE; 57 remove_argument (N, argc, argv); 58 } 59 60 UPDATE_CATFORMAT = NULL; 61 if ((N = get_argument (*argc, argv, "-update-catformat"))) { 62 remove_argument (N, argc, argv); 63 UPDATE_CATFORMAT = strcreate (argv[N]); 50 64 remove_argument (N, argc, argv); 51 65 } … … 185 199 } 186 200 201 /* extra error messages */ 202 MATCHED_TABLES = FALSE; 203 if ((N = get_argument (*argc, argv, "-matched-tables"))) { 204 MATCHED_TABLES = TRUE; 205 remove_argument (N, argc, argv); 206 } 207 187 208 /* replace measurement, don't duplicate */ 188 209 REPLACE_BY_PHOTCODE = FALSE; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/build_links.c
r27435 r37822 1 1 # include "dvomerge.h" 2 3 /* 4 5 There are two modes for the measure table: sorted and unsorted. 6 7 In sorted mode, all measures associated with a given average are in a single block. The block 8 is pointed to by average->measureOffset and the range is average->Nmeasure 9 10 In unsorted mode, it is not possible to go directly from average to measure without scanning. 11 In this case, it is necessary to use the value measure->averef to find the corresponding 12 average entry. 13 14 Note that average->measureOffset and measure->averef are only valid for a given load of the 15 data: they refer to the sequence number in the data blocks. 16 17 next_meas is a list of the equivalent sequence of the measure block as if it were sorted. 18 19 to find the sequence of measurements for a given average: 20 n_0 = average->measureOffset 21 n_1 = next_meas[n_0] 22 n_i = next_meas[n_i-1] 23 24 */ 2 25 3 26 /* build the initial links assuming the table is sorted, … … 6 29 7 30 off_t i, j, N; 8 off_t *next ;31 off_t *next_meas; 9 32 10 33 N = 0; 11 34 12 ALLOCATE (next , off_t, Nmeasure);35 ALLOCATE (next_meas, off_t, Nmeasure); 13 36 for (i = 0; i < Naverage; i++, N++) { 14 37 for (j = 0; j < average[i].Nmeasure - 1; j++, N++) { 15 next [N] = N + 1;38 next_meas[N] = N + 1; 16 39 if (N >= Nmeasure) { 17 40 fprintf (stderr, "WARNING: N out of bounds (1)\n"); 18 41 } 19 42 } 20 next [N] = -1;43 next_meas[N] = -1; 21 44 if (N >= Nmeasure) { 22 45 fprintf (stderr, "WARNING: N out of bounds (2)\n"); … … 28 51 } 29 52 } 30 return (next); 31 } 32 33 /* average[].measureOffset, average[].Nmeasure are valid within an addstar run */ 34 int add_meas_link (Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE) { 35 36 off_t k, m; 37 38 /* if we have trouble, check validity of next[m] : m < Nmeasure */ 39 m = average[0].measureOffset; 40 41 for (k = 0; k < average[0].Nmeasure - 1; k++) { 42 m = next[m]; 43 if (m >= NMEASURE) { 44 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 45 } 46 } 47 48 /* set up references */ 49 next[Nmeasure] = -1; 50 if (Nmeasure >= NMEASURE) { 51 fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n"); 52 } 53 54 if (m == -1) { 55 average[0].measureOffset = Nmeasure; 56 } else { 57 next[m] = Nmeasure; 58 if (m >= NMEASURE) { 59 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 60 } 61 } 62 63 return (TRUE); 64 } 65 66 Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next) { 67 68 off_t i, k, n, N; 69 Measure *tmpmeasure; 70 71 /* fix order of Measure (memory intensive, but fast) */ 72 N = 0; 73 ALLOCATE (tmpmeasure, Measure, Nmeasure); 74 for (i = 0; i < Naverage; i++) { 75 n = average[i].measureOffset; 76 average[i].measureOffset = N; 77 for (k = 0; k < average[i].Nmeasure; k++, N++) { 78 tmpmeasure[N] = measure[n]; 79 tmpmeasure[N].averef = i; 80 n = next[n]; 81 } 82 } 83 free (measure); 84 return (tmpmeasure); 53 return (next_meas); 85 54 } 86 55 … … 95 64 96 65 off_t i, m, k, Nm, averef; 97 off_t *next ;98 99 ALLOCATE (next , off_t, Nmeasure);66 off_t *next_meas; 67 68 ALLOCATE (next_meas, off_t, Nmeasure); 100 69 101 70 /* reset the Nm, offset values for average */ … … 108 77 averef = measure[Nm].averef; 109 78 m = average[averef].measureOffset; 110 next [Nm] = -1;79 next_meas[Nm] = -1; 111 80 112 81 if (m == -1) { /* no links yet for source */ … … 116 85 } 117 86 118 for (k = 0; next [m] != -1; k++) {119 m = next [m];87 for (k = 0; next_meas[m] != -1; k++) { 88 m = next_meas[m]; 120 89 if (m >= Nmeasure) { 121 90 fprintf (stderr, "WARNING: m out of bounds (1)\n"); … … 124 93 125 94 average[averef].Nmeasure = k + 2; 126 next [m] = Nm;95 next_meas[m] = Nm; 127 96 if (m >= Nmeasure) { 128 97 fprintf (stderr, "WARNING: m out of bounds (2)\n"); 129 98 } 130 99 } 131 return (next); 132 } 100 return (next_meas); 101 } 102 103 /* average[].measureOffset, average[].Nmeasure are valid within an addstar run */ 104 int add_meas_link (Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE) { 105 106 off_t k, m; 107 108 /* if we have trouble, check validity of next_meas[m] : m < Nmeasure */ 109 m = average[0].measureOffset; 110 111 for (k = 0; k < average[0].Nmeasure - 1; k++) { 112 m = next_meas[m]; 113 if (m >= NMEASURE) { 114 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 115 } 116 } 117 118 /* set up references */ 119 next_meas[Nmeasure] = -1; 120 if (Nmeasure >= NMEASURE) { 121 fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n"); 122 } 123 124 if (m == -1) { 125 average[0].measureOffset = Nmeasure; 126 } else { 127 next_meas[m] = Nmeasure; 128 if (m >= NMEASURE) { 129 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 130 } 131 } 132 133 return (TRUE); 134 } 135 136 Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next_meas) { 137 138 off_t i, k, n, N; 139 Measure *tmpmeasure; 140 141 /* fix order of Measure (memory intensive, but fast) */ 142 N = 0; 143 ALLOCATE (tmpmeasure, Measure, Nmeasure); 144 for (i = 0; i < Naverage; i++) { 145 n = average[i].measureOffset; 146 average[i].measureOffset = N; 147 for (k = 0; k < average[i].Nmeasure; k++, N++) { 148 if (n == -1) abort(); 149 tmpmeasure[N] = measure[n]; 150 if (measure[n].averef != i) abort(); 151 tmpmeasure[N].averef = i; 152 n = next_meas[n]; 153 } 154 } 155 free (measure); 156 return (tmpmeasure); 157 } 158 159 /*******************************************************************************************/ 133 160 134 161 /* build the initial links assuming the table is sorted */ … … 136 163 137 164 off_t i, j, N; 138 off_t *next ;165 off_t *next_miss; 139 166 140 167 N = 0; 141 168 142 ALLOCATE (next , off_t, Nmissing);169 ALLOCATE (next_miss, off_t, Nmissing); 143 170 for (i = 0; i < Naverage; i++) { 144 171 for (j = 0; j < average[i].Nmissing - 1; j++, N++) { 145 next [N] = N + 1;172 next_miss[N] = N + 1; 146 173 } 147 174 if (average[i].Nmissing > 0) { 148 next [N] = -1;175 next_miss[N] = -1; 149 176 if (N >= Nmissing) { 150 177 fprintf (stderr, "overflow in init_missing_links"); … … 155 182 156 183 } 157 return (next );158 } 159 160 int add_miss_link (Average *average, off_t *next , off_t Nmissing) {184 return (next_miss); 185 } 186 187 int add_miss_link (Average *average, off_t *next_miss, off_t Nmissing) { 161 188 162 189 off_t k, m; … … 165 192 if (average[0].Nmissing < 1) { 166 193 average[0].missingOffset = Nmissing; 167 next [Nmissing] = -1;194 next_miss[Nmissing] = -1; 168 195 return (TRUE); 169 196 } 170 197 171 198 m = average[0].missingOffset; 172 for (k = 0; k < average[0].Nmissing - 1; k++) m = next [m];199 for (k = 0; k < average[0].Nmissing - 1; k++) m = next_miss[m]; 173 200 /* set up references */ 174 next [Nmissing] = -1;175 next [m] = Nmissing;201 next_miss[Nmissing] = -1; 202 next_miss[m] = Nmissing; 176 203 return (TRUE); 177 204 } … … 180 207 we must always save the missing table, if it exists */ 181 208 182 Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next ) {209 Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss) { 183 210 184 211 off_t i, k, n, N; … … 193 220 for (k = 0; k < average[i].Nmissing; k++, N++) { 194 221 tmpmissing[N] = missing[n]; 195 n = next [n];222 n = next_miss[n]; 196 223 } 197 224 } … … 199 226 return (tmpmissing); 200 227 } 228 229 /*******************************************************************************************/ 230 231 /* build the initial links assuming the table is sorted, 232 not partial, and has a correct set of average[].lensingOffset,Nlensing values */ 233 off_t *init_lensing_links (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing) { 234 235 off_t i, j, N; 236 off_t *next_lens; 237 238 N = 0; 239 240 ALLOCATE (next_lens, off_t, Nlensing); 241 for (i = 0; i < Naverage; i++) { 242 if (!average[i].Nlensing) continue; 243 off_t m = average[i].lensingOffset; 244 myAssert (lensing[m].averef == i, "not sorted"); 245 for (j = 0; j < average[i].Nlensing - 1; j++, N++) { 246 myAssert (lensing[m+j+1].averef == i, "not sorted"); 247 next_lens[N] = N + 1; 248 if (N >= Nlensing) { 249 fprintf (stderr, "WARNING: N out of bounds (1)\n"); 250 } 251 } 252 next_lens[N] = -1; 253 if (N >= Nlensing) { 254 fprintf (stderr, "WARNING: N out of bounds (2)\n"); 255 } 256 257 if (N >= Nlensing) { 258 fprintf (stderr, "overflow in init_lensing_links\n"); 259 abort (); 260 } 261 N++; 262 } 263 return (next_lens); 264 } 265 266 /* construct lensing links which are valid FOR THIS LOAD 267 * - if we have a full load, we will get links which can 268 * be used by other programs (eg, relphot, etc) 269 * - if we have a partial load, the links are only valid 270 * for that partial load 271 */ 272 273 off_t *build_lensing_links (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing) { 274 275 off_t i, m, k, Nm, averef; 276 off_t *next_lens; 277 278 ALLOCATE (next_lens, off_t, Nlensing); 279 280 /* reset the Nm, offset values for average */ 281 for (i = 0; i < Naverage; i++) { 282 average[i].lensingOffset = -1; 283 average[i].Nlensing = 0; 284 } 285 286 for (Nm = 0; Nm < Nlensing; Nm++) { 287 averef = lensing[Nm].averef; 288 m = average[averef].lensingOffset; 289 next_lens[Nm] = -1; 290 291 if (m == -1) { /* no links yet for source */ 292 average[averef].lensingOffset = Nm; 293 average[averef].Nlensing = 1; 294 continue; 295 } 296 297 for (k = 0; next_lens[m] != -1; k++) { 298 m = next_lens[m]; 299 if (m >= Nlensing) { 300 fprintf (stderr, "WARNING: m out of bounds (1)\n"); 301 } 302 } 303 304 average[averef].Nlensing = k + 2; 305 next_lens[m] = Nm; 306 if (m >= Nlensing) { 307 fprintf (stderr, "WARNING: m out of bounds (2)\n"); 308 } 309 } 310 return (next_lens); 311 } 312 313 /* average[].lensingOffset, average[].Nlensing are valid within an addstar run */ 314 int add_lens_link (Average *average, off_t *next_lens, off_t Nlensing, off_t NLENSING) { 315 316 off_t k, m; 317 318 /* if we have trouble, check validity of next_lens[m] : m < Nlensing */ 319 m = average[0].lensingOffset; 320 321 for (k = 0; k < average[0].Nlensing - 1; k++) { 322 m = next_lens[m]; 323 if (m >= NLENSING) { 324 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 325 } 326 } 327 328 /* set up references */ 329 next_lens[Nlensing] = -1; 330 if (Nlensing >= NLENSING) { 331 fprintf (stderr, "WARNING: Nlensing out of bounds (1)\n"); 332 } 333 334 // if Nlensing is 0, m may have been mis-set; add to the end 335 if ((average[0].Nlensing == 0) || (m == -1)) { 336 average[0].lensingOffset = Nlensing; 337 } else { 338 next_lens[m] = Nlensing; 339 if (m >= NLENSING) { 340 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 341 } 342 } 343 344 return (TRUE); 345 } 346 347 Lensing *sort_lensing (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next_lens) { 348 349 off_t i, k, n, np, N; 350 Lensing *tmplensing; 351 352 /* 353 for (i = 0; i < Naverage; i++) { 354 if (average[i].Nlensing != 4) { 355 fprintf (stderr, "check %d %d %d\n", (int) i, (int) average[i].Nlensing, (int) average[i].lensingOffset); 356 } 357 } 358 */ 359 360 /* fix order of Lensing (memory intensive, but fast) */ 361 np = -1; 362 N = 0; 363 ALLOCATE (tmplensing, Lensing, Nlensing); 364 for (i = 0; i < Naverage; i++) { 365 if (!average[i].Nlensing) continue; 366 n = average[i].lensingOffset; 367 average[i].lensingOffset = N; 368 for (k = 0; k < average[i].Nlensing; k++, N++) { 369 if (n == -1) { 370 fprintf (stderr, "entry after %d has a problem\n", (int) np); 371 abort(); 372 } 373 tmplensing[N] = lensing[n]; 374 if (lensing[n].averef != i) abort(); 375 tmplensing[N].averef = i; 376 np = n; 377 n = next_lens[n]; 378 } 379 } 380 free (lensing); 381 return (tmplensing); 382 } 383 384 /******** StarPar ********************************************************************************/ 385 386 /* build the initial links assuming the table is sorted, 387 not partial, and has a correct set of average[].starparOffset,Nstarpar values */ 388 off_t *init_starpar_links (Average *average, off_t Naverage, StarPar *starpar, off_t Nstarpar) { 389 390 off_t i, j, N; 391 off_t *next_star; 392 393 N = 0; 394 395 ALLOCATE (next_star, off_t, Nstarpar); 396 for (i = 0; i < Naverage; i++) { 397 if (!average[i].Nstarpar) continue; 398 for (j = 0; j < average[i].Nstarpar - 1; j++, N++) { 399 next_star[N] = N + 1; 400 if (N >= Nstarpar) { 401 fprintf (stderr, "WARNING: N out of bounds (1)\n"); 402 } 403 } 404 next_star[N] = -1; 405 if (N >= Nstarpar) { 406 fprintf (stderr, "WARNING: N out of bounds (2)\n"); 407 } 408 409 if (N >= Nstarpar) { 410 fprintf (stderr, "overflow in init_starpar_links\n"); 411 abort (); 412 } 413 N++; 414 } 415 return (next_star); 416 } 417 418 /* construct starpar links which are valid FOR THIS LOAD 419 * - if we have a full load, we will get links which can 420 * be used by other programs (eg, relphot, etc) 421 * - if we have a partial load, the links are only valid 422 * for that partial load 423 */ 424 425 off_t *build_starpar_links (Average *average, off_t Naverage, StarPar *starpar, off_t Nstarpar) { 426 427 off_t i, m, k, Nm, averef; 428 off_t *next_star; 429 430 ALLOCATE (next_star, off_t, Nstarpar); 431 432 /* reset the Nm, offset values for average */ 433 for (i = 0; i < Naverage; i++) { 434 average[i].starparOffset = -1; 435 average[i].Nstarpar = 0; 436 } 437 438 for (Nm = 0; Nm < Nstarpar; Nm++) { 439 averef = starpar[Nm].averef; 440 m = average[averef].starparOffset; 441 next_star[Nm] = -1; 442 443 if (m == -1) { /* no links yet for source */ 444 average[averef].starparOffset = Nm; 445 average[averef].Nstarpar = 1; 446 continue; 447 } 448 449 for (k = 0; next_star[m] != -1; k++) { 450 m = next_star[m]; 451 if (m >= Nstarpar) { 452 fprintf (stderr, "WARNING: m out of bounds (1)\n"); 453 } 454 } 455 456 average[averef].Nstarpar = k + 2; 457 next_star[m] = Nm; 458 if (m >= Nstarpar) { 459 fprintf (stderr, "WARNING: m out of bounds (2)\n"); 460 } 461 } 462 return (next_star); 463 } 464 465 /* average[].starparOffset, average[].Nstarpar are valid within an addstar run */ 466 int add_star_link (Average *average, off_t *next_star, off_t Nstarpar, off_t NSTARPAR) { 467 468 off_t k, m; 469 470 /* if we have trouble, check validity of next_star[m] : m < Nstarpar */ 471 m = average[0].starparOffset; 472 473 for (k = 0; k < average[0].Nstarpar - 1; k++) { 474 m = next_star[m]; 475 if (m >= NSTARPAR) { 476 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 477 } 478 } 479 480 /* set up references */ 481 next_star[Nstarpar] = -1; 482 if (Nstarpar >= NSTARPAR) { 483 fprintf (stderr, "WARNING: Nstarpar out of bounds (1)\n"); 484 } 485 486 if (m == -1) { 487 average[0].starparOffset = Nstarpar; 488 } else { 489 next_star[m] = Nstarpar; 490 if (m >= NSTARPAR) { 491 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 492 } 493 } 494 495 return (TRUE); 496 } 497 498 StarPar *sort_starpar (Average *average, off_t Naverage, StarPar *starpar, off_t Nstarpar, off_t *next_star) { 499 500 off_t i, k, n, np, N; 501 StarPar *tmpstarpar; 502 503 /* 504 for (i = 0; i < Naverage; i++) { 505 if (average[i].Nstarpar != 4) { 506 fprintf (stderr, "check %d %d %d\n", (int) i, (int) average[i].Nstarpar, (int) average[i].starparOffset); 507 } 508 } 509 */ 510 511 /* fix order of StarPar (memory intensive, but fast) */ 512 np = -1; 513 N = 0; 514 ALLOCATE (tmpstarpar, StarPar, Nstarpar); 515 for (i = 0; i < Naverage; i++) { 516 if (!average[i].Nstarpar) continue; 517 n = average[i].starparOffset; 518 average[i].starparOffset = N; 519 for (k = 0; k < average[i].Nstarpar; k++, N++) { 520 if (n == -1) { 521 fprintf (stderr, "entry after %d has a problem\n", (int) np); 522 abort(); 523 } 524 tmpstarpar[N] = starpar[n]; 525 if (starpar[n].averef != i) abort(); 526 tmpstarpar[N].averef = i; 527 np = n; 528 n = next_star[n]; 529 } 530 } 531 free (starpar); 532 return (tmpstarpar); 533 } 534 535 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r36833 r37822 113 113 create_IDmap_lookup (IDmap); 114 114 115 if (!out[0].swapped) {116 gfits_convert_Image ((Image *) out[0].ftable.buffer, sizeof(Image), Nout);117 out[0].swapped = TRUE;118 }119 120 115 Nout += Nimages; 121 116 IDstart += Nimages; … … 179 174 off_t lastID = IDmap->old[IDmap->Nmap-1]; 180 175 176 // update measure.imageID 181 177 for (i = 0; i < catalog[0].Nmeasure; i++) { 182 178 oldID = catalog[0].measure[i].imageID; … … 199 195 } 200 196 catalog[0].measure[i].imageID = newID; 197 } 198 199 // also update lensing.imageID if lensing exists 200 for (i = 0; i < catalog[0].Nlensing; i++) { 201 oldID = catalog[0].lensing[i].imageID; 202 if (oldID == 0) continue; 203 204 newID = dvo_map_image_ID (IDmap, oldID); 205 if (newID == 0) { 206 if (oldID > lastID) { 207 fprintf (stderr, "problem with image IDs : input out of range\n"); 208 fprintf (stderr, "old ID: "OFF_T_FMT", last ID: "OFF_T_FMT"\n", oldID, lastID); 209 exit (2); 210 } 211 if (!IDmap->notFound[oldID]) { 212 fprintf (stderr, "cannot find image ID "OFF_T_FMT"\n", oldID); 213 IDmap->notFound[oldID] = TRUE; 214 // once we discover an imageID is not found, record that fact so we do not complain for every detection 215 } 216 // optionally exit here? or wait until end to report an error? 217 // exit (2); 218 } 219 catalog[0].lensing[i].imageID = newID; 201 220 } 202 221 return TRUE; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvomergeContinue.c
r34260 r37822 131 131 merge_catalogs_old (&outsky[0].regions[j], &outcatalog, &incatalog, RADIUS, secfiltMap); 132 132 133 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;134 135 133 // if we receive a signal which would cause us to exit, wait until the full catalog is written 136 134 SetProtect (TRUE); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvomergeContinue_threaded.c
r34260 r37822 74 74 merge_catalogs_old (&threadData->outsky->regions[j], &outcatalog, &incatalog, RADIUS, threadData->secfiltMap); 75 75 76 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;77 78 76 // if we receive a signal which would cause us to exit, wait until the full catalog is written 79 77 SetProtect (TRUE); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvomergeCreate.c
r33963 r37822 178 178 SkyListFree (inlist); 179 179 180 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;181 180 dvo_catalog_save (&outcatalog, VERBOSE); 182 181 dvo_catalog_unlock (&outcatalog); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvomergeFromList.c
r35590 r37822 143 143 merge_catalogs_old (&skyregion, &outcatalog, &incatalog, RADIUS, secfiltMap); 144 144 145 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;146 147 145 dmhObjectAdd (outstat[0].history, &outcatalog.header, inStats); 148 146 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvomergeUpdate.c
r36528 r37822 13 13 int NsecfiltInput, NsecfiltOutput; 14 14 15 double dtime; 16 struct timeval start, stop; 17 gettimeofday (&start, NULL); 15 INITTIME; 18 16 19 17 CONTINUE = FALSE; … … 121 119 } 122 120 123 gettimeofday (&stop, NULL);124 dtime = DTIME (stop, start);125 126 121 if (!status) { 127 fprintf (stderr,"ERROR: elapsed time %9.4f sec\n", dtime);122 MARKTIME ("ERROR: elapsed time %9.4f sec\n", dtime); 128 123 exit (3); 129 124 } 130 125 131 fprintf (stderr,"SUCCESS: elapsed time %9.4f sec\n", dtime);126 MARKTIME ("SUCCESS: elapsed time %9.4f sec\n", dtime); 132 127 exit (0); 133 128 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
r37046 r37822 58 58 } 59 59 60 # ifdef OLD_CODE 61 // NOTE: i was having trouble dropping objects on edges with the option below. Since an object can move outside the catalog grab the neighbors. 60 62 // SkyListByBounds will return neighbor catalogs if the boundaries exactly match (due to rounding). Since the regions are not infinitely small, 61 63 // compare to a slightly reduced footprint 62 64 float dPos = 2.0/3600.0; 63 65 outlist = SkyListByBounds (outsky, -1, inlist[0].regions[i][0].Rmin + dPos, inlist[0].regions[i][0].Rmax - dPos, inlist[0].regions[i][0].Dmin + dPos, inlist[0].regions[i][0].Dmax - dPos); 66 # endif 67 68 if (MATCHED_TABLES) { 69 // if we know the output will have the same depth / layout as the input, just choose the matched table 70 outlist = SkyRegionByIndex (outsky, inlist[0].regions[i][0].index); 71 } else { 72 // Since an object can move outside the catalog grab the neighbors. 73 float dPos = 2.0/3600.0; 74 outlist = SkyListByBounds (outsky, -1, inlist[0].regions[i][0].Rmin - dPos, inlist[0].regions[i][0].Rmax + dPos, inlist[0].regions[i][0].Dmin - dPos, inlist[0].regions[i][0].Dmax + dPos); 75 } 64 76 65 77 OutputStatus *outstat = OutputStatusInit (outlist->Nregions); … … 163 175 LoadCatalog (&outcatalog, outlist[0].regions[j], outcatalog.filename, "w", NsecfiltOutput); 164 176 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 } 184 } 185 165 186 merge_catalogs_old (outlist[0].regions[j], &outcatalog, &incatalog, RADIUS, secfiltMap); 166 167 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;168 187 169 188 if (outstat[j].missed) { … … 184 203 SetProtect (FALSE); 185 204 205 if (!dvo_catalog_unlock (&outcatalog)) { 206 fprintf (stderr, "ERROR: failed to unlock catalog %s\n", outlist[0].filename[j]); 207 exit (1); 208 } 209 186 210 if (!dvo_catalog_unlink_backup (&outcatalog, TRUE)) { 187 211 fprintf (stderr, "WARNING: failed to remove backup for catalog %s\n", outlist[0].filename[j]); 188 212 } 189 213 190 dvo_catalog_unlock (&outcatalog);191 214 dvo_catalog_free (&outcatalog); 192 215 … … 253 276 if (PARALLEL_INPUT) { snprintf (tmpline, DVO_MAX_PATH, "%s -parallel-input", command); strcpy (command, tmpline); } 254 277 if (FORCE_MERGE) { snprintf (tmpline, DVO_MAX_PATH, "%s -force-merge", command); strcpy (command, tmpline); } 278 if (MATCHED_TABLES) { snprintf (tmpline, DVO_MAX_PATH, "%s -matched-tables", command); strcpy (command, tmpline); } 255 279 256 280 // add some config variables: -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvomergeUpdate_threaded.c
r35765 r37822 72 72 merge_catalogs_old (&threadData->outsky->regions[j], &outcatalog, &incatalog, RADIUS, threadData->secfiltMap); 73 73 74 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;75 76 74 // if we receive a signal which would cause us to exit, wait until the full catalog is written 77 75 SetProtect (TRUE); … … 115 113 int NsecfiltInput, NsecfiltOutput; 116 114 117 double dtime; 118 struct timeval start, stop; 119 gettimeofday (&start, NULL); 115 INITTIME; 120 116 121 117 CONTINUE = FALSE; … … 134 130 135 131 fprintf (stderr, "WARNING / ERROR : multi-threaded dvomerge does not handle merge tracking yet\n"); 132 fprintf (stderr, "WARNING / ERROR : multi-threaded dvomerge does work in a parallel context\n"); 136 133 exit (2); 137 134 … … 293 290 } 294 291 295 gettimeofday (&stop, NULL); 296 dtime = DTIME (stop, start); 297 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec\n", dtime); 298 292 MARKTIME ("SUCCESS: elapsed time %9.4f sec\n", dtime); 299 293 exit (0); 300 294 … … 318 312 } 319 313 } 314 MARKTIME ("ERROR: elapsed time %9.4f sec\n", dtime); 320 315 exit (1); 321 316 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvorepair.c
r37046 r37822 3 3 int main (int argc, char **argv) { 4 4 5 fprintf (stderr, "this program needs to be updated to load old format Measure tables (pre PV1_V5) in which dR,dD are saved, not R,D\n");6 fprintf (stderr, "reminder: relastro can re-construct R,D from X,Y; FtableToMeasure and vice versa could just NAN those values\n");7 exit (2);5 // fprintf (stderr, "this program needs to be updated to load old format Measure tables (pre PV1_V5) in which dR,dD are saved, not R,D\n"); 6 // fprintf (stderr, "reminder: relastro can re-construct R,D from X,Y; FtableToMeasure and vice versa could just NAN those values\n"); 7 // exit (2); 8 8 9 9 dvorepair_help(argc, argv); … … 13 13 if (!strcmp(argv[1], "-images-vs-measures")) dvorepairImagesVsMeasures(argc, argv); 14 14 if (!strcmp(argv[1], "-delete-image-list")) dvorepairDeleteImageList(argc, argv); 15 if (!strcmp(argv[1], "-delete-images-by-extern-id")) dvorepairDeleteImagesByExternID(argc, argv); 15 16 if (!strcmp(argv[1], "-fix-images")) dvorepairFixImages(argc, argv); 16 17 dvorepair_help(0, NULL); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvorepairCPT.c
r37046 r37822 119 119 thisImage = MatchImage (image, Nimage, measure[i].t, measure[i].photcode, measure[i].imageID); 120 120 XY_to_RD (&average[Nave].R, &average[Nave].D, measure[i].Xccd, measure[i].Yccd, &thisImage[0].coords); 121 average[Nave].R = ohana_normalize_angle (average[Nave].R); 121 122 122 123 average[Nave].Nmeasure = 1; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvorepairDeleteImageList.c
r37046 r37822 114 114 index = deleteIDs[i]; 115 115 seq = imageIdx[index]; 116 if (!FindMosaicForImage (image, Nimage, seq)) {117 fprintf (stderr, "cannot find mosaic for %s, skipping\n", image[seq].name);118 continue;119 }120 116 121 117 XY_to_RD(&Rthis, &Dthis, 0, 0, &image[seq].coords); … … 404 400 thisImage = MatchImage (image, Nimage, measure[i].t, measure[i].photcode, measure[i].imageID); 405 401 XY_to_RD (&average[Nave].R, &average[Nave].D, measure[i].Xccd, measure[i].Yccd, &thisImage[0].coords); 402 average[Nave].R = ohana_normalize_angle (average[Nave].R); 406 403 407 404 average[Nave].Nmeasure = 1; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvorepairFixImages.c
r29938 r37822 130 130 int MarkMosaicsToDelete(Image *image, off_t Nimage, int *deleteIndex) { 131 131 132 myAbort ("this function needs to be redone with a concept to match the old BuildChipMatch"); 133 134 # if (0) 135 132 136 off_t i; 133 137 … … 140 144 marked. Now find all WRP images for which none/some/all images are to be deleted. 141 145 */ 146 147 142 148 143 149 // make a copy of the ChipMatch table (generated by BuildChipMatch, see libdvo/src/mosaic_astrom.c) … … 237 243 free (ChipByMosaicID); 238 244 245 # endif 246 239 247 return TRUE; 240 248 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvorepairFixTables.c
r37046 r37822 259 259 thisImage = MatchImage (image, Nimage, measure[i].t, measure[i].photcode, measure[i].imageID); 260 260 XY_to_RD (&average[Nave].R, &average[Nave].D, measure[i].Xccd, measure[i].Yccd, &thisImage[0].coords); 261 average[Nave].R = ohana_normalize_angle (average[Nave].R); 261 262 262 263 average[Nave].Nmeasure = 1; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvoverify_args.c
r36101 r37822 56 56 } 57 57 58 /*** dvoverify -parallel (dvoverify_client, actually) ignores this argument 59 dvoverify should save a subset table of just the IDs, and dvoverify_client should load it 60 dvoverify -cpt should have CHECK_IMAGE_ID = F as default ***/ 58 /*** dvoverify -cpt should have CHECK_IMAGE_ID = F as default ***/ 61 59 62 60 CHECK_IMAGE_ID = TRUE; … … 150 148 } 151 149 150 CHECK_IMAGE_ID = TRUE; 151 if ((N = get_argument (*argc, argv, "-skip-image-ids"))) { 152 CHECK_IMAGE_ID = FALSE; 153 remove_argument (N, argc, argv); 154 } 155 152 156 // restrict to a portion of the sky 153 157 UserPatch.Rmin = 0; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvoverify_catalogs.c
r36084 r37822 47 47 } 48 48 49 sprintf (filename, "%s/%s.cpx", mycatdir, skylist[0].regions[i][0].name); 50 if (!VerifyTableFile (filename)) { 51 Nbad ++; 52 skipIndexCheck = TRUE; 53 AddFailures (filename); 54 } 55 56 sprintf (filename, "%s/%s.cpy", mycatdir, skylist[0].regions[i][0].name); 57 if (!VerifyTableFile (filename)) { 58 Nbad ++; 59 skipIndexCheck = TRUE; 60 AddFailures (filename); 61 } 62 49 63 sprintf (filename, "%s/%s.cpt", mycatdir, skylist[0].regions[i][0].name); 50 64 if (!skipIndexCheck) { … … 80 94 exit (1); 81 95 } 96 97 // save the IDlist as a smaller FITS table 98 if (CHECK_IMAGE_ID) { 99 char filename[DVO_MAX_PATH]; 100 snprintf (filename, DVO_MAX_PATH, "%s/ImageIDs.fits", CATDIR); 101 if (!SaveImageIDsSmall (filename)) { 102 fprintf (stderr, "ERROR: failure to save image IDs\n"); 103 exit (2); 104 } 105 } 82 106 83 107 int i; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvoverify_client.c
r34405 r37822 22 22 // XXX in client mode, we should be reading a reduced table generated by the calling 23 23 // serial program 24 LoadImageIDs (CATDIR); 24 char filename[DVO_MAX_PATH]; 25 snprintf (filename, DVO_MAX_PATH, "%s/ImageIDs.fits", CATDIR); 26 if (!LoadImageIDsSmall (filename)) { 27 fprintf (stderr, "ERROR: failure to load image IDs\n"); 28 exit (2); 29 } 25 30 } 26 31 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/dvoverify_utils.c
r36101 r37822 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 ;180 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_LENSING | LOAD_LENSOBJ; 181 181 catalog.Nsecfilt = 0; 182 182 … … 214 214 int NmeasureTotal = 0; 215 215 int measureOffsetOK = TRUE; 216 int NlensingTotal = 0; 217 int lensingOffsetOK = TRUE; 218 int NlensobjTotal = 0; 219 int lensobjOffsetOK = TRUE; 216 220 for (i = 0; i < catalog.Naverage; i++) { 217 221 NmeasureTotal += catalog.average[i].Nmeasure; … … 227 231 fprintf (stderr, "measureOffset + Nmeasure > catalog.Nmeasure : %d %d %d\n", i, catalog.average[i].Nmeasure, (int) catalog.Nmeasure); 228 232 } 233 234 // sum of Nlensing for each object < Nlensing for catalog 235 NlensingTotal += catalog.average[i].Nlensing; 236 if (VERBOSE && !(NlensingTotal <= catalog.Nlensing)) { 237 fprintf (stderr, "NlensingTotal > catalog.Nlensing: %d %d %d\n", i, catalog.average[i].Nlensing, (int) catalog.Nlensing); 238 } 239 // lensingOffset needs to be in range for each object 240 lensingOffsetOK &= (!catalog.Nlensing || (catalog.average[i].lensingOffset < catalog.Nlensing)); 241 if (VERBOSE && catalog.Nlensing && !(catalog.average[i].lensingOffset < catalog.Nlensing)) { 242 fprintf (stderr, "lensingOffset >= catalog.Nlensing: %d %d %d\n", i, catalog.average[i].lensingOffset, (int) catalog.Nlensing); 243 } 244 lensingOffsetOK &= (catalog.average[i].lensingOffset + catalog.average[i].Nlensing <= catalog.Nlensing); 245 if (VERBOSE && !(catalog.average[i].lensingOffset + catalog.average[i].Nlensing <= catalog.Nlensing)) { 246 fprintf (stderr, "lensingOffset + Nlensing > catalog.Nlensing : %d %d %d\n", i, catalog.average[i].Nlensing, (int) catalog.Nlensing); 247 } 248 249 NlensobjTotal += catalog.average[i].Nlensobj; 250 if (VERBOSE && !(NlensobjTotal <= catalog.Nlensobj)) { 251 fprintf (stderr, "NlensobjTotal > catalog.Nlensobj: %d %d %d\n", i, catalog.average[i].Nlensobj, (int) catalog.Nlensobj); 252 } 253 lensobjOffsetOK &= (catalog.average[i].lensobjOffset < catalog.Nlensobj); 254 if (VERBOSE && !(catalog.average[i].lensobjOffset < catalog.Nlensobj)) { 255 fprintf (stderr, "lensobjOffset >= catalog.Nlensobj: %d %d %d\n", i, catalog.average[i].lensobjOffset, (int) catalog.Nlensobj); 256 } 257 lensobjOffsetOK &= (catalog.average[i].lensobjOffset + catalog.average[i].Nlensobj <= catalog.Nlensobj); 258 if (VERBOSE && !(catalog.average[i].lensobjOffset + catalog.average[i].Nlensobj <= catalog.Nlensobj)) { 259 fprintf (stderr, "lensobjOffset + Nlensobj > catalog.Nlensobj : %d %d %d\n", i, catalog.average[i].Nlensobj, (int) catalog.Nlensobj); 260 } 229 261 } 230 262 … … 236 268 if (NmeasureTotal != catalog.Nmeasure) { 237 269 fprintf (stderr, "ERROR: catalog %s has an invalid Nmeasure\n", catalog.filename); 270 status = FALSE; 271 } 272 273 if (!lensingOffsetOK) { 274 fprintf (stderr, "ERROR: catalog %s has an invalid lensingOffset\n", catalog.filename); 275 status = FALSE; 276 } 277 278 if (NlensingTotal != catalog.Nlensing) { 279 fprintf (stderr, "ERROR: catalog %s has an invalid Nlensing\n", catalog.filename); 280 status = FALSE; 281 } 282 283 if (!lensobjOffsetOK) { 284 fprintf (stderr, "ERROR: catalog %s has an invalid lensobjOffset\n", catalog.filename); 285 status = FALSE; 286 } 287 288 if (NlensobjTotal != catalog.Nlensobj) { 289 fprintf (stderr, "ERROR: catalog %s has an invalid Nlensobj\n", catalog.filename); 238 290 status = FALSE; 239 291 } … … 247 299 } 248 300 249 int objIDsOK = TRUE; 250 int catIDsOK = TRUE; 251 int averefOK = TRUE; 252 253 for (i = 0; i < catalog.Naverage; i++) { 254 m = catalog.average[i].measureOffset; 255 for (j = 0; j < catalog.average[i].Nmeasure; j++) { 256 objIDsOK &= (catalog.average[i].objID == catalog.measure[m+j].objID); 257 catIDsOK &= (catalog.average[i].catID == catalog.measure[m+j].catID); 258 averefOK &= (catalog.measure[m+j].averef == i); 259 } 260 } 301 // check measure <-> average links 302 { 303 int objIDsOK = TRUE; 304 int catIDsOK = TRUE; 305 int averefOK = TRUE; 306 307 for (i = 0; i < catalog.Naverage; i++) { 308 m = catalog.average[i].measureOffset; 309 for (j = 0; j < catalog.average[i].Nmeasure; j++) { 310 objIDsOK &= (catalog.average[i].objID == catalog.measure[m+j].objID); 311 catIDsOK &= (catalog.average[i].catID == catalog.measure[m+j].catID); 312 averefOK &= (catalog.measure[m+j].averef == i); 313 } 314 } 261 315 262 if (!objIDsOK) { 263 fprintf (stderr, "ERROR: catalog %s has invalid obj IDs\n", catalog.filename); 264 status = FALSE; 265 } 266 if (!catIDsOK) { 267 fprintf (stderr, "ERROR: catalog %s has invalid cat IDs\n", catalog.filename); 268 status = FALSE; 269 } 270 if (!averefOK) { 271 fprintf (stderr, "ERROR: catalog %s has invalid averef values\n", catalog.filename); 272 status = FALSE; 316 if (!objIDsOK) { 317 fprintf (stderr, "ERROR: catalog %s has invalid obj IDs\n", catalog.filename); 318 status = FALSE; 319 } 320 if (!catIDsOK) { 321 fprintf (stderr, "ERROR: catalog %s has invalid cat IDs\n", catalog.filename); 322 status = FALSE; 323 } 324 if (!averefOK) { 325 fprintf (stderr, "ERROR: catalog %s has invalid averef values\n", catalog.filename); 326 status = FALSE; 327 } 328 } 329 330 // check lensing <-> average links 331 { 332 int objIDsOK = TRUE; 333 int catIDsOK = TRUE; 334 int averefOK = TRUE; 335 336 for (i = 0; i < catalog.Naverage; i++) { 337 m = catalog.average[i].lensingOffset; 338 for (j = 0; j < catalog.average[i].Nlensing; j++) { 339 objIDsOK &= (catalog.average[i].objID == catalog.lensing[m+j].objID); 340 catIDsOK &= (catalog.average[i].catID == catalog.lensing[m+j].catID); 341 averefOK &= (catalog.lensing[m+j].averef == i); 342 } 343 } 344 345 if (!objIDsOK) { 346 fprintf (stderr, "ERROR: catalog %s has invalid lensing obj IDs\n", catalog.filename); 347 status = FALSE; 348 } 349 if (!catIDsOK) { 350 fprintf (stderr, "ERROR: catalog %s has invalid lensing cat IDs\n", catalog.filename); 351 status = FALSE; 352 } 353 if (!averefOK) { 354 fprintf (stderr, "ERROR: catalog %s has invalid lensing averef values\n", catalog.filename); 355 status = FALSE; 356 } 357 } 358 359 // check lensobj <-> average links 360 { 361 int objIDsOK = TRUE; 362 int catIDsOK = TRUE; 363 364 for (i = 0; i < catalog.Naverage; i++) { 365 m = catalog.average[i].lensobjOffset; 366 for (j = 0; j < catalog.average[i].Nlensobj; j++) { 367 objIDsOK &= (catalog.average[i].objID == catalog.lensobj[m+j].objID); 368 catIDsOK &= (catalog.average[i].catID == catalog.lensobj[m+j].catID); 369 } 370 } 371 372 if (!objIDsOK) { 373 fprintf (stderr, "ERROR: catalog %s has invalid lensobj obj IDs\n", catalog.filename); 374 status = FALSE; 375 } 376 if (!catIDsOK) { 377 fprintf (stderr, "ERROR: catalog %s has invalid lensobj cat IDs\n", catalog.filename); 378 status = FALSE; 379 } 273 380 } 274 381 … … 321 428 } 322 429 } 430 431 for (i = 0; i < catalog[0].Naverage; i++) { 432 m = catalog[0].average[i].lensingOffset; 433 for (j = 0; j < catalog[0].average[i].Nlensing; j++) { 434 id = catalog[0].lensing[m+j].imageID; 435 if (id == 0) continue; // detections from ref photcodes can (should) have unset image IDs 436 if (id > maxID) { 437 Nfail ++; 438 continue; 439 // is this sufficient to catch IDs set without an image table? 440 } 441 if (IDlist) { 442 if (IDlist[id] < 0) { 443 Nfail ++; 444 continue; 445 } 446 } else { 447 if (id > 0) { 448 Nfail ++; 449 continue; 450 } 451 } 452 } 453 } 454 323 455 return Nfail; 324 456 } … … 382 514 return TRUE; 383 515 } 516 517 # define GET_COLUMN(OUT,NAME,TYPE) \ 518 OUT = gfits_get_bintable_column_data (&theader, &ftable, NAME, type, &Nrow, &Ncol); \ 519 myAssert (!strcmp(type, #TYPE), "wrong column type"); 520 521 // STATUS is value expected for success 522 # define CHECK_STATUS(STATUS,MSG,...) \ 523 if (!(STATUS)) { \ 524 fprintf (stderr, MSG, __VA_ARGS__); \ 525 return FALSE; \ 526 } 527 528 // write out the IDmap data for clients to read 529 int SaveImageIDsSmall(char *filename) { 530 531 Header header; 532 Header theader; 533 Matrix matrix; 534 FTable ftable; 535 536 gfits_init_header (&header); 537 header.extend = TRUE; 538 gfits_create_header (&header); 539 gfits_create_matrix (&header, &matrix); 540 541 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_IDS"); 542 543 gfits_define_bintable_column (&theader, "J", "IMAGE_IDS", "image IDs", NULL, 1.0, FT_BZERO_INT32); 544 545 // generate the output array that carries the data 546 gfits_create_table (&theader, &ftable); 547 548 // add the columns to the output array 549 gfits_set_bintable_column (&theader, &ftable, "IMAGE_IDS", IDlist, maxID + 1); 550 551 FILE *f = fopen (filename, "w"); 552 if (!f) { 553 fprintf (stderr, "ERROR: cannot open image ID file for output %s\n", filename); 554 return FALSE; 555 } 556 557 int status; 558 status = gfits_fwrite_header (f, &header); 559 CHECK_STATUS (status, "ERROR: cannot write header for image ID file %s\n", filename); 560 561 status = gfits_fwrite_matrix (f, &matrix); 562 CHECK_STATUS (status, "ERROR: cannot write matrix for image ID file %s\n", filename); 563 564 status = gfits_fwrite_Theader (f, &theader); 565 CHECK_STATUS (status, "ERROR: cannot write table header for image ID file %s\n", filename); 566 567 status = gfits_fwrite_table (f, &ftable); 568 CHECK_STATUS (status, "ERROR: cannot write table data for image ID file %s\n", filename); 569 570 gfits_free_header (&header); 571 gfits_free_matrix (&matrix); 572 gfits_free_header (&theader); 573 gfits_free_table (&ftable); 574 575 int fd = fileno (f); 576 577 status = fflush (f); 578 CHECK_STATUS (!status, "ERROR: cannot flush file image ID file %s\n", filename); 579 580 status = fsync (fd); 581 CHECK_STATUS (!status, "ERROR: cannot flush file image ID file %s\n", filename); 582 583 status = fclose (f); 584 CHECK_STATUS (!status, "ERROR: problem closing image ID file file %s\n", filename); 585 586 return TRUE; 587 } 588 589 int LoadImageIDsSmall (char *filename) { 590 591 int Ncol; 592 off_t Nrow; 593 Header header; 594 Header theader; 595 Matrix matrix; 596 FTable ftable; 597 598 FILE *f = fopen (filename, "r"); 599 if (!f) { 600 fprintf (stderr, "ERROR: cannot open image subset file %s\n", filename); 601 return FALSE; 602 } 603 604 /* load in PHU segment (ignore) */ 605 if (!gfits_fread_header (f, &header)) { 606 if (VERBOSE) fprintf (stderr, "can't read image subset header\n"); 607 fclose (f); 608 return FALSE; 609 } 610 if (!gfits_fread_matrix (f, &matrix, &header)) { 611 if (VERBOSE) fprintf (stderr, "can't read image subset matrix\n"); 612 gfits_free_header (&header); 613 fclose (f); 614 return FALSE; 615 } 616 617 ftable.header = &theader; 618 619 // load data for this header 620 if (!gfits_load_header (f, &theader)) { 621 fclose (f); 622 return FALSE; 623 } 624 625 // read the fits table bytes 626 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) { 627 fclose (f); 628 return FALSE; 629 } 630 fclose (f); 631 632 char type[16]; 633 634 GET_COLUMN (IDlist, "IMAGE_IDS", int); 635 maxID = Nrow - 1; 636 fprintf (stderr, "loaded data for %lld images\n", (long long) Nrow); 637 638 return TRUE; 639 } 640 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/merge_catalogs_new.c
r28855 r37822 8 8 // input entries always define new objects 9 9 10 #define notyet 111 12 10 int merge_catalogs_new (SkyRegion *region, Catalog *output, Catalog *input, int *secfiltMap) { 13 11 14 12 off_t i, j, offset; 15 off_t NAVERAGE, NMEASURE, N average, Nmeasure, NsecfiltIn, NsecfiltOut, Nm;13 off_t NAVERAGE, NMEASURE, NLENSING, NSTARPAR, Naverage, Nmeasure, Nlensing, Nstarpar, NsecfiltIn, NsecfiltOut, Nm; 16 14 17 15 Naverage = output[0].Naverage; 18 16 Nmeasure = output[0].Nmeasure; 17 Nlensing = output[0].Nlensing; 18 Nstarpar = output[0].Nstarpar; 19 19 20 20 NsecfiltOut = output[0].Nsecfilt; … … 23 23 NAVERAGE = Naverage + 100; 24 24 NMEASURE = Nmeasure + 1000; 25 NLENSING = Nlensing + 1000; 26 NSTARPAR = Nstarpar + 1000; 25 27 26 28 REALLOCATE (output[0].average, Average, NAVERAGE); 27 29 REALLOCATE (output[0].secfilt, SecFilt, NAVERAGE*NsecfiltOut); 28 30 REALLOCATE (output[0].measure, Measure, NMEASURE); 31 REALLOCATE (output[0].lensing, Lensing, NLENSING); 32 REALLOCATE (output[0].starpar, StarPar, NSTARPAR); 29 33 30 34 // add all of these entries to the existing catalog … … 63 67 } 64 68 output[0].average[Naverage].Nmeasure = Nm; 69 70 Nm = 0; 71 for (j = 0; j < input[0].average[i].Nlensing; j++) { 72 offset = input[0].average[i].lensingOffset + j; 73 74 output[0].lensing[Nlensing] = input[0].lensing[offset]; 75 output[0].lensing[Nlensing].averef = Naverage; 76 77 Nlensing ++; 78 Nm ++; 79 if (Nlensing == NLENSING) { 80 NLENSING += 1000; 81 REALLOCATE (output[0].lensing, Lensing, NLENSING); 82 } 83 } 84 output[0].average[Naverage].Nlensing = Nm; 85 86 Nm = 0; 87 for (j = 0; j < input[0].average[i].Nstarpar; j++) { 88 offset = input[0].average[i].starparOffset + j; 89 90 output[0].starpar[Nstarpar] = input[0].starpar[offset]; 91 output[0].starpar[Nstarpar].averef = Naverage; 92 93 Nstarpar ++; 94 Nm ++; 95 if (Nstarpar == NSTARPAR) { 96 NSTARPAR += 1000; 97 REALLOCATE (output[0].starpar, StarPar, NSTARPAR); 98 } 99 } 100 output[0].average[Naverage].Nstarpar = Nm; 101 65 102 Naverage ++; 66 103 if (Naverage == NAVERAGE) { … … 72 109 REALLOCATE (output[0].average, Average, MAX (Naverage, 1)); 73 110 REALLOCATE (output[0].measure, Measure, MAX (Nmeasure, 1)); 111 REALLOCATE (output[0].lensing, Lensing, MAX (Nlensing, 1)); 112 REALLOCATE (output[0].starpar, StarPar, MAX (Nstarpar, 1)); 74 113 REALLOCATE (output[0].secfilt, SecFilt, NsecfiltOut*MAX (Naverage, 1)); 75 114 output[0].Naverage = Naverage; 76 output[0].Nmeasure = Nmeasure; 115 output[0].Nlensing = Nlensing; 116 output[0].Nstarpar = Nstarpar; 77 117 output[0].Nsecf_mem = Naverage * NsecfiltOut; 78 118 … … 84 124 85 125 if (VERBOSE) { 86 fprintf (stderr, OFF_T_FMT": using "OFF_T_FMT" stars ("OFF_T_FMT" measures ) for catalog\n",126 fprintf (stderr, OFF_T_FMT": using "OFF_T_FMT" stars ("OFF_T_FMT" measures, "OFF_T_FMT" lensing) for catalog\n", 87 127 i, 88 128 output[0].Naverage, 89 output[0].Nmeasure); 129 output[0].Nmeasure, 130 output[0].Nlensing); 90 131 } 91 132 return (TRUE); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvomerge/src/merge_catalogs_old.c
r37046 r37822 4 4 # define IN_REGION(R,D) ( \ 5 5 ((D) >= region[0].Dmin) && ((D) < region[0].Dmax) && \ 6 ((R) >= region[0].Rmin) && ((R) < region[0].Rmax))6 ((R) >= region[0].Rmin) && ((R) < region[0].Rmax)) 7 7 8 8 // merge the input data into the output catalog … … 14 14 double *X1, *Y1, *X2, *Y2; 15 15 double dX, dY, dR; 16 off_t *N1, *N2, *next_meas;17 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch ;16 off_t *N1, *N2, *next_meas, *next_lens, *next_star; 17 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch, Nlens, NLENS, Nstar, NSTAR; 18 18 int NsecfiltIn; 19 19 int NsecfiltOut; … … 52 52 Nmatch = 0; 53 53 NMEAS = Nmeas = output[0].Nmeasure; 54 NLENS = Nlens = output[0].Nlensing; 55 NSTAR = Nstar = output[0].Nstarpar; 54 56 55 57 // current max obj ID for this catalog … … 63 65 * coordops.update.c). We use the center of the region (catalog) for crval1,2. 64 66 */ 67 68 InitCoords (&tcoords, "DEC--ARC"); 65 69 tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax); 66 70 if (region[0].Dmax < 90) { … … 69 73 tcoords.crval2 = 90.0; 70 74 } 71 tcoords.crpix1 = 0;72 tcoords.crpix2 = 0;73 75 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 74 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;75 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;76 tcoords.Npolyterms = 1;77 strcpy (tcoords.ctype, "DEC--ARC");78 76 79 77 if (VERBOSE) fprintf (stderr, "merging %s into %s\n", input[0].filename, output[0].filename); … … 113 111 } 114 112 115 116 113 /* set up pointers for linked list of measure */ 117 114 if (output[0].sorted && (output[0].Nmeasure >= output[0].Nmeas_disk)) { … … 119 116 // is sorted while processed 120 117 next_meas = init_measure_links (output[0].average, Nave, output[0].measure, Nmeas); 118 next_lens = init_lensing_links (output[0].average, Nave, output[0].lensing, Nlens); 119 next_star = init_starpar_links (output[0].average, Nave, output[0].starpar, Nstar); 121 120 } else { 122 121 next_meas = build_measure_links (output[0].average, Nave, output[0].measure, Nmeas); 122 next_lens = build_lensing_links (output[0].average, Nave, output[0].lensing, Nlens); 123 next_star = build_starpar_links (output[0].average, Nave, output[0].starpar, Nstar); 123 124 } 124 125 … … 182 183 REALLOCATE (output[0].measure, Measure, NMEAS); 183 184 } 185 if (Nlens + input[0].average[N].Nlensing >= NLENS) { 186 NLENS = Nlens + input[0].average[N].Nlensing + 1000; 187 REALLOCATE (next_lens, off_t, NLENS); 188 REALLOCATE (output[0].lensing, Lensing, NLENS); 189 } 190 if (Nstar + input[0].average[N].Nstarpar >= NSTAR) { 191 NSTAR = Nstar + input[0].average[N].Nstarpar + 1000; 192 REALLOCATE (next_star, off_t, NSTAR); 193 REALLOCATE (output[0].starpar, StarPar, NSTAR); 194 } 184 195 185 196 // 4) average properties from the input and the output db need to be properly merged. … … 191 202 if (REPLACE_BY_PHOTCODE) { 192 203 // index to first measure for this object 204 // XXX this does not support lensing measurements 193 205 int Mout = output[0].average[n].measureOffset; 194 206 if (replace_match(&output[0].average[n], &output[0].measure[Mout], &input[0].average[N], &input[0].measure[offset])) { … … 248 260 } 249 261 262 // if lensing measurements exist, add them too 263 if (output[0].lensing) { 264 for (Nin = 0; Nin < input[0].average[N].Nlensing; Nin++) { 265 /* add to end of lensing list */ 266 add_lens_link (&output[0].average[n], next_lens, Nlens, NLENS); 267 268 // set the new lensing 269 off_t lensoff = input[0].average[N].lensingOffset + Nin; 270 output[0].lensing[Nlens] = input[0].lensing[lensoff]; 271 272 output[0].lensing[Nlens].averef = n; 273 output[0].lensing[Nlens].objID = output[0].average[n].objID; 274 output[0].lensing[Nlens].catID = output[0].catID; 275 output[0].average[n].Nlensing ++; 276 Nlens ++; 277 } 278 } 279 280 // if lensing measurements exist, add them too 281 if (output[0].starpar) { 282 for (Nin = 0; Nin < input[0].average[N].Nstarpar; Nin++) { 283 /* add to end of lensing list */ 284 add_star_link (&output[0].average[n], next_star, Nstar, NSTAR); 285 286 // set the new starpar 287 off_t staroff = input[0].average[N].starparOffset + Nin; 288 output[0].starpar[Nstar] = input[0].starpar[staroff]; 289 290 output[0].starpar[Nstar].averef = n; 291 output[0].starpar[Nstar].objID = output[0].average[n].objID; 292 output[0].starpar[Nstar].catID = output[0].catID; 293 output[0].average[n].Nstarpar ++; 294 Nstar ++; 295 } 296 } 297 250 298 // update the average properties to reflect the incoming entries: 251 299 // if the original value is NAN but the input value is not, accept the input: … … 288 336 REALLOCATE (output[0].measure, Measure, NMEAS); 289 337 } 338 if (Nlens + input[0].average[N].Nlensing >= NLENS) { 339 NLENS = Nlens + input[0].average[N].Nlensing + 1000; 340 REALLOCATE (next_lens, off_t, NLENS); 341 REALLOCATE (output[0].lensing, Lensing, NLENS); 342 } 343 if (Nstar + input[0].average[N].Nstarpar >= NSTAR) { 344 NSTAR = Nstar + input[0].average[N].Nstarpar + 1000; 345 REALLOCATE (next_star, off_t, NSTAR); 346 REALLOCATE (output[0].starpar, StarPar, NSTAR); 347 } 290 348 if (Nave >= NAVE) { 291 349 NAVE = Nave + 1000; … … 295 353 296 354 if (input[0].found_t[N] >= 0) continue; 297 if (!IN_REGION (input[0].average[N].R, input[0].average[N].D)) continue; 355 356 // if we are using MATCHED_TABLES, we are going to leave the edge cases in their 357 // source catalog, even if they have leaked beyond the edge 358 if (!MATCHED_TABLES && !IN_REGION (input[0].average[N].R, input[0].average[N].D)) continue; 298 359 299 360 // XXX should we accept the input measurements for these fields? … … 355 416 next_meas[Nmeas - Ngroup + j] = Nmeas - Ngroup + j + 1; 356 417 } 418 419 /** add lensing for this input average object **/ 420 if (output[0].lensing) { 421 output[0].average[Nave].lensingOffset = Nlens; 422 for (Nin = 0; Nin < input[0].average[N].Nlensing; Nin ++) { 423 // supply the lensing values from this detection 424 off_t lensoff = input[0].average[N].lensingOffset + Nin; 425 output[0].lensing[Nlens] = input[0].lensing[lensoff]; 426 427 // the following lensing elements cannot be set until here: 428 output[0].lensing[Nlens].averef = Nave; 429 output[0].lensing[Nlens].objID = output[0].average[Nave].objID; 430 output[0].lensing[Nlens].catID = output[0].catID; 431 432 // as we add lensing, update Nlensing to match 433 output[0].average[Nave].Nlensing ++; 434 435 /* we set next[Nlens] to -1 here, and update correctly below */ 436 next_lens[Nlens] = -1; 437 Nlens ++; 438 } 439 int Ngroup = input[0].average[N].Nlensing; 440 for (j = 0; j < Ngroup - 1; j++) { 441 next_lens[Nlens - Ngroup + j] = Nlens - Ngroup + j + 1; 442 } 443 } 444 445 /** add starpar for this input average object **/ 446 if (output[0].starpar) { 447 output[0].average[Nave].starparOffset = Nstar; 448 for (Nin = 0; Nin < input[0].average[N].Nstarpar; Nin ++) { 449 // supply the starpar values from this detection 450 off_t staroff = input[0].average[N].starparOffset + Nin; 451 output[0].starpar[Nstar] = input[0].starpar[staroff]; 452 453 // the following starpar elements cannot be set until here: 454 output[0].starpar[Nstar].averef = Nave; 455 output[0].starpar[Nstar].objID = output[0].average[Nave].objID; 456 output[0].starpar[Nstar].catID = output[0].catID; 457 458 // as we add starpar, update Nstarpar to match 459 output[0].average[Nave].Nstarpar ++; 460 461 /* we set next[Nstar] to -1 here, and update correctly below */ 462 next_star[Nstar] = -1; 463 Nstar ++; 464 } 465 int Ngroup = input[0].average[N].Nstarpar; 466 for (j = 0; j < Ngroup - 1; j++) { 467 next_star[Nstar - Ngroup + j] = Nstar - Ngroup + j + 1; 468 } 469 } 470 357 471 Nave ++; 358 472 } … … 362 476 REALLOCATE (output[0].average, Average, Nave); 363 477 REALLOCATE (output[0].measure, Measure, Nmeas); 478 REALLOCATE (output[0].lensing, Lensing, Nlens); 479 REALLOCATE (output[0].starpar, StarPar, Nstar); 364 480 365 481 # define NOSORT 0 … … 369 485 output[0].sorted = TRUE; 370 486 output[0].measure = sort_measure (output[0].average, Nave, output[0].measure, Nmeas, next_meas); 487 output[0].lensing = sort_lensing (output[0].average, Nave, output[0].lensing, Nlens, next_lens); 488 output[0].starpar = sort_starpar (output[0].average, Nave, output[0].starpar, Nstar, next_star); 371 489 } 372 490 … … 384 502 output[0].Naverage = Nave; 385 503 output[0].Nmeasure = Nmeas; 504 output[0].Nlensing = Nlens; 505 output[0].Nstarpar = Nstar; 386 506 output[0].Nsecf_mem = Nave*NsecfiltOut; 387 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);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); 388 508 389 509 free (next_meas); 510 free (next_lens); 511 free (next_star); 390 512 391 513 free (X2); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvopsps/Makefile
r35098 r37822 30 30 $(SRC)/insert_objects_dvopsps.$(ARCH).o \ 31 31 $(SRC)/insert_objects_dvopsps_catalog.$(ARCH).o \ 32 $(SRC)/insert_FWobjects_dvopsps.$(ARCH).o \ 33 $(SRC)/insert_FWobjects_dvopsps_catalog.$(ARCH).o \ 32 34 $(SRC)/insert_detections_dvopsps.$(ARCH).o \ 33 35 $(SRC)/insert_detections_dvopsps_catalog.$(ARCH).o … … 46 48 $(SRC)/insert_objects_dvopsps.$(ARCH).o \ 47 49 $(SRC)/insert_objects_dvopsps_catalog.$(ARCH).o \ 50 $(SRC)/insert_FWobjects_dvopsps.$(ARCH).o \ 51 $(SRC)/insert_FWobjects_dvopsps_catalog.$(ARCH).o \ 48 52 $(SRC)/insert_detections_dvopsps.$(ARCH).o \ 49 53 $(SRC)/insert_detections_dvopsps_catalog.$(ARCH).o -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvopsps/include/dvopsps.h
r36188 r37822 9 9 10 10 typedef struct { 11 int imageID; 12 unsigned int ippDetectID; 11 uint64_t objID; 13 12 uint64_t detectID; 14 13 uint64_t ippObjID; 15 uint64_t objID; 16 int photcode; 17 unsigned int flags; 18 float zp; 19 float zpErr; 20 float airMass; 21 float expTime; 14 unsigned int ippDetectID; 15 int imageID; 16 int catID; 22 17 double ra; 23 18 double dec; 24 19 float raErr; 25 20 float decErr; 21 float zp; 22 float telluricExt; 23 float airmass; 24 float expTime; 25 26 float Mpsf; 27 float dMpsf; 28 float Mkron; 29 float dMkron; 30 float Map; 31 float dMap; 32 33 unsigned int flags; 26 34 } Detections; 27 35 … … 78 86 79 87 int insert_detections_mysql_commit PROTO((IOBuffer *buffer, MYSQL *mysql)); 80 int insert_detections_mysql_value PROTO((IOBuffer *buffer, Average *average, Measure *measure));88 // int insert_detections_mysql_value PROTO((IOBuffer *buffer, Average *average, Measure *measure)); 81 89 int insert_detections_mysql_init PROTO((IOBuffer *buffer)); 82 90 83 91 int insert_detections_mysql_array PROTO((MYSQL *mysql, Detections *detections, int Ndetections)); 84 92 int insert_detections_mysql_detvalue PROTO((IOBuffer *buffer, Detections *detection)); 93 int assign_detection_values PROTO((Detections *detection, Measure *measure, Average *average)); 85 94 86 95 int init_detections PROTO(()); … … 93 102 94 103 int insert_objects_mysql_create_tables PROTO((char *basename, MYSQL *mysql)); 95 96 104 int insert_objects_mysql_commit PROTO((IOBuffer *ave_buffer, IOBuffer *sec_buffer, MYSQL *mysql)); 97 105 int insert_objects_mysql_value PROTO((IOBuffer *ave_buffer, IOBuffer *sec_buffer, Average *average, SecFilt *secfilt, int Nsecfilt)); 98 106 int insert_objects_mysql_init PROTO((IOBuffer *ave_buffer, IOBuffer *sec_buffer, char *basename)); 107 108 int insert_FWobjects_dvopsps PROTO(()); 109 int insert_FWobjects_dvopsps_parallel PROTO((SkyList *sky)); 110 int insert_FWobjects_dvopsps_catalog PROTO((Catalog *catalog, char *basename, MYSQL *mysql)); 111 112 int insert_FWobjects_mysql_create_tables PROTO((char *basename, MYSQL *mysql)); 113 int insert_FWobjects_mysql_init PROTO((IOBuffer *ave_buffer, IOBuffer *sec_buffer, IOBuffer *cpy_buffer, char *basename)); 114 int insert_FWobjects_mysql_value PROTO((IOBuffer *ave_buffer, IOBuffer *sec_buffer, IOBuffer *cpy_buffer, Average *average, SecFilt *secfilt, int Nsecfilt, Lensobj *lensobj, int Nlensobj)); 115 int insert_FWobjects_mysql_commit PROTO((IOBuffer *ave_buffer, IOBuffer *sec_buffer, IOBuffer *cpy_buffer, MYSQL *mysql)); 99 116 100 117 int insert_skytable PROTO(()); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvopsps/src/DetectionOps.c
r35578 r37822 1 1 # include "dvopsps.h" 2 # define BZERO_INT16 1.0*0x80003 # define BZERO_INT32 1.0*0x800000004 # define BZERO_INT64 1.0*0x80000000000000005 2 6 3 # define GET_COLUMN(OUT,NAME,TYPE) \ … … 49 46 50 47 // need to create and assign to flat-field correction 51 GET_COLUMN(imageID , "imageID", int); 52 GET_COLUMN(ippDetectID , "ippDetectID", int); 48 GET_COLUMN(objID , "objID", int64_t); 53 49 GET_COLUMN(detectID , "detectID", int64_t); 54 50 GET_COLUMN(ippObjID , "ippObjID", int64_t); 55 GET_COLUMN(objID , "objID", int64_t); 56 GET_COLUMN(photcode , "photcode", int); 57 GET_COLUMN(flags , "flags", int); 58 GET_COLUMN(zp , "zp", float); 59 GET_COLUMN(zpErr , "zpErr", float); 60 GET_COLUMN(airMass , "airMass", float); 61 GET_COLUMN(expTime , "expTime", float); 51 GET_COLUMN(ippDetectID , "ippDetectID", int); 52 GET_COLUMN(imageID , "imageID", int); 53 GET_COLUMN(catID , "catID", int); 62 54 GET_COLUMN(ra , "ra", double); // XXX signed vs unsigned? 63 55 GET_COLUMN(dec , "dec", double); 64 56 GET_COLUMN(raErr , "raErr", float); 65 57 GET_COLUMN(decErr , "decErr", float); 58 GET_COLUMN(zp , "zp", float); 59 GET_COLUMN(telluricExt , "telluricExt", float); 60 GET_COLUMN(airmass , "airmass", float); 61 GET_COLUMN(expTime , "expTime", float); 62 GET_COLUMN(Mpsf , "Mpsf", float); 63 GET_COLUMN(dMpsf , "dMpsf", float); 64 GET_COLUMN(Mkron , "Mkron", float); 65 GET_COLUMN(dMkron , "dMkron", float); 66 GET_COLUMN(Map , "Map", float); 67 GET_COLUMN(dMap , "dMap", float); 68 GET_COLUMN(flags , "flags", int); 66 69 gfits_free_header (&theader); 67 70 gfits_free_table (&ftable); … … 69 72 ALLOCATE (detections, Detections, Nrow); 70 73 for (i = 0; i < Nrow; i++) { 71 detections[i].imageID = imageID[i]; 72 detections[i].ippDetectID = ippDetectID[i]; 74 detections[i].objID = objID[i]; 73 75 detections[i].detectID = detectID[i]; 74 76 detections[i].ippObjID = ippObjID[i]; 75 detections[i].objID = objID[i]; 76 detections[i].photcode = photcode[i]; 77 detections[i].flags = flags[i]; 78 detections[i].zp = zp[i]; 79 detections[i].zpErr = zpErr[i]; 80 detections[i].airMass = airMass[i]; 81 detections[i].expTime = expTime[i]; 77 detections[i].ippDetectID = ippDetectID[i]; 78 detections[i].imageID = imageID[i]; 79 detections[i].catID = catID[i]; 82 80 detections[i].ra = ra[i]; 83 81 detections[i].dec = dec[i]; 84 82 detections[i].raErr = raErr[i]; 85 83 detections[i].decErr = decErr[i]; 84 detections[i].zp = zp[i]; 85 detections[i].telluricExt = telluricExt[i]; 86 detections[i].airmass = airmass[i]; 87 detections[i].expTime = expTime[i]; 88 detections[i].Mpsf = Mpsf[i]; 89 detections[i].dMpsf = dMpsf[i]; 90 detections[i].Mkron = Mkron[i]; 91 detections[i].dMkron = dMkron[i]; 92 detections[i].Map = Map[i]; 93 detections[i].dMap = dMap[i]; 94 detections[i].flags = flags[i]; 86 95 } 87 96 fprintf (stderr, "loaded data for %lld detections\n", (long long) Nrow); 88 97 89 free (imageID ); 90 free (ippDetectID); 98 free (objID ); 91 99 free (detectID ); 92 100 free (ippObjID ); 93 free (objID ); 94 free (photcode ); 95 free (flags ); 96 free (zp ); 97 free (zpErr ); 98 free (airMass ); 99 free (expTime ); 101 free (ippDetectID); 102 free (imageID ); 103 free (catID ); 100 104 free (ra ); 101 105 free (dec ); 102 106 free (raErr ); 103 107 free (decErr ); 108 free (zp ); 109 free (telluricExt); 110 free (airmass ); 111 free (expTime ); 112 free (Mpsf ); 113 free (dMpsf ); 114 free (Mkron ); 115 free (dMkron ); 116 free (Map ); 117 free (dMap ); 118 free (flags ); 104 119 105 120 gfits_free_header (&header); … … 149 164 150 165 // XXX need to get the bzero values right 151 gfits_define_bintable_column (&theader, "J", "imageID", NULL, NULL, 1.0, BZERO_INT32); 152 gfits_define_bintable_column (&theader, "J", "ippDetectID", NULL, NULL, 1.0, BZERO_INT32); 166 gfits_define_bintable_column (&theader, "K", "objID", NULL, NULL, 1.0, 0); 153 167 gfits_define_bintable_column (&theader, "K", "detectID", NULL, NULL, 1.0, 0); 154 168 gfits_define_bintable_column (&theader, "K", "ippObjID", NULL, NULL, 1.0, 0); 155 gfits_define_bintable_column (&theader, "K", "objID", NULL, NULL, 1.0, 0); 156 // gfits_define_bintable_column (&theader, "K", "detectID", NULL, NULL, 1.0, BZERO_INT64); 157 // gfits_define_bintable_column (&theader, "K", "ippObjID", NULL, NULL, 1.0, BZERO_INT64); 158 // gfits_define_bintable_column (&theader, "K", "objID", NULL, NULL, 1.0, BZERO_INT64); 159 gfits_define_bintable_column (&theader, "J", "photcode", NULL, NULL, 1.0, 0.0); 160 gfits_define_bintable_column (&theader, "J", "flags", NULL, NULL, 1.0, BZERO_INT32); 161 gfits_define_bintable_column (&theader, "E", "zp", NULL, NULL, 1.0, 0.0); 162 gfits_define_bintable_column (&theader, "E", "zpErr", NULL, NULL, 1.0, 0.0); 163 gfits_define_bintable_column (&theader, "E", "airMass", NULL, NULL, 1.0, 0.0); 164 gfits_define_bintable_column (&theader, "E", "expTime", NULL, NULL, 1.0, 0.0); 169 gfits_define_bintable_column (&theader, "J", "ippDetectID", NULL, NULL, 1.0, FT_BZERO_INT32); 170 gfits_define_bintable_column (&theader, "J", "imageID", NULL, NULL, 1.0, FT_BZERO_INT32); 171 gfits_define_bintable_column (&theader, "J", "catID", NULL, NULL, 1.0, FT_BZERO_INT32); 165 172 gfits_define_bintable_column (&theader, "D", "ra", NULL, NULL, 1.0, 0.0); 166 173 gfits_define_bintable_column (&theader, "D", "dec", NULL, NULL, 1.0, 0.0); 167 174 gfits_define_bintable_column (&theader, "E", "raErr", NULL, NULL, 1.0, 0.0); 168 175 gfits_define_bintable_column (&theader, "E", "decErr", NULL, NULL, 1.0, 0.0); 176 gfits_define_bintable_column (&theader, "E", "zp", NULL, NULL, 1.0, 0.0); 177 gfits_define_bintable_column (&theader, "E", "telluricExt", NULL, NULL, 1.0, 0.0); 178 gfits_define_bintable_column (&theader, "E", "airmass", NULL, NULL, 1.0, 0.0); 179 gfits_define_bintable_column (&theader, "E", "expTime", NULL, NULL, 1.0, 0.0); 180 gfits_define_bintable_column (&theader, "E", "Mpsf", NULL, NULL, 1.0, 0.0); 181 gfits_define_bintable_column (&theader, "E", "dMpsf", NULL, NULL, 1.0, 0.0); 182 gfits_define_bintable_column (&theader, "E", "Mkron", NULL, NULL, 1.0, 0.0); 183 gfits_define_bintable_column (&theader, "E", "dMkron", NULL, NULL, 1.0, 0.0); 184 gfits_define_bintable_column (&theader, "E", "Map", NULL, NULL, 1.0, 0.0); 185 gfits_define_bintable_column (&theader, "E", "dMap", NULL, NULL, 1.0, 0.0); 186 gfits_define_bintable_column (&theader, "J", "flags", NULL, NULL, 1.0, FT_BZERO_INT32); 169 187 170 188 // generate the output array that carries the data … … 172 190 173 191 // create intermediate storage arrays 174 int32_t *imageID ; ALLOCATE (imageID , int32_t, Ndetections); 175 uint32_t *ippDetectID ; ALLOCATE (ippDetectID , uint32_t, Ndetections); 192 uint64_t *objID ; ALLOCATE (objID , uint64_t, Ndetections); 176 193 uint64_t *detectID ; ALLOCATE (detectID , uint64_t, Ndetections); 177 194 uint64_t *ippObjID ; ALLOCATE (ippObjID , uint64_t, Ndetections); 178 uint64_t *objID ; ALLOCATE (objID , uint64_t, Ndetections); 179 int *photcode ; ALLOCATE (photcode , int, Ndetections); 180 uint32_t *flags ; ALLOCATE (flags , uint32_t, Ndetections); 181 float *zp ; ALLOCATE (zp , float, Ndetections); 182 float *zpErr ; ALLOCATE (zpErr , float, Ndetections); 183 float *airMass ; ALLOCATE (airMass , float, Ndetections); 184 float *expTime ; ALLOCATE (expTime , float, Ndetections); 195 uint32_t *ippDetectID ; ALLOCATE (ippDetectID , uint32_t, Ndetections); 196 int32_t *imageID ; ALLOCATE (imageID , int32_t, Ndetections); 197 int32_t *catID ; ALLOCATE (catID , int32_t, Ndetections); 185 198 double *ra ; ALLOCATE (ra , double, Ndetections); 186 199 double *dec ; ALLOCATE (dec , double, Ndetections); 187 200 float *raErr ; ALLOCATE (raErr , float, Ndetections); 188 201 float *decErr ; ALLOCATE (decErr , float, Ndetections); 202 float *zp ; ALLOCATE (zp , float, Ndetections); 203 float *telluricExt ; ALLOCATE (telluricExt , float, Ndetections); 204 float *airmass ; ALLOCATE (airmass , float, Ndetections); 205 float *expTime ; ALLOCATE (expTime , float, Ndetections); 206 float *Mpsf ; ALLOCATE (Mpsf , float, Ndetections); 207 float *dMpsf ; ALLOCATE (dMpsf , float, Ndetections); 208 float *Mkron ; ALLOCATE (Mkron , float, Ndetections); 209 float *dMkron ; ALLOCATE (dMkron , float, Ndetections); 210 float *Map ; ALLOCATE (Map , float, Ndetections); 211 float *dMap ; ALLOCATE (dMap , float, Ndetections); 212 uint32_t *flags ; ALLOCATE (flags , uint32_t, Ndetections); 189 213 190 214 // assign the storage arrays 191 215 for (i = 0; i < Ndetections; i++) { 192 imageID[i] = detections[i].imageID ; 193 ippDetectID[i] = detections[i].ippDetectID ; 216 objID[i] = detections[i].objID ; 194 217 detectID[i] = detections[i].detectID ; 195 218 ippObjID[i] = detections[i].ippObjID ; 196 objID[i] = detections[i].objID ; 197 photcode[i] = detections[i].photcode ; 198 flags[i] = detections[i].flags ; 199 zp[i] = detections[i].zp ; 200 zpErr[i] = detections[i].zpErr ; 201 airMass[i] = detections[i].airMass ; 202 expTime[i] = detections[i].expTime ; 219 ippDetectID[i] = detections[i].ippDetectID ; 220 imageID[i] = detections[i].imageID ; 221 catID[i] = detections[i].catID ; 203 222 ra[i] = detections[i].ra ; 204 223 dec[i] = detections[i].dec ; 205 224 raErr[i] = detections[i].raErr ; 206 225 decErr[i] = detections[i].decErr ; 226 zp[i] = detections[i].zp ; 227 telluricExt[i] = detections[i].telluricExt ; 228 airmass[i] = detections[i].airmass ; 229 expTime[i] = detections[i].expTime ; 230 Mpsf[i] = detections[i].Mpsf ; 231 dMpsf[i] = detections[i].dMpsf ; 232 Mkron[i] = detections[i].Mkron ; 233 dMkron[i] = detections[i].dMkron ; 234 Map[i] = detections[i].Map ; 235 dMap[i] = detections[i].dMap ; 236 flags[i] = detections[i].flags ; 207 237 } 208 238 209 239 // add the columns to the output array 210 gfits_set_bintable_column (&theader, &ftable, "imageID", imageID , Ndetections); 211 gfits_set_bintable_column (&theader, &ftable, "ippDetectID", ippDetectID , Ndetections); 240 gfits_set_bintable_column (&theader, &ftable, "objID", objID , Ndetections); 212 241 gfits_set_bintable_column (&theader, &ftable, "detectID", detectID , Ndetections); 213 242 gfits_set_bintable_column (&theader, &ftable, "ippObjID", ippObjID , Ndetections); 214 gfits_set_bintable_column (&theader, &ftable, "objID", objID , Ndetections); 215 gfits_set_bintable_column (&theader, &ftable, "photcode", photcode , Ndetections); 216 gfits_set_bintable_column (&theader, &ftable, "flags", flags , Ndetections); 217 gfits_set_bintable_column (&theader, &ftable, "zp", zp , Ndetections); 218 gfits_set_bintable_column (&theader, &ftable, "zpErr", zpErr , Ndetections); 219 gfits_set_bintable_column (&theader, &ftable, "airMass", airMass , Ndetections); 220 gfits_set_bintable_column (&theader, &ftable, "expTime", expTime , Ndetections); 243 gfits_set_bintable_column (&theader, &ftable, "ippDetectID", ippDetectID , Ndetections); 244 gfits_set_bintable_column (&theader, &ftable, "imageID", imageID , Ndetections); 245 gfits_set_bintable_column (&theader, &ftable, "catID", catID , Ndetections); 221 246 gfits_set_bintable_column (&theader, &ftable, "ra", ra , Ndetections); 222 247 gfits_set_bintable_column (&theader, &ftable, "dec", dec , Ndetections); 223 248 gfits_set_bintable_column (&theader, &ftable, "raErr", raErr , Ndetections); 224 249 gfits_set_bintable_column (&theader, &ftable, "decErr", decErr , Ndetections); 225 226 free (imageID ); 227 free (ippDetectID ); 250 gfits_set_bintable_column (&theader, &ftable, "zp", zp , Ndetections); 251 gfits_set_bintable_column (&theader, &ftable, "telluricExt", telluricExt , Ndetections); 252 gfits_set_bintable_column (&theader, &ftable, "airmass", airmass , Ndetections); 253 gfits_set_bintable_column (&theader, &ftable, "expTime", expTime , Ndetections); 254 gfits_set_bintable_column (&theader, &ftable, "Mpsf", Mpsf , Ndetections); 255 gfits_set_bintable_column (&theader, &ftable, "dMpsf", dMpsf , Ndetections); 256 gfits_set_bintable_column (&theader, &ftable, "Mkron", Mkron , Ndetections); 257 gfits_set_bintable_column (&theader, &ftable, "dMkron", dMkron , Ndetections); 258 gfits_set_bintable_column (&theader, &ftable, "Map", Map , Ndetections); 259 gfits_set_bintable_column (&theader, &ftable, "dMap", dMap , Ndetections); 260 gfits_set_bintable_column (&theader, &ftable, "flags", flags , Ndetections); 261 262 free (objID ); 228 263 free (detectID ); 229 264 free (ippObjID ); 230 free (objID ); 231 free (photcode ); 232 free (flags ); 233 free (zp ); 234 free (zpErr ); 235 free (airMass ); 236 free (expTime ); 265 free (ippDetectID ); 266 free (imageID ); 267 free (catID ); 237 268 free (ra ); 238 269 free (dec ); 239 270 free (raErr ); 240 271 free (decErr ); 272 free (zp ); 273 free (telluricExt ); 274 free (airmass ); 275 free (expTime ); 276 free (Mpsf ); 277 free (dMpsf ); 278 free (Mkron ); 279 free (dMkron ); 280 free (Map ); 281 free (dMap ); 282 free (flags ); 241 283 242 284 gfits_fwrite_Theader (f, &theader); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvopsps/src/dvopsps.c
r35098 r37822 14 14 if (!strcasecmp (argv[1], "objects")) { 15 15 status = insert_objects_dvopsps (); 16 } 17 if (!strcasecmp (argv[1], "forced_warp_objects")) { 18 status = insert_FWobjects_dvopsps (); 16 19 } 17 20 if (!strcasecmp (argv[1], "skytable")) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvopsps/src/dvopsps_client.c
r35111 r37822 22 22 status = insert_objects_dvopsps (); 23 23 } 24 if (!strcasecmp (argv[1], "forced_warp_objects")) { 25 status = insert_FWobjects_dvopsps (); 26 } 24 27 if (status == -1) { 25 28 fprintf (stderr, "invalid mode, should be : detections, skytable\n"); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvopsps/src/initialize_dvopsps.c
r36188 r37822 21 21 fprintf (stderr, "\n"); 22 22 23 fprintf (stderr, " (mode) is one of detections, objects, skytable\n");23 fprintf (stderr, " (mode) is one of detections, objects, forced_warp_objects, skytable\n"); 24 24 25 25 fprintf (stderr, "\n"); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvopsps/src/insert_detections_dvopsps.c
r37304 r37822 95 95 dvo_catalog_unlock (&catalog); 96 96 dvo_catalog_free (&catalog); 97 98 if (!status) { 99 fprintf (stderr, "failure to insert data in mysql\n"); 100 exit (2); 101 } 97 102 } 98 103 … … 281 286 } 282 287 283 # define PRINT_FLOAT(BUFFER,FIELD,FORMAT) \284 if (!isfinite(FIELD)) PrintIOBuffer (BUFFER, "NULL, "); \285 else PrintIOBuffer (BUFFER, FORMAT, FIELD);286 287 int insert_detections_mysql_detvalue (IOBuffer *buffer, Detections *detection) {288 289 PrintIOBuffer (buffer, "(%d, ", detection->imageID); // imageID290 PrintIOBuffer (buffer, "%u, ", detection->ippDetectID); // ippDetectID291 PrintIOBuffer (buffer, "%lu, ", detection->detectID); // detectID292 PrintIOBuffer (buffer, "%lu, ", detection->ippObjID); // ippObjID293 PrintIOBuffer (buffer, "%lu, ", detection->objID); // objID294 PrintIOBuffer (buffer, "%u, ", detection->flags); // flags295 PRINT_FLOAT(buffer, detection->zp, "%.6f, ");296 PRINT_FLOAT(buffer, detection->zpErr, "%.6f, ");297 PRINT_FLOAT(buffer, detection->airMass, "%.6f, ");298 PRINT_FLOAT(buffer, detection->expTime, "%.6f, ");299 PRINT_FLOAT(buffer, detection->ra, "%.8f, ");300 PRINT_FLOAT(buffer, detection->dec, "%.8f, ");301 PRINT_FLOAT(buffer, detection->raErr, "%.6f, ");302 PRINT_FLOAT(buffer, detection->decErr, "%.6f),\n");303 return TRUE;304 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c
r37048 r37822 6 6 Detections *detections = NULL; 7 7 8 static float ZeroPoint = 25.0; 9 8 10 int init_detections () { 9 11 NDETECTIONS = 1000; … … 15 17 16 18 off_t i, j; 19 20 ZeroPoint = GetZeroPoint(); 17 21 18 22 int missingID = 0; … … 47 51 if (measure->photcode >= PHOTCODE_END) continue; 48 52 49 PhotCode *code = GetPhotcodebyCode(measure->photcode); 50 51 detections[Ndetections].imageID = measure->imageID; // imageID 52 detections[Ndetections].ippDetectID = measure->detID; // ippDetectID 53 detections[Ndetections].detectID = measure->extID; // detectID 54 detections[Ndetections].ippObjID = ((uint64_t)average->catID * 1000000000) + (uint64_t)average->objID; // ippObjID 55 // NOTE: this is better, but the above is the current ippToPsps value 56 // detections[Ndetections]. ((uint64_t)average->catID << 32) + (uint64_t)average->objID; // ippObjID 57 detections[Ndetections].objID = average->extID; // objID 58 detections[Ndetections].photcode = measure->photcode; // photcode 59 detections[Ndetections].flags = measure->dbFlags; // flags 60 detections[Ndetections].zp = code->C * 0.001 + code->K * (measure->airmass - 1) - measure->Mcal; // zp 61 detections[Ndetections].zpErr = measure->dMcal; // zpErr 62 detections[Ndetections].airMass = measure->airmass; 63 detections[Ndetections].expTime = pow(10.0, 0.4 * measure->dt); // expTime 64 detections[Ndetections].ra = measure->R; // ra 65 detections[Ndetections].dec = measure->D; // dec 66 detections[Ndetections].raErr = measure->dXccd * 0.01 * fabs(measure->pltscale); // estimate of raErr 67 detections[Ndetections].decErr = measure->dYccd * 0.01 * fabs(measure->pltscale); // estimate of decErr 68 53 assign_detection_values (&detections[Ndetections], measure, average); 69 54 Ndetections ++; 55 70 56 myAssert (Ndetections <= NDETECTIONS, "programming error"); 71 57 } … … 109 95 110 96 off_t found = 0; 97 98 ZeroPoint = GetZeroPoint(); 111 99 112 100 INITTIME; … … 143 131 144 132 // XXX check return status 145 if (!insert_detections_mysql_value (&buffer, &average[i], &measure[Nmeas])) { 133 Detections detection; 134 assign_detection_values (&detection, &measure[Nmeas], &average[i]); 135 136 if (!insert_detections_mysql_detvalue (&buffer, &detection)) { 146 137 fprintf (stderr, "failure to insert detections in mysql\n"); 147 138 status = FALSE; … … 194 185 } 195 186 196 // PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (imageID, ippDetectID, detectID, ippObjID, objID, photcode, flags, zp, zpErr, airMass, expTime, ra, dec_, raErr, decErr) VALUES \n"); 197 PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (imageID, ippDetectID, detectID, ippObjID, objID, flags, zp, zpErr, airMass, expTime, ra, dec_, raErr, decErr) VALUES \n"); 198 199 return TRUE; 200 } 201 202 # define PRINT_FLOAT(BUFFER,FIELD,FORMAT) \ 203 if (isinf(FIELD) || isnan(FIELD)) PrintIOBuffer (BUFFER, "NULL, "); \ 204 else PrintIOBuffer (BUFFER, FORMAT, FIELD); 205 206 int insert_detections_mysql_value (IOBuffer *buffer, Average *average, Measure *measure) { 207 208 PhotCode *code = GetPhotcodebyCode(measure->photcode); 209 PrintIOBuffer (buffer, "(%d, ", measure->imageID); // imageID 210 PrintIOBuffer (buffer, "%u, ", measure->detID); // ippDetectID 211 PrintIOBuffer (buffer, "%lu, ", measure->extID); // detectID 212 PrintIOBuffer (buffer, "%lu, ", ((uint64_t)average->catID * 1000000000) + (uint64_t)average->objID); // ippObjID 213 // NOTE: the following is better, but the above is the current ippToPsps value 214 // ((uint64_t)average->catID << 32) + (uint64_t)average->objID, // ippObjID 215 PrintIOBuffer (buffer, "%lu, ", average->extID); // objID 216 // XXX PrintIOBuffer (buffer, "%d, ", measure->photcode); // photcode 217 PrintIOBuffer (buffer, "%u, ", measure->dbFlags); // flags 218 219 float zp = code->C * 0.001 + code->K * (measure->airmass - 1) - measure->Mcal; 220 float exptime = pow(10.0, 0.4 * measure->dt); 221 double ra = measure->R; 222 double dec = measure->D; 223 double dR = measure->dXccd * 0.01 * fabs(measure->pltscale); 224 double dD = measure->dYccd * 0.01 * fabs(measure->pltscale); 225 226 PRINT_FLOAT(buffer, zp, "%.6f, "); 227 PRINT_FLOAT(buffer, measure->dMcal, "%.6f, "); 228 PRINT_FLOAT(buffer, measure->airmass, "%.6f, "); 229 PRINT_FLOAT(buffer, exptime, "%.6f, "); 230 PRINT_FLOAT(buffer, ra, "%.8f, "); 231 PRINT_FLOAT(buffer, dec, "%.8f, "); 232 PRINT_FLOAT(buffer, dR, "%.6f, "); 233 PRINT_FLOAT(buffer, dD, "%.6f),\n"); 234 235 return TRUE; 236 } 237 187 PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (objID, detectID, ippObjID, ippDetectID, imageID, catID, "); 188 PrintIOBuffer (buffer, "ra, dec_, raErr, decErr, zp, telluricExt, airmass, expTime, "); 189 PrintIOBuffer (buffer, "Mpsf, dMpsf, Mkron, dMkron, Map, dMap, flags) VALUES \n"); 190 191 return TRUE; 192 } 193 238 194 int insert_detections_mysql_commit (IOBuffer *buffer, MYSQL *mysql) { 239 195 … … 254 210 // XXX check return status 255 211 if (mysql) { 256 if (DEBUG) fprintf (stderr, "%s\n", buffer->buffer);257 212 int mysqlStatus = mysql_query(mysql, buffer->buffer); 258 213 if (mysqlStatus) { … … 260 215 fprintf (stderr, "%s\n", mysql_error(mysql)); 261 216 fprintf (stderr, "Nbuffer: %d\n", buffer->Nbuffer); 217 if (DEBUG) fprintf (stderr, "%s\n", buffer->buffer); 262 218 status = FALSE; 263 219 } … … 270 226 return status; 271 227 } 228 229 # define PRINT_FLOAT(BUFFER,FIELD,FORMAT) \ 230 if (!isfinite(FIELD)) PrintIOBuffer (BUFFER, "NULL, "); \ 231 else PrintIOBuffer (BUFFER, FORMAT, FIELD); 232 233 int insert_detections_mysql_detvalue (IOBuffer *buffer, Detections *detection) { 234 235 if (detection->detectID == 164458937060000101) { 236 fprintf (stderr, "isfinite: %d\n", isfinite(detection->dMpsf)); 237 fprintf (stderr, "isnan: %d\n", isnan(detection->dMpsf)); 238 fprintf (stderr, "isinf: %d\n", isinf(detection->dMpsf)); 239 } 240 241 // XXX I needed OFF_T_FMT on my 32bit ubuntu laptop; ok on 64bit? 242 PrintIOBuffer (buffer, "("OFF_T_FMT", ", detection->objID); // objID 243 PrintIOBuffer (buffer, OFF_T_FMT", ", detection->detectID); // detectID 244 PrintIOBuffer (buffer, OFF_T_FMT", ", detection->ippObjID); // ippObjID 245 PrintIOBuffer (buffer, "%u, ", detection->ippDetectID); // ippDetectID 246 PrintIOBuffer (buffer, "%d, ", detection->imageID); // imageID 247 PrintIOBuffer (buffer, "%d, ", detection->catID); // DVO Catalog ID 248 249 PRINT_FLOAT(buffer, detection->ra, "%.8f, "); 250 PRINT_FLOAT(buffer, detection->dec, "%.8f, "); 251 PRINT_FLOAT(buffer, detection->raErr, "%.6f, "); 252 PRINT_FLOAT(buffer, detection->decErr, "%.6f, "); 253 PRINT_FLOAT(buffer, detection->zp, "%.6f, "); 254 PRINT_FLOAT(buffer, detection->telluricExt, "%.6f, "); 255 PRINT_FLOAT(buffer, detection->airmass, "%.6f, "); 256 PRINT_FLOAT(buffer, detection->expTime, "%.6f, "); 257 258 PRINT_FLOAT(buffer, detection->Mpsf, "%.6f, "); 259 PRINT_FLOAT(buffer, detection->dMpsf, "%.6f, "); 260 PRINT_FLOAT(buffer, detection->Mkron, "%.6f, "); 261 PRINT_FLOAT(buffer, detection->dMkron, "%.6f, "); 262 PRINT_FLOAT(buffer, detection->Map, "%.6f, "); 263 PRINT_FLOAT(buffer, detection->dMap, "%.6f, "); 264 265 PrintIOBuffer (buffer, "%u),\n", detection->flags); // flags 266 return TRUE; 267 } 268 269 float getMagFromValueOrFlux (float flux, float mag, float zp) { 270 271 // first, if mag is finite, use mag: 272 if (isfinite(mag)) { 273 return (zp + mag - ZeroPoint); 274 } 275 276 if (isfinite(flux) && (flux > 0.0)) { 277 // fprintf (stderr, "funny flux: %f with mag %f\n", flux, mag); 278 return (zp - 2.5*log10(flux)); 279 } 280 281 if (isfinite(flux) && (flux <= 0.0)) { 282 return (NAN); 283 } 284 return (NAN); 285 } 286 287 float getdMagFromValueOrFlux (float flux, float dflux, float dmag) { 288 289 // first, if mag is finite, use mag: 290 if (isfinite(dmag)) { 291 return (dmag); 292 } 293 294 if (isfinite(flux) && isfinite(dflux)) { 295 return (dflux / fabs(flux)); 296 } 297 return (NAN); 298 } 299 300 int assign_detection_values (Detections *detection, Measure *measure, Average *average) { 301 302 PhotCode *code = GetPhotcodebyCode(measure->photcode); 303 304 uint64_t ippObjID = ((uint64_t)average->catID << 32) + (uint64_t)average->objID; // ippObjID 305 306 float nominalZP = code->C * 0.001 + code->K * (measure->airmass - 1); 307 float zp = nominalZP - measure->Mcal; 308 float telluricExt = - measure->Mcal; 309 float expTime = pow(10.0, 0.4 * measure->dt); 310 float airmass = measure->airmass; 311 312 detection->objID = average->extID; // objID 313 detection->detectID = measure->extID; // detectID 314 detection->ippObjID = ippObjID; // ippObjID 315 detection->ippDetectID = measure->detID; // ippDetectID 316 detection->imageID = measure->imageID; // imageID 317 detection->catID = measure->catID; // catID 318 319 detection->ra = measure->R; // ra 320 detection->dec = measure->D; // dec 321 detection->raErr = measure->dXccd * 0.01 * fabs(measure->pltscale); // estimate of raErr 322 detection->decErr = measure->dYccd * 0.01 * fabs(measure->pltscale); // estimate of decErr 323 324 detection->zp = zp; 325 detection->telluricExt = telluricExt; 326 detection->airmass = airmass; 327 detection->expTime = expTime; 328 329 // XXX clean this up with dvo_photcode_ops calls: 330 // if (isfinite(measure->FluxPSF) && (measure->FluxPSF < 0.0)) 331 detection->Mpsf = getMagFromValueOrFlux (measure->FluxPSF, measure->M, zp); 332 detection->Mkron = getMagFromValueOrFlux (measure->FluxKron, measure->Mkron, zp); 333 detection->Map = getMagFromValueOrFlux (measure->FluxAp, measure->Map, zp); 334 335 detection->dMpsf = getdMagFromValueOrFlux (measure->FluxPSF, measure->dFluxPSF, measure->dM); 336 detection->dMkron = getdMagFromValueOrFlux (measure->FluxKron, measure->dFluxKron, measure->dMkron); 337 detection->dMap = getdMagFromValueOrFlux (measure->FluxAp, measure->dFluxAp, measure->dMap); 338 339 detection->flags = measure->dbFlags; // flags 340 341 return TRUE; 342 } 343 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvopsps/src/insert_objects_dvopsps_catalog.c
r37048 r37822 88 88 bzero (buffer.buffer, buffer.Nalloc); 89 89 90 // Only send the necessary fields (eg, do not sent parallax and pm) 90 91 PrintIOBuffer (&buffer, "CREATE TABLE %s_cpt (" 91 "RA DOUBLE, " 92 "DEC_ DOUBLE, " 93 "RA_ERR FLOAT, " 94 "DEC_ERR FLOAT, " 95 "U_RA FLOAT, " 96 "U_DEC FLOAT, " 97 "V_RA_ERR FLOAT, " 98 "V_DEC_ERR FLOAT, " 99 "PAR FLOAT, " 100 "PAR_ERR FLOAT, " 101 "CHISQ_POS FLOAT, " 102 "CHISQ_PM FLOAT, " 103 "CHISQ_PAP FLOAT, " 104 "MEAN_EPOCH INT, " 105 "TIME_RANGE INT, " 106 "PSF_QF FLOAT, " 107 "PSF_QF_PERF FLOAT, " 108 "STARGAL_SEP FLOAT, " 109 "NUMBER_POS SMALLINT, " 110 "NMEASURE SMALLINT, " 111 "NMISSING SMALLINT, " 112 "NEXTEND SMALLINT, " 113 "OFF_MEASURE INT, " 114 "OFF_MISSING INT, " 115 "OFF_EXTEND INT, " 116 "FLAGS INT, " 117 "PHOTFLAGS_U INT, " 118 "PHOTFLAGS_L INT, " 119 "OBJ_ID INT, " 120 "CAT_ID INT, " 121 "EXT_ID BIGINT" 92 "EXT_ID BIGINT, " 93 "OBJ_ID INT, " 94 "CAT_ID INT, " 95 "TESS_ID TINYINT, " 96 "PROJECTION_ID SMALLINT, " 97 "SKYCELL_ID TINYINT, " 98 "RA_STK DOUBLE, " 99 "DEC_STK DOUBLE, " 100 "RA_STK_ERR FLOAT, " 101 "DEC_STK_ERR FLOAT, " 102 "RA_MEAN DOUBLE, " 103 "DEC_MEAN DOUBLE, " 104 "RA_ERR FLOAT, " 105 "DEC_ERR FLOAT, " 106 "CHISQ_POS FLOAT, " 107 "CHISQ_PM FLOAT, " 108 "CHISQ_PAR FLOAT, " 109 "FLAGS INT " 122 110 ")\n", basename); 111 112 // skipping these cpt fields: 113 // "U_RA FLOAT, " 114 // "U_DEC FLOAT, " 115 // "V_RA_ERR FLOAT, " 116 // "V_DEC_ERR FLOAT, " 117 // "PAR FLOAT, " 118 // "PAR_ERR FLOAT, " 119 // "OFF_MEASURE INT, " 120 // "OFF_MISSING INT, " 121 // "OFF_EXTEND INT, " 122 // "PSF_QF FLOAT, " 123 // "PSF_QF_PERF FLOAT, " 124 // "STARGAL_SEP FLOAT, " 125 // "NUMBER_POS SMALLINT, " 126 // "NMEASURE SMALLINT, " 127 // "NMISSING SMALLINT, " 128 // "NEXTEND SMALLINT, " 129 // "PHOTFLAGS_U INT, " 130 // "PHOTFLAGS_L INT, " 131 132 123 133 124 134 if (DEBUG) fprintf (stderr, "%s\n", buffer.buffer); … … 145 155 146 156 PrintIOBuffer (&buffer, "CREATE TABLE %s_cps (" 147 "MAG FLOAT, "148 "MAG_ AP FLOAT, "149 "MAG_ KRON FLOAT, "150 "MAG_ KRON_ERR FLOAT, "151 "MAG_ ERRFLOAT, "152 " MAG_CHI FLOAT, "153 " STACK_PSF_MAGFLOAT, "154 " STACK_PSF_MAG_ERRFLOAT, "155 " STACK_KRON_MAG FLOAT, "156 " STACK_KRON_MAG_ERR FLOAT, "157 " FLAGS INT, "158 " NCODE SMALLINT, "159 " NUSED SMALLINT, "160 " MAG_20 SMALLINT, "161 " MAG_80 SMALLINT, "162 " UBERCAL_DIST SMALLINT, "163 " MAG_STDEV SMALLINT, "164 " STACK_DETECT_ID BIGINT"157 "MAG FLOAT, " 158 "MAG_ERR FLOAT, " 159 "MAG_STDEV FLOAT, " 160 "MAG_MIN FLOAT, " 161 "MAG_MAX FLOAT, " 162 "NUSED SMALLINT, " 163 "MAG_KRON FLOAT, " 164 "MAG_KRON_ERR FLOAT, " 165 "MAG_KRON_STDEV FLOAT, " 166 "NUSED_KRON SMALLINT, " 167 "MAG_AP FLOAT, " 168 "MAG_AP_ERR FLOAT, " 169 "MAG_AP_STDEV FLOAT, " 170 "NUSED_AP SMALLINT, " 171 "NCODE SMALLINT, " 172 "NSTACK_DET SMALLINT, " 173 "PSF_QF_PERF_MAX FLOAT, " 174 "FLAGS INT " 165 175 ")\n", basename); 166 167 // "FLUX_PSF FLOAT, "168 // "FLUX_PSF_ERR FLOAT, "169 // "FLUX_KRON FLOAT, "170 // "FLUX_KRON_ERR FLOAT, "171 176 172 177 if (DEBUG) fprintf (stderr, "%s\n", buffer.buffer); … … 191 196 192 197 PrintIOBuffer (ave_buffer, "INSERT INTO %s_cpt (" 193 "RA, " 194 "DEC_, " 195 "RA_ERR, " 196 "DEC_ERR, " 197 "U_RA, " 198 "U_DEC, " 199 "V_RA_ERR, " 200 "V_DEC_ERR, " 201 "PAR, " 202 "PAR_ERR, " 203 "CHISQ_POS, " 204 "CHISQ_PM, " 205 "CHISQ_PAP, " 206 "MEAN_EPOCH, " 207 "TIME_RANGE, " 208 "PSF_QF, " 209 "PSF_QF_PERF, " 210 "STARGAL_SEP, " 211 "NUMBER_POS, " 212 "NMEASURE, " 213 "NMISSING, " 214 "NEXTEND, " 215 "OFF_MEASURE, " 216 "OFF_MISSING, " 217 "OFF_EXTEND, " 218 "FLAGS, " 219 "PHOTFLAGS_U, " 220 "PHOTFLAGS_L, " 221 "OBJ_ID, " 222 "CAT_ID, " 223 "EXT_ID" 198 "EXT_ID, " 199 "OBJ_ID, " 200 "CAT_ID, " 201 "TESS_ID, " 202 "PROJECTION_ID, " 203 "SKYCELL_ID, " 204 "RA_STK, " 205 "DEC_STK, " 206 "RA_STK_ERR, " 207 "DEC_STK_ERR, " 208 "RA_MEAN, " 209 "DEC_MEAN, " 210 "RA_ERR, " 211 "DEC_ERR, " 212 "CHISQ_POS, " 213 "CHISQ_PM, " 214 "CHISQ_PAR, " 215 "FLAGS " 224 216 ") VALUES \n", basename); 225 217 … … 230 222 PrintIOBuffer (sec_buffer, "INSERT INTO %s_cps (" 231 223 "MAG, " 232 "MAG_AP, " 224 "MAG_ERR, " 225 "MAG_STDEV, " 226 "MAG_MIN, " 227 "MAG_MAX, " 228 "NUSED, " 229 233 230 "MAG_KRON, " 234 231 "MAG_KRON_ERR, " 235 "MAG_ERR, " 236 "MAG_CHI, " 237 "STACK_PSF_MAG, " 238 "STACK_PSF_MAG_ERR, " 239 "STACK_KRON_MAG, " 240 "STACK_KRON_MAG_ERR, " 241 "FLAGS, " 232 "MAG_KRON_STDEV, " 233 "NUSED_KRON, " 234 235 "MAG_AP, " 236 "MAG_AP_ERR, " 237 "MAG_AP_STDEV, " 238 "NUSED_AP, " 239 242 240 "NCODE, " 243 "NUSED, " 244 "MAG_20, " 245 "MAG_80, " 246 "UBERCAL_DIST, " 247 "MAG_STDEV, " 248 "STACK_DETECT_ID " 241 "NSTACK_DET, " 242 "PSF_QF_PERF_MAX, " 243 "FLAGS " 249 244 ") VALUES \n", basename); 250 245 return TRUE; … … 261 256 // XXX this bit could/should be autocoded... 262 257 PrintIOBuffer (ave_buffer, " ("); 258 PrintIOBuffer (ave_buffer, OFF_T_FMT", ", average->extID); 259 PrintIOBuffer (ave_buffer, "%u, ", average->objID); 260 PrintIOBuffer (ave_buffer, "%u, ", average->catID); 261 262 PrintIOBuffer (ave_buffer, "%hhd, ", average->tessID); 263 PrintIOBuffer (ave_buffer, "%hd, ", average->projectionID); 264 PrintIOBuffer (ave_buffer, "%hhd, ", average->skycellID); 265 266 PRINT_FLOAT(ave_buffer, average->Rstk, "%.8f, "); // 0.036 mas precision 267 PRINT_FLOAT(ave_buffer, average->Dstk, "%.8f, "); // 0.036 mas precision 268 PRINT_FLOAT(ave_buffer, average->dRstk, "%.5f, "); // 0.010 mas precision 269 PRINT_FLOAT(ave_buffer, average->dDstk, "%.5f, "); // 0.010 mas precision 270 263 271 PRINT_FLOAT(ave_buffer, average->R, "%.8f, "); // 0.036 mas precision 264 272 PRINT_FLOAT(ave_buffer, average->D, "%.8f, "); // 0.036 mas precision 265 273 PRINT_FLOAT(ave_buffer, average->dR, "%.5f, "); // 0.010 mas precision 266 274 PRINT_FLOAT(ave_buffer, average->dD, "%.5f, "); // 0.010 mas precision 267 PRINT_FLOAT(ave_buffer, average->uR, "%.5f, "); // 0.010 mas/yr precision 268 PRINT_FLOAT(ave_buffer, average->uD, "%.5f, "); 269 PRINT_FLOAT(ave_buffer, average->duR, "%.5f, "); 270 PRINT_FLOAT(ave_buffer, average->duD, "%.5f, "); 271 PRINT_FLOAT(ave_buffer, average->P, "%.5f, "); 272 PRINT_FLOAT(ave_buffer, average->dP, "%.5f, "); 275 273 276 PRINT_FLOAT(ave_buffer, average->ChiSqAve, "%.4f, "); 274 277 PRINT_FLOAT(ave_buffer, average->ChiSqPM, "%.4f, "); 275 278 PRINT_FLOAT(ave_buffer, average->ChiSqPar, "%.4f, "); 276 PrintIOBuffer (ave_buffer, "%d, ", average->Tmean); 277 PrintIOBuffer (ave_buffer, "%d, ", average->Trange); 278 PRINT_FLOAT(ave_buffer, average->psfQF, "%.3f, "); 279 PRINT_FLOAT(ave_buffer, average->psfQFperf, "%.3f, "); 280 PRINT_FLOAT(ave_buffer, average->stargal, "%.3f, "); 281 PrintIOBuffer (ave_buffer, "%hu, ", average->Npos); 282 PrintIOBuffer (ave_buffer, "%hu, ", average->Nmeasure); 283 PrintIOBuffer (ave_buffer, "%hu, ", average->Nmissing); 284 PrintIOBuffer (ave_buffer, "%hu, ", average->Nextend); 285 PrintIOBuffer (ave_buffer, "%d, ", average->measureOffset); 286 PrintIOBuffer (ave_buffer, "%d, ", average->missingOffset); 287 PrintIOBuffer (ave_buffer, "%d, ", 0); // was : average->extendOffset); 288 PrintIOBuffer (ave_buffer, "%u, ", average->flags); 289 PrintIOBuffer (ave_buffer, "%u, ", average->photFlagsUpper); 290 PrintIOBuffer (ave_buffer, "%u, ", average->photFlagsLower); 291 PrintIOBuffer (ave_buffer, "%u, ", average->objID); 292 PrintIOBuffer (ave_buffer, "%u, ", average->catID); 293 PrintIOBuffer (ave_buffer, "%lu", average->extID); 279 280 PrintIOBuffer (ave_buffer, "%u ", average->flags); 281 294 282 PrintIOBuffer (ave_buffer, "),\n"); 295 283 284 // XXX what rules for keeping or NAN-ing various mags? 296 285 for (i = 0; i < Nsecfilt; i++) { 297 286 float meanPSFMag = -999.0; 298 287 float meanPSFMagErr = -999.0; 288 float meanPSFMagStd = -999.0; 289 float meanPSFMagMin = -999.0; 290 float meanPSFMagMax = -999.0; 299 291 if (isfinite(secfilt->dM) && isfinite(secfilt->M)) { 300 meanPSFMag = secfilt->M;292 meanPSFMag = secfilt->M; 301 293 meanPSFMagErr = secfilt->dM; 294 meanPSFMagStd = secfilt->Mstdev; 295 meanPSFMagMin = secfilt->Mmin; 296 meanPSFMagMax = secfilt->Mmax; 302 297 } 303 298 304 299 float meanKronMag = -999.0; 305 300 float meanKronMagErr = -999.0; 301 float meanKronMagStd = -999.0; 306 302 if (isfinite(secfilt->dMkron) && isfinite(secfilt->Mkron) && (secfilt->dMkron < 0.333)) { 307 meanKronMag = secfilt->Mkron;303 meanKronMag = secfilt->Mkron; 308 304 meanKronMagErr = secfilt->dMkron; 305 meanKronMagStd = secfilt->sMkron; 309 306 } 310 307 311 308 float meanApMag = -999.0; 312 if (isfinite(secfilt->Map)) { 313 meanApMag = secfilt->Map; 314 } 315 316 float stackPSFMag = -999.0; 317 float stackPSFMagErr = -999.0; 318 if (isfinite(secfilt->dFpsfStk) && isfinite(secfilt->FpsfStk) && (secfilt->dFpsfStk > 0.0)) { 319 float SN = secfilt->FpsfStk / secfilt->dFpsfStk; 320 if (SN > 3.0) { 321 stackPSFMag = -2.5 * log10(secfilt->FpsfStk) + 8.9; 322 stackPSFMagErr = secfilt->dFpsfStk / secfilt->FpsfStk; 323 } 324 } 325 326 float stackKronMag = -999.0; 327 float stackKronMagErr = -999.0; 328 if (isfinite(secfilt->dFkronStk) && isfinite(secfilt->FkronStk) && (secfilt->dFkronStk > 0.0)) { 329 float SN = secfilt->FkronStk / secfilt->dFkronStk; 330 if (SN > 3.0) { 331 stackKronMag = -2.5 * log10(secfilt->FkronStk) + 8.9; 332 stackKronMagErr = secfilt->dFkronStk / secfilt->FkronStk; 333 } 309 float meanApMagErr = -999.0; 310 float meanApMagStd = -999.0; 311 if (isfinite(secfilt->dMap) && isfinite(secfilt->Map)) { 312 meanApMag = secfilt->Map; 313 meanApMagErr = secfilt->dMap; 314 meanApMagStd = secfilt->sMap; 334 315 } 335 316 336 317 PrintIOBuffer (sec_buffer, " ("); 337 318 PRINT_FLOAT(sec_buffer, meanPSFMag, "%.6f, "); // umag precision 338 PRINT_FLOAT(sec_buffer, meanApMag, "%.6f, "); // umag precision 319 PRINT_FLOAT(sec_buffer, meanPSFMagErr, "%.6f, "); // umag precision 320 PRINT_FLOAT(sec_buffer, meanPSFMagStd, "%.6f, "); // umag precision 321 PRINT_FLOAT(sec_buffer, meanPSFMagMin, "%.6f, "); // umag precision 322 PRINT_FLOAT(sec_buffer, meanPSFMagMax, "%.6f, "); // umag precision 323 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->Nused); 324 339 325 PRINT_FLOAT(sec_buffer, meanKronMag, "%.6f, "); // umag precision 340 326 PRINT_FLOAT(sec_buffer, meanKronMagErr, "%.6f, "); // umag precision 341 PRINT_FLOAT(sec_buffer, mean PSFMagErr,"%.6f, "); // umag precision342 P RINT_FLOAT(sec_buffer, secfilt->Mchisq, "%.6f, ");343 PRINT_FLOAT(sec_buffer, stackPSFMag, "%.6f, "); // umag precision 344 PRINT_FLOAT(sec_buffer, stackPSFMagErr,"%.6f, "); // umag precision345 PRINT_FLOAT(sec_buffer, stackKronMag,"%.6f, "); // umag precision346 PRINT_FLOAT(sec_buffer, stackKronMagErr, "%.6f, "); // 0.36umag precision347 PrintIOBuffer (sec_buffer, "% u, ", secfilt->flags);327 PRINT_FLOAT(sec_buffer, meanKronMagStd, "%.6f, "); // umag precision 328 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->NusedKron); 329 330 PRINT_FLOAT(sec_buffer, meanApMag, "%.6f, "); // umag precision 331 PRINT_FLOAT(sec_buffer, meanApMagErr, "%.6f, "); // umag precision 332 PRINT_FLOAT(sec_buffer, meanApMagStd, "%.6f, "); // umag precision 333 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->NusedAp); 348 334 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->Ncode); 349 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->Nused); 350 PrintIOBuffer (sec_buffer, "%.6f, ", secfilt->Mmin); 351 PrintIOBuffer (sec_buffer, "%.6f, ", secfilt->Mmax); 352 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->ubercalDist); 353 PrintIOBuffer (sec_buffer, "%.6f, ", secfilt->Mstdev); 354 PrintIOBuffer (sec_buffer, "%lu ", secfilt->stackDetectID); 335 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->NstackDet); 336 337 PRINT_FLOAT(sec_buffer, secfilt->psfQfPerfMax, "%.6f,"); 338 PrintIOBuffer (sec_buffer, "%u ", secfilt->flags); 355 339 PrintIOBuffer (sec_buffer, "),\n"); 356 340 secfilt ++; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvosplit/include/dvosplit.h
r33656 r37822 22 22 } AveLinks; 23 23 24 int FULL_TABLE; 24 25 int VERBOSE; 25 26 char *OUTDIR; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvosplit/src/args.c
r33656 r37822 57 57 } 58 58 59 // override input catalog format (PS1_V1, PS1_REF, etc) 60 FULL_TABLE = FALSE; 61 if ((N = get_argument (argc, argv, "-full-table"))) { 62 remove_argument (N, &argc, argv); 63 FULL_TABLE = TRUE; 64 } 65 59 66 /* extra error messages */ 60 67 VERBOSE = FALSE; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvosplit/src/split_averages.c
r37043 r37822 27 27 incatalog[0].catflags = LOAD_AVES | LOAD_SECF; 28 28 29 if ( incatalog[0].catmode == DVO_MODE_SPLIT) {29 if ((incatalog[0].catmode == DVO_MODE_SPLIT) && !FULL_TABLE) { 30 30 Nblocks = incatalog[0].Naves_disk / NROWS; 31 31 if (incatalog[0].Naves_disk % NROWS) Nblocks ++; … … 36 36 for (block = 0; block < Nblocks; block++) { 37 37 38 if ( incatalog[0].catmode == DVO_MODE_SPLIT) {38 if ((incatalog[0].catmode == DVO_MODE_SPLIT) && !FULL_TABLE) { 39 39 // read up to NROWS at a time 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].Naves_off); 42 43 } else { 43 44 dvo_catalog_load (incatalog, VERBOSE); 44 45 fprintf (stderr, "splitting %s (averages)\n", incatalog[0].filename); 45 46 } 46 47 assert (block*NROWS == incatalog[0].Naves_off);48 47 49 48 // distribute data to the output catalogs … … 54 53 inD = incatalog[0].average[ave].D; 55 54 55 if (incatalog[0].average[ave].Nmeasure == 0) { 56 fprintf (stderr, "WARNING: object with no measurements, skipping %d (%f, %f)\n", averef, inR, inD); 57 continue; 58 } 56 59 // which of the outcatalogs contains this coordinate? 57 60 … … 98 101 99 102 // write out the new values 100 for (cat = 0; cat < outlist[0].Nregions; cat++) { 101 outcatalogs[cat].catflags = LOAD_AVES | LOAD_SECF; 103 if (!FULL_TABLE) { 104 for (cat = 0; cat < outlist[0].Nregions; cat++) { 105 outcatalogs[cat].catflags = LOAD_AVES | LOAD_SECF; 102 106 103 dvo_catalog_save (&outcatalogs[cat], VERBOSE);104 // 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);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); 105 109 106 // advance the pointers and free the current data107 // XXX these should be done within save segment:108 outcatalogs[cat].Naves_disk += outcatalogs[cat].Naverage;109 outcatalogs[cat].Naves_off += outcatalogs[cat].Naverage;110 outcatalogs[cat].Nsecf_disk += outcatalogs[cat].Nsecfilt * outcatalogs[cat].Naverage;111 outcatalogs[cat].Nsecf_off += outcatalogs[cat].Nsecfilt * outcatalogs[cat].Naverage;112 outcatalogs[cat].Nsecfilt = Nsecfilt;110 // advance the pointers and free the current data 111 // XXX these should be done within save segment: 112 outcatalogs[cat].Naves_disk += outcatalogs[cat].Naverage; 113 outcatalogs[cat].Naves_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; 116 outcatalogs[cat].Nsecfilt = Nsecfilt; 113 117 114 outcatalogs[cat].Naverage = 0; 115 outcatalogs[cat].Nsecf_mem = 0; 118 outcatalogs[cat].Naverage = 0; 119 outcatalogs[cat].Nsecf_mem = 0; 120 } 116 121 } 117 122 } 118 123 119 for (cat = 0; cat < outlist[0].Nregions; cat++) { 120 dvo_catalog_free_data (&outcatalogs[cat]); 124 if (!FULL_TABLE) { 125 for (cat = 0; cat < outlist[0].Nregions; cat++) { 126 dvo_catalog_free_data (&outcatalogs[cat]); 127 } 121 128 } 122 129 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/dvosplit/src/split_measures.c
r37043 r37822 27 27 // } 28 28 29 if ( incatalog[0].catmode == DVO_MODE_SPLIT) {29 if ((incatalog[0].catmode == DVO_MODE_SPLIT) && !FULL_TABLE) { 30 30 Nblocks = incatalog[0].Nmeas_disk / NROWS; 31 31 if (incatalog[0].Nmeas_disk % NROWS) Nblocks ++; … … 37 37 38 38 // read up to NROWS at a time 39 if ( incatalog[0].catmode == DVO_MODE_SPLIT) {39 if ((incatalog[0].catmode == DVO_MODE_SPLIT) && !FULL_TABLE) { 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 43 } else { 43 44 dvo_catalog_load (incatalog, VERBOSE); 44 45 fprintf (stderr, "splitting %s (measures)\n", incatalog[0].filename); 45 46 } 46 47 assert (block*NROWS == incatalog[0].Nmeas_off);48 47 49 48 for (meas = 0; meas < incatalog[0].Nmeasure; meas++) { … … 52 51 Ncat = outcat[averef]; 53 52 53 int averef_out = outref[averef]; 54 if (averef_out >= outcatalogs[Ncat].Naverage) { 55 fprintf (stderr, "mismatch 1\n"); 56 abort(); 57 } 58 54 59 Nout = outcatalogs[Ncat].Nmeasure; 55 60 outcatalogs[Ncat].measure[Nout] = incatalog[0].measure[meas]; 56 61 outcatalogs[Ncat].measure[Nout].averef = outref[averef]; 62 57 63 outcatalogs[Ncat].Nmeasure++; 58 64 … … 64 70 dvo_catalog_free_data (incatalog); 65 71 72 if (!FULL_TABLE) { 73 for (cat = 0; cat < outlist[0].Nregions; cat++) { 74 outcatalogs[cat].catflags = LOAD_MEAS; 75 dvo_catalog_save (&outcatalogs[cat], VERBOSE); 76 77 outcatalogs[cat].Nmeas_disk += outcatalogs[cat].Nmeasure; 78 outcatalogs[cat].Nmeas_off += outcatalogs[cat].Nmeasure; 79 outcatalogs[cat].Nmeasure = 0; 80 } 81 } 82 } 83 84 if (FULL_TABLE) { 66 85 for (cat = 0; cat < outlist[0].Nregions; cat++) { 67 outcatalogs[cat].catflags = LOAD_ MEAS;86 outcatalogs[cat].catflags = LOAD_AVES | LOAD_SECF | LOAD_MEAS; 68 87 dvo_catalog_save (&outcatalogs[cat], VERBOSE); 69 70 outcatalogs[cat].Nmeas_disk += outcatalogs[cat].Nmeasure;71 outcatalogs[cat].Nmeas_off += outcatalogs[cat].Nmeasure;72 outcatalogs[cat].Nmeasure = 0;73 74 88 } 75 89 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/fixcat/src/gcatstats.c
r36481 r37822 46 46 /* project onto rectilinear grid with 1 arcsec pixels, sort by X */ 47 47 /* reference for coords is center of field */ 48 InitCoords (&catstats[0].coords, "DEC--TAN"); 48 49 catstats[0].coords.crval1 = RaCenter; 49 50 catstats[0].coords.crval2 = DecCenter; 50 catstats[0].coords.crpix1 = catstats[0].coords.crpix2 = 0.0;51 51 catstats[0].coords.cdelt1 = catstats[0].coords.cdelt2 = 1.0 / 3600.0; 52 catstats[0].coords.pc1_1 = catstats[0].coords.pc2_2 = 1.0;53 catstats[0].coords.pc1_2 = catstats[0].coords.pc2_1 = 0.0;54 strcpy (catstats[0].coords.ctype, "DEC--TAN");55 52 56 53 X1 = catstats[0].X; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/gastro/src/gfitpoly.c
r27435 r37822 261 261 det = 1.0 / (a1*b2 - a2*b1); 262 262 263 InitCoords (coords, "DEC--PLY"); 264 263 265 coords[0].pc1_1 = p11*a1 + p12*b1*(S2/S1); 264 266 coords[0].pc2_1 = p21*a1 + p22*b1*(S2/S1); … … 273 275 274 276 coords[0].Npolyterms = NORDER; 275 strcpy (coords[0].ctype, "DEC--PLY");276 277 277 278 /* generate higher order terms from vector */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/gastro/src/gstars.c
r36481 r37822 79 79 if (!strcasecmp (ROUGH_ASTROMETRY, "config")) { 80 80 /* default values for coords */ 81 strcpy (coords[0].ctype, "DEC--TAN");81 InitCoords (coords, "DEC--TAN"); 82 82 coords[0].pc1_1 = CCD_PC1_1; coords[0].pc1_2 = CCD_PC1_2; 83 83 coords[0].pc2_1 = CCD_PC2_1; coords[0].pc2_2 = CCD_PC2_2; 84 84 coords[0].cdelt1 = coords[0].cdelt2 = ASEC_PIX / 3600.0; 85 coords[0].Npolyterms = 0;86 85 coords[0].crpix1 = 0.5*(*NX); 87 86 coords[0].crpix2 = 0.5*(*NY); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/gastro2/src/gproject2.c
r12332 r37822 19 19 20 20 /* create Tangent Plane to Sky transformation from input coords */ 21 strcpy (TPtoSky.ctype, coords[0].ctype);21 InitCoords (&TPtoSky, coords[0].ctype); 22 22 TPtoSky.crval1 = coords[0].crval1; 23 23 TPtoSky.crval2 = coords[0].crval2; 24 24 25 TPtoSky.cdelt1 = TPtoSky.cdelt2 = 1;26 TPtoSky.crpix1 = TPtoSky.crpix2 = 0;27 TPtoSky.pc1_1 = TPtoSky.pc2_2 = 1;28 TPtoSky.pc1_2 = TPtoSky.pc2_1 = 0;29 TPtoSky.Npolyterms = 0;30 for (i = 0; i < 7; i++) {31 TPtoSky.polyterms[i][0] = 0;32 TPtoSky.polyterms[i][1] = 0;33 }34 35 25 /* create Focal Plane to Tangent Plane transformation from input coords */ 36 strcpy (FPtoTP.ctype, "FP---PLY"); 37 FPtoTP.crval1 = FPtoTP.crval2 = 0; 38 26 InitCoords (&FPtoTP, "FP---PLY"); 39 27 FPtoTP.cdelt1 = coords[0].cdelt1; 40 28 FPtoTP.cdelt2 = coords[0].cdelt2; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/gastro2/src/gstars2.c
r37054 r37822 28 28 29 29 /* default values for coords */ 30 strcpy (Target[0].coords.ctype, "DEC--TAN");30 InitCoords (&Target[0].coords, "DEC--TAN"); 31 31 Target[0].coords.pc1_1 = CCD_PC1_1; Target[0].coords.pc1_2 = CCD_PC1_2; 32 32 Target[0].coords.pc2_1 = CCD_PC2_1; Target[0].coords.pc2_2 = CCD_PC2_2; 33 33 Target[0].coords.cdelt1 = Target[0].coords.cdelt2 = ASEC_PIX / 3600.0; 34 Target[0].coords.Npolyterms = 0;35 34 Target[0].coords.crpix1 = 0.5*NX; 36 35 Target[0].coords.crpix2 = 0.5*NY; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/getstar
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/getstar/include/dvoImageOverlaps.h
r27435 r37822 37 37 int edge_check (double *x1, double *y1, double *x2, double *y2); 38 38 double opening_angle (double x1, double y1, double x2, double y2, double x3, double y3); 39 40 void initMosaicCoords (); 41 void saveMosaicCoords (Coords *input); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/getstar/src/MatchCoords.c
r31238 r37822 29 29 if (!WITH_PHU && !strcmp (&dbImages[i].coords.ctype[4], "-DIS")) continue; 30 30 if ( SOLO_PHU && strcmp (&dbImages[i].coords.ctype[4], "-DIS")) continue; 31 32 /* if any of these images are WRP images, need to find matching DIS */33 if (!FindMosaicForImage (dbImages, NdbImages, i)) continue;34 31 35 32 /* define image corners */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/getstar/src/MatchImages.c
r36481 r37822 23 23 /* we keep the original crpix1,2 and crref1,2 */ 24 24 /* for mosaic astrometry, the grid should be w.r.t. the tangent-plane, not chip coords */ 25 InitCoords (&tcoords, "DEC--TAN"); 25 26 if (!strcmp (&image[0].coords.ctype[4], "-WRP")) { 26 // if the input image is a mosaic, we need to register that mosaic for the calculations below 27 if (MOSAIC == NULL) { 28 fprintf (stderr, "no mosaic for WRP image (use -mosaic)\n"); 29 return NULL; 30 } 31 RegisterMosaic (MOSAIC); 32 33 tcoords = MOSAIC[0]; 27 myAssert (image[0].coords.mosaic, "should already have tested this"); 28 tcoords = image[0].coords.mosaic[0]; 34 29 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 35 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;36 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;37 tcoords.Npolyterms = 1;38 strcpy (tcoords.ctype, "DEC--TAN");39 30 /* register so image->sky conversions below have correct mosaic */ 40 31 } else { 41 32 tcoords = image[0].coords; 42 33 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 43 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;44 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;45 tcoords.Npolyterms = 1;46 strcpy (tcoords.ctype, "DEC--TAN");47 34 } 48 35 … … 77 64 if (!WITH_PHU && !strcmp (&dbImages[i].coords.ctype[4], "-DIS")) continue; 78 65 if ( SOLO_PHU && strcmp (&dbImages[i].coords.ctype[4], "-DIS")) continue; 79 80 /* if any of these images are WRP images, need to find matching DIS */81 if (!FindMosaicForImage (dbImages, NdbImages, i)) continue;82 66 83 67 /* define image corners */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/getstar/src/ReadImageFiles.c
r36874 r37822 42 42 43 43 mode = GetFileMode (header); 44 45 initMosaicCoords (); 44 46 45 47 /*** load data from a single PHU or a collection of PHU files ***/ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/getstar/src/ReadImageHeader.c
r21508 r37822 1 1 # include "dvoImageOverlaps.h" 2 3 // for DIS/WRP sets, we need to save the DIS set and supply it to the WRP entries 4 static Coords *mosaic = NULL; 5 6 void initMosaicCoords () { 7 mosaic = NULL; 8 } 9 10 void saveMosaicCoords (Coords *input) { 11 mosaic = input; 12 } 2 13 3 14 /* read an image header corresponding to a CMF / CMP data block */ … … 44 55 /* only load astrometry, NAXIS1,2, and time if this is a MOSAIC_PHU (ctype is ....-DIS) */ 45 56 if (!strcmp (&image[0].coords.ctype[4], "-DIS")) { 46 MOSAIC = &image[0].coords;57 saveMosaicCoords (&image[0].coords); 47 58 return (TRUE); 48 59 } … … 56 67 } 57 68 if (!strcmp (&image[0].coords.ctype[4], "-WRP")) { 58 if ( MOSAIC== NULL) {69 if (mosaic == NULL) { 59 70 fprintf (stderr, "no mosaic for WRP image (use -mosaic)\n"); 60 71 return (FALSE); 61 72 } 62 RegisterMosaic (MOSAIC);73 image[0].coords.mosaic = mosaic; 63 74 } else { 64 75 /* force image to lie in 0-360 range */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/getstar/src/WriteImages.c
r27435 r37822 5 5 6 6 int i, N; 7 int nWRP, newWRP,isWRP;7 int isWRP; 8 8 FILE *f; 9 9 … … 16 16 } 17 17 18 nWRP = -1;18 Image *mosaic = NULL; 19 19 isWRP = FALSE; 20 20 for (i = 0; i < Nmatches; i++) { 21 if (!strcmp (&images[0].coords.ctype[4], "-WRP")) { 22 if (!FindMosaicForImage (images, Nimages, i)) { 23 fprintf (stderr, "failed to find matching mosaic\n"); 24 exit (1); 25 } 21 N = matches[i]; 22 if (!strcmp (&images[N].coords.ctype[4], "-WRP")) { 26 23 if (isWRP) { 27 newWRP = GetRegisteredMosaic(); 28 if (newWRP != nWRP) { 24 if (mosaic != images[N].parent) { 29 25 fprintf (stderr, "only one mosaic allowed in an output file\n"); 30 26 exit (1); 31 27 } 32 28 } else { 33 nWRP = GetRegisteredMosaic(); 34 isWRP = TRUE; 29 mosaic = images[N].parent; 35 30 } 36 31 } … … 38 33 39 34 if (isWRP) { 40 WriteImageFITS (f, &images[nWRP]);35 WriteImageFITS (f, mosaic); 41 36 } else { 42 37 // write a blank -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/imregister/imphot/dumpfits.c
r30617 r37822 34 34 35 35 ftable.header = &theader; 36 gfits_table_set_Image (&ftable, subset, Nmatch);36 // gfits_table_set_Image (&ftable, subset, Nmatch); 37 37 38 38 gfits_fwrite_header (f, &header); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/imregister/imphot/modify.c
r27435 r37822 30 30 gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, match, Nmatch); 31 31 for (i = 0; i < Nmatch; i++) { 32 gfits_convert_Image ((Image *) db[0].vtable.buffer[i], sizeof (Image), 1); 32 fprintf (stderr, "need to work with real output format\n"); 33 exit (2); 34 // gfits_convert_Image ((Image *) db[0].vtable.buffer[i], sizeof (Image), 1); 33 35 } 34 36 gfits_db_update (db); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/kapa2/include/constants.h
r36084 r37822 10 10 | PointerMotionMask) 11 11 12 # define NCHANNELS 312 # define NCHANNELS 10 13 13 # define NPIXELS_DYNAMIC 128 14 14 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/kapa2/include/structures.h
r32695 r37822 217 217 KapaImageChannel *image; 218 218 KapaImageChannel channel[NCHANNELS]; 219 int currentChannel; 219 220 } KapaImageWidget; 220 221 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/kapa2/src/CreatePicture.c
r16270 r37822 40 40 41 41 case 24: 42 43 extra = 4 - (image[0].wide.dx * 3) % 4; 44 REALLOCATE (image[0].wide.data, char, image[0].wide.dy*(3*image[0].wide.dx+extra)); 45 46 extra = 4 - (image[0].zoom.dx * 3) % 4; 47 REALLOCATE (image[0].zoom.data, char, image[0].zoom.dy*(3*image[0].zoom.dx+extra)); 48 42 49 extra = 4 - (image[0].picture.dx * 3) % 4; 43 REALLOCATE (image[0].wide.data, char, image[0].wide.dy*(3*image[0].wide.dx+extra));44 REALLOCATE (image[0].zoom.data, char, image[0].zoom.dy*(3*image[0].zoom.dx+extra));45 50 REALLOCATE (image[0].picture.data, char, image[0].picture.dy*(3*image[0].picture.dx+extra)); 46 51 c = (unsigned char *) image[0].picture.data; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/kapa2/src/CursorOps.c
r25757 r37822 100 100 // Sx, Sy are the screen coordinates of the Ix,Iy pixel 101 101 Image_to_Picture (&Sx, &Sy, Ix, Iy, picture); 102 103 // Sx,Sy should be forced into the pixel 104 int Sxi = Sx + 0.5; 105 int Syi = Sy + 0.5; 102 106 103 107 // i_start, j_start are now limited to valid screen coordinates 104 *i_start = MIN (MAX (Sx , 0), picture[0].dx);105 *j_start = MIN (MAX (Sy , 0), picture[0].dy);108 *i_start = MIN (MAX (Sxi, 0), picture[0].dx); 109 *j_start = MIN (MAX (Syi, 0), picture[0].dy); 106 110 } 107 111 … … 127 131 Iy = MIN (MAX (Iy, 0), matrix[0].Naxis[1]); 128 132 129 // I_end, J_end are the last displayed image pixel130 // *I_end = Ix;131 // *J_end = Iy;132 133 133 // Sx, Sy are the screen coordinates of the Ix,Iy pixel 134 134 Image_to_Picture (&Sx, &Sy, Ix, Iy, picture); 135 135 136 // Sx,Sy should be forced into the pixel 137 int Sxi = Sx + 0.5; 138 int Syi = Sy + 0.5; 139 140 // double IxTest, IyTest; 141 // Picture_to_Image (&IxTest, &IyTest, Sx, Sy, picture); 142 // fprintf (stderr, "dx,dy: %d,%d : %f,%f : %f,%f : %f:%f\n", picture[0].dx, picture[0].dy, Ix, Iy, Sx, Sy, IxTest, IyTest); 143 136 144 // i_start, j_start are now limited to valid screen coordinates 137 *i_end = MIN (MAX (Sx, 0), picture[0].dx); 138 *j_end = MIN (MAX (Sy, 0), picture[0].dy); 145 // XXX: i_end, j_end *should* be the last valid screen pixel plus 1 146 *i_end = MIN (MAX (Sxi, 0), picture[0].dx); 147 *j_end = MIN (MAX (Syi, 0), picture[0].dy); 139 148 140 149 // round off error can leave us with a small number of extra pixels here. -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/kapa2/src/Graphs.c
r36487 r37822 57 57 graph[0].data.flipnorth = FALSE; // +North = +Y by default 58 58 59 graph[0].data.coords.pc1_1 = graph[0].data.coords.pc2_2 = 1.0; 60 graph[0].data.coords.pc1_2 = graph[0].data.coords.pc2_1 = 0.0; 61 graph[0].data.coords.crval1 = 0.0; 62 graph[0].data.coords.crval2 = 0.0; 63 graph[0].data.coords.crpix1 = 0.0; 64 graph[0].data.coords.crpix2 = 0.0; 65 graph[0].data.coords.cdelt1 = graph[0].data.coords.cdelt2 = 1.0; 66 strcpy (graph[0].data.coords.ctype, "DEC--LIN"); 59 InitCoords (&graph[0].data.coords, "DEC--LIN"); 67 60 strcpy (graph[0].data.axis, "2222"); 68 61 strcpy (graph[0].data.ticks, "2222"); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/kapa2/src/Image.c
r36487 r37822 11 11 channel->slope = 1; 12 12 13 channel->coords.pc1_1 = channel->coords.pc2_2 = 1.0; 14 channel->coords.pc1_2 = channel->coords.pc2_1 = 0.0; 15 channel->coords.crval1 = 0.0; 16 channel->coords.crval2 = 0.0; 17 channel->coords.crpix1 = 0.0; 18 channel->coords.crpix2 = 0.0; 19 channel->coords.cdelt1 = channel->coords.cdelt2 = 1.0; 20 strcpy (channel->coords.ctype, "DEC--LIN"); 21 channel->coords.Npolyterms = 0; 13 InitCoords (&channel->coords, "DEC--LIN"); 22 14 23 15 channel->matrix.datasize = 0; /* a flag to show there is no data in the matrix */ … … 42 34 InitImageChannel (&image[0].channel[i]); 43 35 } 44 image[0].image = &image[0].channel[0]; 36 37 image[0].currentChannel = 0; 38 image[0].image = &image[0].channel[image[0].currentChannel]; 45 39 46 40 image[0].nPixels = 0; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/kapa2/src/InterpretKeys.c
r25757 r37822 50 50 Z = -1; 51 51 52 if (graph) { 52 int haveGraph = graph && graph->haveGraph; 53 if (haveGraph) { 53 54 X = (event[0].x - graph[0].axis[0].fx)*(graph[0].axis[0].max - graph[0].axis[0].min)/graph[0].axis[0].dfx + graph[0].axis[0].min; 54 55 Y = (event[0].y - graph[0].axis[1].fy)*(graph[0].axis[1].max - graph[0].axis[1].min)/graph[0].axis[1].dfy + graph[0].axis[1].min; 55 56 XY_to_RD (&R, &D, X, Y, &graph[0].data.coords); 56 57 } 57 if (image && ! graph) {58 if (image && !haveGraph) { 58 59 if (event[0].x < image[0].picture.x) goto skip_cursor; 59 60 if (event[0].y < image[0].picture.y) goto skip_cursor; … … 89 90 switch (keysym) { 90 91 91 case XK_F1: 92 image[0].image = &image[0].channel[0]; 93 SetColorScale (graphic, image); 94 Remap (graphic, image); 95 Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0); 92 # define SET_CHANNEL_CASE(NCHAN) \ 93 case XK_F##NCHAN: \ 94 image[0].currentChannel = NCHAN-1; \ 95 image[0].image = &image[0].channel[NCHAN-1]; \ 96 SetColorScale (graphic, image); \ 97 Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0); \ 98 Screen_to_Image (&X, &Y, (double)(event[0].x + 0.5), (double)(event[0].y + 0.5), &image[0].picture); \ 99 UpdateStatusBox (graphic, image, X, Y, 0.0, 1); \ 96 100 break; 97 101 98 case XK_F2: 99 image[0].image = &image[0].channel[1]; 100 SetColorScale (graphic, image); 101 Remap (graphic, image); 102 Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0); 103 break; 102 // Remap (graphic, image); 104 103 105 case XK_F3: 106 image[0].image = &image[0].channel[2]; 107 SetColorScale (graphic, image); 108 Remap (graphic, image); 109 Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0); 110 break; 104 // the number of entries here must match the value of NCHANNELS in contants.h 105 SET_CHANNEL_CASE(1); 106 SET_CHANNEL_CASE(2); 107 SET_CHANNEL_CASE(3); 108 SET_CHANNEL_CASE(4); 109 SET_CHANNEL_CASE(5); 110 SET_CHANNEL_CASE(6); 111 SET_CHANNEL_CASE(7); 112 SET_CHANNEL_CASE(8); 113 SET_CHANNEL_CASE(9); 114 SET_CHANNEL_CASE(10); 111 115 112 116 case XK_KP_Home: -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/kapa2/src/LoadPicture.c
r28241 r37822 55 55 // choose expand for wide to guarantee we fit: 56 56 wx = MAX ((header.Naxis[0] / (float) image[0].wide.dx), (header.Naxis[1] / (float) image[0].wide.dy)); 57 if (wx > 1.0) { 58 image[0].wide.expand = -wx; 59 } else { 60 image[0].wide.expand = 1.0 / wx; 61 } 57 58 // -4.002 -> -5 59 // image[0].wide.expand = (wx > 1.0) ? ceil (-wx) : floor (1.0 / wx); 60 image[0].wide.expand = (wx > 1.0) ? floor (-wx) : ceil (1.0 / wx); 61 // fprintf (stderr, "%d : %f\n", image[0].wide.expand, wx); 62 image[0].wide.expand = (wx > 1.0) ? ceil (-wx) : floor (1.0 / wx); 63 62 64 image[0].wide.Xc = 0.5*header.Naxis[0]; 63 65 image[0].wide.Yc = 0.5*header.Naxis[1]; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/kapa2/src/Reconfig.c
r21153 r37822 15 15 16 16 // if the new size is the same as the old size, do nothing. 17 if ((graphic->dx == NX) && (graphic->dy == NY)) return (TRUE); 17 if ((graphic->dx == NX) && (graphic->dy == NY)) { 18 if (USE_XWINDOW) XClearWindow (graphic->display, graphic->window); 19 Refresh (); 20 return (TRUE); 21 } 18 22 19 23 // set the new window size -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/kapa2/src/Remap32.c
r34088 r37822 37 37 swap_client = 0; 38 38 # endif 39 40 39 swap_server = ImageByteOrder (graphic[0].display); 41 40 swap_bytes = !(swap_client ^ swap_server); … … 91 90 in_pix = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 92 91 92 unsigned short *in_base = image[0].pixmap; 93 OUT_TYPE *out_base = (OUT_TYPE *) picture[0].data; 94 95 int Ninmax = matrix[0].Naxis[0] * matrix[0].Naxis[1]; 96 int Noutmax = picture[0].dx * picture[0].dy; 97 93 98 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ 94 99 95 100 /**** fill in bottom area ****/ 96 101 for (j = 0; j < dx*j_start; j++, out_pix++) { 102 myAssert (out_pix - out_base < Noutmax, "too far out"); 97 103 *out_pix = back; 98 104 } … … 105 111 out_pix2 = out_pix + jj*dx; 106 112 for (i = 0; i < i_start; i++, out_pix2++) { 113 myAssert (out_pix2 - out_base < Noutmax, "too far out"); 107 114 *out_pix2 = back; 108 115 } … … 114 121 if (expand_out == 1) { 115 122 for (i = i_start; i < i_end; i++, in_pix2 += inDX*expand_in, out_pix++) { 123 myAssert (out_pix - out_base < Noutmax, "too far out"); 124 myAssert (in_pix2 - in_base < Ninmax, "too far in"); 116 125 *out_pix = pixel[*in_pix2]; 117 126 } 118 127 } else { 119 128 for (i = i_start; i < i_end; i+= expand_out, in_pix2 += inDX, out_pix+= expand_out) { 129 myAssert (in_pix2 - in_base < Ninmax, "too far in"); 120 130 pixvalue = pixel[*in_pix2]; 121 131 out_pix2 = out_pix; 122 132 for (jj = 0; (jj < expand_out) && (j + jj < dy); jj++, out_pix2+=(dx-expand_out)) { 123 133 for (ii = 0; ii < expand_out; ii++, out_pix2++) { 134 myAssert (out_pix2 - out_base < Noutmax, "too far out"); 124 135 *out_pix2 = pixvalue; 125 136 } … … 133 144 out_pix2 = out_pix + jj*dx; 134 145 for (i = i_end; i < dx; i++, out_pix2++) { 146 myAssert (out_pix2 - out_base < Noutmax, "too far out"); 135 147 *out_pix2 = back; 136 148 } … … 142 154 for (j = 0; j < dy - j_end; j++) { 143 155 for (i = 0; i < dx; i++, out_pix ++) { 156 myAssert (out_pix - out_base < Noutmax, "too far out"); 144 157 *out_pix = back; 145 158 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/kapa2/src/SetChannel.c
r31665 r37822 21 21 if (Nchannel >= NCHANNELS) return (TRUE); 22 22 23 image[0].image = &image[0].channel[Nchannel]; 23 image[0].currentChannel = Nchannel; 24 image[0].image = &image[0].channel[image[0].currentChannel]; 24 25 SetColorScale (graphic, image); 25 26 … … 61 62 62 63 Refresh (); 63 XFlush (graphic[0].display);64 if (USE_XWINDOW) XFlush (graphic[0].display); 64 65 65 66 return (TRUE); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/kapa2/src/UpdateStatusBox.c
r30606 r37822 20 20 21 21 bzero (line, 100); 22 snprintf (line, 100, "(%d x %d) @ %d ",23 image[0].picture.dx, image[0].picture.dy, image[0].picture.expand);22 snprintf (line, 100, "(%d x %d) @ %d ch: %d ", 23 image[0].picture.dx, image[0].picture.dy, image[0].picture.expand, image[0].currentChannel+1); 24 24 XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 25 25 image[0].text_x + PAD1, image[0].text_y + 4*textpad + 4*PAD1, line, 25); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/Makefile.Targets
r37034 r37822 1 1 AOBJS = \ 2 $(ASRC)/coords.$(ARCH).o \ 2 $(ASRC)/coords-disk.$(ARCH).o \ 3 $(ASRC)/AstromOffsetMap_Disk.$(ARCH).o \ 3 4 $(ASRC)/average.$(ARCH).o \ 4 5 $(ASRC)/average-loneos.$(ARCH).o \ … … 13 14 $(ASRC)/average-ps1-v4.$(ARCH).o \ 14 15 $(ASRC)/average-ps1-v5.$(ARCH).o \ 16 $(ASRC)/average-ps1-sim.$(ARCH).o \ 15 17 $(ASRC)/average-ps1-ref.$(ARCH).o \ 16 18 $(ASRC)/secfilt.$(ARCH).o \ … … 26 28 $(ASRC)/secfilt-ps1-v4.$(ARCH).o \ 27 29 $(ASRC)/secfilt-ps1-v5.$(ARCH).o \ 30 $(ASRC)/secfilt-ps1-sim.$(ARCH).o \ 28 31 $(ASRC)/secfilt-ps1-ref.$(ARCH).o \ 29 32 $(ASRC)/measure.$(ARCH).o \ … … 39 42 $(ASRC)/measure-ps1-v4.$(ARCH).o \ 40 43 $(ASRC)/measure-ps1-v5.$(ARCH).o \ 44 $(ASRC)/measure-ps1-sim.$(ARCH).o \ 41 45 $(ASRC)/measure-ps1-ref.$(ARCH).o \ 42 46 $(ASRC)/lensing.$(ARCH).o \ 43 47 $(ASRC)/lensing-ps1-v5.$(ARCH).o \ 48 $(ASRC)/lensing-ps1-v5-alt.$(ARCH).o \ 44 49 $(ASRC)/lensobj.$(ARCH).o \ 45 50 $(ASRC)/lensobj-ps1-v5.$(ARCH).o \ 51 $(ASRC)/starpar.$(ARCH).o \ 52 $(ASRC)/starpar-ps1-v5.$(ARCH).o \ 53 $(ASRC)/starpar-ps1-sim.$(ARCH).o \ 46 54 $(ASRC)/missing.$(ARCH).o \ 47 55 $(ASRC)/photcode.$(ARCH).o \ … … 56 64 $(ASRC)/photcode-ps1-v5.$(ARCH).o \ 57 65 $(ASRC)/photcode-ps1-ref.$(ARCH).o \ 58 $(ASRC)/image.$(ARCH).o \59 66 $(ASRC)/image-loneos.$(ARCH).o \ 60 67 $(ASRC)/image-elixir.$(ARCH).o \ … … 69 76 $(ASRC)/image-ps1-v4.$(ARCH).o \ 70 77 $(ASRC)/image-ps1-v5.$(ARCH).o \ 78 $(ASRC)/image-ps1-sim.$(ARCH).o \ 71 79 $(ASRC)/image-ps1-ref.$(ARCH).o \ 72 80 $(ASRC)/regimage.$(ARCH).o \ … … 98 106 99 107 AINCS = \ 100 $(AINC)/coords.h \ 108 $(AINC)/coords-disk.h \ 109 $(AINC)/AstromOffsetMap_Disk.h \ 101 110 $(AINC)/average.h \ 102 111 $(AINC)/average-loneos.h \ … … 111 120 $(AINC)/average-ps1-v4.h \ 112 121 $(AINC)/average-ps1-v5.h \ 122 $(AINC)/average-ps1-sim.h \ 113 123 $(AINC)/average-ps1-ref.h \ 114 124 $(AINC)/secfilt.h \ … … 124 134 $(AINC)/secfilt-ps1-v4.h \ 125 135 $(AINC)/secfilt-ps1-v5.h \ 136 $(AINC)/secfilt-ps1-sim.h \ 126 137 $(AINC)/secfilt-ps1-ref.h \ 127 138 $(AINC)/measure.h \ … … 137 148 $(AINC)/measure-ps1-v4.h \ 138 149 $(AINC)/measure-ps1-v5.h \ 150 $(AINC)/measure-ps1-sim.h \ 139 151 $(AINC)/measure-ps1-ref.h \ 140 152 $(AINC)/lensing.h \ 141 153 $(AINC)/lensing-ps1-v5.h \ 154 $(AINC)/lensing-ps1-v5-alt.h \ 142 155 $(AINC)/lensobj.h \ 143 156 $(AINC)/lensobj-ps1-v5.h \ 157 $(AINC)/starpar.h \ 158 $(AINC)/starpar-ps1-v5.h \ 159 $(AINC)/starpar-ps1-sim.h \ 144 160 $(AINC)/missing.h \ 145 161 $(AINC)/photcode.h \ … … 154 170 $(AINC)/photcode-ps1-v5.h \ 155 171 $(AINC)/photcode-ps1-ref.h \ 156 $(AINC)/image.h \157 172 $(AINC)/image-loneos.h \ 158 173 $(AINC)/image-elixir.h \ … … 167 182 $(AINC)/image-ps1-v4.h \ 168 183 $(AINC)/image-ps1-v5.h \ 184 $(AINC)/image-ps1-sim.h \ 169 185 $(AINC)/image-ps1-ref.h \ 170 186 $(AINC)/regimage.h \ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/average-ps1-v5.d
r37034 r37822 2 2 EXTNAME DVO_AVERAGE_PS1_V5 3 3 TYPE BINTABLE 4 SIZE 1 844 SIZE 192 5 5 DESCRIPTION DVO Average Object Table 6 6 … … 47 47 FIELD lensingOffset, OFF_LENSING, int, offset to first lensing obs 48 48 FIELD lensobjOffset, OFF_LENSOBJ, int, offset to mean lensing data 49 FIELD starparOffset, OFF_STARPAR, int, offset to stellar parameter data 49 50 FIELD extendOffset, OFF_EXTEND, int, offset to extended object entry 50 FIELD paramsOffset, OFF_PARAMS, int, offset to stellar parameter data51 51 52 52 FIELD refColorBlue, REF_COLOR_BLUE, float, color of astrometry ref stars 53 53 FIELD refColorRed, REF_COLOR_RED, float, color of astrometry ref stars 54 55 FIELD tessID, TESS_ID, char, ID of tessellation for primary skycell 56 FIELD skycellID, SKYCELL_ID, char, ID of skycell for primary skycell 57 FIELD projectionID, PROJECTION_ID, short, ID of projection for primary skycell 58 59 FIELD Nstarpar, DUMMY, short, number of stellar parameter entries 60 FIELD dummy, DUMMY, short, unassigned bytes 54 61 55 62 # 'flags' was called 'code' prior to 2009.02.07 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/average.d
r37034 r37822 2 2 EXTNAME DVO_AVERAGE 3 3 TYPE BINTABLE 4 SIZE 1 844 SIZE 192 5 5 DESCRIPTION DVO Average Object Table 6 6 … … 47 47 FIELD lensingOffset, OFF_LENSING, int, offset to first lensing obs 48 48 FIELD lensobjOffset, OFF_LENSOBJ, int, offset to mean lensing data 49 FIELD starparOffset, OFF_STARPAR, int, offset to stellar parameter data 49 50 FIELD extendOffset, OFF_EXTEND, int, offset to extended object entry 50 FIELD paramsOffset, OFF_PARAMS, int, offset to stellar parameter data51 51 52 52 FIELD refColorBlue, REF_COLOR_BLUE, float, color of astrometry ref stars 53 53 FIELD refColorRed, REF_COLOR_RED, float, color of astrometry ref stars 54 55 FIELD tessID, TESS_ID, char, ID of tessellation for primary skycell 56 FIELD skycellID, SKYCELL_ID, char, ID of skycell for primary skycell 57 FIELD projectionID, PROJECTION_ID, short, ID of projection for primary skycell 58 59 FIELD Nstarpar, DUMMY, short, number of stellar parameter entries 60 FIELD dummy, DUMMY, short, unassigned bytes 54 61 55 62 # 'flags' was called 'code' prior to 2009.02.07 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/cmf-ps1-v5-lensing.d
r37034 r37822 3 3 EXTNAME CMF_PS1_V5 4 4 TYPE BINTABLE 5 SIZE 3 125 SIZE 320 6 6 7 7 # elements of data structure / FITS table … … 81 81 FIELD E2_sh_psf, E2_SH_PSF, float, lensing shear 82 82 83 FIELD srcChipNum, SRC_CHIP_NUM, short, source chip in warp 84 FIELD srcChipX, SRC_CHIP_X, short, source chip x coordinate 85 FIELD srcChipY, SRC_CHIP_Y, short, source chip y coordinate 86 FIELD padding3, SRC_CHIP_PAD, short, source chip in warp 87 83 88 FIELD Mr1, MOMENTS_R1, float, first radial moment, pixels 84 89 FIELD Mrh, MOMENTS_RH, float, half radial moment, pixels^1/2 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/coords.d
r6454 r37822 17 17 FIELD pc2_2, PC2_2, float, rotation matrix 18 18 FIELD polyterms, POLYTERMS, float[7][2], higher order warping terms 19 FIELD ctype, CTYPE, char[15], coordinate type19 FIELD ctype, CTYPE, char[15], coordinate type 20 20 FIELD Npolyterms, NPOLYTERMS, char, order of polynomial 21 FIELD astrom_map_id, ASTROM_MAP_ID, unsigned int, reference to 2D astrometry map -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/image-elixir.d
r30604 r37822 6 6 # elements of the image structure 7 7 8 SUBSTRUCT coords, COORDS, Coords ,astrometric data8 SUBSTRUCT coords, COORDS, CoordsDisk, astrometric data 9 9 SUBFIELD crval1, CRVAL1, double, coordinate at reference pixel 10 10 SUBFIELD crval2, CRVAL2, double, coordinate at reference pixel -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/image-loneos.d
r30604 r37822 6 6 # elements of the image structure 7 7 8 SUBSTRUCT coords, COORDS, Coords ,astrometric data8 SUBSTRUCT coords, COORDS, CoordsDisk, astrometric data 9 9 SUBFIELD crval1, CRVAL1, double, coordinate at reference pixel 10 10 SUBFIELD crval2, CRVAL2, double, coordinate at reference pixel -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/image-panstarrs-dev-0.d
r30604 r37822 7 7 # elements of the image structure 8 8 9 SUBSTRUCT coords, COORDS, Coords ,astrometric data9 SUBSTRUCT coords, COORDS, CoordsDisk, astrometric data 10 10 SUBFIELD crval1, CRVAL1, double, coordinate at reference pixel 11 11 SUBFIELD crval2, CRVAL2, double, coordinate at reference pixel -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/image-panstarrs-dev-1.d
r30604 r37822 7 7 # elements of the image structure 8 8 9 SUBSTRUCT coords, COORDS, Coords ,astrometric data9 SUBSTRUCT coords, COORDS, CoordsDisk, astrometric data 10 10 SUBFIELD crval1, CRVAL1, double, coordinate at reference pixel 11 11 SUBFIELD crval2, CRVAL2, double, coordinate at reference pixel -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/image-ps1-dev-1.d
r30604 r37822 7 7 # elements of the image structure 8 8 9 SUBSTRUCT coords, COORDS, Coords ,astrometric data9 SUBSTRUCT coords, COORDS, CoordsDisk, astrometric data 10 10 SUBFIELD crval1, CRVAL1, double, coordinate at reference pixel 11 11 SUBFIELD crval2, CRVAL2, double, coordinate at reference pixel -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/image-ps1-dev-2.d
r30604 r37822 7 7 # elements of the image structure 8 8 9 SUBSTRUCT coords, COORDS, Coords ,astrometric data9 SUBSTRUCT coords, COORDS, CoordsDisk, astrometric data 10 10 SUBFIELD crval1, CRVAL1, double, coordinate at reference pixel 11 11 SUBFIELD crval2, CRVAL2, double, coordinate at reference pixel -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/image-ps1-dev-3.d
r30604 r37822 7 7 # elements of the image structure 8 8 9 SUBSTRUCT coords, COORDS, Coords ,astrometric data9 SUBSTRUCT coords, COORDS, CoordsDisk, astrometric data 10 10 SUBFIELD crval1, CRVAL1, double, coordinate at reference pixel 11 11 SUBFIELD crval2, CRVAL2, double, coordinate at reference pixel -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/image-ps1-ref.d
r30604 r37822 7 7 # elements of the image structure 8 8 9 SUBSTRUCT coords, COORDS, Coords ,astrometric data9 SUBSTRUCT coords, COORDS, CoordsDisk, astrometric data 10 10 SUBFIELD crval1, CRVAL1, double, coordinate at reference pixel 11 11 SUBFIELD crval2, CRVAL2, double, coordinate at reference pixel -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/image-ps1-v1.d
r30604 r37822 7 7 # elements of the image structure 8 8 9 SUBSTRUCT coords, COORDS, Coords ,astrometric data9 SUBSTRUCT coords, COORDS, CoordsDisk, astrometric data 10 10 SUBFIELD crval1, CRVAL1, double, coordinate at reference pixel 11 11 SUBFIELD crval2, CRVAL2, double, coordinate at reference pixel -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/image-ps1-v2.d
r36833 r37822 7 7 # elements of the image structure 8 8 9 SUBSTRUCT coords, COORDS, Coords ,astrometric data9 SUBSTRUCT coords, COORDS, CoordsDisk, astrometric data 10 10 SUBFIELD crval1, CRVAL1, double, coordinate at reference pixel 11 11 SUBFIELD crval2, CRVAL2, double, coordinate at reference pixel -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/image-ps1-v3.d
r36833 r37822 7 7 # elements of the image structure 8 8 9 SUBSTRUCT coords, COORDS, Coords ,astrometric data9 SUBSTRUCT coords, COORDS, CoordsDisk, astrometric data 10 10 SUBFIELD crval1, CRVAL1, double, coordinate at reference pixel 11 11 SUBFIELD crval2, CRVAL2, double, coordinate at reference pixel -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/image-ps1-v4.d
r36833 r37822 7 7 # elements of the image structure 8 8 9 SUBSTRUCT coords, COORDS, Coords ,astrometric data9 SUBSTRUCT coords, COORDS, CoordsDisk, astrometric data 10 10 SUBFIELD crval1, CRVAL1, double, coordinate at reference pixel 11 11 SUBFIELD crval2, CRVAL2, double, coordinate at reference pixel -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/image-ps1-v5.d
r37034 r37822 8 8 # careful of 8-byte boundaries 9 9 10 SUBSTRUCT coords, COORDS, Coords ,astrometric data10 SUBSTRUCT coords, COORDS, CoordsDisk, astrometric data 11 11 SUBFIELD crval1, CRVAL1, double, coordinate at reference pixel 12 12 SUBFIELD crval2, CRVAL2, double, coordinate at reference pixel -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/image.d
r37034 r37822 2 2 EXTNAME DVO_IMAGE 3 3 TYPE BINTABLE 4 SIZE 3 604 SIZE 384 5 5 DESCRIPTION DVO Image Table 6 6 … … 8 8 # careful of 8-byte boundaries 9 9 10 # Coords is an internal structure defined in def/common.h 10 11 SUBSTRUCT coords, COORDS, Coords, astrometric data 11 12 SUBFIELD crval1, CRVAL1, double, coordinate at reference pixel … … 22 23 SUBFIELD ctype, CTYPE, char[15], coordinate type 23 24 SUBFIELD Npolyterms, NPOLYTERMS, char, order of polynomial 24 # 120 bytes 25 SUBFIELD mosaic, MOSAIC, e_void, pointer to parent mosaic 26 SUBFIELD imageMap, IMAGE_MAP, e_void, pointer to image map 27 # 136 bytes 25 28 26 29 # change this to a double? … … 76 79 FIELD photom_map_id, PHOTOM_MAP_ID, unsigned int, reference to 2D zero point map 77 80 FIELD astrom_map_id, ASTROM_MAP_ID, unsigned int, reference to 2D astrometry map 81 82 FIELD *parent, PARENT, e_void, pointer to parent mosaic (not save to disk) 78 83 # nFitPhotom lands on the old location of Mxxxx, which was used to mean nFitPhotom in some cases 79 84 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/lensing-ps1-v5.d
r37329 r37822 30 30 31 31 FIELD F_ApR5, FLUX_AP_R5, float, Flux inside r = 5 32 FIELD dF_ApR5, FLUX_ERR_AP_R5, float, Flux inside r = 533 FIELD sF_ApR5, FLUX_STD_AP_R5, float, Flux inside r = 534 FIELD fF_ApR5, FLUX_FIL_AP_R5, float, Flux inside r = 532 FIELD dF_ApR5, FLUX_ERR_AP_R5, float, error on Flux inside r = 5 33 FIELD sF_ApR5, FLUX_STD_AP_R5, float, stdev of Flux inside r = 5 34 FIELD fF_ApR5, FLUX_FIL_AP_R5, float, fill factor for Flux inside r = 5 35 35 36 36 FIELD F_ApR6, FLUX_AP_R6, float, Flux inside r = 5 37 FIELD dF_ApR6, FLUX_ERR_AP_R6, float, Flux inside r = 538 FIELD sF_ApR6, FLUX_ AP_R6, float,Flux inside r = 539 FIELD fF_ApR6, FLUX_ AP_R6, float,Flux inside r = 537 FIELD dF_ApR6, FLUX_ERR_AP_R6, float, error on Flux inside r = 5 38 FIELD sF_ApR6, FLUX_STD_AP_R6, float, stdev of Flux inside r = 5 39 FIELD fF_ApR6, FLUX_FIL_AP_R6, float, fill factor for Flux inside r = 5 40 40 41 41 FIELD detID, DET_ID, unsigned int, detection ID -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/lensing.d
r37329 r37822 29 29 FIELD E2_sh_psf, E2_SH_PSF, float, lensing shear psf stars E2 30 30 31 FIELD F_ApR5,FLUX_AP_R5, float, Flux inside r = 532 FIELD dF_ApR5, FLUX_ERR_AP_R5, float, Flux inside r = 533 FIELD sF_ApR5, FLUX_STD_AP_R5, float, Flux inside r = 534 FIELD fF_ApR5, FLUX_FIL_AP_R5, float, Flux inside r = 531 FIELD F_ApR5, FLUX_AP_R5, float, Flux inside r = 5 32 FIELD dF_ApR5, FLUX_ERR_AP_R5, float, error on Flux inside r = 5 33 FIELD sF_ApR5, FLUX_STD_AP_R5, float, stdev of Flux inside r = 5 34 FIELD fF_ApR5, FLUX_FIL_AP_R5, float, fill factor for Flux inside r = 5 35 35 36 FIELD F_ApR6, FLUX_AP_R6, float, Flux inside r = 637 FIELD dF_ApR6, FLUX_ERR_AP_R6, float, Flux inside r = 638 FIELD sF_ApR6, FLUX_STD_ R6, float, Flux inside r = 639 FIELD fF_ApR6, FLUX_ AP_R6, float, Flux inside r = 636 FIELD F_ApR6, FLUX_AP_R6, float, Flux inside r = 5 37 FIELD dF_ApR6, FLUX_ERR_AP_R6, float, error on Flux inside r = 5 38 FIELD sF_ApR6, FLUX_STD_AP_R6, float, stdev of Flux inside r = 5 39 FIELD fF_ApR6, FLUX_FIL_AP_R6, float, fill factor for Flux inside r = 5 40 40 41 41 FIELD detID, DET_ID, int, detection ID -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/lensobj-ps1-v5.d
r37329 r37822 30 30 31 31 FIELD F_ApR5, FLUX_AP_R5, float, Flux inside r = 5 32 FIELD dF_ApR5, FLUX_ERR_AP_R5, float, Flux inside r = 533 FIELD sF_ApR5, FLUX_STD_AP_R5, float, Flux inside r = 534 FIELD fF_ApR5, FLUX_FIL_AP_R5, float, Flux inside r = 532 FIELD dF_ApR5, FLUX_ERR_AP_R5, float, error on Flux inside r = 5 33 FIELD sF_ApR5, FLUX_STD_AP_R5, float, stdev of Flux inside r = 5 34 FIELD fF_ApR5, FLUX_FIL_AP_R5, float, fill factor for Flux inside r = 5 35 35 36 36 FIELD F_ApR6, FLUX_AP_R6, float, Flux inside r = 5 37 FIELD dF_ApR6, FLUX_ERR_AP_R6, float, Flux inside r = 538 FIELD sF_ApR6, FLUX_ AP_R6, float,Flux inside r = 539 FIELD fF_ApR6, FLUX_ AP_R6, float,Flux inside r = 537 FIELD dF_ApR6, FLUX_ERR_AP_R6, float, error on Flux inside r = 5 38 FIELD sF_ApR6, FLUX_STD_AP_R6, float, stdev of Flux inside r = 5 39 FIELD fF_ApR6, FLUX_FIL_AP_R6, float, fill factor for Flux inside r = 5 40 40 41 41 FIELD gamma, GAMMA, float -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/lensobj.d
r37329 r37822 29 29 FIELD E2_sh_psf, E2_SH_PSF, float, mean lensing shear psf stars E2 30 30 31 FIELD F_ApR5,FLUX_AP_R5, float, Flux inside r = 532 FIELD dF_ApR5, FLUX_ERR_AP_R5, float,Flux inside r = 533 FIELD sF_ApR5, FLUX_STD_AP_R5, float,Flux inside r = 534 FIELD fF_ApR5, FLUX_FIL_AP_R5, float,Flux inside r = 531 FIELD F_ApR5, FLUX_AP_R5, float, Flux inside r = 5 32 FIELD dF_ApR5, FLUX_ERR_AP_R5, float, error on Flux inside r = 5 33 FIELD sF_ApR5, FLUX_STD_AP_R5, float, stdev of Flux inside r = 5 34 FIELD fF_ApR5, FLUX_FIL_AP_R5, float, fill factor for Flux inside r = 5 35 35 36 FIELD F_ApR6,FLUX_AP_R6, float, Flux inside r = 537 FIELD dF_ApR6, FLUX_ERR_AP_R6, float,Flux inside r = 538 FIELD sF_ApR6, FLUX_AP_R6, float,Flux inside r = 539 FIELD fF_ApR6, FLUX_AP_R6, float,Flux inside r = 536 FIELD F_ApR6, FLUX_AP_R6, float, Flux inside r = 5 37 FIELD dF_ApR6, FLUX_ERR_AP_R6, float, error on Flux inside r = 5 38 FIELD sF_ApR6, FLUX_STD_AP_R6, float, stdev of Flux inside r = 5 39 FIELD fF_ApR6, FLUX_FIL_AP_R6, float, fill factor for Flux inside r = 5 40 40 41 41 FIELD gamma, GAMMA, float -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/measure-ps1-v5.d
r37034 r37822 68 68 FIELD psfNdof, PSF_NDOF, int, psf degrees of freedom 69 69 FIELD psfNpix, PSF_NPIX, int, psf number of pixels 70 FIELD crNsigma, CR_NSIGMA, float, Nsigma deviation towards CR70 FIELD photFlags2, PHOT_FLAGS, int, flags supplied by photometry program 71 71 FIELD extNsigma, EXT_NSIGMA, float, Nsigma deviation towards EXT 72 72 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/measure.d
r37034 r37822 66 66 FIELD psfNdof, PSF_NDOF, int, psf degrees of freedom 67 67 FIELD psfNpix, PSF_NPIX, int, psf number of pixels 68 FIELD crNsigma, CR_NSIGMA, float, Nsigma deviation towards CR68 FIELD photFlags2, PHOT_FLAGS, int, flags supplied by photometry program 69 69 FIELD extNsigma, EXT_NSIGMA, float, Nsigma deviation towards EXT 70 70 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/secfilt-ps1-v4.d
r37034 r37822 23 23 FIELD ubercalDist, UBERCAL_DIST, short, number of images from an ubercal-image 24 24 FIELD Mstdev, MAG_STDEV, short, standard deviation of measurements, millimags 25 FIELD stackDetectID, STACK_DETECT_ID, uint64_t, detection ID on stack used for fluxes (if any) 25 FIELD stackPrmryOff, STACK_PRIMARY_OFF, int, measure entry which is primary stack detection 26 FIELD stackBestOff, STACK_BEST_OFF, int, measure entry which is best stack detection -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/secfilt-ps1-v5.d
r37034 r37822 2 2 EXTNAME DVO_SECFILT_PS1_V5 3 3 TYPE BINTABLE 4 SIZE 1 604 SIZE 176 5 5 DESCRIPTION DVO SecFilt : Secondary Filter Data 6 6 … … 15 15 FIELD sMkron, MAG_KRON_STDEV, float, standard deviation of kron mags, mags 16 16 17 # XXX I could add these fields to secfilt or calculate in dvopsps? 18 FIELD psfQfMax, PSF_QF_MAX, float, best psfQf for this filter 19 FIELD psfQfPerfMax, PSF_QF_PERF_MAX, float, best psfQfPerfect for this filter 20 17 21 # these statistics are PSF-specific 18 22 FIELD Mstdev, MAG_STDEV, float, standard deviation of measurements, mags … … 42 46 FIELD dFapStk, FLUX_AP_STK_ERR, float, mean flux ap error 43 47 44 ## need an 8-byte boundary here ## 45 FIELD stackDetectID, STACK_DETECT_ID, uint64_t, detection ID on stack used for fluxes (if any) 48 FIELD Nstack, NSTACK, short, number of measurements in band (gpc1 stack only) 49 FIELD NstackDet, NSTACK_DET, short, number of stack detections in band (gpc1 stack only) 50 51 FIELD stackPrmryOff, STACK_PRIMARY_OFF, int, measure entry which is primary stack detection 52 FIELD stackBestOff, STACK_BEST_OFF, int, measure entry which is best stack detection 46 53 47 54 ## *** this section is for forced-warp mean values *** … … 66 73 FIELD NusedApWrp, NUSED_AP_WRP, short, number of detections used in average 67 74 75 FIELD Nwarp, NWARP, short, number of measurements in band (gpc1 warp only) 76 FIELD NwarpGood, NWARP_GOOD, short, number of meas with psf_qf > 0.85 in band (gpc1 warp only) 77 68 78 FIELD ubercalDist, UBERCAL_DIST, short, number of images from an ubercal-image 69 79 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/def/secfilt.d
r37034 r37822 2 2 EXTNAME DVO_SECFILT 3 3 TYPE BINTABLE 4 SIZE 1 604 SIZE 176 5 5 DESCRIPTION DVO SecFilt : Secondary Filter Data 6 6 … … 15 15 FIELD sMkron, MAG_KRON_STDEV, float, standard deviation of kron mags, mags 16 16 17 # XXX I could add these fields to secfilt or calculate in dvopsps? 18 FIELD psfQfMax, PSF_QF_MAX, float, best psfQf for this filter 19 FIELD psfQfPerfMax, PSF_QF_PERF_MAX, float, best psfQfPerfect for this filter 20 17 21 # these statistics are PSF-specific 18 22 FIELD Mstdev, MAG_STDEV, float, standard deviation of measurements, mags … … 21 25 FIELD Mchisq, MAG_CHI, float, chisq on average mag, value 22 26 23 FIELD Ncode, NCODE, short, number of detections in band 24 FIELD Nused, NUSED, short, number of detections used in average25 FIELD NusedKron, NUSED_KRON, short, number of detections used in average26 FIELD NusedAp, NUSED_AP, short, number of detections used in average27 FIELD Ncode, NCODE, short, number of detections in band (gpc1 chip only) 28 FIELD Nused, NUSED, short, number of detections used to calculate secfilt.M 29 FIELD NusedKron, NUSED_KRON, short, number of detections used to calculate secfilt.Mkron 30 FIELD NusedAp, NUSED_AP, short, number of detections used to calculate secfilt.Map 27 31 28 32 FIELD flags, FLAGS, uint32_t, photometry flags … … 42 46 FIELD dFapStk, FLUX_AP_STK_ERR, float, mean flux ap error 43 47 44 ## need an 8-byte boundary here ## 45 FIELD stackDetectID, STACK_DETECT_ID, uint64_t, detection ID on stack used for fluxes (if any) 48 FIELD Nstack, NSTACK, short, number of measurements in band (gpc1 stack only) 49 FIELD NstackDet, NSTACK_DET, short, number of stack detections in band (gpc1 stack only) 50 51 FIELD stackPrmryOff, STACK_PRIMARY_OFF, int, measure entry which is primary stack detection 52 FIELD stackBestOff, STACK_BEST_OFF, int, measure entry which is best stack detection 46 53 47 54 ## *** this section is for forced-warp mean values *** … … 66 73 FIELD NusedApWrp, NUSED_AP_WRP, short, number of detections used in average 67 74 68 FIELD ubercalDist, UBERCAL_DIST, short, number of images from an ubercal-image 75 FIELD Nwarp, NWARP, short, number of measurements in band (gpc1 warp only) 76 FIELD NwarpGood, NWARP_GOOD, short, number of meas with psf_qf > 0.85 in band (gpc1 warp only) 77 78 FIELD ubercalDist, UBERCAL_DIST, short, number of images from an ubercal-image 69 79 70 80 # *** 20090206 : new fields : M_20, M_80; dropped dummy -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/doc/autocode.txt
r21508 r37822 35 35 36 36 - the element name 37 - the element FITS field (in FITS table) 37 38 - the element data type 38 39 - the element description 39 40 - the element physical unit 41 42 SUBFIELD / SUBSTRUCT keywords allows the user to define elements of a 43 structure which are themselves structures. These fields are used as 44 follow: 45 46 Binary / ASCII FITS tables write out the SUBFIELD entries as if they 47 were regular table rows (substructure distinction not visible in FITS 48 table). SUBSTRUCT rows are NOT added to the FITS table. 49 50 In a C-structure, the SUBFIELD rows are skipped and only the SUBSTRUCT 51 row is saved. The definition of the substructure is assumed to be 52 defined elsewhere in the C code. 40 53 41 54 Template File … … 43 56 The template file is a source code in whatever language is desired. 44 57 Within the template, the defined keywords may be used as desired, 45 wherever needed. In addition, there are special directives which 46 invoke additional special behavior. All special directives have the 47 form of comments within their target language. They are replaced with 48 a block of code in that target language, normally one which iterates 49 over the FIELD elements of the schema file. As such, the directive 50 appropriate for one language should not be used within code for a 51 different language. Here is a list of existing special directives: 58 wherever needed. 59 60 In addition, there are special directives which invoke additional 61 special behavior. All special directives have the form of comments 62 within their target language. They are replaced with a block of code 63 in that target language, normally one which iterates over the FIELD 64 elements of the schema file. As such, the directive appropriate for 65 one language should not be used within code for a different language. 66 Here is a list of existing special directives: 52 67 53 68 /** STRUCT DEFINITION **/ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libautocode/generate
r26384 r37822 144 144 if ($type eq "e_time") { $pt1 = "J"; } 145 145 if ($type eq "e_void") { $pt1 = "B"; $Np = 8*$Np; } 146 # if ($type eq "Image") { $pt1 = "B"; $Np = 8*$Np; } 146 147 # e_void is a 64 bit pointer, cast to size_t. its value is not loaded 147 148 # from the table. … … 248 249 if ($type eq "e_time") { $pt1 = sprintf "I%s", $length; } 249 250 if ($type eq "e_void") { $pt1 = sprintf "I%s", $length; } 251 # if ($type eq "Image") { $pt1 = sprintf "I%s", $length; } 250 252 251 253 if (!$pt1) { die "unknown type $type"; } … … 331 333 if ($type eq "e_time") { $T = "WORD"; $n = 4; } 332 334 if ($type eq "e_void") { $T = "DBLE"; $n = 8; } 335 # if ($type eq "Image") { $T = "DBLE"; $n = 8; } 333 336 334 337 if (!$n) { die "unknown type $type"; } … … 375 378 if ($type eq "e_time") { $Nbytes += 4*$Np; $valid = 1; } 376 379 if ($type eq "e_void") { $Nbytes += 8*$Np; $valid = 1; } 380 # if ($type eq "Image") { $Nbytes += 8*$Np; $valid = 1; } 377 381 if (!$valid) { die "unknown type $type"; } 378 382 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/Makefile
r37035 r37822 38 38 $(DESTINC)/ps1_v5_defs.h \ 39 39 $(DESTINC)/ps1_ref_defs.h \ 40 $(DESTINC)/ps1_sim_defs.h \ 40 41 $(DESTINC)/cmf-ps1-dv3.h \ 41 42 $(DESTINC)/cmf-ps1-v5.h \ 42 43 $(DESTINC)/cmf-ps1-sv3.h \ 43 $(DESTINC)/cmf-ps1-v5-lensing.h 44 $(DESTINC)/cmf-ps1-sv4.h \ 45 $(DESTINC)/cmf-ps1-v5-lensing.h \ 46 $(DESTINC)/cmf-ps1-v5-lensing-alt.h 44 47 45 48 INCS = $(DEFS) $(DESTINC)/dvo.h $(DESTINC)/autocode.h $(DESTINC)/dvo_util.h $(DESTINC)/dvodb.h $(DESTINC)/libdvo_astro.h $(DESTINC)/convert.h $(DESTINC)/get_graphdata.h … … 48 51 $(SRC)/version.$(ARCH).o \ 49 52 $(SRC)/coordops.$(ARCH).o \ 53 $(SRC)/galaxy_model.$(ARCH).o \ 50 54 $(SRC)/dvosorts.$(ARCH).o \ 51 55 $(SRC)/dvo_photcode_ops.$(ARCH).o \ … … 82 86 $(SRC)/dvo_convert_PS1_V5.$(ARCH).o \ 83 87 $(SRC)/dvo_convert_PS1_REF.$(ARCH).o \ 88 $(SRC)/dvo_convert_PS1_SIM.$(ARCH).o \ 84 89 $(SRC)/flatcorr_io.$(ARCH).o \ 85 90 $(SRC)/skyregion_io.$(ARCH).o \ 86 91 $(SRC)/skyregion_gsc.$(ARCH).o \ 87 92 $(SRC)/skyregion_ops.$(ARCH).o \ 93 $(SRC)/AstromOffsetMapIO.$(ARCH).o \ 94 $(SRC)/AstromOffsetMapOps.$(ARCH).o \ 95 $(SRC)/AstromOffsetMapUtils.$(ARCH).o \ 88 96 $(SRC)/dvo_set_skyregion.$(ARCH).o \ 89 97 $(SRC)/dvo_set_catdir.$(ARCH).o \ … … 92 100 $(SRC)/cmf-ps1-dv3.$(ARCH).o \ 93 101 $(SRC)/cmf-ps1-sv3.$(ARCH).o \ 102 $(SRC)/cmf-ps1-sv4.$(ARCH).o \ 94 103 $(SRC)/cmf-ps1-v5.$(ARCH).o \ 95 104 $(SRC)/cmf-ps1-v5-lensing.$(ARCH).o \ 105 $(SRC)/cmf-ps1-v5-lensing-alt.$(ARCH).o \ 96 106 $(SRC)/dvo_util.$(ARCH).o \ 97 107 $(SRC)/dbBooleanCond.$(ARCH).o \ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/include/cmf-ps1-v5-lensing.h
r37035 r37822 71 71 float E2_sh_psf; // lensing shear 72 72 73 short srcChipNum; 74 short srcChipX; 75 short srcChipY; 76 73 77 float Mr1; // first radial moment (pixels) 74 78 float Mrh; // half radial moment (pixels^1/2) -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/include/dvo.h
r37331 r37822 24 24 DVO_FORMAT_PS1_DEV_3, 25 25 DVO_FORMAT_PS1_REF, 26 DVO_FORMAT_PS1_SIM, 26 27 DVO_FORMAT_PS1_V1, 27 28 DVO_FORMAT_PS1_V2, … … 36 37 37 38 typedef enum {DVO_CAT_OPEN_FAIL, DVO_CAT_OPEN_OK, DVO_CAT_OPEN_EMPTY} DVOCatalogOpenModes; 38 39 typedef enum {40 PROJ_NONE, // undefined41 PROJ_ZEA, // zenithal42 PROJ_ZPL, // zenithal43 PROJ_ARC, // zenithal44 PROJ_STG, // zenithal45 PROJ_SIN, // zenithal46 PROJ_TAN, // zenithal47 PROJ_TNX, // zenithal48 PROJ_DIS, // zenithal (TAN + polyterms)49 PROJ_LIN, // cartesian50 PROJ_PLY, // cartesian51 PROJ_WRP, // cartesian52 PROJ_AIT, // pseudocyl53 PROJ_GLS, // pseudocyl54 PROJ_PAR, // pseudocyl55 } OhanaProjection;56 57 typedef enum {58 PROJ_MODE_NONE,59 PROJ_MODE_CARTESIAN,60 PROJ_MODE_ZENITHAL,61 PROJ_MODE_PSEUDOCYL,62 } OhanaProjectionMode;63 39 64 40 // these are used as NAN for types of int values … … 79 55 80 56 /* catalog values to be loaded */ 81 # define LOAD_NONE 0x000 82 # define LOAD_AVES 0x001 83 # define LOAD_MEAS 0x002 84 # define LOAD_MISS 0x004 85 # define LOAD_SECF 0x008 86 # define SKIP_AVES 0x010 87 # define SKIP_MEAS 0x020 88 # define SKIP_MISS 0x040 89 # define SKIP_SECF 0x080 90 # define LOAD_LENSING 0x100 91 # define LOAD_LENSOBJ 0x200 92 # define SKIP_LENSING 0x400 93 # define SKIP_LENSOBJ 0x800 57 # define LOAD_NONE 0x0000 58 # define LOAD_AVES 0x0001 59 # define LOAD_MEAS 0x0002 60 # define LOAD_MISS 0x0004 61 # define LOAD_SECF 0x0008 62 # define SKIP_AVES 0x0010 63 # define SKIP_MEAS 0x0020 64 # define SKIP_MISS 0x0040 65 # define SKIP_SECF 0x0080 66 # define LOAD_LENSING 0x0100 67 # define LOAD_LENSOBJ 0x0200 68 # define SKIP_LENSING 0x0400 69 # define SKIP_LENSOBJ 0x0800 70 # define LOAD_STARPAR 0x1000 71 # define SKIP_STARPAR 0x2000 94 72 95 73 /* photometry code types */ … … 114 92 ID_IMAGE_ASTROM_FEW = 0x00000100, /* currently too few measurements for astrometry */ 115 93 ID_IMAGE_PHOTOM_UBERCAL = 0x00000200, /* externally-supplied photometry zero point from ubercal analysis */ 94 ID_IMAGE_ASTROM_GMM = 0x00000400, /* image was fitted to positions corrected by the galaxy motion model */ 116 95 } DVOImageFlags; 117 96 … … 128 107 ID_MEAS_BLEND_MEAS = 0x00000100, // detection is within radius of multiple objects 129 108 ID_MEAS_BLEND_OBJ = 0x00000200, // multiple detections within radius of object 130 ID_MEAS_ UNDEF_3 = 0x00000400, // unused109 ID_MEAS_WARP_USED = 0x00000400, // measurement used to find mean warp photometry 131 110 ID_MEAS_UNDEF_4 = 0x00000800, // unused 132 111 ID_MEAS_BLEND_MEAS_X = 0x00001000, // detection is within radius of multiple objects across catalogs … … 136 115 ID_MEAS_STACK_PRIMARY = 0x00010000, // this stack measurement is in the primary skycell 137 116 ID_MEAS_STACK_PHOT_SRC = 0x00020000, // this measurement supplied the stack photometry 117 ID_MEAS_ICRF_QSO = 0x00040000, // this measurement is an ICRF reference position 118 ID_MEAS_IMAGE_EPOCH = 0x00080000, // this measurement is registered to the image epoch (not tied to ref catalog epoch) 138 119 } DVOMeasureFlags; 139 120 … … 152 133 */ 153 134 135 /** these names were previously used for Average flags in old (LONEOS-era) dvo versions 136 ID_BAD_OBJECT = 0x00004000, // if all measurements are bad, set this bit 137 ID_MOVING = 0x00008000, // is a moving object 138 ID_ROCK = 0x0000a000, // 0x8000 + 0x2000 139 ID_GHOST = 0x0000c001, // 0x8000 + 0x4000 + 0x0001 140 ID_TRAIL = 0x0000c002, // 0x8000 + 0x4000 + 0x0002 141 ID_BLEED = 0x0000c003, // 0x8000 + 0x4000 + 0x0003 142 ID_COSMIC = 0x0000c004, // 0x8000 + 0x4000 + 0x0004 143 **/ 144 154 145 /* Average.flags values -- these values are 32 bit (as of PS1_V1) */ 155 146 typedef enum { 156 ID_STAR_FEW = 0x00000001, // used within relphot: skip star 157 ID_STAR_POOR = 0x00000002, // used within relphot: skip star 158 ID_PROPER = 0x00000400, // star with large proper motion 159 ID_TRANSIENT = 0x00001000, // is this mutually exclusive with USNO? 160 ID_VARIABLE = 0x00002000, // not currently set? 161 ID_ASTEROID = 0x00002000, // identified with an asteroid 162 ID_BAD_OBJECT = 0x00004000, // if all measurements are bad, set this bit 163 ID_MOVING = 0x00008000, // is a moving object 164 ID_ROCK = 0x0000a000, // 0x8000 + 0x2000 165 ID_GHOST = 0x0000c001, // 0x8000 + 0x4000 + 0x0001 166 ID_TRAIL = 0x0000c002, // 0x8000 + 0x4000 + 0x0002 167 ID_BLEED = 0x0000c003, // 0x8000 + 0x4000 + 0x0003 168 ID_COSMIC = 0x0000c004, // 0x8000 + 0x4000 + 0x0004 169 ID_STAR_FIT_AVE = 0x00010000, // average position fitted 170 ID_STAR_FIT_PM = 0x00020000, // proper motion fitted 171 ID_STAR_FIT_PAR = 0x00040000, // parallax fitted 172 ID_STAR_USE_AVE = 0x00080000, // average position used (not PM or PAR) 173 ID_STAR_USE_PM = 0x00100000, // proper motion used (not AVE or PAR) 174 ID_STAR_USE_PAR = 0x00200000, // parallax used (not AVE or PM) 175 ID_STAR_NO_ASTROM = 0x00400000, // mean astrometry could not be measured 176 ID_STAR_BAD_PM = 0x00800000, // mean astrometry could not be measured 177 ID_OBJ_EXT = 0x01000000, // extended in our data (eg, PS) 178 ID_OBJ_EXT_ALT = 0x02000000, // extended in external data (eg, 2MASS) 179 ID_OBJ_GOOD = 0x04000000, // good-quality measurement in our data (eg,PS) 180 ID_OBJ_GOOD_ALT = 0x08000000, // good-quality measurement in external data (eg, 2MASS) 181 ID_OBJ_GOOD_STACK = 0x10000000, // good-quality object in the stack (> 1 good stack) 147 ID_STAR_FEW = 0x00000001, // used within relphot: skip star 148 ID_STAR_POOR = 0x00000002, // used within relphot: skip star 149 ID_ICRF_QSO = 0x00000004, // object IDed with known ICRF quasar (may have ICRF position measurement) 150 ID_OTHEF_QSO = 0x00000008, // object IDed with known or suspected quasar, without ICRF reference data 151 ID_PROPER = 0x00000010, // star with large proper motion 152 ID_TRANSIENT = 0x00000020, // identified as a non-periodic (stationary) transient 153 ID_VARIABLE = 0x00000040, // identified as a period variable 154 ID_ASTEROID = 0x00000080, // identified with a known solar-system object (asteroid or other) 155 // bits 0x00000100 - 0x00008000 are currently unused 156 ID_STAR_FIT_AVE = 0x00010000, // average position fitted 157 ID_STAR_FIT_PM = 0x00020000, // proper motion fitted 158 ID_STAR_FIT_PAR = 0x00040000, // parallax fitted 159 ID_STAR_USE_AVE = 0x00080000, // average position used (not PM or PAR) 160 ID_STAR_USE_PM = 0x00100000, // proper motion used (not AVE or PAR) 161 ID_STAR_USE_PAR = 0x00200000, // parallax used (not AVE or PM) 162 ID_STAR_NO_ASTROM = 0x00400000, // mean astrometry could not be measured 163 ID_STAR_BAD_PM = 0x00800000, // mean astrometry could not be measured 164 ID_OBJ_EXT = 0x01000000, // extended in our data (eg, PS) 165 ID_OBJ_EXT_ALT = 0x02000000, // extended in external data (eg, 2MASS) 166 ID_OBJ_GOOD = 0x04000000, // good-quality measurement in our data (eg,PS) 167 ID_OBJ_GOOD_ALT = 0x08000000, // good-quality measurement in external data (eg, 2MASS) 168 ID_OBJ_GOOD_STACK = 0x10000000, // good-quality object in the stack (> 1 good stack) 182 169 ID_OBJ_SUSPECT_STACK = 0x20000000, // suspect object in the stack (> 1 good or suspect stack, < 2 good) 183 ID_OBJ_BAD_STACK = 0x40000000, // good-quality object in the stack (> 1 good stack)170 ID_OBJ_BAD_STACK = 0x40000000, // good-quality object in the stack (> 1 good stack) 184 171 } DVOAverageFlags; 185 172 … … 202 189 } DVOSecfiltFlags; 203 190 191 /* definitions for parallel dvo host information 192 XXX : need better names (safer namespace) 193 */ 194 195 typedef enum { 196 DATA_ON_TGT = 0x01, 197 DATA_ON_BCK = 0x02, 198 DATA_USE_BCK = 0x04, 199 200 DATA_COPY_FAILURE = 0x80, 201 } SkyTableDataFlags; 202 203 typedef enum { 204 HOST_STDIN = 0, 205 HOST_STDOUT = 1, 206 HOST_STDERR = 2, 207 } HostInfoIOfd; 208 204 209 /*** general dvo structures (internal use only / not IO) ***/ 205 210 … … 253 258 } FlatCorrectionTable; 254 259 255 /* definitions for parallel dvo host information256 XXX : need better names (safer namespace)257 */258 259 typedef enum {260 DATA_ON_TGT = 0x01,261 DATA_ON_BCK = 0x02,262 DATA_USE_BCK = 0x04,263 264 DATA_COPY_FAILURE = 0x80,265 } SkyTableDataFlags;266 267 typedef enum {268 HOST_STDIN = 0,269 HOST_STDOUT = 1,270 HOST_STDERR = 2,271 } HostInfoIOfd;272 273 260 typedef struct { 274 261 char *hostname; // name of remote machine … … 289 276 } HostTable; 290 277 278 typedef struct { 279 int Nhosts; 280 HostInfo **hosts; 281 } HostTableGroup; 282 291 283 // A RegionHost processes data for some region in parallel with other regions 292 284 typedef struct RegionHostInfo { … … 315 307 off_t *imseq; 316 308 309 AstromOffsetTable *astromTable; 310 317 311 int *neighbors; // list of neighbor index values 318 312 int Nneighbors; // number of neighbors … … 338 332 # include "cmf-ps1-dv3.h" 339 333 # include "cmf-ps1-sv3.h" 334 # include "cmf-ps1-sv4.h" 340 335 # include "cmf-ps1-v5.h" 341 336 # include "cmf-ps1-v5-lensing.h" 337 # include "cmf-ps1-v5-lensing-alt.h" 342 338 343 339 typedef struct { … … 383 379 char ***name; // projection cell name 384 380 385 int NX_SUB;386 int NY_SUB;381 float NX_SUB; 382 float NY_SUB; 387 383 double dPix; 388 384 389 385 double **Xo; 390 386 double **Yo; 391 int **dX;392 int **dY;387 float **dX; 388 float **dY; 393 389 } BoundaryTree; 394 390 … … 411 407 double Do; 412 408 double dPix; 413 int dX;414 int dY;415 416 int NX_SUB;417 int NY_SUB;409 float dX; 410 float dY; 411 412 float NX_SUB; 413 float NY_SUB; 418 414 419 415 char *basename; … … 442 438 double R; 443 439 double D; 440 float RoffGAL; 441 float DoffGAL; 444 442 float M; 445 443 float Mcal; … … 464 462 } MeasureTiny; 465 463 466 / ** STRUCT DEFINITION **/464 // alternate version of PS1_V4 (old dev version) 467 465 typedef struct { 468 466 double R; // RA (decimal degrees ) … … 500 498 Average *Average_PS1_V4alt_ToInternal (Average_PS1_V4alt *in, off_t Nvalues); 501 499 502 / ** STRUCT DEFINITION **/500 // alternate version of PS1_V4 (old dev version) 503 501 typedef struct { 504 502 float dR; // RA offset (arcsec) … … 556 554 Measure *Measure_PS1_V4alt_ToInternal (Average *ave, Measure_PS1_V4alt *in, off_t Nvalues); 557 555 556 // alternate version of PS1_V5 (old dev version) 557 typedef struct { 558 float M; // average mag in this band (mags) 559 float dM; // formal error on average mag (mags) 560 float Map; // ave aperture mag in this band (mags) 561 float dMap; // ave aperture mag in this band (mags) 562 float sMap; // standard deviation of ap mags (mags) 563 float Mkron; // ave kron mag in this band (mags) 564 float dMkron; // formal error on average kron mag (mags) 565 float sMkron; // standard deviation of kron mags (mags) 566 float Mstdev; // standard deviation of measurements (mags) 567 float Mmin; // min accepted mag (mags) 568 float Mmax; // max accepted mag (mags) 569 float Mchisq; // chisq on average mag (value) 570 short Ncode; // number of detections in band 571 short Nused; // number of detections used in average 572 short NusedKron; // number of detections used in average 573 short NusedAp; // number of detections used in average 574 uint32_t flags; // photometry flags 575 float MpsfStk; // magnitude from stack (primary if available) 576 float FpsfStk; // flux from stack (primary if available) 577 float dFpsfStk; // mean flux psf error 578 float MkronStk; // magnitude from stack (primary if available) 579 float FkronStk; // flux from stack (primary if available) 580 float dFkronStk; // mean flux kron error 581 float MapStk; // magnitude from stack (primary if available) 582 float FapStk; // flux from stack (primary if available) 583 float dFapStk; // mean flux ap error 584 int stackPrmryOff; // measure entry which is primary stack detection 585 int stackBestOff; // measure entry which is best stack detection 586 float MpsfWrp; // psf magnitude from stack (primary if available) 587 float FpsfWrp; // psf flux from stack (primary if available) 588 float dFpsfWrp; // mean flux psf error 589 float sFpsfWrp; // mean flux psf stdev 590 float MkronWrp; // kron magnitude from stack (primary if available) 591 float FkronWrp; // kron flux from stack (primary if available) 592 float dFkronWrp; // mean flux kron error 593 float sFkronWrp; // mean flux kron stdev 594 float MapWrp; // aper magnitude from stack (primary if available) 595 float FapWrp; // aper flux from stack (primary if available) 596 float dFapWrp; // mean flux ap error 597 float sFapWrp; // mean flux ap stdev 598 short NusedWrp; // number of detections used in average 599 short NusedKronWrp; // number of detections used in average 600 short NusedApWrp; // number of detections used in average 601 short ubercalDist; // number of images from an ubercal-image 602 } SecFilt_PS1_V5alt; 603 604 SecFilt_PS1_V5alt *gfits_table_get_SecFilt_PS1_V5alt (FTable *table, off_t *Ndata, char *swapped); 605 int gfits_convert_SecFilt_PS1_V5alt (SecFilt_PS1_V5alt *data, off_t size, off_t nitems); 606 SecFilt *SecFilt_PS1_V5alt_ToInternal (SecFilt_PS1_V5alt *in, off_t Nvalues); 607 608 // alternate version of PS1_V5alt (old dev version) 609 typedef struct { 610 double R; // RA (decimal degrees ) 611 double D; // DEC (decimal degrees ) 612 float dR; // RA error (arcsec) 613 float dD; // DEC error (arcsec) 614 float uR; // RA*cos(D) proper-motion (arcsec/year) 615 float uD; // DEC proper-motion (arcsec/year) 616 float duR; // RA*cos(D) p-m error (arcsec/year) 617 float duD; // DEC p-m error (arcsec/year) 618 float P; // parallax (arcsec) 619 float dP; // parallax error (arcsec) 620 double Rstk; // RA on stack (decimal degrees ) 621 double Dstk; // DEC on stack (decimal degrees ) 622 float dRstk; // RA error on stack (arcsec) 623 float dDstk; // DEC error on stack (arcsec) 624 float ChiSqAve; // astrometry analysis chisq 625 float ChiSqPM; // astrometry analysis chisq 626 float ChiSqPar; // astrometry analysis chisq 627 int Tmean; // mean epoch (PM,PAR ref) (unix time seconds) 628 int Trange; // mean epoch (PM,PAR ref) (unix time seconds) 629 float psfQF; // psf coverage (bad masks) 630 float psfQFperf; // psf coverage (all masks) 631 float stargal; // star / galaxy separator (1/100 arcsec) 632 unsigned short Npos; // number of detections used for astrometry 633 unsigned short Nmeasure; // number of psf measurements 634 unsigned short Nmissing; // number of missings 635 unsigned short Nlensing; // number of lensing measurements 636 unsigned short Nlensobj; // number of lensing measurements 637 unsigned short Nextend; // number of extended measurements 638 int measureOffset; // offset to first psf measurement 639 int missingOffset; // offset to first missing obs 640 int lensingOffset; // offset to first lensing obs 641 int lensobjOffset; // offset to mean lensing data 642 int extendOffset; // offset to extended object entry 643 int starparOffset; // offset to stellar parameter data 644 float refColorBlue; // color of astrometry ref stars 645 float refColorRed; // color of astrometry ref stars 646 uint32_t flags; // average object flags (star; ghost; etc) 647 uint32_t photFlagsUpper; // upper bit of 2 bit summary of per-measure photflags 648 uint32_t photFlagsLower; // lower bit of 2 bit summary of per-measure photflags 649 unsigned int objID; // unique ID for object in table 650 unsigned int catID; // unique ID for table in which object was first realized 651 uint64_t extID; // external ID for object (eg PSPS objID) 652 uint64_t extIDgc; // external ID for object in galactic coords 653 } Average_PS1_V5alt; 654 655 Average_PS1_V5alt *gfits_table_get_Average_PS1_V5alt (FTable *table, off_t *Ndata, char *swapped); 656 int gfits_convert_Average_PS1_V5alt (Average_PS1_V5alt *data, off_t size, off_t nitems); 657 Average *Average_PS1_V5alt_ToInternal (Average_PS1_V5alt *in, off_t Nvalues); 658 558 659 /* for some reason I have merged the set of tables and the file description, 559 660 so I need to have an internal structure to point to the separate files */ … … 574 675 Lensing *lensing; 575 676 Lensobj *lensobj; 677 StarPar *starpar; 576 678 577 679 int Nsecfilt; /* number of secfilt entries for each average entry */ 578 off_t Naverage, Nmeasure, Nmissing, Nlensing, Nlensobj, Ns ecf_mem; /* current number of each component in memory */579 off_t Naves_disk, Nmeas_disk, Nmiss_disk, Nlensing_disk, Nlensobj_disk, Ns ecf_disk; /* current number of each component on disk */580 off_t Naves_off, Nmeas_off, Nmiss_off, Nlensing_off, Nlensobj_off, Ns ecf_off; /* index of first loaded data value */680 off_t Naverage, Nmeasure, Nmissing, Nlensing, Nlensobj, Nstarpar, Nsecf_mem; /* current number of each component in memory */ 681 off_t Naves_disk, Nmeas_disk, Nmiss_disk, Nlensing_disk, Nlensobj_disk, Nstarpar_disk, Nsecf_disk; /* current number of each component on disk */ 682 off_t Naves_off, Nmeas_off, Nmiss_off, Nlensing_off, Nlensobj_off, Nstarpar_off, Nsecf_off; /* index of first loaded data value */ 581 683 582 684 // note that we use these for the full-sky relphot analysis … … 599 701 struct Catalog *lensing_catalog; /* lensing catalog data (split) */ 600 702 struct Catalog *lensobj_catalog; /* lensobj catalog data (split) */ 703 struct Catalog *starpar_catalog; /* starpar catalog data (split) */ 601 704 602 705 unsigned int objID; … … 635 738 int gfits_db_free PROTO((FITS_DB *db)); 636 739 637 /* in coords.c, using libautocode/def/coords.d */638 int XY_to_LM (double *L, double *M, double x, double y, Coords *coords);639 int LM_to_XY (double *x, double *y, double L, double M, Coords *coords);640 int RD_to_LM (double *L, double *M, double ra, double dec, Coords *coords);641 int LM_to_RD (double *ra, double *dec, double L, double M, Coords *coords);642 int XY_to_RD (double *ra, double *dec, double x, double y, Coords *coords);643 int RD_to_XY (double *x, double *y, double ra, double dec, Coords *coords);644 int fXY_to_RD (float *ra, float *dec, double x, double y, Coords *coords);645 int fRD_to_XY (float *x, float *y, double ra, double dec, Coords *coords);646 int GetCoords (Coords *coords, Header *header);647 int PutCoords (Coords *coords, Header *header);648 void RegisterMosaic (Coords *coords);649 void coords_precess (double *ra, double *dec, double in_epoch, double out_epoch);650 OhanaProjection GetProjection (char *ctype);651 int SetProjection (char *ctype, OhanaProjection proj);652 OhanaProjectionMode GetProjectionMode (OhanaProjection proj);653 654 740 char *libdvo_version (void); 655 741 … … 710 796 float PhotFluxInstErr (Measure *measure, dvoMagClassType class); 711 797 float PhotFluxCatErr (Measure *measure, dvoMagClassType class); 798 float PhotFluxAveErr (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 712 799 713 800 float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt); 714 801 float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt); 715 802 716 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt); 803 int PhotNphot (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 804 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 717 805 float PhotMmin (PhotCode *code, Average *average, SecFilt *secfilt); 718 806 float PhotMmax (PhotCode *code, Average *average, SecFilt *secfilt); … … 806 894 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, char *format); 807 895 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, char *format); 896 StarPar *FtableToStarPar (FTable *ftable, off_t *Nstarpar, char *format); 808 897 int FtableToImage (FTable *ftable, Header *theader, char *format); 809 898 … … 813 902 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, char format); 814 903 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, char format); 904 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, char format); 815 905 int ImageToFtable (FTable *ftable, Header *theader, char format); 816 906 int ImageToVtable (VTable *vtable, Header *theader, char format); … … 829 919 # include "ps1_v5_defs.h" 830 920 # include "ps1_ref_defs.h" 921 # include "ps1_sim_defs.h" 831 922 832 923 /*** DVO image db I/O Functions ***/ … … 843 934 void dvo_image_create (FITS_DB *db, double ZeroPoint); 844 935 936 int gfits_table_set_Image (FTable *ftable); 937 int gfits_table_mkheader_Image (Header *header); 938 Image *gfits_table_get_Image (FTable *ftable, off_t *Ndata, char *swapped); 939 845 940 /* flatcorr APIs */ 846 941 FlatCorrectionTable *FlatCorrectionLoad (char *filename, int VERBOSE); … … 856 951 SkyTable *SkyTableLoadOptimal PROTO((char *catdir, char *SKYFILE, char *GSCFILE, int readwrite, int depth, int VERBOSE)); 857 952 int SkyTableSetDepth PROTO((SkyTable *sky, int depth)); 953 SkyList *SkyRegionByIndex PROTO((SkyTable *table, int index)); 858 954 SkyList *SkyRegionByCPT PROTO((SkyTable *table, char *filename)); 859 955 SkyList *SkyRegionByPoint PROTO((SkyTable *table, int depth, double ra, double dec)); … … 902 998 int HostTableTestHost (SkyRegion *region, int hostID); 903 999 1000 void InitHost (HostInfo *host); 1001 1002 HostTableGroup *HostTableGroups (HostTable *table, int *ngroups); 1003 int HostTableGroupWaitJobsGetIO (HostTableGroup *table, char *file, int lineno, int VERBOSE); 1004 904 1005 // functions to support tiny versions of Average and Measure 905 1006 void CopyAverageToTiny (AverageTiny *averageT, Average *average); … … 935 1036 void dvo_lensing_init (Lensing *lensing); 936 1037 void dvo_lensobj_init (Lensobj *lensobj, int toZero); 1038 void dvo_starpar_init (StarPar *starpar); 937 1039 938 1040 void InitRegionHosts (RegionHostInfo *hosts, int Nhosts, int NHOSTS); … … 944 1046 int RegionHostFindNeighbors (RegionHostTable *table, int Nhost); 945 1047 1048 // galaxy_model: 1049 int TransformProperMotion_radians (double *uR, double *uD, double uL, double uB, double Rrad, double Drad, CoordTransform *transform); 1050 int TransformProperMotion (double *uR, double *uD, double uL, double uB, double R, double D, CoordTransform *transform); 1051 int SolarMotionModel_radians (double *uL_sol, double *uB_sol, double Lrad, double Brad, double distance); 1052 int SolarMotionModel (double *uL_sol, double *uB_sol, double L, double B, double distance); 1053 int GalaxyMotionModel_radians (double *uL_gal, double *uB_gal, double Lrad, double Brad); 1054 int GalaxyMotionModel (double *uL_gal, double *uB_gal, double L, double B); 1055 int InitGalaxyModel (char *version); 1056 1057 # define LENSFIELD(NAME) float LensValue_##NAME (PhotCode *code, Lensobj *lensobj); 1058 1059 LENSFIELD(X11_sm_obj) 1060 LENSFIELD(X12_sm_obj) 1061 LENSFIELD(X22_sm_obj) 1062 LENSFIELD(E1_sm_obj) 1063 LENSFIELD(E2_sm_obj) 1064 1065 LENSFIELD(X11_sh_obj) 1066 LENSFIELD(X12_sh_obj) 1067 LENSFIELD(X22_sh_obj) 1068 LENSFIELD(E1_sh_obj) 1069 LENSFIELD(E2_sh_obj) 1070 1071 LENSFIELD(X11_sm_psf) 1072 LENSFIELD(X12_sm_psf) 1073 LENSFIELD(X22_sm_psf) 1074 LENSFIELD(E1_sm_psf) 1075 LENSFIELD(E2_sm_psf) 1076 1077 LENSFIELD(X11_sh_psf) 1078 LENSFIELD(X12_sh_psf) 1079 LENSFIELD(X22_sh_psf) 1080 LENSFIELD(E1_sh_psf) 1081 LENSFIELD(E2_sh_psf) 1082 1083 # undef LENSFIELD 1084 946 1085 # endif // DVO_H -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/include/dvodb.h
r37035 r37822 54 54 MAG_OPTION_NPHOT, // Nused 55 55 MAG_OPTION_UC_DIST, 56 MAG_OPTION_STACK_DET_ID,57 56 MAG_OPTION_FLAGS, 57 58 MAG_OPTION_X11_SM_OBJ, 59 MAG_OPTION_X12_SM_OBJ, 60 MAG_OPTION_X22_SM_OBJ, 61 MAG_OPTION_E1_SM_OBJ, 62 MAG_OPTION_E2_SM_OBJ, 63 64 MAG_OPTION_X11_SH_OBJ, 65 MAG_OPTION_X12_SH_OBJ, 66 MAG_OPTION_X22_SH_OBJ, 67 MAG_OPTION_E1_SH_OBJ, 68 MAG_OPTION_E2_SH_OBJ, 69 70 MAG_OPTION_X11_SM_PSF, 71 MAG_OPTION_X12_SM_PSF, 72 MAG_OPTION_X22_SM_PSF, 73 MAG_OPTION_E1_SM_PSF, 74 MAG_OPTION_E2_SM_PSF, 75 76 MAG_OPTION_X11_SH_PSF, 77 MAG_OPTION_X12_SH_PSF, 78 MAG_OPTION_X22_SH_PSF, 79 MAG_OPTION_E1_SH_PSF, 80 MAG_OPTION_E2_SH_PSF, 81 82 MAG_OPTION_F_AP_R5, 83 MAG_OPTION_F_ERR_AP_R5, 84 MAG_OPTION_F_STDEV_AP_R5, 85 MAG_OPTION_F_FILL_AP_R5, 86 87 MAG_OPTION_F_AP_R6, 88 MAG_OPTION_F_ERR_AP_R6, 89 MAG_OPTION_F_STDEV_AP_R6, 90 MAG_OPTION_F_FILL_AP_R6, 58 91 } dvoMagOptionType; 92 93 // MAG_OPTION_STACK_PRIMARY_OFF, 94 // MAG_OPTION_STACK_BEST_OFF, 59 95 60 96 typedef enum { … … 137 173 MEAS_XFIX, 138 174 MEAS_YFIX, 175 MEAS_XOFF_KH, 176 MEAS_YOFF_KH, 177 MEAS_XOFF_DCR, 178 MEAS_YOFF_DCR, 179 MEAS_ROFF_GAL, 180 MEAS_DOFF_GAL, 139 181 MEAS_POS_SYS_ERR, 140 182 MEAS_XFIELD, … … 160 202 MEAS_FLAT, 161 203 MEAS_CENTER_OFFSET, 162 MEAS_REF_COLOR, 204 MEAS_REF_COLOR_BLUE, 205 MEAS_REF_COLOR_RED, 206 MEAS_X11_SM_OBJ, 207 MEAS_X12_SM_OBJ, 208 MEAS_X22_SM_OBJ, 209 MEAS_E1_SM_OBJ, 210 MEAS_E2_SM_OBJ, 211 MEAS_X11_SH_OBJ, 212 MEAS_X12_SH_OBJ, 213 MEAS_X22_SH_OBJ, 214 MEAS_E1_SH_OBJ, 215 MEAS_E2_SH_OBJ, 216 MEAS_X11_SM_PSF, 217 MEAS_X12_SM_PSF, 218 MEAS_X22_SM_PSF, 219 MEAS_E1_SM_PSF, 220 MEAS_E2_SM_PSF, 221 MEAS_X11_SH_PSF, 222 MEAS_X12_SH_PSF, 223 MEAS_X22_SH_PSF, 224 MEAS_E1_SH_PSF, 225 MEAS_E2_SH_PSF, 226 MEAS_E_BV, // extinction (mags) 227 MEAS_E_BV_ERR, 228 MEAS_DISTANCE_MOD, // distance modulus (mags) 229 MEAS_DISTANCE_MOD_ERR, 230 MEAS_M_R, // absolute mag in r-band 231 MEAS_M_R_ERR, 232 MEAS_FEH, // metallicity 233 MEAS_FEH_ERR, 234 MEAS_URA_GALMODEL, // model pm prediction 235 MEAS_UDEC_GALMODEL, // model pm prediction 236 MEAS_RA_GALMODEL, // model pm prediction 237 MEAS_DEC_GALMODEL, // model pm prediction 163 238 }; 164 239 … … 198 273 AVE_EXTID_HI, 199 274 AVE_EXTID_LO, 200 AVE_REF_COLOR, 275 AVE_REF_COLOR_BLUE, 276 AVE_REF_COLOR_RED, 201 277 AVE_PHOT, // photometry class of values 278 AVE_E_BV, // extinction (mags) 279 AVE_E_BV_ERR, 280 AVE_DISTANCE_MOD, // distance modulus (mags) 281 AVE_DISTANCE_MOD_ERR, 282 AVE_M_R, // absolute mag in r-band 283 AVE_M_R_ERR, 284 AVE_FEH, // metallicity 285 AVE_FEH_ERR, 286 AVE_URA_GALMODEL, // model pm prediction 287 AVE_UDEC_GALMODEL, // model pm prediction 288 AVE_RA_GALMODEL, // model pm prediction 289 AVE_DEC_GALMODEL, // model pm prediction 202 290 }; 203 291 … … 274 362 IMAGE_NLINK_PHOTOM, 275 363 IMAGE_NLINK_ASTROM, 276 IMAGE_REF_COLOR 364 IMAGE_REF_COLOR_BLUE, 365 IMAGE_REF_COLOR_RED 277 366 }; 278 367 … … 366 455 int ParseImageField PROTO((dbField *field, char *fieldName)); 367 456 368 dbValue dbExtractAverages PROTO((Average *average, SecFilt *secfilt, Measure *measure, dbField *field));369 dbValue dbExtractMeasures PROTO((Average *average, SecFilt *secfilt, Measure *measure, dbField *field));457 dbValue dbExtractAverages PROTO((Average *average, SecFilt *secfilt, Measure *measure, Lensobj *lensobj, StarPar *starpar, dbField *field)); 458 dbValue dbExtractMeasures PROTO((Average *average, SecFilt *secfilt, Measure *measure, Lensing *lensing, StarPar *starpar, dbField *field)); 370 459 dbValue dbExtractImages PROTO((Image *image, off_t Nimage, off_t N, dbField *field)); 371 460 … … 374 463 int dbAstroRegionLimits PROTO((dbStack **stack, int *nstack, SkyRegionSelection *selection, int table)); 375 464 char *strfloat PROTO((float value)); 465 466 int dbFieldNeedMeasure (dbField *fields, int Nfields); 467 int dbFieldNeedLensobj (dbField *fields, int Nfields); 468 int dbFieldNeedLensing (dbField *fields, int Nfields); 469 int dbFieldNeedStarpar (dbField *fields, int Nfields, int isAverage); 376 470 377 471 void FreeImageSelection (void); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/include/libdvo_astro.h
r31635 r37822 1 #ifdef notdef 2 # include "external.h" 3 # include "shell.h" 4 # include "dvomath.h" 5 # include "convert.h" 6 # include "display.h" 7 # include "data.h" 8 #endif 1 # ifndef LIBDVO_ASTRO_H 2 # define LIBDVO_ASTRO_H 9 3 10 # ifndef ASTRO_H 11 # define ASTRO_H 4 typedef enum { 5 COORD_NONE, 6 COORD_CELESTIAL, 7 COORD_GALACTIC, // based on Liu et al 2011 8 COORD_ECLIPTIC, 9 COORD_GALACTIC_REID_2004, // an older definition of the galactic plane 10 } CoordTransformSystem; 12 11 13 void InitAstro (void); 14 void FreeAstro (void); 12 typedef enum { 13 PROJ_NONE, // undefined 14 PROJ_ZEA, // zenithal 15 PROJ_ZPL, // zenithal 16 PROJ_ARC, // zenithal 17 PROJ_STG, // zenithal 18 PROJ_SIN, // zenithal 19 PROJ_TAN, // zenithal 20 PROJ_TNX, // zenithal 21 PROJ_DIS, // zenithal (TAN + polyterms) 22 PROJ_LIN, // cartesian 23 PROJ_PLY, // cartesian (allow polyterms) 24 PROJ_WRP, // cartesian (allow polyterms, require mosaic) 25 PROJ_AIT, // pseudocyl 26 PROJ_GLS, // pseudocyl 27 PROJ_PAR, // pseudocyl 28 } OhanaProjection; 29 30 typedef enum { 31 PROJ_MODE_NONE, 32 PROJ_MODE_CARTESIAN, 33 PROJ_MODE_ZENITHAL, 34 PROJ_MODE_PSEUDOCYL, 35 } OhanaProjectionMode; 15 36 16 37 typedef struct { … … 29 50 } CoordTransform; 30 51 31 typedef enum {COORD_NONE, COORD_CELESTIAL, COORD_GALACTIC, COORD_ECLIPTIC} CoordTransformSystem; 52 typedef struct { 53 int Nx; 54 int Ny; 55 float dX; 56 float dY; 57 float **dXv; 58 float **dYv; 59 unsigned int tableID; 60 unsigned int imageID; 61 int keep; 62 } AstromOffsetMap; 63 64 typedef struct { 65 int Nmap; 66 AstromOffsetMap **map; 67 int *imageIDtoTableSeq; 68 int MaxImageID; 69 int MaxTableID; 70 } AstromOffsetTable; 71 72 /* Internal version of Coords (see CoordsDisk in libautocode/def/coords-disk.d) */ 73 typedef struct Coords { 74 double crval1; // coordinate at reference pixel 75 double crval2; // coordinate at reference pixel 76 float crpix1; // coordinate of reference pixel 77 float crpix2; // coordinate of reference pixel 78 float cdelt1; // degrees per pixel 79 float cdelt2; // degrees per pixel 80 float pc1_1; // rotation matrix 81 float pc1_2; // rotation matrix 82 float pc2_1; // rotation matrix 83 float pc2_2; // rotation matrix 84 float polyterms[7][2]; // higher order warping terms 85 char ctype[15]; // coordinate type 86 char Npolyterms; // order of polynomial 87 struct Coords *mosaic; // pointer to parent mosaic 88 AstromOffsetMap *offsetMap; // pointer to offset map transformation 89 } Coords; 90 91 typedef struct Image { 92 Coords coords; // astrometric data 93 e_time tzero; // readout time (row 0) 94 unsigned int nstar; // number of stars on image 95 float secz; // airmass (mag) 96 unsigned short NX; // image width 97 unsigned short NY; // image height 98 float apmifit; // aperture correction (mag) 99 float dapmifit; // apmifit error (mag) 100 float Mcal; // calibration mag (mag) 101 float dMcal; // error on Mcal (mag) 102 short Xm; // image chisq (10*log(value)) 103 short photcode; // identifier for CCD, 104 float exptime; // exposure time (seconds) 105 float sidtime; // sidereal time of exposure 106 float latitude; // observatory latitude (degrees) 107 float RAo; // image center (degrees) 108 float DECo; // image center (degrees) 109 float Radius; // image radius (degrees) 110 float refColorBlue; // median astrometry ref color 111 float refColorRed; // median astrometry ref color 112 char name[117]; // name of original image 113 unsigned char detection_limit; // detection limit (10*mag) 114 unsigned char saturation_limit; // saturation limit (10*mag) 115 unsigned char cerror; // astrometric error (50*arcsec) 116 unsigned char fwhm_x; // PSF x width (25*arcsec) 117 unsigned char fwhm_y; // PSF y width (25*arcsec) 118 unsigned char trate; // scan rate (100 usec/pixel) 119 unsigned char ccdnum; // CCD ID number 120 unsigned int flags; // image quality flags 121 unsigned int imageID; // internal image ID 122 unsigned int parentID; // associated ref image 123 unsigned int externID; // external image ID 124 unsigned short sourceID; // analysis source ID 125 short nLinkAstrom; // mean number of matched measurements for astrometry 126 short nLinkPhotom; // mean number of matched measurements for astrometry 127 short ubercalDist; // distance to nearest ubercal image 128 float dXpixSys; // systematic astrometry error in X 129 float dYpixSys; // systematic astrometry error in Y 130 float dMagSys; // systematic photometry error 131 unsigned short nFitAstrom; // number of stars used for astrometry cal 132 unsigned short nFitPhotom; // number of stars used for photometry cal 133 unsigned int photom_map_id; // reference to 2D zero point map 134 unsigned int astrom_map_id; // reference to 2D astrometry map 135 struct Image *parent; // pointer to parent mosaic (not save to disk) 136 } Image; 32 137 33 138 CoordTransform *InitTransform (CoordTransformSystem input, CoordTransformSystem output); 34 139 int ApplyTransform (double *x, double *y, double X, double Y, CoordTransform *transform); 35 140 141 /* in coords.c */ 142 void InitCoords (Coords *coords, char *projection); 143 void CopyCoords (Coords *tgt, Coords *src); 144 145 int XY_to_LM (double *L, double *M, double x, double y, Coords *coords); 146 int LM_to_XY (double *x, double *y, double L, double M, Coords *coords); 147 int RD_to_LM (double *L, double *M, double ra, double dec, Coords *coords); 148 int LM_to_RD (double *ra, double *dec, double L, double M, Coords *coords); 149 int XY_to_RD (double *ra, double *dec, double x, double y, Coords *coords); 150 int RD_to_XY (double *x, double *y, double ra, double dec, Coords *coords); 151 int fXY_to_RD (float *ra, float *dec, double x, double y, Coords *coords); 152 int fRD_to_XY (float *x, float *y, double ra, double dec, Coords *coords); 153 int GetCoords (Coords *coords, Header *header); 154 int PutCoords (Coords *coords, Header *header); 155 void coords_precess (double *ra, double *dec, double in_epoch, double out_epoch); 156 OhanaProjection GetProjection (char *ctype); 157 int SetProjection (char *ctype, OhanaProjection proj); 158 OhanaProjectionMode GetProjectionMode (OhanaProjection proj); 159 160 /* in AstromOffsetMapIO.c */ 161 AstromOffsetTable *AstromOffsetMapLoad (char *filename, int VERBOSE); 162 int AstromOffsetMapSave (AstromOffsetTable *table, char *filename); 163 AstromOffsetTable *AstromOffsetMapToTable(AstromOffsetMap_Disk_6x6 *map_disk, off_t Nmap); 164 AstromOffsetMap_Disk_6x6 *AstromOffsetTableToMap(AstromOffsetTable *table, off_t *Nmap); 165 166 /* in AstromOffsetMapOps.c */ 167 float AstromOffsetMapValue (AstromOffsetMap *map, float x, float y, int xdir); 168 int AstromOffsetMapFit (AstromOffsetMap *map, float *x, float *y, float *f, int Npts, int xdir); 169 170 /* in AstromOffsetMapUtils.c */ 171 AstromOffsetMap *AstromOffsetMapInit (int Nx, int Ny); 172 void AstromOffsetMapFree (AstromOffsetMap *map); 173 174 int AstromOffsetTableNewMap (AstromOffsetTable *table, int Nx, int Ny, Image *image); 175 int AstromOffsetTableMatchChips (Image *images, off_t Nimages, AstromOffsetTable *table); 176 AstromOffsetTable *AstromOffsetTableInit(); 177 void AstromOffsetTableFree(AstromOffsetTable *table); 178 int AstromOffsetTableAddMapFromImage (AstromOffsetTable *table, Image *image); 179 void AstromOffsetMapPrint (AstromOffsetMap *map, char *filename); 180 int AstromOffsetMapRepair (AstromOffsetMap *map, int xdir); 181 AstromOffsetMap *AstromOffsetMapCopy (AstromOffsetMap *map); 182 void AstromOffsetMapCopyData (AstromOffsetMap *tgt, AstromOffsetMap *src); 183 void AstromOffsetMapSetOrder (AstromOffsetMap *map, int Nx, int Ny, Image *image); 184 36 185 # endif -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/include/ps1_v5_defs.h
r37035 r37822 9 9 10 10 Lensing *Lensing_PS1_V5_ToInternal (Lensing_PS1_V5 *in, off_t Nvalues); 11 Lensing *Lensing_PS1_V5_ALT_ToInternal (Lensing_PS1_V5_ALT *in, off_t Nvalues); 11 12 Lensing_PS1_V5 *LensingInternalTo_PS1_V5 (Lensing *in, off_t Nvalues); 12 13 Lensobj *Lensobj_PS1_V5_ToInternal (Lensobj_PS1_V5 *in, off_t Nvalues); 13 14 Lensobj_PS1_V5 *LensobjInternalTo_PS1_V5 (Lensobj *in, off_t Nvalues); 14 15 16 StarPar *StarPar_PS1_V5_ToInternal (StarPar_PS1_V5 *in, off_t Nvalues); 17 StarPar_PS1_V5 *StarParInternalTo_PS1_V5 (StarPar *in, off_t Nvalues); 18 15 19 PhotCode *PhotCode_PS1_V5_To_Internal (PhotCode_PS1_V5 *in, off_t Nvalues); 16 20 PhotCode_PS1_V5 *PhotCode_Internal_To_PS1_V5 (PhotCode *in, off_t Nvalues); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/BoundaryTree.c
r36490 r37822 84 84 gfits_scan (headerPHU, "DEC_ORI", "%lf", 1, &tree->DEC_origin); 85 85 gfits_scan (headerPHU, "DEC_OFF", "%lf", 1, &tree->DEC_offset); 86 gfits_scan (headerPHU, "NX_SUB", "% d", 1, &tree->NX_SUB);87 gfits_scan (headerPHU, "NY_SUB", "% d", 1, &tree->NY_SUB);86 gfits_scan (headerPHU, "NX_SUB", "%f", 1, &tree->NX_SUB); 87 gfits_scan (headerPHU, "NY_SUB", "%f", 1, &tree->NY_SUB); 88 88 gfits_scan (headerPHU, "PIXSCALE", "%lf", 1, &tree->dPix); 89 89 … … 111 111 ALLOCATE (tree->Xo, double *, tree->Nzone); 112 112 ALLOCATE (tree->Yo, double *, tree->Nzone); 113 ALLOCATE (tree->dX, int *, tree->Nzone);114 ALLOCATE (tree->dY, int *, tree->Nzone);113 ALLOCATE (tree->dX, float *, tree->Nzone); 114 ALLOCATE (tree->dY, float *, tree->Nzone); 115 115 ALLOCATE (tree->cell, int *, tree->Nzone); 116 116 ALLOCATE (tree->projID, int *, tree->Nzone); … … 121 121 ALLOCATE (tree->Xo[i], double, tree->Nband[i]); 122 122 ALLOCATE (tree->Yo[i], double, tree->Nband[i]); 123 ALLOCATE (tree->dX[i], int, tree->Nband[i]);124 ALLOCATE (tree->dY[i], int, tree->Nband[i]);123 ALLOCATE (tree->dX[i], float, tree->Nband[i]); 124 ALLOCATE (tree->dY[i], float, tree->Nband[i]); 125 125 ALLOCATE (tree->cell[i], int, tree->Nband[i]); 126 126 ALLOCATE (tree->projID[i], int, tree->Nband[i]); … … 147 147 GET_COLUMN_NEW(&headerCell, &ftableCell, Xo, "X_CENT", double); 148 148 GET_COLUMN_NEW(&headerCell, &ftableCell, Yo, "Y_CENT", double); 149 GET_COLUMN_NEW(&headerCell, &ftableCell, dX, "X_GRID", int);150 GET_COLUMN_NEW(&headerCell, &ftableCell, dY, "Y_GRID", int);149 GET_COLUMN_NEW(&headerCell, &ftableCell, dX, "X_GRID", float); 150 GET_COLUMN_NEW(&headerCell, &ftableCell, dY, "Y_GRID", float); 151 151 GET_COLUMN_NEW(&headerCell, &ftableCell, name, "NAME", char); // XXX how is this done? 152 152 gfits_free_header (&headerCell); … … 214 214 gfits_modify (&header, "DEC_OFF", "%lf", 1, tree->DEC_offset); 215 215 216 gfits_modify (&header, "NX_SUB", "% d", 1, tree->NX_SUB);217 gfits_modify (&header, "NY_SUB", "% d", 1, tree->NY_SUB);216 gfits_modify (&header, "NX_SUB", "%f", 1, tree->NX_SUB); 217 gfits_modify (&header, "NY_SUB", "%f", 1, tree->NY_SUB); 218 218 gfits_modify (&header, "PIXSCALE", "%lf", 1, tree->dPix); 219 219 … … 289 289 gfits_define_bintable_column (&theader, "D", "X_CENT", "projection cell center pixel", "none", 1.0, 0.0); 290 290 gfits_define_bintable_column (&theader, "D", "Y_CENT", "projection cell center pixel", "none", 1.0, 0.0); 291 gfits_define_bintable_column (&theader, " J", "X_GRID", "skycell grid spacing", "none", 1.0, 0.0);292 gfits_define_bintable_column (&theader, " J", "Y_GRID", "skycell grid spacing", "none", 1.0, 0.0);291 gfits_define_bintable_column (&theader, "E", "X_GRID", "skycell grid spacing", "none", 1.0, 0.0); 292 gfits_define_bintable_column (&theader, "E", "Y_GRID", "skycell grid spacing", "none", 1.0, 0.0); 293 293 gfits_define_bintable_column (&theader, fmt, "NAME", "cell name", "none", 1.0, 0.0); 294 294 … … 310 310 double *Xo ; ALLOCATE (Xo, double, Ncell); 311 311 double *Yo ; ALLOCATE (Yo, double, Ncell); 312 int *dX ; ALLOCATE (dX, int,Ncell);313 int *dY ; ALLOCATE (dY, int,Ncell);312 float *dX ; ALLOCATE (dX, float, Ncell); 313 float *dY ; ALLOCATE (dY, float, Ncell); 314 314 char *name ; ALLOCATE (name, char, Ncell*BOUNDARY_TREE_NAME_LENGTH); 315 315 … … 371 371 int BoundaryTreeCellCoords (BoundaryTree *tree, int *zone, int *band, double ra, double dec) { 372 372 373 ra = ohana_normalize_angle (ra); 374 373 375 // first, find the containing zone 374 376 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/HostTable.c
r35848 r37822 3 3 # include <sys/wait.h> 4 4 5 void InitHost (HostInfo *host) { 6 host->hostname = NULL; 7 host->pathname = NULL; 8 host->results = NULL; 9 host->stdio[HOST_STDIN] = -1; 10 host->stdio[HOST_STDOUT] = -1; 11 host->stdio[HOST_STDERR] = -1; 12 host->pid = 0; 13 return; 14 } 15 5 16 void InitHosts (HostInfo *hosts, int Nhosts, int NHOSTS) { 6 17 7 18 int i; 8 19 for (i = Nhosts; i < NHOSTS; i++) { 9 hosts[i].hostname = NULL; 10 hosts[i].pathname = NULL; 11 hosts[i].results = NULL; 12 hosts[i].stdio[HOST_STDIN] = -1; 13 hosts[i].stdio[HOST_STDOUT] = -1; 14 hosts[i].stdio[HOST_STDERR] = -1; 15 hosts[i].pid = 0; 20 InitHost (&hosts[i]); 16 21 } 17 22 return; … … 36 41 } 37 42 if (table->index) free (table->index); 43 free (table); 44 return; 45 } 46 47 // a HostTableGroup is a pointer set to one or more HostTable entries 48 void FreeTableGroup (HostTableGroup *table) { 49 50 if (!table) return; 51 if (table->hosts) { 52 free (table->hosts); 53 } 38 54 free (table); 39 55 return; … … 136 152 fclose (f); 137 153 return table; 154 } 155 156 // split a host table into Ngroups, each with a unique set of hosts 157 HostTableGroup *HostTableGroups (HostTable *table, int *ngroups) { 158 159 // identify the unique host names and the number of times they each exist 160 // (Host tables are not very large; I can afford to do this in an inefficient way) 161 int i, j, k; 162 163 int Nunique = 0; 164 char **unique_hosts = NULL; // an array of pointers to a set of the names 165 int *Nunique_hosts = NULL; // an array of pointers to the count of each 166 ALLOCATE ( unique_hosts, char *, table->Nhosts); 167 ALLOCATE (Nunique_hosts, int, table->Nhosts); 168 for (i = 0; i < table->Nhosts; i++) Nunique_hosts[i] = 0; 169 170 for (i = 0; i < table->Nhosts; i++) { 171 int found = FALSE; 172 for (j = 0; !found && (j < Nunique); j++) { 173 if (!strcmp(table->hosts[i].hostname, unique_hosts[j])) { 174 Nunique_hosts[j] ++; 175 found = TRUE; 176 } 177 } 178 if (!found) { 179 unique_hosts[Nunique] = table->hosts[i].hostname; 180 Nunique_hosts[Nunique] = 1; 181 Nunique ++; 182 } 183 } 184 185 int Ngroups = 0; 186 for (i = 0; i < Nunique; i++) { 187 Ngroups = MAX (Nunique_hosts[i], Ngroups); 188 } 189 190 HostTableGroup *groups = NULL; 191 int *foundHost = NULL; 192 193 ALLOCATE (foundHost, int, table->Nhosts); 194 ALLOCATE (groups, HostTableGroup, Ngroups); 195 196 for (i = 0; i < table->Nhosts; i++) foundHost[i] = FALSE; 197 198 // in each group, attempt to add one of each unique host 199 for (i = 0; i < Ngroups; i++) { 200 groups[i].Nhosts = 0; 201 ALLOCATE (groups[i].hosts, HostInfo *, Nunique); 202 for (j = 0; j < Nunique; j++) { 203 int found = FALSE; 204 for (k = 0; !found && (k < table->Nhosts); k++) { 205 if (foundHost[k]) continue; 206 if (strcmp(unique_hosts[j], table->hosts[k].hostname)) continue; 207 groups[i].hosts[groups[i].Nhosts] = &table->hosts[k]; 208 groups[i].Nhosts ++; 209 found = TRUE; 210 foundHost[k] = TRUE; 211 } 212 } 213 } 214 *ngroups = Ngroups; 215 return groups; 138 216 } 139 217 … … 255 333 256 334 // this loop has 2 chunks: (a) check for I/O + (b) check for jobs done 257 while ( 1) {335 while (Nfound < Nrunning) { 258 336 259 337 // Wait up to 0.5 second for host to provide I/O … … 284 362 // if (table->hosts[i].stdout.Nbuffer > 0x10000) { 285 363 if (table->hosts[i].stdout.Nbuffer > 0x1000) { 286 int printHead = VERBOSE ||(table->hosts[i].stdout.Nbuffer > 0);364 int printHead = VERBOSE && (table->hosts[i].stdout.Nbuffer > 0); 287 365 if (printHead) fprintf (stdout, "--- stdout from %s --- (%d bytes, v1)\n", table->hosts[i].hostname, table->hosts[i].stdout.Nbuffer); 288 366 int Nout = write (STDOUT_FILENO, table->hosts[i].stdout.buffer, table->hosts[i].stdout.Nbuffer); … … 298 376 // if (table->hosts[i].stderr.Nbuffer > 0x10000) { 299 377 if (table->hosts[i].stderr.Nbuffer > 0x1000) { 300 int printHead = VERBOSE ||(table->hosts[i].stderr.Nbuffer > 0);378 int printHead = VERBOSE && (table->hosts[i].stderr.Nbuffer > 0); 301 379 if (printHead) fprintf (stdout, "--- stderr from %s --- (%d bytes, v1)\n", table->hosts[i].hostname, table->hosts[i].stderr.Nbuffer); 302 380 int Nout = write (STDOUT_FILENO, table->hosts[i].stderr.buffer, table->hosts[i].stderr.Nbuffer); … … 314 392 if (!pid) { 315 393 // fprintf (stderr, "no hosts to harvest\n"); 316 usleep ( 500000);394 usleep (200000); 317 395 break; // no outstanding jobs have finished 318 396 } … … 367 445 } 368 446 } 369 if (!found) { 370 fprintf (stderr, "Programming error: failed to matched finished job to known host!\n"); 371 exit (2); 372 } 373 Nfound ++; 447 if (found) Nfound ++; 448 // we sometimes harvest children not in the list (eg, closed kapa window). just ignore 374 449 if (Nfound == Nrunning) goto escape; // we've harvested all jobs 375 450 } … … 389 464 } 390 465 466 // wait for all children to complete, report output to stdout 467 int HostTableGroupWaitJobsGetIO (HostTableGroup *table, char *file, int lineno, int VERBOSE) { 468 469 // we have launched table->Nhosts jobs; wait for all of them to complete... 470 // if one (N) failed to launch, we will get an ECHILD error from the last (N) calls 471 472 // we need to read any data waiting on stderr or stdout from these jobs, or the overfull 473 // buffers can cause a problem. we alternate between 'select' and 'waitpid' calls with 474 // timeouts for both 475 476 // add all hosts' sockets to the fd_sets 477 fd_set rdSet, wtSet; 478 FD_ZERO (&rdSet); 479 FD_ZERO (&wtSet); 480 481 // XXX can I set the fd_sets once, since I am not actually closing the fd's? 482 483 int globalStatus = TRUE; 484 485 int i; 486 int Nmax = 0; 487 for (i = 0; i < table->Nhosts; i++) { 488 if (!table->hosts[i][0].pid) continue; // any unconnected hosts should be skipped 489 FD_SET (table->hosts[i][0].stdio[HOST_STDIN], &wtSet); 490 Nmax = MAX (Nmax, table->hosts[i][0].stdio[HOST_STDIN]); 491 FD_SET (table->hosts[i][0].stdio[HOST_STDOUT], &rdSet); 492 Nmax = MAX (Nmax, table->hosts[i][0].stdio[HOST_STDOUT]); 493 FD_SET (table->hosts[i][0].stdio[HOST_STDERR], &rdSet); 494 Nmax = MAX (Nmax, table->hosts[i][0].stdio[HOST_STDERR]); 495 } 496 Nmax ++; 497 498 // need the list of connected hosts for exit test below 499 int Nrunning = 0; 500 for (i = 0; i < table->Nhosts; i++) { 501 if (!table->hosts[i][0].pid) continue; // any unconnected hosts should be skipped 502 Nrunning ++; 503 } 504 505 int Nfound = 0; 506 507 // this loop has 2 chunks: (a) check for I/O + (b) check for jobs done 508 while (1) { 509 510 // Wait up to 0.5 second for host to provide I/O 511 // timeout gets mucked: need to reset before each select 512 struct timeval timeout; 513 timeout.tv_sec = 10; 514 timeout.tv_usec = 500000; 515 516 int status = select (Nmax, NULL, &wtSet, NULL, &timeout); 517 if (status == -1) { 518 perror("select()"); 519 exit (2); 520 } 521 522 // we have some sockets to check, check sockets for all hosts 523 for (i = 0; (status > 0) && (i < table->Nhosts); i++) { 524 if (!table->hosts[i][0].pid) continue; // any unconnected hosts should be skipped 525 526 if (FALSE && FD_ISSET (table->hosts[i][0].stdio[HOST_STDIN], &wtSet)) { 527 // this host is waiting for input : this is an error, so exit 528 fprintf (stderr, "host %s is waiting for input\n", table->hosts[i][0].hostname); 529 abort(); 530 } 531 532 if ((table->hosts[i][0].stdio[HOST_STDOUT] > 0) && FD_ISSET (table->hosts[i][0].stdio[HOST_STDOUT], &rdSet)) { 533 // this host has waiting output : read to buffer, and dump if necessary 534 ReadtoIOBuffer (&table->hosts[i][0].stdout, table->hosts[i][0].stdio[HOST_STDOUT]); 535 // if (table->hosts[i][0].stdout.Nbuffer > 0x10000) { 536 if (table->hosts[i][0].stdout.Nbuffer > 0x1000) { 537 int printHead = VERBOSE || (table->hosts[i][0].stdout.Nbuffer > 0); 538 if (printHead) fprintf (stdout, "--- stdout from %s --- (%d bytes, v1)\n", table->hosts[i][0].hostname, table->hosts[i][0].stdout.Nbuffer); 539 int Nout = write (STDOUT_FILENO, table->hosts[i][0].stdout.buffer, table->hosts[i][0].stdout.Nbuffer); 540 if (Nout != table->hosts[i][0].stdout.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); } 541 FlushIOBuffer (&table->hosts[i][0].stdout); 542 if (printHead) fprintf (stdout, "\n"); 543 } 544 } 545 546 if ((table->hosts[i][0].stdio[HOST_STDERR] > 0) && FD_ISSET (table->hosts[i][0].stdio[HOST_STDERR], &rdSet)) { 547 // this host has waiting output : read to buffer, and dump if necessary 548 ReadtoIOBuffer (&table->hosts[i][0].stderr, table->hosts[i][0].stdio[HOST_STDERR]); 549 // if (table->hosts[i][0].stderr.Nbuffer > 0x10000) { 550 if (table->hosts[i][0].stderr.Nbuffer > 0x1000) { 551 int printHead = VERBOSE || (table->hosts[i][0].stderr.Nbuffer > 0); 552 if (printHead) fprintf (stdout, "--- stderr from %s --- (%d bytes, v1)\n", table->hosts[i][0].hostname, table->hosts[i][0].stderr.Nbuffer); 553 int Nout = write (STDOUT_FILENO, table->hosts[i][0].stderr.buffer, table->hosts[i][0].stderr.Nbuffer); 554 if (Nout != table->hosts[i][0].stderr.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); } 555 FlushIOBuffer (&table->hosts[i][0].stderr); 556 if (printHead) fprintf (stdout, "\n"); 557 } 558 } 559 } 560 561 // now check if any children have finished... 562 while (TRUE) { 563 int status = 0; 564 int pid = waitpid (-1, &status, WNOHANG); 565 if (!pid) { 566 // fprintf (stderr, "no hosts to harvest\n"); 567 usleep (500000); 568 break; // no outstanding jobs have finished 569 } 570 if ((pid == -1) && (errno == ECHILD)) goto escape; // no more jobs on which to wait 571 if ((pid == -1) && (errno != ECHILD)) { 572 fprintf (stderr, "programming error (2)? %s %d", file, lineno); 573 exit (2); 574 } 575 576 // find the host which has finished 577 int found = FALSE; 578 for (i = 0; (i < table->Nhosts) && !found; i++) { 579 if (table->hosts[i][0].pid != pid) continue; 580 found = TRUE; 581 582 HostInfo *host = table->hosts[i]; 583 584 // check on the status of this and report any output? 585 if (VERBOSE) fprintf (stdout, "job finished for %s (%d)\n", host->hostname, pid); 586 587 // read stdout 588 int printHead; 589 printHead = VERBOSE || (host->stdout.Nbuffer > 0); 590 EmptyIOBuffer (&host->stdout, 100, host->stdio[HOST_STDOUT]); 591 if (printHead) fprintf (stdout, "--- stdout from %s --- (%d bytes, v2)\n", host->hostname, host->stdout.Nbuffer); 592 int Nout = write (STDOUT_FILENO, host->stdout.buffer, host->stdout.Nbuffer); 593 if (Nout != host->stdout.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); } 594 FlushIOBuffer (&host->stdout); 595 if (printHead) fprintf (stdout, "\n"); 596 597 // read stderr 598 printHead = VERBOSE || (host->stderr.Nbuffer > 0); 599 EmptyIOBuffer (&host->stderr, 100, host->stdio[HOST_STDERR]); 600 if (printHead) fprintf (stdout, "--- stderr from %s --- (%d bytes, v2)\n", host->hostname, host->stderr.Nbuffer); 601 Nout = write (STDOUT_FILENO, host->stderr.buffer, host->stderr.Nbuffer); 602 if (Nout != host->stderr.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); } 603 FlushIOBuffer (&host->stderr); 604 if (printHead) fprintf (stdout, "\n"); 605 606 if (WIFEXITED(status)) { 607 if (VERBOSE) fprintf (stdout, "normal completion, exit status is %d\n", WEXITSTATUS(status)); 608 host->status = WEXITSTATUS(status); 609 if (host->status) { 610 fprintf (stdout, "job failed on %s\n", host->hostname); 611 globalStatus = FALSE; 612 } 613 } else { 614 host->status = -1; 615 fprintf (stdout, "job exited abnormally on %s\n", host->hostname); 616 globalStatus = FALSE; 617 continue; 618 } 619 } 620 if (!found) { 621 fprintf (stderr, "Programming error: failed to matched finished job to known host!\n"); 622 exit (2); 623 } 624 Nfound ++; 625 if (Nfound == Nrunning) goto escape; // we've harvested all jobs 626 } 627 } 628 629 escape: 630 631 // close all opened connections 632 for (i = 0; i < table->Nhosts; i++) { 633 if (!table->hosts[i][0].pid) continue; // any unconnected hosts should be skipped 634 close (table->hosts[i][0].stdio[HOST_STDIN]); 635 close (table->hosts[i][0].stdio[HOST_STDOUT]); 636 close (table->hosts[i][0].stdio[HOST_STDERR]); 637 } 638 639 return globalStatus; 640 } 641 391 642 int HostTableTestHost (SkyRegion *region, int hostID) { 392 643 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/ImageMetadata.c
r37035 r37822 156 156 // assign the storage arrays 157 157 for (i = 0; i < Nimage; i++) { 158 int Nmosaic = FindMosaicForImage (image, Nimage, i); 159 if (!Nmosaic) continue; 160 Nmosaic --; 158 if (!image[i].coords.mosaic) continue; 161 159 imageID[i] = image[i].imageID; 162 160 externID[i] = image[i].externID; 163 crval1[i] = image[Nmosaic].coords.crval1; 164 crval2[i] = image[Nmosaic].coords.crval2; 165 166 theta[i] = DEG_RAD*atan2(image[Nmosaic].coords.pc1_2, image[Nmosaic].coords.pc1_1); 161 Coords *mosaic = image[i].coords.mosaic; 162 163 crval1[i] = mosaic->crval1; 164 crval2[i] = mosaic->crval2; 165 166 theta[i] = DEG_RAD*atan2(mosaic->pc1_2, mosaic->pc1_1); 167 167 168 168 Mcal[i] = image[i].Mcal; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/ImageMetadataSelection.c
r36490 r37822 13 13 14 14 /* field defines a frame with 0,0 at the field center, and 1 arcsec / pixel */ 15 field.crpix1 = field.crpix2 = 0.0;15 InitCoords (&field, "DEC--SIN"); 16 16 field.cdelt1 = field.cdelt2 = 1.0 / 3600; 17 field.pc1_1 = field.pc2_2 = 1.0;18 field.pc1_2 = field.pc2_1 = 0.0;19 field.Npolyterms = 0;20 strcpy (field.ctype, "DEC--SIN");21 17 22 18 /* mosaic defines a frame with 0,0 at the mosaic center, and 1 arcsec / pixel */ 23 mosaic.crpix1 = mosaic.crpix2 = 0.0;19 InitCoords (&mosaic, "DEC--SIN"); 24 20 mosaic.cdelt1 = mosaic.cdelt2 = 1.0 / 3600; 25 mosaic.pc1_1 = mosaic.pc2_2 = 1.0;26 mosaic.pc1_2 = mosaic.pc2_1 = 0.0;27 mosaic.Npolyterms = 0;28 strcpy (mosaic.ctype, "DEC--SIN");29 21 30 22 if ((image = ImageMetadataLoad (filename, &Nimage)) == NULL) return (FALSE); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/ImageOps.c
r34088 r37822 55 55 if (TimeSelect && ((image[i].tzero < tzero) || (image[i].tzero+image[i].trate*image[i].NY > tzero + trange))) continue; 56 56 if (selection->useDisplay) { 57 if (!FindMosaicForImage (image, Nimage, i)) continue;58 57 // first check if region center is in image 59 58 status = RD_to_XY (&X, &Y, Rmid, graph.coords.crval2, &image[i].coords); … … 89 88 } 90 89 if (selection->useSkyregion) { 91 if (!FindMosaicForImage (image, Nimage, i)) continue;92 90 /* project this image to screen display coords */ 93 91 x[0] = 0; y[0] = 0; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/ImageSelection.c
r36490 r37822 22 22 23 23 if (mosaicMode) { 24 /* mosaic defines a frame with 0,0 at the mosaic center, and 1 arcsec / pixel */ 25 mosaic.crpix1 = mosaic.crpix2 = 0.0; 26 mosaic.cdelt1 = mosaic.cdelt2 = 1.0 / 3600; 27 mosaic.pc1_1 = mosaic.pc2_2 = 1.0; 28 mosaic.pc1_2 = mosaic.pc2_1 = 0.0; 29 mosaic.Npolyterms = 0; 30 strcpy (mosaic.ctype, "DEC--SIN"); 24 /* mosaic defines a frame with 0,0 at the mosaic center, and 1 arcsec / pixel */ 25 InitCoords (&mosaic, "DEC--SIN"); 26 mosaic.cdelt1 = mosaic.cdelt2 = 1.0 / 3600; 31 27 } 32 28 … … 64 60 } 65 61 if (m == -1) return (NULL); 66 if (!FindMosaicForImage (image, Nimage, m)) return (NULL);67 62 return (&image[m]); 68 63 } … … 85 80 } 86 81 if (m == -1) return (NULL); 87 if (!FindMosaicForImage (image, Nimage, m)) return (NULL);88 82 return (&image[m]); 89 83 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/LoadImages.c
r33649 r37822 9 9 static Image *imageCache = NULL; 10 10 static off_t cacheNimage = 0; 11 AstromOffsetTable *table = NULL; 11 12 12 13 static time_t getLastModified(char *filename); … … 39 40 lastModified = 0; 40 41 } 41 42 42 43 43 gfits_db_init (&db); … … 77 77 } 78 78 79 // assign image->parent and image->coords.mosaic 80 BuildChipMatch (image, *Nimage); 81 // MARKTIME("build chip match: %f sec\n", dtime); 82 83 char mapfile[DVO_MAX_PATH]; 84 snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", catdir); 85 86 if (table) AstromOffsetTableFree(table); 87 table = AstromOffsetMapLoad (mapfile, FALSE); 88 89 // assign images.coords.offsetMap -> table->map[i] 90 if (table) { 91 AstromOffsetTableMatchChips (image, *Nimage, table); 92 } 93 79 94 return (image); 80 95 } … … 92 107 if (!dvoUseImageCache && (images != NULL)) { 93 108 free(images); 109 AstromOffsetTableFree (table); 94 110 } else { 95 111 // defer free until next LoadImages with a different or modified Images.dat -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/RegionHostTable.c
r36630 r37822 31 31 hosts[i].Nneighbors = 0; 32 32 hosts[i].isNeighbor = FALSE; 33 34 hosts[i].astromTable = NULL; 33 35 } 34 36 return; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/TessellationTable.c
r36490 r37822 28 28 tess[i].dPix = NAN; 29 29 30 tess[i].dX = 0;31 tess[i].dY = 0;32 33 tess[i].NX_SUB = 0;34 tess[i].NY_SUB = 0;30 tess[i].dX = NAN; 31 tess[i].dY = NAN; 32 33 tess[i].NX_SUB = NAN; 34 tess[i].NY_SUB = NAN; 35 35 36 36 tess[i].basename = NULL; … … 123 123 GET_COLUMN_NEW(Xo, "X_CENT", double); 124 124 GET_COLUMN_NEW(Yo, "Y_CENT", double); 125 GET_COLUMN_NEW(dX, "X_GRID", int);126 GET_COLUMN_NEW(dY, "Y_GRID", int);125 GET_COLUMN_NEW(dX, "X_GRID", float); 126 GET_COLUMN_NEW(dY, "Y_GRID", float); 127 127 GET_COLUMN_NEW(Rmin, "R_MIN", double); 128 128 GET_COLUMN_NEW(Rmax, "R_MAX", double); … … 130 130 GET_COLUMN_NEW(Dmax, "D_MAX", double); 131 131 GET_COLUMN_NEW(dPix, "SCALE", double); 132 GET_COLUMN_NEW(NX_SUB, "NX_SUB", int);133 GET_COLUMN_NEW(NY_SUB, "NY_SUB", int);132 GET_COLUMN_NEW(NX_SUB, "NX_SUB", float); 133 GET_COLUMN_NEW(NY_SUB, "NY_SUB", float); 134 134 GET_COLUMN_NEW(TYPE, "TYPE", int); 135 135 … … 280 280 gfits_modify (&header, "DEC_OFF", "%lf", 1, rings->DEC_offset); 281 281 282 gfits_modify (&header, "NX_SUB", "% d", 1, rings->NX_SUB);283 gfits_modify (&header, "NY_SUB", "% d", 1, rings->NY_SUB);282 gfits_modify (&header, "NX_SUB", "%f", 1, rings->NX_SUB); 283 gfits_modify (&header, "NY_SUB", "%f", 1, rings->NY_SUB); 284 284 gfits_modify (&header, "PIXSCALE", "%lf", 1, rings->dPix); 285 285 } … … 300 300 gfits_define_bintable_column (&theader, "D", "X_CENT", "projection cell center pixel", "none", 1.0, 0.0); 301 301 gfits_define_bintable_column (&theader, "D", "Y_CENT", "projection cell center pixel", "none", 1.0, 0.0); 302 gfits_define_bintable_column (&theader, " J", "X_GRID", "skycell grid spacing", "none", 1.0, 0.0);303 gfits_define_bintable_column (&theader, " J", "Y_GRID", "skycell grid spacing", "none", 1.0, 0.0);302 gfits_define_bintable_column (&theader, "E", "X_GRID", "skycell grid spacing", "none", 1.0, 0.0); 303 gfits_define_bintable_column (&theader, "E", "Y_GRID", "skycell grid spacing", "none", 1.0, 0.0); 304 304 gfits_define_bintable_column (&theader, "D", "R_MIN", "RA limit (lower)", "none", 1.0, 0.0); 305 305 gfits_define_bintable_column (&theader, "D", "R_MAX", "RA limit (upper)", "none", 1.0, 0.0); … … 307 307 gfits_define_bintable_column (&theader, "D", "D_MAX", "DEC limit (upper)", "none", 1.0, 0.0); 308 308 gfits_define_bintable_column (&theader, "D", "SCALE", "pixel scale for projection cell", "none", 1.0, 0.0); 309 gfits_define_bintable_column (&theader, " J", "NX_SUB", "skycell subdivision in x", "none", 1.0, 0.0);310 gfits_define_bintable_column (&theader, " J", "NY_SUB", "skycell subdivision in y", "none", 1.0, 0.0);309 gfits_define_bintable_column (&theader, "E", "NX_SUB", "skycell subdivision in x", "none", 1.0, 0.0); 310 gfits_define_bintable_column (&theader, "E", "NY_SUB", "skycell subdivision in y", "none", 1.0, 0.0); 311 311 gfits_define_bintable_column (&theader, "J", "TYPE", "type of tessellation", "none", 1.0, 0.0); 312 312 … … 330 330 double *Xo ; ALLOCATE (Xo , double, Nout); 331 331 double *Yo ; ALLOCATE (Yo , double, Nout); 332 int *dX ; ALLOCATE (dX , int,Nout);333 int *dY ; ALLOCATE (dY , int,Nout);332 float *dX ; ALLOCATE (dX , float, Nout); 333 float *dY ; ALLOCATE (dY , float, Nout); 334 334 double *Rmin ; ALLOCATE (Rmin , double, Nout); 335 335 double *Rmax ; ALLOCATE (Rmax , double, Nout); … … 337 337 double *Dmax ; ALLOCATE (Dmax , double, Nout); 338 338 double *dPix ; ALLOCATE (dPix , double, Nout); 339 int *NX_SUB ; ALLOCATE (NX_SUB, int,Nout);340 int *NY_SUB ; ALLOCATE (NY_SUB, int,Nout);339 float *NX_SUB ; ALLOCATE (NX_SUB, float, Nout); 340 float *NY_SUB ; ALLOCATE (NY_SUB, float, Nout); 341 341 int *TYPE ; ALLOCATE (TYPE, int, Nout); 342 342 … … 559 559 int xi = x / tess[myTess].tree->dX[zone][band]; 560 560 int yi = y / tess[myTess].tree->dY[zone][band]; 561 562 xi = MAX(MIN(xi, tess[myTess].tree->NX_SUB - 1.0), 0); 563 yi = MAX(MIN(yi, tess[myTess].tree->NY_SUB - 1.0), 0); 564 561 565 int N = xi + tess[myTess].tree->NX_SUB * yi; 562 566 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/cmf-ps1-v5-lensing.c
r37035 r37822 1 1 # include "dvo.h" 2 # define ST_SIZE 3 122 # define ST_SIZE 320 3 3 4 4 // this function is based on the one generated by the autocode of cmf-ps1-v5.d … … 100 100 SWAP_WORD (256); // E1_SH_PSF 101 101 SWAP_WORD (260); // E2_SH_PSF 102 SWAP_WORD (264); // MOMENTS_R1 103 SWAP_WORD (268); // MOMENTS_RH 104 SWAP_WORD (272); // KRON_FLUX 105 SWAP_WORD (276); // KRON_FLUX_ERR 106 SWAP_WORD (280); // KRON_FLUX_INNER 107 SWAP_WORD (284); // KRON_FLUX_OUTER 108 SWAP_WORD (288); // SKY_LIMIT_RAD 109 SWAP_WORD (292); // SKY_LIMIT_FLUX 110 SWAP_WORD (296); // SKY_LIMIT_SLOPE 111 SWAP_WORD (300); // FLAGS 112 SWAP_WORD (304); // FLAGS2 113 SWAP_BYTE (308); // N_FRAMES 114 SWAP_BYTE (310); // PADDING 102 103 SWAP_BYTE (264); // SRC_CHIP_NUM 104 SWAP_BYTE (266); // SRC_CHIP_X 105 SWAP_BYTE (268); // SRC_CHIP_Y 106 107 SWAP_WORD (272); // MOMENTS_R1 108 SWAP_WORD (276); // MOMENTS_RH 109 SWAP_WORD (280); // KRON_FLUX 110 SWAP_WORD (284); // KRON_FLUX_ERR 111 SWAP_WORD (288); // KRON_FLUX_INNER 112 SWAP_WORD (292); // KRON_FLUX_OUTER 113 SWAP_WORD (296); // SKY_LIMIT_RAD 114 SWAP_WORD (300); // SKY_LIMIT_FLUX 115 SWAP_WORD (304); // SKY_LIMIT_SLOPE 116 SWAP_WORD (308); // FLAGS 117 SWAP_WORD (312); // FLAGS2 118 SWAP_BYTE (316); // N_FRAMES 119 SWAP_BYTE (318); // PADDING 115 120 } 116 121 # endif … … 289 294 gfits_define_bintable_column (header, "E", "E1_SH_PSF", "lensing shear", "", 1.0, 0.0); 290 295 gfits_define_bintable_column (header, "E", "E2_SH_PSF", "lensing shear", "", 1.0, 0.0); 296 297 gfits_define_bintable_column (header, "I", "SRC_CHIP_NUM", "number of source chip for warp", "", 1.0, 0.0); 298 gfits_define_bintable_column (header, "I", "SRC_CHIP_X", "x-coord in source chip", "", 1.0, 0.0); 299 gfits_define_bintable_column (header, "I", "SRC_CHIP_Y", "y-coord in source chip", "", 1.0, 0.0); 300 gfits_define_bintable_column (header, "I", "PADDING3", "padding for 8byte records", "", 1.0, 0.0); 301 291 302 gfits_define_bintable_column (header, "E", "MOMENTS_R1", "first radial moment", "pixels", 1.0, 0.0); 292 303 gfits_define_bintable_column (header, "E", "MOMENTS_RH", "half radial moment", "pixels^1/2", 1.0, 0.0); … … 385 396 gfits_define_bintable_column (header, "E", "E1_SH_PSF", "lensing shear", "", 1.0, 0.0); 386 397 gfits_define_bintable_column (header, "E", "E2_SH_PSF", "lensing shear", "", 1.0, 0.0); 398 399 gfits_define_bintable_column (header, "I", "SRC_CHIP_NUM", "number of source chip for warp", "", 1.0, 0.0); 400 gfits_define_bintable_column (header, "I", "SRC_CHIP_X", "x-coord in source chip", "", 1.0, 0.0); 401 gfits_define_bintable_column (header, "I", "SRC_CHIP_Y", "y-coord in source chip", "", 1.0, 0.0); 402 gfits_define_bintable_column (header, "I", "PADDING3", "padding for 8byte records", "", 1.0, 0.0); 403 387 404 gfits_define_bintable_column (header, "E", "MOMENTS_R1", "first radial moment", "pixels", 1.0, 0.0); 388 405 gfits_define_bintable_column (header, "E", "MOMENTS_RH", "half radial moment", "pixels^1/2", 1.0, 0.0); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/cmf-ps1-v5.c
r37035 r37822 1 1 # include "dvo.h" 2 # define ST_SIZE 232 2 3 3 4 // this function is based on the one generated by the autocode of cmf-ps1-v5.d … … 7 8 unsigned char tmp; 8 9 9 if (size != 232) {10 fprintf (stderr, "WARNING: mismatch in data types CMF_PS1_V5: "OFF_T_FMT" vs %d\n", size, 232);10 if (size != ST_SIZE) { 11 fprintf (stderr, "WARNING: mismatch in data types CMF_PS1_V5: "OFF_T_FMT" vs %d\n", size, ST_SIZE); 11 12 return (FALSE); 12 13 } … … 33 34 # ifdef BYTE_SWAP 34 35 byte = (unsigned char *) data; 35 for (i = 0; i < nitems; i++, byte += 232) {36 for (i = 0; i < nitems; i++, byte += ST_SIZE) { 36 37 /** BYTE SWAP **/ 37 38 SWAP_WORD (0); // IPP_IDET … … 176 177 177 178 Ncols = ftable[0].header[0].Naxis[0]; 178 if (Ncols != 232) {179 fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, 232);179 if (Ncols != ST_SIZE) { 180 fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, ST_SIZE); 180 181 return NULL; 181 182 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/coord_systems.c
r31635 r37822 1 1 # include "dvo.h" 2 # include "libdvo_astro.h"3 2 4 3 CoordTransform *InitTransform (CoordTransformSystem input, CoordTransformSystem output) { … … 40 39 // \delta^p_J = +27d 07' 41.7087" 41 40 // \theta_J = 122.93192526 deg 41 42 42 // these differ from the above at the several milliarcsec level 43 44 43 45 44 // These values were used in the past, but transform to/from B1950.0 … … 47 46 // transform->Xo = 282.25*RAD_DEG; 48 47 // transform->xo = 33.00; 48 49 break; 50 case COORD_GALACTIC_REID_2004: 51 52 // J2000 FK5 transformation from Reid et al 2004, ApJ 616, 872 53 transform->phi = (27.128336111 - 90.0)*RAD_DEG; // +27d 07' 42.01" (J2000) 54 transform->Xo = (192.859508333 + 90.0)*RAD_DEG; // 12h 51m 26.282s (J2000) 55 transform->xo = 32.932; 56 57 // comments from LSD code (lsd/builtins/misc.py, Mario Juric) 58 // # Appendix of Reid et al. (http://adsabs.harvard.edu/cgi-bin/bib_query?2004ApJ...616..872R) 59 // # This convention is also used by LAMBDA/WMAP (http://lambda.gsfc.nasa.gov/toolbox/tb_coordconv.cfm) 60 61 // _angp = np.radians(192.859508333) # 12h 51m 26.282s (J2000) 62 // _dngp = np.radians(27.128336111) # +27d 07' 42.01" (J2000) 63 // _l0 = np.radians(32.932) 49 64 50 65 break; … … 87 102 switch (output) { 88 103 case COORD_CELESTIAL: 89 // J2000 transformation from Liu et al 2011 ( )104 // J2000 transformation from Liu et al 2011 (A&A 526, A16) 90 105 transform->phi = 62.8717488056*RAD_DEG; 91 106 transform->Xo = 32.9319185700*RAD_DEG; 92 107 transform->xo = 282.8594812080; 108 109 // These values were used in the past, but transform to/from B1950.0 110 // transform->phi = 62.60*RAD_DEG; 111 // transform->Xo = 33.00*RAD_DEG; 112 // transform->xo = 282.25; 113 break; 114 case COORD_GALACTIC: 115 transform->phi = 0.0; 116 transform->Xo = 0.0; 117 transform->xo = 0.0; 118 transform->isIdentity = TRUE; 119 break; 120 case COORD_ECLIPTIC: 121 return NULL; 122 default: 123 abort(); 124 } 125 break; 126 case COORD_GALACTIC_REID_2004: 127 switch (output) { 128 case COORD_CELESTIAL: 129 // J2000 FK5 transformation from Reid et al 2004, ApJ 616, 872 130 transform->phi = (90.0 - 27.128336111)*RAD_DEG; // +27d 07' 42.01" (J2000) 131 transform->Xo = 32.932*RAD_DEG; 132 transform->xo = (192.859508333 + 90.0); // 12h 51m 26.282s (J2000) 93 133 94 134 // These values were used in the past, but transform to/from B1950.0 … … 144 184 Y *= RAD_DEG; 145 185 186 double cosY = cos(Y); 187 double sinY = sin(Y); 188 189 double cosX = cos(X); 190 double sinX = sin(X); 191 146 192 // recast with constants extracted: 147 sin_y = cos (Y)*sin(X)*transform->sin_phi_cos_Xo - cos(Y)*cos(X)*transform->sin_phi_sin_Xo + sin(Y)*transform->cos_phi;193 sin_y = cosY*sinX*transform->sin_phi_cos_Xo - cosY*cosX*transform->sin_phi_sin_Xo + sinY*transform->cos_phi; 148 194 cos_y = sqrt (1 - sin_y*sin_y); 149 195 150 sin_x = cos (Y)*sin(X)*transform->cos_phi_cos_Xo - cos(Y)*cos(X)*transform->cos_phi_sin_Xo - sin(Y)*transform->sin_phi;151 cos_x = cos (Y)*cos(X)*transform->cos_Xo + cos(Y)*sin(X)*transform->sin_Xo;196 sin_x = cosY*sinX*transform->cos_phi_cos_Xo - cosY*cosX*transform->cos_phi_sin_Xo - sinY*transform->sin_phi; 197 cos_x = cosY*cosX*transform->cos_Xo + cosY*sinX*transform->sin_Xo; 152 198 153 199 // atan2 returns -pi : +pi -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/coordops.c
r36490 r37822 3 3 /* note that Coords.ctype carries the DEC (ctype2) value */ 4 4 5 static Coords mosaic; 6 static int gotMosaic = FALSE; 7 8 void RegisterMosaic (Coords *coords) { 9 mosaic = *coords; 10 gotMosaic = TRUE; 11 } 12 13 int isRegisteredMosaic () { 14 return (gotMosaic); 15 } 16 17 int GetMosaicCoords (Coords *coords) { 18 *coords = mosaic; 19 return (TRUE); 20 } 5 // default coordinates have unit scale and no rotation 6 void InitCoords (Coords *coords, char *projection) { 7 coords->crval1 = 0.0; 8 coords->crval2 = 0.0; 9 coords->crpix1 = 0.0; 10 coords->crpix2 = 0.0; 11 12 coords->cdelt1 = 1.0; 13 coords->cdelt2 = 1.0; 14 15 coords->pc1_1 = 1.0; // EW is flipped relative to sky parity (dRA/dX > 0) 16 coords->pc2_2 = 1.0; 17 coords->pc2_1 = 0.0; 18 coords->pc1_2 = 0.0; 19 20 coords->Npolyterms = 1; 21 coords->mosaic = NULL; 22 coords->offsetMap = NULL; 23 24 memset (coords->polyterms, 0, 7*2*sizeof(float)); 25 26 if (projection) { 27 strcpy (coords->ctype, projection); 28 } else { 29 strcpy (coords->ctype, "NONE"); 30 } 31 } 32 33 // default coordinates have unit scale and no rotation 34 void CopyCoords (Coords *tgt, Coords *src) { 35 tgt->crval1 = src->crval1; 36 tgt->crval2 = src->crval2; 37 tgt->crpix1 = src->crpix1; 38 tgt->crpix2 = src->crpix2; 39 tgt->cdelt1 = src->cdelt1; 40 tgt->cdelt2 = src->cdelt2; 41 tgt->pc1_1 = src->pc1_1; 42 tgt->pc2_2 = src->pc2_2; 43 tgt->pc2_1 = src->pc2_1; 44 tgt->pc1_2 = src->pc1_2; 45 tgt->Npolyterms = src->Npolyterms; 46 tgt->mosaic = src->mosaic; // pointer to another structure 47 tgt->offsetMap = src->offsetMap; // pointer to another structure 48 49 memcpy (tgt->polyterms, src->polyterms, 7*2*sizeof(float)); 50 strcpy (tgt->ctype, src->ctype); 51 } 21 52 22 53 int XY_to_LM (double *L, double *M, double x, double y, Coords *coords) { … … 28 59 proj = GetProjection (coords[0].ctype); 29 60 mode = GetProjectionMode (proj); 61 62 // if we have an image map, it should be applied to the pixel coordinates 63 // before anything else is done. It is easier to invert the map if it is 64 // of the form (dX,dY) = f(X,Y), then if (dL,dM) = f(X,Y). 65 if (coords[0].Npolyterms == -1) { 66 myAssert (coords[0].offsetMap, "offsetMap is requested by not defined"); 67 float dX = AstromOffsetMapValue (coords->offsetMap, x, y, TRUE); 68 float dY = AstromOffsetMapValue (coords->offsetMap, x, y, FALSE); 69 if (isnan(dX)) dX = 0.0; 70 if (isnan(dY)) dY = 0.0; 71 x += dX; 72 y += dY; 73 } 30 74 31 75 /** convert pixel coordinates to cartesian system **/ … … 78 122 /* mosaic astrometry : WRP is chip astrometry; apply mosaic (DIS) term */ 79 123 if (proj == PROJ_WRP) { 80 if (!gotMosaic) return (FALSE); 81 XY_to_RD (ra, dec, L, M, &mosaic); 124 if (!coords->mosaic) { 125 myAbort ("missing mosaic element"); 126 return (FALSE); 127 } 128 XY_to_RD (ra, dec, L, M, coords->mosaic); 82 129 } 83 130 return (TRUE); … … 149 196 *dec = DEG_RAD*delta; 150 197 151 *ra = ohana_normalize_angle (*ra);198 // *ra = ohana_normalize_angle (*ra); 152 199 153 200 return (TRUE); … … 182 229 *dec = delta + coords[0].crval2; 183 230 184 *ra = ohana_normalize_angle (*ra);231 // *ra = ohana_normalize_angle (*ra); 185 232 186 233 return (TRUE); … … 208 255 if (mode == PROJ_MODE_CARTESIAN) { 209 256 if (proj == PROJ_WRP) { 210 if (!gotMosaic) return (FALSE); 211 RD_to_XY (L, M, ra, dec, &mosaic); 257 if (!coords->mosaic) { 258 myAbort ("missing mosaic element"); 259 return (FALSE); 260 } 261 RD_to_XY (L, M, ra, dec, coords->mosaic); 212 262 return (TRUE); 213 263 } … … 381 431 *y = Yo / coords[0].cdelt2 + coords[0].crpix2; 382 432 433 // if we have an image map, it should be applied to the pixel coordinates 434 // after anything else is done. It is easier to invert the map if it is 435 // of the form (dX,dY) = f(X,Y), then if (dL,dM) = f(X,Y). 436 if (coords[0].Npolyterms == -1) { 437 myAssert (coords[0].offsetMap, "offsetMap is requested by not defined"); 438 439 double xraw = *x; 440 double yraw = *y; 441 442 double dXo = 0.0; 443 double dYo = 0.0; 444 445 int i; 446 for (i = 0; i < 4; i++) { 447 double dX = AstromOffsetMapValue (coords->offsetMap, xraw, yraw, TRUE); 448 double dY = AstromOffsetMapValue (coords->offsetMap, xraw, yraw, FALSE); 449 450 if (isnan(dX)) dX = 0.0; 451 if (isnan(dY)) dY = 0.0; 452 453 dX -= dXo; 454 dY -= dYo; 455 456 xraw -= dX; 457 yraw -= dY; 458 459 dXo += dX; 460 dYo += dY; 461 } 462 463 *x = xraw; 464 *y = yraw; 465 466 // I need to iterate since the position at which I have first made the correction is 467 // not the true position. but if dX,dY is small and the gradient of dX,dY is also 468 // small, then even a single pass gets us close. 469 470 // XXX test this and use a while (hypot(dX,dY) > XXX) condition 471 } 383 472 return (TRUE); 384 473 } … … 449 538 450 539 rotate = 0.0; 451 coords[0].crval1 = coords[0].crpix1 = coords[0].cdelt1 = 0.0; 452 coords[0].crval2 = coords[0].crpix2 = coords[0].cdelt2 = 0.0; 453 coords[0].pc1_1 = coords[0].pc2_2 = 1.0; 454 coords[0].pc2_1 = coords[0].pc1_2 = 0.0; 455 coords[0].Npolyterms = 1; 456 strcpy (coords[0].ctype, "NONE"); 540 541 InitCoords (coords, NULL); 457 542 458 543 mode = COORD_TYPE_NONE; … … 595 680 596 681 if (status) { 597 if (!gfits_scan (header, "EQUINOX", "%lf", 1, &equinox)) { 598 if (!gfits_scan (header, "EPOCH", "%lf", 1, &equinox)) { 599 equinox = 2000.0; 682 char equinoxString[80]; 683 int haveEquinox = gfits_scan (header, "EQUINOX", "%s", 1, equinoxString); 684 if (haveEquinox) { 685 // is the string a valid number (it is bad to interpret an error message as year 0.0) 686 char *endptr; 687 equinox = strtod (equinoxString, &endptr); 688 if (endptr == equinoxString) haveEquinox = FALSE; 689 } 690 if (!haveEquinox) { 691 haveEquinox = gfits_scan (header, "EPOCH", "%s", 1, equinoxString); 692 if (haveEquinox) { 693 // is the string a valid number (it is bad to interpret an error message as year 0.0) 694 char *endptr; 695 equinox = strtod (equinoxString, &endptr); 696 if (endptr == equinoxString) haveEquinox = FALSE; 600 697 } 698 } 699 if (!haveEquinox) { 700 equinox = 2000.0; 601 701 } 602 702 if (fabs (equinox - 2000.0) > 0.1) { … … 604 704 } 605 705 } 606 706 607 707 if (!status) { 608 708 // fprintf (stderr, "error getting all elements for coordinate mode %s\n", coords[0].ctype); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dbExtractAverages.c
r37035 r37822 50 50 51 51 /* return average.field based on the selection */ 52 dbValue dbExtractAverages (Average *average, SecFilt *secfilt, Measure *measure, dbField *field) {52 dbValue dbExtractAverages (Average *average, SecFilt *secfilt, Measure *measure, Lensobj *lensobj, StarPar *starpar, dbField *field) { 53 53 54 54 // off_t i; … … 161 161 value.Flt = average[0].stargal; 162 162 break; 163 case AVE_REF_COLOR :163 case AVE_REF_COLOR_BLUE: 164 164 value.Flt = average[0].refColorBlue; 165 break; 166 case AVE_REF_COLOR_RED: 167 value.Flt = average[0].refColorRed; 165 168 break; 166 169 … … 200 203 } 201 204 205 /* in some cases below we need a measurement which matches the requested photcode. 206 here is some sample code to find this. 207 208 for (i = 0; i < average[0].Nmeasure; i++) { 209 if (field->photcode->code != measure[i].photcode) continue; 210 value.Flt = measure[i].M; 211 break; 212 } 213 */ 214 202 215 switch (field->magOption) { 203 216 case MAG_OPTION_MAG: … … 207 220 break; 208 221 case MAG_LEVEL_REF: 209 // wh y is measureneeded here?222 // which measure is needed here? 210 223 // PhotRef (field->photcode, average, secfilt, measure, field->magClass, field->magSource); 211 224 break; … … 242 255 break; 243 256 case MAG_LEVEL_REF: 244 // value.Flt = PhotFluxRef (equiv, average, secfilt, measure, field->magClass, field->magSource); 257 // XXX which measure is needed here? 258 // value.Flt = PhotFluxRef (field->photcode, average, secfilt, measure, field->magClass, field->magSource); 245 259 break; 246 260 case MAG_LEVEL_INST: … … 258 272 case MAG_LEVEL_AVE: 259 273 case MAG_LEVEL_REF: 260 // value.Flt = PhotFluxAveErr (equiv, average, secfilt, field->magClass, field->magSource);274 value.Flt = PhotFluxAveErr (field->photcode, average, secfilt, field->magClass, field->magSource); 261 275 break; 262 276 case MAG_LEVEL_INST: … … 271 285 272 286 case MAG_OPTION_STDEV: 287 value.Flt = PhotMstdev (field->photcode, average, secfilt, field->magClass, field->magSource); 288 break; 273 289 case MAG_OPTION_CHISQ: 290 value.Flt = PhotXm (field->photcode, average, secfilt); 291 break; 274 292 case MAG_OPTION_MIN: 293 value.Flt = PhotMmin (field->photcode, average, secfilt); 294 break; 275 295 case MAG_OPTION_MAX: 296 value.Flt = PhotMmax (field->photcode, average, secfilt); 297 break; 276 298 case MAG_OPTION_NCODE: { 277 299 int Nsec = GetPhotcodeNsec (field->photcode->code); … … 281 303 } 282 304 case MAG_OPTION_NPHOT: { 283 int Nsec = GetPhotcodeNsec (field->photcode->code); 284 if (Nsec == -1) break; 285 value.Int = secfilt[Nsec].Nused; 305 value.Int = PhotNphot (field->photcode, average, secfilt, field->magClass, field->magSource); 286 306 break; 287 307 } 288 308 case MAG_OPTION_UC_DIST: 289 case MAG_OPTION_STACK_DET_ID: 290 value.Int = PhotStackID (field->photcode, average, secfilt); 309 value.Flt = PhotUCdist (field->photcode, average, secfilt); 291 310 break; 292 311 case MAG_OPTION_FLAGS: { … … 296 315 break; 297 316 } 317 318 // g:X11_SM_OBJ, etc, are only valid for average 319 case MAG_OPTION_X11_SM_OBJ: { value.Flt = LensValue_X11_sm_obj (field->photcode, lensobj); break; } 320 case MAG_OPTION_X12_SM_OBJ: { value.Flt = LensValue_X12_sm_obj (field->photcode, lensobj); break; } 321 case MAG_OPTION_X22_SM_OBJ: { value.Flt = LensValue_X22_sm_obj (field->photcode, lensobj); break; } 322 case MAG_OPTION_E1_SM_OBJ: { value.Flt = LensValue_E1_sm_obj (field->photcode, lensobj); break; } 323 case MAG_OPTION_E2_SM_OBJ: { value.Flt = LensValue_E2_sm_obj (field->photcode, lensobj); break; } 324 325 case MAG_OPTION_X11_SH_OBJ: { value.Flt = LensValue_X11_sh_obj (field->photcode, lensobj); break; } 326 case MAG_OPTION_X12_SH_OBJ: { value.Flt = LensValue_X12_sh_obj (field->photcode, lensobj); break; } 327 case MAG_OPTION_X22_SH_OBJ: { value.Flt = LensValue_X22_sh_obj (field->photcode, lensobj); break; } 328 case MAG_OPTION_E1_SH_OBJ: { value.Flt = LensValue_E1_sh_obj (field->photcode, lensobj); break; } 329 case MAG_OPTION_E2_SH_OBJ: { value.Flt = LensValue_E2_sh_obj (field->photcode, lensobj); break; } 330 331 case MAG_OPTION_X11_SM_PSF: { value.Flt = LensValue_X11_sm_psf (field->photcode, lensobj); break; } 332 case MAG_OPTION_X12_SM_PSF: { value.Flt = LensValue_X12_sm_psf (field->photcode, lensobj); break; } 333 case MAG_OPTION_X22_SM_PSF: { value.Flt = LensValue_X22_sm_psf (field->photcode, lensobj); break; } 334 case MAG_OPTION_E1_SM_PSF: { value.Flt = LensValue_E1_sm_psf (field->photcode, lensobj); break; } 335 case MAG_OPTION_E2_SM_PSF: { value.Flt = LensValue_E2_sm_psf (field->photcode, lensobj); break; } 336 337 case MAG_OPTION_X11_SH_PSF: { value.Flt = LensValue_X11_sh_psf (field->photcode, lensobj); break; } 338 case MAG_OPTION_X12_SH_PSF: { value.Flt = LensValue_X12_sh_psf (field->photcode, lensobj); break; } 339 case MAG_OPTION_X22_SH_PSF: { value.Flt = LensValue_X22_sh_psf (field->photcode, lensobj); break; } 340 case MAG_OPTION_E1_SH_PSF: { value.Flt = LensValue_E1_sh_psf (field->photcode, lensobj); break; } 341 case MAG_OPTION_E2_SH_PSF: { value.Flt = LensValue_E2_sh_psf (field->photcode, lensobj); break; } 342 298 343 case MAG_OPTION_NONE: 299 344 break; 300 } 301 break; 302 303 # if (0) 304 switch (field->magMode) { 305 case MAG_AVE: 306 value.Flt = PhotAve (field->photcode, average, secfilt); 307 break; 308 case MAG_REF: 309 value.Flt = PhotRef (field->photcode, average, secfilt, measure); 310 break; 311 case MAG_INST: 312 case MAG_CAT: 313 case MAG_SYS: 314 case MAG_REL: 315 case MAG_CAL: 316 // XXX need to code this correctly: this returns just the first matching value 317 value.Flt = NAN; 318 for (i = 0; i < average[0].Nmeasure; i++) { 319 if (field->photcode->code != measure[i].photcode) continue; 320 value.Flt = measure[i].M; 321 break; 322 } 323 break; 324 case MAG_CHISQ: 325 value.Flt = PhotXm (field->photcode, average, secfilt); 326 break; 327 case MAG_ERR: 328 if ((field->photcode->type == PHOT_REF) || (field->photcode->type == PHOT_DEP)) { 329 for (i = 0; i < average[0].Nmeasure; i++) { 330 if (field->photcode->code != measure[i].photcode) continue; 331 value.Flt = measure[i].dM; 332 break; 333 } 334 } else { 335 value.Flt = PhotAveErr (field->photcode, average, secfilt); 336 } 337 break; 338 case MAG_STDEV: 339 value.Flt = PhotMstdev (field->photcode, average, secfilt); 340 break; 341 case MAG_PHOT_FLAGS: 342 if ((field->photcode->type == PHOT_REF) || (field->photcode->type == PHOT_DEP)) { 343 for (i = 0; i < average[0].Nmeasure; i++) { 344 if (field->photcode->code != measure[i].photcode) continue; 345 value.Int = measure[i].photFlags; 346 break; 347 } 348 } else { 349 int Nsec = GetPhotcodeNsec (field->photcode->code); 350 if (Nsec == -1) break; 351 value.Int = secfilt[Nsec].flags; 352 } 353 break; 354 case MAG_NCODE: 355 // XXX push these into dvo_photcode_ops APIs 356 // XXX do I need to allow for conversion to equiv? 357 int Nsec = GetPhotcodeNsec (field->photcode->code); 358 if (Nsec == -1) break; 359 value.Int = secfilt[Nsec].Ncode; 360 break; 361 case MAG_NPHOT: 362 int Nsec = GetPhotcodeNsec (field->photcode->code); 363 if (Nsec == -1) break; 364 value.Int = secfilt[Nsec].Nused; 365 break; 366 367 case MAG_APER: 368 case MAG_APER_AVE: 369 value.Flt = PhotAperAve (field->photcode, average, secfilt); 370 break; 371 372 case MAG_APER_REF: 373 value.Flt = PhotAperRef (field->photcode, average, secfilt, measure); 374 break; 375 376 case MAG_KRON: 377 case MAG_KRON_AVE: 378 value.Flt = PhotKronAve (field->photcode, average, secfilt); 379 break; 380 381 case MAG_KRON_REF: 382 value.Flt = PhotKronRef (field->photcode, average, secfilt, measure); 383 break; 384 385 case MAG_KRON_ERR: 386 value.Flt = PhotKronAveErr (field->photcode, average, secfilt); 387 break; 388 389 case MAG_MIN: 390 value.Flt = PhotMmin (field->photcode, average, secfilt); 391 break; 392 case MAG_MAX: 393 value.Flt = PhotMmax (field->photcode, average, secfilt); 394 break; 395 case MAG_UC_DIST: 396 value.Flt = PhotUCdist (field->photcode, average, secfilt); 397 break; 398 case MAG_STACK_DET_ID: 399 value.Int = PhotStackID (field->photcode, average, secfilt); 400 break; 401 402 case MAG_FLUX_PSF: 403 value.Flt = PhotAveFluxPSF (field->photcode, average, secfilt); 404 break; 405 case MAG_FLUX_PSF_ERR: 406 value.Flt = PhotAvedFluxPSF (field->photcode, average, secfilt); 407 break; 408 case MAG_FLUX_KRON: 409 value.Flt = PhotAveFluxKron (field->photcode, average, secfilt); 410 break; 411 case MAG_FLUX_KRON_ERR: 412 value.Flt = PhotAvedFluxKron (field->photcode, average, secfilt); 413 break; 414 } 415 break; 416 case AVE_dMAG: 417 value.Flt = PhotAveErr (field->photcode, average, secfilt); 418 break; 419 case AVE_Xm: 420 value.Flt = PhotXm (field->photcode, average, secfilt); 421 break; 422 # endif 345 346 default: 347 break; 348 } 349 break; 350 351 case AVE_E_BV: { value.Flt = starpar->Ebv; break; } 352 case AVE_E_BV_ERR: { value.Flt = starpar->dEbv; break; } 353 case AVE_DISTANCE_MOD: { value.Flt = starpar->DistMag; break; } 354 case AVE_DISTANCE_MOD_ERR: { value.Flt = starpar->dDistMag; break; } 355 case AVE_M_R: { value.Flt = starpar->M_r; break; } 356 case AVE_M_R_ERR: { value.Flt = starpar->dM_r; break; } 357 case AVE_FEH: { value.Flt = starpar->FeH; break; } 358 case AVE_FEH_ERR: { value.Flt = starpar->dFeH; break; } 359 case AVE_URA_GALMODEL: { value.Flt = starpar->uRA; break; } 360 case AVE_UDEC_GALMODEL: { value.Flt = starpar->uDEC; break; } 361 case AVE_RA_GALMODEL: { value.Flt = starpar->R; break; } 362 case AVE_DEC_GALMODEL: { value.Flt = starpar->D; break; } 363 423 364 case AVE_TYPE: 424 365 break; 425 366 case AVE_TYPEFRAC: 426 367 break; 368 369 427 370 } 428 371 return (value); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dbExtractImages.c
r37035 r37822 59 59 time_t t; 60 60 dbValue value; 61 off_t Nmosaic;62 61 63 62 value.Flt = NAN; … … 68 67 case IMAGE_RA: 69 68 if (!haveCelestial) { 70 if (!FindMosaicForImage (image, Nimage, N)) return value;71 69 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 72 70 x = 0.0; … … 83 81 case IMAGE_DEC: 84 82 if (!haveCelestial) { 85 if (!FindMosaicForImage (image, Nimage, N)) return value;86 83 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 87 84 x = 0.0; … … 99 96 if (!haveGalactic) { 100 97 if (!haveCelestial) { 101 if (!FindMosaicForImage (image, Nimage, N)) return value;102 98 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 103 99 x = 0.0; … … 118 114 if (!haveGalactic) { 119 115 if (!haveCelestial) { 120 if (!FindMosaicForImage (image, Nimage, N)) return value;121 116 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 122 117 x = 0.0; … … 137 132 if (!haveEcliptic) { 138 133 if (!haveCelestial) { 139 if (!FindMosaicForImage (image, Nimage, N)) return value;140 134 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 141 135 x = 0.0; … … 156 150 if (!haveEcliptic) { 157 151 if (!haveCelestial) { 158 if (!FindMosaicForImage (image, Nimage, N)) return value;159 152 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 160 153 x = 0.0; … … 269 262 270 263 case IMAGE_FWHM_MEDIAN: 271 if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value; 272 Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1 273 value.Flt = (image[Nmosaic].fwhm_x + image[Nmosaic].fwhm_y) / 50.0; 264 if (!image[N].parent) return value; 265 value.Flt = (image[N].parent->fwhm_x + image[N].parent->fwhm_y) / 50.0; 274 266 break; 275 267 case IMAGE_FWHM_MAJ_MEDIAN: 276 if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value; 277 Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1 278 value.Flt = image[Nmosaic].fwhm_x / 25.0; 268 if (!image[N].parent) return value; 269 value.Flt = image[N].parent->fwhm_x / 25.0; 279 270 break; 280 271 case IMAGE_FWHM_MIN_MEDIAN: 281 if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value; 282 Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1 283 value.Flt = image[Nmosaic].fwhm_y / 25.0; 272 if (!image[N].parent) return value; 273 value.Flt = image[N].parent->fwhm_y / 25.0; 284 274 break; 285 275 … … 375 365 break; 376 366 377 case IMAGE_REF_COLOR :367 case IMAGE_REF_COLOR_BLUE: 378 368 value.Flt = image[N].refColorBlue; 369 break; 370 case IMAGE_REF_COLOR_RED: 371 value.Flt = image[N].refColorRed; 379 372 break; 380 373 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dbExtractMeasures.c
r37035 r37822 85 85 86 86 /* return measure.field based on the selection */ 87 dbValue dbExtractMeasures (Average *average, SecFilt *secfilt, Measure *measure, dbField *field) {87 dbValue dbExtractMeasures (Average *average, SecFilt *secfilt, Measure *measure, Lensing *lensing, StarPar *starpar, dbField *field) { 88 88 89 89 int Nsec; … … 248 248 case MAG_OPTION_NPHOT: 249 249 case MAG_OPTION_UC_DIST: 250 case MAG_OPTION_STACK_DET_ID:251 250 case MAG_OPTION_FLAGS: 251 case MAG_OPTION_X11_SM_OBJ: 252 case MAG_OPTION_X12_SM_OBJ: 253 case MAG_OPTION_X22_SM_OBJ: 254 case MAG_OPTION_E1_SM_OBJ: 255 case MAG_OPTION_E2_SM_OBJ: 256 case MAG_OPTION_X11_SH_OBJ: 257 case MAG_OPTION_X12_SH_OBJ: 258 case MAG_OPTION_X22_SH_OBJ: 259 case MAG_OPTION_E1_SH_OBJ: 260 case MAG_OPTION_E2_SH_OBJ: 261 case MAG_OPTION_X11_SM_PSF: 262 case MAG_OPTION_X12_SM_PSF: 263 case MAG_OPTION_X22_SM_PSF: 264 case MAG_OPTION_E1_SM_PSF: 265 case MAG_OPTION_E2_SM_PSF: 266 case MAG_OPTION_X11_SH_PSF: 267 case MAG_OPTION_X12_SH_PSF: 268 case MAG_OPTION_X22_SH_PSF: 269 case MAG_OPTION_E1_SH_PSF: 270 case MAG_OPTION_E2_SH_PSF: 271 case MAG_OPTION_F_AP_R5: 272 case MAG_OPTION_F_ERR_AP_R5: 273 case MAG_OPTION_F_STDEV_AP_R5: 274 case MAG_OPTION_F_FILL_AP_R5: 275 case MAG_OPTION_F_AP_R6: 276 case MAG_OPTION_F_ERR_AP_R6: 277 case MAG_OPTION_F_STDEV_AP_R6: 278 case MAG_OPTION_F_FILL_AP_R6: 279 252 280 case MAG_OPTION_NONE: 253 281 break; … … 475 503 break; 476 504 477 case MEAS_REF_COLOR :505 case MEAS_REF_COLOR_BLUE: 478 506 value.Flt = average[0].refColorBlue; 507 break; 508 case MEAS_REF_COLOR_RED: 509 value.Flt = average[0].refColorRed; 479 510 break; 480 511 … … 529 560 # endif 530 561 break; 531 case MEAS_XFIX: /* OK */ 532 value.Flt = measure[0].Xfix; 533 break; 534 case MEAS_YFIX: /* OK */ 535 value.Flt = measure[0].Yfix; 536 break; 537 case MEAS_XCCD_ERR: /* OK */ 538 value.Flt = FromShortPixels(measure[0].dXccd); 539 break; 540 case MEAS_YCCD_ERR: /* OK */ 541 value.Flt = FromShortPixels(measure[0].dYccd); 542 break; 543 case MEAS_POS_SYS_ERR: /* OK */ 544 value.Flt = FromShortPixels(measure[0].dRsys); 545 break; 562 case MEAS_XFIX: { value.Flt = measure[0].Xfix; break; } 563 case MEAS_YFIX: { value.Flt = measure[0].Yfix; break; } 564 case MEAS_XCCD_ERR: { value.Flt = FromShortPixels(measure[0].dXccd); break; } 565 case MEAS_YCCD_ERR: { value.Flt = FromShortPixels(measure[0].dYccd); break; } 566 case MEAS_POS_SYS_ERR: { value.Flt = FromShortPixels(measure[0].dRsys); } 567 568 case MEAS_XOFF_KH: { value.Flt = measure[0].XoffKH; break; } 569 case MEAS_YOFF_KH: { value.Flt = measure[0].YoffKH; break; } 570 case MEAS_XOFF_DCR: { value.Flt = measure[0].XoffDCR; break; } 571 case MEAS_YOFF_DCR: { value.Flt = measure[0].YoffDCR; break; } 572 case MEAS_ROFF_GAL: { value.Flt = measure[0].RoffGAL; break; } 573 case MEAS_DOFF_GAL: { value.Flt = measure[0].DoffGAL; break; } 546 574 547 575 case MEAS_XFIELD: /* offset relative to exposure center in ra,dec space */ … … 582 610 case MEAS_XMOSAIC: /* offset relative to exposure center in camera coords */ 583 611 if (!haveMosaicMeas) { 584 if (REMOTE_CLIENT) { 585 mosaic = MatchMosaicMetadata (measure[0].imageID); 586 } else { 587 // fprintf (stderr, "non-parallel Xmos broken\n"); 588 // abort(); 589 // mosaic = MatchMosaic (measure[0].t, measure[0].photcode); 590 mosaic = MatchMosaicMetadata (measure[0].imageID); 591 } 612 mosaic = MatchMosaicMetadata (measure[0].imageID); 592 613 if (mosaic == NULL) break; 593 614 double Rm = measure[0].R; … … 599 620 case MEAS_YMOSAIC: /* OK */ 600 621 if (!haveMosaicMeas) { 601 if (REMOTE_CLIENT) { 602 mosaic = MatchMosaicMetadata (measure[0].imageID); 603 } else { 604 // fprintf (stderr, "non-parallel Xmos broken\n"); 605 // abort(); 606 // mosaic = MatchMosaic (measure[0].t, measure[0].photcode); 607 mosaic = MatchMosaicMetadata (measure[0].imageID); 608 } 622 mosaic = MatchMosaicMetadata (measure[0].imageID); 609 623 if (mosaic == NULL) break; 610 624 double Rm = measure[0].R; … … 647 661 case MEAS_PSF_NPIX: /* OK */ 648 662 value.Int = measure[0].psfNpix; 649 break;650 case MEAS_CR_NSIGMA: /* OK */651 value.Flt = measure[0].crNsigma;652 663 break; 653 664 case MEAS_EXT_NSIGMA: /* OK */ … … 684 695 break; 685 696 686 case MEAS_MCAL_OFFSET: /* OK */ 687 value.Flt = measure[0].Mcal; 688 break; 697 case MEAS_MCAL_OFFSET: { value.Flt = measure[0].Mcal; break; } 689 698 690 699 case MEAS_FLAT: /* OK */ … … 721 730 } 722 731 break; 732 733 case MEAS_E_BV: { value.Flt = starpar->Ebv; break; } 734 case MEAS_E_BV_ERR: { value.Flt = starpar->dEbv; break; } 735 case MEAS_DISTANCE_MOD: { value.Flt = starpar->DistMag; break; } 736 case MEAS_DISTANCE_MOD_ERR: { value.Flt = starpar->dDistMag; break; } 737 case MEAS_M_R: { value.Flt = starpar->M_r; break; } 738 case MEAS_M_R_ERR: { value.Flt = starpar->dM_r; break; } 739 case MEAS_FEH: { value.Flt = starpar->FeH; break; } 740 case MEAS_FEH_ERR: { value.Flt = starpar->dFeH; break; } 741 case MEAS_URA_GALMODEL: { value.Flt = starpar->uRA; break; } 742 case MEAS_UDEC_GALMODEL: { value.Flt = starpar->uDEC; break; } 743 case MEAS_RA_GALMODEL: { value.Flt = starpar->R; break; } 744 case MEAS_DEC_GALMODEL: { value.Flt = starpar->D; break; } 723 745 724 746 // case MEAS_FLUX_PSF: /* OK */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dbFields.c
r37035 r37822 28 28 } 29 29 30 int dbFieldNeedMeasure (dbField *fields, int Nfields) { 31 int i; 32 for (i = 0; i < Nfields; i++) { 33 if (fields[i].photcode == NULL) continue; // non-measure fields do not have a photcode 34 if (fields[i].photcode[0].type == PHOT_REF) return TRUE; 35 if (fields[i].photcode[0].type == PHOT_DEP) return TRUE; 36 } 37 return FALSE; 38 } 39 40 int dbFieldNeedLensing (dbField *fields, int Nfields) { 41 int i; 42 for (i = 0; i < Nfields; i++) { 43 if (fields[i].ID == MEAS_X11_SM_OBJ) return TRUE; 44 if (fields[i].ID == MEAS_X12_SM_OBJ) return TRUE; 45 if (fields[i].ID == MEAS_X22_SM_OBJ) return TRUE; 46 if (fields[i].ID == MEAS_E1_SM_OBJ) return TRUE; 47 if (fields[i].ID == MEAS_E2_SM_OBJ) return TRUE; 48 if (fields[i].ID == MEAS_X11_SH_OBJ) return TRUE; 49 if (fields[i].ID == MEAS_X12_SH_OBJ) return TRUE; 50 if (fields[i].ID == MEAS_X22_SH_OBJ) return TRUE; 51 if (fields[i].ID == MEAS_E1_SH_OBJ) return TRUE; 52 if (fields[i].ID == MEAS_E2_SH_OBJ) return TRUE; 53 if (fields[i].ID == MEAS_X11_SM_PSF) return TRUE; 54 if (fields[i].ID == MEAS_X12_SM_PSF) return TRUE; 55 if (fields[i].ID == MEAS_X22_SM_PSF) return TRUE; 56 if (fields[i].ID == MEAS_E1_SM_PSF) return TRUE; 57 if (fields[i].ID == MEAS_E2_SM_PSF) return TRUE; 58 if (fields[i].ID == MEAS_X11_SH_PSF) return TRUE; 59 if (fields[i].ID == MEAS_X12_SH_PSF) return TRUE; 60 if (fields[i].ID == MEAS_X22_SH_PSF) return TRUE; 61 if (fields[i].ID == MEAS_E1_SH_PSF) return TRUE; 62 if (fields[i].ID == MEAS_E2_SH_PSF) return TRUE; 63 } 64 return FALSE; 65 } 66 67 int dbFieldNeedLensobj (dbField *fields, int Nfields) { 68 int i; 69 for (i = 0; i < Nfields; i++) { 70 if (fields[i].magOption == MAG_OPTION_NONE) continue; // non-measure fields do not have a photcode 71 72 if (fields[i].magOption == MAG_OPTION_X11_SM_OBJ) return TRUE; 73 if (fields[i].magOption == MAG_OPTION_X12_SM_OBJ) return TRUE; 74 if (fields[i].magOption == MAG_OPTION_X22_SM_OBJ) return TRUE; 75 if (fields[i].magOption == MAG_OPTION_E1_SM_OBJ) return TRUE; 76 if (fields[i].magOption == MAG_OPTION_E2_SM_OBJ) return TRUE; 77 if (fields[i].magOption == MAG_OPTION_X11_SH_OBJ) return TRUE; 78 if (fields[i].magOption == MAG_OPTION_X12_SH_OBJ) return TRUE; 79 if (fields[i].magOption == MAG_OPTION_X22_SH_OBJ) return TRUE; 80 if (fields[i].magOption == MAG_OPTION_E1_SH_OBJ) return TRUE; 81 if (fields[i].magOption == MAG_OPTION_E2_SH_OBJ) return TRUE; 82 if (fields[i].magOption == MAG_OPTION_X11_SM_PSF) return TRUE; 83 if (fields[i].magOption == MAG_OPTION_X12_SM_PSF) return TRUE; 84 if (fields[i].magOption == MAG_OPTION_X22_SM_PSF) return TRUE; 85 if (fields[i].magOption == MAG_OPTION_E1_SM_PSF) return TRUE; 86 if (fields[i].magOption == MAG_OPTION_E2_SM_PSF) return TRUE; 87 if (fields[i].magOption == MAG_OPTION_X11_SH_PSF) return TRUE; 88 if (fields[i].magOption == MAG_OPTION_X12_SH_PSF) return TRUE; 89 if (fields[i].magOption == MAG_OPTION_X22_SH_PSF) return TRUE; 90 if (fields[i].magOption == MAG_OPTION_E1_SH_PSF) return TRUE; 91 if (fields[i].magOption == MAG_OPTION_E2_SH_PSF) return TRUE; 92 } 93 return FALSE; 94 } 95 96 int dbFieldNeedStarpar (dbField *fields, int Nfields, int isAverage) { 97 int i; 98 for (i = 0; i < Nfields; i++) { 99 if (isAverage) { 100 if (fields[i].ID == AVE_E_BV) return TRUE; 101 if (fields[i].ID == AVE_E_BV_ERR) return TRUE; 102 if (fields[i].ID == AVE_DISTANCE_MOD) return TRUE; 103 if (fields[i].ID == AVE_DISTANCE_MOD_ERR) return TRUE; 104 if (fields[i].ID == AVE_M_R) return TRUE; 105 if (fields[i].ID == AVE_M_R_ERR) return TRUE; 106 if (fields[i].ID == AVE_FEH) return TRUE; 107 if (fields[i].ID == AVE_FEH_ERR) return TRUE; 108 if (fields[i].ID == AVE_URA_GALMODEL) return TRUE; 109 if (fields[i].ID == AVE_UDEC_GALMODEL) return TRUE; 110 if (fields[i].ID == AVE_RA_GALMODEL) return TRUE; 111 if (fields[i].ID == AVE_DEC_GALMODEL) return TRUE; 112 } else { 113 if (fields[i].ID == MEAS_E_BV) return TRUE; 114 if (fields[i].ID == MEAS_E_BV_ERR) return TRUE; 115 if (fields[i].ID == MEAS_DISTANCE_MOD) return TRUE; 116 if (fields[i].ID == MEAS_DISTANCE_MOD_ERR) return TRUE; 117 if (fields[i].ID == MEAS_M_R) return TRUE; 118 if (fields[i].ID == MEAS_M_R_ERR) return TRUE; 119 if (fields[i].ID == MEAS_FEH) return TRUE; 120 if (fields[i].ID == MEAS_FEH_ERR) return TRUE; 121 if (fields[i].ID == MEAS_URA_GALMODEL) return TRUE; 122 if (fields[i].ID == MEAS_UDEC_GALMODEL) return TRUE; 123 if (fields[i].ID == MEAS_RA_GALMODEL) return TRUE; 124 if (fields[i].ID == MEAS_DEC_GALMODEL) return TRUE; 125 } 126 } 127 return FALSE; 128 } 129 30 130 dvoMagSourceType GetMagSource (char *string) { 31 131 32 if (!strcasecmp (string, "chip")) return (MAG_SRC_CHP);33 if (!strcasecmp (string, "warp")) return (MAG_SRC_WRP);132 if (!strcasecmp (string, "chip")) return (MAG_SRC_CHP); 133 if (!strcasecmp (string, "warp")) return (MAG_SRC_WRP); 34 134 if (!strcasecmp (string, "stack")) return (MAG_SRC_STK); 35 135 … … 66 166 dvoMagOptionType GetMagOption (char *string) { 67 167 68 if (!strcasecmp (string, "mag")) return (MAG_OPTION_MAG); 69 if (!strcasecmp (string, "err")) return (MAG_OPTION_ERR); 70 if (!strcasecmp (string, "magerr")) return (MAG_OPTION_ERR); 71 if (!strcasecmp (string, "flux")) return (MAG_OPTION_FLUX); 72 if (!strcasecmp (string, "fluxerr")) return (MAG_OPTION_FLUX_ERR); 73 if (!strcasecmp (string, "stdev")) return (MAG_OPTION_STDEV); 74 if (!strcasecmp (string, "chisq")) return (MAG_OPTION_CHISQ); 75 if (!strcasecmp (string, "min")) return (MAG_OPTION_MIN); 76 if (!strcasecmp (string, "max")) return (MAG_OPTION_MAX); 77 if (!strcasecmp (string, "ncode")) return (MAG_OPTION_NCODE); 78 if (!strcasecmp (string, "nphot")) return (MAG_OPTION_NPHOT); 79 if (!strcasecmp (string, "uc_dist")) return (MAG_OPTION_UC_DIST); 80 if (!strcasecmp (string, "stack_det_id")) return (MAG_OPTION_STACK_DET_ID); 81 if (!strcasecmp (string, "flags")) return (MAG_OPTION_FLAGS); 168 if (!strcasecmp (string, "mag")) return MAG_OPTION_MAG; 169 if (!strcasecmp (string, "err")) return MAG_OPTION_ERR; 170 if (!strcasecmp (string, "magerr")) return MAG_OPTION_ERR; 171 if (!strcasecmp (string, "flux")) return MAG_OPTION_FLUX; 172 if (!strcasecmp (string, "fluxerr")) return MAG_OPTION_FLUX_ERR; 173 if (!strcasecmp (string, "stdev")) return MAG_OPTION_STDEV; 174 if (!strcasecmp (string, "chisq")) return MAG_OPTION_CHISQ; 175 if (!strcasecmp (string, "min")) return MAG_OPTION_MIN; 176 if (!strcasecmp (string, "max")) return MAG_OPTION_MAX; 177 if (!strcasecmp (string, "ncode")) return MAG_OPTION_NCODE; 178 if (!strcasecmp (string, "nphot")) return MAG_OPTION_NPHOT; 179 if (!strcasecmp (string, "uc_dist")) return MAG_OPTION_UC_DIST; 180 if (!strcasecmp (string, "flags")) return MAG_OPTION_FLAGS; 181 if (!strcasecmp (string, "X11_SM_OBJ")) return MAG_OPTION_X11_SM_OBJ; 182 if (!strcasecmp (string, "X12_SM_OBJ")) return MAG_OPTION_X12_SM_OBJ; 183 if (!strcasecmp (string, "X22_SM_OBJ")) return MAG_OPTION_X22_SM_OBJ; 184 if (!strcasecmp (string, "E1_SM_OBJ")) return MAG_OPTION_E1_SM_OBJ; 185 if (!strcasecmp (string, "E2_SM_OBJ")) return MAG_OPTION_E2_SM_OBJ; 186 if (!strcasecmp (string, "X11_SH_OBJ")) return MAG_OPTION_X11_SH_OBJ; 187 if (!strcasecmp (string, "X12_SH_OBJ")) return MAG_OPTION_X12_SH_OBJ; 188 if (!strcasecmp (string, "X22_SH_OBJ")) return MAG_OPTION_X22_SH_OBJ; 189 if (!strcasecmp (string, "E1_SH_OBJ")) return MAG_OPTION_E1_SH_OBJ; 190 if (!strcasecmp (string, "E2_SH_OBJ")) return MAG_OPTION_E2_SH_OBJ; 191 if (!strcasecmp (string, "X11_SM_PSF")) return MAG_OPTION_X11_SM_PSF; 192 if (!strcasecmp (string, "X12_SM_PSF")) return MAG_OPTION_X12_SM_PSF; 193 if (!strcasecmp (string, "X22_SM_PSF")) return MAG_OPTION_X22_SM_PSF; 194 if (!strcasecmp (string, "E1_SM_PSF")) return MAG_OPTION_E1_SM_PSF; 195 if (!strcasecmp (string, "E2_SM_PSF")) return MAG_OPTION_E2_SM_PSF; 196 if (!strcasecmp (string, "X11_SH_PSF")) return MAG_OPTION_X11_SH_PSF; 197 if (!strcasecmp (string, "X12_SH_PSF")) return MAG_OPTION_X12_SH_PSF; 198 if (!strcasecmp (string, "X22_SH_PSF")) return MAG_OPTION_X22_SH_PSF; 199 if (!strcasecmp (string, "E1_SH_PSF")) return MAG_OPTION_E1_SH_PSF; 200 if (!strcasecmp (string, "E2_SH_PSF")) return MAG_OPTION_E2_SH_PSF; 201 // if (!strcasecmp (string, "F_AP_R5")) return MAG_OPTION_F_AP_R5; 202 // if (!strcasecmp (string, "F_ERR_AP_R5")) return MAG_OPTION_F_ERR_AP_R5; 203 // if (!strcasecmp (string, "F_STDEV_AP_R5")) return MAG_OPTION_F_STDEV_AP_R5; 204 // if (!strcasecmp (string, "F_FILL_AP_R5")) return MAG_OPTION_F_FILL_AP_R5; 205 // if (!strcasecmp (string, "F_AP_R6")) return MAG_OPTION_F_AP_R6; 206 // if (!strcasecmp (string, "F_ERR_AP_R6")) return MAG_OPTION_F_ERR_AP_R6; 207 // if (!strcasecmp (string, "F_STDEV_AP_R6")) return MAG_OPTION_F_STDEV_AP_R6; 208 // if (!strcasecmp (string, "F_FILL_AP_R6")) return MAG_OPTION_F_FILL_AP_R6; 82 209 83 210 return MAG_OPTION_NONE; 84 211 } 85 86 # if (0)87 int GetMagMode (char *string) {88 89 // these all imply PSF mags:90 if (!strcasecmp (string, "inst")) return (MAG_INST);91 if (!strcasecmp (string, "cat")) return (MAG_CAT);92 if (!strcasecmp (string, "sys")) return (MAG_SYS);93 if (!strcasecmp (string, "rel")) return (MAG_REL);94 if (!strcasecmp (string, "cal")) return (MAG_CAL);95 if (!strcasecmp (string, "ave")) return (MAG_AVE);96 if (!strcasecmp (string, "ref")) return (MAG_REF);97 if (!strcasecmp (string, "err")) return (MAG_ERR);98 if (!strcasecmp (string, "aveerr")) return (MAG_AVE_ERR);99 100 // these are explicit PSF mags:101 if (!strcasecmp (string, "psf_inst")) return (MAG_INST);102 if (!strcasecmp (string, "psf_cat")) return (MAG_CAT);103 if (!strcasecmp (string, "psf_sys")) return (MAG_SYS);104 if (!strcasecmp (string, "psf_rel")) return (MAG_REL);105 if (!strcasecmp (string, "psf_cal")) return (MAG_CAL);106 if (!strcasecmp (string, "psf_ave")) return (MAG_AVE);107 if (!strcasecmp (string, "psf_ref")) return (MAG_REF);108 if (!strcasecmp (string, "psf_err")) return (MAG_ERR);109 if (!strcasecmp (string, "psf_aveerr")) return (MAG_AVE_ERR);110 111 // these are aper mags:112 if (!strcasecmp (string, "ap")) return (MAG_APER);113 if (!strcasecmp (string, "aper")) return (MAG_APER);114 if (!strcasecmp (string, "aperinst")) return (MAG_APER_INST);115 if (!strcasecmp (string, "aper_inst")) return (MAG_APER_INST);116 if (!strcasecmp (string, "aper_cat")) return (MAG_APER_CAT);117 if (!strcasecmp (string, "aper_sys")) return (MAG_APER_SYS);118 if (!strcasecmp (string, "aper_rel")) return (MAG_APER_REL);119 if (!strcasecmp (string, "aper_cal")) return (MAG_APER_CAL);120 if (!strcasecmp (string, "aper_ave")) return (MAG_APER_AVE);121 if (!strcasecmp (string, "aper_ref")) return (MAG_APER_REF);122 if (!strcasecmp (string, "aper_err")) return (MAG_APER_ERR);123 124 // these are kron mags:125 if (!strcasecmp (string, "kron")) return (MAG_KRON);126 if (!strcasecmp (string, "kron_inst")) return (MAG_KRON_INST);127 if (!strcasecmp (string, "kron_cat")) return (MAG_KRON_CAT);128 if (!strcasecmp (string, "kron_sys")) return (MAG_KRON_SYS);129 if (!strcasecmp (string, "kron_rel")) return (MAG_KRON_REL);130 if (!strcasecmp (string, "kron_cal")) return (MAG_KRON_CAL);131 if (!strcasecmp (string, "kron_ave")) return (MAG_KRON_AVE);132 if (!strcasecmp (string, "kron_ref")) return (MAG_KRON_REF);133 if (!strcasecmp (string, "kron_err")) return (MAG_KRON_ERR);134 if (!strcasecmp (string, "kroninst")) return (MAG_KRON_INST);135 if (!strcasecmp (string, "kronerr")) return (MAG_KRON_ERR);136 137 // other fields:138 if (!strcasecmp (string, "photflags")) return (MAG_PHOT_FLAGS);139 if (!strcasecmp (string, "flags")) return (MAG_PHOT_FLAGS);140 if (!strcasecmp (string, "chisq")) return (MAG_CHISQ);141 if (!strcasecmp (string, "ncode")) return (MAG_NCODE);142 if (!strcasecmp (string, "nphot")) return (MAG_NPHOT);143 if (!strcasecmp (string, "stdev")) return (MAG_STDEV);144 if (!strcasecmp (string, "min")) return (MAG_MIN);145 if (!strcasecmp (string, "max")) return (MAG_MAX);146 if (!strcasecmp (string, "ucdist")) return (MAG_UC_DIST);147 if (!strcasecmp (string, "stackDetectID")) return (MAG_STACK_DET_ID);148 if (!strcasecmp (string, "fluxpsf")) return (MAG_FLUX_PSF);149 if (!strcasecmp (string, "fluxpsferr")) return (MAG_FLUX_PSF_ERR);150 if (!strcasecmp (string, "fluxkron")) return (MAG_FLUX_KRON);151 if (!strcasecmp (string, "fluxkronerr")) return (MAG_FLUX_KRON_ERR);152 return (MAG_NONE);153 }154 # endif155 212 156 213 // field may be of the form mag:psf:inst:wrp. except for the first subword, … … 287 344 fprintf (stderr, "ERROR: unknown mag/photocode argument %s\n", word); 288 345 free (word); 346 return FALSE; 289 347 } 290 348 … … 296 354 297 355 switch (field->magOption) { 298 case MAG_OPTION_STACK_DET_ID:299 356 case MAG_OPTION_NCODE: 300 357 case MAG_OPTION_NPHOT: … … 417 474 if (!strcasecmp (fieldName, "XFIX")) ESCAPE (MEAS_XFIX, OPIHI_FLT); 418 475 if (!strcasecmp (fieldName, "YFIX")) ESCAPE (MEAS_YFIX, OPIHI_FLT); 476 if (!strcasecmp (fieldName, "XOFF_KH")) ESCAPE (MEAS_XOFF_KH, OPIHI_FLT); 477 if (!strcasecmp (fieldName, "YOFF_KH")) ESCAPE (MEAS_YOFF_KH, OPIHI_FLT); 478 if (!strcasecmp (fieldName, "XOFF_DCR")) ESCAPE (MEAS_XOFF_DCR, OPIHI_FLT); 479 if (!strcasecmp (fieldName, "YOFF_DCR")) ESCAPE (MEAS_YOFF_DCR, OPIHI_FLT); 480 if (!strcasecmp (fieldName, "ROFF_GAL")) ESCAPE (MEAS_ROFF_GAL, OPIHI_FLT); 481 if (!strcasecmp (fieldName, "DOFF_GAL")) ESCAPE (MEAS_DOFF_GAL, OPIHI_FLT); 419 482 if (!strcasecmp (fieldName, "POS_SYS_ERR")) ESCAPE (MEAS_POS_SYS_ERR, OPIHI_FLT); 420 483 if (!strcasecmp (fieldName, "XFIELD")) ESCAPE (MEAS_XFIELD, OPIHI_FLT); … … 444 507 if (!strcasecmp (fieldName, "FLAT")) ESCAPE (MEAS_FLAT, OPIHI_FLT); 445 508 if (!strcasecmp (fieldName, "CENTER_OFFSET")) ESCAPE (MEAS_CENTER_OFFSET, OPIHI_FLT); 446 // if (!strcasecmp (fieldName, "FLUX")) ESCAPE (MEAS_FLUX_PSF, OPIHI_FLT); 509 510 // individual lensing measurements are not grouped by photcode: 511 if (!strcasecmp (fieldName, "X11_SM_OBJ")) ESCAPE (MEAS_X11_SM_OBJ, OPIHI_FLT); 512 if (!strcasecmp (fieldName, "X12_SM_OBJ")) ESCAPE (MEAS_X12_SM_OBJ, OPIHI_FLT); 513 if (!strcasecmp (fieldName, "X22_SM_OBJ")) ESCAPE (MEAS_X22_SM_OBJ, OPIHI_FLT); 514 if (!strcasecmp (fieldName, "E1_SM_OBJ")) ESCAPE (MEAS_E1_SM_OBJ, OPIHI_FLT); 515 if (!strcasecmp (fieldName, "E2_SM_OBJ")) ESCAPE (MEAS_E2_SM_OBJ, OPIHI_FLT); 516 if (!strcasecmp (fieldName, "X11_SH_OBJ")) ESCAPE (MEAS_X11_SH_OBJ, OPIHI_FLT); 517 if (!strcasecmp (fieldName, "X12_SH_OBJ")) ESCAPE (MEAS_X12_SH_OBJ, OPIHI_FLT); 518 if (!strcasecmp (fieldName, "X22_SH_OBJ")) ESCAPE (MEAS_X22_SH_OBJ, OPIHI_FLT); 519 if (!strcasecmp (fieldName, "E1_SH_OBJ")) ESCAPE (MEAS_E1_SH_OBJ, OPIHI_FLT); 520 if (!strcasecmp (fieldName, "E2_SH_OBJ")) ESCAPE (MEAS_E2_SH_OBJ, OPIHI_FLT); 521 if (!strcasecmp (fieldName, "X11_SM_PSF")) ESCAPE (MEAS_X11_SM_PSF, OPIHI_FLT); 522 if (!strcasecmp (fieldName, "X12_SM_PSF")) ESCAPE (MEAS_X12_SM_PSF, OPIHI_FLT); 523 if (!strcasecmp (fieldName, "X22_SM_PSF")) ESCAPE (MEAS_X22_SM_PSF, OPIHI_FLT); 524 if (!strcasecmp (fieldName, "E1_SM_PSF")) ESCAPE (MEAS_E1_SM_PSF, OPIHI_FLT); 525 if (!strcasecmp (fieldName, "E2_SM_PSF")) ESCAPE (MEAS_E2_SM_PSF, OPIHI_FLT); 526 if (!strcasecmp (fieldName, "X11_SH_PSF")) ESCAPE (MEAS_X11_SH_PSF, OPIHI_FLT); 527 if (!strcasecmp (fieldName, "X12_SH_PSF")) ESCAPE (MEAS_X12_SH_PSF, OPIHI_FLT); 528 if (!strcasecmp (fieldName, "X22_SH_PSF")) ESCAPE (MEAS_X22_SH_PSF, OPIHI_FLT); 529 if (!strcasecmp (fieldName, "E1_SH_PSF")) ESCAPE (MEAS_E1_SH_PSF, OPIHI_FLT); 530 if (!strcasecmp (fieldName, "E2_SH_PSF")) ESCAPE (MEAS_E2_SH_PSF, OPIHI_FLT); 531 532 if (!strcasecmp (fieldName, "E_BV")) ESCAPE (MEAS_E_BV , OPIHI_FLT); 533 if (!strcasecmp (fieldName, "E_BV_ERR")) ESCAPE (MEAS_E_BV_ERR , OPIHI_FLT); 534 if (!strcasecmp (fieldName, "DISTANCE_MOD")) ESCAPE (MEAS_DISTANCE_MOD , OPIHI_FLT); 535 if (!strcasecmp (fieldName, "DISTANCE_MOD_ERR")) ESCAPE (MEAS_DISTANCE_MOD_ERR, OPIHI_FLT); 536 if (!strcasecmp (fieldName, "D_M")) ESCAPE (MEAS_DISTANCE_MOD , OPIHI_FLT); 537 if (!strcasecmp (fieldName, "D_M_ERR")) ESCAPE (MEAS_DISTANCE_MOD_ERR, OPIHI_FLT); 538 if (!strcasecmp (fieldName, "M_R")) ESCAPE (MEAS_M_R , OPIHI_FLT); 539 if (!strcasecmp (fieldName, "M_R_ERR")) ESCAPE (MEAS_M_R_ERR , OPIHI_FLT); 540 if (!strcasecmp (fieldName, "FEH")) ESCAPE (MEAS_FEH , OPIHI_FLT); 541 if (!strcasecmp (fieldName, "FEH_ERR")) ESCAPE (MEAS_FEH_ERR , OPIHI_FLT); 542 if (!strcasecmp (fieldName, "URA_GALMODEL")) ESCAPE (MEAS_URA_GALMODEL , OPIHI_FLT); 543 if (!strcasecmp (fieldName, "UDEC_GALMODEL")) ESCAPE (MEAS_UDEC_GALMODEL , OPIHI_FLT); 544 if (!strcasecmp (fieldName, "RA_GALMODEL")) ESCAPE (MEAS_RA_GALMODEL , OPIHI_FLT); 545 if (!strcasecmp (fieldName, "DEC_GALMODEL")) ESCAPE (MEAS_DEC_GALMODEL , OPIHI_FLT); 546 if (!strcasecmp (fieldName, "URA_GAL")) ESCAPE (MEAS_URA_GALMODEL , OPIHI_FLT); 547 if (!strcasecmp (fieldName, "UDEC_GAL")) ESCAPE (MEAS_UDEC_GALMODEL , OPIHI_FLT); 548 if (!strcasecmp (fieldName, "RA_GAL")) ESCAPE (MEAS_RA_GALMODEL , OPIHI_FLT); 549 if (!strcasecmp (fieldName, "DEC_GAL")) ESCAPE (MEAS_DEC_GALMODEL , OPIHI_FLT); 550 551 // if (!strcasecmp (fieldName, "FLUX")) ESCAPE (MEAS_FLUX_PSF, OPIHI_FLT); 447 552 // if (!strcasecmp (fieldName, "FLUX_ERR")) ESCAPE (MEAS_FLUX_PSF_ERR, OPIHI_FLT); 448 553 // if (!strcasecmp (fieldName, "FLUX_PSF")) ESCAPE (MEAS_FLUX_PSF, OPIHI_FLT); … … 450 555 // if (!strcasecmp (fieldName, "FLUX_KRON")) ESCAPE (MEAS_FLUX_KRON, OPIHI_FLT); 451 556 // if (!strcasecmp (fieldName, "FLUX_KRON_ERR")) ESCAPE (MEAS_FLUX_KRON_ERR, OPIHI_FLT); 452 if (!strcasecmp (fieldName, "REF_COLOR")) ESCAPE (MEAS_REF_COLOR, OPIHI_FLT); 557 if (!strcasecmp (fieldName, "REF_COLOR_BLUE")) ESCAPE (MEAS_REF_COLOR_BLUE, OPIHI_FLT); 558 if (!strcasecmp (fieldName, "REF_COLOR_RED")) ESCAPE (MEAS_REF_COLOR_RED, OPIHI_FLT); 453 559 454 560 // for words that don't parse, try a photcode … … 525 631 if (!strcasecmp (fieldName, "EXTID_HI")) ESCAPE (AVE_EXTID_HI, OPIHI_INT); 526 632 if (!strcasecmp (fieldName, "EXTID_LO")) ESCAPE (AVE_EXTID_LO, OPIHI_INT); 527 if (!strcasecmp (fieldName, "REF_COLOR")) ESCAPE (AVE_REF_COLOR, OPIHI_FLT); 633 if (!strcasecmp (fieldName, "REF_COLOR_BLUE")) ESCAPE (AVE_REF_COLOR_BLUE, OPIHI_FLT); 634 if (!strcasecmp (fieldName, "REF_COLOR_RED")) ESCAPE (AVE_REF_COLOR_RED, OPIHI_FLT); 635 636 if (!strcasecmp (fieldName, "E_BV")) ESCAPE (AVE_E_BV , OPIHI_FLT); 637 if (!strcasecmp (fieldName, "E_BV_ERR")) ESCAPE (AVE_E_BV_ERR , OPIHI_FLT); 638 if (!strcasecmp (fieldName, "DISTANCE_MOD")) ESCAPE (AVE_DISTANCE_MOD , OPIHI_FLT); 639 if (!strcasecmp (fieldName, "DISTANCE_MOD_ERR")) ESCAPE (AVE_DISTANCE_MOD_ERR, OPIHI_FLT); 640 if (!strcasecmp (fieldName, "M_R")) ESCAPE (AVE_M_R , OPIHI_FLT); 641 if (!strcasecmp (fieldName, "M_R_ERR")) ESCAPE (AVE_M_R_ERR , OPIHI_FLT); 642 if (!strcasecmp (fieldName, "FEH")) ESCAPE (AVE_FEH , OPIHI_FLT); 643 if (!strcasecmp (fieldName, "FEH_ERR")) ESCAPE (AVE_FEH_ERR , OPIHI_FLT); 644 if (!strcasecmp (fieldName, "URA_GALMODEL")) ESCAPE (AVE_URA_GALMODEL , OPIHI_FLT); 645 if (!strcasecmp (fieldName, "UDEC_GALMODEL")) ESCAPE (AVE_UDEC_GALMODEL , OPIHI_FLT); 646 if (!strcasecmp (fieldName, "RA_GALMODEL")) ESCAPE (AVE_RA_GALMODEL , OPIHI_FLT); 647 if (!strcasecmp (fieldName, "DEC_GALMODEL")) ESCAPE (AVE_DEC_GALMODEL , OPIHI_FLT); 648 528 649 529 650 // check for code:mode in photcode name … … 655 776 if (!strcasecmp (fieldName, "NLINK_PHOTOM")) ESCAPE (IMAGE_NLINK_PHOTOM, OPIHI_INT); 656 777 if (!strcasecmp (fieldName, "NLINK_ASTROM")) ESCAPE (IMAGE_NLINK_ASTROM, OPIHI_INT); 657 if (!strcasecmp (fieldName, "REF_COLOR")) ESCAPE (IMAGE_REF_COLOR, OPIHI_FLT); 778 if (!strcasecmp (fieldName, "REF_COLOR_BLUE")) ESCAPE (IMAGE_REF_COLOR_BLUE, OPIHI_FLT); 779 if (!strcasecmp (fieldName, "REF_COLOR_RED")) ESCAPE (IMAGE_REF_COLOR_RED, OPIHI_FLT); 658 780 659 781 // for words that don't parse, try a photcode -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_catalog.c
r37331 r37822 58 58 if (!strcasecmp (catformat, "PS1_V5")) return (DVO_FORMAT_PS1_V5); 59 59 if (!strcasecmp (catformat, "PS1_REF")) return (DVO_FORMAT_PS1_REF); 60 if (!strcasecmp (catformat, "PS1_SIM")) return (DVO_FORMAT_PS1_SIM); 60 61 return (DVO_FORMAT_UNDEF); 61 62 } … … 129 130 average->Nlensing = 0; 130 131 average->Nlensobj = 0; 132 average->Nstarpar = 0; 131 133 average->Nextend = 0; 132 134 … … 135 137 average->lensingOffset = -1; 136 138 average->lensobjOffset = -1; 139 average->starparOffset = -1; 137 140 average->extendOffset = -1; 138 average->paramsOffset = -1;139 141 140 142 average->refColorBlue = NAN; 141 143 average->refColorRed = NAN; 144 145 average->tessID = 0; 146 average->skycellID = 0; 147 average->projectionID = 0; 148 149 average->dummy = 0; 142 150 143 151 average->flags = 0; … … 173 181 secfilt->sMkron = NAN; 174 182 183 secfilt->psfQfMax = NAN; 184 secfilt->psfQfPerfMax = NAN; 185 175 186 secfilt->Mstdev = NAN; 176 187 secfilt->Mmin = NAN; … … 197 208 secfilt->dFapStk = NAN; 198 209 199 secfilt->stackDetectID = 0; 210 secfilt->Nstack = 0; 211 secfilt->NstackDet = 0; 212 213 secfilt->stackPrmryOff = -1; 214 secfilt->stackBestOff = -1; 200 215 201 216 secfilt->MpsfWrp = NAN; … … 217 232 secfilt->NusedKronWrp = 0; 218 233 secfilt->NusedApWrp = 0; 234 235 secfilt->Nwarp = 0; 236 secfilt->NwarpGood = 0; 219 237 220 238 secfilt->ubercalDist = 1000; … … 278 296 measure->psfNdof = 0; 279 297 measure->psfNpix = 0; 280 measure->crNsigma = NAN;281 298 measure->extNsigma = NAN; 282 299 … … 301 318 measure->dbFlags = 0; 302 319 measure->photFlags = 0; 320 measure->photFlags2= 0; 303 321 } 304 322 … … 422 440 423 441 // init all data, or just catalog data 442 void dvo_starpar_init (StarPar *starpar) { 443 starpar->R = NAN; 444 starpar->D = NAN; 445 starpar->galLat = NAN; 446 starpar->galLon = NAN; 447 starpar->Ebv = NAN; 448 starpar->dEbv = NAN; 449 starpar->DistMag = NAN; 450 starpar->dDistMag = NAN; 451 starpar->M_r = NAN; 452 starpar->dM_r = NAN; 453 starpar->FeH = NAN; 454 starpar->dFeH = NAN; 455 starpar->uRA = NAN; 456 starpar->uDEC = NAN; 457 starpar->averef = -1; 458 starpar->objID = -1; 459 starpar->catID = -1; 460 } 461 462 // init all data, or just catalog data 424 463 void dvo_catalog_init (Catalog *catalog, int complete) { 425 464 … … 447 486 catalog[0].lensobj = NULL; 448 487 488 catalog[0].starpar = NULL; 489 449 490 catalog[0].averageT = NULL; 450 491 catalog[0].measureT = NULL; … … 462 503 catalog[0].Nlensobj = 0; 463 504 505 catalog[0].Nstarpar = 0; 506 464 507 catalog[0].Naves_disk = 0; 465 508 catalog[0].Nmeas_disk = 0; … … 470 513 catalog[0].Nlensobj_disk = 0; 471 514 515 catalog[0].Nstarpar_disk = 0; 516 472 517 catalog[0].Naves_off = 0; 473 518 catalog[0].Nmeas_off = 0; … … 477 522 catalog[0].Nlensing_off = 0; 478 523 catalog[0].Nlensobj_off = 0; 524 525 catalog[0].Nstarpar_off = 0; 479 526 480 527 /* pointers to SPLIT data files */ … … 484 531 catalog[0].lensing_catalog = NULL; 485 532 catalog[0].lensobj_catalog = NULL; 533 catalog[0].starpar_catalog = NULL; 486 534 487 535 /* pointers for data manipulation */ … … 525 573 526 574 if (catalog[0].f == (FILE *) NULL) return (2); 527 fflush (catalog[0].f); 575 576 if (fflush (catalog[0].f)) { 577 fprintf (stderr, "failed to flush file\n"); 578 return FALSE; 579 } 580 528 581 // fprintf (stderr, "unlocking: %s\n", catalog[0].filename); 529 582 … … 537 590 538 591 // closes f but does not set back to NULL 539 fclearlockfile (catalog[0].filename, catalog[0].f, catalog[0].lockmode, &dbstate); 592 if (!fclearlockfile (catalog[0].filename, catalog[0].f, catalog[0].lockmode, &dbstate)) { 593 fprintf (stderr, "failed to unlock or close file\n"); 594 return (0); 595 } 540 596 541 597 if (catalog[0].catmode == DVO_MODE_SPLIT) { 542 if (catalog[0].measure_catalog) dvo_catalog_unlock (catalog[0].measure_catalog); 543 if (catalog[0].missing_catalog) dvo_catalog_unlock (catalog[0].missing_catalog); 544 if (catalog[0].secfilt_catalog) dvo_catalog_unlock (catalog[0].secfilt_catalog); 545 if (catalog[0].lensing_catalog) dvo_catalog_unlock (catalog[0].lensing_catalog); 546 if (catalog[0].lensobj_catalog) dvo_catalog_unlock (catalog[0].lensobj_catalog); 598 if (catalog[0].measure_catalog) { if (!dvo_catalog_unlock (catalog[0].measure_catalog)) { fprintf (stderr, "failed to unlock measures\n"); return (0); }} 599 if (catalog[0].missing_catalog) { if (!dvo_catalog_unlock (catalog[0].missing_catalog)) { fprintf (stderr, "failed to unlock missing\n"); return (0); }} 600 if (catalog[0].secfilt_catalog) { if (!dvo_catalog_unlock (catalog[0].secfilt_catalog)) { fprintf (stderr, "failed to unlock secfilt\n"); return (0); }} 601 if (catalog[0].lensing_catalog) { if (!dvo_catalog_unlock (catalog[0].lensing_catalog)) { fprintf (stderr, "failed to unlock lensing\n"); return (0); }} 602 if (catalog[0].lensobj_catalog) { if (!dvo_catalog_unlock (catalog[0].lensobj_catalog)) { fprintf (stderr, "failed to unlock lensobj\n"); return (0); }} 603 if (catalog[0].starpar_catalog) { if (!dvo_catalog_unlock (catalog[0].starpar_catalog)) { fprintf (stderr, "failed to unlock starpar\n"); return (0); }} 547 604 } 548 605 return (1); … … 582 639 } 583 640 641 // NOTE: this only check if we can write a backup; it does not actually write the backup 584 642 if (!check_file_access (catalog[0].filename, BACKUP, READWRITE, VERBOSE)) { 585 643 fprintf (stderr, "no permission to access %s\n", catalog[0].filename); … … 820 878 free (catalog[0].lensobj_catalog); 821 879 } 880 if (catalog[0].starpar_catalog) { 881 free (catalog[0].starpar_catalog[0].filename); 882 dvo_catalog_free (catalog[0].starpar_catalog); 883 free (catalog[0].starpar_catalog); 884 } 822 885 } 823 886 dvo_catalog_free_data (catalog); … … 859 922 catalog[0].lensobj = NULL; 860 923 } 861 // if (catalog[0].X_t) free (catalog[0].X_t); 862 // if (catalog[0].Y_t) free (catalog[0].Y_t); 863 if (catalog[0].nOwn_t) free (catalog[0].nOwn_t); 864 if (catalog[0].found_t) free (catalog[0].found_t); 865 // if (catalog[0].image_t) free (catalog[0].image_t); 866 // if (catalog[0].mosaic_t) free (catalog[0].mosaic_t); 867 if (catalog[0].foundWarp_t) free (catalog[0].foundWarp_t); 924 if (catalog[0].starpar) { 925 free (catalog[0].starpar); 926 catalog[0].Nstarpar = 0; 927 catalog[0].starpar = NULL; 928 } 929 if (catalog[0].nOwn_t) { free (catalog[0].nOwn_t); catalog[0].nOwn_t = NULL; } 930 if (catalog[0].found_t) { free (catalog[0].found_t); catalog[0].found_t = NULL; } 931 if (catalog[0].foundWarp_t) { free (catalog[0].foundWarp_t); catalog[0].foundWarp_t = NULL; } 868 932 } 869 933 … … 974 1038 } 975 1039 } 1040 if (catalog[0].starpar_catalog != NULL) { 1041 if (catalog[0].Nstarpar_disk == 0) { 1042 // need to relock (and re-open) file for close elsewhere 1043 status = dvo_catalog_lock (catalog[0].starpar_catalog, lockmode); 1044 } else { 1045 if (!dvo_catalog_backup (catalog[0].starpar_catalog, FALSE)) { 1046 return FALSE; 1047 } 1048 } 1049 } 976 1050 } 977 1051 return TRUE; … … 1025 1099 } 1026 1100 } 1101 if ((catalog[0].starpar_catalog != NULL) && (catalog[0].Nstarpar_disk > 0)) { 1102 if (!dvo_catalog_unlink_backup (catalog[0].starpar_catalog, FALSE)) { 1103 return FALSE; 1104 } 1105 } 1027 1106 } 1028 1107 return TRUE; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_catalog_create.c
r37035 r37822 95 95 free (file); 96 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 97 109 free (path); 98 110 free (root); … … 117 129 } 118 130 if (dvo_catalog_lock (catalog[0].lensobj_catalog, catalog[0].lockmode) != DVO_CAT_OPEN_EMPTY) { 131 fprintf (stderr, "error with file lock\n"); 132 exit (2); 133 } 134 if (dvo_catalog_lock (catalog[0].starpar_catalog, catalog[0].lockmode) != DVO_CAT_OPEN_EMPTY) { 119 135 fprintf (stderr, "error with file lock\n"); 120 136 exit (2); … … 146 162 ALLOCATE (catalog[0].lensing, Lensing, 1); 147 163 ALLOCATE (catalog[0].lensobj, Lensobj, 1); 164 ALLOCATE (catalog[0].starpar, StarPar, 1); 148 165 149 166 /* setup secondary filters to match photcodes: -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_catalog_mef.c
r37035 r37822 4 4 5 5 off_t Nbytes; 6 off_t Naverage;7 off_t Nmeasure;8 off_t Nmissing;9 off_t Nlensing;10 off_t Nlensobj;11 6 off_t Nitems, Nexpect; 12 7 int Nsecfilt; … … 18 13 19 14 ftable.header = &header; 20 21 /* get the components from the header */22 if (!gfits_scan (&catalog[0].header, "NSTARS", OFF_T_FMT, 1, &Naverage)) return (FALSE);23 if (!gfits_scan (&catalog[0].header, "NMEAS", OFF_T_FMT, 1, &Nmeasure)) return (FALSE);24 if (!gfits_scan (&catalog[0].header, "NMISS", OFF_T_FMT, 1, &Nmissing)) return (FALSE);25 if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0;26 if (!gfits_scan (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, &Nlensing)) return (FALSE);27 if (!gfits_scan (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, &Nlensobj)) return (FALSE);28 15 29 16 /* the OBJID is a counter that uniquely defines an average entry and never changes. if … … 38 25 catalog[0].catID = 0; 39 26 } 27 28 // NSTARS, average, Naves_disk 29 30 # define GET_TABLE_SIZES(HFIELD, CFIELD, DFIELD, REQUIRED) \ 31 off_t N##CFIELD; \ 32 if (REQUIRED) { \ 33 if (!gfits_scan (&catalog[0].header, HFIELD, OFF_T_FMT, 1, &N##CFIELD)) return (FALSE); \ 34 } else { \ 35 if (!gfits_scan (&catalog[0].header, HFIELD, OFF_T_FMT, 1, &N##CFIELD)) N##CFIELD = 0; \ 36 } \ 37 /* save the current number so we can do partial updates */ \ 38 catalog[0].DFIELD = N##CFIELD; \ 39 /* default values, but we will assign these a valid value before we exit (even if empty) */ \ 40 catalog[0].CFIELD = NULL; 40 41 41 /* save the current number so we can do partial updates*/42 catalog[0].Naves_disk = Naverage;43 catalog[0].Nmeas_disk = Nmeasure;44 catalog[0].Nmiss_disk = Nmissing;45 catalog[0].Nsecf_disk = Naverage * Nsecfilt;46 catalog[0].Nlensing_disk = Nlensing;47 catalog[0].Nlensobj_disk = Nlensobj;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); 48 49 49 50 /** Nsecfilt is unusual: it does not list the number of data items in the table 50 51 instead, the number of items is Nsecfilt * Naverage. **/ 52 53 if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0; 51 54 catalog[0].Nsecfilt = Nsecfilt; 52 53 /* default values, but we will assign these a valid value before we exit (even if empty) */ 54 catalog[0].average = NULL; 55 catalog[0].measure = NULL; 56 catalog[0].missing = NULL; 55 catalog[0].Nsecf_disk = Naverage * Nsecfilt; 57 56 catalog[0].secfilt = NULL; 58 catalog[0].lensing = NULL;59 catalog[0].lensobj = NULL;60 61 /* validate table mode ?*/62 57 63 58 /*** Average Table ***/ … … 259 254 } 260 255 256 /* read StarPar table header */ 257 if (!gfits_fread_header (catalog[0].f, &header)) { 258 if (VERBOSE) fprintf (stderr, "can't read table starpar header"); 259 return (FALSE); 260 } 261 /* read StarPar table data */ 262 if (catalog[0].catflags & LOAD_STARPAR) { 263 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 264 if (VERBOSE) fprintf (stderr, "can't read table starpar data"); 265 return (FALSE); 266 } 267 catalog[0].starpar = FtableToStarPar (&ftable, &catalog[0].Nstarpar, &catalog[0].catformat); 268 if (Nstarpar != catalog[0].Nstarpar_disk) { 269 fprintf (stderr, "Warning: mismatch between Nstarpar in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nstarpar, catalog[0].Nstarpar_disk); 270 } 271 catalog[0].Nstarpar = catalog[0].Nstarpar_disk; 272 catalog[0].Nstarpar_off = 0; 273 } else { 274 Nbytes = gfits_data_size (&header); 275 fseeko (catalog[0].f, Nbytes, SEEK_CUR); 276 ALLOCATE (catalog[0].starpar, StarPar, 1); 277 catalog[0].Nstarpar = 0; 278 catalog[0].Nstarpar_off = catalog[0].Nstarpar_disk; 279 } 280 261 281 return (TRUE); 262 282 } … … 309 329 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, catalog[0].Nlensing); 310 330 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, catalog[0].Nlensobj); 331 gfits_modify (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, catalog[0].Nstarpar); 311 332 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 312 333 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 403 424 /* write out Lensobj table (convert to FITS table format) */ 404 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); 443 444 /* write out StarPar table (convert to FITS table format) */ 445 StarParToFtable (&ftable, catalog[0].starpar, catalog[0].Nstarpar, catalog[0].catformat); 405 446 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 406 447 fprintf (stderr, "can't write table header"); … … 446 487 lensobj header 447 488 lensobj table 489 starpar header 490 starpar table 448 491 */ 449 492 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_catalog_raw.c
r37035 r37822 92 92 FORMAT_CASE (PS1_V5, PS1_V5); 93 93 FORMAT_CASE (PS1_REF, PS1_REF); 94 FORMAT_CASE (PS1_SIM, PS1_SIM); 94 95 95 96 default: … … 287 288 if (catalog[0].catformat == DVO_FORMAT_PS1_V5) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_V5"); 288 289 if (catalog[0].catformat == DVO_FORMAT_PS1_REF) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_REF"); 290 if (catalog[0].catformat == DVO_FORMAT_PS1_SIM) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_SIM"); 289 291 290 292 /* rewind file pointers and truncate file */ … … 391 393 FORMAT_CASE (PS1_V5, PS1_V5); 392 394 FORMAT_CASE (PS1_REF, PS1_REF); 395 FORMAT_CASE (PS1_SIM, PS1_SIM); 393 396 394 397 default: … … 443 446 FORMAT_CASE (PS1_V5, PS1_V5); 444 447 FORMAT_CASE (PS1_REF, PS1_REF); 448 FORMAT_CASE (PS1_SIM, PS1_SIM); 445 449 446 450 default: … … 498 502 FORMAT_CASE (PS1_V5, PS1_V5); 499 503 FORMAT_CASE (PS1_REF, PS1_REF); 504 FORMAT_CASE (PS1_SIM, PS1_SIM); 500 505 501 506 default: … … 550 555 FORMAT_CASE (PS1_V5, PS1_V5); 551 556 FORMAT_CASE (PS1_REF, PS1_REF); 557 FORMAT_CASE (PS1_SIM, PS1_SIM); 552 558 553 559 default: … … 606 612 FORMAT_CASE (PS1_V5, PS1_V5); 607 613 FORMAT_CASE (PS1_REF, PS1_REF); 614 FORMAT_CASE (PS1_SIM, PS1_SIM); 608 615 609 616 default: … … 658 665 FORMAT_CASE (PS1_V5, PS1_V5); 659 666 FORMAT_CASE (PS1_REF, PS1_REF); 667 FORMAT_CASE (PS1_SIM, PS1_SIM); 660 668 661 669 default: -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_catalog_split.c
r37035 r37822 75 75 Matrix matrix; 76 76 77 // ohana_memcheck_func (TRUE); 78 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 77 130 /* rewind file pointers and truncate (file is still open) */ 78 fseeko (catalog->f, 0LL, SEEK_SET); 131 if (fseeko (catalog->f, 0LL, SEEK_SET)) { 132 perror ("dvo_catalog_save_subset: "); 133 fprintf (stderr, "failed to seek to beginning\n"); 134 } 79 135 80 136 // write PHU header … … 134 190 if (!gfits_scan (&catalog[0].header, name, "%s", 1, string)) { 135 191 free (path); 136 // databases created prior to ~2014.07.01 did not have the LENSING or LENSOBJpaths in their headers.192 // databases created prior to ~2014.07.01 did not have the LENSING, LENSOBJ, STARPAR paths in their headers. 137 193 // in these cases, we do not try to lock or open the relevant file 138 194 if (!strcmp (name, "LENSING")) return (DVO_CAT_OPEN_EMPTY); 139 195 if (!strcmp (name, "LENSOBJ")) return (DVO_CAT_OPEN_EMPTY); 196 if (!strcmp (name, "STARPAR")) return (DVO_CAT_OPEN_EMPTY); 140 197 return (DVO_CAT_OPEN_FAIL); 141 198 } … … 182 239 off_t Nlensing; 183 240 off_t Nlensobj; 241 off_t Nstarpar; 184 242 off_t Nitems; 185 243 int status, Nsecfilt; … … 196 254 197 255 /* get the components from the header - these duplicate information in the split files (NAXIS2) */ 198 // NSTARS, NMEAS, NMISS are required; NLENSING, NLENSOBJ are not (0 if not found)256 // NSTARS, NMEAS, NMISS are required; NLENSING, NLENSOBJ, NSTARPAR are not (0 if not found) 199 257 if (!gfits_scan (&catalog[0].header, "NSTARS", OFF_T_FMT, 1, &Naverage)) return (FALSE); 200 258 if (!gfits_scan (&catalog[0].header, "NMEAS", OFF_T_FMT, 1, &Nmeasure)) return (FALSE); … … 203 261 if (!gfits_scan (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, &Nlensing)) Nlensing = 0; 204 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; 205 264 206 265 /* the OBJID is a counter that uniquely defines an average entry and never changes. if … … 223 282 catalog[0].Nlensing_disk = Nlensing; 224 283 catalog[0].Nlensobj_disk = Nlensobj; 284 catalog[0].Nstarpar_disk = Nstarpar; 225 285 226 286 /** Nsecfilt is unusual: it does not list the number of data items in the table … … 235 295 catalog[0].lensing = NULL; 236 296 catalog[0].lensobj = NULL; 297 catalog[0].starpar = NULL; 237 298 238 299 /*** Average Table ***/ … … 348 409 /*** Secfilt Table ***/ 349 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); 350 412 if (status == DVO_CAT_OPEN_FAIL) { 351 413 return (FALSE); … … 465 527 gfits_free_header (&header); 466 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); 568 467 569 return (TRUE); 468 570 } … … 473 575 474 576 off_t Nbytes; 475 off_t Naverage, Nexpect, Nitems, Nmeasure, Nmissing, Nlensing, Nlensobj ;577 off_t Naverage, Nexpect, Nitems, Nmeasure, Nmissing, Nlensing, Nlensobj, Nstarpar; 476 578 Header header; 477 579 FTable ftable; … … 497 599 } 498 600 /* read Average table data : format is irrelevant here */ 499 if (!gfits_fread_ftable_range (catalog[0].f, &ftable, start, Nrows)) {601 if (!gfits_fread_ftable_range (catalog[0].f, FALSE, &ftable, start, Nrows)) { 500 602 if (VERBOSE) fprintf (stderr, "can't read table average data"); 501 603 return (FALSE); … … 527 629 } 528 630 /* read Secfilt table data : format is irrelevant here */ 529 if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start*catalog[0].Nsecfilt, catalog[0].Naverage*catalog[0].Nsecfilt)) {631 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start*catalog[0].Nsecfilt, catalog[0].Naverage*catalog[0].Nsecfilt)) { 530 632 if (VERBOSE) fprintf (stderr, "can't read table measure data"); 531 633 return (FALSE); … … 563 665 } 564 666 /* read Measure table data : format is irrelevant here */ 565 if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) {667 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) { 566 668 if (VERBOSE) fprintf (stderr, "can't read table measure data"); 567 669 return (FALSE); … … 594 696 } 595 697 /* read Missing table data : format is irrelevant here */ 596 if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) {698 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) { 597 699 if (VERBOSE) fprintf (stderr, "can't read table missing data"); 598 700 return (FALSE); … … 628 730 } 629 731 /* read Lensing table data : format is irrelevant here */ 630 if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) {732 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) { 631 733 if (VERBOSE) fprintf (stderr, "can't read table lensing data"); 632 734 return (FALSE); … … 659 761 } 660 762 /* read Lensobj table data : format is irrelevant here */ 661 if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) {763 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) { 662 764 if (VERBOSE) fprintf (stderr, "can't read table lensobj data"); 663 765 return (FALSE); … … 675 777 } 676 778 779 // XXX check the open status of the catalog 780 if (catalog[0].catflags & LOAD_STARPAR) { 781 782 Catalog *subcat = catalog[0].starpar_catalog; 783 784 /* move pointer past header -- must be already read (load_catalog) */ 785 Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header); 786 fseeko (subcat[0].f, Nbytes, SEEK_SET); 787 788 /* read StarPar table header */ 789 if (!gfits_fread_header (subcat[0].f, &header)) { 790 if (VERBOSE) fprintf (stderr, "can't read table starpar header"); 791 return (FALSE); 792 } 793 /* read StarPar table data : format is irrelevant here */ 794 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) { 795 if (VERBOSE) fprintf (stderr, "can't read table starpar data"); 796 return (FALSE); 797 } 798 799 /* convert data format to internal : returns number of row read in Nstarpar */ 800 catalog[0].starpar = FtableToStarPar (&ftable, &Nstarpar, &catalog[0].catformat); 801 if (Nstarpar != Nrows) { 802 // XXX this condition denotes the eof has been reached; not an error or a warning 803 // fprintf (stderr, "Warning: mismatch between Nstarpar in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nstarpar, Nrows); 804 } 805 gfits_free_header (&header); 806 catalog[0].Nstarpar = Nstarpar; 807 catalog[0].Nstarpar_off = start; 808 } 809 677 810 return (TRUE); 678 811 } … … 686 819 SecFilt *primary, *secfilt; 687 820 int Nsecfilt; 688 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new ;821 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new, Nstarpar_disk_new; 689 822 off_t first, start, Nrows; 690 823 … … 719 852 Nlensing_disk_new = MAX (catalog[0].Nlensing_disk, catalog[0].Nlensing + catalog[0].Nlensing_off); 720 853 Nlensobj_disk_new = MAX (catalog[0].Nlensobj_disk, catalog[0].Nlensobj + catalog[0].Nlensobj_off); 854 Nstarpar_disk_new = MAX (catalog[0].Nstarpar_disk, catalog[0].Nstarpar + catalog[0].Nstarpar_off); 721 855 722 856 /* make sure header is consistent with data */ … … 727 861 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 728 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); 729 864 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 730 865 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 845 980 } 846 981 847 /*** Lensing Table ***/848 if ((catalog[0].catflags & LOAD_LENSING) && (catalog[0].lensing != NULL)) {982 /*** Lensing Table (optional, do not save if not loaded) ***/ 983 if ((catalog[0].catflags & LOAD_LENSING) && catalog[0].lensing_catalog->f && catalog[0].lensing) { 849 984 850 985 first = 0; // first row in memory to write … … 872 1007 } 873 1008 874 /*** Lensobj Table ***/875 if ((catalog[0].catflags & LOAD_LENSOBJ) && (catalog[0].lensobj != NULL)) {1009 /*** Lensobj Table (optional, do not save if not loaded) ***/ 1010 if ((catalog[0].catflags & LOAD_LENSOBJ) && catalog[0].lensobj_catalog->f && catalog[0].lensobj) { 876 1011 877 1012 first = 0; // first row in memory to write … … 893 1028 if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) { 894 1029 fprintf (stderr, "trouble writing Lensobj table\n"); 1030 goto failure; 1031 } 1032 gfits_free_header (&header); 1033 gfits_free_table (&ftable); 1034 } 1035 1036 /*** StarPar Table (optional, do not save if not loaded) ***/ 1037 if ((catalog[0].catflags & LOAD_STARPAR) && catalog[0].starpar_catalog->f && catalog[0].starpar) { 1038 1039 first = 0; // first row in memory to write 1040 start = catalog[0].Nstarpar_off; // first disk row to write 1041 Nrows = catalog[0].Nstarpar - first; 1042 1043 assert (Nrows >= 0); 1044 assert (first >= 0); 1045 assert (first <= catalog[0].Nstarpar); 1046 assert (catalog[0].Nstarpar_disk >= catalog[0].Nstarpar_off); 1047 1048 // convert to external table format (note that the block above does not damage or free catalog.average) 1049 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat)) { 1050 fprintf (stderr, "trouble converting format\n"); 1051 goto failure; 1052 } 1053 1054 // write out StarPar table 1055 if (!dvo_catalog_save_subcat (catalog[0].starpar_catalog, &ftable, start, Nrows, catalog[0].Nstarpar_disk, Nstarpar_disk_new)) { 1056 fprintf (stderr, "trouble writing StarPar table\n"); 895 1057 goto failure; 896 1058 } … … 925 1087 SecFilt *primary, *secfilt; 926 1088 int Nsecfilt; 927 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new ;1089 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new, Nstarpar_disk_new; 928 1090 off_t first, start, Nrows; 929 1091 … … 956 1118 if (catalog[0].Nlensobj_off > 0) { 957 1119 fprintf (stderr, "ERROR: only partial catalog (Lensobj) was loaded\n"); 1120 goto failure; 1121 } 1122 if (catalog[0].Nstarpar_off > 0) { 1123 fprintf (stderr, "ERROR: only partial catalog (StarPar) was loaded\n"); 958 1124 goto failure; 959 1125 } … … 984 1150 Nlensing_disk_new = catalog[0].Nlensing; 985 1151 Nlensobj_disk_new = catalog[0].Nlensobj; 1152 Nstarpar_disk_new = catalog[0].Nstarpar; 986 1153 987 1154 /* make sure header is consistent with data */ … … 992 1159 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 993 1160 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 1161 gfits_modify (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, Nstarpar_disk_new); 994 1162 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 995 1163 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 1158 1326 if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) { 1159 1327 fprintf (stderr, "trouble writing Lensobj table\n"); 1328 goto failure; 1329 } 1330 gfits_free_header (&header); 1331 gfits_free_table (&ftable); 1332 } 1333 1334 /*** StarPar Table ***/ 1335 if ((catalog[0].catflags & LOAD_STARPAR) && (catalog[0].starpar != NULL)) { 1336 1337 first = 0; // first row in memory to write 1338 start = catalog[0].Nstarpar_off; // first disk row to write 1339 Nrows = catalog[0].Nstarpar - first; 1340 1341 assert (Nrows >= 0); 1342 assert (first >= 0); 1343 assert (first <= catalog[0].Nstarpar); 1344 assert (catalog[0].Nstarpar_disk >= catalog[0].Nstarpar_off); 1345 1346 // convert to external table format 1347 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat)) { 1348 fprintf (stderr, "trouble converting format\n"); 1349 goto failure; 1350 } 1351 1352 // write out StarPar table 1353 if (!dvo_catalog_save_subcat (catalog[0].starpar_catalog, &ftable, start, Nrows, catalog[0].Nstarpar_disk, Nstarpar_disk_new)) { 1354 fprintf (stderr, "trouble writing StarPar table\n"); 1160 1355 goto failure; 1161 1356 } … … 1189 1384 SecFilt *primary, *secfilt; 1190 1385 int Nsecfilt; 1191 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new ;1386 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new, Nstarpar_disk_new; 1192 1387 off_t first, start, Nrows; 1193 1388 … … 1221 1416 Nlensing_disk_new = MAX (catalog[0].Nlensing_disk, catalog[0].Nlensing + catalog[0].Nlensing_off); 1222 1417 Nlensobj_disk_new = MAX (catalog[0].Nlensobj_disk, catalog[0].Nlensobj + catalog[0].Nlensobj_off); 1418 Nstarpar_disk_new = MAX (catalog[0].Nstarpar_disk, catalog[0].Nstarpar + catalog[0].Nstarpar_off); 1223 1419 1224 1420 /* make sure header is consistent with data */ … … 1229 1425 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 1230 1426 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 1427 gfits_modify (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, Nstarpar_disk_new); 1231 1428 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 1232 1429 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 1399 1596 if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) { 1400 1597 fprintf (stderr, "trouble writing Lensobj table\n"); 1598 goto failure; 1599 } 1600 gfits_free_header (&header); 1601 gfits_free_table (&ftable); 1602 } 1603 1604 /*** StarPar Table ***/ 1605 if (catalog[0].starpar != NULL) { 1606 1607 first = catalog[0].Nstarpar_disk - catalog[0].Nstarpar_off; // first row in memory to write 1608 start = catalog[0].Nstarpar_disk; // first disk row to write 1609 Nrows = catalog[0].Nstarpar - first; 1610 1611 assert (Nrows >= 0); 1612 assert (first >= 0); 1613 assert (first <= catalog[0].Nstarpar); 1614 assert (catalog[0].Nstarpar_disk >= catalog[0].Nstarpar_off); 1615 1616 // convert to external table format 1617 // XXX does catalog.starpar have averef correctly set up? 1618 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat)) { 1619 fprintf (stderr, "trouble converting format\n"); 1620 goto failure; 1621 } 1622 1623 // write out StarPar table 1624 if (!dvo_catalog_save_subcat (catalog[0].starpar_catalog, &ftable, start, Nrows, catalog[0].Nstarpar_disk, Nstarpar_disk_new)) { 1625 fprintf (stderr, "trouble writing StarPar table\n"); 1401 1626 goto failure; 1402 1627 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_convert.c
r37035 r37822 43 43 CONVERT_FORMAT ("DVO_AVERAGE_PS1_V5", PS1_V5); 44 44 CONVERT_FORMAT ("DVO_AVERAGE_PS1_REF", PS1_REF); 45 CONVERT_FORMAT ("DVO_AVERAGE_PS1_SIM", PS1_SIM); 45 46 # undef CONVERT_FORMAT 46 47 … … 77 78 free (tmpAverage); 78 79 *format = DVO_FORMAT_PS1_V4; 80 return (average); 81 } 82 83 // block to convert old tables (PS1_V5 versions made during development) 84 if (!strcmp (extname, "DVO_AVERAGE_PS1_V5") && (ftable[0].header[0].Naxis[0] == 184)) { 85 Average_PS1_V5alt *tmpAverage; 86 tmpAverage = gfits_table_get_Average_PS1_V5alt (ftable, Naverage, NULL); 87 if (!tmpAverage) { 88 fprintf (stderr, "ERROR: failed to read averages\n"); 89 exit (2); 90 } 91 average = Average_PS1_V5alt_ToInternal (tmpAverage, *Naverage); 92 free (tmpAverage); 93 *format = DVO_FORMAT_PS1_V5; 79 94 return (average); 80 95 } … … 115 130 CONVERT_FORMAT ("DVO_AVERAGE_PS1_V5", PS1_V5, PS1_V5); 116 131 CONVERT_FORMAT ("DVO_AVERAGE_PS1_REF", PS1_REF, PS1_REF); 132 CONVERT_FORMAT ("DVO_AVERAGE_PS1_SIM", PS1_SIM, PS1_SIM); 117 133 # undef CONVERT_FORMAT 118 134 … … 151 167 FORMAT_CASE (PS1_V5, PS1_V5); 152 168 FORMAT_CASE (PS1_REF, PS1_REF); 169 FORMAT_CASE (PS1_SIM, PS1_SIM); 153 170 # undef FORMAT_CASE 154 171 … … 226 243 CONVERT_FORMAT ("DVO_MEASURE_PS1_V5", PS1_V5, PS1_V5, TRUE); 227 244 CONVERT_FORMAT ("DVO_MEASURE_PS1_REF", PS1_REF, PS1_REF, FALSE); 245 CONVERT_FORMAT ("DVO_MEASURE_PS1_SIM", PS1_SIM, PS1_SIM, TRUE); 228 246 # undef CONVERT_FORMAT 229 247 … … 240 258 case DVO_FORMAT_##FORMAT: { \ 241 259 Measure_##TYPE *tmpMeasure; \ 242 myAssert (ABS_COORDS || average, "conversion tointernal needs average table"); \260 myAssert (ABS_COORDS || average, "conversion from internal needs average table"); \ 243 261 tmpMeasure = MeasureInternalTo_##TYPE (average, measure, Nmeasure); \ 244 262 gfits_table_set_Measure_##TYPE (ftable, tmpMeasure, Nmeasure); \ … … 264 282 FORMAT_CASE (PS1_V5, PS1_V5, TRUE); 265 283 FORMAT_CASE (PS1_REF, PS1_REF, FALSE); 284 FORMAT_CASE (PS1_SIM, PS1_SIM, TRUE); 266 285 # undef FORMAT_CASE 267 286 … … 285 304 return (FALSE); 286 305 } 306 307 // block to convert old tables (PS1_V5 versions made during development) 308 if (!strcmp (extname, "DVO_SECFILT_PS1_V5") && (ftable[0].header[0].Naxis[0] == 160)) { 309 SecFilt_PS1_V5alt *tmpSecFilt; 310 tmpSecFilt = gfits_table_get_SecFilt_PS1_V5alt (ftable, Nsecfilt, NULL); 311 if (!tmpSecFilt) { 312 fprintf (stderr, "ERROR: failed to read secfilts\n"); 313 exit (2); 314 } 315 secfilt = SecFilt_PS1_V5alt_ToInternal (tmpSecFilt, *Nsecfilt); 316 free (tmpSecFilt); 317 *format = DVO_FORMAT_PS1_V5; 318 return (secfilt); 319 } 320 287 321 288 322 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ … … 321 355 CONVERT_FORMAT ("DVO_SECFILT_PS1_V5", PS1_V5, PS1_V5); 322 356 CONVERT_FORMAT ("DVO_SECFILT_PS1_REF", PS1_REF, PS1_REF); 357 CONVERT_FORMAT ("DVO_SECFILT_PS1_SIM", PS1_SIM, PS1_SIM); 323 358 # undef CONVERT_FORMAT 324 359 … … 357 392 FORMAT_CASE (PS1_V5, PS1_V5); 358 393 FORMAT_CASE (PS1_REF, PS1_REF); 394 FORMAT_CASE (PS1_SIM, PS1_SIM); 359 395 # undef FORMAT_CASE 360 396 … … 378 414 return (FALSE); 379 415 } 416 417 if (!strcmp (extname, "DVO_LENSING_PS1_V5") && (ftable[0].header[0].Naxis[0] == 128)) { 418 Lensing_PS1_V5_ALT *tmpLensing; 419 tmpLensing = gfits_table_get_Lensing_PS1_V5_ALT (ftable, Nlensing, NULL); 420 if (!tmpLensing) { 421 fprintf (stderr, "ERROR: failed to read lensings\n"); 422 exit (2); 423 } 424 lensing = Lensing_PS1_V5_ALT_ToInternal (tmpLensing, *Nlensing); 425 free (tmpLensing); 426 *format = DVO_FORMAT_PS1_V5; 427 return (lensing); } 380 428 381 429 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ … … 392 440 return (lensing); } 393 441 442 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 443 if (!strcmp (extname, NAME)) { \ 444 fprintf (stderr, "ERROR: format %s not defined for lensing, skipping\n", NAME); \ 445 *Nlensing = 0; \ 446 return NULL; \ 447 } 448 394 449 if (!strcmp (extname, "DVO_LENSING")) { 395 450 lensing = gfits_table_get_Lensing (ftable, Nlensing, NULL); … … 402 457 } 403 458 404 // CONVERT_FORMAT ("DVO_LENSING_PS1_REF", PS1_REF, PS1_REF);405 // CONVERT_FORMAT ("DVO_LENSING_ELIXIR", ELIXIR, Elixir);406 // CONVERT_FORMAT ("DVO_LENSING_LONEOS", LONEOS, Loneos);407 // CONVERT_FORMAT ("DVO_LENSING_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0);408 // CONVERT_FORMAT ("DVO_LENSING_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1);409 // CONVERT_FORMAT ("DVO_LENSING_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1);410 // CONVERT_FORMAT ("DVO_LENSING_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2);411 // CONVERT_FORMAT ("DVO_LENSING_PS1_V1", PS1_V1, PS1_V1);412 // CONVERT_FORMAT ("DVO_LENSING_PS1_V2", PS1_V2, PS1_V2);413 // CONVERT_FORMAT ("DVO_LENSING_PS1_V3", PS1_V3, PS1_V3);414 // CONVERT_FORMAT ("DVO_LENSING_PS1_V4", PS1_V4, PS1_V4);415 CONVERT_FORMAT ("DVO_LENSING_PS1_V5", PS1_V5, PS1_V5);459 SKIPPING_FORMAT ("DVO_LENSING_PS1_REF", PS1_REF, PS1_REF); 460 SKIPPING_FORMAT ("DVO_LENSING_ELIXIR", ELIXIR, Elixir); 461 SKIPPING_FORMAT ("DVO_LENSING_LONEOS", LONEOS, Loneos); 462 SKIPPING_FORMAT ("DVO_LENSING_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0); 463 SKIPPING_FORMAT ("DVO_LENSING_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1); 464 SKIPPING_FORMAT ("DVO_LENSING_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 465 SKIPPING_FORMAT ("DVO_LENSING_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 466 SKIPPING_FORMAT ("DVO_LENSING_PS1_V1", PS1_V1, PS1_V1); 467 SKIPPING_FORMAT ("DVO_LENSING_PS1_V2", PS1_V2, PS1_V2); 468 SKIPPING_FORMAT ("DVO_LENSING_PS1_V3", PS1_V3, PS1_V3); 469 SKIPPING_FORMAT ("DVO_LENSING_PS1_V4", PS1_V4, PS1_V4); 470 CONVERT_FORMAT ("DVO_LENSING_PS1_V5", PS1_V5, PS1_V5); 416 471 # undef CONVERT_FORMAT 417 472 … … 549 604 default: 550 605 fprintf (stderr, "table format unknown (lensobj)\n"); 606 return (FALSE); 607 } 608 return (TRUE); 609 } 610 611 /*** StarPar / FTable conversion functions ***/ 612 613 StarPar *FtableToStarPar (FTable *ftable, off_t *Nstarpar, char *format) { 614 615 StarPar *starpar; 616 char extname[80]; 617 618 /* convert to the internal format */ 619 if (!gfits_scan (ftable[0].header, "EXTNAME", "%s", 1, extname)) { 620 fprintf (stderr, "EXTNAME missing for starpar table\n"); 621 return (FALSE); 622 } 623 624 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 625 if (!strcmp (extname, NAME)) { \ 626 StarPar_##TYPE *tmpStarPar; \ 627 tmpStarPar = gfits_table_get_StarPar_##TYPE (ftable, Nstarpar, NULL); \ 628 if (!tmpStarPar) { \ 629 fprintf (stderr, "ERROR: failed to read starpar\n"); \ 630 exit (2); \ 631 } \ 632 starpar = StarPar_##TYPE##_ToInternal (tmpStarPar, *Nstarpar); \ 633 free (tmpStarPar); \ 634 *format = DVO_FORMAT_##FORMAT; \ 635 return (starpar); } 636 637 if (!strcmp (extname, "DVO_STARPAR")) { 638 starpar = gfits_table_get_StarPar (ftable, Nstarpar, NULL); 639 if (!starpar) { 640 fprintf (stderr, "ERROR: failed to read starpar\n"); 641 exit (2); 642 } 643 *format = DVO_FORMAT_INTERNAL; 644 return (starpar); 645 } 646 647 CONVERT_FORMAT ("DVO_STARPAR_PS1_SIM", PS1_SIM, PS1_SIM); 648 // CONVERT_FORMAT ("DVO_STARPAR_PS1_REF", PS1_REF, PS1_REF); 649 // CONVERT_FORMAT ("DVO_STARPAR_ELIXIR", ELIXIR, Elixir); 650 // CONVERT_FORMAT ("DVO_STARPAR_LONEOS", LONEOS, Loneos); 651 // CONVERT_FORMAT ("DVO_STARPAR_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0); 652 // CONVERT_FORMAT ("DVO_STARPAR_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1); 653 // CONVERT_FORMAT ("DVO_STARPAR_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 654 // CONVERT_FORMAT ("DVO_STARPAR_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 655 // CONVERT_FORMAT ("DVO_STARPAR_PS1_V1", PS1_V1, PS1_V1); 656 // CONVERT_FORMAT ("DVO_STARPAR_PS1_V2", PS1_V2, PS1_V2); 657 // CONVERT_FORMAT ("DVO_STARPAR_PS1_V3", PS1_V3, PS1_V3); 658 // CONVERT_FORMAT ("DVO_STARPAR_PS1_V4", PS1_V4, PS1_V4); 659 CONVERT_FORMAT ("DVO_STARPAR_PS1_V5", PS1_V5, PS1_V5); 660 // CONVERT_FORMAT ("DVO_STELLAR_PARAMS_PS1_V5", PS1_V5, PS1_V5); 661 // XXX fix in libauto: STELLAR_PARAMS to STARPAR 662 # undef CONVERT_FORMAT 663 664 fprintf (stderr, "table format unknown: %s\n", extname); 665 666 *Nstarpar = 0; 667 return (NULL); 668 } 669 670 // StarParToFtable needs the Average since old formats stored starpar.dR,dD only 671 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, char format) { 672 673 # define FORMAT_CASE(FORMAT, TYPE) \ 674 case DVO_FORMAT_##FORMAT: { \ 675 StarPar_##TYPE *tmpStarPar; \ 676 tmpStarPar = StarParInternalTo_##TYPE (starpar, Nstarpar); \ 677 gfits_table_set_StarPar_##TYPE (ftable, tmpStarPar, Nstarpar); \ 678 free (tmpStarPar); \ 679 break; } 680 681 /* convert from the internal format */ 682 switch (format) { 683 case DVO_FORMAT_INTERNAL: { 684 gfits_table_set_StarPar (ftable, starpar, Nstarpar); 685 break; } 686 687 FORMAT_CASE (PS1_SIM, PS1_SIM); 688 // FORMAT_CASE (PS1_REF, PS1_REF); 689 // FORMAT_CASE (ELIXIR, Elixir); 690 // FORMAT_CASE (LONEOS, Loneos); 691 // FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 692 // FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 693 // FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 694 // FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 695 // FORMAT_CASE (PS1_V1, PS1_V1); 696 // FORMAT_CASE (PS1_V2, PS1_V2); 697 // FORMAT_CASE (PS1_V3, PS1_V3); 698 // FORMAT_CASE (PS1_V4, PS1_V4); 699 FORMAT_CASE (PS1_V5, PS1_V5); 700 # undef FORMAT_CASE 701 702 default: 703 fprintf (stderr, "table format unknown (starpar)\n"); 551 704 return (FALSE); 552 705 } … … 607 760 return (TRUE); } 608 761 609 if (!strcmp (extname, "DVO_IMAGE")) {610 Image *image;611 image = gfits_table_get_Image (ftable, &Nimage, NULL);612 if (!image) {613 fprintf (stderr, "ERROR: failed to read images\n");614 exit (2);615 }616 *format = DVO_FORMAT_INTERNAL;617 return (TRUE);618 }619 620 762 CONVERT_FORMAT ("DVO_IMAGE_ELIXIR", ELIXIR, Elixir); 621 763 CONVERT_FORMAT ("DVO_IMAGE_LONEOS", LONEOS, Loneos); … … 630 772 CONVERT_FORMAT ("DVO_IMAGE_PS1_V5", PS1_V5, PS1_V5); 631 773 CONVERT_FORMAT ("DVO_IMAGE_PS1_REF", PS1_REF, PS1_REF); 774 CONVERT_FORMAT ("DVO_IMAGE_PS1_SIM", PS1_SIM, PS1_SIM); 632 775 633 776 # undef CONVERT_FORMAT … … 654 797 /* convert from the internal format */ 655 798 switch (format) { 656 case DVO_FORMAT_INTERNAL: {657 gfits_convert_Image ((Image *) ftable[0].buffer, sizeof(Image), Nimage);658 break; }659 660 799 FORMAT_CASE (ELIXIR, Elixir); 661 800 FORMAT_CASE (LONEOS, Loneos); … … 670 809 FORMAT_CASE (PS1_V5, PS1_V5); 671 810 FORMAT_CASE (PS1_REF, PS1_REF); 811 FORMAT_CASE (PS1_SIM, PS1_SIM); 672 812 673 813 # undef FORMAT_CASE … … 708 848 /* convert from the internal format */ 709 849 switch (format) { 710 case DVO_FORMAT_INTERNAL: {711 for (i = 0; i < Nrow; i++) {712 gfits_convert_Image ((Image *) vtable[0].buffer[i], sizeof(Image), 1);713 }714 return (TRUE); }715 716 850 FORMAT_CASE (ELIXIR, Elixir); 717 851 FORMAT_CASE (LONEOS, Loneos); … … 726 860 FORMAT_CASE (PS1_V5, PS1_V5); 727 861 FORMAT_CASE (PS1_REF, PS1_REF); 862 FORMAT_CASE (PS1_SIM, PS1_SIM); 728 863 729 864 # undef FORMAT_CASE -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c
r37035 r37822 32 32 out[i].psfQF = in[i].psfQF; 33 33 out[i].psfChisq = in[i].psfChisq; 34 out[i].crNsigma = in[i].crNsigma;35 34 out[i].extNsigma = in[i].extNsigma; 36 35 out[i].FWx = in[i].FWx; … … 80 79 out[i].psfQF = in[i].psfQF; 81 80 out[i].psfChisq = in[i].psfChisq; 82 out[i].crNsigma = in[i].crNsigma;83 81 out[i].extNsigma = in[i].extNsigma; 84 82 out[i].FWx = in[i].FWx; … … 221 219 222 220 for (i = 0; i < Nvalues; i++) { 223 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 221 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 222 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 223 out[i].coords.mosaic = NULL; 224 out[i].coords.offsetMap = NULL; 224 225 225 226 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN … … 289 290 290 291 for (i = 0; i < Nvalues; i++) { 291 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 292 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 293 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 292 294 293 295 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c
r37035 r37822 34 34 out[i].psfQF = in[i].psfQF; 35 35 out[i].psfChisq = in[i].psfChisq; 36 out[i].crNsigma = in[i].crNsigma;37 36 out[i].extNsigma = in[i].extNsigma; 38 37 out[i].FWx = in[i].FWx; … … 80 79 out[i].psfQF = in[i].psfQF; 81 80 out[i].psfChisq = in[i].psfChisq; 82 out[i].crNsigma = in[i].crNsigma;83 81 out[i].extNsigma = in[i].extNsigma; 84 82 out[i].FWx = in[i].FWx; … … 216 214 217 215 for (i = 0; i < Nvalues; i++) { 218 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 216 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 217 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 218 out[i].coords.mosaic = NULL; 219 out[i].coords.offsetMap = NULL; 219 220 220 221 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN … … 281 282 282 283 for (i = 0; i < Nvalues; i++) { 283 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 284 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 285 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 284 286 285 287 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_3.c
r37055 r37822 18 18 19 19 for (i = 0; i < Nvalues; i++) { 20 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 20 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 21 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 22 out[i].coords.mosaic = NULL; 23 out[i].coords.offsetMap = NULL; 21 24 22 25 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN … … 78 81 79 82 for (i = 0; i < Nvalues; i++) { 80 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 83 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 84 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 81 85 82 86 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_convert_PS1_REF.c
r37035 r37822 145 145 146 146 for (i = 0; i < Nvalues; i++) { 147 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 147 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 148 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 149 out[i].coords.mosaic = NULL; 150 out[i].coords.offsetMap = NULL; 148 151 149 152 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN … … 208 211 209 212 for (i = 0; i < Nvalues; i++) { 210 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 213 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 214 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 211 215 212 216 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_convert_PS1_V1.c
r37035 r37822 40 40 out[i].psfNdof = in[i].psfNdof; 41 41 out[i].psfNpix = in[i].psfNpix; 42 out[i].crNsigma = in[i].crNsigma;43 42 out[i].extNsigma = in[i].extNsigma; 44 43 out[i].FWx = in[i].FWx; … … 95 94 out[i].psfNdof = in[i].psfNdof; 96 95 out[i].psfNpix = in[i].psfNpix; 97 out[i].crNsigma = in[i].crNsigma;98 96 out[i].extNsigma = in[i].extNsigma; 99 97 out[i].FWx = in[i].FWx; … … 240 238 241 239 for (i = 0; i < Nvalues; i++) { 242 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 240 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 241 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 242 out[i].coords.mosaic = NULL; 243 out[i].coords.offsetMap = NULL; 243 244 244 245 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN … … 304 305 305 306 for (i = 0; i < Nvalues; i++) { 306 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 307 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 308 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 307 309 308 310 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_convert_PS1_V2.c
r37035 r37822 40 40 out[i].psfNdof = in[i].psfNdof; 41 41 out[i].psfNpix = in[i].psfNpix; 42 out[i].crNsigma = in[i].crNsigma;43 42 out[i].extNsigma = in[i].extNsigma; 44 43 out[i].FWx = in[i].FWx; … … 96 95 out[i].psfNdof = in[i].psfNdof; 97 96 out[i].psfNpix = in[i].psfNpix; 98 out[i].crNsigma = in[i].crNsigma;99 97 out[i].extNsigma = in[i].extNsigma; 100 98 out[i].FWx = in[i].FWx; … … 251 249 252 250 for (i = 0; i < Nvalues; i++) { 253 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 251 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 252 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 253 out[i].coords.mosaic = NULL; 254 out[i].coords.offsetMap = NULL; 254 255 255 256 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN … … 315 316 316 317 for (i = 0; i < Nvalues; i++) { 317 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 318 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 319 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 318 320 319 321 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_convert_PS1_V3.c
r37035 r37822 40 40 out[i].psfNdof = in[i].psfNdof; 41 41 out[i].psfNpix = in[i].psfNpix; 42 out[i].crNsigma = in[i].crNsigma;43 42 out[i].extNsigma = in[i].extNsigma; 44 43 out[i].FWx = in[i].FWx; … … 96 95 out[i].psfNdof = in[i].psfNdof; 97 96 out[i].psfNpix = in[i].psfNpix; 98 out[i].crNsigma = in[i].crNsigma;99 97 out[i].extNsigma = in[i].extNsigma; 100 98 out[i].FWx = in[i].FWx; … … 261 259 262 260 for (i = 0; i < Nvalues; i++) { 263 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 261 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 262 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 263 out[i].coords.mosaic = NULL; 264 out[i].coords.offsetMap = NULL; 264 265 265 266 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN … … 325 326 326 327 for (i = 0; i < Nvalues; i++) { 327 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 328 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 329 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 328 330 329 331 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_convert_PS1_V4.c
r37035 r37822 49 49 out[i].psfNdof = in[i].psfNdof; 50 50 out[i].psfNpix = in[i].psfNpix; 51 out[i].crNsigma = in[i].crNsigma;52 51 out[i].extNsigma = in[i].extNsigma; 53 52 out[i].FWx = in[i].FWx; … … 114 113 out[i].psfNdof = in[i].psfNdof; 115 114 out[i].psfNpix = in[i].psfNpix; 116 out[i].crNsigma = in[i].crNsigma;117 115 out[i].extNsigma = in[i].extNsigma; 118 116 out[i].FWx = in[i].FWx; … … 251 249 out[i].Mstdev = in[i].Mstdev; 252 250 out[i].ubercalDist = in[i].ubercalDist; 253 out[i].stackDetectID = in[i].stackDetectID; 251 out[i].stackPrmryOff = in[i].stackPrmryOff; 252 out[i].stackBestOff = in[i].stackBestOff; 254 253 } 255 254 return (out); … … 281 280 out[i].Mstdev = in[i].Mstdev; 282 281 out[i].ubercalDist = in[i].ubercalDist; 283 out[i].stackDetectID = in[i].stackDetectID; 282 out[i].stackPrmryOff = in[i].stackPrmryOff; 283 out[i].stackBestOff = in[i].stackBestOff; 284 284 } 285 285 return (out); … … 299 299 300 300 for (i = 0; i < Nvalues; i++) { 301 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 301 // this is only save because the initial 120 bytes in Coords match CoordsDisk 302 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 303 out[i].coords.mosaic = NULL; 304 out[i].coords.offsetMap = NULL; 302 305 303 306 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN … … 363 366 364 367 for (i = 0; i < Nvalues; i++) { 365 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 368 // this is only save because the initial 120 bytes in Coords match CoordsDisk 369 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 366 370 367 371 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN … … 539 543 out[i].psfNdof = in[i].psfNdof; 540 544 out[i].psfNpix = in[i].psfNpix; 541 out[i].crNsigma = in[i].crNsigma;542 545 out[i].extNsigma = in[i].extNsigma; 543 546 out[i].FWx = in[i].FWx; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c
r37331 r37822 56 56 out[i].psfNdof = in[i].psfNdof; 57 57 out[i].psfNpix = in[i].psfNpix; 58 out[i].crNsigma = in[i].crNsigma;59 58 out[i].extNsigma = in[i].extNsigma; 60 59 out[i].FWx = in[i].FWx; … … 73 72 out[i].dbFlags = in[i].dbFlags; 74 73 out[i].photFlags = in[i].photFlags; 74 out[i].photFlags2 = in[i].photFlags2; 75 75 } 76 76 return (out); … … 128 128 out[i].psfNdof = in[i].psfNdof; 129 129 out[i].psfNpix = in[i].psfNpix; 130 out[i].crNsigma = in[i].crNsigma;131 130 out[i].extNsigma = in[i].extNsigma; 132 131 out[i].FWx = in[i].FWx; … … 145 144 out[i].dbFlags = in[i].dbFlags; 146 145 out[i].photFlags = in[i].photFlags; 146 out[i].photFlags2 = in[i].photFlags2; 147 147 } 148 148 return (out); … … 191 191 out[i].Nlensing = in[i].Nlensing; 192 192 out[i].Nlensobj = in[i].Nlensobj; 193 out[i].Nstarpar = in[i].Nstarpar; 193 194 out[i].Nextend = in[i].Nextend; 194 195 … … 197 198 out[i].lensingOffset = in[i].lensingOffset; 198 199 out[i].lensobjOffset = in[i].lensobjOffset; 200 out[i].starparOffset = in[i].starparOffset; 199 201 out[i].extendOffset = in[i].extendOffset; 200 out[i].paramsOffset = in[i].paramsOffset;201 202 202 203 out[i].refColorBlue = in[i].refColorBlue; 203 204 out[i].refColorRed = in[i].refColorRed; 205 206 out[i].tessID = in[i].tessID; 207 out[i].skycellID = in[i].skycellID; 208 out[i].projectionID = in[i].projectionID; 204 209 205 210 out[i].flags = in[i].flags; … … 223 228 224 229 for (i = 0; i < Nvalues; i++) { 225 out[i].R = in[i].R; 226 out[i].D = in[i].D; 227 out[i].dR = in[i].dR; 228 out[i].dD = in[i].dD; 229 out[i].uR = in[i].uR; 230 out[i].uD = in[i].uD; 231 out[i].duR = in[i].duR; 232 out[i].duD = in[i].duD; 233 out[i].P = in[i].P; 234 out[i].dP = in[i].dP; 235 236 out[i].Rstk = in[i].Rstk; 237 out[i].Dstk = in[i].Dstk; 238 out[i].dRstk = in[i].dRstk; 239 out[i].dDstk = in[i].dDstk; 240 241 out[i].ChiSqAve = in[i].ChiSqAve; 242 out[i].ChiSqPM = in[i].ChiSqPM; 243 out[i].ChiSqPar = in[i].ChiSqPar; 244 out[i].Tmean = in[i].Tmean; 245 out[i].Trange = in[i].Trange; 246 247 out[i].psfQF = in[i].psfQF; 248 out[i].psfQFperf = in[i].psfQFperf; 249 out[i].stargal = in[i].stargal; 250 out[i].Npos = in[i].Npos; 251 252 out[i].Nmeasure = in[i].Nmeasure; 253 out[i].Nmissing = in[i].Nmissing; 254 out[i].Nlensing = in[i].Nlensing; 255 out[i].Nlensobj = in[i].Nlensobj; 256 out[i].Nextend = in[i].Nextend; 257 258 out[i].measureOffset = in[i].measureOffset; 259 out[i].missingOffset = in[i].missingOffset; 260 out[i].lensingOffset = in[i].lensingOffset; 261 out[i].lensobjOffset = in[i].lensobjOffset; 262 out[i].extendOffset = in[i].extendOffset; 263 out[i].paramsOffset = in[i].paramsOffset; 264 265 out[i].refColorBlue = in[i].refColorBlue; 266 out[i].refColorRed = in[i].refColorRed; 267 268 out[i].flags = in[i].flags; 230 out[i].R = in[i].R; 231 out[i].D = in[i].D; 232 out[i].dR = in[i].dR; 233 out[i].dD = in[i].dD; 234 out[i].uR = in[i].uR; 235 out[i].uD = in[i].uD; 236 out[i].duR = in[i].duR; 237 out[i].duD = in[i].duD; 238 out[i].P = in[i].P; 239 out[i].dP = in[i].dP; 240 241 out[i].Rstk = in[i].Rstk; 242 out[i].Dstk = in[i].Dstk; 243 out[i].dRstk = in[i].dRstk; 244 out[i].dDstk = in[i].dDstk; 245 246 out[i].ChiSqAve = in[i].ChiSqAve; 247 out[i].ChiSqPM = in[i].ChiSqPM; 248 out[i].ChiSqPar = in[i].ChiSqPar; 249 out[i].Tmean = in[i].Tmean; 250 out[i].Trange = in[i].Trange; 251 252 out[i].psfQF = in[i].psfQF; 253 out[i].psfQFperf = in[i].psfQFperf; 254 out[i].stargal = in[i].stargal; 255 out[i].Npos = in[i].Npos; 256 257 out[i].Nmeasure = in[i].Nmeasure; 258 out[i].Nmissing = in[i].Nmissing; 259 out[i].Nlensing = in[i].Nlensing; 260 out[i].Nlensobj = in[i].Nlensobj; 261 out[i].Nstarpar = in[i].Nstarpar; 262 out[i].Nextend = in[i].Nextend; 263 264 out[i].measureOffset = in[i].measureOffset; 265 out[i].missingOffset = in[i].missingOffset; 266 out[i].lensingOffset = in[i].lensingOffset; 267 out[i].lensobjOffset = in[i].lensobjOffset; 268 out[i].starparOffset = in[i].starparOffset; 269 out[i].extendOffset = in[i].extendOffset; 270 271 out[i].refColorBlue = in[i].refColorBlue; 272 out[i].refColorRed = in[i].refColorRed; 273 274 out[i].tessID = in[i].tessID; 275 out[i].skycellID = in[i].skycellID; 276 out[i].projectionID = in[i].projectionID; 277 278 out[i].flags = in[i].flags; 269 279 out[i].photFlagsUpper = in[i].photFlagsUpper; 270 280 out[i].photFlagsLower = in[i].photFlagsLower; 271 out[i].objID = in[i].objID;272 out[i].catID = in[i].catID;273 out[i].extID = in[i].extID;274 out[i].extIDgc = in[i].extIDgc;281 out[i].objID = in[i].objID; 282 out[i].catID = in[i].catID; 283 out[i].extID = in[i].extID; 284 out[i].extIDgc = in[i].extIDgc; 275 285 } 276 286 return (out); … … 286 296 for (i = 0; i < Nvalues; i++) { 287 297 dvo_secfilt_init (&out[i]); 288 289 out[i].M = in[i].M;290 out[i].dM = in[i].dM;291 out[i].Map = in[i].Map;292 out[i].dMap = in[i].dMap;293 out[i].sMap = in[i].sMap;294 out[i].Mkron = in[i].Mkron;295 out[i].dMkron = in[i].dMkron;296 297 out[i].Mstdev = in[i].Mstdev;298 out[i].Mmin = in[i].Mmin;299 out[i].Mmax = in[i].Mmax;300 out[i].Mchisq = in[i].Mchisq;301 302 out[i].Ncode = in[i].Ncode;303 out[i].Nused = in[i].Nused;304 out[i].NusedKron = in[i].NusedKron;305 out[i].NusedAp = in[i].NusedAp;306 307 out[i].flags = in[i].flags;308 309 out[i].MpsfStk = in[i].MpsfStk;310 out[i].FpsfStk = in[i].FpsfStk;311 out[i].dFpsfStk = in[i].dFpsfStk;312 313 out[i].MkronStk = in[i].MkronStk;314 out[i].FkronStk = in[i].FkronStk;315 out[i].dFkronStk = in[i].dFkronStk;316 317 out[i].MapStk = in[i].MapStk;318 out[i].FapStk = in[i].FapStk;319 out[i].dFapStk = in[i].dFapStk;320 321 out[i].stackDetectID = in[i].stackDetectID;322 323 out[i].MpsfWrp = in[i].MpsfWrp;324 out[i].FpsfWrp = in[i].FpsfWrp;325 out[i].dFpsfWrp = in[i].dFpsfWrp;326 out[i].sFpsfWrp = in[i].sFpsfWrp;327 328 out[i].MkronWrp = in[i].MkronWrp;329 out[i].FkronWrp = in[i].FkronWrp;330 out[i].dFkronWrp = in[i].dFkronWrp;331 out[i].sFkronWrp = in[i].sFkronWrp;332 333 out[i].MapWrp = in[i].MapWrp;334 out[i].FapWrp = in[i].FapWrp;335 out[i].dFapWrp = in[i].dFapWrp;336 out[i].sFapWrp = in[i].sFapWrp;337 338 out[i].NusedWrp = in[i].NusedWrp;339 out[i].NusedKronWrp = in[i].NusedKronWrp;340 out[i].NusedApWrp = in[i].NusedApWrp;341 342 out[i].ubercalDist = in[i].ubercalDist;343 }344 return (out);345 }346 347 SecFilt_PS1_V5 *SecFiltInternalTo_PS1_V5 (SecFilt *in, off_t Nvalues) {348 349 off_t i;350 SecFilt_PS1_V5 *out;351 352 ALLOCATE_ZERO (out, SecFilt_PS1_V5, Nvalues);353 354 for (i = 0; i < Nvalues; i++) {355 298 356 299 out[i].M = in[i].M; … … 363 306 out[i].sMkron = in[i].sMkron; 364 307 308 out[i].psfQfMax = in[i].psfQfMax; 309 out[i].psfQfPerfMax = in[i].psfQfPerfMax; 310 365 311 out[i].Mstdev = in[i].Mstdev; 366 312 out[i].Mmin = in[i].Mmin; … … 387 333 out[i].dFapStk = in[i].dFapStk; 388 334 389 out[i].stackDetectID = in[i].stackDetectID; 335 out[i].Nstack = in[i].Nstack; 336 out[i].NstackDet = in[i].NstackDet; 337 338 out[i].stackPrmryOff = in[i].stackPrmryOff; 339 out[i].stackBestOff = in[i].stackBestOff; 390 340 391 341 out[i].MpsfWrp = in[i].MpsfWrp; … … 407 357 out[i].NusedKronWrp = in[i].NusedKronWrp; 408 358 out[i].NusedApWrp = in[i].NusedApWrp; 359 360 out[i].Nwarp = in[i].Nwarp; 361 out[i].NwarpGood = in[i].NwarpGood; 362 363 out[i].ubercalDist = in[i].ubercalDist; 364 } 365 return (out); 366 } 367 368 SecFilt_PS1_V5 *SecFiltInternalTo_PS1_V5 (SecFilt *in, off_t Nvalues) { 369 370 off_t i; 371 SecFilt_PS1_V5 *out; 372 373 ALLOCATE_ZERO (out, SecFilt_PS1_V5, Nvalues); 374 375 for (i = 0; i < Nvalues; i++) { 376 377 out[i].M = in[i].M; 378 out[i].dM = in[i].dM; 379 out[i].Map = in[i].Map; 380 out[i].dMap = in[i].dMap; 381 out[i].sMap = in[i].sMap; 382 out[i].Mkron = in[i].Mkron; 383 out[i].dMkron = in[i].dMkron; 384 out[i].sMkron = in[i].sMkron; 385 386 out[i].psfQfMax = in[i].psfQfMax; 387 out[i].psfQfPerfMax = in[i].psfQfPerfMax; 388 389 out[i].Mstdev = in[i].Mstdev; 390 out[i].Mmin = in[i].Mmin; 391 out[i].Mmax = in[i].Mmax; 392 out[i].Mchisq = in[i].Mchisq; 393 394 out[i].Ncode = in[i].Ncode; 395 out[i].Nused = in[i].Nused; 396 out[i].NusedKron = in[i].NusedKron; 397 out[i].NusedAp = in[i].NusedAp; 398 399 out[i].flags = in[i].flags; 400 401 out[i].MpsfStk = in[i].MpsfStk; 402 out[i].FpsfStk = in[i].FpsfStk; 403 out[i].dFpsfStk = in[i].dFpsfStk; 404 405 out[i].MkronStk = in[i].MkronStk; 406 out[i].FkronStk = in[i].FkronStk; 407 out[i].dFkronStk = in[i].dFkronStk; 408 409 out[i].MapStk = in[i].MapStk; 410 out[i].FapStk = in[i].FapStk; 411 out[i].dFapStk = in[i].dFapStk; 412 413 out[i].Nstack = in[i].Nstack; 414 out[i].NstackDet = in[i].NstackDet; 415 416 out[i].stackPrmryOff = in[i].stackPrmryOff; 417 out[i].stackBestOff = in[i].stackBestOff; 418 419 out[i].MpsfWrp = in[i].MpsfWrp; 420 out[i].FpsfWrp = in[i].FpsfWrp; 421 out[i].dFpsfWrp = in[i].dFpsfWrp; 422 out[i].sFpsfWrp = in[i].sFpsfWrp; 423 424 out[i].MkronWrp = in[i].MkronWrp; 425 out[i].FkronWrp = in[i].FkronWrp; 426 out[i].dFkronWrp = in[i].dFkronWrp; 427 out[i].sFkronWrp = in[i].sFkronWrp; 428 429 out[i].MapWrp = in[i].MapWrp; 430 out[i].FapWrp = in[i].FapWrp; 431 out[i].dFapWrp = in[i].dFapWrp; 432 out[i].sFapWrp = in[i].sFapWrp; 433 434 out[i].NusedWrp = in[i].NusedWrp; 435 out[i].NusedKronWrp = in[i].NusedKronWrp; 436 out[i].NusedApWrp = in[i].NusedApWrp; 437 438 out[i].Nwarp = in[i].Nwarp; 439 out[i].NwarpGood = in[i].NwarpGood; 409 440 410 441 out[i].ubercalDist = in[i].ubercalDist; … … 634 665 } 635 666 667 StarPar *StarPar_PS1_V5_ToInternal (StarPar_PS1_V5 *in, off_t Nvalues) { 668 669 off_t i; 670 StarPar *out; 671 672 ALLOCATE_ZERO (out, StarPar, Nvalues); 673 674 for (i = 0; i < Nvalues; i++) { 675 dvo_starpar_init (&out[i]); 676 677 out[i].R = in[i].R; 678 out[i].D = in[i].D; 679 out[i].galLat = in[i].galLat; 680 out[i].galLon = in[i].galLon; 681 682 out[i].Ebv = in[i].Ebv ; 683 out[i].dEbv = in[i].dEbv ; 684 out[i].DistMag = in[i].DistMag ; 685 out[i].dDistMag = in[i].dDistMag; 686 out[i].M_r = in[i].M_r ; 687 out[i].dM_r = in[i].dM_r ; 688 out[i].FeH = in[i].FeH ; 689 out[i].dFeH = in[i].dFeH ; 690 out[i].uRA = in[i].uRA ; 691 out[i].uDEC = in[i].uDEC ; 692 693 out[i].averef = in[i].averef; 694 out[i].objID = in[i].objID ; 695 out[i].catID = in[i].catID ; 696 } 697 return (out); 698 } 699 700 StarPar_PS1_V5 *StarParInternalTo_PS1_V5 (StarPar *in, off_t Nvalues) { 701 702 off_t i; 703 StarPar_PS1_V5 *out; 704 705 ALLOCATE_ZERO (out, StarPar_PS1_V5, Nvalues); 706 707 for (i = 0; i < Nvalues; i++) { 708 709 out[i].R = in[i].R; 710 out[i].D = in[i].D; 711 out[i].galLat = in[i].galLat; 712 out[i].galLon = in[i].galLon; 713 714 out[i].Ebv = in[i].Ebv ; 715 out[i].dEbv = in[i].dEbv ; 716 out[i].DistMag = in[i].DistMag ; 717 out[i].dDistMag = in[i].dDistMag; 718 out[i].M_r = in[i].M_r ; 719 out[i].dM_r = in[i].dM_r ; 720 out[i].FeH = in[i].FeH ; 721 out[i].dFeH = in[i].dFeH ; 722 out[i].uRA = in[i].uRA ; 723 out[i].uDEC = in[i].uDEC ; 724 725 out[i].averef = in[i].averef; 726 out[i].objID = in[i].objID ; 727 out[i].catID = in[i].catID ; 728 } 729 return (out); 730 } 731 636 732 # define RAW_IMAGE_NAME_LEN 117 637 733 … … 647 743 648 744 for (i = 0; i < Nvalues; i++) { 649 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 745 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 746 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 747 out[i].coords.mosaic = NULL; 748 out[i].coords.offsetMap = NULL; 650 749 651 750 // RAW_IMAGE_NAME_LEN == DVO_IMAGE_NAME_LEN … … 712 811 713 812 for (i = 0; i < Nvalues; i++) { 714 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 813 // this is only save because the initial 120 bytes in Coords match CoordsDisk 814 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 715 815 716 816 // RAW_IMAGE_NAME_LEN == DVO_IMAGE_NAME_LEN … … 840 940 return (out); 841 941 } 942 943 /*********************** old / alternate version **********************/ 944 945 // 'primary' is needed to conform with the API for Loneos and Elixir, but is not used 946 Average *Average_PS1_V5alt_ToInternal (Average_PS1_V5alt *in, off_t Nvalues) { 947 948 off_t i; 949 Average *out; 950 951 ALLOCATE_ZERO (out, Average, Nvalues); 952 953 for (i = 0; i < Nvalues; i++) { 954 dvo_average_init (&out[i]); 955 956 out[i].R = in[i].R; 957 out[i].D = in[i].D; 958 out[i].dR = in[i].dR; 959 out[i].dD = in[i].dD; 960 out[i].uR = in[i].uR; 961 out[i].uD = in[i].uD; 962 out[i].duR = in[i].duR; 963 out[i].duD = in[i].duD; 964 out[i].P = in[i].P; 965 out[i].dP = in[i].dP; 966 967 out[i].Rstk = in[i].Rstk; 968 out[i].Dstk = in[i].Dstk; 969 out[i].dRstk = in[i].dRstk; 970 out[i].dDstk = in[i].dDstk; 971 972 out[i].ChiSqAve = in[i].ChiSqAve; 973 out[i].ChiSqPM = in[i].ChiSqPM; 974 out[i].ChiSqPar = in[i].ChiSqPar; 975 out[i].Tmean = in[i].Tmean; 976 out[i].Trange = in[i].Trange; 977 978 out[i].psfQF = in[i].psfQF; 979 out[i].psfQFperf = in[i].psfQFperf; 980 out[i].stargal = in[i].stargal; 981 out[i].Npos = in[i].Npos; 982 983 out[i].Nmeasure = in[i].Nmeasure; 984 out[i].Nmissing = in[i].Nmissing; 985 out[i].Nlensing = in[i].Nlensing; 986 out[i].Nlensobj = in[i].Nlensobj; 987 out[i].Nextend = in[i].Nextend; 988 989 out[i].measureOffset = in[i].measureOffset; 990 out[i].missingOffset = in[i].missingOffset; 991 out[i].lensingOffset = in[i].lensingOffset; 992 out[i].lensobjOffset = in[i].lensobjOffset; 993 out[i].starparOffset = in[i].starparOffset; 994 out[i].extendOffset = in[i].extendOffset; 995 996 out[i].refColorBlue = in[i].refColorBlue; 997 out[i].refColorRed = in[i].refColorRed; 998 999 out[i].flags = in[i].flags; 1000 out[i].photFlagsUpper = in[i].photFlagsUpper; 1001 out[i].photFlagsLower = in[i].photFlagsLower; 1002 out[i].objID = in[i].objID; 1003 out[i].catID = in[i].catID; 1004 out[i].extID = in[i].extID; 1005 out[i].extIDgc = in[i].extIDgc; 1006 } 1007 return (out); 1008 } 1009 1010 int gfits_convert_Average_PS1_V5alt (Average_PS1_V5alt *data, off_t size, off_t nitems) { 1011 1012 off_t i; 1013 unsigned char *byte, tmp; 1014 1015 if (size != 184) { 1016 fprintf (stderr, "WARNING: mismatch in data types Average_PS1_V5alt: "OFF_T_FMT" vs %d\n", size, 184); 1017 return (FALSE); 1018 } 1019 1020 /* provide initial values to avoid compiler warnings for non-BYTE_SWAP arch */ 1021 i = tmp = 0; 1022 byte = NULL; 1023 1024 # ifdef BYTE_SWAP 1025 byte = (unsigned char *) data; 1026 for (i = 0; i < nitems; i++, byte += 184) { 1027 /** BYTE SWAP **/ 1028 SWAP_DBLE (0); // RA 1029 SWAP_DBLE (8); // DEC 1030 SWAP_WORD (16); // RA_ERR 1031 SWAP_WORD (20); // DEC_ERR 1032 SWAP_WORD (24); // U_RA 1033 SWAP_WORD (28); // U_DEC 1034 SWAP_WORD (32); // V_RA_ERR 1035 SWAP_WORD (36); // V_DEC_ERR 1036 SWAP_WORD (40); // PAR 1037 SWAP_WORD (44); // PAR_ERR 1038 SWAP_DBLE (48); // RA_STK 1039 SWAP_DBLE (56); // DEC_STK 1040 SWAP_WORD (64); // RA_STK_ERR 1041 SWAP_WORD (68); // DEC_STK_ERR 1042 SWAP_WORD (72); // CHISQ_POS 1043 SWAP_WORD (76); // CHISQ_PM 1044 SWAP_WORD (80); // CHISQ_PAP 1045 SWAP_WORD (84); // MEAN_EPOCH 1046 SWAP_WORD (88); // TIME_RANGE 1047 SWAP_WORD (92); // PSF_QF 1048 SWAP_WORD (96); // PSF_QF_PERF 1049 SWAP_WORD (100); // STARGAL_SEP 1050 SWAP_BYTE (104); // NUMBER_POS 1051 SWAP_BYTE (106); // NMEASURE 1052 SWAP_BYTE (108); // NMISSING 1053 SWAP_BYTE (110); // NLENSING 1054 SWAP_BYTE (112); // NLENSOBJ 1055 SWAP_BYTE (114); // NEXTEND 1056 SWAP_WORD (116); // OFF_MEASURE 1057 SWAP_WORD (120); // OFF_MISSING 1058 SWAP_WORD (124); // OFF_LENSING 1059 SWAP_WORD (128); // OFF_LENSOBJ 1060 SWAP_WORD (132); // OFF_EXTEND 1061 SWAP_WORD (136); // OFF_PARAMS 1062 SWAP_WORD (140); // REF_COLOR_BLUE 1063 SWAP_WORD (144); // REF_COLOR_RED 1064 SWAP_WORD (148); // FLAGS 1065 SWAP_WORD (152); // PHOTFLAGS_U 1066 SWAP_WORD (156); // PHOTFLAGS_L 1067 SWAP_WORD (160); // OBJ_ID 1068 SWAP_WORD (164); // CAT_ID 1069 SWAP_DBLE (168); // EXT_ID 1070 SWAP_DBLE (176); // EXT_ID_GC 1071 } 1072 # endif 1073 1074 return (TRUE); 1075 } 1076 1077 /*** add test of EXTNAME and header-defined columns? ***/ 1078 /* return internal structure representation */ 1079 Average_PS1_V5alt *gfits_table_get_Average_PS1_V5alt (FTable *ftable, off_t *Ndata, char *swapped) { 1080 1081 int Ncols; 1082 Average_PS1_V5alt *data; 1083 1084 Ncols = ftable[0].header[0].Naxis[0]; 1085 if (Ncols != 184) { 1086 fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, 184); 1087 return NULL; 1088 } 1089 1090 *Ndata = ftable[0].header[0].Naxis[1]; 1091 data = (Average_PS1_V5alt *) ftable[0].buffer; 1092 if ((swapped == NULL) || (*swapped == FALSE)) { 1093 if (!gfits_convert_Average_PS1_V5alt (data, sizeof (Average_PS1_V5alt), *Ndata)) { 1094 return NULL; 1095 } 1096 gfits_table_scale_data (ftable); 1097 if (swapped != NULL) *swapped = TRUE; 1098 } 1099 return (data); 1100 } 1101 1102 /****** alt secfilt **********/ 1103 1104 SecFilt *SecFilt_PS1_V5alt_ToInternal (SecFilt_PS1_V5alt *in, off_t Nvalues) { 1105 1106 off_t i; 1107 SecFilt *out; 1108 1109 ALLOCATE_ZERO (out, SecFilt, Nvalues); 1110 1111 for (i = 0; i < Nvalues; i++) { 1112 dvo_secfilt_init (&out[i]); 1113 1114 out[i].M = in[i].M; 1115 out[i].dM = in[i].dM; 1116 out[i].Map = in[i].Map; 1117 out[i].dMap = in[i].dMap; 1118 out[i].sMap = in[i].sMap; 1119 out[i].Mkron = in[i].Mkron; 1120 out[i].dMkron = in[i].dMkron; 1121 1122 out[i].Mstdev = in[i].Mstdev; 1123 out[i].Mmin = in[i].Mmin; 1124 out[i].Mmax = in[i].Mmax; 1125 out[i].Mchisq = in[i].Mchisq; 1126 1127 out[i].Ncode = in[i].Ncode; 1128 out[i].Nused = in[i].Nused; 1129 out[i].NusedKron = in[i].NusedKron; 1130 out[i].NusedAp = in[i].NusedAp; 1131 1132 out[i].flags = in[i].flags; 1133 1134 out[i].MpsfStk = in[i].MpsfStk; 1135 out[i].FpsfStk = in[i].FpsfStk; 1136 out[i].dFpsfStk = in[i].dFpsfStk; 1137 1138 out[i].MkronStk = in[i].MkronStk; 1139 out[i].FkronStk = in[i].FkronStk; 1140 out[i].dFkronStk = in[i].dFkronStk; 1141 1142 out[i].MapStk = in[i].MapStk; 1143 out[i].FapStk = in[i].FapStk; 1144 out[i].dFapStk = in[i].dFapStk; 1145 1146 out[i].stackPrmryOff = in[i].stackPrmryOff; 1147 out[i].stackBestOff = in[i].stackBestOff; 1148 1149 out[i].MpsfWrp = in[i].MpsfWrp; 1150 out[i].FpsfWrp = in[i].FpsfWrp; 1151 out[i].dFpsfWrp = in[i].dFpsfWrp; 1152 out[i].sFpsfWrp = in[i].sFpsfWrp; 1153 1154 out[i].MkronWrp = in[i].MkronWrp; 1155 out[i].FkronWrp = in[i].FkronWrp; 1156 out[i].dFkronWrp = in[i].dFkronWrp; 1157 out[i].sFkronWrp = in[i].sFkronWrp; 1158 1159 out[i].MapWrp = in[i].MapWrp; 1160 out[i].FapWrp = in[i].FapWrp; 1161 out[i].dFapWrp = in[i].dFapWrp; 1162 out[i].sFapWrp = in[i].sFapWrp; 1163 1164 out[i].NusedWrp = in[i].NusedWrp; 1165 out[i].NusedKronWrp = in[i].NusedKronWrp; 1166 out[i].NusedApWrp = in[i].NusedApWrp; 1167 1168 out[i].ubercalDist = in[i].ubercalDist; 1169 } 1170 return (out); 1171 } 1172 1173 int gfits_convert_SecFilt_PS1_V5alt (SecFilt_PS1_V5alt *data, off_t size, off_t nitems) { 1174 1175 off_t i; 1176 unsigned char *byte, tmp; 1177 1178 if (size != 160) { 1179 fprintf (stderr, "WARNING: mismatch in data types SecFilt_PS1_V5alt: "OFF_T_FMT" vs %d\n", size, 160); 1180 return (FALSE); 1181 } 1182 1183 /* provide initial values to avoid compiler warnings for non-BYTE_SWAP arch */ 1184 i = tmp = 0; 1185 byte = NULL; 1186 1187 # ifdef BYTE_SWAP 1188 byte = (unsigned char *) data; 1189 for (i = 0; i < nitems; i++, byte += 160) { 1190 /** BYTE SWAP **/ 1191 SWAP_WORD (0); // MAG 1192 SWAP_WORD (4); // MAG_ERR 1193 SWAP_WORD (8); // MAG_AP 1194 SWAP_WORD (12); // MAG_AP_ERR 1195 SWAP_WORD (16); // MAG_AP_STDEV 1196 SWAP_WORD (20); // MAG_KRON 1197 SWAP_WORD (24); // MAG_KRON_ERR 1198 SWAP_WORD (28); // MAG_KRON_STDEV 1199 SWAP_WORD (32); // MAG_STDEV 1200 SWAP_WORD (36); // MAG_MIN 1201 SWAP_WORD (40); // MAG_MAX 1202 SWAP_WORD (44); // MAG_CHI 1203 SWAP_BYTE (48); // NCODE 1204 SWAP_BYTE (50); // NUSED 1205 SWAP_BYTE (52); // NUSED_KRON 1206 SWAP_BYTE (54); // NUSED_AP 1207 SWAP_WORD (56); // FLAGS 1208 SWAP_WORD (60); // MAG_PSF_STK 1209 SWAP_WORD (64); // FLUX_PSF_STK 1210 SWAP_WORD (68); // FLUX_PSF_STK_ERR 1211 SWAP_WORD (72); // MAG_KRON_STK 1212 SWAP_WORD (76); // FLUX_KRON_STK 1213 SWAP_WORD (80); // FLUX_KRON_STK_ERR 1214 SWAP_WORD (84); // MAG_AP_STK 1215 SWAP_WORD (88); // FLUX_AP_STK 1216 SWAP_WORD (92); // FLUX_AP_STK_ERR 1217 SWAP_WORD (96); // STACK_PRIMARY_OFF 1218 SWAP_WORD (100); // STACK_BEST_OFF 1219 SWAP_WORD (104); // MAG_PSF_WRP 1220 SWAP_WORD (108); // FLUX_PSF_WRP 1221 SWAP_WORD (112); // FLUX_PSF_WRP_ERR 1222 SWAP_WORD (116); // FLUX_PSF_WRP_STD 1223 SWAP_WORD (120); // MAG_KRON_WRP 1224 SWAP_WORD (124); // FLUX_KRON_WRP 1225 SWAP_WORD (128); // FLUX_KRON_WRP_ERR 1226 SWAP_WORD (132); // FLUX_KRON_WRP_STD 1227 SWAP_WORD (136); // MAG_AP_WRP 1228 SWAP_WORD (140); // FLUX_AP_WRP 1229 SWAP_WORD (144); // FLUX_AP_WRP_ERR 1230 SWAP_WORD (148); // FLUX_AP_WRP_STD 1231 SWAP_BYTE (152); // NUSED_WRP 1232 SWAP_BYTE (154); // NUSED_KRON_WRP 1233 SWAP_BYTE (156); // NUSED_AP_WRP 1234 SWAP_BYTE (158); // UBERCAL_DIST 1235 } 1236 # endif 1237 1238 return (TRUE); 1239 } 1240 1241 /*** add test of EXTNAME and header-defined columns? ***/ 1242 /* return internal structure representation */ 1243 SecFilt_PS1_V5alt *gfits_table_get_SecFilt_PS1_V5alt (FTable *ftable, off_t *Ndata, char *swapped) { 1244 1245 int Ncols; 1246 SecFilt_PS1_V5alt *data; 1247 1248 Ncols = ftable[0].header[0].Naxis[0]; 1249 if (Ncols != 160) { 1250 fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, 160); 1251 return NULL; 1252 } 1253 1254 *Ndata = ftable[0].header[0].Naxis[1]; 1255 data = (SecFilt_PS1_V5alt *) ftable[0].buffer; 1256 if ((swapped == NULL) || (*swapped == FALSE)) { 1257 if (!gfits_convert_SecFilt_PS1_V5alt (data, sizeof (SecFilt_PS1_V5alt), *Ndata)) { 1258 return NULL; 1259 } 1260 gfits_table_scale_data (ftable); 1261 if (swapped != NULL) *swapped = TRUE; 1262 } 1263 return (data); 1264 } 1265 1266 1267 Lensing *Lensing_PS1_V5_ALT_ToInternal (Lensing_PS1_V5_ALT *in, off_t Nvalues) { 1268 1269 off_t i; 1270 Lensing *out; 1271 1272 ALLOCATE_ZERO (out, Lensing, Nvalues); 1273 1274 for (i = 0; i < Nvalues; i++) { 1275 dvo_lensing_init (&out[i]); 1276 1277 out[i].X11_sm_obj = in[i].X11_sm_obj; 1278 out[i].X12_sm_obj = in[i].X12_sm_obj; 1279 out[i].X22_sm_obj = in[i].X22_sm_obj; 1280 out[i].E1_sm_obj = in[i].E1_sm_obj; 1281 out[i].E2_sm_obj = in[i].E2_sm_obj; 1282 1283 out[i].X11_sh_obj = in[i].X11_sh_obj; 1284 out[i].X12_sh_obj = in[i].X12_sh_obj; 1285 out[i].X22_sh_obj = in[i].X22_sh_obj; 1286 out[i].E1_sh_obj = in[i].E1_sh_obj; 1287 out[i].E2_sh_obj = in[i].E2_sh_obj; 1288 1289 out[i].X11_sm_psf = in[i].X11_sm_psf; 1290 out[i].X12_sm_psf = in[i].X12_sm_psf; 1291 out[i].X22_sm_psf = in[i].X22_sm_psf; 1292 out[i].E1_sm_psf = in[i].E1_sm_psf; 1293 out[i].E2_sm_psf = in[i].E2_sm_psf; 1294 1295 out[i].X11_sh_psf = in[i].X11_sh_psf; 1296 out[i].X12_sh_psf = in[i].X12_sh_psf; 1297 out[i].X22_sh_psf = in[i].X22_sh_psf; 1298 out[i].E1_sh_psf = in[i].E1_sh_psf; 1299 out[i].E2_sh_psf = in[i].E2_sh_psf; 1300 1301 out[i].F_ApR5 = in[i].F_ApR5; 1302 out[i].dF_ApR5 = in[i].dF_ApR5; 1303 out[i].sF_ApR5 = in[i].sF_ApR5; 1304 out[i].fF_ApR5 = in[i].fF_ApR5; 1305 1306 out[i].F_ApR6 = in[i].F_ApR6; 1307 out[i].dF_ApR6 = in[i].dF_ApR6; 1308 out[i].sF_ApR6 = in[i].sF_ApR6; 1309 out[i].fF_ApR6 = in[i].fF_ApR6; 1310 1311 out[i].detID = in[i].detID; 1312 out[i].objID = in[i].objID; 1313 out[i].catID = in[i].catID; 1314 1315 out[i].averef = in[i].averef; 1316 } 1317 return (out); 1318 } 1319 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_convert_elixir.c
r37035 r37822 210 210 211 211 for (i = 0; i < Nvalues; i++) { 212 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 212 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 213 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 214 out[i].coords.mosaic = NULL; 215 out[i].coords.offsetMap = NULL; 213 216 214 217 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN … … 280 283 281 284 for (i = 0; i < Nvalues; i++) { 282 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 285 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 286 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 283 287 284 288 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_convert_loneos.c
r37035 r37822 188 188 189 189 for (i = 0; i < Nvalues; i++) { 190 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 190 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 191 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 192 out[i].coords.mosaic = NULL; 193 out[i].coords.offsetMap = NULL; 191 194 192 195 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN … … 259 262 260 263 for (i = 0; i < Nvalues; i++) { 261 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 264 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 265 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 262 266 263 267 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c
r37035 r37822 227 227 228 228 for (i = 0; i < Nvalues; i++) { 229 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 229 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 230 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 231 out[i].coords.mosaic = NULL; 232 out[i].coords.offsetMap = NULL; 230 233 231 234 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN … … 297 300 298 301 for (i = 0; i < Nvalues; i++) { 299 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 302 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 303 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 300 304 301 305 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c
r37035 r37822 227 227 228 228 for (i = 0; i < Nvalues; i++) { 229 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 229 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 230 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 231 out[i].coords.mosaic = NULL; 232 out[i].coords.offsetMap = NULL; 230 233 231 234 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN … … 297 300 298 301 for (i = 0; i < Nvalues; i++) { 299 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 302 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 303 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 300 304 301 305 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_image.c
r37035 r37822 200 200 201 201 gfits_create_matrix (&db[0].header, &db[0].matrix); 202 gfits_table_set_Image (&db[0].ftable , NULL, 0);202 gfits_table_set_Image (&db[0].ftable); 203 203 204 204 gfits_modify (&db[0].header, "NIMAGES", "%d", 1, 0); … … 207 207 dvo_image_createID (&db[0].header); 208 208 209 if (db[0].format == DVO_FORMAT_INTERNAL) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "INTERNAL");209 // if (db[0].format == DVO_FORMAT_INTERNAL) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "INTERNAL"); 210 210 if (db[0].format == DVO_FORMAT_LONEOS) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "LONEOS"); 211 211 if (db[0].format == DVO_FORMAT_ELIXIR) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "ELIXIR"); … … 221 221 if (db[0].format == DVO_FORMAT_PS1_V5) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_V5"); 222 222 if (db[0].format == DVO_FORMAT_PS1_REF) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_REF"); 223 if (db[0].format == DVO_FORMAT_PS1_SIM) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_SIM"); 223 224 224 225 return; … … 267 268 } 268 269 270 int gfits_table_set_Image (FTable *ftable) { 271 272 Header *header; 273 274 header = ftable[0].header; 275 276 gfits_table_mkheader_Image (header); 277 278 /* create table */ 279 if (!gfits_create_table (header, ftable)) return (FALSE); 280 281 return (TRUE); 282 } 283 284 int gfits_table_mkheader_Image (Header *header) { 285 286 /* create table header */ 287 if (!gfits_create_table_header (header, "BINTABLE", "DVO_IMAGE")) return (FALSE); 288 289 /* define table layout */ 290 /** TABLE DEFINITION **/ 291 gfits_define_bintable_column (header, "D", "CRVAL1", "coordinate at reference pixel", "", 1.0, 0.0); 292 gfits_define_bintable_column (header, "D", "CRVAL2", "coordinate at reference pixel", "", 1.0, 0.0); 293 gfits_define_bintable_column (header, "E", "CRPIX1", "coordinate of reference pixel", "", 1.0, 0.0); 294 gfits_define_bintable_column (header, "E", "CRPIX2", "coordinate of reference pixel", "", 1.0, 0.0); 295 gfits_define_bintable_column (header, "E", "CDELT1", "degrees per pixel", "", 1.0, 0.0); 296 gfits_define_bintable_column (header, "E", "CDELT2", "degrees per pixel", "", 1.0, 0.0); 297 gfits_define_bintable_column (header, "E", "PC1_1", "rotation matrix", "", 1.0, 0.0); 298 gfits_define_bintable_column (header, "E", "PC1_2", "rotation matrix", "", 1.0, 0.0); 299 gfits_define_bintable_column (header, "E", "PC2_1", "rotation matrix", "", 1.0, 0.0); 300 gfits_define_bintable_column (header, "E", "PC2_2", "rotation matrix", "", 1.0, 0.0); 301 gfits_define_bintable_column (header, "14E", "POLYTERMS", "higher order warping terms", "", 1.0, 0.0); 302 if (sizeof(void *) == 4) { 303 gfits_define_bintable_column (header, "J", "POINTER1", "", "", 1.0, 0.0); 304 gfits_define_bintable_column (header, "J", "POINTER2", "", "", 1.0, 0.0); 305 } 306 if (sizeof(void *) == 8) { 307 gfits_define_bintable_column (header, "K", "POINTER1", "", "", 1.0, 0.0); 308 gfits_define_bintable_column (header, "K", "POINTER2", "", "", 1.0, 0.0); 309 } 310 gfits_define_bintable_column (header, "15A", "CTYPE", "coordinate type", "", 1.0, 0.0); 311 gfits_define_bintable_column (header, "A", "NPOLYTERMS", "order of polynomial", "", 1.0, 0.0); 312 gfits_define_bintable_column (header, "J", "TZERO", "readout time (row 0)", "", 1.0, 0.0); 313 gfits_define_bintable_column (header, "J", "NSTAR", "number of stars on image", "", 1.0, 0.0); 314 gfits_define_bintable_column (header, "E", "SECZ", "airmass", "mag", 1.0, 0.0); 315 gfits_define_bintable_column (header, "I", "NX", "image width", "", 1.0, 0.0); 316 gfits_define_bintable_column (header, "I", "NY", "image height", "", 1.0, 0.0); 317 gfits_define_bintable_column (header, "E", "APMIFIT", "aperture correction", "mag", 1.0, 0.0); 318 gfits_define_bintable_column (header, "E", "DAPMIFIT", "apmifit error", "mag", 1.0, 0.0); 319 gfits_define_bintable_column (header, "E", "MCAL", "calibration mag", "mag", 1.0, 0.0); 320 gfits_define_bintable_column (header, "E", "DMCAL", "error on Mcal", "mag", 1.0, 0.0); 321 gfits_define_bintable_column (header, "I", "XM", "image chisq", "10*log(value)", 1.0, 0.0); 322 gfits_define_bintable_column (header, "I", "PHOTCODE", "identifier for CCD,", "", 1.0, 0.0); 323 gfits_define_bintable_column (header, "E", "EXPTIME", "exposure time", "seconds", 1.0, 0.0); 324 gfits_define_bintable_column (header, "E", "ST", "sidereal time of exposure", "", 1.0, 0.0); 325 gfits_define_bintable_column (header, "E", "LAT", "observatory latitude", "degrees", 1.0, 0.0); 326 gfits_define_bintable_column (header, "E", "RA_CENTER", "image center", "degrees", 1.0, 0.0); 327 gfits_define_bintable_column (header, "E", "DEC_CENTER", "image center", "degrees", 1.0, 0.0); 328 gfits_define_bintable_column (header, "E", "RADIUS", "image radius", "degrees", 1.0, 0.0); 329 gfits_define_bintable_column (header, "E", "REF_COLOR_BLUE", "median astrometry ref color", "", 1.0, 0.0); 330 gfits_define_bintable_column (header, "E", "REF_COLOR_RED", "median astrometry ref color", "", 1.0, 0.0); 331 gfits_define_bintable_column (header, "117A", "NAME", "name of original image ", "", 1.0, 0.0); 332 gfits_define_bintable_column (header, "B", "DETECTION_LIMIT", "detection limit", "10*mag", 1.0, 0.0); 333 gfits_define_bintable_column (header, "B", "SATURATION_LIMIT", "saturation limit", "10*mag", 1.0, 0.0); 334 gfits_define_bintable_column (header, "B", "CERROR", "astrometric error", "50*arcsec", 1.0, 0.0); 335 gfits_define_bintable_column (header, "B", "FWHM_X", "PSF x width", "25*arcsec", 1.0, 0.0); 336 gfits_define_bintable_column (header, "B", "FWHM_Y", "PSF y width", "25*arcsec", 1.0, 0.0); 337 gfits_define_bintable_column (header, "B", "TRATE", "scan rate", "100 usec/pixel", 1.0, 0.0); 338 gfits_define_bintable_column (header, "B", "CCDNUM", "CCD ID number", "", 1.0, 0.0); 339 gfits_define_bintable_column (header, "J", "FLAGS", "image quality flags", "", 1.0, 0.0); 340 gfits_define_bintable_column (header, "J", "IMAGE_ID", "internal image ID", "", 1.0, 0.0); 341 gfits_define_bintable_column (header, "J", "PARENT_ID", "associated ref image", "", 1.0, 0.0); 342 gfits_define_bintable_column (header, "J", "EXTERN_ID", "external image ID", "", 1.0, 0.0); 343 gfits_define_bintable_column (header, "I", "SOURCE_ID", "analysis source ID", "", 1.0, 0.0); 344 gfits_define_bintable_column (header, "I", "NLINK_ASTROM", "mean number of matched measurements for astrometry", "", 1.0, 0.0); 345 gfits_define_bintable_column (header, "I", "NLINK_PHOTOM", "mean number of matched measurements for astrometry", "", 1.0, 0.0); 346 gfits_define_bintable_column (header, "I", "UBERCAL_DIST", "distance to nearest ubercal image", "", 1.0, 0.0); 347 gfits_define_bintable_column (header, "E", "XPIX_SYS_ERR", "systematic astrometry error in X", "", 1.0, 0.0); 348 gfits_define_bintable_column (header, "E", "YPIX_SYS_ERR", "systematic astrometry error in Y", "", 1.0, 0.0); 349 gfits_define_bintable_column (header, "E", "MAG_SYS_ERR", "systematic photometry error", "", 1.0, 0.0); 350 gfits_define_bintable_column (header, "I", "N_FIT_ASTROM", "number of stars used for astrometry cal", "", 1.0, 0.0); 351 gfits_define_bintable_column (header, "I", "N_FIT_PHOTOM", "number of stars used for photometry cal", "", 1.0, 0.0); 352 gfits_define_bintable_column (header, "J", "PHOTOM_MAP_ID", "reference to 2D zero point map", "", 1.0, 0.0); 353 gfits_define_bintable_column (header, "J", "ASTROM_MAP_ID", "reference to 2D astrometry map", "", 1.0, 0.0); 354 if (sizeof(void *) == 4) { 355 gfits_define_bintable_column (header, "J", "POINTER3", "", "", 1.0, 0.0); 356 } 357 if (sizeof(void *) == 8) { 358 gfits_define_bintable_column (header, "K", "POINTER3", "", "", 1.0, 0.0); 359 } 360 361 return (TRUE); 362 } 363 364 /* return internal structure representation */ 365 Image *gfits_table_get_Image (FTable *ftable, off_t *Ndata, char *swapped) { 366 367 int Ncols; 368 Image *data; 369 370 Ncols = ftable[0].header[0].Naxis[0]; 371 if (Ncols != sizeof(Image)) { 372 fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, (int) sizeof(Image)); 373 return NULL; 374 } 375 376 *Ndata = ftable[0].header[0].Naxis[1]; 377 data = (Image *) ftable[0].buffer; 378 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"); 384 } 385 386 return (data); 387 } 388 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_image_raw.c
r37035 r37822 61 61 if (db[0].format == DVO_FORMAT_PS1_V5) ImageSize = sizeof(Image_PS1_V5); 62 62 if (db[0].format == DVO_FORMAT_PS1_REF) ImageSize = sizeof(Image_PS1_REF); 63 if (db[0].format == DVO_FORMAT_PS1_SIM) ImageSize = sizeof(Image_PS1_SIM); 63 64 64 65 /* check that filesize makes sense */ … … 92 93 if (db[0].format == DVO_FORMAT_PS1_V5) gfits_table_mkheader_Image_PS1_V5 (&db[0].theader); 93 94 if (db[0].format == DVO_FORMAT_PS1_REF) gfits_table_mkheader_Image_PS1_REF (&db[0].theader); 95 if (db[0].format == DVO_FORMAT_PS1_SIM) gfits_table_mkheader_Image_PS1_SIM (&db[0].theader); 94 96 95 97 /* read data from file */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_photcode_ops.c
r37035 r37822 687 687 } 688 688 689 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt) { 690 691 int Ns; 692 float Mstdev; 689 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) { 693 690 694 691 if (code == NULL) return NAN; 695 692 696 Ns = photcodes[0].hashNsec[code[0].code]; 697 Mstdev = (Ns == -1) ? NAN : 0.001*secfilt[Ns].Mstdev; 693 int Ns = photcodes[0].hashNsec[code[0].code]; 694 if (Ns == -1) return (NAN); 695 696 float Mstdev = NAN; 697 switch (source) { 698 case MAG_SRC_CHP: 699 switch (class) { 700 case MAG_CLASS_PSF: 701 Mstdev = secfilt[Ns].Mstdev; 702 break; 703 case MAG_CLASS_KRON: 704 Mstdev = secfilt[Ns].sMkron; 705 break; 706 case MAG_CLASS_APER: 707 Mstdev = secfilt[Ns].sMap; 708 break; 709 default: 710 break; 711 } 712 break; 713 case MAG_SRC_WRP: 714 switch (class) { 715 case MAG_CLASS_PSF: 716 Mstdev = secfilt[Ns].sFpsfWrp; 717 break; 718 case MAG_CLASS_KRON: 719 Mstdev = secfilt[Ns].sFkronWrp; 720 break; 721 case MAG_CLASS_APER: 722 Mstdev = secfilt[Ns].sFapWrp; 723 break; 724 default: 725 break; 726 } 727 break; 728 case MAG_SRC_STK: 729 default: 730 break; 731 } 698 732 return (Mstdev); 733 } 734 735 int PhotNphot (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) { 736 737 if (code == NULL) return 0; 738 739 int Ns = photcodes[0].hashNsec[code[0].code]; 740 if (Ns == -1) return 0; 741 742 int Nphot = 0; 743 switch (source) { 744 case MAG_SRC_CHP: 745 switch (class) { 746 case MAG_CLASS_PSF: 747 Nphot = secfilt[Ns].Nused; 748 break; 749 case MAG_CLASS_KRON: 750 Nphot = secfilt[Ns].NusedKron; 751 break; 752 case MAG_CLASS_APER: 753 Nphot = secfilt[Ns].NusedAp; 754 break; 755 default: 756 break; 757 } 758 break; 759 case MAG_SRC_WRP: 760 switch (class) { 761 case MAG_CLASS_PSF: 762 Nphot = secfilt[Ns].NusedWrp; 763 break; 764 case MAG_CLASS_KRON: 765 Nphot = secfilt[Ns].NusedKronWrp; 766 break; 767 case MAG_CLASS_APER: 768 Nphot = secfilt[Ns].NusedApWrp; 769 break; 770 default: 771 break; 772 } 773 break; 774 case MAG_SRC_STK: 775 default: 776 break; 777 } 778 return (Nphot); 699 779 } 700 780 … … 783 863 } 784 864 785 unsigned int PhotStackID (PhotCode *code, Average *average, SecFilt *secfilt) {786 787 int Ns;788 unsigned int ID;789 790 if (code == NULL) return 0;791 792 Ns = photcodes[0].hashNsec[code[0].code];793 ID = (Ns == -1) ? 0 : secfilt[Ns].stackDetectID;794 return (ID);795 }865 // XX unsigned int PhotStackID (PhotCode *code, Average *average, SecFilt *secfilt) { 866 // XX 867 // XX int Ns; 868 // XX unsigned int ID; 869 // XX 870 // XX if (code == NULL) return 0; 871 // XX 872 // XX Ns = photcodes[0].hashNsec[code[0].code]; 873 // XX ID = (Ns == -1) ? 0 : secfilt[Ns].stackDetectID; 874 // XX return (ID); 875 // XX } 796 876 797 877 // Xm is now (2014.07.03) stored as the chisq except in dvo formats which use as short … … 1112 1192 } 1113 1193 return (Fave); 1194 } 1195 1196 float PhotFluxAveErr (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) { 1197 1198 if (code == NULL) return NAN; 1199 1200 int Ns = photcodes[0].hashNsec[code[0].code]; 1201 if (Ns == -1) return (NAN); 1202 1203 float dFave = NAN; 1204 switch (source) { 1205 case MAG_SRC_CHP: 1206 switch (class) { 1207 case MAG_CLASS_PSF: 1208 dFave = secfilt[Ns].dM * MagToFlux(secfilt[Ns].M); 1209 break; 1210 case MAG_CLASS_KRON: 1211 dFave = secfilt[Ns].dMkron * MagToFlux(secfilt[Ns].Mkron); 1212 break; 1213 case MAG_CLASS_APER: 1214 dFave = secfilt[Ns].dMap * MagToFlux(secfilt[Ns].Map); 1215 break; 1216 default: 1217 break; 1218 } 1219 break; 1220 case MAG_SRC_WRP: 1221 switch (class) { 1222 case MAG_CLASS_PSF: 1223 dFave = secfilt[Ns].dFpsfWrp; 1224 break; 1225 case MAG_CLASS_KRON: 1226 dFave = secfilt[Ns].dFkronWrp; 1227 break; 1228 case MAG_CLASS_APER: 1229 dFave = secfilt[Ns].dFapWrp; 1230 break; 1231 default: 1232 break; 1233 } 1234 break; 1235 case MAG_SRC_STK: 1236 switch (class) { 1237 case MAG_CLASS_PSF: 1238 dFave = secfilt[Ns].dFpsfStk; 1239 break; 1240 case MAG_CLASS_KRON: 1241 dFave = secfilt[Ns].dFkronStk; 1242 break; 1243 case MAG_CLASS_APER: 1244 dFave = secfilt[Ns].dFapStk; 1245 break; 1246 default: 1247 break; 1248 } 1249 break; 1250 default: 1251 break; 1252 } 1253 return (dFave); 1114 1254 } 1115 1255 … … 1648 1788 m2 = (Ns2 == -1) ? average[0].M : secfilt[Ns2].M; 1649 1789 */ 1790 1791 /*** lensing *********************************************************************************/ 1792 1793 # define LENSFIELD(NAME) \ 1794 float LensValue_##NAME (PhotCode *code, Lensobj *lensobj) { \ 1795 if (code == NULL) return NAN; \ 1796 int Ns = photcodes->hashNsec[code->code]; \ 1797 float value = (Ns == -1) ? NAN : lensobj[Ns].NAME; \ 1798 return (value); \ 1799 } 1800 1801 LENSFIELD(X11_sm_obj); 1802 LENSFIELD(X12_sm_obj); 1803 LENSFIELD(X22_sm_obj); 1804 LENSFIELD(E1_sm_obj); 1805 LENSFIELD(E2_sm_obj); 1806 1807 LENSFIELD(X11_sh_obj); 1808 LENSFIELD(X12_sh_obj); 1809 LENSFIELD(X22_sh_obj); 1810 LENSFIELD(E1_sh_obj); 1811 LENSFIELD(E2_sh_obj); 1812 1813 LENSFIELD(X11_sm_psf); 1814 LENSFIELD(X12_sm_psf); 1815 LENSFIELD(X22_sm_psf); 1816 LENSFIELD(E1_sm_psf); 1817 LENSFIELD(E2_sm_psf); 1818 1819 LENSFIELD(X11_sh_psf); 1820 LENSFIELD(X12_sh_psf); 1821 LENSFIELD(X22_sh_psf); 1822 LENSFIELD(E1_sh_psf); 1823 LENSFIELD(E2_sh_psf); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_tiny_values.c
r37035 r37822 20 20 measureT[0].dM = measure[0].dM; 21 21 measureT[0].airmass = measure[0].airmass; 22 measureT[0].RoffGAL = measure[0].RoffGAL; 23 measureT[0].DoffGAL = measure[0].DoffGAL; 22 24 measureT[0].Xccd = measure[0].Xccd; 23 25 measureT[0].Yccd = measure[0].Yccd; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/dvo_util.c
r33030 r37822 145 145 if ((image->externID == externID) && (image->sourceID == sourceID)) { 146 146 BuildChipMatch(dvoConfig->images, dvoConfig->nImages); 147 if (FindMosaicForImage(dvoConfig->images, dvoConfig->nImages, i)) { 148 return image; 149 } else { 150 fprintf(stderr, "FindMosaicForImage failed\n"); 151 return NULL; 152 } 147 return image; 153 148 } 154 149 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/flatcorr_io.c
r33963 r37822 183 183 } 184 184 185 // eddie uses cell_x = (int) (X + X_PAD) / (base + X_PAD) 186 // where base = 600, X_PAD = 8, Y_PAD = 10. denominator is thus (608,610), whic is (4880/8),(4864/8) 187 // these match Eddie's NCELL_X,Y / CHIP_DX,DY, so I think we are good with this: 188 189 # define X_PAD 8 190 # define Y_PAD 10 191 185 192 float FlatCorrectionOffset (FlatCorrectionTable *flatcorr, int ID, int X, int Y) { 186 193 … … 191 198 192 199 // convert X,Y to Xbin, Ybin: 193 int Xbin = MAX(MIN( X* flatcorr->image[seq].Nx / flatcorr->image[seq].DX, flatcorr->image[seq].Nx - 1), 0);194 int Ybin = MAX(MIN( Y* flatcorr->image[seq].Ny / flatcorr->image[seq].DY, flatcorr->image[seq].Ny - 1), 0);200 int Xbin = MAX(MIN((X + X_PAD) * flatcorr->image[seq].Nx / flatcorr->image[seq].DX, flatcorr->image[seq].Nx - 1), 0); 201 int Ybin = MAX(MIN((Y + Y_PAD) * flatcorr->image[seq].Ny / flatcorr->image[seq].DY, flatcorr->image[seq].Ny - 1), 0); 195 202 196 203 // XXX warn if X,Y are out of range? not super important unless *way* out of range -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/mosaic_astrom.c
r29938 r37822 1 1 # include <dvo.h> 2 3 // the block of code below was used to define the chip->mosaic relationship before this 4 // was assigned to the coords value 2 5 3 6 off_t getDISentry (e_time start, e_time stop, e_time *startMos, off_t *indexMos, off_t Nmosaic); 4 7 void SortDISindex (e_time *S, off_t *I, off_t N); 8 9 # if (0) 5 10 6 11 /* chip-match table: j = ChipMatch[i], images[j] is DIS for images[i] WRP */ … … 93 98 } 94 99 95 int BuildChipMatch_old (Image *images, off_t Nimages) { 100 // this is a very old version of BuildChipMatch which does not use bisection 101 int BuildChipMatch_nosort (Image *images, off_t Nimages) { 96 102 97 103 off_t i, j, NDIS; … … 140 146 } 141 147 142 int BuildChipMatch (Image *images, off_t Nimages) { 148 // this is an old version of BuildChipMatch which stores the results here in a local static variable 149 int BuildChipMatch_static (Image *images, off_t Nimages) { 143 150 144 151 off_t i, j, NDIS; … … 198 205 return (TRUE); 199 206 } 200 207 # endif 208 209 // XXX Note that this links (images[i].coords.mosaic, images[i].parent) will break 210 // if we reallocate the Image array in the middle of program 211 int BuildChipMatch (Image *images, off_t Nimages) { 212 213 off_t i, j, NDIS; 214 215 off_t Ndis = 0; 216 off_t *DISentry = NULL; 217 e_time *DIStzero = NULL; 218 219 if (DISentry != NULL) free (DISentry); 220 if (DIStzero != NULL) free (DIStzero); 221 222 // allocate containers for DIS indexing 223 Ndis = 0; 224 NDIS = 100; 225 ALLOCATE (DISentry, off_t, NDIS); 226 ALLOCATE (DIStzero, e_time, NDIS); 227 228 // find all DIS images, save tzero (& photcode?) 229 for (i = 0; i < Nimages; i++) { 230 if (strcmp(&images[i].coords.ctype[4], "-DIS")) continue; 231 DISentry[Ndis] = i; 232 DIStzero[Ndis] = images[i].tzero; 233 Ndis ++; 234 if (Ndis >= NDIS) { 235 NDIS += 100; 236 REALLOCATE (DISentry, off_t, NDIS); 237 REALLOCATE (DIStzero, e_time, NDIS); 238 } 239 } 240 241 // sort the index, start, and stop by the start times: 242 SortDISindex (DIStzero, DISentry, Ndis); 243 244 /* find all matched WRP images */ 245 for (i = 0; i < Nimages; i++) { 246 images[i].parent = NULL; // reset to NULL 247 images[i].coords.mosaic = NULL; // reset to NULL 248 if (strcmp(&images[i].coords.ctype[4], "-WRP")) continue; // only define link for WRP coords 249 250 j = getDISentry (images[i].tzero, images[i].tzero + (int) images[i].exptime, DIStzero, DISentry, Ndis); 251 if (j == -1) { 252 fprintf (stderr, "WARNING: can't find matching mosaic \n"); 253 continue; 254 } 255 if (j >= Nimages) myAbort("invalid DIS entry"); 256 images[i].parent = &images[j]; 257 images[i].coords.mosaic = &images[j].coords; 258 } 259 return (TRUE); 260 } 261 262 // use bisection to find the overlapping mosaic 201 263 off_t getDISentry (e_time start, e_time stop, e_time *startMos, off_t *indexMos, off_t Nmosaic) { 202 203 // use bisection to find the overlapping mosaic204 264 205 265 off_t Nlo, Nhi, N; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/skyregion_gsc.c
r34088 r37822 204 204 for (i = 0; i < Nregions; i++) { 205 205 strncpy (temp, &buffer[i*48], 48); 206 temp[4 9] = 0;206 temp[48] = 0; 207 207 hstgsc_hms_to_deg (&Rmin, &Rmax, &Dmin, &Dmax, &temp[7]); 208 208 if (Dmax < Dmin) SWAP (Dmin, Dmax); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libdvo/src/skyregion_ops.c
r35102 r37822 16 16 if (c) return (c+1); 17 17 return name; 18 } 19 20 /* find region which corresponds to the given index */ 21 SkyList *SkyRegionByIndex (SkyTable *table, int index) { 22 23 SkyList *list; 24 25 ALLOCATE (list, SkyList, 1); 26 ALLOCATE (list[0].regions, SkyRegion *, 1); 27 ALLOCATE (list[0].filename, char *, 1); 28 list[0].Nregions = 0; 29 list[0].ownElements = FALSE; // this list is only holding a view to the elements 30 strcpy (list[0].hosts, table[0].hosts); 31 32 list[0].regions[0] = &table[0].regions[index]; 33 list[0].filename[0] = table[0].filename[index]; 34 list[0].Nregions = 1; 35 return (list); 18 36 } 19 37 … … 250 268 } 251 269 252 if( Rmax > (Rmin+180.)) {253 254 double temp = Rmax;255 Rmax = Rmin;256 Rmin = temp;257 }258 259 270 list = SkyListByBounds (table, depth, Rmin, Rmax, Dmin, Dmax); 260 return (list); 261 } 262 271 272 // fprintf (stderr, "%s : %f - %f, %f - %f : %d\n", 273 // image->name, Rmin, Rmax, Dmin, Dmax, (int) list->Nregions); 274 275 return (list); 276 } 277 278 // a region like -10 10 0 20 will become 350 10 0 20 and return all regions on both sides of 0,360 263 279 SkyList *SkyListByBounds (SkyTable *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax) { 264 280 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libfits/Makefile
r34088 r37822 32 32 $(HEAD)/F_scan.$(ARCH).o $(HEAD)/F_print.$(ARCH).o \ 33 33 $(HEAD)/F_copy_H.$(ARCH).o $(HEAD)/F_delete.$(ARCH).o \ 34 $(HEAD)/F_read_XH.$(ARCH).o $(HEAD)/F_init_H.$(ARCH).o \ 35 $(HEAD)/F_convert_H.$(ARCH).o $(HEAD)/version.$(ARCH).o 34 $(HEAD)/F_find_H.$(ARCH).o $(HEAD)/F_init_H.$(ARCH).o \ 35 $(HEAD)/F_convert_H.$(ARCH).o $(HEAD)/F_read_XH.$(ARCH).o \ 36 $(HEAD)/version.$(ARCH).o 36 37 37 38 MATRIX_OBJ = \ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libfits/header/F_free_H.c
r7054 r37822 4 4 /*********************** fits free header ***********************************/ 5 5 void gfits_free_header (Header *header) { 6 7 // fprintf (stderr, "free data for %zx\n", (size_t) header->buffer); 6 8 7 9 if (header[0].buffer == (char *) NULL) return; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libfits/include/gfitsio.h
r37039 r37822 17 17 # define NEWLINE 10 /* UNIX RETURN character */ 18 18 # endif /* NEWLINE */ 19 20 /* gfits_bintable_format returns 'byte' as the type associated with one-byte logical (non-char) values */ 21 typedef char byte; 19 22 20 23 /********** FITS Constants *********/ … … 116 119 int gfits_modify_alt PROTO((Header *header, char *field, char *mode, int N,...)); 117 120 int gfits_print_alt PROTO((Header *header, char *field, char *mode, int N,...)); 121 int gfits_find_Xheader PROTO((FILE *f, Header *header, char *extname)); 118 122 int gfits_read_Xheader PROTO((char *filename, Header *header, int N)); 119 123 int gfits_read_header PROTO((char *filename, Header *header)); … … 184 188 int gfits_fread_ftable PROTO((FILE *f, FTable *ftable, char *extname)); 185 189 int gfits_fread_ftable_data PROTO((FILE *f, FTable *ftable, int padIfShort)); 186 int gfits_fread_ftable_range PROTO((FILE *f, FTable *ftable, off_t start, off_t Nrows));190 int gfits_fread_ftable_range PROTO((FILE *f, int padIfShort, FTable *ftable, off_t start, off_t Nrows)); 187 191 int gfits_fread_vtable PROTO((FILE *f, VTable *vtable, char *extname, off_t Nrow, off_t *row)); 188 192 int gfits_fread_vtable_range PROTO((FILE *f, VTable *vtable, off_t start, off_t Nrows)); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libfits/table/F_read_T.c
r29938 r37822 19 19 int gfits_fread_ftable (FILE *f, FTable *table, char *extname) { 20 20 21 int j, found;22 off_t Nbytes;23 21 Header *header; 24 char tname[80];25 22 26 23 header = table[0].header; 27 fseeko (f, 0, SEEK_SET); 28 29 found = FALSE; 30 for (j = -1; !found; j++) { 31 /* load data for this header */ 32 if (!gfits_load_header (f, header)) return (FALSE); 33 34 /* check if this is the correct extension or not */ 35 bzero (tname, 80); 36 gfits_scan (header, "EXTNAME", "%s", 1, tname); 37 if (!strcmp (tname, extname)) { 38 if (gfits_fread_ftable_data (f, table, FALSE)) return (TRUE); 39 gfits_free_header (header); 40 return (FALSE); 41 } 42 43 /* skip to next header */ 44 Nbytes = gfits_data_size (header); 45 fseeko (f, Nbytes, SEEK_CUR); 46 gfits_free_header (header); 47 } 48 return (TRUE); 49 } 24 if (!gfits_find_Xheader (f, header, extname)) return FALSE; 25 26 if (gfits_fread_ftable_data (f, table, FALSE)) return (TRUE); 27 gfits_free_header (header); 28 return (FALSE); 29 } 50 30 51 31 /*********************** fits read ftable data ***********************************/ … … 84 64 85 65 /*********************** fits read ftable data ***********************************/ 86 int gfits_fread_ftable_range (FILE *f, FTable *table, off_t start, off_t Nrows) {66 int gfits_fread_ftable_range (FILE *f, int padIfShort, FTable *table, off_t start, off_t Nrows) { 87 67 88 68 off_t Nbytes, Nread, Nskip, Nx, Ny; … … 109 89 if (ferror (f)) { 110 90 perror ("fits read error"); 91 free (table[0].buffer); 92 return (FALSE); 93 } 94 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; 111 100 } else { 112 fprintf (stderr, "unexpected eof\n"); 113 } 114 free (table[0].buffer); 115 return (FALSE); 101 free (table[0].buffer); 102 return (FALSE); 103 } 116 104 } 117 105 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libfits/table/F_write_T.c
r28241 r37822 95 95 96 96 // cursor must be at start of the table (after table header) 97 fseeko (f, Nskip, SEEK_CUR); 97 if (fseeko (f, Nskip, SEEK_CUR)) { 98 fprintf (stderr, "can't seek table start\n"); 99 return (FALSE); 100 } 101 98 102 Nwrite = fwrite (ftable[0].buffer, sizeof (char), Nbytes, f); 99 103 if (Nwrite != Nbytes) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libkapa/src/KapaWindow.c
r36488 r37822 98 98 graphdata[0].lweight = graphdata[0].size = 1.0; 99 99 100 graphdata[0].coords.pc1_1 = graphdata[0].coords.pc2_2 = 1.0; 101 graphdata[0].coords.pc1_2 = graphdata[0].coords.pc2_1 = 0.0; 102 strcpy (graphdata[0].coords.ctype, "DEC--LIN"); 103 graphdata[0].coords.crval1 = 0.0; 104 graphdata[0].coords.crval2 = 0.0; 105 graphdata[0].coords.crpix1 = 0.0; 106 graphdata[0].coords.crpix2 = 0.0; 107 graphdata[0].coords.cdelt1 = graphdata[0].coords.cdelt2 = 1.0; 108 graphdata[0].flipeast = TRUE; 100 InitCoords (&graphdata[0].coords, "DEC--LIN"); 101 graphdata[0].flipeast = TRUE; // default coords has EW flipped relative to sky 109 102 graphdata[0].flipnorth = FALSE; 110 103 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libohana/Makefile
r33646 r37822 35 35 $(SRC)/time.$(ARCH).o \ 36 36 $(SRC)/gaussj.$(ARCH).o \ 37 $(SRC)/spherical.$(ARCH).o \ 38 $(SRC)/vstats.$(ARCH).o \ 37 39 $(SRC)/config.$(ARCH).o \ 38 40 $(SRC)/Fread.$(ARCH).o \ … … 45 47 $(SRC)/gprint.$(ARCH).o \ 46 48 $(SRC)/version.$(ARCH).o 49 50 # $(SRC)/legendre.$(ARCH).o \ 51 # $(SRC)/gsl_utils.$(ARCH).o \ 47 52 48 53 TYPETEST = \ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libohana/include/ohana.h
r37033 r37822 192 192 193 193 # ifndef isfinite 194 # define isfinite(A) (!isnan(A) )194 # define isfinite(A) (!isnan(A) && !isinf(A)) 195 195 # endif 196 196 … … 242 242 // sorting is now defined as a macro call 243 243 # include <ohana_sort.h> 244 245 // vector statistics options 246 typedef enum { 247 VSTATS_NONE, 248 VSTATS_MEAN, 249 VSTATS_MEDIAN, 250 VSTATS_WT_MEAN, 251 VSTATS_INNER_MEAN, 252 VSTATS_INNER_WTMEAN, 253 VSTATS_CHI_INNER_MEAN, 254 VSTATS_CHI_INNER_WTMEAN 255 } VStatsMode; 256 257 typedef struct { 258 double median; 259 double mean; 260 double sigma; 261 double error; 262 double chisq; 263 double min; 264 double max; 265 double Upper80; 266 double Lower20; 267 double total; 268 int Nmeas; 269 VStatsMode statmode; 270 } VStatsType; 244 271 245 272 /* socket / pipe communication buffer */ … … 314 341 char *ohana_version PROTO((void)); 315 342 343 int dgaussjordan_pivot PROTO((double **A, double **B, int N, int M, double minPivot)); 316 344 int dgaussjordan PROTO((double **A, double **B, int N, int M)); 317 345 int fgaussjordan PROTO((float **A, float **B, int n, int m)); … … 388 416 int rconnect (char *command, char *hostname, char *shell, int *stdio, int *errorInfo, int doHandshake); 389 417 418 int vstats_setmode (VStatsType *stats, char *mode); 419 int vstats_getstats (double *value, double *dvalue, double *weight, int N, VStatsType *stats); 420 int vstats_getstats_f (float *value, float *dvalue, float *weight, int N, VStatsType *stats); 421 390 422 /* 391 423 # define F_SETFL 4 … … 404 436 */ 405 437 406 # endif 438 439 /** gsl-based functions for legendre and related polynomials **/ 440 441 double ohana_gsl_sf_log_1plusx (double x, double *err); 442 double ohana_gsl_sf_lnpoch(const double a, const double x, double *err); 443 double ohana_gsl_lnpoch_pos (const double a, const double x, double *err); 444 double ohana_gsl_pochrel_smallx(const double a, const double x, double *err); 445 446 double legendre_Pl (int l, double x, double *err); 447 double legendre_Plm (int l, int m, double x, double *err); 448 double legendre_Plm_sphere(int l, int m, double x, double *err); 449 450 typedef struct { 451 double *Fr; 452 double *Fi; 453 int *l; 454 int *m; 455 int lmax; 456 int Nterms; 457 } SHterms; 458 459 SHterms *SHtermsInit (int lmax); 460 void SHtermsFree (SHterms *terms); 461 void SHtermsForRD (SHterms *terms, double R, double D); 462 void SHtermsForLM (SHterms *terms, double R, double D, int l, int m); 463 464 typedef struct { 465 double *dR_B; 466 double *dR_E; 467 double *dD_B; 468 double *dD_E; 469 int *l; 470 int *m; 471 int lmax; 472 int Nterms; 473 } VSHterms; 474 475 VSHterms *VSHtermsInit (int lmax); 476 void VSHtermsFree (VSHterms *terms); 477 void VSHtermsForRD (VSHterms *terms, double R, double D); 478 void VSHtermsForLM (VSHterms *terms, double R, double D, int l, int m); 479 480 # endif -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libohana/src/gaussj.c
r36084 r37822 1 1 # include <ohana.h> 2 2 # define GROWTHTEST 0 3 # define MAX_RANGE 1.0e9 3 # define VERY_VERBOSE 0 4 # define MAX_RANGE 1.0e16 4 5 5 6 // Gauss-Jordan elimination using full pivots based on Press et al's description. Substantially … … 8 9 // than their implementation. (largely based on version by William Kahan) 9 10 11 int dgaussjordan (double **A, double **B, int N, int M) { 12 13 # define myMIN_PIVOT 1.0e-7 14 int status = dgaussjordan_pivot (A, B, N, M, myMIN_PIVOT); 15 return status; 16 } 17 10 18 // MAX_RANGE is used to test for ill-conditioned input matrices. For an ill-conditioned 11 19 // matrix, one or more of the pivots trends towards zero. Rather than allow this to go to the 12 20 // numerical precision, I am raising an error if |growth| > 1e8 13 int dgaussjordan (double **A, double **B, int N, int M) {21 int dgaussjordan_pivot (double **A, double **B, int N, int M, double MIN_PIVOT) { 14 22 15 23 int *colIndex; … … 48 56 // search for the next pivot 49 57 for (row = 0; row < N; row++) { 50 if (!finite(A[row][diag])) goto escape; 58 if (!finite(A[row][diag])) { 59 fprintf (stderr, "infinity\n"); 60 goto escape; 61 } 51 62 52 63 // if we have already operated on this row (pivot[row] is true), skip it … … 65 76 # if (GROWTHTEST) 66 77 fprintf (stderr, "maxcol: %d\n", maxcol); 78 # if (VERY_VERBOSE) 67 79 fprintf (stderr, "full A matrix:\n"); 68 80 for (row = 0; row < N; row++) { 69 for (col = 0; col < N; col++) {70 fprintf (stderr, "%10.3e ", A[row][col]);71 }72 fprintf (stderr, "\n");81 for (col = 0; col < N; col++) { 82 fprintf (stderr, "%10.3e ", A[row][col]); 83 } 84 fprintf (stderr, "\n"); 73 85 } 74 86 fprintf (stderr, "\n"); 75 87 # endif 88 # endif 76 89 77 90 // if pivot[maxcol] is set, we have already done this row: this implies a singular matrix 78 if (pivot[maxcol]) goto escape; 91 if (pivot[maxcol]) { 92 fprintf (stderr, "singular\n"); 93 goto escape; 94 } 79 95 pivot[maxcol] = TRUE; 80 96 … … 86 102 rowIndex[diag] = maxrow; 87 103 colIndex[diag] = maxcol; 88 if (A[maxcol][maxcol] == 0.0) goto escape; 104 if (A[maxcol][maxcol] == 0.0) { 105 fprintf (stderr, "zero pivot\n"); 106 goto escape; 107 } 108 89 109 // XXX Kahan replaces the 0.0 pivot with epsilon*(largest element in column) + underFlow 90 110 91 111 /* rescale by pivot reciprocal */ 92 112 double tmpval = 1.0 / A[maxcol][maxcol]; 113 114 # if (0) 115 if (fabs(A[maxcol][maxcol]) < MIN_PIVOT) { 116 // we are ill-conditioned. set this row & col to 0.0, 1.0 on pivot 117 // fprintf (stderr, "WARNING: eliminating degenerate pivot %lf @ A[%d][%d]\n", A[maxcol][maxcol], maxcol, maxcol); 118 for (col = 0; col < N; col++) A[maxcol][col] = 0.0; 119 for (col = 0; col < M; col++) B[maxcol][col] = 0.0; 120 for (row = 0; row < N; row++) A[row][maxcol] = 0.0; 121 A[maxcol][maxcol] = 1.0; 122 continue; 123 } 124 # endif 125 93 126 // XXX why is this here (don't I double count this element?) A[maxcol][maxcol] = 1.0; 94 127 A[maxcol][maxcol] = 1.0; … … 102 135 # if (GROWTHTEST) 103 136 fprintf (stderr, "column: %d, maxval : %f, growth: %e, epsilon: %e\n", maxcol, tmpval, growth, epsilon); 137 # if (VERY_VERBOSE) 104 138 fprintf (stderr, "A diagonal: "); 105 139 for (col = 0; col < N; col++) fprintf (stderr, "%f ", A[col][col]); 106 140 fprintf (stderr, "\n"); 107 141 # endif 108 109 if (fabs(growth) > MAX_RANGE) goto escape; 142 # endif 143 144 if (fabs(growth) > MAX_RANGE) { 145 fprintf (stderr, "max range\n"); 146 goto escape; 147 } 110 148 111 149 /* adjust the elements above the pivot */ … … 119 157 } 120 158 121 # if (GROWTHTEST) 122 fprintf (stderr, "final A matrix:\n"); 123 for (row = 0; row < N; row++) { 124 for (col = 0; col < N; col++) { 125 fprintf (stderr, "%10.3e ", A[row][col]); 126 } 127 fprintf (stderr, "\n"); 159 # if (GROWTHTEST && VERY_VERBOSE) 160 fprintf (stderr, "final A matrix:\n"); 161 for (row = 0; row < N; row++) { 162 for (col = 0; col < N; col++) { 163 fprintf (stderr, "%10.3e ", A[row][col]); 128 164 } 129 165 fprintf (stderr, "\n"); 166 } 167 fprintf (stderr, "\n"); 130 168 # endif 131 169 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libohana/src/glockfile.c
r35754 r37822 288 288 289 289 /* set value to IDLE */ 290 fseeko (flock, 0LL, SEEK_SET); 290 if (fseeko (flock, 0LL, SEEK_SET)) { 291 *state = LCK_HARDCLOSE; 292 goto failure; 293 } 294 291 295 nbytes = fprintf (flock, "IDLE\n"); 292 296 if (nbytes != 5) { … … 303 307 304 308 /* now unlock the file */ 305 fclose (f); 309 if (fclose (f)) { 310 *state = LCK_UNKNOWN; 311 goto failure; 312 } 306 313 307 314 *state = LCK_UNLOCK; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/libohana/src/ohana_allocate.c
r32632 r37822 178 178 if (!in) return; 179 179 180 // fprintf (stderr, "free %zx\n", (size_t) in); 181 180 182 ref = (Memblock *) in - 1; 183 184 // fprintf (stderr, " file: %s, line: %d, func: %s, size: %zd, addr: %zx\n", 185 // ref->file, ref->line, ref->func, ref->size, (size_t) ref); 181 186 182 187 pthread_mutex_lock(&memBlockListMutex); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/markrock/src/gcatstats.c
r36481 r37822 34 34 /* project onto rectilinear grid with 1 arcsec pixels, sort by X */ 35 35 /* reference for coords is center of field */ 36 InitCoords (&catstats[0].coords, "DEC--TAN"); 36 37 catstats[0].coords.crval1 = RaCenter; 37 38 catstats[0].coords.crval2 = DecCenter; 38 catstats[0].coords.crpix1 = catstats[0].coords.crpix2 = 0.0;39 39 catstats[0].coords.cdelt1 = catstats[0].coords.cdelt2 = 1.0 / 3600.0; 40 catstats[0].coords.pc1_1 = catstats[0].coords.pc2_2 = 1.0; 41 catstats[0].coords.pc1_2 = catstats[0].coords.pc2_1 = 0.0; 42 strcpy (catstats[0].coords.ctype, "DEC--TAN"); 43 40 44 41 X1 = catstats[0].X; 45 42 Y1 = catstats[0].Y; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/markstar/src/gcatstats.c
r36483 r37822 44 44 /* project onto rectilinear grid with 1 arcsec pixels, sort by X */ 45 45 /* reference for coords is center of field */ 46 InitCoords (&catstats[0].coords, "DEC--TAN"); 46 47 catstats[0].coords.crval1 = RaCenter; 47 48 catstats[0].coords.crval2 = DecCenter; 48 catstats[0].coords.crpix1 = catstats[0].coords.crpix2 = 0.0;49 49 catstats[0].coords.cdelt1 = catstats[0].coords.cdelt2 = 1.0 / 3600.0; 50 catstats[0].coords.pc1_1 = catstats[0].coords.pc2_2 = 1.0;51 catstats[0].coords.pc1_2 = catstats[0].coords.pc2_1 = 0.0;52 strcpy (catstats[0].coords.ctype, "DEC--TAN");53 50 54 51 X1 = catstats[0].X; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/mosastro/src/chips.c
r7401 r37822 21 21 22 22 /* bore site center guess */ 23 strcpy (chip[i].map.ctype, "DEC--PLY"); 24 chip[i].map.crpix1 = 0.0; 25 chip[i].map.crpix2 = 0.0; 26 chip[i].map.cdelt1 = 1.0; 27 chip[i].map.cdelt2 = 1.0; 23 InitCoords (&chip[i].map, "DEC--PLY"); 28 24 29 25 /* find (L,M) coords of reference pixel (0,0) */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/mosastro/src/fakefield.c
r3401 r37822 22 22 23 23 /* bore site center guess */ 24 strcpy (field.project.ctype, "DEC--TAN"); 25 field.project.crpix1 = 0; 26 field.project.crpix2 = 0; 24 InitCoords (&field.project, "DEC--TAN"); 27 25 28 26 /* set TP plate scale */ … … 30 28 field.project.cdelt2 = 1.0/3600.0; 31 29 32 /** allow guess at field rotation?? **/33 field.project.pc1_1 = 1;34 field.project.pc2_2 = 1;35 field.project.pc1_2 = 0;36 field.project.pc2_1 = 0;37 field.project.Npolyterms = 1;38 39 30 /** distort only has power in polyterms **/ 40 strcpy (field.distort.ctype, "DEC--PLY"); 41 field.distort.crval1 = 0.0; 42 field.distort.crval2 = 0.0; 43 field.distort.crpix1 = 0.0; 44 field.distort.crpix2 = 0.0; 45 field.distort.cdelt1 = 1.0; 46 field.distort.cdelt2 = 1.0; 47 48 field.distort.pc1_1 = 1; 49 field.distort.pc2_2 = 1; 50 field.distort.pc1_2 = 0; 51 field.distort.pc2_1 = 0; 52 53 /* how do we handle renormalization? (fixed at 1000 pixels??) */ 54 field.distort.Npolyterms = 3; 55 for (i = 0; i < 7; i++) { 56 field.distort.polyterms[i][0] = 0; 57 field.distort.polyterms[i][1] = 0; 58 } 31 InitCoords (&field.distort, "DEC--PLY"); 59 32 60 33 return (1); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/mosastro/src/field.c
r7401 r37822 12 12 13 13 /* bore site center guess */ 14 strcpy (field.project.ctype, "DEC--TAN");14 InitCoords (&field.project, "DEC--TAN"); 15 15 16 16 # if (PSASTRO_MODE) … … 23 23 # endif 24 24 25 field.project.crpix1 = 0;26 field.project.crpix2 = 0;27 28 25 /* measure average plate scale - would be better using parabolic min... */ 29 26 field.project.cdelt1 = 0; … … 47 44 3600*field.project.cdelt1, 3600*field.project.cdelt2); 48 45 49 /** allow guess at field rotation?? **/50 field.project.pc1_1 = 1;51 field.project.pc2_2 = 1;52 field.project.pc1_2 = 0;53 field.project.pc2_1 = 0;54 field.project.Npolyterms = 1;55 56 46 /* bore site center guess */ 57 strcpy (field.distort.ctype, "DEC--PLY"); 58 field.distort.crval1 = 0.0; 59 field.distort.crval2 = 0.0; 60 field.distort.crpix1 = 0.0; 61 field.distort.crpix2 = 0.0; 62 field.distort.cdelt1 = 1.0; 63 field.distort.cdelt2 = 1.0; 64 65 /** allow guess at field rotation?? **/ 66 field.distort.pc1_1 = 1; 67 field.distort.pc2_2 = 1; 68 field.distort.pc1_2 = 0; 69 field.distort.pc2_1 = 0; 70 71 /* allow 2nd and 3rd order? */ 72 /* how do we handle renormalization? (fixed at 1000 pixels??) */ 73 field.distort.Npolyterms = 1; 74 for (i = 0; i < 7; i++) { 75 field.distort.polyterms[i][0] = 0; 76 field.distort.polyterms[i][1] = 0; 77 } 47 InitCoords (&field.distort, "DEC--PLY"); 78 48 return (TRUE); 79 49 } … … 138 108 int load_field (char *filename) { 139 109 140 int i;141 110 Coords coords; 142 111 Header header; … … 156 125 157 126 /* bore site center guess */ 158 strcpy (field.project.ctype, "DEC--TAN");127 InitCoords (&field.project, "DEC--TAN"); 159 128 field.project.crval1 = 0.5*(field.Rmin + field.Rmax); 160 129 field.project.crval2 = 0.5*(field.Dmin + field.Dmax); 161 field.project.crpix1 = 0;162 field.project.crpix2 = 0;163 130 164 131 /* measure average plate scale - would be better using parabolic min... */ … … 174 141 175 142 /* bore site center guess */ 176 strcpy (field.distort.ctype, "DEC--PLY"); 177 field.distort.crval1 = 0.0; 178 field.distort.crval2 = 0.0; 179 field.distort.crpix1 = 0.0; 180 field.distort.crpix2 = 0.0; 181 field.distort.cdelt1 = 1.0; 182 field.distort.cdelt2 = 1.0; 183 184 /** allow guess at field rotation?? **/ 185 field.distort.pc1_1 = 1; 186 field.distort.pc2_2 = 1; 187 field.distort.pc1_2 = 0; 188 field.distort.pc2_1 = 0; 143 InitCoords (&field.distort, "DEC--PLY"); 189 144 190 /* allow 2nd and 3rd order? */191 /* how do we handle renormalization? (fixed at 1000 pixels??) */192 field.distort.Npolyterms = coords.Npolyterms;193 for (i = 0; i < 7; i++) {194 field.distort.polyterms[i][0] = coords.polyterms[i][0];195 field.distort.polyterms[i][1] = coords.polyterms[i][1];196 }197 145 return (TRUE); 198 146 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/mosastro/src/fitpoly.c
r16058 r37822 130 130 double R; 131 131 132 InitCoords (coords, "DEC--PLY"); 133 132 134 /* update the higher order terms */ 133 135 if (NORDER > 1) { … … 166 168 167 169 coords[0].Npolyterms = NORDER; 168 strcpy (coords[0].ctype, "DEC--PLY");169 170 } 170 171 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/mosastro/src/mkobs.c
r7080 r37822 104 104 105 105 /* Chip-Sky terms */ 106 strcpy (coords.ctype, "DEC--WRP");106 InitCoords (&coords, "DEC--WRP"); 107 107 coords.crval1 = Ro; 108 108 coords.crval2 = Do; … … 124 124 } 125 125 126 coords.pc1_1 = 1;127 coords.pc2_2 = 1;128 coords.pc1_2 = 0;129 coords.pc2_1 = 0;130 coords.Npolyterms = 1;131 132 126 header = mkheader (2*dX, 2*dY, Nstars, &coords); 133 127 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/mosastro/src/mkstandards.c
r7080 r37822 32 32 33 33 /* bore site center guess */ 34 strcpy (coords.ctype, "DEC--TAN");34 InitCoords (&coords, "DEC--TAN"); 35 35 coords.crval1 = atof(argv[1]); 36 36 coords.crval2 = atof(argv[2]); 37 37 coords.crpix1 = dX; 38 38 coords.crpix2 = dX; 39 40 39 coords.cdelt1 = 1/3600.0; 41 40 coords.cdelt2 = 1/3600.0; 42 43 coords.pc1_1 = 1;44 coords.pc2_2 = 1;45 coords.pc1_2 = 0;46 coords.pc2_1 = 0;47 coords.Npolyterms = 1;48 41 49 42 if (Random) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/mosastro/src/testcoords.c
r3404 r37822 53 53 exit (1); 54 54 } 55 RegisterMosaic (&field.project); 55 56 chip[0].map.mosaic = &field.project; 56 57 strcpy (chip[0].map.ctype, "DEC--WRP"); 57 58 for (i = 0; i < chip[0].Nmatch; i++) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.astro/Makefile
r36489 r37822 71 71 $(SRC)/star.$(ARCH).o \ 72 72 $(SRC)/transform.$(ARCH).o \ 73 $(SRC)/vshimage.$(ARCH).o \ 74 $(SRC)/shimage.$(ARCH).o \ 73 75 $(SRC)/imsub.$(ARCH).o \ 74 76 $(SRC)/imfit.$(ARCH).o \ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.astro/cdensify.c
r36489 r37822 97 97 // generate the PSF in a local tangent plane 98 98 Coords coords; 99 coords.crpix1 = coords.crpix2 = 0.0; 100 coords.crval1 = coords.crval2 = 0.0; 101 coords.cdelt1 = coords.cdelt2 = 1.0; 102 coords.pc1_1 = coords.pc2_2 = 1.0; 103 coords.pc1_2 = coords.pc2_1 = 0.0; 104 coords.Npolyterms = 0; 105 strcpy (coords.ctype, "DEC--TAN"); 99 InitCoords (&coords, "DEC--TAN"); 106 100 107 101 r = vr[0].elements.Flt; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.astro/coords.c
r33662 r37822 71 71 if ((mosbuffer = SelectBuffer (MOSAIC, OLDBUFFER, TRUE)) == NULL) goto escape; 72 72 GetCoords (&moscoords, &mosbuffer[0].header); 73 RegisterMosaic (&moscoords);73 coords.mosaic = &moscoords; 74 74 } 75 75 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.astro/cplot.c
r34613 r37822 4 4 5 5 double ra_prev = 0; 6 int i, kapa, Npts, status, leftside ;6 int i, kapa, Npts, status, leftside, valid, size; 7 7 opihi_flt *x, *y, *r, *d, Rmin, Rmax, Rmid; 8 8 Vector Xvec, Yvec, *xvec, *yvec; … … 11 11 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 12 12 13 if (argc != 3) { 13 valid = (argc == 3); 14 valid |= (argc > 4) && !strcmp (argv[3], "where"); 15 if (!valid) { 14 16 gprint (GP_ERR, "USAGE: cplot <ra> <dec> [style]\n"); 17 gprint (GP_ERR, " OR: cplot <ra> <dec> [style] where (condition)\n"); 15 18 return (FALSE); 16 19 } … … 32 35 } 33 36 37 // tvec is used for logical test (truth vector) 38 Vector *tvec = NULL; 39 if (argc > 4) { 40 char *out = dvomath (argc - 4, &argv[4], &size, 1); 41 if (out == NULL) { 42 print_error (); 43 return FALSE; 44 } 45 if ((tvec = SelectVector (out, OLDVECTOR, TRUE)) == NULL) { 46 gprint (GP_ERR, " invalid logic result\n"); 47 DeleteNamedVector (out); 48 free (out); 49 return (FALSE); 50 } 51 } 52 53 if (tvec && tvec[0].Nelements != yvec[0].Nelements) { 54 gprint (GP_ERR, "logic test vector not the same length as data vectors\n"); 55 DeleteVector (tvec); 56 return (FALSE); 57 } 58 34 59 SetVector (&Xvec, OPIHI_FLT, xvec[0].Nelements); 35 60 SetVector (&Yvec, OPIHI_FLT, xvec[0].Nelements); … … 42 67 Npts = 0; 43 68 for (i = 0; i < Xvec.Nelements; i++, r++, d++) { 69 if (tvec) { 70 int skip = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0); 71 if (skip) continue; 72 } 73 44 74 double ra = ohana_normalize_angle (*r); 45 75 while (ra < Rmin) ra += 360.0; … … 88 118 free (Yvec.elements.Ptr); 89 119 120 if (tvec) DeleteVector (tvec); 121 90 122 return (TRUE); 91 123 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.astro/csystem.c
r34342 r37822 13 13 if (argc != 5) goto syntax; 14 14 15 switch (argv[1][0]) { 16 case 'C': input = COORD_CELESTIAL; break; 17 case 'G': input = COORD_GALACTIC; break; 18 case 'E': input = COORD_ECLIPTIC; break; 19 default: goto syntax; 15 if (!strcmp(argv[1], "G2004")) { 16 input = COORD_GALACTIC_REID_2004; 17 } else { 18 switch (argv[1][0]) { 19 case 'C': input = COORD_CELESTIAL; break; 20 case 'G': input = COORD_GALACTIC; break; 21 case 'E': input = COORD_ECLIPTIC; break; 22 default: goto syntax; 23 } 20 24 } 21 25 22 switch (argv[2][0]) { 23 case 'C': output = COORD_CELESTIAL; break; 24 case 'G': output = COORD_GALACTIC; break; 25 case 'E': output = COORD_ECLIPTIC; break; 26 default: goto syntax; 26 if (!strcmp(argv[2], "G2004")) { 27 output = COORD_GALACTIC_REID_2004; 28 } else { 29 switch (argv[2][0]) { 30 case 'C': output = COORD_CELESTIAL; break; 31 case 'G': output = COORD_GALACTIC; break; 32 case 'E': output = COORD_ECLIPTIC; break; 33 default: goto syntax; 34 } 27 35 } 28 36 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.astro/fitplx.c
r36489 r37822 104 104 /* project coordinates to a plane centered on the object with units of arcsec */ 105 105 Coords coords; 106 InitCoords (&coords, "DEC--SIN"); 106 107 coords.crval1 = Rmean; 107 108 coords.crval2 = Dmean; 108 coords.crpix1 = 0;109 coords.crpix2 = 0;110 109 coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0; 111 coords.pc1_1 = coords.pc2_2 = 1.0;112 coords.pc1_2 = coords.pc2_1 = 0.0;113 coords.Npolyterms = 1;114 strcpy (coords.ctype, "DEC--SIN");115 110 116 111 double *X, *Y, *t, *pX, *pY, *dX, *dY; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.astro/fitpm.c
r36489 r37822 100 100 /* project coordinates to a plane centered on the object with units of arcsec */ 101 101 Coords coords; 102 InitCoords (&coords, "DEC--SIN"); 102 103 coords.crval1 = Rmean; 103 104 coords.crval2 = Dmean; 104 coords.crpix1 = 0;105 coords.crpix2 = 0;106 105 coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0; 107 coords.pc1_1 = coords.pc2_2 = 1.0;108 coords.pc1_2 = coords.pc2_1 = 0.0;109 coords.Npolyterms = 1;110 strcpy (coords.ctype, "DEC--SIN");111 106 112 107 double *X, *Y, *t, *dX, *dY; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.astro/gauss.c
r36679 r37822 30 30 if (!GetImageData (&data, &kapa, name)) return (FALSE); 31 31 FREE (name); 32 33 int channel = 0; 34 if ((N = get_argument (argc, argv, "-ch"))) { 35 channel = GetKapaChannelFromString (argv[N]); 36 if (!channel) return FALSE; 37 KiiSetChannel (kapa, channel - 1); 38 } 32 39 33 40 Nborder = 3; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.astro/getcoords.c
r34345 r37822 54 54 if (!strcmp(&coords.ctype[4], "-WRP")) { 55 55 if (MOSAIC == NULL) { 56 gprint (GP_ERR, "must supply mosaic for WRP coords \n");56 gprint (GP_ERR, "must supply mosaic for WRP coords with -mosaic [buffer]\n"); 57 57 return (FALSE); 58 58 } … … 65 65 } 66 66 GetCoords (&moscoords, &mosbuffer[0].header); 67 RegisterMosaic (&moscoords);67 coords.mosaic = &moscoords; 68 68 } 69 69 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.astro/init.c
r36489 r37822 61 61 int times PROTO((int, char **)); 62 62 int transform PROTO((int, char **)); 63 int vshimage PROTO((int, char **)); 64 int shimage PROTO((int, char **)); 63 65 64 66 static Command cmds[] = { … … 121 123 {1, "star", star, "star stats at rough coords"}, 122 124 {1, "transform", transform, "geometric transformation of image"}, 125 {1, "vshimage", vshimage, "generate images for vector spherical harmonic terms"}, 126 {1, "shimage", shimage, "generate images for spherical harmonic terms"}, 123 127 }; 124 128 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.astro/objload.c
r34088 r37822 19 19 if (!GetImage (NULL, &kapa, name)) return (FALSE); 20 20 FREE (name); 21 22 int channel = 0; 23 if ((N = get_argument (argc, argv, "-ch"))) { 24 channel = GetKapaChannelFromString (argv[N]); 25 if (!channel) return FALSE; 26 KiiSetChannel (kapa, channel - 1); 27 } 21 28 22 29 Objtype = 0; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.astro/region.c
r36489 r37822 17 17 if (!GetGraph (&graphmode, &kapa, name)) return (FALSE); 18 18 FREE (name); 19 20 int channel = 0; 21 if ((N = get_argument (argc, argv, "-ch"))) { 22 channel = GetKapaChannelFromString (argv[N]); 23 if (!channel) return FALSE; 24 KiiSetChannel (kapa, channel - 1); 25 } 19 26 20 27 NoClear = FALSE; … … 80 87 if (!ohana_str_to_radec (&Ra, &Dec, argv[1], argv[2])) return (FALSE); 81 88 Radius = atof (argv[3]); 82 strcpy (graphmode.coords.ctype, "DEC--TAN"); 89 InitCoords (&graphmode.coords, "DEC--TAN"); 90 83 91 if (argc == 5) { 84 92 if (!strcasecmp (argv[4], "TAN")) … … 99 107 strcpy (graphmode.coords.ctype, "DEC--PAR"); 100 108 } 109 110 graphmode.coords.crval1 = Ra; 111 graphmode.coords.crval2 = Dec; 101 112 102 113 graphmode.coords.pc1_1 = (graphmode.flipeast) ? -1 : 1; 114 graphmode.coords.pc2_2 = (graphmode.flipnorth) ? -1 : 1; 115 103 116 /* ask kapa for coordinate limits, to get the right aspect ratio */ 104 117 KapaGetLimits (kapa, &dx, &dy); … … 132 145 set_int_variable ("NORTH_UP", !graphmode.flipnorth); 133 146 134 graphmode.coords.pc1_1 = (graphmode.flipeast) ? -1 : 1;135 graphmode.coords.pc2_2 = (graphmode.flipnorth) ? -1 : 1;136 137 graphmode.coords.pc1_2 = graphmode.coords.pc2_1 = 0.0;138 graphmode.coords.crval1 = Ra;139 graphmode.coords.crval2 = Dec;140 graphmode.coords.crpix1 = 0.0;141 graphmode.coords.crpix2 = 0.0;142 graphmode.coords.cdelt1 = graphmode.coords.cdelt2 = 1.0;143 144 147 if (!NoClear) KapaClearSections (kapa); 145 148 KapaSetLimits (kapa, &graphmode); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/Makefile
r37049 r37822 39 39 $(SRC)/densify.$(ARCH).o \ 40 40 $(SRC)/device.$(ARCH).o \ 41 $(SRC)/dft2d.$(ARCH).o \ 41 42 $(SRC)/dimendown.$(ARCH).o \ 42 43 $(SRC)/dimenup.$(ARCH).o \ … … 160 161 $(SRC)/vstats.$(ARCH).o \ 161 162 $(SRC)/xsection.$(ARCH).o \ 163 $(SRC)/vsh.$(ARCH).o \ 164 $(SRC)/vshfit.$(ARCH).o \ 165 $(SRC)/shterms.$(ARCH).o \ 166 $(SRC)/shfit.$(ARCH).o \ 167 $(SRC)/shdot.$(ARCH).o \ 168 $(SRC)/shapply.$(ARCH).o \ 162 169 $(SRC)/wd.$(ARCH).o \ 163 170 $(SRC)/write_vectors.$(ARCH).o \ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/center.c
r29540 r37822 16 16 if (!GetImage (NULL, &kapa, name)) return (FALSE); 17 17 FREE (name); 18 19 int channel = 0; 20 if ((N = get_argument (argc, argv, "-ch"))) { 21 channel = GetKapaChannelFromString (argv[N]); 22 if (!channel) return FALSE; 23 KiiSetChannel (kapa, channel - 1); 24 } 18 25 19 26 // XXX need an option to center the image based on the current plot limits -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/dimenup.c
r20936 r37822 23 23 return (FALSE); 24 24 } 25 26 gfits_free_matrix (&buf[0].matrix); 27 gfits_free_header (&buf[0].header); 28 CreateBuffer (buf, Nx, Ny, -32, 0.0, 1.0); 25 ResetBuffer (buf, Nx, Ny, -32, 0.0, 1.0); 29 26 30 27 out = (float *) buf[0].matrix.buffer; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/erase.c
r13479 r37822 15 15 if (!GetImage (NULL, &kapa, name)) return (FALSE); 16 16 FREE (name); 17 18 int channel = 0; 19 if ((N = get_argument (argc, argv, "-ch"))) { 20 channel = GetKapaChannelFromString (argv[N]); 21 if (!channel) return FALSE; 22 KiiSetChannel (kapa, channel - 1); 23 } 17 24 18 25 if (argc < 2) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/fit2d.c
r31160 r37822 138 138 y = yvec[0].elements.Flt; 139 139 z = zvec[0].elements.Flt; 140 if (Weight) dz = dzvec[0].elements.Flt; 141 140 142 for (i = 0; i < xvec[0].Nelements; i++, x++, y++, z++) { 141 143 if (mask[i]) continue; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/init.c
r37049 r37822 1 1 # include "data.h" 2 // XXX adding a comment 2 3 3 4 int accum PROTO((int, char **)); … … 31 32 int densify PROTO((int, char **)); 32 33 int device PROTO((int, char **)); 34 int dft2d PROTO((int, char **)); 33 35 int dimendown PROTO((int, char **)); 34 36 int dimenup PROTO((int, char **)); … … 147 149 int vpop PROTO((int, char **)); 148 150 int vsmooth PROTO((int, char **)); 151 int vsh PROTO((int, char **)); 152 int vshfit PROTO((int, char **)); 153 int shterms PROTO((int, char **)); 154 int shfit PROTO((int, char **)); 155 int shdot PROTO((int, char **)); 156 int shapply PROTO((int, char **)); 149 157 int wd PROTO((int, char **)); 150 158 int write_vectors PROTO((int, char **)); … … 189 197 {1, "densify", densify, "create an image histogram from a set of vectors"}, 190 198 {1, "device", device, "set / get current graphics device"}, 199 {1, "dft2d", dft2d, "2D discrete fourier transform"}, 191 200 {1, "dimendown", dimendown, "convert image to vector"}, 192 201 {1, "dimenup", dimenup, "convert vector to image"}, … … 314 323 {1, "vstats", vstats, "statistics on a vector"}, 315 324 {1, "vzload", vzload, "load vectors as overlay on image display (scaled points)"}, 325 {1, "vsh", vsh, "Vector Spherical Harmonics"}, 326 {1, "vshfit", vshfit, "Vector Spherical Harmonics fits"}, 327 {1, "shterms", shterms, "Spherical Harmonics terms"}, 328 {1, "shfit", shfit, "Spherical Harmonics fits"}, 329 {1, "shdot", shdot, "Spherical Harmonics dot product"}, 330 {1, "shapply", shapply, "Spherical Harmonics fit application"}, 316 331 {1, "wd", wd, "write an image to a file"}, 317 332 {1, "write", write_vectors, "write vectors to datafile"}, -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/load.c
r34088 r37822 23 23 if (!GetImageData (&data, &kapa, name)) return (FALSE); 24 24 FREE (name); 25 26 int channel = 0; 27 if ((N = get_argument (argc, argv, "-ch"))) { 28 channel = GetKapaChannelFromString (argv[N]); 29 if (!channel) return FALSE; 30 KiiSetChannel (kapa, channel - 1); 31 } 25 32 26 33 ISCEL = FALSE; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/point.c
r15620 r37822 21 21 if (!GetImageData (&data, &kapa, name)) return (FALSE); 22 22 FREE (name); 23 24 int channel = 0; 25 if ((N = get_argument (argc, argv, "-ch"))) { 26 channel = GetKapaChannelFromString (argv[N]); 27 if (!channel) return FALSE; 28 KiiSetChannel (kapa, channel - 1); 29 } 23 30 24 31 celestial = FALSE; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/read_vectors.c
r37049 r37822 5 5 6 6 void read_vectors_cleanup (); 7 int read_table_sizes (Header *header); 7 8 8 9 int datafile (int argc, char **argv) { … … 331 332 332 333 off_t Nbytes; 333 int i, j, N, N extend, Ny, Binary, vecType, padIfShort;334 char type[16], ID[80] , *CCDKeyword;334 int i, j, N, Ny, Binary, vecType; 335 char type[16], ID[80]; 335 336 FTable table; 336 337 Header header; 337 338 Vector **vec; 338 int FITS_TRANSPOSE;339 339 340 340 table.buffer = NULL; 341 341 header.buffer = NULL; 342 342 343 FITS_TRANSPOSE = FALSE;343 int FITS_TRANSPOSE = FALSE; 344 344 if ((N = get_argument (argc, argv, "-transpose"))) { 345 345 remove_argument (N, &argc, argv); … … 347 347 } 348 348 349 CCDKeyword = NULL;349 char *CCDKeyword = NULL; 350 350 if ((N = get_argument (argc, argv, "-keyword"))) { 351 351 remove_argument (N, &argc, argv); … … 354 354 } 355 355 356 padIfShort = FALSE;356 int padIfShort = FALSE; 357 357 if ((N = get_argument (argc, argv, "-pad-if-short"))) { 358 358 remove_argument (N, &argc, argv); … … 360 360 } 361 361 362 Nextend = -1; 362 int getSizes = FALSE; 363 if ((N = get_argument (argc, argv, "-sizes"))) { 364 remove_argument (N, &argc, argv); 365 getSizes = TRUE; 366 } 367 368 int Nextend = -1; 363 369 if ((N = get_argument (argc, argv, "-extnum"))) { 364 370 remove_argument (N, &argc, argv); 365 371 Nextend = atoi (extname); 372 } 373 374 int start = 0; 375 int Nrows = -1; // -1 : read entire table 376 if ((N = get_argument (argc, argv, "-range"))) { 377 remove_argument (N, &argc, argv); 378 start = atoi (argv[N]); 379 remove_argument (N, &argc, argv); 380 Nrows = atoi (argv[N]); 381 remove_argument (N, &argc, argv); 382 } 383 384 // if CharAsVectors, char fields will be saved as vectors NAME:0 -- NAME:n for n characters 385 // else char fields will be saved as $NAME:0 - $NAME:m for m rows 386 // if (Ny > 10000), force CharAsVectors 387 int CharAsVectors = FALSE; 388 if ((N = get_argument (argc, argv, "-char-vectors"))) { 389 remove_argument (N, &argc, argv); 390 CharAsVectors = TRUE; 366 391 } 367 392 … … 397 422 } 398 423 if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension %d\n", Nextend); 399 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension %d\n", Nextend); 400 424 425 if (getSizes) { 426 read_table_sizes (&header); 427 if (CCDKeyword != NULL) free (CCDKeyword); 428 gfits_free_header (&header); 429 return TRUE; 430 } 431 432 if (Nrows == -1) { 433 Nrows = header.Naxis[1] - start; 434 } 435 if (start < 0) ESCAPE ("invalid range: start < 0\n"); 436 if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]); 437 if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n"); 438 if (start + Nrows > header.Naxis[1]) ESCAPE ("invalid range: start + Nrows > Ny (%d)\n", header.Naxis[1]); 439 440 // Ny = 100, start = 0, Nrows = -1 -> Nrows => 100 441 // Ny = 100, start = 10, Nrows = 90 442 443 if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend); 401 444 } else { 402 445 if (CCDKeyword == NULL) { … … 428 471 continue; 429 472 } 430 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension\n"); 473 474 if (Nrows == -1) { 475 Nrows = header.Naxis[1] - start; 476 } 477 if (start < 0) ESCAPE ("invalid range: start < 0\n"); 478 if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]); 479 if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n"); 480 if (start + Nrows > header.Naxis[1]) ESCAPE ("invalid range: start + Nrows > Ny (%d)\n", header.Naxis[1]); 481 482 if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend); 483 484 // if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension\n"); 485 431 486 break; 432 487 } … … 465 520 if (!FITS_TRANSPOSE) { 466 521 // read string column into a list rather than a vector 467 if (!strcmp (type, "char") ) {522 if (!strcmp (type, "char") && !CharAsVectors && (Ny < 3000)) { 468 523 char *fieldName = argv[i]; 469 524 char *Ptr = data; … … 537 592 if (vec) free (vec); 538 593 } 594 595 // read -fits foo -sizes -- Nx, Ny, Nfields -> $table:Nx, $table:Ny, $table:$Nfields 596 // read -fits foo -fields 597 598 int read_table_sizes (Header *header) { 599 600 int Nfields; 601 602 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 603 604 set_int_variable ("table:Nx", header->Naxis[0]); 605 set_int_variable ("table:Nx", header->Naxis[0]); 606 set_int_variable ("table:Nfields", Nfields); 607 608 return TRUE; 609 } 610 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/relocate.c
r27435 r37822 17 17 FREE (name); 18 18 19 int channel = 0; 20 if ((N = get_argument (argc, argv, "-ch"))) { 21 channel = GetKapaChannelFromString (argv[N]); 22 if (!channel) return FALSE; 23 KiiSetChannel (kapa, channel - 1); 24 } 25 19 26 if (argc != 3) { 20 27 gprint (GP_ERR, "USAGE: relocate x y [-n]\n"); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/resize.c
r29938 r37822 17 17 if (!GetImage (NULL, &kapa, name)) return (FALSE); 18 18 FREE (name); 19 20 int channel = 0; 21 if ((N = get_argument (argc, argv, "-ch"))) { 22 channel = GetKapaChannelFromString (argv[N]); 23 if (!channel) return FALSE; 24 KiiSetChannel (kapa, channel - 1); 25 } 19 26 20 27 if ((N = get_argument (argc, argv, "-by-image"))) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/save.c
r13479 r37822 16 16 FREE (name); 17 17 18 int channel = 0; 19 if ((N = get_argument (argc, argv, "-ch"))) { 20 channel = GetKapaChannelFromString (argv[N]); 21 if (!channel) return FALSE; 22 KiiSetChannel (kapa, channel - 1); 23 } 24 18 25 celestial = FALSE; 19 26 if ((N = get_argument (argc, argv, "-c"))) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/tv.c
r35757 r37822 18 18 if (!GetImage (&data, &kapa, name)) return (FALSE); 19 19 FREE (name); 20 21 int channel = 0; 22 if ((N = get_argument (argc, argv, "-ch"))) { 23 remove_argument (N, &argc, argv); 24 channel = GetKapaChannelFromString (argv[N]); 25 remove_argument (N, &argc, argv); 26 if (!channel) return FALSE; 27 KiiSetChannel (kapa, channel - 1); 28 } 20 29 21 30 /* shell exits on pipe close, FIX */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/tvchannel.c
r16038 r37822 22 22 } 23 23 24 Nchannel = atoi (argv[1]); 24 Nchannel = GetKapaChannelFromString (argv[1]); 25 if (!Nchannel) return FALSE; 26 27 KiiSetChannel (kapa, Nchannel - 1); 28 return (TRUE); 29 } 30 31 int GetKapaChannelFromString (char *string) { 32 33 int Nchannel = atoi (string); 25 34 if (Nchannel == 0) { 26 35 // try the string values R/Red, G/Green, B/Blue 27 if (!strcasecmp ( argv[1], "R") || !strcasecmp (argv[1], "RED")) {36 if (!strcasecmp (string, "R") || !strcasecmp (string, "RED")) { 28 37 Nchannel = 1; 29 38 } 30 if (!strcasecmp ( argv[1], "G") || !strcasecmp (argv[1], "GREEN")) {39 if (!strcasecmp (string, "G") || !strcasecmp (string, "GREEN")) { 31 40 Nchannel = 2; 32 41 } 33 if (!strcasecmp ( argv[1], "B") || !strcasecmp (argv[1], "BLUE")) {42 if (!strcasecmp (string, "B") || !strcasecmp (string, "BLUE")) { 34 43 Nchannel = 3; 35 44 } 36 45 } 37 if ((Nchannel < 1) || (Nchannel > 3)) { 38 gprint (GP_ERR, "invalid channel : use 1 - 3 or (R)ed, (G)reen, (B)lue\n"); 39 return (FALSE); 46 if ((Nchannel < 1) || (Nchannel > 10)) { 47 gprint (GP_ERR, "invalid channel : use 1 - 10 or (R)ed, (G)reen, (B)lue\n"); 48 gprint (GP_ERR, " (R)ed, (G)reen, (B)lue == (1,2,3)\n"); 49 return (0); 40 50 } 41 42 KiiSetChannel (kapa, Nchannel - 1); 43 return (TRUE); 51 return Nchannel; 44 52 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/tvcontour.c
r13479 r37822 71 71 if (!GetImage (NULL, &kapa, name)) return (FALSE); 72 72 FREE (name); 73 74 int channel = 0; 75 if ((N = get_argument (argc, argv, "-ch"))) { 76 channel = GetKapaChannelFromString (argv[N]); 77 if (!channel) return FALSE; 78 KiiSetChannel (kapa, channel - 1); 79 } 73 80 74 81 if ((argc != 4) && (argc != 5)) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/tvgrid.c
r13479 r37822 24 24 if (!GetImage (NULL, &kapa, name)) return (FALSE); 25 25 FREE (name); 26 27 int channel = 0; 28 if ((N = get_argument (argc, argv, "-ch"))) { 29 channel = GetKapaChannelFromString (argv[N]); 30 if (!channel) return FALSE; 31 KiiSetChannel (kapa, channel - 1); 32 } 26 33 27 34 if (argc != 3) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/vload.c
r20936 r37822 18 18 if (!GetImage (NULL, &kapa, name)) return (FALSE); 19 19 FREE (name); 20 21 int channel = 0; 22 if ((N = get_argument (argc, argv, "-ch"))) { 23 channel = GetKapaChannelFromString (argv[N]); 24 if (!channel) return FALSE; 25 KiiSetChannel (kapa, channel - 1); 26 } 20 27 21 28 type = KII_OVERLAY_BOX; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/cmd.data/vzload.c
r20936 r37822 18 18 if (!GetImage (NULL, &kapa, name)) return (FALSE); 19 19 FREE (name); 20 21 int channel = 0; 22 if ((N = get_argument (argc, argv, "-ch"))) { 23 channel = GetKapaChannelFromString (argv[N]); 24 if (!channel) return FALSE; 25 KiiSetChannel (kapa, channel - 1); 26 } 20 27 21 28 MAX_OUTPUT_SIZE = 10.0; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/Makefile
r37049 r37822 46 46 $(SRC)/badimages.$(ARCH).o \ 47 47 $(SRC)/catdir.$(ARCH).o \ 48 $(SRC)/catname.$(ARCH).o \ 48 49 $(SRC)/cmatch.$(ARCH).o \ 49 50 $(SRC)/cmpload.$(ARCH).o \ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/avextract.c
r37049 r37822 5 5 off_t i, j, n, m; 6 6 int N, Npts, NPTS, last, next, state, Nfields, Nreturn, Ncstack, Nstack; 7 int Nsecfilt, VERBOSE , needMeasures;7 int Nsecfilt, VERBOSE; 8 8 char **cstack, name[1024]; 9 9 void *Signal; … … 137 137 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results 138 138 if (PARALLEL && !HOST_ID) { 139 int status = HostTableParallelOps (skylist, argc, argv, RESULT_FILE, TRUE, 0, VERBOSE);139 int status = HostTableParallelOps (skylist, argc, argv, RESULT_FILE, TRUE, 0, VERBOSE); 140 140 141 141 dbFreeFields (fields, Nfields); … … 163 163 } 164 164 165 // check the requested fields : are all average/secfilt entries, or do we need measures? 166 needMeasures = FALSE; 167 for (i = 0; !needMeasures && (i < Nfields); i++) { 168 if (fields[i].photcode == NULL) continue; // non-measure fields do not have a photcode 169 if (fields[i].photcode[0].type == PHOT_REF) needMeasures = TRUE; 170 if (fields[i].photcode[0].type == PHOT_DEP) needMeasures = TRUE; 171 } 165 // check the requested fields 166 int needMeasure = dbFieldNeedMeasure (fields, Nfields); 167 int needLensobj = dbFieldNeedLensobj (fields, Nfields); 168 int needStarpar = dbFieldNeedStarpar (fields, Nfields, TRUE); 172 169 173 170 // grab data from all selected sky regions … … 189 186 catalog.filename = (HOST_ID || PARALLEL_LOCAL) ? hostfile : skylist[0].filename[i]; 190 187 catalog.catflags = LOAD_AVES | LOAD_SECF; 191 catalog.catflags |= needMeasures ? LOAD_MEAS : SKIP_MEAS; 188 catalog.catflags |= needMeasure ? LOAD_MEAS : SKIP_MEAS; 189 catalog.catflags |= needLensobj ? LOAD_LENSOBJ : SKIP_LENSOBJ; 190 catalog.catflags |= needStarpar ? LOAD_STARPAR : SKIP_STARPAR; 192 191 catalog.Nsecfilt = 0; 193 192 … … 205 204 // XXX for measure values, this could be optimized for one loop over measures... 206 205 207 m = catalog.average[j].measureOffset;208 209 206 dbExtractAveragesInitAve (); // reset counters for saved fields (costs very little) 210 207 208 Average *average = &catalog.average[j]; 209 210 m = average->measureOffset; 211 Measure *measure = needMeasure ? &catalog.measure[m] : NULL; 212 213 m = average->lensobjOffset; 214 Lensobj *lensobj = needLensobj ? &catalog.lensobj[m] : NULL; 215 216 m = average->starparOffset; 217 StarPar *starpar = needStarpar ? &catalog.starpar[m] : NULL; 218 219 m = j*Nsecfilt; 220 SecFilt *secfilt = &catalog.secfilt[m]; 221 211 222 for (n = 0; n < Nfields; n++) { 212 values[n] = dbExtractAverages ( &catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]);223 values[n] = dbExtractAverages (average, secfilt, measure, lensobj, starpar, &fields[n]); 213 224 } 214 225 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/avmatch.c
r37049 r37822 149 149 } 150 150 151 // check the requested fields : are all average/secfilt entries, or do we need measures? 152 int needMeasures = FALSE; 153 for (i = 0; !needMeasures && (i < Nfields); i++) { 154 if (fields[i].photcode == NULL) continue; // assert this? 155 if (fields[i].photcode[0].type == PHOT_REF) needMeasures = TRUE; 156 if (fields[i].photcode[0].type == PHOT_DEP) needMeasures = TRUE; 157 } 151 // check the requested fields 152 int needMeasure = dbFieldNeedMeasure (fields, Nfields); 153 int needLensobj = dbFieldNeedLensobj (fields, Nfields); 154 int needStarpar = dbFieldNeedStarpar (fields, Nfields, TRUE); 158 155 159 156 /* create output storage vectors */ … … 194 191 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 195 192 catalog.catflags = LOAD_AVES | LOAD_SECF; 196 catalog.catflags |= needMeasures ? LOAD_MEAS : SKIP_MEAS; 193 catalog.catflags |= needMeasure ? LOAD_MEAS : SKIP_MEAS; 194 catalog.catflags |= needLensobj ? LOAD_LENSOBJ : SKIP_LENSOBJ; 195 catalog.catflags |= needStarpar ? LOAD_STARPAR : SKIP_STARPAR; 197 196 catalog.Nsecfilt = 0; 198 197 … … 219 218 if (Ncat == -2) continue; // no matches to this point 220 219 221 m = catalog.average[Ncat].measureOffset; 220 m = Ncat; 221 Average *average = &catalog.average[m]; 222 223 m = average->measureOffset; 224 Measure *measure = needMeasure ? &catalog.measure[m] : NULL; 225 226 m = average->lensobjOffset; 227 Lensobj *lensobj = needLensobj ? &catalog.lensobj[m] : NULL; 228 229 m = average->starparOffset; 230 StarPar *starpar = needStarpar ? &catalog.starpar[m] : NULL; 231 232 m = Ncat*Nsecfilt; 233 SecFilt *secfilt = &catalog.secfilt[m]; 222 234 223 235 // reset counters for saved fields, extract fields 224 236 dbExtractAveragesInitAve (); 225 237 for (n = 0; n < Nfields; n++) { 226 values[n] = dbExtractAverages ( &catalog.average[Ncat], &catalog.secfilt[Ncat*Nsecfilt], &catalog.measure[m], &fields[n]);238 values[n] = dbExtractAverages (average, secfilt, measure, lensobj, starpar, &fields[n]); 227 239 } 228 240 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/cmpload.c
r34088 r37822 24 24 if (!GetImage (NULL, &kapa, name)) return (FALSE); 25 25 FREE (name); 26 27 int channel = 0; 28 if ((N = get_argument (argc, argv, "-ch"))) { 29 channel = GetKapaChannelFromString (argv[N]); 30 if (!channel) return FALSE; 31 KiiSetChannel (kapa, channel - 1); 32 } 26 33 27 34 Objtype = 0; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/dvo_host_utils.c
r35416 r37822 137 137 138 138 // determine the sky region 139 // XXX EAM 20141230 : this needs to respect the -region selection 139 140 double Rmin, Rmax, Dmin, Dmax; 140 141 get_skyregion (&Rmin, &Rmax, &Dmin, &Dmax); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/find_matches.c
r36489 r37822 38 38 * far from the projection pole. We use the center of the region (catalog) for crval1,2. 39 39 */ 40 InitCoords (&tcoords, "DEC--ARC"); 40 41 tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax); 41 42 if (region[0].Dmax < 90) { … … 44 45 tcoords.crval2 = 90.0; 45 46 } 46 tcoords.crpix1 = 0;47 tcoords.crpix2 = 0;48 47 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 49 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;50 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;51 tcoords.Npolyterms = 1;52 strcpy (tcoords.ctype, "DEC--ARC");53 48 54 49 // this region includes a boundary layer of size RADIUS -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/gimages.c
r36489 r37822 85 85 if ((image = LoadImagesDVO (&Nimage)) == NULL) return (FALSE); 86 86 image_subset (image, Nimage, &subset, &Nsubset, selection, tzero, trange, TimeSelect); 87 BuildChipMatch (image, Nimage);87 // BuildChipMatch (image, Nimage); 88 88 89 89 int DistortImage = wordhash ("-DIS"); … … 102 102 } 103 103 } 104 if (!FindMosaicForImage (image, Nimage, i)) continue;105 104 106 105 typehash = wordhash (&image[i].coords.ctype[4]); … … 129 128 if (fabs(Ro - Ra) > 120.0) continue; 130 129 130 InitCoords (&local, "DEC--TAN"); 131 131 local.crval1 = Ro; 132 132 local.crval2 = Do; 133 local.crpix1 = local.crpix2 = 0.0;134 133 local.cdelt1 = local.cdelt2 = 1.0/3600.0; 135 local.pc1_1 = local.pc2_2 = 1.0;136 local.pc2_1 = local.pc1_2 = 0.0;137 local.Npolyterms = 1;138 strcpy (local.ctype, "DEC--TAN");139 134 140 135 if (typehash == DistortImage) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/gstar.c
r37049 r37822 23 23 GSTAR_STACK_FLUX_KRON, 24 24 GSTAR_STACK_FLUX_KRON_ERR, 25 GSTAR_STACK_FLUX_APER, 26 GSTAR_STACK_FLUX_APER_ERR, 27 GSTAR_WARP_FLUX_PSF, 28 GSTAR_WARP_FLUX_PSF_ERR, 29 GSTAR_WARP_FLUX_KRON, 30 GSTAR_WARP_FLUX_KRON_ERR, 31 GSTAR_WARP_FLUX_APER, 32 GSTAR_WARP_FLUX_APER_ERR, 33 GSTAR_STACK_MAG_PSF, 34 GSTAR_STACK_MAG_PSF_ERR, 35 GSTAR_STACK_MAG_KRON, 36 GSTAR_STACK_MAG_KRON_ERR, 37 GSTAR_STACK_MAG_APER, 38 GSTAR_STACK_MAG_APER_ERR, 39 GSTAR_WARP_MAG_PSF, 40 GSTAR_WARP_MAG_PSF_ERR, 41 GSTAR_WARP_MAG_KRON, 42 GSTAR_WARP_MAG_KRON_ERR, 43 GSTAR_WARP_MAG_APER, 44 GSTAR_WARP_MAG_APER_ERR, 25 45 } GSTAR_SECF_CODES; 26 46 … … 31 51 void sort_index_float (float *X, int *IDX, int N) { 32 52 33 # define SWAPFUNC(A,B){ float tmp; int itmp; \34 tmp = X[A]; X[A] = X[B]; X[B] = tmp;\35 itmp = IDX[A]; IDX[A] = IDX[B]; IDX[B] = itmp;\36 }53 # define SWAPFUNC(A,B){ float tmp; int itmp; \ 54 tmp = X[A]; X[A] = X[B]; X[B] = tmp; \ 55 itmp = IDX[A]; IDX[A] = IDX[B]; IDX[B] = itmp; \ 56 } 37 57 # define COMPARE(A,B)(X[A] < X[B]) 38 58 … … 52 72 off_t i, Nstars, *N1; 53 73 off_t j, k, m, N, Nlo, Nhi; 54 int Nsecfilt, NPTS, QUIET, FULL_OUTPUT, STACK_OUTPUT,INST, SHOW_MASKS;74 int Nsecfilt, NPTS, QUIET, INST, SHOW_MASKS; 55 75 int found, GetMeasures; 56 76 int SaveVectors; … … 109 129 } 110 130 111 FULL_OUTPUT = FALSE;131 int FULL_OUTPUT = FALSE; 112 132 if ((N = get_argument (argc, argv, "-full"))) { 113 133 FULL_OUTPUT = TRUE; … … 115 135 } 116 136 117 STACK_OUTPUT = FALSE;118 if ((N = get_argument (argc, argv, " -stack"))) {137 int STACK_OUTPUT = FALSE; 138 if ((N = get_argument (argc, argv, "+stack"))) { 119 139 STACK_OUTPUT = TRUE; 140 remove_argument (N, &argc, argv); 141 } 142 143 int EXTRA_OUTPUT = FALSE; 144 if ((N = get_argument (argc, argv, "+extras"))) { 145 EXTRA_OUTPUT = TRUE; 146 remove_argument (N, &argc, argv); 147 } 148 149 int WARP_OUTPUT = FALSE; 150 if ((N = get_argument (argc, argv, "+warp"))) { 151 WARP_OUTPUT = TRUE; 152 remove_argument (N, &argc, argv); 153 } 154 155 int FLUX_OUTPUT = FALSE; 156 if ((N = get_argument (argc, argv, "+flux"))) { 157 FLUX_OUTPUT = TRUE; 158 remove_argument (N, &argc, argv); 159 } 160 161 int MAG_OUTPUT = TRUE; 162 if ((N = get_argument (argc, argv, "-mag"))) { 163 MAG_OUTPUT = FALSE; 164 remove_argument (N, &argc, argv); 165 } 166 167 int KRON_OUTPUT = FALSE; 168 if ((N = get_argument (argc, argv, "+kron"))) { 169 KRON_OUTPUT = TRUE; 170 remove_argument (N, &argc, argv); 171 } 172 173 int APER_OUTPUT = FALSE; 174 if ((N = get_argument (argc, argv, "+aper"))) { 175 APER_OUTPUT = TRUE; 120 176 remove_argument (N, &argc, argv); 121 177 } … … 185 241 // an error exit status here is a significant error 186 242 if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) { 187 fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);188 exit (2);243 fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename); 244 exit (2); 189 245 } 190 246 dvo_catalog_unlock (&catalog); … … 248 304 k = N1[i]; 249 305 if (!QUIET) { 250 gprint (GP_LOG, "star: "OFF_T_FMT"\n", i);306 gprint (GP_LOG, "star: "OFF_T_FMT"\n", k); 251 307 gprint (GP_LOG, "%11.7f ", catalog.average[k].R); 252 308 gprint (GP_LOG, "%11.7f ", catalog.average[k].D); … … 259 315 260 316 if (FULL_OUTPUT) { 261 gprint (GP_LOG, "%f ", catalog.average[k].dR);262 gprint (GP_LOG, "%f ", catalog.average[k].dD);263 gprint (GP_LOG, "%f ", catalog.average[k].uR);264 gprint (GP_LOG, "%f ", catalog.average[k].uD);265 gprint (GP_LOG, "%f ", catalog.average[k].duR);266 gprint (GP_LOG, "%f ", catalog.average[k].duD);267 gprint (GP_LOG, "%f ", catalog.average[k].P);268 gprint (GP_LOG, "%f ", catalog.average[k].dP);269 270 gprint (GP_LOG, "%f ", catalog.average[k].ChiSqPM);271 gprint (GP_LOG, "%f ", catalog.average[k].ChiSqPar);272 273 date = ohana_sec_to_date (catalog.average[k].Tmean);274 gprint (GP_LOG, "%20s ", date);275 gprint (GP_LOG, "%f ", catalog.average[k].Trange / 86400.0);317 gprint (GP_LOG, "%f ", catalog.average[k].dR); 318 gprint (GP_LOG, "%f ", catalog.average[k].dD); 319 gprint (GP_LOG, "%f ", catalog.average[k].uR); 320 gprint (GP_LOG, "%f ", catalog.average[k].uD); 321 gprint (GP_LOG, "%f ", catalog.average[k].duR); 322 gprint (GP_LOG, "%f ", catalog.average[k].duD); 323 gprint (GP_LOG, "%f ", catalog.average[k].P); 324 gprint (GP_LOG, "%f ", catalog.average[k].dP); 325 326 gprint (GP_LOG, "%f ", catalog.average[k].ChiSqPM); 327 gprint (GP_LOG, "%f ", catalog.average[k].ChiSqPar); 328 329 date = ohana_sec_to_date (catalog.average[k].Tmean); 330 gprint (GP_LOG, "%20s ", date); 331 gprint (GP_LOG, "%f ", catalog.average[k].Trange / 86400.0); 276 332 } 277 333 278 gprint (GP_LOG, "\n ");334 gprint (GP_LOG, "\n\n"); 279 335 280 336 /* filter names */ 337 gprint (GP_LOG, "filter : "); 281 338 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_FILTER_NAMES); 282 339 gprint (GP_LOG, "\n"); 283 340 284 341 /* average mags */ 342 gprint (GP_LOG, "chp_psf_ave: "); 285 343 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG); 286 344 gprint (GP_LOG, "\n"); 287 345 288 346 /* average mag errors */ 347 gprint (GP_LOG, "chp_psf_err: "); 289 348 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_ERR); 290 349 gprint (GP_LOG, "\n"); 291 350 292 351 /* average mag chisq */ 352 gprint (GP_LOG, "chp_psf_chi: "); 293 353 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_CHISQ); 294 354 gprint (GP_LOG, "\n"); 295 355 296 if (FULL_OUTPUT) { 356 357 if (APER_OUTPUT) { 297 358 /* Map */ 359 gprint (GP_LOG, "chp_ap__ave: "); 298 360 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_AP_MAG); 299 361 gprint (GP_LOG, "\n"); 300 362 } 363 364 if (KRON_OUTPUT) { 301 365 /* Mkron */ 366 gprint (GP_LOG, "chp_krn_ave: "); 302 367 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_KRON_MAG); 303 368 gprint (GP_LOG, "\n"); 304 369 305 370 /* dMkron */ 371 gprint (GP_LOG, "chp_krn_err: "); 306 372 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_KRON_MAG_ERR); 307 373 gprint (GP_LOG, "\n"); 308 374 } 375 376 if (EXTRA_OUTPUT) { 309 377 /* Mmin */ 378 gprint (GP_LOG, "chp_psf_min: "); 310 379 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_MIN); 311 380 gprint (GP_LOG, "\n"); 312 381 313 382 /* Mmax */ 383 gprint (GP_LOG, "chp_psf_max: "); 314 384 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_MAX);; 315 385 gprint (GP_LOG, "\n"); 316 386 317 387 /* UCDIST */ 388 gprint (GP_LOG, "ubercal_dst: "); 318 389 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_UCDIST);; 319 390 gprint (GP_LOG, "\n"); 320 391 321 392 /* secfilt flags */ 393 gprint (GP_LOG, "filtflags: "); 322 394 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_SECF_FLAGS); 323 395 gprint (GP_LOG, "\n"); 324 325 396 } 326 if (STACK_OUTPUT ) {397 if (STACK_OUTPUT && MAG_OUTPUT) { 327 398 /* FluxPSF */ 399 gprint (GP_LOG, "stk_psf_ave: "); 400 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_MAG_PSF); 401 gprint (GP_LOG, "\n"); 402 403 /* dFluxPSF */ 404 gprint (GP_LOG, "stk_psf_err: "); 405 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_MAG_PSF_ERR); 406 gprint (GP_LOG, "\n"); 407 408 if (KRON_OUTPUT) { 409 /* MagKron */ 410 gprint (GP_LOG, "stk_krn_ave: "); 411 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_MAG_KRON); 412 gprint (GP_LOG, "\n"); 413 414 /* dMagKron */ 415 gprint (GP_LOG, "stk_krn_err: "); 416 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_MAG_KRON_ERR); 417 gprint (GP_LOG, "\n"); 418 } 419 420 if (APER_OUTPUT) { 421 /* MagAper */ 422 gprint (GP_LOG, "stk_ap__ave: "); 423 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_MAG_APER); 424 gprint (GP_LOG, "\n"); 425 426 /* dMagAper */ 427 gprint (GP_LOG, "stk_ap__err: "); 428 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_MAG_APER_ERR); 429 gprint (GP_LOG, "\n"); 430 } 431 } 432 if (WARP_OUTPUT && MAG_OUTPUT) { 433 /* FluxPSF */ 434 gprint (GP_LOG, "wrp_psf_ave: "); 435 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_MAG_PSF); 436 gprint (GP_LOG, "\n"); 437 438 /* dFluxPSF */ 439 gprint (GP_LOG, "wrp_psf_err: "); 440 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_MAG_PSF_ERR); 441 gprint (GP_LOG, "\n"); 442 443 if (KRON_OUTPUT) { 444 /* MagKron */ 445 gprint (GP_LOG, "wrp_krn_ave: "); 446 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_MAG_KRON); 447 gprint (GP_LOG, "\n"); 448 449 /* dMagKron */ 450 gprint (GP_LOG, "wrp_krn_err: "); 451 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_MAG_KRON_ERR); 452 gprint (GP_LOG, "\n"); 453 454 } 455 456 if (APER_OUTPUT) { 457 /* MagAper */ 458 gprint (GP_LOG, "wrp_ap__ave: "); 459 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_MAG_APER); 460 gprint (GP_LOG, "\n"); 461 462 /* dMagAper */ 463 gprint (GP_LOG, "wrp_ap__err: "); 464 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_MAG_APER_ERR); 465 gprint (GP_LOG, "\n"); 466 } 467 } 468 if (STACK_OUTPUT && FLUX_OUTPUT) { 469 /* FluxPSF */ 470 gprint (GP_LOG, "stk_psf_ave: "); 328 471 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_PSF); 329 472 gprint (GP_LOG, "\n"); 330 473 331 474 /* dFluxPSF */ 475 gprint (GP_LOG, "stk_psf_err: "); 332 476 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_PSF_ERR); 333 477 gprint (GP_LOG, "\n"); 334 335 /* FluxKron */ 336 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_KRON); 337 gprint (GP_LOG, "\n"); 338 339 /* dFluxKron */ 340 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_KRON_ERR); 341 gprint (GP_LOG, "\n"); 342 478 479 if (KRON_OUTPUT) { 480 /* FluxKron */ 481 gprint (GP_LOG, "stk_krn_ave: "); 482 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_KRON); 483 gprint (GP_LOG, "\n"); 484 485 /* dFluxKron */ 486 gprint (GP_LOG, "stk_krn_err: "); 487 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_KRON_ERR); 488 gprint (GP_LOG, "\n"); 489 } 490 491 if (APER_OUTPUT) { 492 /* FluxAper */ 493 gprint (GP_LOG, "stk_ap_ave: "); 494 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_APER); 495 gprint (GP_LOG, "\n"); 496 497 /* dFluxAper */ 498 gprint (GP_LOG, "stk_ap_err: "); 499 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_APER_ERR); 500 gprint (GP_LOG, "\n"); 501 } 343 502 } 344 } 503 if (WARP_OUTPUT && FLUX_OUTPUT) { 504 /* FluxPSF */ 505 gprint (GP_LOG, "wrp_psf_ave: "); 506 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_FLUX_PSF); 507 gprint (GP_LOG, "\n"); 508 509 /* dFluxPSF */ 510 gprint (GP_LOG, "wrp_psf_ave: "); 511 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_FLUX_PSF_ERR); 512 gprint (GP_LOG, "\n"); 513 514 if (KRON_OUTPUT) { 515 /* FluxKron */ 516 gprint (GP_LOG, "wrp_krn_ave: "); 517 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_FLUX_KRON); 518 gprint (GP_LOG, "\n"); 519 520 /* dFluxKron */ 521 gprint (GP_LOG, "wrp_krn_err: "); 522 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_FLUX_KRON_ERR); 523 gprint (GP_LOG, "\n"); 524 } 525 526 if (APER_OUTPUT) { 527 /* FluxAper */ 528 gprint (GP_LOG, "wrp_ap__ave: "); 529 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_FLUX_APER); 530 gprint (GP_LOG, "\n"); 531 532 /* dFluxAper */ 533 gprint (GP_LOG, "wrp_ap__err: "); 534 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_FLUX_APER_ERR); 535 gprint (GP_LOG, "\n"); 536 } 537 } 538 } 539 gprint (GP_LOG, "\n"); 540 345 541 if (GetMeasures || SaveVectors) { 346 542 … … 413 609 414 610 if (FULL_OUTPUT) { 415 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Mcal);416 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Map);417 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Mkron);418 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].dMkron);419 gprint (GP_LOG, "%5.1f ", pow(10.0, 0.4*catalog.measure[Nv].dt));420 gprint (GP_LOG, "%5.3f ", catalog.measure[Nv].airmass);421 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].az);422 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].Xccd);423 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].Yccd);424 gprint (GP_LOG, "%3.1f ", FromShortPixels(catalog.measure[Nv].dXccd));425 gprint (GP_LOG, "%3.1f ", FromShortPixels(catalog.measure[Nv].dYccd));426 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].Sky);427 gprint (GP_LOG, "%5.1f ", catalog.measure[Nv].dSky);428 gprint (GP_LOG, "%8d ", catalog.measure[Nv].averef);429 gprint (GP_LOG, "0x%08x ", catalog.measure[Nv].detID);430 gprint (GP_LOG, "0x%08x ", catalog.measure[Nv].imageID);431 gprint (GP_LOG, "%.3f ", catalog.measure[Nv].psfQF);432 gprint (GP_LOG, "%.1f ", catalog.measure[Nv].psfChisq);433 gprint (GP_LOG, "%.1f ", catalog.measure[Nv].crNsigma);434 gprint (GP_LOG, "%.1f ", catalog.measure[Nv].extNsigma);435 gprint (GP_LOG, "%.1f ", FromShortDegrees(catalog.measure[Nv].theta));611 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Mcal); 612 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Map); 613 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Mkron); 614 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].dMkron); 615 gprint (GP_LOG, "%5.1f ", pow(10.0, 0.4*catalog.measure[Nv].dt)); 616 gprint (GP_LOG, "%5.3f ", catalog.measure[Nv].airmass); 617 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].az); 618 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].Xccd); 619 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].Yccd); 620 gprint (GP_LOG, "%3.1f ", FromShortPixels(catalog.measure[Nv].dXccd)); 621 gprint (GP_LOG, "%3.1f ", FromShortPixels(catalog.measure[Nv].dYccd)); 622 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].Sky); 623 gprint (GP_LOG, "%5.1f ", catalog.measure[Nv].dSky); 624 gprint (GP_LOG, "%8d ", catalog.measure[Nv].averef); 625 gprint (GP_LOG, "0x%08x ", catalog.measure[Nv].detID); 626 gprint (GP_LOG, "0x%08x ", catalog.measure[Nv].imageID); 627 gprint (GP_LOG, "%5.3f ", catalog.measure[Nv].psfQF); 628 gprint (GP_LOG, "%7.1f ", catalog.measure[Nv].psfChisq); 629 // gprint (GP_LOG, "%3.1f ", catalog.measure[Nv].crNsigma); 630 gprint (GP_LOG, "%4.1f ", catalog.measure[Nv].extNsigma); 631 gprint (GP_LOG, "%5.1f ", FromShortDegrees(catalog.measure[Nv].theta)); 436 632 } 437 if ( STACK_OUTPUT) {438 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].FluxPSF);439 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].dFluxPSF);440 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].FluxKron);441 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].dFluxKron);633 if (FLUX_OUTPUT) { 634 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].FluxPSF); 635 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].dFluxPSF); 636 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].FluxKron); 637 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].dFluxKron); 442 638 } 443 639 gprint (GP_LOG, "\n"); … … 547 743 548 744 switch (type) { 549 case GSTAR_AVE_MAG : /* averagemags */550 if (seq == -1) { 551 print_double (NAN); 552 } else { 553 print_double (secfilt[seq].M );554 } 555 break; 556 557 case GSTAR_AVE_MAG_ ERR: /* average mags errors */558 if (seq == -1) { 559 print_double (NAN); 560 } else { 561 print_double (secfilt[seq]. dM);745 case GSTAR_AVE_MAG_MIN: /* average ap mags */ 746 if (seq == -1) { 747 print_double (NAN); 748 } else { 749 print_double (secfilt[seq].Mmin); 750 } 751 break; 752 753 case GSTAR_AVE_MAG_MAX: /* average ap mags */ 754 if (seq == -1) { 755 print_double (NAN); 756 } else { 757 print_double (secfilt[seq].Mmax); 562 758 } 563 759 break; … … 592 788 break; 593 789 790 /*** CHIP : MAG ***/ 791 792 case GSTAR_AVE_MAG: /* average mags */ 793 if (seq == -1) { 794 print_double (NAN); 795 } else { 796 print_double (secfilt[seq].M); 797 } 798 break; 799 800 case GSTAR_AVE_MAG_ERR: /* average mags errors */ 801 if (seq == -1) { 802 print_double (NAN); 803 } else { 804 print_double (secfilt[seq].dM); 805 } 806 break; 807 594 808 case GSTAR_AVE_AP_MAG: /* average ap mags */ 595 809 if (seq == -1) { … … 600 814 break; 601 815 602 case GSTAR_AVE_MAG_MIN: /* average ap mags */603 if (seq == -1) {604 print_double (NAN);605 } else {606 print_double (secfilt[seq].Mmin);607 }608 break;609 610 case GSTAR_AVE_MAG_MAX: /* average ap mags */611 if (seq == -1) {612 print_double (NAN);613 } else {614 print_double (secfilt[seq].Mmax);615 }616 break;617 618 816 case GSTAR_AVE_KRON_MAG: /* average ap mags */ 619 817 if (seq == -1) { … … 632 830 break; 633 831 832 /******************* STACK : FLUX **********************/ 833 634 834 case GSTAR_STACK_FLUX_PSF: /* average ap mags */ 635 835 if (seq == -1) { … … 664 864 break; 665 865 866 case GSTAR_STACK_FLUX_APER: /* average ap mags */ 867 if (seq == -1) { 868 print_double (NAN); 869 } else { 870 print_double_exp (secfilt[seq].FapStk); 871 } 872 break; 873 874 case GSTAR_STACK_FLUX_APER_ERR: /* average ap mags */ 875 if (seq == -1) { 876 print_double (NAN); 877 } else { 878 print_double_exp (secfilt[seq].dFapStk); 879 } 880 break; 881 882 /******************* STACK : MAG **********************/ 883 884 case GSTAR_STACK_MAG_PSF: /* average ap mags */ 885 if (seq == -1) { 886 print_double (NAN); 887 } else { 888 print_double (secfilt[seq].MpsfStk); 889 } 890 break; 891 892 case GSTAR_STACK_MAG_PSF_ERR: /* average ap mags */ 893 if (seq == -1) { 894 print_double (NAN); 895 } else { 896 print_double (secfilt[seq].dFpsfStk / secfilt[seq].FpsfStk); 897 } 898 break; 899 900 case GSTAR_STACK_MAG_KRON: /* average ap mags */ 901 if (seq == -1) { 902 print_double (NAN); 903 } else { 904 print_double (secfilt[seq].MkronStk); 905 } 906 break; 907 908 case GSTAR_STACK_MAG_KRON_ERR: /* average ap mags */ 909 if (seq == -1) { 910 print_double (NAN); 911 } else { 912 print_double (secfilt[seq].dFkronStk / secfilt[seq].FkronStk); 913 } 914 break; 915 916 case GSTAR_STACK_MAG_APER: /* average ap mags */ 917 if (seq == -1) { 918 print_double (NAN); 919 } else { 920 print_double (secfilt[seq].MapStk); 921 } 922 break; 923 924 case GSTAR_STACK_MAG_APER_ERR: /* average ap mags */ 925 if (seq == -1) { 926 print_double (NAN); 927 } else { 928 print_double (secfilt[seq].dFapStk / secfilt[seq].FapStk); 929 } 930 break; 931 932 /******************* WARP : FLUX **********************/ 933 934 case GSTAR_WARP_FLUX_PSF: /* average ap mags */ 935 if (seq == -1) { 936 print_double (NAN); 937 } else { 938 print_double_exp (secfilt[seq].FpsfWrp); 939 } 940 break; 941 942 case GSTAR_WARP_FLUX_PSF_ERR: /* average ap mags */ 943 if (seq == -1) { 944 print_double (NAN); 945 } else { 946 print_double_exp (secfilt[seq].dFpsfWrp); 947 } 948 break; 949 950 case GSTAR_WARP_FLUX_KRON: /* average ap mags */ 951 if (seq == -1) { 952 print_double (NAN); 953 } else { 954 print_double_exp (secfilt[seq].FkronWrp); 955 } 956 break; 957 958 case GSTAR_WARP_FLUX_KRON_ERR: /* average ap mags */ 959 if (seq == -1) { 960 print_double (NAN); 961 } else { 962 print_double_exp (secfilt[seq].dFkronWrp); 963 } 964 break; 965 966 case GSTAR_WARP_FLUX_APER: /* average ap mags */ 967 if (seq == -1) { 968 print_double (NAN); 969 } else { 970 print_double_exp (secfilt[seq].FapWrp); 971 } 972 break; 973 974 case GSTAR_WARP_FLUX_APER_ERR: /* average ap mags */ 975 if (seq == -1) { 976 print_double (NAN); 977 } else { 978 print_double_exp (secfilt[seq].dFapWrp); 979 } 980 break; 981 982 /******************* WARP : MAG **********************/ 983 984 case GSTAR_WARP_MAG_PSF: /* average ap mags */ 985 if (seq == -1) { 986 print_double (NAN); 987 } else { 988 print_double (secfilt[seq].MpsfWrp); 989 } 990 break; 991 992 case GSTAR_WARP_MAG_PSF_ERR: /* average ap mags */ 993 if (seq == -1) { 994 print_double (NAN); 995 } else { 996 print_double (secfilt[seq].dFpsfWrp / secfilt[seq].FpsfWrp); 997 } 998 break; 999 1000 case GSTAR_WARP_MAG_KRON: /* average ap mags */ 1001 if (seq == -1) { 1002 print_double (NAN); 1003 } else { 1004 print_double (secfilt[seq].MkronWrp); 1005 } 1006 break; 1007 1008 case GSTAR_WARP_MAG_KRON_ERR: /* average ap mags */ 1009 if (seq == -1) { 1010 print_double (NAN); 1011 } else { 1012 print_double (secfilt[seq].dFkronWrp / secfilt[seq].FkronWrp); 1013 } 1014 break; 1015 1016 case GSTAR_WARP_MAG_APER: /* average ap mags */ 1017 if (seq == -1) { 1018 print_double (NAN); 1019 } else { 1020 print_double (secfilt[seq].MapWrp); 1021 } 1022 break; 1023 1024 case GSTAR_WARP_MAG_APER_ERR: /* average ap mags */ 1025 if (seq == -1) { 1026 print_double (NAN); 1027 } else { 1028 print_double (secfilt[seq].dFapWrp / secfilt[seq].FapWrp); 1029 } 1030 break; 1031 666 1032 } 667 1033 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/images.c
r34584 r37822 131 131 /* it is not an error for the database not to have any images */ 132 132 if ((image = LoadImagesDVO (&Nimage)) == NULL) return (TRUE); 133 BuildChipMatch (image, Nimage);133 // BuildChipMatch (image, Nimage); 134 134 135 135 if (SOLO_MOSAIC && photcode) { … … 152 152 SetVector (&Yvec, OPIHI_FLT, NPTS); 153 153 154 Image *mosaic = NULL; 155 154 156 ALLOCATE (plist, int, NPTS); 155 157 n = N = 0; … … 157 159 if (ByName && strncmp (image[i].name, name, strlen(name))) continue; 158 160 if (TimeSelect && ((image[i].tzero < tzero) || (image[i].tzero+image[i].trate*image[i].NY > tzero + trange))) continue; 159 if (!(Nmosaic = FindMosaicForImage (image, Nimage, i))) continue; 160 Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1 161 162 mosaic = image[i].parent; 163 Nmosaic = (SOLO_MOSAIC && mosaic) ? mosaic - image : -1; 164 161 165 if (photcode) { 162 166 if ( photcodeEquiv && (photcode[0].code != GetPhotcodeEquivCodebyCode(image[i].photcode))) continue; … … 170 174 typehash = wordhash (&image[i].coords.ctype[4]); 171 175 172 if (photcode && SOLO_MOSAIC ) {176 if (photcode && SOLO_MOSAIC && (Nmosaic >= 0)) { 173 177 // mosaic (DIS) images are not currently given a photcode : plot these via the WRP entries 174 178 /* DIS images represent a field, not a chip */ 175 179 if (typehash != ChipImage) continue; 176 180 if (foundMosaic[Nmosaic]) continue; 177 x[0] = -0.5* image[Nmosaic].NX; y[0] = -0.5*image[Nmosaic].NY;178 x[1] = +0.5* image[Nmosaic].NX; y[1] = -0.5*image[Nmosaic].NY;179 x[2] = +0.5* image[Nmosaic].NX; y[2] = +0.5*image[Nmosaic].NY;180 x[3] = -0.5* image[Nmosaic].NX; y[3] = +0.5*image[Nmosaic].NY;181 x[0] = -0.5*mosaic->NX; y[0] = -0.5*mosaic->NY; 182 x[1] = +0.5*mosaic->NX; y[1] = -0.5*mosaic->NY; 183 x[2] = +0.5*mosaic->NX; y[2] = +0.5*mosaic->NY; 184 x[3] = -0.5*mosaic->NX; y[3] = +0.5*mosaic->NY; 181 185 for (j = 0; j < Npts; j++) { 182 status = XY_to_RD (&r[j], &d[j], x[j], y[j], & image[Nmosaic].coords);186 status = XY_to_RD (&r[j], &d[j], x[j], y[j], &mosaic->coords); 183 187 if (!status) break; 184 188 r[j] = ohana_normalize_angle (r[j]); … … 198 202 199 203 /* DIS images represent a field, not a chip */ 200 if ((typehash == DistortImage) && !WITH_MOSAIC) continue; 201 if ((typehash != DistortImage) && SOLO_MOSAIC) continue; 204 if ((typehash == DistortImage) && !WITH_MOSAIC) continue; // do not plot the mosaic images 205 if ((typehash != DistortImage) && SOLO_MOSAIC) continue; // plot only the mosaic images 206 202 207 if (typehash == DistortImage) { 203 208 x[0] = -0.5*image[i].NX; y[0] = -0.5*image[i].NY; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/imbox.c
r34584 r37822 43 43 SetVector (&Yvec, OPIHI_FLT, NPTS); 44 44 45 mosaic.ctype[0] = 0; 46 45 47 while (gfits_fread_header (f, &header)) { 46 48 if (!GetCoords (&coords, &header)) goto skip; 47 49 if (!SOLO_PHU && !strcmp (&coords.ctype[4], "-DIS")) { 48 50 mosaic = coords; 49 RegisterMosaic (&mosaic);50 51 goto skip; 52 } 53 if (!strcmp (&coords.ctype[4], "-WRP")) { 54 if (!mosaic.ctype[0]) { 55 fprintf (stderr, "PHU mosaic not found\n"); 56 return FALSE; 57 } 58 coords.mosaic = &mosaic; 51 59 } 52 60 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/imdata.c
r37049 r37822 87 87 if ((image = LoadImagesDVO (&Nimage)) == NULL) return (FALSE); 88 88 image_subset (image, Nimage, &subset, &Nsubset, selection, tzero, trange, TimeSelect); 89 BuildChipMatch (image, Nimage);89 // BuildChipMatch (image, Nimage); 90 90 GetTimeFormat (&TimeReference, &TimeFormat); 91 91 … … 103 103 I = subset[i]; 104 104 105 if (!FindMosaicForImage (image, Nimage, I)) continue;106 105 skyset = SkyListByImage (sky, -1, &image[I]); 107 106 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/imdense.c
r34584 r37822 22 22 23 23 if ((image = LoadImagesDVO (&Nimage)) == NULL) return (FALSE); 24 BuildChipMatch (image, Nimage);24 // BuildChipMatch (image, Nimage); 25 25 26 26 Rmin = graphmode.coords.crval1 - 182.0; … … 42 42 /* project this image to screen display coords */ 43 43 status = FALSE; 44 if (!FindMosaicForImage (image, Nimage, i)) continue;45 44 XY_to_RD (&r, &d, x, y, &image[i].coords); 46 45 r = ohana_normalize_angle (r); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/imextract.c
r37049 r37822 90 90 91 91 if ((image = LoadImagesDVO (&Nimage)) == NULL) goto escape; 92 BuildChipMatch (image, Nimage);92 // BuildChipMatch (image, Nimage); 93 93 dbExtractImagesInit (); 94 94 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/imlist.c
r34088 r37822 38 38 } 39 39 40 // int RegionSelect = FALSE;41 // if ((N = get_argument (argc, argv, "-region"))) {42 // remove_argument (N, &argc, argv);43 // RegionSelect = TRUE;44 // }45 46 40 PhotcodeValue = NULL; 47 41 PhotcodeSelect = FALSE; … … 76 70 } 77 71 72 int MAX_LIST = -1; 73 if ((N = get_argument (argc, argv, "-max-list"))) { 74 remove_argument (N, &argc, argv); 75 MAX_LIST = atoi (argv[N]); 76 remove_argument (N, &argc, argv); 77 } 78 78 79 if (argc != 1) { 79 gprint (GP_ERR, "USAGE: image [-time start range] [-region] [-name string] \n");80 gprint (GP_ERR, "USAGE: image [-time start range] [-region] [-name string] [-photcode code] [-Nphotcode N] [-max-list N]\n"); 80 81 return (FALSE); 81 82 } … … 83 84 if ((image = LoadImagesDVO (&Nimage)) == NULL) return (FALSE); 84 85 image_subset (image, Nimage, &subset, &Nsubset, selection, tzero, trange, TimeSelect); 85 BuildChipMatch (image, Nimage);86 MAX_LIST = MAX_LIST < 0 ? Nsubset : MIN(MAX_LIST, Nsubset); 86 87 87 88 GetTimeFormat (&TimeReference, &TimeFormat); 88 89 89 for (j = 0; j < Nsubset; j++) {90 for (j = 0; j < MAX_LIST; j++) { 90 91 i = subset[j]; 91 92 if (NameSelect && (strstr (image[i].name, name) == (char *) NULL)) continue; … … 97 98 } 98 99 } 99 if (!FindMosaicForImage (image, Nimage, i)) continue;100 100 t = TimeValue (image[i].tzero, TimeReference, TimeFormat); 101 101 if (!strcmp(&image[i].coords.ctype[4], "-DIS")) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/imstats.c
r34584 r37822 31 31 32 32 if ((image = LoadImagesDVO (&Nimage)) == NULL) return (FALSE); 33 BuildChipMatch (image, Nimage);33 // BuildChipMatch (image, Nimage); 34 34 35 35 /* assign vector values */ … … 44 44 else 45 45 Yvec.elements.Flt[i] = image[i].dMcal; 46 if (!FindMosaicForImage (image, Nimage, i)) continue;47 46 XY_to_RD (&r, &d, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords); 48 47 gprint (GP_ERR, "%d %8.4f %8.4f %10d %6d %5.3f %6.3f %6.3f\n", -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/init.c
r37049 r37822 7 7 int calmextract PROTO((int, char **)); 8 8 int catlog PROTO((int, char **)); 9 int catname PROTO((int, char **)); 9 10 int catdir_define PROTO((int, char **)); 10 11 int ccd PROTO((int, char **)); … … 68 69 // {1, "calextract", calextract, "extract photometry calibration"}, 69 70 // {1, "calmextract", calmextract, "extract photometry calibration"}, 71 {1, "catname", catname, "list catalog files by name"}, 70 72 {1, "catdir", catdir_define,"re-define CATDIR"}, 71 73 // {1, "ccd", ccd, "plot color-color diagram"}, -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/mextract.c
r35416 r37822 211 211 } 212 212 213 // int needLensing = dbFieldNeedLensing (fields, Nfields); 214 int needStarpar = dbFieldNeedStarpar (fields, Nfields, FALSE); 215 213 216 // grab data from all selected sky regions 214 217 Signal = signal (SIGINT, handle_interrupt); … … 227 230 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 228 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; 229 234 catalog.Nsecfilt = Nsecfilt; 230 235 … … 259 264 // extract the relevant values for this measurement 260 265 dbExtractMeasuresInitMeas (); // reset counters for saved fields (costs very little 266 267 Average *average = &catalog.average[j]; 268 269 int Nstarpar = average->starparOffset; 270 StarPar *starpar = needStarpar ? &catalog.starpar[Nstarpar] : NULL; 271 272 // int Nlensing = average->lensobjOffset; 273 // Lensobj *lensobj = needLensobj ? &catalog.lensobj[m] : NULL; 274 275 int Nsec = j*Nsecfilt; 276 SecFilt *secfilt = &catalog.secfilt[Nsec]; 277 261 278 for (n = 0; n < Nfields; n++) { 262 values[n] = dbExtractMeasures ( &catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]);279 values[n] = dbExtractMeasures (average, secfilt, &catalog.measure[m], NULL, starpar, &fields[n]); 263 280 } 264 281 // fprintf (stderr, "object: ave: %f, cat: %f, averef %d\n", fields[n].name, values[2], values[3], catalog.measure[m].averef); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/mmatch.c
r35416 r37822 233 233 ALLOCATE (index, off_t, Nelem); 234 234 235 // int needLensing = dbFieldNeedLensing (fields, Nfields); 236 int needStarpar = dbFieldNeedStarpar (fields, Nfields, FALSE); 237 235 238 // grab data from all selected sky regions 236 239 Signal = signal (SIGINT, handle_interrupt); … … 246 249 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 247 250 catalog.catflags = LOAD_AVES | LOAD_SECF | LOAD_MEAS; 251 catalog.catflags |= needStarpar ? LOAD_STARPAR : SKIP_STARPAR; 248 252 catalog.Nsecfilt = Nsecfilt; 249 253 … … 282 286 // extract the relevant values for this measurement 283 287 dbExtractMeasuresInitMeas (); // reset counters for saved fields (costs very little 288 289 Average *average = &catalog.average[Ncat]; 290 291 int Nstarpar = average->starparOffset; 292 StarPar *starpar = needStarpar ? &catalog.starpar[Nstarpar] : NULL; 293 294 // int Nlensing = average->lensobjOffset; 295 // Lensobj *lensobj = needLensobj ? &catalog.lensobj[m] : NULL; 296 297 int Nsec = Ncat*Nsecfilt; 298 SecFilt *secfilt = &catalog.secfilt[Nsec]; 299 284 300 for (n = 0; n < Nfields; n++) { 285 values[n] = dbExtractMeasures ( &catalog.average[Ncat], &catalog.secfilt[Ncat*Nsecfilt], &catalog.measure[m], &fields[n]);301 values[n] = dbExtractMeasures (average, secfilt, &catalog.measure[m], NULL, starpar, &fields[n]); 286 302 } 287 303 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/mmextract.c
r35263 r37822 174 174 } 175 175 176 // int needLensing = dbFieldNeedLensing (fields, Nfields); 177 int needStarpar = dbFieldNeedStarpar (fields, Nfields, FALSE); 178 176 179 // grab data from all selected sky regions 177 180 Signal = signal (SIGINT, handle_interrupt); … … 213 216 // extract the relevant values for this measurement 214 217 dbExtractMeasuresInitMeas (); // reset counters for saved fields 218 219 Average *average = &catalog.average[j]; 220 221 int Nstarpar = average->starparOffset; 222 StarPar *starpar = needStarpar ? &catalog.starpar[Nstarpar] : NULL; 223 224 // int Nlensing = average->lensobjOffset; 225 // Lensobj *lensobj = needLensobj ? &catalog.lensobj[m] : NULL; 226 227 int Nsec = j*Nsecfilt; 228 SecFilt *secfilt = &catalog.secfilt[Nsec]; 229 215 230 for (n = 0; n < Nfields; n++) { 216 231 // values needs to be a pointer to a type with FLT and INT (with a union, we would save a bit of memory...) 217 values[n] = dbExtractMeasures ( &catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]);232 values[n] = dbExtractMeasures (average, secfilt, &catalog.measure[m], NULL, starpar, &fields[n]); 218 233 } 219 234 // fprintf (stderr, "object: ave: %f, cat: %f, averef %d\n", fields[n].name, values[2], values[3], catalog.measure[m].averef); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/objectcoverage.c
r34088 r37822 147 147 strcpy (buf[0].file, "(empty)"); 148 148 149 InitCoords (&coords, projection); 149 150 coords.crval1 = RaCenter; 150 151 coords.crval2 = DecCenter; 151 152 coords.crpix1 = 0.5*Nx; 152 153 coords.crpix2 = 0.5*Ny; 153 strcpy (coords.ctype, projection); 154 coords.pc1_1 = -1.0; 154 coords.pc1_1 = -1.0; // sky parity 155 155 coords.pc2_2 = +1.0; 156 coords.pc1_2 = 0.0;157 coords.pc2_1 = 0.0;158 156 coords.cdelt1 = coords.cdelt2 = pixscale; 159 coords.Npolyterms = 0;160 157 161 158 PutCoords (&coords, &buf[0].header); … … 166 163 for (xs = 0; xs < Nx; xs++) { 167 164 status = XY_to_RD (&r, &d, (double)(xs), (double)(ys), &coords); 168 status &= (r >= 0); 169 status &= (r <= 360); 165 r = ohana_normalize_angle (r); 170 166 if (status) { 171 167 V[ys*Nx + xs] = ShowDensity ? 0 : 2; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/showtile.c
r36489 r37822 28 28 29 29 /* reference for coords is this image */ 30 coords.crpix1 = coords.crpix2 = 0.0; 31 coords.crval1 = coords.crval2 = 0.0; 32 coords.cdelt1 = coords.cdelt2 = 1.0; 33 coords.pc1_1 = coords.pc2_2 = 1.0; 34 coords.pc1_2 = coords.pc2_1 = 0.0; 35 coords.Npolyterms = 0; 36 strcpy (coords.ctype, "DEC--TAN"); 30 InitCoords (&coords, "DEC--TAN"); 37 31 38 32 /* fill in top-left region */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/simage.c
r36489 r37822 42 42 } 43 43 /* get astrometry information */ 44 strcpy (coords.ctype, "NONE"); 45 gfits_scan (&header, "CTYPE2", "%s", 1, coords.ctype); 46 if (strcmp (coords.ctype, "DEC--PLY")) { 47 gprint (GP_ERR, "ERROR: wrong astrometric info in header\n"); 44 if (!GetCoords (&coords, &header)) { 45 gprint (GP_ERR, "ERROR: can't get coord info from header\n"); 48 46 return (FALSE); 49 47 } 50 gfits_scan (&header, "CDELT1", "%f", 1, &coords.cdelt1);51 gfits_scan (&header, "CDELT2", "%f", 1, &coords.cdelt2);52 gfits_scan (&header, "CRVAL1", "%lf", 1, &coords.crval1);53 gfits_scan (&header, "CRVAL2", "%lf", 1, &coords.crval2);54 gfits_scan (&header, "CRPIX1", "%f", 1, &coords.crpix1);55 gfits_scan (&header, "CRPIX2", "%f", 1, &coords.crpix2);56 gfits_scan (&header, "PC001001", "%f", 1, &coords.pc1_1);57 gfits_scan (&header, "PC001002", "%f", 1, &coords.pc1_2);58 gfits_scan (&header, "PC002001", "%f", 1, &coords.pc2_1);59 gfits_scan (&header, "PC002002", "%f", 1, &coords.pc2_2);60 /* RA Terms */61 gfits_scan (&header, "PCA1X2Y0", "%f", 1, &coords.polyterms[0][0]);62 gfits_scan (&header, "PCA1X1Y1", "%f", 1, &coords.polyterms[1][0]);63 gfits_scan (&header, "PCA1X0Y2", "%f", 1, &coords.polyterms[2][0]);64 gfits_scan (&header, "PCA1X3Y0", "%f", 1, &coords.polyterms[3][0]);65 gfits_scan (&header, "PCA1X2Y1", "%f", 1, &coords.polyterms[4][0]);66 gfits_scan (&header, "PCA1X1Y2", "%f", 1, &coords.polyterms[5][0]);67 gfits_scan (&header, "PCA1X0Y3", "%f", 1, &coords.polyterms[6][0]);68 /* Dec Terms */69 gfits_scan (&header, "PCA2X2Y0", "%f", 1, &coords.polyterms[0][1]);70 gfits_scan (&header, "PCA2X1Y1", "%f", 1, &coords.polyterms[1][1]);71 gfits_scan (&header, "PCA2X0Y2", "%f", 1, &coords.polyterms[2][1]);72 gfits_scan (&header, "PCA2X3Y0", "%f", 1, &coords.polyterms[3][1]);73 gfits_scan (&header, "PCA2X2Y1", "%f", 1, &coords.polyterms[4][1]);74 gfits_scan (&header, "PCA2X1Y2", "%f", 1, &coords.polyterms[5][1]);75 gfits_scan (&header, "PCA2X0Y3", "%f", 1, &coords.polyterms[6][1]);76 coords.Npolyterms = 2; /* how many do we use? */77 48 78 49 /* find number of stars */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/skycoverage.c
r33963 r37822 204 204 strcpy (buf[0].file, "(empty)"); 205 205 206 InitCoords (&coords, projection); 206 207 coords.crval1 = RaCenter; 207 208 coords.crval2 = DecCenter; 208 209 coords.crpix1 = 0.5*Nx; 209 210 coords.crpix2 = 0.5*Ny; 210 strcpy (coords.ctype, projection); 211 coords.pc1_1 = -1.0; 211 coords.pc1_1 = -1.0; // sky parity 212 212 coords.pc2_2 = +1.0; 213 coords.pc1_2 = 0.0;214 coords.pc2_1 = 0.0;215 213 coords.cdelt1 = coords.cdelt2 = pixscale; 216 coords.Npolyterms = 0;217 214 218 215 PutCoords (&coords, &buf[0].header); … … 222 219 return (FALSE); 223 220 } 224 BuildChipMatch (image, Nimage);221 // BuildChipMatch (image, Nimage); 225 222 226 223 V = (float *)buf[0].matrix.buffer; … … 230 227 for (xs = 0; xs < Nx; xs++) { 231 228 status = XY_to_RD (&r, &d, (double)(xs), (double)(ys), &coords); 232 status &= (r >= 0);233 status &= (r <= 360); 229 r = ohana_normalize_angle (r); 230 234 231 // are we in a part of the projection covering the sky or not? 235 232 if (status) { … … 284 281 } 285 282 } 286 287 if (!FindMosaicForImage (image, Nimage, i)) continue;288 283 289 284 typehash = wordhash (&image[i].coords.ctype[4]); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/dvo/subpix.c
r37049 r37822 115 115 /* load all images, extract those touching Ra, Dec */ 116 116 if ((image = LoadImagesDVO (&Nimage)) == NULL) return (FALSE); 117 BuildChipMatch (image, Nimage);117 // BuildChipMatch (image, Nimage); 118 118 119 119 for (i = 0; i < Nimage; i++) { 120 if (!FindMosaicForImage (image, Nimage, i)) continue;121 120 status = RD_to_XY (&X, &Y, Ra, Dec, &image[i].coords); 122 121 if (!status || (X < 0) || (X > image[i].NX) || (Y < 0) || (Y > image[i].NY)) continue; … … 134 133 for (i = 0; i < Nsub; i++) { 135 134 I = index[i]; 136 if (!FindMosaicForImage (image, Nimage, I)) continue;137 135 Timage = image[I].tzero; 138 136 for (j = 0; j < Nmeasure; j++) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/include/astro.h
r31635 r37822 12 12 void FreeAstro (void); 13 13 14 typedef struct {15 int isIdentity; // identity transformation16 double phi; // saved in radians17 double Xo; // saved in radians18 double xo; // saved in degrees19 double sin_phi_cos_Xo; // pre-computed values20 double sin_phi_sin_Xo; // pre-computed values21 double cos_phi_cos_Xo; // pre-computed values22 double cos_phi_sin_Xo; // pre-computed values23 double cos_phi; // pre-computed values24 double sin_phi; // pre-computed values25 double cos_Xo; // pre-computed values26 double sin_Xo; // pre-computed values27 } CoordTransform;28 29 #ifndef MOVED_TO_LIBDVO30 typedef enum {COORD_NONE, COORD_CELESTIAL, COORD_GALACTIC, COORD_ECLIPTIC} CoordTransformSystem;31 #endif32 33 CoordTransform *InitTransform (CoordTransformSystem input, CoordTransformSystem output);34 int ApplyTransform (double *x, double *y, double X, double Y, CoordTransform *transform);35 36 14 # endif -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/include/data.h
r36679 r37822 224 224 void ListMedImages (); 225 225 226 // in tvchannel.c 227 int GetKapaChannelFromString (char *string); 228 226 229 # endif -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/include/dvomath.h
r37049 r37822 187 187 int ListBuffersToList PROTO((char *name)); 188 188 int CreateBuffer PROTO((Buffer *buf, int Nx, int Ny, int bitpix, float bzero, float bscale)); 189 int ResetBuffer PROTO((Buffer *buf, int Nx, int Ny, int bitpix, float bzero, float bscale)); 189 190 Buffer *SelectBuffer PROTO((char *name, int mode, int verbose)); 190 191 void dump_buffers PROTO((int n)); /* deprecated? */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/lib.shell/BufferOps.c
r33662 r37822 88 88 } 89 89 90 int ResetBuffer (Buffer *buf, int Nx, int Ny, int bitpix, float bzero, float bscale) { 91 92 gfits_free_matrix (&buf[0].matrix); 93 gfits_free_header (&buf[0].header); 94 CreateBuffer (buf, Nx, Ny, bitpix, bzero, bscale); 95 return TRUE; 96 } 97 90 98 int CreateBuffer (Buffer *buf, int Nx, int Ny, int bitpix, float bzero, float bscale) { 91 99 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/pantasks/controller_status.c
r23530 r37822 3 3 int controller_status (int argc, char **argv) { 4 4 5 int status;6 char command[1024] ;5 int i, status; 6 char command[1024], tmpline[1024]; 7 7 IOBuffer buffer; 8 8 9 if (argc != 1) { 10 gprint (GP_ERR, "USAGE: controller status\n"); 9 if ((argc > 1) && (!strcasecmp(argv[1], "help"))) { 10 gprint (GP_ERR, "USAGE: controller status [options]\n"); 11 gprint (GP_ERR, " OPTIONS:\n"); 12 gprint (GP_ERR, " -cmd command\n"); 13 gprint (GP_ERR, " -host hostname\n"); 14 gprint (GP_ERR, " -state state\n"); 15 gprint (GP_ERR, " -age seconds\n"); 16 gprint (GP_ERR, " +jobs [-nohost]\n"); 17 gprint (GP_ERR, " +host [-nojobs]\n"); 11 18 return (FALSE); 12 19 } … … 19 26 } 20 27 28 snprintf (command, 1024, "status"); 29 for (i = 1; i < argc; i++) { 30 snprintf (tmpline, 1024, "%s %s", command, argv[i]); 31 strcpy (command, tmpline); 32 } 21 33 22 sprintf (command, "status");23 34 InitIOBuffer (&buffer, 0x100); 24 35 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/pcontrol/Makefile
r34088 r37822 11 11 12 12 # programs may add their own internal requirements here 13 LIBS1 = -l kapa -lFITS -lohana13 LIBS1 = -ldvo -lkapa -lFITS -lohana 14 14 LIBS2 = -lbasiccmd -lshell -ldata 15 15 FULL_CFLAGS = $(BASE_CFLAGS) -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/opihi/pcontrol/status.c
r36623 r37822 85 85 86 86 usage: 87 gprint (GP_ ERR, "USAGE: status [-cmd command] [-host hostname] [-state state] [-age seconds] [+jobs,-nohost] [+host,-nojobs]\n");87 gprint (GP_LOG, "USAGE: status [-cmd command] [-host hostname] [-state state] [-age seconds] [+jobs,-nohost] [+host,-nojobs]\n"); 88 88 return FALSE; 89 89 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/photdbc/include/photdbc.h
r37045 r37822 31 31 int PARALLEL_MANUAL; 32 32 int PARALLEL_SERIAL; 33 char *PARALLEL_OUTHOSTS; 33 34 34 35 int HOST_ID; 35 36 char *HOSTDIR; 37 char *HOSTDIR_OUTPUT; 36 38 37 39 // need to get RADIUS from Config … … 40 42 41 43 /* global variables */ 44 int SKIP_IMAGES; 45 int ONLY_IMAGES; 42 46 int SHOW_PARAMS; 43 47 int VERBOSE; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/photdbc/src/CopyToHostLocation.c
r33655 r37822 54 54 } 55 55 56 char extname[4][16] = {"cpm", "cpt", "cps", "cpn"}; 57 for (j = 0; success && (j < 4); j++) { 56 # define NEXTNAME 7 57 char extname[NEXTNAME][16] = {"cpm", "cpt", "cps", "cpn", "cpx", "cpy", "cpz"}; 58 for (j = 0; success && (j < NEXTNAME); j++) { 58 59 59 60 // set the in and out table names -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/photdbc/src/args.c
r36833 r37822 15 15 remove_argument (N, &argc, argv); 16 16 SHOW_PARAMS = TRUE; 17 } 18 19 SKIP_IMAGES = FALSE; 20 if ((N = get_argument (argc, argv, "-skip-images"))) { 21 SKIP_IMAGES = TRUE; 22 remove_argument (N, &argc, argv); 23 } 24 25 ONLY_IMAGES = FALSE; 26 if ((N = get_argument (argc, argv, "-only-images"))) { 27 if (SKIP_IMAGES) { 28 fprintf (stderr, "-skip-images and -only-images cannot be used together\n"); 29 } 30 ONLY_IMAGES = TRUE; 31 remove_argument (N, &argc, argv); 17 32 } 18 33 … … 131 146 } 132 147 148 // XXX for the moment, make this selection manual. it needs to be automatic 149 // based on the state of the SkyTable 150 HOSTDIR_OUTPUT = NULL; 151 PARALLEL_OUTHOSTS = NULL; 152 if ((N = get_argument (argc, argv, "-parallel-output"))) { 153 remove_argument (N, &argc, argv); 154 PARALLEL_OUTHOSTS = strcreate (argv[N]); 155 remove_argument (N, &argc, argv); 156 } 157 133 158 if (argc != 2) usage(); 134 159 … … 171 196 if (!HOSTDIR) usage(); 172 197 198 HOSTDIR_OUTPUT = NULL; 199 if ((N = get_argument (argc, argv, "-hostdir-output"))) { 200 remove_argument (N, &argc, argv); 201 HOSTDIR_OUTPUT = strcreate (argv[N]); 202 remove_argument (N, &argc, argv); 203 } 204 173 205 VERBOSE = FALSE; 174 206 if ((N = get_argument (argc, argv, "-v"))) { … … 289 321 fprintf (stderr, " photdbc (output)\n\n"); 290 322 323 fprintf (stderr, " parallel options:\n"); 324 fprintf (stderr, " -parallel:\n"); 325 fprintf (stderr, " -parallel-output HostTable : HostTable should be relative path in OUTPUT directory\n"); 326 fprintf (stderr, " -parallel-manual\n"); 327 fprintf (stderr, " -parallel-serial\n\n"); 328 291 329 fprintf (stderr, " allowed filters / restrictions include:\n\n"); 292 330 … … 303 341 fprintf (stderr, " option options:\n"); 304 342 fprintf (stderr, " -v : verbose mode\n"); 305 fprintf (stderr, " -params : list the current parameters\n\n"); 343 fprintf (stderr, " -params : list the current parameters\n"); 344 fprintf (stderr, " -skip-images\n"); 345 fprintf (stderr, " -only-images\n"); 346 fprintf (stderr, " -set-format (catformat)\n"); 347 fprintf (stderr, " -set-mode (catmode)\n"); 306 348 307 349 fprintf (stderr, "ptolemy.rc config values used by this program:\n"); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/photdbc/src/copy_images.c
r36833 r37822 52 52 } 53 53 54 BuildChipMatch (image, Nimage); 55 // MARKTIME("build chip match: %f sec\n", dtime); 56 57 char mapfile[DVO_MAX_PATH]; 58 snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR); 59 AstromOffsetTable *table_src = AstromOffsetMapLoad (mapfile, VERBOSE); 60 61 // assign images.coords.offsetMap -> table->map[i] 62 if (table_src) { 63 AstromOffsetTableMatchChips (image, Nimage, table_src); 64 } 65 54 66 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset, FALSE); 67 68 if (table_src) { 69 AstromOffsetTable *table_tgt = AstromOffsetTableInit (); 70 71 off_t i; 72 for (i = 0; i < Nsubset; i++) { 73 if (!subset[i].coords.offsetMap) continue; 74 if (subset[i].coords.Npolyterms != -1) continue; // assert on this? 75 AstromOffsetTableAddMapFromImage (table_tgt, &subset[i]); 76 } 77 snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", outdir); 78 AstromOffsetMapSave (table_tgt, mapfile); 79 free (table_tgt->imageIDtoTableSeq); 80 free (table_tgt->map); 81 free (table_tgt); 82 } 55 83 56 84 dvo_image_addrows (&out, subset, Nsubset); … … 73 101 SavePhotcodesFITS (filename); 74 102 103 // free the astrom offset tables 104 AstromOffsetTableFree (table_src); 105 75 106 return (TRUE); 76 107 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/photdbc/src/find_images.c
r36481 r37822 19 19 20 20 /* we make positional comparisons in the projection of catalog */ 21 InitCoords (&tcoords, "DEC--TAN"); 21 22 tcoords.crval1 = 0.5*(region[0].RA[0] + region[0].RA[1]); 22 23 tcoords.crval2 = 0.5*(region[0].DEC[0] + region[0].DEC[1]); 23 tcoords.crpix1 = tcoords.crpix2 = 0.0;24 24 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 25 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;26 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;27 strcpy (tcoords.ctype, "DEC--TAN");28 25 29 26 timage = gfits_table_get_Image (&db[0].ftable, &Ntimage, &db[0].swapped); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/photdbc/src/join_stars.c
r37045 r37822 50 50 51 51 /* coordinate system for projection */ 52 InitCoords (&tcoords, "DEC--TAN"); 52 53 tcoords.crval1 = Rmid; 53 54 tcoords.crval2 = Dmid; 54 tcoords.crpix1 = tcoords.crpix2 = 0.0;55 55 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 56 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;57 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;58 tcoords.Npolyterms = 0;59 strcpy (tcoords.ctype, "DEC--TAN");60 56 61 57 /* project & sort coordinates in local linear frame */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/photdbc/src/photdbc.c
r36833 r37822 15 15 16 16 // load and copy the image table 17 copy_images (argv[1], skylist); 17 if (!SKIP_IMAGES) { 18 copy_images (argv[1], skylist); 19 } 18 20 19 21 // hostID is 0 for master program 20 photdbc_catalogs (argv[1], skylist, 0); 22 if (!ONLY_IMAGES) { 23 photdbc_catalogs (argv[1], skylist, 0); 24 } 21 25 22 26 char *skyfile = SkyTableFilename (argv[1]); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/photdbc/src/photdbc_catalogs.c
r36833 r37822 42 42 snprintf (outfile, DVO_MAX_PATH, "%s/%s.cpt", outroot, skylist[0].regions[i]->name); 43 43 outcatalog.filename = outfile; 44 45 if (HOSTDIR_OUTPUT) { 46 // parallel-ouput puts the output in a per-host directory (keeps the source sky partition) 47 snprintf (outfile, DVO_MAX_PATH, "%s/%s.cpt", HOSTDIR_OUTPUT, skylist[0].regions[i]->name); 48 } 49 44 50 if (outcatalog.filename == NULL) Shutdown ("error with input catalog name"); 45 51 … … 95 101 } 96 102 103 HostTable *table_output = NULL; 104 if (PARALLEL_OUTHOSTS) { 105 table_output = HostTableLoad (outroot, PARALLEL_OUTHOSTS); 106 if (!table_output) { 107 fprintf (stderr, "%s not found in %s, please create\n", PARALLEL_OUTHOSTS, outroot); 108 } 109 } 110 97 111 int i; 98 112 for (i = 0; i < table->Nhosts; i++) { … … 123 137 if (CATFORMAT) { snprintf (tmpline, DVO_MAX_PATH, "%s -set-format %s", command, CATFORMAT); strcpy (command, tmpline); } 124 138 if (CATMODE) { snprintf (tmpline, DVO_MAX_PATH, "%s -set-mode %s", command, CATMODE); strcpy (command, tmpline); } 139 140 if (PARALLEL_OUTHOSTS) { 141 tmppath = abspath (table_output->hosts[i].pathname, DVO_MAX_PATH); 142 free (table_output->hosts[i].pathname); 143 table_output->hosts[i].pathname = tmppath; 144 snprintf (tmpline, DVO_MAX_PATH, "%s -hostdir-output %s", command, table_output->hosts[i].pathname); strcpy (command, tmpline); 145 } 125 146 126 147 fprintf (stderr, "command: %s\n", command); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/photdbc/src/select_images.c
r36833 r37822 34 34 35 35 // the comparison is made in the catalog local projection. below we set crval1,2 36 tcoords.crpix1 = tcoords.crpix2 = 0.0;36 InitCoords (&tcoords, "DEC--TAN"); 37 37 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 38 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;39 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;40 strcpy (tcoords.ctype, "DEC--TAN");41 38 42 39 ALLOCATE (skycoords, SkyRegionCoords, skylist[0].Nregions); … … 92 89 93 90 if (VERBOSE) fprintf (stderr, "finding images\n"); 94 BuildChipMatch (timage, Ntimage);95 MARKTIME("build chip match: %f sec\n", dtime);96 91 97 92 nimage = 0; … … 115 110 keep_image: 116 111 117 // this adds 1.3 sec for 3M images118 if (!FindMosaicForImage (timage, Ntimage, i)) {119 fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);120 continue;121 }122 123 112 /* define image corners - note the DIS images (mosaic phu) are special */ 124 113 if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/Makefile
r36833 r37822 59 59 $(SRC)/save_catalogs.$(ARCH).o \ 60 60 $(SRC)/CoordOps.$(ARCH).o \ 61 $(SRC)/ FixProblemImages.$(ARCH).o\61 $(SRC)/extra.$(ARCH).o \ 62 62 $(SRC)/StarMaps.$(ARCH).o \ 63 63 $(SRC)/high_speed_catalogs.$(ARCH).o \ … … 74 74 $(SRC)/relastro_parallel_regions.$(ARCH).o \ 75 75 $(SRC)/MeanPosIO.$(ARCH).o \ 76 $(SRC)/MeasPosIO.$(ARCH).o \ 76 77 $(SRC)/share_mean_pos.$(ARCH).o \ 78 $(SRC)/share_meas_pos.$(ARCH).o \ 77 79 $(SRC)/share_images_pos.$(ARCH).o \ 80 $(SRC)/share_icrf_obj.$(ARCH).o \ 81 $(SRC)/ICRF.$(ARCH).o \ 82 $(SRC)/ICRFobjIO.$(ARCH).o \ 83 $(SRC)/FrameCorrection.$(ARCH).o \ 84 $(SRC)/FrameCorrectionIO.$(ARCH).o \ 85 $(SRC)/FrameCorrectionUtils.$(ARCH).o \ 78 86 $(SRC)/ImagePosIO.$(ARCH).o \ 79 87 $(SRC)/ImageTable.$(ARCH).o \ … … 81 89 $(SRC)/indexCatalogs.$(ARCH).o \ 82 90 $(SRC)/syncfile.$(ARCH).o \ 91 $(SRC)/client_logger.$(ARCH).o \ 83 92 $(SRC)/relastroVisual.$(ARCH).o 84 93 … … 116 125 $(SRC)/relastro_objects.$(ARCH).o \ 117 126 $(SRC)/save_catalogs.$(ARCH).o \ 118 $(SRC)/ CoordOps.$(ARCH).o \127 $(SRC)/extra.$(ARCH).o \ 119 128 $(SRC)/high_speed_catalogs.$(ARCH).o \ 120 129 $(SRC)/high_speed_objects.$(ARCH).o \ … … 126 135 $(SRC)/plot_scatter.$(ARCH).o \ 127 136 $(SRC)/plotstuff.$(ARCH).o \ 137 $(SRC)/ICRF.$(ARCH).o \ 128 138 $(SRC)/relastroVisual.$(ARCH).o \ 129 139 $(SRC)/syncfile.$(ARCH).o \ 130 140 $(SRC)/BrightCatalog.$(ARCH).o 131 132 #$(SRC)/FitChip.$(ARCH).o \133 #$(SRC)/FitMosaic.$(ARCH).o \134 #$(SRC)/UpdateChips.$(ARCH).o \135 #$(SRC)/UpdateMosaic.$(ARCH).o \136 #$(SRC)/UpdateSimple.$(ARCH).o \137 #$(SRC)/write_coords.$(ARCH).o \138 #$(SRC)/FixProblemImages.$(ARCH).o \139 #$(SRC)/StarMaps.$(ARCH).o \140 141 141 142 $(RELASTRO_CLIENT): $(INC)/relastro.h -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/doc/pv2.txt
r37038 r37822 1 2 2014.10.28 3 4 Going over the sequence of steps in relastro. I'm concerned that the 5 iteration is not modifying the measure.R,D values, preventing any 6 actual iterative improvements. 7 8 * UpdateObjects : takes measure.R,D to calculate average.R,D and 9 motion terms 10 11 * ImageOps : 12 * getImageRaw : takes measure.X,Y, applies image.coords to get (L,M), 13 (P,Q), etc, calculates 14 * getImageRef : takes average.R,D, applies image.coords to get 15 (P,Q), (L,M), etc 16 * FitChip : fit raw.X,Y to ref.L,M, plus residual map (dX,dY) 17 18 *** modified raw.L,M values are then dropped and not used to update measure.R.D 1 19 2 20 2014.07.03 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/include/relastro.h
r37038 r37822 34 34 35 35 typedef struct { 36 floatR;37 floatD;36 double R; 37 double D; 38 38 unsigned int objID; 39 39 unsigned int catID; 40 40 } MeanPos; 41 42 typedef struct { 43 double R; 44 double D; 45 unsigned int objID; 46 unsigned int catID; 47 unsigned int imageID; 48 } MeasPos; 41 49 42 50 typedef struct { … … 47 55 int nFitAstrom; 48 56 int flags; 57 float refColorBlue; 58 float refColorRed; 49 59 } ImagePos; 50 60 … … 134 144 } StatType; 135 145 146 typedef struct { 147 off_t Nave; 148 off_t Npm; 149 off_t Npar; 150 off_t Nskip; 151 off_t Noffset; 152 } FitStats; 153 154 typedef struct { 155 double scale; 156 double **Roff; 157 double **Doff; 158 double *dR; 159 int *Nra; 160 int Ndec; 161 } FrameCorrectionType; 162 163 typedef struct { 164 // AstromOffsetMap *map; 165 Coords *coords; // carries a pointer to the AstromOffsetMap 166 FrameCorrectionType *frame; 167 } FrameCorrectionSet; 168 169 170 typedef struct { 171 double *Rave; 172 double *Dave; 173 double *dRoff; 174 double *dDoff; 175 int Nicrfobj; 176 } ICRFobj; 177 136 178 /* global variables set in parameter file */ 137 179 # define DVO_MAX_PATH 1024 … … 164 206 double MIN_ERROR; 165 207 208 int IMFIT_TOO_FEW; // need more than this number of stars to fit an image 166 209 int IMFIT_CLIP_NITER; // number of clipping iterations to perform in FitChip 167 210 double IMFIT_CLIP_NSIGMA; // number of sigma to clip in FitChip … … 180 223 181 224 int USE_FIXED_PIXCOORDS; 225 int USE_GALAXY_MODEL; 226 int USE_ICRF_CORRECT; 227 228 int USE_ICRF_LOCAL; 229 int USE_ICRF_SHFIT; 230 int USE_ICRF_POLE; 182 231 183 232 int RESET; 233 int RESET_IMAGES; 184 234 int RESET_BAD_IMAGES; 185 235 int NLOOP; … … 196 246 int PLOTDELAY; 197 247 int CHIPORDER; 248 int CHIPMAP; 198 249 199 250 int MaxDensityUse; … … 234 285 int CLIP_THRESH; 235 286 int USE_BASIC_CHECK; 287 int APPLY_OFFSETS; // in parallel-regions mode, do not launch UpdateObjectOffsets unless -apply-offsets is called 236 288 237 289 int ExcludeBogus; … … 389 441 void FitSimple (StarData *raw, StarData *ref, int Nmatch, Coords *coords); 390 442 void initObjectData (Catalog *catalog, int Ncatalog); 391 int UpdateObjects (Catalog *catalog, int Ncatalog );443 int UpdateObjects (Catalog *catalog, int Ncatalog, int Nloop); 392 444 int UpdateSimple (Catalog *catalog, int Ncatalog); 393 445 int UpdateChips (Catalog *catalog, int Ncatalog); … … 409 461 StarData *getImageRef (Catalog *catalog, int Ncatalog, off_t im, off_t *Nstars, CoordMode mode); 410 462 StarData *getImageRaw (Catalog *catalog, int Ncatalog, off_t im, off_t *Nstars, CoordMode mode); 463 int setImageRaw (Catalog *catalog, int Ncatalog, off_t im, StarData *raw, off_t Nraw, CoordMode mode); 411 464 off_t getImageByID (off_t ID); 465 int updateImageRaw (Catalog *catalog, int Ncatalog, off_t im); 412 466 413 467 Mosaic *getmosaics (off_t *N); … … 439 493 int relastroGetVisual(void); 440 494 441 int FixProblemImages (SkyList *skylist);442 495 int *getCatlist (int *N, off_t im); 443 496 444 void initCoords (void); 445 void getOffsets (double *dPos, off_t *nPos, off_t N); 446 void saveOffsets (double dPos, off_t nPos, off_t N); 447 void setBadCoords (off_t N); 448 int badCoords (off_t N); 449 Coords *getCoords (off_t N); 450 int saveCoords (Coords *coords, off_t N); 451 void resetImageRaw (Catalog *catalog, int Ncatalog, off_t im); 497 void SaveCoords (Coords *tgt, Coords *src); 498 void RestoreCoords (Coords *tgt, Coords *src, Image *image); 452 499 453 500 int high_speed_catalogs (SkyTable *sky, SkyList *skylist, int hostID, char *hostpath); … … 460 507 int checkStarMap(int N); 461 508 int createStarMap (Catalog *catalog, int Ncatalog); 509 int printStarMap(int N, char *filename); 462 510 463 511 int GetScatterRawRef(float *dLsig, float *dMsig, float *dRsig, int *nKeep, StarData *raw, StarData *ref, int Nstars, float SigmaLimit); … … 511 559 MeanPos *MeanPosLoad(char *filename, off_t *nmeanpos); 512 560 561 int share_meas_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 562 int slurp_meas_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 563 int set_meas_pos (MeasPos *measpos, Average *average, MeasureTiny *measure); 564 MeasPos *merge_meas_pos (MeasPos *target, int *ntarget, MeasPos *source, int Nsource); 565 566 int MeasPosSave(char *filename, MeasPos *measpos, off_t Nmeaspos); 567 MeasPos *MeasPosLoad(char *filename, off_t *nmeaspos); 568 513 569 int indexCatalogs (Catalog *catalog, int Ncatalog); 514 570 int catID_and_objID_to_seq (int catID, int objID, int *catSeq, off_t *objSeq); … … 520 576 521 577 int share_image_pos (RegionHostTable *regionHosts, int nloop); 522 int slurp_image_pos ( RegionHostTable *regionHosts, int nloop);578 int slurp_image_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 523 579 ImagePos *merge_image_pos (ImagePos *target, int *ntarget, ImagePos *source, int Nsource); 524 580 int set_image_pos (ImagePos *image_pos, Image *image); … … 535 591 int areImagesLoaded (); 536 592 int areImagesMatched (); 593 594 int isGPC1chip (int photcode); 595 int isGPC1stack (int photcode); 596 int isGPC1warp (int photcode); 597 598 int save_astrom_table (); 599 AstromOffsetTable *get_astrom_table (); 600 void put_astrom_table (AstromOffsetTable *myTable); 601 602 int fit_map (AstromOffsetMap *map, StarData *raw, StarData *ref, int Npts); 603 604 // ICRF QSOs : these must be marked in the database (flag on average, flag on measure) 605 606 void ICRFinit (); 607 int ICRFsave (int cat, int ave, int meas); 608 int ICRFdata (int n, int *cat, int *ave, int *meas); 609 int ICRFmax (); 610 int select_catalog_ICRF (Catalog *catalog, int Ncatalog); 611 612 void ICRFobjFree (ICRFobj *icrfobj); 613 ICRFobj *get_ICRF_data (Catalog *catalog, int Ncatalog); 614 ICRFobj *merge_icrf_obj (ICRFobj *target, ICRFobj *source); 615 ICRFobj *slurp_icrf_obj (RegionHostTable *regionHosts, int nloop); 616 int share_icrf_obj (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 617 618 int ICRFobjSave(char *filename, ICRFobj *icrfobj); 619 ICRFobj *ICRFobjLoad(char *filename); 620 621 int SHfitWithMask (double *R, double *D, double *value, int *mask, int Npts, SHterms *fit); 622 623 FrameCorrectionType *FrameCorrectionInit (double scale); 624 void FrameCorrectionFree (FrameCorrectionType *frame); 625 626 int FrameCorrectionParallelMaster (RegionHostTable *regionHosts); 627 int FrameCorrectionParallelSlave (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 628 int FrameCorrectionSerial (Catalog *catalog, int Ncatalog); 629 630 FrameCorrectionSet *FrameCorrectionMeasure (ICRFobj *icrfobj); 631 632 int FrameCorrectionFromSH (FrameCorrectionType *frame, SHterms *dR, SHterms *dD); 633 634 Coords *FrameCorrectionImageToMap (Header *header, Matrix *matrix, Coords *coords, int raDirection); 635 int FrameCorrectionMapToImage (Header *header, Matrix *matrix, Coords *coords, int raDirection); 636 int FrameCorrectionSHtoImage (Header *header, Matrix *matrix, FrameCorrectionType *frame, int raDirection); 637 FrameCorrectionType *FrameCorrectionImageToSH (Header *header, Matrix *matrix, FrameCorrectionType *frame, int raDirection); 638 int FrameCorrectionFromSH (FrameCorrectionType *frame, SHterms *dR, SHterms *dD); 639 void FrameCorrectionFree (FrameCorrectionType *frame); 640 FrameCorrectionType *FrameCorrectionInit (double scale); 641 void FrameCorrectionSetFree (FrameCorrectionSet *set); 642 FrameCorrectionSet *FrameCorrectionSetInit (); 643 644 int FrameCorrectionSetSave(char *filename, FrameCorrectionSet *set); 645 FrameCorrectionSet *FrameCorrectionSetLoad(char *filename); 646 647 int FrameCorrectionFitSH (ICRFobj *icrfobj, SHterms *dRc, SHterms *dDc); 648 int FrameCorrectionFitLocal (ICRFobj *icrfobj, Coords *coords); 649 int FrameCorrectionApply (Catalog *catalog, int Ncatalog, FrameCorrectionType *frame, Coords *coords); 650 651 int dump_stardata_pts (StarData *raw, int Npts, char *filename); 652 void printNcatTotal (); 653 654 int HarvestRegionHosts (RegionHostTable *regionHosts); 655 656 void lockUpdateChips (); 657 void unlockUpdateChips (); 658 659 int client_logger_init (char *dirname); 660 int client_logger_message (char *format,...); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/BrightCatalog.c
r37038 r37822 43 43 if (!gfits_fread_header (f, &header)) { 44 44 if (VERBOSE) fprintf (stderr, "can't read image subset header\n"); 45 fclose (f);46 45 goto escape; 47 46 } 48 47 if (!gfits_fread_matrix (f, &matrix, &header)) { 49 48 if (VERBOSE) fprintf (stderr, "can't read image subset matrix\n"); 50 gfits_free_header (&header);51 fclose (f);52 49 goto escape; 53 50 } … … 70 67 GET_COLUMN(R, "RA", double); 71 68 GET_COLUMN(D, "DEC", double); 69 GET_COLUMN(RoffGAL, "ROFF_GAL", float); 70 GET_COLUMN(DoffGAL, "DOFF_GAL", float); 72 71 GET_COLUMN(M, "MAG_SYS", float); 73 72 GET_COLUMN(Mcal, "MAG_CAL", float); … … 94 93 measure[i].R = R[i]; 95 94 measure[i].D = D[i]; 95 measure[i].RoffGAL = RoffGAL[i]; 96 measure[i].DoffGAL = DoffGAL[i]; 96 97 measure[i].M = M[i]; 97 98 measure[i].Mcal = Mcal[i]; … … 115 116 free (R ); 116 117 free (D ); 118 free (RoffGAL ); 119 free (DoffGAL ); 117 120 free (M ); 118 121 free (Mcal ); … … 310 313 if (catalog) free (catalog); 311 314 312 fclose (f);315 if (f) fclose (f); 313 316 return NULL; 314 317 } … … 343 346 gfits_create_table_header (&theader, "BINTABLE", "MEASURE_TINY"); 344 347 345 gfits_define_bintable_column (&theader, "E", "RA_OFF", "ra offset", "arcsec", 1.0, 0.0); 346 gfits_define_bintable_column (&theader, "E", "DEC_OFF", "dec offset", "arcsec", 1.0, 0.0); 348 gfits_define_bintable_column (&theader, "D", "RA", "ra", "degrees", 1.0, 0.0); 349 gfits_define_bintable_column (&theader, "D", "DEC", "dec", "degrees", 1.0, 0.0); 350 gfits_define_bintable_column (&theader, "E", "ROFF_GAL", "ra offset", "arcsec", 1.0, 0.0); 351 gfits_define_bintable_column (&theader, "E", "DOFF_GAL", "dec offset", "arcsec", 1.0, 0.0); 347 352 gfits_define_bintable_column (&theader, "E", "MAG_SYS", "magnitude (sys)", NULL, 1.0, 0.0); 348 353 gfits_define_bintable_column (&theader, "E", "MAG_CAL", "magnitude (cal)", NULL, 1.0, 0.0); … … 368 373 double *R ; ALLOCATE (R , double, catalog->Nmeasure); 369 374 double *D ; ALLOCATE (D , double, catalog->Nmeasure); 375 float *RoffGAL ; ALLOCATE (RoffGAL , float, catalog->Nmeasure); 376 float *DoffGAL ; ALLOCATE (DoffGAL , float, catalog->Nmeasure); 370 377 float *M ; ALLOCATE (M , float, catalog->Nmeasure); 371 378 float *Mcal ; ALLOCATE (Mcal , float, catalog->Nmeasure); … … 390 397 R[i] = measure[i].R ; 391 398 D[i] = measure[i].D ; 399 RoffGAL[i] = measure[i].RoffGAL ; 400 DoffGAL[i] = measure[i].DoffGAL ; 392 401 M[i] = measure[i].M ; 393 402 Mcal[i] = measure[i].Mcal ; … … 411 420 gfits_set_bintable_column (&theader, &ftable, "RA", R, catalog->Nmeasure); 412 421 gfits_set_bintable_column (&theader, &ftable, "DEC", D, catalog->Nmeasure); 422 gfits_set_bintable_column (&theader, &ftable, "ROFF_GAL", RoffGAL, catalog->Nmeasure); 423 gfits_set_bintable_column (&theader, &ftable, "DOFF_GAL", DoffGAL, catalog->Nmeasure); 413 424 gfits_set_bintable_column (&theader, &ftable, "MAG_SYS", M, catalog->Nmeasure); 414 425 gfits_set_bintable_column (&theader, &ftable, "MAG_CAL", Mcal, catalog->Nmeasure); … … 430 441 free (R ); 431 442 free (D ); 443 free (RoffGAL ); 444 free (DoffGAL ); 432 445 free (M ); 433 446 free (Mcal ); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/ConfigInit.c
r36630 r37822 25 25 if (!ScanConfig (config, "RELASTRO_IMFIT_CLIP_NSIGMA", "%lf", 0, &IMFIT_CLIP_NSIGMA)) IMFIT_CLIP_NSIGMA = 3.0; 26 26 if (!ScanConfig (config, "RELASTRO_IMFIT_SYS_SIGMA_LIM", "%lf", 0, &IMFIT_SYS_SIGMA_LIM)) IMFIT_SYS_SIGMA_LIM = 0.01; 27 if (!ScanConfig (config, "RELASTRO_IMFIT_TOO_FEW", "%d", 0, &IMFIT_TOO_FEW)) IMFIT_TOO_FEW = 5; 27 28 28 29 if (!ScanConfig (config, "PM_DT_MIN", "%lf", 0, &PM_DT_MIN)) PM_DT_MIN = 0.25; … … 36 37 37 38 if (!ScanConfig (config, "USE_FIXED_PIXCOORDS", "%d", 0, &USE_FIXED_PIXCOORDS)) USE_FIXED_PIXCOORDS = FALSE; 39 if (!ScanConfig (config, "USE_GALAXY_MODEL", "%d", 0, &USE_GALAXY_MODEL)) USE_GALAXY_MODEL = FALSE; 40 if (!ScanConfig (config, "USE_ICRF_CORRECT", "%d", 0, &USE_ICRF_CORRECT)) USE_ICRF_CORRECT = FALSE; 41 if (!ScanConfig (config, "USE_ICRF_LOCAL", "%d", 0, &USE_ICRF_LOCAL)) USE_ICRF_LOCAL = FALSE; 42 if (!ScanConfig (config, "USE_ICRF_SHFIT", "%d", 0, &USE_ICRF_SHFIT)) USE_ICRF_SHFIT = FALSE; 43 if (!ScanConfig (config, "USE_ICRF_POLE", "%d", 0, &USE_ICRF_POLE)) USE_ICRF_POLE = FALSE; 38 44 39 45 // force CATDIR to be absolute (so parallel mode will work) -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/FitChip.c
r37038 r37822 14 14 15 15 for (Niter = 0; Niter < IMFIT_CLIP_NITER; Niter ++) { 16 16 17 17 // measure the scatter for the unmarked (good) measurements with dM < limit 18 18 // SIGMA_LIM here is redundant with ImageOps.c:915 … … 49 49 // use that count to set order_use below 50 50 51 // 20140925 : the same logic below is used to constrain the dimensions of the image map 52 51 53 // figures to assess the fitting process: 52 54 // x vs dx, x vs dy, y vs dx, y vs dy : 53 55 // residual vector field 54 56 // dx vs mag, dy vs mag 57 if (relastroGetVisual()) { 58 fprintf (stderr, "fitting chip %s, %d matched stars\n", image->name, Nmatch); 59 } 55 60 relastroVisualPlotChipFit(raw, ref, dRmax, Nmatch); 61 62 // for polynomial fits, I used (5,30,60) = (5,6,7) stars per term 56 63 57 64 // set the maximum order for the polynomial (based on number of stars kept above) 58 65 int order_use = 0; 59 if (Nkeep > 5) order_use = 1; // 4 stars per polynomial term (per dimension) 60 if (Nkeep > 30) order_use = 2; // 5 stars per polynomial term (per dimension) 61 if (Nkeep > 60) order_use = 3; // 6 stars per polynomial term (per dimension) 66 if (Nkeep > 5) order_use = 1; // 5 stars per cell 67 if (Nkeep > 24) order_use = 2; // 6 stars per cell 68 if (Nkeep > 63) order_use = 3; // 7 stars per cell 69 if (Nkeep > 128) order_use = 4; // 8 stars per cell 70 if (Nkeep > 225) order_use = 5; // 9 stars per cell 71 if (Nkeep > 360) order_use = 6; // 10 stars per cell 62 72 if (order_use < 1) { 63 73 if (VERBOSE2) fprintf (stderr, "insufficient measurements (%d) for linear fit\n", Nkeep); … … 65 75 return FALSE; 66 76 } 67 image[0].coords.Npolyterms = order_use; 77 if (CHIPMAP) { 78 order_use = MIN(MIN(order_use, CHIPMAP), 6); // can only go up to 6th order map (can be user limited) 79 } else { 80 order_use = MIN(order_use, 3); // can only go up to 3rd order for polynomials 81 } 82 83 if (VERBOSE2) fprintf (stderr, "using %d for %s\n", order_use, image[0].name); 84 85 // when fitting the map, first fit a linear model (below? change Npolyterms to -1) 86 image[0].coords.Npolyterms = CHIPMAP ? 1 : order_use; 68 87 69 88 if (fit) fit_free (fit); … … 91 110 } 92 111 112 // apply fit to get the fitted X,Y coordinates. we need these to fit the residual map below 93 113 for (i = 0; i < Nmatch; i++) { 114 // we have not yet fitted the map, so Npolyterms needs to be 1 here: 115 LM_to_XY (&ref[i].X, &ref[i].Y, ref[i].L, ref[i].M, &image[0].coords); 116 } 117 118 if (CHIPMAP) { 119 if (image[0].coords.offsetMap == NULL) { 120 // allocate a new table and assign to this image 121 // need to lock threads here because 'table' is a static with 122 // modifiable elements 123 lockUpdateChips (); 124 AstromOffsetTable *table = get_astrom_table (); 125 AstromOffsetTableNewMap(table, order_use, order_use, image); 126 unlockUpdateChips (); 127 } 128 // XXX Need to check / update the order of the map here. if we already have a map, it might have been 129 // allocated with too small arrays 130 AstromOffsetMapSetOrder (image[0].coords.offsetMap, order_use, order_use, image); 131 image[0].coords.offsetMap->keep = TRUE; // if we are trying or re-trying this map, we should keep it unless it fails 132 fit_map (image[0].coords.offsetMap, raw, ref, Nmatch); 133 image[0].coords.Npolyterms = -1; 134 } 135 136 if (!strcmp(image[0].name, "o5745g0403o.356777.cm.982487.smf[XY17.hdr]")) { 137 fprintf (stderr, "test image\n"); 138 } 139 140 for (i = 0; i < Nmatch; i++) { 141 // if we have fitted the map above, Npolyterms needs to be -1 here: 94 142 XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, &image[0].coords); 95 143 } 96 97 144 } 98 145 … … 223 270 L,M -> X,Y (polynomial transformation : WRP) 224 271 225 Some details about this function:226 227 - the initial value of the clipping radius is set based on the distribution of the dR228 values for the bright sources.229 230 - NITER clipping passes are performed231 232 - the per-star astrometric errors are included in the fit. The photcode table controls233 whether only the reported positional errors are used, or if the magnitudes errors are234 scaled to determine the error, and if there is a systematic floor for all sources.235 236 - input detections are pre-filtered on the basis of the photFlags, etc, in bcatalog237 238 - outlying detections are clipped in the iterative passes, but the clipped detections are239 not recorded272 Some details about this function: 273 274 - the initial value of the clipping radius is set based on the distribution of the dR 275 values for the bright sources. 276 277 - NITER clipping passes are performed 278 279 - the per-star astrometric errors are included in the fit. The photcode table controls 280 whether only the reported positional errors are used, or if the magnitudes errors are 281 scaled to determine the error, and if there is a systematic floor for all sources. 282 283 - input detections are pre-filtered on the basis of the photFlags, etc, in bcatalog 284 285 - outlying detections are clipped in the iterative passes, but the clipped detections are 286 not recorded 240 287 241 288 */ … … 243 290 /* example using fit_apply() : 244 291 245 f = fopen ("test3.dat", "w"); 246 247 // apply new coords to raw (X,Y -> L,M) 248 for (i = 0; i < Nmatch; i++) { 249 fprintf (f, "%f %f %f %f ", raw[i].X, raw[i].Y, raw[i].L, raw[i].M); 250 fit_apply (newfit, &L1, &M1, raw[i].X - coords[0].crpix1, raw[i].Y - coords[0].crpix2); 251 fprintf (f, "%f %f\n", L1, M1); 292 f = fopen ("test3.dat", "w"); 293 294 // apply new coords to raw (X,Y -> L,M) 295 for (i = 0; i < Nmatch; i++) { 296 fprintf (f, "%f %f %f %f ", raw[i].X, raw[i].Y, raw[i].L, raw[i].M); 297 fit_apply (newfit, &L1, &M1, raw[i].X - coords[0].crpix1, raw[i].Y - coords[0].crpix2); 298 fprintf (f, "%f %f\n", L1, M1); 299 } 300 fclose (f); 301 */ 302 303 int fit_map (AstromOffsetMap *map, StarData *raw, StarData *ref, int Npts) { 304 305 // we are actually fitting the residual after the linear fit has been taken off 306 307 // fit the linear terms as above 308 // calculate dX (raw.X - ref.X) and dY 309 310 int i, N; 311 312 float *x, *y, *dX, *dY; 313 ALLOCATE (x, float, Npts); 314 ALLOCATE (y, float, Npts); 315 ALLOCATE (dX, float, Npts); 316 ALLOCATE (dY, float, Npts); 317 318 N = 0; 319 for (i = 0; i < Npts; i++) { 320 if (raw[i].mask) continue; 321 x[N] = raw[i].X; 322 y[N] = raw[i].Y; 323 dX[N] = ref[i].X - raw[i].X; 324 dY[N] = ref[i].Y - raw[i].Y; 325 N++; 326 } 327 328 // in coordsops.c:XY_to_LM, the map is defined to carry dX,dY so that: 329 // (L,M) = f(X',Y') : (X',Y') = (X,Y) + (dX,dY) 330 331 AstromOffsetMapFit (map, x, y, dX, N, TRUE); 332 AstromOffsetMapFit (map, x, y, dY, N, FALSE); 333 334 AstromOffsetMapRepair (map, TRUE); 335 AstromOffsetMapRepair (map, FALSE); 336 337 free (x); 338 free (y); 339 free (dX); 340 free (dY); 341 342 return TRUE; 343 } 344 345 int dump_stardata_pts (StarData *raw, int Npts, char *filename) { 346 347 FILE *f = fopen (filename, "w"); 348 if (!f) { 349 fprintf (stderr, "failed to open file %s\n", filename); 350 return FALSE; 351 } 352 353 int i; 354 for (i = 0; i < Npts; i++) { 355 fprintf (f, "%4d %10.6f %10.6f %10.6f %10.6f %9.2f %9.2f %9.2f %9.2f %9.4f %3d\n", 356 i, raw[i].R, raw[i].D, raw[i].P, raw[i].Q, raw[i].L, raw[i].M, raw[i].X, raw[i].Y, raw[i].dPos, raw[i].mask); 252 357 } 253 358 fclose (f); 254 */ 255 359 360 return TRUE; 361 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/ImageOps.c
r37038 r37822 28 28 static off_t *imageIDs; // list of all image IDs 29 29 static off_t *imageIdx; // list of index for image IDs 30 # else 30 31 // as an alternative, we generate imageSeq, which directly maps imageID -> seq 32 static off_t *imageSeq; // list of index for image IDs 33 34 // MAX_ID requires 512M to store the image index 35 # define MAX_ID 0x8000000 36 static off_t minImageID = MAX_ID; 37 static off_t maxImageID = 0; 38 39 # else /* not using IMAGE_ID */ 31 40 static unsigned int *start; 32 41 static unsigned int *stop; … … 84 93 imageIdx[i] = i; 85 94 imageIDs[i] = image[i].imageID; 95 minImageID = MIN(minImageID, image[i].imageID); 96 maxImageID = MAX(maxImageID, image[i].imageID); 97 myAssert (image[i].imageID < MAX_ID, "image IDs too large for index memory"); 86 98 } 87 99 llsortpair (imageIDs, imageIdx, Nimage); 100 101 ALLOCATE (imageSeq, off_t, maxImageID + 1); 102 for (i = 0; i < maxImageID + 1; i++) { 103 imageSeq[i] = -1; // not yet assigned 104 } 105 106 for (i = 0; i < Nimage; i++) { 107 off_t N = image[i].imageID; 108 myAssert (imageSeq[N] == -1, "previously assigned"); 109 imageSeq[N] = i; 110 } 111 88 112 # else 89 113 ALLOCATE (start, unsigned, Nimage); … … 98 122 99 123 off_t getImageByID (off_t ID) { 124 # if USE_IMAGE_ID 125 126 if (imageSeq) { 127 if (ID < minImageID) return (-1); 128 if (ID > maxImageID) return (-1); 129 off_t N = imageSeq[ID]; 130 return N; 131 } 100 132 101 133 // we have a pair of vectors (imageIDs, imageIdx) sorted by imageIDs 102 134 // use bisection to find the specified image ID 103 135 104 # if USE_IMAGE_ID105 136 off_t Nlo, Nhi, N; 106 137 … … 207 238 if (VERBOSE2 || (MATCHCAT && (N_onImage[i] < 20))) { 208 239 name = GetPhotcodeNamebyCode (image[i].photcode); 209 fprintf (stderr, "image "OFF_T_FMT" (%d, %s) has "OFF_T_FMT" of %d measures (%s, %s)", i, image[i].imageID, image[i].name, N_onImage[i], image[i].nstar, 240 int showExample = (Nfew < 30); 241 if (showExample) fprintf (stderr, "image "OFF_T_FMT" (%d, %s) has "OFF_T_FMT" of %d measures (%s, %s) ", i, image[i].imageID, image[i].name, N_onImage[i], image[i].nstar, 210 242 ohana_sec_to_date(image[i].tzero), name); 211 243 if (N_onImage[i] < 20) { 212 fprintf (stderr, "*");244 if (showExample) fprintf (stderr, "*"); 213 245 Nfew ++; 214 246 } 215 247 if (N_onImage[i] < 15) { 216 fprintf (stderr, "*** warning ***");248 if (showExample) fprintf (stderr, "*** warning ***"); 217 249 Nbad ++; 218 250 } 219 fprintf (stderr, "\n");220 } 221 } 222 fprintf (stderr, OFF_T_FMT" total images, %d with < 20 measurements, %d with < 15\n", Nimage, Nfew, Nbad);251 if (showExample) fprintf (stderr, "\n"); 252 } 253 } 254 if (MATCHCAT) fprintf (stderr, OFF_T_FMT" total images, %d with < 20 measurements, %d with < 15\n", Nimage, Nfew, Nbad); 223 255 } 224 256 … … 245 277 } 246 278 279 if (!ID) return; // detection not associated with an image 280 247 281 idx = getImageByID (ID); 248 282 if (idx == -1) { … … 250 284 return; 251 285 } 286 measure->myDet = TRUE; // I 'own' this detection (I am calibrating its image) 252 287 253 288 // index for (catalog, measure) -> image … … 334 369 # endif 335 370 336 /*337 Coords *getCoords (off_t meas, int cat) {338 339 off_t i;340 341 i = MeasureToImage[cat][meas];342 if (i == -1) return (NULL);343 return (&image[i].coords);344 }345 */346 347 371 float getColorBlue (off_t meas, int cat) { 348 372 … … 433 457 Coords *moscoords, *imcoords; 434 458 435 // check if this image is bad and should be skipped436 if (badCoords(im)) return;437 438 459 // WRP images need to have an associated mosaic 439 460 moscoords = NULL; … … 491 512 492 513 int TESTPT = FALSE; 493 494 TESTPT |= CAT_ID_SRC && OBJ_ID_SRC && (measure->imageID == CAT_ID_SRC) && (measure->detID == OBJ_ID_SRC); 495 TESTPT |= CAT_ID_DST && OBJ_ID_DST && (measure->imageID == CAT_ID_DST) && (measure->detID == OBJ_ID_DST); 514 TESTPT |= CAT_ID_SRC && OBJ_ID_SRC && (measure->catID == CAT_ID_SRC) && (measure->objID == OBJ_ID_SRC); 515 TESTPT |= CAT_ID_DST && OBJ_ID_DST && (measure->catID == CAT_ID_DST) && (measure->objID == OBJ_ID_DST); 496 516 if (TESTPT) { 497 517 fprintf (stderr, "got test det\n"); … … 597 617 int Noff = NoffRAave + NoffDECave + NoffRAori + NoffDECori; 598 618 if (VERBOSE2 && (Noff > 0)) fprintf (stderr, "Noff ave RA %d, Noff ave DEC %d, Noff ori RA %d, Noff ori DEC %d\n", NoffRAave, NoffDECave, NoffRAori, NoffDECori); 599 saveOffsets (dPos, nPos, im);600 619 601 620 return; … … 604 623 void printNcatTotal () { 605 624 fprintf (stderr, "NcatTotal: %d\n", NcatTotal); 606 }607 608 // return StarData values for detections in the specified image, converting coordinates from the609 // chip positions: X,Y -> L,M -> P,Q -> R,D610 void resetImageRaw (Catalog *catalog, int Ncatalog, off_t im) {611 612 off_t i, m, c, n;613 double X, Y, L, M, P, Q, R, D;614 615 Mosaic *mosaic;616 Coords *moscoords, *imcoords, *oldcoords;617 618 fprintf (stderr, "fix resetImageRaw wrt MeasureTiny\n");619 abort();620 621 // check if this image is bad and should be skipped622 if (!badCoords(im)) {623 fprintf (stderr, "ERROR: inconsistent result?");624 abort();625 }626 627 // replace the current coords with the old coords:628 oldcoords = getCoords (im);629 memcpy (&image[im].coords, oldcoords, sizeof(Coords));630 631 // WRP images need to have an associated mosaic632 moscoords = NULL;633 if (!strcmp(&image[im].coords.ctype[4], "-WRP")) {634 mosaic = getMosaicForImage (im);635 if (mosaic == NULL) return; // if we cannot find the associated image, skip it636 moscoords = &mosaic[0].coords;637 }638 imcoords = &image[im].coords;639 640 for (i = 0; i < N_onImage[im]; i++) {641 m = ImageToMeasure[im][i];642 c = ImageToCatalog[im][i];643 644 // XXX unclear if this should use Measure or MeasureTiny; it is only called by FixProblemImages, which has not been updated645 Measure *measure = &catalog[c].measure[m];646 647 X = measure[0].Xccd;648 Y = measure[0].Yccd;649 if (USE_FIXED_PIXCOORDS) {650 if (isfinite(measure[0].Xfix) && isfinite(measure[0].Yfix)) {651 float dX = measure[0].Xfix - measure[0].Xccd;652 float dY = measure[0].Yfix - measure[0].Yccd;653 if (hypot(dX,dY) < 2.0) {654 X = measure[0].Xfix;655 Y = measure[0].Yfix;656 }657 }658 }659 n = measure[0].averef;660 661 if (moscoords == NULL) {662 // this is a Simple image (not a mosaic)663 // note that for a Simple image, L,M = P,Q664 XY_to_LM (&L, &M, X, Y, imcoords);665 LM_to_RD (&R, &D, L, M, imcoords);666 } else {667 XY_to_LM (&L, &M, X, Y, imcoords);668 XY_to_LM (&P, &Q, L, M, moscoords);669 LM_to_RD (&R, &D, P, Q, moscoords);670 }671 measure[0].R = R;672 measure[0].D = D;673 674 float dRoff = dvoOffsetR(measure, &catalog[c].average[n]);675 676 if (dRoff > +180.0*3600.0) {677 // average on high end of boundary, move star up678 measure[0].R += 360.0;679 dRoff -= 360.0*3600.0;680 }681 if (dRoff < -180.0*3600.0) {682 measure[0].R -= 360.0;683 dRoff += 360.0*3600.0;684 }685 }686 687 return;688 625 } 689 626 … … 736 673 737 674 n = measure[0].averef; 675 676 int TESTPT = FALSE; 677 TESTPT |= CAT_ID_SRC && OBJ_ID_SRC && (catalog[c].average[n].catID == CAT_ID_SRC) && (catalog[c].average[n].objID == OBJ_ID_SRC); 678 TESTPT |= CAT_ID_DST && OBJ_ID_DST && (catalog[c].average[n].catID == CAT_ID_DST) && (catalog[c].average[n].objID == OBJ_ID_DST); 679 if (TESTPT) { 680 fprintf (stderr, "got test det\n"); 681 } 738 682 739 683 // an object with only one detection provides no information about the image calibration … … 808 752 ref[i].D = catalog[c].average[n].D; 809 753 754 // if we are correcting for the Galaxy Motion Model, we assume the mean R,D is at the J2000 epoch position 755 if (USE_GALAXY_MODEL) { 756 myAssert (!isnan(measure[0].RoffGAL), "oops"); 757 myAssert (!isnan(measure[0].DoffGAL), "oops"); 758 ref[i].R += measure[0].RoffGAL / 3600.0; 759 ref[i].D += measure[0].DoffGAL / 3600.0; 760 } 761 810 762 ref[i].Mag = measure[0].M; 811 763 ref[i].dMag = measure[0].dM; … … 842 794 *Nstars = N_onImage[im]; 843 795 return (ref); 796 } 797 798 // return StarData values for detections in the specified image, converting coordinates from the 799 // chip positions: X,Y -> L,M -> P,Q -> R,D. This function is used by the image fitting steps, for 800 // which the detections have already been filtered when they were loaded (bcatalog) 801 int setImageRaw (Catalog *catalog, int Ncatalog, off_t im, StarData *raw, off_t Nraw, CoordMode mode) { 802 803 off_t i, m, c; 804 805 Coords *moscoords; 806 807 moscoords = NULL; 808 if (mode == MODE_MOSAIC) { 809 moscoords = image[im].coords.mosaic; 810 myAssert (moscoords, "coords.mosaic not defined for image %s (%d)", image[im].name, (int) im); 811 } 812 813 myAssert (Nraw == N_onImage[im], "impossible!"); 814 815 for (i = 0; i < N_onImage[im]; i++) { 816 m = ImageToMeasure[im][i]; 817 c = ImageToCatalog[im][i]; 818 819 // XXX should I use the raw coords or just measure.X,Y -> R,D? 820 821 switch (mode) { 822 case MODE_SIMPLE: 823 /* note that for a Simple image, L,M = P,Q */ 824 XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, &image[im].coords); 825 raw[i].P = raw[i].L; 826 raw[i].Q = raw[i].M; 827 LM_to_RD (&raw[i].R, &raw[i].D, raw[i].P, raw[i].Q, &image[im].coords); 828 break; 829 case MODE_MOSAIC: 830 XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, &image[im].coords); 831 XY_to_LM (&raw[i].P, &raw[i].Q, raw[i].L, raw[i].M, moscoords); 832 LM_to_RD (&raw[i].R, &raw[i].D, raw[i].P, raw[i].Q, moscoords); 833 break; 834 default: 835 fprintf (stderr, "error: invalid mode in getImageRaw"); 836 abort (); 837 } 838 839 MeasureTiny *measure = &catalog[c].measureT[m]; 840 measure->R = raw[i].R; 841 measure->D = raw[i].D; 842 if (catalog[c].measure) { 843 catalog[c].measure[m].R = raw[i].R; 844 catalog[c].measure[m].D = raw[i].D; 845 } 846 } 847 return TRUE; 848 } 849 850 // return StarData values for detections in the specified image, converting coordinates from the 851 // chip positions: X,Y -> L,M -> P,Q -> R,D. This function is used by the image fitting steps, for 852 // which the detections have already been filtered when they were loaded (bcatalog) 853 int updateImageRaw (Catalog *catalog, int Ncatalog, off_t im) { 854 855 off_t i, m, c; 856 857 for (i = 0; i < N_onImage[im]; i++) { 858 m = ImageToMeasure[im][i]; 859 c = ImageToCatalog[im][i]; 860 861 MeasureTiny *measure = &catalog[c].measureT[m]; 862 863 /* apply the current image transformation or use the current value of R+dR, D+dD? */ 864 double X = measure[0].Xccd; 865 double Y = measure[0].Yccd; 866 if (USE_FIXED_PIXCOORDS) { 867 if (isfinite(measure[0].Xfix) && isfinite(measure[0].Yfix)) { 868 float dX = measure[0].Xfix - measure[0].Xccd; 869 float dY = measure[0].Yfix - measure[0].Yccd; 870 if (hypot(dX,dY) < 2.0) { 871 X = measure[0].Xfix; 872 Y = measure[0].Yfix; 873 } 874 } 875 } 876 877 double R, D; 878 XY_to_RD (&R, &D, X, Y, &image[im].coords); 879 measure->R = R; 880 measure->D = D; 881 if (catalog[c].measure) { 882 catalog[c].measure[m].R = R; 883 catalog[c].measure[m].D = D; 884 } 885 } 886 return TRUE; 844 887 } 845 888 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/ImagePosIO.c
r36630 r37822 70 70 GET_COLUMN (polyterms, "POLYTERMS", float); // verify that we got 14 columns? 71 71 GET_COLUMN (ctype, "CTYPE", char); // verify that we got 15 columns? 72 GET_COLUMN (Npolyterms, "NPOLYTERMS", char);72 GET_COLUMN (Npolyterms, "NPOLYTERMS", byte); 73 73 GET_COLUMN (dXpixSys, "XPIX_SYS_ERR", float); 74 74 GET_COLUMN (dYpixSys, "YPIX_SYS_ERR", float); 75 GET_COLUMN (refColorBlue, "REF_COLOR_BLUE", float); 76 GET_COLUMN (refColorRed, "REF_COLOR_RED", float); 75 77 GET_COLUMN (imageID, "ID", int); 76 78 GET_COLUMN (nFitAstrom, "NFIT", int); … … 85 87 ALLOCATE (image_pos, ImagePos, Nrow); 86 88 for (i = 0; i < Nrow; i++) { 87 image_pos[i].coords.crval1 = crval1 [i]; 88 image_pos[i].coords.crval2 = crval2 [i]; 89 image_pos[i].coords.crpix1 = crpix1 [i]; 90 image_pos[i].coords.crpix2 = crpix2 [i]; 91 image_pos[i].coords.cdelt1 = cdelt1 [i]; 92 image_pos[i].coords.cdelt2 = cdelt2 [i]; 93 image_pos[i].coords.pc1_1 = pc1_1 [i]; 94 image_pos[i].coords.pc1_2 = pc1_2 [i]; 95 image_pos[i].coords.pc2_1 = pc2_1 [i]; 96 image_pos[i].coords.pc2_2 = pc2_2 [i]; 97 image_pos[i].coords.Npolyterms = Npolyterms[i]; 98 image_pos[i].dXpixSys = dXpixSys [i]; 99 image_pos[i].dYpixSys = dYpixSys [i]; 100 image_pos[i].imageID = imageID [i]; 101 image_pos[i].nFitAstrom = nFitAstrom[i]; 102 image_pos[i].flags = flags [i]; 89 InitCoords(&image_pos[i].coords, NULL); 90 image_pos[i].coords.crval1 = crval1 [i]; 91 image_pos[i].coords.crval2 = crval2 [i]; 92 image_pos[i].coords.crpix1 = crpix1 [i]; 93 image_pos[i].coords.crpix2 = crpix2 [i]; 94 image_pos[i].coords.cdelt1 = cdelt1 [i]; 95 image_pos[i].coords.cdelt2 = cdelt2 [i]; 96 image_pos[i].coords.pc1_1 = pc1_1 [i]; 97 image_pos[i].coords.pc1_2 = pc1_2 [i]; 98 image_pos[i].coords.pc2_1 = pc2_1 [i]; 99 image_pos[i].coords.pc2_2 = pc2_2 [i]; 100 image_pos[i].coords.Npolyterms = Npolyterms [i]; 101 image_pos[i].dXpixSys = dXpixSys [i]; 102 image_pos[i].dYpixSys = dYpixSys [i]; 103 image_pos[i].refColorBlue = refColorBlue[i]; 104 image_pos[i].refColorRed = refColorRed [i]; 105 image_pos[i].imageID = imageID [i]; 106 image_pos[i].nFitAstrom = nFitAstrom [i]; 107 image_pos[i].flags = flags [i]; 103 108 104 109 // polyterms and ctype are a bit different … … 108 113 fprintf (stderr, "loaded data for %lld images\n", (long long) Nrow); 109 114 110 free (crval1 ); 111 free (crval2 ); 112 free (crpix1 ); 113 free (crpix2 ); 114 free (cdelt1 ); 115 free (cdelt2 ); 116 free (pc1_1 ); 117 free (pc1_2 ); 118 free (pc2_1 ); 119 free (pc2_2 ); 120 free (polyterms ); 121 free (ctype ); 122 free (Npolyterms); 123 free (dXpixSys ); 124 free (dYpixSys ); 125 free (imageID ); 126 free (nFitAstrom); 127 free (flags ); 115 free (crval1 ); 116 free (crval2 ); 117 free (crpix1 ); 118 free (crpix2 ); 119 free (cdelt1 ); 120 free (cdelt2 ); 121 free (pc1_1 ); 122 free (pc1_2 ); 123 free (pc2_1 ); 124 free (pc2_2 ); 125 free (polyterms ); 126 free (ctype ); 127 free (Npolyterms ); 128 free (dXpixSys ); 129 free (dYpixSys ); 130 free (refColorBlue); 131 free (refColorRed ); 132 free (imageID ); 133 free (nFitAstrom ); 134 free (flags ); 128 135 129 136 *nimage_pos = Nrow; … … 153 160 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_POS"); 154 161 155 gfits_define_bintable_column (&theader, "D", "CRVAL1", "word", "unit", 1.0, 0.0); 156 gfits_define_bintable_column (&theader, "D", "CRVAL2", "word", "unit", 1.0, 0.0); 157 gfits_define_bintable_column (&theader, "E", "CRPIX1", "word", "unit", 1.0, 0.0); 158 gfits_define_bintable_column (&theader, "E", "CRPIX2", "word", "unit", 1.0, 0.0); 159 gfits_define_bintable_column (&theader, "E", "CDELT1", "word", "unit", 1.0, 0.0); 160 gfits_define_bintable_column (&theader, "E", "CDELT2", "word", "unit", 1.0, 0.0); 161 gfits_define_bintable_column (&theader, "E", "PC1_1", "word", "unit", 1.0, 0.0); 162 gfits_define_bintable_column (&theader, "E", "PC1_2", "word", "unit", 1.0, 0.0); 163 gfits_define_bintable_column (&theader, "E", "PC2_1", "word", "unit", 1.0, 0.0); 164 gfits_define_bintable_column (&theader, "E", "PC2_2", "word", "unit", 1.0, 0.0); 165 gfits_define_bintable_column (&theader, "14E", "POLYTERMS", "word", "unit", 1.0, 0.0); 166 gfits_define_bintable_column (&theader, "15A", "CTYPE", "word", "unit", 1.0, 0.0); 167 gfits_define_bintable_column (&theader, "L", "NPOLYTERMS", "word", "unit", 1.0, 0.0); 168 gfits_define_bintable_column (&theader, "E", "XPIX_SYS_ERR", "word", "unit", 1.0, 0.0); 169 gfits_define_bintable_column (&theader, "E", "YPIX_SYS_ERR", "word", "unit", 1.0, 0.0); 170 gfits_define_bintable_column (&theader, "J", "ID", "image ID", "unitless", 1.0, 0.0); 171 gfits_define_bintable_column (&theader, "J", "NFIT", "number of fitted stars", "unitless", 1.0, 0.0); 172 gfits_define_bintable_column (&theader, "J", "FLAGS", "analysis flags", "unitless", 1.0, 0.0); 162 gfits_define_bintable_column (&theader, "D", "CRVAL1", "word", "unit", 1.0, 0.0); 163 gfits_define_bintable_column (&theader, "D", "CRVAL2", "word", "unit", 1.0, 0.0); 164 gfits_define_bintable_column (&theader, "E", "CRPIX1", "word", "unit", 1.0, 0.0); 165 gfits_define_bintable_column (&theader, "E", "CRPIX2", "word", "unit", 1.0, 0.0); 166 gfits_define_bintable_column (&theader, "E", "CDELT1", "word", "unit", 1.0, 0.0); 167 gfits_define_bintable_column (&theader, "E", "CDELT2", "word", "unit", 1.0, 0.0); 168 gfits_define_bintable_column (&theader, "E", "PC1_1", "word", "unit", 1.0, 0.0); 169 gfits_define_bintable_column (&theader, "E", "PC1_2", "word", "unit", 1.0, 0.0); 170 gfits_define_bintable_column (&theader, "E", "PC2_1", "word", "unit", 1.0, 0.0); 171 gfits_define_bintable_column (&theader, "E", "PC2_2", "word", "unit", 1.0, 0.0); 172 gfits_define_bintable_column (&theader, "14E", "POLYTERMS", "word", "unit", 1.0, 0.0); 173 gfits_define_bintable_column (&theader, "15A", "CTYPE", "word", "unit", 1.0, 0.0); 174 gfits_define_bintable_column (&theader, "L", "NPOLYTERMS", "word", "unit", 1.0, 0.0); 175 gfits_define_bintable_column (&theader, "E", "XPIX_SYS_ERR", "word", "unit", 1.0, 0.0); 176 gfits_define_bintable_column (&theader, "E", "YPIX_SYS_ERR", "word", "unit", 1.0, 0.0); 177 gfits_define_bintable_column (&theader, "E", "REF_COLOR_BLUE", "word", "unit", 1.0, 0.0); 178 gfits_define_bintable_column (&theader, "E", "REF_COLOR_RED", "word", "unit", 1.0, 0.0); 179 gfits_define_bintable_column (&theader, "J", "ID", "image ID", "unitless", 1.0, 0.0); 180 gfits_define_bintable_column (&theader, "J", "NFIT", "number of fitted stars", "unitless", 1.0, 0.0); 181 gfits_define_bintable_column (&theader, "J", "FLAGS", "analysis flags", "unitless", 1.0, 0.0); 173 182 174 183 // generate the output array that carries the data 175 184 gfits_create_table (&theader, &ftable); 176 185 177 double *crval1 ; 178 double *crval2 ; 179 float *crpix1 ; 180 float *crpix2 ; 181 float *cdelt1 ; 182 float *cdelt2 ; 183 float *pc1_1 ; 184 float *pc1_2 ; 185 float *pc2_1 ; 186 float *pc2_2 ; 187 float *polyterms ; 188 char *ctype ; 189 char *Npolyterms; 190 float *dXpixSys ; 191 float *dYpixSys ; 192 int *imageID ; 193 int *nFitAstrom; 194 int *flags ; 186 double *crval1 ; 187 double *crval2 ; 188 float *crpix1 ; 189 float *crpix2 ; 190 float *cdelt1 ; 191 float *cdelt2 ; 192 float *pc1_1 ; 193 float *pc1_2 ; 194 float *pc2_1 ; 195 float *pc2_2 ; 196 float *polyterms ; 197 char *ctype ; 198 char *Npolyterms ; 199 float *dXpixSys ; 200 float *dYpixSys ; 201 float *refColorBlue; 202 float *refColorRed ; 203 int *imageID ; 204 int *nFitAstrom ; 205 int *flags ; 195 206 196 207 // create intermediate storage arrays … … 210 221 ALLOCATE (dXpixSys , float , Nimage_pos); 211 222 ALLOCATE (dYpixSys , float , Nimage_pos); 223 ALLOCATE (refColorBlue, float , Nimage_pos); 224 ALLOCATE (refColorRed , float , Nimage_pos); 212 225 ALLOCATE (imageID , int , Nimage_pos); 213 226 ALLOCATE (nFitAstrom, int , Nimage_pos); … … 216 229 // assign the storage arrays 217 230 for (i = 0; i < Nimage_pos; i++) { 218 crval1 [i] = image_pos[i].coords.crval1 ; 219 crval2 [i] = image_pos[i].coords.crval2 ; 220 crpix1 [i] = image_pos[i].coords.crpix1 ; 221 crpix2 [i] = image_pos[i].coords.crpix2 ; 222 cdelt1 [i] = image_pos[i].coords.cdelt1 ; 223 cdelt2 [i] = image_pos[i].coords.cdelt2 ; 224 pc1_1 [i] = image_pos[i].coords.pc1_1 ; 225 pc1_2 [i] = image_pos[i].coords.pc1_2 ; 226 pc2_1 [i] = image_pos[i].coords.pc2_1 ; 227 pc2_2 [i] = image_pos[i].coords.pc2_2 ; 228 Npolyterms[i] = image_pos[i].coords.Npolyterms; 229 dXpixSys [i] = image_pos[i].dXpixSys ; 230 dYpixSys [i] = image_pos[i].dYpixSys ; 231 imageID [i] = image_pos[i].imageID ; 232 nFitAstrom[i] = image_pos[i].nFitAstrom ; 233 flags [i] = image_pos[i].flags ; 231 crval1 [i] = image_pos[i].coords.crval1 ; 232 crval2 [i] = image_pos[i].coords.crval2 ; 233 crpix1 [i] = image_pos[i].coords.crpix1 ; 234 crpix2 [i] = image_pos[i].coords.crpix2 ; 235 cdelt1 [i] = image_pos[i].coords.cdelt1 ; 236 cdelt2 [i] = image_pos[i].coords.cdelt2 ; 237 pc1_1 [i] = image_pos[i].coords.pc1_1 ; 238 pc1_2 [i] = image_pos[i].coords.pc1_2 ; 239 pc2_1 [i] = image_pos[i].coords.pc2_1 ; 240 pc2_2 [i] = image_pos[i].coords.pc2_2 ; 241 Npolyterms [i] = image_pos[i].coords.Npolyterms; 242 dXpixSys [i] = image_pos[i].dXpixSys ; 243 dYpixSys [i] = image_pos[i].dYpixSys ; 244 refColorBlue[i] = image_pos[i].refColorBlue ; 245 refColorRed [i] = image_pos[i].refColorRed ; 246 imageID [i] = image_pos[i].imageID ; 247 nFitAstrom [i] = image_pos[i].nFitAstrom ; 248 flags [i] = image_pos[i].flags ; 234 249 235 250 // polyterms and ctype are a bit different … … 239 254 240 255 // add the columns to the output array 241 gfits_set_bintable_column (&theader, &ftable, "CRVAL1", crval1 , Nimage_pos); 242 gfits_set_bintable_column (&theader, &ftable, "CRVAL2", crval2 , Nimage_pos); 243 gfits_set_bintable_column (&theader, &ftable, "CRPIX1", crpix1 , Nimage_pos); 244 gfits_set_bintable_column (&theader, &ftable, "CRPIX2", crpix2 , Nimage_pos); 245 gfits_set_bintable_column (&theader, &ftable, "CDELT1", cdelt1 , Nimage_pos); 246 gfits_set_bintable_column (&theader, &ftable, "CDELT2", cdelt2 , Nimage_pos); 247 gfits_set_bintable_column (&theader, &ftable, "PC1_1", pc1_1 , Nimage_pos); 248 gfits_set_bintable_column (&theader, &ftable, "PC1_2", pc1_2 , Nimage_pos); 249 gfits_set_bintable_column (&theader, &ftable, "PC2_1", pc2_1 , Nimage_pos); 250 gfits_set_bintable_column (&theader, &ftable, "PC2_2", pc2_2 , Nimage_pos); 251 gfits_set_bintable_column (&theader, &ftable, "POLYTERMS", polyterms , Nimage_pos); 252 gfits_set_bintable_column (&theader, &ftable, "CTYPE", ctype , Nimage_pos); 253 gfits_set_bintable_column (&theader, &ftable, "NPOLYTERMS", Npolyterms, Nimage_pos); 254 gfits_set_bintable_column (&theader, &ftable, "XPIX_SYS_ERR",dXpixSys , Nimage_pos); 255 gfits_set_bintable_column (&theader, &ftable, "YPIX_SYS_ERR",dYpixSys , Nimage_pos); 256 gfits_set_bintable_column (&theader, &ftable, "ID", imageID , Nimage_pos); 257 gfits_set_bintable_column (&theader, &ftable, "NFIT", nFitAstrom, Nimage_pos); 258 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags , Nimage_pos); 259 260 free (crval1 ); 261 free (crval2 ); 262 free (crpix1 ); 263 free (crpix2 ); 264 free (cdelt1 ); 265 free (cdelt2 ); 266 free (pc1_1 ); 267 free (pc1_2 ); 268 free (pc2_1 ); 269 free (pc2_2 ); 270 free (polyterms ); 271 free (ctype ); 272 free (Npolyterms); 273 free (dXpixSys ); 274 free (dYpixSys ); 275 free (imageID ); 276 free (nFitAstrom); 277 free (flags ); 256 gfits_set_bintable_column (&theader, &ftable, "CRVAL1", crval1 , Nimage_pos); 257 gfits_set_bintable_column (&theader, &ftable, "CRVAL2", crval2 , Nimage_pos); 258 gfits_set_bintable_column (&theader, &ftable, "CRPIX1", crpix1 , Nimage_pos); 259 gfits_set_bintable_column (&theader, &ftable, "CRPIX2", crpix2 , Nimage_pos); 260 gfits_set_bintable_column (&theader, &ftable, "CDELT1", cdelt1 , Nimage_pos); 261 gfits_set_bintable_column (&theader, &ftable, "CDELT2", cdelt2 , Nimage_pos); 262 gfits_set_bintable_column (&theader, &ftable, "PC1_1", pc1_1 , Nimage_pos); 263 gfits_set_bintable_column (&theader, &ftable, "PC1_2", pc1_2 , Nimage_pos); 264 gfits_set_bintable_column (&theader, &ftable, "PC2_1", pc2_1 , Nimage_pos); 265 gfits_set_bintable_column (&theader, &ftable, "PC2_2", pc2_2 , Nimage_pos); 266 gfits_set_bintable_column (&theader, &ftable, "POLYTERMS", polyterms , Nimage_pos); 267 gfits_set_bintable_column (&theader, &ftable, "CTYPE", ctype , Nimage_pos); 268 gfits_set_bintable_column (&theader, &ftable, "NPOLYTERMS", Npolyterms, Nimage_pos); 269 gfits_set_bintable_column (&theader, &ftable, "XPIX_SYS_ERR", dXpixSys , Nimage_pos); 270 gfits_set_bintable_column (&theader, &ftable, "YPIX_SYS_ERR", dYpixSys , Nimage_pos); 271 gfits_set_bintable_column (&theader, &ftable, "REF_COLOR_BLUE", refColorBlue, Nimage_pos); 272 gfits_set_bintable_column (&theader, &ftable, "REF_COLOR_RED", refColorRed , Nimage_pos); 273 gfits_set_bintable_column (&theader, &ftable, "ID", imageID , Nimage_pos); 274 gfits_set_bintable_column (&theader, &ftable, "NFIT", nFitAstrom, Nimage_pos); 275 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags , Nimage_pos); 276 277 free (crval1 ); 278 free (crval2 ); 279 free (crpix1 ); 280 free (crpix2 ); 281 free (cdelt1 ); 282 free (cdelt2 ); 283 free (pc1_1 ); 284 free (pc1_2 ); 285 free (pc2_1 ); 286 free (pc2_2 ); 287 free (polyterms ); 288 free (ctype ); 289 free (Npolyterms ); 290 free (dXpixSys ); 291 free (dYpixSys ); 292 free (refColorBlue); 293 free (refColorRed ); 294 free (imageID ); 295 free (nFitAstrom ); 296 free (flags ); 278 297 279 298 FILE *f = fopen (filename, "w"); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/ParFactor.c
r33652 r37822 63 63 double jd, lambda, beta, epsilon, Radius; 64 64 65 /* given a time T in UNIX seconds, determine the solar longitude S */ 65 /* given a Time relative to Tmean, Tmean in years since J2000, determine the solar 66 longitude S */ 66 67 67 68 // jd = ohana_sec_to_jd (365.25*86400.0*(Time + Tmean)); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/StarMaps.c
r36630 r37822 176 176 } 177 177 178 int printStarMap(int N, char *filename) { 179 180 off_t i, Nimages; 181 Image *images = getimages(&Nimages, NULL); 182 double L, M; 183 184 FILE *f = fopen (filename, "w"); 185 186 for (i = 0; i < starmap[N].Npoints; i++) { 187 // set the transformed coordinates 188 XY_to_LM (&L, &M, starmap[N].points[i].X, starmap[N].points[i].Y, &images[N].coords); 189 190 fprintf (f, "%d %7.2f %f : %7.2f %7.2f : %7.2f %7.2f : %7.2f %7.2f\n", (int) i, starmap[N].points[i].X, starmap[N].points[i].Y, starmap[N].points[i].L, starmap[N].points[i].M, L, M, starmap[N].points[i].L - L, starmap[N].points[i].M - M); 191 } 192 fclose (f); 193 return (TRUE); 194 } 195 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/UpdateChips.c
r33652 r37822 36 36 off_t i, Nraw, Nref, nFitAstr; 37 37 StarData *raw, *ref; 38 Coords *oldCoords;39 38 float dXpixSys, dYpixSys; 40 39 double *Ro, *Do; … … 74 73 Nskip ++; 75 74 mode[i] = 0; 75 continue; 76 } 77 if (Nraw <= IMFIT_TOO_FEW) { 78 Nskip ++; 79 mode[i] = 0; 80 free (raw); 76 81 continue; 77 82 } … … 90 95 91 96 // save these in case of failure 92 saveCoords (&image[i].coords, i); 97 Coords oldCoords; 98 SaveCoords (&oldCoords, &image[i].coords); 99 93 100 dXpixSys = image[i].dXpixSys; 94 101 dYpixSys = image[i].dYpixSys; … … 100 107 if (VERBOSE) fprintf (stderr, "reject fit for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT" of %d\n", image[i].name, i, Nraw, image[i].nstar); 101 108 102 // restore status quo ante 103 oldCoords = getCoords (i); 104 memcpy (&image[i].coords, oldCoords, sizeof(Coords)); 105 image[i].dXpixSys = dXpixSys; 106 image[i].dYpixSys = dYpixSys; 107 image[i].nFitAstrom = nFitAstr; 108 109 saveCenter (image, &Ro[i], &Do[i], i); 110 mode[i] = 1; 111 NoldFit ++; 112 free (raw); 113 free (ref); 114 continue; 109 if (1) { 110 // restore status quo ante (replace truMap with tmpMap) 111 RestoreCoords (&image[i].coords, &oldCoords, &image[i]); 112 image[i].dXpixSys = dXpixSys; 113 image[i].dYpixSys = dYpixSys; 114 image[i].nFitAstrom = nFitAstr; 115 116 saveCenter (image, &Ro[i], &Do[i], i); 117 mode[i] = 1; 118 NoldFit ++; 119 free (raw); 120 free (ref); 121 continue; 122 } 115 123 } 116 124 117 125 if (!checkStarMap (i)) { 118 126 if (VERBOSE) fprintf (stderr, "fit diverges too much for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT"\n", image[i].name, i, Nraw); 119 // restore status quo ante 120 oldCoords = getCoords (i); 121 memcpy (&image[i].coords, oldCoords, sizeof(Coords)); 122 image[i].dXpixSys = dXpixSys; 123 image[i].dYpixSys = dYpixSys; 124 image[i].nFitAstrom = nFitAstr; 125 126 saveCenter (image, &Ro[i], &Do[i], i); 127 mode[i] = 2; 128 image[i].flags |= ID_IMAGE_ASTROM_POOR; 129 NoldFit ++; 130 free (raw); 131 free (ref); 132 continue; 127 128 if (1) { 129 // restore status quo ante (replace truMap with tmpMap) 130 RestoreCoords (&image[i].coords, &oldCoords, &image[i]); 131 image[i].dXpixSys = dXpixSys; 132 image[i].dYpixSys = dYpixSys; 133 image[i].nFitAstrom = nFitAstr; 134 135 saveCenter (image, &Ro[i], &Do[i], i); 136 mode[i] = 2; 137 image[i].flags |= ID_IMAGE_ASTROM_POOR; 138 NoldFit ++; 139 free (raw); 140 free (ref); 141 continue; 142 } 133 143 } 144 145 // Apply the modified coords back to the measure.R,D. Note that raw.R,D, ref.L,M, etc 146 // are all automatically updated in this block because they are re-generated from 147 // image.coords on each pass. 148 setImageRaw (catalog, Ncatalog, i, raw, Nraw, MODE_MOSAIC); 149 if (USE_GALAXY_MODEL) { 150 image[i].flags |= ID_IMAGE_ASTROM_GMM; 151 } 134 152 135 153 saveCenter (image, &Ro[i], &Do[i], i); … … 235 253 off_t Nraw, Nref, nFitAstr; 236 254 StarData *raw, *ref; 237 Coords *oldCoords;238 255 float dXpixSys, dYpixSys; 239 256 … … 260 277 threadinfo->Nskip ++; 261 278 threadinfo->mode[i] = 0; 279 continue; 280 } 281 if (Nraw <= IMFIT_TOO_FEW) { 282 threadinfo->Nskip ++; 283 threadinfo->mode[i] = 0; 284 free (raw); 262 285 continue; 263 286 } … … 276 299 277 300 // save these in case of failure 278 saveCoords (&image[i].coords, i); 301 Coords oldCoords; 302 SaveCoords (&oldCoords, &image[i].coords); 279 303 dXpixSys = image[i].dXpixSys; 280 304 dYpixSys = image[i].dYpixSys; … … 286 310 if (VERBOSE) fprintf (stderr, "reject fit for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT" of %d\n", image[i].name, i, Nraw, image[i].nstar); 287 311 288 // restore status quo ante 289 oldCoords = getCoords (i); 290 memcpy (&image[i].coords, oldCoords, sizeof(Coords)); 312 // restore status quo ante (replace truMap with tmpMap) 313 RestoreCoords (&image[i].coords, &oldCoords, &image[i]); 291 314 image[i].dXpixSys = dXpixSys; 292 315 image[i].dYpixSys = dYpixSys; … … 303 326 if (!checkStarMap (i)) { 304 327 if (VERBOSE) fprintf (stderr, "fit diverges too much for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT"\n", image[i].name, i, Nraw); 305 // restore status quo ante 306 oldCoords = getCoords (i);307 memcpy (&image[i].coords, oldCoords, sizeof(Coords));328 329 // restore status quo ante (replace truMap with tmpMap) 330 RestoreCoords (&image[i].coords, &oldCoords, &image[i]); 308 331 image[i].dXpixSys = dXpixSys; 309 332 image[i].dYpixSys = dYpixSys; … … 319 342 } 320 343 344 // apply the modified R,D back to the measures 345 setImageRaw (threadinfo->catalog, threadinfo->Ncatalog, i, raw, Nraw, MODE_MOSAIC); 346 321 347 saveCenter (image, &threadinfo->Ro[i], &threadinfo->Do[i], i); 322 348 threadinfo->mode[i] = 3; … … 333 359 static pthread_mutex_t UpdateChips_mutex = PTHREAD_MUTEX_INITIALIZER; 334 360 361 void lockUpdateChips () { 362 pthread_mutex_lock (&UpdateChips_mutex); 363 } 364 void unlockUpdateChips () { 365 pthread_mutex_unlock (&UpdateChips_mutex); 366 } 367 335 368 // we have an array of chips (image, Nimage). we need to hand out images one at a time to 336 369 // the worker threads as they need 337 370 off_t getNextImageForThread () { 338 371 339 pthread_mutex_lock (&UpdateChips_mutex);372 lockUpdateChips (); 340 373 if (nextImage >= Nimage) { 341 pthread_mutex_unlock (&UpdateChips_mutex);374 unlockUpdateChips (); 342 375 return (-1); 343 376 } … … 345 378 nextImage ++; 346 379 347 pthread_mutex_unlock (&UpdateChips_mutex);380 unlockUpdateChips (); 348 381 return (thisImage); 349 382 } … … 494 527 } 495 528 496 // XXX if (!FindMosaicForImage (image, Nimage, i)) { } 529 // save the coords and offset map in src at tgt 530 void SaveCoords (Coords *tgt, Coords *src) { 531 myAssert (tgt, "oops"); 532 myAssert (src, "oops"); 533 CopyCoords (tgt, src); // src retains a pointer to the AstromOffsetMap table, to be saved 534 tgt->offsetMap = AstromOffsetMapCopy(src->offsetMap); // oldCoords now saves the old values in a new structure 535 } 536 537 // restore the coords and offset map at tgt from src 538 void RestoreCoords (Coords *tgt, Coords *src, Image *image) { 539 540 AstromOffsetMap *truMap = tgt->offsetMap; 541 AstromOffsetMap *tmpMap = src->offsetMap; 542 543 // copy the coords structure data first, then fix the offsetMap pointers 544 // this modifies tgt.coords, but we need to keep the original pointer 545 CopyCoords (tgt, src); 546 tgt->offsetMap = truMap; 547 548 // we want to keep the old solution, which is (maybe) a pointer to a stand-alone 549 // map. the image has a bad solution, but it is a pointer to the map in the I/O 550 // table. those values will be saved on exit. 551 552 if (!tmpMap && !truMap) return; 553 554 if (tmpMap && truMap) { 555 AstromOffsetMapSetOrder (truMap, tmpMap->Nx, tmpMap->Ny, image); 556 AstromOffsetMapCopyData (truMap, tmpMap); 557 return; 558 } 559 560 if (tmpMap && !truMap) { 561 // is this even possible? 562 lockUpdateChips (); 563 AstromOffsetTable *table = get_astrom_table (); 564 AstromOffsetTableNewMap(table, tmpMap->Nx, tmpMap->Ny, image); // registers the map with the image 565 unlockUpdateChips (); 566 AstromOffsetMapCopyData (image->coords.offsetMap, tmpMap); 567 return; 568 } 569 if (!tmpMap && truMap) { 570 truMap->keep = FALSE; 571 return; 572 } 573 myAbort ("oops"); 574 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/UpdateMeasures.c
r35763 r37822 1 1 # include "relastro.h" 2 void dump_measures (Average *average, Measure *measure); // in ImageOps.c 2 3 3 void printNcatTotal (); 4 // this function is called by UpdateObjectOffsets or relastro_images.c for reset 5 int UpdateMeasures (Catalog *catalog, int Ncatalog) { 6 7 off_t i, j, Nimage; 8 Image *image; 9 double DPOS_MAX_ASEC; 10 11 int badImage = 12 ID_IMAGE_ASTROM_NOCAL | 13 ID_IMAGE_ASTROM_POOR | 14 ID_IMAGE_ASTROM_FAIL | 15 ID_IMAGE_ASTROM_SKIP | 16 ID_IMAGE_ASTROM_FEW; 17 18 if (RESET_BAD_IMAGES) badImage = 0; 19 20 image = getimages (&Nimage, NULL); 21 22 // track measurements which are far from their original position (poor at pole) 23 int NoffRAave = 0; int NoffRAori = 0; 24 int NoffDECave = 0; int NoffDECori = 0; 25 26 for (i = 0; i < Ncatalog; i++) { 27 myAssert (!catalog[i].Nmeasure || catalog[i].measureT, "programming error"); 28 for (j = 0; j < catalog[i].Nmeasure; j++) { 29 MeasureTiny *measureT = &catalog[i].measureT[j]; 30 Measure *measureB = catalog[i].measure ? &catalog[i].measure[j] : NULL; 31 32 off_t im = getImageByID (measureT->imageID); 33 if (im < 0) continue; // detections without imageIDs are not associated with a known image (eg, refs) 34 35 // check that we have the right image: 36 myAssert (measureT->photcode == image[im].photcode, "image photcode mismatch"); 37 myAssert (measureT->t >= image[im].tzero, "image time mismatch (1)"); 38 myAssert (measureT->t <= image[im].tzero + image[im].NX*image[im].trate/5000.0, "image time mismatch (2)"); 39 // I'm allowing the trate*NX to be a factor of 2x too small 40 41 // skip measurements on images that have failed solutions (divergent or otherwise) 42 // XXX apply this or not?? 43 if (FALSE && (image[im].flags & badImage)) continue; 44 45 Coords *moscoords = image[im].coords.mosaic; 46 Coords *imcoords = &image[im].coords; 47 48 if (moscoords) { 49 DPOS_MAX_ASEC = 3600.0*DPOS_MAX*hypot(moscoords->cdelt1, moscoords->cdelt2); 50 } else { 51 DPOS_MAX_ASEC = 3600.0*DPOS_MAX*hypot(imcoords->cdelt1, imcoords->cdelt2); 52 } 53 54 double X = measureT->Xccd; 55 double Y = measureT->Yccd; 56 if (USE_FIXED_PIXCOORDS) { 57 if (isfinite(measureT->Xfix) && isfinite(measureT->Yfix)) { 58 float dX = measureT->Xfix - measureT->Xccd; 59 float dY = measureT->Yfix - measureT->Yccd; 60 if (hypot(dX,dY) < 2.0) { 61 X = measureT->Xfix; 62 Y = measureT->Yfix; 63 } 64 } 65 } 66 67 double R, D; 68 XY_to_RD (&R, &D, X, Y, imcoords); 69 70 int n = measureT[0].averef; 71 Average *average = &catalog[i].average[n]; 72 73 double dR = 3600.0*(average[0].R - R); 74 double dD = 3600.0*(average[0].D - D); 75 76 // make sure detection is on the same side of the 0,360 boundary as the average 77 // this will give some funny results withing ~1 arcsec of the pol 78 if (dR > +180.0*3600.0) { 79 // average on high end of boundary, move star up 80 R += 360.0; 81 dR = 3600.0*(average[0].R - R); 82 } 83 if (dR < -180.0*3600.0) { 84 // average on low end of boundary, move star down 85 R -= 360.0; 86 dR = 3600.0*(average[0].R - R); 87 } 88 89 float csdec = cos(average[0].D * RAD_DEG); 90 91 // complain if the new location is far from the average location 92 // NOTE: This should never happen, or our StarMap tests are not working 93 if (fabs(dR*csdec) > 3.0*ADDSTAR_RADIUS) { 94 NoffRAave ++; 95 if (VERBOSE2 && catalog[i].measure) { 96 fprintf (stderr, "measurement is far from average location (R): %f %f (%f %f %f)\n", average[0].R, average[0].D, dR, dR*csdec, dD); 97 dump_measures (&average[0], catalog[i].measure); 98 } 99 } 100 if (fabs(dD) > 3.0*ADDSTAR_RADIUS) { 101 NoffDECave ++; 102 if (VERBOSE2 && catalog[i].measure) { 103 fprintf (stderr, "measurement is far from average location (D): %f %f (%f %f)\n", average[0].R, average[0].D, dR, dD); 104 dump_measures (&average[0], catalog[i].measure); 105 } 106 } 107 108 // complain if the new location is far from the old location 109 if (fabs(csdec*(measureT[0].R - R)) > DPOS_MAX_ASEC) { 110 NoffRAori ++; 111 if (VERBOSE2 && catalog[i].measure) { 112 fprintf (stderr, "measurement moves far from original location (R): %f %f (%f %f %f %f)\n", average[0].R, average[0].D, measureT[0].R, dR, csdec*(measureT[0].R - R), dD); 113 dump_measures (&average[0], catalog[i].measure); 114 } 115 } 116 if (fabs(measureT[0].D - D) > DPOS_MAX_ASEC) { 117 NoffDECori ++; 118 if (VERBOSE2 && catalog[i].measure) { 119 fprintf (stderr, "measurement moves far from original location (D): %f %f (%f %f %f)\n", average[0].R, average[0].D, dR, measureT[0].D, dD); 120 dump_measures (&average[0], catalog[i].measure); 121 } 122 } 123 measureT->R = R; 124 measureT->D = D; 125 if (measureB) { 126 measureB->R = R; 127 measureB->D = D; 128 } 129 } 130 } 131 // printNcatTotal (); 132 133 int Noff = NoffRAave + NoffDECave + NoffRAori + NoffDECori; 134 if (VERBOSE && (Noff > 0)) fprintf (stderr, "Noff ave RA %d, Noff ave DEC %d, Noff ori RA %d, Noff ori DEC %d\n", NoffRAave, NoffDECave, NoffRAori, NoffDECori); 135 136 return (TRUE); 137 } 4 138 5 139 // this function operates on Measure, not MeasureTiny 6 int UpdateMeasures (Catalog *catalog, int Ncatalog) {140 int UpdateMeasuresOld (Catalog *catalog, int Ncatalog) { 7 141 8 142 off_t i, Nimage; … … 32 166 } 33 167 34 printNcatTotal ();168 // printNcatTotal (); 35 169 36 170 return (TRUE); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/UpdateObjectOffsets.c
r37038 r37822 59 59 60 60 // uses MeasureTiny values, but will also update Measure values when populated 61 UpdateObjects (&catalog, 1); 61 // if Galaxy Motion Model correction is active, do not apply at this last stage 62 UpdateObjects (&catalog, 1, FALSE); 62 63 63 64 free_tiny_values(&catalog); … … 74 75 save_catalogs (&catalog, 1); 75 76 } 76 77 printNcatTotal(); 77 78 return (TRUE); 78 79 } 80 81 int UpdateObjectOffsets_parallel_group (HostTableGroup *group, SkyList *sky); 82 int UpdateObjectOffsets_parallel_table (HostTable *table, SkyList *sky); 79 83 80 84 // CATDIR is supplied globally … … 90 94 exit (1); 91 95 } 96 97 # if (0) 98 99 UpdateObjectOffsets_parallel_table (table, sky); 100 101 # else 102 103 int Ngroups; 104 HostTableGroup *groups = HostTableGroups (table, &Ngroups); 105 // split the table into Ngroups, each with a unique set of machines (this avoids overloading the remote host machines) 106 107 int i; 108 for (i = 0; i < Ngroups; i++) { 109 // update only a group of unique machines at a time 110 UpdateObjectOffsets_parallel_group (&groups[i], sky); 111 } 112 # endif 113 114 return TRUE; 115 } 116 117 // CATDIR is supplied globally 118 # define DEBUG 1 119 int UpdateObjectOffsets_parallel_group (HostTableGroup *group, SkyList *sky) { 120 121 // launch the relastro_client jobs to the parallel hosts 122 123 int i, j; 124 for (i = 0; i < group->Nhosts; i++) { 125 126 if (sky->Nregions < group->Nhosts) { 127 // do any of the regions want this host? 128 int wantThisHost = FALSE; 129 for (j = 0; j < sky->Nregions; j++) { 130 if (HostTableTestHost (sky->regions[j], group->hosts[i][0].hostID)) { 131 wantThisHost = TRUE; 132 break; 133 } 134 } 135 if (!wantThisHost) { 136 // fprintf (stderr, "skip host %s\n", group->hosts[i][0].hostname); 137 continue; 138 } 139 } 140 141 // ensure that the paths are absolute path names 142 char *tmppath = abspath (group->hosts[i][0].pathname, DVO_MAX_PATH); 143 free (group->hosts[i][0].pathname); 144 group->hosts[i][0].pathname = tmppath; 145 146 // options / arguments that can affect relastro_client -load: 147 // VERBOSE, VERBOSE2 148 // RESET (-reset) 149 // TimeSelect -time 150 // (note that psfQF is applied rigidly at 0.85, as is the galaxy test) 151 // ImagSelect, ImagMin, ImagMax 152 // MaxDensityUse, MaxDensityValue 153 154 char command[1024]; 155 snprintf (command, 1024, "relastro_client -update-offsets -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -minerror %f", 156 group->hosts[i][0].hostID, CATDIR, group->hosts[i][0].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, MIN_ERROR); 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); 183 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 184 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); 187 } 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); 194 195 if (TimeSelect) { 196 char *tstart = ohana_sec_to_date (TSTART); 197 char *tstop = ohana_sec_to_date (TSTOP); 198 strextend (command, "-time %s %s", tstart, tstop); 199 free (tstart); 200 free (tstop); 201 } 202 fprintf (stderr, "command: %s\n", command); 203 204 if (PARALLEL_MANUAL) continue; 205 206 if (PARALLEL_SERIAL) { 207 int status = system (command); 208 if (status) { 209 fprintf (stderr, "ERROR running relastro_client\n"); 210 exit (2); 211 } 212 } else { 213 // launch the job on the remote machine (no handshake) 214 int errorInfo = 0; 215 int pid = rconnect ("ssh", group->hosts[i][0].hostname, command, group->hosts[i][0].stdio, &errorInfo, FALSE); 216 if (!pid) { 217 if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", group->hosts[i][0].hostname, errorInfo); 218 exit (1); 219 } 220 group->hosts[i][0].pid = pid; // save for future reference 221 } 222 } 223 224 if (PARALLEL_MANUAL) { 225 fprintf (stderr, "run the relastro_client commands above. when these are done, hit return\n"); 226 getchar(); 227 } 228 if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) { 229 HostTableGroupWaitJobsGetIO (group, __FILE__, __LINE__, VERBOSE); 230 } 231 232 return TRUE; 233 } 234 235 // CATDIR is supplied globally 236 # define DEBUG 1 237 int UpdateObjectOffsets_parallel_table (HostTable *table, SkyList *sky) { 238 239 // launch the relastro_client jobs to the parallel hosts 92 240 93 241 int i, j; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/UpdateObjects.c
r37038 r37822 1 1 # include "relastro.h" 2 # define PAR_TOOFEW 5 3 4 int UpdateObjects_Chips (Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int Nsecfilt, FitStats *fitStats, int i, off_t m, int applyGalaxyOffset); 5 int UpdateObjects_Stack (Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int Nsecfilt, FitStats *fitStats); 2 6 3 7 static off_t Nmax; … … 13 17 static double *C_red; 14 18 19 static Coords coords; 20 21 static time_t T2000; 22 23 void initFitStats (FitStats *fitStats) { 24 fitStats->Nave = 0; 25 fitStats->Npm = 0; 26 fitStats->Npar = 0; 27 fitStats->Nskip = 0; 28 fitStats->Noffset = 0; 29 return; 30 } 31 32 void sumFitStats (FitStats *srcFitStats, FitStats *tgtFitStats) { 33 tgtFitStats->Nave += srcFitStats->Nave ; 34 tgtFitStats->Npm += srcFitStats->Npm ; 35 tgtFitStats->Npar += srcFitStats->Npar ; 36 tgtFitStats->Nskip += srcFitStats->Nskip ; 37 tgtFitStats->Noffset += srcFitStats->Noffset ; 38 return; 39 } 40 15 41 void initObjectData (Catalog *catalog, int Ncatalog) { 16 42 … … 41 67 ALLOCATE (C_blue, double, MAX (1, Nmax)); 42 68 ALLOCATE (C_red, double, MAX (1, Nmax)); 69 70 /* project coordinates to a plane centered on the object with units of arcsec */ 71 InitCoords (&coords, "DEC--SIN"); 72 coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0; 73 74 // use J2000 as a reference time 75 T2000 = ohana_date_to_sec ("2000/01/01,12:00:00"); 43 76 } 44 77 … … 66 99 // This function operates on both Measure and MeasureTiny. In the big stages, this should 67 100 // be called with just MeasureTiny set and Measure == NULL 68 int UpdateObjects (Catalog *catalog, int Ncatalog) { 69 70 off_t j, k, m; 71 int i, N, NcBlue, NcRed, Nsecfilt, mode, result, status, XVERB; 72 StatType statsR, statsD; 73 Coords coords; 74 PMFit fitAve, fitPM, fitPAR, fit; 75 time_t T2000; 76 off_t Nave, Npm, Npar, Nskip, Noffset; 77 off_t NaveSum, NpmSum, NparSum, NskipSum, NoffSum; 78 double Tmin, Tmax, Tmean, Trange; 79 80 memset (&fit, 0, sizeof(fit)); 81 memset (&fitAve, 0, sizeof(fitAve)); 82 memset (&fitPM, 0, sizeof(fitPM)); 83 memset (&fitPAR, 0, sizeof(fitPAR)); 101 int UpdateObjects (Catalog *catalog, int Ncatalog, int Nloop) { 102 84 103 initObjectData (catalog, Ncatalog); 85 104 86 int setRefColor = areImagesMatched();87 88 /* project coordinates to a plane centered on the object with units of arcsec */89 coords.crval1 = 0;90 coords.crval2 = 0;91 coords.crpix1 = 0;92 coords.crpix2 = 0;93 coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0;94 coords.pc1_1 = coords.pc2_2 = 1.0;95 coords.pc1_2 = coords.pc2_1 = 0.0;96 coords.Npolyterms = 1;97 strcpy (coords.ctype, "DEC--SIN");98 99 XVERB = FALSE;100 101 // use J2000 as a reference time102 T2000 = ohana_date_to_sec ("2000/01/01");103 105 // XXX in the future, use catalog[0].Nsecfilt only? allow catalogs to have variable Nsecfilt? 104 105 Nsecfilt = GetPhotcodeNsecfilt (); 106 int Nsecfilt = GetPhotcodeNsecfilt (); 106 107 if (Ncatalog) { 107 108 assert (catalog[0].Nsecfilt == Nsecfilt); 108 109 } 109 110 110 NaveSum = NparSum = NpmSum = NoffSum = NskipSum = 0; 111 FitStats sumStatsChips; initFitStats (&sumStatsChips); 112 FitStats sumStatsStack; initFitStats (&sumStatsStack); 113 114 int i; 111 115 for (i = 0; i < Ncatalog; i++) { 112 116 113 117 if (VERBOSE2) fprintf (stderr, "astrometrize catalog %d : "OFF_T_FMT" ave, "OFF_T_FMT" meas\n", i, catalog[i].Naverage, catalog[i].Nmeasure); 114 118 115 Nave = Npar = Npm = Nskip = Noffset = 0; 119 FitStats fitStatsChips; initFitStats (&fitStatsChips); 120 FitStats fitStatsStack; initFitStats (&fitStatsStack); 121 122 off_t j; 116 123 for (j = 0; j < catalog[i].Naverage; j++) { 117 124 /* calculate the average value of R,D for a single star */ 118 119 XVERB = FALSE; 120 fitAve.chisq = NAN; 121 fitPM.chisq = NAN; 122 fitPAR.chisq = NAN; 123 124 // if we fail to fit the astrometry for some reason, we need to set/reset these 125 catalog[i].average[j].flags |= ID_STAR_NO_ASTROM; 126 catalog[i].average[j].ChiSqAve = NAN; 127 catalog[i].average[j].ChiSqPM = NAN; 128 catalog[i].average[j].ChiSqPar = NAN; 129 catalog[i].average[j].Npos = 0; 130 131 if (catalog[i].average[j].Nmeasure == 0) { 125 off_t m = catalog[i].average[j].measureOffset; 126 MeasureTiny *measure = &catalog[i].measureT[m]; 127 Measure *measureBig = catalog[i].measure ? &catalog[i].measure[m] : NULL; 128 Average *average = &catalog[i].average[j]; 129 SecFilt *secfilt = &catalog[i].secfilt[j*Nsecfilt]; 130 131 UpdateObjects_Stack(average, secfilt, measure, measureBig, Nsecfilt, &fitStatsStack); 132 UpdateObjects_Chips(average, secfilt, measure, measureBig, Nsecfilt, &fitStatsChips, i, m, Nloop); 133 } 134 if (VERBOSE2) fprintf (stderr, "catalog %d : chips "OFF_T_FMT" ave, "OFF_T_FMT" pm, "OFF_T_FMT" par : Nskip "OFF_T_FMT", Noffset "OFF_T_FMT"\n", i, fitStatsChips.Nave, fitStatsChips.Npm, fitStatsChips.Npar, fitStatsChips.Nskip, fitStatsChips.Noffset); 135 if (VERBOSE2) fprintf (stderr, "catalog %d : stack "OFF_T_FMT" ave, "OFF_T_FMT" pm, "OFF_T_FMT" par : Nskip "OFF_T_FMT", Noffset "OFF_T_FMT"\n", i, fitStatsStack.Nave, fitStatsStack.Npm, fitStatsStack.Npar, fitStatsStack.Nskip, fitStatsStack.Noffset); 136 sumFitStats (&fitStatsChips, &sumStatsChips); 137 sumFitStats (&fitStatsStack, &sumStatsStack); 138 } 139 freeObjectData (); 140 141 if (VERBOSE && (Ncatalog > 1)) fprintf (stderr, "fitted "OFF_T_FMT" objects ("OFF_T_FMT" ave, "OFF_T_FMT" pm, "OFF_T_FMT" par), skipped "OFF_T_FMT", "OFF_T_FMT" have too large an offset\n", (sumStatsChips.Nave + sumStatsChips.Npm + sumStatsChips.Npar), sumStatsChips.Nave, sumStatsChips.Npm, sumStatsChips.Npar, sumStatsChips.Nskip, sumStatsChips.Noffset); 142 if (VERBOSE && (Ncatalog > 1)) fprintf (stderr, "fitted "OFF_T_FMT" objects ("OFF_T_FMT" ave, "OFF_T_FMT" pm, "OFF_T_FMT" par), skipped "OFF_T_FMT", "OFF_T_FMT" have too large an offset\n", (sumStatsStack.Nave + sumStatsStack.Npm + sumStatsStack.Npar), sumStatsStack.Nave, sumStatsStack.Npm, sumStatsStack.Npar, sumStatsStack.Nskip, sumStatsStack.Noffset); 143 return (TRUE); 144 } 145 146 // This function operates on both Measure and MeasureTiny. In the big stages, this should 147 // be called with just MeasureTiny set and Measure == NULL 148 int UpdateObjects_Chips (Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int Nsecfilt, FitStats *fitStats, int i, off_t m, int applyGalaxyOffset) { 149 150 int setRefColor = areImagesMatched(); 151 152 /* calculate the average value of R,D for a single star */ 153 154 PMFit fit; memset (&fit, 0, sizeof(fit)); 155 PMFit fitAve; memset (&fitAve, 0, sizeof(fitAve)); fitAve.chisq = NAN; 156 PMFit fitPM; memset (&fitPM, 0, sizeof(fitPM)); fitPM.chisq = NAN; 157 PMFit fitPAR; memset (&fitPAR, 0, sizeof(fitPAR)); fitPAR.chisq = NAN; 158 159 // if we fail to fit the astrometry for some reason, we need to set/reset these 160 average[0].flags |= ID_STAR_NO_ASTROM; 161 average[0].ChiSqAve = NAN; 162 average[0].ChiSqPM = NAN; 163 average[0].ChiSqPar = NAN; 164 average[0].Npos = 0; 165 166 // an object with no measurements is externally supplied 167 if (average[0].Nmeasure == 0) return TRUE; 168 169 int NcBlue = 0; 170 int NcRed = 0; 171 int N = 0; 172 173 int mode = FIT_MODE; // start with the globally-defined fit mode 174 175 int XVERB = FALSE; 176 XVERB |= (average[0].objID == OBJ_ID_SRC) && (average[0].catID == CAT_ID_SRC); 177 XVERB |= (average[0].objID == OBJ_ID_DST) && (average[0].catID == CAT_ID_DST); 178 179 // find the basic properties of the detections for this object (Tmin, Tmax, Tmean) 180 off_t k; 181 for (k = 0; k < average[0].Nmeasure; k++) { 182 183 if (XVERB) { 184 char *date = ohana_sec_to_date (measure[k].t); 185 int dbFlagsBig = measureBig ? measureBig[k].dbFlags : 0; 186 fprintf (stderr, OFF_T_FMT" %f %f %s : 0x%08x : 0x%08x\n", k, measure[k].R, measure[k].D, date, measure[k].dbFlags, dbFlagsBig); 187 free (date); 188 } 189 190 // SKIP gpc1 stack data 191 if (isGPC1stack(measure[k].photcode)) continue; 192 193 // SKIP gpc1 forced-warp data 194 if (isGPC1warp(measure[k].photcode)) continue; 195 196 // reset the bit to note that a detection was used (or not) 197 measure[k].dbFlags &= ~ID_MEAS_USED_OBJ; 198 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; } 199 200 // does the measurement pass the supplied filtering constraints? 201 // MeasFilterTestTiny does not test psfQF 202 // exclude bad detections based on: photcodes, psfQF, time range, photflags & astromBadMask, mag_inst 203 int keepMeasure = measureBig ? MeasFilterTest(&measureBig[k], FALSE) : MeasFilterTestTiny(&measure[k], FALSE); 204 if (!keepMeasure) { 205 continue; 206 } 207 208 double Ri = getMeanR (&measure[k], average, secfilt); 209 double Di = getMeanD (&measure[k], average, secfilt); 210 211 // if we are correcting for the Galaxy Motion Model, only should apply it here 212 // (a) when we are working to correct the images (mean R,D assumed to be at J2000) and 213 // (b) if we think the measure R,D is already at the image epoch position 214 if (USE_GALAXY_MODEL && applyGalaxyOffset) { 215 Ri -= measure[k].RoffGAL / 3600.0; 216 Di -= measure[k].DoffGAL / 3600.0; 217 } 218 219 // XXX add in dR,dD GAL here 220 221 // mark (as POOR) any measurements which are deviant from the mean by > ExcludeBogusRadius 222 if (ExcludeBogus) { 223 coords.crval1 = average[0].R; 224 coords.crval2 = average[0].D; 225 double Xi, Yi; 226 RD_to_XY (&Xi, &Yi, Ri, Di, &coords); 227 double radius = hypot(Xi, Yi); 228 if (radius > ExcludeBogusRadius) { 229 measure[k].dbFlags |= ID_MEAS_POOR_ASTROM; 230 if (measureBig) { measureBig[k].dbFlags |= ID_MEAS_POOR_ASTROM; } 132 231 continue; 133 232 } 134 135 NcBlue = 0; 136 NcRed = 0; 137 N = 0; 138 m = catalog[i].average[j].measureOffset; 139 MeasureTiny *measure = &catalog[i].measureT[m]; 140 Measure *measureBig = catalog[i].measure ? &catalog[i].measure[m] : NULL; 141 // when we update the output measure values, we need to do it here 142 143 mode = FIT_MODE; 144 145 // XVERB |= (catalog[i].averge[j].objID == 0xc90) && (catalog[i].average[j].catID == 0x2a1e); 146 XVERB |= (catalog[i].average[j].objID == OBJ_ID_SRC) && (catalog[i].average[j].catID == CAT_ID_SRC); 147 XVERB |= (catalog[i].average[j].objID == OBJ_ID_DST) && (catalog[i].average[j].catID == CAT_ID_DST); 148 149 // find the basic properties of the detections for this object (Tmin, Tmax, Tmean) 150 for (k = 0; k < catalog[i].average[j].Nmeasure; k++) { 151 152 if (XVERB) { 153 char *date = ohana_sec_to_date (measure[k].t); 154 int dbFlagsBig = measureBig ? measureBig[k].dbFlags : 0; 155 fprintf (stderr, OFF_T_FMT" %f %f %s : 0x%08x : 0x%08x\n", k, measure[k].R, measure[k].D, date, measure[k].dbFlags, dbFlagsBig); 156 free (date); 157 } 158 159 // reset the bit to note that a detection was used (or not) 160 measure[k].dbFlags &= ~ID_MEAS_USED_OBJ; 161 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; } 162 163 // does the measurement pass the supplied filtering constraints? 164 // MeasFilterTestTiny does not test psfQF 165 // exclude bad detections based on: photcodes, psfQF, time range, photflags & astromBadMask, mag_inst 166 int keepMeasure = measureBig ? MeasFilterTest(&measureBig[k], FALSE) : MeasFilterTestTiny(&measure[k], FALSE); 167 if (!keepMeasure) { 168 continue; 169 } 170 171 // mark (as POOR) any measurements which are deviant from the mean by > ExcludeBogusRadius 172 if (ExcludeBogus) { 173 double Ri = getMeanR (&measure[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 174 double Di = getMeanD (&measure[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 175 coords.crval1 = catalog[i].average[j].R; 176 coords.crval2 = catalog[i].average[j].D; 177 double Xi, Yi; 178 RD_to_XY (&Xi, &Yi, Ri, Di, &coords); 179 double radius = hypot(Xi, Yi); 180 if (radius > ExcludeBogusRadius) { 181 measure[k].dbFlags |= ID_MEAS_POOR_ASTROM; 182 if (measureBig) { measureBig[k].dbFlags |= ID_MEAS_POOR_ASTROM; } 183 continue; 184 } 185 measure[k].dbFlags &= ~ID_MEAS_POOR_ASTROM; 186 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_POOR_ASTROM; } 187 } 188 189 // outlier rejection 190 if (FALSE && FlagOutlier && (measure[k].dbFlags & ID_MEAS_POOR_ASTROM)) { 191 continue; 192 } 193 194 R[N] = getMeanR (&measure[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 195 D[N] = getMeanD (&measure[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 196 197 // XXX I think this is a problem: T[] is time in years relative to J2000, but ParFactor expects 198 // to get Time in years relative to UNIX Tzero (1970/01/01) 199 T[N] = (measure[k].t - T2000) / (86400*365.25) ; // time relative to J2000 in years 200 201 // dX, dY : error in arcsec -- 202 dX[N] = GetAstromErrorTiny (&measure[k], ERROR_MODE_RA); 203 dY[N] = GetAstromErrorTiny (&measure[k], ERROR_MODE_DEC); 204 205 // allow a given photcode or measurement to be 206 // ignored if the error is NAN (for photcode, set astromErrSys to NaN) 207 if (isnan(dX[N])) continue; 208 if (isnan(dY[N])) continue; 209 210 // add systematic error in quadrature, if desired 211 // only do this after the fit has converged (or you will never improve the poor images) 212 // if (INCLUDE_SYS_ERR) { 213 // float dRsys = FromShortPixels(measure[k].dRsys); 214 // dX[N] = hypot(dX[N], dRsys); 215 // dY[N] = hypot(dY[N], dRsys); 216 // } 217 218 // dX[N] = 0.1; 219 // dY[N] = 0.1; 220 221 dT[N] = measure[k].dt; 222 223 // XXX this is (slightly) inconsistent: dX,dY are the X and Y direction errors in 224 // arcseconds. dR, dD are the errors in those directions in degrees. IF we have 225 // non-circular errors (different values for X and Y), then dR and dD will be 226 // incorrect: they would need to be rotated to take out the position angle 227 dR[N] = dX[N] / 3600.0; 228 dD[N] = dY[N] / 3600.0; 229 230 if (setRefColor) { 231 float colorBlue = getColorBlue (m+k, i); 232 if (!isnan(colorBlue)) { 233 C_blue[NcBlue] = colorBlue; 234 NcBlue++; 235 } 236 float colorRed = getColorRed (m+k, i); 237 if (!isnan(colorRed)) { 238 C_red[NcRed] = colorRed; 239 NcRed++; 240 } 241 } 242 243 measure[k].dbFlags |= ID_MEAS_USED_OBJ; 244 if (measureBig) { measureBig[k].dbFlags |= ID_MEAS_USED_OBJ; } 245 246 N++; 247 } // loop over measurements : catalog[i].average[j].Nmeasure 248 249 // if we have too few good detections for the desired fit, or too limited a 250 // baseline, use a fit with fewer parameters. XXX if we have too few measurements 251 // for even the average position, consider including the lower-quality detections? 252 253 // find Tmin & Tmax from the list of accepted measurements 254 Tmean = 0; 255 Tmin = Tmax = T[0]; 256 for (k = 0; k < N; k++) { 257 Tmin = MIN(Tmin, T[k]); 258 Tmax = MAX(Tmax, T[k]); 259 Tmean += T[k]; 233 measure[k].dbFlags &= ~ID_MEAS_POOR_ASTROM; 234 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_POOR_ASTROM; } 235 } 236 237 // outlier rejection 238 if (FALSE && FlagOutlier && (measure[k].dbFlags & ID_MEAS_POOR_ASTROM)) { 239 continue; 240 } 241 242 R[N] = Ri; 243 D[N] = Di; 244 245 // measure[k].t is UNIX seconds, T2000 is UNIX seconds for J2000. 246 // T[] is time in years since J2000 (jd = 2451545) 247 T[N] = (measure[k].t - T2000) / (86400*365.25) ; // time relative to J2000 in years 248 249 // dX, dY : error in arcsec -- 250 dX[N] = GetAstromErrorTiny (&measure[k], ERROR_MODE_RA); 251 dY[N] = GetAstromErrorTiny (&measure[k], ERROR_MODE_DEC); 252 253 // allow a given photcode or measurement to be 254 // ignored if the error is NAN (for photcode, set astromErrSys to NaN) 255 if (isnan(dX[N])) continue; 256 if (isnan(dY[N])) continue; 257 258 // add systematic error in quadrature, if desired 259 // only do this after the fit has converged (or you will never improve the poor images) 260 // if (INCLUDE_SYS_ERR) { 261 // float dRsys = FromShortPixels(measure[k].dRsys); 262 // dX[N] = hypot(dX[N], dRsys); 263 // dY[N] = hypot(dY[N], dRsys); 264 // } 265 266 // dX[N] = 0.1; 267 // dY[N] = 0.1; 268 269 dT[N] = measure[k].dt; 270 271 // XXX this is (slightly) inconsistent: dX,dY are the X and Y direction errors in 272 // arcseconds. dR, dD are the errors in those directions in degrees. IF we have 273 // non-circular errors (different values for X and Y), then dR and dD will be 274 // incorrect: they would need to be rotated to take out the position angle 275 dR[N] = dX[N] / 3600.0; 276 dD[N] = dY[N] / 3600.0; 277 278 if (setRefColor) { 279 float colorBlue = getColorBlue (m+k, i); 280 if (!isnan(colorBlue)) { 281 C_blue[NcBlue] = colorBlue; 282 NcBlue++; 260 283 } 261 // XXX add the parallax factor range as a criterion as well 262 Trange = Tmax - Tmin; 263 if (Trange < PM_DT_MIN) mode = FIT_AVERAGE; 264 if (((mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) && (N <= PM_TOOFEW)) mode = FIT_AVERAGE; 265 266 if (RELASTRO_OP == OP_HIGH_SPEED) { 267 Tmean = 0.5*(Tmax - Tmin); 268 } else { 269 Tmean /= (float) N; 284 float colorRed = getColorRed (m+k, i); 285 if (!isnan(colorRed)) { 286 C_red[NcRed] = colorRed; 287 NcRed++; 270 288 } 271 272 // too few measurements for average position (require 2 values) 273 if (N < SRC_MEAS_TOOFEW) { 274 if (N < 2) continue; 275 } 276 277 /* we need to do the fit in a locally linear space; choose a ref coordinate */ 278 coords.crval1 = R[0]; 279 coords.crval2 = D[0]; 280 281 // to judge the quality of the PM and PAR fits, we need to fit all three models and compare Chisq 282 283 if ((mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) { 284 // project all of the R,D coordinates to a plane centered on this coordinate. set 285 // the times to be relative to Tmean (this is required for parallax as well) 286 for (k = 0; k < N; k++) { 287 RD_to_XY (&X[k], &Y[k], R[k], D[k], &coords); 288 T[k] -= Tmean; 289 if (XVERB) { 290 fprintf (stderr, OFF_T_FMT" %f %f %f %f %f +/- %f %f\n", k, T[k], R[k], D[k], X[k], Y[k], dX[k], dY[k]); 291 } 292 } 293 294 FitPM (&fitPM, X, dX, Y, dY, T, N, XVERB); 295 296 if (XVERB) fprintf (stderr, "fitted PM: %f - %f : %f %f : %f %f : %f vs %f\n", Tmin, Tmax, fitPM.Ro, fitPM.Do, fitPM.uR, fitPM.uD, fitPM.chisq, fitAve.chisq); 297 298 // project Ro, Do back to RA,DEC 299 XY_to_RD (&fitPM.Ro, &fitPM.Do, fitPM.Ro, fitPM.Do, &coords); 300 if (XVERB) fprintf (stderr, "project: %f %f : %f %f : %f\n", fitPM.Ro, fitPM.Do, fitPM.uR, fitPM.uD, fitPM.p); 301 302 fitPM.p = fitPM.dp = 0.0; 303 catalog[i].average[j].flags |= ID_STAR_FIT_PM; 304 Npm ++; 305 306 // XXX a hard-wired hack... 307 if ((fabs(fitPM.uR) > 2.0) || (fabs(fitPM.uD) > 2.0)) { 308 mode = FIT_AVERAGE; 309 catalog[i].average[j].flags |= ID_STAR_BAD_PM; 310 } 311 } 312 313 if (mode == FIT_PM_AND_PAR) { 314 float pXmin = +2.0; 315 float pXmax = -2.0; 316 float pYmin = +2.0; 317 float pYmax = -2.0; 318 for (k = 0; k < N; k++) { 319 ParFactor (&pX[k], &pY[k], R[k], D[k], T[k], Tmean); 320 pXmin = MIN (pXmin, pX[k]); 321 pXmax = MAX (pXmax, pX[k]); 322 pYmin = MIN (pYmin, pY[k]); 323 pYmax = MAX (pYmax, pY[k]); 324 } 325 float dXRange = pXmax - pXmin; 326 float dYRange = pYmax - pYmin; 327 float parRange = hypot (dXRange, dYRange); 289 } 290 291 measure[k].dbFlags |= ID_MEAS_USED_OBJ; 292 if (measureBig) { measureBig[k].dbFlags |= ID_MEAS_USED_OBJ; } 293 294 N++; 295 } // loop over measurements : average[0].Nmeasure 296 297 if (N < 1) { 298 if (isfinite(average[0].Rstk) && isfinite(average[0].Dstk)) { 299 average[0].R = average[0].Rstk; 300 average[0].D = average[0].Dstk; 301 average[0].dR = average[0].dRstk; 302 average[0].dD = average[0].dDstk; 303 } 304 return FALSE; 305 } 306 307 // if we have too few good detections for the desired fit, or too limited a 308 // baseline, use a fit with fewer parameters. XXX if we have too few measurements 309 // for even the average position, consider including the lower-quality detections? 310 311 // find Tmin & Tmax from the list of accepted measurements 312 double Tmean = 0.0; 313 double Tmin = T[0]; 314 double Tmax = T[0]; 315 for (k = 0; k < N; k++) { 316 Tmin = MIN(Tmin, T[k]); 317 Tmax = MAX(Tmax, T[k]); 318 Tmean += T[k]; 319 } 320 double Trange = Tmax - Tmin; 321 322 if (RELASTRO_OP == OP_HIGH_SPEED) { 323 Tmean = 0.5*(Tmax - Tmin); 324 } else { 325 Tmean /= (float) N; 326 } 327 328 /* we need to do the fit in a locally linear space; choose a ref coordinate */ 329 coords.crval1 = R[0]; 330 coords.crval2 = D[0]; 331 332 // to judge the quality of the PM and PAR fits, we need to fit all three models and compare Chisq 333 334 // project all of the R,D coordinates to a plane centered on this coordinate. set 335 // the times to be relative to Tmean (this is required for parallax as well) 336 for (k = 0; k < N; k++) { 337 RD_to_XY (&X[k], &Y[k], R[k], D[k], &coords); 338 T[k] -= Tmean; 339 if (XVERB) { 340 fprintf (stderr, OFF_T_FMT" %f %f %f %f %f +/- %f %f\n", k, T[k], R[k], D[k], X[k], Y[k], dX[k], dY[k]); 341 } 342 } 343 344 // *** first fit for the proper motion (skip fit if Trange or Npts is too small) *** 345 if ((mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) { 346 if (Trange < PM_DT_MIN) { 347 mode = FIT_AVERAGE; 348 goto skipPM; 349 } 350 if (N <= PM_TOOFEW) { 351 mode = FIT_AVERAGE; 352 goto skipPM; 353 } 354 355 FitPM (&fitPM, X, dX, Y, dY, T, N, XVERB); 356 357 if (XVERB) fprintf (stderr, "fitted PM: %f - %f : %f %f : %f %f : %f vs %f\n", Tmin, Tmax, fitPM.Ro, fitPM.Do, fitPM.uR, fitPM.uD, fitPM.chisq, fitAve.chisq); 358 359 // project Ro, Do back to RA,DEC 360 XY_to_RD (&fitPM.Ro, &fitPM.Do, fitPM.Ro, fitPM.Do, &coords); 361 if (XVERB) fprintf (stderr, "project: %f %f : %f %f : %f\n", fitPM.Ro, fitPM.Do, fitPM.uR, fitPM.uD, fitPM.p); 362 if (fabs(fitPM.Ro) < 0.01) fprintf (stderr, "watch out for 0,360 boundary\n"); 363 // XXX : does this make sense at 0,360 boundary? 364 365 fitPM.p = fitPM.dp = 0.0; 366 average[0].flags |= ID_STAR_FIT_PM; 367 fitStats->Npm ++; 368 369 // XXX a hard-wired hack... 370 if ((fabs(fitPM.uR) > 2.0) || (fabs(fitPM.uD) > 2.0)) { 371 mode = FIT_AVERAGE; 372 average[0].flags |= ID_STAR_BAD_PM; 373 } 374 } 375 376 skipPM: 377 // fit the parallax + proper-motion model 378 // NOTE : we only fit PAR if we have already fitted for proper motion. if we do not fit PM or we fail 379 // to fit PM, we do not attempt PAR. thus failure to fit PAR falls back to PM-only 380 if (mode == FIT_PM_AND_PAR) { 381 if (Trange < PM_DT_MIN) { 382 mode = FIT_PM_ONLY; 383 goto skipPAR; 384 } 385 if (N <= PAR_TOOFEW) { 386 mode = FIT_PM_ONLY; 387 goto skipPAR; 388 } 389 float pXmin = +2.0; 390 float pXmax = -2.0; 391 float pYmin = +2.0; 392 float pYmax = -2.0; 393 for (k = 0; k < N; k++) { 394 ParFactor (&pX[k], &pY[k], R[k], D[k], T[k], Tmean); 395 pXmin = MIN (pXmin, pX[k]); 396 pXmax = MAX (pXmax, pX[k]); 397 pYmin = MIN (pYmin, pY[k]); 398 pYmax = MAX (pYmax, pY[k]); 399 } 400 float dXRange = pXmax - pXmin; 401 float dYRange = pYmax - pYmin; 402 float parRange = hypot (dXRange, dYRange); 328 403 329 # define PAR_TOOFEW 5 330 if ((parRange >= PAR_FACTOR_MIN) && (N > PAR_TOOFEW)) { 331 FitPMandPar (&fitPAR, X, dX, Y, dY, T, pX, pY, N, XVERB); 332 if (XVERB) fprintf (stderr, "fitted PM+PAR: %f - %f : %f %f : %f %f : %f %f : %f vs %f vs %f\n", Tmin, Tmax, fitPAR.Ro, fitPAR.Do, fitPAR.uR, fitPAR.uD, fitPAR.p, fitPAR.dp, fitPAR.chisq, fitPM.chisq, fitAve.chisq); 333 334 XY_to_RD (&fitPAR.Ro, &fitPAR.Do, fitPAR.Ro, fitPAR.Do, &coords); 335 catalog[i].average[j].flags |= ID_STAR_FIT_PAR; 336 Npar ++; 337 338 // XXX a hard-wired hack... 339 if ((fabs(fitPAR.uR) > 2.0) || (fabs(fitPAR.uD) > 2.0)) { 340 mode = FIT_AVERAGE; 341 catalog[i].average[j].flags |= ID_STAR_BAD_PM; 342 } 343 } else { 344 // need to set mode = FIT_PM_ONLY if we do not fit for parallax 345 mode = FIT_PM_ONLY; 346 } 347 } 348 349 // fit the average model 350 if ((mode == FIT_AVERAGE) || (mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) { 351 liststats_pos (R, dR, N, &statsR, XVERB); // WARNING: this function modifies R (do not use after here) 352 liststats_pos (D, dD, N, &statsD, XVERB); // WARNING: this function modifies D (do not use after here) 353 354 fitAve.Ro = statsR.mean; 355 fitAve.dRo = 3600.0*statsR.sigma; 356 357 fitAve.Do = statsD.mean; 358 fitAve.dDo = 3600.0*statsD.sigma; 359 360 fitAve.chisq = 0.5 * (statsR.chisq + statsD.chisq); 361 fitAve.Nfit = N; 362 363 fitAve.uR = fitAve.duR = 0.0; 364 fitAve.uD = fitAve.duD = 0.0; 365 fitAve.p = fitAve.dp = 0.0; 366 catalog[i].average[j].flags |= ID_STAR_FIT_AVE; 367 Nave ++; 368 } 369 370 if (setRefColor) { 371 float colorMedian; 372 dsort (C_blue, NcBlue); 373 colorMedian = (NcBlue > 0) ? C_blue[(int)(0.5*NcBlue)] : NAN; 374 catalog[i].average[j].refColorBlue = colorMedian; 375 dsort (C_red, NcRed); 376 colorMedian = (NcRed > 0) ? C_red[(int)(0.5*NcRed)] : NAN; 377 catalog[i].average[j].refColorRed = colorMedian; 378 } 379 380 /* choose the result based on the chisq values */ 381 // XXXX for now, just use the mode as the result: 382 result = mode; 383 384 switch (result) { 385 case FIT_AVERAGE: 386 catalog[i].average[j].flags |= ID_STAR_USE_AVE; 387 fit = fitAve; 388 break; 389 case FIT_PM_ONLY: 390 catalog[i].average[j].flags |= ID_STAR_USE_PM; 391 fit = fitPM; 392 break; 393 case FIT_PM_AND_PAR: 394 catalog[i].average[j].flags |= ID_STAR_USE_PAR; 395 fit = fitPAR; 396 break; 397 } 398 if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f) pm=(%f %f) plx=(%f +/- %f)\n", 399 catalog[i].average[j].R, 400 catalog[i].average[j].D, 401 fit.Ro, fit.Do, 402 3600*(catalog[i].average[j].R - fit.Ro), 403 3600*(catalog[i].average[j].D - fit.Do), 404 fit.uR, fit.uD, fit.p, fit.dp); 405 406 // make sure that the fit succeeded 407 status = TRUE; 408 status &= finite(fit.Ro); 409 status &= finite(fit.Do); 410 status &= finite(fit.dRo); 411 status &= finite(fit.dDo); 412 status &= finite(fit.uR); 413 status &= finite(fit.uD); 414 status &= finite(fit.duR); 415 status &= finite(fit.duD); 416 status &= finite(fit.p); 417 status &= finite(fit.dp); 418 if (!status) { 419 Nskip ++; 420 continue; 421 } 422 423 // what is the offset relative to the mean fit position? 424 coords.crval1 = catalog[i].average[j].R; 425 coords.crval2 = catalog[i].average[j].D; 426 427 double dXoff, dYoff; 428 RD_to_XY (&dXoff, &dYoff, fit.Ro, fit.Do, &coords); 429 float dPos = hypot (dXoff, dYoff); 430 if (dPos > MaxMeanOffset) { 431 if (Noffset < 100) { 432 fprintf (stderr, "(%f,%f) -> (%f,%f) (%f,%f)\n", coords.crval1, coords.crval2, fit.Ro, fit.Do, dXoff, dYoff); 433 } 434 Noffset ++; 435 continue; 436 } 437 438 439 // the measure fields must be updated before the average fields 440 for (k = 0; k < catalog[i].average[j].Nmeasure; k++) { 441 setMeanR (fit.Ro, &measure[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 442 setMeanD (fit.Do, &measure[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 443 if (measureBig) { 444 setMeanR_Big (fit.Ro, &measureBig[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 445 setMeanD_Big (fit.Do, &measureBig[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 446 } 447 } 448 449 catalog[i].average[j].R = fit.Ro; // RA in degrees 450 catalog[i].average[j].D = fit.Do; // DEC in degrees 451 catalog[i].average[j].dR = fit.dRo; // RA scatter in arcsec 452 catalog[i].average[j].dD = fit.dDo; // DEC scatter in arcsec 453 454 catalog[i].average[j].uR = fit.uR; // RA proper motion in arcsec/year 455 catalog[i].average[j].uD = fit.uD; // DEC proper motion in arcsec/year 456 catalog[i].average[j].duR = fit.duR; // RA proper motion error in arcsec/year 457 catalog[i].average[j].duD = fit.duD; // DEC proper motion error in arcsec/year 458 459 catalog[i].average[j].P = fit.p; // parallax in arcsec 460 catalog[i].average[j].dP = fit.dp; // parallax error in arcsec 461 462 catalog[i].average[j].ChiSqAve = fitAve.chisq; 463 catalog[i].average[j].ChiSqPM = fitPM.chisq; 464 catalog[i].average[j].ChiSqPar = fitPAR.chisq; 465 catalog[i].average[j].Tmean = (Tmean * 86400 * 365.25) + T2000; 466 catalog[i].average[j].Trange = (Trange * 86400 * 365.25); 467 catalog[i].average[j].Npos = fit.Nfit; 468 469 // unset the NO_ASTROM bit (not(NO_ASTROM) == HAVE_ASTROM) 470 catalog[i].average[j].flags &= ~ID_STAR_NO_ASTROM; 471 472 if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f) pm=(%f %f) chisq=(%f, %f, %f)\n", 473 catalog[i].average[j].R, 474 catalog[i].average[j].D, 475 fit.Ro, fit.Do, 476 3600*(catalog[i].average[j].R - fit.Ro), 477 3600*(catalog[i].average[j].D - fit.Do), 478 catalog[i].average[j].uR, 479 catalog[i].average[j].uD, 480 fitAve.chisq, fitPM.chisq, fitPAR.chisq); 481 } 482 483 NaveSum += Nave; 484 NpmSum += Npm; 485 NparSum += Npar; 486 NskipSum += Nskip; 487 NoffSum += Noffset; 488 if (VERBOSE) fprintf (stderr, "catalog %d : "OFF_T_FMT" ave, "OFF_T_FMT" pm, "OFF_T_FMT" par : Nskip "OFF_T_FMT", Noffset "OFF_T_FMT"\n", i, Nave, Npm, Npar, Nskip, Noffset); 489 } 490 491 freeObjectData (); 492 493 if (VERBOSE) fprintf (stderr, "fitted "OFF_T_FMT" objects ("OFF_T_FMT" ave, "OFF_T_FMT" pm, "OFF_T_FMT" par), skipped "OFF_T_FMT", "OFF_T_FMT" have too large an offset\n", (NaveSum + NpmSum + NparSum), NaveSum, NpmSum, NparSum, NskipSum, NoffSum); 404 if (parRange < PAR_FACTOR_MIN) { 405 mode = FIT_PM_ONLY; 406 goto skipPAR; 407 } 408 409 FitPMandPar (&fitPAR, X, dX, Y, dY, T, pX, pY, N, XVERB); 410 if (XVERB) fprintf (stderr, "fitted PM+PAR: %f - %f : %f %f : %f %f : %f %f : %f vs %f vs %f\n", Tmin, Tmax, fitPAR.Ro, fitPAR.Do, fitPAR.uR, fitPAR.uD, fitPAR.p, fitPAR.dp, fitPAR.chisq, fitPM.chisq, fitAve.chisq); 411 412 XY_to_RD (&fitPAR.Ro, &fitPAR.Do, fitPAR.Ro, fitPAR.Do, &coords); 413 average[0].flags |= ID_STAR_FIT_PAR; 414 fitStats->Npar ++; 415 416 if (fabs(fitPM.Ro) < 0.01) fprintf (stderr, "watch out for 0,360 boundary\n"); 417 418 // XXX a hard-wired hack... 419 if ((fabs(fitPAR.uR) > 2.0) || (fabs(fitPAR.uD) > 2.0)) { 420 mode = FIT_PM_ONLY; 421 } 422 } 423 424 skipPAR: 425 { 426 // ALWAYS fit the average model 427 StatType statsR, statsD; 428 liststats_pos (X, dX, N, &statsR, XVERB); // WARNING: this function modifies R (do not use after here) 429 liststats_pos (Y, dY, N, &statsD, XVERB); // WARNING: this function modifies D (do not use after here) 430 431 // project Ro, Do back to RA,DEC 432 XY_to_RD (&fitAve.Ro, &fitAve.Do, statsR.mean, statsD.mean, &coords); 433 if (XVERB) fprintf (stderr, "average: %f %f\n", fitAve.Ro, fitAve.Do); 434 435 fitAve.dRo = statsR.sigma; 436 fitAve.dDo = statsD.sigma; 437 438 fitAve.chisq = (N > 1) ? 0.5 * (statsR.chisq + statsD.chisq) : NAN; 439 fitAve.Nfit = N; 440 441 fitAve.uR = fitAve.duR = 0.0; 442 fitAve.uD = fitAve.duD = 0.0; 443 fitAve.p = fitAve.dp = 0.0; 444 average[0].flags |= ID_STAR_FIT_AVE; 445 fitStats->Nave ++; 446 } 447 448 if (setRefColor) { 449 float colorMedian; 450 dsort (C_blue, NcBlue); 451 colorMedian = (NcBlue > 0) ? C_blue[(int)(0.5*NcBlue)] : NAN; 452 average[0].refColorBlue = colorMedian; 453 dsort (C_red, NcRed); 454 colorMedian = (NcRed > 0) ? C_red[(int)(0.5*NcRed)] : NAN; 455 average[0].refColorRed = colorMedian; 456 } 457 458 /* choose the result based on the chisq values */ 459 // XXXX for now, just use the mode as the result: 460 int result = mode; 461 462 switch (result) { 463 case FIT_AVERAGE: 464 average[0].flags |= ID_STAR_USE_AVE; 465 fit = fitAve; 466 break; 467 case FIT_PM_ONLY: 468 average[0].flags |= ID_STAR_USE_PM; 469 fit = fitPM; 470 break; 471 case FIT_PM_AND_PAR: 472 average[0].flags |= ID_STAR_USE_PAR; 473 fit = fitPAR; 474 break; 475 } 476 if (XVERB) { 477 fprintf (stderr, "%f %f -> %f %f (%f,%f) pm=(%f %f) plx=(%f +/- %f)\n", 478 average[0].R, 479 average[0].D, 480 fit.Ro, fit.Do, 481 3600*(average[0].R - fit.Ro), 482 3600*(average[0].D - fit.Do), 483 fit.uR, fit.uD, fit.p, fit.dp); 484 fprintf (stderr, "-----\n"); 485 } 486 487 // make sure that the fit succeeded 488 int status = TRUE; 489 status &= finite(fit.Ro); 490 status &= finite(fit.Do); 491 status &= finite(fit.dRo); 492 status &= finite(fit.dDo); 493 status &= finite(fit.uR); 494 status &= finite(fit.uD); 495 status &= finite(fit.duR); 496 status &= finite(fit.duD); 497 status &= finite(fit.p); 498 status &= finite(fit.dp); 499 if (!status) { 500 fitStats->Nskip ++; 501 return FALSE; // XXX ?? 502 } 503 504 // what is the offset relative to the mean fit position? 505 coords.crval1 = average[0].R; 506 coords.crval2 = average[0].D; 507 if (isnan(coords.crval1)) { 508 return (FALSE); 509 } 510 if (isnan(coords.crval2)) { 511 return (FALSE); 512 } 513 514 double dXoff, dYoff; 515 RD_to_XY (&dXoff, &dYoff, fit.Ro, fit.Do, &coords); 516 float dPos = hypot (dXoff, dYoff); 517 if (dPos > MaxMeanOffset) { 518 if (fitStats->Noffset < 100) { 519 fprintf (stderr, "(%f,%f) -> (%f,%f) (%f,%f)\n", coords.crval1, coords.crval2, fit.Ro, fit.Do, dXoff, dYoff); 520 } 521 fitStats->Noffset ++; 522 return FALSE; // XXX ?? 523 } 524 525 if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f) pm=(%f %f) chisq=(%f, %f, %f)\n", 526 average[0].R, 527 average[0].D, 528 fit.Ro, fit.Do, 529 3600*(average[0].R - fit.Ro), 530 3600*(average[0].D - fit.Do), 531 average[0].uR, 532 average[0].uD, 533 fitAve.chisq, fitPM.chisq, fitPAR.chisq); 534 535 average[0].R = fit.Ro; // RA in degrees 536 average[0].D = fit.Do; // DEC in degrees 537 average[0].dR = fit.dRo; // RA scatter in arcsec 538 average[0].dD = fit.dDo; // DEC scatter in arcsec 539 540 average[0].uR = fit.uR; // RA proper motion in arcsec/year 541 average[0].uD = fit.uD; // DEC proper motion in arcsec/year 542 average[0].duR = fit.duR; // RA proper motion error in arcsec/year 543 average[0].duD = fit.duD; // DEC proper motion error in arcsec/year 544 545 average[0].P = fit.p; // parallax in arcsec 546 average[0].dP = fit.dp; // parallax error in arcsec 547 548 average[0].ChiSqAve = fitAve.chisq; 549 average[0].ChiSqPM = fitPM.chisq; 550 average[0].ChiSqPar = fitPAR.chisq; 551 552 average[0].Tmean = (Tmean * 86400 * 365.25) + T2000; 553 average[0].Trange = (Trange * 86400 * 365.25); 554 average[0].Npos = fit.Nfit; 555 556 // unset the NO_ASTROM bit (not(NO_ASTROM) == HAVE_ASTROM) 557 average[0].flags &= ~ID_STAR_NO_ASTROM; 558 494 559 return (TRUE); 495 560 } 561 562 // This function operates on both Measure and MeasureTiny. In the big stages, this should 563 // be called with just MeasureTiny set and Measure == NULL 564 int UpdateObjects_Stack (Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int Nsecfilt, FitStats *fitStats) { 565 566 off_t k; 567 568 // set the default values 569 average[0].Rstk = NAN; // RA in degrees 570 average[0].Dstk = NAN; // DEC in degrees 571 average[0].dRstk = NAN; // RA scatter in arcsec 572 average[0].dDstk = NAN; // DEC scatter in arcsec 573 574 /* calculate the average value of R,D for a single star */ 575 PMFit fitAve; 576 memset (&fitAve, 0, sizeof(fitAve)); 577 fitAve.chisq = NAN; 578 579 if (average[0].Nmeasure == 0) return TRUE; 580 581 int N = 0; 582 583 int XVERB = FALSE; 584 XVERB |= (average[0].objID == OBJ_ID_SRC) && (average[0].catID == CAT_ID_SRC); 585 XVERB |= (average[0].objID == OBJ_ID_DST) && (average[0].catID == CAT_ID_DST); 586 587 // find the basic properties of the detections for this object (Tmin, Tmax, Tmean) 588 for (k = 0; k < average[0].Nmeasure; k++) { 589 590 if (XVERB) { 591 char *date = ohana_sec_to_date (measure[k].t); 592 int dbFlagsBig = measureBig ? measureBig[k].dbFlags : 0; 593 fprintf (stderr, "stack: "OFF_T_FMT" %f %f %s : 0x%08x : 0x%08x\n", k, measure[k].R, measure[k].D, date, measure[k].dbFlags, dbFlagsBig); 594 free (date); 595 } 596 597 // SKIP everything except gpc1 stack data 598 if (!isGPC1stack(measure[k].photcode)) continue; 599 600 // exclude bad detections based on: photcodes, psfQF, time range, photflags & astromBadMask, mag_inst 601 int keepMeasure = measureBig ? MeasFilterTest(&measureBig[k], FALSE) : MeasFilterTestTiny(&measure[k], FALSE); 602 if (!keepMeasure) { 603 continue; 604 } 605 606 R[N] = getMeanR (&measure[k], average, secfilt); 607 D[N] = getMeanD (&measure[k], average, secfilt); 608 609 // dX, dY : error in arcsec -- 610 dX[N] = GetAstromErrorTiny (&measure[k], ERROR_MODE_RA); 611 dY[N] = GetAstromErrorTiny (&measure[k], ERROR_MODE_DEC); 612 613 // allow a given photcode or measurement to be 614 // ignored if the error is NAN (for photcode, set astromErrSys to NaN) 615 if (isnan(dX[N])) continue; 616 if (isnan(dY[N])) continue; 617 618 // XXX this is (slightly) inconsistent: dX,dY are the X and Y direction errors in 619 // arcseconds. dR, dD are the errors in those directions in degrees. IF we have 620 // non-circular errors (different values for X and Y), then dR and dD will be 621 // incorrect: they would need to be rotated to take out the position angle 622 dR[N] = dX[N] / 3600.0; 623 dD[N] = dY[N] / 3600.0; 624 625 // XXX use a different flag for stack measurements? 626 // measure[k].dbFlags |= ID_MEAS_USED_OBJ; 627 // if (measureBig) { measureBig[k].dbFlags |= ID_MEAS_USED_OBJ; } 628 629 N++; 630 } // loop over measurements : average[0].Nmeasure 631 632 // if we have too few good detections for the desired fit, or too limited a 633 // baseline, use a fit with fewer parameters. XXX if we have too few measurements 634 // for even the average position, consider including the lower-quality detections? 635 636 // too few measurements for average position (require 2 values) 637 if (N < 1) return FALSE; // XXX ?? 638 639 // find the mean position 640 StatType statsR, statsD; 641 liststats_pos (R, dR, N, &statsR, XVERB); // WARNING: this function modifies R (do not use after here) 642 liststats_pos (D, dD, N, &statsD, XVERB); // WARNING: this function modifies D (do not use after here) 643 644 fitAve.Ro = statsR.mean; 645 fitAve.dRo = 3600.0*statsR.sigma; 646 647 fitAve.Do = statsD.mean; 648 fitAve.dDo = 3600.0*statsD.sigma; 649 650 fitAve.chisq = 0.5 * (statsR.chisq + statsD.chisq); 651 fitAve.Nfit = N; 652 653 // XXX choose stack flag? average[0].flags |= ID_STAR_FIT_AVE; 654 fitStats->Nave ++; 655 656 if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f)\n", 657 average[0].R, 658 average[0].D, 659 fitAve.Ro, fitAve.Do, 660 3600*(average[0].R - fitAve.Ro), 661 3600*(average[0].D - fitAve.Do)); 662 663 // make sure that the fit succeeded 664 int status = TRUE; 665 status &= finite(fitAve.Ro); 666 status &= finite(fitAve.Do); 667 status &= finite(fitAve.dRo); 668 status &= finite(fitAve.dDo); 669 if (!status) { 670 fitStats->Nskip ++; 671 return FALSE; 672 } 673 674 // what is the offset relative to the mean fit position? 675 coords.crval1 = average[0].R; 676 coords.crval2 = average[0].D; 677 678 double dXoff, dYoff; 679 RD_to_XY (&dXoff, &dYoff, fitAve.Ro, fitAve.Do, &coords); 680 float dPos = hypot (dXoff, dYoff); 681 if (dPos > MaxMeanOffset) { 682 if (fitStats->Noffset < 100) { 683 fprintf (stderr, "(%f,%f) -> (%f,%f) (%f,%f)\n", coords.crval1, coords.crval2, fitAve.Ro, fitAve.Do, dXoff, dYoff); 684 } 685 fitStats->Noffset ++; 686 return FALSE; 687 } 688 689 // set the stack position values 690 average[0].Rstk = fitAve.Ro; // RA in degrees 691 average[0].Dstk = fitAve.Do; // DEC in degrees 692 average[0].dRstk = fitAve.dRo; // RA scatter in arcsec 693 average[0].dDstk = fitAve.dDo; // DEC scatter in arcsec 694 695 return (TRUE); 696 } 697 698 496 699 497 700 /* fitting proper-motion and parallax: -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/args.c
r37038 r37822 265 265 remove_argument (N, &argc, argv); 266 266 MaxDensityUse = TRUE; 267 } 268 269 APPLY_OFFSETS = FALSE; 270 if ((N = get_argument (argc, argv, "-apply-offsets"))) { 271 remove_argument (N, &argc, argv); 272 APPLY_OFFSETS = TRUE; 267 273 } 268 274 … … 372 378 } 373 379 380 CHIPMAP = 0; 381 if ((N = get_argument (argc, argv, "-chipmap"))) { 382 remove_argument (N, &argc, argv); 383 CHIPMAP = atoi(argv[N]); 384 remove_argument (N, &argc, argv); 385 386 } 387 374 388 SAVEPLOT = FALSE; 375 389 PLOTSTUFF = FALSE; … … 399 413 RESET = TRUE; 400 414 } 401 402 415 RESET_BAD_IMAGES = FALSE; 403 416 if ((N = get_argument (argc, argv, "-reset-bad-images"))) { 404 417 remove_argument (N, &argc, argv); 405 418 RESET_BAD_IMAGES = TRUE; 419 } 420 RESET_IMAGES = FALSE; 421 if ((N = get_argument (argc, argv, "-reset-images"))) { 422 remove_argument (N, &argc, argv); 423 RESET_IMAGES = TRUE; 406 424 } 407 425 … … 868 886 fprintf (stderr, " -high-speed (code[,code,code]) (code[,code,code]) (radius) (output catdir)\n"); 869 887 fprintf (stderr, " -hpm (radius) (output catdir)\n"); 888 fprintf (stderr, " -chipmap (MaxOrder)\n"); 870 889 fprintf (stderr, " -merge-source (objID) (catID) into (objID) (catID)\n\n"); 871 890 … … 880 899 fprintf (stderr, " -statmode (mode)\n"); 881 900 fprintf (stderr, " -reset\n"); 901 fprintf (stderr, " -reset-images\n"); 882 902 fprintf (stderr, " -nloop (N) : number of image-fit iterations\n"); 883 903 fprintf (stderr, " -update : apply new fit to database\n"); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/assign_images.c
r36630 r37822 23 23 BuildChipMatch (image, Nimage); 24 24 MARKTIME("build chip match for %d images: %f sec\n", (int) Nimage, dtime); 25 26 char mapfile[DVO_MAX_PATH]; 27 snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR); 28 AstromOffsetTable *table = AstromOffsetMapLoad (mapfile, VERBOSE); 29 30 // assign images.coords.offsetMap -> table->map[i] 31 if (table) { 32 AstromOffsetTableMatchChips (image, Nimage, table); 33 } else { 34 table = AstromOffsetTableInit (); 35 } 36 put_astrom_table (table); 25 37 26 38 initMosaics (image, Nimage); … … 89 101 if (!strcmp(&image[j].coords.ctype[4], "-DIS")) continue; 90 102 91 // match the image to its corresponding ASTROMETRIC mosaic (not the same as the Mosaic above)92 if (!FindMosaicForImage (image, Nimage, j)) {93 if (VERBOSE2) fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);94 continue;95 }96 97 103 // Exclude images with crazy astrometry 98 104 // XXX NOTE : this is gpc1-specific … … 150 156 151 157 // this is a bit memory expensive : I am making a complete copy of the image table here 152 off_t Nsubset = regionHosts->hosts[i].Nimage; 153 regionHosts->hosts[i].image[Nsubset] = image[j]; 154 regionHosts->hosts[i].imseq[Nsubset] = j; 155 156 regionHosts->hosts[i].Nimage ++; 157 if (regionHosts->hosts[i].Nimage == regionHosts->hosts[i].NIMAGE) { 158 regionHosts->hosts[i].NIMAGE += D_NIMAGE; 159 REALLOCATE (regionHosts->hosts[i].image, Image, regionHosts->hosts[i].NIMAGE); 160 REALLOCATE (regionHosts->hosts[i].imseq, off_t, regionHosts->hosts[i].NIMAGE); 158 off_t Nsubset = host->Nimage; 159 host->image[Nsubset] = image[j]; 160 host->imseq[Nsubset] = j; 161 162 host->Nimage ++; 163 if (host->Nimage == host->NIMAGE) { 164 host->NIMAGE += D_NIMAGE; 165 REALLOCATE (host->image, Image, host->NIMAGE); 166 REALLOCATE (host->imseq, off_t, host->NIMAGE); 167 } 168 169 // save the astrometry maps, where they exist 170 if (image[j].coords.offsetMap) { 171 if (!host->astromTable) { 172 host->astromTable = AstromOffsetTableInit(); 173 } 174 AstromOffsetTableAddMapFromImage(host->astromTable, &image[j]); 161 175 } 162 176 } … … 199 213 } 200 214 201 int calculate_host_image_bounds (RegionHostTable *regionHosts) {202 203 int i, n;204 off_t j;205 206 for (i = 0; i < regionHosts->Nhosts; i++) {207 208 RegionHostInfo *host = ®ionHosts->hosts[i];209 210 // XXX clear the chip match?211 212 BuildChipMatch (host->image, host->Nimage);213 214 double Rmin = 360.0;215 double Rmax = 0.0;216 double Dmin = +90.0;217 double Dmax = -90.0;218 219 for (j = 0; j < host->Nimage; j++) {220 221 Image *image = &host->image[j];222 223 if (!FindMosaicForImage (host->image, host->Nimage, j)) {224 fprintf (stderr, "missing astrometry? programming error?\n");225 abort ();226 }227 228 // define image corners229 for (n = 0; n < 4; n++) {230 double Xc, Yc, Rc, Dc;231 Xc = Xf[n]*image->NX;232 Yc = Yf[n]*image->NY;233 XY_to_RD (&Rc, &Dc, Xc, Yc, &image->coords);234 Rc = ohana_normalize_angle_to_midpoint (Rc, 180.0);235 236 Rmin = MIN (Rmin, Rc);237 Dmin = MIN (Dmin, Rc);238 239 Rmax = MAX (Rmax, Rc);240 Dmax = MAX (Dmax, Rc);241 }242 243 }244 245 host->RminCat = Rmin;246 host->DminCat = Dmin;247 host->RmaxCat = Rmax;248 host->DmaxCat = Dmax;249 250 // regionHosts needs to have the full outer boundary251 // (so reload_catalogs covers the correct region)252 regionHosts->Rmin = MIN(Rmin, regionHosts->Rmin);253 regionHosts->Rmax = MAX(Rmax, regionHosts->Rmax);254 regionHosts->Dmin = MIN(Dmin, regionHosts->Dmin);255 regionHosts->Dmax = MAX(Dmax, regionHosts->Dmax);256 }257 return TRUE;258 }259 260 261 215 // XXX add a search tree to speed this up? 262 216 int find_host_for_coords (RegionHostTable *regionHosts, double Rc, double Dc) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/bcatalog.c
r36833 r37822 27 27 28 28 /* for outlier rejection, project coordinates to a plane centered on the object with units of arcsec */ 29 coords.crval1 = 0; 30 coords.crval2 = 0; 31 coords.crpix1 = 0; 32 coords.crpix2 = 0; 29 InitCoords (&coords, "DEC--SIN"); 33 30 coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0; 34 coords.pc1_1 = coords.pc2_2 = 1.0;35 coords.pc1_2 = coords.pc2_1 = 0.0;36 coords.Npolyterms = 1;37 strcpy (coords.ctype, "DEC--SIN");38 31 39 32 // XXX in the future, use catalog[0].Nsecfilt only? allow catalogs to have variable Nsecfilt? … … 72 65 if (catalog[0].average[i].Nmeasure <= SRC_MEAS_TOOFEW) { 73 66 continue; 74 // XXX can't (easily) count this for a given chip75 67 } 76 68 … … 84 76 if (RESET) { 85 77 subcatalog[0].average[Naverage].flags &= ~averageBits; 78 } 79 80 // if we want to do static correction to ICRF, keep the ICRF QSOs (regardless of other data quality) 81 if (USE_ICRF_CORRECT && (subcatalog[0].average[Naverage].flags & ID_ICRF_QSO)) { 82 Nm = 0; 83 for (j = 0; j < catalog[0].average[i].Nmeasure; j++) { 84 85 offset = catalog[0].average[i].measureOffset + j; 86 87 CopyMeasureToTiny (&subcatalog[0].measureT[Nmeasure], &catalog[0].measure[offset]); 88 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_SKIP_ASTROM; 89 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_NOCAL; 90 subcatalog[0].measureT[Nmeasure].averef = Naverage; 91 if (RESET) { 92 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_POOR_ASTROM; 93 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_AREA; 94 } 95 96 Nmeasure ++; 97 Nm ++; 98 if (Nmeasure == NMEASURE) { 99 NMEASURE += 1000; 100 REALLOCATE (subcatalog[0].measureT, MeasureTiny, NMEASURE); 101 } 102 } 103 subcatalog[0].average[Naverage].Nmeasure = Nm; 104 Naverage ++; 105 if (Naverage == NAVERAGE) { 106 NAVERAGE += 50; 107 REALLOCATE (subcatalog[0].average, Average, NAVERAGE); 108 REALLOCATE (subcatalog[0].secfilt, SecFilt, NAVERAGE*Nsecfilt); 109 } 110 continue; 111 } 112 113 // if we want to correct to the galay model, we need to use objects with distances determined by Green & Schlafly 114 if (USE_GALAXY_MODEL && !catalog[0].average[i].Nstarpar) { 115 // we may want to add some starpar quality filters... 116 continue; 86 117 } 87 118 … … 116 147 // exclude bogus 117 148 if (ExcludeBogus) { 118 double Ri = getMeanR_Big (&catalog[0].measure[offset], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt]); 119 double Di = getMeanD_Big (&catalog[0].measure[offset], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt]); 120 coords.crval1 = catalog[0].average[i].R; 121 coords.crval2 = catalog[0].average[i].D; 122 double Xi, Yi; 123 RD_to_XY (&Xi, &Yi, Ri, Di, &coords); 124 double radius = hypot(Xi, Yi); 125 if (radius > ExcludeBogusRadius) { 126 NskipBogus ++; 127 if (VERBOSE2) { 128 FILE *foutput = fbogus ? fbogus : stderr; 129 char *date = ohana_sec_to_date(catalog[0].measure[offset].t); 130 fprintf (foutput, "exclude bogus: %10.6f %10.6f : %10.6f %10.6f : %6.2f %6.2f : %6.2f : %5d %s\n", catalog[0].average[i].R, catalog[0].average[i].D, Ri, Di, Xi, Yi, radius, catalog[0].measure[offset].photcode, date); 131 free (date); 132 } 133 continue; 149 double Ri = getMeanR_Big (&catalog[0].measure[offset], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt]); 150 double Di = getMeanD_Big (&catalog[0].measure[offset], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt]); 151 coords.crval1 = catalog[0].average[i].R; 152 coords.crval2 = catalog[0].average[i].D; 153 double Xi, Yi; 154 RD_to_XY (&Xi, &Yi, Ri, Di, &coords); 155 double radius = hypot(Xi, Yi); 156 if (radius > ExcludeBogusRadius) { 157 NskipBogus ++; 158 if (VERBOSE2) { 159 FILE *foutput = fbogus ? fbogus : stderr; 160 char *date = ohana_sec_to_date(catalog[0].measure[offset].t); 161 fprintf (foutput, "exclude bogus: %10.6f %10.6f : %10.6f %10.6f : %6.2f %6.2f : %6.2f : %5d %s\n", catalog[0].average[i].R, catalog[0].average[i].D, Ri, Di, Xi, Yi, radius, catalog[0].measure[offset].photcode, date); 162 free (date); 134 163 } 164 continue; 165 } 135 166 } 136 167 … … 157 188 subcatalog[0].measureT[Nmeasure].averef = Naverage; 158 189 if (RESET) { 159 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_POOR_ASTROM;160 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_AREA;190 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_POOR_ASTROM; 191 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_AREA; 161 192 } 162 193 … … 164 195 Nm ++; 165 196 if (Nmeasure == NMEASURE) { 166 NMEASURE += 1000; 167 REALLOCATE (subcatalog[0].measureT, MeasureTiny, NMEASURE); 168 } 197 NMEASURE += 1000; 198 REALLOCATE (subcatalog[0].measureT, MeasureTiny, NMEASURE); 199 } 200 } 201 // we have filtered this object. do not keep it if we now have too few meas 202 if (Nm <= SRC_MEAS_TOOFEW) { 203 Nmeasure -= Nm; 204 continue; 169 205 } 170 206 subcatalog[0].average[Naverage].Nmeasure = Nm; … … 186 222 assert (Nsecfilt == catalog[0].Nsecfilt); 187 223 188 // limit the total number of stars in the catalog224 // limit the total number of stars in the catalog 189 225 if (MaxDensityUse) { 190 226 LimitDensityCatalog_ByNmeasureGrid (subcatalog, catalog); … … 217 253 218 254 # define SWAPFUNC(A,B){ int tmpI; off_t tmpT; \ 219 tmpI = X[A]; X[A] = X[B]; X[B] = tmpI;\220 tmpT = Y[A]; Y[A] = Y[B]; Y[B] = tmpT;\221 }255 tmpI = X[A]; X[A] = X[B]; X[B] = tmpI; \ 256 tmpT = Y[A]; Y[A] = Y[B]; Y[B] = tmpT; \ 257 } 222 258 # define COMPARE(A,B)(X[A] > X[B]) 223 259 … … 231 267 /* generate a grid in a locally-projected coordinate system, try to select average entries 232 268 from each grid cell in decending Nmeasure order. 233 */269 */ 234 270 int LimitDensityCatalog_ByNmeasureGrid (Catalog *subcatalog, Catalog *oldcatalog) { 235 271 … … 269 305 /* project coordinates to a plane centered on the object with units of arcsec */ 270 306 Coords coords; 307 InitCoords (&coords, "DEC--SIN"); 271 308 coords.crval1 = Rc; 272 309 coords.crval2 = Dc; 273 coords.crpix1 = 0;274 coords.crpix2 = 0;275 310 coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0; 276 coords.pc1_1 = coords.pc2_2 = 1.0;277 coords.pc1_2 = coords.pc2_1 = 0.0;278 coords.Npolyterms = 1;279 strcpy (coords.ctype, "DEC--SIN");280 311 281 312 // convert all average R,D values to X,Y: -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/fitpoly.c
r33652 r37822 78 78 } 79 79 80 int array_print (double **matrix, int Nx, int Ny) { 81 82 int i, j; 83 for (i = 0; i < Nx; i++) { 84 for (j = 0; j < Ny; j++) { 85 fprintf (stderr, "%10.3e ", matrix[i][j]); 86 } 87 fprintf (stderr, "\n"); 88 } 89 return TRUE; 90 } 91 92 int fit_print (CoordFit *fit) { 93 94 fprintf (stderr, "Npts: %d, Norder: %d, Nterms: %d, Nsums: %d, Nelems: %d\n", 95 fit[0].Npts, fit[0].Norder, fit[0].Nterms, fit[0].Nsums, fit[0].Nelems); 96 97 fprintf (stderr, "sums: \n"); 98 array_print (fit[0].sum, fit[0].Nsums, fit[0].Nsums); 99 100 fprintf (stderr, "xsums: \n"); 101 array_print (fit[0].xsum, fit[0].Nterms, fit[0].Nterms); 102 103 fprintf (stderr, "ysums: \n"); 104 array_print (fit[0].ysum, fit[0].Nterms, fit[0].Nterms); 105 106 fprintf (stderr, "xfits: \n"); 107 array_print (fit[0].xfit, fit[0].Nterms, fit[0].Nterms); 108 109 fprintf (stderr, "yfits: \n"); 110 array_print (fit[0].yfit, fit[0].Nterms, fit[0].Nterms); 111 112 return TRUE; 113 } 114 80 115 // XXX use implicit masks as below or explicit masks (with function to set?) 81 116 // XXX eg, add a global mask to this file and … … 134 169 for (j = 0; j < fit[0].Nelems; j++) { 135 170 matrix[i][j] = 0.0; 171 matrix[j][i] = 0.0; 136 172 } 137 173 vector[i][0] = 0.0; … … 148 184 } 149 185 150 if (!dgaussjordan (matrix, vector, fit[0].Nelems, 2)) {186 if (!dgaussjordan_pivot (matrix, vector, fit[0].Nelems, 2, 1e-16)) { 151 187 array_free (matrix, fit[0].Nelems); 152 188 array_free (vector, fit[0].Nelems); … … 277 313 /* this should only apply to the polynomial, not the projection terms */ 278 314 /* compare with psastro supporting code */ 315 // this code will work for linear (Npolyterm == 0 or 1) and linear + map fits 279 316 int fit_apply_coords (CoordFit *fit, Coords *coords, int keepRef) { 280 317 … … 352 389 /* keep the order and type from initial values */ 353 390 391 if (isnan(coords[0].crval1)) { 392 return FALSE; 393 } 394 if (isnan(coords[0].crval2)) { 395 return FALSE; 396 } 397 if (isnan(coords[0].crpix1)) { 398 return FALSE; 399 } 400 if (isnan(coords[0].crpix2)) { 401 return FALSE; 402 } 403 354 404 return (TRUE); 355 405 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/high_speed_objects.c
r37038 r37822 149 149 150 150 // define a local projection 151 InitCoords (&tcoords, "DEC--ARC"); 151 152 tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax); 152 153 if (region[0].Dmax < 90) { … … 155 156 tcoords.crval2 = 90.0; 156 157 } 157 tcoords.crpix1 = 0;158 tcoords.crpix2 = 0;159 158 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 160 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;161 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;162 tcoords.Npolyterms = 1;163 strcpy (tcoords.ctype, "DEC--ARC");164 159 165 160 /* build spatial index (RA sort) referencing input array sequence */ … … 271 266 272 267 populate_tiny_values (&catalogOut, DVO_TV_MEASURE); 273 UpdateObjects (&catalogOut, 1 );268 UpdateObjects (&catalogOut, 1, 0); 274 269 free_tiny_values(&catalogOut); 275 270 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/high_speed_utils.c
r33652 r37822 141 141 off_t n; 142 142 for (n = 0; n < NfieldsA; n++) { 143 valuesA[n] = dbExtractAverages (&catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt], &catalog[0].measure[m], &fieldsA[n]);143 valuesA[n] = dbExtractAverages (&catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt], &catalog[0].measure[m], NULL, NULL, &fieldsA[n]); 144 144 } 145 145 return dbBooleanCond(stackA, NstackA, valuesA); … … 155 155 off_t n; 156 156 for (n = 0; n < NfieldsB; n++) { 157 valuesB[n] = dbExtractAverages (&catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt], &catalog[0].measure[m], &fieldsB[n]);157 valuesB[n] = dbExtractAverages (&catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt], &catalog[0].measure[m], NULL, NULL, &fieldsB[n]); 158 158 } 159 159 return dbBooleanCond(stackB, NstackB, valuesB); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/hpm_objects.c
r37038 r37822 126 126 127 127 // define a local projection 128 InitCoords (&tcoords, "DEC--ARC"); 128 129 tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax); 129 130 if (region[0].Dmax < 90) { … … 132 133 tcoords.crval2 = 90.0; 133 134 } 134 tcoords.crpix1 = 0;135 tcoords.crpix2 = 0;136 135 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 137 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;138 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;139 tcoords.Npolyterms = 1;140 136 strcpy (tcoords.ctype, "DEC--ARC"); 141 137 … … 256 252 // distinguishing a bad fit from a fit with 1 or 2 bad points 257 253 FIT_MODE = FIT_PM_ONLY; 258 UpdateObjects (&testcat, 1 );254 UpdateObjects (&testcat, 1, 0); 259 255 260 256 free_tiny_values(&testcat); … … 286 282 287 283 populate_tiny_values (&catalogOut, DVO_TV_MEASURE); 288 UpdateObjects (&catalogOut, 1 );284 UpdateObjects (&catalogOut, 1, 0); 289 285 free_tiny_values(&catalogOut); 290 286 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/initialize.c
r37038 r37822 9 9 10 10 if (DCR_BLUE_COLOR_POS) fprintf (stderr, "DCR_BLUE_COLOR_POS: %s - %s\n", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG); 11 if (DCR_ BLUE_COLOR_POS) fprintf (stderr, "DCR_BLUE_COLOR_POS: %s - %s\n", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);11 if (DCR_RED_COLOR_POS) fprintf (stderr, "DCR_RED_COLOR_POS: %s - %s\n", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG); 12 12 13 13 if (PHOTCODE_KEEP_LIST) fprintf (stderr, "PHOTCODE_KEEP_LIST: %s\n", PHOTCODE_KEEP_LIST); … … 63 63 initstats (STATMODE); 64 64 65 if (USE_ICRF_CORRECT) { 66 if (!USE_ICRF_LOCAL && !USE_ICRF_SHFIT) { 67 fprintf (stderr, "no ICRF correction method chosen\n"); 68 exit (2); 69 } 70 } 71 if (USE_ICRF_CORRECT) ICRFinit(); 72 65 73 /* XXX drop irrelevant entries */ 66 74 if (SHOW_PARAMS) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/launch_region_hosts.c
r37038 r37822 6 6 int i; 7 7 8 // clear the I/O files 9 for (i = 0; i < regionHosts->Nhosts; i++) { 10 char *syncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanmags.sync"); 11 if (truncate (syncfile, 0)) fprintf (stderr, "trouble clearing syncfile %s\n", syncfile); 12 free (syncfile); 8 // do not remote the sync and fits files if we do a manual run -- user must clear if needed 9 if (!PARALLEL_REGIONS_MANUAL) { 10 // clear the I/O files 11 for (i = 0; i < regionHosts->Nhosts; i++) { 12 char *meansync = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanpos.sync"); 13 if (truncate (meansync, 0)) fprintf (stderr, "trouble clearing meansync %s\n", meansync); 14 free (meansync); 13 15 14 char *fitsfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanmags.fits");15 if (truncate (fitsfile, 0)) fprintf (stderr, "trouble clearing fitsfile %s\n", fitsfile);16 free (fitsfile);16 char *meanfits = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanpos.fits"); 17 if (truncate (meanfits, 0)) fprintf (stderr, "trouble clearing meanfits %s\n", meanfits); 18 free (meanfits); 17 19 18 char *imsyncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagemags.sync");19 if (truncate (imsyncfile, 0)) fprintf (stderr, "trouble clearing imsyncfile %s\n", imsyncfile);20 free (imsyncfile);20 char *meassync = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "measpos.sync"); 21 if (truncate (meassync, 0)) fprintf (stderr, "trouble clearing meassync %s\n", meassync); 22 free (meassync); 21 23 22 char *imfitsfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagemags.fits");23 if (truncate (imfitsfile, 0)) fprintf (stderr, "trouble clearing imfitsfile %s\n", imfitsfile);24 free (imfitsfile);24 char *measfits = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "measpos.fits"); 25 if (truncate (measfits, 0)) fprintf (stderr, "trouble clearing measfits %s\n", measfits); 26 free (measfits); 25 27 26 char *loopsyncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "loop.sync"); 27 if (truncate (loopsyncfile, 0)) fprintf (stderr, "trouble clearing loopsyncfile %s\n", loopsyncfile); 28 free (loopsyncfile); 28 char *icrfsync = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "icrfobj.sync"); 29 if (truncate (icrfsync, 0)) fprintf (stderr, "trouble clearing icrfsync %s\n", icrfsync); 30 free (icrfsync); 31 32 char *icrffits = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "icrfobj.fits"); 33 if (truncate (icrffits, 0)) fprintf (stderr, "trouble clearing icrffits %s\n", icrffits); 34 free (icrffits); 35 36 char *imsyncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagepos.sync"); 37 if (truncate (imsyncfile, 0)) fprintf (stderr, "trouble clearing imsyncfile %s\n", imsyncfile); 38 free (imsyncfile); 39 40 char *imfitsfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagepos.fits"); 41 if (truncate (imfitsfile, 0)) fprintf (stderr, "trouble clearing imfitsfile %s\n", imfitsfile); 42 free (imfitsfile); 43 44 char *loopsyncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "loop.sync"); 45 if (truncate (loopsyncfile, 0)) fprintf (stderr, "trouble clearing loopsyncfile %s\n", loopsyncfile); 46 free (loopsyncfile); 47 } 48 49 char *framesync = make_filename (CATDIR, "master", 0, "frame.corr.sync"); 50 if (truncate (framesync, 0)) fprintf (stderr, "trouble clearing framesync %s\n", framesync); 51 free (framesync); 52 53 char *framefits = make_filename (CATDIR, "master", 0, "frame.corr.fits"); 54 if (truncate (framefits, 0)) fprintf (stderr, "trouble clearing framefits %s\n", framefits); 55 free (framefits); 29 56 } 30 57 … … 37 64 char filename[1024]; 38 65 snprintf (filename, 1024, "%s/Image.%d.fits", CATDIR, host->hostID); 66 if (unlink (filename)) fprintf (stderr, "trouble clearing image %s\n", filename); 39 67 40 68 // write the image subset for this host 41 69 ImageTableSave (filename, host->image, host->Nimage); 70 71 if (host->astromTable) { 72 char mapname[1024]; 73 snprintf (mapname, 1024, "%s/AstroMap.%d.fits", CATDIR, host->hostID); 74 75 // write the image subset for this host 76 AstromOffsetMapSave (host->astromTable, mapname); 77 } 42 78 43 79 char command[1024]; … … 92 128 if (PhotFlagPoor) strextend (command, "+photflagpoor %d", PhotFlagPoor); 93 129 130 if (CHIPMAP) strextend (command, "-chipmap %d", CHIPMAP); 131 if (RESET_IMAGES) strextend (command, "-reset-images"); 132 94 133 if (MinBadQF > 0.0) strextend (command, "-min-bad-psfqf %f", MinBadQF); 95 134 if (MaxMeanOffset != 10.0) strextend (command, "-max-mean-offset %f", MaxMeanOffset); … … 99 138 strextend (command, "-D RELASTRO_DPOS_MAX %f", DPOS_MAX); 100 139 strextend (command, "-D ADDSTAR_RADIUS %f", ADDSTAR_RADIUS); 140 141 strextend (command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL); 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); 101 147 102 148 if (USE_FIXED_PIXCOORDS) strextend (command, "-D USE_FIXED_PIXCOORDS 1"); … … 133 179 } 134 180 181 if (USE_ICRF_CORRECT) return TRUE; 182 183 int status = HarvestRegionHosts (regionHosts); 184 return status; 185 } 186 187 int HarvestRegionHosts (RegionHostTable *regionHosts) { 188 189 int status = TRUE; 190 135 191 if (PARALLEL_REGIONS_MANUAL) { 136 192 fprintf (stderr, "run the relastro_client commands above. when these are done, hit return\n"); 137 193 getchar(); 138 194 } else { 139 RegionHostTableWaitJobsGetIO (regionHosts, __FILE__, __LINE__, VERBOSE);195 status = RegionHostTableWaitJobsGetIO (regionHosts, __FILE__, __LINE__, VERBOSE); 140 196 } 141 142 int status = TRUE;143 for (i = 0; i < regionHosts->Nhosts; i++) {144 status = status && (regionHosts->hosts[i].status == 0);145 }146 147 197 return status; 148 198 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/liststats.c
r34576 r37822 252 252 X2 += M / dM; 253 253 dS += M; 254 if (XVERB) fprintf (stderr, "chisq contrib : %f : %f : %f : %f : %f\n", Mo, 3600.0*(value[i] - Mo), 3600.0*dvalue[i], (value[i] - Mo) / dvalue[i], X2);254 if (XVERB) fprintf (stderr, "chisq contrib : %f : %f : %f : %f : %f\n", Mo, (value[i] - Mo), dvalue[i], (value[i] - Mo) / dvalue[i], X2); 255 255 } 256 256 X2 = X2 / (Nm - 1); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/load_catalogs.c
r37038 r37822 6 6 Catalog *load_catalogs (SkyList *skylist, int *Ncatalog, int subselect, int hostID, char *hostpath, char *syncfile) { 7 7 8 int i, j , Nstar;8 int i, j; 9 9 // int k, m; 10 10 Catalog *catalog, *pcatalog, tcatalog; … … 88 88 89 89 bcatalog_show_skips(); 90 91 Nstar = 0; 90 fprintf (stderr, "included %d ICRF QSOs\n", ICRFmax()); 91 92 int Nstar = 0; 93 int Nmeas = 0; 92 94 for (i = 0; i < Ncat; i++) { 93 95 Nstar += catalog[i].Naverage; 96 Nmeas += catalog[i].Nmeasure; 94 97 if ((sizeof(IDX_T) == 8) && (catalog[i].Nmeasure > 0xffffffff)) { 95 98 fprintf (stderr, "ERROR: using small-sized IDX_T on data with more than 2G detections per table will cause errors\n"); … … 101 104 fprintf (stderr, "warning: insufficient stars %d\n", Nstar); 102 105 } 106 fprintf (stderr, "using %d stars, %d measurements to calibrate\n", Nstar, Nmeas); 103 107 104 108 // if we are running with parallel_images but not a parallel database, we need to … … 170 174 if (FlagOutlier) strextend (command, "-clip %d", CLIP_THRESH); 171 175 if (ExcludeBogus) strextend (command, "-exclude-bogus %f", ExcludeBogusRadius); 176 177 if (USE_ICRF_CORRECT) strextend (command, "-D USE_ICRF_CORRECT %d", USE_ICRF_CORRECT); 178 if (USE_GALAXY_MODEL) strextend (command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL); 172 179 173 180 if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/load_images.c
r36630 r37822 1 1 # include "relastro.h" 2 3 static AstromOffsetTable *table = NULL; 4 5 /* AstromOffsetMap is the map of Astrometry Offsets for non-polynomial astrometric 6 * corrections for each chip. 7 */ 2 8 3 9 int load_images (FITS_DB *db, SkyList *skylist, int UseFullOverlap) { … … 17 23 MARKTIME(" convert image table: %f sec\n", dtime); 18 24 25 // assign image->parent and image->coords.mosaic 26 BuildChipMatch (image, Nimage); 27 MARKTIME("build chip match: %f sec\n", dtime); 28 29 char mapfile[DVO_MAX_PATH]; 30 snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR); 31 table = AstromOffsetMapLoad (mapfile, VERBOSE); 32 33 // assign images.coords.offsetMap -> table->map[i] 34 if (table) { 35 AstromOffsetTableMatchChips (image, Nimage, table); 36 } else { 37 table = AstromOffsetTableInit (); 38 } 39 19 40 // select the images which overlap the selected sky regions 20 41 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset, UseFullOverlap); 21 42 MARKTIME(" select images: %f sec\n", dtime); 43 44 if (Nsubset == Nimage) { 45 free (subset); 46 subset = image; 47 } 22 48 23 49 initImages (subset, LineNumber, Nsubset); … … 51 77 return TRUE; 52 78 } 79 80 int save_astrom_table () { 81 82 char mapfile[DVO_MAX_PATH]; 83 snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR); 84 AstromOffsetMapSave (table, mapfile); 85 86 return TRUE; 87 } 88 89 AstromOffsetTable *get_astrom_table () { 90 return table; 91 } 92 93 void put_astrom_table (AstromOffsetTable *myTable) { 94 table = myTable; 95 } 96 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/markObjects.c
r37038 r37822 14 14 int m = catalog[i].average[j].measureOffset; 15 15 for (n = 0; n < catalog[i].average[j].Nmeasure; n++) { 16 if (!catalog[i].measureT[m+n].myDet) continue; 17 nOwn ++; 16 // this is a detection I own (it is on one of my images) 17 if (catalog[i].measureT[m+n].myDet) { 18 nOwn ++; 19 continue; 20 } 21 // 2MASS detections are counted as 'owned' (I completely control this object is nOwn_t == Nmeasure; no sharing needed) 22 if ((catalog[i].measureT[m+n].photcode == 2011) || 23 (catalog[i].measureT[m+n].photcode == 2012) || 24 (catalog[i].measureT[m+n].photcode == 2013)) { 25 nOwn ++; 26 continue; 27 } 18 28 } 19 29 catalog[i].nOwn_t[j] = nOwn; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/relastroVisual.c
r37038 r37822 24 24 /** Spawn a kapa window */ 25 25 static int initWindow(int *kapid) { 26 if (NTHREADS) { 27 fprintf (stderr, "-visual and -threads are incompatible, quitting\n"); 28 exit (2); 29 } 26 30 if (*kapid == -1) { 27 31 *kapid = KapaOpenNamedSocket("kapa", "relastro_plots"); … … 348 352 349 353 int i; 350 for (i = 0; i < numObj; i++) {354 for (i = 0; i < numObj; i++) { 351 355 if (raw[i].mask) continue; // XXX 352 356 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/relastro_client.c
r36833 r37822 79 79 load_images (&db, skylist, FALSE); 80 80 81 // I can free the database after I have loaded the images... 82 81 83 // // load the image subset table from the specified location 82 84 // off_t Nimage; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/relastro_images.c
r36833 r37822 23 23 MARKTIME("load images: %f sec\n", dtime); 24 24 25 initCoords();26 27 25 /* load catalog data from region files : subselect high-quality measurements */ 28 // XXX pass in the image table29 // XXX who carries the image grid?30 26 31 27 // photcodesKeep is used here to allow measurements from the images being calibrated … … 33 29 catalog = load_catalogs (skylist, &Ncatalog, TRUE, 0, NULL, NULL); 34 30 MARKTIME("load catalog data: %f sec\n", dtime); 31 32 // find ICRF QSOs for reference downstream (only if USE_ICRF_CORRECT) 33 select_catalog_ICRF (catalog, Ncatalog); 35 34 36 35 if (photcodesReset) { … … 65 64 case TARGET_SIMPLE: 66 65 for (i = 0; i < NLOOP; i++) { 67 UpdateObjects (catalog, Ncatalog );66 UpdateObjects (catalog, Ncatalog, i); 68 67 UpdateSimple (catalog, Ncatalog); 69 68 } … … 71 70 72 71 case TARGET_CHIPS: 72 if (RESET_IMAGES) UpdateMeasures (catalog, Ncatalog); 73 73 for (i = 0; i < NLOOP; i++) { 74 UpdateObjects (catalog, Ncatalog); 75 UpdateChips (catalog, Ncatalog); 74 UpdateObjects (catalog, Ncatalog, (i > 0)); // calculate <R>,<D>; if (i > 0), apply Galaxy Motion Model (if desired) 75 if ((i > 1) || !USE_GALAXY_MODEL) { 76 // if GALAXY_MODEL is selected, we want to delay the frame correction until we have 77 // applied the galaxy model a couple of times. 78 FrameCorrectionSerial (catalog, Ncatalog); 79 } 80 UpdateChips (catalog, Ncatalog); // measure.X,Y -> R,D, fit image.coords 76 81 MARKTIME("update chips: %f sec\n", dtime); 77 82 } … … 82 87 case TARGET_MOSAICS: 83 88 for (i = 0; i < NLOOP; i++) { 84 UpdateObjects (catalog, Ncatalog );89 UpdateObjects (catalog, Ncatalog, i); 85 90 UpdateMosaic (catalog, Ncatalog); 86 91 } … … 102 107 if (PARALLEL) { 103 108 // save the updated image parameters 109 // need to also save the image map table... 110 save_astrom_table (); 104 111 dvo_image_update (&db, VERBOSE); 105 112 dvo_image_unlock (&db); … … 109 116 UpdateObjectOffsets (skylist, 0, NULL); 110 117 111 // iterate over catalogs to make detection coordinates consistant112 // FixProblemImages (skylist);113 114 118 if (!PARALLEL) { 115 119 // save the updated image parameters 120 save_astrom_table (); 116 121 dvo_image_update (&db, VERBOSE); 117 122 dvo_image_unlock (&db); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/relastro_objects.c
r36833 r37822 77 77 populate_tiny_values(&catalog, DVO_TV_MEASURE); 78 78 79 UpdateObjects (&catalog, 1 );79 UpdateObjects (&catalog, 1, 0); 80 80 81 81 free_tiny_values(&catalog); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/relastro_parallel_images.c
r36833 r37822 17 17 INITTIME; 18 18 19 client_logger_init (CATDIR); 20 19 21 // load the RegionTable (UserRegion should not be used at this level) 20 22 RegionHostTable *regionHosts = RegionHostTableLoad (CATDIR, REGION_FILE); 21 23 int myHost = regionHosts->index[REGION_HOST_ID]; 22 24 RegionHostFindNeighbors (regionHosts, myHost); 25 client_logger_message ("started parallel images on %s\n", regionHosts->hosts[myHost].hostname); 23 26 24 27 // load the subset images belonging to this host … … 29 32 exit (2); 30 33 } 34 35 // assign image->parent and image->coords.mosaic 36 BuildChipMatch (image, Nimage); 37 38 char mapfile[DVO_MAX_PATH]; 39 snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.%d.fits", CATDIR, REGION_HOST_ID); 40 AstromOffsetTable *table = AstromOffsetMapLoad (mapfile, VERBOSE); 41 42 // assign images.coords.offsetMap -> table->map[i] 43 if (table) { 44 AstromOffsetTableMatchChips (image, Nimage, table); 45 } else { 46 table = AstromOffsetTableInit (); 47 } 48 put_astrom_table (table); 49 client_logger_message ("loaded images on %s\n", regionHosts->hosts[myHost].hostname); 31 50 32 51 // once we have read this table, we should remove it for repeat runs … … 42 61 SkyList *skylist = SkyListByBounds (sky, -1, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 43 62 44 initCoords();45 46 63 /* load catalog data from region files (hostID is 0 since we are not a client */ 47 64 char *syncfile = make_filename (CATDIR, regionHosts->hosts[myHost].hostname, REGION_HOST_ID, "loadcat.sync"); 48 65 catalog = load_catalogs (skylist, &Ncatalog, TRUE, 0, NULL, syncfile); 49 MARKTIME("-- load catalog data : %f sec\n", dtime);66 MARKTIME("-- load catalog data, host %d: %f sec\n", REGION_HOST_ID, dtime); 50 67 free (syncfile); 51 68 69 client_logger_message ("loaded catalog data %s\n", regionHosts->hosts[myHost].hostname); 70 71 // find ICRF QSOs for reference downstream (only if USE_ICRF_CORRECT) 72 select_catalog_ICRF (catalog, Ncatalog); 73 52 74 if (photcodesReset) { 53 75 photcodesKeep = photcodesReset; … … 60 82 /* match measurements with images, mosaics */ 61 83 initImageBins (catalog, Ncatalog, TRUE); 62 MARKTIME("-- make image bins : %f sec\n", dtime);84 MARKTIME("-- make image bins, host %d: %f sec\n", REGION_HOST_ID, dtime); 63 85 64 86 findImages (catalog, Ncatalog, TRUE); 65 MARKTIME("-- set up image indexes : %f sec\n", dtime);87 MARKTIME("-- set up image indexes, host %d: %f sec\n", REGION_HOST_ID, dtime); 66 88 67 89 // set test points based on the starmap 68 90 createStarMap (catalog, Ncatalog); 91 92 client_logger_message ("set up image indexes on %s\n", regionHosts->hosts[myHost].hostname); 69 93 70 94 markObjects (catalog, Ncatalog); … … 72 96 SAVEPLOT = FALSE; 73 97 98 client_logger_message ("starting the loops: %s\n", regionHosts->hosts[myHost].hostname); 99 74 100 /* major modes */ 75 101 switch (FIT_TARGET) { 76 102 case TARGET_SIMPLE: 77 103 for (i = 0; i < NLOOP; i++) { 78 UpdateObjects (catalog, Ncatalog );104 UpdateObjects (catalog, Ncatalog, i); 79 105 share_mean_pos (catalog, Ncatalog, regionHosts, i); 80 106 slurp_mean_pos (catalog, Ncatalog, regionHosts, i); 81 107 UpdateSimple (catalog, Ncatalog); 82 108 share_image_pos (regionHosts, i); 83 slurp_image_pos ( regionHosts, i);109 slurp_image_pos (catalog, Ncatalog, regionHosts, i); 84 110 } 85 111 break; 86 112 87 113 case TARGET_CHIPS: 114 if (RESET_IMAGES) { 115 UpdateMeasures (catalog, Ncatalog); 116 MARKTIME("reset measures, host %d: %f sec\n", REGION_HOST_ID, dtime); 117 client_logger_message ("reset measures: %s\n", regionHosts->hosts[myHost].hostname); 118 } 88 119 for (i = 0; i < NLOOP; i++) { 89 UpdateObjects (catalog, Ncatalog); 120 UpdateObjects (catalog, Ncatalog, (i > 0)); 121 MARKTIME("update objects loop %d, host %d: %f sec\n", i, REGION_HOST_ID, dtime); 122 client_logger_message ("update objects loop %d: %s\n", i, regionHosts->hosts[myHost].hostname); 123 if ((i > 1) || !USE_GALAXY_MODEL) { 124 // if GALAXY_MODEL is selected, we want to delay the frame correction until we have 125 // applied the galaxy model a couple of times. 126 FrameCorrectionParallelSlave (catalog, Ncatalog, regionHosts, i); 127 MARKTIME("frame correction loop %d, host %d: %f sec\n", i, REGION_HOST_ID, dtime); 128 client_logger_message ("frame correction loop %d: %s\n", i, regionHosts->hosts[myHost].hostname); 129 } 90 130 share_mean_pos (catalog, Ncatalog, regionHosts, i); 91 131 slurp_mean_pos (catalog, Ncatalog, regionHosts, i); 132 client_logger_message ("slurp mags loop %d: %s\n", i, regionHosts->hosts[myHost].hostname); 133 92 134 UpdateChips (catalog, Ncatalog); 135 MARKTIME("update chips loop %d, host %d: %f sec\n", i, REGION_HOST_ID, dtime); 136 client_logger_message ("update chips loop %d: %s\n", i, regionHosts->hosts[myHost].hostname); 137 93 138 share_image_pos (regionHosts, i); 94 slurp_image_pos (regionHosts, i); 95 MARKTIME("update chips: %f sec\n", dtime); 139 slurp_image_pos (catalog, Ncatalog, regionHosts, i); 140 client_logger_message ("slurp image pos loop %d: %s\n", i, regionHosts->hosts[myHost].hostname); 141 142 share_meas_pos (catalog, Ncatalog, regionHosts, i); 143 slurp_meas_pos (catalog, Ncatalog, regionHosts, i); 144 MARKTIME("done exchange loop %d, host %d: %f sec\n", i, REGION_HOST_ID, dtime); 145 client_logger_message ("slurp meas loop %d: %s\n", i, regionHosts->hosts[myHost].hostname); 96 146 } 97 147 // create summary plots of the process … … 101 151 case TARGET_MOSAICS: 102 152 for (i = 0; i < NLOOP; i++) { 103 UpdateObjects (catalog, Ncatalog );153 UpdateObjects (catalog, Ncatalog, i); 104 154 share_mean_pos (catalog, Ncatalog, regionHosts, i); 105 155 slurp_mean_pos (catalog, Ncatalog, regionHosts, i); 106 156 UpdateMosaic (catalog, Ncatalog); 107 157 share_image_pos (regionHosts, i); 108 slurp_image_pos ( regionHosts, i);158 slurp_image_pos (catalog, Ncatalog, regionHosts, i); 109 159 } 110 160 break; … … 128 178 129 179 share_image_pos (regionHosts, -1); 180 client_logger_message ("share image pos loop %d: %s\n", -1, regionHosts->hosts[myHost].hostname); 130 181 131 182 exit (0); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/relastro_parallel_regions.c
r36630 r37822 44 44 if (!launch_region_hosts (regionHosts)) Shutdown ("error launching region hosts"); 45 45 46 // If we are doing FrameCorrection, we have to loop here waiting for ICRF objects from the region 47 // hosts. we then measure the frame correction and send back the result 48 if (!FrameCorrectionParallelMaster (regionHosts)) Shutdown ("error running parallel frame correction"); 49 46 50 // retrieve updated image parameters from the remote hosts (also set Image.mcal) 47 if (!slurp_image_pos ( regionHosts, -1)) Shutdown ("error loading image updates");51 if (!slurp_image_pos (NULL, 0, regionHosts, -1)) Shutdown ("error loading image updates"); 48 52 49 53 if (!UPDATE) { … … 59 63 60 64 if (PARALLEL) { 61 // save the updated image parameters 65 // save the updated image parameters. if we are NOT PARALLEL, we have to wait 66 // until after UpdateObjectOffsets, or the image parameters are swapped and/or freed 67 save_astrom_table (); 62 68 dvo_image_save (&db, VERBOSE); 63 69 dvo_image_unlock (&db); … … 65 71 66 72 // iterate over catalogs to make detection coordinates consistant 67 UpdateObjectOffsets (skylist, 0, NULL); 73 if (APPLY_OFFSETS) { 74 UpdateObjectOffsets (skylist, 0, NULL); 75 } 68 76 69 77 if (!PARALLEL) { 70 78 // save the changes to the image parameters 79 save_astrom_table (); 71 80 dvo_image_save (&db, VERBOSE); 72 81 dvo_image_unlock (&db); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/select_images.c
r36630 r37822 23 23 int InRange, found; 24 24 double Ri[5], Di[5], Xi[5], Yi[5], dx, dy; 25 Coords tcoords;26 25 SkyRegionCoords *skycoords; 27 26 … … 46 45 47 46 // the comparison is made in the catalog local projection. below we set crval1,2 48 tcoords.crpix1 = tcoords.crpix2 = 0.0; 47 Coords tcoords; 48 InitCoords (&tcoords, "DEC--TAN"); 49 49 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 50 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;51 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;52 strcpy (tcoords.ctype, "DEC--TAN");53 50 54 51 ALLOCATE (skycoords, SkyRegionCoords, skylist[0].Nregions); … … 104 101 105 102 if (VERBOSE) fprintf (stderr, "finding images\n"); 106 BuildChipMatch (timage, Ntimage);107 MARKTIME("build chip match: %f sec\n", dtime);108 103 109 104 nimage = 0; … … 148 143 } 149 144 150 // this adds 1.3 sec for 3M images151 if (!FindMosaicForImage (timage, Ntimage, i)) {152 fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);153 continue;154 }155 156 145 /* define image corners - note the DIS images (mosaic phu) are special */ 157 146 if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/share_images_pos.c
r36630 r37822 34 34 free (iposfile); 35 35 36 // save the per-chip residual table 37 AstromOffsetTable *table = get_astrom_table (); 38 if (table) { 39 char mapname[1024]; 40 snprintf (mapname, 1024, "%s/AstroMapUpdate.%d.fits", CATDIR, REGION_HOST_ID); 41 42 // write the image subset for this host 43 AstromOffsetMapSave (table, mapname); 44 } 45 36 46 char *syncfile = make_filename (CATDIR, hostname, REGION_HOST_ID, "imagepos.sync"); 37 47 update_sync_file (syncfile, nloop); … … 41 51 } 42 52 43 int slurp_image_pos ( RegionHostTable *regionHosts, int nloop) {53 int slurp_image_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop) { 44 54 45 off_t Nimage, i ;55 off_t Nimage, i, j; 46 56 Image *images = getimages (&Nimage, NULL); 47 57 … … 74 84 continue; 75 85 } 86 Coords *moscoords = images[seq].coords.mosaic; 76 87 images[seq].coords = image_pos[i].coords ; 77 images[seq].dXpixSys = image_pos[i].dXpixSys ; 78 images[seq].dYpixSys = image_pos[i].dYpixSys ; 79 images[seq].imageID = image_pos[i].imageID ; 80 images[seq].nFitAstrom = image_pos[i].nFitAstrom; 81 images[seq].flags = image_pos[i].flags ; 88 images[seq].coords.mosaic = moscoords; 89 90 images[seq].dXpixSys = image_pos[i].dXpixSys ; 91 images[seq].dYpixSys = image_pos[i].dYpixSys ; 92 images[seq].refColorBlue = image_pos[i].refColorBlue; 93 images[seq].refColorRed = image_pos[i].refColorRed; 94 images[seq].imageID = image_pos[i].imageID ; 95 images[seq].nFitAstrom = image_pos[i].nFitAstrom; 96 images[seq].flags = image_pos[i].flags ; 97 } 98 99 // load the astrometry offset maps, if they exist, and apply 100 for (i = 0; i < regionHosts->Nhosts; i++) { 101 if (regionHosts->hosts[i].hostID == REGION_HOST_ID) continue; 102 if (REGION_HOST_ID && !regionHosts->hosts[i].isNeighbor) continue; 103 104 char mapname[1024]; 105 snprintf (mapname, 1024, "%s/AstroMapUpdate.%d.fits", CATDIR, regionHosts->hosts[i].hostID); 106 107 AstromOffsetTable *table = AstromOffsetMapLoad (mapname, VERBOSE); 108 109 // apply table entries here to existing images 110 for (j = 0; j < table->Nmap; j++) { 111 off_t seq = getImageByID (table->map[j][0].imageID); 112 // I do not necessarily own all images listed in the table. skip if not found 113 if (seq < 0) continue; 114 115 AstromOffsetMap *oldMap = images[seq].coords.offsetMap; 116 AstromOffsetMap *newMap = table->map[j]; 117 118 if (oldMap) { 119 AstromOffsetMapSetOrder (oldMap, newMap->Nx, newMap->Ny, &images[seq]); 120 AstromOffsetMapCopyData (oldMap, newMap); 121 } else { 122 lockUpdateChips (); 123 AstromOffsetTable *FullTable = get_astrom_table (); 124 AstromOffsetTableNewMap(FullTable, newMap->Nx, newMap->Ny, &images[seq]); // registers the map with the image 125 unlockUpdateChips (); 126 AstromOffsetMapCopyData (images[seq].coords.offsetMap, newMap); // oldMap is now not valid 127 } 128 } 129 AstromOffsetTableFree(table); 130 } 131 132 // apply the modified image parameters to my detections 133 for (i = 0; FALSE && (Ncatalog > 0) && (i < Nimage_pos); i++) { 134 off_t seq = getImageByID (image_pos[i].imageID); 135 if (seq < 0) continue; 136 updateImageRaw (catalog, Ncatalog, seq); 82 137 } 83 138 free (image_pos); … … 93 148 image_pos->dXpixSys = image->dXpixSys; 94 149 image_pos->dYpixSys = image->dYpixSys; 150 image_pos->refColorBlue = image->refColorBlue; 151 image_pos->refColorRed = image->refColorRed; 95 152 image_pos->imageID = image->imageID; 96 153 image_pos->nFitAstrom = image->nFitAstrom; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relastro/src/testparallax.c
r36482 r37822 49 49 50 50 /* project coordinates to a plane centered on the object with units of arcsec */ 51 coords.crval1 = 0; 52 coords.crval2 = 0; 53 coords.crpix1 = 0; 54 coords.crpix2 = 0; 51 InitCoords (&coords, "DEC--SIN"); 55 52 coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0; 56 coords.pc1_1 = coords.pc2_2 = 1.0;57 coords.pc1_2 = coords.pc2_1 = 0.0;58 coords.Npolyterms = 1;59 strcpy (coords.ctype, "DEC--SIN");60 53 61 54 // use one point as a local reference -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/include/relphot.h
r37037 r37822 440 440 int MatchImageName (off_t meas, int cat, char *name); 441 441 int MatchImageSkycellID (off_t meas, int cat, int myTessID, int myProjectionID, int mySkycellID); 442 int FindImageSkycellID (off_t meas, int cat, int *myTessID, int *myProjectionID, int *mySkycellID); 442 443 443 444 int load_tess (char *treefile); … … 451 452 int setMrel_catalog_alt (Catalog *catalog, int Nc, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, int Nsecfilt); 452 453 int setMrelAverageExposure (off_t meas, int cat, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, Average *average, AverageTiny *averageT, SecFilt *secfilt, Measure *measure, MeasureTiny *measureT, off_t *found); 453 int setMrelAverageStack (off_t meas, int cat, FlatCorrectionTable *flatcorr, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, char *primaryCell); 454 int setMrelAverageStack (off_t measureOffset, int cat, FlatCorrectionTable *flatcorr, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, off_t Nmeasure); 455 int setMrelAverageForcedWarp (off_t measureOffset, int cat, int pass, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, off_t *found, off_t Nmeasure); 456 454 457 int setGlobalObjStats (Average *average, Measure *measure); 455 458 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/src/BoundaryTreeOps.c
r36491 r37822 51 51 if (!tess) return FALSE; 52 52 53 status = TessellationPrimaryCellIDs(tess, Ntess, tessID, projID, skycellID, ra, dec); 53 double R = ohana_normalize_angle(ra); 54 status = TessellationPrimaryCellIDs(tess, Ntess, tessID, projID, skycellID, R, dec); 54 55 return status; 55 56 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/src/ImageOps.c
r37037 r37822 35 35 static off_t *imageIdx; // list of index for image IDs 36 36 37 // QQ // as an alternative, we generate imageSeq, which directly maps imageID -> seq 38 // QQ static off_t *imageSeq; // list of index for image IDs 39 // QQ 40 // QQ // MAX_ID requires 512M to store the image index 41 // QQ # define MAX_ID 0x8000000 42 // QQ static off_t minImageID = MAX_ID; 43 // QQ static off_t maxImageID = 0; 44 37 45 // elsewhere, we have loaded a set of catalogs with measures (catalog[cat].measure[meas]) 38 46 // each image has N_onImage[ImageIndex] measurements … … 95 103 96 104 TessellationIDsByImageName (&tessID[i], &projectID[i], &skycellID[i], image[i].name); 105 106 // QQ minImageID = MIN(minImageID, image[i].imageID); 107 // QQ maxImageID = MAX(maxImageID, image[i].imageID); 108 // QQ myAssert (image[i].imageID < MAX_ID, "image IDs too large for index memory"); 97 109 } 98 110 … … 100 112 // XXX does this break the imageID <-> projectID, etc match? 101 113 llsortpair (imageIDs, imageIdx, Nimage); 114 115 // QQ ALLOCATE (imageSeq, off_t, maxImageID + 1); 116 // QQ for (i = 0; i < maxImageID + 1; i++) { 117 // QQ imageSeq[i] = -1; // not yet assigned 118 // QQ } 119 // QQ 120 // QQ for (i = 0; i < Nimage; i++) { 121 // QQ off_t N = image[i].imageID; 122 // QQ myAssert (imageSeq[N] == -1, "previously assigned"); 123 // QQ imageSeq[N] = i; 124 // QQ } 102 125 } 103 126 … … 168 191 off_t getImageByID (off_t ID) { 169 192 193 // QQ if (imageSeq) { 194 // QQ myAssert (ID >= minImageID, "oops"); 195 // QQ myAssert (ID <= maxImageID, "oops"); 196 // QQ off_t N = imageSeq[ID]; 197 // QQ return N; 198 // QQ } 199 170 200 // we have a pair of vectors (imageIDs, imageIdx) sorted by imageIDs 171 201 // use bisection to find the specified image ID … … 491 521 if (projectID[i] != myProjectionID) return FALSE; 492 522 if (skycellID[i] != mySkycellID) return FALSE; 523 524 return TRUE; 525 } 526 527 // returns image.Mcal - ff(x,y) 528 int FindImageSkycellID (off_t meas, int cat, int *myTessID, int *myProjectionID, int *mySkycellID) { 529 530 off_t i; 531 532 if (!MeasureToImage) return FALSE; 533 534 if (meas < 0) return FALSE; 535 536 i = MeasureToImage[cat][meas]; 537 if (i == -1) return FALSE; 538 539 if (tessID[i] == -1) return FALSE; 540 if (projectID[i] == -1) return FALSE; 541 if (skycellID[i] == -1) return FALSE; 542 543 *myTessID = tessID[i]; 544 *myProjectionID = projectID[i]; 545 *mySkycellID = skycellID[i]; 493 546 494 547 return TRUE; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/src/ImageTable.c
r36630 r37822 32 32 } 33 33 34 // XXX do not make the chip match -- we have not loaded the PHU entries (and do not need them here) 35 // BuildChipMatch (image, Nimage); 36 34 37 *nimage = Nimage; 35 38 return image; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/src/MosaicOps.c
r37037 r37822 520 520 m = MosaicToImage[i][j]; 521 521 522 if (!FindMosaicForImage (image, Nimage, m)) {523 if (VERBOSE2) fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);524 continue;525 }526 527 522 NX = image[m].NX; 528 523 NY = image[m].NY; 529 XY_to_RD (&R, &D, 0.5*NX, 0.5*NY, &image[m].coords);524 if (!XY_to_RD (&R, &D, 0.5*NX, 0.5*NY, &image[m].coords)) continue; 530 525 R = ohana_normalize_angle_to_midpoint (R, 180.0); 531 526 … … 587 582 } 588 583 589 strcpy (mosaic[i].coords.ctype, "DEC--TAN");584 InitCoords (&mosaic[i].coords, "DEC--TAN"); 590 585 mosaic[i].coords.crval1 = Rmid; 591 586 mosaic[i].coords.crval2 = Dmid; 592 mosaic[i].coords.crpix1 = 0.0;593 mosaic[i].coords.crpix2 = 0.0;594 587 mosaic[i].coords.cdelt1 = 1.0 / 3600.0; 595 588 mosaic[i].coords.cdelt2 = 1.0 / 3600.0; 596 mosaic[i].coords.pc1_1 = 1.0;597 mosaic[i].coords.pc2_2 = 1.0;598 mosaic[i].coords.pc1_2 = 0.0;599 mosaic[i].coords.pc2_1 = 0.0;600 589 601 590 mosaic[i].Mcal = 0.0; … … 631 620 NY = image[m].NY; 632 621 dS += hypot (image[m].coords.cdelt1*image[m].coords.pc1_1, image[m].coords.cdelt1*image[m].coords.pc2_1); 633 XY_to_RD (&R, &D, 0.0, 0.0, &image[m].coords); 622 623 OhanaProjection proj = GetProjection (image[m].coords.ctype); 624 if ((proj == PROJ_WRP) && !image[m].coords.mosaic) { 625 XY_to_LM (&R, &D, 0.0, 0.0, &image[m].coords); 626 } else { 627 XY_to_RD (&R, &D, 0.0, 0.0, &image[m].coords); 628 } 634 629 Rmin = MIN (Rmin, R); 635 630 Rmax = MAX (Rmax, R); 636 631 Dmin = MIN (Dmin, D); 637 632 Dmax = MAX (Dmax, D); 638 XY_to_RD (&R, &D, (double) NX, 0.0, &image[m].coords); 633 634 if ((proj == PROJ_WRP) && !image[m].coords.mosaic) { 635 XY_to_LM (&R, &D, (double) NX, 0.0, &image[m].coords); 636 } else { 637 XY_to_RD (&R, &D, (double) NX, 0.0, &image[m].coords); 638 } 639 639 Rmin = MIN (Rmin, R); 640 640 Rmax = MAX (Rmax, R); 641 641 Dmin = MIN (Dmin, D); 642 642 Dmax = MAX (Dmax, D); 643 XY_to_RD (&R, &D, (double) NX, (double) NY, &image[m].coords); 643 644 if ((proj == PROJ_WRP) && !image[m].coords.mosaic) { 645 XY_to_LM (&R, &D, (double) NX, (double) NY, &image[m].coords); 646 } else { 647 XY_to_RD (&R, &D, (double) NX, (double) NY, &image[m].coords); 648 } 644 649 Rmin = MIN (Rmin, R); 645 650 Rmax = MAX (Rmax, R); 646 651 Dmin = MIN (Dmin, D); 647 652 Dmax = MAX (Dmax, D); 648 XY_to_RD (&R, &D, 0.0, (double) NY, &image[m].coords); 653 654 if ((proj == PROJ_WRP) && !image[m].coords.mosaic) { 655 XY_to_LM (&R, &D, 0.0, (double) NY, &image[m].coords); 656 } else { 657 XY_to_RD (&R, &D, 0.0, (double) NY, &image[m].coords); 658 } 649 659 Rmin = MIN (Rmin, R); 650 660 Rmax = MAX (Rmax, R); … … 652 662 Dmax = MAX (Dmax, D); 653 663 664 // XXX : this probably does not handle mosaics at RA = 0,360 well 665 654 666 /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */ 655 667 … … 668 680 } 669 681 dS /= MosaicN_Image[i]; 670 strcpy (mosaic[i].coords.ctype, "DEC--TAN"); 682 683 InitCoords (&mosaic[i].coords, "DEC--TAN"); 671 684 mosaic[i].coords.crval1 = Rmin; 672 685 mosaic[i].coords.crval2 = Dmin; 673 mosaic[i].coords.crpix1 = 0.0;674 mosaic[i].coords.crpix2 = 0.0;675 686 mosaic[i].coords.cdelt1 = dS; 676 687 mosaic[i].coords.cdelt2 = dS; 677 mosaic[i].coords.pc1_1 = 1.0; 678 mosaic[i].coords.pc2_2 = 1.0; 679 mosaic[i].coords.pc1_2 = 0.0; 680 mosaic[i].coords.pc2_1 = 0.0; 688 681 689 RD_to_XY (&dX, &dY, Rmax, Dmax, &mosaic[i].coords); 682 690 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/src/StarOps.c
r37037 r37822 1086 1086 if (ecode != thisCode) { continue; } 1087 1087 1088 // SKIP gpc1 stack data 1089 if (isGPC1stack(catalog[i].measureT[m].photcode)) continue; 1090 1091 // SKIP gpc1 forced-warp data 1092 if (isGPC1warp(catalog[i].measureT[m].photcode)) continue; 1093 1088 1094 // NOTE: we do not skip MEAS_BAD because this measurement is just an internal assessment of the outliers 1089 1095 Mcal = getMcal (m, i, flatcorr, catalog); … … 1131 1137 if (ecode != thisCode) { continue; } 1132 1138 1139 // SKIP gpc1 stack data 1140 if (isGPC1stack(catalog[i].measureT[m].photcode)) continue; 1141 1142 // SKIP gpc1 forced-warp data 1143 if (isGPC1warp(catalog[i].measureT[m].photcode)) continue; 1144 1133 1145 // NOTE: we do not skip MEAS_BAD because this measurement is just an internal assessment of the outliers 1134 1146 Mcal = getMcal (m, i, flatcorr, catalog); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/src/assign_images.c
r37037 r37822 80 80 if (!strcmp(&image[j].coords.ctype[4], "-DIS")) continue; 81 81 82 // match the image to its corresponding ASTROMETRIC mosaic (not the same as the Mosaic above)83 if (!FindMosaicForImage (image, Nimage, j)) {84 if (VERBOSE2) fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);85 continue;86 }87 88 82 // Exclude images with crazy astrometry 89 83 // XXX NOTE : this is gpc1-specific … … 123 117 124 118 if (MOSAIC_ZEROPT) { 125 // use the coords of the associated mosaic to select 119 // use the coords of the associated mosaic to select (only for chips; stacks use their own center) 126 120 Mosaic *mosaic = getMosaicForImage (j); 127 Rc = mosaic->coords.crval1; 128 Dc = mosaic->coords.crval2; 129 // NOTE : have defined mosaic Rc,Dc to choose the side of 0,360 on which most of the 130 // chips are located. but, for host assignment, we rationalize to 0.0 - 360.0 131 Rc = ohana_normalize_angle_to_midpoint (Rc, 180.0); 121 if (mosaic) { 122 Rc = mosaic->coords.crval1; 123 Dc = mosaic->coords.crval2; 124 // NOTE : have defined mosaic Rc,Dc to choose the side of 0,360 on which most of the 125 // chips are located. but, for host assignment, we rationalize to 0.0 - 360.0 126 Rc = ohana_normalize_angle_to_midpoint (Rc, 180.0); 127 } 132 128 } 133 129 … … 206 202 } 207 203 208 int calculate_host_image_bounds (RegionHostTable *regionHosts, double Rmid) {209 210 int i, n;211 off_t j;212 213 for (i = 0; i < regionHosts->Nhosts; i++) {214 215 RegionHostInfo *host = ®ionHosts->hosts[i];216 217 // XXX clear the chip match?218 219 BuildChipMatch (host->image, host->Nimage);220 221 double Rmin = 720.0;222 double Rmax = -360.0;223 double Dmin = +90.0;224 double Dmax = -90.0;225 226 for (j = 0; j < host->Nimage; j++) {227 228 Image *image = &host->image[j];229 230 if (!FindMosaicForImage (host->image, host->Nimage, j)) {231 fprintf (stderr, "missing astrometry? programming error?\n");232 abort ();233 }234 235 // define image corners236 for (n = 0; n < 4; n++) {237 double Xc, Yc, Rc, Dc;238 Xc = Xf[n]*image->NX;239 Yc = Yf[n]*image->NY;240 XY_to_RD (&Rc, &Dc, Xc, Yc, &image->coords);241 Rc = ohana_normalize_angle_to_midpoint (Rc, Rmid);242 243 Rmin = MIN (Rmin, Rc);244 Dmin = MIN (Dmin, Rc);245 246 Rmax = MAX (Rmax, Rc);247 Dmax = MAX (Dmax, Rc);248 }249 250 }251 252 // RminCat, RmaxCat may extended beyond 0.0 - 360.0253 host->RminCat = Rmin;254 host->DminCat = Dmin;255 host->RmaxCat = Rmax;256 host->DmaxCat = Dmax;257 258 // regionHosts needs to have the full outer boundary259 // (so reload_catalogs covers the correct region)260 regionHosts->Rmin = MIN(Rmin, regionHosts->Rmin);261 regionHosts->Rmax = MAX(Rmax, regionHosts->Rmax);262 regionHosts->Dmin = MIN(Dmin, regionHosts->Dmin);263 regionHosts->Dmax = MAX(Dmax, regionHosts->Dmax);264 }265 return TRUE;266 }267 268 269 204 // Rc is in range 0.0 - 360.0, hosts Rmin,Rmax in range 0.0 - 360.0 270 205 int find_host_for_coords (RegionHostTable *regionHosts, double Rc, double Dc) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/src/bcatalog.c
r37037 r37822 78 78 int Nsec = GetPhotcodeNsec(thisCode); 79 79 80 fprintf (stderr, "really use dvo_secfilt_init?");80 // fprintf (stderr, "really use dvo_secfilt_init?"); 81 81 dvo_secfilt_init (&subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec]); 82 82 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/src/load_images.c
r35759 r37822 27 27 } 28 28 MARKTIME("read image table: %f sec\n", dtime); 29 30 BuildChipMatch (image, Nimage); 31 MARKTIME("build chip match for %d images: %f sec\n", (int) Nimage, dtime); 32 33 char mapfile[DVO_MAX_PATH]; 34 snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR); 35 AstromOffsetTable *table = AstromOffsetMapLoad (mapfile, VERBOSE); 36 37 // assign images.coords.offsetMap -> table->map[i] 38 if (table) { 39 AstromOffsetTableMatchChips (image, Nimage, table); 40 } 29 41 30 42 // allocate and init an array to identify the images included in the subset -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/src/reload_catalogs.c
r36630 r37822 128 128 } 129 129 130 int reload_catalog_parallel_group (HostTableGroup *group, SkyList *sky, char *imageFile); 131 130 132 // XXX Image to Image Subset 131 133 int reload_catalogs_parallel (SkyList *sky) { … … 165 167 free (BOUNDARY_TREE); 166 168 BOUNDARY_TREE = tmppath; 167 168 } 169 } 170 171 int Ngroups; 172 HostTableGroup *groups = HostTableGroups (table, &Ngroups); 173 // split the table into Ngroups, each with a unique set of machines (this avoids overloading the remote host machines) 174 175 int i; 176 for (i = 0; i < Ngroups; i++) { 177 // update only a group of unique machines at a time 178 reload_catalog_parallel_group (&groups[i], sky, imageFile); 179 } 180 return TRUE; 181 } 182 183 int reload_catalog_parallel_group (HostTableGroup *group, SkyList *sky, char *imageFile) { 169 184 170 185 int i, j; 171 for (i = 0; i < table->Nhosts; i++) {172 173 if (sky->Nregions < table->Nhosts) {186 for (i = 0; i < group->Nhosts; i++) { 187 188 if (sky->Nregions < group->Nhosts) { 174 189 // do any of the regions want this host? 175 190 int wantThisHost = FALSE; 176 191 for (j = 0; j < sky->Nregions; j++) { 177 if (HostTableTestHost (sky->regions[j], table->hosts[i].hostID)) {192 if (HostTableTestHost (sky->regions[j], group->hosts[i][0].hostID)) { 178 193 wantThisHost = TRUE; 179 194 break; … … 181 196 } 182 197 if (!wantThisHost) { 183 // fprintf (stderr, "skip host %s\n", table->hosts[i].hostname);198 // fprintf (stderr, "skip host %s\n", group->hosts[i][0].hostname); 184 199 continue; 185 200 } … … 187 202 188 203 // ensure that the paths are absolute path names 189 char *tmppath = abspath ( table->hosts[i].pathname, DVO_MAX_PATH);190 free ( table->hosts[i].pathname);191 table->hosts[i].pathname = tmppath;204 char *tmppath = abspath (group->hosts[i][0].pathname, DVO_MAX_PATH); 205 free (group->hosts[i][0].pathname); 206 group->hosts[i][0].pathname = tmppath; 192 207 193 208 char command[1024]; 194 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", 195 PhotcodeList, imageFile, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, CAMERA, STAR_TOOFEW, MIN_ERROR);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); 196 211 197 212 // options & configs which affect relphot_client -update-catalogs … … 238 253 // launch the job on the remote machine (no handshake) 239 254 int errorInfo = 0; 240 int pid = rconnect ("ssh", table->hosts[i].hostname, command, table->hosts[i].stdio, &errorInfo, FALSE);255 int pid = rconnect ("ssh", group->hosts[i][0].hostname, command, group->hosts[i][0].stdio, &errorInfo, FALSE); 241 256 if (!pid) { 242 if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", table->hosts[i].hostname, errorInfo);257 if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", group->hosts[i][0].hostname, errorInfo); 243 258 exit (1); 244 259 } 245 table->hosts[i].pid = pid; // save for future reference260 group->hosts[i][0].pid = pid; // save for future reference 246 261 } 247 262 } … … 252 267 } 253 268 if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) { 254 int status = HostTable WaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);269 int status = HostTableGroupWaitJobsGetIO (group, __FILE__, __LINE__, VERBOSE); 255 270 if (!status) { 256 271 fprintf (stderr, "at least one remote client job failed to load data, exiting\n"); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/src/relphot.c
r36630 r37822 9 9 switch (mode) { 10 10 case UPDATE_IMAGES: 11 // IF CALLED WITH NLOOP == 0, DOES NOT LOAD bcatalog, just loads image table and generates ImageSubset.dat 11 12 relphot_images (); 12 13 exit (0); … … 14 15 case UPDATE_AVERAGES: 15 16 // take the current set of detections and set the mean magnitudes 17 // DOES NOT LOAD THE IMAGE TABLE 16 18 relphot_objects (0, NULL); 17 19 exit (0); … … 43 45 exit (1); 44 46 } 47 48 /*** 49 50 I would like to merge the functionality of relphot_images (Nloop == 0), relphot_objects, and apply_offsets 51 52 ***/ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/src/relphot_objects.c
r35104 r37822 36 36 if (!HostTableTestHost(skylist[0].regions[i], hostID)) continue; 37 37 38 // set up the basic catalog info39 38 // set up the basic catalog info 40 39 char hostfile[1024]; -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/src/relphot_parallel_regions.c
r37037 r37822 43 43 MARKTIME("-- load image data: %f sec\n", dtime); 44 44 45 // save Images.dat using the copied structure 46 if (UPDATE_CATFORMAT) { 47 // ensure the db format is updated 48 db.format = dvo_catalog_catformat (UPDATE_CATFORMAT); 49 } 50 45 51 /* assign the images to the different region hosts */ 46 52 if (!assign_images (&db, regionHosts)) Shutdown ("error assigning images to region hosts"); … … 49 55 /* launch processing on the parallel region hosts */ 50 56 if (!launch_region_hosts (regionHosts)) Shutdown ("error launching region hosts"); 57 MARKTIME ("finished relphot -parallel-regions: %f sec total\n", dtime); 51 58 52 59 // retrieve updated image parameters from the remote hosts (also set Image.mcal) -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/src/select_images.c
r36491 r37822 36 36 37 37 // the comparison is made in the catalog local projection. below we set crval1,2 38 tcoords.crpix1 = tcoords.crpix2 = 0.0;38 InitCoords (&tcoords, "DEC--TAN"); 39 39 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 40 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;41 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;42 strcpy (tcoords.ctype, "DEC--TAN");43 40 44 41 double RminSkyRegion = region[0].Rmin; … … 93 90 94 91 if (VERBOSE) fprintf (stderr, "finding images\n"); 95 BuildChipMatch (timage, Ntimage);96 MARKTIME("build chip match for %d images: %f sec\n", (int) Ntimage, dtime);97 92 98 93 D_NIMAGE = 6000; … … 107 102 108 103 if (!(i % 300000)) fprintf (stderr, "."); 104 105 // XXX I am just going for force this for the moment: 106 goto found_it; 109 107 110 108 /* exclude images by photcode */ … … 123 121 } 124 122 125 // this adds 1.3 sec for 3M images126 if (!FindMosaicForImage (timage, Ntimage, i)) {127 if (VERBOSE2) fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);128 continue;129 }130 131 123 /* define image corners - note the DIS images (mosaic phu) are special */ 132 124 if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) { … … 405 397 406 398 // the comparison is made in the catalog local projection. below we set crval1,2 407 tcoords.crpix1 = tcoords.crpix2 = 0.0;399 InitCoords (&tcoords, "DEC--TAN"); 408 400 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 409 tcoords.pc1_1 = tcoords.pc2_2 = 1.0;410 tcoords.pc1_2 = tcoords.pc2_1 = 0.0;411 412 tcoords.Npolyterms = 0;413 memset (tcoords.polyterms, 0, 14*sizeof(float));414 strcpy (tcoords.ctype, "DEC--TAN");415 401 416 402 /* compare with each region file */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/relphot/src/setMrelCatalog.c
r37037 r37822 36 36 } 37 37 38 int setMrelAverageForcedWarp (off_t measureOffset, int cat, int pass, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, off_t *found);39 40 38 int setMrel_catalog_alt (Catalog *catalog, int Nc, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, int Nsecfilt) { 41 39 … … 50 48 int isSetMrelFinal = (pass >= 0); 51 49 52 char *primaryCell = NULL;53 if (isSetMrelFinal) {54 ALLOCATE (primaryCell, char, DVO_MAX_PATH);55 }50 // XX char *primaryCell = NULL; 51 // XX if (isSetMrelFinal) { 52 // XX ALLOCATE (primaryCell, char, DVO_MAX_PATH); 53 // XX } 56 54 57 55 for (j = 0; j < catalog[Nc].Naverage; j++) { … … 60 58 Average *average = catalog[Nc].average ? &catalog[Nc].average[j] : NULL; 61 59 Measure *measure = catalog[Nc].measure ? &catalog[Nc].measure[m] : NULL; 62 setMrelAverageExposure (m, Nc, pass, flatcorr, results, average, &catalog[Nc].averageT[j], &catalog[Nc].secfilt[j*Nsecfilt], measure, &catalog[Nc].measureT[m], &catalog[Nc].found_t[Nsecfilt*j]); 60 SecFilt *secfilt = catalog[Nc].secfilt ? &catalog[Nc].secfilt[j*Nsecfilt] : NULL; 61 setMrelAverageExposure (m, Nc, pass, flatcorr, results, average, &catalog[Nc].averageT[j], secfilt, measure, &catalog[Nc].measureT[m], &catalog[Nc].found_t[Nsecfilt*j]); 63 62 64 63 // only apply Stack operation on setMrelFinal in first pass 65 64 if (isSetMrelFinal && (pass == 0)) { 66 setMrelAverageStack (m, Nc, flatcorr, results, &catalog[Nc].average[j], &catalog[Nc].secfilt[j*Nsecfilt], &catalog[Nc].measure[m], primaryCell);65 setMrelAverageStack (m, Nc, flatcorr, results, average, secfilt, &catalog[Nc].measure[m], catalog[Nc].Nmeasure); 67 66 setGlobalObjStats (&catalog[Nc].average[j], &catalog[Nc].measure[m]); 68 67 } … … 70 69 // only measure force-warp mean values if issetMrelFinal (make it optional?) 71 70 if (isSetMrelFinal) { 72 setMrelAverageForcedWarp (m, Nc, pass, results, &catalog[Nc].average[j], &catalog[Nc].secfilt[j*Nsecfilt], &catalog[Nc].measure[m], &catalog[Nc].foundWarp_t[Nsecfilt*j]);73 setGlobalObjStats ( &catalog[Nc].average[j], &catalog[Nc].measure[m]);74 } 75 } 76 if (primaryCell) free (primaryCell);71 setMrelAverageForcedWarp (m, Nc, pass, results, average, secfilt, measure, &catalog[Nc].foundWarp_t[Nsecfilt*j], catalog[Nc].Nmeasure); 72 setGlobalObjStats (average, measure); 73 } 74 } 75 // if (primaryCell) free (primaryCell); 77 76 return (TRUE); 78 77 } … … 147 146 off_t meas = measureOffset; 148 147 148 float psfQfMax = 0.0; 149 float psfQfPerfMax = 0.0; 150 149 151 int Nap = 0; 150 152 int Npsf = 0; … … 166 168 // SKIP gpc1 forced-warp data 167 169 if (isGPC1warp(measureT[k].photcode)) continue; 170 171 if (isSetMrelFinal) { 172 if (measure[k].psfQF > psfQfMax) psfQfMax = measure[k].psfQF; 173 if (measure[k].psfQFperf > psfQfPerfMax) psfQfPerfMax = measure[k].psfQFperf; 174 } 168 175 169 176 if (measureT[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS(Nbad); … … 367 374 secfilt[Nsec].Mmin = psfstats->min; 368 375 376 secfilt[Nsec].psfQfMax = psfQfMax; 377 secfilt[Nsec].psfQfPerfMax = psfQfPerfMax; 378 369 379 // NOTE : use the modified weight for apmags as well as psf mags 370 380 liststats (Maplist, daplist, waplist, Nap, apstats); … … 441 451 442 452 // only apply Stack operation on setMrelFinal in first pass 443 int setMrelAverageStack (off_t measureOffset, int cat, FlatCorrectionTable *flatcorr, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, char *primaryCell) { 444 445 off_t k, ID; 446 447 float Msys = 0, Mcal= 0, Mmos = 0, Mgrid = 0; 453 // this function has 3 goals, not to be confused: 454 // 1) find and mark the PRIMARY detections (regardless of the quality of the detection) 455 // 2) select the BEST detections per filter (regardless of PRIMARY) 456 // 3) apply the zero point and AB->Jy transformations 457 int setMrelAverageStack (off_t measureOffset, int cat, FlatCorrectionTable *flatcorr, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, off_t Nmeasure) { 458 459 off_t k; 460 461 float Mcal= 0, Mmos = 0, Mgrid = 0, Finst = 0; 448 462 449 463 // set the primary projection cell and skycell for this coordinate … … 453 467 get_tess_ids(&tessID, &projectID, &skycellID, average[0].R, average[0].D); 454 468 469 average[0].tessID = tessID; 470 average[0].projectionID = projectID; 471 average[0].skycellID = skycellID; 472 455 473 int NstackGood = 0; 456 474 int NstackSuspect = 0; … … 467 485 int haveStack = FALSE; 468 486 469 // need to find the measurement closest to the center of its skycell, as well as the 470 // closest for the subset of primary projection cells 471 472 float stackCenterOffsetMin = 1e9; 473 off_t stackCenterMeasureMin = -1; 474 475 float stackPrimaryOffsetMin = 1e9; 476 off_t stackPrimaryMeasureMin = -1; 487 float psfQFbest = 0.0; 488 489 off_t stackBestMeasure = -1; 490 off_t stackPrimaryMeasure = -1; 477 491 478 492 int isBad = FALSE; 479 493 int isSuspect = FALSE; 480 494 495 int Nstack = 0; // number for this photcode 496 int NstackDet = 0; // number for this photcode 497 498 secfilt[Nsec].stackBestOff = -1; 499 secfilt[Nsec].stackPrmryOff = -1; 500 481 501 off_t meas = measureOffset; 482 502 for (k = 0; k < average[0].Nmeasure; k++, meas++) { 503 504 // only examine gpc1 stack data 505 if (!isGPC1stack(measure[k].photcode)) continue; 483 506 484 507 // skip measurements that do not match the current photcode … … 487 510 if (code->equiv != thisCode) { continue; } 488 511 512 Nstack ++; 513 if ((measure[k].photFlags2 & 0x00000004) == 0) NstackDet ++; 514 489 515 // clear this bit for all measurements 490 516 measure[k].dbFlags &= ~ID_MEAS_STACK_PRIMARY; 491 492 // only examine gpc1 stack data 493 if (!isGPC1stack(measure[k].photcode)) continue; 517 measure[k].dbFlags &= ~ID_MEAS_STACK_PHOT_SRC; 494 518 495 519 haveStack = TRUE; 496 520 haveStackObject = TRUE; 497 521 522 // find the PRIMARY measurement 523 524 // if we request the primary (USE_TREE_FOR_PRIMARY), this is true if the measurement is from the 525 // primary skycell for this position 526 if (MatchImageSkycellID (meas, cat, tessID, projectID, skycellID)) { 527 stackPrimaryMeasure = k; 528 measure[k].dbFlags |= ID_MEAS_STACK_PRIMARY; 529 secfilt[Nsec].stackPrmryOff = meas; 530 myAssert (secfilt[Nsec].stackPrmryOff <= Nmeasure, "stackPrmryOff out of range"); 531 } 532 533 // now choose the BEST measurements (may also be PRIMARY) 534 498 535 if (measure[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS_STACK(Nbad); 499 536 500 if (getImageEntry (meas, cat) < 0) continue;501 537 // measurements without an image are either external reference photometry or 502 538 // data for which the associated image has not been loaded (probably because of 503 539 // overlaps). we only want measurements associated with stack images in this loop 504 540 505 Mcal = getMcal_alt (meas, cat, flatcorr, measure[k].Xccd, measure[k].Yccd); 506 if (isnan(Mcal)) SKIP_THIS_MEAS_STACK(Ncal); 507 Mmos = getMmos (meas, cat); 508 if (isnan(Mmos)) SKIP_THIS_MEAS_STACK(Nmos); 509 Mgrid = getMgrid (meas, cat); 510 if (isnan(Mgrid)) SKIP_THIS_MEAS_STACK(Ngrid); 511 512 Msys = PhotSys (&measure[k], &average[0], &secfilt[0], MAG_CLASS_PSF); 513 if (isnan(Msys)) SKIP_THIS_MEAS_STACK(Nsys); 514 515 unsigned int stackImageID; 516 517 // which stack image should we use for the mean value? 518 // if we request the primary (USE_TREE_FOR_PRIMARY), then find the min distances for data from the primary cell 519 if (MatchImageSkycellID (meas, cat, tessID, projectID, skycellID)) { 520 float stackPrimaryOffset = getCenterOffset (meas, cat, &measure[k], &stackImageID); 521 if (stackPrimaryOffset < stackPrimaryOffsetMin) { 522 stackPrimaryOffsetMin = stackPrimaryOffset; 523 // stackPrimaryIDmin = stackImageID; 524 stackPrimaryMeasureMin = k; 525 } 526 } 527 528 // get the center distance for the generic case: 529 float stackCenterOffset = getCenterOffset (meas, cat, &measure[k], &stackImageID); 530 if (stackCenterOffset < stackCenterOffsetMin) { 531 stackCenterOffsetMin = stackCenterOffset; 532 // stackCenterIDmin = stackImageID; 533 stackCenterMeasureMin = k; 541 // match measurement to its image (this is just a check, right?) 542 if (getImageEntry (meas, cat) < 0) { 543 // measurements without an image are either external reference photometry or 544 // data for which the associated image has not been loaded (probably because of 545 // overlaps). Msys + measure.Mcal is our best guess of the true magnitude 546 Mmos = Mgrid = 0; 547 Mcal = measure[k].Mcal; // check that this is zero for loaded REF value 548 } else { 549 Mcal = getMcal_alt (meas, cat, flatcorr, measure[k].Xccd, measure[k].Yccd); 550 if (isnan(Mcal)) SKIP_THIS_MEAS_STACK(Ncal); 551 Mmos = getMmos (meas, cat); 552 if (isnan(Mmos)) SKIP_THIS_MEAS_STACK(Nmos); 553 Mgrid = getMgrid (meas, cat); 554 if (isnan(Mgrid)) SKIP_THIS_MEAS_STACK(Ngrid); 555 } 556 557 // NOTE: negative and insignificant vlues values are allowed, but not NAN flux values 558 Finst = PhotFluxInst (&measure[k], MAG_CLASS_PSF); 559 if (isnan(Finst)) SKIP_THIS_MEAS_STACK(Ninst); 560 561 if (measure[k].psfQFperf > psfQFbest) { 562 psfQFbest = measure[k].psfQFperf; 563 stackBestMeasure = k; 534 564 } 535 565 … … 554 584 555 585 // measurements which are bad will not have a valid stack entry and are skipped 556 k = (stack PrimaryMeasureMin >= 0) ? stackPrimaryMeasureMin : stackCenterMeasureMin;586 k = (stackBestMeasure >= 0) ? stackBestMeasure : stackPrimaryMeasure; 557 587 if (k < 0) continue; 558 559 588 560 589 // we are now populating stackDetectID not stack Image ID in secfilt 561 590 // ID = (stackPrimaryMeasureMin >= 0) ? stackPrimaryIDmin : stackCenterIDmin; 562 ID = measure[k].extID; // for the stack, this is the stackDetectID591 // ID = measure[k].extID; // for the stack, this is the stackDetectID 563 592 564 593 // get the zero point for the selected image … … 605 634 secfilt[Nsec].dFapStk = zpFactor * measure[k].dFluxAp; 606 635 636 // Jy to AB mags 607 637 secfilt[Nsec].MpsfStk = (measure[k].FluxPSF > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FpsfStk) : NAN; 608 638 secfilt[Nsec].MkronStk = (measure[k].FluxKron > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FkronStk) : NAN; 609 639 secfilt[Nsec].MapStk = (measure[k].FluxAp > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FapStk) : NAN; 610 640 611 secfilt[Nsec].stackDetectID = ID; 612 641 secfilt[Nsec].stackBestOff = k + measureOffset; 642 myAssert (secfilt[Nsec].stackBestOff <= Nmeasure, "stackBestOff out of range"); 643 644 secfilt[Nsec].Nstack = Nstack; 645 secfilt[Nsec].NstackDet = NstackDet; 646 647 // this is the measurement used by secfilt[] 613 648 measure[k].dbFlags |= ID_MEAS_STACK_PHOT_SRC; 614 if (stackPrimaryMeasureMin >= 0) { 615 measure[k].dbFlags |= ID_MEAS_STACK_PRIMARY; 649 if (k == stackPrimaryMeasure) { 616 650 secfilt[Nsec].flags |= ID_SECF_STACK_PRIMARY; 617 651 } … … 639 673 // somewhat simplified relative to chip-photometry: 640 674 // * no grid, no mosaic, no 2MASS, no SYNTH, no Ubercal, no flatcorr 641 int setMrelAverageForcedWarp (off_t measureOffset, int cat, int pass, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, off_t *found ) {675 int setMrelAverageForcedWarp (off_t measureOffset, int cat, int pass, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, off_t *found, off_t Nmeasure) { 642 676 643 677 off_t k; 644 float Fsys = 0,Mcal= 0;678 float Mcal= 0; 645 679 646 680 // we are measuring means for 3 types of FLUXes: psf, ap, kron. I am using the psf mag … … 664 698 665 699 // option for a test print 666 if ( FALSE && (average[0].objID == 0x7146) && (average[0].catID == 0x49d8)) {700 if ((average[0].objID == 0xd6e) && (average[0].catID == 0x4984)) { 667 701 fprintf (stderr, "test obj\n"); 668 702 print_measure_set_alt (average, secfilt, measure); … … 680 714 if (found[Nsec]) continue; 681 715 716 // I need to restrict the measurements coming only from the same skycell as the secfilt values 717 // if we cannot make that association, skip this set of warps 718 int stkTessID, stkProjID, stkSkycellID; 719 720 myAssert (secfilt[Nsec].stackBestOff <= Nmeasure, "stackBestOff out of range"); 721 if (!FindImageSkycellID (secfilt[Nsec].stackBestOff, cat, &stkTessID, &stkProjID, &stkSkycellID)) continue; 722 682 723 off_t meas = measureOffset; 683 724 … … 685 726 int Npsf = 0; 686 727 int Nkron = 0; 728 729 int Nwarp = 0; 730 int NwarpGood = 0; 687 731 for (k = 0; k < average[0].Nmeasure; k++, meas++) { 688 732 … … 694 738 if (!code) continue; 695 739 if (code->equiv != thisCode) { continue; } 740 741 Nwarp ++; 742 if (measure[k].psfQFperf > 0.85) NwarpGood ++; 743 744 measure[k].dbFlags &= ~ID_MEAS_WARP_USED; 745 746 if (!MatchImageSkycellID (meas, cat, stkTessID, stkProjID, stkSkycellID)) continue; 696 747 697 748 if (measure[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS(Nbad); … … 720 771 // are small (and not measured) 721 772 float Fpsf = PhotFluxCat (&measure[k], MAG_CLASS_PSF); 722 if (isnan(F sys)) SKIP_THIS_MEAS(Nsys);773 if (isnan(Fpsf)) SKIP_THIS_MEAS(Nsys); 723 774 // if (Msys < 0.0) SKIP_THIS_MEAS(Nsys); 724 775 // if (Msys > 30.0) SKIP_THIS_MEAS(Nsys); 725 776 726 777 float dFpsf = PhotFluxCatErr (&measure[k], MAG_CLASS_PSF); 778 if (isnan(dFpsf)) SKIP_THIS_MEAS (Nsys); 779 780 int isBad = (measure[k].psfQF < 0.85); 781 isBad |= isnan(measure[k].psfQF); 782 if (isBad) SKIP_THIS_MEAS (Nsys); 783 784 int isPoor = (measure[k].psfQFperf < 0.85); 785 if ((pass == 0) && isPoor) SKIP_THIS_MEAS (Nsys); 786 727 787 dFpsf = MAX (dFpsf, MIN_ERROR*Fpsf); // MIN_ERROR is a fractional error 728 788 Fpsflist[Npsf] = Fpsf * Fcal; … … 730 790 wpsflist[Npsf] = 1.0; 731 791 Npsf ++; 792 793 measure[k].dbFlags |= ID_MEAS_WARP_USED; 732 794 733 795 float Fap = PhotFluxCat (&measure[k], MAG_CLASS_APER); … … 775 837 secfilt[Nsec].NusedKronWrp = Nkron; 776 838 secfilt[Nsec].MkronWrp = isnan(secfilt[Nsec].FkronWrp) ? NAN : 8.9 - 2.5*log10(secfilt[Nsec].FkronWrp); // 8.9 since flux is in Jy 839 840 secfilt[Nsec].Nwarp = Nwarp; 841 secfilt[Nsec].NwarpGood = NwarpGood; 777 842 } 778 843 return (TRUE); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/uniphot/Makefile
r35764 r37822 1 default: uniphot setphot setphot_client setfwhm setposangle setposangle_client setastrom setastrom_client fiximids fiximids_client fixstkids fixstkids_client ckids ckids_client1 default: uniphot setphot setphot_client setfwhm setposangle setposangle_client setastrom setastrom_client setgalmodel setgalmodel_client fiximids fiximids_client fixstkids fixstkids_client ckids ckids_client 2 2 help: 3 3 @echo "make options: uniphot setphot setfwhm default help install default (uniphot setphot setfwhm)" … … 25 25 setastrom: $(BIN)/setastrom.$(ARCH) 26 26 setastrom_client: $(BIN)/setastrom_client.$(ARCH) 27 setgalmodel: $(BIN)/setgalmodel.$(ARCH) 28 setgalmodel_client: $(BIN)/setgalmodel_client.$(ARCH) 27 29 fiximids: $(BIN)/fiximids.$(ARCH) 28 30 fiximids_client: $(BIN)/fiximids_client.$(ARCH) … … 32 34 ckids_client: $(BIN)/ckids_client.$(ARCH) 33 35 34 install: $(DESTBIN)/uniphot $(DESTBIN)/setfwhm $(DESTBIN)/setphot $(DESTBIN)/setphot_client $(DESTBIN)/setposangle $(DESTBIN)/setposangle_client $(DESTBIN)/setastrom $(DESTBIN)/setastrom_client $(DESTBIN)/ fiximids $(DESTBIN)/fiximids_client $(DESTBIN)/fixstkids $(DESTBIN)/fixstkids_client $(DESTBIN)/ckids $(DESTBIN)/ckids_client36 install: $(DESTBIN)/uniphot $(DESTBIN)/setfwhm $(DESTBIN)/setphot $(DESTBIN)/setphot_client $(DESTBIN)/setposangle $(DESTBIN)/setposangle_client $(DESTBIN)/setastrom $(DESTBIN)/setastrom_client $(DESTBIN)/setgalmodel $(DESTBIN)/setgalmodel_client $(DESTBIN)/fiximids $(DESTBIN)/fiximids_client $(DESTBIN)/fixstkids $(DESTBIN)/fixstkids_client $(DESTBIN)/ckids $(DESTBIN)/ckids_client 35 37 36 38 UNIPHOT = \ … … 110 112 $(SRC)/setastrom.$(ARCH).o \ 111 113 $(SRC)/initialize_setastrom.$(ARCH).o \ 114 $(SRC)/dcr_correction.$(ARCH).o \ 115 $(SRC)/kh_correction.$(ARCH).o \ 112 116 $(SRC)/astrom_correction.$(ARCH).o \ 113 117 $(SRC)/update_dvo_setastrom.$(ARCH).o \ … … 123 127 $(SRC)/update_dvo_setastrom.$(ARCH).o \ 124 128 $(SRC)/update_catalog_setastrom.$(ARCH).o \ 129 $(SRC)/dcr_correction.$(ARCH).o \ 130 $(SRC)/kh_correction.$(ARCH).o \ 125 131 $(SRC)/astrom_correction.$(ARCH).o \ 126 132 $(SRC)/initialize_setastrom.$(ARCH).o … … 128 134 $(SETASTROM_CLIENT): $(INC)/setastrom.h 129 135 $(BIN)/setastrom_client.$(ARCH): $(SETASTROM_CLIENT) 136 137 SETGALMODEL = \ 138 $(SRC)/setgalmodel.$(ARCH).o \ 139 $(SRC)/initialize_setgalmodel.$(ARCH).o \ 140 $(SRC)/galmodel_correction.$(ARCH).o \ 141 $(SRC)/update_dvo_setgalmodel.$(ARCH).o \ 142 $(SRC)/update_catalog_setgalmodel.$(ARCH).o \ 143 $(SRC)/SetSignals.$(ARCH).o \ 144 $(SRC)/Shutdown.$(ARCH).o 145 146 $(SETGALMODEL): $(INC)/setgalmodel.h 147 $(BIN)/setgalmodel.$(ARCH): $(SETGALMODEL) 148 149 SETGALMODEL_CLIENT = \ 150 $(SRC)/setgalmodel_client.$(ARCH).o \ 151 $(SRC)/update_dvo_setgalmodel.$(ARCH).o \ 152 $(SRC)/update_catalog_setgalmodel.$(ARCH).o \ 153 $(SRC)/galmodel_correction.$(ARCH).o \ 154 $(SRC)/initialize_setgalmodel.$(ARCH).o 155 156 $(SETGALMODEL_CLIENT): $(INC)/setgalmodel.h 157 $(BIN)/setgalmodel_client.$(ARCH): $(SETGALMODEL_CLIENT) 130 158 131 159 SETFWHM = \ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/uniphot/include/setastrom.h
r35103 r37822 25 25 char *SINGLE_CPT; 26 26 27 char *KH_FILE; 28 char *DCR_FILE; 29 30 int KH_RESET; 31 int DCR_RESET; 32 27 33 SkyRegion UserPatch; 28 34 … … 46 52 // int SetSignals PROTO((void)); 47 53 48 int update_dvo_setastrom PROTO(( char *corrfile));49 int update_dvo_setastrom_parallel PROTO((SkyTable *sky , char *corrfile));54 int update_dvo_setastrom PROTO(()); 55 int update_dvo_setastrom_parallel PROTO((SkyTable *sky)); 50 56 51 57 int update_catalog_setastrom PROTO((Catalog *catalog)); 52 58 53 59 // spline correction functions 54 int load_astrom_correction (char *filename);55 int get_astrom_correction (int sub, int chip, double *dX, double *dY, float Minst);56 60 double spline_apply_dbl (double *x, double *y, double *y2, int N, double X); 61 62 int load_kh_correction (char *filename); 63 int get_kh_correction (int sub, int chip, double *dX, double *dY, float Minst); 64 65 int load_dcr_correction (char *filename); 66 int get_dcr_correction (int filter, double *dX, double *dY, float Color); -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/uniphot/src/astrom_correction.c
r35103 r37822 2 2 3 3 // astrometry correction functions: 4 // load the correction set from a file 5 6 // the correction is saved as a set of splines, one per file extension 7 // extensions have names of the form XYnn.Dx.Td 8 9 // where nn = 00 - 77, the chip number 10 // x is X or Y, the correction direction (dir) 11 // d is 0 or 1, pre or post camera correction (sub) 12 13 // these are stored in an N-D array of (Spline *) splineset[sub][dir][chip] 14 15 # define N_SUB 2 16 # define N_DIR 2 17 # define N_CHIP 78 18 // note that we are allocating pointers for XY00 - XY77, but only the octal elements are set (and not the 00,07,70,77 ones) 19 20 Spline ****splineset; 21 22 int load_astrom_correction (char *filename) { 23 24 int Ncol; 25 off_t Nrow; 26 27 char type[16]; 28 char extname[80]; 29 30 Header header; 31 Header theader; 32 FTable ftable; 33 34 /* open file for input */ 35 FILE *f = fopen (filename, "r"); 36 if (f == (FILE *) NULL) { 37 gprint (GP_ERR, "can't open file for read : %s\n", filename); 38 return FALSE; 39 } 40 41 // read the PHU header 42 if (!gfits_load_header (f, &header)) return (FALSE); 43 44 int Nbytes = gfits_data_size (&header); 45 fseeko (f, Nbytes, SEEK_CUR); 46 // XXX gfits_free_header (&header); 47 48 ftable.header = &theader; 49 50 int sub, dir, chip; 51 52 // we have a N-D array of splines: 53 // splineset[sub][dir][chip] 54 55 ALLOCATE (splineset, Spline ***, N_SUB); 56 for (sub = 0; sub < N_SUB; sub++) { 57 ALLOCATE (splineset[sub], Spline **, N_DIR); 58 for (dir = 0; dir < N_DIR; dir++) { 59 ALLOCATE (splineset[sub][dir], Spline *, N_CHIP); 60 for (chip = 0; chip < N_CHIP; chip ++) { 61 splineset[sub][dir][chip] = NULL; 62 } 63 } 64 } 65 66 while (TRUE) { 67 // load data for this header : if not found, assume we hit the end of the file 68 if (!gfits_load_header (f, &theader)) break; 69 70 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) return (FALSE); 71 72 if (!gfits_scan (&theader, "EXTNAME", "%s", 1, extname)) return (FALSE); 73 74 // figure out the chip ID, diretion, and sequence from the EXTNAME 75 76 // EXTNAME is of the form XY%d%d.D%s.T%s where 77 char chipname[3]; 78 chipname[0] = extname[2]; 79 chipname[1] = extname[3]; 80 chipname[2] = 0; 81 int chip = atoi(chipname); 82 myAssert (chip > 0, "error in extname %s not(chip > 0)\n", extname); 83 myAssert (chip < 77, "error in extname %s not(chip < 77)\n", extname); 84 myAssert (chip != 7, "error in extname %s not(chip != 7)\n", extname); 85 myAssert (chip != 70, "error in extname %s not(chip != 70)\n", extname); 86 87 int dir = -1; 88 if (extname[6] == 'X') { 89 dir = 0; 90 } 91 if (extname[6] == 'Y') { 92 dir = 1; 93 } 94 myAssert (dir != -1, "error in extname %s (dir)\n", extname); 95 96 int sub = -1; 97 if (extname[9] == '0') { 98 sub = 0; 99 } 100 if (extname[9] == '1') { 101 sub = 1; 102 } 103 myAssert (sub != -1, "error in extname %s (sub)\n", extname); 104 105 // need to create and assign to flat-field correction 106 double *xk = gfits_get_bintable_column_data (&theader, &ftable, "X_KNOT", type, &Nrow, &Ncol); 107 myAssert (!strcmp(type, "double"), "error reading X_KNOT"); 108 109 // need to create and assign to flat-field correction 110 double *yk = gfits_get_bintable_column_data (&theader, &ftable, "Y_KNOT", type, &Nrow, &Ncol); 111 myAssert (!strcmp(type, "double"), "error reading X_KNOT"); 112 113 // need to create and assign to flat-field correction 114 double *y2 = gfits_get_bintable_column_data (&theader, &ftable, "DY2_DX", type, &Nrow, &Ncol); 115 myAssert (!strcmp(type, "double"), "error reading X_KNOT"); 116 117 ALLOCATE (splineset[sub][dir][chip], Spline, 1); 118 splineset[sub][dir][chip]->xk = xk; 119 splineset[sub][dir][chip]->yk = yk; 120 splineset[sub][dir][chip]->y2 = y2; 121 splineset[sub][dir][chip]->Nknots = Nrow; 122 } 123 return (TRUE); 124 } 125 126 int get_astrom_correction (int sub, int chip, double *dX, double *dY, float Minst) { 127 128 Spline *spline = NULL; 129 130 *dX = 0.0; 131 *dY = 0.0; 132 133 // XXX need to include some limits on Minst? 134 135 spline = splineset[sub][0][chip]; 136 if (spline) { 137 *dX = spline_apply_dbl (spline->xk, spline->yk, spline->y2, spline->Nknots, Minst); 138 } 139 140 spline = splineset[sub][1][chip]; 141 if (spline) { 142 *dY = spline_apply_dbl (spline->xk, spline->yk, spline->y2, spline->Nknots, Minst); 143 } 144 return (TRUE); 145 } 4 // KH correction 5 // DCR correction 146 6 147 7 /* evaluate spline for x, y, y2 at X */ -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/uniphot/src/find_image_sgroups.c
r36481 r37822 18 18 } 19 19 20 coords.crpix1 = coords.crpix2 = 0.0; 21 coords.cdelt1 = coords.cdelt2 = 1.0; /* scale is degrees, radius in degrees */ 22 coords.pc1_1 = coords.pc2_2 = 1.0; 23 coords.pc1_2 = coords.pc2_1 = 0.0; 24 strcpy (coords.ctype, "DEC--TAN"); 20 InitCoords (&coords, "DEC--TAN"); 25 21 26 22 Ngroup = 0; … … 41 37 // NOCAL above is used to mark images which do not match the photcode (including the DIS) 42 38 // if (!strcmp(&image[i].coords.ctype[4], "-DIS")) continue; 43 44 // this adds 1.3 sec for 3M images45 if (!FindMosaicForImage (image, Nimage, i)) {46 fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);47 continue;48 }49 39 50 40 /* define image center - note the DIS images (mosaic phu) are special */ … … 83 73 // if (!strcmp(&image[j].coords.ctype[4], "-DIS")) continue; 84 74 85 // this adds 1.3 sec for 3M images86 if (!FindMosaicForImage (image, Nimage, j)) {87 fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", j);88 continue;89 }90 91 75 /* project image center to local coords, check radius */ 92 76 if (!strcmp(&image[j].coords.ctype[4], "-DIS")) { -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/uniphot/src/initialize_setastrom.c
r35103 r37822 2 2 3 3 void usage_setastrom () { 4 fprintf (stderr, "USAGE: setastrom (corrections)[options]\n");4 fprintf (stderr, "USAGE: setastrom [options]\n"); 5 5 fprintf (stderr, " options:\n"); 6 fprintf (stderr, " -DCR (file) : supply DCR correction splines\n"); 7 fprintf (stderr, " -KH (file) : supply Koppenhoefer correction splines\n"); 6 8 fprintf (stderr, " -v : verbose mode\n"); 7 9 fprintf (stderr, " -region Rmin Rmax Dmin Dmax\n"); … … 49 51 int N; 50 52 53 KH_FILE = NULL; 54 if ((N = get_argument (argc, argv, "-KH"))) { 55 remove_argument (N, &argc, argv); 56 char *tmpfile = strcreate (argv[N]); 57 KH_FILE = abspath (tmpfile, DVO_MAX_PATH); 58 remove_argument (N, &argc, argv); 59 } 60 KH_RESET = FALSE; 61 if ((N = get_argument (argc, argv, "-KH-reset"))) { 62 remove_argument (N, &argc, argv); 63 KH_RESET = TRUE; 64 } 65 66 DCR_FILE = NULL; 67 if ((N = get_argument (argc, argv, "-DCR"))) { 68 remove_argument (N, &argc, argv); 69 char *tmpfile = strcreate (argv[N]); 70 DCR_FILE = abspath (tmpfile, DVO_MAX_PATH); 71 remove_argument (N, &argc, argv); 72 } 73 DCR_RESET = FALSE; 74 if ((N = get_argument (argc, argv, "-DCR-reset"))) { 75 remove_argument (N, &argc, argv); 76 DCR_RESET = TRUE; 77 } 78 51 79 SINGLE_CPT = NULL; 52 80 if ((N = get_argument (argc, argv, "-cpt"))) { … … 118 146 } 119 147 120 if (argc != 2) usage_setastrom(); 148 if (!KH_FILE && !DCR_FILE) { 149 fprintf (stderr, "at least one of -KH and -DCR must be supplied\n"); 150 exit (1); 151 } 152 153 if (argc != 1) usage_setastrom(); 121 154 122 155 return (TRUE); … … 124 157 125 158 void usage_setastrom_client () { 126 fprintf (stderr, "USAGE: setastrom_client (correction)-hostID (hostID) -catdir (catdir) -hostdir (hostdir) [options]\n");159 fprintf (stderr, "USAGE: setastrom_client -hostID (hostID) -catdir (catdir) -hostdir (hostdir) [options]\n"); 127 160 fprintf (stderr, " options:\n"); 161 fprintf (stderr, " -DCR (file) : supply DCR correction splines\n"); 162 fprintf (stderr, " -KH (file) : supply Koppenhoefer correction splines\n"); 128 163 fprintf (stderr, " -region Rmin Rmax Dmin Dmax\n"); 129 164 fprintf (stderr, " -update-catformat (format) : change database schema on output\n"); … … 163 198 164 199 int N; 200 201 KH_FILE = NULL; 202 if ((N = get_argument (argc, argv, "-KH"))) { 203 remove_argument (N, &argc, argv); 204 KH_FILE = strcreate (argv[N]); 205 remove_argument (N, &argc, argv); 206 } 207 KH_RESET = FALSE; 208 if ((N = get_argument (argc, argv, "-KH-reset"))) { 209 remove_argument (N, &argc, argv); 210 KH_RESET = TRUE; 211 } 212 213 DCR_FILE = NULL; 214 if ((N = get_argument (argc, argv, "-DCR"))) { 215 remove_argument (N, &argc, argv); 216 DCR_FILE = strcreate (argv[N]); 217 remove_argument (N, &argc, argv); 218 } 219 DCR_RESET = FALSE; 220 if ((N = get_argument (argc, argv, "-DCR-reset"))) { 221 remove_argument (N, &argc, argv); 222 DCR_RESET = TRUE; 223 } 165 224 166 225 /* specify portion of the sky : allow default of all sky? */ … … 223 282 if (!CATDIR) usage_setastrom_client(); 224 283 225 if (argc != 2) usage_setastrom_client(); 284 if (!KH_FILE && !DCR_FILE) { 285 fprintf (stderr, "at least one of -KH and -DCR must be supplied\n"); 286 exit (1); 287 } 288 289 if (argc != 1) usage_setastrom_client(); 226 290 return (TRUE); 227 291 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/uniphot/src/load_zpt_table.c
r33654 r37822 173 173 mjdstart = tstart_uc[i]; 174 174 mjdstop = tstop_uc[i]; 175 } else {175 } else { 176 176 char name[9]; 177 snprintf (name, 9, "TS0_%04d", i); 177 // snprintf (name, 9, "TS0_%04d", i); 178 snprintf (name, 9, "S0_MJD%d", i); 178 179 if (!gfits_scan (&header, name, "%lf", 1, &mjdstart)) { 179 180 fprintf (stderr, "cannot find %s in header of %s\n", name, filename); … … 182 183 } 183 184 184 snprintf (name, 9, "TS1_%04d", i); 185 // snprintf (name, 9, "TS1_%04d", i); 186 snprintf (name, 9, "S1_MJD%d", i); 185 187 if (!gfits_scan (&header, name, "%lf", 1, &mjdstop)) { 186 188 fprintf (stderr, "cannot find %s in header of %s\n", name, filename); … … 189 191 } 190 192 } 191 flatcorrTable->tstart[i] = ohana_mjd_to_sec(mjdstart);192 flatcorrTable->tstop[i] = ohana_mjd_to_sec(mjdstop);193 flatcorrTable->tstart[i] = (mjdstart > 0) ? ohana_mjd_to_sec(mjdstart) : ohana_mjd_to_sec(50000.0); // 1995/10/10 (ancient history) 194 flatcorrTable->tstop[i] = (mjdstop > 0) ? ohana_mjd_to_sec(mjdstop) : ohana_mjd_to_sec(60000.0); // 2023/02/25 (infinite future) 193 195 } 194 196 … … 247 249 } else { 248 250 if (!gfits_scan (&header, "FILTER", "%s", 1, filter)) { 249 fprintf (stderr, "cannot find FILTER in header of %s\n", filename); 250 fclose (f); 251 return NULL; 251 fprintf (stderr, "cannot find FILTER in header of %s, using %s\n", filename, filters_uc[nfilter]); 252 strcpy (filter, filters_uc[nfilter]); 253 // fclose (f); 254 // return NULL; 252 255 } 253 256 } … … 278 281 REALLOCATE (offset64, double, matrix.Naxis[0]); 279 282 matrix.buffer = (char *) offset64; 283 } 284 if (matrix.Naxes == 1) { 285 int Ntotal = NSEASON*NCHIP_X*NCHIP_Y*NCELL_X*NCELL_Y; 286 if (matrix.Naxis[0] != Ntotal) { 287 int Nextra = Ntotal - matrix.Naxis[0]; 288 assert (Nextra >= 0); 289 fprintf (stderr, "warning: images are not fully populated, extending by %d\n", Nextra); 290 291 REALLOCATE (offset64, double, Ntotal); 292 int npix; 293 for (npix = matrix.Naxis[0]; npix < Ntotal; npix ++) offset64[npix] = 0.0; 294 295 matrix.Naxis[0] = Ntotal; 296 matrix.buffer = (char *) offset64; 297 } 280 298 } 281 299 -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/uniphot/src/match_zpts_to_images.c
r35764 r37822 97 97 } 98 98 99 // if secz is crazy, do not trust ubercal; skip and move along 100 if (image[Ni].secz < 0.1) { 101 i++; 102 continue; 103 } 104 99 105 // we have a match: set zpt and record the match 100 106 // is the zero point supplied nominally corrected or not? -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/uniphot/src/update_catalog_setastrom.c
r37043 r37822 1 1 # include "setastrom.h" 2 3 // this code does both DCR and KH corrections, if both are specified. 2 4 3 5 // XXX this function is dependent in two ways on the specific numerical values of the photcodes … … 7 9 int update_catalog_setastrom (Catalog *catalog) { 8 10 9 off_t i , found;11 off_t i; 10 12 11 13 time_t timeRef = ohana_date_to_sec("2011/05/11,00:00:00"); 12 14 13 found = 0; 15 int Nsecfilt = GetPhotcodeNsecfilt (); 16 PhotCode *code_g = GetPhotcodebyName ("g"); 17 PhotCode *code_i = GetPhotcodebyName ("i"); 18 PhotCode *code_z = GetPhotcodebyName ("z"); 19 PhotCode *code_y = GetPhotcodebyName ("y"); 20 21 int Nsec_g = GetPhotcodeNsec(code_g->code); 22 int Nsec_i = GetPhotcodeNsec(code_i->code); 23 int Nsec_z = GetPhotcodeNsec(code_z->code); 24 int Nsec_y = GetPhotcodeNsec(code_y->code); 25 26 off_t found = 0; 14 27 15 28 for (i = 0; i < catalog[0].Nmeasure; i++) { … … 17 30 Measure *measure = &catalog[0].measure[i]; 18 31 19 // XXX only do GPC1 data for now32 // only do GPC1 data for now (true for both DCR and KH) 20 33 if (measure[0].photcode < 10000) continue; 21 34 if (measure[0].photcode > 10600) continue; 22 35 23 // XXX hardwire the list of chips to correct 36 int averef = measure->averef; 37 Average *average = &catalog[0].average[averef]; 38 SecFilt *secfilt = &catalog[0].secfilt[averef*Nsecfilt]; 39 40 int chipID = measure[0].photcode % 100; 41 42 // XXX hardwire the list of chips to KH correct 24 43 // some notes: 25 // XY24 surp isingly does not need correction44 // XY24 surprisingly does not need correction 26 45 // XY27 has poor astrometry with a weird correction for all mags 27 // XY36 surp isingly does not need correction46 // XY36 surprisingly does not need correction 28 47 // XY67 has poor astrometry with a weird correction for all mags 29 48 30 int chipID = measure[0].photcode % 100;49 int doKH = FALSE; 31 50 switch (chipID) { 32 51 case 4: … … 57 76 case 72: 58 77 case 73: 78 doKH = TRUE; 59 79 break; 60 80 default: 61 measure[0].Xfix = measure[0].Xccd; 62 measure[0].Yfix = measure[0].Yccd; 63 continue; 64 } 65 66 double Xccd = measure[0].Xccd; 67 double Yccd = measure[0].Yccd; 81 break; 82 } 83 68 84 double pltScale = fabs(measure[0].pltscale); 69 70 // this is not needed, is it? 71 // double posAngle = FromShortDegrees(measure[0].posangle); 72 73 // I need to know which chip we have. use photcode assuming range 74 int chip = measure[0].photcode % 100; 75 76 // correction may be Minst or Minst + 5.0*log(fwhm 77 float fwhm_maj = FromShortPixels(measure[0].FWx); 78 float Minst = PhotInst (measure, MAG_CLASS_PSF); 79 float MinstSB = Minst + 5.0*log10(fwhm_maj); 80 81 // I should validate that the spline I'm using is SB corrected not Minst... 82 83 // XXX this is very ad hoc. the splines are measured based on an extraction from dvo 84 // the dvo values of fwhm_maj are sigmas (NOT FWHM!) in pixels. 85 double posAngle = FromShortDegrees(measure[0].posangle); 86 87 /**** KH section ****/ 88 89 double dX_KH = 0.0; 90 double dY_KH = 0.0; 91 if (KH_FILE && doKH && (measure[0].t < timeRef)) { 92 93 // correction may be Minst or Minst + 5.0*log(fwhm 94 float fwhm_maj = FromShortPixels(measure[0].FWx); 95 float Minst = PhotInst (measure, MAG_CLASS_PSF); 96 // float MinstSB = Minst + 5.0*log10(fwhm_maj); 97 98 // NOTE: the spline correction was measured on the nightly-science database using measurements 99 // from the period in which fwhm_maj & fwhm_min were a factor of sqrt(2) too small. I am making 100 // this correction here (but ideally I would re-measure the KH trend from PV2 data and re-generate 101 // the splines 102 float MinstSB = Minst + 5.0*log10(M_SQRT2*fwhm_maj); 103 104 // I should validate that the spline I'm using is SB corrected not Minst.. 105 // NOTE: it is SB, not raw Minst 106 107 // XXX this is very ad hoc. the splines are measured based on an extraction from dvo 108 // the dvo values of fwhm_maj are sigmas (NOT FWHM!) in pixels. 85 109 86 // saturate fwhm_maj in the range 1.0 < fwhm_maj < 5.0 87 // (images with really odd psf probably have poor astrometry anyway...) 88 fwhm_maj = MIN(fwhm_maj,5.0); 89 fwhm_maj = MAX(fwhm_maj,1.0); 90 91 double dX; 92 double dY; 93 94 // correction is in arcseconds 95 if (measure[0].t < timeRef) { 96 get_astrom_correction (0, chip, &dX, &dY, MinstSB); 97 } else { 98 // XXX do not correct new data 99 // get_astrom_correction (1, chip, &dX, &dY, MinstSB); 100 dX = 0.0; 101 dY = 0.0; 102 } 110 // saturate fwhm_maj in the range 1.0 < fwhm_maj < 5.0 111 // (images with really odd psf probably have poor astrometry anyway...) 112 fwhm_maj = MIN(fwhm_maj,5.0); 113 fwhm_maj = MAX(fwhm_maj,1.0); 114 115 // correction is in arcseconds 116 get_kh_correction (0, chipID, &dX_KH, &dY_KH, MinstSB); 117 } 118 119 /**** DCR section ****/ 120 121 double dX_DCR = 0.0; 122 double dY_DCR = 0.0; 123 if (DCR_FILE) { 124 125 // check if the color*airmass term is not-nan (Skip otherwise) 126 127 // XXX hard-wire gpc1 photcodes for now: 128 // I should use photcode ops: PhotCode *code = PhotCodeByCode(measure->photcode) 129 // int equiv = code->equiv 130 // Nsec = GetNsec(equiv) 131 132 float dColor = 0.0; 133 int filtCode = (int)(measure->photcode / 100); // eg, 101 = r 134 switch (filtCode) { 135 case 100: 136 case 101: 137 case 102: { 138 float gmag = secfilt[Nsec_g].M; 139 float imag = secfilt[Nsec_i].M; 140 dColor = average->refColorBlue - (gmag - imag); 141 break; 142 } 143 case 103: 144 case 104: { 145 float zmag = secfilt[Nsec_z].M; 146 float ymag = secfilt[Nsec_y].M; 147 dColor = average->refColorRed - (zmag - ymag); 148 break; 149 } 150 } 151 int filtSeq = filtCode % 100; 152 if (!isfinite(dColor)) goto skip_DCR; 153 154 // I need to get the parallactic angle, but I only have alt & az, s:o 155 156 // airmass = 1.0 / cos(90 - alt) 157 // cos(90 - alt) = cos(zd) = sin(alt) = 1.0 / airmass 158 // airmass = 1.0 / sin(alt) 159 160 // airmass = 1.0 / cos(zd) 161 // cos(zd) = 1.0 / airmass == sn_alt 162 // sin(zd) = sqrt(1.0 - cos(zd)^2) == cs_alt 163 // tan(zd) = sin(zd) / cos(zd) = cs_alt / sn_alt 164 165 double sn_alt = 1.0 / measure->airmass; 166 double cs_alt = sqrt(1.0 - SQ(sn_alt)); 167 double tan_zd = cs_alt / sn_alt; 168 169 double cs_az = cos(RAD_DEG*measure->az); 170 double sn_az = sin(RAD_DEG*measure->az); 171 172 # define LATITUDE (20.7070999146*RAD_DEG) 173 double sn_lat = sin(LATITUDE); 174 double cs_lat = cos(LATITUDE); 175 176 // double sind = sn_alt * sn_lat + cs_alt * cs_az * cs_lat; 177 // *dec = DEG_RAD * asin (sind); 178 179 // WARNING: these are NOT sin(ha),cos(ha) but are scaled 180 // double ha = DEG_RAD * atan2 (sinh, cosh); 181 double sinh = -cs_alt * sn_az; 182 double cosh = sn_alt * cs_lat - cs_alt * cs_az * sn_lat; 183 double r_ha = hypot(sinh, cosh); 184 double sn_ha = sinh / r_ha; 185 double cs_ha = cosh / r_ha; 186 187 sinh = -cs_az * sn_alt * sn_ha * sn_lat + sn_az * sn_alt * cs_ha - sn_ha * cs_alt * cs_lat; 188 cosh = -sn_az * sn_ha * sn_lat - cs_az * cs_ha; 189 double r_rot = hypot(sinh, cosh); 190 191 double sn_rot = -sinh / r_rot; 192 double cs_rot = +cosh / r_rot; 193 194 double dPx = 0.0; 195 double dPy = 0.0; 196 197 float colorOffset = dColor * tan_zd; 198 get_dcr_correction (filtSeq, &dPx, &dPy, colorOffset); 199 200 // if we had x-terms, we would have: 201 // double dPx = dRx *cs_rot + dD_s*sn_rot; 202 // double dPy = dD_s*cs_rot - dRx *sn_rot; 203 // double dR = dPx*cs_rot - dPy*sn_rot; 204 // double dD = dPx*sn_rot + dPy*cs_rot; 205 206 // since dPx = 0.0, instead we have: dPx, dPy as measured in dvo.dcr.sh 207 double dR = -dPy*sn_rot; 208 double dD = +dPy*cs_rot; 209 210 // dR = (measure->R - average->R) * 3600 * dcos(dec) [ie, in the projected plane] 211 // dD = (measure->D - average->D) * 3600 212 // average->D = measure->D - dD/3600 213 214 // now we need to rotate dR,dD into the chip frame and correction Xccd,Yccd 215 216 // are the plate-scale and posangle correctly set in the db? 217 218 // XXX the koppenhoefer code implies pos if angle from y -> D, (ie negative of the 219 // below). if so, apply sin(pos) -> -sin(pos) 220 221 // if parity = sky: 222 // double dR = dX*cos(pos) + dY*sin(pos); 223 // double dD = -dX*sin(pos) + dY*cos(pos); 224 225 // XXX signs set here to reflect pos = -pos 226 float posAngRad = posAngle * RAD_DEG; 227 dX_DCR = dR*cos(posAngRad) + dD*sin(posAngRad); 228 dY_DCR = -dR*sin(posAngRad) + dD*cos(posAngRad); 229 } 230 231 skip_DCR: 103 232 104 233 // do not modify the original Xccd,Yccd values 105 measure[0].Xfix = Xccd + dX / pltScale; 106 measure[0].Yfix = Yccd + dY / pltScale; 107 234 if (KH_FILE) { 235 measure[0].XoffKH = dX_KH / pltScale; 236 measure[0].YoffKH = dY_KH / pltScale; 237 } 238 if (KH_RESET) { 239 measure[0].XoffKH = 0.0; 240 measure[0].YoffKH = 0.0; 241 } 242 if (DCR_FILE) { 243 measure[0].XoffDCR = -dX_DCR / pltScale; 244 measure[0].YoffDCR = -dY_DCR / pltScale; 245 } 246 if (DCR_RESET) { 247 measure[0].XoffDCR = -dX_DCR / pltScale; 248 measure[0].YoffDCR = -dY_DCR / pltScale; 249 } 250 251 measure[0].Xfix = measure[0].Xccd; 252 measure[0].Yfix = measure[0].Yccd; 253 if (isfinite(measure[0].XoffKH) && isfinite(measure[0].YoffKH)) { 254 measure[0].Xfix += measure[0].XoffKH; 255 measure[0].Yfix += measure[0].YoffKH; 256 } 257 if (isfinite(measure[0].XoffDCR) && isfinite(measure[0].YoffDCR)) { 258 measure[0].Xfix += measure[0].XoffDCR; 259 measure[0].Yfix += measure[0].YoffDCR; 260 } 108 261 found ++; 109 262 } -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/uniphot/src/update_dvo_setastrom.c
r35103 r37822 1 1 # include "setastrom.h" 2 2 3 int update_dvo_setastrom ( char *corrfile) {3 int update_dvo_setastrom () { 4 4 5 5 SkyTable *sky = NULL; … … 13 13 14 14 if (PARALLEL && !HOST_ID) { 15 int status = update_dvo_setastrom_parallel (sky , corrfile);15 int status = update_dvo_setastrom_parallel (sky); 16 16 return status; 17 17 } 18 18 19 load_astrom_correction (corrfile); 19 if (KH_FILE) load_kh_correction (KH_FILE); 20 if (DCR_FILE) load_dcr_correction (DCR_FILE); 20 21 21 22 // determine the populated SkyRegions overlapping the requested area (default depth) … … 78 79 # define DEBUG 1 79 80 80 int update_dvo_setastrom_parallel (SkyTable *sky , char *corrfile) {81 int update_dvo_setastrom_parallel (SkyTable *sky) { 81 82 82 83 // now launch the setastrom_client jobs to the parallel hosts 83 84 char *abscorrfile = abspath (corrfile, DVO_MAX_PATH);85 84 86 85 // load the list of hosts … … 96 95 97 96 char command[1024]; 98 snprintf (command, 1024, "setastrom_client %s-hostID %d -catdir %s -hostdir %s -region %f %f %f %f",99 abscorrfile,table->hosts[i].hostID, CATDIR, table->hosts[i].pathname,97 snprintf (command, 1024, "setastrom_client -hostID %d -catdir %s -hostdir %s -region %f %f %f %f", 98 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, 100 99 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 101 102 fprintf (stderr, "command: %s\n", command);103 100 104 101 char tmpline[1024]; 105 102 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 106 103 if (UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); } 104 if (KH_FILE) { snprintf (tmpline, 1024, "%s -KH %s", command, KH_FILE); strcpy (command, tmpline); } 105 if (DCR_FILE) { snprintf (tmpline, 1024, "%s -DCR %s", command, DCR_FILE); strcpy (command, tmpline); } 107 106 if (UPDATE_CATFORMAT) { snprintf (tmpline, 1024, "%s -update-catformat %s", command, UPDATE_CATFORMAT); strcpy (command, tmpline); } 107 108 if (KH_RESET) { snprintf (tmpline, 1024, "%s -KH-reset", command); strcpy (command, tmpline); } 109 if (DCR_RESET) { snprintf (tmpline, 1024, "%s -DCR-reset", command); strcpy (command, tmpline); } 110 111 fprintf (stderr, "command: %s\n", command); 108 112 109 113 if (PARALLEL_MANUAL) continue; … … 126 130 } 127 131 } 128 free (abscorrfile);129 132 130 133 // wait for the remote jobs to be completed -
branches/eam_branches/ipp-pv3-20140717-merge/Ohana/src/uniphot/src/update_dvo_uniphot.c
r36481 r37822 57 57 glob (line, 0, NULL, &pglob); 58 58 59 coords.crpix1 = coords.crpix2 = 0.0; 60 coords.cdelt1 = coords.cdelt2 = 1.0; /* scale is degrees, radius in degrees */ 61 coords.pc1_1 = coords.pc2_2 = 1.0; 62 coords.pc1_2 = coords.pc2_1 = 0.0; 63 strcpy (coords.ctype, "DEC--TAN"); 59 InitCoords (&coords, "DEC--TAN"); 64 60 65 61 for (i = 0; i < pglob.gl_pathc; i++) {
Note:
See TracChangeset
for help on using the changeset viewer.
