Changeset 37403 for branches/eam_branches/ps2-tc3-20130727/Ohana
- Timestamp:
- Sep 19, 2014, 4:05:27 PM (12 years ago)
- Location:
- branches/eam_branches/ps2-tc3-20130727
- Files:
-
- 1 deleted
- 278 edited
- 73 copied
-
. (modified) (1 prop)
-
Ohana (modified) (1 prop)
-
Ohana/src/addstar/Makefile (modified) (2 diffs)
-
Ohana/src/addstar/include/addstar.h (modified) (5 diffs)
-
Ohana/src/addstar/src/BoundaryTreeIO.c (modified) (1 diff)
-
Ohana/src/addstar/src/FilterStars.c (modified) (3 diffs)
-
Ohana/src/addstar/src/GetFileMode.c (modified) (1 diff)
-
Ohana/src/addstar/src/LoadData.c (modified) (1 diff)
-
Ohana/src/addstar/src/MatchHeaders.c (modified) (2 diffs)
-
Ohana/src/addstar/src/ReadImageHeader.c (modified) (2 diffs)
-
Ohana/src/addstar/src/ReadStarsFITS.c (modified) (42 diffs)
-
Ohana/src/addstar/src/ReadXradFITS.c (copied) (copied from trunk/Ohana/src/addstar/src/ReadXradFITS.c )
-
Ohana/src/addstar/src/SEDfit.c (modified) (1 diff)
-
Ohana/src/addstar/src/StarOps.c (modified) (1 diff)
-
Ohana/src/addstar/src/UpdateImageIDs.c (modified) (1 diff)
-
Ohana/src/addstar/src/addstar.c (modified) (13 diffs)
-
Ohana/src/addstar/src/addstar_client.c (modified) (1 diff)
-
Ohana/src/addstar/src/args.c (modified) (4 diffs)
-
Ohana/src/addstar/src/args_parallel_client.c (modified) (2 diffs)
-
Ohana/src/addstar/src/build_links.c (modified) (10 diffs)
-
Ohana/src/addstar/src/fakeimage.c (modified) (2 diffs)
-
Ohana/src/addstar/src/find_matches.c (modified) (16 diffs)
-
Ohana/src/addstar/src/find_matches_closest.c (modified) (17 diffs)
-
Ohana/src/addstar/src/find_matches_closest_refstars.c (modified) (8 diffs)
-
Ohana/src/addstar/src/find_matches_refstars.c (modified) (7 diffs)
-
Ohana/src/addstar/src/findskycell.c (modified) (8 diffs)
-
Ohana/src/addstar/src/load2mass_catalog.c (modified) (2 diffs)
-
Ohana/src/addstar/src/loadsupercos_ops.c (modified) (5 diffs)
-
Ohana/src/addstar/src/mkcmf.c (modified) (9 diffs)
-
Ohana/src/addstar/src/replace_match.c (modified) (1 diff)
-
Ohana/src/addstar/src/resort_catalog.c (modified) (6 diffs)
-
Ohana/src/addstar/src/resort_catalogs.c (copied) (copied from trunk/Ohana/src/addstar/src/resort_catalogs.c )
-
Ohana/src/addstar/src/resort_threaded.c (modified) (8 diffs)
-
Ohana/src/addstar/src/resort_unthreaded.c (modified) (1 diff)
-
Ohana/src/addstar/src/resort_unthreaded_catalogs.c (deleted)
-
Ohana/src/addstar/src/update_coords.c (modified) (3 diffs)
-
Ohana/src/addstar/test/simple.dvo (modified) (12 diffs)
-
Ohana/src/checkastro (copied) (copied from trunk/Ohana/src/checkastro )
-
Ohana/src/checkastro/Makefile (copied) (copied from trunk/Ohana/src/checkastro/Makefile )
-
Ohana/src/checkastro/bin (copied) (copied from trunk/Ohana/src/checkastro/bin )
-
Ohana/src/checkastro/doc (copied) (copied from trunk/Ohana/src/checkastro/doc )
-
Ohana/src/checkastro/include (copied) (copied from trunk/Ohana/src/checkastro/include )
-
Ohana/src/checkastro/include/checkastro.h (copied) (copied from trunk/Ohana/src/checkastro/include/checkastro.h )
-
Ohana/src/checkastro/src (copied) (copied from trunk/Ohana/src/checkastro/src )
-
Ohana/src/checkastro/src/BrightCatalog.c (copied) (copied from trunk/Ohana/src/checkastro/src/BrightCatalog.c )
-
Ohana/src/checkastro/src/ConfigInit.c (copied) (copied from trunk/Ohana/src/checkastro/src/ConfigInit.c )
-
Ohana/src/checkastro/src/ImageOps.c (copied) (copied from trunk/Ohana/src/checkastro/src/ImageOps.c )
-
Ohana/src/checkastro/src/MeasFilterTest.c (copied) (copied from trunk/Ohana/src/checkastro/src/MeasFilterTest.c )
-
Ohana/src/checkastro/src/SetSignals.c (copied) (copied from trunk/Ohana/src/checkastro/src/SetSignals.c )
-
Ohana/src/checkastro/src/Shutdown.c (copied) (copied from trunk/Ohana/src/checkastro/src/Shutdown.c )
-
Ohana/src/checkastro/src/args.c (copied) (copied from trunk/Ohana/src/checkastro/src/args.c )
-
Ohana/src/checkastro/src/bcatalog.c (copied) (copied from trunk/Ohana/src/checkastro/src/bcatalog.c )
-
Ohana/src/checkastro/src/checkastro.c (copied) (copied from trunk/Ohana/src/checkastro/src/checkastro.c )
-
Ohana/src/checkastro/src/checkastro_client.c (copied) (copied from trunk/Ohana/src/checkastro/src/checkastro_client.c )
-
Ohana/src/checkastro/src/checkastro_images.c (copied) (copied from trunk/Ohana/src/checkastro/src/checkastro_images.c )
-
Ohana/src/checkastro/src/initialize.c (copied) (copied from trunk/Ohana/src/checkastro/src/initialize.c )
-
Ohana/src/checkastro/src/load_catalogs.c (copied) (copied from trunk/Ohana/src/checkastro/src/load_catalogs.c )
-
Ohana/src/checkastro/src/load_images.c (copied) (copied from trunk/Ohana/src/checkastro/src/load_images.c )
-
Ohana/src/checkastro/src/select_images.c (copied) (copied from trunk/Ohana/src/checkastro/src/select_images.c )
-
Ohana/src/delstar/include/delstar.h (modified) (1 diff)
-
Ohana/src/delstar/src/ImageOpsFixLAP.c (modified) (1 diff)
-
Ohana/src/delstar/src/ImageSubsetFixLAP.c (modified) (1 diff)
-
Ohana/src/delstar/src/MeasureEdgeOps.c (modified) (1 diff)
-
Ohana/src/delstar/src/args.c (modified) (2 diffs)
-
Ohana/src/delstar/src/delete_duplicate_images.c (modified) (3 diffs)
-
Ohana/src/delstar/src/delete_fix_LAP_edges.c (modified) (2 diffs)
-
Ohana/src/dvolens (copied) (copied from trunk/Ohana/src/dvolens )
-
Ohana/src/dvolens/Makefile (copied) (copied from trunk/Ohana/src/dvolens/Makefile )
-
Ohana/src/dvolens/include (copied) (copied from trunk/Ohana/src/dvolens/include )
-
Ohana/src/dvolens/include/dvolens.h (copied) (copied from trunk/Ohana/src/dvolens/include/dvolens.h )
-
Ohana/src/dvolens/src (copied) (copied from trunk/Ohana/src/dvolens/src )
-
Ohana/src/dvolens/src/ConfigInit.c (copied) (copied from trunk/Ohana/src/dvolens/src/ConfigInit.c )
-
Ohana/src/dvolens/src/SetSignals.c (copied) (copied from trunk/Ohana/src/dvolens/src/SetSignals.c )
-
Ohana/src/dvolens/src/Shutdown.c (copied) (copied from trunk/Ohana/src/dvolens/src/Shutdown.c )
-
Ohana/src/dvolens/src/args.c (copied) (copied from trunk/Ohana/src/dvolens/src/args.c )
-
Ohana/src/dvolens/src/client_logger.c (copied) (copied from trunk/Ohana/src/dvolens/src/client_logger.c )
-
Ohana/src/dvolens/src/dvolens.c (copied) (copied from trunk/Ohana/src/dvolens/src/dvolens.c )
-
Ohana/src/dvolens/src/dvolens_client.c (copied) (copied from trunk/Ohana/src/dvolens/src/dvolens_client.c )
-
Ohana/src/dvolens/src/help.c (copied) (copied from trunk/Ohana/src/dvolens/src/help.c )
-
Ohana/src/dvolens/src/initialize.c (copied) (copied from trunk/Ohana/src/dvolens/src/initialize.c )
-
Ohana/src/dvolens/src/update_objects.c (copied) (copied from trunk/Ohana/src/dvolens/src/update_objects.c )
-
Ohana/src/dvolens/src/update_objects_catalog.c (copied) (copied from trunk/Ohana/src/dvolens/src/update_objects_catalog.c )
-
Ohana/src/dvomerge/include/dvomerge.h (modified) (1 diff)
-
Ohana/src/dvomerge/include/dvoverify.h (modified) (1 diff)
-
Ohana/src/dvomerge/src/IDmapIO.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/LoadCatalog.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/build_links.c (modified) (13 diffs)
-
Ohana/src/dvomerge/src/dvo_image_merge_dbs.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvomergeContinue.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvomergeContinue_threaded.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvomergeCreate.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvomergeFromList.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvomergeImageIDs.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvomergeUpdate.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvomergeUpdate_threaded.c (modified) (5 diffs)
-
Ohana/src/dvomerge/src/dvorepair.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvorepairCPT.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvorepairDeleteImageList.c (modified) (3 diffs)
-
Ohana/src/dvomerge/src/dvorepairFixCPT.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvorepairFixTables.c (modified) (3 diffs)
-
Ohana/src/dvomerge/src/dvorepairImageVsMeasure.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvorepairImagesVsMeasures.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvoverify_args.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvoverify_catalogs.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvoverify_client.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvoverify_utils.c (modified) (7 diffs)
-
Ohana/src/dvomerge/src/merge_catalogs_new.c (modified) (4 diffs)
-
Ohana/src/dvomerge/src/merge_catalogs_old.c (modified) (23 diffs)
-
Ohana/src/dvomerge/src/replace_match.c (modified) (3 diffs)
-
Ohana/src/dvopsps/include/dvopsps.h (modified) (2 diffs)
-
Ohana/src/dvopsps/src/DetectionOps.c (modified) (5 diffs)
-
Ohana/src/dvopsps/src/insert_detections_dvopsps.c (modified) (6 diffs)
-
Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c (modified) (11 diffs)
-
Ohana/src/dvopsps/src/insert_objects_dvopsps.c (modified) (1 diff)
-
Ohana/src/dvopsps/src/insert_objects_dvopsps_catalog.c (modified) (7 diffs)
-
Ohana/src/dvopsps/src/insert_skytable.c (modified) (3 diffs)
-
Ohana/src/dvosplit/src/dvosplit.c (modified) (1 diff)
-
Ohana/src/dvosplit/src/split_averages.c (modified) (1 diff)
-
Ohana/src/dvosplit/src/split_measures.c (modified) (2 diffs)
-
Ohana/src/gastro2/src/gstars2.c (modified) (1 diff)
-
Ohana/src/getstar (modified) (1 prop)
-
Ohana/src/getstar/src/GetFileMode.c (modified) (1 diff)
-
Ohana/src/getstar/src/ReadImageFiles.c (modified) (1 diff)
-
Ohana/src/getstar/src/getstar.c (modified) (1 diff)
-
Ohana/src/getstar/src/select_by_region.c (modified) (2 diffs)
-
Ohana/src/getstar/src/write_getstar_ps1_dev_0.c (modified) (3 diffs)
-
Ohana/src/getstar/src/write_getstar_ps1_dev_1.c (modified) (3 diffs)
-
Ohana/src/getstar/src/write_getstar_ps1_dev_2.c (modified) (3 diffs)
-
Ohana/src/kapa2/src/CheckPipe.c (modified) (2 diffs)
-
Ohana/src/kapa2/src/DrawObjects.c (modified) (1 diff)
-
Ohana/src/kapa2/src/EventLoop.c (modified) (3 diffs)
-
Ohana/src/kapa2/src/FlushDisplay.c (modified) (1 diff)
-
Ohana/src/kapa2/src/Refresh.c (modified) (1 diff)
-
Ohana/src/kapa2/src/bDrawObjects.c (modified) (1 diff)
-
Ohana/src/libautocode/Makefile.Targets (modified) (13 diffs)
-
Ohana/src/libautocode/def/average-ps1-dev-2.d (modified) (1 diff)
-
Ohana/src/libautocode/def/average-ps1-v1.d (modified) (1 diff)
-
Ohana/src/libautocode/def/average-ps1-v2.d (modified) (1 diff)
-
Ohana/src/libautocode/def/average-ps1-v3.d (modified) (1 diff)
-
Ohana/src/libautocode/def/average-ps1-v4.d (modified) (1 diff)
-
Ohana/src/libautocode/def/average-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/average-ps1-v5.d )
-
Ohana/src/libautocode/def/average.d (modified) (5 diffs)
-
Ohana/src/libautocode/def/cmf-ps1-dv4.d (copied) (copied from trunk/Ohana/src/libautocode/def/cmf-ps1-dv4.d )
-
Ohana/src/libautocode/def/cmf-ps1-sv3.d (copied) (copied from trunk/Ohana/src/libautocode/def/cmf-ps1-sv3.d )
-
Ohana/src/libautocode/def/cmf-ps1-v5-lensing.d (copied) (copied from trunk/Ohana/src/libautocode/def/cmf-ps1-v5-lensing.d )
-
Ohana/src/libautocode/def/cmf-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/cmf-ps1-v5.d )
-
Ohana/src/libautocode/def/common.h (modified) (1 diff)
-
Ohana/src/libautocode/def/image-ps1-v2.d (modified) (1 diff)
-
Ohana/src/libautocode/def/image-ps1-v3.d (modified) (1 diff)
-
Ohana/src/libautocode/def/image-ps1-v4.d (modified) (1 diff)
-
Ohana/src/libautocode/def/image-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/image-ps1-v5.d )
-
Ohana/src/libautocode/def/image.d (modified) (1 diff)
-
Ohana/src/libautocode/def/lensing-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/lensing-ps1-v5.d )
-
Ohana/src/libautocode/def/lensing.d (copied) (copied from trunk/Ohana/src/libautocode/def/lensing.d )
-
Ohana/src/libautocode/def/lensobj-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/lensobj-ps1-v5.d )
-
Ohana/src/libautocode/def/lensobj.d (copied) (copied from trunk/Ohana/src/libautocode/def/lensobj.d )
-
Ohana/src/libautocode/def/measure-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/measure-ps1-v5.d )
-
Ohana/src/libautocode/def/measure.d (modified) (8 diffs)
-
Ohana/src/libautocode/def/photcode-ps1-v2.d (modified) (1 diff)
-
Ohana/src/libautocode/def/photcode-ps1-v3.d (modified) (1 diff)
-
Ohana/src/libautocode/def/photcode-ps1-v4.d (modified) (1 diff)
-
Ohana/src/libautocode/def/photcode-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/photcode-ps1-v5.d )
-
Ohana/src/libautocode/def/photcode.d (modified) (1 diff)
-
Ohana/src/libautocode/def/secfilt-ps1-v1.d (modified) (1 diff)
-
Ohana/src/libautocode/def/secfilt-ps1-v2.d (modified) (1 diff)
-
Ohana/src/libautocode/def/secfilt-ps1-v3.d (modified) (1 diff)
-
Ohana/src/libautocode/def/secfilt-ps1-v4.d (modified) (2 diffs)
-
Ohana/src/libautocode/def/secfilt-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/secfilt-ps1-v5.d )
-
Ohana/src/libautocode/def/secfilt.d (modified) (1 diff)
-
Ohana/src/libautocode/doc/sizes.ps1-v5.txt (copied) (copied from trunk/Ohana/src/libautocode/doc/sizes.ps1-v5.txt )
-
Ohana/src/libdvo/Makefile (modified) (3 diffs)
-
Ohana/src/libdvo/doc/notes.ps1v5.txt (copied) (copied from trunk/Ohana/src/libdvo/doc/notes.ps1v5.txt )
-
Ohana/src/libdvo/include/cmf-ps1-sv3.h (copied) (copied from trunk/Ohana/src/libdvo/include/cmf-ps1-sv3.h )
-
Ohana/src/libdvo/include/cmf-ps1-v5-lensing.h (copied) (copied from trunk/Ohana/src/libdvo/include/cmf-ps1-v5-lensing.h )
-
Ohana/src/libdvo/include/cmf-ps1-v5.h (copied) (copied from trunk/Ohana/src/libdvo/include/cmf-ps1-v5.h )
-
Ohana/src/libdvo/include/dvo.h (modified) (22 diffs)
-
Ohana/src/libdvo/include/dvodb.h (modified) (8 diffs)
-
Ohana/src/libdvo/include/elixir_defs.h (modified) (1 diff)
-
Ohana/src/libdvo/include/loneos_defs.h (modified) (1 diff)
-
Ohana/src/libdvo/include/panstarrs_dev_0_defs.h (modified) (1 diff)
-
Ohana/src/libdvo/include/panstarrs_dev_1_defs.h (modified) (1 diff)
-
Ohana/src/libdvo/include/ps1_dev_1_defs.h (modified) (1 diff)
-
Ohana/src/libdvo/include/ps1_dev_2_defs.h (modified) (1 diff)
-
Ohana/src/libdvo/include/ps1_ref_defs.h (modified) (1 diff)
-
Ohana/src/libdvo/include/ps1_v1_defs.h (modified) (1 diff)
-
Ohana/src/libdvo/include/ps1_v2_defs.h (modified) (1 diff)
-
Ohana/src/libdvo/include/ps1_v3_defs.h (modified) (1 diff)
-
Ohana/src/libdvo/include/ps1_v4_defs.h (modified) (1 diff)
-
Ohana/src/libdvo/include/ps1_v5_defs.h (copied) (copied from trunk/Ohana/src/libdvo/include/ps1_v5_defs.h )
-
Ohana/src/libdvo/src/BoundaryTree.c (modified) (7 diffs)
-
Ohana/src/libdvo/src/ImageMetadata.c (modified) (1 diff)
-
Ohana/src/libdvo/src/LoadPhotcodesFITS.c (modified) (2 diffs)
-
Ohana/src/libdvo/src/LoadPhotcodesText.c (modified) (2 diffs)
-
Ohana/src/libdvo/src/SavePhotcodesFITS.c (modified) (1 diff)
-
Ohana/src/libdvo/src/TessellationTable.c (modified) (9 diffs)
-
Ohana/src/libdvo/src/cmf-ps1-dv3.c (modified) (1 diff)
-
Ohana/src/libdvo/src/cmf-ps1-sv3.c (copied) (copied from trunk/Ohana/src/libdvo/src/cmf-ps1-sv3.c )
-
Ohana/src/libdvo/src/cmf-ps1-v5-lensing.c (copied) (copied from trunk/Ohana/src/libdvo/src/cmf-ps1-v5-lensing.c )
-
Ohana/src/libdvo/src/cmf-ps1-v5.c (copied) (copied from trunk/Ohana/src/libdvo/src/cmf-ps1-v5.c )
-
Ohana/src/libdvo/src/dbExtractAverages.c (modified) (4 diffs)
-
Ohana/src/libdvo/src/dbExtractImages.c (modified) (7 diffs)
-
Ohana/src/libdvo/src/dbExtractMeasures.c (modified) (20 diffs)
-
Ohana/src/libdvo/src/dbFields.c (modified) (9 diffs)
-
Ohana/src/libdvo/src/dvo_catalog.c (modified) (21 diffs)
-
Ohana/src/libdvo/src/dvo_catalog_chipcoords.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_catalog_create.c (modified) (3 diffs)
-
Ohana/src/libdvo/src/dvo_catalog_mef.c (modified) (10 diffs)
-
Ohana/src/libdvo/src/dvo_catalog_raw.c (modified) (12 diffs)
-
Ohana/src/libdvo/src/dvo_catalog_split.c (modified) (27 diffs)
-
Ohana/src/libdvo/src/dvo_convert.c (modified) (17 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c (modified) (11 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c (modified) (13 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_DEV_3.c (modified) (3 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_REF.c (modified) (7 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_V1.c (modified) (12 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_V2.c (modified) (14 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_V3.c (modified) (15 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_V4.c (modified) (18 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_V5.c (copied) (copied from trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c )
-
Ohana/src/libdvo/src/dvo_convert_elixir.c (modified) (11 diffs)
-
Ohana/src/libdvo/src/dvo_convert_loneos.c (modified) (11 diffs)
-
Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c (modified) (9 diffs)
-
Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c (modified) (9 diffs)
-
Ohana/src/libdvo/src/dvo_image.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_image_raw.c (modified) (2 diffs)
-
Ohana/src/libdvo/src/dvo_photcode_ops.c (modified) (16 diffs)
-
Ohana/src/libdvo/src/dvo_tiny_values.c (modified) (1 diff)
-
Ohana/src/libdvo/src/skyregion_io.c (modified) (1 diff)
-
Ohana/src/libfits/include/gfitsio.h (modified) (1 diff)
-
Ohana/src/libfits/matrix/F_compress_M.c (modified) (2 diffs)
-
Ohana/src/libfits/table/F_get_column.c (modified) (1 diff)
-
Ohana/src/libfits/table/F_set_column.c (modified) (9 diffs)
-
Ohana/src/libfits/table/F_table_format.c (modified) (5 diffs)
-
Ohana/src/libkapa/src/KapaOpen.c (modified) (8 diffs)
-
Ohana/src/libohana/include/ohana.h (modified) (4 diffs)
-
Ohana/src/libohana/src (modified) (1 prop)
-
Ohana/src/libohana/src/string.c (modified) (13 diffs)
-
Ohana/src/opihi/cmd.astro/cplot.c (modified) (5 diffs)
-
Ohana/src/opihi/cmd.basic/Makefile (modified) (1 diff)
-
Ohana/src/opihi/cmd.basic/init.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.basic/list.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.basic/strmatch.c (copied) (copied from trunk/Ohana/src/opihi/cmd.basic/strmatch.c )
-
Ohana/src/opihi/cmd.data/Makefile (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/init.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.data/print_vectors.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/print_vectors.c )
-
Ohana/src/opihi/cmd.data/read_vectors.c (modified) (23 diffs)
-
Ohana/src/opihi/dvo/Makefile (modified) (2 diffs)
-
Ohana/src/opihi/dvo/avextract.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/avmatch.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/coordmosaic.c (copied) (copied from trunk/Ohana/src/opihi/dvo/coordmosaic.c )
-
Ohana/src/opihi/dvo/fitsed.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/gstar.c (modified) (21 diffs)
-
Ohana/src/opihi/dvo/hosts.c (modified) (5 diffs)
-
Ohana/src/opihi/dvo/imdata.c (modified) (4 diffs)
-
Ohana/src/opihi/dvo/imextract.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/init.c (modified) (2 diffs)
-
Ohana/src/opihi/dvo/lcurve.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/lightcurve.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/photcode_ops.c (copied) (copied from trunk/Ohana/src/opihi/dvo/photcode_ops.c )
-
Ohana/src/opihi/dvo/photometry.c (modified) (11 diffs)
-
Ohana/src/opihi/dvo/pmeasure.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/subpix.c (modified) (1 diff)
-
Ohana/src/opihi/include/dvomath.h (modified) (1 diff)
-
Ohana/src/opihi/include/dvoshell.h (modified) (1 diff)
-
Ohana/src/opihi/include/shell.h (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/VectorIO.c (modified) (3 diffs)
-
Ohana/src/opihi/lib.shell/string.c (modified) (1 diff)
-
Ohana/src/opihi/pcontrol/PclientCommand.c (modified) (5 diffs)
-
Ohana/src/photdbc/Makefile (modified) (2 diffs)
-
Ohana/src/photdbc/include/photdbc.h (modified) (3 diffs)
-
Ohana/src/photdbc/src/args.c (modified) (4 diffs)
-
Ohana/src/photdbc/src/copy_images.c (modified) (2 diffs)
-
Ohana/src/photdbc/src/get_mags.c (modified) (2 diffs)
-
Ohana/src/photdbc/src/initialize.c (modified) (2 diffs)
-
Ohana/src/photdbc/src/join_stars.c (modified) (5 diffs)
-
Ohana/src/photdbc/src/make_subcatalog.c (modified) (7 diffs)
-
Ohana/src/photdbc/src/photdbc.c (modified) (1 diff)
-
Ohana/src/photdbc/src/photdbc_catalogs.c (modified) (1 diff)
-
Ohana/src/photdbc/src/select_images.c (copied) (copied from trunk/Ohana/src/photdbc/src/select_images.c )
-
Ohana/src/relastro/Makefile (modified) (3 diffs)
-
Ohana/src/relastro/doc/pv2.txt (copied) (copied from trunk/Ohana/src/relastro/doc/pv2.txt )
-
Ohana/src/relastro/include/relastro.h (modified) (9 diffs)
-
Ohana/src/relastro/src/BrightCatalog.c (modified) (20 diffs)
-
Ohana/src/relastro/src/FitChip.c (modified) (7 diffs)
-
Ohana/src/relastro/src/GetAstromError.c (modified) (2 diffs)
-
Ohana/src/relastro/src/ImageOps.c (modified) (27 diffs)
-
Ohana/src/relastro/src/MeanPosIO.c (modified) (1 diff)
-
Ohana/src/relastro/src/MosaicOps.c (modified) (1 diff)
-
Ohana/src/relastro/src/ParFactor.c (modified) (1 diff)
-
Ohana/src/relastro/src/Shutdown.c (modified) (1 diff)
-
Ohana/src/relastro/src/UpdateObjectOffsets.c (modified) (1 diff)
-
Ohana/src/relastro/src/UpdateObjects.c (modified) (4 diffs)
-
Ohana/src/relastro/src/args.c (modified) (6 diffs)
-
Ohana/src/relastro/src/bcatalog.c (modified) (10 diffs)
-
Ohana/src/relastro/src/dvo_astrom_ops.c (modified) (3 diffs)
-
Ohana/src/relastro/src/extra.c (copied) (copied from trunk/Ohana/src/relastro/src/extra.c )
-
Ohana/src/relastro/src/high_speed_objects.c (modified) (2 diffs)
-
Ohana/src/relastro/src/hpm_objects.c (modified) (1 diff)
-
Ohana/src/relastro/src/initialize.c (modified) (2 diffs)
-
Ohana/src/relastro/src/launch_region_hosts.c (modified) (4 diffs)
-
Ohana/src/relastro/src/load_catalogs.c (modified) (9 diffs)
-
Ohana/src/relastro/src/markObjects.c (modified) (2 diffs)
-
Ohana/src/relastro/src/relastroVisual.c (modified) (2 diffs)
-
Ohana/src/relastro/src/relastro_client.c (modified) (1 diff)
-
Ohana/src/relastro/src/relastro_images.c (modified) (2 diffs)
-
Ohana/src/relastro/src/relastro_merge_source.c (modified) (1 diff)
-
Ohana/src/relastro/src/relastro_objects.c (modified) (1 diff)
-
Ohana/src/relastro/src/relastro_parallel_images.c (modified) (1 diff)
-
Ohana/src/relastro/src/share_mean_pos.c (modified) (1 diff)
-
Ohana/src/relastro/src/syncfile.c (modified) (1 diff)
-
Ohana/src/relphot/Makefile (modified) (2 diffs)
-
Ohana/src/relphot/doc/mosaic.txt (modified) (1 diff)
-
Ohana/src/relphot/doc/pv2.txt (copied) (copied from trunk/Ohana/src/relphot/doc/pv2.txt )
-
Ohana/src/relphot/include/relphot.h (modified) (8 diffs)
-
Ohana/src/relphot/src/BrightCatalog.c (modified) (13 diffs)
-
Ohana/src/relphot/src/GridOps.c (modified) (3 diffs)
-
Ohana/src/relphot/src/ImageMagIO.c (modified) (2 diffs)
-
Ohana/src/relphot/src/ImageOps.c (modified) (18 diffs)
-
Ohana/src/relphot/src/ImageSubset.c (modified) (2 diffs)
-
Ohana/src/relphot/src/MeanMagIO.c (modified) (6 diffs)
-
Ohana/src/relphot/src/MosaicOps.c (modified) (39 diffs)
-
Ohana/src/relphot/src/Shutdown.c (modified) (1 diff)
-
Ohana/src/relphot/src/StarOps.c (modified) (16 diffs)
-
Ohana/src/relphot/src/args.c (modified) (1 diff)
-
Ohana/src/relphot/src/assign_images.c (modified) (1 diff)
-
Ohana/src/relphot/src/bcatalog.c (modified) (10 diffs)
-
Ohana/src/relphot/src/extra.c (copied) (copied from trunk/Ohana/src/relphot/src/extra.c )
-
Ohana/src/relphot/src/initialize.c (modified) (4 diffs)
-
Ohana/src/relphot/src/launch_region_hosts.c (modified) (2 diffs)
-
Ohana/src/relphot/src/load_catalogs.c (modified) (5 diffs)
-
Ohana/src/relphot/src/plot_scatter.c (modified) (1 diff)
-
Ohana/src/relphot/src/relphot_client.c (modified) (1 diff)
-
Ohana/src/relphot/src/relphot_images.c (modified) (1 diff)
-
Ohana/src/relphot/src/relphot_parallel_images.c (modified) (2 diffs)
-
Ohana/src/relphot/src/relphot_parallel_regions.c (modified) (3 diffs)
-
Ohana/src/relphot/src/setExclusions.c (modified) (1 diff)
-
Ohana/src/relphot/src/setMrelCatalog.c (modified) (23 diffs)
-
Ohana/src/relphot/src/setMrelFinal.c (modified) (3 diffs)
-
Ohana/src/relphot/src/share_mean_mags.c (modified) (1 diff)
-
Ohana/src/relphot/src/syncfile.c (modified) (1 diff)
-
Ohana/src/tools/Makefile (modified) (1 diff)
-
Ohana/src/tools/src/ftable.c (modified) (1 diff)
-
Ohana/src/tools/src/random.c (copied) (copied from trunk/Ohana/src/tools/src/random.c )
-
Ohana/src/uniphot/src/ImageSubset.c (modified) (2 diffs)
-
Ohana/src/uniphot/src/ImageSubsetFixImageIDs.c (modified) (1 diff)
-
Ohana/src/uniphot/src/ImageSubsetFixStackIDs.c (modified) (1 diff)
-
Ohana/src/uniphot/src/ImageSubsetSetPosangle.c (modified) (1 diff)
-
Ohana/src/uniphot/src/load_images_fiximids.c (modified) (1 diff)
-
Ohana/src/uniphot/src/load_images_fixstkids.c (modified) (1 diff)
-
Ohana/src/uniphot/src/update_catalog_fiximids.c (modified) (2 diffs)
-
Ohana/src/uniphot/src/update_catalog_setastrom.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ps2-tc3-20130727
- Property svn:mergeinfo changed
-
branches/eam_branches/ps2-tc3-20130727/Ohana
- Property svn:mergeinfo changed
-
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/Makefile
r35263 r37403 78 78 $(SRC)/parse_time.$(ARCH).o \ 79 79 $(SRC)/replace_match.$(ARCH).o \ 80 $(SRC)/resort_catalog .$(ARCH).o \80 $(SRC)/resort_catalogs.$(ARCH).o \ 81 81 $(SRC)/resort_threaded.$(ARCH).o \ 82 82 $(SRC)/resort_unthreaded.$(ARCH).o \ 83 $(SRC)/resort_ unthreaded_catalogs.$(ARCH).o \83 $(SRC)/resort_catalog.$(ARCH).o \ 84 84 $(SRC)/StarOps.$(ARCH).o \ 85 85 $(SRC)/ReadStarsFITS.$(ARCH).o \ 86 86 $(SRC)/ReadStarsTEXT.$(ARCH).o \ 87 87 $(SRC)/ReadStarsSDSS.$(ARCH).o \ 88 $(SRC)/ReadXradFITS.$(ARCH).o \ 88 89 $(SRC)/FilterStars.$(ARCH).o \ 89 90 $(SRC)/ImageOptions.$(ARCH).o \ … … 105 106 $(SRC)/addstar_client.$(ARCH).o \ 106 107 $(SRC)/args_parallel_client.$(ARCH).o \ 107 $(SRC)/resort_catalog .$(ARCH).o \108 $(SRC)/resort_catalogs.$(ARCH).o \ 108 109 $(SRC)/resort_threaded.$(ARCH).o \ 109 110 $(SRC)/resort_unthreaded.$(ARCH).o \ 110 $(SRC)/resort_ unthreaded_catalogs.$(ARCH).o111 $(SRC)/resort_catalog.$(ARCH).o 111 112 112 113 ADDSTARD = \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/include/addstar.h
r35579 r37403 35 35 char *exthead; 36 36 char *extdata; 37 char *extxrad; 37 38 char *exttype; 38 39 int extnum_head; 39 40 int extnum_data; 41 int extnum_xrad; 40 42 } HeaderSet; 41 43 42 44 typedef struct { 43 Average average; 44 Measure measure; 45 Average average; 46 Measure measure; 47 Lensing *lensing; // optionally carry out the lensing measurements 45 48 int found; 46 49 } Stars; … … 145 148 146 149 int OLD_RESORT; 150 int READ_XRAD_DATA; 147 151 148 152 int PARALLEL; … … 236 240 Stars *rd_gsc PROTO((char *filename, unsigned int *nstars)); 237 241 int replace_match PROTO((Average *average, Measure *measure, Stars *star)); 238 int resort_threaded PROTO((AddstarClientOptions *options, SkyTable *sky)); 239 int resort_unthreaded PROTO((AddstarClientOptions *options, SkyTable *sky, int hostID, char *hostpath)); 240 int resort_unthreaded_catalogs PROTO((AddstarClientOptions *options, SkyList *skylist, int hostID, char *hostpath)); 242 int resort_catalogs PROTO((AddstarClientOptions *options, SkyTable *sky)); 243 int resort_catalogs_parallel PROTO((AddstarClientOptions *options, SkyList *sky)); 244 int resort_threaded PROTO((SkyList *skylist, int ForceSort)); 245 int resort_unthreaded PROTO((SkyList *skylist, int ForceSort)); 241 246 void resort_catalog PROTO((Catalog *catalog)); 242 247 void resort_catalog_old PROTO((Catalog *catalog)); 248 243 249 Stars *ReadStarsFITS PROTO((FILE *f, Header *header, Header *in_theader, unsigned int *nstars)); 244 250 Stars *ReadStarsTEXT PROTO((FILE *f, unsigned int *nstars)); … … 247 253 Stars *FilterStars PROTO((Stars *instars, Image *image, unsigned int imageID, const AddstarClientOptions *options)); 248 254 Stars *MergeStars PROTO((Stars *stars, unsigned int *Nstars, Stars *instars, unsigned int Ninstars)); 255 256 int ReadXradFITS PROTO((FILE *f, Header *theader, Stars *stars, unsigned int Nstars)); 257 249 258 double scat_subpix PROTO((double x, double y)); 250 259 void update_coords PROTO((Average *average, Measure *measure, off_t *next)); 251 260 off_t *init_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure)); 261 off_t *init_lensing_links PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing)); 252 262 off_t *init_missing_links PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing)); 253 off_t add_meas_link PROTO((Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE)); 254 off_t add_miss_link PROTO((Average *average, off_t *next_miss, off_t Nmissing)); 263 int add_meas_link PROTO((Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE)); 264 int add_miss_link PROTO((Average *average, off_t *next_miss, off_t Nmissing)); 265 int add_lens_link PROTO((Average *average, off_t *next_lens, off_t Nlensing, off_t NLENSING)); 255 266 off_t *build_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure)); 267 off_t *build_lensing_links PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing)); 256 268 Measure *sort_measure PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next_meas)); 257 269 Missing *sort_missing PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss)); 270 Lensing *sort_lensing PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next_lens)); 258 271 int ImageOptions PROTO((AddstarClientOptions *options, Image *images, off_t Nimages)); 259 272 int GetFileMode PROTO((Header *header)); … … 311 324 void *memrchr(const void *s, int c, size_t n); 312 325 int addstar_create_ID (); 326 int strextend (char *input, char *format,...); 313 327 314 328 /** -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/BoundaryTreeIO.c
r34260 r37403 1 1 # include "addstar.h" 2 3 /** this file is deprecated (functions moved to libdvo) ***/ 2 4 3 5 # define GET_COLUMN_NEW(OUT,NAME,TYPE) \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/FilterStars.c
r34260 r37403 9 9 10 10 // the imageID supplied here is the sequence **within this set** 11 // this value is updated based on the image table later 11 // this value is updated based on the image table later (in UpdateImageIDs) 12 12 Stars *FilterStars (Stars *instars, Image *image, unsigned int imageID, const AddstarClientOptions *options) { 13 13 … … 99 99 stars[N].measure.dFluxKron /= image[0].exptime; 100 100 } 101 if (!isnan(stars[N].measure.FluxAp)) { 102 stars[N].measure.FluxAp /= image[0].exptime; 103 } 104 if (!isnan(stars[N].measure.dFluxAp)) { 105 stars[N].measure.dFluxAp /= image[0].exptime; 106 } 101 107 102 108 // the external ID is supplied, but do we trust it? … … 120 126 121 127 stars[N].measure.imageID = imageID; // this value is updated in UpdateImageIDs 128 129 // add imageID to lensing entry, if it exists 130 if (stars[N].lensing) { 131 stars[N].lensing->imageID = imageID; 132 } 122 133 123 134 N ++; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/GetFileMode.c
r36680 r37403 10 10 int havePHOT_VER, haveTARG_VER; 11 11 12 // NOTE target of %t must be int length 12 13 gfits_scan_alt (header, "SIMPLE", "%t", 1, &simple); 13 14 int haveNaxis = gfits_scan (header, "NAXIS", "%d", 1, &Naxis); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/LoadData.c
r34088 r37403 83 83 continue; 84 84 } 85 86 // XRAD : if we want to read the xrad table, skip to that table here: 87 if (headerSets[i].extnum_xrad != -1) { 88 int Nxrad = headerSets[i].extnum_xrad; 89 Nskip = 0; 90 for (j = 0; j < Nxrad; j++) { 91 Nskip += extsize[j]; 92 } 93 fseeko (f, Nskip, SEEK_SET); 94 95 if (!ReadXradFITS (f, headers[Nxrad], inStars, images[0][Nvalid].nstar)) { 96 fprintf (stderr, "problem reading the radial flux data for %s\n", headerSets[i].extdata); 97 } 98 } 99 85 100 inStars = FilterStars (inStars, &images[0][Nvalid], Nvalid, options); 86 101 *stars = MergeStars (*stars, Nstars, inStars, images[0][Nvalid].nstar); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/MatchHeaders.c
r35416 r37403 59 59 if (!strcmp (exttype, "PS1_V3")) goto keep; 60 60 if (!strcmp (exttype, "PS1_V4")) goto keep; 61 if (!strcmp (exttype, "PS1_V5")) goto keep; 62 61 63 if (!strcmp (exttype, "PS1_SV1")) goto keep; 62 64 if (!strcmp (exttype, "PS1_SV2")) goto keep; 63 if (!strcmp (exttype, "PS1_DV3")) { 64 goto keep; 65 } 65 if (!strcmp (exttype, "PS1_SV3")) goto keep; 66 67 if (!strcmp (exttype, "PS1_DV1")) goto keep; 68 if (!strcmp (exttype, "PS1_DV2")) goto keep; 69 if (!strcmp (exttype, "PS1_DV3")) goto keep; 70 if (!strcmp (exttype, "PS1_DV4")) goto keep; 66 71 continue; 67 72 … … 74 79 headerSets[Nimage].extdata = strcreate (extname); 75 80 headerSets[Nimage].exthead = strcreate (exthead); 81 headerSets[Nimage].extxrad = NULL; 76 82 headerSets[Nimage].extnum_data = i; 77 83 headerSets[Nimage].extnum_head = -1; 84 headerSets[Nimage].extnum_xrad = -1; 85 86 // XXX a special case for fforce xrad data 87 if (READ_XRAD_DATA) { 88 // extname is foobar.psf, convert to foobar.xrad 89 int Nchar = strlen (extname); // foobar.psf : Nchar = 10 90 ALLOCATE (headerSets[Nimage].extxrad, char, Nchar + 2); // xrad is 1 longer than psf 91 memcpy (headerSets[Nimage].extxrad, extname, Nchar - 3); // Nchar - 3 = 7 92 memcpy (&headerSets[Nimage].extxrad[Nchar-3], "xrad", 4); 93 headerSets[Nimage].extxrad[Nchar + 1] = 0; // put the 0 at element 11 for foobar.xrad\0 94 } 78 95 79 96 // find the matching exthead entry 80 97 for (j = 0; j < Nheaders; j++) { 81 98 if (!gfits_scan (headers[j], ExtnameKeyword, "%s", 1, extname)) continue; 82 if (strcmp (extname, headerSets[Nimage].exthead)) continue; 83 headerSets[Nimage].extnum_head = j; 84 break; 99 if (!strcmp (extname, headerSets[Nimage].exthead)) { 100 headerSets[Nimage].extnum_head = j; 101 if (!READ_XRAD_DATA) break; 102 } 103 if (READ_XRAD_DATA && !strcmp (extname, headerSets[Nimage].extxrad)) { 104 headerSets[Nimage].extnum_xrad = j; 105 } 106 if ((headerSets[Nimage].extnum_head > -1) && (headerSets[Nimage].extnum_xrad > -1)) { 107 // we can only get here if READ_XRAD_DATA is true 108 break; 109 } 85 110 } 86 111 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/ReadImageHeader.c
r31395 r37403 44 44 image[0].NX = Nx; 45 45 image[0].NY = Ny; 46 47 image[0].refColorBlue = NAN; 48 image[0].refColorRed = NAN; 46 49 47 50 if (!gfits_scan (header, "TZERO", "%d", 1, &image[0].tzero) && !ACCEPT_TIME) { … … 133 136 134 137 tmp = 0; 135 gfits_scan (header, "FLIMIT", "%lf", 1, &tmp); 138 // gfits_scan (header, "FLIMIT", "%lf", 1, &tmp); 139 gfits_scan (header, "DETEFF.MAGREF", "%lf", 1, &tmp); 136 140 image[0].detection_limit = tmp * 10.0; 137 141 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/ReadStarsFITS.c
r35416 r37403 12 12 Stars *Convert_PS1_V3 PROTO((FTable *table, unsigned int *nstars)); 13 13 Stars *Convert_PS1_V4 PROTO((FTable *table, unsigned int *nstars)); 14 Stars *Convert_PS1_V5 PROTO((FTable *table, unsigned int *nstars)); 15 Stars *Convert_PS1_V5_Lensing PROTO((FTable *table, unsigned int *nstars)); 14 16 Stars *Convert_PS1_SV1 PROTO((FTable *table, unsigned int *nstars)); 15 17 Stars *Convert_PS1_SV1_Alt PROTO((FTable *table, unsigned int *nstars)); 16 18 Stars *Convert_PS1_SV2 PROTO((FTable *table, unsigned int *nstars)); 19 Stars *Convert_PS1_SV3 PROTO((FTable *table, unsigned int *nstars)); 17 20 Stars *Convert_PS1_DV3 PROTO((FTable *table, unsigned int *nstars)); 21 Stars *Convert_PS1_DV4 PROTO((FTable *table, unsigned int *nstars)); 18 22 19 23 // given a file with the pointer at the start of the table block and the … … 73 77 stars = Convert_PS1_V4 (&table, &Nstars); 74 78 } 79 if (!strcmp (type, "PS1_V5")) { 80 if (table.header[0].Naxis[0] == 312) { 81 stars = Convert_PS1_V5_Lensing (&table, &Nstars); 82 } else { 83 stars = Convert_PS1_V5 (&table, &Nstars); 84 } 85 } 75 86 if (!strcmp (type, "PS1_SV1")) { 76 87 stars = Convert_PS1_SV1 (&table, &Nstars); … … 79 90 stars = Convert_PS1_SV2 (&table, &Nstars); 80 91 } 92 if (!strcmp (type, "PS1_SV3")) { 93 stars = Convert_PS1_SV3 (&table, &Nstars); 94 } 81 95 if (!strcmp (type, "PS1_DV3")) { 82 96 stars = Convert_PS1_DV3 (&table, &Nstars); 83 97 } 98 if (!strcmp (type, "PS1_DV4")) { 99 stars = Convert_PS1_DV4 (&table, &Nstars); 100 } 84 101 if (stars == NULL) { 85 102 fprintf (stderr, "invalid table type %s\n", type); … … 91 108 92 109 return stars; 110 } 111 112 float GetFluxFromFluxOrMag (float flux, float mag) { 113 114 if (isnan(mag) && isnan(flux)) return NAN; 115 116 if (isnan(flux)) return pow(10.0,-0.4*mag); 117 return flux; 118 } 119 120 float GetFluxErrFromFluxOrMag (float dFlux, float flux, float dMag) { 121 122 if (isnan(dMag) && isnan(dFlux)) return NAN; 123 if (isnan(dFlux) && isnan(flux)) return NAN; 124 125 if (isnan(dFlux)) return (fabs(dMag * flux)); 126 return dFlux; 93 127 } 94 128 … … 148 182 stars[i].measure.psfNdof = NAN_S_INT; // not provided by SMPDATA: 149 183 stars[i].measure.psfNpix = NAN_S_INT; // not provided by SMPDATA: 150 stars[i].measure.crNsigma = NAN; // not provided by SMPDATA:151 184 stars[i].measure.extNsigma = NAN; // not provided by SMPDATA: 152 185 … … 217 250 stars[i].measure.psfNdof = NAN_S_INT; // not provided by PS1_DEV_0: 218 251 stars[i].measure.psfNpix = NAN_S_INT; // not provided by PS1_DEV_0: 219 stars[i].measure.crNsigma = NAN; // not provided by PS1_DEV_0:220 252 stars[i].measure.extNsigma = NAN; // not provided by PS1_DEV_0: 221 253 … … 289 321 stars[i].measure.psfNdof = NAN_S_INT; // not provided by PS1_DEV_1: 290 322 stars[i].measure.psfNpix = NAN_S_INT; // not provided by PS1_DEV_1: 291 stars[i].measure.crNsigma = ps1data[i].crNsigma;292 323 stars[i].measure.extNsigma = ps1data[i].extNsigma; 293 324 … … 360 391 stars[i].measure.dMcal = ps1data[i].dMcal; 361 392 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 393 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure 362 394 363 395 stars[i].measure.Mkron = NAN; // not provided by PS1_V1: … … 373 405 stars[i].measure.psfNdof = ps1data[i].psfNdof; 374 406 stars[i].measure.psfNpix = ps1data[i].psfNpix; 375 stars[i].measure.crNsigma = ps1data[i].crNsigma;376 407 stars[i].measure.extNsigma = ps1data[i].extNsigma; 377 408 … … 445 476 stars[i].measure.dMcal = ps1data[i].dMcal; 446 477 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 478 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure 447 479 448 480 stars[i].measure.Mkron = NAN; // not provided by PS1_V1_Alt: … … 458 490 stars[i].measure.psfNdof = ps1data[i].psfNdof; 459 491 stars[i].measure.psfNpix = ps1data[i].psfNpix; 460 stars[i].measure.crNsigma = ps1data[i].crNsigma;461 492 stars[i].measure.extNsigma = ps1data[i].extNsigma; 462 493 … … 522 553 stars[i].measure.dMcal = ps1data[i].dMcal; 523 554 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 555 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure 524 556 525 557 stars[i].measure.Mkron = NAN; // not provided by PS1_V2: … … 535 567 stars[i].measure.psfNdof = ps1data[i].psfNdof; 536 568 stars[i].measure.psfNpix = ps1data[i].psfNpix; 537 stars[i].measure.crNsigma = ps1data[i].crNsigma;538 569 stars[i].measure.extNsigma = ps1data[i].extNsigma; 539 570 … … 595 626 stars[i].measure.dMcal = ps1data[i].dMcal; 596 627 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 628 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure 597 629 598 630 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; … … 600 632 601 633 // these fluxes are converted from counts to counts/sec in FilterStars.c 602 stars[i].measure.FluxPSF = ps1data[i].Flux;603 stars[i].measure.dFluxPSF = ps1data[i].dFlux;634 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 635 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 604 636 stars[i].measure.FluxKron = ps1data[i].kronFlux; 605 637 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 638 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (NAN, ps1data[i].Map); 639 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (NAN, stars[i].measure.FluxAp, stars[i].measure.dMap); 606 640 607 641 stars[i].measure.Sky = ps1data[i].sky; … … 613 647 stars[i].measure.psfNdof = ps1data[i].psfNdof; 614 648 stars[i].measure.psfNpix = ps1data[i].psfNpix; 615 stars[i].measure.crNsigma = ps1data[i].crNsigma;616 649 stars[i].measure.extNsigma = ps1data[i].extNsigma; 617 650 … … 625 658 626 659 stars[i].measure.photFlags = ps1data[i].flags; 660 stars[i].measure.photFlags2 = ps1data[i].flags2; 627 661 628 662 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 676 710 stars[i].measure.dMcal = ps1data[i].dMcal; 677 711 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 712 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 678 713 679 714 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; … … 681 716 682 717 // these fluxes are converted from counts to counts/sec in FilterStars.c 683 stars[i].measure.FluxPSF = ps1data[i].Flux;684 stars[i].measure.dFluxPSF = ps1data[i].dFlux;718 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 719 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 685 720 stars[i].measure.FluxKron = ps1data[i].kronFlux; 686 721 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 722 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 723 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 687 724 688 725 stars[i].measure.Sky = ps1data[i].sky; … … 695 732 stars[i].measure.psfNdof = ps1data[i].psfNdof; 696 733 stars[i].measure.psfNpix = ps1data[i].psfNpix; 697 stars[i].measure.crNsigma = ps1data[i].crNsigma;698 734 stars[i].measure.extNsigma = ps1data[i].extNsigma; 699 735 … … 707 743 708 744 stars[i].measure.photFlags = ps1data[i].flags; 745 stars[i].measure.photFlags2 = ps1data[i].flags2; 709 746 710 747 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 724 761 } 725 762 726 Stars *Convert_PS1_ SV1(FTable *table, unsigned int *nstars) {763 Stars *Convert_PS1_V5 (FTable *table, unsigned int *nstars) { 727 764 728 765 off_t Nstars; … … 730 767 double ZeroPt; 731 768 Stars *stars; 732 CMF_PS1_SV1 *ps1data; 733 734 if (table[0].header[0].Naxis[0] == 196) { 735 stars = Convert_PS1_SV1_Alt (table, nstars); 736 return (stars); 737 } 738 739 ps1data = gfits_table_get_CMF_PS1_SV1 (table, &Nstars, NULL); 769 CMF_PS1_V5 *ps1data; 770 771 ps1data = gfits_table_get_CMF_PS1_V5 (table, &Nstars, NULL); 740 772 if (!ps1data) { 741 773 fprintf (stderr, "skipping inconsistent entry\n"); … … 763 795 stars[i].measure.dMcal = ps1data[i].dMcal; 764 796 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 797 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 765 798 766 799 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 767 800 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 768 801 769 802 // these fluxes are converted from counts to counts/sec in FilterStars.c 770 stars[i].measure.FluxPSF = ps1data[i].Flux;771 stars[i].measure.dFluxPSF = ps1data[i].dFlux;803 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 804 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 772 805 stars[i].measure.FluxKron = ps1data[i].kronFlux; 773 806 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 807 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 808 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 774 809 775 810 stars[i].measure.Sky = ps1data[i].sky; … … 782 817 stars[i].measure.psfNdof = ps1data[i].psfNdof; 783 818 stars[i].measure.psfNpix = ps1data[i].psfNpix; 784 stars[i].measure.crNsigma = ps1data[i].crNsigma;785 819 stars[i].measure.extNsigma = ps1data[i].extNsigma; 786 820 … … 794 828 795 829 stars[i].measure.photFlags = ps1data[i].flags; 830 stars[i].measure.photFlags2 = ps1data[i].flags2; 796 831 797 832 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 799 834 800 835 // the Average fields and the following Measure fields are set in FilterStars after 801 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID, 802 // averef is set in find_matches, dbFlags is zero on ingest. 836 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID. 837 838 // averef is set in find_matches 839 840 // dbFlags is zero on ingest. 803 841 804 842 // the following fields are currently not being set anywhere: t_msec … … 808 846 } 809 847 810 Stars *Convert_PS1_ SV1_Alt(FTable *table, unsigned int *nstars) {848 Stars *Convert_PS1_V5_Lensing (FTable *table, unsigned int *nstars) { 811 849 812 850 off_t Nstars; … … 814 852 double ZeroPt; 815 853 Stars *stars; 816 CMF_PS1_SV1 *ps1data; 817 818 // some test output files were produced called CMF_PS1_SV1 but with mismatch byte boundaries 819 820 ps1data = gfits_table_get_CMF_PS1_SV1_Alt (table, &Nstars, NULL); 854 CMF_PS1_V5_Lensing *ps1data; 855 856 ps1data = gfits_table_get_CMF_PS1_V5_Lensing (table, &Nstars, NULL); 821 857 if (!ps1data) { 822 858 fprintf (stderr, "skipping inconsistent entry\n"); … … 844 880 stars[i].measure.dMcal = ps1data[i].dMcal; 845 881 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 882 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 846 883 847 884 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 848 885 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 849 886 850 887 // these fluxes are converted from counts to counts/sec in FilterStars.c 851 stars[i].measure.FluxPSF = ps1data[i].Flux;852 stars[i].measure.dFluxPSF = ps1data[i].dFlux;888 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 889 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 853 890 stars[i].measure.FluxKron = ps1data[i].kronFlux; 854 891 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 892 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 893 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 894 895 stars[i].measure.Sky = ps1data[i].sky; 896 stars[i].measure.dSky = ps1data[i].dSky; 897 898 stars[i].measure.psfChisq = ps1data[i].psfChisq; 899 stars[i].measure.psfQF = ps1data[i].psfQF; 900 stars[i].measure.psfQFperf = ps1data[i].psfQFperf; 901 902 stars[i].measure.psfNdof = ps1data[i].psfNdof; 903 stars[i].measure.psfNpix = ps1data[i].psfNpix; 904 stars[i].measure.extNsigma = ps1data[i].extNsigma; 905 906 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 907 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 908 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 909 910 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx); 911 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy); 912 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy); 913 914 stars[i].measure.photFlags = ps1data[i].flags; 915 stars[i].measure.photFlags2 = ps1data[i].flags2; 916 917 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 918 stars[i].measure.detID = ps1data[i].detID; 919 920 ALLOCATE (stars[i].lensing, Lensing, 1); 921 dvo_lensing_init (stars[i].lensing); 922 923 stars[i].lensing->X11_sm_obj = ps1data[i].X11_sm_obj; 924 stars[i].lensing->X12_sm_obj = ps1data[i].X12_sm_obj; 925 stars[i].lensing->X22_sm_obj = ps1data[i].X22_sm_obj; 926 stars[i].lensing->E1_sm_obj = ps1data[i].E1_sm_obj; 927 stars[i].lensing->E2_sm_obj = ps1data[i].E2_sm_obj; 928 929 stars[i].lensing->X11_sh_obj = ps1data[i].X11_sh_obj; 930 stars[i].lensing->X12_sh_obj = ps1data[i].X12_sh_obj; 931 stars[i].lensing->X22_sh_obj = ps1data[i].X22_sh_obj; 932 stars[i].lensing->E1_sh_obj = ps1data[i].E1_sh_obj; 933 stars[i].lensing->E2_sh_obj = ps1data[i].E2_sh_obj; 934 935 stars[i].lensing->X11_sm_psf = ps1data[i].X11_sm_psf; 936 stars[i].lensing->X12_sm_psf = ps1data[i].X12_sm_psf; 937 stars[i].lensing->X22_sm_psf = ps1data[i].X22_sm_psf; 938 stars[i].lensing->E1_sm_psf = ps1data[i].E1_sm_psf; 939 stars[i].lensing->E2_sm_psf = ps1data[i].E2_sm_psf; 940 941 stars[i].lensing->X11_sh_psf = ps1data[i].X11_sh_psf; 942 stars[i].lensing->X12_sh_psf = ps1data[i].X12_sh_psf; 943 stars[i].lensing->X22_sh_psf = ps1data[i].X22_sh_psf; 944 stars[i].lensing->E1_sh_psf = ps1data[i].E1_sh_psf; 945 stars[i].lensing->E2_sh_psf = ps1data[i].E2_sh_psf; 946 947 // stars[i].lensing->F_ApR5 = ps1data[i].F_ApR5; 948 // stars[i].lensing->dF_ApR5 = ps1data[i].dF_ApR5; 949 // stars[i].lensing->sF_ApR5 = ps1data[i].sF_ApR5; 950 // stars[i].lensing->fF_ApR5 = ps1data[i].fF_ApR5; 951 // 952 // stars[i].lensing->F_ApR6 = ps1data[i].F_ApR6; 953 // stars[i].lensing->dF_ApR6 = ps1data[i].dF_ApR6; 954 // stars[i].lensing->sF_ApR6 = ps1data[i].sF_ApR6; 955 // stars[i].lensing->fF_ApR6 = ps1data[i].fF_ApR6; 956 957 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 958 stars[i].lensing->detID = ps1data[i].detID; 959 960 // the Average fields and the following Measure fields are set in FilterStars after 961 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID. 962 963 // averef is set in find_matches 964 965 // dbFlags is zero on ingest. 966 967 // the following fields are currently not being set anywhere: t_msec 968 } 969 *nstars = Nstars; 970 return (stars); 971 } 972 973 Stars *Convert_PS1_SV1 (FTable *table, unsigned int *nstars) { 974 975 off_t Nstars; 976 unsigned int i; 977 double ZeroPt; 978 Stars *stars; 979 CMF_PS1_SV1 *ps1data; 980 981 if (table[0].header[0].Naxis[0] == 196) { 982 stars = Convert_PS1_SV1_Alt (table, nstars); 983 return (stars); 984 } 985 986 ps1data = gfits_table_get_CMF_PS1_SV1 (table, &Nstars, NULL); 987 if (!ps1data) { 988 fprintf (stderr, "skipping inconsistent entry\n"); 989 return (NULL); 990 } 991 ZeroPt = GetZeroPoint(); 992 993 ALLOCATE (stars, Stars, Nstars); 994 for (i = 0; i < Nstars; i++) { 995 InitStar (&stars[i]); 996 stars[i].measure.Xccd = ps1data[i].X; 997 stars[i].measure.Yccd = ps1data[i].Y; 998 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX); 999 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY); 1000 1001 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle); 1002 stars[i].measure.pltscale = ps1data[i].pltscale; 1003 1004 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1005 stars[i].measure.M = NAN; 1006 } else { 1007 stars[i].measure.M = ps1data[i].M + ZeroPt; 1008 } 1009 stars[i].measure.dM = ps1data[i].dM; 1010 stars[i].measure.dMcal = ps1data[i].dMcal; 1011 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 1012 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure 1013 1014 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1015 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1016 1017 // these fluxes are converted from counts to counts/sec in FilterStars.c 1018 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1019 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 1020 stars[i].measure.FluxKron = ps1data[i].kronFlux; 1021 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1022 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (NAN, ps1data[i].Map); 1023 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (NAN, stars[i].measure.FluxAp, stars[i].measure.dMap); 1024 1025 stars[i].measure.Sky = ps1data[i].sky; 1026 stars[i].measure.dSky = ps1data[i].dSky; 1027 1028 stars[i].measure.psfChisq = ps1data[i].psfChisq; 1029 stars[i].measure.psfQF = ps1data[i].psfQF; 1030 stars[i].measure.psfQFperf = ps1data[i].psfQFperf; 1031 1032 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1033 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1034 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1035 1036 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 1037 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 1038 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 1039 1040 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx); 1041 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy); 1042 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy); 1043 1044 stars[i].measure.photFlags = ps1data[i].flags; 1045 stars[i].measure.photFlags2 = ps1data[i].flags2; 1046 1047 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1048 stars[i].measure.detID = ps1data[i].detID; 1049 1050 // the Average fields and the following Measure fields are set in FilterStars after 1051 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID, 1052 // averef is set in find_matches, dbFlags is zero on ingest. 1053 1054 // the following fields are currently not being set anywhere: t_msec 1055 } 1056 *nstars = Nstars; 1057 return (stars); 1058 } 1059 1060 Stars *Convert_PS1_SV1_Alt (FTable *table, unsigned int *nstars) { 1061 1062 off_t Nstars; 1063 unsigned int i; 1064 double ZeroPt; 1065 Stars *stars; 1066 CMF_PS1_SV1 *ps1data; 1067 1068 // some test output files were produced called CMF_PS1_SV1 but with mismatch byte boundaries 1069 1070 ps1data = gfits_table_get_CMF_PS1_SV1_Alt (table, &Nstars, NULL); 1071 if (!ps1data) { 1072 fprintf (stderr, "skipping inconsistent entry\n"); 1073 return (NULL); 1074 } 1075 ZeroPt = GetZeroPoint(); 1076 1077 ALLOCATE (stars, Stars, Nstars); 1078 for (i = 0; i < Nstars; i++) { 1079 InitStar (&stars[i]); 1080 stars[i].measure.Xccd = ps1data[i].X; 1081 stars[i].measure.Yccd = ps1data[i].Y; 1082 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX); 1083 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY); 1084 1085 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle); 1086 stars[i].measure.pltscale = ps1data[i].pltscale; 1087 1088 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1089 stars[i].measure.M = NAN; 1090 } else { 1091 stars[i].measure.M = ps1data[i].M + ZeroPt; 1092 } 1093 stars[i].measure.dM = ps1data[i].dM; 1094 stars[i].measure.dMcal = ps1data[i].dMcal; 1095 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 1096 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure 1097 1098 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1099 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1100 1101 // these fluxes are converted from counts to counts/sec in FilterStars.c 1102 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1103 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 1104 stars[i].measure.FluxKron = ps1data[i].kronFlux; 1105 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1106 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (NAN, ps1data[i].Map); 1107 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (NAN, stars[i].measure.FluxAp, stars[i].measure.dMap); 855 1108 856 1109 stars[i].measure.Sky = ps1data[i].sky; … … 861 1114 stars[i].measure.psfNdof = ps1data[i].psfNdof; 862 1115 stars[i].measure.psfNpix = ps1data[i].psfNpix; 863 stars[i].measure.crNsigma = ps1data[i].crNsigma;864 1116 stars[i].measure.extNsigma = ps1data[i].extNsigma; 865 1117 … … 873 1125 874 1126 stars[i].measure.photFlags = ps1data[i].flags; 1127 stars[i].measure.photFlags2 = ps1data[i].flags2; 875 1128 876 1129 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 921 1174 stars[i].measure.dMcal = ps1data[i].dMcal; 922 1175 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 1176 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 923 1177 924 1178 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; … … 926 1180 927 1181 // these fluxes are converted from counts to counts/sec in FilterStars.c 928 stars[i].measure.FluxPSF = ps1data[i].Flux;929 stars[i].measure.dFluxPSF = ps1data[i].dFlux;1182 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1183 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 930 1184 stars[i].measure.FluxKron = ps1data[i].kronFlux; 931 1185 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1186 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1187 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 932 1188 933 1189 stars[i].measure.Sky = ps1data[i].sky; … … 940 1196 stars[i].measure.psfNdof = ps1data[i].psfNdof; 941 1197 stars[i].measure.psfNpix = ps1data[i].psfNpix; 942 stars[i].measure.crNsigma = ps1data[i].crNsigma;943 1198 stars[i].measure.extNsigma = ps1data[i].extNsigma; 944 1199 … … 952 1207 953 1208 stars[i].measure.photFlags = ps1data[i].flags; 1209 stars[i].measure.photFlags2 = ps1data[i].flags2; 954 1210 955 1211 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 966 1222 } 967 1223 968 Stars *Convert_PS1_ DV3 (FTable *table, unsigned int *nstars) {1224 Stars *Convert_PS1_SV3 (FTable *table, unsigned int *nstars) { 969 1225 970 1226 off_t Nstars; … … 972 1228 double ZeroPt; 973 1229 Stars *stars; 974 CMF_PS1_ DV3 *ps1data;975 976 ps1data = gfits_table_get_CMF_PS1_ DV3 (table, &Nstars, NULL);1230 CMF_PS1_SV3 *ps1data; 1231 1232 ps1data = gfits_table_get_CMF_PS1_SV3 (table, &Nstars, NULL); 977 1233 if (!ps1data) { 978 1234 fprintf (stderr, "skipping inconsistent entry\n"); … … 1000 1256 stars[i].measure.dMcal = ps1data[i].dMcal; 1001 1257 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 1258 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1002 1259 1003 1260 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1004 1261 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1005 1262 1006 1263 // these fluxes are converted from counts to counts/sec in FilterStars.c 1007 stars[i].measure.FluxPSF = ps1data[i].Flux;1008 stars[i].measure.dFluxPSF = ps1data[i].dFlux;1264 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1265 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 1009 1266 stars[i].measure.FluxKron = ps1data[i].kronFlux; 1010 1267 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1268 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1269 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 1270 1271 stars[i].measure.Sky = ps1data[i].sky; 1272 stars[i].measure.dSky = ps1data[i].dSky; 1273 1274 stars[i].measure.psfChisq = ps1data[i].psfChisq; 1275 stars[i].measure.psfQF = ps1data[i].psfQF; 1276 stars[i].measure.psfQFperf = ps1data[i].psfQFperf; 1277 1278 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1279 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1280 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1281 1282 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 1283 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 1284 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 1285 1286 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx); 1287 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy); 1288 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy); 1289 1290 stars[i].measure.photFlags = ps1data[i].flags; 1291 stars[i].measure.photFlags2 = ps1data[i].flags2; 1292 1293 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1294 stars[i].measure.detID = ps1data[i].detID; 1295 1296 // the Average fields and the following Measure fields are set in FilterStars after 1297 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID, 1298 // averef is set in find_matches, dbFlags is zero on ingest. 1299 1300 // the following fields are currently not being set anywhere: t_msec 1301 } 1302 *nstars = Nstars; 1303 return (stars); 1304 } 1305 1306 Stars *Convert_PS1_DV3 (FTable *table, unsigned int *nstars) { 1307 1308 off_t Nstars; 1309 unsigned int i; 1310 double ZeroPt; 1311 Stars *stars; 1312 CMF_PS1_DV3 *ps1data; 1313 1314 ps1data = gfits_table_get_CMF_PS1_DV3 (table, &Nstars, NULL); 1315 if (!ps1data) { 1316 fprintf (stderr, "skipping inconsistent entry\n"); 1317 return (NULL); 1318 } 1319 ZeroPt = GetZeroPoint(); 1320 1321 ALLOCATE (stars, Stars, Nstars); 1322 for (i = 0; i < Nstars; i++) { 1323 InitStar (&stars[i]); 1324 stars[i].measure.Xccd = ps1data[i].X; 1325 stars[i].measure.Yccd = ps1data[i].Y; 1326 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX); 1327 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY); 1328 1329 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle); 1330 stars[i].measure.pltscale = ps1data[i].pltscale; 1331 1332 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1333 stars[i].measure.M = NAN; 1334 } else { 1335 stars[i].measure.M = ps1data[i].M + ZeroPt; 1336 } 1337 stars[i].measure.dM = ps1data[i].dM; 1338 stars[i].measure.dMcal = ps1data[i].dMcal; 1339 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 1340 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1341 1342 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1343 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1344 1345 // these fluxes are converted from counts to counts/sec in FilterStars.c 1346 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1347 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 1348 stars[i].measure.FluxKron = ps1data[i].kronFlux; 1349 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1350 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1351 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 1011 1352 1012 1353 stars[i].measure.Sky = ps1data[i].sky; … … 1018 1359 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1019 1360 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1020 stars[i].measure.crNsigma = ps1data[i].crNsigma;1021 1361 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1022 1362 … … 1030 1370 1031 1371 stars[i].measure.photFlags = ps1data[i].flags; 1372 stars[i].measure.photFlags2 = ps1data[i].flags2; 1032 1373 1033 1374 // this is may optionally be replaced by the internal sequence (see FilterStars.c) … … 1047 1388 } 1048 1389 1049 1050 1390 Stars *Convert_PS1_DV4 (FTable *table, unsigned int *nstars) { 1391 1392 off_t Nstars; 1393 unsigned int i; 1394 double ZeroPt; 1395 Stars *stars; 1396 CMF_PS1_DV4 *ps1data; 1397 1398 ps1data = gfits_table_get_CMF_PS1_DV4 (table, &Nstars, NULL); 1399 if (!ps1data) { 1400 fprintf (stderr, "skipping inconsistent entry\n"); 1401 return (NULL); 1402 } 1403 ZeroPt = GetZeroPoint(); 1404 1405 fprintf (stderr, "WARNING: Convert_PS1_DV4 not yet updated to match real format\n"); 1406 1407 ALLOCATE (stars, Stars, Nstars); 1408 for (i = 0; i < Nstars; i++) { 1409 InitStar (&stars[i]); 1410 stars[i].measure.Xccd = ps1data[i].X; 1411 stars[i].measure.Yccd = ps1data[i].Y; 1412 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX); 1413 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY); 1414 1415 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle); 1416 stars[i].measure.pltscale = ps1data[i].pltscale; 1417 1418 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1419 stars[i].measure.M = NAN; 1420 } else { 1421 stars[i].measure.M = ps1data[i].M + ZeroPt; 1422 } 1423 stars[i].measure.dM = ps1data[i].dM; 1424 stars[i].measure.dMcal = ps1data[i].dMcal; 1425 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 1426 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1427 1428 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1429 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1430 1431 // these fluxes are converted from counts to counts/sec in FilterStars.c 1432 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1433 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 1434 stars[i].measure.FluxKron = ps1data[i].kronFlux; 1435 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1436 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1437 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 1438 1439 stars[i].measure.Sky = ps1data[i].sky; 1440 stars[i].measure.dSky = ps1data[i].dSky; 1441 1442 stars[i].measure.psfChisq = ps1data[i].psfChisq; 1443 stars[i].measure.psfQF = ps1data[i].psfQF; 1444 stars[i].measure.psfQFperf = ps1data[i].psfQFperf; 1445 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1446 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1447 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1448 1449 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 1450 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 1451 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 1452 1453 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx); 1454 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy); 1455 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy); 1456 1457 stars[i].measure.photFlags = ps1data[i].flags; 1458 stars[i].measure.photFlags2 = ps1data[i].flags2; 1459 1460 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1461 stars[i].measure.detID = ps1data[i].detID; 1462 1463 // the Average fields and the following Measure fields are set in FilterStars after 1464 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID. 1465 1466 // averef is set in find_matches 1467 1468 // dbFlags is zero on ingest. 1469 1470 // the following fields are currently not being set anywhere: t_msec 1471 } 1472 *nstars = Nstars; 1473 return (stars); 1474 } 1475 1476 1477 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/SEDfit.c
r34405 r37403 162 162 } 163 163 164 double R = incat[0].average[i].R; 165 double D = incat[0].average[i].D; 166 164 167 for (j = 0; valid && (j < Nmodel); j++) { 165 168 n = modelRow[j]; 166 169 dvo_measure_init (&outcat[0].measure[Nmeas]); 167 outcat[0].measure[Nmeas]. dR = 0.0;168 outcat[0].measure[Nmeas]. dD = 0.0;170 outcat[0].measure[Nmeas].R = R; 171 outcat[0].measure[Nmeas].D = D; 169 172 outcat[0].measure[Nmeas].M = table[0].row[minFit.row][0].mags[n] + minFit.Md; 170 173 outcat[0].measure[Nmeas].dM = 0.0; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/StarOps.c
r34260 r37403 8 8 star[0].found = -1; // found == -1 -> not yet found (use enums?) 9 9 10 star[0].lensing = NULL; // we only populate this if needed 10 11 return TRUE; 11 12 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/UpdateImageIDs.c
r35579 r37403 55 55 for (i = 0; i < Nstars; i++) { 56 56 stars[i].measure.imageID += imageID; 57 if (stars[i].lensing) { 58 stars[i].lensing->imageID += imageID; 59 } 57 60 } 58 61 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/addstar.c
r34405 r37403 1 1 # include "addstar.h" 2 3 # define RESETTIME { gettimeofday (&startTimer, (void *) NULL); } 2 4 3 5 // LARGEFILES: this program currently limits Nstars (input file) to < 2^31 … … 7 9 int Nmatch, status, loadObjects; 8 10 off_t i, Nimages; 9 off_t Naverage, Nmeasure ;11 off_t Naverage, Nmeasure, Nlensing; 10 12 Stars *stars, **subset; 11 13 Image *images; … … 18 20 SkyList *newlist = NULL; 19 21 20 double dtime;21 struct timeval start, stop;22 23 gettimeofday (&start, NULL);22 struct timeval startAddstar, stopAddstar; 23 gettimeofday (&startAddstar, (void *) NULL); 24 25 INITTIME; 24 26 25 27 SetSignals (); … … 40 42 41 43 if (options.mode == ADDSTAR_MODE_RESORT) { 42 if (NTHREADS == 0) { 43 resort_unthreaded (&options, sky, 0, NULL); 44 } else { 45 resort_threaded (&options, sky); 46 } 44 resort_catalogs (&options, sky); 47 45 exit (0); 48 46 } 47 48 MARKTIME ("init and config: %f sec\n", dtime); RESETTIME; 49 49 50 50 stars = NULL; … … 54 54 case ADDSTAR_MODE_IMAGE: 55 55 stars = LoadStars (argv[1], &Nstars, &images, &Nimages, &options); 56 MARKTIME ("load smf: %f sec\n", dtime); RESETTIME; 56 57 57 58 // set and update the imageID sequence … … 71 72 skylist = SkyListForStars (sky, -1, stars, Nstars); 72 73 break; 73 case ADDSTAR_MODE_RESORT:74 74 case ADDSTAR_MODE_REFCAT: 75 75 skylist = SkyListByPatch (sky, -1, &UserPatch); … … 100 100 101 101 /* match stars to existing catalog data (or otherwise manipulate catalog data) */ 102 Nmatch = Naverage = Nmeasure = 0;102 Nmatch = Naverage = Nmeasure = Nlensing = 0; 103 103 for (i = 0; loadObjects && (i < skylist[0].Nregions); i++) { 104 104 … … 107 107 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 108 108 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 109 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF ;109 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF | LOAD_LENSING; 110 110 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 111 111 … … 132 132 } 133 133 } 134 MARKTIME ("load cpt: %f sec\n", dtime); RESETTIME; 134 135 135 136 // Naves_disk == 0 implies an empty catalog file … … 161 162 if (Nsubset) free (subset); 162 163 break; 163 case ADDSTAR_MODE_RESORT: 164 if (options.nosort == 3) catalog.sorted = FALSE; 165 166 // no need to resort empty catalogs 167 if (catalog.Naves_disk == 0) { 168 dvo_catalog_unlock (&catalog); 169 dvo_catalog_free (&catalog); 170 continue; 171 } 172 173 if (OLD_RESORT) { 174 resort_catalog_old (&catalog); 175 } else { 176 resort_catalog (&catalog); 177 } 178 Nsubset = 1; 179 break; 180 } 164 } 165 MARKTIME ("match stars: %f sec\n", dtime); RESETTIME; 166 181 167 /* report total updated values */ 182 168 Naverage += catalog.Naverage; 183 169 Nmeasure += catalog.Nmeasure; 170 Nlensing += catalog.Nlensing; 184 171 185 172 // write out catalog, if appropriate … … 187 174 SetProtect (TRUE); 188 175 if (options.update) { 189 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF ;176 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF | LOAD_LENSING; 190 177 dvo_catalog_update (&catalog, VERBOSE); 191 178 } else { … … 196 183 dvo_catalog_unlock (&catalog); 197 184 dvo_catalog_free (&catalog); 185 MARKTIME ("save cpt: %f sec\n", dtime); RESETTIME; 198 186 199 187 if (options.mode == ADDSTAR_MODE_REFCAT) free (stars); … … 229 217 dvo_image_unlock (&db); /* unlock? */ 230 218 231 gettimeofday (&stop ,NULL);232 dtime = DTIME (stop, start);233 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for %5d stars (%5d matches), "OFF_T_FMT" average, "OFF_T_FMT" measure \n", dtime, Nstars, Nmatch, Naverage, Nmeasure);219 gettimeofday (&stopAddstar, (void *) NULL); 220 float dtime = DTIME (stopAddstar, startAddstar); 221 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for %5d stars (%5d matches), "OFF_T_FMT" average, "OFF_T_FMT" measure, "OFF_T_FMT" lensing\n", dtime, Nstars, Nmatch, Naverage, Nmeasure, Nlensing); 234 222 235 223 exit (0); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/addstar_client.c
r33963 r37403 25 25 26 26 if (options.mode == ADDSTAR_MODE_RESORT) { 27 resort_ unthreaded (&options, sky, HOST_ID, HOSTDIR);27 resort_catalogs (&options, sky); 28 28 exit (0); 29 29 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/args.c
r35760 r37403 34 34 remove_argument (N, &argc, argv); 35 35 } 36 OLD_RESORT = FALSE; 37 if ((N = get_argument (argc, argv, "-old-resort"))) { 38 remove_argument (N, &argc, argv); 39 OLD_RESORT = TRUE; 40 } 41 36 42 if ((N = get_argument (argc, argv, "-create-id"))) { 37 43 options.mode = ADDSTAR_MODE_CREATE_ID; … … 75 81 PMM_CCD_TABLE = strcreate (argv[N]); 76 82 remove_argument (N, &argc, argv); 83 } 84 85 READ_XRAD_DATA = FALSE; 86 if ((N = get_argument (argc, argv, "-xrad"))) { 87 remove_argument (N, &argc, argv); 88 READ_XRAD_DATA = TRUE; 77 89 } 78 90 … … 350 362 // XXX for the moment, make this selection manual. it needs to be automatic 351 363 // based on the state of the SkyTable 364 HOST_ID = 0; 365 HOSTDIR = NULL; 352 366 PARALLEL = FALSE; 353 367 if ((N = get_argument (argc, argv, "-parallel"))) { … … 466 480 } 467 481 482 int strextend (char *input, char *format,...) { 483 484 char tmpextra[1024], tmpline[1024]; 485 va_list argp; 486 487 va_start (argp, format); 488 vsnprintf (tmpextra, 1024, format, argp); 489 snprintf (tmpline, 1024, "%s %s", input, tmpextra); 490 strcpy (input, tmpline); 491 492 return TRUE; 493 } 494 468 495 /** addstar modes: 469 496 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/args_parallel_client.c
r33963 r37403 87 87 } 88 88 89 OLD_RESORT = FALSE; 90 if ((N = get_argument (argc, argv, "-old-resort"))) { 91 remove_argument (N, &argc, argv); 92 OLD_RESORT = TRUE; 93 } 94 89 95 /* extra error messages */ 90 96 VERBOSE = FALSE; … … 118 124 exit (2); 119 125 } 126 127 int strextend (char *input, char *format,...) { 128 129 char tmpextra[1024], tmpline[1024]; 130 va_list argp; 131 132 va_start (argp, format); 133 vsnprintf (tmpextra, 1024, format, argp); 134 snprintf (tmpline, 1024, "%s %s", input, tmpextra); 135 strcpy (input, tmpline); 136 137 return TRUE; 138 } 139 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/build_links.c
r27435 r37403 1 1 # include "addstar.h" 2 3 # define myAbortF(FORMAT,...) { fprintf (stderr, FORMAT, __VA_ARGS__); abort(); } 2 4 3 5 /* … … 47 49 48 50 if (N >= Nmeasure) { 49 fprintf (stderr, "overflow in init_measure_links\n"); 50 abort (); 51 myAbort ("overflow in init_measure_links\n"); 51 52 } 52 53 } … … 102 103 103 104 /* average[].measureOffset, average[].Nmeasure are valid within an addstar run */ 104 off_t add_meas_link (Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE) {105 int add_meas_link (Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE) { 105 106 106 107 off_t k, m; … … 134 135 } 135 136 136 /* Missing does not carry enough information to reconstruct the links137 we must always save the missing table, if it exists */138 139 137 Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next_meas) { 140 138 141 off_t i, k, n, N;139 int i, k, n, N; 142 140 Measure *tmpmeasure; 143 141 … … 149 147 average[i].measureOffset = N; 150 148 for (k = 0; k < average[i].Nmeasure; k++, N++) { 151 if (n == -1) abort();149 if (n == -1) myAbortF("invalid measureOffset for ave %d, measureOffset %d, measure %d\n", i, average[i].measureOffset, k); 152 150 tmpmeasure[N] = measure[n]; 153 if (measure[n].averef != i) abort();151 if (measure[n].averef != i) myAbortF("invalid averef for ave %d, measureOffset %d, measure %d, averef %d\n", i, average[i].measureOffset, k, measure[n].averef); 154 152 tmpmeasure[N].averef = i; 155 153 n = next_meas[n]; … … 159 157 return (tmpmeasure); 160 158 } 159 160 /*******************************************************************************************/ 161 161 162 162 /* build the initial links assuming the table is sorted */ … … 176 176 next_miss[N] = -1; 177 177 if (N >= Nmissing) { 178 fprintf (stderr, "overflow in init_missing_links"); 179 abort (); 178 myAbort ("overflow in init_missing_links"); 180 179 } 181 180 N++; … … 186 185 } 187 186 188 off_t add_miss_link (Average *average, off_t *next_miss, off_t Nmissing) {187 int add_miss_link (Average *average, off_t *next_miss, off_t Nmissing) { 189 188 190 189 off_t k, m; … … 205 204 } 206 205 206 /* Missing does not carry enough information to reconstruct the links 207 we must always save the missing table, if it exists */ 208 207 209 Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss) { 208 210 … … 225 227 } 226 228 229 /*******************************************************************************************/ 230 231 /* build the initial links assuming the table is sorted, 232 not partial, and has a correct set of average[].lensingOffset,Nlensing values */ 233 off_t *init_lensing_links (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing) { 234 235 off_t i, j, N; 236 off_t *next_lens; 237 238 N = 0; 239 240 ALLOCATE (next_lens, off_t, Nlensing); 241 for (i = 0; i < Naverage; i++) { 242 if (!average[i].Nlensing) continue; 243 for (j = 0; j < average[i].Nlensing - 1; j++, N++) { 244 next_lens[N] = N + 1; 245 if (N >= Nlensing) { 246 fprintf (stderr, "WARNING: N out of bounds (1)\n"); 247 } 248 } 249 next_lens[N] = -1; 250 if (N >= Nlensing) { 251 fprintf (stderr, "WARNING: N out of bounds (2)\n"); 252 } 253 254 if (N >= Nlensing) { 255 myAbort ("overflow in init_lensing_links\n"); 256 } 257 N++; 258 } 259 return (next_lens); 260 } 261 262 /* construct lensing links which are valid FOR THIS LOAD 263 * - if we have a full load, we will get links which can 264 * be used by other programs (eg, relphot, etc) 265 * - if we have a partial load, the links are only valid 266 * for that partial load 267 */ 268 269 off_t *build_lensing_links (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing) { 270 271 off_t i, m, k, Nm, averef; 272 off_t *next_lens; 273 274 ALLOCATE (next_lens, off_t, Nlensing); 275 276 /* reset the Nm, offset values for average */ 277 for (i = 0; i < Naverage; i++) { 278 average[i].lensingOffset = -1; 279 average[i].Nlensing = 0; 280 } 281 282 for (Nm = 0; Nm < Nlensing; Nm++) { 283 averef = lensing[Nm].averef; 284 m = average[averef].lensingOffset; 285 next_lens[Nm] = -1; 286 287 if (m == -1) { /* no links yet for source */ 288 average[averef].lensingOffset = Nm; 289 average[averef].Nlensing = 1; 290 continue; 291 } 292 293 for (k = 0; next_lens[m] != -1; k++) { 294 m = next_lens[m]; 295 if (m >= Nlensing) { 296 fprintf (stderr, "WARNING: m out of bounds (1)\n"); 297 } 298 } 299 300 average[averef].Nlensing = k + 2; 301 next_lens[m] = Nm; 302 if (m >= Nlensing) { 303 fprintf (stderr, "WARNING: m out of bounds (2)\n"); 304 } 305 } 306 return (next_lens); 307 } 308 309 /* average[].lensingOffset, average[].Nlensing are valid within an addstar run */ 310 int add_lens_link (Average *average, off_t *next_lens, off_t Nlensing, off_t NLENSING) { 311 312 off_t k, m; 313 314 /* if we have trouble, check validity of next_lens[m] : m < Nlensing */ 315 m = average[0].lensingOffset; 316 317 for (k = 0; k < average[0].Nlensing - 1; k++) { 318 m = next_lens[m]; 319 if (m >= NLENSING) { 320 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 321 } 322 } 323 324 /* set up references */ 325 next_lens[Nlensing] = -1; 326 if (Nlensing >= NLENSING) { 327 fprintf (stderr, "WARNING: Nlensing out of bounds (1)\n"); 328 } 329 330 if (m == -1) { 331 average[0].lensingOffset = Nlensing; 332 } else { 333 next_lens[m] = Nlensing; 334 if (m >= NLENSING) { 335 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 336 } 337 } 338 339 return (TRUE); 340 } 341 342 Lensing *sort_lensing (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next_lens) { 343 344 int i, k, n, N; 345 Lensing *tmplensing; 346 347 /* fix order of Lensing (memory intensive, but fast) */ 348 N = 0; 349 ALLOCATE (tmplensing, Lensing, Nlensing); 350 for (i = 0; i < Naverage; i++) { 351 if (!average[i].Nlensing) continue; 352 n = average[i].lensingOffset; 353 average[i].lensingOffset = N; 354 for (k = 0; k < average[i].Nlensing; k++, N++) { 355 if (n == -1) myAbortF("invalid lensingOffset for ave %d, lensingOffset %d, lensing %d\n", i, average[i].lensingOffset, k); 356 tmplensing[N] = lensing[n]; 357 if (lensing[n].averef != i) myAbortF("invalid averef for ave %d, lensingOffset %d, lensing %d, averef %d\n", i, average[i].lensingOffset, k, lensing[n].averef); 358 tmplensing[N].averef = i; 359 n = next_lens[n]; 360 } 361 } 362 free (lensing); 363 return (tmplensing); 364 } 365 366 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/fakeimage.c
r36680 r37403 6 6 double pltscale, pixscale; 7 7 double Rmin, Rmax, Dmin, Dmax; 8 // double Xmin, Xmax, Ymin, Ymax;9 8 double dX, dY, r, d; 10 9 char chipname[80], chipdata[256], name[80]; … … 168 167 image[0].cerror = 0.0; 169 168 170 // RD_to_XY (&Xmax, &Ymax, Rmax, Dmax, MOSAIC);171 // RD_to_XY (&Xmin, &Ymin, Rmin, Dmin, MOSAIC);172 169 image[0].NX = Rmax - Rmin; 173 170 image[0].NY = Dmax - Dmin; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/find_matches.c
r36680 r37403 14 14 15 15 if (NSTAR_GROUP <= 0) { 16 fprintf (stderr, "ERROR: NSTAR_GROUP NOT SET!\n");17 exit (1);16 fprintf (stderr, "ERROR: NSTAR_GROUP NOT SET!\n"); 17 exit (1); 18 18 } 19 19 … … 36 36 ALLOCATE (Y2, double, NAVE); 37 37 ALLOCATE (N2, off_t, NAVE); 38 ALLOCATE (catalog[0].found , off_t, NAVE);38 ALLOCATE (catalog[0].found_t, off_t, NAVE); 39 39 /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */ 40 40 … … 77 77 if (Nstars < 1) { 78 78 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", catalog[0].filename); 79 free (catalog[0].found);80 79 free (X1); 81 80 free (Y1); … … 92 91 RD_to_XY (&X2[i], &Y2[i], catalog[0].average[i].R, catalog[0].average[i].D, &tcoords); 93 92 N2[i] = i; 94 catalog[0].found [N2[i]] = -1;93 catalog[0].found_t[N2[i]] = -1; 95 94 } 96 95 if (Nave > 1) sort_coords_index (X2, Y2, N2, Nave); … … 160 159 161 160 // the following measure elements cannot be set until here: 162 catalog[0].measure[Nmeas]. dR = 3600.0*(catalog[0].average[n].R - stars[N].average.R);163 catalog[0].measure[Nmeas]. dD = 3600.0*(catalog[0].average[n].D - stars[N].average.D);161 catalog[0].measure[Nmeas].R = stars[N].average.R; 162 catalog[0].measure[Nmeas].D = stars[N].average.D; 164 163 catalog[0].measure[Nmeas].dbFlags = 0; 165 164 catalog[0].measure[Nmeas].averef = n; // this must be an absolute sequence number, if partial average is loaded … … 167 166 catalog[0].measure[Nmeas].catID = catalog[0].catID; 168 167 169 // rationalize dR: 170 if (catalog[0].measure[Nmeas].dR > +180.0*3600.0) { 171 // average on high end of boundary, move star up 172 stars[N].average.R += 360.0; 173 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N].average.R); 174 } 175 if (catalog[0].measure[Nmeas].dR < -180.0*3600.0) { 176 // average on low end of boundary, move star down 177 stars[N].average.R -= 360.0; 178 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N].average.R); 179 } 180 if (fabs(catalog[0].measure[Nmeas].dR) > 10*RADIUS) { 168 float dRoff = dvoOffsetR(&catalog[0].measure[Nmeas], &catalog[0].average[n]); 169 170 // rationalize R: 171 if (dRoff > +180.0*3600.0) { 172 // average on high end of boundary, move star up 173 catalog[0].measure[Nmeas].R += 360.0; 174 dRoff -= 360.0*3600.0; 175 } 176 if (dRoff < -180.0*3600.0) { 177 // average on low end of boundary, move star down 178 catalog[0].measure[Nmeas].R -= 360.0; 179 dRoff += 360.0*3600.0; 180 } 181 if (fabs(dRoff) > 10*RADIUS) { 182 // take declination into account and check again. 183 double cosD = cos(RAD_DEG*catalog[0].average[n].D); 184 if (fabs(dRoff*cosD) > 10*RADIUS) { 181 185 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 182 186 catalog[0].average[n].R, catalog[0].average[n].D, … … 184 188 X1[i], X2[J], 185 189 Y1[i], Y2[J]); 190 } 186 191 } 187 192 … … 196 201 if (Nsec > -1) { 197 202 if (isnan(catalog[0].secfilt[n*Nsecfilt+Nsec].M)) { 198 catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas] );203 catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas], MAG_CLASS_PSF); 199 204 } 200 205 } … … 213 218 } 214 219 /* this catalog star matches more than one image star */ 215 if (catalog[0].found [n] > -1) {216 catalog[0].measure[catalog[0].found [n]].dbFlags |= ID_MEAS_BLEND_OBJ;220 if (catalog[0].found_t[n] > -1) { 221 catalog[0].measure[catalog[0].found_t[n]].dbFlags |= ID_MEAS_BLEND_OBJ; 217 222 catalog[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_OBJ; 218 223 } else { 219 catalog[0].found [n] = Nmeas;224 catalog[0].found_t[n] = Nmeas; 220 225 } 221 226 /* Nm is updated, but not written out in -update mode (for existing entries) … … 232 237 } 233 238 234 /* incorporate unmatched image stars, if this star is in field of this catalog */235 /* these new entries are all written out in UPDATE mode */239 /* incorporate unmatched image stars, if this star is in field of this catalog */ 240 /* these new entries are all written out in UPDATE mode */ 236 241 for (i = 0; (i < Nstars) && !options.only_match; i += NSTAR_GROUP) { 237 242 /* make sure there is space for next entry */ … … 260 265 261 266 if (PSPS_ID) { 262 catalog[0].average[Nave].extID = CreatePSPSObjectID(catalog[0].average[Nave].R, catalog[0].average[Nave].D);267 catalog[0].average[Nave].extID = CreatePSPSObjectID(catalog[0].average[Nave].R, catalog[0].average[Nave].D); 263 268 } 264 269 … … 274 279 275 280 // the following measure elements cannot be set until here: 276 catalog[0].measure[Nmeas]. dR = 0.0;277 catalog[0].measure[Nmeas]. dD = 0.0;281 catalog[0].measure[Nmeas].R = stars[i].average.R; 282 catalog[0].measure[Nmeas].D = stars[i].average.D; 278 283 catalog[0].measure[Nmeas].dbFlags = 0; 279 284 catalog[0].measure[Nmeas].averef = Nave; // XXX EAM : must be absolute Nave if partial read … … 284 289 /* in UPDATE mode, this value is not saved; use relphot to recalculate */ 285 290 if (Nsec > -1) { 286 catalog[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas]);291 catalog[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas], MAG_CLASS_PSF); 287 292 } 288 293 289 294 /* next[Nmeas] should always be -1 in this context (it is always the only 290 measurement for the star) */295 measurement for the star) */ 291 296 stars[i].found = Nmeas; 292 297 next_meas[Nmeas] = -1; // initial value here update below … … 309 314 } 310 315 311 /* note stars which have been found in this catalog */316 /* note stars which have been found in this catalog */ 312 317 for (i = 0; i < NstarsIn; i++) { 313 318 if (stars[i].found > -1) { … … 316 321 } 317 322 318 /* check if the catalog has changed? if no change, no need to write */323 /* check if the catalog has changed? if no change, no need to write */ 319 324 catalog[0].objID = objID; // new max value, save on catalog close 320 325 catalog[0].Naverage = Nave; … … 323 328 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas, Nmatch); 324 329 325 free (catalog[0].found);326 330 free (X1); 327 331 free (Y1); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/find_matches_closest.c
r36680 r37403 7 7 double *X1, *Y1, *X2, *Y2; 8 8 double dX, dY, dR; 9 off_t *N1, *N2, *next_meas ;10 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch ;9 off_t *N1, *N2, *next_meas, *next_lens; 10 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch, Nlens, NLENS; 11 11 int Nsecfilt, Nsec; 12 12 unsigned int objID, catID; … … 36 36 ALLOCATE (Y2, double, NAVE); 37 37 ALLOCATE (N2, off_t, NAVE); 38 ALLOCATE (catalog[0].found , off_t, NAVE);38 ALLOCATE (catalog[0].found_t, off_t, NAVE); 39 39 /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */ 40 40 … … 42 42 Nmatch = 0; 43 43 NMEAS = Nmeas = catalog[0].Nmeasure; 44 NLENS = Nlens = catalog[0].Nlensing; 44 45 45 46 // current max obj ID for this catalog … … 76 77 if (Nstars < 1) { 77 78 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", catalog[0].filename); 78 free (catalog[0].found);79 79 free (X1); 80 80 free (Y1); … … 91 91 RD_to_XY (&X2[i], &Y2[i], catalog[0].average[i].R, catalog[0].average[i].D, &tcoords); 92 92 N2[i] = i; 93 catalog[0].found [N2[i]] = -1;93 catalog[0].found_t[N2[i]] = -1; 94 94 } 95 95 if (Nave > 1) sort_coords_index (X2, Y2, N2, Nave); … … 100 100 // is sorted while processed 101 101 next_meas = init_measure_links (catalog[0].average, Nave, catalog[0].measure, Nmeas); 102 next_lens = init_lensing_links (catalog[0].average, Nave, catalog[0].lensing, Nlens); 102 103 } else { 103 104 next_meas = build_measure_links (catalog[0].average, Nave, catalog[0].measure, Nmeas); 105 next_lens = build_lensing_links (catalog[0].average, Nave, catalog[0].lensing, Nlens); 104 106 } 105 107 … … 177 179 REALLOCATE (catalog[0].measure, Measure, NMEAS); 178 180 } 181 if (Nlens >= NLENS) { 182 NLENS = Nlens + 1000; 183 REALLOCATE (next_lens, off_t, NLENS); 184 REALLOCATE (catalog[0].lensing, Lensing, NLENS); 185 } 179 186 180 187 /* add to end of measurement list */ … … 186 193 catalog[0].measure[Nmeas] = stars[N].measure; 187 194 188 /** dR,dD now represent arcsec **/ 189 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N].average.R); 190 catalog[0].measure[Nmeas].dD = 3600.0*(catalog[0].average[n].D - stars[N].average.D); 195 // measure now carries R,D (not dR,dD) 196 // note that ReadStarsFITS does not set measure.R,D and average.R,D 197 catalog[0].measure[Nmeas].R = stars[N].average.R; 198 catalog[0].measure[Nmeas].D = stars[N].average.D; 191 199 catalog[0].measure[Nmeas].dbFlags = 0; 192 200 catalog[0].measure[Nmeas].averef = n; … … 194 202 catalog[0].measure[Nmeas].catID = catalog[0].catID; 195 203 204 float dRoff = dvoOffsetR(&catalog[0].measure[Nmeas], &catalog[0].average[n]); 205 196 206 // rationalize dR 197 if ( catalog[0].measure[Nmeas].dR> +180.0*3600.0) {207 if (dRoff > +180.0*3600.0) { 198 208 // average on high end of boundary, move star up 199 stars[N].average.R += 360.0;200 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N].average.R);201 } 202 if ( catalog[0].measure[Nmeas].dR< -180.0*3600.0) {209 catalog[0].measure[Nmeas].R += 360.0; 210 dRoff -= 360.0*3600.0; 211 } 212 if (dRoff < -180.0*3600.0) { 203 213 // average on low end of boundary, move star down 204 stars[N].average.R -= 360.0; 205 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N].average.R); 206 } 207 if (fabs(catalog[0].measure[Nmeas].dR) > 10*RADIUS) { 208 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 209 catalog[0].average[n].R, catalog[0].average[n].D, 210 stars[N].average.R, stars[N].average.D, 211 X1[i], X2[Jmin], 212 Y1[i], Y2[Jmin]); 213 // XXX abort on this? -- this is a bad failure... 214 catalog[0].measure[Nmeas].R -= 360.0; 215 dRoff += 360.0*3600.0; 216 } 217 if (fabs(dRoff) > 10*RADIUS) { 218 // take declination into account and check again. 219 double cosD = cos(RAD_DEG*catalog[0].average[n].D); 220 if (fabs(dRoff*cosD) > 10*RADIUS) { 221 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 222 catalog[0].average[n].R, catalog[0].average[n].D, 223 stars[N].average.R, stars[N].average.D, 224 X1[i], X2[Jmin], 225 Y1[i], Y2[Jmin]); 226 // XXX abort on this? -- this is a bad failure... 227 } 228 } 229 230 // add the lensing values if they exist 231 if (stars[N].lensing) { 232 add_lens_link (&catalog[0].average[n], next_lens, Nlens, NLENS); // ? 233 catalog[0].lensing[Nlens] = stars[N].lensing[0]; 234 235 catalog[0].lensing[Nlens].averef = n; 236 catalog[0].lensing[Nlens].objID = catalog[0].average[n].objID; 237 catalog[0].lensing[Nlens].catID = catalog[0].catID; 238 catalog[0].average[n].Nlensing ++; 239 Nlens ++; 214 240 } 215 241 … … 224 250 if (Nsec > -1) { 225 251 if (isnan(catalog[0].secfilt[n*Nsecfilt+Nsec].M)) { 226 catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas] );252 catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas], MAG_CLASS_PSF); 227 253 } 228 254 } … … 234 260 Nm is recalculated in build_meas_links if loaded table is not sorted */ 235 261 stars[N].found = Nmeas; 236 catalog[0].found [n] = Nmeas;262 catalog[0].found_t[n] = Nmeas; 237 263 catalog[0].average[n].Nmeasure ++; 238 264 Nmeas ++; … … 249 275 REALLOCATE (catalog[0].measure, Measure, NMEAS); 250 276 } 277 if (Nlens >= NLENS - NSTAR_GROUP) { 278 NLENS = Nlens + 1000; 279 REALLOCATE (next_lens, off_t, NLENS); 280 REALLOCATE (catalog[0].lensing, Lensing, NLENS); 281 } 251 282 if (Nave >= NAVE) { 252 283 NAVE = Nave + 1000; … … 278 309 279 310 for (j = 0; j < NSTAR_GROUP; j++) { 280 // supply the measurments from this detection 281 catalog[0].measure[Nmeas] = stars[i + j].measure; 282 283 // the following measure elements cannot be set until here: 284 catalog[0].measure[Nmeas].dR = 0.0; // astrometric offset, not error 285 catalog[0].measure[Nmeas].dD = 0.0; // astrometric offset, not error 286 catalog[0].measure[Nmeas].dbFlags = 0; 287 catalog[0].measure[Nmeas].averef = Nave; 288 catalog[0].measure[Nmeas].objID = catalog[0].average[Nave].objID; 289 catalog[0].measure[Nmeas].catID = catalog[0].catID; 290 291 /* set the average magnitude if not already set and the photcode.equiv is not 0 */ 292 /* in UPDATE mode, this value is not saved; use relphot to recalculate */ 293 if (Nsec > -1) { 294 catalog[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas]); 295 } 296 297 /* next[Nmeas] should always be -1 in this context (it is always the only 298 measurement for the star) */ 299 stars[i+j].found = Nmeas; 300 next_meas[Nmeas] = -1; // inital value here update below 301 Nmeas ++; 311 // supply the measurments from this detection 312 dvo_measure_init (&catalog[0].measure[Nmeas]); 313 catalog[0].measure[Nmeas] = stars[i + j].measure; 314 315 // the following measure elements cannot be set until here: 316 catalog[0].measure[Nmeas].R = stars[i].average.R; 317 catalog[0].measure[Nmeas].D = stars[i].average.D; 318 catalog[0].measure[Nmeas].dbFlags = 0; 319 catalog[0].measure[Nmeas].averef = Nave; 320 catalog[0].measure[Nmeas].objID = catalog[0].average[Nave].objID; 321 catalog[0].measure[Nmeas].catID = catalog[0].catID; 322 323 /* set the average magnitude if not already set and the photcode.equiv is not 0 */ 324 /* in UPDATE mode, this value is not saved; use relphot to recalculate */ 325 if (Nsec > -1) { 326 catalog[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas], MAG_CLASS_PSF); 327 } 328 329 /* next[Nmeas] should always be -1 in this context (it is always the only 330 measurement for the star) */ 331 stars[i+j].found = Nmeas; 332 next_meas[Nmeas] = -1; // inital value here update below 333 Nmeas ++; 302 334 } 303 335 for (j = 0; j < NSTAR_GROUP - 1; j++) { 304 next_meas[Nmeas - NSTAR_GROUP + j] = Nmeas - NSTAR_GROUP + j + 1; 305 } 336 next_meas[Nmeas - NSTAR_GROUP + j] = Nmeas - NSTAR_GROUP + j + 1; 337 } 338 339 // if we have lensing data, insert that as well 340 if (stars[i].lensing) { 341 catalog[0].average[Nave].Nlensing = NSTAR_GROUP; 342 catalog[0].average[Nave].lensingOffset = Nlens; 343 for (j = 0; j < NSTAR_GROUP; j++) { 344 // add the lensing values if they exist 345 if (stars[i + j].lensing) { 346 dvo_lensing_init (&catalog[0].lensing[Nlens]); 347 catalog[0].lensing[Nlens] = stars[i + j].lensing[0]; 348 349 catalog[0].lensing[Nlens].averef = Nave; 350 catalog[0].lensing[Nlens].objID = catalog[0].average[Nave].objID; 351 catalog[0].lensing[Nlens].catID = catalog[0].catID; 352 next_lens[Nlens] = -1; 353 Nlens ++; 354 } 355 } 356 for (j = 0; j < NSTAR_GROUP - 1; j++) { 357 next_lens[Nlens - NSTAR_GROUP + j] = Nlens - NSTAR_GROUP + j + 1; 358 } 359 } 360 306 361 Nave ++; 307 362 } … … 309 364 REALLOCATE (catalog[0].average, Average, Nave); 310 365 REALLOCATE (catalog[0].measure, Measure, Nmeas); 366 REALLOCATE (catalog[0].lensing, Lensing, Nlens); 311 367 312 368 if (options.nosort) { … … 315 371 catalog[0].sorted = TRUE; 316 372 catalog[0].measure = sort_measure (catalog[0].average, Nave, catalog[0].measure, Nmeas, next_meas); 373 catalog[0].lensing = sort_lensing (catalog[0].average, Nave, catalog[0].lensing, Nlens, next_lens); 317 374 } 318 375 … … 328 385 catalog[0].Naverage = Nave; 329 386 catalog[0].Nmeasure = Nmeas; 387 catalog[0].Nlensing = Nlens; 330 388 catalog[0].Nsecf_mem = Nave*Nsecfilt; 331 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); 332 333 free (catalog[0].found); 389 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nlens: "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas, Nlens, Nmatch); 390 334 391 free (X1); 335 392 free (Y1); … … 339 396 free (Y2); 340 397 free (next_meas); 398 free (next_lens); 341 399 342 400 return (Nmatch); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/find_matches_closest_refstars.c
r36680 r37403 31 31 ALLOCATE (Y2, double, NAVE); 32 32 ALLOCATE (N2, off_t, NAVE); 33 ALLOCATE (catalog[0].found , off_t, NAVE);33 ALLOCATE (catalog[0].found_t, off_t, NAVE); 34 34 /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */ 35 35 … … 71 71 if (Nstars < 1) { 72 72 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", catalog[0].filename); 73 free (catalog[0].found);74 73 free (X1); 75 74 free (Y1); … … 86 85 RD_to_XY (&X2[i], &Y2[i], catalog[0].average[i].R, catalog[0].average[i].D, &tcoords); 87 86 N2[i] = i; 88 catalog[0].found [N2[i]] = -1;87 catalog[0].found_t[N2[i]] = -1; 89 88 } 90 89 if (Nave > 1) sort_coords_index (X2, Y2, N2, Nave); … … 180 179 181 180 /** *** dR,dD now in arcsec *** **/ 182 catalog[0].measure[Nmeas]. dR = 3600.0*(catalog[0].average[n].R - stars[N][0].average.R);183 catalog[0].measure[Nmeas]. dD = 3600.0*(catalog[0].average[n].D - stars[N][0].average.D);181 catalog[0].measure[Nmeas].R = stars[N][0].average.R; 182 catalog[0].measure[Nmeas].D = stars[N][0].average.D; 184 183 catalog[0].measure[Nmeas].dbFlags = 0; 185 184 catalog[0].measure[Nmeas].averef = n; … … 187 186 catalog[0].measure[Nmeas].catID = catalog[0].catID; 188 187 188 float dRoff = dvoOffsetR(&catalog[0].measure[Nmeas], &catalog[0].average[n]); 189 189 190 // rationalize dR: 190 if ( catalog[0].measure[Nmeas].dR> +180.0*3600.0) {191 if (dRoff > +180.0*3600.0) { 191 192 // average on high end of boundary, move star up 192 stars[N][0].average.R += 360.0;193 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N][0].average.R);194 } 195 if ( catalog[0].measure[Nmeas].dR< -180.0*3600.0) {193 catalog[0].measure[Nmeas].R += 360.0; 194 dRoff -= 360.0*3600.0; 195 } 196 if (dRoff < -180.0*3600.0) { 196 197 // average on low end of boundary, move star down 197 stars[N][0].average.R -= 360.0;198 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N][0].average.R);198 catalog[0].measure[Nmeas].R -= 360.0; 199 dRoff += 360.0*3600.0; 199 200 } 200 201 … … 218 219 /* this catalog star matches more than one image star */ 219 220 // XXX should this be an average flag? 220 if (catalog[0].found [n] > -1) {221 catalog[0].measure[catalog[0].found [n]].dbFlags |= ID_MEAS_BLEND_OBJ;221 if (catalog[0].found_t[n] > -1) { 222 catalog[0].measure[catalog[0].found_t[n]].dbFlags |= ID_MEAS_BLEND_OBJ; 222 223 catalog[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_OBJ; 223 224 } else { 224 catalog[0].found [n] = Nmeas;225 catalog[0].found_t[n] = Nmeas; 225 226 } 226 227 … … 290 291 catalog[0].measure[Nmeas] = stars[N][0].measure; 291 292 292 catalog[0].measure[Nmeas]. dR = 0.0; // astrometric offset, not error293 catalog[0].measure[Nmeas]. dD = 0.0; // astrometric offset, not error293 catalog[0].measure[Nmeas].R = catalog[0].average[Nave].R; 294 catalog[0].measure[Nmeas].D = catalog[0].average[Nave].D; 294 295 catalog[0].measure[Nmeas].dbFlags = 0; 295 296 catalog[0].measure[Nmeas].averef = Nave; … … 329 330 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); 330 331 331 free (catalog[0].found);332 332 free (X1); 333 333 free (Y1); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/find_matches_refstars.c
r36680 r37403 37 37 ALLOCATE (Y2, double, NAVE); 38 38 ALLOCATE (N2, off_t, NAVE); 39 ALLOCATE (catalog[0].found , off_t, NAVE);39 ALLOCATE (catalog[0].found_t, off_t, NAVE); 40 40 REALLOCATE (catalog[0].average, Average, NAVE); 41 41 REALLOCATE (catalog[0].secfilt, SecFilt, NAVE*catalog[0].Nsecfilt); … … 69 69 RD_to_XY (&X2[i], &Y2[i], catalog[0].average[i].R, catalog[0].average[i].D, &tcoords); 70 70 N2[i] = i; 71 catalog[0].found [N2[i]] = -1;71 catalog[0].found_t[N2[i]] = -1; 72 72 } 73 73 if (Nave > 1) sort_coords_index (X2, Y2, N2, Nave); … … 141 141 catalog[0].measure[Nmeas] = stars[N][0].measure; 142 142 143 /** *** dR,dD now in arcsec *****/144 catalog[0].measure[Nmeas]. dR = 3600.0*(catalog[0].average[n].R - stars[N][0].average.R);145 catalog[0].measure[Nmeas]. dD = 3600.0*(catalog[0].average[n].D - stars[N][0].average.D);143 /** measure now stores R,D **/ 144 catalog[0].measure[Nmeas].R = stars[N][0].average.R; 145 catalog[0].measure[Nmeas].D = stars[N][0].average.D; 146 146 catalog[0].measure[Nmeas].dbFlags = 0; 147 147 catalog[0].measure[Nmeas].averef = n; … … 149 149 catalog[0].measure[Nmeas].catID = catalog[0].catID; 150 150 151 float dRoff = dvoOffsetR(&catalog[0].measure[Nmeas], &catalog[0].average[n]); 152 151 153 // rationalize dR: 152 if ( catalog[0].measure[Nmeas].dR> +180.0*3600.0) {154 if (dRoff > +180.0*3600.0) { 153 155 // average on high end of boundary, move star up 154 stars[N][0].average.R += 360.0;155 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N][0].average.R);156 } 157 if ( catalog[0].measure[Nmeas].dR< -180.0*3600.0) {156 catalog[0].measure[Nmeas].R += 360.0; 157 dRoff -= 360.0*3600.0; 158 } 159 if (dRoff < -180.0*3600.0) { 158 160 // average on low end of boundary, move star down 159 stars[N][0].average.R -= 360.0;160 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N][0].average.R);161 catalog[0].measure[Nmeas].R -= 360.0; 162 dRoff += 360.0*3600.0; 161 163 } 162 164 … … 188 190 } 189 191 /* this catalog star matches more than one image star */ 190 if (catalog[0].found [n] > -1) {191 catalog[0].measure[catalog[0].found [n]].dbFlags |= ID_MEAS_BLEND_OBJ;192 if (catalog[0].found_t[n] > -1) { 193 catalog[0].measure[catalog[0].found_t[n]].dbFlags |= ID_MEAS_BLEND_OBJ; 192 194 catalog[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_OBJ; 193 195 } else { 194 catalog[0].found [n] = Nmeas;196 catalog[0].found_t[n] = Nmeas; 195 197 } 196 198 … … 262 264 catalog[0].measure[Nmeas] = stars[N][0].measure; 263 265 264 catalog[0].measure[Nmeas]. dR = 0.0;265 catalog[0].measure[Nmeas]. dD = 0.0;266 catalog[0].measure[Nmeas].R = stars[N][0].average.R; 267 catalog[0].measure[Nmeas].D = stars[N][0].average.D; 266 268 267 269 catalog[0].measure[Nmeas].t = (stars[N][0].measure.t == 0) ? TIMEREF : stars[N][0].measure.t; /** careful : time_t vs e_time **/ … … 303 305 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %d "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas, Nmatch); 304 306 305 free (catalog[0].found);306 307 free (X1); 307 308 free (Y1); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/findskycell.c
r36680 r37403 27 27 int apply_tree (char *treefile, char *datafile); 28 28 29 float SCALE = 1.0;30 int NX_SUB = 1;31 int NY_SUB = 1;29 float SCALE = 1.0; 30 float NX_SUB = 1.0; 31 float NY_SUB = 1.0; 32 32 33 33 double R_MIN = 0.0; … … 162 162 } 163 163 164 # define MARKTIME(MSG,...) { \165 float dtime; \166 gettimeofday (&stop, (void *) NULL); \167 dtime = DTIME (stop, start); \168 fprintf (stderr, MSG, __VA_ARGS__); }169 170 164 int mktree (char *treefile, char *catdir) { 171 165 … … 223 217 ALLOCATE (tree.Xo, double *, tree.Nzone); 224 218 ALLOCATE (tree.Yo, double *, tree.Nzone); 225 ALLOCATE (tree.dX, int *, tree.Nzone);226 ALLOCATE (tree.dY, int *, tree.Nzone);219 ALLOCATE (tree.dX, float *, tree.Nzone); 220 ALLOCATE (tree.dY, float *, tree.Nzone); 227 221 ALLOCATE (tree.cell, int *, tree.Nzone); 228 222 ALLOCATE (tree.name, char **, tree.Nzone); … … 257 251 ALLOCATE (tree.Xo[zone], double, tree.NBAND[zone]); 258 252 ALLOCATE (tree.Yo[zone], double, tree.NBAND[zone]); 259 ALLOCATE (tree.dX[zone], int, tree.NBAND[zone]);260 ALLOCATE (tree.dY[zone], int, tree.NBAND[zone]);253 ALLOCATE (tree.dX[zone], float, tree.NBAND[zone]); 254 ALLOCATE (tree.dY[zone], float, tree.NBAND[zone]); 261 255 ALLOCATE (tree.cell[zone], int, tree.NBAND[zone]); 262 256 ALLOCATE (tree.name[zone], char *, tree.NBAND[zone]); … … 266 260 tree.Xo[zone][band] = NAN; 267 261 tree.Yo[zone][band] = NAN; 268 tree.dX[zone][band] = -1;269 tree.dY[zone][band] = -1;262 tree.dX[zone][band] = NAN; 263 tree.dY[zone][band] = NAN; 270 264 tree.cell[zone][band] = -1; 271 265 ALLOCATE (tree.name[zone][band], char, BOUNDARY_TREE_NAME_LENGTH); … … 292 286 REALLOCATE (tree.Xo[zone], double, tree.NBAND[zone]); 293 287 REALLOCATE (tree.Yo[zone], double, tree.NBAND[zone]); 294 REALLOCATE (tree.dX[zone], int, tree.NBAND[zone]);295 REALLOCATE (tree.dY[zone], int, tree.NBAND[zone]);288 REALLOCATE (tree.dX[zone], float, tree.NBAND[zone]); 289 REALLOCATE (tree.dY[zone], float, tree.NBAND[zone]); 296 290 REALLOCATE (tree.cell[zone], int, tree.NBAND[zone]); 297 291 REALLOCATE (tree.name[zone], char *, tree.NBAND[zone]); … … 301 295 tree.Xo[zone][band] = NAN; 302 296 tree.Yo[zone][band] = NAN; 303 tree.dX[zone][band] = -1;304 tree.dY[zone][band] = -1;297 tree.dX[zone][band] = NAN; 298 tree.dY[zone][band] = NAN; 305 299 tree.cell[zone][j] = -1; 306 300 ALLOCATE (tree.name[zone][j], char, BOUNDARY_TREE_NAME_LENGTH); … … 402 396 } 403 397 404 struct timeval start, stop; 405 gettimeofday (&start, (void *) NULL); 398 INITTIME; 406 399 407 400 int Npts = 10000000; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/load2mass_catalog.c
r35416 r37403 17 17 for (i = 0; i < Nstars; i+=3) { 18 18 19 double R = stars[i].average.R; 20 double D = stars[i].average.D; 21 19 22 // construct an average object for this object 20 23 // XXX for now, the output objects will have limited astrometric interpretation... 21 24 // XXX every 3 stars represents 3 measurements and 1 average 22 25 dvo_average_init (&catalog[0].average[Nave]); 23 catalog[0].average[Nave].R = stars[i].average.R;24 catalog[0].average[Nave].D = stars[i].average.D;26 catalog[0].average[Nave].R = R; 27 catalog[0].average[Nave].D = D; 25 28 catalog[0].average[Nave].measureOffset = Nmeas; 26 29 … … 33 36 catalog[0].measure[Nmeas] = stars[i+j].measure; 34 37 35 catalog[0].measure[Nmeas]. dR = 0.0;36 catalog[0].measure[Nmeas]. dD = 0.0;38 catalog[0].measure[Nmeas].R = R; 39 catalog[0].measure[Nmeas].D = D; 37 40 catalog[0].measure[Nmeas].dt = NAN_S_SHORT; 38 41 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/loadsupercos_ops.c
r33653 r37403 1 1 # include "addstar.h" 2 2 # include "supercos.h" 3 4 // this is defined in libohana/src/string.c but not generally exposed5 char *_parse_nextword_csv (char *string);6 3 7 4 int loadsupercos_getFilterInfo (char *line, char *emulsion, char *filterID) { … … 13 10 // emulsion is field 11, filterID is field 12 14 11 for (i = 1; i < 11; i++) { 15 p1 = _parse_nextword_csv (p1);12 p1 = parse_nextword_csv (p1); 16 13 if (!p1) { 17 14 fprintf (stderr, "error parsing filter info for line %s\n", line); … … 24 21 } 25 22 26 char *p2 = _parse_nextword_csv (p1);23 char *p2 = parse_nextword_csv (p1); 27 24 if (!p2) { 28 25 fprintf (stderr, "error parsing filter info for line %s\n", line); … … 34 31 } 35 32 36 char *p3 = _parse_nextword_csv (p2);33 char *p3 = parse_nextword_csv (p2); 37 34 if (!p3) { 38 35 fprintf (stderr, "error parsing filter info for line %s\n", line); … … 60 57 // lstObs is field 20 61 58 for (i = 1; i < 20; i++) { 62 p1 = _parse_nextword_csv (p1);59 p1 = parse_nextword_csv (p1); 63 60 if (!p1) { 64 61 fprintf (stderr, "error parsing filter info for line %s\n", line); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/mkcmf.c
r35760 r37403 1 1 # include "mkcmf.h" 2 2 3 # define ZERO_POINT 25.0 3 4 # define SKY 100.0 4 5 # define DSKY 2.0 … … 14 15 void gauss_init (int Nbin); 15 16 double rnd_gauss (double mean, double sigma); 17 void writeStars_PS1_V5_Lensing (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars); 18 void writeStars_PS1_V5 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars); 16 19 void writeStars_PS1_V4 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars); 17 20 void writeStars_PS1_V3 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars); 18 21 void writeStars_PS1_V2 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars); 19 22 void writeStars_PS1_V1 (FTable *ftable, double *X, double *Y, double *M, int Nstars); 23 void writeStars_PS1_SV3 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars); 20 24 void writeStars_PS1_DEV_1 (FTable *ftable, double *X, double *Y, double *M, int Nstars); 21 25 void writeStars_PS1_DEV_0 (FTable *ftable, double *X, double *Y, double *M, int Nstars); … … 23 27 int ADDNOISE = TRUE; 24 28 float BAD_PSFQF_FRAC = 0.0; 29 30 static float exptime = 1.0; 31 static Coords coords; 32 33 static char reserved[] = "Reserved space. This line can be used to add a new FITS card."; 25 34 26 35 int main (int argc, char **argv) { … … 38 47 Matrix matrix; 39 48 FTable ftable; 40 Coords coords;41 49 42 50 int APPEND = FALSE; … … 105 113 } 106 114 107 float exptime = 1.0;108 115 if ((N = get_argument (argc, argv, "-exptime"))) { 109 116 remove_argument (N, &argc, argv); … … 288 295 gfits_modify (&header, "UTC-OBS", "%s", 1, time); 289 296 } 290 gfits_modify (&header, "ZERO_PT", "%lf", 1, 25.0);297 gfits_modify (&header, "ZERO_PT", "%lf", 1, ZERO_POINT); 291 298 gfits_modify (&header, "EXPTIME", "%lf", 1, exptime); 292 299 gfits_modify (&header, "AIRMASS", "%lf", 1, airmass); … … 300 307 PutCoords (&coords, &header); 301 308 gfits_modify (&header, "EXTNAME", "%s", 1, exthead); 309 310 int i; 311 for (i = 1; i < 32; i++) { 312 gfits_modify_alt (&header, "COMMENT", "%C", i, reserved); 313 } 302 314 303 315 ftable.header = &theader; … … 327 339 if (!strcmp(type, "PS1_V4")) { 328 340 writeStars_PS1_V4 (&ftable, X, Y, M, Flag, Nstars); 341 found = TRUE; 342 } 343 if (!strcmp(type, "PS1_V5")) { 344 writeStars_PS1_V5 (&ftable, X, Y, M, Flag, Nstars); 345 found = TRUE; 346 } 347 if (!strcmp(type, "PS1_V5_Lensing")) { 348 writeStars_PS1_V5_Lensing (&ftable, X, Y, M, Flag, Nstars); 349 found = TRUE; 350 } 351 if (!strcmp(type, "PS1_SV3")) { 352 writeStars_PS1_SV3 (&ftable, X, Y, M, Flag, Nstars); 329 353 found = TRUE; 330 354 } … … 764 788 } 765 789 790 void writeStars_PS1_V5 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars) { 791 792 int i; 793 CMF_PS1_V5 *stars; 794 float flux, fSN; 795 796 // XXX add gaussian-distributed noise based on counts 797 // this needs to make different output 'stars' entries depending on the desired type 798 ALLOCATE (stars, CMF_PS1_V5, Nstars); 799 for (i = 0; i < Nstars; i++) { 800 801 flux = pow (10.0, -0.4*M[i]); 802 fSN = 1.0 / sqrt(flux); 803 804 stars[i].detID = i; 805 stars[i].X = X[i]; 806 stars[i].Y = Y[i]; 807 stars[i].dX = FX * fSN; 808 stars[i].dY = FY * fSN; 809 810 stars[i].posangle = 10.0; 811 stars[i].pltscale = 0.25; 812 813 stars[i].M = M[i]; 814 stars[i].dM = fSN; 815 816 stars[i].Flux = flux; 817 stars[i].dFlux = flux * fSN; 818 819 stars[i].Map = M[i] - 0.05; 820 stars[i].MapRaw = M[i] - 0.10; 821 822 stars[i].apRadius = 8.0; 823 824 stars[i].apFlux = pow(10.0, -0.4*stars[i].Map); 825 stars[i].apFluxErr = stars[i].apFlux * fSN; 826 827 stars[i].Mcalib = M[i] + ZERO_POINT + 2.5*log10(exptime); 828 stars[i].dMcal = 0.05; 829 830 XY_to_RD (&stars[i].RA, &stars[i].DEC, X[i], Y[i], &coords); 831 stars[i].apNpix = 3.14*8.0*8.0; 832 833 stars[i].Mpeak = M[i] + 1.0; 834 stars[i].sky = SKY; 835 stars[i].dSky = DSKY; 836 stars[i].psfChisq = PSFCHI; 837 stars[i].crNsigma = CRN; 838 stars[i].extNsigma = EXTN; 839 stars[i].fx = FX; 840 stars[i].fy = FY; 841 stars[i].df = DF; 842 843 stars[i].k = 1.0; 844 stars[i].fwhmMaj = FX*2.8; 845 stars[i].fwhmMin = FY*2.8; 846 847 // randomly give poor PSFQF values 848 if ((BAD_PSFQF_FRAC > 0.0) && (drand48() < BAD_PSFQF_FRAC)) { 849 stars[i].psfQF = 0.25; 850 stars[i].psfQFperf = 0.24; 851 } else { 852 stars[i].psfQF = PSFQUAL; 853 stars[i].psfQFperf = MAX(PSFQUAL - 0.01, 0.0); 854 } 855 856 stars[i].psfNdof = 1; 857 stars[i].psfNpix = 2; 858 859 stars[i].Mxx = FX; 860 stars[i].Mxy = 0.01; 861 stars[i].Myy = FX; 862 stars[i].M3c = FX; 863 stars[i].M3s = FX; 864 stars[i].M4c = FX; 865 stars[i].M4s = FX; 866 stars[i].Mr1 = FX; 867 stars[i].Mrh = FX; 868 869 stars[i].kronFlux = flux * 1.25; 870 stars[i].kronFluxErr = fSN * flux * 1.25; 871 872 stars[i].kronInner = fSN * flux * 0.9; 873 stars[i].kronOuter = fSN * flux * 1.5; 874 875 stars[i].skyLimitRad = 1; 876 stars[i].skyLimitFlux = 2; 877 stars[i].skyLimitSlope = 0.2; 878 879 stars[i].flags = Flag[i]; 880 stars[i].flags2 = 0x80; 881 882 stars[i].nFrames = 1; 883 884 if (ADDNOISE) { 885 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0); 886 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0); 887 float Moff = fSN*rnd_gauss(0.0, 1.0); 888 stars[i].M += Moff; 889 stars[i].Map += Moff; 890 stars[i].MapRaw += Moff; 891 stars[i].Mcalib += Moff; 892 } 893 } 894 895 gfits_table_set_CMF_PS1_V5 (ftable, stars, Nstars); 896 gfits_modify (ftable->header, "EXTTYPE", "%s", 1, "PS1_V5"); 897 } 898 899 void writeStars_PS1_SV3 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars) { 900 901 int i; 902 CMF_PS1_SV3 *stars; 903 float flux, fSN; 904 905 // XXX add gaussian-distributed noise based on counts 906 // this needs to make different output 'stars' entries depending on the desired type 907 ALLOCATE (stars, CMF_PS1_SV3, Nstars); 908 for (i = 0; i < Nstars; i++) { 909 910 flux = pow (10.0, -0.4*M[i]); 911 fSN = 1.0 / sqrt(flux); 912 913 stars[i].detID = i; 914 stars[i].X = X[i]; 915 stars[i].Y = Y[i]; 916 stars[i].dX = FX * fSN; 917 stars[i].dY = FY * fSN; 918 919 stars[i].posangle = 10.0; 920 stars[i].pltscale = 0.25; 921 922 stars[i].M = M[i]; 923 stars[i].dM = fSN; 924 925 stars[i].Flux = flux; 926 stars[i].dFlux = flux * fSN; 927 928 stars[i].Map = M[i] - 0.05; 929 stars[i].MapRaw = M[i] - 0.10; 930 931 stars[i].apRadius = 8.0; 932 933 stars[i].apFlux = pow(10.0, -0.4*stars[i].Map); 934 stars[i].apFluxErr = stars[i].apFlux * fSN; 935 936 stars[i].Mcalib = M[i] + ZERO_POINT + 2.5*log10(exptime); 937 stars[i].dMcal = 0.05; 938 939 XY_to_RD (&stars[i].RA, &stars[i].DEC, X[i], Y[i], &coords); 940 stars[i].apNpix = 3.14*8.0*8.0; 941 942 stars[i].Mpeak = M[i] + 1.0; 943 stars[i].sky = SKY; 944 stars[i].dSky = DSKY; 945 stars[i].psfChisq = PSFCHI; 946 stars[i].crNsigma = CRN; 947 stars[i].extNsigma = EXTN; 948 stars[i].fx = FX; 949 stars[i].fy = FY; 950 stars[i].df = DF; 951 952 stars[i].k = 1.0; 953 stars[i].fwhmMaj = FX*2.8; 954 stars[i].fwhmMin = FY*2.8; 955 956 // randomly give poor PSFQF values 957 if ((BAD_PSFQF_FRAC > 0.0) && (drand48() < BAD_PSFQF_FRAC)) { 958 stars[i].psfQF = 0.25; 959 stars[i].psfQFperf = 0.24; 960 } else { 961 stars[i].psfQF = PSFQUAL; 962 stars[i].psfQFperf = MAX(PSFQUAL - 0.01, 0.0); 963 } 964 965 stars[i].psfNdof = 1; 966 stars[i].psfNpix = 2; 967 968 stars[i].Mxx = FX; 969 stars[i].Mxy = 0.01; 970 stars[i].Myy = FX; 971 stars[i].M3c = FX; 972 stars[i].M3s = FX; 973 stars[i].M4c = FX; 974 stars[i].M4s = FX; 975 stars[i].Mr1 = FX; 976 stars[i].Mrh = FX; 977 978 stars[i].kronFlux = flux * 1.25; 979 stars[i].kronFluxErr = fSN * flux * 1.25; 980 981 stars[i].kronInner = fSN * flux * 0.9; 982 stars[i].kronOuter = fSN * flux * 1.5; 983 984 // stars[i].skyLimitRad = 1; 985 // stars[i].skyLimitFlux = 2; 986 // stars[i].skyLimitSlope = 0.2; 987 988 stars[i].flags = Flag[i]; 989 stars[i].flags2 = 0x80; 990 991 stars[i].nFrames = 1; 992 993 if (ADDNOISE) { 994 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0); 995 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0); 996 float Moff = fSN*rnd_gauss(0.0, 1.0); 997 stars[i].M += Moff; 998 stars[i].Map += Moff; 999 stars[i].MapRaw += Moff; 1000 stars[i].Mcalib += Moff; 1001 } 1002 } 1003 1004 gfits_table_set_CMF_PS1_SV3 (ftable, stars, Nstars); 1005 gfits_modify (ftable->header, "EXTTYPE", "%s", 1, "PS1_SV3"); 1006 } 1007 1008 void writeStars_PS1_V5_Lensing (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars) { 1009 1010 int i; 1011 CMF_PS1_V5_Lensing *stars; 1012 float flux, fSN; 1013 1014 // XXX add gaussian-distributed noise based on counts 1015 // this needs to make different output 'stars' entries depending on the desired type 1016 ALLOCATE (stars, CMF_PS1_V5_Lensing, Nstars); 1017 for (i = 0; i < Nstars; i++) { 1018 1019 flux = pow (10.0, -0.4*M[i]); 1020 fSN = 1.0 / sqrt(flux); 1021 1022 stars[i].detID = i; 1023 stars[i].X = X[i]; 1024 stars[i].Y = Y[i]; 1025 stars[i].dX = FX * fSN; 1026 stars[i].dY = FY * fSN; 1027 1028 stars[i].posangle = 10.0; 1029 stars[i].pltscale = 0.25; 1030 1031 stars[i].M = M[i]; 1032 stars[i].dM = fSN; 1033 1034 stars[i].Flux = flux; 1035 stars[i].dFlux = flux * fSN; 1036 1037 stars[i].Map = M[i] - 0.05; 1038 stars[i].MapRaw = M[i] - 0.10; 1039 1040 stars[i].apRadius = 8.0; 1041 1042 stars[i].apFlux = pow(10.0, -0.4*stars[i].Map); 1043 stars[i].apFluxErr = stars[i].apFlux * fSN; 1044 1045 stars[i].Mcalib = M[i] + ZERO_POINT + 2.5*log10(exptime); 1046 stars[i].dMcal = 0.05; 1047 1048 XY_to_RD (&stars[i].RA, &stars[i].DEC, X[i], Y[i], &coords); 1049 stars[i].apNpix = 3.14*8.0*8.0; 1050 1051 stars[i].Mpeak = M[i] + 1.0; 1052 stars[i].sky = SKY; 1053 stars[i].dSky = DSKY; 1054 stars[i].psfChisq = PSFCHI; 1055 stars[i].crNsigma = CRN; 1056 stars[i].extNsigma = EXTN; 1057 stars[i].fx = FX; 1058 stars[i].fy = FY; 1059 stars[i].df = DF; 1060 1061 stars[i].k = 1.0; 1062 stars[i].fwhmMaj = FX*2.8; 1063 stars[i].fwhmMin = FY*2.8; 1064 1065 // randomly give poor PSFQF values 1066 if ((BAD_PSFQF_FRAC > 0.0) && (drand48() < BAD_PSFQF_FRAC)) { 1067 stars[i].psfQF = 0.25; 1068 stars[i].psfQFperf = 0.24; 1069 } else { 1070 stars[i].psfQF = PSFQUAL; 1071 stars[i].psfQFperf = MAX(PSFQUAL - 0.01, 0.0); 1072 } 1073 1074 stars[i].psfNdof = 1; 1075 stars[i].psfNpix = 2; 1076 1077 stars[i].Mxx = FX; 1078 stars[i].Mxy = 0.01; 1079 stars[i].Myy = FX; 1080 stars[i].M3c = FX; 1081 stars[i].M3s = FX; 1082 stars[i].M4c = FX; 1083 stars[i].M4s = FX; 1084 stars[i].Mr1 = FX; 1085 stars[i].Mrh = FX; 1086 1087 stars[i].X11_sm_obj = FX; 1088 stars[i].X12_sm_obj = FX; 1089 stars[i].X22_sm_obj = FY; 1090 stars[i].E1_sm_obj = FX; 1091 stars[i].E2_sm_obj = FX; 1092 1093 stars[i].X11_sh_obj = FX; 1094 stars[i].X12_sh_obj = 0.2; 1095 stars[i].X22_sh_obj = FY; 1096 stars[i].E1_sh_obj = FX*0.9; 1097 stars[i].E2_sh_obj = FX*0.8; 1098 1099 stars[i].X11_sm_psf = FX; 1100 stars[i].X12_sm_psf = FX; 1101 stars[i].X22_sm_psf = FX; 1102 stars[i].E1_sm_psf = FX; 1103 stars[i].E2_sm_psf = FX; 1104 1105 stars[i].X11_sh_psf = FX; 1106 stars[i].X12_sh_psf = FX; 1107 stars[i].X22_sh_psf = FX; 1108 stars[i].E1_sh_psf = FX; 1109 stars[i].E2_sh_psf = FX; 1110 1111 stars[i].kronFlux = flux * 1.25; 1112 stars[i].kronFluxErr = fSN * flux * 1.25; 1113 1114 stars[i].kronInner = fSN * flux * 0.9; 1115 stars[i].kronOuter = fSN * flux * 1.5; 1116 1117 stars[i].skyLimitRad = 1; 1118 stars[i].skyLimitFlux = 2; 1119 stars[i].skyLimitSlope = 0.2; 1120 1121 stars[i].flags = Flag[i]; 1122 stars[i].flags2 = 0x80; 1123 1124 stars[i].nFrames = 1; 1125 1126 if (ADDNOISE) { 1127 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0); 1128 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0); 1129 float Moff = fSN*rnd_gauss(0.0, 1.0); 1130 stars[i].M += Moff; 1131 stars[i].Map += Moff; 1132 stars[i].MapRaw += Moff; 1133 stars[i].Mcalib += Moff; 1134 } 1135 } 1136 1137 gfits_table_set_CMF_PS1_V5_Lensing (ftable, stars, Nstars); 1138 gfits_modify (ftable->header, "EXTTYPE", "%s", 1, "PS1_V5"); 1139 } 1140 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/replace_match.c
r26278 r37403 12 12 j = i + m; 13 13 if (measure[j].photcode != star[0].measure.photcode) continue; 14 measure[j]. dR = 3600.0*(average[0].R - star[0].average.R);15 measure[j]. dD = 3600.0*(average[0].D - star[0].average.D);14 measure[j].R = star[0].average.R; 15 measure[j].D = star[0].average.D; 16 16 measure[j].M = star[0].measure.M; 17 17 measure[j].dM = star[0].measure.dM; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/resort_catalog.c
r35760 r37403 1 1 # include "addstar.h" 2 2 3 void SortAveMatch (off_t *MEAS, off_t *AVE, off_t N); 4 void resort_catalog_measure (Catalog *catalog); 5 void resort_catalog_lensing (Catalog *catalog); 6 3 7 void resort_catalog_old (Catalog *catalog) { 4 8 5 off_t *next_meas; 6 off_t Naves, Nmeas; 7 double dtime; 8 struct timeval start, stop; 9 off_t *next_meas, *next_lens; 10 off_t Naves, Nmeas, Nlens; 9 11 10 12 if (catalog[0].sorted == TRUE) return; 11 13 12 gettimeofday (&start, NULL);14 INITTIME; 13 15 14 16 /* internal counters */ 15 17 Nmeas = catalog[0].Nmeasure; 18 Nlens = catalog[0].Nlensing; 16 19 Naves = catalog[0].Naverage; 17 20 18 21 /* set up pointers for linked list of measure, missing */ 19 22 next_meas = build_measure_links (catalog[0].average, Naves, catalog[0].measure, Nmeas); 23 next_lens = build_lensing_links (catalog[0].average, Naves, catalog[0].lensing, Nlens); 20 24 21 25 catalog[0].sorted = TRUE; 22 26 catalog[0].measure = sort_measure (catalog[0].average, Naves, catalog[0].measure, Nmeas, next_meas); 23 24 gettimeofday (&stop, NULL); 25 dtime = DTIME (stop, start); 26 fprintf (stderr, " match time %9.4f sec for %7lld measures, %6lld average\n", dtime, (long long) Nmeas, (long long) Naves); 27 catalog[0].lensing = sort_lensing (catalog[0].average, Naves, catalog[0].lensing, Nlens, next_lens); 28 29 MARKTIME (" match time %9.4f sec for %7lld measures, %6lld average\n", dtime, (long long) Nmeas, (long long) Naves); 27 30 28 31 return; 29 32 } 30 33 31 // sort the measure Sequence based on the average Sequence entries32 void SortAveMeasMatch (off_t *MEAS, off_t *AVE, off_t N) {33 34 # define SWAPFUNC(A,B){ off_t tmp_meas; off_t tmp_ave; \35 tmp_meas = MEAS[A]; MEAS[A] = MEAS[B]; MEAS[B] = tmp_meas; \36 tmp_ave = AVE[A]; AVE[A] = AVE[B]; AVE[B] = tmp_ave; \37 }38 # define COMPARE(A,B)(AVE[A] < AVE[B])39 OHANA_SORT (N, COMPARE, SWAPFUNC);40 # undef SWAPFUNC41 # undef COMPARE42 }43 44 # define MARKTIME(MSG,...) { \45 float dtime; \46 gettimeofday (&stop, (void *) NULL); \47 dtime = DTIME (stop, start); start = stop; \48 fprintf (stderr, MSG, __VA_ARGS__); }49 50 // XXX : where is the time going? perhaps the ALLOCATE?51 // XXX : I don't thnk his is getting the right answer yet.52 53 34 void resort_catalog (Catalog *catalog) { 35 36 if (catalog[0].sorted == TRUE) return; 37 38 resort_catalog_measure (catalog); 39 resort_catalog_lensing (catalog); 40 } 41 42 void resort_catalog_measure (Catalog *catalog) { 54 43 55 44 off_t Naverage, Nmeasure; … … 62 51 Measure *measureTMP = NULL; 63 52 64 if (catalog[0].sorted == TRUE) return;65 66 53 // struct timeval start, stop; 67 54 // gettimeofday (&start, NULL); … … 70 57 Nmeasure = catalog[0].Nmeasure; 71 58 Naverage = catalog[0].Naverage; 59 60 if (!Nmeasure) return; 72 61 73 62 measure = catalog[0].measure; … … 93 82 myAssert(average[averageSeq[i]].catID == measure[measureSeq[i]].catID, "object / detection mismatch"); 94 83 # if (1) 95 myAssert(average[averageSeq[i]].objID == measure[measureSeq[i]].objID, "object / detection mismatch"); 84 // myAssert(average[averageSeq[i]].objID == measure[measureSeq[i]].objID, "object / detection mismatch"); 85 // check if the objID is correct. if not, check if it is byte-swapped (this has happened) and repair if so. 86 // otherwise, abort 87 if (average[averageSeq[i]].objID != measure[measureSeq[i]].objID) { 88 fprintf (stderr, "object / detection mismatch average.objID = %d, measure.objID = %d, catID: %d, detID: %d", 89 average[averageSeq[i]].objID, measure[measureSeq[i]].objID, 90 measure[measureSeq[i]].catID, measure[measureSeq[i]].detID); 91 int objIDalt = measure[measureSeq[i]].objID; 92 char *byte = (char *) &objIDalt; 93 char tmp; 94 tmp = byte[0]; byte[0] = byte[3]; byte[3] = tmp; 95 tmp = byte[1]; byte[1] = byte[2]; byte[2] = tmp; 96 if (average[averageSeq[i]].objID == objIDalt) { 97 fprintf (stderr, "objID is byte-swapped, repairing\n"); 98 measure[measureSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this... 99 } else if (measure[measureSeq[i]].objID == 0) { 100 fprintf (stderr, "objID is 0, repairing\n"); 101 measure[measureSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this... 102 } else { 103 myAbort ("objID is NOT byte-swapped, aborting\n"); 104 } 105 } 96 106 # else 97 107 // for reasons I do not understand, the mini dvodbs generated on stsci1X had a handful of detections with an inconsistency between averef and objID. … … 113 123 // fprintf (stderr, "\n"); 114 124 115 SortAveM easMatch(measureSeq, averageSeq, Nmeasure);125 SortAveMatch(measureSeq, averageSeq, Nmeasure); 116 126 // MARKTIME("sort : %f sec\n", dtime); 117 127 … … 188 198 } 189 199 200 void resort_catalog_lensing (Catalog *catalog) { 201 202 off_t Naverage, Nlensing; 203 Lensing *lensing; 204 Average *average; 205 off_t i, j, N, currentAve; 206 207 off_t *lensingSeq = NULL; 208 off_t *averageSeq = NULL; 209 Lensing *lensingTMP = NULL; 210 211 // struct timeval start, stop; 212 // gettimeofday (&start, NULL); 213 214 /* internal counters */ 215 Nlensing = catalog[0].Nlensing; 216 Naverage = catalog[0].Naverage; 217 218 if (!Nlensing) return; 219 220 lensing = catalog[0].lensing; 221 average = catalog[0].average; 222 223 // we have a table of average objects and an unsorted table of measurements. each measurement 224 // has a reference to the average object sequence (as well as an ID) 225 // lensing[i].averef -> average[averef] 226 // lensing[i].objID = average[averef].objID 227 // lensing[i].catID = average[averef].catID 228 229 // we want a sorted lensing array with all averef entries in sequence 230 231 ALLOCATE (lensingSeq, off_t, Nlensing); 232 ALLOCATE (averageSeq, off_t, Nlensing); 233 234 for (i = 0; i < Nlensing; i++) { 235 lensingSeq[i] = i; 236 averageSeq[i] = lensing[i].averef; 237 238 if (catalog[0].catformat >= DVO_FORMAT_PS1_V1) { 239 // earlier formats did not carry the objID or catID, so they are not available (we could assign on load, but we don't) 240 myAssert(average[averageSeq[i]].catID == lensing[lensingSeq[i]].catID, "object / detection mismatch"); 241 # if (1) 242 myAssert(average[averageSeq[i]].objID == lensing[lensingSeq[i]].objID, "object / detection mismatch"); 243 # else 244 // for reasons I do not understand, the mini dvodbs generated on stsci1X had a handful of detections with an inconsistency between averef and objID. 245 // this happened for 28 detections in the dbs on /data/stsci1?.0/eugene/dvo3pi.20130616, but not at all (as far as I know) in the rest of LAP DVO 246 if (average[averageSeq[i]].objID != lensing[lensingSeq[i]].objID) { 247 fprintf (stderr, "R"); 248 lensing[lensingSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this... 249 } 250 # endif 251 } 252 } 253 254 // check that averageSeq is now in order 255 // for (i = 1; i < Nlensing; i++) { 256 // if (averageSeq[i] < averageSeq[i-1]) { 257 // fprintf (stderr, "%d ", (int) i); 258 // } 259 // } 260 // fprintf (stderr, "\n"); 261 262 SortAveMatch(lensingSeq, averageSeq, Nlensing); 263 // MARKTIME("sort : %f sec\n", dtime); 264 265 // check that averageSeq is now in order 266 // for (i = 1; i < Nlensing; i++) { 267 // if (averageSeq[i] < averageSeq[i-1]) { 268 // fprintf (stderr, "%d ", (int) i); 269 // } 270 // } 271 // fprintf (stderr, "\n"); 272 273 // copy the lensing entries in the sorted order 274 ALLOCATE (lensingTMP, Lensing, Nlensing); 275 for (i = 0; i < Nlensing; i++) { 276 j = lensingSeq[i]; 277 lensingTMP[i] = lensing[j]; 278 } 279 // MARKTIME("assign lensing : %f sec\n", dtime); 280 281 // update the values of average.lensingOffset and average.Nlensing 282 FREE(lensing); 283 catalog[0].lensing = lensingTMP; 284 285 N = 0; 286 currentAve = averageSeq[0]; 287 average[currentAve].lensingOffset = 0; 288 for (i = 0; i < Nlensing; i++) { 289 if (averageSeq[i] != currentAve) { 290 // we have hit the next entry in the list 291 average[currentAve].Nlensing = N; 292 N = 0; 293 currentAve = averageSeq[i]; 294 average[currentAve].lensingOffset = i; 295 } 296 N++; 297 } 298 // N++; 299 average[currentAve].Nlensing = N; 300 // MARKTIME("update Nlensing : %f sec\n", dtime); 301 302 int NlensingTotal = 0; 303 int lensingOffsetOK = TRUE; 304 for (i = 0; i < Naverage; i++) { 305 NlensingTotal += catalog[0].average[i].Nlensing; 306 if (VERBOSE && !(NlensingTotal <= catalog[0].Nlensing)) { 307 fprintf (stderr, "too few lensing: %d %d %d\n", (int) i, NlensingTotal, (int) catalog[0].Nlensing); 308 } 309 lensingOffsetOK &= (catalog[0].average[i].lensingOffset < catalog[0].Nlensing); 310 if (VERBOSE && !(catalog[0].average[i].lensingOffset < catalog[0].Nlensing)) { 311 fprintf (stderr, "offset too large: %d %d %d\n", (int) i, catalog[0].average[i].Nlensing, (int) catalog[0].Nlensing); 312 } 313 lensingOffsetOK &= (catalog[0].average[i].lensingOffset + catalog[0].average[i].Nlensing <= catalog[0].Nlensing); 314 if (VERBOSE && !(catalog[0].average[i].lensingOffset + catalog[0].average[i].Nlensing <= catalog[0].Nlensing)) { 315 fprintf (stderr, "orrset + Nlensing too large: %d + %d > %d %d\n", (int) i, catalog[0].average[i].lensingOffset, catalog[0].average[i].Nlensing, (int) catalog[0].Nlensing); 316 } 317 } 318 319 if (!lensingOffsetOK) { 320 fprintf (stderr, "ERROR: catalog %s has an invalid lensingOffset\n", catalog[0].filename); 321 } 322 323 if (NlensingTotal != catalog[0].Nlensing) { 324 fprintf (stderr, "ERROR: catalog %s has an invalid Nlensing\n", catalog[0].filename); 325 } 326 327 // MARKTIME(" match time %9.4f sec for %7lld lensings, %6lld average\n", dtime, (long long) Nlensing, (long long) Naverage); 328 329 catalog[0].sorted = TRUE; 330 331 FREE (lensingSeq); 332 FREE (averageSeq); 333 334 return; 335 } 336 337 // sort the measure or lensing Sequence based on the average Sequence entries 338 void SortAveMatch (off_t *MEAS, off_t *AVE, off_t N) { 339 340 # define SWAPFUNC(A,B){ off_t tmp_meas; off_t tmp_ave; \ 341 tmp_meas = MEAS[A]; MEAS[A] = MEAS[B]; MEAS[B] = tmp_meas; \ 342 tmp_ave = AVE[A]; AVE[A] = AVE[B]; AVE[B] = tmp_ave; \ 343 } 344 # define COMPARE(A,B)(AVE[A] < AVE[B]) 345 OHANA_SORT (N, COMPARE, SWAPFUNC); 346 # undef SWAPFUNC 347 # undef COMPARE 348 } 349 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/resort_threaded.c
r29938 r37403 13 13 int iThread; 14 14 int state; 15 int nosort;15 int forcesort; 16 16 char *filename; 17 17 SkyRegion *region; … … 37 37 } 38 38 39 // chose the catalog file (local or remote?) 40 char hostfile[1024]; 41 snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, threadData->region->name); 42 catalog.filename = HOST_ID ? hostfile : threadData->filename; 43 39 44 // set the parameters which guide catalog open/load/create 40 catalog.filename = threadData->filename;41 45 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 42 46 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 43 catalog.catflags = LOAD_AVES | LOAD_MEAS ;47 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_LENSING; 44 48 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 45 49 … … 64 68 65 69 // this is an overloaded value to mean 'force sort' 66 if (threadData-> nosort == 3) catalog.sorted = FALSE;70 if (threadData->forcesort) catalog.sorted = FALSE; 67 71 68 72 if (OLD_RESORT) { … … 88 92 } 89 93 90 int resort_threaded ( AddstarClientOptions *options, SkyTable *sky) {94 int resort_threaded (SkyList *skylist, int ForceSort) { 91 95 92 96 int j, launched, done, Nwait, Nrun; … … 97 101 ThreadData *threadData; 98 102 pthread_t *threads; 99 100 double dtime;101 struct timeval start, stop;102 gettimeofday (&start, NULL);103 104 SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);105 106 // in these cases, limit the sky catalogs to an existing subset107 if (options->existing_regions) {108 SkyList *tmp;109 tmp = SkyListExistingSubset (skylist, CATDIR);110 SkyListFree (skylist);111 skylist = tmp;112 }113 if (VERBOSE) fprintf (stderr, "writing to "OFF_T_FMT" regions\n", skylist[0].Nregions);114 115 if (options->only_images) {116 fprintf (stderr, "-image (only images) makes no sense with -resort\n");117 exit (2);118 }119 if (options->only_match) {120 fprintf (stderr, "-only-match makes no sense with -resort\n");121 exit (2);122 }123 if (options->nosort == 1) {124 fprintf (stderr, "-nosort makes no sense with -resort\n");125 exit (2);126 }127 if (options->update) {128 fprintf (stderr, "-update makes no sense with -resort\n");129 exit (2);130 }131 if (options->calibrate) {132 fprintf (stderr, "-cal (calibrate) makes no sense with -resort\n");133 exit (2);134 }135 103 136 104 ALLOCATE(threads, pthread_t, NTHREADS); … … 148 116 Naverage = Nmeasure = 0; 149 117 for (i = 0; i < skylist[0].Nregions; i++) { 118 119 // does this host ID match the desired location for the table? 120 if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue; 150 121 151 122 launched = FALSE; … … 166 137 if (threadData[j].state == TS_FAIL) goto failure; 167 138 if (threadData[j].state != TS_WAIT) continue; 168 threadData[j]. nosort = options->nosort;139 threadData[j].forcesort = ForceSort; 169 140 threadData[j].filename = skylist[0].filename[i]; 170 141 threadData[j].region = skylist[0].regions[i]; … … 203 174 } 204 175 205 gettimeofday (&stop, NULL);206 dtime = DTIME (stop, start);207 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for, "OFF_T_FMT" average, "OFF_T_FMT" measure\n", dtime, Naverage, Nmeasure);208 209 176 // for (i = 0; i < NTHREADS; i++) { 210 177 // pthread_cancel(threads[i]); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/resort_unthreaded.c
r35142 r37403 1 1 # include "addstar.h" 2 2 3 int resort_unthreaded (AddstarClientOptions *options, SkyTable *sky, int hostID, char *hostpath) { 3 // pass in options and skylist? 4 int resort_unthreaded (SkyList *skylist, int ForceSort) { 4 5 5 double dtime; 6 struct timeval start, stop; 6 off_t i; 7 off_t Naverage, Nmeasure; 8 Catalog catalog; 7 9 8 gettimeofday (&start, NULL); 10 /* match stars to existing catalog data (or otherwise manipulate catalog data) */ 11 Naverage = Nmeasure = 0; 12 for (i = 0; i < skylist[0].Nregions; i++) { 9 13 10 SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch); 11 12 // in these cases, limit the sky catalogs to an existing subset 13 if (options->existing_regions) { 14 SkyList *tmp; 15 tmp = SkyListExistingSubset (skylist, CATDIR); 16 SkyListFree (skylist); 17 skylist = tmp; 14 // does this host ID match the desired location for the table? 15 if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue; 16 17 // chose the catalog file (local or remote?) 18 char hostfile[1024]; 19 snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name); 20 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 21 22 // set the parameters which guide catalog open/load/create 23 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 24 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 25 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_LENSING; 26 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 27 28 // an error exit status here is a significant error (disk I/O or file access) 29 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) { 30 fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", catalog.filename); 31 exit (2); 32 } 33 34 // Naves_disk == 0 implies an empty catalog file, skip empty catalogs 35 if (catalog.Naves_disk == 0) { 36 dvo_catalog_unlock (&catalog); 37 dvo_catalog_free (&catalog); 38 continue; 39 } 40 41 // this is an overloaded value to mean 'force sort' 42 if (ForceSort) catalog.sorted = FALSE; 43 44 if (OLD_RESORT) { 45 resort_catalog_old (&catalog); 46 } else { 47 resort_catalog (&catalog); 48 } 49 50 // report total updated values 51 Naverage += catalog.Naverage; 52 Nmeasure += catalog.Nmeasure; 53 54 // write out catalog, if appropriate 55 SetProtect (TRUE); 56 dvo_catalog_save (&catalog, VERBOSE); 57 SetProtect (FALSE); 58 dvo_catalog_unlock (&catalog); 59 dvo_catalog_free (&catalog); 18 60 } 19 if (VERBOSE) fprintf (stderr, "writing to "OFF_T_FMT" regions\n", skylist[0].Nregions);20 21 if (options->only_images) {22 fprintf (stderr, "-image (only images) makes no sense with -resort\n");23 exit (2);24 }25 if (options->only_match) {26 fprintf (stderr, "-only-match makes no sense with -resort\n");27 exit (2);28 }29 if (options->nosort == 1) {30 fprintf (stderr, "-nosort makes no sense with -resort\n");31 exit (2);32 }33 if (options->update) {34 fprintf (stderr, "-update makes no sense with -resort\n");35 exit (2);36 }37 if (options->calibrate) {38 fprintf (stderr, "-cal (calibrate) makes no sense with -resort\n");39 exit (2);40 }41 42 resort_unthreaded_catalogs (options, skylist, hostID, hostpath);43 44 gettimeofday (&stop, NULL);45 dtime = DTIME (stop, start);46 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec\n", dtime);47 48 61 return TRUE; 49 62 } 50 63 64 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/update_coords.c
r34405 r37403 19 19 continue; 20 20 } 21 R = measure[m]. dR;22 D = measure[m]. dD;21 R = measure[m].R; 22 D = measure[m].D; 23 23 r += R; 24 24 d += D; … … 33 33 r = r / Npt; /* these are corrections in 1/100 arcsec to RA and DEC */ 34 34 d = d / Npt; 35 average[0].R -= r / 3600.0;36 average[0].D -= d / 3600.0;35 average[0].R = r; 36 average[0].D = d; 37 37 m = average[0].measureOffset; /* first measurement of this star */ 38 for (i = 0; i < average[0].Nmeasure; i++) { 39 measure[m].dR -= r; 40 measure[m].dD -= d; 41 m = next[m]; 42 } 43 38 44 39 /* measure scatter, if possible */ 45 40 if (Npt < 2) return; … … 47 42 dR2 = r2 / Npt - r*r; 48 43 dD2 = d2 / Npt - d*d; 49 average[0].ChiSqAve = sqrt (dD2 + dR2 / SQ(cos(d*RAD_DEG)));44 average[0].ChiSqAve = 3600.0*sqrt (dD2 + dR2 / SQ(cos(d*RAD_DEG))); 50 45 /* ChiSqAve is supposed to be a chisq */ 51 46 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/test/simple.dvo
r35263 r37403 7 7 test.fields PS1_DEV_0 PS1_V1 8 8 test.fields PS1_DEV_1 PS1_V1 9 test.fields PS1_V1 PS1_V110 test.fields PS1_V2 PS1_V111 test.fields PS1_V3 PS1_V112 test.fields PS1_V4 PS1_V19 test.fields PS1_V1 PS1_V1 10 test.fields PS1_V2 PS1_V1 11 test.fields PS1_V3 PS1_V1 12 test.fields PS1_V4 PS1_V1 13 13 14 14 test.fields PS1_DEV_0 PS1_V2 15 15 test.fields PS1_DEV_1 PS1_V2 16 test.fields PS1_V1 PS1_V217 test.fields PS1_V2 PS1_V218 test.fields PS1_V3 PS1_V219 test.fields PS1_V4 PS1_V416 test.fields PS1_V1 PS1_V2 17 test.fields PS1_V2 PS1_V2 18 test.fields PS1_V3 PS1_V2 19 test.fields PS1_V4 PS1_V4 20 20 21 21 test.fields PS1_DEV_0 PS1_V3 22 22 test.fields PS1_DEV_1 PS1_V3 23 test.fields PS1_V1 PS1_V324 test.fields PS1_V2 PS1_V325 test.fields PS1_V3 PS1_V326 test.fields PS1_V4 PS1_V423 test.fields PS1_V1 PS1_V3 24 test.fields PS1_V2 PS1_V3 25 test.fields PS1_V3 PS1_V3 26 test.fields PS1_V4 PS1_V4 27 27 28 28 test.fields PS1_DEV_0 PS1_V4 29 29 test.fields PS1_DEV_1 PS1_V4 30 test.fields PS1_V1 PS1_V431 test.fields PS1_V2 PS1_V432 test.fields PS1_V3 PS1_V433 test.fields PS1_V4 PS1_V430 test.fields PS1_V1 PS1_V4 31 test.fields PS1_V2 PS1_V4 32 test.fields PS1_V3 PS1_V4 33 test.fields PS1_V4 PS1_V4 34 34 end 35 36 if (not($?NO_NOISE)) 37 $NO_NOISE = "" 38 end 35 39 36 40 # create a populated catdir with a single cmf -- test each field … … 50 54 51 55 mkinput 52 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1 56 echo mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1 $NO_NOISE 57 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1 $NO_NOISE 53 58 if ($TAP_VERBOSE) 54 59 echo exec addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass 55 60 exec addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass 56 61 else 62 echo addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass 57 63 exec addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass >& tmp.log 58 64 end … … 112 118 113 119 # some fields require arithmetic manipulations 114 if ("$name:0" == "KRON_FLUX") 115 set v1 = -2.5*log(v1) 116 end 117 if ("$name:0" == "KRON_FLUX_ERR") 118 set v1 = KRON_FLUX_ERR / KRON_FLUX 120 ## if ("$name:0" == "KRON_FLUX") 121 ## set v1 = -2.5*log(v1) 122 ## end 123 ## if ("$name:0" == "KRON_FLUX_ERR") 124 ## set v1 = KRON_FLUX_ERR / KRON_FLUX 125 ## end 126 if (("$name:0" == "X_PSF_SIG") || ("$name:0" == "Y_PSF_SIG")) 127 set v1 = int(100*(v1)) 128 set v2 = int(100*(v2 + 0.0001)) 129 end 130 if ("$name:0" == "POSANGLE") 131 set v1 = int((0xffff/360.0)*(v1)) 132 set v2 = int((0xffff/360.0)*(v2 + 0.0028)) 119 133 end 120 134 … … 206 220 # this list is good for PS1_V1 207 221 list testfields_PS1_V1 208 IPP_IDET : detid 209 X_PSF : xccd 210 Y_PSF : yccd 222 IPP_IDET : detid 223 X_PSF : xccd 224 Y_PSF : yccd 211 225 X_PSF_SIG : xccd:err # FAIL 212 226 Y_PSF_SIG : yccd:err # FAIL … … 215 229 POSANGLE : SKIP # astrometry is not calibrated in the cmf 216 230 PLTSCALE : SKIP # astrometry is not calibrated in the cmf 217 PSF_INST_MAG : mag:inst 218 PSF_INST_MAG_SIG : mag:err 231 PSF_INST_MAG : mag:inst 232 PSF_INST_MAG_SIG : mag:err 219 233 AP_MAG_STANDARD : mag:ap # FAIL 220 234 AP_MAG_RADIUS : SKIP # no accessor … … 222 236 CAL_PSF_MAG : SKIP # photometry is not calibrated in the cmf 223 237 CAL_PSF_MAG_SIG : SKIP # photometry is not calibrated in the cmf 224 SKY : sky 225 SKY_SIG : sky_err 226 PSF_CHISQ : psf_chisq 227 CR_NSIGMA : cr_nsigma 238 SKY : sky 239 SKY_SIG : sky_err 240 PSF_CHISQ : psf_chisq 241 CR_NSIGMA : cr_nsigma 228 242 EXT_NSIGMA : ext_nsigma 229 PSF_MAJOR : FWHM_MAJ 230 PSF_MINOR : FWHM_MIN 243 PSF_MAJOR : FWHM_MAJ 244 PSF_MINOR : FWHM_MIN 231 245 PSF_THETA : THETA # FAIL 232 PSF_QF : PSF_QF 246 PSF_QF : PSF_QF 233 247 PSF_NDOF : SKIP # no accessor 234 248 PSF_NPIX : SKIP # no accessor … … 237 251 MOMENTS_YY : SKIP # no accessor 238 252 FLAGS : phot_flags 239 N_FRAMES : SKIP # no accessor 253 N_FRAMES : SKIP # no accessor 240 254 end 241 255 242 256 # this list is good for PS1_V2 243 257 list testfields_PS1_V2 244 IPP_IDET : detid 245 X_PSF : xccd 246 Y_PSF : yccd 258 IPP_IDET : detid 259 X_PSF : xccd 260 Y_PSF : yccd 247 261 X_PSF_SIG : xccd:err # FAIL 248 262 Y_PSF_SIG : yccd:err # FAIL … … 251 265 POSANGLE : SKIP # astrometry is not calibrated in the cmf 252 266 PLTSCALE : SKIP # astrometry is not calibrated in the cmf 253 PSF_INST_MAG : mag:inst 254 PSF_INST_MAG_SIG : mag:err 267 PSF_INST_MAG : mag:inst 268 PSF_INST_MAG_SIG : mag:err 255 269 AP_MAG_STANDARD : mag:ap # FAIL 256 270 AP_MAG_RADIUS : SKIP # no accessor … … 258 272 CAL_PSF_MAG : SKIP # photometry is not calibrated in the cmf 259 273 CAL_PSF_MAG_SIG : SKIP # photometry is not calibrated in the cmf 260 SKY : sky 261 SKY_SIG : sky_err 262 PSF_CHISQ : psf_chisq 263 CR_NSIGMA : cr_nsigma 274 SKY : sky 275 SKY_SIG : sky_err 276 PSF_CHISQ : psf_chisq 277 CR_NSIGMA : cr_nsigma 264 278 EXT_NSIGMA : ext_nsigma 265 PSF_MAJOR : FWHM_MAJ 266 PSF_MINOR : FWHM_MIN 279 PSF_MAJOR : FWHM_MAJ 280 PSF_MINOR : FWHM_MIN 267 281 PSF_THETA : THETA # FAIL 268 PSF_QF : PSF_QF 282 PSF_QF : PSF_QF 269 283 PSF_NDOF : SKIP # no accessor 270 284 PSF_NPIX : SKIP # no accessor … … 273 287 MOMENTS_YY : SKIP # no accessor 274 288 FLAGS : phot_flags 275 N_FRAMES : SKIP # no accessor 289 N_FRAMES : SKIP # no accessor 276 290 end 277 291 278 292 # this list is good for PS1_V3 279 293 list testfields_PS1_V3 280 IPP_IDET : detid 281 X_PSF : xccd 282 Y_PSF : yccd 294 IPP_IDET : detid 295 X_PSF : xccd 296 Y_PSF : yccd 283 297 X_PSF_SIG : xccd:err # FAIL 284 298 Y_PSF_SIG : yccd:err # FAIL 285 299 POSANGLE : SKIP # astrometry is not calibrated in the cmf 286 300 PLTSCALE : SKIP # astrometry is not calibrated in the cmf 287 PSF_INST_MAG : mag:inst 288 PSF_INST_MAG_SIG : mag:err 301 PSF_INST_MAG : mag:inst 302 PSF_INST_MAG_SIG : mag:err 289 303 PSF_INST_FLUX : SKIP # not ingested into DVO 290 304 PSF_INST_FLUX_SIG : SKIP # not ingested into DVO … … 297 311 DEC_PSF : SKIP # astrometry is not calibrated in the cmf 298 312 PEAK_FLUX_AS_MAG : SKIP # not ingested into DVO 299 SKY : sky 300 SKY_SIG : sky_err 301 PSF_CHISQ : psf_chisq 302 CR_NSIGMA : cr_nsigma 313 SKY : sky 314 SKY_SIG : sky_err 315 PSF_CHISQ : psf_chisq 316 CR_NSIGMA : cr_nsigma 303 317 EXT_NSIGMA : ext_nsigma 304 PSF_MAJOR : FWHM_MAJ 305 PSF_MINOR : FWHM_MIN 318 PSF_MAJOR : FWHM_MAJ 319 PSF_MINOR : FWHM_MIN 306 320 PSF_THETA : THETA # FAIL 307 PSF_QF : PSF_QF 321 PSF_QF : PSF_QF 308 322 PSF_QF_PERFECT : SKIP # not ingested into DVO 309 323 PSF_NDOF : PSF_NDOF … … 326 340 end 327 341 328 # this list is good for PS1_V 4329 list testfields_PS1_V 4330 IPP_IDET : detid 331 X_PSF : xccd 332 Y_PSF : yccd 333 X_PSF_SIG : xccd:err # FAIL334 Y_PSF_SIG : yccd:err # FAIL335 POSANGLE : SKIP # astrometry is not calibrated in the cmf336 PLTSCALE : SKIP # astrometry is not calibrated in the cmf337 PSF_INST_MAG : mag:inst 338 PSF_INST_MAG_SIG : mag:err 339 PSF_INST_FLUX : SKIP # not ingested into DVO340 PSF_INST_FLUX_SIG : SKIP # not ingested into DVO341 AP_MAG : mag:aper inst # FAIL342 # this list is good for PS1_V5 343 list testfields_PS1_V5 344 IPP_IDET : detid 345 X_PSF : xccd 346 Y_PSF : yccd 347 X_PSF_SIG : xccd:err 348 Y_PSF_SIG : yccd:err 349 POSANGLE : posangle 350 PLTSCALE : platescale 351 PSF_INST_MAG : mag:inst 352 PSF_INST_MAG_SIG : mag:err 353 PSF_INST_FLUX : flux:inst 354 PSF_INST_FLUX_SIG : flux:inst:err 355 AP_MAG : mag:aper:inst 342 356 AP_MAG_RAW : SKIP # not ingested into DVO 343 357 AP_MAG_RADIUS : SKIP # not ingested into DVO 344 CAL_PSF_MAG : SKIP # photometry is not calibrated in the cmf 345 CAL_PSF_MAG_SIG : SKIP # photometry is not calibrated in the cmf 346 RA_PSF : SKIP # astrometry is not calibrated in the cmf 347 DEC_PSF : SKIP # astrometry is not calibrated in the cmf 348 PEAK_FLUX_AS_MAG : SKIP # not ingested into DVO 349 SKY : sky 350 SKY_SIGMA : sky_err 351 PSF_CHISQ : psf_chisq 352 CR_NSIGMA : cr_nsigma 353 EXT_NSIGMA : ext_nsigma 354 PSF_MAJOR : FWHM_MAJ 355 PSF_MINOR : FWHM_MIN 356 PSF_THETA : THETA # FAIL 357 PSF_QF : PSF_QF 358 PSF_QF_PERFECT : SKIP # not ingested into DVO 359 PSF_NDOF : PSF_NDOF 360 PSF_NPIX : PSF_NPIX 361 MOMENTS_XX : MXX 362 MOMENTS_XY : MXY 363 MOMENTS_YY : MYY 364 MOMENTS_M3C : SKIP # not ingested into DVO 365 MOMENTS_M3S : SKIP # not ingested into DVO 366 MOMENTS_M4C : SKIP # not ingested into DVO 367 MOMENTS_M4S : SKIP # not ingested into DVO 368 MOMENTS_R1 : SKIP # not ingested into DVO 369 MOMENTS_RH : SKIP # not ingested into DVO 370 KRON_FLUX : mag:kroninst 371 KRON_FLUX_ERR : mag:kronerr 372 KRON_FLUX_INNER : SKIP # not ingested into DVO 373 KRON_FLUX_OUTER : SKIP # not ingested into DVO 374 FLAGS : phot_flags 375 N_FRAMES : SKIP # not ingested into DVO 376 end 358 AP_FLUX : flux:aper:inst 359 AP_FLUX_SIG : flux:aper:inst:err 360 CAL_PSF_MAG : mag:cal 361 CAL_PSF_MAG_SIG : mag:cal:err 362 RA_PSF : ra 363 DEC_PSF : dec 364 AP_NPIX : SKIP # not ingested into DVO 365 PEAK_FLUX_AS_MAG : SKIP # not ingested into DVO 366 SKY : sky 367 SKY_SIGMA : sky_err 368 PSF_CHISQ : psf_chisq 369 CR_NSIGMA : cr_nsigma 370 EXT_NSIGMA : ext_nsigma 371 PSF_MAJOR : fwhm_maj # XXX technically, this is not FWHM but Sigma 372 PSF_MINOR : fwhm_min # XXX technically, this is not FWHM but Sigma 373 PSF_THETA : theta # FAIL 374 PSF_CORE : SKIP # not ingested into DVO 375 PSF_FWHM_MAJ : SKIP # not ingested into DVO 376 PSF_FWHM_MIN : SKIP # not ingested into DVO 377 PSF_QF : psf_qf 378 PSF_QF_PERFECT : SKIP # not ingested into DVO 379 PSF_NDOF : psf_ndof 380 PSF_NPIX : psf_npix 381 MOMENTS_XX : Mxx 382 MOMENTS_XY : Mxy 383 MOMENTS_YY : Myy 384 MOMENTS_M3C : SKIP # not ingested into DVO 385 MOMENTS_M3S : SKIP # not ingested into DVO 386 MOMENTS_M4C : SKIP # not ingested into DVO 387 MOMENTS_M4S : SKIP # not ingested into DVO 388 MOMENTS_R1 : SKIP # not ingested into DVO 389 MOMENTS_RH : SKIP # not ingested into DVO 390 KRON_FLUX : flux:kron:inst 391 KRON_FLUX_ERR : flux:kron:inst:err 392 KRON_FLUX_INNER : SKIP # not ingested into DVO 393 KRON_FLUX_OUTER : SKIP # not ingested into DVO 394 SKY_LIMIT_RAD : SKIP # not ingested into DVO 395 SKY_LIMIT_FLUX : SKIP # not ingested into DVO 396 SKY_LIMIT_SLOPE : SKIP # not ingested into DVO 397 FLAGS : phot_flags 398 FLAGS2 : SKIP # not ingested into DVO 399 N_FRAMES : SKIP # not ingested into DVO 400 end 401 402 # this list is good for PS1_SV3 403 list testfields_PS1_SV3 404 IPP_IDET : detid 405 X_PSF : xccd 406 Y_PSF : yccd 407 X_PSF_SIG : xccd:err 408 Y_PSF_SIG : yccd:err 409 POSANGLE : posangle 410 PLTSCALE : platescale 411 PSF_INST_MAG : mag:inst 412 PSF_INST_MAG_SIG : mag:err 413 PSF_INST_FLUX : flux:inst 414 PSF_INST_FLUX_SIG : flux:inst:err 415 AP_MAG : mag:aper:inst 416 AP_MAG_RAW : SKIP # not ingested into DVO 417 AP_MAG_RADIUS : SKIP # not ingested into DVO 418 AP_FLUX : flux:aper:inst 419 AP_FLUX_SIG : flux:aper:inst:err 420 CAL_PSF_MAG : mag:cal 421 CAL_PSF_MAG_SIG : mag:cal:err 422 RA_PSF : ra 423 DEC_PSF : dec 424 AP_NPIX : SKIP # not ingested into DVO 425 PEAK_FLUX_AS_MAG : SKIP # not ingested into DVO 426 SKY : sky 427 SKY_SIGMA : sky_err 428 PSF_CHISQ : psf_chisq 429 CR_NSIGMA : cr_nsigma 430 EXT_NSIGMA : ext_nsigma 431 PSF_MAJOR : fwhm_maj # XXX technically, this is not FWHM but Sigma 432 PSF_MINOR : fwhm_min # XXX technically, this is not FWHM but Sigma 433 PSF_THETA : theta # FAIL 434 PSF_CORE : SKIP # not ingested into DVO 435 PSF_FWHM_MAJ : SKIP # not ingested into DVO 436 PSF_FWHM_MIN : SKIP # not ingested into DVO 437 PSF_QF : psf_qf 438 PSF_QF_PERFECT : SKIP # not ingested into DVO 439 PSF_NDOF : psf_ndof 440 PSF_NPIX : psf_npix 441 MOMENTS_XX : Mxx 442 MOMENTS_XY : Mxy 443 MOMENTS_YY : Myy 444 MOMENTS_M3C : SKIP # not ingested into DVO 445 MOMENTS_M3S : SKIP # not ingested into DVO 446 MOMENTS_M4C : SKIP # not ingested into DVO 447 MOMENTS_M4S : SKIP # not ingested into DVO 448 MOMENTS_R1 : SKIP # not ingested into DVO 449 MOMENTS_RH : SKIP # not ingested into DVO 450 KRON_FLUX : flux:kron:inst 451 KRON_FLUX_ERR : flux:kron:inst:err 452 KRON_FLUX_INNER : SKIP # not ingested into DVO 453 KRON_FLUX_OUTER : SKIP # not ingested into DVO 454 FLAGS : phot_flags 455 FLAGS2 : SKIP # not ingested into DVO 456 N_FRAMES : SKIP # not ingested into DVO 457 end -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/delstar/include/delstar.h
r35837 r37403 67 67 int UPDATE; 68 68 int IMAGE_DETAILS; 69 int IMAGE_DUPLICATES_BY_OBSTIME; 69 70 int IMAGE_ONLY; 70 71 int ORPHAN; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/delstar/src/ImageOpsFixLAP.c
r35758 r37403 1 1 # include "delstar.h" 2 # define FT_BZERO_INT32 1.0*0x800000003 2 4 3 off_t Nimage = 0; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/delstar/src/ImageSubsetFixLAP.c
r35758 r37403 1 1 # include "delstar.h" 2 # define FT_BZERO_INT16 1.0*0x80003 # define FT_BZERO_INT32 1.0*0x800000004 2 5 3 # define GET_COLUMN(OUT,NAME,TYPE) \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/delstar/src/MeasureEdgeOps.c
r35758 r37403 1 1 # include "delstar.h" 2 # define FT_BZERO_INT32 1.0*0x800000003 2 4 3 # define GET_COLUMN(OUT,NAME,TYPE) \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/delstar/src/args.c
r35758 r37403 18 18 fprintf (stderr, " -image-details : list info about the deleted images (-dup-images only)\n"); 19 19 fprintf (stderr, " -image-only : only examine the image table (changes are NOT saved; -dup-images only)\n"); 20 fprintf (stderr, " -image-only-force : modify only the image table (-dup-images only)\n"); 21 fprintf (stderr, " -image-by-obstime : use date/time and photcode (not externID) to find duplicates\n"); 20 22 fprintf (stderr, " -region Rmin Rmax Dmin Dmax : apply changes to this part of the sky\n"); 21 23 … … 68 70 if ((N = get_argument (argc, argv, "-image-details"))) { 69 71 IMAGE_DETAILS = TRUE; 72 remove_argument (N, &argc, argv); 73 } 74 75 IMAGE_DUPLICATES_BY_OBSTIME = FALSE; 76 if ((N = get_argument (argc, argv, "-image-by-obstime"))) { 77 IMAGE_DUPLICATES_BY_OBSTIME = TRUE; 70 78 remove_argument (N, &argc, argv); 71 79 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/delstar/src/delete_duplicate_images.c
r35758 r37403 1 1 # include "delstar.h" 2 3 IndexArray *find_duplicates_obstime (Image *image, off_t Nimage, off_t *Nduplicates); 4 off_t find_obstime_range (Image *image, off_t Nimage, off_t firstEntry); 5 void sort_by_obstime (e_time *T, short *P, off_t *I, off_t N); 6 void sort_by_photcode (short *P, off_t *I, off_t N); 2 7 3 8 // this function identifies the images to be deleted based on duplication of the … … 18 23 19 24 off_t Nduplicates = 0; 20 IndexArray *imageID = find_duplicates (image, Nimage, &Nduplicates); 25 IndexArray *imageID = NULL; 26 27 if (IMAGE_DUPLICATES_BY_OBSTIME) { 28 imageID = find_duplicates_obstime (image, Nimage, &Nduplicates); 29 } else { 30 imageID = find_duplicates (image, Nimage, &Nduplicates); 31 } 21 32 22 33 if (Nduplicates == 0) { … … 494 505 } 495 506 507 // sort by increasing obstime 508 void sort_by_obstime (e_time *T, short *P, off_t *I, off_t N) { 509 510 # define SWAPFUNC(A,B){ e_time tmpT; short tmpP; off_t tmpI; \ 511 tmpT = T[A]; T[A] = T[B]; T[B] = tmpT; \ 512 tmpP = P[A]; P[A] = P[B]; P[B] = tmpP; \ 513 tmpI = I[A]; I[A] = I[B]; I[B] = tmpI; \ 514 } 515 # define COMPARE(A,B)(T[A] < T[B]) 516 517 OHANA_SORT (N, COMPARE, SWAPFUNC); 518 519 # undef SWAPFUNC 520 # undef COMPARE 521 522 } 523 524 // sort by increasing photcode 525 void sort_by_photcode (short *P, off_t *I, off_t N) { 526 527 # define SWAPFUNC(A,B){ short tmpP; off_t tmpI; \ 528 tmpP = P[A]; P[A] = P[B]; P[B] = tmpP; \ 529 tmpI = I[A]; I[A] = I[B]; I[B] = tmpI; \ 530 } 531 # define COMPARE(A,B)(P[A] < P[B]) 532 533 OHANA_SORT (N, COMPARE, SWAPFUNC); 534 535 # undef SWAPFUNC 536 # undef COMPARE 537 538 } 539 540 static e_time *obstime = NULL; 541 static short *photcode = NULL; 542 static off_t *primary = NULL; 543 static off_t *idx = NULL; 544 static char *keep = NULL; 545 546 static short *photcode_subset = NULL; 547 static off_t *idx_subset = NULL; 548 549 static off_t Nsubset = 0; 550 static off_t NSUBSET = 300; 551 552 off_t find_obstime_range (Image *image, off_t Nimage, off_t firstEntry) { 553 554 Nsubset = 0; 555 556 // find all entries with the same obstime: 557 e_time firstTime = obstime[firstEntry]; 558 559 idx_subset[Nsubset] = idx[firstEntry]; 560 photcode_subset[Nsubset] = photcode[firstEntry]; 561 Nsubset++; 562 563 off_t i = firstEntry + Nsubset; 564 while ((i < Nimage) && (obstime[i] == firstTime)) { 565 idx_subset[Nsubset] = idx[i]; 566 photcode_subset[Nsubset] = photcode[i]; 567 Nsubset++; 568 i++; 569 if (Nsubset >= NSUBSET) { 570 NSUBSET += 1000; 571 REALLOCATE (photcode_subset, short, NSUBSET); 572 REALLOCATE (idx_subset, off_t, NSUBSET); 573 } 574 } 575 576 sort_by_photcode (photcode_subset, idx_subset, Nsubset); 577 578 return i; 579 } 580 581 // alternative version to find duplicates based on obstime and photcode 582 IndexArray *find_duplicates_obstime (Image *image, off_t Nimage, off_t *Nduplicates) { 583 584 if (Nimage < 1) return NULL; 585 586 // how to find duplicates: 587 // generate a set of arrays (idx, obstime, photcode, keep) 588 // sort the arrays by obstime 589 // loop over obstime. 590 // for a given new obstime, scan through the entries with the same value 591 // create a sub-array of photcodes, idx 592 // sort by photcode 593 // loop over entries 594 // find matching photcodes 595 // mark duplicate enties 596 597 ALLOCATE (obstime, e_time, Nimage); 598 ALLOCATE (photcode, short, Nimage); 599 ALLOCATE (primary, off_t, Nimage); 600 ALLOCATE (idx, off_t, Nimage); 601 ALLOCATE (keep, char, Nimage); 602 603 off_t i; 604 605 INITTIME; 606 607 // skip entries with photcode == 0? 608 for (i = 0; i < Nimage; i++) { 609 idx[i] = i; 610 primary[i] = -1; // only duplicates get a value for primary 611 keep[i] = TRUE; 612 obstime[i] = image[i].tzero; 613 photcode[i] = image[i].photcode; 614 } 615 MARKTIME(" generate index arrays: %f sec\n", dtime); 616 617 // sort the 4 arrays 618 sort_by_obstime (obstime, photcode, idx, Nimage); 619 MARKTIME(" sort index arrays: %f sec\n", dtime); 620 621 // image[idx[i]].tzero = obstime[i] 622 // keep[i] -> keep image[i] ('keep' is NOT resorted) 623 624 // allocate arrays to store the subsets (these are global static) 625 // These get reallocated if necessary in find_obstime_range() 626 ALLOCATE (photcode_subset, short, NSUBSET); 627 ALLOCATE (idx_subset, off_t, NSUBSET); 628 629 // entries of idx_subset correspond to the original image sequence: 630 // image[idx_subset[i]].tzero = obstime[i] 631 632 off_t firstEntry = 0; 633 off_t nextEntry = 0; 634 635 while (nextEntry < Nimage) { 636 if (firstEntry >= Nimage) { 637 fprintf (stderr, "error, too far?\n"); 638 } 639 640 // generate photcode_subset, idx_subset in order of photcode for this unique obstime[firstEntry] 641 // returned value is the first value of the next entry 642 nextEntry = find_obstime_range (image, Nimage, firstEntry); 643 644 // step through the photcodes and find duplicates 645 int j; 646 int firstCodeEntry = 0; 647 short firstCode = photcode_subset[firstCodeEntry]; 648 for (j = 1; j < Nsubset; j++) { 649 if (photcode_subset[j] == firstCode) { 650 // mark as duplicate 651 off_t dupIndex = idx_subset[j]; 652 keep[dupIndex] = FALSE; 653 primary[dupIndex] = idx_subset[firstCodeEntry]; 654 } else { 655 // new value of photcode, call if the first one 656 firstCodeEntry = j; 657 firstCode = photcode_subset[firstCodeEntry]; 658 } 659 } 660 firstEntry = nextEntry; 661 } 662 MARKTIME(" find duplicates: %f sec\n", dtime); 663 664 IndexArray *imageID = make_index_array (image, Nimage, IMAGE_ID); 665 MARKTIME(" make index array: %f sec\n", dtime); 666 667 // set imageID->value to TRUE for images we want to delete 668 off_t Ndup = 0; 669 for (i = 0; i < Nimage; i++) { 670 if (keep[i]) continue; 671 off_t Ni = image[i].imageID - imageID->minID; 672 myAssert (Ni >= 0, "oops"); 673 myAssert (Ni < imageID->range, "oops"); 674 imageID->value[Ni] = TRUE; 675 Ndup ++; 676 } 677 MARKTIME(" mark duplicates: %f sec\n", dtime); 678 679 for (i = 0; IMAGE_DETAILS && (i < Nimage); i++) { 680 off_t Ni = image[i].imageID - imageID->minID; 681 if (!imageID->value[Ni]) continue; 682 683 char *date = NULL; 684 date = ohana_sec_to_date (image[i].tzero); 685 fprintf (stderr, "delete image : (" OFF_T_FMT "), extID = %d : %30s : %20s %5d == ", i, image[i].externID, image[i].name, date, image[i].photcode); 686 free (date); 687 688 off_t myPrimary = primary[i]; 689 if (myPrimary < 0) { 690 fprintf (stderr, "ERROR: this should never happen\n"); 691 abort(); 692 } 693 date = ohana_sec_to_date (image[myPrimary].tzero); 694 fprintf (stderr, "parent image : (" OFF_T_FMT "), extID = %d : %30s : %20s %5d\n", myPrimary, image[myPrimary].externID, image[myPrimary].name, date, image[myPrimary].photcode); 695 free (date); 696 } 697 698 *Nduplicates = Ndup; 699 700 free (photcode_subset); 701 free (idx_subset); 702 703 free (obstime); 704 free (photcode); 705 free (primary); 706 free (idx); 707 free (keep); 708 709 return imageID;; 710 } 711 496 712 // find the min & max values of the given ID (externID or imageID) 497 713 // construct an empty array with length needed to fit IDs -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/delstar/src/delete_fix_LAP_edges.c
r35805 r37403 206 206 double Dgapmin = Dmin + dD; 207 207 double Dgapmax = Dmax - dD; 208 209 float cosDec = cos(RAD_DEG * 0.5 * (Dmin + Dmax)); 208 210 209 211 // XXX should deal with pole, but not yet... … … 218 220 float maxOff = 0.0; 219 221 m = catalog[0].average[i].measureOffset; 222 220 223 for (j = 0; j < catalog[0].average[i].Nmeasure; j++) { 221 float dRoff = catalog[0].measure[m+j].dR * cos(RAD_DEG * 0.5 * (Dmin + Dmax)); 222 float dDoff = catalog[0].measure[m+j].dD; 224 225 float dRoff = dvoOffsetR(&catalog[0].measure[m+j], &catalog[0].average[i])*cosDec; 226 float dDoff = dvoOffsetD(&catalog[0].measure[m+j], &catalog[0].average[i]); 223 227 float dOff = hypot (dRoff, dDoff); 224 228 maxOff = MAX (maxOff, dOff); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/include/dvomerge.h
r35765 r37403 129 129 int merge_catalogs_old PROTO((SkyRegion *region, Catalog *output, Catalog *input, double RADIUS, int *secflitMap)); 130 130 131 off_t *build_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure)); 131 132 off_t *init_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure)); 133 int add_meas_link PROTO((Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE)); 134 Measure *sort_measure PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next)); 135 136 off_t *build_lensing_links PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing)); 137 off_t *init_lensing_links PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing)); 138 int add_lens_link PROTO((Average *average, off_t *next, off_t Nlensing, off_t NLENSING)); 139 Lensing *sort_lensing PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next)); 140 132 141 off_t *init_missing_links PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing)); 133 off_t *build_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure));134 int add_meas_link PROTO((Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE));135 142 int add_miss_link PROTO((Average *average, off_t *next, off_t Nmissing)); 136 Measure *sort_measure PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next));137 143 Missing *sort_missing PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss)); 138 144 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/include/dvoverify.h
r34405 r37403 56 56 int LoadImageIDs (char *catdir); 57 57 int CheckImageID (Catalog *catalog); 58 59 int SaveImageIDsSmall(char *filename); 60 int LoadImageIDsSmall (char *filename); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/IDmapIO.c
r34277 r37403 27 27 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_ID_MAP"); 28 28 29 gfits_define_bintable_column (&theader, "J", "OLD_IDS", "old image IDs", NULL, 1.0, 1.0*0x8000);30 gfits_define_bintable_column (&theader, "J", "NEW_IDS", "new image IDs", NULL, 1.0, 1.0*0x8000);29 gfits_define_bintable_column (&theader, "J", "OLD_IDS", "old image IDs", NULL, 1.0, FT_BZERO_INT32); 30 gfits_define_bintable_column (&theader, "J", "NEW_IDS", "new image IDs", NULL, 1.0, FT_BZERO_INT32); 31 31 32 32 // generate the output array that carries the data -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/LoadCatalog.c
r29938 r37403 8 8 9 9 // always load all of the data (if any exists) 10 catalog[0].catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF ;10 catalog[0].catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF | LOAD_LENSING | LOAD_LENSOBJ; 11 11 12 12 catalog[0].catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/build_links.c
r27435 r37403 1 1 # include "dvomerge.h" 2 3 /* 4 5 There are two modes for the measure table: sorted and unsorted. 6 7 In sorted mode, all measures associated with a given average are in a single block. The block 8 is pointed to by average->measureOffset and the range is average->Nmeasure 9 10 In unsorted mode, it is not possible to go directly from average to measure without scanning. 11 In this case, it is necessary to use the value measure->averef to find the corresponding 12 average entry. 13 14 Note that average->measureOffset and measure->averef are only valid for a given load of the 15 data: they refer to the sequence number in the data blocks. 16 17 next_meas is a list of the equivalent sequence of the measure block as if it were sorted. 18 19 to find the sequence of measurements for a given average: 20 n_0 = average->measureOffset 21 n_1 = next_meas[n_0] 22 n_i = next_meas[n_i-1] 23 24 */ 2 25 3 26 /* build the initial links assuming the table is sorted, … … 6 29 7 30 off_t i, j, N; 8 off_t *next ;31 off_t *next_meas; 9 32 10 33 N = 0; 11 34 12 ALLOCATE (next , off_t, Nmeasure);35 ALLOCATE (next_meas, off_t, Nmeasure); 13 36 for (i = 0; i < Naverage; i++, N++) { 14 37 for (j = 0; j < average[i].Nmeasure - 1; j++, N++) { 15 next [N] = N + 1;38 next_meas[N] = N + 1; 16 39 if (N >= Nmeasure) { 17 40 fprintf (stderr, "WARNING: N out of bounds (1)\n"); 18 41 } 19 42 } 20 next [N] = -1;43 next_meas[N] = -1; 21 44 if (N >= Nmeasure) { 22 45 fprintf (stderr, "WARNING: N out of bounds (2)\n"); … … 28 51 } 29 52 } 30 return (next); 31 } 32 33 /* average[].measureOffset, average[].Nmeasure are valid within an addstar run */ 34 int add_meas_link (Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE) { 35 36 off_t k, m; 37 38 /* if we have trouble, check validity of next[m] : m < Nmeasure */ 39 m = average[0].measureOffset; 40 41 for (k = 0; k < average[0].Nmeasure - 1; k++) { 42 m = next[m]; 43 if (m >= NMEASURE) { 44 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 45 } 46 } 47 48 /* set up references */ 49 next[Nmeasure] = -1; 50 if (Nmeasure >= NMEASURE) { 51 fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n"); 52 } 53 54 if (m == -1) { 55 average[0].measureOffset = Nmeasure; 56 } else { 57 next[m] = Nmeasure; 58 if (m >= NMEASURE) { 59 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 60 } 61 } 62 63 return (TRUE); 64 } 65 66 Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next) { 67 68 off_t i, k, n, N; 69 Measure *tmpmeasure; 70 71 /* fix order of Measure (memory intensive, but fast) */ 72 N = 0; 73 ALLOCATE (tmpmeasure, Measure, Nmeasure); 74 for (i = 0; i < Naverage; i++) { 75 n = average[i].measureOffset; 76 average[i].measureOffset = N; 77 for (k = 0; k < average[i].Nmeasure; k++, N++) { 78 tmpmeasure[N] = measure[n]; 79 tmpmeasure[N].averef = i; 80 n = next[n]; 81 } 82 } 83 free (measure); 84 return (tmpmeasure); 53 return (next_meas); 85 54 } 86 55 … … 95 64 96 65 off_t i, m, k, Nm, averef; 97 off_t *next ;98 99 ALLOCATE (next , off_t, Nmeasure);66 off_t *next_meas; 67 68 ALLOCATE (next_meas, off_t, Nmeasure); 100 69 101 70 /* reset the Nm, offset values for average */ … … 108 77 averef = measure[Nm].averef; 109 78 m = average[averef].measureOffset; 110 next [Nm] = -1;79 next_meas[Nm] = -1; 111 80 112 81 if (m == -1) { /* no links yet for source */ … … 116 85 } 117 86 118 for (k = 0; next [m] != -1; k++) {119 m = next [m];87 for (k = 0; next_meas[m] != -1; k++) { 88 m = next_meas[m]; 120 89 if (m >= Nmeasure) { 121 90 fprintf (stderr, "WARNING: m out of bounds (1)\n"); … … 124 93 125 94 average[averef].Nmeasure = k + 2; 126 next [m] = Nm;95 next_meas[m] = Nm; 127 96 if (m >= Nmeasure) { 128 97 fprintf (stderr, "WARNING: m out of bounds (2)\n"); 129 98 } 130 99 } 131 return (next); 132 } 100 return (next_meas); 101 } 102 103 /* average[].measureOffset, average[].Nmeasure are valid within an addstar run */ 104 int add_meas_link (Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE) { 105 106 off_t k, m; 107 108 /* if we have trouble, check validity of next_meas[m] : m < Nmeasure */ 109 m = average[0].measureOffset; 110 111 for (k = 0; k < average[0].Nmeasure - 1; k++) { 112 m = next_meas[m]; 113 if (m >= NMEASURE) { 114 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 115 } 116 } 117 118 /* set up references */ 119 next_meas[Nmeasure] = -1; 120 if (Nmeasure >= NMEASURE) { 121 fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n"); 122 } 123 124 if (m == -1) { 125 average[0].measureOffset = Nmeasure; 126 } else { 127 next_meas[m] = Nmeasure; 128 if (m >= NMEASURE) { 129 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 130 } 131 } 132 133 return (TRUE); 134 } 135 136 Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next_meas) { 137 138 off_t i, k, n, N; 139 Measure *tmpmeasure; 140 141 /* fix order of Measure (memory intensive, but fast) */ 142 N = 0; 143 ALLOCATE (tmpmeasure, Measure, Nmeasure); 144 for (i = 0; i < Naverage; i++) { 145 n = average[i].measureOffset; 146 average[i].measureOffset = N; 147 for (k = 0; k < average[i].Nmeasure; k++, N++) { 148 if (n == -1) abort(); 149 tmpmeasure[N] = measure[n]; 150 if (measure[n].averef != i) abort(); 151 tmpmeasure[N].averef = i; 152 n = next_meas[n]; 153 } 154 } 155 free (measure); 156 return (tmpmeasure); 157 } 158 159 /*******************************************************************************************/ 133 160 134 161 /* build the initial links assuming the table is sorted */ … … 136 163 137 164 off_t i, j, N; 138 off_t *next ;165 off_t *next_miss; 139 166 140 167 N = 0; 141 168 142 ALLOCATE (next , off_t, Nmissing);169 ALLOCATE (next_miss, off_t, Nmissing); 143 170 for (i = 0; i < Naverage; i++) { 144 171 for (j = 0; j < average[i].Nmissing - 1; j++, N++) { 145 next [N] = N + 1;172 next_miss[N] = N + 1; 146 173 } 147 174 if (average[i].Nmissing > 0) { 148 next [N] = -1;175 next_miss[N] = -1; 149 176 if (N >= Nmissing) { 150 177 fprintf (stderr, "overflow in init_missing_links"); … … 155 182 156 183 } 157 return (next );158 } 159 160 int add_miss_link (Average *average, off_t *next , off_t Nmissing) {184 return (next_miss); 185 } 186 187 int add_miss_link (Average *average, off_t *next_miss, off_t Nmissing) { 161 188 162 189 off_t k, m; … … 165 192 if (average[0].Nmissing < 1) { 166 193 average[0].missingOffset = Nmissing; 167 next [Nmissing] = -1;194 next_miss[Nmissing] = -1; 168 195 return (TRUE); 169 196 } 170 197 171 198 m = average[0].missingOffset; 172 for (k = 0; k < average[0].Nmissing - 1; k++) m = next [m];199 for (k = 0; k < average[0].Nmissing - 1; k++) m = next_miss[m]; 173 200 /* set up references */ 174 next [Nmissing] = -1;175 next [m] = Nmissing;201 next_miss[Nmissing] = -1; 202 next_miss[m] = Nmissing; 176 203 return (TRUE); 177 204 } … … 180 207 we must always save the missing table, if it exists */ 181 208 182 Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next ) {209 Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss) { 183 210 184 211 off_t i, k, n, N; … … 193 220 for (k = 0; k < average[i].Nmissing; k++, N++) { 194 221 tmpmissing[N] = missing[n]; 195 n = next [n];222 n = next_miss[n]; 196 223 } 197 224 } … … 199 226 return (tmpmissing); 200 227 } 228 229 /*******************************************************************************************/ 230 231 /* build the initial links assuming the table is sorted, 232 not partial, and has a correct set of average[].lensingOffset,Nlensing values */ 233 off_t *init_lensing_links (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing) { 234 235 off_t i, j, N; 236 off_t *next_lens; 237 238 N = 0; 239 240 ALLOCATE (next_lens, off_t, Nlensing); 241 for (i = 0; i < Naverage; i++) { 242 if (!average[i].Nlensing) continue; 243 for (j = 0; j < average[i].Nlensing - 1; j++, N++) { 244 next_lens[N] = N + 1; 245 if (N >= Nlensing) { 246 fprintf (stderr, "WARNING: N out of bounds (1)\n"); 247 } 248 } 249 next_lens[N] = -1; 250 if (N >= Nlensing) { 251 fprintf (stderr, "WARNING: N out of bounds (2)\n"); 252 } 253 254 if (N >= Nlensing) { 255 fprintf (stderr, "overflow in init_lensing_links\n"); 256 abort (); 257 } 258 N++; 259 } 260 return (next_lens); 261 } 262 263 /* construct lensing links which are valid FOR THIS LOAD 264 * - if we have a full load, we will get links which can 265 * be used by other programs (eg, relphot, etc) 266 * - if we have a partial load, the links are only valid 267 * for that partial load 268 */ 269 270 off_t *build_lensing_links (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing) { 271 272 off_t i, m, k, Nm, averef; 273 off_t *next_lens; 274 275 ALLOCATE (next_lens, off_t, Nlensing); 276 277 /* reset the Nm, offset values for average */ 278 for (i = 0; i < Naverage; i++) { 279 average[i].lensingOffset = -1; 280 average[i].Nlensing = 0; 281 } 282 283 for (Nm = 0; Nm < Nlensing; Nm++) { 284 averef = lensing[Nm].averef; 285 m = average[averef].lensingOffset; 286 next_lens[Nm] = -1; 287 288 if (m == -1) { /* no links yet for source */ 289 average[averef].lensingOffset = Nm; 290 average[averef].Nlensing = 1; 291 continue; 292 } 293 294 for (k = 0; next_lens[m] != -1; k++) { 295 m = next_lens[m]; 296 if (m >= Nlensing) { 297 fprintf (stderr, "WARNING: m out of bounds (1)\n"); 298 } 299 } 300 301 average[averef].Nlensing = k + 2; 302 next_lens[m] = Nm; 303 if (m >= Nlensing) { 304 fprintf (stderr, "WARNING: m out of bounds (2)\n"); 305 } 306 } 307 return (next_lens); 308 } 309 310 /* average[].lensingOffset, average[].Nlensing are valid within an addstar run */ 311 int add_lens_link (Average *average, off_t *next_lens, off_t Nlensing, off_t NLENSING) { 312 313 off_t k, m; 314 315 /* if we have trouble, check validity of next_lens[m] : m < Nlensing */ 316 m = average[0].lensingOffset; 317 318 for (k = 0; k < average[0].Nlensing - 1; k++) { 319 m = next_lens[m]; 320 if (m >= NLENSING) { 321 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 322 } 323 } 324 325 /* set up references */ 326 next_lens[Nlensing] = -1; 327 if (Nlensing >= NLENSING) { 328 fprintf (stderr, "WARNING: Nlensing out of bounds (1)\n"); 329 } 330 331 if (m == -1) { 332 average[0].lensingOffset = Nlensing; 333 } else { 334 next_lens[m] = Nlensing; 335 if (m >= NLENSING) { 336 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 337 } 338 } 339 340 return (TRUE); 341 } 342 343 Lensing *sort_lensing (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next_lens) { 344 345 off_t i, k, n, np, N; 346 Lensing *tmplensing; 347 348 /* 349 for (i = 0; i < Naverage; i++) { 350 if (average[i].Nlensing != 4) { 351 fprintf (stderr, "check %d %d %d\n", (int) i, (int) average[i].Nlensing, (int) average[i].lensingOffset); 352 } 353 } 354 */ 355 356 /* fix order of Lensing (memory intensive, but fast) */ 357 N = 0; 358 ALLOCATE (tmplensing, Lensing, Nlensing); 359 for (i = 0; i < Naverage; i++) { 360 if (!average[i].Nlensing) continue; 361 n = average[i].lensingOffset; 362 average[i].lensingOffset = N; 363 for (k = 0; k < average[i].Nlensing; k++, N++) { 364 if (n == -1) { 365 fprintf (stderr, "entry after %d has a problem\n", (int) np); 366 abort(); 367 } 368 tmplensing[N] = lensing[n]; 369 if (lensing[n].averef != i) abort(); 370 tmplensing[N].averef = i; 371 np = n; 372 n = next_lens[n]; 373 } 374 } 375 free (lensing); 376 return (tmplensing); 377 } 378 379 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r36680 r37403 172 172 } 173 173 174 if (!IDmap->Nmap) { 175 fprintf (stderr, "input database has image IDs, but no Image table\n"); 176 return FALSE; 177 } 178 174 179 off_t lastID = IDmap->old[IDmap->Nmap-1]; 175 180 181 // update measure.imageID 176 182 for (i = 0; i < catalog[0].Nmeasure; i++) { 177 183 oldID = catalog[0].measure[i].imageID; … … 195 201 catalog[0].measure[i].imageID = newID; 196 202 } 203 204 // also update lensing.imageID if lensing exists 205 for (i = 0; i < catalog[0].Nlensing; i++) { 206 oldID = catalog[0].lensing[i].imageID; 207 if (oldID == 0) continue; 208 209 newID = dvo_map_image_ID (IDmap, oldID); 210 if (newID == 0) { 211 if (oldID > lastID) { 212 fprintf (stderr, "problem with image IDs : input out of range\n"); 213 fprintf (stderr, "old ID: "OFF_T_FMT", last ID: "OFF_T_FMT"\n", oldID, lastID); 214 exit (2); 215 } 216 if (!IDmap->notFound[oldID]) { 217 fprintf (stderr, "cannot find image ID "OFF_T_FMT"\n", oldID); 218 IDmap->notFound[oldID] = TRUE; 219 // once we discover an imageID is not found, record that fact so we do not complain for every detection 220 } 221 // optionally exit here? or wait until end to report an error? 222 // exit (2); 223 } 224 catalog[0].lensing[i].imageID = newID; 225 } 197 226 return TRUE; 198 227 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeContinue.c
r34260 r37403 131 131 merge_catalogs_old (&outsky[0].regions[j], &outcatalog, &incatalog, RADIUS, secfiltMap); 132 132 133 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;134 135 133 // if we receive a signal which would cause us to exit, wait until the full catalog is written 136 134 SetProtect (TRUE); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeContinue_threaded.c
r34260 r37403 74 74 merge_catalogs_old (&threadData->outsky->regions[j], &outcatalog, &incatalog, RADIUS, threadData->secfiltMap); 75 75 76 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;77 78 76 // if we receive a signal which would cause us to exit, wait until the full catalog is written 79 77 SetProtect (TRUE); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeCreate.c
r33963 r37403 178 178 SkyListFree (inlist); 179 179 180 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;181 180 dvo_catalog_save (&outcatalog, VERBOSE); 182 181 dvo_catalog_unlock (&outcatalog); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeFromList.c
r35590 r37403 143 143 merge_catalogs_old (&skyregion, &outcatalog, &incatalog, RADIUS, secfiltMap); 144 144 145 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;146 147 145 dmhObjectAdd (outstat[0].history, &outcatalog.header, inStats); 148 146 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeImageIDs.c
r35765 r37403 18 18 if (inDB.dbstate == LCK_EMPTY) { 19 19 dvo_image_unlock (&inDB); // unlock input 20 IDmap->old = NULL; 21 IDmap->new = NULL; 20 22 IDmap->Nmap = 0; 21 23 return TRUE; … … 99 101 if (inDB.dbstate == LCK_EMPTY) { 100 102 dvo_image_unlock (&inDB); // unlock input 103 IDmap->old = NULL; 104 IDmap->new = NULL; 101 105 IDmap->Nmap = 0; 102 106 return TRUE; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeUpdate.c
r36680 r37403 13 13 int NsecfiltInput, NsecfiltOutput; 14 14 15 double dtime; 16 struct timeval start, stop; 17 gettimeofday (&start, NULL); 15 INITTIME; 18 16 19 17 CONTINUE = FALSE; … … 121 119 } 122 120 123 gettimeofday (&stop, NULL);124 dtime = DTIME (stop, start);125 126 121 if (!status) { 127 fprintf (stderr,"ERROR: elapsed time %9.4f sec\n", dtime);122 MARKTIME ("ERROR: elapsed time %9.4f sec\n", dtime); 128 123 exit (3); 129 124 } 130 125 131 fprintf (stderr,"SUCCESS: elapsed time %9.4f sec\n", dtime);126 MARKTIME ("SUCCESS: elapsed time %9.4f sec\n", dtime); 132 127 exit (0); 133 128 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
r36680 r37403 140 140 } 141 141 142 if (!incatalog.sorted) { 143 fprintf (stderr, "ERROR: input catalog %s is not sorted (and must be for dvomerge)\n", filename_input); 144 exit (1); 145 } 146 142 147 dvo_update_image_IDs (IDmap, &incatalog); 143 148 … … 158 163 LoadCatalog (&outcatalog, outlist[0].regions[j], outcatalog.filename, "w", NsecfiltOutput); 159 164 165 // if no catalog already exists, use the input catalog to define the format 166 if (outcatalog.Naves_disk == 0) { 167 outcatalog.catformat = incatalog.catformat; 168 } 169 160 170 merge_catalogs_old (outlist[0].regions[j], &outcatalog, &incatalog, RADIUS, secfiltMap); 161 162 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;163 171 164 172 if (outstat[j].missed) { -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeUpdate_threaded.c
r35765 r37403 72 72 merge_catalogs_old (&threadData->outsky->regions[j], &outcatalog, &incatalog, RADIUS, threadData->secfiltMap); 73 73 74 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;75 76 74 // if we receive a signal which would cause us to exit, wait until the full catalog is written 77 75 SetProtect (TRUE); … … 115 113 int NsecfiltInput, NsecfiltOutput; 116 114 117 double dtime; 118 struct timeval start, stop; 119 gettimeofday (&start, NULL); 115 INITTIME; 120 116 121 117 CONTINUE = FALSE; … … 134 130 135 131 fprintf (stderr, "WARNING / ERROR : multi-threaded dvomerge does not handle merge tracking yet\n"); 132 fprintf (stderr, "WARNING / ERROR : multi-threaded dvomerge does work in a parallel context\n"); 136 133 exit (2); 137 134 … … 293 290 } 294 291 295 gettimeofday (&stop, NULL); 296 dtime = DTIME (stop, start); 297 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec\n", dtime); 298 292 MARKTIME ("SUCCESS: elapsed time %9.4f sec\n", dtime); 299 293 exit (0); 300 294 … … 318 312 } 319 313 } 314 MARKTIME ("ERROR: elapsed time %9.4f sec\n", dtime); 320 315 exit (1); 321 316 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvorepair.c
r29938 r37403 2 2 3 3 int main (int argc, char **argv) { 4 5 fprintf (stderr, "this program needs to be updated to load old format Measure tables (pre PV1_V5) in which dR,dD are saved, not R,D\n"); 6 fprintf (stderr, "reminder: relastro can re-construct R,D from X,Y; FtableToMeasure and vice versa could just NAN those values\n"); 7 exit (2); 4 8 5 9 dvorepair_help(argc, argv); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvorepairCPT.c
r33657 r37403 76 76 } 77 77 78 measure = FtableToMeasure (&cpmFtable, &Nmeasure, &catformat);78 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat); 79 79 myAssert(measure, "failed to convert ftable to measure data"); 80 80 … … 126 126 average[Nave].measureOffset = -1; 127 127 average[Nave].missingOffset = -1; 128 average[Nave].extendOffset = -1; 128 average[Nave].refColorBlue = NAN; 129 average[Nave].refColorRed = NAN; 129 130 130 131 average[Nave].objID = measure[i].objID; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvorepairDeleteImageList.c
r29938 r37403 250 250 gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow); 251 251 252 measure = FtableToMeasure (&cpmFtable, &Nmeasure, &catformat);252 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat); 253 253 myAssert(measure, "failed to convert ftable to measure data"); 254 254 … … 288 288 289 289 // convert internal to external format 290 if (!MeasureToFtable (&cpmFtable, measureNew, NmeasureNew, catformat)) {290 if (!MeasureToFtable (&cpmFtable, NULL, measureNew, NmeasureNew, catformat)) { 291 291 myAbort("trouble converting format"); 292 292 } … … 411 411 average[Nave].measureOffset = -1; 412 412 average[Nave].missingOffset = -1; 413 average[Nave].extendOffset = -1; 413 average[Nave].refColorBlue = NAN; 414 average[Nave].refColorRed = NAN; 414 415 415 416 average[Nave].objID = measure[i].objID; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvorepairFixCPT.c
r29938 r37403 120 120 } 121 121 122 measure = FtableToMeasure (&cpmFtable, &Nmeasure, &catformat);122 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat); 123 123 myAssert(measure, "failed to convert ftable to measure data"); 124 124 … … 127 127 128 128 // convert internal to external format 129 if (!MeasureToFtable (&cpmFtable, measure, Nmeasure, catformat)) {129 if (!MeasureToFtable (&cpmFtable, NULL, measure, Nmeasure, catformat)) { 130 130 myAbort("trouble converting format"); 131 131 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvorepairFixTables.c
r29938 r37403 103 103 104 104 // convert internal to external format 105 if (!MeasureToFtable (&cpmFtable, measureNew, NmeasureNew, catformat)) {105 if (!MeasureToFtable (&cpmFtable, NULL, measureNew, NmeasureNew, catformat)) { 106 106 myAbort("trouble converting format"); 107 107 } … … 183 183 gfits_scan(&cpmHeaderTBL, "NAXIS2", "%d", 1, &Nrows); 184 184 185 measure = FtableToMeasure (&cpmFtable, &Nmeasure, &catformat);185 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat); 186 186 myAssert(measure, "failed to convert ftable to measure data"); 187 187 … … 266 266 average[Nave].measureOffset = -1; 267 267 average[Nave].missingOffset = -1; 268 average[Nave].extendOffset = -1; 268 average[Nave].refColorBlue = NAN; 269 average[Nave].refColorRef = NAN; 269 270 270 271 average[Nave].objID = measure[i].objID; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvorepairImageVsMeasure.c
r33657 r37403 128 128 gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow); 129 129 130 measure = FtableToMeasure (&cpmFtable, &Nmeasure, &catformat);130 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat); 131 131 myAssert(measure, "failed to convert ftable to measure data"); 132 132 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvorepairImagesVsMeasures.c
r29938 r37403 134 134 gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow); 135 135 136 measure = FtableToMeasure (&cpmFtable, &Nmeasure, &catformat);136 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat); 137 137 myAssert(measure, "failed to convert ftable to measure data"); 138 138 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvoverify_args.c
r36680 r37403 56 56 } 57 57 58 /*** dvoverify -parallel (dvoverify_client, actually) ignores this argument 59 dvoverify should save a subset table of just the IDs, and dvoverify_client should load it 60 dvoverify -cpt should have CHECK_IMAGE_ID = F as default ***/ 58 /*** dvoverify -cpt should have CHECK_IMAGE_ID = F as default ***/ 61 59 62 60 CHECK_IMAGE_ID = TRUE; … … 150 148 } 151 149 150 CHECK_IMAGE_ID = TRUE; 151 if ((N = get_argument (*argc, argv, "-skip-image-ids"))) { 152 CHECK_IMAGE_ID = FALSE; 153 remove_argument (N, argc, argv); 154 } 155 152 156 // restrict to a portion of the sky 153 157 UserPatch.Rmin = 0; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvoverify_catalogs.c
r36680 r37403 47 47 } 48 48 49 sprintf (filename, "%s/%s.cpx", mycatdir, skylist[0].regions[i][0].name); 50 if (!VerifyTableFile (filename)) { 51 Nbad ++; 52 skipIndexCheck = TRUE; 53 AddFailures (filename); 54 } 55 56 sprintf (filename, "%s/%s.cpy", mycatdir, skylist[0].regions[i][0].name); 57 if (!VerifyTableFile (filename)) { 58 Nbad ++; 59 skipIndexCheck = TRUE; 60 AddFailures (filename); 61 } 62 49 63 sprintf (filename, "%s/%s.cpt", mycatdir, skylist[0].regions[i][0].name); 50 64 if (!skipIndexCheck) { … … 80 94 exit (1); 81 95 } 96 97 // save the IDlist as a smaller FITS table 98 if (CHECK_IMAGE_ID) { 99 char filename[DVO_MAX_PATH]; 100 snprintf (filename, DVO_MAX_PATH, "%s/ImageIDs.fits", CATDIR); 101 if (!SaveImageIDsSmall (filename)) { 102 fprintf (stderr, "ERROR: failure to save image IDs\n"); 103 exit (2); 104 } 105 } 82 106 83 107 int i; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvoverify_client.c
r34405 r37403 22 22 // XXX in client mode, we should be reading a reduced table generated by the calling 23 23 // serial program 24 LoadImageIDs (CATDIR); 24 char filename[DVO_MAX_PATH]; 25 snprintf (filename, DVO_MAX_PATH, "%s/ImageIDs.fits", CATDIR); 26 if (!LoadImageIDsSmall (filename)) { 27 fprintf (stderr, "ERROR: failure to load image IDs\n"); 28 exit (2); 29 } 25 30 } 26 31 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvoverify_utils.c
r36680 r37403 178 178 catalog.catformat = DVO_FORMAT_UNDEF; // read-only,do not set the catformat 179 179 catalog.catmode = DVO_MODE_UNDEF; // read-only, do not set the catmode 180 catalog.catflags = LOAD_AVES | LOAD_MEAS ;180 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_LENSING | LOAD_LENSOBJ; 181 181 catalog.Nsecfilt = 0; 182 182 … … 214 214 int NmeasureTotal = 0; 215 215 int measureOffsetOK = TRUE; 216 int NlensingTotal = 0; 217 int lensingOffsetOK = TRUE; 218 int NlensobjTotal = 0; 219 int lensobjOffsetOK = TRUE; 216 220 for (i = 0; i < catalog.Naverage; i++) { 217 221 NmeasureTotal += catalog.average[i].Nmeasure; … … 227 231 fprintf (stderr, "measureOffset + Nmeasure > catalog.Nmeasure : %d %d %d\n", i, catalog.average[i].Nmeasure, (int) catalog.Nmeasure); 228 232 } 233 234 // sum of Nlensing for each object < Nlensing for catalog 235 NlensingTotal += catalog.average[i].Nlensing; 236 if (VERBOSE && !(NlensingTotal <= catalog.Nlensing)) { 237 fprintf (stderr, "NlensingTotal > catalog.Nlensing: %d %d %d\n", i, catalog.average[i].Nlensing, (int) catalog.Nlensing); 238 } 239 // lensingOffset needs to be in range for each object 240 lensingOffsetOK &= (catalog.average[i].lensingOffset < catalog.Nlensing); 241 if (VERBOSE && !(catalog.average[i].lensingOffset < catalog.Nlensing)) { 242 fprintf (stderr, "lensingOffset >= catalog.Nlensing: %d %d %d\n", i, catalog.average[i].lensingOffset, (int) catalog.Nlensing); 243 } 244 lensingOffsetOK &= (catalog.average[i].lensingOffset + catalog.average[i].Nlensing <= catalog.Nlensing); 245 if (VERBOSE && !(catalog.average[i].lensingOffset + catalog.average[i].Nlensing <= catalog.Nlensing)) { 246 fprintf (stderr, "lensingOffset + Nlensing > catalog.Nlensing : %d %d %d\n", i, catalog.average[i].Nlensing, (int) catalog.Nlensing); 247 } 248 249 NlensobjTotal += catalog.average[i].Nlensobj; 250 if (VERBOSE && !(NlensobjTotal <= catalog.Nlensobj)) { 251 fprintf (stderr, "NlensobjTotal > catalog.Nlensobj: %d %d %d\n", i, catalog.average[i].Nlensobj, (int) catalog.Nlensobj); 252 } 253 lensobjOffsetOK &= (catalog.average[i].lensobjOffset < catalog.Nlensobj); 254 if (VERBOSE && !(catalog.average[i].lensobjOffset < catalog.Nlensobj)) { 255 fprintf (stderr, "lensobjOffset >= catalog.Nlensobj: %d %d %d\n", i, catalog.average[i].lensobjOffset, (int) catalog.Nlensobj); 256 } 257 lensobjOffsetOK &= (catalog.average[i].lensobjOffset + catalog.average[i].Nlensobj <= catalog.Nlensobj); 258 if (VERBOSE && !(catalog.average[i].lensobjOffset + catalog.average[i].Nlensobj <= catalog.Nlensobj)) { 259 fprintf (stderr, "lensobjOffset + Nlensobj > catalog.Nlensobj : %d %d %d\n", i, catalog.average[i].Nlensobj, (int) catalog.Nlensobj); 260 } 229 261 } 230 262 … … 236 268 if (NmeasureTotal != catalog.Nmeasure) { 237 269 fprintf (stderr, "ERROR: catalog %s has an invalid Nmeasure\n", catalog.filename); 270 status = FALSE; 271 } 272 273 if (!lensingOffsetOK) { 274 fprintf (stderr, "ERROR: catalog %s has an invalid lensingOffset\n", catalog.filename); 275 status = FALSE; 276 } 277 278 if (NlensingTotal != catalog.Nlensing) { 279 fprintf (stderr, "ERROR: catalog %s has an invalid Nlensing\n", catalog.filename); 280 status = FALSE; 281 } 282 283 if (!lensobjOffsetOK) { 284 fprintf (stderr, "ERROR: catalog %s has an invalid lensobjOffset\n", catalog.filename); 285 status = FALSE; 286 } 287 288 if (NlensobjTotal != catalog.Nlensobj) { 289 fprintf (stderr, "ERROR: catalog %s has an invalid Nlensobj\n", catalog.filename); 238 290 status = FALSE; 239 291 } … … 247 299 } 248 300 249 int objIDsOK = TRUE; 250 int catIDsOK = TRUE; 251 int averefOK = TRUE; 252 253 for (i = 0; i < catalog.Naverage; i++) { 254 m = catalog.average[i].measureOffset; 255 for (j = 0; j < catalog.average[i].Nmeasure; j++) { 256 objIDsOK &= (catalog.average[i].objID == catalog.measure[m+j].objID); 257 catIDsOK &= (catalog.average[i].catID == catalog.measure[m+j].catID); 258 averefOK &= (catalog.measure[m+j].averef == i); 259 } 260 } 301 // check measure <-> average links 302 { 303 int objIDsOK = TRUE; 304 int catIDsOK = TRUE; 305 int averefOK = TRUE; 306 307 for (i = 0; i < catalog.Naverage; i++) { 308 m = catalog.average[i].measureOffset; 309 for (j = 0; j < catalog.average[i].Nmeasure; j++) { 310 objIDsOK &= (catalog.average[i].objID == catalog.measure[m+j].objID); 311 catIDsOK &= (catalog.average[i].catID == catalog.measure[m+j].catID); 312 averefOK &= (catalog.measure[m+j].averef == i); 313 } 314 } 261 315 262 if (!objIDsOK) { 263 fprintf (stderr, "ERROR: catalog %s has invalid obj IDs\n", catalog.filename); 264 status = FALSE; 265 } 266 if (!catIDsOK) { 267 fprintf (stderr, "ERROR: catalog %s has invalid cat IDs\n", catalog.filename); 268 status = FALSE; 269 } 270 if (!averefOK) { 271 fprintf (stderr, "ERROR: catalog %s has invalid averef values\n", catalog.filename); 272 status = FALSE; 316 if (!objIDsOK) { 317 fprintf (stderr, "ERROR: catalog %s has invalid obj IDs\n", catalog.filename); 318 status = FALSE; 319 } 320 if (!catIDsOK) { 321 fprintf (stderr, "ERROR: catalog %s has invalid cat IDs\n", catalog.filename); 322 status = FALSE; 323 } 324 if (!averefOK) { 325 fprintf (stderr, "ERROR: catalog %s has invalid averef values\n", catalog.filename); 326 status = FALSE; 327 } 328 } 329 330 // check lensing <-> average links 331 { 332 int objIDsOK = TRUE; 333 int catIDsOK = TRUE; 334 int averefOK = TRUE; 335 336 for (i = 0; i < catalog.Naverage; i++) { 337 m = catalog.average[i].lensingOffset; 338 for (j = 0; j < catalog.average[i].Nlensing; j++) { 339 objIDsOK &= (catalog.average[i].objID == catalog.lensing[m+j].objID); 340 catIDsOK &= (catalog.average[i].catID == catalog.lensing[m+j].catID); 341 averefOK &= (catalog.lensing[m+j].averef == i); 342 } 343 } 344 345 if (!objIDsOK) { 346 fprintf (stderr, "ERROR: catalog %s has invalid lensing obj IDs\n", catalog.filename); 347 status = FALSE; 348 } 349 if (!catIDsOK) { 350 fprintf (stderr, "ERROR: catalog %s has invalid lensing cat IDs\n", catalog.filename); 351 status = FALSE; 352 } 353 if (!averefOK) { 354 fprintf (stderr, "ERROR: catalog %s has invalid lensing averef values\n", catalog.filename); 355 status = FALSE; 356 } 357 } 358 359 // check lensobj <-> average links 360 { 361 int objIDsOK = TRUE; 362 int catIDsOK = TRUE; 363 364 for (i = 0; i < catalog.Naverage; i++) { 365 m = catalog.average[i].lensobjOffset; 366 for (j = 0; j < catalog.average[i].Nlensobj; j++) { 367 objIDsOK &= (catalog.average[i].objID == catalog.lensobj[m+j].objID); 368 catIDsOK &= (catalog.average[i].catID == catalog.lensobj[m+j].catID); 369 } 370 } 371 372 if (!objIDsOK) { 373 fprintf (stderr, "ERROR: catalog %s has invalid lensobj obj IDs\n", catalog.filename); 374 status = FALSE; 375 } 376 if (!catIDsOK) { 377 fprintf (stderr, "ERROR: catalog %s has invalid lensobj cat IDs\n", catalog.filename); 378 status = FALSE; 379 } 273 380 } 274 381 … … 321 428 } 322 429 } 430 431 for (i = 0; i < catalog[0].Naverage; i++) { 432 m = catalog[0].average[i].lensingOffset; 433 for (j = 0; j < catalog[0].average[i].Nlensing; j++) { 434 id = catalog[0].lensing[m+j].imageID; 435 if (id == 0) continue; // detections from ref photcodes can (should) have unset image IDs 436 if (id > maxID) { 437 Nfail ++; 438 continue; 439 // is this sufficient to catch IDs set without an image table? 440 } 441 if (IDlist) { 442 if (IDlist[id] < 0) { 443 Nfail ++; 444 continue; 445 } 446 } else { 447 if (id > 0) { 448 Nfail ++; 449 continue; 450 } 451 } 452 } 453 } 454 323 455 return Nfail; 324 456 } … … 382 514 return TRUE; 383 515 } 516 517 # define GET_COLUMN(OUT,NAME,TYPE) \ 518 OUT = gfits_get_bintable_column_data (&theader, &ftable, NAME, type, &Nrow, &Ncol); \ 519 myAssert (!strcmp(type, #TYPE), "wrong column type"); 520 521 // STATUS is value expected for success 522 # define CHECK_STATUS(STATUS,MSG,...) \ 523 if (!(STATUS)) { \ 524 fprintf (stderr, MSG, __VA_ARGS__); \ 525 return FALSE; \ 526 } 527 528 // write out the IDmap data for clients to read 529 int SaveImageIDsSmall(char *filename) { 530 531 Header header; 532 Header theader; 533 Matrix matrix; 534 FTable ftable; 535 536 gfits_init_header (&header); 537 header.extend = TRUE; 538 gfits_create_header (&header); 539 gfits_create_matrix (&header, &matrix); 540 541 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_IDS"); 542 543 gfits_define_bintable_column (&theader, "J", "IMAGE_IDS", "image IDs", NULL, 1.0, FT_BZERO_INT32); 544 545 // generate the output array that carries the data 546 gfits_create_table (&theader, &ftable); 547 548 // add the columns to the output array 549 gfits_set_bintable_column (&theader, &ftable, "IMAGE_IDS", IDlist, maxID + 1); 550 551 FILE *f = fopen (filename, "w"); 552 if (!f) { 553 fprintf (stderr, "ERROR: cannot open image ID file for output %s\n", filename); 554 return FALSE; 555 } 556 557 int status; 558 status = gfits_fwrite_header (f, &header); 559 CHECK_STATUS (status, "ERROR: cannot write header for image ID file %s\n", filename); 560 561 status = gfits_fwrite_matrix (f, &matrix); 562 CHECK_STATUS (status, "ERROR: cannot write matrix for image ID file %s\n", filename); 563 564 status = gfits_fwrite_Theader (f, &theader); 565 CHECK_STATUS (status, "ERROR: cannot write table header for image ID file %s\n", filename); 566 567 status = gfits_fwrite_table (f, &ftable); 568 CHECK_STATUS (status, "ERROR: cannot write table data for image ID file %s\n", filename); 569 570 gfits_free_header (&header); 571 gfits_free_matrix (&matrix); 572 gfits_free_header (&theader); 573 gfits_free_table (&ftable); 574 575 int fd = fileno (f); 576 577 status = fflush (f); 578 CHECK_STATUS (!status, "ERROR: cannot flush file image ID file %s\n", filename); 579 580 status = fsync (fd); 581 CHECK_STATUS (!status, "ERROR: cannot flush file image ID file %s\n", filename); 582 583 status = fclose (f); 584 CHECK_STATUS (!status, "ERROR: problem closing image ID file file %s\n", filename); 585 586 return TRUE; 587 } 588 589 int LoadImageIDsSmall (char *filename) { 590 591 int Ncol; 592 off_t Nrow; 593 Header header; 594 Header theader; 595 Matrix matrix; 596 FTable ftable; 597 598 FILE *f = fopen (filename, "r"); 599 if (!f) { 600 fprintf (stderr, "ERROR: cannot open image subset file %s\n", filename); 601 return FALSE; 602 } 603 604 /* load in PHU segment (ignore) */ 605 if (!gfits_fread_header (f, &header)) { 606 if (VERBOSE) fprintf (stderr, "can't read image subset header\n"); 607 fclose (f); 608 return FALSE; 609 } 610 if (!gfits_fread_matrix (f, &matrix, &header)) { 611 if (VERBOSE) fprintf (stderr, "can't read image subset matrix\n"); 612 gfits_free_header (&header); 613 fclose (f); 614 return FALSE; 615 } 616 617 ftable.header = &theader; 618 619 // load data for this header 620 if (!gfits_load_header (f, &theader)) { 621 fclose (f); 622 return FALSE; 623 } 624 625 // read the fits table bytes 626 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) { 627 fclose (f); 628 return FALSE; 629 } 630 fclose (f); 631 632 char type[16]; 633 634 GET_COLUMN (IDlist, "IMAGE_IDS", int); 635 maxID = Nrow - 1; 636 fprintf (stderr, "loaded data for %lld images\n", (long long) Nrow); 637 638 return TRUE; 639 } 640 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/merge_catalogs_new.c
r28855 r37403 8 8 // input entries always define new objects 9 9 10 #define notyet 111 12 10 int merge_catalogs_new (SkyRegion *region, Catalog *output, Catalog *input, int *secfiltMap) { 13 11 14 12 off_t i, j, offset; 15 off_t NAVERAGE, NMEASURE, N average, Nmeasure, NsecfiltIn, NsecfiltOut, Nm;13 off_t NAVERAGE, NMEASURE, NLENSING, Naverage, Nmeasure, Nlensing, NsecfiltIn, NsecfiltOut, Nm; 16 14 17 15 Naverage = output[0].Naverage; … … 63 61 } 64 62 output[0].average[Naverage].Nmeasure = Nm; 63 64 Nm = 0; 65 for (j = 0; j < input[0].average[i].Nlensing; j++) { 66 offset = input[0].average[i].lensingOffset + j; 67 68 output[0].lensing[Nlensing] = input[0].lensing[offset]; 69 output[0].lensing[Nlensing].averef = Naverage; 70 71 Nlensing ++; 72 Nm ++; 73 if (Nlensing == NLENSING) { 74 NLENSING += 1000; 75 REALLOCATE (output[0].lensing, Lensing, NLENSING); 76 } 77 } 78 output[0].average[Naverage].Nlensing = Nm; 79 65 80 Naverage ++; 66 81 if (Naverage == NAVERAGE) { … … 72 87 REALLOCATE (output[0].average, Average, MAX (Naverage, 1)); 73 88 REALLOCATE (output[0].measure, Measure, MAX (Nmeasure, 1)); 89 REALLOCATE (output[0].lensing, Lensing, MAX (Nlensing, 1)); 74 90 REALLOCATE (output[0].secfilt, SecFilt, NsecfiltOut*MAX (Naverage, 1)); 75 91 output[0].Naverage = Naverage; 76 output[0].N measure = Nmeasure;92 output[0].Nlensing = Nlensing; 77 93 output[0].Nsecf_mem = Naverage * NsecfiltOut; 78 94 … … 84 100 85 101 if (VERBOSE) { 86 fprintf (stderr, OFF_T_FMT": using "OFF_T_FMT" stars ("OFF_T_FMT" measures ) for catalog\n",102 fprintf (stderr, OFF_T_FMT": using "OFF_T_FMT" stars ("OFF_T_FMT" measures, "OFF_T_FMT" lensing) for catalog\n", 87 103 i, 88 104 output[0].Naverage, 89 output[0].Nmeasure); 105 output[0].Nmeasure, 106 output[0].Nlensing); 90 107 } 91 108 return (TRUE); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/merge_catalogs_old.c
r36680 r37403 1 1 # include "dvomerge.h" 2 2 # define PSPS_ID TRUE 3 4 # define MARKTIME(MSG,...) { \5 float dtime; \6 gettimeofday (&stop, (void *) NULL); \7 dtime = DTIME (stop, start); \8 fprintf (stderr, MSG, __VA_ARGS__); \9 gettimeofday (&start, (void *) NULL); \10 }11 3 12 4 # define IN_REGION(R,D) ( \ … … 19 11 20 12 off_t i, j, k, Nin, offset, J, Jmin, status, Nstars; 21 double RADIUS2, Rmin , Rin, Din;13 double RADIUS2, Rmin; 22 14 double *X1, *Y1, *X2, *Y2; 23 15 double dX, dY, dR; 24 off_t *N1, *N2, *next_meas;25 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch ;16 off_t *N1, *N2, *next_meas, *next_lens; 17 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch, Nlens, NLENS; 26 18 int NsecfiltIn; 27 19 int NsecfiltOut; … … 29 21 Coords tcoords; 30 22 31 // struct timeval start, stop; 32 // gettimeofday (&start, (void *) NULL); 23 // INITTIME; 33 24 34 25 NsecfiltOut = output[0].Nsecfilt; … … 40 31 ALLOCATE (Y1, double, input[0].Naverage); 41 32 ALLOCATE (N1, off_t, input[0].Naverage); 42 ALLOCATE (input[0].found, off_t, input[0].Naverage); 33 if (!input[0].found_t) { 34 ALLOCATE (input[0].found_t, off_t, input[0].Naverage); 35 } else { 36 REALLOCATE (input[0].found_t, off_t, input[0].Naverage); 37 } 43 38 44 39 /** allocate local arrays (catalog) **/ … … 47 42 ALLOCATE (Y2, double, NAVE); 48 43 ALLOCATE (N2, off_t, NAVE); 49 ALLOCATE (output[0].found, off_t, NAVE); 44 if (!output[0].found_t) { 45 ALLOCATE (output[0].found_t, off_t, NAVE); 46 } else { 47 REALLOCATE (output[0].found_t, off_t, NAVE); 48 } 50 49 /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */ 51 50 … … 53 52 Nmatch = 0; 54 53 NMEAS = Nmeas = output[0].Nmeasure; 54 NLENS = Nlens = output[0].Nlensing; 55 55 56 56 // current max obj ID for this catalog … … 87 87 N1[Nstars] = i; 88 88 Nstars ++; 89 input[0].found [i] = -1;89 input[0].found_t[i] = -1; 90 90 } 91 91 if (Nstars < 1) { 92 92 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", output[0].filename); 93 free (output[0].found);94 free (input[0].found);95 93 free (X1); 96 94 free (Y1); … … 106 104 for (i = 0; i < Nave; i++) { 107 105 RD_to_XY (&X2[i], &Y2[i], output[0].average[i].R, output[0].average[i].D, &tcoords); 108 output[0].found [i] = -1;106 output[0].found_t[i] = -1; 109 107 N2[i] = i; 110 108 } … … 115 113 exit (3); 116 114 } 117 118 115 119 116 /* set up pointers for linked list of measure */ … … 122 119 // is sorted while processed 123 120 next_meas = init_measure_links (output[0].average, Nave, output[0].measure, Nmeas); 121 next_lens = init_lensing_links (output[0].average, Nave, output[0].lensing, Nlens); 124 122 } else { 125 123 next_meas = build_measure_links (output[0].average, Nave, output[0].measure, Nmeas); 124 next_lens = build_lensing_links (output[0].average, Nave, output[0].lensing, Nlens); 126 125 } 127 126 … … 185 184 REALLOCATE (output[0].measure, Measure, NMEAS); 186 185 } 186 if (Nlens + input[0].average[N].Nmeasure >= NLENS) { 187 NLENS = Nlens + input[0].average[N].Nmeasure + 1000; 188 REALLOCATE (next_lens, off_t, NLENS); 189 REALLOCATE (output[0].lensing, Lensing, NLENS); 190 } 187 191 188 192 // 4) average properties from the input and the output db need to be properly merged. … … 194 198 if (REPLACE_BY_PHOTCODE) { 195 199 // index to first measure for this object 200 // XXX this does not support lensing measurements 196 201 int Mout = output[0].average[n].measureOffset; 197 202 if (replace_match(&output[0].average[n], &output[0].measure[Mout], &input[0].average[N], &input[0].measure[offset])) { 198 input[0].found [N] = Mout;203 input[0].found_t[N] = Mout; 199 204 continue; 200 205 } … … 206 211 output[0].measure[Nmeas] = input[0].measure[offset]; 207 212 208 Rin = input[0].average[N].R - input[0].measure[offset].dR / 3600.0; 209 Din = input[0].average[N].D - input[0].measure[offset].dD / 3600.0; 210 211 /** dR,dD now represent arcsec **/ 212 output[0].measure[Nmeas].dR = 3600.0*(output[0].average[n].R - Rin); // XXX update these based on choice of astromety 213 output[0].measure[Nmeas].dD = 3600.0*(output[0].average[n].D - Din); // XXX update these based on choice of astromety 213 // old code: find R,D using average_in[0], the get offset relative to average_out[0]. no longer 214 // needed since we carry around R,D 215 // Rin = input[0].average[N].R - input[0].measure[offset].dR / 3600.0; 216 // Din = input[0].average[N].D - input[0].measure[offset].dD / 3600.0; 217 // output[0].measure[Nmeas].dR = 3600.0*(output[0].average[n].R - Rin); 218 // output[0].measure[Nmeas].dD = 3600.0*(output[0].average[n].D - Din); 219 214 220 output[0].measure[Nmeas].dbFlags = 0; // XXX why reset these? 215 221 output[0].measure[Nmeas].averef = n; … … 221 227 // fprintf (stderr, "Nave : "OFF_T_FMT", Nmeas : "OFF_T_FMT", dR: %f, dD: %f, catID: %d\n", n, Nmeas, output[0].measure[Nmeas].dR, output[0].measure[Nmeas].dD, output[0].measure[i].catID); 222 228 223 // rationalize dR 224 if (output[0].measure[Nmeas].dR > +180.0*3600.0) { 229 float dRoff = dvoOffsetR(&output[0].measure[Nmeas], &output[0].average[n]); 230 231 // rationalize R 232 if (dRoff > +180.0*3600.0) { 225 233 // average on high end of boundary, move star up 226 Rin+= 360.0;227 output[0].measure[Nmeas].dR = 3600.0*(output[0].average[n].R - Rin);228 } 229 if ( output[0].measure[Nmeas].dR< -180.0*3600.0) {234 output[0].measure[Nmeas].R += 360.0; 235 dRoff -= 360.0*3600.0; 236 } 237 if (dRoff < -180.0*3600.0) { 230 238 // average on low end of boundary, move star down 231 Rin -= 360.0; 232 output[0].measure[Nmeas].dR = 3600.0*(output[0].average[n].R - Rin); 233 } 234 if (fabs(output[0].measure[Nmeas].dR) > 10*RADIUS) { 235 // ok take declination into account and check again. 236 double cosD = cos(RAD_DEG*Din); 237 if (fabs(output[0].measure[Nmeas].dR*cosD) > 10*RADIUS) { 238 239 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 240 output[0].average[n].R, output[0].average[n].D, Rin, Din, 241 X1[i], X2[Jmin], Y1[i], Y2[Jmin]); 242 243 // XXX abort on this? -- this is a bad failure... 239 output[0].measure[Nmeas].R -= 360.0; 240 dRoff += 360.0*3600.0; 241 } 242 if (fabs(dRoff) > 10*RADIUS) { 243 // take declination into account and check again. 244 double cosD = cos(RAD_DEG*output[0].average[n].D); 245 if (fabs(dRoff*cosD) > 10*RADIUS) { 246 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 247 output[0].average[n].R, output[0].average[n].D, 248 output[0].measure[Nmeas].R, output[0].measure[Nmeas].D, 249 X1[i], X2[Jmin], Y1[i], Y2[Jmin]); 250 // XXX abort on this? -- this is a bad failure... 244 251 } 245 252 } 246 input[0].found [N] = Nmeas;253 input[0].found_t[N] = Nmeas; 247 254 output[0].average[n].Nmeasure ++; 248 255 Nmeas ++; 256 } 257 258 // if lensing measurements exist, add them too 259 if (output[0].lensing) { 260 for (Nin = 0; Nin < input[0].average[N].Nlensing; Nin++) { 261 /* add to end of lensing list */ 262 add_lens_link (&output[0].average[n], next_lens, Nlens, NLENS); 263 264 // set the new lensing 265 off_t lensoff = input[0].average[N].lensingOffset + Nin; 266 output[0].lensing[Nlens] = input[0].lensing[lensoff]; 267 268 output[0].lensing[Nlens].averef = n; 269 output[0].lensing[Nlens].objID = output[0].average[n].objID; 270 output[0].lensing[Nlens].catID = output[0].catID; 271 output[0].average[n].Nlensing ++; 272 Nlens ++; 273 } 249 274 } 250 275 … … 273 298 /* Nm is updated, but not written out in -update mode (for existing entries) 274 299 Nm is recalculated in build_meas_links if loaded table is not sorted */ 275 output[0].found [n] = Nmeas;300 output[0].found_t[n] = Nmeas; 276 301 i++; 277 302 } … … 289 314 REALLOCATE (output[0].measure, Measure, NMEAS); 290 315 } 316 if (Nlens + input[0].average[N].Nlensing >= NLENS) { 317 NLENS = Nlens + input[0].average[N].Nlensing + 1000; 318 REALLOCATE (next_lens, off_t, NLENS); 319 REALLOCATE (output[0].lensing, Lensing, NLENS); 320 } 291 321 if (Nave >= NAVE) { 292 322 NAVE = Nave + 1000; … … 295 325 } 296 326 297 if (input[0].found [N] >= 0) continue;327 if (input[0].found_t[N] >= 0) continue; 298 328 if (!IN_REGION (input[0].average[N].R, input[0].average[N].D)) continue; 299 329 … … 348 378 349 379 /* we set next[Nmeas] to -1 here, and update correctly below */ 350 input[0].found [N] = Nmeas;380 input[0].found_t[N] = Nmeas; 351 381 next_meas[Nmeas] = -1; 352 382 Nmeas ++; … … 356 386 next_meas[Nmeas - Ngroup + j] = Nmeas - Ngroup + j + 1; 357 387 } 388 389 /** add lensing for this input average object **/ 390 if (output[0].lensing) { 391 output[0].average[Nave].lensingOffset = Nlens; 392 for (Nin = 0; Nin < input[0].average[N].Nlensing; Nin ++) { 393 // supply the lensing values from this detection 394 off_t lensoff = input[0].average[N].lensingOffset + Nin; 395 output[0].lensing[Nlens] = input[0].lensing[lensoff]; 396 397 // the following lensing elements cannot be set until here: 398 output[0].lensing[Nlens].averef = Nave; 399 output[0].lensing[Nlens].objID = output[0].average[Nave].objID; 400 output[0].lensing[Nlens].catID = output[0].catID; 401 402 // as we add lensing, update Nlensing to match 403 output[0].average[Nave].Nlensing ++; 404 405 /* we set next[Nlens] to -1 here, and update correctly below */ 406 next_lens[Nlens] = -1; 407 Nlens ++; 408 } 409 int Ngroup = input[0].average[N].Nlensing; 410 for (j = 0; j < Ngroup - 1; j++) { 411 next_lens[Nlens - Ngroup + j] = Nlens - Ngroup + j + 1; 412 } 413 } 414 358 415 Nave ++; 359 416 } … … 363 420 REALLOCATE (output[0].average, Average, Nave); 364 421 REALLOCATE (output[0].measure, Measure, Nmeas); 422 REALLOCATE (output[0].lensing, Lensing, Nlens); 365 423 366 424 # define NOSORT 0 … … 370 428 output[0].sorted = TRUE; 371 429 output[0].measure = sort_measure (output[0].average, Nave, output[0].measure, Nmeas, next_meas); 430 output[0].lensing = sort_lensing (output[0].average, Nave, output[0].lensing, Nlens, next_lens); 372 431 } 373 432 374 433 /* note stars which have been found in this catalog */ 375 434 for (i = 0; i < input[0].Naverage; i++) { 376 if (input[0].found [i] > -1) {377 input[0].found [i] = -2;435 if (input[0].found_t[i] > -1) { 436 input[0].found_t[i] = -2; 378 437 } else { 379 input[0].found [i] = -3;438 input[0].found_t[i] = -3; 380 439 } 381 440 } … … 385 444 output[0].Naverage = Nave; 386 445 output[0].Nmeasure = Nmeas; 446 output[0].Nlensing = Nlens; 387 447 output[0].Nsecf_mem = Nave*NsecfiltOut; 388 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);448 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nlens: "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas, Nlens, Nmatch); 389 449 390 450 free (next_meas); 391 392 free (output[0].found); 451 free (next_lens); 452 393 453 free (X2); 394 454 free (Y2); 395 455 free (N2); 396 free (input[0].found);397 456 free (X1); 398 457 free (Y1); … … 411 470 images have boundaries which are lines in pixels coords, but curve in RA and DEC 412 471 413 output[0].found [Ncat] but stars[Nstar].found472 output[0].found_t[Ncat] but stars[Nstar].found 414 473 415 474 */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/replace_match.c
r33963 r37403 7 7 unsigned int averef; 8 8 unsigned int catID; 9 double Rin, Din;10 9 11 10 // find the matching photcode in the object's list of measurements … … 18 17 measure_out[Nout] = measure_in[0]; 19 18 20 Rin = average_in[0].R - measure_in[0].dR / 3600.0; 21 Din = average_in[0].D - measure_in[0].dD / 3600.0; 19 // old code: find R,D using average_in[0], the get offset relative to average_out[0]. no longer 20 // needed since we carry around R,D 21 // double Rin = average_in[0].R - measure_in[0].dR / 3600.0; 22 // double Din = average_in[0].D - measure_in[0].dD / 3600.0; 23 // measure_out[Nout].dR = 3600.0*(average_out[0].R - Rin); 24 // measure_out[Nout].dD = 3600.0*(average_out[0].D - Din); 22 25 23 /** dR,dD now represent arcsec **/24 measure_out[Nout].dR = 3600.0*(average_out[0].R - Rin);25 measure_out[Nout].dD = 3600.0*(average_out[0].D - Din);26 26 measure_out[Nout].dbFlags = 0; // XXX why reset these? 27 27 measure_out[Nout].averef = averef; … … 29 29 measure_out[Nout].catID = catID; 30 30 31 float dRoff = dvoOffsetR(&measure_out[Nout], average_out); 32 31 33 // rationalize dR 32 if ( measure_out[Nout].dR> +180.0*3600.0) {34 if (dRoff > +180.0*3600.0) { 33 35 // average on high end of boundary, move star up 34 Rin+= 360.0;35 measure_out[Nout].dR = 3600.0*(average_out[0].R - Rin);36 measure_out[Nout].R += 360.0; 37 dRoff -= 360.0*3600.0; 36 38 } 37 if ( measure_out[Nout].dR< -180.0*3600.0) {39 if (dRoff < -180.0*3600.0) { 38 40 // average on low end of boundary, move star down 39 Rin-= 360.0;40 measure_out[Nout].dR = 3600.0*(average_out[0].R - Rin);41 measure_out[Nout].R -= 360.0; 42 dRoff += 360.0*3600.0; 41 43 } 42 44 43 45 // warn on surprisingly distant detections 44 if (fabs( measure_out[Nout].dR) > 10*RADIUS) {46 if (fabs(dRoff) > 10*RADIUS) { 45 47 // ok take declination into account and check again. 46 double cosD = cos(RAD_DEG*Din); 47 if (fabs(measure_out[Nout].dR*cosD) > 10*RADIUS) { 48 48 double cosD = cos(RAD_DEG*average_out[0].D); 49 if (fabs(dRoff*cosD) > 10*RADIUS) { 49 50 fprintf (stderr, "surprisingly distant detection: %10.6f,%10.6f vs %10.6f,%10.6f\n", 50 average_out[0].R, average_out[0].D, Rin, Din);51 average_out[0].R, average_out[0].D, measure_out[Nout].R, measure_out[Nout].D); 51 52 } 52 53 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvopsps/include/dvopsps.h
r36680 r37403 9 9 10 10 typedef struct { 11 int imageID; 12 unsigned int ippDetectID; 11 uint64_t objID; 13 12 uint64_t detectID; 14 13 uint64_t ippObjID; 15 uint64_t objID; 16 int photcode; 17 unsigned int flags; 18 float zp; 19 float zpErr; 20 float airMass; 21 float expTime; 14 unsigned int ippDetectID; 15 int imageID; 16 int catID; 22 17 double ra; 23 18 double dec; 24 19 float raErr; 25 20 float decErr; 21 float zp; 22 float telluricExt; 23 float airmass; 24 float expTime; 25 26 float Mpsf; 27 float dMpsf; 28 float Mkron; 29 float dMkron; 30 float Map; 31 float dMap; 32 33 unsigned int flags; 26 34 } Detections; 27 35 … … 78 86 79 87 int insert_detections_mysql_commit PROTO((IOBuffer *buffer, MYSQL *mysql)); 80 int insert_detections_mysql_value PROTO((IOBuffer *buffer, Average *average, Measure *measure));88 // int insert_detections_mysql_value PROTO((IOBuffer *buffer, Average *average, Measure *measure)); 81 89 int insert_detections_mysql_init PROTO((IOBuffer *buffer)); 82 90 83 91 int insert_detections_mysql_array PROTO((MYSQL *mysql, Detections *detections, int Ndetections)); 84 92 int insert_detections_mysql_detvalue PROTO((IOBuffer *buffer, Detections *detection)); 93 int assign_detection_values PROTO((Detections *detection, Measure *measure, Average *average)); 85 94 86 95 int init_detections PROTO(()); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvopsps/src/DetectionOps.c
r35578 r37403 1 1 # include "dvopsps.h" 2 # define BZERO_INT16 1.0*0x80003 # define BZERO_INT32 1.0*0x800000004 # define BZERO_INT64 1.0*0x80000000000000005 2 6 3 # define GET_COLUMN(OUT,NAME,TYPE) \ … … 49 46 50 47 // need to create and assign to flat-field correction 51 GET_COLUMN(imageID , "imageID", int); 52 GET_COLUMN(ippDetectID , "ippDetectID", int); 48 GET_COLUMN(objID , "objID", int64_t); 53 49 GET_COLUMN(detectID , "detectID", int64_t); 54 50 GET_COLUMN(ippObjID , "ippObjID", int64_t); 55 GET_COLUMN(objID , "objID", int64_t); 56 GET_COLUMN(photcode , "photcode", int); 57 GET_COLUMN(flags , "flags", int); 58 GET_COLUMN(zp , "zp", float); 59 GET_COLUMN(zpErr , "zpErr", float); 60 GET_COLUMN(airMass , "airMass", float); 61 GET_COLUMN(expTime , "expTime", float); 51 GET_COLUMN(ippDetectID , "ippDetectID", int); 52 GET_COLUMN(imageID , "imageID", int); 53 GET_COLUMN(catID , "catID", int); 62 54 GET_COLUMN(ra , "ra", double); // XXX signed vs unsigned? 63 55 GET_COLUMN(dec , "dec", double); 64 56 GET_COLUMN(raErr , "raErr", float); 65 57 GET_COLUMN(decErr , "decErr", float); 58 GET_COLUMN(zp , "zp", float); 59 GET_COLUMN(telluricExt , "telluricExt", float); 60 GET_COLUMN(airmass , "airmass", float); 61 GET_COLUMN(expTime , "expTime", float); 62 GET_COLUMN(Mpsf , "Mpsf", float); 63 GET_COLUMN(dMpsf , "dMpsf", float); 64 GET_COLUMN(Mkron , "Mkron", float); 65 GET_COLUMN(dMkron , "dMkron", float); 66 GET_COLUMN(Map , "Map", float); 67 GET_COLUMN(dMap , "dMap", float); 68 GET_COLUMN(flags , "flags", int); 66 69 gfits_free_header (&theader); 67 70 gfits_free_table (&ftable); … … 69 72 ALLOCATE (detections, Detections, Nrow); 70 73 for (i = 0; i < Nrow; i++) { 71 detections[i].imageID = imageID[i]; 72 detections[i].ippDetectID = ippDetectID[i]; 74 detections[i].objID = objID[i]; 73 75 detections[i].detectID = detectID[i]; 74 76 detections[i].ippObjID = ippObjID[i]; 75 detections[i].objID = objID[i]; 76 detections[i].photcode = photcode[i]; 77 detections[i].flags = flags[i]; 78 detections[i].zp = zp[i]; 79 detections[i].zpErr = zpErr[i]; 80 detections[i].airMass = airMass[i]; 81 detections[i].expTime = expTime[i]; 77 detections[i].ippDetectID = ippDetectID[i]; 78 detections[i].imageID = imageID[i]; 79 detections[i].catID = catID[i]; 82 80 detections[i].ra = ra[i]; 83 81 detections[i].dec = dec[i]; 84 82 detections[i].raErr = raErr[i]; 85 83 detections[i].decErr = decErr[i]; 84 detections[i].zp = zp[i]; 85 detections[i].telluricExt = telluricExt[i]; 86 detections[i].airmass = airmass[i]; 87 detections[i].expTime = expTime[i]; 88 detections[i].Mpsf = Mpsf[i]; 89 detections[i].dMpsf = dMpsf[i]; 90 detections[i].Mkron = Mkron[i]; 91 detections[i].dMkron = dMkron[i]; 92 detections[i].Map = Map[i]; 93 detections[i].dMap = dMap[i]; 94 detections[i].flags = flags[i]; 86 95 } 87 96 fprintf (stderr, "loaded data for %lld detections\n", (long long) Nrow); 88 97 89 free (imageID ); 90 free (ippDetectID); 98 free (objID ); 91 99 free (detectID ); 92 100 free (ippObjID ); 93 free (objID ); 94 free (photcode ); 95 free (flags ); 96 free (zp ); 97 free (zpErr ); 98 free (airMass ); 99 free (expTime ); 101 free (ippDetectID); 102 free (imageID ); 103 free (catID ); 100 104 free (ra ); 101 105 free (dec ); 102 106 free (raErr ); 103 107 free (decErr ); 108 free (zp ); 109 free (telluricExt); 110 free (airmass ); 111 free (expTime ); 112 free (Mpsf ); 113 free (dMpsf ); 114 free (Mkron ); 115 free (dMkron ); 116 free (Map ); 117 free (dMap ); 118 free (flags ); 104 119 105 120 gfits_free_header (&header); … … 149 164 150 165 // XXX need to get the bzero values right 151 gfits_define_bintable_column (&theader, "J", "imageID", NULL, NULL, 1.0, BZERO_INT32); 152 gfits_define_bintable_column (&theader, "J", "ippDetectID", NULL, NULL, 1.0, BZERO_INT32); 166 gfits_define_bintable_column (&theader, "K", "objID", NULL, NULL, 1.0, 0); 153 167 gfits_define_bintable_column (&theader, "K", "detectID", NULL, NULL, 1.0, 0); 154 168 gfits_define_bintable_column (&theader, "K", "ippObjID", NULL, NULL, 1.0, 0); 155 gfits_define_bintable_column (&theader, "K", "objID", NULL, NULL, 1.0, 0); 156 // gfits_define_bintable_column (&theader, "K", "detectID", NULL, NULL, 1.0, BZERO_INT64); 157 // gfits_define_bintable_column (&theader, "K", "ippObjID", NULL, NULL, 1.0, BZERO_INT64); 158 // gfits_define_bintable_column (&theader, "K", "objID", NULL, NULL, 1.0, BZERO_INT64); 159 gfits_define_bintable_column (&theader, "J", "photcode", NULL, NULL, 1.0, 0.0); 160 gfits_define_bintable_column (&theader, "J", "flags", NULL, NULL, 1.0, BZERO_INT32); 161 gfits_define_bintable_column (&theader, "E", "zp", NULL, NULL, 1.0, 0.0); 162 gfits_define_bintable_column (&theader, "E", "zpErr", NULL, NULL, 1.0, 0.0); 163 gfits_define_bintable_column (&theader, "E", "airMass", NULL, NULL, 1.0, 0.0); 164 gfits_define_bintable_column (&theader, "E", "expTime", NULL, NULL, 1.0, 0.0); 169 gfits_define_bintable_column (&theader, "J", "ippDetectID", NULL, NULL, 1.0, FT_BZERO_INT32); 170 gfits_define_bintable_column (&theader, "J", "imageID", NULL, NULL, 1.0, FT_BZERO_INT32); 171 gfits_define_bintable_column (&theader, "J", "catID", NULL, NULL, 1.0, FT_BZERO_INT32); 165 172 gfits_define_bintable_column (&theader, "D", "ra", NULL, NULL, 1.0, 0.0); 166 173 gfits_define_bintable_column (&theader, "D", "dec", NULL, NULL, 1.0, 0.0); 167 174 gfits_define_bintable_column (&theader, "E", "raErr", NULL, NULL, 1.0, 0.0); 168 175 gfits_define_bintable_column (&theader, "E", "decErr", NULL, NULL, 1.0, 0.0); 176 gfits_define_bintable_column (&theader, "E", "zp", NULL, NULL, 1.0, 0.0); 177 gfits_define_bintable_column (&theader, "E", "telluricExt", NULL, NULL, 1.0, 0.0); 178 gfits_define_bintable_column (&theader, "E", "airmass", NULL, NULL, 1.0, 0.0); 179 gfits_define_bintable_column (&theader, "E", "expTime", NULL, NULL, 1.0, 0.0); 180 gfits_define_bintable_column (&theader, "E", "Mpsf", NULL, NULL, 1.0, 0.0); 181 gfits_define_bintable_column (&theader, "E", "dMpsf", NULL, NULL, 1.0, 0.0); 182 gfits_define_bintable_column (&theader, "E", "Mkron", NULL, NULL, 1.0, 0.0); 183 gfits_define_bintable_column (&theader, "E", "dMkron", NULL, NULL, 1.0, 0.0); 184 gfits_define_bintable_column (&theader, "E", "Map", NULL, NULL, 1.0, 0.0); 185 gfits_define_bintable_column (&theader, "E", "dMap", NULL, NULL, 1.0, 0.0); 186 gfits_define_bintable_column (&theader, "J", "flags", NULL, NULL, 1.0, FT_BZERO_INT32); 169 187 170 188 // generate the output array that carries the data … … 172 190 173 191 // create intermediate storage arrays 174 int32_t *imageID ; ALLOCATE (imageID , int32_t, Ndetections); 175 uint32_t *ippDetectID ; ALLOCATE (ippDetectID , uint32_t, Ndetections); 192 uint64_t *objID ; ALLOCATE (objID , uint64_t, Ndetections); 176 193 uint64_t *detectID ; ALLOCATE (detectID , uint64_t, Ndetections); 177 194 uint64_t *ippObjID ; ALLOCATE (ippObjID , uint64_t, Ndetections); 178 uint64_t *objID ; ALLOCATE (objID , uint64_t, Ndetections); 179 int *photcode ; ALLOCATE (photcode , int, Ndetections); 180 uint32_t *flags ; ALLOCATE (flags , uint32_t, Ndetections); 181 float *zp ; ALLOCATE (zp , float, Ndetections); 182 float *zpErr ; ALLOCATE (zpErr , float, Ndetections); 183 float *airMass ; ALLOCATE (airMass , float, Ndetections); 184 float *expTime ; ALLOCATE (expTime , float, Ndetections); 195 uint32_t *ippDetectID ; ALLOCATE (ippDetectID , uint32_t, Ndetections); 196 int32_t *imageID ; ALLOCATE (imageID , int32_t, Ndetections); 197 int32_t *catID ; ALLOCATE (catID , int32_t, Ndetections); 185 198 double *ra ; ALLOCATE (ra , double, Ndetections); 186 199 double *dec ; ALLOCATE (dec , double, Ndetections); 187 200 float *raErr ; ALLOCATE (raErr , float, Ndetections); 188 201 float *decErr ; ALLOCATE (decErr , float, Ndetections); 202 float *zp ; ALLOCATE (zp , float, Ndetections); 203 float *telluricExt ; ALLOCATE (telluricExt , float, Ndetections); 204 float *airmass ; ALLOCATE (airmass , float, Ndetections); 205 float *expTime ; ALLOCATE (expTime , float, Ndetections); 206 float *Mpsf ; ALLOCATE (Mpsf , float, Ndetections); 207 float *dMpsf ; ALLOCATE (dMpsf , float, Ndetections); 208 float *Mkron ; ALLOCATE (Mkron , float, Ndetections); 209 float *dMkron ; ALLOCATE (dMkron , float, Ndetections); 210 float *Map ; ALLOCATE (Map , float, Ndetections); 211 float *dMap ; ALLOCATE (dMap , float, Ndetections); 212 uint32_t *flags ; ALLOCATE (flags , uint32_t, Ndetections); 189 213 190 214 // assign the storage arrays 191 215 for (i = 0; i < Ndetections; i++) { 192 imageID[i] = detections[i].imageID ; 193 ippDetectID[i] = detections[i].ippDetectID ; 216 objID[i] = detections[i].objID ; 194 217 detectID[i] = detections[i].detectID ; 195 218 ippObjID[i] = detections[i].ippObjID ; 196 objID[i] = detections[i].objID ; 197 photcode[i] = detections[i].photcode ; 198 flags[i] = detections[i].flags ; 199 zp[i] = detections[i].zp ; 200 zpErr[i] = detections[i].zpErr ; 201 airMass[i] = detections[i].airMass ; 202 expTime[i] = detections[i].expTime ; 219 ippDetectID[i] = detections[i].ippDetectID ; 220 imageID[i] = detections[i].imageID ; 221 catID[i] = detections[i].catID ; 203 222 ra[i] = detections[i].ra ; 204 223 dec[i] = detections[i].dec ; 205 224 raErr[i] = detections[i].raErr ; 206 225 decErr[i] = detections[i].decErr ; 226 zp[i] = detections[i].zp ; 227 telluricExt[i] = detections[i].telluricExt ; 228 airmass[i] = detections[i].airmass ; 229 expTime[i] = detections[i].expTime ; 230 Mpsf[i] = detections[i].Mpsf ; 231 dMpsf[i] = detections[i].dMpsf ; 232 Mkron[i] = detections[i].Mkron ; 233 dMkron[i] = detections[i].dMkron ; 234 Map[i] = detections[i].Map ; 235 dMap[i] = detections[i].dMap ; 236 flags[i] = detections[i].flags ; 207 237 } 208 238 209 239 // add the columns to the output array 210 gfits_set_bintable_column (&theader, &ftable, "imageID", imageID , Ndetections); 211 gfits_set_bintable_column (&theader, &ftable, "ippDetectID", ippDetectID , Ndetections); 240 gfits_set_bintable_column (&theader, &ftable, "objID", objID , Ndetections); 212 241 gfits_set_bintable_column (&theader, &ftable, "detectID", detectID , Ndetections); 213 242 gfits_set_bintable_column (&theader, &ftable, "ippObjID", ippObjID , Ndetections); 214 gfits_set_bintable_column (&theader, &ftable, "objID", objID , Ndetections); 215 gfits_set_bintable_column (&theader, &ftable, "photcode", photcode , Ndetections); 216 gfits_set_bintable_column (&theader, &ftable, "flags", flags , Ndetections); 217 gfits_set_bintable_column (&theader, &ftable, "zp", zp , Ndetections); 218 gfits_set_bintable_column (&theader, &ftable, "zpErr", zpErr , Ndetections); 219 gfits_set_bintable_column (&theader, &ftable, "airMass", airMass , Ndetections); 220 gfits_set_bintable_column (&theader, &ftable, "expTime", expTime , Ndetections); 243 gfits_set_bintable_column (&theader, &ftable, "ippDetectID", ippDetectID , Ndetections); 244 gfits_set_bintable_column (&theader, &ftable, "imageID", imageID , Ndetections); 245 gfits_set_bintable_column (&theader, &ftable, "catID", catID , Ndetections); 221 246 gfits_set_bintable_column (&theader, &ftable, "ra", ra , Ndetections); 222 247 gfits_set_bintable_column (&theader, &ftable, "dec", dec , Ndetections); 223 248 gfits_set_bintable_column (&theader, &ftable, "raErr", raErr , Ndetections); 224 249 gfits_set_bintable_column (&theader, &ftable, "decErr", decErr , Ndetections); 225 226 free (imageID ); 227 free (ippDetectID ); 250 gfits_set_bintable_column (&theader, &ftable, "zp", zp , Ndetections); 251 gfits_set_bintable_column (&theader, &ftable, "telluricExt", telluricExt , Ndetections); 252 gfits_set_bintable_column (&theader, &ftable, "airmass", airmass , Ndetections); 253 gfits_set_bintable_column (&theader, &ftable, "expTime", expTime , Ndetections); 254 gfits_set_bintable_column (&theader, &ftable, "Mpsf", Mpsf , Ndetections); 255 gfits_set_bintable_column (&theader, &ftable, "dMpsf", dMpsf , Ndetections); 256 gfits_set_bintable_column (&theader, &ftable, "Mkron", Mkron , Ndetections); 257 gfits_set_bintable_column (&theader, &ftable, "dMkron", dMkron , Ndetections); 258 gfits_set_bintable_column (&theader, &ftable, "Map", Map , Ndetections); 259 gfits_set_bintable_column (&theader, &ftable, "dMap", dMap , Ndetections); 260 gfits_set_bintable_column (&theader, &ftable, "flags", flags , Ndetections); 261 262 free (objID ); 228 263 free (detectID ); 229 264 free (ippObjID ); 230 free (objID ); 231 free (photcode ); 232 free (flags ); 233 free (zp ); 234 free (zpErr ); 235 free (airMass ); 236 free (expTime ); 265 free (ippDetectID ); 266 free (imageID ); 267 free (catID ); 237 268 free (ra ); 238 269 free (dec ); 239 270 free (raErr ); 240 271 free (decErr ); 272 free (zp ); 273 free (telluricExt ); 274 free (airmass ); 275 free (expTime ); 276 free (Mpsf ); 277 free (dMpsf ); 278 free (Mkron ); 279 free (dMkron ); 280 free (Map ); 281 free (dMap ); 282 free (flags ); 241 283 242 284 gfits_fwrite_Theader (f, &theader); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvopsps/src/insert_detections_dvopsps.c
r36680 r37403 2 2 # define USE_MYSQL 1 3 3 // # define SAVE_REMOTE 1 4 5 # define MARKTIME(MSG,...) { \6 float dtime; \7 gettimeofday (&stop, (void *) NULL); \8 dtime = DTIME (stop, start); \9 fprintf (stderr, MSG, __VA_ARGS__); }10 4 11 5 // we have two ways of writing to the mysql database: … … 74 68 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 75 69 76 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, " w")) {70 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "r")) { 77 71 fprintf (stderr, "ERROR: failure reading catalog %s\n", catalog.filename); 78 72 exit (1); … … 101 95 dvo_catalog_unlock (&catalog); 102 96 dvo_catalog_free (&catalog); 97 98 if (!status) { 99 fprintf (stderr, "failure to insert data in mysql\n"); 100 exit (2); 101 } 103 102 } 104 103 … … 245 244 buffer.Nalloc = 0; 246 245 247 struct timeval start, stop;248 249 246 if (Ndetections == 0) return TRUE; 250 247 … … 254 251 int Ninsert = 0; 255 252 256 gettimeofday (&start, (void *) NULL);253 INITTIME; 257 254 for (i = 0; i < Ndetections; i++) { 258 255 … … 289 286 } 290 287 291 # define PRINT_FLOAT(BUFFER,FIELD,FORMAT) \292 if (!isfinite(FIELD)) PrintIOBuffer (BUFFER, "NULL, "); \293 else PrintIOBuffer (BUFFER, FORMAT, FIELD);294 295 int insert_detections_mysql_detvalue (IOBuffer *buffer, Detections *detection) {296 297 PrintIOBuffer (buffer, "(%d, ", detection->imageID); // imageID298 PrintIOBuffer (buffer, "%u, ", detection->ippDetectID); // ippDetectID299 PrintIOBuffer (buffer, "%lu, ", detection->detectID); // detectID300 PrintIOBuffer (buffer, "%lu, ", detection->ippObjID); // ippObjID301 PrintIOBuffer (buffer, "%lu, ", detection->objID); // objID302 PrintIOBuffer (buffer, "%u, ", detection->flags); // flags303 PRINT_FLOAT(buffer, detection->zp, "%.6f, ");304 PRINT_FLOAT(buffer, detection->zpErr, "%.6f, ");305 PRINT_FLOAT(buffer, detection->airMass, "%.6f, ");306 PRINT_FLOAT(buffer, detection->expTime, "%.6f, ");307 PRINT_FLOAT(buffer, detection->ra, "%.8f, ");308 PRINT_FLOAT(buffer, detection->dec, "%.8f, ");309 PRINT_FLOAT(buffer, detection->raErr, "%.6f, ");310 PRINT_FLOAT(buffer, detection->decErr, "%.6f),\n");311 return TRUE;312 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c
r36680 r37403 1 1 # include "dvopsps.h" 2 2 # define DEBUG 0 3 4 # define MARKTIME(MSG,...) { \5 float dtime; \6 gettimeofday (&stop, (void *) NULL); \7 dtime = DTIME (stop, start); \8 fprintf (stderr, MSG, __VA_ARGS__); }9 3 10 4 int Ndetections = 0; … … 12 6 Detections *detections = NULL; 13 7 8 static float ZeroPoint = 25.0; 9 14 10 int init_detections () { 15 11 NDETECTIONS = 1000; … … 21 17 22 18 off_t i, j; 19 20 ZeroPoint = GetZeroPoint(); 23 21 24 22 int missingID = 0; … … 53 51 if (measure->photcode >= PHOTCODE_END) continue; 54 52 55 PhotCode *code = GetPhotcodebyCode(measure->photcode); 56 57 detections[Ndetections].imageID = measure->imageID; // imageID 58 detections[Ndetections].ippDetectID = measure->detID; // ippDetectID 59 detections[Ndetections].detectID = measure->extID; // detectID 60 detections[Ndetections].ippObjID = ((uint64_t)average->catID * 1000000000) + (uint64_t)average->objID; // ippObjID 61 // NOTE: this is better, but the above is the current ippToPsps value 62 // detections[Ndetections]. ((uint64_t)average->catID << 32) + (uint64_t)average->objID; // ippObjID 63 detections[Ndetections].objID = average->extID; // objID 64 detections[Ndetections].photcode = measure->photcode; // photcode 65 detections[Ndetections].flags = measure->dbFlags; // flags 66 detections[Ndetections].zp = code->C * 0.001 + code->K * (measure->airmass - 1) - measure->Mcal; // zp 67 detections[Ndetections].zpErr = measure->dMcal; // zpErr 68 detections[Ndetections].airMass = measure->airmass; 69 detections[Ndetections].expTime = pow(10.0, 0.4 * measure->dt); // expTime 70 detections[Ndetections].ra = average->R - measure->dR / 3600.; // ra 71 detections[Ndetections].dec = average->D - measure->dD / 3600.; // dec 72 detections[Ndetections].raErr = measure->dXccd * 0.01 * fabs(measure->pltscale); // estimate of raErr 73 detections[Ndetections].decErr = measure->dYccd * 0.01 * fabs(measure->pltscale); // estimate of decErr 74 53 assign_detection_values (&detections[Ndetections], measure, average); 75 54 Ndetections ++; 55 76 56 myAssert (Ndetections <= NDETECTIONS, "programming error"); 77 57 } … … 107 87 off_t i, j; 108 88 int missingID = 0; 109 struct timeval start, stop;110 89 111 90 IOBuffer buffer; … … 117 96 off_t found = 0; 118 97 119 gettimeofday (&start, (void *) NULL); 98 ZeroPoint = GetZeroPoint(); 99 100 INITTIME; 120 101 insert_detections_mysql_init (&buffer); 121 102 int Ninsert = 0; … … 150 131 151 132 // XXX check return status 152 if (!insert_detections_mysql_value (&buffer, &average[i], &measure[Nmeas])) { 133 Detections detection; 134 assign_detection_values (&detection, &measure[Nmeas], &average[i]); 135 136 if (!insert_detections_mysql_detvalue (&buffer, &detection)) { 153 137 fprintf (stderr, "failure to insert detections in mysql\n"); 154 138 status = FALSE; … … 201 185 } 202 186 203 // PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (imageID, ippDetectID, detectID, ippObjID, objID, photcode, flags, zp, zpErr, airMass, expTime, ra, dec_, raErr, decErr) VALUES \n"); 204 PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (imageID, ippDetectID, detectID, ippObjID, objID, flags, zp, zpErr, airMass, expTime, ra, dec_, raErr, decErr) VALUES \n"); 205 206 return TRUE; 207 } 208 209 # define PRINT_FLOAT(BUFFER,FIELD,FORMAT) \ 210 if (isinf(FIELD) || isnan(FIELD)) PrintIOBuffer (BUFFER, "NULL, "); \ 211 else PrintIOBuffer (BUFFER, FORMAT, FIELD); 212 213 int insert_detections_mysql_value (IOBuffer *buffer, Average *average, Measure *measure) { 214 215 PhotCode *code = GetPhotcodebyCode(measure->photcode); 216 PrintIOBuffer (buffer, "(%d, ", measure->imageID); // imageID 217 PrintIOBuffer (buffer, "%u, ", measure->detID); // ippDetectID 218 PrintIOBuffer (buffer, "%lu, ", measure->extID); // detectID 219 PrintIOBuffer (buffer, "%lu, ", ((uint64_t)average->catID * 1000000000) + (uint64_t)average->objID); // ippObjID 220 // NOTE: the following is better, but the above is the current ippToPsps value 221 // ((uint64_t)average->catID << 32) + (uint64_t)average->objID, // ippObjID 222 PrintIOBuffer (buffer, "%lu, ", average->extID); // objID 223 // XXX PrintIOBuffer (buffer, "%d, ", measure->photcode); // photcode 224 PrintIOBuffer (buffer, "%u, ", measure->dbFlags); // flags 225 226 float zp = code->C * 0.001 + code->K * (measure->airmass - 1) - measure->Mcal; 227 float exptime = pow(10.0, 0.4 * measure->dt); 228 double ra = average->R - measure->dR / 3600.0; 229 double dec = average->D - measure->dD / 3600.0; 230 double dR = measure->dXccd * 0.01 * fabs(measure->pltscale); 231 double dD = measure->dYccd * 0.01 * fabs(measure->pltscale); 232 233 PRINT_FLOAT(buffer, zp, "%.6f, "); 234 PRINT_FLOAT(buffer, measure->dMcal, "%.6f, "); 235 PRINT_FLOAT(buffer, measure->airmass, "%.6f, "); 236 PRINT_FLOAT(buffer, exptime, "%.6f, "); 237 PRINT_FLOAT(buffer, ra, "%.8f, "); 238 PRINT_FLOAT(buffer, dec, "%.8f, "); 239 PRINT_FLOAT(buffer, dR, "%.6f, "); 240 PRINT_FLOAT(buffer, dD, "%.6f),\n"); 241 242 return TRUE; 243 } 244 187 PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (objID, detectID, ippObjID, ippDetectID, imageID, catID, "); 188 PrintIOBuffer (buffer, "ra, dec_, raErr, decErr, zp, telluricExt, airmass, expTime, "); 189 PrintIOBuffer (buffer, "Mpsf, dMpsf, Mkron, dMkron, Map, dMap, flags) VALUES \n"); 190 191 return TRUE; 192 } 193 245 194 int insert_detections_mysql_commit (IOBuffer *buffer, MYSQL *mysql) { 246 195 … … 261 210 // XXX check return status 262 211 if (mysql) { 263 if (DEBUG) fprintf (stderr, "%s\n", buffer->buffer);264 212 int mysqlStatus = mysql_query(mysql, buffer->buffer); 265 213 if (mysqlStatus) { … … 267 215 fprintf (stderr, "%s\n", mysql_error(mysql)); 268 216 fprintf (stderr, "Nbuffer: %d\n", buffer->Nbuffer); 217 if (DEBUG) fprintf (stderr, "%s\n", buffer->buffer); 269 218 status = FALSE; 270 219 } … … 277 226 return status; 278 227 } 228 229 # define PRINT_FLOAT(BUFFER,FIELD,FORMAT) \ 230 if (!isfinite(FIELD)) PrintIOBuffer (BUFFER, "NULL, "); \ 231 else PrintIOBuffer (BUFFER, FORMAT, FIELD); 232 233 int insert_detections_mysql_detvalue (IOBuffer *buffer, Detections *detection) { 234 235 if (detection->detectID == 164458937060000101) { 236 fprintf (stderr, "isfinite: %d\n", isfinite(detection->dMpsf)); 237 fprintf (stderr, "isnan: %d\n", isnan(detection->dMpsf)); 238 fprintf (stderr, "isinf: %d\n", isinf(detection->dMpsf)); 239 } 240 241 PrintIOBuffer (buffer, "(%lu, ", detection->objID); // objID 242 PrintIOBuffer (buffer, "%lu, ", detection->detectID); // detectID 243 PrintIOBuffer (buffer, "%lu, ", detection->ippObjID); // ippObjID 244 PrintIOBuffer (buffer, "%u, ", detection->ippDetectID); // ippDetectID 245 PrintIOBuffer (buffer, "%d, ", detection->imageID); // imageID 246 PrintIOBuffer (buffer, "%d, ", detection->catID); // DVO Catalog ID 247 248 PRINT_FLOAT(buffer, detection->ra, "%.8f, "); 249 PRINT_FLOAT(buffer, detection->dec, "%.8f, "); 250 PRINT_FLOAT(buffer, detection->raErr, "%.6f, "); 251 PRINT_FLOAT(buffer, detection->decErr, "%.6f, "); 252 PRINT_FLOAT(buffer, detection->zp, "%.6f, "); 253 PRINT_FLOAT(buffer, detection->telluricExt, "%.6f, "); 254 PRINT_FLOAT(buffer, detection->airmass, "%.6f, "); 255 PRINT_FLOAT(buffer, detection->expTime, "%.6f, "); 256 257 PRINT_FLOAT(buffer, detection->Mpsf, "%.6f, "); 258 PRINT_FLOAT(buffer, detection->dMpsf, "%.6f, "); 259 PRINT_FLOAT(buffer, detection->Mkron, "%.6f, "); 260 PRINT_FLOAT(buffer, detection->dMkron, "%.6f, "); 261 PRINT_FLOAT(buffer, detection->Map, "%.6f, "); 262 PRINT_FLOAT(buffer, detection->dMap, "%.6f, "); 263 264 PrintIOBuffer (buffer, "%u),\n", detection->flags); // flags 265 return TRUE; 266 } 267 268 float getMagFromValueOrFlux (float flux, float mag, float zp) { 269 270 // first, if mag is finite, use mag: 271 if (isfinite(mag)) { 272 return (zp + mag - ZeroPoint); 273 } 274 275 if (isfinite(flux) && (flux > 0.0)) { 276 // fprintf (stderr, "funny flux: %f with mag %f\n", flux, mag); 277 return (zp - 2.5*log10(flux)); 278 } 279 280 if (isfinite(flux) && (flux <= 0.0)) { 281 return (NAN); 282 } 283 return (NAN); 284 } 285 286 float getdMagFromValueOrFlux (float flux, float dflux, float dmag) { 287 288 // first, if mag is finite, use mag: 289 if (isfinite(dmag)) { 290 return (dmag); 291 } 292 293 if (isfinite(flux) && isfinite(dflux)) { 294 return (dflux / fabs(flux)); 295 } 296 return (NAN); 297 } 298 299 int assign_detection_values (Detections *detection, Measure *measure, Average *average) { 300 301 PhotCode *code = GetPhotcodebyCode(measure->photcode); 302 303 uint64_t ippObjID = ((uint64_t)average->catID << 32) + (uint64_t)average->objID; // ippObjID 304 305 float nominalZP = code->C * 0.001 + code->K * (measure->airmass - 1); 306 float zp = nominalZP - measure->Mcal; 307 float telluricExt = - measure->Mcal; 308 float expTime = pow(10.0, 0.4 * measure->dt); 309 float airmass = measure->airmass; 310 311 detection->objID = average->extID; // objID 312 detection->detectID = measure->extID; // detectID 313 detection->ippObjID = ippObjID; // ippObjID 314 detection->ippDetectID = measure->detID; // ippDetectID 315 detection->imageID = measure->imageID; // imageID 316 detection->catID = measure->catID; // catID 317 318 detection->ra = measure->R; // ra 319 detection->dec = measure->D; // dec 320 detection->raErr = measure->dXccd * 0.01 * fabs(measure->pltscale); // estimate of raErr 321 detection->decErr = measure->dYccd * 0.01 * fabs(measure->pltscale); // estimate of decErr 322 323 detection->zp = zp; 324 detection->telluricExt = telluricExt; 325 detection->airmass = airmass; 326 detection->expTime = expTime; 327 328 // XXX clean this up with dvo_photcode_ops calls: 329 // if (isfinite(measure->FluxPSF) && (measure->FluxPSF < 0.0)) 330 detection->Mpsf = getMagFromValueOrFlux (measure->FluxPSF, measure->M, zp); 331 detection->Mkron = getMagFromValueOrFlux (measure->FluxKron, measure->Mkron, zp); 332 detection->Map = getMagFromValueOrFlux (measure->FluxAp, measure->Map, zp); 333 334 detection->dMpsf = getdMagFromValueOrFlux (measure->FluxPSF, measure->dFluxPSF, measure->dM); 335 detection->dMkron = getdMagFromValueOrFlux (measure->FluxKron, measure->dFluxKron, measure->dMkron); 336 detection->dMap = getdMagFromValueOrFlux (measure->FluxAp, measure->dFluxAp, measure->dMap); 337 338 detection->flags = measure->dbFlags; // flags 339 340 return TRUE; 341 } 342 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvopsps/src/insert_objects_dvopsps.c
r35098 r37403 56 56 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 57 57 58 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, " w")) {58 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "r")) { 59 59 fprintf (stderr, "ERROR: failure reading catalog %s\n", catalog.filename); 60 60 exit (1); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvopsps/src/insert_objects_dvopsps_catalog.c
r35450 r37403 2 2 # define DEBUG 0 3 3 4 # define MARKTIME(MSG,...) { \5 float dtime; \6 gettimeofday (&stop, (void *) NULL); \7 dtime = DTIME (stop, start); \8 fprintf (stderr, MSG, __VA_ARGS__); }9 10 4 int insert_objects_dvopsps_catalog (Catalog *catalog, char *basename, MYSQL *mysql) { 11 5 12 6 off_t i; 13 7 int missingID = 0; 14 struct timeval start, stop;15 8 16 9 IOBuffer ave_buffer, sec_buffer; … … 31 24 insert_objects_mysql_create_tables (cleanname, mysql); 32 25 33 gettimeofday (&start, (void *) NULL);26 INITTIME; 34 27 insert_objects_mysql_init (&ave_buffer, &sec_buffer, cleanname); 35 28 int Ninsert = 0; … … 95 88 bzero (buffer.buffer, buffer.Nalloc); 96 89 90 // Only send the necessary fields (eg, do not sent parallax and pm) 97 91 PrintIOBuffer (&buffer, "CREATE TABLE %s_cpt (" 98 "RA DOUBLE, " 99 "DEC_ DOUBLE, " 100 "RA_ERR FLOAT, " 101 "DEC_ERR FLOAT, " 102 "U_RA FLOAT, " 103 "U_DEC FLOAT, " 104 "V_RA_ERR FLOAT, " 105 "V_DEC_ERR FLOAT, " 106 "PAR FLOAT, " 107 "PAR_ERR FLOAT, " 108 "CHISQ_POS FLOAT, " 109 "CHISQ_PM FLOAT, " 110 "CHISQ_PAP FLOAT, " 111 "MEAN_EPOCH INT, " 112 "TIME_RANGE INT, " 113 "PSF_QF FLOAT, " 114 "PSF_QF_PERF FLOAT, " 115 "STARGAL_SEP FLOAT, " 116 "NUMBER_POS SMALLINT, " 117 "NMEASURE SMALLINT, " 118 "NMISSING SMALLINT, " 119 "NEXTEND SMALLINT, " 120 "OFF_MEASURE INT, " 121 "OFF_MISSING INT, " 122 "OFF_EXTEND INT, " 123 "FLAGS INT, " 124 "PHOTFLAGS_U INT, " 125 "PHOTFLAGS_L INT, " 126 "OBJ_ID INT, " 127 "CAT_ID INT, " 128 "EXT_ID BIGINT" 92 "EXT_ID BIGINT, " 93 "OBJ_ID INT, " 94 "CAT_ID INT, " 95 "TESS_ID TINYINT, " 96 "PROJECTION_ID SMALLINT, " 97 "SKYCELL_ID TINYINT, " 98 "RA_STK DOUBLE, " 99 "DEC_STK DOUBLE, " 100 "RA_STK_ERR FLOAT, " 101 "DEC_STK_ERR FLOAT, " 102 "RA_MEAN DOUBLE, " 103 "DEC_MEAN DOUBLE, " 104 "RA_ERR FLOAT, " 105 "DEC_ERR FLOAT, " 106 "CHISQ_POS FLOAT, " 107 "CHISQ_PM FLOAT, " 108 "CHISQ_PAR FLOAT, " 109 "FLAGS INT " 129 110 ")\n", basename); 111 112 // skipping these cpt fields: 113 // "U_RA FLOAT, " 114 // "U_DEC FLOAT, " 115 // "V_RA_ERR FLOAT, " 116 // "V_DEC_ERR FLOAT, " 117 // "PAR FLOAT, " 118 // "PAR_ERR FLOAT, " 119 // "OFF_MEASURE INT, " 120 // "OFF_MISSING INT, " 121 // "OFF_EXTEND INT, " 122 // "PSF_QF FLOAT, " 123 // "PSF_QF_PERF FLOAT, " 124 // "STARGAL_SEP FLOAT, " 125 // "NUMBER_POS SMALLINT, " 126 // "NMEASURE SMALLINT, " 127 // "NMISSING SMALLINT, " 128 // "NEXTEND SMALLINT, " 129 // "PHOTFLAGS_U INT, " 130 // "PHOTFLAGS_L INT, " 131 132 130 133 131 134 if (DEBUG) fprintf (stderr, "%s\n", buffer.buffer); … … 152 155 153 156 PrintIOBuffer (&buffer, "CREATE TABLE %s_cps (" 154 "MAG FLOAT, "155 "MAG_ AP FLOAT, "156 "MAG_ KRON FLOAT, "157 "MAG_ KRON_ERR FLOAT, "158 "MAG_ ERRFLOAT, "159 " MAG_CHI FLOAT, "160 " STACK_PSF_MAGFLOAT, "161 " STACK_PSF_MAG_ERRFLOAT, "162 " STACK_KRON_MAG FLOAT, "163 " STACK_KRON_MAG_ERR FLOAT, "164 " FLAGS INT, "165 " NCODE SMALLINT, "166 " NUSED SMALLINT, "167 " MAG_20 SMALLINT, "168 " MAG_80 SMALLINT, "169 " UBERCAL_DIST SMALLINT, "170 " MAG_STDEV SMALLINT, "171 " STACK_DETECT_ID BIGINT"157 "MAG FLOAT, " 158 "MAG_ERR FLOAT, " 159 "MAG_STDEV FLOAT, " 160 "MAG_MIN FLOAT, " 161 "MAG_MAX FLOAT, " 162 "NUSED SMALLINT, " 163 "MAG_KRON FLOAT, " 164 "MAG_KRON_ERR FLOAT, " 165 "MAG_KRON_STDEV FLOAT, " 166 "NUSED_KRON SMALLINT, " 167 "MAG_AP FLOAT, " 168 "MAG_AP_ERR FLOAT, " 169 "MAG_AP_STDEV FLOAT, " 170 "NUSED_AP SMALLINT, " 171 "NCODE SMALLINT, " 172 "NSTACK_DET SMALLINT, " 173 "PSF_QF_PERF_MAX FLOAT, " 174 "FLAGS INT " 172 175 ")\n", basename); 173 174 // "FLUX_PSF FLOAT, "175 // "FLUX_PSF_ERR FLOAT, "176 // "FLUX_KRON FLOAT, "177 // "FLUX_KRON_ERR FLOAT, "178 176 179 177 if (DEBUG) fprintf (stderr, "%s\n", buffer.buffer); … … 198 196 199 197 PrintIOBuffer (ave_buffer, "INSERT INTO %s_cpt (" 200 "RA, " 201 "DEC_, " 202 "RA_ERR, " 203 "DEC_ERR, " 204 "U_RA, " 205 "U_DEC, " 206 "V_RA_ERR, " 207 "V_DEC_ERR, " 208 "PAR, " 209 "PAR_ERR, " 210 "CHISQ_POS, " 211 "CHISQ_PM, " 212 "CHISQ_PAP, " 213 "MEAN_EPOCH, " 214 "TIME_RANGE, " 215 "PSF_QF, " 216 "PSF_QF_PERF, " 217 "STARGAL_SEP, " 218 "NUMBER_POS, " 219 "NMEASURE, " 220 "NMISSING, " 221 "NEXTEND, " 222 "OFF_MEASURE, " 223 "OFF_MISSING, " 224 "OFF_EXTEND, " 225 "FLAGS, " 226 "PHOTFLAGS_U, " 227 "PHOTFLAGS_L, " 228 "OBJ_ID, " 229 "CAT_ID, " 230 "EXT_ID" 198 "EXT_ID, " 199 "OBJ_ID, " 200 "CAT_ID, " 201 "TESS_ID, " 202 "PROJECTION_ID, " 203 "SKYCELL_ID, " 204 "RA_STK, " 205 "DEC_STK, " 206 "RA_STK_ERR, " 207 "DEC_STK_ERR, " 208 "RA_MEAN, " 209 "DEC_MEAN, " 210 "RA_ERR, " 211 "DEC_ERR, " 212 "CHISQ_POS, " 213 "CHISQ_PM, " 214 "CHISQ_PAR, " 215 "FLAGS " 231 216 ") VALUES \n", basename); 232 217 … … 237 222 PrintIOBuffer (sec_buffer, "INSERT INTO %s_cps (" 238 223 "MAG, " 239 "MAG_AP, " 224 "MAG_ERR, " 225 "MAG_STDEV, " 226 "MAG_MIN, " 227 "MAG_MAX, " 228 "NUSED, " 229 240 230 "MAG_KRON, " 241 231 "MAG_KRON_ERR, " 242 "MAG_ERR, " 243 "MAG_CHI, " 244 "STACK_PSF_MAG, " 245 "STACK_PSF_MAG_ERR, " 246 "STACK_KRON_MAG, " 247 "STACK_KRON_MAG_ERR, " 248 "FLAGS, " 232 "MAG_KRON_STDEV, " 233 "NUSED_KRON, " 234 235 "MAG_AP, " 236 "MAG_AP_ERR, " 237 "MAG_AP_STDEV, " 238 "NUSED_AP, " 239 249 240 "NCODE, " 250 "NUSED, " 251 "MAG_20, " 252 "MAG_80, " 253 "UBERCAL_DIST, " 254 "MAG_STDEV, " 255 "STACK_DETECT_ID " 241 "NSTACK_DET, " 242 "PSF_QF_PERF_MAX, " 243 "FLAGS " 256 244 ") VALUES \n", basename); 257 245 return TRUE; … … 268 256 // XXX this bit could/should be autocoded... 269 257 PrintIOBuffer (ave_buffer, " ("); 258 PrintIOBuffer (ave_buffer, "%lu, ", average->extID); 259 PrintIOBuffer (ave_buffer, "%u, ", average->objID); 260 PrintIOBuffer (ave_buffer, "%u, ", average->catID); 261 262 PrintIOBuffer (ave_buffer, "%hhd, ", average->tessID); 263 PrintIOBuffer (ave_buffer, "%hd, ", average->projectionID); 264 PrintIOBuffer (ave_buffer, "%hhd, ", average->skycellID); 265 266 PRINT_FLOAT(ave_buffer, average->Rstk, "%.8f, "); // 0.036 mas precision 267 PRINT_FLOAT(ave_buffer, average->Dstk, "%.8f, "); // 0.036 mas precision 268 PRINT_FLOAT(ave_buffer, average->dRstk, "%.5f, "); // 0.010 mas precision 269 PRINT_FLOAT(ave_buffer, average->dDstk, "%.5f, "); // 0.010 mas precision 270 270 271 PRINT_FLOAT(ave_buffer, average->R, "%.8f, "); // 0.036 mas precision 271 272 PRINT_FLOAT(ave_buffer, average->D, "%.8f, "); // 0.036 mas precision 272 273 PRINT_FLOAT(ave_buffer, average->dR, "%.5f, "); // 0.010 mas precision 273 274 PRINT_FLOAT(ave_buffer, average->dD, "%.5f, "); // 0.010 mas precision 274 PRINT_FLOAT(ave_buffer, average->uR, "%.5f, "); // 0.010 mas/yr precision 275 PRINT_FLOAT(ave_buffer, average->uD, "%.5f, "); 276 PRINT_FLOAT(ave_buffer, average->duR, "%.5f, "); 277 PRINT_FLOAT(ave_buffer, average->duD, "%.5f, "); 278 PRINT_FLOAT(ave_buffer, average->P, "%.5f, "); 279 PRINT_FLOAT(ave_buffer, average->dP, "%.5f, "); 275 280 276 PRINT_FLOAT(ave_buffer, average->ChiSqAve, "%.4f, "); 281 277 PRINT_FLOAT(ave_buffer, average->ChiSqPM, "%.4f, "); 282 278 PRINT_FLOAT(ave_buffer, average->ChiSqPar, "%.4f, "); 283 PrintIOBuffer (ave_buffer, "%d, ", average->Tmean); 284 PrintIOBuffer (ave_buffer, "%d, ", average->Trange); 285 PRINT_FLOAT(ave_buffer, average->psfQF, "%.3f, "); 286 PRINT_FLOAT(ave_buffer, average->psfQFperf, "%.3f, "); 287 PRINT_FLOAT(ave_buffer, average->stargal, "%.3f, "); 288 PrintIOBuffer (ave_buffer, "%hu, ", average->Npos); 289 PrintIOBuffer (ave_buffer, "%hu, ", average->Nmeasure); 290 PrintIOBuffer (ave_buffer, "%hu, ", average->Nmissing); 291 PrintIOBuffer (ave_buffer, "%hu, ", average->Nextend); 292 PrintIOBuffer (ave_buffer, "%d, ", average->measureOffset); 293 PrintIOBuffer (ave_buffer, "%d, ", average->missingOffset); 294 PrintIOBuffer (ave_buffer, "%d, ", average->extendOffset); 295 PrintIOBuffer (ave_buffer, "%u, ", average->flags); 296 PrintIOBuffer (ave_buffer, "%u, ", average->photFlagsUpper); 297 PrintIOBuffer (ave_buffer, "%u, ", average->photFlagsLower); 298 PrintIOBuffer (ave_buffer, "%u, ", average->objID); 299 PrintIOBuffer (ave_buffer, "%u, ", average->catID); 300 PrintIOBuffer (ave_buffer, "%lu", average->extID); 279 280 PrintIOBuffer (ave_buffer, "%u ", average->flags); 281 301 282 PrintIOBuffer (ave_buffer, "),\n"); 302 283 284 // XXX what rules for keeping or NAN-ing various mags? 303 285 for (i = 0; i < Nsecfilt; i++) { 304 286 float meanPSFMag = -999.0; 305 287 float meanPSFMagErr = -999.0; 288 float meanPSFMagStd = -999.0; 289 float meanPSFMagMin = -999.0; 290 float meanPSFMagMax = -999.0; 306 291 if (isfinite(secfilt->dM) && isfinite(secfilt->M)) { 307 meanPSFMag = secfilt->M;292 meanPSFMag = secfilt->M; 308 293 meanPSFMagErr = secfilt->dM; 294 meanPSFMagStd = secfilt->Mstdev; 295 meanPSFMagMin = secfilt->Mmin; 296 meanPSFMagMax = secfilt->Mmax; 309 297 } 310 298 311 299 float meanKronMag = -999.0; 312 300 float meanKronMagErr = -999.0; 301 float meanKronMagStd = -999.0; 313 302 if (isfinite(secfilt->dMkron) && isfinite(secfilt->Mkron) && (secfilt->dMkron < 0.333)) { 314 meanKronMag = secfilt->Mkron;303 meanKronMag = secfilt->Mkron; 315 304 meanKronMagErr = secfilt->dMkron; 305 meanKronMagStd = secfilt->sMkron; 316 306 } 317 307 318 308 float meanApMag = -999.0; 319 if (isfinite(secfilt->Map)) { 320 meanApMag = secfilt->Map; 321 } 322 323 float stackPSFMag = -999.0; 324 float stackPSFMagErr = -999.0; 325 if (isfinite(secfilt->dFluxPSF) && isfinite(secfilt->FluxPSF) && (secfilt->dFluxPSF > 0.0)) { 326 float SN = secfilt->FluxPSF / secfilt->dFluxPSF; 327 if (SN > 3.0) { 328 stackPSFMag = -2.5 * log10(secfilt->FluxPSF) + 8.9; 329 stackPSFMagErr = secfilt->dFluxPSF / secfilt->FluxPSF; 330 } 331 } 332 333 float stackKronMag = -999.0; 334 float stackKronMagErr = -999.0; 335 if (isfinite(secfilt->dFluxKron) && isfinite(secfilt->FluxKron) && (secfilt->dFluxKron > 0.0)) { 336 float SN = secfilt->FluxKron / secfilt->dFluxKron; 337 if (SN > 3.0) { 338 stackKronMag = -2.5 * log10(secfilt->FluxKron) + 8.9; 339 stackKronMagErr = secfilt->dFluxKron / secfilt->FluxKron; 340 } 309 float meanApMagErr = -999.0; 310 float meanApMagStd = -999.0; 311 if (isfinite(secfilt->dMap) && isfinite(secfilt->Map)) { 312 meanApMag = secfilt->Map; 313 meanApMagErr = secfilt->dMap; 314 meanApMagStd = secfilt->sMap; 341 315 } 342 316 343 317 PrintIOBuffer (sec_buffer, " ("); 344 318 PRINT_FLOAT(sec_buffer, meanPSFMag, "%.6f, "); // umag precision 345 PRINT_FLOAT(sec_buffer, meanApMag, "%.6f, "); // umag precision 319 PRINT_FLOAT(sec_buffer, meanPSFMagErr, "%.6f, "); // umag precision 320 PRINT_FLOAT(sec_buffer, meanPSFMagStd, "%.6f, "); // umag precision 321 PRINT_FLOAT(sec_buffer, meanPSFMagMin, "%.6f, "); // umag precision 322 PRINT_FLOAT(sec_buffer, meanPSFMagMax, "%.6f, "); // umag precision 323 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->Nused); 324 346 325 PRINT_FLOAT(sec_buffer, meanKronMag, "%.6f, "); // umag precision 347 326 PRINT_FLOAT(sec_buffer, meanKronMagErr, "%.6f, "); // umag precision 348 PRINT_FLOAT(sec_buffer, meanPSFMagErr, "%.6f, "); // umag precision 349 PRINT_FLOAT(sec_buffer, secfilt->Xm, "%.6f, "); 350 PRINT_FLOAT(sec_buffer, stackPSFMag, "%.6f, "); // umag precision 351 PRINT_FLOAT(sec_buffer, stackPSFMagErr, "%.6f, "); // umag precision 352 PRINT_FLOAT(sec_buffer, stackKronMag, "%.6f, "); // umag precision 353 PRINT_FLOAT(sec_buffer, stackKronMagErr, "%.6f, "); // 0.36 umag precision 354 PrintIOBuffer (sec_buffer, "%u, ", secfilt->flags); 355 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->Ncode); 356 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->Nused); 357 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->M_20); 358 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->M_80); 359 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->ubercalDist); 360 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->Mstdev); 361 PrintIOBuffer (sec_buffer, "%lu ", secfilt->stackDetectID); 327 PRINT_FLOAT(sec_buffer, meanKronMagStd, "%.6f, "); // umag precision 328 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->NusedKron); 329 330 PRINT_FLOAT(sec_buffer, meanApMag, "%.6f, "); // umag precision 331 PRINT_FLOAT(sec_buffer, meanApMagErr, "%.6f, "); // umag precision 332 PRINT_FLOAT(sec_buffer, meanApMagStd, "%.6f, "); // umag precision 333 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->NusedAp); 334 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->Ncode); 335 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->NstackDet); 336 337 PRINT_FLOAT(sec_buffer, secfilt->psfQfPerfMax, "%.6f,"); 338 PrintIOBuffer (sec_buffer, "%u ", secfilt->flags); 362 339 PrintIOBuffer (sec_buffer, "),\n"); 363 340 secfilt ++; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvopsps/src/insert_skytable.c
r35098 r37403 2 2 # define DEBUG 1 3 3 # define USE_MYSQL 1 4 5 # define MARKTIME(MSG,...) { \6 float dtime; \7 gettimeofday (&stop, (void *) NULL); \8 dtime = DTIME (stop, start); \9 fprintf (stderr, MSG, __VA_ARGS__); }10 4 11 5 // determine the relevant catalogs, launch parallel clients if desired … … 13 7 14 8 off_t i; 15 struct timeval start, stop;16 9 SkyTable *sky = NULL; 17 10 … … 34 27 # endif 35 28 36 gettimeofday (&start, (void *) NULL); 29 INITTIME; 30 37 31 insert_skytable_mysql_init (&buffer); 38 32 int Ninsert = 0; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvosplit/src/dvosplit.c
r33963 r37403 16 16 ConfigInit (&argc, argv); 17 17 args (argc, argv); 18 19 /* 20 fprintf (stderr, 21 "this program has the ability to split dvo catalogs one file (cpt, cpm, etc) at a time. 22 however, new updates to the cpm format requires the average RA,DEC coords to load the 23 measures. update the code to handle that first"); 24 exit (2); 25 */ 18 26 19 27 CATDIR = strcreate (argv[1]); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvosplit/src/split_averages.c
r33656 r37403 1 1 # include "dvosplit.h" 2 # define NROWS 100000 /* ~10MB per block for measures */2 # define NROWS 1000000 /* ~10MB per block for measures */ 3 3 # define DNOUT 1000 4 4 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvosplit/src/split_measures.c
r33656 r37403 1 1 # include "dvosplit.h" 2 # define NROWS 100000 /* ~10MB per row for measures */2 # define NROWS 1000000 /* ~10MB per row for measures */ 3 3 # define DNOUT 1000 4 4 … … 19 19 20 20 // split out the measure entries: 21 incatalog[0].catflags = LOAD_MEAS; 21 incatalog[0].catflags = LOAD_MEAS | LOAD_AVES | LOAD_SECF; 22 22 23 // if ((incatalog[0].catformat == DVO_FORMAT_ELIXIR) || (incatalog[0].catformat == DVO_FORMAT_LONEOS)) { 23 24 // // for these two formats, we need the average and secfilt values around until we do the measures... -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/gastro2/src/gstars2.c
r36680 r37403 125 125 /* read from FITS table or from text table */ 126 126 /* Is NAXIS == 0 a better test?? */ 127 gfits_scan_alt (&Target[0].header, "NAXIS", "% t", 1, &naxis);127 gfits_scan_alt (&Target[0].header, "NAXIS", "%d", 1, &naxis); 128 128 if ((naxis == 0) && !TEXTMODE) { 129 129 Nskip = gfits_data_size (&Target[0].header); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/getstar
- Property svn:mergeinfo set to
-
branches/eam_branches/ps2-tc3-20130727/Ohana/src/getstar/src/GetFileMode.c
r36680 r37403 8 8 int simple, extend, haveNaxis, haveCTYPE; 9 9 10 // NOTE target of %t must be int length 10 11 gfits_scan_alt (header, "SIMPLE", "%t", 1, &simple); 11 12 haveNaxis = gfits_scan (header, "NAXIS", "%d", 1, &Naxis); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/getstar/src/ReadImageFiles.c
r34088 r37403 138 138 !strcmp (tmpword, "PS1_V1") || 139 139 !strcmp (tmpword, "PS1_V2") || 140 !strcmp (tmpword, "PS1_V3")) { 140 !strcmp (tmpword, "PS1_V3") || 141 !strcmp (tmpword, "PS1_V4") || 142 !strcmp (tmpword, "PS1_V5")) { 141 143 142 144 exttype[Nimage] = strcreate (tmpword); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/getstar/src/getstar.c
r31669 r37403 14 14 set_db (&db); 15 15 16 sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);16 sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, FALSE, SKY_DEPTH, VERBOSE); 17 17 if (!sky) exit (1); 18 18 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/getstar/src/select_by_region.c
r35066 r37403 73 73 for (m = 0; m < catalog[0].average[i].Nmeasure; m++) { 74 74 if (catalog[0].measure[offset + m].photcode == code) { 75 mag = PhotRel (&catalog[0].measure[offset + m], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt] );75 mag = PhotRel (&catalog[0].measure[offset + m], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt], MAG_CLASS_PSF); 76 76 break; 77 77 } … … 126 126 for (m = 0; m < catalog[0].average[i].Nmeasure; m++) { 127 127 if (catalog[0].measure[offset + m].photcode == code) { 128 mag = PhotRel (&catalog[0].measure[offset + m], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt] );128 mag = PhotRel (&catalog[0].measure[offset + m], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt], MAG_CLASS_PSF); 129 129 break; 130 130 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/getstar/src/write_getstar_ps1_dev_0.c
r21508 r37403 61 61 for (m = 0; m < average[i].Nmeasure; m++) { 62 62 if (measure[offset + m].photcode == code_c0) { 63 output[i].mag = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt] );63 output[i].mag = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt], MAG_CLASS_PSF); 64 64 break; 65 65 } … … 75 75 for (m = 0; m < average[i].Nmeasure; m++) { 76 76 if (measure[offset + m].photcode == code_c1) { 77 output[i].c1 = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt] );77 output[i].c1 = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt], MAG_CLASS_PSF); 78 78 break; 79 79 } … … 89 89 for (m = 0; m < average[i].Nmeasure; m++) { 90 90 if (measure[offset + m].photcode == code_c2) { 91 output[i].c2 = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt] );91 output[i].c2 = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt], MAG_CLASS_PSF); 92 92 break; 93 93 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/getstar/src/write_getstar_ps1_dev_1.c
r21508 r37403 64 64 for (m = 0; m < average[i].Nmeasure; m++) { 65 65 if (measure[offset + m].photcode == code_c0) { 66 output[i].mag = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt] );66 output[i].mag = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt], MAG_CLASS_PSF); 67 67 break; 68 68 } … … 78 78 for (m = 0; m < average[i].Nmeasure; m++) { 79 79 if (measure[offset + m].photcode == code_c1) { 80 output[i].c1 = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt] );80 output[i].c1 = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt], MAG_CLASS_PSF); 81 81 break; 82 82 } … … 92 92 for (m = 0; m < average[i].Nmeasure; m++) { 93 93 if (measure[offset + m].photcode == code_c2) { 94 output[i].c2 = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt] );94 output[i].c2 = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt], MAG_CLASS_PSF); 95 95 break; 96 96 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/getstar/src/write_getstar_ps1_dev_2.c
r21508 r37403 70 70 for (m = 0; m < average[i].Nmeasure; m++) { 71 71 if (measure[offset + m].photcode == code_c0) { 72 output[i].mag = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt] );72 output[i].mag = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt], MAG_CLASS_PSF); 73 73 break; 74 74 } … … 84 84 for (m = 0; m < average[i].Nmeasure; m++) { 85 85 if (measure[offset + m].photcode == code_c1) { 86 output[i].c1 = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt] );86 output[i].c1 = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt], MAG_CLASS_PSF); 87 87 break; 88 88 } … … 98 98 for (m = 0; m < average[i].Nmeasure; m++) { 99 99 if (measure[offset + m].photcode == code_c2) { 100 output[i].c2 = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt] );100 output[i].c2 = PhotRel (&measure[offset + m], &average[i], &secfilt[i*Nsecfilt], MAG_CLASS_PSF); 101 101 break; 102 102 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/kapa2/src/CheckPipe.c
r29938 r37403 1 1 # include "Ximage.h" 2 # include <errno.h> 2 3 # define STRCONST(A) ((int)(0x1000000*A[0] + 0x10000*A[1] + 0x100*A[2] + 0x1*A[3])) 3 4 … … 41 42 word[4] = 0; 42 43 switch (status) { 43 case -1: /* no input from pipe: continue */ 44 return (TRUE); 44 case -1: 45 if (errno == EAGAIN) { 46 /* no input from pipe: continue */ 47 return (TRUE); 48 } 49 perror ("exiting due to problem with socket connection in CheckPipe"); 50 return (FALSE); 45 51 break; 46 52 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/kapa2/src/DrawObjects.c
r35416 r37403 608 608 } 609 609 } 610 if (object[0].ptype == 12) { /* filled triangle (down) */ 611 XPoint points[4]; 612 for (i = 0; i < object[0].Npts; i++) { 613 if (!(finite(x[i]) && finite(y[i]))) continue; 614 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 615 sy = x[i]*myi + y[i]*myj + by + YCENTER; 616 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 617 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) { 618 if (scaleColor) { 619 if (!finite(z[i])) continue; 620 int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1))); 621 XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel); 622 } 623 D = scaleSize ? dz*z[i] : ds; 624 points[0].x = sx - D; points[0].y = sy - 0.58*D; 625 points[1].x = sx + D; points[1].y = sy - 0.58*D; 626 points[2].x = sx; points[2].y = sy + 1.15*D; 627 points[3].x = sx - D; points[3].y = sy - 0.58*D; 628 XFillPolygon (graphic->display, graphic->window, graphic->gc, points, 4, Convex, CoordModeOrigin); 629 } 630 } 631 } 610 632 if (object[0].ptype == 100) { /* connect a pair of points */ 611 633 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/kapa2/src/EventLoop.c
r21153 r37403 1 1 # include "Ximage.h" 2 # define DEBUG 0 2 3 3 4 /* list events being selected below, all other masks are ignored */ … … 6 7 int LastEvent (Display *display, int type, XEvent *event) { 7 8 8 int found ;9 int found, Nfound; 9 10 10 11 found = FALSE; 12 Nfound = 0; 11 13 while (XCheckTypedEvent (display, type, event)) { 14 // If the link is slow, then I should wait a little while for some config events to 15 // build up (typically, the window is being dragged around, so we get a whole series of 16 // config events. the flush / sync time is slow on a slow link, so we should try to wait 17 // for the config events to stop, but on a timescale deteremined by the flush/sync time 18 // if (type == ConfigureNotify) fprintf (stderr, "config (%d)\n", Nfound); 19 Nfound ++; 12 20 found = TRUE; 21 } 22 if (DEBUG && found) { 23 if (type == ConfigureNotify) fprintf (stderr, "config (%d)\n", Nfound); 24 if (type == CirculateNotify) fprintf (stderr, "circul (%d)\n", Nfound); 25 if (type == Expose) fprintf (stderr, "expose (%d)\n", Nfound); 26 } 27 28 // if I have a ConfigureNotify event, I should purge all Expose events as well: 29 if (found && (type == ConfigureNotify)) { 30 XEvent discard; 31 while (XCheckTypedEvent (display, Expose, &discard)); 13 32 } 14 33 return (found); … … 38 57 39 58 if (XEventsQueued (display, QueuedAfterFlush) < 1) { 40 /* fprintf (stderr, "."); */41 59 usleep (50000); 42 60 continue; 43 61 } 44 62 63 // If I have a config event, I want to also purge all expose events 64 45 65 /* grab the last entry for these events */ 46 if (LastEvent (display, ConfigureNotify, &event)) Reconfig (&event);47 if (LastEvent (display, CirculateNotify, &event)) Reconfig (&event);48 if (LastEvent (display, Expose, &event)) Refresh ();66 if (LastEvent (display, ConfigureNotify, &event)) { Reconfig (&event); continue; } 67 if (LastEvent (display, CirculateNotify, &event)) { Reconfig (&event); continue; } 68 if (LastEvent (display, Expose, &event)) { Refresh (); continue; } 49 69 if (LastEvent (display, MappingNotify, &event)) XRefreshKeyboardMapping ((XMappingEvent *) &event); 50 70 if (LastEvent (display, MotionNotify, &event)) UpdatePointer (graphic, (XMotionEvent *) &event); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/kapa2/src/FlushDisplay.c
r21153 r37403 30 30 31 31 if (flush) { 32 XFlush (graphic->display); 32 // I changed XFlush to XSync to avoid lag 33 // of the display (build up of config events) 34 XSync (graphic->display, FALSE); 33 35 reftime = now; 34 36 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/kapa2/src/Refresh.c
r27790 r37403 47 47 Y0 = graphic[0].dy - graphic[0].dy * section[0].y - dY; 48 48 X0 = graphic[0].dx * section[0].x; 49 // fprintf (stderr, "section: (%s) %d %d - %d %d\n", section[0].name, X0, Y0, dX, dY);50 49 51 50 XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, X0, Y0, dX, dY); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/kapa2/src/bDrawObjects.c
r36680 r37403 540 540 FillCircle (buffer, sx, sy, D); 541 541 // out-of-range points skipped by bDrawLineHorizontal 542 } 543 } 544 } 545 if (object[0].ptype == 12) { /* filled triangle (down) */ 546 for (i = 0; i < object[0].Npts; i++) { 547 if (!(finite(x[i]) && finite(y[i]))) continue; 548 sx = x[i]*mxi + y[i]*mxj + bx; 549 sy = x[i]*myi + y[i]*myj + by; 550 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 551 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 552 { 553 if (scaleColor) { 554 if (!finite(z[i])) continue; 555 int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1))); 556 buffer->bColor_R = pixel1[pixel]; 557 buffer->bColor_G = pixel2[pixel]; 558 buffer->bColor_B = pixel3[pixel]; 559 } 560 D = scaleSize ? dz*z[i] : ds; 561 // FillTriangle (buffer, sx - D, sy - 0.58*D, sx + D, sy - 0.58*D, sx, sy + 1.15*D); 562 FillTriangle (buffer, sx, sy + 0.58*D, D, 1.73*D); 563 // out-of-range points skipped by bDrawPoint 542 564 } 543 565 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/Makefile.Targets
r34405 r37403 12 12 $(ASRC)/average-ps1-v3.$(ARCH).o \ 13 13 $(ASRC)/average-ps1-v4.$(ARCH).o \ 14 $(ASRC)/average-ps1-v5.$(ARCH).o \ 14 15 $(ASRC)/average-ps1-ref.$(ARCH).o \ 15 16 $(ASRC)/secfilt.$(ARCH).o \ … … 24 25 $(ASRC)/secfilt-ps1-v3.$(ARCH).o \ 25 26 $(ASRC)/secfilt-ps1-v4.$(ARCH).o \ 27 $(ASRC)/secfilt-ps1-v5.$(ARCH).o \ 26 28 $(ASRC)/secfilt-ps1-ref.$(ARCH).o \ 27 29 $(ASRC)/measure.$(ARCH).o \ … … 36 38 $(ASRC)/measure-ps1-v3.$(ARCH).o \ 37 39 $(ASRC)/measure-ps1-v4.$(ARCH).o \ 40 $(ASRC)/measure-ps1-v5.$(ARCH).o \ 38 41 $(ASRC)/measure-ps1-ref.$(ARCH).o \ 42 $(ASRC)/lensing.$(ARCH).o \ 43 $(ASRC)/lensing-ps1-v5.$(ARCH).o \ 44 $(ASRC)/lensobj.$(ARCH).o \ 45 $(ASRC)/lensobj-ps1-v5.$(ARCH).o \ 39 46 $(ASRC)/missing.$(ARCH).o \ 40 47 $(ASRC)/photcode.$(ARCH).o \ … … 47 54 $(ASRC)/photcode-ps1-v3.$(ARCH).o \ 48 55 $(ASRC)/photcode-ps1-v4.$(ARCH).o \ 56 $(ASRC)/photcode-ps1-v5.$(ARCH).o \ 49 57 $(ASRC)/photcode-ps1-ref.$(ARCH).o \ 50 58 $(ASRC)/image.$(ARCH).o \ … … 60 68 $(ASRC)/image-ps1-v3.$(ARCH).o \ 61 69 $(ASRC)/image-ps1-v4.$(ARCH).o \ 70 $(ASRC)/image-ps1-v5.$(ARCH).o \ 62 71 $(ASRC)/image-ps1-ref.$(ARCH).o \ 63 72 $(ASRC)/regimage.$(ARCH).o \ … … 73 82 $(ASRC)/cmf-ps1-sv1.$(ARCH).o \ 74 83 $(ASRC)/cmf-ps1-sv2.$(ARCH).o \ 84 $(ASRC)/cmf-ps1-dv4.$(ARCH).o \ 75 85 $(ASRC)/cmf-smpdata.$(ARCH).o \ 76 86 $(ASRC)/getstar-ps1-dev-0.$(ARCH).o \ … … 84 94 $(ASRC)/FlatCorrectionImage.$(ARCH).o \ 85 95 $(ASRC)/FlatCorrection.$(ARCH).o 96 97 # $(ASRC)/cmf-ps1-sv3.$(ARCH).o 86 98 87 99 AINCS = \ … … 98 110 $(AINC)/average-ps1-v3.h \ 99 111 $(AINC)/average-ps1-v4.h \ 112 $(AINC)/average-ps1-v5.h \ 100 113 $(AINC)/average-ps1-ref.h \ 101 114 $(AINC)/secfilt.h \ … … 110 123 $(AINC)/secfilt-ps1-v3.h \ 111 124 $(AINC)/secfilt-ps1-v4.h \ 125 $(AINC)/secfilt-ps1-v5.h \ 112 126 $(AINC)/secfilt-ps1-ref.h \ 113 127 $(AINC)/measure.h \ … … 122 136 $(AINC)/measure-ps1-v3.h \ 123 137 $(AINC)/measure-ps1-v4.h \ 138 $(AINC)/measure-ps1-v5.h \ 124 139 $(AINC)/measure-ps1-ref.h \ 140 $(AINC)/lensing.h \ 141 $(AINC)/lensing-ps1-v5.h \ 142 $(AINC)/lensobj.h \ 143 $(AINC)/lensobj-ps1-v5.h \ 125 144 $(AINC)/missing.h \ 126 145 $(AINC)/photcode.h \ … … 133 152 $(AINC)/photcode-ps1-v3.h \ 134 153 $(AINC)/photcode-ps1-v4.h \ 154 $(AINC)/photcode-ps1-v5.h \ 135 155 $(AINC)/photcode-ps1-ref.h \ 136 156 $(AINC)/image.h \ … … 146 166 $(AINC)/image-ps1-v3.h \ 147 167 $(AINC)/image-ps1-v4.h \ 168 $(AINC)/image-ps1-v5.h \ 148 169 $(AINC)/image-ps1-ref.h \ 149 170 $(AINC)/regimage.h \ … … 159 180 $(AINC)/cmf-ps1-sv1.h \ 160 181 $(AINC)/cmf-ps1-sv2.h \ 182 $(AINC)/cmf-ps1-dv4.h \ 161 183 $(AINC)/cmf-smpdata.h \ 162 184 $(AINC)/getstar-ps1-dev-0.h \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/average-ps1-dev-2.d
r16810 r37403 25 25 FIELD measureOffset, OFF_MEASURE, int, offset to first psf measurement 26 26 FIELD missingOffset, OFF_MISSING, int, offset to first missing obs 27 FIELD extendOffset, OFF_EXTEND, int, offset to first extended measurement27 FIELD refColor, REF_COLOR, float, color of astrometry ref stars 28 28 29 29 FIELD code, code, unsigned short, ID code (star; ghost; etc) -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/average-ps1-v1.d
r21508 r37403 30 30 FIELD measureOffset, OFF_MEASURE, uint32_t, offset to first psf measurement 31 31 FIELD missingOffset, OFF_MISSING, uint32_t, offset to first missing obs 32 FIELD extendOffset, OFF_EXTEND, uint32_t, offset to first extended measurement32 FIELD refColor, REF_COLOR, float, color of astrometry ref stars 33 33 34 34 # 'flags' was called 'code' prior to 2009.02.07 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/average-ps1-v2.d
r33647 r37403 35 35 FIELD measureOffset, OFF_MEASURE, uint32_t, offset to first psf measurement 36 36 FIELD missingOffset, OFF_MISSING, uint32_t, offset to first missing obs 37 FIELD extendOffset, OFF_EXTEND, uint32_t, offset to first extended measurement37 FIELD refColor, REF_COLOR, float, color of astrometry ref stars 38 38 39 39 # 'flags' was called 'code' prior to 2009.02.07 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/average-ps1-v3.d
r33647 r37403 35 35 FIELD measureOffset, OFF_MEASURE, uint32_t, offset to first psf measurement 36 36 FIELD missingOffset, OFF_MISSING, uint32_t, offset to first missing obs 37 FIELD extendOffset, OFF_EXTEND, uint32_t, offset to first extended measurement37 FIELD refColor, REF_COLOR, float, color of astrometry ref stars 38 38 39 39 # 'flags' was called 'code' prior to 2009.02.07 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/average-ps1-v4.d
r34405 r37403 38 38 FIELD measureOffset, OFF_MEASURE, uint32_t, offset to first psf measurement 39 39 FIELD missingOffset, OFF_MISSING, uint32_t, offset to first missing obs 40 FIELD extendOffset, OFF_EXTEND, uint32_t, offset to first extended measurement40 FIELD refColor, REF_COLOR, float, color of reference stars 41 41 42 42 # 'flags' was called 'code' prior to 2009.02.07 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/average.d
r34405 r37403 2 2 EXTNAME DVO_AVERAGE 3 3 TYPE BINTABLE 4 SIZE 1 284 SIZE 192 5 5 DESCRIPTION DVO Average Object Table 6 6 … … 19 19 FIELD dP, PAR_ERR, float, parallax error, arcsec 20 20 21 FIELD Rstk, RA_STK, double, RA on stack, decimal degrees 22 FIELD Dstk, DEC_STK, double, DEC on stack, decimal degrees 23 FIELD dRstk, RA_STK_ERR, float, RA error on stack, arcsec 24 FIELD dDstk, DEC_STK_ERR, float, DEC error on stack, arcsec 25 21 26 FIELD ChiSqAve, CHISQ_POS, float, astrometry analysis chisq 22 27 FIELD ChiSqPM, CHISQ_PM, float, astrometry analysis chisq … … 34 39 FIELD Nmeasure, NMEASURE, unsigned short, number of psf measurements 35 40 FIELD Nmissing, NMISSING, unsigned short, number of missings 41 FIELD Nlensing, NLENSING, unsigned short, number of lensing measurements 42 FIELD Nlensobj, NLENSOBJ, unsigned short, number of lensing measurements 36 43 FIELD Nextend, NEXTEND, unsigned short, number of extended measurements 37 44 38 45 FIELD measureOffset, OFF_MEASURE, int, offset to first psf measurement 39 46 FIELD missingOffset, OFF_MISSING, int, offset to first missing obs 40 FIELD extendOffset, OFF_EXTEND, int, offset to first extended measurement 47 FIELD lensingOffset, OFF_LENSING, int, offset to first lensing obs 48 FIELD lensobjOffset, OFF_LENSOBJ, int, offset to mean lensing data 49 FIELD extendOffset, OFF_EXTEND, int, offset to extended object entry 50 FIELD paramsOffset, OFF_PARAMS, int, offset to stellar parameter data 51 52 FIELD refColorBlue, REF_COLOR_BLUE, float, color of astrometry ref stars 53 FIELD refColorRed, REF_COLOR_RED, float, color of astrometry ref stars 54 55 FIELD tessID, TESS_ID, char, ID of tessellation for primary skycell 56 FIELD skycellID, SKYCELL_ID, char, ID of skycell for primary skycell 57 FIELD projectionID, PROJECTION_ID, short, ID of projection for primary skycell 58 59 FIELD dummy, DUMMY, int, unassigned bytes 41 60 42 61 # 'flags' was called 'code' prior to 2009.02.07 … … 49 68 FIELD catID, CAT_ID, unsigned int, unique ID for table in which object was first realized 50 69 FIELD extID, EXT_ID, uint64_t, external ID for object (eg PSPS objID) 70 FIELD extIDgc, EXT_ID_GC, uint64_t, external ID for object in galactic coords 51 71 52 72 # this structure should only be used for internal representations … … 56 76 57 77 # *** 20090206 : new fields : ChiSq, Npos, flags (was code, uint16_t), extID 58 59 78 # *** 20100331 : new fields needed to assess astrometry analysis quality: 60 79 # *** 20140617 : new fields : Rstk, Dstk, dRstk,dDstk, Nlensing, Nlensobj, lensingOffset, lensobjOffset, refColor 61 80 62 81 # photflagsUpper & photflagsLower: we have Nmeasures of a given source -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/common.h
r34088 r37403 32 32 # define rawshort short 33 33 34 # define DVO_IMAGE_NAME_LEN 1 2134 # define DVO_IMAGE_NAME_LEN 117 35 35 36 36 /*** rawshort is used to handle the broken pre-autocode photreg tables -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/image-ps1-v2.d
r30604 r37403 42 42 FIELD DECo, DEC_CENTER, float, image center, degrees 43 43 FIELD Radius, RADIUS, float, image radius, degrees 44 FIELD DUMMY, DUMMY,float, dummy44 FIELD refColor, REF_COLOR, float, dummy 45 45 46 46 # should we define the max length of name as a macro? -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/image-ps1-v3.d
r33647 r37403 42 42 FIELD DECo, DEC_CENTER, float, image center, degrees 43 43 FIELD Radius, RADIUS, float, image radius, degrees 44 FIELD DUMMY, DUMMY,float, dummy44 FIELD refColor, REF_COLOR, float, dummy 45 45 46 46 # should we define the max length of name as a macro? -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/image-ps1-v4.d
r34260 r37403 42 42 FIELD DECo, DEC_CENTER, float, image center, degrees 43 43 FIELD Radius, RADIUS, float, image radius, degrees 44 FIELD DUMMY, DUMMY,float, dummy44 FIELD refColor, REF_COLOR, float, dummy 45 45 46 46 # should we define the max length of name as a macro? -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/image.d
r33963 r37403 44 44 FIELD DECo, DEC_CENTER, float, image center, degrees 45 45 FIELD Radius, RADIUS, float, image radius, degrees 46 FIELD DUMMY, DUMMY, float, dummy 46 FIELD refColorBlue, REF_COLOR_BLUE, float, median astrometry ref color 47 FIELD refColorRed, REF_COLOR_RED, float, median astrometry ref color 47 48 48 FIELD name, NAME, char[121], name of original image 49 # should we define the max length of name as a macro? 50 FIELD name, NAME, char[117], name of original image 49 51 FIELD detection_limit, DETECTION_LIMIT, unsigned char, detection limit, 10*mag 50 52 FIELD saturation_limit, SATURATION_LIMIT, unsigned char, saturation limit, 10*mag -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/measure.d
r35099 r37403 2 2 EXTNAME DVO_MEASURE 3 3 TYPE BINTABLE 4 SIZE 1844 SIZE 228 5 5 DESCRIPTION DVO Detection Measurement Table 6 6 7 FIELD dR, D_RA, float, RA offset, arcsec 8 FIELD dD, D_DEC, float, DEC offset, arcsec 9 FIELD M, MAG, float, catalog mag, mag 10 FIELD Mcal, M_CAL, float, image cal mag, mag 11 FIELD Map, M_APER, float, aperture mag, mag 12 FIELD Mkron, M_KRON, float, kron magnitude, mag 13 FIELD dMkron, M_KRON_ERR, float, kron magnitude error, mag 14 FIELD dM, MAG_ERR, float, mag error, mag 15 FIELD dMcal, MAG_CAL_ERR, float, systematic calibration error, mag 16 FIELD dt, M_TIME, float, exposure time, 2.5*log(exptime) 7 FIELD R, RA, double, RA at epoch, degrees 8 FIELD D, DEC, double, DEC at epoch, degrees 9 FIELD M, MAG, float, catalog mag, mag 10 FIELD dM, MAG_ERR, float, mag error, mag 11 FIELD Map, M_APER, float, aperture mag, mag 12 FIELD dMap, M_APER, float, aperture mag, mag 13 FIELD Mkron, M_KRON, float, kron magnitude, mag 14 FIELD dMkron, M_KRON_ERR, float, kron magnitude error, mag 15 FIELD Mcal, M_CAL, float, image cal mag, mag 16 FIELD dMcal, MAG_CAL_ERR, float, systematic calibration error, mag 17 FIELD dt, M_TIME, float, exposure time, 2.5*log(exptime) 17 18 18 19 # for stacks only? 19 FIELD FluxPSF, FLUX_PSF, float, flux from psf fit, counts/sec? 20 FIELD dFluxPSF, FLUX_PSF_ERR, float, error on psf flux, counts/sec? 21 FIELD FluxKron, FLUX_KRON, float, flux from kron ap, counts/sec? 22 FIELD dFluxKron, FLUX_KRON_ERR, float, error on kron flux, counts/sec? 20 FIELD FluxPSF, FLUX_PSF, float, flux from psf fit, counts/sec 21 FIELD dFluxPSF, FLUX_PSF_ERR, float, error on psf flux, counts/sec 22 FIELD FluxKron, FLUX_KRON, float, flux from kron ap, counts/sec 23 FIELD dFluxKron, FLUX_KRON_ERR, float, error on kron flux, counts/sec 24 FIELD FluxAp, FLUX_AP, float, flux from ap, counts/sec 25 FIELD dFluxAp, FLUX_AP_ERR, float, error on ap flux, counts/sec 23 26 24 27 # note that with airmass = 1.0 / cos(90 - alt), we have full alt/az representation … … 33 36 FIELD Yfix, Y_FIX, float, Y coord after correction, pixels 34 37 38 FIELD XoffKH, X_OFF_KH, float, X offset from correction, pixels 39 FIELD YoffKH, Y_OFF_KH, float, Y offset from correction, pixels 40 FIELD XoffDCR, X_OFF_DCR, float, X offset from correction, pixels 41 FIELD YoffDCR, Y_OFF_DCR, float, Y offset from correction, pixels 42 FIELD RoffGAL, R_OFF_GAL, float, RA offset from correction, arcsec 43 FIELD DoffGAL, D_OFF_GAL, float, DEC offset from correction, arcsec 44 35 45 # could these be packed into fewer bits? 36 46 FIELD Sky, SKY_FLUX, float, local estimate of sky flux, counts/sec … … 38 48 39 49 FIELD t, TIME, int, time in seconds (UNIX) 40 FIELD t_msec, TIME_MSEC, unsigned short, time fraction of second, milliseconds41 50 FIELD averef, AVE_REF, unsigned int, reference to average entry 42 51 43 52 FIELD detID, DET_ID, unsigned int, detection ID 44 FIELD imageID, IMAGE_ID, unsigned int, reference to DVO image ID45 53 FIELD objID, OBJ_ID, unsigned int, unique ID for object in table 46 54 FIELD catID, CAT_ID, unsigned int, unique ID for table in which object was first realized … … 48 56 # PSPS uses a 64-bit detection ID 49 57 FIELD extID, EXT_ID, uint64_t, external ID (eg PSPS detID) 58 59 FIELD imageID, IMAGE_ID, unsigned int, reference to DVO image ID 50 60 51 61 # do we need more resolution than a short? should this be a log? … … 56 66 FIELD psfNdof, PSF_NDOF, int, psf degrees of freedom 57 67 FIELD psfNpix, PSF_NPIX, int, psf number of pixels 58 FIELD crNsigma, CR_NSIGMA, float, Nsigma deviation towards CR68 FIELD photFlags2, PHOT_FLAGS, int, flags supplied by photometry program 59 69 FIELD extNsigma, EXT_NSIGMA, float, Nsigma deviation towards EXT 60 70 … … 69 79 FIELD Myy, MYY, short, second moments in pixel coords, 1/100 of pixels^2 70 80 81 # fractional exposure time 82 FIELD t_msec, TIME_MSEC, unsigned short, time fraction of second, milliseconds 83 FIELD photcode, PHOTCODE, unsigned short, photcode 84 71 85 # convert this to error in pixels on load? 72 86 FIELD dXccd, X_CCD_ERR, short, X coord error on chip, 1/100 of pixels … … 77 91 FIELD pltscale, PLTSCALE, float, plate scale, arcsec/pixel 78 92 79 FIELD photcode, PHOTCODE, unsigned short, photcode80 93 FIELD dbFlags, DB_FLAGS, unsigned int, flags supplied by analysis in database 81 94 FIELD photFlags, PHOT_FLAGS, unsigned int, flags supplied by photometry program … … 85 98 # Changed dbFlags, photFlags : uint16_t to uint64_t 86 99 100 # *** 20140617 : changed: dR,dD -> R,D (removed dependence on average.R,D) 101 added: dMap, FluxAp, dFluxAp, (X,Y)off(KH,DCR,GAL) 102 87 103 # XXX unsigned int values are probably not being saved in the FITS file correctly: no BZERO, BSCALE -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/photcode-ps1-v2.d
r27579 r37403 22 22 FIELD astromErrScale, ASTROM_ERR_SCALE, float, astrometric error scale 23 23 FIELD astromErrMagScale, ASTROM_ERR_MAG_SCALE, float, astrometric error / mag error scale 24 FIELD astromPoorMask, ASTROM_POOR_MASK, short,detections matching this mask should only be used in emergencies25 FIELD astromBadMask, ASTROM_BAD_MASK, short,detections matching this mask should not be used24 FIELD astromPoorMask, ASTROM_POOR_MASK, unsigned short, detections matching this mask should only be used in emergencies 25 FIELD astromBadMask, ASTROM_BAD_MASK, unsigned short, detections matching this mask should not be used 26 26 FIELD photomErrSys, PHOTOM_ERR_SYS, float, systematic photometric error 27 FIELD photomPoorMask, PHOTOM_POOR_MASK, short,detections matching this mask should only be used in emergencies28 FIELD photomBadMask, PHOTOM_BAD_MASK, short,detections matching this mask should not be used27 FIELD photomPoorMask, PHOTOM_POOR_MASK, unsigned short, detections matching this mask should only be used in emergencies 28 FIELD photomBadMask, PHOTOM_BAD_MASK, unsigned short, detections matching this mask should not be used 29 29 30 30 # dR_total^2 = dR_sys^2 + AS * dR_obs^2 + MS * dM_obs^2 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/photcode-ps1-v3.d
r33647 r37403 22 22 FIELD astromErrScale, ASTROM_ERR_SCALE, float, astrometric error scale 23 23 FIELD astromErrMagScale, ASTROM_ERR_MAG_SCALE, float, astrometric error / mag error scale 24 FIELD astromPoorMask, ASTROM_POOR_MASK, int,detections matching this mask should only be used in emergencies25 FIELD astromBadMask, ASTROM_BAD_MASK, int,detections matching this mask should not be used24 FIELD astromPoorMask, ASTROM_POOR_MASK, unsigned int, detections matching this mask should only be used in emergencies 25 FIELD astromBadMask, ASTROM_BAD_MASK, unsigned int, detections matching this mask should not be used 26 26 FIELD photomErrSys, PHOTOM_ERR_SYS, float, systematic photometric error 27 FIELD photomPoorMask, PHOTOM_POOR_MASK, int,detections matching this mask should only be used in emergencies28 FIELD photomBadMask, PHOTOM_BAD_MASK, int,detections matching this mask should not be used27 FIELD photomPoorMask, PHOTOM_POOR_MASK, unsigned int, detections matching this mask should only be used in emergencies 28 FIELD photomBadMask, PHOTOM_BAD_MASK, unsigned int, detections matching this mask should not be used 29 29 30 30 # dR_total^2 = dR_sys^2 + AS * dR_obs^2 + MS * dM_obs^2 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/photcode-ps1-v4.d
r34260 r37403 22 22 FIELD astromErrScale, ASTROM_ERR_SCALE, float, astrometric error scale 23 23 FIELD astromErrMagScale, ASTROM_ERR_MAG_SCALE, float, astrometric error / mag error scale 24 FIELD astromPoorMask, ASTROM_POOR_MASK, int,detections matching this mask should only be used in emergencies25 FIELD astromBadMask, ASTROM_BAD_MASK, int,detections matching this mask should not be used24 FIELD astromPoorMask, ASTROM_POOR_MASK, unsigned int, detections matching this mask should only be used in emergencies 25 FIELD astromBadMask, ASTROM_BAD_MASK, unsigned int, detections matching this mask should not be used 26 26 FIELD photomErrSys, PHOTOM_ERR_SYS, float, systematic photometric error 27 FIELD photomPoorMask, PHOTOM_POOR_MASK, int,detections matching this mask should only be used in emergencies28 FIELD photomBadMask, PHOTOM_BAD_MASK, int,detections matching this mask should not be used27 FIELD photomPoorMask, PHOTOM_POOR_MASK, unsigned int, detections matching this mask should only be used in emergencies 28 FIELD photomBadMask, PHOTOM_BAD_MASK, unsigned int, detections matching this mask should not be used 29 29 30 30 # dR_total^2 = dR_sys^2 + AS * dR_obs^2 + MS * dM_obs^2 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/photcode.d
r33647 r37403 22 22 FIELD astromErrScale, ASTROM_ERR_SCALE, float, astrometric error scale 23 23 FIELD astromErrMagScale, ASTROM_ERR_MAG_SCALE, float, astrometric error / mag error scale 24 FIELD astromPoorMask, ASTROM_POOR_MASK, int,detections matching this mask should only be used in emergencies25 FIELD astromBadMask, ASTROM_BAD_MASK, int,detections matching this mask should not be used24 FIELD astromPoorMask, ASTROM_POOR_MASK, unsigned int, detections matching this mask should only be used in emergencies 25 FIELD astromBadMask, ASTROM_BAD_MASK, unsigned int, detections matching this mask should not be used 26 26 FIELD photomErrSys, PHOTOM_ERR_SYS, float, systematic photometric error 27 FIELD photomPoorMask, PHOTOM_POOR_MASK, int,detections matching this mask should only be used in emergencies28 FIELD photomBadMask, PHOTOM_BAD_MASK, int,detections matching this mask should not be used27 FIELD photomPoorMask, PHOTOM_POOR_MASK, unsigned int, detections matching this mask should only be used in emergencies 28 FIELD photomBadMask, PHOTOM_BAD_MASK, unsigned int, detections matching this mask should not be used 29 29 30 30 # dR_total^2 = dR_sys^2 + AS * dR_obs^2 + MS * dM_obs^2 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/secfilt-ps1-v1.d
r21508 r37403 6 6 7 7 # elements of data structure / FITS table 8 FIELD M, MAG, float, average mag in this band, mags9 FIELD dM, MAG_ERR, float, error on average mag, mags10 FIELD Xm, MAG_CHI, float, chisq on average mag, [100*log(value)]11 FIELD Ncode, NCODE, short, number of detections in band12 FIELD Nused, NUSED, short, number of detections used in average13 FIELD M_20, MAG_20, short, lower 20percent mag, millimags14 FIELD M_80, MAG_80, short, upper 20percent mag, millimags8 FIELD M, MAG, float, average mag in this band, mags 9 FIELD dM, MAG_ERR, float, error on average mag, mags 10 FIELD Mchisq, MAG_CHI, float, chisq on average mag, value 11 FIELD Ncode, NCODE, short, number of detections in band 12 FIELD Nused, NUSED, short, number of detections used in average 13 FIELD M_20, MAG_20, short, lower 20percent mag, millimags 14 FIELD M_80, MAG_80, short, upper 20percent mag, millimags -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/secfilt-ps1-v2.d
r27579 r37403 6 6 7 7 # elements of data structure / FITS table 8 FIELD M, MAG, float, average mag in this band, mags9 FIELD dM, MAG_ERR, float, error on average mag, mags10 FIELD Xm, MAG_CHI, float, chisq on average mag, [100*log(value)]11 FIELD flags, FLAGS, uint32_t, photometry flags12 FIELD Ncode, NCODE, short, number of detections in band13 FIELD Nused, NUSED, short, number of detections used in average14 FIELD M_20, MAG_20, short, lower 20percent mag, millimags15 FIELD M_80, MAG_80, short, upper 20percent mag, millimags8 FIELD M, MAG, float, average mag in this band, mags 9 FIELD dM, MAG_ERR, float, error on average mag, mags 10 FIELD Mchisq, MAG_CHI, float, chisq on average mag, value 11 FIELD flags, FLAGS, uint32_t, photometry flags 12 FIELD Ncode, NCODE, short, number of detections in band 13 FIELD Nused, NUSED, short, number of detections used in average 14 FIELD M_20, MAG_20, short, lower 20percent mag, millimags 15 FIELD M_80, MAG_80, short, upper 20percent mag, millimags -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/secfilt-ps1-v3.d
r33963 r37403 9 9 FIELD Map, MAG_AP, float, ave aperture mag in this band, mags 10 10 FIELD dM, MAG_ERR, float, formal error on average mag, mags 11 FIELD Xm, MAG_CHI, float, chisq on average mag, [100*log(value)]11 FIELD Mchisq, MAG_CHI, float, chisq on average mag, value 12 12 FIELD flags, FLAGS, uint32_t, photometry flags 13 13 FIELD Ncode, NCODE, short, number of detections in band -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/secfilt-ps1-v4.d
r34620 r37403 11 11 FIELD dMkron, MAG_KRON_ERR, float, formal error on average kron mag, mags 12 12 FIELD dM, MAG_ERR, float, formal error on average mag, mags 13 FIELD Xm, MAG_CHI, float, chisq on average mag, [100*log(value)]13 FIELD Mchisq, MAG_CHI, float, chisq on average mag, value 14 14 FIELD FluxPSF, FLUX_PSF, float, mean flux psf fit (PS1: stack) 15 15 FIELD dFluxPSF, FLUX_PSF_ERR, float, mean flux psf error … … 23 23 FIELD ubercalDist, UBERCAL_DIST, short, number of images from an ubercal-image 24 24 FIELD Mstdev, MAG_STDEV, short, standard deviation of measurements, millimags 25 FIELD stackDetectID, STACK_DETECT_ID, uint64_t, detection ID on stack used for fluxes (if any) 25 FIELD stackPrmryOff, STACK_PRIMARY_OFF, int, measure entry which is primary stack detection 26 FIELD stackBestOff, STACK_BEST_OFF, int, measure entry which is best stack detection -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libautocode/def/secfilt.d
r35099 r37403 2 2 EXTNAME DVO_SECFILT 3 3 TYPE BINTABLE 4 SIZE 644 SIZE 176 5 5 DESCRIPTION DVO SecFilt : Secondary Filter Data 6 6 7 # elements of data structure / FITS table7 ## *** this section is for per-exposure mean values *** (unlabled values are implicitly PSF values) 8 8 FIELD M, MAG, float, average mag in this band, mags 9 FIELD dM, MAG_ERR, float, formal error on average mag, mags 9 10 FIELD Map, MAG_AP, float, average mag in this band, mags 11 FIELD dMap, MAG_AP_ERR, float, formal error on average mag, mags 12 FIELD sMap, MAG_AP_STDEV, float, standard deviation of ap mags, mags 10 13 FIELD Mkron, MAG_KRON, float, ave kron mag in this band, mags 11 14 FIELD dMkron, MAG_KRON_ERR, float, formal error on average kron mag, mags 12 FIELD dM, MAG_ERR, float, formal error on average mag, mags 13 FIELD Xm, MAG_CHI, float, chisq on average mag, [100*log(value)] 14 FIELD FluxPSF, FLUX_PSF, float, mean flux psf fit (PS1: stack) 15 FIELD dFluxPSF, FLUX_PSF_ERR, float, mean flux psf error 16 FIELD FluxKron, FLUX_KRON, float, mean flux kron ap (PS1: stack) 17 FIELD dFluxKron, FLUX_KRON_ERR, float, mean flux kron err 15 FIELD sMkron, MAG_KRON_STDEV, float, standard deviation of kron mags, mags 16 17 # XXX I could add these fields to secfilt or calculate in dvopsps? 18 FIELD psfQfMax, PSF_QF_MAX, float, best psfQf for this filter 19 FIELD psfQfPerfMax, PSF_QF_PERF_MAX, float, best psfQfPerfect for this filter 20 21 # these statistics are PSF-specific 22 FIELD Mstdev, MAG_STDEV, float, standard deviation of measurements, mags 23 FIELD Mmin, MAG_MIN, float, minimum accepted mag, mags 24 FIELD Mmax, MAG_MAX, float, maximum accepted mag, mags 25 FIELD Mchisq, MAG_CHI, float, chisq on average mag, value 26 27 FIELD Ncode, NCODE, short, number of detections in band (gpc1 chip only) 28 FIELD Nused, NUSED, short, number of detections used to calculate secfilt.M 29 FIELD NusedKron, NUSED_KRON, short, number of detections used to calculate secfilt.Mkron 30 FIELD NusedAp, NUSED_AP, short, number of detections used to calculate secfilt.Map 31 18 32 FIELD flags, FLAGS, uint32_t, photometry flags 19 FIELD Ncode, NCODE, short, number of detections in band 20 FIELD Nused, NUSED, short, number of detections used in average 21 FIELD M_20, MAG_20, short, lower 20percent mag, millimags 22 FIELD M_80, MAG_80, short, upper 20percent mag, millimags 23 FIELD ubercalDist, UBERCAL_DIST, short, number of images from an ubercal-image 24 FIELD Mstdev, MAG_STDEV, short, standard deviation of measurements, millimags 25 FIELD stackDetectID, STACK_DETECT_ID, uint64_t, detection ID on stack used for fluxes (if any) 33 34 ## *** this section is for stack values *** 35 36 FIELD MpsfStk, MAG_PSF_STK, float, magnitude from stack (primary if available) 37 FIELD FpsfStk, FLUX_PSF_STK, float, flux from stack (primary if available) 38 FIELD dFpsfStk, FLUX_PSF_STK_ERR, float, mean flux psf error 39 40 FIELD MkronStk, MAG_KRON_STK, float, magnitude from stack (primary if available) 41 FIELD FkronStk, FLUX_KRON_STK, float, flux from stack (primary if available) 42 FIELD dFkronStk, FLUX_KRON_STK_ERR, float, mean flux kron error 43 44 FIELD MapStk, MAG_AP_STK, float, magnitude from stack (primary if available) 45 FIELD FapStk, FLUX_AP_STK, float, flux from stack (primary if available) 46 FIELD dFapStk, FLUX_AP_STK_ERR, float, mean flux ap error 47 48 FIELD Nstack, NSTACK, short, number of measurements in band (gpc1 stack only) 49 FIELD NstackDet, NSTACK_DET, short, number of stack detections in band (gpc1 stack only) 50 51 FIELD stackPrmryOff, STACK_PRIMARY_OFF, int, measure entry which is primary stack detection 52 FIELD stackBestOff, STACK_BEST_OFF, int, measure entry which is best stack detection 53 54 ## *** this section is for forced-warp mean values *** 55 56 FIELD MpsfWrp, MAG_PSF_WRP, float, psf magnitude from stack (primary if available) 57 FIELD FpsfWrp, FLUX_PSF_WRP, float, psf flux from stack (primary if available) 58 FIELD dFpsfWrp, FLUX_PSF_WRP_ERR, float, mean flux psf error 59 FIELD sFpsfWrp, FLUX_PSF_WRP_STD, float, mean flux psf stdev 60 61 FIELD MkronWrp, MAG_KRON_WRP, float, kron magnitude from stack (primary if available) 62 FIELD FkronWrp, FLUX_KRON_WRP, float, kron flux from stack (primary if available) 63 FIELD dFkronWrp, FLUX_KRON_WRP_ERR, float, mean flux kron error 64 FIELD sFkronWrp, FLUX_KRON_WRP_STD, float, mean flux kron stdev 65 66 FIELD MapWrp, MAG_AP_WRP, float, aper magnitude from stack (primary if available) 67 FIELD FapWrp, FLUX_AP_WRP, float, aper flux from stack (primary if available) 68 FIELD dFapWrp, FLUX_AP_WRP_ERR, float, mean flux ap error 69 FIELD sFapWrp, FLUX_AP_WRP_STD, float, mean flux ap stdev 70 71 FIELD NusedWrp, NUSED_WRP, short, number of detections used in average 72 FIELD NusedKronWrp, NUSED_KRON_WRP, short, number of detections used in average 73 FIELD NusedApWrp, NUSED_AP_WRP, short, number of detections used in average 74 75 FIELD Nwarp, NWARP, short, number of measurements in band (gpc1 warp only) 76 FIELD NwarpGood, NWARP_GOOD, short, number of meas with psf_qf > 0.85 in band (gpc1 warp only) 77 78 FIELD ubercalDist, UBERCAL_DIST, short, number of images from an ubercal-image 26 79 27 80 # *** 20090206 : new fields : M_20, M_80; dropped dummy 28 81 # *** 20120302 : new fields : ubercalDist, Map, Mstdev 29 82 # *** 20120710 : new fields : Mkron, dMkron, FluxPSF, dFluxPSF, FluxKron, dFluxKron, stackID 83 84 # *** 20140617 : added : dMap, NusedKron, NusedAp, MpsfStk, MkronStk, MapStk, *Wrp 85 : changed : Mstdev, M_20 (to Mmin,short:float),M_80 (to Mmax,short:float), 86 : rename : FpsfStk, dFpsfStk, FkronStk, dFronStk (were FluxPSF, dFluxPSF, FluxKron, dFluxKron) -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/Makefile
r36680 r37403 36 36 $(DESTINC)/ps1_v3_defs.h \ 37 37 $(DESTINC)/ps1_v4_defs.h \ 38 $(DESTINC)/ps1_v5_defs.h \ 38 39 $(DESTINC)/ps1_ref_defs.h \ 39 $(DESTINC)/cmf-ps1-dv3.h 40 $(DESTINC)/cmf-ps1-dv3.h \ 41 $(DESTINC)/cmf-ps1-v5.h \ 42 $(DESTINC)/cmf-ps1-sv3.h \ 43 $(DESTINC)/cmf-ps1-v5-lensing.h 40 44 41 45 INCS = $(DEFS) $(DESTINC)/dvo.h $(DESTINC)/autocode.h $(DESTINC)/dvo_util.h $(DESTINC)/dvodb.h $(DESTINC)/libdvo_astro.h $(DESTINC)/convert.h $(DESTINC)/get_graphdata.h … … 76 80 $(SRC)/dvo_convert_PS1_V3.$(ARCH).o \ 77 81 $(SRC)/dvo_convert_PS1_V4.$(ARCH).o \ 82 $(SRC)/dvo_convert_PS1_V5.$(ARCH).o \ 78 83 $(SRC)/dvo_convert_PS1_REF.$(ARCH).o \ 79 84 $(SRC)/flatcorr_io.$(ARCH).o \ … … 86 91 $(SRC)/cmf-ps1-sv1-alt.$(ARCH).o \ 87 92 $(SRC)/cmf-ps1-dv3.$(ARCH).o \ 93 $(SRC)/cmf-ps1-sv3.$(ARCH).o \ 94 $(SRC)/cmf-ps1-v5.$(ARCH).o \ 95 $(SRC)/cmf-ps1-v5-lensing.$(ARCH).o \ 88 96 $(SRC)/dvo_util.$(ARCH).o \ 89 97 $(SRC)/dbBooleanCond.$(ARCH).o \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/dvo.h
r36680 r37403 28 28 DVO_FORMAT_PS1_V3, 29 29 DVO_FORMAT_PS1_V4, 30 DVO_FORMAT_PS1_V5, 30 31 } DVOTableFormat; 31 32 … … 78 79 79 80 /* catalog values to be loaded */ 80 # define LOAD_NONE 0x00 81 # define LOAD_AVES 0x01 82 # define LOAD_MEAS 0x02 83 # define LOAD_MISS 0x04 84 # define LOAD_SECF 0x08 85 # define SKIP_AVES 0x10 86 # define SKIP_MEAS 0x20 87 # define SKIP_MISS 0x40 88 # define SKIP_SECF 0x80 89 90 // # define LOAD_MEAS_META 0x100 -- is this used?? 81 # define LOAD_NONE 0x000 82 # define LOAD_AVES 0x001 83 # define LOAD_MEAS 0x002 84 # define LOAD_MISS 0x004 85 # define LOAD_SECF 0x008 86 # define SKIP_AVES 0x010 87 # define SKIP_MEAS 0x020 88 # define SKIP_MISS 0x040 89 # define SKIP_SECF 0x080 90 # define LOAD_LENSING 0x100 91 # define LOAD_LENSOBJ 0x200 92 # define SKIP_LENSING 0x400 93 # define SKIP_LENSOBJ 0x800 91 94 92 95 /* photometry code types */ … … 125 128 ID_MEAS_BLEND_MEAS = 0x00000100, // detection is within radius of multiple objects 126 129 ID_MEAS_BLEND_OBJ = 0x00000200, // multiple detections within radius of object 127 ID_MEAS_ UNDEF_3 = 0x00000400, // unused130 ID_MEAS_WARP_USED = 0x00000400, // measurement used to find mean warp photometry 128 131 ID_MEAS_UNDEF_4 = 0x00000800, // unused 129 132 ID_MEAS_BLEND_MEAS_X = 0x00001000, // detection is within radius of multiple objects across catalogs … … 171 174 ID_STAR_USE_PAR = 0x00200000, // parallax used (not AVE or PM) 172 175 ID_STAR_NO_ASTROM = 0x00400000, // mean astrometry could not be measured 176 ID_STAR_BAD_PM = 0x00800000, // mean astrometry could not be measured 173 177 ID_OBJ_EXT = 0x01000000, // extended in our data (eg, PS) 174 178 ID_OBJ_EXT_ALT = 0x02000000, // extended in external data (eg, 2MASS) … … 333 337 // another special case : does not match byte-boundaries 334 338 # include "cmf-ps1-dv3.h" 339 # include "cmf-ps1-sv3.h" 340 # include "cmf-ps1-v5.h" 341 # include "cmf-ps1-v5-lensing.h" 335 342 336 343 typedef struct { … … 376 383 char ***name; // projection cell name 377 384 378 int NX_SUB;379 int NY_SUB;385 float NX_SUB; 386 float NY_SUB; 380 387 double dPix; 381 388 382 389 double **Xo; 383 390 double **Yo; 384 int **dX;385 int **dY;391 float **dX; 392 float **dY; 386 393 } BoundaryTree; 387 394 … … 404 411 double Do; 405 412 double dPix; 406 int dX;407 int dY;408 409 int NX_SUB;410 int NY_SUB;413 float dX; 414 float dY; 415 416 float NX_SUB; 417 float NY_SUB; 411 418 412 419 char *basename; … … 433 440 // a reduced-subset structure for relphot & relastro 434 441 typedef struct { 435 float dR;436 float dD;442 double R; 443 double D; 437 444 float M; 438 445 float Mcal; … … 457 464 } MeasureTiny; 458 465 459 / ** STRUCT DEFINITION **/466 // alternate version of PS1_V4 (old dev version) 460 467 typedef struct { 461 468 double R; // RA (decimal degrees ) … … 481 488 uint32_t measureOffset; // offset to first psf measurement 482 489 uint32_t missingOffset; // offset to first missing obs 483 uint32_t extendOffset;// offset to first extended measurement490 float refColor; // offset to first extended measurement 484 491 uint32_t flags; // average object flags (star; ghost; etc) 485 492 uint32_t photFlagsUpper; // upper bit of 2 bit summary of per-measure photflags … … 493 500 Average *Average_PS1_V4alt_ToInternal (Average_PS1_V4alt *in, off_t Nvalues); 494 501 495 / ** STRUCT DEFINITION **/502 // alternate version of PS1_V4 (old dev version) 496 503 typedef struct { 497 504 float dR; // RA offset (arcsec) … … 547 554 548 555 Measure_PS1_V4alt *gfits_table_get_Measure_PS1_V4alt (FTable *table, off_t *Ndata, char *swapped); 549 Measure *Measure_PS1_V4alt_ToInternal (Measure_PS1_V4alt *in, off_t Nvalues); 556 Measure *Measure_PS1_V4alt_ToInternal (Average *ave, Measure_PS1_V4alt *in, off_t Nvalues); 557 558 // alternate version of PS1_V5 (old dev version) 559 typedef struct { 560 float M; // average mag in this band (mags) 561 float dM; // formal error on average mag (mags) 562 float Map; // ave aperture mag in this band (mags) 563 float dMap; // ave aperture mag in this band (mags) 564 float sMap; // standard deviation of ap mags (mags) 565 float Mkron; // ave kron mag in this band (mags) 566 float dMkron; // formal error on average kron mag (mags) 567 float sMkron; // standard deviation of kron mags (mags) 568 float Mstdev; // standard deviation of measurements (mags) 569 float Mmin; // min accepted mag (mags) 570 float Mmax; // max accepted mag (mags) 571 float Mchisq; // chisq on average mag (value) 572 short Ncode; // number of detections in band 573 short Nused; // number of detections used in average 574 short NusedKron; // number of detections used in average 575 short NusedAp; // number of detections used in average 576 uint32_t flags; // photometry flags 577 float MpsfStk; // magnitude from stack (primary if available) 578 float FpsfStk; // flux from stack (primary if available) 579 float dFpsfStk; // mean flux psf error 580 float MkronStk; // magnitude from stack (primary if available) 581 float FkronStk; // flux from stack (primary if available) 582 float dFkronStk; // mean flux kron error 583 float MapStk; // magnitude from stack (primary if available) 584 float FapStk; // flux from stack (primary if available) 585 float dFapStk; // mean flux ap error 586 int stackPrmryOff; // measure entry which is primary stack detection 587 int stackBestOff; // measure entry which is best stack detection 588 float MpsfWrp; // psf magnitude from stack (primary if available) 589 float FpsfWrp; // psf flux from stack (primary if available) 590 float dFpsfWrp; // mean flux psf error 591 float sFpsfWrp; // mean flux psf stdev 592 float MkronWrp; // kron magnitude from stack (primary if available) 593 float FkronWrp; // kron flux from stack (primary if available) 594 float dFkronWrp; // mean flux kron error 595 float sFkronWrp; // mean flux kron stdev 596 float MapWrp; // aper magnitude from stack (primary if available) 597 float FapWrp; // aper flux from stack (primary if available) 598 float dFapWrp; // mean flux ap error 599 float sFapWrp; // mean flux ap stdev 600 short NusedWrp; // number of detections used in average 601 short NusedKronWrp; // number of detections used in average 602 short NusedApWrp; // number of detections used in average 603 short ubercalDist; // number of images from an ubercal-image 604 } SecFilt_PS1_V5alt; 605 606 SecFilt_PS1_V5alt *gfits_table_get_SecFilt_PS1_V5alt (FTable *table, off_t *Ndata, char *swapped); 607 int gfits_convert_SecFilt_PS1_V5alt (SecFilt_PS1_V5alt *data, off_t size, off_t nitems); 608 SecFilt *SecFilt_PS1_V5alt_ToInternal (SecFilt_PS1_V5alt *in, off_t Nvalues); 609 610 // alternate version of PS1_V5alt (old dev version) 611 typedef struct { 612 double R; // RA (decimal degrees ) 613 double D; // DEC (decimal degrees ) 614 float dR; // RA error (arcsec) 615 float dD; // DEC error (arcsec) 616 float uR; // RA*cos(D) proper-motion (arcsec/year) 617 float uD; // DEC proper-motion (arcsec/year) 618 float duR; // RA*cos(D) p-m error (arcsec/year) 619 float duD; // DEC p-m error (arcsec/year) 620 float P; // parallax (arcsec) 621 float dP; // parallax error (arcsec) 622 double Rstk; // RA on stack (decimal degrees ) 623 double Dstk; // DEC on stack (decimal degrees ) 624 float dRstk; // RA error on stack (arcsec) 625 float dDstk; // DEC error on stack (arcsec) 626 float ChiSqAve; // astrometry analysis chisq 627 float ChiSqPM; // astrometry analysis chisq 628 float ChiSqPar; // astrometry analysis chisq 629 int Tmean; // mean epoch (PM,PAR ref) (unix time seconds) 630 int Trange; // mean epoch (PM,PAR ref) (unix time seconds) 631 float psfQF; // psf coverage (bad masks) 632 float psfQFperf; // psf coverage (all masks) 633 float stargal; // star / galaxy separator (1/100 arcsec) 634 unsigned short Npos; // number of detections used for astrometry 635 unsigned short Nmeasure; // number of psf measurements 636 unsigned short Nmissing; // number of missings 637 unsigned short Nlensing; // number of lensing measurements 638 unsigned short Nlensobj; // number of lensing measurements 639 unsigned short Nextend; // number of extended measurements 640 int measureOffset; // offset to first psf measurement 641 int missingOffset; // offset to first missing obs 642 int lensingOffset; // offset to first lensing obs 643 int lensobjOffset; // offset to mean lensing data 644 int extendOffset; // offset to extended object entry 645 int paramsOffset; // offset to stellar parameter data 646 float refColorBlue; // color of astrometry ref stars 647 float refColorRed; // color of astrometry ref stars 648 uint32_t flags; // average object flags (star; ghost; etc) 649 uint32_t photFlagsUpper; // upper bit of 2 bit summary of per-measure photflags 650 uint32_t photFlagsLower; // lower bit of 2 bit summary of per-measure photflags 651 unsigned int objID; // unique ID for object in table 652 unsigned int catID; // unique ID for table in which object was first realized 653 uint64_t extID; // external ID for object (eg PSPS objID) 654 uint64_t extIDgc; // external ID for object in galactic coords 655 } Average_PS1_V5alt; 656 657 Average_PS1_V5alt *gfits_table_get_Average_PS1_V5alt (FTable *table, off_t *Ndata, char *swapped); 658 int gfits_convert_Average_PS1_V5alt (Average_PS1_V5alt *data, off_t size, off_t nitems); 659 Average *Average_PS1_V5alt_ToInternal (Average_PS1_V5alt *in, off_t Nvalues); 660 661 /* for some reason I have merged the set of tables and the file description, 662 so I need to have an internal structure to point to the separate files */ 550 663 551 664 /* a catalog contains this data */ … … 561 674 SecFilt *secfilt; 562 675 676 // lensing data (optional?) 677 Lensing *lensing; 678 Lensobj *lensobj; 679 563 680 int Nsecfilt; /* number of secfilt entries for each average entry */ 564 off_t Naverage, Nmeasure, Nmissing, N secf_mem; /* current number of each component in memory */565 off_t Naves_disk, Nmeas_disk, Nmiss_disk, N secf_disk; /* current number of each component on disk */566 off_t Naves_off, Nmeas_off, Nmiss_off, N secf_off; /* index of first loaded data value */681 off_t Naverage, Nmeasure, Nmissing, Nlensing, Nlensobj, Nsecf_mem; /* current number of each component in memory */ 682 off_t Naves_disk, Nmeas_disk, Nmiss_disk, Nlensing_disk, Nlensobj_disk, Nsecf_disk; /* current number of each component on disk */ 683 off_t Naves_off, Nmeas_off, Nmiss_off, Nlensing_off, Nlensobj_off, Nsecf_off; /* index of first loaded data value */ 567 684 568 685 // note that we use these for the full-sky relphot analysis … … 583 700 struct Catalog *missing_catalog; /* missing catalog data (split) */ 584 701 struct Catalog *secfilt_catalog; /* secfilt catalog data (split) */ 702 struct Catalog *lensing_catalog; /* lensing catalog data (split) */ 703 struct Catalog *lensobj_catalog; /* lensobj catalog data (split) */ 585 704 586 705 unsigned int objID; … … 591 710 char catmode; /* storage mode (raw, mef, split, mysql) */ 592 711 char catformat; /* storage format (elixir, panstarrs, etc) */ 593 char catflags; /* choices to be loaded */ 594 char sorted; /* is measure table average-sorted? */ 712 int sorted; /* is measure table average-sorted? (NOTE this is an int only because gfits_scan %t requires it) */ 595 713 714 short catflags; /* choices to be loaded */ 715 596 716 /* pointers for data manipulation */ 597 off_t *found; 598 off_t *image; 599 off_t *mosaic; 600 float *X; 601 float *Y; 602 int *nOwn; // relastro uses this to count owned detections per object 717 off_t *found_t; 718 off_t *foundWarp_t; 719 // off_t *image_t; 720 // off_t *mosaic_t; 721 // float *X_t; 722 // float *Y_t; 723 int *nOwn_t; // relastro uses this to count owned detections per object 603 724 604 725 } Catalog; … … 660 781 char *GetPhotcodeNamebyCode (int code); 661 782 662 float PhotInst (Measure *measure); 663 float PhotCat (Measure *measure); 664 float PhotSys (Measure *measure, Average *average, SecFilt *secfilt); 665 float PhotRel (Measure *measure, Average *average, SecFilt *secfilt); 666 float PhotCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code); 667 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt); 668 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure); 669 float PhotAveErr (PhotCode *code, Average *average, SecFilt *secfilt); 670 671 float PhotAperInst (Measure *measure); 672 float PhotAperCat (Measure *measure); 673 float PhotAperSys (Measure *measure, Average *average, SecFilt *secfilt); 674 float PhotAperRel (Measure *measure, Average *average, SecFilt *secfilt); 675 float PhotAperCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code); 676 float PhotAperAve (PhotCode *code, Average *average, SecFilt *secfilt); 677 float PhotAperRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure); 678 679 float PhotKronInst (Measure *measure); 680 float PhotKronCat (Measure *measure); 681 float PhotKronSys (Measure *measure, Average *average, SecFilt *secfilt); 682 float PhotKronRel (Measure *measure, Average *average, SecFilt *secfilt); 683 float PhotKronCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code); 684 float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt); 685 float PhotKronRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure); 686 float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt); 783 float PhotInst (Measure *measure, dvoMagClassType class); 784 float PhotCat (Measure *measure, dvoMagClassType class); 785 float PhotSys (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class); 786 float PhotRel (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class); 787 float PhotCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code, dvoMagClassType class); 788 float PhotErr (Measure *measure, dvoMagClassType class); 789 float PhotCalErr (Measure *measure, dvoMagClassType class); 790 791 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 792 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure, dvoMagClassType class, dvoMagSourceType source); 793 float PhotAveErr (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 794 795 float PhotInstTiny (MeasureTiny *measure, dvoMagClassType class); 796 float PhotCatTiny (MeasureTiny *measure, dvoMagClassType class); 797 float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class); 798 float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class); 799 float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code, dvoMagClassType class); 800 801 float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 802 float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, dvoMagClassType class, dvoMagSourceType source); 803 804 float PhotFluxInst (Measure *measure, dvoMagClassType class); 805 float PhotFluxCat (Measure *measure, dvoMagClassType class); 806 float PhotFluxSys (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class); 807 float PhotFluxRel (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class); 808 float PhotFluxCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code, dvoMagClassType class); 809 810 float PhotFluxAve (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 811 float PhotFluxRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure, dvoMagClassType class, dvoMagSourceType source); 812 813 float PhotFluxInstErr (Measure *measure, dvoMagClassType class); 814 float PhotFluxCatErr (Measure *measure, dvoMagClassType class); 815 float PhotFluxAveErr (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 687 816 688 817 float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt); 689 690 818 float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt); 691 float PhotAveFluxPSF (PhotCode *code, Average *average, SecFilt *secfilt); 692 float PhotAvedFluxPSF (PhotCode *code, Average *average, SecFilt *secfilt); 693 float PhotAveFluxKron (PhotCode *code, Average *average, SecFilt *secfilt); 694 float PhotAvedFluxKron (PhotCode *code, Average *average, SecFilt *secfilt); 695 696 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt); 697 float PhotM20 (PhotCode *code, Average *average, SecFilt *secfilt); 698 float PhotM80 (PhotCode *code, Average *average, SecFilt *secfilt); 819 820 int PhotNphot (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 821 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 822 float PhotMmin (PhotCode *code, Average *average, SecFilt *secfilt); 823 float PhotMmax (PhotCode *code, Average *average, SecFilt *secfilt); 699 824 float PhotUCdist (PhotCode *code, Average *average, SecFilt *secfilt); 700 825 unsigned int PhotStackID (PhotCode *code, Average *average, SecFilt *secfilt); … … 703 828 int PhotColor (Average *average, SecFilt *secfilt, Measure *measure, int c1, int c2, double *color); 704 829 705 float PhotInstTiny (MeasureTiny *measure);706 float PhotCatTiny (MeasureTiny *measure);707 float PhotAperTiny (MeasureTiny *measure);708 float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt);709 float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt);710 float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code);711 float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt);712 float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure);713 830 float PhotXmTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt); 714 831 float PhotdMTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt); … … 781 898 /*** conversion functions / I/O conversions ***/ 782 899 Average *ReadRawAverage (FILE *f, off_t Naverage, char format, SecFilt **primary); 783 Measure *ReadRawMeasure (FILE *f, off_t Nmeasure, char format);900 Measure *ReadRawMeasure (FILE *f, Average *average, off_t Nmeasure, char format); 784 901 SecFilt *ReadRawSecFilt (FILE *f, off_t Nsecfilt, char format); 785 902 int WriteRawAverage (FILE *f, Average *average, off_t Naverage, char format, SecFilt *primary); 786 int WriteRawMeasure (FILE *f, Measure *measure, off_t Nmeasure, char format);903 int WriteRawMeasure (FILE *f, Average *average, Measure *measure, off_t Nmeasure, char format); 787 904 int WriteRawSecFilt (FILE *f, SecFilt *secfilt, off_t Nsecfilt, char format); 788 905 … … 790 907 791 908 Average *FtableToAverage (FTable *ftable, off_t *Naverage, char *format, SecFilt **primary); 792 Measure *FtableToMeasure (FTable *ftable, off_t *Nmeasure, char *format);909 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, char *format); 793 910 SecFilt *FtableToSecFilt (FTable *ftable, off_t *Nsecfilt, char *format); 911 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, char *format); 912 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, char *format); 794 913 int FtableToImage (FTable *ftable, Header *theader, char *format); 795 914 796 915 int AverageToFtable (FTable *ftable, Average *average, off_t Naverage, char format, SecFilt *primary); 797 int MeasureToFtable (FTable *ftable, Measure *measure, off_t Nmeasure, char format);916 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, char format); 798 917 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, char format); 918 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, char format); 919 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, char format); 799 920 int ImageToFtable (FTable *ftable, Header *theader, char format); 800 921 int ImageToVtable (VTable *vtable, Header *theader, char format); … … 811 932 # include "ps1_v3_defs.h" 812 933 # include "ps1_v4_defs.h" 934 # include "ps1_v5_defs.h" 813 935 # include "ps1_ref_defs.h" 814 936 … … 905 1027 void TessellationTableInit (TessellationTable *tess, int Ntess); 906 1028 1029 float dvoOffsetR (Measure *measure, Average *average); 1030 float dvoOffsetD (Measure *measure, Average *average); 1031 double dvoMeanR (float dR, Average *average); 1032 double dvoMeanD (float dD, Average *average); 1033 907 1034 void dvo_average_init (Average *average); 908 1035 void dvo_averageT_init (AverageTiny *average); … … 910 1037 void dvo_measure_init (Measure *measure); 911 1038 void dvo_measureT_init (MeasureTiny *measure); 1039 1040 void dvo_lensing_init (Lensing *lensing); 1041 void dvo_lensobj_init (Lensobj *lensobj, int toZero); 912 1042 913 1043 void InitRegionHosts (RegionHostInfo *hosts, int Nhosts, int NHOSTS); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/dvodb.h
r36680 r37403 22 22 23 23 /* magnitude types */ 24 enum {MAG_NONE, 25 26 // these magnitude types are from the measurement table (or derived therein) 27 // the following imply PSF magnitudes: 28 MAG_INST, // -2.5*log(DN) [ie, not DN/sec] 29 MAG_CAT, // MAG_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1) 30 MAG_SYS, // MAG_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode] 31 MAG_REL, // MAG_SYS - Mcal [specific zero point for image] 32 MAG_CAL, // MAG_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode] 33 MAG_ERR, // error on PSF MAG 34 35 // the following imply APERTURE magnitudes: 36 MAG_APER_INST, // -2.5*log(DN) [ie, not DN/sec] 37 MAG_APER_CAT, // MAG_APER_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1) 38 MAG_APER_SYS, // MAG_APER_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode] 39 MAG_APER_REL, // MAG_APER_SYS - Mcal [specific zero point for image] 40 MAG_APER_CAL, // MAG_APER_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode] 41 MAG_APER_ERR, // error on APER MAG (if known, else psf error) 42 MAG_APER, // in mextract -> MAG_APER_REL, in avextract -> MAG_APER_AVE 43 44 // the following imply KRON magnitudes: 45 MAG_KRON_INST, // -2.5*log(DN) [ie, not DN/sec] 46 MAG_KRON_CAT, // MAG_KRON_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1) 47 MAG_KRON_SYS, // MAG_KRON_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode] 48 MAG_KRON_REL, // MAG_KRON_SYS - Mcal [specific zero point for image] 49 MAG_KRON_CAL, // MAG_KRON_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode] 50 MAG_KRON_ERR, // error on KRON MAG 51 MAG_KRON, // in mextract -> MAG_KRON_REL, in avextract -> MAG_KRON_AVE 52 53 // these magnitude types are from the average (secfilt) table: 54 // the following imply PSF magnitudes (or fluxes) 55 MAG_AVE, 56 MAG_REF, 57 MAG_STDEV, 58 MAG_AVE_ERR, 59 MAG_CHISQ, 60 MAG_20, 61 MAG_80, 62 MAG_FLUX_PSF, 63 MAG_FLUX_PSF_ERR, 64 65 // the following imply APERTURE magnitudes: 66 MAG_APER_AVE, 67 MAG_APER_REF, 68 69 // the following imply KRON magnitudes or fluxes: 70 MAG_KRON_AVE, 71 MAG_KRON_REF, 72 MAG_FLUX_KRON, 73 MAG_FLUX_KRON_ERR, 74 75 // other secfilt fields of interest 76 MAG_PHOT_FLAGS, 77 MAG_NCODE, 78 MAG_NPHOT, 79 MAG_UC_DIST, 80 MAG_STACK_DET_ID, 81 }; 24 25 typedef enum { 26 MAG_SRC_NONE, 27 MAG_SRC_CHP, 28 MAG_SRC_WRP, 29 MAG_SRC_STK, 30 } dvoMagSourceType; 31 32 typedef enum { 33 MAG_LEVEL_NONE, // -2.5*log(DN) [ie, not DN/sec] 34 MAG_LEVEL_INST, // -2.5*log(DN) [ie, not DN/sec] 35 MAG_LEVEL_CAT, // MAG_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1) 36 MAG_LEVEL_SYS, // MAG_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode] 37 MAG_LEVEL_REL, // MAG_SYS - Mcal [specific zero point for image] 38 MAG_LEVEL_CAL, // MAG_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode] 39 MAG_LEVEL_AVE, 40 MAG_LEVEL_REF, 41 } dvoMagLevelType; 42 43 typedef enum { 44 MAG_OPTION_NONE, 45 MAG_OPTION_MAG, 46 MAG_OPTION_ERR, 47 MAG_OPTION_FLUX, 48 MAG_OPTION_FLUX_ERR, 49 MAG_OPTION_STDEV, 50 MAG_OPTION_CHISQ, 51 MAG_OPTION_MIN, 52 MAG_OPTION_MAX, 53 MAG_OPTION_NCODE, 54 MAG_OPTION_NPHOT, // Nused 55 MAG_OPTION_UC_DIST, 56 MAG_OPTION_FLAGS, 57 } dvoMagOptionType; 58 59 // MAG_OPTION_STACK_PRIMARY_OFF, 60 // MAG_OPTION_STACK_BEST_OFF, 61 62 typedef enum { 63 MAG_CLASS_NONE, 64 MAG_CLASS_PSF, 65 MAG_CLASS_KRON, 66 MAG_CLASS_APER, 67 } dvoMagClassType; 82 68 83 69 /* measure fields */ … … 119 105 MEAS_OBJ_FLAGS, 120 106 MEAS_SECFILT_FLAGS, 121 MEAS_ MAG,107 MEAS_PHOT, // photometry class of measurements 122 108 MEAS_MINST, 123 109 MEAS_MCAT, … … 173 159 MEAS_EXTERN_ID, 174 160 MEAS_EXPNAME_AS_INT, 175 MEAS_MCAL_OFFSET, 161 MEAS_MCAL_OFFSET, // make this a dvoMagOption? 176 162 MEAS_FLAT, 177 163 MEAS_CENTER_OFFSET, 178 MEAS_FLUX_PSF, 179 MEAS_FLUX_PSF_ERR, 180 MEAS_FLUX_KRON, 181 MEAS_FLUX_KRON_ERR, 164 MEAS_REF_COLOR, 182 165 }; 183 166 … … 210 193 AVE_NMISS, 211 194 AVE_NPOS, 212 AVE_NPHOT,213 AVE_NCODE,214 AVE_MAG,215 AVE_dMAG,216 AVE_Xm,217 195 AVE_OBJ_FLAGS, 218 196 AVE_TYPE, … … 222 200 AVE_EXTID_HI, 223 201 AVE_EXTID_LO, 202 AVE_REF_COLOR, 203 AVE_PHOT, // photometry class of values 224 204 }; 205 206 // AVE_NPHOT, 207 // AVE_NCODE, 208 // AVE_MAG, 209 // AVE_dMAG, 210 // AVE_Xm, 225 211 226 212 enum {IMAGE_ZERO, … … 289 275 IMAGE_NFIT_ASTROM, 290 276 IMAGE_NLINK_PHOTOM, 291 IMAGE_NLINK_ASTROM 277 IMAGE_NLINK_ASTROM, 278 IMAGE_REF_COLOR 292 279 }; 293 280 … … 309 296 int table; 310 297 int ID; 311 int magMode; 298 299 dvoMagSourceType magSource; // chip, (forced) warp, stack [only relevant for averages] 300 dvoMagLevelType magLevel; // inst, cat, sys, rel, ave, ref, err, min, max, stdev, nphot, chisq, 301 dvoMagOptionType magOption; // psf, kron, aper 302 dvoMagClassType magClass; 303 312 304 char type; 313 305 PhotCode *photcode; … … 371 363 372 364 int GetMagMode PROTO((char *string)); 373 PhotCode *ParsePhotcodeField PROTO((char *field, int *mode, int def));365 int ParsePhotcodeField PROTO((dbField *field, char *fieldName, int fieldID)); 374 366 int ParseMeasureField PROTO((dbField *field, char *fieldName)); 375 367 int ParseAverageField PROTO((dbField *field, char *fieldName)); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/elixir_defs.h
r35162 r37403 3 3 Average *Average_Elixir_ToInternal (Average_Elixir *in, off_t Nvalues, SecFilt **primary); 4 4 Average_Elixir *AverageInternalTo_Elixir (Average *in, off_t Nvalues, SecFilt *primary); 5 Measure *Measure_Elixir_ToInternal ( Measure_Elixir *in, off_t Nvalues);6 Measure_Elixir *MeasureInternalTo_Elixir ( Measure *in, off_t Nvalues);5 Measure *Measure_Elixir_ToInternal (Average *ave, Measure_Elixir *in, off_t Nvalues); 6 Measure_Elixir *MeasureInternalTo_Elixir (Average *ave, Measure *in, off_t Nvalues); 7 7 SecFilt *SecFilt_Elixir_ToInternal (SecFilt_Elixir *in, off_t Nvalues); 8 8 SecFilt_Elixir *SecFiltInternalTo_Elixir (SecFilt *in, off_t Nvalues); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/loneos_defs.h
r35162 r37403 3 3 Average *Average_Loneos_ToInternal (Average_Loneos *in, off_t Nvalues, SecFilt **primary); 4 4 Average_Loneos *AverageInternalTo_Loneos (Average *in, off_t Nvalues, SecFilt *primary); 5 Measure *Measure_Loneos_ToInternal ( Measure_Loneos *in, off_t Nvalues);6 Measure_Loneos *MeasureInternalTo_Loneos ( Measure *in, off_t Nvalues);5 Measure *Measure_Loneos_ToInternal (Average *ave, Measure_Loneos *in, off_t Nvalues); 6 Measure_Loneos *MeasureInternalTo_Loneos (Average *ave, Measure *in, off_t Nvalues); 7 7 SecFilt *SecFilt_Loneos_ToInternal (SecFilt_Loneos *in, off_t Nvalues); 8 8 SecFilt_Loneos *SecFiltInternalTo_Loneos (SecFilt *in, off_t Nvalues); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/panstarrs_dev_0_defs.h
r35162 r37403 3 3 Average *Average_Panstarrs_DEV_0_ToInternal (Average_Panstarrs_DEV_0 *in, off_t Nvalues, SecFilt **primary); 4 4 Average_Panstarrs_DEV_0 *AverageInternalTo_Panstarrs_DEV_0 (Average *in, off_t Nvalues, SecFilt *primary); 5 Measure *Measure_Panstarrs_DEV_0_ToInternal ( Measure_Panstarrs_DEV_0 *in, off_t Nvalues);6 Measure_Panstarrs_DEV_0 *MeasureInternalTo_Panstarrs_DEV_0 ( Measure *in, off_t Nvalues);5 Measure *Measure_Panstarrs_DEV_0_ToInternal (Average *ave, Measure_Panstarrs_DEV_0 *in, off_t Nvalues); 6 Measure_Panstarrs_DEV_0 *MeasureInternalTo_Panstarrs_DEV_0 (Average *ave, Measure *in, off_t Nvalues); 7 7 SecFilt *SecFilt_Panstarrs_DEV_0_ToInternal (SecFilt_Panstarrs_DEV_0 *in, off_t Nvalues); 8 8 SecFilt_Panstarrs_DEV_0 *SecFiltInternalTo_Panstarrs_DEV_0 (SecFilt *in, off_t Nvalues); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/panstarrs_dev_1_defs.h
r35162 r37403 3 3 Average *Average_Panstarrs_DEV_1_ToInternal (Average_Panstarrs_DEV_1 *in, off_t Nvalues, SecFilt **primary); 4 4 Average_Panstarrs_DEV_1 *AverageInternalTo_Panstarrs_DEV_1 (Average *in, off_t Nvalues, SecFilt *primary); 5 Measure *Measure_Panstarrs_DEV_1_ToInternal ( Measure_Panstarrs_DEV_1 *in, off_t Nvalues);6 Measure_Panstarrs_DEV_1 *MeasureInternalTo_Panstarrs_DEV_1 ( Measure *in, off_t Nvalues);5 Measure *Measure_Panstarrs_DEV_1_ToInternal (Average *ave, Measure_Panstarrs_DEV_1 *in, off_t Nvalues); 6 Measure_Panstarrs_DEV_1 *MeasureInternalTo_Panstarrs_DEV_1 (Average *ave, Measure *in, off_t Nvalues); 7 7 SecFilt *SecFilt_Panstarrs_DEV_1_ToInternal (SecFilt_Panstarrs_DEV_1 *in, off_t Nvalues); 8 8 SecFilt_Panstarrs_DEV_1 *SecFiltInternalTo_Panstarrs_DEV_1 (SecFilt *in, off_t Nvalues); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/ps1_dev_1_defs.h
r35162 r37403 3 3 Average *Average_PS1_DEV_1_ToInternal (Average_PS1_DEV_1 *in, off_t Nvalues, SecFilt **primary); 4 4 Average_PS1_DEV_1 *AverageInternalTo_PS1_DEV_1 (Average *in, off_t Nvalues, SecFilt *primary); 5 Measure *Measure_PS1_DEV_1_ToInternal ( Measure_PS1_DEV_1 *in, off_t Nvalues);6 Measure_PS1_DEV_1 *MeasureInternalTo_PS1_DEV_1 ( Measure *in, off_t Nvalues);5 Measure *Measure_PS1_DEV_1_ToInternal (Average *ave, Measure_PS1_DEV_1 *in, off_t Nvalues); 6 Measure_PS1_DEV_1 *MeasureInternalTo_PS1_DEV_1 (Average *ave, Measure *in, off_t Nvalues); 7 7 SecFilt *SecFilt_PS1_DEV_1_ToInternal (SecFilt_PS1_DEV_1 *in, off_t Nvalues); 8 8 SecFilt_PS1_DEV_1 *SecFiltInternalTo_PS1_DEV_1 (SecFilt *in, off_t Nvalues); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/ps1_dev_2_defs.h
r35162 r37403 3 3 Average *Average_PS1_DEV_2_ToInternal (Average_PS1_DEV_2 *in, off_t Nvalues, SecFilt **primary); 4 4 Average_PS1_DEV_2 *AverageInternalTo_PS1_DEV_2 (Average *in, off_t Nvalues, SecFilt *primary); 5 Measure *Measure_PS1_DEV_2_ToInternal ( Measure_PS1_DEV_2 *in, off_t Nvalues);6 Measure_PS1_DEV_2 *MeasureInternalTo_PS1_DEV_2 ( Measure *in, off_t Nvalues);5 Measure *Measure_PS1_DEV_2_ToInternal (Average *ave, Measure_PS1_DEV_2 *in, off_t Nvalues); 6 Measure_PS1_DEV_2 *MeasureInternalTo_PS1_DEV_2 (Average *ave, Measure *in, off_t Nvalues); 7 7 SecFilt *SecFilt_PS1_DEV_2_ToInternal (SecFilt_PS1_DEV_2 *in, off_t Nvalues); 8 8 SecFilt_PS1_DEV_2 *SecFiltInternalTo_PS1_DEV_2 (SecFilt *in, off_t Nvalues); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/ps1_ref_defs.h
r35162 r37403 3 3 Average *Average_PS1_REF_ToInternal (Average_PS1_REF *in, off_t Nvalues, SecFilt **primary); 4 4 Average_PS1_REF *AverageInternalTo_PS1_REF (Average *in, off_t Nvalues, SecFilt *primary); 5 Measure *Measure_PS1_REF_ToInternal ( Measure_PS1_REF *in, off_t Nvalues);6 Measure_PS1_REF *MeasureInternalTo_PS1_REF ( Measure *in, off_t Nvalues);5 Measure *Measure_PS1_REF_ToInternal (Average *ave, Measure_PS1_REF *in, off_t Nvalues); 6 Measure_PS1_REF *MeasureInternalTo_PS1_REF (Average *ave, Measure *in, off_t Nvalues); 7 7 SecFilt *SecFilt_PS1_REF_ToInternal (SecFilt_PS1_REF *in, off_t Nvalues); 8 8 SecFilt_PS1_REF *SecFiltInternalTo_PS1_REF (SecFilt *in, off_t Nvalues); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/ps1_v1_defs.h
r35162 r37403 3 3 Average *Average_PS1_V1_ToInternal (Average_PS1_V1 *in, off_t Nvalues, SecFilt **primary); 4 4 Average_PS1_V1 *AverageInternalTo_PS1_V1 (Average *in, off_t Nvalues, SecFilt *primary); 5 Measure *Measure_PS1_V1_ToInternal ( Measure_PS1_V1 *in, off_t Nvalues);6 Measure_PS1_V1 *MeasureInternalTo_PS1_V1 ( Measure *in, off_t Nvalues);5 Measure *Measure_PS1_V1_ToInternal (Average *ave, Measure_PS1_V1 *in, off_t Nvalues); 6 Measure_PS1_V1 *MeasureInternalTo_PS1_V1 (Average *ave, Measure *in, off_t Nvalues); 7 7 SecFilt *SecFilt_PS1_V1_ToInternal (SecFilt_PS1_V1 *in, off_t Nvalues); 8 8 SecFilt_PS1_V1 *SecFiltInternalTo_PS1_V1 (SecFilt *in, off_t Nvalues); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/ps1_v2_defs.h
r35162 r37403 3 3 Average *Average_PS1_V2_ToInternal (Average_PS1_V2 *in, off_t Nvalues, SecFilt **primary); 4 4 Average_PS1_V2 *AverageInternalTo_PS1_V2 (Average *in, off_t Nvalues, SecFilt *primary); 5 Measure *Measure_PS1_V2_ToInternal ( Measure_PS1_V2 *in, off_t Nvalues);6 Measure_PS1_V2 *MeasureInternalTo_PS1_V2 ( Measure *in, off_t Nvalues);5 Measure *Measure_PS1_V2_ToInternal (Average *ave, Measure_PS1_V2 *in, off_t Nvalues); 6 Measure_PS1_V2 *MeasureInternalTo_PS1_V2 (Average *ave, Measure *in, off_t Nvalues); 7 7 SecFilt *SecFilt_PS1_V2_ToInternal (SecFilt_PS1_V2 *in, off_t Nvalues); 8 8 SecFilt_PS1_V2 *SecFiltInternalTo_PS1_V2 (SecFilt *in, off_t Nvalues); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/ps1_v3_defs.h
r35162 r37403 3 3 Average *Average_PS1_V3_ToInternal (Average_PS1_V3 *in, off_t Nvalues, SecFilt **primary); 4 4 Average_PS1_V3 *AverageInternalTo_PS1_V3 (Average *in, off_t Nvalues, SecFilt *primary); 5 Measure *Measure_PS1_V3_ToInternal ( Measure_PS1_V3 *in, off_t Nvalues);6 Measure_PS1_V3 *MeasureInternalTo_PS1_V3 ( Measure *in, off_t Nvalues);5 Measure *Measure_PS1_V3_ToInternal (Average *ave, Measure_PS1_V3 *in, off_t Nvalues); 6 Measure_PS1_V3 *MeasureInternalTo_PS1_V3 (Average *ave, Measure *in, off_t Nvalues); 7 7 SecFilt *SecFilt_PS1_V3_ToInternal (SecFilt_PS1_V3 *in, off_t Nvalues); 8 8 SecFilt_PS1_V3 *SecFiltInternalTo_PS1_V3 (SecFilt *in, off_t Nvalues); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/ps1_v4_defs.h
r35162 r37403 3 3 Average *Average_PS1_V4_ToInternal (Average_PS1_V4 *in, off_t Nvalues, SecFilt **primary); 4 4 Average_PS1_V4 *AverageInternalTo_PS1_V4 (Average *in, off_t Nvalues, SecFilt *primary); 5 Measure *Measure_PS1_V4_ToInternal ( Measure_PS1_V4 *in, off_t Nvalues);6 Measure_PS1_V4 *MeasureInternalTo_PS1_V4 ( Measure *in, off_t Nvalues);5 Measure *Measure_PS1_V4_ToInternal (Average *ave, Measure_PS1_V4 *in, off_t Nvalues); 6 Measure_PS1_V4 *MeasureInternalTo_PS1_V4 (Average *ave, Measure *in, off_t Nvalues); 7 7 SecFilt *SecFilt_PS1_V4_ToInternal (SecFilt_PS1_V4 *in, off_t Nvalues); 8 8 SecFilt_PS1_V4 *SecFiltInternalTo_PS1_V4 (SecFilt *in, off_t Nvalues); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/BoundaryTree.c
r36680 r37403 84 84 gfits_scan (headerPHU, "DEC_ORI", "%lf", 1, &tree->DEC_origin); 85 85 gfits_scan (headerPHU, "DEC_OFF", "%lf", 1, &tree->DEC_offset); 86 gfits_scan (headerPHU, "NX_SUB", "% d", 1, &tree->NX_SUB);87 gfits_scan (headerPHU, "NY_SUB", "% d", 1, &tree->NY_SUB);86 gfits_scan (headerPHU, "NX_SUB", "%f", 1, &tree->NX_SUB); 87 gfits_scan (headerPHU, "NY_SUB", "%f", 1, &tree->NY_SUB); 88 88 gfits_scan (headerPHU, "PIXSCALE", "%lf", 1, &tree->dPix); 89 89 … … 111 111 ALLOCATE (tree->Xo, double *, tree->Nzone); 112 112 ALLOCATE (tree->Yo, double *, tree->Nzone); 113 ALLOCATE (tree->dX, int *, tree->Nzone);114 ALLOCATE (tree->dY, int *, tree->Nzone);113 ALLOCATE (tree->dX, float *, tree->Nzone); 114 ALLOCATE (tree->dY, float *, tree->Nzone); 115 115 ALLOCATE (tree->cell, int *, tree->Nzone); 116 116 ALLOCATE (tree->projID, int *, tree->Nzone); … … 121 121 ALLOCATE (tree->Xo[i], double, tree->Nband[i]); 122 122 ALLOCATE (tree->Yo[i], double, tree->Nband[i]); 123 ALLOCATE (tree->dX[i], int, tree->Nband[i]);124 ALLOCATE (tree->dY[i], int, tree->Nband[i]);123 ALLOCATE (tree->dX[i], float, tree->Nband[i]); 124 ALLOCATE (tree->dY[i], float, tree->Nband[i]); 125 125 ALLOCATE (tree->cell[i], int, tree->Nband[i]); 126 126 ALLOCATE (tree->projID[i], int, tree->Nband[i]); … … 147 147 GET_COLUMN_NEW(&headerCell, &ftableCell, Xo, "X_CENT", double); 148 148 GET_COLUMN_NEW(&headerCell, &ftableCell, Yo, "Y_CENT", double); 149 GET_COLUMN_NEW(&headerCell, &ftableCell, dX, "X_GRID", int);150 GET_COLUMN_NEW(&headerCell, &ftableCell, dY, "Y_GRID", int);149 GET_COLUMN_NEW(&headerCell, &ftableCell, dX, "X_GRID", float); 150 GET_COLUMN_NEW(&headerCell, &ftableCell, dY, "Y_GRID", float); 151 151 GET_COLUMN_NEW(&headerCell, &ftableCell, name, "NAME", char); // XXX how is this done? 152 152 gfits_free_header (&headerCell); … … 214 214 gfits_modify (&header, "DEC_OFF", "%lf", 1, tree->DEC_offset); 215 215 216 gfits_modify (&header, "NX_SUB", "% d", 1, tree->NX_SUB);217 gfits_modify (&header, "NY_SUB", "% d", 1, tree->NY_SUB);216 gfits_modify (&header, "NX_SUB", "%f", 1, tree->NX_SUB); 217 gfits_modify (&header, "NY_SUB", "%f", 1, tree->NY_SUB); 218 218 gfits_modify (&header, "PIXSCALE", "%lf", 1, tree->dPix); 219 219 … … 289 289 gfits_define_bintable_column (&theader, "D", "X_CENT", "projection cell center pixel", "none", 1.0, 0.0); 290 290 gfits_define_bintable_column (&theader, "D", "Y_CENT", "projection cell center pixel", "none", 1.0, 0.0); 291 gfits_define_bintable_column (&theader, " J", "X_GRID", "skycell grid spacing", "none", 1.0, 0.0);292 gfits_define_bintable_column (&theader, " J", "Y_GRID", "skycell grid spacing", "none", 1.0, 0.0);291 gfits_define_bintable_column (&theader, "E", "X_GRID", "skycell grid spacing", "none", 1.0, 0.0); 292 gfits_define_bintable_column (&theader, "E", "Y_GRID", "skycell grid spacing", "none", 1.0, 0.0); 293 293 gfits_define_bintable_column (&theader, fmt, "NAME", "cell name", "none", 1.0, 0.0); 294 294 … … 310 310 double *Xo ; ALLOCATE (Xo, double, Ncell); 311 311 double *Yo ; ALLOCATE (Yo, double, Ncell); 312 int *dX ; ALLOCATE (dX, int,Ncell);313 int *dY ; ALLOCATE (dY, int,Ncell);312 float *dX ; ALLOCATE (dX, float, Ncell); 313 float *dY ; ALLOCATE (dY, float, Ncell); 314 314 char *name ; ALLOCATE (name, char, Ncell*BOUNDARY_TREE_NAME_LENGTH); 315 315 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/ImageMetadata.c
r35416 r37403 124 124 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_SUBSET"); 125 125 126 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image ID", NULL, 1.0, 1.0*0x8000);127 gfits_define_bintable_column (&theader, "J", "EXTERN_ID", "extern ID", NULL, 1.0, 1.0*0x8000);128 gfits_define_bintable_column (&theader, "J", "EXPNAME_AS_INT", "expname as integer", NULL, 1.0, 1.0*0x8000);129 gfits_define_bintable_column (&theader, "D", "CRVAL1", "ra at center", "degrees",1.0, 0.0);130 gfits_define_bintable_column (&theader, "D", "CRVAL2", "dec at center", "degrees",1.0, 0.0);131 gfits_define_bintable_column (&theader, "E", "THETA", "camera rot angle", "degrees",1.0, 0.0);132 gfits_define_bintable_column (&theader, "E", "MCAL", "zero point offset","magnitudes", 1.0, 0.0);133 gfits_define_bintable_column (&theader, "E", "SECZ", "airmass", "none",1.0, 0.0);134 gfits_define_bintable_column (&theader, "E", "X_CENTER", "chip center", "none",1.0, 0.0);135 gfits_define_bintable_column (&theader, "E", "Y_CENTER", "chip center", "none",1.0, 0.0);126 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image ID", NULL, 1.0, FT_BZERO_INT32); 127 gfits_define_bintable_column (&theader, "J", "EXTERN_ID", "extern ID", NULL, 1.0, FT_BZERO_INT32); 128 gfits_define_bintable_column (&theader, "J", "EXPNAME_AS_INT", "expname as integer", NULL, 1.0, FT_BZERO_INT32); 129 gfits_define_bintable_column (&theader, "D", "CRVAL1", "ra at center", "degrees", 1.0, 0.0); 130 gfits_define_bintable_column (&theader, "D", "CRVAL2", "dec at center", "degrees", 1.0, 0.0); 131 gfits_define_bintable_column (&theader, "E", "THETA", "camera rot angle", "degrees", 1.0, 0.0); 132 gfits_define_bintable_column (&theader, "E", "MCAL", "zero point offset", "magnitudes", 1.0, 0.0); 133 gfits_define_bintable_column (&theader, "E", "SECZ", "airmass", "none", 1.0, 0.0); 134 gfits_define_bintable_column (&theader, "E", "X_CENTER", "chip center", "none", 1.0, 0.0); 135 gfits_define_bintable_column (&theader, "E", "Y_CENTER", "chip center", "none", 1.0, 0.0); 136 136 137 137 // generate the output array that carries the data -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/LoadPhotcodesFITS.c
r35755 r37403 64 64 CONVERT_FORMAT("DVO_PHOTCODE_PS1_V3", PS1_V3); 65 65 CONVERT_FORMAT("DVO_PHOTCODE_PS1_V4", PS1_V4); 66 CONVERT_FORMAT("DVO_PHOTCODE_PS1_V5", PS1_V5); 66 67 67 68 table = GetPhotcodeTable (); … … 100 101 // photcode.equiv of 0 means "undefined" 101 102 for (i = 0; i < Ncode; i++) { 103 if (!strcasecmp(photcode[i].name, "MAG")) { 104 fprintf (stderr, "MAG is not an allowed photcode name (reserved to DVO internals)\n"); 105 free (photcode); 106 return FALSE; 107 } 108 if (!strcasecmp(photcode[i].name, "FLUX")) { 109 fprintf (stderr, "FLUX is not an allowed photcode name (reserved to DVO internals)\n"); 110 free (photcode); 111 return FALSE; 112 } 113 102 114 if (photcode[i].type == PHOT_DEP) { 103 115 if (photcode[i].equiv == 0) continue; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/LoadPhotcodesText.c
r28833 r37403 108 108 } 109 109 110 if (!strcasecmp(name, "MAG")) { 111 fprintf (stderr, "MAG is not an allowed photcode name (reserved to DVO internals)\n"); 112 return FALSE; 113 } 114 110 115 photcode[Ncode].type = 0; 111 116 memset(photcode[Ncode].dummy, 0, sizeof(photcode[Ncode].dummy)); … … 137 142 photcode[Ncode].photomErrSys = atof (photomErrSys); 138 143 139 photcode[Ncode].astromPoorMask = strtol (astromPoorMask, NULL, 0);140 photcode[Ncode].astromBadMask = strtol (astromBadMask, NULL, 0);141 photcode[Ncode].photomPoorMask = strtol (photomPoorMask, NULL, 0);142 photcode[Ncode].photomBadMask = strtol (photomBadMask, NULL, 0);144 photcode[Ncode].astromPoorMask = strtoll (astromPoorMask, NULL, 0); 145 photcode[Ncode].astromBadMask = strtoll (astromBadMask, NULL, 0); 146 photcode[Ncode].photomPoorMask = strtoll (photomPoorMask, NULL, 0); 147 photcode[Ncode].photomBadMask = strtoll (photomBadMask, NULL, 0); 143 148 144 149 switch (photcode[Ncode].type) { -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/SavePhotcodesFITS.c
r34260 r37403 30 30 // for the moment, we simply support the latest photcode format for output 31 31 // XXX update this as needed as new formats are defined 32 PhotCode_PS1_V 4 *photcode_output = PhotCode_Internal_To_PS1_V4(table[0].code, table[0].Ncode);32 PhotCode_PS1_V5 *photcode_output = PhotCode_Internal_To_PS1_V5 (table[0].code, table[0].Ncode); 33 33 34 34 /* convert FITS format data to internal format (byteswaps & EXTNAME) */ 35 35 if (!gfits_db_create (&db)) return (FALSE); 36 if (!gfits_table_set_PhotCode_PS1_V 4(&db.ftable, photcode_output, table[0].Ncode)) return (FALSE);36 if (!gfits_table_set_PhotCode_PS1_V5 (&db.ftable, photcode_output, table[0].Ncode)) return (FALSE); 37 37 if (!gfits_db_save (&db)) return (FALSE); 38 38 if (!gfits_db_close (&db)) return (FALSE); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/TessellationTable.c
r36680 r37403 28 28 tess[i].dPix = NAN; 29 29 30 tess[i].dX = 0;31 tess[i].dY = 0;32 33 tess[i].NX_SUB = 0;34 tess[i].NY_SUB = 0;30 tess[i].dX = NAN; 31 tess[i].dY = NAN; 32 33 tess[i].NX_SUB = NAN; 34 tess[i].NY_SUB = NAN; 35 35 36 36 tess[i].basename = NULL; … … 123 123 GET_COLUMN_NEW(Xo, "X_CENT", double); 124 124 GET_COLUMN_NEW(Yo, "Y_CENT", double); 125 GET_COLUMN_NEW(dX, "X_GRID", int);126 GET_COLUMN_NEW(dY, "Y_GRID", int);125 GET_COLUMN_NEW(dX, "X_GRID", float); 126 GET_COLUMN_NEW(dY, "Y_GRID", float); 127 127 GET_COLUMN_NEW(Rmin, "R_MIN", double); 128 128 GET_COLUMN_NEW(Rmax, "R_MAX", double); … … 130 130 GET_COLUMN_NEW(Dmax, "D_MAX", double); 131 131 GET_COLUMN_NEW(dPix, "SCALE", double); 132 GET_COLUMN_NEW(NX_SUB, "NX_SUB", int);133 GET_COLUMN_NEW(NY_SUB, "NY_SUB", int);132 GET_COLUMN_NEW(NX_SUB, "NX_SUB", float); 133 GET_COLUMN_NEW(NY_SUB, "NY_SUB", float); 134 134 GET_COLUMN_NEW(TYPE, "TYPE", int); 135 135 … … 280 280 gfits_modify (&header, "DEC_OFF", "%lf", 1, rings->DEC_offset); 281 281 282 gfits_modify (&header, "NX_SUB", "% d", 1, rings->NX_SUB);283 gfits_modify (&header, "NY_SUB", "% d", 1, rings->NY_SUB);282 gfits_modify (&header, "NX_SUB", "%f", 1, rings->NX_SUB); 283 gfits_modify (&header, "NY_SUB", "%f", 1, rings->NY_SUB); 284 284 gfits_modify (&header, "PIXSCALE", "%lf", 1, rings->dPix); 285 285 } … … 300 300 gfits_define_bintable_column (&theader, "D", "X_CENT", "projection cell center pixel", "none", 1.0, 0.0); 301 301 gfits_define_bintable_column (&theader, "D", "Y_CENT", "projection cell center pixel", "none", 1.0, 0.0); 302 gfits_define_bintable_column (&theader, " J", "X_GRID", "skycell grid spacing", "none", 1.0, 0.0);303 gfits_define_bintable_column (&theader, " J", "Y_GRID", "skycell grid spacing", "none", 1.0, 0.0);302 gfits_define_bintable_column (&theader, "E", "X_GRID", "skycell grid spacing", "none", 1.0, 0.0); 303 gfits_define_bintable_column (&theader, "E", "Y_GRID", "skycell grid spacing", "none", 1.0, 0.0); 304 304 gfits_define_bintable_column (&theader, "D", "R_MIN", "RA limit (lower)", "none", 1.0, 0.0); 305 305 gfits_define_bintable_column (&theader, "D", "R_MAX", "RA limit (upper)", "none", 1.0, 0.0); … … 307 307 gfits_define_bintable_column (&theader, "D", "D_MAX", "DEC limit (upper)", "none", 1.0, 0.0); 308 308 gfits_define_bintable_column (&theader, "D", "SCALE", "pixel scale for projection cell", "none", 1.0, 0.0); 309 gfits_define_bintable_column (&theader, " J", "NX_SUB", "skycell subdivision in x", "none", 1.0, 0.0);310 gfits_define_bintable_column (&theader, " J", "NY_SUB", "skycell subdivision in y", "none", 1.0, 0.0);309 gfits_define_bintable_column (&theader, "E", "NX_SUB", "skycell subdivision in x", "none", 1.0, 0.0); 310 gfits_define_bintable_column (&theader, "E", "NY_SUB", "skycell subdivision in y", "none", 1.0, 0.0); 311 311 gfits_define_bintable_column (&theader, "J", "TYPE", "type of tessellation", "none", 1.0, 0.0); 312 312 … … 330 330 double *Xo ; ALLOCATE (Xo , double, Nout); 331 331 double *Yo ; ALLOCATE (Yo , double, Nout); 332 int *dX ; ALLOCATE (dX , int,Nout);333 int *dY ; ALLOCATE (dY , int,Nout);332 float *dX ; ALLOCATE (dX , float, Nout); 333 float *dY ; ALLOCATE (dY , float, Nout); 334 334 double *Rmin ; ALLOCATE (Rmin , double, Nout); 335 335 double *Rmax ; ALLOCATE (Rmax , double, Nout); … … 337 337 double *Dmax ; ALLOCATE (Dmax , double, Nout); 338 338 double *dPix ; ALLOCATE (dPix , double, Nout); 339 int *NX_SUB ; ALLOCATE (NX_SUB, int,Nout);340 int *NY_SUB ; ALLOCATE (NY_SUB, int,Nout);339 float *NX_SUB ; ALLOCATE (NX_SUB, float, Nout); 340 float *NY_SUB ; ALLOCATE (NY_SUB, float, Nout); 341 341 int *TYPE ; ALLOCATE (TYPE, int, Nout); 342 342 … … 559 559 int xi = x / tess[myTess].tree->dX[zone][band]; 560 560 int yi = y / tess[myTess].tree->dY[zone][band]; 561 562 xi = MAX(MIN(xi, tess[myTess].tree->NX_SUB - 1.0), 0); 563 yi = MAX(MIN(yi, tess[myTess].tree->NY_SUB - 1.0), 0); 564 561 565 int N = xi + tess[myTess].tree->NX_SUB * yi; 562 566 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/cmf-ps1-dv3.c
r35416 r37403 2 2 3 3 /*** note : this file is derived from the autocode version, but is modified because 4 the forma does not match with structure byte boundaries ***/4 the format does not match with structure byte boundaries ***/ 5 5 6 6 /* if we are not correctly including the ohana headers, this will fail */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dbExtractAverages.c
r36680 r37403 52 52 dbValue dbExtractAverages (Average *average, SecFilt *secfilt, Measure *measure, dbField *field) { 53 53 54 off_t i; 55 int Nsec; 54 // off_t i; 56 55 dbValue value; 57 56 … … 162 161 value.Flt = average[0].stargal; 163 162 break; 163 case AVE_REF_COLOR: 164 value.Flt = average[0].refColorBlue; 165 break; 164 166 165 167 case AVE_OBJ_FLAGS: … … 179 181 break; 180 182 181 case AVE_MAG: 182 switch (field->magMode) { 183 case MAG_AVE: 184 value.Flt = PhotAve (field->photcode, average, secfilt); 185 break; 186 case MAG_REF: 187 value.Flt = PhotRef (field->photcode, average, secfilt, measure); 188 break; 189 case MAG_INST: 190 case MAG_CAT: 191 case MAG_SYS: 192 case MAG_REL: 193 case MAG_CAL: 194 // XXX need to code this correctly: this returns just the first matching value 195 value.Flt = NAN; 183 case AVE_PHOT: 184 // if we request mag:ave, use equiv for photcode (ie a given measure, say GPC1.g.XY01, will return g for mag:ave) 185 if (field->photcode->type == PHOT_MAG) { 186 // this is an error 187 break; 188 } 189 190 // if we ask for 2MASS_K, etc (REF values), return NAN unless measure->code matches 191 if (field->photcode->type == PHOT_REF) { 192 // need to ensure measure exists. 193 break; 194 } 195 196 // if we ask for GPC1.g.XY03:rel, etc (DEP values), return NAN unless measure->code matches 197 if (field->photcode->type == PHOT_DEP) { 198 // again. 199 break; 200 } 201 202 /* in some cases below we need a measurement which matches the requested photcode. 203 here is some sample code to find this. 204 196 205 for (i = 0; i < average[0].Nmeasure; i++) { 197 206 if (field->photcode->code != measure[i].photcode) continue; … … 199 208 break; 200 209 } 201 break; 202 case MAG_CHISQ: 210 */ 211 212 switch (field->magOption) { 213 case MAG_OPTION_MAG: 214 switch (field->magLevel) { 215 case MAG_LEVEL_AVE: 216 value.Flt = PhotAve (field->photcode, average, secfilt, field->magClass, field->magSource); 217 break; 218 case MAG_LEVEL_REF: 219 // which measure is needed here? 220 // PhotRef (field->photcode, average, secfilt, measure, field->magClass, field->magSource); 221 break; 222 case MAG_LEVEL_INST: 223 case MAG_LEVEL_CAT: 224 case MAG_LEVEL_SYS: 225 case MAG_LEVEL_REL: 226 case MAG_LEVEL_CAL: 227 case MAG_LEVEL_NONE: 228 break; 229 } 230 break; 231 232 case MAG_OPTION_ERR: 233 switch (field->magLevel) { 234 case MAG_LEVEL_AVE: 235 case MAG_LEVEL_REF: 236 value.Flt = PhotAveErr (field->photcode, average, secfilt, field->magClass, field->magSource); 237 break; 238 case MAG_LEVEL_INST: 239 case MAG_LEVEL_CAT: 240 case MAG_LEVEL_SYS: 241 case MAG_LEVEL_REL: 242 case MAG_LEVEL_CAL: 243 case MAG_LEVEL_NONE: 244 break; 245 } 246 break; 247 248 case MAG_OPTION_FLUX: 249 switch (field->magLevel) { 250 case MAG_LEVEL_AVE: 251 value.Flt = PhotFluxAve (field->photcode, average, secfilt, field->magClass, field->magSource); 252 break; 253 case MAG_LEVEL_REF: 254 // XXX which measure is needed here? 255 // value.Flt = PhotFluxRef (field->photcode, average, secfilt, measure, field->magClass, field->magSource); 256 break; 257 case MAG_LEVEL_INST: 258 case MAG_LEVEL_CAT: 259 case MAG_LEVEL_SYS: 260 case MAG_LEVEL_REL: 261 case MAG_LEVEL_CAL: 262 case MAG_LEVEL_NONE: 263 break; 264 } 265 break; 266 267 case MAG_OPTION_FLUX_ERR: 268 switch (field->magLevel) { 269 case MAG_LEVEL_AVE: 270 case MAG_LEVEL_REF: 271 value.Flt = PhotFluxAveErr (field->photcode, average, secfilt, field->magClass, field->magSource); 272 break; 273 case MAG_LEVEL_INST: 274 case MAG_LEVEL_CAT: 275 case MAG_LEVEL_SYS: 276 case MAG_LEVEL_REL: 277 case MAG_LEVEL_CAL: 278 case MAG_LEVEL_NONE: 279 break; 280 } 281 break; 282 283 case MAG_OPTION_STDEV: 284 value.Flt = PhotMstdev (field->photcode, average, secfilt, field->magClass, field->magSource); 285 break; 286 case MAG_OPTION_CHISQ: 203 287 value.Flt = PhotXm (field->photcode, average, secfilt); 204 288 break; 205 case MAG_ERR: 206 if ((field->photcode->type == PHOT_REF) || (field->photcode->type == PHOT_DEP)) { 207 for (i = 0; i < average[0].Nmeasure; i++) { 208 if (field->photcode->code != measure[i].photcode) continue; 209 value.Flt = measure[i].dM; 210 break; 211 } 212 } else { 213 value.Flt = PhotAveErr (field->photcode, average, secfilt); 214 } 215 break; 216 case MAG_STDEV: 217 value.Flt = PhotMstdev (field->photcode, average, secfilt); 218 break; 219 case MAG_PHOT_FLAGS: 220 if ((field->photcode->type == PHOT_REF) || (field->photcode->type == PHOT_DEP)) { 221 for (i = 0; i < average[0].Nmeasure; i++) { 222 if (field->photcode->code != measure[i].photcode) continue; 223 value.Int = measure[i].photFlags; 224 break; 225 } 226 } else { 227 Nsec = GetPhotcodeNsec (field->photcode->code); 228 if (Nsec == -1) break; 229 value.Int = secfilt[Nsec].flags; 230 } 231 break; 232 case MAG_NCODE: 233 // XXX push these into dvo_photcode_ops APIs 234 // XXX do I need to allow for conversion to equiv? 235 Nsec = GetPhotcodeNsec (field->photcode->code); 289 case MAG_OPTION_MIN: 290 value.Flt = PhotMmin (field->photcode, average, secfilt); 291 break; 292 case MAG_OPTION_MAX: 293 value.Flt = PhotMmax (field->photcode, average, secfilt); 294 break; 295 case MAG_OPTION_NCODE: { 296 int Nsec = GetPhotcodeNsec (field->photcode->code); 236 297 if (Nsec == -1) break; 237 298 value.Int = secfilt[Nsec].Ncode; 238 299 break; 239 case MAG_NPHOT: 240 Nsec = GetPhotcodeNsec (field->photcode->code); 300 } 301 case MAG_OPTION_NPHOT: { 302 value.Int = PhotNphot (field->photcode, average, secfilt, field->magClass, field->magSource); 303 break; 304 } 305 case MAG_OPTION_UC_DIST: 306 value.Flt = PhotUCdist (field->photcode, average, secfilt); 307 break; 308 // XX case MAG_OPTION_STACK_DET_ID: 309 // XX value.Int = PhotStackID (field->photcode, average, secfilt); 310 // XX break; 311 case MAG_OPTION_FLAGS: { 312 int Nsec = GetPhotcodeNsec (field->photcode->code); 241 313 if (Nsec == -1) break; 242 value.Int = secfilt[Nsec].Nused; 243 break; 244 245 case MAG_APER: 246 case MAG_APER_AVE: 247 value.Flt = PhotAperAve (field->photcode, average, secfilt); 248 break; 249 250 case MAG_APER_REF: 251 value.Flt = PhotAperRef (field->photcode, average, secfilt, measure); 252 break; 253 254 case MAG_KRON: 255 case MAG_KRON_AVE: 256 value.Flt = PhotKronAve (field->photcode, average, secfilt); 257 break; 258 259 case MAG_KRON_REF: 260 value.Flt = PhotKronRef (field->photcode, average, secfilt, measure); 261 break; 262 263 case MAG_KRON_ERR: 264 value.Flt = PhotKronAveErr (field->photcode, average, secfilt); 265 break; 266 267 case MAG_20: 268 value.Flt = PhotM20 (field->photcode, average, secfilt); 269 break; 270 case MAG_80: 271 value.Flt = PhotM80 (field->photcode, average, secfilt); 272 break; 273 case MAG_UC_DIST: 274 value.Flt = PhotUCdist (field->photcode, average, secfilt); 275 break; 276 case MAG_STACK_DET_ID: 277 value.Int = PhotStackID (field->photcode, average, secfilt); 278 break; 279 280 case MAG_FLUX_PSF: 281 value.Flt = PhotAveFluxPSF (field->photcode, average, secfilt); 282 break; 283 case MAG_FLUX_PSF_ERR: 284 value.Flt = PhotAvedFluxPSF (field->photcode, average, secfilt); 285 break; 286 case MAG_FLUX_KRON: 287 value.Flt = PhotAveFluxKron (field->photcode, average, secfilt); 288 break; 289 case MAG_FLUX_KRON_ERR: 290 value.Flt = PhotAvedFluxKron (field->photcode, average, secfilt); 291 break; 292 } 293 break; 294 case AVE_dMAG: 295 value.Flt = PhotAveErr (field->photcode, average, secfilt); 296 break; 297 case AVE_Xm: 298 value.Flt = PhotXm (field->photcode, average, secfilt); 299 break; 314 value.Int = secfilt[Nsec].flags; 315 break; 316 } 317 case MAG_OPTION_NONE: 318 break; 319 } 320 break; 321 300 322 case AVE_TYPE: 301 323 break; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dbExtractImages.c
r35102 r37403 69 69 if (!haveCelestial) { 70 70 if (!FindMosaicForImage (image, Nimage, N)) return value; 71 x = 0.5*image[N].NX; 72 y = 0.5*image[N].NY; 71 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 72 x = 0.0; 73 y = 0.0; 74 } else { 75 x = 0.5*image[N].NX; 76 y = 0.5*image[N].NY; 77 } 73 78 XY_to_RD (&RAo, &DECo, x, y, &image[N].coords); 74 79 haveCelestial = TRUE; … … 79 84 if (!haveCelestial) { 80 85 if (!FindMosaicForImage (image, Nimage, N)) return value; 81 x = 0.5*image[N].NX; 82 y = 0.5*image[N].NY; 86 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 87 x = 0.0; 88 y = 0.0; 89 } else { 90 x = 0.5*image[N].NX; 91 y = 0.5*image[N].NY; 92 } 83 93 XY_to_RD (&RAo, &DECo, x, y, &image[N].coords); 84 94 haveCelestial = TRUE; … … 90 100 if (!haveCelestial) { 91 101 if (!FindMosaicForImage (image, Nimage, N)) return value; 92 x = 0.5*image[N].NX; 93 y = 0.5*image[N].NY; 102 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 103 x = 0.0; 104 y = 0.0; 105 } else { 106 x = 0.5*image[N].NX; 107 y = 0.5*image[N].NY; 108 } 94 109 XY_to_RD (&RAo, &DECo, x, y, &image[N].coords); 95 110 haveCelestial = TRUE; … … 104 119 if (!haveCelestial) { 105 120 if (!FindMosaicForImage (image, Nimage, N)) return value; 106 x = 0.5*image[N].NX; 107 y = 0.5*image[N].NY; 121 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 122 x = 0.0; 123 y = 0.0; 124 } else { 125 x = 0.5*image[N].NX; 126 y = 0.5*image[N].NY; 127 } 108 128 XY_to_RD (&RAo, &DECo, x, y, &image[N].coords); 109 129 haveCelestial = TRUE; … … 118 138 if (!haveCelestial) { 119 139 if (!FindMosaicForImage (image, Nimage, N)) return value; 120 x = 0.5*image[N].NX; 121 y = 0.5*image[N].NY; 140 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 141 x = 0.0; 142 y = 0.0; 143 } else { 144 x = 0.5*image[N].NX; 145 y = 0.5*image[N].NY; 146 } 122 147 XY_to_RD (&RAo, &DECo, x, y, &image[N].coords); 123 148 haveCelestial = TRUE; … … 132 157 if (!haveCelestial) { 133 158 if (!FindMosaicForImage (image, Nimage, N)) return value; 134 x = 0.5*image[N].NX; 135 y = 0.5*image[N].NY; 159 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 160 x = 0.0; 161 y = 0.0; 162 } else { 163 x = 0.5*image[N].NX; 164 y = 0.5*image[N].NY; 165 } 136 166 XY_to_RD (&RAo, &DECo, x, y, &image[N].coords); 137 167 haveCelestial = TRUE; … … 344 374 value.Int = image[N].nLinkAstrom; 345 375 break; 376 377 case IMAGE_REF_COLOR: 378 value.Flt = image[N].refColorBlue; 379 break; 346 380 } 347 381 return (value); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dbExtractMeasures.c
r36680 r37403 90 90 dbValue value; 91 91 double dT; 92 float dR, dD; 92 93 93 94 Coords *mosaic, *fieldc; … … 99 100 100 101 switch (field->ID) { 101 case MEAS_ MAG: { /* magnitudes are already determined above */102 case MEAS_PHOT: { /* magnitudes are already determined above */ 102 103 PhotCode *myEquiv = GetPhotcodeEquivbyCode (measure[0].photcode); 103 104 104 // if we request mag:ave, use equiv for photcode 105 // if we request mag:ave, use equiv for photcode (ie a given measure, say GPC1.g.XY01, will return g for mag:ave) 105 106 if (field->photcode->type == PHOT_MAG) { 106 107 equiv = myEquiv; … … 116 117 // if we ask for g:ave, or other SEC-level values, return the corresponding field 117 118 if (field->photcode->type == PHOT_SEC) { 118 switch (field->mag Mode) {119 switch (field->magLevel) { 119 120 // measure-like : return non-NAN if measure.equiv.photcode matches field.photcode 120 case MAG_INST: 121 case MAG_CAT: 122 case MAG_SYS: 123 case MAG_REL: 124 case MAG_CAL: 125 case MAG_ERR: 126 127 case MAG_APER_INST: 128 case MAG_APER_CAT: 129 case MAG_APER_SYS: 130 case MAG_APER_REL: 131 case MAG_APER_CAL: 132 case MAG_APER_ERR: 133 134 case MAG_KRON_INST: 135 case MAG_KRON_CAT: 136 case MAG_KRON_SYS: 137 case MAG_KRON_REL: 138 case MAG_KRON_CAL: 139 case MAG_KRON_ERR: 140 141 case MAG_PHOT_FLAGS: 121 case MAG_LEVEL_INST: 122 case MAG_LEVEL_CAT: 123 case MAG_LEVEL_SYS: 124 case MAG_LEVEL_REL: 125 case MAG_LEVEL_CAL: 142 126 equiv = myEquiv; 143 127 if (equiv && (equiv->code == field->photcode->code)) goto valid_photcode; … … 145 129 146 130 // mean-like : return value for the given photcode 147 case MAG_AVE: 148 case MAG_REF: 149 case MAG_STDEV: 150 case MAG_AVE_ERR: 151 case MAG_CHISQ: 152 case MAG_FLUX_PSF: 153 case MAG_FLUX_PSF_ERR: 154 155 case MAG_APER_AVE: 156 157 case MAG_KRON_AVE: 158 case MAG_FLUX_KRON: 159 case MAG_FLUX_KRON_ERR: 160 161 case MAG_20: 162 case MAG_80: 163 case MAG_UC_DIST: 164 case MAG_STACK_DET_ID: 165 166 case MAG_NCODE: 167 case MAG_NPHOT: 131 case MAG_LEVEL_AVE: 132 case MAG_LEVEL_REF: 168 133 equiv = field->photcode; 169 134 goto valid_photcode; … … 177 142 178 143 valid_photcode: 179 switch (field->magMode) { 180 case MAG_INST: 181 value.Flt = PhotInst (measure); 182 break; 183 case MAG_CAT: 184 value.Flt = PhotCat (measure); 185 break; 186 case MAG_SYS: 187 value.Flt = PhotSys (measure, average, secfilt); 188 break; 189 case MAG_REL: 190 value.Flt = PhotRel (measure, average, secfilt); 191 break; 192 case MAG_CAL: 193 value.Flt = PhotCal (measure, average, secfilt, measure, equiv); 194 break; 195 case MAG_AVE: 196 value.Flt = PhotAve (equiv, average, secfilt); 197 break; 198 case MAG_REF: 199 value.Flt = PhotRef (equiv, average, secfilt, measure); 200 break; 201 case MAG_ERR: 202 value.Flt = measure[0].dM; 203 break; 204 case MAG_AVE_ERR: 205 value.Flt = PhotAveErr (equiv, average, secfilt); 206 break; 207 208 case MAG_APER_INST: 209 value.Flt = PhotAperInst (measure); 210 break; 211 case MAG_APER_CAT: 212 value.Flt = PhotAperCat (measure); 213 break; 214 case MAG_APER_SYS: 215 value.Flt = PhotAperSys (measure, average, secfilt); 216 break; 217 case MAG_APER: 218 case MAG_APER_REL: 219 value.Flt = PhotAperRel (measure, average, secfilt); 220 break; 221 case MAG_APER_CAL: 222 value.Flt = PhotAperCal (measure, average, secfilt, measure, equiv); 223 break; 224 case MAG_APER_AVE: 225 value.Flt = PhotAperAve (equiv, average, secfilt); 226 break; 227 case MAG_APER_REF: 228 value.Flt = PhotAperRef (equiv, average, secfilt, measure); 229 break; 230 case MAG_APER_ERR: 231 value.Flt = measure[0].dM; 232 break; 233 234 case MAG_KRON_INST: 235 value.Flt = PhotKronInst (measure); 236 break; 237 case MAG_KRON_CAT: 238 value.Flt = PhotKronCat (measure); 239 break; 240 case MAG_KRON_SYS: 241 value.Flt = PhotKronSys (measure, average, secfilt); 242 break; 243 case MAG_KRON: 244 case MAG_KRON_REL: 245 value.Flt = PhotKronRel (measure, average, secfilt); 246 break; 247 case MAG_KRON_CAL: 248 value.Flt = PhotKronCal (measure, average, secfilt, measure, equiv); 249 break; 250 case MAG_KRON_AVE: 251 value.Flt = PhotKronAve (equiv, average, secfilt); 252 break; 253 case MAG_KRON_REF: 254 value.Flt = PhotKronRef (equiv, average, secfilt, measure); 255 break; 256 case MAG_KRON_ERR: 257 value.Flt = measure[0].dMkron; 258 break; 259 260 case MAG_PHOT_FLAGS: 261 if ((field->photcode->type == PHOT_REF) || (field->photcode->type == PHOT_DEP)) { 262 value.Int = measure[0].photFlags; 144 switch (field->magOption) { 145 case MAG_OPTION_MAG: 146 switch (field->magLevel) { 147 case MAG_LEVEL_INST: 148 value.Flt = PhotInst (measure, field->magClass); 149 break; 150 case MAG_LEVEL_CAT: 151 value.Flt = PhotCat (measure, field->magClass); 152 break; 153 case MAG_LEVEL_SYS: 154 value.Flt = PhotSys (measure, average, secfilt, field->magClass); 155 break; 156 case MAG_LEVEL_REL: 157 value.Flt = PhotRel (measure, average, secfilt, field->magClass); 158 break; 159 case MAG_LEVEL_CAL: 160 value.Flt = PhotCal (measure, average, secfilt, measure, equiv, field->magClass); 161 break; 162 case MAG_LEVEL_AVE: 163 value.Flt = PhotAve (equiv, average, secfilt, field->magClass, field->magSource); 164 break; 165 case MAG_LEVEL_REF: 166 value.Flt = PhotRef (equiv, average, secfilt, measure, field->magClass, field->magSource); 167 break; 168 case MAG_LEVEL_NONE: 169 break; 263 170 } 264 171 break; 265 172 266 case MAG_NCODE: 267 if (equiv == NULL) break; 268 Nsec = GetPhotcodeNsec (equiv->code); 269 if (Nsec == -1) break; 270 value.Int = secfilt[Nsec].Ncode; 173 case MAG_OPTION_ERR: 174 switch (field->magLevel) { 175 case MAG_LEVEL_INST: 176 case MAG_LEVEL_CAT: 177 case MAG_LEVEL_SYS: 178 case MAG_LEVEL_REL: 179 value.Flt = PhotErr (measure, field->magClass); 180 break; 181 case MAG_LEVEL_CAL: 182 value.Flt = PhotCalErr (measure, field->magClass); 183 break; 184 case MAG_LEVEL_AVE: 185 case MAG_LEVEL_REF: 186 value.Flt = PhotAveErr (equiv, average, secfilt, field->magClass, field->magSource); 187 break; 188 case MAG_LEVEL_NONE: 189 break; 190 } 271 191 break; 272 case MAG_NPHOT: 273 if (equiv == NULL) break; 274 Nsec = GetPhotcodeNsec (equiv->code); 275 if (Nsec == -1) break; 276 value.Int = secfilt[Nsec].Nused; 192 193 case MAG_OPTION_FLUX: 194 switch (field->magLevel) { 195 case MAG_LEVEL_INST: 196 value.Flt = PhotFluxInst (measure, field->magClass); 197 break; 198 case MAG_LEVEL_CAT: 199 value.Flt = PhotFluxCat (measure, field->magClass); 200 break; 201 case MAG_LEVEL_SYS: 202 value.Flt = PhotFluxSys (measure, average, secfilt, field->magClass); 203 break; 204 case MAG_LEVEL_REL: 205 value.Flt = PhotFluxRel (measure, average, secfilt, field->magClass); 206 break; 207 case MAG_LEVEL_CAL: 208 value.Flt = PhotFluxCal (measure, average, secfilt, measure, equiv, field->magClass); 209 break; 210 case MAG_LEVEL_AVE: 211 value.Flt = PhotFluxAve (equiv, average, secfilt, field->magClass, field->magSource); 212 break; 213 case MAG_LEVEL_REF: 214 value.Flt = PhotFluxRef (equiv, average, secfilt, measure, field->magClass, field->magSource); 215 break; 216 case MAG_LEVEL_NONE: 217 break; 218 } 277 219 break; 278 220 279 case MAG_CHISQ: 280 value.Flt = PhotXm (equiv, average, secfilt); 221 case MAG_OPTION_FLUX_ERR: 222 switch (field->magLevel) { 223 case MAG_LEVEL_INST: 224 value.Flt = PhotFluxInstErr (measure, field->magClass); 225 break; 226 case MAG_LEVEL_CAT: 227 value.Flt = PhotFluxCatErr (measure, field->magClass); 228 break; 229 case MAG_LEVEL_SYS: 230 case MAG_LEVEL_REL: 231 case MAG_LEVEL_CAL: 232 // value.Flt = PhotFluxErr (measure, field->magClass); 233 break; 234 case MAG_LEVEL_AVE: 235 case MAG_LEVEL_REF: 236 // value.Flt = PhotFluxAveErr (equiv, average, secfilt, field->magClass, field->magSource); 237 break; 238 case MAG_LEVEL_NONE: 239 break; 240 } 281 241 break; 282 case MAG_STDEV: 283 value.Flt = PhotMstdev (equiv, average, secfilt); 284 break; 285 case MAG_20: 286 value.Flt = PhotM20 (equiv, average, secfilt); 287 break; 288 case MAG_80: 289 value.Flt = PhotM80 (equiv, average, secfilt); 290 break; 291 case MAG_UC_DIST: 292 value.Flt = PhotUCdist (equiv, average, secfilt); 293 break; 294 295 case MAG_FLUX_PSF: 296 value.Flt = PhotAveFluxPSF (field->photcode, average, secfilt); 297 break; 298 case MAG_FLUX_PSF_ERR: 299 value.Flt = PhotAvedFluxPSF (field->photcode, average, secfilt); 300 break; 301 case MAG_FLUX_KRON: 302 value.Flt = PhotAveFluxKron (field->photcode, average, secfilt); 303 break; 304 case MAG_FLUX_KRON_ERR: 305 value.Flt = PhotAvedFluxKron (field->photcode, average, secfilt); 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: 251 case MAG_OPTION_NONE: 306 252 break; 307 253 } … … 309 255 } 310 256 case MEAS_RA: /* OK */ 311 value.Flt = average[0].R - measure[0].dR / 3600.0;257 value.Flt = measure[0].R; 312 258 break; 313 259 case MEAS_DEC: /* OK */ 314 value.Flt = average[0].D - measure[0].dD / 3600.0;260 value.Flt = measure[0].D; 315 261 break; 316 262 case MEAS_RA_AVE: /* OK */ … … 323 269 case MEAS_GLON: 324 270 if (!haveGalacticMeas) { 325 ApplyTransform (&GLON_MEAS, &GLAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_galactic);271 ApplyTransform (&GLON_MEAS, &GLAT_MEAS, measure[0].R, measure[0].D, celestial_to_galactic); 326 272 haveGalacticMeas = TRUE; 327 273 } … … 330 276 case MEAS_GLAT: 331 277 if (!haveGalacticMeas) { 332 ApplyTransform (&GLON_MEAS, &GLAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_galactic);278 ApplyTransform (&GLON_MEAS, &GLAT_MEAS, measure[0].R, measure[0].D, celestial_to_galactic); 333 279 haveGalacticMeas = TRUE; 334 280 } … … 337 283 case MEAS_ELON: 338 284 if (!haveEclipticMeas) { 339 ApplyTransform (&ELON_MEAS, &ELAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_ecliptic);285 ApplyTransform (&ELON_MEAS, &ELAT_MEAS, measure[0].R, measure[0].D, celestial_to_ecliptic); 340 286 haveEclipticMeas = TRUE; 341 287 } … … 344 290 case MEAS_ELAT: 345 291 if (!haveEclipticMeas) { 346 ApplyTransform (&ELON_MEAS, &ELAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_ecliptic);292 ApplyTransform (&ELON_MEAS, &ELAT_MEAS, measure[0].R, measure[0].D, celestial_to_ecliptic); 347 293 haveEclipticMeas = TRUE; 348 294 } … … 441 387 // the error. 442 388 case MEAS_RA_OFFSET: /* OK */ 443 value.Flt = measure[0].dR;389 value.Flt = dvoOffsetR (measure, average); 444 390 break; 445 391 case MEAS_DEC_OFFSET: /* OK */ 446 value.Flt = measure[0].dD;392 value.Flt = dvoOffsetD (measure, average); 447 393 break; 448 394 case MEAS_RA_FIT_OFFSET: /* OK */ 449 395 dT = (measure[0].t - average[0].Tmean) / (86400*365.25); 450 value.Flt = average[0].uR * dT + measure[0].dR; 396 dR = dvoOffsetR (measure, average); 397 value.Flt = average[0].uR * dT + dR; 451 398 break; 452 399 case MEAS_DEC_FIT_OFFSET: /* OK */ 453 400 dT = (measure[0].t - average[0].Tmean) / (86400*365.25); 454 value.Flt = average[0].uD * dT + measure[0].dD; 401 dD = dvoOffsetD (measure, average); 402 value.Flt = average[0].uD * dT + dD; 455 403 break; 456 404 case MEAS_RA_OFFSET_ERR: /* OK */ … … 524 472 case MEAS_PLATESCALE: /* OK */ 525 473 value.Flt = measure[0].pltscale; 474 break; 475 476 case MEAS_REF_COLOR: 477 value.Flt = average[0].refColorBlue; 526 478 break; 527 479 … … 552 504 // measure.xccd if we need it 553 505 Image *image; 554 ra = average[0].R - measure[0].dR / 3600.0;555 dec = average[0].D - measure[0].dD / 3600.0;506 ra = measure[0].R; 507 dec = measure[0].D; 556 508 image = MatchImageDVO (measure[0].t, measure[0].photcode, measure[0].imageID); 557 509 if (image == NULL) break; … … 567 519 { 568 520 Image *image; 569 ra = average[0].R - measure[0].dR / 3600.0;570 dec = average[0].D - measure[0].dD / 3600.0;521 ra = measure[0].R; 522 dec = measure[0].D; 571 523 image = MatchImageDVO (measure[0].t, measure[0].photcode, measure[0].imageID); 572 524 if (image == NULL) break; … … 603 555 } 604 556 if (fieldc == NULL) break; 605 double Rm = average[0].R - measure[0].dR / 3600.0;606 double Dm = average[0].D - measure[0].dD / 3600.0;557 double Rm = measure[0].R; 558 double Dm = measure[0].D; 607 559 RD_to_XY (&XFIELD_MEAS, &YFIELD_MEAS, Rm, Dm, fieldc); 608 560 } … … 620 572 } 621 573 if (fieldc == NULL) break; 622 double Rm = average[0].R - measure[0].dR / 3600.0;623 double Dm = average[0].D - measure[0].dD / 3600.0;574 double Rm = measure[0].R; 575 double Dm = measure[0].D; 624 576 RD_to_XY (&XFIELD_MEAS, &YFIELD_MEAS, Rm, Dm, fieldc); 625 577 } … … 638 590 } 639 591 if (mosaic == NULL) break; 640 double Rm = average[0].R - measure[0].dR / 3600.0;641 double Dm = average[0].D - measure[0].dD / 3600.0;592 double Rm = measure[0].R; 593 double Dm = measure[0].D; 642 594 RD_to_XY (&XMOS_MEAS, &YMOS_MEAS, Rm, Dm, mosaic); 643 595 } … … 655 607 } 656 608 if (mosaic == NULL) break; 657 double Rm = average[0].R - measure[0].dR / 3600.0;658 double Dm = average[0].D - measure[0].dD / 3600.0;609 double Rm = measure[0].R; 610 double Dm = measure[0].D; 659 611 RD_to_XY (&XMOS_MEAS, &YMOS_MEAS, Rm, Dm, mosaic); 660 612 } … … 694 646 case MEAS_PSF_NPIX: /* OK */ 695 647 value.Int = measure[0].psfNpix; 696 break;697 case MEAS_CR_NSIGMA: /* OK */698 value.Flt = measure[0].crNsigma;699 648 break; 700 649 case MEAS_EXT_NSIGMA: /* OK */ … … 769 718 break; 770 719 771 case MEAS_FLUX_PSF: /* OK */772 value.Flt = measure[0].FluxPSF;773 break;774 case MEAS_FLUX_PSF_ERR: /* OK */775 value.Flt = measure[0].dFluxPSF;776 break;777 case MEAS_FLUX_KRON: /* OK */778 value.Flt = measure[0].FluxKron;779 break;780 case MEAS_FLUX_KRON_ERR: /* OK */781 value.Flt = measure[0].dFluxKron;782 break;720 // case MEAS_FLUX_PSF: /* OK */ 721 // value.Flt = measure[0].FluxPSF; 722 // break; 723 // case MEAS_FLUX_PSF_ERR: /* OK */ 724 // value.Flt = measure[0].dFluxPSF; 725 // break; 726 // case MEAS_FLUX_KRON: /* OK */ 727 // value.Flt = measure[0].FluxKron; 728 // break; 729 // case MEAS_FLUX_KRON_ERR: /* OK */ 730 // value.Flt = measure[0].dFluxKron; 731 // break; 783 732 } 784 733 return (value); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dbFields.c
r36680 r37403 9 9 for (i = 0; i < Nfields; i++) { 10 10 if (fields[i].name != NULL) free (fields[i].name); 11 if (fields[i].photcode != NULL) {12 if (fields[i].photcode[0].type == PHOT_MAG) {13 free (fields[i].photcode);14 }15 }16 11 } 17 12 free (fields); … … 24 19 field->ID = 0; 25 20 field->type = OPIHI_FLT; 26 field->magMode = 0; 21 22 field->magSource = MAG_SRC_NONE; 23 field->magLevel = MAG_LEVEL_NONE; 24 field->magClass = MAG_CLASS_NONE; 25 field->magOption = MAG_OPTION_NONE; 26 27 27 field->photcode = NULL; 28 28 } 29 29 30 dvoMagSourceType GetMagSource (char *string) { 31 32 if (!strcasecmp (string, "chip")) return (MAG_SRC_CHP); 33 if (!strcasecmp (string, "warp")) return (MAG_SRC_WRP); 34 if (!strcasecmp (string, "stack")) return (MAG_SRC_STK); 35 36 if (!strcasecmp (string, "chp")) return (MAG_SRC_CHP); 37 if (!strcasecmp (string, "wrp")) return (MAG_SRC_WRP); 38 if (!strcasecmp (string, "stk")) return (MAG_SRC_STK); 39 40 return MAG_SRC_NONE; 41 } 42 43 dvoMagLevelType GetMagLevel (char *string) { 44 45 if (!strcasecmp (string, "inst")) return (MAG_LEVEL_INST); 46 if (!strcasecmp (string, "cat")) return (MAG_LEVEL_CAT); 47 if (!strcasecmp (string, "sys")) return (MAG_LEVEL_SYS); 48 if (!strcasecmp (string, "rel")) return (MAG_LEVEL_REL); 49 if (!strcasecmp (string, "cal")) return (MAG_LEVEL_CAL); 50 if (!strcasecmp (string, "ave")) return (MAG_LEVEL_AVE); 51 if (!strcasecmp (string, "ref")) return (MAG_LEVEL_REF); 52 53 return MAG_LEVEL_NONE; 54 } 55 56 dvoMagClassType GetMagClass (char *string) { 57 58 if (!strcasecmp (string, "psf")) return (MAG_CLASS_PSF); 59 if (!strcasecmp (string, "kron")) return (MAG_CLASS_KRON); 60 if (!strcasecmp (string, "aper")) return (MAG_CLASS_APER); 61 if (!strcasecmp (string, "ap")) return (MAG_CLASS_APER); 62 63 return MAG_CLASS_NONE; 64 } 65 66 dvoMagOptionType GetMagOption (char *string) { 67 68 if (!strcasecmp (string, "mag")) return (MAG_OPTION_MAG); 69 if (!strcasecmp (string, "err")) return (MAG_OPTION_ERR); 70 if (!strcasecmp (string, "magerr")) return (MAG_OPTION_ERR); 71 if (!strcasecmp (string, "flux")) return (MAG_OPTION_FLUX); 72 if (!strcasecmp (string, "fluxerr")) return (MAG_OPTION_FLUX_ERR); 73 if (!strcasecmp (string, "stdev")) return (MAG_OPTION_STDEV); 74 if (!strcasecmp (string, "chisq")) return (MAG_OPTION_CHISQ); 75 if (!strcasecmp (string, "min")) return (MAG_OPTION_MIN); 76 if (!strcasecmp (string, "max")) return (MAG_OPTION_MAX); 77 if (!strcasecmp (string, "ncode")) return (MAG_OPTION_NCODE); 78 if (!strcasecmp (string, "nphot")) return (MAG_OPTION_NPHOT); 79 if (!strcasecmp (string, "uc_dist")) return (MAG_OPTION_UC_DIST); 80 if (!strcasecmp (string, "flags")) return (MAG_OPTION_FLAGS); 81 82 return MAG_OPTION_NONE; 83 } 84 85 # if (0) 30 86 int GetMagMode (char *string) { 31 87 … … 85 141 if (!strcasecmp (string, "nphot")) return (MAG_NPHOT); 86 142 if (!strcasecmp (string, "stdev")) return (MAG_STDEV); 87 if (!strcasecmp (string, " 20")) return (MAG_20);88 if (!strcasecmp (string, " 80")) return (MAG_80);143 if (!strcasecmp (string, "min")) return (MAG_MIN); 144 if (!strcasecmp (string, "max")) return (MAG_MAX); 89 145 if (!strcasecmp (string, "ucdist")) return (MAG_UC_DIST); 90 if (!strcasecmp (string, "stackDetectID")) return (MAG_STACK_DET_ID);91 146 if (!strcasecmp (string, "fluxpsf")) return (MAG_FLUX_PSF); 92 147 if (!strcasecmp (string, "fluxpsferr")) return (MAG_FLUX_PSF_ERR); … … 95 150 return (MAG_NONE); 96 151 } 97 98 PhotCode *ParsePhotcodeField (char *field, int *mode, int defMode) { 99 100 int useDefault; 101 char *tmpstring, *p; 102 PhotCode *code; 103 104 *mode = defMode; 105 useDefault = TRUE; 106 107 p = strchr (field, ':'); 108 if (p != NULL) { 109 *mode = GetMagMode (p + 1); 110 useDefault = FALSE; 111 if (*mode == MAG_NONE) return (NULL); 112 tmpstring = strncreate (field, p - field); 113 } else { 114 tmpstring = strcreate (field); 115 } 116 if (!strcasecmp (tmpstring, "MAG")) { 117 ALLOCATE (code, PhotCode, 1); 118 code[0].code = 0; 119 strcpy (code[0].name, "MAG"); 120 code[0].type = PHOT_MAG; 121 // the field call 'mag' is only valid for mextract 122 // it should default to REL, but other types should default to AVE 123 if (useDefault) { 124 *mode = MAG_REL; 152 # endif 153 154 // field may be of the form mag:psf:inst:wrp. except for the first subword, 155 // the words may be in any order 156 int ParsePhotcodeField (dbField *field, char *fieldName, int fieldID) { 157 158 int j; 159 160 // defaults: 161 field->ID = fieldID; // change if not true in the end? 162 163 // check what options are provided. do not allow duplicate types 164 // except mag and flux may exist with err 165 dvoMagSourceType mySource = MAG_SRC_NONE; 166 dvoMagLevelType myLevel = MAG_LEVEL_NONE; 167 dvoMagClassType myClass = MAG_CLASS_NONE; 168 dvoMagOptionType myOption = MAG_OPTION_NONE; 169 170 field->magSource = MAG_SRC_CHP; 171 field->magLevel = MAG_LEVEL_AVE; 172 field->magClass = MAG_CLASS_PSF; 173 field->magOption = MAG_OPTION_MAG; 174 175 // make a local working copy of fieldName and replace ':' with spaces 176 char *fieldCopy = strcreate(fieldName); 177 for (j = 0; fieldCopy[j]; j++) { 178 if (fieldCopy[j] == ':') fieldCopy[j] = ' '; 179 } 180 181 char *firstWord = getword(fieldCopy); 182 183 // firstWord may be either flux, mag or photcode 184 if (!strcasecmp (firstWord, "MAG")) { 185 // default level for 'mag' is rel 186 field->magLevel = MAG_LEVEL_REL; 187 myOption = MAG_OPTION_MAG; 188 } 189 if (!strcasecmp (firstWord, "FLUX")) { 190 // default level for 'flux' is rel 191 field->magLevel = MAG_LEVEL_REL; 192 myOption = MAG_OPTION_FLUX; 193 } 194 PhotCode *code = GetPhotcodebyName (firstWord); 195 free (firstWord); 196 197 if (!code) return FALSE; 198 199 // defaults for photcode clases 200 if (code->type == PHOT_DEP) { 201 field->magLevel = MAG_LEVEL_REL; 202 } 203 if (code->type == PHOT_SEC) { 204 field->magLevel = MAG_LEVEL_AVE; 205 } 206 if (code->type == PHOT_REF) { 207 field->magLevel = MAG_LEVEL_CAT; 208 // is this one required? 209 } 210 211 // look at the remaining words and assign properties as approrpiate 212 char *ptr = skipword(fieldCopy); 213 while (ptr) { 214 215 char *word = getword(ptr); 216 if (!word) break; 217 218 dvoMagSourceType source = GetMagSource (word); 219 if (source != MAG_SRC_NONE) { 220 if (mySource != MAG_SRC_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 221 mySource = source; 222 ptr = skipword (ptr); 223 continue; 125 224 } 126 free (tmpstring); 127 return (code); 128 } 129 code = GetPhotcodebyName (tmpstring); 130 if (!code) { 131 return NULL; 132 } 133 134 // enforce compatibility 135 if (useDefault) { 136 if (code[0].type == PHOT_REF) { 137 *mode = MAG_CAT; 225 226 dvoMagLevelType level = GetMagLevel (word); 227 if (level != MAG_LEVEL_NONE) { 228 if (myLevel != MAG_LEVEL_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 229 myLevel = level; 230 ptr = skipword (ptr); 231 continue; 138 232 } 139 if (code[0].type == PHOT_DEP) { 140 *mode = MAG_REL; 233 234 dvoMagClassType class = GetMagClass (word); 235 if (class != MAG_CLASS_NONE) { 236 if (myClass != MAG_CLASS_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 237 myClass = class; 238 ptr = skipword (ptr); 239 continue; 141 240 } 142 } 143 free (tmpstring); 144 return (code); 145 } 146 147 # define ESCAPE(F,M,T) { \ 148 field->ID = (F); \ 149 field->magMode = (M); \ 150 field->type = (T); \ 151 field->photcode = NULL; \ 152 return (TRUE); } 153 154 int ParseMeasureField (dbField *field, char *fieldName) { 155 156 int mode; 157 PhotCode *code; 158 159 field->table = DVO_TABLE_MEASURE; 160 field->name = strcreate (fieldName); 161 162 if (!strcasecmp (fieldName, "GLON")) { 163 dbExtractMeasuresInitTransform (COORD_GALACTIC); 164 ESCAPE (MEAS_GLON, MAG_NONE, OPIHI_FLT); 165 } 166 if (!strcasecmp (fieldName, "GLAT")) { 167 dbExtractMeasuresInitTransform (COORD_GALACTIC); 168 ESCAPE (MEAS_GLAT, MAG_NONE, OPIHI_FLT); 169 } 170 if (!strcasecmp (fieldName, "GLON:AVE")) { 171 dbExtractMeasuresInitTransform (COORD_GALACTIC); 172 ESCAPE (MEAS_GLON_AVE, MAG_NONE, OPIHI_FLT); 173 } 174 if (!strcasecmp (fieldName, "GLAT:AVE")) { 175 dbExtractMeasuresInitTransform (COORD_GALACTIC); 176 ESCAPE (MEAS_GLAT_AVE, MAG_NONE, OPIHI_FLT); 177 } 178 179 if (!strcasecmp (fieldName, "ELON")) { 180 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 181 ESCAPE (MEAS_ELON, MAG_NONE, OPIHI_FLT); 182 } 183 if (!strcasecmp (fieldName, "ELAT")) { 184 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 185 ESCAPE (MEAS_ELAT, MAG_NONE, OPIHI_FLT); 186 } 187 if (!strcasecmp (fieldName, "ELON:AVE")) { 188 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 189 ESCAPE (MEAS_ELON_AVE, MAG_NONE, OPIHI_FLT); 190 } 191 if (!strcasecmp (fieldName, "ELAT:AVE")) { 192 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 193 ESCAPE (MEAS_ELAT_AVE, MAG_NONE, OPIHI_FLT); 194 } 195 196 if (!strcasecmp (fieldName, "RA")) ESCAPE (MEAS_RA, MAG_NONE, OPIHI_FLT); 197 if (!strcasecmp (fieldName, "DEC")) ESCAPE (MEAS_DEC, MAG_NONE, OPIHI_FLT); 198 if (!strcasecmp (fieldName, "RA:AVE")) ESCAPE (MEAS_RA_AVE, MAG_NONE, OPIHI_FLT); 199 if (!strcasecmp (fieldName, "DEC:AVE")) ESCAPE (MEAS_DEC_AVE, MAG_NONE, OPIHI_FLT); 200 if (!strcasecmp (fieldName, "RA:ERR")) ESCAPE (MEAS_RA_AVE_ERR, MAG_NONE, OPIHI_FLT); 201 if (!strcasecmp (fieldName, "DEC:ERR")) ESCAPE (MEAS_DEC_AVE_ERR, MAG_NONE, OPIHI_FLT); 202 if (!strcasecmp (fieldName, "uRA")) ESCAPE (MEAS_U_RA, MAG_NONE, OPIHI_FLT); 203 if (!strcasecmp (fieldName, "uDEC")) ESCAPE (MEAS_U_DEC, MAG_NONE, OPIHI_FLT); 204 if (!strcasecmp (fieldName, "duRA")) ESCAPE (MEAS_U_RA_ERR, MAG_NONE, OPIHI_FLT); 205 if (!strcasecmp (fieldName, "duDEC")) ESCAPE (MEAS_U_DEC_ERR, MAG_NONE, OPIHI_FLT); 206 if (!strcasecmp (fieldName, "PAR")) ESCAPE (MEAS_PAR, MAG_NONE, OPIHI_FLT); 207 if (!strcasecmp (fieldName, "dPAR")) ESCAPE (MEAS_PAR_ERR, MAG_NONE, OPIHI_FLT); 208 if (!strcasecmp (fieldName, "dR")) ESCAPE (MEAS_RA_OFFSET, MAG_NONE, OPIHI_FLT); 209 if (!strcasecmp (fieldName, "dD")) ESCAPE (MEAS_DEC_OFFSET, MAG_NONE, OPIHI_FLT); 210 if (!strcasecmp (fieldName, "dR:FIT")) ESCAPE (MEAS_RA_FIT_OFFSET, MAG_NONE, OPIHI_FLT); 211 if (!strcasecmp (fieldName, "dD:FIT")) ESCAPE (MEAS_DEC_FIT_OFFSET, MAG_NONE, OPIHI_FLT); 212 if (!strcasecmp (fieldName, "dR:ERR")) ESCAPE (MEAS_RA_OFFSET_ERR, MAG_NONE, OPIHI_FLT); 213 if (!strcasecmp (fieldName, "dD:ERR")) ESCAPE (MEAS_DEC_OFFSET_ERR, MAG_NONE, OPIHI_FLT); 214 if (!strcasecmp (fieldName, "ChiSqPos")) ESCAPE (MEAS_CHISQ_POS, MAG_NONE, OPIHI_FLT); 215 if (!strcasecmp (fieldName, "ChiSqPM")) ESCAPE (MEAS_CHISQ_PM, MAG_NONE, OPIHI_FLT); 216 if (!strcasecmp (fieldName, "ChiSqPar")) ESCAPE (MEAS_CHISQ_PAR, MAG_NONE, OPIHI_FLT); 217 if (!strcasecmp (fieldName, "Tmean")) ESCAPE (MEAS_TMEAN, MAG_NONE, OPIHI_FLT); 218 if (!strcasecmp (fieldName, "Trange")) ESCAPE (MEAS_TRANGE, MAG_NONE, OPIHI_FLT); 219 if (!strcasecmp (fieldName, "nmeas")) ESCAPE (MEAS_NMEAS, MAG_NONE, OPIHI_INT); 220 if (!strcasecmp (fieldName, "nmiss")) ESCAPE (MEAS_NMISS, MAG_NONE, OPIHI_INT); 221 if (!strcasecmp (fieldName, "npos")) ESCAPE (MEAS_NPOS, MAG_NONE, OPIHI_INT); 222 if (!strcasecmp (fieldName, "OBJFLAGS")) ESCAPE (MEAS_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 223 if (!strcasecmp (fieldName, "OBJ_FLAGS")) ESCAPE (MEAS_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 224 if (!strcasecmp (fieldName, "OBJ_PHOT_FLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, MAG_NONE, OPIHI_INT); 225 if (!strcasecmp (fieldName, "SECFLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, MAG_NONE, OPIHI_INT); 226 if (!strcasecmp (fieldName, "SEC_FLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, MAG_NONE, OPIHI_INT); 227 if (!strcasecmp (fieldName, "SECFILT_FLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, MAG_NONE, OPIHI_INT); 228 if (!strcasecmp (fieldName, "DB_FLAGS")) ESCAPE (MEAS_DB_FLAGS, MAG_NONE, OPIHI_INT); 229 if (!strcasecmp (fieldName, "PHOT_FLAGS")) ESCAPE (MEAS_PHOT_FLAGS, MAG_NONE, OPIHI_INT); 230 if (!strcasecmp (fieldName, "DBFLAGS")) ESCAPE (MEAS_DB_FLAGS, MAG_NONE, OPIHI_INT); 231 if (!strcasecmp (fieldName, "PHOTFLAGS")) ESCAPE (MEAS_PHOT_FLAGS, MAG_NONE, OPIHI_INT); 232 if (!strcasecmp (fieldName, "AIRMASS")) ESCAPE (MEAS_AIRMASS, MAG_NONE, OPIHI_FLT); 233 if (!strcasecmp (fieldName, "MEAN_AIRMASS")) ESCAPE (MEAS_MEAN_AIRMASS, MAG_NONE, OPIHI_FLT); 234 if (!strcasecmp (fieldName, "ALT")) ESCAPE (MEAS_ALT, MAG_NONE, OPIHI_FLT); 235 if (!strcasecmp (fieldName, "AZ")) ESCAPE (MEAS_AZ, MAG_NONE, OPIHI_FLT); 236 if (!strcasecmp (fieldName, "EXPTIME")) ESCAPE (MEAS_EXPTIME, MAG_NONE, OPIHI_FLT); 237 if (!strcasecmp (fieldName, "PHOTCODE")) ESCAPE (MEAS_PHOTCODE, MAG_NONE, OPIHI_INT); 238 if (!strcasecmp (fieldName, "PHOTCODE:KLAM")) ESCAPE (MEAS_PHOTCODE_KLAM, MAG_NONE, OPIHI_FLT); 239 if (!strcasecmp (fieldName, "PHOTCODE:C")) ESCAPE (MEAS_PHOTCODE_C, MAG_NONE, OPIHI_FLT); 240 if (!strcasecmp (fieldName, "PHOTCODE:EQUIV")) ESCAPE (MEAS_PHOTCODE_EQUIV, MAG_NONE, OPIHI_INT); 241 if (!strcasecmp (fieldName, "TIME")) ESCAPE (MEAS_TIME, MAG_NONE, OPIHI_FLT); 242 if (!strcasecmp (fieldName, "FWHM")) ESCAPE (MEAS_FWHM, MAG_NONE, OPIHI_FLT); 243 if (!strcasecmp (fieldName, "FWHM_MAJ")) ESCAPE (MEAS_FWHM_MAJ, MAG_NONE, OPIHI_FLT); 244 if (!strcasecmp (fieldName, "FWHM_MIN")) ESCAPE (MEAS_FWHM_MIN, MAG_NONE, OPIHI_FLT); 245 if (!strcasecmp (fieldName, "THETA")) ESCAPE (MEAS_THETA, MAG_NONE, OPIHI_FLT); 246 if (!strcasecmp (fieldName, "POSANGLE")) ESCAPE (MEAS_POSANGLE, MAG_NONE, OPIHI_FLT); 247 if (!strcasecmp (fieldName, "PLATESCALE")) ESCAPE (MEAS_PLATESCALE, MAG_NONE, OPIHI_FLT); 248 if (!strcasecmp (fieldName, "MXX")) ESCAPE (MEAS_MXX, MAG_NONE, OPIHI_FLT); 249 if (!strcasecmp (fieldName, "MYY")) ESCAPE (MEAS_MYY, MAG_NONE, OPIHI_FLT); 250 if (!strcasecmp (fieldName, "MXY")) ESCAPE (MEAS_MXY, MAG_NONE, OPIHI_FLT); 251 if (!strcasecmp (fieldName, "DOPHOT")) ESCAPE (MEAS_DOPHOT, MAG_NONE, OPIHI_INT); 252 if (!strcasecmp (fieldName, "XCCD")) ESCAPE (MEAS_XCCD, MAG_NONE, OPIHI_FLT); 253 if (!strcasecmp (fieldName, "YCCD")) ESCAPE (MEAS_YCCD, MAG_NONE, OPIHI_FLT); 254 if (!strcasecmp (fieldName, "XCCD:ERR")) ESCAPE (MEAS_XCCD_ERR, MAG_NONE, OPIHI_FLT); 255 if (!strcasecmp (fieldName, "YCCD:ERR")) ESCAPE (MEAS_YCCD_ERR, MAG_NONE, OPIHI_FLT); 256 if (!strcasecmp (fieldName, "XFIX")) ESCAPE (MEAS_XFIX, MAG_NONE, OPIHI_FLT); 257 if (!strcasecmp (fieldName, "YFIX")) ESCAPE (MEAS_YFIX, MAG_NONE, OPIHI_FLT); 258 if (!strcasecmp (fieldName, "POS_SYS_ERR")) ESCAPE (MEAS_POS_SYS_ERR, MAG_NONE, OPIHI_FLT); 259 if (!strcasecmp (fieldName, "XFIELD")) ESCAPE (MEAS_XFIELD, MAG_NONE, OPIHI_FLT); 260 if (!strcasecmp (fieldName, "YFIELD")) ESCAPE (MEAS_YFIELD, MAG_NONE, OPIHI_FLT); 261 if (!strcasecmp (fieldName, "XMOSAIC")) ESCAPE (MEAS_XMOSAIC, MAG_NONE, OPIHI_FLT); 262 if (!strcasecmp (fieldName, "YMOSAIC")) ESCAPE (MEAS_YMOSAIC, MAG_NONE, OPIHI_FLT); 263 if (!strcasecmp (fieldName, "XCHIP")) ESCAPE (MEAS_XCCD, MAG_NONE, OPIHI_FLT); 264 if (!strcasecmp (fieldName, "YCHIP")) ESCAPE (MEAS_YCCD, MAG_NONE, OPIHI_FLT); 265 if (!strcasecmp (fieldName, "XFPA")) ESCAPE (MEAS_XMOSAIC, MAG_NONE, OPIHI_FLT); 266 if (!strcasecmp (fieldName, "YFPA")) ESCAPE (MEAS_YMOSAIC, MAG_NONE, OPIHI_FLT); 267 if (!strcasecmp (fieldName, "DETID")) ESCAPE (MEAS_DET_ID, MAG_NONE, OPIHI_INT); 268 if (!strcasecmp (fieldName, "OBJID")) ESCAPE (MEAS_OBJ_ID, MAG_NONE, OPIHI_INT); 269 if (!strcasecmp (fieldName, "CATID")) ESCAPE (MEAS_CAT_ID, MAG_NONE, OPIHI_INT); 270 if (!strcasecmp (fieldName, "IMAGEID")) ESCAPE (MEAS_IMAGE_ID, MAG_NONE, OPIHI_INT); 271 if (!strcasecmp (fieldName, "EXTERNID")) ESCAPE (MEAS_EXTERN_ID, MAG_NONE, OPIHI_INT); 272 if (!strcasecmp (fieldName, "EXPNAME")) ESCAPE (MEAS_EXPNAME_AS_INT, MAG_NONE, OPIHI_INT); 273 if (!strcasecmp (fieldName, "PSF_QF")) ESCAPE (MEAS_PSF_QF, MAG_NONE, OPIHI_FLT); 274 if (!strcasecmp (fieldName, "PSF_QF_PERFECT")) ESCAPE (MEAS_PSF_QF_PERFECT, MAG_NONE, OPIHI_FLT); 275 if (!strcasecmp (fieldName, "PSF_CHISQ")) ESCAPE (MEAS_PSF_CHISQ, MAG_NONE, OPIHI_FLT); 276 if (!strcasecmp (fieldName, "PSF_NDOF")) ESCAPE (MEAS_PSF_NDOF, MAG_NONE, OPIHI_INT); 277 if (!strcasecmp (fieldName, "PSF_NPIX")) ESCAPE (MEAS_PSF_NPIX, MAG_NONE, OPIHI_INT); 278 if (!strcasecmp (fieldName, "CR_NSIGMA")) ESCAPE (MEAS_CR_NSIGMA, MAG_NONE, OPIHI_FLT); 279 if (!strcasecmp (fieldName, "EXT_NSIGMA")) ESCAPE (MEAS_EXT_NSIGMA, MAG_NONE, OPIHI_FLT); 280 if (!strcasecmp (fieldName, "SKY")) ESCAPE (MEAS_SKY, MAG_NONE, OPIHI_FLT); 281 if (!strcasecmp (fieldName, "SKY_ERR")) ESCAPE (MEAS_dSKY, MAG_NONE, OPIHI_FLT); 282 if (!strcasecmp (fieldName, "MCAL_OFFSET")) ESCAPE (MEAS_MCAL_OFFSET, MAG_NONE, OPIHI_FLT); 283 if (!strcasecmp (fieldName, "FLAT")) ESCAPE (MEAS_FLAT, MAG_NONE, OPIHI_FLT); 284 if (!strcasecmp (fieldName, "CENTER_OFFSET")) ESCAPE (MEAS_CENTER_OFFSET, MAG_NONE, OPIHI_FLT); 285 if (!strcasecmp (fieldName, "FLUX")) ESCAPE (MEAS_FLUX_PSF, MAG_NONE, OPIHI_FLT); 286 if (!strcasecmp (fieldName, "FLUX_ERR")) ESCAPE (MEAS_FLUX_PSF_ERR, MAG_NONE, OPIHI_FLT); 287 if (!strcasecmp (fieldName, "FLUX_PSF")) ESCAPE (MEAS_FLUX_PSF, MAG_NONE, OPIHI_FLT); 288 if (!strcasecmp (fieldName, "FLUX_PSF_ERR")) ESCAPE (MEAS_FLUX_PSF_ERR, MAG_NONE, OPIHI_FLT); 289 if (!strcasecmp (fieldName, "FLUX_KRON")) ESCAPE (MEAS_FLUX_KRON, MAG_NONE, OPIHI_FLT); 290 if (!strcasecmp (fieldName, "FLUX_KRON_ERR")) ESCAPE (MEAS_FLUX_KRON_ERR, MAG_NONE, OPIHI_FLT); 291 292 // for words that don't parse, try a photcode 293 294 // check for code:mode in photcode name 295 code = ParsePhotcodeField (fieldName, &mode, MAG_AVE); 296 if (code == NULL) { 297 gprint (GP_ERR, "unknown field '%s' for measurement table in DVO database\n", fieldName); 298 return (FALSE); 299 } 300 301 field->ID = MEAS_MAG; 302 field->magMode = mode; 303 switch (mode) { 304 case MAG_STACK_DET_ID: 305 case MAG_NCODE: 306 case MAG_NPHOT: 307 case MAG_PHOT_FLAGS: 241 242 dvoMagOptionType option = GetMagOption (word); 243 if (option != MAG_OPTION_NONE) { 244 // some combinations are OK: mag + err -> err 245 if ((myOption == MAG_OPTION_MAG) && (option == MAG_OPTION_ERR)) { 246 myOption = option; 247 ptr = skipword (ptr); 248 continue; 249 } 250 // some combinations are OK: err + mag -> err 251 if ((myOption == MAG_OPTION_ERR) && (option == MAG_OPTION_MAG)) { 252 ptr = skipword (ptr); 253 continue; 254 } 255 // some combinations are OK: flux + err -> FLUX_ERR 256 if ((myOption == MAG_OPTION_FLUX) && (option == MAG_OPTION_ERR)) { 257 myOption = MAG_OPTION_FLUX_ERR; 258 ptr = skipword (ptr); 259 continue; 260 } 261 // some combinations are OK: err + flux -> FLUX_ERR 262 if ((myOption == MAG_OPTION_ERR) && (option == MAG_OPTION_FLUX)) { 263 myOption = MAG_OPTION_FLUX_ERR; 264 ptr = skipword (ptr); 265 continue; 266 } 267 // some combinations are OK: flux + fluxerr -> FLUX_ERR 268 if ((myOption == MAG_OPTION_FLUX) && (option == MAG_OPTION_FLUX_ERR)) { 269 myOption = MAG_OPTION_FLUX_ERR; 270 ptr = skipword (ptr); 271 continue; 272 } 273 // some combinations are OK: fluxerr + flux -> FLUX_ERR 274 if ((myOption == MAG_OPTION_FLUX_ERR) && (option == MAG_OPTION_FLUX)) { 275 myOption = MAG_OPTION_FLUX_ERR; 276 ptr = skipword (ptr); 277 continue; 278 } 279 if (myOption != MAG_OPTION_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 280 myOption = option; 281 ptr = skipword (ptr); 282 continue; 283 } 284 285 fprintf (stderr, "ERROR: unknown mag/photocode argument %s\n", word); 286 free (word); 287 } 288 289 // if nothing is provided, use the defaults 290 field->magSource = (mySource == MAG_SRC_NONE) ? field->magSource : mySource; 291 field->magLevel = (myLevel == MAG_LEVEL_NONE) ? field->magLevel : myLevel; 292 field->magClass = (myClass == MAG_CLASS_NONE) ? field->magClass : myClass; 293 field->magOption = (myOption == MAG_OPTION_NONE) ? field->magOption : myOption; 294 295 switch (field->magOption) { 296 case MAG_OPTION_NCODE: 297 case MAG_OPTION_NPHOT: 298 case MAG_OPTION_FLAGS: 308 299 field->type = OPIHI_INT; 309 300 break; … … 313 304 } 314 305 field->photcode = code; 306 return TRUE; 307 } 308 309 // field needs to be initialized with dbInitField() 310 # define ESCAPE(F,T) { \ 311 field->ID = (F); \ 312 field->type = (T); \ 313 return (TRUE); } 314 315 int ParseMeasureField (dbField *field, char *fieldName) { 316 317 field->table = DVO_TABLE_MEASURE; 318 field->name = strcreate (fieldName); 319 320 if (!strcasecmp (fieldName, "GLON")) { 321 dbExtractMeasuresInitTransform (COORD_GALACTIC); 322 ESCAPE (MEAS_GLON, OPIHI_FLT); 323 } 324 if (!strcasecmp (fieldName, "GLAT")) { 325 dbExtractMeasuresInitTransform (COORD_GALACTIC); 326 ESCAPE (MEAS_GLAT, OPIHI_FLT); 327 } 328 if (!strcasecmp (fieldName, "GLON:AVE")) { 329 dbExtractMeasuresInitTransform (COORD_GALACTIC); 330 ESCAPE (MEAS_GLON_AVE, OPIHI_FLT); 331 } 332 if (!strcasecmp (fieldName, "GLAT:AVE")) { 333 dbExtractMeasuresInitTransform (COORD_GALACTIC); 334 ESCAPE (MEAS_GLAT_AVE, OPIHI_FLT); 335 } 336 337 if (!strcasecmp (fieldName, "ELON")) { 338 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 339 ESCAPE (MEAS_ELON, OPIHI_FLT); 340 } 341 if (!strcasecmp (fieldName, "ELAT")) { 342 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 343 ESCAPE (MEAS_ELAT, OPIHI_FLT); 344 } 345 if (!strcasecmp (fieldName, "ELON:AVE")) { 346 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 347 ESCAPE (MEAS_ELON_AVE, OPIHI_FLT); 348 } 349 if (!strcasecmp (fieldName, "ELAT:AVE")) { 350 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 351 ESCAPE (MEAS_ELAT_AVE, OPIHI_FLT); 352 } 353 354 if (!strcasecmp (fieldName, "RA")) ESCAPE (MEAS_RA, OPIHI_FLT); 355 if (!strcasecmp (fieldName, "DEC")) ESCAPE (MEAS_DEC, OPIHI_FLT); 356 if (!strcasecmp (fieldName, "RA:AVE")) ESCAPE (MEAS_RA_AVE, OPIHI_FLT); 357 if (!strcasecmp (fieldName, "DEC:AVE")) ESCAPE (MEAS_DEC_AVE, OPIHI_FLT); 358 if (!strcasecmp (fieldName, "RA:ERR")) ESCAPE (MEAS_RA_AVE_ERR, OPIHI_FLT); 359 if (!strcasecmp (fieldName, "DEC:ERR")) ESCAPE (MEAS_DEC_AVE_ERR, OPIHI_FLT); 360 if (!strcasecmp (fieldName, "uRA")) ESCAPE (MEAS_U_RA, OPIHI_FLT); 361 if (!strcasecmp (fieldName, "uDEC")) ESCAPE (MEAS_U_DEC, OPIHI_FLT); 362 if (!strcasecmp (fieldName, "duRA")) ESCAPE (MEAS_U_RA_ERR, OPIHI_FLT); 363 if (!strcasecmp (fieldName, "duDEC")) ESCAPE (MEAS_U_DEC_ERR, OPIHI_FLT); 364 if (!strcasecmp (fieldName, "PAR")) ESCAPE (MEAS_PAR, OPIHI_FLT); 365 if (!strcasecmp (fieldName, "dPAR")) ESCAPE (MEAS_PAR_ERR, OPIHI_FLT); 366 if (!strcasecmp (fieldName, "dR")) ESCAPE (MEAS_RA_OFFSET, OPIHI_FLT); 367 if (!strcasecmp (fieldName, "dD")) ESCAPE (MEAS_DEC_OFFSET, OPIHI_FLT); 368 if (!strcasecmp (fieldName, "dR:FIT")) ESCAPE (MEAS_RA_FIT_OFFSET, OPIHI_FLT); 369 if (!strcasecmp (fieldName, "dD:FIT")) ESCAPE (MEAS_DEC_FIT_OFFSET, OPIHI_FLT); 370 if (!strcasecmp (fieldName, "dR:ERR")) ESCAPE (MEAS_RA_OFFSET_ERR, OPIHI_FLT); 371 if (!strcasecmp (fieldName, "dD:ERR")) ESCAPE (MEAS_DEC_OFFSET_ERR, OPIHI_FLT); 372 if (!strcasecmp (fieldName, "ChiSqPos")) ESCAPE (MEAS_CHISQ_POS, OPIHI_FLT); 373 if (!strcasecmp (fieldName, "ChiSqPM")) ESCAPE (MEAS_CHISQ_PM, OPIHI_FLT); 374 if (!strcasecmp (fieldName, "ChiSqPar")) ESCAPE (MEAS_CHISQ_PAR, OPIHI_FLT); 375 if (!strcasecmp (fieldName, "Tmean")) ESCAPE (MEAS_TMEAN, OPIHI_FLT); 376 if (!strcasecmp (fieldName, "Trange")) ESCAPE (MEAS_TRANGE, OPIHI_FLT); 377 if (!strcasecmp (fieldName, "nmeas")) ESCAPE (MEAS_NMEAS, OPIHI_INT); 378 if (!strcasecmp (fieldName, "nmiss")) ESCAPE (MEAS_NMISS, OPIHI_INT); 379 if (!strcasecmp (fieldName, "npos")) ESCAPE (MEAS_NPOS, OPIHI_INT); 380 if (!strcasecmp (fieldName, "OBJFLAGS")) ESCAPE (MEAS_OBJ_FLAGS, OPIHI_INT); 381 if (!strcasecmp (fieldName, "OBJ_FLAGS")) ESCAPE (MEAS_OBJ_FLAGS, OPIHI_INT); 382 if (!strcasecmp (fieldName, "OBJ_PHOT_FLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, OPIHI_INT); 383 if (!strcasecmp (fieldName, "SECFLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, OPIHI_INT); 384 if (!strcasecmp (fieldName, "SEC_FLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, OPIHI_INT); 385 if (!strcasecmp (fieldName, "SECFILT_FLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, OPIHI_INT); 386 if (!strcasecmp (fieldName, "DB_FLAGS")) ESCAPE (MEAS_DB_FLAGS, OPIHI_INT); 387 if (!strcasecmp (fieldName, "PHOT_FLAGS")) ESCAPE (MEAS_PHOT_FLAGS, OPIHI_INT); 388 if (!strcasecmp (fieldName, "DBFLAGS")) ESCAPE (MEAS_DB_FLAGS, OPIHI_INT); 389 if (!strcasecmp (fieldName, "PHOTFLAGS")) ESCAPE (MEAS_PHOT_FLAGS, OPIHI_INT); 390 if (!strcasecmp (fieldName, "AIRMASS")) ESCAPE (MEAS_AIRMASS, OPIHI_FLT); 391 if (!strcasecmp (fieldName, "MEAN_AIRMASS")) ESCAPE (MEAS_MEAN_AIRMASS, OPIHI_FLT); 392 if (!strcasecmp (fieldName, "ALT")) ESCAPE (MEAS_ALT, OPIHI_FLT); 393 if (!strcasecmp (fieldName, "AZ")) ESCAPE (MEAS_AZ, OPIHI_FLT); 394 if (!strcasecmp (fieldName, "EXPTIME")) ESCAPE (MEAS_EXPTIME, OPIHI_FLT); 395 if (!strcasecmp (fieldName, "PHOTCODE")) ESCAPE (MEAS_PHOTCODE, OPIHI_INT); 396 if (!strcasecmp (fieldName, "PHOTCODE:KLAM")) ESCAPE (MEAS_PHOTCODE_KLAM, OPIHI_FLT); 397 if (!strcasecmp (fieldName, "PHOTCODE:C")) ESCAPE (MEAS_PHOTCODE_C, OPIHI_FLT); 398 if (!strcasecmp (fieldName, "PHOTCODE:EQUIV")) ESCAPE (MEAS_PHOTCODE_EQUIV, OPIHI_INT); 399 if (!strcasecmp (fieldName, "TIME")) ESCAPE (MEAS_TIME, OPIHI_FLT); 400 if (!strcasecmp (fieldName, "FWHM")) ESCAPE (MEAS_FWHM, OPIHI_FLT); 401 if (!strcasecmp (fieldName, "FWHM_MAJ")) ESCAPE (MEAS_FWHM_MAJ, OPIHI_FLT); 402 if (!strcasecmp (fieldName, "FWHM_MIN")) ESCAPE (MEAS_FWHM_MIN, OPIHI_FLT); 403 if (!strcasecmp (fieldName, "THETA")) ESCAPE (MEAS_THETA, OPIHI_FLT); 404 if (!strcasecmp (fieldName, "POSANGLE")) ESCAPE (MEAS_POSANGLE, OPIHI_FLT); 405 if (!strcasecmp (fieldName, "PLATESCALE")) ESCAPE (MEAS_PLATESCALE, OPIHI_FLT); 406 if (!strcasecmp (fieldName, "MXX")) ESCAPE (MEAS_MXX, OPIHI_FLT); 407 if (!strcasecmp (fieldName, "MYY")) ESCAPE (MEAS_MYY, OPIHI_FLT); 408 if (!strcasecmp (fieldName, "MXY")) ESCAPE (MEAS_MXY, OPIHI_FLT); 409 if (!strcasecmp (fieldName, "DOPHOT")) ESCAPE (MEAS_DOPHOT, OPIHI_INT); 410 if (!strcasecmp (fieldName, "XCCD")) ESCAPE (MEAS_XCCD, OPIHI_FLT); 411 if (!strcasecmp (fieldName, "YCCD")) ESCAPE (MEAS_YCCD, OPIHI_FLT); 412 if (!strcasecmp (fieldName, "XCCD:ERR")) ESCAPE (MEAS_XCCD_ERR, OPIHI_FLT); 413 if (!strcasecmp (fieldName, "YCCD:ERR")) ESCAPE (MEAS_YCCD_ERR, OPIHI_FLT); 414 if (!strcasecmp (fieldName, "XFIX")) ESCAPE (MEAS_XFIX, OPIHI_FLT); 415 if (!strcasecmp (fieldName, "YFIX")) ESCAPE (MEAS_YFIX, OPIHI_FLT); 416 if (!strcasecmp (fieldName, "POS_SYS_ERR")) ESCAPE (MEAS_POS_SYS_ERR, OPIHI_FLT); 417 if (!strcasecmp (fieldName, "XFIELD")) ESCAPE (MEAS_XFIELD, OPIHI_FLT); 418 if (!strcasecmp (fieldName, "YFIELD")) ESCAPE (MEAS_YFIELD, OPIHI_FLT); 419 if (!strcasecmp (fieldName, "XMOSAIC")) ESCAPE (MEAS_XMOSAIC, OPIHI_FLT); 420 if (!strcasecmp (fieldName, "YMOSAIC")) ESCAPE (MEAS_YMOSAIC, OPIHI_FLT); 421 if (!strcasecmp (fieldName, "XCHIP")) ESCAPE (MEAS_XCCD, OPIHI_FLT); 422 if (!strcasecmp (fieldName, "YCHIP")) ESCAPE (MEAS_YCCD, OPIHI_FLT); 423 if (!strcasecmp (fieldName, "XFPA")) ESCAPE (MEAS_XMOSAIC, OPIHI_FLT); 424 if (!strcasecmp (fieldName, "YFPA")) ESCAPE (MEAS_YMOSAIC, OPIHI_FLT); 425 if (!strcasecmp (fieldName, "DETID")) ESCAPE (MEAS_DET_ID, OPIHI_INT); 426 if (!strcasecmp (fieldName, "OBJID")) ESCAPE (MEAS_OBJ_ID, OPIHI_INT); 427 if (!strcasecmp (fieldName, "CATID")) ESCAPE (MEAS_CAT_ID, OPIHI_INT); 428 if (!strcasecmp (fieldName, "IMAGEID")) ESCAPE (MEAS_IMAGE_ID, OPIHI_INT); 429 if (!strcasecmp (fieldName, "EXTERNID")) ESCAPE (MEAS_EXTERN_ID, OPIHI_INT); 430 if (!strcasecmp (fieldName, "EXPNAME")) ESCAPE (MEAS_EXPNAME_AS_INT, OPIHI_INT); 431 if (!strcasecmp (fieldName, "PSF_QF")) ESCAPE (MEAS_PSF_QF, OPIHI_FLT); 432 if (!strcasecmp (fieldName, "PSF_QF_PERFECT")) ESCAPE (MEAS_PSF_QF_PERFECT, OPIHI_FLT); 433 if (!strcasecmp (fieldName, "PSF_CHISQ")) ESCAPE (MEAS_PSF_CHISQ, OPIHI_FLT); 434 if (!strcasecmp (fieldName, "PSF_NDOF")) ESCAPE (MEAS_PSF_NDOF, OPIHI_INT); 435 if (!strcasecmp (fieldName, "PSF_NPIX")) ESCAPE (MEAS_PSF_NPIX, OPIHI_INT); 436 if (!strcasecmp (fieldName, "CR_NSIGMA")) ESCAPE (MEAS_CR_NSIGMA, OPIHI_FLT); 437 if (!strcasecmp (fieldName, "EXT_NSIGMA")) ESCAPE (MEAS_EXT_NSIGMA, OPIHI_FLT); 438 if (!strcasecmp (fieldName, "SKY")) ESCAPE (MEAS_SKY, OPIHI_FLT); 439 if (!strcasecmp (fieldName, "SKY_ERR")) ESCAPE (MEAS_dSKY, OPIHI_FLT); 440 if (!strcasecmp (fieldName, "MCAL_OFFSET")) ESCAPE (MEAS_MCAL_OFFSET, OPIHI_FLT); 441 if (!strcasecmp (fieldName, "FLAT")) ESCAPE (MEAS_FLAT, OPIHI_FLT); 442 if (!strcasecmp (fieldName, "CENTER_OFFSET")) ESCAPE (MEAS_CENTER_OFFSET, OPIHI_FLT); 443 // if (!strcasecmp (fieldName, "FLUX")) ESCAPE (MEAS_FLUX_PSF, OPIHI_FLT); 444 // if (!strcasecmp (fieldName, "FLUX_ERR")) ESCAPE (MEAS_FLUX_PSF_ERR, OPIHI_FLT); 445 // if (!strcasecmp (fieldName, "FLUX_PSF")) ESCAPE (MEAS_FLUX_PSF, OPIHI_FLT); 446 // if (!strcasecmp (fieldName, "FLUX_PSF_ERR")) ESCAPE (MEAS_FLUX_PSF_ERR, OPIHI_FLT); 447 // if (!strcasecmp (fieldName, "FLUX_KRON")) ESCAPE (MEAS_FLUX_KRON, OPIHI_FLT); 448 // if (!strcasecmp (fieldName, "FLUX_KRON_ERR")) ESCAPE (MEAS_FLUX_KRON_ERR, OPIHI_FLT); 449 if (!strcasecmp (fieldName, "REF_COLOR")) ESCAPE (MEAS_REF_COLOR, OPIHI_FLT); 450 451 // for words that don't parse, try a photcode 452 453 // check for code:mode in photcode name 454 if (!ParsePhotcodeField (field, fieldName, MEAS_PHOT)) { 455 gprint (GP_ERR, "unknown field '%s' for measurement table in DVO database\n", fieldName); 456 return (FALSE); 457 } 458 315 459 return (TRUE); 316 460 } 317 461 318 462 int ParseAverageField (dbField *field, char *fieldName) { 319 320 int mode;321 PhotCode *code;322 463 323 464 field->table = DVO_TABLE_AVERAGE; … … 328 469 if (!strcasecmp (fieldName, "GLON")) { 329 470 dbExtractAveragesInitTransform (COORD_GALACTIC); 330 ESCAPE (AVE_GLON, MAG_NONE,OPIHI_FLT);471 ESCAPE (AVE_GLON, OPIHI_FLT); 331 472 } 332 473 if (!strcasecmp (fieldName, "GLAT")) { 333 474 dbExtractAveragesInitTransform (COORD_GALACTIC); 334 ESCAPE (AVE_GLAT, MAG_NONE,OPIHI_FLT);475 ESCAPE (AVE_GLAT, OPIHI_FLT); 335 476 } 336 477 … … 339 480 if (!strcasecmp (fieldName, "ELON")) { 340 481 dbExtractAveragesInitTransform (COORD_ECLIPTIC); 341 ESCAPE (AVE_ELON, MAG_NONE,OPIHI_FLT);482 ESCAPE (AVE_ELON, OPIHI_FLT); 342 483 } 343 484 if (!strcasecmp (fieldName, "ELAT")) { 344 485 dbExtractAveragesInitTransform (COORD_ECLIPTIC); 345 ESCAPE (AVE_ELAT, MAG_NONE, OPIHI_FLT); 346 } 347 348 if (!strcasecmp (fieldName, "RA")) ESCAPE (AVE_RA, MAG_NONE, OPIHI_FLT); 349 if (!strcasecmp (fieldName, "DEC")) ESCAPE (AVE_DEC, MAG_NONE, OPIHI_FLT); 350 if (!strcasecmp (fieldName, "GLON")) ESCAPE (AVE_GLON, MAG_NONE, OPIHI_FLT); 351 if (!strcasecmp (fieldName, "GLAT")) ESCAPE (AVE_GLAT, MAG_NONE, OPIHI_FLT); 352 if (!strcasecmp (fieldName, "ELON")) ESCAPE (AVE_ELON, MAG_NONE, OPIHI_FLT); 353 if (!strcasecmp (fieldName, "ELAT")) ESCAPE (AVE_ELAT, MAG_NONE, OPIHI_FLT); 354 if (!strcasecmp (fieldName, "dRA")) ESCAPE (AVE_RA_ERR, MAG_NONE, OPIHI_FLT); 355 if (!strcasecmp (fieldName, "dDEC")) ESCAPE (AVE_DEC_ERR, MAG_NONE, OPIHI_FLT); 356 if (!strcasecmp (fieldName, "uRA")) ESCAPE (AVE_U_RA, MAG_NONE, OPIHI_FLT); 357 if (!strcasecmp (fieldName, "uDEC")) ESCAPE (AVE_U_DEC, MAG_NONE, OPIHI_FLT); 358 if (!strcasecmp (fieldName, "duRA")) ESCAPE (AVE_U_RA_ERR, MAG_NONE, OPIHI_FLT); 359 if (!strcasecmp (fieldName, "duDEC")) ESCAPE (AVE_U_DEC_ERR, MAG_NONE, OPIHI_FLT); 360 if (!strcasecmp (fieldName, "PAR")) ESCAPE (AVE_PAR, MAG_NONE, OPIHI_FLT); 361 if (!strcasecmp (fieldName, "dPAR")) ESCAPE (AVE_PAR_ERR, MAG_NONE, OPIHI_FLT); 362 if (!strcasecmp (fieldName, "ChiSqPos")) ESCAPE (AVE_CHISQ_POS, MAG_NONE, OPIHI_FLT); 363 if (!strcasecmp (fieldName, "ChiSqPM")) ESCAPE (AVE_CHISQ_PM, MAG_NONE, OPIHI_FLT); 364 if (!strcasecmp (fieldName, "ChiSqPar")) ESCAPE (AVE_CHISQ_PAR, MAG_NONE, OPIHI_FLT); 365 if (!strcasecmp (fieldName, "Tmean")) ESCAPE (AVE_TMEAN, MAG_NONE, OPIHI_FLT); 366 if (!strcasecmp (fieldName, "Trange")) ESCAPE (AVE_TRANGE, MAG_NONE, OPIHI_FLT); 367 if (!strcasecmp (fieldName, "psfqf")) ESCAPE (AVE_PSF_QF, MAG_NONE, OPIHI_FLT); 368 if (!strcasecmp (fieldName, "psfqfperf")) ESCAPE (AVE_PSF_QF_PERF, MAG_NONE, OPIHI_FLT); 369 if (!strcasecmp (fieldName, "psf_qf")) ESCAPE (AVE_PSF_QF, MAG_NONE, OPIHI_FLT); 370 if (!strcasecmp (fieldName, "psf_qf_perf")) ESCAPE (AVE_PSF_QF_PERF, MAG_NONE, OPIHI_FLT); 371 if (!strcasecmp (fieldName, "stargal")) ESCAPE (AVE_STARGAL, MAG_NONE, OPIHI_FLT); 372 if (!strcasecmp (fieldName, "NMEAS")) ESCAPE (AVE_NMEAS, MAG_NONE, OPIHI_INT); 373 if (!strcasecmp (fieldName, "NMISS")) ESCAPE (AVE_NMISS, MAG_NONE, OPIHI_INT); 374 if (!strcasecmp (fieldName, "NPOS")) ESCAPE (AVE_NPOS, MAG_NONE, OPIHI_INT); 375 if (!strcasecmp (fieldName, "NASTROM")) ESCAPE (AVE_NPOS, MAG_NONE, OPIHI_INT); 376 if (!strcasecmp (fieldName, "FLAGS")) ESCAPE (AVE_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 377 if (!strcasecmp (fieldName, "OBJ_FLAGS")) ESCAPE (AVE_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 378 if (!strcasecmp (fieldName, "OBJFLAGS")) ESCAPE (AVE_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 379 if (!strcasecmp (fieldName, "OBJID")) ESCAPE (AVE_OBJID, MAG_NONE, OPIHI_INT); 380 if (!strcasecmp (fieldName, "CATID")) ESCAPE (AVE_CATID, MAG_NONE, OPIHI_INT); 381 if (!strcasecmp (fieldName, "EXTID_HI")) ESCAPE (AVE_EXTID_HI, MAG_NONE, OPIHI_INT); 382 if (!strcasecmp (fieldName, "EXTID_LO")) ESCAPE (AVE_EXTID_LO, MAG_NONE, OPIHI_INT); 486 ESCAPE (AVE_ELAT, OPIHI_FLT); 487 } 488 489 if (!strcasecmp (fieldName, "RA")) ESCAPE (AVE_RA, OPIHI_FLT); 490 if (!strcasecmp (fieldName, "DEC")) ESCAPE (AVE_DEC, OPIHI_FLT); 491 if (!strcasecmp (fieldName, "GLON")) ESCAPE (AVE_GLON, OPIHI_FLT); 492 if (!strcasecmp (fieldName, "GLAT")) ESCAPE (AVE_GLAT, OPIHI_FLT); 493 if (!strcasecmp (fieldName, "ELON")) ESCAPE (AVE_ELON, OPIHI_FLT); 494 if (!strcasecmp (fieldName, "ELAT")) ESCAPE (AVE_ELAT, OPIHI_FLT); 495 if (!strcasecmp (fieldName, "dRA")) ESCAPE (AVE_RA_ERR, OPIHI_FLT); 496 if (!strcasecmp (fieldName, "dDEC")) ESCAPE (AVE_DEC_ERR, OPIHI_FLT); 497 if (!strcasecmp (fieldName, "uRA")) ESCAPE (AVE_U_RA, OPIHI_FLT); 498 if (!strcasecmp (fieldName, "uDEC")) ESCAPE (AVE_U_DEC, OPIHI_FLT); 499 if (!strcasecmp (fieldName, "duRA")) ESCAPE (AVE_U_RA_ERR, OPIHI_FLT); 500 if (!strcasecmp (fieldName, "duDEC")) ESCAPE (AVE_U_DEC_ERR, OPIHI_FLT); 501 if (!strcasecmp (fieldName, "PAR")) ESCAPE (AVE_PAR, OPIHI_FLT); 502 if (!strcasecmp (fieldName, "dPAR")) ESCAPE (AVE_PAR_ERR, OPIHI_FLT); 503 if (!strcasecmp (fieldName, "ChiSqPos")) ESCAPE (AVE_CHISQ_POS, OPIHI_FLT); 504 if (!strcasecmp (fieldName, "ChiSqPM")) ESCAPE (AVE_CHISQ_PM, OPIHI_FLT); 505 if (!strcasecmp (fieldName, "ChiSqPar")) ESCAPE (AVE_CHISQ_PAR, OPIHI_FLT); 506 if (!strcasecmp (fieldName, "Tmean")) ESCAPE (AVE_TMEAN, OPIHI_FLT); 507 if (!strcasecmp (fieldName, "Trange")) ESCAPE (AVE_TRANGE, OPIHI_FLT); 508 if (!strcasecmp (fieldName, "psfqf")) ESCAPE (AVE_PSF_QF, OPIHI_FLT); 509 if (!strcasecmp (fieldName, "psfqfperf")) ESCAPE (AVE_PSF_QF_PERF, OPIHI_FLT); 510 if (!strcasecmp (fieldName, "psf_qf")) ESCAPE (AVE_PSF_QF, OPIHI_FLT); 511 if (!strcasecmp (fieldName, "psf_qf_perf")) ESCAPE (AVE_PSF_QF_PERF, OPIHI_FLT); 512 if (!strcasecmp (fieldName, "stargal")) ESCAPE (AVE_STARGAL, OPIHI_FLT); 513 if (!strcasecmp (fieldName, "NMEAS")) ESCAPE (AVE_NMEAS, OPIHI_INT); 514 if (!strcasecmp (fieldName, "NMISS")) ESCAPE (AVE_NMISS, OPIHI_INT); 515 if (!strcasecmp (fieldName, "NPOS")) ESCAPE (AVE_NPOS, OPIHI_INT); 516 if (!strcasecmp (fieldName, "NASTROM")) ESCAPE (AVE_NPOS, OPIHI_INT); 517 if (!strcasecmp (fieldName, "FLAGS")) ESCAPE (AVE_OBJ_FLAGS, OPIHI_INT); 518 if (!strcasecmp (fieldName, "OBJ_FLAGS")) ESCAPE (AVE_OBJ_FLAGS, OPIHI_INT); 519 if (!strcasecmp (fieldName, "OBJFLAGS")) ESCAPE (AVE_OBJ_FLAGS, OPIHI_INT); 520 if (!strcasecmp (fieldName, "OBJID")) ESCAPE (AVE_OBJID, OPIHI_INT); 521 if (!strcasecmp (fieldName, "CATID")) ESCAPE (AVE_CATID, OPIHI_INT); 522 if (!strcasecmp (fieldName, "EXTID_HI")) ESCAPE (AVE_EXTID_HI, OPIHI_INT); 523 if (!strcasecmp (fieldName, "EXTID_LO")) ESCAPE (AVE_EXTID_LO, OPIHI_INT); 524 if (!strcasecmp (fieldName, "REF_COLOR")) ESCAPE (AVE_REF_COLOR, OPIHI_FLT); 383 525 384 526 // check for code:mode in photcode name 385 code = ParsePhotcodeField (fieldName, &mode, MAG_AVE); 386 if (code == NULL) { 527 if (!ParsePhotcodeField (field, fieldName, AVE_PHOT)) { 387 528 gprint (GP_ERR, "unknown field '%s' for average table in DVO database\n", fieldName); 388 529 return (FALSE); 389 530 } 390 531 391 if ( code[0].type == PHOT_MAG) {532 if (field->photcode->type == PHOT_MAG) { 392 533 gprint (GP_ERR, "'mag' is ambiguous for avextract\n"); 393 free (code);394 534 return (FALSE); 395 535 } 396 536 397 field->ID = AVE_MAG;398 field->magMode = mode;399 switch (mode) {400 case MAG_STACK_DET_ID:401 case MAG_NCODE:402 case MAG_NPHOT:403 case MAG_PHOT_FLAGS:404 field->type = OPIHI_INT;405 break;406 default:407 field->type = OPIHI_FLT;408 break;409 }410 field->photcode = code;411 537 return (TRUE); 412 538 } … … 422 548 if (!strcasecmp (fieldName, "GLON")) { 423 549 dbExtractImagesInitTransform (COORD_GALACTIC); 424 ESCAPE (IMAGE_GLON, MAG_NONE,OPIHI_FLT);550 ESCAPE (IMAGE_GLON, OPIHI_FLT); 425 551 } 426 552 if (!strcasecmp (fieldName, "GLAT")) { 427 553 dbExtractImagesInitTransform (COORD_GALACTIC); 428 ESCAPE (IMAGE_GLAT, MAG_NONE,OPIHI_FLT);554 ESCAPE (IMAGE_GLAT, OPIHI_FLT); 429 555 } 430 556 … … 433 559 if (!strcasecmp (fieldName, "ELON")) { 434 560 dbExtractImagesInitTransform (COORD_ECLIPTIC); 435 ESCAPE (IMAGE_ELON, MAG_NONE,OPIHI_FLT);561 ESCAPE (IMAGE_ELON, OPIHI_FLT); 436 562 } 437 563 if (!strcasecmp (fieldName, "ELAT")) { 438 564 dbExtractImagesInitTransform (COORD_ECLIPTIC); 439 ESCAPE (IMAGE_ELAT, MAG_NONE, OPIHI_FLT); 440 } 441 442 if (!strcasecmp (fieldName, "RA" )) ESCAPE (IMAGE_RA, MAG_NONE, OPIHI_FLT); 443 if (!strcasecmp (fieldName, "DEC" )) ESCAPE (IMAGE_DEC, MAG_NONE, OPIHI_FLT); 444 if (!strcasecmp (fieldName, "GLON" )) ESCAPE (IMAGE_GLON, MAG_NONE, OPIHI_FLT); 445 if (!strcasecmp (fieldName, "GLAT" )) ESCAPE (IMAGE_GLAT, MAG_NONE, OPIHI_FLT); 446 if (!strcasecmp (fieldName, "ELON" )) ESCAPE (IMAGE_ELON, MAG_NONE, OPIHI_FLT); 447 if (!strcasecmp (fieldName, "ELAT" )) ESCAPE (IMAGE_ELAT, MAG_NONE, OPIHI_FLT); 448 449 if (!strcasecmp (fieldName, "theta" )) ESCAPE (IMAGE_THETA, MAG_NONE, OPIHI_FLT); 450 if (!strcasecmp (fieldName, "skew" )) ESCAPE (IMAGE_SKEW, MAG_NONE, OPIHI_FLT); 451 if (!strcasecmp (fieldName, "scale" )) ESCAPE (IMAGE_SCALE, MAG_NONE, OPIHI_FLT); 452 if (!strcasecmp (fieldName, "dscale" )) ESCAPE (IMAGE_DSCALE, MAG_NONE, OPIHI_FLT); 453 454 if (!strcasecmp (fieldName, "time" )) ESCAPE (IMAGE_TIME, MAG_NONE, OPIHI_FLT); 455 if (!strcasecmp (fieldName, "nstar" )) ESCAPE (IMAGE_NSTAR, MAG_NONE, OPIHI_INT); 456 if (!strcasecmp (fieldName, "airmass" )) ESCAPE (IMAGE_AIRMASS, MAG_NONE, OPIHI_FLT); 457 if (!strcasecmp (fieldName, "NX" )) ESCAPE (IMAGE_NX_PIX, MAG_NONE, OPIHI_INT); 458 if (!strcasecmp (fieldName, "NY" )) ESCAPE (IMAGE_NY_PIX, MAG_NONE, OPIHI_INT); 459 if (!strcasecmp (fieldName, "apresid" )) ESCAPE (IMAGE_APRESID, MAG_NONE, OPIHI_FLT); 460 if (!strcasecmp (fieldName, "dapresid" )) ESCAPE (IMAGE_DAPRESID, MAG_NONE, OPIHI_FLT); 461 462 if (!strcasecmp (fieldName, "Mcal" )) ESCAPE (IMAGE_MCAL, MAG_NONE, OPIHI_FLT); 463 if (!strcasecmp (fieldName, "dMcal" )) ESCAPE (IMAGE_dMCAL, MAG_NONE, OPIHI_FLT); 464 if (!strcasecmp (fieldName, "Xm" )) ESCAPE (IMAGE_XM, MAG_NONE, OPIHI_FLT); 465 if (!strcasecmp (fieldName, "photcode" )) ESCAPE (IMAGE_PHOTCODE, MAG_NONE, OPIHI_INT); 466 if (!strcasecmp (fieldName, "exptime" )) ESCAPE (IMAGE_EXPTIME, MAG_NONE, OPIHI_FLT); 467 if (!strcasecmp (fieldName, "sidtime" )) ESCAPE (IMAGE_SIDTIME, MAG_NONE, OPIHI_FLT); 468 469 if (!strcasecmp (fieldName, "latitude" )) ESCAPE (IMAGE_LATITUDE, MAG_NONE, OPIHI_FLT); 470 471 if (!strcasecmp (fieldName, "detlimit" )) ESCAPE (IMAGE_DET_LIMIT, MAG_NONE, OPIHI_FLT); 472 if (!strcasecmp (fieldName, "satlimit" )) ESCAPE (IMAGE_SAT_LIMIT, MAG_NONE, OPIHI_FLT); 473 if (!strcasecmp (fieldName, "cerror" )) ESCAPE (IMAGE_CERROR, MAG_NONE, OPIHI_FLT); 474 475 if (!strcasecmp (fieldName, "FWHM" )) ESCAPE (IMAGE_FWHM, MAG_NONE, OPIHI_FLT); 476 if (!strcasecmp (fieldName, "FWHM_MAJ" )) ESCAPE (IMAGE_FWHM_MAJ, MAG_NONE, OPIHI_FLT); 477 if (!strcasecmp (fieldName, "FWHM_MIN" )) ESCAPE (IMAGE_FWHM_MIN, MAG_NONE, OPIHI_FLT); 478 if (!strcasecmp (fieldName, "FWHM_MAJOR" )) ESCAPE (IMAGE_FWHM_MAJ, MAG_NONE, OPIHI_FLT); 479 if (!strcasecmp (fieldName, "FWHM_MINOR" )) ESCAPE (IMAGE_FWHM_MIN, MAG_NONE, OPIHI_FLT); 480 481 if (!strcasecmp (fieldName, "FWHM_MEDIAN" )) ESCAPE (IMAGE_FWHM_MEDIAN, MAG_NONE, OPIHI_FLT); 482 if (!strcasecmp (fieldName, "FWHM_MAJ_MEDIAN")) ESCAPE (IMAGE_FWHM_MAJ_MEDIAN, MAG_NONE, OPIHI_FLT); 483 if (!strcasecmp (fieldName, "FWHM_MIN_MEDIAN")) ESCAPE (IMAGE_FWHM_MIN_MEDIAN, MAG_NONE, OPIHI_FLT); 484 if (!strcasecmp (fieldName, "FWHM_MAJOR_MEDIAN")) ESCAPE (IMAGE_FWHM_MAJ_MEDIAN, MAG_NONE, OPIHI_FLT); 485 if (!strcasecmp (fieldName, "FWHM_MINOR_MEDIAN")) ESCAPE (IMAGE_FWHM_MIN_MEDIAN, MAG_NONE, OPIHI_FLT); 486 487 if (!strcasecmp (fieldName, "trate" )) ESCAPE (IMAGE_TRATE, MAG_NONE, OPIHI_FLT); 488 489 if (!strcasecmp (fieldName, "ncal" )) ESCAPE (IMAGE_NCAL, MAG_NONE, OPIHI_INT); 490 if (!strcasecmp (fieldName, "sky" )) ESCAPE (IMAGE_SKY, MAG_NONE, OPIHI_FLT); // deprecated for now 491 492 if (!strcasecmp (fieldName, "imflags" )) ESCAPE (IMAGE_FLAGS, MAG_NONE, OPIHI_INT); 493 if (!strcasecmp (fieldName, "flags" )) ESCAPE (IMAGE_FLAGS, MAG_NONE, OPIHI_INT); 494 if (!strcasecmp (fieldName, "ccdnum" )) ESCAPE (IMAGE_CCDNUM, MAG_NONE, OPIHI_INT); 495 496 if (!strcasecmp (fieldName, "imageID" )) ESCAPE (IMAGE_IMAGE_ID, MAG_NONE, OPIHI_INT); 497 if (!strcasecmp (fieldName, "externID" )) ESCAPE (IMAGE_EXTERN_ID, MAG_NONE, OPIHI_INT); 498 if (!strcasecmp (fieldName, "sourceID" )) ESCAPE (IMAGE_SOURCE_ID, MAG_NONE, OPIHI_INT); 499 500 if (!strcasecmp (fieldName, "X_LL_CHIP")) ESCAPE (IMAGE_X_LL_CHIP, MAG_NONE, OPIHI_FLT); 501 if (!strcasecmp (fieldName, "X_LR_CHIP")) ESCAPE (IMAGE_X_LR_CHIP, MAG_NONE, OPIHI_FLT); 502 if (!strcasecmp (fieldName, "X_UL_CHIP")) ESCAPE (IMAGE_X_UL_CHIP, MAG_NONE, OPIHI_FLT); 503 if (!strcasecmp (fieldName, "X_UR_CHIP")) ESCAPE (IMAGE_X_UR_CHIP, MAG_NONE, OPIHI_FLT); 504 if (!strcasecmp (fieldName, "Y_LL_CHIP")) ESCAPE (IMAGE_Y_LL_CHIP, MAG_NONE, OPIHI_FLT); 505 if (!strcasecmp (fieldName, "Y_LR_CHIP")) ESCAPE (IMAGE_Y_LR_CHIP, MAG_NONE, OPIHI_FLT); 506 if (!strcasecmp (fieldName, "Y_UL_CHIP")) ESCAPE (IMAGE_Y_UL_CHIP, MAG_NONE, OPIHI_FLT); 507 if (!strcasecmp (fieldName, "Y_UR_CHIP")) ESCAPE (IMAGE_Y_UR_CHIP, MAG_NONE, OPIHI_FLT); 508 if (!strcasecmp (fieldName, "X_LL_FP" )) ESCAPE (IMAGE_X_LL_FP, MAG_NONE, OPIHI_FLT); 509 if (!strcasecmp (fieldName, "X_LR_FP" )) ESCAPE (IMAGE_X_LR_FP, MAG_NONE, OPIHI_FLT); 510 if (!strcasecmp (fieldName, "X_UL_FP" )) ESCAPE (IMAGE_X_UL_FP, MAG_NONE, OPIHI_FLT); 511 if (!strcasecmp (fieldName, "X_UR_FP" )) ESCAPE (IMAGE_X_UR_FP, MAG_NONE, OPIHI_FLT); 512 if (!strcasecmp (fieldName, "Y_LL_FP" )) ESCAPE (IMAGE_Y_LL_FP, MAG_NONE, OPIHI_FLT); 513 if (!strcasecmp (fieldName, "Y_LR_FP" )) ESCAPE (IMAGE_Y_LR_FP, MAG_NONE, OPIHI_FLT); 514 if (!strcasecmp (fieldName, "Y_UL_FP" )) ESCAPE (IMAGE_Y_UL_FP, MAG_NONE, OPIHI_FLT); 515 if (!strcasecmp (fieldName, "Y_UR_FP" )) ESCAPE (IMAGE_Y_UR_FP, MAG_NONE, OPIHI_FLT); 516 517 if (!strcasecmp (fieldName, "dX_SYS" )) ESCAPE (IMAGE_X_ERR_SYS, MAG_NONE, OPIHI_FLT); 518 if (!strcasecmp (fieldName, "dY_SYS" )) ESCAPE (IMAGE_Y_ERR_SYS, MAG_NONE, OPIHI_FLT); 519 if (!strcasecmp (fieldName, "dM_SYS" )) ESCAPE (IMAGE_MAG_ERR_SYS,MAG_NONE, OPIHI_FLT); 520 521 if (!strcasecmp (fieldName, "UBERCAL_DIST")) ESCAPE (IMAGE_UBERCAL_DIST,MAG_NONE, OPIHI_INT); 522 if (!strcasecmp (fieldName, "UCDIST")) ESCAPE (IMAGE_UBERCAL_DIST,MAG_NONE, OPIHI_INT); 523 524 if (!strcasecmp (fieldName, "NFIT_PHOTOM")) ESCAPE (IMAGE_NFIT_PHOTOM,MAG_NONE, OPIHI_INT); 525 if (!strcasecmp (fieldName, "NFIT_ASTROM")) ESCAPE (IMAGE_NFIT_ASTROM,MAG_NONE, OPIHI_INT); 526 if (!strcasecmp (fieldName, "NLINK_PHOTOM")) ESCAPE (IMAGE_NLINK_PHOTOM,MAG_NONE, OPIHI_INT); 527 if (!strcasecmp (fieldName, "NLINK_ASTROM")) ESCAPE (IMAGE_NLINK_ASTROM,MAG_NONE, OPIHI_INT); 565 ESCAPE (IMAGE_ELAT, OPIHI_FLT); 566 } 567 568 if (!strcasecmp (fieldName, "RA" )) ESCAPE (IMAGE_RA, OPIHI_FLT); 569 if (!strcasecmp (fieldName, "DEC" )) ESCAPE (IMAGE_DEC, OPIHI_FLT); 570 if (!strcasecmp (fieldName, "GLON" )) ESCAPE (IMAGE_GLON, OPIHI_FLT); 571 if (!strcasecmp (fieldName, "GLAT" )) ESCAPE (IMAGE_GLAT, OPIHI_FLT); 572 if (!strcasecmp (fieldName, "ELON" )) ESCAPE (IMAGE_ELON, OPIHI_FLT); 573 if (!strcasecmp (fieldName, "ELAT" )) ESCAPE (IMAGE_ELAT, OPIHI_FLT); 574 575 if (!strcasecmp (fieldName, "theta" )) ESCAPE (IMAGE_THETA, OPIHI_FLT); 576 if (!strcasecmp (fieldName, "skew" )) ESCAPE (IMAGE_SKEW, OPIHI_FLT); 577 if (!strcasecmp (fieldName, "scale" )) ESCAPE (IMAGE_SCALE, OPIHI_FLT); 578 if (!strcasecmp (fieldName, "dscale" )) ESCAPE (IMAGE_DSCALE, OPIHI_FLT); 579 580 if (!strcasecmp (fieldName, "time" )) ESCAPE (IMAGE_TIME, OPIHI_FLT); 581 if (!strcasecmp (fieldName, "nstar" )) ESCAPE (IMAGE_NSTAR, OPIHI_INT); 582 if (!strcasecmp (fieldName, "airmass" )) ESCAPE (IMAGE_AIRMASS, OPIHI_FLT); 583 if (!strcasecmp (fieldName, "NX" )) ESCAPE (IMAGE_NX_PIX, OPIHI_INT); 584 if (!strcasecmp (fieldName, "NY" )) ESCAPE (IMAGE_NY_PIX, OPIHI_INT); 585 if (!strcasecmp (fieldName, "apresid" )) ESCAPE (IMAGE_APRESID, OPIHI_FLT); 586 if (!strcasecmp (fieldName, "dapresid" )) ESCAPE (IMAGE_DAPRESID, OPIHI_FLT); 587 588 if (!strcasecmp (fieldName, "Mcal" )) ESCAPE (IMAGE_MCAL, OPIHI_FLT); 589 if (!strcasecmp (fieldName, "dMcal" )) ESCAPE (IMAGE_dMCAL, OPIHI_FLT); 590 if (!strcasecmp (fieldName, "Xm" )) ESCAPE (IMAGE_XM, OPIHI_FLT); 591 if (!strcasecmp (fieldName, "photcode" )) ESCAPE (IMAGE_PHOTCODE, OPIHI_INT); 592 if (!strcasecmp (fieldName, "exptime" )) ESCAPE (IMAGE_EXPTIME, OPIHI_FLT); 593 if (!strcasecmp (fieldName, "sidtime" )) ESCAPE (IMAGE_SIDTIME, OPIHI_FLT); 594 595 if (!strcasecmp (fieldName, "latitude" )) ESCAPE (IMAGE_LATITUDE, OPIHI_FLT); 596 597 if (!strcasecmp (fieldName, "detlimit" )) ESCAPE (IMAGE_DET_LIMIT, OPIHI_FLT); 598 if (!strcasecmp (fieldName, "satlimit" )) ESCAPE (IMAGE_SAT_LIMIT, OPIHI_FLT); 599 if (!strcasecmp (fieldName, "cerror" )) ESCAPE (IMAGE_CERROR, OPIHI_FLT); 600 601 if (!strcasecmp (fieldName, "FWHM" )) ESCAPE (IMAGE_FWHM, OPIHI_FLT); 602 if (!strcasecmp (fieldName, "FWHM_MAJ" )) ESCAPE (IMAGE_FWHM_MAJ, OPIHI_FLT); 603 if (!strcasecmp (fieldName, "FWHM_MIN" )) ESCAPE (IMAGE_FWHM_MIN, OPIHI_FLT); 604 if (!strcasecmp (fieldName, "FWHM_MAJOR" )) ESCAPE (IMAGE_FWHM_MAJ, OPIHI_FLT); 605 if (!strcasecmp (fieldName, "FWHM_MINOR" )) ESCAPE (IMAGE_FWHM_MIN, OPIHI_FLT); 606 607 if (!strcasecmp (fieldName, "FWHM_MEDIAN" )) ESCAPE (IMAGE_FWHM_MEDIAN, OPIHI_FLT); 608 if (!strcasecmp (fieldName, "FWHM_MAJ_MEDIAN")) ESCAPE (IMAGE_FWHM_MAJ_MEDIAN, OPIHI_FLT); 609 if (!strcasecmp (fieldName, "FWHM_MIN_MEDIAN")) ESCAPE (IMAGE_FWHM_MIN_MEDIAN, OPIHI_FLT); 610 if (!strcasecmp (fieldName, "FWHM_MAJOR_MEDIAN")) ESCAPE (IMAGE_FWHM_MAJ_MEDIAN, OPIHI_FLT); 611 if (!strcasecmp (fieldName, "FWHM_MINOR_MEDIAN")) ESCAPE (IMAGE_FWHM_MIN_MEDIAN, OPIHI_FLT); 612 613 if (!strcasecmp (fieldName, "trate" )) ESCAPE (IMAGE_TRATE, OPIHI_FLT); 614 615 if (!strcasecmp (fieldName, "ncal" )) ESCAPE (IMAGE_NCAL, OPIHI_INT); 616 if (!strcasecmp (fieldName, "sky" )) ESCAPE (IMAGE_SKY, OPIHI_FLT); // deprecated for now 617 618 if (!strcasecmp (fieldName, "imflags" )) ESCAPE (IMAGE_FLAGS, OPIHI_INT); 619 if (!strcasecmp (fieldName, "flags" )) ESCAPE (IMAGE_FLAGS, OPIHI_INT); 620 if (!strcasecmp (fieldName, "ccdnum" )) ESCAPE (IMAGE_CCDNUM, OPIHI_INT); 621 622 if (!strcasecmp (fieldName, "imageID" )) ESCAPE (IMAGE_IMAGE_ID, OPIHI_INT); 623 if (!strcasecmp (fieldName, "externID" )) ESCAPE (IMAGE_EXTERN_ID, OPIHI_INT); 624 if (!strcasecmp (fieldName, "sourceID" )) ESCAPE (IMAGE_SOURCE_ID, OPIHI_INT); 625 626 if (!strcasecmp (fieldName, "X_LL_CHIP")) ESCAPE (IMAGE_X_LL_CHIP, OPIHI_FLT); 627 if (!strcasecmp (fieldName, "X_LR_CHIP")) ESCAPE (IMAGE_X_LR_CHIP, OPIHI_FLT); 628 if (!strcasecmp (fieldName, "X_UL_CHIP")) ESCAPE (IMAGE_X_UL_CHIP, OPIHI_FLT); 629 if (!strcasecmp (fieldName, "X_UR_CHIP")) ESCAPE (IMAGE_X_UR_CHIP, OPIHI_FLT); 630 if (!strcasecmp (fieldName, "Y_LL_CHIP")) ESCAPE (IMAGE_Y_LL_CHIP, OPIHI_FLT); 631 if (!strcasecmp (fieldName, "Y_LR_CHIP")) ESCAPE (IMAGE_Y_LR_CHIP, OPIHI_FLT); 632 if (!strcasecmp (fieldName, "Y_UL_CHIP")) ESCAPE (IMAGE_Y_UL_CHIP, OPIHI_FLT); 633 if (!strcasecmp (fieldName, "Y_UR_CHIP")) ESCAPE (IMAGE_Y_UR_CHIP, OPIHI_FLT); 634 if (!strcasecmp (fieldName, "X_LL_FP" )) ESCAPE (IMAGE_X_LL_FP, OPIHI_FLT); 635 if (!strcasecmp (fieldName, "X_LR_FP" )) ESCAPE (IMAGE_X_LR_FP, OPIHI_FLT); 636 if (!strcasecmp (fieldName, "X_UL_FP" )) ESCAPE (IMAGE_X_UL_FP, OPIHI_FLT); 637 if (!strcasecmp (fieldName, "X_UR_FP" )) ESCAPE (IMAGE_X_UR_FP, OPIHI_FLT); 638 if (!strcasecmp (fieldName, "Y_LL_FP" )) ESCAPE (IMAGE_Y_LL_FP, OPIHI_FLT); 639 if (!strcasecmp (fieldName, "Y_LR_FP" )) ESCAPE (IMAGE_Y_LR_FP, OPIHI_FLT); 640 if (!strcasecmp (fieldName, "Y_UL_FP" )) ESCAPE (IMAGE_Y_UL_FP, OPIHI_FLT); 641 if (!strcasecmp (fieldName, "Y_UR_FP" )) ESCAPE (IMAGE_Y_UR_FP, OPIHI_FLT); 642 643 if (!strcasecmp (fieldName, "dX_SYS" )) ESCAPE (IMAGE_X_ERR_SYS, OPIHI_FLT); 644 if (!strcasecmp (fieldName, "dY_SYS" )) ESCAPE (IMAGE_Y_ERR_SYS, OPIHI_FLT); 645 if (!strcasecmp (fieldName, "dM_SYS" )) ESCAPE (IMAGE_MAG_ERR_SYS,OPIHI_FLT); 646 647 if (!strcasecmp (fieldName, "UBERCAL_DIST")) ESCAPE (IMAGE_UBERCAL_DIST,OPIHI_INT); 648 if (!strcasecmp (fieldName, "UCDIST")) ESCAPE (IMAGE_UBERCAL_DIST,OPIHI_INT); 649 650 if (!strcasecmp (fieldName, "NFIT_PHOTOM")) ESCAPE (IMAGE_NFIT_PHOTOM, OPIHI_INT); 651 if (!strcasecmp (fieldName, "NFIT_ASTROM")) ESCAPE (IMAGE_NFIT_ASTROM, OPIHI_INT); 652 if (!strcasecmp (fieldName, "NLINK_PHOTOM")) ESCAPE (IMAGE_NLINK_PHOTOM, OPIHI_INT); 653 if (!strcasecmp (fieldName, "NLINK_ASTROM")) ESCAPE (IMAGE_NLINK_ASTROM, OPIHI_INT); 654 if (!strcasecmp (fieldName, "REF_COLOR")) ESCAPE (IMAGE_REF_COLOR, OPIHI_FLT); 528 655 529 656 // for words that don't parse, try a photcode -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_catalog.c
r36680 r37403 56 56 if (!strcasecmp (catformat, "PS1_V3")) return (DVO_FORMAT_PS1_V3); 57 57 if (!strcasecmp (catformat, "PS1_V4")) return (DVO_FORMAT_PS1_V4); 58 if (!strcasecmp (catformat, "PS1_V5")) return (DVO_FORMAT_PS1_V5); 58 59 if (!strcasecmp (catformat, "PS1_REF")) return (DVO_FORMAT_PS1_REF); 59 60 return (DVO_FORMAT_UNDEF); … … 69 70 } 70 71 72 float dvoOffsetR (Measure *measure, Average *average) { 73 74 float dR = (measure[0].R - average[0].R) * 3600.0; 75 return dR; 76 } 77 78 float dvoOffsetD (Measure *measure, Average *average) { 79 80 float dD = (measure[0].D - average[0].D) * 3600.0; 81 return dD; 82 } 83 84 double dvoMeanR (float dR, Average *average) { 85 86 double ra = average[0].R - dR / 3600.0; 87 return ra; 88 } 89 90 double dvoMeanD (float dD, Average *average) { 91 92 double dec = average[0].D - dD / 3600.0; 93 return dec; 94 } 95 71 96 // init all data, or just catalog data 72 97 void dvo_average_init (Average *average) { 73 98 average->R = 0; 74 99 average->D = 0; 75 average->dR = 0;76 average->dD = 0;100 average->dR = NAN; 101 average->dD = NAN; 77 102 78 103 average->uR = 0; 79 104 average->uD = 0; 80 average->duR = 0;81 average->duD = 0;105 average->duR = NAN; 106 average->duD = NAN; 82 107 average->P = 0; 83 average->dP = 0; 108 average->dP = NAN; 109 110 average->Rstk = NAN; 111 average->Dstk = NAN; 112 average->dRstk = NAN; 113 average->dDstk = NAN; 84 114 85 115 average->ChiSqAve = NAN; … … 97 127 average->Nmeasure = 0; 98 128 average->Nmissing = 0; 129 average->Nlensing = 0; 130 average->Nlensobj = 0; 99 131 average->Nextend = 0; 132 100 133 average->measureOffset = -1; 101 134 average->missingOffset = -1; 135 average->lensingOffset = -1; 136 average->lensobjOffset = -1; 102 137 average->extendOffset = -1; 138 average->paramsOffset = -1; 139 140 average->refColorBlue = NAN; 141 average->refColorRed = NAN; 142 143 average->tessID = 0; 144 average->skycellID = 0; 145 average->projectionID = 0; 146 average->dummy = 0; 103 147 104 148 average->flags = 0; … … 109 153 average->catID = 0; 110 154 average->extID = 0; 155 average->extIDgc = 0; 111 156 } 112 157 … … 125 170 void dvo_secfilt_init (SecFilt *secfilt) { 126 171 secfilt->M = NAN; 172 secfilt->dM = NAN; 127 173 secfilt->Map = NAN; 174 secfilt->dMap = NAN; 175 secfilt->sMap = NAN; 128 176 secfilt->Mkron = NAN; 129 177 secfilt->dMkron = NAN; 130 secfilt->dM = NAN; 131 secfilt->Xm = NAN_S_SHORT; 132 133 secfilt->FluxPSF = NAN; 134 secfilt->dFluxPSF = NAN; 135 secfilt->FluxKron = NAN; 136 secfilt->dFluxKron = NAN; 137 138 secfilt->flags = 0; 178 secfilt->sMkron = NAN; 179 180 secfilt->psfQfMax = NAN; 181 secfilt->psfQfPerfMax = NAN; 182 183 secfilt->Mstdev = NAN; 184 secfilt->Mmin = NAN; 185 secfilt->Mmax = NAN; 186 secfilt->Mchisq = NAN; 187 139 188 secfilt->Ncode = 0; 140 189 secfilt->Nused = 0; 141 142 secfilt->M_20 = NAN_S_SHORT; 143 secfilt->M_80 = NAN_S_SHORT; 190 secfilt->NusedKron = 0; 191 secfilt->NusedAp = 0; 192 193 secfilt->flags = 0; 194 195 secfilt->MpsfStk = NAN; 196 secfilt->FpsfStk = NAN; 197 secfilt->dFpsfStk = NAN; 198 199 secfilt->MkronStk = NAN; 200 secfilt->FkronStk = NAN; 201 secfilt->dFkronStk = NAN; 202 203 secfilt->MapStk = NAN; 204 secfilt->FapStk = NAN; 205 secfilt->dFapStk = NAN; 206 207 secfilt->Nstack = 0; 208 secfilt->NstackDet = 0; 209 210 secfilt->stackPrmryOff = -1; 211 secfilt->stackBestOff = -1; 212 213 secfilt->MpsfWrp = NAN; 214 secfilt->FpsfWrp = NAN; 215 secfilt->dFpsfWrp = NAN; 216 secfilt->sFpsfWrp = NAN; 217 218 secfilt->MkronWrp = NAN; 219 secfilt->FkronWrp = NAN; 220 secfilt->dFkronWrp = NAN; 221 secfilt->sFkronWrp = NAN; 222 223 secfilt->MapWrp = NAN; 224 secfilt->FapWrp = NAN; 225 secfilt->dFapWrp = NAN; 226 secfilt->sFapWrp = NAN; 227 228 secfilt->NusedWrp = 0; 229 secfilt->NusedKronWrp = 0; 230 secfilt->NusedApWrp = 0; 231 232 secfilt->Nwarp = 0; 233 secfilt->NwarpGood = 0; 144 234 145 235 secfilt->ubercalDist = 1000; 146 secfilt->Mstdev = NAN_S_SHORT;147 secfilt->stackDetectID = 0;148 236 } 149 237 150 238 // init all data, or just catalog data 151 239 void dvo_measure_init (Measure *measure) { 240 measure->R = NAN; 241 measure->D = NAN; 242 152 243 measure->M = NAN; 153 measure->dR = NAN; 154 measure->dD = NAN; 155 measure->Mcal = NAN; 244 measure->dM = NAN; 156 245 measure->Map = NAN; 246 measure->dMap = NAN; 157 247 measure->Mkron = NAN; 158 248 measure->dMkron = NAN; 159 measure-> dM= NAN;249 measure->Mcal = NAN; 160 250 measure->dMcal = NAN; 161 251 measure->dt = NAN; … … 165 255 measure->FluxKron = NAN; 166 256 measure->dFluxKron = NAN; 257 measure->FluxAp = NAN; 258 measure->dFluxAp = NAN; 167 259 168 260 measure->airmass = NAN; … … 174 266 measure->Yfix = NAN; 175 267 268 measure->XoffKH = NAN; 269 measure->YoffKH = NAN; 270 measure->XoffDCR = NAN; 271 measure->YoffDCR = NAN; 272 measure->RoffGAL = NAN; 273 measure->DoffGAL = NAN; 274 176 275 measure->Sky = NAN; 177 276 measure->dSky = NAN; 178 277 179 278 measure->t = 0; 180 measure->t_msec = 0;181 279 measure->averef = 0; 182 280 183 281 measure->detID = 0; 184 measure->imageID = 0;185 282 measure->objID = 0; 186 283 measure->catID = 0; 284 187 285 measure->extID = 0; 286 287 measure->imageID = 0; 188 288 189 289 measure->psfQF = NAN; 190 290 measure->psfQFperf = NAN; 191 291 measure->psfChisq = NAN; 292 192 293 measure->psfNdof = 0; 193 294 measure->psfNpix = 0; 194 measure->crNsigma = NAN;195 295 measure->extNsigma = NAN; 196 296 … … 203 303 measure->Myy = 0; 204 304 305 measure->t_msec = 0; 306 measure->photcode = 0; 307 205 308 measure->dXccd = 0; 206 309 measure->dYccd = 0; … … 210 313 measure->pltscale = NAN; 211 314 212 measure->photcode = 0;213 315 measure->dbFlags = 0; 214 316 measure->photFlags = 0; 317 measure->photFlags2= 0; 215 318 } 216 319 217 320 void dvo_measureT_init (MeasureTiny *measure) { 218 measure-> dR= NAN;219 measure-> dD= NAN;321 measure->R = NAN; 322 measure->D = NAN; 220 323 measure->M = NAN; 221 324 measure->Mcal = NAN; … … 244 347 measure->dRsys = 0; 245 348 measure->myDet = FALSE; 349 } 350 351 // init all data, or just catalog data 352 void dvo_lensing_init (Lensing *lensing) { 353 lensing->X11_sm_obj = NAN; 354 lensing->X12_sm_obj = NAN; 355 lensing->X22_sm_obj = NAN; 356 lensing->E1_sm_obj = NAN; 357 lensing->E2_sm_obj = NAN; 358 359 lensing->X11_sh_obj = NAN; 360 lensing->X12_sh_obj = NAN; 361 lensing->X22_sh_obj = NAN; 362 lensing->E1_sh_obj = NAN; 363 lensing->E2_sh_obj = NAN; 364 365 lensing->X11_sm_psf = NAN; 366 lensing->X12_sm_psf = NAN; 367 lensing->X22_sm_psf = NAN; 368 lensing->E1_sm_psf = NAN; 369 lensing->E2_sm_psf = NAN; 370 371 lensing->X11_sh_psf = NAN; 372 lensing->X12_sh_psf = NAN; 373 lensing->X22_sh_psf = NAN; 374 lensing->E1_sh_psf = NAN; 375 lensing->E2_sh_psf = NAN; 376 377 lensing->F_ApR5 = NAN; 378 lensing->dF_ApR5 = NAN; 379 lensing->sF_ApR5 = NAN; 380 lensing->fF_ApR5 = NAN; 381 382 lensing->F_ApR6 = NAN; 383 lensing->dF_ApR6 = NAN; 384 lensing->sF_ApR6 = NAN; 385 lensing->fF_ApR6 = NAN; 386 387 lensing->detID = -1; 388 lensing->objID = -1; 389 lensing->catID = -1; 390 lensing->averef = 0; 391 392 lensing->imageID = -1; 393 lensing->padding = 0; 394 } 395 396 // init all data, or just catalog data 397 void dvo_lensobj_init (Lensobj *lensobj, int toZero) { 398 lensobj->X11_sm_obj = toZero ? 0 : NAN; 399 lensobj->X12_sm_obj = toZero ? 0 : NAN; 400 lensobj->X22_sm_obj = toZero ? 0 : NAN; 401 lensobj->E1_sm_obj = toZero ? 0 : NAN; 402 lensobj->E2_sm_obj = toZero ? 0 : NAN; 403 lensobj->X11_sh_obj = toZero ? 0 : NAN; 404 lensobj->X12_sh_obj = toZero ? 0 : NAN; 405 lensobj->X22_sh_obj = toZero ? 0 : NAN; 406 lensobj->E1_sh_obj = toZero ? 0 : NAN; 407 lensobj->E2_sh_obj = toZero ? 0 : NAN; 408 lensobj->X11_sm_psf = toZero ? 0 : NAN; 409 lensobj->X12_sm_psf = toZero ? 0 : NAN; 410 lensobj->X22_sm_psf = toZero ? 0 : NAN; 411 lensobj->E1_sm_psf = toZero ? 0 : NAN; 412 lensobj->E2_sm_psf = toZero ? 0 : NAN; 413 lensobj->X11_sh_psf = toZero ? 0 : NAN; 414 lensobj->X12_sh_psf = toZero ? 0 : NAN; 415 lensobj->X22_sh_psf = toZero ? 0 : NAN; 416 lensobj->E1_sh_psf = toZero ? 0 : NAN; 417 lensobj->E2_sh_psf = toZero ? 0 : NAN; 418 lensobj->F_ApR5 = toZero ? 0 : NAN; 419 lensobj->dF_ApR5 = toZero ? 0 : NAN; 420 lensobj->sF_ApR5 = toZero ? 0 : NAN; 421 lensobj->fF_ApR5 = toZero ? 0 : NAN; 422 lensobj->F_ApR6 = toZero ? 0 : NAN; 423 lensobj->dF_ApR6 = toZero ? 0 : NAN; 424 lensobj->sF_ApR6 = toZero ? 0 : NAN; 425 lensobj->fF_ApR6 = toZero ? 0 : NAN; 426 427 lensobj->gamma = NAN; 428 lensobj->E1 = NAN; 429 lensobj->E2 = NAN; 430 431 lensobj->objID = -1; 432 lensobj->catID = -1; 433 434 lensobj->photcode = 0; 435 lensobj->Nmeas = 0; 246 436 } 247 437 … … 269 459 catalog[0].secfilt = NULL; 270 460 461 catalog[0].lensing = NULL; 462 catalog[0].lensobj = NULL; 463 271 464 catalog[0].averageT = NULL; 272 465 catalog[0].measureT = NULL; … … 281 474 catalog[0].Nsecf_mem = 0; 282 475 476 catalog[0].Nlensing = 0; 477 catalog[0].Nlensobj = 0; 478 283 479 catalog[0].Naves_disk = 0; 284 480 catalog[0].Nmeas_disk = 0; … … 286 482 catalog[0].Nsecf_disk = 0; 287 483 484 catalog[0].Nlensing_disk = 0; 485 catalog[0].Nlensobj_disk = 0; 486 288 487 catalog[0].Naves_off = 0; 289 488 catalog[0].Nmeas_off = 0; … … 291 490 catalog[0].Nsecf_off = 0; 292 491 492 catalog[0].Nlensing_off = 0; 493 catalog[0].Nlensobj_off = 0; 494 293 495 /* pointers to SPLIT data files */ 294 496 catalog[0].measure_catalog = NULL; 295 497 catalog[0].missing_catalog = NULL; 296 498 catalog[0].secfilt_catalog = NULL; 499 catalog[0].lensing_catalog = NULL; 500 catalog[0].lensobj_catalog = NULL; 297 501 298 502 /* pointers for data manipulation */ 299 catalog[0].found = NULL; 300 catalog[0].image = NULL; 301 catalog[0].mosaic = NULL; 302 catalog[0].X = NULL; 303 catalog[0].Y = NULL; 503 // catalog[0].X_t = NULL; 504 // catalog[0].Y_t = NULL; 505 catalog[0].nOwn_t = NULL; 506 catalog[0].found_t = NULL; 507 // catalog[0].image_t = NULL; 508 // catalog[0].mosaic_t = NULL; 509 catalog[0].foundWarp_t = NULL; 304 510 } 305 511 … … 345 551 } 346 552 553 // closes f but does not set back to NULL 347 554 fclearlockfile (catalog[0].filename, catalog[0].f, catalog[0].lockmode, &dbstate); 348 555 349 556 if (catalog[0].catmode == DVO_MODE_SPLIT) { 350 if (catalog[0].measure_catalog != NULL) dvo_catalog_unlock (catalog[0].measure_catalog); 351 if (catalog[0].missing_catalog != NULL) dvo_catalog_unlock (catalog[0].missing_catalog); 352 if (catalog[0].secfilt_catalog != NULL) dvo_catalog_unlock (catalog[0].secfilt_catalog); 557 if (catalog[0].measure_catalog) dvo_catalog_unlock (catalog[0].measure_catalog); 558 if (catalog[0].missing_catalog) dvo_catalog_unlock (catalog[0].missing_catalog); 559 if (catalog[0].secfilt_catalog) dvo_catalog_unlock (catalog[0].secfilt_catalog); 560 if (catalog[0].lensing_catalog) dvo_catalog_unlock (catalog[0].lensing_catalog); 561 if (catalog[0].lensobj_catalog) dvo_catalog_unlock (catalog[0].lensobj_catalog); 353 562 } 354 563 return (1); … … 579 788 for (in = out = i = 0; i < catalog[0].Naverage; i++) { 580 789 for (j = 0; j < catalog[0].Nsecfilt; j++, in++, out++) { 581 outsec[out].M = insec[in].M;582 outsec[out].dM = insec[in].dM;583 outsec[out]. Xm = insec[in].Xm;790 outsec[out].M = insec[in].M; 791 outsec[out].dM = insec[in].dM; 792 outsec[out].Mchisq = insec[in].Mchisq; 584 793 } 585 794 for (j = 0; j < Nextra; j++, out++) { 586 outsec[out].M = NAN;587 outsec[out].dM = NAN;588 outsec[out]. Xm = NAN_S_SHORT;795 outsec[out].M = NAN; 796 outsec[out].dM = NAN; 797 outsec[out].Mchisq = NAN; 589 798 } 590 799 } … … 616 825 free (catalog[0].secfilt_catalog); 617 826 } 827 if (catalog[0].lensing_catalog) { 828 free (catalog[0].lensing_catalog[0].filename); 829 dvo_catalog_free (catalog[0].lensing_catalog); 830 free (catalog[0].lensing_catalog); 831 } 832 if (catalog[0].lensobj_catalog) { 833 free (catalog[0].lensobj_catalog[0].filename); 834 dvo_catalog_free (catalog[0].lensobj_catalog); 835 free (catalog[0].lensobj_catalog); 836 } 618 837 } 619 838 dvo_catalog_free_data (catalog); … … 625 844 626 845 /* free, initialize data structures */ 627 if (catalog[0].average != NULL) {846 if (catalog[0].average) { 628 847 free (catalog[0].average); 629 848 catalog[0].Naverage = 0; 630 849 catalog[0].average = NULL; 631 850 } 632 if (catalog[0].measure != NULL) {851 if (catalog[0].measure) { 633 852 free (catalog[0].measure); 634 853 catalog[0].Nmeasure = 0; 635 854 catalog[0].measure = NULL; 636 855 } 637 if (catalog[0].missing != NULL) {856 if (catalog[0].missing) { 638 857 free (catalog[0].missing); 639 858 catalog[0].Nmissing = 0; 640 859 catalog[0].missing = NULL; 641 860 } 642 if (catalog[0].secfilt != NULL) {861 if (catalog[0].secfilt) { 643 862 free (catalog[0].secfilt); 644 863 catalog[0].Nsecf_mem = 0; 645 864 catalog[0].secfilt = NULL; 646 865 } 866 if (catalog[0].lensing) { 867 free (catalog[0].lensing); 868 catalog[0].Nlensing = 0; 869 catalog[0].lensing = NULL; 870 } 871 if (catalog[0].lensobj) { 872 free (catalog[0].lensobj); 873 catalog[0].Nlensobj = 0; 874 catalog[0].lensobj = NULL; 875 } 876 if (catalog[0].nOwn_t) { free (catalog[0].nOwn_t); catalog[0].nOwn_t = NULL; } 877 if (catalog[0].found_t) { free (catalog[0].found_t); catalog[0].found_t = NULL; } 878 if (catalog[0].foundWarp_t) { free (catalog[0].foundWarp_t); catalog[0].foundWarp_t = NULL; } 647 879 } 648 880 … … 733 965 } 734 966 } 967 if (catalog[0].lensing_catalog != NULL) { 968 if (catalog[0].Nlensing_disk == 0) { 969 // need to relock (and re-open) file for close elsewhere 970 status = dvo_catalog_lock (catalog[0].lensing_catalog, lockmode); 971 } else { 972 if (!dvo_catalog_backup (catalog[0].lensing_catalog, FALSE)) { 973 return FALSE; 974 } 975 } 976 } 977 if (catalog[0].lensobj_catalog != NULL) { 978 if (catalog[0].Nlensobj_disk == 0) { 979 // need to relock (and re-open) file for close elsewhere 980 status = dvo_catalog_lock (catalog[0].lensobj_catalog, lockmode); 981 } else { 982 if (!dvo_catalog_backup (catalog[0].lensobj_catalog, FALSE)) { 983 return FALSE; 984 } 985 } 986 } 735 987 } 736 988 return TRUE; … … 754 1006 status = unlink (tmpfilename); 755 1007 if (status) { 756 fprintf (stderr, "failed to unlink catalog %s \n", catalog->filename);1008 fprintf (stderr, "failed to unlink catalog %s~\n", catalog->filename); 757 1009 return FALSE; 758 1010 } … … 774 1026 } 775 1027 } 1028 if ((catalog[0].lensing_catalog != NULL) && (catalog[0].Nlensing_disk > 0)) { 1029 if (!dvo_catalog_unlink_backup (catalog[0].lensing_catalog, FALSE)) { 1030 return FALSE; 1031 } 1032 } 1033 if ((catalog[0].lensobj_catalog != NULL) && (catalog[0].Nlensobj_disk > 0)) { 1034 if (!dvo_catalog_unlink_backup (catalog[0].lensobj_catalog, FALSE)) { 1035 return FALSE; 1036 } 1037 } 776 1038 } 777 1039 return TRUE; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_catalog_chipcoords.c
r16810 r37403 56 56 m = average[i].measureOffset; 57 57 for (j = 0; j < average[i].Nmeasure; j++, m++) { 58 ra = average[i].R - measure[m].dR / 3600.0;59 dec = average[i].D - measure[m].dD / 3600.0;58 ra = measure[m].R; 59 dec = measure[m].D; 60 60 N = dvo_match_image (image, Nimage, measure[m].t, measure[m].photcode); 61 61 if (N == -1) continue; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_catalog_create.c
r27435 r37403 70 70 gfits_modify (&catalog[0].header, "SECFILT", "%s", 1, file); 71 71 free (file); 72 73 /* define lensing catalog file */ 74 ALLOCATE (catalog[0].lensing_catalog, Catalog, 1); 75 dvo_catalog_init (catalog[0].lensing_catalog, TRUE); 76 77 /* create basic data for lensing catalog file */ 78 gfits_create_header (&catalog[0].lensing_catalog[0].header); 79 ALLOCATE (catalog[0].lensing_catalog[0].filename, char, length); 80 sprintf (catalog[0].lensing_catalog[0].filename, "%s/%s.cpx", path, root); 81 file = filebasename (catalog[0].lensing_catalog[0].filename); 82 gfits_modify (&catalog[0].header, "LENSING", "%s", 1, file); 83 free (file); 84 85 /* define lensobj catalog file */ 86 ALLOCATE (catalog[0].lensobj_catalog, Catalog, 1); 87 dvo_catalog_init (catalog[0].lensobj_catalog, TRUE); 88 89 /* create basic data for lensobj catalog file */ 90 gfits_create_header (&catalog[0].lensobj_catalog[0].header); 91 ALLOCATE (catalog[0].lensobj_catalog[0].filename, char, length); 92 sprintf (catalog[0].lensobj_catalog[0].filename, "%s/%s.cpy", path, root); 93 file = filebasename (catalog[0].lensobj_catalog[0].filename); 94 gfits_modify (&catalog[0].header, "LENSOBJ", "%s", 1, file); 95 free (file); 96 72 97 free (path); 73 98 free (root); … … 84 109 } 85 110 if (dvo_catalog_lock (catalog[0].secfilt_catalog, catalog[0].lockmode) != DVO_CAT_OPEN_EMPTY) { 111 fprintf (stderr, "error with file lock\n"); 112 exit (2); 113 } 114 if (dvo_catalog_lock (catalog[0].lensing_catalog, catalog[0].lockmode) != DVO_CAT_OPEN_EMPTY) { 115 fprintf (stderr, "error with file lock\n"); 116 exit (2); 117 } 118 if (dvo_catalog_lock (catalog[0].lensobj_catalog, catalog[0].lockmode) != DVO_CAT_OPEN_EMPTY) { 86 119 fprintf (stderr, "error with file lock\n"); 87 120 exit (2); … … 111 144 ALLOCATE (catalog[0].missing, Missing, 1); 112 145 ALLOCATE (catalog[0].secfilt, SecFilt, 1); 146 ALLOCATE (catalog[0].lensing, Lensing, 1); 147 ALLOCATE (catalog[0].lensobj, Lensobj, 1); 113 148 114 149 /* setup secondary filters to match photcodes: -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_catalog_mef.c
r33649 r37403 7 7 off_t Nmeasure; 8 8 off_t Nmissing; 9 off_t Nlensing; 10 off_t Nlensobj; 9 11 off_t Nitems, Nexpect; 10 12 int Nsecfilt; … … 22 24 if (!gfits_scan (&catalog[0].header, "NMISS", OFF_T_FMT, 1, &Nmissing)) return (FALSE); 23 25 if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0; 26 if (!gfits_scan (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, &Nlensing)) return (FALSE); 27 if (!gfits_scan (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, &Nlensobj)) return (FALSE); 24 28 25 29 /* the OBJID is a counter that uniquely defines an average entry and never changes. if … … 40 44 catalog[0].Nmiss_disk = Nmissing; 41 45 catalog[0].Nsecf_disk = Naverage * Nsecfilt; 46 catalog[0].Nlensing_disk = Nlensing; 47 catalog[0].Nlensobj_disk = Nlensobj; 42 48 43 49 /** Nsecfilt is unusual: it does not list the number of data items in the table … … 50 56 catalog[0].missing = NULL; 51 57 catalog[0].secfilt = NULL; 58 catalog[0].lensing = NULL; 59 catalog[0].lensobj = NULL; 52 60 53 61 /* validate table mode ?*/ … … 101 109 return (FALSE); 102 110 } 103 catalog[0].measure = FtableToMeasure (&ftable, &catalog[0].Nmeasure, &catalog[0].catformat);111 catalog[0].measure = FtableToMeasure (&ftable, catalog[0].average, &catalog[0].Nmeasure, &catalog[0].catformat); 104 112 if (Nmeasure != catalog[0].Nmeas_disk) { 105 113 fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nmeasure, catalog[0].Nmeas_disk); … … 201 209 } 202 210 211 /* read Lensing table header */ 212 if (!gfits_fread_header (catalog[0].f, &header)) { 213 if (VERBOSE) fprintf (stderr, "can't read table lensing header"); 214 return (FALSE); 215 } 216 /* read Lensing table data */ 217 if (catalog[0].catflags & LOAD_LENSING) { 218 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 219 if (VERBOSE) fprintf (stderr, "can't read table lensing data"); 220 return (FALSE); 221 } 222 catalog[0].lensing = FtableToLensing (&ftable, &catalog[0].Nlensing, &catalog[0].catformat); 223 if (Nlensing != catalog[0].Nlensing_disk) { 224 fprintf (stderr, "Warning: mismatch between Nlensing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensing, catalog[0].Nlensing_disk); 225 } 226 catalog[0].Nlensing = catalog[0].Nlensing_disk; 227 catalog[0].Nlensing_off = 0; 228 } else { 229 Nbytes = gfits_data_size (&header); 230 fseeko (catalog[0].f, Nbytes, SEEK_CUR); 231 ALLOCATE (catalog[0].lensing, Lensing, 1); 232 catalog[0].Nlensing = 0; 233 catalog[0].Nlensing_off = catalog[0].Nlensing_disk; 234 } 235 236 /* read Lensobj table header */ 237 if (!gfits_fread_header (catalog[0].f, &header)) { 238 if (VERBOSE) fprintf (stderr, "can't read table lensobj header"); 239 return (FALSE); 240 } 241 /* read Lensobj table data */ 242 if (catalog[0].catflags & LOAD_LENSOBJ) { 243 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 244 if (VERBOSE) fprintf (stderr, "can't read table lensobj data"); 245 return (FALSE); 246 } 247 catalog[0].lensobj = FtableToLensobj (&ftable, &catalog[0].Nlensobj, &catalog[0].catformat); 248 if (Nlensobj != catalog[0].Nlensobj_disk) { 249 fprintf (stderr, "Warning: mismatch between Nlensobj in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensobj, catalog[0].Nlensobj_disk); 250 } 251 catalog[0].Nlensobj = catalog[0].Nlensobj_disk; 252 catalog[0].Nlensobj_off = 0; 253 } else { 254 Nbytes = gfits_data_size (&header); 255 fseeko (catalog[0].f, Nbytes, SEEK_CUR); 256 ALLOCATE (catalog[0].lensobj, Lensobj, 1); 257 catalog[0].Nlensobj = 0; 258 catalog[0].Nlensobj_off = catalog[0].Nlensobj_disk; 259 } 260 203 261 return (TRUE); 204 262 } … … 249 307 gfits_modify (&catalog[0].header, "NMISS", OFF_T_FMT, 1, catalog[0].Nmissing); 250 308 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 309 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, catalog[0].Nlensing); 310 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, catalog[0].Nlensobj); 251 311 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 252 312 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 289 349 290 350 /* write out Measure table (convert to FITS table format) */ 291 MeasureToFtable (&ftable, catalog[0]. measure, catalog[0].Nmeasure, catalog[0].catformat);351 MeasureToFtable (&ftable, catalog[0].average, catalog[0].measure, catalog[0].Nmeasure, catalog[0].catformat); 292 352 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 293 353 fprintf (stderr, "can't write table header"); … … 317 377 Nitems = catalog[0].Naverage * Nsecfilt; 318 378 SecFiltToFtable (&ftable, secfilt, Nitems, catalog[0].catformat); 379 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 380 fprintf (stderr, "can't write table header"); 381 goto failure; 382 } 383 if (!gfits_fwrite_table (catalog[0].f, &ftable)) { 384 fprintf (stderr, "can't write table data"); 385 goto failure; 386 } 387 gfits_free_table (&ftable); 388 gfits_free_header (&header); 389 390 /* write out Lensing table (convert to FITS table format) */ 391 LensingToFtable (&ftable, catalog[0].lensing, catalog[0].Nlensing, catalog[0].catformat); 392 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 393 fprintf (stderr, "can't write table header"); 394 goto failure; 395 } 396 if (!gfits_fwrite_table (catalog[0].f, &ftable)) { 397 fprintf (stderr, "can't write table data"); 398 goto failure; 399 } 400 gfits_free_table (&ftable); 401 gfits_free_header (&header); 402 403 /* write out Lensobj table (convert to FITS table format) */ 404 LensobjToFtable (&ftable, catalog[0].lensobj, catalog[0].Nlensobj, catalog[0].catformat); 319 405 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 320 406 fprintf (stderr, "can't write table header"); … … 356 442 secfilt header 357 443 secfilt table 444 lensing header 445 lensing table 446 lensobj header 447 lensobj table 358 448 */ 359 449 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_catalog_raw.c
r34260 r37403 90 90 FORMAT_CASE (PS1_V3, PS1_V3); 91 91 FORMAT_CASE (PS1_V4, PS1_V4); 92 FORMAT_CASE (PS1_V5, PS1_V5); 92 93 FORMAT_CASE (PS1_REF, PS1_REF); 93 94 … … 144 145 /* read and convert the measures (use a macro to clean this up?) */ 145 146 if (catalog[0].catflags & LOAD_MEAS) { 146 catalog[0].measure = ReadRawMeasure (catalog[0].f, catalog[0]. Nmeasure, catalog[0].catformat);147 catalog[0].measure = ReadRawMeasure (catalog[0].f, catalog[0].average, catalog[0].Nmeasure, catalog[0].catformat); 147 148 } else { 148 149 /* skip over measures */ … … 284 285 if (catalog[0].catformat == DVO_FORMAT_PS1_V3) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_V3"); 285 286 if (catalog[0].catformat == DVO_FORMAT_PS1_V4) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_V4"); 287 if (catalog[0].catformat == DVO_FORMAT_PS1_V5) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_V5"); 286 288 if (catalog[0].catformat == DVO_FORMAT_PS1_REF) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_REF"); 287 289 … … 303 305 /* write averages and measures */ 304 306 WriteRawAverage (f, catalog[0].average, catalog[0].Naverage, catalog[0].catformat, primary); 305 WriteRawMeasure (f, catalog[0]. measure, catalog[0].Nmeasure, catalog[0].catformat);307 WriteRawMeasure (f, catalog[0].average, catalog[0].measure, catalog[0].Nmeasure, catalog[0].catformat); 306 308 307 309 /* write missing data */ … … 387 389 FORMAT_CASE (PS1_V3, PS1_V3); 388 390 FORMAT_CASE (PS1_V4, PS1_V4); 391 FORMAT_CASE (PS1_V5, PS1_V5); 389 392 FORMAT_CASE (PS1_REF, PS1_REF); 390 393 … … 438 441 FORMAT_CASE (PS1_V3, PS1_V3); 439 442 FORMAT_CASE (PS1_V4, PS1_V4); 443 FORMAT_CASE (PS1_V5, PS1_V5); 440 444 FORMAT_CASE (PS1_REF, PS1_REF); 441 445 … … 451 455 /** Average / Raw Table conversions **/ 452 456 453 Measure *ReadRawMeasure (FILE *f, off_t Nmeasure, char format) {457 Measure *ReadRawMeasure (FILE *f, Average *average, off_t Nmeasure, char format) { 454 458 455 459 Measure *measure; … … 467 471 } \ 468 472 gfits_convert_Measure_##TYPE (tmpMeasure, sizeof(Measure_##TYPE), Nmeasure); \ 469 measure = Measure_##TYPE##_ToInternal ( tmpMeasure, Nmeasure); \473 measure = Measure_##TYPE##_ToInternal (average, tmpMeasure, Nmeasure); \ 470 474 free (tmpMeasure); \ 471 475 break; } … … 481 485 } 482 486 gfits_convert_Measure (measure, sizeof(Measure), Nmeasure); 487 break; } 488 489 FORMAT_CASE (LONEOS, Loneos); 490 FORMAT_CASE (ELIXIR, Elixir); 491 FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 492 FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 493 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 494 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 495 FORMAT_CASE (PS1_V1, PS1_V1); 496 FORMAT_CASE (PS1_V2, PS1_V2); 497 FORMAT_CASE (PS1_V3, PS1_V3); 498 FORMAT_CASE (PS1_V5, PS1_V5); 499 FORMAT_CASE (PS1_REF, PS1_REF); 500 501 default: 502 fprintf (stderr, "error reading measures\n"); 503 return (NULL); 504 } 505 # undef FORMAT_CASE 506 507 return (measure); 508 } 509 510 /* accepts and converts internal measure formats and outputs 511 raw data in the specified format */ 512 int WriteRawMeasure (FILE *f, Average *average, Measure *measure, off_t Nmeasure, char format) { 513 514 // this macro generates the case statements for each type 515 # define FORMAT_CASE(NAME,TYPE) \ 516 case DVO_FORMAT_##NAME: { \ 517 off_t nitems; \ 518 Measure_##TYPE *tmpMeasure; \ 519 tmpMeasure = MeasureInternalTo_##TYPE (average, measure, Nmeasure); \ 520 gfits_convert_Measure_##TYPE (tmpMeasure, sizeof(Measure_##TYPE), Nmeasure); \ 521 nitems = fwrite (tmpMeasure, sizeof(Measure_##TYPE), Nmeasure, f); \ 522 free (tmpMeasure); \ 523 if (nitems != Nmeasure) { \ 524 fprintf (stderr, "failed to write measures ("OFF_T_FMT" vs "OFF_T_FMT")\n", nitems, Nmeasure); \ 525 return (FALSE); \ 526 } \ 527 break; } 528 529 switch (format) { 530 case DVO_FORMAT_INTERNAL: { 531 off_t nitems; 532 gfits_convert_Measure (measure, sizeof(Measure), Nmeasure); 533 nitems = fwrite (measure, sizeof(Measure), Nmeasure, f); 534 if (nitems != Nmeasure) { 535 fprintf (stderr, "failed to write measures ("OFF_T_FMT" vs "OFF_T_FMT")\n", nitems, Nmeasure); 536 return (FALSE); 537 } 483 538 break; } 484 539 … … 493 548 FORMAT_CASE (PS1_V3, PS1_V3); 494 549 FORMAT_CASE (PS1_V4, PS1_V4); 495 FORMAT_CASE (PS1_REF, PS1_REF); 496 497 default: 498 fprintf (stderr, "error reading measures\n"); 499 return (NULL); 500 } 501 # undef FORMAT_CASE 502 503 return (measure); 504 } 505 506 /* accepts and converts internal measure formats and outputs 507 raw data in the specified format */ 508 int WriteRawMeasure (FILE *f, Measure *measure, off_t Nmeasure, char format) { 509 510 // this macro generates the case statements for each type 511 # define FORMAT_CASE(NAME,TYPE) \ 512 case DVO_FORMAT_##NAME: { \ 513 off_t nitems; \ 514 Measure_##TYPE *tmpMeasure; \ 515 tmpMeasure = MeasureInternalTo_##TYPE (measure, Nmeasure); \ 516 gfits_convert_Measure_##TYPE (tmpMeasure, sizeof(Measure_##TYPE), Nmeasure); \ 517 nitems = fwrite (tmpMeasure, sizeof(Measure_##TYPE), Nmeasure, f); \ 518 free (tmpMeasure); \ 519 if (nitems != Nmeasure) { \ 520 fprintf (stderr, "failed to write measures ("OFF_T_FMT" vs "OFF_T_FMT")\n", nitems, Nmeasure); \ 521 return (FALSE); \ 522 } \ 523 break; } 524 525 switch (format) { 526 case DVO_FORMAT_INTERNAL: { 527 off_t nitems; 528 gfits_convert_Measure (measure, sizeof(Measure), Nmeasure); 529 nitems = fwrite (measure, sizeof(Measure), Nmeasure, f); 530 if (nitems != Nmeasure) { 531 fprintf (stderr, "failed to write measures ("OFF_T_FMT" vs "OFF_T_FMT")\n", nitems, Nmeasure); 532 return (FALSE); 533 } 534 break; } 535 536 FORMAT_CASE (LONEOS, Loneos); 537 FORMAT_CASE (ELIXIR, Elixir); 538 FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 539 FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 540 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 541 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 542 FORMAT_CASE (PS1_V1, PS1_V1); 543 FORMAT_CASE (PS1_V2, PS1_V2); 544 FORMAT_CASE (PS1_V3, PS1_V3); 545 FORMAT_CASE (PS1_V4, PS1_V4); 550 FORMAT_CASE (PS1_V5, PS1_V5); 546 551 FORMAT_CASE (PS1_REF, PS1_REF); 547 552 … … 599 604 FORMAT_CASE (PS1_V3, PS1_V3); 600 605 FORMAT_CASE (PS1_V4, PS1_V4); 606 FORMAT_CASE (PS1_V5, PS1_V5); 601 607 FORMAT_CASE (PS1_REF, PS1_REF); 602 608 … … 650 656 FORMAT_CASE (PS1_V3, PS1_V3); 651 657 FORMAT_CASE (PS1_V4, PS1_V4); 658 FORMAT_CASE (PS1_V5, PS1_V5); 652 659 FORMAT_CASE (PS1_REF, PS1_REF); 653 660 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_catalog_split.c
r34844 r37403 134 134 if (!gfits_scan (&catalog[0].header, name, "%s", 1, string)) { 135 135 free (path); 136 // databases created prior to ~2014.07.01 did not have the LENSING or LENSOBJ paths in their headers. 137 // in these cases, we do not try to lock or open the relevant file 138 if (!strcmp (name, "LENSING")) return (DVO_CAT_OPEN_EMPTY); 139 if (!strcmp (name, "LENSOBJ")) return (DVO_CAT_OPEN_EMPTY); 136 140 return (DVO_CAT_OPEN_FAIL); 137 141 } … … 161 165 fseeko (subcat[0].f, Nskip, SEEK_CUR); 162 166 163 /* read Measuretable header */167 /* read table header */ 164 168 if (!gfits_fread_header (subcat[0].f, header)) { 165 169 if (VERBOSE) fprintf (stderr, "can't read %s PHU header\n", name); … … 176 180 off_t Nmeasure; 177 181 off_t Nmissing; 182 off_t Nlensing; 183 off_t Nlensobj; 178 184 off_t Nitems; 179 185 int status, Nsecfilt; … … 190 196 191 197 /* get the components from the header - these duplicate information in the split files (NAXIS2) */ 198 // NSTARS, NMEAS, NMISS are required; NLENSING, NLENSOBJ are not (0 if not found) 192 199 if (!gfits_scan (&catalog[0].header, "NSTARS", OFF_T_FMT, 1, &Naverage)) return (FALSE); 193 200 if (!gfits_scan (&catalog[0].header, "NMEAS", OFF_T_FMT, 1, &Nmeasure)) return (FALSE); 194 201 if (!gfits_scan (&catalog[0].header, "NMISS", OFF_T_FMT, 1, &Nmissing)) return (FALSE); 195 if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0; 202 if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0; 203 if (!gfits_scan (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, &Nlensing)) Nlensing = 0; 204 if (!gfits_scan (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, &Nlensobj)) Nlensobj = 0; 196 205 197 206 /* the OBJID is a counter that uniquely defines an average entry and never changes. if … … 212 221 catalog[0].Nmiss_disk = Nmissing; 213 222 catalog[0].Nsecf_disk = Naverage * Nsecfilt; 223 catalog[0].Nlensing_disk = Nlensing; 224 catalog[0].Nlensobj_disk = Nlensobj; 214 225 215 226 /** Nsecfilt is unusual: it does not list the number of data items in the table … … 222 233 catalog[0].missing = NULL; 223 234 catalog[0].secfilt = NULL; 235 catalog[0].lensing = NULL; 236 catalog[0].lensobj = NULL; 224 237 225 238 /*** Average Table ***/ … … 277 290 } 278 291 /* convert data format to internal : returns number of row read in Nmeasure */ 279 catalog[0].measure = FtableToMeasure (&ftable, &Nmeasure, &catalog[0].catformat);292 catalog[0].measure = FtableToMeasure (&ftable, catalog[0].average, &Nmeasure, &catalog[0].catformat); 280 293 if (Nmeasure != catalog[0].Nmeas_disk) { 281 294 fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nmeasure, catalog[0].Nmeas_disk); … … 372 385 gfits_free_header (ftable.header); 373 386 387 /*** Lensing Table ***/ 388 if (!(catalog[0].catflags & SKIP_LENSING)) { 389 // unless we specify 'skip', we still need to load the Lensing table 390 status = dvo_catalog_open_subcat (catalog, &catalog[0].lensing_catalog, ftable.header, "LENSING", VERBOSE); 391 if (status == DVO_CAT_OPEN_FAIL) { 392 return (FALSE); 393 } 394 // the Lensing file need not exist, unless we expect data to exist 395 if ((status == DVO_CAT_OPEN_EMPTY) && (catalog[0].Nlensing_disk > 0)) { 396 return (FALSE); 397 } 398 } 399 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_LENSING)) { 400 // only read the Lensing table if the file actually exists 401 /* read Lensing table data */ 402 if (!gfits_fread_ftable_data (catalog[0].lensing_catalog[0].f, &ftable, FALSE)) { 403 if (VERBOSE) fprintf (stderr, "can't read table lensing data\n"); 404 return (FALSE); 405 } 406 /* convert data format to internal : returns number of row read in Nlensing */ 407 catalog[0].lensing = FtableToLensing (&ftable, &Nlensing, &catalog[0].catformat); 408 if (Nlensing != catalog[0].Nlensing_disk) { 409 fprintf (stderr, "Warning: mismatch between Nlensing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensing, catalog[0].Nlensing_disk); 410 } 411 catalog[0].Nlensing = catalog[0].Nlensing_disk; 412 catalog[0].Nlensing_off = 0; 413 } else { 414 if (catalog[0].lensing_catalog) { 415 gfits_free_header (&catalog[0].lensing_catalog[0].header); 416 } else { 417 ALLOCATE (catalog[0].lensing_catalog, Catalog, 1); 418 dvo_catalog_init (catalog[0].lensing_catalog, TRUE); 419 } 420 gfits_create_header (&catalog[0].lensing_catalog[0].header); 421 ALLOCATE (catalog[0].lensing, Lensing, 1); 422 catalog[0].Nlensing = 0; 423 catalog[0].Nlensing_off = catalog[0].Nlensing_disk; 424 } 425 gfits_free_header (&header); 426 427 /*** Lensobj Table ***/ 428 if (!(catalog[0].catflags & SKIP_LENSOBJ)) { 429 // unless we specify 'skip', we still need to load the 430 status = dvo_catalog_open_subcat (catalog, &catalog[0].lensobj_catalog, ftable.header, "LENSOBJ", VERBOSE); 431 if (status == DVO_CAT_OPEN_FAIL) { 432 return (FALSE); 433 } 434 // the Lensobj file need not exist, unless we expect data to exist 435 if ((status == DVO_CAT_OPEN_EMPTY) && (catalog[0].Nlensobj_disk > 0)) { 436 return (FALSE); 437 } 438 } 439 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_LENSOBJ)) { 440 // only read the Lensobj table if the file actually exists 441 /* read Lensobj table data */ 442 if (!gfits_fread_ftable_data (catalog[0].lensobj_catalog[0].f, &ftable, FALSE)) { 443 if (VERBOSE) fprintf (stderr, "can't read table lensobj data\n"); 444 return (FALSE); 445 } 446 /* convert data format to internal : returns number of row read in Nlensobj */ 447 catalog[0].lensobj = FtableToLensobj (&ftable, &Nlensobj, &catalog[0].catformat); 448 if (Nlensobj != catalog[0].Nlensobj_disk) { 449 fprintf (stderr, "Warning: mismatch between Nlensobj in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensobj, catalog[0].Nlensobj_disk); 450 } 451 catalog[0].Nlensobj = catalog[0].Nlensobj_disk; 452 catalog[0].Nlensobj_off = 0; 453 } else { 454 if (catalog[0].lensobj_catalog) { 455 gfits_free_header (&catalog[0].lensobj_catalog[0].header); 456 } else { 457 ALLOCATE (catalog[0].lensobj_catalog, Catalog, 1); 458 dvo_catalog_init (catalog[0].lensobj_catalog, TRUE); 459 } 460 gfits_create_header (&catalog[0].lensobj_catalog[0].header); 461 ALLOCATE (catalog[0].lensobj, Lensobj, 1); 462 catalog[0].Nlensobj = 0; 463 catalog[0].Nlensobj_off = catalog[0].Nlensobj_disk; 464 } 465 gfits_free_header (&header); 466 374 467 return (TRUE); 375 468 } … … 380 473 381 474 off_t Nbytes; 382 off_t Naverage, Nexpect, Nitems, Nmeasure, Nmissing ;475 off_t Naverage, Nexpect, Nitems, Nmeasure, Nmissing, Nlensing, Nlensobj; 383 476 Header header; 384 477 FTable ftable; … … 476 569 477 570 /* convert data format to internal : returns number of row read in Nmeasure */ 478 catalog[0].measure = FtableToMeasure (&ftable, &Nmeasure, &catalog[0].catformat);571 catalog[0].measure = FtableToMeasure (&ftable, catalog[0].average, &Nmeasure, &catalog[0].catformat); 479 572 if (Nmeasure != Nrows) { 480 573 // XXX this condition denotes the eof has been reached; not an error or a warning … … 519 612 catalog[0].Nmiss_off = start; 520 613 } 614 615 // XXX check the open status of the catalog 616 if (catalog[0].catflags & LOAD_LENSING) { 617 618 Catalog *subcat = catalog[0].lensing_catalog; 619 620 /* move pointer past header -- must be already read (load_catalog) */ 621 Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header); 622 fseeko (subcat[0].f, Nbytes, SEEK_SET); 623 624 /* read Lensing table header */ 625 if (!gfits_fread_header (subcat[0].f, &header)) { 626 if (VERBOSE) fprintf (stderr, "can't read table lensing header"); 627 return (FALSE); 628 } 629 /* read Lensing table data : format is irrelevant here */ 630 if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) { 631 if (VERBOSE) fprintf (stderr, "can't read table lensing data"); 632 return (FALSE); 633 } 634 635 /* convert data format to internal : returns number of row read in Nlensing */ 636 catalog[0].lensing = FtableToLensing (&ftable, &Nlensing, &catalog[0].catformat); 637 if (Nlensing != Nrows) { 638 // XXX this condition denotes the eof has been reached; not an error or a warning 639 // fprintf (stderr, "Warning: mismatch between Nlensing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensing, Nrows); 640 } 641 gfits_free_header (&header); 642 catalog[0].Nlensing = Nlensing; 643 catalog[0].Nlensing_off = start; 644 } 645 646 // XXX check the open status of the catalog 647 if (catalog[0].catflags & LOAD_LENSOBJ) { 648 649 Catalog *subcat = catalog[0].lensobj_catalog; 650 651 /* move pointer past header -- must be already read (load_catalog) */ 652 Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header); 653 fseeko (subcat[0].f, Nbytes, SEEK_SET); 654 655 /* read Lensobj table header */ 656 if (!gfits_fread_header (subcat[0].f, &header)) { 657 if (VERBOSE) fprintf (stderr, "can't read table lensobj header"); 658 return (FALSE); 659 } 660 /* read Lensobj table data : format is irrelevant here */ 661 if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) { 662 if (VERBOSE) fprintf (stderr, "can't read table lensobj data"); 663 return (FALSE); 664 } 665 666 /* convert data format to internal : returns number of row read in Nlensobj */ 667 catalog[0].lensobj = FtableToLensobj (&ftable, &Nlensobj, &catalog[0].catformat); 668 if (Nlensobj != Nrows) { 669 // XXX this condition denotes the eof has been reached; not an error or a warning 670 // fprintf (stderr, "Warning: mismatch between Nlensobj in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensobj, Nrows); 671 } 672 gfits_free_header (&header); 673 catalog[0].Nlensobj = Nlensobj; 674 catalog[0].Nlensobj_off = start; 675 } 676 521 677 return (TRUE); 522 678 } … … 530 686 SecFilt *primary, *secfilt; 531 687 int Nsecfilt; 532 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new ;688 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new; 533 689 off_t first, start, Nrows; 534 690 … … 561 717 Nmiss_disk_new = MAX (catalog[0].Nmiss_disk, catalog[0].Nmissing + catalog[0].Nmiss_off); 562 718 Nsecf_disk_new = MAX (catalog[0].Nsecf_disk, catalog[0].Naverage*Nsecfilt + catalog[0].Nsecf_off); 719 Nlensing_disk_new = MAX (catalog[0].Nlensing_disk, catalog[0].Nlensing + catalog[0].Nlensing_off); 720 Nlensobj_disk_new = MAX (catalog[0].Nlensobj_disk, catalog[0].Nlensobj + catalog[0].Nlensobj_off); 563 721 564 722 /* make sure header is consistent with data */ … … 567 725 gfits_modify (&catalog[0].header, "NMISS", OFF_T_FMT, 1, Nmiss_disk_new); 568 726 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 727 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 728 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 569 729 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 570 730 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 621 781 assert (catalog[0].Nmeas_disk >= catalog[0].Nmeas_off); 622 782 623 // convert to external table format 624 if (!MeasureToFtable (&ftable, &catalog[0].measure[first], Nrows, catalog[0].catformat)) {783 // convert to external table format (note that the block above does not damage or free catalog.average) 784 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat)) { 625 785 fprintf (stderr, "trouble converting format\n"); 626 786 goto failure; … … 679 839 if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecf_disk, Nsecf_disk_new)) { 680 840 fprintf (stderr, "failure writing SecFilt table\n"); 841 goto failure; 842 } 843 gfits_free_header (&header); 844 gfits_free_table (&ftable); 845 } 846 847 /*** Lensing Table ***/ 848 if ((catalog[0].catflags & LOAD_LENSING) && (catalog[0].lensing != NULL)) { 849 850 first = 0; // first row in memory to write 851 start = catalog[0].Nlensing_off; // first disk row to write 852 Nrows = catalog[0].Nlensing - first; 853 854 assert (Nrows >= 0); 855 assert (first >= 0); 856 assert (first <= catalog[0].Nlensing); 857 assert (catalog[0].Nlensing_disk >= catalog[0].Nlensing_off); 858 859 // convert to external table format (note that the block above does not damage or free catalog.average) 860 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat)) { 861 fprintf (stderr, "trouble converting format\n"); 862 goto failure; 863 } 864 865 // write out Lensing table 866 if (!dvo_catalog_save_subcat (catalog[0].lensing_catalog, &ftable, start, Nrows, catalog[0].Nlensing_disk, Nlensing_disk_new)) { 867 fprintf (stderr, "trouble writing Lensing table\n"); 868 goto failure; 869 } 870 gfits_free_header (&header); 871 gfits_free_table (&ftable); 872 } 873 874 /*** Lensobj Table ***/ 875 if ((catalog[0].catflags & LOAD_LENSOBJ) && (catalog[0].lensobj != NULL)) { 876 877 first = 0; // first row in memory to write 878 start = catalog[0].Nlensobj_off; // first disk row to write 879 Nrows = catalog[0].Nlensobj - first; 880 881 assert (Nrows >= 0); 882 assert (first >= 0); 883 assert (first <= catalog[0].Nlensobj); 884 assert (catalog[0].Nlensobj_disk >= catalog[0].Nlensobj_off); 885 886 // convert to external table format (note that the block above does not damage or free catalog.average) 887 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat)) { 888 fprintf (stderr, "trouble converting format\n"); 889 goto failure; 890 } 891 892 // write out Lensobj table 893 if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) { 894 fprintf (stderr, "trouble writing Lensobj table\n"); 681 895 goto failure; 682 896 } … … 711 925 SecFilt *primary, *secfilt; 712 926 int Nsecfilt; 713 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new ;927 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new; 714 928 off_t first, start, Nrows; 715 929 … … 734 948 if (catalog[0].Nsecf_off > 0) { 735 949 fprintf (stderr, "ERROR: only partial catalog (Secfilt) was loaded\n"); 950 goto failure; 951 } 952 if (catalog[0].Nlensing_off > 0) { 953 fprintf (stderr, "ERROR: only partial catalog (Lensing) was loaded\n"); 954 goto failure; 955 } 956 if (catalog[0].Nlensobj_off > 0) { 957 fprintf (stderr, "ERROR: only partial catalog (Lensobj) was loaded\n"); 736 958 goto failure; 737 959 } … … 760 982 Nmiss_disk_new = catalog[0].Nmissing; 761 983 Nsecf_disk_new = catalog[0].Naverage*Nsecfilt; 984 Nlensing_disk_new = catalog[0].Nlensing; 985 Nlensobj_disk_new = catalog[0].Nlensobj; 762 986 763 987 /* make sure header is consistent with data */ … … 766 990 gfits_modify (&catalog[0].header, "NMISS", OFF_T_FMT, 1, Nmiss_disk_new); 767 991 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 992 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 993 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 768 994 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 769 995 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 821 1047 822 1048 // convert to external table format 823 if (!MeasureToFtable (&ftable, &catalog[0].measure[first], Nrows, catalog[0].catformat)) {1049 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat)) { 824 1050 fprintf (stderr, "trouble converting format\n"); 825 1051 goto failure; … … 878 1104 if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecf_disk, Nsecf_disk_new)) { 879 1105 fprintf (stderr, "failure writing SecFilt table\n"); 1106 goto failure; 1107 } 1108 gfits_free_header (&header); 1109 gfits_free_table (&ftable); 1110 } 1111 1112 /*** Lensing Table ***/ 1113 if ((catalog[0].catflags & LOAD_LENSING) && (catalog[0].lensing != NULL)) { 1114 1115 first = 0; // first row in memory to write 1116 start = catalog[0].Nlensing_off; // first disk row to write 1117 Nrows = catalog[0].Nlensing - first; 1118 1119 assert (Nrows >= 0); 1120 assert (first >= 0); 1121 assert (first <= catalog[0].Nlensing); 1122 assert (catalog[0].Nlensing_disk >= catalog[0].Nlensing_off); 1123 1124 // convert to external table format 1125 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat)) { 1126 fprintf (stderr, "trouble converting format\n"); 1127 goto failure; 1128 } 1129 1130 // write out Lensing table 1131 if (!dvo_catalog_save_subcat (catalog[0].lensing_catalog, &ftable, start, Nrows, catalog[0].Nlensing_disk, Nlensing_disk_new)) { 1132 fprintf (stderr, "trouble writing Lensing table\n"); 1133 goto failure; 1134 } 1135 gfits_free_header (&header); 1136 gfits_free_table (&ftable); 1137 } 1138 1139 /*** Lensobj Table ***/ 1140 if ((catalog[0].catflags & LOAD_LENSOBJ) && (catalog[0].lensobj != NULL)) { 1141 1142 first = 0; // first row in memory to write 1143 start = catalog[0].Nlensobj_off; // first disk row to write 1144 Nrows = catalog[0].Nlensobj - first; 1145 1146 assert (Nrows >= 0); 1147 assert (first >= 0); 1148 assert (first <= catalog[0].Nlensobj); 1149 assert (catalog[0].Nlensobj_disk >= catalog[0].Nlensobj_off); 1150 1151 // convert to external table format 1152 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat)) { 1153 fprintf (stderr, "trouble converting format\n"); 1154 goto failure; 1155 } 1156 1157 // write out Lensobj table 1158 if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) { 1159 fprintf (stderr, "trouble writing Lensobj table\n"); 880 1160 goto failure; 881 1161 } … … 909 1189 SecFilt *primary, *secfilt; 910 1190 int Nsecfilt; 911 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new ;1191 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new; 912 1192 off_t first, start, Nrows; 913 1193 … … 939 1219 Nmiss_disk_new = MAX (catalog[0].Nmiss_disk, catalog[0].Nmissing + catalog[0].Nmiss_off); 940 1220 Nsecf_disk_new = MAX (catalog[0].Nsecf_disk, catalog[0].Naverage*Nsecfilt + catalog[0].Nsecf_off); 1221 Nlensing_disk_new = MAX (catalog[0].Nlensing_disk, catalog[0].Nlensing + catalog[0].Nlensing_off); 1222 Nlensobj_disk_new = MAX (catalog[0].Nlensobj_disk, catalog[0].Nlensobj + catalog[0].Nlensobj_off); 941 1223 942 1224 /* make sure header is consistent with data */ … … 945 1227 gfits_modify (&catalog[0].header, "NMISS", OFF_T_FMT, 1, Nmiss_disk_new); 946 1228 gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt); 1229 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 1230 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 947 1231 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 948 1232 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 1000 1284 1001 1285 // convert to external table format 1002 if (!MeasureToFtable (&ftable, &catalog[0].measure[first], Nrows, catalog[0].catformat)) { 1286 // XXX does catalog.measure have averef correctly set up? 1287 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat)) { 1003 1288 fprintf (stderr, "trouble converting format\n"); 1004 1289 goto failure; … … 1058 1343 if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecf_disk, Nsecf_disk_new)) { 1059 1344 fprintf (stderr, "failure writing SecFilt table\n"); 1345 goto failure; 1346 } 1347 gfits_free_header (&header); 1348 gfits_free_table (&ftable); 1349 } 1350 1351 /*** Lensing Table ***/ 1352 if (catalog[0].lensing != NULL) { 1353 1354 first = catalog[0].Nlensing_disk - catalog[0].Nlensing_off; // first row in memory to write 1355 start = catalog[0].Nlensing_disk; // first disk row to write 1356 Nrows = catalog[0].Nlensing - first; 1357 1358 assert (Nrows >= 0); 1359 assert (first >= 0); 1360 assert (first <= catalog[0].Nlensing); 1361 assert (catalog[0].Nlensing_disk >= catalog[0].Nlensing_off); 1362 1363 // convert to external table format 1364 // XXX does catalog.lensing have averef correctly set up? 1365 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat)) { 1366 fprintf (stderr, "trouble converting format\n"); 1367 goto failure; 1368 } 1369 1370 // write out Lensing table 1371 if (!dvo_catalog_save_subcat (catalog[0].lensing_catalog, &ftable, start, Nrows, catalog[0].Nlensing_disk, Nlensing_disk_new)) { 1372 fprintf (stderr, "trouble writing Lensing table\n"); 1373 goto failure; 1374 } 1375 gfits_free_header (&header); 1376 gfits_free_table (&ftable); 1377 } 1378 1379 /*** Lensobj Table ***/ 1380 if (catalog[0].lensobj != NULL) { 1381 1382 first = catalog[0].Nlensobj_disk - catalog[0].Nlensobj_off; // first row in memory to write 1383 start = catalog[0].Nlensobj_disk; // first disk row to write 1384 Nrows = catalog[0].Nlensobj - first; 1385 1386 assert (Nrows >= 0); 1387 assert (first >= 0); 1388 assert (first <= catalog[0].Nlensobj); 1389 assert (catalog[0].Nlensobj_disk >= catalog[0].Nlensobj_off); 1390 1391 // convert to external table format 1392 // XXX does catalog.lensobj have averef correctly set up? 1393 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat)) { 1394 fprintf (stderr, "trouble converting format\n"); 1395 goto failure; 1396 } 1397 1398 // write out Lensobj table 1399 if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) { 1400 fprintf (stderr, "trouble writing Lensobj table\n"); 1060 1401 goto failure; 1061 1402 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert.c
r36680 r37403 41 41 CONVERT_FORMAT ("DVO_AVERAGE_PS1_V3", PS1_V3); 42 42 CONVERT_FORMAT ("DVO_AVERAGE_PS1_V4", PS1_V4); 43 CONVERT_FORMAT ("DVO_AVERAGE_PS1_V5", PS1_V5); 43 44 CONVERT_FORMAT ("DVO_AVERAGE_PS1_REF", PS1_REF); 44 45 # undef CONVERT_FORMAT … … 76 77 free (tmpAverage); 77 78 *format = DVO_FORMAT_PS1_V4; 79 return (average); 80 } 81 82 // block to convert old tables (PS1_V5 versions made during development) 83 if (!strcmp (extname, "DVO_AVERAGE_PS1_V5") && (ftable[0].header[0].Naxis[0] == 184)) { 84 Average_PS1_V5alt *tmpAverage; 85 tmpAverage = gfits_table_get_Average_PS1_V5alt (ftable, Naverage, NULL); 86 if (!tmpAverage) { 87 fprintf (stderr, "ERROR: failed to read averages\n"); 88 exit (2); 89 } 90 average = Average_PS1_V5alt_ToInternal (tmpAverage, *Naverage); 91 free (tmpAverage); 92 *format = DVO_FORMAT_PS1_V5; 78 93 return (average); 79 94 } … … 112 127 CONVERT_FORMAT ("DVO_AVERAGE_PS1_V3", PS1_V3, PS1_V3); 113 128 CONVERT_FORMAT ("DVO_AVERAGE_PS1_V4", PS1_V4, PS1_V4); 129 CONVERT_FORMAT ("DVO_AVERAGE_PS1_V5", PS1_V5, PS1_V5); 114 130 CONVERT_FORMAT ("DVO_AVERAGE_PS1_REF", PS1_REF, PS1_REF); 115 131 # undef CONVERT_FORMAT … … 147 163 FORMAT_CASE (PS1_V3, PS1_V3); 148 164 FORMAT_CASE (PS1_V4, PS1_V4); 165 FORMAT_CASE (PS1_V5, PS1_V5); 149 166 FORMAT_CASE (PS1_REF, PS1_REF); 150 167 # undef FORMAT_CASE … … 159 176 /*** Measure / FTable conversion functions ***/ 160 177 161 Measure *FtableToMeasure (FTable *ftable, off_t *Nmeasure, char *format) { 178 // FtableToMeasure needs the Average since old formats stored measure.dR,dD only 179 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, char *format) { 162 180 163 181 Measure *measure; … … 179 197 exit (2); 180 198 } 181 measure = Measure_PS1_V4alt_ToInternal (tmpMeasure, *Nmeasure); 199 myAssert (average, "conversion to internal needs average table"); 200 measure = Measure_PS1_V4alt_ToInternal (average, tmpMeasure, *Nmeasure); 182 201 free (tmpMeasure); 183 202 *format = DVO_FORMAT_PS1_V4; … … 185 204 } 186 205 187 # define CONVERT_FORMAT(NAME, FORMAT, TYPE )\188 if (!strcmp (extname, NAME)) { \189 Measure_##TYPE *tmpMeasure; \206 # define CONVERT_FORMAT(NAME, FORMAT, TYPE, ABS_COORDS) \ 207 if (!strcmp (extname, NAME)) { \ 208 Measure_##TYPE *tmpMeasure; \ 190 209 tmpMeasure = gfits_table_get_Measure_##TYPE (ftable, Nmeasure, NULL); \ 191 if (!tmpMeasure) { \ 192 fprintf (stderr, "ERROR: failed to read measures\n"); \ 193 exit (2); \ 194 } \ 195 measure = Measure_##TYPE##_ToInternal (tmpMeasure, *Nmeasure); \ 196 free (tmpMeasure); \ 197 *format = DVO_FORMAT_##FORMAT; \ 210 if (!tmpMeasure) { \ 211 fprintf (stderr, "ERROR: failed to read measures\n"); \ 212 exit (2); \ 213 } \ 214 myAssert (ABS_COORDS || average, "conversion to internal needs average table"); \ 215 measure = Measure_##TYPE##_ToInternal (average, tmpMeasure, *Nmeasure); \ 216 free (tmpMeasure); \ 217 *format = DVO_FORMAT_##FORMAT; \ 198 218 return (measure); } 199 219 … … 208 228 } 209 229 210 CONVERT_FORMAT ("DVO_MEASURE_ELIXIR", ELIXIR, Elixir); 211 CONVERT_FORMAT ("DVO_MEASURE_LONEOS", LONEOS, Loneos); 212 CONVERT_FORMAT ("DVO_MEASURE_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0); 213 CONVERT_FORMAT ("DVO_MEASURE_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1); 214 CONVERT_FORMAT ("DVO_MEASURE_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 215 CONVERT_FORMAT ("DVO_MEASURE_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 216 CONVERT_FORMAT ("DVO_MEASURE_PS1_V1", PS1_V1, PS1_V1); 217 CONVERT_FORMAT ("DVO_MEASURE_PS1_V2", PS1_V2, PS1_V2); 218 CONVERT_FORMAT ("DVO_MEASURE_PS1_V3", PS1_V3, PS1_V3); 219 CONVERT_FORMAT ("DVO_MEASURE_PS1_V4", PS1_V4, PS1_V4); 220 CONVERT_FORMAT ("DVO_MEASURE_PS1_REF", PS1_REF, PS1_REF); 230 CONVERT_FORMAT ("DVO_MEASURE_ELIXIR", ELIXIR, Elixir, FALSE); 231 CONVERT_FORMAT ("DVO_MEASURE_LONEOS", LONEOS, Loneos, FALSE); 232 CONVERT_FORMAT ("DVO_MEASURE_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0, FALSE); 233 CONVERT_FORMAT ("DVO_MEASURE_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1, FALSE); 234 CONVERT_FORMAT ("DVO_MEASURE_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1, FALSE); 235 CONVERT_FORMAT ("DVO_MEASURE_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2, FALSE); 236 CONVERT_FORMAT ("DVO_MEASURE_PS1_V1", PS1_V1, PS1_V1, FALSE); 237 CONVERT_FORMAT ("DVO_MEASURE_PS1_V2", PS1_V2, PS1_V2, FALSE); 238 CONVERT_FORMAT ("DVO_MEASURE_PS1_V3", PS1_V3, PS1_V3, FALSE); 239 CONVERT_FORMAT ("DVO_MEASURE_PS1_V4", PS1_V4, PS1_V4, FALSE); 240 CONVERT_FORMAT ("DVO_MEASURE_PS1_V5", PS1_V5, PS1_V5, TRUE); 241 CONVERT_FORMAT ("DVO_MEASURE_PS1_REF", PS1_REF, PS1_REF, FALSE); 221 242 # undef CONVERT_FORMAT 222 243 … … 227 248 } 228 249 229 int MeasureToFtable (FTable *ftable, Measure *measure, off_t Nmeasure, char format) { 230 231 # define FORMAT_CASE(FORMAT, TYPE) \ 250 // MeasureToFtable needs the Average since old formats stored measure.dR,dD only 251 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, char format) { 252 253 # define FORMAT_CASE(FORMAT, TYPE, ABS_COORDS) \ 232 254 case DVO_FORMAT_##FORMAT: { \ 233 255 Measure_##TYPE *tmpMeasure; \ 234 tmpMeasure = MeasureInternalTo_##TYPE (measure, Nmeasure); \ 256 myAssert (ABS_COORDS || average, "conversion to internal needs average table"); \ 257 tmpMeasure = MeasureInternalTo_##TYPE (average, measure, Nmeasure); \ 235 258 gfits_table_set_Measure_##TYPE (ftable, tmpMeasure, Nmeasure); \ 236 259 free (tmpMeasure); \ … … 243 266 break; } 244 267 245 FORMAT_CASE (ELIXIR, Elixir); 246 FORMAT_CASE (LONEOS, Loneos); 247 FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 248 FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 249 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 250 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 251 FORMAT_CASE (PS1_V1, PS1_V1); 252 FORMAT_CASE (PS1_V2, PS1_V2); 253 FORMAT_CASE (PS1_V3, PS1_V3); 254 FORMAT_CASE (PS1_V4, PS1_V4); 255 FORMAT_CASE (PS1_REF, PS1_REF); 268 FORMAT_CASE (ELIXIR, Elixir, FALSE); 269 FORMAT_CASE (LONEOS, Loneos, FALSE); 270 FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0, FALSE); 271 FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1, FALSE); 272 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1, FALSE); 273 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2, FALSE); 274 FORMAT_CASE (PS1_V1, PS1_V1, FALSE); 275 FORMAT_CASE (PS1_V2, PS1_V2, FALSE); 276 FORMAT_CASE (PS1_V3, PS1_V3, FALSE); 277 FORMAT_CASE (PS1_V4, PS1_V4, FALSE); 278 FORMAT_CASE (PS1_V5, PS1_V5, TRUE); 279 FORMAT_CASE (PS1_REF, PS1_REF, FALSE); 256 280 # undef FORMAT_CASE 257 281 … … 275 299 return (FALSE); 276 300 } 301 302 // block to convert old tables (PS1_V5 versions made during development) 303 if (!strcmp (extname, "DVO_SECFILT_PS1_V5") && (ftable[0].header[0].Naxis[0] == 160)) { 304 SecFilt_PS1_V5alt *tmpSecFilt; 305 tmpSecFilt = gfits_table_get_SecFilt_PS1_V5alt (ftable, Nsecfilt, NULL); 306 if (!tmpSecFilt) { 307 fprintf (stderr, "ERROR: failed to read secfilts\n"); 308 exit (2); 309 } 310 secfilt = SecFilt_PS1_V5alt_ToInternal (tmpSecFilt, *Nsecfilt); 311 free (tmpSecFilt); 312 *format = DVO_FORMAT_PS1_V5; 313 return (secfilt); 314 } 315 277 316 278 317 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ … … 309 348 CONVERT_FORMAT ("DVO_SECFILT_PS1_V3", PS1_V3, PS1_V3); 310 349 CONVERT_FORMAT ("DVO_SECFILT_PS1_V4", PS1_V4, PS1_V4); 350 CONVERT_FORMAT ("DVO_SECFILT_PS1_V5", PS1_V5, PS1_V5); 311 351 CONVERT_FORMAT ("DVO_SECFILT_PS1_REF", PS1_REF, PS1_REF); 312 352 # undef CONVERT_FORMAT … … 344 384 FORMAT_CASE (PS1_V3, PS1_V3); 345 385 FORMAT_CASE (PS1_V4, PS1_V4); 386 FORMAT_CASE (PS1_V5, PS1_V5); 346 387 FORMAT_CASE (PS1_REF, PS1_REF); 347 388 # undef FORMAT_CASE … … 349 390 default: 350 391 fprintf (stderr, "table format unknown (secfilt)\n"); 392 return (FALSE); 393 } 394 return (TRUE); 395 } 396 397 /*** Lensing / FTable conversion functions ***/ 398 399 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, char *format) { 400 401 Lensing *lensing; 402 char extname[80]; 403 404 /* convert to the internal format */ 405 if (!gfits_scan (ftable[0].header, "EXTNAME", "%s", 1, extname)) { 406 fprintf (stderr, "EXTNAME missing for lensing table\n"); 407 return (FALSE); 408 } 409 410 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 411 if (!strcmp (extname, NAME)) { \ 412 Lensing_##TYPE *tmpLensing; \ 413 tmpLensing = gfits_table_get_Lensing_##TYPE (ftable, Nlensing, NULL); \ 414 if (!tmpLensing) { \ 415 fprintf (stderr, "ERROR: failed to read lensings\n"); \ 416 exit (2); \ 417 } \ 418 lensing = Lensing_##TYPE##_ToInternal (tmpLensing, *Nlensing); \ 419 free (tmpLensing); \ 420 *format = DVO_FORMAT_##FORMAT; \ 421 return (lensing); } 422 423 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 424 if (!strcmp (extname, NAME)) { \ 425 fprintf (stderr, "ERROR: format %s not defined for lensing, skipping\n", NAME); \ 426 *Nlensing = 0; \ 427 return NULL; \ 428 } 429 430 if (!strcmp (extname, "DVO_LENSING")) { 431 lensing = gfits_table_get_Lensing (ftable, Nlensing, NULL); 432 if (!lensing) { 433 fprintf (stderr, "ERROR: failed to read lensings\n"); 434 exit (2); 435 } 436 *format = DVO_FORMAT_INTERNAL; 437 return (lensing); 438 } 439 440 SKIPPING_FORMAT ("DVO_LENSING_PS1_REF", PS1_REF, PS1_REF); 441 SKIPPING_FORMAT ("DVO_LENSING_ELIXIR", ELIXIR, Elixir); 442 SKIPPING_FORMAT ("DVO_LENSING_LONEOS", LONEOS, Loneos); 443 SKIPPING_FORMAT ("DVO_LENSING_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0); 444 SKIPPING_FORMAT ("DVO_LENSING_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1); 445 SKIPPING_FORMAT ("DVO_LENSING_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 446 SKIPPING_FORMAT ("DVO_LENSING_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 447 SKIPPING_FORMAT ("DVO_LENSING_PS1_V1", PS1_V1, PS1_V1); 448 SKIPPING_FORMAT ("DVO_LENSING_PS1_V2", PS1_V2, PS1_V2); 449 SKIPPING_FORMAT ("DVO_LENSING_PS1_V3", PS1_V3, PS1_V3); 450 SKIPPING_FORMAT ("DVO_LENSING_PS1_V4", PS1_V4, PS1_V4); 451 CONVERT_FORMAT ("DVO_LENSING_PS1_V5", PS1_V5, PS1_V5); 452 # undef CONVERT_FORMAT 453 454 fprintf (stderr, "table format unknown: %s\n", extname); 455 456 *Nlensing = 0; 457 return (NULL); 458 } 459 460 // LensingToFtable needs the Average since old formats stored lensing.dR,dD only 461 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, char format) { 462 463 # define FORMAT_CASE(FORMAT, TYPE) \ 464 case DVO_FORMAT_##FORMAT: { \ 465 Lensing_##TYPE *tmpLensing; \ 466 tmpLensing = LensingInternalTo_##TYPE (lensing, Nlensing); \ 467 gfits_table_set_Lensing_##TYPE (ftable, tmpLensing, Nlensing); \ 468 free (tmpLensing); \ 469 break; } 470 471 /* convert from the internal format */ 472 switch (format) { 473 case DVO_FORMAT_INTERNAL: { 474 gfits_table_set_Lensing (ftable, lensing, Nlensing); 475 break; } 476 477 // FORMAT_CASE (PS1_REF, PS1_REF); 478 // FORMAT_CASE (ELIXIR, Elixir); 479 // FORMAT_CASE (LONEOS, Loneos); 480 // FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 481 // FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 482 // FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 483 // FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 484 // FORMAT_CASE (PS1_V1, PS1_V1); 485 // FORMAT_CASE (PS1_V2, PS1_V2); 486 // FORMAT_CASE (PS1_V3, PS1_V3); 487 // FORMAT_CASE (PS1_V4, PS1_V4); 488 FORMAT_CASE (PS1_V5, PS1_V5); 489 # undef FORMAT_CASE 490 491 default: 492 fprintf (stderr, "table format unknown (lensing)\n"); 493 return (FALSE); 494 } 495 return (TRUE); 496 } 497 498 /*** Lensobj / FTable conversion functions ***/ 499 500 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, char *format) { 501 502 Lensobj *lensobj; 503 char extname[80]; 504 505 /* convert to the internal format */ 506 if (!gfits_scan (ftable[0].header, "EXTNAME", "%s", 1, extname)) { 507 fprintf (stderr, "EXTNAME missing for lensobj table\n"); 508 return (FALSE); 509 } 510 511 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 512 if (!strcmp (extname, NAME)) { \ 513 Lensobj_##TYPE *tmpLensobj; \ 514 tmpLensobj = gfits_table_get_Lensobj_##TYPE (ftable, Nlensobj, NULL); \ 515 if (!tmpLensobj) { \ 516 fprintf (stderr, "ERROR: failed to read lensobjs\n"); \ 517 exit (2); \ 518 } \ 519 lensobj = Lensobj_##TYPE##_ToInternal (tmpLensobj, *Nlensobj); \ 520 free (tmpLensobj); \ 521 *format = DVO_FORMAT_##FORMAT; \ 522 return (lensobj); } 523 524 if (!strcmp (extname, "DVO_LENSOBJ")) { 525 lensobj = gfits_table_get_Lensobj (ftable, Nlensobj, NULL); 526 if (!lensobj) { 527 fprintf (stderr, "ERROR: failed to read lensobjs\n"); 528 exit (2); 529 } 530 *format = DVO_FORMAT_INTERNAL; 531 return (lensobj); 532 } 533 534 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_REF", PS1_REF, PS1_REF); 535 // CONVERT_FORMAT ("DVO_LENSOBJ_ELIXIR", ELIXIR, Elixir); 536 // CONVERT_FORMAT ("DVO_LENSOBJ_LONEOS", LONEOS, Loneos); 537 // CONVERT_FORMAT ("DVO_LENSOBJ_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0); 538 // CONVERT_FORMAT ("DVO_LENSOBJ_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1); 539 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 540 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 541 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V1", PS1_V1, PS1_V1); 542 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V2", PS1_V2, PS1_V2); 543 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V3", PS1_V3, PS1_V3); 544 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V4", PS1_V4, PS1_V4); 545 CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V5", PS1_V5, PS1_V5); 546 # undef CONVERT_FORMAT 547 548 fprintf (stderr, "table format unknown: %s\n", extname); 549 550 *Nlensobj = 0; 551 return (NULL); 552 } 553 554 // LensobjToFtable needs the Average since old formats stored lensobj.dR,dD only 555 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, char format) { 556 557 # define FORMAT_CASE(FORMAT, TYPE) \ 558 case DVO_FORMAT_##FORMAT: { \ 559 Lensobj_##TYPE *tmpLensobj; \ 560 tmpLensobj = LensobjInternalTo_##TYPE (lensobj, Nlensobj); \ 561 gfits_table_set_Lensobj_##TYPE (ftable, tmpLensobj, Nlensobj); \ 562 free (tmpLensobj); \ 563 break; } 564 565 /* convert from the internal format */ 566 switch (format) { 567 case DVO_FORMAT_INTERNAL: { 568 gfits_table_set_Lensobj (ftable, lensobj, Nlensobj); 569 break; } 570 571 // FORMAT_CASE (PS1_REF, PS1_REF); 572 // FORMAT_CASE (ELIXIR, Elixir); 573 // FORMAT_CASE (LONEOS, Loneos); 574 // FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 575 // FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 576 // FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 577 // FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 578 // FORMAT_CASE (PS1_V1, PS1_V1); 579 // FORMAT_CASE (PS1_V2, PS1_V2); 580 // FORMAT_CASE (PS1_V3, PS1_V3); 581 // FORMAT_CASE (PS1_V4, PS1_V4); 582 FORMAT_CASE (PS1_V5, PS1_V5); 583 # undef FORMAT_CASE 584 585 default: 586 fprintf (stderr, "table format unknown (lensobj)\n"); 351 587 return (FALSE); 352 588 } … … 428 664 CONVERT_FORMAT ("DVO_IMAGE_PS1_V3", PS1_V3, PS1_V3); 429 665 CONVERT_FORMAT ("DVO_IMAGE_PS1_V4", PS1_V4, PS1_V4); 666 CONVERT_FORMAT ("DVO_IMAGE_PS1_V5", PS1_V5, PS1_V5); 430 667 CONVERT_FORMAT ("DVO_IMAGE_PS1_REF", PS1_REF, PS1_REF); 431 668 … … 467 704 FORMAT_CASE (PS1_V3, PS1_V3); 468 705 FORMAT_CASE (PS1_V4, PS1_V4); 706 FORMAT_CASE (PS1_V5, PS1_V5); 469 707 FORMAT_CASE (PS1_REF, PS1_REF); 470 708 … … 522 760 FORMAT_CASE (PS1_V3, PS1_V3); 523 761 FORMAT_CASE (PS1_V4, PS1_V4); 762 FORMAT_CASE (PS1_V5, PS1_V5); 524 763 FORMAT_CASE (PS1_REF, PS1_REF); 525 764 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c
r35162 r37403 3 3 /* convert PS1_DEV_1 formats to internal formats */ 4 4 5 Measure *Measure_PS1_DEV_1_ToInternal ( Measure_PS1_DEV_1 *in, off_t Nvalues) {5 Measure *Measure_PS1_DEV_1_ToInternal (Average *ave, Measure_PS1_DEV_1 *in, off_t Nvalues) { 6 6 7 7 off_t i; … … 12 12 for (i = 0; i < Nvalues; i++) { 13 13 dvo_measure_init (&out[i]); 14 out[i].dR = in[i].dR; 15 out[i].dD = in[i].dD; 14 15 int averef = in[i].averef; 16 out[i].R = ave[averef].R - in[i].dR / 3600.0; 17 out[i].D = ave[averef].D - in[i].dD / 3600.0; 16 18 out[i].M = in[i].M; 17 19 out[i].Mcal = in[i].Mcal; … … 30 32 out[i].psfQF = in[i].psfQF; 31 33 out[i].psfChisq = in[i].psfChisq; 32 out[i].crNsigma = in[i].crNsigma;33 34 out[i].extNsigma = in[i].extNsigma; 34 35 out[i].FWx = in[i].FWx; … … 50 51 } 51 52 52 Measure_PS1_DEV_1 *MeasureInternalTo_PS1_DEV_1 ( Measure *in, off_t Nvalues) {53 Measure_PS1_DEV_1 *MeasureInternalTo_PS1_DEV_1 (Average *ave, Measure *in, off_t Nvalues) { 53 54 54 55 off_t i; … … 58 59 59 60 for (i = 0; i < Nvalues; i++) { 60 out[i].dR = in[i].dR; 61 out[i].dD = in[i].dD; 61 int averef = in[i].averef; 62 63 out[i].dR = 3600.0*(ave[averef].R - in[i].R); 64 out[i].dD = 3600.0*(ave[averef].D - in[i].D); 62 65 out[i].M = in[i].M; 63 66 out[i].Mcal = in[i].Mcal; … … 76 79 out[i].psfQF = in[i].psfQF; 77 80 out[i].psfChisq = in[i].psfChisq; 78 out[i].crNsigma = in[i].crNsigma;79 81 out[i].extNsigma = in[i].extNsigma; 80 82 out[i].FWx = in[i].FWx; … … 180 182 out[i].M = in[i].M; 181 183 out[i].dM = in[i].dM; 182 out[i]. Xm = in[i].Xm;184 out[i].Mchisq= pow (10.0, 0.01*in[i].Xm); 183 185 out[i].Ncode = in[i].Ncode; 184 186 out[i].Nused = in[i].Nused; … … 197 199 out[i].M = in[i].M; 198 200 out[i].dM = in[i].dM; 199 out[i].Xm = in[i].Xm;201 out[i].Xm = 100.0*log10(in[i].Mchisq); 200 202 out[i].Ncode = in[i].Ncode; 201 203 out[i].Nused = in[i].Nused; … … 203 205 return (out); 204 206 } 207 208 # define RAW_IMAGE_NAME_LEN 64 205 209 206 210 Image *Image_PS1_DEV_1_ToInternal (Image_PS1_DEV_1 *in, off_t Nvalues, off_t Nalloc) { … … 217 221 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 218 222 219 strncpy (out[i].name, in[i].name, 63); // out[128], in[64] 220 out[i].name[63] = 0; // force termination 223 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 224 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 225 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 221 226 222 227 out[i].tzero = in[i].tzero; … … 284 289 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 285 290 286 strncpy (out[i].name, in[i].name, 63); // out[128], in[64] 287 out[i].name[63] = 0; // force termination 291 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 292 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 293 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 288 294 289 295 out[i].tzero = in[i].tzero; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c
r35162 r37403 3 3 /* convert PS1_DEV_2 formats to internal formats */ 4 4 5 Measure *Measure_PS1_DEV_2_ToInternal ( Measure_PS1_DEV_2 *in, off_t Nvalues) {5 Measure *Measure_PS1_DEV_2_ToInternal (Average *ave, Measure_PS1_DEV_2 *in, off_t Nvalues) { 6 6 7 7 off_t i; … … 12 12 for (i = 0; i < Nvalues; i++) { 13 13 dvo_measure_init (&out[i]); 14 out[i].dR = in[i].dR; 15 out[i].dD = in[i].dD; 14 15 int averef = in[i].averef; 16 out[i].R = ave[averef].R - in[i].dR / 3600.0; 17 out[i].D = ave[averef].D - in[i].dD / 3600.0; 16 18 out[i].M = in[i].M; 17 19 out[i].Mcal = in[i].Mcal; … … 32 34 out[i].psfQF = in[i].psfQF; 33 35 out[i].psfChisq = in[i].psfChisq; 34 out[i].crNsigma = in[i].crNsigma;35 36 out[i].extNsigma = in[i].extNsigma; 36 37 out[i].FWx = in[i].FWx; … … 48 49 } 49 50 50 Measure_PS1_DEV_2 *MeasureInternalTo_PS1_DEV_2 ( Measure *in, off_t Nvalues) {51 Measure_PS1_DEV_2 *MeasureInternalTo_PS1_DEV_2 (Average *ave, Measure *in, off_t Nvalues) { 51 52 52 53 off_t i; … … 56 57 57 58 for (i = 0; i < Nvalues; i++) { 58 out[i].dR = in[i].dR; 59 out[i].dD = in[i].dD; 59 int averef = in[i].averef; 60 61 out[i].dR = 3600.0*(ave[averef].R - in[i].R); 62 out[i].dD = 3600.0*(ave[averef].D - in[i].D); 60 63 out[i].M = in[i].M; 61 64 out[i].Mcal = in[i].Mcal; … … 76 79 out[i].psfQF = in[i].psfQF; 77 80 out[i].psfChisq = in[i].psfChisq; 78 out[i].crNsigma = in[i].crNsigma;79 81 out[i].extNsigma = in[i].extNsigma; 80 82 out[i].FWx = in[i].FWx; … … 119 121 out[i].measureOffset = in[i].measureOffset; 120 122 out[i].missingOffset = in[i].missingOffset; 121 out[i]. extendOffset = in[i].extendOffset;123 out[i].refColorBlue = in[i].refColor; 122 124 out[i].objID = in[i].objID; 123 125 out[i].catID = in[i].catID; … … 153 155 out[i].measureOffset = in[i].measureOffset; 154 156 out[i].missingOffset = in[i].missingOffset; 155 out[i]. extendOffset = in[i].extendOffset;157 out[i].refColor = in[i].refColorBlue; 156 158 out[i].objID = in[i].objID; 157 159 out[i].catID = in[i].catID; … … 175 177 out[i].M = in[i].M; 176 178 out[i].dM = in[i].dM; 177 out[i]. Xm = in[i].Xm;179 out[i].Mchisq= pow (10.0, 0.01*in[i].Xm); 178 180 out[i].Ncode = in[i].Ncode; 179 181 out[i].Nused = in[i].Nused; … … 192 194 out[i].M = in[i].M; 193 195 out[i].dM = in[i].dM; 194 out[i].Xm = in[i].Xm;196 out[i].Xm = 100.0*log10(in[i].Mchisq); 195 197 out[i].Ncode = in[i].Ncode; 196 198 out[i].Nused = in[i].Nused; … … 198 200 return (out); 199 201 } 202 203 # define RAW_IMAGE_NAME_LEN 64 200 204 201 205 Image *Image_PS1_DEV_2_ToInternal (Image_PS1_DEV_2 *in, off_t Nvalues, off_t Nalloc) { … … 212 216 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 213 217 214 strncpy (out[i].name, in[i].name, 63); // out[121], in[64] 215 out[i].name[63] = 0; // force termination 218 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 219 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 220 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 216 221 217 222 out[i].tzero = in[i].tzero; … … 276 281 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 277 282 278 strncpy (out[i].name, in[i].name, 63); // in[121], out[64] 279 out[i].name[63] = 0; // force termination 283 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 284 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 285 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 280 286 281 287 out[i].tzero = in[i].tzero; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_3.c
r35162 r37403 4 4 5 5 // We only provide image and photcode conversion 6 7 # define RAW_IMAGE_NAME_LEN 128 6 8 7 9 Image *Image_PS1_DEV_3_ToInternal (Image_PS1_DEV_3 *in, off_t Nvalues, off_t Nalloc) { … … 18 20 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 19 21 20 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 21 out[i].name[120] = 0; // force termination 22 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 23 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 24 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 22 25 23 26 out[i].tzero = in[i].tzero; … … 77 80 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 78 81 79 strncpy (out[i].name, in[i].name, 127); // out[128], in[128] 80 out[i].name[127] = 0; // force termination 82 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 83 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 84 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 81 85 82 86 out[i].tzero = in[i].tzero; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert_PS1_REF.c
r35162 r37403 3 3 /* convert PS1_REF formats to internal formats */ 4 4 5 Measure *Measure_PS1_REF_ToInternal ( Measure_PS1_REF *in, off_t Nvalues) {5 Measure *Measure_PS1_REF_ToInternal (Average *ave, Measure_PS1_REF *in, off_t Nvalues) { 6 6 7 7 off_t i; … … 13 13 dvo_measure_init (&out[i]); 14 14 15 out[i].dR = in[i].dR; 16 out[i].dD = in[i].dD; 15 int averef = in[i].averef; 16 out[i].R = ave[averef].R - in[i].dR / 3600.0; 17 out[i].D = ave[averef].D - in[i].dD / 3600.0; 17 18 out[i].M = in[i].M; 18 19 out[i].dM = in[i].dM; … … 28 29 } 29 30 30 Measure_PS1_REF *MeasureInternalTo_PS1_REF ( Measure *in, off_t Nvalues) {31 Measure_PS1_REF *MeasureInternalTo_PS1_REF (Average *ave, Measure *in, off_t Nvalues) { 31 32 32 33 off_t i; … … 36 37 37 38 for (i = 0; i < Nvalues; i++) { 38 out[i].dR = in[i].dR; 39 out[i].dD = in[i].dD; 39 int averef = in[i].averef; 40 41 out[i].dR = 3600.0*(ave[averef].R - in[i].R); 42 out[i].dD = 3600.0*(ave[averef].D - in[i].D); 40 43 out[i].M = in[i].M; 41 44 out[i].dM = in[i].dM; … … 129 132 } 130 133 134 # define RAW_IMAGE_NAME_LEN 121 135 131 136 Image *Image_PS1_REF_ToInternal (Image_PS1_REF *in, off_t Nvalues, off_t Nalloc) { 132 137 … … 142 147 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 143 148 144 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 145 out[i].name[120] = 0; // force termination 149 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 150 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 151 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 146 152 147 153 out[i].tzero = in[i].tzero; … … 204 210 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 205 211 206 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 207 out[i].name[120] = 0; // force termination 212 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 213 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 214 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 208 215 209 216 out[i].tzero = in[i].tzero; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert_PS1_V1.c
r35162 r37403 3 3 /* convert PS1_V1 formats to internal formats */ 4 4 5 Measure *Measure_PS1_V1_ToInternal ( Measure_PS1_V1 *in, off_t Nvalues) {5 Measure *Measure_PS1_V1_ToInternal (Average *ave, Measure_PS1_V1 *in, off_t Nvalues) { 6 6 7 7 off_t i; … … 13 13 dvo_measure_init (&out[i]); 14 14 15 out[i].dR = in[i].dR; 16 out[i].dD = in[i].dD; 15 int averef = in[i].averef; 16 out[i].R = ave[averef].R - in[i].dR / 3600.0; 17 out[i].D = ave[averef].D - in[i].dD / 3600.0; 17 18 out[i].M = in[i].M; 18 19 out[i].Mcal = in[i].Mcal; … … 39 40 out[i].psfNdof = in[i].psfNdof; 40 41 out[i].psfNpix = in[i].psfNpix; 41 out[i].crNsigma = in[i].crNsigma;42 42 out[i].extNsigma = in[i].extNsigma; 43 43 out[i].FWx = in[i].FWx; … … 58 58 } 59 59 60 Measure_PS1_V1 *MeasureInternalTo_PS1_V1 ( Measure *in, off_t Nvalues) {60 Measure_PS1_V1 *MeasureInternalTo_PS1_V1 (Average *ave, Measure *in, off_t Nvalues) { 61 61 62 62 off_t i; … … 66 66 67 67 for (i = 0; i < Nvalues; i++) { 68 out[i].dR = in[i].dR; 69 out[i].dD = in[i].dD; 68 int averef = in[i].averef; 69 70 out[i].dR = 3600.0*(ave[averef].R - in[i].R); 71 out[i].dD = 3600.0*(ave[averef].D - in[i].D); 70 72 out[i].M = in[i].M; 71 73 out[i].Mcal = in[i].Mcal; … … 92 94 out[i].psfNdof = in[i].psfNdof; 93 95 out[i].psfNpix = in[i].psfNpix; 94 out[i].crNsigma = in[i].crNsigma;95 96 out[i].extNsigma = in[i].extNsigma; 96 97 out[i].FWx = in[i].FWx; … … 140 141 out[i].measureOffset = in[i].measureOffset; 141 142 out[i].missingOffset = in[i].missingOffset; 142 out[i]. extendOffset = in[i].extendOffset;143 out[i].refColorBlue = in[i].refColor; 143 144 out[i].flags = in[i].flags; 144 145 out[i].objID = in[i].objID; … … 175 176 out[i].measureOffset = in[i].measureOffset; 176 177 out[i].missingOffset = in[i].missingOffset; 177 out[i]. extendOffset = in[i].extendOffset;178 out[i].refColor = in[i].refColorBlue; 178 179 out[i].flags = in[i].flags; 179 180 out[i].objID = in[i].objID; … … 196 197 out[i].M = in[i].M; 197 198 out[i].dM = in[i].dM; 198 out[i]. Xm = in[i].Xm;199 out[i].Mchisq= in[i].Mchisq; 199 200 out[i].Ncode = in[i].Ncode; 200 201 out[i].Nused = in[i].Nused; 201 out[i].M _20 = in[i].M_20;202 out[i].M _80 = in[i].M_80;202 out[i].Mmin = in[i].M_20*0.001; 203 out[i].Mmax = in[i].M_80*0.001; 203 204 } 204 205 return (out); … … 215 216 out[i].M = in[i].M; 216 217 out[i].dM = in[i].dM; 217 out[i]. Xm = in[i].Xm;218 out[i].Mchisq= in[i].Mchisq; 218 219 out[i].Ncode = in[i].Ncode; 219 220 out[i].Nused = in[i].Nused; 220 out[i].M_20 = in[i].M_20; 221 out[i].M_80 = in[i].M_80; 222 } 223 return (out); 224 } 221 out[i].M_20 = in[i].Mmin*1000.0; 222 out[i].M_80 = in[i].Mmax*1000.0; 223 } 224 return (out); 225 } 226 227 # define RAW_IMAGE_NAME_LEN 121 225 228 226 229 Image *Image_PS1_V1_ToInternal (Image_PS1_V1 *in, off_t Nvalues, off_t Nalloc) { … … 237 240 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 238 241 239 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 240 out[i].name[120] = 0; // force termination 242 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 243 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 244 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 241 245 242 246 out[i].tzero = in[i].tzero; … … 300 304 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 301 305 302 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 303 out[i].name[120] = 0; // force termination 306 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 307 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 308 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 304 309 305 310 out[i].tzero = in[i].tzero; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert_PS1_V2.c
r35162 r37403 3 3 /* convert PS1_V2 formats to internal formats */ 4 4 5 Measure *Measure_PS1_V2_ToInternal ( Measure_PS1_V2 *in, off_t Nvalues) {5 Measure *Measure_PS1_V2_ToInternal (Average *ave, Measure_PS1_V2 *in, off_t Nvalues) { 6 6 7 7 off_t i; … … 13 13 dvo_measure_init (&out[i]); 14 14 15 out[i].dR = in[i].dR; 16 out[i].dD = in[i].dD; 15 int averef = in[i].averef; 16 out[i].R = ave[averef].R - in[i].dR / 3600.0; 17 out[i].D = ave[averef].D - in[i].dD / 3600.0; 17 18 out[i].M = in[i].M; 18 19 out[i].Mcal = in[i].Mcal; … … 39 40 out[i].psfNdof = in[i].psfNdof; 40 41 out[i].psfNpix = in[i].psfNpix; 41 out[i].crNsigma = in[i].crNsigma;42 42 out[i].extNsigma = in[i].extNsigma; 43 43 out[i].FWx = in[i].FWx; … … 59 59 } 60 60 61 Measure_PS1_V2 *MeasureInternalTo_PS1_V2 ( Measure *in, off_t Nvalues) {61 Measure_PS1_V2 *MeasureInternalTo_PS1_V2 (Average *ave, Measure *in, off_t Nvalues) { 62 62 63 63 off_t i; … … 67 67 68 68 for (i = 0; i < Nvalues; i++) { 69 out[i].dR = in[i].dR; 70 out[i].dD = in[i].dD; 69 int averef = in[i].averef; 70 71 out[i].dR = 3600.0*(ave[averef].R - in[i].R); 72 out[i].dD = 3600.0*(ave[averef].D - in[i].D); 71 73 out[i].M = in[i].M; 72 74 out[i].Mcal = in[i].Mcal; … … 93 95 out[i].psfNdof = in[i].psfNdof; 94 96 out[i].psfNpix = in[i].psfNpix; 95 out[i].crNsigma = in[i].crNsigma;96 97 out[i].extNsigma = in[i].extNsigma; 97 98 out[i].FWx = in[i].FWx; … … 145 146 out[i].measureOffset = in[i].measureOffset; 146 147 out[i].missingOffset = in[i].missingOffset; 147 out[i]. extendOffset = in[i].extendOffset;148 out[i].refColorBlue = in[i].refColor; 148 149 out[i].flags = in[i].flags; 149 150 out[i].objID = in[i].objID; … … 184 185 out[i].measureOffset = in[i].measureOffset; 185 186 out[i].missingOffset = in[i].missingOffset; 186 out[i]. extendOffset = in[i].extendOffset;187 out[i].refColor = in[i].refColorBlue; 187 188 out[i].flags = in[i].flags; 188 189 out[i].objID = in[i].objID; … … 205 206 out[i].M = in[i].M; 206 207 out[i].dM = in[i].dM; 207 out[i]. Xm = in[i].Xm;208 out[i].Mchisq= in[i].Mchisq; 208 209 out[i].flags = in[i].flags; 209 210 out[i].Ncode = in[i].Ncode; 210 211 out[i].Nused = in[i].Nused; 211 out[i].M _20 = in[i].M_20;212 out[i].M _80 = in[i].M_80;212 out[i].Mmin = in[i].M_20*0.001; 213 out[i].Mmax = in[i].M_80*0.001; 213 214 } 214 215 return (out); … … 225 226 out[i].M = in[i].M; 226 227 out[i].dM = in[i].dM; 227 out[i]. Xm = in[i].Xm;228 out[i].Mchisq= in[i].Mchisq; 228 229 out[i].flags = in[i].flags; 229 230 out[i].Ncode = in[i].Ncode; 230 231 out[i].Nused = in[i].Nused; 231 out[i].M_20 = in[i].M_20; 232 out[i].M_80 = in[i].M_80; 233 } 234 return (out); 235 } 232 out[i].M_20 = in[i].Mmin*1000.0; 233 out[i].M_80 = in[i].Mmax*1000.0; 234 } 235 return (out); 236 } 237 238 # define RAW_IMAGE_NAME_LEN 121 236 239 237 240 Image *Image_PS1_V2_ToInternal (Image_PS1_V2 *in, off_t Nvalues, off_t Nalloc) { … … 248 251 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 249 252 250 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 251 out[i].name[120] = 0; // force termination 253 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 254 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 255 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 252 256 253 257 out[i].tzero = in[i].tzero; … … 269 273 out[i].DECo = in[i].DECo; 270 274 out[i].Radius = in[i].Radius; 275 out[i].refColorBlue = in[i].refColor; 271 276 272 277 out[i].detection_limit = in[i].detection_limit; … … 310 315 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 311 316 312 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 313 out[i].name[120] = 0; // force termination 317 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 318 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 319 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 314 320 315 321 out[i].tzero = in[i].tzero; … … 331 337 out[i].DECo = in[i].DECo; 332 338 out[i].Radius = in[i].Radius; 339 out[i].refColor = in[i].refColorBlue; 333 340 334 341 out[i].detection_limit = in[i].detection_limit; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert_PS1_V3.c
r35162 r37403 3 3 /* convert PS1_V3 formats to internal formats */ 4 4 5 Measure *Measure_PS1_V3_ToInternal ( Measure_PS1_V3 *in, off_t Nvalues) {5 Measure *Measure_PS1_V3_ToInternal (Average *ave, Measure_PS1_V3 *in, off_t Nvalues) { 6 6 7 7 off_t i; … … 13 13 dvo_measure_init (&out[i]); 14 14 15 out[i].dR = in[i].dR; 16 out[i].dD = in[i].dD; 15 int averef = in[i].averef; 16 out[i].R = ave[averef].R - in[i].dR / 3600.0; 17 out[i].D = ave[averef].D - in[i].dD / 3600.0; 17 18 out[i].M = in[i].M; 18 19 out[i].Mcal = in[i].Mcal; … … 39 40 out[i].psfNdof = in[i].psfNdof; 40 41 out[i].psfNpix = in[i].psfNpix; 41 out[i].crNsigma = in[i].crNsigma;42 42 out[i].extNsigma = in[i].extNsigma; 43 43 out[i].FWx = in[i].FWx; … … 59 59 } 60 60 61 Measure_PS1_V3 *MeasureInternalTo_PS1_V3 ( Measure *in, off_t Nvalues) {61 Measure_PS1_V3 *MeasureInternalTo_PS1_V3 (Average *ave, Measure *in, off_t Nvalues) { 62 62 63 63 off_t i; … … 67 67 68 68 for (i = 0; i < Nvalues; i++) { 69 out[i].dR = in[i].dR; 70 out[i].dD = in[i].dD; 69 int averef = in[i].averef; 70 71 out[i].dR = 3600.0*(ave[averef].R - in[i].R); 72 out[i].dD = 3600.0*(ave[averef].D - in[i].D); 71 73 out[i].M = in[i].M; 72 74 out[i].Mcal = in[i].Mcal; … … 93 95 out[i].psfNdof = in[i].psfNdof; 94 96 out[i].psfNpix = in[i].psfNpix; 95 out[i].crNsigma = in[i].crNsigma;96 97 out[i].extNsigma = in[i].extNsigma; 97 98 out[i].FWx = in[i].FWx; … … 145 146 out[i].measureOffset = in[i].measureOffset; 146 147 out[i].missingOffset = in[i].missingOffset; 147 out[i]. extendOffset = in[i].extendOffset;148 out[i].refColorBlue = in[i].refColor; 148 149 out[i].flags = in[i].flags; 149 150 out[i].photFlagsUpper = in[i].photFlagsUpper; … … 186 187 out[i].measureOffset = in[i].measureOffset; 187 188 out[i].missingOffset = in[i].missingOffset; 188 out[i]. extendOffset = in[i].extendOffset;189 out[i].refColor = in[i].refColorBlue; 189 190 out[i].flags = in[i].flags; 190 191 out[i].photFlagsUpper = in[i].photFlagsUpper; … … 210 211 out[i].Map = in[i].Map; 211 212 out[i].dM = in[i].dM; 212 out[i]. Xm = in[i].Xm;213 out[i].Mchisq = in[i].Mchisq; 213 214 out[i].flags = in[i].flags; 214 215 out[i].Ncode = in[i].Ncode; 215 216 out[i].Nused = in[i].Nused; 216 out[i].M _20 = in[i].M_20;217 out[i].M _80 = in[i].M_80;217 out[i].Mmin = in[i].M_20*0.001; 218 out[i].Mmax = in[i].M_80*0.001; 218 219 out[i].Mstdev = in[i].Mstdev; 219 220 out[i].ubercalDist = in[i].ubercalDist; … … 233 234 out[i].Map = in[i].Map; 234 235 out[i].dM = in[i].dM; 235 out[i]. Xm = in[i].Xm;236 out[i].Mchisq = in[i].Mchisq; 236 237 out[i].flags = in[i].flags; 237 238 out[i].Ncode = in[i].Ncode; 238 239 out[i].Nused = in[i].Nused; 239 out[i].M_20 = in[i].M _20;240 out[i].M_80 = in[i].M _80;240 out[i].M_20 = in[i].Mmin*1000.0; 241 out[i].M_80 = in[i].Mmax*1000.0; 241 242 out[i].Mstdev = in[i].Mstdev; 242 243 out[i].ubercalDist = in[i].ubercalDist; … … 244 245 return (out); 245 246 } 247 248 # define RAW_IMAGE_NAME_LEN 121 246 249 247 250 Image *Image_PS1_V3_ToInternal (Image_PS1_V3 *in, off_t Nvalues, off_t Nalloc) { … … 258 261 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 259 262 260 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 261 out[i].name[120] = 0; // force termination 263 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 264 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 265 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 262 266 263 267 out[i].tzero = in[i].tzero; … … 279 283 out[i].DECo = in[i].DECo; 280 284 out[i].Radius = in[i].Radius; 285 out[i].refColorBlue = in[i].refColor; 281 286 282 287 out[i].detection_limit = in[i].detection_limit; … … 320 325 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 321 326 322 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 323 out[i].name[120] = 0; // force termination 327 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 328 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 329 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 324 330 325 331 out[i].tzero = in[i].tzero; … … 341 347 out[i].DECo = in[i].DECo; 342 348 out[i].Radius = in[i].Radius; 349 out[i].refColor = in[i].refColorBlue; 343 350 344 351 out[i].detection_limit = in[i].detection_limit; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert_PS1_V4.c
r36680 r37403 3 3 /* convert PS1_V4 formats to internal formats */ 4 4 5 Measure *Measure_PS1_V4_ToInternal ( Measure_PS1_V4 *in, off_t Nvalues) {5 Measure *Measure_PS1_V4_ToInternal (Average *ave, Measure_PS1_V4 *in, off_t Nvalues) { 6 6 7 7 off_t i; … … 13 13 dvo_measure_init (&out[i]); 14 14 15 out[i].dR = in[i].dR; 16 out[i].dD = in[i].dD; 15 int averef = in[i].averef; 16 out[i].R = ave[averef].R - in[i].dR / 3600.0; 17 out[i].D = ave[averef].D - in[i].dD / 3600.0; 17 18 out[i].M = in[i].M; 18 19 out[i].Mcal = in[i].Mcal; … … 48 49 out[i].psfNdof = in[i].psfNdof; 49 50 out[i].psfNpix = in[i].psfNpix; 50 out[i].crNsigma = in[i].crNsigma;51 51 out[i].extNsigma = in[i].extNsigma; 52 52 out[i].FWx = in[i].FWx; … … 68 68 } 69 69 70 Measure_PS1_V4 *MeasureInternalTo_PS1_V4 ( Measure *in, off_t Nvalues) {70 Measure_PS1_V4 *MeasureInternalTo_PS1_V4 (Average *ave, Measure *in, off_t Nvalues) { 71 71 72 72 off_t i; … … 76 76 77 77 for (i = 0; i < Nvalues; i++) { 78 out[i].dR = in[i].dR; 79 out[i].dD = in[i].dD; 78 int averef = in[i].averef; 79 80 out[i].dR = 3600.0*(ave[averef].R - in[i].R); 81 out[i].dD = 3600.0*(ave[averef].D - in[i].D); 80 82 out[i].M = in[i].M; 81 83 out[i].Mcal = in[i].Mcal; … … 111 113 out[i].psfNdof = in[i].psfNdof; 112 114 out[i].psfNpix = in[i].psfNpix; 113 out[i].crNsigma = in[i].crNsigma;114 115 out[i].extNsigma = in[i].extNsigma; 115 116 out[i].FWx = in[i].FWx; … … 166 167 out[i].measureOffset = in[i].measureOffset; 167 168 out[i].missingOffset = in[i].missingOffset; 168 out[i]. extendOffset = in[i].extendOffset;169 out[i].refColorBlue = in[i].refColor; 169 170 out[i].flags = in[i].flags; 170 171 out[i].photFlagsUpper = in[i].photFlagsUpper; … … 210 211 out[i].measureOffset = in[i].measureOffset; 211 212 out[i].missingOffset = in[i].missingOffset; 212 out[i]. extendOffset = in[i].extendOffset;213 out[i].refColor = in[i].refColorBlue; 213 214 out[i].flags = in[i].flags; 214 215 out[i].photFlagsUpper = in[i].photFlagsUpper; … … 236 237 out[i].dMkron = in[i].dMkron; 237 238 out[i].dM = in[i].dM; 238 out[i]. Xm = in[i].Xm;239 out[i].F luxPSF= in[i].FluxPSF;240 out[i].dF luxPSF= in[i].dFluxPSF;241 out[i].F luxKron= in[i].FluxKron;242 out[i].dF luxKron= in[i].dFluxKron;239 out[i].Mchisq = in[i].Mchisq; 240 out[i].FpsfStk = in[i].FluxPSF; 241 out[i].dFpsfStk = in[i].dFluxPSF; 242 out[i].FkronStk = in[i].FluxKron; 243 out[i].dFkronStk = in[i].dFluxKron; 243 244 out[i].flags = in[i].flags; 244 245 out[i].Ncode = in[i].Ncode; 245 246 out[i].Nused = in[i].Nused; 246 out[i].M _20 = in[i].M_20;247 out[i].M _80 = in[i].M_80;247 out[i].Mmin = in[i].M_20*0.001; 248 out[i].Mmax = in[i].M_80*0.001; 248 249 out[i].Mstdev = in[i].Mstdev; 249 250 out[i].ubercalDist = in[i].ubercalDist; 250 out[i].stackDetectID = in[i].stackDetectID; 251 out[i].stackPrmryOff = in[i].stackPrmryOff; 252 out[i].stackBestOff = in[i].stackBestOff; 251 253 } 252 254 return (out); … … 266 268 out[i].dMkron = in[i].dMkron; 267 269 out[i].dM = in[i].dM; 268 out[i]. Xm = in[i].Xm;269 out[i].FluxPSF = in[i].F luxPSF;270 out[i].dFluxPSF = in[i].dF luxPSF;271 out[i].FluxKron = in[i].F luxKron;272 out[i].dFluxKron = in[i].dF luxKron;270 out[i].Mchisq = in[i].Mchisq; 271 out[i].FluxPSF = in[i].FpsfStk; 272 out[i].dFluxPSF = in[i].dFpsfStk; 273 out[i].FluxKron = in[i].FkronStk; 274 out[i].dFluxKron = in[i].dFkronStk; 273 275 out[i].flags = in[i].flags; 274 276 out[i].Ncode = in[i].Ncode; 275 277 out[i].Nused = in[i].Nused; 276 out[i].M_20 = in[i].M _20;277 out[i].M_80 = in[i].M _80;278 out[i].M_20 = in[i].Mmin*1000.0; 279 out[i].M_80 = in[i].Mmax*1000.0; 278 280 out[i].Mstdev = in[i].Mstdev; 279 281 out[i].ubercalDist = in[i].ubercalDist; 280 out[i].stackDetectID = in[i].stackDetectID; 281 } 282 return (out); 283 } 282 out[i].stackPrmryOff = in[i].stackPrmryOff; 283 out[i].stackBestOff = in[i].stackBestOff; 284 } 285 return (out); 286 } 287 288 # define RAW_IMAGE_NAME_LEN 121 284 289 285 290 Image *Image_PS1_V4_ToInternal (Image_PS1_V4 *in, off_t Nvalues, off_t Nalloc) { … … 296 301 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 297 302 298 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 299 out[i].name[120] = 0; // force termination 303 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 304 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 305 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 300 306 301 307 out[i].tzero = in[i].tzero; … … 317 323 out[i].DECo = in[i].DECo; 318 324 out[i].Radius = in[i].Radius; 325 out[i].refColorBlue = in[i].refColor; 319 326 320 327 out[i].detection_limit = in[i].detection_limit; … … 358 365 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 359 366 360 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 361 out[i].name[120] = 0; // force termination 367 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 368 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 369 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 362 370 363 371 out[i].tzero = in[i].tzero; … … 379 387 out[i].DECo = in[i].DECo; 380 388 out[i].Radius = in[i].Radius; 389 out[i].refColor = in[i].refColorBlue; 381 390 382 391 out[i].detection_limit = in[i].detection_limit; … … 484 493 /*** there are some mini dvodbs with the wrong PS1_V4 format (missing Xoff,Yoff / Xfix,Yfix) ************/ 485 494 486 Measure *Measure_PS1_V4alt_ToInternal ( Measure_PS1_V4alt *in, off_t Nvalues) {495 Measure *Measure_PS1_V4alt_ToInternal (Average *ave, Measure_PS1_V4alt *in, off_t Nvalues) { 487 496 488 497 off_t i; … … 494 503 dvo_measure_init (&out[i]); 495 504 496 out[i].dR = in[i].dR; 497 out[i].dD = in[i].dD; 505 int averef = in[i].averef; 506 out[i].R = ave[averef].R - in[i].dR / 3600.0; 507 out[i].D = ave[averef].D - in[i].dD / 3600.0; 498 508 out[i].M = in[i].M; 499 509 out[i].Mcal = in[i].Mcal; … … 529 539 out[i].psfNdof = in[i].psfNdof; 530 540 out[i].psfNpix = in[i].psfNpix; 531 out[i].crNsigma = in[i].crNsigma;532 541 out[i].extNsigma = in[i].extNsigma; 533 542 out[i].FWx = in[i].FWx; … … 680 689 out[i].measureOffset = in[i].measureOffset; 681 690 out[i].missingOffset = in[i].missingOffset; 682 out[i]. extendOffset = in[i].extendOffset;691 out[i].refColorBlue = in[i].refColor; 683 692 out[i].flags = in[i].flags; 684 693 out[i].photFlagsUpper = in[i].photFlagsUpper; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert_elixir.c
r35162 r37403 2 2 3 3 /* convert elixir-format measures to internal measures */ 4 Measure *Measure_Elixir_ToInternal ( Measure_Elixir *in, off_t Nvalues) {4 Measure *Measure_Elixir_ToInternal (Average *ave, Measure_Elixir *in, off_t Nvalues) { 5 5 6 6 off_t i; … … 15 15 out[i].averef = in[i].averef; 16 16 17 // changed for PS1_V5 18 int averef = out[i].averef; 19 out[i].R = (in[i].dR == NAN_S_SHORT) ? NAN : ave[averef].R - 0.01 * in[i].dR / 3600.0; 20 out[i].D = (in[i].dD == NAN_S_SHORT) ? NAN : ave[averef].D - 0.01 * in[i].dD / 3600.0; 21 17 22 // changed for PANSTARRS_DEV_0 18 out[i].dR = (in[i].dR == NAN_S_SHORT) ? NAN : in[i].dR * 0.01;19 out[i].dD = (in[i].dD == NAN_S_SHORT) ? NAN : in[i].dD * 0.01;20 23 out[i].M = (in[i].M == NAN_S_SHORT) ? NAN : in[i].M * 0.001; 21 24 out[i].dM = (in[i].dM == NAN_U_CHAR) ? NAN : in[i].dM * 0.001; … … 47 50 48 51 /* convert internal measures to elixir-format measures */ 49 Measure_Elixir *MeasureInternalTo_Elixir ( Measure *in, off_t Nvalues) {52 Measure_Elixir *MeasureInternalTo_Elixir (Average *ave, Measure *in, off_t Nvalues) { 50 53 51 54 off_t i; … … 59 62 out[i].averef = in[i].averef; 60 63 64 // changed for PS1_V5 65 int averef = in[i].averef; 66 int isBad = isnan(in[i].R) || isnan(in[i].D); 67 out[i].dR = isBad ? NAN_S_SHORT : 100.0*3600.0*(ave[averef].R - in[i].R); 68 out[i].dD = isBad ? NAN_S_SHORT : 100.0*3600.0*(ave[averef].D - in[i].D); 69 61 70 // changed for PANSTARRS_DEV_0 62 out[i].dR = isnan(in[i].dR ) ? NAN_S_SHORT : in[i].dR * 100.0;63 out[i].dD = isnan(in[i].dD ) ? NAN_S_SHORT : in[i].dD * 100.0;64 71 out[i].M = isnan(in[i].M ) ? NAN_S_SHORT : in[i].M * 1000.0; 65 72 out[i].dM = isnan(in[i].dM ) ? NAN_U_CHAR : in[i].dM * 1000.0; … … 104 111 primary[0][i].M = (in[i].M == NAN_S_SHORT) ? NAN : in[i].M * 0.001; 105 112 primary[0][i].dM = (in[i].dM == NAN_S_SHORT) ? NAN : in[i].dM * 0.001; 106 primary[0][i]. Xm = in[i].Xm;113 primary[0][i].Mchisq= pow (10.0, 0.01*in[i].Xm); 107 114 108 115 // added for PANSTARRS_DEV_0 … … 137 144 out[i].M = isnan(primary[i].M) ? NAN_S_SHORT : primary[i].M * 1000.0; 138 145 out[i].dM = isnan(primary[i].dM) ? NAN_S_SHORT : primary[i].dM * 1000.0; 139 out[i].Xm = primary[i].Xm;146 out[i].Xm = 100.0*log10(primary[i].Mchisq); 140 147 141 148 // changed or added for PS1_DEV_2 … … 162 169 dvo_secfilt_init (&out[i]); 163 170 164 out[i]. Xm = in[i].Xm;171 out[i].Mchisq = pow (10.0, 0.01*in[i].Xm); 165 172 166 173 // added or changed for PANSTARRS_DEV_0 … … 180 187 181 188 for (i = 0; i < Nvalues; i++) { 182 out[i].Xm = in[i].Xm;189 out[i].Xm = 100.0*log10(in[i].Mchisq); 183 190 184 191 // added or changed for PANSTARRS_DEV_0 … … 188 195 return (out); 189 196 } 197 198 # define RAW_IMAGE_NAME_LEN 32 190 199 191 200 /* convert elixir-format images to internal images */ … … 203 212 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 204 213 205 strncpy (out[i].name, in[i].name, 31); // in[32], out[128] 206 out[i].name[31] = 0; // force termination 214 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 215 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 216 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 207 217 208 218 out[i].tzero = in[i].tzero; … … 272 282 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 273 283 274 strncpy (out[i].name, in[i].name, 31); // out[32], in[128] 275 out[i].name[31] = 0; // force termination 284 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 285 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 286 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 276 287 277 288 out[i].tzero = in[i].tzero; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert_loneos.c
r35162 r37403 2 2 3 3 /* convert loneos-format measures to internal measures */ 4 Measure *Measure_Loneos_ToInternal ( Measure_Loneos *in, off_t Nvalues) {4 Measure *Measure_Loneos_ToInternal (Average *ave, Measure_Loneos *in, off_t Nvalues) { 5 5 6 6 off_t i; … … 18 18 out[i].t = in[i].t; 19 19 20 // changed for PS1_V5 21 int averef = out[i].averef; 22 out[i].R = (in[i].dR == NAN_S_SHORT) ? NAN : ave[averef].R - 0.01 * in[i].dR / 3600.0; 23 out[i].D = (in[i].dD == NAN_S_SHORT) ? NAN : ave[averef].D - 0.01 * in[i].dD / 3600.0; 24 20 25 // changed for PANSTARRS_DEV_0 21 out[i].dR = (in[i].dR == NAN_S_SHORT) ? NAN : in[i].dR * 0.01;22 out[i].dD = (in[i].dD == NAN_S_SHORT) ? NAN : in[i].dD * 0.01;23 26 out[i].M = (in[i].M == NAN_S_SHORT) ? NAN : in[i].M * 0.001; 24 27 out[i].dM = (in[i].dM == NAN_U_CHAR) ? NAN : in[i].dM * 0.001; … … 40 43 41 44 /* convert internal measures to loneos-format measures */ 42 Measure_Loneos *MeasureInternalTo_Loneos ( Measure *in, off_t Nvalues) {45 Measure_Loneos *MeasureInternalTo_Loneos (Average *ave, Measure *in, off_t Nvalues) { 43 46 44 47 off_t i; … … 48 51 49 52 for (i = 0; i < Nvalues; i++) { 50 51 // changed for PANSTARRS_DEV_0 52 out[i].dR = isnan(in[i].dR ) ? NAN_S_SHORT : in[i].dR * 100.0; 53 out[i].dD = isnan(in[i].dD ) ? NAN_S_SHORT : in[i].dD * 100.0; 53 // changed for PS1_V5 54 int averef = in[i].averef; 55 int isBad = isnan(in[i].R) || isnan(in[i].D); 56 out[i].dR = isBad ? NAN_S_SHORT : 100.0*3600.0*(ave[averef].R - in[i].R); 57 out[i].dD = isBad ? NAN_S_SHORT : 100.0*3600.0*(ave[averef].D - in[i].D); 58 54 59 out[i].M = isnan(in[i].M ) ? NAN_S_SHORT : in[i].M * 1000.0; 55 60 out[i].dM = isnan(in[i].dM ) ? NAN_U_CHAR : in[i].dM * 1000.0; … … 85 90 // changed for PANSTARRS_DEV_0 (moved from Average to Measure) 86 91 primary[0][i].M = (in[i].M == NAN_S_SHORT) ? NAN : in[i].M * 0.001; 87 primary[0][i]. Xm = in[i].Xm;92 primary[0][i].Mchisq= pow (10.0, 0.01*in[i].Xm); 88 93 89 94 // added for PANSTARRS_DEV_0 … … 119 124 // changed for PANSTARRS_DEV_0 (moved from Average to Measure) 120 125 out[i].M = isnan(primary[i].M) ? NAN_S_SHORT : primary[i].M * 1000.0; 121 out[i].Xm = primary[i].Xm;126 out[i].Xm = 100.0*log10(primary[i].Mchisq); 122 127 123 128 // changed or added for PS1_DEV_2 … … 144 149 dvo_secfilt_init (&out[i]); 145 150 146 out[i]. Xm = in[i].Xm;151 out[i].Mchisq= pow (10.0, 0.01*in[i].Xm); 147 152 148 153 // added or changed for PANSTARRS_DEV_0 … … 161 166 162 167 for (i = 0; i < Nvalues; i++) { 163 out[i].Xm = in[i].Xm;168 out[i].Xm = 100.0*log10(in[i].Mchisq); 164 169 165 170 // added or changed for PANSTARRS_DEV_0 … … 168 173 return (out); 169 174 } 175 176 # define RAW_IMAGE_NAME_LEN 32 170 177 171 178 /* convert loneos-format images to internal images */ … … 183 190 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 184 191 185 strncpy (out[i].name, in[i].name, 31); // in[32], out[128] 186 out[i].name[31] = 0; // force termination 192 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 193 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 194 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 187 195 188 196 out[i].tzero = in[i].tzero; … … 253 261 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 254 262 255 strncpy (out[i].name, in[i].name, 31); // out[32], in[128] 256 out[i].name[31] = 0; // force termination 263 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 264 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 265 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 257 266 258 267 out[i].tzero = in[i].tzero; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c
r35162 r37403 2 2 3 3 /* convert panstarrs-format measures to internal measures */ 4 Measure *Measure_Panstarrs_DEV_0_ToInternal ( Measure_Panstarrs_DEV_0 *in, off_t Nvalues) {4 Measure *Measure_Panstarrs_DEV_0_ToInternal (Average *ave, Measure_Panstarrs_DEV_0 *in, off_t Nvalues) { 5 5 6 6 off_t i; … … 11 11 for (i = 0; i < Nvalues; i++) { 12 12 dvo_measure_init (&out[i]); 13 out[i].dR = in[i].dR; 14 out[i].dD = in[i].dD; 13 14 int averef = in[i].averef; 15 out[i].R = ave[averef].R - in[i].dR / 3600.0; 16 out[i].D = ave[averef].D - in[i].dD / 3600.0; 15 17 out[i].M = in[i].M; 16 18 out[i].dM = in[i].dM; … … 52 54 53 55 /* convert internal measures to panstarrs-format measures */ 54 Measure_Panstarrs_DEV_0 *MeasureInternalTo_Panstarrs_DEV_0 ( Measure *in, off_t Nvalues) {56 Measure_Panstarrs_DEV_0 *MeasureInternalTo_Panstarrs_DEV_0 (Average *ave, Measure *in, off_t Nvalues) { 55 57 56 58 off_t i; … … 60 62 61 63 for (i = 0; i < Nvalues; i++) { 62 out[i].dR = in[i].dR; 63 out[i].dD = in[i].dD; 64 int averef = in[i].averef; 65 66 out[i].dR = 3600.0*(ave[averef].R - in[i].R); 67 out[i].dD = 3600.0*(ave[averef].D - in[i].D); 64 68 out[i].M = in[i].M; 65 69 out[i].dM = in[i].dM; … … 184 188 out[i].M = in[i].M; 185 189 out[i].dM = in[i].dM; 186 out[i]. Xm = in[i].Xm;190 out[i].Mchisq= pow (10.0, 0.01*in[i].Xm); 187 191 out[i].Ncode = in[i].Ncode; 188 192 out[i].Nused = in[i].Nused; … … 202 206 out[i].M = in[i].M; 203 207 out[i].dM = in[i].dM; 204 out[i].Xm = in[i].Xm;208 out[i].Xm = 100.0*log10(in[i].Mchisq); 205 209 out[i].Ncode = in[i].Ncode; 206 210 out[i].Nused = in[i].Nused; … … 208 212 return (out); 209 213 } 214 215 # define RAW_IMAGE_NAME_LEN 32 210 216 211 217 /* convert panstarrs-format images to internal images */ … … 223 229 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 224 230 225 strncpy (out[i].name, in[i].name, 31); // out[128], in[32] 226 out[i].name[31] = 0; // force termination 231 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 232 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 233 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 227 234 228 235 out[i].tzero = in[i].tzero; … … 292 299 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 293 300 294 strncpy (out[i].name, in[i].name, 31); // out[32], in[128] 295 out[i].name[31] = 0; // force termination 301 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 302 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 303 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 296 304 297 305 out[i].tzero = in[i].tzero; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c
r35162 r37403 2 2 3 3 /* convert panstarrs-format measures to internal measures */ 4 Measure *Measure_Panstarrs_DEV_1_ToInternal ( Measure_Panstarrs_DEV_1 *in, off_t Nvalues) {4 Measure *Measure_Panstarrs_DEV_1_ToInternal (Average *ave, Measure_Panstarrs_DEV_1 *in, off_t Nvalues) { 5 5 6 6 off_t i; … … 11 11 for (i = 0; i < Nvalues; i++) { 12 12 dvo_measure_init (&out[i]); 13 out[i].dR = in[i].dR; 14 out[i].dD = in[i].dD; 13 14 int averef = in[i].averef; 15 out[i].R = ave[averef].R - in[i].dR / 3600.0; 16 out[i].D = ave[averef].D - in[i].dD / 3600.0; 15 17 out[i].M = in[i].M; 16 18 out[i].dM = in[i].dM; … … 52 54 53 55 /* convert internal measures to panstarrs-format measures */ 54 Measure_Panstarrs_DEV_1 *MeasureInternalTo_Panstarrs_DEV_1 ( Measure *in, off_t Nvalues) {56 Measure_Panstarrs_DEV_1 *MeasureInternalTo_Panstarrs_DEV_1 (Average *ave, Measure *in, off_t Nvalues) { 55 57 56 58 off_t i; … … 60 62 61 63 for (i = 0; i < Nvalues; i++) { 62 out[i].dR = in[i].dR; 63 out[i].dD = in[i].dD; 64 int averef = in[i].averef; 65 66 out[i].dR = 3600.0*(ave[averef].R - in[i].R); 67 out[i].dD = 3600.0*(ave[averef].D - in[i].D); 64 68 out[i].M = in[i].M; 65 69 out[i].dM = in[i].dM; … … 184 188 out[i].M = in[i].M; 185 189 out[i].dM = in[i].dM; 186 out[i]. Xm = in[i].Xm;190 out[i].Mchisq= pow (10.0, 0.01*in[i].Xm); 187 191 out[i].Ncode = in[i].Ncode; 188 192 out[i].Nused = in[i].Nused; … … 202 206 out[i].M = in[i].M; 203 207 out[i].dM = in[i].dM; 204 out[i].Xm = in[i].Xm;208 out[i].Xm = 100.0*log10(in[i].Mchisq); 205 209 out[i].Ncode = in[i].Ncode; 206 210 out[i].Nused = in[i].Nused; … … 208 212 return (out); 209 213 } 214 215 # define RAW_IMAGE_NAME_LEN 64 210 216 211 217 /* convert panstarrs-format images to internal images */ … … 223 229 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 224 230 225 strncpy (out[i].name, in[i].name, 63); // in[64], out[128] 226 out[i].name[63] = 0; // force termination 231 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 232 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 233 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 227 234 228 235 out[i].tzero = in[i].tzero; … … 292 299 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 293 300 294 strncpy (out[i].name, in[i].name, 63); // in[128], out[64] 295 out[i].name[63] = 0; // force termination 301 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 302 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 303 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 296 304 297 305 out[i].tzero = in[i].tzero; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_image.c
r35162 r37403 219 219 if (db[0].format == DVO_FORMAT_PS1_V3) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_V3"); 220 220 if (db[0].format == DVO_FORMAT_PS1_V4) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_V4"); 221 if (db[0].format == DVO_FORMAT_PS1_V5) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_V5"); 221 222 if (db[0].format == DVO_FORMAT_PS1_REF) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_REF"); 222 223 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_image_raw.c
r34260 r37403 59 59 if (db[0].format == DVO_FORMAT_PS1_V3) ImageSize = sizeof(Image_PS1_V3); 60 60 if (db[0].format == DVO_FORMAT_PS1_V4) ImageSize = sizeof(Image_PS1_V4); 61 if (db[0].format == DVO_FORMAT_PS1_V5) ImageSize = sizeof(Image_PS1_V5); 61 62 if (db[0].format == DVO_FORMAT_PS1_REF) ImageSize = sizeof(Image_PS1_REF); 62 63 … … 89 90 if (db[0].format == DVO_FORMAT_PS1_V3) gfits_table_mkheader_Image_PS1_V3 (&db[0].theader); 90 91 if (db[0].format == DVO_FORMAT_PS1_V4) gfits_table_mkheader_Image_PS1_V4 (&db[0].theader); 92 if (db[0].format == DVO_FORMAT_PS1_V5) gfits_table_mkheader_Image_PS1_V5 (&db[0].theader); 91 93 if (db[0].format == DVO_FORMAT_PS1_REF) gfits_table_mkheader_Image_PS1_REF (&db[0].theader); 92 94 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_photcode_ops.c
r36680 r37403 18 18 19 19 static PhotCodeData *photcodes = NULL; 20 static PhotCode *genericCodeMag = NULL; 21 static PhotCode *genericCodeFlux = NULL; 20 22 21 23 PhotCodeData *GetPhotcodeTable () { … … 26 28 photcodes[0].code = NULL; 27 29 } 30 if (genericCodeMag == NULL) { 31 ALLOCATE (genericCodeMag, PhotCode, 1); 32 genericCodeMag->code = 0; 33 strcpy (genericCodeMag->name, "MAG"); 34 genericCodeMag->type = PHOT_MAG; 35 } 36 if (genericCodeFlux == NULL) { 37 ALLOCATE (genericCodeFlux, PhotCode, 1); 38 genericCodeFlux->code = 0; 39 strcpy (genericCodeFlux->name, "MAG"); 40 genericCodeFlux->type = PHOT_MAG; 41 } 28 42 return photcodes; 29 43 } … … 57 71 if (name == NULL) return (NULL); 58 72 73 // "MAG" is a special word, not allowed for a photcode name 74 if (!strcasecmp (name, "MAG")) { 75 return genericCodeMag; 76 } 77 78 // "FLUX" is a special word, not allowed for a photcode name 79 if (!strcasecmp (name, "FLUX")) { 80 return genericCodeFlux; 81 } 82 59 83 for (i = 0; i < photcodes[0].Ncode; i++) { 60 84 if (!strcmp (photcodes[0].code[i].name, name)) { … … 70 94 71 95 if (name == NULL) return (0); 96 97 // "MAG" is a special photcode name for internal use 98 if (!strcasecmp (name, "MAG")) { 99 return genericCodeMag->code; 100 } 101 // "FLUX" is a special photcode name for internal use 102 if (!strcasecmp (name, "FLUX")) { 103 return genericCodeFlux->code; 104 } 72 105 73 106 for (i = 0; i < photcodes[0].Ncode; i++) { … … 222 255 223 256 /******** photometry conversion functions *********/ 224 float PhotInst (Measure *measure) { 225 226 int Np; 227 float M; 228 229 Np = photcodes[0].hashcode[measure[0].photcode]; 257 float PhotInst (Measure *measure, dvoMagClassType class) { 258 259 int Np = photcodes[0].hashcode[measure[0].photcode]; 230 260 if (Np == -1) return (NAN); 231 232 if (photcodes[0].code[Np].type == PHOT_REF) { 233 M = measure[0].M; 234 return (M); 235 } 236 237 M = measure[0].M - measure[0].dt - ZERO_POINT; 238 239 return (M); 240 241 } 242 243 float PhotCat (Measure *measure) { 244 245 int Np; 246 float Mcat; 247 PhotCode *code; 248 249 Np = photcodes[0].hashcode[measure[0].photcode]; 261 PhotCode *code = &photcodes[0].code[Np]; 262 263 float Mraw = NAN; 264 switch (class) { 265 case MAG_CLASS_PSF: 266 Mraw = measure[0].M; 267 break; 268 case MAG_CLASS_KRON: 269 Mraw = measure[0].Mkron; 270 break; 271 case MAG_CLASS_APER: 272 Mraw = measure[0].Map; 273 break; 274 default: 275 break; 276 } 277 if (code->type == PHOT_REF) { 278 return (Mraw); 279 } 280 float Minst = Mraw - measure[0].dt - ZERO_POINT; 281 282 return (Minst); 283 } 284 285 float PhotCat (Measure *measure, dvoMagClassType class) { 286 287 int Np = photcodes[0].hashcode[measure[0].photcode]; 250 288 if (Np == -1) return (NAN); 251 252 if (photcodes[0].code[Np].type == PHOT_REF) { 253 Mcat = measure[0].M; 254 return (Mcat); 255 } 256 code = &photcodes[0].code[Np]; 257 Mcat = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 289 PhotCode *code = &photcodes[0].code[Np]; 290 291 float Mraw = NAN; 292 switch (class) { 293 case MAG_CLASS_PSF: 294 Mraw = measure[0].M; 295 break; 296 case MAG_CLASS_KRON: 297 Mraw = measure[0].Mkron; 298 break; 299 case MAG_CLASS_APER: 300 Mraw = measure[0].Map; 301 break; 302 default: 303 break; 304 } 305 if (code->type == PHOT_REF) { 306 return (Mraw); 307 } 308 309 float Mcat = Mraw - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 258 310 259 311 return (Mcat); 260 312 } 261 313 262 float PhotSys (Measure *measure, Average *average, SecFilt *secfilt) { 263 264 int i, Np; 265 float Mcat, Mcol, Msys, mc, Mc; 266 PhotCode *code; 267 268 Np = photcodes[0].hashcode[measure[0].photcode]; 314 float PhotSys (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class) { 315 316 int Np = photcodes[0].hashcode[measure[0].photcode]; 269 317 if (Np == -1) return (NAN); 270 271 if (photcodes[0].code[Np].type == PHOT_REF) { 272 Msys = measure[0].M; 273 return (Msys); 274 } 275 code = &photcodes[0].code[Np]; 276 Mcat = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 318 PhotCode *code = &photcodes[0].code[Np]; 319 320 float Mraw = NAN; 321 switch (class) { 322 case MAG_CLASS_PSF: 323 Mraw = measure[0].M; 324 break; 325 case MAG_CLASS_KRON: 326 Mraw = measure[0].Mkron; 327 break; 328 case MAG_CLASS_APER: 329 Mraw = measure[0].Map; 330 break; 331 default: 332 break; 333 } 334 if (code->type == PHOT_REF) { 335 return (Mraw); 336 } 337 float Mcat = Mraw - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 277 338 278 339 /* for DEP, color must be made of PRI/SEC */ 279 mc = PhotColorForCode (average, secfilt, NULL, code);340 float mc = PhotColorForCode (average, secfilt, NULL, code); 280 341 if (isnan(mc)) return (Mcat); 281 mc = mc - SCALE*code[0].dX; 282 283 Mc = mc; 284 Mcol = 0; 342 mc -= SCALE*code[0].dX; 343 344 int i = 0; 345 double Mc = mc; 346 float Mcol = 0; 285 347 for (i = 0; i < code[0].Nc; i++) { 286 348 Mcol += code[0].X[i]*Mc; 287 349 Mc *= mc; 288 350 } 289 Msys = Mcat + Mcol;351 float Msys = Mcat + Mcol; 290 352 return (Msys); 291 353 } 292 354 293 float PhotRel (Measure *measure, Average *average, SecFilt *secfilt) { 294 295 int i, Np; 296 float Mcat, Mcol, Mrel, mc, Mc; 297 PhotCode *code; 298 299 Np = photcodes[0].hashcode[measure[0].photcode]; 355 float PhotRel (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class) { 356 357 int Np = photcodes[0].hashcode[measure[0].photcode]; 300 358 if (Np == -1) return (NAN); 301 302 if (photcodes[0].code[Np].type == PHOT_REF) { 303 Mcat = measure[0].M; 304 return (Mcat); 305 } 306 code = &photcodes[0].code[Np]; 307 Mrel = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 359 PhotCode *code = &photcodes[0].code[Np]; 360 361 float Mraw = NAN; 362 switch (class) { 363 case MAG_CLASS_PSF: 364 Mraw = measure[0].M; 365 break; 366 case MAG_CLASS_KRON: 367 Mraw = measure[0].Mkron; 368 break; 369 case MAG_CLASS_APER: 370 Mraw = measure[0].Map; 371 break; 372 default: 373 break; 374 } 375 if (code->type == PHOT_REF) { 376 return (Mraw); 377 } 378 float Mcat = Mraw - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 308 379 309 380 /* for DEP, color must be made of PRI/SEC */ 310 mc = PhotColorForCode (average, secfilt, NULL, code); 311 if (isnan(mc)) return (Mrel); 312 mc = mc - SCALE*code[0].dX; 313 314 Mc = mc; 315 Mcol = 0; 381 float mc = PhotColorForCode (average, secfilt, NULL, code); 382 if (isnan(mc)) return (Mcat); 383 mc -= SCALE*code[0].dX; 384 385 double Mc = mc; 386 float Mcol = 0; 387 int i = 0; 388 for (i = 0; i < code[0].Nc; i++) { 389 Mcol += code[0].X[i]*Mc; 390 Mc *= mc; 391 } 392 float Mrel = Mcat + Mcol; 393 return (Mrel); 394 } 395 396 /* return calibrated magnitude from measure for given photcode */ 397 float PhotCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code, dvoMagClassType class) { 398 399 int i; 400 401 if (code == NULL) return NAN; 402 403 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 404 int Np = photcodes[0].hashcode[thisone[0].photcode]; 405 if (Np == -1) return (NAN); 406 PhotCode *myCode = &photcodes[0].code[Np]; 407 408 if (code->code != myCode->equiv) return (NAN); 409 410 // if we are REF type, just get the right version and return 411 if (myCode->type == PHOT_REF) { 412 float Mraw = NAN; 413 switch (class) { 414 case MAG_CLASS_PSF: 415 Mraw = thisone[0].M; 416 break; 417 case MAG_CLASS_KRON: 418 Mraw = thisone[0].Mkron; 419 break; 420 case MAG_CLASS_APER: 421 Mraw = thisone[0].Map; 422 break; 423 default: 424 break; 425 } 426 return (Mraw); 427 } 428 429 float Mcal = PhotRel (thisone, average, secfilt, class) + SCALE*code[0].C; 430 431 float mc = PhotColorForCode (average, secfilt, measure, code); 432 if (isnan(mc)) return (Mcal); 433 mc -= SCALE*code[0].dX; 434 435 double Mc = mc; 436 float Mcol = 0; 437 for (i = 0; i < code[0].Nc; i++) { 438 Mcol += code[0].X[i]*Mc; 439 Mc *= mc; 440 } 441 Mcal += Mcol; 442 return (Mcal); 443 } 444 445 /***/ 446 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) { 447 448 if (code == NULL) return NAN; 449 450 int Ns = photcodes[0].hashNsec[code[0].code]; 451 if (Ns == -1) return (NAN); 452 453 float Mave = NAN; 454 switch (source) { 455 case MAG_SRC_CHP: 456 switch (class) { 457 case MAG_CLASS_PSF: 458 Mave = secfilt[Ns].M; 459 break; 460 case MAG_CLASS_KRON: 461 Mave = secfilt[Ns].Mkron; 462 break; 463 case MAG_CLASS_APER: 464 Mave = secfilt[Ns].Map; 465 break; 466 default: 467 break; 468 } 469 break; 470 case MAG_SRC_WRP: 471 switch (class) { 472 case MAG_CLASS_PSF: 473 Mave = secfilt[Ns].MpsfWrp; 474 break; 475 case MAG_CLASS_KRON: 476 Mave = secfilt[Ns].MkronWrp; 477 break; 478 case MAG_CLASS_APER: 479 Mave = secfilt[Ns].MapWrp; 480 break; 481 default: 482 break; 483 } 484 break; 485 case MAG_SRC_STK: 486 switch (class) { 487 case MAG_CLASS_PSF: 488 Mave = secfilt[Ns].MpsfStk; 489 break; 490 case MAG_CLASS_KRON: 491 Mave = secfilt[Ns].MkronStk; 492 break; 493 case MAG_CLASS_APER: 494 Mave = secfilt[Ns].MapStk; 495 break; 496 default: 497 break; 498 } 499 break; 500 default: 501 break; 502 } 503 return (Mave); 504 } 505 506 /* return calibrated magnitude from average/secfilt for given photcode */ 507 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure, dvoMagClassType class, dvoMagSourceType source) { 508 509 int i; 510 511 float Mave = PhotAve (code, average, secfilt, class, source); 512 if (isnan(Mave)) return NAN; 513 514 // correct for relative zero-point 515 float Mref = Mave + SCALE*code[0].C; 516 517 float mc = PhotColorForCode (average, secfilt, measure, code); 518 if (isnan(mc)) return (Mref); 519 mc -= SCALE*code[0].dX; 520 521 // correct for color terms 522 double Mc = mc; 523 float Mcol = 0; 316 524 for (i = 0; i < code[0].Nc; i++) { 317 525 Mcol += code[0].X[i]*Mc; 318 526 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 319 527 } 320 Mrel += Mcol;321 return (Mrel);322 }323 324 /* return calibrated magnitude from measure for given photcode */325 float PhotCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code) {326 327 int i, Np;328 float Mcal, Mrel, Mcol, mc, Mc;329 330 if (code == NULL) return NAN;331 332 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */333 Np = photcodes[0].hashcode[thisone[0].photcode];334 if (Np == -1) return (NAN);335 336 if (photcodes[0].code[Np].type == PHOT_REF) {337 Mrel = thisone[0].M;338 return (Mrel);339 }340 if (code[0].code != photcodes[0].code[Np].equiv) return (NAN);341 342 Mcal = PhotRel (thisone, average, secfilt) + SCALE*code[0].C;343 344 mc = PhotColorForCode (average, secfilt, measure, code);345 if (isnan(mc)) return (Mcal);346 mc = mc - SCALE*code[0].dX;347 348 Mc = mc;349 Mcol = 0;350 for (i = 0; i < code[0].Nc; i++) {351 Mcol += code[0].X[i]*Mc;352 Mc *= mc;353 }354 Mcal += Mcol;355 return (Mcal);356 }357 358 /***/359 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt) {360 361 int Ns;362 float Mave;363 364 if (code == NULL) return NAN;365 366 Ns = photcodes[0].hashNsec[code[0].code];367 Mave = (Ns == -1) ? NAN : secfilt[Ns].M;368 return (Mave);369 }370 371 /* return calibrated magnitude from average/secfilt for given photcode */372 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) {373 374 int i, Ns;375 float Mave, Mref, Mcol, mc;376 double Mc;377 378 if (code == NULL) return NAN;379 380 Ns = photcodes[0].hashNsec[code[0].code];381 Mave = (Ns == -1) ? NAN : secfilt[Ns].M;382 Mref = Mave + SCALE*code[0].C;383 384 mc = PhotColorForCode (average, secfilt, measure, code);385 if (isnan(mc)) return (Mref);386 mc = mc - SCALE*code[0].dX;387 388 Mc = mc;389 Mcol = 0;390 for (i = 0; i < code[0].Nc; i++) {391 Mcol += code[0].X[i]*Mc;392 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */393 }394 528 Mref += Mcol; 395 529 return (Mref); 396 530 } 397 531 398 float PhotAveErr (PhotCode *code, Average *average, SecFilt *secfilt) { 399 400 int Ns; 401 float dM; 402 403 if (code == NULL) return NAN; 404 405 Ns = photcodes[0].hashNsec[code[0].code]; 406 dM = (Ns == -1) ? NAN : secfilt[Ns].dM; 407 return (dM); 408 } 409 410 /************************************** APERTURE-related Magnitudes ***********************************************/ 411 412 float PhotAperInst (Measure *measure) { 413 414 int Np; 415 float Minst; 416 417 Np = photcodes[0].hashcode[measure[0].photcode]; 418 if (Np == -1) return (NAN); 419 420 if (photcodes[0].code[Np].type == PHOT_REF) { 421 Minst = measure[0].Map; 422 return (Minst); 423 } 424 Minst = measure[0].Map - measure[0].dt - ZERO_POINT; 425 426 return (Minst); 427 } 428 429 float PhotAperCat (Measure *measure) { 430 431 int Np; 432 float Mcat; 433 PhotCode *code; 434 435 Np = photcodes[0].hashcode[measure[0].photcode]; 436 if (Np == -1) return (NAN); 437 438 if (photcodes[0].code[Np].type == PHOT_REF) { 439 Mcat = measure[0].Map; 440 return (Mcat); 441 } 442 code = &photcodes[0].code[Np]; 443 Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 444 445 return (Mcat); 446 } 447 448 float PhotAperSys (Measure *measure, Average *average, SecFilt *secfilt) { 449 450 int i, Np; 451 float Mcat, Mcol, Msys, mc, Mc; 452 PhotCode *code; 453 454 Np = photcodes[0].hashcode[measure[0].photcode]; 455 if (Np == -1) return (NAN); 456 457 if (photcodes[0].code[Np].type == PHOT_REF) { 458 Mcat = measure[0].Map; 459 return (Mcat); 460 } 461 code = &photcodes[0].code[Np]; 462 Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 463 464 /* for DEP, color must be made of PRI/SEC */ 465 mc = PhotColorForCode (average, secfilt, NULL, code); 466 if (isnan(mc)) return (Mcat); 467 mc = mc - SCALE*code[0].dX; 468 469 Mc = mc; 470 Mcol = 0; 471 for (i = 0; i < code[0].Nc; i++) { 472 Mcol += code[0].X[i]*Mc; 473 Mc *= mc; 474 } 475 Msys = Mcat + Mcol; 476 return (Msys); 477 } 478 479 float PhotAperRel (Measure *measure, Average *average, SecFilt *secfilt) { 480 481 int i, Np; 482 float Mcat, Mcol, Mrel, mc, Mc; 483 PhotCode *code; 484 485 Np = photcodes[0].hashcode[measure[0].photcode]; 486 if (Np == -1) return (NAN); 487 488 if (photcodes[0].code[Np].type == PHOT_REF) { 489 Mcat = measure[0].Map; 490 return (Mcat); 491 } 492 code = &photcodes[0].code[Np]; 493 Mrel = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 494 495 /* for DEP, color must be made of PRI/SEC */ 496 mc = PhotColorForCode (average, secfilt, NULL, code); 497 if (isnan(mc)) return (Mrel); 498 mc = mc - SCALE*code[0].dX; 499 500 Mc = mc; 501 Mcol = 0; 502 for (i = 0; i < code[0].Nc; i++) { 503 Mcol += code[0].X[i]*Mc; 504 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 505 } 506 Mrel += Mcol; 507 return (Mrel); 508 } 509 510 /* return calibrated magnitude from measure for given photcode */ 511 float PhotAperCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code) { 512 513 int i, Np; 514 float Mcal, Mrel, Mcol, mc, Mc; 515 516 if (code == NULL) return NAN; 517 518 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 519 Np = photcodes[0].hashcode[thisone[0].photcode]; 520 if (Np == -1) return (NAN); 521 522 if (photcodes[0].code[Np].type == PHOT_REF) { 523 Mrel = thisone[0].Map; 524 return (Mrel); 525 } 526 if (code[0].code != photcodes[0].code[Np].equiv) return (NAN); 527 528 Mcal = PhotAperRel (thisone, average, secfilt) + SCALE*code[0].C; 529 530 mc = PhotColorForCode (average, secfilt, measure, code); 531 if (isnan(mc)) return (Mcal); 532 mc = mc - SCALE*code[0].dX; 533 534 Mc = mc; 535 Mcol = 0; 536 for (i = 0; i < code[0].Nc; i++) { 537 Mcol += code[0].X[i]*Mc; 538 Mc *= mc; 539 } 540 Mcal += Mcol; 541 return (Mcal); 542 } 543 544 float PhotAperAve (PhotCode *code, Average *average, SecFilt *secfilt) { 545 546 int Ns; 547 float Maper; 548 549 if (code == NULL) return NAN; 550 551 Ns = photcodes[0].hashNsec[code[0].code]; 552 Maper = (Ns == -1) ? NAN : secfilt[Ns].Map; 553 return (Maper); 554 } 555 556 /* return calibrated magnitude from average/secfilt for given photcode */ 557 float PhotAperRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) { 558 559 int i, Ns; 560 float Mave, Mref, Mcol, mc; 561 double Mc; 562 563 if (code == NULL) return NAN; 564 565 Ns = photcodes[0].hashNsec[code[0].code]; 566 Mave = (Ns == -1) ? NAN : secfilt[Ns].Map; 567 Mref = Mave + SCALE*code[0].C; 568 569 mc = PhotColorForCode (average, secfilt, measure, code); 570 if (isnan(mc)) return (Mref); 571 mc = mc - SCALE*code[0].dX; 572 573 Mc = mc; 574 Mcol = 0; 575 for (i = 0; i < code[0].Nc; i++) { 576 Mcol += code[0].X[i]*Mc; 577 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 578 } 579 Mref += Mcol; 580 return (Mref); 581 } 582 583 /************************************** KRON-related Magnitudes ***********************************************/ 584 585 float PhotKronInst (Measure *measure) { 586 587 int Np; 588 float Minst; 589 590 Np = photcodes[0].hashcode[measure[0].photcode]; 591 if (Np == -1) return (NAN); 592 593 if (photcodes[0].code[Np].type == PHOT_REF) { 594 Minst = measure[0].Mkron; 595 return (Minst); 596 } 597 Minst = measure[0].Mkron - measure[0].dt - ZERO_POINT; 598 599 return (Minst); 600 } 601 602 float PhotKronCat (Measure *measure) { 603 604 int Np; 605 float Mcat; 606 PhotCode *code; 607 608 Np = photcodes[0].hashcode[measure[0].photcode]; 609 if (Np == -1) return (NAN); 610 611 if (photcodes[0].code[Np].type == PHOT_REF) { 612 Mcat = measure[0].Mkron; 613 return (Mcat); 614 } 615 code = &photcodes[0].code[Np]; 616 Mcat = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 617 618 return (Mcat); 619 } 620 621 float PhotKronSys (Measure *measure, Average *average, SecFilt *secfilt) { 622 623 int i, Np; 624 float Mcat, Mcol, Msys, mc, Mc; 625 PhotCode *code; 626 627 Np = photcodes[0].hashcode[measure[0].photcode]; 628 if (Np == -1) return (NAN); 629 630 if (photcodes[0].code[Np].type == PHOT_REF) { 631 Msys = measure[0].Mkron; 632 return (Msys); 633 } 634 code = &photcodes[0].code[Np]; 635 Mcat = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 636 637 /* for DEP, color must be made of PRI/SEC */ 638 mc = PhotColorForCode (average, secfilt, NULL, code); 639 if (isnan(mc)) return (Mcat); 640 mc = mc - SCALE*code[0].dX; 641 642 Mc = mc; 643 Mcol = 0; 644 for (i = 0; i < code[0].Nc; i++) { 645 Mcol += code[0].X[i]*Mc; 646 Mc *= mc; 647 } 648 Msys = Mcat + Mcol; 649 return (Msys); 650 } 651 652 float PhotKronRel (Measure *measure, Average *average, SecFilt *secfilt) { 653 654 int i, Np; 655 float Mcat, Mcol, Mrel, mc, Mc; 656 PhotCode *code; 657 658 Np = photcodes[0].hashcode[measure[0].photcode]; 659 if (Np == -1) return (NAN); 660 661 if (photcodes[0].code[Np].type == PHOT_REF) { 662 Mcat = measure[0].Mkron; 663 return (Mcat); 664 } 665 code = &photcodes[0].code[Np]; 666 Mrel = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 667 668 /* for DEP, color must be made of PRI/SEC */ 669 mc = PhotColorForCode (average, secfilt, NULL, code); 670 if (isnan(mc)) return (Mrel); 671 mc = mc - SCALE*code[0].dX; 672 673 Mc = mc; 674 Mcol = 0; 675 for (i = 0; i < code[0].Nc; i++) { 676 Mcol += code[0].X[i]*Mc; 677 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 678 } 679 Mrel += Mcol; 680 return (Mrel); 681 } 682 683 /* return calibrated magnitude from measure for given photcode */ 684 float PhotKronCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code) { 685 686 int i, Np; 687 float Mcal, Mrel, Mcol, mc, Mc; 688 689 if (code == NULL) return NAN; 690 691 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 692 Np = photcodes[0].hashcode[thisone[0].photcode]; 693 if (Np == -1) return (NAN); 694 695 if (photcodes[0].code[Np].type == PHOT_REF) { 696 Mrel = thisone[0].Mkron; 697 return (Mrel); 698 } 699 if (code[0].code != photcodes[0].code[Np].equiv) return (NAN); 700 701 Mcal = PhotKronRel (thisone, average, secfilt) + SCALE*code[0].C; 702 703 mc = PhotColorForCode (average, secfilt, measure, code); 704 if (isnan(mc)) return (Mcal); 705 mc = mc - SCALE*code[0].dX; 706 707 Mc = mc; 708 Mcol = 0; 709 for (i = 0; i < code[0].Nc; i++) { 710 Mcol += code[0].X[i]*Mc; 711 Mc *= mc; 712 } 713 Mcal += Mcol; 714 return (Mcal); 715 } 716 717 float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt) { 718 719 int Ns; 720 float Mkron; 721 722 if (code == NULL) return NAN; 723 724 Ns = photcodes[0].hashNsec[code[0].code]; 725 Mkron = (Ns == -1) ? NAN : secfilt[Ns].Mkron; 726 return (Mkron); 727 } 728 729 /* return calibrated magnitude from average/secfilt for given photcode */ 730 float PhotKronRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) { 731 732 int i, Ns; 733 float Mave, Mref, Mcol, mc; 734 double Mc; 735 736 if (code == NULL) return NAN; 737 738 Ns = photcodes[0].hashNsec[code[0].code]; 739 Mave = (Ns == -1) ? NAN : secfilt[Ns].Mkron; 740 Mref = Mave + SCALE*code[0].C; 741 742 mc = PhotColorForCode (average, secfilt, measure, code); 743 if (isnan(mc)) return (Mref); 744 mc = mc - SCALE*code[0].dX; 745 746 Mc = mc; 747 Mcol = 0; 748 for (i = 0; i < code[0].Nc; i++) { 749 Mcol += code[0].X[i]*Mc; 750 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 751 } 752 Mref += Mcol; 753 return (Mref); 754 } 755 756 float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt) { 757 758 int Ns; 759 float dMkron; 760 761 if (code == NULL) return NAN; 762 763 Ns = photcodes[0].hashNsec[code[0].code]; 764 dMkron = (Ns == -1) ? NAN : secfilt[Ns].dMkron; 765 return (dMkron); 532 float PhotErr (Measure *measure, dvoMagClassType class) { 533 534 float dMraw = NAN; 535 switch (class) { 536 case MAG_CLASS_PSF: 537 dMraw = measure[0].dM; 538 break; 539 case MAG_CLASS_KRON: 540 dMraw = measure[0].dMkron; 541 break; 542 case MAG_CLASS_APER: 543 dMraw = measure[0].dMap; 544 break; 545 default: 546 break; 547 } 548 return (dMraw); 549 } 550 551 float PhotCalErr (Measure *measure, dvoMagClassType class) { 552 553 float dMcal = measure[0].dMcal; 554 return (dMcal); 555 } 556 557 float PhotAveErr (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) { 558 559 if (code == NULL) return NAN; 560 561 int Ns = photcodes[0].hashNsec[code[0].code]; 562 if (Ns == -1) return (NAN); 563 564 float dMave = NAN; 565 switch (source) { 566 case MAG_SRC_CHP: 567 switch (class) { 568 case MAG_CLASS_PSF: 569 dMave = secfilt[Ns].dM; 570 break; 571 case MAG_CLASS_KRON: 572 dMave = secfilt[Ns].dMkron; 573 break; 574 case MAG_CLASS_APER: 575 dMave = secfilt[Ns].dMap; 576 break; 577 default: 578 break; 579 } 580 break; 581 case MAG_SRC_WRP: 582 switch (class) { 583 case MAG_CLASS_PSF: 584 dMave = secfilt[Ns].dFpsfWrp / secfilt[Ns].FpsfWrp; 585 break; 586 case MAG_CLASS_KRON: 587 dMave = secfilt[Ns].dFkronWrp / secfilt[Ns].FkronWrp; 588 break; 589 case MAG_CLASS_APER: 590 dMave = secfilt[Ns].dFapWrp / secfilt[Ns].FapWrp; 591 break; 592 default: 593 break; 594 } 595 break; 596 case MAG_SRC_STK: 597 switch (class) { 598 case MAG_CLASS_PSF: 599 dMave = secfilt[Ns].dFpsfStk / secfilt[Ns].FpsfStk; 600 break; 601 case MAG_CLASS_KRON: 602 dMave = secfilt[Ns].dFkronStk / secfilt[Ns].FkronStk; 603 break; 604 case MAG_CLASS_APER: 605 dMave = secfilt[Ns].dFapStk / secfilt[Ns].FapStk; 606 break; 607 default: 608 break; 609 } 610 break; 611 default: 612 break; 613 } 614 return (dMave); 766 615 } 767 616 … … 788 637 789 638 /* color term may not use DEP magnitude */ 639 // currently only returns the PSF color 790 640 float PhotColorForCode (Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code) { 791 641 … … 837 687 } 838 688 839 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt) { 840 841 int Ns; 842 float Mstdev; 843 844 if (code == NULL) return NAN; 845 846 Ns = photcodes[0].hashNsec[code[0].code]; 847 Mstdev = (Ns == -1) ? NAN : 0.001*secfilt[Ns].Mstdev; 689 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) { 690 691 if (code == NULL) return NAN; 692 693 int Ns = photcodes[0].hashNsec[code[0].code]; 694 if (Ns == -1) return (NAN); 695 696 float Mstdev = NAN; 697 switch (source) { 698 case MAG_SRC_CHP: 699 switch (class) { 700 case MAG_CLASS_PSF: 701 Mstdev = secfilt[Ns].Mstdev; 702 break; 703 case MAG_CLASS_KRON: 704 Mstdev = secfilt[Ns].sMkron; 705 break; 706 case MAG_CLASS_APER: 707 Mstdev = secfilt[Ns].sMap; 708 break; 709 default: 710 break; 711 } 712 break; 713 case MAG_SRC_WRP: 714 switch (class) { 715 case MAG_CLASS_PSF: 716 Mstdev = secfilt[Ns].sFpsfWrp; 717 break; 718 case MAG_CLASS_KRON: 719 Mstdev = secfilt[Ns].sFkronWrp; 720 break; 721 case MAG_CLASS_APER: 722 Mstdev = secfilt[Ns].sFapWrp; 723 break; 724 default: 725 break; 726 } 727 break; 728 case MAG_SRC_STK: 729 default: 730 break; 731 } 848 732 return (Mstdev); 733 } 734 735 int PhotNphot (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) { 736 737 if (code == NULL) return 0; 738 739 int Ns = photcodes[0].hashNsec[code[0].code]; 740 if (Ns == -1) return 0; 741 742 int Nphot = 0; 743 switch (source) { 744 case MAG_SRC_CHP: 745 switch (class) { 746 case MAG_CLASS_PSF: 747 Nphot = secfilt[Ns].Nused; 748 break; 749 case MAG_CLASS_KRON: 750 Nphot = secfilt[Ns].NusedKron; 751 break; 752 case MAG_CLASS_APER: 753 Nphot = secfilt[Ns].NusedAp; 754 break; 755 default: 756 break; 757 } 758 break; 759 case MAG_SRC_WRP: 760 switch (class) { 761 case MAG_CLASS_PSF: 762 Nphot = secfilt[Ns].NusedWrp; 763 break; 764 case MAG_CLASS_KRON: 765 Nphot = secfilt[Ns].NusedKronWrp; 766 break; 767 case MAG_CLASS_APER: 768 Nphot = secfilt[Ns].NusedApWrp; 769 break; 770 default: 771 break; 772 } 773 break; 774 case MAG_SRC_STK: 775 default: 776 break; 777 } 778 return (Nphot); 849 779 } 850 780 … … 857 787 858 788 Ns = photcodes[0].hashNsec[code[0].code]; 859 Fpsf = (Ns == -1) ? NAN : secfilt[Ns].F luxPSF;789 Fpsf = (Ns == -1) ? NAN : secfilt[Ns].FpsfStk; 860 790 return (Fpsf); 861 791 } … … 869 799 870 800 Ns = photcodes[0].hashNsec[code[0].code]; 871 dFpsf = (Ns == -1) ? NAN : secfilt[Ns].dF luxPSF;801 dFpsf = (Ns == -1) ? NAN : secfilt[Ns].dFpsfStk; 872 802 return (dFpsf); 873 803 } … … 881 811 882 812 Ns = photcodes[0].hashNsec[code[0].code]; 883 Fkron = (Ns == -1) ? NAN : secfilt[Ns].F luxKron;813 Fkron = (Ns == -1) ? NAN : secfilt[Ns].FkronStk; 884 814 return (Fkron); 885 815 } … … 893 823 894 824 Ns = photcodes[0].hashNsec[code[0].code]; 895 dFkron = (Ns == -1) ? NAN : secfilt[Ns].dF luxKron;825 dFkron = (Ns == -1) ? NAN : secfilt[Ns].dFkronStk; 896 826 return (dFkron); 897 827 } 898 828 899 float PhotM 20(PhotCode *code, Average *average, SecFilt *secfilt) {829 float PhotMmin (PhotCode *code, Average *average, SecFilt *secfilt) { 900 830 901 831 int Ns; 902 float M 20;832 float Mmin; 903 833 904 834 if (code == NULL) return NAN; 905 835 906 836 Ns = photcodes[0].hashNsec[code[0].code]; 907 M 20 = (Ns == -1) ? NAN : 0.001*secfilt[Ns].M_20;908 return (M 20);909 } 910 911 float PhotM 80(PhotCode *code, Average *average, SecFilt *secfilt) {837 Mmin = (Ns == -1) ? NAN : secfilt[Ns].Mmin; 838 return (Mmin); 839 } 840 841 float PhotMmax (PhotCode *code, Average *average, SecFilt *secfilt) { 912 842 913 843 int Ns; 914 float M 80;844 float Mmax; 915 845 916 846 if (code == NULL) return NAN; 917 847 918 848 Ns = photcodes[0].hashNsec[code[0].code]; 919 M 80 = (Ns == -1) ? NAN : 0.001*secfilt[Ns].M_80;920 return (M 80);849 Mmax = (Ns == -1) ? NAN : secfilt[Ns].Mmax; 850 return (Mmax); 921 851 } 922 852 … … 933 863 } 934 864 935 unsigned int PhotStackID (PhotCode *code, Average *average, SecFilt *secfilt) { 865 // XX unsigned int PhotStackID (PhotCode *code, Average *average, SecFilt *secfilt) { 866 // XX 867 // XX int Ns; 868 // XX unsigned int ID; 869 // XX 870 // XX if (code == NULL) return 0; 871 // XX 872 // XX Ns = photcodes[0].hashNsec[code[0].code]; 873 // XX ID = (Ns == -1) ? 0 : secfilt[Ns].stackDetectID; 874 // XX return (ID); 875 // XX } 876 877 // Xm is now (2014.07.03) stored as the chisq except in dvo formats which use as short 878 float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt) { 936 879 937 880 int Ns; 938 unsigned int ID;939 940 if (code == NULL) return 0;881 float Xm; 882 883 if (code == NULL) return NAN; 941 884 942 885 Ns = photcodes[0].hashNsec[code[0].code]; 943 ID = (Ns == -1) ? 0 : secfilt[Ns].stackDetectID; 944 return (ID); 945 } 946 947 // XXX return NAN or NAN_S_SHORT? (secfilt->Xm is short) 948 float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt) { 949 950 int Ns; 951 short Mi; 952 float Xm; 953 954 if (code == NULL) return NAN; 955 956 Ns = photcodes[0].hashNsec[code[0].code]; 957 Mi = (Ns == -1) ? NAN : secfilt[Ns].Xm; 958 Xm = (isnan(Mi)) ? -1.0 : pow (10.0, 0.01*Mi); 886 Xm = (Ns == -1) ? NAN : secfilt[Ns].Mchisq; 959 887 return (Xm); 960 888 } … … 1006 934 } 1007 935 1008 /******** alternate photometry conversion functions using MeasureTiny and AverageTiny *********/ 1009 float PhotInstTiny (MeasureTiny *measure) { 1010 1011 int Np; 1012 float M; 1013 1014 Np = photcodes[0].hashcode[measure[0].photcode]; 936 float MagToFlux (float Mag) { 937 float Flux = pow(10.0, -0.4*(Mag)); 938 return (Flux); 939 } 940 941 /** flux conversion *******************************************************************/ 942 float PhotFluxInst (Measure *measure, dvoMagClassType class) { 943 944 float Moff = - measure[0].dt - ZERO_POINT; 945 float Finst = NAN; 946 switch (class) { 947 case MAG_CLASS_PSF: 948 Finst = isnan (measure[0].FluxPSF) ? MagToFlux(measure[0].M + Moff) : measure[0].FluxPSF; 949 break; 950 case MAG_CLASS_KRON: 951 Finst = isnan (measure[0].FluxKron) ? MagToFlux(measure[0].Mkron + Moff) : measure[0].FluxKron; 952 break; 953 case MAG_CLASS_APER: 954 Finst = isnan (measure[0].FluxAp) ? MagToFlux(measure[0].Map + Moff) : measure[0].FluxAp; 955 break; 956 default: 957 break; 958 } 959 return (Finst); 960 } 961 962 // returns Jy fluxes assuming mag in AB? (needs an extra AP factor, right?) 963 float PhotFluxCat (Measure *measure, dvoMagClassType class) { 964 965 int Np = photcodes[0].hashcode[measure[0].photcode]; 1015 966 if (Np == -1) return (NAN); 1016 1017 if (photcodes[0].code[Np].type == PHOT_REF) { 1018 M = measure[0].M; 1019 return (M); 1020 } 1021 1022 M = measure[0].M - measure[0].dt - ZERO_POINT; 1023 1024 return (M); 1025 1026 } 1027 1028 float PhotCatTiny (MeasureTiny *measure) { 1029 1030 int Np; 1031 float Mcat; 1032 PhotCode *code; 1033 1034 Np = photcodes[0].hashcode[measure[0].photcode]; 967 PhotCode *code = &photcodes[0].code[Np]; 968 969 // mag_AB = -2.5 log (flux_cgs) - 48.6 (by definition) [~Vega flux in V-band] 970 // flux_Jy = flux_cgs * 10^23 971 // -2.5 log (flux_cgs) = -2.5 log (flux_Jy * 10^-23) = -2.5 log (flux_Jy) + 2.5*23 972 973 // from these we get: 974 // mag_AB = -2.5 log (flux_Jy) + 8.9 975 // log (flux_Jy) = -0.4*mag_AB + 3.56 976 977 // mag_AB = mag_inst + ZP 978 979 // log(flux_Jy) = -0.4*mag_inst -0.4*ZP + 3.56 980 // mag_inst = -2.5 log (flux_Jy) - ZP + 8.9 981 982 // log (flux_Jy) = -0.4*(mag_inst + ZP - 8.9) 983 984 // -2.5 log (flux_inst) = -2.5 log (flux_Jy) - ZP + 8.9 985 // log (flux_inst) = log (flux_Jy) + 0.4 ZP - 3.56 986 // flux_inst = flux_Jy * 10^(0.4*ZP - 3.56) 987 // flux_Jy = flux_inst * 10^(3.56 - 0.4*ZP) = flux_inst * zpFactor 988 // flux_Jy = flux_inst * 3630.8 * 10^(-0.4*ZP) 989 990 // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux 991 float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 992 float Moff = Mcal - ZERO_POINT + 8.9; 993 float Foff = 3630.8 * MagToFlux(Mcal); 994 float Fcat = NAN; 995 switch (class) { 996 case MAG_CLASS_PSF: 997 Fcat = isnan (measure[0].FluxPSF) ? MagToFlux(measure[0].M + Moff) : measure[0].FluxPSF * Foff; 998 break; 999 case MAG_CLASS_KRON: 1000 Fcat = isnan (measure[0].FluxKron) ? MagToFlux(measure[0].Mkron + Moff) : measure[0].FluxKron * Foff; 1001 break; 1002 case MAG_CLASS_APER: 1003 Fcat = isnan (measure[0].FluxAp) ? MagToFlux(measure[0].Map + Moff) : measure[0].FluxAp * Foff; 1004 break; 1005 default: 1006 break; 1007 } 1008 return (Fcat); 1009 } 1010 1011 // corrected for color trends 1012 float PhotFluxSys (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class) { 1013 1014 int Np = photcodes[0].hashcode[measure[0].photcode]; 1035 1015 if (Np == -1) return (NAN); 1036 1037 if (photcodes[0].code[Np].type == PHOT_REF) { 1038 Mcat = measure[0].M; 1039 return (Mcat); 1040 } 1041 code = &photcodes[0].code[Np]; 1042 Mcat = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 1043 1044 return (Mcat); 1045 } 1046 1047 # if (0) 1048 float PhotAperTiny (MeasureTiny *measure) { 1049 1050 int Np; 1051 float Mcat; 1052 PhotCode *code; 1053 1054 Np = photcodes[0].hashcode[measure[0].photcode]; 1055 if (Np == -1) return (NAN); 1056 1057 if (photcodes[0].code[Np].type == PHOT_REF) { 1058 Mcat = measure[0].Map; 1059 return (Mcat); 1060 } 1061 code = &photcodes[0].code[Np]; 1062 Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 1063 1064 return (Mcat); 1065 } 1066 # endif 1067 1068 float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt) { 1069 1070 int i, Np; 1071 float Mcat, Mcol, Msys, mc, Mc; 1072 PhotCode *code; 1073 1074 Np = photcodes[0].hashcode[measure[0].photcode]; 1075 if (Np == -1) return (NAN); 1076 1077 if (photcodes[0].code[Np].type == PHOT_REF) { 1078 Msys = measure[0].M; 1079 return (Msys); 1080 } 1081 code = &photcodes[0].code[Np]; 1082 Mcat = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 1083 1084 /* for DEP, color must be made of PRI/SEC */ 1085 mc = PhotColorForCodeTiny (average, secfilt, NULL, code); 1086 if (isnan(mc)) return (Mcat); 1087 mc = mc - SCALE*code[0].dX; 1088 1089 Mc = mc; 1090 Mcol = 0; 1016 PhotCode *code = &photcodes[0].code[Np]; 1017 1018 // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux 1019 float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 1020 float Moff = Mcal - ZERO_POINT + 8.9; 1021 float Foff = 3630.8 * MagToFlux(Mcal); 1022 float Fcat = NAN; 1023 switch (class) { 1024 case MAG_CLASS_PSF: 1025 Fcat = isnan (measure[0].FluxPSF) ? MagToFlux(measure[0].M + Moff) : measure[0].FluxPSF * Foff; 1026 break; 1027 case MAG_CLASS_KRON: 1028 Fcat = isnan (measure[0].FluxKron) ? MagToFlux(measure[0].Mkron + Moff) : measure[0].FluxKron * Foff; 1029 break; 1030 case MAG_CLASS_APER: 1031 Fcat = isnan (measure[0].FluxAp) ? MagToFlux(measure[0].Map + Moff) : measure[0].FluxAp * Foff; 1032 break; 1033 default: 1034 break; 1035 } 1036 if (isnan(Fcat)) return (NAN); 1037 1038 // find the relevant color 1039 float mc = PhotColorForCode (average, secfilt, NULL, code); 1040 if (isnan(mc)) return (Fcat); 1041 mc -= SCALE*code[0].dX; 1042 1043 // find the color correction in mags 1044 int i = 0; 1045 double Mc = mc; 1046 float Mcol = 0; 1091 1047 for (i = 0; i < code[0].Nc; i++) { 1092 1048 Mcol += code[0].X[i]*Mc; 1093 1049 Mc *= mc; 1094 1050 } 1095 Msys = Mcat + Mcol; 1096 return (Msys); 1097 } 1098 1099 float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt) { 1100 1101 int i, Np; 1102 float Mcat, Mcol, Mrel, mc, Mc; 1103 PhotCode *code; 1104 1105 Np = photcodes[0].hashcode[measure[0].photcode]; 1051 float Fcol = MagToFlux (Mcol); 1052 1053 float Fsys = Fcat * Fcol; 1054 return (Fsys); 1055 } 1056 1057 float PhotFluxRel (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class) { 1058 1059 int Np = photcodes[0].hashcode[measure[0].photcode]; 1106 1060 if (Np == -1) return (NAN); 1107 1108 if (photcodes[0].code[Np].type == PHOT_REF) { 1109 Mcat = measure[0].M; 1110 return (Mcat); 1111 } 1112 code = &photcodes[0].code[Np]; 1113 Mrel = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 1061 PhotCode *code = &photcodes[0].code[Np]; 1062 1063 // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux 1064 float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 1065 float Moff = Mcal - ZERO_POINT + 8.9; 1066 float Foff = 3630.8 * MagToFlux(Mcal); 1067 float Fcat = NAN; 1068 switch (class) { 1069 case MAG_CLASS_PSF: 1070 Fcat = isnan (measure[0].FluxPSF) ? MagToFlux(measure[0].M + Moff) : measure[0].FluxPSF * Foff; 1071 break; 1072 case MAG_CLASS_KRON: 1073 Fcat = isnan (measure[0].FluxKron) ? MagToFlux(measure[0].Mkron + Moff) : measure[0].FluxKron * Foff; 1074 break; 1075 case MAG_CLASS_APER: 1076 Fcat = isnan (measure[0].FluxAp) ? MagToFlux(measure[0].Map + Moff) : measure[0].FluxAp * Foff; 1077 break; 1078 default: 1079 break; 1080 } 1081 if (isnan(Fcat)) return (NAN); 1114 1082 1115 1083 /* for DEP, color must be made of PRI/SEC */ 1116 mc = PhotColorForCodeTiny (average, secfilt, NULL, code); 1117 if (isnan(mc)) return (Mrel); 1118 mc = mc - SCALE*code[0].dX; 1119 1120 Mc = mc; 1121 Mcol = 0; 1084 float mc = PhotColorForCode (average, secfilt, NULL, code); 1085 if (isnan(mc)) return (Fcat); 1086 mc -= SCALE*code[0].dX; 1087 1088 double Mc = mc; 1089 float Mcol = 0; 1090 int i = 0; 1091 for (i = 0; i < code[0].Nc; i++) { 1092 Mcol += code[0].X[i]*Mc; 1093 Mc *= mc; 1094 } 1095 float Fcol = MagToFlux (Mcol); 1096 1097 float Frel = Fcat * Fcol; 1098 return (Frel); 1099 } 1100 1101 /* return calibrated magnitude from measure for given photcode */ 1102 float PhotFluxCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code, dvoMagClassType class) { 1103 1104 int i; 1105 1106 if (code == NULL) return NAN; 1107 1108 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 1109 int Np = photcodes[0].hashcode[thisone[0].photcode]; 1110 if (Np == -1) return (NAN); 1111 PhotCode *myCode = &photcodes[0].code[Np]; 1112 1113 if (code->code != myCode->equiv) return (NAN); 1114 1115 float Frel = PhotFluxRel (thisone, average, secfilt, class) + SCALE*code[0].C; 1116 1117 // get the relevant color term 1118 float mc = PhotColorForCode (average, secfilt, measure, code); 1119 if (isnan(mc)) return (Frel); 1120 mc -= SCALE*code[0].dX; 1121 1122 // get the corresponding color correction in mags, convert to flux 1123 double Mc = mc; 1124 float Mcol = 0; 1125 for (i = 0; i < code[0].Nc; i++) { 1126 Mcol += code[0].X[i]*Mc; 1127 Mc *= mc; 1128 } 1129 float Fcol = MagToFlux (Mcol); 1130 1131 float Fcal = Frel * Fcol; 1132 return (Fcal); 1133 } 1134 1135 /***/ 1136 float PhotFluxAve (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) { 1137 1138 if (code == NULL) return NAN; 1139 1140 int Ns = photcodes[0].hashNsec[code[0].code]; 1141 if (Ns == -1) return (NAN); 1142 1143 float Fave = NAN; 1144 switch (source) { 1145 case MAG_SRC_CHP: 1146 switch (class) { 1147 case MAG_CLASS_PSF: 1148 Fave = MagToFlux(secfilt[Ns].M); 1149 break; 1150 case MAG_CLASS_KRON: 1151 Fave = MagToFlux(secfilt[Ns].Mkron); 1152 break; 1153 case MAG_CLASS_APER: 1154 Fave = MagToFlux(secfilt[Ns].Map); 1155 break; 1156 default: 1157 break; 1158 } 1159 break; 1160 case MAG_SRC_WRP: 1161 switch (class) { 1162 case MAG_CLASS_PSF: 1163 Fave = isnan (secfilt[Ns].FpsfWrp) ? MagToFlux(secfilt[Ns].MpsfWrp) : secfilt[Ns].FpsfWrp; 1164 break; 1165 case MAG_CLASS_KRON: 1166 Fave = isnan (secfilt[Ns].FkronWrp) ? MagToFlux(secfilt[Ns].MkronWrp) : secfilt[Ns].FkronWrp; 1167 break; 1168 case MAG_CLASS_APER: 1169 Fave = isnan (secfilt[Ns].FapWrp) ? MagToFlux(secfilt[Ns].MapWrp) : secfilt[Ns].FapWrp; 1170 break; 1171 default: 1172 break; 1173 } 1174 break; 1175 case MAG_SRC_STK: 1176 switch (class) { 1177 case MAG_CLASS_PSF: 1178 Fave = isnan (secfilt[Ns].FpsfStk) ? MagToFlux(secfilt[Ns].MpsfStk) : secfilt[Ns].FpsfStk; 1179 break; 1180 case MAG_CLASS_KRON: 1181 Fave = isnan (secfilt[Ns].FkronStk) ? MagToFlux(secfilt[Ns].MkronStk) : secfilt[Ns].FkronStk; 1182 break; 1183 case MAG_CLASS_APER: 1184 Fave = isnan (secfilt[Ns].FapStk) ? MagToFlux(secfilt[Ns].MapStk) : secfilt[Ns].FapStk; 1185 break; 1186 default: 1187 break; 1188 } 1189 break; 1190 default: 1191 break; 1192 } 1193 return (Fave); 1194 } 1195 1196 float PhotFluxAveErr (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) { 1197 1198 if (code == NULL) return NAN; 1199 1200 int Ns = photcodes[0].hashNsec[code[0].code]; 1201 if (Ns == -1) return (NAN); 1202 1203 float dFave = NAN; 1204 switch (source) { 1205 case MAG_SRC_CHP: 1206 switch (class) { 1207 case MAG_CLASS_PSF: 1208 dFave = secfilt[Ns].dM * MagToFlux(secfilt[Ns].M); 1209 break; 1210 case MAG_CLASS_KRON: 1211 dFave = secfilt[Ns].dMkron * MagToFlux(secfilt[Ns].Mkron); 1212 break; 1213 case MAG_CLASS_APER: 1214 dFave = secfilt[Ns].dMap * MagToFlux(secfilt[Ns].Map); 1215 break; 1216 default: 1217 break; 1218 } 1219 break; 1220 case MAG_SRC_WRP: 1221 switch (class) { 1222 case MAG_CLASS_PSF: 1223 dFave = secfilt[Ns].dFpsfWrp; 1224 break; 1225 case MAG_CLASS_KRON: 1226 dFave = secfilt[Ns].dFkronWrp; 1227 break; 1228 case MAG_CLASS_APER: 1229 dFave = secfilt[Ns].dFapWrp; 1230 break; 1231 default: 1232 break; 1233 } 1234 break; 1235 case MAG_SRC_STK: 1236 switch (class) { 1237 case MAG_CLASS_PSF: 1238 dFave = secfilt[Ns].dFpsfStk; 1239 break; 1240 case MAG_CLASS_KRON: 1241 dFave = secfilt[Ns].dFkronStk; 1242 break; 1243 case MAG_CLASS_APER: 1244 dFave = secfilt[Ns].dFapStk; 1245 break; 1246 default: 1247 break; 1248 } 1249 break; 1250 default: 1251 break; 1252 } 1253 return (dFave); 1254 } 1255 1256 /* return calibrated magnitude from average/secfilt for given photcode */ 1257 float PhotFluxRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure, dvoMagClassType class, dvoMagSourceType source) { 1258 1259 int i; 1260 1261 float Fave = PhotFluxAve (code, average, secfilt, class, source); 1262 if (isnan(Fave)) return NAN; 1263 1264 // correct for relative zero-point 1265 float Moff = SCALE*code[0].C; 1266 1267 float mc = PhotColorForCode (average, secfilt, measure, code); 1268 if (isnan(mc)) return (Fave * MagToFlux(Moff)); 1269 mc -= SCALE*code[0].dX; 1270 1271 // correct for color terms 1272 double Mc = mc; 1273 float Mcol = 0; 1122 1274 for (i = 0; i < code[0].Nc; i++) { 1123 1275 Mcol += code[0].X[i]*Mc; 1124 1276 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 1125 1277 } 1126 Mrel += Mcol; 1127 return (Mrel); 1128 } 1129 1130 /* return calibrated magnitude from measure for given photcode */ 1131 float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code) { 1132 1133 int i, Np; 1134 float Mcal, Mrel, Mcol, mc, Mc; 1135 1136 if (code == NULL) return NAN; 1137 1138 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 1139 Np = photcodes[0].hashcode[thisone[0].photcode]; 1278 float Foff = MagToFlux(Mcol); 1279 return (Fave * Foff); 1280 } 1281 1282 float PhotFluxInstErr (Measure *measure, dvoMagClassType class) { 1283 1284 float Moff = - measure[0].dt - ZERO_POINT; 1285 1286 // use dFlux if we can, but use dMag if we must: 1287 // dFlux = Flux * dMag 1288 1289 float dFinst = NAN; 1290 switch (class) { 1291 case MAG_CLASS_PSF: 1292 if (isnan (measure[0].dFluxPSF)) { 1293 float Finst = MagToFlux(measure[0].M + Moff); 1294 dFinst = measure[0].dM * Finst; 1295 } else { 1296 dFinst = measure[0].dFluxPSF; 1297 } 1298 break; 1299 case MAG_CLASS_KRON: 1300 if (isnan (measure[0].dFluxKron)) { 1301 float Finst = MagToFlux(measure[0].Mkron + Moff); 1302 dFinst = measure[0].dMkron * Finst; 1303 } else { 1304 dFinst = measure[0].dFluxKron; 1305 } 1306 break; 1307 case MAG_CLASS_APER: 1308 if (isnan (measure[0].dFluxAp)) { 1309 float Finst = MagToFlux(measure[0].Map + Moff); 1310 dFinst = measure[0].dMap * Finst; 1311 } else { 1312 dFinst = measure[0].dFluxAp; 1313 } 1314 break; 1315 default: 1316 break; 1317 } 1318 return (dFinst); 1319 } 1320 1321 float PhotFluxCatErr (Measure *measure, dvoMagClassType class) { 1322 1323 int Np = photcodes[0].hashcode[measure[0].photcode]; 1140 1324 if (Np == -1) return (NAN); 1141 1142 if (photcodes[0].code[Np].type == PHOT_REF) { 1143 Mrel = thisone[0].M; 1144 return (Mrel); 1145 } 1146 if (code[0].code != photcodes[0].code[Np].equiv) return (NAN); 1147 1148 Mcal = PhotRelTiny (thisone, average, secfilt) + SCALE*code[0].C; 1149 1150 mc = PhotColorForCodeTiny (average, secfilt, measure, code); 1151 if (isnan(mc)) return (Mcal); 1152 mc = mc - SCALE*code[0].dX; 1153 1154 Mc = mc; 1155 Mcol = 0; 1325 PhotCode *code = &photcodes[0].code[Np]; 1326 1327 // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux 1328 float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 1329 float Moff = Mcal - ZERO_POINT + 8.9; 1330 float Foff = 3630.8 * MagToFlux(Mcal); 1331 1332 // use dFlux if we can, but use dMag if we must: 1333 // dFlux = Flux * dMag 1334 1335 float dFcat = NAN; 1336 switch (class) { 1337 case MAG_CLASS_PSF: 1338 if (isnan (measure[0].dFluxPSF)) { 1339 float Finst = MagToFlux(measure[0].M + Moff); 1340 dFcat = measure[0].dM * Finst; 1341 } else { 1342 dFcat = measure[0].dFluxPSF * Foff; 1343 } 1344 break; 1345 case MAG_CLASS_KRON: 1346 if (isnan (measure[0].dFluxKron)) { 1347 float Finst = MagToFlux(measure[0].Mkron + Moff); 1348 dFcat = measure[0].dMkron * Finst; 1349 } else { 1350 dFcat = measure[0].dFluxKron * Foff; 1351 } 1352 break; 1353 case MAG_CLASS_APER: 1354 if (isnan (measure[0].dFluxAp)) { 1355 float Finst = MagToFlux(measure[0].Map + Moff); 1356 dFcat = measure[0].dMap * Finst; 1357 } else { 1358 dFcat = measure[0].dFluxAp * Foff; 1359 } 1360 break; 1361 default: 1362 break; 1363 } 1364 return (dFcat); 1365 } 1366 1367 /******** alternate photometry conversion functions using MeasureTiny and AverageTiny *********/ 1368 float PhotInstTiny (MeasureTiny *measure, dvoMagClassType class) { 1369 1370 int Np = photcodes[0].hashcode[measure[0].photcode]; 1371 if (Np == -1) return (NAN); 1372 PhotCode *code = &photcodes[0].code[Np]; 1373 1374 float Mraw = NAN; 1375 switch (class) { 1376 case MAG_CLASS_PSF: 1377 Mraw = measure[0].M; 1378 break; 1379 case MAG_CLASS_KRON: 1380 // Mraw = measure[0].Mkron; 1381 break; 1382 case MAG_CLASS_APER: 1383 // Mraw = measure[0].Map; 1384 break; 1385 default: 1386 break; 1387 } 1388 if (code->type == PHOT_REF) { 1389 return (Mraw); 1390 } 1391 float Minst = Mraw - measure[0].dt - ZERO_POINT; 1392 1393 return (Minst); 1394 } 1395 1396 float PhotCatTiny (MeasureTiny *measure, dvoMagClassType class) { 1397 1398 int Np = photcodes[0].hashcode[measure[0].photcode]; 1399 if (Np == -1) return (NAN); 1400 PhotCode *code = &photcodes[0].code[Np]; 1401 1402 float Mraw = NAN; 1403 switch (class) { 1404 case MAG_CLASS_PSF: 1405 Mraw = measure[0].M; 1406 break; 1407 case MAG_CLASS_KRON: 1408 // Mraw = measure[0].Mkron; 1409 break; 1410 case MAG_CLASS_APER: 1411 // Mraw = measure[0].Map; 1412 break; 1413 default: 1414 break; 1415 } 1416 if (code->type == PHOT_REF) { 1417 return (Mraw); 1418 } 1419 1420 float Mcat = Mraw - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 1421 1422 return (Mcat); 1423 } 1424 1425 float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class) { 1426 1427 int Np = photcodes[0].hashcode[measure[0].photcode]; 1428 if (Np == -1) return (NAN); 1429 PhotCode *code = &photcodes[0].code[Np]; 1430 1431 float Mraw = NAN; 1432 switch (class) { 1433 case MAG_CLASS_PSF: 1434 Mraw = measure[0].M; 1435 break; 1436 case MAG_CLASS_KRON: 1437 // Mraw = measure[0].Mkron; 1438 break; 1439 case MAG_CLASS_APER: 1440 // Mraw = measure[0].Map; 1441 break; 1442 default: 1443 break; 1444 } 1445 if (code->type == PHOT_REF) { 1446 return (Mraw); 1447 } 1448 float Mcat = Mraw - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 1449 1450 /* for DEP, color must be made of PRI/SEC */ 1451 float mc = PhotColorForCodeTiny (average, secfilt, NULL, code); 1452 if (isnan(mc)) return (Mcat); 1453 mc -= SCALE*code[0].dX; 1454 1455 int i = 0; 1456 double Mc = mc; 1457 float Mcol = 0; 1156 1458 for (i = 0; i < code[0].Nc; i++) { 1157 1459 Mcol += code[0].X[i]*Mc; 1158 1460 Mc *= mc; 1159 1461 } 1462 float Msys = Mcat + Mcol; 1463 return (Msys); 1464 } 1465 1466 float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class) { 1467 1468 int Np = photcodes[0].hashcode[measure[0].photcode]; 1469 if (Np == -1) return (NAN); 1470 PhotCode *code = &photcodes[0].code[Np]; 1471 1472 float Mraw = NAN; 1473 switch (class) { 1474 case MAG_CLASS_PSF: 1475 Mraw = measure[0].M; 1476 break; 1477 case MAG_CLASS_KRON: 1478 // Mraw = measure[0].Mkron; 1479 break; 1480 case MAG_CLASS_APER: 1481 // Mraw = measure[0].Map; 1482 break; 1483 default: 1484 break; 1485 } 1486 if (code->type == PHOT_REF) { 1487 return (Mraw); 1488 } 1489 float Mcat = Mraw - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 1490 1491 /* for DEP, color must be made of PRI/SEC */ 1492 float mc = PhotColorForCodeTiny (average, secfilt, NULL, code); 1493 if (isnan(mc)) return (Mcat); 1494 mc -= SCALE*code[0].dX; 1495 1496 double Mc = mc; 1497 float Mcol = 0; 1498 int i = 0; 1499 for (i = 0; i < code[0].Nc; i++) { 1500 Mcol += code[0].X[i]*Mc; 1501 Mc *= mc; 1502 } 1503 float Mrel = Mcat + Mcol; 1504 return (Mrel); 1505 } 1506 1507 /* return calibrated magnitude from measure for given photcode */ 1508 float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code, dvoMagClassType class) { 1509 1510 int i; 1511 1512 if (code == NULL) return NAN; 1513 1514 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 1515 int Np = photcodes[0].hashcode[thisone[0].photcode]; 1516 if (Np == -1) return (NAN); 1517 PhotCode *myCode = &photcodes[0].code[Np]; 1518 1519 if (code->code != myCode->equiv) return (NAN); 1520 1521 // if we are REF type, just get the right version and return 1522 if (myCode->type == PHOT_REF) { 1523 float Mraw = NAN; 1524 switch (class) { 1525 case MAG_CLASS_PSF: 1526 Mraw = thisone[0].M; 1527 break; 1528 case MAG_CLASS_KRON: 1529 // Mraw = thisone[0].Mkron; 1530 break; 1531 case MAG_CLASS_APER: 1532 // Mraw = thisone[0].Map; 1533 break; 1534 default: 1535 break; 1536 } 1537 return (Mraw); 1538 } 1539 1540 float Mcal = PhotRelTiny (thisone, average, secfilt, class) + SCALE*code[0].C; 1541 1542 float mc = PhotColorForCodeTiny (average, secfilt, measure, code); 1543 if (isnan(mc)) return (Mcal); 1544 mc -= SCALE*code[0].dX; 1545 1546 double Mc = mc; 1547 float Mcol = 0; 1548 for (i = 0; i < code[0].Nc; i++) { 1549 Mcol += code[0].X[i]*Mc; 1550 Mc *= mc; 1551 } 1160 1552 Mcal += Mcol; 1161 1553 return (Mcal); 1554 } 1555 1556 /***/ 1557 float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) { 1558 1559 if (code == NULL) return NAN; 1560 1561 int Ns = photcodes[0].hashNsec[code[0].code]; 1562 if (Ns == -1) return (NAN); 1563 1564 float Mave = NAN; 1565 switch (source) { 1566 case MAG_SRC_CHP: 1567 switch (class) { 1568 case MAG_CLASS_PSF: 1569 Mave = secfilt[Ns].M; 1570 break; 1571 case MAG_CLASS_KRON: 1572 Mave = secfilt[Ns].Mkron; 1573 break; 1574 case MAG_CLASS_APER: 1575 Mave = secfilt[Ns].Map; 1576 break; 1577 default: 1578 break; 1579 } 1580 break; 1581 case MAG_SRC_WRP: 1582 switch (class) { 1583 case MAG_CLASS_PSF: 1584 Mave = secfilt[Ns].MpsfWrp; 1585 break; 1586 case MAG_CLASS_KRON: 1587 Mave = secfilt[Ns].MkronWrp; 1588 break; 1589 case MAG_CLASS_APER: 1590 Mave = secfilt[Ns].MapWrp; 1591 break; 1592 default: 1593 break; 1594 } 1595 break; 1596 case MAG_SRC_STK: 1597 switch (class) { 1598 case MAG_CLASS_PSF: 1599 Mave = secfilt[Ns].MpsfStk; 1600 break; 1601 case MAG_CLASS_KRON: 1602 Mave = secfilt[Ns].MkronStk; 1603 break; 1604 case MAG_CLASS_APER: 1605 Mave = secfilt[Ns].MapStk; 1606 break; 1607 default: 1608 break; 1609 } 1610 break; 1611 default: 1612 break; 1613 } 1614 return (Mave); 1615 } 1616 1617 /* return calibrated magnitude from average/secfilt for given photcode */ 1618 float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, dvoMagClassType class, dvoMagSourceType source) { 1619 1620 int i; 1621 1622 float Mave = PhotAveTiny (code, average, secfilt, class, source); 1623 if (isnan(Mave)) return NAN; 1624 1625 // correct for relative zero-point 1626 float Mref = Mave + SCALE*code[0].C; 1627 1628 float mc = PhotColorForCodeTiny (average, secfilt, measure, code); 1629 if (isnan(mc)) return (Mref); 1630 mc -= SCALE*code[0].dX; 1631 1632 // correct for color terms 1633 double Mc = mc; 1634 float Mcol = 0; 1635 for (i = 0; i < code[0].Nc; i++) { 1636 Mcol += code[0].X[i]*Mc; 1637 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 1638 } 1639 Mref += Mcol; 1640 return (Mref); 1162 1641 } 1163 1642 … … 1212 1691 } 1213 1692 1214 /* return calibrated magnitude from average/secfilt for given photcode */1215 float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure) {1216 1217 int i, Ns;1218 float Mave, Mref, Mcol, mc;1219 double Mc;1220 1221 if (code == NULL) return NAN;1222 1223 Ns = photcodes[0].hashNsec[code[0].code];1224 Mave = (Ns == -1) ? NAN : secfilt[Ns].M;1225 Mref = Mave + SCALE*code[0].C;1226 1227 mc = PhotColorForCodeTiny (average, secfilt, measure, code);1228 if (isnan(mc)) return (Mref);1229 mc = mc - SCALE*code[0].dX;1230 1231 Mc = mc;1232 Mcol = 0;1233 for (i = 0; i < code[0].Nc; i++) {1234 Mcol += code[0].X[i]*Mc;1235 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */1236 }1237 Mref += Mcol;1238 return (Mref);1239 }1240 1241 /***/1242 float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) {1243 1244 int Ns;1245 float Mave;1246 1247 if (code == NULL) return NAN;1248 1249 Ns = photcodes[0].hashNsec[code[0].code];1250 Mave = (Ns == -1) ? NAN : secfilt[Ns].M;1251 return (Mave);1252 }1253 1254 1693 float PhotdMTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) { 1255 1694 … … 1264 1703 } 1265 1704 1266 // X XX return NAN or NAN_S_SHORT? (secfilt->Xm is short)1705 // Xm is now (2014.07.03) stored as the chisq except in dvo formats which use as short 1267 1706 float PhotXmTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) { 1268 1707 1269 1708 int Ns; 1270 short Mi;1271 1709 float Xm; 1272 1710 … … 1274 1712 1275 1713 Ns = photcodes[0].hashNsec[code[0].code]; 1276 Mi = (Ns == -1) ? NAN : secfilt[Ns].Xm; 1277 Xm = (isnan(Mi)) ? -1.0 : pow (10.0, 0.01*Mi); 1714 Xm = (Ns == -1) ? NAN : secfilt[Ns].Mchisq; 1278 1715 return (Xm); 1279 1716 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_tiny_values.c
r36680 r37403 14 14 15 15 void CopyMeasureToTiny (MeasureTiny *measureT, Measure *measure) { 16 measureT[0]. dR = measure[0].dR;17 measureT[0]. dD = measure[0].dD;16 measureT[0].R = measure[0].R; 17 measureT[0].D = measure[0].D; 18 18 measureT[0].M = measure[0].M; 19 19 measureT[0].Mcal = measure[0].Mcal; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/skyregion_io.c
r33649 r37403 78 78 gfits_free_matrix (&matrix); 79 79 gfits_free_header (&theader); 80 fclose (f); 80 81 81 82 return (skytable); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libfits/include/gfitsio.h
r35756 r37403 27 27 # define FT_RECORD_SIZE 2880 /* FITS block size */ 28 28 29 # define FT_BZERO_INT8 -1.0*0x80 29 30 # define FT_BZERO_INT16 1.0*0x8000 30 31 # define FT_BZERO_INT32 1.0*0x80000000 32 # define FT_BZERO_INT64 1.0*0x8000000000000000 31 33 32 34 /* this structure defines the buffer which contains a header -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libfits/matrix/F_compress_M.c
r34088 r37403 58 58 59 59 // is ZIMAGE present? 60 // NOTE target of %t must be int length 60 61 status = gfits_scan_alt (ftable->header, "ZIMAGE", "%t", 1, &zimage); 61 62 if (!status || !zimage) ESCAPE; … … 125 126 int have_ztension; 126 127 128 // NOTE target of %t must be int length 127 129 have_zsimple = gfits_scan_alt (header, "ZSIMPLE", "%t", 1, &zsimple); 128 130 have_ztension = gfits_scan (header, "ZTENSION", "%s", 1, exttype); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libfits/table/F_get_column.c
r36680 r37403 75 75 Pout = array; 76 76 if (!strcmp (type, "char")) { 77 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 78 *(char *)Pout = *(char *)Pin*Bscale + Bzero; 79 } 80 } 81 if (!strcmp (type, "byte")) { 77 82 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 78 83 *(char *)Pout = *(char *)Pin*Bscale + Bzero; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libfits/table/F_set_column.c
r35101 r37403 81 81 Pin = data; 82 82 Pout = array; 83 // does it makes sense to scale 'char' data? 83 84 if (!strcmp (type, "char")) { 85 for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) { 86 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 87 } 88 } 89 if (!strcmp (type, "byte")) { 84 90 for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) { 85 91 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; … … 221 227 Pout = array; 222 228 229 // # define ASSIGN_DATA(ITYPE,INAME,ISIZE,OTYPE,ONAME) 230 // if (!strcmp (intype, #ITYPE)) { 231 223 232 /** input == char **/ 224 233 if (!strcmp (outtype, "char") && !strcmp (intype, "char")) { … … 228 237 } 229 238 } 239 if (!strcmp (outtype, "byte") && !strcmp (intype, "char")) { 240 int NbytesIn = 1; 241 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) { 242 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 243 } 244 } 230 245 if (!strcmp (outtype, "short") && !strcmp (intype, "char")) { 231 246 int NbytesIn = 1; … … 265 280 } 266 281 if (!strcmp (outtype, "double") && !strcmp (intype, "char")) { 282 int NbytesIn = 1; 283 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 284 *(double *)Pout = (*(char *)Pin - Bzero) / Bscale; 285 # ifdef BYTE_SWAP 286 SWAP_DBLE; 287 # endif 288 } 289 } 290 291 /** input == byte **/ 292 if (!strcmp (outtype, "char") && !strcmp (intype, "byte")) { 293 int NbytesIn = 1; 294 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) { 295 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 296 } 297 } 298 if (!strcmp (outtype, "byte") && !strcmp (intype, "byte")) { 299 int NbytesIn = 1; 300 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) { 301 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 302 } 303 } 304 if (!strcmp (outtype, "short") && !strcmp (intype, "byte")) { 305 int NbytesIn = 1; 306 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 307 *(short *)Pout = (*(char *)Pin - Bzero) / Bscale; 308 # ifdef BYTE_SWAP 309 SWAP_BYTE; 310 # endif 311 } 312 } 313 if (!strcmp (outtype, "int") && !strcmp (intype, "byte")) { 314 int NbytesIn = 1; 315 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 316 *(int *)Pout = (*(char *)Pin - Bzero) / Bscale; 317 # ifdef BYTE_SWAP 318 SWAP_WORD; 319 # endif 320 } 321 } 322 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "byte")) { 323 int NbytesIn = 1; 324 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 325 *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale; 326 # ifdef BYTE_SWAP 327 SWAP_DBLE; 328 # endif 329 } 330 } 331 if (!strcmp (outtype, "float") && !strcmp (intype, "byte")) { 332 int NbytesIn = 1; 333 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 334 *(float *)Pout = (*(char *)Pin - Bzero) / Bscale; 335 # ifdef BYTE_SWAP 336 SWAP_WORD; 337 # endif 338 } 339 } 340 if (!strcmp (outtype, "double") && !strcmp (intype, "byte")) { 267 341 int NbytesIn = 1; 268 342 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { … … 281 355 } 282 356 } 357 if (!strcmp (outtype, "byte") && !strcmp (intype, "short")) { 358 int NbytesIn = 2; 359 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 360 *(char *)Pout = (*(short *)Pin - Bzero) / Bscale; 361 } 362 } 283 363 if (!strcmp (outtype, "short") && !strcmp (intype, "short")) { 284 364 int NbytesIn = 2; … … 334 414 } 335 415 } 416 if (!strcmp (outtype, "byte") && !strcmp (intype, "int")) { 417 int NbytesIn = 4; 418 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 419 *(char *)Pout = (*(int *)Pin - Bzero) / Bscale; 420 } 421 } 336 422 if (!strcmp (outtype, "short") && !strcmp (intype, "int")) { 337 423 int NbytesIn = 4; … … 387 473 } 388 474 } 475 if (!strcmp (outtype, "byte") && !strcmp (intype, "int64_t")) { 476 int NbytesIn = 8; 477 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 478 *(char *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 479 } 480 } 389 481 if (!strcmp (outtype, "short") && !strcmp (intype, "int64_t")) { 390 482 int NbytesIn = 8; … … 440 532 } 441 533 } 534 if (!strcmp (outtype, "byte") && !strcmp (intype, "float")) { 535 int NbytesIn = 4; 536 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 537 *(char *)Pout = (*(float *)Pin - Bzero) / Bscale; 538 } 539 } 442 540 if (!strcmp (outtype, "short") && !strcmp (intype, "float")) { 443 541 int NbytesIn = 4; … … 488 586 /** input == double **/ 489 587 if (!strcmp (outtype, "char") && !strcmp (intype, "double")) { 588 int NbytesIn = 8; 589 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 590 *(char *)Pout = (*(double *)Pin - Bzero) / Bscale; 591 } 592 } 593 if (!strcmp (outtype, "byte") && !strcmp (intype, "double")) { 490 594 int NbytesIn = 8; 491 595 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libfits/table/F_table_format.c
r28241 r37403 19 19 if ((Nv == 0) && (Fchar == format)) Nv = 1; 20 20 21 // NOTE: X, L, B all are stored in 1-byte columns (X by default has at least room for 8 bits) 22 // I report these as type 'byte' as opposed to 'char', which is interpreted as a string 23 21 24 *Nbytes = 0; 22 25 switch (*Fchar) { 23 26 case 'X': 24 { *Nbytes = 1; strcpy (type, " char"); *Nval = 1 + (int) Nv / 8; }27 { *Nbytes = 1; strcpy (type, "byte"); *Nval = 1 + (int) Nv / 8; } 25 28 break; 26 29 case 'L': 27 { *Nbytes = 1; strcpy (type, " char"); *Nval = Nv; }30 { *Nbytes = 1; strcpy (type, "byte"); *Nval = Nv; } 28 31 break; 29 32 case 'A': … … 31 34 break; 32 35 case 'B': 33 { *Nbytes = 1; strcpy (type, " char"); *Nval = Nv; }36 { *Nbytes = 1; strcpy (type, "byte"); *Nval = Nv; } 34 37 break; 35 38 case 'I': … … 268 271 } 269 272 273 // Does it make sense to scale 'char' data (as opposed to 'byte')? 270 274 if (!strcmp (type, "char")) { 275 for (j = 0; j < Ny; j++) { 276 for (n = 0; n < Nval; n++) { 277 tmpChar = (char *)&ftable[0].buffer[j*Nx + n*Nbytes + off]; 278 *tmpChar = *tmpChar * tscale + tzero; 279 } 280 } 281 } 282 if (!strcmp (type, "byte")) { 271 283 for (j = 0; j < Ny; j++) { 272 284 for (n = 0; n < Nval; n++) { … … 352 364 } 353 365 366 // does this make sense? (see note above) 354 367 if (!strcmp (type, "char")) { 355 368 for (j = 0; j < Ny; j++) { … … 360 373 } 361 374 } 375 if (!strcmp (type, "byte")) { 376 for (j = 0; j < Ny; j++) { 377 for (n = 0; n < Nval; n++) { 378 tmpChar = (char *)&ftable[0].buffer[j*Nx + n*Nbytes + off]; 379 *tmpChar = (*tmpChar - tzero) / tscale; 380 } 381 } 382 } 362 383 if (!strcmp (type, "short")) { 363 384 for (j = 0; j < Ny; j++) { -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libkapa/src/KapaOpen.c
r35761 r37403 1 1 # include "kapa_internal.h" 2 3 // kapa connection timeout is N_RETRY * 10000 usec 4 # define N_RETRY 2000 2 5 3 6 # define MY_PORT 2500 … … 9 12 static int *VALID = NULL; 10 13 11 char *_parse_nextword (char *string);12 14 int KapaLaunchCommand (char *line); 13 15 … … 218 220 // apparently, I can connect on someone else's port (eg GoogleTalkPlugin) 219 221 // do a simple handshake before we set !NONBLOCK: 220 char line[5]; 221 int Nout = read (InitSocket, line, 4); 222 if (Nout != 4) { 223 if (DEBUG) fprintf (stderr, "connection failed\n"); 224 close (InitSocket); 225 return (-1); 226 } 227 if (strncmp (line, "KAPA", 4)) { 228 if (DEBUG) fprintf (stderr, "connection to the wrong server\n"); 229 close (InitSocket); 230 return (-1); 222 223 // ensure the socket is NONBLOCK first... 224 fcntl (InitSocket, F_SETFL, O_NONBLOCK); 225 226 int Ntry = 0; 227 retry_message: 228 { 229 char line[5]; 230 int Nout = read (InitSocket, line, 4); 231 if ((Nout == -1) && (errno == EAGAIN)) { 232 Ntry ++; 233 if (Ntry > 500) { 234 if (DEBUG) fprintf (stderr, "handshake failure\n"); 235 close (InitSocket); 236 return (-1); 237 } 238 usleep (10000); 239 goto retry_message; 240 } 241 if (Nout != 4) { 242 if (DEBUG) fprintf (stderr, "connection failed\n"); 243 close (InitSocket); 244 return (-1); 245 } 246 if (strncmp (line, "KAPA", 4)) { 247 if (DEBUG) fprintf (stderr, "connection to the wrong server\n"); 248 close (InitSocket); 249 return (-1); 250 } 231 251 } 232 252 … … 265 285 } 266 286 267 # define NTRY 500 287 INITTIME; 288 268 289 Ntry = 0; 269 while (Ntry < N TRY) {290 while (Ntry < N_RETRY) { 270 291 sock = KapaClientSocket ("localhost"); 271 292 if (sock != -1) break; 272 // if (errno != EAGAIN) break; 273 if (errno != ECONNREFUSED) break; 293 if (errno != ECONNREFUSED) { 294 perror ("KapaOpen"); 295 break; 296 } 274 297 // no connection yet. try again, but first check 275 298 // if the kapa job has exited … … 288 311 } 289 312 290 if (sock < 0) return (-1); 313 if (sock < 0) { 314 MARKTIME ("failed to connect to kapa after %f seconds\n", dtime); 315 int killStatus = kill (pid, SIGKILL); 316 if (killStatus) { 317 perror ("failed to kill process"); 318 } 319 int waitStatus = waitpid (pid, NULL, 0); 320 if (waitStatus == pid) { 321 fprintf (stderr, "harvested process %d\n", pid); 322 } else if (waitStatus < 0) { 323 fprintf (stderr, "failed to harvest process %d\n", pid); 324 } else if (waitStatus == 0) { 325 fprintf (stderr, "process not exited: %d\n", pid); 326 } else { 327 fprintf (stderr, "odd exit status: %d vs pid %d\n", waitStatus, pid); 328 } 329 return (-1); 330 } 331 291 332 return (sock); 292 333 } … … 330 371 fcntl (InitSocket, F_SETFL, O_NONBLOCK); 331 372 332 # define NTRY 500 373 INITTIME; 374 333 375 Ntry = 0; 334 while (Ntry < N TRY) {376 while (Ntry < N_RETRY) { 335 377 fd = accept (InitSocket, (struct sockaddr *)&Address, &AddressLength); 336 378 if (fd != -1) break; … … 352 394 } 353 395 354 if (fd < 0) return (-1); 396 if (fd < 0) { 397 MARKTIME ("failed to connect to kapa after %f seconds\n", dtime); 398 kill (pid, SIGKILL); 399 waitpid (pid, NULL, WNOHANG); 400 return (-1); 401 } 355 402 356 403 // the client uses a BLOCKing socket by default … … 394 441 done = FALSE; 395 442 while (!done) { 396 q = _parse_nextword (p);443 q = parse_nextword (p); 397 444 if (q && *q) { 398 445 argv[i] = strncreate (p, q - p); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libohana/include/ohana.h
r35754 r37403 71 71 # endif 72 72 73 # define MARKTIME(MSG,...) { \ 74 gettimeofday (&stopTimer, (void *) NULL); \ 75 float dtime = DTIME (stopTimer, startTimer); \ 76 fprintf (stderr, MSG, __VA_ARGS__); } 77 78 # define INITTIME \ 79 struct timeval startTimer, stopTimer; \ 80 gettimeofday (&startTimer, (void *) NULL); 81 73 82 #ifdef __GNUC__ 74 83 #define OHANA_FORMAT(style, fmt, varargs) __attribute__((format(style, fmt, varargs))) … … 183 192 184 193 # ifndef isfinite 185 # define isfinite(A) (!isnan(A) )194 # define isfinite(A) (!isnan(A) && !isinf(A)) 186 195 # endif 187 196 … … 252 261 int scan_line PROTO((FILE *f, char *line)); 253 262 int scan_line_maxlen PROTO((FILE *f, char *line, int maxlen)); 263 char *parse_nextword PROTO((char *string)); 264 char *parse_nextword_csv PROTO((char *string)); 254 265 int dparse PROTO((double *X, int NX, char *line)); 255 266 int dparse_csv PROTO((double *X, int NX, char *line)); 256 267 int iparse PROTO((int *X, int NX, char *line)); 257 268 int iparse_csv PROTO((int *X, int NX, char *line)); 269 int charparse_csv PROTO((char *X, int NX, char *line)); 270 char *ptrparse PROTO((int NX, char *line)); 271 char *ptrparse_csv PROTO((int NX, char *line)); 258 272 int charparse_csv PROTO((char *X, int NX, char *line)); 259 273 int charparse PROTO((char *X, int NX, char *line)); … … 266 280 char *strip_version PROTO((char *input)); 267 281 char *strsubs PROTO((char *string, char *match, char *with)); 282 283 char *getword PROTO((char *string)); 284 char *skipword PROTO((char *string)); 268 285 269 286 /* in findexec.c */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libohana/src
- Property svn:mergeinfo deleted
-
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libohana/src/string.c
r34753 r37403 167 167 } 168 168 169 char * _parse_nextword (char *string) {169 char *parse_nextword (char *string) { 170 170 171 171 if (string == (char *) NULL) return ((char *) NULL); … … 182 182 // ,,, : go from , to , to , to 0 183 183 184 char * _parse_nextword_csv (char *string) {184 char *parse_nextword_csv (char *string) { 185 185 186 186 if (string == (char *) NULL) return ((char *) NULL); … … 199 199 word = line; 200 200 for (i = 0; i < NX - 1; i++) 201 word = _parse_nextword (word);201 word = parse_nextword (word); 202 202 203 203 *X = strtod (word, &ptr); … … 215 215 word = line; 216 216 for (i = 0; i < NX - 1; i++) 217 word = _parse_nextword_csv (word);217 word = parse_nextword_csv (word); 218 218 219 219 if (word[0] == '"') word[0] = ' '; … … 237 237 word = line; 238 238 for (i = 0; i < NX - 1; i++) 239 word = _parse_nextword (word);239 word = parse_nextword (word); 240 240 241 241 *X = strtol (word, &ptr, 0); … … 253 253 word = line; 254 254 for (i = 0; i < NX - 1; i++) 255 word = _parse_nextword_csv (word);255 word = parse_nextword_csv (word); 256 256 257 257 if (word[0] == '"') word[0] = ' '; … … 274 274 word = line; 275 275 for (i = 0; i < NX - 1; i++) 276 word = _parse_nextword (word);276 word = parse_nextword (word); 277 277 278 278 *X = word[0]; … … 287 287 word = line; 288 288 for (i = 0; i < NX - 1; i++) 289 word = _parse_nextword_csv (word);289 word = parse_nextword_csv (word); 290 290 291 291 if (word[0] == '"') word[0] = word[1]; … … 299 299 } 300 300 301 // return a pointer to the start of the desired field 302 char *ptrparse (int NX, char *line) { 303 304 int i; 305 char *word; 306 307 word = line; 308 for (i = 0; i < NX - 1; i++) { 309 word = parse_nextword (word); 310 } 311 return word; 312 } 313 314 char *ptrparse_csv (int NX, char *line) { 315 316 int i; 317 char *word; 318 319 word = line; 320 for (i = 0; i < NX - 1; i++) 321 word = parse_nextword_csv (word); 322 323 if (word[0] == '"') word ++; 324 if (word[0] == ',') return NULL; 325 return word; 326 } 327 301 328 int tparse (time_t *X, int NX, char *line) { 302 329 … … 306 333 word = line; 307 334 for (i = 0; i < NX - 1; i++) 308 word = _parse_nextword (word);335 word = parse_nextword (word); 309 336 310 337 status = ohana_str_to_time (word, X); … … 320 347 word = line; 321 348 for (i = 0; i < NX - 1; i++) 322 word = _parse_nextword_csv (word);349 word = parse_nextword_csv (word); 323 350 324 351 if (word[0] == '"') word[0] = ' '; … … 341 368 word = line; 342 369 for (i = 0; i < NX - 1; i++) 343 word = _parse_nextword (word);370 word = parse_nextword (word); 344 371 345 372 *X = strtod (word, &ptr); … … 402 429 return (q); 403 430 } 431 432 // return a newly allocated string containing the first complete set of non-whitespace 433 char *getword (char *string) { 434 435 int i, j; 436 char *word; 437 438 if (!string) return (NULL); 439 440 // find the end of the whitespace (is there any non-whitespace?) 441 for (i = 0; OHANA_WHITESPACE (string[i]); i++); 442 if (!string[i]) return (NULL); 443 444 for (j = i; string[j] && !OHANA_WHITESPACE(string[j]); j++); 445 word = strncreate (&string[i], j - i); 446 return (word); 447 } 448 449 // returns a pointer to the next word, or NULL if there is not a next word 450 char *skipword (char *string) { 451 452 int i; 453 454 if (!string) return (NULL); 455 456 // find the end of the whitespace (is there any non-whitespace?) 457 for (i = 0; OHANA_WHITESPACE (string[i]); i++); 458 if (!string[i]) return (NULL); 459 460 // find the end of the non-whitespace (this word) 461 while (string[i] && !OHANA_WHITESPACE(string[i])) i++; 462 463 // find the end of the following whitespace 464 while (string[i] && OHANA_WHITESPACE(string[i])) i++; 465 if (!string[i]) return (NULL); 466 467 return (&string[i]); 468 } 469 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.astro/cplot.c
r34613 r37403 4 4 5 5 double ra_prev = 0; 6 int i, kapa, Npts, status, leftside ;6 int i, kapa, Npts, status, leftside, valid, size; 7 7 opihi_flt *x, *y, *r, *d, Rmin, Rmax, Rmid; 8 8 Vector Xvec, Yvec, *xvec, *yvec; … … 11 11 if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE; 12 12 13 if (argc != 3) { 13 valid = (argc == 3); 14 valid |= (argc > 4) && !strcmp (argv[3], "where"); 15 if (!valid) { 14 16 gprint (GP_ERR, "USAGE: cplot <ra> <dec> [style]\n"); 17 gprint (GP_ERR, " OR: cplot <ra> <dec> [style] where (condition)\n"); 15 18 return (FALSE); 16 19 } … … 32 35 } 33 36 37 // tvec is used for logical test (truth vector) 38 Vector *tvec = NULL; 39 if (argc > 4) { 40 char *out = dvomath (argc - 4, &argv[4], &size, 1); 41 if (out == NULL) { 42 print_error (); 43 return FALSE; 44 } 45 if ((tvec = SelectVector (out, OLDVECTOR, TRUE)) == NULL) { 46 gprint (GP_ERR, " invalid logic result\n"); 47 DeleteNamedVector (out); 48 free (out); 49 return (FALSE); 50 } 51 } 52 53 if (tvec && tvec[0].Nelements != yvec[0].Nelements) { 54 gprint (GP_ERR, "logic test vector not the same length as data vectors\n"); 55 DeleteVector (tvec); 56 return (FALSE); 57 } 58 34 59 SetVector (&Xvec, OPIHI_FLT, xvec[0].Nelements); 35 60 SetVector (&Yvec, OPIHI_FLT, xvec[0].Nelements); … … 42 67 Npts = 0; 43 68 for (i = 0; i < Xvec.Nelements; i++, r++, d++) { 69 if (tvec) { 70 int skip = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0); 71 if (skip) continue; 72 } 73 44 74 double ra = ohana_normalize_angle (*r); 45 75 while (ra < Rmin) ra += 360.0; … … 88 118 free (Yvec.elements.Ptr); 89 119 120 if (tvec) DeleteVector (tvec); 121 90 122 return (TRUE); 91 123 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.basic/Makefile
r35237 r37403 55 55 $(SRC)/substr.$(ARCH).o \ 56 56 $(SRC)/strhash.$(ARCH).o \ 57 $(SRC)/strmatch.$(ARCH).o \ 57 58 $(SRC)/strpop.$(ARCH).o \ 58 59 $(SRC)/strsub.$(ARCH).o \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.basic/init.c
r35237 r37403 40 40 int fprintf_opihi PROTO((int, char **)); 41 41 int strlen_func PROTO((int, char **)); 42 int strmatch PROTO((int, char **)); 42 43 int substr_func PROTO((int, char **)); 43 44 int strpop PROTO((int, char **)); … … 97 98 {1, "strpop", strpop, "pop a string"}, 98 99 {1, "strsub", strsub, "replace instances of a key in a string"}, 100 {1, "strmatch", strmatch, "string length"}, 99 101 {1, "wait", wait_func, "wait until return is typed"}, 100 102 {1, "which", which, "show command *"} -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.basic/list.c
r36680 r37403 2 2 # define D_NLINES 100 3 3 static char prompt[] = ">> "; 4 5 static int set_list_varname (char *line, char *base, int N, int excelStyle);6 4 7 5 int list (int argc, char **argv) { … … 311 309 return (TRUE); 312 310 } 313 314 static int set_list_varname (char *line, char *base, int N, int excelStyle) {315 316 int i;317 318 // A-Z correspond to 0 - 25319 320 if (excelStyle) {321 float f = log(26.0);322 float g = (N == 0) ? 0.0 : log(1.0*N);323 int Ndigit = (int) (g / f) + 1;324 if (Ndigit > 10) {325 sprintf (line, "%s:ZZZZZZZZZZ", base);326 return FALSE;327 }328 char name[12];329 memset (name, 0, 12);330 for (i = 0; i < Ndigit; i++) {331 float Npow = Ndigit - i - 1;332 float g = pow(26.0, Npow);333 int V = (int) (N / g);334 name[i] = (Npow == 0.0) ? 'A' + V : 'A' + V - 1;335 N -= V * g;336 }337 sprintf (line, "%s:%s", base, name);338 } else {339 sprintf (line, "%s:%d", base, N);340 }341 return TRUE;342 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/Makefile
r36680 r37403 98 98 $(SRC)/point.$(ARCH).o \ 99 99 $(SRC)/ps.$(ARCH).o \ 100 $(SRC)/print_vectors.$(ARCH).o \ 100 101 $(SRC)/queuedelete.$(ARCH).o \ 101 102 $(SRC)/queuedrop.$(ARCH).o \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/init.c
r36680 r37403 87 87 int point PROTO((int, char **)); 88 88 int ps PROTO((int, char **)); 89 int print_vectors PROTO((int, char **)); 89 90 int queuelist PROTO((int, char **)); 90 91 int queueload PROTO((int, char **)); … … 250 251 {1, "ppm", jpeg, "convert display graphic to PPM"}, 251 252 {1, "ps", ps, "convert display to PostScript"}, 253 {1, "print_vectors", print_vectors, "print a set of vectors"}, 252 254 {1, "queuedelete", queuedelete, "delete a queue"}, 253 255 {1, "queuedrop", queuedrop, "drop values from queue matching a key"}, -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/read_vectors.c
r36680 r37403 3 3 FILE *f = (FILE *) NULL; 4 4 char filename[2048]; 5 6 void read_vectors_cleanup (); 5 7 6 8 int datafile (int argc, char **argv) { … … 23 25 // vector types 24 26 enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME, COLTYPE_CHAR}; 25 static int FITS_TRANSPOSE; 27 28 static int Nvec = 0; 29 static Vector **vec = NULL; 30 static char **listname = NULL; 31 static int *col = NULL; 32 static int *coltype = NULL; 33 static char *buffer = NULL; 26 34 27 35 int read_vectors (int argc, char **argv) { … … 29 37 int TimeFormat; 30 38 time_t TimeReference; 31 int i, j, Nskip, Narg, Nvec, *col,IsCSV, VERBOSE;32 int Nbytes, Nstart, NELEM, Nelem, nread , *coltype;39 int i, j, Nskip, Narg, IsCSV, VERBOSE; 40 int Nbytes, Nstart, NELEM, Nelem, nread; 33 41 char *colstr, *c0, *c1, *extname; 34 Vector **vec; 35 36 char *buffer = NULL; 37 38 FITS_TRANSPOSE = FALSE; 39 if ((Narg = get_argument (argc, argv, "-transpose"))) { 40 remove_argument (Narg, &argc, argv); 41 FITS_TRANSPOSE = TRUE; 42 } 42 char varname[1024]; // used as a buffer for the names of string fields 43 43 44 44 /* auto-sense table type */ … … 88 88 89 89 Nvec = (argc - 1) / 2; 90 ALLOCATE (listname, char *, Nvec); 90 91 ALLOCATE (vec, Vector *, Nvec); 91 92 ALLOCATE (col, int, Nvec); 92 93 ALLOCATE (coltype, int, Nvec); 94 for (i = 0; i < Nvec; i++) { 95 listname[i] = NULL; 96 vec[i] = NULL; 97 } 93 98 94 99 for (i = 0; i < Nvec; i++) { … … 115 120 } 116 121 117 if ((vec[i] = SelectVector (argv[2*i + 1], ANYVECTOR, TRUE)) == NULL) { 118 gprint (GP_ERR, "USAGE: read name N name N ...\n"); 119 free (vec); 120 free (col); 121 return (FALSE); 122 if (coltype[i] == COLTYPE_CHAR) { 123 listname[i] = strcreate (argv[2*i + 1]); 124 } else { 125 if ((vec[i] = SelectVector (argv[2*i + 1], ANYVECTOR, TRUE)) == NULL) { 126 gprint (GP_ERR, "USAGE: read name N name N ...\n"); 127 read_vectors_cleanup(); 128 return (FALSE); 129 } 122 130 } 123 131 … … 144 152 bad_colname: 145 153 gprint (GP_ERR, "USAGE: read name N name N ...\n"); 146 free (vec); 147 free (col); 154 read_vectors_cleanup(); 148 155 return (FALSE); 149 156 } … … 153 160 NELEM = 1000; 154 161 for (i = 0; i < Nvec; i++) { 155 if ((coltype[i] == COLTYPE_INT) || (coltype[i] == COLTYPE_CHAR)) { 156 ResetVector (vec[i], OPIHI_INT, NELEM); 157 } else { 158 // note that COLTYPE_TIME is a type of float 159 ResetVector (vec[i], OPIHI_FLT, NELEM); 162 switch (coltype[i]) { 163 case COLTYPE_INT: 164 ResetVector (vec[i], OPIHI_INT, NELEM); 165 break; 166 case COLTYPE_FLT: 167 case COLTYPE_TIME: 168 // note that COLTYPE_TIME is a type of float 169 ResetVector (vec[i], OPIHI_FLT, NELEM); 170 break; 171 case COLTYPE_CHAR: 172 default: 173 break; 160 174 } 161 175 } … … 166 180 if (scan_line_maxlen (f, buffer, 0x10000) == EOF) { 167 181 gprint (GP_ERR, "problem reading file %s\n", filename); 168 free (vec); 169 free (col); 182 read_vectors_cleanup(); 170 183 return FALSE; 171 184 } … … 213 226 for (i = 0; i < Nvec; i++) { 214 227 int ivalue; 215 char cvalue;216 228 double dvalue; 217 229 time_t tvalue; … … 224 236 break; 225 237 case COLTYPE_CHAR: 226 readStatus = IsCSV ? charparse_csv (&cvalue, col[i], c0) : charparse (&cvalue, col[i], c0); 227 vec[i][0].elements.Int[Nelem] = readStatus ? cvalue : 0; 228 break; 238 { 239 // I need to get an isolated word in 'value' with the string value of this field 240 char *ptr = IsCSV ? ptrparse_csv (col[i], c0) : ptrparse (col[i], c0); 241 char *value = NULL; 242 if (IsCSV) { 243 char *end = parse_nextword_csv (ptr); 244 if (end) { 245 value = end ? strncreate (ptr, end - ptr) : strcreate (ptr); 246 } 247 } else { 248 value = thisword(ptr); 249 } 250 set_list_varname (varname, listname[i], Nelem, FALSE); 251 set_str_variable (varname, value); 252 free (value); 253 break; 254 } 229 255 case COLTYPE_FLT: 230 256 readStatus = IsCSV ? dparse_csv (&dvalue, col[i], c0) : dparse (&dvalue, col[i], c0); … … 256 282 NELEM += 1000; 257 283 for (i = 0; i < Nvec; i++) { 258 if (coltype[i] == COLTYPE_INT) { 259 REALLOCATE (vec[i][0].elements.Int, opihi_int, NELEM); 260 } else { 261 REALLOCATE (vec[i][0].elements.Flt, opihi_flt, NELEM); 284 switch (coltype[i]) { 285 case COLTYPE_INT: 286 ResetVector (vec[i], OPIHI_INT, NELEM); 287 break; 288 case COLTYPE_FLT: 289 case COLTYPE_TIME: 290 ResetVector (vec[i], OPIHI_FLT, NELEM); 291 break; 292 case COLTYPE_CHAR: 293 default: 294 break; 262 295 } 263 296 } … … 266 299 } 267 300 } 301 // set the final vector / list length 268 302 for (i = 0; i < Nvec; i++) { 269 if (coltype[i] == COLTYPE_INT) { 270 REALLOCATE (vec[i][0].elements.Int, opihi_int, MAX (Nelem,1)); 271 } else { 272 REALLOCATE (vec[i][0].elements.Flt, opihi_flt, MAX (Nelem,1)); 273 } 274 vec[i][0].Nelements = Nelem; 275 } 276 277 free (vec); 278 free (col); 279 if (buffer) free (buffer); 303 switch (coltype[i]) { 304 case COLTYPE_INT: 305 ResetVector (vec[i], OPIHI_INT, Nelem); 306 break; 307 case COLTYPE_FLT: 308 case COLTYPE_TIME: 309 ResetVector (vec[i], OPIHI_FLT, Nelem); 310 break; 311 case COLTYPE_CHAR: 312 sprintf (varname, "%s:n", listname[i]); 313 set_int_variable (varname, Nelem); 314 break; 315 default: 316 break; 317 } 318 } 319 read_vectors_cleanup(); 280 320 return (TRUE); 281 282 321 } 283 322 284 # define ESCAPE( MSG) {\285 gprint (GP_ERR, "%s\n", MSG); \323 # define ESCAPE(...) { \ 324 gprint (GP_ERR, __VA_ARGS__); \ 286 325 if (CCDKeyword != NULL) free (CCDKeyword); \ 287 326 gfits_free_table (&table); \ … … 292 331 293 332 off_t Nbytes; 294 int i, j, k,N, Nextend, Ny, Binary, vecType, padIfShort;333 int i, j, N, Nextend, Ny, Binary, vecType, padIfShort; 295 334 char type[16], ID[80], *CCDKeyword; 296 335 FTable table; 297 336 Header header; 298 337 Vector **vec; 338 int FITS_TRANSPOSE; 299 339 300 340 table.buffer = NULL; 301 341 header.buffer = NULL; 342 343 FITS_TRANSPOSE = FALSE; 344 if ((N = get_argument (argc, argv, "-transpose"))) { 345 remove_argument (N, &argc, argv); 346 FITS_TRANSPOSE = TRUE; 347 } 302 348 303 349 CCDKeyword = NULL; … … 328 374 // } 329 375 330 if (argc < 2) ESCAPE ("USAGE: read -fits extension [-extnum] [-keyword key] name name ... ");331 332 if (f == NULL) ESCAPE ("file not found ");376 if (argc < 2) ESCAPE ("USAGE: read -fits extension [-extnum] [-keyword key] name name ...\n"); 377 378 if (f == NULL) ESCAPE ("file not found\n"); 333 379 fseeko (f, 0LL, SEEK_SET); 334 380 table.header = &header; … … 338 384 // first extension is PHU, cannot be a table. 339 385 // Nextend counts from 0 for first extension 340 if (!gfits_load_header (f, &header)) ESCAPE ("error reading primary header for file ");386 if (!gfits_load_header (f, &header)) ESCAPE ("error reading primary header for file\n"); 341 387 Nbytes = gfits_data_size (&header); 342 388 fseeko (f, Nbytes, SEEK_CUR); … … 344 390 345 391 for (i = 0; i < Nextend; i++) { 346 if (!gfits_load_header (f, &header)) ESCAPE ("extension not found");392 if (!gfits_load_header (f, &header)) ESCAPE ("extension %d not found\n", i); 347 393 Nbytes = gfits_data_size (&header); 348 394 /* skip the prior data buffers */ … … 350 396 gfits_free_header (&header); 351 397 } 352 if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension ");353 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension ");398 if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension %d\n", Nextend); 399 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension %d\n", Nextend); 354 400 355 401 } else { … … 382 428 continue; 383 429 } 384 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension ");430 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension\n"); 385 431 break; 386 432 } … … 391 437 gfits_scan (&header, "XTENSION", "%s", 1, type); 392 438 if (strcmp (type, "BINTABLE") && strcmp (type, "TABLE")) { 393 ESCAPE ("specified extension is not a table\n");439 ESCAPE ("specified extension %s is not a table\n", type); 394 440 } 395 441 Binary = !strcmp (type, "BINTABLE"); … … 418 464 419 465 if (!FITS_TRANSPOSE) { 466 // read string column into a list rather than a vector 467 if (!strcmp (type, "char")) { 468 char *fieldName = argv[i]; 469 char *Ptr = data; 470 char varname[1024]; // used as a buffer for the names of string fields 471 for (j = 0; j < Ny; j++) { 472 set_list_varname (varname, fieldName, j, FALSE); 473 char *value = strncreate (&Ptr[j*Nval], Nval); 474 // replace instances of $ with _ 475 char *p = strchr (value, '$'); 476 while (p) { 477 *p = '_'; 478 p = strchr (p, '$'); 479 } 480 set_str_variable (varname, value); 481 free (value); 482 } 483 sprintf (varname, "%s:n", fieldName); 484 set_int_variable (varname, Ny); 485 continue; 486 } 487 420 488 // define the multifield vector names (Nval vectors x Ny elements) 421 489 ALLOCATE (vec, Vector *, Nval); … … 429 497 } 430 498 431 if (!strcmp (type, "char")) { 432 char *Ptr = data; 433 for (j = 0; j < Ny; j++) { 434 for (k = 0; k < Nval; k++, Ptr++) { 435 vec[k][0].elements.Int[j] = *Ptr; 436 } 437 } 438 } 439 if (!strcmp (type, "short")) { 440 short *Ptr = data; 441 for (j = 0; j < Ny; j++) { 442 for (k = 0; k < Nval; k++, Ptr++) { 443 vec[k][0].elements.Int[j] = *Ptr; 444 } 445 } 446 } 447 if (!strcmp (type, "int")) { 448 int *Ptr = data; 449 for (j = 0; j < Ny; j++) { 450 for (k = 0; k < Nval; k++, Ptr++) { 451 vec[k][0].elements.Int[j] = *Ptr; 452 } 453 } 454 } 455 if (!strcmp (type, "int64_t")) { 456 int64_t *Ptr = data; 457 for (j = 0; j < Ny; j++) { 458 for (k = 0; k < Nval; k++, Ptr++) { 459 vec[k][0].elements.Int[j] = *Ptr; 460 } 461 } 462 } 463 if (!strcmp (type, "float")) { 464 float *Ptr = data; 465 for (j = 0; j < Ny; j++) { 466 for (k = 0; k < Nval; k++, Ptr++) { 467 vec[k][0].elements.Flt[j] = *Ptr; 468 } 469 } 470 } 471 if (!strcmp (type, "double")) { 472 double *Ptr = data; 473 for (j = 0; j < Ny; j++) { 474 for (k = 0; k < Nval; k++, Ptr++) { 475 vec[k][0].elements.Flt[j] = *Ptr; 476 } 477 } 478 } 499 if (!VectorAssignData (vec, type, data, Ny, Nval)) ESCAPE ("bad column type %s", type); 500 479 501 } else { 480 502 // define the multifield vector names (Ny vectors x Nval elements) … … 489 511 } 490 512 491 if (!strcmp (type, "char")) { 492 char *Ptr = data; 493 for (j = 0; j < Ny; j++) { 494 for (k = 0; k < Nval; k++, Ptr++) { 495 vec[j][0].elements.Int[k] = *Ptr; 496 } 497 } 498 } 499 if (!strcmp (type, "short")) { 500 short *Ptr = data; 501 for (j = 0; j < Ny; j++) { 502 for (k = 0; k < Nval; k++, Ptr++) { 503 vec[j][0].elements.Int[k] = *Ptr; 504 } 505 } 506 } 507 if (!strcmp (type, "int")) { 508 int *Ptr = data; 509 for (j = 0; j < Ny; j++) { 510 for (k = 0; k < Nval; k++, Ptr++) { 511 vec[j][0].elements.Int[k] = *Ptr; 512 } 513 } 514 } 515 if (!strcmp (type, "int64_t")) { 516 int64_t *Ptr = data; 517 for (j = 0; j < Ny; j++) { 518 for (k = 0; k < Nval; k++, Ptr++) { 519 vec[j][0].elements.Int[k] = *Ptr; 520 } 521 } 522 } 523 if (!strcmp (type, "float")) { 524 float *Ptr = data; 525 for (j = 0; j < Ny; j++) { 526 for (k = 0; k < Nval; k++, Ptr++) { 527 vec[j][0].elements.Flt[k] = *Ptr; 528 } 529 } 530 } 531 if (!strcmp (type, "double")) { 532 double *Ptr = data; 533 for (j = 0; j < Ny; j++) { 534 for (k = 0; k < Nval; k++, Ptr++) { 535 vec[j][0].elements.Flt[k] = *Ptr; 536 } 537 } 538 } 513 if (!VectorAssignDataTranspose (vec, type, data, Ny, Nval)) ESCAPE ("bad column type %s", type); 539 514 } 540 515 free (data); … … 546 521 return (TRUE); 547 522 } 523 524 void read_vectors_cleanup () { 525 526 int i; 527 528 if (col) free (col); 529 if (coltype) free (coltype); 530 if (buffer) free (buffer); 531 if (listname) { 532 for (i = 0; i < Nvec; i++) { 533 if (listname[i]) free (listname[i]); 534 } 535 free (listname); 536 } 537 if (vec) free (vec); 538 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/Makefile
r36680 r37403 25 25 $(SRC)/dvo_host_utils.$(ARCH).o \ 26 26 $(SRC)/region_list.$(ARCH).o \ 27 $(SRC)/find_matches.$(ARCH).o \ 28 $(SRC)/photometry.$(ARCH).o 27 $(SRC)/photcode_ops.$(ARCH).o \ 28 $(SRC)/find_matches.$(ARCH).o 29 30 # $(SRC)/photometry.$(ARCH).o 31 32 broken = \ 33 $(SRC)/calextract.$(ARCH).o \ 34 $(SRC)/calmextract.$(ARCH).o \ 35 $(SRC)/ccd.$(ARCH).o \ 36 $(SRC)/cmd.$(ARCH).o \ 37 $(SRC)/dmagaves.$(ARCH).o \ 38 $(SRC)/dmagmeas.$(ARCH).o \ 39 $(SRC)/dmags.$(ARCH).o \ 40 $(SRC)/ddmags.$(ARCH).o \ 41 $(SRC)/fitcolors.$(ARCH).o 29 42 30 43 cmds = \ … … 32 45 $(SRC)/avmatch.$(ARCH).o \ 33 46 $(SRC)/badimages.$(ARCH).o \ 34 $(SRC)/calextract.$(ARCH).o \35 $(SRC)/calmextract.$(ARCH).o \36 47 $(SRC)/catdir.$(ARCH).o \ 37 $(SRC)/ccd.$(ARCH).o \38 48 $(SRC)/cmatch.$(ARCH).o \ 39 $(SRC)/cmd.$(ARCH).o \40 49 $(SRC)/cmpload.$(ARCH).o \ 41 50 $(SRC)/cmpread.$(ARCH).o \ 42 51 $(SRC)/coordimage.$(ARCH).o \ 43 $(SRC)/ ddmags.$(ARCH).o \52 $(SRC)/coordmosaic.$(ARCH).o \ 44 53 $(SRC)/detrend.$(ARCH).o \ 45 $(SRC)/dmagaves.$(ARCH).o \46 $(SRC)/dmagmeas.$(ARCH).o \47 $(SRC)/dmags.$(ARCH).o \48 54 $(SRC)/dmt.$(ARCH).o \ 49 55 $(SRC)/elixir.$(ARCH).o \ 50 $(SRC)/fitcolors.$(ARCH).o \51 56 $(SRC)/fitsed.$(ARCH).o \ 52 57 $(SRC)/gcat.$(ARCH).o \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/avextract.c
r35416 r37403 166 166 needMeasures = FALSE; 167 167 for (i = 0; !needMeasures && (i < Nfields); i++) { 168 if (fields[i].magMode == MAG_NONE) continue; 169 if (fields[i].photcode == NULL) continue; // assert this? 168 if (fields[i].photcode == NULL) continue; // non-measure fields do not have a photcode 170 169 if (fields[i].photcode[0].type == PHOT_REF) needMeasures = TRUE; 171 170 if (fields[i].photcode[0].type == PHOT_DEP) needMeasures = TRUE; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/avmatch.c
r36680 r37403 152 152 int needMeasures = FALSE; 153 153 for (i = 0; !needMeasures && (i < Nfields); i++) { 154 if (fields[i].magMode == MAG_NONE) continue;155 154 if (fields[i].photcode == NULL) continue; // assert this? 156 155 if (fields[i].photcode[0].type == PHOT_REF) needMeasures = TRUE; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/fitsed.c
r34088 r37403 83 83 /* interpret command-line options */ 84 84 if ((selection = SetRegionSelection (&argc, argv)) == NULL) goto escape; 85 if (!SetPhotSelections (&argc, argv, 4)) goto usage;85 // if (!SetPhotSelections (&argc, argv, 4)) goto usage; 86 86 87 87 PLOT = FALSE; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/gstar.c
r35109 r37403 15 15 GSTAR_UCDIST, 16 16 GSTAR_AVE_AP_MAG, 17 GSTAR_AVE_MAG_ 20,18 GSTAR_AVE_MAG_ 80,17 GSTAR_AVE_MAG_MIN, 18 GSTAR_AVE_MAG_MAX, 19 19 GSTAR_AVE_KRON_MAG, 20 20 GSTAR_AVE_KRON_MAG_ERR, … … 23 23 GSTAR_STACK_FLUX_KRON, 24 24 GSTAR_STACK_FLUX_KRON_ERR, 25 GSTAR_STACK_FLUX_APER, 26 GSTAR_STACK_FLUX_APER_ERR, 27 GSTAR_WARP_FLUX_PSF, 28 GSTAR_WARP_FLUX_PSF_ERR, 29 GSTAR_WARP_FLUX_KRON, 30 GSTAR_WARP_FLUX_KRON_ERR, 31 GSTAR_WARP_FLUX_APER, 32 GSTAR_WARP_FLUX_APER_ERR, 33 GSTAR_STACK_MAG_PSF, 34 GSTAR_STACK_MAG_PSF_ERR, 35 GSTAR_STACK_MAG_KRON, 36 GSTAR_STACK_MAG_KRON_ERR, 37 GSTAR_STACK_MAG_APER, 38 GSTAR_STACK_MAG_APER_ERR, 39 GSTAR_WARP_MAG_PSF, 40 GSTAR_WARP_MAG_PSF_ERR, 41 GSTAR_WARP_MAG_KRON, 42 GSTAR_WARP_MAG_KRON_ERR, 43 GSTAR_WARP_MAG_APER, 44 GSTAR_WARP_MAG_APER_ERR, 25 45 } GSTAR_SECF_CODES; 26 46 … … 31 51 void sort_index_float (float *X, int *IDX, int N) { 32 52 33 # define SWAPFUNC(A,B){ float tmp; int itmp; \34 tmp = X[A]; X[A] = X[B]; X[B] = tmp;\35 itmp = IDX[A]; IDX[A] = IDX[B]; IDX[B] = itmp;\36 }53 # define SWAPFUNC(A,B){ float tmp; int itmp; \ 54 tmp = X[A]; X[A] = X[B]; X[B] = tmp; \ 55 itmp = IDX[A]; IDX[A] = IDX[B]; IDX[B] = itmp; \ 56 } 37 57 # define COMPARE(A,B)(X[A] < X[B]) 38 58 … … 52 72 off_t i, Nstars, *N1; 53 73 off_t j, k, m, N, Nlo, Nhi; 54 int Nsecfilt, NPTS, QUIET, FULL_OUTPUT, STACK_OUTPUT,INST, SHOW_MASKS;74 int Nsecfilt, NPTS, QUIET, INST, SHOW_MASKS; 55 75 int found, GetMeasures; 56 76 int SaveVectors; … … 109 129 } 110 130 111 FULL_OUTPUT = FALSE;131 int FULL_OUTPUT = FALSE; 112 132 if ((N = get_argument (argc, argv, "-full"))) { 113 133 FULL_OUTPUT = TRUE; … … 115 135 } 116 136 117 STACK_OUTPUT = FALSE;118 if ((N = get_argument (argc, argv, " -stack"))) {137 int STACK_OUTPUT = FALSE; 138 if ((N = get_argument (argc, argv, "+stack"))) { 119 139 STACK_OUTPUT = TRUE; 140 remove_argument (N, &argc, argv); 141 } 142 143 int EXTRA_OUTPUT = FALSE; 144 if ((N = get_argument (argc, argv, "+extras"))) { 145 EXTRA_OUTPUT = TRUE; 146 remove_argument (N, &argc, argv); 147 } 148 149 int WARP_OUTPUT = FALSE; 150 if ((N = get_argument (argc, argv, "+warp"))) { 151 WARP_OUTPUT = TRUE; 152 remove_argument (N, &argc, argv); 153 } 154 155 int FLUX_OUTPUT = FALSE; 156 if ((N = get_argument (argc, argv, "+flux"))) { 157 FLUX_OUTPUT = TRUE; 158 remove_argument (N, &argc, argv); 159 } 160 161 int MAG_OUTPUT = TRUE; 162 if ((N = get_argument (argc, argv, "-mag"))) { 163 MAG_OUTPUT = FALSE; 164 remove_argument (N, &argc, argv); 165 } 166 167 int KRON_OUTPUT = FALSE; 168 if ((N = get_argument (argc, argv, "+kron"))) { 169 KRON_OUTPUT = TRUE; 170 remove_argument (N, &argc, argv); 171 } 172 173 int APER_OUTPUT = FALSE; 174 if ((N = get_argument (argc, argv, "+aper"))) { 175 APER_OUTPUT = TRUE; 120 176 remove_argument (N, &argc, argv); 121 177 } … … 185 241 // an error exit status here is a significant error 186 242 if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) { 187 fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);188 exit (2);243 fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename); 244 exit (2); 189 245 } 190 246 dvo_catalog_unlock (&catalog); … … 248 304 k = N1[i]; 249 305 if (!QUIET) { 250 gprint (GP_LOG, "star: "OFF_T_FMT"\n", i);306 gprint (GP_LOG, "star: "OFF_T_FMT"\n", k); 251 307 gprint (GP_LOG, "%11.7f ", catalog.average[k].R); 252 308 gprint (GP_LOG, "%11.7f ", catalog.average[k].D); … … 259 315 260 316 if (FULL_OUTPUT) { 261 gprint (GP_LOG, "%f ", catalog.average[k].dR);262 gprint (GP_LOG, "%f ", catalog.average[k].dD);263 gprint (GP_LOG, "%f ", catalog.average[k].uR);264 gprint (GP_LOG, "%f ", catalog.average[k].uD);265 gprint (GP_LOG, "%f ", catalog.average[k].duR);266 gprint (GP_LOG, "%f ", catalog.average[k].duD);267 gprint (GP_LOG, "%f ", catalog.average[k].P);268 gprint (GP_LOG, "%f ", catalog.average[k].dP);269 270 gprint (GP_LOG, "%f ", catalog.average[k].ChiSqPM);271 gprint (GP_LOG, "%f ", catalog.average[k].ChiSqPar);272 273 date = ohana_sec_to_date (catalog.average[k].Tmean);274 gprint (GP_LOG, "%20s ", date);275 gprint (GP_LOG, "%f ", catalog.average[k].Trange / 86400.0);317 gprint (GP_LOG, "%f ", catalog.average[k].dR); 318 gprint (GP_LOG, "%f ", catalog.average[k].dD); 319 gprint (GP_LOG, "%f ", catalog.average[k].uR); 320 gprint (GP_LOG, "%f ", catalog.average[k].uD); 321 gprint (GP_LOG, "%f ", catalog.average[k].duR); 322 gprint (GP_LOG, "%f ", catalog.average[k].duD); 323 gprint (GP_LOG, "%f ", catalog.average[k].P); 324 gprint (GP_LOG, "%f ", catalog.average[k].dP); 325 326 gprint (GP_LOG, "%f ", catalog.average[k].ChiSqPM); 327 gprint (GP_LOG, "%f ", catalog.average[k].ChiSqPar); 328 329 date = ohana_sec_to_date (catalog.average[k].Tmean); 330 gprint (GP_LOG, "%20s ", date); 331 gprint (GP_LOG, "%f ", catalog.average[k].Trange / 86400.0); 276 332 } 277 333 278 gprint (GP_LOG, "\n ");334 gprint (GP_LOG, "\n\n"); 279 335 280 336 /* filter names */ 337 gprint (GP_LOG, "filter : "); 281 338 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_FILTER_NAMES); 282 339 gprint (GP_LOG, "\n"); 283 340 284 341 /* average mags */ 342 gprint (GP_LOG, "chp_psf_ave: "); 285 343 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG); 286 344 gprint (GP_LOG, "\n"); 287 345 288 346 /* average mag errors */ 347 gprint (GP_LOG, "chp_psf_err: "); 289 348 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_ERR); 290 349 gprint (GP_LOG, "\n"); 291 350 292 351 /* average mag chisq */ 352 gprint (GP_LOG, "chp_psf_chi: "); 293 353 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_CHISQ); 294 354 gprint (GP_LOG, "\n"); 295 355 296 if (FULL_OUTPUT) { 356 357 if (APER_OUTPUT) { 297 358 /* Map */ 359 gprint (GP_LOG, "chp_ap__ave: "); 298 360 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_AP_MAG); 299 361 gprint (GP_LOG, "\n"); 300 362 } 363 364 if (KRON_OUTPUT) { 301 365 /* Mkron */ 366 gprint (GP_LOG, "chp_krn_ave: "); 302 367 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_KRON_MAG); 303 368 gprint (GP_LOG, "\n"); 304 369 305 370 /* dMkron */ 371 gprint (GP_LOG, "chp_krn_err: "); 306 372 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_KRON_MAG_ERR); 307 373 gprint (GP_LOG, "\n"); 308 309 /* M_20 */ 310 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_20); 311 gprint (GP_LOG, "\n"); 312 313 /* M_80 */ 314 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_80);; 374 } 375 376 if (EXTRA_OUTPUT) { 377 /* Mmin */ 378 gprint (GP_LOG, "chp_psf_min: "); 379 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_MIN); 380 gprint (GP_LOG, "\n"); 381 382 /* Mmax */ 383 gprint (GP_LOG, "chp_psf_max: "); 384 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_MAX);; 315 385 gprint (GP_LOG, "\n"); 316 386 317 387 /* UCDIST */ 388 gprint (GP_LOG, "ubercal_dst: "); 318 389 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_UCDIST);; 319 390 gprint (GP_LOG, "\n"); 320 391 321 392 /* secfilt flags */ 393 gprint (GP_LOG, "filtflags: "); 322 394 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_SECF_FLAGS); 323 395 gprint (GP_LOG, "\n"); 324 325 396 } 326 if (STACK_OUTPUT ) {397 if (STACK_OUTPUT && MAG_OUTPUT) { 327 398 /* FluxPSF */ 399 gprint (GP_LOG, "stk_psf_ave: "); 400 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_MAG_PSF); 401 gprint (GP_LOG, "\n"); 402 403 /* dFluxPSF */ 404 gprint (GP_LOG, "stk_psf_err: "); 405 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_MAG_PSF_ERR); 406 gprint (GP_LOG, "\n"); 407 408 if (KRON_OUTPUT) { 409 /* MagKron */ 410 gprint (GP_LOG, "stk_krn_ave: "); 411 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_MAG_KRON); 412 gprint (GP_LOG, "\n"); 413 414 /* dMagKron */ 415 gprint (GP_LOG, "stk_krn_err: "); 416 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_MAG_KRON_ERR); 417 gprint (GP_LOG, "\n"); 418 } 419 420 if (APER_OUTPUT) { 421 /* MagAper */ 422 gprint (GP_LOG, "stk_ap__ave: "); 423 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_MAG_APER); 424 gprint (GP_LOG, "\n"); 425 426 /* dMagAper */ 427 gprint (GP_LOG, "stk_ap__err: "); 428 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_MAG_APER_ERR); 429 gprint (GP_LOG, "\n"); 430 } 431 } 432 if (WARP_OUTPUT && MAG_OUTPUT) { 433 /* FluxPSF */ 434 gprint (GP_LOG, "wrp_psf_ave: "); 435 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_MAG_PSF); 436 gprint (GP_LOG, "\n"); 437 438 /* dFluxPSF */ 439 gprint (GP_LOG, "wrp_psf_err: "); 440 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_MAG_PSF_ERR); 441 gprint (GP_LOG, "\n"); 442 443 if (KRON_OUTPUT) { 444 /* MagKron */ 445 gprint (GP_LOG, "wrp_krn_ave: "); 446 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_MAG_KRON); 447 gprint (GP_LOG, "\n"); 448 449 /* dMagKron */ 450 gprint (GP_LOG, "wrp_krn_err: "); 451 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_MAG_KRON_ERR); 452 gprint (GP_LOG, "\n"); 453 454 } 455 456 if (APER_OUTPUT) { 457 /* MagAper */ 458 gprint (GP_LOG, "wrp_ap__ave: "); 459 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_MAG_APER); 460 gprint (GP_LOG, "\n"); 461 462 /* dMagAper */ 463 gprint (GP_LOG, "wrp_ap__err: "); 464 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_MAG_APER_ERR); 465 gprint (GP_LOG, "\n"); 466 } 467 } 468 if (STACK_OUTPUT && FLUX_OUTPUT) { 469 /* FluxPSF */ 470 gprint (GP_LOG, "stk_psf_ave: "); 328 471 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_PSF); 329 472 gprint (GP_LOG, "\n"); 330 473 331 474 /* dFluxPSF */ 475 gprint (GP_LOG, "stk_psf_err: "); 332 476 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_PSF_ERR); 333 477 gprint (GP_LOG, "\n"); 334 335 /* FluxKron */ 336 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_KRON); 337 gprint (GP_LOG, "\n"); 338 339 /* dFluxKron */ 340 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_KRON_ERR); 341 gprint (GP_LOG, "\n"); 342 478 479 if (KRON_OUTPUT) { 480 /* FluxKron */ 481 gprint (GP_LOG, "stk_krn_ave: "); 482 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_KRON); 483 gprint (GP_LOG, "\n"); 484 485 /* dFluxKron */ 486 gprint (GP_LOG, "stk_krn_err: "); 487 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_KRON_ERR); 488 gprint (GP_LOG, "\n"); 489 } 490 491 if (APER_OUTPUT) { 492 /* FluxAper */ 493 gprint (GP_LOG, "stk_ap_ave: "); 494 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_APER); 495 gprint (GP_LOG, "\n"); 496 497 /* dFluxAper */ 498 gprint (GP_LOG, "stk_ap_err: "); 499 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_STACK_FLUX_APER_ERR); 500 gprint (GP_LOG, "\n"); 501 } 343 502 } 344 } 503 if (WARP_OUTPUT && FLUX_OUTPUT) { 504 /* FluxPSF */ 505 gprint (GP_LOG, "wrp_psf_ave: "); 506 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_FLUX_PSF); 507 gprint (GP_LOG, "\n"); 508 509 /* dFluxPSF */ 510 gprint (GP_LOG, "wrp_psf_ave: "); 511 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_FLUX_PSF_ERR); 512 gprint (GP_LOG, "\n"); 513 514 if (KRON_OUTPUT) { 515 /* FluxKron */ 516 gprint (GP_LOG, "wrp_krn_ave: "); 517 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_FLUX_KRON); 518 gprint (GP_LOG, "\n"); 519 520 /* dFluxKron */ 521 gprint (GP_LOG, "wrp_krn_err: "); 522 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_FLUX_KRON_ERR); 523 gprint (GP_LOG, "\n"); 524 } 525 526 if (APER_OUTPUT) { 527 /* FluxAper */ 528 gprint (GP_LOG, "wrp_ap__ave: "); 529 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_FLUX_APER); 530 gprint (GP_LOG, "\n"); 531 532 /* dFluxAper */ 533 gprint (GP_LOG, "wrp_ap__err: "); 534 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_WARP_FLUX_APER_ERR); 535 gprint (GP_LOG, "\n"); 536 } 537 } 538 } 539 gprint (GP_LOG, "\n"); 540 345 541 if (GetMeasures || SaveVectors) { 346 542 … … 374 570 int Nv = index[j]; 375 571 376 Mcat = PhotCat (&catalog.measure[Nv] );572 Mcat = PhotCat (&catalog.measure[Nv], MAG_CLASS_PSF); 377 573 if (INST) { 378 Mrel = PhotInst (&catalog.measure[Nv] );574 Mrel = PhotInst (&catalog.measure[Nv], MAG_CLASS_PSF); 379 575 } else { 380 Mrel = PhotRel (&catalog.measure[Nv], &catalog.average[k], &catalog.secfilt[k*Nsecfilt]); 381 } 576 Mrel = PhotRel (&catalog.measure[Nv], &catalog.average[k], &catalog.secfilt[k*Nsecfilt], MAG_CLASS_PSF); 577 } 578 579 float dRoff = dvoOffsetR(&catalog.measure[Nv], &catalog.average[k]); 580 float dDoff = dvoOffsetD(&catalog.measure[Nv], &catalog.average[k]); 382 581 383 582 if (GetMeasures && !QUIET) { … … 387 586 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].dM); 388 587 gprint (GP_LOG, "%20s ", date); 389 gprint (GP_LOG, "%7.4f ", catalog.measure[Nv].dR); 390 gprint (GP_LOG, "%7.4f ", catalog.measure[Nv].dD); 588 589 gprint (GP_LOG, "%7.4f ", dRoff); 590 gprint (GP_LOG, "%7.4f ", dDoff); 391 591 gprint (GP_LOG, "0x%08x ", catalog.measure[Nv].photFlags); 392 592 gprint (GP_LOG, "0x%08x ", catalog.measure[Nv].dbFlags); … … 409 609 410 610 if (FULL_OUTPUT) { 411 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Mcal);412 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Map);413 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Mkron);414 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].dMkron);415 gprint (GP_LOG, "%5.1f ", pow(10.0, 0.4*catalog.measure[Nv].dt));416 gprint (GP_LOG, "%5.3f ", catalog.measure[Nv].airmass);417 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].az);418 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].Xccd);419 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].Yccd);420 gprint (GP_LOG, "%3.1f ", FromShortPixels(catalog.measure[Nv].dXccd));421 gprint (GP_LOG, "%3.1f ", FromShortPixels(catalog.measure[Nv].dYccd));422 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].Sky);423 gprint (GP_LOG, "%5.1f ", catalog.measure[Nv].dSky);424 gprint (GP_LOG, "%8d ", catalog.measure[Nv].averef);425 gprint (GP_LOG, "0x%08x ", catalog.measure[Nv].detID);426 gprint (GP_LOG, "0x%08x ", catalog.measure[Nv].imageID);427 gprint (GP_LOG, "%.3f ", catalog.measure[Nv].psfQF);428 gprint (GP_LOG, "%.1f ", catalog.measure[Nv].psfChisq);429 gprint (GP_LOG, "%.1f ", catalog.measure[Nv].crNsigma);430 gprint (GP_LOG, "%.1f ", catalog.measure[Nv].extNsigma);431 gprint (GP_LOG, "%.1f ", FromShortDegrees(catalog.measure[Nv].theta));611 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Mcal); 612 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Map); 613 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].Mkron); 614 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].dMkron); 615 gprint (GP_LOG, "%5.1f ", pow(10.0, 0.4*catalog.measure[Nv].dt)); 616 gprint (GP_LOG, "%5.3f ", catalog.measure[Nv].airmass); 617 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].az); 618 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].Xccd); 619 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].Yccd); 620 gprint (GP_LOG, "%3.1f ", FromShortPixels(catalog.measure[Nv].dXccd)); 621 gprint (GP_LOG, "%3.1f ", FromShortPixels(catalog.measure[Nv].dYccd)); 622 gprint (GP_LOG, "%6.1f ", catalog.measure[Nv].Sky); 623 gprint (GP_LOG, "%5.1f ", catalog.measure[Nv].dSky); 624 gprint (GP_LOG, "%8d ", catalog.measure[Nv].averef); 625 gprint (GP_LOG, "0x%08x ", catalog.measure[Nv].detID); 626 gprint (GP_LOG, "0x%08x ", catalog.measure[Nv].imageID); 627 gprint (GP_LOG, "%5.3f ", catalog.measure[Nv].psfQF); 628 gprint (GP_LOG, "%7.1f ", catalog.measure[Nv].psfChisq); 629 // gprint (GP_LOG, "%3.1f ", catalog.measure[Nv].crNsigma); 630 gprint (GP_LOG, "%4.1f ", catalog.measure[Nv].extNsigma); 631 gprint (GP_LOG, "%5.1f ", FromShortDegrees(catalog.measure[Nv].theta)); 432 632 } 433 if ( STACK_OUTPUT) {434 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].FluxPSF);435 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].dFluxPSF);436 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].FluxKron);437 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].dFluxKron);633 if (FLUX_OUTPUT) { 634 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].FluxPSF); 635 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].dFluxPSF); 636 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].FluxKron); 637 gprint (GP_LOG, "%10.3e ", catalog.measure[Nv].dFluxKron); 438 638 } 439 639 gprint (GP_LOG, "\n"); … … 447 647 vec3[0].elements.Flt[N] = catalog.measure[Nv].airmass; 448 648 vec4[0].elements.Flt[N] = catalog.measure[Nv].photcode; 449 vec5[0].elements.Flt[N] = catalog.measure[Nv].dR;450 vec6[0].elements.Flt[N] = catalog.measure[Nv].dD;649 vec5[0].elements.Flt[N] = dRoff; 650 vec6[0].elements.Flt[N] = dDoff; 451 651 N ++; 452 652 if (N == NPTS - 1) { … … 543 743 544 744 switch (type) { 545 case GSTAR_AVE_MAG : /* averagemags */546 if (seq == -1) { 547 print_double (NAN); 548 } else { 549 print_double (secfilt[seq].M );550 } 551 break; 552 553 case GSTAR_AVE_MAG_ ERR: /* average mags errors */554 if (seq == -1) { 555 print_double (NAN); 556 } else { 557 print_double (secfilt[seq]. dM);745 case GSTAR_AVE_MAG_MIN: /* average ap mags */ 746 if (seq == -1) { 747 print_double (NAN); 748 } else { 749 print_double (secfilt[seq].Mmin); 750 } 751 break; 752 753 case GSTAR_AVE_MAG_MAX: /* average ap mags */ 754 if (seq == -1) { 755 print_double (NAN); 756 } else { 757 print_double (secfilt[seq].Mmax); 558 758 } 559 759 break; … … 561 761 case GSTAR_AVE_MAG_CHISQ: /* average mag chisq */ 562 762 if (seq == -1) { 563 print_ short (NAN_S_SHORT, NAN_S_SHORT);564 } else { 565 print_ short (pow (10.0, 0.01*secfilt[seq].Xm), secfilt[seq].Xm);763 print_double (NAN); 764 } else { 765 print_double (secfilt[seq].Mchisq); 566 766 } 567 767 break; … … 588 788 break; 589 789 790 /*** CHIP : MAG ***/ 791 792 case GSTAR_AVE_MAG: /* average mags */ 793 if (seq == -1) { 794 print_double (NAN); 795 } else { 796 print_double (secfilt[seq].M); 797 } 798 break; 799 800 case GSTAR_AVE_MAG_ERR: /* average mags errors */ 801 if (seq == -1) { 802 print_double (NAN); 803 } else { 804 print_double (secfilt[seq].dM); 805 } 806 break; 807 590 808 case GSTAR_AVE_AP_MAG: /* average ap mags */ 591 809 if (seq == -1) { … … 596 814 break; 597 815 598 case GSTAR_AVE_MAG_20: /* average ap mags */599 if (seq == -1) {600 print_double (NAN);601 } else {602 print_short (0.001*secfilt[seq].M_20, secfilt[seq].M_20);603 }604 break;605 606 case GSTAR_AVE_MAG_80: /* average ap mags */607 if (seq == -1) {608 print_double (NAN);609 } else {610 print_short (0.001*secfilt[seq].M_80, secfilt[seq].M_80);611 }612 break;613 614 816 case GSTAR_AVE_KRON_MAG: /* average ap mags */ 615 817 if (seq == -1) { … … 628 830 break; 629 831 832 /******************* STACK : FLUX **********************/ 833 630 834 case GSTAR_STACK_FLUX_PSF: /* average ap mags */ 631 835 if (seq == -1) { 632 836 print_double (NAN); 633 837 } else { 634 print_double_exp (secfilt[seq].F luxPSF);838 print_double_exp (secfilt[seq].FpsfStk); 635 839 } 636 840 break; … … 640 844 print_double (NAN); 641 845 } else { 642 print_double_exp (secfilt[seq].dF luxPSF);846 print_double_exp (secfilt[seq].dFpsfStk); 643 847 } 644 848 break; … … 648 852 print_double (NAN); 649 853 } else { 650 print_double_exp (secfilt[seq].F luxKron);854 print_double_exp (secfilt[seq].FkronStk); 651 855 } 652 856 break; … … 656 860 print_double (NAN); 657 861 } else { 658 print_double_exp (secfilt[seq].dFluxKron); 862 print_double_exp (secfilt[seq].dFkronStk); 863 } 864 break; 865 866 case GSTAR_STACK_FLUX_APER: /* average ap mags */ 867 if (seq == -1) { 868 print_double (NAN); 869 } else { 870 print_double_exp (secfilt[seq].FapStk); 871 } 872 break; 873 874 case GSTAR_STACK_FLUX_APER_ERR: /* average ap mags */ 875 if (seq == -1) { 876 print_double (NAN); 877 } else { 878 print_double_exp (secfilt[seq].dFapStk); 879 } 880 break; 881 882 /******************* STACK : MAG **********************/ 883 884 case GSTAR_STACK_MAG_PSF: /* average ap mags */ 885 if (seq == -1) { 886 print_double (NAN); 887 } else { 888 print_double (secfilt[seq].MpsfStk); 889 } 890 break; 891 892 case GSTAR_STACK_MAG_PSF_ERR: /* average ap mags */ 893 if (seq == -1) { 894 print_double (NAN); 895 } else { 896 print_double (secfilt[seq].dFpsfStk / secfilt[seq].FpsfStk); 897 } 898 break; 899 900 case GSTAR_STACK_MAG_KRON: /* average ap mags */ 901 if (seq == -1) { 902 print_double (NAN); 903 } else { 904 print_double (secfilt[seq].MkronStk); 905 } 906 break; 907 908 case GSTAR_STACK_MAG_KRON_ERR: /* average ap mags */ 909 if (seq == -1) { 910 print_double (NAN); 911 } else { 912 print_double (secfilt[seq].dFkronStk / secfilt[seq].FkronStk); 913 } 914 break; 915 916 case GSTAR_STACK_MAG_APER: /* average ap mags */ 917 if (seq == -1) { 918 print_double (NAN); 919 } else { 920 print_double (secfilt[seq].MapStk); 921 } 922 break; 923 924 case GSTAR_STACK_MAG_APER_ERR: /* average ap mags */ 925 if (seq == -1) { 926 print_double (NAN); 927 } else { 928 print_double (secfilt[seq].dFapStk / secfilt[seq].FapStk); 929 } 930 break; 931 932 /******************* WARP : FLUX **********************/ 933 934 case GSTAR_WARP_FLUX_PSF: /* average ap mags */ 935 if (seq == -1) { 936 print_double (NAN); 937 } else { 938 print_double_exp (secfilt[seq].FpsfWrp); 939 } 940 break; 941 942 case GSTAR_WARP_FLUX_PSF_ERR: /* average ap mags */ 943 if (seq == -1) { 944 print_double (NAN); 945 } else { 946 print_double_exp (secfilt[seq].dFpsfWrp); 947 } 948 break; 949 950 case GSTAR_WARP_FLUX_KRON: /* average ap mags */ 951 if (seq == -1) { 952 print_double (NAN); 953 } else { 954 print_double_exp (secfilt[seq].FkronWrp); 955 } 956 break; 957 958 case GSTAR_WARP_FLUX_KRON_ERR: /* average ap mags */ 959 if (seq == -1) { 960 print_double (NAN); 961 } else { 962 print_double_exp (secfilt[seq].dFkronWrp); 963 } 964 break; 965 966 case GSTAR_WARP_FLUX_APER: /* average ap mags */ 967 if (seq == -1) { 968 print_double (NAN); 969 } else { 970 print_double_exp (secfilt[seq].FapWrp); 971 } 972 break; 973 974 case GSTAR_WARP_FLUX_APER_ERR: /* average ap mags */ 975 if (seq == -1) { 976 print_double (NAN); 977 } else { 978 print_double_exp (secfilt[seq].dFapWrp); 979 } 980 break; 981 982 /******************* WARP : MAG **********************/ 983 984 case GSTAR_WARP_MAG_PSF: /* average ap mags */ 985 if (seq == -1) { 986 print_double (NAN); 987 } else { 988 print_double (secfilt[seq].MpsfWrp); 989 } 990 break; 991 992 case GSTAR_WARP_MAG_PSF_ERR: /* average ap mags */ 993 if (seq == -1) { 994 print_double (NAN); 995 } else { 996 print_double (secfilt[seq].dFpsfWrp / secfilt[seq].FpsfWrp); 997 } 998 break; 999 1000 case GSTAR_WARP_MAG_KRON: /* average ap mags */ 1001 if (seq == -1) { 1002 print_double (NAN); 1003 } else { 1004 print_double (secfilt[seq].MkronWrp); 1005 } 1006 break; 1007 1008 case GSTAR_WARP_MAG_KRON_ERR: /* average ap mags */ 1009 if (seq == -1) { 1010 print_double (NAN); 1011 } else { 1012 print_double (secfilt[seq].dFkronWrp / secfilt[seq].FkronWrp); 1013 } 1014 break; 1015 1016 case GSTAR_WARP_MAG_APER: /* average ap mags */ 1017 if (seq == -1) { 1018 print_double (NAN); 1019 } else { 1020 print_double (secfilt[seq].MapWrp); 1021 } 1022 break; 1023 1024 case GSTAR_WARP_MAG_APER_ERR: /* average ap mags */ 1025 if (seq == -1) { 1026 print_double (NAN); 1027 } else { 1028 print_double (secfilt[seq].dFapWrp / secfilt[seq].FapWrp); 659 1029 } 660 1030 break; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/hosts.c
r36680 r37403 3 3 # define DVO_MAX_PATH 1024 4 4 5 enum {TEMP_NONE, TEMP_DVO_RESULTS, TEMP_DVO_LOG, TEMP_RELASTRO_CATALOG, TEMP_RELPHOT_CATALOG, TEMP_RELPHOT_LOG, TEMP_DVOPSPS_DET, TEMP_FIXSTKIDS_RESULTS}; 5 enum {TEMP_NONE, TEMP_DVO_RESULTS, TEMP_DVO_LOG, 6 TEMP_RELASTRO_CATALOG, TEMP_RELPHOT_CATALOG, TEMP_RELPHOT_LOG, TEMP_DVOPSPS_DET, TEMP_FIXSTKIDS_RESULTS, 7 TEMP_RELASTRO_CAT_FULL, TEMP_RELPHOT_CAT_FULL, TEMP_CHECKASTRO_CAT_FULL, 8 }; 6 9 7 10 // functions to manage the remote hosts … … 71 74 if (!strcasecmp(argv[N], "dvo.results")) TEMP_TYPE = TEMP_DVO_RESULTS; 72 75 if (!strcasecmp(argv[N], "dvo.log")) TEMP_TYPE = TEMP_DVO_LOG; 73 if (!strcasecmp(argv[N], "relastro.catalog")) TEMP_TYPE = TEMP_RELASTRO_CATALOG;76 if (!strcasecmp(argv[N], "relastro.catalog")) TEMP_TYPE = TEMP_RELASTRO_CATALOG; 74 77 if (!strcasecmp(argv[N], "relphot.catalog")) TEMP_TYPE = TEMP_RELPHOT_CATALOG; 78 if (!strcasecmp(argv[N], "relastro.catfull")) TEMP_TYPE = TEMP_RELASTRO_CAT_FULL; 79 if (!strcasecmp(argv[N], "checkastro.catfull"))TEMP_TYPE = TEMP_CHECKASTRO_CAT_FULL; 80 if (!strcasecmp(argv[N], "relphot.catfull")) TEMP_TYPE = TEMP_RELPHOT_CAT_FULL; 75 81 if (!strcasecmp(argv[N], "relphot.log")) TEMP_TYPE = TEMP_RELPHOT_LOG; 76 82 if (!strcasecmp(argv[N], "dvopsps.det")) TEMP_TYPE = TEMP_DVOPSPS_DET; … … 78 84 if (TEMP_TYPE == TEMP_NONE) { 79 85 gprint (GP_ERR, "USAGE: hosts purge-temp [-type (type)]\n"); 80 gprint (GP_ERR, " allowed types dvo.results, dvo.log, relphot. results, relphot.log]\n");86 gprint (GP_ERR, " allowed types dvo.results, dvo.log, relphot.catalog, relphot.log, relphot.catfull, relastro.catalog, relastro.catfull, checkastro.catfull, dvopsps.det, fixstkids.results]\n"); 81 87 return FALSE; 82 88 } … … 118 124 if (TEMP_TYPE == TEMP_RELPHOT_CATALOG) snprintf (name, DVO_MAX_PATH, "%s/relphot.catalog.subset.dat", table->hosts[i].pathname); 119 125 if (TEMP_TYPE == TEMP_RELPHOT_LOG) snprintf (name, DVO_MAX_PATH, "%s/log.rlpc.*", table->hosts[i].pathname); 126 if (TEMP_TYPE == TEMP_RELASTRO_CAT_FULL) snprintf (name, DVO_MAX_PATH, "%s/relastro.catalog.?????.?????.dat", table->hosts[i].pathname); 127 if (TEMP_TYPE == TEMP_CHECKASTRO_CAT_FULL) snprintf (name, DVO_MAX_PATH, "%s/checkastro.catalog.?????.?????.dat", table->hosts[i].pathname); 128 if (TEMP_TYPE == TEMP_RELPHOT_CAT_FULL) snprintf (name, DVO_MAX_PATH, "%s/relphot.catalog.?????.?????.dat", table->hosts[i].pathname); 120 129 if (TEMP_TYPE == TEMP_DVOPSPS_DET) snprintf (name, DVO_MAX_PATH, "%s/dvopsps.*.det.dat", table->hosts[i].pathname); 121 130 if (TEMP_TYPE == TEMP_FIXSTKIDS_RESULTS) snprintf (name, DVO_MAX_PATH, "%s/fixstkids.results.*.dat", table->hosts[i].pathname); … … 126 135 if (TEMP_TYPE == TEMP_RELPHOT_CATALOG) snprintf (name, DVO_MAX_PATH, "%s/relphot.catalog.subset.dat", table->hosts[i].pathname); 127 136 if (TEMP_TYPE == TEMP_RELPHOT_LOG) snprintf (name, DVO_MAX_PATH, "%s/log.rlpc.*", table->hosts[i].pathname); 137 if (TEMP_TYPE == TEMP_RELASTRO_CAT_FULL) snprintf (name, DVO_MAX_PATH, "%s/relastro.catalog.%05d.?????.dat", table->hosts[i].pathname, PID); 138 if (TEMP_TYPE == TEMP_CHECKASTRO_CAT_FULL) snprintf (name, DVO_MAX_PATH, "%s/checkastro.catalog.%05d.?????.dat", table->hosts[i].pathname, PID); 139 if (TEMP_TYPE == TEMP_RELPHOT_CAT_FULL) snprintf (name, DVO_MAX_PATH, "%s/relphot.catalog.%05d.?????.dat", table->hosts[i].pathname, PID); 128 140 if (TEMP_TYPE == TEMP_DVOPSPS_DET) snprintf (name, DVO_MAX_PATH, "%s/dvopsps.%05d.*.det.dat", table->hosts[i].pathname, PID); 129 141 if (TEMP_TYPE == TEMP_FIXSTKIDS_RESULTS) snprintf (name, DVO_MAX_PATH, "%s/fixstkids.results.%05d.*.dat", table->hosts[i].pathname, PID); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/imdata.c
r34088 r37403 3 3 int imdata (int argc, char **argv) { 4 4 5 off_t i, j, k, n,I;5 off_t i, j, k, I; 6 6 int N, NPTS, found, mode, TimeSelect, TimeFormat; 7 7 off_t Nregions, NREGIONS; … … 152 152 for (i = 0; i < catalog.Nmeasure; i++) { 153 153 if ((catalog.measure[i].t < start) || (catalog.measure[i].t > stop)) continue; 154 n = catalog.measure[i].averef; 155 vec[0].elements.Flt[N] = catalog.average[n].R - catalog.measure[i].dR / 3600.0; 154 vec[0].elements.Flt[N] = catalog.measure[i].R; 156 155 N++; 157 156 CHECK_REALLOCATE (vec[0].elements.Flt, opihi_flt, NPTS, N, 1000); … … 161 160 for (i = 0; i < catalog.Nmeasure; i++) { 162 161 if ((catalog.measure[i].t < start) || (catalog.measure[i].t > stop)) continue; 163 n = catalog.measure[i].averef; 164 vec[0].elements.Flt[N] = catalog.average[n].D - catalog.measure[i].dD / 3600.0; 162 vec[0].elements.Flt[N] = catalog.measure[i].D; 165 163 N++; 166 164 CHECK_REALLOCATE (vec[0].elements.Flt, opihi_flt, NPTS, N, 1000); … … 194 192 for (i = 0; i < catalog.Nmeasure; i++) { 195 193 if ((catalog.measure[i].t < start) || (catalog.measure[i].t > stop)) continue; 196 n = catalog.measure[i].averef;194 //n = catalog.measure[i].averef; 197 195 // vec[0].elements.Flt[N] = catalog.average[n].M; 198 196 N++; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/imextract.c
r34088 r37403 185 185 gprint (GP_ERR, " Mcal : photometry calibration (mags)\n"); 186 186 gprint (GP_ERR, " dMcal : photometry calibration error (mags)\n"); 187 gprint (GP_ERR, " Xm: chisq of photometry calibration\n");187 gprint (GP_ERR, " Mchisq : chisq of photometry calibration\n"); 188 188 gprint (GP_ERR, " photcode : numeric photcode value for image\n"); 189 189 gprint (GP_ERR, " exptime : exposure duration (seconds)\n"); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/init.c
r36680 r37403 14 14 int cmpread PROTO((int, char **)); 15 15 int coordimage PROTO((int, char **)); 16 int coordmosaic PROTO((int, char **)); 17 int psastro_model PROTO((int, char **)); 16 18 int ddmags PROTO((int, char **)); 17 19 int detrend PROTO((int, char **)); … … 64 66 {1, "avmatch", avmatch, "extract average data values matched to RA,DEC points"}, 65 67 {1, "badimages", badimages, "look for images with anomalous astrometry"}, 66 {1, "calextract", calextract, "extract photometry calibration"},67 {1, "calmextract", calmextract, "extract photometry calibration"},68 // {1, "calextract", calextract, "extract photometry calibration"}, 69 // {1, "calmextract", calmextract, "extract photometry calibration"}, 68 70 {1, "catdir", catdir_define,"re-define CATDIR"}, 69 {1, "ccd", ccd, "plot color-color diagram"},71 // {1, "ccd", ccd, "plot color-color diagram"}, 70 72 {1, "cmatch", cmatch, "match two catalogs"}, 71 {1, "cmd", cmd, "plot cmd of stars in current region"},73 // {1, "cmd", cmd, "plot cmd of stars in current region"}, 72 74 {1, "cmpload", cmpload, "load cmp file into ?"}, 73 75 {1, "cmpread", cmpread, "read data from cmp format files"}, 74 76 {1, "coordimage", coordimage, "generate a map of the transformation residuals"}, 75 {1, "ddmags", ddmags, "plot magnitude differences"}, 77 {1, "coordmosaic", coordmosaic, "generate a map of the distortion"}, 78 {1, "psastro_model", psastro_model, "save psastro-format astrometry model"}, 79 // {1, "ddmags", ddmags, "plot magnitude differences"}, 76 80 {1, "detrend", detrend, "extract from detrend database?"}, 77 {1, "dmagaves", dmagaves, "foo"},78 {1, "dmagmeas", dmagmeas, "foo"},79 {1, "dmags", dmags, "plot differential magnitudes between filters"},81 // {1, "dmagaves", dmagaves, "foo"}, 82 // {1, "dmagmeas", dmagmeas, "foo"}, 83 // {1, "dmags", dmags, "plot differential magnitudes between filters"}, 80 84 {1, "dmt", dmt, "plot mag scatter"}, 81 85 {1, "elixir", elixir, "talk to elixir"}, 82 {1, "fitcolors", fitcolors, "fit chip-to-chip color terms"},86 // {1, "fitcolors", fitcolors, "fit chip-to-chip color terms"}, 83 87 {1, "fitsed", fitsed, "fit stellar SEDs to objects"}, 84 88 {1, "gcat", gcat, "get catalog at location"}, -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/lcurve.c
r34584 r37403 129 129 if (ErrorBars) dYvec.elements.Flt[N] = catalog.measure[m].dM; 130 130 Xvec.elements.Flt[N] = TimeValue (catalog.measure[m].t, TimeReference, TimeFormat); 131 Yvec.elements.Flt[N] = PhotCat (&catalog.measure[m] );131 Yvec.elements.Flt[N] = PhotCat (&catalog.measure[m], MAG_CLASS_PSF); 132 132 /**** need to use PhotRel optionally here ****/ 133 133 N++; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/lightcurve.c
r27435 r37403 121 121 dmvec[0].elements.Flt[N] = catalog.measure[m].dM; 122 122 if (RELPHOT) { 123 mvec[0].elements.Flt[N] = PhotCat (&catalog.measure[m] );123 mvec[0].elements.Flt[N] = PhotCat (&catalog.measure[m], MAG_CLASS_PSF); 124 124 } else { 125 mvec[0].elements.Flt[N] = PhotRel (&catalog.measure[m], &catalog.average[k], &catalog.secfilt[k*Nsecfilt] );125 mvec[0].elements.Flt[N] = PhotRel (&catalog.measure[m], &catalog.average[k], &catalog.secfilt[k*Nsecfilt], MAG_CLASS_PSF); 126 126 } 127 127 N++; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/photometry.c
r36680 r37403 41 41 } 42 42 43 # if (0) 43 44 /* selection criteria */ 44 45 /* selections based on Measure quantities */ … … 78 79 static time_t TimeReference; 79 80 static int TimeFormat; 80 81 # endif 82 83 # if (0) 81 84 int GetTimeSelection (time_t *tz, time_t *te) { 82 85 *tz = tzero; … … 298 301 return; 299 302 } 300 301 /* (re)load photcodes from photcode table */ 302 int InitPhotcodes () { 303 304 double ZERO_POINT; 305 char MasterPhotcodeFile[256]; 306 char CatdirPhotcodeFile[256]; 307 char *catdir; 308 309 if (VarConfig ("ZERO_PT", "%lf", &ZERO_POINT) == (char *) NULL) { 310 gprint (GP_ERR, "ZERO_PT undefined in config\n"); 311 return (FALSE); 312 } 313 SetZeroPoint (ZERO_POINT); 314 315 catdir = GetCATDIR(); 316 if (catdir == NULL) { 317 CatdirPhotcodeFile[0] = 0; 318 } else { 319 sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", catdir); 320 } 321 322 if (VarConfig ("PHOTCODE_FILE", "%s", MasterPhotcodeFile) == (char *) NULL) { 323 gprint (GP_ERR, "PHOTCODE_FILE undefined in config\n"); 324 return (FALSE); 325 } 326 327 // XXX now that DVO does not allow write access, we can drop the MasterPhotcodeFile 328 if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, FALSE)) { 329 gprint (GP_ERR, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile); 330 return (FALSE); 331 } 332 return (TRUE); 333 } 334 303 # endif 304 305 # if (0) 335 306 int ListPhotSelections () { 336 307 … … 1121 1092 return (list); 1122 1093 } 1123 1094 # endif 1095 1096 # if (0) 1124 1097 double GetMeasure (int param, Average *average, Measure *measure, double mag) { 1125 1098 … … 1135 1108 break; 1136 1109 case MEAS_RA: /* OK */ 1137 value = average[0].R - measure[0].dR / 3600.0;1110 value = measure[0].R; 1138 1111 break; 1139 1112 case MEAS_DEC: /* OK */ 1140 value = average[0].D - measure[0].dD / 3600.0;1113 value = measure[0].D; 1141 1114 break; 1142 1115 case MEAS_DOPHOT: /* OK */ … … 1156 1129 break; 1157 1130 case MEAS_RA_OFFSET: /* OK */ 1158 value = measure[0].dR;1131 value = dvoOffsetR(measure, average); 1159 1132 break; 1160 1133 case MEAS_DEC_OFFSET: /* OK */ 1161 value = measure[0].dD;1134 value = dvoOffsetD(measure, average); 1162 1135 break; 1163 1136 case MEAS_FWHM: /* OK */ … … 1172 1145 value = measure[0].Xccd; 1173 1146 # else 1174 ra = average[0].R - measure[0].dR / 3600.0;1175 dec = average[0].D - measure[0].dD / 3600.0;1147 ra = measure[0].R; 1148 dec = measure[0].D; 1176 1149 image = MatchImageDVO (measure[0].t, measure[0].photcode, measure[0].imageID); 1177 1150 if (image == NULL) break; … … 1185 1158 value = measure[0].Yccd; 1186 1159 # else 1187 ra = average[0].R - measure[0].dR / 3600.0;1188 dec = average[0].D - measure[0].dD / 3600.0;1160 ra = measure[0].R; 1161 dec = measure[0].D; 1189 1162 image = MatchImageDVO (measure[0].t, measure[0].photcode, measure[0].imageID); 1190 1163 if (image == NULL) break; … … 1195 1168 # if 0 1196 1169 case MEAS_XMOSAIC: /* OK */ 1197 ra = average[0].R - measure[0].dR / 3600.0;1198 dec = average[0].D - measure[0].dD / 3600.0;1170 ra = measure[0].R; 1171 dec = measure[0].D; 1199 1172 mosaic = MatchMosaic (measure[0].t, measure[0].photcode); // XXX not used anymore 1200 1173 if (mosaic == NULL) break; … … 1203 1176 break; 1204 1177 case MEAS_YMOSAIC: /* OK */ 1205 ra = average[0].R - measure[0].dR / 3600.0;1206 dec = average[0].D - measure[0].dD / 3600.0;1178 ra = measure[0].R; 1179 dec = measure[0].D; 1207 1180 mosaic = MatchMosaic (measure[0].t, measure[0].photcode); // XXX not used anymore 1208 1181 if (mosaic == NULL) break; … … 1214 1187 return (value); 1215 1188 } 1189 # endif 1216 1190 1217 1191 /** the mosaic entries do not use the registered mosaic found -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/pmeasure.c
r34088 r37403 203 203 if (TimeSelect && (catalog.measure[m+k].t > tzero + trange)) continue; 204 204 if ((PhotcodeClip != -1) && (catalog.measure[m+k].photcode != PhotcodeClip)) continue; 205 mag = PhotCat (&catalog.measure[m+k] );205 mag = PhotCat (&catalog.measure[m+k], MAG_CLASS_PSF); 206 206 Zvec[Npts] = MIN (1.0, MAX (0.01, (mag - Mz) / Mr)); 207 207 if (LimExclude && (Zvec[Npts] > 0.99)) continue; 208 208 if (Zvec[Npts] < 0.011) continue; 209 R = catalog. average[i].R - catalog.measure[m+k].dR/3600.0;210 D = catalog. average[i].D - catalog.measure[m+k].dD/3600.0;209 R = catalog.measure[m+k].R; 210 D = catalog.measure[m+k].D; 211 211 // XXX drop this check 212 212 if ((R < Rmin) || (R > Rmax) || (D < -90.0) || (D > 90.0)) { 213 213 char *date; 214 214 date = ohana_sec_to_date (catalog.measure[m+k].t); 215 gprint (GP_LOG, "out: %f, %f : %s : (%f, %f) + (%f, %f)\n", R, D, date, catalog.average[i].R, catalog.average[i].D, catalog.measure[m+k]. dR/3600.0, catalog.measure[m+k].dD/3600.0);215 gprint (GP_LOG, "out: %f, %f : %s : (%f, %f) + (%f, %f)\n", R, D, date, catalog.average[i].R, catalog.average[i].D, catalog.measure[m+k].R, catalog.measure[m+k].D); 216 216 free (date); 217 217 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/subpix.c
r31635 r37403 138 138 for (j = 0; j < Nmeasure; j++) { 139 139 if (measure[j].t == Timage) { 140 Mabs = PhotCat (&measure[j] );140 Mabs = PhotCat (&measure[j], MAG_CLASS_PSF); 141 141 RD_to_XY (&X, &Y, Ra, Dec, &image[I].coords); 142 142 t = TimeValue (measure[j].t, TimeReference, TimeFormat); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/include/dvomath.h
r36680 r37403 170 170 Vector **ReadVectorTableFITS PROTO((char *filename, char *extname, int *Nvec)); 171 171 172 int VectorAssignData PROTO((Vector **vec, char *type, void *data, int Nrows, int Nval)); 173 int VectorAssignDataTranspose PROTO((Vector **vec, char *type, void *data, int Nrows, int Nval)); 174 172 175 /* buffer handling */ 173 176 Buffer *InitBuffer PROTO((void)); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/include/dvoshell.h
r35416 r37403 90 90 int wordhash PROTO((char *word)); 91 91 92 int GetMagMode PROTO((char *string));93 PhotCode *ParsePhotcodeField PROTO((char *field, int *mode, int def));94 int ParseMeasureField PROTO((dbField *field, char *fieldName));95 int ParseAverageField PROTO((dbField *field, char *fieldName));96 int ParseImageField PROTO((dbField *field, char *fieldName));97 98 dbValue dbExtractMeasures PROTO((Average *average, SecFilt *secfilt, Measure *measure, dbField *field));99 dbValue dbExtractImages PROTO((Image *image, off_t Nimage, off_t N, dbField *field));100 101 92 int HostTableLaunchJobs PROTO((SkyList *sky, HostTable *table, char *basecmd, char *options, int VERBOSE)); 102 93 int HostTableParallelOps PROTO((SkyList *sky, int argc, char **argv, char *ResultFile, int ReadVectors, int Nelements, int VERBOSE)); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/include/shell.h
r33662 r37403 166 166 // wrap readline in ohana mem functions: 167 167 char *opihi_readline PROTO((char *prompt)); 168 169 int set_list_varname (char *line, char *base, int N, int excelStyle); 168 170 169 171 /* gprint functions */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/lib.shell/VectorIO.c
r35109 r37403 134 134 FTable ftable; 135 135 136 int i, j , k;136 int i, j; 137 137 FILE *f = NULL; 138 138 … … 202 202 assert (status); 203 203 204 # define ASSIGN_DATA(TYPE,OPTYPE) \ 205 /* assign the data to the actual vector */ \ 206 if (!strcmp (type, #TYPE)) { \ 207 TYPE *Ptr = data; \ 208 for (k = 0; k < Nrows; k++) { \ 209 for (j = 0; j < Nval; j++, Ptr++) { \ 210 vec[Nvec + j][0].elements.OPTYPE[k] = *Ptr; \ 211 } } } 212 213 // assign the data to the actual vector 214 ASSIGN_DATA(char, Int); 215 ASSIGN_DATA(short, Int); 216 ASSIGN_DATA(int, Int); 217 ASSIGN_DATA(int64_t, Int); 218 ASSIGN_DATA(float, Flt); 219 ASSIGN_DATA(double, Flt); 204 if (!VectorAssignData(&vec[Nvec], type, data, Nrows, Nval)) { 205 // free unneeded things 206 gprint (GP_ERR, "trouble parsing data block type %s\n", type); 207 return (NULL); 208 } 220 209 221 210 free (data); … … 241 230 // return (FALSE); 242 231 } 232 233 # define ASSIGN_DATA(TYPE,DTYPE,OPTYPE) \ 234 /* assign the data to the actual vector */ \ 235 if (!strcmp (type, #TYPE)) { \ 236 DTYPE *Ptr = data; \ 237 for (k = 0; k < Nrows; k++) { \ 238 for (j = 0; j < Nval; j++, Ptr++) { \ 239 vec[j][0].elements.OPTYPE[k] = *Ptr; \ 240 } } return TRUE; } 241 242 int VectorAssignData (Vector **vec, char *type, void *data, int Nrows, int Nval) { 243 244 int j, k; 245 246 // assign the data to the actual vector 247 ASSIGN_DATA(byte, char, Int); 248 ASSIGN_DATA(char, char, Int); 249 ASSIGN_DATA(short, short, Int); 250 ASSIGN_DATA(int, int, Int); 251 ASSIGN_DATA(int64_t, int64_t, Int); 252 ASSIGN_DATA(float, float, Flt); 253 ASSIGN_DATA(double, double, Flt); 254 255 return FALSE; 256 } 257 258 # define ASSIGN_DATA_TRANSPOSE(TYPE,DTYPE,OPTYPE) \ 259 /* assign the data to the actual vector */ \ 260 if (!strcmp (type, #TYPE)) { \ 261 DTYPE *Ptr = data; \ 262 for (k = 0; k < Nrows; k++) { \ 263 for (j = 0; j < Nval; j++, Ptr++) { \ 264 vec[k][0].elements.OPTYPE[j] = *Ptr; \ 265 } } return TRUE; } 266 267 int VectorAssignDataTranspose (Vector **vec, char *type, void *data, int Nrows, int Nval) { 268 269 int j, k; 270 271 // assign the data to the actual vector 272 ASSIGN_DATA_TRANSPOSE(byte, char, Int); 273 ASSIGN_DATA_TRANSPOSE(char, char, Int); 274 ASSIGN_DATA_TRANSPOSE(short, short, Int); 275 ASSIGN_DATA_TRANSPOSE(int, int, Int); 276 ASSIGN_DATA_TRANSPOSE(int64_t, int64_t, Int); 277 ASSIGN_DATA_TRANSPOSE(float, float, Flt); 278 ASSIGN_DATA_TRANSPOSE(double, double, Flt); 279 280 return FALSE; 281 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/lib.shell/string.c
r33662 r37403 322 322 } 323 323 324 int set_list_varname (char *line, char *base, int N, int excelStyle) { 325 326 int i; 327 328 // A-Z correspond to 0 - 25 329 330 if (excelStyle) { 331 float f = log(26.0); 332 float g = (N == 0) ? 0.0 : log(1.0*N); 333 int Ndigit = (int) (g / f) + 1; 334 if (Ndigit > 10) { 335 sprintf (line, "%s:ZZZZZZZZZZ", base); 336 return FALSE; 337 } 338 char name[12]; 339 memset (name, 0, 12); 340 for (i = 0; i < Ndigit; i++) { 341 float Npow = Ndigit - i - 1; 342 float g = pow(26.0, Npow); 343 int V = (int) (N / g); 344 name[i] = (Npow == 0.0) ? 'A' + V : 'A' + V - 1; 345 N -= V * g; 346 } 347 sprintf (line, "%s:%s", base, name); 348 } else { 349 sprintf (line, "%s:%d", base, N); 350 } 351 return TRUE; 352 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pcontrol/PclientCommand.c
r27435 r37403 25 25 return (PCLIENT_DOWN); 26 26 } 27 27 28 28 // prepare host to accept response 29 29 host[0].response_state = response_state; … … 35 35 return (PCLIENT_GOOD); 36 36 } 37 37 38 38 // check for response; message must end with specified string. 39 39 // accumulate the response in the buffer … … 47 47 ASSERT (response != NULL, "response missing"); 48 48 ASSERT (buffer != NULL, "buffer missing"); 49 50 // INITTIME; 49 51 50 52 /* avoid blocking very long on read, test every 100 usec, up to 0.1 sec */ … … 66 68 return (PCLIENT_DOWN); 67 69 } 68 if (line == NULL) return (PCLIENT_HUNG); 69 if (status == -1) return (PCLIENT_HUNG); 70 if (line == NULL) { 71 // MARKTIME ("-- client hung (line NULL): %s : %f sec\n", host[0].hostname, dtime); 72 return (PCLIENT_HUNG); 73 } 74 if (status == -1) { 75 // MARKTIME ("-- client hung (status -1): %s : %f sec\n", host[0].hostname, dtime); 76 return (PCLIENT_HUNG); 77 } 70 78 71 79 // fprintf (stderr, "response: %s\n", buffer[0].buffer); … … 75 83 76 84 /* memstr returns a view, not an allocated string : don't free */ 77 /* ReadtoIOBuffer returns : 85 /* ReadtoIOBuffer returns : 78 86 0 - pipe closed 79 87 -1 - no more data in pipe, data not ready -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/photdbc/Makefile
r33655 r37403 31 31 $(SRC)/args.$(ARCH).o \ 32 32 $(SRC)/copy_images.$(ARCH).o \ 33 $(SRC)/select_images.$(ARCH).o \ 33 34 $(SRC)/Shutdown.$(ARCH).o \ 34 35 $(SRC)/join_stars.$(ARCH).o \ … … 41 42 $(SRC)/ConfigInit.$(ARCH).o \ 42 43 $(SRC)/args.$(ARCH).o \ 43 $(SRC)/copy_images.$(ARCH).o \44 44 $(SRC)/Shutdown.$(ARCH).o \ 45 45 $(SRC)/join_stars.$(ARCH).o \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/photdbc/include/photdbc.h
r33963 r37403 20 20 int Nmeas; 21 21 } StatType; 22 23 typedef struct { 24 double Xc[5]; 25 double Yc[5]; 26 double Rc; 27 double Dc; 28 } SkyRegionCoords; 22 29 23 30 int PARALLEL; … … 80 87 PhotCodeData photcodes; 81 88 82 char *PHOTCODE_DROP_LIST, *PHOTCODE_ SKIP_LIST;83 int NphotcodesDrop, Nphotcodes Skip;84 PhotCode **photcodesDrop, **photcodes Skip;89 char *PHOTCODE_DROP_LIST, *PHOTCODE_KEEP_LIST; 90 int NphotcodesDrop, NphotcodesKeep; 91 PhotCode **photcodesDrop, **photcodesKeep; 85 92 86 93 # define FLAG_AREA 0X0001 … … 131 138 void SetProtect (int mode); 132 139 int SetSignals (void); 133 int copy_images (char *outdir );140 int copy_images (char *outdir, SkyList *skylist); 134 141 void usage(); 142 143 void dsortindex (double *X, off_t *Y, int N); 144 off_t getRegionStartByRA (double R, double *Rref, off_t Nregions); 145 146 Image *select_images (SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage, int UseFullOverlap); 135 147 136 148 int photdbc_catalogs (char *outroot, SkyList *skylist, int hostID); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/photdbc/src/args.c
r33655 r37403 85 85 } 86 86 87 // measurements with these photcodes are not copied to the output 87 88 PHOTCODE_DROP_LIST = NULL; 88 89 if ((N = get_argument (argc, argv, "-photcode-drop"))) { … … 92 93 } 93 94 94 PHOTCODE_SKIP_LIST = NULL; 95 if ((N = get_argument (argc, argv, "-photcode-skip"))) { 96 remove_argument (N, &argc, argv); 97 PHOTCODE_SKIP_LIST = strcreate(argv[N]); 95 // measurements with these photcodes are kept ***regardless of quality*** 96 // -photcode-keep J will keep all J-band measurements of all kinds 97 // -photcode-keep GPC1.02.g will keep all g-band measurements from chip XY02 98 PHOTCODE_KEEP_LIST = NULL; 99 if ((N = get_argument (argc, argv, "-photcode-keep"))) { 100 remove_argument (N, &argc, argv); 101 PHOTCODE_KEEP_LIST = strcreate(argv[N]); 98 102 remove_argument (N, &argc, argv); 99 103 } … … 254 258 } 255 259 256 PHOTCODE_ SKIP_LIST = NULL;257 if ((N = get_argument (argc, argv, "-photcode- skip"))) {258 remove_argument (N, &argc, argv); 259 PHOTCODE_ SKIP_LIST = strcreate(argv[N]);260 PHOTCODE_KEEP_LIST = NULL; 261 if ((N = get_argument (argc, argv, "-photcode-keep"))) { 262 remove_argument (N, &argc, argv); 263 PHOTCODE_KEEP_LIST = strcreate(argv[N]); 260 264 remove_argument (N, &argc, argv); 261 265 } … … 290 294 291 295 fprintf (stderr, " -photcode-drop : remove these photcodes from the output (REF or DEP only)\n"); 292 fprintf (stderr, " -photcode- skip : ignore these photcodes when assessing the validity (keep unless object is dropped)\n");296 fprintf (stderr, " -photcode-keep : ignore these photcodes when assessing the validity (keep unless object is dropped)\n"); 293 297 294 298 fprintf (stderr, " -instmag (min) (max) : range of valid instrumental magnitudes (or measurements are dropped)\n"); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/photdbc/src/copy_images.c
r33655 r37403 1 1 # include "photdbc.h" 2 2 3 int copy_images (char *outdir ) {3 int copy_images (char *outdir, SkyList *skylist) { 4 4 5 5 int status; 6 off_t Nimage; 6 off_t Nimage, Nsubset; 7 off_t *LineNumber; 7 8 char *ImageOut; 8 9 unsigned int imageID; 9 10 FITS_DB in; 10 11 FITS_DB out; 11 Image *image ;12 Image *image, *subset; 12 13 struct stat filestat; 13 14 char *path; … … 50 51 exit (2); 51 52 } 52 dvo_image_addrows (&out, image, Nimage); 53 54 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset, FALSE); 55 56 dvo_image_addrows (&out, subset, Nsubset); 53 57 54 58 // note that imageID is unsigned int -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/photdbc/src/get_mags.c
r15509 r37403 22 22 catalog[0].secfilt[i*Nsecfilt+j].M = NAN; 23 23 catalog[0].secfilt[i*Nsecfilt+j].dM = NAN; 24 catalog[0].secfilt[i*Nsecfilt+j]. Xm = NAN_S_SHORT;24 catalog[0].secfilt[i*Nsecfilt+j].Mchisq = NAN; 25 25 } 26 26 } … … 56 56 Mval = (Nsec == -1) ? &catalog[0].average[i].dM : &catalog[0].secfilt[i*Nsecfilt+Nsec].dM; 57 57 *Mval = stats.sigma; 58 Mval = (Nsec == -1) ? &catalog[0].average[i]. Xm : &catalog[0].secfilt[i*Nsecfilt+Nsec].Xm;59 *Mval = 100.0*log10(stats.chisq);58 Mval = (Nsec == -1) ? &catalog[0].average[i].Mchisq : &catalog[0].secfilt[i*Nsecfilt+Nsec].Mchisq; 59 *Mval = stats.chisq; 60 60 } 61 61 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/photdbc/src/initialize.c
r33655 r37403 13 13 14 14 photcodesDrop = ParsePhotcodeList (PHOTCODE_DROP_LIST, &NphotcodesDrop, FALSE); 15 photcodes Skip = ParsePhotcodeList (PHOTCODE_SKIP_LIST, &NphotcodesSkip, FALSE);15 photcodesKeep = ParsePhotcodeList (PHOTCODE_KEEP_LIST, &NphotcodesKeep, FALSE); 16 16 17 17 if (SHOW_PARAMS) { … … 54 54 55 55 photcodesDrop = ParsePhotcodeList (PHOTCODE_DROP_LIST, &NphotcodesDrop, FALSE); 56 photcodes Skip = ParsePhotcodeList (PHOTCODE_SKIP_LIST, &NphotcodesSkip, FALSE);56 photcodesKeep = ParsePhotcodeList (PHOTCODE_KEEP_LIST, &NphotcodesKeep, FALSE); 57 57 58 58 if (SHOW_PARAMS) { -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/photdbc/src/join_stars.c
r36680 r37403 3 3 void join_stars (Catalog *catalog) { 4 4 5 off_t i, j, k, m, M, Ni, Nj, first_j, Nfirst;5 off_t i, j, k, m, Ni, Nj, first_j; 6 6 off_t Naves, Nmeas, Ncurr; 7 7 off_t Naverage, Nmeasure, *index; … … 109 109 mpointer[Nmeas].measure = m; 110 110 mpointer[Nmeas].averef = Naves; 111 mpointer[Nmeas].R = average[Ni].R - measure[m].dR / 3600.0;112 mpointer[Nmeas].D = average[Ni].D - measure[m].dD / 3600.0;111 mpointer[Nmeas].R = measure[m].R; 112 mpointer[Nmeas].D = measure[m].D; 113 113 Nmeas ++; 114 114 } … … 155 155 mpointer[Nmeas].measure = m; 156 156 mpointer[Nmeas].averef = Ncurr; 157 mpointer[Nmeas].R = average[Nj].R - measure[m].dR / 3600.0;158 mpointer[Nmeas].D = average[Nj].D - measure[m].dD / 3600.0;157 mpointer[Nmeas].R = measure[m].R; 158 mpointer[Nmeas].D = measure[m].D; 159 159 Nmeas ++; 160 160 } 161 Nfirst = average[Nj].Nmeasure;162 161 naverage[Ncurr].Nmeasure += average[Nj].Nmeasure; 163 162 found[j] = TRUE; … … 178 177 179 178 /* update original measurement offsets for new detections */ 180 for (k = Nfirst; k < naverage[Ncurr].Nmeasure; k++) {181 m = naverage[Ncurr].measureOffset + k;182 M = mpointer[m].measure;183 measure[M].dR = 3600.0*(Sr - mpointer[m].R);184 measure[M].dD = 3600.0*(Sd - mpointer[m].D);185 }179 // for (k = Nfirst; k < naverage[Ncurr].Nmeasure; k++) { 180 // m = naverage[Ncurr].measureOffset + k; 181 // M = mpointer[m].measure; 182 // measure[M].dR = 3600.0*(Sr - mpointer[m].R); 183 // measure[M].dD = 3600.0*(Sd - mpointer[m].D); 184 // } 186 185 187 186 /* update current reference star position */ … … 189 188 # else 190 189 /* update original measurement offsets for new detections */ 191 for (k = Nfirst; k < naverage[Ncurr].Nmeasure; k++) { 192 m = naverage[Ncurr].measureOffset + k; 193 M = mpointer[m].measure; 194 measure[M].dR = 3600.0*(naverage[Ncurr].R - mpointer[m].R); 195 measure[M].dD = 3600.0*(naverage[Ncurr].D - mpointer[m].D); 196 } 190 // now not needed measure[M] carries R,D 191 // for (k = Nfirst; k < naverage[Ncurr].Nmeasure; k++) { 192 // m = naverage[Ncurr].measureOffset + k; 193 // M = mpointer[m].measure; 194 // measure[M].dR = 3600.0*(naverage[Ncurr].R - mpointer[m].R); 195 // measure[M].dD = 3600.0*(naverage[Ncurr].D - mpointer[m].D); 196 // } 197 197 # endif 198 198 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/photdbc/src/make_subcatalog.c
r31635 r37403 9 9 off_t NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm, Nsecfilt; 10 10 double mag, minMag, minSigma; 11 int keep, *sec Skip;11 int keep, *secKeep; 12 12 PhotCode *photcode; 13 13 … … 16 16 17 17 // set up a list of SEC entries to ignore when evaluating a source 18 ALLOCATE (sec Skip, int, Nsecfilt);18 ALLOCATE (secKeep, int, Nsecfilt); 19 19 for (i = 0; i < Nsecfilt; i++) { 20 sec Skip[i] = FALSE;20 secKeep[i] = FALSE; 21 21 photcode = GetPhotcodebyNsec(i); 22 for (k = 0; k < Nphotcodes Skip; k++) {23 if (photcodes Skip[k][0].code != photcode[0].code) continue;24 sec Skip[i] = TRUE;22 for (k = 0; k < NphotcodesKeep; k++) { 23 if (photcodesKeep[k][0].code != photcode[0].code) continue; 24 secKeep[i] = TRUE; 25 25 } 26 26 } … … 67 67 keep = FALSE; 68 68 for (j = 0; !keep && (j < Nsecfilt); j++) { 69 if (sec Skip[j]) continue;69 if (secKeep[j]) continue; 70 70 if (catalog[0].secfilt[Nsecfilt*i+j].Ncode >= NCODE_MIN) { 71 71 keep = TRUE; … … 101 101 if (NphotcodesDrop > 0) { 102 102 found = FALSE; 103 for (k = 0; (k < Nphotcodes Skip) && !found; k++) {104 if (photcodes Skip[k][0].code == catalog[0].measure[offset].photcode) found = TRUE;105 if (photcodes Skip[k][0].code == GetPhotcodeEquivCodebyCode(catalog[0].measure[offset].photcode)) found = TRUE;103 for (k = 0; (k < NphotcodesDrop) && !found; k++) { 104 if (photcodesDrop[k][0].code == catalog[0].measure[offset].photcode) found = TRUE; 105 if (photcodesDrop[k][0].code == GetPhotcodeEquivCodebyCode(catalog[0].measure[offset].photcode)) found = TRUE; 106 106 } 107 107 if (found) continue; … … 109 109 110 110 // ignore certain photcodes to assess the measurements 111 if (Nphotcodes Skip > 0) {111 if (NphotcodesKeep > 0) { 112 112 found = FALSE; 113 for (k = 0; (k < Nphotcodes Skip) && !found; k++) {114 if (photcodes Skip[k][0].code == catalog[0].measure[offset].photcode) found = TRUE;115 if (photcodes Skip[k][0].code == GetPhotcodeEquivCodebyCode(catalog[0].measure[offset].photcode)) found = TRUE;113 for (k = 0; (k < NphotcodesKeep) && !found; k++) { 114 if (photcodesKeep[k][0].code == catalog[0].measure[offset].photcode) found = TRUE; 115 if (photcodesKeep[k][0].code == GetPhotcodeEquivCodebyCode(catalog[0].measure[offset].photcode)) found = TRUE; 116 116 } 117 117 if (found) goto keep; … … 123 123 // select measurements by mag limit -- drop exactly this measurement 124 124 if (ExcludeByInstMag) { 125 mag = PhotInst (&catalog[0].measure[offset] );125 mag = PhotInst (&catalog[0].measure[offset], MAG_CLASS_PSF); 126 126 if (mag < INST_MAG_MIN) continue; 127 127 if (mag > INST_MAG_MAX) continue; … … 135 135 // check measurements for this object -- drop object if no measurements pass 136 136 if (ExcludeByMaxMinMag) { 137 mag = PhotSys (&catalog[0].measure[offset], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt] );137 mag = PhotSys (&catalog[0].measure[offset], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt], MAG_CLASS_PSF); 138 138 minMag = MIN (minMag, mag); 139 139 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/photdbc/src/photdbc.c
r33655 r37403 9 9 initialize (argc, argv); 10 10 11 // load and copy the image table12 copy_images (argv[1]);13 14 11 // the output catalog needs to inherit the SKY_DEPTH of the input catalog 15 12 sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, 0, VERBOSE); 16 13 SkyTableSetFilenames (sky, CATDIR, "cpt"); 17 14 skylist = SkyListByPatch (sky, -1, ®ION); 15 16 // load and copy the image table 17 copy_images (argv[1], skylist); 18 18 19 19 // hostID is 0 for master program -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/photdbc/src/photdbc_catalogs.c
r33963 r37403 120 120 if (ExcludeByMaxMinMag) { snprintf (tmpline, DVO_MAX_PATH, "%s -maxminmag %f", command, MAX_MIN_MAG); strcpy (command, tmpline); } 121 121 if (PHOTCODE_DROP_LIST) { snprintf (tmpline, DVO_MAX_PATH, "%s -photcode-drop %s", command, PHOTCODE_DROP_LIST); strcpy (command, tmpline); } 122 if (PHOTCODE_ SKIP_LIST) { snprintf (tmpline, DVO_MAX_PATH, "%s -photcode-skip %s", command, PHOTCODE_SKIP_LIST); strcpy (command, tmpline); }122 if (PHOTCODE_KEEP_LIST) { snprintf (tmpline, DVO_MAX_PATH, "%s -photcode-keep %s", command, PHOTCODE_KEEP_LIST); strcpy (command, tmpline); } 123 123 if (CATFORMAT) { snprintf (tmpline, DVO_MAX_PATH, "%s -set-format %s", command, CATFORMAT); strcpy (command, tmpline); } 124 124 if (CATMODE) { snprintf (tmpline, DVO_MAX_PATH, "%s -set-mode %s", command, CATMODE); strcpy (command, tmpline); } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/Makefile
r36680 r37403 59 59 $(SRC)/save_catalogs.$(ARCH).o \ 60 60 $(SRC)/CoordOps.$(ARCH).o \ 61 $(SRC)/extra.$(ARCH).o \ 61 62 $(SRC)/FixProblemImages.$(ARCH).o \ 62 63 $(SRC)/StarMaps.$(ARCH).o \ … … 117 118 $(SRC)/save_catalogs.$(ARCH).o \ 118 119 $(SRC)/CoordOps.$(ARCH).o \ 120 $(SRC)/extra.$(ARCH).o \ 119 121 $(SRC)/high_speed_catalogs.$(ARCH).o \ 120 122 $(SRC)/high_speed_objects.$(ARCH).o \ … … 127 129 $(SRC)/plotstuff.$(ARCH).o \ 128 130 $(SRC)/relastroVisual.$(ARCH).o \ 131 $(SRC)/syncfile.$(ARCH).o \ 129 132 $(SRC)/BrightCatalog.$(ARCH).o 130 133 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/include/relastro.h
r36680 r37403 5 5 # include <assert.h> 6 6 # include <pthread.h> 7 8 # define MARKTIME(MSG,...) { \9 gettimeofday (&stopTimer, (void *) NULL); \10 float dtime = DTIME (stopTimer, startTimer); \11 fprintf (stderr, MSG, __VA_ARGS__); }12 13 # define INITTIME \14 struct timeval startTimer, stopTimer; \15 gettimeofday (&startTimer, (void *) NULL);16 7 17 8 // choose off_t or int depending on full-scale relphot analysis resources … … 83 74 double L, M; /* Focal Plane - pixels */ 84 75 double X, Y; /* Chip Coords - pixels */ 85 double Mag; 86 double dMag; 87 double dPos; 76 float Mag; 77 float ColorBlue; 78 float ColorRed; 79 float dMag; 80 float dPos; 88 81 int mask; 89 82 int Nmeas; … … 140 133 int Nmeas; 141 134 } StatType; 135 136 typedef struct { 137 off_t Nave; 138 off_t Npm; 139 off_t Npar; 140 off_t Nskip; 141 off_t Noffset; 142 } FitStats; 142 143 143 144 /* global variables set in parameter file */ … … 207 208 double MaxDensityValue; 208 209 209 char *PHOTCODE_KEEP_LIST, *PHOTCODE_SKIP_LIST ;210 int NphotcodesKeep, NphotcodesSkip ;211 PhotCode **photcodesKeep, **photcodesSkip ;210 char *PHOTCODE_KEEP_LIST, *PHOTCODE_SKIP_LIST, *PHOTCODE_RESET_LIST; 211 int NphotcodesKeep, NphotcodesSkip, NphotcodesReset; 212 PhotCode **photcodesKeep, **photcodesSkip, **photcodesReset; 212 213 213 214 char *PHOTCODE_A_LIST, *PHOTCODE_B_LIST; … … 217 218 SkyRegionSelection SELECTION; 218 219 220 char *DCR_BLUE_COLOR_POS, *DCR_BLUE_COLOR_NEG; 221 PhotCode *DCR_BLUE_PHOTCODE_POS, *DCR_BLUE_PHOTCODE_NEG; 222 int DCR_BLUE_NSEC_POS, DCR_BLUE_NSEC_NEG; 223 224 char *DCR_RED_COLOR_POS, *DCR_RED_COLOR_NEG; 225 PhotCode *DCR_RED_PHOTCODE_POS, *DCR_RED_PHOTCODE_NEG; 226 int DCR_RED_NSEC_POS, DCR_RED_NSEC_NEG; 227 219 228 int ImagSelect; 220 229 double ImagMin, ImagMax; … … 233 242 int CLIP_THRESH; 234 243 int USE_BASIC_CHECK; 244 245 int ExcludeBogus; 246 double ExcludeBogusRadius; 235 247 236 248 FitMode FIT_MODE; … … 307 319 int liststats PROTO((double *value, double *dvalue, int N, StatType *stats)); 308 320 int liststats_pos PROTO((double *value, double *dvalue, int N, StatType *stats, int XVERB)); 309 Catalog *load_catalogs PROTO((SkyList *skylist, int *Ncatalog, int subselect, int hostID, char *hostpath ));321 Catalog *load_catalogs PROTO((SkyList *skylist, int *Ncatalog, int subselect, int hostID, char *hostpath, char *syncfile)); 310 322 int load_images PROTO((FITS_DB *db, SkyList *skylist, int UseFullOverlap)); 311 323 Image *select_images PROTO((SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage, int UseFullOverlap)); … … 417 429 int setMeanR (double ra_fit, MeasureTiny *measure, Average *average, SecFilt *secfilt); 418 430 int setMeanD (double dec_fit, MeasureTiny *measure, Average *average, SecFilt *secfilt); 431 double getMeanR_Big (Measure *measure, Average *average, SecFilt *secfilt); 432 double getMeanD_Big (Measure *measure, Average *average, SecFilt *secfilt); 419 433 int setMeanR_Big (double ra_fit, Measure *measure, Average *average, SecFilt *secfilt); 420 434 int setMeanD_Big (double dec_fit, Measure *measure, Average *average, SecFilt *secfilt); … … 521 535 int ImageTableSave (char *filename, Image *images, off_t Nimages); 522 536 int select_mosaics_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage); 537 538 float getColorBlue (off_t meas, int cat); 539 float getColorRed (off_t meas, int cat); 540 541 int strextend (char *input, char *format,...); 542 543 int areImagesLoaded (); 544 int areImagesMatched (); 545 546 int isGPC1chip (int photcode); 547 int isGPC1stack (int photcode); 548 int isGPC1warp (int photcode); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/BrightCatalog.c
r35105 r37403 68 68 69 69 // need to create and assign to flat-field correction 70 GET_COLUMN( dR, "RA_OFF", float);71 GET_COLUMN( dD, "DEC_OFF", float);70 GET_COLUMN(R, "RA", double); 71 GET_COLUMN(D, "DEC", double); 72 72 GET_COLUMN(M, "MAG_SYS", float); 73 73 GET_COLUMN(Mcal, "MAG_CAL", float); … … 92 92 ALLOCATE (measure, MeasureTiny, Nrow); 93 93 for (i = 0; i < Nrow; i++) { 94 measure[i]. dR = dR[i];95 measure[i]. dD = dD[i];94 measure[i].R = R[i]; 95 measure[i].D = D[i]; 96 96 measure[i].M = M[i]; 97 97 measure[i].Mcal = Mcal[i]; … … 113 113 // fprintf (stderr, "loaded data for %lld measures\n", (long long) Nrow); 114 114 115 free ( dR);116 free ( dD);115 free (R ); 116 free (D ); 117 117 free (M ); 118 118 free (Mcal ); … … 145 145 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) goto escape; 146 146 147 GET_COLUMN(R, "RA", double); 148 GET_COLUMN(D, "DEC", double); 149 GET_COLUMN(dR, "RA_ERR", float); 150 GET_COLUMN(dD, "DEC_ERR", float); 151 GET_COLUMN(uR, "U_RA", float); 152 GET_COLUMN(uD, "U_DEC", float); 153 GET_COLUMN(duR, "V_RA_ERR", float); 154 GET_COLUMN(duD, "V_DEC_ERR", float); 155 GET_COLUMN(P, "PAR", float); 156 GET_COLUMN(dP, "PAR_ERR", float); 157 GET_COLUMN(ChiSqAve, "CHISQ_POS", float); 158 GET_COLUMN(ChiSqPM, "CHISQ_PM", float); 159 GET_COLUMN(ChiSqPar, "CHISQ_PAP", float); 160 GET_COLUMN(Tmean, "MEAN_EPOCH", int); 161 GET_COLUMN(Trange, "TIME_RANGE", int); 162 GET_COLUMN(stargal, "STARGAL_SEP", float); 163 GET_COLUMN(Npos, "NUMBER_POS", short); 164 GET_COLUMN(Nmeasure, "NMEASURE", short); 165 GET_COLUMN(Nmissing, "NMISSING", short); 166 GET_COLUMN(Nextend, "NEXTEND", short); 167 GET_COLUMN(measureOffset, "OFF_MEASURE", int); 168 GET_COLUMN(missingOffset, "OFF_MISSING", int); 169 GET_COLUMN(extendOffset, "OFF_EXTEND", int); 170 GET_COLUMN(flags, "FLAGS", int); 171 GET_COLUMN(photFlagsUpper, "PHOTFLAGS_U", int); 172 GET_COLUMN(photFlagsLower, "PHOTFLAGS_L", int); 173 GET_COLUMN(objID, "OBJ_ID", int); 174 GET_COLUMN(catID, "CAT_ID", int); 175 GET_COLUMN(extID, "EXT_ID", int64_t); 147 GET_COLUMN(R, "RA", double); 148 GET_COLUMN(D, "DEC", double); 149 GET_COLUMN(dR, "RA_ERR", float); 150 GET_COLUMN(dD, "DEC_ERR", float); 151 GET_COLUMN(uR, "U_RA", float); 152 GET_COLUMN(uD, "U_DEC", float); 153 GET_COLUMN(duR, "V_RA_ERR", float); 154 GET_COLUMN(duD, "V_DEC_ERR", float); 155 GET_COLUMN(P, "PAR", float); 156 GET_COLUMN(dP, "PAR_ERR", float); 157 GET_COLUMN(ChiSqAve, "CHISQ_POS", float); 158 GET_COLUMN(ChiSqPM, "CHISQ_PM", float); 159 GET_COLUMN(ChiSqPar, "CHISQ_PAP", float); 160 GET_COLUMN(Tmean, "MEAN_EPOCH", int); 161 GET_COLUMN(Trange, "TIME_RANGE", int); 162 GET_COLUMN(stargal, "STARGAL_SEP", float); 163 GET_COLUMN(Npos, "NUMBER_POS", short); 164 GET_COLUMN(Nmeasure, "NMEASURE", short); 165 GET_COLUMN(Nmissing, "NMISSING", short); 166 GET_COLUMN(Nextend, "NEXTEND", short); 167 GET_COLUMN(measureOffset, "OFF_MEASURE", int); 168 GET_COLUMN(missingOffset, "OFF_MISSING", int); 169 GET_COLUMN(refColorBlue, "REF_COLOR_BLUE", float); 170 GET_COLUMN(refColorRed, "REF_COLOR_RED", float); 171 GET_COLUMN(flags, "FLAGS", int); 172 GET_COLUMN(photFlagsUpper, "PHOTFLAGS_U", int); 173 GET_COLUMN(photFlagsLower, "PHOTFLAGS_L", int); 174 GET_COLUMN(objID, "OBJ_ID", int); 175 GET_COLUMN(catID, "CAT_ID", int); 176 GET_COLUMN(extID, "EXT_ID", int64_t); 176 177 gfits_free_header (&theader); 177 178 gfits_free_table (&ftable); … … 202 203 average[i].measureOffset = measureOffset[i] ; 203 204 average[i].missingOffset = missingOffset[i] ; 204 average[i].extendOffset = extendOffset[i] ; 205 average[i].refColorBlue = refColorBlue[i] ; 206 average[i].refColorRed = refColorRed[i] ; 205 207 average[i].flags = flags[i] ; 206 208 average[i].photFlagsUpper = photFlagsUpper[i] ; … … 234 236 free (measureOffset); 235 237 free (missingOffset); 236 free (extendOffset); 238 free (refColorBlue); 239 free (refColorRed); 237 240 free (flags); 238 241 free (photFlagsUpper); … … 256 259 257 260 // need to create and assign to flat-field correction 258 GET_COLUMN(M, "MAG", float);259 GET_COLUMN(dM, "MAG_ERR", float);260 GET_COLUMN( Xm,"MAG_CHI", float);261 GET_COLUMN(flags, "FLAGS", int);262 GET_COLUMN(Ncode, "NCODE", short);263 GET_COLUMN(Nused, "NUSED", short);264 GET_COLUMN(M _20, "MAG_20", short);265 GET_COLUMN(M _80, "MAG_80", short);261 GET_COLUMN(M, "MAG", float); 262 GET_COLUMN(dM, "MAG_ERR", float); 263 GET_COLUMN(Mchisq, "MAG_CHI", float); 264 GET_COLUMN(flags, "FLAGS", int); 265 GET_COLUMN(Ncode, "NCODE", short); 266 GET_COLUMN(Nused, "NUSED", short); 267 GET_COLUMN(Mmin, "MAG_MIN", float); 268 GET_COLUMN(Mmax, "MAG_MAX", float); 266 269 gfits_free_header (&theader); 267 270 gfits_free_table (&ftable); … … 270 273 ALLOCATE (secfilt, SecFilt, Nrow); 271 274 for (i = 0; i < Nrow; i++) { 272 secfilt[i].M = M[i];273 secfilt[i].dM = dM[i];274 secfilt[i]. Xm = Xm[i];275 secfilt[i].flags = flags[i];276 secfilt[i].Ncode = Ncode[i];277 secfilt[i].Nused = Nused[i];278 secfilt[i].M _20 = M_20[i];279 secfilt[i].M _80 = M_80[i];275 secfilt[i].M = M[i]; 276 secfilt[i].dM = dM[i]; 277 secfilt[i].Mchisq = Mchisq[i]; 278 secfilt[i].flags = flags[i]; 279 secfilt[i].Ncode = Ncode[i]; 280 secfilt[i].Nused = Nused[i]; 281 secfilt[i].Mmin = Mmin[i]; 282 secfilt[i].Mmax = Mmax[i]; 280 283 } 281 284 fprintf (stderr, "loaded data for %lld averages\n", (long long) Nrow); … … 283 286 free (M ); 284 287 free (dM ); 285 free ( Xm);288 free (Mchisq); 286 289 free (flags); 287 290 free (Ncode); 288 291 free (Nused); 289 free (M _20);290 free (M _80);292 free (Mmin ); 293 free (Mmax ); 291 294 catalog->secfilt = secfilt; 292 295 // assert Nsecfilt * Naverage = Nrow? … … 351 354 gfits_define_bintable_column (&theader, "E", "Y_FIX", "ccd y fiex coord", "pix", 1.0, 0.0); 352 355 gfits_define_bintable_column (&theader, "E", "EXPTIME", "-2.5 * log (exposure time)", "sec", 1.0, 0.0); 353 gfits_define_bintable_column (&theader, "J", "TIME", "time of exp", "sec", 1.0, 1.0*0x8000);354 gfits_define_bintable_column (&theader, "J", "AVE_REF", "pointer to average table", NULL, 1.0, 1.0*0x8000);355 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image", NULL, 1.0, 1.0*0x8000);356 gfits_define_bintable_column (&theader, "J", "DB_FLAGS", "flags", NULL, 1.0, 1.0*0x8000);357 gfits_define_bintable_column (&theader, "J", "PHOT_FLAGS", "photflags", NULL, 1.0, 1.0*0x8000);358 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog", NULL, 1.0, 1.0*0x8000);359 gfits_define_bintable_column (&theader, "I", "PHOTCODE", "photcode", NULL, 1.0, 1.0*0x80);356 gfits_define_bintable_column (&theader, "J", "TIME", "time of exp", "sec", 1.0, 0.0); 357 gfits_define_bintable_column (&theader, "J", "AVE_REF", "pointer to average table", NULL, 1.0, 0.0); 358 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image", NULL, 1.0, 0.0); 359 gfits_define_bintable_column (&theader, "J", "DB_FLAGS", "flags", NULL, 1.0, 0.0); 360 gfits_define_bintable_column (&theader, "J", "PHOT_FLAGS", "photflags", NULL, 1.0, 0.0); 361 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog", NULL, 1.0, 0.0); 362 gfits_define_bintable_column (&theader, "I", "PHOTCODE", "photcode", NULL, 1.0, 0.0); 360 363 361 364 // generate the output array that carries the data … … 363 366 364 367 // create intermediate storage arrays 365 float *dR ; ALLOCATE (dR , float, catalog->Nmeasure);366 float *dD ; ALLOCATE (dD , float, catalog->Nmeasure);367 float *M ; ALLOCATE (M , float,catalog->Nmeasure);368 float *Mcal ; ALLOCATE (Mcal , float,catalog->Nmeasure);369 float *dM ; ALLOCATE (dM , float,catalog->Nmeasure);370 float *airmass ; ALLOCATE (airmass , float,catalog->Nmeasure);371 float *Xccd ; ALLOCATE (Xccd , float,catalog->Nmeasure);372 float *Yccd ; ALLOCATE (Yccd , float,catalog->Nmeasure);373 float *Xfix ; ALLOCATE (Xfix , float,catalog->Nmeasure);374 float *Yfix ; ALLOCATE (Yfix , float,catalog->Nmeasure);375 float *dt ; ALLOCATE (dt , float,catalog->Nmeasure);376 int *t ; ALLOCATE (t , int ,catalog->Nmeasure);377 int *averef ; ALLOCATE (averef , int ,catalog->Nmeasure);378 int *imageID ; ALLOCATE (imageID , int ,catalog->Nmeasure);379 int *dbFlags ; ALLOCATE (dbFlags , int ,catalog->Nmeasure);380 int *photFlags ; ALLOCATE (photFlags, int ,catalog->Nmeasure);381 int *catID ; ALLOCATE (catID , int ,catalog->Nmeasure);382 short *photcode ; ALLOCATE (photcode , short,catalog->Nmeasure);368 double *R ; ALLOCATE (R , double, catalog->Nmeasure); 369 double *D ; ALLOCATE (D , double, catalog->Nmeasure); 370 float *M ; ALLOCATE (M , float, catalog->Nmeasure); 371 float *Mcal ; ALLOCATE (Mcal , float, catalog->Nmeasure); 372 float *dM ; ALLOCATE (dM , float, catalog->Nmeasure); 373 float *airmass ; ALLOCATE (airmass , float, catalog->Nmeasure); 374 float *Xccd ; ALLOCATE (Xccd , float, catalog->Nmeasure); 375 float *Yccd ; ALLOCATE (Yccd , float, catalog->Nmeasure); 376 float *Xfix ; ALLOCATE (Xfix , float, catalog->Nmeasure); 377 float *Yfix ; ALLOCATE (Yfix , float, catalog->Nmeasure); 378 float *dt ; ALLOCATE (dt , float, catalog->Nmeasure); 379 int *t ; ALLOCATE (t , int , catalog->Nmeasure); 380 int *averef ; ALLOCATE (averef , int , catalog->Nmeasure); 381 int *imageID ; ALLOCATE (imageID , int , catalog->Nmeasure); 382 int *dbFlags ; ALLOCATE (dbFlags , int , catalog->Nmeasure); 383 int *photFlags ; ALLOCATE (photFlags, int , catalog->Nmeasure); 384 int *catID ; ALLOCATE (catID , int , catalog->Nmeasure); 385 short *photcode ; ALLOCATE (photcode , short, catalog->Nmeasure); 383 386 384 387 // assign the storage arrays 385 388 MeasureTiny *measure = catalog->measure; 386 389 for (i = 0; i < catalog->Nmeasure; i++) { 387 dR[i] = measure[i].dR;388 dD[i] = measure[i].dD;390 R[i] = measure[i].R ; 391 D[i] = measure[i].D ; 389 392 M[i] = measure[i].M ; 390 393 Mcal[i] = measure[i].Mcal ; … … 406 409 407 410 // add the columns to the output array 408 gfits_set_bintable_column (&theader, &ftable, "RA _OFF", dR,catalog->Nmeasure);409 gfits_set_bintable_column (&theader, &ftable, "DEC _OFF", dD,catalog->Nmeasure);411 gfits_set_bintable_column (&theader, &ftable, "RA", R, catalog->Nmeasure); 412 gfits_set_bintable_column (&theader, &ftable, "DEC", D, catalog->Nmeasure); 410 413 gfits_set_bintable_column (&theader, &ftable, "MAG_SYS", M, catalog->Nmeasure); 411 414 gfits_set_bintable_column (&theader, &ftable, "MAG_CAL", Mcal, catalog->Nmeasure); … … 425 428 gfits_set_bintable_column (&theader, &ftable, "PHOTCODE", photcode, catalog->Nmeasure); 426 429 427 free ( dR);428 free ( dD);430 free (R ); 431 free (D ); 429 432 free (M ); 430 433 free (Mcal ); … … 454 457 gfits_create_table_header (&theader, "BINTABLE", "AVERAGE"); 455 458 456 gfits_define_bintable_column (&theader, "D", "RA", "RA", "", 1.0, 0.0); 457 gfits_define_bintable_column (&theader, "D", "DEC", "DEC", "", 1.0, 0.0); 458 gfits_define_bintable_column (&theader, "E", "RA_ERR", "RA error", "", 1.0, 0.0); 459 gfits_define_bintable_column (&theader, "E", "DEC_ERR", "DEC error", "", 1.0, 0.0); 460 gfits_define_bintable_column (&theader, "E", "U_RA", "RA*cos(D) proper-motion", "", 1.0, 0.0); 461 gfits_define_bintable_column (&theader, "E", "U_DEC", "DEC proper-motion", "", 1.0, 0.0); 462 gfits_define_bintable_column (&theader, "E", "V_RA_ERR", "RA*cos(D) p-m error", "", 1.0, 0.0); 463 gfits_define_bintable_column (&theader, "E", "V_DEC_ERR", "DEC p-m error", "", 1.0, 0.0); 464 gfits_define_bintable_column (&theader, "E", "PAR", "parallax", "", 1.0, 0.0); 465 gfits_define_bintable_column (&theader, "E", "PAR_ERR", "parallax error", "", 1.0, 0.0); 466 gfits_define_bintable_column (&theader, "E", "CHISQ_POS", "astrometry analysis chisq", "", 1.0, 0.0); 467 gfits_define_bintable_column (&theader, "E", "CHISQ_PM", "astrometry analysis chisq", "", 1.0, 0.0); 468 gfits_define_bintable_column (&theader, "E", "CHISQ_PAP", "astrometry analysis chisq", "", 1.0, 0.0); 469 gfits_define_bintable_column (&theader, "J", "MEAN_EPOCH", "mean epoch (PM-PAR ref)", "", 1.0, 1.0*0x8000); 470 gfits_define_bintable_column (&theader, "J", "TIME_RANGE", "mean epoch (PM-PAR ref)", "", 1.0, 1.0*0x8000); 471 gfits_define_bintable_column (&theader, "E", "STARGAL_SEP", "star/galaxy separator", "", 1.0, 0.0); 472 gfits_define_bintable_column (&theader, "I", "NUMBER_POS", "number of detections used for astrometry", "", 1.0, 1.0*0x80); 473 gfits_define_bintable_column (&theader, "I", "NMEASURE", "number of psf measurements", "", 1.0, 1.0*0x80); 474 gfits_define_bintable_column (&theader, "I", "NMISSING", "number of missings", "", 1.0, 1.0*0x80); 475 gfits_define_bintable_column (&theader, "I", "NEXTEND", "number of extended measurements", "", 1.0, 1.0*0x80); 476 gfits_define_bintable_column (&theader, "J", "OFF_MEASURE", "offset to first psf measurement", "", 1.0, 1.0*0x8000); 477 gfits_define_bintable_column (&theader, "J", "OFF_MISSING", "offset to first missing obs", "", 1.0, 1.0*0x8000); 478 gfits_define_bintable_column (&theader, "J", "OFF_EXTEND", "offset to first extended measurement", "", 1.0, 1.0*0x8000); 479 gfits_define_bintable_column (&theader, "J", "FLAGS", "average object flags (star; ghost; etc)", "", 1.0, 1.0*0x8000); 480 gfits_define_bintable_column (&theader, "J", "PHOTFLAGS_U", "upper bit of 2 bit summary of per-measure photflags", "", 1.0, 1.0*0x8000); 481 gfits_define_bintable_column (&theader, "J", "PHOTFLAGS_L", "lower bit of 2 bit summary of per-measure photflags", "", 1.0, 1.0*0x8000); 482 gfits_define_bintable_column (&theader, "J", "OBJ_ID", "unique ID for object in table", "", 1.0, 1.0*0x8000); 483 gfits_define_bintable_column (&theader, "J", "CAT_ID", "unique ID for table in which object was first realized", "", 1.0, 1.0*0x8000); 484 gfits_define_bintable_column (&theader, "K", "EXT_ID", "external ID for object (eg PSPS objID)", "", 1.0, 1.0*0x80000000); 459 gfits_define_bintable_column (&theader, "D", "RA", "RA", "", 1.0, 0.0); 460 gfits_define_bintable_column (&theader, "D", "DEC", "DEC", "", 1.0, 0.0); 461 gfits_define_bintable_column (&theader, "E", "RA_ERR", "RA error", "", 1.0, 0.0); 462 gfits_define_bintable_column (&theader, "E", "DEC_ERR", "DEC error", "", 1.0, 0.0); 463 gfits_define_bintable_column (&theader, "E", "U_RA", "RA*cos(D) proper-motion", "", 1.0, 0.0); 464 gfits_define_bintable_column (&theader, "E", "U_DEC", "DEC proper-motion", "", 1.0, 0.0); 465 gfits_define_bintable_column (&theader, "E", "V_RA_ERR", "RA*cos(D) p-m error", "", 1.0, 0.0); 466 gfits_define_bintable_column (&theader, "E", "V_DEC_ERR", "DEC p-m error", "", 1.0, 0.0); 467 gfits_define_bintable_column (&theader, "E", "PAR", "parallax", "", 1.0, 0.0); 468 gfits_define_bintable_column (&theader, "E", "PAR_ERR", "parallax error", "", 1.0, 0.0); 469 gfits_define_bintable_column (&theader, "E", "CHISQ_POS", "astrometry analysis chisq", "", 1.0, 0.0); 470 gfits_define_bintable_column (&theader, "E", "CHISQ_PM", "astrometry analysis chisq", "", 1.0, 0.0); 471 gfits_define_bintable_column (&theader, "E", "CHISQ_PAP", "astrometry analysis chisq", "", 1.0, 0.0); 472 gfits_define_bintable_column (&theader, "J", "MEAN_EPOCH", "mean epoch (PM-PAR ref)", "", 1.0, 0.00); 473 gfits_define_bintable_column (&theader, "J", "TIME_RANGE", "mean epoch (PM-PAR ref)", "", 1.0, 0.00); 474 gfits_define_bintable_column (&theader, "E", "STARGAL_SEP", "star/galaxy separator", "", 1.0, 0.0); 475 gfits_define_bintable_column (&theader, "I", "NUMBER_POS", "number of detections used for astrometry", "", 1.0, 0.0); 476 gfits_define_bintable_column (&theader, "I", "NMEASURE", "number of psf measurements", "", 1.0, 0.0); 477 gfits_define_bintable_column (&theader, "I", "NMISSING", "number of missings", "", 1.0, 0.0); 478 gfits_define_bintable_column (&theader, "I", "NEXTEND", "number of extended measurements", "", 1.0, 0.0); 479 gfits_define_bintable_column (&theader, "J", "OFF_MEASURE", "offset to first psf measurement", "", 1.0, 0.0); 480 gfits_define_bintable_column (&theader, "J", "OFF_MISSING", "offset to first missing obs", "", 1.0, 0.0); 481 gfits_define_bintable_column (&theader, "E", "REF_COLOR_BLUE", "reference color", "", 1.0, 0.0); 482 gfits_define_bintable_column (&theader, "E", "REF_COLOR_RED", "reference color", "", 1.0, 0.0); 483 gfits_define_bintable_column (&theader, "J", "FLAGS", "average object flags (star; ghost; etc)", "", 1.0, 0.0); 484 gfits_define_bintable_column (&theader, "J", "PHOTFLAGS_U", "upper bit of 2 bit summary of per-measure photflags", "", 1.0, 0.0); 485 gfits_define_bintable_column (&theader, "J", "PHOTFLAGS_L", "lower bit of 2 bit summary of per-measure photflags", "", 1.0, 0.0); 486 gfits_define_bintable_column (&theader, "J", "OBJ_ID", "unique ID for object in table", "", 1.0, 0.0); 487 gfits_define_bintable_column (&theader, "J", "CAT_ID", "unique ID for table in which object was first realized", "", 1.0, 0.0); 488 gfits_define_bintable_column (&theader, "K", "EXT_ID", "external ID for object (eg PSPS objID)", "", 1.0, 0.0); 485 489 486 490 // generate the output array that carries the data … … 510 514 int *measureOffset ; ALLOCATE (measureOffset , int , catalog->Naverage); 511 515 int *missingOffset ; ALLOCATE (missingOffset , int , catalog->Naverage); 512 int *extendOffset ; ALLOCATE (extendOffset , int , catalog->Naverage); 516 float *refColorBlue ; ALLOCATE (refColorBlue , float , catalog->Naverage); 517 float *refColorRed ; ALLOCATE (refColorRed , float , catalog->Naverage); 513 518 int *flags ; ALLOCATE (flags , int , catalog->Naverage); 514 519 int *photFlagsUpper; ALLOCATE (photFlagsUpper, int , catalog->Naverage); … … 543 548 measureOffset[i] = average[i].measureOffset ; 544 549 missingOffset[i] = average[i].missingOffset ; 545 extendOffset[i] = average[i].extendOffset ; 550 refColorBlue[i] = average[i].refColorBlue ; 551 refColorRed[i] = average[i].refColorRed ; 546 552 flags[i] = average[i].flags ; 547 553 photFlagsUpper[i] = average[i].photFlagsUpper ; … … 553 559 554 560 // add the columns to the output array 555 gfits_set_bintable_column (&theader, &ftable, "RA", R, catalog->Naverage); 556 gfits_set_bintable_column (&theader, &ftable, "DEC", D, catalog->Naverage); 557 gfits_set_bintable_column (&theader, &ftable, "RA_ERR", dR, catalog->Naverage); 558 gfits_set_bintable_column (&theader, &ftable, "DEC_ERR", dD, catalog->Naverage); 559 gfits_set_bintable_column (&theader, &ftable, "U_RA", uR, catalog->Naverage); 560 gfits_set_bintable_column (&theader, &ftable, "U_DEC", uD, catalog->Naverage); 561 gfits_set_bintable_column (&theader, &ftable, "V_RA_ERR", duR, catalog->Naverage); 562 gfits_set_bintable_column (&theader, &ftable, "V_DEC_ERR", duD, catalog->Naverage); 563 gfits_set_bintable_column (&theader, &ftable, "PAR", P, catalog->Naverage); 564 gfits_set_bintable_column (&theader, &ftable, "PAR_ERR", dP, catalog->Naverage); 565 gfits_set_bintable_column (&theader, &ftable, "CHISQ_POS", ChiSqAve, catalog->Naverage); 566 gfits_set_bintable_column (&theader, &ftable, "CHISQ_PM", ChiSqPM, catalog->Naverage); 567 gfits_set_bintable_column (&theader, &ftable, "CHISQ_PAP", ChiSqPar, catalog->Naverage); 568 gfits_set_bintable_column (&theader, &ftable, "MEAN_EPOCH", Tmean, catalog->Naverage); 569 gfits_set_bintable_column (&theader, &ftable, "TIME_RANGE", Trange, catalog->Naverage); 570 gfits_set_bintable_column (&theader, &ftable, "STARGAL_SEP", stargal, catalog->Naverage); 571 gfits_set_bintable_column (&theader, &ftable, "NUMBER_POS", Npos, catalog->Naverage); 572 gfits_set_bintable_column (&theader, &ftable, "NMEASURE", Nmeasure, catalog->Naverage); 573 gfits_set_bintable_column (&theader, &ftable, "NMISSING", Nmissing, catalog->Naverage); 574 gfits_set_bintable_column (&theader, &ftable, "NEXTEND", Nextend, catalog->Naverage); 575 gfits_set_bintable_column (&theader, &ftable, "OFF_MEASURE", measureOffset, catalog->Naverage); 576 gfits_set_bintable_column (&theader, &ftable, "OFF_MISSING", missingOffset, catalog->Naverage); 577 gfits_set_bintable_column (&theader, &ftable, "OFF_EXTEND", extendOffset, catalog->Naverage); 578 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags, catalog->Naverage); 579 gfits_set_bintable_column (&theader, &ftable, "PHOTFLAGS_U", photFlagsUpper, catalog->Naverage); 580 gfits_set_bintable_column (&theader, &ftable, "PHOTFLAGS_L", photFlagsLower, catalog->Naverage); 581 gfits_set_bintable_column (&theader, &ftable, "OBJ_ID", objID, catalog->Naverage); 582 gfits_set_bintable_column (&theader, &ftable, "CAT_ID", catID, catalog->Naverage); 583 gfits_set_bintable_column (&theader, &ftable, "EXT_ID", extID, catalog->Naverage); 561 gfits_set_bintable_column (&theader, &ftable, "RA", R, catalog->Naverage); 562 gfits_set_bintable_column (&theader, &ftable, "DEC", D, catalog->Naverage); 563 gfits_set_bintable_column (&theader, &ftable, "RA_ERR", dR, catalog->Naverage); 564 gfits_set_bintable_column (&theader, &ftable, "DEC_ERR", dD, catalog->Naverage); 565 gfits_set_bintable_column (&theader, &ftable, "U_RA", uR, catalog->Naverage); 566 gfits_set_bintable_column (&theader, &ftable, "U_DEC", uD, catalog->Naverage); 567 gfits_set_bintable_column (&theader, &ftable, "V_RA_ERR", duR, catalog->Naverage); 568 gfits_set_bintable_column (&theader, &ftable, "V_DEC_ERR", duD, catalog->Naverage); 569 gfits_set_bintable_column (&theader, &ftable, "PAR", P, catalog->Naverage); 570 gfits_set_bintable_column (&theader, &ftable, "PAR_ERR", dP, catalog->Naverage); 571 gfits_set_bintable_column (&theader, &ftable, "CHISQ_POS", ChiSqAve, catalog->Naverage); 572 gfits_set_bintable_column (&theader, &ftable, "CHISQ_PM", ChiSqPM, catalog->Naverage); 573 gfits_set_bintable_column (&theader, &ftable, "CHISQ_PAP", ChiSqPar, catalog->Naverage); 574 gfits_set_bintable_column (&theader, &ftable, "MEAN_EPOCH", Tmean, catalog->Naverage); 575 gfits_set_bintable_column (&theader, &ftable, "TIME_RANGE", Trange, catalog->Naverage); 576 gfits_set_bintable_column (&theader, &ftable, "STARGAL_SEP", stargal, catalog->Naverage); 577 gfits_set_bintable_column (&theader, &ftable, "NUMBER_POS", Npos, catalog->Naverage); 578 gfits_set_bintable_column (&theader, &ftable, "NMEASURE", Nmeasure, catalog->Naverage); 579 gfits_set_bintable_column (&theader, &ftable, "NMISSING", Nmissing, catalog->Naverage); 580 gfits_set_bintable_column (&theader, &ftable, "NEXTEND", Nextend, catalog->Naverage); 581 gfits_set_bintable_column (&theader, &ftable, "OFF_MEASURE", measureOffset, catalog->Naverage); 582 gfits_set_bintable_column (&theader, &ftable, "OFF_MISSING", missingOffset, catalog->Naverage); 583 gfits_set_bintable_column (&theader, &ftable, "REF_COLOR_BLUE", refColorBlue, catalog->Naverage); 584 gfits_set_bintable_column (&theader, &ftable, "REF_COLOR_RED", refColorRed, catalog->Naverage); 585 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags, catalog->Naverage); 586 gfits_set_bintable_column (&theader, &ftable, "PHOTFLAGS_U", photFlagsUpper, catalog->Naverage); 587 gfits_set_bintable_column (&theader, &ftable, "PHOTFLAGS_L", photFlagsLower, catalog->Naverage); 588 gfits_set_bintable_column (&theader, &ftable, "OBJ_ID", objID, catalog->Naverage); 589 gfits_set_bintable_column (&theader, &ftable, "CAT_ID", catID, catalog->Naverage); 590 gfits_set_bintable_column (&theader, &ftable, "EXT_ID", extID, catalog->Naverage); 584 591 585 592 free (R); … … 605 612 free (measureOffset); 606 613 free (missingOffset); 607 free (extendOffset); 614 free (refColorBlue); 615 free (refColorRed); 608 616 free (flags); 609 617 free (photFlagsUpper); … … 629 637 gfits_define_bintable_column (&theader, "I", "NCODE", "magnitude (err)", NULL, 1.0, 0.0); 630 638 gfits_define_bintable_column (&theader, "I", "NUSED", "airmass", NULL, 1.0, 0.0); 631 gfits_define_bintable_column (&theader, " I", "MAG_20", "ccd x coord", "pix", 1.0, 0.0);632 gfits_define_bintable_column (&theader, " I", "MAG_80", "ccd y coord", "pix", 1.0, 0.0);639 gfits_define_bintable_column (&theader, "E", "MAG_MIN", "ccd x coord", "pix", 1.0, 0.0); 640 gfits_define_bintable_column (&theader, "E", "MAG_MAX", "ccd y coord", "pix", 1.0, 0.0); 633 641 634 642 // generate the output array that carries the data … … 642 650 float *M ; ALLOCATE (M , float, Nsec); 643 651 float *dM ; ALLOCATE (dM , float, Nsec); 644 float * Xm ; ALLOCATE (Xm, float, Nsec);652 float *Mchisq ; ALLOCATE (Mchisq , float, Nsec); 645 653 int *flags ; ALLOCATE (flags , int, Nsec); 646 654 short *Ncode ; ALLOCATE (Ncode , short, Nsec); 647 655 short *Nused ; ALLOCATE (Nused , short, Nsec); 648 short *M_20 ; ALLOCATE (M_20 , short, Nsec);649 short *M_80 ; ALLOCATE (M_80 , short, Nsec);656 float *Mmin ; ALLOCATE (Mmin , float, Nsec); 657 float *Mmax ; ALLOCATE (Mmax , float, Nsec); 650 658 651 659 // assign the storage arrays 652 660 SecFilt *secfilt = catalog->secfilt; 653 661 for (i = 0; i < Nsec; i++) { 654 M [i] = secfilt[i]. M ;655 dM [i] = secfilt[i]. dM ;656 Xm [i] = secfilt[i]. Xm;657 flags [i] = secfilt[i]. flags ;658 Ncode [i] = secfilt[i]. Ncode ;659 Nused [i] = secfilt[i]. Nused ;660 M _20 [i] = secfilt[i]. M_20;661 M _80 [i] = secfilt[i]. M_80;662 M [i] = secfilt[i].M ; 663 dM [i] = secfilt[i].dM ; 664 Mchisq[i] = secfilt[i].Mchisq ; 665 flags [i] = secfilt[i].flags ; 666 Ncode [i] = secfilt[i].Ncode ; 667 Nused [i] = secfilt[i].Nused ; 668 Mmin [i] = secfilt[i].Mmin ; 669 Mmax [i] = secfilt[i].Mmax ; 662 670 } 663 671 664 672 // add the columns to the output array 665 gfits_set_bintable_column (&theader, &ftable, "MAG", M , Nsec);666 gfits_set_bintable_column (&theader, &ftable, "MAG_ERR", dM , Nsec);667 gfits_set_bintable_column (&theader, &ftable, "MAG_CHI", Xm, Nsec);668 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags , Nsec);669 gfits_set_bintable_column (&theader, &ftable, "NCODE", Ncode , Nsec);670 gfits_set_bintable_column (&theader, &ftable, "NUSED", Nused , Nsec);671 gfits_set_bintable_column (&theader, &ftable, "MAG_ 20", M_20, Nsec);672 gfits_set_bintable_column (&theader, &ftable, "MAG_ 80", M_80, Nsec);673 gfits_set_bintable_column (&theader, &ftable, "MAG", M , Nsec); 674 gfits_set_bintable_column (&theader, &ftable, "MAG_ERR", dM , Nsec); 675 gfits_set_bintable_column (&theader, &ftable, "MAG_CHI", Mchisq, Nsec); 676 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags , Nsec); 677 gfits_set_bintable_column (&theader, &ftable, "NCODE", Ncode , Nsec); 678 gfits_set_bintable_column (&theader, &ftable, "NUSED", Nused , Nsec); 679 gfits_set_bintable_column (&theader, &ftable, "MAG_MIN", Mmin , Nsec); 680 gfits_set_bintable_column (&theader, &ftable, "MAG_MAX", Mmax , Nsec); 673 681 674 682 free (M ); 675 683 free (dM ); 676 free ( Xm);684 free (Mchisq ); 677 685 free (flags ); 678 686 free (Ncode ); 679 687 free (Nused ); 680 free (M _20);681 free (M _80);688 free (Mmin ); 689 free (Mmax ); 682 690 683 691 gfits_fwrite_Theader (f, &theader); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/FitChip.c
r33652 r37403 4 4 int FitChip (StarData *raw, StarData *ref, int Nmatch, Image *image) { 5 5 6 int i, NstatFull, Nstat, Niter ;6 int i, NstatFull, Nstat, Niter, Nkeep; 7 7 float dLsig, dMsig, dRsig; 8 8 float dLsigFull, dMsigFull, dRsigFull; … … 24 24 25 25 // measure the scatter distribution (use only the bright end detections) 26 Nkeep = 0; 26 27 for (i = 0; i < Nmatch; i++) { 27 28 if (raw[i].mask) continue; … … 42 43 continue; 43 44 } 44 } 45 Nkeep ++; 46 } 47 48 // I'm rejecting some points from the fit above; I count the remainders and actually 49 // use that count to set order_use below 45 50 46 51 // figures to assess the fitting process: … … 50 55 relastroVisualPlotChipFit(raw, ref, dRmax, Nmatch); 51 56 52 // fit the requested order polynomial 53 if (CHIPORDER > 0) { 54 int Ndof_min = 3; 55 int order_max = 0.5*(sqrt(4*Nmatch - 4*Ndof_min + 1) - 3); 56 int order_use = MIN (CHIPORDER, order_max); 57 if (order_use < 1) { 58 if (VERBOSE2) fprintf (stderr, "insufficient measurements (%d) for linear fit\n", Nmatch); 59 image[0].flags |= ID_IMAGE_ASTROM_FEW; 60 return FALSE; 61 } 62 image[0].coords.Npolyterms = order_use; 63 } 57 // set the maximum order for the polynomial (based on number of stars kept above) 58 int order_use = 0; 59 if (Nkeep > 5) order_use = 1; // 4 stars per polynomial term (per dimension) 60 if (Nkeep > 30) order_use = 2; // 5 stars per polynomial term (per dimension) 61 if (Nkeep > 60) order_use = 3; // 6 stars per polynomial term (per dimension) 62 if (order_use < 1) { 63 if (VERBOSE2) fprintf (stderr, "insufficient measurements (%d) for linear fit\n", Nkeep); 64 image[0].flags |= ID_IMAGE_ASTROM_FEW; 65 return FALSE; 66 } 67 image[0].coords.Npolyterms = order_use; 64 68 65 69 if (fit) fit_free (fit); … … 71 75 fit_add (fit, raw[i].X, raw[i].Y, ref[i].L, ref[i].M, raw[i].dPos); 72 76 } 73 74 # if (0)75 // check if the fit has enough data points for the polynomial order76 skip = FALSE;77 switch (image[0].coords.Npolyterms) {78 case 0:79 case 1:80 skip = (fit[0].Npts < 8);81 break;82 case 2:83 skip = (fit[0].Npts < 11);84 break;85 case 3:86 skip = (fit[0].Npts < 15);87 break;88 default:89 fprintf (stderr, "invalid chip order %d\n", image[0].coords.Npolyterms);90 skip = TRUE;91 }92 if (skip) {93 if (VERBOSE2) fprintf (stderr, "insufficient measurements (%d) for requested order (%d)\n", fit[0].Npts, image[0].coords.Npolyterms);94 fit_free (fit);95 image[0].flags |= ID_IMAGE_ASTROM_FEW;96 return FALSE;97 }98 # endif99 77 100 78 // measure the fit, update the coords & object coordinates … … 134 112 } 135 113 114 int Ncolor; 115 float colorMedian; 116 float *colorList = NULL; 117 ALLOCATE (colorList, float, Nmatch); 118 119 // calculate the median blue color 120 Ncolor = 0; 121 for (i = 0; i < Nmatch; i++) { 122 if (!raw[i].mask) continue; 123 if (isnan(ref[i].ColorBlue)) continue; 124 colorList[Ncolor] = ref[i].ColorBlue; 125 Ncolor ++; 126 } 127 fsort (colorList, Ncolor); 128 colorMedian = (Ncolor > 0) ? colorList[(int)(0.5*Ncolor)] : NAN; 129 image[0].refColorBlue = colorMedian; 130 131 // calculate the median red color 132 Ncolor = 0; 133 for (i = 0; i < Nmatch; i++) { 134 if (!raw[i].mask) continue; 135 if (isnan(ref[i].ColorRed)) continue; 136 colorList[Ncolor] = ref[i].ColorRed; 137 Ncolor ++; 138 } 139 fsort (colorList, Ncolor); 140 colorMedian = (Ncolor > 0) ? colorList[(int)(0.5*Ncolor)] : NAN; 141 image[0].refColorRed = colorMedian; 142 143 free (colorList); 144 136 145 GetScatterRawRef(&dLsigFull, &dMsigFull, &dRsigFull, &NstatFull, raw, ref, Nmatch, SIGMA_LIM); 137 146 GetScatterRawRef(&dLsig, &dMsig, &dRsig, &Nstat, raw, ref, Nmatch, IMFIT_SYS_SIGMA_LIM); … … 151 160 image[0].dYpixSys = dMsig; 152 161 image[0].nFitAstrom = fit[0].Npts; 162 163 // fprintf (stderr, "%s %6.3f %4d %4d\n", image[0].name, image[0].refColor, Ncolor, image[0].nFitAstrom); 153 164 154 165 if (fit) fit_free (fit); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/GetAstromError.c
r33652 r37403 30 30 31 31 code = GetPhotcodebyCode (measure[0].photcode); 32 if (!code) return NAN; 32 33 33 34 // do not raise an exception, just send back the result … … 72 73 73 74 code = GetPhotcodebyCode (measure[0].photcode); 75 if (!code) return NAN; 74 76 75 77 // do not raise an exception, just send back the result -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/ImageOps.c
r36680 r37403 39 39 // N_onImage was 'Nlist' 40 40 // N_ONIMAGE was 'NLIST' 41 42 int areImagesLoaded () { 43 44 if (image) return TRUE; 45 return FALSE; 46 } 47 48 int areImagesMatched () { 49 50 if (MeasureToImage) return TRUE; 51 return FALSE; 52 } 41 53 42 54 Image *getimages (off_t *N, off_t **line_number) { … … 333 345 */ 334 346 347 float getColorBlue (off_t meas, int cat) { 348 349 off_t i; 350 351 i = MeasureToImage[cat][meas]; 352 if (i == -1) return (NAN); 353 return (image[i].refColorBlue); 354 } 355 356 float getColorRed (off_t meas, int cat) { 357 358 off_t i; 359 360 i = MeasureToImage[cat][meas]; 361 if (i == -1) return (NAN); 362 return (image[i].refColorRed); 363 } 364 335 365 void plot_images () { 336 366 … … 385 415 for (j = 0; j < average[0].Nmeasure; j++) { 386 416 off = average[0].measureOffset + j; 387 fprintf (stderr, " dR, dD, mag, dMag: %f, %f, %f, %f\n", measure[off].dR, measure[off].dD, measure[off].M, measure[off].dM);417 fprintf (stderr, "R, D, mag, dMag: %lf, %lf, %f, %f\n", measure[off].R, measure[off].D, measure[off].M, measure[off].dM); 388 418 } 389 419 return; … … 468 498 } 469 499 500 X = measure[0].Xccd; 501 Y = measure[0].Yccd; 470 502 if (USE_FIXED_PIXCOORDS) { 471 X = isfinite(measure[0].Xfix) ? measure[0].Xfix : measure[0].Xccd; 472 Y = isfinite(measure[0].Yfix) ? measure[0].Yfix : measure[0].Yccd; 473 } else { 474 X = measure[0].Xccd; 475 Y = measure[0].Yccd; 503 if (isfinite(measure[0].Xfix) && isfinite(measure[0].Yfix)) { 504 float dX = measure[0].Xfix - measure[0].Xccd; 505 float dY = measure[0].Yfix - measure[0].Yccd; 506 if (hypot(dX,dY) < 2.0) { 507 X = measure[0].Xfix; 508 Y = measure[0].Yfix; 509 } 510 } 476 511 } 477 512 n = measure[0].averef; … … 528 563 529 564 // complain if the new location is far from the old location 530 if (fabs(csdec*(measure[0]. dR - dR)) > DPOS_MAX_ASEC) {565 if (fabs(csdec*(measure[0].R - R)) > DPOS_MAX_ASEC) { 531 566 NoffRAori ++; 532 567 if (VERBOSE2) { 533 fprintf (stderr, "measurement moves far from original location (R): %f %f (%f %f %f %f)\n", average[0].R, average[0].D, measure[0]. dR, dR, csdec*(measure[0].dR - dR), dD);568 fprintf (stderr, "measurement moves far from original location (R): %f %f (%f %f %f %f)\n", average[0].R, average[0].D, measure[0].R, dR, csdec*(measure[0].R - R), dD); 534 569 dump_measures (&average[0], catalog[c].measure); 535 570 } 536 571 // abort(); 537 572 } 538 if (fabs(measure[0]. dD - dD) > DPOS_MAX_ASEC) {573 if (fabs(measure[0].D - D) > DPOS_MAX_ASEC) { 539 574 NoffDECori ++; 540 575 if (VERBOSE2) { 541 fprintf (stderr, "measurement moves far from original location (D): %f %f (%f %f %f)\n", average[0].R, average[0].D, dR, measure[0]. dD, dD);576 fprintf (stderr, "measurement moves far from original location (D): %f %f (%f %f %f)\n", average[0].R, average[0].D, dR, measure[0].D, dD); 542 577 dump_measures (&average[0], catalog[c].measure); 543 578 } // abort(); 544 579 } 545 580 546 dPos += SQ(measure[0].dR - dR) + SQ(measure[0].dD - dD); 581 // XXX NOTE : apply csdec: 582 dPos += SQ(measure[0].R - R) + SQ(measure[0].D - D); 547 583 nPos ++; 548 584 549 measure[0]. dR = dR;550 measure[0]. dD = dD;551 measureT[0]. dR = dR;552 measureT[0]. dD = dD;585 measure[0].R = R; 586 measure[0].D = D; 587 measureT[0].R = R; 588 measureT[0].D = D; 553 589 554 590 // set the systematic error for this image: … … 560 596 561 597 int Noff = NoffRAave + NoffDECave + NoffRAori + NoffDECori; 562 if (VERBOSE && (Noff > 0)) fprintf (stderr, "Noff ave RA %d, Noff ave DEC %d, Noff ori RA %d, Noff ori DEC %d\n", NoffRAave, NoffDECave, NoffRAori, NoffDECori);598 if (VERBOSE2 && (Noff > 0)) fprintf (stderr, "Noff ave RA %d, Noff ave DEC %d, Noff ori RA %d, Noff ori DEC %d\n", NoffRAave, NoffDECave, NoffRAori, NoffDECori); 563 599 saveOffsets (dPos, nPos, im); 564 600 … … 575 611 576 612 off_t i, m, c, n; 577 double X, Y, L, M, P, Q, R, D , dR, dD;613 double X, Y, L, M, P, Q, R, D; 578 614 579 615 Mosaic *mosaic; … … 609 645 Measure *measure = &catalog[c].measure[m]; 610 646 647 X = measure[0].Xccd; 648 Y = measure[0].Yccd; 611 649 if (USE_FIXED_PIXCOORDS) { 612 X = isfinite(measure[0].Xfix) ? measure[0].Xfix : measure[0].Xccd; 613 Y = isfinite(measure[0].Yfix) ? measure[0].Yfix : measure[0].Yccd; 614 } else { 615 X = measure[0].Xccd; 616 Y = measure[0].Yccd; 650 if (isfinite(measure[0].Xfix) && isfinite(measure[0].Yfix)) { 651 float dX = measure[0].Xfix - measure[0].Xccd; 652 float dY = measure[0].Yfix - measure[0].Yccd; 653 if (hypot(dX,dY) < 2.0) { 654 X = measure[0].Xfix; 655 Y = measure[0].Yfix; 656 } 657 } 617 658 } 618 659 n = measure[0].averef; 619 660 620 dR = dD = 0.0;621 661 if (moscoords == NULL) { 622 662 // this is a Simple image (not a mosaic) … … 629 669 LM_to_RD (&R, &D, P, Q, moscoords); 630 670 } 631 632 measure[0].dR = dR; 633 measure[0].dD = dD; 634 635 if (measure[0].dR > +180.0*3600.0) { 671 measure[0].R = R; 672 measure[0].D = D; 673 674 float dRoff = dvoOffsetR(measure, &catalog[c].average[n]); 675 676 if (dRoff > +180.0*3600.0) { 636 677 // average on high end of boundary, move star up 637 R += 360.0; 638 measure[0].dR = 3600.0*(catalog[c].average[n].R - R); 639 } 640 if (measure[0].dR < -180.0*3600.0) { 641 // average on low end of boundary, move star down 642 R -= 360.0; 643 measure[0].dR = 3600.0*(catalog[c].average[n].R - R); 678 measure[0].R += 360.0; 679 dRoff -= 360.0*3600.0; 680 } 681 if (dRoff < -180.0*3600.0) { 682 measure[0].R -= 360.0; 683 dRoff += 360.0*3600.0; 644 684 } 645 685 } … … 679 719 680 720 /* apply the current image transformation or use the current value of R+dR, D+dD? */ 721 raw[i].X = measure[0].Xccd; 722 raw[i].Y = measure[0].Yccd; 681 723 if (USE_FIXED_PIXCOORDS) { 682 raw[i].X = isfinite(measure[0].Xfix) ? measure[0].Xfix : measure[0].Xccd; 683 raw[i].Y = isfinite(measure[0].Yfix) ? measure[0].Yfix : measure[0].Yccd; 684 } else { 685 raw[i].X = measure[0].Xccd; 686 raw[i].Y = measure[0].Yccd; 687 } 688 724 if (isfinite(measure[0].Xfix) && isfinite(measure[0].Yfix)) { 725 float dX = measure[0].Xfix - measure[0].Xccd; 726 float dY = measure[0].Yfix - measure[0].Yccd; 727 if (hypot(dX,dY) < 2.0) { 728 raw[i].X = measure[0].Xfix; 729 raw[i].Y = measure[0].Yfix; 730 } 731 } 732 } 689 733 raw[i].Mag = measure[0].M; 690 734 raw[i].dMag = measure[0].dM; … … 699 743 raw[i].mask |= MARK_TOO_FEW_MEAS; 700 744 } 701 if (!finite(measure[0]. dR) || !finite(measure[0].dD)) {745 if (!finite(measure[0].R) || !finite(measure[0].D)) { 702 746 raw[i].mask |= MARK_NAN_POS_ERROR; 703 747 } … … 738 782 StarData *ref; 739 783 784 int Nsecfilt = GetPhotcodeNsecfilt(); 785 740 786 mosaic = NULL; 741 787 moscoords = NULL; … … 765 811 ref[i].dMag = measure[0].dM; 766 812 ref[i].dPos = GetAstromErrorTiny (&measure[0], ERROR_MODE_POS); 813 814 if ((DCR_BLUE_NSEC_POS >= 0) && (DCR_BLUE_NSEC_NEG >= -1)) { 815 ref[i].ColorBlue = catalog[c].secfilt[n*Nsecfilt + DCR_BLUE_NSEC_POS].M - catalog[c].secfilt[n*Nsecfilt + DCR_BLUE_NSEC_NEG].M; 816 } 817 if ((DCR_RED_NSEC_POS >= 0) && (DCR_RED_NSEC_NEG >= -1)) { 818 ref[i].ColorRed = catalog[c].secfilt[n*Nsecfilt + DCR_RED_NSEC_POS].M - catalog[c].secfilt[n*Nsecfilt + DCR_RED_NSEC_NEG].M; 819 } 767 820 768 821 ref[i].mask = FALSE; … … 839 892 // skip measurements based on user selected criteria 840 893 if (!MeasFilterTest(&measure[k], FALSE)) continue; 841 R[N] = measure[k]. dR;842 D[N] = measure[k]. dD;894 R[N] = measure[k].R; 895 D[N] = measure[k].D; 843 896 dR[N] = GetAstromError (&measure[k], ERROR_MODE_RA); 844 897 dD[N] = GetAstromError (&measure[k], ERROR_MODE_DEC); … … 859 912 N = 0; 860 913 for (k = 0; k < catalog[0].average[j].Nmeasure; k++) { 861 // reset flag on each invocation914 // reset flag on each invocation 862 915 measure[k].dbFlags &= ~ID_MEAS_POOR_ASTROM; 863 916 … … 865 918 if (!MeasFilterTest(&measure[k], FALSE)) continue; 866 919 867 x = measure[k]. dR - statsR.median;868 y = measure[k]. dD - statsD.median;920 x = measure[k].R - statsR.median; 921 y = measure[k].D - statsD.median; 869 922 theta = atan2(y,x); 870 923 if ((x*x + y*y) > (SQR(statsR.sigma * Ns * cos(theta)) + … … 898 951 double *R, *D, *dR, *dD, *d2; 899 952 StatType statsR, statsD; 953 954 // XXX we are not going to use this for now 955 return; 900 956 901 957 Nsecfilt = GetPhotcodeNsecfilt(); … … 937 993 // skip measurements based on user selected criteria 938 994 if (!MeasFilterTest(&measure[k], FALSE)) continue; 939 R[N] = measure[k]. dR;940 D[N] = measure[k]. dD;995 R[N] = measure[k].R; 996 D[N] = measure[k].D; 941 997 dR[N] = GetAstromError(&measure[k], ERROR_MODE_RA); 942 998 dD[N] = GetAstromError(&measure[k], ERROR_MODE_DEC); … … 958 1014 // skip bad measurements 959 1015 if (!MeasFilterTest(&measure[k], FALSE)) continue; 960 x = measure[k]. dR - statsR.median;961 y = measure[k]. dD - statsD.median;1016 x = measure[k].R - statsR.median; 1017 y = measure[k].D - statsD.median; 962 1018 theta = atan2(y,x); 963 1019 d2[N] = (x*x + y*y) / (SQR(statsR.sigma * Ns * cos(theta)) + … … 974 1030 for (k = 0; k < N; k++) { 975 1031 off_t ind = (off_t) index[k]; 976 R[k] = measure[ind]. dR;977 D[k] = measure[ind]. dD;1032 R[k] = measure[ind].R; 1033 D[k] = measure[ind].D; 978 1034 dR[k] = GetAstromError(&measure[ind], ERROR_MODE_RA); 979 1035 dD[k] = GetAstromError(&measure[ind], ERROR_MODE_DEC); … … 989 1045 //skip bad measurements 990 1046 if (!MeasFilterTest(&measure[k], FALSE)) continue; 991 x = measure[k]. dR - statsR.median;992 y = measure[k]. dD - statsD.median;1047 x = measure[k].R - statsR.median; 1048 y = measure[k].D - statsD.median; 993 1049 theta = atan2(y,x); 994 1050 d2[N] = (x*x + y*y) / (SQR(statsR.sigma * Ns * cos(theta)) + … … 1024 1080 float mag; 1025 1081 1026 if (!finite(measure[0]. dR) || !finite(measure[0].dD)) return FALSE;1082 if (!finite(measure[0].R) || !finite(measure[0].D)) return FALSE; 1027 1083 if (!finite(measure[0].M)) return FALSE; //XXX is this necessary for all relastro tasks? 1028 1084 if (!finite(measure[0].dM)) return FALSE; //XXX is this necessary for all relastro tasks? … … 1063 1119 } else { 1064 1120 code = GetPhotcodebyCode (measure[0].photcode); 1121 if (!code) return FALSE; 1065 1122 mask = code[0].astromBadMask; 1066 1123 } … … 1075 1132 /* select measurements by mag limit */ 1076 1133 if (ImagSelect) { 1077 mag = PhotInstTiny (measure );1134 mag = PhotInstTiny (measure, MAG_CLASS_PSF); 1078 1135 if (mag < ImagMin || mag > ImagMax) return FALSE; 1079 1136 } … … 1090 1147 float mag; 1091 1148 1092 if (!finite(measure[0]. dR) || !finite(measure[0].dD)) return FALSE;1149 if (!finite(measure[0].R) || !finite(measure[0].D)) return FALSE; 1093 1150 if (!finite(measure[0].M)) return FALSE; //XXX is this necessary for all relastro tasks? 1094 1151 if (!finite(measure[0].dM)) return FALSE; //XXX is this necessary for all relastro tasks? … … 1129 1186 } else { 1130 1187 code = GetPhotcodebyCode (measure[0].photcode); 1188 if (!code) return FALSE; 1131 1189 mask = code[0].astromBadMask; 1132 1190 } … … 1141 1199 /* select measurements by mag limit */ 1142 1200 if (ImagSelect) { 1143 mag = PhotInst (measure );1201 mag = PhotInst (measure, MAG_CLASS_PSF); 1144 1202 if (mag < ImagMin || mag > ImagMax) return FALSE; 1145 1203 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/MeanPosIO.c
r36680 r37403 111 111 gfits_define_bintable_column (&theader, "D", "RA", "mean position, ra", "degrees", 1.0, 0.0); 112 112 gfits_define_bintable_column (&theader, "D", "DEC", "mean position, dec", "degrees", 1.0, 0.0); 113 gfits_define_bintable_column (&theader, "J", "OBJ_ID", "object ID", NULL, 1.0, 1.0*0x8000);114 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog ID", NULL, 1.0, 1.0*0x8000);113 gfits_define_bintable_column (&theader, "J", "OBJ_ID", "object ID", NULL, 1.0, FT_BZERO_INT32); 114 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog ID", NULL, 1.0, FT_BZERO_INT32); 115 115 116 116 // generate the output array that carries the data -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/MosaicOps.c
r36680 r37403 97 97 98 98 /* a new mosaic, define ranges */ 99 mosaic[Nmosaic].start = start;100 mosaic[Nmosaic].stop = stop;101 mosaic[Nmosaic].Mcal = 0.0;102 mosaic[Nmosaic].dMcal = 0.0;103 mosaic[Nmosaic].Xm = 0.0;104 mosaic[Nmosaic].flags = image[i].flags;105 mosaic[Nmosaic].secz = image[i].secz;106 mosaic[Nmosaic].coords = image[i].coords;99 mosaic[Nmosaic].start = start; 100 mosaic[Nmosaic].stop = stop; 101 mosaic[Nmosaic].Mcal = 0.0; 102 mosaic[Nmosaic].dMcal = 0.0; 103 mosaic[Nmosaic].Xm = 0.0; 104 mosaic[Nmosaic].flags = image[i].flags; 105 mosaic[Nmosaic].secz = image[i].secz; 106 mosaic[Nmosaic].coords = image[i].coords; 107 107 mosaic[Nmosaic].myImage = i; 108 108 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/ParFactor.c
r33652 r37403 63 63 double jd, lambda, beta, epsilon, Radius; 64 64 65 /* given a time T in UNIX seconds, determine the solar longitude S */ 65 /* given a Time relative to Tmean, Tmean in years since J2000, determine the solar 66 longitude S */ 66 67 67 68 // jd = ohana_sec_to_jd (365.25*86400.0*(Time + Tmean)); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/Shutdown.c
r12332 r37403 23 23 SetProtect (TRUE); 24 24 gfits_db_close (db); 25 fprintf (stderr, "ERROR: addstarhalted\n");25 fprintf (stderr, "ERROR: relastro halted\n"); 26 26 exit (1); 27 27 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/UpdateObjectOffsets.c
r35763 r37403 126 126 table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, MIN_ERROR); 127 127 128 char tmpline[1024]; 129 if (FIT_MODE == FIT_PM_ONLY) { snprintf (tmpline, 1024, "%s -pm", command); strcpy (command, tmpline); } 130 if (FIT_MODE == FIT_PAR_ONLY) { snprintf (tmpline, 1024, "%s -par", command); strcpy (command, tmpline); } 131 if (FIT_MODE == FIT_PM_AND_PAR) { snprintf (tmpline, 1024, "%s -pmpar", command); strcpy (command, tmpline); } 132 133 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 134 if (VERBOSE2) { snprintf (tmpline, 1024, "%s -vv", command); strcpy (command, tmpline); } 135 if (RESET) { snprintf (tmpline, 1024, "%s -reset", command); strcpy (command, tmpline); } 136 if (UPDATE) { snprintf (tmpline, 1024, "%s -update", command); strcpy (command, tmpline); } 137 138 if (RESET_BAD_IMAGES) { snprintf (tmpline, 1024, "%s -reset-bad-images", command); strcpy (command, tmpline); } 139 140 if (ImagSelect) { snprintf (tmpline, 1024, "%s -instmag %f %f", command, ImagMin, ImagMax); strcpy (command, tmpline); } 141 if (MaxDensityUse) { snprintf (tmpline, 1024, "%s -max-density %f", command, MaxDensityValue); strcpy (command, tmpline); } 128 if (FIT_MODE == FIT_PM_ONLY) strextend (command, "-pm"); 129 if (FIT_MODE == FIT_PAR_ONLY) strextend (command, "-par"); 130 if (FIT_MODE == FIT_PM_AND_PAR) strextend (command, "-pmpar"); 131 132 if (VERBOSE) strextend (command, "-v"); 133 if (VERBOSE2) strextend (command, "-vv"); 134 if (RESET) strextend (command, "-reset"); 135 if (UPDATE) strextend (command, "-update"); 136 137 if (RESET_BAD_IMAGES) strextend (command, "-reset-bad-images"); 138 139 if (ImagSelect) strextend (command, "-instmag %f %f", ImagMin, ImagMax); 140 if (MaxDensityUse) strextend (command, "-max-density %f", MaxDensityValue); 142 141 143 if (USE_BASIC_CHECK) { snprintf (tmpline, 1024, "%s -basic-image-search", command); strcpy (command, tmpline); } 144 if (FlagOutlier) { snprintf (tmpline, 1024, "%s -clip %d", command, CLIP_THRESH); strcpy (command, tmpline); } 142 if (USE_BASIC_CHECK) strextend (command, "-basic-image-search"); 143 if (FlagOutlier) strextend (command, "-clip %d", CLIP_THRESH); 144 if (ExcludeBogus) strextend (command, "-exclude-bogus %f", ExcludeBogusRadius); 145 145 146 if (USE_FIXED_PIXCOORDS) { snprintf (tmpline, 1024, "%s -D USE_FIXED_PIXCOORDS 1", command); strcpy (command, tmpline); }147 148 if (PHOTCODE_KEEP_LIST) { snprintf (tmpline, 1024, "%s +photcode %s", command, PHOTCODE_KEEP_LIST); strcpy (command, tmpline); }149 if (PHOTCODE_SKIP_LIST) { snprintf (tmpline, 1024, "%s -photcode %s", command, PHOTCODE_SKIP_LIST); strcpy (command, tmpline); }150 if (PhotFlagSelect) { snprintf (tmpline, 1024, "%s +photflags", command); strcpy (command, tmpline); }151 if (PhotFlagBad) { snprintf (tmpline, 1024, "%s +photflagbad %d", command, PhotFlagBad); strcpy (command, tmpline); }152 if (PhotFlagPoor) { snprintf (tmpline, 1024, "%s +photflagpoor %d", command, PhotFlagPoor); strcpy (command, tmpline); }146 if (USE_FIXED_PIXCOORDS) strextend (command, "-D USE_FIXED_PIXCOORDS 1"); 147 148 if (PHOTCODE_KEEP_LIST) strextend (command, "+photcode %s", PHOTCODE_KEEP_LIST); 149 if (PHOTCODE_SKIP_LIST) strextend (command, "-photcode %s", PHOTCODE_SKIP_LIST); 150 if (PhotFlagSelect) strextend (command, "+photflags"); 151 if (PhotFlagBad) strextend (command, "+photflagbad %d", PhotFlagBad); 152 if (PhotFlagPoor) strextend (command, "+photflagpoor %d", PhotFlagPoor); 153 153 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 154 154 155 if (MinBadQF > 0.0) { snprintf (tmpline, 1024, "%s -min-bad-psfqf %f", command, MinBadQF); strcpy (command, tmpline); } 156 if (MaxMeanOffset != 10.0) { snprintf (tmpline, 1024, "%s -max-mean-offset %f", command, MaxMeanOffset); strcpy (command, tmpline); } 155 if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) { 156 strextend (command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG); 157 } 158 if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) { 159 strextend (command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG); 160 } 161 162 if (MinBadQF > 0.0) strextend (command, "-min-bad-psfqf %f", MinBadQF); 163 if (MaxMeanOffset != 10.0) strextend (command, "-max-mean-offset %f", MaxMeanOffset); 157 164 158 165 if (TimeSelect) { 159 166 char *tstart = ohana_sec_to_date (TSTART); 160 167 char *tstop = ohana_sec_to_date (TSTOP); 161 s nprintf (tmpline, 1024, "%s -time %s %s", command, tstart, tstop);168 strextend (command, "-time %s %s", tstart, tstop); 162 169 free (tstart); 163 170 free (tstop); 164 strcpy (command, tmpline);165 171 } 166 172 fprintf (stderr, "command: %s\n", command); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/UpdateObjects.c
r36680 r37403 1 1 # include "relastro.h" 2 # define PAR_TOOFEW 5 3 4 int UpdateObjects_Chips (Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int Nsecfilt, FitStats *fitStats, int i, off_t m); 5 int UpdateObjects_Stack (Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int Nsecfilt, FitStats *fitStats); 2 6 3 7 static off_t Nmax; … … 10 14 static double *T; 11 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 } 12 40 13 41 void initObjectData (Catalog *catalog, int Ncatalog) { … … 36 64 ALLOCATE (pX, double, MAX (1, Nmax)); 37 65 ALLOCATE (pY, double, MAX (1, Nmax)); 38 } 39 40 void freeObjectData () { 41 42 free (R); 43 free (D); 44 free (T); 45 free (X); 46 free (Y); 47 48 free (dR); 49 free (dD); 50 free (dT); 51 free (dX); 52 free (dY); 53 54 free (pX); 55 free (pY); 56 } 57 58 // This function operates on both Measure and MeasureTiny. In the big stages, this should 59 // be called with just MeasureTiny set and Measure == NULL 60 int UpdateObjects (Catalog *catalog, int Ncatalog) { 61 62 off_t j, k, m; 63 int i, N, Nsecfilt, mode, result, status, XVERB; 64 StatType statsR, statsD; 65 Coords coords; 66 PMFit fitAve, fitPM, fitPAR, fit; 67 time_t T2000; 68 off_t Nave, Npm, Npar, Nskip, Noffset; 69 off_t NaveSum, NpmSum, NparSum, NskipSum, NoffSum; 70 double Tmin, Tmax, Tmean, Trange; 71 72 memset (&fit, 0, sizeof(fit)); 73 memset (&fitAve, 0, sizeof(fitAve)); 74 memset (&fitPM, 0, sizeof(fitPM)); 75 memset (&fitPAR, 0, sizeof(fitPAR)); 76 initObjectData (catalog, Ncatalog); 66 67 ALLOCATE (C_blue, double, MAX (1, Nmax)); 68 ALLOCATE (C_red, double, MAX (1, Nmax)); 77 69 78 70 /* project coordinates to a plane centered on the object with units of arcsec */ … … 87 79 strcpy (coords.ctype, "DEC--SIN"); 88 80 89 XVERB = FALSE;90 91 81 // use J2000 as a reference time 92 T2000 = ohana_date_to_sec ("2000/01/01"); 82 T2000 = ohana_date_to_sec ("2000/01/01,12:00:00"); 83 } 84 85 void freeObjectData () { 86 87 free (R); 88 free (D); 89 free (T); 90 free (X); 91 free (Y); 92 93 free (dR); 94 free (dD); 95 free (dT); 96 free (dX); 97 free (dY); 98 99 free (pX); 100 free (pY); 101 102 free (C_blue); 103 free (C_red); 104 } 105 106 // This function operates on both Measure and MeasureTiny. In the big stages, this should 107 // be called with just MeasureTiny set and Measure == NULL 108 int UpdateObjects (Catalog *catalog, int Ncatalog) { 109 110 initObjectData (catalog, Ncatalog); 111 93 112 // XXX in the future, use catalog[0].Nsecfilt only? allow catalogs to have variable Nsecfilt? 94 95 Nsecfilt = GetPhotcodeNsecfilt (); 113 int Nsecfilt = GetPhotcodeNsecfilt (); 96 114 if (Ncatalog) { 97 115 assert (catalog[0].Nsecfilt == Nsecfilt); 98 116 } 99 117 100 NaveSum = NparSum = NpmSum = NoffSum = NskipSum = 0; 118 FitStats sumStatsChips; initFitStats (&sumStatsChips); 119 FitStats sumStatsStack; initFitStats (&sumStatsStack); 120 121 int i; 101 122 for (i = 0; i < Ncatalog; i++) { 102 123 103 124 if (VERBOSE2) fprintf (stderr, "astrometrize catalog %d : "OFF_T_FMT" ave, "OFF_T_FMT" meas\n", i, catalog[i].Naverage, catalog[i].Nmeasure); 104 125 105 Nave = Npar = Npm = Nskip = Noffset = 0; 126 FitStats fitStatsChips; initFitStats (&fitStatsChips); 127 FitStats fitStatsStack; initFitStats (&fitStatsStack); 128 129 off_t j; 106 130 for (j = 0; j < catalog[i].Naverage; j++) { 107 131 /* calculate the average value of R,D for a single star */ 108 109 XVERB = FALSE; 110 fitAve.chisq = NAN; 111 fitPM.chisq = NAN; 112 fitPAR.chisq = NAN; 113 114 if (catalog[i].average[j].Nmeasure == 0) { 115 continue; 116 } 117 118 N = 0; 119 m = catalog[i].average[j].measureOffset; 132 off_t m = catalog[i].average[j].measureOffset; 120 133 MeasureTiny *measure = &catalog[i].measureT[m]; 121 134 Measure *measureBig = catalog[i].measure ? &catalog[i].measure[m] : NULL; 122 // when we update the output measure values, we need to do it here 123 124 mode = FIT_MODE; 125 126 // XVERB |= (catalog[i].averge[j].objID == 0xc90) && (catalog[i].average[j].catID == 0x2a1e); 127 XVERB |= (catalog[i].average[j].objID == OBJ_ID_SRC) && (catalog[i].average[j].catID == CAT_ID_SRC); 128 XVERB |= (catalog[i].average[j].objID == OBJ_ID_DST) && (catalog[i].average[j].catID == CAT_ID_DST); 129 130 // find the basic properties of the detections for this object (Tmin, Tmax, Tmean) 131 for (k = 0; k < catalog[i].average[j].Nmeasure; k++) { 132 133 if (XVERB) { 134 char *date = ohana_sec_to_date (measure[k].t); 135 int dbFlagsBig = measureBig ? measureBig[k].dbFlags : 0; 136 fprintf (stderr, OFF_T_FMT" %f %f %s : 0x%08x : 0x%08x\n", k, measure[k].dR, measure[k].dD, date, measure[k].dbFlags, dbFlagsBig); 137 free (date); 138 } 139 140 // does the measurement pass the supplied filtering constraints? 141 // MeasFilterTestTiny does not test psfQF 142 int keepMeasure = measureBig ? MeasFilterTest(&measureBig[k], FALSE) : MeasFilterTestTiny(&measure[k], FALSE); 143 if (!keepMeasure) { 144 measure[k].dbFlags &= ~ID_MEAS_USED_OBJ; 145 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; } 146 continue; 147 } 148 149 // outlier rejection 150 if (FlagOutlier && (measure[k].dbFlags & ID_MEAS_POOR_ASTROM)) { 151 measure[k].dbFlags &= ~ID_MEAS_USED_OBJ; 152 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; } 153 continue; 154 } 155 156 measure[k].dbFlags |= ID_MEAS_USED_OBJ; 157 if (measureBig) { measureBig[k].dbFlags |= ID_MEAS_USED_OBJ; } 158 159 R[N] = getMeanR (&measure[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 160 D[N] = getMeanD (&measure[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 161 162 // XXX I think this is a problem: T[] is time in years relative to J2000, but ParFactor expects 163 // to get Time in years relative to UNIX Tzero (1970/01/01) 164 T[N] = (measure[k].t - T2000) / (86400*365.25) ; // time relative to J2000 in years 165 166 // dX, dY : error in arcsec -- 167 dX[N] = GetAstromErrorTiny (&measure[k], ERROR_MODE_RA); 168 dY[N] = GetAstromErrorTiny (&measure[k], ERROR_MODE_DEC); 169 170 // allow a given photcode or measurement to be 171 // ignored if the error is NAN (for photcode, set astromErrSys to NaN) 172 if (isnan(dX[N])) { 173 measure[k].dbFlags &= ~ID_MEAS_USED_OBJ; 174 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; } 175 continue; 176 } 177 if (isnan(dY[N])) { 178 measure[k].dbFlags &= ~ID_MEAS_USED_OBJ; 179 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; } 180 continue; 181 } 182 183 // add systematic error in quadrature, if desired 184 // only do this after the fit has converged (or you will never improve the poor images) 185 // if (INCLUDE_SYS_ERR) { 186 // float dRsys = FromShortPixels(measure[k].dRsys); 187 // dX[N] = hypot(dX[N], dRsys); 188 // dY[N] = hypot(dY[N], dRsys); 189 // } 190 191 // dX[N] = 0.1; 192 // dY[N] = 0.1; 193 194 dT[N] = measure[k].dt; 195 196 // XXX this is (slightly) inconsistent: dX,dY are the X and Y direction errors in 197 // arcseconds. dR, dD are the errors in those directions in degrees. IF we have 198 // non-circular errors (different values for X and Y), then dR and dD will be 199 // incorrect: they would need to be rotated to take out the position angle 200 dR[N] = dX[N] / 3600.0; 201 dD[N] = dY[N] / 3600.0; 202 203 N++; 204 } 205 206 // if we have too few good detections for the desired fit, or too limited a 207 // baseline, use a fit with fewer parameters. XXX if we have too few measurements 208 // for even the average position, consider including the lower-quality detections? 209 210 catalog[i].average[j].flags &= ~ID_STAR_NO_ASTROM; 211 212 // find Tmin & Tmax from the list of accepted measurements 213 Tmean = 0; 214 Tmin = Tmax = T[0]; 215 for (k = 0; k < N; k++) { 216 Tmin = MIN(Tmin, T[k]); 217 Tmax = MAX(Tmax, T[k]); 218 Tmean += T[k]; 219 } 220 // XXX add the parallax factor range as a criterion as well 221 Trange = Tmax - Tmin; 222 if (Trange < PM_DT_MIN) mode = FIT_AVERAGE; 223 if (((mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) && (N <= PM_TOOFEW)) mode = FIT_AVERAGE; 224 225 if (RELASTRO_OP == OP_HIGH_SPEED) { 226 Tmean = 0.5*(Tmax - Tmin); 227 } else { 228 Tmean /= (float) N; 229 } 230 231 // too few measurements for average position (require 2 values) 232 if (N < SRC_MEAS_TOOFEW) { 233 // XXX need to define PHOTOM and ASTROM object flags 234 // XXX reset the average value fields? 235 catalog[i].average[j].flags |= ID_STAR_NO_ASTROM; 236 catalog[i].average[j].ChiSqAve = NAN; 237 catalog[i].average[j].ChiSqPM = NAN; 238 catalog[i].average[j].ChiSqPar = NAN; 239 if (N < 2) continue; 240 } 241 242 /* we need to do the fit in a locally linear space; choose a ref coordinate */ 243 coords.crval1 = R[0]; 244 coords.crval2 = D[0]; 245 246 // to judge the quality of the PM and PAR fits, we need to fit all three models and compare Chisq 247 248 if ((mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) { 249 // project all of the R,D coordinates to a plane centered on this coordinate. set 250 // the times to be relative to Tmean (this is required for parallax as well) 251 for (k = 0; k < N; k++) { 252 RD_to_XY (&X[k], &Y[k], R[k], D[k], &coords); 253 T[k] -= Tmean; 254 if (XVERB) { 255 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]); 256 } 257 } 258 259 FitPM (&fitPM, X, dX, Y, dY, T, N, XVERB); 260 261 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); 262 263 // project Ro, Do back to RA,DEC 264 XY_to_RD (&fitPM.Ro, &fitPM.Do, fitPM.Ro, fitPM.Do, &coords); 265 if (XVERB) fprintf (stderr, "project: %f %f : %f %f : %f\n", fitPM.Ro, fitPM.Do, fitPM.uR, fitPM.uD, fitPM.p); 266 267 fitPM.p = fitPM.dp = 0.0; 268 catalog[i].average[j].flags |= ID_STAR_FIT_PM; 269 Npm ++; 270 } 271 272 if (mode == FIT_PM_AND_PAR) { 273 // fprintf (stderr, "parallax fitting is still untested (%s, %d)\n", __FILE__, __LINE__); 274 275 float pXmin = +2.0; 276 float pXmax = -2.0; 277 float pYmin = +2.0; 278 float pYmax = -2.0; 279 for (k = 0; k < N; k++) { 280 ParFactor (&pX[k], &pY[k], R[k], D[k], T[k], Tmean); 281 pXmin = MIN (pXmin, pX[k]); 282 pXmax = MAX (pXmax, pX[k]); 283 pYmin = MIN (pYmin, pY[k]); 284 pYmax = MAX (pYmax, pY[k]); 285 } 286 float dXRange = pXmax - pXmin; 287 float dYRange = pYmax - pYmin; 288 float parRange = hypot (dXRange, dYRange); 289 290 # define PAR_TOOFEW 5 291 if ((parRange >= PAR_FACTOR_MIN) && (N > PAR_TOOFEW)) { 292 FitPMandPar (&fitPAR, X, dX, Y, dY, T, pX, pY, N, XVERB); 293 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); 294 295 XY_to_RD (&fitPAR.Ro, &fitPAR.Do, fitPAR.Ro, fitPAR.Do, &coords); 296 catalog[i].average[j].flags |= ID_STAR_FIT_PAR; 297 Npar ++; 298 } else { 299 // need to set mode = FIT_PM_ONLY if we do not fit for parallax 300 mode = FIT_PM_ONLY; 301 } 302 } 303 304 // fit the average model 305 if ((mode == FIT_AVERAGE) || (mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) { 306 liststats_pos (R, dR, N, &statsR, XVERB); // WARNING: this function modifies R (do not use after here) 307 liststats_pos (D, dD, N, &statsD, XVERB); // WARNING: this function modifies D (do not use after here) 308 309 fitAve.Ro = statsR.mean; 310 fitAve.dRo = 3600.0*statsR.sigma; 311 312 fitAve.Do = statsD.mean; 313 fitAve.dDo = 3600.0*statsD.sigma; 314 315 fitAve.chisq = 0.5 * (statsR.chisq + statsD.chisq); 316 fitAve.Nfit = N; 317 318 fitAve.uR = fitAve.duR = 0.0; 319 fitAve.uD = fitAve.duD = 0.0; 320 fitAve.p = fitAve.dp = 0.0; 321 catalog[i].average[j].flags |= ID_STAR_FIT_AVE; 322 Nave ++; 323 } 324 325 /* choose the result based on the chisq values */ 326 // XXXX for now, just use the mode as the result: 327 result = mode; 328 329 switch (result) { 330 case FIT_AVERAGE: 331 catalog[i].average[j].flags |= ID_STAR_USE_AVE; 332 fit = fitAve; 333 break; 334 case FIT_PM_ONLY: 335 catalog[i].average[j].flags |= ID_STAR_USE_PM; 336 fit = fitPM; 337 break; 338 case FIT_PM_AND_PAR: 339 catalog[i].average[j].flags |= ID_STAR_USE_PAR; 340 fit = fitPAR; 341 break; 342 } 343 if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f) pm=(%f %f) plx=(%f +/- %f)\n", 344 catalog[i].average[j].R, 345 catalog[i].average[j].D, 346 fit.Ro, fit.Do, 347 3600*(catalog[i].average[j].R - fit.Ro), 348 3600*(catalog[i].average[j].D - fit.Do), 349 fit.uR, fit.uD, fit.p, fit.dp); 350 351 // make sure that the fit succeeded 352 status = TRUE; 353 status &= finite(fit.Ro); 354 status &= finite(fit.Do); 355 status &= finite(fit.dRo); 356 status &= finite(fit.dDo); 357 status &= finite(fit.uR); 358 status &= finite(fit.uD); 359 status &= finite(fit.duR); 360 status &= finite(fit.duD); 361 status &= finite(fit.p); 362 status &= finite(fit.dp); 363 if (!status) { 364 Nskip ++; 135 Average *average = &catalog[i].average[j]; 136 SecFilt *secfilt = &catalog[i].secfilt[j*Nsecfilt]; 137 138 UpdateObjects_Stack(average, secfilt, measure, measureBig, Nsecfilt, &fitStatsStack); 139 UpdateObjects_Chips(average, secfilt, measure, measureBig, Nsecfilt, &fitStatsChips, i, m); 140 } 141 if (VERBOSE) 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); 142 if (VERBOSE) 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); 143 sumFitStats (&fitStatsChips, &sumStatsChips); 144 sumFitStats (&fitStatsStack, &sumStatsStack); 145 } 146 freeObjectData (); 147 148 if (VERBOSE) fprintf (stderr, "fitted "OFF_T_FMT" objects ("OFF_T_FMT" ave, "OFF_T_FMT" pm, "OFF_T_FMT" par), skipped "OFF_T_FMT", "OFF_T_FMT" have too large an offset\n", (sumStatsChips.Nave + sumStatsChips.Npm + sumStatsChips.Npar), sumStatsChips.Nave, sumStatsChips.Npm, sumStatsChips.Npar, sumStatsChips.Nskip, sumStatsChips.Noffset); 149 if (VERBOSE) fprintf (stderr, "fitted "OFF_T_FMT" objects ("OFF_T_FMT" ave, "OFF_T_FMT" pm, "OFF_T_FMT" par), skipped "OFF_T_FMT", "OFF_T_FMT" have too large an offset\n", (sumStatsStack.Nave + sumStatsStack.Npm + sumStatsStack.Npar), sumStatsStack.Nave, sumStatsStack.Npm, sumStatsStack.Npar, sumStatsStack.Nskip, sumStatsStack.Noffset); 150 return (TRUE); 151 } 152 153 // This function operates on both Measure and MeasureTiny. In the big stages, this should 154 // be called with just MeasureTiny set and Measure == NULL 155 int UpdateObjects_Chips (Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int Nsecfilt, FitStats *fitStats, int i, off_t m) { 156 157 int setRefColor = areImagesMatched(); 158 159 /* calculate the average value of R,D for a single star */ 160 161 PMFit fit; memset (&fit, 0, sizeof(fit)); 162 PMFit fitAve; memset (&fitAve, 0, sizeof(fitAve)); fitAve.chisq = NAN; 163 PMFit fitPM; memset (&fitPM, 0, sizeof(fitPM)); fitPM.chisq = NAN; 164 PMFit fitPAR; memset (&fitPAR, 0, sizeof(fitPAR)); fitPAR.chisq = NAN; 165 166 // if we fail to fit the astrometry for some reason, we need to set/reset these 167 average[0].flags |= ID_STAR_NO_ASTROM; 168 average[0].ChiSqAve = NAN; 169 average[0].ChiSqPM = NAN; 170 average[0].ChiSqPar = NAN; 171 average[0].Npos = 0; 172 173 // an object with no measurements is externally supplied 174 if (average[0].Nmeasure == 0) return TRUE; 175 176 int NcBlue = 0; 177 int NcRed = 0; 178 int N = 0; 179 180 int mode = FIT_MODE; // start with the globally-defined fit mode 181 182 int XVERB = FALSE; 183 XVERB |= (average[0].objID == OBJ_ID_SRC) && (average[0].catID == CAT_ID_SRC); 184 XVERB |= (average[0].objID == OBJ_ID_DST) && (average[0].catID == CAT_ID_DST); 185 186 // find the basic properties of the detections for this object (Tmin, Tmax, Tmean) 187 off_t k; 188 for (k = 0; k < average[0].Nmeasure; k++) { 189 190 if (XVERB) { 191 char *date = ohana_sec_to_date (measure[k].t); 192 int dbFlagsBig = measureBig ? measureBig[k].dbFlags : 0; 193 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); 194 free (date); 195 } 196 197 // SKIP gpc1 stack data 198 if (isGPC1stack(measure[k].photcode)) continue; 199 200 // SKIP gpc1 forced-warp data 201 if (isGPC1warp(measure[k].photcode)) continue; 202 203 // reset the bit to note that a detection was used (or not) 204 measure[k].dbFlags &= ~ID_MEAS_USED_OBJ; 205 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; } 206 207 // does the measurement pass the supplied filtering constraints? 208 // MeasFilterTestTiny does not test psfQF 209 // exclude bad detections based on: photcodes, psfQF, time range, photflags & astromBadMask, mag_inst 210 int keepMeasure = measureBig ? MeasFilterTest(&measureBig[k], FALSE) : MeasFilterTestTiny(&measure[k], FALSE); 211 if (!keepMeasure) { 212 continue; 213 } 214 215 double Ri = getMeanR (&measure[k], average, secfilt); 216 double Di = getMeanD (&measure[k], average, secfilt); 217 218 // mark (as POOR) any measurements which are deviant from the mean by > ExcludeBogusRadius 219 if (ExcludeBogus) { 220 coords.crval1 = average[0].R; 221 coords.crval2 = average[0].D; 222 double Xi, Yi; 223 RD_to_XY (&Xi, &Yi, Ri, Di, &coords); 224 double radius = hypot(Xi, Yi); 225 if (radius > ExcludeBogusRadius) { 226 measure[k].dbFlags |= ID_MEAS_POOR_ASTROM; 227 if (measureBig) { measureBig[k].dbFlags |= ID_MEAS_POOR_ASTROM; } 365 228 continue; 366 229 } 367 368 // what is the offset relative to the mean fit position? 369 coords.crval1 = catalog[i].average[j].R; 370 coords.crval2 = catalog[i].average[j].D; 371 372 double dXoff, dYoff; 373 RD_to_XY (&dXoff, &dYoff, fit.Ro, fit.Do, &coords); 374 float dPos = hypot (dXoff, dYoff); 375 if (dPos > MaxMeanOffset) { 376 if (Noffset < 100) { 377 fprintf (stderr, "(%f,%f) -> (%f,%f) (%f,%f)\n", coords.crval1, coords.crval2, fit.Ro, fit.Do, dXoff, dYoff); 378 } 379 Noffset ++; 380 continue; 230 measure[k].dbFlags &= ~ID_MEAS_POOR_ASTROM; 231 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_POOR_ASTROM; } 232 } 233 234 // outlier rejection 235 if (FALSE && FlagOutlier && (measure[k].dbFlags & ID_MEAS_POOR_ASTROM)) { 236 continue; 237 } 238 239 R[N] = Ri; 240 D[N] = Di; 241 242 // measure[k].t is UNIX seconds, T2000 is UNIX seconds for J2000. 243 // T[] is time in years since J2000 (jd = 2451545) 244 T[N] = (measure[k].t - T2000) / (86400*365.25) ; // time relative to J2000 in years 245 246 // dX, dY : error in arcsec -- 247 dX[N] = GetAstromErrorTiny (&measure[k], ERROR_MODE_RA); 248 dY[N] = GetAstromErrorTiny (&measure[k], ERROR_MODE_DEC); 249 250 // allow a given photcode or measurement to be 251 // ignored if the error is NAN (for photcode, set astromErrSys to NaN) 252 if (isnan(dX[N])) continue; 253 if (isnan(dY[N])) continue; 254 255 // add systematic error in quadrature, if desired 256 // only do this after the fit has converged (or you will never improve the poor images) 257 // if (INCLUDE_SYS_ERR) { 258 // float dRsys = FromShortPixels(measure[k].dRsys); 259 // dX[N] = hypot(dX[N], dRsys); 260 // dY[N] = hypot(dY[N], dRsys); 261 // } 262 263 // dX[N] = 0.1; 264 // dY[N] = 0.1; 265 266 dT[N] = measure[k].dt; 267 268 // XXX this is (slightly) inconsistent: dX,dY are the X and Y direction errors in 269 // arcseconds. dR, dD are the errors in those directions in degrees. IF we have 270 // non-circular errors (different values for X and Y), then dR and dD will be 271 // incorrect: they would need to be rotated to take out the position angle 272 dR[N] = dX[N] / 3600.0; 273 dD[N] = dY[N] / 3600.0; 274 275 if (setRefColor) { 276 float colorBlue = getColorBlue (m+k, i); 277 if (!isnan(colorBlue)) { 278 C_blue[NcBlue] = colorBlue; 279 NcBlue++; 381 280 } 382 383 384 // the measure fields must be updated before the average fields 385 for (k = 0; k < catalog[i].average[j].Nmeasure; k++) { 386 setMeanR (fit.Ro, &measure[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 387 setMeanD (fit.Do, &measure[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 388 if (measureBig) { 389 setMeanR_Big (fit.Ro, &measureBig[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 390 setMeanD_Big (fit.Do, &measureBig[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 391 } 392 } 393 394 catalog[i].average[j].R = fit.Ro; // RA in degrees 395 catalog[i].average[j].D = fit.Do; // DEC in degrees 396 catalog[i].average[j].dR = fit.dRo; // RA scatter in arcsec 397 catalog[i].average[j].dD = fit.dDo; // DEC scatter in arcsec 398 399 catalog[i].average[j].uR = fit.uR; // RA proper motion in arcsec/year 400 catalog[i].average[j].uD = fit.uD; // DEC proper motion in arcsec/year 401 catalog[i].average[j].duR = fit.duR; // RA proper motion error in arcsec/year 402 catalog[i].average[j].duD = fit.duD; // DEC proper motion error in arcsec/year 403 404 catalog[i].average[j].P = fit.p; // parallax in arcsec 405 catalog[i].average[j].dP = fit.dp; // parallax error in arcsec 406 407 catalog[i].average[j].ChiSqAve = fitAve.chisq; 408 catalog[i].average[j].ChiSqPM = fitPM.chisq; 409 catalog[i].average[j].ChiSqPar = fitPAR.chisq; 410 catalog[i].average[j].Tmean = (Tmean * 86400 * 365.25) + T2000; 411 catalog[i].average[j].Trange = (Trange * 86400 * 365.25); 412 catalog[i].average[j].Npos = fit.Nfit; 413 if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f) pm=(%f %f) chisq=(%f, %f, %f)\n", 414 catalog[i].average[j].R, 415 catalog[i].average[j].D, 416 fit.Ro, fit.Do, 417 3600*(catalog[i].average[j].R - fit.Ro), 418 3600*(catalog[i].average[j].D - fit.Do), 419 catalog[i].average[j].uR, 420 catalog[i].average[j].uD, 421 fitAve.chisq, fitPM.chisq, fitPAR.chisq); 422 } 423 424 NaveSum += Nave; 425 NpmSum += Npm; 426 NparSum += Npar; 427 NskipSum += Nskip; 428 NoffSum += Noffset; 429 if (VERBOSE) fprintf (stderr, "catalog %d : "OFF_T_FMT" ave, "OFF_T_FMT" pm, "OFF_T_FMT" par : Nskip "OFF_T_FMT", Noffset "OFF_T_FMT"\n", i, Nave, Npm, Npar, Nskip, Noffset); 430 } 431 432 freeObjectData (); 433 434 if (VERBOSE) fprintf (stderr, "fitted "OFF_T_FMT" objects ("OFF_T_FMT" ave, "OFF_T_FMT" pm, "OFF_T_FMT" par), skipped "OFF_T_FMT", "OFF_T_FMT" have too large an offset\n", (NaveSum + NpmSum + NparSum), NaveSum, NpmSum, NparSum, NskipSum, NoffSum); 281 float colorRed = getColorRed (m+k, i); 282 if (!isnan(colorRed)) { 283 C_red[NcRed] = colorRed; 284 NcRed++; 285 } 286 } 287 288 measure[k].dbFlags |= ID_MEAS_USED_OBJ; 289 if (measureBig) { measureBig[k].dbFlags |= ID_MEAS_USED_OBJ; } 290 291 N++; 292 } // loop over measurements : average[0].Nmeasure 293 294 if (N < 1) { 295 if (isfinite(average[0].Rstk) && isfinite(average[0].Dstk)) { 296 average[0].R = average[0].Rstk; 297 average[0].D = average[0].Dstk; 298 average[0].dR = average[0].dRstk; 299 average[0].dD = average[0].dDstk; 300 } 301 return FALSE; 302 } 303 304 // if we have too few good detections for the desired fit, or too limited a 305 // baseline, use a fit with fewer parameters. XXX if we have too few measurements 306 // for even the average position, consider including the lower-quality detections? 307 308 // find Tmin & Tmax from the list of accepted measurements 309 double Tmean = 0.0; 310 double Tmin = T[0]; 311 double Tmax = T[0]; 312 for (k = 0; k < N; k++) { 313 Tmin = MIN(Tmin, T[k]); 314 Tmax = MAX(Tmax, T[k]); 315 Tmean += T[k]; 316 } 317 double Trange = Tmax - Tmin; 318 319 if (RELASTRO_OP == OP_HIGH_SPEED) { 320 Tmean = 0.5*(Tmax - Tmin); 321 } else { 322 Tmean /= (float) N; 323 } 324 325 /* we need to do the fit in a locally linear space; choose a ref coordinate */ 326 coords.crval1 = R[0]; 327 coords.crval2 = D[0]; 328 329 // to judge the quality of the PM and PAR fits, we need to fit all three models and compare Chisq 330 331 // *** first fit for the proper motion (skip fit if Trange or Npts is too small) *** 332 if ((mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) { 333 if (Trange < PM_DT_MIN) { 334 mode = FIT_AVERAGE; 335 goto skipPM; 336 } 337 if (N <= PM_TOOFEW) { 338 mode = FIT_AVERAGE; 339 goto skipPM; 340 } 341 342 // project all of the R,D coordinates to a plane centered on this coordinate. set 343 // the times to be relative to Tmean (this is required for parallax as well) 344 for (k = 0; k < N; k++) { 345 RD_to_XY (&X[k], &Y[k], R[k], D[k], &coords); 346 T[k] -= Tmean; 347 if (XVERB) { 348 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]); 349 } 350 } 351 352 FitPM (&fitPM, X, dX, Y, dY, T, N, XVERB); 353 354 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); 355 356 // project Ro, Do back to RA,DEC 357 XY_to_RD (&fitPM.Ro, &fitPM.Do, fitPM.Ro, fitPM.Do, &coords); 358 if (XVERB) fprintf (stderr, "project: %f %f : %f %f : %f\n", fitPM.Ro, fitPM.Do, fitPM.uR, fitPM.uD, fitPM.p); 359 360 fitPM.p = fitPM.dp = 0.0; 361 average[0].flags |= ID_STAR_FIT_PM; 362 fitStats->Npm ++; 363 364 // XXX a hard-wired hack... 365 if ((fabs(fitPM.uR) > 2.0) || (fabs(fitPM.uD) > 2.0)) { 366 mode = FIT_AVERAGE; 367 average[0].flags |= ID_STAR_BAD_PM; 368 } 369 } 370 371 skipPM: 372 // fit the parallax + proper-motion model 373 // NOTE : we only fit PAR if we have already fitted for proper motion. if we do not fit PM or we fail 374 // to fit PM, we do not attempt PAR. thus failure to fit PAR falls back to PM-only 375 if (mode == FIT_PM_AND_PAR) { 376 if (Trange < PM_DT_MIN) { 377 mode = FIT_PM_ONLY; 378 goto skipPAR; 379 } 380 if (N <= PAR_TOOFEW) { 381 mode = FIT_PM_ONLY; 382 goto skipPAR; 383 } 384 float pXmin = +2.0; 385 float pXmax = -2.0; 386 float pYmin = +2.0; 387 float pYmax = -2.0; 388 for (k = 0; k < N; k++) { 389 ParFactor (&pX[k], &pY[k], R[k], D[k], T[k], Tmean); 390 pXmin = MIN (pXmin, pX[k]); 391 pXmax = MAX (pXmax, pX[k]); 392 pYmin = MIN (pYmin, pY[k]); 393 pYmax = MAX (pYmax, pY[k]); 394 } 395 float dXRange = pXmax - pXmin; 396 float dYRange = pYmax - pYmin; 397 float parRange = hypot (dXRange, dYRange); 398 399 if (parRange < PAR_FACTOR_MIN) { 400 mode = FIT_PM_ONLY; 401 goto skipPAR; 402 } 403 404 FitPMandPar (&fitPAR, X, dX, Y, dY, T, pX, pY, N, XVERB); 405 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); 406 407 XY_to_RD (&fitPAR.Ro, &fitPAR.Do, fitPAR.Ro, fitPAR.Do, &coords); 408 average[0].flags |= ID_STAR_FIT_PAR; 409 fitStats->Npar ++; 410 411 // XXX a hard-wired hack... 412 if ((fabs(fitPAR.uR) > 2.0) || (fabs(fitPAR.uD) > 2.0)) { 413 mode = FIT_PM_ONLY; 414 } 415 } 416 417 skipPAR: 418 { 419 // ALWAYS fit the average model 420 StatType statsR, statsD; 421 liststats_pos (R, dR, N, &statsR, XVERB); // WARNING: this function modifies R (do not use after here) 422 liststats_pos (D, dD, N, &statsD, XVERB); // WARNING: this function modifies D (do not use after here) 423 424 fitAve.Ro = statsR.mean; 425 fitAve.dRo = 3600.0*statsR.sigma; 426 427 fitAve.Do = statsD.mean; 428 fitAve.dDo = 3600.0*statsD.sigma; 429 430 fitAve.chisq = (N > 1) ? 0.5 * (statsR.chisq + statsD.chisq) : NAN; 431 fitAve.Nfit = N; 432 433 fitAve.uR = fitAve.duR = 0.0; 434 fitAve.uD = fitAve.duD = 0.0; 435 fitAve.p = fitAve.dp = 0.0; 436 average[0].flags |= ID_STAR_FIT_AVE; 437 fitStats->Nave ++; 438 } 439 440 if (setRefColor) { 441 float colorMedian; 442 dsort (C_blue, NcBlue); 443 colorMedian = (NcBlue > 0) ? C_blue[(int)(0.5*NcBlue)] : NAN; 444 average[0].refColorBlue = colorMedian; 445 dsort (C_red, NcRed); 446 colorMedian = (NcRed > 0) ? C_red[(int)(0.5*NcRed)] : NAN; 447 average[0].refColorRed = colorMedian; 448 } 449 450 /* choose the result based on the chisq values */ 451 // XXXX for now, just use the mode as the result: 452 int result = mode; 453 454 switch (result) { 455 case FIT_AVERAGE: 456 average[0].flags |= ID_STAR_USE_AVE; 457 fit = fitAve; 458 break; 459 case FIT_PM_ONLY: 460 average[0].flags |= ID_STAR_USE_PM; 461 fit = fitPM; 462 break; 463 case FIT_PM_AND_PAR: 464 average[0].flags |= ID_STAR_USE_PAR; 465 fit = fitPAR; 466 break; 467 } 468 if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f) pm=(%f %f) plx=(%f +/- %f)\n", 469 average[0].R, 470 average[0].D, 471 fit.Ro, fit.Do, 472 3600*(average[0].R - fit.Ro), 473 3600*(average[0].D - fit.Do), 474 fit.uR, fit.uD, fit.p, fit.dp); 475 476 // make sure that the fit succeeded 477 int status = TRUE; 478 status &= finite(fit.Ro); 479 status &= finite(fit.Do); 480 status &= finite(fit.dRo); 481 status &= finite(fit.dDo); 482 status &= finite(fit.uR); 483 status &= finite(fit.uD); 484 status &= finite(fit.duR); 485 status &= finite(fit.duD); 486 status &= finite(fit.p); 487 status &= finite(fit.dp); 488 if (!status) { 489 fitStats->Nskip ++; 490 return FALSE; // XXX ?? 491 } 492 493 // what is the offset relative to the mean fit position? 494 coords.crval1 = average[0].R; 495 coords.crval2 = average[0].D; 496 497 double dXoff, dYoff; 498 RD_to_XY (&dXoff, &dYoff, fit.Ro, fit.Do, &coords); 499 float dPos = hypot (dXoff, dYoff); 500 if (dPos > MaxMeanOffset) { 501 if (fitStats->Noffset < 100) { 502 fprintf (stderr, "(%f,%f) -> (%f,%f) (%f,%f)\n", coords.crval1, coords.crval2, fit.Ro, fit.Do, dXoff, dYoff); 503 } 504 fitStats->Noffset ++; 505 return FALSE; // XXX ?? 506 } 507 508 average[0].R = fit.Ro; // RA in degrees 509 average[0].D = fit.Do; // DEC in degrees 510 average[0].dR = fit.dRo; // RA scatter in arcsec 511 average[0].dD = fit.dDo; // DEC scatter in arcsec 512 513 average[0].uR = fit.uR; // RA proper motion in arcsec/year 514 average[0].uD = fit.uD; // DEC proper motion in arcsec/year 515 average[0].duR = fit.duR; // RA proper motion error in arcsec/year 516 average[0].duD = fit.duD; // DEC proper motion error in arcsec/year 517 518 average[0].P = fit.p; // parallax in arcsec 519 average[0].dP = fit.dp; // parallax error in arcsec 520 521 average[0].ChiSqAve = fitAve.chisq; 522 average[0].ChiSqPM = fitPM.chisq; 523 average[0].ChiSqPar = fitPAR.chisq; 524 525 average[0].Tmean = (Tmean * 86400 * 365.25) + T2000; 526 average[0].Trange = (Trange * 86400 * 365.25); 527 average[0].Npos = fit.Nfit; 528 529 // unset the NO_ASTROM bit (not(NO_ASTROM) == HAVE_ASTROM) 530 average[0].flags &= ~ID_STAR_NO_ASTROM; 531 532 if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f) pm=(%f %f) chisq=(%f, %f, %f)\n", 533 average[0].R, 534 average[0].D, 535 fit.Ro, fit.Do, 536 3600*(average[0].R - fit.Ro), 537 3600*(average[0].D - fit.Do), 538 average[0].uR, 539 average[0].uD, 540 fitAve.chisq, fitPM.chisq, fitPAR.chisq); 541 435 542 return (TRUE); 436 543 } 544 545 // This function operates on both Measure and MeasureTiny. In the big stages, this should 546 // be called with just MeasureTiny set and Measure == NULL 547 int UpdateObjects_Stack (Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int Nsecfilt, FitStats *fitStats) { 548 549 off_t k; 550 551 // set the default values 552 average[0].Rstk = NAN; // RA in degrees 553 average[0].Dstk = NAN; // DEC in degrees 554 average[0].dRstk = NAN; // RA scatter in arcsec 555 average[0].dDstk = NAN; // DEC scatter in arcsec 556 557 /* calculate the average value of R,D for a single star */ 558 PMFit fitAve; 559 memset (&fitAve, 0, sizeof(fitAve)); 560 fitAve.chisq = NAN; 561 562 if (average[0].Nmeasure == 0) return TRUE; 563 564 int N = 0; 565 566 int XVERB = FALSE; 567 XVERB |= (average[0].objID == OBJ_ID_SRC) && (average[0].catID == CAT_ID_SRC); 568 XVERB |= (average[0].objID == OBJ_ID_DST) && (average[0].catID == CAT_ID_DST); 569 570 // find the basic properties of the detections for this object (Tmin, Tmax, Tmean) 571 for (k = 0; k < average[0].Nmeasure; k++) { 572 573 if (XVERB) { 574 char *date = ohana_sec_to_date (measure[k].t); 575 int dbFlagsBig = measureBig ? measureBig[k].dbFlags : 0; 576 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); 577 free (date); 578 } 579 580 // SKIP everything except gpc1 stack data 581 if (!isGPC1stack(measure[k].photcode)) continue; 582 583 // exclude bad detections based on: photcodes, psfQF, time range, photflags & astromBadMask, mag_inst 584 int keepMeasure = measureBig ? MeasFilterTest(&measureBig[k], FALSE) : MeasFilterTestTiny(&measure[k], FALSE); 585 if (!keepMeasure) { 586 continue; 587 } 588 589 R[N] = getMeanR (&measure[k], average, secfilt); 590 D[N] = getMeanD (&measure[k], average, secfilt); 591 592 // dX, dY : error in arcsec -- 593 dX[N] = GetAstromErrorTiny (&measure[k], ERROR_MODE_RA); 594 dY[N] = GetAstromErrorTiny (&measure[k], ERROR_MODE_DEC); 595 596 // allow a given photcode or measurement to be 597 // ignored if the error is NAN (for photcode, set astromErrSys to NaN) 598 if (isnan(dX[N])) continue; 599 if (isnan(dY[N])) continue; 600 601 // XXX this is (slightly) inconsistent: dX,dY are the X and Y direction errors in 602 // arcseconds. dR, dD are the errors in those directions in degrees. IF we have 603 // non-circular errors (different values for X and Y), then dR and dD will be 604 // incorrect: they would need to be rotated to take out the position angle 605 dR[N] = dX[N] / 3600.0; 606 dD[N] = dY[N] / 3600.0; 607 608 // XXX use a different flag for stack measurements? 609 // measure[k].dbFlags |= ID_MEAS_USED_OBJ; 610 // if (measureBig) { measureBig[k].dbFlags |= ID_MEAS_USED_OBJ; } 611 612 N++; 613 } // loop over measurements : average[0].Nmeasure 614 615 // if we have too few good detections for the desired fit, or too limited a 616 // baseline, use a fit with fewer parameters. XXX if we have too few measurements 617 // for even the average position, consider including the lower-quality detections? 618 619 // too few measurements for average position (require 2 values) 620 if (N < 1) return FALSE; // XXX ?? 621 622 // find the mean position 623 StatType statsR, statsD; 624 liststats_pos (R, dR, N, &statsR, XVERB); // WARNING: this function modifies R (do not use after here) 625 liststats_pos (D, dD, N, &statsD, XVERB); // WARNING: this function modifies D (do not use after here) 626 627 fitAve.Ro = statsR.mean; 628 fitAve.dRo = 3600.0*statsR.sigma; 629 630 fitAve.Do = statsD.mean; 631 fitAve.dDo = 3600.0*statsD.sigma; 632 633 fitAve.chisq = 0.5 * (statsR.chisq + statsD.chisq); 634 fitAve.Nfit = N; 635 636 // XXX choose stack flag? average[0].flags |= ID_STAR_FIT_AVE; 637 fitStats->Nave ++; 638 639 if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f)\n", 640 average[0].R, 641 average[0].D, 642 fitAve.Ro, fitAve.Do, 643 3600*(average[0].R - fitAve.Ro), 644 3600*(average[0].D - fitAve.Do)); 645 646 // make sure that the fit succeeded 647 int status = TRUE; 648 status &= finite(fitAve.Ro); 649 status &= finite(fitAve.Do); 650 status &= finite(fitAve.dRo); 651 status &= finite(fitAve.dDo); 652 if (!status) { 653 fitStats->Nskip ++; 654 return FALSE; 655 } 656 657 // what is the offset relative to the mean fit position? 658 coords.crval1 = average[0].R; 659 coords.crval2 = average[0].D; 660 661 double dXoff, dYoff; 662 RD_to_XY (&dXoff, &dYoff, fitAve.Ro, fitAve.Do, &coords); 663 float dPos = hypot (dXoff, dYoff); 664 if (dPos > MaxMeanOffset) { 665 if (fitStats->Noffset < 100) { 666 fprintf (stderr, "(%f,%f) -> (%f,%f) (%f,%f)\n", coords.crval1, coords.crval2, fitAve.Ro, fitAve.Do, dXoff, dYoff); 667 } 668 fitStats->Noffset ++; 669 return FALSE; 670 } 671 672 // set the stack position values 673 average[0].Rstk = fitAve.Ro; // RA in degrees 674 average[0].Dstk = fitAve.Do; // DEC in degrees 675 average[0].dRstk = fitAve.dRo; // RA scatter in arcsec 676 average[0].dDstk = fitAve.dDo; // DEC scatter in arcsec 677 678 return (TRUE); 679 } 680 681 437 682 438 683 /* fitting proper-motion and parallax: -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/args.c
r36680 r37403 179 179 FlagOutlier = FALSE; 180 180 if ((N = get_argument (argc, argv, "-clip"))) { 181 fprintf (stderr, "-clip is currently disabled\n"); 181 182 remove_argument (N, &argc, argv); 182 183 CLIP_THRESH = atof (argv[N]); 183 184 remove_argument (N, &argc, argv); 184 185 FlagOutlier = TRUE; 186 } 187 188 ExcludeBogus = FALSE; 189 ExcludeBogusRadius = 0.0; 190 if ((N = get_argument (argc, argv, "-exclude-bogus"))) { 191 remove_argument (N, &argc, argv); 192 ExcludeBogusRadius = atof (argv[N]); 193 remove_argument (N, &argc, argv); 194 ExcludeBogus = TRUE; 185 195 } 186 196 … … 284 294 } 285 295 296 // eg g - r or r - i 297 DCR_BLUE_COLOR_POS = NULL; 298 DCR_BLUE_COLOR_NEG = NULL; 299 if ((N = get_argument (argc, argv, "-dcr-blue-color"))) { 300 remove_argument (N, &argc, argv); 301 DCR_BLUE_COLOR_POS = strcreate(argv[N]); 302 remove_argument (N, &argc, argv); 303 DCR_BLUE_COLOR_NEG = strcreate(argv[N]); 304 remove_argument (N, &argc, argv); 305 } 306 307 // eg, z - y or i - z 308 DCR_RED_COLOR_POS = NULL; 309 DCR_RED_COLOR_NEG = NULL; 310 if ((N = get_argument (argc, argv, "-dcr-red-color"))) { 311 remove_argument (N, &argc, argv); 312 DCR_RED_COLOR_POS = strcreate(argv[N]); 313 remove_argument (N, &argc, argv); 314 DCR_RED_COLOR_NEG = strcreate(argv[N]); 315 remove_argument (N, &argc, argv); 316 } 317 318 PHOTCODE_RESET_LIST = NULL; 319 if ((N = get_argument (argc, argv, "-reset-to-photcode"))) { 320 remove_argument (N, &argc, argv); 321 PHOTCODE_RESET_LIST = strcreate(argv[N]); 322 remove_argument (N, &argc, argv); 323 } 324 286 325 PHOTCODE_KEEP_LIST = NULL; 287 326 if ((N = get_argument (argc, argv, "+photcode"))) { … … 291 330 } 292 331 293 PHOTCODE_SKIP_LIST = strcreate("SCOS.103a.E,SCOS.4414.OG590,SCOS.4415.OG590,SCOS.IIIaF.OG590,SCOS.IIIaF.RG610,SCOS.IIIaF.RG630,SCOS.IIIaJ.GG385,SCOS.IIIaJ.GG395,SCOS.IVN.RG715,SCOS.IVN.RG9"); 332 char *SuperCOSMOS_SKIP = strcreate("SCOS.103a.E,SCOS.4414.OG590,SCOS.4415.OG590,SCOS.IIIaF.OG590,SCOS.IIIaF.RG610,SCOS.IIIaF.RG630,SCOS.IIIaJ.GG385,SCOS.IIIaJ.GG395,SCOS.IVN.RG715,SCOS.IVN.RG9"); 333 334 PHOTCODE_SKIP_LIST = NULL; 294 335 if ((N = get_argument (argc, argv, "-photcode"))) { 295 336 remove_argument (N, &argc, argv); 296 char * tmp1= strcreate(argv[N]);297 298 int Ntotal = strlen(tmp1) + strlen(PHOTCODE_SKIP_LIST) + 5;299 300 char *tmp2 = NULL;301 ALLOCATE (tmp2, char, Ntotal);302 snprintf (tmp2, Ntotal, "%s,%s", PHOTCODE_SKIP_LIST, tmp1);303 304 free (tmp1);305 free (PHOTCODE_SKIP_LIST);306 307 PHOTCODE_SKIP_LIST = tmp2;337 char *RawSkip = strcreate(argv[N]); 338 339 char *GotSkip = strstr (RawSkip, SuperCOSMOS_SKIP); 340 if (!GotSkip) { 341 int Ntotal = strlen(RawSkip) + strlen(SuperCOSMOS_SKIP) + 5; 342 ALLOCATE (PHOTCODE_SKIP_LIST, char, Ntotal); 343 snprintf (PHOTCODE_SKIP_LIST, Ntotal, "%s,%s", SuperCOSMOS_SKIP, RawSkip); 344 free (RawSkip); 345 free (SuperCOSMOS_SKIP); 346 } else { 347 PHOTCODE_SKIP_LIST = RawSkip; 348 } 308 349 remove_argument (N, &argc, argv); 309 350 } … … 582 623 FlagOutlier = FALSE; 583 624 if ((N = get_argument (argc, argv, "-clip"))) { 625 fprintf (stderr, "-clip is currently disabled\n"); 584 626 remove_argument (N, &argc, argv); 585 627 CLIP_THRESH = atof (argv[N]); 586 628 remove_argument (N, &argc, argv); 587 629 FlagOutlier = TRUE; 630 } 631 632 ExcludeBogus = FALSE; 633 ExcludeBogusRadius = 0.0; 634 if ((N = get_argument (argc, argv, "-exclude-bogus"))) { 635 remove_argument (N, &argc, argv); 636 ExcludeBogusRadius = atof (argv[N]); 637 remove_argument (N, &argc, argv); 638 ExcludeBogus = TRUE; 588 639 } 589 640 … … 655 706 remove_argument (N, &argc, argv); 656 707 TimeSelect = TRUE; 708 } 709 710 DCR_BLUE_COLOR_POS = NULL; 711 DCR_BLUE_COLOR_NEG = NULL; 712 if ((N = get_argument (argc, argv, "-dcr-blue-color"))) { 713 remove_argument (N, &argc, argv); 714 DCR_BLUE_COLOR_POS = strcreate(argv[N]); 715 remove_argument (N, &argc, argv); 716 DCR_BLUE_COLOR_NEG = strcreate(argv[N]); 717 remove_argument (N, &argc, argv); 718 } 719 DCR_RED_COLOR_POS = NULL; 720 DCR_RED_COLOR_NEG = NULL; 721 if ((N = get_argument (argc, argv, "-dcr-red-color"))) { 722 remove_argument (N, &argc, argv); 723 DCR_RED_COLOR_POS = strcreate(argv[N]); 724 remove_argument (N, &argc, argv); 725 DCR_RED_COLOR_NEG = strcreate(argv[N]); 726 remove_argument (N, &argc, argv); 727 } 728 729 PHOTCODE_RESET_LIST = NULL; 730 if ((N = get_argument (argc, argv, "-reset-to-photcode"))) { 731 remove_argument (N, &argc, argv); 732 PHOTCODE_RESET_LIST = strcreate(argv[N]); 733 remove_argument (N, &argc, argv); 657 734 } 658 735 … … 861 938 exit (2); 862 939 } 940 941 int strextend (char *input, char *format,...) { 942 943 char tmpextra[1024], tmpline[1024]; 944 va_list argp; 945 946 va_start (argp, format); 947 vsnprintf (tmpextra, 1024, format, argp); 948 snprintf (tmpline, 1024, "%s %s", input, tmpextra); 949 strcpy (input, tmpline); 950 951 return TRUE; 952 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/bcatalog.c
r34429 r37403 1 1 # include "relastro.h" 2 2 3 static int Nkeep1 = 0; 4 static int Nkeep2 = 0; 3 5 static int Nskip1 = 0; 4 6 static int Nskip2 = 0; 5 static unsigned int Tref = 1323353985; 6 static short Cref = 10355; 7 8 FILE *fbogus = NULL; 9 static int NskipBogus = 0; 10 11 // test image: 2013/06/15,13:25:51, GPC1.r.XY50 12 static int CHECK_TEST_IMAGE = FALSE; 13 // static unsigned int Tref = 1378812312; 14 // static short Cref = 10001; 15 16 static unsigned int Tref = 1379570672; 17 static short Cref = 10341; 18 19 int LimitDensityCatalog_ByNmeasureGrid (Catalog *subcatalog, Catalog *oldcatalog); 7 20 8 21 int bcatalog (Catalog *subcatalog, Catalog *catalog) { … … 11 24 off_t NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm; 12 25 int Nsecfilt; 26 Coords coords; 27 28 /* for outlier rejection, project coordinates to a plane centered on the object with units of arcsec */ 29 coords.crval1 = 0; 30 coords.crval2 = 0; 31 coords.crpix1 = 0; 32 coords.crpix2 = 0; 33 coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0; 34 coords.pc1_1 = coords.pc2_2 = 1.0; 35 coords.pc1_2 = coords.pc2_1 = 0.0; 36 coords.Npolyterms = 1; 37 strcpy (coords.ctype, "DEC--SIN"); 13 38 14 39 // XXX in the future, use catalog[0].Nsecfilt only? allow catalogs to have variable Nsecfilt? … … 34 59 ID_STAR_NO_ASTROM ; 35 60 61 if (VERBOSE2 && ExcludeBogus && (fbogus == NULL)) { 62 char name[1024]; 63 snprintf (name, 1024, "%s/bogus.%02d.dat", CATDIR, HOST_ID); 64 fbogus = fopen (name, "w"); 65 if (!fbogus) { 66 fprintf (stderr, "trouble opening bogus detection dump : %s\n", name); 67 } 68 } 69 36 70 /* exclude stars not in range or with too few measurements */ 37 71 for (i = 0; i < catalog[0].Naverage; i++) { … … 60 94 if (!MeasFilterTest(&catalog[0].measure[offset], TRUE)) { 61 95 catalog[0].measure[offset].dbFlags &= ~ID_MEAS_USED_CHIP; 62 if ( FALSE && (abs(catalog[0].measure[offset].t - Tref) < 10) && (catalog[0].measure[offset].photcode == Cref)) {96 if (CHECK_TEST_IMAGE && (abs(catalog[0].measure[offset].t - Tref) < 10) && (catalog[0].measure[offset].photcode == Cref)) { 63 97 Nskip1 ++; 64 98 } 65 99 continue; 66 100 } 67 68 // filter out outliers 69 if (FlagOutlier && (catalog[0].measure[offset].dbFlags & ID_MEAS_POOR_ASTROM)) { 101 if (CHECK_TEST_IMAGE && (abs(catalog[0].measure[offset].t - Tref) < 10) && (catalog[0].measure[offset].photcode == Cref)) { 102 Nkeep1 ++; 103 } 104 105 // filter out outliers - these are detections inconsistent with the offset distribution 106 // XXX disable this for now 107 if (FALSE && FlagOutlier && (catalog[0].measure[offset].dbFlags & ID_MEAS_POOR_ASTROM)) { 70 108 catalog[0].measure[offset].dbFlags &= ~ID_MEAS_USED_CHIP; 71 109 if (FALSE && (abs(catalog[0].measure[offset].t - Tref) < 10) && (catalog[0].measure[offset].photcode == Cref)) { … … 76 114 catalog[0].measure[offset].dbFlags |= ID_MEAS_USED_CHIP; 77 115 116 // exclude bogus 117 if (ExcludeBogus) { 118 double Ri = getMeanR_Big (&catalog[0].measure[offset], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt]); 119 double Di = getMeanD_Big (&catalog[0].measure[offset], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt]); 120 coords.crval1 = catalog[0].average[i].R; 121 coords.crval2 = catalog[0].average[i].D; 122 double Xi, Yi; 123 RD_to_XY (&Xi, &Yi, Ri, Di, &coords); 124 double radius = hypot(Xi, Yi); 125 if (radius > ExcludeBogusRadius) { 126 NskipBogus ++; 127 if (VERBOSE2) { 128 FILE *foutput = fbogus ? fbogus : stderr; 129 char *date = ohana_sec_to_date(catalog[0].measure[offset].t); 130 fprintf (foutput, "exclude bogus: %10.6f %10.6f : %10.6f %10.6f : %6.2f %6.2f : %6.2f : %5d %s\n", catalog[0].average[i].R, catalog[0].average[i].D, Ri, Di, Xi, Yi, radius, catalog[0].measure[offset].photcode, date); 131 free (date); 132 } 133 continue; 134 } 135 } 136 78 137 // re-assess on each run of relastro if a measurement should be used 79 138 … … 87 146 // but before the final average properties are calculated, these measurements may be 88 147 // allowed. 148 149 if (CHECK_TEST_IMAGE && (abs(catalog[0].measure[offset].t - Tref) < 10) && (catalog[0].measure[offset].photcode == Cref)) { 150 Nkeep2 ++; 151 } 89 152 90 153 CopyMeasureToTiny (&subcatalog[0].measureT[Nmeasure], &catalog[0].measure[offset]); … … 125 188 // limit the total number of stars in the catalog 126 189 if (MaxDensityUse) { 127 LimitDensityCatalog_ByNmeasure (subcatalog, catalog);190 LimitDensityCatalog_ByNmeasureGrid (subcatalog, catalog); 128 191 } else { 129 192 if (VERBOSE2) { … … 134 197 } 135 198 } 199 if (CHECK_TEST_IMAGE && (Nkeep1 + Nkeep2 + Nskip1 + Nskip2 > 0)) { 200 fprintf (stderr, "kept %d %d, skipped %d %d\n", Nkeep1, Nkeep2, Nskip1, Nskip2); 201 } 202 136 203 return (TRUE); 137 204 } 138 205 139 206 void bcatalog_show_skips () { 140 fprintf (stderr, "Nskip: %d, %d\n", Nskip1, Nskip2); 207 if (ExcludeBogus) { 208 if (fbogus) fclose (fbogus); 209 fprintf (stderr, "NskipBogus: %d\n", NskipBogus); 210 // fprintf (stderr, "Nskip: %d, %d\n", Nskip1, Nskip2); 211 // fprintf (stderr, "Nkeep: %d, %d\n", Nkeep1, Nkeep2); 212 } 141 213 } 142 214 … … 155 227 # undef COMPARE 156 228 229 } 230 231 /* generate a grid in a locally-projected coordinate system, try to select average entries 232 from each grid cell in decending Nmeasure order. 233 */ 234 int LimitDensityCatalog_ByNmeasureGrid (Catalog *subcatalog, Catalog *oldcatalog) { 235 236 off_t i, j; 237 int ix, iy; 238 239 Catalog tmpcatalog; 240 241 double Rmin, Rmax, Dmin, Dmax; 242 243 int Nsecfilt = GetPhotcodeNsecfilt (); 244 245 gfits_scan (&oldcatalog[0].header, "RA0", "%lf", 1, &Rmin); 246 gfits_scan (&oldcatalog[0].header, "DEC0", "%lf", 1, &Dmin); 247 gfits_scan (&oldcatalog[0].header, "RA1", "%lf", 1, &Rmax); 248 gfits_scan (&oldcatalog[0].header, "DEC1", "%lf", 1, &Dmax); 249 250 if (VERBOSE2) fprintf (stderr, "extracting from catalog covering region %f,%f to %f,%f\n", Rmin, Dmin, Rmax, Dmax); 251 252 float AREA = fabs(Dmax - Dmin) * fabs(Rmax - Rmin) * cos (0.5*RAD_DEG*(Dmax + Dmin)); 253 assert (AREA > 0); 254 255 off_t Nmax = MaxDensityValue * AREA; 256 if (subcatalog[0].Naverage <= Nmax) { 257 if (VERBOSE) { 258 fprintf (stderr, "subcatalog has less than the max density\n"); 259 } 260 return (TRUE); 261 } 262 263 off_t Naverage = subcatalog[0].Naverage; 264 265 // generate a grid in locally projected space 266 double Rc = 0.5*(Rmin + Rmax); 267 double Dc = 0.5*(Dmin + Dmax); 268 269 /* project coordinates to a plane centered on the object with units of arcsec */ 270 Coords coords; 271 coords.crval1 = Rc; 272 coords.crval2 = Dc; 273 coords.crpix1 = 0; 274 coords.crpix2 = 0; 275 coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0; 276 coords.pc1_1 = coords.pc2_2 = 1.0; 277 coords.pc1_2 = coords.pc2_1 = 0.0; 278 coords.Npolyterms = 1; 279 strcpy (coords.ctype, "DEC--SIN"); 280 281 // convert all average R,D values to X,Y: 282 double *X, *Y; 283 ALLOCATE (X, double, Naverage); 284 ALLOCATE (Y, double, Naverage); 285 float Xmin = +10000.0, Ymin = +10000.0; 286 float Xmax = -10000.0, Ymax = -10000.0; 287 for (i = 0; i < Naverage; i++) { 288 X[i] = NAN; 289 Y[i] = NAN; 290 // skip any stars which are outside of nominal catalog range 291 if (subcatalog[0].average[i].R < Rmin) continue; 292 if (subcatalog[0].average[i].R > Rmax) continue; 293 if (subcatalog[0].average[i].D < Dmin) continue; 294 if (subcatalog[0].average[i].D > Dmax) continue; 295 RD_to_XY (&X[i], &Y[i], subcatalog[0].average[i].R, subcatalog[0].average[i].D, &coords); 296 Xmin = MIN (Xmin, X[i]); 297 Xmax = MAX (Xmax, X[i]); 298 Ymin = MIN (Ymin, Y[i]); 299 Ymax = MAX (Ymax, Y[i]); 300 } 301 302 // how many grid cells? what is the grid spacing? 303 float dX = Xmax - Xmin; 304 float dY = Ymax - Ymin; 305 306 // *** XXX for the moment, I'm using a hard-wired cell size (200 arcsec ~ 3.3 arcmin) 307 int NX = (int)(dX / 200) + 1; 308 int NY = (int)(dY / 200) + 1; 309 // fprintf (stderr, "Density Grid: %d x %d\n", NX, NY); 310 // XXX check that NX,NY are sensible (5 degrees / 200 arcsec seems like the absolute max) 311 if (NX > 1000) { 312 fprintf (stderr, "serious problem with %s: NX = %d\n", subcatalog[0].filename, NX); 313 exit (3); 314 } 315 if (NY > 1000) { 316 fprintf (stderr, "serious problem with %s: NY = %d\n", subcatalog[0].filename, NY); 317 exit (3); 318 } 319 320 // kind of ugly : generate a grid of index, Nmeasure arrays 321 // to be filled below (I also need NN and Nn to track the number of 322 // entries in each). 323 int **NN_grid; 324 int **Nn_grid; 325 int ***Nm_grid; 326 off_t ***idxgrid; 327 ALLOCATE (NN_grid, int *, NX); 328 ALLOCATE (Nn_grid, int *, NX); 329 ALLOCATE (Nm_grid, int **, NX); 330 ALLOCATE (idxgrid, off_t **, NX); 331 332 for (ix = 0; ix < NX; ix++) { 333 ALLOCATE (NN_grid[ix], int, NY); 334 ALLOCATE (Nn_grid[ix], int, NY); 335 ALLOCATE (Nm_grid[ix], int *, NY); 336 ALLOCATE (idxgrid[ix], off_t *, NY); 337 for (iy = 0; iy < NY; iy++) { 338 Nn_grid[ix][iy] = 0; 339 NN_grid[ix][iy] = 100; 340 ALLOCATE (Nm_grid[ix][iy], int, NN_grid[ix][iy]); 341 ALLOCATE (idxgrid[ix][iy], off_t, NN_grid[ix][iy]); 342 } 343 } 344 345 // assign all of the average entries to a grid cell 346 for (i = 0; i < Naverage; i++) { 347 if (isnan(X[i])) continue; 348 if (isnan(Y[i])) continue; 349 ix = (X[i] - Xmin) / 200.0; 350 iy = (Y[i] - Ymin) / 200.0; 351 int Nn = Nn_grid[ix][iy]; 352 Nm_grid[ix][iy][Nn] = subcatalog[0].average[i].Nmeasure; 353 354 // if we are resetting to a given photcode, we need to have that photcode... 355 if (NphotcodesReset) { 356 int k; 357 int foundReset = FALSE; 358 int m = subcatalog[0].average[i].measureOffset; 359 MeasureTiny *measure = &subcatalog[0].measureT[m]; 360 for (j = 0; (j < subcatalog[0].average[i].Nmeasure) && !foundReset; j++) { 361 if (CHECK_TEST_IMAGE && (abs(measure[j].t - Tref) < 10) && (measure[j].photcode == Cref)) { 362 fprintf (stderr, "."); 363 } 364 for (k = 0; (k < NphotcodesReset) && !foundReset; k++) { 365 if (photcodesReset[k][0].code == measure[j].photcode) foundReset = TRUE; 366 } 367 } 368 if (!foundReset) { 369 Nm_grid[ix][iy][Nn] = 0; 370 } 371 } 372 373 idxgrid[ix][iy][Nn] = i; 374 Nn_grid[ix][iy] ++; 375 if (Nn_grid[ix][iy] >= NN_grid[ix][iy]) { 376 NN_grid[ix][iy] += 100; 377 REALLOCATE (Nm_grid[ix][iy], int, NN_grid[ix][iy]); 378 REALLOCATE (idxgrid[ix][iy], off_t, NN_grid[ix][iy]); 379 } 380 } 381 382 // sort all of the grid cells 383 for (ix = 0; ix < NX; ix++) { 384 for (iy = 0; iy < NY; iy++) { 385 sort_by_Nmeasure (Nm_grid[ix][iy], idxgrid[ix][iy], Nn_grid[ix][iy]); 386 NN_grid[ix][iy] = 0; // I'm going to use this array to track which element I've already selected 387 } 388 } 389 390 // cycle over the grid until we ready Nmax 391 off_t *keepidx = NULL; 392 ALLOCATE (keepidx, off_t, Naverage); 393 memset (keepidx, 0, Naverage*sizeof(off_t)); 394 int Nkeep = 0; 395 396 for (i = 0; (i < 20) && (Nkeep < Nmax); i++) { 397 for (ix = 0; (ix < NX) && (Nkeep < Nmax); ix++) { 398 for (iy = 0; (iy < NY) && (Nkeep < Nmax); iy++) { 399 if (NN_grid[ix][iy] >= Nn_grid[ix][iy]) continue; // all used up! 400 int Nn = NN_grid[ix][iy]; 401 keepidx[Nkeep] = idxgrid[ix][iy][Nn]; 402 Nkeep ++; 403 NN_grid[ix][iy] ++; 404 } 405 } 406 } 407 408 // count the number of measurements this selection will yield 409 off_t ave, NMEASURE = 0; 410 for (i = 0; i < Nkeep; i++) { 411 ave = keepidx[i]; 412 NMEASURE += subcatalog[0].average[ave].Nmeasure; 413 } 414 415 // test catID : 37262 37261 37257 37258 416 int dumpit = FALSE; 417 dumpit |= (oldcatalog[0].catID == 37007); 418 // dumpit |= (oldcatalog[0].catID == 37261); 419 // dumpit |= (oldcatalog[0].catID == 37257); 420 // dumpit |= (oldcatalog[0].catID == 37258); 421 if (dumpit) { 422 char name[64]; 423 snprintf (name, 64, "cat.%05d.dump.dat", oldcatalog[0].catID); 424 FILE *fdump = fopen (name, "w"); 425 for (i = 0; i < Nkeep; i++) { 426 ave = keepidx[i]; 427 fprintf (fdump, "%10.6f %10.6f %d\n", subcatalog[0].average[ave].R, subcatalog[0].average[ave].D, subcatalog[0].average[ave].Nmeasure); 428 } 429 fclose (fdump); 430 } 431 432 // allocate the output data 433 ALLOCATE (tmpcatalog.average, Average, Nkeep); 434 ALLOCATE (tmpcatalog.measureT, MeasureTiny, NMEASURE); 435 ALLOCATE (tmpcatalog.secfilt, SecFilt, Nkeep * Nsecfilt); 436 437 off_t Nmeasure = 0; 438 439 // copy the Nkeep selected entries from subcatalog to tmpcatalog (adjusting links) 440 for (i = 0; i < Nkeep; i++) { 441 ave = keepidx[i]; 442 tmpcatalog.average[i] = subcatalog[0].average[ave]; 443 tmpcatalog.average[i].measureOffset = Nmeasure; 444 for (j = 0; j < tmpcatalog.average[i].Nmeasure; j++) { 445 off_t offset = subcatalog[0].average[ave].measureOffset + j; 446 tmpcatalog.measureT[Nmeasure] = subcatalog[0].measureT[offset]; 447 tmpcatalog.measureT[Nmeasure].averef = i; 448 Nmeasure ++; 449 } 450 for (j = 0; j < Nsecfilt; j++) { 451 tmpcatalog.secfilt[i*Nsecfilt + j] = subcatalog[0].secfilt[ave*Nsecfilt + j]; 452 } 453 } 454 455 if (VERBOSE2) { 456 char *basename = filebasename (oldcatalog[0].filename); 457 fprintf (stderr, "limited to %d ("OFF_T_FMT" subset, "OFF_T_FMT" total) stars, "OFF_T_FMT" ("OFF_T_FMT" subset, "OFF_T_FMT" total) measures for catalog %s\n", 458 Nkeep, subcatalog[0].Naverage, oldcatalog[0].Naverage, Nmeasure, subcatalog[0].Nmeasure, oldcatalog[0].Nmeasure, basename); 459 free (basename); 460 } 461 462 free (X); 463 free (Y); 464 465 for (ix = 0; ix < NX; ix++) { 466 for (iy = 0; iy < NY; iy++) { 467 free (Nm_grid[ix][iy]); 468 free (idxgrid[ix][iy]); 469 } 470 free (NN_grid[ix]); 471 free (Nn_grid[ix]); 472 free (Nm_grid[ix]); 473 free (idxgrid[ix]); 474 } 475 free (NN_grid); 476 free (Nn_grid); 477 free (Nm_grid); 478 free (idxgrid); 479 480 free (keepidx); 481 482 free (subcatalog[0].average); 483 free (subcatalog[0].measureT); 484 free (subcatalog[0].secfilt); 485 486 subcatalog[0].average = tmpcatalog.average; 487 subcatalog[0].measureT = tmpcatalog.measureT; 488 subcatalog[0].secfilt = tmpcatalog.secfilt; 489 subcatalog[0].Naverage = Nkeep; 490 subcatalog[0].Nmeasure = Nmeasure; 491 subcatalog[0].Nsecfilt = oldcatalog[0].Nsecfilt; 492 subcatalog[0].Nsecf_mem = Naverage * oldcatalog[0].Nsecfilt; 493 494 return (TRUE); 157 495 } 158 496 … … 205 543 NMEASURE += subcatalog[0].average[ave].Nmeasure; 206 544 } 545 546 # if (0) 547 if (oldcatalog[0].catID == 59962) { 548 FILE *fdump = fopen ("cat.dump.dat", "w"); 549 for (i = 0; i < Nmax; i++) { 550 ave = index[i]; 551 fprintf (fdump, "%10.6f %10.6f %d\n", subcatalog[0].average[ave].R, subcatalog[0].average[ave].D, subcatalog[0].average[ave].Nmeasure); 552 } 553 fclose (fdump); 554 } 555 # endif 207 556 208 557 // allocate the output data -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/dvo_astrom_ops.c
r33652 r37403 1 1 # include "relastro.h" 2 /* the Measure carries the instantaneous mean position at the epoch t */ 2 3 3 4 double getMeanR (MeasureTiny *measure, Average *average, SecFilt *secfilt) { … … 5 6 double ra; 6 7 7 /* the measure carries the instantaneous mean position at the epoch t */ 8 ra = average[0].R - measure[0].dR / 3600.0; 8 // old: ra = average[0].R - measure[0].dR / 3600.0; 9 if (!measure) return NAN; 10 ra = measure[0].R; 11 12 return (ra); 13 } 14 15 double getMeanD (MeasureTiny *measure, Average *average, SecFilt *secfilt) { 16 17 double dec; 18 19 // old: dec = average[0].D - measure[0].dD / 3600.0; 20 if (!measure) return NAN; 21 dec = measure[0].D; 22 23 return (dec); 24 } 25 26 int setMeanR (double ra_fit, MeasureTiny *measure, Average *average, SecFilt *secfilt) { 27 28 // old: measure[0].dR += (ra_fit - average[0].R) * 3600.0; 29 if (!measure) return FALSE; 30 measure[0].R = ra_fit; 31 32 return (TRUE); 33 } 34 35 int setMeanD (double dec_fit, MeasureTiny *measure, Average *average, SecFilt *secfilt) { 36 37 // old: measure[0].dD += (dec_fit - average[0].D) * 3600.0; 38 if (!measure) return FALSE; 39 measure[0].D = dec_fit; 40 41 return (TRUE); 42 } 43 44 double getMeanR_Big (Measure *measure, Average *average, SecFilt *secfilt) { 45 46 double ra; 47 48 // old: ra = average[0].R - measure[0].dR / 3600.0; 49 if (!measure) return NAN; 50 ra = measure[0].R; 51 52 return (ra); 53 } 54 55 double getMeanD_Big (Measure *measure, Average *average, SecFilt *secfilt) { 56 57 double dec; 58 59 // old: dec = average[0].D - measure[0].dD / 3600.0; 60 if (!measure) return NAN; 61 dec = measure[0].D; 62 63 return (dec); 64 } 65 66 int setMeanR_Big (double ra_fit, Measure *measure, Average *average, SecFilt *secfilt) { 67 68 // old: measure[0].dR += (ra_fit - average[0].R) * 3600.0; 69 if (!measure) return TRUE; 70 measure[0].R = ra_fit; 71 72 return (TRUE); 73 } 74 75 int setMeanD_Big (double dec_fit, Measure *measure, Average *average, SecFilt *secfilt) { 76 77 // measure[0].dD += (dec_fit - average[0].D) * 3600.0; 78 if (!measure) return TRUE; 79 measure[0].D = dec_fit; 80 81 return (TRUE); 82 } 9 83 10 84 /* possible corrections to mean ra: … … 18 92 */ 19 93 20 return (ra);21 }22 23 double getMeanD (MeasureTiny *measure, Average *average, SecFilt *secfilt) {24 25 double dec;26 27 /* the measure carries the instantaneous mean position at the epoch t */28 dec = average[0].D - measure[0].dD / 3600.0;29 30 /* possible corrections to mean ra:31 32 - proper-motion and parallax33 - abberation34 - precession and nutation, etc35 - refraction36 - DCR37 38 */39 40 return (dec);41 }42 43 int setMeanR (double ra_fit, MeasureTiny *measure, Average *average, SecFilt *secfilt) {44 45 /* math to get from new fitted position to new measure offset46 ra_obs = average[0].R - measure[0].dR / 3600.0;47 measure[0].dR = (ra_fit - ra_obs) * 3600.0;48 measure[0].dR = (ra_fit - average[0].R + measure[0].dR/3600) * 3600.049 measure[0].dR = (ra_fit - average[0].R) * 3600.0 + measure[0].dR;50 */51 52 /* the measure carries the instantaneous mean position at the epoch t */53 measure[0].dR += (ra_fit - average[0].R) * 3600.0;54 55 /* possible corrections to mean ra:56 57 - proper-motion and parallax58 - abberation59 - precession and nutation, etc60 - refraction61 - DCR62 63 */64 65 return (TRUE);66 }67 68 int setMeanD (double dec_fit, MeasureTiny *measure, Average *average, SecFilt *secfilt) {69 70 /* math to get from new fitted position to new measure offset71 dec_obs = average[0].D - measure[0].dD / 3600.0;72 measure[0].dD = (dec_fit - dec_obs) * 3600.0;73 measure[0].dD = (dec_fit - average[0].D + measure[0].dD/3600) * 3600.074 measure[0].dD = (dec_fit - average[0].D) * 3600.0 + measure[0].dD;75 */76 77 /* the measure carries the instantaneous mean position at the epoch t */78 measure[0].dD += (dec_fit - average[0].D) * 3600.0;79 80 /* possible corrections to mean ra:81 82 - proper-motion and parallax83 - abberation84 - precession and nutation, etc85 - refraction86 - DCR87 88 */89 90 return (TRUE);91 }92 93 int setMeanR_Big (double ra_fit, Measure *measure, Average *average, SecFilt *secfilt) {94 95 if (!measure) return TRUE;96 97 /* math to get from new fitted position to new measure offset98 ra_obs = average[0].R - measure[0].dR / 3600.0;99 measure[0].dR = (ra_fit - ra_obs) * 3600.0;100 measure[0].dR = (ra_fit - average[0].R + measure[0].dR/3600) * 3600.0101 measure[0].dR = (ra_fit - average[0].R) * 3600.0 + measure[0].dR;102 */103 104 /* the measure carries the instantaneous mean position at the epoch t */105 measure[0].dR += (ra_fit - average[0].R) * 3600.0;106 107 /* possible corrections to mean ra:108 109 - proper-motion and parallax110 - abberation111 - precession and nutation, etc112 - refraction113 - DCR114 115 */116 117 return (TRUE);118 }119 120 int setMeanD_Big (double dec_fit, Measure *measure, Average *average, SecFilt *secfilt) {121 122 if (!measure) return TRUE;123 124 /* math to get from new fitted position to new measure offset125 dec_obs = average[0].D - measure[0].dD / 3600.0;126 measure[0].dD = (dec_fit - dec_obs) * 3600.0;127 measure[0].dD = (dec_fit - average[0].D + measure[0].dD/3600) * 3600.0128 measure[0].dD = (dec_fit - average[0].D) * 3600.0 + measure[0].dD;129 */130 131 /* the measure carries the instantaneous mean position at the epoch t */132 measure[0].dD += (dec_fit - average[0].D) * 3600.0;133 134 /* possible corrections to mean ra:135 136 - proper-motion and parallax137 - abberation138 - precession and nutation, etc139 - refraction140 - DCR141 142 */143 144 return (TRUE);145 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/high_speed_objects.c
r36680 r37403 241 241 for(i1=0;i1<catalog[0].average[nv[l]].Nmeasure;i1++) { 242 242 catalogOut.measure[Nmatchmeas]=catalog[0].measure[m+i1]; 243 / *Set offset RA and Dec wrt correct average value*/244 catalogOut.measure[Nmatchmeas].dR=catalog[0].measure[m+i1].dR+3600.0*(catalog[0].average[nv[0]].R-catalog[0].average[nv[l]].R);245 catalogOut.measure[Nmatchmeas].dD=catalog[0].measure[m+i1].dD+3600.0*(catalog[0].average[nv[0]].D-catalog[0].average[nv[l]].D);243 // DROP no longer necessary to repoint R,D 244 // catalogOut.measure[Nmatchmeas].dR=catalog[0].measure[m+i1].dR+3600.0*(catalog[0].average[nv[0]].R-catalog[0].average[nv[l]].R); 245 // catalogOut.measure[Nmatchmeas].dD=catalog[0].measure[m+i1].dD+3600.0*(catalog[0].average[nv[0]].D-catalog[0].average[nv[l]].D); 246 246 catalogOut.measure[Nmatchmeas].averef = Nmatch; 247 247 Nmatchmeasobj++; … … 297 297 // XXX require a set or not? assert (Nset > 0); 298 298 299 if (!finite(measure[0]. dR)) return FALSE;300 if (!finite(measure[0]. dD)) return FALSE;301 if (!finite(measure[0].M)) return FALSE;299 if (!finite(measure[0].R)) return FALSE; 300 if (!finite(measure[0].D)) return FALSE; 301 if (!finite(measure[0].M)) return FALSE; 302 302 303 303 float dX = GetAstromError (measure, ERROR_MODE_RA); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/hpm_objects.c
r36680 r37403 240 240 for (k = 0; k < catalog[0].average[nj].Nmeasure; k++) { 241 241 testcat.measure[Nmatchmeas] = catalog[0].measure[m+k]; 242 / * Set offset RA and Dec wrt correct average value*/243 testcat.measure[Nmatchmeas].dR = catalog[0].measure[m+k].dR + 3600.0*(catalog[0].average[ni].R - catalog[0].average[nj].R);244 testcat.measure[Nmatchmeas].dD = catalog[0].measure[m+k].dD + 3600.0*(catalog[0].average[ni].D - catalog[0].average[nj].D);242 // DROP: was needed when dR,dD were relative to average.R,D 243 // testcat.measure[Nmatchmeas].R = catalog[0].measure[m+k].R; 244 // testcat.measure[Nmatchmeas].D = catalog[0].measure[m+k].D; 245 245 testcat.measure[Nmatchmeas].averef = 0; 246 246 Nmatchmeas++; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/initialize.c
r36680 r37403 8 8 if (RELASTRO_OP == OP_MERGE_SOURCE) return; 9 9 10 fprintf (stderr, "PHOTCODE_KEEP_LIST: %s\n", PHOTCODE_KEEP_LIST); 11 fprintf (stderr, "PHOTCODE_SKIP_LIST: %s\n", PHOTCODE_SKIP_LIST); 12 fprintf (stderr, "PHOTCODE_A_LIST: %s\n", PHOTCODE_A_LIST); 13 fprintf (stderr, "PHOTCODE_B_LIST: %s\n", PHOTCODE_B_LIST); 10 if (DCR_BLUE_COLOR_POS) fprintf (stderr, "DCR_BLUE_COLOR_POS: %s - %s\n", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG); 11 if (DCR_BLUE_COLOR_POS) fprintf (stderr, "DCR_BLUE_COLOR_POS: %s - %s\n", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG); 14 12 15 photcodesKeep = ParsePhotcodeList (PHOTCODE_KEEP_LIST, &NphotcodesKeep, FALSE); 16 photcodesSkip = ParsePhotcodeList (PHOTCODE_SKIP_LIST, &NphotcodesSkip, FALSE); 17 photcodesGroupA = ParsePhotcodeList (PHOTCODE_A_LIST, &NphotcodesGroupA, TRUE); 18 photcodesGroupB = ParsePhotcodeList (PHOTCODE_B_LIST, &NphotcodesGroupB, TRUE); 13 if (PHOTCODE_KEEP_LIST) fprintf (stderr, "PHOTCODE_KEEP_LIST: %s\n", PHOTCODE_KEEP_LIST); 14 if (PHOTCODE_SKIP_LIST) fprintf (stderr, "PHOTCODE_SKIP_LIST: %s\n", PHOTCODE_SKIP_LIST); 15 if (PHOTCODE_RESET_LIST) fprintf (stderr, "PHOTCODE_RESET_LIST: %s\n", PHOTCODE_RESET_LIST); 16 if (PHOTCODE_A_LIST) fprintf (stderr, "PHOTCODE_A_LIST: %s\n", PHOTCODE_A_LIST); 17 if (PHOTCODE_B_LIST) fprintf (stderr, "PHOTCODE_B_LIST: %s\n", PHOTCODE_B_LIST); 18 19 photcodesKeep = ParsePhotcodeList (PHOTCODE_KEEP_LIST, &NphotcodesKeep, FALSE); 20 photcodesSkip = ParsePhotcodeList (PHOTCODE_SKIP_LIST, &NphotcodesSkip, FALSE); 21 photcodesReset = ParsePhotcodeList (PHOTCODE_RESET_LIST, &NphotcodesReset, FALSE); 22 photcodesGroupA = ParsePhotcodeList (PHOTCODE_A_LIST, &NphotcodesGroupA, TRUE); 23 photcodesGroupB = ParsePhotcodeList (PHOTCODE_B_LIST, &NphotcodesGroupB, TRUE); 24 25 // blue color elements 26 DCR_BLUE_NSEC_POS = DCR_BLUE_NSEC_NEG = -1; 27 if (DCR_BLUE_COLOR_POS) { 28 DCR_BLUE_PHOTCODE_POS = GetPhotcodebyName (DCR_BLUE_COLOR_POS); 29 if (!DCR_BLUE_PHOTCODE_POS) { 30 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", DCR_BLUE_COLOR_POS); 31 exit (1); 32 } 33 DCR_BLUE_NSEC_POS = GetPhotcodeNsec (DCR_BLUE_PHOTCODE_POS[0].code); 34 } 35 if (DCR_BLUE_COLOR_NEG) { 36 DCR_BLUE_PHOTCODE_NEG = GetPhotcodebyName (DCR_BLUE_COLOR_NEG); 37 if (!DCR_BLUE_PHOTCODE_NEG) { 38 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", DCR_BLUE_COLOR_NEG); 39 exit (1); 40 } 41 DCR_BLUE_NSEC_NEG = GetPhotcodeNsec (DCR_BLUE_PHOTCODE_NEG[0].code); 42 } 43 44 // red color elements 45 DCR_RED_NSEC_POS = DCR_RED_NSEC_NEG = -1; 46 if (DCR_RED_COLOR_POS) { 47 DCR_RED_PHOTCODE_POS = GetPhotcodebyName (DCR_RED_COLOR_POS); 48 if (!DCR_RED_PHOTCODE_POS) { 49 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", DCR_RED_COLOR_POS); 50 exit (1); 51 } 52 DCR_RED_NSEC_POS = GetPhotcodeNsec (DCR_RED_PHOTCODE_POS[0].code); 53 } 54 if (DCR_RED_COLOR_NEG) { 55 DCR_RED_PHOTCODE_NEG = GetPhotcodebyName (DCR_RED_COLOR_NEG); 56 if (!DCR_RED_PHOTCODE_NEG) { 57 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", DCR_RED_COLOR_NEG); 58 exit (1); 59 } 60 DCR_RED_NSEC_NEG = GetPhotcodeNsec (DCR_RED_PHOTCODE_NEG[0].code); 61 } 19 62 20 63 initstats (STATMODE); … … 42 85 args_client (argc, argv); 43 86 44 fprintf (stderr, "PHOTCODE_KEEP_LIST: %s\n", PHOTCODE_KEEP_LIST); 45 fprintf (stderr, "PHOTCODE_SKIP_LIST: %s\n", PHOTCODE_SKIP_LIST); 46 fprintf (stderr, "PHOTCODE_A_LIST: %s\n", PHOTCODE_A_LIST); 47 fprintf (stderr, "PHOTCODE_B_LIST: %s\n", PHOTCODE_B_LIST); 87 if (PHOTCODE_KEEP_LIST) fprintf (stderr, "PHOTCODE_KEEP_LIST: %s\n", PHOTCODE_KEEP_LIST); 88 if (PHOTCODE_SKIP_LIST) fprintf (stderr, "PHOTCODE_SKIP_LIST: %s\n", PHOTCODE_SKIP_LIST); 89 if (PHOTCODE_RESET_LIST) fprintf (stderr, "PHOTCODE_RESET_LIST: %s\n", PHOTCODE_RESET_LIST); 90 if (PHOTCODE_A_LIST) fprintf (stderr, "PHOTCODE_A_LIST: %s\n", PHOTCODE_A_LIST); 91 if (PHOTCODE_B_LIST) fprintf (stderr, "PHOTCODE_B_LIST: %s\n", PHOTCODE_B_LIST); 48 92 49 photcodesKeep = ParsePhotcodeList (PHOTCODE_KEEP_LIST, &NphotcodesKeep, FALSE); 50 photcodesSkip = ParsePhotcodeList (PHOTCODE_SKIP_LIST, &NphotcodesSkip, FALSE); 51 photcodesGroupA = ParsePhotcodeList (PHOTCODE_A_LIST, &NphotcodesGroupA, TRUE); 52 photcodesGroupB = ParsePhotcodeList (PHOTCODE_B_LIST, &NphotcodesGroupB, TRUE); 93 photcodesKeep = ParsePhotcodeList (PHOTCODE_KEEP_LIST, &NphotcodesKeep, FALSE); 94 photcodesSkip = ParsePhotcodeList (PHOTCODE_SKIP_LIST, &NphotcodesSkip, FALSE); 95 photcodesReset = ParsePhotcodeList (PHOTCODE_RESET_LIST, &NphotcodesReset, FALSE); 96 photcodesGroupA = ParsePhotcodeList (PHOTCODE_A_LIST, &NphotcodesGroupA, TRUE); 97 photcodesGroupB = ParsePhotcodeList (PHOTCODE_B_LIST, &NphotcodesGroupB, TRUE); 53 98 54 99 initstats (STATMODE); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/launch_region_hosts.c
r36680 r37403 1 1 # include "relastro.h" 2 2 # define DEBUG 0 3 4 int strextend (char *input, char *format,...) {5 6 char tmpextra[1024], tmpline[1024];7 va_list argp;8 9 va_start (argp, format);10 vsnprintf (tmpextra, 1024, format, argp);11 snprintf (tmpline, 1024, "%s %s", input, tmpextra);12 strcpy (input, tmpline);13 14 return TRUE;15 }16 3 17 4 int launch_region_hosts (RegionHostTable *regionHosts) { … … 22 9 for (i = 0; i < regionHosts->Nhosts; i++) { 23 10 char *syncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanmags.sync"); 24 truncate (syncfile, 0);11 if (truncate (syncfile, 0)) fprintf (stderr, "trouble clearing syncfile %s\n", syncfile); 25 12 free (syncfile); 26 13 27 14 char *fitsfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanmags.fits"); 28 truncate (fitsfile, 0);15 if (truncate (fitsfile, 0)) fprintf (stderr, "trouble clearing fitsfile %s\n", fitsfile); 29 16 free (fitsfile); 30 17 31 18 char *imsyncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagemags.sync"); 32 truncate (imsyncfile, 0);19 if (truncate (imsyncfile, 0)) fprintf (stderr, "trouble clearing imsyncfile %s\n", imsyncfile); 33 20 free (imsyncfile); 34 21 35 22 char *imfitsfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagemags.fits"); 36 truncate (imfitsfile, 0);23 if (truncate (imfitsfile, 0)) fprintf (stderr, "trouble clearing imfitsfile %s\n", imfitsfile); 37 24 free (imfitsfile); 38 25 39 26 char *loopsyncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "loop.sync"); 40 truncate (loopsyncfile, 0);27 if (truncate (loopsyncfile, 0)) fprintf (stderr, "trouble clearing loopsyncfile %s\n", loopsyncfile); 41 28 free (loopsyncfile); 42 29 } … … 88 75 if (PHOTCODE_KEEP_LIST) strextend (command, "+photcode %s", PHOTCODE_KEEP_LIST); 89 76 if (PHOTCODE_SKIP_LIST) strextend (command, "-photcode %s", PHOTCODE_SKIP_LIST); 77 if (PHOTCODE_RESET_LIST) strextend (command, "-reset-to-photcode %s", PHOTCODE_RESET_LIST); 90 78 91 79 if (MaxDensityUse) strextend (command, "-max-density %f", MaxDensityValue); 92 80 if (ImagSelect) strextend (command, "-instmag %f %f", ImagMin, ImagMax); 81 if (ExcludeBogus) strextend (command, "-exclude-bogus %f", ExcludeBogusRadius); 82 83 if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) { 84 strextend (command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG); 85 } 86 if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) { 87 strextend (command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG); 88 } 89 93 90 if (PhotFlagSelect) strextend (command, "+photflags"); 94 91 if (PhotFlagBad) strextend (command, "+photflagbad %d", PhotFlagBad); … … 97 94 if (MinBadQF > 0.0) strextend (command, "-min-bad-psfqf %f", MinBadQF); 98 95 if (MaxMeanOffset != 10.0) strextend (command, "-max-mean-offset %f", MaxMeanOffset); 96 97 strextend (command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW); 98 strextend (command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM); 99 strextend (command, "-D RELASTRO_DPOS_MAX %f", DPOS_MAX); 100 strextend (command, "-D ADDSTAR_RADIUS %f", ADDSTAR_RADIUS); 101 102 if (USE_FIXED_PIXCOORDS) strextend (command, "-D USE_FIXED_PIXCOORDS 1"); 99 103 100 104 if (TimeSelect) { -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/load_catalogs.c
r36680 r37403 1 1 # include "relastro.h" 2 2 3 Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog );3 Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog, char *syncfile); 4 4 void bcatalog_show_skips (); 5 5 6 Catalog *load_catalogs (SkyList *skylist, int *Ncatalog, int subselect, int hostID, char *hostpath) { 7 8 int i, j, k, m, Nstar; 6 Catalog *load_catalogs (SkyList *skylist, int *Ncatalog, int subselect, int hostID, char *hostpath, char *syncfile) { 7 8 int i, j, Nstar; 9 // int k, m; 9 10 Catalog *catalog, *pcatalog, tcatalog; 10 11 11 12 // XXX need to decide how to determine PARALLEL mode... 12 13 if (PARALLEL && !hostID) { 13 catalog = load_catalogs_parallel (skylist, Ncatalog );14 catalog = load_catalogs_parallel (skylist, Ncatalog, syncfile); 14 15 return catalog; 15 16 } … … 73 74 if (RESET) { 74 75 for (j = 0; j < catalog[Ncat].Naverage; j++) { 76 # if (0) 75 77 catalog[Ncat].average[j].flags = 0; 76 78 m = catalog[Ncat].average[j].measureOffset; … … 78 80 catalog[Ncat].measure[m+k].dbFlags = 0; 79 81 } 82 # endif 80 83 } 81 84 } … … 84 87 } 85 88 86 // XXX TEST :bcatalog_show_skips();89 bcatalog_show_skips(); 87 90 88 91 Nstar = 0; … … 99 102 } 100 103 104 // if we are running with parallel_images but not a parallel database, we need to 105 // release the lock so the next image host can proceed 106 if (!hostID && syncfile) { 107 update_sync_file (syncfile, 1); 108 } 109 101 110 // only return the populated catalogs 102 111 REALLOCATE (catalog, Catalog, Ncat); … … 113 122 // CATDIR is supplied globally 114 123 # define DEBUG 1 115 Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog ) {124 Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog, char *syncfile) { 116 125 117 126 char uniquer[12]; … … 150 159 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); 151 160 152 char tmpline[1024]; 153 if (FIT_MODE == FIT_PM_ONLY) { snprintf (tmpline, 1024, "%s -pm", command); strcpy (command, tmpline); } 154 if (FIT_MODE == FIT_PAR_ONLY) { snprintf (tmpline, 1024, "%s -par", command); strcpy (command, tmpline); } 155 if (FIT_MODE == FIT_PM_AND_PAR) { snprintf (tmpline, 1024, "%s -pmpar", command); strcpy (command, tmpline); } 156 157 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 158 if (VERBOSE2) { snprintf (tmpline, 1024, "%s -vv", command); strcpy (command, tmpline); } 159 if (RESET) { snprintf (tmpline, 1024, "%s -reset", command); strcpy (command, tmpline); } 160 if (ImagSelect) { snprintf (tmpline, 1024, "%s -instmag %f %f", command, ImagMin, ImagMax); strcpy (command, tmpline); } 161 if (MaxDensityUse) { snprintf (tmpline, 1024, "%s -max-density %f", command, MaxDensityValue); strcpy (command, tmpline); } 161 if (FIT_MODE == FIT_PM_ONLY) strextend (command, "-pm"); 162 if (FIT_MODE == FIT_PAR_ONLY) strextend (command, "-par"); 163 if (FIT_MODE == FIT_PM_AND_PAR) strextend (command, "-pmpar"); 164 165 if (VERBOSE) strextend (command, "-v"); 166 if (VERBOSE2) strextend (command, "-vv"); 167 if (RESET) strextend (command, "-reset"); 168 if (ImagSelect) strextend (command, "-instmag %f %f", ImagMin, ImagMax); 169 if (MaxDensityUse) strextend (command, "-max-density %f", MaxDensityValue); 170 if (FlagOutlier) strextend (command, "-clip %d", CLIP_THRESH); 171 if (ExcludeBogus) strextend (command, "-exclude-bogus %f", ExcludeBogusRadius); 162 172 163 if (FlagOutlier) { snprintf (tmpline, 1024, "%s -clip %d", command, CLIP_THRESH); strcpy (command, tmpline); } 164 165 if (USE_FIXED_PIXCOORDS) { snprintf (tmpline, 1024, "%s -D USE_FIXED_PIXCOORDS 1", command); strcpy (command, tmpline); } 166 167 if (PHOTCODE_KEEP_LIST) { snprintf (tmpline, 1024, "%s +photcode %s", command, PHOTCODE_KEEP_LIST); strcpy (command, tmpline); } 168 if (PHOTCODE_SKIP_LIST) { snprintf (tmpline, 1024, "%s -photcode %s", command, PHOTCODE_SKIP_LIST); strcpy (command, tmpline); } 169 if (PhotFlagSelect) { snprintf (tmpline, 1024, "%s +photflags", command); strcpy (command, tmpline); } 170 if (PhotFlagBad) { snprintf (tmpline, 1024, "%s +photflagbad %d", command, PhotFlagBad); strcpy (command, tmpline); } 171 if (PhotFlagPoor) { snprintf (tmpline, 1024, "%s +photflagpoor %d", command, PhotFlagPoor); strcpy (command, tmpline); } 173 if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) { 174 strextend (command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG); 175 } 176 if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) { 177 strextend (command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG); 178 } 179 180 if (USE_FIXED_PIXCOORDS) strextend (command, "-D USE_FIXED_PIXCOORDS 1"); 181 if (PHOTCODE_KEEP_LIST) strextend (command, "+photcode %s", PHOTCODE_KEEP_LIST); 182 if (PHOTCODE_SKIP_LIST) strextend (command, "-photcode %s", PHOTCODE_SKIP_LIST); 183 if (PhotFlagSelect) strextend (command, "+photflags"); 184 if (PhotFlagBad) strextend (command, "+photflagbad %d", PhotFlagBad); 185 if (PhotFlagPoor) strextend (command, "+photflagpoor %d", PhotFlagPoor); 172 186 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 173 187 … … 175 189 char *tstart = ohana_sec_to_date (TSTART); 176 190 char *tstop = ohana_sec_to_date (TSTOP); 177 s nprintf (tmpline, 1024, "%s -time %s %s", command, tstart, tstop);191 strextend (command, "-time %s %s", tstart, tstop); 178 192 free (tstart); 179 193 free (tstop); 180 strcpy (command, tmpline);181 194 } 182 195 … … 211 224 } 212 225 226 // update syncfile here (save lots of I/O time): 227 228 // at this point, the remote relastro_client jobs are done loading their data. in a 229 // parallel_images mode, the next image host can be launched while this image host now 230 // reads that 231 232 // NOTE: if I let all hosts load blindly, I saturate the data clients with too many 233 // relastro_client requests. I need to have the master mediate this. the master 234 // will not launch the next remote job until this one says it is done 235 if (syncfile) { 236 update_sync_file (syncfile, 1); 237 } 238 213 239 // each host generates a BrightCatalog structure, with the measure, average, etc value 214 240 // loaded into a single set of arrays (of MeasureTiny, AverageTiny, Secfilt). I need to -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/markObjects.c
r36680 r37403 8 8 // How strongly do I own this object? 9 9 for (i = 0; i < Ncatalog; i++) { 10 ALLOCATE (catalog[i].nOwn , int, catalog[i].Naverage);11 memset (catalog[i].nOwn , 0, catalog[i].Naverage*sizeof(int));10 ALLOCATE (catalog[i].nOwn_t, int, catalog[i].Naverage); 11 memset (catalog[i].nOwn_t, 0, catalog[i].Naverage*sizeof(int)); 12 12 for (j = 0; j < catalog[i].Naverage; j++) { 13 13 int nOwn = 0; … … 17 17 nOwn ++; 18 18 } 19 catalog[i].nOwn [j] = nOwn;19 catalog[i].nOwn_t[j] = nOwn; 20 20 } 21 21 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/relastroVisual.c
r31635 r37403 431 431 432 432 // populate vectors 433 ALLOCATE(Din, float, Nmeasure);434 ALLOCATE(Rin, float, Nmeasure);433 ALLOCATE(Din, float, Nmeasure); 434 ALLOCATE(Rin, float, Nmeasure); 435 435 ALLOCATE(Dout, float, Nmeasure); 436 436 ALLOCATE(Rout, float, Nmeasure); … … 451 451 meas = catalog[0].measure[m]; 452 452 if (!MeasFilterTest(&meas, FALSE)) continue; 453 xmin = MIN(xmin, meas. dR);454 xmax = MAX(xmax, meas. dR);455 ymin = MIN(ymin, meas. dD);456 ymax = MAX(ymax, meas. dD);453 xmin = MIN(xmin, meas.R); 454 xmax = MAX(xmax, meas.R); 455 ymin = MIN(ymin, meas.D); 456 ymax = MAX(ymax, meas.D); 457 457 458 458 if (meas.dbFlags & ID_MEAS_POOR_ASTROM) { 459 Rout[Nout] = ( float)(meas.dR);460 Dout[Nout] = ( float)(meas.dD);459 Rout[Nout] = (meas.R); 460 Dout[Nout] = (meas.D); 461 461 fprintf(stderr, "r: %f\td: %f\t outlier: 1\n", Rout[Nout], Dout[Nout]); 462 462 Nout++; 463 463 } else { 464 Rin[Nin] = ( float)(meas.dR);465 Din[Nin] = ( float)(meas.dD);464 Rin[Nin] = (meas.R); 465 Din[Nin] = (meas.D); 466 466 fprintf(stderr, "r: %f\td: %f\t outlier: 0\n", Rin[Nin], Din[Nin]); 467 467 Nin++; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/relastro_client.c
r36680 r37403 33 33 // USAGE: relastro_client -load-objects 34 34 int Ncatalog; 35 Catalog *catalog = load_catalogs (skylist, &Ncatalog, TRUE, HOST_ID, HOSTDIR );35 Catalog *catalog = load_catalogs (skylist, &Ncatalog, TRUE, HOST_ID, HOSTDIR, NULL); 36 36 if (!catalog) { 37 37 fprintf (stderr, "ERROR loading catalogs from %s\n", CATDIR); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/relastro_images.c
r36680 r37403 28 28 // XXX pass in the image table 29 29 // XXX who carries the image grid? 30 catalog = load_catalogs (skylist, &Ncatalog, TRUE, 0, NULL); 30 31 // photcodesKeep is used here to allow measurements from the images being calibrated 32 // note if -reset-to-photcode is selected, photocodesKeep is replaced with below with photcodesReset 33 catalog = load_catalogs (skylist, &Ncatalog, TRUE, 0, NULL, NULL); 31 34 MARKTIME("load catalog data: %f sec\n", dtime); 35 36 if (photcodesReset) { 37 photcodesKeep = photcodesReset; 38 NphotcodesKeep = NphotcodesReset; 39 } 32 40 33 41 if (Ncatalog == 0) { … … 50 58 // set test points based on the starmap 51 59 createStarMap (catalog, Ncatalog); 60 61 // XXX NOTE : for 2mass reset, photcodesKeep should now limit to 2MASS measurements 52 62 53 63 /* major modes */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/relastro_merge_source.c
r34088 r37403 100 100 catalog_src.measure[m].averef = index_dst; 101 101 102 // OLD CODE: when measure.dR,dD were relative to average.R,D it was necessary to modify them 102 103 // get the instantaneous positions: 103 double R = catalog_src.average[index_src].R - catalog_src.measure[m].dR / 3600.0;104 double D = catalog_src.average[index_src].D - catalog_src.measure[m].dD / 3600.0;104 // DROP double R = catalog_src.average[index_src].R - catalog_src.measure[m].dR / 3600.0; 105 // DROP double D = catalog_src.average[index_src].D - catalog_src.measure[m].dD / 3600.0; 105 106 106 107 // update the offset coordinates to match the new source 107 catalog_src.measure[m].dR = 3600.0*(catalog_src.average[index_dst].R - R);108 catalog_src.measure[m].dD = 3600.0*(catalog_src.average[index_dst].D - D);108 // DROP catalog_src.measure[m].dR = 3600.0*(catalog_src.average[index_dst].R - R); 109 // DROP catalog_src.measure[m].dD = 3600.0*(catalog_src.average[index_dst].D - D); 109 110 } 110 111 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/relastro_objects.c
r36680 r37403 40 40 snprintf (hostfile, 1024, "%s/%s.cpt", hostpath, skylist[0].regions[i]->name); 41 41 catalog.filename = hostID ? hostfile : skylist[0].filename[i]; 42 43 // set up the basic catalog info 42 44 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 43 45 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/relastro_parallel_images.c
r36680 r37403 45 45 46 46 /* load catalog data from region files (hostID is 0 since we are not a client */ 47 catalog = load_catalogs (skylist, &Ncatalog, TRUE, 0, NULL); 47 char *syncfile = make_filename (CATDIR, regionHosts->hosts[myHost].hostname, REGION_HOST_ID, "loadcat.sync"); 48 catalog = load_catalogs (skylist, &Ncatalog, TRUE, 0, NULL, syncfile); 48 49 MARKTIME("-- load catalog data: %f sec\n", dtime); 50 free (syncfile); 49 51 50 // NOTE: if I let all hosts load blindly, I saturate the data clients with too many 51 // relastro_client requests. I need to have the master mediate this. the master 52 // will not launch the next remote job until this one says it is done 53 char *syncfile = make_filename (CATDIR, regionHosts->hosts[myHost].hostname, REGION_HOST_ID, "loadcat.sync"); 54 update_sync_file (syncfile, 1); 55 52 if (photcodesReset) { 53 photcodesKeep = photcodesReset; 54 NphotcodesKeep = NphotcodesReset; 55 } 56 56 57 // generate tables go from catID,objID -> catSeq,objSeq 57 58 indexCatalogs (catalog, Ncatalog); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/share_mean_pos.c
r36680 r37403 33 33 // XXX : sky objects without missing detections 34 34 // XXX watch out for detections which are not associated with an image (REF) 35 if (catalog[i].nOwn [j] == catalog[i].average[j].Nmeasure) continue;35 if (catalog[i].nOwn_t[j] == catalog[i].average[j].Nmeasure) continue; 36 36 37 37 set_mean_pos (&meanpos[Nmeanpos], &catalog[i].average[j]); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/syncfile.c
r36680 r37403 50 50 int clear_sync_file (char *filename) { 51 51 // delete file contents 52 truncate (filename, 0);52 if (truncate (filename, 0)) fprintf (stderr, "trouble clearing file %s\n", filename); 53 53 54 54 return TRUE; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/Makefile
r36680 r37403 34 34 $(SRC)/args.$(ARCH).o \ 35 35 $(SRC)/help.$(ARCH).o \ 36 $(SRC)/extra.$(ARCH).o \ 36 37 $(SRC)/bcatalog.$(ARCH).o \ 37 38 $(SRC)/global_stats.$(ARCH).o \ … … 82 83 $(SRC)/args.$(ARCH).o \ 83 84 $(SRC)/help.$(ARCH).o \ 85 $(SRC)/extra.$(ARCH).o \ 84 86 $(SRC)/synthetic_mags.$(ARCH).o \ 85 87 $(SRC)/plotstuff.$(ARCH).o \ 86 88 $(SRC)/liststats.$(ARCH).o \ 87 89 $(SRC)/initialize.$(ARCH).o \ 90 $(SRC)/syncfile.$(ARCH).o \ 88 91 $(SRC)/load_catalogs.$(ARCH).o \ 89 92 $(SRC)/reload_catalogs.$(ARCH).o \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/doc/mosaic.txt
r33963 r37403 1 2 3 2014.07.09 4 5 * trying to make sense of mosaic.Mcal vs image.Mcal in the context of UBERCAL: 6 7 * relphot_images: 8 * load_images (convert raw FITS table to Image structure, select subset matching selection) 9 * initMosaics (associate mosaics to images (gpc1 photcodes only)) 10 * initMosaicGrid (define spatial range of mosaics [only used by grid analysis]; set Mcal to <image.Mcal> and image.Mcal to 0.0) 11 --- calculate image or mosaic Mcal values 12 * setMcalFinal (set image.Mcal = mosaicMcal) 13 14 * relphot_parallel_regions: 15 * assign_images 16 * makeMosaics (equivalent to initMosaics, but works on full image table, not subset) 17 * setMosaicCenters (set Mcal to <image.Mcal> and image.Mcal to 0.0) <--- this is wrong! 18 (sends images ONLY, not mosaics, to remote machines) 19 (slurps back new image values, applies to db) 20 21 * relphot_parallel_images: 22 * makeMosaics (associate mosaics to images, gpc1 photcodes only) 23 * initMosaicGrid (needed in this one) 24 --- 1 25 2 26 For 'mosaic' zero points, I define the mosaics by grouping the images -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/include/relphot.h
r36680 r37403 4 4 # include <signal.h> 5 5 # include <pthread.h> 6 7 # define MARKTIME(MSG,...) { \8 gettimeofday (&stopTimer, (void *) NULL); \9 float dtime = DTIME (stopTimer, startTimer); \10 fprintf (stderr, MSG, __VA_ARGS__); }11 12 # define INITTIME \13 struct timeval startTimer, stopTimer; \14 gettimeofday (&startTimer, (void *) NULL);15 6 16 7 /* # define GRID_V1 */ … … 119 110 float M; 120 111 float dM; 121 float Xm;112 float Mchisq; 122 113 int Nsec; 123 114 unsigned int objID; … … 130 121 float dMcal; 131 122 float dMagSys; 132 float Xm;123 short Xm; 133 124 int nFitPhotom; 134 125 int flags; … … 317 308 int findMosaics PROTO((Catalog *catalog, int Ncatalog, int doMosaicList)); 318 309 319 void makeMosaics (Image *image, off_t Nimage );310 void makeMosaics (Image *image, off_t Nimage, int mergeMcal); 320 311 Mosaic *getMosaicForImage (off_t im); 321 312 void setMosaicCenters (Image *image, off_t Nimage); … … 360 351 void liststats_setmode PROTO((StatType *stats, char *strmode)); 361 352 int liststats PROTO((double *value, double *dvalue, double *wvalue, int N, StatType *stats)); 362 Catalog *load_catalogs PROTO((SkyList *skylist, int *Ncatalog, int hostID, char *hostpath ));363 Catalog *load_catalogs_parallel PROTO((SkyList *sky, int *Ncatalog ));353 Catalog *load_catalogs PROTO((SkyList *skylist, int *Ncatalog, int hostID, char *hostpath, char *syncfile)); 354 Catalog *load_catalogs_parallel PROTO((SkyList *sky, int *Ncatalog, char *syncfile)); 364 355 365 356 SkyList *load_images PROTO((FITS_DB *db, char *regionName, SkyRegion *region)); … … 449 440 int MatchImageName (off_t meas, int cat, char *name); 450 441 int MatchImageSkycellID (off_t meas, int cat, int myTessID, int myProjectionID, int mySkycellID); 442 int FindImageSkycellID (off_t meas, int cat, int *myTessID, int *myProjectionID, int *mySkycellID); 451 443 452 444 int load_tess (char *treefile); … … 460 452 int setMrel_catalog_alt (Catalog *catalog, int Nc, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, int Nsecfilt); 461 453 int setMrelAverageExposure (off_t meas, int cat, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, Average *average, AverageTiny *averageT, SecFilt *secfilt, Measure *measure, MeasureTiny *measureT, off_t *found); 462 int setMrelAverageStack (off_t meas, int cat, FlatCorrectionTable *flatcorr, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure , char *primaryCell);454 int setMrelAverageStack (off_t meas, int cat, FlatCorrectionTable *flatcorr, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure); 463 455 int setGlobalObjStats (Average *average, Measure *measure); 464 456 … … 509 501 int relphot_parallel_images (); 510 502 int relphot_parallel_regions (); 503 504 // in extra.c 505 int isGPC1chip (int photcode); 506 int isGPC1stack (int photcode); 507 int isGPC1warp (int photcode); 508 509 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/BrightCatalog.c
r36680 r37403 63 63 64 64 // need to create and assign to flat-field correction 65 GET_COLUMN( dR, "RA_OFF", float);66 GET_COLUMN( dD, "DEC_OFF", float);65 GET_COLUMN(R, "RA", double); 66 GET_COLUMN(D, "DEC", double); 67 67 GET_COLUMN(M, "MAG_SYS", float); 68 68 GET_COLUMN(Mcal, "MAG_CAL", float); … … 85 85 ALLOCATE (measure, MeasureTiny, Nrow); 86 86 for (i = 0; i < Nrow; i++) { 87 measure[i]. dR = dR[i];88 measure[i]. dD = dD[i];87 measure[i].R = R[i]; 88 measure[i].D = D[i]; 89 89 measure[i].M = M[i]; 90 90 measure[i].Mcal = Mcal[i]; … … 105 105 fprintf (stderr, "loaded data for %lld measure\n", (long long) Nrow); 106 106 107 free ( dR);108 free ( dD);107 free (R ); 108 free (D ); 109 109 free (M ); 110 110 free (Mcal ); … … 136 136 137 137 // need to create and assign to flat-field correction 138 GET_COLUMN(R, "RA", double);139 GET_COLUMN(D, "DEC", double);138 GET_COLUMN(R, "RA", double); 139 GET_COLUMN(D, "DEC", double); 140 140 GET_COLUMN(Nmeasure, "NMEAS", int); 141 141 GET_COLUMN(measureOffset, "MEASURE_OFF", int); … … 182 182 183 183 // need to create and assign to flat-field correction 184 GET_COLUMN(M, "MAG", float);185 GET_COLUMN(dM, "MAG_ERR", float);186 GET_COLUMN( Xm,"MAG_CHI", float);187 GET_COLUMN(flags, "FLAGS", int);188 GET_COLUMN(Ncode, "NCODE", short);189 GET_COLUMN(Nused, "NUSED", short);190 GET_COLUMN(M _20, "MAG_20", short);191 GET_COLUMN(M _80, "MAG_80", short);184 GET_COLUMN(M, "MAG", float); 185 GET_COLUMN(dM, "MAG_ERR", float); 186 GET_COLUMN(Mchisq, "MAG_CHI", float); 187 GET_COLUMN(flags, "FLAGS", int); 188 GET_COLUMN(Ncode, "NCODE", short); 189 GET_COLUMN(Nused, "NUSED", short); 190 GET_COLUMN(Mmin, "MAG_MIN", float); 191 GET_COLUMN(Mmax, "MAG_MAX", float); 192 192 gfits_free_header (&theader); 193 193 gfits_free_table (&ftable); … … 196 196 ALLOCATE (secfilt, SecFilt, Nrow); 197 197 for (i = 0; i < Nrow; i++) { 198 secfilt[i].M = M[i];199 secfilt[i].dM = dM[i];200 secfilt[i]. Xm = Xm[i];201 secfilt[i].flags = flags[i];202 secfilt[i].Ncode = Ncode[i];203 secfilt[i].Nused = Nused[i];204 secfilt[i].M _20 = M_20[i];205 secfilt[i].M _80 = M_80[i];198 secfilt[i].M = M[i]; 199 secfilt[i].dM = dM[i]; 200 secfilt[i].Mchisq = Mchisq[i]; 201 secfilt[i].flags = flags[i]; 202 secfilt[i].Ncode = Ncode[i]; 203 secfilt[i].Nused = Nused[i]; 204 secfilt[i].Mmin = Mmin[i]; 205 secfilt[i].Mmax = Mmax[i]; 206 206 } 207 207 fprintf (stderr, "loaded data for %lld secfilt\n", (long long) Nrow); 208 208 209 free (M );210 free (dM );211 free ( Xm);212 free (flags );213 free (Ncode );214 free (Nused );215 free (M _20);216 free (M _80);209 free (M ); 210 free (dM ); 211 free (Mchisq); 212 free (flags ); 213 free (Ncode ); 214 free (Nused ); 215 free (Mmin ); 216 free (Mmax ); 217 217 catalog->secfilt = secfilt; 218 218 // assert Nsecfilt * Naverage = Nrow? … … 265 265 gfits_create_table_header (&theader, "BINTABLE", "MEASURE_TINY"); 266 266 267 gfits_define_bintable_column (&theader, " E", "RA_OFF", "ra offset", "arcsec", 1.0, 0.0);268 gfits_define_bintable_column (&theader, " E", "DEC_OFF", "dec offset", "arcsec", 1.0, 0.0);267 gfits_define_bintable_column (&theader, "D", "RA", "ra", "degree", 1.0, 0.0); 268 gfits_define_bintable_column (&theader, "D", "DEC", "dec", "degree", 1.0, 0.0); 269 269 gfits_define_bintable_column (&theader, "E", "MAG_SYS", "magnitude (sys)", NULL, 1.0, 0.0); 270 270 gfits_define_bintable_column (&theader, "E", "MAG_CAL", "magnitude (cal)", NULL, 1.0, 0.0); … … 274 274 gfits_define_bintable_column (&theader, "E", "Y_CCD", "ccd y coord", "pix", 1.0, 0.0); 275 275 gfits_define_bintable_column (&theader, "E", "EXPTIME", "-2.5 * log (exposure time)", "sec", 1.0, 0.0); 276 gfits_define_bintable_column (&theader, "J", "TIME", "time of exp", "sec", 1.0, 1.0*0x8000);277 gfits_define_bintable_column (&theader, "J", "AVE_REF", "pointer to average table", NULL, 1.0, 1.0*0x8000);278 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image", NULL, 1.0, 1.0*0x8000);279 gfits_define_bintable_column (&theader, "J", "DB_FLAGS", "flags", NULL, 1.0, 1.0*0x8000);280 gfits_define_bintable_column (&theader, "J", "PHOT_FLAGS", "photflags", NULL, 1.0, 1.0*0x8000);281 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog", NULL, 1.0, 1.0*0x8000);282 gfits_define_bintable_column (&theader, "I", "PHOTCODE", "photcode", NULL, 1.0, 1.0*0x80);276 gfits_define_bintable_column (&theader, "J", "TIME", "time of exp", "sec", 1.0, FT_BZERO_INT32); 277 gfits_define_bintable_column (&theader, "J", "AVE_REF", "pointer to average table", NULL, 1.0, FT_BZERO_INT32); 278 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image", NULL, 1.0, FT_BZERO_INT32); 279 gfits_define_bintable_column (&theader, "J", "DB_FLAGS", "flags", NULL, 1.0, FT_BZERO_INT32); 280 gfits_define_bintable_column (&theader, "J", "PHOT_FLAGS", "photflags", NULL, 1.0, FT_BZERO_INT32); 281 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog", NULL, 1.0, FT_BZERO_INT32); 282 gfits_define_bintable_column (&theader, "I", "PHOTCODE", "photcode", NULL, 1.0, FT_BZERO_INT16); 283 283 284 284 // generate the output array that carries the data … … 286 286 287 287 // create intermediate storage arrays 288 float *dR ; ALLOCATE (dR , float, catalog->Nmeasure);289 float *dD ; ALLOCATE (dD , float, catalog->Nmeasure);290 float *M ; ALLOCATE (M , float,catalog->Nmeasure);291 float *Mcal ; ALLOCATE (Mcal , float,catalog->Nmeasure);292 float *dM ; ALLOCATE (dM , float,catalog->Nmeasure);293 float *airmass ; ALLOCATE (airmass , float,catalog->Nmeasure);294 float *Xccd ; ALLOCATE (Xccd , float,catalog->Nmeasure);295 float *Yccd ; ALLOCATE (Yccd , float,catalog->Nmeasure);296 float *dt ; ALLOCATE (dt , float,catalog->Nmeasure);297 int *t ; ALLOCATE (t , int ,catalog->Nmeasure);298 int *averef ; ALLOCATE (averef , int ,catalog->Nmeasure);299 int *imageID ; ALLOCATE (imageID , int ,catalog->Nmeasure);300 int *dbFlags ; ALLOCATE (dbFlags , int ,catalog->Nmeasure);301 int *photFlags ; ALLOCATE (photFlags, int ,catalog->Nmeasure);302 int *catID ; ALLOCATE (catID , int ,catalog->Nmeasure);303 short *photcode ; ALLOCATE (photcode , short,catalog->Nmeasure);288 double *R ; ALLOCATE (R , double, catalog->Nmeasure); 289 double *D ; ALLOCATE (D , double, catalog->Nmeasure); 290 float *M ; ALLOCATE (M , float, catalog->Nmeasure); 291 float *Mcal ; ALLOCATE (Mcal , float, catalog->Nmeasure); 292 float *dM ; ALLOCATE (dM , float, catalog->Nmeasure); 293 float *airmass ; ALLOCATE (airmass , float, catalog->Nmeasure); 294 float *Xccd ; ALLOCATE (Xccd , float, catalog->Nmeasure); 295 float *Yccd ; ALLOCATE (Yccd , float, catalog->Nmeasure); 296 float *dt ; ALLOCATE (dt , float, catalog->Nmeasure); 297 int *t ; ALLOCATE (t , int , catalog->Nmeasure); 298 int *averef ; ALLOCATE (averef , int , catalog->Nmeasure); 299 int *imageID ; ALLOCATE (imageID , int , catalog->Nmeasure); 300 int *dbFlags ; ALLOCATE (dbFlags , int , catalog->Nmeasure); 301 int *photFlags ; ALLOCATE (photFlags, int , catalog->Nmeasure); 302 int *catID ; ALLOCATE (catID , int , catalog->Nmeasure); 303 short *photcode ; ALLOCATE (photcode , short, catalog->Nmeasure); 304 304 305 305 // assign the storage arrays 306 306 MeasureTiny *measure = catalog->measure; 307 307 for (i = 0; i < catalog->Nmeasure; i++) { 308 dR[i] = measure[i].dR ;309 dD[i] = measure[i].dD ;308 R[i] = measure[i].R ; 309 D[i] = measure[i].D ; 310 310 M[i] = measure[i].M ; 311 311 Mcal[i] = measure[i].Mcal ; … … 325 325 326 326 // add the columns to the output array 327 gfits_set_bintable_column (&theader, &ftable, "RA _OFF", dR,catalog->Nmeasure);328 gfits_set_bintable_column (&theader, &ftable, "DEC _OFF", dD,catalog->Nmeasure);327 gfits_set_bintable_column (&theader, &ftable, "RA", R, catalog->Nmeasure); 328 gfits_set_bintable_column (&theader, &ftable, "DEC", D, catalog->Nmeasure); 329 329 gfits_set_bintable_column (&theader, &ftable, "MAG_SYS", M, catalog->Nmeasure); 330 330 gfits_set_bintable_column (&theader, &ftable, "MAG_CAL", Mcal, catalog->Nmeasure); … … 342 342 gfits_set_bintable_column (&theader, &ftable, "PHOTCODE", photcode, catalog->Nmeasure); 343 343 344 free ( dR);345 free ( dD);344 free (R ); 345 free (D ); 346 346 free (M ); 347 347 free (Mcal ); … … 428 428 gfits_create_table_header (&theader, "BINTABLE", "SECFILT"); 429 429 430 gfits_define_bintable_column (&theader, "E", "MAG", " ra offset","arcsec", 1.0, 0.0);431 gfits_define_bintable_column (&theader, "E", "MAG_ERR", " dec offset","arcsec", 1.0, 0.0);432 gfits_define_bintable_column (&theader, "E", "MAG_CHI", " magnitude (sys)",NULL, 1.0, 0.0);433 gfits_define_bintable_column (&theader, "J", "FLAGS", " magnitude (cal)",NULL, 1.0, 0.0);434 gfits_define_bintable_column (&theader, "I", "NCODE", " magnitude (err)",NULL, 1.0, 0.0);435 gfits_define_bintable_column (&theader, "I", "NUSED", " airmass",NULL, 1.0, 0.0);436 gfits_define_bintable_column (&theader, " I", "MAG_20", "ccd x coord", "pix",1.0, 0.0);437 gfits_define_bintable_column (&theader, " I", "MAG_80", "ccd y coord", "pix",1.0, 0.0);430 gfits_define_bintable_column (&theader, "E", "MAG", "", "arcsec", 1.0, 0.0); 431 gfits_define_bintable_column (&theader, "E", "MAG_ERR", "", "arcsec", 1.0, 0.0); 432 gfits_define_bintable_column (&theader, "E", "MAG_CHI", "", NULL, 1.0, 0.0); 433 gfits_define_bintable_column (&theader, "J", "FLAGS", "", NULL, 1.0, 0.0); 434 gfits_define_bintable_column (&theader, "I", "NCODE", "", NULL, 1.0, 0.0); 435 gfits_define_bintable_column (&theader, "I", "NUSED", "", NULL, 1.0, 0.0); 436 gfits_define_bintable_column (&theader, "E", "MAG_MIN", "min valid mag", "mag", 1.0, 0.0); 437 gfits_define_bintable_column (&theader, "E", "MAG_MAX", "max valid mag", "mag", 1.0, 0.0); 438 438 439 439 // generate the output array that carries the data … … 447 447 float *M ; ALLOCATE (M , float, Nsec); 448 448 float *dM ; ALLOCATE (dM , float, Nsec); 449 float * Xm ; ALLOCATE (Xm, float, Nsec);449 float *Mchisq ; ALLOCATE (Mchisq , float, Nsec); 450 450 int *flags ; ALLOCATE (flags , int, Nsec); 451 451 short *Ncode ; ALLOCATE (Ncode , short, Nsec); 452 452 short *Nused ; ALLOCATE (Nused , short, Nsec); 453 short *M_20 ; ALLOCATE (M_20 , short, Nsec);454 short *M_80 ; ALLOCATE (M_80 , short, Nsec);453 float *Mmin ; ALLOCATE (Mmin , float, Nsec); 454 float *Mmax ; ALLOCATE (Mmax , float, Nsec); 455 455 456 456 // assign the storage arrays 457 457 SecFilt *secfilt = catalog->secfilt; 458 458 for (i = 0; i < Nsec; i++) { 459 M [i] = secfilt[i]. M ;460 dM [i] = secfilt[i]. dM ;461 Xm [i] = secfilt[i]. Xm;462 flags [i] = secfilt[i]. flags ;463 Ncode [i] = secfilt[i]. Ncode ;464 Nused [i] = secfilt[i]. Nused ;465 M _20 [i] = secfilt[i]. M_20;466 M _80 [i] = secfilt[i]. M_80;459 M [i] = secfilt[i].M ; 460 dM [i] = secfilt[i].dM ; 461 Mchisq[i] = secfilt[i].Mchisq ; 462 flags [i] = secfilt[i].flags ; 463 Ncode [i] = secfilt[i].Ncode ; 464 Nused [i] = secfilt[i].Nused ; 465 Mmin [i] = secfilt[i].Mmin ; 466 Mmax [i] = secfilt[i].Mmax ; 467 467 } 468 468 469 469 // add the columns to the output array 470 gfits_set_bintable_column (&theader, &ftable, "MAG", M , Nsec);471 gfits_set_bintable_column (&theader, &ftable, "MAG_ERR", dM , Nsec);472 gfits_set_bintable_column (&theader, &ftable, "MAG_CHI", Xm, Nsec);473 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags , Nsec);474 gfits_set_bintable_column (&theader, &ftable, "NCODE", Ncode , Nsec);475 gfits_set_bintable_column (&theader, &ftable, "NUSED", Nused , Nsec);476 gfits_set_bintable_column (&theader, &ftable, "MAG_ 20", M_20, Nsec);477 gfits_set_bintable_column (&theader, &ftable, "MAG_ 80", M_80, Nsec);470 gfits_set_bintable_column (&theader, &ftable, "MAG", M , Nsec); 471 gfits_set_bintable_column (&theader, &ftable, "MAG_ERR", dM , Nsec); 472 gfits_set_bintable_column (&theader, &ftable, "MAG_CHI", Mchisq, Nsec); 473 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags , Nsec); 474 gfits_set_bintable_column (&theader, &ftable, "NCODE", Ncode , Nsec); 475 gfits_set_bintable_column (&theader, &ftable, "NUSED", Nused , Nsec); 476 gfits_set_bintable_column (&theader, &ftable, "MAG_MIN", Mmin , Nsec); 477 gfits_set_bintable_column (&theader, &ftable, "MAG_MAX", Mmax , Nsec); 478 478 479 479 free (M ); 480 480 free (dM ); 481 free ( Xm);481 free (Mchisq ); 482 482 free (flags ); 483 483 free (Ncode ); 484 484 free (Nused ); 485 free (M _20);486 free (M _80);485 free (Mmin ); 486 free (Mmax ); 487 487 488 488 gfits_fwrite_Theader (f, &theader); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/GridOps.c
r34088 r37403 414 414 // select the color- and airmass-corrected observed magnitude for this star 415 415 // XXX need to be able to turn off the color-correction until initial average mags are found 416 Msys = PhotCatTiny (&catalog[c].measureT[m] );416 Msys = PhotCatTiny (&catalog[c].measureT[m], MAG_CLASS_PSF); 417 417 if (isnan(Msys)) { 418 418 Nsys++; … … 573 573 574 574 n = catalog[c].measureT[m].averef; 575 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt] );575 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt], MAG_CLASS_PSF); 576 576 if (isnan(Msys)) { 577 577 Nsys++; … … 651 651 652 652 n = catalog[c].measureT[m].averef; 653 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt] );653 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt], MAG_CLASS_PSF); 654 654 655 655 xlist[N] = Xmeas[c][m]; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/ImageMagIO.c
r36680 r37403 61 61 GET_COLUMN (dMcal, "MCAL_ERR", float); 62 62 GET_COLUMN (dMagSys, "MCAL_SYSERR", float); 63 GET_COLUMN (Xm, "CHISQ", float);64 63 GET_COLUMN (nFitPhotom, "NFIT", int); 65 64 GET_COLUMN (flags, "FLAGS", int); 66 65 GET_COLUMN (ubercalDist, "UDIST", int); 67 66 GET_COLUMN (imageID, "ID", int); 67 GET_COLUMN (Xm, "CHISQ", short); 68 68 69 69 // free the memory associated with the FITS files … … 121 121 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_MAGS"); 122 122 123 gfits_define_bintable_column (&theader, "E", "MCAL", "cal offset", "magnitudes", 1.0, 0.0);124 gfits_define_bintable_column (&theader, "E", "MCAL_ERR", "cal error", "magnitudes", 1.0, 0.0);125 gfits_define_bintable_column (&theader, "E", "MCAL_SYSERR", "systematic error", "magnitudes", 1.0, 0.0);126 gfits_define_bintable_column (&theader, " E", "CHISQ", "cal chisq", "unitless",1.0, 0.0);127 gfits_define_bintable_column (&theader, "J", " NFIT", "number of fitted stars", "unitless",1.0, 0.0);128 gfits_define_bintable_column (&theader, "J", " FLAGS", "analysis flags", "unitless",1.0, 0.0);129 gfits_define_bintable_column (&theader, "J", " UDIST", "distance to ubercal images", "images",1.0, 0.0);130 gfits_define_bintable_column (&theader, " J", "ID", "image ID", "unitless", 1.0, 0.0);123 gfits_define_bintable_column (&theader, "E", "MCAL", "cal offset", "magnitudes", 1.0, 0.0); 124 gfits_define_bintable_column (&theader, "E", "MCAL_ERR", "cal error", "magnitudes", 1.0, 0.0); 125 gfits_define_bintable_column (&theader, "E", "MCAL_SYSERR", "systematic error", "magnitudes", 1.0, 0.0); 126 gfits_define_bintable_column (&theader, "J", "NFIT", "number of fitted stars", "unitless", 1.0, 0.0); 127 gfits_define_bintable_column (&theader, "J", "FLAGS", "analysis flags", "unitless", 1.0, 0.0); 128 gfits_define_bintable_column (&theader, "J", "UDIST", "distance to ubercal images", "images", 1.0, 0.0); 129 gfits_define_bintable_column (&theader, "J", "ID", "image ID", "unitless", 1.0, 0.0); 130 gfits_define_bintable_column (&theader, "I", "CHISQ", "cal chisq", "unitless", 1.0, FT_BZERO_INT16); 131 131 132 132 // generate the output array that carries the data -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/ImageOps.c
r36680 r37403 495 495 } 496 496 497 // returns image.Mcal - ff(x,y) 498 int FindImageSkycellID (off_t meas, int cat, int *myTessID, int *myProjectionID, int *mySkycellID) { 499 500 off_t i; 501 502 if (!MeasureToImage) return FALSE; 503 504 if (meas < 0) return FALSE; 505 506 i = MeasureToImage[cat][meas]; 507 if (i == -1) return FALSE; 508 509 if (tessID[i] == -1) return FALSE; 510 if (projectID[i] == -1) return FALSE; 511 if (skycellID[i] == -1) return FALSE; 512 513 *myTessID = tessID[i]; 514 *myProjectionID = projectID[i]; 515 *mySkycellID = skycellID[i]; 516 517 return TRUE; 518 } 519 497 520 float getMflat (off_t meas, int cat, FlatCorrectionTable *flatcorr, Catalog *catalog) { 498 521 … … 531 554 liststats_setmode (&stats, STATMODE); 532 555 533 if (FREEZE_IMAGES) return;556 // FREEZE_IMAGES only applies to mosaic data (eg, gpc1) 534 557 535 558 fprintf (stderr, "limiting negative clouds to %f\n", CLOUD_TOLERANCE); … … 561 584 if (!bad) continue; 562 585 } 586 587 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 563 588 564 589 // UBERCAL image: if this is an ubercal image, set minUbercalDist to 0: … … 608 633 609 634 n = catalog[c].measureT[m].averef; 610 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt] );635 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt], MAG_CLASS_PSF); 611 636 if (isnan(Msys)) { 612 637 Nsys++; … … 695 720 double MaxOffset, MaxScatter, MedOffset; 696 721 697 if (FREEZE_IMAGES) return;722 // if (FREEZE_IMAGES) return; 698 723 699 724 if (VERBOSE) fprintf (stderr, "marking poor images\n"); … … 706 731 for (i = N = 0; i < Nimage; i++) { 707 732 if (image[i].flags & IMAGE_BAD) continue; 733 734 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 735 708 736 mlist[N] = image[i].Mcal; 709 737 slist[N] = image[i].dMcal; … … 797 825 Graphdata graphdata; 798 826 799 if (FREEZE_IMAGES) return;827 // if (FREEZE_IMAGES) return; 800 828 801 829 ALLOCATE (xlist, double, Nimage); … … 810 838 float mindMcal = +100.0; 811 839 float maxdMcal = -100.0; 812 for (i = 0; i < Nimage; i++) { 813 Mlist[i] = image[i].Mcal; 814 dlist[i] = image[i].dMcal; 815 xlist[i] = image[i].secz; 840 841 int Nplot = 0; 842 843 for (i = 0; i < Nimage; i++) { 844 845 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 846 847 Mlist[Nplot] = image[i].Mcal; 848 dlist[Nplot] = image[i].dMcal; 849 xlist[Nplot] = image[i].secz; 816 850 minAirmass = MIN (image[i].secz, minAirmass); 817 851 maxAirmass = MAX (image[i].secz, maxAirmass); … … 820 854 mindMcal = MIN (image[i].dMcal, mindMcal); 821 855 maxdMcal = MAX (image[i].dMcal, maxdMcal); 856 857 Nplot ++; 822 858 } 823 859 … … 852 888 for (i = 0; i < NBIN; i++) xlist[i] = 0.00025*i; 853 889 bzero (Mlist, NBIN*sizeof(double)); 854 for (i = 0; i < Nimage; i++) { 890 891 for (i = 0; i < Nimage; i++) { 892 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 893 855 894 bin = image[i].dMcal / 0.00025; 856 895 bin = MAX (0, MIN (NBIN - 1, bin)); … … 877 916 StatType stats; 878 917 bzero (&stats, sizeof (StatType)); 879 if (FREEZE_IMAGES) return (stats); 918 919 // we no longer blindly apply FREEZE_IMAGES to all images, only to mosaics 920 // if (FREEZE_IMAGES) return (stats); 880 921 881 922 ALLOCATE (list, double, Nimage); … … 885 926 for (i = 0; i < Nimage; i++) { 886 927 if (image[i].flags & IMAGE_BAD) continue; 928 929 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 887 930 888 931 N = 0; … … 920 963 921 964 bzero (&stats, sizeof (StatType)); 922 if (FREEZE_IMAGES) return (stats);965 // if (FREEZE_IMAGES) return (stats); 923 966 924 967 ALLOCATE (list, double, Nimage); … … 929 972 930 973 if (image[i].flags & IMAGE_BAD) continue; 974 975 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 931 976 932 977 list[n] = pow (10.0, 0.01*image[i].Xm); … … 950 995 951 996 bzero (&stats, sizeof (StatType)); 952 if (FREEZE_IMAGES) return (stats);997 // if (FREEZE_IMAGES) return (stats); 953 998 954 999 ALLOCATE (list, double, Nimage); … … 959 1004 960 1005 if (image[i].flags & IMAGE_BAD) continue; 1006 1007 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 961 1008 962 1009 list[n] = image[i].Mcal; … … 980 1027 981 1028 bzero (&stats, sizeof (StatType)); 982 if (FREEZE_IMAGES) return (stats);1029 // if (FREEZE_IMAGES) return (stats); 983 1030 984 1031 ALLOCATE (list, double, Nimage); … … 989 1036 990 1037 if (image[i].flags & IMAGE_BAD) continue; 1038 1039 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 991 1040 992 1041 list[n] = image[i].dMcal; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/ImageSubset.c
r36680 r37403 126 126 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_SUBSET"); 127 127 128 gfits_define_bintable_column (&theader, "E", "MCAL", "zero point offset", "magnitudes", 1.0, 0.0); 129 gfits_define_bintable_column (&theader, "E", "MCAL_ERR", "zero point error", "magnitudes", 1.0, 0.0); 130 131 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image ID", NULL, 1.0, 1.0*0x8000); 132 gfits_define_bintable_column (&theader, "J", "PHOTOM_MAP", "map", NULL, 1.0, 1.0*0x8000); 133 gfits_define_bintable_column (&theader, "J", "FLAGS", "flags", NULL, 1.0, 1.0*0x8000); 134 135 gfits_define_bintable_column (&theader, "J", "TESS_ID", "ID", NULL, 1.0, 0.0); 136 gfits_define_bintable_column (&theader, "J", "PROJ_ID", "ID", NULL, 1.0, 0.0); 137 gfits_define_bintable_column (&theader, "J", "SKYCELL_ID", "ID", NULL, 1.0, 0.0); 138 139 gfits_define_bintable_column (&theader, "J", "TZERO", "exposure start", NULL, 1.0, 1.0*0x8000); 140 gfits_define_bintable_column (&theader, "I", "TRATE", "tti rate", NULL, 1.0, 0.0); 141 142 gfits_define_bintable_column (&theader, "I", "UBERCAL_DIST", "ubercal distance", NULL, 1.0, 1.0*0x80); 128 gfits_define_bintable_column (&theader, "E", "MCAL", "zero point offset", "magnitudes", 1.0, 0.0); 129 gfits_define_bintable_column (&theader, "E", "MCAL_ERR", "zero point error", "magnitudes", 1.0, 0.0); 130 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image ID", NULL, 1.0, FT_BZERO_INT32); 131 gfits_define_bintable_column (&theader, "J", "PHOTOM_MAP", "map", NULL, 1.0, FT_BZERO_INT32); 132 gfits_define_bintable_column (&theader, "J", "FLAGS", "flags", NULL, 1.0, FT_BZERO_INT32); 133 gfits_define_bintable_column (&theader, "J", "TESS_ID", "ID", NULL, 1.0, 0.0); 134 gfits_define_bintable_column (&theader, "J", "PROJ_ID", "ID", NULL, 1.0, 0.0); 135 gfits_define_bintable_column (&theader, "J", "SKYCELL_ID", "ID", NULL, 1.0, 0.0); 136 gfits_define_bintable_column (&theader, "J", "TZERO", "exposure start", NULL, 1.0, FT_BZERO_INT32); 137 gfits_define_bintable_column (&theader, "I", "TRATE", "tti rate", NULL, 1.0, FT_BZERO_INT16); 138 gfits_define_bintable_column (&theader, "I", "UBERCAL_DIST", "ubercal distance", NULL, 1.0, 0.0); 143 139 144 140 // generate the output array that carries the data … … 152 148 153 149 // create intermediate storage arrays 154 ALLOCATE (Mcal, float, Nimage);155 ALLOCATE (dMcal, float, Nimage);150 ALLOCATE (Mcal, float, Nimage); 151 ALLOCATE (dMcal, float, Nimage); 156 152 ALLOCATE (imageID, unsigned int, Nimage); 157 153 ALLOCATE (map, unsigned int, Nimage); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/MeanMagIO.c
r36680 r37403 60 60 GET_COLUMN (M, "MAG", float); 61 61 GET_COLUMN (dM, "MAG_ERR", float); 62 GET_COLUMN ( Xm,"MAG_CHISQ", float);62 GET_COLUMN (Mchisq, "MAG_CHISQ", float); 63 63 GET_COLUMN (Nsec, "NSEC", int); 64 64 GET_COLUMN (objID, "OBJ_ID", int); … … 73 73 ALLOCATE (meanmags, MeanMag, Nrow); 74 74 for (i = 0; i < Nrow; i++) { 75 meanmags[i].M = M [i];76 meanmags[i].dM = dM [i];77 meanmags[i]. Xm = Xm[i];78 meanmags[i].Nsec = Nsec [i];79 meanmags[i].objID = objID [i];80 meanmags[i].catID = catID [i];75 meanmags[i].M = M [i]; 76 meanmags[i].dM = dM [i]; 77 meanmags[i].Mchisq = Mchisq [i]; 78 meanmags[i].Nsec = Nsec [i]; 79 meanmags[i].objID = objID [i]; 80 meanmags[i].catID = catID [i]; 81 81 } 82 82 fprintf (stderr, "loaded data for %lld objects (* filters)\n", (long long) Nrow); 83 83 84 free (M );85 free (dM );86 free ( Xm);87 free (Nsec );88 free (objID );89 free (catID );84 free (M ); 85 free (dM ); 86 free (Mchisq); 87 free (Nsec ); 88 free (objID ); 89 free (catID ); 90 90 91 91 *nmeanmags = Nrow; … … 118 118 gfits_define_bintable_column (&theader, "E", "MAG_ERR", "mean magnitude error", "magnitudes", 1.0, 0.0); 119 119 gfits_define_bintable_column (&theader, "E", "MAG_CHISQ", "mean magnitude chisq", "unitless", 1.0, 0.0); 120 gfits_define_bintable_column (&theader, "J", "NSEC", "secfilt sequence", NULL, 1.0, 1.0*0x8000);121 gfits_define_bintable_column (&theader, "J", "OBJ_ID", "object ID", NULL, 1.0, 1.0*0x8000);122 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog ID", NULL, 1.0, 1.0*0x8000);120 gfits_define_bintable_column (&theader, "J", "NSEC", "secfilt sequence", NULL, 1.0, FT_BZERO_INT32); 121 gfits_define_bintable_column (&theader, "J", "OBJ_ID", "object ID", NULL, 1.0, FT_BZERO_INT32); 122 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog ID", NULL, 1.0, FT_BZERO_INT32); 123 123 124 124 // generate the output array that carries the data 125 125 gfits_create_table (&theader, &ftable); 126 126 127 float *M, *dM, * Xm;127 float *M, *dM, *Mchisq; 128 128 int *Nsec; 129 129 unsigned int *objID, *catID; … … 132 132 ALLOCATE (M, float, Nmeanmags); 133 133 ALLOCATE (dM, float, Nmeanmags); 134 ALLOCATE ( Xm,float, Nmeanmags);134 ALLOCATE (Mchisq, float, Nmeanmags); 135 135 ALLOCATE (Nsec, int, Nmeanmags); 136 136 ALLOCATE (objID, unsigned int, Nmeanmags); … … 139 139 // assign the storage arrays 140 140 for (i = 0; i < Nmeanmags; i++) { 141 M [i] = meanmags[i].M;142 dM [i] = meanmags[i].dM;143 Xm [i] = meanmags[i].Xm;144 Nsec [i] = meanmags[i].Nsec;145 objID [i] = meanmags[i].objID;146 catID [i] = meanmags[i].catID;141 M [i] = meanmags[i].M ; 142 dM [i] = meanmags[i].dM ; 143 Mchisq[i] = meanmags[i].Mchisq; 144 Nsec [i] = meanmags[i].Nsec ; 145 objID [i] = meanmags[i].objID ; 146 catID [i] = meanmags[i].catID ; 147 147 } 148 148 … … 150 150 gfits_set_bintable_column (&theader, &ftable, "MAG", M, Nmeanmags); 151 151 gfits_set_bintable_column (&theader, &ftable, "MAG_ERR", dM, Nmeanmags); 152 gfits_set_bintable_column (&theader, &ftable, "MAG_CHISQ", Xm,Nmeanmags);152 gfits_set_bintable_column (&theader, &ftable, "MAG_CHISQ", Mchisq, Nmeanmags); 153 153 gfits_set_bintable_column (&theader, &ftable, "NSEC", Nsec, Nmeanmags); 154 154 gfits_set_bintable_column (&theader, &ftable, "OBJ_ID", objID, Nmeanmags); 155 155 gfits_set_bintable_column (&theader, &ftable, "CAT_ID", catID, Nmeanmags); 156 156 157 free (M );158 free (dM );159 free ( Xm);160 free (Nsec );161 free (objID );162 free (catID );157 free (M ); 158 free (dM ); 159 free (Mchisq); 160 free (Nsec ); 161 free (objID ); 162 free (catID ); 163 163 164 164 FILE *f = fopen (filename, "w"); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/MosaicOps.c
r36680 r37403 1 1 # include "relphot.h" 2 2 void plot_setMcal (double *list, int Npts, StatType *stats, float clouds); 3 off_t findMosaic (unsigned int *startTimes, off_t Nmosaic, unsigned int start); 3 4 4 5 // see discussion in ImagesOps.c re: IDX_T … … 36 37 // MosaicN_image was 'Nimlist' 37 38 // MosaicToImage was 'imlist' 39 40 void sort_times (unsigned int *T, int N) { 41 42 # define SWAPFUNC(A,B){ unsigned int tmp; \ 43 tmp = T[A]; T[A] = T[B]; T[B] = tmp; \ 44 } 45 # define COMPARE(A,B)(T[A] < T[B]) 46 47 OHANA_SORT (N, COMPARE, SWAPFUNC); 48 49 # undef SWAPFUNC 50 # undef COMPARE 51 52 } 38 53 39 54 /* find mosaic frames (unique time periods & photcode name matches mosaic) */ … … 96 111 97 112 /* a new mosaic, define ranges -- preserve the original values incase this image is not used */ 98 mosaic[Nmosaic].start = start;99 mosaic[Nmosaic].stop = stop;100 mosaic[Nmosaic].Mcal = 0.0; // note : mosaic stores only offsets relative to the original image values101 mosaic[Nmosaic].dMcal = 0.0; // note : at the end, mosaic.Mcal is added back to the input images102 mosaic[Nmosaic].dMsys = 0.0;103 mosaic[Nmosaic].Xm = 0.0;113 mosaic[Nmosaic].start = start; 114 mosaic[Nmosaic].stop = stop; 115 mosaic[Nmosaic].Mcal = 0.0; // note : mosaic stores only offsets relative to the original image values 116 mosaic[Nmosaic].dMcal = 0.0; // note : at the end, mosaic.Mcal is added back to the input images 117 mosaic[Nmosaic].dMsys = 0.0; 118 mosaic[Nmosaic].Xm = 0.0; 104 119 mosaic[Nmosaic].flags = image[i].flags; 105 mosaic[Nmosaic].secz = image[i].secz;120 mosaic[Nmosaic].secz = image[i].secz; 106 121 mosaic[Nmosaic].photcode = GetPhotcodeEquivCodebyCode (image[i].photcode); 107 122 … … 136 151 } 137 152 138 off_t findMosaic (unsigned int *startTimes, off_t Nmosaic, unsigned int start);139 140 void sort_times (unsigned int *T, int N) {141 142 # define SWAPFUNC(A,B){ unsigned int tmp; \143 tmp = T[A]; T[A] = T[B]; T[B] = tmp; \144 }145 # define COMPARE(A,B)(T[A] < T[B])146 147 OHANA_SORT (N, COMPARE, SWAPFUNC);148 149 # undef SWAPFUNC150 # undef COMPARE151 152 }153 154 153 /* find mosaic frames (unique time periods) (NOTE : we do NOT require matching photcodes...) 155 154 this function will also identify the images NOT in the subset which belong to a selected mosaic … … 157 156 void initMosaics (Image *subset, off_t Nsubset, Image *image, char *inSubset, off_t Nimage) { 158 157 159 off_t i, j, status,found, NMOSAIC, *MosaicN_IMAGE;158 off_t i, j, found, NMOSAIC, *MosaicN_IMAGE; 160 159 unsigned int start, stop, *startTimes, *startTimesMosaic; 161 char *pname;162 160 163 161 if (!MOSAIC_ZEROPT) return; … … 172 170 // generate a list of all subset image start times 173 171 ALLOCATE (startTimes, unsigned int, Nsubset); 172 int Nmoschip = 0; 174 173 for (i = 0; i < Nsubset; i++) { 175 startTimes[i] = subset[i].tzero; 176 } 177 sort_times (startTimes, Nsubset); 174 if (!isGPC1chip(subset[i].photcode)) continue; 175 startTimes[Nmoschip] = subset[i].tzero; 176 Nmoschip ++; 177 } 178 sort_times (startTimes, Nmoschip); 178 179 MARKTIME("create array of all image obstimes: %f sec\n", dtime); 179 180 … … 184 185 185 186 // generate a list of the unique start times (these define the mosaics) 186 for (i = 0; i < Nsubset; i++) { 187 if (startTimes[i] < startTimesMosaic[Nmosaic]) { 188 fprintf (stderr, "error?\n"); 189 abort(); 190 } 187 for (i = 0; i < Nmoschip; i++) { 188 myAssert (startTimes[i] >= startTimesMosaic[Nmosaic], "times out of order?"); 191 189 if (startTimes[i] == startTimesMosaic[Nmosaic]) continue; 192 190 Nmosaic ++; … … 210 208 for (i = 0; i < Nmosaic; i++) { 211 209 /* a new mosaic, define ranges */ 212 mosaic[i].start = startTimesMosaic[i];213 mosaic[i].stop = 0;214 mosaic[i].Mcal = 0.0;215 mosaic[i].dMcal = 0.0;216 mosaic[i].dMsys = 0.0;217 mosaic[i].Xm = 0.0;218 mosaic[i].flags = 0;219 mosaic[i].secz = NAN;210 mosaic[i].start = startTimesMosaic[i]; 211 mosaic[i].stop = 0; 212 mosaic[i].Mcal = 0.0; 213 mosaic[i].dMcal = 0.0; 214 mosaic[i].dMsys = 0.0; 215 mosaic[i].Xm = 0.0; 216 mosaic[i].flags = 0; 217 mosaic[i].secz = NAN; 220 218 mosaic[i].photcode = 0; 221 mosaic[i].skipCal = FALSE;219 mosaic[i].skipCal = FALSE; 222 220 223 221 memset (&mosaic[i].coords, 0, sizeof(Coords)); … … 238 236 } 239 237 240 /* select valid mosaic images by photcode */ 241 pname = GetPhotcodeNamebyCode (image[i].photcode); 242 if (!pname) continue; 243 status = strncmp (pname, MOSAICNAME, strlen (MOSAICNAME)); 244 if (status) continue; 238 if (!isGPC1chip(image[i].photcode)) continue; 245 239 246 240 /* set image time range */ … … 262 256 263 257 // assign each image to a mosaic 258 int Nsimple = 0; 264 259 for (i = 0; i < Nsubset; i++) { 265 260 ImageToMosaic[i] = -1; 266 261 267 /* select valid mosaic images by photcode */268 pname = GetPhotcodeNamebyCode (subset[i].photcode);269 status = strncmp (pname, MOSAICNAME, strlen (MOSAICNAME));270 if (status) continue;262 if (!isGPC1chip(subset[i].photcode)) { 263 Nsimple ++; 264 continue; 265 } 271 266 272 267 start = subset[i].tzero; … … 299 294 abort(); 300 295 } 301 mosaic[j].stop = stop;302 mosaic[j].Mcal = 0.0;303 mosaic[j].dMcal = 0.0;304 mosaic[j].Xm = 0.0;305 mosaic[j].dMsys = subset[i].flags;306 mosaic[j].flags = subset[i].flags;307 mosaic[j].secz = subset[i].secz;296 mosaic[j].stop = stop; 297 mosaic[j].Mcal = 0.0; 298 mosaic[j].dMcal = 0.0; 299 mosaic[j].Xm = 0.0; 300 mosaic[j].dMsys = subset[i].flags; 301 mosaic[j].flags = subset[i].flags; 302 mosaic[j].secz = subset[i].secz; 308 303 mosaic[j].photcode = GetPhotcodeEquivCodebyCode (subset[i].photcode); 309 304 } … … 316 311 initMosaicGrid (subset, Nsubset); 317 312 318 fprintf (stderr, "matched %d images to %d mosaics \n", (int) Nsubset, (int) Nmosaic);313 fprintf (stderr, "matched %d images to %d mosaics, %d simple chips not matched to mosaics\n", (int) (Nsubset - Nsimple), (int) Nmosaic, (int) Nsimple); 319 314 return; 320 315 } 321 316 322 /* find mosaic frames (unique time periods) (NOTE : we do NOT require matching photcodes but we 323 match images by MOSAICNAME. this last point is weak: it forces a single camera at a time. 324 we can extend the logic to multiple cameras if we make list of MOSAICNAMES (better to assign a camera ID) 317 /* find mosaic frames (unique time periods) (NOTE : require gpc1 chips, which is pretty limiting) 318 if mergeMcal is TRUE, <image.Mcal> values will be saved on Mosaic.Mcal 325 319 */ 326 void makeMosaics (Image *image, off_t Nimage ) {327 328 off_t i, j, status,found, NMOSAIC, *MosaicN_IMAGE;320 void makeMosaics (Image *image, off_t Nimage, int mergeMcal) { 321 322 off_t i, j, found, NMOSAIC, *MosaicN_IMAGE; 329 323 unsigned int start, stop, *startTimes, *startTimesMosaic; 330 char *pname;331 324 332 325 if (!MOSAIC_ZEROPT) return; … … 341 334 // generate a list of all image start times 342 335 ALLOCATE (startTimes, unsigned int, Nimage); 336 int Nmoschip = 0; 343 337 for (i = 0; i < Nimage; i++) { 344 startTimes[i] = image[i].tzero; 345 } 346 sort_times (startTimes, Nimage); 338 if (!isGPC1chip(image[i].photcode)) continue; 339 startTimes[Nmoschip] = image[i].tzero; 340 Nmoschip ++; 341 } 342 sort_times (startTimes, Nmoschip); 347 343 MARKTIME("create array of all image obstimes: %f sec\n", dtime); 348 344 … … 353 349 354 350 // generate a list of the unique start times (these define the mosaics) 355 for (i = 0; i < Nimage; i++) { 356 if (startTimes[i] < startTimesMosaic[Nmosaic]) { 357 fprintf (stderr, "error?\n"); 358 abort(); 359 } 351 for (i = 0; i < Nmoschip; i++) { 352 myAssert (startTimes[i] >= startTimesMosaic[Nmosaic], "times out of order?"); 360 353 if (startTimes[i] == startTimesMosaic[Nmosaic]) continue; 361 354 Nmosaic ++; … … 379 372 // init the mosaic array values 380 373 for (i = 0; i < Nmosaic; i++) { 381 mosaic[i].start = startTimesMosaic[i];382 mosaic[i].stop = 0;383 mosaic[i].Mcal = 0.0;384 mosaic[i].dMcal = 0.0;385 mosaic[i].dMsys = 0.0;386 mosaic[i].Xm = 0.0;387 mosaic[i].flags = 0;388 mosaic[i].secz = NAN;374 mosaic[i].start = startTimesMosaic[i]; 375 mosaic[i].stop = 0; 376 mosaic[i].Mcal = 0.0; 377 mosaic[i].dMcal = 0.0; 378 mosaic[i].dMsys = 0.0; 379 mosaic[i].Xm = 0.0; 380 mosaic[i].flags = 0; 381 mosaic[i].secz = NAN; 389 382 mosaic[i].photcode = 0; 390 mosaic[i].skipCal = FALSE;383 mosaic[i].skipCal = FALSE; 391 384 392 385 memset (&mosaic[i].coords, 0, sizeof(Coords)); … … 401 394 402 395 // assign each image to a mosaic 396 int Nsimple = 0; 403 397 for (i = 0; i < Nimage; i++) { 404 398 ImageToMosaic[i] = -1; 405 399 406 /* select valid mosaic images by photcode */ 407 pname = GetPhotcodeNamebyCode (image[i].photcode); 408 if (!pname) continue; 409 410 status = strncmp (pname, MOSAICNAME, strlen (MOSAICNAME)); 411 if (status) continue; 400 if (!isGPC1chip(image[i].photcode)) { 401 Nsimple ++; 402 continue; 403 } 412 404 413 405 start = image[i].tzero; … … 440 432 abort(); 441 433 } 442 mosaic[j].stop = stop;443 mosaic[j].Mcal = 0.0;444 mosaic[j].dMcal = 0.0;445 mosaic[j].Xm = 0.0;446 mosaic[j].dMsys = image[i].flags;447 mosaic[j].flags = image[i].flags;448 mosaic[j].secz = image[i].secz;434 mosaic[j].stop = stop; 435 mosaic[j].Mcal = 0.0; 436 mosaic[j].dMcal = 0.0; 437 mosaic[j].Xm = 0.0; 438 mosaic[j].dMsys = image[i].flags; 439 mosaic[j].flags = image[i].flags; 440 mosaic[j].secz = image[i].secz; 449 441 mosaic[j].photcode = GetPhotcodeEquivCodebyCode (image[i].photcode); 450 442 } … … 456 448 free (startTimesMosaic); 457 449 450 if (mergeMcal) { 451 initMosaicGrid (image, Nimage); 452 } 453 458 454 fprintf (stderr, "matched %d images to %d mosaics\n", (int) Nimage, (int) Nmosaic); 459 460 455 return; 461 456 } … … 513 508 off_t i, j, m, NX, NY, NC, Nc; 514 509 double R, D, Rmid, Dmid; 515 double Mcal, dMcal, Xm;516 510 double *Rc, *Dc; 517 511 … … 523 517 Nc = 0; 524 518 Rmid = Dmid = NAN; 525 Mcal = dMcal = Xm = 0;526 519 for (j = 0; j < MosaicN_Image[i]; j++) { 527 520 m = MosaicToImage[i][j]; … … 563 556 REALLOCATE (Dc, double, NC); 564 557 } 565 566 Mcal += image[m].Mcal;567 dMcal += image[m].dMcal;568 Xm += image[m].Xm;569 570 // for ubercal images, we (elsewhere) keep Mcal frozen571 572 /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */573 image[m].Mcal = 0.0;574 image[m].dMcal = NAN;575 image[m].Xm = NAN_S_SHORT;576 558 } 577 559 … … 617 599 mosaic[i].coords.pc2_1 = 0.0; 618 600 619 mosaic[i].Mcal = Mcal / MosaicN_Image[i];620 mosaic[i].dMcal = dMcal / MosaicN_Image[i];621 mosaic[i].Xm = Xm / MosaicN_Image[i];601 mosaic[i].Mcal = 0.0; 602 mosaic[i].dMcal = 0.0; 603 mosaic[i].Xm = 0.0; 622 604 } 623 605 return; … … 635 617 double R, D, Rmin, Rmax, Dmin, Dmax; 636 618 double Mcal, dMcal, Xm; 619 620 fprintf (stderr, "*** moving Mcal from image.Mcal to mosaic.Mcal ***\n"); 637 621 638 622 dXmax = dYmax = 0.0; … … 667 651 Dmin = MIN (Dmin, D); 668 652 Dmax = MAX (Dmax, D); 653 654 /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */ 655 656 // XXX: how does this work with UBERCAL? We want to keep the Mcal values supplied by ubercal, but 657 // solve for a single offset for each exposure (Mosaic.Mcal). 658 // we also want to keep the flat-field terms for each exposure (regardless of ubercal or not) 659 // if it helps, note that ubercal uses a single zp per exposure, so the mean of those values is the same as the value 660 669 661 Mcal += image[m].Mcal; 670 662 dMcal += image[m].dMcal; 671 663 Xm += image[m].Xm; 672 664 673 // XXX: how does this work with UBERCAL? We want to keep the Mcal values supplied by ubercal, but 674 // solve for a single offset for each exposure (Mosaic.Mcal). 675 676 // we also want to keep the flat-field terms for each exposure (regardless of ubercal or not) 677 678 // if it helps, note that ubercal uses a single zp per exposure, so the mean of those values is the same as the value 679 680 /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */ 681 image[m].Mcal = 0.0; 682 image[m].dMcal = NAN; 683 image[m].Xm = NAN_S_SHORT; 665 image[m].Mcal = 0.0; 666 image[m].dMcal = NAN; 667 image[m].Xm = NAN_S_SHORT; 684 668 } 685 669 dS /= MosaicN_Image[i]; … … 697 681 RD_to_XY (&dX, &dY, Rmax, Dmax, &mosaic[i].coords); 698 682 699 mosaic[i].Mcal = Mcal / MosaicN_Image[i];700 mosaic[i].dMcal = dMcal / MosaicN_Image[i];701 mosaic[i].Xm = Xm / MosaicN_Image[i];683 mosaic[i].Mcal = Mcal / MosaicN_Image[i]; 684 mosaic[i].dMcal = dMcal / MosaicN_Image[i]; 685 mosaic[i].Xm = Xm / MosaicN_Image[i]; 702 686 } 703 687 if (!USE_GRID) return; … … 709 693 } 710 694 711 // XXX : what about mosaics with skipCal == TRUE?712 695 void setMcalFinal () { 713 696 … … 719 702 image = getimages (&Nimage, NULL); 720 703 721 // XXX I think this is OK in the ubercal context, but probably need to skip UBERCAL 722 // images? (no need to update them) 704 fprintf (stderr, "*** return Mcal from mosaic.Mcal to image.Mcal ***\n"); 723 705 724 706 // copy the mosaic results to the images. set the mosaic Mcal to 0.0 since we have moved its … … 840 822 mosID = ImageToMosaic[idx]; 841 823 if (mosID < 0) { 842 Image *image = getimage(idx); 843 fprintf (stderr, "unmatched image %s\n", image[0].name); 824 // Image *image = getimage(idx); 825 // fprintf (stderr, "unmatched image %s\n", image[0].name); 826 // skip measurements from simple chips (not matched to a mosaic by definition) 844 827 return; 845 828 } … … 882 865 if (!MOSAIC_ZEROPT) return (0); 883 866 867 // unassigned measurements belong to simple chips 884 868 i = MeasureToMosaic[cat][meas]; 885 if (i == -1) return ( NAN);869 if (i == -1) return (0.0); 886 870 887 871 if (mosaic[i].flags & IMAGE_BAD) return (NAN); … … 1127 1111 1128 1112 off_t n = catalog[c].measureT[m].averef; 1129 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt] );1113 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt], MAG_CLASS_PSF); 1130 1114 1131 1115 float delta = Msys - Mrel - Mcal - Mgrid + Mflat; … … 1164 1148 1165 1149 off_t n = catalog[c].measureT[m].averef; 1166 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt] );1150 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt], MAG_CLASS_PSF); 1167 1151 if (isnan(Msys)) { 1168 1152 info->Nsys++; … … 1239 1223 1240 1224 if (testImage) { 1241 fprintf (stderr, "%f %f : % d %f\n", myMosaic[0].Mcal, myMosaic[0].dMsys, myMosaic[0].Xm, pow(10.0, 0.01*myMosaic[0].Xm));1225 fprintf (stderr, "%f %f : %f\n", myMosaic[0].Mcal, myMosaic[0].dMsys, pow (10.0, 0.01*myMosaic[0].Xm)); 1242 1226 } 1243 1227 … … 1592 1576 if (mosaic[i].flags & IMAGE_BAD) continue; 1593 1577 if (mosaic[i].skipCal) continue; 1578 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; 1579 1594 1580 list[n] = mosaic[i].Mcal; 1595 1581 dlist[n] = 1; … … 1622 1608 if (mosaic[i].flags & IMAGE_BAD) continue; 1623 1609 if (mosaic[i].skipCal) continue; 1610 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; 1611 1624 1612 list[n] = mosaic[i].dMcal; 1625 1613 dlist[n] = 1; … … 1653 1641 if (mosaic[i].flags & IMAGE_BAD) continue; 1654 1642 if (mosaic[i].skipCal) continue; 1643 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; 1655 1644 1656 1645 N = 0; … … 1699 1688 if (mosaic[i].flags & IMAGE_BAD) continue; 1700 1689 if (mosaic[i].skipCal) continue; 1701 list[n] = pow(10.0, 0.01*mosaic[i].Xm); 1690 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; 1691 1692 list[n] = pow (10.0, 0.01*mosaic[i].Xm); 1702 1693 dlist[n] = 1; 1703 1694 n++; … … 1782 1773 void plot_mosaic_fields (Catalog *catalog) { 1783 1774 1784 off_t i, j, m, c, N, ave,Nimage;1775 off_t i, j, m, c, N, Nimage; 1785 1776 double *xlist, *ylist; 1786 // double Xmin, Xmax, Ymin, Ymax;1787 1777 char string[64]; 1788 1778 Graphdata graphdata; … … 1803 1793 for (i = 0; i < Nmosaic; i++) { 1804 1794 N = 0; 1805 // Xmin = Ymin = +360.0;1806 // Xmax = Ymax = -360.0;1807 1795 for (j = 0; j < N_onMosaic[i]; j++) { 1808 1796 … … 1812 1800 if (catalog[c].measureT[m].dbFlags & (ID_MEAS_AREA | ID_MEAS_NOCAL)) continue; 1813 1801 1814 ave = catalog[c].measureT[m].averef;1815 xlist[N] = catalog[c]. averageT[ave].R - catalog[c].measureT[m].dR / 3600.0;1816 ylist[N] = catalog[c]. averageT[ave].D - catalog[c].measureT[m].dD / 3600.0;1802 // ave = catalog[c].measureT[m].averef; 1803 xlist[N] = catalog[c].measureT[m].R; 1804 ylist[N] = catalog[c].measureT[m].D; 1817 1805 N++; 1818 1806 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/Shutdown.c
r33651 r37403 23 23 SetProtect (TRUE); 24 24 if (db) gfits_db_close (db); 25 fprintf (stderr, "ERROR: addstarhalted\n");25 fprintf (stderr, "ERROR: relphot halted\n"); 26 26 exit (1); 27 27 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/StarOps.c
r36680 r37403 153 153 int i; 154 154 155 // fprintf (stderr, "this version of setMrel is invalid for now\n"); 156 // exit (1); 157 155 158 int Nsecfilt = GetPhotcodeNsecfilt (); 156 159 … … 407 410 408 411 /* star/photcodes already calibrated */ 409 if ( isSetMrelFinal && catalog[Nc].found [Nsecfilt*j+Nsec]) continue;412 if ( isSetMrelFinal && catalog[Nc].found_t[Nsecfilt*j+Nsec]) continue; 410 413 411 414 // skip bad stars … … 467 470 468 471 // skip some absurd values NAN, < 0.0, > 30.0 469 Msys = PhotSysTiny (&catalog[Nc].measureT[m], &catalog[Nc].averageT[j], &catalog[Nc].secfilt[j*Nsecfilt] );472 Msys = PhotSysTiny (&catalog[Nc].measureT[m], &catalog[Nc].averageT[j], &catalog[Nc].secfilt[j*Nsecfilt], MAG_CLASS_PSF); 470 473 if (isnan(Msys)) SKIP_THIS_MEAS(Nsys); 471 474 if (Msys < 0.0) SKIP_THIS_MEAS(Nsys); … … 670 673 liststats (list, dlist, wlist, N, &stats); 671 674 672 catalog[Nc].secfilt[Nsecfilt*j+Nsec].M = stats.mean;673 catalog[Nc].secfilt[Nsecfilt*j+Nsec].dM = stats.error;674 catalog[Nc].secfilt[Nsecfilt*j+Nsec]. Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq + 1e-4) : NAN_S_SHORT;675 catalog[Nc].secfilt[Nsecfilt*j+Nsec].M = stats.mean; 676 catalog[Nc].secfilt[Nsecfilt*j+Nsec].dM = stats.error; 677 catalog[Nc].secfilt[Nsecfilt*j+Nsec].Mchisq = (stats.Nmeas > 1) ? stats.chisq : NAN; 675 678 676 679 // when running -averages, we have no information about the images, so we cannot set this … … 680 683 681 684 if (isSetMrelFinal) { 682 catalog[Nc].found [Nsecfilt*j+Nsec] = TRUE;685 catalog[Nc].found_t[Nsecfilt*j+Nsec] = TRUE; 683 686 684 687 catalog[Nc].secfilt[Nsecfilt*j+Nsec].Mstdev = 1000.0*stats.sigma; // Mstdev is in millimags (not enough space for more precision) … … 950 953 951 954 int i, j, Ndel, Nave, Ntot, mark, Ns, Nscat, Nchi, Nnan; 952 float dM , Xm;953 double Chisq,MaxScatter, MaxChisq;955 float dM; 956 double MaxScatter, MaxChisq; 954 957 double *xlist, *slist, *dlist; 955 958 … … 978 981 for (j = 0; j < catalog[i].Naverage; j++) { 979 982 if ( catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD ) continue; 980 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm; 981 if (Xm == -1) continue; 982 Chisq = pow (10.0, 0.01*Xm); 983 xlist[Ntot] = Chisq; 983 float Mchisq = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq; 984 if (isnan(Mchisq)) continue; 985 xlist[Ntot] = Mchisq; 984 986 slist[Ntot] = catalog[i].secfilt[Nsecfilt*j+Nsec].dM; 985 987 dlist[Ntot] = 1; … … 999 1001 for (j = 0; j < catalog[i].Naverage; j++) { 1000 1002 dM = catalog[i].secfilt[Nsecfilt*j+Nsec].dM; 1001 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm; 1002 Chisq = pow (10.0, 0.01*Xm); 1003 mark = (dM > MaxScatter) || (Xm == NAN_S_SHORT) || (Chisq > MaxChisq); 1003 float Mchisq = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq; 1004 mark = (dM > MaxScatter) || (isnan(Mchisq)) || (Mchisq > MaxChisq); 1004 1005 if (mark) { 1005 1006 catalog[i].secfilt[Nsecfilt*j+Nsec].flags |= ID_STAR_POOR; 1006 1007 Ndel ++; 1007 if (dM > MaxScatter) { Nscat ++; }1008 if ( Xm == NAN_S_SHORT){ Nnan ++; }1009 if ( Chisq > MaxChisq) { Nchi ++; }1008 if (dM > MaxScatter) { Nscat ++; } 1009 if (isnan(Mchisq)) { Nnan ++; } 1010 if (Mchisq > MaxChisq) { Nchi ++; } 1010 1011 } else { 1011 1012 catalog[i].secfilt[Nsecfilt*j+Nsec].flags &= ~ID_STAR_POOR; … … 1072 1073 1073 1074 /* on final processing, skip stars already measured */ 1074 if (final && catalog[i].found [Nsecfilt*j + Nsec]) continue;1075 if (final && catalog[i].found_t[Nsecfilt*j + Nsec]) continue; 1075 1076 1076 1077 /* skip bad stars to prevent them from becoming good (on inner sample) */ … … 1085 1086 if (ecode != thisCode) { continue; } 1086 1087 1088 // SKIP gpc1 stack data 1089 if (isGPC1stack(catalog[i].measureT[m].photcode)) continue; 1090 1091 // SKIP gpc1 forced-warp data 1092 if (isGPC1warp(catalog[i].measureT[m].photcode)) continue; 1093 1087 1094 // NOTE: we do not skip MEAS_BAD because this measurement is just an internal assessment of the outliers 1088 1095 Mcal = getMcal (m, i, flatcorr, catalog); … … 1093 1100 if (isnan(Mgrid)) { Ngrid ++; continue; } 1094 1101 1095 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt] );1102 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt], MAG_CLASS_PSF); 1096 1103 list[N] = Msys - Mcal - Mmos - Mgrid; 1097 1104 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); … … 1130 1137 if (ecode != thisCode) { continue; } 1131 1138 1139 // SKIP gpc1 stack data 1140 if (isGPC1stack(catalog[i].measureT[m].photcode)) continue; 1141 1142 // SKIP gpc1 forced-warp data 1143 if (isGPC1warp(catalog[i].measureT[m].photcode)) continue; 1144 1132 1145 // NOTE: we do not skip MEAS_BAD because this measurement is just an internal assessment of the outliers 1133 1146 Mcal = getMcal (m, i, flatcorr, catalog); … … 1138 1151 if (isnan(Mgrid)) continue; 1139 1152 1140 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt] );1153 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt], MAG_CLASS_PSF); 1141 1154 list[N] = Msys - Mcal - Mmos - Mgrid; 1142 1155 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); … … 1233 1246 1234 1247 off_t j, Ntot; 1235 int i, n , Xm;1248 int i, n; 1236 1249 double *list, *dlist; 1237 1250 StatType stats; … … 1254 1267 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 1255 1268 1256 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm;1257 if ( Xm == NAN_S_SHORT) continue;1258 list[n] = pow (10.0, 0.01*Xm);1269 float Mchisq = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq; 1270 if (isnan(Mchisq)) continue; 1271 list[n] = Mchisq; 1259 1272 dlist[n] = 1; 1260 1273 n++; … … 1377 1390 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 1378 1391 xlist[N] = catalog[i].secfilt[Nsecfilt*j+Nsec].M; 1379 value = catalog[i].secfilt[Nsecfilt*j+Nsec]. Xm;1380 if ( value == NAN_S_SHORT) continue;1381 ylist[N] = 0.01*value;1392 value = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq; 1393 if (isnan(value)) continue; 1394 ylist[N] = value; 1382 1395 N++; 1383 1396 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/args.c
r36680 r37403 227 227 } 228 228 229 SHOW_PARAMS = FALSE;229 SHOW_PARAMS = TRUE; 230 230 if ((N = get_argument (argc, argv, "-params"))) { 231 231 remove_argument (N, &argc, argv); 232 SHOW_PARAMS = TRUE;232 SHOW_PARAMS = FALSE; 233 233 } 234 234 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/assign_images.c
r36680 r37403 25 25 26 26 if (MOSAIC_ZEROPT) { 27 makeMosaics (image, Nimage );28 29 // center coords and Mcal, dMcal, Xmfor the mosaics27 makeMosaics (image, Nimage, FALSE); 28 29 // center coords and Mcal, dMcal, Mchisq for the mosaics 30 30 setMosaicCenters (image, Nimage); 31 31 MARKTIME("set mosaic coordinates and Mcal values: %f sec\n", dtime); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/bcatalog.c
r35416 r37403 23 23 Nmeasure = Naverage = 0; 24 24 25 int NmMax = 0; 26 int NmMin = catalog[0].Nmeasure; 27 25 28 Ncode = Ntime = Ndophot = Nmag = Nsigma = Nimag = Nfew = Npsfqf = Ngalaxy = Nnan = Nbad = Npoor = 0; 26 29 … … 55 58 if (RESET) { 56 59 int Ns; 60 61 # if (0) 57 62 DVOSecfiltFlags secfiltBits = 58 63 ID_SECF_STAR_FEW | … … 66 71 ID_SECF_USE_UBERCAL | 67 72 ID_SECF_OBJ_EXT; 73 # endif 74 68 75 for (Ns = 0; Ns < Nphotcodes; Ns++) { 69 76 … … 71 78 int Nsec = GetPhotcodeNsec(thisCode); 72 79 73 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].M = NAN; 74 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Map = NAN; 75 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].dM = NAN; 76 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Mstdev = NAN_S_SHORT; 77 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Xm = NAN; 78 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].M_20 = NAN_S_SHORT; 79 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].M_80 = NAN_S_SHORT; 80 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Ncode = 0; 81 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Nused = 0; 82 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].flags &= ~secfiltBits; 83 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].ubercalDist = 1000; 80 // fprintf (stderr, "really use dvo_secfilt_init?"); 81 dvo_secfilt_init (&subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec]); 82 83 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].M = NAN; 84 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Map = NAN; 85 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].dM = NAN; 86 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Mstdev = NAN_S_SHORT; 87 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Mchisq = NAN; 88 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].M_20 = NAN_S_SHORT; 89 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].M_80 = NAN_S_SHORT; 90 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Ncode = 0; 91 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Nused = 0; 92 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].flags &= ~secfiltBits; 93 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].ubercalDist = 1000; 84 94 } 85 95 } … … 136 146 137 147 /* select measurements by mag limit */ 138 mag = PhotCat (&catalog[0].measure[offset] );148 mag = PhotCat (&catalog[0].measure[offset], MAG_CLASS_PSF); 139 149 if (mag > MAG_LIM) { Nmag ++; continue; } 140 150 … … 144 154 /* select measurements by mag limit */ 145 155 if (ImagSelect) { 146 mag = PhotInst (&catalog[0].measure[offset] );156 mag = PhotInst (&catalog[0].measure[offset], MAG_CLASS_PSF); 147 157 if (mag < ImagMin) { Nimag ++; continue; } 148 158 if (mag > ImagMax) { Nimag ++; continue; } … … 180 190 } 181 191 myAssert (Nmeasure < NMEASURE, "realloc failure"); 182 } 192 } // end of catalog.average.Nmeasure loop 183 193 184 194 // skip object if it is likely to be a galaxy … … 205 215 continue; 206 216 } 217 NmMin = MIN (Nm, NmMin); 218 NmMax = MAX (Nm, NmMax); 207 219 208 220 // for w-band photometry (& other cases?) convert gri photometry … … 235 247 subcatalog[0].Nsecf_mem = Naverage * catalog[0].Nsecfilt; 236 248 249 if (VERBOSE) { 250 fprintf (stderr, "using "OFF_T_FMT" stars ("OFF_T_FMT" measures) of "OFF_T_FMT" ("OFF_T_FMT" measures) for catalog %s, %d < Nm < %d\n", 251 subcatalog[0].Naverage, subcatalog[0].Nmeasure, catalog[0].Naverage, catalog[0].Nmeasure, catalog[0].filename, NmMin, NmMax); 252 fprintf (stderr, "rejections: %d stars have too few measures:\n %d code, %d time, %d dophot, %d mag, %d sigma, %d imag, %d psfqf, %d Nnan, %d galaxies, %d bad, %d poor\n", 253 Nfew, Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Npsfqf, Nnan, Ngalaxy, Nbad, Npoor); 254 } 255 237 256 // limit the total number of stars in the catalog 238 257 if (MaxDensityUse) { … … 240 259 } 241 260 242 if (VERBOSE) {243 fprintf (stderr, "using "OFF_T_FMT" stars ("OFF_T_FMT" measures) of "OFF_T_FMT" for catalog %s\n",244 subcatalog[0].Naverage, subcatalog[0].Nmeasure, i, catalog[0].filename);245 fprintf (stderr, "rejections: %d code, %d time, %d dophot, %d mag, %d sigma, %d imag, %d few, %d psfqf, %d Nnan, %d galaxies, %d bad, %d poor\n",246 Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Nfew, Npsfqf, Nnan, Ngalaxy, Nbad, Npoor);247 }248 261 return (TRUE); 249 262 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/initialize.c
r36680 r37403 36 36 37 37 if (SHOW_PARAMS) { 38 fprintf (stderr, "current parameter settings:\n"); 38 int Ns; 39 fprintf (stderr, "subset selection criteria:\n"); 40 fprintf (stderr, " photcodes "); 41 for (Ns = 0; Ns < Nphotcodes; Ns++) { 42 if (Ns == Nphotcodes - 1) { 43 fprintf (stderr, "%s\n", photcodes[Ns][0].name); 44 } else { 45 fprintf (stderr, "%s, ", photcodes[Ns][0].name); 46 } 47 } 39 48 if (TimeSelect) { 40 49 fprintf (stderr, "TimeSelect: TRUE (%s - %s)\n", ohana_sec_to_date (TSTART), ohana_sec_to_date (TSTOP)); … … 42 51 fprintf (stderr, "TimeSelect: FALSE\n"); 43 52 } 53 if (DophotSelect) { 54 fprintf (stderr, "DophotSelect: TRUE (%d)\n", DophotValue); 55 } else { 56 fprintf (stderr, "DophotSelect: FALSE\n"); 57 } 58 fprintf (stderr, "PSF_QF limit: 0.85 (hardwired)\n"); 59 60 // fprintf (stderr, "Photom Bad Mask: 0x%08x, Photom Poor Mask: 0x%08x\n"); 61 62 fprintf (stderr, "MAG_LIM: %f, SIGMA_LIM: %f\n", MAG_LIM, SIGMA_LIM); 63 fprintf (stderr, "INST_MAG_MIN: %f, INST_MAG_MAX: %f\n", ImagMin, ImagMax); 64 65 fprintf (stderr, "STAR_TOOFEW: %d\n", STAR_TOOFEW); 66 44 67 fprintf (stderr, "VERBOSE: %d, PLOTSTUFF: %d\n", VERBOSE, PLOTSTUFF); 45 68 fprintf (stderr, "GRID_X: %d, GRID_Y: %d, BINNING: %d == Nmx: %d, Nmy: %d\n", … … 49 72 (int)(RELPHOT_GRID_X/RELPHOT_GRID_BINNING), (int)(RELPHOT_GRID_Y/RELPHOT_GRID_BINNING)); 50 73 51 fprintf (stderr, "MAG_LIM %lf\n", MAG_LIM);52 74 fprintf (stderr, "STAR_SCATTER %lf\n", STAR_SCATTER); 53 75 fprintf (stderr, "IMAGE_SCATTER %lf\n", IMAGE_SCATTER); … … 56 78 fprintf (stderr, "GSCFILE %s\n", GSCFILE); 57 79 fprintf (stderr, "CATDIR %s\n", CATDIR); 58 exit (0);59 80 } 60 81 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/launch_region_hosts.c
r36680 r37403 22 22 for (i = 0; i < regionHosts->Nhosts; i++) { 23 23 char *syncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanmags.sync"); 24 truncate (syncfile, 0);24 if (truncate (syncfile, 0)) fprintf (stderr, "trouble clearing syncfile %s\n", syncfile); 25 25 free (syncfile); 26 26 27 27 char *fitsfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanmags.fits"); 28 truncate (fitsfile, 0);28 if (truncate (fitsfile, 0)) fprintf (stderr, "trouble clearing fitsfile %s\n", fitsfile ); 29 29 free (fitsfile); 30 30 31 31 char *imsyncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagemags.sync"); 32 truncate (imsyncfile, 0);32 if (truncate (imsyncfile, 0)) fprintf (stderr, "trouble clearing imsyncfile %s\n", imsyncfile); 33 33 free (imsyncfile); 34 34 35 35 char *imfitsfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagemags.fits"); 36 truncate (imfitsfile, 0);36 if (truncate (imfitsfile, 0)) fprintf (stderr, "trouble clearing imfitsfile %s\n", imfitsfile); 37 37 free (imfitsfile); 38 38 39 39 char *loopsyncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "loop.sync"); 40 truncate (loopsyncfile, 0);40 if (truncate (loopsyncfile, 0)) fprintf (stderr, "trouble clearing loopsyncfile %s\n", loopsyncfile); 41 41 free (loopsyncfile); 42 42 } … … 55 55 56 56 char command[1024]; 57 snprintf (command, 1024, "relphot %s -parallel-images %s -region-hosts %s -region-hostID %d -D CATDIR %s -region %f %f %f %f -statmode %s -D CAMERA %s -D STAR_TOOFEW %d -minerror %f", 58 PhotcodeList, filename, REGION_FILE, host->hostID, CATDIR, host->RminCat, host->RmaxCat, host->DminCat, host->DmaxCat, STATMODE, CAMERA, STAR_TOOFEW, MIN_ERROR); 57 snprintf (command, 1024, "relphot %s", PhotcodeList); 58 strextend (command, "-parallel-images %s", filename); 59 strextend (command, "-region-hosts %s", REGION_FILE); 60 strextend (command, "-region-hostID %d", host->hostID); 61 strextend (command, "-D CATDIR %s", CATDIR); 62 strextend (command, "-region %f %f %f %f", host->RminCat, host->RmaxCat, host->DminCat, host->DmaxCat); 63 strextend (command, "-statmode %s", STATMODE); 64 strextend (command, "-D CAMERA %s", CAMERA); 65 strextend (command, "-D STAR_TOOFEW %d", STAR_TOOFEW); 66 strextend (command, "-minerror %f", MIN_ERROR); 67 strextend (command, "-cloud-limit %f", CLOUD_TOLERANCE); 59 68 60 69 if (VERBOSE) strextend (command, "-v"); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/load_catalogs.c
r36680 r37403 12 12 // if this function is called with a specified hostID, then only the fraction of the 13 13 // database hosted by that hostID is loaded 14 Catalog *load_catalogs (SkyList *skylist, int *Ncatalog, int hostID, char *hostpath ) {14 Catalog *load_catalogs (SkyList *skylist, int *Ncatalog, int hostID, char *hostpath, char *syncfile) { 15 15 16 16 off_t i, Nmeas, Nstar, Nmeas_total, Nstar_total; … … 19 19 // XXX need to decide how to determine PARALLEL mode... 20 20 if (PARALLEL && !hostID) { 21 catalog = load_catalogs_parallel (skylist, Ncatalog );21 catalog = load_catalogs_parallel (skylist, Ncatalog, syncfile); 22 22 return catalog; 23 23 } … … 92 92 // in regular relphot, we shutdown here; in relphot_client, we generate and return an empty table (for consistency) 93 93 94 // if we are running with parallel_images but not a parallel database, we need to 95 // release the lock so the next image host can proceed 96 if (!hostID && syncfile) { 97 update_sync_file (syncfile, 1); 98 } 99 94 100 // XXX consider only returning the populated catalogs 95 101 *Ncatalog = skylist[0].Nregions; … … 105 111 // CATDIR is supplied globally 106 112 # define DEBUG 1 107 Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog ) {113 Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog, char *syncfile) { 108 114 109 115 char uniquer[12]; … … 206 212 } 207 213 214 // update syncfile here (save lots of I/O time): 215 216 // at this point, the remote relastro_client jobs are done loading their data. in a 217 // parallel_images mode, the next image host can be launched while this image host now 218 // reads that 219 220 // NOTE: if I let all hosts load blindly, I saturate the data clients with too many 221 // relphot_client requests. I need to have the master mediate this. the master 222 // will not launch the next remote job until this one says it is done 223 if (syncfile) { 224 update_sync_file (syncfile, 1); 225 } 226 208 227 // each host generates a BrightCatalog structure, with the measure, average, etc value 209 228 // loaded into a single set of arrays (of MeasureTiny, AverageTiny, Secfilt). I need to -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/plot_scatter.c
r35759 r37403 51 51 52 52 xlist[N] = Mrel; 53 ylist[N] = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt] ) - Mcal - Mmos - Mgrid - Mrel;54 ilist[N] = PhotInstTiny (&catalog[i].measureT[m] );53 ylist[N] = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt], MAG_CLASS_PSF) - Mcal - Mmos - Mgrid - Mrel; 54 ilist[N] = PhotInstTiny (&catalog[i].measureT[m], MAG_CLASS_PSF); 55 55 N++; 56 56 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/relphot_client.c
r36680 r37403 39 39 case MODE_LOAD: { 40 40 int Ncatalog; 41 Catalog *catalog = load_catalogs (skylist, &Ncatalog, HOST_ID, HOSTDIR );41 Catalog *catalog = load_catalogs (skylist, &Ncatalog, HOST_ID, HOSTDIR, NULL); 42 42 if (!catalog) { 43 43 fprintf (stderr, "ERROR loading catalogs from %s\n", CATDIR); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/relphot_images.c
r36680 r37403 52 52 if (NLOOP > 0) { 53 53 /* load catalog data from region files (hostID is 0 since we are not a client */ 54 catalog = load_catalogs (skylist, &Ncatalog, 0, NULL );54 catalog = load_catalogs (skylist, &Ncatalog, 0, NULL, NULL); 55 55 MARKTIME("-- load catalog data: %f sec\n", dtime); 56 56 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/relphot_parallel_images.c
r36680 r37403 38 38 // unlink (IMAGE_TABLE); // XXX a bit risky, add some protection? 39 39 40 // XXX need to deal with mosaic vs image... 41 makeMosaics (image, Nimage); 40 makeMosaics (image, Nimage, TRUE); 42 41 43 42 initImages (image, NULL, Nimage); … … 56 55 57 56 /* load catalog data from region files (hostID is 0 since we are not a client */ 58 catalog = load_catalogs (skylist, &Ncatalog, 0, NULL); 57 char *syncfile = make_filename (CATDIR, regionHosts->hosts[myHost].hostname, REGION_HOST_ID, "loadcat.sync"); 58 catalog = load_catalogs (skylist, &Ncatalog, 0, NULL, syncfile); 59 59 MARKTIME("-- load catalog data: %f sec\n", dtime); 60 free (syncfile); 61 60 62 client_logger_message ("loaded catalog data\n"); 61 63 62 // NOTE: if I let all hosts load blindly, I saturate the data clients with too many63 // relphot_client requests. I need to have the master mediate this. the master64 // will not launch the next remote job until this one says it is done65 char *syncfile = make_filename (CATDIR, regionHosts->hosts[myHost].hostname, REGION_HOST_ID, "loadcat.sync");66 update_sync_file (syncfile, 1);67 68 64 // generate tables go from catID,objID -> catSeq,objSeq 69 65 indexCatalogs (catalog, Ncatalog); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/relphot_parallel_regions.c
r36680 r37403 1 1 # include "relphot.h" 2 int save_images_backup (FITS_DB *db); 2 3 3 4 int relphot_parallel_regions () { … … 63 64 SkyList *skylist = SkyListByBounds (sky, -1, regionHosts->Rmin, regionHosts->Rmax, regionHosts->Dmin, regionHosts->Dmax); 64 65 66 // I have to save a copy because dvo_image_save and _unlock swap and free the data 67 save_images_backup (&db); 68 65 69 /* update catalogs (in parallel) */ 66 70 reload_catalogs (skylist, flatcorr, 0, NULL); … … 74 78 } 75 79 80 int save_images_backup (FITS_DB *db) { 81 82 FITS_DB dbX; 83 char filename[1024]; 84 85 INITTIME; 86 87 gfits_db_init (&dbX); 88 dbX.lockstate = LCK_XCLD; 89 dbX.timeout = 60.0; 90 dbX.mode = db->mode; 91 dbX.format = db->format; 92 93 snprintf (filename, 1024, "%s.bck", ImageCat); 94 if (!gfits_db_lock (&dbX, filename)) { 95 fprintf (stderr, "can't lock backup image image catalog\n"); 96 return (FALSE); 97 } 98 99 // copy Images.dat data (all or only the subset / vtable elements?) I think I need to dump 100 // the entire Image table, but with the updates in place I think this says: re-work the 101 // ftable/vtable usage in this program to be more sensible... 102 gfits_copy_header (&db->header, &dbX.header); 103 gfits_copy_matrix (&db->matrix, &dbX.matrix); 104 gfits_copy_header (&db->theader, &dbX.theader); 105 gfits_copy_ftable (&db->ftable, &dbX.ftable); 106 107 dbX.ftable.header = &dbX.theader; 108 109 dvo_image_save (&dbX, VERBOSE); 110 dvo_image_unlock (&dbX); 111 MARKTIME("-- save Image.dat.bck: %f sec\n", dtime); 112 113 return TRUE; 114 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/setExclusions.c
r33651 r37403 35 35 /* select measurements by mag limit */ 36 36 if (AreaSelect) { 37 r = catalog[i]. averageT[j].R + catalog[i].measureT[m].dR / 3600.0;38 d = catalog[i]. averageT[j].D + catalog[i].measureT[m].dD / 3600.0;37 r = catalog[i].measureT[m].R; 38 d = catalog[i].measureT[m].D; 39 39 if ((coords = getCoords (m, i)) == NULL) goto markbad; 40 40 RD_to_XY (&x, &y, r, d, coords); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/setMrelCatalog.c
r36680 r37403 1 1 # include "relphot.h" 2 # define UBERCAL_WEIGHT 100.0 2 3 3 4 # define SKIP_THIS_MEAS(REASON) { \ … … 13 14 continue; } 14 15 16 static float MagToFlux (float Mag) { 17 float Flux = pow(10.0, -0.4*(Mag)); 18 return (Flux); 19 } 20 15 21 int print_measure_set_alt (Average *average, SecFilt *secfilt, Measure *measure) { 16 22 … … 29 35 return (TRUE); 30 36 } 37 38 int setMrelAverageForcedWarp (off_t measureOffset, int cat, int pass, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, off_t *found); 31 39 32 40 int setMrel_catalog_alt (Catalog *catalog, int Nc, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, int Nsecfilt) { … … 42 50 int isSetMrelFinal = (pass >= 0); 43 51 44 char *primaryCell = NULL;45 if (isSetMrelFinal) {46 ALLOCATE (primaryCell, char, DVO_MAX_PATH);47 }52 // XX char *primaryCell = NULL; 53 // XX if (isSetMrelFinal) { 54 // XX ALLOCATE (primaryCell, char, DVO_MAX_PATH); 55 // XX } 48 56 49 57 for (j = 0; j < catalog[Nc].Naverage; j++) { … … 52 60 Average *average = catalog[Nc].average ? &catalog[Nc].average[j] : NULL; 53 61 Measure *measure = catalog[Nc].measure ? &catalog[Nc].measure[m] : NULL; 54 setMrelAverageExposure (m, Nc, pass, flatcorr, results, average, &catalog[Nc].averageT[j], &catalog[Nc].secfilt[j*Nsecfilt], measure, &catalog[Nc].measureT[m], &catalog[Nc].found [Nsecfilt*j]);62 setMrelAverageExposure (m, Nc, pass, flatcorr, results, average, &catalog[Nc].averageT[j], &catalog[Nc].secfilt[j*Nsecfilt], measure, &catalog[Nc].measureT[m], &catalog[Nc].found_t[Nsecfilt*j]); 55 63 56 64 // only apply Stack operation on setMrelFinal in first pass 57 65 if (isSetMrelFinal && (pass == 0)) { 58 setMrelAverageStack (m, Nc, flatcorr, results, &catalog[Nc].average[j], &catalog[Nc].secfilt[j*Nsecfilt], &catalog[Nc].measure[m] , primaryCell);66 setMrelAverageStack (m, Nc, flatcorr, results, &catalog[Nc].average[j], &catalog[Nc].secfilt[j*Nsecfilt], &catalog[Nc].measure[m]); 59 67 setGlobalObjStats (&catalog[Nc].average[j], &catalog[Nc].measure[m]); 60 68 } 61 } 62 if (primaryCell) free (primaryCell); 69 70 // only measure force-warp mean values if issetMrelFinal (make it optional?) 71 if (isSetMrelFinal) { 72 setMrelAverageForcedWarp (m, Nc, pass, results, &catalog[Nc].average[j], &catalog[Nc].secfilt[j*Nsecfilt], &catalog[Nc].measure[m], &catalog[Nc].foundWarp_t[Nsecfilt*j]); 73 setGlobalObjStats (&catalog[Nc].average[j], &catalog[Nc].measure[m]); 74 } 75 } 76 // if (primaryCell) free (primaryCell); 63 77 return (TRUE); 64 78 } 65 79 80 // set mean of chip measurements (selected by photcode range for now): 66 81 int setMrelAverageExposure (off_t measureOffset, int cat, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, Average *average, AverageTiny *averageT, SecFilt *secfilt, Measure *measure, MeasureTiny *measureT, off_t *found) { 67 82 … … 132 147 off_t meas = measureOffset; 133 148 149 float psfQfMax = 0.0; 150 float psfQfPerfMax = 0.0; 151 134 152 int Nap = 0; 135 153 int Npsf = 0; … … 144 162 145 163 // are we a PS1 exposure photcode? 146 if ((measureT[k].photcode >= 10000) && (measureT[k].photcode <= 10500)) { 147 NexpPS1 ++; 164 if (isGPC1chip(measureT[k].photcode)) NexpPS1 ++; 165 166 // SKIP gpc1 stack data 167 if (isGPC1stack(measureT[k].photcode)) continue; 168 169 // SKIP gpc1 forced-warp data 170 if (isGPC1warp(measureT[k].photcode)) continue; 171 172 if (isSetMrelFinal) { 173 if (measure[k].psfQF > psfQfMax) psfQfMax = measure[k].psfQF; 174 if (measure[k].psfQFperf > psfQfPerfMax) psfQfPerfMax = measure[k].psfQFperf; 148 175 } 149 176 … … 166 193 167 194 // skip some absurd values NAN, < 0.0, > 30.0 168 Msys = PhotSysTiny (&measureT[k], &averageT[0], &secfilt[0] );195 Msys = PhotSysTiny (&measureT[k], &averageT[0], &secfilt[0], MAG_CLASS_PSF); 169 196 if (isnan(Msys)) SKIP_THIS_MEAS(Nsys); 170 197 if (Msys < 0.0) SKIP_THIS_MEAS(Nsys); … … 197 224 } 198 225 havePS1 = TRUE; 199 }200 201 // gpc1 stack data202 if ((measure[k].photcode >= 11000) && (measure[k].photcode <= 11400)) {203 continue;204 226 } 205 227 … … 255 277 256 278 // Map (Maplist) and Mkron (Mkronlist,dkronlist) are used to calculate mean mags per filter 257 float Map = Phot AperCat (&measure[k]);279 float Map = PhotCat (&measure[k], MAG_CLASS_APER); 258 280 if (!isnan(Map)) { 259 281 Maplist[Nap] = Map - Mcal - Mmos - Mgrid; 260 daplist[Nap] = dMpsf; 261 waplist[Nap] = isUbercal ? 10.0: 1.0;282 daplist[Nap] = dMpsf;// XXX check on this... 283 waplist[Nap] = isUbercal ? UBERCAL_WEIGHT : 1.0; 262 284 Nap ++; 263 285 } 264 286 265 float Mkron = Phot KronCat (&measure[k]);287 float Mkron = PhotCat (&measure[k], MAG_CLASS_KRON); 266 288 if (!isnan(Mkron)) { 267 289 Mkronlist[Nkron] = Mkron - Mcal - Mmos - Mgrid; 268 290 dkronlist[Nkron] = measure[k].dMkron; 269 wkronlist[Nkron] = isUbercal ? 10.0: 1.0;291 wkronlist[Nkron] = isUbercal ? UBERCAL_WEIGHT : 1.0; 270 292 Nkron ++; 271 293 } … … 280 302 Mpsflist[Npsf] = Msys - Mcal - Mmos - Mgrid; 281 303 dpsflist[Npsf] = dMpsf; 282 wpsflist[Npsf] = isUbercal ? 10.0: 1.0;304 wpsflist[Npsf] = isUbercal ? UBERCAL_WEIGHT : 1.0; 283 305 284 306 // NOTE: … … 293 315 if (refPhotcode) { 294 316 if (code->code == refPhotcode->code) { 295 wpsflist[Npsf] = 100.0;317 wpsflist[Npsf] = UBERCAL_WEIGHT; 296 318 } 297 319 } … … 304 326 if (isSetMrelFinal && (pass == 0)) { 305 327 if ((thisCode < 6) || (thisCode == 9)) { 306 secfilt[Nsec].Ncode = NexpPS1; 328 secfilt[Nsec].Ncode = NexpPS1; 307 329 } else { 308 330 secfilt[Nsec].Ncode = Ncode; // 2MASS data if it exists … … 334 356 liststats (Mpsflist, dpsflist, wpsflist, Npsf, psfstats); 335 357 336 secfilt[Nsec].M = psfstats->mean;337 secfilt[Nsec].dM = psfstats->error;338 secfilt[Nsec]. Xm = (psfstats->Nmeas > 1) ? 100.0*log10(psfstats->chisq + 1e-4) : NAN_S_SHORT;358 secfilt[Nsec].M = psfstats->mean; 359 secfilt[Nsec].dM = psfstats->error; 360 secfilt[Nsec].Mchisq = (psfstats->Nmeas > 1) ? psfstats->chisq : NAN; 339 361 340 362 // when running -averages, we have no information about the images, so we cannot set this … … 346 368 found[Nsec] = TRUE; 347 369 348 secfilt[Nsec].Mstdev = 1000.0*psfstats->sigma; // Mstdev is in millimags (not enough space for more precision)370 secfilt[Nsec].Mstdev = psfstats->sigma; // Mstdev is in millimags (not enough space for more precision) 349 371 // secfilt[Nsec].Ncode = Ncode; 350 372 secfilt[Nsec].Nused = psfstats->Nmeas; 351 373 352 secfilt[Nsec].M_80 = 1000 * psfstats->Upper80; 353 secfilt[Nsec].M_20 = 1000 * psfstats->Lower20; 374 secfilt[Nsec].Mmax = psfstats->max; 375 secfilt[Nsec].Mmin = psfstats->min; 376 377 secfilt[Nsec].psfQfMax = psfQfMax; 378 secfilt[Nsec].psfQfPerfMax = psfQfPerfMax; 354 379 355 380 // NOTE : use the modified weight for apmags as well as psf mags 356 381 liststats (Maplist, daplist, waplist, Nap, apstats); 357 382 secfilt[Nsec].Map = Nap > 0 ? apstats->mean : NAN; 383 secfilt[Nsec].dMap = Nap > 0 ? apstats->error : NAN; 384 secfilt[Nsec].sMap = Nap > 0 ? apstats->sigma : NAN; 385 secfilt[Nsec].NusedAp = Nap; 358 386 359 387 liststats (Mkronlist, dkronlist, wkronlist, Nkron, kronstats); 360 388 secfilt[Nsec].Mkron = Nkron > 0 ? kronstats->mean : NAN; 361 389 secfilt[Nsec].dMkron = Nkron > 0 ? kronstats->error : NAN; 390 secfilt[Nsec].sMkron = Nkron > 0 ? kronstats->sigma : NAN; 391 secfilt[Nsec].NusedKron = Nkron; 362 392 363 393 // NOTE: for 2MASS measurements, Next should be 1, as should N … … 422 452 423 453 // only apply Stack operation on setMrelFinal in first pass 424 int setMrelAverageStack (off_t measureOffset, int cat, FlatCorrectionTable *flatcorr, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, char *primaryCell) { 425 426 off_t k, ID; 427 428 float Msys = 0, Mcal= 0, Mmos = 0, Mgrid = 0; 454 // this function has 3 goals, not to be confused: 455 // 1) find and mark the PRIMARY detections (regardless of the quality of the detection) 456 // 2) select the BEST detections per filter (regardless of PRIMARY) 457 // 3) apply the zero point and AB->Jy transformations 458 int setMrelAverageStack (off_t measureOffset, int cat, FlatCorrectionTable *flatcorr, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure) { 459 460 off_t k; 461 462 float Mcal= 0, Mmos = 0, Mgrid = 0, Finst = 0; 429 463 430 464 // set the primary projection cell and skycell for this coordinate … … 434 468 get_tess_ids(&tessID, &projectID, &skycellID, average[0].R, average[0].D); 435 469 470 average[0].tessID = tessID; 471 average[0].projectionID = projectID; 472 average[0].skycellID = skycellID; 473 436 474 int NstackGood = 0; 437 475 int NstackSuspect = 0; … … 448 486 int haveStack = FALSE; 449 487 450 // need to find the measurement closest to the center of its skycell, as well as the 451 // closest for the subset of primary projection cells 452 453 float stackCenterOffsetMin = 1e9; 454 off_t stackCenterMeasureMin = -1; 455 456 float stackPrimaryOffsetMin = 1e9; 457 off_t stackPrimaryMeasureMin = -1; 488 float psfQFbest = 0.0; 489 490 off_t stackBestMeasure = -1; 491 off_t stackPrimaryMeasure = -1; 458 492 459 493 int isBad = FALSE; 460 494 int isSuspect = FALSE; 461 495 496 int Nstack = 0; // number for this photcode 497 int NstackDet = 0; // number for this photcode 498 462 499 off_t meas = measureOffset; 463 500 for (k = 0; k < average[0].Nmeasure; k++, meas++) { 501 502 // only examine gpc1 stack data 503 if (!isGPC1stack(measure[k].photcode)) continue; 464 504 465 505 // skip measurements that do not match the current photcode … … 468 508 if (code->equiv != thisCode) { continue; } 469 509 510 Nstack ++; 511 if ((measure[k].photFlags2 & 0x00000004) == 0) NstackDet ++; 512 470 513 // clear this bit for all measurements 471 514 measure[k].dbFlags &= ~ID_MEAS_STACK_PRIMARY; 472 473 // only examine gpc1 stack data 474 // XXX this is absurdly hardwired (along with several photcode tests) 475 if (measure[k].photcode < 11000) continue; 476 if (measure[k].photcode > 11400) continue; 515 measure[k].dbFlags &= ~ID_MEAS_STACK_PHOT_SRC; 477 516 478 517 haveStack = TRUE; 479 518 haveStackObject = TRUE; 480 519 520 // match measurement to its image (this is just a check, right?) 521 if (getImageEntry (meas, cat) < 0) { 522 fprintf (stderr, "*** warning : this should be impossible\n"); 523 abort(); 524 continue; 525 } 526 527 // find the PRIMARY measurement 528 529 // if we request the primary (USE_TREE_FOR_PRIMARY), this is true if the measurement is from the 530 // primary skycell for this position 531 if (MatchImageSkycellID (meas, cat, tessID, projectID, skycellID)) { 532 stackPrimaryMeasure = k; 533 measure[k].dbFlags |= ID_MEAS_STACK_PRIMARY; 534 secfilt[Nsec].stackPrmryOff = meas; 535 } 536 537 // now choose the BEST measurements (may also be PRIMARY) 538 481 539 if (measure[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS_STACK(Nbad); 482 540 483 if (getImageEntry (meas, cat) < 0) continue;484 541 // measurements without an image are either external reference photometry or 485 542 // data for which the associated image has not been loaded (probably because of … … 493 550 if (isnan(Mgrid)) SKIP_THIS_MEAS_STACK(Ngrid); 494 551 495 Msys = PhotSys (&measure[k], &average[0], &secfilt[0]); 496 if (isnan(Msys)) SKIP_THIS_MEAS_STACK(Nsys); 497 498 unsigned int stackImageID; 499 500 // which stack image should we use for the mean value? 501 // if we request the primary (USE_TREE_FOR_PRIMARY), then find the min distances for data from the primary cell 502 if (MatchImageSkycellID (meas, cat, tessID, projectID, skycellID)) { 503 float stackPrimaryOffset = getCenterOffset (meas, cat, &measure[k], &stackImageID); 504 if (stackPrimaryOffset < stackPrimaryOffsetMin) { 505 stackPrimaryOffsetMin = stackPrimaryOffset; 506 // stackPrimaryIDmin = stackImageID; 507 stackPrimaryMeasureMin = k; 508 } 509 } 510 511 // get the center distance for the generic case: 512 float stackCenterOffset = getCenterOffset (meas, cat, &measure[k], &stackImageID); 513 if (stackCenterOffset < stackCenterOffsetMin) { 514 stackCenterOffsetMin = stackCenterOffset; 515 // stackCenterIDmin = stackImageID; 516 stackCenterMeasureMin = k; 552 // NOTE: negative and insignificant vlues values are allowed, but not NAN flux values 553 Finst = PhotFluxInst (&measure[k], MAG_CLASS_PSF); 554 if (isnan(Finst)) SKIP_THIS_MEAS_STACK(Ninst); 555 556 if (measure[k].psfQFperf > psfQFbest) { 557 psfQFbest = measure[k].psfQFperf; 558 stackBestMeasure = k; 517 559 } 518 560 … … 537 579 538 580 // measurements which are bad will not have a valid stack entry and are skipped 539 k = (stack PrimaryMeasureMin >= 0) ? stackPrimaryMeasureMin : stackCenterMeasureMin;581 k = (stackBestMeasure >= 0) ? stackBestMeasure : stackPrimaryMeasure; 540 582 if (k < 0) continue; 541 542 583 543 584 // we are now populating stackDetectID not stack Image ID in secfilt 544 585 // ID = (stackPrimaryMeasureMin >= 0) ? stackPrimaryIDmin : stackCenterIDmin; 545 ID = measure[k].extID; // for the stack, this is the stackDetectID586 // ID = measure[k].extID; // for the stack, this is the stackDetectID 546 587 547 588 // get the zero point for the selected image … … 581 622 582 623 // need to put in AB mag factor to get to Janskies (or uJy?) 583 secfilt[Nsec].FluxPSF = zpFactor * measure[k].FluxPSF; 584 secfilt[Nsec].dFluxPSF = zpFactor * measure[k].dFluxPSF; 585 secfilt[Nsec].FluxKron = zpFactor * measure[k].FluxKron; 586 secfilt[Nsec].dFluxKron = zpFactor * measure[k].dFluxKron; 587 588 secfilt[Nsec].stackDetectID = ID; 589 624 secfilt[Nsec].FpsfStk = zpFactor * measure[k].FluxPSF; 625 secfilt[Nsec].dFpsfStk = zpFactor * measure[k].dFluxPSF; 626 secfilt[Nsec].FkronStk = zpFactor * measure[k].FluxKron; 627 secfilt[Nsec].dFkronStk = zpFactor * measure[k].dFluxKron; 628 secfilt[Nsec].FapStk = zpFactor * measure[k].FluxAp; 629 secfilt[Nsec].dFapStk = zpFactor * measure[k].dFluxAp; 630 631 // Jy to AB mags 632 secfilt[Nsec].MpsfStk = (measure[k].FluxPSF > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FpsfStk) : NAN; 633 secfilt[Nsec].MkronStk = (measure[k].FluxKron > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FkronStk) : NAN; 634 secfilt[Nsec].MapStk = (measure[k].FluxAp > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FapStk) : NAN; 635 636 secfilt[Nsec].stackBestOff = k + measureOffset; 637 638 secfilt[Nsec].Nstack = Nstack; 639 secfilt[Nsec].NstackDet = NstackDet; 640 641 // this is the measurement used by secfilt[] 590 642 measure[k].dbFlags |= ID_MEAS_STACK_PHOT_SRC; 591 if (stackPrimaryMeasureMin >= 0) { 592 measure[k].dbFlags |= ID_MEAS_STACK_PRIMARY; 643 if (k == stackPrimaryMeasure) { 593 644 secfilt[Nsec].flags |= ID_SECF_STACK_PRIMARY; 594 645 } … … 607 658 } 608 659 660 # undef SKIP_THIS_MEAS 661 # define SKIP_THIS_MEAS(REASON) { \ 662 measure[k].dbFlags |= ID_MEAS_SKIP_PHOTOM; \ 663 results->REASON ++; \ 664 continue; } 665 666 // set mean of forced-warp measurements (selected by photcode range for now): 667 // somewhat simplified relative to chip-photometry: 668 // * no grid, no mosaic, no 2MASS, no SYNTH, no Ubercal, no flatcorr 669 int setMrelAverageForcedWarp (off_t measureOffset, int cat, int pass, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, off_t *found) { 670 671 off_t k; 672 float Mcal= 0; 673 674 // we are measuring means for 3 types of FLUXes: psf, ap, kron. I am using the psf mag 675 // error for the ap mags, but krons have their own errors. it is an open question if I 676 // should be doing weighted or unweighted fits (this is a user option) 677 double *Fpsflist = results->Mpsflist; 678 double *dpsflist = results->dpsflist; 679 double *wpsflist = results->wpsflist; 680 681 double *Faplist = results->Maplist; 682 double *daplist = results->daplist; 683 double *waplist = results->waplist; 684 685 double *Fkronlist = results->Mkronlist; 686 double *dkronlist = results->dkronlist; 687 double *wkronlist = results->wkronlist; 688 689 StatType *psfstats = &results->psfstats; 690 StatType *apstats = &results->apstats; 691 StatType *kronstats = &results->kronstats; 692 693 // option for a test print 694 if ((average[0].objID == 0xd6e) && (average[0].catID == 0x4984)) { 695 fprintf (stderr, "test obj\n"); 696 print_measure_set_alt (average, secfilt, measure); 697 } 698 699 int Ns; 700 for (Ns = 0; Ns < Nphotcodes; Ns++) { 701 702 int thisCode = photcodes[Ns][0].code; 703 int Nsec = GetPhotcodeNsec(thisCode); 704 705 /* calculate the average mag in this SEC photcode for a single star */ 706 707 /* star/photcodes already calibrated */ 708 if (found[Nsec]) continue; 709 710 // I need to restrict the measurements coming only from the same skycell as the secfilt values 711 // if we cannot make that association, skip this set of warps 712 int stkTessID, stkProjID, stkSkycellID; 713 if (!FindImageSkycellID (secfilt[Nsec].stackBestOff, cat, &stkTessID, &stkProjID, &stkSkycellID)) continue; 714 715 off_t meas = measureOffset; 716 717 int Nap = 0; 718 int Npsf = 0; 719 int Nkron = 0; 720 721 int Nwarp = 0; 722 int NwarpGood = 0; 723 for (k = 0; k < average[0].Nmeasure; k++, meas++) { 724 725 // only examine gpc1 forced-warp data 726 if (!isGPC1warp(measure[k].photcode)) continue; 727 728 // skip measurements that do not match the current photcode 729 PhotCode *code = GetPhotcodebyCode (measure[k].photcode); 730 if (!code) continue; 731 if (code->equiv != thisCode) { continue; } 732 733 Nwarp ++; 734 if (measure[k].psfQFperf > 0.85) NwarpGood ++; 735 736 measure[k].dbFlags &= ~ID_MEAS_WARP_USED; 737 738 if (!MatchImageSkycellID (meas, cat, stkTessID, stkProjID, stkSkycellID)) continue; 739 740 if (measure[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS(Nbad); 741 742 if (getImageEntry (meas, cat) < 0) { 743 // measurements without an image are either external reference photometry or 744 // data for which the associated image has not been loaded (probably because of 745 // overlaps). Msys + measure.Mcal is our best guess of the true magnitude 746 Mcal = measure[k].Mcal; // check that this is zero for loaded REF value 747 } else { 748 // use getMcal not getMcal_alt? 749 Mcal = getMcal_alt (meas, cat, NULL, measure[k].Xccd, measure[k].Yccd); 750 // Mcal = getMcal (meas, cat); 751 if (isnan(Mcal)) SKIP_THIS_MEAS(Ncal); 752 } 753 float Fcal = MagToFlux(-Mcal); 754 755 // in the calculations below, 756 // ...list gives the error per measurement, wlist gives the weight 757 // we can modify the error and weight in a few ways: 758 // 1) MIN_ERROR guarantees a floor 759 // 2) photomErrSys is added in quadrature as a sytematic error, set per photcode 760 761 // skip some absurd values NAN 762 // NOTE : I am using PhotCat not PhotSys for now since GPC1 chip-to-chip color terms 763 // are small (and not measured) 764 float Fpsf = PhotFluxCat (&measure[k], MAG_CLASS_PSF); 765 if (isnan(Fpsf)) SKIP_THIS_MEAS(Nsys); 766 // if (Msys < 0.0) SKIP_THIS_MEAS(Nsys); 767 // if (Msys > 30.0) SKIP_THIS_MEAS(Nsys); 768 769 float dFpsf = PhotFluxCatErr (&measure[k], MAG_CLASS_PSF); 770 if (isnan(dFpsf)) SKIP_THIS_MEAS (Nsys); 771 772 int isBad = (measure[k].psfQF < 0.85); 773 isBad |= isnan(measure[k].psfQF); 774 if (isBad) SKIP_THIS_MEAS (Nsys); 775 776 int isPoor = (measure[k].psfQFperf < 0.85); 777 if ((pass == 0) && isPoor) SKIP_THIS_MEAS (Nsys); 778 779 dFpsf = MAX (dFpsf, MIN_ERROR*Fpsf); // MIN_ERROR is a fractional error 780 Fpsflist[Npsf] = Fpsf * Fcal; 781 dpsflist[Npsf] = dFpsf * Fcal; 782 wpsflist[Npsf] = 1.0; 783 Npsf ++; 784 785 measure[k].dbFlags |= ID_MEAS_WARP_USED; 786 787 float Fap = PhotFluxCat (&measure[k], MAG_CLASS_APER); 788 float dFap = PhotFluxCatErr (&measure[k], MAG_CLASS_APER); 789 if (!isnan(Fap)) { 790 Faplist[Nap] = Fap * Fcal; 791 daplist[Nap] = dFap * Fcal; 792 waplist[Nap] = 1.0; // drop weight lists? 793 Nap ++; 794 } 795 796 float Fkron = PhotFluxCat (&measure[k], MAG_CLASS_KRON); 797 float dFkron = PhotFluxCatErr (&measure[k], MAG_CLASS_KRON); 798 if (!isnan(Fkron)) { 799 Fkronlist[Nkron] = Fkron * Fcal; 800 dkronlist[Nkron] = dFkron * Fcal; 801 wkronlist[Nkron] = 1.0; 802 Nkron ++; 803 } 804 } 805 if (Npsf < 1) continue; 806 807 found[Nsec] = TRUE; 808 809 liststats (Fpsflist, dpsflist, wpsflist, Npsf, psfstats); 810 811 secfilt[Nsec].FpsfWrp = psfstats->mean; 812 secfilt[Nsec].dFpsfWrp = psfstats->error; 813 secfilt[Nsec].sFpsfWrp = psfstats->sigma; // Mstdev is in millimags (not enough space for more precision) 814 secfilt[Nsec].NusedWrp = psfstats->Nmeas; 815 secfilt[Nsec].MpsfWrp = isnan(secfilt[Nsec].FpsfWrp) ? NAN : 8.9 - 2.5*log10(secfilt[Nsec].FpsfWrp); // 8.9 since flux is in Jy 816 817 // NOTE : use the modified weight for apmags as well as psf mags 818 liststats (Faplist, daplist, waplist, Nap, apstats); 819 secfilt[Nsec].FapWrp = Nap > 0 ? apstats->mean : NAN; 820 secfilt[Nsec].dFapWrp = Nap > 0 ? apstats->error : NAN; 821 secfilt[Nsec].sFapWrp = Nap > 0 ? apstats->sigma : NAN; 822 secfilt[Nsec].NusedApWrp = Nap; 823 secfilt[Nsec].MapWrp = isnan(secfilt[Nsec].FapWrp) ? NAN : 8.9 - 2.5*log10(secfilt[Nsec].FapWrp); // 8.9 since flux is in Jy 824 825 liststats (Fkronlist, dkronlist, wkronlist, Nkron, kronstats); 826 secfilt[Nsec].FkronWrp = Nkron > 0 ? kronstats->mean : NAN; 827 secfilt[Nsec].dFkronWrp = Nkron > 0 ? kronstats->error : NAN; 828 secfilt[Nsec].sFkronWrp = Nkron > 0 ? kronstats->sigma : NAN; 829 secfilt[Nsec].NusedKronWrp = Nkron; 830 secfilt[Nsec].MkronWrp = isnan(secfilt[Nsec].FkronWrp) ? NAN : 8.9 - 2.5*log10(secfilt[Nsec].FkronWrp); // 8.9 since flux is in Jy 831 832 secfilt[Nsec].Nwarp = Nwarp; 833 secfilt[Nsec].NwarpGood = NwarpGood; 834 } 835 return (TRUE); 836 } 837 609 838 int setGlobalObjStats (Average *average, Measure *measure) { 610 839 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/setMrelFinal.c
r35759 r37403 85 85 86 86 /* set catalog[0].found[i] = FALSE */ 87 ALLOCATE (catalog[0].found, off_t, MAX (1, Nsecfilt*catalog[0].Naverage)); 87 ALLOCATE (catalog[0].found_t, off_t, MAX (1, Nsecfilt*catalog[0].Naverage)); 88 ALLOCATE (catalog[0].foundWarp_t, off_t, MAX (1, Nsecfilt*catalog[0].Naverage)); 88 89 for (i = 0; i < Nsecfilt*catalog[0].Naverage; i++) { 89 catalog[0].found[i] = FALSE; 90 catalog[0].found_t[i] = FALSE; 91 catalog[0].foundWarp_t[i] = FALSE; 90 92 } 91 93 … … 194 196 195 197 /* star/photcodes already calibrated */ 196 if (catalog[0].found [Nsecfilt*i+Nsec]) continue;198 if (catalog[0].found_t[Nsecfilt*i+Nsec]) continue; 197 199 198 200 m = catalog[0].average[i].measureOffset; … … 229 231 if ((pass < 4) && ImagSelect) { 230 232 if (Nim > -1) { 231 mag = PhotInst (&catalog[0].measure[m] );233 mag = PhotInst (&catalog[0].measure[m], MAG_CLASS_PSF); 232 234 if (mag < ImagMin) goto skip; 233 235 if (mag > ImagMax) goto skip; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/share_mean_mags.c
r36680 r37403 123 123 meanmags->M = secfilt->M; 124 124 meanmags->dM = secfilt->dM; 125 meanmags-> Xm = secfilt->Xm;125 meanmags->Mchisq = secfilt->Mchisq; 126 126 meanmags->Nsec = Nsec; // key to secfilt entry 127 127 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/syncfile.c
r36680 r37403 50 50 int clear_sync_file (char *filename) { 51 51 // delete file contents 52 truncate (filename, 0);52 if (truncate (filename, 0)) fprintf (stderr, "trouble clearing file %s\n", filename); 53 53 54 54 return TRUE; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/tools/Makefile
r31496 r37403 17 17 PROGRAMS = gconfig fhead ftable fields list_astro glockfile \ 18 18 radec mktemp precess csystem fits_insert \ 19 medianfilter mefhead ckfits roc 19 medianfilter mefhead ckfits roc random 20 20 21 21 all tools: $(PROGRAMS) -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/tools/src/ftable.c
r34260 r37403 460 460 } else { 461 461 for (j = 0; j < Nv; j++) { 462 if (!strcmp (type, "byte")) { 463 memcpy (line, &data[i*Nv*Nb + Nb*j], Nb); 464 fprintf (stdout, "%d ", *(char *)line); 465 } 466 if (!strcmp (type, "short")) { 467 memcpy (line, &data[i*Nv*Nb + Nb*j], Nb); 468 fprintf (stdout, "%d ", *(short *)line); 469 } 462 470 if (!strcmp (type, "int")) { 463 471 memcpy (line, &data[i*Nv*Nb + Nb*j], Nb); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/uniphot/src/ImageSubset.c
r33654 r37403 99 99 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_SUBSET"); 100 100 101 gfits_define_bintable_column (&theader, "E", "MCAL", "zero point offset", "magnitudes", 1.0, 0.0); 102 gfits_define_bintable_column (&theader, "E", "MCAL_ERR", "zero point error", "magnitudes", 1.0, 0.0); 103 104 // an unsigned int needs to have bzero of 0x8000 105 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image ID", NULL, 1.0, 1.0*0x8000); 106 gfits_define_bintable_column (&theader, "J", "PHOTOM_MAP", "map", NULL, 1.0, 1.0*0x8000); 107 gfits_define_bintable_column (&theader, "J", "FLAGS", "flags", NULL, 1.0, 1.0*0x8000); 101 gfits_define_bintable_column (&theader, "E", "MCAL", "zero point offset", "magnitudes", 1.0, 0.0); 102 gfits_define_bintable_column (&theader, "E", "MCAL_ERR", "zero point error", "magnitudes", 1.0, 0.0); 103 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image ID", NULL, 1.0, FT_BZERO_INT32); 104 gfits_define_bintable_column (&theader, "J", "PHOTOM_MAP", "map", NULL, 1.0, FT_BZERO_INT32); 105 gfits_define_bintable_column (&theader, "J", "FLAGS", "flags", NULL, 1.0, FT_BZERO_INT32); 108 106 109 107 // generate the output array that carries the data … … 114 112 115 113 // create intermediate storage arrays 116 ALLOCATE (Mcal, float,Nimage);117 ALLOCATE (dMcal, float,Nimage);114 ALLOCATE (Mcal, float, Nimage); 115 ALLOCATE (dMcal, float, Nimage); 118 116 ALLOCATE (imageID, unsigned int, Nimage); 119 117 ALLOCATE (map, unsigned int, Nimage); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/uniphot/src/ImageSubsetFixImageIDs.c
r35764 r37403 1 1 # include "fiximids.h" 2 # define FT_BZERO_INT16 1.0*0x80003 # define FT_BZERO_INT32 1.0*0x800000004 2 5 3 # define GET_COLUMN(OUT,NAME,TYPE) \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/uniphot/src/ImageSubsetFixStackIDs.c
r35764 r37403 1 1 # include "fixstkids.h" 2 # define FT_BZERO_INT16 1.0*0x80003 # define FT_BZERO_INT32 1.0*0x800000004 2 5 3 # define GET_COLUMN(OUT,NAME,TYPE) \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/uniphot/src/ImageSubsetSetPosangle.c
r34749 r37403 149 149 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_SUBSET"); 150 150 151 // an unsigned int needs to have bzero of 0x8000 152 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image ID", NULL, 1.0, 1.0*0x8000); 151 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image ID", NULL, 1.0, FT_BZERO_INT32); 153 152 gfits_define_bintable_column (&theader, "E", "TZERO", "tmp", "mp", 1.0, 0.0); 154 153 gfits_define_bintable_column (&theader, "E", "TRATE", "tmp", "mp", 1.0, 0.0); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/uniphot/src/load_images_fiximids.c
r35764 r37403 1 1 # include "fiximids.h" 2 # define FT_BZERO_INT32 1.0*0x800000003 2 4 3 off_t Nimage = 0; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/uniphot/src/load_images_fixstkids.c
r35764 r37403 1 1 # include "fixstkids.h" 2 # define FT_BZERO_INT32 1.0*0x800000003 2 4 3 off_t Nimage = 0; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/uniphot/src/update_catalog_fiximids.c
r35764 r37403 1 1 # include "fiximids.h" 2 3 // test image: 2013/06/15,13:25:51, GPC1.r.XY50 4 static int CHECK_TEST_IMAGE = FALSE; 5 static unsigned int Tref = 1378812312; 6 static short Cref = 10001; 2 7 3 8 void update_catalog_fiximids (Catalog *catalog) { … … 18 23 short photcode = catalog[0].measure[i].photcode; 19 24 e_time time = catalog[0].measure[i].t; 25 26 if (CHECK_TEST_IMAGE && (abs(time - Tref) < 10) && (photcode == Cref)) { 27 fprintf (stderr, "."); 28 } 20 29 21 30 // skip detections with no valid imageID (eg, ref photcode) -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/uniphot/src/update_catalog_setastrom.c
r35103 r37403 76 76 // correction may be Minst or Minst + 5.0*log(fwhm 77 77 float fwhm_maj = FromShortPixels(measure[0].FWx); 78 float Minst = PhotInst (measure );78 float Minst = PhotInst (measure, MAG_CLASS_PSF); 79 79 float MinstSB = Minst + 5.0*log10(fwhm_maj); 80 80
Note:
See TracChangeset
for help on using the changeset viewer.
