Changeset 38986
- Timestamp:
- Oct 27, 2015, 4:49:06 PM (11 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 21 deleted
- 279 edited
- 23 copied
-
. (modified) (1 prop)
-
Makefile.Common (modified) (1 diff)
-
src/addstar/Makefile (modified) (10 diffs)
-
src/addstar/include/2mass.h (modified) (2 diffs)
-
src/addstar/include/WISE.h (modified) (1 diff)
-
src/addstar/include/addstar.h (modified) (4 diffs)
-
src/addstar/include/loadstarpar.h (modified) (3 diffs)
-
src/addstar/include/supercos.h (modified) (1 diff)
-
src/addstar/src/LoadFilenames.c (modified) (1 prop)
-
src/addstar/src/SkyListForStars.c (modified) (5 diffs)
-
src/addstar/src/UpdateDatabase_Image.c (modified) (1 diff)
-
src/addstar/src/UpdateDatabase_Refcat.c (modified) (1 diff)
-
src/addstar/src/UpdateDatabase_Reflist.c (modified) (1 diff)
-
src/addstar/src/addstar.c (modified) (6 diffs)
-
src/addstar/src/addstar_client.c (modified) (1 diff)
-
src/addstar/src/addstarc.c (modified) (1 diff)
-
src/addstar/src/addstard.c (modified) (1 diff)
-
src/addstar/src/addstart.c (modified) (1 diff)
-
src/addstar/src/args_loadstarpar.c (modified) (8 diffs)
-
src/addstar/src/find_matches.c (modified) (13 diffs)
-
src/addstar/src/find_matches_closest.c (modified) (8 diffs)
-
src/addstar/src/find_matches_closest_refstars.c (modified) (11 diffs)
-
src/addstar/src/find_matches_refstars.c (modified) (9 diffs)
-
src/addstar/src/find_matches_starpar.c (modified) (1 diff)
-
src/addstar/src/get2mass_full.c (modified) (10 diffs)
-
src/addstar/src/get2mass_ops.c (modified) (2 diffs)
-
src/addstar/src/getgsc.c (modified) (3 diffs)
-
src/addstar/src/getusno.c (modified) (5 diffs)
-
src/addstar/src/getusnob.c (modified) (7 diffs)
-
src/addstar/src/greference.c (modified) (4 diffs)
-
src/addstar/src/grefstars.c (modified) (2 diffs)
-
src/addstar/src/load2mass.c (modified) (1 diff)
-
src/addstar/src/load2mass_as_rawdata.c (modified) (5 diffs)
-
src/addstar/src/loadICRF.c (modified) (1 diff)
-
src/addstar/src/loadICRF_catalog.c (modified) (1 diff)
-
src/addstar/src/loadICRF_client.c (modified) (1 diff)
-
src/addstar/src/loadgalphot.c (modified) (1 diff)
-
src/addstar/src/loadgalphot_catalog.c (modified) (1 diff)
-
src/addstar/src/loadstarpar.c (modified) (2 diffs)
-
src/addstar/src/loadstarpar_catalog.c (modified) (1 diff)
-
src/addstar/src/loadstarpar_client.c (modified) (2 diffs)
-
src/addstar/src/loadstarpar_extras.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/addstar/src/loadstarpar_extras.c )
-
src/addstar/src/loadstarpar_io.c (modified) (3 diffs)
-
src/addstar/src/loadstarpar_readstars.c (modified) (1 diff)
-
src/addstar/src/loadstarpar_save_remote.c (modified) (2 diffs)
-
src/addstar/src/loadsupercos.c (modified) (3 diffs)
-
src/addstar/src/loadsupercos_ops.c (modified) (1 diff)
-
src/addstar/src/loadsupercos_rawdata.c (modified) (9 diffs)
-
src/addstar/src/loadtycho.c (modified) (1 diff)
-
src/addstar/src/loadtycho_rawdata.c (modified) (4 diffs)
-
src/addstar/src/loadwise.c (modified) (1 diff)
-
src/addstar/src/loadwise_prelim_rawdata.c (modified) (1 diff)
-
src/addstar/src/loadwise_rawdata.c (modified) (6 diffs)
-
src/addstar/src/loadwise_star_full.c (modified) (29 diffs)
-
src/addstar/src/replace_match.c (modified) (2 diffs)
-
src/addstar/src/resort_catalog.c (modified) (2 diffs)
-
src/addstar/src/resort_threaded.c (modified) (1 diff)
-
src/addstar/src/resort_unthreaded.c (modified) (1 diff)
-
src/addstar/src/sedstar.c (modified) (2 diffs)
-
src/addstar/test (modified) (1 prop)
-
src/delstar/src/Shutdown.c (modified) (1 diff)
-
src/delstar/src/delete_duplicate_images.c (modified) (1 diff)
-
src/delstar/src/delete_duplicate_measures.c (modified) (1 diff)
-
src/delstar/src/delete_fix_LAP.c (modified) (1 diff)
-
src/delstar/src/delete_fix_LAP_edges_delete.c (modified) (1 diff)
-
src/delstar/src/delete_imagefile.c (modified) (1 diff)
-
src/delstar/src/delete_imagename.c (modified) (1 diff)
-
src/delstar/src/delete_photcodes.c (modified) (1 diff)
-
src/delstar/src/delete_photcodes_single.c (modified) (1 diff)
-
src/delstar/src/delete_times.c (modified) (1 diff)
-
src/dvolens/include/dvolens.h (modified) (1 diff)
-
src/dvolens/src/dvolens.c (modified) (1 diff)
-
src/dvolens/src/update_objects.c (modified) (1 diff)
-
src/dvomerge/Makefile (modified) (8 diffs)
-
src/dvomerge/include/dvomerge.h (modified) (3 diffs)
-
src/dvomerge/include/dvoutils.h (modified) (2 diffs)
-
src/dvomerge/include/dvoverify.h (modified) (2 diffs)
-
src/dvomerge/src/LoadCatalog.c (modified) (1 diff)
-
src/dvomerge/src/ReadDeleteListExternID.c (modified) (2 diffs)
-
src/dvomerge/src/args.c (modified) (2 diffs)
-
src/dvomerge/src/build_links.c (modified) (1 diff)
-
src/dvomerge/src/dvoconvert.c (modified) (1 diff)
-
src/dvomerge/src/dvomergeContinue.c (modified) (1 diff)
-
src/dvomerge/src/dvomergeContinue_threaded.c (modified) (2 diffs)
-
src/dvomerge/src/dvomergeCreate.c (modified) (1 diff)
-
src/dvomerge/src/dvomergeFromList.c (modified) (2 diffs)
-
src/dvomerge/src/dvomergeUpdate_catalogs.c (modified) (4 diffs)
-
src/dvomerge/src/dvomergeUpdate_threaded.c (modified) (2 diffs)
-
src/dvomerge/src/dvomerge_client.c (modified) (2 diffs)
-
src/dvomerge/src/dvorepair.c (modified) (1 diff)
-
src/dvomerge/src/dvorepairCPT.c (modified) (1 diff)
-
src/dvomerge/src/dvorepairDeleteImagesByExternID.c (modified) (9 diffs)
-
src/dvomerge/src/dvorepairFixImages.c (modified) (4 diffs)
-
src/dvomerge/src/dvorepairFixWarpIDs.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/dvomerge/src/dvorepairFixWarpIDs.c )
-
src/dvomerge/src/dvorepairImageVsMeasure.c (modified) (1 diff)
-
src/dvomerge/src/dvorepair_by_objID.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/dvomerge/src/dvorepair_by_objID.c )
-
src/dvomerge/src/dvosecfilt_catalogs.c (modified) (1 diff)
-
src/dvomerge/src/dvoutils.c (modified) (1 diff)
-
src/dvomerge/src/dvoutils_load_image_index.c (modified) (3 diffs)
-
src/dvomerge/src/dvoutils_uniq_images.c (modified) (6 diffs)
-
src/dvomerge/src/dvoverify.c (modified) (2 diffs)
-
src/dvomerge/src/dvoverify_args.c (modified) (3 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) (5 diffs)
-
src/dvomerge/src/help.c (modified) (1 diff)
-
src/dvomerge/src/merge_catalogs_old.c (modified) (2 diffs)
-
src/dvomerge/src/repair_catalog_by_objID.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/dvomerge/src/repair_catalog_by_objID.c )
-
src/dvomerge/src/replace_match.c (modified) (4 diffs)
-
src/dvomerge/src/replace_tycho.c (modified) (2 diffs)
-
src/dvopsps/include/dvopsps.h (modified) (7 diffs)
-
src/dvopsps/src/insert_detections_dvopsps_catalog.c (modified) (2 diffs)
-
src/dvosplit/src/split_averages.c (modified) (1 diff)
-
src/dvosplit/src/split_measures.c (modified) (1 diff)
-
src/fakeastro/include/fakeastro.h (modified) (1 diff)
-
src/fakeastro/src/args.c (modified) (1 diff)
-
src/fakeastro/src/fakestar_catalog.c (modified) (1 diff)
-
src/fakeastro/src/fit_fake_stars.c (modified) (1 diff)
-
src/fakeastro/src/make_2mass_measures.c (modified) (3 diffs)
-
src/fakeastro/src/save_fake_stars.c (modified) (1 diff)
-
src/getstar/src/MatchImages.c (modified) (1 diff, 1 prop)
-
src/getstar/src/write_catalog.c (modified) (1 diff)
-
src/kapa2/include/prototypes.h (modified) (1 diff)
-
src/kapa2/include/structures.h (modified) (1 diff)
-
src/kapa2/src/DrawFrame.c (modified) (11 diffs)
-
src/kapa2/src/Graphs.c (modified) (2 diffs)
-
src/kapa2/src/LoadFrame.c (modified) (2 diffs)
-
src/kapa2/src/PSFrame.c (modified) (1 diff)
-
src/kapa2/src/SetGraphData.c (modified) (1 diff)
-
src/kapa2/src/bDrawFrame.c (modified) (1 diff)
-
src/libautocode/Makefile.Targets (modified) (2 diffs)
-
src/libautocode/def/average-ps1-v5.d (modified) (5 diffs)
-
src/libautocode/def/average.d (modified) (1 diff)
-
src/libautocode/def/galphot-ps1-v5-r0.d (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/libautocode/def/galphot-ps1-v5-r0.d )
-
src/libautocode/def/galphot-ps1-v5-r1.d (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/libautocode/def/galphot-ps1-v5-r1.d )
-
src/libautocode/def/measure-ps1-v5.d (modified) (1 diff)
-
src/libautocode/def/measure.d (modified) (1 diff)
-
src/libautocode/def/secfilt-ps1-v5.d (modified) (1 diff)
-
src/libdvo/Makefile (modified) (3 diffs)
-
src/libdvo/include/dvo.h (modified) (6 diffs)
-
src/libdvo/include/dvodb.h (modified) (1 diff)
-
src/libdvo/include/get_graphdata.h (modified) (1 diff)
-
src/libdvo/include/libdvo_astro.h (modified) (3 diffs)
-
src/libdvo/include/ps1_v5_defs.h (modified) (1 diff)
-
src/libdvo/src/AstromOffsetMapIO.c (modified) (7 diffs)
-
src/libdvo/src/AstromOffsetMapOps.c (modified) (19 diffs)
-
src/libdvo/src/AstromOffsetMapUtils.c (modified) (8 diffs)
-
src/libdvo/src/LoadImages.c (modified) (1 diff)
-
src/libdvo/src/dbExtractImages.c (modified) (1 diff)
-
src/libdvo/src/dbExtractMeasures.c (modified) (1 diff)
-
src/libdvo/src/dbFields.c (modified) (5 diffs)
-
src/libdvo/src/dvo_catalog.c (modified) (14 diffs)
-
src/libdvo/src/dvo_catalog_split.c (modified) (24 diffs)
-
src/libdvo/src/dvo_convert.c (modified) (32 diffs)
-
src/libdvo/src/dvo_convert_PS1_V5.c (modified) (5 diffs)
-
src/libdvo/src/dvo_photcode_ops.c (modified) (5 diffs)
-
src/libdvo/test (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/libdvo/test )
-
src/libfits/Makefile (modified) (1 diff)
-
src/libfits/extern/gzip.c (modified) (1 diff)
-
src/libfits/header/F_H_field.c (modified) (1 diff)
-
src/libfits/include/gfitsio.h (modified) (1 diff)
-
src/libfits/matrix/F_compress_data.c (modified) (1 diff)
-
src/libfits/table/F_compress_T.c (modified) (4 diffs)
-
src/libfits/table/F_read_T.c (modified) (2 diffs)
-
src/libfits/test/tcomptiming.c (modified) (1 diff)
-
src/libkapa/Makefile (modified) (2 diffs)
-
src/libkapa/include/alphabet.h (modified) (2 diffs)
-
src/libkapa/include/kapa.h (modified) (3 diffs)
-
src/libkapa/rotfont (modified) (1 prop)
-
src/libkapa/rotfont/Makefile (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/libkapa/rotfont/Makefile )
-
src/libkapa/rotfont/courier12.h (deleted)
-
src/libkapa/rotfont/courier14.h (deleted)
-
src/libkapa/rotfont/courier18.h (deleted)
-
src/libkapa/rotfont/courier24.h (deleted)
-
src/libkapa/rotfont/courier8.h (deleted)
-
src/libkapa/rotfont/fixfont.c (modified) (7 diffs)
-
src/libkapa/rotfont/fontdimen.sh (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/libkapa/rotfont/fontdimen.sh )
-
src/libkapa/rotfont/fontsize.in.ps (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/libkapa/rotfont/fontsize.in.ps )
-
src/libkapa/rotfont/fontsize.sh (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/libkapa/rotfont/fontsize.sh )
-
src/libkapa/rotfont/helvetica12.h (deleted)
-
src/libkapa/rotfont/helvetica14.h (deleted)
-
src/libkapa/rotfont/helvetica18.h (deleted)
-
src/libkapa/rotfont/helvetica24.h (deleted)
-
src/libkapa/rotfont/helvetica8.h (deleted)
-
src/libkapa/rotfont/symbol12.h (deleted)
-
src/libkapa/rotfont/symbol14.h (deleted)
-
src/libkapa/rotfont/symbol18.h (deleted)
-
src/libkapa/rotfont/symbol24.h (deleted)
-
src/libkapa/rotfont/symbol8.h (deleted)
-
src/libkapa/rotfont/times12.h (deleted)
-
src/libkapa/rotfont/times14.h (deleted)
-
src/libkapa/rotfont/times18.h (deleted)
-
src/libkapa/rotfont/times24.h (deleted)
-
src/libkapa/rotfont/times8.h (deleted)
-
src/libkapa/src/DrawRotString.c (modified) (1 diff)
-
src/libkapa/src/KapaWindow.c (modified) (2 diffs)
-
src/libkapa/src/PSRotFont.c (modified) (3 diffs)
-
src/libohana/include/ohana_allocate.h (modified) (2 diffs)
-
src/libohana/include/ohana_sort.h (modified) (1 diff)
-
src/libohana/src/ohana_allocate.c (modified) (8 diffs)
-
src/libohana/src/sorts.c (modified) (7 diffs)
-
src/markrock/src/markrock.c (modified) (1 diff)
-
src/markstar/src/markstar.c (modified) (1 diff)
-
src/opihi/cmd.astro/fitplx.c (modified) (9 diffs)
-
src/opihi/cmd.basic/date.c (modified) (3 diffs)
-
src/opihi/cmd.data/box.c (modified) (3 diffs)
-
src/opihi/cmd.data/device.c (modified) (2 diffs)
-
src/opihi/cmd.data/read_vectors.c (modified) (1 diff)
-
src/opihi/cmd.data/uniq.c (modified) (2 diffs)
-
src/opihi/dvo/mextract.c (modified) (4 diffs)
-
src/opihi/lib.data/gaussian.c (modified) (2 diffs)
-
src/opihi/lib.shell/ConfigInit.c (modified) (1 diff)
-
src/opihi/lib.shell/SocketOps.c (modified) (2 diffs)
-
src/opihi/lib.shell/gprint.c (modified) (1 diff)
-
src/opihi/pantasks (modified) (1 prop)
-
src/opihi/pantasks/CheckJobs.c (modified) (4 diffs)
-
src/opihi/pantasks/CheckTasks.c (modified) (2 diffs)
-
src/opihi/pantasks/TaskOps.c (modified) (1 diff)
-
src/opihi/pantasks/pantasks_server.c.in (modified) (3 diffs)
-
src/opihi/pantasks/test/local.sh (modified) (2 diffs)
-
src/photdbc/Makefile (modified) (5 diffs)
-
src/photdbc/include/dvocompress.h (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/photdbc/include/dvocompress.h )
-
src/photdbc/src/Shutdown_dvodist.c (modified) (1 diff)
-
src/photdbc/src/args_dvocompress.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/photdbc/src/args_dvocompress.c )
-
src/photdbc/src/copy_images.c (modified) (1 diff)
-
src/photdbc/src/dvocompress.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/photdbc/src/dvocompress.c )
-
src/photdbc/src/dvocompress_catalogs.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/photdbc/src/dvocompress_catalogs.c )
-
src/photdbc/src/dvocompress_client.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/photdbc/src/dvocompress_client.c )
-
src/photdbc/src/photdbc.c (modified) (1 diff)
-
src/photdbc/src/photdbc_catalogs.c (modified) (1 diff)
-
src/photdbc/src/photdbc_client.c (modified) (1 diff)
-
src/relastro/Makefile (modified) (3 diffs)
-
src/relastro/doc/bright.sh (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/relastro/doc/bright.sh )
-
src/relastro/doc/memory.txt (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/relastro/doc/memory.txt )
-
src/relastro/include/relastro.h (modified) (11 diffs)
-
src/relastro/src/FitAstromOps.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/FitAstromOps.c )
-
src/relastro/src/FitChip.c (modified) (6 diffs)
-
src/relastro/src/FitPM.c (modified) (1 diff)
-
src/relastro/src/FitPMandPar.c (modified) (1 diff)
-
src/relastro/src/FitPosPMfixed.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/FitPosPMfixed.c )
-
src/relastro/src/FrameCorrection.c (modified) (1 diff)
-
src/relastro/src/FrameCorrectionUtils.c (modified) (2 diffs)
-
src/relastro/src/GetAstromError.c (modified) (3 diffs)
-
src/relastro/src/ImageOps.c (modified) (6 diffs)
-
src/relastro/src/ParFactor.c (modified) (3 diffs)
-
src/relastro/src/Shutdown.c (modified) (1 diff)
-
src/relastro/src/StarMaps.c (modified) (1 diff)
-
src/relastro/src/UpdateChips.c (modified) (9 diffs)
-
src/relastro/src/UpdateObjectOffsets.c (modified) (5 diffs)
-
src/relastro/src/UpdateObjects.c (modified) (19 diffs)
-
src/relastro/src/args.c (modified) (4 diffs)
-
src/relastro/src/assign_images.c (modified) (1 diff)
-
src/relastro/src/bcatalog.c (modified) (1 diff)
-
src/relastro/src/high_speed_catalogs.c (modified) (3 diffs)
-
src/relastro/src/high_speed_objects.c (modified) (1 diff)
-
src/relastro/src/hpm_catalogs.c (modified) (3 diffs)
-
src/relastro/src/hpm_objects.c (modified) (1 diff)
-
src/relastro/src/launch_region_hosts.c (modified) (1 diff)
-
src/relastro/src/load_catalogs.c (modified) (2 diffs)
-
src/relastro/src/load_images.c (modified) (3 diffs)
-
src/relastro/src/relastro.c (modified) (1 diff)
-
src/relastro/src/relastro_client.c (modified) (2 diffs)
-
src/relastro/src/relastro_images.c (modified) (4 diffs)
-
src/relastro/src/relastro_merge_source.c (modified) (1 diff)
-
src/relastro/src/relastro_objects.c (modified) (3 diffs)
-
src/relastro/src/relastro_parallel_images.c (modified) (3 diffs)
-
src/relastro/src/save_catalogs.c (modified) (1 diff)
-
src/relastro/src/share_images_pos.c (modified) (1 diff)
-
src/relphot/include/relphot.h (modified) (2 diffs)
-
src/relphot/src/Shutdown.c (modified) (1 diff)
-
src/relphot/src/args.c (modified) (2 diffs)
-
src/relphot/src/load_catalogs.c (modified) (2 diffs)
-
src/relphot/src/load_images.c (modified) (1 diff)
-
src/relphot/src/reload_catalogs.c (modified) (2 diffs)
-
src/relphot/src/relphot.c (modified) (1 diff)
-
src/relphot/src/relphot_client.c (modified) (1 diff)
-
src/relphot/src/relphot_objects.c (modified) (2 diffs)
-
src/relphot/src/relphot_parallel_images.c (modified) (2 diffs)
-
src/relphot/src/relphot_synthphot.c (modified) (1 diff)
-
src/relphot/src/setMrelCatalog.c (modified) (1 diff)
-
src/tools/Makefile (modified) (1 diff)
-
src/tools/src/fits_to_mysql.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/tools/src/fits_to_mysql.c )
-
src/tools/src/pspsconvert.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/tools/src/pspsconvert.c )
-
src/uniphot/Makefile (modified) (6 diffs)
-
src/uniphot/include/ckids.h (modified) (1 diff)
-
src/uniphot/include/fiximids.h (modified) (1 diff)
-
src/uniphot/include/fixstkids.h (modified) (1 diff)
-
src/uniphot/include/setastrom.h (modified) (1 diff)
-
src/uniphot/include/setgalmodel.h (modified) (1 diff)
-
src/uniphot/include/setphot.h (modified) (2 diffs)
-
src/uniphot/include/setphot_client.h (deleted)
-
src/uniphot/include/setposangle.h (modified) (1 diff)
-
src/uniphot/src/Shutdown.c (modified) (1 diff)
-
src/uniphot/src/ckids.c (modified) (1 diff)
-
src/uniphot/src/ckids_client.c (modified) (1 diff)
-
src/uniphot/src/fiximids.c (modified) (1 diff)
-
src/uniphot/src/fiximids_client.c (modified) (1 diff)
-
src/uniphot/src/fixstkids.c (modified) (1 diff)
-
src/uniphot/src/fixstkids_client.c (modified) (1 diff)
-
src/uniphot/src/initialize_setphot.c (modified) (1 diff)
-
src/uniphot/src/initialize_setphot_client.c (modified) (1 diff)
-
src/uniphot/src/load_zpt_table.c (modified) (3 diffs)
-
src/uniphot/src/repair_catalog_by_objID.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/uniphot/src/repair_catalog_by_objID.c )
-
src/uniphot/src/setastrom.c (modified) (1 diff)
-
src/uniphot/src/setastrom_client.c (modified) (1 diff)
-
src/uniphot/src/setfwhm.c (modified) (1 diff)
-
src/uniphot/src/setgalmodel.c (modified) (1 diff)
-
src/uniphot/src/setgalmodel_client.c (modified) (1 diff)
-
src/uniphot/src/setphot.c (modified) (2 diffs)
-
src/uniphot/src/setphot_client.c (modified) (1 diff)
-
src/uniphot/src/setposangle.c (modified) (1 diff)
-
src/uniphot/src/setposangle_client.c (modified) (1 diff)
-
src/uniphot/src/uniphot.c (modified) (1 diff)
-
src/uniphot/src/update_catalog_setastrom.c (modified) (5 diffs)
-
src/uniphot/src/update_catalog_setgalmodel.c (modified) (3 diffs)
-
src/uniphot/src/update_dvo_ckids.c (modified) (1 diff)
-
src/uniphot/src/update_dvo_fiximids.c (modified) (1 diff)
-
src/uniphot/src/update_dvo_fixstkids.c (modified) (1 diff)
-
src/uniphot/src/update_dvo_setastrom.c (modified) (2 diffs)
-
src/uniphot/src/update_dvo_setgalmodel.c (modified) (1 diff)
-
src/uniphot/src/update_dvo_setphot.c (modified) (4 diffs)
-
src/uniphot/src/update_dvo_setposangle.c (modified) (1 diff)
-
src/uniphot/src/update_dvo_uniphot.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
-
Property svn:mergeinfo
set to
/branches/eam_branches/ipp-20150625/Ohana merged eligible
-
Property svn:mergeinfo
set to
-
trunk/Ohana/Makefile.Common
r38441 r38986 51 51 @echo $< 52 52 @echo $^ 53 echo CFLAGS: $(CFLAGS) 54 echo TEST_CFLAGS: $(TEST_CFLAGS) 55 echo BASE_CFLAGS: $(BASE_CFLAGS) 53 56 @if [ ! -d $(TESTDIR) ]; then mkdir -p $(TESTDIR); fi 54 57 $(CC) $(TEST_CFLAGS) -o $@ $^ $(TEST_LDFLAGS) -
trunk/Ohana/src/addstar/Makefile
r38636 r38986 37 37 mkcmf : $(BIN)/mkcmf.$(ARCH) 38 38 39 # programs in 'OTHERS' have not been updated since moving from Stars to Catalog as an internal carrier40 39 # programs in 'SERVER' use the client-server concept and are out of date 41 40 42 INSTALL = addstar sedstar loadgalphot loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf dumpskycells findskycell 43 OTHERS = load2mass loadwise loadtycho loadsupercos 41 INSTALL = addstar sedstar loadgalphot loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf dumpskycells findskycell load2mass loadwise loadtycho loadsupercos 44 42 SERVER = addstar_client addstarc addstard addstart 45 43 46 old: $(OTHERS)47 44 all: $(INSTALL) 48 45 49 46 # I need to fix the client/server version of addstar now that I have dropped Stars 50 47 # as an autocode type and have converted to carrying average and measure 51 # all: addstar sedstar load2mass skycells52 53 # $(SRC)/find_matches.$(ARCH).o \54 # $(SRC)/find_matches_closest.$(ARCH).o \55 # $(SRC)/find_matches_refstars.$(ARCH).o \56 # $(SRC)/find_matches_closest_refstars.$(ARCH).o \57 # $(SRC)/find_subset.$(ARCH).o \58 # $(SRC)/getgsc.$(ARCH).o \59 # $(SRC)/getusno.$(ARCH).o \60 # $(SRC)/getusnob.$(ARCH).o \61 # $(SRC)/greference.$(ARCH).o \62 # $(SRC)/grefstars.$(ARCH).o \63 # $(SRC)/dump.$(ARCH).o \64 # $(SRC)/ReadStarsTEXT.$(ARCH).o \65 # $(SRC)/StarOps.$(ARCH).o \66 # $(SRC)/replace_match.$(ARCH).o \67 #68 48 69 49 ADDSTAR = \ … … 104 84 $(SRC)/ReadStarsUKIRT.$(ARCH).o \ 105 85 $(SRC)/ReadXradFITS.$(ARCH).o \ 86 $(SRC)/find_matches.$(ARCH).o \ 87 $(SRC)/find_matches_closest.$(ARCH).o \ 88 $(SRC)/find_matches_refstars.$(ARCH).o \ 89 $(SRC)/find_matches_closest_refstars.$(ARCH).o \ 90 $(SRC)/getgsc.$(ARCH).o \ 91 $(SRC)/getusno.$(ARCH).o \ 92 $(SRC)/getusnob.$(ARCH).o \ 93 $(SRC)/greference.$(ARCH).o \ 94 $(SRC)/grefstars.$(ARCH).o \ 95 $(SRC)/replace_match.$(ARCH).o \ 106 96 $(SRC)/FilterStars.$(ARCH).o \ 107 97 $(SRC)/ImageOptions.$(ARCH).o \ … … 112 102 $(SRC)/update_coords.$(ARCH).o \ 113 103 $(SRC)/psps_ids.$(ARCH).o 114 115 ##116 104 117 105 # this is the client for parallel operations … … 243 231 $(SRC)/load2mass.$(ARCH).o \ 244 232 $(SRC)/load2mass_as_rawdata.$(ARCH).o \ 245 $(SRC)/load2mass_catalog.$(ARCH).o \246 233 $(SRC)/get2mass_ops.$(ARCH).o \ 247 234 $(SRC)/get2mass_full.$(ARCH).o \ … … 252 239 $(SRC)/update_coords.$(ARCH).o \ 253 240 $(SRC)/SkyRegionUtils.$(ARCH).o \ 254 $(SRC)/StarOps.$(ARCH).o \ 255 $(SRC)/ConfigInit.$(ARCH).o \ 256 $(SRC)/Shutdown.$(ARCH).o \ 257 $(SRC)/SetSignals.$(ARCH).o \ 258 $(SRC)/psps_ids.$(ARCH).o 241 $(SRC)/ConfigInit.$(ARCH).o \ 242 $(SRC)/Shutdown.$(ARCH).o \ 243 $(SRC)/SetSignals.$(ARCH).o \ 244 $(SRC)/psps_ids.$(ARCH).o 245 246 # $(SRC)/load2mass_catalog.$(ARCH).o 259 247 260 248 LOAD-GALPHOT = \ … … 296 284 $(SRC)/loadstarpar_save_remote.$(ARCH).o \ 297 285 $(SRC)/loadstarpar_table.$(ARCH).o \ 286 $(SRC)/loadstarpar_extras.$(ARCH).o \ 298 287 $(SRC)/resort_catalog.$(ARCH).o \ 299 288 $(SRC)/psps_ids.$(ARCH).o … … 314 303 $(SRC)/loadstarpar_save_remote.$(ARCH).o \ 315 304 $(SRC)/loadstarpar_table.$(ARCH).o \ 305 $(SRC)/loadstarpar_extras.$(ARCH).o \ 316 306 $(SRC)/resort_catalog.$(ARCH).o \ 317 307 $(SRC)/psps_ids.$(ARCH).o 308 309 # drop resort_catalog? 318 310 319 311 LOAD-ICRF = \ … … 359 351 $(SRC)/ConfigInit.$(ARCH).o \ 360 352 $(SRC)/Shutdown.$(ARCH).o \ 361 $(SRC)/StarOps.$(ARCH).o \362 353 $(SRC)/find_matches_refstars.$(ARCH).o \ 363 354 $(SRC)/build_links.$(ARCH).o \ … … 376 367 $(SRC)/Shutdown.$(ARCH).o \ 377 368 $(SRC)/find_matches_closest_refstars.$(ARCH).o \ 369 $(SRC)/replace_match.$(ARCH).o \ 378 370 $(SRC)/build_links.$(ARCH).o \ 379 371 $(SRC)/SetSignals.$(ARCH).o \ … … 391 383 $(SRC)/ConfigInit.$(ARCH).o \ 392 384 $(SRC)/Shutdown.$(ARCH).o \ 393 $(SRC)/S tarOps.$(ARCH).o \385 $(SRC)/SkyListForStars.$(ARCH).o \ 394 386 $(SRC)/find_matches_refstars.$(ARCH).o \ 395 387 $(SRC)/build_links.$(ARCH).o \ -
trunk/Ohana/src/addstar/include/2mass.h
r24977 r38986 22 22 23 23 SkyTable *get2mass_acc (SkyRegion *patch, char *path, char *accel); 24 Stars *get2mass_2DR_data (SkyRegion *region, char *filename, SkyRegion *patch, int photcode, int *nstars); 25 Stars *get2mass_AS_data (SkyRegion *region, char *filename, SkyRegion *patch, int phocode, int *nstars); 26 Stars *get2mass_AS_rawdata (SkyRegion *region, char *filename, SkyRegion *patch, int phocode, int *nstars); 24 25 // Stars *get2mass_2DR_data (SkyRegion *region, char *filename, SkyRegion *patch, int photcode, int *nstars); 26 // Stars *get2mass_AS_data (SkyRegion *region, char *filename, SkyRegion *patch, int phocode, int *nstars); 27 // Stars *get2mass_AS_rawdata (SkyRegion *region, char *filename, SkyRegion *patch, int phocode, int *nstars); 27 28 28 29 SkyTable *scan2mass_acc (char *path, char *accel); … … 35 36 int load2mass_as_rawdata (SkyList *skytable, char *filename, AddstarClientOptions options); 36 37 SkyTable *load2mass_acc (char *path, char *accel); 37 int get2mass_3star (Stars *star, char *line, int Nmax); 38 int load2mass_catalog (Catalog *catalog, Stars *stars, int Nstars); 38 39 // int get2mass_3star (Stars *star, char *line, int Nmax); 40 // int load2mass_catalog (Catalog *catalog, Stars *stars, int Nstars); 39 41 40 42 int get2mass_setup (int photcode); 41 43 int get2mass_coords (char *line, double *R, double *D, int Nmax); 42 int get2mass_star (Stars *star, char *line, int Nmax);43 int get2mass_3star (Stars *star, char *line, int Nmax);44 44 45 int get2mass_3star_full (Stars **star, char *line, int Nmax); 45 // int get2mass_star (Stars *star, char *line, int Nmax); 46 // int get2mass_3star (Stars *star, char *line, int Nmax); 47 48 int get2mass_3star_full (Measure *measure, char *line, int Nmax); 46 49 char *next2MASSfield (char *line); 47 int set2MASS_ph_qual ( Stars *star, char qual);48 int set2MASS_rd_flag ( Stars *star, char qual);49 int set2MASS_cc_flag ( Stars *star, char qual);50 int set2MASS_bl_flag ( Stars *star, char qual);51 int set2MASS_gal_flag ( Stars *star, char qual);52 int set2MASS_mp_flag ( Stars *star, char qual);53 int set2MASS_dup_flag ( Stars *star, char qual);54 int set2MASS_use_flag ( Stars *star, char qual);50 int set2MASS_ph_qual (Measure *measure, char qual); 51 int set2MASS_rd_flag (Measure *measure, char qual); 52 int set2MASS_cc_flag (Measure *measure, char qual); 53 int set2MASS_bl_flag (Measure *measure, char qual); 54 int set2MASS_gal_flag (Measure *measure, char qual); 55 int set2MASS_mp_flag (Measure *measure, char qual); 56 int set2MASS_dup_flag (Measure *measure, char qual); 57 int set2MASS_use_flag (Measure *measure, char qual); 55 58 int get2mass_sortStars (TMStars *tstars, int Ntstars); -
trunk/Ohana/src/addstar/include/WISE.h
r38062 r38986 35 35 int getWISE_sortStars (WISE_Stars *tstars, int Ntstars); 36 36 37 int loadwise_star_prelim (Stars **star, char *line, int Nmax);38 int loadwise_star_allsky (Stars **star, char *line, int Nmax);39 int loadwise_star_allwise ( Stars **star, char *line, int Nmax);37 int loadwise_star_prelim (Measure *measure, char *line, int Nmax); 38 int loadwise_star_allsky (Measure *measure, char *line, int Nmax); 39 int loadwise_star_allwise (Measure *measure, char *line, int Nmax); 40 40 41 41 42 42 char *nextWISEfield (char *line); 43 int setWISE_cc_flag (Stars *star, char qual);44 int setWISE_ph_qual (Stars *star, char qual);45 int setWISE_rd_flag (Stars *star, char qual);46 int setWISE_bl_flag (Stars *star, char qual);47 int setWISE_gal_flag ( Stars *star, char qual);48 int setWISE_mp_flag (Stars *star, char qual);49 int setWISE_dup_flag ( Stars *star, char qual);50 int setWISE_use_flag ( Stars *star, char qual);43 int setWISE_cc_flag (Measure *measure, char qual); 44 int setWISE_ph_qual (Measure *measure, char qual); 45 int setWISE_rd_flag (Measure *measure, char qual); 46 int setWISE_bl_flag (Measure *measure, char qual); 47 int setWISE_gal_flag (Measure *measure, char qual); 48 int setWISE_mp_flag (Measure *measure, char qual); 49 int setWISE_dup_flag (Measure *measure, char qual); 50 int setWISE_use_flag (Measure *measure, char qual); 51 51 52 52 char *skipNbounds (char *line, char bound, int Nbound, int Nbyte); -
trunk/Ohana/src/addstar/include/addstar.h
r38636 r38986 49 49 int extnum_xrad; 50 50 } HeaderSet; 51 52 # if (0)53 typedef struct {54 Average average;55 Measure measure;56 Lensing *lensing; // optionally carry out the lensing measurements57 int found;58 } Stars;59 60 typedef struct {61 unsigned int Nstars;62 Stars *stars;63 off_t Nimages;64 Image *images;65 Coords *mosaic;66 SkyRegion *patch;67 AddstarClientOptions *options;68 char *refcat;69 } DVO_DATA;70 # endif71 51 72 52 # define IDTYPE int … … 222 202 int find_matches PROTO((SkyRegion *region, Catalog *newcat, Catalog *catalog, AddstarClientOptions options)); 223 203 224 # if (0) 225 int find_matches_refstars PROTO((SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options)); 226 int find_matches_closest_refstars PROTO((SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options)); 227 228 int dump_rawstars PROTO((Stars *stars, unsigned int Nstars)); 229 230 Stars **find_subset PROTO((SkyRegion *region, Stars *stars, unsigned int Nstars, unsigned int *NSTARS)); 204 int find_matches_refstars PROTO((SkyRegion *region, Catalog *srccat, Catalog *tgtcat, AddstarClientOptions options)); 205 int find_matches_closest_refstars PROTO((SkyRegion *region, Catalog *srccat, Catalog *tgtcat, AddstarClientOptions options)); 206 207 Catalog *greference PROTO((char *Refcat, SkyRegion *catstats, int photcode)); 208 231 209 int gcatalog PROTO((Catalog *catalog)); 232 Stars *get2mass PROTO((SkyRegion *patch, int photcode, int mode, unsigned int *NSTARS)); 233 234 Stars *greference PROTO((char *Refcat, SkyRegion *catstats, int photcode, unsigned int *nstars)); 235 Stars *getgsc PROTO((SkyRegion *patch, unsigned int *NSTARS)); 236 Stars *getusno PROTO((SkyRegion *catstats, int photcode, unsigned int *Nstars)); 237 Stars *getusnob PROTO((SkyRegion *catstats, int photcode, unsigned int *Nstars)); 210 Catalog *getgsc PROTO((SkyRegion *patch)); 211 Catalog *getusno PROTO((SkyRegion *catstats)); 212 Catalog *getusnob PROTO((SkyRegion *catstats)); 238 213 239 214 // load text-based stars (REF only in the sense of REF photcodes) 240 Stars *grefstars PROTO((char *file, int photcode, unsigned int *Nstars)); 241 242 Stars *rd_gsc PROTO((char *filename, unsigned int *nstars)); 243 244 int replace_match PROTO((Average *average, Measure *measure, Stars *star)); 245 # endif 215 Catalog *grefstars PROTO((char *file, int photcode)); 216 217 Catalog *rd_gsc PROTO((char *filename)); 218 219 int replace_match PROTO((Average *average, Measure *measure, Measure *newmeas, off_t *found)); 246 220 247 221 Catalog *LoadStars PROTO((char *file, Image **images, off_t *Nimages, AddstarClientOptions *options)); … … 297 271 298 272 SkyList *SkyListExistingSubset PROTO((SkyList *input, char *path)); 273 SkyList *SkyListForStars PROTO((SkyTable *table, int depth, Catalog *catalog)); 299 274 300 275 // these are all for the addstar client/server which has not been maintained … … 311 286 int UpdateDatabase_Reflist PROTO((AddstarClientOptions *options, Stars *stars, unsigned int Nstars)); 312 287 int UpdateDatabase_Refcat PROTO((AddstarClientOptions *options, SkyRegion *UserPatch, char *refcat)); 313 SkyList *SkyListForStars PROTO((SkyTable *table, int depth, Stars *stars, unsigned int Nstars));314 288 int SkyListSetPath PROTO((SkyList *list, char *path)); 315 289 int InitDataset PROTO((void)); -
trunk/Ohana/src/addstar/include/loadstarpar.h
r37807 r38986 12 12 char *INPUT; 13 13 14 AddstarClientOptions args_loadstarpar (int argc, char **argv, AddstarClientOptions options);15 AddstarClientOptions args_loadstarpar_client (int argc, char **argv, AddstarClientOptions options);14 AddstarClientOptions args_loadstarpar (int *argc, char **argv, AddstarClientOptions options); 15 AddstarClientOptions args_loadstarpar_client (int *argc, char **argv, AddstarClientOptions options); 16 16 17 17 int loadstarpar_table (SkyList *skylistInput, HostTable *hosts, char *filename, AddstarClientOptions *options); … … 23 23 int save_remote_host (HostInfo *host); 24 24 25 int init_remote_hosts ( );26 int find_empty_slot ( );27 int harvest_all ( );28 int harvest_host ( );25 int init_remote_hosts (void); 26 int find_empty_slot (void); 27 int harvest_all (void); 28 int harvest_host (void); 29 29 30 30 int loadstarpar_catalog (StarPar_Stars *stars, int Nstars, SkyRegion *region, char *filename, AddstarClientOptions *options); … … 40 40 41 41 int loadstarpar_sortStars (StarPar_Stars *stars, int Nstars); 42 43 int loadstarpar_tmpdir (void); -
trunk/Ohana/src/addstar/include/supercos.h
r33653 r38986 80 80 Image *loadsupercos_plates (Survey *survey, int Nsurvey, char *filename, int *nimage); 81 81 int loadsupercos_getFilterInfo (char *line, char *emulsion, char *filterID); 82 int loadsupercos_rawdata (Image *image, int *imlist, int Nimage, SkyList *skytable, char *filename, AddstarClientOptions options); 83 int loadsupercos_sortStars (Stars *tstars, int Ntstars); 82 int loadsupercos_rawdata (Image *image, int *imlist, int Nimage, SkyTable *skytable, char *filename, AddstarClientOptions options); 84 83 int *loadsupercos_image_index (Image *image, int Nimage); 85 84 int loadsupercos_getST (char *line, double *st); -
trunk/Ohana/src/addstar/src/LoadFilenames.c
- Property svn:mergeinfo deleted
-
trunk/Ohana/src/addstar/src/SkyListForStars.c
r38553 r38986 1 1 # include "addstar.h" 2 2 3 # if (0) 4 void sort_stars_ra (Stars *stars, int N) { 3 void sort_stars_ra (Catalog *catalog) { 5 4 6 # define SWAPFUNC(A,B){ Stars tmp; tmp = stars[A]; stars[A] = stars[B]; stars[B] = tmp; }7 # define COMPARE(A,B)( stars[A].average.R < stars[B].average.R)5 # define SWAPFUNC(A,B){ Average tmp; tmp = catalog->average[A]; catalog->average[A] = catalog->average[B]; catalog->average[B] = tmp; } 6 # define COMPARE(A,B)(catalog->average[A].R < catalog->average[B].R) 8 7 9 OHANA_SORT ( N, COMPARE, SWAPFUNC);8 OHANA_SORT (catalog->Naverage, COMPARE, SWAPFUNC); 10 9 11 10 # undef SWAPFUNC … … 14 13 } 15 14 16 SkyList *SkyListForStars (SkyTable *table, int depth, Stars *stars, unsigned int Nstars) {15 SkyList *SkyListForStars (SkyTable *table, int depth, Catalog *catalog) { 17 16 18 17 int i, j, Nr, NR; … … 28 27 list[0].ownElements = FALSE; // free these elements when freeing the list 29 28 30 sort_stars_ra (stars, Nstars); /* sort by RA */ 31 for (i = 0; i < Nstars; i++) { 32 if (stars[i].found == -2) continue; 33 here = SkyRegionByPoint (table, depth, stars[i].average.R, stars[i].average.D); 34 stars[i].found = -2; 29 sort_stars_ra (catalog); /* sort by RA */ 30 31 ALLOCATE (catalog->found_t, off_t, catalog->Naverage); 32 for (i = 0; i < catalog->Naverage; i++) { 33 catalog->found_t[i] = 0; 34 } 35 36 for (i = 0; i < catalog->Naverage; i++) { 37 if (catalog->found_t[i] == -2) continue; 38 here = SkyRegionByPoint (table, depth, catalog->average[i].R, catalog->average[i].D); 39 catalog->found_t[i] = -2; 35 40 /* search forward for all contained stars */ 36 for (j = i; j < Nstars; j++) {37 if ( stars[j].average.R >= here[0].regions[0][0].Rmax) break;38 if ( stars[j].average.R < here[0].regions[0][0].Rmin) break;39 if ( stars[j].average.D < here[0].regions[0][0].Dmin) continue;40 if ( stars[j].average.D >= here[0].regions[0][0].Dmax) continue;41 stars[j].found= -2;41 for (j = i; j < catalog->Naverage; j++) { 42 if (catalog->average[j].R >= here[0].regions[0][0].Rmax) break; 43 if (catalog->average[j].R < here[0].regions[0][0].Rmin) break; 44 if (catalog->average[j].D < here[0].regions[0][0].Dmin) continue; 45 if (catalog->average[j].D >= here[0].regions[0][0].Dmax) continue; 46 catalog->found_t[j] = -2; 42 47 } 43 48 list[0].regions[Nr] = here[0].regions[0]; … … 54 59 55 60 /* reset to -1 for all stars: required start for find_match_refstars */ 56 for (i = 0; i < Nstars; i++) stars[i].found = -1; 61 free (catalog->found_t); 62 catalog->found_t = NULL; 57 63 return (list); 58 64 } … … 70 76 71 77 */ 72 # endif -
trunk/Ohana/src/addstar/src/UpdateDatabase_Image.c
r38471 r38986 79 79 dvo_catalog_save (&catalog, VERBOSE); 80 80 } 81 SetProtect (FALSE);82 81 } 83 82 dvo_catalog_unlock (&catalog); 83 SetProtect (FALSE); 84 84 85 dvo_catalog_free (&catalog); 85 86 } -
trunk/Ohana/src/addstar/src/UpdateDatabase_Refcat.c
r38471 r38986 69 69 dvo_catalog_save (&catalog, VERBOSE); 70 70 } 71 SetProtect (FALSE);72 71 } 73 72 dvo_catalog_unlock (&catalog); 73 SetProtect (FALSE); 74 74 75 dvo_catalog_free (&catalog); 75 76 free (stars); -
trunk/Ohana/src/addstar/src/UpdateDatabase_Reflist.c
r38471 r38986 65 65 dvo_catalog_save (&catalog, VERBOSE); 66 66 } 67 SetProtect (FALSE);68 67 } 69 68 dvo_catalog_unlock (&catalog); 69 SetProtect (FALSE); 70 70 71 dvo_catalog_free (&catalog); 71 72 } -
trunk/Ohana/src/addstar/src/addstar.c
r38553 r38986 57 57 UpdateImageIDs (newcat, images, Nimages); 58 58 59 // if ((DUMP != NULL) && !strcmp (DUMP, "rawstars")) dump_rawstars (stars, Nstars);60 59 for (i = 0; i < Nimages; i++) { 61 60 newlist = SkyListByImage (sky, -1, &images[i]); … … 66 65 ImageOptions (&options, images, Nimages); 67 66 break; 68 # if (0)69 67 case ADDSTAR_MODE_REFLIST: 70 stars = grefstars (argv[1], options.photcode, &Nstars);71 skylist = SkyListForStars (sky, -1, stars, Nstars);68 newcat = grefstars (argv[1], options.photcode); 69 skylist = SkyListForStars (sky, -1, newcat); 72 70 break; 73 71 case ADDSTAR_MODE_REFCAT: … … 80 78 skylist[0].ownElements = FALSE; 81 79 break; 82 # endif83 80 84 81 default: … … 146 143 switch (options.mode) { 147 144 case ADDSTAR_MODE_IMAGE: 148 // Nsubset = Nstars;149 145 if (options.closest) { 150 146 Nmatch += find_matches_closest (skylist[0].regions[i], newcat, &catalog, options); … … 153 149 } 154 150 break; 155 # if (0) 151 156 152 case ADDSTAR_MODE_REFCAT: 157 stars = greference (argv[1], skylist[0].regions[i], options.photcode, &Nstars);153 newcat = greference (argv[1], skylist[0].regions[i], options.photcode); 158 154 case ADDSTAR_MODE_REFLIST: { 159 Stars **subset = find_subset (skylist[0].regions[i], stars, Nstars, &Nsubset);160 155 if (options.closest) { 161 Nmatch += find_matches_closest_refstars (skylist[0].regions[i], subset, Nsubset, &catalog, options);156 Nmatch += find_matches_closest_refstars (skylist[0].regions[i], newcat, &catalog, options); 162 157 } else { 163 Nmatch += find_matches_refstars (skylist[0].regions[i], subset, Nsubset, &catalog, options);158 Nmatch += find_matches_refstars (skylist[0].regions[i], newcat, &catalog, options); 164 159 } 165 if (Nsubset) free (subset);166 160 break; 167 161 } 168 # endif169 162 default: 170 163 abort(); … … 186 179 dvo_catalog_save (&catalog, VERBOSE); 187 180 } 188 SetProtect (FALSE);189 181 } 190 182 dvo_catalog_unlock (&catalog); 183 SetProtect (FALSE); 191 184 dvo_catalog_free (&catalog); 192 185 if (VERBOSE) MARKTIME ("save cpt: %f sec\n", dtime); RESETTIME; -
trunk/Ohana/src/addstar/src/addstar_client.c
r37116 r38986 13 13 14 14 // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, etc) 15 SetSignals (); 15 16 options = ConfigInit (&argc, argv); 16 17 options = args_parallel_client (argc, argv, options); -
trunk/Ohana/src/addstar/src/addstarc.c
r33963 r38986 11 11 12 12 /* load config and options */ 13 SetSignals (); 13 14 options = ConfigInit (&argc, argv); 14 15 options = args_client (argc, argv, options); -
trunk/Ohana/src/addstar/src/addstard.c
r27435 r38986 8 8 AddstarClientOptions options; 9 9 10 SetSignals (); 10 11 options = ConfigInit (&argc, argv); 11 12 args_server (argc, argv); -
trunk/Ohana/src/addstar/src/addstart.c
r33963 r38986 8 8 DVO_DATA *dataset; 9 9 10 SetSignals (); 10 11 options = ConfigInit (&argc, argv); 11 12 args_server (argc, argv); -
trunk/Ohana/src/addstar/src/args_loadstarpar.c
r37807 r38986 5 5 static void help_client (void); 6 6 7 AddstarClientOptions args_loadstarpar (int argc, char **argv, AddstarClientOptions options) {7 AddstarClientOptions args_loadstarpar (int *argc, char **argv, AddstarClientOptions options) { 8 8 9 9 int N; 10 10 11 11 /* check for help request */ 12 if (get_argument ( argc, argv, "-help") ||13 get_argument ( argc, argv, "-h")) {12 if (get_argument (*argc, argv, "-help") || 13 get_argument (*argc, argv, "-h")) { 14 14 help (); 15 15 } … … 28 28 HOST_ID = 0; 29 29 PARALLEL = FALSE; 30 if ((N = get_argument ( argc, argv, "-parallel"))) {30 if ((N = get_argument (*argc, argv, "-parallel"))) { 31 31 PARALLEL = TRUE; 32 remove_argument (N, &argc, argv);32 remove_argument (N, argc, argv); 33 33 } 34 34 // this is a test mode : rather than launching the remote jobs and waiting for completion, 35 35 // relphot will simply list the remote command and wait for the user to signal completion 36 36 PARALLEL_MANUAL = FALSE; 37 if ((N = get_argument ( argc, argv, "-parallel-manual"))) {37 if ((N = get_argument (*argc, argv, "-parallel-manual"))) { 38 38 PARALLEL = TRUE; // -parallel-manual implies -parallel 39 39 PARALLEL_MANUAL = TRUE; 40 remove_argument (N, &argc, argv);40 remove_argument (N, argc, argv); 41 41 } 42 42 // this is a test mode : rather than launching the relphot_client jobs remotely, they are 43 43 // run in serial via 'system' 44 44 PARALLEL_SERIAL = FALSE; 45 if ((N = get_argument ( argc, argv, "-parallel-serial"))) {45 if ((N = get_argument (*argc, argv, "-parallel-serial"))) { 46 46 if (PARALLEL_MANUAL) { 47 47 fprintf (stderr, "ERROR: cannot mix -parallel-manual and -parallel-serial\n"); … … 50 50 PARALLEL = TRUE; // -parallel-serial implies -parallel 51 51 PARALLEL_SERIAL = TRUE; 52 remove_argument (N, &argc, argv);53 } 54 55 /* only add to existing regions */52 remove_argument (N, argc, argv); 53 } 54 55 /* only add to existing regions */ 56 56 options.existing_regions = FALSE; 57 if ((N = get_argument (argc, argv, "-existing-regions"))) { 58 options.existing_regions = TRUE; 59 remove_argument (N, &argc, argv); 60 } 57 // XXX NOT USED if ((N = get_argument (*argc, argv, "-existing-regions"))) { 58 // XXX NOT USED options.existing_regions = TRUE; 59 // XXX NOT USED remove_argument (N, argc, argv); 60 // XXX NOT USED } 61 61 62 /* only add to existing objects */ 62 63 options.only_match = FALSE; 63 if ((N = get_argument ( argc, argv, "-only-match"))) {64 if ((N = get_argument (*argc, argv, "-only-match"))) { 64 65 options.only_match = TRUE; 65 remove_argument (N, &argc, argv); 66 } 66 remove_argument (N, argc, argv); 67 } 68 67 69 /* replace measurement, don't duplicate (ref/cat only) */ 68 70 options.replace = FALSE; 69 if ((N = get_argument ( argc, argv, "-replace"))) {71 if ((N = get_argument (*argc, argv, "-replace"))) { 70 72 options.replace = TRUE; 71 remove_argument (N, &argc, argv);73 remove_argument (N, argc, argv); 72 74 } 73 75 74 76 /* extra error messages */ 75 77 VERBOSE = FALSE; 76 if ((N = get_argument ( argc, argv, "-v"))) {78 if ((N = get_argument (*argc, argv, "-v"))) { 77 79 VERBOSE = TRUE; 78 remove_argument (N, &argc, argv);80 remove_argument (N, argc, argv); 79 81 } 80 82 … … 96 98 DUMP = NULL; 97 99 98 if ( argc < 2) {100 if (*argc < 2) { 99 101 fprintf (stderr, "USAGE: loadstarpar [options] (fitsfile) [..more files]\n"); 100 102 exit (2); … … 103 105 } 104 106 105 AddstarClientOptions args_loadstarpar_client (int argc, char **argv, AddstarClientOptions options) {107 AddstarClientOptions args_loadstarpar_client (int *argc, char **argv, AddstarClientOptions options) { 106 108 107 109 int N; 108 110 109 111 /* check for help request */ 110 if (get_argument ( argc, argv, "-help") ||111 get_argument ( argc, argv, "-h")) {112 if (get_argument (*argc, argv, "-help") || 113 get_argument (*argc, argv, "-h")) { 112 114 help (); 113 115 } … … 118 120 119 121 HOST_ID = 0; 120 if ((N = get_argument ( argc, argv, "-hostID"))) {121 remove_argument (N, &argc, argv);122 if ((N = get_argument (*argc, argv, "-hostID"))) { 123 remove_argument (N, argc, argv); 122 124 HOST_ID = atoi (argv[N]); 123 remove_argument (N, &argc, argv);125 remove_argument (N, argc, argv); 124 126 } 125 127 if (!HOST_ID) help_client(); 126 128 127 129 HOSTDIR = NULL; 128 if ((N = get_argument ( argc, argv, "-hostdir"))) {129 remove_argument (N, &argc, argv);130 if ((N = get_argument (*argc, argv, "-hostdir"))) { 131 remove_argument (N, argc, argv); 130 132 HOSTDIR = strcreate (argv[N]); 131 remove_argument (N, &argc, argv);133 remove_argument (N, argc, argv); 132 134 } 133 135 if (!HOSTDIR) help_client(); 134 136 135 137 CPT_FILE = NULL; 136 if ((N = get_argument ( argc, argv, "-cpt"))) {137 remove_argument (N, &argc, argv);138 if ((N = get_argument (*argc, argv, "-cpt"))) { 139 remove_argument (N, argc, argv); 138 140 CPT_FILE = strcreate (argv[N]); 139 remove_argument (N, &argc, argv);141 remove_argument (N, argc, argv); 140 142 } 141 143 if (!CPT_FILE) help_client(); 142 144 143 145 INPUT = NULL; 144 if ((N = get_argument ( argc, argv, "-input"))) {145 remove_argument (N, &argc, argv);146 if ((N = get_argument (*argc, argv, "-input"))) { 147 remove_argument (N, argc, argv); 146 148 INPUT = strcreate (argv[N]); 147 remove_argument (N, &argc, argv);149 remove_argument (N, argc, argv); 148 150 } 149 151 if (!INPUT) help_client(); … … 157 159 /* only add to existing objects */ 158 160 options.only_match = FALSE; 159 if ((N = get_argument ( argc, argv, "-only-match"))) {161 if ((N = get_argument (*argc, argv, "-only-match"))) { 160 162 options.only_match = TRUE; 161 remove_argument (N, &argc, argv);163 remove_argument (N, argc, argv); 162 164 } 163 165 /* replace measurement, don't duplicate (ref/cat only) */ 164 166 options.replace = FALSE; 165 if ((N = get_argument ( argc, argv, "-replace"))) {167 if ((N = get_argument (*argc, argv, "-replace"))) { 166 168 options.replace = TRUE; 167 remove_argument (N, &argc, argv);169 remove_argument (N, argc, argv); 168 170 } 169 171 170 172 /* extra error messages */ 171 173 VERBOSE = FALSE; 172 if ((N = get_argument ( argc, argv, "-v"))) {174 if ((N = get_argument (*argc, argv, "-v"))) { 173 175 VERBOSE = TRUE; 174 remove_argument (N, &argc, argv);176 remove_argument (N, argc, argv); 175 177 } 176 178 … … 192 194 DUMP = NULL; 193 195 194 if ( argc != 1) {196 if (*argc != 1) { 195 197 fprintf (stderr, "USAGE: loadstarpar_client -cpt (file) -input (file)\n"); 196 198 exit (2); -
trunk/Ohana/src/addstar/src/find_matches.c
r38553 r38986 3 3 int find_matches (SkyRegion *region, Catalog *srccat, Catalog *tgtcat, AddstarClientOptions options) { 4 4 5 off_t i, j, n, N,J, Nstars, mSrc;5 off_t i, j, J, Nstars, mSrc; 6 6 double RADIUS, RADIUS2; 7 7 double *X1, *Y1, *X2, *Y2; … … 9 9 off_t *N1, *N2; 10 10 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch; 11 int Nsecfilt, Nsec, status;12 11 unsigned int objID, catID; 13 12 Coords tcoords; 13 int Nsecfilt, Nsec; 14 14 15 15 /* photcode data - must by of type DEP; options.photcode is equiv photcode for all input … … 58 58 catID = tgtcat[0].catID; 59 59 60 /* project onto rectilinear grid with 1 arcsec pixels. the choice of ZEA projection has the61 * advantage that every point in R,D has a mapping to a unique X,Y. However, note that not all62 * possible X,Y points map back to R,D and the local plate scale changes substantially far from63 * the projection pole. a better mapping might be ARC, not yet implemented (see64 * coordops.update.c). We use the center of the region (tgtcat) for crval1,2.60 /* project onto rectilinear grid with 1 arcsec pixels. the choice of ARC projection has 61 * the advantage that every point in R,D has a mapping to a unique X,Y. However, note 62 * that not all possible X,Y points map back to R,D and the local plate scale changes 63 * substantially far from the projection pole. We use the center of the region (tgtcat) 64 * for crval1,2. 65 65 */ 66 66 InitCoords (&tcoords, "DEC--ARC"); 67 67 tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax); 68 if ( region[0].Dmax < 90) {68 if ((region[0].Dmax < 90) && (region[0].Dmin > -90)) { 69 69 tcoords.crval2 = 0.5*(region[0].Dmin + region[0].Dmax); 70 70 } else { 71 tcoords.crval2 = 90.0;71 tcoords.crval2 = (region[0].Dmax >= 90) ? 90.0 : -90.0; 72 72 } 73 73 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; … … 76 76 Nstars = 0; 77 77 for (i = 0; i < srccat->Naverage; i++) { 78 status = RD_to_XY (&X1[Nstars], &Y1[Nstars], srccat->average[i].R, srccat->average[i].D, &tcoords);78 int status = RD_to_XY (&X1[Nstars], &Y1[Nstars], srccat->average[i].R, srccat->average[i].D, &tcoords); 79 79 if (!status) continue; 80 80 N1[Nstars] = i; … … 101 101 if (Nave > 1) sort_coords_index (X2, Y2, N2, Nave); 102 102 103 /* set up pointers for linked list of measure */103 /* set up pointers for linked list of measurements */ 104 104 if (tgtcat[0].sorted && (tgtcat[0].Nmeasure == tgtcat[0].Nmeasure_disk)) { 105 // this version is only valid if we have done a full catalog load, and if the catalog 106 // is sorted while processed 105 107 next_meas = init_measure_links (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas); 106 108 } else { … … 109 111 110 112 /* choose a radius for matches (defined in args.c or ImageOptions.c) */ 111 RADIUS = options.radius; 113 if (options.radius == 0) { 114 RADIUS = 2.0; /* hardwired default for refstars */ 115 } else { 116 RADIUS = options.radius; /* provided by config */ 117 } 112 118 RADIUS2 = RADIUS*RADIUS; 113 119 114 /** find matched stars **/ 120 /****************** find matched stars ********************/ 121 115 122 for (i = j = 0; (i < Nstars) && (j < Nave); ) { 116 123 if (!finite(X1[i]) || !finite(Y1[i])) { … … 144 151 /*** a match is found, add to average, measure ***/ 145 152 Nmatch ++; 146 n = N2[J];147 N = N1[i];153 off_t n = N2[J]; 154 off_t N = N1[i]; 148 155 149 156 /* make sure there is space for next entry */ … … 161 168 162 169 /** add measurements for this star **/ 163 170 164 171 // set the new measurements 165 172 tgtcat[0].measure[Nmeas] = srccat->measure[mSrc + mOff]; … … 231 238 tgtcat[0].found_t[n] = Nmeas; 232 239 } 233 /* Nm is updated, but not written out in -update mode (for existing entries)234 Nm is recalculated in build_meas_links if loaded table is not sorted */235 240 tgtcat[0].average[n].Nmeasure ++; 236 241 Nmeas ++; … … 245 250 } 246 251 247 /* incorporate unmatched image stars, if this star is in field of this tgtcat */248 /* these new entries are all written out in UPDATE mode */249 for (i = 0; (i < Nstars) && !options.only_match; i ++) {252 /* incorporate unmatched image stars, if this star is in field of this tgtcat */ 253 /* these new entries are all written out in UPDATE mode */ 254 for (i = 0; (i < Nstars) && !options.only_match; i++) { 250 255 /* make sure there is space for next entry */ 251 256 if (Nmeas >= NMEAS - srccat->average[i].Nmeasure) { … … 324 329 } 325 330 326 /* note stars which have been found in this tgtcat */331 /* note stars which have been found in this tgtcat */ 327 332 for (i = 0; i < srccat->Nmeasure; i++) { 328 333 if (srccat->found_t[i] > -1) { … … 331 336 } 332 337 333 /* check if the tgtcat has changed? if no change, no need to write */338 /* check if the tgtcat has changed? if no change, no need to write */ 334 339 tgtcat[0].objID = objID; // new max value, save on tgtcat close 335 340 tgtcat[0].Naverage = Nave; … … 341 346 free (Y1); 342 347 free (N1); 343 free (N2);344 348 free (X2); 345 349 free (Y2); 350 free (N2); 346 351 free (next_meas); 347 352 -
trunk/Ohana/src/addstar/src/find_matches_closest.c
r38553 r38986 3 3 int find_matches_closest (SkyRegion *region, Catalog *srccat, Catalog *tgtcat, AddstarClientOptions options) { 4 4 5 off_t i, j, n, N,J, Jmin, status, Nstars, mSrc;5 off_t i, j, J, Jmin, status, Nstars, mSrc; 6 6 double RADIUS, RADIUS2, Rmin; 7 7 double *X1, *Y1, *X2, *Y2; … … 9 9 off_t *N1, *N2; 10 10 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch, Nlens, NLENS; 11 int Nsecfilt, Nsec;12 11 unsigned int objID, catID; 13 12 Coords tcoords; 13 int Nsecfilt, Nsec; 14 14 15 15 /* photcode data - must by of type DEP; options.photcode is equiv photcode for all input … … 62 62 * the advantage that every point in R,D has a mapping to a unique X,Y. However, note 63 63 * that not all possible X,Y points map back to R,D and the local plate scale changes 64 * far from the projection pole. We use the center of the region (tgtcat) for crval1,2. 64 * substantially far from the projection pole. We use the center of the region (tgtcat) 65 * for crval1,2. 65 66 */ 66 67 InitCoords (&tcoords, "DEC--ARC"); 67 68 tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax); 68 if ( region[0].Dmax < 90) {69 if ((region[0].Dmax < 90) && (region[0].Dmin > -90)) { 69 70 tcoords.crval2 = 0.5*(region[0].Dmin + region[0].Dmax); 70 71 } else { 71 tcoords.crval2 = 90.0;72 tcoords.crval2 = (region[0].Dmax >= 90) ? 90.0 : -90.0; 72 73 } 73 74 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; … … 114 115 115 116 /* choose a radius for matches */ 116 RADIUS = options.radius; /* provided by config */ 117 if (options.radius == 0) { 118 RADIUS = 2.0; /* hardwired default for refstars */ 119 } else { 120 RADIUS = options.radius; /* provided by config */ 121 } 117 122 RADIUS2 = RADIUS*RADIUS; 118 123 … … 178 183 /*** a match is found, add to average, measure ***/ 179 184 Nmatch ++; 180 n = N2[Jmin];181 N = N1[i];185 off_t n = N2[Jmin]; 186 off_t N = N1[i]; 182 187 183 188 /* make sure there is space for next entry */ … … 355 360 next_meas[Nmeas-1] = (mSrc < srccat->average[i].Nmeasure - 1) ? Nmeas : -1; 356 361 } 357 srccat->found_t[i] = Nave;358 359 362 // if we have lensing data, insert that as well 360 363 if (srccat->lensing) { … … 374 377 } 375 378 } 379 srccat->found_t[i] = Nave; 376 380 Nave ++; 377 381 } … … 407 411 free (Y1); 408 412 free (N1); 409 free (N2);410 413 free (X2); 411 414 free (Y2); 415 free (N2); 412 416 free (next_meas); 413 417 free (next_lens); -
trunk/Ohana/src/addstar/src/find_matches_closest_refstars.c
r38467 r38986 1 1 # include "addstar.h" 2 2 3 /* differences with find_matches_closest(): 4 * accepts Stars **stars (vs Stars *stars) 5 * NREFSTAR_GROUP vs NSTAR_GROUP 6 * does not update lensing fields 7 * allows option to replace existing entries 8 * allows multiple photcodes 9 10 */ 11 12 int find_matches_closest_refstars (SkyRegion *region, Stars **stars, unsigned int NstarsIn, Catalog *catalog, AddstarClientOptions options) { 13 14 off_t i, j, n, N, J, Jmin, status; 3 int find_matches_closest_refstars (SkyRegion *region, Catalog *srccat, Catalog *tgtcat, AddstarClientOptions options) { 4 5 off_t i, j, J, Jmin, status, mSrc; 15 6 double RADIUS, RADIUS2, Rmin; 16 7 double *X1, *Y1, *X2, *Y2; 17 8 double dX, dY, dR; 18 off_t *N1, *N2 , *next_meas;9 off_t *N1, *N2; 19 10 off_t Nave, NAVE, Nmeas, NMEAS, Nstars, Nmatch; 20 11 unsigned int objID, catID; … … 22 13 int Nsecfilt; 23 14 24 switch (NREFSTAR_GROUP) {25 case 1:26 case 3:27 case 4:28 case 6:29 break;30 default:31 fprintf (stderr, "ERROR: NREFSTAR_GROUP NOT SET!\n");32 exit (1);33 }34 35 15 /* photcode data -- should not have to modify secfilt / average */ 36 16 Nsecfilt = GetPhotcodeNsecfilt (); 37 17 38 /** allocate local arrays (stars) **/ 39 ALLOCATE (X1, double, NstarsIn); 40 ALLOCATE (Y1, double, NstarsIn); 41 ALLOCATE (N1, off_t, NstarsIn); 42 43 /** allocate local arrays (catalog) **/ 44 NAVE = Nave = catalog[0].Naverage; 18 /** allocate local arrays (srccat) **/ 19 ALLOCATE (X1, double, srccat->Naverage); 20 ALLOCATE (Y1, double, srccat->Naverage); 21 ALLOCATE (N1, off_t, srccat->Naverage); 22 23 if (!srccat->found_t) { 24 ALLOCATE (srccat->found_t, off_t, srccat->Naverage); 25 for (i = 0; i < srccat->Naverage; i++) { 26 srccat->found_t[i] = -1; 27 } 28 } 29 30 /** allocate local arrays (tgtcat) **/ 31 NAVE = Nave = tgtcat[0].Naverage; 45 32 ALLOCATE (X2, double, NAVE); 46 33 ALLOCATE (Y2, double, NAVE); 47 34 ALLOCATE (N2, off_t, NAVE); 48 ALLOCATE (catalog[0].found_t, off_t, NAVE); 35 36 if (!tgtcat->found_t) { 37 ALLOCATE (tgtcat[0].found_t, off_t, NAVE); 38 for (i = 0; i < NAVE; i++) { 39 tgtcat->found_t[i] = -1; 40 } 41 } 49 42 /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */ 50 43 51 44 /* internal counters */ 52 45 Nmatch = 0; 53 NMEAS = Nmeas = catalog[0].Nmeasure;46 NMEAS = Nmeas = tgtcat[0].Nmeasure; 54 47 55 // current max obj ID for this catalog 56 objID = catalog[0].objID; 57 catID = catalog[0].catID; 48 off_t *next_meas = NULL; 49 50 // current max obj ID for this tgtcat 51 objID = tgtcat[0].objID; 52 catID = tgtcat[0].catID; 58 53 59 54 /* project onto rectilinear grid with 1 arcsec pixels. the choice of ARC projection has 60 55 * the advantage that every point in R,D has a mapping to a unique X,Y. However, note 61 56 * that not all possible X,Y points map back to R,D and the local plate scale changes 62 * far from the projection pole. We use the center of the region (catalog) for crval1,2. 57 * substantially far from the projection pole. We use the center of the region (tgtcat) 58 * for crval1,2. 63 59 */ 64 60 InitCoords (&tcoords, "DEC--ARC"); 65 61 tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax); 66 if ( region[0].Dmax < 90) {62 if ((region[0].Dmax < 90) && (region[0].Dmin > -90)) { 67 63 tcoords.crval2 = 0.5*(region[0].Dmin + region[0].Dmax); 68 64 } else { 69 tcoords.crval2 = 90.0;65 tcoords.crval2 = (region[0].Dmax >= 90) ? 90.0 : -90.0; 70 66 } 71 67 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; … … 73 69 /* build spatial index (RA sort) referencing input array sequence */ 74 70 Nstars = 0; 75 for (i = 0; i < NstarsIn; i++) {76 status = RD_to_XY (&X1[Nstars], &Y1[Nstars], s tars[i][0].average.R, stars[i][0].average.D, &tcoords);71 for (i = 0; i < srccat->Naverage; i++) { 72 status = RD_to_XY (&X1[Nstars], &Y1[Nstars], srccat->average[i].R, srccat->average[i].D, &tcoords); 77 73 if (!status) continue; 78 74 N1[Nstars] = i; … … 80 76 } 81 77 if (Nstars < 1) { 82 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", catalog[0].filename);78 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", tgtcat[0].filename); 83 79 free (X1); 84 80 free (Y1); … … 93 89 /* build spatial index (RA sort) */ 94 90 for (i = 0; i < Nave; i++) { 95 RD_to_XY (&X2[i], &Y2[i], catalog[0].average[i].R, catalog[0].average[i].D, &tcoords);91 RD_to_XY (&X2[i], &Y2[i], tgtcat[0].average[i].R, tgtcat[0].average[i].D, &tcoords); 96 92 N2[i] = i; 97 catalog[0].found_t[N2[i]] = -1;93 tgtcat[0].found_t[N2[i]] = -1; 98 94 } 99 95 if (Nave > 1) sort_coords_index (X2, Y2, N2, Nave); 100 96 101 97 /* set up pointers for linked list of measure */ 102 if ( catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeasure_disk)) {103 // this version is only valid if we have done a full catalog load, and if the catalog98 if (tgtcat[0].sorted && (tgtcat[0].Nmeasure == tgtcat[0].Nmeasure_disk)) { 99 // this version is only valid if we have done a full tgtcat load, and if the tgtcat 104 100 // is sorted while processed 105 next_meas = init_measure_links ( catalog[0].average, Nave, catalog[0].measure, Nmeas);101 next_meas = init_measure_links (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas); 106 102 } else { 107 next_meas = build_measure_links ( catalog[0].average, Nave, catalog[0].measure, Nmeas);103 next_meas = build_measure_links (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas); 108 104 } 109 105 … … 116 112 RADIUS2 = RADIUS*RADIUS; 117 113 118 /** find matched stars**/119 // XXX could use NREFSTAR_GROUP to do this match more quicky 114 /****************** find matched stars ********************/ 115 120 116 for (i = j = 0; (i < Nstars) && (j < Nave); ) { 121 117 if (!finite(X1[i]) || !finite(Y1[i])) { … … 140 136 } 141 137 142 if (stars[N1[i]][0].found != -1) { 143 /* this star has already been assigned to an object in this or another catalog */ 138 // XXX check that this is allocated 139 if (srccat->found_t[N1[i]] != -1) { 140 /* this star has already been assigned to an object in this or another tgtcat */ 144 141 i++; 145 142 continue; … … 169 166 /*** a match is found, add to average, measure ***/ 170 167 Nmatch ++; 171 n = N2[Jmin]; 172 N = N1[i]; 173 174 /** in replace mode, search for entry and replace values M, dM, R, D */ 175 // XXX this fails for unsorted catalogs, right? 176 if (options.replace && replace_match (&catalog[0].average[n], catalog[0].measure, stars[N])) { 177 i++; 178 continue; 179 } 168 off_t n = N2[Jmin]; 169 off_t N = N1[i]; 180 170 181 171 /* make sure there is space for next entry */ 182 if (Nmeas >= NMEAS ) {183 NMEAS = Nmeas + 1000 ;172 if (Nmeas >= NMEAS - srccat->average[N].Nmeasure) { 173 NMEAS = Nmeas + 1000 + srccat->average[N].Nmeasure; 184 174 REALLOCATE (next_meas, off_t, NMEAS); 185 REALLOCATE (catalog[0].measure, Measure, NMEAS); 186 } 187 188 /* add to end of measurement list */ 189 add_meas_link (&catalog[0].average[n], next_meas, Nmeas, NMEAS); 190 175 REALLOCATE (tgtcat[0].measure, Measure, NMEAS); 176 } 177 191 178 /** add measurements for this star **/ 192 193 // set the new measurements 194 catalog[0].measure[Nmeas] = stars[N][0].measure; 195 196 catalog[0].measure[Nmeas].dbFlags = 0; 197 catalog[0].measure[Nmeas].averef = n; 198 catalog[0].measure[Nmeas].objID = catalog[0].average[n].objID; 199 catalog[0].measure[Nmeas].catID = catalog[0].catID; 200 201 float dRoff = dvoOffsetR(&catalog[0].measure[Nmeas], &catalog[0].average[n]); 202 203 // rationalize dR: 204 if (dRoff > +180.0*3600.0) { 205 // average on high end of boundary, move star up 206 catalog[0].measure[Nmeas].R += 360.0; 207 dRoff -= 360.0*3600.0; 208 } 209 if (dRoff < -180.0*3600.0) { 210 // average on low end of boundary, move star down 211 catalog[0].measure[Nmeas].R -= 360.0; 212 dRoff += 360.0*3600.0; 213 } 214 215 // the reference data may not have per-object time specified 216 catalog[0].measure[Nmeas].t = (TIMEREF == 0) ? stars[N][0].measure.t : TIMEREF; /** careful : time_t vs e_time **/ 217 catalog[0].measure[Nmeas].t_msec = (TIMEREF == 0) ? stars[N][0].measure.t_msec : TIMEREF; /** careful : time_t vs e_time **/ 218 219 // we can choose to accept the proper-motion and parallax from the reference catalog 220 if (ACCEPT_MOTION) { 221 catalog[0].average[n].dR = stars[N][0].average.dR; 222 catalog[0].average[n].dD = stars[N][0].average.dD; 223 catalog[0].average[n].uR = stars[N][0].average.uR; 224 catalog[0].average[n].uD = stars[N][0].average.uD; 225 catalog[0].average[n].duR = stars[N][0].average.duR; 226 catalog[0].average[n].duD = stars[N][0].average.duD; 227 catalog[0].average[n].P = stars[N][0].average.P; 228 catalog[0].average[n].dP = stars[N][0].average.dP; 229 catalog[0].average[n].Tmean = stars[N][0].average.Tmean; 230 } 179 off_t mOff = srccat->average[N].measureOffset; 180 for (mSrc = 0; mSrc < srccat->average[N].Nmeasure; mSrc++) { 181 /** in replace mode, search for entry and replace values M, dM, R, D */ 182 // XXX this fails for unsorted tgtcats, right? 183 if (options.replace && replace_match (&tgtcat[0].average[n], tgtcat[0].measure, &srccat->measure[mSrc + mOff], &srccat->found_t[N])) continue; 184 185 /* add to end of measurement list */ 186 add_meas_link (&tgtcat[0].average[n], next_meas, Nmeas, NMEAS); 187 188 // set the new measurements 189 tgtcat[0].measure[Nmeas] = srccat->measure[mSrc + mOff]; 190 191 // measure now carries R,D (not dR,dD) 192 tgtcat[0].measure[Nmeas].dbFlags = 0; 193 tgtcat[0].measure[Nmeas].averef = n; 194 tgtcat[0].measure[Nmeas].objID = tgtcat[0].average[n].objID; 195 tgtcat[0].measure[Nmeas].catID = tgtcat[0].catID; 196 197 float dRoff = dvoOffsetR(&tgtcat[0].measure[Nmeas], &tgtcat[0].average[n]); 198 199 // rationalize dR: 200 if (dRoff > +180.0*3600.0) { 201 // average on high end of boundary, move star up 202 tgtcat[0].measure[Nmeas].R += 360.0; 203 dRoff -= 360.0*3600.0; 204 } 205 if (dRoff < -180.0*3600.0) { 206 // average on low end of boundary, move star down 207 tgtcat[0].measure[Nmeas].R -= 360.0; 208 dRoff += 360.0*3600.0; 209 } 210 if (fabs(dRoff) > 10*RADIUS) { 211 // take declination into account and check again. 212 double cosD = cos(RAD_DEG*tgtcat[0].average[n].D); 213 if (fabs(dRoff*cosD) > 10*RADIUS) { 214 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 215 tgtcat[0].average[n].R, tgtcat[0].average[n].D, 216 srccat->average[N].R, srccat->average[N].D, 217 X1[i], X2[Jmin], 218 Y1[i], Y2[Jmin]); 219 // XXX abort on this? -- this is a bad failure... 220 } 221 } 222 223 // the reference data may not have per-object time specified 224 if (TIMEREF) { 225 tgtcat[0].measure[Nmeas].t = TIMEREF; 226 tgtcat[0].measure[Nmeas].t_msec = 0; 227 } 228 229 // we can choose to accept the proper-motion and parallax from the reference tgtcat 230 if (ACCEPT_MOTION) { 231 tgtcat[0].average[n].dR = srccat->average[N].dR; 232 tgtcat[0].average[n].dD = srccat->average[N].dD; 233 tgtcat[0].average[n].uR = srccat->average[N].uR; 234 tgtcat[0].average[n].uD = srccat->average[N].uD; 235 tgtcat[0].average[n].duR = srccat->average[N].duR; 236 tgtcat[0].average[n].duD = srccat->average[N].duD; 237 tgtcat[0].average[n].P = srccat->average[N].P; 238 tgtcat[0].average[n].dP = srccat->average[N].dP; 239 tgtcat[0].average[n].Tmean = srccat->average[N].Tmean; 240 } 231 241 232 242 /** don't update average / secfilt values for REF photcodes **/ 233 243 234 /*** handle multiple stars */ 235 /* this catalog star matches more than one image star */ 236 // XXX should this be an average flag? 237 if (catalog[0].found_t[n] > -1) { 238 catalog[0].measure[catalog[0].found_t[n]].dbFlags |= ID_MEAS_BLEND_OBJ; 239 catalog[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_OBJ; 240 } else { 241 catalog[0].found_t[n] = Nmeas; 242 } 243 244 stars[N][0].found = Nmeas; 245 catalog[0].average[n].Nmeasure ++; 246 Nmeas ++; 247 248 // make this optional: 249 // update_coords (&catalog[0].average[n], &catalog[0].measure[0], next_meas); 244 tgtcat[0].average[n].Nmeasure ++; 245 Nmeas ++; 246 } 247 248 srccat->found_t[N] = n; 249 tgtcat[0].found_t[n] = -1; 250 250 i++; 251 251 } 252 253 /*************** add unmatched stars *************************/ 252 254 253 255 /* Incorporate unmatched refcat stars. Skip this step if we want to … … 255 257 reference up-to-date with known stars only */ 256 258 257 for (i = 0; (i < Nstars) && !options.only_match; i+ =NREFSTAR_GROUP) {259 for (i = 0; (i < Nstars) && !options.only_match; i++) { 258 260 /* make sure there is space for next entry */ 259 if (Nmeas >= NMEAS - NREFSTAR_GROUP) {260 NMEAS = Nmeas + 1000 ;261 if (Nmeas >= NMEAS - srccat->average[i].Nmeasure) { 262 NMEAS = Nmeas + 1000 + srccat->average[i].Nmeasure; 261 263 REALLOCATE (next_meas, off_t, NMEAS); 262 REALLOCATE ( catalog[0].measure, Measure, NMEAS);264 REALLOCATE (tgtcat[0].measure, Measure, NMEAS); 263 265 } 264 266 if (Nave >= NAVE) { 265 267 NAVE = Nave + 1000; 266 REALLOCATE (catalog[0].average, Average, NAVE); 267 REALLOCATE (catalog[0].secfilt, SecFilt, NAVE*catalog[0].Nsecfilt); 268 } 269 270 N = N1[i]; 271 if (stars[N][0].found >= 0) continue; 272 if (!IN_REGION (stars[N][0].average.R, stars[N][0].average.D)) continue; 273 274 dvo_average_init (&catalog[0].average[Nave]); 275 catalog[0].average[Nave].R = stars[N][0].average.R; 276 catalog[0].average[Nave].D = stars[N][0].average.D; 277 278 catalog[0].average[Nave].Nmeasure = NREFSTAR_GROUP; 279 catalog[0].average[Nave].measureOffset = Nmeas; 280 catalog[0].average[Nave].objID = objID; 281 catalog[0].average[Nave].catID = catID; 268 REALLOCATE (tgtcat[0].average, Average, NAVE); 269 REALLOCATE (tgtcat[0].found_t, off_t, NAVE); 270 if (tgtcat[0].secfilt) { 271 // we only update the secfilt table if it has been allocated for output 272 REALLOCATE (tgtcat[0].secfilt, SecFilt, NAVE*tgtcat[0].Nsecfilt); 273 } 274 } 275 276 if (srccat->found_t[i] != -1) continue; 277 if (!IN_REGION (srccat->average[i].R, srccat->average[i].D)) continue; 278 279 dvo_average_init (&tgtcat[0].average[Nave]); 280 tgtcat[0].average[Nave].R = srccat->average[i].R; 281 tgtcat[0].average[Nave].D = srccat->average[i].D; 282 283 tgtcat[0].average[Nave].Nmeasure = srccat->average[i].Nmeasure; 284 tgtcat[0].average[Nave].measureOffset = Nmeas; 285 tgtcat[0].average[Nave].objID = objID; 286 tgtcat[0].average[Nave].catID = catID; 282 287 283 288 if (PSPS_ID) { 284 catalog[0].average[Nave].extID = CreatePSPSObjectID(catalog[0].average[Nave].R, catalog[0].average[Nave].D);289 tgtcat[0].average[Nave].extID = CreatePSPSObjectID(tgtcat[0].average[Nave].R, tgtcat[0].average[Nave].D); 285 290 } 286 291 287 292 if (ACCEPT_MOTION) { 288 catalog[0].average[Nave].dR = stars[N][0].average.dR;289 catalog[0].average[Nave].dD = stars[N][0].average.dD;290 catalog[0].average[Nave].uR = stars[N][0].average.uR;291 catalog[0].average[Nave].uD = stars[N][0].average.uD;292 catalog[0].average[Nave].duR = stars[N][0].average.duR;293 catalog[0].average[Nave].duD = stars[N][0].average.duD;294 catalog[0].average[Nave].P = stars[N][0].average.P;295 catalog[0].average[Nave].dP = stars[N][0].average.dP;296 catalog[0].average[Nave].Tmean = stars[N][0].average.Tmean;293 tgtcat[0].average[Nave].dR = srccat->average[i].dR; 294 tgtcat[0].average[Nave].dD = srccat->average[i].dD; 295 tgtcat[0].average[Nave].uR = srccat->average[i].uR; 296 tgtcat[0].average[Nave].uD = srccat->average[i].uD; 297 tgtcat[0].average[Nave].duR = srccat->average[i].duR; 298 tgtcat[0].average[Nave].duD = srccat->average[i].duD; 299 tgtcat[0].average[Nave].P = srccat->average[i].P; 300 tgtcat[0].average[Nave].dP = srccat->average[i].dP; 301 tgtcat[0].average[Nave].Tmean = srccat->average[i].Tmean; 297 302 } 298 303 … … 300 305 301 306 for (j = 0; j < Nsecfilt; j++) { 302 dvo_secfilt_init (&catalog[0].secfilt[Nave*Nsecfilt+j], SECFILT_RESET_ALL); 303 } 304 305 for (j = 0; j < NREFSTAR_GROUP; j++) { 306 N = N1[i + j]; 307 308 catalog[0].measure[Nmeas] = stars[N][0].measure; 309 catalog[0].measure[Nmeas].dbFlags = 0; 310 catalog[0].measure[Nmeas].averef = Nave; 311 catalog[0].measure[Nmeas].objID = catalog[0].average[Nave].objID; 312 catalog[0].measure[Nmeas].catID = catalog[0].catID; 313 314 catalog[0].measure[Nmeas].t = (stars[N][0].measure.t == 0) ? TIMEREF : stars[N][0].measure.t; /** careful : time_t vs e_time **/ 315 catalog[0].measure[Nmeas].t_msec = (stars[N][0].measure.t == 0) ? 0 : stars[N][0].measure.t_msec; /** careful : time_t vs e_time **/ 316 317 stars[N][0].found = Nmeas; 318 next_meas[Nmeas] = -1; 307 dvo_secfilt_init (&tgtcat[0].secfilt[Nave*Nsecfilt+j], SECFILT_RESET_ALL); 308 } 309 310 off_t mOff = srccat->average[i].measureOffset; 311 for (mSrc = 0; mSrc < srccat->average[i].Nmeasure; mSrc++) { 312 // supply the measurements from this detection 313 dvo_measure_init (&tgtcat[0].measure[Nmeas]); 314 tgtcat[0].measure[Nmeas] = srccat->measure[mSrc + mOff]; 315 316 // the following measure elements cannot be set until here: 317 tgtcat[0].measure[Nmeas].dbFlags = 0; 318 tgtcat[0].measure[Nmeas].averef = Nave; 319 tgtcat[0].measure[Nmeas].objID = tgtcat[0].average[Nave].objID; 320 tgtcat[0].measure[Nmeas].catID = tgtcat[0].catID; 321 322 if (TIMEREF) { 323 tgtcat[0].measure[Nmeas].t = TIMEREF; 324 tgtcat[0].measure[Nmeas].t_msec = 0; 325 } 326 319 327 Nmeas ++; 320 } 321 for (j = 0; j < NREFSTAR_GROUP - 1; j++) { 322 next_meas[Nmeas - NREFSTAR_GROUP + j] = Nmeas - NREFSTAR_GROUP + j + 1; 323 } 328 329 // update the next_meas pointer for this entry (last one for this star is -1) 330 next_meas[Nmeas-1] = (mSrc < srccat->average[i].Nmeasure - 1) ? Nmeas : -1; 331 } 332 srccat->found_t[i] = Nave; 324 333 Nave ++; 325 334 } 326 335 327 REALLOCATE ( catalog[0].average, Average, Nave);328 REALLOCATE ( catalog[0].measure, Measure, Nmeas);336 REALLOCATE (tgtcat[0].average, Average, Nave); 337 REALLOCATE (tgtcat[0].measure, Measure, Nmeas); 329 338 330 339 // XXX allow for unsorted output? 331 catalog[0].measure = sort_measure (catalog[0].average, Nave, catalog[0].measure, Nmeas, next_meas); 332 catalog[0].sorted = TRUE; 333 334 /* note stars which have been found in this catalog */ 335 for (i = 0; i < Nstars; i++) { 336 if (stars[i][0].found > -1) { 337 stars[i][0].found = -2; 338 } 339 } 340 341 catalog[0].objID = objID; // new max value, save on catalog close 342 catalog[0].Naverage = Nave; 343 catalog[0].Nmeasure = Nmeas; 344 catalog[0].Nsecfilt_mem = Nave*Nsecfilt; 340 tgtcat[0].measure = sort_measure (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas, next_meas); 341 tgtcat[0].sorted = TRUE; 342 343 /* note stars which have been found in this tgtcat */ 344 for (i = 0; i < srccat->Naverage; i++) { 345 if (srccat->found_t[i] > -1) { 346 srccat->found_t[i] = -2; 347 } 348 } 349 350 /* check if the tgtcat has changed? if no change, no need to write */ 351 tgtcat[0].objID = objID; // new max value, save on tgtcat close 352 tgtcat[0].Naverage = Nave; 353 tgtcat[0].Nmeasure = Nmeas; 354 tgtcat[0].Nsecfilt_mem = Nave*Nsecfilt; 345 355 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); 346 356 … … 348 358 free (Y1); 349 359 free (N1); 350 free (N2);351 360 free (X2); 352 361 free (Y2); 362 free (N2); 353 363 free (next_meas); 354 364 355 365 return (Nmatch); 356 366 } 367 368 /* differences with find_matches_closest(): 369 * accepts Stars **stars (vs Stars *stars) 370 * NREFSTAR_GROUP vs NSTAR_GROUP 371 * does not update lensing fields 372 * allows option to replace existing entries 373 * allows multiple photcodes 374 375 */ 376 -
trunk/Ohana/src/addstar/src/find_matches_refstars.c
r38467 r38986 1 1 # include "addstar.h" 2 2 3 int find_matches_refstars (SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options) { 4 5 off_t i, j, n, N, J; 3 // see bottom of this file for differences between find_matches_refstars.c and find_matches.c 4 int find_matches_refstars (SkyRegion *region, Catalog *srccat, Catalog *tgtcat, AddstarClientOptions options) { 5 6 off_t i, j, J, Nstars, mSrc; 6 7 double RADIUS, RADIUS2; 7 8 double *X1, *Y1, *X2, *Y2; 8 9 double dX, dY, dR; 9 off_t *N1, *N2 , *next_meas;10 off_t *N1, *N2; 10 11 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch; 11 12 unsigned int objID, catID; … … 13 14 int Nsecfilt; 14 15 15 switch (NREFSTAR_GROUP) {16 case 1:17 case 3:18 case 4:19 break;20 default:21 fprintf (stderr, "ERROR: NREFSTAR_GROUP NOT SET!\n");22 exit (1);23 }24 25 16 /* photcode data -- should not have to modify secfilt / average */ 26 17 Nsecfilt = GetPhotcodeNsecfilt (); 27 18 28 19 /** allocate local arrays (stars) **/ 29 ALLOCATE (X1, double, Nstars); 30 ALLOCATE (Y1, double, Nstars); 31 ALLOCATE (N1, off_t, Nstars); 32 33 /** allocate local arrays (catalog) **/ 34 Nave = catalog[0].Naverage; 35 NAVE = Nave + 1000; 20 ALLOCATE (X1, double, srccat->Naverage); 21 ALLOCATE (Y1, double, srccat->Naverage); 22 ALLOCATE (N1, off_t, srccat->Naverage); 23 24 myAbort ("figure out if found_t needs to be tracking Naverage or Nmeasure"); 25 if (!srccat->found_t) { 26 ALLOCATE (srccat->found_t, off_t, srccat->Naverage); 27 for (i = 0; i < srccat->Naverage; i++) { 28 srccat->found_t[i] = -1; 29 } 30 } 31 32 /** allocate local arrays (tgtcat) **/ 33 NAVE = Nave = tgtcat[0].Naverage; 36 34 ALLOCATE (X2, double, NAVE); 37 35 ALLOCATE (Y2, double, NAVE); 38 36 ALLOCATE (N2, off_t, NAVE); 39 ALLOCATE (catalog[0].found_t, off_t, NAVE); 40 REALLOCATE (catalog[0].average, Average, NAVE); 41 REALLOCATE (catalog[0].secfilt, SecFilt, NAVE*catalog[0].Nsecfilt); 37 38 if (!tgtcat->found_t) { 39 ALLOCATE (tgtcat[0].found_t, off_t, NAVE); 40 for (i = 0; i < NAVE; i++) { 41 tgtcat->found_t[i] = -1; 42 } 43 } 42 44 /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */ 43 45 46 /* internal counters */ 44 47 Nmatch = 0; 45 NMEAS = Nmeas = catalog[0].Nmeasure;48 NMEAS = Nmeas = tgtcat[0].Nmeasure; 46 49 47 // current max obj ID for this catalog 48 objID = catalog[0].objID; 49 catID = catalog[0].catID; 50 51 /* project onto rectilinear grid with 1 arcsec pixels, sort by X */ 52 /* reference for coords is catalog center */ 53 InitCoords (&tcoords, "DEC--ZEA"); 50 off_t *next_meas = NULL; 51 52 // current max obj ID for this tgtcat 53 objID = tgtcat[0].objID; 54 catID = tgtcat[0].catID; 55 56 /* project onto rectilinear grid with 1 arcsec pixels. the choice of ARC projection has 57 * the advantage that every point in R,D has a mapping to a unique X,Y. However, note 58 * that not all possible X,Y points map back to R,D and the local plate scale changes 59 * substantially far from the projection pole. We use the center of the region (tgtcat) 60 * for crval1,2. 61 */ 62 InitCoords (&tcoords, "DEC--ARC"); 54 63 tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax); 55 tcoords.crval2 = 0.5*(region[0].Dmin + region[0].Dmax); 64 if ((region[0].Dmax < 90) && (region[0].Dmin > -90)) { 65 tcoords.crval2 = 0.5*(region[0].Dmin + region[0].Dmax); 66 } else { 67 tcoords.crval2 = (region[0].Dmax >= 90) ? 90.0 : -90.0; 68 } 56 69 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 57 58 for (i = 0; i < Nstars; i++) { 59 RD_to_XY (&X1[i], &Y1[i], stars[i][0].average.R, stars[i][0].average.D, &tcoords); 60 N1[i] = i; 70 71 /* build spatial index (RA sort) referencing input array sequence */ 72 Nstars = 0; 73 for (i = 0; i < srccat->Naverage; i++) { 74 int status = RD_to_XY (&X1[Nstars], &Y1[Nstars], srccat->average[i].R, srccat->average[i].D, &tcoords); 75 if (!status) continue; 76 N1[Nstars] = i; 77 Nstars ++; 78 } 79 if (Nstars < 1) { 80 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", tgtcat[0].filename); 81 free (X1); 82 free (Y1); 83 free (N1); 84 free (X2); 85 free (Y2); 86 free (N2); 87 return (0); 61 88 } 62 89 if (Nstars > 1) sort_coords_index (X1, Y1, N1, Nstars); 63 90 91 /* build spatial index (RA sort) */ 64 92 for (i = 0; i < Nave; i++) { 65 RD_to_XY (&X2[i], &Y2[i], catalog[0].average[i].R, catalog[0].average[i].D, &tcoords);93 RD_to_XY (&X2[i], &Y2[i], tgtcat[0].average[i].R, tgtcat[0].average[i].D, &tcoords); 66 94 N2[i] = i; 67 catalog[0].found_t[N2[i]] = -1;95 tgtcat[0].found_t[N2[i]] = -1; 68 96 } 69 97 if (Nave > 1) sort_coords_index (X2, Y2, N2, Nave); 70 98 71 99 /* set up pointers for linked list of measurements */ 72 if ( catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeasure_disk)) {100 if (tgtcat[0].sorted && (tgtcat[0].Nmeasure == tgtcat[0].Nmeasure_disk)) { 73 101 // this version is only valid if we have done a full catalog load, and if the catalog 74 102 // is sorted while processed 75 next_meas = init_measure_links ( catalog[0].average, Nave, catalog[0].measure, Nmeas);103 next_meas = init_measure_links (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas); 76 104 } else { 77 next_meas = build_measure_links ( catalog[0].average, Nave, catalog[0].measure, Nmeas);105 next_meas = build_measure_links (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas); 78 106 } 79 107 80 /* choose a radius for matches */108 /* choose a radius for matches (defined in args.c or ImageOptions.c) */ 81 109 if (options.radius == 0) { 82 110 RADIUS = 2.0; /* hardwired default for refstars */ … … 86 114 RADIUS2 = RADIUS*RADIUS; 87 115 88 /** find matched stars**/89 // XXX could use NREFSTAR_GROUP to do this match more quicky 116 /****************** find matched stars ********************/ 117 90 118 for (i = j = 0; (i < Nstars) && (j < Nave); ) { 91 119 if (!finite(X1[i]) || !finite(Y1[i])) { … … 97 125 continue; 98 126 } 99 127 128 /* negative dX: j is too large */ 100 129 dX = X1[i] - X2[j]; 101 130 if (dX <= -1.02*RADIUS) { … … 103 132 continue; 104 133 } 134 /* positive dX, i is too large */ 105 135 if (dX >= 1.02*RADIUS) { 106 136 j++; … … 108 138 } 109 139 110 /* negative dX: j is too large, positive dX, i is too large*/140 /* within match range; look for matches */ 111 141 for (J = j; (dX > -1.02*RADIUS) && (J < Nave); J++) { 112 142 dX = X1[i] - X2[J]; … … 117 147 /*** a match is found, add to average, measure ***/ 118 148 Nmatch ++; 119 n = N2[J]; 120 N = N1[i]; 121 122 /** in replace mode, search for entry and replace values M, dM, R, D */ 123 if (options.replace && replace_match (&catalog[0].average[n], catalog[0].measure, stars[N])) continue; 124 125 if (Nmeas == NMEAS) { 126 NMEAS = Nmeas + 1000; 149 off_t n = N2[J]; 150 off_t N = N1[i]; 151 152 /* make sure there is space for next entry */ 153 if (Nmeas >= NMEAS - srccat->average[N].Nmeasure) { 154 NMEAS = Nmeas + 1000 + srccat->average[N].Nmeasure; 127 155 REALLOCATE (next_meas, off_t, NMEAS); 128 REALLOCATE ( catalog[0].measure, Measure, NMEAS);156 REALLOCATE (tgtcat[0].measure, Measure, NMEAS); 129 157 } 130 158 131 /* add to end of measurement list */ 132 add_meas_link (&catalog[0].average[n], next_meas, Nmeas, NMEAS); 159 /** add measurements for this star **/ 160 off_t mOff = srccat->average[N].measureOffset; 161 for (mSrc = 0; mSrc < srccat->average[N].Nmeasure; mSrc++) { 162 /** in replace mode, search for entry and replace values M, dM, R, D */ 163 if (options.replace && replace_match (&tgtcat[0].average[n], tgtcat[0].measure, &srccat->measure[mSrc + mOff], &srccat->found_t[N])) continue; 164 165 /* add to end of measurement list */ 166 add_meas_link (&tgtcat[0].average[n], next_meas, Nmeas, NMEAS); 133 167 134 /** add measurements for this star **/135 136 // set the new measurements137 catalog[0].measure[Nmeas] = stars[N][0].measure;138 139 /** measure now stores R,D **/ 140 catalog[0].measure[Nmeas].dbFlags = 0;141 catalog[0].measure[Nmeas].averef = n; 142 catalog[0].measure[Nmeas].objID = catalog[0].average[n].objID;143 catalog[0].measure[Nmeas].catID = catalog[0].catID;144 145 float dRoff = dvoOffsetR(&catalog[0].measure[Nmeas], &catalog[0].average[n]);146 147 // rationalize dR:148 if (dRoff > +180.0*3600.0) {168 /** add measurements for this star **/ 169 170 // set the new measurements 171 tgtcat[0].measure[Nmeas] = srccat->measure[mSrc + mOff]; 172 173 // the following measure elements cannot be set until here: 174 tgtcat[0].measure[Nmeas].dbFlags = 0; 175 tgtcat[0].measure[Nmeas].averef = n; // this must be an absolute sequence number, if partial average is loaded 176 tgtcat[0].measure[Nmeas].objID = tgtcat[0].average[n].objID; 177 tgtcat[0].measure[Nmeas].catID = tgtcat[0].catID; 178 179 float dRoff = dvoOffsetR(&tgtcat[0].measure[Nmeas], &tgtcat[0].average[n]); 180 181 // rationalize R: 182 if (dRoff > +180.0*3600.0) { 149 183 // average on high end of boundary, move star up 150 catalog[0].measure[Nmeas].R += 360.0;184 tgtcat[0].measure[Nmeas].R += 360.0; 151 185 dRoff -= 360.0*3600.0; 186 } 187 if (dRoff < -180.0*3600.0) { 188 // average on low end of boundary, move star down 189 tgtcat[0].measure[Nmeas].R -= 360.0; 190 dRoff += 360.0*3600.0; 191 } 192 if (fabs(dRoff) > 10*RADIUS) { 193 // take declination into account and check again. 194 double cosD = cos(RAD_DEG*tgtcat[0].average[n].D); 195 if (fabs(dRoff*cosD) > 10*RADIUS) { 196 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 197 tgtcat[0].average[n].R, tgtcat[0].average[n].D, 198 srccat->average[N].R, srccat->average[N].D, 199 X1[i], X2[J], 200 Y1[i], Y2[J]); 201 } 202 } 203 204 if (TIMEREF) { 205 tgtcat[0].measure[Nmeas].t = TIMEREF; /** careful : time_t vs e_time **/ 206 tgtcat[0].measure[Nmeas].t_msec = 0; 207 } 208 209 if (ACCEPT_MOTION) { 210 tgtcat[0].average[n].uR = srccat->average[N].uR; 211 tgtcat[0].average[n].uD = srccat->average[N].uD; 212 tgtcat[0].average[n].duR = srccat->average[N].duR; 213 tgtcat[0].average[n].duD = srccat->average[N].duD; 214 tgtcat[0].average[n].P = srccat->average[N].P; 215 tgtcat[0].average[n].dP = srccat->average[N].dP; 216 } 217 218 /** don't update average / secfilt values for REF photcodes **/ 219 220 myAbort ("fix logic on multiple detections"); 221 222 /*** flag multiple stars */ 223 /* this image star matches more than one tgtcat star */ 224 if (srccat->found_t[N] > -1) { 225 tgtcat[0].measure[srccat->found_t[N]].dbFlags |= ID_MEAS_BLEND_MEAS; 226 tgtcat[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_MEAS; 227 } 228 if (srccat->found_t[N] == -2) { /* this image star matches a tgtcat star on a neighboring tgtcat */ 229 tgtcat[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_MEAS_X; 230 } 231 if (srccat->found_t[N] == -1) { /* this image star matches only this tgtcat star */ 232 srccat->found_t[N] = Nmeas; /* save first match, in case coincidences are found */ 233 } 234 /* this tgtcat star matches more than one image star */ 235 if (tgtcat[0].found_t[n] > -1) { 236 tgtcat[0].measure[tgtcat[0].found_t[n]].dbFlags |= ID_MEAS_BLEND_OBJ; 237 tgtcat[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_OBJ; 238 } else { 239 tgtcat[0].found_t[n] = Nmeas; 240 } 241 tgtcat[0].average[n].Nmeasure ++; 242 Nmeas ++; 152 243 } 153 if (dRoff < -180.0*3600.0) { 154 // average on low end of boundary, move star down 155 catalog[0].measure[Nmeas].R -= 360.0; 156 dRoff += 360.0*3600.0; 157 } 158 159 catalog[0].measure[Nmeas].t = (TIMEREF == 0) ? stars[N][0].measure.t : TIMEREF; /** careful : time_t vs e_time **/ 160 catalog[0].measure[Nmeas].t_msec = (TIMEREF == 0) ? stars[N][0].measure.t_msec : TIMEREF; /** careful : time_t vs e_time **/ 161 162 if (ACCEPT_MOTION) { 163 catalog[0].average[n].uR = stars[N][0].average.uR; 164 catalog[0].average[n].uD = stars[N][0].average.uD; 165 catalog[0].average[n].duR = stars[N][0].average.duR; 166 catalog[0].average[n].duD = stars[N][0].average.duD; 167 catalog[0].average[n].P = stars[N][0].average.P; 168 catalog[0].average[n].dP = stars[N][0].average.dP; 169 } 170 171 /** don't update average / secfilt values for REF photcodes **/ 172 173 /*** handle multiple stars */ 174 /* this image star matches more than one catalog star */ 175 if (stars[N][0].found > -1) { 176 catalog[0].measure[stars[N][0].found].dbFlags |= ID_MEAS_BLEND_MEAS; 177 catalog[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_MEAS; 178 } 179 if (stars[N][0].found == -2) { /* this image star matches a catalog star on a neighboring catalog */ 180 catalog[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_MEAS_X; 181 } 182 if (stars[N][0].found == -1) { /* this image star matches only this catalog star */ 183 stars[N][0].found = Nmeas; /* save first match, in case coincidences are found */ 184 } 185 /* this catalog star matches more than one image star */ 186 if (catalog[0].found_t[n] > -1) { 187 catalog[0].measure[catalog[0].found_t[n]].dbFlags |= ID_MEAS_BLEND_OBJ; 188 catalog[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_OBJ; 189 } else { 190 catalog[0].found_t[n] = Nmeas; 191 } 192 193 catalog[0].average[n].Nmeasure ++; 194 Nmeas ++; 195 196 // update_coords (&catalog[0].average[n], &catalog[0].measure[0], next_meas); 244 245 // update_coords (&tgtcat[0].average[n], &tgtcat[0].measure[0], next_meas); 197 246 } 198 247 i++; 199 248 } 200 201 /* we don't add missed entries for refcat202 (already in database, not refcat) */203 249 204 250 /* incorporate unmatched refcat stars */ … … 207 253 the reference up-to-date with known stars only */ 208 254 209 for (i = 0; (i < Nstars) && !options.only_match; i+=NREFSTAR_GROUP) { 210 if (Nmeas >= NMEAS - NREFSTAR_GROUP) { 211 NMEAS = Nmeas + 1000; 255 for (i = 0; (i < Nstars) && !options.only_match; i++) { 256 /* make sure there is space for next entry */ 257 if (Nmeas >= NMEAS - srccat->average[i].Nmeasure) { 258 NMEAS = Nmeas + 1000 + srccat->average[i].Nmeasure; 212 259 REALLOCATE (next_meas, off_t, NMEAS); 213 REALLOCATE ( catalog[0].measure, Measure, NMEAS);214 } 215 if (Nave == NAVE) {260 REALLOCATE (tgtcat[0].measure, Measure, NMEAS); 261 } 262 if (Nave >= NAVE) { 216 263 NAVE = Nave + 1000; 217 REALLOCATE (catalog[0].average, Average, NAVE); 218 REALLOCATE (catalog[0].secfilt, SecFilt, NAVE*catalog[0].Nsecfilt); 219 } 220 221 N = i; 222 if (stars[N][0].found > -1) continue; 223 if (!IN_REGION (stars[N][0].average.R, stars[N][0].average.D)) continue; 224 225 dvo_average_init (&catalog[0].average[Nave]); 226 catalog[0].average[Nave].R = stars[N][0].average.R; 227 catalog[0].average[Nave].D = stars[N][0].average.D; 228 229 catalog[0].average[Nave].Nmeasure = NREFSTAR_GROUP; 230 catalog[0].average[Nave].measureOffset = Nmeas; 231 catalog[0].average[Nave].objID = objID; 232 catalog[0].average[Nave].catID = catID; 264 REALLOCATE (tgtcat[0].average, Average, NAVE); 265 if (tgtcat[0].secfilt) { 266 // we only update the secfilt table if it has been allocated for output 267 REALLOCATE (tgtcat[0].secfilt, SecFilt, NAVE*tgtcat[0].Nsecfilt); 268 } 269 } 270 271 if (srccat->found_t[i] >= 0) continue; 272 if (!IN_REGION (srccat->average[i].R, srccat->average[i].D)) continue; 273 274 dvo_average_init (&tgtcat[0].average[Nave]); 275 tgtcat[0].average[Nave].R = srccat->average[i].R; 276 tgtcat[0].average[Nave].D = srccat->average[i].D; 277 278 tgtcat[0].average[Nave].Nmeasure = srccat->average[i].Nmeasure; 279 tgtcat[0].average[Nave].measureOffset = Nmeas; 280 tgtcat[0].average[Nave].objID = objID; 281 tgtcat[0].average[Nave].catID = catID; 233 282 234 283 if (PSPS_ID) { 235 catalog[0].average[Nave].extID = CreatePSPSObjectID(catalog[0].average[Nave].R, catalog[0].average[Nave].D);284 tgtcat[0].average[Nave].extID = CreatePSPSObjectID(tgtcat[0].average[Nave].R, tgtcat[0].average[Nave].D); 236 285 } 237 286 238 287 if (ACCEPT_MOTION) { 239 catalog[0].average[Nave].dR = stars[N][0].average.dR;240 catalog[0].average[Nave].dD = stars[N][0].average.dD;241 catalog[0].average[Nave].uR = stars[N][0].average.uR;242 catalog[0].average[Nave].uD = stars[N][0].average.uD;243 catalog[0].average[Nave].duR = stars[N][0].average.duR;244 catalog[0].average[Nave].duD = stars[N][0].average.duD;245 catalog[0].average[Nave].P = stars[N][0].average.P;246 catalog[0].average[Nave].dP = stars[N][0].average.dP;288 tgtcat[0].average[Nave].dR = srccat->average[i].dR; 289 tgtcat[0].average[Nave].dD = srccat->average[i].dD; 290 tgtcat[0].average[Nave].uR = srccat->average[i].uR; 291 tgtcat[0].average[Nave].uD = srccat->average[i].uD; 292 tgtcat[0].average[Nave].duR = srccat->average[i].duR; 293 tgtcat[0].average[Nave].duD = srccat->average[i].duD; 294 tgtcat[0].average[Nave].P = srccat->average[i].P; 295 tgtcat[0].average[Nave].dP = srccat->average[i].dP; 247 296 } 248 297 249 298 objID ++; 250 299 251 for (j = 0; j < Nsecfilt; j++) { 252 dvo_secfilt_init (&catalog[0].secfilt[Nave*Nsecfilt+j], SECFILT_RESET_ALL); 253 } 254 255 for (j = 0; j < NREFSTAR_GROUP; j++) { 256 N = i + j; 257 258 catalog[0].measure[Nmeas] = stars[N][0].measure; 259 260 catalog[0].measure[Nmeas].t = (stars[N][0].measure.t == 0) ? TIMEREF : stars[N][0].measure.t; /** careful : time_t vs e_time **/ 261 catalog[0].measure[Nmeas].t_msec = (stars[N][0].measure.t == 0) ? 0 : stars[N][0].measure.t_msec; /** careful : time_t vs e_time **/ 262 catalog[0].measure[Nmeas].dbFlags = 0; 263 catalog[0].measure[Nmeas].averef = Nave; 264 catalog[0].measure[Nmeas].objID = catalog[0].average[Nave].objID; 265 catalog[0].measure[Nmeas].catID = catalog[0].catID; 266 267 stars[N][0].found = Nmeas; 268 next_meas[Nmeas] = -1; // initial value here, update below 269 Nmeas ++; 270 } 271 272 for (j = 0; j < NREFSTAR_GROUP - 1; j++) { 273 next_meas[Nmeas - NREFSTAR_GROUP + j] = Nmeas - NREFSTAR_GROUP + j + 1; 300 for (j = 0; tgtcat[0].secfilt && (j < Nsecfilt); j++) { 301 dvo_secfilt_init (&tgtcat[0].secfilt[Nave*Nsecfilt+j], SECFILT_RESET_ALL); 302 } 303 304 off_t mOff = srccat->average[i].measureOffset; 305 for (mSrc = 0; mSrc < srccat->average[i].Nmeasure; mSrc++) { 306 // supply the measurments from this detection 307 dvo_measure_init (&tgtcat[0].measure[Nmeas]); 308 tgtcat[0].measure[Nmeas] = srccat->measure[mSrc + mOff]; 309 310 // the following measure elements cannot be set until here: 311 tgtcat[0].measure[Nmeas].dbFlags = 0; 312 tgtcat[0].measure[Nmeas].averef = Nave; // XXX EAM : must be absolute Nave if partial read 313 tgtcat[0].measure[Nmeas].objID = tgtcat[0].average[Nave].objID; 314 tgtcat[0].measure[Nmeas].catID = tgtcat[0].catID; 315 316 if (TIMEREF) { 317 tgtcat[0].measure[Nmeas].t = TIMEREF; 318 tgtcat[0].measure[Nmeas].t_msec = 0; 319 } 320 321 /* next[Nmeas] should always be -1 in this context (it is always the only 322 measurement for the star) */ 323 srccat->found_t[i] = Nmeas; 324 Nmeas ++; 325 326 // update the next_meas pointer for this entry (last one for this star is -1) 327 next_meas[Nmeas-1] = (mSrc < srccat->average[i].Nmeasure - 1) ? Nmeas : -1; 274 328 } 275 329 Nave ++; 276 330 } 277 331 278 REALLOCATE (catalog[0].average, Average, Nave); 332 REALLOCATE (tgtcat[0].average, Average, Nave); 333 REALLOCATE (tgtcat[0].measure, Measure, Nmeas); 279 334 280 335 // XXX allow for unsorted output? 281 catalog[0].measure = sort_measure (catalog[0].average, Nave, catalog[0].measure, Nmeas, next_meas); 282 283 /* note stars which have been found in this catalog */ 284 for (i = 0; i < Nstars; i++) { 285 if (stars[i][0].found > -1) { 286 stars[i][0].found = -2; 287 } else { 288 stars[i][0].found = -3; 289 } 290 } 291 292 catalog[0].objID = objID; // new max value, save on catalog close 293 catalog[0].Naverage = Nave; 294 catalog[0].Nmeasure = Nmeas; 295 catalog[0].Nsecfilt_mem = Nave*Nsecfilt; 296 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %d "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas, Nmatch); 336 tgtcat[0].measure = sort_measure (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas, next_meas); 337 338 /* note stars which have been found in this tgtcat */ 339 for (i = 0; i < srccat->Nmeasure; i++) { 340 if (srccat->found_t[i] > -1) { 341 srccat->found_t[i] = -2; 342 } 343 } 344 345 tgtcat[0].objID = objID; // new max value, save on tgtcat close 346 tgtcat[0].Naverage = Nave; 347 tgtcat[0].Nmeasure = Nmeas; 348 tgtcat[0].Nsecfilt_mem = Nave*Nsecfilt; 349 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); 297 350 298 351 free (X1); … … 306 359 return (Nmatch); 307 360 } 361 362 /** differences between find_matches_refstars.c and find_matches.c: 363 * refstars has replace_match 364 * refstars has TIMEREF and ACCEPT_MOTION 365 * refstars does NOT have AddToCalibration 366 * refstars does NOT have Nsec 367 * refstars does NOT do update_coords 368 **/ -
trunk/Ohana/src/addstar/src/find_matches_starpar.c
r38636 r38986 131 131 132 132 /** add starpar for this star **/ 133 134 // set the new starparments 135 catalog[0].starpar[Nstarpar] = stars[N].starpar; 136 catalog[0].starpar[Nstarpar].averef = n; 137 catalog[0].starpar[Nstarpar].objID = catalog[0].average[n].objID; 138 catalog[0].starpar[Nstarpar].catID = catID; 139 140 // NOTE: include R,D in starpar? 141 // XXX if I add R,D to starpar, I should rationalize R,D to the same boundary? 142 133 off_t m; 134 if (options->replace && catalog[0].average[n].Nstarpar) { 135 m = catalog[0].average[n].starparOffset; 136 } else { 137 m = Nstarpar; 138 catalog[0].average[n].starparOffset = m; 139 catalog[0].average[n].Nstarpar ++; 140 Nstarpar ++; 141 } 142 catalog[0].starpar[m] = stars[N].starpar; 143 catalog[0].starpar[m].averef = n; 144 catalog[0].starpar[m].objID = catalog[0].average[n].objID; 145 catalog[0].starpar[m].catID = catID; 143 146 stars[N].found = TRUE; 144 catalog[0].average[n].Nstarpar ++;145 Nstarpar ++;146 147 i++; 147 148 } -
trunk/Ohana/src/addstar/src/get2mass_full.c
r34088 r38986 6 6 // fill in the data for a JHK triplet star. takes a pointer to the start of the line the 7 7 // RA and DEC have already been set 8 int get2mass_3star_full ( Stars **star, char *line, int Nmax) {8 int get2mass_3star_full (Measure *measure, char *line, int Nmax) { 9 9 10 10 char *ptr; … … 17 17 ptr = next2MASSfield (ptr); // dec (assumed to be already set) 18 18 ptr = next2MASSfield (ptr); // err_maj 19 star[0][0].measure.FWx = ToShortPixels(strtod (ptr, NULL));19 measure[0].FWx = ToShortPixels(strtod (ptr, NULL)); 20 20 ptr = next2MASSfield (ptr); // err_min 21 star[0][0].measure.FWy = ToShortPixels(strtod (ptr, NULL));21 measure[0].FWy = ToShortPixels(strtod (ptr, NULL)); 22 22 ptr = next2MASSfield (ptr); // err_ang 23 star[0][0].measure.theta = ToShortPixels(strtod (ptr, NULL));24 25 star[2][0].measure.FWx = star[1][0].measure.FWx = star[0][0].measure.FWx;26 star[2][0].measure.FWy = star[1][0].measure.FWy = star[0][0].measure.FWy;27 star[2][0].measure.theta = star[1][0].measure.theta = star[0][0].measure.theta;23 measure[0].theta = ToShortPixels(strtod (ptr, NULL)); 24 25 measure[2].FWx = measure[1].FWx = measure[0].FWx; 26 measure[2].FWy = measure[1].FWy = measure[0].FWy; 27 measure[2].theta = measure[1].theta = measure[0].theta; 28 28 29 29 ptr = next2MASSfield (ptr); // designation (skip) 30 30 31 31 ptr = next2MASSfield (ptr); // j_m 32 star[0][0].measure.M = strtod (ptr, NULL);32 measure[0].M = strtod (ptr, NULL); 33 33 ptr = next2MASSfield (ptr); // j_cmsig 34 star[0][0].measure.dM = strtod (ptr, NULL);34 measure[0].dM = strtod (ptr, NULL); 35 35 ptr = next2MASSfield (ptr); // j_msigcom 36 36 dMfull = strtod (ptr, NULL); 37 star[0][0].measure.dMcal = sqrt (SQ(dMfull) - SQ(star[0][0].measure.dM));37 measure[0].dMcal = sqrt (SQ(dMfull) - SQ(measure[0].dM)); 38 38 ptr = next2MASSfield (ptr); // j_snr (skip) 39 39 40 40 ptr = next2MASSfield (ptr); // h_m 41 star[1][0].measure.M = strtod (ptr, NULL);41 measure[1].M = strtod (ptr, NULL); 42 42 ptr = next2MASSfield (ptr); // h_cmsig 43 star[1][0].measure.dM = strtod (ptr, NULL);43 measure[1].dM = strtod (ptr, NULL); 44 44 ptr = next2MASSfield (ptr); // h_msigcom 45 45 dMfull = strtod (ptr, NULL); 46 star[1][0].measure.dMcal = sqrt (SQ(dMfull) - SQ(star[1][0].measure.dM));46 measure[1].dMcal = sqrt (SQ(dMfull) - SQ(measure[1].dM)); 47 47 ptr = next2MASSfield (ptr); // h_snr (skip) 48 48 49 49 ptr = next2MASSfield (ptr); // k_m 50 star[2][0].measure.M = strtod (ptr, NULL);50 measure[2].M = strtod (ptr, NULL); 51 51 ptr = next2MASSfield (ptr); // k_cmsig 52 star[2][0].measure.dM = strtod (ptr, NULL);52 measure[2].dM = strtod (ptr, NULL); 53 53 ptr = next2MASSfield (ptr); // k_msigcom 54 54 dMfull = strtod (ptr, NULL); 55 star[2][0].measure.dMcal = sqrt (SQ(dMfull) - SQ(star[2][0].measure.dM));55 measure[2].dMcal = sqrt (SQ(dMfull) - SQ(measure[2].dM)); 56 56 ptr = next2MASSfield (ptr); // k_snr (skip) 57 57 58 star[2][0].measure.photFlags = star[1][0].measure.photFlags = star[0][0].measure.photFlags = 0;58 measure[2].photFlags = measure[1].photFlags = measure[0].photFlags = 0; 59 59 60 60 ptr = next2MASSfield (ptr); // ph_qual 61 set2MASS_ph_qual ( star[0], ptr[0]);62 set2MASS_ph_qual ( star[1], ptr[1]);63 set2MASS_ph_qual ( star[2], ptr[2]);61 set2MASS_ph_qual (&measure[0], ptr[0]); 62 set2MASS_ph_qual (&measure[1], ptr[1]); 63 set2MASS_ph_qual (&measure[2], ptr[2]); 64 64 65 65 ptr = next2MASSfield (ptr); // rd_flg 66 set2MASS_rd_flag ( star[0], ptr[0]);67 set2MASS_rd_flag ( star[1], ptr[1]);68 set2MASS_rd_flag ( star[2], ptr[2]);66 set2MASS_rd_flag (&measure[0], ptr[0]); 67 set2MASS_rd_flag (&measure[1], ptr[1]); 68 set2MASS_rd_flag (&measure[2], ptr[2]); 69 69 70 70 ptr = next2MASSfield (ptr); // bl_flg 71 set2MASS_bl_flag ( star[0], ptr[0]);72 set2MASS_bl_flag ( star[1], ptr[1]);73 set2MASS_bl_flag ( star[2], ptr[2]);71 set2MASS_bl_flag (&measure[0], ptr[0]); 72 set2MASS_bl_flag (&measure[1], ptr[1]); 73 set2MASS_bl_flag (&measure[2], ptr[2]); 74 74 75 75 ptr = next2MASSfield (ptr); // cc_flg 76 set2MASS_cc_flag ( star[0], ptr[0]);77 set2MASS_cc_flag ( star[1], ptr[1]);78 set2MASS_cc_flag ( star[2], ptr[2]);76 set2MASS_cc_flag (&measure[0], ptr[0]); 77 set2MASS_cc_flag (&measure[1], ptr[1]); 78 set2MASS_cc_flag (&measure[2], ptr[2]); 79 79 80 80 ptr = next2MASSfield (ptr); // ndet (skip for now, XXX use somehow?) … … 84 84 85 85 ptr = next2MASSfield (ptr); // gal_contam (one flag for all filters) 86 set2MASS_gal_flag ( star[0], ptr[0]);87 set2MASS_gal_flag ( star[1], ptr[0]);88 set2MASS_gal_flag ( star[2], ptr[0]);86 set2MASS_gal_flag (&measure[0], ptr[0]); 87 set2MASS_gal_flag (&measure[1], ptr[0]); 88 set2MASS_gal_flag (&measure[2], ptr[0]); 89 89 90 90 ptr = next2MASSfield (ptr); // mp_flg (one flag for all filters) 91 set2MASS_mp_flag ( star[0], ptr[0]);92 set2MASS_mp_flag ( star[1], ptr[0]);93 set2MASS_mp_flag ( star[2], ptr[0]);91 set2MASS_mp_flag (&measure[0], ptr[0]); 92 set2MASS_mp_flag (&measure[1], ptr[0]); 93 set2MASS_mp_flag (&measure[2], ptr[0]); 94 94 95 95 ptr = next2MASSfield (ptr); // pts_key (skip for now, XXX use somehow?) … … 101 101 102 102 ptr = next2MASSfield (ptr); // x_scan 103 star[0][0].measure.Xccd = strtod (ptr, NULL);104 star[2][0].measure.Xccd = star[1][0].measure.Xccd = star[0][0].measure.Xccd;103 measure[0].Xccd = strtod (ptr, NULL); 104 measure[2].Xccd = measure[1].Xccd = measure[0].Xccd; 105 105 106 106 ptr = next2MASSfield (ptr); // jdate (julian date) 107 107 jd = strtod (ptr, NULL); 108 star[0][0].measure.t = ohana_jd_to_sec (jd);109 star[2][0].measure.t = star[1][0].measure.t = star[0][0].measure.t;108 measure[0].t = ohana_jd_to_sec (jd); 109 measure[2].t = measure[1].t = measure[0].t; 110 110 111 111 ptr = next2MASSfield (ptr); // j_psfchi 112 star[0][0].measure.psfChisq = strtod (ptr, NULL);112 measure[0].psfChisq = strtod (ptr, NULL); 113 113 ptr = next2MASSfield (ptr); // h_psfchi 114 star[1][0].measure.psfChisq = strtod (ptr, NULL);114 measure[1].psfChisq = strtod (ptr, NULL); 115 115 ptr = next2MASSfield (ptr); // k_psfchi 116 star[2][0].measure.psfChisq = strtod (ptr, NULL);116 measure[2].psfChisq = strtod (ptr, NULL); 117 117 118 118 ptr = next2MASSfield (ptr); // j_m_stdap 119 star[0][0].measure.Map = strtod (ptr, NULL);119 measure[0].Map = strtod (ptr, NULL); 120 120 ptr = next2MASSfield (ptr); // j_msig_stdap (skip?) 121 121 122 122 ptr = next2MASSfield (ptr); // h_m_stdap 123 star[1][0].measure.Map = strtod (ptr, NULL);123 measure[1].Map = strtod (ptr, NULL); 124 124 ptr = next2MASSfield (ptr); // h_msig_stdap (skip?) 125 125 126 126 ptr = next2MASSfield (ptr); // k_m_stdap 127 star[2][0].measure.Map = strtod (ptr, NULL);127 measure[2].Map = strtod (ptr, NULL); 128 128 ptr = next2MASSfield (ptr); // k_msig_stdap (skip?) 129 129 … … 133 133 134 134 ptr = next2MASSfield (ptr); // dup_src (one flag for all filters) 135 set2MASS_dup_flag ( star[0], ptr[0]);136 set2MASS_dup_flag ( star[1], ptr[0]);137 set2MASS_dup_flag ( star[2], ptr[0]);135 set2MASS_dup_flag (&measure[0], ptr[0]); 136 set2MASS_dup_flag (&measure[1], ptr[0]); 137 set2MASS_dup_flag (&measure[2], ptr[0]); 138 138 139 139 ptr = next2MASSfield (ptr); // use_src (one flag for all filters) 140 set2MASS_use_flag ( star[0], ptr[0]);141 set2MASS_use_flag ( star[1], ptr[0]);142 set2MASS_use_flag ( star[2], ptr[0]);143 144 star[0][0].measure.photcode = TM_J;145 star[0][0].measure.detID = 0;146 star[0][0].measure.imageID = 0;147 148 star[1][0].measure.photcode = TM_H;149 star[1][0].measure.detID = 0;150 star[1][0].measure.imageID = 0;151 152 star[2][0].measure.photcode = TM_K;153 star[2][0].measure.detID = 0;154 star[2][0].measure.imageID = 0;140 set2MASS_use_flag (&measure[0], ptr[0]); 141 set2MASS_use_flag (&measure[1], ptr[0]); 142 set2MASS_use_flag (&measure[2], ptr[0]); 143 144 measure[0].photcode = TM_J; 145 measure[0].detID = 0; 146 measure[0].imageID = 0; 147 148 measure[1].photcode = TM_H; 149 measure[1].detID = 0; 150 measure[1].imageID = 0; 151 152 measure[2].photcode = TM_K; 153 measure[2].detID = 0; 154 measure[2].imageID = 0; 155 155 156 156 return TRUE; … … 170 170 } 171 171 172 int set2MASS_ph_qual ( Stars *star, char qual) {173 174 switch (qual) { 175 case 'A': star[0].measure.photFlags |= 0x00000001; break; // was: 0x0004176 case 'B': star[0].measure.photFlags |= 0x00000002; break; // was: 0x0005177 case 'C': star[0].measure.photFlags |= 0x00000004; break; // was: 0x0006178 case 'D': star[0].measure.photFlags |= 0x00000008; break; // was: 0x0007179 case 'E': star[0].measure.photFlags |= 0x00000010; break; // was: 0x0003180 case 'F': star[0].measure.photFlags |= 0x00000020; break; // was: 0x0002181 case 'U': star[0].measure.photFlags |= 0x00000040; break; // was: 0x0001182 case 'X': star[0].measure.photFlags |= 0x00000080; break; // was: 0x0000172 int set2MASS_ph_qual (Measure *measure, char qual) { 173 174 switch (qual) { 175 case 'A': measure[0].photFlags |= 0x00000001; break; // was: 0x0004 176 case 'B': measure[0].photFlags |= 0x00000002; break; // was: 0x0005 177 case 'C': measure[0].photFlags |= 0x00000004; break; // was: 0x0006 178 case 'D': measure[0].photFlags |= 0x00000008; break; // was: 0x0007 179 case 'E': measure[0].photFlags |= 0x00000010; break; // was: 0x0003 180 case 'F': measure[0].photFlags |= 0x00000020; break; // was: 0x0002 181 case 'U': measure[0].photFlags |= 0x00000040; break; // was: 0x0001 182 case 'X': measure[0].photFlags |= 0x00000080; break; // was: 0x0000 183 183 default: 184 184 fprintf (stderr, "error!\n"); … … 188 188 } 189 189 190 int set2MASS_rd_flag ( Stars *star, char qual) {191 192 switch (qual) { 193 case '0': star[0].measure.photFlags |= 0x00000100; break; // was: 0x0000194 case '1': star[0].measure.photFlags |= 0x00000200; break; // was: 0x0010195 case '2': star[0].measure.photFlags |= 0x00000400; break; // was: 0x0020196 case '3': star[0].measure.photFlags |= 0x00000800; break; // was: 0x0030197 case '4': star[0].measure.photFlags |= 0x00001000; break; // was: 0x0040198 case '6': star[0].measure.photFlags |= 0x00002000; break; // was: 0x0050199 case '9': star[0].measure.photFlags |= 0x00004000; break; // was: 0x0060190 int set2MASS_rd_flag (Measure *measure, char qual) { 191 192 switch (qual) { 193 case '0': measure[0].photFlags |= 0x00000100; break; // was: 0x0000 194 case '1': measure[0].photFlags |= 0x00000200; break; // was: 0x0010 195 case '2': measure[0].photFlags |= 0x00000400; break; // was: 0x0020 196 case '3': measure[0].photFlags |= 0x00000800; break; // was: 0x0030 197 case '4': measure[0].photFlags |= 0x00001000; break; // was: 0x0040 198 case '6': measure[0].photFlags |= 0x00002000; break; // was: 0x0050 199 case '9': measure[0].photFlags |= 0x00004000; break; // was: 0x0060 200 200 default: 201 201 fprintf (stderr, "error!\n"); … … 205 205 } 206 206 207 int set2MASS_cc_flag ( Stars *star, char qual) {208 209 switch (qual) { 210 case 'p': star[0].measure.photFlags |= 0x00010000; break; // was: 0x0000211 case 'c': star[0].measure.photFlags |= 0x00020000; break; // was: 0x0100212 case 'd': star[0].measure.photFlags |= 0x00040000; break; // was: 0x0200213 case 's': star[0].measure.photFlags |= 0x00080000; break; // was: 0x0300214 case 'b': star[0].measure.photFlags |= 0x00010000; break; // was: 0x0400215 case '0': star[0].measure.photFlags |= 0x00020000; break; // was: 0x0500207 int set2MASS_cc_flag (Measure *measure, char qual) { 208 209 switch (qual) { 210 case 'p': measure[0].photFlags |= 0x00010000; break; // was: 0x0000 211 case 'c': measure[0].photFlags |= 0x00020000; break; // was: 0x0100 212 case 'd': measure[0].photFlags |= 0x00040000; break; // was: 0x0200 213 case 's': measure[0].photFlags |= 0x00080000; break; // was: 0x0300 214 case 'b': measure[0].photFlags |= 0x00010000; break; // was: 0x0400 215 case '0': measure[0].photFlags |= 0x00020000; break; // was: 0x0500 216 216 default: 217 217 fprintf (stderr, "error!\n"); … … 221 221 } 222 222 223 int set2MASS_bl_flag ( Stars *star, char qual) {224 225 switch (qual) { 226 case '0': star[0].measure.photFlags &= ~0x00300000; break; // was: ~0x0008227 case '1': star[0].measure.photFlags |= 0x00100000; break; // was: ~0x0008228 default: star[0].measure.photFlags |= 0x00200000; break; // was: 0x0008229 } 230 return (TRUE); 231 } 232 233 int set2MASS_gal_flag ( Stars *star, char qual) {234 235 switch (qual) { 236 case '0': star[0].measure.photFlags &= ~0x00c00000; break; // was: ~0x0080237 case '1': star[0].measure.photFlags |= 0x00400000; break; // was: ~0x0080238 default: star[0].measure.photFlags |= 0x00800000; // was: 0x0080239 star[0].measure.extNsigma = 100.0;223 int set2MASS_bl_flag (Measure *measure, char qual) { 224 225 switch (qual) { 226 case '0': measure[0].photFlags &= ~0x00300000; break; // was: ~0x0008 227 case '1': measure[0].photFlags |= 0x00100000; break; // was: ~0x0008 228 default: measure[0].photFlags |= 0x00200000; break; // was: 0x0008 229 } 230 return (TRUE); 231 } 232 233 int set2MASS_gal_flag (Measure *measure, char qual) { 234 235 switch (qual) { 236 case '0': measure[0].photFlags &= ~0x00c00000; break; // was: ~0x0080 237 case '1': measure[0].photFlags |= 0x00400000; break; // was: ~0x0080 238 default: measure[0].photFlags |= 0x00800000; // was: 0x0080 239 measure[0].extNsigma = 100.0; 240 240 break; 241 241 } … … 243 243 } 244 244 245 int set2MASS_mp_flag ( Stars *star, char qual) {246 247 switch (qual) { 248 case '0': star[0].measure.photFlags &= ~0x03000000; break; // was: ~0x0800249 case '1': star[0].measure.photFlags |= 0x01000000; break; // was: ~0x0800250 default: star[0].measure.photFlags |= 0x02000000; break; // was: 0x0800251 } 252 return (TRUE); 253 } 254 255 int set2MASS_dup_flag ( Stars *star, char qual) {256 257 switch (qual) { 258 case '0': star[0].measure.photFlags &= ~0x0c000000; break; // was: ~0x1000259 case '1': star[0].measure.photFlags |= 0x04000000; break; // was: ~0x1000260 default: star[0].measure.photFlags |= 0x08000000; break; // was: 0x1000261 } 262 return (TRUE); 263 } 264 265 int set2MASS_use_flag ( Stars *star, char qual) {266 267 switch (qual) { 268 case '0': star[0].measure.photFlags &= ~0x10000000; break; // was: ~0x2000269 case '1': star[0].measure.photFlags |= 0x10000000; break; // was: 0x2000245 int set2MASS_mp_flag (Measure *measure, char qual) { 246 247 switch (qual) { 248 case '0': measure[0].photFlags &= ~0x03000000; break; // was: ~0x0800 249 case '1': measure[0].photFlags |= 0x01000000; break; // was: ~0x0800 250 default: measure[0].photFlags |= 0x02000000; break; // was: 0x0800 251 } 252 return (TRUE); 253 } 254 255 int set2MASS_dup_flag (Measure *measure, char qual) { 256 257 switch (qual) { 258 case '0': measure[0].photFlags &= ~0x0c000000; break; // was: ~0x1000 259 case '1': measure[0].photFlags |= 0x04000000; break; // was: ~0x1000 260 default: measure[0].photFlags |= 0x08000000; break; // was: 0x1000 261 } 262 return (TRUE); 263 } 264 265 int set2MASS_use_flag (Measure *measure, char qual) { 266 267 switch (qual) { 268 case '0': measure[0].photFlags &= ~0x10000000; break; // was: ~0x2000 269 case '1': measure[0].photFlags |= 0x10000000; break; // was: 0x2000 270 270 default: abort(); 271 271 } -
trunk/Ohana/src/addstar/src/get2mass_ops.c
r34088 r38986 36 36 } 37 37 38 # if (0) 38 39 // fill in the data for a single star. takes a pointer to the start of the line 39 40 int get2mass_star (Stars *star, char *line, int Nmax) { … … 136 137 return TRUE; 137 138 } 139 # endif 138 140 139 141 // fill in the coords for a single star. takes a pointer to the start of the line -
trunk/Ohana/src/addstar/src/getgsc.c
r38467 r38986 4 4 # define DNSTARS 1000 5 5 6 static short GSC_M;7 6 static SkyTable *sky = NULL; 8 7 9 Stars *getgsc (SkyRegion *patch, unsigned int *NSTARS) { 8 static short int GSC_M; 9 10 Catalog *getgsc (SkyRegion *patch) { 10 11 11 unsigned int i, Ngsc, Nstars; 12 Stars *gsc; 13 Stars *stars; 12 unsigned int i; 14 13 SkyList *skylist; 15 14 … … 23 22 skylist = SkyListByPatch (sky, -1, patch); 24 23 25 Nstars = 0; 26 ALLOCATE (stars, Stars, 1); 27 24 Catalog *catalog = NULL; 25 ALLOCATE (catalog, Catalog, 1); 26 dvo_catalog_init (catalog, TRUE); 27 ALLOCATE (catalog->average, Average, 1); 28 ALLOCATE (catalog->measure, Measure, 1); 29 ALLOCATE (catalog->lensing, Lensing, 1); 30 31 SkyRegion region; 32 region.Rmin = 0.0; 33 region.Rmax = 360.0; 34 region.Dmin = -90.0; 35 region.Dmax = +90.0; 36 28 37 for (i = 0; i < skylist[0].Nregions; i++) { 29 gsc = rd_gsc (skylist[0].filename[i], &Ngsc);38 Catalog *newcat = rd_gsc (skylist[0].filename[i]); 30 39 31 REALLOCATE (stars, Stars, MAX (1, Nstars + Ngsc)); 32 memcpy (&stars[Nstars], gsc, Ngsc*sizeof(Stars)); 33 Nstars += Ngsc; 34 35 free (gsc); 40 AddstarClientOptions matchOptions; 41 matchOptions.radius = 0.4; // tight radius at this stage 42 matchOptions.calibrate = FALSE; 43 matchOptions.only_match = FALSE; 44 matchOptions.nosort = FALSE; 45 matchOptions.photcode = 0; // use an invalid photcode to avoid touching secfilt 46 47 find_matches_closest (®ion, newcat, catalog, matchOptions); 48 49 if (newcat) { 50 dvo_catalog_free (newcat); 51 free (newcat); 52 } 36 53 } 37 54 38 // XXX don't free because we only load it once and save it39 55 SkyListFree (skylist); 40 // SkyTableFree (sky);41 56 42 if (VERBOSE) fprintf (stderr, "%d stars from HST GSC\n", Nstars); 43 *NSTARS = Nstars; 44 return (stars); 57 if (VERBOSE) fprintf (stderr, "%d stars from HST GSC\n", (int) catalog->Naverage); 58 return (catalog); 45 59 } 46 60 47 Stars *rd_gsc (char *filename, unsigned int *nstars) {61 Catalog *rd_gsc (char *filename) { 48 62 49 int i, N STARS, Nstars, Nbytes, nbytes, Nline, Nbyte;63 int i, Nbytes, nbytes, Nline, Nbyte; 50 64 char *buffer; 51 65 FILE *f; 52 Stars *stars;53 66 54 Nstars = 0; 55 NSTARS = 1000; 56 ALLOCATE (stars, Stars, NSTARS); 67 int Nave = 0; 68 int Nmeas = 0; 69 int NAVE = 1000; 70 int NMEAS = 1000; 71 72 Catalog *catalog = NULL; 73 ALLOCATE (catalog, Catalog, 1); 74 dvo_catalog_init (catalog, TRUE); 75 ALLOCATE (catalog->average, Average, NAVE); 76 ALLOCATE (catalog->measure, Measure, NMEAS); 57 77 58 78 f = fopen (filename, "r"); … … 68 88 for (i = 0; i < Nline; i++) { 69 89 70 InitStar (&stars[Nstars]); 90 dvo_average_init (&catalog->average[Nave]); 91 dvo_measure_init (&catalog->measure[Nmeas]); 71 92 72 93 Nbyte = i*BYTES_STAR; 73 dparse (& stars[Nstars].average.R, 1, &buffer[Nbyte]);74 dparse (& stars[Nstars].average.D, 2, &buffer[Nbyte]);94 dparse (&catalog->average[Nave].R, 1, &buffer[Nbyte]); 95 dparse (&catalog->average[Nave].D, 2, &buffer[Nbyte]); 75 96 76 if ( stars[Nstars].average.R < UserPatch.Rmin) continue;77 if ( stars[Nstars].average.R > UserPatch.Rmax) continue;78 if ( stars[Nstars].average.D < UserPatch.Dmin) continue;79 if ( stars[Nstars].average.D > UserPatch.Dmax) continue;97 if (catalog->average[Nave].R < UserPatch.Rmin) continue; 98 if (catalog->average[Nave].R > UserPatch.Rmax) continue; 99 if (catalog->average[Nave].D < UserPatch.Dmin) continue; 100 if (catalog->average[Nave].D > UserPatch.Dmax) continue; 80 101 81 stars[Nstars].measure.R = stars[Nstars].average.R;82 stars[Nstars].measure.D = stars[Nstars].average.D;102 catalog->measure[Nmeas].R = catalog->average[Nave].R; 103 catalog->measure[Nmeas].D = catalog->average[Nave].D; 83 104 84 fparse (& stars[Nstars].measure.M, 3, &buffer[Nbyte]);85 stars[Nstars].measure.dM= NAN;86 stars[Nstars].measure.photcode= GSC_M;87 stars[Nstars].measure.t= 0;105 fparse (&catalog->measure[Nmeas].M, 3, &buffer[Nbyte]); 106 catalog->measure[Nmeas].dM = NAN; 107 catalog->measure[Nmeas].photcode = GSC_M; 108 catalog->measure[Nmeas].t = 0; 88 109 89 Nstars ++; 90 CHECK_REALLOCATE (stars, Stars, NSTARS, Nstars, 1000); 110 catalog->average[Nave].Nmeasure = 1; 111 catalog->average[Nave].measureOffset = Nmeas; 112 113 Nave ++; 114 Nmeas ++; 115 116 CHECK_REALLOCATE (catalog->average, Average, NAVE, Nave, 1000); 117 CHECK_REALLOCATE (catalog->measure, Measure, NMEAS, Nmeas, 1000); 91 118 } 92 119 } 93 120 fclose (f); 94 121 free (buffer); 95 REALLOCATE (stars, Stars, Nstars); 96 *nstars = Nstars; 97 return (stars); 122 return (catalog); 98 123 } -
trunk/Ohana/src/addstar/src/getusno.c
r38467 r38986 4 4 # define NELEM 3 5 5 6 Stars *getusno (SkyRegion *catstats, int photcode, unsigned int *nstars) {6 Catalog *getusno (SkyRegion *catstats) { 7 7 8 8 off_t offset; … … 15 15 double dec; 16 16 int spd, spd_start, spd_end; 17 int NUSNO, Nusno;18 Stars *stars;19 17 short int USNO_RED, USNO_BLUE; 20 18 … … 22 20 NAMED_PHOTCODE (USNO_RED, "USNO_RED"); 23 21 NAMED_PHOTCODE (USNO_BLUE, "USNO_BLUE"); 24 if (photcode == USNO_RED) goto good_code;25 if (photcode == USNO_BLUE) goto good_code;26 Shutdown ("USNO photcode not specified");27 good_code:28 22 29 23 /* identify ra & dec range of interest */ … … 43 37 } 44 38 45 Nusno = 0; 46 NUSNO = 5000; 47 ALLOCATE (stars, Stars, NUSNO); 39 int Nave = 0; 40 int Nmeas = 0; 41 int NAVE = 1000; 42 int NMEAS = 1000; 43 44 Catalog *catalog = NULL; 45 ALLOCATE (catalog, Catalog, 1); 46 dvo_catalog_init (catalog, TRUE); 47 ALLOCATE (catalog->average, Average, NAVE); 48 ALLOCATE (catalog->measure, Measure, NMEAS); 48 49 49 50 for (spd = spd_start; spd < spd_end; spd += 75) { … … 110 111 if (buf[1] > iDEC1) continue; 111 112 112 InitStar (&stars[Nusno]); 113 dvo_average_init (&catalog->average[Nave]); 114 dvo_measure_init (&catalog->measure[Nmeas+0]); 115 dvo_measure_init (&catalog->measure[Nmeas+1]); 113 116 114 stars[Nusno].average.R = buf[0]/360000.0; 115 stars[Nusno].average.D = buf[1]/360000.0 - 90.0; 116 stars[Nusno].measure.R = stars[Nusno].average.R; 117 stars[Nusno].measure.D = stars[Nusno].average.D; 118 stars[Nusno].measure.dM = NAN; 117 catalog->average[Nave].R = buf[0]/360000.0; 118 catalog->average[Nave].D = buf[1]/360000.0 - 90.0; 119 119 120 /* one pass of addstar does either r or b */ 121 if (photcode == USNO_RED) { 122 stars[Nusno].measure.photcode = USNO_RED; 123 stars[Nusno].measure.M = fabs (0.1*(buf[2] - 1000*((int)(buf[2]/1000)))); 124 } 125 if (photcode == USNO_BLUE) { 126 stars[Nusno].measure.photcode = USNO_BLUE; 127 stars[Nusno].measure.M = fabs (0.1*((int)(buf[2] - 1000000*((int)(buf[2]/1000000))) / 1000)); 128 } 129 Nusno ++; 130 CHECK_REALLOCATE (stars, Stars, NUSNO, Nusno, 5000); 120 catalog->measure[Nmeas+0].R = catalog->average[Nave].R; 121 catalog->measure[Nmeas+0].D = catalog->average[Nave].D; 122 catalog->measure[Nmeas+0].dM = NAN; 123 catalog->measure[Nmeas+1].R = catalog->average[Nave].R; 124 catalog->measure[Nmeas+1].D = catalog->average[Nave].D; 125 catalog->measure[Nmeas+1].dM = NAN; 126 127 catalog->measure[Nmeas+0].photcode = USNO_RED; 128 catalog->measure[Nmeas+0].M = fabs (0.1*(buf[2] - 1000*((int)(buf[2]/1000)))); 129 catalog->measure[Nmeas+1].photcode = USNO_BLUE; 130 catalog->measure[Nmeas+1].M = fabs (0.1*((int)(buf[2] - 1000000*((int)(buf[2]/1000000))) / 1000)); 131 132 catalog->average[Nave].Nmeasure = 2; 133 catalog->average[Nave].measureOffset = Nmeas; 134 135 Nave ++; 136 Nmeas += 2; 137 138 CHECK_REALLOCATE (catalog->average, Average, NAVE, Nave, 1000); 139 CHECK_REALLOCATE (catalog->measure, Measure, NMEAS, Nmeas, 1000); 131 140 } 132 141 free (buffer); 133 142 fclose (f); 134 143 } 135 REALLOCATE (stars, Stars, Nusno); 144 catalog->Naverage = Nave; 145 catalog->Nmeasure = Nmeas; 136 146 137 *nstars = Nusno; 138 if (VERBOSE) fprintf (stderr, "%d stars from USNO 1.0\n", Nusno); 139 return (stars); 147 if (VERBOSE) fprintf (stderr, "%d stars from USNO 1.0\n", Nave); 148 return (catalog); 140 149 } 141 150 -
trunk/Ohana/src/addstar/src/getusnob.c
r38467 r38986 3 3 # define NELEM 20 4 4 5 Stars *getusnob (SkyRegion *catstats, int photcode, unsigned int *nstars) {5 Catalog *getusnob (SkyRegion *catstats) { 6 6 7 7 off_t offset; 8 int i, bin, first, last, nitems, Nitems, Nbins, Nitemsum;8 int i, j, bin, first, last, nitems, Nitems, Nbins, Nitemsum; 9 9 float hours[100]; 10 10 int start[100], number[100], *buffer, *buf; … … 15 15 int iDEC0, iDEC1, iRA0, iRA1; 16 16 int spd, spd_start, spd_end; 17 int NUSNO, Nusno, Nstars;18 17 short int USNO_RED, USNO_BLUE, USNO_N; 19 18 e_time USNOepoch; 20 Stars *stars;21 19 22 20 m1 = m2 = 0.0; … … 26 24 NAMED_PHOTCODE (USNO_BLUE, "USNO_BLUE"); 27 25 NAMED_PHOTCODE (USNO_N, "USNO_N"); 28 if (photcode == USNO_RED) goto good_code;29 if (photcode == USNO_BLUE) goto good_code;30 if (photcode == USNO_N) goto good_code;31 Shutdown ("USNO photcode not specified");32 good_code:33 26 34 27 fprintf (stderr, "loading USNO-B 1.0\n"); … … 52 45 53 46 Nitemsum = 0; 54 Nusno = 0; 55 NUSNO = 5000; 56 ALLOCATE (stars, Stars, NUSNO); 47 48 int Nave = 0; 49 int Nmeas = 0; 50 int NAVE = 1000; 51 int NMEAS = 1000; 52 53 Catalog *catalog = NULL; 54 ALLOCATE (catalog, Catalog, 1); 55 dvo_catalog_init (catalog, TRUE); 56 ALLOCATE (catalog->average, Average, NAVE); 57 ALLOCATE (catalog->measure, Measure, NMEAS); 57 58 58 59 for (spd = spd_start; spd < spd_end; spd ++) { … … 96 97 97 98 /* sum the number of stars in data segment of interest */ 98 Nstars = 0;99 int Nstars = 0; 99 100 for (bin = first; bin < last; bin++) { 100 101 Nstars += number[bin]; … … 125 126 /* USNO coords are reported for J2000 / epoch 2000.0 */ 126 127 /* extract the basic stellar data */ 127 InitStar (&stars[Nusno]); 128 dvo_average_init (&catalog->average[Nave]); 129 dvo_measure_init (&catalog->measure[Nmeas+0]); 130 dvo_measure_init (&catalog->measure[Nmeas+1]); 128 131 129 stars[Nusno].average.R = buf[0]/360000.0;130 stars[Nusno].average.D = buf[1]/360000.0 - 90.0;132 catalog->average[Nave].R = buf[0]/360000.0; 133 catalog->average[Nave].D = buf[1]/360000.0 - 90.0; 131 134 132 135 /* XXX uR cos(D) or just uR ??? */ 133 stars[Nusno].average.uR = 2.0 * ((buf[2] % 10000) - 5000);134 stars[Nusno].average.uD = 2.0 * ((buf[2]/10000 % 10000) - 5000);136 catalog->average[Nave].uR = 2.0 * ((buf[2] % 10000) - 5000); 137 catalog->average[Nave].uD = 2.0 * ((buf[2]/10000 % 10000) - 5000); 135 138 136 stars[Nusno].average.duR = (buf[3] % 1000); 137 stars[Nusno].average.duD = (buf[3]/1000 % 1000); 138 139 stars[Nusno].average.dR = 0.001 * (buf[4] % 1000); 140 stars[Nusno].average.dD = 0.001 * (buf[4]/1000 % 1000); 141 142 stars[Nusno].average.P = 0; 143 stars[Nusno].average.dP = 0; 144 145 stars[Nusno].measure.R = stars[Nusno].average.R; 146 stars[Nusno].measure.D = stars[Nusno].average.D; 147 148 /* USNO magnitude errors are reported as a fixed 0.3 mag */ 149 stars[Nusno].measure.dM = 0.3; 139 catalog->average[Nave].duR = (buf[3] % 1000); 140 catalog->average[Nave].duD = (buf[3]/1000 % 1000); 141 catalog->average[Nave].dR = 0.001 * (buf[4] % 1000); 142 catalog->average[Nave].dD = 0.001 * (buf[4]/1000 % 1000); 143 catalog->average[Nave].P = 0; 144 catalog->average[Nave].dP = 0; 150 145 151 146 /* USNO-B uses J2000 equinox and 2000.0 epoch for coordinates */ 152 147 /* the magnitudes have no temporal information */ 153 stars[Nusno].measure.t = USNOepoch;154 148 155 /* one pass of addstar does r, b, or n */ 156 if (photcode == USNO_BLUE) { 157 m1 = fabs(0.01 * (buf[5] % 10000)); /* 1st blue mag */ 158 m2 = fabs(0.01 * (buf[7] % 10000)); /* 1st blue mag */ 149 for (j = 0; j < 3; j++) { 150 catalog->measure[Nmeas+j].R = catalog->average[Nave].R; 151 catalog->measure[Nmeas+j].D = catalog->average[Nave].D; 152 catalog->measure[Nmeas+j].dM = 0.3; /* USNO magnitude errors are reported as a fixed 0.3 mag */ 153 catalog->measure[Nmeas+j].t = USNOepoch; 159 154 } 160 if (photcode == USNO_RED) {161 m1 = fabs(0.01 * (buf[6] % 10000)); /* 1st red mag */162 m2 = fabs(0.01 * (buf[8] % 10000)); /* 2nd red mag */163 }164 if (photcode == USNO_N) {165 m1 = fabs(0.01 * (buf[9] % 10000)); /* N (IR) survey */166 m2 = 0;167 }168 stars[Nusno].measure.photcode = photcode;169 155 170 /* if two mags are available, get an average */ 156 catalog->measure[Nmeas+0].photcode = USNO_BLUE; 157 m1 = fabs(0.01 * (buf[5] % 10000)); /* 1st blue mag */ 158 m2 = fabs(0.01 * (buf[7] % 10000)); /* 2nd blue mag */ 171 159 if (m1 && m2) { 172 160 mag = 0.5*(m1 + m2); … … 174 162 mag = (m1) ? m1 : m2; 175 163 } 176 stars[Nusno].measure.M = (mag == 0.0) ? 32.0 : mag;164 catalog->measure[Nmeas+0].M = (mag == 0.0) ? 32.0 : mag; 177 165 178 Nusno ++; 179 CHECK_REALLOCATE (stars, Stars, NUSNO, Nusno, 5000); 166 catalog->measure[Nmeas+1].photcode = USNO_RED; 167 m1 = fabs(0.01 * (buf[6] % 10000)); /* 1st red mag */ 168 m2 = fabs(0.01 * (buf[8] % 10000)); /* 2nd red mag */ 169 if (m1 && m2) { 170 mag = 0.5*(m1 + m2); 171 } else { 172 mag = (m1) ? m1 : m2; 173 } 174 catalog->measure[Nmeas+1].M = (mag == 0.0) ? 32.0 : mag; 175 176 catalog->measure[Nmeas+2].photcode = USNO_N; 177 catalog->measure[Nmeas+2].M = fabs(0.01 * (buf[9] % 10000)); /* N (IR) survey */ 178 179 catalog->average[Nave].Nmeasure = 3; 180 catalog->average[Nave].measureOffset = Nmeas; 181 182 Nave ++; 183 Nmeas += 3; 184 185 CHECK_REALLOCATE (catalog->average, Average, NAVE, Nave, 1000); 186 CHECK_REALLOCATE (catalog->measure, Measure, NMEAS, Nmeas, 1000); 180 187 } 181 188 free (buffer); 182 189 Nitemsum += Nitems; 183 if (VERBOSE) fprintf (stderr, "N usno: %d, Nitems: %d, Nitemsum : %d, Nbytes stars: %d\n", Nusno, Nitems, Nitemsum, (unsigned int) (Nusno*sizeof(Stars)));190 if (VERBOSE) fprintf (stderr, "Naverage: %d, Nitems: %d, Nitemsum : %d\n", Nave, Nitems, Nitemsum); 184 191 fclose (f); 185 192 } 193 catalog->Naverage = Nave; 194 catalog->Nmeasure = Nmeas; 186 195 187 REALLOCATE (stars, Stars, MAX (1, Nusno)); 188 189 *nstars = Nusno; 190 if (VERBOSE) fprintf (stderr, "%d stars from USNO-B 1.0\n", Nusno); 191 return (stars); 196 if (VERBOSE) fprintf (stderr, "%d stars from USNO-B 1.0\n", Nave); 197 return (catalog); 192 198 } -
trunk/Ohana/src/addstar/src/greference.c
r38467 r38986 3 3 # define LOAD_DR2 1 4 4 5 Stars *greference (char *Refcat, SkyRegion *region, int photcode, unsigned int *nstars) {5 Catalog *greference (char *Refcat, SkyRegion *region, int photcode) { 6 6 7 unsigned int Nstars; 8 Stars *stars; 7 Catalog *catalog = NULL; 9 8 10 9 if (VERBOSE) fprintf (stderr, "loading reference catalog data from %s\n", Refcat); 11 10 if (VERBOSE) fprintf (stderr, "full region: %f - %f, %f - %f\n", region[0].Rmin, region[0].Rmax, region[0].Dmin, region[0].Dmax); 12 11 13 Nstars = 0; 14 stars = NULL; 15 12 /* get stars from HST GSC for the given region */ 13 if (!strcasecmp (Refcat, "GSC")) { 14 catalog = getgsc (region); 15 } 16 16 17 /* get stars from USNO for the given region */ 17 18 if (!strcasecmp (Refcat, "USNO")) { 18 stars = getusno (region, photcode, &Nstars);19 catalog = getusno (region); 19 20 } 20 21 21 22 /* get stars from the USNO B catalog for the given region */ 22 23 if (!strcasecmp (Refcat, "USNOB")) { 23 stars = getusnob (region, photcode, &Nstars);24 catalog = getusnob (region); 24 25 } 25 26 26 27 /* get stars from the Tycho catalog for the given region */ 27 28 if (!strcasecmp (Refcat, "TYCHO")) { 28 // stars = gettycho2 (region, photcode, &Nstars);29 29 fprintf (stderr, "Tycho load via addstar is deprecated: use loadtycho\n"); 30 30 exit (2); … … 33 33 /* get stars from the Tycho catalog for the given region (old ingest) */ 34 34 if (!strcasecmp (Refcat, "TYCHO_OLD")) { 35 // stars = gettycho (region, photcode, &Nstars);36 35 fprintf (stderr, "Tycho load via addstar is deprecated: use loadtycho\n"); 37 36 exit (2); 38 37 } 39 38 40 /* get stars from HST GSC for the given region */41 if (!strcasecmp (Refcat, "GSC")) {42 stars = getgsc (region, &Nstars);43 }44 45 39 /* get stars from 2MASS for the given region */ 46 40 if (!strcasecmp (Refcat, "2MASS")) { 47 // stars = get2mass (region, photcode, LOAD_ALLSKY, &Nstars);48 41 fprintf (stderr, "2MASS load via addstar is deprecated: use load2mass\n"); 49 42 exit (2); … … 52 45 /* get stars from 2MASS for the given region */ 53 46 if (!strcasecmp (Refcat, "2MASS-ALLSKY")) { 54 // stars = get2mass (region, photcode, LOAD_ALLSKY, &Nstars);55 47 fprintf (stderr, "2MASS load via addstar is deprecated: use load2mass\n"); 56 48 exit (2); … … 59 51 /* get stars from 2MASS for the given region */ 60 52 if (!strcasecmp (Refcat, "2MASS-DR2")) { 61 // stars = get2mass (region, photcode, LOAD_DR2, &Nstars);62 53 fprintf (stderr, "2MASS load via addstar is deprecated: use load2mass\n"); 63 54 exit (2); 64 55 } 65 56 66 if (VERBOSE && ( Nstars== 0)) fprintf (stderr, "no ref objects in region %s\n", region[0].name);57 if (VERBOSE && (catalog->Naverage == 0)) fprintf (stderr, "no ref objects in region %s\n", region[0].name); 67 58 68 *nstars = Nstars; 69 return (stars); 70 59 return (catalog); 71 60 } -
trunk/Ohana/src/addstar/src/grefstars.c
r38467 r38986 2 2 3 3 /* read ASCII file with ref star data */ 4 Stars *grefstars (char *file, int photcode, unsigned int *Nstars) {4 Catalog *grefstars (char *file, int photcode) { 5 5 6 6 FILE *f; 7 int N, NSTARS; 8 Stars *stars; 7 int NSTARS; 9 8 char line[256]; 10 9 … … 13 12 if (f == NULL) Shutdown ("can't read data from %s", file); 14 13 15 NSTARS = 100; 16 ALLOCATE (stars, Stars, NSTARS); 14 NSTARS = 1000; 15 16 Catalog *catalog = NULL; 17 ALLOCATE (catalog, Catalog, 1); 18 dvo_catalog_init (catalog, TRUE); 19 ALLOCATE (catalog->average, Average, NSTARS); 20 ALLOCATE (catalog->measure, Measure, NSTARS); 17 21 18 22 /* read in stars line-by-line */ 19 for (N = 0; scan_line (f, line) != EOF; N++) { 23 int N = 0; 24 while (scan_line (f, line) != EOF) { 20 25 stripwhite (line); 21 26 if (line[0] == 0) continue; 22 27 if (line[0] == '#') continue; 23 28 24 InitStar (&stars[N]); 29 dvo_average_init (&catalog->average[N]); 30 dvo_measure_init (&catalog->measure[N]); 25 31 26 32 int status = sscanf (line, "%lf %lf %f %f %x", 27 &stars[N].average.R, &stars[N].average.D, 28 &stars[N].measure.M, &stars[N].measure.dM, 29 &stars[N].measure.photFlags); 33 &catalog->average[N].R, &catalog->average[N].D, 34 &catalog->measure[N].M, &catalog->measure[N].dM, 35 &catalog->measure[N].photFlags); 36 30 37 if ((status != 4) && (status != 5)) { 31 38 fprintf (stderr, "error reading line: %s\n", line); 32 N --;33 39 continue; 34 40 } 35 stars[N].average.R = ohana_normalize_angle (stars[N].average.R);41 catalog->average[N].R = ohana_normalize_angle (catalog->average[N].R); 36 42 37 stars[N].measure.R = stars[N].average.R;38 stars[N].measure.D = stars[N].average.D;43 catalog->measure[N].R = catalog->average[N].R; 44 catalog->measure[N].D = catalog->average[N].D; 39 45 40 stars[N].measure.photcode = photcode;46 catalog->measure[N].photcode = photcode; 41 47 42 CHECK_REALLOCATE (stars, Stars, NSTARS, N+1, 100); 48 catalog->average[N].Nmeasure = 1; 49 catalog->average[N].measureOffset = N; 50 51 N++; 52 CHECK_REALLOCATE (catalog->average, Average, NSTARS, N, 1000); 53 CHECK_REALLOCATE (catalog->measure, Measure, NSTARS, N, 1000); 43 54 } 44 *Nstars = N; 45 return (stars); 55 catalog->Naverage = N; 56 catalog->Nmeasure = N; 57 return (catalog); 46 58 } -
trunk/Ohana/src/addstar/src/load2mass.c
r25757 r38986 12 12 13 13 // need to construct these options with args_load2mass... 14 SetSignals (); 14 15 options = ConfigInit (&argc, argv); 15 16 options = args_load2mass (argc, argv, options); -
trunk/Ohana/src/addstar/src/load2mass_as_rawdata.c
r38471 r38986 12 12 int load2mass_as_rawdata (SkyList *skytable, char *filename, AddstarClientOptions options) { 13 13 14 int i, j, verbose;15 int N stars, NSTARS, Ntstars, NTSTARS;14 int i, j, k, verbose; 15 int Ntstars, NTSTARS; 16 16 int Nbyte, Nextra, offset; 17 17 … … 21 21 char *buffer, *p, *q; 22 22 23 Stars **stars; // this is an array of pointers to be consistent with input to find_match_refstars24 23 TMStars *tstars; 25 24 SkyList *skylist; … … 117 116 if (DEBUG) fprintf (stderr, "writing to %s\n", skylist[0].filename[0]); 118 117 119 // collect array of (Stars *) stars in a new output catalog 120 Nstars = 0; 121 NSTARS = 3000; 122 ALLOCATE (stars, Stars *, NSTARS); 118 int Nave = 0; 119 int Nmeas = 0; 120 int NAVE = 1000; 121 int NMEAS = 3000; 122 123 Catalog *newcat = NULL; 124 ALLOCATE (newcat, Catalog, 1); 125 dvo_catalog_init (newcat, TRUE); 126 ALLOCATE (newcat->average, Average, NAVE); 127 ALLOCATE (newcat->measure, Measure, NMEAS); 123 128 124 129 // loop over stars in this 2mass region that are also in this output region … … 140 145 offset = tstars[j].offset; 141 146 142 ALLOCATE (stars[Nstars+0], Stars, 1); 143 ALLOCATE (stars[Nstars+1], Stars, 1); 144 ALLOCATE (stars[Nstars+2], Stars, 1); 145 146 InitStar (stars[Nstars+0]); 147 InitStar (stars[Nstars+1]); 148 InitStar (stars[Nstars+2]); 149 150 stars[Nstars+0][0].average.R = tstars[j].R; 151 stars[Nstars+0][0].average.D = tstars[j].D; 152 stars[Nstars+1][0].average.R = tstars[j].R; 153 stars[Nstars+1][0].average.D = tstars[j].D; 154 stars[Nstars+2][0].average.R = tstars[j].R; 155 stars[Nstars+2][0].average.D = tstars[j].D; 156 get2mass_3star_full (&stars[Nstars], &buffer[offset], Nbyte - offset); 147 dvo_average_init (&newcat->average[Nave]); 148 for (k = 0; k < 4; k++) { 149 dvo_measure_init (&newcat->measure[Nmeas+k]); 150 } 151 152 newcat->average[Nave].R = tstars[j].R; 153 newcat->average[Nave].D = tstars[j].D; 154 get2mass_3star_full (&newcat->measure[Nmeas], &buffer[offset], Nbyte - offset); 157 155 158 156 tstars[j].flag = TRUE; 159 157 160 Nstars += 3; 161 if (Nstars >= NSTARS - 3) { 162 NSTARS += 3000; 163 REALLOCATE (stars, Stars *, NSTARS); 164 } 165 } 166 167 if (!Nstars) { 168 free (stars); 158 newcat->average[Nave].Nmeasure = 3; 159 newcat->average[Nave].measureOffset = Nmeas; 160 161 Nave ++; 162 Nmeas += 3; 163 164 CHECK_REALLOCATE (newcat->average, Average, NAVE, Nave, 1000); 165 CHECK_REALLOCATE (newcat->measure, Measure, NMEAS, Nmeas, 3000); 166 } 167 newcat->Naverage = Nave; 168 newcat->Nmeasure = Nmeas; 169 170 if (!newcat->Naverage) { 171 dvo_catalog_free (newcat); 172 free (newcat); 169 173 continue; 170 174 } 171 175 172 if (DEBUG) fprintf (stderr, "selected %d stars (%10.6f - %10.6f, %10.6f - %10.6f)\n", Nstars, 176 if (DEBUG) fprintf (stderr, "selected %d stars (%10.6f - %10.6f, %10.6f - %10.6f)\n", 177 (int) newcat->Naverage, 173 178 region[0].Rmin, region[0].Rmax, region[0].Dmin, region[0].Dmax); 174 179 … … 193 198 // assume no input star matches an existing star 194 199 // simply add to the existing table 195 // load2mass_catalog (&catalog, stars, Nstars);196 find_matches_refstars (skylist[0].regions[0], stars, Nstars, &catalog, options); 197 // load2mass_catalog (&catalog, stars, Nstars);198 199 dvo_catalog_save (&catalog, VERBOSE);200 dvo_catalog_unlock (&catalog);200 find_matches_refstars (skylist[0].regions[0], newcat, &catalog, options); 201 202 SetProtect (TRUE); 203 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 204 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 205 SetProtect (FALSE); 201 206 dvo_catalog_free (&catalog); 202 // free (catalog.filename);203 // XXX don't free this! it points to an element of the skytable204 207 } 205 208 206 209 SkyListFree (skylist); 207 for (j = 0; j < Nstars; j++) free (stars[j]);208 free ( stars);210 dvo_catalog_free (newcat); 211 free (newcat); 209 212 VERBOSE = verbose; 210 213 } -
trunk/Ohana/src/addstar/src/loadICRF.c
r37807 r38986 16 16 AddstarClientOptions options; 17 17 18 SetSignals (); 18 19 options = ConfigInit (&argc, argv); 19 20 options = args_loadICRF (&argc, argv, options); // XXX fix args after rest is done -
trunk/Ohana/src/addstar/src/loadICRF_catalog.c
r38471 r38986 22 22 find_matches_ICRF (region, stars, Nstars, &catalog, options); 23 23 24 dvo_catalog_save (&catalog, VERBOSE); 25 dvo_catalog_unlock (&catalog); 24 SetProtect (TRUE); 25 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 26 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 27 SetProtect (FALSE); 28 26 29 dvo_catalog_free (&catalog); 27 30 -
trunk/Ohana/src/addstar/src/loadICRF_client.c
r37807 r38986 7 7 8 8 // need to construct these options with args_loadICRF... 9 SetSignals (); 9 10 options = ConfigInit (&argc, argv); 10 11 options = args_loadICRF_client (&argc, argv, options); -
trunk/Ohana/src/addstar/src/loadgalphot.c
r38600 r38986 13 13 14 14 // need to construct these options with args_loadgalphot... 15 SetSignals (); 15 16 options = ConfigInit (&argc, argv); 16 17 options = args_loadgalphot (&argc, argv, options); -
trunk/Ohana/src/addstar/src/loadgalphot_catalog.c
r38553 r38986 22 22 find_matches_galphot (region, stars, Nstars, &catalog, options); 23 23 24 dvo_catalog_save (&catalog, VERBOSE); 25 dvo_catalog_unlock (&catalog); 24 SetProtect (TRUE); 25 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 26 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 27 SetProtect (FALSE); 28 26 29 dvo_catalog_free (&catalog); 27 30 -
trunk/Ohana/src/addstar/src/loadstarpar.c
r37807 r38986 17 17 18 18 // need to construct these options with args_loadstarpar... 19 SetSignals (); 19 20 options = ConfigInit (&argc, argv); 20 options = args_loadstarpar ( argc, argv, options);21 options = args_loadstarpar (&argc, argv, options); 21 22 22 23 // load the full sky description table (dvodb must exist) … … 24 25 SkyTableSetFilenames (sky, CATDIR, "cpt"); 25 26 27 // make the tmpdir if needed 28 if (!loadstarpar_tmpdir()) exit (1); 29 26 30 // load the list of hosts 27 31 HostTable *hosts = NULL; -
trunk/Ohana/src/addstar/src/loadstarpar_catalog.c
r38471 r38986 22 22 find_matches_starpar (region, stars, Nstars, &catalog, options); 23 23 24 dvo_catalog_save (&catalog, VERBOSE); 25 dvo_catalog_unlock (&catalog); 24 SetProtect (TRUE); 25 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 26 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 27 SetProtect (FALSE); 28 26 29 dvo_catalog_free (&catalog); 27 30 -
trunk/Ohana/src/addstar/src/loadstarpar_client.c
r37807 r38986 7 7 8 8 // need to construct these options with args_loadstarpar... 9 SetSignals (); 9 10 options = ConfigInit (&argc, argv); 10 options = args_loadstarpar_client ( argc, argv, options);11 options = args_loadstarpar_client (&argc, argv, options); 11 12 12 13 // client is called with a pointer to the file to be loaded … … 20 21 StarPar_Stars *stars = loadstarpar_load_stars (INPUT, &Nstars); 21 22 22 loadstarpar_catalog (stars, Nstars, skylist->regions[0], CPT_FILE, &options); 23 char filename[DVO_MAX_PATH]; 24 snprintf (filename, DVO_MAX_PATH, "%s/%s.cpt", HOSTDIR, CPT_FILE); 25 26 loadstarpar_catalog (stars, Nstars, skylist->regions[0], filename, &options); 23 27 24 28 free (stars); -
trunk/Ohana/src/addstar/src/loadstarpar_io.c
r37807 r38986 29 29 gfits_define_bintable_column (&theader, "D", "DEC", "", "degree", 1.0, 0.0); 30 30 gfits_define_bintable_column (&theader, "E", "GLON", "", "degree", 1.0, 0.0); 31 gfits_define_bintable_column (&theader, " D", "GLAT", "", "degree", 1.0, 0.0);31 gfits_define_bintable_column (&theader, "E", "GLAT", "", "degree", 1.0, 0.0); 32 32 gfits_define_bintable_column (&theader, "E", "Ebv", "", "", 1.0, 0.0); 33 33 gfits_define_bintable_column (&theader, "E", "dEbv", "", "", 1.0, 0.0); … … 84 84 gfits_free_table (&ftable); 85 85 86 fflush (f); 87 fclose (f); 88 86 89 return TRUE; 87 90 } 88 91 89 92 90 # define GET_COLUMN(OUT,NAME,TYPE ) \93 # define GET_COLUMN(OUT,NAME,TYPE,RTYPE) \ 91 94 TYPE *OUT = gfits_get_bintable_column_data (&theader, &ftable, NAME, type, &Nrow, &Ncol); \ 92 myAssert (!strcmp(type, # TYPE), "wrong column type");95 myAssert (!strcmp(type, #RTYPE), "wrong column type"); 93 96 94 97 StarPar_Stars *loadstarpar_load_stars (char *filename, int *nstars) { … … 134 137 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) goto escape; 135 138 136 GET_COLUMN(ra , "RA" , double );137 GET_COLUMN(dec , "DEC" , double );138 GET_COLUMN(glon , "GLON" , float );139 GET_COLUMN(glat , "GLAT" , float );140 GET_COLUMN(Ebv , "Ebv" , float );141 GET_COLUMN(dEbv , "dEbv" , float );142 GET_COLUMN(DistMag , "DistMag" , float );143 GET_COLUMN(dDistMag, "dDistMag" , float );144 GET_COLUMN(M_r , "M_r" , float );145 GET_COLUMN(dM_r , "dM_r" , float );146 GET_COLUMN(FeH , "FeH" , float );147 GET_COLUMN(dFeH , "dFeH" , float );148 GET_COLUMN(averef , "averef" , unsigned int );149 GET_COLUMN(objID , "objID" , unsigned int );150 GET_COLUMN(catID , "catID" , unsigned int );139 GET_COLUMN(ra , "RA" , double , double ); 140 GET_COLUMN(dec , "DEC" , double , double ); 141 GET_COLUMN(glon , "GLON" , float , float ); 142 GET_COLUMN(glat , "GLAT" , float , float ); 143 GET_COLUMN(Ebv , "Ebv" , float , float ); 144 GET_COLUMN(dEbv , "dEbv" , float , float ); 145 GET_COLUMN(DistMag , "DistMag" , float , float ); 146 GET_COLUMN(dDistMag, "dDistMag" , float , float ); 147 GET_COLUMN(M_r , "M_r" , float , float ); 148 GET_COLUMN(dM_r , "dM_r" , float , float ); 149 GET_COLUMN(FeH , "FeH" , float , float ); 150 GET_COLUMN(dFeH , "dFeH" , float , float ); 151 GET_COLUMN(averef , "averef" , unsigned int, int ); 152 GET_COLUMN(objID , "objID" , unsigned int, int ); 153 GET_COLUMN(catID , "catID" , unsigned int, int ); 151 154 152 155 gfits_free_header (&theader); -
trunk/Ohana/src/addstar/src/loadstarpar_readstars.c
r37807 r38986 47 47 char type[16]; 48 48 49 GET_COLUMN (gl at, "l", float);50 GET_COLUMN (gl on, "b", float);49 GET_COLUMN (glon, "l", float); 50 GET_COLUMN (glat, "b", float); 51 51 GET_COLUMN (conv, "conv", byte); 52 52 GET_COLUMN (lnZ, "lnZ", float); -
trunk/Ohana/src/addstar/src/loadstarpar_save_remote.c
r38441 r38986 18 18 19 19 // save to a unique filename 20 char filename[ 1024]; // CATDIR/tmpdir/starpar.PID.index.fits21 snprintf (filename, 1024, "%s/tmpdir/starpar.%s.%05d.fits", CATDIR, uniquer, region->index);20 char filename[DVO_MAX_PATH]; // CATDIR/tmpdir/starpar.PID.index.fits 21 snprintf (filename, DVO_MAX_PATH, "%s/tmpdir/starpar.%s.%05d.fits", CATDIR, uniquer, region->index); 22 22 23 23 // write the data to the given FITS file … … 57 57 strextend (&command, "-input %s", filename); 58 58 59 if (options->only_match) strextend (&command, "-only-match"); 60 if (options->replace) strextend (&command, "-replace"); 61 62 fprintf (stderr, "command: %s\n", command); 63 59 64 // launch the job on the remote machine (no handshake) 60 65 int errorInfo = 0; -
trunk/Ohana/src/addstar/src/loadsupercos.c
r38441 r38986 15 15 int i, status; 16 16 SkyTable *sky; 17 SkyList *skylist = NULL;18 17 AddstarClientOptions options; 19 18 FITS_DB db; 20 19 21 20 // need to construct these options with args_loadWISE... 21 SetSignals (); 22 22 options = ConfigInit (&argc, argv); 23 23 options = args_loadsupercos (&argc, argv, options); … … 27 27 SkyTableSetFilenames (sky, CATDIR, "cpt"); 28 28 29 // generate the subset matching the user-selected region30 skylist = SkyListByPatch (sky, -1, &UserPatch);31 32 // if we only match to existing (already populated) regions, limit the select to those regions:33 if (options.existing_regions) {34 SkyList *tmp;35 tmp = SkyListExistingSubset (skylist, CATDIR);36 SkyListFree (skylist);37 skylist = tmp;38 }39 40 29 // load the images table (needed regardless) 41 30 int Nsurvey = 0; … … 68 57 for (i = 3; i < argc; i++) { 69 58 fprintf (stderr, "loading %s\n", argv[i]); 70 loadsupercos_rawdata (image, imlist, Nimage, sky list, argv[i], options);59 loadsupercos_rawdata (image, imlist, Nimage, sky, argv[i], options); 71 60 } 72 61 exit (0); -
trunk/Ohana/src/addstar/src/loadsupercos_ops.c
r37036 r38986 79 79 } 80 80 81 int loadsupercos_sortStars (Stars *tstars, int Ntstars) {82 83 # define SWAPFUNC(A,B){ Stars temp = tstars[A]; tstars[A] = tstars[B]; tstars[B] = temp; }84 # define COMPARE(A,B)(tstars[A].average.R < tstars[B].average.R)85 86 OHANA_SORT (Ntstars, COMPARE, SWAPFUNC);87 88 # undef SWAPFUNC89 # undef COMPARE90 91 return TRUE;92 }93 94 81 int *loadsupercos_image_index (Image *image, int Nimage) { 95 82 -
trunk/Ohana/src/addstar/src/loadsupercos_rawdata.c
r38471 r38986 6 6 # define DEBUG 0 7 7 8 int loadsupercos_rawdata (Image *image, int *imlist, int Nimage, Sky List*skytable, char *filename, AddstarClientOptions options) {8 int loadsupercos_rawdata (Image *image, int *imlist, int Nimage, SkyTable *skytable, char *filename, AddstarClientOptions options) { 9 9 10 int i , j, verbose;11 int N stars, NSTARS, Nrecords;10 int i; 11 int Nrecords; 12 12 13 13 FILE *f; … … 15 15 16 16 Detection *sstars; 17 Stars **stars, *tstars;18 SkyList *skylist;19 SkyRegion *region;20 17 Catalog catalog; 21 18 … … 26 23 if (f == NULL) Shutdown ("can't read the Supercosmos data file: %s", filename); 27 24 28 ALLOCATE (tstars, Stars, NRECORDS);29 25 ALLOCATE (sstars, Detection, NRECORDS); 30 26 … … 33 29 double Dmin = +90.0; 34 30 double Dmax = -90.0; 31 32 Catalog *newcat = NULL; 33 ALLOCATE (newcat, Catalog, 1); 34 dvo_catalog_init (newcat, TRUE); 35 ALLOCATE (newcat->average, Average, NRECORDS); 36 ALLOCATE (newcat->measure, Measure, NRECORDS); 35 37 36 38 while ((Nrecords = fread (buffer, NBYTE, NRECORDS, f)) != 0) { … … 62 64 // convert to the Stars format 63 65 for (i = 0; i < Nrecords; i++) { 64 InitStar (&tstars[i]);65 tstars[i].measure.Xccd = sstars[i].xCen;66 tstars[i].measure.Yccd = sstars[i].yCen;67 66 68 tstars[i].measure.M = sstars[i].sMag; 69 tstars[i].measure.Map = sstars[i].gMag; 70 tstars[i].measure.photFlags = sstars[i].class; 67 dvo_average_init (&newcat->average[i]); 68 dvo_measure_init (&newcat->measure[i]); 71 69 72 tstars[i].average.R = sstars[i].ra;73 tstars[i].average.D = sstars[i].dec;70 newcat->measure[i].Xccd = sstars[i].xCen; 71 newcat->measure[i].Yccd = sstars[i].yCen; 74 72 75 tstars[i].measure.R = sstars[i].ra; 76 tstars[i].measure.D = sstars[i].dec; 73 newcat->measure[i].M = sstars[i].sMag; 74 newcat->measure[i].Map = sstars[i].gMag; 75 newcat->measure[i].photFlags = sstars[i].class; 76 77 newcat->average[i].R = sstars[i].ra; 78 newcat->average[i].D = sstars[i].dec; 79 80 newcat->measure[i].R = sstars[i].ra; 81 newcat->measure[i].D = sstars[i].dec; 77 82 78 83 int Ni = imlist[sstars[i].plateID]; … … 80 85 81 86 // XXX fix these 82 tstars[i].measure.Mcal = 0.0;83 tstars[i].measure.dt = image[Ni].exptime;87 newcat->measure[i].Mcal = 0.0; 88 newcat->measure[i].dt = image[Ni].exptime; 84 89 85 90 double sidtime = image[Ni].sidtime; … … 87 92 88 93 double alt, az; 89 altaz (&alt, &az, 15.0*sidtime - tstars[i].average.R, tstars[i].average.D, latitude);94 altaz (&alt, &az, 15.0*sidtime - newcat->average[i].R, newcat->average[i].D, latitude); 90 95 91 tstars[i].measure.airmass = 1.0 / cos(RAD_DEG*alt);92 tstars[i].measure.az = az;93 tstars[i].measure.t = image[Ni].tzero;94 tstars[i].measure.imageID = image[Ni].imageID;95 tstars[i].measure.photcode = image[Ni].photcode;96 newcat->measure[i].airmass = 1.0 / cos(RAD_DEG*alt); 97 newcat->measure[i].az = az; 98 newcat->measure[i].t = image[Ni].tzero; 99 newcat->measure[i].imageID = image[Ni].imageID; 100 newcat->measure[i].photcode = image[Ni].photcode; 96 101 97 tstars[i].measure.FWx = ToShortPixels(sstars[i].aU);98 tstars[i].measure.FWy = ToShortPixels(sstars[i].bU);99 tstars[i].measure.theta = ToShortDegrees(sstars[i].thetaU);102 newcat->measure[i].FWx = ToShortPixels(sstars[i].aU); 103 newcat->measure[i].FWy = ToShortPixels(sstars[i].bU); 104 newcat->measure[i].theta = ToShortDegrees(sstars[i].thetaU); 100 105 101 Rmin = MIN (Rmin, tstars[i].average.R);102 Rmax = MAX (Rmax, tstars[i].average.R);103 Dmin = MIN (Dmin, tstars[i].average.D);104 Dmax = MAX (Dmax, tstars[i].average.D);106 Rmin = MIN (Rmin, newcat->average[i].R); 107 Rmax = MAX (Rmax, newcat->average[i].R); 108 Dmin = MIN (Dmin, newcat->average[i].D); 109 Dmax = MAX (Dmax, newcat->average[i].D); 105 110 } 106 111 107 112 if (VERBOSE) fprintf (stderr, "scan %d stars (%10.6f - %10.6f, %10.6f - %10.6f) .. ", Nrecords, Rmin, Rmax, Dmin, Dmax); 108 113 109 // sort the tstars by RA 110 loadsupercos_sortStars (tstars, Nrecords); 114 SkyList *skylist = SkyListForStars (skytable, -1, newcat); 111 115 112 // scan through the stars, loading the containing catalogs 113 // skip through table for unsaved stars 114 for (i = 0; i < Nrecords; i++) { 115 if (tstars[i].found != -1) continue; 116 for (i = 0; i < skylist[0].Nregions; i++) { 117 // now we have all of the loaded stars in this catalog 118 dvo_catalog_init (&catalog, TRUE); 119 catalog.filename = skylist[0].filename[0]; 120 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 121 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 122 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 123 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 116 124 117 // scan forward until we reach the UserPatch (stars sorted by RA) 118 if (tstars[i].average.R < UserPatch.Rmin) continue; 119 if (tstars[i].average.R > UserPatch.Rmax) break; 120 if (tstars[i].average.D < UserPatch.Dmin) continue; 121 if (tstars[i].average.D > UserPatch.Dmax) continue; 122 123 // identify the relevant catalog 124 skylist = SkyRegionByPoint_List (skytable, -1, tstars[i].average.R, tstars[i].average.D); 125 if (skylist[0].Nregions == 0) { 126 SkyListFree (skylist); 127 continue; 128 } 129 region = skylist[0].regions[0]; 130 if (DEBUG) fprintf (stderr, "writing to %s\n", skylist[0].filename[0]); 131 132 int this_image_id = tstars[i].measure.imageID; 133 134 // loop over stars in this WISE region that are also in this output region 135 Nstars = 0; 136 NSTARS = 1000; 137 ALLOCATE (stars, Stars *, NSTARS); 138 139 for (j = i; j < Nrecords; j++) { 140 if (tstars[j].found != -1) continue; 141 142 if (tstars[j].measure.imageID != this_image_id) continue; 143 144 // check if in skyregion 145 if (tstars[j].average.R < region[0].Rmin) continue; 146 if (tstars[j].average.R > region[0].Rmax) break; 147 if (tstars[j].average.D < region[0].Dmin) continue; 148 if (tstars[j].average.D > region[0].Dmax) continue; 149 150 // check if in UserPatch 151 if (tstars[j].average.R < UserPatch.Rmin) continue; 152 if (tstars[j].average.R > UserPatch.Rmax) break; 153 if (tstars[j].average.D < UserPatch.Dmin) continue; 154 if (tstars[j].average.D > UserPatch.Dmax) continue; 155 156 stars[Nstars] = &tstars[j]; 157 Nstars ++; 158 159 CHECK_REALLOCATE (stars, Stars *, NSTARS, Nstars, 1000); 160 } 161 162 if (DEBUG) fprintf (stderr, "selected %d stars (%10.6f - %10.6f, %10.6f - %10.6f)\n", Nstars, 163 region[0].Rmin, region[0].Rmax, region[0].Dmin, region[0].Dmax); 164 165 if (1) { 166 verbose = VERBOSE; 167 VERBOSE = FALSE; 168 169 // now we have all of the loaded stars in this catalog 170 dvo_catalog_init (&catalog, TRUE); 171 catalog.filename = skylist[0].filename[0]; 172 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 173 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 174 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 175 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 176 177 // an error exit status here is a significant error 178 if (!dvo_catalog_open (&catalog, skylist[0].regions[0], VERBOSE, "w")) { 179 fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", catalog.filename); 180 exit (2); 181 } 182 183 // assume no input star matches an existing star 184 // simply add to the existing table 185 // loadWISE_catalog (&catalog, stars, Nstars); 186 find_matches_refstars (skylist[0].regions[0], stars, Nstars, &catalog, options); 187 // loadWISE_catalog (&catalog, stars, Nstars); 188 189 dvo_catalog_save (&catalog, VERBOSE); 190 dvo_catalog_unlock (&catalog); 191 dvo_catalog_free (&catalog); 192 // free (catalog.filename); 193 // XXX don't free this! it points to an element of the skytable 125 // an error exit status here is a significant error 126 if (!dvo_catalog_open (&catalog, skylist[0].regions[0], VERBOSE, "w")) { 127 fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", catalog.filename); 128 exit (2); 194 129 } 195 130 196 SkyListFree (skylist); 131 // assume no input star matches an existing star 132 // simply add to the existing table 133 find_matches_refstars (skylist[0].regions[0], newcat, &catalog, options); 197 134 198 free (stars); 199 VERBOSE = verbose; 135 SetProtect (TRUE); 136 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 137 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 138 SetProtect (FALSE); 139 140 dvo_catalog_free (&catalog); 200 141 } 142 143 SkyListFree (skylist); 144 dvo_catalog_free (newcat); 145 free (newcat); 146 201 147 if (VERBOSE) fprintf (stderr, "done\n"); 202 148 } … … 204 150 if (VERBOSE) fprintf (stderr, "\n"); 205 151 206 free (tstars);207 152 free (sstars); 208 153 … … 225 170 */ 226 171 172 173 174 175 176 177 178 179 180 181 182 183 184 -
trunk/Ohana/src/addstar/src/loadtycho.c
r38467 r38986 20 20 21 21 // need to construct these options with args_loadtycho... 22 SetSignals (); 22 23 options = ConfigInit (&argc, argv); 23 24 options = args_loadtycho (&argc, argv, options); -
trunk/Ohana/src/addstar/src/loadtycho_rawdata.c
r38471 r38986 22 22 23 23 Tycho_Stars *tstars; 24 Stars *stars, **starrefs; // this is an array of pointers to be consistent with input to find_match_refstars25 24 SkyList *skylist; 26 25 SkyRegion *region; … … 87 86 if (DEBUG) fprintf (stderr, "writing to %s\n", skylist[0].filename[0]); 88 87 89 // collect array of (Stars *) stars in a new output catalog 90 int Nstars = 0; 91 int NSTARS = (NGROUP*1000); 92 ALLOCATE (stars, Stars, NSTARS); 88 int Nave = 0; 89 int Nmeas = 0; 90 int NAVE = 1000; 91 int NMEAS = 4000; 92 93 Catalog *newcat = NULL; 94 ALLOCATE (newcat, Catalog, 1); 95 dvo_catalog_init (newcat, TRUE); 96 ALLOCATE (newcat->average, Average, NAVE); 97 ALLOCATE (newcat->measure, Measure, NMEAS); 93 98 94 99 // loop over stars in this WISE region that are also in this output region … … 108 113 if (tstars[j].average.D > UserPatch.Dmax) continue; 109 114 110 for (k = 0; k < NGROUP; k++) { 111 stars[Nstars+k].average = tstars[j].average; 112 stars[Nstars+k].measure = tstars[j].measure[k]; 113 stars[Nstars+k].found = -1; 114 } 115 dvo_average_init (&newcat->average[Nave]); 116 newcat->average[Nave] = tstars[j].average; 117 for (k = 0; k < NGROUP; k++) { 118 dvo_measure_init (&newcat->measure[Nmeas + k]); 119 newcat->measure[Nmeas + k] = tstars[j].measure[k]; 120 } 115 121 tstars[j].flag = TRUE; 116 122 117 Nstars += NGROUP; 118 if (Nstars >= NSTARS - NGROUP) { 119 NSTARS += (NGROUP*1000); 120 REALLOCATE (stars, Stars, NSTARS); 121 } 123 newcat->average[Nave].Nmeasure = NGROUP; 124 newcat->average[Nave].measureOffset = Nmeas; 125 126 Nave ++; 127 Nmeas += NGROUP; 128 129 CHECK_REALLOCATE (newcat->average, Average, NAVE, Nave, 1000); 130 CHECK_REALLOCATE (newcat->measure, Measure, NMEAS, Nmeas + NGROUP, 4000); 122 131 } 132 newcat->Naverage = Nave; 133 newcat->Nmeasure = Nmeas; 123 134 124 ALLOCATE (starrefs, Stars *, NSTARS); 125 for (j = 0; j < Nstars; j++) { 126 starrefs[j] = &stars[j]; 135 if (!newcat->Naverage) { 136 dvo_catalog_free (newcat); 137 free (newcat); 138 continue; 127 139 } 128 140 … … 145 157 // assume no input star matches an existing star 146 158 // simply add to the existing table 147 find_matches_closest_refstars(region, starrefs, Nstars, &catalog, options);159 find_matches_closest_refstars(region, newcat, &catalog, options); 148 160 149 dvo_catalog_save (&catalog, verbose); 150 dvo_catalog_unlock (&catalog); 161 SetProtect (TRUE); 162 if (!dvo_catalog_save (&catalog, verbose)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 163 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 164 SetProtect (FALSE); 165 151 166 dvo_catalog_free (&catalog); 152 167 153 168 SkyListFree (skylist); 154 free (stars);155 free ( starrefs);169 dvo_catalog_free (newcat); 170 free (newcat); 156 171 } 157 172 free (tstars); -
trunk/Ohana/src/addstar/src/loadwise.c
r37807 r38986 20 20 21 21 // need to construct these options with args_loadWISE... 22 SetSignals (); 22 23 options = ConfigInit (&argc, argv); 23 24 options = args_loadwise (argc, argv, options); -
trunk/Ohana/src/addstar/src/loadwise_prelim_rawdata.c
r38471 r38986 202 202 // loadWISE_catalog (&catalog, stars, Nstars); 203 203 204 dvo_catalog_save (&catalog, VERBOSE); 205 dvo_catalog_unlock (&catalog); 204 SetProtect (TRUE); 205 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 206 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 207 SetProtect (FALSE); 208 206 209 dvo_catalog_free (&catalog); 207 210 // free (catalog.filename); -
trunk/Ohana/src/addstar/src/loadwise_rawdata.c
r38471 r38986 13 13 14 14 int i, j, k, verbose; 15 int N stars, NSTARS, Ntstars, NTSTARS;15 int Ntstars, NTSTARS; 16 16 int Nbyte, Nextra, offset; 17 17 … … 21 21 char *buffer, *p, *q; 22 22 23 Stars **stars; // this is an array of pointers to be consistent with input to find_match_refstars24 23 WISE_Stars *tstars; 25 24 SkyList *skylist; … … 117 116 if (DEBUG) fprintf (stderr, "writing to %s\n", skylist[0].filename[0]); 118 117 119 // collect array of (Stars *) stars in a new output catalog 120 Nstars = 0; 121 NSTARS = 3000; 122 ALLOCATE (stars, Stars *, NSTARS); 118 int Nave = 0; 119 int Nmeas = 0; 120 int NAVE = 1000; 121 int NMEAS = 4000; 122 123 Catalog *newcat = NULL; 124 ALLOCATE (newcat, Catalog, 1); 125 dvo_catalog_init (newcat, TRUE); 126 ALLOCATE (newcat->average, Average, NAVE); 127 ALLOCATE (newcat->measure, Measure, NMEAS); 123 128 124 129 // loop over stars in this WISE region that are also in this output region … … 140 145 offset = tstars[j].offset; 141 146 147 dvo_average_init (&newcat->average[Nave]); 142 148 for (k = 0; k < 4; k++) { 143 ALLOCATE (stars[Nstars + k], Stars, 1); 144 InitStar (stars[Nstars + k]); 145 stars[Nstars+k][0].average.R = tstars[j].R; 146 stars[Nstars+k][0].average.D = tstars[j].D; 147 stars[Nstars+k][0].measure.R = tstars[j].R; 148 stars[Nstars+k][0].measure.D = tstars[j].D; 149 } 149 dvo_measure_init (&newcat->measure[Nmeas+k]); 150 } 150 151 152 newcat->average[Nave].R = tstars[j].R; 153 newcat->average[Nave].D = tstars[j].D; 154 151 155 switch (MODE) { 152 156 case MODE_PRELIM: 153 loadwise_star_prelim (& stars[Nstars], &buffer[offset], Nbyte - offset);157 loadwise_star_prelim (&newcat->measure[Nmeas], &buffer[offset], Nbyte - offset); 154 158 break; 155 159 case MODE_ALLSKY: 156 loadwise_star_allsky (& stars[Nstars], &buffer[offset], Nbyte - offset);160 loadwise_star_allsky (&newcat->measure[Nmeas], &buffer[offset], Nbyte - offset); 157 161 break; 158 162 case MODE_ALLWISE: 159 loadwise_star_allwise (& stars[Nstars], &buffer[offset], Nbyte - offset);163 loadwise_star_allwise (&newcat->measure[Nmeas], &buffer[offset], Nbyte - offset); 160 164 break; 161 165 default: … … 165 169 tstars[j].flag = TRUE; 166 170 167 Nstars += 4; 168 if (Nstars >= NSTARS - 4) { 169 NSTARS += 4000; 170 REALLOCATE (stars, Stars *, NSTARS); 171 } 172 } 173 174 if (!Nstars) { 175 free (stars); 171 newcat->average[Nave].Nmeasure = 4; 172 newcat->average[Nave].measureOffset = Nmeas; 173 174 Nave ++; 175 Nmeas += 4; 176 177 CHECK_REALLOCATE (newcat->average, Average, NAVE, Nave, 1000); 178 CHECK_REALLOCATE (newcat->measure, Measure, NMEAS, Nmeas, 4000); 179 } 180 newcat->Naverage = Nave; 181 newcat->Nmeasure = Nmeas; 182 183 if (!newcat->Naverage) { 184 dvo_catalog_free (newcat); 185 free (newcat); 176 186 continue; 177 187 } 178 188 179 if (DEBUG) fprintf (stderr, "selected %d stars (%10.6f - %10.6f, %10.6f - %10.6f)\n", Nstars, 189 if (DEBUG) fprintf (stderr, "selected %d stars (%10.6f - %10.6f, %10.6f - %10.6f)\n", 190 (int) newcat->Naverage, 180 191 region[0].Rmin, region[0].Rmax, region[0].Dmin, region[0].Dmax); 181 192 … … 200 211 // assume no input star matches an existing star 201 212 // simply add to the existing table 202 // loadWISE_catalog (&catalog, stars, Nstars);203 find_matches_refstars (skylist[0].regions[0], stars, Nstars, &catalog, options); 204 // loadWISE_catalog (&catalog, stars, Nstars);205 206 dvo_catalog_save (&catalog, VERBOSE);207 dvo_catalog_unlock (&catalog);213 find_matches_refstars (skylist[0].regions[0], newcat, &catalog, options); 214 215 SetProtect (TRUE); 216 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 217 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 218 SetProtect (FALSE); 208 219 dvo_catalog_free (&catalog); 209 // free (catalog.filename);210 // XXX don't free this! it points to an element of the skytable211 220 } 212 221 213 222 SkyListFree (skylist); 214 for (j = 0; j < Nstars; j++) free (stars[j]);215 free ( stars);223 dvo_catalog_free (newcat); 224 free (newcat); 216 225 VERBOSE = verbose; 217 226 } -
trunk/Ohana/src/addstar/src/loadwise_star_full.c
r38062 r38986 2 2 # include "WISE.h" 3 3 4 int setWISE_ph_qual ( Stars *star, char qual);5 int setWISE_var_flag_allsky ( Stars *star, char qual);6 int setWISE_ext_flag_allsky ( Stars **star, char ptr);7 int setWISE_var_flag_prelim ( Stars *star, char qual);8 int setWISE_ext_flag_prelim ( Stars **star, char ptr);9 int setWISE_cc_flag ( Stars *star, char qual);10 int setWISE_sat_flag ( Stars *star, char *ptr);11 int setWISE_blend_flag ( Stars **star, char *ptr);4 int setWISE_ph_qual (Measure *measure, char qual); 5 int setWISE_var_flag_allsky (Measure *measure, char qual); 6 int setWISE_ext_flag_allsky (Measure *measure, char ptr); 7 int setWISE_var_flag_prelim (Measure *measure, char qual); 8 int setWISE_ext_flag_prelim (Measure *measure, char ptr); 9 int setWISE_cc_flag (Measure *measure, char qual); 10 int setWISE_sat_flag (Measure *measure, char *ptr); 11 int setWISE_blend_flag (Measure *measure, char *ptr); 12 12 13 13 // fill in the data for a WISE quad star. takes a pointer to the start of the line the 14 14 // RA and DEC have already been set 15 int loadwise_star_allwise ( Stars **star, char *line, int Nmax) {15 int loadwise_star_allwise (Measure *measure, char *line, int Nmax) { 16 16 17 17 int i; … … 23 23 24 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;25 measure[0].posangle = 0.0; 26 measure[0].pltscale = 1.0; 27 27 28 28 ptr = skipNbounds (ptr, '|', 3, Nmax); // skip: desig, ra, dec, 29 star[0][0].measure.dXccd = ToShortPixels((strtod (ptr, NULL) + 0.005)); // sig_ra -- add 5/1000 to avoid truncation29 measure[0].dXccd = ToShortPixels((strtod (ptr, NULL) + 0.005)); // sig_ra -- add 5/1000 to avoid truncation 30 30 ptr = nextWISEfield (ptr); 31 star[0][0].measure.dYccd = ToShortPixels((strtod (ptr, NULL) + 0.005)); // sig_dec31 measure[0].dYccd = ToShortPixels((strtod (ptr, NULL) + 0.005)); // sig_dec 32 32 ptr = nextWISEfield (ptr); 33 33 34 34 // we only know a single set of values for all 4 bands 35 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;36 measure[i].dXccd = measure[0].dXccd; 37 measure[i].dYccd = measure[0].dYccd; 38 measure[i].posangle = measure[0].posangle; 39 measure[i].pltscale = measure[0].pltscale; 40 40 } 41 41 ptr = skipNbounds (ptr, '|', 5, Nmax); // skip: sig_radec, glon, glat, elon, elat 42 42 43 star[0][0].measure.Xccd = strtod (ptr, NULL); // wx43 measure[0].Xccd = strtod (ptr, NULL); // wx 44 44 ptr = nextWISEfield (ptr); // skip wx 45 star[0][0].measure.Yccd = strtod (ptr, NULL); // wy45 measure[0].Yccd = strtod (ptr, NULL); // wy 46 46 ptr = nextWISEfield (ptr); // skip wy 47 47 48 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;49 measure[i].Xccd = measure[0].Xccd; 50 measure[i].Yccd = measure[0].Yccd; 51 51 } 52 52 ptr = skipNbounds (ptr, '|', 4, Nmax); // skip: cntr, source_id, coadd_id, src … … 55 55 for (i = 0; i < 4; i++) { 56 56 char *endpoint; 57 star[i][0].measure.M = strtod (ptr, &endpoint); // w?mpro57 measure[i].M = strtod (ptr, &endpoint); // w?mpro 58 58 if (endpoint == ptr) { 59 star[i][0].measure.M = NAN;59 measure[i].M = NAN; 60 60 } 61 61 ptr = nextWISEfield (ptr); 62 star[i][0].measure.dM = strtod (ptr, &endpoint); // w?sigmpro62 measure[i].dM = strtod (ptr, &endpoint); // w?sigmpro 63 63 if (endpoint == ptr) { 64 star[i][0].measure.dM = NAN;64 measure[i].dM = NAN; 65 65 } 66 66 ptr = skipNbounds (ptr, '|', 2, Nmax); // skip: w?sigmpro, w?snr 67 star[i][0].measure.psfChisq = strtod (ptr, NULL); // w?rchi268 star[i][0].measure.psfQF = strtod (ptr, NULL); // w?rchi267 measure[i].psfChisq = strtod (ptr, NULL); // w?rchi2 68 measure[i].psfQF = strtod (ptr, NULL); // w?rchi2 69 69 ptr = nextWISEfield (ptr); // skip : w1rchi2 70 70 71 71 // init the photFlags field 72 star[i][0].measure.photFlags = 0;72 measure[i].photFlags = 0; 73 73 } 74 74 … … 76 76 77 77 // set blend flags for all 4 measures 78 setWISE_blend_flag ( star, ptr); // nb & na both used here78 setWISE_blend_flag (measure, ptr); // nb & na both used here 79 79 ptr = skipNbounds (ptr, '|', 2, Nmax); // skip: nb, na 80 80 81 81 for (i = 0; i < 4; i++) { 82 setWISE_sat_flag ( star[i], ptr); // w1sat82 setWISE_sat_flag (&measure[i], ptr); // w1sat 83 83 ptr = nextWISEfield (ptr); 84 84 } … … 88 88 89 89 for (i = 0; i < 4; i++) { 90 setWISE_cc_flag ( star[i], ptr[i]); // cc_flags90 setWISE_cc_flag (&measure[i], ptr[i]); // cc_flags 91 91 } 92 92 ptr = nextWISEfield (ptr); // skip cc_flags … … 94 94 95 95 // set ext flags for all 4 measures 96 setWISE_ext_flag_allsky ( star, ptr[0]); // ext_flg96 setWISE_ext_flag_allsky (measure, ptr[0]); // ext_flg 97 97 ptr = nextWISEfield (ptr); // skip ext_flags 98 98 99 99 for (i = 0; i < 4; i++) { 100 setWISE_var_flag_allsky ( star[i], ptr[i]); // var_flg100 setWISE_var_flag_allsky (&measure[i], ptr[i]); // var_flg 101 101 } 102 102 ptr = nextWISEfield (ptr); // skip var_flags 103 103 104 104 for (i = 0; i < 4; i++) { 105 setWISE_ph_qual ( star[i], ptr[i]); // ph_qual105 setWISE_ph_qual (&measure[i], ptr[i]); // ph_qual 106 106 } 107 107 … … 123 123 // the release is based on data taken in the period 14 January 2010 to 29 April 2010 124 124 if (mjdmean == 0.0) { 125 star[i][0].measure.t = 0;125 measure[i].t = 0; 126 126 } else { 127 star[i][0].measure.t = ohana_mjd_to_sec (mjdmean);127 measure[i].t = ohana_mjd_to_sec (mjdmean); 128 128 } 129 129 } 130 130 131 star[0][0].measure.photcode = WISE_W1;132 star[0][0].measure.detID = 0;133 star[0][0].measure.imageID = 0;134 135 star[1][0].measure.photcode = WISE_W2;136 star[1][0].measure.detID = 0;137 star[1][0].measure.imageID = 0;138 139 star[2][0].measure.photcode = WISE_W3;140 star[2][0].measure.detID = 0;141 star[2][0].measure.imageID = 0;142 143 star[3][0].measure.photcode = WISE_W4;144 star[3][0].measure.detID = 0;145 star[3][0].measure.imageID = 0;131 measure[0].photcode = WISE_W1; 132 measure[0].detID = 0; 133 measure[0].imageID = 0; 134 135 measure[1].photcode = WISE_W2; 136 measure[1].detID = 0; 137 measure[1].imageID = 0; 138 139 measure[2].photcode = WISE_W3; 140 measure[2].detID = 0; 141 measure[2].imageID = 0; 142 143 measure[3].photcode = WISE_W4; 144 measure[3].detID = 0; 145 measure[3].imageID = 0; 146 146 147 147 return TRUE; … … 156 156 // fill in the data for a WISE quad star. takes a pointer to the start of the line the 157 157 // RA and DEC have already been set 158 int loadwise_star_allsky ( Stars **star, char *line, int Nmax) {158 int loadwise_star_allsky (Measure *measure, char *line, int Nmax) { 159 159 160 160 int i; … … 166 166 167 167 // I can assign dRA and dDEC to dX and dY if I can consistently set posangle and pltscale 168 star[0][0].measure.posangle = 0.0;169 star[0][0].measure.pltscale = 1.0;168 measure[0].posangle = 0.0; 169 measure[0].pltscale = 1.0; 170 170 171 171 ptr = skipNbounds (ptr, '|', 3, Nmax); // skip: desig, ra, dec, 172 star[0][0].measure.dXccd = ToShortPixels(strtod (ptr, NULL)); // sig_ra172 measure[0].dXccd = ToShortPixels(strtod (ptr, NULL)); // sig_ra 173 173 ptr = nextWISEfield (ptr); 174 star[0][0].measure.dYccd = ToShortPixels(strtod (ptr, NULL)); // sig_dec174 measure[0].dYccd = ToShortPixels(strtod (ptr, NULL)); // sig_dec 175 175 ptr = nextWISEfield (ptr); 176 176 177 177 // we only know a single set of values for all 4 bands 178 178 for (i = 1; i < 4; i++) { 179 star[i][0].measure.dXccd = star[0][0].measure.dXccd;180 star[i][0].measure.dYccd = star[0][0].measure.dYccd;181 star[i][0].measure.posangle = star[0][0].measure.posangle;182 star[i][0].measure.pltscale = star[0][0].measure.pltscale;179 measure[i].dXccd = measure[0].dXccd; 180 measure[i].dYccd = measure[0].dYccd; 181 measure[i].posangle = measure[0].posangle; 182 measure[i].pltscale = measure[0].pltscale; 183 183 } 184 184 ptr = skipNbounds (ptr, '|', 5, Nmax); // skip: sig_radec, glon, glat, elon, elat 185 185 186 star[0][0].measure.Xccd = strtod (ptr, NULL); // wx186 measure[0].Xccd = strtod (ptr, NULL); // wx 187 187 ptr = nextWISEfield (ptr); // skip wx 188 star[0][0].measure.Yccd = strtod (ptr, NULL); // wy188 measure[0].Yccd = strtod (ptr, NULL); // wy 189 189 ptr = nextWISEfield (ptr); // skip wy 190 190 191 191 for (i = 1; i < 4; i++) { 192 star[i][0].measure.Xccd = star[0][0].measure.Xccd;193 star[i][0].measure.Yccd = star[0][0].measure.Yccd;192 measure[i].Xccd = measure[0].Xccd; 193 measure[i].Yccd = measure[0].Yccd; 194 194 } 195 195 ptr = skipNbounds (ptr, '|', 4, Nmax); // skip: cntr, source_id, coadd_id, src … … 198 198 for (i = 0; i < 4; i++) { 199 199 char *endpoint; 200 star[i][0].measure.M = strtod (ptr, &endpoint); // w?mpro200 measure[i].M = strtod (ptr, &endpoint); // w?mpro 201 201 if (endpoint == ptr) { 202 star[i][0].measure.M = NAN;202 measure[i].M = NAN; 203 203 } 204 204 ptr = nextWISEfield (ptr); 205 star[i][0].measure.dM = strtod (ptr, &endpoint); // w?sigmpro205 measure[i].dM = strtod (ptr, &endpoint); // w?sigmpro 206 206 if (endpoint == ptr) { 207 star[i][0].measure.dM = NAN;207 measure[i].dM = NAN; 208 208 } 209 209 ptr = skipNbounds (ptr, '|', 2, Nmax); // skip: w?sigmpro, w?snr 210 star[i][0].measure.psfChisq = strtod (ptr, NULL); // w?rchi2210 measure[i].psfChisq = strtod (ptr, NULL); // w?rchi2 211 211 ptr = nextWISEfield (ptr); // skip : w1rchi2 212 212 213 213 // init the photFlags field 214 star[i][0].measure.photFlags = 0;214 measure[i].photFlags = 0; 215 215 } 216 216 … … 218 218 219 219 // set blend flags for all 4 measures 220 setWISE_blend_flag ( star, ptr); // nb & na both used here220 setWISE_blend_flag (measure, ptr); // nb & na both used here 221 221 ptr = skipNbounds (ptr, '|', 2, Nmax); // skip: nb, na 222 222 223 223 for (i = 0; i < 4; i++) { 224 setWISE_sat_flag ( star[i], ptr); // w1sat224 setWISE_sat_flag (&measure[i], ptr); // w1sat 225 225 ptr = nextWISEfield (ptr); 226 226 } … … 228 228 229 229 for (i = 0; i < 4; i++) { 230 setWISE_cc_flag ( star[i], ptr[i]); // cc_flg230 setWISE_cc_flag (&measure[i], ptr[i]); // cc_flg 231 231 } 232 232 ptr = nextWISEfield (ptr); // skip cc_flags 233 233 234 234 // set ext flags for all 4 measures 235 setWISE_ext_flag_allsky ( star, ptr[0]); // ext_flg235 setWISE_ext_flag_allsky (measure, ptr[0]); // ext_flg 236 236 ptr = nextWISEfield (ptr); // skip ext_flags 237 237 238 238 for (i = 0; i < 4; i++) { 239 setWISE_var_flag_allsky ( star[i], ptr[i]); // var_flg239 setWISE_var_flag_allsky (&measure[i], ptr[i]); // var_flg 240 240 } 241 241 ptr = nextWISEfield (ptr); // skip var_flags 242 242 243 243 for (i = 0; i < 4; i++) { 244 setWISE_ph_qual ( star[i], ptr[i]); // ph_qual244 setWISE_ph_qual (&measure[i], ptr[i]); // ph_qual 245 245 } 246 246 … … 261 261 // the release is based on data taken in the period 14 January 2010 to 29 April 2010 262 262 if (mjdmean == 0.0) { 263 star[i][0].measure.t = 0;263 measure[i].t = 0; 264 264 } else { 265 star[i][0].measure.t = ohana_mjd_to_sec (mjdmean);265 measure[i].t = ohana_mjd_to_sec (mjdmean); 266 266 } 267 267 } 268 268 269 star[0][0].measure.photcode = WISE_W1;270 star[0][0].measure.detID = 0;271 star[0][0].measure.imageID = 0;272 273 star[1][0].measure.photcode = WISE_W2;274 star[1][0].measure.detID = 0;275 star[1][0].measure.imageID = 0;276 277 star[2][0].measure.photcode = WISE_W3;278 star[2][0].measure.detID = 0;279 star[2][0].measure.imageID = 0;280 281 star[3][0].measure.photcode = WISE_W4;282 star[3][0].measure.detID = 0;283 star[3][0].measure.imageID = 0;269 measure[0].photcode = WISE_W1; 270 measure[0].detID = 0; 271 measure[0].imageID = 0; 272 273 measure[1].photcode = WISE_W2; 274 measure[1].detID = 0; 275 measure[1].imageID = 0; 276 277 measure[2].photcode = WISE_W3; 278 measure[2].detID = 0; 279 measure[2].imageID = 0; 280 281 measure[3].photcode = WISE_W4; 282 measure[3].detID = 0; 283 measure[3].imageID = 0; 284 284 285 285 return TRUE; … … 288 288 // fill in the data for a WISE quad star. takes a pointer to the start of the line the 289 289 // RA and DEC have already been set 290 int loadwise_star_prelim ( Stars **star, char *line, int Nmax) {290 int loadwise_star_prelim (Measure *measure, char *line, int Nmax) { 291 291 292 292 int i; … … 298 298 299 299 // I can assign dRA and dDEC to dX and dY if I can consistently set posangle and pltscale 300 star[0][0].measure.posangle = 0.0;301 star[0][0].measure.pltscale = 1.0;300 measure[0].posangle = 0.0; 301 measure[0].pltscale = 1.0; 302 302 303 303 ptr = skipNbounds (ptr, '|', 3, Nmax); // skip: desig, ra, dec, 304 star[0][0].measure.dXccd = ToShortPixels(strtod (ptr, NULL)); // sig_ra304 measure[0].dXccd = ToShortPixels(strtod (ptr, NULL)); // sig_ra 305 305 ptr = nextWISEfield (ptr); 306 star[0][0].measure.dYccd = ToShortPixels(strtod (ptr, NULL)); // sig_dec306 measure[0].dYccd = ToShortPixels(strtod (ptr, NULL)); // sig_dec 307 307 ptr = nextWISEfield (ptr); 308 308 309 309 // we only know a single set of values for all 4 bands 310 310 for (i = 1; i < 4; i++) { 311 star[i][0].measure.dXccd = star[0][0].measure.dXccd;312 star[i][0].measure.dYccd = star[0][0].measure.dYccd;313 star[i][0].measure.posangle = star[0][0].measure.posangle;314 star[i][0].measure.pltscale = star[0][0].measure.pltscale;311 measure[i].dXccd = measure[0].dXccd; 312 measure[i].dYccd = measure[0].dYccd; 313 measure[i].posangle = measure[0].posangle; 314 measure[i].pltscale = measure[0].pltscale; 315 315 } 316 316 ptr = skipNbounds (ptr, '|', 5, Nmax); // skip: sig_radec, glon, glat, elon, elat 317 317 318 star[0][0].measure.Xccd = strtod (ptr, NULL); // wx318 measure[0].Xccd = strtod (ptr, NULL); // wx 319 319 ptr = nextWISEfield (ptr); // skip wx 320 star[0][0].measure.Yccd = strtod (ptr, NULL); // wy320 measure[0].Yccd = strtod (ptr, NULL); // wy 321 321 ptr = nextWISEfield (ptr); // skip wy 322 322 323 323 for (i = 1; i < 4; i++) { 324 star[i][0].measure.Xccd = star[0][0].measure.Xccd;325 star[i][0].measure.Yccd = star[0][0].measure.Yccd;324 measure[i].Xccd = measure[0].Xccd; 325 measure[i].Yccd = measure[0].Yccd; 326 326 } 327 327 ptr = skipNbounds (ptr, '|', 4, Nmax); // skip: cntr, source_id, coadd_id, src … … 329 329 // W1 330 330 for (i = 0; i < 4; i++) { 331 star[i][0].measure.M = strtod (ptr, NULL); // w?mpro331 measure[i].M = strtod (ptr, NULL); // w?mpro 332 332 ptr = nextWISEfield (ptr); 333 star[i][0].measure.dM = strtod (ptr, NULL); // w?sigmpro333 measure[i].dM = strtod (ptr, NULL); // w?sigmpro 334 334 ptr = skipNbounds (ptr, '|', 2, Nmax); // skip: w?sigmpro, w?snr 335 star[i][0].measure.psfChisq = strtod (ptr, NULL); // w?rchi2335 measure[i].psfChisq = strtod (ptr, NULL); // w?rchi2 336 336 ptr = nextWISEfield (ptr); // skip : w1rchi2 337 337 338 338 // init the photFlags field 339 star[i][0].measure.photFlags = 0;339 measure[i].photFlags = 0; 340 340 } 341 341 … … 343 343 344 344 // set blend flags for all 4 measures 345 setWISE_blend_flag ( star, ptr); // nb & na both used here345 setWISE_blend_flag (measure, ptr); // nb & na both used here 346 346 ptr = skipNbounds (ptr, '|', 2, Nmax); // skip: nb, na 347 347 348 348 for (i = 0; i < 4; i++) { 349 setWISE_sat_flag ( star[i], ptr); // w1sat349 setWISE_sat_flag (&measure[i], ptr); // w1sat 350 350 ptr = nextWISEfield (ptr); 351 351 } … … 353 353 354 354 for (i = 0; i < 4; i++) { 355 setWISE_cc_flag ( star[i], ptr[i]); // cc_flg355 setWISE_cc_flag (&measure[i], ptr[i]); // cc_flg 356 356 } 357 357 ptr = nextWISEfield (ptr); // skip cc_flags 358 358 359 359 // set ext flags for all 4 measures 360 setWISE_ext_flag_prelim ( star, *ptr); // ext_flg360 setWISE_ext_flag_prelim (measure, *ptr); // ext_flg 361 361 ptr = nextWISEfield (ptr); // skip ext_flags 362 362 363 363 for (i = 0; i < 4; i++) { 364 setWISE_var_flag_prelim ( star[i], ptr[i]); // var_flg364 setWISE_var_flag_prelim (&measure[i], ptr[i]); // var_flg 365 365 } 366 366 ptr = nextWISEfield (ptr); // skip var_flags 367 367 368 368 for (i = 0; i < 4; i++) { 369 setWISE_ph_qual ( star[i], ptr[i]); // ph_qual369 setWISE_ph_qual (&measure[i], ptr[i]); // ph_qual 370 370 } 371 371 372 372 double jd = 2455263.0; // NOTE : WISE prelim release does not contain per-detection time info. 373 373 // the release is based on data taken in the period 14 January 2010 to 29 April 2010 374 star[0][0].measure.t = ohana_jd_to_sec (jd);375 star[1][0].measure.t = star[0][0].measure.t;376 star[2][0].measure.t = star[0][0].measure.t;377 star[3][0].measure.t = star[0][0].measure.t;378 379 star[0][0].measure.photcode = WISE_W1;380 star[0][0].measure.detID = 0;381 star[0][0].measure.imageID = 0;382 383 star[1][0].measure.photcode = WISE_W2;384 star[1][0].measure.detID = 0;385 star[1][0].measure.imageID = 0;386 387 star[2][0].measure.photcode = WISE_W3;388 star[2][0].measure.detID = 0;389 star[2][0].measure.imageID = 0;390 391 star[3][0].measure.photcode = WISE_W4;392 star[3][0].measure.detID = 0;393 star[3][0].measure.imageID = 0;374 measure[0].t = ohana_jd_to_sec (jd); 375 measure[1].t = measure[0].t; 376 measure[2].t = measure[0].t; 377 measure[3].t = measure[0].t; 378 379 measure[0].photcode = WISE_W1; 380 measure[0].detID = 0; 381 measure[0].imageID = 0; 382 383 measure[1].photcode = WISE_W2; 384 measure[1].detID = 0; 385 measure[1].imageID = 0; 386 387 measure[2].photcode = WISE_W3; 388 measure[2].detID = 0; 389 measure[2].imageID = 0; 390 391 measure[3].photcode = WISE_W4; 392 measure[3].detID = 0; 393 measure[3].imageID = 0; 394 394 395 395 return TRUE; … … 436 436 # define FLAG_VARIABLE_LEVEL3 0x40000000 // var_flg == 8 or 9 437 437 438 int setWISE_blend_flag ( Stars **star, char *ptr) {438 int setWISE_blend_flag (Measure *measure, char *ptr) { 439 439 440 440 int nb = atoi (ptr); … … 445 445 446 446 if (na == 0) { 447 star[0][0].measure.photFlags |= FLAG_BLEND_ACTIVE;448 star[1][0].measure.photFlags |= FLAG_BLEND_ACTIVE;449 star[2][0].measure.photFlags |= FLAG_BLEND_ACTIVE;450 star[3][0].measure.photFlags |= FLAG_BLEND_ACTIVE;447 measure[0].photFlags |= FLAG_BLEND_ACTIVE; 448 measure[1].photFlags |= FLAG_BLEND_ACTIVE; 449 measure[2].photFlags |= FLAG_BLEND_ACTIVE; 450 measure[3].photFlags |= FLAG_BLEND_ACTIVE; 451 451 } else { 452 star[0][0].measure.photFlags |= FLAG_BLEND_PASSIVE;453 star[1][0].measure.photFlags |= FLAG_BLEND_PASSIVE;454 star[2][0].measure.photFlags |= FLAG_BLEND_PASSIVE;455 star[3][0].measure.photFlags |= FLAG_BLEND_PASSIVE;452 measure[0].photFlags |= FLAG_BLEND_PASSIVE; 453 measure[1].photFlags |= FLAG_BLEND_PASSIVE; 454 measure[2].photFlags |= FLAG_BLEND_PASSIVE; 455 measure[3].photFlags |= FLAG_BLEND_PASSIVE; 456 456 } 457 457 return TRUE; 458 458 } 459 459 460 int setWISE_sat_flag ( Stars *star, char *ptr) {460 int setWISE_sat_flag (Measure *measure, char *ptr) { 461 461 462 462 float sat = strtod (ptr, NULL); 463 463 if (sat > 0.0) { 464 star[0].measure.photFlags |= FLAG_SATURATED_PIX;464 measure[0].photFlags |= FLAG_SATURATED_PIX; 465 465 } 466 466 return TRUE; 467 467 } 468 468 469 int setWISE_cc_flag ( Stars *star, char qual) {469 int setWISE_cc_flag (Measure *measure, char qual) { 470 470 471 471 switch (qual) { 472 case 'p': star[0].measure.photFlags |= FLAG_CC_PERSIST; break;473 case 'h': star[0].measure.photFlags |= FLAG_CC_HALO; break;474 case 'd': star[0].measure.photFlags |= FLAG_CC_SPIKE; break;475 case 'o': star[0].measure.photFlags |= FLAG_CC_GHOST; break;476 477 case 'P': star[0].measure.photFlags |= FLAG_CC_PERSIST | FLAG_CC_SPURIOUS; break;478 case 'H': star[0].measure.photFlags |= FLAG_CC_HALO | FLAG_CC_SPURIOUS; break;479 case 'D': star[0].measure.photFlags |= FLAG_CC_SPIKE | FLAG_CC_SPURIOUS; break;480 case 'O': star[0].measure.photFlags |= FLAG_CC_GHOST | FLAG_CC_SPURIOUS; break;472 case 'p': measure[0].photFlags |= FLAG_CC_PERSIST; break; 473 case 'h': measure[0].photFlags |= FLAG_CC_HALO; break; 474 case 'd': measure[0].photFlags |= FLAG_CC_SPIKE; break; 475 case 'o': measure[0].photFlags |= FLAG_CC_GHOST; break; 476 477 case 'P': measure[0].photFlags |= FLAG_CC_PERSIST | FLAG_CC_SPURIOUS; break; 478 case 'H': measure[0].photFlags |= FLAG_CC_HALO | FLAG_CC_SPURIOUS; break; 479 case 'D': measure[0].photFlags |= FLAG_CC_SPIKE | FLAG_CC_SPURIOUS; break; 480 case 'O': measure[0].photFlags |= FLAG_CC_GHOST | FLAG_CC_SPURIOUS; break; 481 481 482 482 case '0': break; … … 487 487 } 488 488 489 int setWISE_ext_flag_allsky ( Stars **star, char value) {489 int setWISE_ext_flag_allsky (Measure *measure, char value) { 490 490 491 491 switch (value) { … … 493 493 return TRUE; 494 494 case '1': 495 star[0][0].measure.photFlags |= FLAG_EXTENDED;496 star[1][0].measure.photFlags |= FLAG_EXTENDED;497 star[2][0].measure.photFlags |= FLAG_EXTENDED;498 star[3][0].measure.photFlags |= FLAG_EXTENDED;495 measure[0].photFlags |= FLAG_EXTENDED; 496 measure[1].photFlags |= FLAG_EXTENDED; 497 measure[2].photFlags |= FLAG_EXTENDED; 498 measure[3].photFlags |= FLAG_EXTENDED; 499 499 return TRUE; 500 500 case '2': 501 star[0][0].measure.photFlags |= FLAG_EXT_IN_XSC;502 star[1][0].measure.photFlags |= FLAG_EXT_IN_XSC;503 star[2][0].measure.photFlags |= FLAG_EXT_IN_XSC;504 star[3][0].measure.photFlags |= FLAG_EXT_IN_XSC;501 measure[0].photFlags |= FLAG_EXT_IN_XSC; 502 measure[1].photFlags |= FLAG_EXT_IN_XSC; 503 measure[2].photFlags |= FLAG_EXT_IN_XSC; 504 measure[3].photFlags |= FLAG_EXT_IN_XSC; 505 505 return TRUE; 506 506 case '3': 507 star[0][0].measure.photFlags |= FLAG_EXTENDED | FLAG_EXT_IN_XSC;508 star[1][0].measure.photFlags |= FLAG_EXTENDED | FLAG_EXT_IN_XSC;509 star[2][0].measure.photFlags |= FLAG_EXTENDED | FLAG_EXT_IN_XSC;510 star[3][0].measure.photFlags |= FLAG_EXTENDED | FLAG_EXT_IN_XSC;507 measure[0].photFlags |= FLAG_EXTENDED | FLAG_EXT_IN_XSC; 508 measure[1].photFlags |= FLAG_EXTENDED | FLAG_EXT_IN_XSC; 509 measure[2].photFlags |= FLAG_EXTENDED | FLAG_EXT_IN_XSC; 510 measure[3].photFlags |= FLAG_EXTENDED | FLAG_EXT_IN_XSC; 511 511 return TRUE; 512 512 case '4': 513 star[0][0].measure.photFlags |= FLAG_EXT_BY_XSC;514 star[1][0].measure.photFlags |= FLAG_EXT_BY_XSC;515 star[2][0].measure.photFlags |= FLAG_EXT_BY_XSC;516 star[3][0].measure.photFlags |= FLAG_EXT_BY_XSC;513 measure[0].photFlags |= FLAG_EXT_BY_XSC; 514 measure[1].photFlags |= FLAG_EXT_BY_XSC; 515 measure[2].photFlags |= FLAG_EXT_BY_XSC; 516 measure[3].photFlags |= FLAG_EXT_BY_XSC; 517 517 return TRUE; 518 518 case '5': 519 star[0][0].measure.photFlags |= FLAG_EXTENDED | FLAG_EXT_BY_XSC;520 star[1][0].measure.photFlags |= FLAG_EXTENDED | FLAG_EXT_BY_XSC;521 star[2][0].measure.photFlags |= FLAG_EXTENDED | FLAG_EXT_BY_XSC;522 star[3][0].measure.photFlags |= FLAG_EXTENDED | FLAG_EXT_BY_XSC;519 measure[0].photFlags |= FLAG_EXTENDED | FLAG_EXT_BY_XSC; 520 measure[1].photFlags |= FLAG_EXTENDED | FLAG_EXT_BY_XSC; 521 measure[2].photFlags |= FLAG_EXTENDED | FLAG_EXT_BY_XSC; 522 measure[3].photFlags |= FLAG_EXTENDED | FLAG_EXT_BY_XSC; 523 523 return TRUE; 524 524 default: … … 529 529 } 530 530 531 int setWISE_ext_flag_prelim ( Stars **star, char value) {531 int setWISE_ext_flag_prelim (Measure *measure, char value) { 532 532 533 533 switch (value) { … … 535 535 return TRUE; 536 536 case '1': 537 star[0][0].measure.photFlags |= FLAG_EXTENDED;538 star[1][0].measure.photFlags |= FLAG_EXTENDED;539 star[2][0].measure.photFlags |= FLAG_EXTENDED;540 star[3][0].measure.photFlags |= FLAG_EXTENDED;537 measure[0].photFlags |= FLAG_EXTENDED; 538 measure[1].photFlags |= FLAG_EXTENDED; 539 measure[2].photFlags |= FLAG_EXTENDED; 540 measure[3].photFlags |= FLAG_EXTENDED; 541 541 return TRUE; 542 542 default: … … 548 548 549 549 // NOTE: var flag definition changed slightly between prelim & allsky 550 int setWISE_var_flag_allsky ( Stars *star, char qual) {550 int setWISE_var_flag_allsky (Measure *measure, char qual) { 551 551 552 552 switch (qual) { … … 559 559 case '4': 560 560 case '5': 561 star[0].measure.photFlags |= FLAG_VARIABLE_LEVEL1;561 measure[0].photFlags |= FLAG_VARIABLE_LEVEL1; 562 562 return TRUE; 563 563 case '6': 564 564 case '7': 565 star[0].measure.photFlags |= FLAG_VARIABLE_LEVEL2;565 measure[0].photFlags |= FLAG_VARIABLE_LEVEL2; 566 566 return TRUE; 567 567 case '8': 568 568 case '9': 569 star[0].measure.photFlags |= FLAG_VARIABLE_LEVEL3;569 measure[0].photFlags |= FLAG_VARIABLE_LEVEL3; 570 570 return TRUE; 571 571 default: … … 575 575 } 576 576 577 int setWISE_var_flag_prelim ( Stars *star, char qual) {577 int setWISE_var_flag_prelim (Measure *measure, char qual) { 578 578 579 579 switch (qual) { … … 584 584 case '3': 585 585 case '4': 586 star[0].measure.photFlags |= FLAG_VARIABLE_LEVEL1;586 measure[0].photFlags |= FLAG_VARIABLE_LEVEL1; 587 587 return TRUE; 588 588 case '5': 589 589 case '6': 590 590 case '7': 591 star[0].measure.photFlags |= FLAG_VARIABLE_LEVEL2;591 measure[0].photFlags |= FLAG_VARIABLE_LEVEL2; 592 592 return TRUE; 593 593 case '8': 594 594 case '9': 595 star[0].measure.photFlags |= FLAG_VARIABLE_LEVEL3;595 measure[0].photFlags |= FLAG_VARIABLE_LEVEL3; 596 596 return TRUE; 597 597 default: … … 601 601 } 602 602 603 int setWISE_ph_qual ( Stars *star, char qual) {603 int setWISE_ph_qual (Measure *measure, char qual) { 604 604 605 605 switch (qual) { 606 case 'A': star[0].measure.photFlags |= FLAG_PH_A; break;607 case 'B': star[0].measure.photFlags |= FLAG_PH_B; break;608 case 'C': star[0].measure.photFlags |= FLAG_PH_C; break;609 case 'U': star[0].measure.photFlags |= FLAG_PH_U; break;610 case 'X': star[0].measure.photFlags |= FLAG_PH_X; break;611 case 'Z': star[0].measure.photFlags |= FLAG_PH_Z; break;606 case 'A': measure[0].photFlags |= FLAG_PH_A; break; 607 case 'B': measure[0].photFlags |= FLAG_PH_B; break; 608 case 'C': measure[0].photFlags |= FLAG_PH_C; break; 609 case 'U': measure[0].photFlags |= FLAG_PH_U; break; 610 case 'X': measure[0].photFlags |= FLAG_PH_X; break; 611 case 'Z': measure[0].photFlags |= FLAG_PH_Z; break; 612 612 default: 613 613 fprintf (stderr, "error in ph_flag: %c\n", qual); -
trunk/Ohana/src/addstar/src/replace_match.c
r37036 r38986 1 1 # include "addstar.h" 2 2 3 int replace_match (Average *average, Measure *measure, Stars *star) {3 int replace_match (Average *average, Measure *measure, Measure *newmeas, off_t *found) { 4 4 5 5 int i, j, m; … … 11 11 for (i = 0; i < average[0].Nmeasure; i++) { 12 12 j = i + m; 13 if (measure[j].photcode != star[0].measure.photcode) continue;14 measure[j].R = star[0].average.R;15 measure[j].D = star[0].average.D;16 measure[j].M = star[0].measure.M;17 measure[j].dM = star[0].measure.dM;18 star[0].found = average[0].measureOffset + i;13 if (measure[j].photcode != newmeas->photcode) continue; 14 measure[j].R = newmeas->R; 15 measure[j].D = newmeas->D; 16 measure[j].M = newmeas->M; 17 measure[j].dM = newmeas->dM; 18 *found = average[0].measureOffset + i; 19 19 return (TRUE); 20 20 } -
trunk/Ohana/src/addstar/src/resort_catalog.c
r38638 r38986 55 55 // earlier formats did not carry the objID or catID, so they are not available (we could assign on load, but we don't) 56 56 myAssert(average[averageSeq[i]].catID == measure[measureSeq[i]].catID, "object / detection mismatch"); 57 # if (1)58 57 myAssert (average[averageSeq[i]].objID == measure[measureSeq[i]].objID, "object ID mismatch?"); 59 # endif60 58 # if (0) 61 59 // myAssert(average[averageSeq[i]].objID == measure[measureSeq[i]].objID, "object / detection mismatch"); 62 // check if the objID is correct. if not, check if it is byte-swapped (this has happened) and repair if so. 63 // otherwise, abort60 61 // Check some possible causes for objID failures 64 62 if (average[averageSeq[i]].objID != measure[measureSeq[i]].objID) { 65 63 fprintf (stderr, "object / detection mismatch average.objID = %d, measure.objID = %d, catID: %d, detID: %d", 66 64 average[averageSeq[i]].objID, measure[measureSeq[i]].objID, 67 65 measure[measureSeq[i]].catID, measure[measureSeq[i]].detID); 66 // is the byte-swapped value the correct objID? 68 67 int objIDalt = measure[measureSeq[i]].objID; 69 68 char *byte = (char *) &objIDalt; … … 72 71 tmp = byte[1]; byte[1] = byte[2]; byte[2] = tmp; 73 72 if (average[averageSeq[i]].objID == objIDalt) { 74 fprintf (stderr, "objID is byte-swapped, repairing\n"); 75 measure[measureSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this... 76 } else if (measure[measureSeq[i]].objID == 0) { 77 fprintf (stderr, "objID is 0, repairing\n"); 78 measure[measureSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this... 73 myAbort ("measure.objID is byte-swapped, consider repairing\n"); 74 // measure[measureSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this... 75 } 76 if (measure[measureSeq[i]].objID == 0) { 77 myAbort ("measure.objID is 0, repairing\n"); 78 // measure[measureSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this... 79 79 } else { 80 myAbort ("objID is NOT byte-swapped , aborting\n");80 myAbort ("objID is NOT byte-swapped and NOT 0, aborting\n"); 81 81 } 82 82 } -
trunk/Ohana/src/addstar/src/resort_threaded.c
r38636 r38986 81 81 // write out catalog, if appropriate 82 82 SetProtect (TRUE); 83 dvo_catalog_save (&catalog, VERBOSE); 83 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 84 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 84 85 SetProtect (FALSE); 85 dvo_catalog_unlock (&catalog); 86 86 87 dvo_catalog_free (&catalog); 87 88 threadData->state = TS_DONE; -
trunk/Ohana/src/addstar/src/resort_unthreaded.c
r38636 r38986 52 52 // write out catalog, if appropriate 53 53 SetProtect (TRUE); 54 dvo_catalog_save (&catalog, VERBOSE); 54 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 55 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 55 56 SetProtect (FALSE); 56 dvo_catalog_unlock (&catalog); 57 57 58 dvo_catalog_free (&catalog); 58 59 } -
trunk/Ohana/src/addstar/src/sedstar.c
r38471 r38986 12 12 13 13 // need to construct these options with args_load2mass... 14 SetSignals (); 14 15 options = ConfigInit (&argc, argv); 15 16 options = args_sedstar (argc, argv, options); … … 64 65 SEDfitCatalog (&outcatalog, &incatalog, sedtable); 65 66 66 dvo_catalog_save (&outcatalog, VERBOSE); 67 dvo_catalog_unlock (&outcatalog); 67 SetProtect (TRUE); 68 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", outcatalog.filename); exit (1); } 69 if (!dvo_catalog_unlock (&outcatalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", outcatalog.filename); exit (1); } 70 SetProtect (FALSE); 68 71 dvo_catalog_free (&outcatalog); 69 72 -
trunk/Ohana/src/addstar/test
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20150625/Ohana/src/addstar/test merged: 38983
- Property svn:mergeinfo changed
-
trunk/Ohana/src/delstar/src/Shutdown.c
r35758 r38986 21 21 va_end (argp); 22 22 23 SetProtect (TRUE);24 if (db) gfits_db_close (db);25 23 fprintf (stderr, "ERROR: delstar halted\n"); 26 24 exit (1); -
trunk/Ohana/src/delstar/src/delete_duplicate_images.c
r38471 r38986 131 131 132 132 if (UPDATE) { 133 SetProtect (TRUE); 133 134 dvo_catalog_save_complete (&catalog, VERBOSE2); 134 135 } 135 136 136 dvo_catalog_unlock (&catalog); 137 SetProtect (FALSE); 138 137 139 dvo_catalog_free (&catalog); 138 140 } -
trunk/Ohana/src/delstar/src/delete_duplicate_measures.c
r38471 r38986 66 66 // skip if nothing was deleted 67 67 if (UPDATE) { 68 if (!dvo_catalog_backup (&catalog, TRUE)) {68 if (!dvo_catalog_backup (&catalog, "~", TRUE)) { 69 69 fprintf (stderr, "ERROR: failed to make backup for catalog %s\n", catalog.filename); 70 70 exit (1); 71 71 } 72 SetProtect (TRUE); 72 73 dvo_catalog_save_complete (&catalog, VERBOSE2); 73 74 } 74 75 } 75 76 76 dvo_catalog_unlock (&catalog); 77 SetProtect (FALSE); 78 77 79 dvo_catalog_free (&catalog); 78 80 } -
trunk/Ohana/src/delstar/src/delete_fix_LAP.c
r38471 r38986 68 68 int noChange = (NaverageStart == catalog.Naverage) && (NmeasureStart == catalog.Nmeasure); 69 69 if (UPDATE && !noChange) { 70 SetProtect (TRUE); 70 71 dvo_catalog_save_complete (&catalog, VERBOSE2); 71 72 } 72 73 73 dvo_catalog_unlock (&catalog); 74 SetProtect (FALSE); 75 74 76 dvo_catalog_free (&catalog); 75 77 } -
trunk/Ohana/src/delstar/src/delete_fix_LAP_edges_delete.c
r38471 r38986 117 117 if (UPDATE && !noChange) { 118 118 // XXX save a backup copy first 119 // dvo_catalog_backup (&catalog, TRUE); 119 // dvo_catalog_backup (&catalog, "~", TRUE); 120 SetProtect (TRUE); 120 121 dvo_catalog_save_complete (&catalog, VERBOSE2); 121 122 } 122 123 123 dvo_catalog_unlock (&catalog); 124 SetProtect (FALSE); 125 124 126 dvo_catalog_free (&catalog); 125 127 } -
trunk/Ohana/src/delstar/src/delete_imagefile.c
r38471 r38986 48 48 find_matches (&catalog, image[0].photcode, start, stop); 49 49 50 dvo_catalog_save (&catalog, VERBOSE); 51 dvo_catalog_unlock (&catalog); 50 SetProtect (TRUE); 51 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 52 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 53 SetProtect (FALSE); 52 54 dvo_catalog_free (&catalog); 53 55 } -
trunk/Ohana/src/delstar/src/delete_imagename.c
r38471 r38986 62 62 find_matches (&catalog, image[j].photcode, start, stop); 63 63 64 SetProtect (TRUE); 64 65 dvo_catalog_save_complete (&catalog, VERBOSE); 65 66 dvo_catalog_unlock (&catalog); 67 SetProtect (FALSE); 66 68 dvo_catalog_free (&catalog); 67 69 } -
trunk/Ohana/src/delstar/src/delete_photcodes.c
r38471 r38986 60 60 61 61 delete_photcodes_catalog (&catalog, photcodes, Nphotcodes); 62 SetProtect (TRUE); 62 63 dvo_catalog_save_complete (&catalog, VERBOSE2); 63 64 dvo_catalog_unlock (&catalog); 65 SetProtect (FALSE); 64 66 dvo_catalog_free (&catalog); 65 67 } -
trunk/Ohana/src/delstar/src/delete_photcodes_single.c
r38471 r38986 28 28 29 29 delete_photcodes_catalog (&catalog, photcodes, Nphotcodes); 30 SetProtect (TRUE); 30 31 dvo_catalog_save_complete (&catalog, VERBOSE2); 31 32 dvo_catalog_unlock (&catalog); 33 SetProtect (FALSE); 32 34 dvo_catalog_free (&catalog); 33 35 return TRUE; -
trunk/Ohana/src/delstar/src/delete_times.c
r38471 r38986 77 77 78 78 find_matches (&catalog, code, START, END); 79 dvo_catalog_save (&catalog, VERBOSE); 80 dvo_catalog_unlock (&catalog); 79 SetProtect (TRUE); 80 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 81 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 82 SetProtect (FALSE); 81 83 dvo_catalog_free (&catalog); 82 84 } -
trunk/Ohana/src/dvolens/include/dvolens.h
r38153 r38986 68 68 int main PROTO((int argc, char **argv)); 69 69 70 void update_objects PROTO(( ));70 void update_objects PROTO((void)); 71 71 int update_objects_parallel PROTO((SkyList *sky)); 72 72 int update_objects_catalog PROTO((Catalog *catalog)); -
trunk/Ohana/src/dvolens/src/dvolens.c
r37358 r38986 4 4 5 5 // get configuration info, args 6 SetSignals (); 6 7 DvoLensMode mode = initialize (argc, argv); 7 8 if (!mode) exit (2); -
trunk/Ohana/src/dvolens/src/update_objects.c
r38471 r38986 94 94 95 95 SetProtect (TRUE); 96 dvo_catalog_save (&catalog, VERBOSE);97 dvo_catalog_unlock (&catalog);96 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 97 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 98 98 SetProtect (FALSE); 99 99 -
trunk/Ohana/src/dvomerge/Makefile
r38468 r38986 40 40 $(SRC)/dvo_image_merge_dbs.$(ARCH).o \ 41 41 $(SRC)/IDmapIO.$(ARCH).o \ 42 $(SRC)/ConfigInit.$(ARCH).o \ 42 43 $(SRC)/SetSignals.$(ARCH).o \ 43 $(SRC)/ConfigInit.$(ARCH).o \44 44 $(SRC)/Shutdown.$(ARCH).o \ 45 45 $(SRC)/help.$(ARCH).o \ … … 51 51 $(SRC)/replace_match.$(ARCH).o \ 52 52 $(SRC)/replace_tycho.$(ARCH).o \ 53 $(SRC)/repair_catalog_by_objID.$(ARCH).o \ 53 54 $(SRC)/merge_catalogs_new.$(ARCH).o \ 54 55 $(SRC)/merge_catalogs_old.$(ARCH).o … … 75 76 $(SRC)/replace_match.$(ARCH).o \ 76 77 $(SRC)/replace_tycho.$(ARCH).o \ 78 $(SRC)/repair_catalog_by_objID.$(ARCH).o \ 77 79 $(SRC)/merge_catalogs_new.$(ARCH).o \ 78 80 $(SRC)/merge_catalogs_old.$(ARCH).o … … 122 124 $(SRC)/dvorepair.$(ARCH).o \ 123 125 $(SRC)/dvorepairFixCPT.$(ARCH).o \ 126 $(SRC)/dvorepairFixWarpIDs.$(ARCH).o \ 124 127 $(SRC)/dvorepairImagesVsMeasures.$(ARCH).o \ 125 128 $(SRC)/dvorepairDeleteImageList.$(ARCH).o \ … … 127 130 $(SRC)/dvorepairDeleteImagesByExternID.$(ARCH).o \ 128 131 $(SRC)/dvorepairFixImages.$(ARCH).o \ 132 $(SRC)/dvorepair_by_objID.$(ARCH).o \ 133 $(SRC)/repair_catalog_by_objID.$(ARCH).o \ 129 134 $(SRC)/psps_ids.$(ARCH).o \ 130 135 $(SRC)/LoadImages.$(ARCH).o \ 131 136 $(SRC)/ReadDeleteList.$(ARCH).o \ 132 137 $(SRC)/ReadDeleteListExternID.$(ARCH).o \ 138 $(SRC)/SetSignals.$(ARCH).o \ 139 $(SRC)/Shutdown.$(ARCH).o \ 133 140 $(SRC)/myIndex.$(ARCH).o \ 134 141 $(SRC)/match_image.$(ARCH).o \ … … 140 147 141 148 DVOVERIFY = \ 149 $(SRC)/SetSignals.$(ARCH).o \ 150 $(SRC)/Shutdown.$(ARCH).o \ 142 151 $(SRC)/dvoverify.$(ARCH).o \ 143 152 $(SRC)/dvoverify_args.$(ARCH).o \ … … 149 158 150 159 DVOVERIFY_CLIENT = \ 160 $(SRC)/SetSignals.$(ARCH).o \ 161 $(SRC)/Shutdown.$(ARCH).o \ 151 162 $(SRC)/dvoverify_client.$(ARCH).o \ 152 163 $(SRC)/dvoverify_args.$(ARCH).o \ … … 158 169 159 170 DVOUTILS = \ 171 $(SRC)/SetSignals.$(ARCH).o \ 172 $(SRC)/Shutdown.$(ARCH).o \ 160 173 $(SRC)/dvoutils.$(ARCH).o \ 161 174 $(SRC)/dvoutils_args.$(ARCH).o \ -
trunk/Ohana/src/dvomerge/include/dvomerge.h
r38553 r38986 47 47 48 48 int MATCHED_TABLES; 49 int REPAIR_BY_OBJID; 49 50 50 51 char *SINGLE_CPT; … … 202 203 int dvomergeUpdate_catalogs PROTO((char *input, char *output, SkyTable *outsky, SkyList *inlist, int NsecfiltInput, int NsecfiltOutput, IDmapType *IDmap, int *secfiltMap)); 203 204 204 int replace_match PROTO((Average *average_out, Measure *measure_out, Average *average_in, Measure *measure_in));205 int replace_match PROTO((Average *average_out, Measure *measure_out, off_t *next_meas, Average *average_in, Measure *measure_in)); 205 206 206 207 int IDmapSave PROTO((char *filename, IDmapType *IDmap)); … … 241 242 242 243 void replace_tycho_init (); 243 int replace_tycho (Average *averageInp, Measure *measureInp, Average *averageOut, Measure *measureOut); 244 int replace_tycho (Average *averageInp, Measure *measureInp, off_t *next_meas, Average *averageOut, Measure *measureOut); 245 int repair_catalog_by_objID (Catalog *catalog); 246 247 int dvorepair_by_objID (int argc, char **argv); 248 int dvorepairFixWarpIDs (int argc, char **argv); 249 -
trunk/Ohana/src/dvomerge/include/dvoutils.h
r37807 r38986 22 22 } DVOUTILS_OP_TYPE; 23 23 24 typedef struct { 25 int *externID; 26 short *photcode; 27 int Nimages; 28 } ImageData; 29 24 30 int VERBOSE; 25 31 int DVOUTILS_OP; … … 30 36 int dvoutils_args (int *argc, char **argv); 31 37 int dvoutils_uniq_images (char *filename); 32 int *dvoutils_load_image_index (char *filename, int *nindex); 38 39 ImageData *dvoutils_load_image_index (char *filename); 33 40 34 41 Image *dvoutils_load_image_table (char *filename, int *nimage); 42 43 int SetSignals PROTO((void)); 44 void SetProtect PROTO((int mode)); 45 void TrapSignal PROTO((int sig)); 46 int Shutdown PROTO((char *format, ...)) OHANA_FORMAT(printf, 1, 2); 47 -
trunk/Ohana/src/dvomerge/include/dvoverify.h
r38553 r38986 37 37 int LIST_MISSING; 38 38 39 int IGNORE_SORTED_STATE; 40 39 41 SkyRegion UserPatch; 40 42 … … 62 64 63 65 void FreeImageIDs (void); 66 67 int SetSignals PROTO((void)); 68 void SetProtect PROTO((int mode)); 69 void TrapSignal PROTO((int sig)); 70 int Shutdown PROTO((char *format, ...)) OHANA_FORMAT(printf, 1, 2); 71 -
trunk/Ohana/src/dvomerge/src/LoadCatalog.c
r38471 r38986 9 9 10 10 // always load all of the data (if any exists) 11 catalog[0].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ | DVO_LOAD_STARPAR | DVO_LOAD_GALPHOT; 11 // XXXX TEMP HACK : skip GALPHOT 12 // XXXX catalog[0].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ | DVO_LOAD_STARPAR | DVO_LOAD_GALPHOT; 13 catalog[0].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ | DVO_LOAD_STARPAR; 12 14 13 15 catalog[0].catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data -
trunk/Ohana/src/dvomerge/src/ReadDeleteListExternID.c
r37807 r38986 47 47 // confirm we have 9 fields broken by 8 spaces: 48 48 space = c0; // pointer to track the space-separated words 49 indexPoint = c0; // pointer to the ID on this line49 indexPoint = strchr(c0, ' '); // pointer to the ID on this line 50 50 51 for (j = 0; j < 8; j++) {51 for (j = 0; j < 9; j++) { 52 52 space = strchr(space, ' '); 53 53 if (!space) { … … 62 62 indexList[Nindex] = index; 63 63 64 //fprintf (stderr, "index: %d, line: %s\n", index, c0);64 fprintf (stderr, "index: %d, line: %s\n", index, c0); 65 65 66 66 Nindex ++; -
trunk/Ohana/src/dvomerge/src/args.c
r38553 r38986 94 94 if ((N = get_argument (*argc, argv, "-replace-tycho"))) { 95 95 REPLACE_TYCHO = TRUE; 96 remove_argument (N, argc, argv); 97 } 98 99 REPAIR_BY_OBJID = FALSE; 100 if ((N = get_argument (*argc, argv, "-repair-by-objid"))) { 101 REPAIR_BY_OBJID = TRUE; 96 102 remove_argument (N, argc, argv); 97 103 } … … 266 272 } 267 273 274 REPAIR_BY_OBJID = FALSE; 275 if ((N = get_argument (*argc, argv, "-repair-by-objid"))) { 276 REPAIR_BY_OBJID = TRUE; 277 remove_argument (N, argc, argv); 278 } 279 268 280 NTHREADS = 0; 269 281 if ((N = get_argument (*argc, argv, "-threads"))) { -
trunk/Ohana/src/dvomerge/src/build_links.c
r37814 r38986 145 145 n = average[i].measureOffset; 146 146 average[i].measureOffset = N; 147 int myObjID = average[i].objID; 147 148 for (k = 0; k < average[i].Nmeasure; k++, N++) { 148 149 if (n == -1) abort(); 149 150 tmpmeasure[N] = measure[n]; 150 if (measure[n].averef != i) abort(); 151 myAssert (measure[n].averef == i, "error in averef?"); 152 myAssert (measure[n].objID == myObjID, "error in objID?"); 151 153 tmpmeasure[N].averef = i; 152 154 n = next_meas[n]; -
trunk/Ohana/src/dvomerge/src/dvoconvert.c
r38441 r38986 94 94 95 95 outcatalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 96 97 SetProtect (TRUE); 98 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", outcatalog.filename); exit (1); } 99 if (!dvo_catalog_unlock (&outcatalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", outcatalog.filename); exit (1); } 100 SetProtect (FALSE); 101 96 102 dvo_catalog_save (&outcatalog, VERBOSE); 97 103 dvo_catalog_unlock (&outcatalog); -
trunk/Ohana/src/dvomerge/src/dvomergeContinue.c
r38441 r38986 133 133 // if we receive a signal which would cause us to exit, wait until the full catalog is written 134 134 SetProtect (TRUE); 135 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { 136 fprintf (stderr, "ERROR: failed to save catalog %s\n", outlist[0].filename[j]); 137 exit (1); 138 } 135 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", outcatalog.filename); exit (1); } 136 if (!dvo_catalog_unlock (&outcatalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", outcatalog.filename); exit (1); } 139 137 SetProtect (FALSE); 140 138 141 dvo_catalog_unlock (&outcatalog);142 139 dvo_catalog_free (&outcatalog); 143 140 -
trunk/Ohana/src/dvomerge/src/dvomergeContinue_threaded.c
r38441 r38986 77 77 SetProtect (TRUE); 78 78 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { 79 fprintf (stderr, "ERROR: failed to save catalog %s\n", outlist[0].filename[j]); 79 fprintf (stderr, "ERROR: failed to save catalog %s\n", outcatalog.filename); 80 threadData->state = TS_FAIL; 81 continue; 82 } 83 if (!dvo_catalog_unlock (&outcatalog)) { 84 fprintf (stderr, "ERROR: failed to unlock catalog %s\n", outcatalog.filename); 80 85 threadData->state = TS_FAIL; 81 86 continue; … … 83 88 SetProtect (FALSE); 84 89 85 dvo_catalog_unlock (&outcatalog);86 90 dvo_catalog_free (&outcatalog); 87 91 -
trunk/Ohana/src/dvomerge/src/dvomergeCreate.c
r38441 r38986 178 178 SkyListFree (inlist); 179 179 180 dvo_catalog_save (&outcatalog, VERBOSE); 181 dvo_catalog_unlock (&outcatalog); 180 SetProtect (TRUE); 181 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", outcatalog.filename); exit (1); } 182 if (!dvo_catalog_unlock (&outcatalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", outcatalog.filename); exit (1); } 183 SetProtect (FALSE); 184 182 185 dvo_catalog_free (&outcatalog); 183 186 } -
trunk/Ohana/src/dvomerge/src/dvomergeFromList.c
r38441 r38986 147 147 // if we receive a signal which would cause us to exit, wait until the full catalog is written 148 148 SetProtect (TRUE); 149 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { 150 fprintf (stderr, "ERROR: failed to save catalog %s\n", outputfile); 151 exit (1); 152 } 149 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save catalog %s\n", outcatalog.filename); exit (1); } 150 if (!dvo_catalog_unlock (&outcatalog)) { fprintf (stderr, "ERROR: failed to unlock catalog %s\n", outcatalog.filename); exit (1); } 153 151 SetProtect (FALSE); 154 152 … … 158 156 OutputStatusFree (outstat, 1); 159 157 160 dvo_catalog_unlock (&outcatalog);161 158 dvo_catalog_free (&outcatalog); 162 159 -
trunk/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
r38470 r38986 177 177 LoadCatalog (&outcatalog, outlist[0].regions[j], outcatalog.filename, "w", NsecfiltOutput); 178 178 179 // if no catalog already exists, use the input catalog to define the format or the specified format180 179 if (UPDATE_CATFORMAT) { 181 180 outcatalog.catformat = dvo_catalog_catformat (UPDATE_CATFORMAT); 182 181 } else { 183 outcatalog.catformat = incatalog.catformat; 184 } 182 // IF no catalog already exists, use the input catalog to define the format 183 if (outcatalog.Naverage_disk == 0) { 184 outcatalog.catformat = incatalog.catformat; 185 } 186 } 187 185 188 if (UPDATE_CATCOMPRESS) { 186 189 outcatalog.catcompress = dvo_catalog_catcompress (UPDATE_CATCOMPRESS); 187 190 } else { 188 outcatalog.catcompress = incatalog.catcompress; 191 // IF no catalog already exists, use the input catalog to define the compression 192 if (outcatalog.Naverage_disk == 0) { 193 outcatalog.catcompress = incatalog.catcompress; 194 } 195 } 196 197 if (REPAIR_BY_OBJID) { 198 // For gpc1 / PV3, I broke some catalogs with dvomerge -replace: the last object can 199 // contaminate the first set of new measurements 200 repair_catalog_by_objID (&outcatalog); 189 201 } 190 202 … … 195 207 } 196 208 197 if (!dvo_catalog_backup (&outcatalog, TRUE)) {209 if (!dvo_catalog_backup (&outcatalog, "~", TRUE)) { 198 210 fprintf (stderr, "ERROR: failed to make backup for catalog %s\n", outlist[0].filename[j]); 199 211 exit (1); … … 202 214 // if we receive a signal which would cause us to exit, wait until the full catalog is written 203 215 SetProtect (TRUE); 204 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { 205 fprintf (stderr, "ERROR: failed to save catalog %s\n", outlist[0].filename[j]); 206 exit (1); 207 } 216 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save catalog %s\n", outcatalog.filename); exit (1); } 217 if (!dvo_catalog_unlock (&outcatalog)) { fprintf (stderr, "ERROR: failed to unlock catalog %s\n", outcatalog.filename); exit (1); } 208 218 SetProtect (FALSE); 209 219 210 if (!dvo_catalog_unlock (&outcatalog)) { 211 fprintf (stderr, "ERROR: failed to unlock catalog %s\n", outlist[0].filename[j]); 212 exit (1); 213 } 214 215 if (!dvo_catalog_unlink_backup (&outcatalog, TRUE)) { 220 if (!dvo_catalog_unlink_backup (&outcatalog, "~", TRUE)) { 216 221 fprintf (stderr, "WARNING: failed to remove backup for catalog %s\n", outlist[0].filename[j]); 217 222 } … … 282 287 283 288 // options / arguments that can affect relastro_client -update-objects: 284 char command[DVO_MAX_PATH];285 s nprintf (command, DVO_MAX_PATH, "dvomerge_client %s into %s -hostID %d -hostdir %s -region %f %f %f %f -D ADDSTAR_RADIUS %f",286 absinput, absoutput, group->hosts[i][0].hostID, group->hosts[i][0].pathname,287 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, RADIUS288 ); 289 290 char tmpline[DVO_MAX_PATH];291 if (VER BOSE) { snprintf (tmpline, DVO_MAX_PATH, "%s -v", command); strcpy (command, tmpline); }292 if ( VERIFY) { snprintf (tmpline, DVO_MAX_PATH, "%s -verify", command); strcpy (command, tmpline); }293 if ( VERIFY_CATALOG_ONLY) { snprintf (tmpline, DVO_MAX_PATH, "%s -verify-catalogs", command); strcpy (command, tmpline); }294 if ( REPLACE_BY_PHOTCODE) { snprintf (tmpline, DVO_MAX_PATH, "%s -replace", command); strcpy (command, tmpline); }295 if ( REPLACE_TYCHO) { snprintf (tmpline, DVO_MAX_PATH, "%s -replace-tycho", command); strcpy (command, tmpline); }296 if ( PARALLEL_INPUT) { snprintf (tmpline, DVO_MAX_PATH, "%s -parallel-input", command); strcpy (command, tmpline); }297 if ( FORCE_MERGE) { snprintf (tmpline, DVO_MAX_PATH, "%s -force-merge", command); strcpy (command, tmpline); }298 if ( MATCHED_TABLES) { snprintf (tmpline, DVO_MAX_PATH, "%s -matched-tables", command); strcpy (command, tmpline); }299 if ( UPDATE_CATFORMAT) { snprintf (tmpline, DVO_MAX_PATH, "%s -update-catformat %s", command, UPDATE_CATFORMAT); strcpy (command, tmpline); }289 char *command = NULL; 290 strextend (&command, "dvomerge_client %s into %s -hostID %d -hostdir %s -region %f %f %f %f -D ADDSTAR_RADIUS %f", 291 absinput, absoutput, group->hosts[i][0].hostID, group->hosts[i][0].pathname, 292 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, RADIUS); 293 294 if (VERBOSE) { strextend (&command, "-v"); } 295 if (VERIFY) { strextend (&command, "-verify"); } 296 if (VERIFY_CATALOG_ONLY) { strextend (&command, "-verify-catalogs"); } 297 if (REPLACE_BY_PHOTCODE) { strextend (&command, "-replace"); } 298 if (REPLACE_TYCHO) { strextend (&command, "-replace-tycho"); } 299 if (PARALLEL_INPUT) { strextend (&command, "-parallel-input"); } 300 if (FORCE_MERGE) { strextend (&command, "-force-merge"); } 301 if (MATCHED_TABLES) { strextend (&command, "-matched-tables"); } 302 if (UPDATE_CATFORMAT) { strextend (&command, "-update-catformat %s", UPDATE_CATFORMAT); } 303 if (UPDATE_CATCOMPRESS) { strextend (&command, "-update-catcompress %s", UPDATE_CATCOMPRESS); } 304 if (REPAIR_BY_OBJID) { strextend (&command, "-repair-by-objid"); } 300 305 301 306 // add some config variables: 302 s nprintf (tmpline, DVO_MAX_PATH, "%s -D CATMODE %s", command, CATMODE); strcpy (command, tmpline);303 s nprintf (tmpline, DVO_MAX_PATH, "%s -D CATFORMAT %s", command, CATFORMAT); strcpy (command, tmpline);304 s nprintf (tmpline, DVO_MAX_PATH, "%s -D SKY_DEPTH %d", command, SKY_DEPTH); strcpy (command, tmpline);307 strextend (&command, "-D CATMODE %s", CATMODE); 308 strextend (&command, "-D CATFORMAT %s", CATFORMAT); 309 strextend (&command, "-D SKY_DEPTH %d", SKY_DEPTH); 305 310 306 311 fprintf (stderr, "command: %s\n", command); -
trunk/Ohana/src/dvomerge/src/dvomergeUpdate_threaded.c
r38441 r38986 75 75 SetProtect (TRUE); 76 76 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { 77 fprintf (stderr, "ERROR: failed to save catalog %s\n", outlist[0].filename[j]); 77 fprintf (stderr, "ERROR: failed to save catalog %s\n", outcatalog.filename); 78 threadData->state = TS_FAIL; 79 continue; 80 } 81 if (!dvo_catalog_unlock (&outcatalog)) { 82 fprintf (stderr, "ERROR: failed to save catalog %s\n", outcatalog.filename); 78 83 threadData->state = TS_FAIL; 79 84 continue; … … 81 86 SetProtect (FALSE); 82 87 83 dvo_catalog_unlock (&outcatalog);84 88 dvo_catalog_free (&outcatalog); 85 89 -
trunk/Ohana/src/dvomerge/src/dvomerge_client.c
r35818 r38986 3 3 int main (int argc, char **argv) { 4 4 5 SetSignals (); 5 6 dvomerge_client_help (argc, argv); 6 7 ConfigInit (&argc, argv); … … 83 84 // loop over the populatable output tables; check for data in input in the corresponding regions 84 85 85 SetPhotcodeTable(NULL);86 86 if (REPLACE_TYCHO) replace_tycho_init(); 87 87 88 dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, IDmap, secfiltMap); 88 89 -
trunk/Ohana/src/dvomerge/src/dvorepair.c
r37807 r38986 7 7 // exit (2); 8 8 9 SetSignals (); 9 10 dvorepair_help(argc, argv); 10 11 12 if (!strcmp(argv[1], "-fix-warp-ids")) dvorepairFixWarpIDs(argc, argv); 13 11 14 if (!strcmp(argv[1], "-fix-cpt")) dvorepairFixCPT(argc, argv); 15 if (!strcmp(argv[1], "-fix-cpt-by-objID")) dvorepair_by_objID(argc, argv); 12 16 // if (!strcmp(argv[1], "-fix-tables")) dvorepairFixTables(argc, argv); 13 17 if (!strcmp(argv[1], "-images-vs-measures")) dvorepairImagesVsMeasures(argc, argv); -
trunk/Ohana/src/dvomerge/src/dvorepairCPT.c
r38441 r38986 39 39 exit (2); 40 40 } 41 42 SetSignals (); 41 43 42 44 imageFilename = argv[1]; -
trunk/Ohana/src/dvomerge/src/dvorepairDeleteImagesByExternID.c
r38468 r38986 16 16 int SaveImageTable (Image *image, off_t Nimage, char *catdir, FITS_DB *oldDB); 17 17 Image *DeleteSelectedImages (Image *image, off_t Nimage, int *deleteImage, myIndexType *imageIDindex, off_t *NnewImage); 18 int DeleteLensing (Catalog *catalog, myIndexType *imageIDindex, int *deleteImage, int *nDelete); 19 int DeleteMeasure (Catalog *catalog, myIndexType *imageIDindex, int *deleteImage, int *nDelete); 20 int RepairAverage (Catalog *catalog); 18 21 19 22 int dvorepairDeleteImagesByExternID (int argc, char **argv) { … … 21 24 FITS_DB db; // database handle pointing to input image table 22 25 23 int i, j, N, NmeasureNew, Ndelete, Nvalid;24 off_t Nimage , Nmeasure;26 int i, N; 27 off_t Nimage; 25 28 int nPass, raPass; 26 29 27 30 Image *image; 28 Measure *measure;29 Measure *measureNew;30 31 char *cpmFilenameSrc = NULL;32 char *cptFilenameSrc = NULL;33 char *cpsFilenameSrc = NULL;34 char *cpmFilenameTgt = NULL;35 char *cptFilenameTgt = NULL;36 char *cpsFilenameTgt = NULL;37 38 31 char *imageFilename = NULL; 39 40 DVOCatFormat catformat; 32 char filename[DVO_MAX_PATH]; 41 33 42 34 N = get_argument (argc, argv, "-delete-images-by-extern-id"); … … 59 51 char *catdir = argv[1]; 60 52 char *delList = argv[2]; 53 54 sprintf (filename, "%s/Photcodes.dat", catdir); 55 if (!LoadPhotcodes (filename, NULL, FALSE)) { 56 fprintf (stderr, "error reading photcodes from %s\n", catdir); 57 exit (1); 58 } 61 59 62 60 // load the image data … … 196 194 } 197 195 198 ALLOCATE(cpmFilenameSrc, char, strlen(catdir) + 64); 199 ALLOCATE(cptFilenameSrc, char, strlen(catdir) + 64); 200 ALLOCATE(cpsFilenameSrc, char, strlen(catdir) + 64); 201 ALLOCATE(cpmFilenameTgt, char, strlen(catdir) + 64); 202 ALLOCATE(cptFilenameTgt, char, strlen(catdir) + 64); 203 ALLOCATE(cpsFilenameTgt, char, strlen(catdir) + 64); 204 205 int NdeleteTotal = 0; 196 int NmeasureDelTotal = 0; 197 int NlensingDelTotal = 0; 206 198 207 199 for (raPass = 0; raPass < nPass; raPass++) { … … 231 223 232 224 // loop over the populated input regions 233 int Ncheck = 0;234 225 for (i = 0; i < inlist[0].Nregions; i++) { 235 226 if (!inlist[0].regions[i][0].table) continue; 236 227 237 sprintf (cpmFilenameSrc, "%s/%s.cpm", catdir, inlist[0].regions[i][0].name); 238 sprintf (cptFilenameSrc, "%s/%s.cpt", catdir, inlist[0].regions[i][0].name); 239 sprintf (cpsFilenameSrc, "%s/%s.cps", catdir, inlist[0].regions[i][0].name); 240 sprintf (cpmFilenameTgt, "%s/%s.cpm.broken", catdir, inlist[0].regions[i][0].name); 241 sprintf (cptFilenameTgt, "%s/%s.cpt.broken", catdir, inlist[0].regions[i][0].name); 242 sprintf (cpsFilenameTgt, "%s/%s.cps.broken", catdir, inlist[0].regions[i][0].name); 243 244 Header cpmHeaderPHU; 245 Header cpmHeaderTBL; 246 FTable cpmFtable; 247 248 /*** read and examine the CPM file ***/ 249 { 250 if (VERBOSE) fprintf (stderr, "check %s\n", cpmFilenameSrc); 251 252 cpmFtable.header = &cpmHeaderTBL; 253 254 // open cpm file 255 FILE *cpmFile = fopen(cpmFilenameSrc, "r"); 256 if (!cpmFile) continue; 257 // myAssert(cpmFile, "failed to open cpm file"); 258 259 // load the cpm header 260 if (!gfits_fread_header (cpmFile, &cpmHeaderPHU)) { 261 myAbort("failure to cpm header"); 262 } 263 264 // move to TBL header 265 int Nbytes = cpmHeaderPHU.datasize + gfits_data_size (&cpmHeaderPHU); 266 fseeko (cpmFile, Nbytes, SEEK_SET); 267 268 // read cpm TBL header 269 if (!gfits_fread_header (cpmFile, &cpmHeaderTBL)) { 270 myAbort("can't read header for cpm table"); 271 } 272 273 // read Measure table data : format is irrelevant here */ 274 if (!gfits_fread_ftable_data (cpmFile, &cpmFtable, TRUE)) { 275 myAbort("can't read data for cpm table"); 276 } 277 278 int NbytesPerRow; 279 gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow); 280 281 myAbort ("fix compression"); 282 283 // this function can only handle PS1_V5 and later formats 284 // NOTE: FtableToMeasure (and equivalent) free the data associated with cpmFtable. 285 // We are left with the data in measure. 286 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat, FALSE); 287 myAssert(measure, "failed to convert ftable to measure data"); 288 289 Nvalid = (int)(cpmFtable.validsize / NbytesPerRow); 290 Nvalid = MIN(Nmeasure, Nvalid); 291 292 // close the input cpm file 293 fclose(cpmFile); 294 295 // allocate an output array of measures (to replace, if needed) 296 ALLOCATE (measureNew, Measure, Nvalid); 297 298 NmeasureNew = 0; 299 Ndelete = 0; 300 301 // examine all measurements: find ones that need to be deleted 302 for (j = 0; j < Nvalid; j++) { 303 int imageID = measure[j].imageID; 304 myAssert(imageID, "measure is missing an image ID"); 305 // XXX this case is valid if we have REF detections (no associated image) 306 307 int N = myIndexGetEntry(imageIDindex, imageID); 308 if (N < 0) { 309 // this detection comes from a non-existant image, delete 310 Ndelete ++; 311 continue; 312 } 313 314 if (deleteImage[N]) { 315 Ndelete ++; 316 continue; 317 } 318 measureNew[NmeasureNew] = measure[j]; 319 NmeasureNew ++; 320 } 228 snprintf (filename, DVO_MAX_PATH, "%s/%s.cpt", catdir, inlist[0].regions[i][0].name); 229 230 Catalog catalog; 231 232 // set up the basic catalog info 233 dvo_catalog_init (&catalog, TRUE); 234 catalog.filename = filename; // XXX only allow non-parallel dbs for now 235 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT | DVO_LOAD_LENSING; 236 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 237 238 if (!dvo_catalog_open (&catalog, inlist[0].regions[i], VERBOSE, "w")) { 239 fprintf (stderr, "ERROR: failure reading catalog %s\n", catalog.filename); 240 exit (1); 321 241 } 322 323 NdeleteTotal += Ndelete; 324 325 // if we actually want to delete any measurements, write out a new cpm file 326 if (Ndelete > 0) { 327 328 fprintf (stderr, "deleting %d of %d (keep %d) detections from %s -> %s\n", (int) Ndelete, (int) Nvalid, (int) NmeasureNew, cpmFilenameSrc, cpmFilenameTgt); 242 if (!catalog.Naverage_disk) { 243 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 244 dvo_catalog_unlock (&catalog); 245 dvo_catalog_free (&catalog); 246 continue; 247 } 329 248 330 // the CPT and CPS tables need to be regenerated. This must happen first because, in the process, we also update measure->averef 331 // what about other tables? 332 RepairTableCPT_V1(cptFilenameSrc, cptFilenameTgt, cpsFilenameSrc, cpsFilenameTgt, measureNew, NmeasureNew, image, Nimage, imageIDindex, catformat); 333 334 // convert internal to external format 335 if (!MeasureToFtable (&cpmFtable, NULL, measureNew, NmeasureNew, catformat, TRUE)) { 336 myAbort("trouble converting format"); 337 } 338 339 // rename the old cpm file: 340 if (rename (cpmFilenameSrc, cpmFilenameTgt)) { 341 perror ("tried to rename file"); 342 exit (2); 343 } 344 345 // create and write the output file 346 FILE *cpmFile = fopen(cpmFilenameSrc, "w"); 347 myAssert(cpmFile, "failed to open cpt file"); 348 349 // write PHU header 350 if (!gfits_fwrite_header (cpmFile, &cpmHeaderPHU)) { 351 myAbort("can't write primary header"); 352 } 353 354 Matrix matrix; 355 356 // write the PHU matrix; this is probably a NOP, do I have to keep it in? 357 gfits_create_matrix (&cpmHeaderPHU, &matrix); 358 if (!gfits_fwrite_matrix (cpmFile, &matrix)) { 359 myAbort("can't write primary matrix"); 360 } 361 gfits_free_matrix (&matrix); 362 363 // write the table data 364 if (!gfits_fwrite_ftable_range (cpmFile, &cpmFtable, 0, NmeasureNew, 0, NmeasureNew)) { 365 myAbort("can't write table data"); 366 } 367 fclose (cpmFile); 368 369 gfits_free_table (&cpmFtable); 370 } else { 371 if (VERBOSE) fprintf (stderr, "nothing to delete in %s\n", cpmFilenameSrc); 249 /*** delete the measure and lensing entries matching the list of imageIDs ***/ 250 int NmeasureDel = 0; 251 DeleteMeasure (&catalog, imageIDindex, deleteImage, &NmeasureDel); 252 253 int NlensingDel = 0; 254 DeleteLensing (&catalog, imageIDindex, deleteImage, &NlensingDel); 255 256 fprintf (stderr, "deleting %d measure, %d lensing (keep %d, %d)\n", NmeasureDel, NlensingDel, (int) catalog.Nmeasure, (int) catalog.Nlensing); 257 258 if (!NmeasureDel && !NlensingDel) { 259 if (VERBOSE) fprintf (stderr, "nothing to delete in %s\n", catalog.filename); 260 dvo_catalog_unlock (&catalog); 261 dvo_catalog_free (&catalog); 262 continue; 372 263 } 373 264 374 gfits_free_header (&cpmHeaderPHU); 375 gfits_free_header (&cpmHeaderTBL); 376 free (measure); 377 free (measureNew); 378 379 Ncheck ++; 380 if (Ncheck % 1000 == 0) { 381 fprintf (stderr, "%s...", inlist[0].regions[i][0].name); 265 NmeasureDelTotal += NmeasureDel; 266 NlensingDelTotal += NlensingDel; 267 268 // the CPT and CPS tables need to be regenerated. This must happen first because, in the process, we also update measure->averef 269 // what about other tables? 270 RepairAverage (&catalog); 271 272 if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename); 273 274 if (!dvo_catalog_backup (&catalog, ".undel", TRUE)) { 275 fprintf (stderr, "ERROR: failed to make backup for catalog %s\n", catalog.filename); 276 exit (1); 382 277 } 278 279 SetProtect (TRUE); 280 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 281 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 282 SetProtect (FALSE); 283 dvo_catalog_free (&catalog); 383 284 } 384 285 fprintf (stderr, "\n"); … … 386 287 } 387 288 388 fprintf (stderr, "Deleted %d detections\n", NdeleteTotal);289 fprintf (stderr, "Deleted %d measure, %d lensing detections\n", NmeasureDelTotal, NlensingDelTotal); 389 290 390 291 off_t NnewImage; … … 400 301 free (deleteIDs); 401 302 402 free(cpmFilenameSrc);403 free(cptFilenameSrc);404 free(cpsFilenameSrc);405 free(cpmFilenameTgt);406 free(cptFilenameTgt);407 free(cpsFilenameTgt);408 409 303 SkyTableFree(insky); 410 304 411 305 gfits_db_free (&db); 306 307 ohana_memcheck (TRUE); 412 308 413 309 exit (0); … … 661 557 gfits_scan (&cptHeaderPHU, "NSECFILT", "%d", 1, &Nsecfilt); 662 558 663 myAbort ("test for compression"); 559 if (0) { 560 char compressMode[256]; 561 if (gfits_scan (&cptHeaderTBL, "DVO_CMP", "%s", 1, compressMode)) { 562 if (strcmp (compressMode, "NONE")) { 563 myAbort ("fix compression"); 564 } 565 } 566 } 664 567 665 568 /* convert internal to external format */ … … 774 677 } 775 678 679 int RepairAverage (Catalog *catalog) { 680 681 off_t i, j, Nave; 682 683 // average is sorted so averef is valid 684 // secfilt is also sorted so sequence is valid (but this is kind of moot since it will be re-calculated) 685 // average.measureOffset is NOT valid 686 // average.lensingOffset is NOT valid 687 688 Average *average = catalog->average; 689 Measure *measure = catalog->measure; 690 Lensing *lensing = catalog->lensing; 691 692 // reset the values of average.Nmeasure, average.Nlensing 693 for (i = 0; i < catalog->Naverage; i++) { 694 average[i].Nmeasure = 0; 695 average[i].Nlensing = 0; 696 } 697 698 // re-calculate average.Nmeasure 699 for (i = 0; i < catalog->Nmeasure; i++) { 700 Nave = measure[i].averef; 701 myAssert (measure[i].objID == average[Nave].objID, "invalid measure:average match"); 702 average[Nave].Nmeasure ++; 703 } 704 705 // re-calculate average.Nlensing 706 for (i = 0; i < catalog->Nlensing; i++) { 707 Nave = lensing[i].averef; 708 myAssert (lensing[i].objID == average[Nave].objID, "invalid lensing:average match"); 709 average[Nave].Nlensing ++; 710 } 711 712 // create a copy of the average table, keeping only the entries with Nmeasure & Nlensing > 0 713 ALLOCATE_PTR (averageNew, Average, catalog->Naverage); 714 ALLOCATE_PTR (averefNew, int, catalog->Naverage); 715 716 Nave = 0; 717 for (i = 0; i < catalog->Naverage; i++) { 718 averefNew[i] = -1; 719 if (!average[i].Nmeasure && !average[i].Nlensing) continue; 720 721 averageNew[Nave] = average[i]; 722 averefNew[i] = Nave; 723 Nave ++; 724 } 725 off_t NaverageNew = Nave; 726 727 // update measure.averef values 728 for (i = 0; i < catalog->Nmeasure; i++) { 729 Nave = averefNew[measure[i].averef]; 730 myAssert (Nave >= 0, "oops"); 731 measure[i].averef = Nave; 732 } 733 734 // update lensing.averef values 735 for (i = 0; i < catalog->Nlensing; i++) { 736 Nave = averefNew[lensing[i].averef]; 737 myAssert (Nave >= 0, "oops"); 738 lensing[i].averef = Nave; 739 } 740 741 // XXX need to update measureOffset and lensingOffset 742 743 // measure[] should be blocked and sequential: 744 // measure[i+1].averef >= measure[i].averef 745 746 // update average.measureOffset values 747 Nave = -1; 748 for (i = 0; i < catalog->Nmeasure; i++) { 749 if (measure[i].averef == Nave) continue; 750 Nave = measure[i].averef; 751 averageNew[Nave].measureOffset = i; 752 } 753 754 // update average.lensingOffset values 755 Nave = -1; 756 for (i = 0; i < catalog->Nlensing; i++) { 757 if (lensing[i].averef == Nave) continue; 758 Nave = lensing[i].averef; 759 averageNew[Nave].lensingOffset = i; 760 } 761 762 // check the result (measure -> average) 763 for (i = 0; i < catalog->Nmeasure; i++) { 764 Nave = measure[i].averef; 765 myAssert(averageNew[Nave].objID == measure[i].objID, "objIDs do not match"); 766 myAssert(averageNew[Nave].catID == measure[i].catID, "catIDs do not match"); 767 } 768 // check the result (average -> measure) 769 for (i = 0; i < NaverageNew; i++) { 770 int m = averageNew[i].measureOffset; 771 for (j = 0; j < averageNew[i].Nmeasure; j++) { 772 myAssert(averageNew[i].objID == measure[j+m].objID, "objIDs do not match"); 773 myAssert(averageNew[i].catID == measure[j+m].catID, "catIDs do not match"); 774 myAssert(measure[j+m].averef == i, "averef broken"); 775 } 776 } 777 778 // check the result (lensing -> average) 779 for (i = 0; i < catalog->Nlensing; i++) { 780 Nave = lensing[i].averef; 781 myAssert(averageNew[Nave].objID == lensing[i].objID, "objIDs do not match"); 782 myAssert(averageNew[Nave].catID == lensing[i].catID, "catIDs do not match"); 783 } 784 // check the result (average -> lensing) 785 for (i = 0; i < NaverageNew; i++) { 786 int m = averageNew[i].lensingOffset; 787 for (j = 0; j < averageNew[i].Nlensing; j++) { 788 myAssert(averageNew[i].objID == lensing[j+m].objID, "objIDs do not match"); 789 myAssert(averageNew[i].catID == lensing[j+m].catID, "catIDs do not match"); 790 myAssert(lensing[j+m].averef == i, "averef broken"); 791 } 792 } 793 794 free (catalog->secfilt); 795 ALLOCATE (catalog->secfilt, SecFilt, NaverageNew*catalog->Nsecfilt); 796 for (i = 0; i < NaverageNew*catalog->Nsecfilt; i++) { 797 dvo_secfilt_init (&catalog->secfilt[i], SECFILT_RESET_ALL); 798 } 799 800 free (averefNew); 801 free (catalog->average); 802 catalog->average = averageNew; 803 catalog->Naverage = NaverageNew; 804 catalog->Naverage_disk = NaverageNew; 805 806 catalog->Nsecfilt_disk = NaverageNew*catalog->Nsecfilt; 807 808 return (TRUE); 809 } 810 811 // delete measure entries 812 int DeleteMeasure (Catalog *catalog, myIndexType *imageIDindex, int *deleteImage, int *nDelete) { 813 814 int j; 815 816 Measure *measure = catalog->measure; 817 818 // allocate an output array of measures (to replace, if needed) 819 ALLOCATE_PTR (measureNew, Measure, catalog->Nmeasure); 820 821 int NmeasureNew = 0; 822 int NmeasureDel = 0; 823 824 // examine all measurements: find ones that need to be deleted 825 for (j = 0; j < catalog->Nmeasure; j++) { 826 int imageID = measure[j].imageID; 827 myAssert(imageID, "measure is missing an image ID"); 828 // XXX this case is valid if we have REF detections (no associated image) 829 830 int N = myIndexGetEntry(imageIDindex, imageID); 831 if (N < 0) { 832 // this detection comes from a non-existant image; delete 833 NmeasureDel ++; 834 continue; 835 } 836 837 // measure matches a bad image; delete 838 if (deleteImage[N]) { 839 NmeasureDel ++; 840 continue; 841 } 842 843 // keep this measure 844 measureNew[NmeasureNew] = measure[j]; 845 NmeasureNew ++; 846 } 847 848 free (catalog->measure); 849 catalog->measure = measureNew; 850 catalog->Nmeasure = NmeasureNew; 851 catalog->Nmeasure_disk = NmeasureNew; 852 853 *nDelete = NmeasureDel; 854 855 return TRUE; 856 } 857 858 // delete lensing entries 859 int DeleteLensing (Catalog *catalog, myIndexType *imageIDindex, int *deleteImage, int *nDelete) { 860 861 int j; 862 863 Lensing *lensing = catalog->lensing; 864 865 // allocate an output array of measures (to replace, if needed) 866 ALLOCATE_PTR (lensingNew, Lensing, catalog->Nlensing); 867 868 int NlensingNew = 0; 869 int NlensingDel = 0; 870 871 // examine all lensingments: find ones that need to be deleted 872 for (j = 0; j < catalog->Nlensing; j++) { 873 int imageID = lensing[j].imageID; 874 myAssert(imageID, "lensing is missing an image ID"); 875 // XXX this case is valid if we have REF detections (no associated image) 876 877 int N = myIndexGetEntry(imageIDindex, imageID); 878 if (N < 0) { 879 // this detection comes from a non-existant image; delete 880 NlensingDel ++; 881 continue; 882 } 883 884 // lensing matches a bad image; delete 885 if (deleteImage[N]) { 886 NlensingDel ++; 887 continue; 888 } 889 890 // keep this lensing 891 lensingNew[NlensingNew] = lensing[j]; 892 NlensingNew ++; 893 } 894 895 free (catalog->lensing); 896 catalog->lensing = lensingNew; 897 catalog->Nlensing = NlensingNew; 898 catalog->Nlensing_disk = NlensingNew; 899 900 *nDelete = NlensingDel; 901 902 return TRUE; 903 } 904 -
trunk/Ohana/src/dvomerge/src/dvorepairFixImages.c
r38441 r38986 255 255 256 256 /* setup image table format and lock */ 257 gfits_db_init ( oldDB);257 gfits_db_init (&db); 258 258 db.mode = oldDB->mode; 259 259 db.format = oldDB->format; … … 266 266 /* load or create the image table */ 267 267 myAssert (db.dbstate == LCK_EMPTY, "do not overwrite exiting image table"); 268 myAssert (db.format == DVO_FORMAT_PS1_V2, "format mismatch");268 // myAssert (db.format == DVO_FORMAT_PS1_V2, "format mismatch"); 269 269 270 270 dvo_image_create (&db, GetZeroPoint()); 271 gfits_copy_header (&oldDB->header, &db.header); 271 272 272 273 // replace the existing buffer with the image array … … 277 278 nbytes = gfits_data_size (db.ftable.header); 278 279 db.ftable.datasize = nbytes; 279 db.ftable.buffer = (char *) imageOut; 280 REALLOCATE (db.ftable.buffer, char, MAX (nbytes, 1)); 280 281 free (db.ftable.buffer); 282 ALLOCATE (db.ftable.buffer, char, MAX (nbytes, 1)); 283 memcpy (db.ftable.buffer, imageOut, nbytes); 281 284 memset (&db.ftable.buffer[Nx*Nout], ' ', nbytes - Nx*Nout); 282 285 … … 295 298 dvo_image_unlock (&db); 296 299 300 gfits_db_free (&db); 301 297 302 return TRUE; 298 303 } -
trunk/Ohana/src/dvomerge/src/dvorepairImageVsMeasure.c
r38441 r38986 39 39 } 40 40 41 SetSignals (); 41 42 catdir = argv[1]; 42 43 Ntol = atoi(argv[2]); -
trunk/Ohana/src/dvomerge/src/dvosecfilt_catalogs.c
r38471 r38986 82 82 catalog.Nsecfilt_disk = Nsecfilt * catalog.Naverage_disk; 83 83 84 dvo_catalog_save (&catalog, VERBOSE); 85 dvo_catalog_unlock (&catalog); 84 SetProtect (TRUE); 85 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 86 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 87 SetProtect (FALSE); 88 86 89 dvo_catalog_free (&catalog); 87 90 } -
trunk/Ohana/src/dvomerge/src/dvoutils.c
r37807 r38986 4 4 5 5 // check various options 6 SetSignals (); 6 7 dvoutils_args (&argc, argv); 7 8 -
trunk/Ohana/src/dvomerge/src/dvoutils_load_image_index.c
r38441 r38986 2 2 3 3 // load the array of EXTERN_ID from the ImageIndex.fits tables 4 int *dvoutils_load_image_index (char *filename, int *nindex) {4 ImageData *dvoutils_load_image_index (char *filename) { 5 5 6 6 int Ncol; 7 off_t Nrow ;7 off_t Nrow, Nphot; 8 8 Header header; 9 9 Header theader; … … 46 46 fclose (f); 47 47 48 int *externID = gfits_get_bintable_column_data (&theader, &ftable, "EXTERN_ID", type, &Nrow, &Ncol); 48 ImageData *imdata = NULL; 49 ALLOCATE (imdata, ImageData, 1); 50 51 imdata->externID = gfits_get_bintable_column_data (&theader, &ftable, "EXTERN_ID", type, &Nrow, &Ncol); 49 52 myAssert (!strcmp(type, "int"), "wrong column type"); 53 54 imdata->photcode = gfits_get_bintable_column_data (&theader, &ftable, "PHOTCODE", type, &Nphot, &Ncol); 55 myAssert (Nphot == Nrow, "photcode & extern_id mis-match"); 56 57 imdata->Nimages = Nrow; 50 58 51 59 gfits_free_header (&header); … … 54 62 gfits_free_table (&ftable); 55 63 56 *nindex = Nrow; 57 58 return externID; 64 return imdata; 59 65 } 60 66 -
trunk/Ohana/src/dvomerge/src/dvoutils_uniq_images.c
r38441 r38986 40 40 } 41 41 42 int Nimage; 43 // Image *image = dvoutils_load_image_table (imFile, &Nimage); 44 int *extern_id = dvoutils_load_image_index (imFile, &Nimage); 45 if (!extern_id) continue; 42 ImageData *imdata = dvoutils_load_image_index (imFile); 43 if (!imdata) continue; 46 44 47 45 DBlist[Ndb] = strcreate (imFile); … … 57 55 58 56 int i; 59 for (i = 0; i < Nimage; i++) { 60 if (!extern_id[i]) continue; 61 myMaxID = MAX(extern_id[i], myMaxID); 62 myMinID = MIN(extern_id[i], myMinID); 57 int Nbad = 0; 58 for (i = 0; i < imdata->Nimages; i++) { 59 if (!imdata->photcode[i] && imdata->externID[i]) myAbort ("invalid combo"); 60 61 if (!imdata->photcode[i]) continue; 62 if (!imdata->externID[i]) { 63 Nbad ++; 64 continue; 65 } 66 myMaxID = MAX(imdata->externID[i], myMaxID); 67 myMinID = MIN(imdata->externID[i], myMinID); 63 68 } 64 69 65 fprintf (stderr, "read %s, %d images, %d - %d vs %d - %d\n", imFile, (int) Nimage, myMinID, myMaxID, minID, maxID); 70 fprintf (stderr, "read %s, %d images, %d - %d vs %d - %d\n", imFile, (int) imdata->Nimages, myMinID, myMaxID, minID, maxID); 71 72 if (Nbad) { 73 fprintf (stderr, "WARNING: %d images without extern_id set\n", (int) Nbad); 74 } 66 75 67 76 // if this is new, we treat it a bit differently … … 124 133 } 125 134 126 for (i = 0; i < Nimage; i++) {127 if (! extern_id[i]) continue;128 int n = extern_id[i] - minID;135 for (i = 0; i < imdata->Nimages; i++) { 136 if (!imdata->externID[i]) continue; 137 int n = imdata->externID[i] - minID; 129 138 if (IDlist[n] == 0) { 130 139 DBfound[n] = Ndb; … … 133 142 IDlist[n] ++; 134 143 if (VERBOSE && (IDlist[n] > 1)) { 135 fprintf (stderr, "duplicate ext_id %d in file %s\n", extern_id[i], imFile);144 fprintf (stderr, "duplicate ext_id %d in file %s\n", imdata->externID[i], imFile); 136 145 } 137 146 } … … 140 149 fprintf (stderr, "------------ %s ----------\n", imFile); 141 150 142 for (i = 0; i < Nimage; i++) {143 if (! extern_id[i]) continue;144 fprintf (stderr, "%d => %d\n", extern_id[i], extern_id[i] - minID);151 for (i = 0; i < imdata->Nimages; i++) { 152 if (!imdata->externID[i]) continue; 153 fprintf (stderr, "%d => %d\n", imdata->externID[i], imdata->externID[i] - minID); 145 154 } 146 155 … … 165 174 int n = DBfound[i]; 166 175 myAssert (n > -1, "impossible!"); 167 fprintf (stdout, " %d : %d -- in %s (%d) : %d \n", i + minID, IDlist[i], DBlist[n], DBfound[i], DBindex[i]);176 fprintf (stdout, "primary %d : %d -- in %s (%d) : %d \n", i + minID, IDlist[i], DBlist[n], DBfound[i], DBindex[i]); 168 177 } 169 178 -
trunk/Ohana/src/dvomerge/src/dvoverify.c
r38553 r38986 14 14 15 15 // check various options 16 SetSignals (); 16 17 dvoverify_args (&argc, argv); 17 18 CATDIR = argv[1]; … … 78 79 SkyListFree (skylist); 79 80 80 ohana_memcheck ( TRUE);81 ohana_memdump ( TRUE);81 ohana_memcheck (VERBOSE); 82 ohana_memdump (VERBOSE); 82 83 exit (0); 83 84 } -
trunk/Ohana/src/dvomerge/src/dvoverify_args.c
r38553 r38986 24 24 if ((N = get_argument (*argc, argv, "-sorted"))) { 25 25 CHECKSORTED = TRUE; 26 remove_argument (N, argc, argv); 27 } 28 29 // in some cases, the header sorted state can claim F but is actually T 30 IGNORE_SORTED_STATE = FALSE; 31 if ((N = get_argument (*argc, argv, "-ignore-sorted-state"))) { 32 IGNORE_SORTED_STATE = TRUE; 26 33 remove_argument (N, argc, argv); 27 34 } … … 50 57 free (filename); 51 58 52 ohana_memcheck ( TRUE);53 ohana_memdump ( TRUE);59 ohana_memcheck (VERBOSE); 60 ohana_memdump (VERBOSE); 54 61 55 62 if (!isGood) exit (1); … … 204 211 } 205 212 213 // in some cases, the header sorted state can claim F but is actually T 214 IGNORE_SORTED_STATE = FALSE; 215 if ((N = get_argument (*argc, argv, "-ignore-sorted-state"))) { 216 IGNORE_SORTED_STATE = TRUE; 217 remove_argument (N, argc, argv); 218 } 219 206 220 if (!HOST_ID || !HOSTDIR || (*argc != 2)) { 207 221 fprintf (stderr, "USAGE: dvoverify_client (catdir) -results (file) -hostID ID -hostdir DIR [-region Rmin Rmax Dmin Dmax] [-v] [-s]\n\n"); -
trunk/Ohana/src/dvomerge/src/dvoverify_catalogs.c
r38553 r38986 117 117 118 118 // options / arguments that can affect relastro_client -update-objects: 119 char command[DVO_MAX_PATH]; 120 snprintf (command, DVO_MAX_PATH, "dvoverify_client %s -results %s -hostID %d -hostdir %s -region %f %f %f %f", 121 abscatdir, table->hosts[i].results, table->hosts[i].hostID, table->hosts[i].pathname, 122 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax 123 ); 119 char *command = NULL; 120 strextend (&command, "dvoverify_client %s -results %s -hostID %d -hostdir %s -region %f %f %f %f", 121 abscatdir, table->hosts[i].results, table->hosts[i].hostID, table->hosts[i].pathname, 122 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 124 123 125 char tmpline[DVO_MAX_PATH];126 if ( VERBOSE) { snprintf (tmpline, DVO_MAX_PATH, "%s -v", command); strcpy (command, tmpline); }127 if ( CHECKSORTED) { snprintf (tmpline, DVO_MAX_PATH, "%s -s", command); strcpy (command, tmpline); }128 if (!CHECK_IMAGE_ID) { snprintf (tmpline, DVO_MAX_PATH, "%s -skip-image-ids", command); strcpy (command, tmpline); }129 if (LIST_MISSING) { snprintf (tmpline, DVO_MAX_PATH, "%s -list-missing", command); strcpy (command, tmpline); }124 if (VERBOSE) { strextend (&command, "-v"); } 125 if (CHECKSORTED) { strextend (&command, "-s"); } 126 if (IGNORE_SORTED_STATE) { strextend (&command, "-ignore-sorted-state"); } 127 if (!CHECK_IMAGE_ID) { strextend (&command, "-skip-image-ids"); } 128 if (LIST_MISSING) { strextend (&command, "-list-missing"); } 130 129 131 130 fprintf (stderr, "command: %s\n", command); … … 149 148 table->hosts[i].pid = pid; // save for future reference 150 149 } 150 free (command); 151 151 } 152 152 -
trunk/Ohana/src/dvomerge/src/dvoverify_client.c
r37360 r38986 8 8 9 9 // check various options 10 SetSignals (); 10 11 dvoverify_client_args (&argc, argv); 11 12 CATDIR = argv[1]; -
trunk/Ohana/src/dvomerge/src/dvoverify_utils.c
r38553 r38986 188 188 dvo_catalog_init (&catalog, TRUE); 189 189 catalog.filename = filename; 190 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ ;190 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ | DVO_LOAD_STARPAR | DVO_LOAD_GALPHOT; 191 191 catalog.Nsecfilt = 0; 192 192 … … 214 214 215 215 // if the table is NOT SORTED, do we have a subset of checks we can make? 216 if (!catalog.sorted ) {216 if (!catalog.sorted && !IGNORE_SORTED_STATE) { 217 217 fprintf (stderr, "!"); 218 218 dvo_catalog_unlock (&catalog); … … 222 222 return TRUE; 223 223 } 224 225 int NmeasureTotal = 0; 226 int measureOffsetOK = TRUE; 227 int NlensingTotal = 0; 228 int lensingOffsetOK = TRUE; 229 int NlensobjTotal = 0; 230 int lensobjOffsetOK = TRUE; 231 for (i = 0; i < catalog.Naverage; i++) { 232 NmeasureTotal += catalog.average[i].Nmeasure; 233 if (VERBOSE && !(NmeasureTotal <= catalog.Nmeasure)) { 234 fprintf (stderr, "NmeasureTotal > catalog.Nmeasure: %d %d %d\n", i, catalog.average[i].Nmeasure, (int) catalog.Nmeasure); 235 } 236 measureOffsetOK &= (catalog.average[i].measureOffset < catalog.Nmeasure); 237 if (VERBOSE && !(catalog.average[i].measureOffset < catalog.Nmeasure)) { 238 fprintf (stderr, "measureOffset >= catalog.Nmeasure: %d %d %d\n", i, catalog.average[i].measureOffset, (int) catalog.Nmeasure); 239 } 240 measureOffsetOK &= (catalog.average[i].measureOffset + catalog.average[i].Nmeasure <= catalog.Nmeasure); 241 if (VERBOSE && !(catalog.average[i].measureOffset + catalog.average[i].Nmeasure <= catalog.Nmeasure)) { 242 fprintf (stderr, "measureOffset + Nmeasure > catalog.Nmeasure : %d %d %d\n", i, catalog.average[i].Nmeasure, (int) catalog.Nmeasure); 243 } 244 245 // sum of Nlensing for each object < Nlensing for catalog 246 NlensingTotal += catalog.average[i].Nlensing; 247 if (VERBOSE && !(NlensingTotal <= catalog.Nlensing)) { 248 fprintf (stderr, "NlensingTotal > catalog.Nlensing: %d %d %d\n", i, catalog.average[i].Nlensing, (int) catalog.Nlensing); 249 } 250 // lensingOffset needs to be in range for each object 251 lensingOffsetOK &= (!catalog.Nlensing || (catalog.average[i].lensingOffset < catalog.Nlensing)); 252 if (VERBOSE && catalog.Nlensing && !(catalog.average[i].lensingOffset < catalog.Nlensing)) { 253 fprintf (stderr, "lensingOffset >= catalog.Nlensing: %d %d %d\n", i, catalog.average[i].lensingOffset, (int) catalog.Nlensing); 254 } 255 lensingOffsetOK &= (catalog.average[i].lensingOffset + catalog.average[i].Nlensing <= catalog.Nlensing); 256 if (VERBOSE && !(catalog.average[i].lensingOffset + catalog.average[i].Nlensing <= catalog.Nlensing)) { 257 fprintf (stderr, "lensingOffset + Nlensing > catalog.Nlensing : %d %d %d\n", i, catalog.average[i].Nlensing, (int) catalog.Nlensing); 258 } 259 260 NlensobjTotal += catalog.average[i].Nlensobj; 261 if (VERBOSE && !(NlensobjTotal <= catalog.Nlensobj)) { 262 fprintf (stderr, "NlensobjTotal > catalog.Nlensobj: %d %d %d\n", i, catalog.average[i].Nlensobj, (int) catalog.Nlensobj); 263 } 264 lensobjOffsetOK &= (catalog.average[i].lensobjOffset < catalog.Nlensobj); 265 if (VERBOSE && !(catalog.average[i].lensobjOffset < catalog.Nlensobj)) { 266 fprintf (stderr, "lensobjOffset >= catalog.Nlensobj: %d %d %d\n", i, catalog.average[i].lensobjOffset, (int) catalog.Nlensobj); 267 } 268 lensobjOffsetOK &= (catalog.average[i].lensobjOffset + catalog.average[i].Nlensobj <= catalog.Nlensobj); 269 if (VERBOSE && !(catalog.average[i].lensobjOffset + catalog.average[i].Nlensobj <= catalog.Nlensobj)) { 270 fprintf (stderr, "lensobjOffset + Nlensobj > catalog.Nlensobj : %d %d %d\n", i, catalog.average[i].Nlensobj, (int) catalog.Nlensobj); 271 } 272 } 273 274 if (!measureOffsetOK) { 275 fprintf (stderr, "ERROR: catalog %s has an invalid measureOffset\n", catalog.filename); 276 status = FALSE; 277 } 278 279 if (NmeasureTotal != catalog.Nmeasure) { 280 fprintf (stderr, "ERROR: catalog %s has an invalid Nmeasure\n", catalog.filename); 281 status = FALSE; 282 } 283 284 if (!lensingOffsetOK) { 285 fprintf (stderr, "ERROR: catalog %s has an invalid lensingOffset\n", catalog.filename); 286 status = FALSE; 287 } 288 289 if (NlensingTotal != catalog.Nlensing) { 290 fprintf (stderr, "ERROR: catalog %s has an invalid Nlensing\n", catalog.filename); 291 status = FALSE; 292 } 293 294 if (!lensobjOffsetOK) { 295 fprintf (stderr, "ERROR: catalog %s has an invalid lensobjOffset\n", catalog.filename); 296 status = FALSE; 297 } 298 299 if (NlensobjTotal != catalog.Nlensobj) { 300 fprintf (stderr, "ERROR: catalog %s has an invalid Nlensobj\n", catalog.filename); 301 status = FALSE; 302 } 224 225 # define CHECK_TABLE(NAME) { \ 226 int Ntotal = 0; int offsetOK = TRUE; int isOK = FALSE; \ 227 for (i = 0; i < catalog.Naverage; i++) { \ 228 Ntotal += catalog.average[i].N##NAME; \ 229 if (VERBOSE && !(Ntotal <= catalog.N##NAME)) { \ 230 fprintf (stderr, "Ntotal (%s) > catalog.N##NAME: %d %d : %d > %d\n", #NAME, i, Ntotal, catalog.average[i].N##NAME, (int) catalog.N##NAME); \ 231 } \ 232 isOK = (catalog.average[i].N##NAME == 0) || (catalog.average[i].NAME##Offset < catalog.N##NAME); \ 233 offsetOK &= isOK; \ 234 if (VERBOSE && !isOK) { \ 235 fprintf (stderr, "%sOffset >= catalog.N%s: %d : %d >= %d\n", #NAME, #NAME, i, catalog.average[i].NAME##Offset, (int) catalog.N##NAME); \ 236 } \ 237 isOK = (catalog.average[i].N##NAME == 0) || (catalog.average[i].NAME##Offset + catalog.average[i].N##NAME <= catalog.N##NAME); \ 238 offsetOK &= isOK; \ 239 if (VERBOSE && !isOK) { \ 240 fprintf (stderr, "%sOffset + N%s > catalog.N%s : %d : %d + %d > %d\n", #NAME, #NAME, #NAME, i, catalog.average[i].N##NAME, catalog.average[i].NAME##Offset, (int) catalog.N##NAME); \ 241 } } \ 242 if (!offsetOK) { \ 243 fprintf (stderr, "ERROR: catalog %s has an invalid %sOffset\n", catalog.filename, #NAME); \ 244 status = FALSE; \ 245 } \ 246 if (Ntotal != catalog.N##NAME) { \ 247 fprintf (stderr, "ERROR: catalog %s has an invalid N%s\n", catalog.filename, #NAME); \ 248 status = FALSE; \ 249 } \ 250 } 251 252 CHECK_TABLE(measure); 253 CHECK_TABLE(lensing); 254 CHECK_TABLE(lensobj); 255 CHECK_TABLE(starpar); 256 CHECK_TABLE(galphot); 303 257 304 258 // if we have a problem with Nmeasure and/or measureOffset values, we … … 312 266 // check measure <-> average links 313 267 { 314 int objIDsOK = TRUE;315 int catIDsOK = TRUE;316 int averefOK = TRUE;268 int NobjIDsBAD = 0; 269 int NcatIDsBAD = 0; 270 int NaverefBAD = 0; 317 271 318 272 for (i = 0; i < catalog.Naverage; i++) { 319 273 m = catalog.average[i].measureOffset; 320 274 for (j = 0; j < catalog.average[i].Nmeasure; j++) { 321 objIDsOK &= (catalog.average[i].objID == catalog.measure[m+j].objID); 322 catIDsOK &= (catalog.average[i].catID == catalog.measure[m+j].catID); 323 averefOK &= (catalog.measure[m+j].averef == i); 275 if (catalog.average[i].objID != catalog.measure[m+j].objID) { 276 NobjIDsBAD ++; 277 278 // check if objID matches R,D 279 Measure *measure = &catalog.measure[m+j]; 280 int iTest = measure->objID; 281 if (catalog.average[iTest].objID == iTest) { 282 double dR = 3600.0*(catalog.average[iTest].R - measure->R) * cos (RAD_DEG*measure->D); 283 double dD = 3600.0*(catalog.average[iTest].D - measure->D); 284 double dRad = hypot (dR, dD); 285 char *date = ohana_sec_to_date (measure->t); 286 fprintf (stderr, "matches ave %d = %d, %s : %6.3f %5d : %f, %f = %f\n", iTest, measure->objID, date, measure->M, measure->photcode, dR, dD, dRad); 287 free (date); 288 } else { 289 fprintf (stderr, "cannot find averef\n"); 290 } 291 } 292 if (catalog.average[i].catID != catalog.measure[m+j].catID) { 293 NcatIDsBAD ++; 294 } 295 if (catalog.measure[m+j].averef != i) { 296 NaverefBAD ++; 297 } 324 298 } 325 299 } 326 300 327 if ( !objIDsOK) {328 fprintf (stderr, "ERROR: catalog %s has invalid obj IDs\n", catalog.filename);329 status = FALSE; 330 } 331 if ( !catIDsOK) {332 fprintf (stderr, "ERROR: catalog %s has invalid cat IDs\n", catalog.filename);333 status = FALSE; 334 } 335 if ( !averefOK) {336 fprintf (stderr, "ERROR: catalog %s has invalid averef values\n", catalog.filename);301 if (NobjIDsBAD) { 302 fprintf (stderr, "ERROR: catalog %s has %d invalid obj IDs\n", catalog.filename, NobjIDsBAD); 303 status = FALSE; 304 } 305 if (NcatIDsBAD) { 306 fprintf (stderr, "ERROR: catalog %s has %d invalid cat IDs\n", catalog.filename, NcatIDsBAD); 307 status = FALSE; 308 } 309 if (NaverefBAD) { 310 fprintf (stderr, "ERROR: catalog %s has %d invalid averef values\n", catalog.filename, NaverefBAD); 337 311 status = FALSE; 338 312 } … … 387 361 if (!catIDsOK) { 388 362 fprintf (stderr, "ERROR: catalog %s has invalid lensobj cat IDs\n", catalog.filename); 363 status = FALSE; 364 } 365 } 366 367 // check starpar <-> average links 368 { 369 int objIDsOK = TRUE; 370 int catIDsOK = TRUE; 371 int averefOK = TRUE; 372 373 for (i = 0; i < catalog.Naverage; i++) { 374 m = catalog.average[i].starparOffset; 375 for (j = 0; j < catalog.average[i].Nstarpar; j++) { 376 objIDsOK &= (catalog.average[i].objID == catalog.starpar[m+j].objID); 377 catIDsOK &= (catalog.average[i].catID == catalog.starpar[m+j].catID); 378 averefOK &= (catalog.starpar[m+j].averef == i); 379 } 380 } 381 382 if (!objIDsOK) { 383 fprintf (stderr, "ERROR: catalog %s has invalid starpar obj IDs\n", catalog.filename); 384 status = FALSE; 385 } 386 if (!catIDsOK) { 387 fprintf (stderr, "ERROR: catalog %s has invalid starpar cat IDs\n", catalog.filename); 388 status = FALSE; 389 } 390 if (!averefOK) { 391 fprintf (stderr, "ERROR: catalog %s has invalid starpar averef values\n", catalog.filename); 392 status = FALSE; 393 } 394 } 395 396 // check galphot <-> average links 397 { 398 int objIDsOK = TRUE; 399 int catIDsOK = TRUE; 400 int averefOK = TRUE; 401 402 for (i = 0; i < catalog.Naverage; i++) { 403 m = catalog.average[i].galphotOffset; 404 for (j = 0; j < catalog.average[i].Ngalphot; j++) { 405 objIDsOK &= (catalog.average[i].objID == catalog.galphot[m+j].objID); 406 catIDsOK &= (catalog.average[i].catID == catalog.galphot[m+j].catID); 407 averefOK &= (catalog.galphot[m+j].averef == i); 408 } 409 } 410 411 if (!objIDsOK) { 412 fprintf (stderr, "ERROR: catalog %s has invalid galphot obj IDs\n", catalog.filename); 413 status = FALSE; 414 } 415 if (!catIDsOK) { 416 fprintf (stderr, "ERROR: catalog %s has invalid galphot cat IDs\n", catalog.filename); 417 status = FALSE; 418 } 419 if (!averefOK) { 420 fprintf (stderr, "ERROR: catalog %s has invalid galphot averef values\n", catalog.filename); 389 421 status = FALSE; 390 422 } -
trunk/Ohana/src/dvomerge/src/help.c
r35590 r38986 172 172 173 173 fprintf (stderr, "USAGE\n"); 174 fprintf (stderr, " dvorepair -fix-warp-ids (catdir) (idfile) - regenerate images.dat warp_skyfile_ids (EXTERN_ID) values\n"); 174 175 fprintf (stderr, " dvorepair -fix-cpt (images) (rootlist) - regenerate cpt & cps files from the cpm files\n"); 175 176 fprintf (stderr, " dvorepair -images-vs-measures (catdir) (Ntol) - find images with too many missing detections\n"); -
trunk/Ohana/src/dvomerge/src/merge_catalogs_old.c
r38468 r38986 198 198 int Nreplace = 0; 199 199 if (REPLACE_TYCHO) { 200 int Mout = output[0].average[n].measureOffset;201 200 int Minp = input[0].average[N].measureOffset; 202 Nreplace = replace_tycho (&output[0].average[n], &output[0].measure[Mout], &input[0].average[N], &input[0].measure[Minp]);201 Nreplace = replace_tycho (&output[0].average[n], output[0].measure, next_meas, &input[0].average[N], &input[0].measure[Minp]); 203 202 if (Nreplace == 6) { 204 203 input[0].found_t[N] = Nmeas; … … 216 215 // index to first measure for this object 217 216 // XXX this does not support lensing measurements 218 int Mout = output[0].average[n].measureOffset; 219 if (replace_match(&output[0].average[n], &output[0].measure[Mout], &input[0].average[N], &input[0].measure[offset])) { 220 input[0].found_t[N] = Mout; 217 if (replace_match (&output[0].average[n], output[0].measure, next_meas, &input[0].average[N], &input[0].measure[offset])) { 218 input[0].found_t[N] = output[0].average[n].measureOffset; 221 219 continue; 222 220 } -
trunk/Ohana/src/dvomerge/src/replace_match.c
r37046 r38986 1 1 # include "dvomerge.h" 2 2 3 // XXX this function does not work because it it loops over the average->Nmeasure entries 4 // as if they were sorted, but objects which have had entries added to them have elements 5 // out of sequence. I probably need to step through next_meas to find the sequence. 6 3 7 // average and measure pointers to the objects of interest and their first / current measurement 4 int replace_match (Average *average_out, Measure *measure_out, Average *average_in, Measure *measure_in) {8 int replace_match (Average *average_out, Measure *measure_out, off_t *next_meas, Average *average_in, Measure *measure_in) { 5 9 6 10 int Nout; … … 8 12 unsigned int catID; 9 13 14 off_t m = average_out->measureOffset; 15 10 16 // find the matching photcode in the object's list of measurements 11 17 for (Nout = 0; Nout < average_out[0].Nmeasure; Nout ++) { 12 if (measure_out[Nout].photcode != measure_in[0].photcode) continue; 18 myAssert (m > -1, "oops"); 19 if (measure_out[m].photcode != measure_in[0].photcode) { 20 m = next_meas[m]; 21 continue; 22 } 13 23 14 24 // set the new measurements 15 averef = measure_out[ Nout].averef;16 catID = measure_out[ Nout].catID;17 measure_out[ Nout] = measure_in[0];25 averef = measure_out[m].averef; 26 catID = measure_out[m].catID; 27 measure_out[m] = measure_in[0]; 18 28 19 29 // old code: find R,D using average_in[0], the get offset relative to average_out[0]. no longer … … 24 34 // measure_out[Nout].dD = 3600.0*(average_out[0].D - Din); 25 35 26 measure_out[ Nout].dbFlags = 0; // XXX why reset these?27 measure_out[ Nout].averef = averef;28 measure_out[ Nout].objID = average_out[0].objID;29 measure_out[ Nout].catID = catID;36 measure_out[m].dbFlags = 0; // XXX why reset these? 37 measure_out[m].averef = averef; 38 measure_out[m].objID = average_out[0].objID; 39 measure_out[m].catID = catID; 30 40 31 float dRoff = dvoOffsetR(&measure_out[ Nout], average_out);41 float dRoff = dvoOffsetR(&measure_out[m], average_out); 32 42 33 43 // rationalize dR 34 44 if (dRoff > +180.0*3600.0) { 35 45 // average on high end of boundary, move star up 36 measure_out[ Nout].R += 360.0;46 measure_out[m].R += 360.0; 37 47 dRoff -= 360.0*3600.0; 38 48 } 39 49 if (dRoff < -180.0*3600.0) { 40 50 // average on low end of boundary, move star down 41 measure_out[ Nout].R -= 360.0;51 measure_out[m].R -= 360.0; 42 52 dRoff += 360.0*3600.0; 43 53 } … … 49 59 if (fabs(dRoff*cosD) > 10*RADIUS) { 50 60 fprintf (stderr, "surprisingly distant detection: %10.6f,%10.6f vs %10.6f,%10.6f\n", 51 average_out[0].R, average_out[0].D, measure_out[ Nout].R, measure_out[Nout].D);61 average_out[0].R, average_out[0].D, measure_out[m].R, measure_out[m].D); 52 62 } 53 63 } -
trunk/Ohana/src/dvomerge/src/replace_tycho.c
r38468 r38986 10 10 } 11 11 12 int replace_tycho (Average *averageOut, Measure *measureOut, Average *averageInp, Measure *measureInp) {12 int replace_tycho (Average *averageOut, Measure *measureOut, off_t *next_meas, Average *averageInp, Measure *measureInp) { 13 13 14 14 int i; … … 17 17 int index[6]; 18 18 19 off_t m = averageOut->measureOffset; 20 19 21 // find all tycho measurements 20 22 for (i = 0; (i < averageOut->Nmeasure) && (Nindex < 6); i++) { 21 23 24 myAssert (m > -1, "oops"); 25 22 26 int valid = FALSE; 23 valid = valid || (measureOut[i].photcode == TYCHO_B); 24 valid = valid || (measureOut[i].photcode == TYCHO_V); 25 if (!valid) continue; 26 27 index[Nindex] = i; 28 Nindex ++; 27 valid = valid || (measureOut[m].photcode == TYCHO_B); 28 valid = valid || (measureOut[m].photcode == TYCHO_V); 29 if (valid) { 30 index[Nindex] = m; 31 Nindex ++; 32 } 33 m = next_meas[m]; 29 34 } 30 35 -
trunk/Ohana/src/dvopsps/include/dvopsps.h
r38851 r38986 72 72 void ConfigInit PROTO((int *argc, char **argv)); 73 73 74 void usage_dvopsps PROTO(( ));74 void usage_dvopsps PROTO((void)); 75 75 void initialize_dvopsps PROTO((int argc, char **argv)); 76 76 int args_dvopsps PROTO((int argc, char **argv)); 77 77 78 void usage_dvopsps_client PROTO(( ));78 void usage_dvopsps_client PROTO((void)); 79 79 void initialize_dvopsps_client PROTO((int argc, char **argv)); 80 80 int args_dvopsps_client PROTO((int argc, char **argv)); … … 82 82 MYSQL *mysql_dvopsps_connect PROTO((MYSQL *mysqlBase)); 83 83 84 int insert_detections_dvopsps PROTO(( ));84 int insert_detections_dvopsps PROTO((void)); 85 85 int insert_detections_dvopsps_parallel PROTO((SkyTable *sky)); 86 86 int insert_detections_dvopsps_catalog PROTO((Catalog *catalog, MYSQL *mysql)); … … 94 94 int assign_detection_values PROTO((Detections *detection, Measure *measure, Average *average)); 95 95 96 int init_detections PROTO(( ));96 int init_detections PROTO((void)); 97 97 int append_detections_dvopsps_catalog PROTO((Catalog *catalog)); 98 int save_detections_dvopsps PROTO(( ));98 int save_detections_dvopsps PROTO((void)); 99 99 100 int insert_objects_dvopsps PROTO(( ));100 int insert_objects_dvopsps PROTO((void)); 101 101 int insert_objects_dvopsps_parallel PROTO((SkyList *sky)); 102 102 int insert_objects_dvopsps_catalog PROTO((Catalog *catalog, char *basename, MYSQL *mysql)); … … 107 107 int insert_objects_mysql_init PROTO((IOBuffer *ave_buffer, IOBuffer *sec_buffer, char *basename)); 108 108 109 int insert_FWobjects_dvopsps PROTO(( ));109 int insert_FWobjects_dvopsps PROTO((void)); 110 110 int insert_FWobjects_dvopsps_parallel PROTO((SkyList *sky)); 111 111 int insert_FWobjects_dvopsps_catalog PROTO((Catalog *catalog, char *basename, MYSQL *mysql)); … … 116 116 int insert_FWobjects_mysql_commit PROTO((IOBuffer *ave_buffer, IOBuffer *sec_buffer, IOBuffer *cpy_buffer, MYSQL *mysql)); 117 117 118 int insert_FGshape_dvopsps PROTO(( ));118 int insert_FGshape_dvopsps PROTO((void)); 119 119 int insert_FGshape_dvopsps_parallel PROTO((SkyList *sky)); 120 120 int insert_FGshape_dvopsps_catalog PROTO((Catalog *catalog, char *basename, MYSQL *mysql)); … … 125 125 int insert_FGshape_mysql_commit PROTO((IOBuffer *ave_buffer, IOBuffer *cpy_buffer, MYSQL *mysql)); 126 126 127 int insert_skytable PROTO(( ));127 int insert_skytable PROTO((void)); 128 128 129 129 int insert_skytable_mysql_commit PROTO((IOBuffer *buffer, MYSQL *mysql)); … … 131 131 int insert_skytable_mysql_init PROTO((IOBuffer *buffer)); 132 132 133 int insert_diffobj_dvopsps PROTO(( ));133 int insert_diffobj_dvopsps PROTO((void)); 134 134 int insert_diffobj_dvopsps_parallel PROTO((SkyList *sky)); 135 135 int insert_diffobj_dvopsps_catalog PROTO((Catalog *catalog, char *basename, MYSQL *mysql)); -
trunk/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c
r38851 r38986 109 109 110 110 // NOTE for testing, just do a few objects 111 if (!mysql) {112 catalog[0].Naverage = 5;113 }114 111 for (i = 0; i < catalog[0].Naverage; i++) { 115 112 … … 225 222 mysql_free_result (result); 226 223 } else { 227 fprintf (stderr, " %s\n", buffer->buffer);224 fprintf (stderr, "."); 228 225 } 229 226 -
trunk/Ohana/src/dvosplit/src/split_averages.c
r38441 r38986 105 105 outcatalogs[cat].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT; 106 106 107 SetProtect (TRUE); 107 108 dvo_catalog_save (&outcatalogs[cat], VERBOSE); 109 SetProtect (FALSE); 108 110 // fprintf (stderr, "secfilt: %d %d %d %d\n", outcatalogs[cat].Nsecfilt_mem, outcatalogs[cat].Nsecfilt_disk, outcatalogs[cat].Nsecfilt_off, outcatalogs[cat].Naverage, outcatalogs[cat].Nsecfilt); 109 111 -
trunk/Ohana/src/dvosplit/src/split_measures.c
r38441 r38986 73 73 for (cat = 0; cat < outlist[0].Nregions; cat++) { 74 74 outcatalogs[cat].catflags = DVO_LOAD_MEASURE; 75 76 SetProtect (TRUE); 75 77 dvo_catalog_save (&outcatalogs[cat], VERBOSE); 78 SetProtect (FALSE); 76 79 77 80 outcatalogs[cat].Nmeasure_disk += outcatalogs[cat].Nmeasure; -
trunk/Ohana/src/fakeastro/include/fakeastro.h
r38441 r38986 103 103 104 104 float RADIUS; 105 float MAX_MAG_2MASS; 105 106 106 107 SkyRegion UserPatch; -
trunk/Ohana/src/fakeastro/src/args.c
r37807 r38986 104 104 if ((N = get_argument (*argc, argv, "-uniform-radec"))) { 105 105 UNIFORM_RADEC = TRUE; 106 remove_argument (N, argc, argv); 107 } 108 109 MAX_MAG_2MASS = 16.0; 110 if ((N = get_argument (*argc, argv, "-2mass-limit"))) { 111 remove_argument (N, argc, argv); 112 MAX_MAG_2MASS = atof(argv[N]); 106 113 remove_argument (N, argc, argv); 107 114 } -
trunk/Ohana/src/fakeastro/src/fakestar_catalog.c
r38471 r38986 21 21 insert_fakestar (region, stars, Nstars, &catalog); 22 22 23 dvo_catalog_save (&catalog, VERBOSE); 24 dvo_catalog_unlock (&catalog); 23 SetProtect (TRUE); 24 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 25 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 26 SetProtect (FALSE); 27 25 28 dvo_catalog_free (&catalog); 26 29 -
trunk/Ohana/src/fakeastro/src/fit_fake_stars.c
r37807 r38986 133 133 AstromOffsetTableNewMap(table, order_use, order_use, image); 134 134 } 135 AstromOffsetMapFit (image[0].coords.offsetMap, Xref, Yref, dX, N stars, TRUE);136 AstromOffsetMapFit (image[0].coords.offsetMap, Xref, Yref, dY, N stars, FALSE);135 AstromOffsetMapFit (image[0].coords.offsetMap, Xref, Yref, dX, NULL, Nstars, TRUE); 136 AstromOffsetMapFit (image[0].coords.offsetMap, Xref, Yref, dY, NULL, Nstars, FALSE); 137 137 138 138 image[0].coords.Npolyterms = -1; -
trunk/Ohana/src/fakeastro/src/make_2mass_measures.c
r37807 r38986 24 24 // PhotCode *codeK = GetPhotcodebyName ("2MASS_K"); 25 25 26 float ZP = 21.0; // this is chosen to give 16.0 mag stars a flux of 100.0 counts (crude, yes)27 float SkyCts = 300.0; // this is chosen to make SN @ 16.0 = 5.0 (26 float ZP = MAX_MAG_2MASS + 6.5; // this is chosen to give stars at the limit a flux of 400.0 counts (crude, yes) 27 float SkyCts = 1000.0; // this is chosen to make SN @ limit ~ 10.0 ( 28 28 29 29 int Nmeasure = catalog->Nmeasure; … … 45 45 // make a crude JHK color for now: 46 46 double J_PS1 = secfilt[i*Nsecfilt + Nsec].M - 1.0; // make all stars have y-J = 1.0 47 if (J_PS1 > 16.0) continue; // only generate 2MASS detections for objects with J_PS1 < 16.047 if (J_PS1 > MAX_MAG_2MASS) continue; // only generate 2MASS detections for objects with J_PS1 < 16.0 48 48 49 49 if (isnan(secfilt[i*Nsecfilt + Nsec].M)) { … … 56 56 57 57 J_PS1 = secfilt[i*Nsecfilt + ns].M; // pretend secfilt.M = J 58 if (J_PS1 > 16.0) continue; // only generate 2MASS detections for objects with J_PS1 < 16.058 if (J_PS1 > MAX_MAG_2MASS) continue; // only generate 2MASS detections for objects with J_PS1 < 16.0 59 59 } 60 60 -
trunk/Ohana/src/fakeastro/src/save_fake_stars.c
r38471 r38986 24 24 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 25 25 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 26 //catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT | DVO_LOAD_MEASURE | DVO_LOAD_STARPAR; // use this for non-update mode27 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT | DVO_LOAD_STARPAR;26 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT | DVO_LOAD_MEASURE | DVO_LOAD_STARPAR; // use this for non-update mode 27 // catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_SECFILT | DVO_LOAD_STARPAR; 28 28 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 29 29 -
trunk/Ohana/src/getstar/src/MatchImages.c
- Property svn:mergeinfo deleted
r38732 r38986 29 29 tcoords.crval1 = image[0].coords.crval1; 30 30 tcoords.crval2 = image[0].coords.crval2; 31 31 32 if (!strcmp (&image[0].coords.ctype[4], "-WRP")) { 32 33 myAssert (image[0].coords.mosaic, "should already have tested this"); -
trunk/Ohana/src/getstar/src/write_catalog.c
r15539 r38986 5 5 /* write out the selected stars */ 6 6 // XXX need to set the catalog boundaries by hand? RA0-RA1, DEC0-DEC1 7 dvo_catalog_save (catalog, VERBOSE); 8 dvo_catalog_unlock (catalog); 9 dvo_catalog_free (catalog); 7 SetProtect (TRUE); 8 if (!dvo_catalog_save (catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog->filename); exit (1); } 9 if (!dvo_catalog_unlock (catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog->filename); exit (1); } 10 SetProtect (FALSE); 11 dvo_catalog_free (catalog); 10 12 fprintf (stderr, "SUCCESS\n"); 11 13 exit (0); -
trunk/Ohana/src/kapa2/include/prototypes.h
r38465 r38986 40 40 void DrawYErrors PROTO((KapaGraphWidget *graph, Gobjects *objects)); 41 41 void DrawTick PROTO((Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis)); 42 void AxisTickScale PROTO((Axis *axis, double * major, double *minor, int *nsignif));42 void AxisTickScale PROTO((Axis *axis, double *range, double *major, double *minor, int *nsignif)); 43 43 TickMarkData *CreateAxisTicks PROTO((Axis *axis, int *nticks)); 44 44 int PrintTick PROTO((char *string, double value, double min, double max, int nsignif)); -
trunk/Ohana/src/kapa2/include/structures.h
r38465 r38986 143 143 double fx, dfx, fy, dfy; /* axis location on graphic */ 144 144 double lweight; 145 double fLabelRange; 146 double fMinor; 145 147 int color; 146 148 } Axis; -
trunk/Ohana/src/kapa2/src/DrawFrame.c
r34088 r38986 116 116 117 117 if ((naxis == 0) || (naxis == 2)) { 118 x = MAX(x, fx); 119 } 120 // y = MAX(y, fy); 121 // } 118 x = MIN(MAX(x, fx),fx+dfx); 119 } 120 if ((naxis == 1) || (naxis == 3)) { 121 y = MAX(MIN(y, fy),fy+dfy); 122 } 122 123 123 124 dir = ((naxis == 0) || (naxis == 1)) ? -1 : +1; … … 137 138 138 139 /* temporarily assume rectilinear axes */ 139 if (naxis == 0) { dx = 0; dy = +1.0*pad; pos = 7; } 140 if (naxis == 2) { dx = 0; dy = -1.0*pad; pos = 1; } 141 142 if (naxis == 1) { dy = 0; dx = -0.5*pad; pos = 3; } 143 if (naxis == 3) { dy = 0; dx = +0.5*pad; pos = 5; } 140 if (naxis == 0) { dx = 0; dy = +1.0*pad; pos = 7; } // center, down justified 141 if (naxis == 2) { dx = 0; dy = -1.0*pad; pos = 1; } // center, up justified 142 143 if (naxis == 1) { dy = 0; dx = -0.5*pad; pos = 3; } // left, center justified 144 if (naxis == 3) { dy = 0; dx = +0.5*pad; pos = 5; } // right, center justified 144 145 145 146 xt = fx + (value-min)*dfx/(max - min) + dx; … … 154 155 # define MIN_RANGE 1e-30 155 156 156 void AxisTickScale (Axis *axis, double *major, double *minor, int *nsignif) { 157 158 double range, lrange, factor, mantis, fmantis, power; 159 160 range = axis[0].max - axis[0].min; 161 if (fabs(range) < MIN_RANGE) { 162 range = (range < 0) ? -MIN_RANGE : +MIN_RANGE; 163 } 164 165 lrange = log10(MAX(fabs(range), MIN_RANGE)); 157 void AxisTickScale (Axis *axis, double *range, double *major, double *minor, int *nsignif) { 158 159 double lrange, factor, mantis, fmantis, power; 160 161 *range = axis->fLabelRange*(axis[0].max - axis[0].min); 162 if (fabs(*range) < MIN_RANGE) { 163 *range = (*range < 0) ? -MIN_RANGE : +MIN_RANGE; 164 } 165 166 lrange = log10(MAX(fabs(*range), MIN_RANGE)); 167 double truncRange = ((int) ((lrange + 0.005) * 1000)) / 1000.0; 168 lrange = truncRange; 169 166 170 mantis = modf (lrange, &factor); 167 171 if (mantis < 0.0) { … … 179 183 if ((fmantis >= 1.0) && (fmantis < 1.999)) { 180 184 *major = 0.5 * power; 181 *minor = 0.1 * power;182 185 *nsignif = factor - 1; 183 186 if (axis[0].areticks == 1) { 184 187 *major = 0.25 * power; 185 *minor = 0.05 * power;186 188 *nsignif = factor - 2; 189 } 190 if (axis[0].areticks == 3) { 191 *major = 1.0 * power; 192 *nsignif = factor - 1; 187 193 } 188 194 } 189 195 if ((fmantis >= 1.999) && (fmantis < 3.999)) { 190 196 *major = 1.0 * power; 191 *minor = 0.2 * power;192 197 *nsignif = factor; 193 198 if (axis[0].areticks == 1) { 194 199 *major = 0.5 * power; 195 *minor = 0.1 * power;196 200 *nsignif = factor - 1; 201 } 202 if (axis[0].areticks == 3) { 203 *major = 2.0 * power; 204 *nsignif = factor; 197 205 } 198 206 } 199 207 if ((fmantis >= 3.999) && (fmantis < 5.999)) { 200 208 *major = 1.0 * power; 201 *minor = 0.5 * power;202 209 *nsignif = factor; 203 210 if (axis[0].areticks == 1) { 204 211 *major = 1.0 * power; 205 *minor = 0.2 * power; 212 *nsignif = factor; 213 } 214 if (axis[0].areticks == 3) { 215 *major = 2.0 * power; 206 216 *nsignif = factor; 207 217 } … … 209 219 if ((fmantis >= 5.999) && (fmantis < 7.999)) { 210 220 *major = 2.0 * power; 211 *minor = 0.5 * power;212 221 *nsignif = factor; 213 222 if (axis[0].areticks == 1) { 214 223 *major = 1.0 * power; 215 *minor = 0.5 * power; 224 *nsignif = factor; 225 } 226 if (axis[0].areticks == 3) { 227 *major = 4.0 * power; 216 228 *nsignif = factor; 217 229 } … … 219 231 if ((fmantis >= 7.999) && (fmantis < 10.000)) { 220 232 *major = 2.5 * power; 221 *minor = 0.5 * power; 222 *nsignif = factor - 1; 233 *nsignif = factor - 1; 223 234 if (axis[0].areticks == 1) { 224 235 *major = 2.0 * power; 225 *minor = 0.5 * power; 226 *nsignif = factor; 227 } 228 } 236 *nsignif = factor; 237 } 238 if (axis[0].areticks == 3) { 239 *major = 4.0 * power; 240 *nsignif = factor; 241 } 242 } 243 *minor = *major / axis->fMinor; 229 244 } 230 245 … … 233 248 TickMarkData *ticks; 234 249 double range, major, minor, first, value; 235 int i, NTICKS, done, ifirst,nsignif;250 int i, NTICKS, done, nsignif; 236 251 237 252 *nticks = 0; … … 240 255 if (isnan(axis->max) || isinf(axis->max)) return NULL; 241 256 242 range = axis->max - axis->min;243 244 // not sure why I skip out here instead of using the MIN_RANGE value245 if (fabs(range) < MIN_RANGE) return NULL;246 247 if (fabs(range) < MIN_RANGE) {248 range = (range < 0) ? -MIN_RANGE : +MIN_RANGE;249 }250 251 257 // length of the axis in pixels 252 258 // int nPixels = hypot(axis->dfx, axis->dfy); 253 259 // double dPixels = nPixels / range; // axis pixel-scale 254 260 255 AxisTickScale (axis, & major, &minor, &nsignif);261 AxisTickScale (axis, &range, &major, &minor, &nsignif); 256 262 257 263 // be a little generous … … 259 265 ALLOCATE (ticks, TickMarkData, NTICKS); 260 266 261 // value of the tick mark 262 ifirst = (axis->min < 0.0) ? (axis->min/minor - 0.05) : (axis->min/minor + 0.05); 267 // value of the first tick mark (near axis->min) 268 double minValue = axis->min / minor; 269 int ifirst = (int) minValue; 270 271 if ((axis->min > 0.0) && (minValue - ifirst > +0.1)) { 272 ifirst ++; 273 } 274 if ((axis->min < 0.0) && (minValue - ifirst < -0.1)) { 275 ifirst --; 276 } 263 277 first = minor*ifirst; 264 278 265 // allow undershoot by 1 pixel 266 // double overshoot = (axis->min - first) * dPixels; 267 // if (overshoot > 0.5) { 268 // if (range > 0) { 269 // first += minor; 270 // } else { 271 // first -= minor; 272 // } 273 // } 274 275 // XXX need to fix first and last value for printing label: currently prints first label 276 // too early & fails to do last label if too close 279 // only write the labels for the inner fRange of the axies 280 double minLabelValue = 0.5*(1.0 - 1.001*axis->fLabelRange)*(axis->max - axis->min) + axis->min; 281 double maxLabelValue = 0.5*(1.0 + 1.001*axis->fLabelRange)*(axis->max - axis->min) + axis->min; 277 282 278 283 // loop to find the ticks … … 284 289 ticks[i].IsMajor |= (fabs((int)((value + 0.5*minor)/major) - (value/major)) < 0.5*(minor/major)); 285 290 ticks[i].IsMajor |= (fabs((int)((value - 0.5*minor)/major) - (value/major)) < 0.5*(minor/major)); 286 ticks[i].IsLabel = (ticks[i].IsMajor && axis->islabel); 291 int inLabelRange = (range > 0) ? (value >= minLabelValue) && (value <= maxLabelValue) : (value <= minLabelValue) && (value >= maxLabelValue); 292 ticks[i].IsLabel = inLabelRange && ticks[i].IsMajor && axis->islabel; 287 293 ticks[i].value = value; 288 294 ticks[i].nsignif = nsignif; … … 292 298 value -= minor; 293 299 294 done |= (range > 0) && (value > axis->max); 295 done |= (range < 0) && (value < axis->max); 300 done |= (range > 0) && (value > axis->max + 0.1*minor); 301 done |= (range < 0) && (value < axis->max - 0.1*minor); 302 // fprintf (stderr, "%d : %f %f %f %f\n", done, range, value, axis->max, 0.1*minor); 296 303 } 297 304 -
trunk/Ohana/src/kapa2/src/Graphs.c
r37807 r38986 23 23 graph[0].axis[i].labelPad = NAN; 24 24 graph[0].axis[i].pad = NAN; 25 graph[0].axis[i].fLabelRange = 1.0; 26 graph[0].axis[i].fMinor = 5.0; 25 27 } 26 28 graph[0].data.ticktextPad = NAN; … … 35 37 graph[0].data.padYm = NAN; 36 38 graph[0].data.padYp = NAN; 39 40 graph[0].data.fLabelRangeXm = 1.0; 41 graph[0].data.fLabelRangeXp = 1.0; 42 graph[0].data.fLabelRangeYm = 1.0; 43 graph[0].data.fLabelRangeYp = 1.0; 44 45 graph[0].data.fMinorXm = 5.0; 46 graph[0].data.fMinorXp = 5.0; 47 graph[0].data.fMinorYm = 5.0; 48 graph[0].data.fMinorYp = 5.0; 37 49 38 50 for (i = 0; i < 8; i++) { -
trunk/Ohana/src/kapa2/src/LoadFrame.c
r29539 r38986 37 37 graph[0].axis[3].labelPad = graph[0].data.labelPadYp; 38 38 39 graph[0].axis[0].fLabelRange = graph[0].data.fLabelRangeXm; 40 graph[0].axis[1].fLabelRange = graph[0].data.fLabelRangeYm; 41 graph[0].axis[2].fLabelRange = graph[0].data.fLabelRangeXp; 42 graph[0].axis[3].fLabelRange = graph[0].data.fLabelRangeYp; 43 44 graph[0].axis[0].fMinor = graph[0].data.fMinorXm; 45 graph[0].axis[1].fMinor = graph[0].data.fMinorYm; 46 graph[0].axis[2].fMinor = graph[0].data.fMinorXp; 47 graph[0].axis[3].fMinor = graph[0].data.fMinorYp; 48 39 49 for (i = 0; i < 4; i++) { 40 50 graph[0].axis[i].lweight = graph[0].data.lweight; … … 63 73 case '2': 64 74 graph[0].axis[i].areticks = 2; 75 break; 76 case '3': 77 graph[0].axis[i].areticks = 3; 65 78 break; 66 79 } -
trunk/Ohana/src/kapa2/src/PSFrame.c
r34088 r38986 81 81 y = fy + (value-min)*dfy/(max - min); 82 82 83 if ((naxis == 0) || (naxis == 2)) { 84 x = MIN(MAX(x, fx),fx+dfx); 85 } 86 if ((naxis == 1) || (naxis == 3)) { 87 y = MIN(MAX(y, fy),fy+dfy); 88 } 89 83 90 dir = ((naxis == 0) || (naxis == 1)) ? +1 : -1; 84 91 dx = dir*size*dfy*n; -
trunk/Ohana/src/kapa2/src/SetGraphData.c
r27790 r38986 27 27 graph[0].axis[2].labelPad = graph[0].data.labelPadXp; 28 28 graph[0].axis[3].labelPad = graph[0].data.labelPadYp; 29 30 graph[0].axis[0].fLabelRange = graph[0].data.fLabelRangeXm; 31 graph[0].axis[1].fLabelRange = graph[0].data.fLabelRangeYm; 32 graph[0].axis[2].fLabelRange = graph[0].data.fLabelRangeXp; 33 graph[0].axis[3].fLabelRange = graph[0].data.fLabelRangeYp; 34 35 graph[0].axis[0].fMinor = graph[0].data.fMinorXm; 36 graph[0].axis[1].fMinor = graph[0].data.fMinorYm; 37 graph[0].axis[2].fMinor = graph[0].data.fMinorXp; 38 graph[0].axis[3].fMinor = graph[0].data.fMinorYp; 29 39 30 40 graph[0].axis[0].pad = graph[0].data.padXm; -
trunk/Ohana/src/kapa2/src/bDrawFrame.c
r34088 r38986 84 84 y = fy + (value-min)*dfy/(max - min); 85 85 86 if ((naxis == 0) || (naxis == 2)) { 87 x = MIN(MAX(x, fx),fx+dfx); 88 } 89 if ((naxis == 1) || (naxis == 3)) { 90 y = MAX(MIN(y, fy),fy+dfy); 91 } 92 86 93 dir = ((naxis == 0) || (naxis == 1)) ? -1 : +1; 87 94 dx = dir*size*dfy*n; -
trunk/Ohana/src/libautocode/Makefile.Targets
r38553 r38986 56 56 $(ASRC)/starpar-ps1-sim.$(ARCH).o \ 57 57 $(ASRC)/galphot.$(ARCH).o \ 58 $(ASRC)/galphot-ps1-v5.$(ARCH).o \ 58 $(ASRC)/galphot-ps1-v5-r0.$(ARCH).o \ 59 $(ASRC)/galphot-ps1-v5-r1.$(ARCH).o \ 59 60 $(ASRC)/missing.$(ARCH).o \ 60 61 $(ASRC)/photcode.$(ARCH).o \ … … 168 169 $(AINC)/starpar-ps1-sim.h \ 169 170 $(AINC)/galphot.h \ 170 $(AINC)/galphot-ps1-v5.h \ 171 $(AINC)/galphot-ps1-v5-r0.h \ 172 $(AINC)/galphot-ps1-v5-r1.h \ 171 173 $(AINC)/missing.h \ 172 174 $(AINC)/photcode.h \ -
trunk/Ohana/src/libautocode/def/average-ps1-v5.d
r38441 r38986 26 26 FIELD ChiSqAve, CHISQ_POS, float, astrometry analysis chisq 27 27 FIELD ChiSqPM, CHISQ_PM, float, astrometry analysis chisq 28 FIELD ChiSqPar, CHISQ_P AP, float, astrometry analysis chisq28 FIELD ChiSqPar, CHISQ_PLX, float, astrometry analysis chisq 29 29 FIELD Tmean, MEAN_EPOCH, int, mean epoch (PM,PAR ref), unix time seconds 30 30 FIELD Trange, TIME_RANGE, int, mean epoch (PM,PAR ref), unix time seconds … … 41 41 FIELD Nlensing, NLENSING, unsigned short, number of lensing measurements 42 42 FIELD Nlensobj, NLENSOBJ, unsigned short, number of lensing measurements 43 FIELD Ngalphot, NGALPHOT,unsigned short, number of galphot measurements43 FIELD Ngalphot, NGALPHOT, unsigned short, number of galphot measurements 44 44 45 45 FIELD measureOffset, OFF_MEASURE, int, offset to first psf measurement … … 48 48 FIELD lensobjOffset, OFF_LENSOBJ, int, offset to mean lensing data 49 49 FIELD starparOffset, OFF_STARPAR, int, offset to stellar parameter data 50 FIELD galphotOffset, OFF_GALPHOT, int, offset to galphot object entry50 FIELD galphotOffset, OFF_GALPHOT, int, offset to galphot object entry 51 51 52 52 FIELD refColorBlue, REF_COLOR_BLUE, float, color of astrometry ref stars … … 57 57 FIELD projectionID, PROJECTION_ID, short, ID of projection for primary skycell 58 58 59 FIELD Nstarpar, DUMMY,short, number of stellar parameter entries59 FIELD Nstarpar, N_STAR_PAR, short, number of stellar parameter entries 60 60 FIELD dummy, DUMMY, short, unassigned bytes 61 61 … … 69 69 FIELD catID, CAT_ID, unsigned int, unique ID for table in which object was first realized 70 70 FIELD extID, EXT_ID, uint64_t, external ID for object (eg PSPS objID) 71 FIELD extIDgc, EXT_ID_GC, uint64_t, external ID for object in galactic coords 71 72 # replace extIDgc (unused) with uRgal, uDgal: 73 # FIELD extIDgc, EXT_ID_GC, uint64_t, external ID for object in galactic coords 74 FIELD uRgal, U_RA_GAL, float, modeled proper motion based on galactic motion 75 FIELD uDgal, U_DEC_GAL, float, modeled proper motion based on galactic motion 72 76 73 77 # 4 double, 2 uint64_t, 17 float, 12 int, 6 short -
trunk/Ohana/src/libautocode/def/average.d
r38601 r38986 69 69 FIELD catID, CAT_ID, unsigned int, unique ID for table in which object was first realized 70 70 FIELD extID, EXT_ID, uint64_t, external ID for object (eg PSPS objID) 71 FIELD extIDgc, EXT_ID_GC, uint64_t, external ID for object in galactic coords 71 72 # replace extIDgc (unused) with uRgal, uDgal: 73 # FIELD extIDgc, EXT_ID_GC, uint64_t, external ID for object in galactic coords 74 FIELD uRgal, U_RA_GAL, float, modeled proper motion based on galactic motion 75 FIELD uDgal, U_DEC_GAL, float, modeled proper motion based on galactic motion 72 76 73 77 # this structure should only be used for internal representations -
trunk/Ohana/src/libautocode/def/measure-ps1-v5.d
r38062 r38986 70 70 FIELD psfNdof, PSF_NDOF, int, psf degrees of freedom 71 71 FIELD psfNpix, PSF_NPIX, int, psf number of pixels 72 FIELD photFlags2, PHOT_FLAGS ,int, flags supplied by photometry program72 FIELD photFlags2, PHOT_FLAGS2, int, flags supplied by photometry program 73 73 FIELD extNsigma, EXT_NSIGMA, float, Nsigma deviation towards EXT 74 74 -
trunk/Ohana/src/libautocode/def/measure.d
r38062 r38986 42 42 FIELD XoffCAM, X_OFF_CAM, float, X offset from correction, pixels 43 43 FIELD YoffCAM, Y_OFF_CAM, float, Y offset from correction, pixels 44 45 # XXX I can deprecate these as I am going to apply the correct uR,uD offset 46 # XXX not sure how to use this yet... 44 47 FIELD RoffGAL, R_OFF_GAL, float, RA offset from correction, arcsec 45 48 FIELD DoffGAL, D_OFF_GAL, float, DEC offset from correction, arcsec -
trunk/Ohana/src/libautocode/def/secfilt-ps1-v5.d
r37246 r38986 10 10 FIELD Map, MAG_AP, float, ave aperture mag in this band, mags 11 11 FIELD dMap, MAG_AP_ERR, float, ave aperture mag in this band, mags 12 FIELD sMap, MAG_AP_STDEV, float, standard deviation of ap mags, mags12 FIELD sMap, MAG_AP_STDEV, float, standard deviation of ap mags, mags 13 13 FIELD Mkron, MAG_KRON, float, ave kron mag in this band, mags 14 14 FIELD dMkron, MAG_KRON_ERR, float, formal error on average kron mag, mags 15 FIELD sMkron, MAG_KRON_STDEV, float, standard deviation of kron mags, mags15 FIELD sMkron, MAG_KRON_STDEV, float, standard deviation of kron mags, mags 16 16 17 17 # XXX I could add these fields to secfilt or calculate in dvopsps? -
trunk/Ohana/src/libdvo/Makefile
r38472 r38986 6 6 HOME = $(ROOT)/src/libdvo 7 7 AUTO = $(ROOT)/src/libautocode 8 BIN = $(HOME)/bin 8 9 LIB = $(HOME)/lib 9 10 SRC = $(HOME)/src … … 22 23 FULL_LDFLAGS = $(BASE_LDFLAGS) -lFITS -lohana 23 24 24 default: install 25 TEST_CFLAGS = $(BASE_CFLAGS) 26 TEST_CPPFLAGS = $(BASE_CPPFLAGS) 27 TEST_LDFLAGS = $(BASE_LDFLAGS) -ldvo -lFITS -lohana -ltap_ohana 28 29 TESTPROG = tap_AstromOffsetMapIO 30 $(TESTPROG) : % : $(TESTBIN)/% 31 test: $(TESTPROG) 32 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 | $(TESTHARNESS); done 33 test.verbose: $(TESTPROG) 34 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 |& $(TESTHARNESS) -v; done 35 25 36 install: $(DESTLIB)/libdvo.a $(DESTLIB)/libdvo.$(DLLTYPE) 26 37 libdvo: $(LIB)/libdvo.$(ARCH).a $(LIB)/libdvo.$(ARCH).$(DLLTYPE) … … 183 194 cd $(AUTO) && $(MAKE) clean 184 195 185 TESTPROG = 186 $(TESTPROG) : % : $(TESTBIN)/% $(OBJS) 187 test: $(TESTPROG) 188 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 | $(TESTHARNESS); done 189 test.verbose: $(TESTPROG) 190 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 |& $(TESTHARNESS) -v; done 191 192 .PRECIOUS: $(ASRC)/%.c 196 # .PRECIOUS: $(ASRC)/%.c -
trunk/Ohana/src/libdvo/include/dvo.h
r38649 r38986 171 171 ID_PROPER = 0x00000010, // star with large proper motion 172 172 ID_TRANSIENT = 0x00000020, // identified as a non-periodic (stationary) transient 173 ID_VARIABLE = 0x00000040, // identified as a period variable173 ID_VARIABLE = 0x00000040, // identified as a periodic variable 174 174 ID_ASTEROID = 0x00000080, // identified with a known solar-system object (asteroid or other) 175 // bits 0x00000100 - 0x00008000 are currently unused 175 ID_STACK_ASTROM = 0x00000100, // stack position used for astrometry 176 177 // bits 0x00000200 - 0x00008000 are currently unused 176 178 ID_STAR_FIT_AVE = 0x00010000, // average position fitted 177 179 ID_STAR_FIT_PM = 0x00020000, // proper motion fitted … … 813 815 int sorted; /* is measure table average-sorted? (NOTE this is an int only because gfits_scan %t requires it) */ 814 816 815 816 817 /* pointers for data manipulation */ 817 818 off_t *found_t; … … 819 820 820 821 char *measureRank; 821 // off_t *image_t;822 // off_t *mosaic_t;823 // float *X_t;824 // float *Y_t;825 822 int *nOwn_t; // relastro uses this to count owned detections per object 826 823 … … 840 837 int gfits_db_free PROTO((FITS_DB *db)); 841 838 839 int gfits_fread_uncompressed (Catalog *catalog, FTable *ftable, char *nativeOrder, char VERBOSE); 840 842 841 char *libdvo_version (void); 843 842 … … 903 902 float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt); 904 903 904 int PhotSecfiltFlags (PhotCode *code, Average *average, SecFilt *secfilt); 905 int PhotNcode (PhotCode *code, Average *average, SecFilt *secfilt); 905 906 int PhotNphot (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 906 907 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); … … 969 970 void dvo_catalog_test (Catalog *catalog, int halt); 970 971 971 int dvo_catalog_backup (Catalog *catalog, int primary);972 int dvo_catalog_unlink_backup (Catalog *catalog, int primary);972 int dvo_catalog_backup (Catalog *catalog, char *suffix, int primary); 973 int dvo_catalog_unlink_backup (Catalog *catalog, char *suffix, int primary); 973 974 974 975 /* catmode-specific APIs */ -
trunk/Ohana/src/libdvo/include/dvodb.h
r38638 r38986 356 356 IMAGE_FWHM_MEDIAN, 357 357 IMAGE_EXPTIME, 358 IMAGE_EXPNAME_AS_INT, 358 359 IMAGE_NSTAR, 359 360 IMAGE_NCAL, -
trunk/Ohana/src/libdvo/include/get_graphdata.h
r31647 r38986 11 11 double labelPadXm, labelPadYm, labelPadXp, labelPadYp; 12 12 double padXm, padXp, padYm, padYp; 13 double fLabelRangeXm, fLabelRangeXp, fLabelRangeYm, fLabelRangeYp; 14 double fMinorXm, fMinorXp, fMinorYm, fMinorYp; 13 15 Coords coords; 14 16 int flipeast, flipnorth; -
trunk/Ohana/src/libdvo/include/libdvo_astro.h
r38462 r38986 56 56 float dX; 57 57 float dY; 58 float * *dXv;59 float * *dYv;58 float *dXv; 59 float *dYv; 60 60 unsigned int tableID; 61 61 unsigned int imageID; … … 65 65 typedef struct { 66 66 int Nmap; 67 int NMAP; 67 68 AstromOffsetMap **map; 68 69 int *imageIDtoTableSeq; … … 160 161 161 162 /* in AstromOffsetMapIO.c */ 162 AstromOffsetTable *AstromOffsetMapLoad (char *filename, int VERBOSE);163 AstromOffsetTable *AstromOffsetMapLoad (char *filename, int Nrows, int VERBOSE); 163 164 int AstromOffsetMapSave (AstromOffsetTable *table, char *filename); 164 165 AstromOffsetTable *AstromOffsetMapToTable(AstromOffsetMap_Disk_6x6 *map_disk, off_t Nmap); 165 166 AstromOffsetMap_Disk_6x6 *AstromOffsetTableToMap(AstromOffsetTable *table, off_t *Nmap); 167 int AstromOffsetTableSetIDs (AstromOffsetTable *table); 168 AstromOffsetTable *AstromOffsetMapAppendToTable(AstromOffsetTable *table, AstromOffsetMap_Disk_6x6 *map_disk, off_t Nmap); 166 169 167 170 /* in AstromOffsetMapOps.c */ 168 171 float AstromOffsetMapValue (AstromOffsetMap *map, float x, float y, int xdir); 169 int AstromOffsetMapFit (AstromOffsetMap *map, float *x, float *y, float *f, int Npts, int xdir);172 int AstromOffsetMapFit (AstromOffsetMap *map, float *x, float *y, float *f, float *df, int Npts, int xdir); 170 173 171 174 /* in AstromOffsetMapUtils.c */ -
trunk/Ohana/src/libdvo/include/ps1_v5_defs.h
r38441 r38986 23 23 StarPar_PS1_V5 *StarParInternalTo_PS1_V5 (StarPar *in, off_t Nvalues); 24 24 25 GalPhot *GalPhot_PS1_V5_ToInternal (GalPhot_PS1_V5 *in, off_t Nvalues); 26 GalPhot_PS1_V5 *GalPhotInternalTo_PS1_V5 (GalPhot *in, off_t Nvalues); 25 GalPhot *GalPhot_PS1_V5_R1_ToInternal (GalPhot_PS1_V5_R1 *in, off_t Nvalues); 26 GalPhot *GalPhot_PS1_V5_R0_ToInternal (GalPhot_PS1_V5_R0 *in, off_t Nvalues); 27 28 GalPhot_PS1_V5_R1 *GalPhotInternalTo_PS1_V5_R1 (GalPhot *in, off_t Nvalues); 27 29 28 30 PhotCode *PhotCode_PS1_V5_To_Internal (PhotCode_PS1_V5 *in, off_t Nvalues); -
trunk/Ohana/src/libdvo/src/AstromOffsetMapIO.c
r38441 r38986 1 1 # include "dvo.h" 2 2 3 AstromOffsetTable *AstromOffsetMapLoad (char *filename, int VERBOSE) {3 AstromOffsetTable *AstromOffsetMapLoad (char *filename, int Nrows, int VERBOSE) { 4 4 5 5 off_t Nmap; … … 7 7 Header header; 8 8 Matrix matrix; 9 9 10 Header theader; 10 11 FTable ftable; 12 ftable.header = &theader; 13 ftable.buffer = NULL; 11 14 12 15 FILE *f = fopen (filename, "r"); … … 17 20 18 21 /* load in table data */ 19 ftable.header = &theader;20 22 if (!gfits_fread_header (f, &header)) { 21 23 if (VERBOSE) fprintf (stderr, "can't read Astrom Offset Map header\n"); … … 30 32 } 31 33 32 // for now, we only have one flavor (6x6) 33 34 if (!gfits_fread_ftable (f, &ftable, "ASTROM_OFFSET_MAP_DISK_6x6")) { 35 if (VERBOSE) fprintf (stderr, "can't read Astrom Offset Map table\n"); 36 gfits_free_header (&header); 37 gfits_free_matrix (&matrix); 38 fclose (f); 39 return (NULL); 40 } 41 AstromOffsetMap_Disk_6x6 *map_disk = gfits_table_get_AstromOffsetMap_Disk_6x6 (&ftable, &Nmap, NULL, NULL); 42 if (!map_disk) { 43 fprintf (stderr, "ERROR: failed to read Astrom Offset Map\n"); 44 exit (2); 45 } 46 47 // AstromOffsetMap_Disk_6x6 *map_disk is an external format stored as an array of maps. 48 // Convert the disk array of maps to then internal format in a rich structure: 49 AstromOffsetTable *table = AstromOffsetMapToTable (map_disk, Nmap); 34 // the output table is not what is stored in the FITS file. read and convert 35 // from the disk file format 36 AstromOffsetTable *table = NULL; 37 38 // for now, we only have one flavor (6x6) of disk file format 39 40 // loop over the ftable reading blocks of 100k rows at a time 41 if (Nrows) { 42 if (!gfits_find_Xheader (f, ftable.header, "ASTROM_OFFSET_MAP_DISK_6x6")) myAbort ("problem 1"); 43 int NrowsTotal = ftable.header[0].Naxis[1]; 44 int Nblocks = (NrowsTotal % Nrows) ? (int) (NrowsTotal / Nrows) + 1 : (NrowsTotal / Nrows); 45 46 // allocate the full array up front. passes through AstromOffsetMapAppendToTable 47 // check the current allocation and will bump the allocation as needed. 48 ALLOCATE (table, AstromOffsetTable, 1); 49 ALLOCATE (table->map, AstromOffsetMap *, NrowsTotal); 50 table->Nmap = 0; 51 table->NMAP = NrowsTotal; 52 53 // on each call to gfits_fread_ftable_range, we need to reset the FILE pointer to the 54 // beginning of the data block. again this seems a little wrong. 55 off_t diskStart = ftello (f); 56 57 int i; 58 for (i = 0; i < Nblocks; i++) { 59 if (!gfits_fread_ftable_range (f, FALSE, FALSE, &ftable, i*Nrows, Nrows)) myAbort ("problem 2"); 60 61 AstromOffsetMap_Disk_6x6 *map_disk = gfits_table_get_AstromOffsetMap_Disk_6x6 (&ftable, &Nmap, NULL, NULL); 62 if (!map_disk) myAbort ("ERROR: failed to read Astrom Offset Map\n"); 63 64 table = AstromOffsetMapAppendToTable (table, map_disk, Nmap); 65 66 // XXX this is kind of hack-ish: gfits_fread_ftable_range modifies Naxis[1] to the 67 // number of rows actually read, but this makes a subsequent read invalid. I'm 68 // resetting the value of Naxis[1] before the next read to deal with this problem. 69 // But is there a more consistent way to address this? 70 71 // Answer: the FTable structure could include information about the table 72 // representation on disk, including start,Nrows values. I'm not going to mess 73 // around with that just now. 74 75 ftable.header[0].Naxis[1] = NrowsTotal; 76 fseeko (f, diskStart, SEEK_SET); 77 } 78 AstromOffsetTableSetIDs (table); 79 gfits_free_header (ftable.header); 80 gfits_free_table (&ftable); 81 } else { 82 83 // convert the blocks into the equivalent table entries and append 84 if (!gfits_fread_ftable (f, &ftable, "ASTROM_OFFSET_MAP_DISK_6x6")) { 85 if (VERBOSE) fprintf (stderr, "can't read Astrom Offset Map table\n"); 86 gfits_free_header (&header); 87 gfits_free_matrix (&matrix); 88 fclose (f); 89 return (NULL); 90 } 91 AstromOffsetMap_Disk_6x6 *map_disk = gfits_table_get_AstromOffsetMap_Disk_6x6 (&ftable, &Nmap, NULL, NULL); 92 if (!map_disk) { 93 fprintf (stderr, "ERROR: failed to read Astrom Offset Map\n"); 94 exit (2); 95 } 96 97 // AstromOffsetMap_Disk_6x6 *map_disk is an external format stored as an array of maps. 98 // Convert the disk array of maps to then internal format in a rich structure: 99 table = AstromOffsetMapToTable (map_disk, Nmap); 100 gfits_free_table (&ftable); 101 } 50 102 51 103 gfits_free_header (&theader); 52 104 gfits_free_matrix (&matrix); 53 gfits_free_table (&ftable);54 105 55 106 return (table); … … 135 186 table->map[i][0].Nx = map_disk[i].Nx; 136 187 table->map[i][0].Ny = map_disk[i].Ny; 137 table->map[i][0].tableID = map_disk[i].tableID;138 table->map[i][0].imageID = map_disk[i].imageID;188 table->map[i][0].tableID = map_disk[i].tableID; 189 table->map[i][0].imageID = map_disk[i].imageID; 139 190 140 191 // STORE THESE VALUES? 141 table->map[i][0].d Y= map_disk[i].dX;142 table->map[i][0].d X= map_disk[i].dY;192 table->map[i][0].dX = map_disk[i].dX; 193 table->map[i][0].dY = map_disk[i].dY; 143 194 144 195 // since this was on disk, we obviously keep it 145 196 table->map[i][0].keep = TRUE; 146 197 147 ALLOCATE (table->map[i][0].dXv, float *, map_disk[i].Nx);148 ALLOCATE (table->map[i][0].dYv, float *, map_disk[i].Nx);149 150 for (j = 0; j < map_disk[i].Nx; j++) {151 ALLOCATE (table->map[i][0].dXv[j], float, map_disk[i].Ny);152 ALLOCATE (table->map[i][0].dYv[j], float, map_disk[i].Ny); 153 154 for (k = 0; k < map_disk[i].Ny; k++) {155 table->map[i][0].dXv[j ][k] = map_disk[i].dXv[j][k];156 table->map[i][0].dYv[j ][k] = map_disk[i].dYv[j][k];198 int Nx = table->map[i][0].Nx; 199 int Ny = table->map[i][0].Ny; 200 201 ALLOCATE (table->map[i][0].dXv, float, Nx*Ny); 202 ALLOCATE (table->map[i][0].dYv, float, Nx*Ny); 203 204 for (j = 0; j < Nx; j++) { 205 for (k = 0; k < Ny; k++) { 206 table->map[i][0].dXv[j + k*Nx] = map_disk[i].dXv[j][k]; 207 table->map[i][0].dYv[j + k*Nx] = map_disk[i].dYv[j][k]; 157 208 } 158 209 } … … 182 233 map_disk[Ndisk].dY = table->map[i][0].dY; 183 234 184 185 186 for (j = 0; j < map_disk[Ndisk].Nx; j++) { 187 for (k = 0; k < map_disk[Ndisk].Ny; k++) { 188 map_disk[Ndisk].dXv[j][k] = table->map[i][0].dXv[j][k]; 189 map_disk[Ndisk].dYv[j][k] = table->map[i][0].dYv[j][k]; 235 int Nx = table->map[i][0].Nx; 236 int Ny = table->map[i][0].Ny; 237 238 for (j = 0; j < Nx; j++) { 239 for (k = 0; k < Ny; k++) { 240 map_disk[Ndisk].dXv[j][k] = table->map[i][0].dXv[j + k*Nx]; 241 map_disk[Ndisk].dYv[j][k] = table->map[i][0].dYv[j + k*Nx]; 190 242 } 191 243 for (k = map_disk[Ndisk].Ny; k < 6; k++) { … … 206 258 } 207 259 260 AstromOffsetTable *AstromOffsetMapAppendToTable(AstromOffsetTable *table, AstromOffsetMap_Disk_6x6 *map_disk, off_t Nmap) { 261 262 int i, j, k, Nstart; 263 264 if (table == NULL) { 265 ALLOCATE (table, AstromOffsetTable, 1); 266 Nstart = 0; 267 table->Nmap = Nmap; 268 ALLOCATE (table->map, AstromOffsetMap *, Nmap); 269 } else { 270 Nstart = table->Nmap; 271 if (table->Nmap + Nmap > table->NMAP) { 272 table->NMAP = table->Nmap + Nmap; 273 REALLOCATE (table->map, AstromOffsetMap *, table->NMAP); 274 } 275 table->Nmap += Nmap; 276 } 277 278 // append map values (this allocates just the area needed for each image, not the 279 // full 6x6, saving some memory while doing the analysis) 280 for (i = 0; i < Nmap; i++) { 281 int N = i + Nstart; 282 ALLOCATE (table->map[N], AstromOffsetMap, 1); 283 284 table->map[N][0].Nx = map_disk[i].Nx; 285 table->map[N][0].Ny = map_disk[i].Ny; 286 table->map[N][0].tableID = map_disk[i].tableID; 287 table->map[N][0].imageID = map_disk[i].imageID; 288 289 // STORE THESE VALUES? 290 table->map[N][0].dX = map_disk[i].dX; 291 table->map[N][0].dY = map_disk[i].dY; 292 293 // since this was on disk, we obviously keep it 294 table->map[N][0].keep = TRUE; 295 296 int Nx = table->map[N][0].Nx; 297 int Ny = table->map[N][0].Ny; 298 299 ALLOCATE (table->map[N][0].dXv, float, Nx*Ny); 300 ALLOCATE (table->map[N][0].dYv, float, Nx*Ny); 301 302 for (j = 0; j < Nx; j++) { 303 for (k = 0; k < Ny; k++) { 304 table->map[N][0].dXv[j + k*Nx] = map_disk[i].dXv[j][k]; 305 table->map[N][0].dYv[j + k*Nx] = map_disk[i].dYv[j][k]; 306 } 307 } 308 } 309 return table; 310 } 311 312 int AstromOffsetTableSetIDs (AstromOffsetTable *table) { 313 314 int i; 315 316 // find the max value of imageID 317 int MaxTableID = 0; 318 int MaxImageID = 0; 319 for (i = 0; i < table->Nmap; i++) { 320 MaxTableID = MAX(table->map[i][0].tableID, MaxTableID); 321 MaxImageID = MAX(table->map[i][0].imageID, MaxImageID); 322 } 323 table->MaxTableID = MaxTableID; 324 table->MaxImageID = MaxImageID; 325 326 // generate the index and init values to -1 327 ALLOCATE (table->imageIDtoTableSeq, int, MaxImageID + 1); 328 for (i = 0; i <= MaxImageID; i++) { 329 table->imageIDtoTableSeq[i] = -1; 330 } 331 332 // assign the ID values 333 for (i = 0; i < table->Nmap; i++) { 334 int ImageID = table->map[i][0].imageID; 335 myAssert (table->imageIDtoTableSeq[ImageID] == -1, "oops, duplicate image IDs"); 336 table->imageIDtoTableSeq[ImageID] = i; 337 } 338 return TRUE; 339 } -
trunk/Ohana/src/libdvo/src/AstromOffsetMapOps.c
r37807 r38986 6 6 int dump_map_data (float *x, float *y, float *f, int Npts, char *filename); 7 7 int AstromOffsetMapFit_Chisq (AstromOffsetMap *map, float *x, float *y, float *f, int Npts, int xdir); 8 int AstromOffsetMapFit_Me dian (AstromOffsetMap *map, float *x, float *y, float *f, int Npts, int xdir);8 int AstromOffsetMapFit_Mean (AstromOffsetMap *map, float *x, float *y, float *f, float *df, int Npts, int xdir); 9 9 10 10 float AstromOffsetMapValue (AstromOffsetMap *map, float x, float y, int xdir) { … … 12 12 // given x,y find the offset (x-direction) at that location from the map 13 13 14 float **V = xdir ? map->dXv : map->dYv; 14 int Nx = map->Nx; 15 int Ny = map->Ny; 16 17 float *V = xdir ? map->dXv : map->dYv; 15 18 16 19 // if there is no spatial information, the value at the point is the value in the map 17 if (( map->Nx == 1) && (map->Ny == 1)) return V[0][0];20 if ((Nx == 1) && (Ny == 1)) return V[0]; 18 21 19 22 // if there is no spatial information in 1D, the interpolation is 1D 20 if ( map->Nx == 1) {23 if (Nx == 1) { 21 24 float ymo = y * map->dY - 0.5; 22 25 int ymi = floor(ymo); 23 ymi = MAX(0,MIN( map->Ny - 2, ymi)); // force range of ymi to be 0,Ny-2 (Ny must be > 1)26 ymi = MAX(0,MIN(Ny - 2, ymi)); // force range of ymi to be 0,Ny-2 (Ny must be > 1) 24 27 25 28 float ymf = ymo - ymi; 26 29 27 float value = ymf * V[ 0][ymi+1] + (1.0 - ymf) * V[0][ymi];30 float value = ymf * V[ymi+1] + (1.0 - ymf) * V[ymi]; 28 31 return value; 29 32 } 30 33 31 34 // if there is no spatial information in 1D, the interpolation is 1D 32 if ( map->Ny == 1) {35 if (Ny == 1) { 33 36 float xmo = x * map->dX - 0.5; 34 37 int xmi = floor(xmo); 35 xmi = MAX(0,MIN( map->Nx - 2, xmi)); // force range of ymi to be 0,Nx-2 (Nx must be > 1)38 xmi = MAX(0,MIN(Nx - 2, xmi)); // force range of ymi to be 0,Nx-2 (Nx must be > 1) 36 39 37 40 float xmf = xmo - xmi; 38 41 39 float value = xmf * V[xmi+1] [0] + (1.0 - xmf) * V[xmi][0];42 float value = xmf * V[xmi+1] + (1.0 - xmf) * V[xmi]; 40 43 return value; 41 44 } … … 45 48 float xmo = x * map->dX - 0.5; 46 49 int xmi = floor(xmo); 47 xmi = MAX(0,MIN( map->Nx - 2, xmi)); // force range of ymi to be 0,Nx-150 xmi = MAX(0,MIN(Nx - 2, xmi)); // force range of ymi to be 0,Nx-1 48 51 float xmf = xmo - xmi; 49 52 50 53 float ymo = y * map->dY - 0.5; 51 54 int ymi = floor(ymo); 52 ymi = MAX(0,MIN( map->Ny - 2, ymi)); // force range of ymi to be 0,Ny-255 ymi = MAX(0,MIN(Ny - 2, ymi)); // force range of ymi to be 0,Ny-2 53 56 float ymf = ymo - ymi; 54 57 55 float V00 = V[xmi+0 ][ymi+0];56 float V01 = V[xmi+0 ][ymi+1];57 float V10 = V[xmi+1 ][ymi+0];58 float V11 = V[xmi+1 ][ymi+1];58 float V00 = V[xmi+0 + (ymi+0)*Nx]; 59 float V01 = V[xmi+0 + (ymi+1)*Nx]; 60 float V10 = V[xmi+1 + (ymi+0)*Nx]; 61 float V11 = V[xmi+1 + (ymi+1)*Nx]; 59 62 60 63 float Vx0 = V10*xmf + V00*(1.0 - xmf); … … 65 68 } 66 69 67 int AstromOffsetMapFit (AstromOffsetMap *map, float *x, float *y, float *f, int Npts, int xdir) {68 69 int status = AstromOffsetMapFit_Me dian (map, x, y,f, Npts, xdir);70 int AstromOffsetMapFit (AstromOffsetMap *map, float *x, float *y, float *f, float *df, int Npts, int xdir) { 71 72 int status = AstromOffsetMapFit_Mean (map, x, y, f, df, Npts, xdir); 70 73 return status; 71 74 } … … 78 81 79 82 // choose to map direction: 80 float * *V= xdir ? map->dXv : map->dYv;83 float *Vptr = xdir ? map->dXv : map->dYv; 81 84 82 85 // special cases: … … 88 91 89 92 vstats_getstats_f (f, NULL, NULL, Npts, &stats); 90 V [0][0] = stats.mean;93 Vptr[0] = stats.mean; 91 94 return TRUE; 92 95 } … … 352 355 for (iy = 0; iy < Ny; iy++) { 353 356 int I = ix + Nx * iy; 354 V [ix][iy] = B[I][0];357 Vptr[I] = B[I][0]; 355 358 // error[ix][iy] = sqrt(A[I][I]); 356 359 } … … 371 374 // given (x,y),value vector sets, choose the map that minimizes the difference between 372 375 // the values and bilinear interpolation of the map 373 int AstromOffsetMapFit_Me dian (AstromOffsetMap *map, float *x, float *y, float *f, int Npts, int xdir) {376 int AstromOffsetMapFit_Mean (AstromOffsetMap *map, float *x, float *y, float *f, float *df, int Npts, int xdir) { 374 377 375 378 int i, ix, iy; 376 379 377 380 // choose to map direction: 378 float * *V= xdir ? map->dXv : map->dYv;381 float *Vptr = xdir ? map->dXv : map->dYv; 379 382 380 383 // measure clipped median in each bin … … 386 389 int Npix = Nx*Ny; 387 390 388 double **values ;391 double **values, **dvalues; 389 392 int *Nvalue; 390 393 ALLOCATE (Nvalue, int, Npix); 391 394 ALLOCATE (values, double *, Npix); 395 ALLOCATE (dvalues, double *, Npix); 392 396 for (i = 0; i < Npix; i++) { 393 397 ALLOCATE (values[i], double, Npts); 398 ALLOCATE (dvalues[i], double, Npts); 394 399 Nvalue[i] = 0; 395 400 } … … 400 405 // data value & weight for this point 401 406 if (!isfinite(f[i])) continue; 407 if (df && !isfinite(df[i])) continue; 408 if (df && df[i] == 0.0) continue; 402 409 403 410 // if (mask && (mask[i] & maskValue)) continue; … … 414 421 int N = Nvalue[I]; 415 422 values[I][N] = f[i]; 423 dvalues[I][N] = df ? df[i] : 1.0; 416 424 Nvalue[I] ++; 417 425 } … … 421 429 int I = ix + Nx * iy; 422 430 if (Nvalue[I] > 5) { 423 vstats_getstats (values[I], NULL, NULL, Nvalue[I], &stats);424 V [ix][iy] = stats.mean;431 vstats_getstats (values[I], dvalues[I], NULL, Nvalue[I], &stats); 432 Vptr[I] = stats.mean; 425 433 } else { 426 V [ix][iy] = NAN;434 Vptr[I] = NAN; 427 435 } 428 436 } … … 432 440 for (i = 0; i < Npix; i++) { 433 441 free (values[i]); 442 free (dvalues[i]); 434 443 } 435 444 free (values); 445 free (dvalues); 436 446 free (Nvalue); 437 447 … … 453 463 int ix, iy; 454 464 455 float * *Vfix = NULL;456 ALLOCATE (Vfix, float *, Nx);465 float *Vfix = NULL; 466 ALLOCATE (Vfix, float, Nx*Ny); 457 467 for (ix = 0; ix < Nx; ix++) { 458 ALLOCATE (Vfix[ix], float, Ny); 459 for (iy = 0; iy < Ny; iy++) { 460 Vfix[ix][iy] = NAN; 468 for (iy = 0; iy < Ny; iy++) { 469 Vfix[ix + iy*Nx] = NAN; 461 470 } 462 471 } … … 468 477 for (ix = 0; ix < Nx; ix++) { 469 478 for (iy = 0; iy < Ny; iy++) { 470 float value = xdir ? map->dXv[ix][iy] : map->dYv[ix][iy]; 479 int I = ix + iy*Nx; 480 float value = xdir ? map->dXv[I] : map->dYv[I]; 471 481 if (isnan(value)) continue; 472 482 mean += value; … … 479 489 for (ix = 0; ix < Nx; ix++) { 480 490 for (iy = 0; iy < Ny; iy++) { 481 482 float value = xdir ? map->dXv[ ix][iy] : map->dYv[ix][iy];491 int I = ix + iy*Nx; 492 float value = xdir ? map->dXv[I] : map->dYv[I]; 483 493 if (!isnan(value)) { 484 Vfix[ ix][iy] = value;494 Vfix[I] = value; 485 495 continue; 486 496 } … … 499 509 if (ny < 0) continue; 500 510 if (ny >= Ny) continue; 501 float value = xdir ? map->dXv[nx][ny] : map->dYv[nx][ny]; 511 int I = ix + iy*Nx; 512 float value = xdir ? map->dXv[I] : map->dYv[I]; 502 513 if (isnan(value)) continue; 503 514 … … 508 519 // if there are no valid (non-NAN) local pixels, use global mean 509 520 meanLocal = (npixLocal > 0.0) ? meanLocal / npixLocal : mean; 510 Vfix[ ix][iy] = meanLocal;521 Vfix[I] = meanLocal; 511 522 } 512 523 } … … 515 526 for (ix = 0; ix < Ny; ix++) { 516 527 for (iy = 0; iy < Ny; iy++) { 528 int I = ix + iy*Nx; 517 529 if (xdir) { 518 map->dXv[ ix][iy] = Vfix[ix][iy];530 map->dXv[I] = Vfix[I]; 519 531 } else { 520 map->dYv[ix][iy] = Vfix[ix][iy]; 521 } 522 } 523 } 524 for (ix = 0; ix < Nx; ix++) { 525 free (Vfix[ix]); 532 map->dYv[I] = Vfix[I]; 533 } 534 } 526 535 } 527 536 free (Vfix); -
trunk/Ohana/src/libdvo/src/AstromOffsetMapUtils.c
r37807 r38986 36 36 map->keep = TRUE; // output map size 37 37 38 ALLOCATE (map->dXv, float *, map->Nx); 39 ALLOCATE (map->dYv, float *, map->Nx); 40 41 int j, k; 42 for (j = 0; j < map->Nx; j++) { 43 ALLOCATE (map->dXv[j], float, map->Ny); 44 ALLOCATE (map->dYv[j], float, map->Ny); 45 46 for (k = 0; k < map->Ny; k++) { 47 map->dXv[j][k] = 0.0; 48 map->dYv[j][k] = 0.0; 38 ALLOCATE (map->dXv, float, Nx*Ny); 39 ALLOCATE (map->dYv, float, Nx*Ny); 40 41 int j, k; 42 for (j = 0; j < Nx; j++) { 43 for (k = 0; k < Ny; k++) { 44 map->dXv[j + k*Nx] = 0.0; 45 map->dYv[j + k*Nx] = 0.0; 49 46 } 50 47 } … … 56 53 57 54 if (!map) return; 58 59 int j;60 for (j = 0; j < map->Nx; j++) {61 if (map->dXv) free (map->dXv[j]);62 if (map->dYv) free (map->dYv[j]);63 }64 55 65 56 free (map->dXv); … … 76 67 77 68 // rather than try to figure out how to resize, and free/allocate, lets just free the old arrays and make new ones 78 for (j = 0; j < map->Nx; j++) {79 if (map->dXv) free (map->dXv[j]);80 if (map->dYv) free (map->dYv[j]);81 }82 69 free (map->dXv); 83 70 free (map->dYv); … … 90 77 map->keep = TRUE; // output map size 91 78 92 ALLOCATE (map->dXv, float *, map->Nx); 93 ALLOCATE (map->dYv, float *, map->Nx); 94 95 for (j = 0; j < map->Nx; j++) { 96 ALLOCATE (map->dXv[j], float, map->Ny); 97 ALLOCATE (map->dYv[j], float, map->Ny); 98 99 for (k = 0; k < map->Ny; k++) { 100 map->dXv[j][k] = 0.0; 101 map->dYv[j][k] = 0.0; 79 ALLOCATE (map->dXv, float, Nx*Ny); 80 ALLOCATE (map->dYv, float, Nx*Ny); 81 82 for (j = 0; j < Nx; j++) { 83 for (k = 0; k < Ny; k++) { 84 map->dXv[j + k*Nx] = 0.0; 85 map->dYv[j + k*Nx] = 0.0; 102 86 } 103 87 } … … 116 100 tgt->tableID = map->tableID; 117 101 118 int j, k; 119 for (j = 0; j < tgt->Nx; j++) { 120 for (k = 0; k < map->Ny; k++) { 121 tgt->dXv[j][k] = map->dXv[j][k]; 122 tgt->dYv[j][k] = map->dYv[j][k]; 102 int Nx = map->Nx; 103 int Ny = map->Ny; 104 105 int j, k; 106 for (j = 0; j < Nx; j++) { 107 for (k = 0; k < Ny; k++) { 108 tgt->dXv[j + k*Nx] = map->dXv[j + k*Nx]; 109 tgt->dYv[j + k*Nx] = map->dYv[j + k*Nx]; 123 110 } 124 111 } … … 139 126 tgt->keep = src->keep; 140 127 141 int j, k; 142 for (j = 0; j < tgt->Nx; j++) { 143 for (k = 0; k < src->Ny; k++) { 144 tgt->dXv[j][k] = src->dXv[j][k]; 145 tgt->dYv[j][k] = src->dYv[j][k]; 128 int Nx = src->dX; 129 int Ny = src->dY; 130 131 int j, k; 132 for (j = 0; j < Nx; j++) { 133 for (k = 0; k < Ny; k++) { 134 tgt->dXv[j + k*Nx] = src->dXv[j + k*Nx]; 135 tgt->dYv[j + k*Nx] = src->dYv[j + k*Nx]; 146 136 } 147 137 } … … 153 143 if (!table) return; 154 144 155 int i , j;145 int i; 156 146 for (i = 0; i < table->Nmap; i++) { 157 for (j = 0; j < table->map[i][0].Nx; j++) {158 free (table->map[i][0].dXv[j]);159 free (table->map[i][0].dYv[j]);160 }161 147 if (!table->map[i]) continue; 162 148 FREE (table->map[i][0].dXv); … … 260 246 } 261 247 248 int Nx = map->Nx; 249 int Ny = map->Ny; 250 262 251 fprintf (f, "imageID: %d, tableID: %d (dX: %f, dY: %f), keep: %d\n", map->imageID, map->tableID, map->dX, map->dY, map->keep); 263 252 int ix, iy; 264 253 fprintf (f, "dXv map:\n"); 265 for (ix = 0; ix < map->Nx; ix++) {266 for (iy = 0; iy < map->Ny; iy++) {267 fprintf (f, "%9.5f ", map->dXv[ix ][iy]);254 for (ix = 0; ix < Nx; ix++) { 255 for (iy = 0; iy < Ny; iy++) { 256 fprintf (f, "%9.5f ", map->dXv[ix + iy*Nx]); 268 257 } 269 258 fprintf (f, "\n"); 270 259 } 271 260 fprintf (f, "dYv map:\n"); 272 for (ix = 0; ix < map->Nx; ix++) {273 for (iy = 0; iy < map->Ny; iy++) {274 fprintf (f, "%9.5f ", map->dYv[ix ][iy]);261 for (ix = 0; ix < Nx; ix++) { 262 for (iy = 0; iy < Ny; iy++) { 263 fprintf (f, "%9.5f ", map->dYv[ix + iy*Nx]); 275 264 } 276 265 fprintf (f, "\n"); -
trunk/Ohana/src/libdvo/src/LoadImages.c
r38553 r38986 85 85 86 86 if (table) AstromOffsetTableFree(table); 87 table = AstromOffsetMapLoad (mapfile, FALSE);87 table = AstromOffsetMapLoad (mapfile, 100000, FALSE); 88 88 89 89 // assign images.coords.offsetMap -> table->map[i] -
trunk/Ohana/src/libdvo/src/dbExtractImages.c
r37807 r38986 233 233 value.Flt = image[N].exptime; 234 234 break; 235 236 case IMAGE_EXPNAME_AS_INT: 237 // XXX NOTE this does not handle gpc2 images 238 if ((image[N].name[0] == 'o') && (image[N].name[5] == 'g') && (image[N].name[10] == 'o')) { 239 int mjd = atoi(&image[N].name[1]); 240 int Nexp = atoi(&image[N].name[6]); 241 value.Int = mjd * 10000 + Nexp; 242 } 243 break; 244 235 245 case IMAGE_SIDTIME: 236 246 value.Flt = image[N].sidtime; -
trunk/Ohana/src/libdvo/src/dbExtractMeasures.c
r38635 r38986 241 241 break; 242 242 243 case MAG_OPTION_STDEV: 244 case MAG_OPTION_CHISQ: 245 case MAG_OPTION_MIN: 246 case MAG_OPTION_MAX: 247 case MAG_OPTION_NCODE: 248 case MAG_OPTION_NPHOT: 249 case MAG_OPTION_UC_DIST: 250 case MAG_OPTION_FLAGS: 243 // the following are all values which are come from the secfit table 244 case MAG_OPTION_STDEV: { value.Flt = PhotMstdev (equiv, average, secfilt, field->magClass, field->magSource); break; } 245 case MAG_OPTION_CHISQ: { value.Flt = PhotXm (equiv, average, secfilt); break; } 246 case MAG_OPTION_MIN: { value.Flt = PhotMmin (equiv, average, secfilt); break;} 247 case MAG_OPTION_MAX: { value.Flt = PhotMmax (equiv, average, secfilt); break;} 248 case MAG_OPTION_NCODE: { value.Int = PhotNcode (equiv, average, secfilt); break; } 249 case MAG_OPTION_NPHOT: { value.Int = PhotNphot (equiv, average, secfilt, field->magClass, field->magSource); break; } 250 case MAG_OPTION_UC_DIST: { value.Flt = PhotUCdist (equiv, average, secfilt); break; } 251 case MAG_OPTION_FLAGS: { value.Int = PhotSecfiltFlags (equiv, average, secfilt); break; } 252 253 // the following values come from the mean lensobj table 251 254 case MAG_OPTION_X11_SM_OBJ: 252 255 case MAG_OPTION_X12_SM_OBJ: -
trunk/Ohana/src/libdvo/src/dbFields.c
r38638 r38986 356 356 dvoMagSourceType source = GetMagSource (word); 357 357 if (source != MAG_SRC_NONE) { 358 // if mySource is already set, then we have two 'source' elements (an error) 358 359 if (mySource != MAG_SRC_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 359 360 mySource = source; … … 364 365 dvoMagLevelType level = GetMagLevel (word); 365 366 if (level != MAG_LEVEL_NONE) { 367 // if myLevel is already set, then we have two 'level' elements (an error) 366 368 if (myLevel != MAG_LEVEL_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 367 369 myLevel = level; … … 372 374 dvoMagClassType class = GetMagClass (word); 373 375 if (class != MAG_CLASS_NONE) { 376 // if myClass is already set, then we have two 'class' elements (an error) 374 377 if (myClass != MAG_CLASS_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 375 378 myClass = class; … … 380 383 dvoMagOptionType option = GetMagOption (word); 381 384 if (option != MAG_OPTION_NONE) { 382 // some combinations are OK: mag + err -> err 383 if ((myOption == MAG_OPTION_MAG) && (option == MAG_OPTION_ERR)) { 385 // if myClass is already set, then we have two 'class' elements 386 // this is an error unless the request was of the form mag:value 387 // if so, then code->type will be PHOT_MAG 388 389 if (code->type == PHOT_MAG) { 390 // mag:err -> magerr 391 if ((myOption == MAG_OPTION_MAG) && (option == MAG_OPTION_ERR)) { 392 myOption = MAG_OPTION_ERR; 393 ptr = skipword (ptr); 394 continue; 395 } 396 // flux:err -> fluxerr 397 if ((myOption == MAG_OPTION_FLUX) && (option == MAG_OPTION_ERR)) { 398 myOption = MAG_OPTION_FLUX_ERR; 399 ptr = skipword (ptr); 400 continue; 401 } 384 402 myOption = option; 385 ptr = skipword (ptr);386 continue;387 }388 // some combinations are OK: err + mag -> err389 if ((myOption == MAG_OPTION_ERR) && (option == MAG_OPTION_MAG)) {390 ptr = skipword (ptr);391 continue;392 }393 // some combinations are OK: flux + err -> FLUX_ERR394 if ((myOption == MAG_OPTION_FLUX) && (option == MAG_OPTION_ERR)) {395 myOption = MAG_OPTION_FLUX_ERR;396 ptr = skipword (ptr);397 continue;398 }399 // some combinations are OK: err + flux -> FLUX_ERR400 if ((myOption == MAG_OPTION_ERR) && (option == MAG_OPTION_FLUX)) {401 myOption = MAG_OPTION_FLUX_ERR;402 ptr = skipword (ptr);403 continue;404 }405 // some combinations are OK: flux + fluxerr -> FLUX_ERR406 if ((myOption == MAG_OPTION_FLUX) && (option == MAG_OPTION_FLUX_ERR)) {407 myOption = MAG_OPTION_FLUX_ERR;408 ptr = skipword (ptr);409 continue;410 }411 // some combinations are OK: fluxerr + flux -> FLUX_ERR412 if ((myOption == MAG_OPTION_FLUX_ERR) && (option == MAG_OPTION_FLUX)) {413 myOption = MAG_OPTION_FLUX_ERR;414 403 ptr = skipword (ptr); 415 404 continue; … … 815 804 if (!strcasecmp (fieldName, "photcode" )) ESCAPE (IMAGE_PHOTCODE, OPIHI_INT); 816 805 if (!strcasecmp (fieldName, "exptime" )) ESCAPE (IMAGE_EXPTIME, OPIHI_FLT); 806 if (!strcasecmp (fieldName, "expname" )) ESCAPE (IMAGE_EXPNAME_AS_INT, OPIHI_INT); 817 807 if (!strcasecmp (fieldName, "sidtime" )) ESCAPE (IMAGE_SIDTIME, OPIHI_FLT); 818 808 -
trunk/Ohana/src/libdvo/src/dvo_catalog.c
r38553 r38986 200 200 average->catID = 0; 201 201 average->extID = 0; 202 average->extIDgc = 0; 202 203 average->uRgal = NAN; 204 average->uDgal = NAN; 203 205 } 204 206 … … 600 602 601 603 /* pointers for data manipulation */ 602 // catalog[0].X_t = NULL;603 // catalog[0].Y_t = NULL;604 604 catalog[0].nOwn_t = NULL; 605 605 catalog[0].found_t = NULL; 606 // catalog[0].image_t = NULL;607 // catalog[0].mosaic_t = NULL;608 606 catalog[0].foundWarp_t = NULL; 607 catalog[0].measureRank = NULL; 609 608 } 610 609 … … 922 921 void dvo_catalog_free (Catalog *catalog) { 923 922 923 if (!catalog) return; 924 924 925 if (catalog[0].catmode == DVO_MODE_SPLIT) { 925 926 … … 1044 1045 1045 1046 // make a backup of this catalog (including the measure, secfilt, and missing tables as needed) 1046 int dvo_catalog_backup (Catalog *catalog, int primary) {1047 int dvo_catalog_backup (Catalog *catalog, char *suffix, int primary) { 1047 1048 1048 1049 // skip empty cpt files … … 1052 1053 1053 1054 char tmpfilename[DVO_MAX_PATH]; 1054 int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s ~", catalog->filename);1055 int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s%s", catalog->filename, suffix); 1055 1056 if (status >= DVO_MAX_PATH) { 1056 1057 fprintf (stderr, "path name too long: %s\n", catalog->filename); … … 1067 1068 } 1068 1069 1070 // play it safe: do not overwrite an existing backup file 1071 struct stat fileStats; 1072 status = stat (tmpfilename, &fileStats); 1073 if (!status) { 1074 fprintf (stderr, "ERROR: backup file %s already exists, exiting\n", tmpfilename); 1075 return FALSE; 1076 } 1077 1078 // some error accessing the file. there is only one acceptable error: file not found 1079 if (status && (errno != ENOENT)) { 1080 perror ("problem with output target"); 1081 return FALSE; 1082 } 1083 1069 1084 status = rename (catalog->filename, tmpfilename); 1070 1085 if (status) { … … 1085 1100 if (catalog[0].catmode == DVO_MODE_SPLIT) { 1086 1101 if (catalog[0].measure_catalog != NULL) { 1087 if (!dvo_catalog_backup (catalog[0].measure_catalog, FALSE)) {1102 if (!dvo_catalog_backup (catalog[0].measure_catalog, suffix, FALSE)) { 1088 1103 return FALSE; 1089 1104 } 1090 1105 } 1091 1106 if (catalog[0].missing_catalog != NULL) { 1092 if (!dvo_catalog_backup (catalog[0].missing_catalog, FALSE)) {1107 if (!dvo_catalog_backup (catalog[0].missing_catalog, suffix, FALSE)) { 1093 1108 return FALSE; 1094 1109 } 1095 1110 } 1096 1111 if (catalog[0].secfilt_catalog != NULL) { 1097 if (!dvo_catalog_backup (catalog[0].secfilt_catalog, FALSE)) {1112 if (!dvo_catalog_backup (catalog[0].secfilt_catalog, suffix, FALSE)) { 1098 1113 return FALSE; 1099 1114 } … … 1104 1119 status = dvo_catalog_lock (catalog[0].lensing_catalog, lockmode); 1105 1120 } else { 1106 if (!dvo_catalog_backup (catalog[0].lensing_catalog, FALSE)) {1121 if (!dvo_catalog_backup (catalog[0].lensing_catalog, suffix, FALSE)) { 1107 1122 return FALSE; 1108 1123 } … … 1114 1129 status = dvo_catalog_lock (catalog[0].lensobj_catalog, lockmode); 1115 1130 } else { 1116 if (!dvo_catalog_backup (catalog[0].lensobj_catalog, FALSE)) {1131 if (!dvo_catalog_backup (catalog[0].lensobj_catalog, suffix, FALSE)) { 1117 1132 return FALSE; 1118 1133 } … … 1124 1139 status = dvo_catalog_lock (catalog[0].starpar_catalog, lockmode); 1125 1140 } else { 1126 if (!dvo_catalog_backup (catalog[0].starpar_catalog, FALSE)) {1141 if (!dvo_catalog_backup (catalog[0].starpar_catalog, suffix, FALSE)) { 1127 1142 return FALSE; 1128 1143 } … … 1134 1149 status = dvo_catalog_lock (catalog[0].galphot_catalog, lockmode); 1135 1150 } else { 1136 if (!dvo_catalog_backup (catalog[0].galphot_catalog, FALSE)) {1151 if (!dvo_catalog_backup (catalog[0].galphot_catalog, suffix, FALSE)) { 1137 1152 return FALSE; 1138 1153 } … … 1144 1159 1145 1160 // make a backup of this catalog (including the measure, secfilt, and missing tables as needed) 1146 int dvo_catalog_unlink_backup (Catalog *catalog, int primary) {1161 int dvo_catalog_unlink_backup (Catalog *catalog, char *suffix, int primary) { 1147 1162 1148 1163 if (primary && !catalog->Naverage_disk) { … … 1152 1167 1153 1168 char tmpfilename[DVO_MAX_PATH]; 1154 int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s ~", catalog->filename);1169 int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s%s", catalog->filename, suffix); 1155 1170 if (status >= DVO_MAX_PATH) { 1156 1171 fprintf (stderr, "path name too long: %s\n", catalog->filename); … … 1168 1183 if (catalog[0].catmode == DVO_MODE_SPLIT) { 1169 1184 if (catalog[0].measure_catalog != NULL) { 1170 if (!dvo_catalog_unlink_backup (catalog[0].measure_catalog, FALSE)) {1185 if (!dvo_catalog_unlink_backup (catalog[0].measure_catalog, suffix, FALSE)) { 1171 1186 outStatus = FALSE; 1172 1187 } 1173 1188 } 1174 1189 if (catalog[0].missing_catalog != NULL) { 1175 if (!dvo_catalog_unlink_backup (catalog[0].missing_catalog, FALSE)) {1190 if (!dvo_catalog_unlink_backup (catalog[0].missing_catalog, suffix, FALSE)) { 1176 1191 outStatus = FALSE; 1177 1192 } 1178 1193 } 1179 1194 if (catalog[0].secfilt_catalog != NULL) { 1180 if (!dvo_catalog_unlink_backup (catalog[0].secfilt_catalog, FALSE)) {1195 if (!dvo_catalog_unlink_backup (catalog[0].secfilt_catalog, suffix, FALSE)) { 1181 1196 outStatus = FALSE; 1182 1197 } 1183 1198 } 1184 1199 if ((catalog[0].lensing_catalog != NULL) && (catalog[0].Nlensing_disk > 0)) { 1185 if (!dvo_catalog_unlink_backup (catalog[0].lensing_catalog, FALSE)) {1200 if (!dvo_catalog_unlink_backup (catalog[0].lensing_catalog, suffix, FALSE)) { 1186 1201 outStatus = FALSE; 1187 1202 } 1188 1203 } 1189 1204 if ((catalog[0].lensobj_catalog != NULL) && (catalog[0].Nlensobj_disk > 0)) { 1190 if (!dvo_catalog_unlink_backup (catalog[0].lensobj_catalog, FALSE)) {1205 if (!dvo_catalog_unlink_backup (catalog[0].lensobj_catalog, suffix, FALSE)) { 1191 1206 outStatus = FALSE; 1192 1207 } 1193 1208 } 1194 1209 if ((catalog[0].starpar_catalog != NULL) && (catalog[0].Nstarpar_disk > 0)) { 1195 if (!dvo_catalog_unlink_backup (catalog[0].starpar_catalog, FALSE)) {1210 if (!dvo_catalog_unlink_backup (catalog[0].starpar_catalog, suffix, FALSE)) { 1196 1211 outStatus = FALSE; 1197 1212 } 1198 1213 } 1199 1214 if ((catalog[0].galphot_catalog != NULL) && (catalog[0].Ngalphot_disk > 0)) { 1200 if (!dvo_catalog_unlink_backup (catalog[0].galphot_catalog, FALSE)) {1215 if (!dvo_catalog_unlink_backup (catalog[0].galphot_catalog, suffix, FALSE)) { 1201 1216 outStatus = FALSE; 1202 1217 } -
trunk/Ohana/src/libdvo/src/dvo_catalog_split.c
r38553 r38986 92 92 if (OHANA_MEMCHECK) ohana_memcheck (TRUE); 93 93 94 if (!catalog->f) return TRUE; 95 94 96 /* rewind file pointers and truncate (file is still open) */ 95 97 if (fseeko (catalog->f, 0LL, SEEK_SET)) { … … 98 100 return FALSE; 99 101 } 102 103 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 100 104 101 105 // write PHU header … … 118 122 gfits_free_matrix (&matrix); 119 123 # endif 124 125 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 120 126 121 127 FTable *outtable = ftable; … … 135 141 char *compressMode = dvo_catalog_compress_string (catalog->catcompress); 136 142 // I should test how Ntile affects fpack/funpack and speed 137 if (!gfits_compress_table (ftable, &cmptable, 1000 , compressMode)) {143 if (!gfits_compress_table (ftable, &cmptable, 10000, compressMode)) { 138 144 fprintf (stderr, "compression failure\n"); 139 145 free (compressMode); … … 548 554 } 549 555 /* read Average table data : format is irrelevant here */ 550 if (!gfits_fread_ftable_range (catalog[0].f, FALSE, &ftable, start, Nrows)) {556 if (!gfits_fread_ftable_range (catalog[0].f, FALSE, FALSE, &ftable, start, Nrows)) { 551 557 if (VERBOSE) fprintf (stderr, "can't read table average data"); 552 558 return (FALSE); … … 578 584 } 579 585 /* read Secfilt table data : format is irrelevant here */ 580 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start*catalog[0].Nsecfilt, catalog[0].Naverage*catalog[0].Nsecfilt)) {586 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, FALSE, &ftable, start*catalog[0].Nsecfilt, catalog[0].Naverage*catalog[0].Nsecfilt)) { 581 587 if (VERBOSE) fprintf (stderr, "can't read table measure data"); 582 588 return (FALSE); … … 614 620 } 615 621 /* read Measure table data : format is irrelevant here */ 616 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) {622 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, FALSE, &ftable, start, Nrows)) { 617 623 if (VERBOSE) fprintf (stderr, "can't read table measure data"); 618 624 return (FALSE); … … 645 651 } 646 652 /* read Missing table data : format is irrelevant here */ 647 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) {653 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, FALSE, &ftable, start, Nrows)) { 648 654 if (VERBOSE) fprintf (stderr, "can't read table missing data"); 649 655 return (FALSE); … … 679 685 } 680 686 /* read Lensing table data : format is irrelevant here */ 681 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) {687 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, FALSE, &ftable, start, Nrows)) { 682 688 if (VERBOSE) fprintf (stderr, "can't read table lensing data"); 683 689 return (FALSE); … … 710 716 } 711 717 /* read Lensobj table data : format is irrelevant here */ 712 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) {718 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, FALSE, &ftable, start, Nrows)) { 713 719 if (VERBOSE) fprintf (stderr, "can't read table lensobj data"); 714 720 return (FALSE); … … 741 747 } 742 748 /* read StarPar table data : format is irrelevant here */ 743 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) {749 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, FALSE, &ftable, start, Nrows)) { 744 750 if (VERBOSE) fprintf (stderr, "can't read table starpar data"); 745 751 return (FALSE); … … 772 778 } 773 779 /* read GalPhot table data : format is irrelevant here */ 774 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) {780 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, FALSE, &ftable, start, Nrows)) { 775 781 if (VERBOSE) fprintf (stderr, "can't read table galphot data"); 776 782 return (FALSE); … … 842 848 } 843 849 850 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 851 844 852 Nmeasure_disk_new = MAX (catalog[0].Nmeasure_disk, catalog[0].Nmeasure + catalog[0].Nmeasure_off); 845 853 Nmissing_disk_new = MAX (catalog[0].Nmissing_disk, catalog[0].Nmissing + catalog[0].Nmissing_off); … … 865 873 /* in split mode, we can save only part of the data */ 866 874 875 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 876 867 877 /*** Average Table ***/ 868 878 if ((catalog[0].catflags & DVO_LOAD_AVERAGE) && (catalog[0].average != NULL)) { … … 890 900 } 891 901 902 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 903 892 904 if (!dvo_catalog_save_subcat (catalog, &ftable, start, Nrows, catalog[0].Naverage_disk, Naverage_disk_new)) { 893 905 fprintf (stderr, "failure writing Average table\n"); 894 906 goto failure; 895 907 } 908 909 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 896 910 897 911 gfits_free_header (&header); … … 922 936 assert (catalog[0].Nmeasure_disk >= catalog[0].Nmeasure_off); 923 937 938 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 939 924 940 // if we are going to compress, we need to receive unswapped data -- 925 941 int swapFromNative = !output_is_compressed (start, Nrows, Nmeasure_disk_new, catalog->catcompress); … … 930 946 goto failure; 931 947 } 948 949 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 932 950 933 951 // write out Measure table … … 937 955 goto failure; 938 956 } 957 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 958 939 959 940 960 gfits_free_header (&header); … … 986 1006 int swapFromNative = !output_is_compressed (start, Nrows, Nsecfilt_disk_new, catalog->catcompress); 987 1007 1008 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 1009 988 1010 // convert to external table format 989 1011 if (!SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat, swapFromNative)) { … … 991 1013 goto failure; 992 1014 } 1015 1016 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 993 1017 994 1018 // write out SecFilt table … … 1003 1027 1004 1028 /*** Lensing Table ***/ 1005 if ((catalog[0].catflags & DVO_LOAD_LENSING) && (catalog[0].lensing != NULL)) {1029 if ((catalog[0].catflags & DVO_LOAD_LENSING) && catalog[0].lensing && Nlensing_disk_new) { 1006 1030 1007 1031 off_t first = 0; // first row in memory to write … … 1034 1058 1035 1059 /*** Lensobj Table ***/ 1036 if ((catalog[0].catflags & DVO_LOAD_LENSOBJ) && (catalog[0].lensobj != NULL)) {1060 if ((catalog[0].catflags & DVO_LOAD_LENSOBJ) && catalog[0].lensobj && Nlensobj_disk_new) { 1037 1061 1038 1062 off_t first = 0; // first row in memory to write … … 1065 1089 1066 1090 /*** StarPar Table ***/ 1067 if ((catalog[0].catflags & DVO_LOAD_STARPAR) && (catalog[0].starpar != NULL)) {1091 if ((catalog[0].catflags & DVO_LOAD_STARPAR) && catalog[0].starpar && Nstarpar_disk_new) { 1068 1092 1069 1093 off_t first = 0; // first row in memory to write … … 1096 1120 1097 1121 /*** GalPhot Table ***/ 1098 if ((catalog[0].catflags & DVO_LOAD_GALPHOT) && (catalog[0].galphot != NULL)) {1122 if ((catalog[0].catflags & DVO_LOAD_GALPHOT) && catalog[0].galphot && Ngalphot_disk_new) { 1099 1123 1100 1124 off_t first = 0; // first row in memory to write -
trunk/Ohana/src/libdvo/src/dvo_convert.c
r38553 r38986 77 77 average = Average_PS1_V4alt_ToInternal (tmpAverage, *Naverage); 78 78 free (tmpAverage); 79 ftable[0].buffer = NULL; 79 80 *format = DVO_FORMAT_PS1_V4; 80 81 return (average); … … 91 92 average = Average_PS1_V5alt_ToInternal (tmpAverage, *Naverage); 92 93 free (tmpAverage); 94 ftable[0].buffer = NULL; 93 95 *format = DVO_FORMAT_PS1_V5; 94 96 return (average); 95 97 } 96 98 97 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \98 if (!strcmp (extname, NAME)) { \99 Average_##TYPE *tmpAverage; \100 tmpAverage = gfits_table_get_Average_##TYPE (ftable, Naverage, NULL, &nativeBytes); \101 if (!tmpAverage) { \102 fprintf (stderr, "ERROR: failed to read averages\n"); \103 exit (2); \104 } \99 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 100 if (!strcmp (extname, NAME)) { \ 101 Average_##TYPE *tmpAverage; \ 102 tmpAverage = gfits_table_get_Average_##TYPE (ftable, Naverage, NULL, &nativeBytes); \ 103 if (!tmpAverage) { \ 104 fprintf (stderr, "ERROR: failed to read averages\n"); \ 105 exit (2); \ 106 } \ 105 107 average = Average_##TYPE##_ToInternal (tmpAverage, *Naverage, primary); \ 106 free (tmpAverage); \ 107 *format = DVO_FORMAT_##FORMAT; \ 108 free (tmpAverage); \ 109 ftable[0].buffer = NULL; \ 110 *format = DVO_FORMAT_##FORMAT; \ 108 111 return (average); } 109 112 … … 141 144 int AverageToFtable (FTable *ftable, Average *average, off_t Naverage, DVOCatFormat format, SecFilt *primary, int swapFromNative) { 142 145 143 # define FORMAT_CASE(FORMAT, TYPE) \146 # define FORMAT_CASE(FORMAT, TYPE) \ 144 147 case DVO_FORMAT_##FORMAT: { \ 145 148 Average_##TYPE *tmpAverage; \ 146 tmpAverage = AverageInternalTo_##TYPE (average, Naverage, primary); \147 gfits_table_set_Average_##TYPE (ftable, tmpAverage, Naverage, swapFromNative); \148 free (tmpAverage);\149 break; }149 tmpAverage = AverageInternalTo_##TYPE (average, Naverage, primary); \ 150 gfits_table_set_Average_##TYPE (ftable, tmpAverage, Naverage, swapFromNative); \ 151 free (tmpAverage); \ 152 break; } 150 153 151 154 /* convert from the internal format */ … … 195 198 if (!strcmp (extname, "DVO_MEASURE_PS1_V4") && (ftable[0].header[0].Naxis[0] == 176)) { 196 199 fprintf (stderr, "reading alt PS1_V4 format\n"); 200 myAssert (!nativeBytes, "need to implement optional swap"); 197 201 Measure_PS1_V4alt *tmpMeasure; 198 202 tmpMeasure = gfits_table_get_Measure_PS1_V4alt (ftable, Nmeasure, NULL); … … 204 208 measure = Measure_PS1_V4alt_ToInternal (average, tmpMeasure, *Nmeasure); 205 209 free (tmpMeasure); 210 ftable[0].buffer = NULL; 206 211 *format = DVO_FORMAT_PS1_V4; 207 212 return (measure); … … 211 216 if (!strcmp (extname, "DVO_MEASURE_PS1_V5") && (ftable[0].header[0].Naxis[0] == 232)) { 212 217 fprintf (stderr, "reading alt PS1_V5 format\n"); 218 myAssert (!nativeBytes, "need to implement optional swap"); 213 219 Measure_PS1_V5alt *tmpMeasure; 214 220 tmpMeasure = gfits_table_get_Measure_PS1_V5alt (ftable, Nmeasure, NULL); … … 220 226 measure = Measure_PS1_V5alt_ToInternal (average, tmpMeasure, *Nmeasure); 221 227 free (tmpMeasure); 228 ftable[0].buffer = NULL; 222 229 *format = DVO_FORMAT_PS1_V5; 223 230 return (measure); 224 231 } 225 232 226 # define CONVERT_FORMAT(NAME, FORMAT, TYPE, ABS_COORDS) \233 # define CONVERT_FORMAT(NAME, FORMAT, TYPE, ABS_COORDS) \ 227 234 if (!strcmp (extname, NAME)) { \ 228 235 Measure_##TYPE *tmpMeasure; \ 229 tmpMeasure = gfits_table_get_Measure_##TYPE (ftable, Nmeasure, NULL, &nativeBytes); \230 if (!tmpMeasure) {\231 fprintf (stderr, "ERROR: failed to read measures\n"); \232 exit (2);\233 }\234 myAssert (ABS_COORDS || average, "conversion to internal needs average table"); \236 tmpMeasure = gfits_table_get_Measure_##TYPE (ftable, Nmeasure, NULL, &nativeBytes); \ 237 if (!tmpMeasure) { \ 238 fprintf (stderr, "ERROR: failed to read measures\n"); \ 239 exit (2); \ 240 } \ 241 myAssert (ABS_COORDS || average, "conversion to internal needs average table"); \ 235 242 measure = Measure_##TYPE##_ToInternal (average, tmpMeasure, *Nmeasure); \ 236 243 free (tmpMeasure); \ 244 ftable[0].buffer = NULL; \ 237 245 *format = DVO_FORMAT_##FORMAT; \ 238 246 return (measure); } … … 272 280 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, DVOCatFormat format, int swapFromNative) { 273 281 274 # define FORMAT_CASE(FORMAT, TYPE, ABS_COORDS) \275 case DVO_FORMAT_##FORMAT: {\276 Measure_##TYPE *tmpMeasure;\277 myAssert (ABS_COORDS || average, "conversion from internal needs average table"); \278 tmpMeasure = MeasureInternalTo_##TYPE (average, measure, Nmeasure); \279 gfits_table_set_Measure_##TYPE (ftable, tmpMeasure, Nmeasure, swapFromNative); \280 free (tmpMeasure);\281 break; }282 # define FORMAT_CASE(FORMAT, TYPE, ABS_COORDS) \ 283 case DVO_FORMAT_##FORMAT: { \ 284 Measure_##TYPE *tmpMeasure; \ 285 myAssert (ABS_COORDS || average, "conversion from internal needs average table"); \ 286 tmpMeasure = MeasureInternalTo_##TYPE (average, measure, Nmeasure); \ 287 gfits_table_set_Measure_##TYPE (ftable, tmpMeasure, Nmeasure, swapFromNative); \ 288 free (tmpMeasure); \ 289 break; } 282 290 283 291 /* convert from the internal format */ … … 322 330 } 323 331 324 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \332 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 325 333 if (!strcmp (extname, NAME)) { \ 326 334 fprintf (stderr, "ERROR: format %s not defined for missing, skipping\n", NAME); \ 327 *Nmissing = 0; \328 return NULL; \329 } 330 331 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \335 *Nmissing = 0; \ 336 return NULL; \ 337 } 338 339 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 332 340 if (!strcmp (extname, NAME)) { \ 333 341 Missing_##TYPE *tmpMissing; \ … … 337 345 exit (2); \ 338 346 } \ 339 missing = Missing_##TYPE##_ToInternal (tmpMissing, *Nmissing); \347 missing = Missing_##TYPE##_ToInternal (tmpMissing, *Nmissing); \ 340 348 free (tmpMissing); \ 349 ftable[0].buffer = NULL; \ 341 350 *format = DVO_FORMAT_##FORMAT; \ 342 351 return (missing); } … … 408 417 secfilt = SecFilt_PS1_V5alt_ToInternal (tmpSecFilt, *Nsecfilt); 409 418 free (tmpSecFilt); 419 ftable[0].buffer = NULL; 410 420 *format = DVO_FORMAT_PS1_V5; 411 421 return (secfilt); … … 413 423 414 424 415 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \416 if (!strcmp (extname, NAME)) { \417 SecFilt_##TYPE *tmpSecFilt; \425 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 426 if (!strcmp (extname, NAME)) { \ 427 SecFilt_##TYPE *tmpSecFilt; \ 418 428 tmpSecFilt = gfits_table_get_SecFilt_##TYPE (ftable, Nsecfilt, NULL, &nativeBytes); \ 419 if (!tmpSecFilt) { \ 420 fprintf (stderr, "ERROR: failed to read secfilts\n"); \ 421 exit (2); \ 422 } \ 423 secfilt = SecFilt_##TYPE##_ToInternal (tmpSecFilt, *Nsecfilt); \ 424 free (tmpSecFilt); \ 425 *format = DVO_FORMAT_##FORMAT; \ 429 if (!tmpSecFilt) { \ 430 fprintf (stderr, "ERROR: failed to read secfilts\n"); \ 431 exit (2); \ 432 } \ 433 secfilt = SecFilt_##TYPE##_ToInternal (tmpSecFilt, *Nsecfilt); \ 434 free (tmpSecFilt); \ 435 ftable[0].buffer = NULL; \ 436 *format = DVO_FORMAT_##FORMAT; \ 426 437 return (secfilt); } 427 438 … … 459 470 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, DVOCatFormat format, int swapFromNative) { 460 471 461 # define FORMAT_CASE(FORMAT, TYPE) \462 case DVO_FORMAT_##FORMAT: {\463 SecFilt_##TYPE *tmpSecFilt;\464 tmpSecFilt = SecFiltInternalTo_##TYPE (secfilt, Nsecfilt);\465 gfits_table_set_SecFilt_##TYPE (ftable, tmpSecFilt, Nsecfilt, swapFromNative); \466 free (tmpSecFilt);\467 break; }472 # define FORMAT_CASE(FORMAT, TYPE) \ 473 case DVO_FORMAT_##FORMAT: { \ 474 SecFilt_##TYPE *tmpSecFilt; \ 475 tmpSecFilt = SecFiltInternalTo_##TYPE (secfilt, Nsecfilt); \ 476 gfits_table_set_SecFilt_##TYPE (ftable, tmpSecFilt, Nsecfilt, swapFromNative); \ 477 free (tmpSecFilt); \ 478 break; } 468 479 469 480 /* convert from the internal format */ … … 517 528 lensing = Lensing_PS1_V5_R0_ToInternal (tmpLensing, *Nlensing); 518 529 free (tmpLensing); 530 ftable[0].buffer = NULL; 519 531 *format = DVO_FORMAT_PS1_V5; 520 532 return (lensing); } … … 529 541 lensing = Lensing_PS1_V5_R1_ToInternal (tmpLensing, *Nlensing); 530 542 free (tmpLensing); 543 ftable[0].buffer = NULL; 531 544 *format = DVO_FORMAT_PS1_V5; 532 545 return (lensing); } … … 541 554 lensing = Lensing_PS1_V5_R2_ToInternal (tmpLensing, *Nlensing); 542 555 free (tmpLensing); 556 ftable[0].buffer = NULL; 543 557 *format = DVO_FORMAT_PS1_V5; 544 558 return (lensing); } 545 559 546 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \560 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 547 561 if (!strcmp (extname, NAME)) { \ 548 562 fprintf (stderr, "ERROR: format %s not defined for lensing, skipping\n", NAME); \ 549 *Nlensing = 0; \550 return NULL; \551 } 552 553 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \563 *Nlensing = 0; \ 564 return NULL; \ 565 } 566 567 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 554 568 if (!strcmp (extname, NAME)) { \ 555 569 Lensing_##TYPE *tmpLensing; \ … … 559 573 exit (2); \ 560 574 } \ 561 lensing = Lensing_##TYPE##_ToInternal (tmpLensing, *Nlensing); \575 lensing = Lensing_##TYPE##_ToInternal (tmpLensing, *Nlensing); \ 562 576 free (tmpLensing); \ 577 ftable[0].buffer = NULL; \ 563 578 *format = DVO_FORMAT_##FORMAT; \ 564 579 return (lensing); } … … 599 614 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, DVOCatFormat format, int swapFromNative) { 600 615 601 # define FORMAT_CASE(FORMAT, TYPE) \602 case DVO_FORMAT_##FORMAT: {\603 Lensing_##TYPE *tmpLensing;\604 tmpLensing = LensingInternalTo_##TYPE (lensing, Nlensing);\605 gfits_table_set_Lensing_##TYPE (ftable, tmpLensing, Nlensing, swapFromNative); \606 free (tmpLensing);\607 break; }616 # define FORMAT_CASE(FORMAT, TYPE) \ 617 case DVO_FORMAT_##FORMAT: { \ 618 Lensing_##TYPE *tmpLensing; \ 619 tmpLensing = LensingInternalTo_##TYPE (lensing, Nlensing); \ 620 gfits_table_set_Lensing_##TYPE (ftable, tmpLensing, Nlensing, swapFromNative); \ 621 free (tmpLensing); \ 622 break; } 608 623 609 624 /* convert from the internal format */ … … 656 671 lensobj = Lensobj_PS1_V5_R0_ToInternal (tmpLensobj, *Nlensobj); 657 672 free (tmpLensobj); 673 ftable[0].buffer = NULL; 658 674 *format = DVO_FORMAT_PS1_V5; 659 675 return (lensobj); } 660 676 661 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \677 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 662 678 if (!strcmp (extname, NAME)) { \ 663 679 fprintf (stderr, "ERROR: format %s not defined for lensobj, skipping\n", NAME); \ 664 *Nlensobj = 0; \665 return NULL; \666 } 667 668 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \680 *Nlensobj = 0; \ 681 return NULL; \ 682 } 683 684 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 669 685 if (!strcmp (extname, NAME)) { \ 670 686 Lensobj_##TYPE *tmpLensobj; \ … … 674 690 exit (2); \ 675 691 } \ 676 lensobj = Lensobj_##TYPE##_ToInternal (tmpLensobj, *Nlensobj); \692 lensobj = Lensobj_##TYPE##_ToInternal (tmpLensobj, *Nlensobj); \ 677 693 free (tmpLensobj); \ 694 ftable[0].buffer = NULL; \ 678 695 *format = DVO_FORMAT_##FORMAT; \ 679 696 return (lensobj); } … … 714 731 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, DVOCatFormat format, int swapFromNative) { 715 732 716 # define FORMAT_CASE(FORMAT, TYPE) \717 case DVO_FORMAT_##FORMAT: {\718 Lensobj_##TYPE *tmpLensobj;\719 tmpLensobj = LensobjInternalTo_##TYPE (lensobj, Nlensobj);\720 gfits_table_set_Lensobj_##TYPE (ftable, tmpLensobj, Nlensobj, swapFromNative); \721 free (tmpLensobj);\722 break; }733 # define FORMAT_CASE(FORMAT, TYPE) \ 734 case DVO_FORMAT_##FORMAT: { \ 735 Lensobj_##TYPE *tmpLensobj; \ 736 tmpLensobj = LensobjInternalTo_##TYPE (lensobj, Nlensobj); \ 737 gfits_table_set_Lensobj_##TYPE (ftable, tmpLensobj, Nlensobj, swapFromNative); \ 738 free (tmpLensobj); \ 739 break; } 723 740 724 741 /* convert from the internal format */ … … 762 779 } 763 780 764 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \781 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 765 782 if (!strcmp (extname, NAME)) { \ 766 783 fprintf (stderr, "ERROR: format %s not defined for starpar, skipping\n", NAME); \ 767 *Nstarpar = 0; \768 return NULL; \769 } 770 771 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \784 *Nstarpar = 0; \ 785 return NULL; \ 786 } 787 788 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 772 789 if (!strcmp (extname, NAME)) { \ 773 790 StarPar_##TYPE *tmpStarPar; \ … … 777 794 exit (2); \ 778 795 } \ 779 starpar = StarPar_##TYPE##_ToInternal (tmpStarPar, *Nstarpar); \796 starpar = StarPar_##TYPE##_ToInternal (tmpStarPar, *Nstarpar); \ 780 797 free (tmpStarPar); \ 798 ftable[0].buffer = NULL; \ 781 799 *format = DVO_FORMAT_##FORMAT; \ 782 800 return (starpar); } … … 817 835 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, DVOCatFormat format, int swapFromNative) { 818 836 819 # define FORMAT_CASE(FORMAT, TYPE) \820 case DVO_FORMAT_##FORMAT: {\821 StarPar_##TYPE *tmpStarPar;\822 tmpStarPar = StarParInternalTo_##TYPE (starpar, Nstarpar);\823 gfits_table_set_StarPar_##TYPE (ftable, tmpStarPar, Nstarpar, swapFromNative); \824 free (tmpStarPar);\825 break; }837 # define FORMAT_CASE(FORMAT, TYPE) \ 838 case DVO_FORMAT_##FORMAT: { \ 839 StarPar_##TYPE *tmpStarPar; \ 840 tmpStarPar = StarParInternalTo_##TYPE (starpar, Nstarpar); \ 841 gfits_table_set_StarPar_##TYPE (ftable, tmpStarPar, Nstarpar, swapFromNative); \ 842 free (tmpStarPar); \ 843 break; } 826 844 827 845 /* convert from the internal format */ … … 866 884 } 867 885 868 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 886 if (!strcmp (extname, "DVO_GALPHOT_PS1_V5") && (ftable[0].header[0].Naxis[0] == 72)) { 887 GalPhot_PS1_V5_R0 *tmpGalPhot; 888 tmpGalPhot = gfits_table_get_GalPhot_PS1_V5_R0 (ftable, Ngalphot, NULL, &nativeBytes); 889 if (!tmpGalPhot) { 890 fprintf (stderr, "ERROR: failed to read galphots\n"); 891 exit (2); 892 } 893 galphot = GalPhot_PS1_V5_R0_ToInternal (tmpGalPhot, *Ngalphot); 894 free (tmpGalPhot); 895 ftable[0].buffer = NULL; 896 *format = DVO_FORMAT_PS1_V5; 897 return (galphot); 898 } 899 900 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 869 901 if (!strcmp (extname, NAME)) { \ 870 902 fprintf (stderr, "ERROR: format %s not defined for galphot, skipping\n", NAME); \ 871 *Ngalphot = 0; \872 return NULL; \873 } 874 875 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \903 *Ngalphot = 0; \ 904 return NULL; \ 905 } 906 907 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 876 908 if (!strcmp (extname, NAME)) { \ 877 909 GalPhot_##TYPE *tmpGalPhot; \ … … 881 913 exit (2); \ 882 914 } \ 883 galphot = GalPhot_##TYPE##_ToInternal (tmpGalPhot, *Ngalphot); \915 galphot = GalPhot_##TYPE##_ToInternal (tmpGalPhot, *Ngalphot); \ 884 916 free (tmpGalPhot); \ 917 ftable[0].buffer = NULL; \ 885 918 *format = DVO_FORMAT_##FORMAT; \ 886 919 return (galphot); } … … 907 940 SKIPPING_FORMAT ("DVO_GALPHOT_PS1_V3", PS1_V3, PS1_V3); 908 941 SKIPPING_FORMAT ("DVO_GALPHOT_PS1_V4", PS1_V4, PS1_V4); 909 CONVERT_FORMAT ("DVO_GALPHOT_PS1_V5", PS1_V5, PS1_V5 );942 CONVERT_FORMAT ("DVO_GALPHOT_PS1_V5", PS1_V5, PS1_V5_R1); 910 943 SKIPPING_FORMAT ("DVO_GALPHOT_PS1_SIM", PS1_SIM, PS1_SIM); 911 944 # undef CONVERT_FORMAT … … 921 954 int GalPhotToFtable (FTable *ftable, GalPhot *galphot, off_t Ngalphot, DVOCatFormat format, int swapFromNative) { 922 955 923 # define FORMAT_CASE(FORMAT, TYPE) \924 case DVO_FORMAT_##FORMAT: {\925 GalPhot_##TYPE *tmpGalPhot;\926 tmpGalPhot = GalPhotInternalTo_##TYPE (galphot, Ngalphot);\927 gfits_table_set_GalPhot_##TYPE (ftable, tmpGalPhot, Ngalphot, swapFromNative); \928 free (tmpGalPhot);\929 break; }956 # define FORMAT_CASE(FORMAT, TYPE) \ 957 case DVO_FORMAT_##FORMAT: { \ 958 GalPhot_##TYPE *tmpGalPhot; \ 959 tmpGalPhot = GalPhotInternalTo_##TYPE (galphot, Ngalphot); \ 960 gfits_table_set_GalPhot_##TYPE (ftable, tmpGalPhot, Ngalphot, swapFromNative); \ 961 free (tmpGalPhot); \ 962 break; } 930 963 931 964 /* convert from the internal format */ … … 946 979 // FORMAT_CASE (PS1_V3, PS1_V3); 947 980 // FORMAT_CASE (PS1_V4, PS1_V4); 948 FORMAT_CASE (PS1_V5, PS1_V5 );981 FORMAT_CASE (PS1_V5, PS1_V5_R1); 949 982 # undef FORMAT_CASE 950 983 … … 990 1023 } 991 1024 992 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \993 if (!strcmp (extname, NAME)) { \994 Image_##TYPE *tmpimage; \995 *format = DVO_FORMAT_##FORMAT; \1025 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 1026 if (!strcmp (extname, NAME)) { \ 1027 Image_##TYPE *tmpimage; \ 1028 *format = DVO_FORMAT_##FORMAT; \ 996 1029 tmpimage = gfits_table_get_Image_##TYPE (ftable, &Nimage, NULL, NULL); \ 997 if (!tmpimage) { \998 fprintf (stderr, "ERROR: failed to read images\n"); \999 exit (2); \1000 } \1030 if (!tmpimage) { \ 1031 fprintf (stderr, "ERROR: failed to read images\n"); \ 1032 exit (2); \ 1033 } \ 1001 1034 off_t Nalloc = gfits_data_pad_size(Nimage*sizeof(Image)); \ 1002 1035 ftable[0].buffer = (char *) Image_##TYPE##_ToInternal (tmpimage, Nimage, Nalloc); \ 1003 free (tmpimage); \1004 gfits_free_header (theader); \1005 gfits_table_mkheader_Image (theader); \1006 gfits_modify (theader, "NAXIS2", OFF_T_FMT, 1, Nimage); \1007 theader[0].Naxis[1] = Nimage; \1008 ftable[0].datasize = gfits_data_size (theader); \1036 free (tmpimage); \ 1037 gfits_free_header (theader); \ 1038 gfits_table_mkheader_Image (theader); \ 1039 gfits_modify (theader, "NAXIS2", OFF_T_FMT, 1, Nimage); \ 1040 theader[0].Naxis[1] = Nimage; \ 1041 ftable[0].datasize = gfits_data_size (theader); \ 1009 1042 return (TRUE); } 1010 1043 … … 1035 1068 Nimage = theader[0].Naxis[1]; 1036 1069 1037 # define FORMAT_CASE(FORMAT, TYPE) \1038 case DVO_FORMAT_##FORMAT: { \1070 # define FORMAT_CASE(FORMAT, TYPE) \ 1071 case DVO_FORMAT_##FORMAT: { \ 1039 1072 Image_##TYPE *tmpImage; \ 1040 tmpImage = ImageInternalTo_##TYPE ((Image *) ftable[0].buffer, Nimage); \1041 free (ftable[0].buffer);\1042 gfits_free_header (ftable->header);\1043 gfits_table_set_Image_##TYPE (ftable, tmpImage, Nimage, TRUE); \1044 free (tmpImage);\1045 break; }1073 tmpImage = ImageInternalTo_##TYPE ((Image *) ftable[0].buffer, Nimage); \ 1074 free (ftable[0].buffer); \ 1075 gfits_free_header (ftable->header); \ 1076 gfits_table_set_Image_##TYPE (ftable, tmpImage, Nimage, TRUE); \ 1077 free (tmpImage); \ 1078 break; } 1046 1079 1047 1080 /* convert from the internal format */ 1048 1081 switch (format) { 1049 FORMAT_CASE (ELIXIR, Elixir);1050 FORMAT_CASE (LONEOS, Loneos);1051 FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0);1052 FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);1053 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1);1054 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2);1055 FORMAT_CASE (PS1_V1, PS1_V1);1056 FORMAT_CASE (PS1_V2, PS1_V2);1057 FORMAT_CASE (PS1_V3, PS1_V3);1058 FORMAT_CASE (PS1_V4, PS1_V4);1059 FORMAT_CASE (PS1_V5, PS1_V5);1060 FORMAT_CASE (PS1_REF, PS1_REF);1061 FORMAT_CASE (PS1_SIM, PS1_SIM);1082 FORMAT_CASE (ELIXIR, Elixir); 1083 FORMAT_CASE (LONEOS, Loneos); 1084 FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 1085 FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 1086 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 1087 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 1088 FORMAT_CASE (PS1_V1, PS1_V1); 1089 FORMAT_CASE (PS1_V2, PS1_V2); 1090 FORMAT_CASE (PS1_V3, PS1_V3); 1091 FORMAT_CASE (PS1_V4, PS1_V4); 1092 FORMAT_CASE (PS1_V5, PS1_V5); 1093 FORMAT_CASE (PS1_REF, PS1_REF); 1094 FORMAT_CASE (PS1_SIM, PS1_SIM); 1062 1095 1063 1096 # undef FORMAT_CASE … … 1076 1109 Nrow = vtable[0].Nrow; 1077 1110 1078 # define FORMAT_CASE(FORMAT, TYPE) \1079 case DVO_FORMAT_##FORMAT: { \1080 Image_##TYPE *tmpImage;\1081 /* convert table rows from internal to external format */\1082 for (i = 0; i < Nrow; i++) {\1083 tmpImage = ImageInternalTo_##TYPE ((Image *) vtable[0].buffer[i], 1); \1084 gfits_convert_Image_##TYPE (tmpImage, sizeof(Image_##TYPE), 1);\1085 free (vtable[0].buffer[i]);\1086 vtable[0].buffer[i] = (char *) tmpImage;\1087 }\1088 /* convert header from old format to new format */\1089 gfits_scan (theader, "NAXIS2", OFF_T_FMT, 1, &Nimage);\1090 gfits_free_header (theader);\1091 gfits_table_mkheader_Image_##TYPE (theader);\1092 gfits_modify (theader, "NAXIS2", OFF_T_FMT, 1, Nimage);\1093 theader[0].Naxis[1] = Nimage;\1094 vtable[0].datasize = gfits_data_size (theader);\1095 return (TRUE); }1111 # define FORMAT_CASE(FORMAT, TYPE) \ 1112 case DVO_FORMAT_##FORMAT: { \ 1113 Image_##TYPE *tmpImage; \ 1114 /* convert table rows from internal to external format */ \ 1115 for (i = 0; i < Nrow; i++) { \ 1116 tmpImage = ImageInternalTo_##TYPE ((Image *) vtable[0].buffer[i], 1); \ 1117 gfits_convert_Image_##TYPE (tmpImage, sizeof(Image_##TYPE), 1); \ 1118 free (vtable[0].buffer[i]); \ 1119 vtable[0].buffer[i] = (char *) tmpImage; \ 1120 } \ 1121 /* convert header from old format to new format */ \ 1122 gfits_scan (theader, "NAXIS2", OFF_T_FMT, 1, &Nimage); \ 1123 gfits_free_header (theader); \ 1124 gfits_table_mkheader_Image_##TYPE (theader); \ 1125 gfits_modify (theader, "NAXIS2", OFF_T_FMT, 1, Nimage); \ 1126 theader[0].Naxis[1] = Nimage; \ 1127 vtable[0].datasize = gfits_data_size (theader); \ 1128 return (TRUE); } 1096 1129 1097 1130 1098 1131 /* convert from the internal format */ 1099 1132 switch (format) { 1100 FORMAT_CASE (ELIXIR, Elixir);1101 FORMAT_CASE (LONEOS, Loneos);1102 FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0);1103 FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);1104 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1);1105 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2);1106 FORMAT_CASE (PS1_V1, PS1_V1);1107 FORMAT_CASE (PS1_V2, PS1_V2);1108 FORMAT_CASE (PS1_V3, PS1_V3);1109 FORMAT_CASE (PS1_V4, PS1_V4);1110 FORMAT_CASE (PS1_V5, PS1_V5);1111 FORMAT_CASE (PS1_REF, PS1_REF);1112 FORMAT_CASE (PS1_SIM, PS1_SIM);1133 FORMAT_CASE (ELIXIR, Elixir); 1134 FORMAT_CASE (LONEOS, Loneos); 1135 FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 1136 FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 1137 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 1138 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 1139 FORMAT_CASE (PS1_V1, PS1_V1); 1140 FORMAT_CASE (PS1_V2, PS1_V2); 1141 FORMAT_CASE (PS1_V3, PS1_V3); 1142 FORMAT_CASE (PS1_V4, PS1_V4); 1143 FORMAT_CASE (PS1_V5, PS1_V5); 1144 FORMAT_CASE (PS1_REF, PS1_REF); 1145 FORMAT_CASE (PS1_SIM, PS1_SIM); 1113 1146 1114 1147 # undef FORMAT_CASE -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c
r38553 r38986 218 218 out[i].catID = in[i].catID; 219 219 out[i].extID = in[i].extID; 220 out[i].extIDgc = in[i].extIDgc; 220 221 out[i].uRgal = in[i].uRgal; 222 out[i].uDgal = in[i].uDgal; 221 223 } 222 224 return (out); … … 286 288 out[i].catID = in[i].catID; 287 289 out[i].extID = in[i].extID; 288 out[i].extIDgc = in[i].extIDgc; 290 291 out[i].uRgal = in[i].uRgal; 292 out[i].uDgal = in[i].uDgal; 289 293 } 290 294 return (out); … … 979 983 } 980 984 981 GalPhot *GalPhot_PS1_V5_ ToInternal (GalPhot_PS1_V5*in, off_t Nvalues) {985 GalPhot *GalPhot_PS1_V5_R1_ToInternal (GalPhot_PS1_V5_R1 *in, off_t Nvalues) { 982 986 983 987 off_t i; … … 1013 1017 } 1014 1018 1015 GalPhot_PS1_V5 *GalPhotInternalTo_PS1_V5 (GalPhot *in, off_t Nvalues) { 1016 1017 off_t i; 1018 GalPhot_PS1_V5 *out; 1019 1020 ALLOCATE_ZERO (out, GalPhot_PS1_V5, Nvalues); 1019 GalPhot *GalPhot_PS1_V5_R0_ToInternal (GalPhot_PS1_V5_R0 *in, off_t Nvalues) { 1020 1021 off_t i; 1022 GalPhot *out; 1023 1024 ALLOCATE_ZERO (out, GalPhot, Nvalues); 1025 1026 for (i = 0; i < Nvalues; i++) { 1027 dvo_galphot_init (&out[i]); 1028 1029 out[i].Xfit = in[i].Xfit; 1030 out[i].Yfit = in[i].Yfit; 1031 out[i].mag = in[i].mag; 1032 out[i].magErr = in[i].magErr; 1033 out[i].majorAxis = in[i].majorAxis; 1034 out[i].minorAxis = in[i].minorAxis; 1035 out[i].majorAxisErr = in[i].majorAxisErr; 1036 out[i].minorAxisErr = in[i].minorAxisErr; 1037 out[i].theta = in[i].theta; 1038 out[i].thetaErr = in[i].thetaErr; 1039 out[i].index = in[i].index; 1040 out[i].chisq = in[i].chisq; 1041 out[i].Npix = in[i].Npix; 1042 out[i].objID = in[i].objID; 1043 out[i].catID = in[i].catID; 1044 out[i].detID = in[i].detID; 1045 out[i].imageID = in[i].imageID; 1046 // out[i].averef = in[i].averef; 1047 out[i].photcode = in[i].photcode; 1048 out[i].modelType = in[i].modelType; 1049 } 1050 return (out); 1051 } 1052 1053 GalPhot_PS1_V5_R1 *GalPhotInternalTo_PS1_V5_R1 (GalPhot *in, off_t Nvalues) { 1054 1055 off_t i; 1056 GalPhot_PS1_V5_R1 *out; 1057 1058 ALLOCATE_ZERO (out, GalPhot_PS1_V5_R1, Nvalues); 1021 1059 1022 1060 for (i = 0; i < Nvalues; i++) { … … 1318 1356 out[i].catID = in[i].catID; 1319 1357 out[i].extID = in[i].extID; 1320 out[i].extIDgc = in[i].extIDgc;1321 1358 } 1322 1359 return (out); -
trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c
r38970 r38986 205 205 /* return equivalent photcode.code for given code */ 206 206 int GetPhotcodeEquivCodebyCode (int code) { 207 myAssert (photcodes, "photcodes not loaded"); 207 208 208 209 int entry; … … 218 219 // returns Nsec if code is PRI/SEC, else -1 219 220 int GetPhotcodeNsec (int code) { 221 myAssert (photcodes, "photcodes not loaded"); 220 222 221 223 int Nsec; … … 230 232 /* Nsec of 0 is PRI */ 231 233 PhotCode *GetPhotcodebyNsec (int Nsec) { 234 myAssert (photcodes, "photcodes not loaded"); 232 235 233 236 int Ncode; … … 245 248 246 249 int GetPhotcodeNsecfilt () { 250 myAssert (photcodes, "photcodes not loaded"); 247 251 return (photcodes[0].Nsecfilt); 248 252 } … … 745 749 } 746 750 return (Mstdev); 751 } 752 753 // return the number of detections in this filter (gpc1) 754 int PhotNcode (PhotCode *code, Average *average, SecFilt *secfilt) { 755 756 if (code == NULL) return 0; 757 758 int Ns = photcodes[0].hashNsec[code[0].code]; 759 if (Ns == -1) return 0; 760 761 return secfilt[Ns].Ncode; 762 } 763 764 // return the number of detections in this filter (gpc1) 765 int PhotSecfiltFlags (PhotCode *code, Average *average, SecFilt *secfilt) { 766 767 if (code == NULL) return 0; 768 769 int Ns = photcodes[0].hashNsec[code[0].code]; 770 if (Ns == -1) return 0; 771 772 return secfilt[Ns].flags; 747 773 } 748 774 -
trunk/Ohana/src/libfits/Makefile
r38441 r38986 25 25 TEST_CPPFLAGS = $(BASE_CPPFLAGS) 26 26 TEST_LDFLAGS = $(BASE_LDFLAGS) -lFITS -lohana -ltap_ohana 27 28 27 29 28 TESTXTRA = tcomptiming -
trunk/Ohana/src/libfits/extern/gzip.c
r38441 r38986 215 215 err = inflate(&stream, Z_FINISH); 216 216 if (err != Z_STREAM_END) { 217 if (err == Z_DATA_ERROR) { 218 fprintf (stderr, "compressed data is corrupted\n"); 219 ESCAPE(err); 220 } 217 221 inflateEnd(&stream); 218 222 if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) ESCAPE (Z_DATA_ERROR); -
trunk/Ohana/src/libfits/header/F_H_field.c
r29537 r38986 33 33 } 34 34 35 if (N < 0) {35 if (N <= 0) { 36 36 /* count the entries */ 37 37 Nfound = 0; -
trunk/Ohana/src/libfits/include/gfitsio.h
r38553 r38986 237 237 int gfits_fread_ftable PROTO((FILE *f, FTable *ftable, char *extname)); 238 238 int gfits_fread_ftable_data PROTO((FILE *f, FTable *ftable, int padIfShort)); 239 int gfits_fread_ftable_range PROTO((FILE *f, int padIfShort, FTable *ftable, off_t start, off_t Nrows));239 int gfits_fread_ftable_range PROTO((FILE *f, int padIfShort, int noSeek, FTable *ftable, off_t start, off_t Nrows)); 240 240 int gfits_fread_vtable PROTO((FILE *f, VTable *vtable, char *extname, off_t Nrow, off_t *row)); 241 241 int gfits_fread_vtable_range PROTO((FILE *f, VTable *vtable, off_t start, off_t Nrows)); -
trunk/Ohana/src/libfits/matrix/F_compress_data.c
r38441 r38986 119 119 return (FALSE); 120 120 } 121 if (Nout > *Nzdata) { 122 fprintf (stderr, "buffer overrun! %d out, %d available\n", Nout, *Nzdata); 123 return FALSE; 124 } 121 125 *Nzdata = Nout; 122 126 return TRUE; -
trunk/Ohana/src/libfits/table/F_compress_T.c
r38553 r38986 211 211 212 212 // allocate the intermediate storage buffers 213 int Nzdata_alloc = max_width*ztilelen + 100;213 int Nzdata_alloc = 2*max_width*ztilelen + 100; 214 214 ALLOCATE (raw, char, max_width*ztilelen); 215 215 ALLOCATE (zdata, char, Nzdata_alloc); … … 223 223 gettimeofday (&startTimer, (void *) NULL); 224 224 225 // ohana_memcheck (TRUE); 226 225 227 // compress the data : copy into a tile, compress the tile, then add to the output table 226 228 // each tile -> 1 row of the output table … … 243 245 } 244 246 247 // ohana_memcheck (TRUE); 248 245 249 // XXX TIMER 2a 246 250 gettimeofday (&stopTimer, (void *) NULL); … … 260 264 } 261 265 266 // ohana_memcheck (TRUE); 262 267 // optname, optvalue = NULL, Noptions = 0 263 268 -
trunk/Ohana/src/libfits/table/F_read_T.c
r38441 r38986 62 62 63 63 /*********************** fits read ftable data ***********************************/ 64 int gfits_fread_ftable_range (FILE *f, int padIfShort, FTable *table, off_t start, off_t Nrows) {64 int gfits_fread_ftable_range (FILE *f, int padIfShort, int noSeek, FTable *table, off_t start, off_t Nrows) { 65 65 66 66 off_t Nbytes, Nread, Nskip, Nx, Ny; … … 79 79 Nskip = start * Nx; 80 80 Nbytes = Nrows * Nx; 81 ALLOCATE (table[0].buffer, char, MAX (Nbytes, 1)); 82 83 fseeko (f, Nskip, SEEK_CUR); 81 82 if (table[0].buffer) { 83 if (table[0].datasize < Nbytes) { 84 REALLOCATE (table[0].buffer, char, MAX (Nbytes, 1)); 85 } 86 } else { 87 ALLOCATE (table[0].buffer, char, MAX (Nbytes, 1)); 88 } 89 90 if (!noSeek) { 91 fseeko (f, Nskip, SEEK_CUR); 92 } 84 93 85 94 Nread = fread (table[0].buffer, sizeof (char), Nbytes, f); -
trunk/Ohana/src/libfits/test/tcomptiming.c
r38553 r38986 25 25 int Ntile = pow (10.0, lNtile); 26 26 fprintf (stderr, "--- Ntile = %d ---\n", Ntile); 27 test_compress_timing (" NONE_2", Ntile);27 test_compress_timing ("GZIP_2", Ntile); 28 28 gfits_compress_timing(); 29 29 gfits_uncompress_timing(); -
trunk/Ohana/src/libkapa/Makefile
r38473 r38986 20 20 install: $(DESTINC)/kapa.h $(DESTLIB)/libkapa.a $(DESTLIB)/libkapa.$(DLLTYPE) 21 21 libkapa: $(LIB)/libkapa.$(ARCH).a $(LIB)/libkapa.$(ARCH).$(DLLTYPE) 22 23 ROTFONT: 24 cd rotfont && $(MAKE) all 22 25 23 26 INCS = $(DESTINC)/kapa.h … … 43 46 $(SRC)/PSRotFont.$(ARCH).o 44 47 45 $(OBJS): $(INCS) 48 $(INCS): ROTFONT 49 $(OBJS): $(INCS) 46 50 $(DRAW): $(INCS) 47 51 -
trunk/Ohana/src/libkapa/include/alphabet.h
r5854 r38986 1 2 # if (0) 3 # include "../rotfont/times8.h" 4 5 # define DEFFONT 1 6 static FontSet HardwiredFonts[] = { 7 {times8font, "times", 8} 8 }; 9 # endif 10 11 # if (1) 1 12 # include "../rotfont/times8.h" 2 13 # include "../rotfont/times12.h" … … 49 60 {symbol24font, "symbol", 24} 50 61 }; 62 # endif 51 63 52 64 /* put these as static in RotFont.c with accessor functions */ -
trunk/Ohana/src/libkapa/include/kapa.h
r38461 r38986 93 93 double labelPadXm, labelPadYm, labelPadXp, labelPadYp; 94 94 double padXm, padXp, padYm, padYp; 95 double fLabelRangeXm, fLabelRangeXp, fLabelRangeYm, fLabelRangeYp; 96 double fMinorXm, fMinorXp, fMinorYm, fMinorYp; 95 97 Coords coords; 96 98 int flipeast, flipnorth; … … 107 109 108 110 typedef struct { 109 int dx, dy, ascent; 111 int dx; 112 int dy; 113 float dXps; 114 int ascent; 110 115 unsigned char *bits; 111 116 } RotFont; … … 231 236 void PSDumpRotSegment PROTO((FILE *f, char *segment, int *Nseg)); 232 237 void PSSetFont PROTO((FILE *f, char *name, int size)); 238 int PSRotStrlen PROTO((char *c)); 233 239 234 240 /* bDrawFuncs.c */ -
trunk/Ohana/src/libkapa/rotfont
- Property svn:ignore
-
old new 1 1 fixfont 2 fontsize.ps 3 courier.12.psx 4 courier.14.psx 5 courier.18.psx 6 courier.24.psx 7 courier.8.psx 8 helvetica.12.psx 9 helvetica.14.psx 10 helvetica.18.psx 11 helvetica.24.psx 12 helvetica.8.psx 13 symbol.12.psx 14 symbol.14.psx 15 symbol.18.psx 16 symbol.24.psx 17 symbol.8.psx 18 times.12.psx 19 times.14.psx 20 times.18.psx 21 times.24.psx 22 times.8.psx 23 courier12.h 24 courier14.h 25 courier18.h 26 courier24.h 27 courier8.h 28 helvetica12.h 29 helvetica14.h 30 helvetica18.h 31 helvetica24.h 32 helvetica8.h 33 symbol12.h 34 symbol14.h 35 symbol18.h 36 symbol24.h 37 symbol8.h 38 times12.h 39 times14.h 40 times18.h 41 times24.h 42 times8.h
-
- Property svn:ignore
-
trunk/Ohana/src/libkapa/rotfont/fixfont.c
r5854 r38986 1 1 # include <stdio.h> 2 2 # include <math.h> 3 # include <stdlib.h> 4 # include <string.h> 3 5 # define TRUE 1 4 6 # define FALSE 0 … … 24 26 25 27 typedef struct { 26 int dx, dy, ascent, Nb; 28 int dx; 29 int dy; 30 float dXps; 31 int ascent; 32 int Nb; 27 33 unsigned char *bits; 28 34 char name[64]; … … 32 38 int scan_line (FILE *f, char *line); 33 39 34 main (int argc, char **argv) {40 int main (int argc, char **argv) { 35 41 36 42 int BitMap, Nvalue, code; … … 43 49 FILE *f; 44 50 45 if (argc != 3) {46 fprintf (stderr, "USAGE: fixfont (file.bdf) ( name)\n");51 if (argc != 4) { 52 fprintf (stderr, "USAGE: fixfont (file.bdf) (file.psx) (name)\n"); 47 53 exit (0); 48 54 } 49 55 50 f = fopen (argv[1], "r"); 56 char *bdfname = argv[1]; 57 char *psxname = argv[2]; 58 char *fontname = argv[3]; 59 60 // read in the PS sizes first 61 f = fopen (psxname, "r"); 51 62 if (f == (FILE *) NULL) { 52 fprintf (stderr, "failed to open file %s\n", argv[1]); 63 fprintf (stderr, "failed to open file %s\n", psxname); 64 exit (0); 65 } 66 67 while (scan_line (f, buffer) != EOF) { 68 int N; 69 float dXps; 70 int Nread = sscanf (buffer, "%d %f", &N, &dXps); 71 if (Nread != 2) continue; 72 if (N < 1) continue; 73 if (N > 255) continue; 74 font[N].dXps = dXps; 75 } 76 fclose (f); 77 78 f = fopen (bdfname, "r"); 79 if (f == (FILE *) NULL) { 80 fprintf (stderr, "failed to open file %s\n", bdfname); 53 81 exit (0); 54 82 } … … 112 140 strcpy (font[i].name, "blank"); 113 141 } 114 fprintf (stdout, "static unsigned char %s_%d_bits[] = {", argv[2], i);142 fprintf (stdout, "static unsigned char %s_%d_bits[] = {", fontname, i); 115 143 for (j = 0; j < font[i].Nb; j++) { 116 144 if (!(j % 12)) fprintf (stdout, "\n"); … … 121 149 } 122 150 123 fprintf (stdout, "static RotFont %sfont[] = {\n", argv[2]);151 fprintf (stdout, "static RotFont %sfont[] = {\n", fontname); 124 152 for (i = 0; i < 255; i++) { 125 fprintf (stdout, "{% d, %d, %d, %s_%d_bits},\n",126 font[i].dx, font[i].dy, font[i]. ascent, argv[2], i);127 } 128 fprintf (stdout, "{% d, %d, %d, %s_%d_bits}};\n",129 font[i].dx, font[i].dy, font[i]. ascent, argv[2], i);153 fprintf (stdout, "{%3d, %3d, %5.2f, %3d, %s_%d_bits},\n", 154 font[i].dx, font[i].dy, font[i].dXps, font[i].ascent, fontname, i); 155 } 156 fprintf (stdout, "{%3d, %3d, %5.2f, %3d, %s_%d_bits}};\n", 157 font[i].dx, font[i].dy, font[i].dXps, font[i].ascent, fontname, i); 130 158 131 159 160 exit (0); 132 161 } 133 162 … … 178 207 179 208 } 180 -
trunk/Ohana/src/libkapa/src/DrawRotString.c
r34088 r38986 22 22 return (TRUE); 23 23 } 24 25 /* position can be one of 9 values center the text in the following way 26 0 1 2 27 3 4 5 28 6 7 8 29 30 e.g., 4 has the center of the string at the x,y position 31 0 has the lower-right corner at the position (left & up justified) 32 */ 24 33 25 34 int DrawRotText (int x, int y, char *string, int pos, double angle) { -
trunk/Ohana/src/libkapa/src/KapaWindow.c
r37807 r38986 161 161 data[0].labelPadYm, data[0].labelPadYp); 162 162 163 KiiSendMessage (fd, "%lf %lf %lf %lf", 164 data[0].fLabelRangeXm, data[0].fLabelRangeXp, 165 data[0].fLabelRangeYm, data[0].fLabelRangeYp); 166 167 KiiSendMessage (fd, "%lf %lf %lf %lf", 168 data[0].fMinorXm, data[0].fMinorXp, 169 data[0].fMinorYm, data[0].fMinorYp); 170 163 171 KiiSendMessage (fd, "%g %g %g %g ", 164 172 data[0].coords.pc1_1, data[0].coords.pc2_2, … … 203 211 &data[0].labelPadXm, &data[0].labelPadXp, 204 212 &data[0].labelPadYm, &data[0].labelPadYp); 213 214 KiiScanMessage (fd, "%lf %lf %lf %lf", 215 &data[0].fLabelRangeXm, &data[0].fLabelRangeXp, 216 &data[0].fLabelRangeYm, &data[0].fLabelRangeYp); 217 218 KiiScanMessage (fd, "%lf %lf %lf %lf", 219 &data[0].fMinorXm, &data[0].fMinorXp, 220 &data[0].fMinorYm, &data[0].fMinorYp); 205 221 206 222 KiiScanMessage (fd, "%f %f %f %f", -
trunk/Ohana/src/libkapa/src/PSRotFont.c
r32695 r38986 9 9 int i, N, code, protect; 10 10 int dX, dY, Xoff, Yoff, X, Y, Nseg, NSEG, YoffBase; 11 double cs, sn, fscale,currentscale;11 double cs, sn, currentscale; 12 12 int basesize, currentsize; 13 13 RotFont *currentfont; … … 23 23 24 24 /* compute string length */ 25 /* PS fonts are somewhat different scales from bitmap font equivalents */ 26 fscale = 1.0; 27 if (!strcmp (currentname, "times")) fscale = 1.07; 28 if (!strcmp (currentname, "courier")) fscale = 1.5; 29 if (!strcmp (currentname, "helvetica")) fscale = 0.9; 30 if (!strcmp (currentname, "symbol")) fscale = 1.2; 31 dX = fscale*RotStrlen (string); 25 dX = PSRotStrlen (string); 32 26 dY = currentfont[65].ascent; 33 27 … … 201 195 } 202 196 197 # define NROT 256 198 int PSRotStrlen (char *c) { 199 200 int i, N, dX, code; 201 double currentscale, scale; 202 203 RotFont *currentfont = GetRotFontData (¤tscale); 204 scale = currentscale; 205 206 /* find string length */ 207 dX = 0; 208 209 code = FALSE; 210 for (i = 0; i < strlen (c); i++) { 211 N = (int)(c[i]); 212 /* skip non-printing characters */ 213 if ((N < 0) || (N >= NROT)) continue; 214 215 /* check for special characters */ 216 if (!code) { 217 if (N == 94) { /* super-script */ 218 scale *= 0.8; 219 continue; 220 } 221 if (N == 95) { /* sub-script */ 222 scale *= 0.8; 223 continue; 224 } 225 if (N == 124) { /* normal-script */ 226 scale = currentscale; 227 continue; 228 } 229 if (N == 92) { /* backslash */ 230 code = TRUE; 231 continue; 232 } 233 if (N == 38) { /* font-code */ 234 i++; 235 continue; 236 } 237 } 238 code = FALSE; 239 dX += scale*currentfont[N].dXps + 1; 240 } 241 return (dX); 242 } 203 243 204 244 -
trunk/Ohana/src/libohana/include/ohana_allocate.h
r38553 r38986 50 50 PTR = (TYPE *) ohana_malloc (__FILE__, __LINE__, __func__, (SIZE), sizeof(TYPE)); \ 51 51 } 52 53 # define ALLOCATE_PTR(PTR,TYPE,SIZE) \ 54 TYPE *PTR = (TYPE *) ohana_malloc (__FILE__, __LINE__, __func__, (SIZE), sizeof(TYPE)); 52 55 53 56 # define ALLOCATE_ZERO(PTR,TYPE,SIZE) { \ … … 107 110 # endif /* OHANA_MEMORY */ 108 111 112 void ohana_memdump_file (FILE *f, int mode); 113 109 114 # endif /* OHANA_ALLOCATE */ -
trunk/Ohana/src/libohana/include/ohana_sort.h
r33963 r38986 67 67 void dsort (double *value, int N); 68 68 void fsort (float *value, int N); 69 void isort (int *value, int N); 70 71 void dsortpair (double *X, double *Y, int N); 69 72 void fsortpair (float *X, float *Y, int N); 70 void dsortpair (double *X, double *Y, int N);71 73 void isortpair (int *X, int *Y, int N); 74 72 75 void llsortpair (off_t *X, off_t *Y, off_t N); 76 77 void dsortthree (double *X, double *Y, double *Z, int N); 73 78 void fsortthree (float *X, float *Y, float *Z, int N); 74 void dsortthree (double *X, double *Y, double *Z, int N); 79 80 void dsortfour (double *X, double *Y, double *Z, double *W, int N); 75 81 void fsortfour (float *X, float *Y, float *Z, float *W, int N); 76 void dsortfour (double *X, double *Y, double *Z, double*W, int N);82 void isortfour (int *X, int *Y, int *Z, int *W, int N); 77 83 78 84 #endif -
trunk/Ohana/src/libohana/src/ohana_allocate.c
r38553 r38986 265 265 } 266 266 267 int ohana_memcheck_func (int allmemory) {267 int ohana_memcheck_func (int VERBOSE) { 268 268 269 269 if (!lastBlock) { 270 fprintf (stderr, "no memory allocated\n");270 if (VERBOSE) fprintf (stderr, "no memory allocated\n"); 271 271 } 272 272 … … 308 308 thisBlock = thisBlock->prevBlock; 309 309 } 310 fprintf (stderr, "%zd memory blocks allocated (%zd bytes total), %zd good, %zd bad\n", Ntotal, Nbytes, Ngood, Nbad); 310 311 if (Ntotal || VERBOSE) { 312 fprintf (stderr, "%zd memory blocks allocated (%zd bytes total), %zd good, %zd bad\n", Ntotal, Nbytes, Ngood, Nbad); 313 } 314 311 315 if (Nbad) status = FALSE; 312 316 … … 356 360 thisBlock = thisBlock->prevBlock; 357 361 } 358 fprintf (stderr, "%zd memory blocks freed (%zd bytes total), %zd good, %zd bad\n", Ntotal_free, Nbytes_free, Ngood_free, Nbad_free); 362 363 if (Ntotal_free || VERBOSE) { 364 fprintf (stderr, "%zd memory blocks freed (%zd bytes total), %zd good, %zd bad\n", Ntotal_free, Nbytes_free, Ngood_free, Nbad_free); 365 } 366 359 367 if (Nbad_free) status = FALSE; 360 368 … … 405 413 thisBlock = thisBlock->prevBlock; 406 414 } 407 fprintf (stderr, "%zd memory blocks dropped (%zd bytes total), %zd good, %zd bad\n", Ntotal_drop, Nbytes_drop, Ngood_drop, Nbad_drop); 415 416 if (Ntotal_drop || VERBOSE) { 417 fprintf (stderr, "%zd memory blocks dropped (%zd bytes total), %zd good, %zd bad\n", Ntotal_drop, Nbytes_drop, Ngood_drop, Nbad_drop); 418 } 419 408 420 if (Nbad_drop) status = FALSE; 409 421 # endif … … 412 424 } 413 425 414 void ohana_memdump_f unc (int allmemory) {426 void ohana_memdump_file (FILE *f, int VERBOSE) { 415 427 416 428 if (!lastBlock) { 417 fprintf (stderr, "no memory allocated\n");429 if (VERBOSE) fprintf (f, "no memory allocated\n"); 418 430 return; 419 431 } … … 424 436 size_t Nbytes = 0; 425 437 426 fprintf ( stderr, " entry | bytes | cumulative | STATUS | file | line | function\n");438 fprintf (f, " entry | bytes | cumulative | STATUS | file | line | function\n"); 427 439 428 440 while (thisBlock) { … … 444 456 if (Ntotal < 100) { 445 457 if (good) { 446 fprintf ( stderr, " %zd %zd %zd GOOD %s %d, func: %s\n", Ntotal, thisBlock->size, Nbytes, thisBlock->file, thisBlock->line, thisBlock->func);458 fprintf (f, " %zd %zd %zd GOOD %s %d, func: %s\n", Ntotal, thisBlock->size, Nbytes, thisBlock->file, thisBlock->line, thisBlock->func); 447 459 } else { 448 fprintf ( stderr, " %zd %zd %zd BAD %s %d, func: %s\n", Ntotal, thisBlock->size, Nbytes, thisBlock->file, thisBlock->line, thisBlock->func);460 fprintf (f, " %zd %zd %zd BAD %s %d, func: %s\n", Ntotal, thisBlock->size, Nbytes, thisBlock->file, thisBlock->line, thisBlock->func); 449 461 } 450 462 } … … 452 464 thisBlock = thisBlock->prevBlock; 453 465 } 454 fprintf (stderr, "%zd memory blocks allocated (%zd bytes total)\n", Ntotal, Nbytes); 455 466 467 if (Ntotal || VERBOSE) { 468 fprintf (f, "%zd memory blocks allocated (%zd bytes total)\n", Ntotal, Nbytes); 469 } 470 471 return; 472 } 473 474 void ohana_memdump_func (int VERBOSE) { 475 ohana_memdump_file (stderr, VERBOSE); 456 476 return; 457 477 } -
trunk/Ohana/src/libohana/src/sorts.c
r33963 r38986 27 27 } 28 28 29 void fsortpair (float *X, float *Y, int N) {29 void isort (int *value, int N) { 30 30 31 # define SWAPFUNC(A,B){ float tmp; \ 31 # define SWAPFUNC(A,B){ int tmp = value[A]; value[A] = value[B]; value[B] = tmp; } 32 # define COMPARE(A,B)(value[A] < value[B]) 33 34 OHANA_SORT (N, COMPARE, SWAPFUNC); 35 36 # undef SWAPFUNC 37 # undef COMPARE 38 39 } 40 41 void dsortpair (double *X, double *Y, int N) { 42 43 # define SWAPFUNC(A,B){ double tmp; \ 32 44 tmp = X[A]; X[A] = X[B]; X[B] = tmp; \ 33 45 tmp = Y[A]; Y[A] = Y[B]; Y[B] = tmp; \ … … 42 54 } 43 55 44 void dsortpair (double *X, double*Y, int N) {56 void fsortpair (float *X, float *Y, int N) { 45 57 46 # define SWAPFUNC(A,B){ doubletmp; \58 # define SWAPFUNC(A,B){ float tmp; \ 47 59 tmp = X[A]; X[A] = X[B]; X[B] = tmp; \ 48 60 tmp = Y[A]; Y[A] = Y[B]; Y[B] = tmp; \ … … 89 101 } 90 102 103 void dsortthree (double *X, double *Y, double *Z, int N) { 104 105 # define SWAPFUNC(A,B){ double tmp; \ 106 tmp = X[A]; X[A] = X[B]; X[B] = tmp; \ 107 tmp = Y[A]; Y[A] = Y[B]; Y[B] = tmp; \ 108 tmp = Z[A]; Z[A] = Z[B]; Z[B] = tmp; \ 109 } 110 # define COMPARE(A,B)(X[A] < X[B]) 111 112 OHANA_SORT (N, COMPARE, SWAPFUNC); 113 114 # undef SWAPFUNC 115 # undef COMPARE 116 117 } 118 91 119 void fsortthree (float *X, float *Y, float *Z, int N) { 92 120 … … 105 133 } 106 134 107 void dsort three (double *X, double *Y, double *Z, int N) {135 void dsortfour (double *X, double *Y, double *Z, double *W, int N) { 108 136 109 137 # define SWAPFUNC(A,B){ double tmp; \ … … 111 139 tmp = Y[A]; Y[A] = Y[B]; Y[B] = tmp; \ 112 140 tmp = Z[A]; Z[A] = Z[B]; Z[B] = tmp; \ 141 tmp = W[A]; W[A] = W[B]; W[B] = tmp; \ 113 142 } 114 143 # define COMPARE(A,B)(X[A] < X[B]) … … 138 167 } 139 168 140 void dsortfour (double *X, double *Y, double *Z, double*W, int N) {169 void isortfour (int *X, int *Y, int *Z, int *W, int N) { 141 170 142 # define SWAPFUNC(A,B){ doubletmp; \171 # define SWAPFUNC(A,B){ int tmp; \ 143 172 tmp = X[A]; X[A] = X[B]; X[B] = tmp; \ 144 173 tmp = Y[A]; Y[A] = Y[B]; Y[B] = tmp; \ … … 154 183 155 184 } 185 -
trunk/Ohana/src/markrock/src/markrock.c
r38471 r38986 60 60 61 61 /* rocks2 = find_slow_rocks (&catalog, &catstats, &Nrocks2); */ 62 dvo_catalog_save (&catalog, VERBOSE); 63 dvo_catalog_unlock (&catalog); 62 SetProtect (TRUE); 63 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 64 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 65 SetProtect (FALSE); 66 64 67 dvo_catalog_free (&catalog); 65 68 -
trunk/Ohana/src/markstar/src/markstar.c
r38471 r38986 68 68 /* find_ghosts (&catalog, &catstats, argv[1], image, Nimage); */ 69 69 70 dvo_catalog_save (&catalog, VERBOSE); 71 dvo_catalog_unlock (&catalog); 70 SetProtect (TRUE); 71 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 72 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 73 SetProtect (FALSE); 74 72 75 dvo_catalog_free (&catalog); 73 76 -
trunk/Ohana/src/opihi/cmd.astro/fitplx.c
r37807 r38986 7 7 8 8 typedef struct { 9 double *X; 10 double *Y; 11 double *t; 12 double *pX; 13 double *pY; 14 double *dX; 15 double *dY; 16 int *index; 17 int Npts; 18 } PlxFitData; 19 20 typedef struct { 9 21 double Ro, dRo; 10 22 double Do, dDo; … … 17 29 double chisq; 18 30 int Nfit; 31 int getChisq; 19 32 } PlxFit; 33 34 int VectorRobustStats (Vector *vector, double *median, double *sigma); 35 double VectorFractionInterpolate (double *values, float fraction, int Npts); 36 37 int PlxSetMeanEpoch (double *R, double *D, double *T, double *Rmean, double *Dmean, double *Tmean, int *mask, int Ntotal); 38 int PlxSetEpochPosition (PlxFitData *fitdata, double *R, double *D, double *dR, double *dD, double *T, int *mask, int Ntotal, Coords *coords, double Tmean); 39 int PlxOutlierClip (PlxFitData *fitdata, int *mask, int Noutlier, float dPsigMax, Vector *dPvec, int VERBOSE); 40 41 int PlxFitDataAlloc (PlxFitData *data, int N); 42 void PlxFitDataFree (PlxFitData *data); 43 int PlxBootstrapResample (PlxFitData *src, PlxFitData *tgt); 20 44 21 45 int FitPMandPar (PlxFit *fit, double *X, double *dX, double *Y, double *dY, double *T, double *pR, double *pD, int Npts, int VERBOSE); … … 47 71 } 48 72 73 int Noutlier = 0; 74 float dPsigMax = FLT_MAX; 75 if ((N = get_argument (argc, argv, "-outlier-tests"))) { 76 remove_argument (N, &argc, argv); 77 Noutlier = atoi(argv[N]); 78 remove_argument (N, &argc, argv); 79 dPsigMax = atof(argv[N]); 80 remove_argument (N, &argc, argv); 81 } 82 83 int Nresample = 0; 84 if ((N = get_argument (argc, argv, "-bootstrap-resample"))) { 85 remove_argument (N, &argc, argv); 86 Nresample = atoi(argv[N]); 87 remove_argument (N, &argc, argv); 88 } 89 90 Vector *dPvec = NULL; 91 if ((N = get_argument (argc, argv, "-dPsig"))) { 92 if (!Noutlier) { gprint (GP_ERR, "-dPsig requires -outlier-tests to be non-zero\n"); return FALSE; } 93 remove_argument (N, &argc, argv); 94 if (!(dPvec = SelectVector (argv[N], ANYVECTOR, TRUE))) return FALSE; 95 remove_argument (N, &argc, argv); 96 } 97 49 98 if (argc != 6) { 50 gprint (GP_ERR, "USAGE: fitplx (ra) (dR) (dec) (dD) (mjd) [-mask mask]\n"); 51 // what about the errors? 99 gprint (GP_ERR, "USAGE: fitplx (ra) (dR) (dec) (dD) (mjd) [-mask mask] [-v] [-vv]\n"); 100 gprint (GP_ERR, " -outlier-tests Nsamples dPsigMax : run Nsample bootstrap-resamples to define the path deviations and reject based on dPsigMax\n"); 101 gprint (GP_ERR, " -dPsig vec : save path deviations in vec\n"); 52 102 return (FALSE); 53 103 } … … 77 127 } 78 128 79 N = tvec->Nelements; // XXX check other lengths 80 81 // find mean values to remove 82 double Npts = 0; 83 double Tmean = 0; 84 double Rmean = 0; 85 double Dmean = 0; 86 double Tmin = +1000000; 87 double Tmax = -1000000; 88 for (i = 0; i < N; i++) { 89 if (mask && !mask[i]) continue; 90 Rmean += R[i]; 91 Dmean += D[i]; 92 Tmean += T[i]; 93 Tmin = MIN(Tmin, T[i]); 94 Tmax = MAX(Tmax, T[i]); 95 Npts += 1.0; 96 } 97 Rmean /= Npts; 98 Dmean /= Npts; 99 Tmean /= Npts; 100 101 float Trange = Tmax - Tmin; 102 // fprintf (stderr, "R,D : %f,%f, T: %f, Trange: %f, Tmin: %f, Tmax: %f\n", Rmean, Dmean, Tmean, Trange, Tmin, Tmax); 129 // Ntotal : all points supplied by user 130 // Nsubset : unmasked points 131 int Ntotal = tvec->Nelements; // XXX check other lengths 132 if (dPvec) ResetVector (dPvec, OPIHI_FLT, Ntotal); 133 134 double Rmean, Dmean, Tmean; 135 PlxSetMeanEpoch (R, D, T, &Rmean, &Dmean, &Tmean, mask, Ntotal); 103 136 104 137 /* project coordinates to a plane centered on the object with units of arcsec */ … … 109 142 coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0; 110 143 111 double *X, *Y, *t, *pX, *pY, *dX, *dY; 112 ALLOCATE (X, double, N); 113 ALLOCATE (Y, double, N); 114 ALLOCATE (dX, double, N); 115 ALLOCATE (dY, double, N); 116 ALLOCATE (t, double, N); 117 ALLOCATE (pX, double, N); 118 ALLOCATE (pY, double, N); 119 120 float pXmin = +2.0; 121 float pXmax = -2.0; 122 float pYmin = +2.0; 123 float pYmax = -2.0; 124 125 int n = 0; 126 for (i = 0; i < N; i++) { 127 if (mask && !mask[i]) continue; 128 RD_to_XY (&X[n], &Y[n], R[i], D[i], &coords); 129 dX[n] = dR[i]; 130 dY[n] = dD[i]; 131 t[n] = (T[i] - Tmean) / 365.25; 132 ParFactor (&pX[n], &pY[n], R[i], D[i], T[i]); 133 pXmin = MIN (pXmin, pX[n]); 134 pXmax = MAX (pXmax, pX[n]); 135 pYmin = MIN (pYmin, pY[n]); 136 pYmax = MAX (pYmax, pY[n]); 137 n++; 138 } 139 float dXRange = pXmax - pXmin; 140 float dYRange = pYmax - pYmin; 141 float parRange = hypot (dXRange, dYRange); 142 143 // fprintf (stderr, "par factor range: %f\n", parRange); 144 145 PlxFit fit; 146 if (!FitPMandPar (&fit, X, dX, Y, dY, t, pX, pY, n, VERBOSE)) { 144 PlxFitData fitdata; 145 PlxFitDataAlloc (&fitdata, Ntotal); 146 PlxSetEpochPosition (&fitdata, R, D, dR, dD, T, mask, Ntotal, &coords, Tmean); 147 148 PlxFit fit; memset (&fit, 0, sizeof(PlxFit)); 149 150 // determine dPsig for detections based on Noutlier attempts 151 if (Noutlier) { 152 int clipRetry = TRUE; 153 for (i = 0; clipRetry && (i < 3); i++) { 154 clipRetry = !PlxOutlierClip (&fitdata, mask, Noutlier, dPsigMax, dPvec, VERBOSE); 155 156 // using the new mask values, reset fitdata 157 PlxSetMeanEpoch (R, D, T, &Rmean, &Dmean, &Tmean, mask, Ntotal); 158 PlxSetEpochPosition (&fitdata, R, D, dR, dD, T, mask, Ntotal, &coords, Tmean); 159 if (VERBOSE) fprintf (stderr, "keep %d of %d\n", fitdata.Npts, Ntotal); 160 } 161 } 162 163 for (i = 0; (VERBOSE == 2) && (i < fitdata.Npts); i++) { 164 int n = fitdata.index[i]; 165 int maskValue = mask ? mask[n] : 0; 166 fprintf (stderr, "%f %f : %f %d : %f %f %f\n", R[n], D[n], T[n], maskValue, fitdata.t[i], fitdata.X[i], fitdata.Y[i]); 167 } 168 169 fit.getChisq = TRUE; 170 if (!FitPMandPar (&fit, 171 fitdata.X, fitdata.dX, 172 fitdata.Y, fitdata.dY, 173 fitdata.t, fitdata.pX, fitdata.pY, fitdata.Npts, VERBOSE)) { 147 174 return FALSE; 148 175 } 176 177 if (Nresample){ 178 PlxFitData sample; 179 PlxFitDataAlloc (&sample, fitdata.Npts); 180 181 PlxFit *testfit = NULL; 182 ALLOCATE (testfit, PlxFit, Nresample); 183 184 int Ngood = 0; 185 for (i = 0; i < Nresample; i++) { 186 PlxBootstrapResample (&fitdata, &sample); 187 188 if (i % 100000 == 99999) fprintf (stderr, "."); 189 190 // fit the sample 191 testfit[Ngood].getChisq = FALSE; 192 if (!FitPMandPar (&testfit[Ngood], 193 sample.X, sample.dX, 194 sample.Y, sample.dY, sample.t, 195 sample.pX, sample.pY, sample.Npts, VERBOSE)) continue; 196 Ngood ++; 197 } 198 199 Vector *pvec, *uRvec, *uDvec, *Rvec, *Dvec; 200 201 // save the Nresample histograms 202 if ((pvec = SelectVector ("plxVector", ANYVECTOR, TRUE)) == NULL) ESCAPE ("missing vector %s\n", "plxVector"); 203 if ((uRvec = SelectVector ("uRVector", ANYVECTOR, TRUE)) == NULL) ESCAPE ("missing vector %s\n", "uDVector"); 204 if ((uDvec = SelectVector ("uDVector", ANYVECTOR, TRUE)) == NULL) ESCAPE ("missing vector %s\n", "uRVector"); 205 if ((Rvec = SelectVector ("RoVector", ANYVECTOR, TRUE)) == NULL) ESCAPE ("missing vector %s\n", "RoVector"); 206 if ((Dvec = SelectVector ("DoVector", ANYVECTOR, TRUE)) == NULL) ESCAPE ("missing vector %s\n", "DoVector"); 207 208 ResetVector ( pvec, OPIHI_FLT, Ngood); 209 ResetVector (uRvec, OPIHI_FLT, Ngood); 210 ResetVector (uDvec, OPIHI_FLT, Ngood); 211 ResetVector ( Rvec, OPIHI_FLT, Ngood); 212 ResetVector ( Dvec, OPIHI_FLT, Ngood); 213 214 for (i = 0; i < Ngood; i++) { 215 pvec->elements.Flt[i] = testfit[i].p; 216 uRvec->elements.Flt[i] = testfit[i].uR; 217 uDvec->elements.Flt[i] = testfit[i].uD; 218 Rvec->elements.Flt[i] = testfit[i].Ro; 219 Dvec->elements.Flt[i] = testfit[i].Do; 220 } 221 222 // now calculate median and sigma for each vector 223 VectorRobustStats (pvec, &fit.p, &fit.dp); 224 VectorRobustStats (uRvec, &fit.uR, &fit.duR); 225 VectorRobustStats (uDvec, &fit.uD, &fit.duD); 226 VectorRobustStats (Rvec, &fit.Ro, &fit.dRo); 227 VectorRobustStats (Dvec, &fit.Do, &fit.dDo); 228 } 229 230 // fprintf (stderr, "%f +/- %f | %f %f\n", fit.p, fit.dp, fit.uR, fit.uD); 231 232 /* 233 FILE *f = fopen ("test.pf.dat", "w"); 234 for (i = 0; i < Ntotal; i++) { 235 double Xf = fit.Ro + fit.uR*fitdata.t[i] + fit.p*fitdata.pX[i]; 236 double Yf = fit.Do + fit.uD*fitdata.t[i] + fit.p*fitdata.pY[i]; 237 fprintf (f, "%f : %f %f : %f %f : %f : %f %f : %f %f\n", T[i], R[i], D[i], Xf, Yf, fitdata.t[i], fitdata.X[i], fitdata.Y[i], fitdata.pX[i], fitdata.pY[i]); 238 } 239 fclose (f); 240 */ 149 241 150 242 // fprintf (stderr, "Roff, Doff: %f, %f; dRo, dDo: %f, %f\n", fit.Ro, fit.Do, fit.dRo, fit.dDo); … … 152 244 XY_to_RD (&Rmean, &Dmean, fit.Ro, fit.Do, &coords); 153 245 if (VERBOSE) { 154 fprintf (stderr, "Ro, Do: %f, %f +/- %f, %f \n", Rmean, Dmean, fit.dRo, fit.dDo);246 fprintf (stderr, "Ro, Do: %f, %f +/- %f, %f (%f, %f)\n", Rmean, Dmean, fit.dRo, fit.dDo, fit.Ro, fit.Do); 155 247 fprintf (stderr, "uR, uD: %f, %f; duR, duD: %f, %f\n", fit.uR, fit.uD, fit.duR, fit.duD); 156 248 fprintf (stderr, "par: %f +/- %f\n", fit.p, fit.dp); … … 164 256 set_variable ("uR", fit.uR); 165 257 set_variable ("uD", fit.uD); 166 set_variable ("duR", fit.duR);167 set_variable ("duD", fit.duD);258 set_variable ("duR", fit.duR); 259 set_variable ("duD", fit.duD); 168 260 set_variable ("plx", fit.p); 169 261 set_variable ("dplx", fit.dp); 170 262 171 263 set_variable ("Tmean", Tmean); 172 set_variable ("Trange", Trange);173 set_variable ("Prange", parRange);174 264 175 265 set_variable ("chisq", fit.chisq); … … 293 383 fit[0].dp = sqrt(A[4][4]); 294 384 295 // add up the chi square for the fit 296 chisq = 0.0; 297 for (i = 0; i < Npts; i++) { 298 Xf = fit[0].Ro + fit[0].uR*T[i] + fit[0].p*pR[i]; 299 Yf = fit[0].Do + fit[0].uD*T[i] + fit[0].p*pD[i]; 300 wx = (fabs(dX[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dX[i]); 301 wy = (fabs(dY[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dY[i]); 302 chisq += SQ(X[i] - Xf) * wx; 303 chisq += SQ(Y[i] - Yf) * wy; 304 // if (VERBOSE) fprintf (stderr, "chisq contrib : %f %f : %f %f : %f %f : %f %f : %f\n", Xf, Yf, X[i] - Xf, Y[i] - Yf, dX[i], dY[i], (X[i] - Xf) / dX[i], (Y[i] - Yf) / dY[i], chisq); 305 } 385 // (optionally) add up the chi square for the fit 386 if (fit->getChisq) { 387 chisq = 0.0; 388 for (i = 0; i < Npts; i++) { 389 Xf = fit[0].Ro + fit[0].uR*T[i] + fit[0].p*pR[i]; 390 Yf = fit[0].Do + fit[0].uD*T[i] + fit[0].p*pD[i]; 391 wx = (fabs(dX[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dX[i]); 392 wy = (fabs(dY[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dY[i]); 393 chisq += SQ(X[i] - Xf) * wx; 394 chisq += SQ(Y[i] - Yf) * wy; 395 // if (VERBOSE) fprintf (stderr, "chisq contrib : %f %f : %f %f : %f %f : %f %f : %f\n", Xf, Yf, X[i] - Xf, Y[i] - Yf, dX[i], dY[i], (X[i] - Xf) / dX[i], (Y[i] - Yf) / dY[i], chisq); 396 } 397 // the reduced chisq is divided by (Ndof = 2*Npts - 5) 398 fit[0].chisq = chisq / (2.0*Npts - 5.0); 399 } 400 306 401 fit[0].Nfit = Npts; 307 308 // the reduced chisq is divided by (Ndof = 2*Npts - 5)309 fit[0].chisq = chisq / (2.0*Npts - 5.0);310 402 return (TRUE); 311 403 } … … 349 441 return TRUE; 350 442 } 443 444 // allocate arrays but not the container 445 int PlxFitDataAlloc (PlxFitData *data, int N) { 446 447 data->Npts = N; 448 ALLOCATE (data->X, double, N); 449 ALLOCATE (data->Y, double, N); 450 ALLOCATE (data->dX, double, N); 451 ALLOCATE (data->dY, double, N); 452 ALLOCATE (data->t, double, N); 453 ALLOCATE (data->pX, double, N); 454 ALLOCATE (data->pY, double, N); 455 ALLOCATE (data->index, int, N); 456 return TRUE; 457 } 458 459 void PlxFitDataFree (PlxFitData *data) { 460 FREE (data->X); 461 FREE (data->Y); 462 FREE (data->dX); 463 FREE (data->dY); 464 FREE (data->t); 465 FREE (data->pX); 466 FREE (data->pY); 467 FREE (data->index); 468 } 469 470 int PlxBootstrapResample (PlxFitData *src, PlxFitData *tgt) { 471 int i; 472 tgt->Npts = src->Npts; 473 for (i = 0; i < src->Npts; i++) { 474 int N = tgt->Npts * drand48(); 475 // int N = i; 476 tgt->X [i] = src->X [N]; 477 tgt->Y [i] = src->Y [N]; 478 tgt->dX[i] = src->dX[N]; 479 tgt->dY[i] = src->dY[N]; 480 tgt->t [i] = src->t [N]; 481 tgt->pX[i] = src->pX[N]; 482 tgt->pY[i] = src->pY[N]; 483 } 484 return TRUE; 485 } 486 487 int PlxSetMeanEpoch (double *R, double *D, double *T, double *Rmean, double *Dmean, double *Tmean, int *mask, int Ntotal) { 488 489 int i; 490 491 // find mean values to remove 492 double Nmean = 0; 493 *Tmean = 0; 494 *Rmean = 0; 495 *Dmean = 0; 496 double Tmin = +1000000; 497 double Tmax = -1000000; 498 for (i = 0; i < Ntotal; i++) { 499 if (mask && !mask[i]) continue; 500 *Rmean += R[i]; 501 *Dmean += D[i]; 502 *Tmean += T[i]; 503 Tmin = MIN(Tmin, T[i]); 504 Tmax = MAX(Tmax, T[i]); 505 Nmean += 1.0; 506 } 507 *Rmean /= Nmean; 508 *Dmean /= Nmean; 509 *Tmean /= Nmean; 510 511 double Trange = Tmax - Tmin; 512 513 // fprintf (stderr, "R,D : %f,%f, T: %f, Trange: %f, Tmin: %f, Tmax: %f\n", *Rmean, *Dmean, *Tmean, Trange, Tmin, Tmax); 514 515 set_variable ("Trange", Trange); 516 return TRUE; 517 } 518 519 // generate the fit values (projected X,Y; parallax factors; 520 int PlxSetEpochPosition (PlxFitData *fitdata, double *R, double *D, double *dR, double *dD, double *T, int *mask, int Ntotal, Coords *coords, double Tmean) { 521 522 int i; 523 524 float pXmin = +2.0; 525 float pXmax = -2.0; 526 float pYmin = +2.0; 527 float pYmax = -2.0; 528 529 int Nsubset = 0; 530 for (i = 0; i < Ntotal; i++) { 531 if (mask && !mask[i]) continue; 532 RD_to_XY (&fitdata->X[Nsubset], &fitdata->Y[Nsubset], R[i], D[i], coords); 533 fitdata->dX[Nsubset] = dR[i]; 534 fitdata->dY[Nsubset] = dD[i]; 535 fitdata->t[Nsubset] = (T[i] - Tmean) / 365.25; 536 ParFactor (&fitdata->pX[Nsubset], &fitdata->pY[Nsubset], R[i], D[i], T[i]); 537 pXmin = MIN (pXmin, fitdata->pX[Nsubset]); 538 pXmax = MAX (pXmax, fitdata->pX[Nsubset]); 539 pYmin = MIN (pYmin, fitdata->pY[Nsubset]); 540 pYmax = MAX (pYmax, fitdata->pY[Nsubset]); 541 fitdata->index[Nsubset] = i; 542 Nsubset++; 543 } 544 fitdata->Npts = Nsubset; 545 float dXRange = pXmax - pXmin; 546 float dYRange = pYmax - pYmin; 547 float parRange = hypot (dXRange, dYRange); 548 549 set_variable ("Prange", parRange); 550 // fprintf (stderr, "par factor range: %f\n", parRange); 551 552 return TRUE; 553 } 554 555 /* Outlier clipping based on bootstrap-resampling tests of the plx path 556 * generate Noutlier resampled datasets 557 * fit the Noutlier plx paths 558 * determine and save the distribution of dXsig and dYsig for each point 559 * sort the resulting distributions and find dPsig (median point) for each measurement 560 * find the 90% point of dPsig : if > dPsigMax, only clip the 10% most deviant points 561 * set the dPvec values if desired 562 * -- mask is modified, dPvec values are set 563 * -- fitdata is unchanged 564 */ 565 566 # define MAX_REJECT 0.1 567 568 int PlxOutlierClip (PlxFitData *fitdata, int *mask, int Noutlier, float dPsigMax, Vector *dPvec, int VERBOSE) { 569 570 int i, n; 571 572 PlxFit testfit; 573 testfit.getChisq = FALSE; 574 575 PlxFitData sample; 576 PlxFitDataAlloc (&sample, fitdata->Npts); 577 578 double **dXsig, **dYsig; 579 ALLOCATE (dXsig, double *, fitdata->Npts); 580 ALLOCATE (dYsig, double *, fitdata->Npts); 581 for (i = 0; i < fitdata->Npts; i++) { 582 ALLOCATE (dXsig[i], double, Noutlier); 583 ALLOCATE (dYsig[i], double, Noutlier); 584 } 585 586 int Nsamples = 0; 587 for (n = 0; n < Noutlier; n++) { 588 // bootstrap resample (fitdata -> sample) 589 PlxBootstrapResample (fitdata, &sample); 590 591 if (n % 100000 == 99999) fprintf (stderr, "."); 592 593 // fit the sample 594 if (!FitPMandPar (&testfit, 595 sample.X, sample.dX, 596 sample.Y, sample.dY, sample.t, 597 sample.pX, sample.pY, sample.Npts, VERBOSE)) continue; 598 599 // fprintf (stderr, "%f +/- %f | %f %f\n", testfit.p, testfit.dp, testfit.uR, testfit.uD); 600 601 // find the distances to the path 602 for (i = 0; i < fitdata->Npts; i++) { 603 double Xf = testfit.Ro + testfit.uR*fitdata->t[i] + testfit.p*fitdata->pX[i]; 604 double Yf = testfit.Do + testfit.uD*fitdata->t[i] + testfit.p*fitdata->pY[i]; 605 dXsig[i][Nsamples] = fabs(fitdata->X[i] - Xf) / fitdata->dX[i]; 606 dYsig[i][Nsamples] = fabs(fitdata->Y[i] - Yf) / fitdata->dY[i]; 607 // fprintf (stderr, "%f : %f %f : %f %f : %f %f : %f %f %f\n", T[i], Xf, Yf, fitdata->X[i], fitdata->Y[i], fitdata->dX[i], fitdata->dY[i], fitdata->t[i], fitdata->pX[i], fitdata->pY[i]); 608 } 609 Nsamples ++; 610 } 611 612 double *dPsig; 613 ALLOCATE (dPsig, double, fitdata->Npts); 614 615 for (i = 0; i < fitdata->Npts; i++) { 616 dsort (dXsig[i], Nsamples); 617 dsort (dYsig[i], Nsamples); 618 619 // choose the median values 620 double dXsigMedian, dYsigMedian; 621 if (Nsamples % 2) { 622 int Ncenter = Nsamples / 2; 623 dXsigMedian = dXsig[i][Ncenter]; 624 dYsigMedian = dYsig[i][Ncenter]; 625 } else { 626 int Ncenter = Nsamples / 2 - 1; 627 dXsigMedian = 0.5*(dXsig[i][Ncenter] + dXsig[i][Ncenter + 1]); 628 dYsigMedian = 0.5*(dYsig[i][Ncenter] + dYsig[i][Ncenter + 1]); 629 } 630 // XXX replace with hypotenuse? 631 dPsig[i] = 0.5*(dXsigMedian + dYsigMedian); 632 // fprintf (stderr, "%d %10.6f %10.6f %10.6f %f %f : %f\n", i, R[i], D[i], T[i], dXsig[i][Ncenter], dYsig[i][Ncenter], dPsig[i]); 633 } 634 635 // make a copy of dPsig[] and check if > 10% are > dPsigMax 636 double *dPsigSort; 637 ALLOCATE (dPsigSort, double, fitdata->Npts); 638 for (i = 0; i < fitdata->Npts; i++) { 639 dPsigSort[i] = dPsig[i]; 640 } 641 dsort (dPsigSort, fitdata->Npts); 642 int Nmax = (1.0 - MAX_REJECT)*fitdata->Npts; 643 644 int completeClip = TRUE; 645 if (dPsigSort[Nmax] > dPsigMax) { 646 if (VERBOSE) fprintf (stderr, "too many outliers: %f at 90\n", dPsigSort[Nmax]); 647 dPsigMax = dPsigSort[Nmax]; 648 completeClip = FALSE; 649 } 650 651 for (i = 0; i < fitdata->Npts; i++) { 652 if (dPsig[i] < dPsigMax) continue; 653 int n = fitdata->index[i]; 654 // fprintf (stderr, "clip %d: %f : %f\n", i, fitdata->t[i], dPsig[i]); 655 mask[n] = 0; // mask these points 656 } 657 658 // only set dPvec if we have completed the clipping? 659 if (dPvec) { 660 for (i = 0; i < dPvec->Nelements; i++) { 661 dPvec->elements.Flt[i] = NAN; 662 } 663 for (i = 0; i < fitdata->Npts; i++) { 664 int n = fitdata->index[i]; 665 dPvec->elements.Flt[n] = dPsig[i]; 666 } 667 } 668 669 free (dPsig); 670 free (dPsigSort); 671 672 for (i = 0; i < fitdata->Npts; i++) { 673 free (dXsig[i]); 674 free (dYsig[i]); 675 } 676 free (dXsig); 677 free (dYsig); 678 679 return completeClip; 680 } 681 682 int VectorRobustStats (Vector *vector, double *median, double *sigma) { 683 684 // warn if vector->Nelements > 1000? 10000?) 685 // warn if vector is not float 686 687 // we need to copy the vector to avoid changing the sort order 688 double *values = NULL; 689 ALLOCATE (values, double, vector->Nelements); 690 691 int i; 692 int Npts = 0; 693 for (i = 0; i < vector->Nelements; i++) { 694 if (!isfinite(vector->elements.Flt[i])) continue; 695 values[Npts] = vector->elements.Flt[i]; 696 Npts++; 697 } 698 699 dsort (values, Npts); 700 701 if (Npts % 2) { 702 int Ncenter = Npts / 2; 703 *median = values[Ncenter]; 704 } else { 705 int Ncenter = Npts / 2 - 1; 706 *median = 0.5*(values[Ncenter] + values[Ncenter + 1]); 707 } 708 709 double Slo = VectorFractionInterpolate (values, 0.158655, Npts); 710 double Shi = VectorFractionInterpolate (values, 0.841345, Npts); 711 712 *sigma = (Shi - Slo) / 2.0; 713 714 return TRUE; 715 } 716 717 double VectorFractionInterpolate (double *values, float fraction, int Npts) { 718 719 float F = fraction * Npts; 720 int N = fraction * Npts; 721 722 if (N < 0 ) return NAN; 723 if (N >= Npts - 2) return NAN; 724 725 // interpolate between N,N+1 726 727 double S = (F - N) * (values[N+1] - values[N]) + values[N]; 728 return S; 729 } -
trunk/Ohana/src/opihi/cmd.basic/date.c
r27435 r38986 3 3 int date (int argc, char **argv) { 4 4 5 int N, SECONDS, REFTIME; 5 int N, SECONDS; 6 double REFTIME; 6 7 struct timeval now; 7 8 char *tstring = NULL; … … 16 17 } 17 18 18 REFTIME = 0 ;19 REFTIME = 0.0; 19 20 if ((N = get_argument (argc, argv, "-reftime"))) { 20 21 remove_argument (N, &argc, argv); 21 REFTIME = ato i(argv[N]);22 REFTIME = atof (argv[N]); 22 23 remove_argument (N, &argc, argv); 23 24 } … … 37 38 gettimeofday (&now, NULL); 38 39 if (SECONDS) { 40 double nowSec = now.tv_sec + 1e-6*now.tv_usec; 39 41 if (varName) { 40 set_ int_variable (varName, now.tv_sec - REFTIME);42 set_variable (varName, nowSec - REFTIME); 41 43 } else { 42 gprint (GP_ERR, "% d\n", (int) now.tv_sec - REFTIME);44 gprint (GP_ERR, "%.12g\n", nowSec - REFTIME); 43 45 } 44 46 } else { -
trunk/Ohana/src/opihi/cmd.data/box.c
r34749 r38986 48 48 if (strlen (graphmode.ticks) != 4) { goto usage; } 49 49 for (i = 0; i < strlen (graphmode.ticks); i++) { 50 if ((graphmode.ticks[i] != '0') && (graphmode.ticks[i] != '1') && (graphmode.ticks[i] != '2') ) { goto usage; }50 if ((graphmode.ticks[i] != '0') && (graphmode.ticks[i] != '1') && (graphmode.ticks[i] != '2') && (graphmode.ticks[i] != '3')) { goto usage; } 51 51 } 52 52 } … … 139 139 remove_argument (N, &argc, argv); 140 140 graphmode.padYp = atof(argv[N]); 141 remove_argument (N, &argc, argv); 142 } 143 144 if ((N = get_argument (argc, argv, "-fminor"))) { 145 remove_argument (N, &argc, argv); 146 graphmode.fMinorXm = atof(argv[N]); 147 graphmode.fMinorXp = atof(argv[N]); 148 graphmode.fMinorYm = atof(argv[N]); 149 graphmode.fMinorYp = atof(argv[N]); 150 remove_argument (N, &argc, argv); 151 } 152 if ((N = get_argument (argc, argv, "-xfminor"))) { 153 remove_argument (N, &argc, argv); 154 graphmode.fMinorXm = atof(argv[N]); 155 remove_argument (N, &argc, argv); 156 } 157 if ((N = get_argument (argc, argv, "+xfminor"))) { 158 remove_argument (N, &argc, argv); 159 graphmode.fMinorXp = atof(argv[N]); 160 remove_argument (N, &argc, argv); 161 } 162 if ((N = get_argument (argc, argv, "-yfminor"))) { 163 remove_argument (N, &argc, argv); 164 graphmode.fMinorYm = atof(argv[N]); 165 remove_argument (N, &argc, argv); 166 } 167 if ((N = get_argument (argc, argv, "+yfminor"))) { 168 remove_argument (N, &argc, argv); 169 graphmode.fMinorYp = atof(argv[N]); 170 remove_argument (N, &argc, argv); 171 } 172 173 if ((N = get_argument (argc, argv, "-flabel"))) { 174 remove_argument (N, &argc, argv); 175 graphmode.fLabelRangeXm = atof(argv[N]); 176 graphmode.fLabelRangeXp = atof(argv[N]); 177 graphmode.fLabelRangeYm = atof(argv[N]); 178 graphmode.fLabelRangeYp = atof(argv[N]); 179 remove_argument (N, &argc, argv); 180 } 181 if ((N = get_argument (argc, argv, "-xflabel"))) { 182 remove_argument (N, &argc, argv); 183 graphmode.fLabelRangeXm = atof(argv[N]); 184 remove_argument (N, &argc, argv); 185 } 186 if ((N = get_argument (argc, argv, "+xflabel"))) { 187 remove_argument (N, &argc, argv); 188 graphmode.fLabelRangeXp = atof(argv[N]); 189 remove_argument (N, &argc, argv); 190 } 191 if ((N = get_argument (argc, argv, "-yflabel"))) { 192 remove_argument (N, &argc, argv); 193 graphmode.fLabelRangeYm = atof(argv[N]); 194 remove_argument (N, &argc, argv); 195 } 196 if ((N = get_argument (argc, argv, "+yflabel"))) { 197 remove_argument (N, &argc, argv); 198 graphmode.fLabelRangeYp = atof(argv[N]); 141 199 remove_argument (N, &argc, argv); 142 200 } … … 174 232 gprint (GP_ERR, " alternatively, set each axis independently with:\n"); 175 233 gprint (GP_ERR, " -xpad, -ypad, +xpad, +ypad\n"); 234 gprint (GP_ERR, " \n"); 235 gprint (GP_ERR, " -fminor : set the number of minor ticks per major (all axes)\n"); 236 gprint (GP_ERR, " alternatively, set each axis independently with:\n"); 237 gprint (GP_ERR, " -xfminor, -yfminor, +xfminor, +yfminor\n"); 238 gprint (GP_ERR, " \n"); 239 gprint (GP_ERR, " -flabel : set the fraction of axis over which major ticks have labels (all axes)\n"); 240 gprint (GP_ERR, " alternatively, set each axis independently with:\n"); 241 gprint (GP_ERR, " -xflabel, -yflabel, +xflabel, +yflabel\n"); 176 242 177 243 return (FALSE); -
trunk/Ohana/src/opihi/cmd.data/device.c
r14590 r38986 6 6 char *name;; 7 7 /* set / get current graphics device */ 8 9 int QUIET = FALSE; 10 if ((N = get_argument (argc, argv, "-q"))) { 11 remove_argument (N, &argc, argv); 12 QUIET = TRUE; 13 } 8 14 9 15 name = NULL; … … 23 29 if (!GetGraph (NULL, &kapa, name)) return (FALSE); 24 30 } 25 gprint (GP_ERR, "kapa %s\n", name);31 if (!QUIET) gprint (GP_ERR, "kapa %s\n", name); 26 32 27 33 return (TRUE); -
trunk/Ohana/src/opihi/cmd.data/read_vectors.c
r38553 r38986 511 511 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension %d\n", Nextend); 512 512 } else { 513 if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend); 513 // arg3 (FALSE) : seek to this segment start 514 if (!gfits_fread_ftable_range (f, padIfShort, FALSE, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend); 514 515 } 515 516 -
trunk/Ohana/src/opihi/cmd.data/uniq.c
r20936 r38986 1 1 # include "data.h" 2 // NOTE: if there are only a few uniq values, the old algorithm is not bad. 3 // for 10000 uniq values, 30M points take ~20sec in the new algorithm, 4 // 3M points takess 45 sec in the old method. 2 5 3 6 int uniq (int argc, char **argv) { 4 7 5 int Nnew, i, j, found;8 int Nnew, i, N; 6 9 Vector *ivec, *ovec; 7 10 11 Vector *cvec = NULL; 12 if ((N = get_argument (argc, argv, "-c"))) { 13 remove_argument (N, &argc, argv); 14 if ((cvec = SelectVector (argv[N], ANYVECTOR, TRUE)) == NULL) { 15 gprint (GP_ERR, "invalid vector %s\n", argv[N]); 16 return FALSE; 17 } 18 remove_argument (N, &argc, argv); 19 } 20 8 21 if (argc != 3) { 9 gprint (GP_ERR, "USAGE: uniq (in) (out) \n");22 gprint (GP_ERR, "USAGE: uniq (in) (out) -c count\n"); 10 23 return (FALSE); 11 24 } … … 16 29 /* allocate the maximum possible needed */ 17 30 ResetVector (ovec, ivec->type, ivec->Nelements); 31 if (cvec) { 32 ResetVector (cvec, OPIHI_INT, ivec->Nelements); 33 } 18 34 19 35 Nnew = 0; 20 36 21 37 if (ivec->type == OPIHI_FLT) { 22 opihi_flt *v1 = ivec[0].elements.Flt; 23 for (i = 0; i < ivec[0].Nelements; i++, v1++) { 24 opihi_flt *v2 = ovec[0].elements.Flt; 25 found = FALSE; 26 for (j = 0; !found && (j < Nnew); j++, v2++) { 27 if (*v1 == *v2) found = TRUE; 38 // copy the input data to a temporary array to avoid damaging it with sort 39 opihi_flt *indata = NULL; 40 ALLOCATE (indata, opihi_flt, ivec[0].Nelements); 41 memcpy (indata, ivec->elements.Flt, ivec[0].Nelements*sizeof(opihi_flt)); 42 43 dsort (indata, ivec->Nelements); 44 45 Nnew = 0; 46 opihi_flt *vtgt = ovec[0].elements.Flt; 47 48 opihi_flt *vsrc = indata; 49 50 for (i = 0; i < ivec->Nelements; Nnew++) { 51 vtgt[Nnew] = *vsrc; 52 int Ndup = 0; 53 opihi_flt lastValue = *vsrc; 54 while ((i < ivec->Nelements) && (*vsrc == lastValue)) { 55 i++; 56 vsrc ++; 57 Ndup ++; 28 58 } 29 if (!found) { 30 ovec[0].elements.Flt[Nnew] = *v1; 31 Nnew ++; 59 if (cvec) { 60 cvec->elements.Int[Nnew] = Ndup; 32 61 } 33 62 } 63 free (indata); 34 64 } else { 35 opihi_int *v1 = ivec[0].elements.Int; 36 for (i = 0; i < ivec[0].Nelements; i++, v1++) { 37 opihi_int *v2 = ovec[0].elements.Int; 38 found = FALSE; 39 for (j = 0; !found && (j < Nnew); j++, v2++) { 40 if (*v1 == *v2) found = TRUE; 65 // copy the input data to a temporary array to avoid damaging it with sort 66 opihi_int *indata = NULL; 67 ALLOCATE (indata, opihi_int, ivec[0].Nelements); 68 memcpy (indata, ivec->elements.Int, ivec[0].Nelements*sizeof(opihi_int)); 69 70 isort (indata, ivec->Nelements); 71 72 Nnew = 0; 73 opihi_int *vtgt = ovec[0].elements.Int; 74 75 opihi_int *vsrc = indata; 76 77 for (i = 0; i < ivec->Nelements; Nnew++) { 78 vtgt[Nnew] = *vsrc; 79 int Ndup = 0; 80 opihi_int lastValue = *vsrc; 81 while ((i < ivec->Nelements) && (*vsrc == lastValue)) { 82 i++; 83 vsrc ++; 84 Ndup ++; 41 85 } 42 if (!found) { 43 ovec[0].elements.Int[Nnew] = *v1; 44 Nnew ++; 86 if (cvec) { 87 cvec->elements.Int[Nnew] = Ndup; 45 88 } 46 89 } 90 free (indata); 47 91 } 48 92 49 93 // free up extra memory 50 94 ResetVector (ovec, ivec->type, Nnew); 95 if (cvec) ResetVector (cvec, OPIHI_INT, Nnew); 51 96 52 97 return (TRUE); -
trunk/Ohana/src/opihi/dvo/mextract.c
r38471 r38986 213 213 } 214 214 215 //int needLensing = dbFieldNeedLensing (fields, Nfields);215 int needLensing = dbFieldNeedLensing (fields, Nfields); 216 216 int needStarpar = dbFieldNeedStarpar (fields, Nfields, FALSE); 217 217 … … 234 234 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 235 235 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 236 //catalog.catflags |= needLensing ? DVO_LOAD_LENSING : DVO_SKIP_LENSING;236 catalog.catflags |= needLensing ? DVO_LOAD_LENSING : DVO_SKIP_LENSING; 237 237 catalog.catflags |= needStarpar ? DVO_LOAD_STARPAR : DVO_SKIP_STARPAR; 238 238 catalog.Nsecfilt = Nsecfilt; … … 274 274 StarPar *starpar = needStarpar ? &catalog.starpar[Nstarpar] : NULL; 275 275 276 // int Nlensing = average->lensobjOffset;277 // Lensobj *lensobj = needLensobj ? &catalog.lensobj[m] : NULL;276 int Nlensing = average->lensingOffset; 277 Lensing *lensing = needLensing ? &catalog.lensing[Nlensing] : NULL; 278 278 279 279 int Nsec = j*Nsecfilt; … … 281 281 282 282 for (n = 0; n < Nfields; n++) { 283 values[n] = dbExtractMeasures (average, secfilt, &catalog.measure[m], NULL, starpar, &fields[n]);283 values[n] = dbExtractMeasures (average, secfilt, &catalog.measure[m], lensing, starpar, &fields[n]); 284 284 } 285 285 // fprintf (stderr, "object: ave: %f, cat: %f, averef %d\n", fields[n].name, values[2], values[3], catalog.measure[m].averef); -
trunk/Ohana/src/opihi/lib.data/gaussian.c
r3894 r38986 20 20 21 21 int i; 22 long A, B;23 22 double val, x, dx, dx1, dx2, dx3, df; 24 23 double mean, sigma; … … 27 26 if (Ngaussint == Nbin) return; 28 27 29 A = time(NULL); 30 for (B = 0; A == time(NULL); B++); 31 srand48(B); 28 long A = time(NULL); 29 srand48(A); 32 30 33 31 Ngaussint = Nbin; -
trunk/Ohana/src/opihi/lib.shell/ConfigInit.c
r16900 r38986 38 38 } 39 39 40 // XXX this is a bit dangerous : answer may have an arbitrary 41 // length, but we do not know the available space in 'ptr' 42 // we really should be passing in the buffer size and limiting the copy 43 44 40 45 if (!strcmp (mode, "%s")) strcpy ((char *) ptr, answer); 41 46 if (!strcmp (mode, "%d")) *(int *) ptr = atoi (answer); -
trunk/Ohana/src/opihi/lib.shell/SocketOps.c
r32632 r38986 23 23 status = gethostname (myHostname, HOST_NAME_MAX); 24 24 25 fprintf (stderr, "target host: %s, real host: %s\n", hostname, myHostname); 25 if (strcmp (hostname, myHostname)) { 26 fprintf (stderr, "target host: %s, real host: %s\n", hostname, myHostname); 27 fprintf (stderr, "please run on the correct host\n"); 28 exit (2); 29 } 26 30 27 31 GetPortRange (&start, &stop, portinfo); … … 197 201 198 202 host = gethostbyname (hostname); 203 if (!host) { 204 gprint (GP_ERR, "cannot connect to pantasks server %s\n", hostname); 205 exit (3); 206 } 207 199 208 bzero (hostip, 80); 200 209 for (i = 0; i < host[0].h_length; i++) { -
trunk/Ohana/src/opihi/lib.shell/gprint.c
r27592 r38986 255 255 if (file == NULL) { 256 256 // XXX this is a problem: we are leaving open the old file 257 fprintf (stderr, " cannot open file %s\n", stream[0].name);257 fprintf (stderr, "gprint cannot open file %s\n", stream[0].name); 258 258 free (stream[0].name); 259 259 file = (dest == GP_LOG) ? stdout : stderr; -
trunk/Ohana/src/opihi/pantasks
-
Property svn:mergeinfo
set to
/branches/eam_branches/ipp-20150616/Ohana/src/opihi/pantasks merged eligible /branches/eam_branches/ipp-20150625/Ohana/src/opihi/pantasks merged eligible
-
Property svn:mergeinfo
set to
-
trunk/Ohana/src/opihi/pantasks/CheckJobs.c
r27614 r38986 1 1 # include "pantasks.h" 2 static int Ncheck = 0; 2 3 3 4 float CheckJobs () { … … 12 13 float time_running, next_timeout; 13 14 14 // int Ncheck; 15 // Ncheck = 0; 15 Ncheck ++; 16 16 17 17 // actual maximum delay is controlled in job_threads.c … … 21 21 /** test all jobs: ready to test? finished? **/ 22 22 while ((job = NextJob ()) != NULL) { 23 // Ncheck ++;24 23 25 24 task = job[0].task; … … 220 219 SetTaskTimer (&job[0].last); 221 220 } 222 // fprintf (stderr, "check %d jobs\n", Ncheck); 221 223 222 JobTaskUnlock(); 224 223 return (next_timeout); -
trunk/Ohana/src/opihi/pantasks/CheckTasks.c
r31666 r38986 1 1 # include "pantasks.h" 2 static int Ncheck = 0; 2 3 3 4 float CheckTasks () { … … 7 8 int status; 8 9 float time_running, next_timeout, fuzz; 10 11 Ncheck ++; 9 12 10 13 // actual maximum delay is controlled in job_threads.c -
trunk/Ohana/src/opihi/pantasks/TaskOps.c
r36623 r38986 22 22 void FreeTasks () { 23 23 int i; 24 for (i = 0; i < Ntasks; i++) { 24 int ntasks = Ntasks; 25 Ntasks = 0; 26 for (i = 0; i < ntasks; i++) { 25 27 FreeTask (tasks[i]); 26 28 } -
trunk/Ohana/src/opihi/pantasks/pantasks_server.c.in
r32632 r38986 19 19 20 20 char hostname[256], portinfo[256]; 21 char log_stdout[1024], log_stderr[1024] ;21 char log_stdout[1024], log_stderr[1024], tmpname[1024]; 22 22 pthread_t JobsAndTasksThread; 23 23 pthread_t clientsThread; … … 34 34 stdin = freopen ("/dev/zero", "r", stdin); 35 35 36 // this block redirects the actual stderr, stdout steams to the output files 37 if (VarConfig ("PANTASKS_SERVER_STDOUT", "%s", log_stdout) != NULL) { 36 // this block redirects the actual stderr, stdout streams to the output files 37 if (VarConfig ("PANTASKS_SERVER_STDOUT", "%s", tmpname) != NULL) { 38 strcpy (log_stdout, tmpname); 38 39 if (strcmp (log_stdout, "stdout")) { 39 40 stdout = freopen (log_stdout, "a", stdout); … … 44 45 } 45 46 } 46 if (VarConfig ("PANTASKS_SERVER_STDERR", "%s", log_stderr) != NULL) { 47 if (VarConfig ("PANTASKS_SERVER_STDERR", "%s", tmpname) != NULL) { 48 strcpy (log_stderr, tmpname); 47 49 if (strcmp (log_stderr, "stderr")) { 48 50 stderr = freopen (log_stderr, "a", stderr); -
trunk/Ohana/src/opihi/pantasks/test/local.sh
r10647 r38986 1 1 2 2 ## a basic test of memory allocation 3 if (not($?VERBOSE)) set VERBOSE = 0 3 4 4 5 exec rm -f tmp.txt … … 38 39 $startmem = $word:1 39 40 end 41 40 42 macro memcheck 41 43 list word -x "ps -p $PID -o rss" -
trunk/Ohana/src/photdbc/Makefile
r36833 r38986 1 default: photdbc photdbc_client dvo dist1 default: photdbc photdbc_client dvocompress dvocompress_client dvodist 2 2 help: 3 @echo "make options: photdbc photdbc_client dvo dist"3 @echo "make options: photdbc photdbc_client dvocompress dvocompress_client dvodist" 4 4 5 5 include ../../Makefile.System … … 20 20 photdbc_client: $(BIN)/photdbc_client.$(ARCH) 21 21 22 dvocompress: $(BIN)/dvocompress.$(ARCH) 23 dvocompress_client: $(BIN)/dvocompress_client.$(ARCH) 24 25 22 26 dvodist: $(BIN)/dvodist.$(ARCH) 23 27 24 install: $(DESTBIN)/photdbc $(DESTBIN)/photdbc_client $(DESTBIN)/dvo dist28 install: $(DESTBIN)/photdbc $(DESTBIN)/photdbc_client $(DESTBIN)/dvocompress $(DESTBIN)/dvocompress_client $(DESTBIN)/dvodist 25 29 26 30 PHOTDBC = \ 27 31 $(SRC)/photdbc.$(ARCH).o \ 28 32 $(SRC)/photdbc_catalogs.$(ARCH).o \ 33 $(SRC)/SetSignals.$(ARCH).o \ 29 34 $(SRC)/initialize.$(ARCH).o \ 30 35 $(SRC)/ConfigInit.$(ARCH).o \ … … 39 44 $(SRC)/photdbc_client.$(ARCH).o \ 40 45 $(SRC)/photdbc_catalogs.$(ARCH).o \ 46 $(SRC)/SetSignals.$(ARCH).o \ 41 47 $(SRC)/initialize.$(ARCH).o \ 42 48 $(SRC)/ConfigInit.$(ARCH).o \ … … 45 51 $(SRC)/join_stars.$(ARCH).o \ 46 52 $(SRC)/make_subcatalog.$(ARCH).o 53 54 DVOCOMPRESS = \ 55 $(SRC)/dvocompress.$(ARCH).o \ 56 $(SRC)/dvocompress_catalogs.$(ARCH).o \ 57 $(SRC)/SetSignals.$(ARCH).o \ 58 $(SRC)/args_dvocompress.$(ARCH).o \ 59 $(SRC)/Shutdown.$(ARCH).o 60 61 DVOCOMPRESS_CLIENT = \ 62 $(SRC)/dvocompress_client.$(ARCH).o \ 63 $(SRC)/dvocompress_catalogs.$(ARCH).o \ 64 $(SRC)/SetSignals.$(ARCH).o \ 65 $(SRC)/args_dvocompress.$(ARCH).o \ 66 $(SRC)/Shutdown.$(ARCH).o 47 67 48 68 DVODIST = \ … … 89 109 $(BIN)/photdbc_client.$(ARCH): $(PHOTDBC_CLIENT) 90 110 111 $(DVOCOMPRESS): $(INC)/dvocompress.h 112 $(BIN)/dvocompress.$(ARCH): $(DVOCOMPRESS) 113 114 $(DVOCOMPRESS_CLIENT): $(INC)/dvocompress.h 115 $(BIN)/dvocompress_client.$(ARCH): $(DVOCOMPRESS_CLIENT) 116 91 117 $(DVODIST): $(INC)/dvodist.h 92 118 $(BIN)/dvodist.$(ARCH): $(DVODIST) -
trunk/Ohana/src/photdbc/src/Shutdown_dvodist.c
r38441 r38986 43 43 va_end (argp); 44 44 45 // XXX this is in SetSignals.c, which includes photdbc.h46 SetProtect (TRUE);47 gfits_db_close (&db);48 45 fprintf (stderr, "ERROR: dvodist halted\n"); 49 46 exit (1); -
trunk/Ohana/src/photdbc/src/copy_images.c
r38441 r38986 59 59 char mapfile[DVO_MAX_PATH]; 60 60 snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR); 61 AstromOffsetTable *table_src = AstromOffsetMapLoad (mapfile, VERBOSE);61 AstromOffsetTable *table_src = AstromOffsetMapLoad (mapfile, 100000, VERBOSE); 62 62 63 63 // assign images.coords.offsetMap -> table->map[i] -
trunk/Ohana/src/photdbc/src/photdbc.c
r38062 r38986 7 7 8 8 /* get configuration info, args, lockfile */ 9 SetSignals (); 9 10 initialize (argc, argv); 10 11 -
trunk/Ohana/src/photdbc/src/photdbc_catalogs.c
r38471 r38986 82 82 // get_mags (catalog); 83 83 84 dvo_catalog_save (&outcatalog, VERBOSE); 85 dvo_catalog_unlock (&outcatalog); 84 SetProtect (TRUE); 85 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", outcatalog.filename); exit (1); } 86 if (!dvo_catalog_unlock (&outcatalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", outcatalog.filename); exit (1); } 87 SetProtect (FALSE); 88 86 89 dvo_catalog_free (&outcatalog); 87 90 -
trunk/Ohana/src/photdbc/src/photdbc_client.c
r38062 r38986 3 3 int main (int argc, char **argv) { 4 4 5 SetSignals (); 5 6 initialize_client (argc, argv); 6 7 -
trunk/Ohana/src/relastro/Makefile
r38062 r38986 20 20 relastro_client: $(BIN)/relastro_client.$(ARCH) 21 21 22 install: $(DESTBIN)/relastro $(DESTBIN)/relastro_client $(DESTBIN)/testparallax 22 install: $(DESTBIN)/relastro $(DESTBIN)/relastro_client 23 24 # $(DESTBIN)/testparallax 23 25 24 26 RELASTRO = \ … … 26 28 $(SRC)/FitChip.$(ARCH).o \ 27 29 $(SRC)/FitMosaic.$(ARCH).o \ 30 $(SRC)/FitSimple.$(ARCH).o \ 31 $(SRC)/FitAstromOps.$(ARCH).o \ 28 32 $(SRC)/FitPM.$(ARCH).o \ 29 $(SRC)/FitPar.$(ARCH).o \30 33 $(SRC)/FitPMandPar.$(ARCH).o \ 31 $(SRC)/Fit Simple.$(ARCH).o\34 $(SRC)/FitPosPMfixed.$(ARCH).o \ 32 35 $(SRC)/ImageOps.$(ARCH).o \ 33 36 $(SRC)/MosaicOps.$(ARCH).o \ … … 99 102 RELASTRO_CLIENT = \ 100 103 $(SRC)/ConfigInit.$(ARCH).o \ 104 $(SRC)/FitSimple.$(ARCH).o \ 105 $(SRC)/FitAstromOps.$(ARCH).o \ 101 106 $(SRC)/FitPM.$(ARCH).o \ 102 $(SRC)/FitPar.$(ARCH).o \103 107 $(SRC)/FitPMandPar.$(ARCH).o \ 104 $(SRC)/Fit Simple.$(ARCH).o\108 $(SRC)/FitPosPMfixed.$(ARCH).o \ 105 109 $(SRC)/ImageOps.$(ARCH).o \ 106 110 $(SRC)/MosaicOps.$(ARCH).o \ -
trunk/Ohana/src/relastro/include/relastro.h
r38441 r38986 28 28 29 29 typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS} FitTarget; 30 31 typedef enum { 32 FIT_RESULT_RA, 33 FIT_RESULT_DEC, 34 FIT_RESULT_uR, 35 FIT_RESULT_uD, 36 FIT_RESULT_PLX, 37 } FitAstromResultMode; 30 38 31 39 typedef enum { … … 115 123 double Ro, dRo; 116 124 double Do, dDo; 117 118 125 double uR, duR; 119 126 double uD, duD; 120 121 double p, dp; 127 double p, dp; 122 128 123 129 double chisq; 124 130 int Nfit; 125 } PMFit; 131 } FitAstromResult; 132 133 typedef struct { 134 double **A; 135 double **B; 136 int Nterms; 137 } FitAstromData; 138 139 typedef struct { 140 double X, dX; 141 double Y, dY; 142 double R, dR; 143 double D, dD; 144 double T, dT; 145 double pR; 146 double pD; 147 double C_blue; 148 double C_red; 149 int measure; 150 } FitAstromPoint; 151 152 typedef struct { 153 off_t Nave; 154 off_t Npm; 155 off_t Npar; 156 off_t Nskip; 157 off_t Noffset; 158 159 double *values; 160 FitAstromResult *fit; // use bootstrap resampling to generate Nfit fits to measure the stats 161 int Nfit; 162 int NfitAlloc; 163 164 FitAstromPoint *points; 165 FitAstromPoint *sample; 166 int Npoints; 167 int NpointsAlloc; 168 169 FitAstromData *fitdataPos; 170 FitAstromData *fitdataPM; 171 FitAstromData *fitdataPar; 172 173 Coords coords; 174 time_t T2000; 175 } FitStats; 126 176 127 177 typedef struct { … … 150 200 151 201 typedef struct { 152 off_t Nave;153 off_t Npm;154 off_t Npar;155 off_t Nskip;156 off_t Noffset;157 } FitStats;158 159 typedef struct {160 202 double scale; 161 203 double **Roff; … … 180 222 int Nicrfobj; 181 223 } ICRFobj; 224 225 # define ID_MEAS_OBJECT_HAS_2MASS ID_MEAS_POOR_PHOTOM 182 226 183 227 /* global variables set in parameter file */ … … 224 268 int PARALLEL_OUTPUT; 225 269 270 int VERBOSE_IMAGE; 271 226 272 int VERBOSE; 227 273 int VERBOSE2; … … 234 280 int USE_ICRF_SHFIT; 235 281 int USE_ICRF_POLE; 282 283 int USE_ALL_IMAGES; 236 284 237 285 int RESET; … … 252 300 int CHIPORDER; 253 301 int CHIPMAP; 302 303 int N_BOOTSTRAP_SAMPLES; 254 304 255 305 int MaxDensityUse; … … 369 419 int liststats_pos PROTO((double *value, double *dvalue, int N, StatType *stats, int XVERB)); 370 420 Catalog *load_catalogs PROTO((SkyList *skylist, int *Ncatalog, int subselect, int hostID, char *hostpath, char *syncfile)); 371 int load_images PROTO((FITS_DB *db, SkyList *skylist, int UseFullOverlap ));421 int load_images PROTO((FITS_DB *db, SkyList *skylist, int UseFullOverlap, int UseAllImages)); 372 422 Image *select_images PROTO((SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage, int UseFullOverlap)); 373 423 … … 448 498 int UpdateObjects (Catalog *catalog, int Ncatalog, int Nloop); 449 499 int UpdateSimple (Catalog *catalog, int Ncatalog); 450 int UpdateChips (Catalog *catalog, int Ncatalog );500 int UpdateChips (Catalog *catalog, int Ncatalog, int Nloop); 451 501 int UpdateMosaic (Catalog *catalog, int Ncatalog); 452 502 int UpdateMeasures (Catalog *catalog, int Ncatalog); … … 457 507 458 508 int sun_ecliptic (double jd, double *lambda, double *beta, double *epsilon, double *Radius); 459 int ParFactor (double *pR, double *pD, double RA, double Dec, double Time , double Tmean);460 int FitPM ( PMFit *fit, double *X, double *dX, double *Y, double *dY, double *T, int Npts, int XVERB);461 int FitP ar (PMFit *fit, double *X, double *dX, double *Y, double *dY, double *pR, double *pD, int Npts);462 int FitP MandPar (PMFit *fit, double *X, double *dX, double *Y, double *dY, double *T, double *pR, double *pD, int Npts, int XVERB);509 int ParFactor (double *pR, double *pD, double RA, double Dec, double Time); 510 int FitPM (FitAstromResult *fit, FitAstromData *data, FitAstromPoint *points, int Npoints); 511 int FitPMandPar (FitAstromResult *fit, FitAstromData *data, FitAstromPoint *points, int Npoints); 512 int FitPosPMfixed (FitAstromResult *fit, FitAstromData *data, FitAstromPoint *points, int Npoints); 463 513 464 514 Mosaic *getMosaicForImage (off_t N); … … 661 711 int client_logger_init (char *dirname); 662 712 int client_logger_message (char *format,...); 713 714 int FitAstromSetChisq (FitAstromResult *fit, FitAstromPoint *points, int Npoints, FitMode mode); 715 double VectorFractionInterpolate (double *values, float fraction, int Npts); 716 int BootstrapRobustStats (FitAstromResult *result, FitAstromResult *fit, int Nfit, int mode); 717 int BootstrapResample (FitAstromPoint *sample, FitAstromPoint *points, int Npoints); 718 int CatalogMaxNmeasure (Catalog *catalog, int Ncatalog); 719 int FitAstromPoints_Project (FitStats *fitStats, double *Tmean, double *Trange, double *parRange); 720 int UpdateObjects_SelectMeasures (FitStats *fit, Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int isStack); 721 int UpdateObjects_Stack (Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int Nsecfilt, FitStats *fitStats); 722 int UpdateObjects_Chips (Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int Nsecfilt, FitStats *fitStats, int cat, off_t measOff); 723 724 void FitAstromResultInit (FitAstromResult *fit); 725 void FitAstromPointInit (FitAstromPoint *object); 726 void FitAstromDataFree (FitAstromData *fit); 727 FitAstromData *FitAstromDataInit (int Nterms); 728 void FitStatsFree (FitStats *fitStats); 729 void FitStatsSum (FitStats *src, FitStats *tgt); 730 void FitStatsReset (FitStats *tgt); 731 FitStats *FitStatsInit (int Nmax, int Nboot); 732 int FitAstromResultSetPM (FitAstromResult *fit, int Nfit, Average *average); 733 void AstromErrorSetLoop (int Nloop, int isImageMode); -
trunk/Ohana/src/relastro/src/FitChip.c
r37807 r38986 81 81 } 82 82 83 if (VERBOSE2) fprintf (stderr, "using %d for %s\n", order_use, image[0].name); 83 if (VERBOSE2) { 84 fprintf (stderr, "using %d for %s\n", order_use, image[0].name); 85 } 84 86 85 87 // when fitting the map, first fit a linear model (below? change Npolyterms to -1) … … 92 94 for (i = 0; i < Nmatch; i++) { 93 95 if (raw[i].mask) continue; 94 fit_add (fit, raw[i].X, raw[i].Y, ref[i].L, ref[i].M, r aw[i].dPos);96 fit_add (fit, raw[i].X, raw[i].Y, ref[i].L, ref[i].M, ref[i].dPos); 95 97 } 96 98 … … 310 312 int i, N; 311 313 312 float *x, *y, *dX, *dY ;314 float *x, *y, *dX, *dY, *dP; 313 315 ALLOCATE (x, float, Npts); 314 316 ALLOCATE (y, float, Npts); 315 317 ALLOCATE (dX, float, Npts); 316 318 ALLOCATE (dY, float, Npts); 319 ALLOCATE (dP, float, Npts); 317 320 318 321 N = 0; … … 323 326 dX[N] = ref[i].X - raw[i].X; 324 327 dY[N] = ref[i].Y - raw[i].Y; 328 dP[N] = ref[i].dPos; 325 329 N++; 326 330 } … … 329 333 // (L,M) = f(X',Y') : (X',Y') = (X,Y) + (dX,dY) 330 334 331 AstromOffsetMapFit (map, x, y, dX, N, TRUE);332 AstromOffsetMapFit (map, x, y, dY, N, FALSE);335 AstromOffsetMapFit (map, x, y, dX, dP, N, TRUE); 336 AstromOffsetMapFit (map, x, y, dY, dP, N, FALSE); 333 337 334 338 AstromOffsetMapRepair (map, TRUE); … … 339 343 free (dX); 340 344 free (dY); 345 free (dP); 341 346 342 347 return TRUE; -
trunk/Ohana/src/relastro/src/FitPM.c
r32695 r38986 1 1 # include "relastro.h" 2 2 3 / * do we want an init function which does the alloc and a clear function to free? */4 int FitPM ( PMFit *fit, double *X, double *dX, double *Y, double *dY, double *T, int Npts, int XVERB) {3 // initial values of *fit are ignored 4 int FitPM (FitAstromResult *fit, FitAstromData *data, FitAstromPoint *points, int Npoints) { 5 5 6 6 int i; 7 7 8 double **A, **B;9 8 double wx, wy, Wx, Wy, Tx, Ty, Tx2, Ty2, Xs, Ys, XT, YT; 10 double chisq, Xf, Yf;11 9 12 /* do I need to do this as 2 2x2 matrix equations? */ 13 A = array_init (4, 4); 14 B = array_init (4, 1); 10 myAssert (data->Nterms == 4, "invalid fit arrays"); 15 11 16 12 Wx = Wy = Tx = Ty = Tx2 = Ty2 = Xs = Ys = XT = YT = 0.0; 17 for (i = 0; i < Npts; i++) { 13 14 for (i = 0; i < Npoints; i++) { 18 15 /* handle case where dX or dY = 0.0 */ 19 wx = 1.0 / SQ( dX[i]);20 wy = 1.0 / SQ( dY[i]);16 wx = 1.0 / SQ(points[i].dX); 17 wy = 1.0 / SQ(points[i].dY); 21 18 22 19 Wx += wx; 23 20 Wy += wy; 24 21 25 Tx += T[i]*wx;26 Ty += T[i]*wy;22 Tx += points[i].T*wx; 23 Ty += points[i].T*wy; 27 24 28 Tx2 += SQ( T[i])*wx;29 Ty2 += SQ( T[i])*wy;25 Tx2 += SQ(points[i].T)*wx; 26 Ty2 += SQ(points[i].T)*wy; 30 27 31 Xs += X[i]*wx;32 Ys += Y[i]*wy;28 Xs += points[i].X*wx; 29 Ys += points[i].Y*wy; 33 30 34 XT += X[i]*T[i]*wx;35 YT += Y[i]*T[i]*wy;31 XT += points[i].X*points[i].T*wx; 32 YT += points[i].Y*points[i].T*wy; 36 33 } 37 34 38 A[0][0] = Wx;39 A[0][1] = Tx;35 data->A[0][0] = Wx; 36 data->A[0][1] = Tx; 40 37 41 A[1][0] = Tx;42 A[1][1] = Tx2;38 data->A[1][0] = Tx; 39 data->A[1][1] = Tx2; 43 40 44 A[2][2] = Wy;45 A[2][3] = Ty;41 data->A[2][2] = Wy; 42 data->A[2][3] = Ty; 46 43 47 A[3][2] = Ty;48 A[3][3] = Ty2;44 data->A[3][2] = Ty; 45 data->A[3][3] = Ty2; 49 46 50 B[0][0] = Xs;51 B[1][0] = XT;52 B[2][0] = Ys;53 B[3][0] = YT;47 data->B[0][0] = Xs; 48 data->B[1][0] = XT; 49 data->B[2][0] = Ys; 50 data->B[3][0] = YT; 54 51 55 dgaussjordan ( A,B, 4, 1);52 dgaussjordan (data->A, data->B, 4, 1); 56 53 57 fit [0].Ro =B[0][0];58 fit [0].uR =B[1][0];59 fit [0].Do =B[2][0];60 fit [0].uD =B[3][0];61 fit [0].p = 0.0;54 fit->Ro = data->B[0][0]; 55 fit->uR = data->B[1][0]; 56 fit->Do = data->B[2][0]; 57 fit->uD = data->B[3][0]; 58 fit->p = 0.0; 62 59 63 fit [0].dRo = sqrt(A[0][0]);64 fit [0].duR = sqrt(A[1][1]);65 fit [0].dDo = sqrt(A[2][2]);66 fit [0].duD = sqrt(A[3][3]);67 fit [0].dp = 0.0;60 fit->dRo = sqrt(data->A[0][0]); 61 fit->duR = sqrt(data->A[1][1]); 62 fit->dDo = sqrt(data->A[2][2]); 63 fit->duD = sqrt(data->A[3][3]); 64 fit->dp = 0.0; 68 65 69 array_free (A, 4); 70 array_free (B, 4); 66 fit->Nfit = Npoints; 71 67 72 // add up the chi square for the fit73 chisq = 0.0;74 for (i = 0; i < Npts; i++) {75 Xf = fit[0].Ro + fit[0].uR*T[i];76 Yf = fit[0].Do + fit[0].uD*T[i];77 chisq += SQ(X[i] - Xf) / SQ(dX[i]);78 chisq += SQ(Y[i] - Yf) / SQ(dY[i]);79 if (XVERB) fprintf (stderr, "chisq contrib : %f %f : %f %f : %f %f : %f %f : %f\n", Xf, Yf, X[i] - Xf, Y[i] - Yf, dX[i], dY[i], (X[i] - Xf) / dX[i], (Y[i] - Yf) / dY[i], chisq);80 }81 fit[0].Nfit = Npts;82 83 // the reduced chisq is divided by (Ndof = 2*Npts - 4)84 fit[0].chisq = chisq / (2.0*Npts - 4.0);85 68 return (TRUE); 86 69 } 87 88 // XXX this function should (optionally?) iterate and clip outlier detections -
trunk/Ohana/src/relastro/src/FitPMandPar.c
r32695 r38986 1 1 # include "relastro.h" 2 2 3 / * do we want an init function which does the alloc and a clear function to free? */4 int FitPMandPar ( PMFit *fit, double *X, double *dX, double *Y, double *dY, double *T, double *pR, double *pD, int Npts, int XVERB) {3 // initial values of *fit are ignored 4 int FitPMandPar (FitAstromResult *fit, FitAstromData *data, FitAstromPoint *points, int Npoints) { 5 5 6 6 int i; 7 7 8 double **A, **B;9 8 double wx, wy, Wx, Wy, Tx, Ty, Tx2, Ty2, Xs, Ys, XT, YT; 10 9 double PR, PD, PRT, PDT, PRX, PDY, PR2, PD2; 11 double chisq, Xf, Yf;12 10 13 A = array_init (5, 5); 14 B = array_init (5, 1); 11 myAssert (data->Nterms == 5, "invalid fit arrays"); 15 12 16 13 PR = PD = PRT = PDT = PRX = PDY = PR2 = PD2 = 0.0; 17 14 Wx = Wy = Tx = Ty = Tx2 = Ty2 = Xs = Ys = XT = YT = 0.0; 18 for (i = 0; i < Npts; i++) { 15 16 for (i = 0; i < Npoints; i++) { 19 17 /* handle case where dX or dY = 0.0 */ 20 wx = 1.0 / SQ( dX[i]);21 wy = 1.0 / SQ( dY[i]);18 wx = 1.0 / SQ(points[i].dX); 19 wy = 1.0 / SQ(points[i].dY); 22 20 23 21 Wx += wx; 24 22 Wy += wy; 25 23 26 Tx += T[i]*wx;27 Ty += T[i]*wy;24 Tx += points[i].T*wx; 25 Ty += points[i].T*wy; 28 26 29 Tx2 += SQ( T[i])*wx;30 Ty2 += SQ( T[i])*wy;27 Tx2 += SQ(points[i].T)*wx; 28 Ty2 += SQ(points[i].T)*wy; 31 29 32 PR += p R[i]*wx;33 PD += p D[i]*wy;30 PR += points[i].pR*wx; 31 PD += points[i].pD*wy; 34 32 35 PRT += p R[i]*T[i]*wx;36 PDT += p D[i]*T[i]*wy;33 PRT += points[i].pR*points[i].T*wx; 34 PDT += points[i].pD*points[i].T*wy; 37 35 38 PRX += p R[i]*X[i]*wx;39 PDY += p D[i]*Y[i]*wy;36 PRX += points[i].pR*points[i].X*wx; 37 PDY += points[i].pD*points[i].Y*wy; 40 38 41 PR2 += SQ(p R[i])*wx;42 PD2 += SQ(p D[i])*wy;39 PR2 += SQ(points[i].pR)*wx; 40 PD2 += SQ(points[i].pD)*wy; 43 41 44 Xs += X[i]*wx;45 Ys += Y[i]*wy;42 Xs += points[i].X*wx; 43 Ys += points[i].Y*wy; 46 44 47 XT += X[i]*T[i]*wx;48 YT += Y[i]*T[i]*wy;45 XT += points[i].X*points[i].T*wx; 46 YT += points[i].Y*points[i].T*wy; 49 47 } 50 48 51 A[0][0] = Wx;52 A[0][1] = Tx;53 A[0][4] = PR;49 data->A[0][0] = Wx; 50 data->A[0][1] = Tx; 51 data->A[0][4] = PR; 54 52 55 A[1][0] = Tx;56 A[1][1] = Tx2;57 A[1][4] = PRT;53 data->A[1][0] = Tx; 54 data->A[1][1] = Tx2; 55 data->A[1][4] = PRT; 58 56 59 A[2][2] = Wy;60 A[2][3] = Ty;61 A[2][4] = PD;57 data->A[2][2] = Wy; 58 data->A[2][3] = Ty; 59 data->A[2][4] = PD; 62 60 63 A[3][2] = Ty;64 A[3][3] = Ty2;65 A[3][4] = PDT;61 data->A[3][2] = Ty; 62 data->A[3][3] = Ty2; 63 data->A[3][4] = PDT; 66 64 67 A[4][0] = PR;68 A[4][1] = PRT;69 A[4][2] = PD;70 A[4][3] = PDT;71 A[4][4] = PR2 + PD2;65 data->A[4][0] = PR; 66 data->A[4][1] = PRT; 67 data->A[4][2] = PD; 68 data->A[4][3] = PDT; 69 data->A[4][4] = PR2 + PD2; 72 70 73 B[0][0] = Xs;74 B[1][0] = XT;75 B[2][0] = Ys;76 B[3][0] = YT;77 B[4][0] = PRX + PDY;71 data->B[0][0] = Xs; 72 data->B[1][0] = XT; 73 data->B[2][0] = Ys; 74 data->B[3][0] = YT; 75 data->B[4][0] = PRX + PDY; 78 76 79 dgaussjordan ( A,B, 5, 1);77 dgaussjordan (data->A, data->B, 5, 1); 80 78 81 fit [0].Ro =B[0][0];82 fit [0].uR =B[1][0];83 fit [0].Do =B[2][0];84 fit [0].uD =B[3][0];85 fit [0].p =B[4][0];79 fit->Ro = data->B[0][0]; 80 fit->uR = data->B[1][0]; 81 fit->Do = data->B[2][0]; 82 fit->uD = data->B[3][0]; 83 fit->p = data->B[4][0]; 86 84 87 fit [0].dRo = sqrt(A[0][0]);88 fit [0].duR = sqrt(A[1][1]);89 fit [0].dDo = sqrt(A[2][2]);90 fit [0].duD = sqrt(A[3][3]);91 fit [0].dp = sqrt(A[4][4]);85 fit->dRo = sqrt(data->A[0][0]); 86 fit->duR = sqrt(data->A[1][1]); 87 fit->dDo = sqrt(data->A[2][2]); 88 fit->duD = sqrt(data->A[3][3]); 89 fit->dp = sqrt(data->A[4][4]); 92 90 93 array_free (A, 5); 94 array_free (B, 5); 91 fit->Nfit = Npoints; 95 92 96 /* get the chisq from the matrix values */97 98 // add up the chi square for the fit99 chisq = 0.0;100 for (i = 0; i < Npts; i++) {101 Xf = fit[0].Ro + fit[0].uR*T[i] + fit[0].p*pR[i];102 Yf = fit[0].Do + fit[0].uD*T[i] + fit[0].p*pD[i];103 chisq += SQ(X[i] - Xf) / SQ(dX[i]);104 chisq += SQ(Y[i] - Yf) / SQ(dY[i]);105 if (XVERB) fprintf (stderr, "chisq contrib : %f %f : %f %f : %f %f : %f %f : %f\n", Xf, Yf, X[i] - Xf, Y[i] - Yf, dX[i], dY[i], (X[i] - Xf) / dX[i], (Y[i] - Yf) / dY[i], chisq);106 107 }108 fit[0].Nfit = Npts;109 110 // the reduced chisq is divided by (Ndof = 2*Npts - 5)111 fit[0].chisq = chisq / (2.0*Npts - 5.0);112 93 return (TRUE); 113 94 } -
trunk/Ohana/src/relastro/src/FrameCorrection.c
r38062 r38986 479 479 } 480 480 481 AstromOffsetMapFit (map, Xfit, Yfit, dXfit, N keep, TRUE);482 AstromOffsetMapFit (map, Xfit, Yfit, dYfit, N keep, FALSE);481 AstromOffsetMapFit (map, Xfit, Yfit, dXfit, NULL, Nkeep, TRUE); 482 AstromOffsetMapFit (map, Xfit, Yfit, dYfit, NULL, Nkeep, FALSE); 483 483 484 484 for (i = 0; i < Npts; i++) { -
trunk/Ohana/src/relastro/src/FrameCorrectionUtils.c
r38553 r38986 240 240 float *buffer = (float *)matrix->buffer; 241 241 242 float * *value = (raDirection) ? map->dXv : map->dYv;242 float *value = (raDirection) ? map->dXv : map->dYv; 243 243 244 244 int ix, iy; 245 245 for (ix = 0; ix < map->Nx; ix++) { 246 246 for (iy = 0; iy < map->Ny; iy++) { 247 buffer[ix + map->Nx*iy] = value[ix ][iy];247 buffer[ix + map->Nx*iy] = value[ix + map->Nx*iy]; 248 248 } 249 249 } … … 265 265 float *buffer = (float *) matrix->buffer; 266 266 267 float * *value = (raDirection) ? map->dXv : map->dYv;267 float *value = (raDirection) ? map->dXv : map->dYv; 268 268 269 269 int ix, iy; 270 270 for (ix = 0; ix < map->Nx; ix++) { 271 271 for (iy = 0; iy < map->Ny; iy++) { 272 value[ix ][iy] = buffer[ix + map->Nx*iy];272 value[ix + map->Nx*iy] = buffer[ix + map->Nx*iy]; 273 273 } 274 274 } -
trunk/Ohana/src/relastro/src/GetAstromError.c
r36833 r38986 1 1 # include "relastro.h" 2 2 # define WEIGHTED_ERRORS 1 3 4 // XXX hard-wire the trends identified by CZW 5 static float BrightMo[] = {-15.6, -16.8, -17.0, -16.7, -16.0}; 6 static float BrightMs[] = {1.3, 1.3, 1.3, 1.8, 2.0}; 7 8 static int Nloop = -1; 9 static int isImage = FALSE; 10 11 // Nloop is used to modify the per detection errors 12 void AstromErrorSetLoop (int N, int isImageMode) { 13 Nloop = N; 14 isImage = isImageMode; 15 } 3 16 4 17 float GetAstromErrorTiny (MeasureTiny *measure, int mode) { … … 41 54 dPtotal = sqrt(SQ(dPsys) + SQ(AS*dPobs) + SQ(MS*dM)); 42 55 56 // for GPC1 data, we have a bright end model: 57 if ((measure[0].photcode > 10000) && (measure[0].photcode < 10480)) { 58 int Np = ((int) (measure[0].photcode / 100)) % 100; 59 myAssert (Np >= 0, "oops"); 60 myAssert (Np <= 4, "oops"); 61 62 float Minst = measure[0].M - measure[0].dt - 25.0; 63 float dPbright = 0.335 / (1.0 + exp(BrightMs[Np]*(Minst - BrightMo[Np]))); 64 dPtotal = hypot(dPtotal, dPbright); 65 } 43 66 dPtotal = MAX (dPtotal, MIN_ERROR); 67 68 // early on, we want 2MASS and Tycho to have a very high weight. This will force images 69 // to match the 2MASS / Tycho / ICRS reference frame. As Nloop gets higher, the weight 70 // needs to drop to allow the ps1 measurements to drive the solution 71 int is2MASS = USE_GALAXY_MODEL && !isImage && (measure[0].photcode >= 2011) && (measure[0].photcode <= 2013); 72 int isTycho = USE_GALAXY_MODEL && !isImage && (measure[0].photcode >= 2020) && (measure[0].photcode <= 2021); 73 int has2MASS = USE_GALAXY_MODEL && isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_2MASS); 74 75 // serious hack: if the object has 2MASS, we set this internal bit and adjust the 76 // weight to ensure the image is tied down to the 2mass frame 77 78 if (has2MASS) { 79 switch (Nloop) { 80 case 0: 81 dPtotal = dPtotal / 1000.0; 82 break; 83 case 1: 84 dPtotal = dPtotal / 300.0; 85 break; 86 case 2: 87 dPtotal = dPtotal / 100.0; 88 break; 89 case 3: 90 dPtotal = dPtotal / 30.0; 91 break; 92 case 4: 93 dPtotal = dPtotal / 10.0; 94 break; 95 case 5: 96 dPtotal = dPtotal / 10.0; 97 break; 98 default: 99 break; 100 } 101 } 102 if (is2MASS) { 103 switch (Nloop) { 104 case 0: 105 dPtotal = dPtotal / 1000.0; 106 break; 107 case 1: 108 dPtotal = dPtotal / 300.0; 109 break; 110 case 2: 111 dPtotal = dPtotal / 100.0; 112 break; 113 case 3: 114 dPtotal = dPtotal / 30.0; 115 break; 116 case 4: 117 dPtotal = dPtotal / 10.0; 118 break; 119 case 5: 120 dPtotal = dPtotal / 10.0; 121 break; 122 default: 123 break; 124 } 125 } 126 if (isTycho) { 127 switch (Nloop) { 128 case 0: 129 case 1: 130 dPtotal = dPtotal / 200.0; 131 break; 132 case 2: 133 case 3: 134 dPtotal = dPtotal / 100.0; 135 break; 136 case 4: 137 case 5: 138 dPtotal = dPtotal / 50.0; 139 break; 140 default: 141 break; 142 } 143 } 144 44 145 return (dPtotal); 45 146 } … … 84 185 dPtotal = sqrt(SQ(dPsys) + SQ(AS*dPobs) + SQ(MS*dM)); 85 186 187 // for GPC1 data, we have a bright end model: 188 if ((measure[0].photcode > 10000) && (measure[0].photcode < 10480)) { 189 int Np = ((int) (measure[0].photcode / 100)) % 100; 190 myAssert (Np >= 0, "oops"); 191 myAssert (Np <= 4, "oops"); 192 193 float Minst = measure[0].M - measure[0].dt - 25.0; 194 float dPbright = 0.335 / (1.0 + exp(BrightMs[Np]*(Minst - BrightMo[Np]))); 195 dPtotal = hypot(dPtotal, dPbright); 196 } 197 86 198 dPtotal = MAX (dPtotal, MIN_ERROR); 87 199 return (dPtotal); -
trunk/Ohana/src/relastro/src/ImageOps.c
r38062 r38986 1 1 # include "relastro.h" 2 int isGPC1chip (int photcode); 2 3 3 4 # define USE_IMAGE_ID 1 … … 690 691 raw[i].mask |= MARK_NAN_POS_ERROR; 691 692 } 693 694 // XXX A TEST: can we use only 2MASS measurements to fit the images? 695 // XXX Do NOT apply this for the real calibration 696 if (FALSE && !(measure[0].dbFlags & ID_MEAS_OBJECT_HAS_2MASS)) { 697 fprintf (stderr, "@"); 698 raw[i].mask |= MARK_BIG_OFFSET; 699 } 700 692 701 raw[i].Nmeas = catalog[c].average[n].Nmeasure; // record so we can check how well connected an image is 693 702 … … 751 760 ref[i].R = catalog[c].average[n].R; 752 761 ref[i].D = catalog[c].average[n].D; 762 763 // if we are applying the galaxy model, move the reference position... 764 if (USE_GALAXY_MODEL) { 765 // apply proper-motion from average position to measure epoch: 766 float dTime = (measure[0].t - catalog[c].average[n].Tmean) / (86400*365.25) ; // time relative to Tmean in years 767 768 // XXX do this in a better way? 769 ref[i].R += dTime * catalog[c].average[n].uR / 3600.0 / cos(ref[i].D*RAD_DEG); 770 ref[i].D += dTime * catalog[c].average[n].uD / 3600.0; 771 } 753 772 754 773 // 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) {774 if (0) { 756 775 myAssert (!isnan(measure[0].RoffGAL), "oops"); 757 776 myAssert (!isnan(measure[0].DoffGAL), "oops"); … … 981 1000 if (VERBOSE) fprintf (stderr, "%d measures marked poor, %d total\n", Ndel, Nave); 982 1001 free (R); 983 free (dR);984 free (D);985 free (dD);1002 free (dR); 1003 free (D); 1004 free (dD); 986 1005 } 987 1006 … … 1110 1129 if (VERBOSE) fprintf (stderr, "%d measures marked poor, %d total\n", Ndel, Nave); 1111 1130 free (R); 1112 free (dR);1113 free (D);1114 free (dD);1115 free (d2);1116 free (index);1131 free (dR); 1132 free (D); 1133 free (dD); 1134 free (d2); 1135 free (index); 1117 1136 } 1118 1137 … … 1215 1234 } 1216 1235 1217 if (MinBadQF > 0.0) { 1236 if ((MinBadQF > 0.0) && isGPC1chip(measure[0].photcode)) { 1237 if (!isfinite(measure[0].psfQF)) return FALSE; 1218 1238 if (measure[0].psfQF < MinBadQF) return FALSE; 1219 1239 } -
trunk/Ohana/src/relastro/src/ParFactor.c
r37261 r38986 2 2 # define J2000 2451545. /* Julian date at standard epoch */ 3 3 4 # if (0) 5 /* Low precision formulae for the sun, from Almanac p. C24 (1990) */ 6 /* ra and dec are returned as decimal hours and decimal degrees. */ 7 void lpsun (double jd, double *ra, double *dec) { 4 /* Low precision formulae for the sun, from Astro. Almanac p. C5 (2012) */ 5 // jdoff is days since J2000 6 int sun_ecliptic (double jdoff, double *lambda, double *beta, double *epsilon, double *Radius) { 8 7 9 double n, L, g, lambda,epsilon,alpha,delta,x,y,z; 10 11 n = jd - J2000; 12 L = 280.460 + 0.9856474 * n; 13 g = (357.528 + 0.9856003 * n)/DEG_IN_RADIAN; 14 lambda = (L + 1.915 * sin(g) + 0.020 * sin(2. * g))/DEG_IN_RADIAN; 15 epsilon = (23.439 - 0.0000004 * n)/DEG_IN_RADIAN; 16 17 // this is the conversion from ecliptic to celestial coords 18 x = cos(lambda); 19 y = cos(epsilon)*sin(lambda); 20 z = sin(epsilon)*sin(lambda); 21 22 *ra = (atan_circ(x,y))*HRS_IN_RADIAN; 23 *dec = (asin(z))*DEG_IN_RADIAN; 24 } 25 # endif 26 27 # if (0) 28 /* code borrowed from Skycalc : fix this stuff XXX */ 29 /* Low precision formulae for the sun, from Almanac p. C24 (1990) */ 30 int sun_ecliptic (double jd, double *lambda, double *beta, double *epsilon) { 31 32 double n, L, g; 33 34 35 n = jd - J2000; 36 L = 280.460 + 0.9856474 * n; 37 g = (357.528 + 0.9856003 * n)*RAD_DEG; 38 *lambda = L + 1.915 * sin(g) + 0.020 * sin(2. * g); // longitude in degrees 39 *beta = 0.0; // approx latitude 40 *epsilon = (23.439 - 0.0000004 * n); // obliquity of ecliptic in degrees 41 return TRUE; 42 } 43 # endif 44 45 /* Low precision formulae for the sun, from Astro. Almanac p. C5 (2012) */ 46 int sun_ecliptic (double jd, double *lambda, double *beta, double *epsilon, double *Radius) { 47 48 double n = jd - J2000; // day number 8 double n = jdoff; // day number 49 9 double L = 280.460 + 0.9856474 * n; // mean solar longitute (corr. for aberration) 50 10 double g = (357.528 + 0.9856003 * n)*RAD_DEG; // Mean anomaly … … 58 18 59 19 /* given RA, DEC, Time, calculate the parallax factor */ 60 // Time is relative to Tmean, Tmean is years relative toJ200061 int ParFactor (double *pR, double *pD, double RA, double DEC, double Time , double Tmean) {20 // Time is years since J2000 21 int ParFactor (double *pR, double *pD, double RA, double DEC, double Time) { 62 22 63 double jd,lambda, beta, epsilon, Radius;23 double lambda, beta, epsilon, Radius; 64 24 65 /* given a Time relative to Tmean, Tmean in years since J2000, determine the solar 66 longitude S */ 25 /* given a Time in years since J2000, determine the solar longitude S */ 67 26 68 // jd = ohana_sec_to_jd (365.25*86400.0*(Time + Tmean)); 69 jd = 365.25*(Time + Tmean) + J2000; 70 // fprintf (stderr, "Time: %f, jd: %f\n", Time, jd); 27 double jdoff = 365.25*Time; 71 28 72 sun_ecliptic (jd , &lambda, &beta, &epsilon, &Radius);29 sun_ecliptic (jdoff, &lambda, &beta, &epsilon, &Radius); 73 30 74 31 double lambda_rad = lambda*RAD_DEG; … … 99 56 return TRUE; 100 57 } 58 59 # if (0) 60 /* Low precision formulae for the sun, from Almanac p. C24 (1990) */ 61 /* ra and dec are returned as decimal hours and decimal degrees. */ 62 void lpsun (double jd, double *ra, double *dec) { 63 64 double n, L, g, lambda,epsilon,alpha,delta,x,y,z; 65 66 n = jd - J2000; 67 L = 280.460 + 0.9856474 * n; 68 g = (357.528 + 0.9856003 * n)/DEG_IN_RADIAN; 69 lambda = (L + 1.915 * sin(g) + 0.020 * sin(2. * g))/DEG_IN_RADIAN; 70 epsilon = (23.439 - 0.0000004 * n)/DEG_IN_RADIAN; 71 72 // this is the conversion from ecliptic to celestial coords 73 x = cos(lambda); 74 y = cos(epsilon)*sin(lambda); 75 z = sin(epsilon)*sin(lambda); 76 77 *ra = (atan_circ(x,y))*HRS_IN_RADIAN; 78 *dec = (asin(z))*DEG_IN_RADIAN; 79 } 80 81 /* code borrowed from Skycalc : fix this stuff XXX */ 82 /* Low precision formulae for the sun, from Almanac p. C24 (1990) */ 83 int sun_ecliptic (double jd, double *lambda, double *beta, double *epsilon) { 84 85 double n, L, g; 86 87 88 n = jd - J2000; 89 L = 280.460 + 0.9856474 * n; 90 g = (357.528 + 0.9856003 * n)*RAD_DEG; 91 *lambda = L + 1.915 * sin(g) + 0.020 * sin(2. * g); // longitude in degrees 92 *beta = 0.0; // approx latitude 93 *epsilon = (23.439 - 0.0000004 * n); // obliquity of ecliptic in degrees 94 return TRUE; 95 } 96 # endif 97 -
trunk/Ohana/src/relastro/src/Shutdown.c
r37038 r38986 21 21 va_end (argp); 22 22 23 SetProtect (TRUE);24 gfits_db_close (db);25 23 fprintf (stderr, "ERROR: relastro halted\n"); 26 24 exit (1); -
trunk/Ohana/src/relastro/src/StarMaps.c
r37807 r38986 163 163 } 164 164 165 if (VERBOSE2) fprintf (stderr, "max deviations for %s using %d pts : %f, %f\n", images[N].name, starmap[N].Npoints, dLmax, dMmax);165 if (VERBOSE2) fprintf (stderr, "max deviations for %s using %d pts (%d fitted) : %f, %f\n", images[N].name, starmap[N].Npoints, images[N].nFitAstrom, dLmax, dMmax); 166 166 167 167 if (dLmax > DPOS_MAX) { 168 if (VERBOSE) fprintf (stderr, "max deviations for %s using %d pts : %f, %f\n", images[N].name, starmap[N].Npoints, dLmax, dMmax);168 if (VERBOSE) fprintf (stderr, "max deviations for %s using %d pts (%d fitted) : %f, %f\n", images[N].name, starmap[N].Npoints, images[N].nFitAstrom, dLmax, dMmax); 169 169 return (FALSE); 170 170 } 171 171 if (dMmax > DPOS_MAX) { 172 if (VERBOSE) fprintf (stderr, "max deviations for %s using %d pts : %f, %f\n", images[N].name, starmap[N].Npoints, dLmax, dMmax);172 if (VERBOSE) fprintf (stderr, "max deviations for %s using %d pts (%d fitted) : %f, %f\n", images[N].name, starmap[N].Npoints, images[N].nFitAstrom, dLmax, dMmax); 173 173 return (FALSE); 174 174 } -
trunk/Ohana/src/relastro/src/UpdateChips.c
r38062 r38986 29 29 // update astrometry of all chips relative to the average positions 30 30 // if NTHREADS is non-zero, call the threaded version of this function 31 int UpdateChips (Catalog *catalog, int Ncatalog ) {31 int UpdateChips (Catalog *catalog, int Ncatalog, int Nloop) { 32 32 33 33 off_t Nskip, Nmosaic, NnewFit, NoldFit; … … 40 40 char *mode; 41 41 42 AstromErrorSetLoop (Nloop, TRUE); 43 42 44 if (NTHREADS) { 43 45 UpdateChips_threaded (catalog, Ncatalog); … … 57 59 // each chip is fitted independently, so we could do N at once in parallel 58 60 for (i = 0; i < Nimage; i++) { 61 62 VERBOSE_IMAGE = !strcmp(image[i].name, "o5745g0516o.356887.cm.982631.smf[XY54]"); 59 63 60 64 // XXX looks like everything below is thread safe : we can unroll this into a set of … … 91 95 } 92 96 97 if (VERBOSE_IMAGE) { 98 dump_stardata_pts (raw, Nraw, "testimage.raw.dat"); 99 dump_stardata_pts (ref, Nref, "testimage.ref.dat"); 100 fprintf (stderr, "dumped test image\n"); 101 } 102 93 103 // note that Nraw & Nref must be equal: if not, we made a programming error in one of these two functions. 94 104 assert (Nraw == Nref); … … 105 115 // fprintf (stderr, "image "OFF_T_FMT" : Nstars: "OFF_T_FMT"\n", i, Nraw); 106 116 if (!FitChip (raw, ref, Nraw, &image[i])) { 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);117 if (VERBOSE) fprintf (stderr, "reject fit for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT", Nused %d of %d\n", image[i].name, i, Nraw, image[i].nFitAstrom, image[i].nstar); 108 118 109 119 if (1) { … … 124 134 125 135 if (!checkStarMap (i)) { 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);136 if (VERBOSE) fprintf (stderr, "fit diverges too much for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT", Nused: %d\n", image[i].name, i, Nraw, image[i].nFitAstrom); 127 137 128 138 if (1) { … … 148 158 setImageRaw (catalog, Ncatalog, i, raw, Nraw, MODE_MOSAIC); 149 159 if (USE_GALAXY_MODEL) { 160 // XXX DEPRECATE? 150 161 image[i].flags |= ID_IMAGE_ASTROM_GMM; 151 162 } … … 311 322 // fprintf (stderr, "image "OFF_T_FMT" : Nstars: "OFF_T_FMT"\n", i, Nraw); 312 323 if (!FitChip (raw, ref, Nraw, &image[i])) { 313 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);324 if (VERBOSE) fprintf (stderr, "reject fit for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT", Nused %d of %d\n", image[i].name, i, Nraw, image[i].nFitAstrom, image[i].nstar); 314 325 315 326 // restore status quo ante (replace truMap with tmpMap) … … 328 339 329 340 if (!checkStarMap (i)) { 330 if (VERBOSE) fprintf (stderr, "fit diverges too much for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT" \n", image[i].name, i, Nraw);341 if (VERBOSE) fprintf (stderr, "fit diverges too much for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT", Nused: %d\n", image[i].name, i, Nraw, image[i].nFitAstrom); 331 342 332 343 // restore status quo ante (replace truMap with tmpMap) -
trunk/Ohana/src/relastro/src/UpdateObjectOffsets.c
r38471 r38986 97 97 } 98 98 99 # if ( 0)99 # if (1) 100 100 101 101 UpdateObjectOffsets_parallel_table (table, sky); … … 155 155 156 156 char *command = NULL; 157 strextend (&command, "relastro_client -update-offsets -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -minerror %f", 158 group->hosts[i][0].hostID, CATDIR, group->hosts[i][0].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, MIN_ERROR); 157 strextend (&command, "relastro_client -update-offsets"); 158 strextend (&command, "-hostID %d", group->hosts[i][0].hostID); 159 strextend (&command, "-D CATDIR %s", CATDIR); 160 strextend (&command, "-hostdir %s", group->hosts[i][0].pathname); 161 strextend (&command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 162 strextend (&command, "-statmode %s", STATMODE); 163 strextend (&command, "-minerror %f", MIN_ERROR); 159 164 160 165 if (FIT_MODE == FIT_PM_ONLY) strextend (&command, "-pm"); … … 176 181 if (ExcludeBogus) strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius); 177 182 183 if (USE_ALL_IMAGES) strextend (&command, "-use-all-images"); 178 184 if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1"); 179 185 … … 184 190 if (PhotFlagPoor) strextend (&command, "+photflagpoor %d", PhotFlagPoor); 185 191 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 192 193 if (N_BOOTSTRAP_SAMPLES > 1) strextend (&command, "-bootstrap-samples %d", N_BOOTSTRAP_SAMPLES); 186 194 187 195 if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) { … … 303 311 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 304 312 313 if (N_BOOTSTRAP_SAMPLES > 1) strextend (&command, "-bootstrap-samples %d", N_BOOTSTRAP_SAMPLES); 314 305 315 if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) { 306 316 strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG); -
trunk/Ohana/src/relastro/src/UpdateObjects.c
r37807 r38986 2 2 # define PAR_TOOFEW 5 3 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); 6 7 static off_t Nmax; 8 static double *X, *dX; 9 static double *Y, *dY; 10 static double *R, *dR; 11 static double *D, *dD; 12 static double *pX; 13 static double *pY; 14 static double *T; 15 static double *dT; 16 static double *C_blue; 17 static double *C_red; 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 41 void initObjectData (Catalog *catalog, int Ncatalog) { 42 43 off_t i, j; 44 45 Nmax = 0; 46 for (i = 0; i < Ncatalog; i++) { 47 for (j = 0; j < catalog[i].Naverage; j++) { 48 Nmax = MAX (Nmax, catalog[i].average[j].Nmeasure); 49 } 50 } 51 52 ALLOCATE (R, double, MAX (1, Nmax)); 53 ALLOCATE (D, double, MAX (1, Nmax)); 54 ALLOCATE (T, double, MAX (1, Nmax)); 55 ALLOCATE (X, double, MAX (1, Nmax)); 56 ALLOCATE (Y, double, MAX (1, Nmax)); 57 58 ALLOCATE (dR, double, MAX (1, Nmax)); 59 ALLOCATE (dD, double, MAX (1, Nmax)); 60 ALLOCATE (dT, double, MAX (1, Nmax)); 61 ALLOCATE (dX, double, MAX (1, Nmax)); 62 ALLOCATE (dY, double, MAX (1, Nmax)); 63 64 ALLOCATE (pX, double, MAX (1, Nmax)); 65 ALLOCATE (pY, double, MAX (1, Nmax)); 66 67 ALLOCATE (C_blue, double, MAX (1, Nmax)); 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"); 76 } 77 78 void freeObjectData () { 79 80 free (R); 81 free (D); 82 free (T); 83 free (X); 84 free (Y); 85 86 free (dR); 87 free (dD); 88 free (dT); 89 free (dX); 90 free (dY); 91 92 free (pX); 93 free (pY); 94 95 free (C_blue); 96 free (C_red); 97 } 4 int DumpObjectsWith2MASS (Catalog *catalog, int Ncatalog); 98 5 99 6 // This function operates on both Measure and MeasureTiny. In the big stages, this should 100 7 // be called with just MeasureTiny set and Measure == NULL 101 8 int UpdateObjects (Catalog *catalog, int Ncatalog, int Nloop) { 102 103 initObjectData (catalog, Ncatalog);104 9 105 10 // XXX in the future, use catalog[0].Nsecfilt only? allow catalogs to have variable Nsecfilt? … … 109 14 } 110 15 111 FitStats sumStatsChips; initFitStats (&sumStatsChips); 112 FitStats sumStatsStack; initFitStats (&sumStatsStack); 16 int NmeasureMax = CatalogMaxNmeasure (catalog, Ncatalog); 17 18 // allocate summary stats with Nmax = 0, Nboot = 0 19 FitStats *sumStatsChips = FitStatsInit (0, 0); 20 FitStats *sumStatsStack = FitStatsInit (0, 0); 21 22 FitStats *fitStatsChips = FitStatsInit (NmeasureMax, N_BOOTSTRAP_SAMPLES); 23 FitStats *fitStatsStack = FitStatsInit (NmeasureMax, N_BOOTSTRAP_SAMPLES); 24 25 AstromErrorSetLoop (Nloop, FALSE); 113 26 114 27 int i; … … 117 30 if (VERBOSE2) fprintf (stderr, "astrometrize catalog %d : "OFF_T_FMT" ave, "OFF_T_FMT" meas\n", i, catalog[i].Naverage, catalog[i].Nmeasure); 118 31 119 FitStats fitStatsChips; initFitStats (&fitStatsChips);120 FitStats fitStatsStack; initFitStats (&fitStatsStack);32 FitStatsReset (fitStatsChips); 33 FitStatsReset (fitStatsStack); 121 34 122 35 off_t j; … … 129 42 SecFilt *secfilt = &catalog[i].secfilt[j*Nsecfilt]; 130 43 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); 44 UpdateObjects_Stack(average, secfilt, measure, measureBig, Nsecfilt, fitStatsStack); 45 UpdateObjects_Chips(average, secfilt, measure, measureBig, Nsecfilt, fitStatsChips, i, m); 46 } 47 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); 48 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); 49 FitStatsSum (fitStatsChips, sumStatsChips); 50 FitStatsSum (fitStatsStack, sumStatsStack); 51 } 52 53 // DumpObjectsWith2MASS (catalog, Ncatalog); 54 55 FitStatsFree (fitStatsChips); 56 FitStatsFree (fitStatsStack); 57 58 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); 59 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); 60 61 FitStatsFree (sumStatsChips); 62 FitStatsFree (sumStatsStack); 63 143 64 return (TRUE); 144 65 } … … 146 67 // This function operates on both Measure and MeasureTiny. In the big stages, this should 147 68 // 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(); 69 int DumpObjectsWith2MASS (Catalog *catalog, int Ncatalog) { 70 71 int i; 72 for (i = 0; i < Ncatalog; i++) { 73 off_t j; 74 for (j = 0; j < catalog[i].Naverage; j++) { 75 /* calculate the average value of R,D for a single star */ 76 off_t m = catalog[i].average[j].measureOffset; 77 78 off_t k; 79 for (k = 0; k < catalog[i].average[j].Nmeasure; k++) { 80 MeasureTiny *measure = &catalog[i].measureT[m+k]; 81 if (measure->dbFlags & ID_MEAS_OBJECT_HAS_2MASS) { 82 fprintf (stderr, "0x%08x 0x%08x : %12.8f %12.8f %5d\n", catalog[i].average[j].objID, catalog[i].average[j].catID, measure->R, measure->D, measure->photcode); 83 } 84 } 85 } 86 } 87 return (TRUE); 88 } 89 90 // This function operates on both Measure and MeasureTiny. In the big stages, this should 91 // be called with just MeasureTiny set and Measure == NULL 92 int UpdateObjects_Chips (Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int Nsecfilt, FitStats *fitStats, int cat, off_t measOff) { 93 94 int k; 151 95 152 96 /* calculate the average value of R,D for a single star */ 153 97 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;98 FitAstromResult fitPos, fitPM, fitPar; 99 FitAstromResultInit (&fitPos); 100 FitAstromResultInit (&fitPM); 101 FitAstromResultInit (&fitPar); 158 102 159 103 // if we fail to fit the astrometry for some reason, we need to set/reset these … … 167 111 if (average[0].Nmeasure == 0) return TRUE; 168 112 169 int NcBlue = 0;170 int NcRed = 0;171 int N = 0;172 173 113 int mode = FIT_MODE; // start with the globally-defined fit mode 174 114 … … 177 117 XVERB |= (average[0].objID == OBJ_ID_DST) && (average[0].catID == CAT_ID_DST); 178 118 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; } 231 continue; 232 } 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++; 283 } 284 float colorRed = getColorRed (m+k, i); 285 if (!isnan(colorRed)) { 286 C_red[NcRed] = colorRed; 287 NcRed++; 288 } 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) { 119 // select the measurements to be used in this analysis 120 UpdateObjects_SelectMeasures (fitStats, average, secfilt, measure, measureBig, FALSE); 121 122 // if there are no exposure detections, use the stack position 123 if (fitStats->Npoints < 1) { 298 124 if (isfinite(average[0].Rstk) && isfinite(average[0].Dstk)) { 299 125 average[0].R = average[0].Rstk; … … 301 127 average[0].dR = average[0].dRstk; 302 128 average[0].dD = average[0].dDstk; 129 average[0].flags |= ID_STACK_ASTROM; 303 130 } 304 131 return FALSE; 305 132 } 306 133 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]; 134 double Tmean, Trange, parRange; 135 FitAstromPoints_Project (fitStats, &Tmean, &Trange, &parRange); 331 136 332 137 // to judge the quality of the PM and PAR fits, we need to fit all three models and compare Chisq 333 138 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 } 139 // if we have too few good detections for the desired fit, or too limited a baseline, 140 // use a fit with fewer parameters. 343 141 344 142 // *** first fit for the proper motion (skip fit if Trange or Npts is too small) *** … … 346 144 if (Trange < PM_DT_MIN) { 347 145 mode = FIT_AVERAGE; 348 goto skipPM;349 } 350 if ( N<= PM_TOOFEW) {146 goto justPosition; 147 } 148 if (fitStats->Npoints <= PM_TOOFEW) { 351 149 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); 150 goto justPosition; 151 } 152 153 if (fitStats->NfitAlloc == 1) { 154 // if N_BOOTSTRAP_SAMPLES = 1, no bootstrap resampling: 155 FitPM (&fitPM, fitStats->fitdataPM, fitStats->points, fitStats->Npoints); 156 } else { 157 fitStats->Nfit = 0; 158 for (k = 0; k < fitStats->NfitAlloc; k++) { 159 BootstrapResample (fitStats->sample, fitStats->points, fitStats->Npoints); 160 if (!FitPM (&fitStats->fit[k], fitStats->fitdataPM, fitStats->sample, fitStats->Npoints)) continue; 161 fitStats->Nfit ++; 162 } 163 BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA); 164 BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC); 165 BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_uR); 166 BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_uD); 167 } 168 FitAstromSetChisq (&fitPM, fitStats->points, fitStats->Npoints, FIT_PM_ONLY); 358 169 359 170 // 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); 171 XY_to_RD (&fitPM.Ro, &fitPM.Do, fitPM.Ro, fitPM.Do, &fitStats->coords); 362 172 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 173 365 174 fitPM.p = fitPM.dp = 0.0; … … 374 183 } 375 184 376 skipPM:377 185 // fit the parallax + proper-motion model 378 186 // NOTE : we only fit PAR if we have already fitted for proper motion. if we do not fit PM or we fail 379 187 // to fit PM, we do not attempt PAR. thus failure to fit PAR falls back to PM-only 380 188 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);403 404 189 if (parRange < PAR_FACTOR_MIN) { 405 190 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); 191 goto justPosition; 192 } 193 if (fitStats->Npoints <= PAR_TOOFEW) { 194 mode = FIT_PM_ONLY; 195 goto justPosition; 196 } 197 198 if (fitStats->NfitAlloc == 1) { 199 // if N_BOOTSTRAP_SAMPLES = 1, no bootstrap resampling: 200 FitPMandPar (&fitPar, fitStats->fitdataPar, fitStats->points, fitStats->Npoints); 201 } else { 202 fitStats->Nfit = 0; 203 for (k = 0; k < fitStats->NfitAlloc; k++) { 204 BootstrapResample (fitStats->sample, fitStats->points, fitStats->Npoints); 205 FitPMandPar (&fitStats->fit[k], fitStats->fitdataPar, fitStats->sample, fitStats->Npoints); 206 fitStats->Nfit ++; 207 } 208 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA); 209 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC); 210 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_uR); 211 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_uD); 212 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_PLX); 213 } 214 FitAstromSetChisq (&fitPar, fitStats->points, fitStats->Npoints, FIT_PM_AND_PAR); 215 216 // project Ro, Do back to RA,DEC 217 XY_to_RD (&fitPar.Ro, &fitPar.Do, fitPar.Ro, fitPar.Do, &fitStats->coords); 218 if (fabs(fitPar.Ro) < 0.01) fprintf (stderr, "watch out for 0,360 boundary\n"); 219 413 220 average[0].flags |= ID_STAR_FIT_PAR; 414 221 fitStats->Npar ++; 415 222 416 if (fabs(fitPM.Ro) < 0.01) fprintf (stderr, "watch out for 0,360 boundary\n");417 418 223 // XXX a hard-wired hack... 419 if ((fabs(fitP AR.uR) > 2.0) || (fabs(fitPAR.uD) > 2.0)) {224 if ((fabs(fitPar.uR) > 2.0) || (fabs(fitPar.uD) > 2.0)) { 420 225 mode = FIT_PM_ONLY; 421 226 } 422 227 } 423 228 424 skipPAR:229 justPosition: 425 230 { 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) 231 // use bootstrap resampling to check the error distribution 232 // if we only have one point, this is silly... 233 234 if (fitStats->NfitAlloc == 1) { 235 FitAstromResultSetPM (&fitPos, 1, average); 236 FitPosPMfixed (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints); 237 } else { 238 fitStats->Nfit = 0; 239 FitAstromResultSetPM (fitStats->fit, fitStats->NfitAlloc, average); 240 for (k = 0; k < fitStats->NfitAlloc; k++) { 241 BootstrapResample (fitStats->sample, fitStats->points, fitStats->Npoints); 242 FitPosPMfixed (&fitStats->fit[k], fitStats->fitdataPos, fitStats->sample, fitStats->Npoints); 243 fitStats->Nfit ++; 244 } 245 BootstrapRobustStats (&fitPos, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA); 246 BootstrapRobustStats (&fitPos, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC); 247 } 248 FitAstromSetChisq (&fitPos, fitStats->points, fitStats->Npoints, FIT_AVERAGE); 430 249 431 250 // 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; 251 XY_to_RD (&fitPos.Ro, &fitPos.Do, fitPos.Ro, fitPos.Do, &fitStats->coords); 444 252 average[0].flags |= ID_STAR_FIT_AVE; 445 253 fitStats->Nave ++; 446 254 } 447 255 256 // update the bit flags of which points were used 257 for (k = 0; k < fitStats->Npoints; k++) { 258 int Nm = fitStats->points[k].measure; 259 myAssert (Nm >= 0, "oops"); 260 measure[Nm].dbFlags |= ID_MEAS_USED_OBJ; 261 if (measureBig) { measureBig[Nm].dbFlags |= ID_MEAS_USED_OBJ; } 262 } 263 264 // we can set the star reference-image color only if we have loaded the image data 265 int setRefColor = areImagesMatched(); 448 266 if (setRefColor) { 267 float *C_blue = NULL; 268 float *C_red = NULL; 269 ALLOCATE (C_blue, float, fitStats->Npoints); 270 ALLOCATE (C_red, float, fitStats->Npoints); 271 272 int NcBlue = 0; 273 int NcRed = 0; 274 275 for (k = 0; k < fitStats->Npoints; k++) { 276 int Nm = fitStats->points[k].measure; 277 float colorBlue = getColorBlue (measOff + Nm, cat); 278 if (!isnan(colorBlue)) { 279 C_blue[NcBlue] = colorBlue; 280 NcBlue++; 281 } 282 float colorRed = getColorRed (measOff + Nm, cat); 283 if (!isnan(colorRed)) { 284 C_red[NcRed] = colorRed; 285 NcRed++; 286 } 287 } 288 289 // need to reassign here if isfinite() 449 290 float colorMedian; 450 dsort (C_blue, NcBlue);291 fsort (C_blue, NcBlue); 451 292 colorMedian = (NcBlue > 0) ? C_blue[(int)(0.5*NcBlue)] : NAN; 452 293 average[0].refColorBlue = colorMedian; 453 dsort (C_red, NcRed);294 fsort (C_red, NcRed); 454 295 colorMedian = (NcRed > 0) ? C_red[(int)(0.5*NcRed)] : NAN; 455 296 average[0].refColorRed = colorMedian; 297 298 free (C_blue); 299 free (C_red); 456 300 } 457 301 … … 459 303 // XXXX for now, just use the mode as the result: 460 304 int result = mode; 305 FitAstromResult fit; 306 FitAstromResultInit (&fit); 461 307 462 308 switch (result) { 463 309 case FIT_AVERAGE: 464 310 average[0].flags |= ID_STAR_USE_AVE; 465 fit = fit Ave;311 fit = fitPos; 466 312 break; 467 313 case FIT_PM_ONLY: … … 471 317 case FIT_PM_AND_PAR: 472 318 average[0].flags |= ID_STAR_USE_PAR; 473 fit = fitP AR;319 fit = fitPar; 474 320 break; 475 321 } … … 503 349 504 350 // 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)) {351 fitStats->coords.crval1 = average[0].R; 352 fitStats->coords.crval2 = average[0].D; 353 if (isnan(fitStats->coords.crval1)) { 508 354 return (FALSE); 509 355 } 510 if (isnan( coords.crval2)) {356 if (isnan(fitStats->coords.crval2)) { 511 357 return (FALSE); 512 358 } 513 359 514 360 double dXoff, dYoff; 515 RD_to_XY (&dXoff, &dYoff, fit.Ro, fit.Do, & coords);361 RD_to_XY (&dXoff, &dYoff, fit.Ro, fit.Do, &fitStats->coords); 516 362 float dPos = hypot (dXoff, dYoff); 517 363 if (dPos > MaxMeanOffset) { 518 364 if (fitStats->Noffset < 100) { 519 fprintf (stderr, "(%f,%f) -> (%f,%f) (%f,%f)\n", coords.crval1,coords.crval2, fit.Ro, fit.Do, dXoff, dYoff);365 fprintf (stderr, "(%f,%f) -> (%f,%f) (%f,%f)\n", fitStats->coords.crval1, fitStats->coords.crval2, fit.Ro, fit.Do, dXoff, dYoff); 520 366 } 521 367 fitStats->Noffset ++; … … 531 377 average[0].uR, 532 378 average[0].uD, 533 fit Ave.chisq, fitPM.chisq, fitPAR.chisq);379 fitPos.chisq, fitPM.chisq, fitPar.chisq); 534 380 535 381 average[0].R = fit.Ro; // RA in degrees … … 546 392 average[0].dP = fit.dp; // parallax error in arcsec 547 393 548 average[0].ChiSqAve = fit Ave.chisq;394 average[0].ChiSqAve = fitPos.chisq; 549 395 average[0].ChiSqPM = fitPM.chisq; 550 average[0].ChiSqPar = fitP AR.chisq;551 552 average[0].Tmean = (Tmean * 86400 * 365.25) + T2000;396 average[0].ChiSqPar = fitPar.chisq; 397 398 average[0].Tmean = (Tmean * 86400 * 365.25) + fitStats->T2000; 553 399 average[0].Trange = (Trange * 86400 * 365.25); 554 400 average[0].Npos = fit.Nfit; … … 563 409 // be called with just MeasureTiny set and Measure == NULL 564 410 int UpdateObjects_Stack (Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int Nsecfilt, FitStats *fitStats) { 565 566 off_t k;567 411 568 412 // set the default values … … 573 417 574 418 /* calculate the average value of R,D for a single star */ 575 PMFit fitAve; 576 memset (&fitAve, 0, sizeof(fitAve)); 577 fitAve.chisq = NAN; 419 FitAstromResult fitPos; 420 FitAstromResultInit (&fitPos); 578 421 579 422 if (average[0].Nmeasure == 0) return TRUE; 580 581 int N = 0;582 423 583 424 int XVERB = FALSE; … … 585 426 XVERB |= (average[0].objID == OBJ_ID_DST) && (average[0].catID == CAT_ID_DST); 586 427 428 // select the measurements to be used in this analysis 429 UpdateObjects_SelectMeasures (fitStats, average, secfilt, measure, measureBig, TRUE); 430 431 // too few measurements for average position (require 2 values) 432 if (fitStats->Npoints < 1) return FALSE; // XXX ?? 433 434 double Tmean, Trange, parRange; 435 FitAstromPoints_Project (fitStats, &Tmean, &Trange, &parRange); 436 437 FitPosPMfixed (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints); 438 FitAstromSetChisq (&fitPos, fitStats->points, fitStats->Npoints, FIT_AVERAGE); 439 440 // project Ro, Do back to RA,DEC 441 XY_to_RD (&fitPos.Ro, &fitPos.Do, fitPos.Ro, fitPos.Do, &fitStats->coords); 442 443 // XXX choose stack flag? average[0].flags |= ID_STAR_FIT_AVE; 444 fitStats->Nave ++; 445 446 if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f)\n", 447 average[0].R, 448 average[0].D, 449 fitPos.Ro, fitPos.Do, 450 3600*(average[0].R - fitPos.Ro), 451 3600*(average[0].D - fitPos.Do)); 452 453 // make sure that the fit succeeded 454 int status = TRUE; 455 status &= finite(fitPos.Ro); 456 status &= finite(fitPos.Do); 457 status &= finite(fitPos.dRo); 458 status &= finite(fitPos.dDo); 459 if (!status) { 460 fitStats->Nskip ++; 461 return FALSE; 462 } 463 464 // what is the offset relative to the mean fit position? 465 fitStats->coords.crval1 = average[0].R; 466 fitStats->coords.crval2 = average[0].D; 467 468 double dXoff, dYoff; 469 RD_to_XY (&dXoff, &dYoff, fitPos.Ro, fitPos.Do, &fitStats->coords); 470 float dPos = hypot (dXoff, dYoff); 471 if (dPos > MaxMeanOffset) { 472 if (fitStats->Noffset < 100) { 473 fprintf (stderr, "(%f,%f) -> (%f,%f) (%f,%f)\n", fitStats->coords.crval1, fitStats->coords.crval2, fitPos.Ro, fitPos.Do, dXoff, dYoff); 474 } 475 fitStats->Noffset ++; 476 return FALSE; 477 } 478 479 // set the stack position values 480 average[0].Rstk = fitPos.Ro; // RA in degrees 481 average[0].Dstk = fitPos.Do; // DEC in degrees 482 average[0].dRstk = fitPos.dRo; // RA scatter in arcsec 483 average[0].dDstk = fitPos.dDo; // DEC scatter in arcsec 484 485 return (TRUE); 486 } 487 488 int UpdateObjects_SelectMeasures (FitStats *fit, Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int isStack) { 489 490 // I've already allocated fit->points (and fit->sample) with space for fit->NpointsAlloc entries 491 492 int has2MASS = FALSE; 493 494 int Npoints = fit->Npoints = 0; 495 FitAstromPoint *points = fit->points; 496 497 int TESTPT2 = FALSE; 498 TESTPT2 |= CAT_ID_SRC && OBJ_ID_SRC && (average[0].catID == CAT_ID_SRC) && (average[0].objID == OBJ_ID_SRC); 499 TESTPT2 |= CAT_ID_DST && OBJ_ID_DST && (average[0].catID == CAT_ID_DST) && (average[0].objID == OBJ_ID_DST); 500 if (TESTPT2) { 501 fprintf (stderr, "got test det\n"); 502 } 503 587 504 // find the basic properties of the detections for this object (Tmin, Tmax, Tmean) 505 off_t k; 588 506 for (k = 0; k < average[0].Nmeasure; k++) { 589 507 590 if ( XVERB) {508 if (0) { 591 509 char *date = ohana_sec_to_date (measure[k].t); 592 510 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);511 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); 594 512 free (date); 595 513 } 596 514 597 // SKIP everything except gpc1 stack data 598 if (!isGPC1stack(measure[k].photcode)) continue; 599 515 // SKIP gpc1 forced-warp data 516 if (isGPC1warp(measure[k].photcode)) continue; 517 518 // SKIP gpc1 stack data 519 if (isStack) { 520 if (!isGPC1stack(measure[k].photcode)) continue; 521 } else { 522 if ( isGPC1stack(measure[k].photcode)) continue; 523 } 524 525 // reset the bit to note that a detection was used (or not) 526 measure[k].dbFlags &= ~ID_MEAS_USED_OBJ; 527 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; } 528 529 // does the measurement pass the supplied filtering constraints? 530 // MeasFilterTestTiny does not test psfQF 600 531 // exclude bad detections based on: photcodes, psfQF, time range, photflags & astromBadMask, mag_inst 601 532 int keepMeasure = measureBig ? MeasFilterTest(&measureBig[k], FALSE) : MeasFilterTestTiny(&measure[k], FALSE); … … 604 535 } 605 536 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); 537 double Ri = measure[k].R; 538 double Di = measure[k].D; 539 540 // mark (as POOR) any measurements which are deviant from the mean by > ExcludeBogusRadius 541 if (ExcludeBogus) { 542 fit->coords.crval1 = average[0].R; 543 fit->coords.crval2 = average[0].D; 544 double Xi, Yi; 545 RD_to_XY (&Xi, &Yi, Ri, Di, &fit->coords); 546 double radius = hypot(Xi, Yi); 547 if (radius > ExcludeBogusRadius) { 548 measure[k].dbFlags |= ID_MEAS_POOR_ASTROM; 549 if (measureBig) { measureBig[k].dbFlags |= ID_MEAS_POOR_ASTROM; } 550 continue; 551 } 552 measure[k].dbFlags &= ~ID_MEAS_POOR_ASTROM; 553 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_POOR_ASTROM; } 554 } 555 556 // outlier rejection 557 if (FALSE && FlagOutlier && (measure[k].dbFlags & ID_MEAS_POOR_ASTROM)) { 558 continue; 559 } 560 561 FitAstromPointInit (&points[Npoints]); 562 563 points[Npoints].R = Ri; 564 points[Npoints].D = Di; 565 566 // measure[k].t is UNIX seconds, T2000 is UNIX seconds for J2000. 567 // T[] is time in years since J2000 (jd = 2451545) 568 points[Npoints].T = (measure[k].t - fit->T2000) / (86400*365.25) ; // time relative to J2000 in years 569 570 // add measured systematic error in quadrature? only do this after the fit has 571 // converged (or you will never improve the poor images) 572 573 // dX,dY are the X and Y direction errors in arcseconds. dR, dD are the errors in 574 // those directions in degrees. IF we have non-circular errors (different values for 575 // X and Y), then dR and dD will be incorrect: they would need to be rotated to take 576 // out the position angle 577 578 // dX, dY : error in arcsec: 579 points[Npoints].dX = GetAstromErrorTiny (&measure[k], ERROR_MODE_RA); 580 points[Npoints].dY = GetAstromErrorTiny (&measure[k], ERROR_MODE_DEC); 612 581 613 582 // allow a given photcode or measurement to be 614 583 // 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++; 584 if (isnan(points[Npoints].dX)) continue; 585 if (isnan(points[Npoints].dY)) continue; 586 587 points[Npoints].dT = measure[k].dt; 588 589 points[Npoints].measure = k; 590 Npoints++; 591 592 if ((measure[k].photcode >= 2011) && (measure[k].photcode <= 2013)) { 593 has2MASS = TRUE; 594 } 595 596 myAssert (Npoints <= fit->NpointsAlloc, "oops"); 630 597 } // loop over measurements : average[0].Nmeasure 631 598 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 599 int TESTPT = FALSE; 600 TESTPT |= CAT_ID_SRC && OBJ_ID_SRC && (average[0].catID == CAT_ID_SRC) && (average[0].objID == OBJ_ID_SRC); 601 TESTPT |= CAT_ID_DST && OBJ_ID_DST && (average[0].catID == CAT_ID_DST) && (average[0].objID == OBJ_ID_DST); 602 if (TESTPT) { 603 fprintf (stderr, "got test det\n"); 604 } 605 606 // XXX flag measurements from stars with 2MASS 607 for (k = 0; k < average[0].Nmeasure; k++) { 608 // reset the bit to note that a detection was used (or not) 609 if (has2MASS) { 610 measure[k].dbFlags |= ID_MEAS_OBJECT_HAS_2MASS; 611 } else { 612 measure[k].dbFlags &= ~ID_MEAS_OBJECT_HAS_2MASS; 613 } 614 } 615 616 fit->Npoints = Npoints; 617 return TRUE; 618 } 619 620 int FitAstromPoints_Project (FitStats *fitStats, double *Tmean, double *Trange, double *parRange) { 621 622 int k; 623 624 int Npoints = fitStats->Npoints; 625 FitAstromPoint *points = fitStats->points; 626 627 // find Tmin & Tmax from the list of accepted measurements 628 double Tmin = points[0].T; 629 double Tmax = points[0].T; 630 double pRmin = +2.0; 631 double pRmax = -2.0; 632 double pDmin = +2.0; 633 double pDmax = -2.0; 634 635 *Tmean = 0.0; 636 637 double Tsum = 0.0; 638 double Wsum = 0.0; 639 for (k = 0; k < Npoints; k++) { 640 Tmin = MIN(Tmin, points[k].T); 641 Tmax = MAX(Tmax, points[k].T); 642 643 float wx = 1.0 / SQ(points[k].dX); 644 645 Tsum += points[k].T * wx; 646 Wsum += wx; 647 648 // at this point, T is in years since J2000 649 ParFactor (&points[k].pR, &points[k].pD, points[k].R, points[k].D, points[k].T); 650 pRmin = MIN (pRmin, points[k].pR); 651 pRmax = MAX (pRmax, points[k].pR); 652 pDmin = MIN (pDmin, points[k].pD); 653 pDmax = MAX (pDmax, points[k].pD); 654 } 655 *Trange = Tmax - Tmin; 656 657 // mean epoch 658 *Tmean = Tsum / Wsum; 659 660 // for HIGH_SPEED, just use the center of the range 661 if (RELASTRO_OP == OP_HIGH_SPEED) { 662 *Tmean = 0.5*(Tmax - Tmin); 663 } 664 665 *parRange = hypot (pRmax - pRmin, pDmax - pDmin); 666 667 /* we need to do the fit in a locally linear space; choose a ref coordinate */ 668 fitStats->coords.crval1 = points[0].R; 669 fitStats->coords.crval2 = points[0].D; 670 671 // project all of the R,D coordinates to a plane centered on this coordinate. set 672 // the times to be relative to Tmean 673 for (k = 0; k < Npoints; k++) { 674 RD_to_XY (&points[k].X, &points[k].Y, points[k].R, points[k].D, &fitStats->coords); 675 points[k].T -= *Tmean; 676 } 677 return TRUE; 678 } 679 680 int CatalogMaxNmeasure (Catalog *catalog, int Ncatalog) { 681 682 int i, j; 683 684 int Nmax = 0; 685 for (i = 0; i < Ncatalog; i++) { 686 for (j = 0; j < catalog[i].Naverage; j++) { 687 Nmax = MAX (Nmax, catalog[i].average[j].Nmeasure); 688 } 689 } 690 return Nmax; 691 } 692 693 int BootstrapResample (FitAstromPoint *sample, FitAstromPoint *points, int Npoints) { 694 int i; 695 696 // I need to draw Npoints random entries from 'points' with replacement: 697 for (i = 0; i < Npoints; i++) { 698 int N = Npoints * drand48(); 699 sample[i] = points[N]; 700 } 701 return TRUE; 702 } 703 704 // calculate mean and sigma points for the 5 fit parameter 705 int BootstrapRobustStats (FitAstromResult *result, FitAstromResult *fit, int Nfit, int mode) { 706 707 // generate a histogram for the selected element 708 double *values = NULL; 709 ALLOCATE (values, double, Nfit); 710 711 int i; 712 713 for (i = 0; i < Nfit; i++) { 714 switch (mode) { 715 case FIT_RESULT_RA: 716 values[i] = fit[i].Ro; 717 break; 718 case FIT_RESULT_DEC: 719 values[i] = fit[i].Do; 720 break; 721 case FIT_RESULT_uR: 722 values[i] = fit[i].uR; 723 break; 724 case FIT_RESULT_uD: 725 values[i] = fit[i].uD; 726 break; 727 case FIT_RESULT_PLX: 728 values[i] = fit[i].p; 729 break; 730 default: 731 myAbort ("invalid option"); 732 } 733 } 734 735 dsort (values, Nfit); 736 737 double median; 738 if (Nfit % 2) { 739 int Ncenter = Nfit / 2; 740 median = values[Ncenter]; 741 } else { 742 int Ncenter = Nfit / 2 - 1; 743 median = 0.5*(values[Ncenter] + values[Ncenter + 1]); 744 } 745 746 double Slo = VectorFractionInterpolate (values, 0.158655, Nfit); 747 double Shi = VectorFractionInterpolate (values, 0.841345, Nfit); 748 double sigma = (Shi - Slo) / 2.0; 749 750 switch (mode) { 751 case FIT_RESULT_RA: 752 result->Ro = median; 753 result->dRo = sigma; 754 break; 755 case FIT_RESULT_DEC: 756 result->Do = median; 757 result->dDo = sigma; 758 break; 759 case FIT_RESULT_uR: 760 result->uR = median; 761 result->duR = sigma; 762 break; 763 case FIT_RESULT_uD: 764 result->uD = median; 765 result->duD = sigma; 766 break; 767 case FIT_RESULT_PLX: 768 result->p = median; 769 result->dp = sigma; 770 break; 771 default: 772 myAbort ("invalid option"); 773 } 774 775 return TRUE; 776 } 777 778 double VectorFractionInterpolate (double *values, float fraction, int Npts) { 779 780 float F = fraction * Npts; 781 int N = fraction * Npts; 782 783 if (N < 0 ) return NAN; 784 if (N >= Npts - 2) return NAN; 785 786 // interpolate between N,N+1 787 788 double S = (F - N) * (values[N+1] - values[N]) + values[N]; 789 return S; 790 } 791 792 int FitAstromSetChisq (FitAstromResult *fit, FitAstromPoint *points, int Npoints, FitMode mode) { 793 794 int i; 795 796 // add up the chi square for the fit 797 double chisq = 0.0; 798 for (i = 0; i < Npoints; i++) { 799 double Xf = fit->Ro + fit->uR*points[i].T + fit->p*points[i].pR; 800 double Yf = fit->Do + fit->uD*points[i].T + fit->p*points[i].pD; 801 chisq += SQ(points[i].X - Xf) / SQ(points[i].dX); 802 chisq += SQ(points[i].Y - Yf) / SQ(points[i].dY); 803 } 804 switch (mode) { 805 case FIT_AVERAGE: 806 fit->chisq = chisq / (2.0*Npoints - 2.0); 807 break; 808 case FIT_PM_ONLY: 809 fit->chisq = chisq / (2.0*Npoints - 4.0); 810 break; 811 case FIT_PM_AND_PAR: 812 fit->chisq = chisq / (2.0*Npoints - 5.0); 813 break; 814 default: 815 myAbort ("invalid mode"); 816 } 817 fit->Nfit = Npoints; 695 818 return (TRUE); 696 819 } 697 820 698 699 700 /* fitting proper-motion and parallax: 701 702 given a source at position r,d, at a time t, we need to calculate a vector (pr,pd) 703 704 let x,y be the coordinate in the linearized frame with y parallel to DEC lines 705 706 L,B are the ecliptic longitude and latitude of the object, 707 dL and dB are the offsets in the L and B directions 708 709 dL = sin(t - topp) 710 dB = cos(t - topp)*sin(B) 711 712 these need to be rotated to the R,D frame to yield pR,pD. Then, the equation of motion 713 for the source in the x,y frame is: 714 715 x = Ro + uR * (t - to) + p * pR 716 y = Do + uD * (t - to) + p * pD 717 718 the unknowns in these equations are Ro, uR, Do, uD, and p 719 720 XXX think through the concepts for the pole a bit better. all objects near the pole 721 move the same way with the same phase. choose a projection center and define dL,dB relative 722 to that center point coordinate system? 723 724 */ 821 int FitAstromResultSetPM (FitAstromResult *fit, int Nfit, Average *average) { 822 823 int i; 824 825 if (USE_GALAXY_MODEL) { 826 for (i = 0; i < Nfit; i++) { 827 fit->uR = average->uRgal; 828 fit->uD = average->uDgal; 829 } 830 } else { 831 for (i = 0; i < Nfit; i++) { 832 fit->uR = 0.0; 833 fit->uD = 0.0; 834 } 835 } 836 837 return TRUE; 838 } -
trunk/Ohana/src/relastro/src/args.c
r38441 r38986 253 253 } 254 254 255 // If we are looking at the whole sky (or whole relevant sky), use the full image table 256 // -- this save substantial memory. this could be automatic if the skyregion covers 257 // more than 2pi. 258 USE_ALL_IMAGES = FALSE; 259 if ((N = get_argument (argc, argv, "-use-all-images"))) { 260 remove_argument (N, &argc, argv); 261 USE_ALL_IMAGES = TRUE; 262 } 263 255 264 USE_BASIC_CHECK = FALSE; 256 265 if ((N = get_argument (argc, argv, "-basic-image-search"))) { … … 271 280 remove_argument (N, &argc, argv); 272 281 APPLY_OFFSETS = TRUE; 282 } 283 284 N_BOOTSTRAP_SAMPLES = 1; 285 if ((N = get_argument (argc, argv, "-bootstrap-samples"))) { 286 remove_argument (N, &argc, argv); 287 N_BOOTSTRAP_SAMPLES = atoi (argv[N]); 288 remove_argument (N, &argc, argv); 289 if ((N_BOOTSTRAP_SAMPLES < 1) || ((N_BOOTSTRAP_SAMPLES > 1) && (N_BOOTSTRAP_SAMPLES < 20))) { 290 fprintf (stderr, "-bootstrap-samples must be either 1 (no sampling) or >= 20\n"); 291 exit (2); 292 } 273 293 } 274 294 … … 685 705 } 686 706 707 // If we are looking at the whole sky (or whole relevant sky), use the full image table 708 // -- this save substantial memory. this could be automatic if the skyregion covers 709 // more than 2pi. 710 USE_ALL_IMAGES = FALSE; 711 if ((N = get_argument (argc, argv, "-use-all-images"))) { 712 remove_argument (N, &argc, argv); 713 USE_ALL_IMAGES = TRUE; 714 } 715 687 716 USE_BASIC_CHECK = FALSE; 688 717 if ((N = get_argument (argc, argv, "-basic-image-search"))) { … … 697 726 remove_argument (N, &argc, argv); 698 727 MaxDensityUse = TRUE; 728 } 729 730 N_BOOTSTRAP_SAMPLES = 1; 731 if ((N = get_argument (argc, argv, "-bootstrap-samples"))) { 732 remove_argument (N, &argc, argv); 733 N_BOOTSTRAP_SAMPLES = atoi (argv[N]); 734 remove_argument (N, &argc, argv); 735 if ((N_BOOTSTRAP_SAMPLES < 1) || ((N_BOOTSTRAP_SAMPLES > 1) && (N_BOOTSTRAP_SAMPLES < 20))) { 736 fprintf (stderr, "-bootstrap-samples must be either 1 (no sampling) or >= 20\n"); 737 exit (2); 738 } 699 739 } 700 740 -
trunk/Ohana/src/relastro/src/assign_images.c
r38441 r38986 26 26 char mapfile[DVO_MAX_PATH]; 27 27 snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR); 28 AstromOffsetTable *table = AstromOffsetMapLoad (mapfile, VERBOSE);28 AstromOffsetTable *table = AstromOffsetMapLoad (mapfile, 100000, VERBOSE); 29 29 30 30 // assign images.coords.offsetMap -> table->map[i] -
trunk/Ohana/src/relastro/src/bcatalog.c
r38441 r38986 112 112 113 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; 114 if (USE_GALAXY_MODEL) { 115 // if we use the galaxy model, we need to require the model pm to exist 116 if (!catalog[0].average[i].Nstarpar) continue; 117 if (!isfinite(catalog[0].average[i].uRgal)) continue; 118 if (!isfinite(catalog[0].average[i].uDgal)) continue; 119 } 120 121 int TESTPT = FALSE; 122 TESTPT |= CAT_ID_SRC && OBJ_ID_SRC && (catalog[0].average[i].catID == CAT_ID_SRC) && (catalog[0].average[i].objID == OBJ_ID_SRC); 123 TESTPT |= CAT_ID_DST && OBJ_ID_DST && (catalog[0].average[i].catID == CAT_ID_DST) && (catalog[0].average[i].objID == OBJ_ID_DST); 124 if (TESTPT) { 125 fprintf (stderr, "got test det\n"); 117 126 } 118 127 -
trunk/Ohana/src/relastro/src/high_speed_catalogs.c
r38471 r38986 153 153 PHOTCODE_A_LIST, PHOTCODE_B_LIST, RADIUS, outputDir, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 154 154 155 strextend (&command, "relastro_client -high-speed %s %s %f %s", PHOTCODE_A_LIST, PHOTCODE_B_LIST, RADIUS, outputDir); 156 strextend (&command, "-hostID %d", table->hosts[i].hostID); 157 strextend (&command, "-D CATDIR %s", CATDIR); 158 strextend (&command, "-hostdir %s", table->hosts[i].pathname); 159 strextend (&command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 160 155 161 free (outputDir); 156 162 … … 166 172 if (MaxDensityUse) { strextend (&command, "-max-density %f", MaxDensityValue); } 167 173 174 if (USE_ALL_IMAGES) { strextend (&command, "-use-all-images"); } 168 175 if (USE_BASIC_CHECK) { strextend (&command, "-basic-image-search"); } 169 176 if (FlagOutlier) { strextend (&command, "-clip %d", CLIP_THRESH); } … … 176 183 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 177 184 178 if (MinBadQF > 0.0) { strextend (&command, "-min-bad-psfqf %f", MinBadQF); } 179 if (MaxMeanOffset != 10.0) { strextend (&command, "-max-mean-offset %f", MaxMeanOffset); } 185 if (MinBadQF > 0.0) strextend (&command, "-min-bad-psfqf %f", MinBadQF); 186 if (MaxMeanOffset != 10.0) strextend (&command, "-max-mean-offset %f", MaxMeanOffset); 187 if (N_BOOTSTRAP_SAMPLES > 1) strextend (&command, "-bootstrap-samples %d", N_BOOTSTRAP_SAMPLES); 180 188 181 189 if (WHERE_A[0]) { strextend (&command, "-D WHERE_A \"%s\"", WHERE_A); } -
trunk/Ohana/src/relastro/src/high_speed_objects.c
r38441 r38986 270 270 271 271 fprintf (stderr, "found %d matches\n", Nmatch); 272 dvo_catalog_save (&catalogOut, VERBOSE2); 273 dvo_catalog_unlock (&catalogOut); 272 273 SetProtect (TRUE); 274 if (!dvo_catalog_save (&catalogOut, VERBOSE2)) { fprintf (stderr, "ERROR: failed to save %s\n", catalogOut.filename); exit (1); } 275 if (!dvo_catalog_unlock (&catalogOut)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalogOut.filename); exit (1); } 276 SetProtect (FALSE); 277 274 278 dvo_catalog_free (&catalogOut); 275 279 free (slowMoving); -
trunk/Ohana/src/relastro/src/hpm_catalogs.c
r38471 r38986 148 148 149 149 char *command = NULL; 150 strextend (&command, "relastro_client -hpm %f %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f", 151 RADIUS, outputDir, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 150 strextend (&command, "relastro_client -hpm %f %s", RADIUS, outputDir); 151 strextend (&command, " -hostID %d", table->hosts[i].hostID); 152 strextend (&command, " -D CATDIR %s", CATDIR); 153 strextend (&command, " -hostdir %s", table->hosts[i].pathname); 154 strextend (&command, " -region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 152 155 153 156 free (outputDir); … … 164 167 if (MaxDensityUse) { strextend (&command, "-max-density %f", MaxDensityValue); } 165 168 169 if (USE_ALL_IMAGES) { strextend (&command, "-use-all-images"); } 166 170 if (USE_BASIC_CHECK) { strextend (&command, "-basic-image-search"); } 167 171 if (FlagOutlier) { strextend (&command, "-clip %d", CLIP_THRESH); } … … 174 178 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 175 179 176 if (MinBadQF > 0.0) { strextend (&command, "-min-bad-psfqf %f", MinBadQF); } 177 if (MaxMeanOffset != 10.0) { strextend (&command, "-max-mean-offset %f", MaxMeanOffset); } 180 if (MinBadQF > 0.0) strextend (&command, "-min-bad-psfqf %f", MinBadQF); 181 if (MaxMeanOffset != 10.0) strextend (&command, "-max-mean-offset %f", MaxMeanOffset); 182 if (N_BOOTSTRAP_SAMPLES > 1) strextend (&command, "-bootstrap-samples %d", N_BOOTSTRAP_SAMPLES); 178 183 179 184 if (TimeSelect) { -
trunk/Ohana/src/relastro/src/hpm_objects.c
r38441 r38986 110 110 if (catalog[0].Naverage == Nslow) { 111 111 fprintf (stderr, "no possible fast objects, skipping this catalog\n"); 112 dvo_catalog_save (&catalogOut, VERBOSE2); 113 dvo_catalog_unlock (&catalogOut); 112 113 SetProtect (TRUE); 114 if (!dvo_catalog_save (&catalogOut, VERBOSE2)) { fprintf (stderr, "ERROR: failed to save %s\n", catalogOut.filename); exit (1); } 115 if (!dvo_catalog_unlock (&catalogOut)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalogOut.filename); exit (1); } 116 SetProtect (FALSE); 117 114 118 dvo_catalog_free (&catalogOut); 115 119 free (slowMoving); -
trunk/Ohana/src/relastro/src/launch_region_hosts.c
r38441 r38986 6 6 int i; 7 7 8 // do not remo te the sync and fits files if we do a manual run -- user must clear if needed8 // do not remove the sync and fits files if we do a manual run -- user must clear if needed 9 9 if (!PARALLEL_REGIONS_MANUAL) { 10 10 // clear the I/O files -
trunk/Ohana/src/relastro/src/load_catalogs.c
r38471 r38986 163 163 164 164 char *command = NULL; 165 strextend (&command, "relastro_client -load-objects %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -minerror %f -D RELASTRO_SIGMA_LIM %f", 166 table->hosts[i].results, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, MIN_ERROR, SIGMA_LIM); 165 strextend (&command, "relastro_client -load-objects %s", table->hosts[i].results); 166 strextend (&command, " -hostID %d", table->hosts[i].hostID); 167 strextend (&command, " -D CATDIR %s", CATDIR); 168 strextend (&command, " -hostdir %s", table->hosts[i].pathname); 169 strextend (&command, " -region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 170 strextend (&command, " -statmode %s", STATMODE); 171 strextend (&command, " -minerror %f", MIN_ERROR); 172 strextend (&command, " -D RELASTRO_SIGMA_LIM %f", SIGMA_LIM); 167 173 168 174 if (FIT_MODE == FIT_PM_ONLY) strextend (&command, "-pm"); … … 188 194 } 189 195 196 if (USE_ALL_IMAGES) strextend (&command, "-use-all-images"); 190 197 if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1"); 191 198 if (PHOTCODE_KEEP_LIST) strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST); -
trunk/Ohana/src/relastro/src/load_images.c
r38441 r38986 7 7 */ 8 8 9 int load_images (FITS_DB *db, SkyList *skylist, int UseFullOverlap ) {9 int load_images (FITS_DB *db, SkyList *skylist, int UseFullOverlap, int UseAllImages) { 10 10 11 11 Image *image, *subset; 12 12 off_t Nimage, Nsubset; 13 off_t *LineNumber ;13 off_t *LineNumber, i; 14 14 15 15 INITTIME; … … 29 29 char mapfile[DVO_MAX_PATH]; 30 30 snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR); 31 table = AstromOffsetMapLoad (mapfile, VERBOSE);31 table = AstromOffsetMapLoad (mapfile, 100000, VERBOSE); 32 32 33 33 // assign images.coords.offsetMap -> table->map[i] … … 39 39 40 40 // select the images which overlap the selected sky regions 41 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset, UseFullOverlap); 42 MARKTIME(" select images: %f sec\n", dtime); 41 if (UseAllImages) { 42 ALLOCATE (LineNumber, off_t, Nimage); 43 for (i = 0; i < Nimage; i++) LineNumber[i] = i; 44 subset = image; 45 Nsubset = Nimage; 46 } else { 47 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset, UseFullOverlap); 48 MARKTIME(" select images: %f sec\n", dtime); 43 49 44 if (Nsubset == Nimage) { 45 free (subset); 46 subset = image; 50 if (Nsubset == Nimage) { 51 free (subset); 52 subset = image; 53 } 47 54 } 48 55 49 56 initImages (subset, LineNumber, Nsubset); 50 57 MARKTIME(" init images: %f sec\n", dtime); 51 58 52 59 initMosaics (subset, Nsubset); 53 60 MARKTIME(" init mosaics: %f sec\n", dtime); -
trunk/Ohana/src/relastro/src/relastro.c
r36630 r38986 4 4 5 5 /* get configuration info, args */ 6 SetSignals (); 6 7 initialize (argc, argv); 7 8 -
trunk/Ohana/src/relastro/src/relastro_client.c
r38441 r38986 22 22 23 23 // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, etc) 24 SetSignals (); 24 25 initialize_client (argc, argv); 25 26 … … 78 79 79 80 /* load regions and images based on specified sky patch (default depth) */ 80 load_images (&db, skylist, FALSE );81 load_images (&db, skylist, FALSE, USE_ALL_IMAGES); 81 82 82 83 // I can free the database after I have loaded the images... -
trunk/Ohana/src/relastro/src/relastro_images.c
r38441 r38986 21 21 22 22 /* load regions and images based on specified sky patch (default depth) (require full overlap) */ 23 load_images (&db, skylist, TRUE );23 load_images (&db, skylist, TRUE, USE_ALL_IMAGES); 24 24 MARKTIME("load images: %f sec\n", dtime); 25 25 … … 73 73 if (RESET_IMAGES) UpdateMeasures (catalog, Ncatalog); 74 74 for (i = 0; i < NLOOP; i++) { 75 UpdateObjects (catalog, Ncatalog, (i > 0)); // calculate <R>,<D>; if (i > 0), apply Galaxy Motion Model (if desired) 76 if ((i > 1) || !USE_GALAXY_MODEL) { 77 // if GALAXY_MODEL is selected, we want to delay the frame correction until we have 78 // applied the galaxy model a couple of times. 79 FrameCorrectionSerial (catalog, Ncatalog); 80 } 81 UpdateChips (catalog, Ncatalog); // measure.X,Y -> R,D, fit image.coords 75 UpdateObjects (catalog, Ncatalog, i); // calculate <R>,<D>; if (i > 0), apply Galaxy Motion Model (if desired) 76 UpdateChips (catalog, Ncatalog, i); // measure.X,Y -> R,D, fit image.coords 82 77 MARKTIME("update chips: %f sec\n", dtime); 83 78 } … … 103 98 freeImageBins (1); 104 99 105 // XXX why do I do this exactly? 106 reload_images (&db); 100 // If we did NOT use all images, then we applied the measured corrections to a subset of 101 // images. we now need to set the images associated with db to have those values so 102 // they will be written out by the dvo_image_update() operations. If we USE_ALL_IMAGES, 103 // then we do not need to do this, and we should call dvo_image_save (not dvo_image_update) 104 if (!USE_ALL_IMAGES) { 105 reload_images (&db); 106 } 107 107 108 108 if (PARALLEL) { … … 110 110 // need to also save the image map table... 111 111 save_astrom_table (); 112 dvo_image_update (&db, VERBOSE); 112 if (USE_ALL_IMAGES) { 113 dvo_image_save (&db, VERBOSE); 114 } else { 115 dvo_image_update (&db, VERBOSE); 116 } 113 117 dvo_image_unlock (&db); 114 118 } 115 119 120 // NOTE: if we have parallel partitions, then we need to save the Images.dat and 121 // AstroMap.fits tables BEFORE the remote relastro_clients are launched (they load 122 // Images.dat and AstroMap.fits) 123 124 // if we do NOT have parallel partitions, we must NOT write them out yet: the act of 125 // writing out the files byte-swaps the data and makes the values invalide for the 126 // following calls to UpdateObjectOffsets (which attempt to apply the image values from 127 // the structure in memory) 128 116 129 // iterate over catalogs to make detection coordinates consistant 117 UpdateObjectOffsets (skylist, 0, NULL); 130 if (APPLY_OFFSETS) { 131 UpdateObjectOffsets (skylist, 0, NULL); 132 } 118 133 119 134 if (!PARALLEL) { 120 135 // save the updated image parameters 121 136 save_astrom_table (); 122 dvo_image_update (&db, VERBOSE); 137 if (USE_ALL_IMAGES) { 138 dvo_image_save (&db, VERBOSE); 139 } else { 140 dvo_image_update (&db, VERBOSE); 141 } 123 142 dvo_image_unlock (&db); 124 143 } -
trunk/Ohana/src/relastro/src/relastro_merge_source.c
r38441 r38986 122 122 resort_catalog (&catalog_src); 123 123 124 dvo_catalog_save (&catalog_src, VERBOSE2); 125 dvo_catalog_unlock (&catalog_src); 124 SetProtect (TRUE); 125 if (!dvo_catalog_save (&catalog_src, VERBOSE2)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog_src.filename); exit (1); } 126 if (!dvo_catalog_unlock (&catalog_src)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog_src.filename); exit (1); } 127 SetProtect (FALSE); 126 128 dvo_catalog_free (&catalog_src); 127 129 -
trunk/Ohana/src/relastro/src/relastro_objects.c
r38471 r38986 150 150 151 151 char *command = NULL; 152 strextend (&command, "relastro_client -update-objects -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s", 153 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE); 152 strextend (&command, "relastro_client -update-objects"); 153 strextend (&command, "-hostID %d", table->hosts[i].hostID); 154 strextend (&command, "-D CATDIR %s", CATDIR); 155 strextend (&command, "-hostdir %s", table->hosts[i].pathname); 156 strextend (&command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 157 strextend (&command, "-statmode %s", STATMODE); 154 158 155 159 if (FIT_MODE == FIT_PM_ONLY) { strextend (&command, "-pm"); } … … 164 168 if (MaxDensityUse) { strextend (&command, "-max-density %f", MaxDensityValue); } 165 169 if (FlagOutlier) { strextend (&command, "-clip %d", CLIP_THRESH); } 170 171 if (USE_ALL_IMAGES) { strextend (&command, "-use-all-images"); } 166 172 if (USE_FIXED_PIXCOORDS) { strextend (&command, "-D USE_FIXED_PIXCOORDS 1"); } 167 173 if (PHOTCODE_KEEP_LIST) { strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST); } … … 172 178 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 173 179 174 if (MinBadQF > 0.0) { strextend (&command, "-min-bad-psfqf %f", MinBadQF); } 175 if (MaxMeanOffset != 10.0) { strextend (&command, "-max-mean-offset %f", MaxMeanOffset); } 180 if (MinBadQF > 0.0) strextend (&command, "-min-bad-psfqf %f", MinBadQF); 181 if (MaxMeanOffset != 10.0) strextend (&command, "-max-mean-offset %f", MaxMeanOffset); 182 if (N_BOOTSTRAP_SAMPLES > 1) strextend (&command, "-bootstrap-samples %d", N_BOOTSTRAP_SAMPLES); 176 183 177 184 if (TimeSelect) { -
trunk/Ohana/src/relastro/src/relastro_parallel_images.c
r38062 r38986 40 40 char mapfile[DVO_MAX_PATH]; 41 41 snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.%d.fits", CATDIR, REGION_HOST_ID); 42 AstromOffsetTable *table = AstromOffsetMapLoad (mapfile, VERBOSE);42 AstromOffsetTable *table = AstromOffsetMapLoad (mapfile, 100000, VERBOSE); 43 43 44 44 // assign images.coords.offsetMap -> table->map[i] … … 120 120 } 121 121 for (i = 0; i < NLOOP; i++) { 122 UpdateObjects (catalog, Ncatalog, (i > 0));122 UpdateObjects (catalog, Ncatalog, i); 123 123 LOGRTIME("UpdateObjects loop %d on %s, host %d: %f sec\n", i, myHostName, REGION_HOST_ID, dtime); 124 if ((i > 1) || !USE_GALAXY_MODEL) { 125 // if GALAXY_MODEL is selected, we want to delay the frame correction until we have 126 // applied the galaxy model a couple of times. 127 FrameCorrectionParallelSlave (catalog, Ncatalog, regionHosts, i); 128 LOGRTIME("FrameCorrection loop %d on %s, host %d: %f sec\n", i, myHostName, REGION_HOST_ID, dtime); 129 } 124 130 125 share_mean_pos (catalog, Ncatalog, regionHosts, i); 131 126 LOGRTIME("share_mean_pos loop %d on %s, host %d: %f sec\n", i, myHostName, REGION_HOST_ID, dtime); … … 133 128 LOGRTIME("slurp_mean_pos loop %d on %s, host %d: %f sec\n", i, myHostName, REGION_HOST_ID, dtime); 134 129 135 UpdateChips (catalog, Ncatalog );130 UpdateChips (catalog, Ncatalog, i); 136 131 LOGRTIME("UpdateChips loop %d on %s, host %d: %f sec\n", i, myHostName, REGION_HOST_ID, dtime); 137 132 -
trunk/Ohana/src/relastro/src/save_catalogs.c
r33652 r38986 9 9 10 10 if (VERBOSE2) fprintf (stderr, "saving catalog %s\n", catalog[i].filename); 11 dvo_catalog_save (&catalog[i], VERBOSE2); 12 dvo_catalog_unlock (&catalog[i]); 11 SetProtect (TRUE); 12 if (!dvo_catalog_save (&catalog[i], VERBOSE2)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog[i].filename); exit (1); } 13 if (!dvo_catalog_unlock (&catalog[i])) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog[i].filename); exit (1); } 14 SetProtect (FALSE); 13 15 dvo_catalog_free (&catalog[i]); 14 16 } -
trunk/Ohana/src/relastro/src/share_images_pos.c
r38062 r38986 115 115 snprintf (mapname, 1024, "%s/AstroMapUpdate.%d.fits", CATDIR, regionHosts->hosts[i].hostID); 116 116 117 AstromOffsetTable *table = AstromOffsetMapLoad (mapname, VERBOSE);117 AstromOffsetTable *table = AstromOffsetMapLoad (mapname, 100000, VERBOSE); 118 118 LOGRTIME("image_maps_load host %d loop %d on %s, host %d: %f sec\n", i, nloop, myHostName, REGION_HOST_ID, dtime); 119 119 -
trunk/Ohana/src/relphot/include/relphot.h
r38466 r38986 14 14 // # define IDX_T off_t 15 15 # define IDX_T int 16 17 typedef enum { 18 STAGE_CHIP = 0x01, 19 STAGE_WARP = 0x02, 20 STAGE_STACK = 0x04, 21 } RelphotStages; 16 22 17 23 typedef enum { … … 327 333 int USE_BASIC_CHECK; 328 334 int USE_FULL_OVERLAP; 335 336 RelphotStages STAGES; 329 337 330 338 # ifdef GRID_V1 -
trunk/Ohana/src/relphot/src/Shutdown.c
r37037 r38986 21 21 va_end (argp); 22 22 23 SetProtect (TRUE);24 if (db) gfits_db_close (db);25 23 fprintf (stderr, "ERROR: relphot halted\n"); 26 24 exit (1); -
trunk/Ohana/src/relphot/src/args.c
r38466 r38986 344 344 } 345 345 346 STAGES = STAGE_CHIP | STAGE_WARP | STAGE_STACK; 347 if ((N = get_argument (argc, argv, "-skip-chip"))) { 348 remove_argument (N, &argc, argv); 349 STAGES &= ~STAGE_CHIP; 350 } 351 if ((N = get_argument (argc, argv, "-skip-warp"))) { 352 remove_argument (N, &argc, argv); 353 STAGES &= ~STAGE_WARP; 354 } 355 if ((N = get_argument (argc, argv, "-skip-stack"))) { 356 remove_argument (N, &argc, argv); 357 STAGES &= ~STAGE_STACK; 358 } 359 if (!STAGES) { 360 fprintf (stderr, "ERROR: no valid stages selected\n"); 361 exit (3); 362 } 363 346 364 REGION_FILE = NULL; 347 365 if ((N = get_argument (argc, argv, "-region-hosts"))) { … … 664 682 } 665 683 684 STAGES = STAGE_CHIP | STAGE_WARP | STAGE_STACK; 685 if ((N = get_argument (argc, argv, "-skip-chip"))) { 686 remove_argument (N, &argc, argv); 687 STAGES &= ~STAGE_CHIP; 688 } 689 if ((N = get_argument (argc, argv, "-skip-warp"))) { 690 remove_argument (N, &argc, argv); 691 STAGES &= ~STAGE_WARP; 692 } 693 if ((N = get_argument (argc, argv, "-skip-stack"))) { 694 remove_argument (N, &argc, argv); 695 STAGES &= ~STAGE_STACK; 696 } 697 if (!STAGES) { 698 fprintf (stderr, "ERROR: no valid stages selected\n"); 699 exit (3); 700 } 701 666 702 if ((MODE == MODE_SYNTH_PHOT) && (argc == 1)) return TRUE; 667 703 if ((MODE == MODE_UPDATE_OBJECTS) && (argc == 1)) return TRUE; -
trunk/Ohana/src/relphot/src/load_catalogs.c
r38471 r38986 253 253 Catalog *catalog = catalogs->catalog; 254 254 *Ncatalog = catalogs->Ncatalog; 255 BrightCatalogSplitFree (catalogs);256 255 257 256 int Nmeasure = 0; … … 263 262 264 263 fprintf (stderr, "loaded %d catalogs, using a total of %d stars (%d measures)\n", catalogs->Ncatalog, Naverage, Nmeasure); 264 client_logger_message ("loaded %d catalogs, using a total of %d stars (%d measures)\n", catalogs->Ncatalog, Naverage, Nmeasure); 265 266 BrightCatalogSplitFree (catalogs); 265 267 266 268 return (catalog); -
trunk/Ohana/src/relphot/src/load_images.c
r38441 r38986 31 31 MARKTIME("build chip match for %d images: %f sec\n", (int) Nimage, dtime); 32 32 33 // XXX consider allowing relphot to skip the AstroMap load (do we need precise astrometry here?) 34 33 35 char mapfile[DVO_MAX_PATH]; 34 36 snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR); 35 AstromOffsetTable *table = AstromOffsetMapLoad (mapfile, VERBOSE);37 AstromOffsetTable *table = AstromOffsetMapLoad (mapfile, 100000, VERBOSE); 36 38 37 39 // assign images.coords.offsetMap -> table->map[i] -
trunk/Ohana/src/relphot/src/reload_catalogs.c
r38471 r38986 105 105 free (moddate); 106 106 107 dvo_catalog_save (&catalog, VERBOSE); 108 dvo_catalog_unlock (&catalog); 107 SetProtect (TRUE); 108 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 109 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 110 SetProtect (FALSE); 109 111 110 112 free_tiny_values(&catalog); … … 244 246 if (SYNTH_ZERO_POINTS) { strextend (&command, "-synthphot-zpts %s", SYNTH_ZERO_POINTS); } 245 247 248 if (!(STAGES & STAGE_CHIP)) { strextend (&command, "-skip-chip"); } 249 if (!(STAGES & STAGE_WARP)) { strextend (&command, "-skip-warp"); } 250 if (!(STAGES & STAGE_STACK)) { strextend (&command, "-skip-stack"); } 251 246 252 // deprecate 247 253 // if (SET_MREL_VERSION != 1) { snprintf (tmpline, 1024, "%s -set-mrel-version %d", SET_MREL_VERSION); } // XXXX deprecate this... -
trunk/Ohana/src/relphot/src/relphot.c
r38062 r38986 4 4 5 5 // get configuration info, args 6 SetSignals (); 6 7 RelphotMode mode = initialize (argc, argv); 7 8 if (!mode) exit (2); -
trunk/Ohana/src/relphot/src/relphot_client.c
r38062 r38986 18 18 19 19 // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, etc) 20 SetSignals (); 20 21 initialize_client (argc, argv); 21 22 client_logger_init (HOSTDIR); -
trunk/Ohana/src/relphot/src/relphot_objects.c
r38471 r38986 101 101 // but it would be better to define a dvo crawler program to do this 102 102 // catalog.catformat = DVO_FORMAT_PS1_V1; 103 dvo_catalog_save (&catalog, VERBOSE); 104 dvo_catalog_unlock (&catalog); 103 SetProtect (TRUE); 104 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 105 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 106 SetProtect (FALSE); 105 107 free_tiny_values(&catalog); 106 108 dvo_catalog_free (&catalog); … … 155 157 if (SYNTH_ZERO_POINTS) { strextend (&command, "-synthphot-zpts %s", SYNTH_ZERO_POINTS); } 156 158 159 if (!(STAGES & STAGE_CHIP)) { strextend (&command, "-skip-chip"); } 160 if (!(STAGES & STAGE_WARP)) { strextend (&command, "-skip-warp"); } 161 if (!(STAGES & STAGE_STACK)) { strextend (&command, "-skip-stack"); } 162 157 163 // if (SET_MREL_VERSION != 1) { strextend (&command, "-set-mrel-version %d", SET_MREL_VERSION); } 158 164 -
trunk/Ohana/src/relphot/src/relphot_parallel_images.c
r37037 r38986 34 34 exit (2); 35 35 } 36 client_logger_message ("loaded images\n"); 36 37 37 38 // once we have read this table, we should remove it for repeat runs … … 53 54 // the following function correctly chooses the sky regions on the 0,360 boundary 54 55 SkyList *skylist = SkyListByBounds (sky, -1, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 56 client_logger_message ("prepare to load catalogs\n"); 55 57 56 58 /* load catalog data from region files (hostID is 0 since we are not a client */ -
trunk/Ohana/src/relphot/src/relphot_synthphot.c
r38471 r38986 71 71 // but it would be better to define a dvo crawler program to do this 72 72 // catalog.catformat = DVO_FORMAT_PS1_V1; 73 dvo_catalog_save (&catalog, VERBOSE); 74 dvo_catalog_unlock (&catalog); 73 SetProtect (TRUE); 74 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 75 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 76 SetProtect (FALSE); 75 77 dvo_catalog_free (&catalog); 76 78 } -
trunk/Ohana/src/relphot/src/setMrelCatalog.c
r38923 r38986 52 52 for (j = 0; j < catalog[Nc].Naverage; j++) { 53 53 54 setMrelAverageExposure (&catalog[Nc], Nc, j, Nsecfilt, isSetMrelFinal, flatcorr, results); 54 if (STAGES & STAGE_CHIP) { 55 setMrelAverageExposure (&catalog[Nc], Nc, j, Nsecfilt, isSetMrelFinal, flatcorr, results); 56 } 55 57 56 58 // only apply Stack operation on setMrelFinal in first pass 57 if (isSetMrelFinal && !IS_DIFF_DB) {59 if (isSetMrelFinal && (STAGES & STAGE_STACK) && !IS_DIFF_DB) { 58 60 setMrelAverageStack (&catalog[Nc], Nc, j, Nsecfilt, flatcorr); 59 61 } 60 62 61 63 // only measure force-warp mean values if issetMrelFinal (make it optional?) 62 if (isSetMrelFinal ) {64 if (isSetMrelFinal && (STAGES & STAGE_WARP)) { 63 65 setMrelAverageForcedWarp (&catalog[Nc], Nc, j, Nsecfilt, flatcorr, results); 64 66 } -
trunk/Ohana/src/tools/Makefile
r37041 r38986 15 15 DVO_INCS = $(DESTINC)/dvo.h $(DESTINC)/gfitsio.h $(DESTINC)/ohana.h $(DESTINC)/autocode.h 16 16 17 PROGRAMS = gconfig fhead ftable fields list_astro glockfile \17 PROGRAMS = gconfig fhead pspsconvert ftable fields list_astro glockfile \ 18 18 radec mktemp precess csystem fits_insert \ 19 medianfilter mefhead ckfits roc random 19 medianfilter mefhead ckfits roc random fits_to_mysql 20 20 21 21 all tools: $(PROGRAMS) -
trunk/Ohana/src/uniphot/Makefile
r38464 r38986 67 67 $(SRC)/update_dvo_setphot.$(ARCH).o \ 68 68 $(SRC)/update_catalog_setphot.$(ARCH).o \ 69 $(SRC)/repair_catalog_by_objID.$(ARCH).o \ 69 70 $(SRC)/SetSignals.$(ARCH).o \ 70 71 $(SRC)/Shutdown.$(ARCH).o … … 77 78 $(SRC)/update_dvo_setphot.$(ARCH).o \ 78 79 $(SRC)/update_catalog_setphot.$(ARCH).o \ 80 $(SRC)/repair_catalog_by_objID.$(ARCH).o \ 79 81 $(SRC)/initialize_setphot_client.$(ARCH).o \ 82 $(SRC)/SetSignals.$(ARCH).o \ 83 $(SRC)/Shutdown.$(ARCH).o \ 80 84 $(SRC)/ImageSubset.$(ARCH).o 81 85 … … 136 140 $(SRC)/repair_tycho_setastrom.$(ARCH).o \ 137 141 $(SRC)/astrom_correction.$(ARCH).o \ 142 $(SRC)/SetSignals.$(ARCH).o \ 143 $(SRC)/Shutdown.$(ARCH).o \ 138 144 $(SRC)/initialize_setastrom.$(ARCH).o 139 145 … … 158 164 $(SRC)/update_catalog_setgalmodel.$(ARCH).o \ 159 165 $(SRC)/galmodel_correction.$(ARCH).o \ 166 $(SRC)/SetSignals.$(ARCH).o \ 167 $(SRC)/Shutdown.$(ARCH).o \ 160 168 $(SRC)/initialize_setgalmodel.$(ARCH).o 161 169 … … 234 242 $(SRC)/initialize_ckids.$(ARCH).o \ 235 243 $(SRC)/update_dvo_ckids.$(ARCH).o \ 244 $(SRC)/SetSignals.$(ARCH).o \ 245 $(SRC)/Shutdown.$(ARCH).o \ 236 246 $(SRC)/update_catalog_ckids.$(ARCH).o 237 247 … … 243 253 $(SRC)/initialize_ckids.$(ARCH).o \ 244 254 $(SRC)/update_dvo_ckids.$(ARCH).o \ 255 $(SRC)/SetSignals.$(ARCH).o \ 256 $(SRC)/Shutdown.$(ARCH).o \ 245 257 $(SRC)/update_catalog_ckids.$(ARCH).o 246 258 -
trunk/Ohana/src/uniphot/include/ckids.h
r35764 r38986 22 22 void ConfigInit PROTO((int *argc, char **argv)); 23 23 24 void usage_ckids PROTO(( ));24 void usage_ckids PROTO((void)); 25 25 void initialize_ckids PROTO((int argc, char **argv)); 26 26 int args_ckids PROTO((int argc, char **argv)); 27 27 28 void usage_ckids_client PROTO(( ));28 void usage_ckids_client PROTO((void)); 29 29 void initialize_ckids_client PROTO((int argc, char **argv)); 30 30 int args_ckids_client PROTO((int argc, char **argv)); 31 31 32 int update_dvo_ckids PROTO(( ));32 int update_dvo_ckids PROTO((void)); 33 33 int update_dvo_ckids_parallel PROTO((SkyList *sky)); 34 34 35 35 void update_catalog_ckids PROTO((Catalog *catalog, FILE *foutput)); 36 37 int Shutdown PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) ); 38 void TrapSignal PROTO((int sig)); 39 void SetProtect PROTO((int mode)); 40 int SetSignals PROTO((void)); 41 -
trunk/Ohana/src/uniphot/include/fiximids.h
r35764 r38986 37 37 void ConfigInit PROTO((int *argc, char **argv)); 38 38 39 void usage_fiximids PROTO(( ));39 void usage_fiximids PROTO((void)); 40 40 void initialize_fiximids PROTO((int argc, char **argv)); 41 41 int args_fiximids PROTO((int argc, char **argv)); 42 42 43 void usage_fiximids_client PROTO(( ));43 void usage_fiximids_client PROTO((void)); 44 44 void initialize_fiximids_client PROTO((int argc, char **argv)); 45 45 int args_fiximids_client PROTO((int argc, char **argv)); -
trunk/Ohana/src/uniphot/include/fixstkids.h
r35764 r38986 34 34 void ConfigInit PROTO((int *argc, char **argv)); 35 35 36 void usage_fixstkids PROTO(( ));36 void usage_fixstkids PROTO((void)); 37 37 void initialize_fixstkids PROTO((int argc, char **argv)); 38 38 int args_fixstkids PROTO((int argc, char **argv)); 39 39 40 void usage_fixstkids_client PROTO(( ));40 void usage_fixstkids_client PROTO((void)); 41 41 void initialize_fixstkids_client PROTO((int argc, char **argv)); 42 42 int args_fixstkids_client PROTO((int argc, char **argv)); -
trunk/Ohana/src/uniphot/include/setastrom.h
r38464 r38986 64 64 void ConfigInit PROTO((int *argc, char **argv)); 65 65 66 void usage_setastrom PROTO(( ));66 void usage_setastrom PROTO((void)); 67 67 void initialize_setastrom PROTO((int argc, char **argv)); 68 68 int args_setastrom PROTO((int argc, char **argv)); 69 69 70 void usage_setastrom_client PROTO(( ));70 void usage_setastrom_client PROTO((void)); 71 71 void initialize_setastrom_client PROTO((int argc, char **argv)); 72 72 int args_setastrom_client PROTO((int argc, char **argv)); 73 73 74 //int Shutdown PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) );75 //void TrapSignal PROTO((int sig));76 //void SetProtect PROTO((int mode));77 //int SetSignals PROTO((void));74 int Shutdown PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) ); 75 void TrapSignal PROTO((int sig)); 76 void SetProtect PROTO((int mode)); 77 int SetSignals PROTO((void)); 78 78 79 int update_dvo_setastrom PROTO(( ));79 int update_dvo_setastrom PROTO((void)); 80 80 int update_dvo_setastrom_parallel PROTO((SkyTable *sky)); 81 81 -
trunk/Ohana/src/uniphot/include/setgalmodel.h
r37807 r38986 26 26 void ConfigInit PROTO((int *argc, char **argv)); 27 27 28 void usage_setgalmodel PROTO(( ));28 void usage_setgalmodel PROTO((void)); 29 29 void initialize_setgalmodel PROTO((int argc, char **argv)); 30 30 int args_setgalmodel PROTO((int argc, char **argv)); 31 31 32 void usage_setgalmodel_client PROTO(( ));32 void usage_setgalmodel_client PROTO((void)); 33 33 void initialize_setgalmodel_client PROTO((int argc, char **argv)); 34 34 int args_setgalmodel_client PROTO((int argc, char **argv)); 35 35 36 //int Shutdown PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) );37 //void TrapSignal PROTO((int sig));38 //void SetProtect PROTO((int mode));39 //int SetSignals PROTO((void));36 int Shutdown PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) ); 37 void TrapSignal PROTO((int sig)); 38 void SetProtect PROTO((int mode)); 39 int SetSignals PROTO((void)); 40 40 41 41 int update_dvo_setgalmodel PROTO((void)); -
trunk/Ohana/src/uniphot/include/setphot.h
r35103 r38986 35 35 int PARALLEL_SERIAL; 36 36 int IMAGES_ONLY; 37 int REPAIR_BY_OBJID; 37 38 38 39 SkyRegion UserPatch; … … 76 77 int parse_zpt_offsets PROTO((char *ZPT_OFFSET_FILTERS, char *ZPT_OFFSET_VALUES)); 77 78 float apply_zpt_offset PROTO((short code)); 79 80 int repair_catalog_by_objID (Catalog *catalog); -
trunk/Ohana/src/uniphot/include/setposangle.h
r35103 r38986 39 39 void ConfigInit PROTO((int *argc, char **argv)); 40 40 41 void usage_setposangle PROTO(( ));41 void usage_setposangle PROTO((void)); 42 42 void initialize_setposangle PROTO((int argc, char **argv)); 43 43 int args_setposangle PROTO((int argc, char **argv)); 44 44 45 void usage_setposangle_client PROTO(( ));45 void usage_setposangle_client PROTO((void)); 46 46 void initialize_setposangle_client PROTO((int argc, char **argv)); 47 47 int args_setposangle_client PROTO((int argc, char **argv)); -
trunk/Ohana/src/uniphot/src/Shutdown.c
r27790 r38986 21 21 va_end (argp); 22 22 23 SetProtect (TRUE);24 gfits_db_close (db);25 23 fprintf (stderr, "ERROR: halted\n"); 26 24 exit (1); -
trunk/Ohana/src/uniphot/src/ckids.c
r35764 r38986 6 6 7 7 /* get configuration info, args, lockfile */ 8 SetSignals (); 8 9 initialize_ckids (argc, argv); 9 10 -
trunk/Ohana/src/uniphot/src/ckids_client.c
r35764 r38986 12 12 13 13 // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES) 14 SetSignals (); 14 15 initialize_ckids_client (argc, argv); 15 16 -
trunk/Ohana/src/uniphot/src/fiximids.c
r38441 r38986 8 8 9 9 /* get configuration info, args, lockfile */ 10 SetSignals (); 10 11 initialize_fiximids (argc, argv); 11 12 -
trunk/Ohana/src/uniphot/src/fiximids_client.c
r35764 r38986 13 13 14 14 // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES) 15 SetSignals (); 15 16 initialize_fiximids_client (argc, argv); 16 17 -
trunk/Ohana/src/uniphot/src/fixstkids.c
r38441 r38986 8 8 9 9 /* get configuration info, args, lockfile */ 10 SetSignals (); 10 11 initialize_fixstkids (argc, argv); 11 12 -
trunk/Ohana/src/uniphot/src/fixstkids_client.c
r35764 r38986 13 13 14 14 // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES) 15 SetSignals (); 15 16 initialize_fixstkids_client (argc, argv); 16 17 -
trunk/Ohana/src/uniphot/src/initialize_setphot.c
r35103 r38986 49 49 if ((N = get_argument (argc, argv, "-reset"))) { 50 50 RESET = TRUE; 51 remove_argument (N, &argc, argv); 52 } 53 54 REPAIR_BY_OBJID = FALSE; 55 if ((N = get_argument (argc, argv, "-repair-by-objid"))) { 56 REPAIR_BY_OBJID = TRUE; 51 57 remove_argument (N, &argc, argv); 52 58 } -
trunk/Ohana/src/uniphot/src/initialize_setphot_client.c
r35103 r38986 53 53 remove_argument (N, &argc, argv); 54 54 UserPatch.Dmax = atof (argv[N]); 55 remove_argument (N, &argc, argv); 56 } 57 58 REPAIR_BY_OBJID = FALSE; 59 if ((N = get_argument (argc, argv, "-repair-by-objid"))) { 60 REPAIR_BY_OBJID = TRUE; 55 61 remove_argument (N, &argc, argv); 56 62 } -
trunk/Ohana/src/uniphot/src/load_zpt_table.c
r37807 r38986 107 107 if (NO_METADATA) { 108 108 NFILTER = 5; 109 NSEASON = 4;109 NSEASON = 5; 110 110 NCHIP_X = 8; 111 111 NCHIP_Y = 8; … … 165 165 // ubercal hard-coded values 166 166 char filters_uc[5][3] = {"g", "r", "i", "z", "y"}; 167 double tstart_uc[] = {55000.0, 55296.0, 55327.0, 55662.0}; 168 double tstop_uc[] = {55296.0, 55327.0, 55662.0, 60000.0}; 167 168 // double tstart_uc[] = {55000.0, 55296.0, 55327.0, 55662.0}; 169 // double tstop_uc[] = {55296.0, 55327.0, 55662.0, 60000.0}; 170 171 double tstart_uc[] = {50000.0, 55296.0, 55327.0, 55662.0, 56110.0}; 172 double tstop_uc[] = {55296.0, 55327.0, 55662.0, 56110.0, 65000.0}; 169 173 170 174 double mjdstart, mjdstop; … … 275 279 exit (2); 276 280 } 281 282 // ***** skip the extra table segment ***** 283 // load data for this header 284 if (!gfits_load_header (f, &theader)) return (NULL); 285 286 // read the fits table bytes 287 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) return (NULL); 288 289 // skip over remaining bytes in data segment 290 fseeko (f, ftable.datasize - ftable.validsize, SEEK_CUR); 277 291 278 292 // XXX the initial hacked-together table from Eddie is missing the last 2 elements. they should be zero -
trunk/Ohana/src/uniphot/src/setastrom.c
r38464 r38986 6 6 7 7 /* get configuration info, args, lockfile */ 8 SetSignals (); 8 9 initialize_setastrom (argc, argv); 9 10 -
trunk/Ohana/src/uniphot/src/setastrom_client.c
r35103 r38986 13 13 14 14 // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES) 15 SetSignals (); 15 16 initialize_setastrom_client (argc, argv); 16 17 17 update_dvo_setastrom ( argv[1]);18 update_dvo_setastrom (); 18 19 19 20 exit (0); -
trunk/Ohana/src/uniphot/src/setfwhm.c
r38441 r38986 10 10 11 11 /* get configuration info, args, lockfile */ 12 SetSignals (); 12 13 initialize_setfwhm (argc, argv); 13 14 -
trunk/Ohana/src/uniphot/src/setgalmodel.c
r37807 r38986 6 6 7 7 /* get configuration info, args, lockfile */ 8 SetSignals (); 8 9 initialize_setgalmodel (argc, argv); 9 10 -
trunk/Ohana/src/uniphot/src/setgalmodel_client.c
r37807 r38986 13 13 14 14 // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES) 15 SetSignals (); 15 16 initialize_setgalmodel_client (argc, argv); 16 17 -
trunk/Ohana/src/uniphot/src/setphot.c
r38464 r38986 11 11 12 12 /* get configuration info, args, lockfile */ 13 SetSignals (); 13 14 initialize_setphot (argc, argv); 14 15 … … 50 51 // write image table (even if some remote clients failed) 51 52 if (UPDATE) { 53 SetProtect (TRUE); 52 54 dvo_image_save (&db, VERBOSE); 55 SetProtect (FALSE); 53 56 } 54 57 -
trunk/Ohana/src/uniphot/src/setphot_client.c
r33654 r38986 13 13 14 14 // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES) 15 SetSignals (); 15 16 initialize_setphot_client (argc, argv); 16 17 -
trunk/Ohana/src/uniphot/src/setposangle.c
r38441 r38986 8 8 9 9 /* get configuration info, args, lockfile */ 10 SetSignals (); 10 11 initialize_setposangle (argc, argv); 11 12 -
trunk/Ohana/src/uniphot/src/setposangle_client.c
r34749 r38986 13 13 14 14 // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES) 15 SetSignals (); 15 16 initialize_setposangle_client (argc, argv); 16 17 -
trunk/Ohana/src/uniphot/src/uniphot.c
r38441 r38986 16 16 17 17 /* get configuration info, args, lockfile */ 18 SetSignals (); 18 19 initialize_uniphot (argc, argv); 19 20 -
trunk/Ohana/src/uniphot/src/update_catalog_setastrom.c
r38062 r38986 42 42 // XXX hardwire the list of chips to KH correct 43 43 // some notes: 44 // XY17 surprisingly does not need correction 44 45 // XY24 surprisingly does not need correction 45 // XY27 has poor astrometry with a weird correction for all mags46 46 // XY36 surprisingly does not need correction 47 // XY67 has poor astrometry with a weird correction for all mags48 47 49 48 int doKH = FALSE; … … 55 54 case 15: 56 55 case 16: 57 case 17:58 56 case 25: 59 57 case 26: 58 case 27: 60 59 case 34: 61 60 case 35: … … 73 72 case 62: 74 73 case 63: 74 case 67: 75 75 case 71: 76 76 case 72: … … 100 100 // this correction here (but ideally I would re-measure the KH trend from PV2 data and re-generate 101 101 // the splines 102 float MinstSB = Minst + 5.0*log10( M_SQRT2*fwhm_maj);102 float MinstSB = Minst + 5.0*log10(fwhm_maj); 103 103 104 104 // I should validate that the spline I'm using is SB corrected not Minst.. … … 249 249 // do not modify the original Xccd,Yccd values 250 250 if (KH_FILE) { 251 measure[0].XoffKH = dX_KH / pltScale;252 measure[0].YoffKH = dY_KH / pltScale;251 measure[0].XoffKH = -dX_KH / pltScale; 252 measure[0].YoffKH = -dY_KH / pltScale; 253 253 } 254 254 if (KH_RESET) { -
trunk/Ohana/src/uniphot/src/update_catalog_setgalmodel.c
r37807 r38986 3 3 int update_catalog_setgalmodel (Catalog *catalog) { 4 4 5 off_t i, j, m; 6 7 // choose this number more judiciously... 8 time_t timeRef = ohana_date_to_sec("2000/01/01,00:00:00"); 5 off_t i, m; 9 6 10 7 Average *average = catalog[0].average; … … 20 17 for (i = 0; i < catalog[0].Naverage; i++) { 21 18 22 { 23 m = average[i].measureOffset; 24 Measure *measure = &catalog[0].measure[m]; 25 for (j = 0; j < average[i].Nmeasure; j++) { 26 measure[j].RoffGAL = 0.0; // XXX divide by dcos? project and calculate? 27 measure[j].DoffGAL = 0.0; // XXX divide by dcos? project and calculate? 28 } 29 } 19 average[i].uRgal = NAN; 20 average[i].uDgal = NAN; 30 21 31 22 if (average[i].Nstarpar == 0) continue; … … 63 54 starpar->uDEC = uD; 64 55 65 m = average[i].measureOffset; 66 Measure *measure = &catalog[0].measure[m]; 67 68 // use the model uR,uD values to move the expected position based on the reference date; 69 for (j = 0; j < average[i].Nmeasure; j++) { 70 71 double dtime = (measure[j].t - timeRef) / 86400.0 / 365.25; 72 73 // do not modify the original Xccd,Yccd values 74 measure[j].RoffGAL = uR * dtime; // XXX divide by dcos? project and calculate? 75 measure[j].DoffGAL = uD * dtime; // XXX divide by dcos? project and calculate? 76 } 56 average[i].uRgal = uR; 57 average[i].uDgal = uD; 77 58 } 78 59 -
trunk/Ohana/src/uniphot/src/update_dvo_ckids.c
r38471 r38986 69 69 if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename); 70 70 71 dvo_catalog_save (&catalog, VERBOSE); 72 dvo_catalog_unlock (&catalog); 71 SetProtect (TRUE); 72 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 73 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 74 SetProtect (FALSE); 73 75 dvo_catalog_free (&catalog); 74 76 } -
trunk/Ohana/src/uniphot/src/update_dvo_fiximids.c
r38471 r38986 64 64 if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename); 65 65 66 dvo_catalog_save (&catalog, VERBOSE); 67 dvo_catalog_unlock (&catalog); 66 SetProtect (TRUE); 67 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 68 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 69 SetProtect (FALSE); 68 70 dvo_catalog_free (&catalog); 69 71 } -
trunk/Ohana/src/uniphot/src/update_dvo_fixstkids.c
r38471 r38986 64 64 if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename); 65 65 66 dvo_catalog_save (&catalog, VERBOSE); 67 dvo_catalog_unlock (&catalog); 66 SetProtect (TRUE); 67 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 68 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 69 SetProtect (FALSE); 68 70 dvo_catalog_free (&catalog); 69 71 } -
trunk/Ohana/src/uniphot/src/update_dvo_setastrom.c
r38471 r38986 1 1 # include "setastrom.h" 2 2 3 int update_dvo_setastrom ( ) {3 int update_dvo_setastrom (void) { 4 4 5 5 SkyTable *sky = NULL; … … 74 74 if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename); 75 75 76 dvo_catalog_save (&catalog, VERBOSE); 77 dvo_catalog_unlock (&catalog); 76 struct timeval now; 77 gettimeofday (&now, (void *) NULL); 78 char *moddate = ohana_sec_to_date (now.tv_sec); 79 gfits_modify (&catalog.header, "SETASTR", "%s", 1, moddate); // replaces the single entry 80 81 char history[128]; 82 snprintf (history, 128, "setastrom applied: %s", moddate); 83 gfits_modify_alt (&catalog.header, "HISTORY", "%S", 0, history); // adds a new entry 84 85 snprintf (history, 128, "setastrom options: KH: %1d, DCR: %1d, CAM: %1d", (KH_FILE != NULL), (DCR_FILE != NULL), (CAM_FILE != NULL)); 86 gfits_modify_alt (&catalog.header, "HISTORY", "%S", 0, history); // adds a new entry 87 88 SetProtect (TRUE); 89 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 90 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 91 SetProtect (FALSE); 78 92 dvo_catalog_free (&catalog); 79 93 } -
trunk/Ohana/src/uniphot/src/update_dvo_setgalmodel.c
r38471 r38986 66 66 if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename); 67 67 68 dvo_catalog_save (&catalog, VERBOSE); 69 dvo_catalog_unlock (&catalog); 68 SetProtect (TRUE); 69 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 70 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 71 SetProtect (FALSE); 70 72 dvo_catalog_free (&catalog); 71 73 } -
trunk/Ohana/src/uniphot/src/update_dvo_setphot.c
r38471 r38986 53 53 dvo_catalog_init (&catalog, TRUE); 54 54 catalog.filename = HOST_ID ? localFilename : skylist[0].filename[i]; 55 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT;55 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE; 56 56 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 57 57 … … 67 67 } 68 68 69 if (REPAIR_BY_OBJID) { 70 // For gpc1 / PV3, I broke some catalogs with dvomerge -replace: the last object can 71 // contaminate the first set of new measurements 72 repair_catalog_by_objID (&catalog); 73 } 74 69 75 update_catalog_setphot (&catalog, image, index, Nimage, flatcorr); 70 76 … … 77 83 if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename); 78 84 79 dvo_catalog_save (&catalog, VERBOSE); 80 dvo_catalog_unlock (&catalog); 85 struct timeval now; 86 gettimeofday (&now, (void *) NULL); 87 char *moddate = ohana_sec_to_date (now.tv_sec); 88 gfits_modify (&catalog.header, "SETPHOT", "%s", 1, moddate); // replaces the single entry 89 90 char history[128]; 91 snprintf (history, 128, "setphot applied: %s", moddate); 92 gfits_modify_alt (&catalog.header, "HISTORY", "%S", 0, history); // adds a new entry 93 94 snprintf (history, 128, "setphot options: reset: %1d, ubercal: %1d", RESET, UBERCAL); 95 gfits_modify_alt (&catalog.header, "HISTORY", "%S", 0, history); // adds a new entry 96 97 free (moddate); 98 99 SetProtect (TRUE); 100 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 101 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 102 SetProtect (FALSE); 81 103 dvo_catalog_free (&catalog); 82 104 } … … 114 136 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 115 137 116 if (VERBOSE) { strextend (&command, "-v"); } 117 if (RESET) { strextend (&command, "-reset"); } 118 if (UPDATE) { strextend (&command, "-update"); } 119 if (UBERCAL) { strextend (&command, "-ubercal"); } 138 if (VERBOSE) { strextend (&command, "-v"); } 139 if (RESET) { strextend (&command, "-reset"); } 140 if (UPDATE) { strextend (&command, "-update"); } 141 if (UBERCAL) { strextend (&command, "-ubercal"); } 142 if (REPAIR_BY_OBJID) { strextend (&command, "-repair-by-objid"); } 120 143 121 144 fprintf (stderr, "command: %s\n", command); -
trunk/Ohana/src/uniphot/src/update_dvo_setposangle.c
r38471 r38986 78 78 if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename); 79 79 80 dvo_catalog_save (&catalog, VERBOSE); 81 dvo_catalog_unlock (&catalog); 80 SetProtect (TRUE); 81 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 82 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 83 SetProtect (FALSE); 82 84 dvo_catalog_free (&catalog); 83 85 } -
trunk/Ohana/src/uniphot/src/update_dvo_uniphot.c
r38471 r38986 101 101 fprintf (stderr, "catalog: %s sgroup: %d %s %f\n", catalog.filename, Nmin, sgroup[Nmin].label, Rmin); 102 102 update_catalog_uniphot (&catalog, &sgroup[Nmin], (Rmin > 2*RADIUS)); 103 dvo_catalog_save (&catalog, VERBOSE); 104 dvo_catalog_unlock (&catalog); 103 SetProtect (TRUE); 104 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 105 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 106 SetProtect (FALSE); 105 107 dvo_catalog_free (&catalog); 106 108 }
Note:
See TracChangeset
for help on using the changeset viewer.
