Changeset 37067 for branches/eam_branches/ipp-ops-20130712/Ohana
- Timestamp:
- Jul 17, 2014, 12:32:26 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-ops-20130712/Ohana
- Files:
-
- 330 edited
- 94 copied
-
. (modified) (1 prop)
-
src/addstar/include/addstar.h (modified) (2 diffs)
-
src/addstar/src/FilterStars.c (modified) (1 diff)
-
src/addstar/src/GetFileMode.c (modified) (1 diff)
-
src/addstar/src/LoadDataPMM.c (modified) (1 diff)
-
src/addstar/src/MatchHeaders.c (modified) (1 diff)
-
src/addstar/src/ReadImageHeader.c (modified) (2 diffs)
-
src/addstar/src/ReadStarsFITS.c (modified) (24 diffs)
-
src/addstar/src/ReadStarsSDSS.c (modified) (1 diff)
-
src/addstar/src/SEDfit.c (modified) (1 diff)
-
src/addstar/src/StarOps.c (modified) (1 diff)
-
src/addstar/src/addstar.c (modified) (6 diffs)
-
src/addstar/src/build_links.c (modified) (1 diff)
-
src/addstar/src/fakeimage.c (modified) (4 diffs)
-
src/addstar/src/find_matches.c (modified) (17 diffs)
-
src/addstar/src/find_matches_closest.c (modified) (18 diffs)
-
src/addstar/src/find_matches_closest_refstars.c (modified) (9 diffs)
-
src/addstar/src/find_matches_refstars.c (modified) (8 diffs)
-
src/addstar/src/findskycell.c (modified) (11 diffs)
-
src/addstar/src/load2mass_catalog.c (modified) (2 diffs)
-
src/addstar/src/loadsupercos_ops.c (modified) (5 diffs)
-
src/addstar/src/loadsupercos_plates.c (modified) (1 diff)
-
src/addstar/src/mkcmf.c (modified) (8 diffs)
-
src/addstar/src/replace_match.c (modified) (1 diff)
-
src/addstar/src/resort_catalog.c (modified) (7 diffs)
-
src/addstar/src/resort_threaded.c (modified) (1 diff)
-
src/addstar/src/resort_unthreaded_catalogs.c (modified) (1 diff)
-
src/addstar/src/sky_tessalation.c (modified) (1 diff)
-
src/addstar/src/update_coords.c (modified) (3 diffs)
-
src/addstar/test/simple.dvo (modified) (12 diffs)
-
src/checkastro (copied) (copied from trunk/Ohana/src/checkastro )
-
src/checkastro/Makefile (copied) (copied from trunk/Ohana/src/checkastro/Makefile )
-
src/checkastro/bin (copied) (copied from trunk/Ohana/src/checkastro/bin )
-
src/checkastro/doc (copied) (copied from trunk/Ohana/src/checkastro/doc )
-
src/checkastro/include (copied) (copied from trunk/Ohana/src/checkastro/include )
-
src/checkastro/include/checkastro.h (copied) (copied from trunk/Ohana/src/checkastro/include/checkastro.h )
-
src/checkastro/src (copied) (copied from trunk/Ohana/src/checkastro/src )
-
src/checkastro/src/BrightCatalog.c (copied) (copied from trunk/Ohana/src/checkastro/src/BrightCatalog.c )
-
src/checkastro/src/ConfigInit.c (copied) (copied from trunk/Ohana/src/checkastro/src/ConfigInit.c )
-
src/checkastro/src/ImageOps.c (copied) (copied from trunk/Ohana/src/checkastro/src/ImageOps.c )
-
src/checkastro/src/MeasFilterTest.c (copied) (copied from trunk/Ohana/src/checkastro/src/MeasFilterTest.c )
-
src/checkastro/src/SetSignals.c (copied) (copied from trunk/Ohana/src/checkastro/src/SetSignals.c )
-
src/checkastro/src/Shutdown.c (copied) (copied from trunk/Ohana/src/checkastro/src/Shutdown.c )
-
src/checkastro/src/args.c (copied) (copied from trunk/Ohana/src/checkastro/src/args.c )
-
src/checkastro/src/bcatalog.c (copied) (copied from trunk/Ohana/src/checkastro/src/bcatalog.c )
-
src/checkastro/src/checkastro.c (copied) (copied from trunk/Ohana/src/checkastro/src/checkastro.c )
-
src/checkastro/src/checkastro_client.c (copied) (copied from trunk/Ohana/src/checkastro/src/checkastro_client.c )
-
src/checkastro/src/checkastro_images.c (copied) (copied from trunk/Ohana/src/checkastro/src/checkastro_images.c )
-
src/checkastro/src/initialize.c (copied) (copied from trunk/Ohana/src/checkastro/src/initialize.c )
-
src/checkastro/src/load_catalogs.c (copied) (copied from trunk/Ohana/src/checkastro/src/load_catalogs.c )
-
src/checkastro/src/load_images.c (copied) (copied from trunk/Ohana/src/checkastro/src/load_images.c )
-
src/checkastro/src/select_images.c (copied) (copied from trunk/Ohana/src/checkastro/src/select_images.c )
-
src/delstar/include/delstar.h (modified) (2 diffs)
-
src/delstar/src/ImageOpsFixLAP.c (modified) (1 diff)
-
src/delstar/src/ImageSubsetFixLAP.c (modified) (1 diff)
-
src/delstar/src/MeasureEdgeOps.c (modified) (1 diff)
-
src/delstar/src/args.c (modified) (2 diffs)
-
src/delstar/src/delete_duplicate_images.c (modified) (3 diffs)
-
src/delstar/src/delete_fix_LAP_edges.c (modified) (2 diffs)
-
src/dvomerge (modified) (1 prop)
-
src/dvomerge/src/IDmapIO.c (modified) (1 diff)
-
src/dvomerge/src/dvo_image_merge_dbs.c (modified) (1 diff)
-
src/dvomerge/src/dvomergeImageIDs.c (modified) (2 diffs)
-
src/dvomerge/src/dvomergeUpdate.c (modified) (2 diffs)
-
src/dvomerge/src/dvomergeUpdate_catalogs.c (modified) (4 diffs)
-
src/dvomerge/src/dvomerge_client.c (modified) (1 prop)
-
src/dvomerge/src/dvorepair.c (modified) (1 diff)
-
src/dvomerge/src/dvorepairCPT.c (modified) (2 diffs)
-
src/dvomerge/src/dvorepairDeleteImageList.c (modified) (3 diffs)
-
src/dvomerge/src/dvorepairFixCPT.c (modified) (2 diffs)
-
src/dvomerge/src/dvorepairFixTables.c (modified) (3 diffs)
-
src/dvomerge/src/dvorepairImageVsMeasure.c (modified) (1 diff)
-
src/dvomerge/src/dvorepairImagesVsMeasures.c (modified) (1 diff)
-
src/dvomerge/src/merge_catalogs_old.c (modified) (17 diffs)
-
src/dvomerge/src/replace_match.c (modified) (3 diffs)
-
src/dvopsps/include/dvopsps.h (modified) (2 diffs)
-
src/dvopsps/src/initialize_dvopsps.c (modified) (4 diffs)
-
src/dvopsps/src/insert_detections_dvopsps.c (modified) (4 diffs)
-
src/dvopsps/src/insert_detections_dvopsps_catalog.c (modified) (9 diffs)
-
src/dvopsps/src/insert_objects_dvopsps_catalog.c (modified) (6 diffs)
-
src/dvopsps/src/insert_skytable.c (modified) (3 diffs)
-
src/dvosplit/src/dvosplit.c (modified) (1 diff)
-
src/dvosplit/src/split_averages.c (modified) (1 diff)
-
src/dvosplit/src/split_measures.c (modified) (2 diffs)
-
src/fixcat/src/gcatstats.c (modified) (1 diff)
-
src/gastro/src/gstars.c (modified) (1 diff)
-
src/gastro2/src/coordtest.c (modified) (1 diff)
-
src/gastro2/src/gstars2.c (modified) (2 diffs)
-
src/getstar (modified) (1 prop)
-
src/getstar/src/GetFileMode.c (modified) (1 diff)
-
src/getstar/src/MatchImages.c (modified) (2 diffs)
-
src/getstar/src/ReadImageFiles.c (modified) (1 diff)
-
src/getstar/src/dvoImagesAtCoords.c (modified) (1 prop)
-
src/getstar/src/select_by_region.c (modified) (2 diffs)
-
src/getstar/src/write_getstar_ps1_dev_0.c (modified) (3 diffs)
-
src/getstar/src/write_getstar_ps1_dev_1.c (modified) (3 diffs)
-
src/getstar/src/write_getstar_ps1_dev_2.c (modified) (3 diffs)
-
src/kapa2/include/constants.h (modified) (1 diff)
-
src/kapa2/src/CheckPipe.c (modified) (2 diffs)
-
src/kapa2/src/DrawObjects.c (modified) (1 diff)
-
src/kapa2/src/EventLoop.c (modified) (3 diffs)
-
src/kapa2/src/FlushDisplay.c (modified) (1 diff)
-
src/kapa2/src/Graphs.c (modified) (1 diff)
-
src/kapa2/src/Image.c (modified) (1 diff)
-
src/kapa2/src/Refresh.c (modified) (1 diff)
-
src/kapa2/src/bDrawObjects.c (modified) (11 diffs)
-
src/libautocode/Makefile.Targets (modified) (13 diffs)
-
src/libautocode/def/average-ps1-dev-2.d (modified) (1 diff)
-
src/libautocode/def/average-ps1-v1.d (modified) (1 diff)
-
src/libautocode/def/average-ps1-v2.d (modified) (1 diff)
-
src/libautocode/def/average-ps1-v3.d (modified) (1 diff)
-
src/libautocode/def/average-ps1-v4.d (modified) (1 diff)
-
src/libautocode/def/average-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/average-ps1-v5.d )
-
src/libautocode/def/average.d (modified) (5 diffs)
-
src/libautocode/def/cmf-ps1-dv4.d (copied) (copied from trunk/Ohana/src/libautocode/def/cmf-ps1-dv4.d )
-
src/libautocode/def/cmf-ps1-sv3.d (copied) (copied from trunk/Ohana/src/libautocode/def/cmf-ps1-sv3.d )
-
src/libautocode/def/cmf-ps1-v5-lensing.d (copied) (copied from trunk/Ohana/src/libautocode/def/cmf-ps1-v5-lensing.d )
-
src/libautocode/def/cmf-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/cmf-ps1-v5.d )
-
src/libautocode/def/common.h (modified) (1 diff)
-
src/libautocode/def/image-ps1-v2.d (modified) (1 diff)
-
src/libautocode/def/image-ps1-v3.d (modified) (1 diff)
-
src/libautocode/def/image-ps1-v4.d (modified) (1 diff)
-
src/libautocode/def/image-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/image-ps1-v5.d )
-
src/libautocode/def/image.d (modified) (1 diff)
-
src/libautocode/def/lensing-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/lensing-ps1-v5.d )
-
src/libautocode/def/lensing.d (copied) (copied from trunk/Ohana/src/libautocode/def/lensing.d )
-
src/libautocode/def/lensobj-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/lensobj-ps1-v5.d )
-
src/libautocode/def/lensobj.d (copied) (copied from trunk/Ohana/src/libautocode/def/lensobj.d )
-
src/libautocode/def/measure-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/measure-ps1-v5.d )
-
src/libautocode/def/measure.d (modified) (7 diffs)
-
src/libautocode/def/photcode-ps1-v2.d (modified) (1 diff)
-
src/libautocode/def/photcode-ps1-v3.d (modified) (1 diff)
-
src/libautocode/def/photcode-ps1-v4.d (modified) (1 diff)
-
src/libautocode/def/photcode-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/photcode-ps1-v5.d )
-
src/libautocode/def/photcode.d (modified) (1 diff)
-
src/libautocode/def/secfilt-ps1-v1.d (modified) (1 diff)
-
src/libautocode/def/secfilt-ps1-v2.d (modified) (1 diff)
-
src/libautocode/def/secfilt-ps1-v3.d (modified) (1 diff)
-
src/libautocode/def/secfilt-ps1-v4.d (modified) (1 diff)
-
src/libautocode/def/secfilt-ps1-v5.d (copied) (copied from trunk/Ohana/src/libautocode/def/secfilt-ps1-v5.d )
-
src/libautocode/def/secfilt.d (modified) (1 diff)
-
src/libautocode/doc/sizes.ps1-v5.txt (copied) (copied from trunk/Ohana/src/libautocode/doc/sizes.ps1-v5.txt )
-
src/libdvo/Makefile (modified) (4 diffs)
-
src/libdvo/doc/notes.ps1v5.txt (copied) (copied from trunk/Ohana/src/libdvo/doc/notes.ps1v5.txt )
-
src/libdvo/include/cmf-ps1-sv3.h (copied) (copied from trunk/Ohana/src/libdvo/include/cmf-ps1-sv3.h )
-
src/libdvo/include/cmf-ps1-v5-lensing.h (copied) (copied from trunk/Ohana/src/libdvo/include/cmf-ps1-v5-lensing.h )
-
src/libdvo/include/cmf-ps1-v5.h (copied) (copied from trunk/Ohana/src/libdvo/include/cmf-ps1-v5.h )
-
src/libdvo/include/dvo.h (modified) (20 diffs)
-
src/libdvo/include/dvodb.h (modified) (9 diffs)
-
src/libdvo/include/elixir_defs.h (modified) (1 diff)
-
src/libdvo/include/loneos_defs.h (modified) (1 diff)
-
src/libdvo/include/panstarrs_dev_0_defs.h (modified) (1 diff)
-
src/libdvo/include/panstarrs_dev_1_defs.h (modified) (1 diff)
-
src/libdvo/include/ps1_dev_1_defs.h (modified) (1 diff)
-
src/libdvo/include/ps1_dev_2_defs.h (modified) (1 diff)
-
src/libdvo/include/ps1_ref_defs.h (modified) (1 diff)
-
src/libdvo/include/ps1_v1_defs.h (modified) (1 diff)
-
src/libdvo/include/ps1_v2_defs.h (modified) (1 diff)
-
src/libdvo/include/ps1_v3_defs.h (modified) (1 diff)
-
src/libdvo/include/ps1_v4_defs.h (modified) (1 diff)
-
src/libdvo/include/ps1_v5_defs.h (copied) (copied from trunk/Ohana/src/libdvo/include/ps1_v5_defs.h )
-
src/libdvo/src/BoundaryTree.c (modified) (4 diffs)
-
src/libdvo/src/HostTable.c (modified) (2 diffs)
-
src/libdvo/src/ImageMetadata.c (modified) (1 diff)
-
src/libdvo/src/ImageMetadataSelection.c (modified) (2 diffs)
-
src/libdvo/src/ImageSelection.c (modified) (1 diff)
-
src/libdvo/src/LoadPhotcodesFITS.c (modified) (2 diffs)
-
src/libdvo/src/LoadPhotcodesText.c (modified) (2 diffs)
-
src/libdvo/src/RegionHostTable.c (copied) (copied from trunk/Ohana/src/libdvo/src/RegionHostTable.c )
-
src/libdvo/src/SavePhotcodesFITS.c (modified) (1 diff)
-
src/libdvo/src/TessellationTable.c (copied) (copied from trunk/Ohana/src/libdvo/src/TessellationTable.c )
-
src/libdvo/src/cmf-ps1-dv3.c (modified) (1 diff)
-
src/libdvo/src/cmf-ps1-sv3.c (copied) (copied from trunk/Ohana/src/libdvo/src/cmf-ps1-sv3.c )
-
src/libdvo/src/cmf-ps1-v5-lensing.c (copied) (copied from trunk/Ohana/src/libdvo/src/cmf-ps1-v5-lensing.c )
-
src/libdvo/src/cmf-ps1-v5.c (copied) (copied from trunk/Ohana/src/libdvo/src/cmf-ps1-v5.c )
-
src/libdvo/src/coordops.c (modified) (2 diffs)
-
src/libdvo/src/dbCheckStack.c (modified) (1 diff)
-
src/libdvo/src/dbExtractAverages.c (modified) (8 diffs)
-
src/libdvo/src/dbExtractImages.c (modified) (7 diffs)
-
src/libdvo/src/dbExtractMeasures.c (modified) (19 diffs)
-
src/libdvo/src/dbFields.c (modified) (10 diffs)
-
src/libdvo/src/dvo_catalog.c (modified) (23 diffs)
-
src/libdvo/src/dvo_catalog_chipcoords.c (modified) (1 diff)
-
src/libdvo/src/dvo_catalog_create.c (modified) (3 diffs)
-
src/libdvo/src/dvo_catalog_mef.c (modified) (10 diffs)
-
src/libdvo/src/dvo_catalog_raw.c (modified) (12 diffs)
-
src/libdvo/src/dvo_catalog_split.c (modified) (27 diffs)
-
src/libdvo/src/dvo_convert.c (modified) (15 diffs)
-
src/libdvo/src/dvo_convert_PS1_DEV_1.c (modified) (9 diffs)
-
src/libdvo/src/dvo_convert_PS1_DEV_2.c (modified) (11 diffs)
-
src/libdvo/src/dvo_convert_PS1_DEV_3.c (modified) (3 diffs)
-
src/libdvo/src/dvo_convert_PS1_REF.c (modified) (7 diffs)
-
src/libdvo/src/dvo_convert_PS1_V1.c (modified) (10 diffs)
-
src/libdvo/src/dvo_convert_PS1_V2.c (modified) (12 diffs)
-
src/libdvo/src/dvo_convert_PS1_V3.c (modified) (13 diffs)
-
src/libdvo/src/dvo_convert_PS1_V4.c (modified) (14 diffs)
-
src/libdvo/src/dvo_convert_PS1_V5.c (copied) (copied from trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c )
-
src/libdvo/src/dvo_convert_elixir.c (modified) (11 diffs)
-
src/libdvo/src/dvo_convert_loneos.c (modified) (11 diffs)
-
src/libdvo/src/dvo_convert_panstarrs_DEV_0.c (modified) (9 diffs)
-
src/libdvo/src/dvo_convert_panstarrs_DEV_1.c (modified) (9 diffs)
-
src/libdvo/src/dvo_image.c (modified) (1 diff)
-
src/libdvo/src/dvo_image_raw.c (modified) (2 diffs)
-
src/libdvo/src/dvo_photcode_ops.c (modified) (19 diffs)
-
src/libdvo/src/dvo_tiny_values.c (modified) (2 diffs)
-
src/libdvo/src/dvosorts.c (modified) (1 diff)
-
src/libdvo/src/skyregion_io.c (modified) (1 diff)
-
src/libfits/include/gfitsio.h (modified) (1 diff)
-
src/libfits/matrix/F_compress_M.c (modified) (2 diffs)
-
src/libfits/table/F_get_column.c (modified) (2 diffs)
-
src/libfits/table/F_set_column.c (modified) (9 diffs)
-
src/libfits/table/F_table_format.c (modified) (5 diffs)
-
src/libkapa/src/IOfuncs.c (modified) (2 diffs)
-
src/libkapa/src/KapaOpen.c (modified) (8 diffs)
-
src/libkapa/src/KapaWindow.c (modified) (1 diff)
-
src/libkapa/src/KiiPicture.c (modified) (5 diffs)
-
src/libkapa/src/bDrawFuncs.c (modified) (2 diffs)
-
src/libohana/include/ohana.h (modified) (3 diffs)
-
src/libohana/src (modified) (1 prop)
-
src/libohana/src/gaussj.c (modified) (3 diffs)
-
src/libohana/src/string.c (modified) (13 diffs)
-
src/markrock/src/gcatstats.c (modified) (1 diff)
-
src/markstar/src/gcatstats.c (modified) (1 diff)
-
src/mosastro/src/warptest.c (modified) (1 diff)
-
src/opihi (modified) (1 prop)
-
src/opihi/cmd.astro (modified) (1 prop)
-
src/opihi/cmd.astro/Makefile (modified) (2 diffs)
-
src/opihi/cmd.astro/cdensify.c (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/cdensify.c )
-
src/opihi/cmd.astro/fitplx.c (modified) (6 diffs)
-
src/opihi/cmd.astro/fitpm.c (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/fitpm.c )
-
src/opihi/cmd.astro/gauss.c (modified) (3 diffs)
-
src/opihi/cmd.astro/init.c (modified) (4 diffs)
-
src/opihi/cmd.astro/region.c (modified) (1 diff)
-
src/opihi/cmd.astro/sersic.c (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/sersic.c )
-
src/opihi/cmd.astro/star.c (modified) (2 diffs)
-
src/opihi/cmd.basic/Makefile (modified) (1 diff)
-
src/opihi/cmd.basic/init.c (modified) (2 diffs)
-
src/opihi/cmd.basic/list.c (modified) (9 diffs)
-
src/opihi/cmd.basic/strmatch.c (copied) (copied from trunk/Ohana/src/opihi/cmd.basic/strmatch.c )
-
src/opihi/cmd.data (modified) (1 prop)
-
src/opihi/cmd.data/Makefile (modified) (5 diffs)
-
src/opihi/cmd.data/cast.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/cast.c )
-
src/opihi/cmd.data/densify.c (modified) (5 diffs)
-
src/opihi/cmd.data/impeaks.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/impeaks.c )
-
src/opihi/cmd.data/imsmooth.2d.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/imsmooth.2d.c )
-
src/opihi/cmd.data/imsmooth.generic.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/imsmooth.generic.c )
-
src/opihi/cmd.data/init.c (modified) (10 diffs)
-
src/opihi/cmd.data/join.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/join.c )
-
src/opihi/cmd.data/match2d.c (modified) (3 diffs)
-
src/opihi/cmd.data/medimage.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/medimage.c )
-
src/opihi/cmd.data/medimage_commands.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/medimage_commands.c )
-
src/opihi/cmd.data/print_vectors.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/print_vectors.c )
-
src/opihi/cmd.data/read_vectors.c (modified) (20 diffs)
-
src/opihi/cmd.data/rebin.c (modified) (1 diff)
-
src/opihi/cmd.data/test/join.sh (copied) (copied from trunk/Ohana/src/opihi/cmd.data/test/join.sh )
-
src/opihi/cmd.data/test/medimage.sh (copied) (copied from trunk/Ohana/src/opihi/cmd.data/test/medimage.sh )
-
src/opihi/cmd.data/vellipse.c (modified) (1 diff)
-
src/opihi/cmd.data/vgauss.c (modified) (2 diffs)
-
src/opihi/cmd.data/vlist.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/vlist.c )
-
src/opihi/dvo/Makefile (modified) (2 diffs)
-
src/opihi/dvo/avextract.c (modified) (1 diff)
-
src/opihi/dvo/avmatch.c (modified) (3 diffs)
-
src/opihi/dvo/coordimage.c (copied) (copied from trunk/Ohana/src/opihi/dvo/coordimage.c )
-
src/opihi/dvo/coordmosaic.c (copied) (copied from trunk/Ohana/src/opihi/dvo/coordmosaic.c )
-
src/opihi/dvo/dvo_client.c (modified) (1 diff)
-
src/opihi/dvo/find_matches.c (modified) (1 diff)
-
src/opihi/dvo/fitsed.c (modified) (1 diff)
-
src/opihi/dvo/gimages.c (modified) (1 diff)
-
src/opihi/dvo/gstar.c (modified) (11 diffs)
-
src/opihi/dvo/hosts.c (modified) (8 diffs)
-
src/opihi/dvo/imdata.c (modified) (4 diffs)
-
src/opihi/dvo/imextract.c (modified) (1 diff)
-
src/opihi/dvo/init.c (modified) (2 diffs)
-
src/opihi/dvo/lcurve.c (modified) (1 diff)
-
src/opihi/dvo/lightcurve.c (modified) (1 diff)
-
src/opihi/dvo/photcode_ops.c (copied) (copied from trunk/Ohana/src/opihi/dvo/photcode_ops.c )
-
src/opihi/dvo/photometry.c (modified) (13 diffs)
-
src/opihi/dvo/pmeasure.c (modified) (1 diff)
-
src/opihi/dvo/showtile.c (modified) (1 diff)
-
src/opihi/dvo/simage.c (modified) (1 diff)
-
src/opihi/dvo/subpix.c (modified) (1 diff)
-
src/opihi/include/data.h (modified) (4 diffs)
-
src/opihi/include/dvomath.h (modified) (3 diffs)
-
src/opihi/include/dvoshell.h (modified) (1 diff)
-
src/opihi/include/pantasks.h (modified) (2 diffs)
-
src/opihi/include/pcontrol.h (modified) (3 diffs)
-
src/opihi/include/shell.h (modified) (1 diff)
-
src/opihi/lib.data/Makefile (modified) (1 diff)
-
src/opihi/lib.data/MedImageOps.c (copied) (copied from trunk/Ohana/src/opihi/lib.data/MedImageOps.c )
-
src/opihi/lib.data/starfuncs.c (modified) (2 diffs)
-
src/opihi/lib.shell/ListOps.c (modified) (1 diff)
-
src/opihi/lib.shell/VectorIO.c (modified) (3 diffs)
-
src/opihi/lib.shell/check_stack.c (modified) (5 diffs)
-
src/opihi/lib.shell/convert_to_RPN.c (modified) (6 diffs)
-
src/opihi/lib.shell/dvomath.c (modified) (1 diff)
-
src/opihi/lib.shell/evaluate_stack.c (modified) (7 diffs)
-
src/opihi/lib.shell/macro_list.c (modified) (1 diff)
-
src/opihi/lib.shell/stack_math.c (modified) (62 diffs)
-
src/opihi/lib.shell/string.c (modified) (1 diff)
-
src/opihi/pantasks/CheckController.c (modified) (2 diffs)
-
src/opihi/pantasks/ControllerOps.c (modified) (1 diff)
-
src/opihi/pantasks/JobOps.c (modified) (1 diff)
-
src/opihi/pantasks/LocalJob.c (modified) (1 diff)
-
src/opihi/pantasks/TaskOps.c (modified) (1 diff)
-
src/opihi/pantasks/init.c (modified) (1 diff)
-
src/opihi/pantasks/init_server.c (modified) (1 diff)
-
src/opihi/pantasks/task_nice.c (modified) (2 diffs)
-
src/opihi/pclient/job.c (modified) (2 diffs)
-
src/opihi/pcontrol/CheckBusyJob.c (modified) (1 diff)
-
src/opihi/pcontrol/JobOps.c (modified) (3 diffs)
-
src/opihi/pcontrol/StartJob.c (modified) (1 diff)
-
src/opihi/pcontrol/job.c (modified) (4 diffs)
-
src/opihi/pcontrol/jobstack.c (modified) (1 diff)
-
src/opihi/pcontrol/status.c (modified) (4 diffs)
-
src/photdbc/Makefile (modified) (2 diffs)
-
src/photdbc/include/photdbc.h (modified) (3 diffs)
-
src/photdbc/src/args.c (modified) (4 diffs)
-
src/photdbc/src/copy_images.c (modified) (2 diffs)
-
src/photdbc/src/find_images.c (modified) (1 diff)
-
src/photdbc/src/get_mags.c (modified) (2 diffs)
-
src/photdbc/src/initialize.c (modified) (2 diffs)
-
src/photdbc/src/join_stars.c (modified) (6 diffs)
-
src/photdbc/src/make_subcatalog.c (modified) (7 diffs)
-
src/photdbc/src/photdbc.c (modified) (1 diff)
-
src/photdbc/src/photdbc_catalogs.c (modified) (1 diff)
-
src/photdbc/src/select_images.c (copied) (copied from trunk/Ohana/src/photdbc/src/select_images.c )
-
src/relastro/Makefile (modified) (2 diffs)
-
src/relastro/doc/pv2.txt (copied) (copied from trunk/Ohana/src/relastro/doc/pv2.txt )
-
src/relastro/include/relastro.h (modified) (12 diffs)
-
src/relastro/src (modified) (1 prop)
-
src/relastro/src/BrightCatalog.c (modified) (20 diffs)
-
src/relastro/src/ConfigInit.c (modified) (3 diffs)
-
src/relastro/src/FitChip.c (modified) (7 diffs)
-
src/relastro/src/GetAstromError.c (modified) (2 diffs)
-
src/relastro/src/ImageOps.c (modified) (28 diffs)
-
src/relastro/src/ImagePosIO.c (copied) (copied from trunk/Ohana/src/relastro/src/ImagePosIO.c )
-
src/relastro/src/ImageTable.c (copied) (copied from trunk/Ohana/src/relastro/src/ImageTable.c )
-
src/relastro/src/MeanPosIO.c (copied) (copied from trunk/Ohana/src/relastro/src/MeanPosIO.c )
-
src/relastro/src/MosaicOps.c (modified) (8 diffs)
-
src/relastro/src/Shutdown.c (modified) (1 diff)
-
src/relastro/src/StarMaps.c (modified) (1 diff)
-
src/relastro/src/UpdateObjectOffsets.c (modified) (1 diff)
-
src/relastro/src/UpdateObjects.c (modified) (17 diffs)
-
src/relastro/src/args.c (modified) (20 diffs)
-
src/relastro/src/assign_images.c (copied) (copied from trunk/Ohana/src/relastro/src/assign_images.c )
-
src/relastro/src/bcatalog.c (modified) (10 diffs)
-
src/relastro/src/dvo_astrom_ops.c (modified) (3 diffs)
-
src/relastro/src/high_speed_objects.c (modified) (3 diffs)
-
src/relastro/src/hpm_objects.c (modified) (2 diffs)
-
src/relastro/src/indexCatalogs.c (copied) (copied from trunk/Ohana/src/relastro/src/indexCatalogs.c )
-
src/relastro/src/initialize.c (modified) (2 diffs)
-
src/relastro/src/launch_region_hosts.c (copied) (copied from trunk/Ohana/src/relastro/src/launch_region_hosts.c )
-
src/relastro/src/load_catalogs.c (modified) (10 diffs)
-
src/relastro/src/load_images.c (modified) (3 diffs)
-
src/relastro/src/markObjects.c (copied) (copied from trunk/Ohana/src/relastro/src/markObjects.c )
-
src/relastro/src/relastro.c (modified) (1 diff)
-
src/relastro/src/relastroVisual.c (modified) (2 diffs)
-
src/relastro/src/relastro_client.c (modified) (4 diffs)
-
src/relastro/src/relastro_images.c (modified) (3 diffs)
-
src/relastro/src/relastro_merge_source.c (modified) (1 diff)
-
src/relastro/src/relastro_objects.c (modified) (2 diffs)
-
src/relastro/src/relastro_parallel_images.c (copied) (copied from trunk/Ohana/src/relastro/src/relastro_parallel_images.c )
-
src/relastro/src/relastro_parallel_regions.c (copied) (copied from trunk/Ohana/src/relastro/src/relastro_parallel_regions.c )
-
src/relastro/src/resort_catalog.c (modified) (1 diff)
-
src/relastro/src/select_images.c (modified) (5 diffs)
-
src/relastro/src/share_images_pos.c (copied) (copied from trunk/Ohana/src/relastro/src/share_images_pos.c )
-
src/relastro/src/share_mean_pos.c (copied) (copied from trunk/Ohana/src/relastro/src/share_mean_pos.c )
-
src/relastro/src/syncfile.c (copied) (copied from trunk/Ohana/src/relastro/src/syncfile.c )
-
src/relastro/src/testparallax.c (modified) (1 diff)
-
src/relphot/Makefile (modified) (3 diffs)
-
src/relphot/doc/mosaic.txt (modified) (1 diff)
-
src/relphot/doc/parallel.txt (modified) (1 diff)
-
src/relphot/doc/pv2.txt (copied) (copied from trunk/Ohana/src/relphot/doc/pv2.txt )
-
src/relphot/include/relphot.h (modified) (12 diffs)
-
src/relphot/src/BoundaryTreeOps.c (modified) (2 diffs)
-
src/relphot/src/BrightCatalog.c (modified) (20 diffs)
-
src/relphot/src/GridOps.c (modified) (3 diffs)
-
src/relphot/src/ImageMagIO.c (copied) (copied from trunk/Ohana/src/relphot/src/ImageMagIO.c )
-
src/relphot/src/ImageOps.c (modified) (28 diffs)
-
src/relphot/src/ImageSubset.c (modified) (8 diffs)
-
src/relphot/src/ImageTable.c (copied) (copied from trunk/Ohana/src/relphot/src/ImageTable.c )
-
src/relphot/src/MeanMagIO.c (copied) (copied from trunk/Ohana/src/relphot/src/MeanMagIO.c )
-
src/relphot/src/MosaicOps.c (modified) (32 diffs)
-
src/relphot/src/Shutdown.c (modified) (1 diff)
-
src/relphot/src/StarOps.c (modified) (21 diffs)
-
src/relphot/src/args.c (modified) (4 diffs)
-
src/relphot/src/assign_images.c (copied) (copied from trunk/Ohana/src/relphot/src/assign_images.c )
-
src/relphot/src/bcatalog.c (modified) (10 diffs)
-
src/relphot/src/client_logger.c (modified) (2 diffs)
-
src/relphot/src/extra.c (copied) (copied from trunk/Ohana/src/relphot/src/extra.c )
-
src/relphot/src/help.c (modified) (2 diffs)
-
src/relphot/src/indexCatalog.c (copied) (copied from trunk/Ohana/src/relphot/src/indexCatalog.c )
-
src/relphot/src/initialize.c (modified) (6 diffs)
-
src/relphot/src/launch_region_hosts.c (copied) (copied from trunk/Ohana/src/relphot/src/launch_region_hosts.c )
-
src/relphot/src/load_catalogs.c (modified) (6 diffs)
-
src/relphot/src/plot_scatter.c (modified) (1 diff)
-
src/relphot/src/reload_catalogs.c (modified) (1 diff)
-
src/relphot/src/relphot.c (modified) (1 diff)
-
src/relphot/src/relphot_client.c (modified) (2 diffs)
-
src/relphot/src/relphot_images.c (modified) (2 diffs)
-
src/relphot/src/relphot_parallel_images.c (copied) (copied from trunk/Ohana/src/relphot/src/relphot_parallel_images.c )
-
src/relphot/src/relphot_parallel_regions.c (copied) (copied from trunk/Ohana/src/relphot/src/relphot_parallel_regions.c )
-
src/relphot/src/select_images.c (modified) (2 diffs)
-
src/relphot/src/setExclusions.c (modified) (1 diff)
-
src/relphot/src/setMrelCatalog.c (modified) (24 diffs)
-
src/relphot/src/setMrelFinal.c (modified) (3 diffs)
-
src/relphot/src/share_image_mags.c (copied) (copied from trunk/Ohana/src/relphot/src/share_image_mags.c )
-
src/relphot/src/share_mean_mags.c (copied) (copied from trunk/Ohana/src/relphot/src/share_mean_mags.c )
-
src/relphot/src/syncfile.c (copied) (copied from trunk/Ohana/src/relphot/src/syncfile.c )
-
src/tools/Makefile (modified) (1 diff)
-
src/tools/src/ftable.c (modified) (1 diff)
-
src/tools/src/medianfilter.c (modified) (2 diffs)
-
src/tools/src/random.c (copied) (copied from trunk/Ohana/src/tools/src/random.c )
-
src/uniphot/src/ImageSubset.c (modified) (2 diffs)
-
src/uniphot/src/ImageSubsetFixImageIDs.c (modified) (1 diff)
-
src/uniphot/src/ImageSubsetFixStackIDs.c (modified) (1 diff)
-
src/uniphot/src/ImageSubsetSetPosangle.c (modified) (1 diff)
-
src/uniphot/src/find_image_sgroups.c (modified) (1 diff)
-
src/uniphot/src/load_images_fiximids.c (modified) (1 diff)
-
src/uniphot/src/load_images_fixstkids.c (modified) (1 diff)
-
src/uniphot/src/update_catalog_fiximids.c (modified) (2 diffs)
-
src/uniphot/src/update_catalog_setastrom.c (modified) (1 diff)
-
src/uniphot/src/update_dvo_setphot.c (modified) (1 diff)
-
src/uniphot/src/update_dvo_uniphot.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-ops-20130712/Ohana
- Property svn:mergeinfo deleted
-
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/include/addstar.h
r35579 r37067 41 41 42 42 typedef struct { 43 Average average; 44 Measure measure; 43 Average average; 44 Measure measure; 45 Lensing *lensing; // optionally carry out the lensing measurements 45 46 int found; 46 47 } Stars; … … 250 251 void update_coords PROTO((Average *average, Measure *measure, off_t *next)); 251 252 off_t *init_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure)); 253 off_t *init_lensing_links PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing)); 252 254 off_t *init_missing_links PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing)); 253 255 off_t add_meas_link PROTO((Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE)); 254 256 off_t add_miss_link PROTO((Average *average, off_t *next_miss, off_t Nmissing)); 257 off_t add_lens_link PROTO((Average *average, off_t *next_lens, off_t Nlensing, off_t NLENSING)); 255 258 off_t *build_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure)); 259 off_t *build_lensing_links PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing)); 256 260 Measure *sort_measure PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next_meas)); 257 261 Missing *sort_missing PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss)); 262 Lensing *sort_lensing PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next_lens)); 258 263 int ImageOptions PROTO((AddstarClientOptions *options, Image *images, off_t Nimages)); 259 264 int GetFileMode PROTO((Header *header)); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/FilterStars.c
r34260 r37067 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? -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/GetFileMode.c
r35416 r37067 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); 14 int haveCTYPE = gfits_scan (header, "CTYPE 1", "%s", 1, ctype);15 int haveCTYPE = gfits_scan (header, "CTYPE2", "%s", 1, ctype); 15 16 16 17 gfits_scan_alt (header, "EXTEND", "%t", 1, &extend); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/LoadDataPMM.c
r34088 r37067 193 193 194 194 // XXX for now, we define a totally fake coordinate system centered on the plate center 195 strcpy (image[0].coords.ctype, " RA---TAN");195 strcpy (image[0].coords.ctype, "DEC--TAN"); 196 196 197 197 image[0].coords.crval1 = pmm_get_ra (RA); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/MatchHeaders.c
r35416 r37067 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 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/ReadImageHeader.c
r31395 r37067 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/ipp-ops-20130712/Ohana/src/addstar/src/ReadStarsFITS.c
r35416 r37067 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 … … 360 394 stars[i].measure.dMcal = ps1data[i].dMcal; 361 395 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 396 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure 362 397 363 398 stars[i].measure.Mkron = NAN; // not provided by PS1_V1: … … 445 480 stars[i].measure.dMcal = ps1data[i].dMcal; 446 481 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 482 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure 447 483 448 484 stars[i].measure.Mkron = NAN; // not provided by PS1_V1_Alt: … … 522 558 stars[i].measure.dMcal = ps1data[i].dMcal; 523 559 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 560 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure 524 561 525 562 stars[i].measure.Mkron = NAN; // not provided by PS1_V2: … … 595 632 stars[i].measure.dMcal = ps1data[i].dMcal; 596 633 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 634 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure 597 635 598 636 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; … … 600 638 601 639 // 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;640 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 641 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 604 642 stars[i].measure.FluxKron = ps1data[i].kronFlux; 605 643 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 644 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (NAN, ps1data[i].Map); 645 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (NAN, stars[i].measure.FluxAp, stars[i].measure.dMap); 606 646 607 647 stars[i].measure.Sky = ps1data[i].sky; … … 676 716 stars[i].measure.dMcal = ps1data[i].dMcal; 677 717 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 718 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 678 719 679 720 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; … … 681 722 682 723 // 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;724 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 725 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 685 726 stars[i].measure.FluxKron = ps1data[i].kronFlux; 686 727 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 728 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 729 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 687 730 688 731 stars[i].measure.Sky = ps1data[i].sky; … … 724 767 } 725 768 726 Stars *Convert_PS1_ SV1(FTable *table, unsigned int *nstars) {769 Stars *Convert_PS1_V5 (FTable *table, unsigned int *nstars) { 727 770 728 771 off_t Nstars; … … 730 773 double ZeroPt; 731 774 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); 775 CMF_PS1_V5 *ps1data; 776 777 ps1data = gfits_table_get_CMF_PS1_V5 (table, &Nstars, NULL); 740 778 if (!ps1data) { 741 779 fprintf (stderr, "skipping inconsistent entry\n"); … … 763 801 stars[i].measure.dMcal = ps1data[i].dMcal; 764 802 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 803 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 765 804 766 805 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 767 806 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 768 807 769 808 // 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;809 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 810 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 772 811 stars[i].measure.FluxKron = ps1data[i].kronFlux; 773 812 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 813 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 814 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 774 815 775 816 stars[i].measure.Sky = ps1data[i].sky; … … 799 840 800 841 // 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. 842 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID. 843 844 // averef is set in find_matches 845 846 // dbFlags is zero on ingest. 803 847 804 848 // the following fields are currently not being set anywhere: t_msec … … 808 852 } 809 853 810 Stars *Convert_PS1_ SV1_Alt(FTable *table, unsigned int *nstars) {854 Stars *Convert_PS1_V5_Lensing (FTable *table, unsigned int *nstars) { 811 855 812 856 off_t Nstars; … … 814 858 double ZeroPt; 815 859 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); 860 CMF_PS1_V5_Lensing *ps1data; 861 862 ps1data = gfits_table_get_CMF_PS1_V5_Lensing (table, &Nstars, NULL); 821 863 if (!ps1data) { 822 864 fprintf (stderr, "skipping inconsistent entry\n"); … … 844 886 stars[i].measure.dMcal = ps1data[i].dMcal; 845 887 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 888 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 846 889 847 890 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 848 891 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 849 892 850 893 // 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;894 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 895 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 853 896 stars[i].measure.FluxKron = ps1data[i].kronFlux; 854 897 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 898 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 899 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 900 901 stars[i].measure.Sky = ps1data[i].sky; 902 stars[i].measure.dSky = ps1data[i].dSky; 903 904 stars[i].measure.psfChisq = ps1data[i].psfChisq; 905 stars[i].measure.psfQF = ps1data[i].psfQF; 906 stars[i].measure.psfQFperf = ps1data[i].psfQFperf; 907 908 stars[i].measure.psfNdof = ps1data[i].psfNdof; 909 stars[i].measure.psfNpix = ps1data[i].psfNpix; 910 stars[i].measure.crNsigma = ps1data[i].crNsigma; 911 stars[i].measure.extNsigma = ps1data[i].extNsigma; 912 913 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 914 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 915 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 916 917 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx); 918 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy); 919 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy); 920 921 stars[i].measure.photFlags = ps1data[i].flags; 922 923 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 924 stars[i].measure.detID = ps1data[i].detID; 925 926 ALLOCATE (stars[i].lensing, Lensing, 1); 927 dvo_lensing_init (stars[i].lensing); 928 929 stars[i].lensing->X11_sm_obj = ps1data[i].X11_sm_obj; 930 stars[i].lensing->X12_sm_obj = ps1data[i].X12_sm_obj; 931 stars[i].lensing->X22_sm_obj = ps1data[i].X22_sm_obj; 932 stars[i].lensing->E1_sm_obj = ps1data[i].E1_sm_obj; 933 stars[i].lensing->E2_sm_obj = ps1data[i].E2_sm_obj; 934 935 stars[i].lensing->X11_sh_obj = ps1data[i].X11_sh_obj; 936 stars[i].lensing->X12_sh_obj = ps1data[i].X12_sh_obj; 937 stars[i].lensing->X22_sh_obj = ps1data[i].X22_sh_obj; 938 stars[i].lensing->E1_sh_obj = ps1data[i].E1_sh_obj; 939 stars[i].lensing->E2_sh_obj = ps1data[i].E2_sh_obj; 940 941 stars[i].lensing->X11_sm_psf = ps1data[i].X11_sm_psf; 942 stars[i].lensing->X12_sm_psf = ps1data[i].X12_sm_psf; 943 stars[i].lensing->X22_sm_psf = ps1data[i].X22_sm_psf; 944 stars[i].lensing->E1_sm_psf = ps1data[i].E1_sm_psf; 945 stars[i].lensing->E2_sm_psf = ps1data[i].E2_sm_psf; 946 947 stars[i].lensing->X11_sh_psf = ps1data[i].X11_sh_psf; 948 stars[i].lensing->X12_sh_psf = ps1data[i].X12_sh_psf; 949 stars[i].lensing->X22_sh_psf = ps1data[i].X22_sh_psf; 950 stars[i].lensing->E1_sh_psf = ps1data[i].E1_sh_psf; 951 stars[i].lensing->E2_sh_psf = ps1data[i].E2_sh_psf; 952 953 // stars[i].lensing->F_ApR5 = ps1data[i].F_ApR5; 954 // stars[i].lensing->dF_ApR5 = ps1data[i].dF_ApR5; 955 // stars[i].lensing->sF_ApR5 = ps1data[i].sF_ApR5; 956 // stars[i].lensing->fF_ApR5 = ps1data[i].fF_ApR5; 957 // 958 // stars[i].lensing->F_ApR6 = ps1data[i].F_ApR6; 959 // stars[i].lensing->dF_ApR6 = ps1data[i].dF_ApR6; 960 // stars[i].lensing->sF_ApR6 = ps1data[i].sF_ApR6; 961 // stars[i].lensing->fF_ApR6 = ps1data[i].fF_ApR6; 962 963 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 964 stars[i].lensing->detID = ps1data[i].detID; 965 966 // the Average fields and the following Measure fields are set in FilterStars after 967 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID. 968 969 // averef is set in find_matches 970 971 // dbFlags is zero on ingest. 972 973 // the following fields are currently not being set anywhere: t_msec 974 } 975 *nstars = Nstars; 976 return (stars); 977 } 978 979 Stars *Convert_PS1_SV1 (FTable *table, unsigned int *nstars) { 980 981 off_t Nstars; 982 unsigned int i; 983 double ZeroPt; 984 Stars *stars; 985 CMF_PS1_SV1 *ps1data; 986 987 if (table[0].header[0].Naxis[0] == 196) { 988 stars = Convert_PS1_SV1_Alt (table, nstars); 989 return (stars); 990 } 991 992 ps1data = gfits_table_get_CMF_PS1_SV1 (table, &Nstars, NULL); 993 if (!ps1data) { 994 fprintf (stderr, "skipping inconsistent entry\n"); 995 return (NULL); 996 } 997 ZeroPt = GetZeroPoint(); 998 999 ALLOCATE (stars, Stars, Nstars); 1000 for (i = 0; i < Nstars; i++) { 1001 InitStar (&stars[i]); 1002 stars[i].measure.Xccd = ps1data[i].X; 1003 stars[i].measure.Yccd = ps1data[i].Y; 1004 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX); 1005 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY); 1006 1007 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle); 1008 stars[i].measure.pltscale = ps1data[i].pltscale; 1009 1010 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1011 stars[i].measure.M = NAN; 1012 } else { 1013 stars[i].measure.M = ps1data[i].M + ZeroPt; 1014 } 1015 stars[i].measure.dM = ps1data[i].dM; 1016 stars[i].measure.dMcal = ps1data[i].dMcal; 1017 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 1018 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure 1019 1020 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1021 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1022 1023 // these fluxes are converted from counts to counts/sec in FilterStars.c 1024 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1025 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 1026 stars[i].measure.FluxKron = ps1data[i].kronFlux; 1027 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1028 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (NAN, ps1data[i].Map); 1029 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (NAN, stars[i].measure.FluxAp, stars[i].measure.dMap); 1030 1031 stars[i].measure.Sky = ps1data[i].sky; 1032 stars[i].measure.dSky = ps1data[i].dSky; 1033 1034 stars[i].measure.psfChisq = ps1data[i].psfChisq; 1035 stars[i].measure.psfQF = ps1data[i].psfQF; 1036 stars[i].measure.psfQFperf = ps1data[i].psfQFperf; 1037 1038 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1039 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1040 stars[i].measure.crNsigma = ps1data[i].crNsigma; 1041 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1042 1043 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 1044 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 1045 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 1046 1047 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx); 1048 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy); 1049 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy); 1050 1051 stars[i].measure.photFlags = ps1data[i].flags; 1052 1053 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1054 stars[i].measure.detID = ps1data[i].detID; 1055 1056 // the Average fields and the following Measure fields are set in FilterStars after 1057 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID, 1058 // averef is set in find_matches, dbFlags is zero on ingest. 1059 1060 // the following fields are currently not being set anywhere: t_msec 1061 } 1062 *nstars = Nstars; 1063 return (stars); 1064 } 1065 1066 Stars *Convert_PS1_SV1_Alt (FTable *table, unsigned int *nstars) { 1067 1068 off_t Nstars; 1069 unsigned int i; 1070 double ZeroPt; 1071 Stars *stars; 1072 CMF_PS1_SV1 *ps1data; 1073 1074 // some test output files were produced called CMF_PS1_SV1 but with mismatch byte boundaries 1075 1076 ps1data = gfits_table_get_CMF_PS1_SV1_Alt (table, &Nstars, NULL); 1077 if (!ps1data) { 1078 fprintf (stderr, "skipping inconsistent entry\n"); 1079 return (NULL); 1080 } 1081 ZeroPt = GetZeroPoint(); 1082 1083 ALLOCATE (stars, Stars, Nstars); 1084 for (i = 0; i < Nstars; i++) { 1085 InitStar (&stars[i]); 1086 stars[i].measure.Xccd = ps1data[i].X; 1087 stars[i].measure.Yccd = ps1data[i].Y; 1088 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX); 1089 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY); 1090 1091 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle); 1092 stars[i].measure.pltscale = ps1data[i].pltscale; 1093 1094 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1095 stars[i].measure.M = NAN; 1096 } else { 1097 stars[i].measure.M = ps1data[i].M + ZeroPt; 1098 } 1099 stars[i].measure.dM = ps1data[i].dM; 1100 stars[i].measure.dMcal = ps1data[i].dMcal; 1101 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 1102 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure 1103 1104 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1105 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1106 1107 // these fluxes are converted from counts to counts/sec in FilterStars.c 1108 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1109 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 1110 stars[i].measure.FluxKron = ps1data[i].kronFlux; 1111 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1112 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (NAN, ps1data[i].Map); 1113 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (NAN, stars[i].measure.FluxAp, stars[i].measure.dMap); 855 1114 856 1115 stars[i].measure.Sky = ps1data[i].sky; … … 921 1180 stars[i].measure.dMcal = ps1data[i].dMcal; 922 1181 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 1182 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 923 1183 924 1184 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; … … 926 1186 927 1187 // 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;1188 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1189 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 930 1190 stars[i].measure.FluxKron = ps1data[i].kronFlux; 931 1191 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1192 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1193 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 932 1194 933 1195 stars[i].measure.Sky = ps1data[i].sky; … … 966 1228 } 967 1229 968 Stars *Convert_PS1_ DV3 (FTable *table, unsigned int *nstars) {1230 Stars *Convert_PS1_SV3 (FTable *table, unsigned int *nstars) { 969 1231 970 1232 off_t Nstars; … … 972 1234 double ZeroPt; 973 1235 Stars *stars; 974 CMF_PS1_ DV3 *ps1data;975 976 ps1data = gfits_table_get_CMF_PS1_ DV3 (table, &Nstars, NULL);1236 CMF_PS1_SV3 *ps1data; 1237 1238 ps1data = gfits_table_get_CMF_PS1_SV3 (table, &Nstars, NULL); 977 1239 if (!ps1data) { 978 1240 fprintf (stderr, "skipping inconsistent entry\n"); … … 1000 1262 stars[i].measure.dMcal = ps1data[i].dMcal; 1001 1263 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 1264 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1002 1265 1003 1266 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1004 1267 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1005 1268 1006 1269 // 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;1270 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1271 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 1009 1272 stars[i].measure.FluxKron = ps1data[i].kronFlux; 1010 1273 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1274 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1275 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 1276 1277 stars[i].measure.Sky = ps1data[i].sky; 1278 stars[i].measure.dSky = ps1data[i].dSky; 1279 1280 stars[i].measure.psfChisq = ps1data[i].psfChisq; 1281 stars[i].measure.psfQF = ps1data[i].psfQF; 1282 stars[i].measure.psfQFperf = ps1data[i].psfQFperf; 1283 1284 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1285 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1286 stars[i].measure.crNsigma = ps1data[i].crNsigma; 1287 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1288 1289 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 1290 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 1291 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 1292 1293 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx); 1294 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy); 1295 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy); 1296 1297 stars[i].measure.photFlags = ps1data[i].flags; 1298 1299 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1300 stars[i].measure.detID = ps1data[i].detID; 1301 1302 // the Average fields and the following Measure fields are set in FilterStars after 1303 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID, 1304 // averef is set in find_matches, dbFlags is zero on ingest. 1305 1306 // the following fields are currently not being set anywhere: t_msec 1307 } 1308 *nstars = Nstars; 1309 return (stars); 1310 } 1311 1312 Stars *Convert_PS1_DV3 (FTable *table, unsigned int *nstars) { 1313 1314 off_t Nstars; 1315 unsigned int i; 1316 double ZeroPt; 1317 Stars *stars; 1318 CMF_PS1_DV3 *ps1data; 1319 1320 ps1data = gfits_table_get_CMF_PS1_DV3 (table, &Nstars, NULL); 1321 if (!ps1data) { 1322 fprintf (stderr, "skipping inconsistent entry\n"); 1323 return (NULL); 1324 } 1325 ZeroPt = GetZeroPoint(); 1326 1327 ALLOCATE (stars, Stars, Nstars); 1328 for (i = 0; i < Nstars; i++) { 1329 InitStar (&stars[i]); 1330 stars[i].measure.Xccd = ps1data[i].X; 1331 stars[i].measure.Yccd = ps1data[i].Y; 1332 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX); 1333 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY); 1334 1335 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle); 1336 stars[i].measure.pltscale = ps1data[i].pltscale; 1337 1338 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1339 stars[i].measure.M = NAN; 1340 } else { 1341 stars[i].measure.M = ps1data[i].M + ZeroPt; 1342 } 1343 stars[i].measure.dM = ps1data[i].dM; 1344 stars[i].measure.dMcal = ps1data[i].dMcal; 1345 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 1346 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1347 1348 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1349 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1350 1351 // these fluxes are converted from counts to counts/sec in FilterStars.c 1352 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1353 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 1354 stars[i].measure.FluxKron = ps1data[i].kronFlux; 1355 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1356 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1357 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 1011 1358 1012 1359 stars[i].measure.Sky = ps1data[i].sky; … … 1047 1394 } 1048 1395 1049 1050 1396 Stars *Convert_PS1_DV4 (FTable *table, unsigned int *nstars) { 1397 1398 off_t Nstars; 1399 unsigned int i; 1400 double ZeroPt; 1401 Stars *stars; 1402 CMF_PS1_DV4 *ps1data; 1403 1404 ps1data = gfits_table_get_CMF_PS1_DV4 (table, &Nstars, NULL); 1405 if (!ps1data) { 1406 fprintf (stderr, "skipping inconsistent entry\n"); 1407 return (NULL); 1408 } 1409 ZeroPt = GetZeroPoint(); 1410 1411 fprintf (stderr, "WARNING: Convert_PS1_DV4 not yet updated to match real format\n"); 1412 1413 ALLOCATE (stars, Stars, Nstars); 1414 for (i = 0; i < Nstars; i++) { 1415 InitStar (&stars[i]); 1416 stars[i].measure.Xccd = ps1data[i].X; 1417 stars[i].measure.Yccd = ps1data[i].Y; 1418 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX); 1419 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY); 1420 1421 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle); 1422 stars[i].measure.pltscale = ps1data[i].pltscale; 1423 1424 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1425 stars[i].measure.M = NAN; 1426 } else { 1427 stars[i].measure.M = ps1data[i].M + ZeroPt; 1428 } 1429 stars[i].measure.dM = ps1data[i].dM; 1430 stars[i].measure.dMcal = ps1data[i].dMcal; 1431 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 1432 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1433 1434 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1435 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1436 1437 // these fluxes are converted from counts to counts/sec in FilterStars.c 1438 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1439 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 1440 stars[i].measure.FluxKron = ps1data[i].kronFlux; 1441 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1442 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1443 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 1444 1445 stars[i].measure.Sky = ps1data[i].sky; 1446 stars[i].measure.dSky = ps1data[i].dSky; 1447 1448 stars[i].measure.psfChisq = ps1data[i].psfChisq; 1449 stars[i].measure.psfQF = ps1data[i].psfQF; 1450 stars[i].measure.psfQFperf = ps1data[i].psfQFperf; 1451 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1452 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1453 stars[i].measure.crNsigma = ps1data[i].crNsigma; 1454 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1455 1456 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 1457 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 1458 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 1459 1460 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx); 1461 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy); 1462 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy); 1463 1464 stars[i].measure.photFlags = ps1data[i].flags; 1465 1466 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1467 stars[i].measure.detID = ps1data[i].detID; 1468 1469 // the Average fields and the following Measure fields are set in FilterStars after 1470 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID. 1471 1472 // averef is set in find_matches 1473 1474 // dbFlags is zero on ingest. 1475 1476 // the following fields are currently not being set anywhere: t_msec 1477 } 1478 *nstars = Nstars; 1479 return (stars); 1480 } 1481 1482 1483 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/ReadStarsSDSS.c
r34088 r37067 201 201 202 202 // XXX for now, we define a totally fake coordinate system centered on the first listed star 203 strcpy (images[N].coords.ctype, " RA---TAN");203 strcpy (images[N].coords.ctype, "DEC--TAN"); 204 204 205 205 images[N].coords.crval1 = stars[0].average.R; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/SEDfit.c
r34405 r37067 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/ipp-ops-20130712/Ohana/src/addstar/src/StarOps.c
r34260 r37067 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/ipp-ops-20130712/Ohana/src/addstar/src/addstar.c
r34405 r37067 7 7 int Nmatch, status, loadObjects; 8 8 off_t i, Nimages; 9 off_t Naverage, Nmeasure ;9 off_t Naverage, Nmeasure, Nlensing; 10 10 Stars *stars, **subset; 11 11 Image *images; … … 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 … … 182 182 Naverage += catalog.Naverage; 183 183 Nmeasure += catalog.Nmeasure; 184 Nlensing += catalog.Nlensing; 184 185 185 186 // write out catalog, if appropriate … … 187 188 SetProtect (TRUE); 188 189 if (options.update) { 189 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF ;190 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF | LOAD_LENSING; 190 191 dvo_catalog_update (&catalog, VERBOSE); 191 192 } else { … … 231 232 gettimeofday (&stop, NULL); 232 233 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);234 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 235 235 236 exit (0); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/build_links.c
r27435 r37067 225 225 } 226 226 227 /*******************************************************************************************/ 228 229 /* build the initial links assuming the table is sorted, 230 not partial, and has a correct set of average[].lensingOffset,Nlensing values */ 231 off_t *init_lensing_links (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing) { 232 233 off_t i, j, N; 234 off_t *next_lens; 235 236 N = 0; 237 238 ALLOCATE (next_lens, off_t, Nlensing); 239 for (i = 0; i < Naverage; i++) { 240 if (!average[i].Nlensing) continue; 241 for (j = 0; j < average[i].Nlensing - 1; j++, N++) { 242 next_lens[N] = N + 1; 243 if (N >= Nlensing) { 244 fprintf (stderr, "WARNING: N out of bounds (1)\n"); 245 } 246 } 247 next_lens[N] = -1; 248 if (N >= Nlensing) { 249 fprintf (stderr, "WARNING: N out of bounds (2)\n"); 250 } 251 252 if (N >= Nlensing) { 253 fprintf (stderr, "overflow in init_lensing_links\n"); 254 abort (); 255 } 256 N++; 257 } 258 return (next_lens); 259 } 260 261 /* construct lensing links which are valid FOR THIS LOAD 262 * - if we have a full load, we will get links which can 263 * be used by other programs (eg, relphot, etc) 264 * - if we have a partial load, the links are only valid 265 * for that partial load 266 */ 267 268 off_t *build_lensing_links (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing) { 269 270 off_t i, m, k, Nm, averef; 271 off_t *next_lens; 272 273 ALLOCATE (next_lens, off_t, Nlensing); 274 275 /* reset the Nm, offset values for average */ 276 for (i = 0; i < Naverage; i++) { 277 average[i].lensingOffset = -1; 278 average[i].Nlensing = 0; 279 } 280 281 for (Nm = 0; Nm < Nlensing; Nm++) { 282 averef = lensing[Nm].averef; 283 m = average[averef].lensingOffset; 284 next_lens[Nm] = -1; 285 286 if (m == -1) { /* no links yet for source */ 287 average[averef].lensingOffset = Nm; 288 average[averef].Nlensing = 1; 289 continue; 290 } 291 292 for (k = 0; next_lens[m] != -1; k++) { 293 m = next_lens[m]; 294 if (m >= Nlensing) { 295 fprintf (stderr, "WARNING: m out of bounds (1)\n"); 296 } 297 } 298 299 average[averef].Nlensing = k + 2; 300 next_lens[m] = Nm; 301 if (m >= Nlensing) { 302 fprintf (stderr, "WARNING: m out of bounds (2)\n"); 303 } 304 } 305 return (next_lens); 306 } 307 308 /* average[].lensingOffset, average[].Nlensing are valid within an addstar run */ 309 off_t add_lens_link (Average *average, off_t *next_lens, off_t Nlensing, off_t NLENSING) { 310 311 off_t k, m; 312 313 /* if we have trouble, check validity of next_lens[m] : m < Nlensing */ 314 m = average[0].lensingOffset; 315 316 for (k = 0; k < average[0].Nlensing - 1; k++) { 317 m = next_lens[m]; 318 if (m >= NLENSING) { 319 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 320 } 321 } 322 323 /* set up references */ 324 next_lens[Nlensing] = -1; 325 if (Nlensing >= NLENSING) { 326 fprintf (stderr, "WARNING: Nlensing out of bounds (1)\n"); 327 } 328 329 if (m == -1) { 330 average[0].lensingOffset = Nlensing; 331 } else { 332 next_lens[m] = Nlensing; 333 if (m >= NLENSING) { 334 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 335 } 336 } 337 338 return (TRUE); 339 } 340 341 Lensing *sort_lensing (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next_lens) { 342 343 off_t i, k, n, N; 344 Lensing *tmplensing; 345 346 /* fix order of Lensing (memory intensive, but fast) */ 347 N = 0; 348 ALLOCATE (tmplensing, Lensing, Nlensing); 349 for (i = 0; i < Naverage; i++) { 350 if (!average[i].Nlensing) continue; 351 n = average[i].lensingOffset; 352 average[i].lensingOffset = N; 353 for (k = 0; k < average[i].Nlensing; k++, N++) { 354 if (n == -1) abort(); 355 tmplensing[N] = lensing[n]; 356 if (lensing[n].averef != i) abort(); 357 tmplensing[N].averef = i; 358 n = next_lens[n]; 359 } 360 } 361 free (lensing); 362 return (tmplensing); 363 } 364 365 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/fakeimage.c
r30613 r37067 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]; … … 34 33 35 34 /* create a mosaic distortion structure */ 36 strcpy (MOSAIC.ctype, " RA---DIS");35 strcpy (MOSAIC.ctype, "DEC--DIS"); 37 36 MOSAIC.crval1 = FAKE_RA; 38 37 MOSAIC.crval2 = FAKE_DEC; … … 86 85 strcpy (image[i+1].name, name); 87 86 88 strcpy (image[i+1].coords.ctype, " RA---WRP");87 strcpy (image[i+1].coords.ctype, "DEC--WRP"); 89 88 90 89 image[i+1].coords.crval1 = dX*pixscale; … … 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/ipp-ops-20130712/Ohana/src/addstar/src/find_matches.c
r34361 r37067 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 … … 65 65 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 66 66 tcoords.Npolyterms = 1; 67 strcpy (tcoords.ctype, " RA---ARC");67 strcpy (tcoords.ctype, "DEC--ARC"); 68 68 69 69 /* build spatial index (RA sort) referencing input array sequence */ … … 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/ipp-ops-20130712/Ohana/src/addstar/src/find_matches_closest.c
r34361 r37067 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 … … 64 65 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 65 66 tcoords.Npolyterms = 1; 66 strcpy (tcoords.ctype, " RA---ARC");67 strcpy (tcoords.ctype, "DEC--ARC"); 67 68 68 69 /* build spatial index (RA sort) referencing input array sequence */ … … 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/ipp-ops-20130712/Ohana/src/addstar/src/find_matches_closest_refstars.c
r34361 r37067 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 … … 59 59 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 60 60 tcoords.Npolyterms = 0; 61 strcpy (tcoords.ctype, " RA---ARC");61 strcpy (tcoords.ctype, "DEC--ARC"); 62 62 63 63 /* build spatial index (RA sort) referencing input array sequence */ … … 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/ipp-ops-20130712/Ohana/src/addstar/src/find_matches_refstars.c
r34260 r37067 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); … … 57 57 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 58 58 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 59 strcpy (tcoords.ctype, " RA---ZEA");59 strcpy (tcoords.ctype, "DEC--ZEA"); 60 60 tcoords.Npolyterms = 0; 61 61 … … 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/ipp-ops-20130712/Ohana/src/addstar/src/findskycell.c
r34844 r37067 12 12 // in an even more specific case, RA[i,zone] = RA_origin[zone] + RA_offset[zone] 13 13 14 enum {TREE_NONE, TREE_MAKE, TREE_USE}; 14 enum {TREE_NONE, TREE_MAKE, TREE_LOCAL, TREE_USE}; 15 enum {REGION_NONE, REGION_USER, REGION_MIN, REGION_MAX}; 15 16 16 17 void usage (void) { 17 18 fprintf (stderr, "USAGE: findcell -mktree (tree) (catdir) [-nx Nx] [-ny Ny]\n"); 19 fprintf (stderr, "USAGE: findcell -mklocal (file) (catdir) [-nx Nx] [-ny Ny]\n"); 18 20 fprintf (stderr, "USAGE: findcell -tree (tree) (datafile)\n"); 19 21 fprintf (stderr, " (datafile) should contain a list of RA,DEC pairs\n"); … … 22 24 23 25 int mktree (char *treefile, char *catdir); 26 int mklocal (char *treefile, char *catdir); 24 27 int apply_tree (char *treefile, char *datafile); 25 28 … … 28 31 int NY_SUB = 1; 29 32 33 double R_MIN = 0.0; 34 double R_MAX = 0.0; 35 double D_MIN = 0.0; 36 double D_MAX = 0.0; 37 int REGION_OPTION = REGION_NONE; 38 39 char *BASENAME = NULL; 40 int projectIDoff = -1; 41 int skycellIDoff = -1; 42 43 int APPEND = FALSE; 44 30 45 int main (int argc, char **argv) { 31 46 … … 42 57 if (get_argument (argc, argv, "-h")) usage (); 43 58 44 NX_SUB = NY_SUB = 1;45 59 if ((N = get_argument (argc, argv, "-nx"))) { 46 60 remove_argument (N, &argc, argv); … … 55 69 56 70 /* pixel scale (arcsec/pixel) */ 57 SCALE = 1.0;58 71 if ((N = get_argument (argc, argv, "-scale"))) { 59 72 remove_argument (N, &argc, argv); 60 73 SCALE = atof (argv[N]); 74 remove_argument (N, &argc, argv); 75 } 76 77 /* pixel scale (arcsec/pixel) */ 78 if ((N = get_argument (argc, argv, "-append"))) { 79 remove_argument (N, &argc, argv); 80 APPEND = TRUE; 81 } 82 83 // user-specified region 84 R_MIN = NAN; 85 R_MAX = NAN; 86 D_MIN = NAN; 87 D_MAX = NAN; 88 if ((N = get_argument (argc, argv, "-region"))) { 89 remove_argument (N, &argc, argv); 90 if (N > argc - 4) { 91 fprintf (stderr, "USAGE: -region requires 4 arguments (Rmin Rmax Dmin Dmax)\n"); 92 exit (1); 93 } 94 R_MIN = atof (argv[N]); remove_argument (N, &argc, argv); 95 R_MAX = atof (argv[N]); remove_argument (N, &argc, argv); 96 D_MIN = atof (argv[N]); remove_argument (N, &argc, argv); 97 D_MAX = atof (argv[N]); remove_argument (N, &argc, argv); 98 REGION_OPTION = REGION_USER; 99 } 100 101 if ((N = get_argument (argc, argv, "-region-min"))) { 102 remove_argument (N, &argc, argv); 103 REGION_OPTION = REGION_MIN; 104 } 105 106 if ((N = get_argument (argc, argv, "-region-max"))) { 107 remove_argument (N, &argc, argv); 108 REGION_OPTION = REGION_MAX; 109 } 110 111 if ((N = get_argument (argc, argv, "-basename"))) { 112 remove_argument (N, &argc, argv); 113 if (N > argc - 3) { 114 fprintf (stderr, "USAGE: -basename (name) (proj_offset) (skycell_offset)\n"); 115 exit (1); 116 } 117 BASENAME = strcreate (argv[N]); 118 remove_argument (N, &argc, argv); 119 projectIDoff = atoi(argv[N]); 120 remove_argument (N, &argc, argv); 121 skycellIDoff = atoi(argv[N]); 61 122 remove_argument (N, &argc, argv); 62 123 } … … 70 131 remove_argument (N, &argc, argv); 71 132 } 133 if ((N = get_argument (argc, argv, "-mklocal"))) { 134 MODE = TREE_LOCAL; 135 remove_argument (N, &argc, argv); 136 treefile = strcreate (argv[N]); 137 remove_argument (N, &argc, argv); 138 } 72 139 if ((N = get_argument (argc, argv, "-tree"))) { 73 140 MODE = TREE_USE; … … 86 153 } 87 154 155 if (MODE == TREE_LOCAL) { 156 mklocal (treefile, argv[1]); 157 exit (0); 158 } 159 88 160 apply_tree (treefile, argv[1]); 89 161 exit (0); 90 162 } 91 92 # define MARKTIME(MSG,...) { \93 float dtime; \94 gettimeofday (&stop, (void *) NULL); \95 dtime = DTIME (stop, start); \96 fprintf (stderr, MSG, __VA_ARGS__); }97 163 98 164 int mktree (char *treefile, char *catdir) { … … 330 396 } 331 397 332 struct timeval start, stop; 333 gettimeofday (&start, (void *) NULL); 398 INITTIME; 334 399 335 400 int Npts = 10000000; … … 348 413 MARKTIME("-- test %d pts: %f sec\n", Npts, dtime); 349 414 350 BoundaryTreeSave (treefile, &tree); 415 if (APPEND) { 416 int Ntess = 0; 417 TessellationTable *tess = TessellationTableLoad (treefile, &Ntess); 418 REALLOCATE (tess, TessellationTable, Ntess + 1); 419 TessellationTableInit (&tess[Ntess], 1); 420 tess[Ntess].tree = &tree; 421 tess[Ntess].type = TESS_RINGS; 422 tess[Ntess].Rmin = 0; 423 tess[Ntess].Rmax = 360; 424 tess[Ntess].Dmin = -90; 425 tess[Ntess].Dmax = +90; 426 427 if (BASENAME) { 428 tess[Ntess].Nbasename = strlen(BASENAME); 429 tess[Ntess].basename = strcreate(BASENAME); 430 tess[Ntess].projectIDoff = projectIDoff; 431 tess[Ntess].skycellIDoff = skycellIDoff; 432 } 433 434 // add basename an related here... 435 Ntess ++; 436 TessellationTableSave (treefile, tess, Ntess); 437 } else { 438 BoundaryTreeSave (treefile, &tree); 439 } 351 440 352 441 return TRUE; … … 354 443 355 444 int apply_tree (char *treefile, char *datafile) { 445 446 int Ntess = 0; 447 TessellationTable *tess = TessellationTableLoad (treefile, &Ntess); 448 if (!tess) { 449 fprintf (stderr, "error loading tessellation table file %s\n", treefile); 450 exit (2); 451 } 452 453 FILE *f = fopen (datafile, "r"); 454 if (!f) { 455 fprintf (stderr, "error opening data file %s\n", datafile); 456 exit (3); 457 } 458 459 double ra, dec; 460 int Nvalue = 0; 461 while ((Nvalue = fscanf (f, "%lf %lf", &ra, &dec)) != EOF) { 462 463 int tessID, projID, skycellID; 464 465 if (!TessellationPrimaryCellIDs (tess, Ntess, &tessID, &projID, &skycellID, ra, dec)) { 466 fprintf (stderr, "error finding cell for %f,%f\n", ra, dec); 467 continue; 468 } 469 470 fprintf (stdout, "%10.6f %10.6f : %2d %04d %03d : %s\n", ra, dec, tessID, projID, skycellID, tess[tessID].basename); 471 } 472 473 exit (0); 474 } 475 476 int apply_tree_old (char *treefile, char *datafile) { 356 477 357 478 BoundaryTree *tree = BoundaryTreeLoad (treefile); … … 405 526 } 406 527 528 // a given tess is defined by a catdir (more than one per catdir?) 529 // this function takes a catdir and generates an extension for a tess file for a local tess. 530 531 /* 532 533 LOCAL projections are defined by single projection cells. should I be supplying the info on 534 the cmd line or figure out the bounds from the catdir? 535 536 */ 537 538 int mklocal (char *treefile, char *catdir) { 539 540 int i, j, status; 541 FITS_DB db; 542 Image *image; 543 off_t Nimage; 544 double x, y, ra, dec; 545 546 if (REGION_OPTION == REGION_NONE) { 547 fprintf (stderr, "ERROR: need to define bounding region (-region Rmin Rmax Dmin Dmax | -region-min | -region-max)\n"); 548 exit (2); 549 } 550 551 if (!BASENAME) { 552 fprintf (stderr, "ERROR: need to define BASENAME -basename (name) (proj_offset) (skycell_offset)\n"); 553 exit (2); 554 } 555 556 char imagefile[DVO_MAX_PATH]; 557 snprintf (imagefile, DVO_MAX_PATH, "%s/Images.dat", catdir); 558 559 status = dvo_image_lock (&db, imagefile, 2.0, LCK_XCLD); 560 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); 561 562 /* load or create the image table */ 563 if (db.dbstate == LCK_EMPTY) Shutdown ("can't read image catalog %s", db.filename); 564 565 if (!dvo_image_load (&db, TRUE, FALSE)) Shutdown ("can't read image catalog %s", db.filename); 566 567 // convert database table to internal structure (binary to Image) 568 // 'image' points to the same memory as db->ftable->buffer 569 image = gfits_table_get_Image (&db.ftable, &Nimage, &db.swapped); 570 if (!image) { 571 fprintf (stderr, "ERROR: failed to read images\n"); 572 exit (2); 573 } 574 575 // generate an empty BoundaryTree 576 TessellationTable *tess = NULL; 577 578 int NtessDisk = 0; 579 if (APPEND) { 580 tess = TessellationTableLoad (treefile, &NtessDisk); 581 REALLOCATE (tess, TessellationTable, Nimage + NtessDisk); 582 } else { 583 ALLOCATE (tess, TessellationTable, Nimage + NtessDisk); 584 } 585 586 TessellationTableInit (&tess[NtessDisk], Nimage); 587 588 // find the RA,DEC of the image centers & assign to cells 589 int Ntess = NtessDisk; 590 for (i = 0; i < Nimage; i++) { 591 // user supplied values, do not try to derive from Image.dat 592 tess[Ntess].NX_SUB = NX_SUB; 593 tess[Ntess].NY_SUB = NY_SUB; 594 tess[Ntess].dPix = SCALE/3600.0; 595 596 x = 0.5*image[i].NX; 597 y = 0.5*image[i].NY; 598 XY_to_RD (&ra, &dec, x, y, &image[i].coords); 599 600 tess[Ntess].Ro = ra; 601 tess[Ntess].Do = dec; 602 tess[Ntess].Xo = x; 603 tess[Ntess].Yo = y; 604 tess[Ntess].dX = image[i].NX / NX_SUB; 605 tess[Ntess].dY = image[i].NY / NY_SUB; 606 607 // find the minimum or maximum containing region 608 if ((REGION_OPTION == REGION_MIN) || (REGION_OPTION == REGION_MAX)) { 609 // XXX short cut for now : if the projection cell bounds the equator or 0,360 boundary, this will fail: 610 double R[4], D[4]; 611 XY_to_RD (&R[0], &D[0], 0, 0, &image[i].coords); 612 XY_to_RD (&R[1], &D[1], image[i].NX, 0, &image[i].coords); 613 XY_to_RD (&R[2], &D[2], 0, image[i].NY, &image[i].coords); 614 XY_to_RD (&R[3], &D[3], image[i].NX, image[i].NY, &image[i].coords); 615 616 if (REGION_OPTION == REGION_MIN) { 617 for (j = 0; j < 4; j++) { 618 R_MIN = (R[j] < ra) ? (isfinite(R_MIN) ? MAX(R_MIN, R[j]) : R[j]) : R_MIN; 619 R_MAX = (R[j] > ra) ? (isfinite(R_MAX) ? MIN(R_MAX, R[j]) : R[j]) : R_MAX; 620 D_MIN = (D[j] < dec) ? (isfinite(D_MIN) ? MAX(D_MIN, D[j]) : D[j]) : D_MIN; 621 D_MAX = (D[j] > dec) ? (isfinite(D_MAX) ? MIN(D_MAX, D[j]) : D[j]) : D_MAX; 622 } 623 } else { 624 for (j = 0; j < 4; j++) { 625 R_MIN = (R[j] < ra) ? (isfinite(R_MIN) ? MIN(R_MIN, R[j]) : R[j]) : R_MIN; 626 R_MAX = (R[j] > ra) ? (isfinite(R_MAX) ? MAX(R_MAX, R[j]) : R[j]) : R_MAX; 627 D_MIN = (D[j] < dec) ? (isfinite(D_MIN) ? MIN(D_MIN, D[j]) : D[j]) : D_MIN; 628 D_MAX = (D[j] > dec) ? (isfinite(D_MAX) ? MAX(D_MAX, D[j]) : D[j]) : D_MAX; 629 } 630 } 631 } 632 tess[Ntess].Rmin = R_MIN; 633 tess[Ntess].Rmax = R_MAX; 634 tess[Ntess].Dmin = D_MIN; 635 tess[Ntess].Dmax = D_MAX; 636 637 tess[Ntess].type = TESS_LOCAL; 638 639 // XXX I don't really want to do the work of discovering the rule... 640 tess[Ntess].Nbasename = strlen(BASENAME); 641 tess[Ntess].basename = strcreate(BASENAME); 642 643 tess[Ntess].projectIDoff = projectIDoff; 644 tess[Ntess].skycellIDoff = skycellIDoff; 645 646 Ntess ++; 647 } 648 649 TessellationTableSave (treefile, tess, Ntess); 650 651 return TRUE; 652 } 653 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/load2mass_catalog.c
r35416 r37067 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/ipp-ops-20130712/Ohana/src/addstar/src/loadsupercos_ops.c
r33653 r37067 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/ipp-ops-20130712/Ohana/src/addstar/src/loadsupercos_plates.c
r33653 r37067 118 118 119 119 // for now, we define a fake coordinate system based on the boresite center 120 strcpy (image[Nimage].coords.ctype, " RA---TAN");120 strcpy (image[Nimage].coords.ctype, "DEC--TAN"); 121 121 122 122 image[Nimage].coords.crval1 = RAo; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/mkcmf.c
r35760 r37067 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; 25 32 26 33 int main (int argc, char **argv) { … … 38 45 Matrix matrix; 39 46 FTable ftable; 40 Coords coords;41 47 42 48 int APPEND = FALSE; … … 105 111 } 106 112 107 float exptime = 1.0;108 113 if ((N = get_argument (argc, argv, "-exptime"))) { 109 114 remove_argument (N, &argc, argv); … … 288 293 gfits_modify (&header, "UTC-OBS", "%s", 1, time); 289 294 } 290 gfits_modify (&header, "ZERO_PT", "%lf", 1, 25.0);295 gfits_modify (&header, "ZERO_PT", "%lf", 1, ZERO_POINT); 291 296 gfits_modify (&header, "EXPTIME", "%lf", 1, exptime); 292 297 gfits_modify (&header, "AIRMASS", "%lf", 1, airmass); … … 327 332 if (!strcmp(type, "PS1_V4")) { 328 333 writeStars_PS1_V4 (&ftable, X, Y, M, Flag, Nstars); 334 found = TRUE; 335 } 336 if (!strcmp(type, "PS1_V5")) { 337 writeStars_PS1_V5 (&ftable, X, Y, M, Flag, Nstars); 338 found = TRUE; 339 } 340 if (!strcmp(type, "PS1_V5_Lensing")) { 341 writeStars_PS1_V5_Lensing (&ftable, X, Y, M, Flag, Nstars); 342 found = TRUE; 343 } 344 if (!strcmp(type, "PS1_SV3")) { 345 writeStars_PS1_SV3 (&ftable, X, Y, M, Flag, Nstars); 329 346 found = TRUE; 330 347 } … … 764 781 } 765 782 783 void writeStars_PS1_V5 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars) { 784 785 int i; 786 CMF_PS1_V5 *stars; 787 float flux, fSN; 788 789 // XXX add gaussian-distributed noise based on counts 790 // this needs to make different output 'stars' entries depending on the desired type 791 ALLOCATE (stars, CMF_PS1_V5, Nstars); 792 for (i = 0; i < Nstars; i++) { 793 794 flux = pow (10.0, -0.4*M[i]); 795 fSN = 1.0 / sqrt(flux); 796 797 stars[i].detID = i; 798 stars[i].X = X[i]; 799 stars[i].Y = Y[i]; 800 stars[i].dX = FX * fSN; 801 stars[i].dY = FY * fSN; 802 803 stars[i].posangle = 10.0; 804 stars[i].pltscale = 0.25; 805 806 stars[i].M = M[i]; 807 stars[i].dM = fSN; 808 809 stars[i].Flux = flux; 810 stars[i].dFlux = flux * fSN; 811 812 stars[i].Map = M[i] - 0.05; 813 stars[i].MapRaw = M[i] - 0.10; 814 815 stars[i].apRadius = 8.0; 816 817 stars[i].apFlux = pow(10.0, -0.4*stars[i].Map); 818 stars[i].apFluxErr = stars[i].apFlux * fSN; 819 820 stars[i].Mcalib = M[i] + ZERO_POINT + 2.5*log10(exptime); 821 stars[i].dMcal = 0.05; 822 823 XY_to_RD (&stars[i].RA, &stars[i].DEC, X[i], Y[i], &coords); 824 stars[i].apNpix = 3.14*8.0*8.0; 825 826 stars[i].Mpeak = M[i] + 1.0; 827 stars[i].sky = SKY; 828 stars[i].dSky = DSKY; 829 stars[i].psfChisq = PSFCHI; 830 stars[i].crNsigma = CRN; 831 stars[i].extNsigma = EXTN; 832 stars[i].fx = FX; 833 stars[i].fy = FY; 834 stars[i].df = DF; 835 836 stars[i].k = 1.0; 837 stars[i].fwhmMaj = FX*2.8; 838 stars[i].fwhmMin = FY*2.8; 839 840 // randomly give poor PSFQF values 841 if ((BAD_PSFQF_FRAC > 0.0) && (drand48() < BAD_PSFQF_FRAC)) { 842 stars[i].psfQF = 0.25; 843 stars[i].psfQFperf = 0.24; 844 } else { 845 stars[i].psfQF = PSFQUAL; 846 stars[i].psfQFperf = MAX(PSFQUAL - 0.01, 0.0); 847 } 848 849 stars[i].psfNdof = 1; 850 stars[i].psfNpix = 2; 851 852 stars[i].Mxx = FX; 853 stars[i].Mxy = 0.01; 854 stars[i].Myy = FX; 855 stars[i].M3c = FX; 856 stars[i].M3s = FX; 857 stars[i].M4c = FX; 858 stars[i].M4s = FX; 859 stars[i].Mr1 = FX; 860 stars[i].Mrh = FX; 861 862 stars[i].kronFlux = flux * 1.25; 863 stars[i].kronFluxErr = fSN * flux * 1.25; 864 865 stars[i].kronInner = fSN * flux * 0.9; 866 stars[i].kronOuter = fSN * flux * 1.5; 867 868 stars[i].skyLimitRad = 1; 869 stars[i].skyLimitFlux = 2; 870 stars[i].skyLimitSlope = 0.2; 871 872 stars[i].flags = Flag[i]; 873 stars[i].flags2 = 0x80; 874 875 stars[i].nFrames = 1; 876 877 if (ADDNOISE) { 878 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0); 879 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0); 880 float Moff = fSN*rnd_gauss(0.0, 1.0); 881 stars[i].M += Moff; 882 stars[i].Map += Moff; 883 stars[i].MapRaw += Moff; 884 stars[i].Mcalib += Moff; 885 } 886 } 887 888 gfits_table_set_CMF_PS1_V5 (ftable, stars, Nstars); 889 gfits_modify (ftable->header, "EXTTYPE", "%s", 1, "PS1_V5"); 890 } 891 892 void writeStars_PS1_SV3 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars) { 893 894 int i; 895 CMF_PS1_SV3 *stars; 896 float flux, fSN; 897 898 // XXX add gaussian-distributed noise based on counts 899 // this needs to make different output 'stars' entries depending on the desired type 900 ALLOCATE (stars, CMF_PS1_SV3, Nstars); 901 for (i = 0; i < Nstars; i++) { 902 903 flux = pow (10.0, -0.4*M[i]); 904 fSN = 1.0 / sqrt(flux); 905 906 stars[i].detID = i; 907 stars[i].X = X[i]; 908 stars[i].Y = Y[i]; 909 stars[i].dX = FX * fSN; 910 stars[i].dY = FY * fSN; 911 912 stars[i].posangle = 10.0; 913 stars[i].pltscale = 0.25; 914 915 stars[i].M = M[i]; 916 stars[i].dM = fSN; 917 918 stars[i].Flux = flux; 919 stars[i].dFlux = flux * fSN; 920 921 stars[i].Map = M[i] - 0.05; 922 stars[i].MapRaw = M[i] - 0.10; 923 924 stars[i].apRadius = 8.0; 925 926 stars[i].apFlux = pow(10.0, -0.4*stars[i].Map); 927 stars[i].apFluxErr = stars[i].apFlux * fSN; 928 929 stars[i].Mcalib = M[i] + ZERO_POINT + 2.5*log10(exptime); 930 stars[i].dMcal = 0.05; 931 932 XY_to_RD (&stars[i].RA, &stars[i].DEC, X[i], Y[i], &coords); 933 stars[i].apNpix = 3.14*8.0*8.0; 934 935 stars[i].Mpeak = M[i] + 1.0; 936 stars[i].sky = SKY; 937 stars[i].dSky = DSKY; 938 stars[i].psfChisq = PSFCHI; 939 stars[i].crNsigma = CRN; 940 stars[i].extNsigma = EXTN; 941 stars[i].fx = FX; 942 stars[i].fy = FY; 943 stars[i].df = DF; 944 945 stars[i].k = 1.0; 946 stars[i].fwhmMaj = FX*2.8; 947 stars[i].fwhmMin = FY*2.8; 948 949 // randomly give poor PSFQF values 950 if ((BAD_PSFQF_FRAC > 0.0) && (drand48() < BAD_PSFQF_FRAC)) { 951 stars[i].psfQF = 0.25; 952 stars[i].psfQFperf = 0.24; 953 } else { 954 stars[i].psfQF = PSFQUAL; 955 stars[i].psfQFperf = MAX(PSFQUAL - 0.01, 0.0); 956 } 957 958 stars[i].psfNdof = 1; 959 stars[i].psfNpix = 2; 960 961 stars[i].Mxx = FX; 962 stars[i].Mxy = 0.01; 963 stars[i].Myy = FX; 964 stars[i].M3c = FX; 965 stars[i].M3s = FX; 966 stars[i].M4c = FX; 967 stars[i].M4s = FX; 968 stars[i].Mr1 = FX; 969 stars[i].Mrh = FX; 970 971 stars[i].kronFlux = flux * 1.25; 972 stars[i].kronFluxErr = fSN * flux * 1.25; 973 974 stars[i].kronInner = fSN * flux * 0.9; 975 stars[i].kronOuter = fSN * flux * 1.5; 976 977 // stars[i].skyLimitRad = 1; 978 // stars[i].skyLimitFlux = 2; 979 // stars[i].skyLimitSlope = 0.2; 980 981 stars[i].flags = Flag[i]; 982 stars[i].flags2 = 0x80; 983 984 stars[i].nFrames = 1; 985 986 if (ADDNOISE) { 987 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0); 988 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0); 989 float Moff = fSN*rnd_gauss(0.0, 1.0); 990 stars[i].M += Moff; 991 stars[i].Map += Moff; 992 stars[i].MapRaw += Moff; 993 stars[i].Mcalib += Moff; 994 } 995 } 996 997 gfits_table_set_CMF_PS1_SV3 (ftable, stars, Nstars); 998 gfits_modify (ftable->header, "EXTTYPE", "%s", 1, "PS1_SV3"); 999 } 1000 1001 void writeStars_PS1_V5_Lensing (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars) { 1002 1003 int i; 1004 CMF_PS1_V5_Lensing *stars; 1005 float flux, fSN; 1006 1007 // XXX add gaussian-distributed noise based on counts 1008 // this needs to make different output 'stars' entries depending on the desired type 1009 ALLOCATE (stars, CMF_PS1_V5_Lensing, Nstars); 1010 for (i = 0; i < Nstars; i++) { 1011 1012 flux = pow (10.0, -0.4*M[i]); 1013 fSN = 1.0 / sqrt(flux); 1014 1015 stars[i].detID = i; 1016 stars[i].X = X[i]; 1017 stars[i].Y = Y[i]; 1018 stars[i].dX = FX * fSN; 1019 stars[i].dY = FY * fSN; 1020 1021 stars[i].posangle = 10.0; 1022 stars[i].pltscale = 0.25; 1023 1024 stars[i].M = M[i]; 1025 stars[i].dM = fSN; 1026 1027 stars[i].Flux = flux; 1028 stars[i].dFlux = flux * fSN; 1029 1030 stars[i].Map = M[i] - 0.05; 1031 stars[i].MapRaw = M[i] - 0.10; 1032 1033 stars[i].apRadius = 8.0; 1034 1035 stars[i].apFlux = pow(10.0, -0.4*stars[i].Map); 1036 stars[i].apFluxErr = stars[i].apFlux * fSN; 1037 1038 stars[i].Mcalib = M[i] + ZERO_POINT + 2.5*log10(exptime); 1039 stars[i].dMcal = 0.05; 1040 1041 XY_to_RD (&stars[i].RA, &stars[i].DEC, X[i], Y[i], &coords); 1042 stars[i].apNpix = 3.14*8.0*8.0; 1043 1044 stars[i].Mpeak = M[i] + 1.0; 1045 stars[i].sky = SKY; 1046 stars[i].dSky = DSKY; 1047 stars[i].psfChisq = PSFCHI; 1048 stars[i].crNsigma = CRN; 1049 stars[i].extNsigma = EXTN; 1050 stars[i].fx = FX; 1051 stars[i].fy = FY; 1052 stars[i].df = DF; 1053 1054 stars[i].k = 1.0; 1055 stars[i].fwhmMaj = FX*2.8; 1056 stars[i].fwhmMin = FY*2.8; 1057 1058 // randomly give poor PSFQF values 1059 if ((BAD_PSFQF_FRAC > 0.0) && (drand48() < BAD_PSFQF_FRAC)) { 1060 stars[i].psfQF = 0.25; 1061 stars[i].psfQFperf = 0.24; 1062 } else { 1063 stars[i].psfQF = PSFQUAL; 1064 stars[i].psfQFperf = MAX(PSFQUAL - 0.01, 0.0); 1065 } 1066 1067 stars[i].psfNdof = 1; 1068 stars[i].psfNpix = 2; 1069 1070 stars[i].Mxx = FX; 1071 stars[i].Mxy = 0.01; 1072 stars[i].Myy = FX; 1073 stars[i].M3c = FX; 1074 stars[i].M3s = FX; 1075 stars[i].M4c = FX; 1076 stars[i].M4s = FX; 1077 stars[i].Mr1 = FX; 1078 stars[i].Mrh = FX; 1079 1080 stars[i].X11_sm_obj = FX; 1081 stars[i].X12_sm_obj = FX; 1082 stars[i].X22_sm_obj = FY; 1083 stars[i].E1_sm_obj = FX; 1084 stars[i].E2_sm_obj = FX; 1085 1086 stars[i].X11_sh_obj = FX; 1087 stars[i].X12_sh_obj = 0.2; 1088 stars[i].X22_sh_obj = FY; 1089 stars[i].E1_sh_obj = FX*0.9; 1090 stars[i].E2_sh_obj = FX*0.8; 1091 1092 stars[i].X11_sm_psf = FX; 1093 stars[i].X12_sm_psf = FX; 1094 stars[i].X22_sm_psf = FX; 1095 stars[i].E1_sm_psf = FX; 1096 stars[i].E2_sm_psf = FX; 1097 1098 stars[i].X11_sh_psf = FX; 1099 stars[i].X12_sh_psf = FX; 1100 stars[i].X22_sh_psf = FX; 1101 stars[i].E1_sh_psf = FX; 1102 stars[i].E2_sh_psf = FX; 1103 1104 stars[i].kronFlux = flux * 1.25; 1105 stars[i].kronFluxErr = fSN * flux * 1.25; 1106 1107 stars[i].kronInner = fSN * flux * 0.9; 1108 stars[i].kronOuter = fSN * flux * 1.5; 1109 1110 stars[i].skyLimitRad = 1; 1111 stars[i].skyLimitFlux = 2; 1112 stars[i].skyLimitSlope = 0.2; 1113 1114 stars[i].flags = Flag[i]; 1115 stars[i].flags2 = 0x80; 1116 1117 stars[i].nFrames = 1; 1118 1119 if (ADDNOISE) { 1120 stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0); 1121 stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0); 1122 float Moff = fSN*rnd_gauss(0.0, 1.0); 1123 stars[i].M += Moff; 1124 stars[i].Map += Moff; 1125 stars[i].MapRaw += Moff; 1126 stars[i].Mcalib += Moff; 1127 } 1128 } 1129 1130 gfits_table_set_CMF_PS1_V5_Lensing (ftable, stars, Nstars); 1131 gfits_modify (ftable->header, "EXTTYPE", "%s", 1, "PS1_V5"); 1132 } 1133 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/replace_match.c
r26278 r37067 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/ipp-ops-20130712/Ohana/src/addstar/src/resort_catalog.c
r35760 r37067 1 1 # include "addstar.h" 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); 2 6 3 7 void resort_catalog_old (Catalog *catalog) { … … 5 9 off_t *next_meas; 6 10 off_t Naves, Nmeas; 7 double dtime;8 struct timeval start, stop;9 11 10 12 if (catalog[0].sorted == TRUE) return; 11 13 12 gettimeofday (&start, NULL);14 INITTIME; 13 15 14 16 /* internal counters */ … … 22 24 catalog[0].measure = sort_measure (catalog[0].average, Naves, catalog[0].measure, Nmeas, next_meas); 23 25 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); 26 MARKTIME (" match time %9.4f sec for %7lld measures, %6lld average\n", dtime, (long long) Nmeas, (long long) Naves); 27 27 28 28 return; 29 29 } 30 30 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 31 void resort_catalog (Catalog *catalog) { 32 33 if (catalog[0].sorted == TRUE) return; 34 35 resort_catalog_measure (catalog); 36 resort_catalog_lensing (catalog); 37 } 38 39 void resort_catalog_measure (Catalog *catalog) { 54 40 55 41 off_t Naverage, Nmeasure; … … 62 48 Measure *measureTMP = NULL; 63 49 64 if (catalog[0].sorted == TRUE) return;65 66 50 // struct timeval start, stop; 67 51 // gettimeofday (&start, NULL); … … 70 54 Nmeasure = catalog[0].Nmeasure; 71 55 Naverage = catalog[0].Naverage; 56 57 if (!Nmeasure) return; 72 58 73 59 measure = catalog[0].measure; … … 113 99 // fprintf (stderr, "\n"); 114 100 115 SortAveM easMatch(measureSeq, averageSeq, Nmeasure);101 SortAveMatch(measureSeq, averageSeq, Nmeasure); 116 102 // MARKTIME("sort : %f sec\n", dtime); 117 103 … … 188 174 } 189 175 176 void resort_catalog_lensing (Catalog *catalog) { 177 178 off_t Naverage, Nlensing; 179 Lensing *lensing; 180 Average *average; 181 off_t i, j, N, currentAve; 182 183 off_t *lensingSeq = NULL; 184 off_t *averageSeq = NULL; 185 Lensing *lensingTMP = NULL; 186 187 // struct timeval start, stop; 188 // gettimeofday (&start, NULL); 189 190 /* internal counters */ 191 Nlensing = catalog[0].Nlensing; 192 Naverage = catalog[0].Naverage; 193 194 if (!Nlensing) return; 195 196 lensing = catalog[0].lensing; 197 average = catalog[0].average; 198 199 // we have a table of average objects and an unsorted table of measurements. each measurement 200 // has a reference to the average object sequence (as well as an ID) 201 // lensing[i].averef -> average[averef] 202 // lensing[i].objID = average[averef].objID 203 // lensing[i].catID = average[averef].catID 204 205 // we want a sorted lensing array with all averef entries in sequence 206 207 ALLOCATE (lensingSeq, off_t, Nlensing); 208 ALLOCATE (averageSeq, off_t, Nlensing); 209 210 for (i = 0; i < Nlensing; i++) { 211 lensingSeq[i] = i; 212 averageSeq[i] = lensing[i].averef; 213 214 if (catalog[0].catformat >= DVO_FORMAT_PS1_V1) { 215 // earlier formats did not carry the objID or catID, so they are not available (we could assign on load, but we don't) 216 myAssert(average[averageSeq[i]].catID == lensing[lensingSeq[i]].catID, "object / detection mismatch"); 217 # if (1) 218 myAssert(average[averageSeq[i]].objID == lensing[lensingSeq[i]].objID, "object / detection mismatch"); 219 # else 220 // for reasons I do not understand, the mini dvodbs generated on stsci1X had a handful of detections with an inconsistency between averef and objID. 221 // 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 222 if (average[averageSeq[i]].objID != lensing[lensingSeq[i]].objID) { 223 fprintf (stderr, "R"); 224 lensing[lensingSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this... 225 } 226 # endif 227 } 228 } 229 230 // check that averageSeq is now in order 231 // for (i = 1; i < Nlensing; i++) { 232 // if (averageSeq[i] < averageSeq[i-1]) { 233 // fprintf (stderr, "%d ", (int) i); 234 // } 235 // } 236 // fprintf (stderr, "\n"); 237 238 SortAveMatch(lensingSeq, averageSeq, Nlensing); 239 // MARKTIME("sort : %f sec\n", dtime); 240 241 // check that averageSeq is now in order 242 // for (i = 1; i < Nlensing; i++) { 243 // if (averageSeq[i] < averageSeq[i-1]) { 244 // fprintf (stderr, "%d ", (int) i); 245 // } 246 // } 247 // fprintf (stderr, "\n"); 248 249 // copy the lensing entries in the sorted order 250 ALLOCATE (lensingTMP, Lensing, Nlensing); 251 for (i = 0; i < Nlensing; i++) { 252 j = lensingSeq[i]; 253 lensingTMP[i] = lensing[j]; 254 } 255 // MARKTIME("assign lensing : %f sec\n", dtime); 256 257 // update the values of average.lensingOffset and average.Nlensing 258 FREE(lensing); 259 catalog[0].lensing = lensingTMP; 260 261 N = 0; 262 currentAve = averageSeq[0]; 263 average[currentAve].lensingOffset = 0; 264 for (i = 0; i < Nlensing; i++) { 265 if (averageSeq[i] != currentAve) { 266 // we have hit the next entry in the list 267 average[currentAve].Nlensing = N; 268 N = 0; 269 currentAve = averageSeq[i]; 270 average[currentAve].lensingOffset = i; 271 } 272 N++; 273 } 274 // N++; 275 average[currentAve].Nlensing = N; 276 // MARKTIME("update Nlensing : %f sec\n", dtime); 277 278 int NlensingTotal = 0; 279 int lensingOffsetOK = TRUE; 280 for (i = 0; i < Naverage; i++) { 281 NlensingTotal += catalog[0].average[i].Nlensing; 282 if (VERBOSE && !(NlensingTotal <= catalog[0].Nlensing)) { 283 fprintf (stderr, "too few lensing: %d %d %d\n", (int) i, NlensingTotal, (int) catalog[0].Nlensing); 284 } 285 lensingOffsetOK &= (catalog[0].average[i].lensingOffset < catalog[0].Nlensing); 286 if (VERBOSE && !(catalog[0].average[i].lensingOffset < catalog[0].Nlensing)) { 287 fprintf (stderr, "offset too large: %d %d %d\n", (int) i, catalog[0].average[i].Nlensing, (int) catalog[0].Nlensing); 288 } 289 lensingOffsetOK &= (catalog[0].average[i].lensingOffset + catalog[0].average[i].Nlensing <= catalog[0].Nlensing); 290 if (VERBOSE && !(catalog[0].average[i].lensingOffset + catalog[0].average[i].Nlensing <= catalog[0].Nlensing)) { 291 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); 292 } 293 } 294 295 if (!lensingOffsetOK) { 296 fprintf (stderr, "ERROR: catalog %s has an invalid lensingOffset\n", catalog[0].filename); 297 } 298 299 if (NlensingTotal != catalog[0].Nlensing) { 300 fprintf (stderr, "ERROR: catalog %s has an invalid Nlensing\n", catalog[0].filename); 301 } 302 303 // MARKTIME(" match time %9.4f sec for %7lld lensings, %6lld average\n", dtime, (long long) Nlensing, (long long) Naverage); 304 305 catalog[0].sorted = TRUE; 306 307 FREE (lensingSeq); 308 FREE (averageSeq); 309 310 return; 311 } 312 313 // sort the measure or lensing Sequence based on the average Sequence entries 314 void SortAveMatch (off_t *MEAS, off_t *AVE, off_t N) { 315 316 # define SWAPFUNC(A,B){ off_t tmp_meas; off_t tmp_ave; \ 317 tmp_meas = MEAS[A]; MEAS[A] = MEAS[B]; MEAS[B] = tmp_meas; \ 318 tmp_ave = AVE[A]; AVE[A] = AVE[B]; AVE[B] = tmp_ave; \ 319 } 320 # define COMPARE(A,B)(AVE[A] < AVE[B]) 321 OHANA_SORT (N, COMPARE, SWAPFUNC); 322 # undef SWAPFUNC 323 # undef COMPARE 324 } 325 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/resort_threaded.c
r29938 r37067 41 41 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 42 42 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 43 catalog.catflags = LOAD_AVES | LOAD_MEAS ;43 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_LENSING; 44 44 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 45 45 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/resort_unthreaded_catalogs.c
r33963 r37067 30 30 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 31 31 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 32 catalog.catflags = LOAD_AVES | LOAD_MEAS ;32 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_LENSING; 33 33 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 34 34 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/sky_tessalation.c
r34844 r37067 1106 1106 refcoords[0].Npolyterms = 0; 1107 1107 memset (refcoords[0].polyterms, 0, 14*sizeof(float)); 1108 strcpy (refcoords[0].ctype, " RA---TAN");1108 strcpy (refcoords[0].ctype, "DEC--TAN"); 1109 1109 return (TRUE); 1110 1110 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/addstar/src/update_coords.c
r34405 r37067 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/ipp-ops-20130712/Ohana/src/addstar/test/simple.dvo
r35263 r37067 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/ipp-ops-20130712/Ohana/src/delstar/include/delstar.h
r35758 r37067 67 67 int UPDATE; 68 68 int IMAGE_DETAILS; 69 int IMAGE_DUPLICATES_BY_OBSTIME; 69 70 int IMAGE_ONLY; 70 71 int ORPHAN; … … 138 139 void SortAveMeasMatch (off_t *MEAS, off_t *AVE, off_t N); 139 140 140 int delete_photcodes ( );141 int delete_photcodes (void); 141 142 int delete_photcodes_parallel (SkyList *sky); 142 143 int delete_photcodes_catalog (Catalog *catalog, PhotCode **photcodes, int Nphotcodes); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/delstar/src/ImageOpsFixLAP.c
r35758 r37067 1 1 # include "delstar.h" 2 # define FT_BZERO_INT32 1.0*0x800000003 2 4 3 off_t Nimage = 0; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/delstar/src/ImageSubsetFixLAP.c
r35758 r37067 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/ipp-ops-20130712/Ohana/src/delstar/src/MeasureEdgeOps.c
r35758 r37067 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/ipp-ops-20130712/Ohana/src/delstar/src/args.c
r35758 r37067 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/ipp-ops-20130712/Ohana/src/delstar/src/delete_duplicate_images.c
r35758 r37067 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/ipp-ops-20130712/Ohana/src/delstar/src/delete_fix_LAP_edges.c
r35805 r37067 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/ipp-ops-20130712/Ohana/src/dvomerge
- Property svn:mergeinfo deleted
-
branches/eam_branches/ipp-ops-20130712/Ohana/src/dvomerge/src/IDmapIO.c
r34277 r37067 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/ipp-ops-20130712/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r34277 r37067 167 167 off_t i, oldID, newID; 168 168 169 if (!IDmap->old) { 170 fprintf (stderr, "input database has image IDs, but no Image table\n"); 171 return FALSE; 172 } 173 174 if (!IDmap->Nmap) { 175 fprintf (stderr, "input database has image IDs, but no Image table\n"); 176 return FALSE; 177 } 178 179 off_t lastID = IDmap->old[IDmap->Nmap-1]; 180 169 181 for (i = 0; i < catalog[0].Nmeasure; i++) { 170 182 oldID = catalog[0].measure[i].imageID; 171 183 if (oldID == 0) continue; 172 184 173 if (!IDmap->old) {174 fprintf (stderr, "input database has image IDs, but no Image table\n");175 }176 177 185 newID = dvo_map_image_ID (IDmap, oldID); 178 186 if (newID == 0) { 187 if (oldID > lastID) { 188 fprintf (stderr, "problem with image IDs : input out of range\n"); 189 fprintf (stderr, "old ID: "OFF_T_FMT", last ID: "OFF_T_FMT"\n", oldID, lastID); 190 exit (2); 191 } 179 192 if (!IDmap->notFound[oldID]) { 180 193 fprintf (stderr, "cannot find image ID "OFF_T_FMT"\n", oldID); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/dvomerge/src/dvomergeImageIDs.c
r35765 r37067 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/ipp-ops-20130712/Ohana/src/dvomerge/src/dvomergeUpdate.c
r35765 r37067 111 111 SetPhotcodeTable(NULL); 112 112 113 dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, &IDmap, secfiltMap);113 int status = dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, &IDmap, secfiltMap); 114 114 115 115 // save the output sky table copy … … 123 123 gettimeofday (&stop, NULL); 124 124 dtime = DTIME (stop, start); 125 126 if (!status) { 127 fprintf (stderr, "ERROR: elapsed time %9.4f sec\n", dtime); 128 exit (3); 129 } 130 125 131 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec\n", dtime); 126 127 132 exit (0); 128 133 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
r35765 r37067 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 147 dvo_update_image_IDs (IDmap, &incatalog); 148 142 149 // merge input into the appropriate output tables 143 150 for (j = 0; j < outlist[0].Nregions; j++) { … … 156 163 LoadCatalog (&outcatalog, outlist[0].regions[j], outcatalog.filename, "w", NsecfiltOutput); 157 164 158 dvo_update_image_IDs (IDmap, &incatalog);159 165 merge_catalogs_old (outlist[0].regions[j], &outcatalog, &incatalog, RADIUS, secfiltMap); 160 166 161 167 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 162 168 163 if (outstat[ i].missed) {169 if (outstat[j].missed) { 164 170 dmhObjectAdd (outstat[j].history, &outcatalog.header, inStats); 165 171 } … … 248 254 if (FORCE_MERGE) { snprintf (tmpline, DVO_MAX_PATH, "%s -force-merge", command); strcpy (command, tmpline); } 249 255 256 // add some config variables: 257 snprintf (tmpline, DVO_MAX_PATH, "%s -D CATMODE %s", command, CATMODE); strcpy (command, tmpline); 258 snprintf (tmpline, DVO_MAX_PATH, "%s -D CATFORMAT %s", command, CATFORMAT); strcpy (command, tmpline); 259 snprintf (tmpline, DVO_MAX_PATH, "%s -D SKY_DEPTH %d", command, SKY_DEPTH); strcpy (command, tmpline); 260 250 261 fprintf (stderr, "command: %s\n", command); 251 262 … … 275 286 } 276 287 if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) { 277 HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE); 288 int status = HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE); 289 if (!status) { 290 fprintf (stderr, "error running one of the remote clients\n"); 291 return status; 292 } 278 293 } 279 294 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/dvomerge/src/dvomerge_client.c
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/ipp-ops-20130712/Ohana/src/dvomerge/src/dvorepair.c
r29938 r37067 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/ipp-ops-20130712/Ohana/src/dvomerge/src/dvorepairCPT.c
r33657 r37067 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/ipp-ops-20130712/Ohana/src/dvomerge/src/dvorepairDeleteImageList.c
r29938 r37067 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/ipp-ops-20130712/Ohana/src/dvomerge/src/dvorepairFixCPT.c
r29938 r37067 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/ipp-ops-20130712/Ohana/src/dvomerge/src/dvorepairFixTables.c
r29938 r37067 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/ipp-ops-20130712/Ohana/src/dvomerge/src/dvorepairImageVsMeasure.c
r33657 r37067 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/ipp-ops-20130712/Ohana/src/dvomerge/src/dvorepairImagesVsMeasures.c
r29938 r37067 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/ipp-ops-20130712/Ohana/src/dvomerge/src/merge_catalogs_old.c
r35416 r37067 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; … … 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 … … 76 75 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 77 76 tcoords.Npolyterms = 1; 78 strcpy (tcoords.ctype, " RA---ARC");77 strcpy (tcoords.ctype, "DEC--ARC"); 79 78 80 79 if (VERBOSE) fprintf (stderr, "merging %s into %s\n", input[0].filename, output[0].filename); … … 87 86 N1[Nstars] = i; 88 87 Nstars ++; 89 input[0].found [i] = -1;88 input[0].found_t[i] = -1; 90 89 } 91 90 if (Nstars < 1) { 92 91 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", output[0].filename); 93 free (output[0].found);94 free (input[0].found);95 92 free (X1); 96 93 free (Y1); … … 106 103 for (i = 0; i < Nave; i++) { 107 104 RD_to_XY (&X2[i], &Y2[i], output[0].average[i].R, output[0].average[i].D, &tcoords); 108 output[0].found [i] = -1;105 output[0].found_t[i] = -1; 109 106 N2[i] = i; 110 107 } … … 196 193 int Mout = output[0].average[n].measureOffset; 197 194 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;195 input[0].found_t[N] = Mout; 199 196 continue; 200 197 } … … 206 203 output[0].measure[Nmeas] = input[0].measure[offset]; 207 204 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 205 // old code: find R,D using average_in[0], the get offset relative to average_out[0]. no longer 206 // needed since we carry around R,D 207 // Rin = input[0].average[N].R - input[0].measure[offset].dR / 3600.0; 208 // Din = input[0].average[N].D - input[0].measure[offset].dD / 3600.0; 209 // output[0].measure[Nmeas].dR = 3600.0*(output[0].average[n].R - Rin); 210 // output[0].measure[Nmeas].dD = 3600.0*(output[0].average[n].D - Din); 211 214 212 output[0].measure[Nmeas].dbFlags = 0; // XXX why reset these? 215 213 output[0].measure[Nmeas].averef = n; … … 221 219 // 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 220 223 // rationalize dR 224 if (output[0].measure[Nmeas].dR > +180.0*3600.0) { 221 float dRoff = dvoOffsetR(&output[0].measure[Nmeas], &output[0].average[n]); 222 223 // rationalize R 224 if (dRoff > +180.0*3600.0) { 225 225 // 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) {226 output[0].measure[Nmeas].R += 360.0; 227 dRoff -= 360.0*3600.0; 228 } 229 if (dRoff < -180.0*3600.0) { 230 230 // 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... 231 output[0].measure[Nmeas].R -= 360.0; 232 dRoff += 360.0*3600.0; 233 } 234 if (fabs(dRoff) > 10*RADIUS) { 235 // take declination into account and check again. 236 double cosD = cos(RAD_DEG*output[0].average[n].D); 237 if (fabs(dRoff*cosD) > 10*RADIUS) { 238 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 239 output[0].average[n].R, output[0].average[n].D, 240 output[0].measure[Nmeas].R, output[0].measure[Nmeas].D, 241 X1[i], X2[Jmin], Y1[i], Y2[Jmin]); 242 // XXX abort on this? -- this is a bad failure... 244 243 } 245 244 } 246 input[0].found [N] = Nmeas;245 input[0].found_t[N] = Nmeas; 247 246 output[0].average[n].Nmeasure ++; 248 247 Nmeas ++; … … 273 272 /* Nm is updated, but not written out in -update mode (for existing entries) 274 273 Nm is recalculated in build_meas_links if loaded table is not sorted */ 275 output[0].found [n] = Nmeas;274 output[0].found_t[n] = Nmeas; 276 275 i++; 277 276 } … … 295 294 } 296 295 297 if (input[0].found [N] >= 0) continue;296 if (input[0].found_t[N] >= 0) continue; 298 297 if (!IN_REGION (input[0].average[N].R, input[0].average[N].D)) continue; 299 298 … … 348 347 349 348 /* we set next[Nmeas] to -1 here, and update correctly below */ 350 input[0].found [N] = Nmeas;349 input[0].found_t[N] = Nmeas; 351 350 next_meas[Nmeas] = -1; 352 351 Nmeas ++; … … 374 373 /* note stars which have been found in this catalog */ 375 374 for (i = 0; i < input[0].Naverage; i++) { 376 if (input[0].found [i] > -1) {377 input[0].found [i] = -2;375 if (input[0].found_t[i] > -1) { 376 input[0].found_t[i] = -2; 378 377 } else { 379 input[0].found [i] = -3;378 input[0].found_t[i] = -3; 380 379 } 381 380 } … … 390 389 free (next_meas); 391 390 392 free (output[0].found);393 391 free (X2); 394 392 free (Y2); 395 393 free (N2); 396 free (input[0].found);397 394 free (X1); 398 395 free (Y1); … … 411 408 images have boundaries which are lines in pixels coords, but curve in RA and DEC 412 409 413 output[0].found [Ncat] but stars[Nstar].found410 output[0].found_t[Ncat] but stars[Nstar].found 414 411 415 412 */ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/dvomerge/src/replace_match.c
r33963 r37067 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/ipp-ops-20130712/Ohana/src/dvopsps/include/dvopsps.h
r35578 r37067 3 3 # include <signal.h> 4 4 # include "mysql.h" 5 # include "limits.h" 5 6 6 7 # define DVO_MAX_PATH 1024 … … 38 39 int PARALLEL_MANUAL; 39 40 int PARALLEL_SERIAL; 41 42 char *TIME_START; 43 char *TIME_END; 44 45 int PHOTCODE_START; 46 int PHOTCODE_END; 40 47 41 48 char *SINGLE_CPT; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/dvopsps/src/initialize_dvopsps.c
r35206 r37067 2 2 3 3 void usage_dvopsps () { 4 fprintf (stderr, "USAGE: dvopsps (mode) [dbinfo] (mode)[options]\n");4 fprintf (stderr, "USAGE: dvopsps (mode) [dbinfo] [options]\n"); 5 5 fprintf (stderr, " mysql database info is supplied with these:\n"); 6 6 fprintf (stderr, " -dbhost : database host machine\n"); … … 11 11 fprintf (stderr, " -v : verbose mode\n"); 12 12 fprintf (stderr, " -region Rmin Rmax Dmin Dmax\n"); 13 fprintf (stderr, " -cpt n0000/0000.00 : limit to the named cpt file\n"); 13 14 fprintf (stderr, " -parallel : run in parallel mode\n"); 15 fprintf (stderr, " -insert-remote : in parallel mode, the client sends the data to the dbhost\n"); 16 fprintf (stderr, " -time-start YYYY/MM/DD,hh:mm:ss : limit detections to >= this time\n"); 17 fprintf (stderr, " -time-end YYYY/MM/DD,hh:mm:ss : limit detections to < this time\n"); 18 19 fprintf (stderr, " -photcode-start NN : limit detections to >= this photcode number\n"); 20 fprintf (stderr, " -photcode-end NN : limit detections to < this photcode number\n"); 21 fprintf (stderr, "\n"); 22 23 fprintf (stderr, " (mode) is one of detections, objects, skytable\n"); 24 25 fprintf (stderr, "\n"); 14 26 fprintf (stderr, " -h : this help list\n"); 15 27 fprintf (stderr, " -help : this help list\n"); 16 28 fprintf (stderr, " --h : this help list\n"); 17 29 fprintf (stderr, " --help : this help list\n"); 30 18 31 fprintf (stderr, " Note that the dvo db can be specified by -D CATDIR (directory)\n"); 19 32 exit (2); … … 110 123 if ((N = get_argument (argc, argv, "-insert-remote"))) { 111 124 SAVE_REMOTE = FALSE; 125 remove_argument (N, &argc, argv); 126 } 127 128 TIME_START = NULL; 129 if ((N = get_argument (argc, argv, "-time-start"))) { 130 remove_argument (N, &argc, argv); 131 TIME_START = strcreate(argv[N]); 132 remove_argument (N, &argc, argv); 133 time_t TIME_START_SEC; 134 if (!ohana_str_to_time (TIME_START, &TIME_START_SEC)) { 135 fprintf (stderr, "error with starting time given by -time-start: %s\n", TIME_START); 136 exit (2); 137 } 138 } 139 140 TIME_END = NULL; 141 if ((N = get_argument (argc, argv, "-time-end"))) { 142 remove_argument (N, &argc, argv); 143 TIME_END = strcreate(argv[N]); 144 remove_argument (N, &argc, argv); 145 time_t TIME_END_SEC; 146 if (!ohana_str_to_time (TIME_END, &TIME_END_SEC)) { 147 fprintf (stderr, "error with starting time given by -time-end: %s\n", TIME_END); 148 exit (2); 149 } 150 } 151 152 PHOTCODE_START = 0; 153 if ((N = get_argument (argc, argv, "-photcode-start"))) { 154 remove_argument (N, &argc, argv); 155 PHOTCODE_START = atoi(argv[N]); 156 remove_argument (N, &argc, argv); 157 } 158 159 PHOTCODE_END = INT_MAX; 160 if ((N = get_argument (argc, argv, "-photcode-end"))) { 161 remove_argument (N, &argc, argv); 162 PHOTCODE_END = atoi(argv[N]); 112 163 remove_argument (N, &argc, argv); 113 164 } … … 260 311 } 261 312 313 TIME_START = NULL; 314 if ((N = get_argument (argc, argv, "-time-start"))) { 315 remove_argument (N, &argc, argv); 316 TIME_START = strcreate(argv[N]); 317 remove_argument (N, &argc, argv); 318 time_t TIME_START_SEC; 319 if (!ohana_str_to_time (TIME_START, &TIME_START_SEC)) { 320 fprintf (stderr, "error with starting time given by -time-start: %s\n", TIME_START); 321 exit (2); 322 } 323 } 324 325 TIME_END = NULL; 326 if ((N = get_argument (argc, argv, "-time-end"))) { 327 remove_argument (N, &argc, argv); 328 TIME_END = strcreate(argv[N]); 329 remove_argument (N, &argc, argv); 330 time_t TIME_END_SEC; 331 if (!ohana_str_to_time (TIME_END, &TIME_END_SEC)) { 332 fprintf (stderr, "error with starting time given by -time-end: %s\n", TIME_END); 333 exit (2); 334 } 335 } 336 337 PHOTCODE_START = 0; 338 if ((N = get_argument (argc, argv, "-photcode-start"))) { 339 remove_argument (N, &argc, argv); 340 PHOTCODE_START = atoi(argv[N]); 341 remove_argument (N, &argc, argv); 342 } 343 344 PHOTCODE_END = INT_MAX; 345 if ((N = get_argument (argc, argv, "-photcode-end"))) { 346 remove_argument (N, &argc, argv); 347 PHOTCODE_END = atoi(argv[N]); 348 remove_argument (N, &argc, argv); 349 } 350 262 351 VERBOSE = FALSE; 263 352 if ((N = get_argument (argc, argv, "-v"))) { -
branches/eam_branches/ipp-ops-20130712/Ohana/src/dvopsps/src/insert_detections_dvopsps.c
r35804 r37067 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: … … 153 147 if (SAVE_REMOTE) { snprintf (tmpline, 1024, "%s -save %s", command, table->hosts[i].results); strcpy (command, tmpline); } 154 148 149 // some filters -- these are the detections we skip 150 if (TIME_START) { snprintf (tmpline, 1024, "%s -time-start %s", command, TIME_START); strcpy (command, tmpline); } 151 if (TIME_END) { snprintf (tmpline, 1024, "%s -time-end %s", command, TIME_END); strcpy (command, tmpline); } 152 153 if (PHOTCODE_START > 0) { snprintf (tmpline, 1024, "%s -photcode-start %d", command, PHOTCODE_START); strcpy (command, tmpline); } 154 if (PHOTCODE_END <= INT_MAX) { snprintf (tmpline, 1024, "%s -photcode-end %d", command, PHOTCODE_END); strcpy (command, tmpline); } 155 155 156 fprintf (stderr, "command: %s\n", command); 156 157 … … 238 239 buffer.Nalloc = 0; 239 240 240 struct timeval start, stop;241 242 241 if (Ndetections == 0) return TRUE; 243 242 … … 247 246 int Ninsert = 0; 248 247 249 gettimeofday (&start, (void *) NULL);248 INITTIME; 250 249 for (i = 0; i < Ndetections; i++) { 251 250 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c
r35777 r37067 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; … … 29 23 } 30 24 25 time_t TIME_START_SEC = 0; 26 time_t TIME_END_SEC = 0; 27 if (TIME_START) ohana_str_to_time (TIME_START, &TIME_START_SEC); // we validate this in the args.c 28 if (TIME_END) ohana_str_to_time (TIME_END, &TIME_END_SEC); // we validate this in the args.c 29 31 30 for (i = 0; i < catalog[0].Naverage; i++) { 32 31 … … 40 39 Average *average = &catalog->average[i]; 41 40 Measure *measure = &catalog->measure[m + j]; 41 42 // some filters -- these are the detections we skip 43 if (TIME_START && (measure->t < TIME_START_SEC)) continue; 44 if (TIME_END && (measure->t >= TIME_END_SEC)) continue; 45 46 if (measure->photcode < PHOTCODE_START) continue; 47 if (measure->photcode >= PHOTCODE_END) continue; 48 42 49 PhotCode *code = GetPhotcodebyCode(measure->photcode); 43 50 … … 55 62 detections[Ndetections].airMass = measure->airmass; 56 63 detections[Ndetections].expTime = pow(10.0, 0.4 * measure->dt); // expTime 57 detections[Ndetections].ra = average->R - measure->dR / 3600.; // ra58 detections[Ndetections].dec = average->D - measure->dD / 3600.; // dec64 detections[Ndetections].ra = measure->R; // ra 65 detections[Ndetections].dec = measure->D; // dec 59 66 detections[Ndetections].raErr = measure->dXccd * 0.01 * fabs(measure->pltscale); // estimate of raErr 60 67 detections[Ndetections].decErr = measure->dYccd * 0.01 * fabs(measure->pltscale); // estimate of decErr … … 87 94 } 88 95 96 time_t TIME_START_SEC = 0; 97 time_t TIME_END_SEC = INT_MAX; 98 89 99 int insert_detections_dvopsps_catalog (Catalog *catalog, MYSQL *mysql) { 90 100 91 101 off_t i, j; 92 102 int missingID = 0; 93 struct timeval start, stop;94 103 95 104 IOBuffer buffer; … … 101 110 off_t found = 0; 102 111 103 gettimeofday (&start, (void *) NULL);112 INITTIME; 104 113 insert_detections_mysql_init (&buffer); 105 114 int Ninsert = 0; … … 108 117 int status = TRUE; 109 118 119 if (TIME_START) ohana_str_to_time (TIME_START, &TIME_START_SEC); // we validate this in the args.c 120 if (TIME_END) ohana_str_to_time (TIME_END, &TIME_END_SEC); // we validate this in the args.c 121 110 122 // NOTE for testing, just do a few objects 111 123 if (!mysql) { … … 121 133 for (j = 0; j < average[i].Nmeasure; j++) { 122 134 135 off_t Nmeas = m + j; 136 137 // some filters -- these are the detections we skip (not an error, just skipped) 138 if (TIME_START && (measure[Nmeas].t < TIME_START_SEC)) continue; 139 if (TIME_END && (measure[Nmeas].t >= TIME_END_SEC)) continue; 140 141 if (measure[Nmeas].photcode < PHOTCODE_START) continue; 142 if (measure[Nmeas].photcode >= PHOTCODE_END) continue; 143 123 144 // XXX check return status 124 if (!insert_detections_mysql_value (&buffer, &average[i], &measure[ m+j])) {145 if (!insert_detections_mysql_value (&buffer, &average[i], &measure[Nmeas])) { 125 146 fprintf (stderr, "failure to insert detections in mysql\n"); 126 147 status = FALSE; … … 198 219 float zp = code->C * 0.001 + code->K * (measure->airmass - 1) - measure->Mcal; 199 220 float exptime = pow(10.0, 0.4 * measure->dt); 200 double ra = average->R - measure->dR / 3600.0;201 double dec = average->D - measure->dD / 3600.0;221 double ra = measure->R; 222 double dec = measure->D; 202 223 double dR = measure->dXccd * 0.01 * fabs(measure->pltscale); 203 224 double dD = measure->dYccd * 0.01 * fabs(measure->pltscale); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/dvopsps/src/insert_objects_dvopsps_catalog.c
r35450 r37067 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; … … 292 285 PrintIOBuffer (ave_buffer, "%d, ", average->measureOffset); 293 286 PrintIOBuffer (ave_buffer, "%d, ", average->missingOffset); 294 PrintIOBuffer (ave_buffer, "%d, ", average->extendOffset);287 PrintIOBuffer (ave_buffer, "%d, ", 0); // was : average->extendOffset); 295 288 PrintIOBuffer (ave_buffer, "%u, ", average->flags); 296 289 PrintIOBuffer (ave_buffer, "%u, ", average->photFlagsUpper); … … 323 316 float stackPSFMag = -999.0; 324 317 float stackPSFMagErr = -999.0; 325 if (isfinite(secfilt->dF luxPSF) && isfinite(secfilt->FluxPSF) && (secfilt->dFluxPSF> 0.0)) {326 float SN = secfilt->F luxPSF / secfilt->dFluxPSF;318 if (isfinite(secfilt->dFpsfStk) && isfinite(secfilt->FpsfStk) && (secfilt->dFpsfStk > 0.0)) { 319 float SN = secfilt->FpsfStk / secfilt->dFpsfStk; 327 320 if (SN > 3.0) { 328 stackPSFMag = -2.5 * log10(secfilt->F luxPSF) + 8.9;329 stackPSFMagErr = secfilt->dF luxPSF / secfilt->FluxPSF;321 stackPSFMag = -2.5 * log10(secfilt->FpsfStk) + 8.9; 322 stackPSFMagErr = secfilt->dFpsfStk / secfilt->FpsfStk; 330 323 } 331 324 } … … 333 326 float stackKronMag = -999.0; 334 327 float stackKronMagErr = -999.0; 335 if (isfinite(secfilt->dF luxKron) && isfinite(secfilt->FluxKron) && (secfilt->dFluxKron> 0.0)) {336 float SN = secfilt->F luxKron / secfilt->dFluxKron;328 if (isfinite(secfilt->dFkronStk) && isfinite(secfilt->FkronStk) && (secfilt->dFkronStk > 0.0)) { 329 float SN = secfilt->FkronStk / secfilt->dFkronStk; 337 330 if (SN > 3.0) { 338 stackKronMag = -2.5 * log10(secfilt->F luxKron) + 8.9;339 stackKronMagErr = secfilt->dF luxKron / secfilt->FluxKron;331 stackKronMag = -2.5 * log10(secfilt->FkronStk) + 8.9; 332 stackKronMagErr = secfilt->dFkronStk / secfilt->FkronStk; 340 333 } 341 334 } … … 347 340 PRINT_FLOAT(sec_buffer, meanKronMagErr, "%.6f, "); // umag precision 348 341 PRINT_FLOAT(sec_buffer, meanPSFMagErr, "%.6f, "); // umag precision 349 PRINT_FLOAT(sec_buffer, secfilt-> Xm,"%.6f, ");342 PRINT_FLOAT(sec_buffer, secfilt->Mchisq, "%.6f, "); 350 343 PRINT_FLOAT(sec_buffer, stackPSFMag, "%.6f, "); // umag precision 351 344 PRINT_FLOAT(sec_buffer, stackPSFMagErr, "%.6f, "); // umag precision 352 345 PRINT_FLOAT(sec_buffer, stackKronMag, "%.6f, "); // umag precision 353 346 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);347 PrintIOBuffer (sec_buffer, "%u, ", secfilt->flags); 348 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->Ncode); 349 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->Nused); 350 PrintIOBuffer (sec_buffer, "%.6f, ", secfilt->Mmin); 351 PrintIOBuffer (sec_buffer, "%.6f, ", secfilt->Mmax); 359 352 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->ubercalDist); 360 PrintIOBuffer (sec_buffer, "% hd, ", secfilt->Mstdev);353 PrintIOBuffer (sec_buffer, "%.6f, ", secfilt->Mstdev); 361 354 PrintIOBuffer (sec_buffer, "%lu ", secfilt->stackDetectID); 362 355 PrintIOBuffer (sec_buffer, "),\n"); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/dvopsps/src/insert_skytable.c
r35098 r37067 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/ipp-ops-20130712/Ohana/src/dvosplit/src/dvosplit.c
r33963 r37067 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/ipp-ops-20130712/Ohana/src/dvosplit/src/split_averages.c
r33656 r37067 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/ipp-ops-20130712/Ohana/src/dvosplit/src/split_measures.c
r33656 r37067 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/ipp-ops-20130712/Ohana/src/fixcat/src/gcatstats.c
r27435 r37067 52 52 catstats[0].coords.pc1_1 = catstats[0].coords.pc2_2 = 1.0; 53 53 catstats[0].coords.pc1_2 = catstats[0].coords.pc2_1 = 0.0; 54 strcpy (catstats[0].coords.ctype, " RA---TAN");54 strcpy (catstats[0].coords.ctype, "DEC--TAN"); 55 55 56 56 X1 = catstats[0].X; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/gastro/src/gstars.c
r34088 r37067 79 79 if (!strcasecmp (ROUGH_ASTROMETRY, "config")) { 80 80 /* default values for coords */ 81 strcpy (coords[0].ctype, " RA---TAN");81 strcpy (coords[0].ctype, "DEC--TAN"); 82 82 coords[0].pc1_1 = CCD_PC1_1; coords[0].pc1_2 = CCD_PC1_2; 83 83 coords[0].pc2_1 = CCD_PC2_1; coords[0].pc2_2 = CCD_PC2_2; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/gastro2/src/coordtest.c
r8300 r37067 85 85 fit_eval (); 86 86 87 strcpy (coords.ctype, " RA---PLY");87 strcpy (coords.ctype, "DEC--PLY"); 88 88 coords.crval1 = 0.0; 89 89 coords.crval2 = 0.0; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/gastro2/src/gstars2.c
r34088 r37067 28 28 29 29 /* default values for coords */ 30 strcpy (Target[0].coords.ctype, " RA---TAN");30 strcpy (Target[0].coords.ctype, "DEC--TAN"); 31 31 Target[0].coords.pc1_1 = CCD_PC1_1; Target[0].coords.pc1_2 = CCD_PC1_2; 32 32 Target[0].coords.pc2_1 = CCD_PC2_1; Target[0].coords.pc2_2 = CCD_PC2_2; … … 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/ipp-ops-20130712/Ohana/src/getstar
- Property svn:mergeinfo set to
-
branches/eam_branches/ipp-ops-20130712/Ohana/src/getstar/src/GetFileMode.c
r34088 r37067 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); 12 haveCTYPE = gfits_scan (header, "CTYPE 1", "%s", 1, ctype);13 haveCTYPE = gfits_scan (header, "CTYPE2", "%s", 1, ctype); 13 14 14 15 gfits_scan_alt (header, "EXTEND", "%t", 1, &extend); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/getstar/src/MatchImages.c
r34430 r37067 36 36 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 37 37 tcoords.Npolyterms = 1; 38 strcpy (tcoords.ctype, " RA---TAN");38 strcpy (tcoords.ctype, "DEC--TAN"); 39 39 /* register so image->sky conversions below have correct mosaic */ 40 40 } else { … … 44 44 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 45 45 tcoords.Npolyterms = 1; 46 strcpy (tcoords.ctype, " RA---TAN");46 strcpy (tcoords.ctype, "DEC--TAN"); 47 47 } 48 48 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/getstar/src/ReadImageFiles.c
r34088 r37067 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/ipp-ops-20130712/Ohana/src/getstar/src/dvoImagesAtCoords.c
- Property svn:mergeinfo changed
/trunk/Ohana/src/getstar/src/dvoImagesAtCoords.c merged: 36131
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-ops-20130712/Ohana/src/getstar/src/select_by_region.c
r35066 r37067 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/ipp-ops-20130712/Ohana/src/getstar/src/write_getstar_ps1_dev_0.c
r21508 r37067 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/ipp-ops-20130712/Ohana/src/getstar/src/write_getstar_ps1_dev_1.c
r21508 r37067 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/ipp-ops-20130712/Ohana/src/getstar/src/write_getstar_ps1_dev_2.c
r21508 r37067 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/ipp-ops-20130712/Ohana/src/kapa2/include/constants.h
r35766 r37067 15 15 // XXX for the moment, this is set to match the values in SetColorScale3D_CC 16 16 # define NPIXELS_STATIC 128 17 // # define NPIXELS_STATIC 100017 // # define NPIXELS_STATIC 4600 -- if we want fullcolor to work, need this 18 18 19 19 # define PAD1 3 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/kapa2/src/CheckPipe.c
r29938 r37067 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/ipp-ops-20130712/Ohana/src/kapa2/src/DrawObjects.c
r35416 r37067 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/ipp-ops-20130712/Ohana/src/kapa2/src/EventLoop.c
r21153 r37067 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/ipp-ops-20130712/Ohana/src/kapa2/src/FlushDisplay.c
r21153 r37067 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/ipp-ops-20130712/Ohana/src/kapa2/src/Graphs.c
r29539 r37067 64 64 graph[0].data.coords.crpix2 = 0.0; 65 65 graph[0].data.coords.cdelt1 = graph[0].data.coords.cdelt2 = 1.0; 66 strcpy (graph[0].data.coords.ctype, " RA---LIN");66 strcpy (graph[0].data.coords.ctype, "DEC--LIN"); 67 67 strcpy (graph[0].data.axis, "2222"); 68 68 strcpy (graph[0].data.ticks, "2222"); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/kapa2/src/Image.c
r29938 r37067 18 18 channel->coords.crpix2 = 0.0; 19 19 channel->coords.cdelt1 = channel->coords.cdelt2 = 1.0; 20 strcpy (channel->coords.ctype, " RA---LIN");20 strcpy (channel->coords.ctype, "DEC--LIN"); 21 21 channel->coords.Npolyterms = 0; 22 22 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/kapa2/src/Refresh.c
r27790 r37067 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/ipp-ops-20130712/Ohana/src/kapa2/src/bDrawObjects.c
r35416 r37067 315 315 D = scaleSize ? dz*z[i] : ds; 316 316 FillRectangle (buffer, sx, sy, 2*D, 2*D); 317 // plot range saturated by bDrawRectFill 317 318 } 318 319 } … … 335 336 D = scaleSize ? dz*z[i] : ds; 336 337 DrawRectangle (buffer, sx, sy, 2*D, 2*D); 338 // plot range saturated by bDrawRectOpen 337 339 } 338 340 } … … 356 358 DrawLine (buffer, sx - D, sy, sx + D, sy); 357 359 DrawLine (buffer, sx, sy - D, sx, sy + D); 360 // out-of-range points skipped by bDrawPoint 358 361 } 359 362 } … … 377 380 DrawLine (buffer, sx + D, sy - D, sx - D, sy + D); 378 381 DrawLine (buffer, sx - D, sy - D, sx + D, sy + D); 382 // out-of-range points skipped by bDrawPoint 379 383 } 380 384 } … … 398 402 // FillTriangle (buffer, sx - D, sy - 0.58*D, sx + D, sy - 0.58*D, sx, sy + 1.15*D); 399 403 FillTriangle (buffer, sx, sy + 0.58*D, D, -1.73*D); 404 // out-of-range points skipped by bDrawPoint 400 405 } 401 406 } … … 418 423 D = scaleSize ? dz*z[i] : ds; 419 424 OpenTriangle (buffer, sx - D, sy + 0.58*D, sx + D, sy + 0.58*D, sx, sy - 1.15*D); 425 // out-of-range points skipped by bDrawPoint 420 426 } 421 427 } … … 440 446 DrawLine (buffer, sx, sy, sx + D, sy - 0.58*D); 441 447 DrawLine (buffer, sx, sy, sx, sy + 1.15*D); 448 // out-of-range points skipped by bDrawPoint 442 449 } 443 450 } … … 460 467 D = scaleSize ? dz*z[i] : ds; 461 468 DrawCircle (buffer, sx, sy, D); 469 // out-of-range points skipped by bDrawPoint 462 470 } 463 471 } … … 484 492 DrawLine (buffer, sx - 0.58*D, sy + 0.81*D, sx - 0.95*D, sy - 0.31*D); 485 493 DrawLine (buffer, sx - 0.95*D, sy - 0.31*D, sx + 0.00*D, sy - 1.00*D); 494 // out-of-range points skipped by bDrawPoint 486 495 } 487 496 } … … 509 518 DrawLine (buffer, sx + 0.50*D, sy - 0.87*D, sx - 0.50*D, sy - 0.87*D); 510 519 DrawLine (buffer, sx - 0.50*D, sy - 0.87*D, sx - D, sy); 520 // out-of-range points skipped by bDrawPoint 511 521 } 512 522 } … … 529 539 D = scaleSize ? dz*z[i] : ds; 530 540 FillCircle (buffer, sx, sy, D); 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 531 564 } 532 565 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libautocode/Makefile.Targets
r34405 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/average-ps1-dev-2.d
r16810 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/average-ps1-v1.d
r21508 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/average-ps1-v2.d
r33647 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/average-ps1-v3.d
r33647 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/average-ps1-v4.d
r34405 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/average.d
r34405 r37067 2 2 EXTNAME DVO_AVERAGE 3 3 TYPE BINTABLE 4 SIZE 1 284 SIZE 184 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 41 54 42 55 # 'flags' was called 'code' prior to 2009.02.07 … … 49 62 FIELD catID, CAT_ID, unsigned int, unique ID for table in which object was first realized 50 63 FIELD extID, EXT_ID, uint64_t, external ID for object (eg PSPS objID) 64 FIELD extIDgc, EXT_ID_GC, uint64_t, external ID for object in galactic coords 51 65 52 66 # this structure should only be used for internal representations … … 56 70 57 71 # *** 20090206 : new fields : ChiSq, Npos, flags (was code, uint16_t), extID 58 59 72 # *** 20100331 : new fields needed to assess astrometry analysis quality: 60 73 # *** 20140617 : new fields : Rstk, Dstk, dRstk,dDstk, Nlensing, Nlensobj, lensingOffset, lensobjOffset, refColor 61 74 62 75 # photflagsUpper & photflagsLower: we have Nmeasures of a given source -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libautocode/def/common.h
r34088 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/image-ps1-v2.d
r30604 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/image-ps1-v3.d
r33647 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/image-ps1-v4.d
r34260 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/image.d
r33963 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/measure.d
r35099 r37067 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? … … 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/ipp-ops-20130712/Ohana/src/libautocode/def/photcode-ps1-v2.d
r27579 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/photcode-ps1-v3.d
r33647 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/photcode-ps1-v4.d
r34260 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/photcode.d
r33647 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/secfilt-ps1-v1.d
r21508 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/secfilt-ps1-v2.d
r27579 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/secfilt-ps1-v3.d
r33963 r37067 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/ipp-ops-20130712/Ohana/src/libautocode/def/secfilt-ps1-v4.d
r34620 r37067 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 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libautocode/def/secfilt.d
r35099 r37067 2 2 EXTNAME DVO_SECFILT 3 3 TYPE BINTABLE 4 SIZE 644 SIZE 160 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 18 FIELD flags, FLAGS, uint32_t, photometry flags 15 FIELD sMkron, MAG_KRON_STDEV, float, standard deviation of kron mags, mags 16 17 # these statistics are PSF-specific 18 FIELD Mstdev, MAG_STDEV, float, standard deviation of measurements, mags 19 FIELD Mmin, MAG_MIN, float, minimum accepted mag, mags 20 FIELD Mmax, MAG_MAX, float, maximum accepted mag, mags 21 FIELD Mchisq, MAG_CHI, float, chisq on average mag, value 22 19 23 FIELD Ncode, NCODE, short, number of detections in band 20 24 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 25 FIELD NusedKron, NUSED_KRON, short, number of detections used in average 26 FIELD NusedAp, NUSED_AP, short, number of detections used in average 27 28 FIELD flags, FLAGS, uint32_t, photometry flags 29 30 ## *** this section is for stack values *** 31 32 FIELD MpsfStk, MAG_PSF_STK, float, magnitude from stack (primary if available) 33 FIELD FpsfStk, FLUX_PSF_STK, float, flux from stack (primary if available) 34 FIELD dFpsfStk, FLUX_PSF_STK_ERR, float, mean flux psf error 35 36 FIELD MkronStk, MAG_KRON_STK, float, magnitude from stack (primary if available) 37 FIELD FkronStk, FLUX_KRON_STK, float, flux from stack (primary if available) 38 FIELD dFkronStk, FLUX_KRON_STK_ERR, float, mean flux kron error 39 40 FIELD MapStk, MAG_AP_STK, float, magnitude from stack (primary if available) 41 FIELD FapStk, FLUX_AP_STK, float, flux from stack (primary if available) 42 FIELD dFapStk, FLUX_AP_STK_ERR, float, mean flux ap error 43 44 ## need an 8-byte boundary here ## 45 FIELD stackDetectID, STACK_DETECT_ID, uint64_t, detection ID on stack used for fluxes (if any) 46 47 ## *** this section is for forced-warp mean values *** 48 49 FIELD MpsfWrp, MAG_PSF_WRP, float, psf magnitude from stack (primary if available) 50 FIELD FpsfWrp, FLUX_PSF_WRP, float, psf flux from stack (primary if available) 51 FIELD dFpsfWrp, FLUX_PSF_WRP_ERR, float, mean flux psf error 52 FIELD sFpsfWrp, FLUX_PSF_WRP_STD, float, mean flux psf stdev 53 54 FIELD MkronWrp, MAG_KRON_WRP, float, kron magnitude from stack (primary if available) 55 FIELD FkronWrp, FLUX_KRON_WRP, float, kron flux from stack (primary if available) 56 FIELD dFkronWrp, FLUX_KRON_WRP_ERR, float, mean flux kron error 57 FIELD sFkronWrp, FLUX_KRON_WRP_STD, float, mean flux kron stdev 58 59 FIELD MapWrp, MAG_AP_WRP, float, aper magnitude from stack (primary if available) 60 FIELD FapWrp, FLUX_AP_WRP, float, aper flux from stack (primary if available) 61 FIELD dFapWrp, FLUX_AP_WRP_ERR, float, mean flux ap error 62 FIELD sFapWrp, FLUX_AP_WRP_STD, float, mean flux ap stdev 63 64 FIELD NusedWrp, NUSED_WRP, short, number of detections used in average 65 FIELD NusedKronWrp, NUSED_KRON_WRP, short, number of detections used in average 66 FIELD NusedApWrp, NUSED_AP_WRP, short, number of detections used in average 67 23 68 FIELD ubercalDist, UBERCAL_DIST, short, number of images from an ubercal-image 24 FIELD Mstdev, MAG_STDEV, short, standard deviation of measurements, millimags25 FIELD stackDetectID, STACK_DETECT_ID, uint64_t, detection ID on stack used for fluxes (if any)26 69 27 70 # *** 20090206 : new fields : M_20, M_80; dropped dummy 28 71 # *** 20120302 : new fields : ubercalDist, Map, Mstdev 29 72 # *** 20120710 : new fields : Mkron, dMkron, FluxPSF, dFluxPSF, FluxKron, dFluxKron, stackID 73 74 # *** 20140617 : added : dMap, NusedKron, NusedAp, MpsfStk, MkronStk, MapStk, *Wrp 75 : changed : Mstdev, M_20 (to Mmin,short:float),M_80 (to Mmax,short:float), 76 : rename : FpsfStk, dFpsfStk, FkronStk, dFronStk (were FluxPSF, dFluxPSF, FluxKron, dFluxKron) -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/Makefile
r35416 r37067 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 \ … … 103 111 $(SRC)/ImageMetadata.$(ARCH).o \ 104 112 $(SRC)/ImageOps.$(ARCH).o \ 113 $(SRC)/RegionHostTable.$(ARCH).o \ 105 114 $(SRC)/match_image.$(ARCH).o \ 106 115 $(SRC)/db_utils.$(ARCH).o \ 107 116 $(SRC)/convert.$(ARCH).o \ 108 117 $(SRC)/HostTable.$(ARCH).o \ 109 $(SRC)/BoundaryTree.$(ARCH).o 110 118 $(SRC)/BoundaryTree.$(ARCH).o \ 119 $(SRC)/TessellationTable.$(ARCH).o 111 120 112 121 # $(SRC)/dvo_convert_panstarrs.$(ARCH).o -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/include/dvo.h
r35755 r37067 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 */ … … 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) … … 285 289 } HostTable; 286 290 291 // A RegionHost processes data for some region in parallel with other regions 292 typedef struct RegionHostInfo { 293 double Rmin; // (Rmin,Rmax),(Dmin,Dmax) arehard RA,DEC boundaries of the 294 double Rmax; // region for which each host is responsible. A given host 295 double Dmin; // calibrates the images for which the fiducial point (center) 296 double Dmax; // lands in the region, and all objects in the region 297 298 double RminCat; // (RminCat,RmaxCat),(DminCat,DmaxCat) are the region for which 299 double RmaxCat; // the catalogs need to be loaded : this is the outer bounds 300 double DminCat; // of the region containing all images completely 301 double DmaxCat; 302 303 char *hostname; 304 305 int hostID; // remove machine ID in SkyTable 306 int stdio[3]; // fd's for communication with the remote host 307 int pid; // remote process ID 308 int status; 309 IOBuffer stdout; 310 IOBuffer stderr; 311 312 off_t Nimage; 313 off_t NIMAGE; 314 Image *image; 315 off_t *imseq; 316 317 int *neighbors; // list of neighbor index values 318 int Nneighbors; // number of neighbors 319 char isNeighbor; // TRUE if I am a neighbor to the current region host 320 } RegionHostInfo; 321 322 typedef struct { 323 double Rmin; 324 double Rmax; 325 double Dmin; 326 double Dmax; 327 328 int Nhosts; 329 RegionHostInfo *hosts; 330 short *index; 331 } RegionHostTable; 332 287 333 // special-case function: 288 334 CMF_PS1_V2 *gfits_table_get_CMF_PS1_V1_Alt (FTable *ftable, off_t *Ndata, char *swapped); … … 291 337 // another special case : does not match byte-boundaries 292 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" 293 342 294 343 typedef struct { … … 308 357 # define BOUNDARY_TREE_NAME_LENGTH 128 309 358 359 // BoundaryTree is a structure to describe the 3pi RINGS skycell boundaries in terms of lines of constant (RA,DEC) 360 // the structure is flexible for a variety of RINGS-like tessellations, but is not appropriate for the LOCAL style tess 310 361 typedef struct { 311 362 int FixedGridDEC; // is the DEC sequence linear? … … 342 393 } BoundaryTree; 343 394 344 // XXX DROP? // a reduced-subset structure for relastro 345 // XXX DROP? typedef struct { 346 // XXX DROP? double R; 347 // XXX DROP? double D; 348 // XXX DROP? unsigned short Nmeasure; 349 // XXX DROP? int measureOffset; 350 // XXX DROP? uint32_t flags; 351 // XXX DROP? int catID; 352 // XXX DROP? } AverageTinyAstro; 395 typedef enum { TESS_NONE, TESS_LOCAL, TESS_RINGS } TessType; 396 397 // TessellationTable is a structure to describe the parameters of a set of "tessellations" 398 // (these are not strictly tessellations but projection sets as only the non-local 399 // versions can cover the full sky). For LOCAL projection cells, the structure describes 400 // the boundaries of a SINGLE projection cell with Nx * Ny skycells and includes some 401 // basic parameters (not used by the fullsky, eg RINGS, tessellations) 402 typedef struct { 403 double Rmin; // this tessellation is valid only for RA >= Rmin 404 double Rmax; // this tessellation is valid only for RA < Rmax 405 double Dmin; // this tessellation is valid only for DEC >= Dmin 406 double Dmax; // this tessellation is valid only for DEC < Dmax 407 408 double Xo; 409 double Yo; 410 double Ro; 411 double Do; 412 double dPix; 413 int dX; 414 int dY; 415 416 int NX_SUB; 417 int NY_SUB; 418 419 char *basename; 420 int Nbasename; 421 int projectIDoff; 422 int skycellIDoff; 423 424 TessType type; // 425 BoundaryTree *tree; 426 } TessellationTable; 353 427 354 428 // a reduced-subset structure for relphot … … 360 434 uint32_t flags; 361 435 int catID; 436 int objID; 437 int nOwn; 362 438 } AverageTiny; 363 439 364 440 // a reduced-subset structure for relphot & relastro 365 441 typedef struct { 366 float dR;367 float dD;442 double R; 443 double D; 368 444 float M; 369 445 float Mcal; … … 385 461 short dYccd; 386 462 short dRsys; 463 char myDet; 387 464 } MeasureTiny; 465 466 /** STRUCT DEFINITION **/ 467 typedef struct { 468 double R; // RA (decimal degrees ) 469 double D; // DEC (decimal degrees ) 470 float dR; // RA error (arcsec) 471 float dD; // DEC error (arcsec) 472 float uR; // RA*cos(D) proper-motion (arcsec/year) 473 float uD; // DEC proper-motion (arcsec/year) 474 float duR; // RA*cos(D) p-m error (arcsec/year) 475 float duD; // DEC p-m error (arcsec/year) 476 float P; // parallax (arcsec) 477 float dP; // parallax error (arcsec) 478 float ChiSqAve; // astrometry analysis chisq 479 float ChiSqPM; // astrometry analysis chisq 480 float ChiSqPar; // astrometry analysis chisq 481 int Tmean; // mean epoch (PM,PAR ref) (unix time seconds) 482 int Trange; // mean epoch (PM,PAR ref) (unix time seconds) 483 float Xp; // unused 484 unsigned short Npos; // number of detections used for astrometry 485 unsigned short Nmeasure; // number of psf measurements 486 unsigned short Nmissing; // number of missings 487 unsigned short Nextend; // number of extended measurements 488 uint32_t measureOffset; // offset to first psf measurement 489 uint32_t missingOffset; // offset to first missing obs 490 float refColor; // offset to first extended measurement 491 uint32_t flags; // average object flags (star; ghost; etc) 492 uint32_t photFlagsUpper; // upper bit of 2 bit summary of per-measure photflags 493 uint32_t photFlagsLower; // lower bit of 2 bit summary of per-measure photflags 494 unsigned int objID; // unique ID for object in table 495 unsigned int catID; // unique ID for table in which object was first realized 496 uint64_t extID; // external ID for object (eg PSPS objID) 497 } Average_PS1_V4alt; 498 499 Average_PS1_V4alt *gfits_table_get_Average_PS1_V4alt (FTable *table, off_t *Ndata, char *swapped); 500 Average *Average_PS1_V4alt_ToInternal (Average_PS1_V4alt *in, off_t Nvalues); 501 502 /** STRUCT DEFINITION **/ 503 typedef struct { 504 float dR; // RA offset (arcsec) 505 float dD; // DEC offset (arcsec) 506 float M; // catalog mag (mag) 507 float Mcal; // image cal mag (mag) 508 float Map; // aperture mag (mag) 509 float Mkron; // kron magnitude (mag) 510 float dMkron; // kron magnitude error (mag) 511 float dM; // mag error (mag) 512 float dMcal; // systematic calibration error (mag) 513 float dt; // exposure time (2.5*log(exptime)) 514 float FluxPSF; // flux from psf fit (counts/sec?) 515 float dFluxPSF; // error on psf flux (counts/sec?) 516 float FluxKron; // flux from kron ap (counts/sec?) 517 float dFluxKron; // error on kron flux (counts/sec?) 518 float airmass; // (airmass - 1) (airmass) 519 float az; // telescope azimuth 520 float Xccd; // X coord on chip (raw value) (pixels) 521 float Yccd; // Y coord on chip (raw value) (pixels) 522 float Sky; // local estimate of sky flux (counts/sec) 523 float dSky; // local estimate of sky flux (counts/sec) 524 int t; // time in seconds (UNIX) 525 unsigned int averef; // reference to average entry 526 unsigned int detID; // detection ID 527 unsigned int imageID; // reference to DVO image ID 528 unsigned int objID; // unique ID for object in table 529 unsigned int catID; // unique ID for table in which object was first realized 530 uint64_t extID; // external ID (eg PSPS detID) 531 float psfQF; // psf coverage/quality factor 532 float psfQFperf; // psf coverage / quality factor (all mask bits) 533 float psfChisq; // psf fit chisq 534 int psfNdof; // psf degrees of freedom 535 int psfNpix; // psf number of pixels 536 float crNsigma; // Nsigma deviation towards CR 537 float extNsigma; // Nsigma deviation towards EXT 538 short FWx; // object fwhm major axis (1/100 of pixels) 539 short FWy; // object fwhm minor axis (1/100 of pixels ) 540 short theta; // angle wrt ccd X dir ((0xffff/360) deg) 541 short Mxx; // second moments in pixel coords (1/100 of pixels) 542 short Mxy; // second moments in pixel coords (1/100 of pixels) 543 short Myy; // second moments in pixel coords (1/100 of pixels) 544 unsigned short t_msec; // time fraction of second (milliseconds) 545 unsigned short photcode; // photcode 546 short dXccd; // X coord error on chip (1/100 of pixels) 547 short dYccd; // Y coord error on chip (1/100 of pixels) 548 short dRsys; // systematic error from astrom (1/100 of pixels) 549 short posangle; // position angle sky to chip ((0xffff/360) deg) 550 float pltscale; // plate scale (arcsec/pixel) 551 unsigned int dbFlags; // flags supplied by analysis in database 552 unsigned int photFlags; // flags supplied by photometry program 553 } Measure_PS1_V4alt; 554 555 Measure_PS1_V4alt *gfits_table_get_Measure_PS1_V4alt (FTable *table, off_t *Ndata, char *swapped); 556 Measure *Measure_PS1_V4alt_ToInternal (Average *ave, Measure_PS1_V4alt *in, off_t Nvalues); 557 558 /* for some reason I have merged the set of tables and the file description, 559 so I need to have an internal structure to point to the separate files */ 388 560 389 561 /* a catalog contains this data */ … … 399 571 SecFilt *secfilt; 400 572 573 // lensing data (optional?) 574 Lensing *lensing; 575 Lensobj *lensobj; 576 401 577 int Nsecfilt; /* number of secfilt entries for each average entry */ 402 off_t Naverage, Nmeasure, Nmissing, N secf_mem; /* current number of each component in memory */403 off_t Naves_disk, Nmeas_disk, Nmiss_disk, N secf_disk; /* current number of each component on disk */404 off_t Naves_off, Nmeas_off, Nmiss_off, N secf_off; /* index of first loaded data value */578 off_t Naverage, Nmeasure, Nmissing, Nlensing, Nlensobj, Nsecf_mem; /* current number of each component in memory */ 579 off_t Naves_disk, Nmeas_disk, Nmiss_disk, Nlensing_disk, Nlensobj_disk, Nsecf_disk; /* current number of each component on disk */ 580 off_t Naves_off, Nmeas_off, Nmiss_off, Nlensing_off, Nlensobj_off, Nsecf_off; /* index of first loaded data value */ 405 581 406 582 // note that we use these for the full-sky relphot analysis … … 421 597 struct Catalog *missing_catalog; /* missing catalog data (split) */ 422 598 struct Catalog *secfilt_catalog; /* secfilt catalog data (split) */ 599 struct Catalog *lensing_catalog; /* lensing catalog data (split) */ 600 struct Catalog *lensobj_catalog; /* lensobj catalog data (split) */ 423 601 424 602 unsigned int objID; … … 429 607 char catmode; /* storage mode (raw, mef, split, mysql) */ 430 608 char catformat; /* storage format (elixir, panstarrs, etc) */ 431 char catflags; /* choices to be loaded */ 432 char sorted; /* is measure table average-sorted? */ 609 int sorted; /* is measure table average-sorted? (NOTE this is an int only because gfits_scan %t requires it) */ 433 610 611 short catflags; /* choices to be loaded */ 612 434 613 /* pointers for data manipulation */ 435 off_t *found; 436 off_t *image; 437 off_t *mosaic; 438 float *X; 439 float *Y; 614 off_t *found_t; 615 off_t *foundWarp_t; 616 // off_t *image_t; 617 // off_t *mosaic_t; 618 // float *X_t; 619 // float *Y_t; 620 int *nOwn_t; // relastro uses this to count owned detections per object 440 621 441 622 } Catalog; … … 497 678 char *GetPhotcodeNamebyCode (int code); 498 679 499 float PhotInst (Measure *measure); 500 float PhotCat (Measure *measure); 501 float PhotAper (Measure *measure); 502 float PhotKron (Measure *measure); 503 float PhotSys (Measure *measure, Average *average, SecFilt *secfilt); 504 float PhotRel (Measure *measure, Average *average, SecFilt *secfilt); 505 float PhotCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code); 506 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt); 507 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure); 680 float PhotInst (Measure *measure, dvoMagClassType class); 681 float PhotCat (Measure *measure, dvoMagClassType class); 682 float PhotSys (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class); 683 float PhotRel (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class); 684 float PhotCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code, dvoMagClassType class); 685 float PhotErr (Measure *measure, dvoMagClassType class); 686 float PhotCalErr (Measure *measure, dvoMagClassType class); 687 688 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 689 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure, dvoMagClassType class, dvoMagSourceType source); 690 float PhotAveErr (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 691 692 float PhotInstTiny (MeasureTiny *measure, dvoMagClassType class); 693 float PhotCatTiny (MeasureTiny *measure, dvoMagClassType class); 694 float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class); 695 float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class); 696 float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code, dvoMagClassType class); 697 698 float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 699 float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, dvoMagClassType class, dvoMagSourceType source); 700 701 float PhotFluxInst (Measure *measure, dvoMagClassType class); 702 float PhotFluxCat (Measure *measure, dvoMagClassType class); 703 float PhotFluxSys (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class); 704 float PhotFluxRel (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class); 705 float PhotFluxCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code, dvoMagClassType class); 706 707 float PhotFluxAve (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 708 float PhotFluxRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure, dvoMagClassType class, dvoMagSourceType source); 709 710 float PhotFluxInstErr (Measure *measure, dvoMagClassType class); 711 float PhotFluxCatErr (Measure *measure, dvoMagClassType class); 712 508 713 float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt); 509 float PhotdM (PhotCode *code, Average *average, SecFilt *secfilt);510 511 float PhotAperInst (Measure *measure);512 float PhotKronInst (Measure *measure);513 float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt);514 float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt);515 516 714 float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt); 517 float PhotAveFluxPSF (PhotCode *code, Average *average, SecFilt *secfilt);518 float PhotAvedFluxPSF (PhotCode *code, Average *average, SecFilt *secfilt);519 float PhotAveFluxKron (PhotCode *code, Average *average, SecFilt *secfilt);520 float PhotAvedFluxKron (PhotCode *code, Average *average, SecFilt *secfilt);521 715 522 716 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt); 523 float PhotM 20(PhotCode *code, Average *average, SecFilt *secfilt);524 float PhotM 80(PhotCode *code, Average *average, SecFilt *secfilt);717 float PhotMmin (PhotCode *code, Average *average, SecFilt *secfilt); 718 float PhotMmax (PhotCode *code, Average *average, SecFilt *secfilt); 525 719 float PhotUCdist (PhotCode *code, Average *average, SecFilt *secfilt); 526 720 unsigned int PhotStackID (PhotCode *code, Average *average, SecFilt *secfilt); … … 529 723 int PhotColor (Average *average, SecFilt *secfilt, Measure *measure, int c1, int c2, double *color); 530 724 531 float PhotInstTiny (MeasureTiny *measure);532 float PhotCatTiny (MeasureTiny *measure);533 float PhotAperTiny (MeasureTiny *measure);534 float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt);535 float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt);536 float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code);537 float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt);538 float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure);539 725 float PhotXmTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt); 540 726 float PhotdMTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt); … … 607 793 /*** conversion functions / I/O conversions ***/ 608 794 Average *ReadRawAverage (FILE *f, off_t Naverage, char format, SecFilt **primary); 609 Measure *ReadRawMeasure (FILE *f, off_t Nmeasure, char format);795 Measure *ReadRawMeasure (FILE *f, Average *average, off_t Nmeasure, char format); 610 796 SecFilt *ReadRawSecFilt (FILE *f, off_t Nsecfilt, char format); 611 797 int WriteRawAverage (FILE *f, Average *average, off_t Naverage, char format, SecFilt *primary); 612 int WriteRawMeasure (FILE *f, Measure *measure, off_t Nmeasure, char format);798 int WriteRawMeasure (FILE *f, Average *average, Measure *measure, off_t Nmeasure, char format); 613 799 int WriteRawSecFilt (FILE *f, SecFilt *secfilt, off_t Nsecfilt, char format); 614 800 … … 616 802 617 803 Average *FtableToAverage (FTable *ftable, off_t *Naverage, char *format, SecFilt **primary); 618 Measure *FtableToMeasure (FTable *ftable, off_t *Nmeasure, char *format);804 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, char *format); 619 805 SecFilt *FtableToSecFilt (FTable *ftable, off_t *Nsecfilt, char *format); 806 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, char *format); 807 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, char *format); 620 808 int FtableToImage (FTable *ftable, Header *theader, char *format); 621 809 622 810 int AverageToFtable (FTable *ftable, Average *average, off_t Naverage, char format, SecFilt *primary); 623 int MeasureToFtable (FTable *ftable, Measure *measure, off_t Nmeasure, char format);811 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, char format); 624 812 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, char format); 813 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, char format); 814 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, char format); 625 815 int ImageToFtable (FTable *ftable, Header *theader, char format); 626 816 int ImageToVtable (VTable *vtable, Header *theader, char format); … … 637 827 # include "ps1_v3_defs.h" 638 828 # include "ps1_v4_defs.h" 829 # include "ps1_v5_defs.h" 639 830 # include "ps1_ref_defs.h" 640 831 … … 696 887 void sort_coords_index (double *X, double *Y, off_t *S, off_t N); 697 888 void sort_coords_indexonly (double *X, double *Y, off_t *S, off_t N); 889 void sort_IDs_indexonly (opihi_int *X, off_t *S, off_t N); 698 890 void sort_regions (SkyRegion *region, off_t N); 699 891 … … 716 908 int free_tiny_values (Catalog *catalog); 717 909 910 BoundaryTree *BoundaryTreeLoad(char *filename); 911 BoundaryTree *BoundaryTreeRead(Header *headerPHU, Header *headerZone, FILE *f); 912 913 int BoundaryTreeSave(char *filename, BoundaryTree *tree); 914 int BoundaryTreeWrite(FILE *f, BoundaryTree *tree); 915 718 916 int BoundaryTreeCellCoords (BoundaryTree *tree, int *zone, int *band, double ra, double dec); 719 int BoundaryTreeSave(char *filename, BoundaryTree *tree);720 BoundaryTree *BoundaryTreeLoad(char *filename);721 917 int BoundaryTreeProjection (double *x, double *y, double r, double d, BoundaryTree *tree, int zone, int band); 918 919 TessellationTable *TessellationTableLoad(char *filename, int *Ntess); 920 int TessellationTableSave(char *filename, TessellationTable *tess, int Ntess); 921 int TessellationPrimaryCellIDs (TessellationTable *tess, int Ntess, int *tessID, int *projID, int *skycellID, double ra, double dec); 922 void TessellationTableInit (TessellationTable *tess, int Ntess); 923 924 float dvoOffsetR (Measure *measure, Average *average); 925 float dvoOffsetD (Measure *measure, Average *average); 926 double dvoMeanR (float dR, Average *average); 927 double dvoMeanD (float dD, Average *average); 722 928 723 929 void dvo_average_init (Average *average); … … 727 933 void dvo_measureT_init (MeasureTiny *measure); 728 934 935 void dvo_lensing_init (Lensing *lensing); 936 void dvo_lensobj_init (Lensobj *lensobj); 937 938 void InitRegionHosts (RegionHostInfo *hosts, int Nhosts, int NHOSTS); 939 void FreeRegionHosts (RegionHostInfo *hosts, int Nhosts); 940 void FreeRegionHostTable (RegionHostTable *table); 941 RegionHostTable *RegionHostTableLoad (char *catdir, char *rootname); 942 int RegionHostTableWaitJobs (RegionHostTable *regionHosts, char *file, int lineno); 943 int RegionHostTableWaitJobsGetIO (RegionHostTable *regionHosts, char *file, int lineno, int VERBOSE); 944 int RegionHostFindNeighbors (RegionHostTable *table, int Nhost); 945 729 946 # endif // DVO_H -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/include/dvodb.h
r35416 r37067 22 22 23 23 /* magnitude types */ 24 enum {MAG_NONE, 25 MAG_INST, 26 MAG_CAT, 27 MAG_APER, 28 MAG_APER_INST, 29 MAG_KRON, 30 MAG_KRON_INST, 31 MAG_KRON_ERR, 32 MAG_SYS, 33 MAG_REL, 34 MAG_CAL, 35 MAG_AVE, 36 MAG_REF, 37 MAG_ERR, 38 MAG_STDEV, 39 MAG_AVE_ERR, 40 MAG_PHOT_FLAGS, 41 MAG_CHISQ, 42 MAG_NCODE, 43 MAG_NPHOT, 44 MAG_20, 45 MAG_80, 46 MAG_UC_DIST, 47 MAG_STACK_DET_ID, 48 MAG_FLUX_PSF, 49 MAG_FLUX_PSF_ERR, 50 MAG_FLUX_KRON, 51 MAG_FLUX_KRON_ERR, 52 }; 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_STACK_DET_ID, 57 MAG_OPTION_FLAGS, 58 } dvoMagOptionType; 59 60 typedef enum { 61 MAG_CLASS_NONE, 62 MAG_CLASS_PSF, 63 MAG_CLASS_KRON, 64 MAG_CLASS_APER, 65 } dvoMagClassType; 53 66 54 67 /* measure fields */ … … 90 103 MEAS_OBJ_FLAGS, 91 104 MEAS_SECFILT_FLAGS, 92 MEAS_ MAG,105 MEAS_PHOT, // photometry class of measurements 93 106 MEAS_MINST, 94 107 MEAS_MCAT, … … 144 157 MEAS_EXTERN_ID, 145 158 MEAS_EXPNAME_AS_INT, 146 MEAS_MCAL_OFFSET, 159 MEAS_MCAL_OFFSET, // make this a dvoMagOption? 147 160 MEAS_FLAT, 148 161 MEAS_CENTER_OFFSET, 149 MEAS_FLUX_PSF, 150 MEAS_FLUX_PSF_ERR, 151 MEAS_FLUX_KRON, 152 MEAS_FLUX_KRON_ERR, 162 MEAS_REF_COLOR, 153 163 }; 154 164 … … 174 184 AVE_TMEAN, 175 185 AVE_TRANGE, 186 AVE_PSF_QF, 187 AVE_PSF_QF_PERF, 188 AVE_STARGAL, 176 189 AVE_Xp, 177 190 AVE_NMEAS, 178 191 AVE_NMISS, 179 192 AVE_NPOS, 180 AVE_NPHOT,181 AVE_NCODE,182 AVE_MAG,183 AVE_dMAG,184 AVE_Xm,185 193 AVE_OBJ_FLAGS, 186 194 AVE_TYPE, … … 190 198 AVE_EXTID_HI, 191 199 AVE_EXTID_LO, 200 AVE_REF_COLOR, 201 AVE_PHOT, // photometry class of values 192 202 }; 203 204 // AVE_NPHOT, 205 // AVE_NCODE, 206 // AVE_MAG, 207 // AVE_dMAG, 208 // AVE_Xm, 193 209 194 210 enum {IMAGE_ZERO, … … 257 273 IMAGE_NFIT_ASTROM, 258 274 IMAGE_NLINK_PHOTOM, 259 IMAGE_NLINK_ASTROM 275 IMAGE_NLINK_ASTROM, 276 IMAGE_REF_COLOR 260 277 }; 261 278 … … 277 294 int table; 278 295 int ID; 279 int magMode; 296 297 dvoMagSourceType magSource; // chip, (forced) warp, stack [only relevant for averages] 298 dvoMagLevelType magLevel; // inst, cat, sys, rel, ave, ref, err, min, max, stdev, nphot, chisq, 299 dvoMagOptionType magOption; // psf, kron, aper 300 dvoMagClassType magClass; 301 280 302 char type; 281 303 PhotCode *photcode; … … 339 361 340 362 int GetMagMode PROTO((char *string)); 341 PhotCode *ParsePhotcodeField PROTO((char *field, int *mode, int def));363 int ParsePhotcodeField PROTO((dbField *field, char *fieldName, int fieldID)); 342 364 int ParseMeasureField PROTO((dbField *field, char *fieldName)); 343 365 int ParseAverageField PROTO((dbField *field, char *fieldName)); … … 372 394 373 395 // Some values used by code moved to libdvo from opihi. 374 enum {OPIHI_ FLT, OPIHI_INT};396 enum {OPIHI_NOTYPE, OPIHI_FLT, OPIHI_INT}; 375 397 #define opihi_flt double 376 398 #define opihi_int int -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/include/elixir_defs.h
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/include/loneos_defs.h
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/include/panstarrs_dev_0_defs.h
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/include/panstarrs_dev_1_defs.h
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/include/ps1_dev_1_defs.h
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/include/ps1_dev_2_defs.h
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/include/ps1_ref_defs.h
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/include/ps1_v1_defs.h
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/include/ps1_v2_defs.h
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/include/ps1_v3_defs.h
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/include/ps1_v4_defs.h
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/BoundaryTree.c
r35755 r37067 1 1 # include "dvo.h" 2 2 3 # define GET_COLUMN_NEW( OUT,NAME,TYPE)\4 TYPE *OUT = gfits_get_bintable_column_data ( &theader, &ftable, NAME, type, &Nrow, &Ncol); \3 # define GET_COLUMN_NEW(HEADER,FTABLE,OUT,NAME,TYPE) \ 4 TYPE *OUT = gfits_get_bintable_column_data (HEADER, FTABLE, NAME, type, &Nrow, &Ncol); \ 5 5 myAssert (!strcmp(type, #TYPE), "wrong column type"); 6 6 7 # define GET_COLUMN_RAW( OUT,NAME,TYPE)\8 OUT = gfits_get_bintable_column_data ( &theader, &ftable, NAME, type, &Nrow, &Ncol); \7 # define GET_COLUMN_RAW(HEADER,FTABLE,OUT,NAME,TYPE) \ 8 OUT = gfits_get_bintable_column_data (HEADER, FTABLE, NAME, type, &Nrow, &Ncol); \ 9 9 myAssert (!strcmp(type, #TYPE), "wrong column type"); 10 10 … … 12 12 13 13 BoundaryTree *BoundaryTreeLoad(char *filename) { 14 15 Header header; 16 Header theader; 17 Matrix matrix; 18 19 header.buffer = NULL; 20 matrix.buffer = NULL; 21 theader.buffer = NULL; 22 BoundaryTree *tree = NULL; 23 24 FILE *f = fopen (filename, "r"); 25 if (!f) { 26 fprintf (stderr, "ERROR: cannot open boundary tree file %s\n", filename); 27 return NULL; 28 } 29 30 /* load in PHU segment (ignore) */ 31 if (!gfits_fread_header (f, &header)) { 32 if (DEBUG) fprintf (stderr, "can't read boundary tree header\n"); 33 goto escape; 34 } 35 if (!gfits_fread_matrix (f, &matrix, &header)) { 36 if (DEBUG) fprintf (stderr, "can't read boundary tree matrix\n"); 37 goto escape; 38 } 39 40 // load data for this header 41 if (!gfits_load_header (f, &theader)) { 42 if (DEBUG) fprintf (stderr, "can't read boundary tree zone table header\n"); 43 goto escape; 44 } 45 46 tree = BoundaryTreeRead (&header, &theader, f); 47 48 escape: 49 50 gfits_free_header (&theader); 51 gfits_free_header (&header); 52 gfits_free_matrix (&matrix); 53 fclose (f); 54 55 return tree; 56 } 57 58 // assume we are pointing at the relevant table portion 59 BoundaryTree *BoundaryTreeRead(Header *headerPHU, Header *headerZone, FILE *f) { 14 60 15 61 int i, j, nz, nb, Ncol; 16 62 off_t Nrow; 17 63 char type[16]; 18 Header header; 19 Header theader; 20 Matrix matrix; 21 FTable ftable; 22 23 header.buffer = NULL; 24 matrix.buffer = NULL; 25 ftable.buffer = NULL; 26 theader.buffer = NULL; 64 65 FTable ftableZone; 66 67 Header headerCell; 68 FTable ftableCell; 69 70 ftableZone.buffer = NULL; 71 ftableCell.buffer = NULL; 72 headerCell.buffer = NULL; 73 74 // we must have already read in the Zone table header section 75 ftableZone.header = headerZone; 76 ftableCell.header = &headerCell; 77 27 78 BoundaryTree *tree = NULL; 28 79 29 FILE *f = fopen (filename, "r");30 if (!f) {31 fprintf (stderr, "ERROR: cannot open image subset file %s\n", filename);32 return NULL;33 }34 35 /* load in PHU segment (ignore) */36 if (!gfits_fread_header (f, &header)) {37 if (DEBUG) fprintf (stderr, "can't read image subset header\n");38 goto escape;39 }40 if (!gfits_fread_matrix (f, &matrix, &header)) {41 if (DEBUG) fprintf (stderr, "can't read image subset matrix\n");42 goto escape;43 }44 45 80 ALLOCATE (tree, BoundaryTree, 1); 46 81 47 gfits_scan (&header, "DEC_ORI", "%lf", 1, &tree->DEC_origin); 48 gfits_scan (&header, "DEC_OFF", "%lf", 1, &tree->DEC_offset); 49 50 gfits_scan (&header, "NX_SUB", "%d", 1, &tree->NX_SUB); 51 gfits_scan (&header, "NY_SUB", "%d", 1, &tree->NY_SUB); 52 gfits_scan (&header, "PIXSCALE", "%lf", 1, &tree->dPix); 53 54 ftable.header = &theader; 82 // we need to read the boundary tree parameters from the correct header 83 // put them in the PHU header in any case? 84 gfits_scan (headerPHU, "DEC_ORI", "%lf", 1, &tree->DEC_origin); 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); 88 gfits_scan (headerPHU, "PIXSCALE", "%lf", 1, &tree->dPix); 55 89 56 90 /*** zone information table ***/ 57 { 58 // load data for this header 59 if (!gfits_load_header (f, &theader)) goto escape; 60 61 // read the fits table bytes 62 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) goto escape; 91 92 // read the fits table bytes 93 if (!gfits_fread_ftable_data (f, &ftableZone, FALSE)) goto escape; 63 94 64 // need to create and assign to flat-field correction 65 GET_COLUMN_RAW(tree->Nband, "NBAND", int); 66 GET_COLUMN_RAW(tree->RA_origin, "RA_ORIGIN", double); 67 GET_COLUMN_RAW(tree->RA_offset, "RA_OFFSET", double); 68 GET_COLUMN_RAW(tree->DEC_min , "DEC_MIN", double); 69 GET_COLUMN_RAW(tree->DEC_max , "DEC_MAX", double); 70 GET_COLUMN_RAW(tree->DEC_min_raw, "DEC_MIN_RAW", double); 71 GET_COLUMN_RAW(tree->DEC_max_raw, "DEC_MAX_RAW", double); 72 gfits_free_header (&theader); 73 gfits_free_table (&ftable); 74 75 fprintf (stderr, "loaded data for %lld zones\n", (long long) Nrow); 76 tree->Nzone = Nrow; 77 78 // allocate the storage arrays 79 ALLOCATE (tree->ra, double *, tree->Nzone); 80 ALLOCATE (tree->dec, double *, tree->Nzone); 81 ALLOCATE (tree->Xo, double *, tree->Nzone); 82 ALLOCATE (tree->Yo, double *, tree->Nzone); 83 ALLOCATE (tree->dX, int *, tree->Nzone); 84 ALLOCATE (tree->dY, int *, tree->Nzone); 85 ALLOCATE (tree->cell, int *, tree->Nzone); 86 ALLOCATE (tree->projID, int *, tree->Nzone); 87 ALLOCATE (tree->name, char **, tree->Nzone); 88 for (i = 0; i < tree->Nzone; i++) { 89 ALLOCATE (tree->ra[i], double, tree->Nband[i]); 90 ALLOCATE (tree->dec[i], double, tree->Nband[i]); 91 ALLOCATE (tree->Xo[i], double, tree->Nband[i]); 92 ALLOCATE (tree->Yo[i], double, tree->Nband[i]); 93 ALLOCATE (tree->dX[i], int, tree->Nband[i]); 94 ALLOCATE (tree->dY[i], int, tree->Nband[i]); 95 ALLOCATE (tree->cell[i], int, tree->Nband[i]); 96 ALLOCATE (tree->projID[i], int, tree->Nband[i]); 97 ALLOCATE (tree->name[i], char *, tree->Nband[i]); 98 for (j = 0; j < tree->Nband[i]; j++) { 99 ALLOCATE (tree->name[i][j], char, BOUNDARY_TREE_NAME_LENGTH); 100 } 95 // need to create and assign to flat-field correction 96 GET_COLUMN_RAW(headerZone, &ftableZone, tree->Nband, "NBAND", int); 97 GET_COLUMN_RAW(headerZone, &ftableZone, tree->RA_origin, "RA_ORIGIN", double); 98 GET_COLUMN_RAW(headerZone, &ftableZone, tree->RA_offset, "RA_OFFSET", double); 99 GET_COLUMN_RAW(headerZone, &ftableZone, tree->DEC_min , "DEC_MIN", double); 100 GET_COLUMN_RAW(headerZone, &ftableZone, tree->DEC_max , "DEC_MAX", double); 101 GET_COLUMN_RAW(headerZone, &ftableZone, tree->DEC_min_raw, "DEC_MIN_RAW", double); 102 GET_COLUMN_RAW(headerZone, &ftableZone, tree->DEC_max_raw, "DEC_MAX_RAW", double); 103 gfits_free_table (&ftableZone); 104 105 fprintf (stderr, "loaded data for %lld zones\n", (long long) Nrow); 106 tree->Nzone = Nrow; 107 108 // allocate the storage arrays 109 ALLOCATE (tree->ra, double *, tree->Nzone); 110 ALLOCATE (tree->dec, double *, tree->Nzone); 111 ALLOCATE (tree->Xo, double *, tree->Nzone); 112 ALLOCATE (tree->Yo, double *, tree->Nzone); 113 ALLOCATE (tree->dX, int *, tree->Nzone); 114 ALLOCATE (tree->dY, int *, tree->Nzone); 115 ALLOCATE (tree->cell, int *, tree->Nzone); 116 ALLOCATE (tree->projID, int *, tree->Nzone); 117 ALLOCATE (tree->name, char **, tree->Nzone); 118 for (i = 0; i < tree->Nzone; i++) { 119 ALLOCATE (tree->ra[i], double, tree->Nband[i]); 120 ALLOCATE (tree->dec[i], double, tree->Nband[i]); 121 ALLOCATE (tree->Xo[i], double, tree->Nband[i]); 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]); 125 ALLOCATE (tree->cell[i], int, tree->Nband[i]); 126 ALLOCATE (tree->projID[i], int, tree->Nband[i]); 127 ALLOCATE (tree->name[i], char *, tree->Nband[i]); 128 for (j = 0; j < tree->Nband[i]; j++) { 129 ALLOCATE (tree->name[i][j], char, BOUNDARY_TREE_NAME_LENGTH); 101 130 } 102 131 } 103 132 104 133 /*** cell information table ***/ 105 { 106 // load data for this header107 if (!gfits_load_header (f, &theader)) goto escape;108 109 // read the fits table bytes110 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) goto escape;134 135 // load data for this header 136 if (!gfits_load_header (f, &headerCell)) goto escape; 137 138 // read the fits table bytes 139 if (!gfits_fread_ftable_data (f, &ftableCell, FALSE)) goto escape; 111 140 112 // need to create and assign to flat-field correction 113 GET_COLUMN_NEW(R, "RA", double); 114 GET_COLUMN_NEW(D, "DEC", double); 115 GET_COLUMN_NEW(zone, "ZONE", int); 116 GET_COLUMN_NEW(band, "BAND", int); 117 GET_COLUMN_NEW(index, "INDEX", int); 118 GET_COLUMN_NEW(Xo, "X_CENT", double); 119 GET_COLUMN_NEW(Yo, "Y_CENT", double); 120 GET_COLUMN_NEW(dX, "X_GRID", int); 121 GET_COLUMN_NEW(dY, "Y_GRID", int); 122 GET_COLUMN_NEW(name, "NAME", char); // XXX how is this done? 123 gfits_free_header (&theader); 124 gfits_free_table (&ftable); 125 fprintf (stderr, "loaded data for %lld cells\n", (long long) Nrow); 126 127 // assign the storage arrays 128 for (i = 0; i < Nrow; i++) { 129 nz = zone[i]; 130 nb = band[i]; 131 tree->ra[nz][nb] = R[i]; 132 tree->dec[nz][nb] = D[i]; 133 tree->Xo[nz][nb] = Xo[i]; 134 tree->Yo[nz][nb] = Yo[i]; 135 tree->dX[nz][nb] = dX[i]; 136 tree->dY[nz][nb] = dY[i]; 137 tree->cell[nz][nb] = i; // XXX ? 138 memcpy(tree->name[nz][nb], &name[i*BOUNDARY_TREE_NAME_LENGTH], BOUNDARY_TREE_NAME_LENGTH); 139 // XXX parse out the ID from the name (skycell.NNNN) 140 tree->projID[nz][nb] = atoi(&tree->name[nz][nb][8]); 141 } 142 143 free (R ); 144 free (D ); 145 free (zone ); 146 free (band ); 147 free (Xo ); 148 free (Yo ); 149 free (dX ); 150 free (dY ); 151 free (index ); 152 free (name ); 153 } 154 155 gfits_free_header (&header); 156 gfits_free_matrix (&matrix); 157 fclose (f); 141 // need to create and assign to flat-field correction 142 GET_COLUMN_NEW(&headerCell, &ftableCell, R, "RA", double); 143 GET_COLUMN_NEW(&headerCell, &ftableCell, D, "DEC", double); 144 GET_COLUMN_NEW(&headerCell, &ftableCell, zone, "ZONE", int); 145 GET_COLUMN_NEW(&headerCell, &ftableCell, band, "BAND", int); 146 GET_COLUMN_NEW(&headerCell, &ftableCell, index, "INDEX", int); 147 GET_COLUMN_NEW(&headerCell, &ftableCell, Xo, "X_CENT", double); 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); 151 GET_COLUMN_NEW(&headerCell, &ftableCell, name, "NAME", char); // XXX how is this done? 152 gfits_free_header (&headerCell); 153 gfits_free_table (&ftableCell); 154 155 fprintf (stderr, "loaded data for %lld cells\n", (long long) Nrow); 156 157 // assign the storage arrays 158 for (i = 0; i < Nrow; i++) { 159 nz = zone[i]; 160 nb = band[i]; 161 tree->ra[nz][nb] = R[i]; 162 tree->dec[nz][nb] = D[i]; 163 tree->Xo[nz][nb] = Xo[i]; 164 tree->Yo[nz][nb] = Yo[i]; 165 tree->dX[nz][nb] = dX[i]; 166 tree->dY[nz][nb] = dY[i]; 167 tree->cell[nz][nb] = i; // XXX ? 168 memcpy(tree->name[nz][nb], &name[i*BOUNDARY_TREE_NAME_LENGTH], BOUNDARY_TREE_NAME_LENGTH); 169 // XXX parse out the ID from the name (skycell.NNNN) 170 tree->projID[nz][nb] = atoi(&tree->name[nz][nb][8]); 171 } 172 173 free (R ); 174 free (D ); 175 free (zone ); 176 free (band ); 177 free (Xo ); 178 free (Yo ); 179 free (dX ); 180 free (dY ); 181 free (index ); 182 free (name ); 158 183 159 184 return tree; 160 185 161 186 escape: 162 gfits_free_header (&header); 163 gfits_free_matrix (&matrix); 164 gfits_free_header (&theader); 165 gfits_free_table (&ftable); 187 gfits_free_header (&headerCell); 188 gfits_free_table (&ftableCell); 189 gfits_free_table (&ftableZone); 166 190 if (tree) free (tree); 167 191 168 fclose (f);169 192 return NULL; 170 193 } … … 173 196 int BoundaryTreeSave(char *filename, BoundaryTree *tree) { 174 197 175 int i, nz, nb;176 198 Header header; 177 Header theader;178 199 Matrix matrix; 179 FTable ftable;180 200 181 201 gfits_init_header (&header); … … 202 222 gfits_free_header (&header); 203 223 gfits_free_matrix (&matrix); 224 225 BoundaryTreeWrite (f, tree); 226 fclose (f); 227 228 return TRUE; 229 } 230 231 int BoundaryTreeWrite(FILE *f, BoundaryTree *tree) { 232 233 int i, nz, nb; 234 Header theader; 235 FTable ftable; 204 236 205 237 /*** zone information table ***/ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/HostTable.c
r35102 r37067 86 86 FreeHosts (hosts, Nhosts); 87 87 free (filename); 88 fclose (f); 88 89 return NULL; 89 90 } … … 133 134 134 135 free (filename); 136 fclose (f); 135 137 return table; 136 138 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/ImageMetadata.c
r35416 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/ImageMetadataSelection.c
r35416 r37067 18 18 field.pc1_2 = field.pc2_1 = 0.0; 19 19 field.Npolyterms = 0; 20 strcpy (field.ctype, " RA---SIN");20 strcpy (field.ctype, "DEC--SIN"); 21 21 22 22 /* mosaic defines a frame with 0,0 at the mosaic center, and 1 arcsec / pixel */ … … 26 26 mosaic.pc1_2 = mosaic.pc2_1 = 0.0; 27 27 mosaic.Npolyterms = 0; 28 strcpy (mosaic.ctype, " RA---SIN");28 strcpy (mosaic.ctype, "DEC--SIN"); 29 29 30 30 if ((image = ImageMetadataLoad (filename, &Nimage)) == NULL) return (FALSE); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/ImageSelection.c
r35416 r37067 28 28 mosaic.pc1_2 = mosaic.pc2_1 = 0.0; 29 29 mosaic.Npolyterms = 0; 30 strcpy (mosaic.ctype, " RA---SIN");30 strcpy (mosaic.ctype, "DEC--SIN"); 31 31 } 32 32 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/LoadPhotcodesFITS.c
r35755 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/LoadPhotcodesText.c
r28833 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/SavePhotcodesFITS.c
r34260 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/cmf-ps1-dv3.c
r35416 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/coordops.c
r34088 r37067 1 1 # include <dvo.h> 2 3 /* note that Coords.ctype carries the DEC (ctype2) value */ 2 4 3 5 static Coords mosaic; … … 621 623 622 624 /* modifications to the ctype? */ 625 /* note that Coords.ctype carries the DEC (ctype2) value */ 623 626 OldAIPS = FALSE; 624 627 gfits_modify (header, "CTYPE2", "%s", 1, coords[0].ctype); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dbCheckStack.c
r35755 r37067 7 7 // these would be better done using bit values to test for field? temp? float? 8 8 // 9 10 #define OPIHI_INT 111 9 12 10 int dbCheckStack (dbStack *stack, int Nstack, int table, dbField **inFields, int *inNfields) { -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dbExtractAverages.c
r35416 r37067 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 … … 153 152 break; 154 153 154 case AVE_PSF_QF: 155 value.Flt = average[0].psfQF; 156 break; 157 case AVE_PSF_QF_PERF: 158 value.Flt = average[0].psfQFperf; 159 break; 160 case AVE_STARGAL: 161 value.Flt = average[0].stargal; 162 break; 163 case AVE_REF_COLOR: 164 value.Flt = average[0].refColorBlue; 165 break; 166 155 167 case AVE_OBJ_FLAGS: 156 168 value.Int = average[0].flags; … … 169 181 break; 170 182 171 case AVE_MAG: 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 switch (field->magOption) { 203 case MAG_OPTION_MAG: 204 switch (field->magLevel) { 205 case MAG_LEVEL_AVE: 206 value.Flt = PhotAve (field->photcode, average, secfilt, field->magClass, field->magSource); 207 break; 208 case MAG_LEVEL_REF: 209 // why is measure needed here? 210 // PhotRef (field->photcode, average, secfilt, measure, field->magClass, field->magSource); 211 break; 212 case MAG_LEVEL_INST: 213 case MAG_LEVEL_CAT: 214 case MAG_LEVEL_SYS: 215 case MAG_LEVEL_REL: 216 case MAG_LEVEL_CAL: 217 case MAG_LEVEL_NONE: 218 break; 219 } 220 break; 221 222 case MAG_OPTION_ERR: 223 switch (field->magLevel) { 224 case MAG_LEVEL_AVE: 225 case MAG_LEVEL_REF: 226 value.Flt = PhotAveErr (field->photcode, average, secfilt, field->magClass, field->magSource); 227 break; 228 case MAG_LEVEL_INST: 229 case MAG_LEVEL_CAT: 230 case MAG_LEVEL_SYS: 231 case MAG_LEVEL_REL: 232 case MAG_LEVEL_CAL: 233 case MAG_LEVEL_NONE: 234 break; 235 } 236 break; 237 238 case MAG_OPTION_FLUX: 239 switch (field->magLevel) { 240 case MAG_LEVEL_AVE: 241 value.Flt = PhotFluxAve (field->photcode, average, secfilt, field->magClass, field->magSource); 242 break; 243 case MAG_LEVEL_REF: 244 // value.Flt = PhotFluxRef (equiv, average, secfilt, measure, field->magClass, field->magSource); 245 break; 246 case MAG_LEVEL_INST: 247 case MAG_LEVEL_CAT: 248 case MAG_LEVEL_SYS: 249 case MAG_LEVEL_REL: 250 case MAG_LEVEL_CAL: 251 case MAG_LEVEL_NONE: 252 break; 253 } 254 break; 255 256 case MAG_OPTION_FLUX_ERR: 257 switch (field->magLevel) { 258 case MAG_LEVEL_AVE: 259 case MAG_LEVEL_REF: 260 // value.Flt = PhotFluxAveErr (equiv, average, secfilt, field->magClass, field->magSource); 261 break; 262 case MAG_LEVEL_INST: 263 case MAG_LEVEL_CAT: 264 case MAG_LEVEL_SYS: 265 case MAG_LEVEL_REL: 266 case MAG_LEVEL_CAL: 267 case MAG_LEVEL_NONE: 268 break; 269 } 270 break; 271 272 case MAG_OPTION_STDEV: 273 case MAG_OPTION_CHISQ: 274 case MAG_OPTION_MIN: 275 case MAG_OPTION_MAX: 276 case MAG_OPTION_NCODE: { 277 int Nsec = GetPhotcodeNsec (field->photcode->code); 278 if (Nsec == -1) break; 279 value.Int = secfilt[Nsec].Ncode; 280 break; 281 } 282 case MAG_OPTION_NPHOT: { 283 int Nsec = GetPhotcodeNsec (field->photcode->code); 284 if (Nsec == -1) break; 285 value.Int = secfilt[Nsec].Nused; 286 break; 287 } 288 case MAG_OPTION_UC_DIST: 289 case MAG_OPTION_STACK_DET_ID: 290 value.Int = PhotStackID (field->photcode, average, secfilt); 291 break; 292 case MAG_OPTION_FLAGS: { 293 int Nsec = GetPhotcodeNsec (field->photcode->code); 294 if (Nsec == -1) break; 295 value.Int = secfilt[Nsec].flags; 296 break; 297 } 298 case MAG_OPTION_NONE: 299 break; 300 } 301 break; 302 303 # if (0) 172 304 switch (field->magMode) { 173 305 case MAG_AVE: … … 201 333 } 202 334 } else { 203 value.Flt = Phot dM(field->photcode, average, secfilt);335 value.Flt = PhotAveErr (field->photcode, average, secfilt); 204 336 } 205 337 break; … … 215 347 } 216 348 } else { 217 Nsec = GetPhotcodeNsec (field->photcode->code);349 int Nsec = GetPhotcodeNsec (field->photcode->code); 218 350 if (Nsec == -1) break; 219 351 value.Int = secfilt[Nsec].flags; … … 223 355 // XXX push these into dvo_photcode_ops APIs 224 356 // XXX do I need to allow for conversion to equiv? 225 Nsec = GetPhotcodeNsec (field->photcode->code);357 int Nsec = GetPhotcodeNsec (field->photcode->code); 226 358 if (Nsec == -1) break; 227 359 value.Int = secfilt[Nsec].Ncode; 228 360 break; 229 361 case MAG_NPHOT: 230 Nsec = GetPhotcodeNsec (field->photcode->code);362 int Nsec = GetPhotcodeNsec (field->photcode->code); 231 363 if (Nsec == -1) break; 232 364 value.Int = secfilt[Nsec].Nused; 233 365 break; 234 366 367 case MAG_APER: 368 case MAG_APER_AVE: 369 value.Flt = PhotAperAve (field->photcode, average, secfilt); 370 break; 371 372 case MAG_APER_REF: 373 value.Flt = PhotAperRef (field->photcode, average, secfilt, measure); 374 break; 375 235 376 case MAG_KRON: 377 case MAG_KRON_AVE: 236 378 value.Flt = PhotKronAve (field->photcode, average, secfilt); 379 break; 380 381 case MAG_KRON_REF: 382 value.Flt = PhotKronRef (field->photcode, average, secfilt, measure); 237 383 break; 238 384 … … 241 387 break; 242 388 243 case MAG_ 20:244 value.Flt = PhotM 20(field->photcode, average, secfilt);245 break; 246 case MAG_ 80:247 value.Flt = PhotM 80(field->photcode, average, secfilt);389 case MAG_MIN: 390 value.Flt = PhotMmin (field->photcode, average, secfilt); 391 break; 392 case MAG_MAX: 393 value.Flt = PhotMmax (field->photcode, average, secfilt); 248 394 break; 249 395 case MAG_UC_DIST: … … 269 415 break; 270 416 case AVE_dMAG: 271 value.Flt = Phot dM(field->photcode, average, secfilt);417 value.Flt = PhotAveErr (field->photcode, average, secfilt); 272 418 break; 273 419 case AVE_Xm: 274 420 value.Flt = PhotXm (field->photcode, average, secfilt); 275 421 break; 422 # endif 276 423 case AVE_TYPE: 277 424 break; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dbExtractImages.c
r35102 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/dbExtractMeasures.c
r35508 r37067 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_APER: 126 case MAG_APER_INST: 127 case MAG_KRON: 128 case MAG_KRON_INST: 129 case MAG_KRON_ERR: 130 case MAG_ERR: 131 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: 132 126 equiv = myEquiv; 133 127 if (equiv && (equiv->code == field->photcode->code)) goto valid_photcode; … … 135 129 136 130 // mean-like : return value for the given photcode 137 case MAG_AVE: 138 case MAG_REF: 139 case MAG_CHISQ: 140 case MAG_AVE_ERR: 141 case MAG_NCODE: 142 case MAG_NPHOT: 143 case MAG_FLUX_PSF: 144 case MAG_FLUX_PSF_ERR: 145 case MAG_FLUX_KRON: 146 case MAG_FLUX_KRON_ERR: 131 case MAG_LEVEL_AVE: 132 case MAG_LEVEL_REF: 147 133 equiv = field->photcode; 148 134 goto valid_photcode; … … 156 142 157 143 valid_photcode: 158 switch (field->magMode) { 159 case MAG_INST: 160 value.Flt = PhotInst (measure); 161 break; 162 case MAG_CAT: 163 value.Flt = PhotCat (measure); 164 break; 165 case MAG_SYS: 166 value.Flt = PhotSys (measure, average, secfilt); 167 break; 168 case MAG_REL: 169 value.Flt = PhotRel (measure, average, secfilt); 170 break; 171 case MAG_CAL: 172 value.Flt = PhotCal (measure, average, secfilt, measure, equiv); 173 break; 174 case MAG_AVE: 175 value.Flt = PhotAve (equiv, average, secfilt); 176 break; 177 case MAG_REF: 178 value.Flt = PhotRef (equiv, average, secfilt, measure); 179 break; 180 case MAG_APER: 181 value.Flt = PhotAper (measure); 182 break; 183 case MAG_APER_INST: 184 value.Flt = PhotAperInst (measure); 185 break; 186 case MAG_KRON: 187 value.Flt = PhotKron (measure); 188 break; 189 case MAG_KRON_INST: 190 value.Flt = PhotKronInst (measure); 191 break; 192 case MAG_KRON_ERR: 193 value.Flt = measure[0].dMkron; 194 break; 195 case MAG_ERR: 196 value.Flt = measure[0].dM; 197 break; 198 case MAG_AVE_ERR: 199 value.Flt = PhotdM (equiv, average, secfilt); 200 break; 201 case MAG_PHOT_FLAGS: 202 if ((field->photcode->type == PHOT_REF) || (field->photcode->type == PHOT_DEP)) { 203 value.Int = measure[0].photFlags; 204 } else { 205 value.Int = 0; 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; 206 170 } 207 171 break; 208 case MAG_CHISQ: 209 value.Flt = PhotXm (equiv, average, secfilt); 172 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 } 210 191 break; 211 case MAG_NCODE: 212 if (equiv == NULL) { 213 value.Int = 0; 214 break; 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; 215 218 } 216 Nsec = GetPhotcodeNsec (equiv->code);217 if (Nsec == -1) break;218 value.Int = secfilt[Nsec].Ncode;219 219 break; 220 case MAG_NPHOT: 221 if (equiv == NULL) { 222 value.Int = 0; 223 break; 220 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; 224 240 } 225 Nsec = GetPhotcodeNsec (equiv->code);226 if (Nsec == -1) break;227 value.Int = secfilt[Nsec].Nused;228 241 break; 229 case MAG_FLUX_PSF: 230 value.Flt = PhotAveFluxPSF (field->photcode, average, secfilt);231 break;232 case MAG_ FLUX_PSF_ERR:233 value.Flt = PhotAvedFluxPSF (field->photcode, average, secfilt);234 break;235 case MAG_ FLUX_KRON:236 value.Flt = PhotAveFluxKron (field->photcode, average, secfilt);237 break;238 case MAG_ FLUX_KRON_ERR:239 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_STACK_DET_ID: 251 case MAG_OPTION_FLAGS: 252 case MAG_OPTION_NONE: 240 253 break; 241 254 } … … 243 256 } 244 257 case MEAS_RA: /* OK */ 245 value.Flt = average[0].R - measure[0].dR / 3600.0;258 value.Flt = measure[0].R; 246 259 break; 247 260 case MEAS_DEC: /* OK */ 248 value.Flt = average[0].D - measure[0].dD / 3600.0;261 value.Flt = measure[0].D; 249 262 break; 250 263 case MEAS_RA_AVE: /* OK */ … … 257 270 case MEAS_GLON: 258 271 if (!haveGalacticMeas) { 259 ApplyTransform (&GLON_MEAS, &GLAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_galactic);272 ApplyTransform (&GLON_MEAS, &GLAT_MEAS, measure[0].R, measure[0].D, celestial_to_galactic); 260 273 haveGalacticMeas = TRUE; 261 274 } … … 264 277 case MEAS_GLAT: 265 278 if (!haveGalacticMeas) { 266 ApplyTransform (&GLON_MEAS, &GLAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_galactic);279 ApplyTransform (&GLON_MEAS, &GLAT_MEAS, measure[0].R, measure[0].D, celestial_to_galactic); 267 280 haveGalacticMeas = TRUE; 268 281 } … … 271 284 case MEAS_ELON: 272 285 if (!haveEclipticMeas) { 273 ApplyTransform (&ELON_MEAS, &ELAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_ecliptic);286 ApplyTransform (&ELON_MEAS, &ELAT_MEAS, measure[0].R, measure[0].D, celestial_to_ecliptic); 274 287 haveEclipticMeas = TRUE; 275 288 } … … 278 291 case MEAS_ELAT: 279 292 if (!haveEclipticMeas) { 280 ApplyTransform (&ELON_MEAS, &ELAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_ecliptic);293 ApplyTransform (&ELON_MEAS, &ELAT_MEAS, measure[0].R, measure[0].D, celestial_to_ecliptic); 281 294 haveEclipticMeas = TRUE; 282 295 } … … 375 388 // the error. 376 389 case MEAS_RA_OFFSET: /* OK */ 377 value.Flt = measure[0].dR;390 value.Flt = dvoOffsetR (measure, average); 378 391 break; 379 392 case MEAS_DEC_OFFSET: /* OK */ 380 value.Flt = measure[0].dD;393 value.Flt = dvoOffsetD (measure, average); 381 394 break; 382 395 case MEAS_RA_FIT_OFFSET: /* OK */ 383 396 dT = (measure[0].t - average[0].Tmean) / (86400*365.25); 384 value.Flt = average[0].uR * dT + measure[0].dR; 397 dR = dvoOffsetR (measure, average); 398 value.Flt = average[0].uR * dT + dR; 385 399 break; 386 400 case MEAS_DEC_FIT_OFFSET: /* OK */ 387 401 dT = (measure[0].t - average[0].Tmean) / (86400*365.25); 388 value.Flt = average[0].uD * dT + measure[0].dD; 402 dD = dvoOffsetD (measure, average); 403 value.Flt = average[0].uD * dT + dD; 389 404 break; 390 405 case MEAS_RA_OFFSET_ERR: /* OK */ … … 458 473 case MEAS_PLATESCALE: /* OK */ 459 474 value.Flt = measure[0].pltscale; 475 break; 476 477 case MEAS_REF_COLOR: 478 value.Flt = average[0].refColorBlue; 460 479 break; 461 480 … … 486 505 // measure.xccd if we need it 487 506 Image *image; 488 ra = average[0].R - measure[0].dR / 3600.0;489 dec = average[0].D - measure[0].dD / 3600.0;507 ra = measure[0].R; 508 dec = measure[0].D; 490 509 image = MatchImageDVO (measure[0].t, measure[0].photcode, measure[0].imageID); 491 510 if (image == NULL) break; … … 501 520 { 502 521 Image *image; 503 ra = average[0].R - measure[0].dR / 3600.0;504 dec = average[0].D - measure[0].dD / 3600.0;522 ra = measure[0].R; 523 dec = measure[0].D; 505 524 image = MatchImageDVO (measure[0].t, measure[0].photcode, measure[0].imageID); 506 525 if (image == NULL) break; … … 531 550 fieldc = MatchFieldMetadata (measure[0].imageID); 532 551 } else { 533 fprintf (stderr, "non-parallel Xmos broken\n");534 abort();552 // fprintf (stderr, "non-parallel Xmos broken\n"); 553 // abort(); 535 554 // fieldc = MatchField (measure[0].t, measure[0].photcode); 555 fieldc = MatchFieldMetadata (measure[0].imageID); 536 556 } 537 557 if (fieldc == NULL) break; 538 double Rm = average[0].R - measure[0].dR / 3600.0;539 double Dm = average[0].D - measure[0].dD / 3600.0;558 double Rm = measure[0].R; 559 double Dm = measure[0].D; 540 560 RD_to_XY (&XFIELD_MEAS, &YFIELD_MEAS, Rm, Dm, fieldc); 541 561 } … … 547 567 fieldc = MatchFieldMetadata (measure[0].imageID); 548 568 } else { 549 fprintf (stderr, "non-parallel Xmos broken\n");550 abort();569 // fprintf (stderr, "non-parallel Xmos broken\n"); 570 // abort(); 551 571 // fieldc = MatchField (measure[0].t, measure[0].photcode); 572 fieldc = MatchFieldMetadata (measure[0].imageID); 552 573 } 553 574 if (fieldc == NULL) break; 554 double Rm = average[0].R - measure[0].dR / 3600.0;555 double Dm = average[0].D - measure[0].dD / 3600.0;575 double Rm = measure[0].R; 576 double Dm = measure[0].D; 556 577 RD_to_XY (&XFIELD_MEAS, &YFIELD_MEAS, Rm, Dm, fieldc); 557 578 } … … 564 585 mosaic = MatchMosaicMetadata (measure[0].imageID); 565 586 } else { 566 fprintf (stderr, "non-parallel Xmos broken\n"); 567 abort(); 568 mosaic = MatchMosaic (measure[0].t, measure[0].photcode); 587 // fprintf (stderr, "non-parallel Xmos broken\n"); 588 // abort(); 589 // mosaic = MatchMosaic (measure[0].t, measure[0].photcode); 590 mosaic = MatchMosaicMetadata (measure[0].imageID); 569 591 } 570 592 if (mosaic == NULL) break; 571 double Rm = average[0].R - measure[0].dR / 3600.0;572 double Dm = average[0].D - measure[0].dD / 3600.0;593 double Rm = measure[0].R; 594 double Dm = measure[0].D; 573 595 RD_to_XY (&XMOS_MEAS, &YMOS_MEAS, Rm, Dm, mosaic); 574 596 } … … 580 602 mosaic = MatchMosaicMetadata (measure[0].imageID); 581 603 } else { 582 fprintf (stderr, "non-parallel Xmos broken\n"); 583 abort(); 584 mosaic = MatchMosaic (measure[0].t, measure[0].photcode); 604 // fprintf (stderr, "non-parallel Xmos broken\n"); 605 // abort(); 606 // mosaic = MatchMosaic (measure[0].t, measure[0].photcode); 607 mosaic = MatchMosaicMetadata (measure[0].imageID); 585 608 } 586 609 if (mosaic == NULL) break; 587 double Rm = average[0].R - measure[0].dR / 3600.0;588 double Dm = average[0].D - measure[0].dD / 3600.0;610 double Rm = measure[0].R; 611 double Dm = measure[0].D; 589 612 RD_to_XY (&XMOS_MEAS, &YMOS_MEAS, Rm, Dm, mosaic); 590 613 } … … 699 722 break; 700 723 701 case MEAS_FLUX_PSF: /* OK */702 value.Flt = measure[0].FluxPSF;703 break;704 case MEAS_FLUX_PSF_ERR: /* OK */705 value.Flt = measure[0].dFluxPSF;706 break;707 case MEAS_FLUX_KRON: /* OK */708 value.Flt = measure[0].FluxKron;709 break;710 case MEAS_FLUX_KRON_ERR: /* OK */711 value.Flt = measure[0].dFluxKron;712 break;724 // case MEAS_FLUX_PSF: /* OK */ 725 // value.Flt = measure[0].FluxPSF; 726 // break; 727 // case MEAS_FLUX_PSF_ERR: /* OK */ 728 // value.Flt = measure[0].dFluxPSF; 729 // break; 730 // case MEAS_FLUX_KRON: /* OK */ 731 // value.Flt = measure[0].FluxKron; 732 // break; 733 // case MEAS_FLUX_KRON_ERR: /* OK */ 734 // value.Flt = measure[0].dFluxKron; 735 // break; 713 736 } 714 737 return (value); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dbFields.c
r35416 r37067 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, "stack_det_id")) return (MAG_OPTION_STACK_DET_ID); 81 if (!strcasecmp (string, "flags")) return (MAG_OPTION_FLAGS); 82 83 return MAG_OPTION_NONE; 84 } 85 86 # if (0) 30 87 int GetMagMode (char *string) { 31 88 89 // these all imply PSF mags: 32 90 if (!strcasecmp (string, "inst")) return (MAG_INST); 33 91 if (!strcasecmp (string, "cat")) return (MAG_CAT); … … 37 95 if (!strcasecmp (string, "ave")) return (MAG_AVE); 38 96 if (!strcasecmp (string, "ref")) return (MAG_REF); 97 if (!strcasecmp (string, "err")) return (MAG_ERR); 98 if (!strcasecmp (string, "aveerr")) return (MAG_AVE_ERR); 99 100 // these are explicit PSF mags: 101 if (!strcasecmp (string, "psf_inst")) return (MAG_INST); 102 if (!strcasecmp (string, "psf_cat")) return (MAG_CAT); 103 if (!strcasecmp (string, "psf_sys")) return (MAG_SYS); 104 if (!strcasecmp (string, "psf_rel")) return (MAG_REL); 105 if (!strcasecmp (string, "psf_cal")) return (MAG_CAL); 106 if (!strcasecmp (string, "psf_ave")) return (MAG_AVE); 107 if (!strcasecmp (string, "psf_ref")) return (MAG_REF); 108 if (!strcasecmp (string, "psf_err")) return (MAG_ERR); 109 if (!strcasecmp (string, "psf_aveerr")) return (MAG_AVE_ERR); 110 111 // these are aper mags: 39 112 if (!strcasecmp (string, "ap")) return (MAG_APER); 40 113 if (!strcasecmp (string, "aper")) return (MAG_APER); 41 114 if (!strcasecmp (string, "aperinst")) return (MAG_APER_INST); 42 115 if (!strcasecmp (string, "aper_inst")) return (MAG_APER_INST); 116 if (!strcasecmp (string, "aper_cat")) return (MAG_APER_CAT); 117 if (!strcasecmp (string, "aper_sys")) return (MAG_APER_SYS); 118 if (!strcasecmp (string, "aper_rel")) return (MAG_APER_REL); 119 if (!strcasecmp (string, "aper_cal")) return (MAG_APER_CAL); 120 if (!strcasecmp (string, "aper_ave")) return (MAG_APER_AVE); 121 if (!strcasecmp (string, "aper_ref")) return (MAG_APER_REF); 122 if (!strcasecmp (string, "aper_err")) return (MAG_APER_ERR); 123 124 // these are kron mags: 43 125 if (!strcasecmp (string, "kron")) return (MAG_KRON); 126 if (!strcasecmp (string, "kron_inst")) return (MAG_KRON_INST); 127 if (!strcasecmp (string, "kron_cat")) return (MAG_KRON_CAT); 128 if (!strcasecmp (string, "kron_sys")) return (MAG_KRON_SYS); 129 if (!strcasecmp (string, "kron_rel")) return (MAG_KRON_REL); 130 if (!strcasecmp (string, "kron_cal")) return (MAG_KRON_CAL); 131 if (!strcasecmp (string, "kron_ave")) return (MAG_KRON_AVE); 132 if (!strcasecmp (string, "kron_ref")) return (MAG_KRON_REF); 133 if (!strcasecmp (string, "kron_err")) return (MAG_KRON_ERR); 44 134 if (!strcasecmp (string, "kroninst")) return (MAG_KRON_INST); 45 if (!strcasecmp (string, "kron_inst")) return (MAG_KRON_INST);46 135 if (!strcasecmp (string, "kronerr")) return (MAG_KRON_ERR); 47 if (!strcasecmp (string, "err")) return (MAG_ERR); 48 if (!strcasecmp (string, "aveerr")) return (MAG_AVE_ERR);136 137 // other fields: 49 138 if (!strcasecmp (string, "photflags")) return (MAG_PHOT_FLAGS); 50 139 if (!strcasecmp (string, "flags")) return (MAG_PHOT_FLAGS); … … 53 142 if (!strcasecmp (string, "nphot")) return (MAG_NPHOT); 54 143 if (!strcasecmp (string, "stdev")) return (MAG_STDEV); 55 if (!strcasecmp (string, " 20")) return (MAG_20);56 if (!strcasecmp (string, " 80")) return (MAG_80);144 if (!strcasecmp (string, "min")) return (MAG_MIN); 145 if (!strcasecmp (string, "max")) return (MAG_MAX); 57 146 if (!strcasecmp (string, "ucdist")) return (MAG_UC_DIST); 58 147 if (!strcasecmp (string, "stackDetectID")) return (MAG_STACK_DET_ID); … … 63 152 return (MAG_NONE); 64 153 } 65 66 PhotCode *ParsePhotcodeField (char *field, int *mode, int defMode) { 67 68 int useDefault; 69 char *tmpstring, *p; 70 PhotCode *code; 71 72 *mode = defMode; 73 useDefault = TRUE; 74 75 p = strchr (field, ':'); 76 if (p != NULL) { 77 *mode = GetMagMode (p + 1); 78 useDefault = FALSE; 79 if (*mode == MAG_NONE) return (NULL); 80 tmpstring = strncreate (field, p - field); 81 } else { 82 tmpstring = strcreate (field); 83 } 84 if (!strcasecmp (tmpstring, "MAG")) { 85 ALLOCATE (code, PhotCode, 1); 86 code[0].code = 0; 87 strcpy (code[0].name, "MAG"); 88 code[0].type = PHOT_MAG; 89 // the field call 'mag' is only valid for mextract 90 // it should default to REL, but other types should default to AVE 91 if (useDefault) { 92 *mode = MAG_REL; 154 # endif 155 156 // field may be of the form mag:psf:inst:wrp. except for the first subword, 157 // the words may be in any order 158 int ParsePhotcodeField (dbField *field, char *fieldName, int fieldID) { 159 160 int j; 161 162 // defaults: 163 field->ID = fieldID; // change if not true in the end? 164 165 // check what options are provided. do not allow duplicate types 166 // except mag and flux may exist with err 167 dvoMagSourceType mySource = MAG_SRC_NONE; 168 dvoMagLevelType myLevel = MAG_LEVEL_NONE; 169 dvoMagClassType myClass = MAG_CLASS_NONE; 170 dvoMagOptionType myOption = MAG_OPTION_NONE; 171 172 field->magSource = MAG_SRC_CHP; 173 field->magLevel = MAG_LEVEL_AVE; 174 field->magClass = MAG_CLASS_PSF; 175 field->magOption = MAG_OPTION_MAG; 176 177 // make a local working copy of fieldName and replace ':' with spaces 178 char *fieldCopy = strcreate(fieldName); 179 for (j = 0; fieldCopy[j]; j++) { 180 if (fieldCopy[j] == ':') fieldCopy[j] = ' '; 181 } 182 183 char *firstWord = getword(fieldCopy); 184 185 // firstWord may be either flux, mag or photcode 186 if (!strcasecmp (firstWord, "MAG")) { 187 // default level for 'mag' is rel 188 field->magLevel = MAG_LEVEL_REL; 189 myOption = MAG_OPTION_MAG; 190 } 191 if (!strcasecmp (firstWord, "FLUX")) { 192 // default level for 'flux' is rel 193 field->magLevel = MAG_LEVEL_REL; 194 myOption = MAG_OPTION_FLUX; 195 } 196 PhotCode *code = GetPhotcodebyName (firstWord); 197 free (firstWord); 198 199 if (!code) return FALSE; 200 201 // defaults for photcode clases 202 if (code->type == PHOT_DEP) { 203 field->magLevel = MAG_LEVEL_REL; 204 } 205 if (code->type == PHOT_SEC) { 206 field->magLevel = MAG_LEVEL_AVE; 207 } 208 if (code->type == PHOT_REF) { 209 field->magLevel = MAG_LEVEL_CAT; 210 // is this one required? 211 } 212 213 // look at the remaining words and assign properties as approrpiate 214 char *ptr = skipword(fieldCopy); 215 while (ptr) { 216 217 char *word = getword(ptr); 218 if (!word) break; 219 220 dvoMagSourceType source = GetMagSource (word); 221 if (source != MAG_SRC_NONE) { 222 if (mySource != MAG_SRC_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 223 mySource = source; 224 ptr = skipword (ptr); 225 continue; 93 226 } 94 free (tmpstring); 95 return (code); 96 } 97 code = GetPhotcodebyName (tmpstring); 98 if (!code) { 99 return NULL; 100 } 101 102 // enforce compatibility 103 if (useDefault) { 104 if (code[0].type == PHOT_REF) { 105 *mode = MAG_CAT; 227 228 dvoMagLevelType level = GetMagLevel (word); 229 if (level != MAG_LEVEL_NONE) { 230 if (myLevel != MAG_LEVEL_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 231 myLevel = level; 232 ptr = skipword (ptr); 233 continue; 106 234 } 107 if (code[0].type == PHOT_DEP) { 108 *mode = MAG_REL; 235 236 dvoMagClassType class = GetMagClass (word); 237 if (class != MAG_CLASS_NONE) { 238 if (myClass != MAG_CLASS_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 239 myClass = class; 240 ptr = skipword (ptr); 241 continue; 109 242 } 110 } 111 free (tmpstring); 112 return (code); 113 } 114 115 # define ESCAPE(F,M,T) { \ 116 field->ID = (F); \ 117 field->magMode = (M); \ 118 field->type = (T); \ 119 field->photcode = NULL; \ 120 return (TRUE); } 121 122 int ParseMeasureField (dbField *field, char *fieldName) { 123 124 int mode; 125 PhotCode *code; 126 127 field->table = DVO_TABLE_MEASURE; 128 field->name = strcreate (fieldName); 129 130 if (!strcasecmp (fieldName, "GLON")) { 131 dbExtractMeasuresInitTransform (COORD_GALACTIC); 132 ESCAPE (MEAS_GLON, MAG_NONE, OPIHI_FLT); 133 } 134 if (!strcasecmp (fieldName, "GLAT")) { 135 dbExtractMeasuresInitTransform (COORD_GALACTIC); 136 ESCAPE (MEAS_GLAT, MAG_NONE, OPIHI_FLT); 137 } 138 if (!strcasecmp (fieldName, "GLON:AVE")) { 139 dbExtractMeasuresInitTransform (COORD_GALACTIC); 140 ESCAPE (MEAS_GLON_AVE, MAG_NONE, OPIHI_FLT); 141 } 142 if (!strcasecmp (fieldName, "GLAT:AVE")) { 143 dbExtractMeasuresInitTransform (COORD_GALACTIC); 144 ESCAPE (MEAS_GLAT_AVE, MAG_NONE, OPIHI_FLT); 145 } 146 147 if (!strcasecmp (fieldName, "ELON")) { 148 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 149 ESCAPE (MEAS_ELON, MAG_NONE, OPIHI_FLT); 150 } 151 if (!strcasecmp (fieldName, "ELAT")) { 152 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 153 ESCAPE (MEAS_ELAT, MAG_NONE, OPIHI_FLT); 154 } 155 if (!strcasecmp (fieldName, "ELON:AVE")) { 156 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 157 ESCAPE (MEAS_ELON_AVE, MAG_NONE, OPIHI_FLT); 158 } 159 if (!strcasecmp (fieldName, "ELAT:AVE")) { 160 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 161 ESCAPE (MEAS_ELAT_AVE, MAG_NONE, OPIHI_FLT); 162 } 163 164 if (!strcasecmp (fieldName, "RA")) ESCAPE (MEAS_RA, MAG_NONE, OPIHI_FLT); 165 if (!strcasecmp (fieldName, "DEC")) ESCAPE (MEAS_DEC, MAG_NONE, OPIHI_FLT); 166 if (!strcasecmp (fieldName, "RA:AVE")) ESCAPE (MEAS_RA_AVE, MAG_NONE, OPIHI_FLT); 167 if (!strcasecmp (fieldName, "DEC:AVE")) ESCAPE (MEAS_DEC_AVE, MAG_NONE, OPIHI_FLT); 168 if (!strcasecmp (fieldName, "RA:ERR")) ESCAPE (MEAS_RA_AVE_ERR, MAG_NONE, OPIHI_FLT); 169 if (!strcasecmp (fieldName, "DEC:ERR")) ESCAPE (MEAS_DEC_AVE_ERR, MAG_NONE, OPIHI_FLT); 170 if (!strcasecmp (fieldName, "uRA")) ESCAPE (MEAS_U_RA, MAG_NONE, OPIHI_FLT); 171 if (!strcasecmp (fieldName, "uDEC")) ESCAPE (MEAS_U_DEC, MAG_NONE, OPIHI_FLT); 172 if (!strcasecmp (fieldName, "duRA")) ESCAPE (MEAS_U_RA_ERR, MAG_NONE, OPIHI_FLT); 173 if (!strcasecmp (fieldName, "duDEC")) ESCAPE (MEAS_U_DEC_ERR, MAG_NONE, OPIHI_FLT); 174 if (!strcasecmp (fieldName, "PAR")) ESCAPE (MEAS_PAR, MAG_NONE, OPIHI_FLT); 175 if (!strcasecmp (fieldName, "dPAR")) ESCAPE (MEAS_PAR_ERR, MAG_NONE, OPIHI_FLT); 176 if (!strcasecmp (fieldName, "dR")) ESCAPE (MEAS_RA_OFFSET, MAG_NONE, OPIHI_FLT); 177 if (!strcasecmp (fieldName, "dD")) ESCAPE (MEAS_DEC_OFFSET, MAG_NONE, OPIHI_FLT); 178 if (!strcasecmp (fieldName, "dR:FIT")) ESCAPE (MEAS_RA_FIT_OFFSET, MAG_NONE, OPIHI_FLT); 179 if (!strcasecmp (fieldName, "dD:FIT")) ESCAPE (MEAS_DEC_FIT_OFFSET, MAG_NONE, OPIHI_FLT); 180 if (!strcasecmp (fieldName, "dR:ERR")) ESCAPE (MEAS_RA_OFFSET_ERR, MAG_NONE, OPIHI_FLT); 181 if (!strcasecmp (fieldName, "dD:ERR")) ESCAPE (MEAS_DEC_OFFSET_ERR, MAG_NONE, OPIHI_FLT); 182 if (!strcasecmp (fieldName, "ChiSqPos")) ESCAPE (MEAS_CHISQ_POS, MAG_NONE, OPIHI_FLT); 183 if (!strcasecmp (fieldName, "ChiSqPM")) ESCAPE (MEAS_CHISQ_PM, MAG_NONE, OPIHI_FLT); 184 if (!strcasecmp (fieldName, "ChiSqPar")) ESCAPE (MEAS_CHISQ_PAR, MAG_NONE, OPIHI_FLT); 185 if (!strcasecmp (fieldName, "Tmean")) ESCAPE (MEAS_TMEAN, MAG_NONE, OPIHI_FLT); 186 if (!strcasecmp (fieldName, "Trange")) ESCAPE (MEAS_TRANGE, MAG_NONE, OPIHI_FLT); 187 if (!strcasecmp (fieldName, "nmeas")) ESCAPE (MEAS_NMEAS, MAG_NONE, OPIHI_INT); 188 if (!strcasecmp (fieldName, "nmiss")) ESCAPE (MEAS_NMISS, MAG_NONE, OPIHI_INT); 189 if (!strcasecmp (fieldName, "npos")) ESCAPE (MEAS_NPOS, MAG_NONE, OPIHI_INT); 190 if (!strcasecmp (fieldName, "OBJFLAGS")) ESCAPE (MEAS_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 191 if (!strcasecmp (fieldName, "OBJ_FLAGS")) ESCAPE (MEAS_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 192 if (!strcasecmp (fieldName, "OBJ_PHOT_FLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, MAG_NONE, OPIHI_INT); 193 if (!strcasecmp (fieldName, "SECFLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, MAG_NONE, OPIHI_INT); 194 if (!strcasecmp (fieldName, "SEC_FLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, MAG_NONE, OPIHI_INT); 195 if (!strcasecmp (fieldName, "SECFILT_FLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, MAG_NONE, OPIHI_INT); 196 if (!strcasecmp (fieldName, "DB_FLAGS")) ESCAPE (MEAS_DB_FLAGS, MAG_NONE, OPIHI_INT); 197 if (!strcasecmp (fieldName, "PHOT_FLAGS")) ESCAPE (MEAS_PHOT_FLAGS, MAG_NONE, OPIHI_INT); 198 if (!strcasecmp (fieldName, "DBFLAGS")) ESCAPE (MEAS_DB_FLAGS, MAG_NONE, OPIHI_INT); 199 if (!strcasecmp (fieldName, "PHOTFLAGS")) ESCAPE (MEAS_PHOT_FLAGS, MAG_NONE, OPIHI_INT); 200 if (!strcasecmp (fieldName, "AIRMASS")) ESCAPE (MEAS_AIRMASS, MAG_NONE, OPIHI_FLT); 201 if (!strcasecmp (fieldName, "MEAN_AIRMASS")) ESCAPE (MEAS_MEAN_AIRMASS, MAG_NONE, OPIHI_FLT); 202 if (!strcasecmp (fieldName, "ALT")) ESCAPE (MEAS_ALT, MAG_NONE, OPIHI_FLT); 203 if (!strcasecmp (fieldName, "AZ")) ESCAPE (MEAS_AZ, MAG_NONE, OPIHI_FLT); 204 if (!strcasecmp (fieldName, "EXPTIME")) ESCAPE (MEAS_EXPTIME, MAG_NONE, OPIHI_FLT); 205 if (!strcasecmp (fieldName, "PHOTCODE")) ESCAPE (MEAS_PHOTCODE, MAG_NONE, OPIHI_INT); 206 if (!strcasecmp (fieldName, "PHOTCODE:KLAM")) ESCAPE (MEAS_PHOTCODE_KLAM, MAG_NONE, OPIHI_FLT); 207 if (!strcasecmp (fieldName, "PHOTCODE:C")) ESCAPE (MEAS_PHOTCODE_C, MAG_NONE, OPIHI_FLT); 208 if (!strcasecmp (fieldName, "PHOTCODE:EQUIV")) ESCAPE (MEAS_PHOTCODE_EQUIV, MAG_NONE, OPIHI_INT); 209 if (!strcasecmp (fieldName, "TIME")) ESCAPE (MEAS_TIME, MAG_NONE, OPIHI_FLT); 210 if (!strcasecmp (fieldName, "FWHM")) ESCAPE (MEAS_FWHM, MAG_NONE, OPIHI_FLT); 211 if (!strcasecmp (fieldName, "FWHM_MAJ")) ESCAPE (MEAS_FWHM_MAJ, MAG_NONE, OPIHI_FLT); 212 if (!strcasecmp (fieldName, "FWHM_MIN")) ESCAPE (MEAS_FWHM_MIN, MAG_NONE, OPIHI_FLT); 213 if (!strcasecmp (fieldName, "THETA")) ESCAPE (MEAS_THETA, MAG_NONE, OPIHI_FLT); 214 if (!strcasecmp (fieldName, "POSANGLE")) ESCAPE (MEAS_POSANGLE, MAG_NONE, OPIHI_FLT); 215 if (!strcasecmp (fieldName, "PLATESCALE")) ESCAPE (MEAS_PLATESCALE, MAG_NONE, OPIHI_FLT); 216 if (!strcasecmp (fieldName, "MXX")) ESCAPE (MEAS_MXX, MAG_NONE, OPIHI_FLT); 217 if (!strcasecmp (fieldName, "MYY")) ESCAPE (MEAS_MYY, MAG_NONE, OPIHI_FLT); 218 if (!strcasecmp (fieldName, "MXY")) ESCAPE (MEAS_MXY, MAG_NONE, OPIHI_FLT); 219 if (!strcasecmp (fieldName, "DOPHOT")) ESCAPE (MEAS_DOPHOT, MAG_NONE, OPIHI_INT); 220 if (!strcasecmp (fieldName, "XCCD")) ESCAPE (MEAS_XCCD, MAG_NONE, OPIHI_FLT); 221 if (!strcasecmp (fieldName, "YCCD")) ESCAPE (MEAS_YCCD, MAG_NONE, OPIHI_FLT); 222 if (!strcasecmp (fieldName, "XCCD:ERR")) ESCAPE (MEAS_XCCD_ERR, MAG_NONE, OPIHI_FLT); 223 if (!strcasecmp (fieldName, "YCCD:ERR")) ESCAPE (MEAS_YCCD_ERR, MAG_NONE, OPIHI_FLT); 224 if (!strcasecmp (fieldName, "XFIX")) ESCAPE (MEAS_XFIX, MAG_NONE, OPIHI_FLT); 225 if (!strcasecmp (fieldName, "YFIX")) ESCAPE (MEAS_YFIX, MAG_NONE, OPIHI_FLT); 226 if (!strcasecmp (fieldName, "POS_SYS_ERR")) ESCAPE (MEAS_POS_SYS_ERR, MAG_NONE, OPIHI_FLT); 227 if (!strcasecmp (fieldName, "XFIELD")) ESCAPE (MEAS_XFIELD, MAG_NONE, OPIHI_FLT); 228 if (!strcasecmp (fieldName, "YFIELD")) ESCAPE (MEAS_YFIELD, MAG_NONE, OPIHI_FLT); 229 if (!strcasecmp (fieldName, "XMOSAIC")) ESCAPE (MEAS_XMOSAIC, MAG_NONE, OPIHI_FLT); 230 if (!strcasecmp (fieldName, "YMOSAIC")) ESCAPE (MEAS_YMOSAIC, MAG_NONE, OPIHI_FLT); 231 if (!strcasecmp (fieldName, "XCHIP")) ESCAPE (MEAS_XCCD, MAG_NONE, OPIHI_FLT); 232 if (!strcasecmp (fieldName, "YCHIP")) ESCAPE (MEAS_YCCD, MAG_NONE, OPIHI_FLT); 233 if (!strcasecmp (fieldName, "XFPA")) ESCAPE (MEAS_XMOSAIC, MAG_NONE, OPIHI_FLT); 234 if (!strcasecmp (fieldName, "YFPA")) ESCAPE (MEAS_YMOSAIC, MAG_NONE, OPIHI_FLT); 235 if (!strcasecmp (fieldName, "DETID")) ESCAPE (MEAS_DET_ID, MAG_NONE, OPIHI_INT); 236 if (!strcasecmp (fieldName, "OBJID")) ESCAPE (MEAS_OBJ_ID, MAG_NONE, OPIHI_INT); 237 if (!strcasecmp (fieldName, "CATID")) ESCAPE (MEAS_CAT_ID, MAG_NONE, OPIHI_INT); 238 if (!strcasecmp (fieldName, "IMAGEID")) ESCAPE (MEAS_IMAGE_ID, MAG_NONE, OPIHI_INT); 239 if (!strcasecmp (fieldName, "EXTERNID")) ESCAPE (MEAS_EXTERN_ID, MAG_NONE, OPIHI_INT); 240 if (!strcasecmp (fieldName, "EXPNAME")) ESCAPE (MEAS_EXPNAME_AS_INT, MAG_NONE, OPIHI_INT); 241 if (!strcasecmp (fieldName, "PSF_QF")) ESCAPE (MEAS_PSF_QF, MAG_NONE, OPIHI_FLT); 242 if (!strcasecmp (fieldName, "PSF_QF_PERFECT")) ESCAPE (MEAS_PSF_QF_PERFECT, MAG_NONE, OPIHI_FLT); 243 if (!strcasecmp (fieldName, "PSF_CHISQ")) ESCAPE (MEAS_PSF_CHISQ, MAG_NONE, OPIHI_FLT); 244 if (!strcasecmp (fieldName, "PSF_NDOF")) ESCAPE (MEAS_PSF_NDOF, MAG_NONE, OPIHI_INT); 245 if (!strcasecmp (fieldName, "PSF_NPIX")) ESCAPE (MEAS_PSF_NPIX, MAG_NONE, OPIHI_INT); 246 if (!strcasecmp (fieldName, "CR_NSIGMA")) ESCAPE (MEAS_CR_NSIGMA, MAG_NONE, OPIHI_FLT); 247 if (!strcasecmp (fieldName, "EXT_NSIGMA")) ESCAPE (MEAS_EXT_NSIGMA, MAG_NONE, OPIHI_FLT); 248 if (!strcasecmp (fieldName, "SKY")) ESCAPE (MEAS_SKY, MAG_NONE, OPIHI_FLT); 249 if (!strcasecmp (fieldName, "SKY_ERR")) ESCAPE (MEAS_dSKY, MAG_NONE, OPIHI_FLT); 250 if (!strcasecmp (fieldName, "MCAL_OFFSET")) ESCAPE (MEAS_MCAL_OFFSET, MAG_NONE, OPIHI_FLT); 251 if (!strcasecmp (fieldName, "FLAT")) ESCAPE (MEAS_FLAT, MAG_NONE, OPIHI_FLT); 252 if (!strcasecmp (fieldName, "CENTER_OFFSET")) ESCAPE (MEAS_CENTER_OFFSET, MAG_NONE, OPIHI_FLT); 253 if (!strcasecmp (fieldName, "FLUX")) ESCAPE (MEAS_FLUX_PSF, MAG_NONE, OPIHI_FLT); 254 if (!strcasecmp (fieldName, "FLUX_ERR")) ESCAPE (MEAS_FLUX_PSF_ERR, MAG_NONE, OPIHI_FLT); 255 if (!strcasecmp (fieldName, "FLUX_PSF")) ESCAPE (MEAS_FLUX_PSF, MAG_NONE, OPIHI_FLT); 256 if (!strcasecmp (fieldName, "FLUX_PSF_ERR")) ESCAPE (MEAS_FLUX_PSF_ERR, MAG_NONE, OPIHI_FLT); 257 if (!strcasecmp (fieldName, "FLUX_KRON")) ESCAPE (MEAS_FLUX_KRON, MAG_NONE, OPIHI_FLT); 258 if (!strcasecmp (fieldName, "FLUX_KRON_ERR")) ESCAPE (MEAS_FLUX_KRON_ERR, MAG_NONE, OPIHI_FLT); 259 260 // for words that don't parse, try a photcode 261 262 // check for code:mode in photcode name 263 code = ParsePhotcodeField (fieldName, &mode, MAG_AVE); 264 if (code == NULL) { 265 gprint (GP_ERR, "unknown field '%s' for measurement table in DVO database\n", fieldName); 266 return (FALSE); 267 } 268 269 field->ID = MEAS_MAG; 270 field->magMode = mode; 271 switch (mode) { 272 case MAG_STACK_DET_ID: 273 case MAG_NCODE: 274 case MAG_NPHOT: 275 case MAG_PHOT_FLAGS: 243 244 dvoMagOptionType option = GetMagOption (word); 245 if (option != MAG_OPTION_NONE) { 246 // some combinations are OK: mag + err -> err 247 if ((myOption == MAG_OPTION_MAG) && (option == MAG_OPTION_ERR)) { 248 myOption = option; 249 ptr = skipword (ptr); 250 continue; 251 } 252 // some combinations are OK: err + mag -> err 253 if ((myOption == MAG_OPTION_ERR) && (option == MAG_OPTION_MAG)) { 254 ptr = skipword (ptr); 255 continue; 256 } 257 // some combinations are OK: flux + err -> FLUX_ERR 258 if ((myOption == MAG_OPTION_FLUX) && (option == MAG_OPTION_ERR)) { 259 myOption = MAG_OPTION_FLUX_ERR; 260 ptr = skipword (ptr); 261 continue; 262 } 263 // some combinations are OK: err + flux -> FLUX_ERR 264 if ((myOption == MAG_OPTION_ERR) && (option == MAG_OPTION_FLUX)) { 265 myOption = MAG_OPTION_FLUX_ERR; 266 ptr = skipword (ptr); 267 continue; 268 } 269 // some combinations are OK: flux + fluxerr -> FLUX_ERR 270 if ((myOption == MAG_OPTION_FLUX) && (option == MAG_OPTION_FLUX_ERR)) { 271 myOption = MAG_OPTION_FLUX_ERR; 272 ptr = skipword (ptr); 273 continue; 274 } 275 // some combinations are OK: fluxerr + flux -> FLUX_ERR 276 if ((myOption == MAG_OPTION_FLUX_ERR) && (option == MAG_OPTION_FLUX)) { 277 myOption = MAG_OPTION_FLUX_ERR; 278 ptr = skipword (ptr); 279 continue; 280 } 281 if (myOption != MAG_OPTION_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 282 myOption = option; 283 ptr = skipword (ptr); 284 continue; 285 } 286 287 fprintf (stderr, "ERROR: unknown mag/photocode argument %s\n", word); 288 free (word); 289 } 290 291 // if nothing is provided, use the defaults 292 field->magSource = (mySource == MAG_SRC_NONE) ? field->magSource : mySource; 293 field->magLevel = (myLevel == MAG_LEVEL_NONE) ? field->magLevel : myLevel; 294 field->magClass = (myClass == MAG_CLASS_NONE) ? field->magClass : myClass; 295 field->magOption = (myOption == MAG_OPTION_NONE) ? field->magOption : myOption; 296 297 switch (field->magOption) { 298 case MAG_OPTION_STACK_DET_ID: 299 case MAG_OPTION_NCODE: 300 case MAG_OPTION_NPHOT: 301 case MAG_OPTION_FLAGS: 276 302 field->type = OPIHI_INT; 277 303 break; … … 281 307 } 282 308 field->photcode = code; 309 return TRUE; 310 } 311 312 // field needs to be initialized with dbInitField() 313 # define ESCAPE(F,T) { \ 314 field->ID = (F); \ 315 field->type = (T); \ 316 return (TRUE); } 317 318 int ParseMeasureField (dbField *field, char *fieldName) { 319 320 field->table = DVO_TABLE_MEASURE; 321 field->name = strcreate (fieldName); 322 323 if (!strcasecmp (fieldName, "GLON")) { 324 dbExtractMeasuresInitTransform (COORD_GALACTIC); 325 ESCAPE (MEAS_GLON, OPIHI_FLT); 326 } 327 if (!strcasecmp (fieldName, "GLAT")) { 328 dbExtractMeasuresInitTransform (COORD_GALACTIC); 329 ESCAPE (MEAS_GLAT, OPIHI_FLT); 330 } 331 if (!strcasecmp (fieldName, "GLON:AVE")) { 332 dbExtractMeasuresInitTransform (COORD_GALACTIC); 333 ESCAPE (MEAS_GLON_AVE, OPIHI_FLT); 334 } 335 if (!strcasecmp (fieldName, "GLAT:AVE")) { 336 dbExtractMeasuresInitTransform (COORD_GALACTIC); 337 ESCAPE (MEAS_GLAT_AVE, OPIHI_FLT); 338 } 339 340 if (!strcasecmp (fieldName, "ELON")) { 341 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 342 ESCAPE (MEAS_ELON, OPIHI_FLT); 343 } 344 if (!strcasecmp (fieldName, "ELAT")) { 345 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 346 ESCAPE (MEAS_ELAT, OPIHI_FLT); 347 } 348 if (!strcasecmp (fieldName, "ELON:AVE")) { 349 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 350 ESCAPE (MEAS_ELON_AVE, OPIHI_FLT); 351 } 352 if (!strcasecmp (fieldName, "ELAT:AVE")) { 353 dbExtractMeasuresInitTransform (COORD_ECLIPTIC); 354 ESCAPE (MEAS_ELAT_AVE, OPIHI_FLT); 355 } 356 357 if (!strcasecmp (fieldName, "RA")) ESCAPE (MEAS_RA, OPIHI_FLT); 358 if (!strcasecmp (fieldName, "DEC")) ESCAPE (MEAS_DEC, OPIHI_FLT); 359 if (!strcasecmp (fieldName, "RA:AVE")) ESCAPE (MEAS_RA_AVE, OPIHI_FLT); 360 if (!strcasecmp (fieldName, "DEC:AVE")) ESCAPE (MEAS_DEC_AVE, OPIHI_FLT); 361 if (!strcasecmp (fieldName, "RA:ERR")) ESCAPE (MEAS_RA_AVE_ERR, OPIHI_FLT); 362 if (!strcasecmp (fieldName, "DEC:ERR")) ESCAPE (MEAS_DEC_AVE_ERR, OPIHI_FLT); 363 if (!strcasecmp (fieldName, "uRA")) ESCAPE (MEAS_U_RA, OPIHI_FLT); 364 if (!strcasecmp (fieldName, "uDEC")) ESCAPE (MEAS_U_DEC, OPIHI_FLT); 365 if (!strcasecmp (fieldName, "duRA")) ESCAPE (MEAS_U_RA_ERR, OPIHI_FLT); 366 if (!strcasecmp (fieldName, "duDEC")) ESCAPE (MEAS_U_DEC_ERR, OPIHI_FLT); 367 if (!strcasecmp (fieldName, "PAR")) ESCAPE (MEAS_PAR, OPIHI_FLT); 368 if (!strcasecmp (fieldName, "dPAR")) ESCAPE (MEAS_PAR_ERR, OPIHI_FLT); 369 if (!strcasecmp (fieldName, "dR")) ESCAPE (MEAS_RA_OFFSET, OPIHI_FLT); 370 if (!strcasecmp (fieldName, "dD")) ESCAPE (MEAS_DEC_OFFSET, OPIHI_FLT); 371 if (!strcasecmp (fieldName, "dR:FIT")) ESCAPE (MEAS_RA_FIT_OFFSET, OPIHI_FLT); 372 if (!strcasecmp (fieldName, "dD:FIT")) ESCAPE (MEAS_DEC_FIT_OFFSET, OPIHI_FLT); 373 if (!strcasecmp (fieldName, "dR:ERR")) ESCAPE (MEAS_RA_OFFSET_ERR, OPIHI_FLT); 374 if (!strcasecmp (fieldName, "dD:ERR")) ESCAPE (MEAS_DEC_OFFSET_ERR, OPIHI_FLT); 375 if (!strcasecmp (fieldName, "ChiSqPos")) ESCAPE (MEAS_CHISQ_POS, OPIHI_FLT); 376 if (!strcasecmp (fieldName, "ChiSqPM")) ESCAPE (MEAS_CHISQ_PM, OPIHI_FLT); 377 if (!strcasecmp (fieldName, "ChiSqPar")) ESCAPE (MEAS_CHISQ_PAR, OPIHI_FLT); 378 if (!strcasecmp (fieldName, "Tmean")) ESCAPE (MEAS_TMEAN, OPIHI_FLT); 379 if (!strcasecmp (fieldName, "Trange")) ESCAPE (MEAS_TRANGE, OPIHI_FLT); 380 if (!strcasecmp (fieldName, "nmeas")) ESCAPE (MEAS_NMEAS, OPIHI_INT); 381 if (!strcasecmp (fieldName, "nmiss")) ESCAPE (MEAS_NMISS, OPIHI_INT); 382 if (!strcasecmp (fieldName, "npos")) ESCAPE (MEAS_NPOS, OPIHI_INT); 383 if (!strcasecmp (fieldName, "OBJFLAGS")) ESCAPE (MEAS_OBJ_FLAGS, OPIHI_INT); 384 if (!strcasecmp (fieldName, "OBJ_FLAGS")) ESCAPE (MEAS_OBJ_FLAGS, OPIHI_INT); 385 if (!strcasecmp (fieldName, "OBJ_PHOT_FLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, OPIHI_INT); 386 if (!strcasecmp (fieldName, "SECFLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, OPIHI_INT); 387 if (!strcasecmp (fieldName, "SEC_FLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, OPIHI_INT); 388 if (!strcasecmp (fieldName, "SECFILT_FLAGS")) ESCAPE (MEAS_SECFILT_FLAGS, OPIHI_INT); 389 if (!strcasecmp (fieldName, "DB_FLAGS")) ESCAPE (MEAS_DB_FLAGS, OPIHI_INT); 390 if (!strcasecmp (fieldName, "PHOT_FLAGS")) ESCAPE (MEAS_PHOT_FLAGS, OPIHI_INT); 391 if (!strcasecmp (fieldName, "DBFLAGS")) ESCAPE (MEAS_DB_FLAGS, OPIHI_INT); 392 if (!strcasecmp (fieldName, "PHOTFLAGS")) ESCAPE (MEAS_PHOT_FLAGS, OPIHI_INT); 393 if (!strcasecmp (fieldName, "AIRMASS")) ESCAPE (MEAS_AIRMASS, OPIHI_FLT); 394 if (!strcasecmp (fieldName, "MEAN_AIRMASS")) ESCAPE (MEAS_MEAN_AIRMASS, OPIHI_FLT); 395 if (!strcasecmp (fieldName, "ALT")) ESCAPE (MEAS_ALT, OPIHI_FLT); 396 if (!strcasecmp (fieldName, "AZ")) ESCAPE (MEAS_AZ, OPIHI_FLT); 397 if (!strcasecmp (fieldName, "EXPTIME")) ESCAPE (MEAS_EXPTIME, OPIHI_FLT); 398 if (!strcasecmp (fieldName, "PHOTCODE")) ESCAPE (MEAS_PHOTCODE, OPIHI_INT); 399 if (!strcasecmp (fieldName, "PHOTCODE:KLAM")) ESCAPE (MEAS_PHOTCODE_KLAM, OPIHI_FLT); 400 if (!strcasecmp (fieldName, "PHOTCODE:C")) ESCAPE (MEAS_PHOTCODE_C, OPIHI_FLT); 401 if (!strcasecmp (fieldName, "PHOTCODE:EQUIV")) ESCAPE (MEAS_PHOTCODE_EQUIV, OPIHI_INT); 402 if (!strcasecmp (fieldName, "TIME")) ESCAPE (MEAS_TIME, OPIHI_FLT); 403 if (!strcasecmp (fieldName, "FWHM")) ESCAPE (MEAS_FWHM, OPIHI_FLT); 404 if (!strcasecmp (fieldName, "FWHM_MAJ")) ESCAPE (MEAS_FWHM_MAJ, OPIHI_FLT); 405 if (!strcasecmp (fieldName, "FWHM_MIN")) ESCAPE (MEAS_FWHM_MIN, OPIHI_FLT); 406 if (!strcasecmp (fieldName, "THETA")) ESCAPE (MEAS_THETA, OPIHI_FLT); 407 if (!strcasecmp (fieldName, "POSANGLE")) ESCAPE (MEAS_POSANGLE, OPIHI_FLT); 408 if (!strcasecmp (fieldName, "PLATESCALE")) ESCAPE (MEAS_PLATESCALE, OPIHI_FLT); 409 if (!strcasecmp (fieldName, "MXX")) ESCAPE (MEAS_MXX, OPIHI_FLT); 410 if (!strcasecmp (fieldName, "MYY")) ESCAPE (MEAS_MYY, OPIHI_FLT); 411 if (!strcasecmp (fieldName, "MXY")) ESCAPE (MEAS_MXY, OPIHI_FLT); 412 if (!strcasecmp (fieldName, "DOPHOT")) ESCAPE (MEAS_DOPHOT, OPIHI_INT); 413 if (!strcasecmp (fieldName, "XCCD")) ESCAPE (MEAS_XCCD, OPIHI_FLT); 414 if (!strcasecmp (fieldName, "YCCD")) ESCAPE (MEAS_YCCD, OPIHI_FLT); 415 if (!strcasecmp (fieldName, "XCCD:ERR")) ESCAPE (MEAS_XCCD_ERR, OPIHI_FLT); 416 if (!strcasecmp (fieldName, "YCCD:ERR")) ESCAPE (MEAS_YCCD_ERR, OPIHI_FLT); 417 if (!strcasecmp (fieldName, "XFIX")) ESCAPE (MEAS_XFIX, OPIHI_FLT); 418 if (!strcasecmp (fieldName, "YFIX")) ESCAPE (MEAS_YFIX, OPIHI_FLT); 419 if (!strcasecmp (fieldName, "POS_SYS_ERR")) ESCAPE (MEAS_POS_SYS_ERR, OPIHI_FLT); 420 if (!strcasecmp (fieldName, "XFIELD")) ESCAPE (MEAS_XFIELD, OPIHI_FLT); 421 if (!strcasecmp (fieldName, "YFIELD")) ESCAPE (MEAS_YFIELD, OPIHI_FLT); 422 if (!strcasecmp (fieldName, "XMOSAIC")) ESCAPE (MEAS_XMOSAIC, OPIHI_FLT); 423 if (!strcasecmp (fieldName, "YMOSAIC")) ESCAPE (MEAS_YMOSAIC, OPIHI_FLT); 424 if (!strcasecmp (fieldName, "XCHIP")) ESCAPE (MEAS_XCCD, OPIHI_FLT); 425 if (!strcasecmp (fieldName, "YCHIP")) ESCAPE (MEAS_YCCD, OPIHI_FLT); 426 if (!strcasecmp (fieldName, "XFPA")) ESCAPE (MEAS_XMOSAIC, OPIHI_FLT); 427 if (!strcasecmp (fieldName, "YFPA")) ESCAPE (MEAS_YMOSAIC, OPIHI_FLT); 428 if (!strcasecmp (fieldName, "DETID")) ESCAPE (MEAS_DET_ID, OPIHI_INT); 429 if (!strcasecmp (fieldName, "OBJID")) ESCAPE (MEAS_OBJ_ID, OPIHI_INT); 430 if (!strcasecmp (fieldName, "CATID")) ESCAPE (MEAS_CAT_ID, OPIHI_INT); 431 if (!strcasecmp (fieldName, "IMAGEID")) ESCAPE (MEAS_IMAGE_ID, OPIHI_INT); 432 if (!strcasecmp (fieldName, "EXTERNID")) ESCAPE (MEAS_EXTERN_ID, OPIHI_INT); 433 if (!strcasecmp (fieldName, "EXPNAME")) ESCAPE (MEAS_EXPNAME_AS_INT, OPIHI_INT); 434 if (!strcasecmp (fieldName, "PSF_QF")) ESCAPE (MEAS_PSF_QF, OPIHI_FLT); 435 if (!strcasecmp (fieldName, "PSF_QF_PERFECT")) ESCAPE (MEAS_PSF_QF_PERFECT, OPIHI_FLT); 436 if (!strcasecmp (fieldName, "PSF_CHISQ")) ESCAPE (MEAS_PSF_CHISQ, OPIHI_FLT); 437 if (!strcasecmp (fieldName, "PSF_NDOF")) ESCAPE (MEAS_PSF_NDOF, OPIHI_INT); 438 if (!strcasecmp (fieldName, "PSF_NPIX")) ESCAPE (MEAS_PSF_NPIX, OPIHI_INT); 439 if (!strcasecmp (fieldName, "CR_NSIGMA")) ESCAPE (MEAS_CR_NSIGMA, OPIHI_FLT); 440 if (!strcasecmp (fieldName, "EXT_NSIGMA")) ESCAPE (MEAS_EXT_NSIGMA, OPIHI_FLT); 441 if (!strcasecmp (fieldName, "SKY")) ESCAPE (MEAS_SKY, OPIHI_FLT); 442 if (!strcasecmp (fieldName, "SKY_ERR")) ESCAPE (MEAS_dSKY, OPIHI_FLT); 443 if (!strcasecmp (fieldName, "MCAL_OFFSET")) ESCAPE (MEAS_MCAL_OFFSET, OPIHI_FLT); 444 if (!strcasecmp (fieldName, "FLAT")) ESCAPE (MEAS_FLAT, OPIHI_FLT); 445 if (!strcasecmp (fieldName, "CENTER_OFFSET")) ESCAPE (MEAS_CENTER_OFFSET, OPIHI_FLT); 446 // if (!strcasecmp (fieldName, "FLUX")) ESCAPE (MEAS_FLUX_PSF, OPIHI_FLT); 447 // if (!strcasecmp (fieldName, "FLUX_ERR")) ESCAPE (MEAS_FLUX_PSF_ERR, OPIHI_FLT); 448 // if (!strcasecmp (fieldName, "FLUX_PSF")) ESCAPE (MEAS_FLUX_PSF, OPIHI_FLT); 449 // if (!strcasecmp (fieldName, "FLUX_PSF_ERR")) ESCAPE (MEAS_FLUX_PSF_ERR, OPIHI_FLT); 450 // if (!strcasecmp (fieldName, "FLUX_KRON")) ESCAPE (MEAS_FLUX_KRON, OPIHI_FLT); 451 // if (!strcasecmp (fieldName, "FLUX_KRON_ERR")) ESCAPE (MEAS_FLUX_KRON_ERR, OPIHI_FLT); 452 if (!strcasecmp (fieldName, "REF_COLOR")) ESCAPE (MEAS_REF_COLOR, OPIHI_FLT); 453 454 // for words that don't parse, try a photcode 455 456 // check for code:mode in photcode name 457 if (!ParsePhotcodeField (field, fieldName, MEAS_PHOT)) { 458 gprint (GP_ERR, "unknown field '%s' for measurement table in DVO database\n", fieldName); 459 return (FALSE); 460 } 461 283 462 return (TRUE); 284 463 } 285 464 286 465 int ParseAverageField (dbField *field, char *fieldName) { 287 288 int mode;289 PhotCode *code;290 466 291 467 field->table = DVO_TABLE_AVERAGE; … … 296 472 if (!strcasecmp (fieldName, "GLON")) { 297 473 dbExtractAveragesInitTransform (COORD_GALACTIC); 298 ESCAPE (AVE_GLON, MAG_NONE,OPIHI_FLT);474 ESCAPE (AVE_GLON, OPIHI_FLT); 299 475 } 300 476 if (!strcasecmp (fieldName, "GLAT")) { 301 477 dbExtractAveragesInitTransform (COORD_GALACTIC); 302 ESCAPE (AVE_GLAT, MAG_NONE,OPIHI_FLT);478 ESCAPE (AVE_GLAT, OPIHI_FLT); 303 479 } 304 480 … … 307 483 if (!strcasecmp (fieldName, "ELON")) { 308 484 dbExtractAveragesInitTransform (COORD_ECLIPTIC); 309 ESCAPE (AVE_ELON, MAG_NONE,OPIHI_FLT);485 ESCAPE (AVE_ELON, OPIHI_FLT); 310 486 } 311 487 if (!strcasecmp (fieldName, "ELAT")) { 312 488 dbExtractAveragesInitTransform (COORD_ECLIPTIC); 313 ESCAPE (AVE_ELAT, MAG_NONE, OPIHI_FLT); 314 } 315 316 if (!strcasecmp (fieldName, "RA")) ESCAPE (AVE_RA, MAG_NONE, OPIHI_FLT); 317 if (!strcasecmp (fieldName, "DEC")) ESCAPE (AVE_DEC, MAG_NONE, OPIHI_FLT); 318 if (!strcasecmp (fieldName, "GLON")) ESCAPE (AVE_GLON, MAG_NONE, OPIHI_FLT); 319 if (!strcasecmp (fieldName, "GLAT")) ESCAPE (AVE_GLAT, MAG_NONE, OPIHI_FLT); 320 if (!strcasecmp (fieldName, "ELON")) ESCAPE (AVE_ELON, MAG_NONE, OPIHI_FLT); 321 if (!strcasecmp (fieldName, "ELAT")) ESCAPE (AVE_ELAT, MAG_NONE, OPIHI_FLT); 322 if (!strcasecmp (fieldName, "dRA")) ESCAPE (AVE_RA_ERR, MAG_NONE, OPIHI_FLT); 323 if (!strcasecmp (fieldName, "dDEC")) ESCAPE (AVE_DEC_ERR, MAG_NONE, OPIHI_FLT); 324 if (!strcasecmp (fieldName, "uRA")) ESCAPE (AVE_U_RA, MAG_NONE, OPIHI_FLT); 325 if (!strcasecmp (fieldName, "uDEC")) ESCAPE (AVE_U_DEC, MAG_NONE, OPIHI_FLT); 326 if (!strcasecmp (fieldName, "duRA")) ESCAPE (AVE_U_RA_ERR, MAG_NONE, OPIHI_FLT); 327 if (!strcasecmp (fieldName, "duDEC")) ESCAPE (AVE_U_DEC_ERR, MAG_NONE, OPIHI_FLT); 328 if (!strcasecmp (fieldName, "PAR")) ESCAPE (AVE_PAR, MAG_NONE, OPIHI_FLT); 329 if (!strcasecmp (fieldName, "dPAR")) ESCAPE (AVE_PAR_ERR, MAG_NONE, OPIHI_FLT); 330 if (!strcasecmp (fieldName, "ChiSqPos")) ESCAPE (AVE_CHISQ_POS, MAG_NONE, OPIHI_FLT); 331 if (!strcasecmp (fieldName, "ChiSqPM")) ESCAPE (AVE_CHISQ_PM, MAG_NONE, OPIHI_FLT); 332 if (!strcasecmp (fieldName, "ChiSqPar")) ESCAPE (AVE_CHISQ_PAR, MAG_NONE, OPIHI_FLT); 333 if (!strcasecmp (fieldName, "Tmean")) ESCAPE (AVE_TMEAN, MAG_NONE, OPIHI_FLT); 334 if (!strcasecmp (fieldName, "Trange")) ESCAPE (AVE_TRANGE, MAG_NONE, OPIHI_FLT); 335 if (!strcasecmp (fieldName, "NMEAS")) ESCAPE (AVE_NMEAS, MAG_NONE, OPIHI_INT); 336 if (!strcasecmp (fieldName, "NMISS")) ESCAPE (AVE_NMISS, MAG_NONE, OPIHI_INT); 337 if (!strcasecmp (fieldName, "NPOS")) ESCAPE (AVE_NPOS, MAG_NONE, OPIHI_INT); 338 if (!strcasecmp (fieldName, "NASTROM")) ESCAPE (AVE_NPOS, MAG_NONE, OPIHI_INT); 339 if (!strcasecmp (fieldName, "FLAGS")) ESCAPE (AVE_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 340 if (!strcasecmp (fieldName, "OBJ_FLAGS")) ESCAPE (AVE_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 341 if (!strcasecmp (fieldName, "OBJFLAGS")) ESCAPE (AVE_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 342 if (!strcasecmp (fieldName, "OBJID")) ESCAPE (AVE_OBJID, MAG_NONE, OPIHI_INT); 343 if (!strcasecmp (fieldName, "CATID")) ESCAPE (AVE_CATID, MAG_NONE, OPIHI_INT); 344 if (!strcasecmp (fieldName, "EXTID_HI")) ESCAPE (AVE_EXTID_HI, MAG_NONE, OPIHI_INT); 345 if (!strcasecmp (fieldName, "EXTID_LO")) ESCAPE (AVE_EXTID_LO, MAG_NONE, OPIHI_INT); 489 ESCAPE (AVE_ELAT, OPIHI_FLT); 490 } 491 492 if (!strcasecmp (fieldName, "RA")) ESCAPE (AVE_RA, OPIHI_FLT); 493 if (!strcasecmp (fieldName, "DEC")) ESCAPE (AVE_DEC, OPIHI_FLT); 494 if (!strcasecmp (fieldName, "GLON")) ESCAPE (AVE_GLON, OPIHI_FLT); 495 if (!strcasecmp (fieldName, "GLAT")) ESCAPE (AVE_GLAT, OPIHI_FLT); 496 if (!strcasecmp (fieldName, "ELON")) ESCAPE (AVE_ELON, OPIHI_FLT); 497 if (!strcasecmp (fieldName, "ELAT")) ESCAPE (AVE_ELAT, OPIHI_FLT); 498 if (!strcasecmp (fieldName, "dRA")) ESCAPE (AVE_RA_ERR, OPIHI_FLT); 499 if (!strcasecmp (fieldName, "dDEC")) ESCAPE (AVE_DEC_ERR, OPIHI_FLT); 500 if (!strcasecmp (fieldName, "uRA")) ESCAPE (AVE_U_RA, OPIHI_FLT); 501 if (!strcasecmp (fieldName, "uDEC")) ESCAPE (AVE_U_DEC, OPIHI_FLT); 502 if (!strcasecmp (fieldName, "duRA")) ESCAPE (AVE_U_RA_ERR, OPIHI_FLT); 503 if (!strcasecmp (fieldName, "duDEC")) ESCAPE (AVE_U_DEC_ERR, OPIHI_FLT); 504 if (!strcasecmp (fieldName, "PAR")) ESCAPE (AVE_PAR, OPIHI_FLT); 505 if (!strcasecmp (fieldName, "dPAR")) ESCAPE (AVE_PAR_ERR, OPIHI_FLT); 506 if (!strcasecmp (fieldName, "ChiSqPos")) ESCAPE (AVE_CHISQ_POS, OPIHI_FLT); 507 if (!strcasecmp (fieldName, "ChiSqPM")) ESCAPE (AVE_CHISQ_PM, OPIHI_FLT); 508 if (!strcasecmp (fieldName, "ChiSqPar")) ESCAPE (AVE_CHISQ_PAR, OPIHI_FLT); 509 if (!strcasecmp (fieldName, "Tmean")) ESCAPE (AVE_TMEAN, OPIHI_FLT); 510 if (!strcasecmp (fieldName, "Trange")) ESCAPE (AVE_TRANGE, OPIHI_FLT); 511 if (!strcasecmp (fieldName, "psfqf")) ESCAPE (AVE_PSF_QF, OPIHI_FLT); 512 if (!strcasecmp (fieldName, "psfqfperf")) ESCAPE (AVE_PSF_QF_PERF, OPIHI_FLT); 513 if (!strcasecmp (fieldName, "psf_qf")) ESCAPE (AVE_PSF_QF, OPIHI_FLT); 514 if (!strcasecmp (fieldName, "psf_qf_perf")) ESCAPE (AVE_PSF_QF_PERF, OPIHI_FLT); 515 if (!strcasecmp (fieldName, "stargal")) ESCAPE (AVE_STARGAL, OPIHI_FLT); 516 if (!strcasecmp (fieldName, "NMEAS")) ESCAPE (AVE_NMEAS, OPIHI_INT); 517 if (!strcasecmp (fieldName, "NMISS")) ESCAPE (AVE_NMISS, OPIHI_INT); 518 if (!strcasecmp (fieldName, "NPOS")) ESCAPE (AVE_NPOS, OPIHI_INT); 519 if (!strcasecmp (fieldName, "NASTROM")) ESCAPE (AVE_NPOS, OPIHI_INT); 520 if (!strcasecmp (fieldName, "FLAGS")) ESCAPE (AVE_OBJ_FLAGS, OPIHI_INT); 521 if (!strcasecmp (fieldName, "OBJ_FLAGS")) ESCAPE (AVE_OBJ_FLAGS, OPIHI_INT); 522 if (!strcasecmp (fieldName, "OBJFLAGS")) ESCAPE (AVE_OBJ_FLAGS, OPIHI_INT); 523 if (!strcasecmp (fieldName, "OBJID")) ESCAPE (AVE_OBJID, OPIHI_INT); 524 if (!strcasecmp (fieldName, "CATID")) ESCAPE (AVE_CATID, OPIHI_INT); 525 if (!strcasecmp (fieldName, "EXTID_HI")) ESCAPE (AVE_EXTID_HI, OPIHI_INT); 526 if (!strcasecmp (fieldName, "EXTID_LO")) ESCAPE (AVE_EXTID_LO, OPIHI_INT); 527 if (!strcasecmp (fieldName, "REF_COLOR")) ESCAPE (AVE_REF_COLOR, OPIHI_FLT); 346 528 347 529 // check for code:mode in photcode name 348 code = ParsePhotcodeField (fieldName, &mode, MAG_AVE); 349 if (code == NULL) { 530 if (!ParsePhotcodeField (field, fieldName, AVE_PHOT)) { 350 531 gprint (GP_ERR, "unknown field '%s' for average table in DVO database\n", fieldName); 351 532 return (FALSE); 352 533 } 353 534 354 if ( code[0].type == PHOT_MAG) {535 if (field->photcode->type == PHOT_MAG) { 355 536 gprint (GP_ERR, "'mag' is ambiguous for avextract\n"); 356 free (code);357 537 return (FALSE); 358 538 } 359 539 360 field->ID = AVE_MAG;361 field->magMode = mode;362 switch (mode) {363 case MAG_STACK_DET_ID:364 case MAG_NCODE:365 case MAG_NPHOT:366 case MAG_PHOT_FLAGS:367 field->type = OPIHI_INT;368 break;369 default:370 field->type = OPIHI_FLT;371 break;372 }373 field->photcode = code;374 540 return (TRUE); 375 541 } … … 385 551 if (!strcasecmp (fieldName, "GLON")) { 386 552 dbExtractImagesInitTransform (COORD_GALACTIC); 387 ESCAPE (IMAGE_GLON, MAG_NONE,OPIHI_FLT);553 ESCAPE (IMAGE_GLON, OPIHI_FLT); 388 554 } 389 555 if (!strcasecmp (fieldName, "GLAT")) { 390 556 dbExtractImagesInitTransform (COORD_GALACTIC); 391 ESCAPE (IMAGE_GLAT, MAG_NONE,OPIHI_FLT);557 ESCAPE (IMAGE_GLAT, OPIHI_FLT); 392 558 } 393 559 … … 396 562 if (!strcasecmp (fieldName, "ELON")) { 397 563 dbExtractImagesInitTransform (COORD_ECLIPTIC); 398 ESCAPE (IMAGE_ELON, MAG_NONE,OPIHI_FLT);564 ESCAPE (IMAGE_ELON, OPIHI_FLT); 399 565 } 400 566 if (!strcasecmp (fieldName, "ELAT")) { 401 567 dbExtractImagesInitTransform (COORD_ECLIPTIC); 402 ESCAPE (IMAGE_ELAT, MAG_NONE, OPIHI_FLT); 403 } 404 405 if (!strcasecmp (fieldName, "RA" )) ESCAPE (IMAGE_RA, MAG_NONE, OPIHI_FLT); 406 if (!strcasecmp (fieldName, "DEC" )) ESCAPE (IMAGE_DEC, MAG_NONE, OPIHI_FLT); 407 if (!strcasecmp (fieldName, "GLON" )) ESCAPE (IMAGE_GLON, MAG_NONE, OPIHI_FLT); 408 if (!strcasecmp (fieldName, "GLAT" )) ESCAPE (IMAGE_GLAT, MAG_NONE, OPIHI_FLT); 409 if (!strcasecmp (fieldName, "ELON" )) ESCAPE (IMAGE_ELON, MAG_NONE, OPIHI_FLT); 410 if (!strcasecmp (fieldName, "ELAT" )) ESCAPE (IMAGE_ELAT, MAG_NONE, OPIHI_FLT); 411 412 if (!strcasecmp (fieldName, "theta" )) ESCAPE (IMAGE_THETA, MAG_NONE, OPIHI_FLT); 413 if (!strcasecmp (fieldName, "skew" )) ESCAPE (IMAGE_SKEW, MAG_NONE, OPIHI_FLT); 414 if (!strcasecmp (fieldName, "scale" )) ESCAPE (IMAGE_SCALE, MAG_NONE, OPIHI_FLT); 415 if (!strcasecmp (fieldName, "dscale" )) ESCAPE (IMAGE_DSCALE, MAG_NONE, OPIHI_FLT); 416 417 if (!strcasecmp (fieldName, "time" )) ESCAPE (IMAGE_TIME, MAG_NONE, OPIHI_FLT); 418 if (!strcasecmp (fieldName, "nstar" )) ESCAPE (IMAGE_NSTAR, MAG_NONE, OPIHI_INT); 419 if (!strcasecmp (fieldName, "airmass" )) ESCAPE (IMAGE_AIRMASS, MAG_NONE, OPIHI_FLT); 420 if (!strcasecmp (fieldName, "NX" )) ESCAPE (IMAGE_NX_PIX, MAG_NONE, OPIHI_INT); 421 if (!strcasecmp (fieldName, "NY" )) ESCAPE (IMAGE_NY_PIX, MAG_NONE, OPIHI_INT); 422 if (!strcasecmp (fieldName, "apresid" )) ESCAPE (IMAGE_APRESID, MAG_NONE, OPIHI_FLT); 423 if (!strcasecmp (fieldName, "dapresid" )) ESCAPE (IMAGE_DAPRESID, MAG_NONE, OPIHI_FLT); 424 425 if (!strcasecmp (fieldName, "Mcal" )) ESCAPE (IMAGE_MCAL, MAG_NONE, OPIHI_FLT); 426 if (!strcasecmp (fieldName, "dMcal" )) ESCAPE (IMAGE_dMCAL, MAG_NONE, OPIHI_FLT); 427 if (!strcasecmp (fieldName, "Xm" )) ESCAPE (IMAGE_XM, MAG_NONE, OPIHI_FLT); 428 if (!strcasecmp (fieldName, "photcode" )) ESCAPE (IMAGE_PHOTCODE, MAG_NONE, OPIHI_INT); 429 if (!strcasecmp (fieldName, "exptime" )) ESCAPE (IMAGE_EXPTIME, MAG_NONE, OPIHI_FLT); 430 if (!strcasecmp (fieldName, "sidtime" )) ESCAPE (IMAGE_SIDTIME, MAG_NONE, OPIHI_FLT); 431 432 if (!strcasecmp (fieldName, "latitude" )) ESCAPE (IMAGE_LATITUDE, MAG_NONE, OPIHI_FLT); 433 434 if (!strcasecmp (fieldName, "detlimit" )) ESCAPE (IMAGE_DET_LIMIT, MAG_NONE, OPIHI_FLT); 435 if (!strcasecmp (fieldName, "satlimit" )) ESCAPE (IMAGE_SAT_LIMIT, MAG_NONE, OPIHI_FLT); 436 if (!strcasecmp (fieldName, "cerror" )) ESCAPE (IMAGE_CERROR, MAG_NONE, OPIHI_FLT); 437 438 if (!strcasecmp (fieldName, "FWHM" )) ESCAPE (IMAGE_FWHM, MAG_NONE, OPIHI_FLT); 439 if (!strcasecmp (fieldName, "FWHM_MAJ" )) ESCAPE (IMAGE_FWHM_MAJ, MAG_NONE, OPIHI_FLT); 440 if (!strcasecmp (fieldName, "FWHM_MIN" )) ESCAPE (IMAGE_FWHM_MIN, MAG_NONE, OPIHI_FLT); 441 if (!strcasecmp (fieldName, "FWHM_MAJOR" )) ESCAPE (IMAGE_FWHM_MAJ, MAG_NONE, OPIHI_FLT); 442 if (!strcasecmp (fieldName, "FWHM_MINOR" )) ESCAPE (IMAGE_FWHM_MIN, MAG_NONE, OPIHI_FLT); 443 444 if (!strcasecmp (fieldName, "FWHM_MEDIAN" )) ESCAPE (IMAGE_FWHM_MEDIAN, MAG_NONE, OPIHI_FLT); 445 if (!strcasecmp (fieldName, "FWHM_MAJ_MEDIAN")) ESCAPE (IMAGE_FWHM_MAJ_MEDIAN, MAG_NONE, OPIHI_FLT); 446 if (!strcasecmp (fieldName, "FWHM_MIN_MEDIAN")) ESCAPE (IMAGE_FWHM_MIN_MEDIAN, MAG_NONE, OPIHI_FLT); 447 if (!strcasecmp (fieldName, "FWHM_MAJOR_MEDIAN")) ESCAPE (IMAGE_FWHM_MAJ_MEDIAN, MAG_NONE, OPIHI_FLT); 448 if (!strcasecmp (fieldName, "FWHM_MINOR_MEDIAN")) ESCAPE (IMAGE_FWHM_MIN_MEDIAN, MAG_NONE, OPIHI_FLT); 449 450 if (!strcasecmp (fieldName, "trate" )) ESCAPE (IMAGE_TRATE, MAG_NONE, OPIHI_FLT); 451 452 if (!strcasecmp (fieldName, "ncal" )) ESCAPE (IMAGE_NCAL, MAG_NONE, OPIHI_INT); 453 if (!strcasecmp (fieldName, "sky" )) ESCAPE (IMAGE_SKY, MAG_NONE, OPIHI_FLT); // deprecated for now 454 455 if (!strcasecmp (fieldName, "imflags" )) ESCAPE (IMAGE_FLAGS, MAG_NONE, OPIHI_INT); 456 if (!strcasecmp (fieldName, "flags" )) ESCAPE (IMAGE_FLAGS, MAG_NONE, OPIHI_INT); 457 if (!strcasecmp (fieldName, "ccdnum" )) ESCAPE (IMAGE_CCDNUM, MAG_NONE, OPIHI_INT); 458 459 if (!strcasecmp (fieldName, "imageID" )) ESCAPE (IMAGE_IMAGE_ID, MAG_NONE, OPIHI_INT); 460 if (!strcasecmp (fieldName, "externID" )) ESCAPE (IMAGE_EXTERN_ID, MAG_NONE, OPIHI_INT); 461 if (!strcasecmp (fieldName, "sourceID" )) ESCAPE (IMAGE_SOURCE_ID, MAG_NONE, OPIHI_INT); 462 463 if (!strcasecmp (fieldName, "X_LL_CHIP")) ESCAPE (IMAGE_X_LL_CHIP, MAG_NONE, OPIHI_FLT); 464 if (!strcasecmp (fieldName, "X_LR_CHIP")) ESCAPE (IMAGE_X_LR_CHIP, MAG_NONE, OPIHI_FLT); 465 if (!strcasecmp (fieldName, "X_UL_CHIP")) ESCAPE (IMAGE_X_UL_CHIP, MAG_NONE, OPIHI_FLT); 466 if (!strcasecmp (fieldName, "X_UR_CHIP")) ESCAPE (IMAGE_X_UR_CHIP, MAG_NONE, OPIHI_FLT); 467 if (!strcasecmp (fieldName, "Y_LL_CHIP")) ESCAPE (IMAGE_Y_LL_CHIP, MAG_NONE, OPIHI_FLT); 468 if (!strcasecmp (fieldName, "Y_LR_CHIP")) ESCAPE (IMAGE_Y_LR_CHIP, MAG_NONE, OPIHI_FLT); 469 if (!strcasecmp (fieldName, "Y_UL_CHIP")) ESCAPE (IMAGE_Y_UL_CHIP, MAG_NONE, OPIHI_FLT); 470 if (!strcasecmp (fieldName, "Y_UR_CHIP")) ESCAPE (IMAGE_Y_UR_CHIP, MAG_NONE, OPIHI_FLT); 471 if (!strcasecmp (fieldName, "X_LL_FP" )) ESCAPE (IMAGE_X_LL_FP, MAG_NONE, OPIHI_FLT); 472 if (!strcasecmp (fieldName, "X_LR_FP" )) ESCAPE (IMAGE_X_LR_FP, MAG_NONE, OPIHI_FLT); 473 if (!strcasecmp (fieldName, "X_UL_FP" )) ESCAPE (IMAGE_X_UL_FP, MAG_NONE, OPIHI_FLT); 474 if (!strcasecmp (fieldName, "X_UR_FP" )) ESCAPE (IMAGE_X_UR_FP, MAG_NONE, OPIHI_FLT); 475 if (!strcasecmp (fieldName, "Y_LL_FP" )) ESCAPE (IMAGE_Y_LL_FP, MAG_NONE, OPIHI_FLT); 476 if (!strcasecmp (fieldName, "Y_LR_FP" )) ESCAPE (IMAGE_Y_LR_FP, MAG_NONE, OPIHI_FLT); 477 if (!strcasecmp (fieldName, "Y_UL_FP" )) ESCAPE (IMAGE_Y_UL_FP, MAG_NONE, OPIHI_FLT); 478 if (!strcasecmp (fieldName, "Y_UR_FP" )) ESCAPE (IMAGE_Y_UR_FP, MAG_NONE, OPIHI_FLT); 479 480 if (!strcasecmp (fieldName, "dX_SYS" )) ESCAPE (IMAGE_X_ERR_SYS, MAG_NONE, OPIHI_FLT); 481 if (!strcasecmp (fieldName, "dY_SYS" )) ESCAPE (IMAGE_Y_ERR_SYS, MAG_NONE, OPIHI_FLT); 482 if (!strcasecmp (fieldName, "dM_SYS" )) ESCAPE (IMAGE_MAG_ERR_SYS,MAG_NONE, OPIHI_FLT); 483 484 if (!strcasecmp (fieldName, "UBERCAL_DIST")) ESCAPE (IMAGE_UBERCAL_DIST,MAG_NONE, OPIHI_INT); 485 if (!strcasecmp (fieldName, "UCDIST")) ESCAPE (IMAGE_UBERCAL_DIST,MAG_NONE, OPIHI_INT); 486 487 if (!strcasecmp (fieldName, "NFIT_PHOTOM")) ESCAPE (IMAGE_NFIT_PHOTOM,MAG_NONE, OPIHI_INT); 488 if (!strcasecmp (fieldName, "NFIT_ASTROM")) ESCAPE (IMAGE_NFIT_ASTROM,MAG_NONE, OPIHI_INT); 489 if (!strcasecmp (fieldName, "NLINK_PHOTOM")) ESCAPE (IMAGE_NLINK_PHOTOM,MAG_NONE, OPIHI_INT); 490 if (!strcasecmp (fieldName, "NLINK_ASTROM")) ESCAPE (IMAGE_NLINK_ASTROM,MAG_NONE, OPIHI_INT); 568 ESCAPE (IMAGE_ELAT, OPIHI_FLT); 569 } 570 571 if (!strcasecmp (fieldName, "RA" )) ESCAPE (IMAGE_RA, OPIHI_FLT); 572 if (!strcasecmp (fieldName, "DEC" )) ESCAPE (IMAGE_DEC, OPIHI_FLT); 573 if (!strcasecmp (fieldName, "GLON" )) ESCAPE (IMAGE_GLON, OPIHI_FLT); 574 if (!strcasecmp (fieldName, "GLAT" )) ESCAPE (IMAGE_GLAT, OPIHI_FLT); 575 if (!strcasecmp (fieldName, "ELON" )) ESCAPE (IMAGE_ELON, OPIHI_FLT); 576 if (!strcasecmp (fieldName, "ELAT" )) ESCAPE (IMAGE_ELAT, OPIHI_FLT); 577 578 if (!strcasecmp (fieldName, "theta" )) ESCAPE (IMAGE_THETA, OPIHI_FLT); 579 if (!strcasecmp (fieldName, "skew" )) ESCAPE (IMAGE_SKEW, OPIHI_FLT); 580 if (!strcasecmp (fieldName, "scale" )) ESCAPE (IMAGE_SCALE, OPIHI_FLT); 581 if (!strcasecmp (fieldName, "dscale" )) ESCAPE (IMAGE_DSCALE, OPIHI_FLT); 582 583 if (!strcasecmp (fieldName, "time" )) ESCAPE (IMAGE_TIME, OPIHI_FLT); 584 if (!strcasecmp (fieldName, "nstar" )) ESCAPE (IMAGE_NSTAR, OPIHI_INT); 585 if (!strcasecmp (fieldName, "airmass" )) ESCAPE (IMAGE_AIRMASS, OPIHI_FLT); 586 if (!strcasecmp (fieldName, "NX" )) ESCAPE (IMAGE_NX_PIX, OPIHI_INT); 587 if (!strcasecmp (fieldName, "NY" )) ESCAPE (IMAGE_NY_PIX, OPIHI_INT); 588 if (!strcasecmp (fieldName, "apresid" )) ESCAPE (IMAGE_APRESID, OPIHI_FLT); 589 if (!strcasecmp (fieldName, "dapresid" )) ESCAPE (IMAGE_DAPRESID, OPIHI_FLT); 590 591 if (!strcasecmp (fieldName, "Mcal" )) ESCAPE (IMAGE_MCAL, OPIHI_FLT); 592 if (!strcasecmp (fieldName, "dMcal" )) ESCAPE (IMAGE_dMCAL, OPIHI_FLT); 593 if (!strcasecmp (fieldName, "Xm" )) ESCAPE (IMAGE_XM, OPIHI_FLT); 594 if (!strcasecmp (fieldName, "photcode" )) ESCAPE (IMAGE_PHOTCODE, OPIHI_INT); 595 if (!strcasecmp (fieldName, "exptime" )) ESCAPE (IMAGE_EXPTIME, OPIHI_FLT); 596 if (!strcasecmp (fieldName, "sidtime" )) ESCAPE (IMAGE_SIDTIME, OPIHI_FLT); 597 598 if (!strcasecmp (fieldName, "latitude" )) ESCAPE (IMAGE_LATITUDE, OPIHI_FLT); 599 600 if (!strcasecmp (fieldName, "detlimit" )) ESCAPE (IMAGE_DET_LIMIT, OPIHI_FLT); 601 if (!strcasecmp (fieldName, "satlimit" )) ESCAPE (IMAGE_SAT_LIMIT, OPIHI_FLT); 602 if (!strcasecmp (fieldName, "cerror" )) ESCAPE (IMAGE_CERROR, OPIHI_FLT); 603 604 if (!strcasecmp (fieldName, "FWHM" )) ESCAPE (IMAGE_FWHM, OPIHI_FLT); 605 if (!strcasecmp (fieldName, "FWHM_MAJ" )) ESCAPE (IMAGE_FWHM_MAJ, OPIHI_FLT); 606 if (!strcasecmp (fieldName, "FWHM_MIN" )) ESCAPE (IMAGE_FWHM_MIN, OPIHI_FLT); 607 if (!strcasecmp (fieldName, "FWHM_MAJOR" )) ESCAPE (IMAGE_FWHM_MAJ, OPIHI_FLT); 608 if (!strcasecmp (fieldName, "FWHM_MINOR" )) ESCAPE (IMAGE_FWHM_MIN, OPIHI_FLT); 609 610 if (!strcasecmp (fieldName, "FWHM_MEDIAN" )) ESCAPE (IMAGE_FWHM_MEDIAN, OPIHI_FLT); 611 if (!strcasecmp (fieldName, "FWHM_MAJ_MEDIAN")) ESCAPE (IMAGE_FWHM_MAJ_MEDIAN, OPIHI_FLT); 612 if (!strcasecmp (fieldName, "FWHM_MIN_MEDIAN")) ESCAPE (IMAGE_FWHM_MIN_MEDIAN, OPIHI_FLT); 613 if (!strcasecmp (fieldName, "FWHM_MAJOR_MEDIAN")) ESCAPE (IMAGE_FWHM_MAJ_MEDIAN, OPIHI_FLT); 614 if (!strcasecmp (fieldName, "FWHM_MINOR_MEDIAN")) ESCAPE (IMAGE_FWHM_MIN_MEDIAN, OPIHI_FLT); 615 616 if (!strcasecmp (fieldName, "trate" )) ESCAPE (IMAGE_TRATE, OPIHI_FLT); 617 618 if (!strcasecmp (fieldName, "ncal" )) ESCAPE (IMAGE_NCAL, OPIHI_INT); 619 if (!strcasecmp (fieldName, "sky" )) ESCAPE (IMAGE_SKY, OPIHI_FLT); // deprecated for now 620 621 if (!strcasecmp (fieldName, "imflags" )) ESCAPE (IMAGE_FLAGS, OPIHI_INT); 622 if (!strcasecmp (fieldName, "flags" )) ESCAPE (IMAGE_FLAGS, OPIHI_INT); 623 if (!strcasecmp (fieldName, "ccdnum" )) ESCAPE (IMAGE_CCDNUM, OPIHI_INT); 624 625 if (!strcasecmp (fieldName, "imageID" )) ESCAPE (IMAGE_IMAGE_ID, OPIHI_INT); 626 if (!strcasecmp (fieldName, "externID" )) ESCAPE (IMAGE_EXTERN_ID, OPIHI_INT); 627 if (!strcasecmp (fieldName, "sourceID" )) ESCAPE (IMAGE_SOURCE_ID, OPIHI_INT); 628 629 if (!strcasecmp (fieldName, "X_LL_CHIP")) ESCAPE (IMAGE_X_LL_CHIP, OPIHI_FLT); 630 if (!strcasecmp (fieldName, "X_LR_CHIP")) ESCAPE (IMAGE_X_LR_CHIP, OPIHI_FLT); 631 if (!strcasecmp (fieldName, "X_UL_CHIP")) ESCAPE (IMAGE_X_UL_CHIP, OPIHI_FLT); 632 if (!strcasecmp (fieldName, "X_UR_CHIP")) ESCAPE (IMAGE_X_UR_CHIP, OPIHI_FLT); 633 if (!strcasecmp (fieldName, "Y_LL_CHIP")) ESCAPE (IMAGE_Y_LL_CHIP, OPIHI_FLT); 634 if (!strcasecmp (fieldName, "Y_LR_CHIP")) ESCAPE (IMAGE_Y_LR_CHIP, OPIHI_FLT); 635 if (!strcasecmp (fieldName, "Y_UL_CHIP")) ESCAPE (IMAGE_Y_UL_CHIP, OPIHI_FLT); 636 if (!strcasecmp (fieldName, "Y_UR_CHIP")) ESCAPE (IMAGE_Y_UR_CHIP, OPIHI_FLT); 637 if (!strcasecmp (fieldName, "X_LL_FP" )) ESCAPE (IMAGE_X_LL_FP, OPIHI_FLT); 638 if (!strcasecmp (fieldName, "X_LR_FP" )) ESCAPE (IMAGE_X_LR_FP, OPIHI_FLT); 639 if (!strcasecmp (fieldName, "X_UL_FP" )) ESCAPE (IMAGE_X_UL_FP, OPIHI_FLT); 640 if (!strcasecmp (fieldName, "X_UR_FP" )) ESCAPE (IMAGE_X_UR_FP, OPIHI_FLT); 641 if (!strcasecmp (fieldName, "Y_LL_FP" )) ESCAPE (IMAGE_Y_LL_FP, OPIHI_FLT); 642 if (!strcasecmp (fieldName, "Y_LR_FP" )) ESCAPE (IMAGE_Y_LR_FP, OPIHI_FLT); 643 if (!strcasecmp (fieldName, "Y_UL_FP" )) ESCAPE (IMAGE_Y_UL_FP, OPIHI_FLT); 644 if (!strcasecmp (fieldName, "Y_UR_FP" )) ESCAPE (IMAGE_Y_UR_FP, OPIHI_FLT); 645 646 if (!strcasecmp (fieldName, "dX_SYS" )) ESCAPE (IMAGE_X_ERR_SYS, OPIHI_FLT); 647 if (!strcasecmp (fieldName, "dY_SYS" )) ESCAPE (IMAGE_Y_ERR_SYS, OPIHI_FLT); 648 if (!strcasecmp (fieldName, "dM_SYS" )) ESCAPE (IMAGE_MAG_ERR_SYS,OPIHI_FLT); 649 650 if (!strcasecmp (fieldName, "UBERCAL_DIST")) ESCAPE (IMAGE_UBERCAL_DIST,OPIHI_INT); 651 if (!strcasecmp (fieldName, "UCDIST")) ESCAPE (IMAGE_UBERCAL_DIST,OPIHI_INT); 652 653 if (!strcasecmp (fieldName, "NFIT_PHOTOM")) ESCAPE (IMAGE_NFIT_PHOTOM, OPIHI_INT); 654 if (!strcasecmp (fieldName, "NFIT_ASTROM")) ESCAPE (IMAGE_NFIT_ASTROM, OPIHI_INT); 655 if (!strcasecmp (fieldName, "NLINK_PHOTOM")) ESCAPE (IMAGE_NLINK_PHOTOM, OPIHI_INT); 656 if (!strcasecmp (fieldName, "NLINK_ASTROM")) ESCAPE (IMAGE_NLINK_ASTROM, OPIHI_INT); 657 if (!strcasecmp (fieldName, "REF_COLOR")) ESCAPE (IMAGE_REF_COLOR, OPIHI_FLT); 491 658 492 659 // for words that don't parse, try a photcode -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_catalog.c
r35416 r37067 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; 103 142 104 143 average->flags = 0; … … 109 148 average->catID = 0; 110 149 average->extID = 0; 150 average->extIDgc = 0; 111 151 } 112 152 … … 119 159 average->measureOffset = -1; 120 160 average->catID = 0; 161 average->nOwn = 0; 121 162 } 122 163 … … 124 165 void dvo_secfilt_init (SecFilt *secfilt) { 125 166 secfilt->M = NAN; 167 secfilt->dM = NAN; 126 168 secfilt->Map = NAN; 169 secfilt->dMap = NAN; 170 secfilt->sMap = NAN; 127 171 secfilt->Mkron = NAN; 128 172 secfilt->dMkron = NAN; 129 secfilt->dM = NAN; 130 secfilt->Xm = NAN_S_SHORT; 131 132 secfilt->FluxPSF = NAN; 133 secfilt->dFluxPSF = NAN; 134 secfilt->FluxKron = NAN; 135 secfilt->dFluxKron = NAN; 136 137 secfilt->flags = 0; 173 secfilt->sMkron = NAN; 174 175 secfilt->Mstdev = NAN; 176 secfilt->Mmin = NAN; 177 secfilt->Mmax = NAN; 178 secfilt->Mchisq = NAN; 179 138 180 secfilt->Ncode = 0; 139 181 secfilt->Nused = 0; 140 141 secfilt->M_20 = NAN_S_SHORT; 142 secfilt->M_80 = NAN_S_SHORT; 182 secfilt->NusedKron = 0; 183 secfilt->NusedAp = 0; 184 185 secfilt->flags = 0; 186 187 secfilt->MpsfStk = NAN; 188 secfilt->FpsfStk = NAN; 189 secfilt->dFpsfStk = NAN; 190 191 secfilt->MkronStk = NAN; 192 secfilt->FkronStk = NAN; 193 secfilt->dFkronStk = NAN; 194 195 secfilt->MapStk = NAN; 196 secfilt->FapStk = NAN; 197 secfilt->dFapStk = NAN; 198 199 secfilt->stackDetectID = 0; 200 201 secfilt->MpsfWrp = NAN; 202 secfilt->FpsfWrp = NAN; 203 secfilt->dFpsfWrp = NAN; 204 secfilt->sFpsfWrp = NAN; 205 206 secfilt->MkronWrp = NAN; 207 secfilt->FkronWrp = NAN; 208 secfilt->dFkronWrp = NAN; 209 secfilt->sFkronWrp = NAN; 210 211 secfilt->MapWrp = NAN; 212 secfilt->FapWrp = NAN; 213 secfilt->dFapWrp = NAN; 214 secfilt->sFapWrp = NAN; 215 216 secfilt->NusedWrp = 0; 217 secfilt->NusedKronWrp = 0; 218 secfilt->NusedApWrp = 0; 143 219 144 220 secfilt->ubercalDist = 1000; 145 secfilt->Mstdev = NAN_S_SHORT;146 secfilt->stackDetectID = 0;147 221 } 148 222 149 223 // init all data, or just catalog data 150 224 void dvo_measure_init (Measure *measure) { 225 measure->R = NAN; 226 measure->D = NAN; 227 151 228 measure->M = NAN; 152 measure->dR = NAN; 153 measure->dD = NAN; 154 measure->Mcal = NAN; 229 measure->dM = NAN; 155 230 measure->Map = NAN; 231 measure->dMap = NAN; 156 232 measure->Mkron = NAN; 157 233 measure->dMkron = NAN; 158 measure-> dM= NAN;234 measure->Mcal = NAN; 159 235 measure->dMcal = NAN; 160 236 measure->dt = NAN; … … 164 240 measure->FluxKron = NAN; 165 241 measure->dFluxKron = NAN; 242 measure->FluxAp = NAN; 243 measure->dFluxAp = NAN; 166 244 167 245 measure->airmass = NAN; … … 173 251 measure->Yfix = NAN; 174 252 253 measure->XoffKH = NAN; 254 measure->YoffKH = NAN; 255 measure->XoffDCR = NAN; 256 measure->YoffDCR = NAN; 257 measure->RoffGAL = NAN; 258 measure->DoffGAL = NAN; 259 175 260 measure->Sky = NAN; 176 261 measure->dSky = NAN; 177 262 178 263 measure->t = 0; 179 measure->t_msec = 0;180 264 measure->averef = 0; 181 265 182 266 measure->detID = 0; 183 measure->imageID = 0;184 267 measure->objID = 0; 185 268 measure->catID = 0; 269 186 270 measure->extID = 0; 271 272 measure->imageID = 0; 187 273 188 274 measure->psfQF = NAN; 189 275 measure->psfQFperf = NAN; 190 276 measure->psfChisq = NAN; 277 191 278 measure->psfNdof = 0; 192 279 measure->psfNpix = 0; … … 202 289 measure->Myy = 0; 203 290 291 measure->t_msec = 0; 292 measure->photcode = 0; 293 204 294 measure->dXccd = 0; 205 295 measure->dYccd = 0; … … 209 299 measure->pltscale = NAN; 210 300 211 measure->photcode = 0;212 301 measure->dbFlags = 0; 213 302 measure->photFlags = 0; … … 215 304 216 305 void dvo_measureT_init (MeasureTiny *measure) { 217 measure-> dR= NAN;218 measure-> dD= NAN;306 measure->R = NAN; 307 measure->D = NAN; 219 308 measure->M = NAN; 220 309 measure->Mcal = NAN; … … 242 331 measure->dYccd = 0; 243 332 measure->dRsys = 0; 333 measure->myDet = FALSE; 334 } 335 336 // init all data, or just catalog data 337 void dvo_lensing_init (Lensing *lensing) { 338 lensing->X11_sm_obj = NAN; 339 lensing->X12_sm_obj = NAN; 340 lensing->X22_sm_obj = NAN; 341 lensing->E1_sm_obj = NAN; 342 lensing->E2_sm_obj = NAN; 343 344 lensing->X11_sh_obj = NAN; 345 lensing->X12_sh_obj = NAN; 346 lensing->X22_sh_obj = NAN; 347 lensing->E1_sh_obj = NAN; 348 lensing->E2_sh_obj = NAN; 349 350 lensing->X11_sm_psf = NAN; 351 lensing->X12_sm_psf = NAN; 352 lensing->X22_sm_psf = NAN; 353 lensing->E1_sm_psf = NAN; 354 lensing->E2_sm_psf = NAN; 355 356 lensing->X11_sh_psf = NAN; 357 lensing->X12_sh_psf = NAN; 358 lensing->X22_sh_psf = NAN; 359 lensing->E1_sh_psf = NAN; 360 lensing->E2_sh_psf = NAN; 361 362 lensing->F_ApR5 = NAN; 363 lensing->dF_ApR5 = NAN; 364 lensing->sF_ApR5 = NAN; 365 lensing->fF_ApR5 = NAN; 366 367 lensing->F_ApR6 = NAN; 368 lensing->dF_ApR6 = NAN; 369 lensing->sF_ApR6 = NAN; 370 lensing->fF_ApR6 = NAN; 371 372 lensing->detID = -1; 373 lensing->objID = -1; 374 lensing->catID = -1; 375 lensing->averef = 0; 376 } 377 378 // init all data, or just catalog data 379 void dvo_lensobj_init (Lensobj *lensobj) { 380 lensobj->X11_sm_obj = NAN; 381 lensobj->X12_sm_obj = NAN; 382 lensobj->X22_sm_obj = NAN; 383 lensobj->E1_sm_obj = NAN; 384 lensobj->E2_sm_obj = NAN; 385 386 lensobj->X11_sh_obj = NAN; 387 lensobj->X12_sh_obj = NAN; 388 lensobj->X22_sh_obj = NAN; 389 lensobj->E1_sh_obj = NAN; 390 lensobj->E2_sh_obj = NAN; 391 392 lensobj->X11_sm_psf = NAN; 393 lensobj->X12_sm_psf = NAN; 394 lensobj->X22_sm_psf = NAN; 395 lensobj->E1_sm_psf = NAN; 396 lensobj->E2_sm_psf = NAN; 397 398 lensobj->X11_sh_psf = NAN; 399 lensobj->X12_sh_psf = NAN; 400 lensobj->X22_sh_psf = NAN; 401 lensobj->E1_sh_psf = NAN; 402 lensobj->E2_sh_psf = NAN; 403 404 lensobj->F_ApR5 = NAN; 405 lensobj->dF_ApR5 = NAN; 406 lensobj->sF_ApR5 = NAN; 407 lensobj->fF_ApR5 = NAN; 408 409 lensobj->F_ApR6 = NAN; 410 lensobj->dF_ApR6 = NAN; 411 lensobj->sF_ApR6 = NAN; 412 lensobj->fF_ApR6 = NAN; 413 414 lensobj->gamma = NAN; 415 lensobj->E1 = NAN; 416 lensobj->E2 = NAN; 417 418 lensobj->objID = -1; 419 lensobj->catID = -1; 420 421 lensobj->pad = 0; 244 422 } 245 423 … … 267 445 catalog[0].secfilt = NULL; 268 446 447 catalog[0].lensing = NULL; 448 catalog[0].lensobj = NULL; 449 269 450 catalog[0].averageT = NULL; 270 451 catalog[0].measureT = NULL; … … 279 460 catalog[0].Nsecf_mem = 0; 280 461 462 catalog[0].Nlensing = 0; 463 catalog[0].Nlensobj = 0; 464 281 465 catalog[0].Naves_disk = 0; 282 466 catalog[0].Nmeas_disk = 0; … … 284 468 catalog[0].Nsecf_disk = 0; 285 469 470 catalog[0].Nlensing_disk = 0; 471 catalog[0].Nlensobj_disk = 0; 472 286 473 catalog[0].Naves_off = 0; 287 474 catalog[0].Nmeas_off = 0; … … 289 476 catalog[0].Nsecf_off = 0; 290 477 478 catalog[0].Nlensing_off = 0; 479 catalog[0].Nlensobj_off = 0; 480 291 481 /* pointers to SPLIT data files */ 292 482 catalog[0].measure_catalog = NULL; 293 483 catalog[0].missing_catalog = NULL; 294 484 catalog[0].secfilt_catalog = NULL; 485 catalog[0].lensing_catalog = NULL; 486 catalog[0].lensobj_catalog = NULL; 295 487 296 488 /* pointers for data manipulation */ 297 catalog[0].found = NULL; 298 catalog[0].image = NULL; 299 catalog[0].mosaic = NULL; 300 catalog[0].X = NULL; 301 catalog[0].Y = NULL; 489 // catalog[0].X_t = NULL; 490 // catalog[0].Y_t = NULL; 491 catalog[0].nOwn_t = NULL; 492 catalog[0].found_t = NULL; 493 // catalog[0].image_t = NULL; 494 // catalog[0].mosaic_t = NULL; 495 catalog[0].foundWarp_t = NULL; 302 496 } 303 497 … … 343 537 } 344 538 539 // closes f but does not set back to NULL 345 540 fclearlockfile (catalog[0].filename, catalog[0].f, catalog[0].lockmode, &dbstate); 346 541 347 542 if (catalog[0].catmode == DVO_MODE_SPLIT) { 348 if (catalog[0].measure_catalog != NULL) dvo_catalog_unlock (catalog[0].measure_catalog); 349 if (catalog[0].missing_catalog != NULL) dvo_catalog_unlock (catalog[0].missing_catalog); 350 if (catalog[0].secfilt_catalog != NULL) dvo_catalog_unlock (catalog[0].secfilt_catalog); 543 if (catalog[0].measure_catalog) dvo_catalog_unlock (catalog[0].measure_catalog); 544 if (catalog[0].missing_catalog) dvo_catalog_unlock (catalog[0].missing_catalog); 545 if (catalog[0].secfilt_catalog) dvo_catalog_unlock (catalog[0].secfilt_catalog); 546 if (catalog[0].lensing_catalog) dvo_catalog_unlock (catalog[0].lensing_catalog); 547 if (catalog[0].lensobj_catalog) dvo_catalog_unlock (catalog[0].lensobj_catalog); 351 548 } 352 549 return (1); … … 577 774 for (in = out = i = 0; i < catalog[0].Naverage; i++) { 578 775 for (j = 0; j < catalog[0].Nsecfilt; j++, in++, out++) { 579 outsec[out].M = insec[in].M;580 outsec[out].dM = insec[in].dM;581 outsec[out]. Xm = insec[in].Xm;776 outsec[out].M = insec[in].M; 777 outsec[out].dM = insec[in].dM; 778 outsec[out].Mchisq = insec[in].Mchisq; 582 779 } 583 780 for (j = 0; j < Nextra; j++, out++) { 584 outsec[out].M = NAN;585 outsec[out].dM = NAN;586 outsec[out]. Xm = NAN_S_SHORT;781 outsec[out].M = NAN; 782 outsec[out].dM = NAN; 783 outsec[out].Mchisq = NAN; 587 784 } 588 785 } … … 614 811 free (catalog[0].secfilt_catalog); 615 812 } 813 if (catalog[0].lensing_catalog) { 814 free (catalog[0].lensing_catalog[0].filename); 815 dvo_catalog_free (catalog[0].lensing_catalog); 816 free (catalog[0].lensing_catalog); 817 } 818 if (catalog[0].lensobj_catalog) { 819 free (catalog[0].lensobj_catalog[0].filename); 820 dvo_catalog_free (catalog[0].lensobj_catalog); 821 free (catalog[0].lensobj_catalog); 822 } 616 823 } 617 824 dvo_catalog_free_data (catalog); … … 623 830 624 831 /* free, initialize data structures */ 625 if (catalog[0].average != NULL) {832 if (catalog[0].average) { 626 833 free (catalog[0].average); 627 834 catalog[0].Naverage = 0; 628 835 catalog[0].average = NULL; 629 836 } 630 if (catalog[0].measure != NULL) {837 if (catalog[0].measure) { 631 838 free (catalog[0].measure); 632 839 catalog[0].Nmeasure = 0; 633 840 catalog[0].measure = NULL; 634 841 } 635 if (catalog[0].missing != NULL) {842 if (catalog[0].missing) { 636 843 free (catalog[0].missing); 637 844 catalog[0].Nmissing = 0; 638 845 catalog[0].missing = NULL; 639 846 } 640 if (catalog[0].secfilt != NULL) {847 if (catalog[0].secfilt) { 641 848 free (catalog[0].secfilt); 642 849 catalog[0].Nsecf_mem = 0; 643 850 catalog[0].secfilt = NULL; 644 851 } 852 if (catalog[0].lensing) { 853 free (catalog[0].lensing); 854 catalog[0].Nlensing = 0; 855 catalog[0].lensing = NULL; 856 } 857 if (catalog[0].lensobj) { 858 free (catalog[0].lensobj); 859 catalog[0].Nlensobj = 0; 860 catalog[0].lensobj = NULL; 861 } 862 // if (catalog[0].X_t) free (catalog[0].X_t); 863 // if (catalog[0].Y_t) free (catalog[0].Y_t); 864 if (catalog[0].nOwn_t) free (catalog[0].nOwn_t); 865 if (catalog[0].found_t) free (catalog[0].found_t); 866 // if (catalog[0].image_t) free (catalog[0].image_t); 867 // if (catalog[0].mosaic_t) free (catalog[0].mosaic_t); 868 if (catalog[0].foundWarp_t) free (catalog[0].foundWarp_t); 645 869 } 646 870 … … 731 955 } 732 956 } 957 if (catalog[0].lensing_catalog != NULL) { 958 if (catalog[0].Nlensing_disk == 0) { 959 // need to relock (and re-open) file for close elsewhere 960 status = dvo_catalog_lock (catalog[0].lensing_catalog, lockmode); 961 } else { 962 if (!dvo_catalog_backup (catalog[0].lensing_catalog, FALSE)) { 963 return FALSE; 964 } 965 } 966 } 967 if (catalog[0].lensobj_catalog != NULL) { 968 if (catalog[0].Nlensobj_disk == 0) { 969 // need to relock (and re-open) file for close elsewhere 970 status = dvo_catalog_lock (catalog[0].lensobj_catalog, lockmode); 971 } else { 972 if (!dvo_catalog_backup (catalog[0].lensobj_catalog, FALSE)) { 973 return FALSE; 974 } 975 } 976 } 733 977 } 734 978 return TRUE; … … 752 996 status = unlink (tmpfilename); 753 997 if (status) { 754 fprintf (stderr, "failed to unlink catalog %s \n", catalog->filename);998 fprintf (stderr, "failed to unlink catalog %s~\n", catalog->filename); 755 999 return FALSE; 756 1000 } … … 772 1016 } 773 1017 } 1018 if ((catalog[0].lensing_catalog != NULL) && (catalog[0].Nlensing_disk > 0)) { 1019 if (!dvo_catalog_unlink_backup (catalog[0].lensing_catalog, FALSE)) { 1020 return FALSE; 1021 } 1022 } 1023 if ((catalog[0].lensobj_catalog != NULL) && (catalog[0].Nlensobj_disk > 0)) { 1024 if (!dvo_catalog_unlink_backup (catalog[0].lensobj_catalog, FALSE)) { 1025 return FALSE; 1026 } 1027 } 774 1028 } 775 1029 return TRUE; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_catalog_chipcoords.c
r16810 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_catalog_create.c
r27435 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_catalog_mef.c
r33649 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_catalog_raw.c
r34260 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_catalog_split.c
r34844 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_convert.c
r35172 r37067 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 … … 63 64 fprintf (stderr, "EXTNAME missing for average table\n"); 64 65 return (FALSE); 66 } 67 68 // block to convert broken tables (PS1_V4 made before the Xfix addition) 69 if (!strcmp (extname, "DVO_AVERAGE_PS1_V4") && (ftable[0].header[0].Naxis[0] == 120)) { 70 Average_PS1_V4alt *tmpAverage; 71 tmpAverage = gfits_table_get_Average_PS1_V4alt (ftable, Naverage, NULL); 72 if (!tmpAverage) { 73 fprintf (stderr, "ERROR: failed to read averages\n"); 74 exit (2); 75 } 76 average = Average_PS1_V4alt_ToInternal (tmpAverage, *Naverage); 77 free (tmpAverage); 78 *format = DVO_FORMAT_PS1_V4; 79 return (average); 65 80 } 66 81 … … 98 113 CONVERT_FORMAT ("DVO_AVERAGE_PS1_V3", PS1_V3, PS1_V3); 99 114 CONVERT_FORMAT ("DVO_AVERAGE_PS1_V4", PS1_V4, PS1_V4); 115 CONVERT_FORMAT ("DVO_AVERAGE_PS1_V5", PS1_V5, PS1_V5); 100 116 CONVERT_FORMAT ("DVO_AVERAGE_PS1_REF", PS1_REF, PS1_REF); 101 117 # undef CONVERT_FORMAT … … 133 149 FORMAT_CASE (PS1_V3, PS1_V3); 134 150 FORMAT_CASE (PS1_V4, PS1_V4); 151 FORMAT_CASE (PS1_V5, PS1_V5); 135 152 FORMAT_CASE (PS1_REF, PS1_REF); 136 153 # undef FORMAT_CASE … … 145 162 /*** Measure / FTable conversion functions ***/ 146 163 147 Measure *FtableToMeasure (FTable *ftable, off_t *Nmeasure, char *format) { 164 // FtableToMeasure needs the Average since old formats stored measure.dR,dD only 165 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, char *format) { 148 166 149 167 Measure *measure; … … 156 174 } 157 175 158 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 159 if (!strcmp (extname, NAME)) { \ 160 Measure_##TYPE *tmpMeasure; \ 176 // block to convert broken tables (PS1_V4 made before the Xfix addition) 177 if (!strcmp (extname, "DVO_MEASURE_PS1_V4") && (ftable[0].header[0].Naxis[0] == 176)) { 178 fprintf (stderr, "reading alt PS1_V4 format\n"); 179 Measure_PS1_V4alt *tmpMeasure; 180 tmpMeasure = gfits_table_get_Measure_PS1_V4alt (ftable, Nmeasure, NULL); 181 if (!tmpMeasure) { 182 fprintf (stderr, "ERROR: failed to read measures\n"); 183 exit (2); 184 } 185 myAssert (average, "conversion to internal needs average table"); 186 measure = Measure_PS1_V4alt_ToInternal (average, tmpMeasure, *Nmeasure); 187 free (tmpMeasure); 188 *format = DVO_FORMAT_PS1_V4; 189 return (measure); 190 } 191 192 # define CONVERT_FORMAT(NAME, FORMAT, TYPE, ABS_COORDS) \ 193 if (!strcmp (extname, NAME)) { \ 194 Measure_##TYPE *tmpMeasure; \ 161 195 tmpMeasure = gfits_table_get_Measure_##TYPE (ftable, Nmeasure, NULL); \ 162 if (!tmpMeasure) { \ 163 fprintf (stderr, "ERROR: failed to read measures\n"); \ 164 exit (2); \ 165 } \ 166 measure = Measure_##TYPE##_ToInternal (tmpMeasure, *Nmeasure); \ 167 free (tmpMeasure); \ 168 *format = DVO_FORMAT_##FORMAT; \ 196 if (!tmpMeasure) { \ 197 fprintf (stderr, "ERROR: failed to read measures\n"); \ 198 exit (2); \ 199 } \ 200 myAssert (ABS_COORDS || average, "conversion to internal needs average table"); \ 201 measure = Measure_##TYPE##_ToInternal (average, tmpMeasure, *Nmeasure); \ 202 free (tmpMeasure); \ 203 *format = DVO_FORMAT_##FORMAT; \ 169 204 return (measure); } 170 205 … … 179 214 } 180 215 181 CONVERT_FORMAT ("DVO_MEASURE_ELIXIR", ELIXIR, Elixir); 182 CONVERT_FORMAT ("DVO_MEASURE_LONEOS", LONEOS, Loneos); 183 CONVERT_FORMAT ("DVO_MEASURE_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0); 184 CONVERT_FORMAT ("DVO_MEASURE_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1); 185 CONVERT_FORMAT ("DVO_MEASURE_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 186 CONVERT_FORMAT ("DVO_MEASURE_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 187 CONVERT_FORMAT ("DVO_MEASURE_PS1_V1", PS1_V1, PS1_V1); 188 CONVERT_FORMAT ("DVO_MEASURE_PS1_V2", PS1_V2, PS1_V2); 189 CONVERT_FORMAT ("DVO_MEASURE_PS1_V3", PS1_V3, PS1_V3); 190 CONVERT_FORMAT ("DVO_MEASURE_PS1_V4", PS1_V4, PS1_V4); 191 CONVERT_FORMAT ("DVO_MEASURE_PS1_REF", PS1_REF, PS1_REF); 216 CONVERT_FORMAT ("DVO_MEASURE_ELIXIR", ELIXIR, Elixir, FALSE); 217 CONVERT_FORMAT ("DVO_MEASURE_LONEOS", LONEOS, Loneos, FALSE); 218 CONVERT_FORMAT ("DVO_MEASURE_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0, FALSE); 219 CONVERT_FORMAT ("DVO_MEASURE_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1, FALSE); 220 CONVERT_FORMAT ("DVO_MEASURE_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1, FALSE); 221 CONVERT_FORMAT ("DVO_MEASURE_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2, FALSE); 222 CONVERT_FORMAT ("DVO_MEASURE_PS1_V1", PS1_V1, PS1_V1, FALSE); 223 CONVERT_FORMAT ("DVO_MEASURE_PS1_V2", PS1_V2, PS1_V2, FALSE); 224 CONVERT_FORMAT ("DVO_MEASURE_PS1_V3", PS1_V3, PS1_V3, FALSE); 225 CONVERT_FORMAT ("DVO_MEASURE_PS1_V4", PS1_V4, PS1_V4, FALSE); 226 CONVERT_FORMAT ("DVO_MEASURE_PS1_V5", PS1_V5, PS1_V5, TRUE); 227 CONVERT_FORMAT ("DVO_MEASURE_PS1_REF", PS1_REF, PS1_REF, FALSE); 192 228 # undef CONVERT_FORMAT 193 229 … … 198 234 } 199 235 200 int MeasureToFtable (FTable *ftable, Measure *measure, off_t Nmeasure, char format) { 201 202 # define FORMAT_CASE(FORMAT, TYPE) \ 236 // MeasureToFtable needs the Average since old formats stored measure.dR,dD only 237 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, char format) { 238 239 # define FORMAT_CASE(FORMAT, TYPE, ABS_COORDS) \ 203 240 case DVO_FORMAT_##FORMAT: { \ 204 241 Measure_##TYPE *tmpMeasure; \ 205 tmpMeasure = MeasureInternalTo_##TYPE (measure, Nmeasure); \ 242 myAssert (ABS_COORDS || average, "conversion to internal needs average table"); \ 243 tmpMeasure = MeasureInternalTo_##TYPE (average, measure, Nmeasure); \ 206 244 gfits_table_set_Measure_##TYPE (ftable, tmpMeasure, Nmeasure); \ 207 245 free (tmpMeasure); \ … … 214 252 break; } 215 253 216 FORMAT_CASE (ELIXIR, Elixir); 217 FORMAT_CASE (LONEOS, Loneos); 218 FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 219 FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 220 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 221 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 222 FORMAT_CASE (PS1_V1, PS1_V1); 223 FORMAT_CASE (PS1_V2, PS1_V2); 224 FORMAT_CASE (PS1_V3, PS1_V3); 225 FORMAT_CASE (PS1_V4, PS1_V4); 226 FORMAT_CASE (PS1_REF, PS1_REF); 254 FORMAT_CASE (ELIXIR, Elixir, FALSE); 255 FORMAT_CASE (LONEOS, Loneos, FALSE); 256 FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0, FALSE); 257 FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1, FALSE); 258 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1, FALSE); 259 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2, FALSE); 260 FORMAT_CASE (PS1_V1, PS1_V1, FALSE); 261 FORMAT_CASE (PS1_V2, PS1_V2, FALSE); 262 FORMAT_CASE (PS1_V3, PS1_V3, FALSE); 263 FORMAT_CASE (PS1_V4, PS1_V4, FALSE); 264 FORMAT_CASE (PS1_V5, PS1_V5, TRUE); 265 FORMAT_CASE (PS1_REF, PS1_REF, FALSE); 227 266 # undef FORMAT_CASE 228 267 … … 280 319 CONVERT_FORMAT ("DVO_SECFILT_PS1_V3", PS1_V3, PS1_V3); 281 320 CONVERT_FORMAT ("DVO_SECFILT_PS1_V4", PS1_V4, PS1_V4); 321 CONVERT_FORMAT ("DVO_SECFILT_PS1_V5", PS1_V5, PS1_V5); 282 322 CONVERT_FORMAT ("DVO_SECFILT_PS1_REF", PS1_REF, PS1_REF); 283 323 # undef CONVERT_FORMAT … … 315 355 FORMAT_CASE (PS1_V3, PS1_V3); 316 356 FORMAT_CASE (PS1_V4, PS1_V4); 357 FORMAT_CASE (PS1_V5, PS1_V5); 317 358 FORMAT_CASE (PS1_REF, PS1_REF); 318 359 # undef FORMAT_CASE … … 320 361 default: 321 362 fprintf (stderr, "table format unknown (secfilt)\n"); 363 return (FALSE); 364 } 365 return (TRUE); 366 } 367 368 /*** Lensing / FTable conversion functions ***/ 369 370 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, char *format) { 371 372 Lensing *lensing; 373 char extname[80]; 374 375 /* convert to the internal format */ 376 if (!gfits_scan (ftable[0].header, "EXTNAME", "%s", 1, extname)) { 377 fprintf (stderr, "EXTNAME missing for lensing table\n"); 378 return (FALSE); 379 } 380 381 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 382 if (!strcmp (extname, NAME)) { \ 383 Lensing_##TYPE *tmpLensing; \ 384 tmpLensing = gfits_table_get_Lensing_##TYPE (ftable, Nlensing, NULL); \ 385 if (!tmpLensing) { \ 386 fprintf (stderr, "ERROR: failed to read lensings\n"); \ 387 exit (2); \ 388 } \ 389 lensing = Lensing_##TYPE##_ToInternal (tmpLensing, *Nlensing); \ 390 free (tmpLensing); \ 391 *format = DVO_FORMAT_##FORMAT; \ 392 return (lensing); } 393 394 if (!strcmp (extname, "DVO_LENSING")) { 395 lensing = gfits_table_get_Lensing (ftable, Nlensing, NULL); 396 if (!lensing) { 397 fprintf (stderr, "ERROR: failed to read lensings\n"); 398 exit (2); 399 } 400 *format = DVO_FORMAT_INTERNAL; 401 return (lensing); 402 } 403 404 // CONVERT_FORMAT ("DVO_LENSING_PS1_REF", PS1_REF, PS1_REF); 405 // CONVERT_FORMAT ("DVO_LENSING_ELIXIR", ELIXIR, Elixir); 406 // CONVERT_FORMAT ("DVO_LENSING_LONEOS", LONEOS, Loneos); 407 // CONVERT_FORMAT ("DVO_LENSING_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0); 408 // CONVERT_FORMAT ("DVO_LENSING_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1); 409 // CONVERT_FORMAT ("DVO_LENSING_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 410 // CONVERT_FORMAT ("DVO_LENSING_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 411 // CONVERT_FORMAT ("DVO_LENSING_PS1_V1", PS1_V1, PS1_V1); 412 // CONVERT_FORMAT ("DVO_LENSING_PS1_V2", PS1_V2, PS1_V2); 413 // CONVERT_FORMAT ("DVO_LENSING_PS1_V3", PS1_V3, PS1_V3); 414 // CONVERT_FORMAT ("DVO_LENSING_PS1_V4", PS1_V4, PS1_V4); 415 CONVERT_FORMAT ("DVO_LENSING_PS1_V5", PS1_V5, PS1_V5); 416 # undef CONVERT_FORMAT 417 418 fprintf (stderr, "table format unknown: %s\n", extname); 419 420 *Nlensing = 0; 421 return (NULL); 422 } 423 424 // LensingToFtable needs the Average since old formats stored lensing.dR,dD only 425 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, char format) { 426 427 # define FORMAT_CASE(FORMAT, TYPE) \ 428 case DVO_FORMAT_##FORMAT: { \ 429 Lensing_##TYPE *tmpLensing; \ 430 tmpLensing = LensingInternalTo_##TYPE (lensing, Nlensing); \ 431 gfits_table_set_Lensing_##TYPE (ftable, tmpLensing, Nlensing); \ 432 free (tmpLensing); \ 433 break; } 434 435 /* convert from the internal format */ 436 switch (format) { 437 case DVO_FORMAT_INTERNAL: { 438 gfits_table_set_Lensing (ftable, lensing, Nlensing); 439 break; } 440 441 // FORMAT_CASE (PS1_REF, PS1_REF); 442 // FORMAT_CASE (ELIXIR, Elixir); 443 // FORMAT_CASE (LONEOS, Loneos); 444 // FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 445 // FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 446 // FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 447 // FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 448 // FORMAT_CASE (PS1_V1, PS1_V1); 449 // FORMAT_CASE (PS1_V2, PS1_V2); 450 // FORMAT_CASE (PS1_V3, PS1_V3); 451 // FORMAT_CASE (PS1_V4, PS1_V4); 452 FORMAT_CASE (PS1_V5, PS1_V5); 453 # undef FORMAT_CASE 454 455 default: 456 fprintf (stderr, "table format unknown (lensing)\n"); 457 return (FALSE); 458 } 459 return (TRUE); 460 } 461 462 /*** Lensobj / FTable conversion functions ***/ 463 464 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, char *format) { 465 466 Lensobj *lensobj; 467 char extname[80]; 468 469 /* convert to the internal format */ 470 if (!gfits_scan (ftable[0].header, "EXTNAME", "%s", 1, extname)) { 471 fprintf (stderr, "EXTNAME missing for lensobj table\n"); 472 return (FALSE); 473 } 474 475 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 476 if (!strcmp (extname, NAME)) { \ 477 Lensobj_##TYPE *tmpLensobj; \ 478 tmpLensobj = gfits_table_get_Lensobj_##TYPE (ftable, Nlensobj, NULL); \ 479 if (!tmpLensobj) { \ 480 fprintf (stderr, "ERROR: failed to read lensobjs\n"); \ 481 exit (2); \ 482 } \ 483 lensobj = Lensobj_##TYPE##_ToInternal (tmpLensobj, *Nlensobj); \ 484 free (tmpLensobj); \ 485 *format = DVO_FORMAT_##FORMAT; \ 486 return (lensobj); } 487 488 if (!strcmp (extname, "DVO_LENSOBJ")) { 489 lensobj = gfits_table_get_Lensobj (ftable, Nlensobj, NULL); 490 if (!lensobj) { 491 fprintf (stderr, "ERROR: failed to read lensobjs\n"); 492 exit (2); 493 } 494 *format = DVO_FORMAT_INTERNAL; 495 return (lensobj); 496 } 497 498 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_REF", PS1_REF, PS1_REF); 499 // CONVERT_FORMAT ("DVO_LENSOBJ_ELIXIR", ELIXIR, Elixir); 500 // CONVERT_FORMAT ("DVO_LENSOBJ_LONEOS", LONEOS, Loneos); 501 // CONVERT_FORMAT ("DVO_LENSOBJ_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0); 502 // CONVERT_FORMAT ("DVO_LENSOBJ_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1); 503 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 504 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 505 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V1", PS1_V1, PS1_V1); 506 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V2", PS1_V2, PS1_V2); 507 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V3", PS1_V3, PS1_V3); 508 // CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V4", PS1_V4, PS1_V4); 509 CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V5", PS1_V5, PS1_V5); 510 # undef CONVERT_FORMAT 511 512 fprintf (stderr, "table format unknown: %s\n", extname); 513 514 *Nlensobj = 0; 515 return (NULL); 516 } 517 518 // LensobjToFtable needs the Average since old formats stored lensobj.dR,dD only 519 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, char format) { 520 521 # define FORMAT_CASE(FORMAT, TYPE) \ 522 case DVO_FORMAT_##FORMAT: { \ 523 Lensobj_##TYPE *tmpLensobj; \ 524 tmpLensobj = LensobjInternalTo_##TYPE (lensobj, Nlensobj); \ 525 gfits_table_set_Lensobj_##TYPE (ftable, tmpLensobj, Nlensobj); \ 526 free (tmpLensobj); \ 527 break; } 528 529 /* convert from the internal format */ 530 switch (format) { 531 case DVO_FORMAT_INTERNAL: { 532 gfits_table_set_Lensobj (ftable, lensobj, Nlensobj); 533 break; } 534 535 // FORMAT_CASE (PS1_REF, PS1_REF); 536 // FORMAT_CASE (ELIXIR, Elixir); 537 // FORMAT_CASE (LONEOS, Loneos); 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); 546 FORMAT_CASE (PS1_V5, PS1_V5); 547 # undef FORMAT_CASE 548 549 default: 550 fprintf (stderr, "table format unknown (lensobj)\n"); 322 551 return (FALSE); 323 552 } … … 399 628 CONVERT_FORMAT ("DVO_IMAGE_PS1_V3", PS1_V3, PS1_V3); 400 629 CONVERT_FORMAT ("DVO_IMAGE_PS1_V4", PS1_V4, PS1_V4); 630 CONVERT_FORMAT ("DVO_IMAGE_PS1_V5", PS1_V5, PS1_V5); 401 631 CONVERT_FORMAT ("DVO_IMAGE_PS1_REF", PS1_REF, PS1_REF); 402 632 … … 438 668 FORMAT_CASE (PS1_V3, PS1_V3); 439 669 FORMAT_CASE (PS1_V4, PS1_V4); 670 FORMAT_CASE (PS1_V5, PS1_V5); 440 671 FORMAT_CASE (PS1_REF, PS1_REF); 441 672 … … 493 724 FORMAT_CASE (PS1_V3, PS1_V3); 494 725 FORMAT_CASE (PS1_V4, PS1_V4); 726 FORMAT_CASE (PS1_V5, PS1_V5); 495 727 FORMAT_CASE (PS1_REF, PS1_REF); 496 728 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c
r35162 r37067 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; … … 50 52 } 51 53 52 Measure_PS1_DEV_1 *MeasureInternalTo_PS1_DEV_1 ( Measure *in, off_t Nvalues) {54 Measure_PS1_DEV_1 *MeasureInternalTo_PS1_DEV_1 (Average *ave, Measure *in, off_t Nvalues) { 53 55 54 56 off_t i; … … 58 60 59 61 for (i = 0; i < Nvalues; i++) { 60 out[i].dR = in[i].dR; 61 out[i].dD = in[i].dD; 62 int averef = in[i].averef; 63 64 out[i].dR = 3600.0*(ave[averef].R - in[i].R); 65 out[i].dD = 3600.0*(ave[averef].D - in[i].D); 62 66 out[i].M = in[i].M; 63 67 out[i].Mcal = in[i].Mcal; … … 180 184 out[i].M = in[i].M; 181 185 out[i].dM = in[i].dM; 182 out[i]. Xm = in[i].Xm;186 out[i].Mchisq= pow (10.0, 0.01*in[i].Xm); 183 187 out[i].Ncode = in[i].Ncode; 184 188 out[i].Nused = in[i].Nused; … … 197 201 out[i].M = in[i].M; 198 202 out[i].dM = in[i].dM; 199 out[i].Xm = in[i].Xm;203 out[i].Xm = 100.0*log10(in[i].Mchisq); 200 204 out[i].Ncode = in[i].Ncode; 201 205 out[i].Nused = in[i].Nused; … … 203 207 return (out); 204 208 } 209 210 # define RAW_IMAGE_NAME_LEN 64 205 211 206 212 Image *Image_PS1_DEV_1_ToInternal (Image_PS1_DEV_1 *in, off_t Nvalues, off_t Nalloc) { … … 217 223 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 218 224 219 strncpy (out[i].name, in[i].name, 63); // out[128], in[64] 220 out[i].name[63] = 0; // force termination 225 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 226 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 227 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 221 228 222 229 out[i].tzero = in[i].tzero; … … 284 291 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 285 292 286 strncpy (out[i].name, in[i].name, 63); // out[128], in[64] 287 out[i].name[63] = 0; // force termination 293 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 294 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 295 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 288 296 289 297 out[i].tzero = in[i].tzero; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c
r35162 r37067 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; … … 48 50 } 49 51 50 Measure_PS1_DEV_2 *MeasureInternalTo_PS1_DEV_2 ( Measure *in, off_t Nvalues) {52 Measure_PS1_DEV_2 *MeasureInternalTo_PS1_DEV_2 (Average *ave, Measure *in, off_t Nvalues) { 51 53 52 54 off_t i; … … 56 58 57 59 for (i = 0; i < Nvalues; i++) { 58 out[i].dR = in[i].dR; 59 out[i].dD = in[i].dD; 60 int averef = in[i].averef; 61 62 out[i].dR = 3600.0*(ave[averef].R - in[i].R); 63 out[i].dD = 3600.0*(ave[averef].D - in[i].D); 60 64 out[i].M = in[i].M; 61 65 out[i].Mcal = in[i].Mcal; … … 119 123 out[i].measureOffset = in[i].measureOffset; 120 124 out[i].missingOffset = in[i].missingOffset; 121 out[i]. extendOffset = in[i].extendOffset;125 out[i].refColorBlue = in[i].refColor; 122 126 out[i].objID = in[i].objID; 123 127 out[i].catID = in[i].catID; … … 153 157 out[i].measureOffset = in[i].measureOffset; 154 158 out[i].missingOffset = in[i].missingOffset; 155 out[i]. extendOffset = in[i].extendOffset;159 out[i].refColor = in[i].refColorBlue; 156 160 out[i].objID = in[i].objID; 157 161 out[i].catID = in[i].catID; … … 175 179 out[i].M = in[i].M; 176 180 out[i].dM = in[i].dM; 177 out[i]. Xm = in[i].Xm;181 out[i].Mchisq= pow (10.0, 0.01*in[i].Xm); 178 182 out[i].Ncode = in[i].Ncode; 179 183 out[i].Nused = in[i].Nused; … … 192 196 out[i].M = in[i].M; 193 197 out[i].dM = in[i].dM; 194 out[i].Xm = in[i].Xm;198 out[i].Xm = 100.0*log10(in[i].Mchisq); 195 199 out[i].Ncode = in[i].Ncode; 196 200 out[i].Nused = in[i].Nused; … … 198 202 return (out); 199 203 } 204 205 # define RAW_IMAGE_NAME_LEN 64 200 206 201 207 Image *Image_PS1_DEV_2_ToInternal (Image_PS1_DEV_2 *in, off_t Nvalues, off_t Nalloc) { … … 212 218 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 213 219 214 strncpy (out[i].name, in[i].name, 63); // out[121], in[64] 215 out[i].name[63] = 0; // force termination 220 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 221 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 222 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 216 223 217 224 out[i].tzero = in[i].tzero; … … 276 283 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 277 284 278 strncpy (out[i].name, in[i].name, 63); // in[121], out[64] 279 out[i].name[63] = 0; // force termination 285 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN 286 strncpy (out[i].name, in[i].name, RAW_IMAGE_NAME_LEN - 1); 287 out[i].name[RAW_IMAGE_NAME_LEN - 1] = 0; // force termination 280 288 281 289 out[i].tzero = in[i].tzero; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_3.c
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_convert_PS1_REF.c
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_convert_PS1_V1.c
r35162 r37067 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; … … 58 59 } 59 60 60 Measure_PS1_V1 *MeasureInternalTo_PS1_V1 ( Measure *in, off_t Nvalues) {61 Measure_PS1_V1 *MeasureInternalTo_PS1_V1 (Average *ave, Measure *in, off_t Nvalues) { 61 62 62 63 off_t i; … … 66 67 67 68 for (i = 0; i < Nvalues; i++) { 68 out[i].dR = in[i].dR; 69 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); 70 73 out[i].M = in[i].M; 71 74 out[i].Mcal = in[i].Mcal; … … 140 143 out[i].measureOffset = in[i].measureOffset; 141 144 out[i].missingOffset = in[i].missingOffset; 142 out[i]. extendOffset = in[i].extendOffset;145 out[i].refColorBlue = in[i].refColor; 143 146 out[i].flags = in[i].flags; 144 147 out[i].objID = in[i].objID; … … 175 178 out[i].measureOffset = in[i].measureOffset; 176 179 out[i].missingOffset = in[i].missingOffset; 177 out[i]. extendOffset = in[i].extendOffset;180 out[i].refColor = in[i].refColorBlue; 178 181 out[i].flags = in[i].flags; 179 182 out[i].objID = in[i].objID; … … 196 199 out[i].M = in[i].M; 197 200 out[i].dM = in[i].dM; 198 out[i]. Xm = in[i].Xm;201 out[i].Mchisq= in[i].Mchisq; 199 202 out[i].Ncode = in[i].Ncode; 200 203 out[i].Nused = in[i].Nused; 201 out[i].M _20 = in[i].M_20;202 out[i].M _80 = in[i].M_80;204 out[i].Mmin = in[i].M_20*0.001; 205 out[i].Mmax = in[i].M_80*0.001; 203 206 } 204 207 return (out); … … 215 218 out[i].M = in[i].M; 216 219 out[i].dM = in[i].dM; 217 out[i]. Xm = in[i].Xm;220 out[i].Mchisq= in[i].Mchisq; 218 221 out[i].Ncode = in[i].Ncode; 219 222 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 } 223 out[i].M_20 = in[i].Mmin*1000.0; 224 out[i].M_80 = in[i].Mmax*1000.0; 225 } 226 return (out); 227 } 228 229 # define RAW_IMAGE_NAME_LEN 121 225 230 226 231 Image *Image_PS1_V1_ToInternal (Image_PS1_V1 *in, off_t Nvalues, off_t Nalloc) { … … 237 242 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 238 243 239 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 240 out[i].name[120] = 0; // force termination 244 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 245 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 246 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 241 247 242 248 out[i].tzero = in[i].tzero; … … 300 306 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 301 307 302 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 303 out[i].name[120] = 0; // force termination 308 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 309 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 310 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 304 311 305 312 out[i].tzero = in[i].tzero; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_convert_PS1_V2.c
r35162 r37067 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; … … 59 60 } 60 61 61 Measure_PS1_V2 *MeasureInternalTo_PS1_V2 ( Measure *in, off_t Nvalues) {62 Measure_PS1_V2 *MeasureInternalTo_PS1_V2 (Average *ave, Measure *in, off_t Nvalues) { 62 63 63 64 off_t i; … … 67 68 68 69 for (i = 0; i < Nvalues; i++) { 69 out[i].dR = in[i].dR; 70 out[i].dD = in[i].dD; 70 int averef = in[i].averef; 71 72 out[i].dR = 3600.0*(ave[averef].R - in[i].R); 73 out[i].dD = 3600.0*(ave[averef].D - in[i].D); 71 74 out[i].M = in[i].M; 72 75 out[i].Mcal = in[i].Mcal; … … 145 148 out[i].measureOffset = in[i].measureOffset; 146 149 out[i].missingOffset = in[i].missingOffset; 147 out[i]. extendOffset = in[i].extendOffset;150 out[i].refColorBlue = in[i].refColor; 148 151 out[i].flags = in[i].flags; 149 152 out[i].objID = in[i].objID; … … 184 187 out[i].measureOffset = in[i].measureOffset; 185 188 out[i].missingOffset = in[i].missingOffset; 186 out[i]. extendOffset = in[i].extendOffset;189 out[i].refColor = in[i].refColorBlue; 187 190 out[i].flags = in[i].flags; 188 191 out[i].objID = in[i].objID; … … 205 208 out[i].M = in[i].M; 206 209 out[i].dM = in[i].dM; 207 out[i]. Xm = in[i].Xm;210 out[i].Mchisq= in[i].Mchisq; 208 211 out[i].flags = in[i].flags; 209 212 out[i].Ncode = in[i].Ncode; 210 213 out[i].Nused = in[i].Nused; 211 out[i].M _20 = in[i].M_20;212 out[i].M _80 = in[i].M_80;214 out[i].Mmin = in[i].M_20*0.001; 215 out[i].Mmax = in[i].M_80*0.001; 213 216 } 214 217 return (out); … … 225 228 out[i].M = in[i].M; 226 229 out[i].dM = in[i].dM; 227 out[i]. Xm = in[i].Xm;230 out[i].Mchisq= in[i].Mchisq; 228 231 out[i].flags = in[i].flags; 229 232 out[i].Ncode = in[i].Ncode; 230 233 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 } 234 out[i].M_20 = in[i].Mmin*1000.0; 235 out[i].M_80 = in[i].Mmax*1000.0; 236 } 237 return (out); 238 } 239 240 # define RAW_IMAGE_NAME_LEN 121 236 241 237 242 Image *Image_PS1_V2_ToInternal (Image_PS1_V2 *in, off_t Nvalues, off_t Nalloc) { … … 248 253 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 249 254 250 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 251 out[i].name[120] = 0; // force termination 255 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 256 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 257 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 252 258 253 259 out[i].tzero = in[i].tzero; … … 269 275 out[i].DECo = in[i].DECo; 270 276 out[i].Radius = in[i].Radius; 277 out[i].refColorBlue = in[i].refColor; 271 278 272 279 out[i].detection_limit = in[i].detection_limit; … … 310 317 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 311 318 312 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 313 out[i].name[120] = 0; // force termination 319 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 320 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 321 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 314 322 315 323 out[i].tzero = in[i].tzero; … … 331 339 out[i].DECo = in[i].DECo; 332 340 out[i].Radius = in[i].Radius; 341 out[i].refColor = in[i].refColorBlue; 333 342 334 343 out[i].detection_limit = in[i].detection_limit; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_convert_PS1_V3.c
r35162 r37067 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; … … 59 60 } 60 61 61 Measure_PS1_V3 *MeasureInternalTo_PS1_V3 ( Measure *in, off_t Nvalues) {62 Measure_PS1_V3 *MeasureInternalTo_PS1_V3 (Average *ave, Measure *in, off_t Nvalues) { 62 63 63 64 off_t i; … … 67 68 68 69 for (i = 0; i < Nvalues; i++) { 69 out[i].dR = in[i].dR; 70 out[i].dD = in[i].dD; 70 int averef = in[i].averef; 71 72 out[i].dR = 3600.0*(ave[averef].R - in[i].R); 73 out[i].dD = 3600.0*(ave[averef].D - in[i].D); 71 74 out[i].M = in[i].M; 72 75 out[i].Mcal = in[i].Mcal; … … 145 148 out[i].measureOffset = in[i].measureOffset; 146 149 out[i].missingOffset = in[i].missingOffset; 147 out[i]. extendOffset = in[i].extendOffset;150 out[i].refColorBlue = in[i].refColor; 148 151 out[i].flags = in[i].flags; 149 152 out[i].photFlagsUpper = in[i].photFlagsUpper; … … 186 189 out[i].measureOffset = in[i].measureOffset; 187 190 out[i].missingOffset = in[i].missingOffset; 188 out[i]. extendOffset = in[i].extendOffset;191 out[i].refColor = in[i].refColorBlue; 189 192 out[i].flags = in[i].flags; 190 193 out[i].photFlagsUpper = in[i].photFlagsUpper; … … 210 213 out[i].Map = in[i].Map; 211 214 out[i].dM = in[i].dM; 212 out[i]. Xm = in[i].Xm;215 out[i].Mchisq = in[i].Mchisq; 213 216 out[i].flags = in[i].flags; 214 217 out[i].Ncode = in[i].Ncode; 215 218 out[i].Nused = in[i].Nused; 216 out[i].M _20 = in[i].M_20;217 out[i].M _80 = in[i].M_80;219 out[i].Mmin = in[i].M_20*0.001; 220 out[i].Mmax = in[i].M_80*0.001; 218 221 out[i].Mstdev = in[i].Mstdev; 219 222 out[i].ubercalDist = in[i].ubercalDist; … … 233 236 out[i].Map = in[i].Map; 234 237 out[i].dM = in[i].dM; 235 out[i]. Xm = in[i].Xm;238 out[i].Mchisq = in[i].Mchisq; 236 239 out[i].flags = in[i].flags; 237 240 out[i].Ncode = in[i].Ncode; 238 241 out[i].Nused = in[i].Nused; 239 out[i].M_20 = in[i].M _20;240 out[i].M_80 = in[i].M _80;242 out[i].M_20 = in[i].Mmin*1000.0; 243 out[i].M_80 = in[i].Mmax*1000.0; 241 244 out[i].Mstdev = in[i].Mstdev; 242 245 out[i].ubercalDist = in[i].ubercalDist; … … 244 247 return (out); 245 248 } 249 250 # define RAW_IMAGE_NAME_LEN 121 246 251 247 252 Image *Image_PS1_V3_ToInternal (Image_PS1_V3 *in, off_t Nvalues, off_t Nalloc) { … … 258 263 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 259 264 260 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 261 out[i].name[120] = 0; // force termination 265 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 266 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 267 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 262 268 263 269 out[i].tzero = in[i].tzero; … … 279 285 out[i].DECo = in[i].DECo; 280 286 out[i].Radius = in[i].Radius; 287 out[i].refColorBlue = in[i].refColor; 281 288 282 289 out[i].detection_limit = in[i].detection_limit; … … 320 327 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 321 328 322 strncpy (out[i].name, in[i].name, 120); // out[121], in[121] 323 out[i].name[120] = 0; // force termination 329 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN 330 strncpy (out[i].name, in[i].name, DVO_IMAGE_NAME_LEN - 1); 331 out[i].name[DVO_IMAGE_NAME_LEN - 1] = 0; // force termination 324 332 325 333 out[i].tzero = in[i].tzero; … … 341 349 out[i].DECo = in[i].DECo; 342 350 out[i].Radius = in[i].Radius; 351 out[i].refColor = in[i].refColorBlue; 343 352 344 353 out[i].detection_limit = in[i].detection_limit; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_convert_PS1_V4.c
r35162 r37067 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; … … 68 69 } 69 70 70 Measure_PS1_V4 *MeasureInternalTo_PS1_V4 ( Measure *in, off_t Nvalues) {71 Measure_PS1_V4 *MeasureInternalTo_PS1_V4 (Average *ave, Measure *in, off_t Nvalues) { 71 72 72 73 off_t i; … … 76 77 77 78 for (i = 0; i < Nvalues; i++) { 78 out[i].dR = in[i].dR; 79 out[i].dD = in[i].dD; 79 int averef = in[i].averef; 80 81 out[i].dR = 3600.0*(ave[averef].R - in[i].R); 82 out[i].dD = 3600.0*(ave[averef].D - in[i].D); 80 83 out[i].M = in[i].M; 81 84 out[i].Mcal = in[i].Mcal; … … 166 169 out[i].measureOffset = in[i].measureOffset; 167 170 out[i].missingOffset = in[i].missingOffset; 168 out[i]. extendOffset = in[i].extendOffset;171 out[i].refColorBlue = in[i].refColor; 169 172 out[i].flags = in[i].flags; 170 173 out[i].photFlagsUpper = in[i].photFlagsUpper; … … 210 213 out[i].measureOffset = in[i].measureOffset; 211 214 out[i].missingOffset = in[i].missingOffset; 212 out[i]. extendOffset = in[i].extendOffset;215 out[i].refColor = in[i].refColorBlue; 213 216 out[i].flags = in[i].flags; 214 217 out[i].photFlagsUpper = in[i].photFlagsUpper; … … 236 239 out[i].dMkron = in[i].dMkron; 237 240 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;241 out[i].Mchisq = in[i].Mchisq; 242 out[i].FpsfStk = in[i].FluxPSF; 243 out[i].dFpsfStk = in[i].dFluxPSF; 244 out[i].FkronStk = in[i].FluxKron; 245 out[i].dFkronStk = in[i].dFluxKron; 243 246 out[i].flags = in[i].flags; 244 247 out[i].Ncode = in[i].Ncode; 245 248 out[i].Nused = in[i].Nused; 246 out[i].M _20 = in[i].M_20;247 out[i].M _80 = in[i].M_80;249 out[i].Mmin = in[i].M_20*0.001; 250 out[i].Mmax = in[i].M_80*0.001; 248 251 out[i].Mstdev = in[i].Mstdev; 249 252 out[i].ubercalDist = in[i].ubercalDist; … … 266 269 out[i].dMkron = in[i].dMkron; 267 270 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;271 out[i].Mchisq = in[i].Mchisq; 272 out[i].FluxPSF = in[i].FpsfStk; 273 out[i].dFluxPSF = in[i].dFpsfStk; 274 out[i].FluxKron = in[i].FkronStk; 275 out[i].dFluxKron = in[i].dFkronStk; 273 276 out[i].flags = in[i].flags; 274 277 out[i].Ncode = in[i].Ncode; 275 278 out[i].Nused = in[i].Nused; 276 out[i].M_20 = in[i].M _20;277 out[i].M_80 = in[i].M _80;279 out[i].M_20 = in[i].Mmin*1000.0; 280 out[i].M_80 = in[i].Mmax*1000.0; 278 281 out[i].Mstdev = in[i].Mstdev; 279 282 out[i].ubercalDist = in[i].ubercalDist; … … 282 285 return (out); 283 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; … … 481 490 return (out); 482 491 } 492 493 /*** there are some mini dvodbs with the wrong PS1_V4 format (missing Xoff,Yoff / Xfix,Yfix) ************/ 494 495 Measure *Measure_PS1_V4alt_ToInternal (Average *ave, Measure_PS1_V4alt *in, off_t Nvalues) { 496 497 off_t i; 498 Measure *out; 499 500 ALLOCATE_ZERO (out, Measure, Nvalues); 501 502 for (i = 0; i < Nvalues; i++) { 503 dvo_measure_init (&out[i]); 504 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; 508 out[i].M = in[i].M; 509 out[i].Mcal = in[i].Mcal; 510 out[i].Map = in[i].Map; 511 out[i].Mkron = in[i].Mkron; 512 out[i].dMkron = in[i].dMkron; 513 out[i].dM = in[i].dM; 514 out[i].dMcal = in[i].dMcal; 515 out[i].dt = in[i].dt; 516 out[i].FluxPSF = in[i].FluxPSF; 517 out[i].dFluxPSF = in[i].dFluxPSF; 518 out[i].FluxKron = in[i].FluxKron; 519 out[i].dFluxKron = in[i].dFluxKron; 520 out[i].airmass = in[i].airmass; 521 out[i].az = in[i].az; 522 out[i].Xccd = in[i].Xccd; 523 out[i].Yccd = in[i].Yccd; 524 out[i].Xfix = in[i].Xccd; 525 out[i].Yfix = in[i].Yccd; 526 out[i].Sky = in[i].Sky; 527 out[i].dSky = in[i].dSky; 528 out[i].t = in[i].t; 529 out[i].t_msec = in[i].t_msec; 530 out[i].averef = in[i].averef; 531 out[i].detID = in[i].detID; 532 out[i].imageID = in[i].imageID; 533 out[i].objID = in[i].objID; 534 out[i].catID = in[i].catID; 535 out[i].extID = in[i].extID; 536 out[i].psfQF = in[i].psfQF; 537 out[i].psfQFperf = in[i].psfQFperf; 538 out[i].psfChisq = in[i].psfChisq; 539 out[i].psfNdof = in[i].psfNdof; 540 out[i].psfNpix = in[i].psfNpix; 541 out[i].crNsigma = in[i].crNsigma; 542 out[i].extNsigma = in[i].extNsigma; 543 out[i].FWx = in[i].FWx; 544 out[i].FWy = in[i].FWy; 545 out[i].theta = in[i].theta; 546 out[i].Mxx = in[i].Mxx; 547 out[i].Mxy = in[i].Mxy; 548 out[i].Myy = in[i].Myy; 549 out[i].dXccd = in[i].dXccd; 550 out[i].dYccd = in[i].dYccd; 551 out[i].dRsys = in[i].dRsys; 552 out[i].posangle = in[i].posangle; 553 out[i].pltscale = in[i].pltscale; 554 out[i].photcode = in[i].photcode; 555 out[i].dbFlags = in[i].dbFlags; 556 out[i].photFlags = in[i].photFlags; 557 } 558 return (out); 559 } 560 561 // XXX note that there are 2 bad versions of PS1_V4 : the other one does have have PSF_QF_PERFECT, but has PAD instead 562 int gfits_convert_Measure_PS1_V4alt (Measure_PS1_V4alt *data, off_t size, off_t nitems) { 563 564 off_t i; 565 unsigned char *byte, tmp; 566 567 if (size != 176) { 568 fprintf (stderr, "WARNING: mismatch in data types Measure_PS1_V4alt: "OFF_T_FMT" vs %d\n", size, 176); 569 return (FALSE); 570 } 571 572 /* provide initial values to avoid compiler warnings for non-BYTE_SWAP arch */ 573 i = tmp = 0; 574 byte = NULL; 575 576 # ifdef BYTE_SWAP 577 byte = (unsigned char *) data; 578 for (i = 0; i < nitems; i++, byte += 176) { 579 /** BYTE SWAP **/ 580 SWAP_WORD (0); // D_RA 581 SWAP_WORD (4); // D_DEC 582 SWAP_WORD (8); // MAG 583 SWAP_WORD (12); // M_CAL 584 SWAP_WORD (16); // M_APER 585 SWAP_WORD (20); // M_KRON 586 SWAP_WORD (24); // M_KRON_ERR 587 SWAP_WORD (28); // MAG_ERR 588 SWAP_WORD (32); // MAG_CAL_ERR 589 SWAP_WORD (36); // M_TIME 590 SWAP_WORD (40); // FLUX_PSF 591 SWAP_WORD (44); // FLUX_PSF_ERR 592 SWAP_WORD (48); // FLUX_KRON 593 SWAP_WORD (52); // FLUX_KRON_ERR 594 SWAP_WORD (56); // AIRMASS 595 SWAP_WORD (60); // AZ 596 SWAP_WORD (64); // X_CCD 597 SWAP_WORD (68); // Y_CCD 598 SWAP_WORD (72); // SKY_FLUX 599 SWAP_WORD (76); // SKY_FLUX_ERR 600 SWAP_WORD (80); // TIME 601 SWAP_WORD (84); // AVE_REF 602 SWAP_WORD (88); // DET_ID 603 SWAP_WORD (92); // IMAGE_ID 604 SWAP_WORD (96); // OBJ_ID 605 SWAP_WORD (100); // CAT_ID 606 SWAP_DBLE (104); // EXT_ID 607 SWAP_WORD (112); // PSF_QF 608 SWAP_WORD (116); // PSF_QF_PERFECT 609 SWAP_WORD (120); // PSF_CHISQ 610 SWAP_WORD (124); // PSF_NDOF 611 SWAP_WORD (128); // PSF_NPIX 612 SWAP_WORD (132); // CR_NSIGMA 613 SWAP_WORD (136); // EXT_NSIGMA 614 SWAP_BYTE (140); // FWHM_MAJOR 615 SWAP_BYTE (142); // FWHM_MINOR 616 SWAP_BYTE (144); // PSF_THETA 617 SWAP_BYTE (146); // MXX 618 SWAP_BYTE (148); // MXY 619 SWAP_BYTE (150); // MYY 620 SWAP_BYTE (152); // TIME_MSEC 621 SWAP_BYTE (154); // PHOTCODE 622 SWAP_BYTE (156); // X_CCD_ERR 623 SWAP_BYTE (158); // Y_CCD_ERR 624 SWAP_BYTE (160); // POS_SYS_ERR 625 SWAP_BYTE (162); // POSANGLE 626 SWAP_WORD (164); // PLTSCALE 627 SWAP_WORD (168); // DB_FLAGS 628 SWAP_WORD (172); // PHOT_FLAGS 629 } 630 # endif 631 632 return (TRUE); 633 } 634 635 /*** add test of EXTNAME and header-defined columns? ***/ 636 /* return internal structure representation */ 637 Measure_PS1_V4alt *gfits_table_get_Measure_PS1_V4alt (FTable *ftable, off_t *Ndata, char *swapped) { 638 639 int Ncols; 640 Measure_PS1_V4alt *data; 641 642 Ncols = ftable[0].header[0].Naxis[0]; 643 if (Ncols != 176) { 644 fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, 176); 645 return NULL; 646 } 647 648 *Ndata = ftable[0].header[0].Naxis[1]; 649 data = (Measure_PS1_V4alt *) ftable[0].buffer; 650 if ((swapped == NULL) || (*swapped == FALSE)) { 651 if (!gfits_convert_Measure_PS1_V4alt (data, sizeof (Measure_PS1_V4alt), *Ndata)) { 652 return NULL; 653 } 654 gfits_table_scale_data (ftable); 655 if (swapped != NULL) *swapped = TRUE; 656 } 657 return (data); 658 } 659 660 // 'primary' is needed to conform with the API for Loneos and Elixir, but is not used 661 Average *Average_PS1_V4alt_ToInternal (Average_PS1_V4alt *in, off_t Nvalues) { 662 663 off_t i; 664 Average *out; 665 666 ALLOCATE_ZERO (out, Average, Nvalues); 667 668 for (i = 0; i < Nvalues; i++) { 669 dvo_average_init (&out[i]); 670 671 out[i].R = in[i].R; 672 out[i].D = in[i].D; 673 out[i].dR = in[i].dR; 674 out[i].dD = in[i].dD; 675 out[i].uR = in[i].uR; 676 out[i].uD = in[i].uD; 677 out[i].duR = in[i].duR; 678 out[i].duD = in[i].duD; 679 out[i].P = in[i].P; 680 out[i].dP = in[i].dP; 681 out[i].ChiSqAve = in[i].ChiSqAve; 682 out[i].ChiSqPM = in[i].ChiSqPM; 683 out[i].ChiSqPar = in[i].ChiSqPar; 684 out[i].Tmean = in[i].Tmean; 685 out[i].Trange = in[i].Trange; 686 out[i].Npos = in[i].Npos; 687 out[i].Nmeasure = in[i].Nmeasure; 688 out[i].Nmissing = in[i].Nmissing; 689 out[i].Nextend = in[i].Nextend; 690 out[i].measureOffset = in[i].measureOffset; 691 out[i].missingOffset = in[i].missingOffset; 692 out[i].refColorBlue = in[i].refColor; 693 out[i].flags = in[i].flags; 694 out[i].photFlagsUpper = in[i].photFlagsUpper; 695 out[i].photFlagsLower = in[i].photFlagsLower; 696 out[i].objID = in[i].objID; 697 out[i].catID = in[i].catID; 698 out[i].extID = in[i].extID; 699 } 700 return (out); 701 } 702 703 /******/ 704 705 int gfits_convert_Average_PS1_V4alt (Average_PS1_V4alt *data, off_t size, off_t nitems) { 706 707 off_t i; 708 unsigned char *byte, tmp; 709 710 if (size != 120) { 711 fprintf (stderr, "WARNING: mismatch in data types Average_PS1_V4alt: "OFF_T_FMT" vs %d\n", size, 120); 712 return (FALSE); 713 } 714 715 /* provide initial values to avoid compiler warnings for non-BYTE_SWAP arch */ 716 i = tmp = 0; 717 byte = NULL; 718 719 # ifdef BYTE_SWAP 720 byte = (unsigned char *) data; 721 for (i = 0; i < nitems; i++, byte += 120) { 722 /** BYTE SWAP **/ 723 SWAP_DBLE (0); // RA 724 SWAP_DBLE (8); // DEC 725 SWAP_WORD (16); // RA_ERR 726 SWAP_WORD (20); // DEC_ERR 727 SWAP_WORD (24); // U_RA 728 SWAP_WORD (28); // U_DEC 729 SWAP_WORD (32); // V_RA_ERR 730 SWAP_WORD (36); // V_DEC_ERR 731 SWAP_WORD (40); // PAR 732 SWAP_WORD (44); // PAR_ERR 733 SWAP_WORD (48); // CHISQ_POS 734 SWAP_WORD (52); // CHISQ_PM 735 SWAP_WORD (56); // CHISQ_PAP 736 SWAP_WORD (60); // MEAN_EPOCH 737 SWAP_WORD (64); // TIME_RANGE 738 SWAP_WORD (68); // SIGMA 739 SWAP_BYTE (72); // NUMBER_POS 740 SWAP_BYTE (74); // NMEASURE 741 SWAP_BYTE (76); // NMISSING 742 SWAP_BYTE (78); // NEXTEND 743 SWAP_WORD (80); // OFF_MEASURE 744 SWAP_WORD (84); // OFF_MISSING 745 SWAP_WORD (88); // OFF_EXTEND 746 SWAP_WORD (92); // FLAGS 747 SWAP_WORD (96); // PHOTFLAGS_U 748 SWAP_WORD (100); // PHOTFLAGS_L 749 SWAP_WORD (104); // OBJ_ID 750 SWAP_WORD (108); // CAT_ID 751 SWAP_DBLE (112); // EXT_ID 752 } 753 # endif 754 755 return (TRUE); 756 } 757 758 /*** add test of EXTNAME and header-defined columns? ***/ 759 /* return internal structure representation */ 760 Average_PS1_V4alt *gfits_table_get_Average_PS1_V4alt (FTable *ftable, off_t *Ndata, char *swapped) { 761 762 int Ncols; 763 Average_PS1_V4alt *data; 764 765 Ncols = ftable[0].header[0].Naxis[0]; 766 if (Ncols != 120) { 767 fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, 120); 768 return NULL; 769 } 770 771 *Ndata = ftable[0].header[0].Naxis[1]; 772 data = (Average_PS1_V4alt *) ftable[0].buffer; 773 if ((swapped == NULL) || (*swapped == FALSE)) { 774 if (!gfits_convert_Average_PS1_V4alt (data, sizeof (Average_PS1_V4alt), *Ndata)) { 775 return NULL; 776 } 777 gfits_table_scale_data (ftable); 778 if (swapped != NULL) *swapped = TRUE; 779 } 780 return (data); 781 } 782 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_convert_elixir.c
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_convert_loneos.c
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_image.c
r35162 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_image_raw.c
r34260 r37067 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/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_photcode_ops.c
r34844 r37067 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++) { … … 169 202 } 170 203 204 // returns Nsec if code is PRI/SEC, else -1 171 205 int GetPhotcodeNsec (int code) { 172 206 … … 221 255 222 256 /******** photometry conversion functions *********/ 223 float PhotInst (Measure *measure) { 224 225 int Np; 226 float M; 227 228 Np = photcodes[0].hashcode[measure[0].photcode]; 257 float PhotInst (Measure *measure, dvoMagClassType class) { 258 259 int Np = photcodes[0].hashcode[measure[0].photcode]; 229 260 if (Np == -1) return (NAN); 230 231 if (photcodes[0].code[Np].type == PHOT_REF) { 232 M = measure[0].M; 233 return (M); 234 } 235 236 M = measure[0].M - measure[0].dt - ZERO_POINT; 237 238 return (M); 239 240 } 241 242 float PhotCat (Measure *measure) { 243 244 int Np; 245 float Mcat; 246 PhotCode *code; 247 248 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]; 249 288 if (Np == -1) return (NAN); 250 251 if (photcodes[0].code[Np].type == PHOT_REF) { 252 Mcat = measure[0].M; 253 return (Mcat); 254 } 255 code = &photcodes[0].code[Np]; 256 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; 257 310 258 311 return (Mcat); 259 312 } 260 313 261 float PhotAper (Measure *measure) { 262 263 int Np; 264 float Mcat; 265 PhotCode *code; 266 267 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]; 268 317 if (Np == -1) return (NAN); 269 270 if (photcodes[0].code[Np].type == PHOT_REF) { 271 Mcat = measure[0].Map; 272 return (Mcat); 273 } 274 code = &photcodes[0].code[Np]; 275 Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 276 277 return (Mcat); 278 } 279 280 float PhotAperInst (Measure *measure) { 281 282 int Np; 283 float Minst; 284 285 Np = photcodes[0].hashcode[measure[0].photcode]; 286 if (Np == -1) return (NAN); 287 288 if (photcodes[0].code[Np].type == PHOT_REF) { 289 Minst = measure[0].Map; 290 return (Minst); 291 } 292 Minst = measure[0].Map - measure[0].dt - ZERO_POINT; 293 294 return (Minst); 295 } 296 297 float PhotKron (Measure *measure) { 298 299 int Np; 300 float Mcat; 301 PhotCode *code; 302 303 Np = photcodes[0].hashcode[measure[0].photcode]; 304 if (Np == -1) return (NAN); 305 306 if (photcodes[0].code[Np].type == PHOT_REF) { 307 Mcat = measure[0].Mkron; 308 return (Mcat); 309 } 310 code = &photcodes[0].code[Np]; 311 Mcat = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 312 313 return (Mcat); 314 } 315 316 float PhotKronInst (Measure *measure) { 317 318 int Np; 319 float Minst; 320 321 Np = photcodes[0].hashcode[measure[0].photcode]; 322 if (Np == -1) return (NAN); 323 324 if (photcodes[0].code[Np].type == PHOT_REF) { 325 Minst = measure[0].Mkron; 326 return (Minst); 327 } 328 Minst = measure[0].Mkron - measure[0].dt - ZERO_POINT; 329 330 return (Minst); 331 } 332 333 float PhotSys (Measure *measure, Average *average, SecFilt *secfilt) { 334 335 int i, Np; 336 float Mcat, Mcol, Msys, mc, Mc; 337 PhotCode *code; 338 339 Np = photcodes[0].hashcode[measure[0].photcode]; 340 if (Np == -1) return (NAN); 341 342 if (photcodes[0].code[Np].type == PHOT_REF) { 343 Msys = measure[0].M; 344 return (Msys); 345 } 346 code = &photcodes[0].code[Np]; 347 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; 348 338 349 339 /* for DEP, color must be made of PRI/SEC */ 350 mc = PhotColorForCode (average, secfilt, NULL, code);340 float mc = PhotColorForCode (average, secfilt, NULL, code); 351 341 if (isnan(mc)) return (Mcat); 352 mc = mc - SCALE*code[0].dX; 353 354 Mc = mc; 355 Mcol = 0; 342 mc -= SCALE*code[0].dX; 343 344 int i = 0; 345 double Mc = mc; 346 float Mcol = 0; 356 347 for (i = 0; i < code[0].Nc; i++) { 357 348 Mcol += code[0].X[i]*Mc; 358 349 Mc *= mc; 359 350 } 360 Msys = Mcat + Mcol;351 float Msys = Mcat + Mcol; 361 352 return (Msys); 362 353 } 354 355 float PhotRel (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class) { 356 357 int Np = photcodes[0].hashcode[measure[0].photcode]; 358 if (Np == -1) return (NAN); 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; 379 380 /* for DEP, color must be made of PRI/SEC */ 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; 524 for (i = 0; i < code[0].Nc; i++) { 525 Mcol += code[0].X[i]*Mc; 526 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 527 } 528 Mref += Mcol; 529 return (Mref); 530 } 531 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); 615 } 616 617 /********************* other support functions ********************************/ 363 618 364 619 float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt) { … … 381 636 } 382 637 383 float PhotRel (Measure *measure, Average *average, SecFilt *secfilt) {384 385 int i, Np;386 float Mcat, Mcol, Mrel, mc, Mc;387 PhotCode *code;388 389 Np = photcodes[0].hashcode[measure[0].photcode];390 if (Np == -1) return (NAN);391 392 if (photcodes[0].code[Np].type == PHOT_REF) {393 Mcat = measure[0].M;394 return (Mcat);395 }396 code = &photcodes[0].code[Np];397 Mrel = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal;398 399 /* for DEP, color must be made of PRI/SEC */400 mc = PhotColorForCode (average, secfilt, NULL, code);401 if (isnan(mc)) return (Mrel);402 mc = mc - SCALE*code[0].dX;403 404 Mc = mc;405 Mcol = 0;406 for (i = 0; i < code[0].Nc; i++) {407 Mcol += code[0].X[i]*Mc;408 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */409 }410 Mrel += Mcol;411 return (Mrel);412 }413 414 /* return calibrated magnitude from measure for given photcode */415 float PhotCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code) {416 417 int i, Np;418 float Mcal, Mrel, Mcol, mc, Mc;419 420 if (code == NULL) return NAN;421 422 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */423 Np = photcodes[0].hashcode[thisone[0].photcode];424 if (Np == -1) return (NAN);425 426 if (photcodes[0].code[Np].type == PHOT_REF) {427 Mrel = thisone[0].M;428 return (Mrel);429 }430 if (code[0].code != photcodes[0].code[Np].equiv) return (NAN);431 432 Mcal = PhotRel (thisone, average, secfilt) + SCALE*code[0].C;433 434 mc = PhotColorForCode (average, secfilt, measure, code);435 if (isnan(mc)) return (Mcal);436 mc = mc - SCALE*code[0].dX;437 438 Mc = mc;439 Mcol = 0;440 for (i = 0; i < code[0].Nc; i++) {441 Mcol += code[0].X[i]*Mc;442 Mc *= mc;443 }444 Mcal += Mcol;445 return (Mcal);446 }447 448 638 /* color term may not use DEP magnitude */ 639 // currently only returns the PSF color 449 640 float PhotColorForCode (Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code) { 450 641 … … 496 687 } 497 688 498 /* return calibrated magnitude from average/secfilt for given photcode */499 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) {500 501 int i, Ns;502 float Mave, Mref, Mcol, mc;503 double Mc;504 505 if (code == NULL) return NAN;506 507 Ns = photcodes[0].hashNsec[code[0].code];508 Mave = (Ns == -1) ? NAN : secfilt[Ns].M;509 Mref = Mave + SCALE*code[0].C;510 511 mc = PhotColorForCode (average, secfilt, measure, code);512 if (isnan(mc)) return (Mref);513 mc = mc - SCALE*code[0].dX;514 515 Mc = mc;516 Mcol = 0;517 for (i = 0; i < code[0].Nc; i++) {518 Mcol += code[0].X[i]*Mc;519 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */520 }521 Mref += Mcol;522 return (Mref);523 }524 525 /***/526 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt) {527 528 int Ns;529 float Mave;530 531 if (code == NULL) return NAN;532 533 Ns = photcodes[0].hashNsec[code[0].code];534 Mave = (Ns == -1) ? NAN : secfilt[Ns].M;535 return (Mave);536 }537 538 float PhotdM (PhotCode *code, Average *average, SecFilt *secfilt) {539 540 int Ns;541 float dM;542 543 if (code == NULL) return NAN;544 545 Ns = photcodes[0].hashNsec[code[0].code];546 dM = (Ns == -1) ? NAN : secfilt[Ns].dM;547 return (dM);548 }549 550 689 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt) { 551 690 … … 560 699 } 561 700 562 float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt) {563 564 int Ns;565 float Mkron;566 567 if (code == NULL) return NAN;568 569 Ns = photcodes[0].hashNsec[code[0].code];570 Mkron = (Ns == -1) ? NAN : secfilt[Ns].Mkron;571 return (Mkron);572 }573 574 float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt) {575 576 int Ns;577 float dMkron;578 579 if (code == NULL) return NAN;580 581 Ns = photcodes[0].hashNsec[code[0].code];582 dMkron = (Ns == -1) ? NAN : secfilt[Ns].dMkron;583 return (dMkron);584 }585 586 701 float PhotAveFluxPSF (PhotCode *code, Average *average, SecFilt *secfilt) { 587 702 … … 592 707 593 708 Ns = photcodes[0].hashNsec[code[0].code]; 594 Fpsf = (Ns == -1) ? NAN : secfilt[Ns].F luxPSF;709 Fpsf = (Ns == -1) ? NAN : secfilt[Ns].FpsfStk; 595 710 return (Fpsf); 596 711 } … … 604 719 605 720 Ns = photcodes[0].hashNsec[code[0].code]; 606 dFpsf = (Ns == -1) ? NAN : secfilt[Ns].dF luxPSF;721 dFpsf = (Ns == -1) ? NAN : secfilt[Ns].dFpsfStk; 607 722 return (dFpsf); 608 723 } … … 616 731 617 732 Ns = photcodes[0].hashNsec[code[0].code]; 618 Fkron = (Ns == -1) ? NAN : secfilt[Ns].F luxKron;733 Fkron = (Ns == -1) ? NAN : secfilt[Ns].FkronStk; 619 734 return (Fkron); 620 735 } … … 628 743 629 744 Ns = photcodes[0].hashNsec[code[0].code]; 630 dFkron = (Ns == -1) ? NAN : secfilt[Ns].dF luxKron;745 dFkron = (Ns == -1) ? NAN : secfilt[Ns].dFkronStk; 631 746 return (dFkron); 632 747 } 633 748 634 float PhotM 20(PhotCode *code, Average *average, SecFilt *secfilt) {749 float PhotMmin (PhotCode *code, Average *average, SecFilt *secfilt) { 635 750 636 751 int Ns; 637 float M 20;752 float Mmin; 638 753 639 754 if (code == NULL) return NAN; 640 755 641 756 Ns = photcodes[0].hashNsec[code[0].code]; 642 M 20 = (Ns == -1) ? NAN : 0.001*secfilt[Ns].M_20;643 return (M 20);644 } 645 646 float PhotM 80(PhotCode *code, Average *average, SecFilt *secfilt) {757 Mmin = (Ns == -1) ? NAN : secfilt[Ns].Mmin; 758 return (Mmin); 759 } 760 761 float PhotMmax (PhotCode *code, Average *average, SecFilt *secfilt) { 647 762 648 763 int Ns; 649 float M 80;764 float Mmax; 650 765 651 766 if (code == NULL) return NAN; 652 767 653 768 Ns = photcodes[0].hashNsec[code[0].code]; 654 M 80 = (Ns == -1) ? NAN : 0.001*secfilt[Ns].M_80;655 return (M 80);769 Mmax = (Ns == -1) ? NAN : secfilt[Ns].Mmax; 770 return (Mmax); 656 771 } 657 772 … … 680 795 } 681 796 682 // X XX return NAN or NAN_S_SHORT? (secfilt->Xm is short)797 // Xm is now (2014.07.03) stored as the chisq except in dvo formats which use as short 683 798 float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt) { 684 799 685 800 int Ns; 686 short Mi;687 801 float Xm; 688 802 … … 690 804 691 805 Ns = photcodes[0].hashNsec[code[0].code]; 692 Mi = (Ns == -1) ? NAN : secfilt[Ns].Xm; 693 Xm = (isnan(Mi)) ? -1.0 : pow (10.0, 0.01*Mi); 806 Xm = (Ns == -1) ? NAN : secfilt[Ns].Mchisq; 694 807 return (Xm); 695 808 } … … 741 854 } 742 855 743 /******** alternate photometry conversion functions using MeasureTiny and AverageTiny *********/ 744 float PhotInstTiny (MeasureTiny *measure) { 745 746 int Np; 747 float M; 748 749 Np = photcodes[0].hashcode[measure[0].photcode]; 856 float MagToFlux (float Mag) { 857 float Flux = pow(10.0, -0.4*(Mag)); 858 return (Flux); 859 } 860 861 /** flux conversion *******************************************************************/ 862 float PhotFluxInst (Measure *measure, dvoMagClassType class) { 863 864 float Moff = - measure[0].dt - ZERO_POINT; 865 float Finst = NAN; 866 switch (class) { 867 case MAG_CLASS_PSF: 868 Finst = isnan (measure[0].FluxPSF) ? MagToFlux(measure[0].M + Moff) : measure[0].FluxPSF; 869 break; 870 case MAG_CLASS_KRON: 871 Finst = isnan (measure[0].FluxKron) ? MagToFlux(measure[0].Mkron + Moff) : measure[0].FluxKron; 872 break; 873 case MAG_CLASS_APER: 874 Finst = isnan (measure[0].FluxAp) ? MagToFlux(measure[0].Map + Moff) : measure[0].FluxAp; 875 break; 876 default: 877 break; 878 } 879 return (Finst); 880 } 881 882 // returns Jy fluxes assuming mag in AB? (needs an extra AP factor, right?) 883 float PhotFluxCat (Measure *measure, dvoMagClassType class) { 884 885 int Np = photcodes[0].hashcode[measure[0].photcode]; 750 886 if (Np == -1) return (NAN); 751 752 if (photcodes[0].code[Np].type == PHOT_REF) { 753 M = measure[0].M; 754 return (M); 755 } 756 757 M = measure[0].M - measure[0].dt - ZERO_POINT; 758 759 return (M); 760 761 } 762 763 float PhotCatTiny (MeasureTiny *measure) { 764 765 int Np; 766 float Mcat; 767 PhotCode *code; 768 769 Np = photcodes[0].hashcode[measure[0].photcode]; 887 PhotCode *code = &photcodes[0].code[Np]; 888 889 // mag_AB = -2.5 log (flux_cgs) - 48.6 (by definition) [~Vega flux in V-band] 890 // flux_Jy = flux_cgs * 10^23 891 // -2.5 log (flux_cgs) = -2.5 log (flux_Jy * 10^-23) = -2.5 log (flux_Jy) + 2.5*23 892 893 // from these we get: 894 // mag_AB = -2.5 log (flux_Jy) + 8.9 895 // log (flux_Jy) = -0.4*mag_AB + 3.56 896 897 // mag_AB = mag_inst + ZP 898 899 // log(flux_Jy) = -0.4*mag_inst -0.4*ZP + 3.56 900 // mag_inst = -2.5 log (flux_Jy) - ZP + 8.9 901 902 // log (flux_Jy) = -0.4*(mag_inst + ZP - 8.9) 903 904 // -2.5 log (flux_inst) = -2.5 log (flux_Jy) - ZP + 8.9 905 // log (flux_inst) = log (flux_Jy) + 0.4 ZP - 3.56 906 // flux_inst = flux_Jy * 10^(0.4*ZP - 3.56) 907 // flux_Jy = flux_inst * 10^(3.56 - 0.4*ZP) = flux_inst * zpFactor 908 // flux_Jy = flux_inst * 3630.8 * 10^(-0.4*ZP) 909 910 // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux 911 float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 912 float Moff = Mcal - ZERO_POINT + 8.9; 913 float Foff = 3630.8 * MagToFlux(Mcal); 914 float Fcat = NAN; 915 switch (class) { 916 case MAG_CLASS_PSF: 917 Fcat = isnan (measure[0].FluxPSF) ? MagToFlux(measure[0].M + Moff) : measure[0].FluxPSF * Foff; 918 break; 919 case MAG_CLASS_KRON: 920 Fcat = isnan (measure[0].FluxKron) ? MagToFlux(measure[0].Mkron + Moff) : measure[0].FluxKron * Foff; 921 break; 922 case MAG_CLASS_APER: 923 Fcat = isnan (measure[0].FluxAp) ? MagToFlux(measure[0].Map + Moff) : measure[0].FluxAp * Foff; 924 break; 925 default: 926 break; 927 } 928 return (Fcat); 929 } 930 931 // corrected for color trends 932 float PhotFluxSys (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class) { 933 934 int Np = photcodes[0].hashcode[measure[0].photcode]; 770 935 if (Np == -1) return (NAN); 771 772 if (photcodes[0].code[Np].type == PHOT_REF) { 773 Mcat = measure[0].M; 774 return (Mcat); 775 } 776 code = &photcodes[0].code[Np]; 777 Mcat = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 778 779 return (Mcat); 780 } 781 782 # if (0) 783 float PhotAperTiny (MeasureTiny *measure) { 784 785 int Np; 786 float Mcat; 787 PhotCode *code; 788 789 Np = photcodes[0].hashcode[measure[0].photcode]; 790 if (Np == -1) return (NAN); 791 792 if (photcodes[0].code[Np].type == PHOT_REF) { 793 Mcat = measure[0].Map; 794 return (Mcat); 795 } 796 code = &photcodes[0].code[Np]; 797 Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 798 799 return (Mcat); 800 } 801 # endif 802 803 float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt) { 804 805 int i, Np; 806 float Mcat, Mcol, Msys, mc, Mc; 807 PhotCode *code; 808 809 Np = photcodes[0].hashcode[measure[0].photcode]; 810 if (Np == -1) return (NAN); 811 812 if (photcodes[0].code[Np].type == PHOT_REF) { 813 Msys = measure[0].M; 814 return (Msys); 815 } 816 code = &photcodes[0].code[Np]; 817 Mcat = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 818 819 /* for DEP, color must be made of PRI/SEC */ 820 mc = PhotColorForCodeTiny (average, secfilt, NULL, code); 821 if (isnan(mc)) return (Mcat); 822 mc = mc - SCALE*code[0].dX; 823 824 Mc = mc; 825 Mcol = 0; 936 PhotCode *code = &photcodes[0].code[Np]; 937 938 // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux 939 float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 940 float Moff = Mcal - ZERO_POINT + 8.9; 941 float Foff = 3630.8 * MagToFlux(Mcal); 942 float Fcat = NAN; 943 switch (class) { 944 case MAG_CLASS_PSF: 945 Fcat = isnan (measure[0].FluxPSF) ? MagToFlux(measure[0].M + Moff) : measure[0].FluxPSF * Foff; 946 break; 947 case MAG_CLASS_KRON: 948 Fcat = isnan (measure[0].FluxKron) ? MagToFlux(measure[0].Mkron + Moff) : measure[0].FluxKron * Foff; 949 break; 950 case MAG_CLASS_APER: 951 Fcat = isnan (measure[0].FluxAp) ? MagToFlux(measure[0].Map + Moff) : measure[0].FluxAp * Foff; 952 break; 953 default: 954 break; 955 } 956 if (isnan(Fcat)) return (NAN); 957 958 // find the relevant color 959 float mc = PhotColorForCode (average, secfilt, NULL, code); 960 if (isnan(mc)) return (Fcat); 961 mc -= SCALE*code[0].dX; 962 963 // find the color correction in mags 964 int i = 0; 965 double Mc = mc; 966 float Mcol = 0; 826 967 for (i = 0; i < code[0].Nc; i++) { 827 968 Mcol += code[0].X[i]*Mc; 828 969 Mc *= mc; 829 970 } 830 Msys = Mcat + Mcol; 831 return (Msys); 832 } 833 834 float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt) { 835 836 int i, Np; 837 float Mcat, Mcol, Mrel, mc, Mc; 838 PhotCode *code; 839 840 Np = photcodes[0].hashcode[measure[0].photcode]; 971 float Fcol = MagToFlux (Mcol); 972 973 float Fsys = Fcat * Fcol; 974 return (Fsys); 975 } 976 977 float PhotFluxRel (Measure *measure, Average *average, SecFilt *secfilt, dvoMagClassType class) { 978 979 int Np = photcodes[0].hashcode[measure[0].photcode]; 841 980 if (Np == -1) return (NAN); 842 843 if (photcodes[0].code[Np].type == PHOT_REF) { 844 Mcat = measure[0].M; 845 return (Mcat); 846 } 847 code = &photcodes[0].code[Np]; 848 Mrel = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 981 PhotCode *code = &photcodes[0].code[Np]; 982 983 // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux 984 float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 985 float Moff = Mcal - ZERO_POINT + 8.9; 986 float Foff = 3630.8 * MagToFlux(Mcal); 987 float Fcat = NAN; 988 switch (class) { 989 case MAG_CLASS_PSF: 990 Fcat = isnan (measure[0].FluxPSF) ? MagToFlux(measure[0].M + Moff) : measure[0].FluxPSF * Foff; 991 break; 992 case MAG_CLASS_KRON: 993 Fcat = isnan (measure[0].FluxKron) ? MagToFlux(measure[0].Mkron + Moff) : measure[0].FluxKron * Foff; 994 break; 995 case MAG_CLASS_APER: 996 Fcat = isnan (measure[0].FluxAp) ? MagToFlux(measure[0].Map + Moff) : measure[0].FluxAp * Foff; 997 break; 998 default: 999 break; 1000 } 1001 if (isnan(Fcat)) return (NAN); 849 1002 850 1003 /* for DEP, color must be made of PRI/SEC */ 851 mc = PhotColorForCodeTiny (average, secfilt, NULL, code); 852 if (isnan(mc)) return (Mrel); 853 mc = mc - SCALE*code[0].dX; 854 855 Mc = mc; 856 Mcol = 0; 1004 float mc = PhotColorForCode (average, secfilt, NULL, code); 1005 if (isnan(mc)) return (Fcat); 1006 mc -= SCALE*code[0].dX; 1007 1008 double Mc = mc; 1009 float Mcol = 0; 1010 int i = 0; 1011 for (i = 0; i < code[0].Nc; i++) { 1012 Mcol += code[0].X[i]*Mc; 1013 Mc *= mc; 1014 } 1015 float Fcol = MagToFlux (Mcol); 1016 1017 float Frel = Fcat * Fcol; 1018 return (Frel); 1019 } 1020 1021 /* return calibrated magnitude from measure for given photcode */ 1022 float PhotFluxCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code, dvoMagClassType class) { 1023 1024 int i; 1025 1026 if (code == NULL) return NAN; 1027 1028 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 1029 int Np = photcodes[0].hashcode[thisone[0].photcode]; 1030 if (Np == -1) return (NAN); 1031 PhotCode *myCode = &photcodes[0].code[Np]; 1032 1033 if (code->code != myCode->equiv) return (NAN); 1034 1035 float Frel = PhotFluxRel (thisone, average, secfilt, class) + SCALE*code[0].C; 1036 1037 // get the relevant color term 1038 float mc = PhotColorForCode (average, secfilt, measure, code); 1039 if (isnan(mc)) return (Frel); 1040 mc -= SCALE*code[0].dX; 1041 1042 // get the corresponding color correction in mags, convert to flux 1043 double Mc = mc; 1044 float Mcol = 0; 1045 for (i = 0; i < code[0].Nc; i++) { 1046 Mcol += code[0].X[i]*Mc; 1047 Mc *= mc; 1048 } 1049 float Fcol = MagToFlux (Mcol); 1050 1051 float Fcal = Frel * Fcol; 1052 return (Fcal); 1053 } 1054 1055 /***/ 1056 float PhotFluxAve (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) { 1057 1058 if (code == NULL) return NAN; 1059 1060 int Ns = photcodes[0].hashNsec[code[0].code]; 1061 if (Ns == -1) return (NAN); 1062 1063 float Fave = NAN; 1064 switch (source) { 1065 case MAG_SRC_CHP: 1066 switch (class) { 1067 case MAG_CLASS_PSF: 1068 Fave = MagToFlux(secfilt[Ns].M); 1069 break; 1070 case MAG_CLASS_KRON: 1071 Fave = MagToFlux(secfilt[Ns].Mkron); 1072 break; 1073 case MAG_CLASS_APER: 1074 Fave = MagToFlux(secfilt[Ns].Map); 1075 break; 1076 default: 1077 break; 1078 } 1079 break; 1080 case MAG_SRC_WRP: 1081 switch (class) { 1082 case MAG_CLASS_PSF: 1083 Fave = isnan (secfilt[Ns].FpsfWrp) ? MagToFlux(secfilt[Ns].MpsfWrp) : secfilt[Ns].FpsfWrp; 1084 break; 1085 case MAG_CLASS_KRON: 1086 Fave = isnan (secfilt[Ns].FkronWrp) ? MagToFlux(secfilt[Ns].MkronWrp) : secfilt[Ns].FkronWrp; 1087 break; 1088 case MAG_CLASS_APER: 1089 Fave = isnan (secfilt[Ns].FapWrp) ? MagToFlux(secfilt[Ns].MapWrp) : secfilt[Ns].FapWrp; 1090 break; 1091 default: 1092 break; 1093 } 1094 break; 1095 case MAG_SRC_STK: 1096 switch (class) { 1097 case MAG_CLASS_PSF: 1098 Fave = isnan (secfilt[Ns].FpsfStk) ? MagToFlux(secfilt[Ns].MpsfStk) : secfilt[Ns].FpsfStk; 1099 break; 1100 case MAG_CLASS_KRON: 1101 Fave = isnan (secfilt[Ns].FkronStk) ? MagToFlux(secfilt[Ns].MkronStk) : secfilt[Ns].FkronStk; 1102 break; 1103 case MAG_CLASS_APER: 1104 Fave = isnan (secfilt[Ns].FapStk) ? MagToFlux(secfilt[Ns].MapStk) : secfilt[Ns].FapStk; 1105 break; 1106 default: 1107 break; 1108 } 1109 break; 1110 default: 1111 break; 1112 } 1113 return (Fave); 1114 } 1115 1116 /* return calibrated magnitude from average/secfilt for given photcode */ 1117 float PhotFluxRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure, dvoMagClassType class, dvoMagSourceType source) { 1118 1119 int i; 1120 1121 float Fave = PhotFluxAve (code, average, secfilt, class, source); 1122 if (isnan(Fave)) return NAN; 1123 1124 // correct for relative zero-point 1125 float Moff = SCALE*code[0].C; 1126 1127 float mc = PhotColorForCode (average, secfilt, measure, code); 1128 if (isnan(mc)) return (Fave * MagToFlux(Moff)); 1129 mc -= SCALE*code[0].dX; 1130 1131 // correct for color terms 1132 double Mc = mc; 1133 float Mcol = 0; 857 1134 for (i = 0; i < code[0].Nc; i++) { 858 1135 Mcol += code[0].X[i]*Mc; 859 1136 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 860 1137 } 861 Mrel += Mcol; 862 return (Mrel); 863 } 864 865 /* return calibrated magnitude from measure for given photcode */ 866 float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code) { 867 868 int i, Np; 869 float Mcal, Mrel, Mcol, mc, Mc; 870 871 if (code == NULL) return NAN; 872 873 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 874 Np = photcodes[0].hashcode[thisone[0].photcode]; 1138 float Foff = MagToFlux(Mcol); 1139 return (Fave * Foff); 1140 } 1141 1142 float PhotFluxInstErr (Measure *measure, dvoMagClassType class) { 1143 1144 float Moff = - measure[0].dt - ZERO_POINT; 1145 1146 // use dFlux if we can, but use dMag if we must: 1147 // dFlux = Flux * dMag 1148 1149 float dFinst = NAN; 1150 switch (class) { 1151 case MAG_CLASS_PSF: 1152 if (isnan (measure[0].dFluxPSF)) { 1153 float Finst = MagToFlux(measure[0].M + Moff); 1154 dFinst = measure[0].dM * Finst; 1155 } else { 1156 dFinst = measure[0].dFluxPSF; 1157 } 1158 break; 1159 case MAG_CLASS_KRON: 1160 if (isnan (measure[0].dFluxKron)) { 1161 float Finst = MagToFlux(measure[0].Mkron + Moff); 1162 dFinst = measure[0].dMkron * Finst; 1163 } else { 1164 dFinst = measure[0].dFluxKron; 1165 } 1166 break; 1167 case MAG_CLASS_APER: 1168 if (isnan (measure[0].dFluxAp)) { 1169 float Finst = MagToFlux(measure[0].Map + Moff); 1170 dFinst = measure[0].dMap * Finst; 1171 } else { 1172 dFinst = measure[0].dFluxAp; 1173 } 1174 break; 1175 default: 1176 break; 1177 } 1178 return (dFinst); 1179 } 1180 1181 float PhotFluxCatErr (Measure *measure, dvoMagClassType class) { 1182 1183 int Np = photcodes[0].hashcode[measure[0].photcode]; 875 1184 if (Np == -1) return (NAN); 876 877 if (photcodes[0].code[Np].type == PHOT_REF) { 878 Mrel = thisone[0].M; 879 return (Mrel); 880 } 881 if (code[0].code != photcodes[0].code[Np].equiv) return (NAN); 882 883 Mcal = PhotRelTiny (thisone, average, secfilt) + SCALE*code[0].C; 884 885 mc = PhotColorForCodeTiny (average, secfilt, measure, code); 886 if (isnan(mc)) return (Mcal); 887 mc = mc - SCALE*code[0].dX; 888 889 Mc = mc; 890 Mcol = 0; 1185 PhotCode *code = &photcodes[0].code[Np]; 1186 1187 // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux 1188 float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 1189 float Moff = Mcal - ZERO_POINT + 8.9; 1190 float Foff = 3630.8 * MagToFlux(Mcal); 1191 1192 // use dFlux if we can, but use dMag if we must: 1193 // dFlux = Flux * dMag 1194 1195 float dFcat = NAN; 1196 switch (class) { 1197 case MAG_CLASS_PSF: 1198 if (isnan (measure[0].dFluxPSF)) { 1199 float Finst = MagToFlux(measure[0].M + Moff); 1200 dFcat = measure[0].dM * Finst; 1201 } else { 1202 dFcat = measure[0].dFluxPSF * Foff; 1203 } 1204 break; 1205 case MAG_CLASS_KRON: 1206 if (isnan (measure[0].dFluxKron)) { 1207 float Finst = MagToFlux(measure[0].Mkron + Moff); 1208 dFcat = measure[0].dMkron * Finst; 1209 } else { 1210 dFcat = measure[0].dFluxKron * Foff; 1211 } 1212 break; 1213 case MAG_CLASS_APER: 1214 if (isnan (measure[0].dFluxAp)) { 1215 float Finst = MagToFlux(measure[0].Map + Moff); 1216 dFcat = measure[0].dMap * Finst; 1217 } else { 1218 dFcat = measure[0].dFluxAp * Foff; 1219 } 1220 break; 1221 default: 1222 break; 1223 } 1224 return (dFcat); 1225 } 1226 1227 /******** alternate photometry conversion functions using MeasureTiny and AverageTiny *********/ 1228 float PhotInstTiny (MeasureTiny *measure, dvoMagClassType class) { 1229 1230 int Np = photcodes[0].hashcode[measure[0].photcode]; 1231 if (Np == -1) return (NAN); 1232 PhotCode *code = &photcodes[0].code[Np]; 1233 1234 float Mraw = NAN; 1235 switch (class) { 1236 case MAG_CLASS_PSF: 1237 Mraw = measure[0].M; 1238 break; 1239 case MAG_CLASS_KRON: 1240 // Mraw = measure[0].Mkron; 1241 break; 1242 case MAG_CLASS_APER: 1243 // Mraw = measure[0].Map; 1244 break; 1245 default: 1246 break; 1247 } 1248 if (code->type == PHOT_REF) { 1249 return (Mraw); 1250 } 1251 float Minst = Mraw - measure[0].dt - ZERO_POINT; 1252 1253 return (Minst); 1254 } 1255 1256 float PhotCatTiny (MeasureTiny *measure, dvoMagClassType class) { 1257 1258 int Np = photcodes[0].hashcode[measure[0].photcode]; 1259 if (Np == -1) return (NAN); 1260 PhotCode *code = &photcodes[0].code[Np]; 1261 1262 float Mraw = NAN; 1263 switch (class) { 1264 case MAG_CLASS_PSF: 1265 Mraw = measure[0].M; 1266 break; 1267 case MAG_CLASS_KRON: 1268 // Mraw = measure[0].Mkron; 1269 break; 1270 case MAG_CLASS_APER: 1271 // Mraw = measure[0].Map; 1272 break; 1273 default: 1274 break; 1275 } 1276 if (code->type == PHOT_REF) { 1277 return (Mraw); 1278 } 1279 1280 float Mcat = Mraw - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 1281 1282 return (Mcat); 1283 } 1284 1285 float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class) { 1286 1287 int Np = photcodes[0].hashcode[measure[0].photcode]; 1288 if (Np == -1) return (NAN); 1289 PhotCode *code = &photcodes[0].code[Np]; 1290 1291 float Mraw = NAN; 1292 switch (class) { 1293 case MAG_CLASS_PSF: 1294 Mraw = measure[0].M; 1295 break; 1296 case MAG_CLASS_KRON: 1297 // Mraw = measure[0].Mkron; 1298 break; 1299 case MAG_CLASS_APER: 1300 // Mraw = measure[0].Map; 1301 break; 1302 default: 1303 break; 1304 } 1305 if (code->type == PHOT_REF) { 1306 return (Mraw); 1307 } 1308 float Mcat = Mraw - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 1309 1310 /* for DEP, color must be made of PRI/SEC */ 1311 float mc = PhotColorForCodeTiny (average, secfilt, NULL, code); 1312 if (isnan(mc)) return (Mcat); 1313 mc -= SCALE*code[0].dX; 1314 1315 int i = 0; 1316 double Mc = mc; 1317 float Mcol = 0; 891 1318 for (i = 0; i < code[0].Nc; i++) { 892 1319 Mcol += code[0].X[i]*Mc; 893 1320 Mc *= mc; 894 1321 } 1322 float Msys = Mcat + Mcol; 1323 return (Msys); 1324 } 1325 1326 float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class) { 1327 1328 int Np = photcodes[0].hashcode[measure[0].photcode]; 1329 if (Np == -1) return (NAN); 1330 PhotCode *code = &photcodes[0].code[Np]; 1331 1332 float Mraw = NAN; 1333 switch (class) { 1334 case MAG_CLASS_PSF: 1335 Mraw = measure[0].M; 1336 break; 1337 case MAG_CLASS_KRON: 1338 // Mraw = measure[0].Mkron; 1339 break; 1340 case MAG_CLASS_APER: 1341 // Mraw = measure[0].Map; 1342 break; 1343 default: 1344 break; 1345 } 1346 if (code->type == PHOT_REF) { 1347 return (Mraw); 1348 } 1349 float Mcat = Mraw - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 1350 1351 /* for DEP, color must be made of PRI/SEC */ 1352 float mc = PhotColorForCodeTiny (average, secfilt, NULL, code); 1353 if (isnan(mc)) return (Mcat); 1354 mc -= SCALE*code[0].dX; 1355 1356 double Mc = mc; 1357 float Mcol = 0; 1358 int i = 0; 1359 for (i = 0; i < code[0].Nc; i++) { 1360 Mcol += code[0].X[i]*Mc; 1361 Mc *= mc; 1362 } 1363 float Mrel = Mcat + Mcol; 1364 return (Mrel); 1365 } 1366 1367 /* return calibrated magnitude from measure for given photcode */ 1368 float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code, dvoMagClassType class) { 1369 1370 int i; 1371 1372 if (code == NULL) return NAN; 1373 1374 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 1375 int Np = photcodes[0].hashcode[thisone[0].photcode]; 1376 if (Np == -1) return (NAN); 1377 PhotCode *myCode = &photcodes[0].code[Np]; 1378 1379 if (code->code != myCode->equiv) return (NAN); 1380 1381 // if we are REF type, just get the right version and return 1382 if (myCode->type == PHOT_REF) { 1383 float Mraw = NAN; 1384 switch (class) { 1385 case MAG_CLASS_PSF: 1386 Mraw = thisone[0].M; 1387 break; 1388 case MAG_CLASS_KRON: 1389 // Mraw = thisone[0].Mkron; 1390 break; 1391 case MAG_CLASS_APER: 1392 // Mraw = thisone[0].Map; 1393 break; 1394 default: 1395 break; 1396 } 1397 return (Mraw); 1398 } 1399 1400 float Mcal = PhotRelTiny (thisone, average, secfilt, class) + SCALE*code[0].C; 1401 1402 float mc = PhotColorForCodeTiny (average, secfilt, measure, code); 1403 if (isnan(mc)) return (Mcal); 1404 mc -= SCALE*code[0].dX; 1405 1406 double Mc = mc; 1407 float Mcol = 0; 1408 for (i = 0; i < code[0].Nc; i++) { 1409 Mcol += code[0].X[i]*Mc; 1410 Mc *= mc; 1411 } 895 1412 Mcal += Mcol; 896 1413 return (Mcal); 1414 } 1415 1416 /***/ 1417 float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source) { 1418 1419 if (code == NULL) return NAN; 1420 1421 int Ns = photcodes[0].hashNsec[code[0].code]; 1422 if (Ns == -1) return (NAN); 1423 1424 float Mave = NAN; 1425 switch (source) { 1426 case MAG_SRC_CHP: 1427 switch (class) { 1428 case MAG_CLASS_PSF: 1429 Mave = secfilt[Ns].M; 1430 break; 1431 case MAG_CLASS_KRON: 1432 Mave = secfilt[Ns].Mkron; 1433 break; 1434 case MAG_CLASS_APER: 1435 Mave = secfilt[Ns].Map; 1436 break; 1437 default: 1438 break; 1439 } 1440 break; 1441 case MAG_SRC_WRP: 1442 switch (class) { 1443 case MAG_CLASS_PSF: 1444 Mave = secfilt[Ns].MpsfWrp; 1445 break; 1446 case MAG_CLASS_KRON: 1447 Mave = secfilt[Ns].MkronWrp; 1448 break; 1449 case MAG_CLASS_APER: 1450 Mave = secfilt[Ns].MapWrp; 1451 break; 1452 default: 1453 break; 1454 } 1455 break; 1456 case MAG_SRC_STK: 1457 switch (class) { 1458 case MAG_CLASS_PSF: 1459 Mave = secfilt[Ns].MpsfStk; 1460 break; 1461 case MAG_CLASS_KRON: 1462 Mave = secfilt[Ns].MkronStk; 1463 break; 1464 case MAG_CLASS_APER: 1465 Mave = secfilt[Ns].MapStk; 1466 break; 1467 default: 1468 break; 1469 } 1470 break; 1471 default: 1472 break; 1473 } 1474 return (Mave); 1475 } 1476 1477 /* return calibrated magnitude from average/secfilt for given photcode */ 1478 float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, dvoMagClassType class, dvoMagSourceType source) { 1479 1480 int i; 1481 1482 float Mave = PhotAveTiny (code, average, secfilt, class, source); 1483 if (isnan(Mave)) return NAN; 1484 1485 // correct for relative zero-point 1486 float Mref = Mave + SCALE*code[0].C; 1487 1488 float mc = PhotColorForCodeTiny (average, secfilt, measure, code); 1489 if (isnan(mc)) return (Mref); 1490 mc -= SCALE*code[0].dX; 1491 1492 // correct for color terms 1493 double Mc = mc; 1494 float Mcol = 0; 1495 for (i = 0; i < code[0].Nc; i++) { 1496 Mcol += code[0].X[i]*Mc; 1497 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 1498 } 1499 Mref += Mcol; 1500 return (Mref); 897 1501 } 898 1502 … … 947 1551 } 948 1552 949 /* return calibrated magnitude from average/secfilt for given photcode */950 float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure) {951 952 int i, Ns;953 float Mave, Mref, Mcol, mc;954 double Mc;955 956 if (code == NULL) return NAN;957 958 Ns = photcodes[0].hashNsec[code[0].code];959 Mave = (Ns == -1) ? NAN : secfilt[Ns].M;960 Mref = Mave + SCALE*code[0].C;961 962 mc = PhotColorForCodeTiny (average, secfilt, measure, code);963 if (isnan(mc)) return (Mref);964 mc = mc - SCALE*code[0].dX;965 966 Mc = mc;967 Mcol = 0;968 for (i = 0; i < code[0].Nc; i++) {969 Mcol += code[0].X[i]*Mc;970 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */971 }972 Mref += Mcol;973 return (Mref);974 }975 976 /***/977 float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) {978 979 int Ns;980 float Mave;981 982 if (code == NULL) return NAN;983 984 Ns = photcodes[0].hashNsec[code[0].code];985 Mave = (Ns == -1) ? NAN : secfilt[Ns].M;986 return (Mave);987 }988 989 1553 float PhotdMTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) { 990 1554 … … 999 1563 } 1000 1564 1001 // X XX return NAN or NAN_S_SHORT? (secfilt->Xm is short)1565 // Xm is now (2014.07.03) stored as the chisq except in dvo formats which use as short 1002 1566 float PhotXmTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) { 1003 1567 1004 1568 int Ns; 1005 short Mi;1006 1569 float Xm; 1007 1570 … … 1009 1572 1010 1573 Ns = photcodes[0].hashNsec[code[0].code]; 1011 Mi = (Ns == -1) ? NAN : secfilt[Ns].Xm; 1012 Xm = (isnan(Mi)) ? -1.0 : pow (10.0, 0.01*Mi); 1574 Xm = (Ns == -1) ? NAN : secfilt[Ns].Mchisq; 1013 1575 return (Xm); 1014 1576 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dvo_tiny_values.c
r35102 r37067 8 8 averageT[0].measureOffset = average[0].measureOffset; 9 9 averageT[0].catID = average[0].catID; 10 averageT[0].objID = average[0].objID; 11 averageT[0].nOwn = -1; 10 12 return; 11 13 } 12 14 13 15 void CopyMeasureToTiny (MeasureTiny *measureT, Measure *measure) { 14 measureT[0]. dR = measure[0].dR;15 measureT[0]. dD = measure[0].dD;16 measureT[0].R = measure[0].R; 17 measureT[0].D = measure[0].D; 16 18 measureT[0].M = measure[0].M; 17 19 measureT[0].Mcal = measure[0].Mcal; … … 33 35 measureT[0].dYccd = measure[0].dYccd; 34 36 measureT[0].dRsys = measure[0].dRsys; 37 measureT[0].myDet = 0; 35 38 return ; 36 39 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/dvosorts.c
r35263 r37067 60 60 61 61 /* sort a coordinate pair (X,Y) and the associated index (S) */ 62 void sort_IDs_indexonly (opihi_int *X, off_t *S, off_t N) { 63 64 # define SWAPFUNC(A,B){ off_t itmp; \ 65 itmp = S[A]; S[A] = S[B]; S[B] = itmp; \ 66 } 67 # define COMPARE(A,B)(X[S[A]] < X[S[B]]) 68 69 OHANA_SORT (N, COMPARE, SWAPFUNC); 70 71 # undef SWAPFUNC 72 # undef COMPARE 73 74 } 75 76 /* sort a coordinate pair (X,Y) and the associated index (S) */ 62 77 void sort_coords_indexonly (double *X, double *Y, off_t *S, off_t N) { 63 78 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libdvo/src/skyregion_io.c
r33649 r37067 78 78 gfits_free_matrix (&matrix); 79 79 gfits_free_header (&theader); 80 fclose (f); 80 81 81 82 return (skytable); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libfits/include/gfitsio.h
r35756 r37067 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/ipp-ops-20130712/Ohana/src/libfits/matrix/F_compress_M.c
r34088 r37067 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/ipp-ops-20130712/Ohana/src/libfits/table/F_get_column.c
r35101 r37067 79 79 } 80 80 } 81 if (!strcmp (type, "byte")) { 82 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 83 *(char *)Pout = *(char *)Pin*Bscale + Bzero; 84 } 85 } 81 86 if (!strcmp (type, "short")) { 82 87 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { … … 174 179 int gfits_get_bintable_column (Header *header, FTable *table, char *label, void **data) { 175 180 176 off_t Nx, Ny; 177 int i, N, Nfields, Nval, Nbytes, Nstart, Nv, Nb; 178 char tlabel[80], field[80], format[80], type[16], tmpline[16]; 179 char *Pin, *Pout, *array; 180 double Bscale, Bzero; 181 182 if (label == (char *) NULL) return (FALSE); 183 if (label[0] == 0) return (FALSE); 184 185 /* find label in header */ 186 tlabel[0] = 0; 187 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 188 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 189 sprintf (field, "TTYPE%d", i); 190 gfits_scan (header, field, "%s", 1, tlabel); 191 } 192 if (strcasecmp (label, tlabel)) return (FALSE); 193 N = i - 1; 194 195 Bscale = 1; 196 Bzero = 0; 197 198 /* interpret format */ 199 sprintf (field, "TSCAL%d", N); 200 gfits_scan (header, field, "%lf", 1, &Bscale); 201 sprintf (field, "TZERO%d", N); 202 gfits_scan (header, field, "%lf", 1, &Bzero); 203 sprintf (field, "TFORM%d", N); 204 gfits_scan (header, field, "%s", 1, format); 205 206 if (!gfits_bintable_format (format, type, &Nval, &Nbytes)) return (FALSE); 207 208 /* check existing table dimensions */ 209 gfits_scan (header, "NAXIS1", OFF_T_FMT, 1, &Nx); 210 gfits_scan (header, "NAXIS2", OFF_T_FMT, 1, &Ny); 211 212 /* scan columns to find insert point */ 213 Nstart = 0; 214 for (i = 1; i < N; i++) { 215 sprintf (field, "TFORM%d", i); 216 gfits_scan (header, field, "%s", 1, format); 217 gfits_bintable_format (format, tmpline, &Nv, &Nb); 218 Nstart += Nv*Nb; 219 } 220 221 /* extract bytes from table into temporary array */ 222 ALLOCATE (array, char, Nbytes*Nval*Ny); 223 Pin = table[0].buffer + Nstart; 224 Pout = array; 225 for (i = 0; i < Ny; i++, Pin += Nx, Pout += Nval*Nbytes) { 226 memcpy (Pout, Pin, Nval*Nbytes); 227 } 228 229 /* convert data in-situ with correct type, byte swap and Bzero/Bscale */ 230 Pin = array; 231 Pout = array; 232 if (!strcmp (type, "char")) { 233 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 234 *(char *)Pout = *(char *)Pin*Bscale + Bzero; 235 } 236 } 237 if (!strcmp (type, "short")) { 238 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 239 # ifdef BYTE_SWAP 240 SWAP_BYTE; 241 # endif 242 *(short *)Pout = *(short *)Pin*Bscale + Bzero; 243 } 244 } 245 if (!strcmp (type, "int")) { 246 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 247 # ifdef BYTE_SWAP 248 SWAP_WORD; 249 # endif 250 *(int *)Pout = *(int *)Pin*Bscale + Bzero; 251 } 252 } 253 if (!strcmp (type, "int64_t")) { 254 // XXX 64 bit int operations with Bzero & Bscale are inaccurate even with doubles 255 if ((Bzero == 0.0) && (Bscale == 1.0)) { 256 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 257 # ifdef BYTE_SWAP 258 SWAP_DBLE; 259 # endif 260 *(int64_t *)Pout = *(int64_t *)Pin; 261 } 262 } else { 263 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 264 # ifdef BYTE_SWAP 265 SWAP_DBLE; 266 # endif 267 *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; 268 } 269 } 270 } 271 if (!strcmp (type, "float")) { 272 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 273 # ifdef BYTE_SWAP 274 SWAP_WORD; 275 # endif 276 *(float *)Pout = *(float *)Pin*Bscale + Bzero; 277 } 278 } 279 if (!strcmp (type, "double")) { 280 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 281 # ifdef BYTE_SWAP 282 SWAP_DBLE; 283 # endif 284 *(double *)Pout = *(double *)Pin*Bscale + Bzero; 285 } 286 } 181 char type[16]; 182 off_t Nrow; 183 int Ncol; 184 185 char *array = gfits_get_bintable_column_data (header, table, label, type, &Nrow, &Ncol); 186 if (array == NULL) return (FALSE); 287 187 288 188 *data = array; 289 return (TRUE);189 return TRUE; 290 190 } 291 191 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libfits/table/F_set_column.c
r35101 r37067 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/ipp-ops-20130712/Ohana/src/libfits/table/F_table_format.c
r28241 r37067 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/ipp-ops-20130712/Ohana/src/libkapa/src/IOfuncs.c
r35761 r37067 54 54 va_end (argp); 55 55 56 if (!Nbyte) return (FALSE); 56 if (!Nbyte) { 57 KiiSendCommand (device, 16, "LEN: %11d", 0); 58 return (FALSE); 59 } 57 60 58 61 /* the message may contain up to 99,999,999,999 bytes (100MB) */ … … 84 87 /* find the message length, allocate space */ 85 88 sscanf (buffer, "%*s %d", &Nbytes); 89 if (Nbytes == 0) { 90 return TRUE; 91 } 92 86 93 ALLOCATE (message, char, Nbytes + 1); 87 94 memset (message, 0, Nbytes + 1); 95 88 96 89 97 /* read Nbytes from the device */ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libkapa/src/KapaOpen.c
r35761 r37067 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/ipp-ops-20130712/Ohana/src/libkapa/src/KapaWindow.c
r35761 r37067 100 100 graphdata[0].coords.pc1_1 = graphdata[0].coords.pc2_2 = 1.0; 101 101 graphdata[0].coords.pc1_2 = graphdata[0].coords.pc2_1 = 0.0; 102 strcpy (graphdata[0].coords.ctype, " RA---LIN");102 strcpy (graphdata[0].coords.ctype, "DEC--LIN"); 103 103 graphdata[0].coords.crval1 = 0.0; 104 104 graphdata[0].coords.crval2 = 0.0; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libkapa/src/KiiPicture.c
r34088 r37067 21 21 int KiiNewPicture1D (int fd, KiiImage *image, KapaImageData *data, Coords *coords) { 22 22 23 int Nwrite, Npix, Ncolors, size; 23 int Ncolors; 24 off_t Nwrite, Npix, size; 24 25 float min, max; 25 26 … … 36 37 KiiSendMessage (fd, "%8d %8d", image[0].Nx, image[0].Ny); 37 38 KiiSendMessage (fd, "%f %f %s %s", data[0].zero, data[0].range, data[0].name, data[0].file); 38 KiiSendMessage (fd, "%f %f %d", min, max, size);39 KiiSendMessage (fd, "%f %f "OFF_T_FMT" ", min, max, size); 39 40 KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval1, coords[0].crpix1, coords[0].cdelt1, coords[0].pc1_1, coords[0].pc1_2); 40 41 KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval2, coords[0].crpix2, coords[0].cdelt2, coords[0].pc2_1, coords[0].pc2_2); … … 42 43 43 44 /* send the image data */ 44 Nwrite = write (fd, image[0].data1d, size); 45 if (Nwrite != size) { 46 fprintf (stderr, "error sending picture to kapa\n"); 47 return (FALSE); 45 off_t bytes_left = size; 46 while (bytes_left > 0) { 47 Nwrite = write (fd, image[0].data1d, bytes_left); 48 if (Nwrite == 0) { 49 fprintf (stderr, "unable to send more data to kapa?\n"); 50 return FALSE; 51 } 52 if (Nwrite < 0) { 53 if (errno == EAGAIN) continue; 54 if (errno == EWOULDBLOCK) continue; 55 perror ("KiiNewPicture1D:"); 56 return FALSE; 57 } 58 bytes_left -= Nwrite; 48 59 } 49 60 … … 114 125 int KiiNewPicture2D (int fd, KiiImage *image, KapaImageData *data, Coords *coords) { 115 126 116 int j;117 int Nwrite, Nbytes, Npix, Ncolors, size;127 int Ncolors; 128 off_t j, Nwrite, Nbytes, Npix, size; 118 129 float min, max; 119 130 … … 130 141 KiiSendMessage (fd, "%8d %8d", image[0].Nx, image[0].Ny); 131 142 KiiSendMessage (fd, "%f %f %s %s", data[0].zero, data[0].range, data[0].name, data[0].file); 132 KiiSendMessage (fd, "%f %f %d", min, max, size);143 KiiSendMessage (fd, "%f %f "OFF_T_FMT" ", min, max, size); 133 144 KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval1, coords[0].crpix1, coords[0].cdelt1, coords[0].pc1_1, coords[0].pc1_2); 134 145 KiiSendMessage (fd, "%f %f %g %g %g ", coords[0].crval2, coords[0].crpix2, coords[0].cdelt2, coords[0].pc2_1, coords[0].pc2_2); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libkapa/src/bDrawFuncs.c
r33956 r37067 247 247 int i; 248 248 249 if (Y < 0) return; 250 if (Y >= buffer[0].Ny) return; 251 249 252 for (i = X1; i < X2; i++) { 253 if (i < 0) continue; 254 if (i >= buffer[0].Nx) continue; 250 255 if (buffer[0].Nbyte == 1) { 251 256 buffer[0].pixels[Y][i] = buffer->bColor; … … 263 268 int i; 264 269 270 if (X < 0) return; 271 if (X >= buffer[0].Nx) return; 272 265 273 for (i = Y1; i < Y2; i++) { 274 if (i < 0) continue; 275 if (i >= buffer[0].Ny) continue; 266 276 if (buffer[0].Nbyte == 1) { 267 277 buffer[0].pixels[i][X] = buffer->bColor; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libohana/include/ohana.h
r35754 r37067 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))) … … 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/ipp-ops-20130712/Ohana/src/libohana/src
- Property svn:mergeinfo deleted
-
branches/eam_branches/ipp-ops-20130712/Ohana/src/libohana/src/gaussj.c
r24080 r37067 1 1 # include <ohana.h> 2 2 # define GROWTHTEST 0 3 # define MAX_RANGE 1.0e 73 # define MAX_RANGE 1.0e9 4 4 5 5 // Gauss-Jordan elimination using full pivots based on Press et al's description. Substantially … … 91 91 /* rescale by pivot reciprocal */ 92 92 double tmpval = 1.0 / A[maxcol][maxcol]; 93 // XXX why is this here (don't I double count this element?) A[maxcol][maxcol] = 1.0; 93 94 A[maxcol][maxcol] = 1.0; 94 95 for (col = 0; col < N; col++) A[maxcol][col] *= tmpval; … … 117 118 } 118 119 } 120 121 # if (GROWTHTEST) 122 fprintf (stderr, "final A matrix:\n"); 123 for (row = 0; row < N; row++) { 124 for (col = 0; col < N; col++) { 125 fprintf (stderr, "%10.3e ", A[row][col]); 126 } 127 fprintf (stderr, "\n"); 128 } 129 fprintf (stderr, "\n"); 130 # endif 119 131 120 132 // swap back the inverse matrix based on the row swaps above -
branches/eam_branches/ipp-ops-20130712/Ohana/src/libohana/src/string.c
r34753 r37067 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/ipp-ops-20130712/Ohana/src/markrock/src/gcatstats.c
r27435 r37067 40 40 catstats[0].coords.pc1_1 = catstats[0].coords.pc2_2 = 1.0; 41 41 catstats[0].coords.pc1_2 = catstats[0].coords.pc2_1 = 0.0; 42 strcpy (catstats[0].coords.ctype, " RA---TAN");42 strcpy (catstats[0].coords.ctype, "DEC--TAN"); 43 43 44 44 X1 = catstats[0].X; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/markstar/src/gcatstats.c
r27435 r37067 50 50 catstats[0].coords.pc1_1 = catstats[0].coords.pc2_2 = 1.0; 51 51 catstats[0].coords.pc1_2 = catstats[0].coords.pc2_1 = 0.0; 52 strcpy (catstats[0].coords.ctype, " RA---TAN");52 strcpy (catstats[0].coords.ctype, "DEC--TAN"); 53 53 54 54 X1 = catstats[0].X; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/mosastro/src/warptest.c
r3323 r37067 15 15 16 16 /* bore site center guess */ 17 sprintf (coords.ctype, " RA---%s", argv[1]);17 sprintf (coords.ctype, "DEC--%s", argv[1]); 18 18 coords.crval1 = 0.0; 19 19 coords.crval2 = 0.0; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi
- Property svn:mergeinfo deleted
-
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.astro
- Property svn:mergeinfo deleted
-
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.astro/Makefile
r35416 r37067 28 28 $(SRC)/cval.$(ARCH).o \ 29 29 $(SRC)/czplot.$(ARCH).o \ 30 $(SRC)/cdensify.$(ARCH).o \ 30 31 $(SRC)/drizzle.$(ARCH).o \ 31 32 $(SRC)/flux.$(ARCH).o \ 32 33 $(SRC)/fitplx.$(ARCH).o \ 34 $(SRC)/fitpm.$(ARCH).o \ 33 35 $(SRC)/fixwrap.$(ARCH).o \ 34 36 $(SRC)/fixcols.$(ARCH).o \ … … 60 62 $(SRC)/scale.$(ARCH).o \ 61 63 $(SRC)/sexigesimal.$(ARCH).o \ 64 $(SRC)/sersic.$(ARCH).o \ 62 65 $(SRC)/spec.$(ARCH).o \ 63 66 $(SRC)/specpairfit.$(ARCH).o \ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.astro/fitplx.c
r35416 r37067 41 41 remove_argument (N, &argc, argv); 42 42 VERBOSE = TRUE; 43 } 44 if ((N = get_argument (argc, argv, "-vv"))) { 45 remove_argument (N, &argc, argv); 46 VERBOSE = 2; 43 47 } 44 48 … … 108 112 coords.pc1_2 = coords.pc2_1 = 0.0; 109 113 coords.Npolyterms = 1; 110 strcpy (coords.ctype, " RA---SIN");114 strcpy (coords.ctype, "DEC--SIN"); 111 115 112 116 double *X, *Y, *t, *pX, *pY, *dX, *dY; … … 145 149 146 150 PlxFit fit; 147 FitPMandPar (&fit, X, dX, Y, dY, t, pX, pY, n, VERBOSE); 151 if (!FitPMandPar (&fit, X, dX, Y, dY, t, pX, pY, n, VERBOSE)) { 152 return FALSE; 153 } 148 154 149 155 // fprintf (stderr, "Roff, Doff: %f, %f; dRo, dDo: %f, %f\n", fit.Ro, fit.Do, fit.dRo, fit.dDo); … … 204 210 for (i = 0; i < Npts; i++) { 205 211 206 if (VERBOSE ) fprintf (stderr, "%f %f : %f %f : %f : %f %f\n", X[i], dX[i], Y[i], dY[i], T[i], pR[i], pD[i]);212 if (VERBOSE == 2) fprintf (stderr, "%f %f : %f %f : %f : %f %f\n", X[i], dX[i], Y[i], dY[i], T[i], pR[i], pD[i]); 207 213 208 214 /* handle case where dX or dY = 0.0 */ 209 wx = 1.0 / SQ(dX[i]);210 wy = 1.0 / SQ(dY[i]);215 wx = (fabs(dX[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dX[i]); 216 wy = (fabs(dY[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dY[i]); 211 217 212 218 Wx += wx; … … 266 272 B[4][0] = PRX + PDY; 267 273 268 dgaussjordan ((double **)A, (double **)B, 5, 1); 274 if (!dgaussjordan ((double **)A, (double **)B, 5, 1)) { 275 if (VERBOSE) fprintf (stderr, "error in fit\n"); 276 if (VERBOSE == 2) { 277 int j; 278 for (i = 0; i < 5; i++) { 279 for (j = 0; j < 5; j++) { 280 fprintf (stderr, "%e ", A[i][j]); 281 } 282 fprintf (stderr, " : %e\n", A[i][0]); 283 } 284 } 285 return FALSE; 286 } 269 287 270 288 fit[0].Ro = B[0][0]; … … 285 303 Xf = fit[0].Ro + fit[0].uR*T[i] + fit[0].p*pR[i]; 286 304 Yf = fit[0].Do + fit[0].uD*T[i] + fit[0].p*pD[i]; 287 chisq += SQ(X[i] - Xf) / SQ(dX[i]); 288 chisq += SQ(Y[i] - Yf) / SQ(dY[i]); 289 if (VERBOSE) fprintf (stderr, "chisq contrib : %f %f : %f %f : %f %f : %f %f : %f\n", Xf, Yf, X[i] - Xf, Y[i] - Yf, dX[i], dY[i], (X[i] - Xf) / dX[i], (Y[i] - Yf) / dY[i], chisq); 305 wx = (fabs(dX[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dX[i]); 306 wy = (fabs(dY[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dY[i]); 307 chisq += SQ(X[i] - Xf) * wx; 308 chisq += SQ(Y[i] - Yf) * wy; 309 // if (VERBOSE) fprintf (stderr, "chisq contrib : %f %f : %f %f : %f %f : %f %f : %f\n", Xf, Yf, X[i] - Xf, Y[i] - Yf, dX[i], dY[i], (X[i] - Xf) / dX[i], (Y[i] - Yf) / dY[i], chisq); 290 310 } 291 311 fit[0].Nfit = Npts; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.astro/gauss.c
r34088 r37067 10 10 Buffer *buf; 11 11 KapaImageData data; 12 int VERBOSE; 13 14 VERBOSE = TRUE; 15 if ((N = get_argument (argc, argv, "-q"))) { 16 VERBOSE = FALSE; 17 remove_argument (N, &argc, argv); 18 } 19 if ((N = get_argument (argc, argv, "-quiet"))) { 20 VERBOSE = FALSE; 21 remove_argument (N, &argc, argv); 22 } 12 23 13 24 name = NULL; … … 58 69 KiiCursorRead (kapa, &X, &Y, &ZP, &RA, &DEC, key); 59 70 if (!strcasecmp (key, "Q")) break; 60 get_aperture_stats (&buf[0].matrix, (int)(X+0.5), (int)(Y+0.5), Npix, Nborder, max );71 get_aperture_stats (&buf[0].matrix, (int)(X+0.5), (int)(Y+0.5), Npix, Nborder, max, VERBOSE); 61 72 } 62 73 KiiCursorOff (kapa); … … 64 75 } 65 76 77 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.astro/init.c
r35757 r37067 13 13 int czplot PROTO((int, char **)); 14 14 int czcplot PROTO((int, char **)); 15 int cdensify PROTO((int, char **)); 15 16 int drizzle PROTO((int, char **)); 16 17 int flux PROTO((int, char **)); 17 18 int fitplx PROTO((int, char **)); 19 int fitpm PROTO((int, char **)); 18 20 int fixwrap PROTO((int, char **)); 19 21 int fiximage PROTO((int, char **)); … … 49 51 int scale PROTO((int, char **)); 50 52 int sexigesimal PROTO((int, char **)); 53 int sersic PROTO((int, char **)); 51 54 int spec PROTO((int, char **)); 52 55 int specpairfit PROTO((int, char **)); … … 72 75 {1, "czplot", czplot, "plot scaled vectors in sky coordinates"}, 73 76 {1, "czcplot", czcplot, "plot color-scaled vectors in sky coordinates"}, 77 {1, "cdensify", cdensify, "vectors to density history on projection"}, 74 78 {1, "drizzle", drizzle, "transform image to image"}, 75 79 {1, "flux", flux, "flux in a convex contour"}, 76 80 {1, "fitplx", fitplx, "fit proper motion and parallax"}, 81 {1, "fitpm", fitpm, "fit proper motion only"}, 77 82 {1, "fixwrap", fixwrap, "fix megacam over-wrapped pixels"}, 78 83 {1, "fiximage", fiximage, "fix pixels in an image by interpolation"}, … … 107 112 {1, "scale", scale, "get / set real bzero / bscale values"}, 108 113 {1, "sexigesimal", sexigesimal, "convert to/from sexigesimal/decimal"}, 114 {1, "sersic", sersic, "generate sub-pixel resolved sersic model"}, 109 115 {1, "spec", spec, "extract a spectrum"}, 110 116 {1, "specpairfit", specpairfit, "fit spectrum to another spectrum"}, -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.astro/region.c
r31160 r37067 80 80 if (!ohana_str_to_radec (&Ra, &Dec, argv[1], argv[2])) return (FALSE); 81 81 Radius = atof (argv[3]); 82 strcpy (graphmode.coords.ctype, " RA---TAN");82 strcpy (graphmode.coords.ctype, "DEC--TAN"); 83 83 if (argc == 5) { 84 84 if (!strcasecmp (argv[4], "TAN")) 85 strcpy (graphmode.coords.ctype, " RA---TAN");85 strcpy (graphmode.coords.ctype, "DEC--TAN"); 86 86 if (!strcasecmp (argv[4], "SIN")) 87 strcpy (graphmode.coords.ctype, " RA---SIN");87 strcpy (graphmode.coords.ctype, "DEC--SIN"); 88 88 if (!strcasecmp (argv[4], "ARC")) 89 strcpy (graphmode.coords.ctype, " RA---ARC");89 strcpy (graphmode.coords.ctype, "DEC--ARC"); 90 90 if (!strcasecmp (argv[4], "STG")) 91 strcpy (graphmode.coords.ctype, " RA---STG");91 strcpy (graphmode.coords.ctype, "DEC--STG"); 92 92 if (!strcasecmp (argv[4], "ZEA")) 93 strcpy (graphmode.coords.ctype, " RA---ZEA");93 strcpy (graphmode.coords.ctype, "DEC--ZEA"); 94 94 if (!strcasecmp (argv[4], "AIT")) 95 strcpy (graphmode.coords.ctype, " RA---AIT");95 strcpy (graphmode.coords.ctype, "DEC--AIT"); 96 96 if (!strcasecmp (argv[4], "GLS")) 97 strcpy (graphmode.coords.ctype, " RA---GLS");97 strcpy (graphmode.coords.ctype, "DEC--GLS"); 98 98 if (!strcasecmp (argv[4], "PAR")) 99 strcpy (graphmode.coords.ctype, " RA---PAR");99 strcpy (graphmode.coords.ctype, "DEC--PAR"); 100 100 } 101 101 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.astro/star.c
r34088 r37067 6 6 double max; 7 7 Buffer *buf; 8 int VERBOSE; 9 10 VERBOSE = TRUE; 11 if ((N = get_argument (argc, argv, "-q"))) { 12 VERBOSE = FALSE; 13 remove_argument (N, &argc, argv); 14 } 15 if ((N = get_argument (argc, argv, "-quiet"))) { 16 VERBOSE = FALSE; 17 remove_argument (N, &argc, argv); 18 } 8 19 9 20 Nborder = 3; … … 36 47 } 37 48 38 get_aperture_stats (&buf[0].matrix, x, y, dx, Nborder, max );49 get_aperture_stats (&buf[0].matrix, x, y, dx, Nborder, max, VERBOSE); 39 50 40 51 return (TRUE); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.basic/Makefile
r35237 r37067 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/ipp-ops-20130712/Ohana/src/opihi/cmd.basic/init.c
r35237 r37067 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/ipp-ops-20130712/Ohana/src/opihi/cmd.basic/list.c
r33662 r37067 21 21 } 22 22 23 int EXCEL_STYLE = FALSE; 24 if ((N = get_argument (argc, argv, "-excel-style"))) { 25 remove_argument (N, &argc, argv); 26 EXCEL_STYLE = TRUE; 27 } 28 if ((N = get_argument (argc, argv, "-excel"))) { 29 remove_argument (N, &argc, argv); 30 EXCEL_STYLE = TRUE; 31 } 32 23 33 if ((N = get_argument (argc, argv, "-vectors"))) { 24 34 remove_argument (N, &argc, argv); … … 49 59 50 60 for (i = 0; i < argc - 3; i++) { 51 s printf (line, "%s:%d", argv[1], i);61 set_list_varname (line, argv[1], i, EXCEL_STYLE); 52 62 set_str_variable (line, argv[i+3]); 53 63 } … … 83 93 if (!word) break; 84 94 85 sprintf (line, "%s:%d", argv[1], nWords); 95 // sprintf (line, "%s:%d", argv[1], nWords); 96 set_list_varname (line, argv[1], nWords, EXCEL_STYLE); 97 86 98 set_str_variable (line, word); 87 99 FREE (word); … … 120 132 sprintf (line, "%s:%d", argv[3], i); 121 133 value = get_variable (line); 122 sprintf (line, "%s:%d", argv[1], i); 134 // sprintf (line, "%s:%d", argv[1], i); 135 set_list_varname (line, argv[1], i, EXCEL_STYLE); 123 136 set_str_variable (line, value); 124 137 } … … 136 149 N = get_int_variable (line, &found); 137 150 for (i = 0; i < argc - 3; i++) { 138 sprintf (line, "%s:%d", argv[1], N + i); 151 // sprintf (line, "%s:%d", argv[1], N + i); 152 set_list_varname (line, argv[1], N + i, EXCEL_STYLE); 139 153 set_str_variable (line, argv[i+3]); 140 154 } … … 159 173 N = get_int_variable (line, &found); 160 174 for (i = 0; i < N; i++) { 161 sprintf (line, "%s:%d", argv[1], i); 175 // sprintf (line, "%s:%d", argv[1], i); 176 set_list_varname (line, argv[1], i, EXCEL_STYLE); 162 177 value = get_variable (line); 163 178 if (value == NULL) continue; … … 165 180 free (value); 166 181 for (j = i + 1; j < N; j++) { 167 sprintf (line2, "%s:%d", argv[1], j); 182 // sprintf (line2, "%s:%d", argv[1], j); 183 set_list_varname (line2, argv[1], j, EXCEL_STYLE); 168 184 next_value = get_variable (line2); 169 185 set_str_variable (line, next_value); … … 235 251 if (B != (char *) NULL) { *B = 0; } 236 252 if (*A != 0) { 237 sprintf (line, "%s:%d", argv[1], i); 253 // sprintf (line, "%s:%d", argv[1], i); 254 set_list_varname (line, argv[1], i, EXCEL_STYLE); 238 255 set_str_variable (line, A); 239 256 A = B + 1; … … 283 300 284 301 if (*input) { 285 sprintf (line, "%s:%d", argv[1], i); 302 // sprintf (line, "%s:%d", argv[1], i); 303 set_list_varname (line, argv[1], i, EXCEL_STYLE); 286 304 set_str_variable (line, input); 287 305 free (input); 288 306 i++; 289 }307 } 290 308 } 291 309 return (TRUE); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data
- Property svn:mergeinfo deleted
-
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/Makefile
r35416 r37067 25 25 $(SRC)/book.$(ARCH).o \ 26 26 $(SRC)/book_commands.$(ARCH).o \ 27 $(SRC)/cast.$(ARCH).o \ 27 28 $(SRC)/center.$(ARCH).o \ 28 29 $(SRC)/clear.$(ARCH).o \ … … 63 64 $(SRC)/imcut.$(ARCH).o \ 64 65 $(SRC)/imhist.$(ARCH).o \ 66 $(SRC)/impeaks.$(ARCH).o \ 65 67 $(SRC)/imsmooth.$(ARCH).o \ 68 $(SRC)/imsmooth.generic.$(ARCH).o \ 69 $(SRC)/imsmooth.2d.$(ARCH).o \ 66 70 $(SRC)/integrate.$(ARCH).o \ 67 71 $(SRC)/interpolate.$(ARCH).o \ 72 $(SRC)/join.$(ARCH).o \ 68 73 $(SRC)/jpeg.$(ARCH).o \ 69 74 $(SRC)/kern.$(ARCH).o \ … … 84 89 $(SRC)/mget.$(ARCH).o \ 85 90 $(SRC)/minterpolate.$(ARCH).o \ 91 $(SRC)/medimage.$(ARCH).o \ 92 $(SRC)/medimage_commands.$(ARCH).o \ 86 93 $(SRC)/mset.$(ARCH).o \ 87 94 $(SRC)/peak.$(ARCH).o \ … … 91 98 $(SRC)/point.$(ARCH).o \ 92 99 $(SRC)/ps.$(ARCH).o \ 100 $(SRC)/print_vectors.$(ARCH).o \ 93 101 $(SRC)/queuedelete.$(ARCH).o \ 94 102 $(SRC)/queuedrop.$(ARCH).o \ … … 143 151 $(SRC)/vmaxwell.$(ARCH).o \ 144 152 $(SRC)/vgrid.$(ARCH).o \ 153 $(SRC)/vlist.$(ARCH).o \ 145 154 $(SRC)/vload.$(ARCH).o \ 146 155 $(SRC)/vzload.$(ARCH).o \ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/densify.c
r34088 r37067 2 2 3 3 # define CHECKVAL(ARG) if (!isfinite(ARG)) { gprint (GP_ERR, "illegal value for %s: %f\n", #ARG, ARG); return (FALSE); } 4 enum {IS_DOT, IS_SQUARE, IS_CIRCLE, IS_GAUSS}; 4 5 5 6 int densify (int argc, char **argv) { 6 7 7 int i, Nx, Ny, Xb, Yb, N, Xpix, Ypix, good, UseGraph;8 int i, Nx, Ny, Xb, Yb, ix, iy, N, Xpix, Ypix, good, UseGraph; 8 9 double Xmin, Xmax, dX, Ymin, Ymax, dY; 9 10 float *val; … … 24 25 } 25 26 27 float scale = 0.0; 28 if ((N = get_argument (argc, argv, "-scale"))) { 29 remove_argument (N, &argc, argv); 30 scale = atof(argv[N]); 31 remove_argument (N, &argc, argv); 32 } 33 34 int PSFTYPE = IS_DOT; 35 if ((N = get_argument (argc, argv, "-psf"))) { 36 remove_argument (N, &argc, argv); 37 if (!strcasecmp(argv[N], "dot")) PSFTYPE = IS_DOT; 38 if (!strcasecmp(argv[N], "square")) PSFTYPE = IS_SQUARE; 39 if (!strcasecmp(argv[N], "circle")) PSFTYPE = IS_CIRCLE; 40 if (!strcasecmp(argv[N], "gauss")) PSFTYPE = IS_GAUSS; 41 remove_argument (N, &argc, argv); 42 } 43 26 44 good = UseGraph ? (argc == 4) : (argc == 10); 27 45 if (!good) { 28 46 gprint (GP_ERR, "USAGE: densify buffer x y Xmin Xmax dX Ymin Ymax dY\n"); 29 47 gprint (GP_ERR, " OR: densify buffer x y -graph\n"); 48 gprint (GP_ERR, " option: -psf [dot] (circle) (square) (gauss)\n"); 30 49 return (FALSE); 31 50 } … … 69 88 CHECKVAL(dY); 70 89 90 float scaleX = (scale > 0.0) ? scale / dX : 3.0; 91 float scaleY = (scale > 0.0) ? scale / dY : 3.0; 92 71 93 Nx = (Xmax - Xmin) / dX + 1; 72 94 Ny = (Ymax - Ymin) / dY + 1; … … 76 98 CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0); 77 99 strcpy (bf[0].file, "(empty)"); 100 101 float scale2 = (scaleX + 1.0) * (scaleY + 1.0); 102 float fSquare = 1.0 / scale2; 103 float fCircle = 1.0 / (3.141592 * scale2); 104 float fSigma = 0.5 / scale2; 105 float fGauss = 1.0 / (2.0 * 3.141592 * scale2); 78 106 79 107 x = vx[0].elements.Flt; … … 83 111 Xb = (*x - Xmin) / dX; 84 112 Yb = (*y - Ymin) / dY; 85 if (Xb >= Nx) continue; 86 if (Yb >= Ny) continue; 87 if (Xb < 0) continue; 88 if (Yb < 0) continue; 89 val[Xb + Yb*Nx] ++; 113 switch (PSFTYPE) { 114 case IS_DOT: 115 if (Xb >= Nx) continue; 116 if (Yb >= Ny) continue; 117 if (Xb < 0) continue; 118 if (Yb < 0) continue; 119 val[Xb + Yb*Nx] ++; 120 break; 121 case IS_SQUARE: 122 for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) { 123 for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) { 124 if (ix >= Nx) continue; 125 if (iy >= Ny) continue; 126 if (ix < 0) continue; 127 if (iy < 0) continue; 128 val[ix + iy*Nx] += fSquare; 129 } 130 } 131 break; 132 case IS_CIRCLE: 133 for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) { 134 float dX = ix - Xb; 135 for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) { 136 float dY = iy - Yb; 137 float r2 = dX*dX + dY*dY; 138 if (r2 > 9) continue; 139 if (ix >= Nx) continue; 140 if (iy >= Ny) continue; 141 if (ix < 0) continue; 142 if (iy < 0) continue; 143 val[ix + iy*Nx] += fCircle; 144 } 145 } 146 break; 147 case IS_GAUSS: 148 for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) { 149 float dX = ix - Xb; 150 for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) { 151 float dY = iy - Yb; 152 float r2 = dX*dX + dY*dY; 153 if (ix >= Nx) continue; 154 if (iy >= Ny) continue; 155 if (ix < 0) continue; 156 if (iy < 0) continue; 157 val[ix + iy*Nx] += fGauss*exp(-fSigma*r2); 158 } 159 } 160 break; 161 } 90 162 } 91 163 return (TRUE); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/init.c
r35416 r37067 10 10 int center PROTO((int, char **)); 11 11 int parity PROTO((int, char **)); 12 int cast PROTO((int, char **)); 12 13 int circstats PROTO((int, char **)); 13 14 int clear PROTO((int, char **)); … … 52 53 int imcut PROTO((int, char **)); 53 54 int imhist PROTO((int, char **)); 55 int impeaks PROTO((int, char **)); 54 56 int imsmooth PROTO((int, char **)); 57 int imsmooth_generic PROTO((int, char **)); 58 int imsmooth_2d PROTO((int, char **)); 55 59 int integrate PROTO((int, char **)); 56 60 int interpolate PROTO((int, char **)); 61 int join PROTO((int, char **)); 57 62 int jpeg PROTO((int, char **)); 58 63 int kern PROTO((int, char **)); … … 74 79 int mget PROTO((int, char **)); 75 80 int minterp PROTO((int, char **)); 81 int medimage_command PROTO((int, char **)); 76 82 int mset PROTO((int, char **)); 77 83 int peak PROTO((int, char **)); … … 81 87 int point PROTO((int, char **)); 82 88 int ps PROTO((int, char **)); 89 int print_vectors PROTO((int, char **)); 83 90 int queuelist PROTO((int, char **)); 84 91 int queueload PROTO((int, char **)); … … 133 140 int vmaxwell PROTO((int, char **)); 134 141 int vload PROTO((int, char **)); 142 int vlist PROTO((int, char **)); 135 143 int vzload PROTO((int, char **)); 136 144 int vstats PROTO((int, char **)); … … 160 168 {1, "buffers", list_buffers, "list the currently allocated buffers (images)"}, 161 169 {1, "center", center, "center image on coords"}, 170 {1, "cast", cast, "cast input vector to specified type"}, 162 171 {1, "circstats", circstats, "circular statistics"}, 163 172 {1, "clear", clear, "erase plot"}, … … 205 214 {1, "imcut", imcut, "linear image cut between arbitrary coords"}, 206 215 {1, "imhistogram", imhist, "histogram of an image region"}, 216 {1, "impeaks", impeaks, "find peaks in an image (return vectors)"}, 207 217 {1, "imsmooth", imsmooth, "circular gaussian smoothing"}, 218 {1, "imsmooth.generic", imsmooth_generic, "circular non-gaussian smoothing"}, 219 {1, "imsmooth.2d", imsmooth_2d, "circular non-gaussian smoothing"}, 208 220 {1, "imstats", imstats, "statistics on a portion of an image"}, 209 221 {1, "integrate", integrate, "integrate a vector"}, 210 222 {1, "interpolate", interpolate, "interpolate between vector pairs"}, 223 {1, "join", join, "find the join of two ID vectors"}, 211 224 {1, "jpeg", jpeg, "convert display image to JPEG"}, 212 225 {1, "kern", kern, "convolve with 3x3 kernel"}, … … 224 237 {1, "minterp", minterp, "interpolate image pixels"}, 225 238 {1, "iminterp", minterp, "interpolate image pixels"}, 239 {1, "medimage", medimage_command, "median image manipulation"}, 226 240 {1, "matrix", matrix, "matrix math operations"}, 227 241 {1, "match2d", match2d, "match 2 pairs of X,Y vectors and return matched indexes"}, … … 237 251 {1, "ppm", jpeg, "convert display graphic to PPM"}, 238 252 {1, "ps", ps, "convert display to PostScript"}, 253 {1, "print_vectors", print_vectors, "print a set of vectors"}, 239 254 {1, "queuedelete", queuedelete, "delete a queue"}, 240 255 {1, "queuedrop", queuedrop, "drop values from queue matching a key"}, … … 290 305 {1, "vgrid", vgrid, "generate an image from a triplet of vectors"}, 291 306 {1, "vhistogram", histogram, "generate histogram from vector"}, 307 {1, "vlist", vlist, "append values to a vector from command line"}, 292 308 {1, "vload", vload, "load vectors as overlay on image display"}, 293 309 {1, "vmaxwell", vmaxwell, "fit a Maxwellian to a vector"}, -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/match2d.c
r33963 r37067 14 14 Vector *index1, *index2; 15 15 16 if ((N = get_argument (argc, argv, "-h"))) goto usage; 17 if ((N = get_argument (argc, argv, "--help"))) goto usage; 18 16 19 CLOSEST = FALSE; 17 20 if ((N = get_argument (argc, argv, "-closest"))) { … … 38 41 if (argc != 6) { 39 42 gprint (GP_ERR, "USAGE: match2d X1 Y1 X2 Y2 Radius [-index1 (index1)] [-index2 (index2)] [-closest]\n"); 40 gprint (GP_ERR, " if -closest is provided, index1 & index2 will have the same length as X1 and X2 (respectively)\n"); 41 gprint (GP_ERR, " with either the index of the match or a value of -1 for non-matches\n"); 43 gprint (GP_ERR, " use -h or --help for more detail\n"); 42 44 return (FALSE); 43 45 } … … 90 92 91 93 return (TRUE); 94 95 usage: 96 gprint (GP_ERR, "we have two modes of operation:\n\n"); 97 98 gprint (GP_ERR, "without -closest, we are finding all matched pairs within the match radius. in this\n"); 99 gprint (GP_ERR, "case, the two index vectors have the same length, one entry per matched pair.\n"); 100 gprint (GP_ERR, "x1[index1],y1[index1] matches to x2[index2],y2[index2].\n\n"); 101 102 gprint (GP_ERR, "with -closest selected, we are finding the closest element of set 1 to each of set 2\n"); 103 gprint (GP_ERR, "and vice versa. in this case, index1 is always the same length as x1,y1, while index2\n"); 104 gprint (GP_ERR, "is the same lengths as x2,y2. x2[index1],y2[index1] matches x1,y1 while\n"); 105 gprint (GP_ERR, "x1[index2],y1[index2] matches x2,y2\n\n"); 106 107 gprint (GP_ERR, "if -index1 or -index2 is not supplied, the vectors are created with names index1 or index2\n"); 108 gprint (GP_ERR, "use 'reindex' to generate new vectors based on these index vectors\n"); 109 110 return FALSE; 92 111 } 93 112 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/read_vectors.c
r34753 r37067 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) { … … 24 26 enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME, COLTYPE_CHAR}; 25 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; 34 26 35 int read_vectors (int argc, char **argv) { 27 36 28 37 int TimeFormat; 29 38 time_t TimeReference; 30 int i, j, Nskip, Narg, Nvec, *col,IsCSV, VERBOSE;31 int Nbytes, Nstart, NELEM, Nelem, nread , *coltype;39 int i, j, Nskip, Narg, IsCSV, VERBOSE; 40 int Nbytes, Nstart, NELEM, Nelem, nread; 32 41 char *colstr, *c0, *c1, *extname; 33 Vector **vec; 34 35 char *buffer = NULL; 42 char varname[1024]; // used as a buffer for the names of string fields 36 43 37 44 /* auto-sense table type */ … … 81 88 82 89 Nvec = (argc - 1) / 2; 90 ALLOCATE (listname, char *, Nvec); 83 91 ALLOCATE (vec, Vector *, Nvec); 84 92 ALLOCATE (col, int, Nvec); 85 93 ALLOCATE (coltype, int, Nvec); 94 for (i = 0; i < Nvec; i++) { 95 listname[i] = NULL; 96 vec[i] = NULL; 97 } 86 98 87 99 for (i = 0; i < Nvec; i++) { … … 108 120 } 109 121 110 if ((vec[i] = SelectVector (argv[2*i + 1], ANYVECTOR, TRUE)) == NULL) { 111 gprint (GP_ERR, "USAGE: read name N name N ...\n"); 112 free (vec); 113 free (col); 114 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 } 115 130 } 116 131 … … 137 152 bad_colname: 138 153 gprint (GP_ERR, "USAGE: read name N name N ...\n"); 139 free (vec); 140 free (col); 154 read_vectors_cleanup(); 141 155 return (FALSE); 142 156 } … … 146 160 NELEM = 1000; 147 161 for (i = 0; i < Nvec; i++) { 148 if ((coltype[i] == COLTYPE_INT) || (coltype[i] == COLTYPE_CHAR)) { 149 ResetVector (vec[i], OPIHI_INT, NELEM); 150 } else { 151 // note that COLTYPE_TIME is a type of float 152 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; 153 174 } 154 175 } … … 159 180 if (scan_line_maxlen (f, buffer, 0x10000) == EOF) { 160 181 gprint (GP_ERR, "problem reading file %s\n", filename); 161 free (vec); 162 free (col); 182 read_vectors_cleanup(); 163 183 return FALSE; 164 184 } … … 206 226 for (i = 0; i < Nvec; i++) { 207 227 int ivalue; 208 char cvalue;209 228 double dvalue; 210 229 time_t tvalue; … … 217 236 break; 218 237 case COLTYPE_CHAR: 219 readStatus = IsCSV ? charparse_csv (&cvalue, col[i], c0) : charparse (&cvalue, col[i], c0); 220 vec[i][0].elements.Int[Nelem] = readStatus ? cvalue : 0; 221 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 } 222 255 case COLTYPE_FLT: 223 256 readStatus = IsCSV ? dparse_csv (&dvalue, col[i], c0) : dparse (&dvalue, col[i], c0); … … 249 282 NELEM += 1000; 250 283 for (i = 0; i < Nvec; i++) { 251 if (coltype[i] == COLTYPE_INT) { 252 REALLOCATE (vec[i][0].elements.Int, opihi_int, NELEM); 253 } else { 254 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; 255 295 } 256 296 } … … 259 299 } 260 300 } 301 // set the final vector / list length 261 302 for (i = 0; i < Nvec; i++) { 262 if (coltype[i] == COLTYPE_INT) { 263 REALLOCATE (vec[i][0].elements.Int, opihi_int, MAX (Nelem,1)); 264 } else { 265 REALLOCATE (vec[i][0].elements.Flt, opihi_flt, MAX (Nelem,1)); 266 } 267 vec[i][0].Nelements = Nelem; 268 } 269 270 free (vec); 271 free (col); 272 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(); 273 320 return (TRUE); 274 275 321 } 276 322 277 # define ESCAPE( MSG) {\278 gprint (GP_ERR, "%s\n", MSG); \323 # define ESCAPE(...) { \ 324 gprint (GP_ERR, __VA_ARGS__); \ 279 325 if (CCDKeyword != NULL) free (CCDKeyword); \ 280 326 gfits_free_table (&table); \ … … 285 331 286 332 off_t Nbytes; 287 int i, j, k,N, Nextend, Ny, Binary, vecType, padIfShort;333 int i, j, N, Nextend, Ny, Binary, vecType, padIfShort; 288 334 char type[16], ID[80], *CCDKeyword; 289 335 FTable table; 290 336 Header header; 291 337 Vector **vec; 338 int FITS_TRANSPOSE; 292 339 293 340 table.buffer = NULL; 294 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 } 295 348 296 349 CCDKeyword = NULL; … … 321 374 // } 322 375 323 if (argc < 2) ESCAPE ("USAGE: read -fits extension [-extnum] [-keyword key] name name ... ");324 325 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"); 326 379 fseeko (f, 0LL, SEEK_SET); 327 380 table.header = &header; … … 331 384 // first extension is PHU, cannot be a table. 332 385 // Nextend counts from 0 for first extension 333 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"); 334 387 Nbytes = gfits_data_size (&header); 335 388 fseeko (f, Nbytes, SEEK_CUR); … … 337 390 338 391 for (i = 0; i < Nextend; i++) { 339 if (!gfits_load_header (f, &header)) ESCAPE ("extension not found");392 if (!gfits_load_header (f, &header)) ESCAPE ("extension %d not found\n", i); 340 393 Nbytes = gfits_data_size (&header); 341 394 /* skip the prior data buffers */ … … 343 396 gfits_free_header (&header); 344 397 } 345 if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension ");346 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); 347 400 348 401 } else { … … 375 428 continue; 376 429 } 377 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"); 378 431 break; 379 432 } … … 384 437 gfits_scan (&header, "XTENSION", "%s", 1, type); 385 438 if (strcmp (type, "BINTABLE") && strcmp (type, "TABLE")) { 386 ESCAPE ("specified extension is not a table\n");439 ESCAPE ("specified extension %s is not a table\n", type); 387 440 } 388 441 Binary = !strcmp (type, "BINTABLE"); … … 410 463 } 411 464 412 // define the multifield vector names 413 ALLOCATE (vec, Vector *, Nval); 414 for (j = 0; j < Nval; j++) { 415 if (Nval == 1) 416 sprintf (name, "%s", argv[i]); 417 else 418 sprintf (name, "%s:%d", argv[i], j); 419 if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name"); 420 ResetVector (vec[j], vecType, Ny); 421 } 422 423 if (!strcmp (type, "char")) { 424 char *Ptr = data; 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 488 // define the multifield vector names (Nval vectors x Ny elements) 489 ALLOCATE (vec, Vector *, Nval); 490 for (j = 0; j < Nval; j++) { 491 if (Nval == 1) 492 sprintf (name, "%s", argv[i]); 493 else 494 sprintf (name, "%s:%d", argv[i], j); 495 if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name"); 496 ResetVector (vec[j], vecType, Ny); 497 } 498 499 if (!VectorAssignData (vec, type, data, Ny, Nval)) ESCAPE ("bad column type %s", type); 500 501 } else { 502 // define the multifield vector names (Ny vectors x Nval elements) 503 ALLOCATE (vec, Vector *, Ny); 425 504 for (j = 0; j < Ny; j++) { 426 for (k = 0; k < Nval; k++, Ptr++) { 427 vec[k][0].elements.Int[j] = *Ptr; 428 } 429 } 430 } 431 if (!strcmp (type, "short")) { 432 short *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, "int")) { 440 int *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, "int64_t")) { 448 int64_t *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, "float")) { 456 float *Ptr = data; 457 for (j = 0; j < Ny; j++) { 458 for (k = 0; k < Nval; k++, Ptr++) { 459 vec[k][0].elements.Flt[j] = *Ptr; 460 } 461 } 462 } 463 if (!strcmp (type, "double")) { 464 double *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 } 505 if (Ny == 1) 506 sprintf (name, "%s", argv[i]); 507 else 508 sprintf (name, "%s:%d", argv[i], j); 509 if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name"); 510 ResetVector (vec[j], vecType, Nval); 511 } 512 513 if (!VectorAssignDataTranspose (vec, type, data, Ny, Nval)) ESCAPE ("bad column type %s", type); 470 514 } 471 515 free (data); … … 477 521 return (TRUE); 478 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/ipp-ops-20130712/Ohana/src/opihi/cmd.data/rebin.c
r28241 r37067 133 133 *Vout += *Vin; 134 134 if (Normalize) {(*Vn) ++;} 135 // if ((i == 1) && (j == 1)) fprintf (stderr, "%d,%d : %d,%d : %f : %f : %d\n", i, j, x, y, *Vin, *Vout, *Vn); 135 136 } 136 137 if (Normalize) {Vn ++;} -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/vellipse.c
r25757 r37067 228 228 */ 229 229 230 // XXX NOTE that PHI is defined with the wrong sign, should fix this... 230 231 opihi_flt fellipseOD (opihi_flt alpha, opihi_flt *par, int Npar, opihi_flt *dpar) { 231 232 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/cmd.data/vgauss.c
r35109 r37067 48 48 if ((ovec = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE); 49 49 50 CastVector (xvec, OPIHI_FLT); 51 CastVector (yvec, OPIHI_FLT); 52 50 53 int Nsvec = strlen(argv[3]); 51 54 … … 69 72 } 70 73 71 CastVector (xvec, OPIHI_FLT);72 CastVector (yvec, OPIHI_FLT);73 74 CastVector (svec, OPIHI_FLT); 74 75 // XXX Cast is failing. -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/Makefile
r34461 r37067 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 $(SRC)/ddmags.$(ARCH).o \ 51 $(SRC)/coordimage.$(ARCH).o \ 52 $(SRC)/coordmosaic.$(ARCH).o \ 43 53 $(SRC)/detrend.$(ARCH).o \ 44 $(SRC)/dmagaves.$(ARCH).o \45 $(SRC)/dmagmeas.$(ARCH).o \46 $(SRC)/dmags.$(ARCH).o \47 54 $(SRC)/dmt.$(ARCH).o \ 48 55 $(SRC)/elixir.$(ARCH).o \ 49 $(SRC)/fitcolors.$(ARCH).o \50 56 $(SRC)/fitsed.$(ARCH).o \ 51 57 $(SRC)/gcat.$(ARCH).o \ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/avextract.c
r35416 r37067 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/ipp-ops-20130712/Ohana/src/opihi/dvo/avmatch.c
r35416 r37067 70 70 dbExtractAveragesInit (); 71 71 72 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results73 72 RAvec = NULL; 74 73 DECvec = NULL; 75 if (PARALLEL && !HOST_ID) {76 if (!CoordsFile) {77 // get vectors corresponding to coordinates of interest78 if ((RAvec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto help;79 if ((DECvec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) goto help;80 81 ALLOCATE (vec, Vector *, 2);82 vec[0] = RAvec;83 vec[1] = DECvec;84 85 CoordsFile = abspath("coords.fits", 1024);86 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL);87 if (!status) goto escape;88 }89 90 char *targv1 = argv[1];91 char *targv2 = argv[2];92 argv[1] = strcreate ("-coords");93 argv[2] = strcreate (CoordsFile);94 free (CoordsFile);95 96 // I need to pass the RA & DEC vectors to the remote clients...97 int status = HostTableParallelOps (skylist, argc, argv, RESULT_FILE, TRUE, RAvec->Nelements, VERBOSE);98 if (vec) free (vec);99 100 free (argv[1]);101 free (argv[2]);102 argv[1] = targv1;103 argv[2] = targv2;104 105 return status;106 }107 108 74 // get vectors corresponding to coordinates of interest 109 75 if (CoordsFile) { … … 120 86 remove_argument (1, &argc, argv); 121 87 } 88 89 /* load regions which contain all supplied RA,DEC coordinates */ 90 if ((skylist = SelectRegionsByCoordVectors (RAvec, DECvec)) == NULL) goto escape; 91 92 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results 93 if (PARALLEL && !HOST_ID) { 94 95 // We need to copy the args to a temp array and modify them so that we send the 96 // correct set to the remote client. The args list looks like this: 97 // if (!CoordsFile) : avmatch (RADIUS) field, ... [we removed RA & DEC above] 98 // if ( CoordsFile) : avmatch (RADIUS) field, ... [because we stripped off the -coords filename elements] 99 100 // allocate the temp array and copy all but (RA) (DEC) 101 int targc = 0; 102 char **targv = NULL; 103 ALLOCATE (targv, char *, argc + 2); 104 for (i = 0; i < argc; i++) { 105 targv[targc] = strcreate (argv[i]); 106 targc ++; 107 } 108 109 // if not specified, create the coords.fits input file 110 // NOTE: RAvec, DECvec were set above 111 if (!CoordsFile) { 112 ALLOCATE (vec, Vector *, 2); 113 vec[0] = RAvec; 114 vec[1] = DECvec; 115 116 CoordsFile = abspath("coords.fits", 1024); 117 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL); 118 if (!status) goto escape; 119 } 120 121 // add the coords file to the args list 122 targv[targc+0] = strcreate ("-coords"); 123 targv[targc+1] = CoordsFile; // this gets freed with targv 124 targc += 2; 125 126 // I need to pass the RA & DEC vectors to the remote clients... 127 int status = HostTableParallelOps (skylist, targc, targv, RESULT_FILE, TRUE, RAvec->Nelements, VERBOSE); 128 if (vec) free (vec); 129 130 // free up targv 131 for (i = 0; i < targc; i++) { 132 free (targv[i]); 133 } 134 free (targv); 135 136 return status; 137 } 138 122 139 RADIUS = atof (argv[1]); 123 140 remove_argument (1, &argc, argv); … … 135 152 int needMeasures = FALSE; 136 153 for (i = 0; !needMeasures && (i < Nfields); i++) { 137 if (fields[i].magMode == MAG_NONE) continue;138 154 if (fields[i].photcode == NULL) continue; // assert this? 139 155 if (fields[i].photcode[0].type == PHOT_REF) needMeasures = TRUE; 140 156 if (fields[i].photcode[0].type == PHOT_DEP) needMeasures = TRUE; 141 157 } 142 143 /* load regions which contain all supplied RA,DEC coordinates */144 if ((skylist = SelectRegionsByCoordVectors (RAvec, DECvec)) == NULL) goto escape;145 158 146 159 /* create output storage vectors */ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/dvo_client.c
r35263 r37067 90 90 } 91 91 92 // these are set in 'startup.c' for readline-based programs 93 set_variable ("PID", getpid()); 94 set_str_variable ("KAPA", "kapa"); 95 set_int_variable ("UNSIGN", 0); 96 gfits_set_unsign_mode (FALSE); 97 92 98 return; 93 99 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/find_matches.c
r29759 r37067 50 50 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 51 51 tcoords.Npolyterms = 1; 52 strcpy (tcoords.ctype, " RA---ARC");52 strcpy (tcoords.ctype, "DEC--ARC"); 53 53 54 54 // this region includes a boundary layer of size RADIUS -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/fitsed.c
r34088 r37067 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/ipp-ops-20130712/Ohana/src/opihi/dvo/gimages.c
r34844 r37067 136 136 local.pc2_1 = local.pc1_2 = 0.0; 137 137 local.Npolyterms = 1; 138 strcpy (local.ctype, " RA---TAN");138 strcpy (local.ctype, "DEC--TAN"); 139 139 140 140 if (typehash == DistortImage) { -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/gstar.c
r35109 r37067 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, … … 307 307 gprint (GP_LOG, "\n"); 308 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);;309 /* Mmin */ 310 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_MIN); 311 gprint (GP_LOG, "\n"); 312 313 /* Mmax */ 314 for (j = 0; j < Nsecfilt; j++) printPhotcodeSequence (&catalog.average[k], &catalog.secfilt[Nsecfilt*k], j, GSTAR_AVE_MAG_MAX);; 315 315 gprint (GP_LOG, "\n"); 316 316 … … 374 374 int Nv = index[j]; 375 375 376 Mcat = PhotCat (&catalog.measure[Nv] );376 Mcat = PhotCat (&catalog.measure[Nv], MAG_CLASS_PSF); 377 377 if (INST) { 378 Mrel = PhotInst (&catalog.measure[Nv] );378 Mrel = PhotInst (&catalog.measure[Nv], MAG_CLASS_PSF); 379 379 } else { 380 Mrel = PhotRel (&catalog.measure[Nv], &catalog.average[k], &catalog.secfilt[k*Nsecfilt] );380 Mrel = PhotRel (&catalog.measure[Nv], &catalog.average[k], &catalog.secfilt[k*Nsecfilt], MAG_CLASS_PSF); 381 381 } 382 383 float dRoff = dvoOffsetR(&catalog.measure[Nv], &catalog.average[k]); 384 float dDoff = dvoOffsetD(&catalog.measure[Nv], &catalog.average[k]); 382 385 383 386 if (GetMeasures && !QUIET) { … … 387 390 gprint (GP_LOG, "%6.3f ", catalog.measure[Nv].dM); 388 391 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); 392 393 gprint (GP_LOG, "%7.4f ", dRoff); 394 gprint (GP_LOG, "%7.4f ", dDoff); 391 395 gprint (GP_LOG, "0x%08x ", catalog.measure[Nv].photFlags); 392 396 gprint (GP_LOG, "0x%08x ", catalog.measure[Nv].dbFlags); … … 447 451 vec3[0].elements.Flt[N] = catalog.measure[Nv].airmass; 448 452 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;453 vec5[0].elements.Flt[N] = dRoff; 454 vec6[0].elements.Flt[N] = dDoff; 451 455 N ++; 452 456 if (N == NPTS - 1) { … … 561 565 case GSTAR_AVE_MAG_CHISQ: /* average mag chisq */ 562 566 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);567 print_double (NAN); 568 } else { 569 print_double (secfilt[seq].Mchisq); 566 570 } 567 571 break; … … 596 600 break; 597 601 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);602 case GSTAR_AVE_MAG_MIN: /* average ap mags */ 603 if (seq == -1) { 604 print_double (NAN); 605 } else { 606 print_double (secfilt[seq].Mmin); 607 } 608 break; 609 610 case GSTAR_AVE_MAG_MAX: /* average ap mags */ 611 if (seq == -1) { 612 print_double (NAN); 613 } else { 614 print_double (secfilt[seq].Mmax); 611 615 } 612 616 break; … … 632 636 print_double (NAN); 633 637 } else { 634 print_double_exp (secfilt[seq].F luxPSF);638 print_double_exp (secfilt[seq].FpsfStk); 635 639 } 636 640 break; … … 640 644 print_double (NAN); 641 645 } else { 642 print_double_exp (secfilt[seq].dF luxPSF);646 print_double_exp (secfilt[seq].dFpsfStk); 643 647 } 644 648 break; … … 648 652 print_double (NAN); 649 653 } else { 650 print_double_exp (secfilt[seq].F luxKron);654 print_double_exp (secfilt[seq].FkronStk); 651 655 } 652 656 break; … … 656 660 print_double (NAN); 657 661 } else { 658 print_double_exp (secfilt[seq].dF luxKron);659 } 660 break; 661 662 } 663 } 662 print_double_exp (secfilt[seq].dFkronStk); 663 } 664 break; 665 666 } 667 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/hosts.c
r35757 r37067 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 … … 12 15 gprint (GP_ERR, " commands:\n"); 13 16 gprint (GP_ERR, " purge-temp : delete all tempfiles for this shell\n"); 14 gprint (GP_ERR, " : [-old-pid] [-all-pid] [-v] [-verbose] [-commit] [-type type] \n");17 gprint (GP_ERR, " : [-old-pid] [-all-pid] [-v] [-verbose] [-commit] [-type type] [-age hours]\n"); 15 18 gprint (GP_ERR, " get-results : determine name of RESULTS file\n"); 16 19 return FALSE; … … 33 36 } 34 37 38 struct timeval now; 39 gettimeofday (&now, NULL); 40 41 float AGE = 0; 42 int NOW = now.tv_sec; 43 if ((N = get_argument (argc, argv, "-age"))) { 44 remove_argument (N, &argc, argv); 45 AGE = atof(argv[N]); 46 remove_argument (N, &argc, argv); 47 } 48 35 49 int VERBOSE = FALSE; 36 50 if ((N = get_argument (argc, argv, "-v"))) { … … 60 74 if (!strcasecmp(argv[N], "dvo.results")) TEMP_TYPE = TEMP_DVO_RESULTS; 61 75 if (!strcasecmp(argv[N], "dvo.log")) TEMP_TYPE = TEMP_DVO_LOG; 62 if (!strcasecmp(argv[N], "relastro.catalog")) TEMP_TYPE = TEMP_RELASTRO_CATALOG;76 if (!strcasecmp(argv[N], "relastro.catalog")) TEMP_TYPE = TEMP_RELASTRO_CATALOG; 63 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; 64 81 if (!strcasecmp(argv[N], "relphot.log")) TEMP_TYPE = TEMP_RELPHOT_LOG; 65 82 if (!strcasecmp(argv[N], "dvopsps.det")) TEMP_TYPE = TEMP_DVOPSPS_DET; … … 67 84 if (TEMP_TYPE == TEMP_NONE) { 68 85 gprint (GP_ERR, "USAGE: hosts purge-temp [-type (type)]\n"); 69 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"); 70 87 return FALSE; 71 88 } … … 107 124 if (TEMP_TYPE == TEMP_RELPHOT_CATALOG) snprintf (name, DVO_MAX_PATH, "%s/relphot.catalog.subset.dat", table->hosts[i].pathname); 108 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); 109 129 if (TEMP_TYPE == TEMP_DVOPSPS_DET) snprintf (name, DVO_MAX_PATH, "%s/dvopsps.*.det.dat", table->hosts[i].pathname); 110 130 if (TEMP_TYPE == TEMP_FIXSTKIDS_RESULTS) snprintf (name, DVO_MAX_PATH, "%s/fixstkids.results.*.dat", table->hosts[i].pathname); … … 115 135 if (TEMP_TYPE == TEMP_RELPHOT_CATALOG) snprintf (name, DVO_MAX_PATH, "%s/relphot.catalog.subset.dat", table->hosts[i].pathname); 116 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); 117 140 if (TEMP_TYPE == TEMP_DVOPSPS_DET) snprintf (name, DVO_MAX_PATH, "%s/dvopsps.%05d.*.det.dat", table->hosts[i].pathname, PID); 118 141 if (TEMP_TYPE == TEMP_FIXSTKIDS_RESULTS) snprintf (name, DVO_MAX_PATH, "%s/fixstkids.results.%05d.*.dat", table->hosts[i].pathname, PID); … … 121 144 glob (name, 0, NULL, &pglob); 122 145 int j; 146 struct stat filestats; 123 147 for (j = 0; j < pglob.gl_pathc; j++) { 148 if (AGE > 0) { 149 if (stat(pglob.gl_pathv[j], &filestats)) { 150 gprint (GP_ERR, "failed to get stats for %s\n", pglob.gl_pathv[j]); 151 continue; 152 } 153 float myAge = (NOW - filestats.st_mtime) / 3600.0; 154 if (myAge < AGE) continue; 155 } 124 156 if (VERBOSE) gprint (GP_ERR, "unlink %s\n", pglob.gl_pathv[j]); 125 157 if (!DRYRUN) unlink (pglob.gl_pathv[j]); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/imdata.c
r34088 r37067 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/ipp-ops-20130712/Ohana/src/opihi/dvo/imextract.c
r34088 r37067 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/ipp-ops-20130712/Ohana/src/opihi/dvo/init.c
r34461 r37067 13 13 int cmpload PROTO((int, char **)); 14 14 int cmpread PROTO((int, char **)); 15 int coordimage PROTO((int, char **)); 16 int coordmosaic PROTO((int, char **)); 17 int psastro_model PROTO((int, char **)); 15 18 int ddmags PROTO((int, char **)); 16 19 int detrend PROTO((int, char **)); … … 63 66 {1, "avmatch", avmatch, "extract average data values matched to RA,DEC points"}, 64 67 {1, "badimages", badimages, "look for images with anomalous astrometry"}, 65 {1, "calextract", calextract, "extract photometry calibration"},66 {1, "calmextract", calmextract, "extract photometry calibration"},68 // {1, "calextract", calextract, "extract photometry calibration"}, 69 // {1, "calmextract", calmextract, "extract photometry calibration"}, 67 70 {1, "catdir", catdir_define,"re-define CATDIR"}, 68 {1, "ccd", ccd, "plot color-color diagram"},71 // {1, "ccd", ccd, "plot color-color diagram"}, 69 72 {1, "cmatch", cmatch, "match two catalogs"}, 70 {1, "cmd", cmd, "plot cmd of stars in current region"},73 // {1, "cmd", cmd, "plot cmd of stars in current region"}, 71 74 {1, "cmpload", cmpload, "load cmp file into ?"}, 72 75 {1, "cmpread", cmpread, "read data from cmp format files"}, 73 {1, "ddmags", ddmags, "plot magnitude differences"}, 76 {1, "coordimage", coordimage, "generate a map of the transformation residuals"}, 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"}, 74 80 {1, "detrend", detrend, "extract from detrend database?"}, 75 {1, "dmagaves", dmagaves, "foo"},76 {1, "dmagmeas", dmagmeas, "foo"},77 {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"}, 78 84 {1, "dmt", dmt, "plot mag scatter"}, 79 85 {1, "elixir", elixir, "talk to elixir"}, 80 {1, "fitcolors", fitcolors, "fit chip-to-chip color terms"},86 // {1, "fitcolors", fitcolors, "fit chip-to-chip color terms"}, 81 87 {1, "fitsed", fitsed, "fit stellar SEDs to objects"}, 82 88 {1, "gcat", gcat, "get catalog at location"}, -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/lcurve.c
r34584 r37067 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/ipp-ops-20130712/Ohana/src/opihi/dvo/lightcurve.c
r27435 r37067 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/ipp-ops-20130712/Ohana/src/opihi/dvo/photometry.c
r35416 r37067 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 … … 662 633 break; 663 634 case AVE_dMAG: 664 value = Phot dM(code, average, secfilt);635 value = PhotAveErr (code, average, secfilt); 665 636 break; 666 637 case AVE_Xm: … … 865 836 /* for ErrSelect, check average errors */ 866 837 if (ErrSelect) { 867 dM = Phot dM(code, average, secfilt);838 dM = PhotAveErr (code, average, secfilt); 868 839 if (dM > ErrValue) return (FALSE); 869 840 } … … 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/ipp-ops-20130712/Ohana/src/opihi/dvo/pmeasure.c
r34088 r37067 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/ipp-ops-20130712/Ohana/src/opihi/dvo/showtile.c
r34584 r37067 34 34 coords.pc1_2 = coords.pc2_1 = 0.0; 35 35 coords.Npolyterms = 0; 36 strcpy (coords.ctype, " RA---TAN");36 strcpy (coords.ctype, "DEC--TAN"); 37 37 38 38 /* fill in top-left region */ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/simage.c
r34584 r37067 43 43 /* get astrometry information */ 44 44 strcpy (coords.ctype, "NONE"); 45 gfits_scan (&header, "CTYPE 1", "%s", 1, coords.ctype);46 if (strcmp (coords.ctype, " RA---PLY")) {45 gfits_scan (&header, "CTYPE2", "%s", 1, coords.ctype); 46 if (strcmp (coords.ctype, "DEC--PLY")) { 47 47 gprint (GP_ERR, "ERROR: wrong astrometric info in header\n"); 48 48 return (FALSE); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/dvo/subpix.c
r31635 r37067 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/ipp-ops-20130712/Ohana/src/opihi/include/data.h
r34584 r37067 33 33 char **pageIDs; 34 34 } Book; 35 36 // the interpolating spline has valu 37 typedef struct { 38 int Nknots; 39 opihi_flt *xk; 40 opihi_flt *yk; 41 opihi_flt *y2; 42 char *name; 43 } Spline; 44 45 typedef struct { 46 char *name; 47 int Ninput; 48 int Nx; 49 int Ny; 50 float **buffers; 51 } MedImageType; 35 52 36 53 void InitData (void); … … 144 161 145 162 /* starfuncs.c */ 146 double get_aperture_stats (Matrix *matrix, int X, int Y, int Npix, int Nborder, double max );163 double get_aperture_stats (Matrix *matrix, int X, int Y, int Npix, int Nborder, double max, int VERBOSE); 147 164 int set_rough_radii (double Ra, double Ri, double Ro); 148 165 int get_rough_star (float *data, int Nx, int Ny, int x, int y, opihi_flt *xc, opihi_flt *yc, opihi_flt *sx, opihi_flt *sy, opihi_flt *sxy, opihi_flt *zs, opihi_flt *zp, opihi_flt *sk); … … 170 187 void FreeQueues (void); 171 188 void FreeBooks (void); 172 173 // the interpolating spline has valu174 typedef struct {175 int Nknots;176 opihi_flt *xk;177 opihi_flt *yk;178 opihi_flt *y2;179 char *name;180 } Spline;181 189 182 190 /* in SplineOps.c */ … … 207 215 double hermitian_10(double x); 208 216 217 /* in MedImageOps.c */ 218 void InitMedImages (); 219 void FreeMedImages (); 220 void FreeMedImage (MedImageType *medimage); 221 MedImageType *FindMedImage (char *name); 222 MedImageType *CreateMedImage (char *name, int Nx, int Ny); 223 int DeleteMedImage (MedImageType *medimage); 224 void ListMedImages (); 225 209 226 # endif -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/include/dvomath.h
r33662 r37067 55 55 } Buffer; 56 56 57 typedef enum { 58 ST_NONE, 59 ST_LEFT, 60 ST_RIGHT, 61 ST_COMMA, 62 ST_TRINARY, 63 ST_OR, 64 ST_AND, 65 ST_LOGIC, 66 ST_BITWISE, 67 ST_ADD, 68 ST_TIMES, 69 ST_POWER, 70 ST_UNARY, 71 ST_BINARY, 72 73 ST_VALUE, 74 ST_SCALAR_INT, 75 ST_SCALAR_FLT, 76 ST_VECTOR, 77 ST_VECTOR_TMP, 78 ST_MATRIX, 79 ST_MATRIX_TMP, 80 81 ST_STRING, 82 ST_STRING_TMP, 83 } StackVarType; 84 57 85 typedef struct { /* math stack structure */ 58 86 char *name; 59 chartype;87 StackVarType type; 60 88 Buffer *buffer; 61 89 Vector *vector; … … 77 105 void delete_stack PROTO((StackVar *stack, int Nstack)); 78 106 void clear_stack PROTO((StackVar *stack)); 79 void assign_stack PROTO((StackVar *stack, char *name, int type)); 107 void assign_stack PROTO((StackVar *stack, char *name, StackVarType type)); 108 109 int SSS_trinary PROTO((StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op)); 110 int VVV_trinary PROTO((StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op)); 111 int MMM_trinary PROTO((StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op)); 80 112 81 113 int VV_binary PROTO((StackVar *OUT, StackVar *V1, StackVar *V2, char *op)); … … 138 170 Vector **ReadVectorTableFITS PROTO((char *filename, char *extname, int *Nvec)); 139 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 140 175 /* buffer handling */ 141 176 Buffer *InitBuffer PROTO((void)); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/include/dvoshell.h
r35416 r37067 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/ipp-ops-20130712/Ohana/src/opihi/include/pantasks.h
r32632 r37067 116 116 117 117 int active; 118 int priority;118 int nicelevel; 119 119 120 120 } Task; … … 161 161 162 162 JobMode mode; /* local or controller? */ 163 int priority;163 int nicelevel; 164 164 char *realhost; 165 165 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/include/pcontrol.h
r33662 r37067 8 8 /** job status values **/ 9 9 typedef enum { 10 PCONTROL_JOB_NONE, // XXX OK? 10 11 PCONTROL_JOB_ALLJOBS, 11 12 PCONTROL_JOB_PENDING, … … 119 120 int exit_status; 120 121 int Reset; 121 int priority;122 int nicelevel; 122 123 JobMode mode; 123 124 JobStat state; … … 309 310 char *GetJobStackName (int StackID); 310 311 Stack *GetJobStackByName (char *name); 312 int GetJobStackIDbyName (char *name); 311 313 int PutJob (Job *job, int StackID, int where); 312 314 int PutJobSetState (Job *job, int StackID, int where, int state); 313 315 Job *PullJobByID (IDtype JobID, int *StackID); 314 316 Job *PullJobFromStackByID (int StackID, int ID); 315 IDtype AddJob (char *hostname, JobMode mode, int timeout, int priority, int argc, char **argv, int Nxhosts, char **xhosts);317 IDtype AddJob (char *hostname, JobMode mode, int timeout, int nicelevel, int argc, char **argv, int Nxhosts, char **xhosts); 316 318 void DelJob (Job *job); 317 319 Host *UnlinkJobAndHost (Job *job); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/include/shell.h
r33662 r37067 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/ipp-ops-20130712/Ohana/src/opihi/lib.data/Makefile
r34584 r37067 24 24 $(SDIR)/spline.$(ARCH).o \ 25 25 $(SDIR)/SplineOps.$(ARCH).o \ 26 $(SDIR)/MedImageOps.$(ARCH).o \ 26 27 $(SDIR)/mrqmin.$(ARCH).o \ 27 28 $(SDIR)/mrq2dmin.$(ARCH).o \ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.data/starfuncs.c
r34088 r37067 1 1 # include "data.h" 2 2 3 double get_aperture_stats (Matrix *matrix, int X, int Y, int Npix, int Nborder, double max ) {3 double get_aperture_stats (Matrix *matrix, int X, int Y, int Npix, int Nborder, double max, int VERBOSE) { 4 4 5 5 double *ring; … … 95 95 set_int_variable ("Npts", Npts); 96 96 97 gprint (GP_LOG, "%f %f %f %f %f %f %f %f\n", x, y, FWHMx, FWHMy, sky, I, mag, dmag);97 if (VERBOSE) gprint (GP_LOG, "%f %f %f %f %f %f %f %f\n", x, y, FWHMx, FWHMy, sky, I, mag, dmag); 98 98 99 99 return (mag); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/ListOps.c
r33963 r37067 185 185 186 186 // list (word) : nested list 187 // list (word) -x : not nested list 188 // list (word) -split : not nested list187 // list (word) -x : not nested list [-x may be the list of options below] 188 // list -excel (word) -x : 189 189 int is_list_data (char *line) { 190 190 191 char *comm, *temp; 192 193 temp = thisword (nextword (nextword (line))); 194 comm = thisword (line); 195 191 char *comm = NULL; 192 char *temp = NULL; 193 char *name = NULL; 194 char *opts = NULL; 195 196 comm = thisword (line); 196 197 if (comm == NULL) goto escape; 197 198 198 if (strcmp (comm, "list")) goto escape; 199 200 // name == name of the list in question 201 name = nextword (line); 202 203 // skip a -excel or -excel-style modifier 204 if (!strncmp("-excel", name, strlen("-excel"))) name = nextword (name); 205 if (!strncmp("-excel-style", name, strlen("-excel-style"))) name = nextword (name); 206 207 // get the thing following ptr, if any (opts points at a substring, temp is a new string) 208 opts = nextword (name); 209 temp = thisword (opts); 199 210 200 211 /* if (cond) (command) does not define a complete block */ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/VectorIO.c
r35109 r37067 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/ipp-ops-20130712/Ohana/src/opihi/lib.shell/check_stack.c
r34260 r37067 12 12 13 13 for (i = 0; i < Nstack; i++) { 14 if (stack[i].type == 'X') {14 if (stack[i].type == ST_VALUE) { 15 15 16 16 /** if this is a number, put it on the list of scalars and move on. assume value is … … 27 27 stack[i].IntValue = strtol (stack[i].name, &c2, 0); 28 28 if ((fabs(stack[i].FltValue) > MAX_INT) && (c1 == stack[i].name + strlen (stack[i].name))) { 29 stack[i].type = 'S'; // 'S' ==(float)29 stack[i].type = ST_SCALAR_FLT; // (float) 30 30 continue; 31 31 } 32 32 if (c2 == stack[i].name + strlen (stack[i].name)) { 33 stack[i].type = 's'; // 's' ==(int)33 stack[i].type = ST_SCALAR_INT; // (int) 34 34 continue; 35 35 } 36 36 if (c1 == stack[i].name + strlen (stack[i].name)) { 37 stack[i].type = 'S'; // 'S' ==(float)37 stack[i].type = ST_SCALAR_FLT; // (float) 38 38 continue; 39 39 } … … 42 42 if (IsBuffer (stack[i].name)) { 43 43 stack[i].buffer = SelectBuffer (stack[i].name, OLDBUFFER, TRUE); 44 stack[i].type = 'M';44 stack[i].type = ST_MATRIX; 45 45 if (Nx == -1) { 46 46 Nx = stack[i].buffer[0].matrix.Naxis[0]; … … 63 63 if (IsVector (stack[i].name)) { 64 64 stack[i].vector = SelectVector (stack[i].name, OLDVECTOR, FALSE); 65 stack[i].type = 'V';65 stack[i].type = ST_VECTOR; 66 66 67 67 if (Nv == -1) Nv = stack[i].vector[0].Nelements; … … 80 80 81 81 /* this is not a scalar, vector, or matrix. must be string */ 82 stack[i].type = 'W';82 stack[i].type = ST_STRING; 83 83 } 84 84 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/convert_to_RPN.c
r34088 r37067 4 4 StackVar *convert_to_RPN (int argc, char **argv, int *nstack) { 5 5 6 inttype;6 StackVarType type; 7 7 int i, j, Nstack, Nop_stack, NSTACK; 8 8 StackVar *stack, *op_stack; … … 21 21 22 22 /* decide on priority of object */ 23 type = 0; 23 type = ST_NONE; 24 25 /* trinary operations */ 26 if (!strcmp (argv[i], "?")) { type = ST_TRINARY; goto gotit; } 27 if (!strcmp (argv[i], ":")) { type = ST_COMMA; goto gotit; } 28 24 29 /* unary operations */ 25 if (!strcmp (argv[i], "abs")) { type = 9; goto gotit; }26 if (!strcmp (argv[i], "int")) { type = 9; goto gotit; }27 if (!strcmp (argv[i], " exp")) { type = 9; goto gotit; }28 if (!strcmp (argv[i], " ten")) { type = 9; goto gotit; }29 if (!strcmp (argv[i], " log")) { type = 9; goto gotit; }30 if (!strcmp (argv[i], " ln")) { type = 9; goto gotit; }31 if (!strcmp (argv[i], " sqrt")) { type = 9; goto gotit; }32 if (!strcmp (argv[i], " erf")) { type = 9; goto gotit; }33 34 if (!strcmp (argv[i], " sinh")) { type = 9; goto gotit; }35 if (!strcmp (argv[i], " cosh")) { type = 9; goto gotit; }36 if (!strcmp (argv[i], " asinh")) { type = 9; goto gotit; }37 if (!strcmp (argv[i], " acosh")) { type = 9; goto gotit; }38 39 if (!strcmp (argv[i], " sin")) { type = 9; goto gotit; }40 if (!strcmp (argv[i], " cos")) { type = 9; goto gotit; }41 if (!strcmp (argv[i], " tan")) { type = 9; goto gotit; }42 if (!strcmp (argv[i], " dsin")) { type = 9; goto gotit; }43 if (!strcmp (argv[i], " dcos")) { type = 9; goto gotit; }44 if (!strcmp (argv[i], "d tan")) { type = 9; goto gotit; }45 if (!strcmp (argv[i], " asin")) { type = 9; goto gotit; }46 if (!strcmp (argv[i], " acos")) { type = 9; goto gotit; }47 if (!strcmp (argv[i], "a tan")) { type = 9; goto gotit; }48 if (!strcmp (argv[i], " dasin")) { type = 9; goto gotit; }49 if (!strcmp (argv[i], " dacos")) { type = 9; goto gotit; }50 if (!strcmp (argv[i], "da tan")) { type = 9; goto gotit; }51 52 if (!strcmp (argv[i], " lgamma")) { type = 9; goto gotit; }53 54 if (!strcmp (argv[i], "rnd")) { type = 9; goto gotit; }55 if (!strcmp (argv[i], "xramp")) { type = 9; goto gotit; }56 if (!strcmp (argv[i], "yramp")) { type = 9; goto gotit; }57 if (!strcmp (argv[i], "ramp")) { type = 9; goto gotit; }58 if (!strcmp (argv[i], "zero")) { type = 9; goto gotit; }59 if (!strcmp (argv[i], "--")) { type = 9; goto gotit; }60 if (!strcmp (argv[i], "not")) { type = 9; goto gotit; }61 if (!strcmp (argv[i], "isinf")) { type = 9; goto gotit; }62 if (!strcmp (argv[i], "isnan")) { type = 9; goto gotit; }30 if (!strcmp (argv[i], "abs")) { type = ST_UNARY; goto gotit; } 31 if (!strcmp (argv[i], "int")) { type = ST_UNARY; goto gotit; } 32 if (!strcmp (argv[i], "floor")) { type = ST_UNARY; goto gotit; } 33 if (!strcmp (argv[i], "round")) { type = ST_UNARY; goto gotit; } 34 if (!strcmp (argv[i], "ceil")) { type = ST_UNARY; goto gotit; } 35 if (!strcmp (argv[i], "rint")) { type = ST_UNARY; goto gotit; } 36 if (!strcmp (argv[i], "exp")) { type = ST_UNARY; goto gotit; } 37 if (!strcmp (argv[i], "ten")) { type = ST_UNARY; goto gotit; } 38 if (!strcmp (argv[i], "log")) { type = ST_UNARY; goto gotit; } 39 if (!strcmp (argv[i], "ln")) { type = ST_UNARY; goto gotit; } 40 if (!strcmp (argv[i], "sqrt")) { type = ST_UNARY; goto gotit; } 41 if (!strcmp (argv[i], "erf")) { type = ST_UNARY; goto gotit; } 42 if (!strcmp (argv[i], "sinh")) { type = ST_UNARY; goto gotit; } 43 if (!strcmp (argv[i], "cosh")) { type = ST_UNARY; goto gotit; } 44 if (!strcmp (argv[i], "asinh")) { type = ST_UNARY; goto gotit; } 45 if (!strcmp (argv[i], "acosh")) { type = ST_UNARY; goto gotit; } 46 if (!strcmp (argv[i], "sin")) { type = ST_UNARY; goto gotit; } 47 if (!strcmp (argv[i], "cos")) { type = ST_UNARY; goto gotit; } 48 if (!strcmp (argv[i], "tan")) { type = ST_UNARY; goto gotit; } 49 if (!strcmp (argv[i], "dsin")) { type = ST_UNARY; goto gotit; } 50 if (!strcmp (argv[i], "dcos")) { type = ST_UNARY; goto gotit; } 51 if (!strcmp (argv[i], "dtan")) { type = ST_UNARY; goto gotit; } 52 if (!strcmp (argv[i], "asin")) { type = ST_UNARY; goto gotit; } 53 if (!strcmp (argv[i], "acos")) { type = ST_UNARY; goto gotit; } 54 if (!strcmp (argv[i], "atan")) { type = ST_UNARY; goto gotit; } 55 if (!strcmp (argv[i], "dasin")) { type = ST_UNARY; goto gotit; } 56 if (!strcmp (argv[i], "dacos")) { type = ST_UNARY; goto gotit; } 57 if (!strcmp (argv[i], "datan")) { type = ST_UNARY; goto gotit; } 58 if (!strcmp (argv[i], "lgamma")) { type = ST_UNARY; goto gotit; } 59 if (!strcmp (argv[i], "rnd")) { type = ST_UNARY; goto gotit; } 60 if (!strcmp (argv[i], "xramp")) { type = ST_UNARY; goto gotit; } 61 if (!strcmp (argv[i], "yramp")) { type = ST_UNARY; goto gotit; } 62 if (!strcmp (argv[i], "ramp")) { type = ST_UNARY; goto gotit; } 63 if (!strcmp (argv[i], "zero")) { type = ST_UNARY; goto gotit; } 64 if (!strcmp (argv[i], "--")) { type = ST_UNARY; goto gotit; } 65 if (!strcmp (argv[i], "not")) { type = ST_UNARY; goto gotit; } 66 if (!strcmp (argv[i], "isinf")) { type = ST_UNARY; goto gotit; } 67 if (!strcmp (argv[i], "isnan")) { type = ST_UNARY; goto gotit; } 63 68 64 69 /* binary operations */ 65 if (!strcmp (argv[i], "^")) { type = 8; goto gotit; } 66 67 if (!strcmp (argv[i], "@")) { type = 7; goto gotit; } 68 if (!strcmp (argv[i], "/")) { type = 7; goto gotit; } 69 if (!strcmp (argv[i], "*")) { type = 7; goto gotit; } 70 if (!strcmp (argv[i], "%")) { type = 7; goto gotit; } 71 72 if (!strcmp (argv[i], "+")) { type = 6; goto gotit; } 73 if (!strcmp (argv[i], "-")) { type = 6; goto gotit; } 70 if (!strcmp (argv[i], "^")) { type = ST_POWER; goto gotit; } 71 72 if (!strcmp (argv[i], "max")) { type = ST_BINARY; strcpy (argv[i], "U"); goto gotit; } 73 if (!strcmp (argv[i], "min")) { type = ST_BINARY; strcpy (argv[i], "D"); goto gotit; } 74 if (!strcmp (argv[i], "atan2")) { type = ST_BINARY; goto gotit; } 75 if (!strcmp (argv[i], ",")) { type = ST_COMMA; goto gotit; } 76 77 if (!strcmp (argv[i], "@")) { type = ST_TIMES; goto gotit; } 78 if (!strcmp (argv[i], "/")) { type = ST_TIMES; goto gotit; } 79 if (!strcmp (argv[i], "*")) { type = ST_TIMES; goto gotit; } 80 if (!strcmp (argv[i], "%")) { type = ST_TIMES; goto gotit; } 81 82 if (!strcmp (argv[i], "+")) { type = ST_ADD; goto gotit; } 83 if (!strcmp (argv[i], "-")) { type = ST_ADD; goto gotit; } 74 84 75 if (!strcmp (argv[i], "&")) { type = 5; goto gotit; }76 if (!strcmp (argv[i], "|")) { type = 5; goto gotit; }77 78 if (!strcmp (argv[i], "<")) { type = 4; goto gotit; }79 if (!strcmp (argv[i], ">")) { type = 4; goto gotit; }80 if (!strcmp (argv[i], "==")) { type = 4; strcpy (argv[i], "E"); goto gotit; }81 if (!strcmp (argv[i], "!=")) { type = 4; strcpy (argv[i], "N"); goto gotit; }82 if (!strcmp (argv[i], "<=")) { type = 4; strcpy (argv[i], "L"); goto gotit; }83 if (!strcmp (argv[i], ">=")) { type = 4; strcpy (argv[i], "G"); goto gotit; }84 if (!strcmp (argv[i], ">>")) { type = 4; strcpy (argv[i], "U"); goto gotit; }85 if (!strcmp (argv[i], "<<")) { type = 4; strcpy (argv[i], "D"); goto gotit; }86 87 if (!strcmp (argv[i], "&&")) { type = 3; strcpy (argv[i], "A"); goto gotit; }88 if (!strcmp (argv[i], "||")) { type = 3; strcpy (argv[i], "O"); goto gotit; }89 90 if (!strcmp (argv[i], "(")) { type = 2;goto gotit; }91 if (!strcmp (argv[i], ")")) { type = 1; goto gotit; }85 if (!strcmp (argv[i], "&")) { type = ST_BITWISE; goto gotit; } 86 if (!strcmp (argv[i], "|")) { type = ST_BITWISE; goto gotit; } 87 88 if (!strcmp (argv[i], "<")) { type = ST_LOGIC; goto gotit; } 89 if (!strcmp (argv[i], ">")) { type = ST_LOGIC; goto gotit; } 90 if (!strcmp (argv[i], "==")) { type = ST_LOGIC; strcpy (argv[i], "E"); goto gotit; } 91 if (!strcmp (argv[i], "!=")) { type = ST_LOGIC; strcpy (argv[i], "N"); goto gotit; } 92 if (!strcmp (argv[i], "<=")) { type = ST_LOGIC; strcpy (argv[i], "L"); goto gotit; } 93 if (!strcmp (argv[i], ">=")) { type = ST_LOGIC; strcpy (argv[i], "G"); goto gotit; } 94 if (!strcmp (argv[i], ">>")) { type = ST_LOGIC; strcpy (argv[i], "U"); goto gotit; } 95 if (!strcmp (argv[i], "<<")) { type = ST_LOGIC; strcpy (argv[i], "D"); goto gotit; } 96 97 if (!strcmp (argv[i], "&&")) { type = ST_AND; strcpy (argv[i], "A"); goto gotit; } 98 if (!strcmp (argv[i], "||")) { type = ST_OR ; strcpy (argv[i], "O"); goto gotit; } 99 100 if (!strcmp (argv[i], "(")) { type = ST_LEFT; goto gotit; } 101 if (!strcmp (argv[i], ")")) { type = ST_RIGHT; goto gotit; } 92 102 93 103 gotit: 94 104 /* choose how to deal with object */ 95 105 switch (type) { 96 case 8: /* exponentiation: 2^2^3 = 64 != 256 (precedence is right-to-left, not left-to-right!) */106 case ST_POWER: /* exponentiation: 2^2^3 = 64 != 256 (precedence is right-to-left, not left-to-right!) */ 97 107 /* pop previous, higher operators from OP stack to stack */ 98 108 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type > type); j--) { … … 105 115 Nop_stack ++; 106 116 break; 107 case 9: /* unary OPs */ 108 case 7: /* binary OPs */ 109 case 6: 110 case 5: 111 case 4: 112 case 3: 117 case ST_UNARY: 118 case ST_BINARY: 119 case ST_TRINARY: 120 case ST_TIMES: 121 case ST_ADD: 122 case ST_BITWISE: 123 case ST_LOGIC: 124 case ST_AND: 125 case ST_OR: 113 126 /* pop previous, higher or equal operators from OP stack to stack */ 114 127 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type >= type); j--) { … … 121 134 Nop_stack ++; 122 135 break; 123 case 2:136 case ST_LEFT: 124 137 /* push operator on OP stack */ 125 138 assign_stack (&op_stack[Nop_stack], argv[i], type); … … 127 140 Nop_stack ++; 128 141 break; 129 case 1:142 case ST_RIGHT: 130 143 /* pop rest of operators from OP stack to stack, looking for '(' */ 131 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type != 2); j--) {132 move_stack (&stack[Nstack], &op_stack[j]); 133 Nstack ++; 134 Nop_stack --; 135 } 136 if ((j == -1) || (op_stack[j].type != 2)) {144 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type != ST_LEFT); j--) { 145 move_stack (&stack[Nstack], &op_stack[j]); 146 Nstack ++; 147 Nop_stack --; 148 } 149 if ((j == -1) || (op_stack[j].type != ST_LEFT)) { 137 150 push_error ("syntax error: mismatched parenthesis"); 138 151 Nstack = 0; … … 144 157 Nop_stack --; 145 158 break; 146 case 0: 159 case ST_COMMA: 160 /* pop rest of operators from OP stack to stack, looking for '(' (but do not pop the '(')*/ 161 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type != ST_LEFT) && (op_stack[j].type != ST_TRINARY); j--) { 162 move_stack (&stack[Nstack], &op_stack[j]); 163 Nstack ++; 164 Nop_stack --; 165 } 166 break; 167 case ST_NONE: 147 168 /* place the value (number or vector/matrix name) on stack */ 148 169 /* value of 'X' is used as sentinel until we sort out values */ 149 assign_stack (&stack[Nstack], argv[i], 'X');170 assign_stack (&stack[Nstack], argv[i], ST_VALUE); 150 171 Nstack ++; 151 172 break; 173 174 default: 175 push_error ("invalid stack typ"); 176 Nstack = 0; 177 goto cleanup; 152 178 } 153 179 } 154 180 155 /* dump remaining operators on stack, checking for ' )' */181 /* dump remaining operators on stack, checking for '(' */ 156 182 for (j = Nop_stack - 1; j >= 0; j--) { 157 if (op_stack[j].type == 2) {183 if (op_stack[j].type == ST_LEFT) { 158 184 push_error ("syntax error: mismatched parenthesis"); 159 185 Nstack = 0; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/dvomath.c
r31635 r37067 80 80 sprintf (outname, "%s", stack[0].name); 81 81 } else { 82 if (stack[0].type == 's') {82 if (stack[0].type == ST_SCALAR_INT) { 83 83 sprintf (outname, "%d", stack[0].IntValue); 84 84 } else { -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/evaluate_stack.c
r34088 r37067 2 2 # define VERBOSE 0 3 3 4 # define TWO_OP(A,B,FUNC) \ 5 if (!strncasecmp (&stack[i - 2].type, A, 1) && !strncasecmp (&stack[i - 1].type, B, 1)) \ 6 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); 7 8 # define ONE_OP(A,FUNC) \ 9 if (!strncasecmp (&stack[i - 1].type, A, 1)) \ 10 status = FUNC (&tmp_stack, &stack[i - 1], stack[i].name); 4 // all three operands must have the same type 5 # define THREE_OP(A,FUNC) \ 6 if ((stack[i - 3].type == A) && (stack[i - 2].type == A) && (stack[i - 1].type == A)) { \ 7 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 8 goto got_three_op; } \ 9 if ((stack[i - 3].type == A+1) && (stack[i - 2].type == A) && (stack[i - 1].type == A)) { \ 10 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 11 goto got_three_op; } \ 12 if ((stack[i - 3].type == A) && (stack[i - 2].type == A+1) && (stack[i - 1].type == A)) { \ 13 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 14 goto got_three_op; } \ 15 if ((stack[i - 3].type == A+1) && (stack[i - 2].type == A+1) && (stack[i - 1].type == A)) { \ 16 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 17 goto got_three_op; } \ 18 if ((stack[i - 3].type == A) && (stack[i - 2].type == A) && (stack[i - 1].type == A+1)) { \ 19 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 20 goto got_three_op; } \ 21 if ((stack[i - 3].type == A+1) && (stack[i - 2].type == A) && (stack[i - 1].type == A+1)) { \ 22 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 23 goto got_three_op; } \ 24 if ((stack[i - 3].type == A) && (stack[i - 2].type == A+1) && (stack[i - 1].type == A+1)) { \ 25 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 26 goto got_three_op; } \ 27 if ((stack[i - 3].type == A+1) && (stack[i - 2].type == A+1) && (stack[i - 1].type == A+1)) { \ 28 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 29 goto got_three_op; } \ 30 31 // A & B value types all have 2 possible values 32 # define TWO_OP(A,B,FUNC) { \ 33 if ((stack[i - 2].type == A) && (stack[i - 1].type == B)) { \ 34 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); \ 35 goto got_two_op; } \ 36 if ((stack[i - 2].type == A+1) && (stack[i - 1].type == B)) { \ 37 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); \ 38 goto got_two_op; } \ 39 if ((stack[i - 2].type == A) && (stack[i - 1].type == B+1)) { \ 40 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); \ 41 goto got_two_op; } \ 42 if ((stack[i - 2].type == A+1) && (stack[i - 1].type == B+1)) { \ 43 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); \ 44 goto got_two_op; } \ 45 } 46 47 # define ONE_OP(A,FUNC) \ 48 if (stack[i - 1].type == A) { \ 49 status = FUNC (&tmp_stack, &stack[i - 1], stack[i].name); \ 50 goto got_one_op; } 11 51 12 52 int evaluate_stack (StackVar *stack, int *Nstack) { … … 20 60 21 61 if (*Nstack == 1) { 22 if ((stack[0].type == 'S') || (stack[0].type == 's')) {62 if ((stack[0].type == ST_SCALAR_INT) || (stack[0].type == ST_SCALAR_FLT)) { 23 63 clear_stack (&tmp_stack); 24 64 return (TRUE); 25 65 } 26 if (stack[0].type == 'V') {66 if (stack[0].type == ST_VECTOR) { 27 67 /* need to make a copy so we set output value? */ 28 68 V_unary (&tmp_stack, &stack[0], "="); … … 30 70 return (TRUE); 31 71 } 32 if (stack[0].type == 'M') {72 if (stack[0].type == ST_MATRIX) { 33 73 /* need to make a copy so we set output value? */ 34 74 M_unary (&tmp_stack, &stack[0], "="); … … 56 96 } 57 97 58 /***** binary operators *****/ 59 if ((stack[i].type >= 3) && (stack[i].type <= 8)) { 60 61 if (i < 2) { /* need two variables to operate on */ 62 sprintf (line, "syntax error: binary operator with one operand: %s\n", stack[i].name); 98 /***** trinary operators *****/ 99 switch (stack[i].type) { 100 case ST_TRINARY: 101 102 if (i < 3) { /* need two variables to operate on */ 103 snprintf (line, 512, "syntax error: trinary operator without three operands: %s\n", stack[i].name); 104 push_error (line); 105 clear_stack (&tmp_stack); 106 return (FALSE); 107 } 108 109 status = FALSE; 110 THREE_OP (ST_MATRIX,MMM_trinary); 111 THREE_OP (ST_VECTOR,VVV_trinary); 112 113 THREE_OP (ST_SCALAR_FLT,SSS_trinary); 114 THREE_OP (ST_SCALAR_INT,SSS_trinary); 115 116 /* there are no valid unary string operators */ 117 push_error ("invalid operands for trinary operator (mismatch types?)"); 118 clear_stack (&tmp_stack); 119 return (FALSE); 120 121 got_three_op: 122 if (!status) { 123 snprintf (line, 512, "syntax error: invalid operand for binary operation: %s or %s or %s\n", stack[i-1].name, stack[i-2].name, stack[i-3].name); 124 push_error (line); 125 clear_stack (&tmp_stack); 126 return (FALSE); 127 } 128 move_stack (&stack[i-3], &tmp_stack); 129 delete_stack (&stack[i-2], 3); 130 for (j = i + 1; j < *Nstack; j++) { 131 move_stack (&stack[j-3], &stack[j]); 132 } 133 *Nstack -= 3; 134 i -= 3; 135 init_stack (&tmp_stack); 136 continue; 137 138 /***** binary operators *****/ 139 case ST_OR: 140 case ST_AND: 141 case ST_LOGIC: 142 case ST_BITWISE: 143 case ST_ADD: 144 case ST_TIMES: 145 case ST_POWER: 146 case ST_BINARY: 147 148 if (i < 2) { /* need two variables to operate on */ 149 snprintf (line, 512, "syntax error: binary operator with one operand: %s\n", stack[i].name); 150 push_error (line); 151 clear_stack (&tmp_stack); 152 return (FALSE); 153 } 154 155 status = FALSE; 156 TWO_OP (ST_MATRIX,ST_MATRIX,MM_binary); 157 TWO_OP (ST_MATRIX,ST_VECTOR,MV_binary); 158 TWO_OP (ST_MATRIX,ST_SCALAR_INT,MS_binary); 159 160 TWO_OP (ST_VECTOR,ST_MATRIX,VM_binary); 161 TWO_OP (ST_VECTOR,ST_VECTOR,VV_binary); 162 TWO_OP (ST_VECTOR,ST_SCALAR_INT,VS_binary); 163 164 TWO_OP (ST_SCALAR_INT,ST_MATRIX,SM_binary); 165 TWO_OP (ST_SCALAR_INT,ST_VECTOR,SV_binary); 166 TWO_OP (ST_SCALAR_INT,ST_SCALAR_INT,SS_binary); 167 168 TWO_OP (ST_SCALAR_FLT,ST_MATRIX,SM_binary); 169 TWO_OP (ST_SCALAR_FLT,ST_VECTOR,SV_binary); 170 TWO_OP (ST_SCALAR_FLT,ST_SCALAR_INT,SS_binary); 171 172 TWO_OP (ST_STRING,ST_STRING,WW_binary); 173 TWO_OP (ST_STRING,ST_SCALAR_INT,WW_binary); 174 TWO_OP (ST_SCALAR_INT,ST_STRING,WW_binary); 175 176 got_two_op: 177 if (!status) { 178 snprintf (line, 512, "syntax error: invalid operand for binary operation: %s or %s\n", stack[i-1].name, stack[i-2].name); 179 push_error (line); 180 clear_stack (&tmp_stack); 181 return (FALSE); 182 } 183 move_stack (&stack[i-2], &tmp_stack); 184 delete_stack (&stack[i-1], 2); 185 for (j = i + 1; j < *Nstack; j++) { 186 move_stack (&stack[j - 2], &stack[j]); 187 } 188 *Nstack -= 2; 189 i -= 2; 190 init_stack (&tmp_stack); 191 continue; 192 193 /***** unary operators **/ 194 case ST_UNARY: 195 196 if (i < 1) { /* need one variable to operate on */ 197 push_error ("syntax error: unary operator with no operand"); 198 clear_stack (&tmp_stack); 199 return (FALSE); 200 } 201 202 ONE_OP (ST_MATRIX, M_unary); 203 ONE_OP (ST_MATRIX_TMP, M_unary); 204 205 ONE_OP (ST_VECTOR, V_unary); 206 ONE_OP (ST_VECTOR_TMP, V_unary); 207 208 ONE_OP (ST_SCALAR_INT, S_unary); 209 ONE_OP (ST_SCALAR_FLT, S_unary); 210 211 /* there are no valid unary string operators */ 212 push_error ("syntax error: no valid string unary ops"); 213 clear_stack (&tmp_stack); 214 return (FALSE); 215 216 got_one_op: 217 move_stack (&stack[i-1], &tmp_stack); 218 delete_stack (&stack[i], 1); 219 for (j = i + 1; j < *Nstack; j++) { 220 move_stack (&stack[j - 1], &stack[j]); 221 } 222 init_stack (&tmp_stack); 223 *Nstack -= 1; 224 i -= 1; 225 continue; 226 227 case ST_SCALAR_INT: 228 case ST_SCALAR_FLT: 229 case ST_VECTOR: 230 case ST_VECTOR_TMP: 231 case ST_MATRIX: 232 case ST_MATRIX_TMP: 233 case ST_STRING: 234 continue; 235 236 default: 237 snprintf (line, 512, "syntax error: unexpected operator type %s", stack[i].name); 63 238 push_error (line); 64 239 clear_stack (&tmp_stack); 65 240 return (FALSE); 66 } 67 68 status = FALSE; 69 TWO_OP ("M","M",MM_binary); 70 TWO_OP ("M","V",MV_binary); 71 TWO_OP ("M","S",MS_binary); 72 TWO_OP ("V","M",VM_binary); 73 TWO_OP ("V","V",VV_binary); 74 TWO_OP ("V","S",VS_binary); 75 TWO_OP ("S","M",SM_binary); 76 TWO_OP ("S","V",SV_binary); 77 TWO_OP ("S","S",SS_binary); 78 TWO_OP ("W","W",WW_binary); 79 TWO_OP ("W","S",WW_binary); 80 TWO_OP ("S","W",WW_binary); 81 82 if (!status) { 83 sprintf (line, "syntax error: invalid operand for binary operation: %s or %s\n", stack[i-1].name, stack[i-2].name); 84 push_error (line); 85 clear_stack (&tmp_stack); 86 return (FALSE); 87 } 88 move_stack (&stack[i-2], &tmp_stack); 89 delete_stack (&stack[i-1], 2); 90 for (j = i + 1; j < *Nstack; j++) { 91 move_stack (&stack[j - 2], &stack[j]); 92 } 93 *Nstack -= 2; 94 i -= 2; 95 init_stack (&tmp_stack); 96 continue; 97 } 98 99 /***** unary operators **/ 100 if (stack[i].type == 9) { 101 102 if (i < 1) { /* need one variable to operate on */ 103 push_error ("syntax error: unary operator with no operand"); 104 clear_stack (&tmp_stack); 105 return (FALSE); 106 } 107 108 ONE_OP ("M", M_unary); 109 ONE_OP ("V", V_unary); 110 ONE_OP ("S", S_unary); 111 112 /* there are no valid unary string operators */ 113 if (!strncasecmp (&stack[i - 1].type, "W", 1)) { 114 push_error ("syntax error: no valid string unary ops"); 115 clear_stack (&tmp_stack); 116 return (FALSE); 117 } 118 119 move_stack (&stack[i-1], &tmp_stack); 120 delete_stack (&stack[i], 1); 121 for (j = i + 1; j < *Nstack; j++) { 122 move_stack (&stack[j - 1], &stack[j]); 123 } 124 init_stack (&tmp_stack); 125 *Nstack -= 1; 126 i -= 1; 127 continue; 128 } 241 } 129 242 } 130 243 clear_stack (&tmp_stack); … … 160 273 161 274 for (i = 0; i < Nstack; i++) { 162 if (IsBufferPtr (stack[i].buffer) && (stack[i].type == 'm')) {275 if (IsBufferPtr (stack[i].buffer) && (stack[i].type == ST_MATRIX_TMP)) { 163 276 if (VERBOSE) gprint (GP_ERR, "free %s (buff) (%lx)\n", stack[i].name, (long) stack[i].buffer); 164 277 free (stack[i].buffer[0].header.buffer); … … 167 280 stack[i].buffer = NULL; 168 281 } 169 if (IsVectorPtr (stack[i].vector) && (stack[i].type == 'v')) {282 if (IsVectorPtr (stack[i].vector) && (stack[i].type == ST_VECTOR_TMP)) { 170 283 if (VERBOSE) gprint (GP_ERR, "free %s (vect) (%lx)\n", stack[i].name, (long) stack[i].vector); 171 284 free (stack[i].vector[0].elements.Ptr); … … 193 306 } 194 307 195 void assign_stack (StackVar *stack, char *name, inttype) {308 void assign_stack (StackVar *stack, char *name, StackVarType type) { 196 309 stack->name = strcreate (name); 197 310 stack->type = type; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/macro_list.c
r7917 r37067 11 11 } 12 12 13 macro = MatchMacro (argv[ 0], FALSE, TRUE);13 macro = MatchMacro (argv[1], FALSE, TRUE); 14 14 if (macro == NULL) { 15 15 gprint (GP_ERR, "%s: Macro not found\n", argv[1]); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/stack_math.c
r34342 r37067 6 6 */ 7 7 8 // XXX we temporarily drop the concept of using one of the temporary input vectors for 9 // the output vector (thus saving an ALLOC): we have to juggle the size of the input vectors 10 // as well as their temporary state 11 12 int VV_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 8 int SSS_trinary (StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op) { 9 10 char line[512]; // this is only used to report an error 11 12 // set up the possible operations : int OP int -> int, all else yield float 13 // OP is the operation performed on *M1 and *M2 14 # define SSS_FUNC(OP) { \ 15 if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_FLT) && (V3->type == ST_SCALAR_FLT)) { \ 16 opihi_flt M1 = V1[0].FltValue; \ 17 opihi_flt M2 = V2[0].FltValue; \ 18 opihi_flt M3 = V3[0].FltValue; \ 19 OUT[0].type = ST_SCALAR_FLT; \ 20 OUT[0].FltValue = OP; \ 21 break; \ 22 } \ 23 if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT) && (V3->type == ST_SCALAR_INT)) { \ 24 opihi_int M1 = V1[0].IntValue; \ 25 opihi_int M2 = V2[0].IntValue; \ 26 opihi_int M3 = V3[0].IntValue; \ 27 OUT[0].type = ST_SCALAR_INT; \ 28 OUT[0].IntValue = OP; \ 29 break; \ 30 } \ 31 } 32 33 switch (op[0]) { 34 case '?': SSS_FUNC(M1 ? M2: M3); 35 default: 36 snprintf (line, 512, "error: op %c not defined!", op[0]); 37 push_error (line); 38 return (FALSE); 39 } 40 # undef SSS_FUNC 41 42 clear_stack (V1); 43 clear_stack (V2); 44 clear_stack (V3); 45 return (TRUE); 46 47 } 48 49 int VVV_trinary (StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op) { 13 50 14 51 int i, Nx; … … 19 56 return (FALSE); 20 57 } 58 if (V1[0].vector[0].Nelements != V3[0].vector[0].Nelements) { 59 return (FALSE); 60 } 21 61 22 62 Nx = V1[0].vector[0].Nelements; … … 24 64 // create the output vector guaranteed to be temporary until the very end 25 65 OUT[0].vector = InitVector (); 26 OUT[0].type = 'v'; 66 OUT[0].type = ST_VECTOR_TMP; 67 68 // set up the possible operations : int OP int -> int, all else yield float 69 // OP is the operation performed on *M1 and *M2 70 # define VVV_FUNC(OP) { \ 71 if ((V1->vector->type == OPIHI_FLT) && (V2->vector->type == OPIHI_FLT) && (V3->vector->type == OPIHI_FLT)) { \ 72 CopyVector (OUT[0].vector, V1[0].vector); \ 73 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ 74 opihi_flt *M2 = V2[0].vector[0].elements.Flt; \ 75 opihi_flt *M3 = V3[0].vector[0].elements.Flt; \ 76 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 77 for (i = 0; i < Nx; i++, out++, M1++, M2++, M3++) { \ 78 *out = OP; \ 79 } \ 80 break; \ 81 } \ 82 if ((V1->vector->type == OPIHI_INT) && (V2->vector->type == OPIHI_INT) && (V3->vector->type == OPIHI_INT)) { \ 83 CopyVector (OUT[0].vector, V1[0].vector); \ 84 opihi_int *M1 = V1[0].vector[0].elements.Int; \ 85 opihi_int *M2 = V2[0].vector[0].elements.Int; \ 86 opihi_int *M3 = V3[0].vector[0].elements.Int; \ 87 opihi_int *out = OUT[0].vector[0].elements.Int; \ 88 for (i = 0; i < Nx; i++, out++, M1++, M2++, M3++) { \ 89 *out = OP; \ 90 } \ 91 break; \ 92 } \ 93 } 94 95 switch (op[0]) { 96 case '?': VVV_FUNC(*M1 ? *M2: *M3); 97 default: 98 snprintf (line, 512, "error: op %c not defined!", op[0]); 99 push_error (line); 100 return (FALSE); 101 } 102 # undef VVV_FUNC 103 104 /** free up any temporary buffers: **/ 105 106 if (V1[0].type == ST_VECTOR_TMP) { 107 free (V1[0].vector[0].elements.Ptr); 108 free (V1[0].vector); 109 } 110 if (V2[0].type == ST_VECTOR_TMP) { 111 free (V2[0].vector[0].elements.Ptr); 112 free (V2[0].vector); 113 } 114 if (V3[0].type == ST_VECTOR_TMP) { 115 free (V3[0].vector[0].elements.Ptr); 116 free (V3[0].vector); 117 } 118 /* at the end, V1 and V2 are deleted only if they were temporary */ 119 120 clear_stack (V1); 121 clear_stack (V2); 122 clear_stack (V3); 123 return (TRUE); 124 125 } 126 127 int MMM_trinary (StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op) { 128 129 int i, Nx, Ny; 130 float *out, *M1, *M2, *M3; 131 char line[512]; // this is only used to report an error 132 133 Nx = V1[0].buffer[0].matrix.Naxis[0]; 134 Ny = V1[0].buffer[0].matrix.Naxis[1]; 135 136 if (V1[0].type == ST_MATRIX_TMP) { /** use V1 as temp buffer **/ 137 OUT[0].buffer = V1[0].buffer; 138 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 139 } else { 140 if (V2[0].type == ST_MATRIX_TMP) { /** use V2 as temp buffer, but header of V1 **/ 141 OUT[0].buffer = V2[0].buffer; 142 V2[0].type = ST_MATRIX; /* prevent it from being freed below */ 143 } else { /* no spare temp buffer */ 144 OUT[0].buffer = InitBuffer (); 145 CopyBuffer (OUT[0].buffer, V1[0].buffer); 146 } 147 } 148 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 149 150 M1 = (float *)V1[0].buffer[0].matrix.buffer; 151 M2 = (float *)V2[0].buffer[0].matrix.buffer; 152 M3 = (float *)V3[0].buffer[0].matrix.buffer; 153 out = (float *)OUT[0].buffer[0].matrix.buffer; 154 155 # define MMM_FUNC(OP) \ 156 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++, M3++) { \ 157 *out = OP; \ 158 } \ 159 break; 160 161 switch (op[0]) { 162 case '?': MMM_FUNC(*M1 ? *M2: *M3); 163 default: 164 snprintf (line, 512, "error: op %c not defined!", op[0]); 165 push_error (line); 166 return (FALSE); 167 } 168 # undef MMM_FUNC 169 170 /** free up any temporary buffers: **/ 171 172 if (V1[0].type == ST_MATRIX_TMP) { 173 free (V1[0].buffer[0].header.buffer); 174 free (V1[0].buffer[0].matrix.buffer); 175 free (V1[0].buffer); 176 } 177 if (V2[0].type == ST_MATRIX_TMP) { 178 free (V2[0].buffer[0].header.buffer); 179 free (V2[0].buffer[0].matrix.buffer); 180 free (V2[0].buffer); 181 } 182 if (V3[0].type == ST_MATRIX_TMP) { 183 free (V3[0].buffer[0].header.buffer); 184 free (V3[0].buffer[0].matrix.buffer); 185 free (V3[0].buffer); 186 } 187 188 /* at the end, V1 and V2 are deleted only if they were temporary */ 189 190 clear_stack (V1); 191 clear_stack (V2); 192 clear_stack (V3); 193 return (TRUE); 194 195 } 196 197 // XXX we temporarily drop the concept of using one of the temporary input vectors for 198 // the output vector (thus saving an ALLOC): we have to juggle the size of the input vectors 199 // as well as their temporary state 200 201 int VV_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 202 203 int i, Nx; 204 char line[512]; // this is only used to report an error 205 206 // the vectors have to match in length 207 if (V1[0].vector[0].Nelements != V2[0].vector[0].Nelements) { 208 return (FALSE); 209 } 210 211 Nx = V1[0].vector[0].Nelements; 212 213 // create the output vector guaranteed to be temporary until the very end 214 OUT[0].vector = InitVector (); 215 OUT[0].type = ST_VECTOR_TMP; 27 216 28 217 // set up the possible operations : int OP int -> int, all else yield float … … 59 248 break; \ 60 249 } \ 61 if ((FTYPE == 'S') && (V1->vector->type != OPIHI_FLT) && (V2->vector->type != OPIHI_FLT)) { \250 if ((FTYPE == ST_SCALAR_FLT) && (V1->vector->type != OPIHI_FLT) && (V2->vector->type != OPIHI_FLT)) { \ 62 251 MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT); \ 63 252 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 82 271 83 272 switch (op[0]) { 84 case '+': VV_FUNC('s', *M1 + *M2); 85 case '-': VV_FUNC('s', *M1 - *M2); 86 case '*': VV_FUNC('s', *M1 * *M2); 87 case '/': VV_FUNC('S', *M1 / (opihi_flt) *M2); 88 case '%': VV_FUNC('s', (long long)*M1 % (long long)*M2); 89 case '^': VV_FUNC('S', pow (*M1, *M2)); 90 case '@': VV_FUNC('S', DEG_RAD*atan2 (*M1, *M2)); 91 case 'D': VV_FUNC('s', MIN (*M1, *M2)); 92 case 'U': VV_FUNC('s', MAX (*M1, *M2)); 93 case '<': VV_FUNC('s', (*M1 < *M2) ? 1 : 0); 94 case '>': VV_FUNC('s', (*M1 > *M2) ? 1 : 0); 95 case '&': VV_FUNC('s', ((long long)*M1 & (long long)*M2)); 96 case '|': VV_FUNC('s', ((long long)*M1 | (long long)*M2)); 97 case 'E': VV_FUNC('s', (*M1 == *M2) ? 1 : 0); 98 case 'N': VV_FUNC('s', (*M1 != *M2) ? 1 : 0); 99 case 'L': VV_FUNC('s', (*M1 <= *M2) ? 1 : 0); 100 case 'G': VV_FUNC('s', (*M1 >= *M2) ? 1 : 0); 101 case 'A': VV_FUNC('s', (*M1 && *M2) ? 1 : 0); 102 case 'O': VV_FUNC('s', (*M1 || *M2) ? 1 : 0); 273 case '+': VV_FUNC(ST_SCALAR_INT, *M1 + *M2); 274 case '-': VV_FUNC(ST_SCALAR_INT, *M1 - *M2); 275 case '*': VV_FUNC(ST_SCALAR_INT, *M1 * *M2); 276 case '/': VV_FUNC(ST_SCALAR_FLT, *M1 / (opihi_flt) *M2); 277 case '%': VV_FUNC(ST_SCALAR_INT, (long long)*M1 % (long long)*M2); 278 case '^': VV_FUNC(ST_SCALAR_FLT, pow (*M1, *M2)); 279 case '@': VV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, *M2)); 280 case 'a': VV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, *M2)); 281 case 'D': VV_FUNC(ST_SCALAR_INT, MIN (*M1, *M2)); 282 case 'U': VV_FUNC(ST_SCALAR_INT, MAX (*M1, *M2)); 283 case '<': VV_FUNC(ST_SCALAR_INT, (*M1 < *M2) ? 1 : 0); 284 case '>': VV_FUNC(ST_SCALAR_INT, (*M1 > *M2) ? 1 : 0); 285 case '&': VV_FUNC(ST_SCALAR_INT, ((long long)*M1 & (long long)*M2)); 286 case '|': VV_FUNC(ST_SCALAR_INT, ((long long)*M1 | (long long)*M2)); 287 case 'E': VV_FUNC(ST_SCALAR_INT, (*M1 == *M2) ? 1 : 0); 288 case 'N': VV_FUNC(ST_SCALAR_INT, (*M1 != *M2) ? 1 : 0); 289 case 'L': VV_FUNC(ST_SCALAR_INT, (*M1 <= *M2) ? 1 : 0); 290 case 'G': VV_FUNC(ST_SCALAR_INT, (*M1 >= *M2) ? 1 : 0); 291 case 'A': VV_FUNC(ST_SCALAR_INT, (*M1 && *M2) ? 1 : 0); 292 case 'O': VV_FUNC(ST_SCALAR_INT, (*M1 || *M2) ? 1 : 0); 103 293 default: 104 s printf (line, "error: op %c not defined!", op[0]);294 snprintf (line, 512, "error: op %c not defined!", op[0]); 105 295 push_error (line); 106 296 return (FALSE); … … 110 300 /** free up any temporary buffers: **/ 111 301 112 if (V1[0].type == 'v') {302 if (V1[0].type == ST_VECTOR_TMP) { 113 303 free (V1[0].vector[0].elements.Ptr); 114 304 free (V1[0].vector); 115 305 } 116 if (V2[0].type == 'v') {306 if (V2[0].type == ST_VECTOR_TMP) { 117 307 free (V2[0].vector[0].elements.Ptr); 118 308 free (V2[0].vector); … … 134 324 135 325 OUT[0].vector = InitVector (); 136 OUT[0].type = 'v'; /*** <<--- says this is a temporary matrix ***/326 OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/ 137 327 138 328 // set up the possible operations : int OP int -> int, all else yield float 139 329 // OP is the operation performed on *M1 and *M2 140 330 # define SV_FUNC(FTYPE,OP) { \ 141 if ((V1->type == 'S') && (V2->vector->type == OPIHI_FLT)) { \331 if ((V1->type == ST_SCALAR_FLT) && (V2->vector->type == OPIHI_FLT)) { \ 142 332 CopyVector (OUT[0].vector, V2[0].vector); \ 143 333 opihi_flt M1 = V1[0].FltValue; \ … … 149 339 break; \ 150 340 } \ 151 if ((V1->type == 'S') && (V2->vector->type != OPIHI_FLT)) { \341 if ((V1->type == ST_SCALAR_FLT) && (V2->vector->type != OPIHI_FLT)) { \ 152 342 MatchVector (OUT[0].vector, V2[0].vector, OPIHI_FLT); \ 153 343 opihi_flt M1 = V1[0].FltValue; \ … … 159 349 break; \ 160 350 } \ 161 if ((V1->type == 's') && (V2->vector->type == OPIHI_FLT)) { \351 if ((V1->type == ST_SCALAR_INT) && (V2->vector->type == OPIHI_FLT)) { \ 162 352 CopyVector (OUT[0].vector, V2[0].vector); \ 163 353 opihi_int M1 = V1[0].IntValue; \ … … 169 359 break; \ 170 360 } \ 171 if ((FTYPE == 'S') && (V1->type == 's') && (V2->vector->type != OPIHI_FLT)) { \361 if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT) && (V2->vector->type != OPIHI_FLT)) { \ 172 362 MatchVector (OUT[0].vector, V2[0].vector, OPIHI_FLT); \ 173 363 opihi_int M1 = V1[0].IntValue; \ … … 179 369 break; \ 180 370 } \ 181 if ((V1->type == 's') && (V2->vector->type != OPIHI_FLT)) { \371 if ((V1->type == ST_SCALAR_INT) && (V2->vector->type != OPIHI_FLT)) { \ 182 372 CopyVector (OUT[0].vector, V2[0].vector); \ 183 373 opihi_int M1 = V1[0].IntValue; \ … … 192 382 193 383 switch (op[0]) { 194 case '+': SV_FUNC('s', M1 + *M2); 195 case '-': SV_FUNC('s', M1 - *M2); 196 case '*': SV_FUNC('s', M1 * *M2); 197 case '/': SV_FUNC('S', M1 / (opihi_flt) *M2); 198 case '%': SV_FUNC('s', (long long) M1 % (long long) *M2); 199 case '^': SV_FUNC('S', pow (M1, *M2)); 200 case '@': SV_FUNC('S', DEG_RAD*atan2 (M1, *M2)); 201 case 'D': SV_FUNC('s', MIN (M1, *M2)); 202 case 'U': SV_FUNC('s', MAX (M1, *M2)); 203 case '<': SV_FUNC('s', (M1 < *M2) ? 1 : 0); 204 case '>': SV_FUNC('s', (M1 > *M2) ? 1 : 0); 205 case '&': SV_FUNC('s', ((long long)M1 & (long long)*M2)); 206 case '|': SV_FUNC('s', ((long long)M1 | (long long)*M2)); 207 case 'E': SV_FUNC('s', (M1 == *M2) ? 1 : 0); 208 case 'N': SV_FUNC('s', (M1 != *M2) ? 1 : 0); 209 case 'L': SV_FUNC('s', (M1 <= *M2) ? 1 : 0); 210 case 'G': SV_FUNC('s', (M1 >= *M2) ? 1 : 0); 211 case 'A': SV_FUNC('s', (M1 && *M2) ? 1 : 0); 212 case 'O': SV_FUNC('s', (M1 || *M2) ? 1 : 0); 384 case '+': SV_FUNC(ST_SCALAR_INT, M1 + *M2); 385 case '-': SV_FUNC(ST_SCALAR_INT, M1 - *M2); 386 case '*': SV_FUNC(ST_SCALAR_INT, M1 * *M2); 387 case '/': SV_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) *M2); 388 case '%': SV_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) *M2); 389 case '^': SV_FUNC(ST_SCALAR_FLT, pow (M1, *M2)); 390 case '@': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2)); 391 case 'a': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2)); 392 case 'D': SV_FUNC(ST_SCALAR_INT, MIN (M1, *M2)); 393 case 'U': SV_FUNC(ST_SCALAR_INT, MAX (M1, *M2)); 394 case '<': SV_FUNC(ST_SCALAR_INT, (M1 < *M2) ? 1 : 0); 395 case '>': SV_FUNC(ST_SCALAR_INT, (M1 > *M2) ? 1 : 0); 396 case '&': SV_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)*M2)); 397 case '|': SV_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)*M2)); 398 case 'E': SV_FUNC(ST_SCALAR_INT, (M1 == *M2) ? 1 : 0); 399 case 'N': SV_FUNC(ST_SCALAR_INT, (M1 != *M2) ? 1 : 0); 400 case 'L': SV_FUNC(ST_SCALAR_INT, (M1 <= *M2) ? 1 : 0); 401 case 'G': SV_FUNC(ST_SCALAR_INT, (M1 >= *M2) ? 1 : 0); 402 case 'A': SV_FUNC(ST_SCALAR_INT, (M1 && *M2) ? 1 : 0); 403 case 'O': SV_FUNC(ST_SCALAR_INT, (M1 || *M2) ? 1 : 0); 213 404 default: 214 s printf (line, "error: op %c not defined!", op[0]);405 snprintf (line, 512, "error: op %c not defined!", op[0]); 215 406 push_error (line); 216 407 return (FALSE); … … 219 410 220 411 /** free up any temporary buffers: **/ 221 if (V2[0].type == 'v') {412 if (V2[0].type == ST_VECTOR_TMP) { 222 413 free (V2[0].vector[0].elements.Ptr); 223 414 free (V2[0].vector); … … 240 431 241 432 OUT[0].vector = InitVector (); 242 OUT[0].type = 'v'; /*** <<--- says this is a temporary matrix ***/433 OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/ 243 434 244 435 // set up the possible operations : int OP int -> int, all else yield float 245 436 // OP is the operation performed on *M1 and *M2 246 437 # define VS_FUNC(FTYPE,OP) { \ 247 if ((V2->type == 'S') && (V1->vector->type == OPIHI_FLT)) { \438 if ((V2->type == ST_SCALAR_FLT) && (V1->vector->type == OPIHI_FLT)) { \ 248 439 CopyVector (OUT[0].vector, V1[0].vector); \ 249 440 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ … … 255 446 break; \ 256 447 } \ 257 if ((V2->type == 'S') && (V1->vector->type != OPIHI_FLT)) { \448 if ((V2->type == ST_SCALAR_FLT) && (V1->vector->type != OPIHI_FLT)) { \ 258 449 MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT); \ 259 450 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 265 456 break; \ 266 457 } \ 267 if ((V2->type == 's') && (V1->vector->type == OPIHI_FLT)) { \458 if ((V2->type == ST_SCALAR_INT) && (V1->vector->type == OPIHI_FLT)) { \ 268 459 CopyVector (OUT[0].vector, V1[0].vector); \ 269 460 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ … … 275 466 break; \ 276 467 } \ 277 if ((FTYPE == 'S') && (V2->type == 's') && (V1->vector->type != OPIHI_FLT)) { \468 if ((FTYPE == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_INT) && (V1->vector->type != OPIHI_FLT)) { \ 278 469 CopyVector (OUT[0].vector, V1[0].vector); \ 279 470 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 285 476 break; \ 286 477 } \ 287 if ((V2->type == 's') && (V1->vector->type != OPIHI_FLT)) { \478 if ((V2->type == ST_SCALAR_INT) && (V1->vector->type != OPIHI_FLT)) { \ 288 479 CopyVector (OUT[0].vector, V1[0].vector); \ 289 480 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 298 489 299 490 switch (op[0]) { 300 case '+': VS_FUNC('s', *M1 + M2); 301 case '-': VS_FUNC('s', *M1 - M2); 302 case '*': VS_FUNC('s', *M1 * M2); 303 case '/': VS_FUNC('S', *M1 / (opihi_flt) M2); 304 case '%': VS_FUNC('s', (long long) *M1 % (long long) M2); 305 case '^': VS_FUNC('S', pow (*M1, M2)); 306 case '@': VS_FUNC('S', DEG_RAD*atan2 (*M1, M2)); 307 case 'D': VS_FUNC('s', MIN (*M1, M2)); 308 case 'U': VS_FUNC('s', MAX (*M1, M2)); 309 case '<': VS_FUNC('s', (*M1 < M2) ? 1 : 0); 310 case '>': VS_FUNC('s', (*M1 > M2) ? 1 : 0); 311 case '&': VS_FUNC('s', ((long long)*M1 & (long long)M2)); 312 case '|': VS_FUNC('s', ((long long)*M1 | (long long)M2)); 313 case 'E': VS_FUNC('s', (*M1 == M2) ? 1 : 0); 314 case 'N': VS_FUNC('s', (*M1 != M2) ? 1 : 0); 315 case 'L': VS_FUNC('s', (*M1 <= M2) ? 1 : 0); 316 case 'G': VS_FUNC('s', (*M1 >= M2) ? 1 : 0); 317 case 'A': VS_FUNC('s', (*M1 && M2) ? 1 : 0); 318 case 'O': VS_FUNC('s', (*M1 || M2) ? 1 : 0); 491 case '+': VS_FUNC(ST_SCALAR_INT, *M1 + M2); 492 case '-': VS_FUNC(ST_SCALAR_INT, *M1 - M2); 493 case '*': VS_FUNC(ST_SCALAR_INT, *M1 * M2); 494 case '/': VS_FUNC(ST_SCALAR_FLT, *M1 / (opihi_flt) M2); 495 case '%': VS_FUNC(ST_SCALAR_INT, (long long) *M1 % (long long) M2); 496 case '^': VS_FUNC(ST_SCALAR_FLT, pow (*M1, M2)); 497 case '@': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2)); 498 case 'a': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2)); 499 case 'D': VS_FUNC(ST_SCALAR_INT, MIN (*M1, M2)); 500 case 'U': VS_FUNC(ST_SCALAR_INT, MAX (*M1, M2)); 501 case '<': VS_FUNC(ST_SCALAR_INT, (*M1 < M2) ? 1 : 0); 502 case '>': VS_FUNC(ST_SCALAR_INT, (*M1 > M2) ? 1 : 0); 503 case '&': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 & (long long)M2)); 504 case '|': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 | (long long)M2)); 505 case 'E': VS_FUNC(ST_SCALAR_INT, (*M1 == M2) ? 1 : 0); 506 case 'N': VS_FUNC(ST_SCALAR_INT, (*M1 != M2) ? 1 : 0); 507 case 'L': VS_FUNC(ST_SCALAR_INT, (*M1 <= M2) ? 1 : 0); 508 case 'G': VS_FUNC(ST_SCALAR_INT, (*M1 >= M2) ? 1 : 0); 509 case 'A': VS_FUNC(ST_SCALAR_INT, (*M1 && M2) ? 1 : 0); 510 case 'O': VS_FUNC(ST_SCALAR_INT, (*M1 || M2) ? 1 : 0); 319 511 default: 320 s printf (line, "error: op %c not defined!", op[0]);512 snprintf (line, 512, "error: op %c not defined!", op[0]); 321 513 push_error (line); 322 514 return (FALSE); … … 326 518 /** free up any temporary buffers: **/ 327 519 328 if (V1[0].type == 'v') {520 if (V1[0].type == ST_VECTOR_TMP) { 329 521 free (V1[0].vector[0].elements.Ptr); 330 522 free (V1[0].vector); … … 353 545 354 546 /* if possible, use V1 as temp buffer, otherwise create new one */ 355 if (V1[0].type == 'm') {547 if (V1[0].type == ST_MATRIX_TMP) { 356 548 OUT[0].buffer = V1[0].buffer; 357 V1[0].type = 'M'; /* prevent it from being freed below */549 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 358 550 } else { 359 551 /* do buffer.matrix.buffer and buffer.header.buffer get correctly zeroed? */ … … 361 553 CopyBuffer (OUT[0].buffer, V1[0].buffer); 362 554 } 363 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/555 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 364 556 365 557 float *M1 = (float *) V1[0].buffer[0].matrix.buffer; … … 395 587 case '^': MV_FUNC(pow (*M1, *M2)); 396 588 case '@': MV_FUNC(DEG_RAD*atan2 (*M1, *M2)); 589 case 'a': MV_FUNC(DEG_RAD*atan2 (*M1, *M2)); 397 590 case 'D': MV_FUNC(MIN (*M1, *M2)); 398 591 case 'U': MV_FUNC(MAX (*M1, *M2)); … … 408 601 case 'O': MV_FUNC((*M1 || *M2) ? 1 : 0); 409 602 default: 410 s printf (line, "error: op %c not defined!", op[0]);603 snprintf (line, 512, "error: op %c not defined!", op[0]); 411 604 push_error (line); 412 605 return (FALSE); … … 416 609 /** free up any temporary buffers: **/ 417 610 418 if (V1[0].type == 'm') {611 if (V1[0].type == ST_MATRIX_TMP) { 419 612 free (V1[0].buffer[0].header.buffer); 420 613 free (V1[0].buffer[0].matrix.buffer); 421 614 free (V1[0].buffer); 422 615 } 423 if (V2[0].type == 'v') {616 if (V2[0].type == ST_VECTOR_TMP) { 424 617 free (V2[0].vector[0].elements.Ptr); 425 618 free (V2[0].vector); … … 446 639 447 640 /* if possible, use V2 as temp buffer, otherwise create new one */ 448 if (V2[0].type == 'm') {641 if (V2[0].type == ST_MATRIX_TMP) { 449 642 OUT[0].buffer = V2[0].buffer; 450 V2[0].type = 'M'; /* prevent it from being freed below */643 V2[0].type = ST_MATRIX; /* prevent it from being freed below */ 451 644 } else { /* no spare temp buffer */ 452 645 OUT[0].buffer = InitBuffer (); 453 646 CopyBuffer (OUT[0].buffer, V2[0].buffer); 454 647 } 455 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/648 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 456 649 457 650 float *M2 = (float *) V2[0].buffer[0].matrix.buffer; … … 487 680 case '^': VM_FUNC(pow (*M1, *M2)); 488 681 case '@': VM_FUNC(DEG_RAD*atan2 (*M1, *M2)); 682 case 'a': VM_FUNC(DEG_RAD*atan2 (*M1, *M2)); 489 683 case 'D': VM_FUNC(MIN (*M1, *M2)); 490 684 case 'U': VM_FUNC(MAX (*M1, *M2)); … … 500 694 case 'O': VM_FUNC((*M1 || *M2) ? 1 : 0); 501 695 default: 502 s printf (line, "error: op %c not defined!", op[0]);696 snprintf (line, 512, "error: op %c not defined!", op[0]); 503 697 push_error (line); 504 698 return (FALSE); … … 508 702 /** free up any temporary buffers: **/ 509 703 510 if (V1[0].type == 'v') {704 if (V1[0].type == ST_VECTOR_TMP) { 511 705 free (V1[0].vector[0].elements.Ptr); 512 706 free (V1[0].vector); 513 707 } 514 if (V2[0].type == 'm') {708 if (V2[0].type == ST_MATRIX_TMP) { 515 709 free (V2[0].buffer[0].header.buffer); 516 710 free (V2[0].buffer[0].matrix.buffer); … … 535 729 Ny = V1[0].buffer[0].matrix.Naxis[1]; 536 730 537 if (V1[0].type == 'm') { /** use V1 as temp buffer **/731 if (V1[0].type == ST_MATRIX_TMP) { /** use V1 as temp buffer **/ 538 732 OUT[0].buffer = V1[0].buffer; 539 V1[0].type = 'M'; /* prevent it from being freed below */733 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 540 734 } else { 541 if (V2[0].type == 'm') { /** use V2 as temp buffer, but header of V1 **/735 if (V2[0].type == ST_MATRIX_TMP) { /** use V2 as temp buffer, but header of V1 **/ 542 736 OUT[0].buffer = V2[0].buffer; 543 V2[0].type = 'M'; /* prevent it from being freed below */737 V2[0].type = ST_MATRIX; /* prevent it from being freed below */ 544 738 } else { /* no spare temp buffer */ 545 739 OUT[0].buffer = InitBuffer (); … … 547 741 } 548 742 } 549 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/743 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 550 744 551 745 M1 = (float *)V1[0].buffer[0].matrix.buffer; … … 567 761 case '^': MM_FUNC(pow (*M1, *M2)); 568 762 case '@': MM_FUNC(DEG_RAD*atan2 (*M1, *M2)); 763 case 'a': MM_FUNC(DEG_RAD*atan2 (*M1, *M2)); 569 764 case 'D': MM_FUNC(MIN (*M1, *M2)); 570 765 case 'U': MM_FUNC(MAX (*M1, *M2)); … … 580 775 case 'O': MM_FUNC((*M1 || *M2) ? 1 : 0); 581 776 default: 582 s printf (line, "error: op %c not defined!", op[0]);777 snprintf (line, 512, "error: op %c not defined!", op[0]); 583 778 push_error (line); 584 779 return (FALSE); … … 588 783 /** free up any temporary buffers: **/ 589 784 590 if (V1[0].type == 'm') {785 if (V1[0].type == ST_MATRIX_TMP) { 591 786 free (V1[0].buffer[0].header.buffer); 592 787 free (V1[0].buffer[0].matrix.buffer); 593 788 free (V1[0].buffer); 594 789 } 595 if (V2[0].type == 'm') {790 if (V2[0].type == ST_MATRIX_TMP) { 596 791 free (V2[0].buffer[0].header.buffer); 597 792 free (V2[0].buffer[0].matrix.buffer); … … 615 810 616 811 /* if possible, use V1 as temp buffer, otherwise create new one */ 617 if (V1[0].type == 'm') {812 if (V1[0].type == ST_MATRIX_TMP) { 618 813 OUT[0].buffer = V1[0].buffer; 619 V1[0].type = 'M'; /* prevent it from being freed below */814 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 620 815 } else { 621 816 OUT[0].buffer = InitBuffer (); 622 817 CopyBuffer (OUT[0].buffer, V1[0].buffer); 623 818 } 624 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/819 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 625 820 626 821 float *M1 = (float *)V1[0].buffer[0].matrix.buffer; … … 628 823 629 824 # define MS_FUNC(OP) { \ 630 if (V2->type == 'S') { \825 if (V2->type == ST_SCALAR_FLT) { \ 631 826 opihi_flt M2 = V2[0].FltValue; \ 632 827 for (i = 0; i < Nx*Ny; i++, out++, M1++) { \ … … 635 830 break; \ 636 831 } \ 637 if (V2->type == 's') { \832 if (V2->type == ST_SCALAR_INT) { \ 638 833 opihi_int M2 = V2[0].IntValue; \ 639 834 for (i = 0; i < Nx*Ny; i++, out++, M1++) { \ … … 652 847 case '^': MS_FUNC(pow (*M1, M2)); 653 848 case '@': MS_FUNC(DEG_RAD*atan2 (*M1, M2)); 849 case 'a': MS_FUNC(DEG_RAD*atan2 (*M1, M2)); 654 850 case 'D': MS_FUNC(MIN (*M1, M2)); 655 851 case 'U': MS_FUNC(MAX (*M1, M2)); … … 665 861 case 'O': MS_FUNC((*M1 || M2) ? 1 : 0); 666 862 default: 667 s printf (line, "error: op %c not defined!", op[0]);863 snprintf (line, 512, "error: op %c not defined!", op[0]); 668 864 push_error (line); 669 865 return (FALSE); … … 671 867 # undef MS_FUNC 672 868 673 if (V1[0].type == 'm') {869 if (V1[0].type == ST_MATRIX_TMP) { 674 870 free (V1[0].buffer[0].header.buffer); 675 871 free (V1[0].buffer[0].matrix.buffer); … … 691 887 Ny = V2[0].buffer[0].matrix.Naxis[1]; 692 888 693 if (V2[0].type == 'm') { /* V2[0] is NOT temporary, we can't use it for storage */889 if (V2[0].type == ST_MATRIX_TMP) { /* V2[0] is NOT temporary, we can't use it for storage */ 694 890 OUT[0].buffer = V2[0].buffer; 695 V2[0].type = 'M'; /* prevent it from being freed below */891 V2[0].type = ST_MATRIX; /* prevent it from being freed below */ 696 892 } else { 697 893 OUT[0].buffer = InitBuffer (); 698 894 CopyBuffer (OUT[0].buffer, V2[0].buffer); 699 895 } 700 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/896 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 701 897 702 898 float *M2 = (float *)V2[0].buffer[0].matrix.buffer; … … 704 900 705 901 # define SM_FUNC(OP) { \ 706 if (V1->type == 'S') { \902 if (V1->type == ST_SCALAR_FLT) { \ 707 903 opihi_flt M1 = V1[0].FltValue; \ 708 904 for (i = 0; i < Nx*Ny; i++, out++, M2++) { \ … … 711 907 break; \ 712 908 } \ 713 if (V1->type == 's') { \909 if (V1->type == ST_SCALAR_INT) { \ 714 910 opihi_int M1 = V1[0].IntValue; \ 715 911 for (i = 0; i < Nx*Ny; i++, out++, M2++) { \ … … 728 924 case '^': SM_FUNC(pow (M1, *M2)); 729 925 case '@': SM_FUNC(DEG_RAD*atan2 (M1, *M2)); 926 case 'a': SM_FUNC(DEG_RAD*atan2 (M1, *M2)); 730 927 case 'D': SM_FUNC(MIN (M1, *M2)); 731 928 case 'U': SM_FUNC(MAX (M1, *M2)); … … 741 938 case 'O': SM_FUNC((M1 || *M2) ? 1 : 0); 742 939 default: 743 s printf (line, "error: op %c not defined!", op[0]);940 snprintf (line, 512, "error: op %c not defined!", op[0]); 744 941 push_error (line); 745 942 return (FALSE); … … 747 944 # undef SM_FUNC 748 945 749 if (V2[0].type == 'm') {946 if (V2[0].type == ST_MATRIX_TMP) { 750 947 free (V2[0].buffer[0].header.buffer); 751 948 free (V2[0].buffer[0].matrix.buffer); … … 764 961 765 962 # define SS_FUNC(FTYPE,OP) { \ 766 if ((V1->type == 'S') && (V2->type == 'S')) { \963 if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_FLT)) { \ 767 964 opihi_flt M1 = V1[0].FltValue; \ 768 965 opihi_flt M2 = V2[0].FltValue; \ 769 OUT[0].type = 'S'; \966 OUT[0].type = ST_SCALAR_FLT; \ 770 967 OUT[0].FltValue = OP; \ 771 968 break; \ 772 969 } \ 773 if ((V1->type == 'S') && (V2->type == 's')) { \970 if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_INT)) { \ 774 971 opihi_flt M1 = V1[0].FltValue; \ 775 972 opihi_int M2 = V2[0].IntValue; \ 776 OUT[0].type = 'S'; \973 OUT[0].type = ST_SCALAR_FLT; \ 777 974 OUT[0].FltValue = OP; \ 778 975 break; \ 779 976 } \ 780 if ((V1->type == 's') && (V2->type == 'S')) { \977 if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_FLT)) { \ 781 978 opihi_int M1 = V1[0].IntValue; \ 782 979 opihi_flt M2 = V2[0].FltValue; \ 783 OUT[0].type = 'S'; \980 OUT[0].type = ST_SCALAR_FLT; \ 784 981 OUT[0].FltValue = OP; \ 785 982 break; \ 786 983 } \ 787 if ((FTYPE == 'S') && (V1->type == 's') && (V2->type == 's')) { \984 if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT)) { \ 788 985 opihi_int M1 = V1[0].IntValue; \ 789 986 opihi_int M2 = V2[0].IntValue; \ 790 OUT[0].type = 'S'; \987 OUT[0].type = ST_SCALAR_FLT; \ 791 988 OUT[0].FltValue = OP; \ 792 989 break; \ 793 990 } \ 794 if ((V1->type == 's') && (V2->type == 's')) { \991 if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT)) { \ 795 992 opihi_int M1 = V1[0].IntValue; \ 796 993 opihi_int M2 = V2[0].IntValue; \ 797 OUT[0].type = 's'; \994 OUT[0].type = ST_SCALAR_INT; \ 798 995 OUT[0].IntValue = OP; \ 799 996 break; \ … … 802 999 803 1000 switch (op[0]) { 804 case '+': SS_FUNC('s', M1 + M2); 805 case '-': SS_FUNC('s', M1 - M2); 806 case '*': SS_FUNC('s', M1 * M2); 807 case '/': SS_FUNC('S', M1 / (opihi_flt) M2); 808 case '%': SS_FUNC('s', (long long) M1 % (long long) M2); 809 case '^': SS_FUNC('S', pow (M1, M2)); 810 case '@': SS_FUNC('S', DEG_RAD*atan2 (M1, M2)); 811 case 'D': SS_FUNC('s', MIN (M1, M2)); 812 case 'U': SS_FUNC('s', MAX (M1, M2)); 813 case '<': SS_FUNC('s', (M1 < M2) ? 1 : 0); 814 case '>': SS_FUNC('s', (M1 > M2) ? 1 : 0); 815 case '&': SS_FUNC('s', ((long long)M1 & (long long)M2)); 816 case '|': SS_FUNC('s', ((long long)M1 | (long long)M2)); 817 case 'E': SS_FUNC('s', (M1 == M2) ? 1 : 0); 818 case 'N': SS_FUNC('s', (M1 != M2) ? 1 : 0); 819 case 'L': SS_FUNC('s', (M1 <= M2) ? 1 : 0); 820 case 'G': SS_FUNC('s', (M1 >= M2) ? 1 : 0); 821 case 'A': SS_FUNC('s', (M1 && M2) ? 1 : 0); 822 case 'O': SS_FUNC('s', (M1 || M2) ? 1 : 0); 1001 case '+': SS_FUNC(ST_SCALAR_INT, M1 + M2); 1002 case '-': SS_FUNC(ST_SCALAR_INT, M1 - M2); 1003 case '*': SS_FUNC(ST_SCALAR_INT, M1 * M2); 1004 case '/': SS_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) M2); 1005 case '%': SS_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) M2); 1006 case '^': SS_FUNC(ST_SCALAR_FLT, pow (M1, M2)); 1007 case '@': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2)); 1008 case 'a': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2)); 1009 case 'D': SS_FUNC(ST_SCALAR_INT, MIN (M1, M2)); 1010 case 'U': SS_FUNC(ST_SCALAR_INT, MAX (M1, M2)); 1011 case '<': SS_FUNC(ST_SCALAR_INT, (M1 < M2) ? 1 : 0); 1012 case '>': SS_FUNC(ST_SCALAR_INT, (M1 > M2) ? 1 : 0); 1013 case '&': SS_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)M2)); 1014 case '|': SS_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)M2)); 1015 case 'E': SS_FUNC(ST_SCALAR_INT, (M1 == M2) ? 1 : 0); 1016 case 'N': SS_FUNC(ST_SCALAR_INT, (M1 != M2) ? 1 : 0); 1017 case 'L': SS_FUNC(ST_SCALAR_INT, (M1 <= M2) ? 1 : 0); 1018 case 'G': SS_FUNC(ST_SCALAR_INT, (M1 >= M2) ? 1 : 0); 1019 case 'A': SS_FUNC(ST_SCALAR_INT, (M1 && M2) ? 1 : 0); 1020 case 'O': SS_FUNC(ST_SCALAR_INT, (M1 || M2) ? 1 : 0); 823 1021 default: 824 s printf (line, "error: op %c not defined!", op[0]);1022 snprintf (line, 512, "error: op %c not defined!", op[0]); 825 1023 push_error (line); 826 1024 return (FALSE); … … 844 1042 845 1043 if ((op[0] != 'N') && (op[0] != 'E')) { 846 s printf (line, "error: op %c not defined for string operations!", op[0]);1044 snprintf (line, 512, "error: op %c not defined for string operations!", op[0]); 847 1045 push_error (line); 848 1046 return (FALSE); … … 853 1051 thus: string == number -> false */ 854 1052 855 if ( !strncasecmp (&V1[0].type, "S", 1)) {1053 if (V1[0].type == ST_SCALAR_INT) { 856 1054 value = (op[0] == 'N'); 857 1055 goto escape; 858 1056 } 859 if (!strncasecmp (&V2[0].type, "S", 1)) { 1057 if (V1[0].type == ST_SCALAR_FLT) { 1058 value = (op[0] == 'N'); 1059 goto escape; 1060 } 1061 if (V2[0].type == ST_SCALAR_INT) { 1062 value = (op[0] == 'N'); 1063 goto escape; 1064 } 1065 if (V2[0].type == ST_SCALAR_FLT) { 860 1066 value = (op[0] == 'N'); 861 1067 goto escape; … … 870 1076 break; 871 1077 default: 872 s printf (line, "error: op %c not defined for string operations!", op[0]);1078 snprintf (line, 512, "error: op %c not defined for string operations!", op[0]); 873 1079 push_error (line); 874 1080 return (FALSE); … … 877 1083 escape: 878 1084 OUT[0].FltValue = value; 879 OUT[0].type = 'S';1085 OUT[0].type = ST_SCALAR_FLT; 880 1086 881 1087 clear_stack (V1); … … 891 1097 892 1098 # define S_FUNC(OP,FTYPE) { \ 893 if (V1->type == 'S') { \1099 if (V1->type == ST_SCALAR_FLT) { \ 894 1100 opihi_flt M1 = V1[0].FltValue; \ 895 OUT[0].type = 'S'; \1101 OUT[0].type = ST_SCALAR_FLT; \ 896 1102 OUT[0].FltValue = OP; \ 897 1103 clear_stack (V1); \ 898 1104 return (TRUE); \ 899 1105 } \ 900 if ((FTYPE == 'S') && (V1->type == 's')) { \1106 if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT)) { \ 901 1107 opihi_int M1 = V1[0].IntValue; \ 902 OUT[0].type = 'S'; \1108 OUT[0].type = ST_SCALAR_FLT; \ 903 1109 OUT[0].FltValue = OP; \ 904 1110 clear_stack (V1); \ 905 1111 return (TRUE); \ 906 1112 } \ 907 if ((FTYPE == 's') && (V1->type == 's')) { \1113 if ((FTYPE == ST_SCALAR_INT) && (V1->type == ST_SCALAR_INT)) { \ 908 1114 opihi_int M1 = V1[0].IntValue; \ 909 OUT[0].type = 's'; \1115 OUT[0].type = ST_SCALAR_INT; \ 910 1116 OUT[0].IntValue = OP; \ 911 1117 clear_stack (V1); \ … … 914 1120 } 915 1121 916 if (!strcmp (op, "=")) S_FUNC(M1, 's'); 917 if (!strcmp (op, "abs")) S_FUNC(fabs(M1), 's'); 918 if (!strcmp (op, "int")) S_FUNC((long long)(M1), 's'); 919 if (!strcmp (op, "exp")) S_FUNC(exp (M1), 'S'); 920 if (!strcmp (op, "ten")) S_FUNC(pow (10.0,M1), 'S'); 921 if (!strcmp (op, "log")) S_FUNC(log10 (M1), 'S'); 922 if (!strcmp (op, "ln")) S_FUNC(log (M1), 'S'); 923 if (!strcmp (op, "sqrt")) S_FUNC(sqrt (M1), 'S'); 924 if (!strcmp (op, "erf")) S_FUNC(erf (M1), 'S'); 925 if (!strcmp (op, "sinh")) S_FUNC(sinh (M1), 'S'); 926 if (!strcmp (op, "cosh")) S_FUNC(cosh (M1), 'S'); 927 if (!strcmp (op, "asinh")) S_FUNC(asinh (M1), 'S'); 928 if (!strcmp (op, "acosh")) S_FUNC(acosh (M1), 'S'); 929 if (!strcmp (op, "lgamma")) S_FUNC(lgamma (M1), 'S'); 930 if (!strcmp (op, "sin")) S_FUNC(sin (M1), 'S'); 931 if (!strcmp (op, "cos")) S_FUNC(cos (M1), 'S'); 932 if (!strcmp (op, "tan")) S_FUNC(tan (M1), 'S'); 933 if (!strcmp (op, "dsin")) S_FUNC(sin (M1*RAD_DEG), 'S'); 934 if (!strcmp (op, "dcos")) S_FUNC(cos (M1*RAD_DEG), 'S'); 935 if (!strcmp (op, "dtan")) S_FUNC(tan (M1*RAD_DEG), 'S'); 936 if (!strcmp (op, "asin")) S_FUNC(asin (M1), 'S'); 937 if (!strcmp (op, "acos")) S_FUNC(acos (M1), 'S'); 938 if (!strcmp (op, "atan")) S_FUNC(atan (M1), 'S'); 939 if (!strcmp (op, "dasin")) S_FUNC(asin (M1)*DEG_RAD, 'S'); 940 if (!strcmp (op, "dacos")) S_FUNC(acos (M1)*DEG_RAD, 'S'); 941 if (!strcmp (op, "datan")) S_FUNC(atan (M1)*DEG_RAD, 'S'); 942 if (!strcmp (op, "rnd")) S_FUNC(M1*0.0 + drand48(), 'S'); 943 if (!strcmp (op, "not")) S_FUNC(!(M1), 's'); 944 if (!strcmp (op, "--")) S_FUNC(-1*M1, 's'); // NOTE: opihi_int is signed, 945 if (!strcmp (op, "isinf")) S_FUNC(!finite(M1), 'S'); // XXX modify in future 946 if (!strcmp (op, "isnan")) S_FUNC(isnan(M1), 'S'); // XXX modify in future 1122 if (!strcmp (op, "=")) S_FUNC(M1, ST_SCALAR_INT); 1123 if (!strcmp (op, "abs")) S_FUNC(fabs(M1), ST_SCALAR_INT); 1124 if (!strcmp (op, "int")) S_FUNC((long long)(M1), ST_SCALAR_INT); 1125 if (!strcmp (op, "floor")) S_FUNC(floor (M1), ST_SCALAR_FLT); 1126 if (!strcmp (op, "ceil")) S_FUNC(ceil (M1), ST_SCALAR_FLT); 1127 // if (!strcmp (op, "rint")) S_FUNC(nearbyint (M1), ST_SCALAR_FLT); 1128 if (!strcmp (op, "exp")) S_FUNC(exp (M1), ST_SCALAR_FLT); 1129 if (!strcmp (op, "ten")) S_FUNC(pow (10.0,M1), ST_SCALAR_FLT); 1130 if (!strcmp (op, "log")) S_FUNC(log10 (M1), ST_SCALAR_FLT); 1131 if (!strcmp (op, "ln")) S_FUNC(log (M1), ST_SCALAR_FLT); 1132 if (!strcmp (op, "sqrt")) S_FUNC(sqrt (M1), ST_SCALAR_FLT); 1133 if (!strcmp (op, "erf")) S_FUNC(erf (M1), ST_SCALAR_FLT); 1134 if (!strcmp (op, "sinh")) S_FUNC(sinh (M1), ST_SCALAR_FLT); 1135 if (!strcmp (op, "cosh")) S_FUNC(cosh (M1), ST_SCALAR_FLT); 1136 if (!strcmp (op, "asinh")) S_FUNC(asinh (M1), ST_SCALAR_FLT); 1137 if (!strcmp (op, "acosh")) S_FUNC(acosh (M1), ST_SCALAR_FLT); 1138 if (!strcmp (op, "lgamma")) S_FUNC(lgamma (M1), ST_SCALAR_FLT); 1139 if (!strcmp (op, "sin")) S_FUNC(sin (M1), ST_SCALAR_FLT); 1140 if (!strcmp (op, "cos")) S_FUNC(cos (M1), ST_SCALAR_FLT); 1141 if (!strcmp (op, "tan")) S_FUNC(tan (M1), ST_SCALAR_FLT); 1142 if (!strcmp (op, "dsin")) S_FUNC(sin (M1*RAD_DEG), ST_SCALAR_FLT); 1143 if (!strcmp (op, "dcos")) S_FUNC(cos (M1*RAD_DEG), ST_SCALAR_FLT); 1144 if (!strcmp (op, "dtan")) S_FUNC(tan (M1*RAD_DEG), ST_SCALAR_FLT); 1145 if (!strcmp (op, "asin")) S_FUNC(asin (M1), ST_SCALAR_FLT); 1146 if (!strcmp (op, "acos")) S_FUNC(acos (M1), ST_SCALAR_FLT); 1147 if (!strcmp (op, "atan")) S_FUNC(atan (M1), ST_SCALAR_FLT); 1148 if (!strcmp (op, "dasin")) S_FUNC(asin (M1)*DEG_RAD, ST_SCALAR_FLT); 1149 if (!strcmp (op, "dacos")) S_FUNC(acos (M1)*DEG_RAD, ST_SCALAR_FLT); 1150 if (!strcmp (op, "datan")) S_FUNC(atan (M1)*DEG_RAD, ST_SCALAR_FLT); 1151 if (!strcmp (op, "rnd")) S_FUNC(M1*0.0 + drand48(), ST_SCALAR_FLT); 1152 if (!strcmp (op, "not")) S_FUNC(!(M1), ST_SCALAR_INT); 1153 if (!strcmp (op, "--")) S_FUNC(-1*M1, ST_SCALAR_INT); // NOTE: opihi_int is signed, 1154 if (!strcmp (op, "isinf")) S_FUNC(!finite(M1), ST_SCALAR_FLT); // XXX modify in future 1155 if (!strcmp (op, "isnan")) S_FUNC(isnan(M1), ST_SCALAR_FLT); // XXX modify in future 947 1156 948 1157 # undef S_FUNC 949 1158 950 1159 clear_stack (V1); 951 s printf (line, "error: op %s not defined!", op);1160 snprintf (line, 512, "error: op %s not defined!", op); 952 1161 push_error (line); 953 1162 return (FALSE); … … 962 1171 963 1172 OUT[0].vector = InitVector (); 964 OUT[0].type = 'v'; /*** <<--- says this is a temporary matrix ***/1173 OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/ 965 1174 966 1175 # define V_FUNC(OP,FTYPE) { \ … … 974 1183 goto escape; \ 975 1184 } \ 976 if ((V1->vector->type == OPIHI_INT) && (FTYPE == 'S')) { \1185 if ((V1->vector->type == OPIHI_INT) && (FTYPE == ST_SCALAR_FLT)) { \ 977 1186 MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT); \ 978 1187 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 983 1192 goto escape; \ 984 1193 } \ 985 if ((V1->vector->type == OPIHI_INT) && (FTYPE == 's')) { \1194 if ((V1->vector->type == OPIHI_INT) && (FTYPE == ST_SCALAR_INT)) { \ 986 1195 CopyVector (OUT[0].vector, V1[0].vector); \ 987 1196 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 993 1202 } } 994 1203 995 if (!strcmp (op, "=")) V_FUNC(*M1, 's'); 996 if (!strcmp (op, "abs")) V_FUNC(fabs(*M1), 's'); 997 if (!strcmp (op, "int")) V_FUNC((long long)(*M1), 's'); 998 if (!strcmp (op, "exp")) V_FUNC(exp(*M1), 'S'); 999 if (!strcmp (op, "ten")) V_FUNC(pow(10.0,*M1), 'S'); 1000 if (!strcmp (op, "log")) V_FUNC(log10(*M1), 'S'); 1001 if (!strcmp (op, "ln")) V_FUNC(log(*M1), 'S'); 1002 if (!strcmp (op, "sqrt")) V_FUNC(sqrt(*M1), 'S'); 1003 if (!strcmp (op, "erf")) V_FUNC(erf(*M1), 'S'); 1004 if (!strcmp (op, "sinh")) V_FUNC(sinh(*M1), 'S'); 1005 if (!strcmp (op, "cosh")) V_FUNC(cosh(*M1), 'S'); 1006 if (!strcmp (op, "asinh")) V_FUNC(asinh(*M1), 'S'); 1007 if (!strcmp (op, "acosh")) V_FUNC(acosh(*M1), 'S'); 1008 if (!strcmp (op, "lgamma")) V_FUNC(lgamma(*M1), 'S'); 1009 if (!strcmp (op, "sin")) V_FUNC(sin(*M1), 'S'); 1010 if (!strcmp (op, "cos")) V_FUNC(cos(*M1), 'S'); 1011 if (!strcmp (op, "tan")) V_FUNC(tan(*M1), 'S'); 1012 if (!strcmp (op, "dsin")) V_FUNC(sin(*M1*RAD_DEG), 'S'); 1013 if (!strcmp (op, "dcos")) V_FUNC(cos(*M1*RAD_DEG), 'S'); 1014 if (!strcmp (op, "dtan")) V_FUNC(tan(*M1*RAD_DEG), 'S'); 1015 if (!strcmp (op, "asin")) V_FUNC(asin(*M1), 'S'); 1016 if (!strcmp (op, "acos")) V_FUNC(acos(*M1), 'S'); 1017 if (!strcmp (op, "atan")) V_FUNC(atan(*M1), 'S'); 1018 if (!strcmp (op, "dasin")) V_FUNC(asin(*M1)*DEG_RAD, 'S'); 1019 if (!strcmp (op, "dacos")) V_FUNC(acos(*M1)*DEG_RAD, 'S'); 1020 if (!strcmp (op, "datan")) V_FUNC(atan(*M1)*DEG_RAD, 'S'); 1021 if (!strcmp (op, "rnd")) V_FUNC(drand48(), 'S'); 1022 if (!strcmp (op, "ramp")) V_FUNC(i, 's'); 1023 if (!strcmp (op, "zero")) V_FUNC(0, 's'); 1024 if (!strcmp (op, "not")) V_FUNC(!(*M1), 's'); 1025 if (!strcmp (op, "--")) V_FUNC(-1*(*M1), 's'); // NOTE: opihi_int is signed 1026 if (!strcmp (op, "isinf")) V_FUNC(!finite(*M1), 'S'); 1027 if (!strcmp (op, "isnan")) V_FUNC(isnan(*M1), 'S'); 1028 if (!strcmp (op, "xramp")) V_FUNC(i, 's'); 1029 if (!strcmp (op, "yramp")) V_FUNC(0, 's'); 1204 if (!strcmp (op, "=")) V_FUNC(*M1, ST_SCALAR_INT); 1205 if (!strcmp (op, "abs")) V_FUNC(fabs(*M1), ST_SCALAR_INT); 1206 if (!strcmp (op, "int")) V_FUNC((long long)(*M1), ST_SCALAR_INT); 1207 if (!strcmp (op, "floor")) V_FUNC(floor (*M1), ST_SCALAR_FLT); 1208 if (!strcmp (op, "ceil")) V_FUNC(ceil (*M1), ST_SCALAR_FLT); 1209 // if (!strcmp (op, "rint")) V_FUNC(nearbyint (*M1), ST_SCALAR_FLT); 1210 if (!strcmp (op, "exp")) V_FUNC(exp(*M1), ST_SCALAR_FLT); 1211 if (!strcmp (op, "ten")) V_FUNC(pow(10.0,*M1), ST_SCALAR_FLT); 1212 if (!strcmp (op, "log")) V_FUNC(log10(*M1), ST_SCALAR_FLT); 1213 if (!strcmp (op, "ln")) V_FUNC(log(*M1), ST_SCALAR_FLT); 1214 if (!strcmp (op, "sqrt")) V_FUNC(sqrt(*M1), ST_SCALAR_FLT); 1215 if (!strcmp (op, "erf")) V_FUNC(erf(*M1), ST_SCALAR_FLT); 1216 if (!strcmp (op, "sinh")) V_FUNC(sinh(*M1), ST_SCALAR_FLT); 1217 if (!strcmp (op, "cosh")) V_FUNC(cosh(*M1), ST_SCALAR_FLT); 1218 if (!strcmp (op, "asinh")) V_FUNC(asinh(*M1), ST_SCALAR_FLT); 1219 if (!strcmp (op, "acosh")) V_FUNC(acosh(*M1), ST_SCALAR_FLT); 1220 if (!strcmp (op, "lgamma")) V_FUNC(lgamma(*M1), ST_SCALAR_FLT); 1221 if (!strcmp (op, "sin")) V_FUNC(sin(*M1), ST_SCALAR_FLT); 1222 if (!strcmp (op, "cos")) V_FUNC(cos(*M1), ST_SCALAR_FLT); 1223 if (!strcmp (op, "tan")) V_FUNC(tan(*M1), ST_SCALAR_FLT); 1224 if (!strcmp (op, "dsin")) V_FUNC(sin(*M1*RAD_DEG), ST_SCALAR_FLT); 1225 if (!strcmp (op, "dcos")) V_FUNC(cos(*M1*RAD_DEG), ST_SCALAR_FLT); 1226 if (!strcmp (op, "dtan")) V_FUNC(tan(*M1*RAD_DEG), ST_SCALAR_FLT); 1227 if (!strcmp (op, "asin")) V_FUNC(asin(*M1), ST_SCALAR_FLT); 1228 if (!strcmp (op, "acos")) V_FUNC(acos(*M1), ST_SCALAR_FLT); 1229 if (!strcmp (op, "atan")) V_FUNC(atan(*M1), ST_SCALAR_FLT); 1230 if (!strcmp (op, "dasin")) V_FUNC(asin(*M1)*DEG_RAD, ST_SCALAR_FLT); 1231 if (!strcmp (op, "dacos")) V_FUNC(acos(*M1)*DEG_RAD, ST_SCALAR_FLT); 1232 if (!strcmp (op, "datan")) V_FUNC(atan(*M1)*DEG_RAD, ST_SCALAR_FLT); 1233 if (!strcmp (op, "rnd")) V_FUNC(drand48(), ST_SCALAR_FLT); 1234 if (!strcmp (op, "ramp")) V_FUNC(i, ST_SCALAR_INT); 1235 if (!strcmp (op, "zero")) V_FUNC(0, ST_SCALAR_INT); 1236 if (!strcmp (op, "not")) V_FUNC(!(*M1), ST_SCALAR_INT); 1237 if (!strcmp (op, "--")) V_FUNC(-1*(*M1), ST_SCALAR_INT); // NOTE: opihi_int is signed 1238 if (!strcmp (op, "isinf")) V_FUNC(!finite(*M1), ST_SCALAR_FLT); 1239 if (!strcmp (op, "isnan")) V_FUNC(isnan(*M1), ST_SCALAR_FLT); 1240 if (!strcmp (op, "xramp")) V_FUNC(i, ST_SCALAR_INT); 1241 if (!strcmp (op, "yramp")) V_FUNC(0, ST_SCALAR_INT); 1030 1242 /* xramp and yramp above only make sense for matrices. for vectors, xramp = ramp, yramp = zero */ 1031 1243 … … 1034 1246 escape: 1035 1247 1036 if (V1[0].type == 'v') {1248 if (V1[0].type == ST_VECTOR_TMP) { 1037 1249 free (V1[0].vector[0].elements.Ptr); 1038 1250 free (V1[0].vector); … … 1053 1265 Ny = V1[0].buffer[0].matrix.Naxis[1]; 1054 1266 1055 if (V1[0].type == 'm') {1267 if (V1[0].type == ST_MATRIX_TMP) { 1056 1268 OUT[0].buffer = V1[0].buffer; 1057 V1[0].type = 'M'; /* prevent it from being freed below */1269 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 1058 1270 } else { 1059 1271 OUT[0].buffer = InitBuffer (); 1060 1272 CopyBuffer (OUT[0].buffer, V1[0].buffer); 1061 1273 } 1062 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/1274 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 1063 1275 M1 = (float *) V1[0].buffer[0].matrix.buffer; 1064 1276 out = (float *)OUT[0].buffer[0].matrix.buffer; … … 1067 1279 if (!strcmp (op, "abs")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = fabs(*M1); }} 1068 1280 if (!strcmp (op, "int")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = (opihi_flt)(long long)(*M1); }} 1281 1282 if (!strcmp (op, "floor")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = floor (*M1); }} 1283 if (!strcmp (op, "ceil")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = ceil (*M1); }} 1284 // if (!strcmp (op, "rint")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = nearbyint (*M1); }} 1285 1069 1286 if (!strcmp (op, "exp")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = exp(*M1); }} 1070 1287 if (!strcmp (op, "ten")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = pow(10.0,*M1); }} … … 1116 1333 } 1117 1334 1118 if (V1[0].type == 'm') {1335 if (V1[0].type == ST_MATRIX_TMP) { 1119 1336 free (V1[0].buffer[0].header.buffer); 1120 1337 free (V1[0].buffer[0].matrix.buffer); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/lib.shell/string.c
r33662 r37067 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/ipp-ops-20130712/Ohana/src/opihi/pantasks/CheckController.c
r23530 r37067 29 29 if (p != NULL) goto escape; 30 30 31 /** skip past any leading garbage? ***/ 32 33 /** find "Njobs: **/ 34 p = memstr (buffer.buffer, "BEGIN BLOCK Njobs:", MIN(buffer.Nbuffer, 256)); 35 p += strlen("BEGIN BLOCK Njobs:"); 36 31 37 /** parse job list **/ 32 status = sscanf ( buffer.buffer, "%*s%d", &Njobs);38 status = sscanf (p, "%d", &Njobs); 33 39 if (status != 1) goto escape; 34 40 if (VerboseMode()) gprint (GP_ERR, "parse %d jobs on stack %f\n", Njobs, TimerElapsed(&start, TRUE)); 35 41 36 p = buffer.buffer; 42 /* output looks like: 43 BEGIN BLOCK Njobs: NN\n 44 ID name machine\n 45 ID name machine\n 46 */ 47 48 // p is currently pointing at "BEGIN BLOCK Njobs" 49 37 50 for (i = 0; i < Njobs; i++) { 38 51 q = strchr (p, '\n'); … … 67 80 if (p != NULL) goto escape; 68 81 82 /** skip past any leading garbage? ***/ 83 84 /** find "Njobs: **/ 85 p = memstr (buffer.buffer, "BEGIN BLOCK Njobs:", MIN(buffer.Nbuffer, 256)); 86 p += strlen("BEGIN BLOCK Njobs:"); 87 69 88 /** parse job list **/ 70 status = sscanf ( buffer.buffer, "%*s%d", &Njobs);89 status = sscanf (p, "%d", &Njobs); 71 90 if (status != 1) goto escape; 72 91 if (VerboseMode()) gprint (GP_ERR, "check crash stack %f\n", TimerElapsed(&start, TRUE)); 73 92 74 p = buffer.buffer; 93 /* output looks like: 94 BEGIN BLOCK Njobs: NN\n 95 ID name machine\n 96 ID name machine\n 97 */ 98 99 // p is currently pointing at "BEGIN BLOCK Njobs" 100 75 101 for (i = 0; i < Njobs; i++) { 76 102 q = strchr (p, '\n'); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/ControllerOps.c
r34088 r37067 259 259 } 260 260 261 if (job[0]. priority) {261 if (job[0].nicelevel) { 262 262 char tmp[64]; 263 snprintf (tmp, 64, " -nice %d", job[0]. priority);263 snprintf (tmp, 64, " -nice %d", job[0].nicelevel); 264 264 strcat (cmd, tmp); 265 265 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/JobOps.c
r32632 r37067 107 107 job[0].mode = JOB_CONTROLLER; 108 108 } 109 job[0]. priority = task[0].priority;109 job[0].nicelevel = task[0].nicelevel; 110 110 111 111 /* we need our own copy of task[0].argv argc is the number of valid args, like the usual command line. we -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/LocalJob.c
r32632 r37067 162 162 163 163 /* set nice level for the child process -- maybe I should not exit here... */ 164 if (job[0]. priority) {165 status = setpriority (PRIO_PROCESS, pid, job[0]. priority);164 if (job[0].nicelevel) { 165 status = setpriority (PRIO_PROCESS, pid, job[0].nicelevel); 166 166 if (status == -1) { 167 gprint (GP_ERR, "error setting priority\n");167 gprint (GP_ERR, "error setting nice level\n"); 168 168 perror ("setpriority: "); 169 169 exit (2); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/TaskOps.c
r32632 r37067 487 487 488 488 NewTask[0].active = TRUE; 489 NewTask[0]. priority= 0;489 NewTask[0].nicelevel = 0; 490 490 return (NewTask); 491 491 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/init.c
r32632 r37067 34 34 {1, "halt", halt, "halt the scheduler (no job harvesting)"}, 35 35 {1, "host", task_host, "define host machine for a task"}, 36 {1, "nice", task_nice, "set nice prioritylevel for a task"},36 {1, "nice", task_nice, "set nice level for a task"}, 37 37 {1, "ipptool2book", ipptool2book, "convert queue with ipptool output to book"}, 38 38 {1, "kill", kill_job, "kill job"}, -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/init_server.c
r32632 r37067 35 35 {1, "delete", delete_job, "delete job"}, 36 36 {1, "host", task_host, "define host machine for a task"}, 37 {1, "nice", task_nice, "set nice prioritylevel for a task"},37 {1, "nice", task_nice, "set nice level for a task"}, 38 38 {1, "ipptool2book", ipptool2book, "convert queue with ipptool output to book"}, 39 39 {1, "kill", kill_job, "kill job"}, -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pantasks/task_nice.c
r32632 r37067 4 4 5 5 char *endptr = NULL; 6 int priority;6 int nicelevel; 7 7 Task *task; 8 8 9 9 if (argc != 2) { 10 gprint (GP_ERR, "USAGE: nice ( priority)\n");10 gprint (GP_ERR, "USAGE: nice (nicelevel)\n"); 11 11 return (FALSE); 12 12 } … … 20 20 } 21 21 22 priority= strtol (argv[1], &endptr, 10);22 nicelevel = strtol (argv[1], &endptr, 10); 23 23 if (*endptr) goto fail; 24 if ( priority< 0) goto fail;25 if ( priority> 20) goto fail;24 if (nicelevel < 0) goto fail; 25 if (nicelevel > 20) goto fail; 26 26 27 task[0]. priority = priority;27 task[0].nicelevel = nicelevel; 28 28 JobTaskUnlock(); 29 29 return (TRUE); 30 30 31 31 fail: 32 gprint (GP_ERR, "ERROR: nice ( priority) -- prioritymust be an integer 0 to 20\n");32 gprint (GP_ERR, "ERROR: nice (nicelevel) -- nicelevel must be an integer 0 to 20\n"); 33 33 return (FALSE); 34 34 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pclient/job.c
r32632 r37067 3 3 int job (int argc, char **argv) { 4 4 5 int i, N, pid, status, priority;5 int i, N, pid, status, nicelevel; 6 6 char **targv; 7 7 8 priority= 0;8 nicelevel = 0; 9 9 if ((N = get_argument (argc, argv, "-nice"))) { 10 10 remove_argument (N, &argc, argv); 11 priority= atoi (argv[N]);11 nicelevel = atoi (argv[N]); 12 12 remove_argument (N, &argc, argv); 13 13 } … … 62 62 63 63 /* set nice level for the child process */ 64 if ( priority) {65 status = setpriority (PRIO_PROCESS, pid, priority);64 if (nicelevel) { 65 status = setpriority (PRIO_PROCESS, pid, nicelevel); 66 66 if (status == -1) { 67 gprint (GP_ERR, "error setting priority\n");67 gprint (GP_ERR, "error setting nicelevel\n"); 68 68 perror ("setpriority: "); 69 69 exit (2); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pcontrol/CheckBusyJob.c
r28242 r37067 99 99 100 100 // XXX runaway job if output too large? 101 if (job[0].stdout_buf.size > 0x1000000 ) abort();102 if (job[0].stderr_buf.size > 0x1000000 ) abort();101 if (job[0].stdout_buf.size > 0x10000000) abort(); 102 if (job[0].stderr_buf.size > 0x10000000) abort(); 103 103 104 104 // job has exited : move to DONE stack -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pcontrol/JobOps.c
r32632 r37067 61 61 } 62 62 63 int GetJobStackIDbyName (char *name) { 64 if (!strcasecmp (name, "ALLJOBS")) return PCONTROL_JOB_ALLJOBS; 65 if (!strcasecmp (name, "PENDING")) return PCONTROL_JOB_PENDING; 66 if (!strcasecmp (name, "BUSY")) return PCONTROL_JOB_BUSY ; 67 if (!strcasecmp (name, "RESP")) return PCONTROL_JOB_RESP ; 68 if (!strcasecmp (name, "DONE")) return PCONTROL_JOB_DONE ; 69 if (!strcasecmp (name, "KILL")) return PCONTROL_JOB_KILL ; 70 if (!strcasecmp (name, "EXIT")) return PCONTROL_JOB_EXIT ; 71 if (!strcasecmp (name, "CRASH")) return PCONTROL_JOB_CRASH ; 72 return (PCONTROL_JOB_NONE); 73 } 74 63 75 Stack *GetJobStack (int StackID) { 64 76 switch (StackID) { … … 195 207 } 196 208 197 IDtype AddJob (char *hostname, JobMode mode, int timeout, int priority, int argc, char **argv, int Nxhosts, char **xhosts) {209 IDtype AddJob (char *hostname, JobMode mode, int timeout, int nicelevel, int argc, char **argv, int Nxhosts, char **xhosts) { 198 210 199 211 int JobID; … … 220 232 221 233 job[0].mode = mode; 222 job[0]. priority = priority;234 job[0].nicelevel = nicelevel; 223 235 224 236 job[0].state = 0; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pcontrol/StartJob.c
r32632 r37067 25 25 bzero (line, Nline); 26 26 strcpy (line, "job"); 27 if (job[0]. priority) {27 if (job[0].nicelevel) { 28 28 char tmp[64]; 29 snprintf (tmp, 64, " -nice %d", job[0]. priority);29 snprintf (tmp, 64, " -nice %d", job[0].nicelevel); 30 30 strcat (line, tmp); 31 31 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pcontrol/job.c
r32632 r37067 5 5 char *Host = NULL; 6 6 char **targv = NULL; 7 int i, N, Mode, targc, Timeout, priority;7 int i, N, Mode, targc, Timeout, nicelevel; 8 8 IDtype JobID; 9 9 char **xhosts = NULL; … … 43 43 } 44 44 45 priority= 0;45 nicelevel = 0; 46 46 if ((N = get_argument (argc, argv, "-nice"))) { 47 47 remove_argument (N, &argc, argv); 48 priority= atoi (argv[N]);48 nicelevel = atoi (argv[N]); 49 49 remove_argument (N, &argc, argv); 50 50 } … … 76 76 77 77 // a JobID < 0 mean the job was not accepted 78 JobID = AddJob (Host, Mode, Timeout, priority, targc, targv, Nxhosts, xhosts);78 JobID = AddJob (Host, Mode, Timeout, nicelevel, targc, targv, Nxhosts, xhosts); 79 79 gprint (GP_LOG, "JobID: %d\n", (int) JobID); 80 80 return (TRUE); … … 82 82 usage: 83 83 gprint (GP_ERR, "USAGE: job [options] (arg0) (arg1) ... (argN)\n"); 84 gprint (GP_ERR, " options: -host, +host, -timeout, -xhost (host) \n");84 gprint (GP_ERR, " options: -host, +host, -timeout, -xhost (host) -nice (level)\n"); 85 85 gprint (GP_ERR, " arguments of the form @MAX_THREADS@ will be replaced when the job is launched\n"); 86 86 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pcontrol/jobstack.c
r12470 r37067 22 22 /* print list */ 23 23 LockStack (stack); 24 gprint (GP_LOG, " Njobs: %d\n", stack[0].Nobject);24 gprint (GP_LOG, "BEGIN BLOCK Njobs: %d\n", stack[0].Nobject); 25 25 for (i = 0; i < stack[0].Nobject; i++) { 26 26 job = stack[0].object[i]; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/opihi/pcontrol/status.c
r32632 r37067 1 1 # include "pcontrol.h" 2 2 3 int PrintJobStack (int Nstack );3 int PrintJobStack (int Nstack, char *command, char *hostname, int state, float age); 4 4 int PrintHostStack (int Nstack); 5 5 6 6 int status (int argc, char **argv) { 7 7 8 PrintJobStack (PCONTROL_JOB_ALLJOBS); 9 PrintHostStack (PCONTROL_HOST_ALLHOSTS); 8 int N; 9 10 if (get_argument (argc, argv, "-h")) goto usage; 11 if (get_argument (argc, argv, "-help")) goto usage; 12 if (get_argument (argc, argv, "--help")) goto usage; 13 14 /* I would like to add the following options: 15 * strsub on argv[0] 16 * strsub on hostname, realhost 17 * list hostname and realhost 18 * filter by state 19 * filter by dtime 20 */ 21 22 // -cmd (cmd) 23 // -host (hostname) 24 // -state (busy, pending, done, kill, exit, crash, resp, hung 25 // -age (seconds?) (minutes?) 26 // -nohost 27 28 char *COMMAND = NULL; 29 if ((N = get_argument (argc, argv, "-cmd"))) { 30 remove_argument (N, &argc, argv); 31 COMMAND = strcreate (argv[N]); 32 remove_argument (N, &argc, argv); 33 } 34 35 char *HOSTNAME = NULL; 36 if ((N = get_argument (argc, argv, "-host"))) { 37 remove_argument (N, &argc, argv); 38 HOSTNAME = strcreate (argv[N]); 39 remove_argument (N, &argc, argv); 40 } 41 42 int STATE = PCONTROL_JOB_ALLJOBS; 43 if ((N = get_argument (argc, argv, "-state"))) { 44 remove_argument (N, &argc, argv); 45 STATE = GetJobStackIDbyName (argv[N]); 46 remove_argument (N, &argc, argv); 47 if (STATE == PCONTROL_JOB_NONE) goto usage; 48 } 49 50 float AGE = 0.0; 51 if ((N = get_argument (argc, argv, "-age"))) { 52 remove_argument (N, &argc, argv); 53 AGE = atof (argv[N]); 54 remove_argument (N, &argc, argv); 55 } 56 57 int SHOWHOST = TRUE; 58 if ((N = get_argument (argc, argv, "-nohost"))) { 59 remove_argument (N, &argc, argv); 60 SHOWHOST = FALSE; 61 } 62 if ((N = get_argument (argc, argv, "+jobs"))) { 63 remove_argument (N, &argc, argv); 64 SHOWHOST = FALSE; 65 } 66 67 int SHOWJOBS = TRUE; 68 if ((N = get_argument (argc, argv, "-nojobs"))) { 69 remove_argument (N, &argc, argv); 70 SHOWJOBS = FALSE; 71 } 72 if ((N = get_argument (argc, argv, "+host"))) { 73 remove_argument (N, &argc, argv); 74 SHOWJOBS = FALSE; 75 } 76 77 if (SHOWJOBS) { 78 PrintJobStack (PCONTROL_JOB_ALLJOBS, COMMAND, HOSTNAME, STATE, AGE); 79 } 80 if (SHOWHOST) { 81 PrintHostStack (PCONTROL_HOST_ALLHOSTS); 82 } 10 83 11 84 return (TRUE); 85 86 usage: 87 gprint (GP_ERR, "USAGE: status [-cmd command] [-host hostname] [-state state] [-age seconds] [+jobs,-nohost] [+host,-nojobs]\n"); 88 return FALSE; 12 89 } 13 90 14 int PrintJobStack (int Nstack ) {91 int PrintJobStack (int Nstack, char *command, char *hostname, int state, float age) { 15 92 16 93 int i, j, Nobject; … … 30 107 job = stack[0].object[i]; 31 108 ASSERT (job != NULL, "programming error"); 32 if (job[0].realhost == NULL) { 33 gprint (GP_LOG, "%3d %9s ", i, job[0].hostname); 34 } else { 35 gprint (GP_LOG, "%3d %9s ", i, job[0].realhost); 36 } 37 gprint (GP_LOG, "%7s ", GetJobStackName (job[0].state)); 109 110 char *thishost = (job[0].realhost == NULL) ? job[0].hostname : job[0].realhost; 38 111 39 112 switch (job[0].state) { … … 45 118 gettimeofday (&now, (void *) NULL); 46 119 dtime = DTIME (now, job[0].start); 47 gprint (GP_LOG, "%8.2f ", dtime);48 120 break; 49 121 … … 55 127 default: 56 128 dtime = DTIME (job[0].stop, job[0].start); 57 gprint (GP_LOG, "%8.2f ", dtime);58 129 break; 59 130 } 60 131 132 // check on the filters 133 if (command) { 134 if (!strstr (job[0].argv[0], command)) continue; 135 } 136 if (hostname) { 137 if (!strstr (thishost, hostname)) continue; 138 } 139 if (age > 0.0) { 140 if (dtime < age) continue; 141 } 142 if (state != PCONTROL_JOB_ALLJOBS) { 143 // allow PCONTROL_JOB_RESP == BUSY 144 int validState = FALSE; 145 validState |= (state == PCONTROL_JOB_RESP) && (job[0].state == PCONTROL_JOB_BUSY); 146 validState |= (state == PCONTROL_JOB_BUSY) && (job[0].state == PCONTROL_JOB_RESP); 147 validState |= (state == job[0].state); 148 if (!validState) continue; 149 } 150 151 gprint (GP_LOG, "%3d %9s ", i, thishost); 152 gprint (GP_LOG, "%7s ", GetJobStackName (job[0].state)); 153 gprint (GP_LOG, "%8.2f ", dtime); 154 61 155 PrintID (GP_LOG, job[0].JobID); 62 gprint (GP_LOG, " %2d ", job[0]. priority);156 gprint (GP_LOG, " %2d ", job[0].nicelevel); 63 157 for (j = 0; j < job[0].argc; j++) { 64 158 gprint (GP_LOG, "%s ", job[0].argv[j]); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/photdbc/Makefile
r33655 r37067 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/ipp-ops-20130712/Ohana/src/photdbc/include/photdbc.h
r33963 r37067 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/ipp-ops-20130712/Ohana/src/photdbc/src/args.c
r33655 r37067 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/ipp-ops-20130712/Ohana/src/photdbc/src/copy_images.c
r33655 r37067 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/ipp-ops-20130712/Ohana/src/photdbc/src/find_images.c
r30616 r37067 25 25 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 26 26 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 27 strcpy (tcoords.ctype, " RA---TAN");27 strcpy (tcoords.ctype, "DEC--TAN"); 28 28 29 29 timage = gfits_table_get_Image (&db[0].ftable, &Ntimage, &db[0].swapped); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/photdbc/src/get_mags.c
r15509 r37067 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/ipp-ops-20130712/Ohana/src/photdbc/src/initialize.c
r33655 r37067 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/ipp-ops-20130712/Ohana/src/photdbc/src/join_stars.c
r29938 r37067 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; … … 57 57 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 58 58 tcoords.Npolyterms = 0; 59 strcpy (tcoords.ctype, " RA---TAN");59 strcpy (tcoords.ctype, "DEC--TAN"); 60 60 61 61 /* project & sort coordinates in local linear frame */ … … 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/ipp-ops-20130712/Ohana/src/photdbc/src/make_subcatalog.c
r31635 r37067 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/ipp-ops-20130712/Ohana/src/photdbc/src/photdbc.c
r33655 r37067 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/ipp-ops-20130712/Ohana/src/photdbc/src/photdbc_catalogs.c
r33963 r37067 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/ipp-ops-20130712/Ohana/src/relastro/Makefile
r35416 r37067 69 69 $(SRC)/resort_catalog.$(ARCH).o \ 70 70 $(SRC)/BrightCatalog.$(ARCH).o \ 71 $(SRC)/assign_images.$(ARCH).o \ 72 $(SRC)/launch_region_hosts.$(ARCH).o \ 73 $(SRC)/relastro_parallel_images.$(ARCH).o \ 74 $(SRC)/relastro_parallel_regions.$(ARCH).o \ 75 $(SRC)/MeanPosIO.$(ARCH).o \ 76 $(SRC)/share_mean_pos.$(ARCH).o \ 77 $(SRC)/share_images_pos.$(ARCH).o \ 78 $(SRC)/ImagePosIO.$(ARCH).o \ 79 $(SRC)/ImageTable.$(ARCH).o \ 80 $(SRC)/markObjects.$(ARCH).o \ 81 $(SRC)/indexCatalogs.$(ARCH).o \ 82 $(SRC)/syncfile.$(ARCH).o \ 71 83 $(SRC)/relastroVisual.$(ARCH).o 72 84 … … 115 127 $(SRC)/plotstuff.$(ARCH).o \ 116 128 $(SRC)/relastroVisual.$(ARCH).o \ 129 $(SRC)/syncfile.$(ARCH).o \ 117 130 $(SRC)/BrightCatalog.$(ARCH).o 118 131 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/include/relastro.h
r35763 r37067 20 20 typedef enum {FIT_NONE, FIT_AVERAGE, FIT_PM_ONLY, FIT_PAR_ONLY, FIT_PM_AND_PAR} FitMode; 21 21 22 typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS, TARGET_HIGH_SPEED, TARGET_MERGE_SOURCE, TARGET_UPDATE_OBJECTS, TARGET_UPDATE_OFFSETS, TARGET_LOAD_OBJECTS, TARGET_HPM} FitTarget; 22 typedef enum {OP_NONE, OP_IMAGES, OP_HIGH_SPEED, OP_MERGE_SOURCE, OP_UPDATE_OBJECTS, OP_UPDATE_OFFSETS, OP_LOAD_OBJECTS, OP_HPM, OP_PARALLEL_REGIONS, OP_PARALLEL_IMAGES} RelastroOp; 23 24 typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS} FitTarget; 23 25 24 26 typedef enum { … … 30 32 MARK_BIG_OFFSET = 0x0010, 31 33 } MeasurementMask; 34 35 typedef struct { 36 float R; 37 float D; 38 unsigned int objID; 39 unsigned int catID; 40 } MeanPos; 41 42 typedef struct { 43 Coords coords; 44 float dXpixSys; 45 float dYpixSys; 46 unsigned int imageID; 47 int nFitAstrom; 48 int flags; 49 } ImagePos; 32 50 33 51 typedef struct { … … 56 74 double L, M; /* Focal Plane - pixels */ 57 75 double X, Y; /* Chip Coords - pixels */ 58 double Mag; 59 double dMag; 60 double dPos; 76 float Mag; 77 float ColorBlue; 78 float ColorRed; 79 float dMag; 80 float dPos; 61 81 int mask; 62 82 int Nmeas; … … 93 113 unsigned int start; 94 114 unsigned int stop; 115 off_t myImage; 95 116 float Mcal; 96 117 float dMcal; … … 113 134 } StatType; 114 135 115 # define MARKTIME(MSG,...) { \116 float dtime; \117 gettimeofday (&stop, (void *) NULL); \118 dtime = DTIME (stop, start); \119 fprintf (stderr, MSG, __VA_ARGS__); }120 121 136 /* global variables set in parameter file */ 122 137 # define DVO_MAX_PATH 1024 … … 129 144 char SKY_TABLE[DVO_MAX_PATH]; 130 145 int SKY_DEPTH; /** XXX EAM : depth of catalog tables, fix usage */ 146 147 // globals for parallel region operations 148 char *REGION_FILE; 149 char *IMAGE_TABLE; 150 int REGION_HOST_ID; 151 int PARALLEL_REGIONS_MANUAL; 131 152 132 153 int HOST_ID; … … 179 200 double MaxDensityValue; 180 201 181 char *PHOTCODE_KEEP_LIST, *PHOTCODE_SKIP_LIST ;182 int NphotcodesKeep, NphotcodesSkip ;183 PhotCode **photcodesKeep, **photcodesSkip ;202 char *PHOTCODE_KEEP_LIST, *PHOTCODE_SKIP_LIST, *PHOTCODE_RESET_LIST; 203 int NphotcodesKeep, NphotcodesSkip, NphotcodesReset; 204 PhotCode **photcodesKeep, **photcodesSkip, **photcodesReset; 184 205 185 206 char *PHOTCODE_A_LIST, *PHOTCODE_B_LIST; … … 189 210 SkyRegionSelection SELECTION; 190 211 212 char *DCR_BLUE_COLOR_POS, *DCR_BLUE_COLOR_NEG; 213 PhotCode *DCR_BLUE_PHOTCODE_POS, *DCR_BLUE_PHOTCODE_NEG; 214 int DCR_BLUE_NSEC_POS, DCR_BLUE_NSEC_NEG; 215 216 char *DCR_RED_COLOR_POS, *DCR_RED_COLOR_NEG; 217 PhotCode *DCR_RED_PHOTCODE_POS, *DCR_RED_PHOTCODE_NEG; 218 int DCR_RED_NSEC_POS, DCR_RED_NSEC_NEG; 219 191 220 int ImagSelect; 192 221 double ImagMin, ImagMax; … … 206 235 int USE_BASIC_CHECK; 207 236 237 int ExcludeBogus; 238 double ExcludeBogusRadius; 239 208 240 FitMode FIT_MODE; 209 241 242 RelastroOp RELASTRO_OP; 210 243 FitTarget FIT_TARGET; 211 244 … … 278 311 int liststats PROTO((double *value, double *dvalue, int N, StatType *stats)); 279 312 int liststats_pos PROTO((double *value, double *dvalue, int N, StatType *stats, int XVERB)); 280 Catalog *load_catalogs PROTO((SkyList *skylist, int *Ncatalog, int subselect, int hostID, char *hostpath ));313 Catalog *load_catalogs PROTO((SkyList *skylist, int *Ncatalog, int subselect, int hostID, char *hostpath, char *syncfile)); 281 314 int load_images PROTO((FITS_DB *db, SkyList *skylist, int UseFullOverlap)); 282 315 Image *select_images PROTO((SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage, int UseFullOverlap)); … … 388 421 int setMeanR (double ra_fit, MeasureTiny *measure, Average *average, SecFilt *secfilt); 389 422 int setMeanD (double dec_fit, MeasureTiny *measure, Average *average, SecFilt *secfilt); 423 double getMeanR_Big (Measure *measure, Average *average, SecFilt *secfilt); 424 double getMeanD_Big (Measure *measure, Average *average, SecFilt *secfilt); 390 425 int setMeanR_Big (double ra_fit, Measure *measure, Average *average, SecFilt *secfilt); 391 426 int setMeanD_Big (double dec_fit, Measure *measure, Average *average, SecFilt *secfilt); … … 450 485 int hpm_catalogs_parallel (SkyList *skylist); 451 486 int hpm_objects (SkyRegion *region, Catalog *catalog); 487 488 int strextend (char *input, char *format,...); 489 int launch_region_hosts (RegionHostTable *regionHosts); 490 491 int assign_images (FITS_DB *db, RegionHostTable *regionHosts); 492 int select_images_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage); 493 int calculate_image_bounds (Image *image, double *rmin, double *rmax, double *dmin, double *dmax, double Rmid); 494 int calculate_host_image_bounds (RegionHostTable *regionHosts); 495 int find_host_for_coords (RegionHostTable *regionHosts, double Rc, double Dc); 496 497 int relastro_parallel_regions (); 498 int relastro_parallel_images (); 499 500 char *make_filename (char *dirname, char *hostname, int hostID, char *tailname); 501 int check_sync_file (char *filename, int nloop); 502 int clear_sync_file (char *filename); 503 int update_sync_file (char *filename, int nloop); 504 505 int share_mean_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 506 int slurp_mean_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 507 int set_mean_pos (MeanPos *meanpos, Average *average); 508 MeanPos *merge_mean_pos (MeanPos *target, int *ntarget, MeanPos *source, int Nsource); 509 510 int MeanPosSave(char *filename, MeanPos *meanpos, off_t Nmeanpos); 511 MeanPos *MeanPosLoad(char *filename, off_t *nmeanpos); 512 513 int indexCatalogs (Catalog *catalog, int Ncatalog); 514 int catID_and_objID_to_seq (int catID, int objID, int *catSeq, off_t *objSeq); 515 516 int markObjects (Catalog *catalog, int Ncatalog); 517 518 int ImagePosSave(char *filename, ImagePos *image_pos, off_t Nimage_pos); 519 ImagePos *ImagePosLoad(char *filename, off_t *nimage_pos); 520 521 int share_image_pos (RegionHostTable *regionHosts, int nloop); 522 int slurp_image_pos (RegionHostTable *regionHosts, int nloop); 523 ImagePos *merge_image_pos (ImagePos *target, int *ntarget, ImagePos *source, int Nsource); 524 int set_image_pos (ImagePos *image_pos, Image *image); 525 526 Image *ImageTableLoad(char *filename, off_t *nimage); 527 int ImageTableSave (char *filename, Image *images, off_t Nimages); 528 int select_mosaics_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage); 529 530 float getColorBlue (off_t meas, int cat); 531 float getColorRed (off_t meas, int cat); 532 533 int strextend (char *input, char *format,...); 534 535 int areImagesLoaded (); 536 int areImagesMatched (); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/src
- Property svn:mergeinfo deleted
-
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/src/BrightCatalog.c
r35105 r37067 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/ipp-ops-20130712/Ohana/src/relastro/src/ConfigInit.c
r35105 r37067 18 18 if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file); 19 19 20 GetConfig (config, "RELASTRO_SIGMA_LIM", "%lf", 0, &SIGMA_LIM); // exclude measurements on this basis 21 GetConfig (config, "RELASTRO_SRC_MEAS_TOOFEW", "%d", 0, &SRC_MEAS_TOOFEW); 20 // set defaults for all of these if they are not used by parallel / remote clients 21 if (!ScanConfig (config, "RELASTRO_SIGMA_LIM", "%lf", 0, &SIGMA_LIM)) SIGMA_LIM = 0.01; 22 if (!ScanConfig (config, "RELASTRO_SRC_MEAS_TOOFEW", "%d", 0, &SRC_MEAS_TOOFEW)) SRC_MEAS_TOOFEW = 3; 22 23 23 24 if (!ScanConfig (config, "RELASTRO_IMFIT_CLIP_NITER", "%d", 0, &IMFIT_CLIP_NITER)) IMFIT_CLIP_NITER = 3; … … 25 26 if (!ScanConfig (config, "RELASTRO_IMFIT_SYS_SIGMA_LIM", "%lf", 0, &IMFIT_SYS_SIGMA_LIM)) IMFIT_SYS_SIGMA_LIM = 0.01; 26 27 27 GetConfig (config, "PM_DT_MIN", "%lf", 0, &PM_DT_MIN); 28 GetConfig (config, "PM_TOOFEW", "%d", 0, &PM_TOOFEW); 29 GetConfig (config, "POS_TOOFEW", "%d", 0, &POS_TOOFEW); 28 if (!ScanConfig (config, "PM_DT_MIN", "%lf", 0, &PM_DT_MIN)) PM_DT_MIN = 0.25; 29 if (!ScanConfig (config, "PM_TOOFEW", "%d", 0, &PM_TOOFEW)) PM_TOOFEW = 4; 30 if (!ScanConfig (config, "POS_TOOFEW", "%d", 0, &POS_TOOFEW)) POS_TOOFEW = 1; 31 if (!ScanConfig (config, "PAR_FACTOR_MIN", "%lf", 0, &PAR_FACTOR_MIN)) PAR_FACTOR_MIN = 0.2; 32 if (!ScanConfig (config, "RELASTRO_MAP_NX", "%d", 0, &NX_MAP)) NX_MAP = 5; 33 if (!ScanConfig (config, "RELASTRO_MAP_NY", "%d", 0, &NY_MAP)) NY_MAP = 5; 34 if (!ScanConfig (config, "RELASTRO_DPOS_MAX", "%lf", 0, &DPOS_MAX)) DPOS_MAX = 6.0; 35 if (!ScanConfig (config, "ADDSTAR_RADIUS", "%lf", 0, &ADDSTAR_RADIUS)) ADDSTAR_RADIUS = 1.0; 30 36 31 GetConfig (config, "PAR_FACTOR_MIN", "%lf", 0, &PAR_FACTOR_MIN); 32 33 GetConfig (config, "RELASTRO_MAP_NX", "%d", 0, &NX_MAP); 34 GetConfig (config, "RELASTRO_MAP_NY", "%d", 0, &NY_MAP); 35 GetConfig (config, "RELASTRO_DPOS_MAX", "%lf", 0, &DPOS_MAX); 36 GetConfig (config, "ADDSTAR_RADIUS", "%lf", 0, &ADDSTAR_RADIUS); 37 38 if (!ScanConfig (config, "USE_FIXED_PIXCOORDS", "%d", 0, &USE_FIXED_PIXCOORDS)) { 39 USE_FIXED_PIXCOORDS = FALSE; 40 } 37 if (!ScanConfig (config, "USE_FIXED_PIXCOORDS", "%d", 0, &USE_FIXED_PIXCOORDS)) USE_FIXED_PIXCOORDS = FALSE; 41 38 42 39 // force CATDIR to be absolute (so parallel mode will work) … … 56 53 sprintf (ImageCat, "%s/Images.dat", CATDIR); 57 54 58 if (!ScanConfig (config, "SKY_DEPTH", "%d", 0, &SKY_DEPTH)) { 59 SKY_DEPTH = 2; 60 } 61 if (!ScanConfig (config, "SKY_TABLE", "%s", 0, SKY_TABLE)) { 62 SKY_TABLE[0] = 0; 63 } 55 if (!ScanConfig (config, "SKY_DEPTH", "%d", 0, &SKY_DEPTH)) SKY_DEPTH = 2; 56 if (!ScanConfig (config, "SKY_TABLE", "%s", 0, SKY_TABLE)) SKY_TABLE[0] = 0; 64 57 65 58 if (*CATMODE == 0) strcpy (CATMODE, "RAW"); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/src/FitChip.c
r33652 r37067 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/ipp-ops-20130712/Ohana/src/relastro/src/GetAstromError.c
r33652 r37067 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/ipp-ops-20130712/Ohana/src/relastro/src/ImageOps.c
r35763 r37067 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) { … … 226 238 Measure *measureBig = &catalog[cat].measure[meas]; 227 239 int TESTPT = FALSE; 228 TESTPT |= (measureBig->imageID == CAT_ID_SRC) && (measureBig->detID == OBJ_ID_SRC);229 TESTPT |= (measureBig->imageID == CAT_ID_DST) && (measureBig->detID == OBJ_ID_DST);240 TESTPT |= CAT_ID_SRC && OBJ_ID_SRC && (measureBig->imageID == CAT_ID_SRC) && (measureBig->detID == OBJ_ID_SRC); 241 TESTPT |= CAT_ID_DST && OBJ_ID_DST && (measureBig->imageID == CAT_ID_DST) && (measureBig->detID == OBJ_ID_DST); 230 242 if (TESTPT) { 231 243 fprintf (stderr, "got test det\n"); … … 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; … … 462 492 int TESTPT = FALSE; 463 493 464 TESTPT |= (measure->imageID == CAT_ID_SRC) && (measure->detID == OBJ_ID_SRC);465 TESTPT |= (measure->imageID == CAT_ID_DST) && (measure->detID == OBJ_ID_DST);494 TESTPT |= CAT_ID_SRC && OBJ_ID_SRC && (measure->imageID == CAT_ID_SRC) && (measure->detID == OBJ_ID_SRC); 495 TESTPT |= CAT_ID_DST && OBJ_ID_DST && (measure->imageID == CAT_ID_DST) && (measure->detID == OBJ_ID_DST); 466 496 if (TESTPT) { 467 497 fprintf (stderr, "got test det\n"); 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/ipp-ops-20130712/Ohana/src/relastro/src/MosaicOps.c
r27581 r37067 11 11 12 12 // list of mosaic associated with each image 13 static off_t Nmosaic_for_images; // number of images (for off_ternal checks)13 static off_t Nmosaic_for_images; // number of images (for internal checks) 14 14 static off_t *mosaic_for_images; // array of: image -> mosaic 15 15 … … 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 mosaic[Nmosaic].myImage = i; 107 108 108 109 // init the mosaic_own_images array data … … 135 136 ALLOCATE (mosaic_for_images, off_t, Nmosaic_for_images); 136 137 138 // emit an error if we miss mosaics, but stop if we miss too many 139 int NmissMosaic = 0; 140 int NtestMosaic = 0; 141 137 142 /* now assign the WRP images to these mosaics */ 138 143 for (i = 0; i < Nimage; i++) { … … 140 145 141 146 if (strcmp(&image[i].coords.ctype[4], "-WRP")) continue; 147 NtestMosaic ++; 142 148 143 149 /* set image time range */ … … 147 153 Nmos = getMosaicByTimes (start, stop, startMos, stopMos, indexMos); 148 154 if (Nmos == -1) { 149 fprintf (stderr, "cannot match mosaic for %s\n", image[i].name); 155 if (NmissMosaic < 1000) { 156 fprintf (stderr, "cannot match mosaic for %s\n", image[i].name); 157 } 158 NmissMosaic ++; 150 159 continue; 151 160 } … … 164 173 } 165 174 175 fprintf (stderr, "mosaic matching : %d of possible %d failed to match\n", NmissMosaic, NtestMosaic); 176 if (NmissMosaic > 0.5*NtestMosaic) { 177 fprintf (stderr, "serious problem with mosaic matching\n"); 178 exit (5); 179 } 180 166 181 free (startMos); 167 182 free (stopMos); … … 250 265 if (im >= Nmosaic_for_images) abort(); 251 266 252 // search for the mosaic that 267 // search for the mosaic that matches this image 253 268 mos = mosaic_for_images[im]; 254 269 if (mos < 0) return NULL; … … 256 271 return &mosaic[mos]; 257 272 } 273 274 // extend each host image table to include the mosaic 'images' needed by the host 275 int select_mosaics_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage) { 276 277 int i; 278 off_t j; 279 char *mosaicUsed; 280 281 ALLOCATE (mosaicUsed, char, Nmosaic); 282 283 // we need to add the mosaics to each of the region hosts lists of images 284 for (i = 0; i < regionHosts->Nhosts; i++) { 285 286 int Nadd = 0; 287 int NADD = 100; 288 off_t *addMosaic = NULL; 289 ALLOCATE (addMosaic, off_t, NADD); 290 291 // reset the mosaicUsed flags (valid only for this host) 292 memset (mosaicUsed, 0, Nmosaic * sizeof(char)); 293 294 RegionHostInfo *host = ®ionHosts->hosts[i]; 295 296 // find the mosaics associated with a given 297 for (j = 0; j < host->Nimage; j++) { 298 299 int im = host->imseq[j]; 300 301 if (im < 0) abort(); 302 if (im >= Nmosaic_for_images) abort(); 303 304 // search for the mosaic that matches this image (skip unmatched images) 305 off_t mos = mosaic_for_images[im]; 306 if (mos < 0) continue; 307 308 if (mosaicUsed[mos]) continue; 309 310 mosaicUsed[mos] = TRUE; 311 addMosaic[Nadd] = mos; 312 Nadd ++; 313 314 CHECK_REALLOCATE (addMosaic, off_t, NADD, Nadd, 100); 315 } 316 317 REALLOCATE (host->image, Image, host->Nimage + Nadd); 318 319 for (j = 0; j < Nadd; j++) { 320 off_t mos = addMosaic[j]; 321 off_t mos_im = mosaic[mos].myImage; 322 323 host->image[host->Nimage + j] = image[mos_im]; 324 } 325 326 host->Nimage += Nadd; 327 } 328 return TRUE; 329 } 330 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/src/Shutdown.c
r12332 r37067 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/ipp-ops-20130712/Ohana/src/relastro/src/StarMaps.c
r35105 r37067 59 59 off_t i, N, Nimages; 60 60 int xbin, ybin; 61 struct timeval start, stop;62 61 63 gettimeofday (&start, (void *) NULL);62 INITTIME; 64 63 65 64 // Images *images = getimages(&Nimages, NULL); return value ignored -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/src/UpdateObjectOffsets.c
r35763 r37067 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/ipp-ops-20130712/Ohana/src/relastro/src/UpdateObjects.c
r35763 r37067 1 1 # include "relastro.h" 2 2 3 static off_t Nmax;3 static off_t Nmax; 4 4 static double *X, *dX; 5 5 static double *Y, *dY; … … 10 10 static double *T; 11 11 static double *dT; 12 static double *C_blue; 13 static double *C_red; 12 14 13 15 void initObjectData (Catalog *catalog, int Ncatalog) { … … 36 38 ALLOCATE (pX, double, MAX (1, Nmax)); 37 39 ALLOCATE (pY, double, MAX (1, Nmax)); 40 41 ALLOCATE (C_blue, double, MAX (1, Nmax)); 42 ALLOCATE (C_red, double, MAX (1, Nmax)); 43 } 44 45 void freeObjectData () { 46 47 free (R); 48 free (D); 49 free (T); 50 free (X); 51 free (Y); 52 53 free (dR); 54 free (dD); 55 free (dT); 56 free (dX); 57 free (dY); 58 59 free (pX); 60 free (pY); 61 62 free (C_blue); 63 free (C_red); 38 64 } 39 65 … … 43 69 44 70 off_t j, k, m; 45 int i, N, N secfilt, mode, result, status, XVERB;71 int i, N, NcBlue, NcRed, Nsecfilt, mode, result, status, XVERB; 46 72 StatType statsR, statsD; 47 73 Coords coords; … … 57 83 memset (&fitPAR, 0, sizeof(fitPAR)); 58 84 initObjectData (catalog, Ncatalog); 85 86 int setRefColor = areImagesMatched(); 59 87 60 88 /* project coordinates to a plane centered on the object with units of arcsec */ … … 67 95 coords.pc1_2 = coords.pc2_1 = 0.0; 68 96 coords.Npolyterms = 1; 69 strcpy (coords.ctype, " RA---SIN");97 strcpy (coords.ctype, "DEC--SIN"); 70 98 71 99 XVERB = FALSE; … … 94 122 fitPAR.chisq = NAN; 95 123 124 // if we fail to fit the astrometry for some reason, we need to set/reset these 125 catalog[i].average[j].flags |= ID_STAR_NO_ASTROM; 126 catalog[i].average[j].ChiSqAve = NAN; 127 catalog[i].average[j].ChiSqPM = NAN; 128 catalog[i].average[j].ChiSqPar = NAN; 129 catalog[i].average[j].Npos = 0; 130 96 131 if (catalog[i].average[j].Nmeasure == 0) { 97 continue; 98 } 99 132 continue; 133 } 134 135 NcBlue = 0; 136 NcRed = 0; 100 137 N = 0; 101 138 m = catalog[i].average[j].measureOffset; … … 116 153 char *date = ohana_sec_to_date (measure[k].t); 117 154 int dbFlagsBig = measureBig ? measureBig[k].dbFlags : 0; 118 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);155 fprintf (stderr, OFF_T_FMT" %f %f %s : 0x%08x : 0x%08x\n", k, measure[k].R, measure[k].D, date, measure[k].dbFlags, dbFlagsBig); 119 156 free (date); 120 157 } 158 159 // reset the bit to note that a detection was used (or not) 160 measure[k].dbFlags &= ~ID_MEAS_USED_OBJ; 161 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; } 121 162 122 163 // does the measurement pass the supplied filtering constraints? 123 164 // MeasFilterTestTiny does not test psfQF 165 // exclude bad detections based on: photcodes, psfQF, time range, photflags & astromBadMask, mag_inst 124 166 int keepMeasure = measureBig ? MeasFilterTest(&measureBig[k], FALSE) : MeasFilterTestTiny(&measure[k], FALSE); 125 167 if (!keepMeasure) { 126 measure[k].dbFlags &= ~ID_MEAS_USED_OBJ;127 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; }128 168 continue; 129 169 } 130 170 171 // mark (as POOR) any measurements which are deviant from the mean by > ExcludeBogusRadius 172 if (ExcludeBogus) { 173 double Ri = getMeanR (&measure[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 174 double Di = getMeanD (&measure[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 175 coords.crval1 = catalog[i].average[j].R; 176 coords.crval2 = catalog[i].average[j].D; 177 double Xi, Yi; 178 RD_to_XY (&Xi, &Yi, Ri, Di, &coords); 179 double radius = hypot(Xi, Yi); 180 if (radius > ExcludeBogusRadius) { 181 measure[k].dbFlags |= ID_MEAS_POOR_ASTROM; 182 if (measureBig) { measureBig[k].dbFlags |= ID_MEAS_POOR_ASTROM; } 183 continue; 184 } 185 measure[k].dbFlags &= ~ID_MEAS_POOR_ASTROM; 186 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_POOR_ASTROM; } 187 } 188 131 189 // outlier rejection 132 if (FlagOutlier && (measure[k].dbFlags & ID_MEAS_POOR_ASTROM)) { 133 measure[k].dbFlags &= ~ID_MEAS_USED_OBJ; 134 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; } 190 if (FALSE && FlagOutlier && (measure[k].dbFlags & ID_MEAS_POOR_ASTROM)) { 135 191 continue; 136 192 } 137 138 measure[k].dbFlags |= ID_MEAS_USED_OBJ;139 if (measureBig) { measureBig[k].dbFlags |= ID_MEAS_USED_OBJ; }140 193 141 194 R[N] = getMeanR (&measure[k], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); … … 152 205 // allow a given photcode or measurement to be 153 206 // ignored if the error is NAN (for photcode, set astromErrSys to NaN) 154 if (isnan(dX[N])) { 155 measure[k].dbFlags &= ~ID_MEAS_USED_OBJ; 156 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; } 157 continue; 158 } 159 if (isnan(dY[N])) { 160 measure[k].dbFlags &= ~ID_MEAS_USED_OBJ; 161 if (measureBig) { measureBig[k].dbFlags &= ~ID_MEAS_USED_OBJ; } 162 continue; 163 } 207 if (isnan(dX[N])) continue; 208 if (isnan(dY[N])) continue; 164 209 165 210 // add systematic error in quadrature, if desired … … 183 228 dD[N] = dY[N] / 3600.0; 184 229 230 if (setRefColor) { 231 float colorBlue = getColorBlue (m+k, i); 232 if (!isnan(colorBlue)) { 233 C_blue[NcBlue] = colorBlue; 234 NcBlue++; 235 } 236 float colorRed = getColorRed (m+k, i); 237 if (!isnan(colorRed)) { 238 C_red[NcRed] = colorRed; 239 NcRed++; 240 } 241 } 242 243 measure[k].dbFlags |= ID_MEAS_USED_OBJ; 244 if (measureBig) { measureBig[k].dbFlags |= ID_MEAS_USED_OBJ; } 245 185 246 N++; 186 } 247 } // loop over measurements : catalog[i].average[j].Nmeasure 187 248 188 249 // if we have too few good detections for the desired fit, or too limited a 189 250 // baseline, use a fit with fewer parameters. XXX if we have too few measurements 190 251 // for even the average position, consider including the lower-quality detections? 191 192 catalog[i].average[j].flags &= ~ID_STAR_NO_ASTROM;193 252 194 253 // find Tmin & Tmax from the list of accepted measurements … … 205 264 if (((mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) && (N <= PM_TOOFEW)) mode = FIT_AVERAGE; 206 265 207 if ( FIT_TARGET == TARGET_HIGH_SPEED) {266 if (RELASTRO_OP == OP_HIGH_SPEED) { 208 267 Tmean = 0.5*(Tmax - Tmin); 209 268 } else { … … 213 272 // too few measurements for average position (require 2 values) 214 273 if (N < SRC_MEAS_TOOFEW) { 215 // XXX need to define PHOTOM and ASTROM object flags216 // XXX reset the average value fields?217 catalog[i].average[j].flags |= ID_STAR_NO_ASTROM;218 catalog[i].average[j].ChiSqAve = NAN;219 catalog[i].average[j].ChiSqPM = NAN;220 catalog[i].average[j].ChiSqPar = NAN;221 274 if (N < 2) continue; 222 275 } … … 250 303 catalog[i].average[j].flags |= ID_STAR_FIT_PM; 251 304 Npm ++; 305 306 // XXX a hard-wired hack... 307 if ((fabs(fitPM.uR) > 2.0) || (fabs(fitPM.uD) > 2.0)) { 308 mode = FIT_AVERAGE; 309 catalog[i].average[j].flags |= ID_STAR_BAD_PM; 310 } 252 311 } 253 312 254 313 if (mode == FIT_PM_AND_PAR) { 255 // fprintf (stderr, "parallax fitting is still untested (%s, %d)\n", __FILE__, __LINE__);256 257 314 float pXmin = +2.0; 258 315 float pXmax = -2.0; … … 278 335 catalog[i].average[j].flags |= ID_STAR_FIT_PAR; 279 336 Npar ++; 337 338 // XXX a hard-wired hack... 339 if ((fabs(fitPAR.uR) > 2.0) || (fabs(fitPAR.uD) > 2.0)) { 340 mode = FIT_AVERAGE; 341 catalog[i].average[j].flags |= ID_STAR_BAD_PM; 342 } 280 343 } else { 281 344 // need to set mode = FIT_PM_ONLY if we do not fit for parallax … … 303 366 catalog[i].average[j].flags |= ID_STAR_FIT_AVE; 304 367 Nave ++; 368 } 369 370 if (setRefColor) { 371 float colorMedian; 372 dsort (C_blue, NcBlue); 373 colorMedian = (NcBlue > 0) ? C_blue[(int)(0.5*NcBlue)] : NAN; 374 catalog[i].average[j].refColorBlue = colorMedian; 375 dsort (C_red, NcRed); 376 colorMedian = (NcRed > 0) ? C_red[(int)(0.5*NcRed)] : NAN; 377 catalog[i].average[j].refColorRed = colorMedian; 305 378 } 306 379 … … 393 466 catalog[i].average[j].Trange = (Trange * 86400 * 365.25); 394 467 catalog[i].average[j].Npos = fit.Nfit; 468 469 // unset the NO_ASTROM bit (not(NO_ASTROM) == HAVE_ASTROM) 470 catalog[i].average[j].flags &= ~ID_STAR_NO_ASTROM; 471 395 472 if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f) pm=(%f %f) chisq=(%f, %f, %f)\n", 396 473 catalog[i].average[j].R, … … 412 489 } 413 490 491 freeObjectData (); 492 414 493 if (VERBOSE) fprintf (stderr, "fitted "OFF_T_FMT" objects ("OFF_T_FMT" ave, "OFF_T_FMT" pm, "OFF_T_FMT" par), skipped "OFF_T_FMT", "OFF_T_FMT" have too large an offset\n", (NaveSum + NpmSum + NparSum), NaveSum, NpmSum, NparSum, NskipSum, NoffSum); 415 494 return (TRUE); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/src/args.c
r35763 r37067 13 13 /* possible operations */ 14 14 FIT_TARGET = TARGET_NONE; 15 RELASTRO_OP = OP_NONE; 15 16 FIT_MODE = FIT_AVERAGE; 16 17 … … 21 22 if (N > argc - 6) usage_merge_source(); 22 23 if (strcmp(argv[N+3], "into")) usage_merge_source(); 23 FIT_TARGET = TARGET_MERGE_SOURCE;24 RELASTRO_OP = OP_MERGE_SOURCE; 24 25 remove_argument (N, &argc, argv); 25 26 OBJ_ID_SRC = strtol(argv[N], &endptr, 0); … … 43 44 if ((N = get_argument (argc, argv, "-update-objects"))) { 44 45 remove_argument (N, &argc, argv); 45 FIT_TARGET = TARGET_UPDATE_OBJECTS;46 RELASTRO_OP = OP_UPDATE_OBJECTS; 46 47 } 47 48 48 49 if ((N = get_argument (argc, argv, "-update-offsets"))) { 49 50 remove_argument (N, &argc, argv); 50 FIT_TARGET = TARGET_UPDATE_OFFSETS; 51 RELASTRO_OP = OP_UPDATE_OFFSETS; 52 } 53 54 // elements needed for parallel regions / parallel images 55 REGION_FILE = NULL; 56 if ((N = get_argument (argc, argv, "-region-hosts"))) { 57 remove_argument (N, &argc, argv); 58 REGION_FILE = strcreate (argv[N]); 59 remove_argument (N, &argc, argv); 60 } 61 62 REGION_HOST_ID = 0; 63 if ((N = get_argument (argc, argv, "-region-hostID"))) { 64 remove_argument (N, &argc, argv); 65 REGION_HOST_ID = atoi (argv[N]); 66 remove_argument (N, &argc, argv); 67 } 68 69 IMAGE_TABLE = NULL; 70 if ((N = get_argument (argc, argv, "-parallel-images"))) { 71 remove_argument (N, &argc, argv); 72 RELASTRO_OP = OP_PARALLEL_IMAGES; 73 if (N >= argc) usage(); 74 IMAGE_TABLE = strcreate (argv[N]); 75 remove_argument (N, &argc, argv); 76 if (!REGION_FILE) usage(); 77 } 78 79 if ((N = get_argument (argc, argv, "-images"))) { 80 remove_argument (N, &argc, argv); 81 RELASTRO_OP = OP_IMAGES; 82 } 83 84 PARALLEL_REGIONS_MANUAL = FALSE; 85 if ((N = get_argument (argc, argv, "-parallel-regions"))) { 86 remove_argument (N, &argc, argv); 87 RELASTRO_OP = OP_PARALLEL_REGIONS; 88 if (!REGION_FILE) usage(); 89 if ((N = get_argument (argc, argv, "-parallel-regions-manual"))) { 90 remove_argument (N, &argc, argv); 91 PARALLEL_REGIONS_MANUAL = TRUE; 92 } 51 93 } 52 94 … … 90 132 // XXX include a parallax / no-parallax option 91 133 if (N >= argc - 4) usage(); 92 FIT_TARGET = TARGET_HIGH_SPEED;134 RELASTRO_OP = OP_HIGH_SPEED; 93 135 remove_argument (N, &argc, argv); 94 136 PHOTCODE_A_LIST = strcreate(argv[N]); … … 104 146 if ((N = get_argument (argc, argv, "-hpm"))) { 105 147 if (N >= argc - 2) usage(); 106 FIT_TARGET = TARGET_HPM;148 RELASTRO_OP = OP_HPM; 107 149 remove_argument (N, &argc, argv); 108 150 RADIUS = atof(argv[N]); … … 116 158 remove_argument (N, &argc, argv); 117 159 PARALLEL_OUTPUT = TRUE; 118 if (( FIT_TARGET != TARGET_HIGH_SPEED) && (FIT_TARGET != TARGET_HPM)) {160 if ((RELASTRO_OP != OP_HIGH_SPEED) && (RELASTRO_OP != OP_HPM)) { 119 161 fprintf (stderr, "-parallel-output only valid for -high-speed or -hpm modes\n"); 120 162 exit (1); … … 137 179 FlagOutlier = FALSE; 138 180 if ((N = get_argument (argc, argv, "-clip"))) { 181 fprintf (stderr, "-clip is currently disabled\n"); 139 182 remove_argument (N, &argc, argv); 140 183 CLIP_THRESH = atof (argv[N]); … … 143 186 } 144 187 145 if (FIT_TARGET == TARGET_NONE) usage(); 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; 195 } 196 197 if (RELASTRO_OP == OP_NONE) usage(); 198 199 if (((RELASTRO_OP == OP_IMAGES) || (RELASTRO_OP == OP_PARALLEL_REGIONS) || (RELASTRO_OP == OP_PARALLEL_IMAGES)) && (FIT_TARGET == TARGET_NONE)) usage(); 146 200 147 201 /* specify portion of the sky : allow default of all sky? */ … … 240 294 } 241 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 242 325 PHOTCODE_KEEP_LIST = NULL; 243 326 if ((N = get_argument (argc, argv, "+photcode"))) { … … 247 330 } 248 331 249 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; 250 335 if ((N = get_argument (argc, argv, "-photcode"))) { 251 336 remove_argument (N, &argc, argv); 252 char * tmp1= strcreate(argv[N]);253 254 int Ntotal = strlen(tmp1) + strlen(PHOTCODE_SKIP_LIST) + 5;255 256 char *tmp2 = NULL;257 ALLOCATE (tmp2, char, Ntotal);258 snprintf (tmp2, Ntotal, "%s,%s", PHOTCODE_SKIP_LIST, tmp1);259 260 free (tmp1);261 free (PHOTCODE_SKIP_LIST);262 263 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 } 264 349 remove_argument (N, &argc, argv); 265 350 } … … 427 512 428 513 /* possible operations */ 429 FIT_TARGET= TARGET_NONE;514 RELASTRO_OP = TARGET_NONE; 430 515 FIT_MODE = FIT_AVERAGE; 431 516 … … 437 522 BCATALOG = NULL; 438 523 524 REGION_FILE = NULL; 525 REGION_HOST_ID = 0; 526 IMAGE_TABLE = NULL; 527 PARALLEL_REGIONS_MANUAL = FALSE; 528 439 529 HOST_ID = 0; 440 530 if ((N = get_argument (argc, argv, "-hostID"))) { … … 457 547 BCATALOG = strcreate(argv[N]); 458 548 remove_argument (N, &argc, argv); 459 FIT_TARGET = TARGET_LOAD_OBJECTS;549 RELASTRO_OP = OP_LOAD_OBJECTS; 460 550 } 461 551 462 552 if ((N = get_argument (argc, argv, "-update-objects"))) { 463 553 remove_argument (N, &argc, argv); 464 FIT_TARGET = TARGET_UPDATE_OBJECTS;554 RELASTRO_OP = OP_UPDATE_OBJECTS; 465 555 } 466 556 467 557 if ((N = get_argument (argc, argv, "-update-offsets"))) { 468 558 remove_argument (N, &argc, argv); 469 FIT_TARGET = TARGET_UPDATE_OFFSETS;559 RELASTRO_OP = OP_UPDATE_OFFSETS; 470 560 } 471 561 … … 487 577 // XXX include a parallax / no-parallax option 488 578 if (N >= argc - 5) usage_client(); 489 FIT_TARGET = TARGET_HIGH_SPEED;579 RELASTRO_OP = OP_HIGH_SPEED; 490 580 remove_argument (N, &argc, argv); 491 581 PHOTCODE_A_LIST = strcreate(argv[N]); … … 501 591 if ((N = get_argument (argc, argv, "-hpm"))) { 502 592 if (N >= argc - 3) usage(); 503 FIT_TARGET = TARGET_HPM;593 RELASTRO_OP = OP_HPM; 504 594 remove_argument (N, &argc, argv); 505 595 RADIUS = atof(argv[N]); … … 533 623 FlagOutlier = FALSE; 534 624 if ((N = get_argument (argc, argv, "-clip"))) { 625 fprintf (stderr, "-clip is currently disabled\n"); 535 626 remove_argument (N, &argc, argv); 536 627 CLIP_THRESH = atof (argv[N]); … … 539 630 } 540 631 541 if (FIT_TARGET == TARGET_NONE) usage_client(); 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; 639 } 640 641 if (RELASTRO_OP == OP_NONE) usage_client(); 542 642 543 643 /* specify portion of the sky : allow default of all sky? */ … … 608 708 } 609 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); 734 } 735 610 736 PHOTCODE_KEEP_LIST = NULL; 611 737 if ((N = get_argument (argc, argv, "+photcode"))) { … … 718 844 719 845 void usage () { 720 fprintf (stderr, "ERROR: USAGE: relastro -update-simple [options]\n"); 721 fprintf (stderr, " OR: relastro -update-chips [options]\n"); 722 fprintf (stderr, " OR: relastro -update-mosaic [options]\n"); 846 fprintf (stderr, "ERROR: USAGE: relastro -images -update-simple [options]\n"); 847 fprintf (stderr, " OR: relastro -images -update-chips [options]\n"); 848 fprintf (stderr, " OR: relastro -images -update-mosaic [options]\n"); 849 fprintf (stderr, " OR: relastro -parallel-regions -update-simple [options]\n"); 850 fprintf (stderr, " OR: relastro -parallel-regions -update-chips [options]\n"); 851 fprintf (stderr, " OR: relastro -parallel-regions -update-mosaic [options]\n"); 852 fprintf (stderr, " OR: relastro -parallel-images -update-simple [options]\n"); 853 fprintf (stderr, " OR: relastro -parallel-images -update-chips [options]\n"); 854 fprintf (stderr, " OR: relastro -parallel-images -update-mosaic [options]\n"); 723 855 fprintf (stderr, " OR: relastro -update-objects [options]\n"); 724 856 fprintf (stderr, " OR: relastro -high-speed [options]\n"); … … 806 938 exit (2); 807 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/ipp-ops-20130712/Ohana/src/relastro/src/bcatalog.c
r34429 r37067 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/ipp-ops-20130712/Ohana/src/relastro/src/dvo_astrom_ops.c
r33652 r37067 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/ipp-ops-20130712/Ohana/src/relastro/src/high_speed_objects.c
r35494 r37067 161 161 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 162 162 tcoords.Npolyterms = 1; 163 strcpy (tcoords.ctype, " RA---ARC");163 strcpy (tcoords.ctype, "DEC--ARC"); 164 164 165 165 /* build spatial index (RA sort) referencing input array sequence */ … … 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/ipp-ops-20130712/Ohana/src/relastro/src/hpm_objects.c
r35494 r37067 138 138 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 139 139 tcoords.Npolyterms = 1; 140 strcpy (tcoords.ctype, " RA---ARC");140 strcpy (tcoords.ctype, "DEC--ARC"); 141 141 142 142 /* build spatial index (RA sort) referencing input array sequence */ … … 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/ipp-ops-20130712/Ohana/src/relastro/src/initialize.c
r34429 r37067 6 6 args (argc, argv); 7 7 8 if ( FIT_TARGET == TARGET_MERGE_SOURCE) return;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/ipp-ops-20130712/Ohana/src/relastro/src/load_catalogs.c
r35105 r37067 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) { 125 126 char uniquer[12]; 127 int TIME = time(NULL); 128 int PID = getpid(); 129 snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000); 116 130 117 131 // load the list of hosts … … 131 145 132 146 ALLOCATE (table->hosts[i].results, char, 1024); 133 snprintf (table->hosts[i].results, 1024, "%s/relastro.catalog. subset.dat", table->hosts[i].pathname);147 snprintf (table->hosts[i].results, 1024, "%s/relastro.catalog.%s.dat", table->hosts[i].pathname, uniquer); 134 148 135 149 // options / arguments that can affect relastro_client -load: … … 145 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); 146 160 147 char tmpline[1024]; 148 if (FIT_MODE == FIT_PM_ONLY) { snprintf (tmpline, 1024, "%s -pm", command); strcpy (command, tmpline); } 149 if (FIT_MODE == FIT_PAR_ONLY) { snprintf (tmpline, 1024, "%s -par", command); strcpy (command, tmpline); } 150 if (FIT_MODE == FIT_PM_AND_PAR) { snprintf (tmpline, 1024, "%s -pmpar", command); strcpy (command, tmpline); } 151 152 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 153 if (VERBOSE2) { snprintf (tmpline, 1024, "%s -vv", command); strcpy (command, tmpline); } 154 if (RESET) { snprintf (tmpline, 1024, "%s -reset", command); strcpy (command, tmpline); } 155 if (ImagSelect) { snprintf (tmpline, 1024, "%s -instmag %f %f", command, ImagMin, ImagMax); strcpy (command, tmpline); } 156 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); 157 172 158 if (FlagOutlier) { snprintf (tmpline, 1024, "%s -clip %d", command, CLIP_THRESH); strcpy (command, tmpline); } 159 160 if (USE_FIXED_PIXCOORDS) { snprintf (tmpline, 1024, "%s -D USE_FIXED_PIXCOORDS 1", command); strcpy (command, tmpline); } 161 162 if (PHOTCODE_KEEP_LIST) { snprintf (tmpline, 1024, "%s +photcode %s", command, PHOTCODE_KEEP_LIST); strcpy (command, tmpline); } 163 if (PHOTCODE_SKIP_LIST) { snprintf (tmpline, 1024, "%s -photcode %s", command, PHOTCODE_SKIP_LIST); strcpy (command, tmpline); } 164 if (PhotFlagSelect) { snprintf (tmpline, 1024, "%s +photflags", command); strcpy (command, tmpline); } 165 if (PhotFlagBad) { snprintf (tmpline, 1024, "%s +photflagbad %d", command, PhotFlagBad); strcpy (command, tmpline); } 166 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); 167 186 // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values 168 187 … … 170 189 char *tstart = ohana_sec_to_date (TSTART); 171 190 char *tstop = ohana_sec_to_date (TSTOP); 172 s nprintf (tmpline, 1024, "%s -time %s %s", command, tstart, tstop);191 strextend (command, "-time %s %s", tstart, tstop); 173 192 free (tstart); 174 193 free (tstop); 175 strcpy (command, tmpline);176 194 } 177 195 … … 206 224 } 207 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 208 239 // each host generates a BrightCatalog structure, with the measure, average, etc value 209 240 // loaded into a single set of arrays (of MeasureTiny, AverageTiny, Secfilt). I need to -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/src/load_images.c
r35763 r37067 1 1 # include "relastro.h" 2 3 # define MARKTIME(MSG,...) { \4 float dtime; \5 gettimeofday (&stop, (void *) NULL); \6 dtime = DTIME (stop, start); \7 fprintf (stderr, MSG, __VA_ARGS__); }8 2 9 3 int load_images (FITS_DB *db, SkyList *skylist, int UseFullOverlap) { … … 12 6 off_t Nimage, Nsubset; 13 7 off_t *LineNumber; 14 struct timeval start, stop;15 8 16 gettimeofday (&start, (void *) NULL);9 INITTIME; 17 10 18 11 // convert database table to internal structure … … 35 28 36 29 /* unlock, if we can (else, unlocked below) */ 37 int unlockImages = !UPDATE || ( FIT_TARGET == TARGET_UPDATE_OFFSETS);30 int unlockImages = !UPDATE || (RELASTRO_OP == OP_UPDATE_OFFSETS); 38 31 if (unlockImages) dvo_image_unlock (db); 39 32 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/src/relastro.c
r35763 r37067 10 10 SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch); 11 11 12 switch ( FIT_TARGET) {13 case TARGET_UPDATE_OBJECTS:12 switch (RELASTRO_OP) { 13 case OP_UPDATE_OBJECTS: 14 14 /* the object analysis is a separate process iterating over catalogs */ 15 15 relastro_objects (skylist, 0, NULL); 16 16 exit (0); 17 17 18 case TARGET_HIGH_SPEED:18 case OP_HIGH_SPEED: 19 19 /* high-speed is a 2pt cross-correlation process for linking moving objects (high PM) */ 20 20 high_speed_catalogs (sky, skylist, 0, NULL); 21 21 exit (0); 22 22 23 case TARGET_HPM:23 case OP_HPM: 24 24 hpm_catalogs (sky, skylist, 0, NULL); 25 25 exit (0); 26 26 27 case TARGET_MERGE_SOURCE:27 case OP_MERGE_SOURCE: 28 28 /* a special method to manually merge unlinked detections of sources togther (not parallel) */ 29 29 relastro_merge_source (sky); 30 30 exit (0); 31 31 32 case TARGET_SIMPLE: 33 case TARGET_CHIPS: 34 case TARGET_MOSAICS: 32 case OP_IMAGES: 35 33 relastro_images (skylist); 36 34 exit (0); 37 35 38 case TARGET_UPDATE_OFFSETS:36 case OP_UPDATE_OFFSETS: 39 37 // iterate over catalogs to make detection coordinates consistant 40 38 UpdateObjectOffsets (skylist, 0, NULL); 39 exit (0); 40 41 case OP_PARALLEL_REGIONS: 42 // run image updates in parallel across multiple remote machines 43 relastro_parallel_regions (); 44 exit (0); 45 46 case OP_PARALLEL_IMAGES: 47 // operation on the remote machines in the PARALLEL_REGION mode 48 relastro_parallel_images (); 41 49 exit (0); 42 50 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/src/relastroVisual.c
r31635 r37067 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/ipp-ops-20130712/Ohana/src/relastro/src/relastro_client.c
r35763 r37067 28 28 SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch); 29 29 30 switch ( FIT_TARGET) {30 switch (RELASTRO_OP) { 31 31 32 case TARGET_LOAD_OBJECTS: {32 case OP_LOAD_OBJECTS: { 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 fprintf (stderr, "ERROR loading catalogs from %s\n", CATDIR);38 exit (2);37 fprintf (stderr, "ERROR loading catalogs from %s\n", CATDIR); 38 exit (2); 39 39 } 40 40 BrightCatalog *bcatalog = BrightCatalogMerge (catalog, Ncatalog); 41 41 if (!BrightCatalogSave (BCATALOG, bcatalog)) { 42 fprintf (stderr, "ERROR saving bright catalog from %s\n", CATDIR);43 exit (2);42 fprintf (stderr, "ERROR saving bright catalog from %s\n", CATDIR); 43 exit (2); 44 44 } 45 45 break; 46 46 } 47 47 48 case TARGET_UPDATE_OBJECTS: {48 case OP_UPDATE_OBJECTS: { 49 49 // USAGE: relastro_client -update-objects 50 50 relastro_objects (skylist, HOST_ID, HOSTDIR); … … 52 52 } 53 53 54 case TARGET_HIGH_SPEED: {54 case OP_HIGH_SPEED: { 55 55 // USAGE: relastro_client -high-speed 56 56 high_speed_catalogs (sky, skylist, HOST_ID, HOSTDIR); … … 58 58 } 59 59 60 case TARGET_HPM: {60 case OP_HPM: { 61 61 // USAGE: relastro_client -high-speed 62 62 hpm_catalogs (sky, skylist, HOST_ID, HOSTDIR); … … 64 64 } 65 65 66 // XXX loading the images is fairly costly -- see if we can do an image subset 67 case TARGET_UPDATE_OFFSETS: {66 // XXX loading the images is fairly costly -- see if we can do an image subset? 67 case OP_UPDATE_OFFSETS: { 68 68 FITS_DB db; 69 69 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/src/relastro_images.c
r35763 r37067 6 6 Catalog *catalog; 7 7 FITS_DB db; 8 struct timeval start, stop;9 8 10 gettimeofday (&start, (void *) NULL);9 INITTIME; 11 10 12 11 /* register database handle with shutdown procedure */ … … 29 28 // XXX pass in the image table 30 29 // XXX who carries the image grid? 31 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); 32 34 MARKTIME("load catalog data: %f sec\n", dtime); 35 36 if (photcodesReset) { 37 photcodesKeep = photcodesReset; 38 NphotcodesKeep = NphotcodesReset; 39 } 33 40 34 41 if (Ncatalog == 0) { … … 51 58 // set test points based on the starmap 52 59 createStarMap (catalog, Ncatalog); 60 61 // XXX NOTE : for 2mass reset, photcodesKeep should now limit to 2MASS measurements 53 62 54 63 /* major modes */ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/src/relastro_merge_source.c
r34088 r37067 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/ipp-ops-20130712/Ohana/src/relastro/src/relastro_objects.c
r35763 r37067 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 … … 144 146 // PM_TOOFEW 145 147 // SRC_MEAS_TOOFEW 146 // FIT_TARGET147 148 148 149 char command[1024]; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/src/resort_catalog.c
r34088 r37067 30 30 if (catalog[0].sorted == TRUE) return; 31 31 32 // struct timeval start, stop; 33 // gettimeofday (&start, NULL); 32 // INITTIME; 34 33 35 34 /* internal counters */ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/src/select_images.c
r35763 r37067 15 15 void dsortindex (double *X, off_t *Y, int N); 16 16 off_t getRegionStartByRA (double R, double *Rref, off_t Nregions); 17 18 # define MARKTIME(MSG,...) { \19 float dtime; \20 gettimeofday (&stop, (void *) NULL); \21 dtime = DTIME (stop, start); \22 fprintf (stderr, MSG, __VA_ARGS__); }23 17 24 18 Image *select_images (SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage, int UseFullOverlap) { … … 31 25 Coords tcoords; 32 26 SkyRegionCoords *skycoords; 33 struct timeval start, stop;34 27 35 28 double RmaxSkyRegion, RminSkyRegion, RmidSkyRegion, DminSkyRegion, DmaxSkyRegion; … … 50 43 } 51 44 52 gettimeofday (&start, (void *) NULL);45 INITTIME; 53 46 54 47 // the comparison is made in the catalog local projection. below we set crval1,2 … … 57 50 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 58 51 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 59 strcpy (tcoords.ctype, " RA---TAN");52 strcpy (tcoords.ctype, "DEC--TAN"); 60 53 61 54 ALLOCATE (skycoords, SkyRegionCoords, skylist[0].Nregions); … … 132 125 if (NphotcodesKeep > 0) { 133 126 found = FALSE; 134 // XXX this bit of code excludes DIS mosaics and should be fixed 127 // we have to keep DIS mosaics explicitly (photcode = 0) 128 if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) found = TRUE; 135 129 for (k = 0; (k < NphotcodesKeep) && !found; k++) { 136 130 if (photcodesKeep[k][0].code == timage[i].photcode) found = TRUE; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relastro/src/testparallax.c
r34088 r37067 57 57 coords.pc1_2 = coords.pc2_1 = 0.0; 58 58 coords.Npolyterms = 1; 59 strcpy (coords.ctype, " RA---SIN");59 strcpy (coords.ctype, "DEC--SIN"); 60 60 61 61 // use one point as a local reference -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/Makefile
r35416 r37067 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 \ … … 47 48 $(SRC)/relphot_images.$(ARCH).o \ 48 49 $(SRC)/relphot_objects.$(ARCH).o \ 50 $(SRC)/relphot_parallel_regions.$(ARCH).o \ 51 $(SRC)/relphot_parallel_images.$(ARCH).o \ 49 52 $(SRC)/select_images.$(ARCH).o \ 53 $(SRC)/assign_images.$(ARCH).o \ 54 $(SRC)/launch_region_hosts.$(ARCH).o \ 55 $(SRC)/ImageTable.$(ARCH).o \ 56 $(SRC)/ImageMagIO.$(ARCH).o \ 57 $(SRC)/syncfile.$(ARCH).o \ 58 $(SRC)/share_image_mags.$(ARCH).o \ 59 $(SRC)/share_mean_mags.$(ARCH).o \ 60 $(SRC)/MeanMagIO.$(ARCH).o \ 61 $(SRC)/indexCatalog.$(ARCH).o \ 50 62 $(SRC)/client_logger.$(ARCH).o \ 51 63 $(SRC)/setExclusions.$(ARCH).o \ … … 71 83 $(SRC)/args.$(ARCH).o \ 72 84 $(SRC)/help.$(ARCH).o \ 85 $(SRC)/extra.$(ARCH).o \ 73 86 $(SRC)/synthetic_mags.$(ARCH).o \ 74 87 $(SRC)/plotstuff.$(ARCH).o \ 75 88 $(SRC)/liststats.$(ARCH).o \ 76 89 $(SRC)/initialize.$(ARCH).o \ 90 $(SRC)/syncfile.$(ARCH).o \ 77 91 $(SRC)/load_catalogs.$(ARCH).o \ 78 92 $(SRC)/reload_catalogs.$(ARCH).o \ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/doc/mosaic.txt
r33963 r37067 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/ipp-ops-20130712/Ohana/src/relphot/doc/parallel.txt
r33651 r37067 1 2 2014.02.15 3 4 Nearly done with the relphot mods. some outstanding questions; 5 6 * image vs mosaic? 7 * how do decide which images need to be shared? 8 9 2014.02.14 10 11 more relphot notes: 12 13 * I load the catalogs, with a 14 15 2014.02.12 16 17 I am making progess on the relphot -parallel-regions implementation. some things I need to deal with: 18 19 * assign_images: select mosaics for all images saved for a given host (need to supply them as well) 20 ** I need to decide on the Image / Mosaic split. If I am calibrating by image, then the image center defines ownership 21 ** if I am calibrating by exposure, then the mosaic center must define ownership 22 o determine SkyList covering the images for region host 23 o tag detections and objects which I own or do not own 24 o ImageOps.c / matchImage matches detections to images and needs to handle mine / not mine cases 25 o ditto for matchMosaics 26 o load_catalogs : I need to make my requested catalogs unique (just add uniquer to load_catalogs.c:130 27 o figure out what fields I'm saving in meanmags and how to construct it 28 -- mag, objID, catID, photcode, (dmag or other stats?) 29 * from which hosts do I slurp mean mags? 30 o function to merge a new meanmag array into the existing one 31 o how to go from (objID,catID) to a given catalog[i].average[j] 32 33 2014.02.06 34 35 ** a single region-level host owns images for which the center lands 36 in its region. 37 38 ** it owns detections which come from images which it owns 39 40 ** it owns objects which land in its region 41 42 Extending parallel relphot processing to split the sky (and images) 43 into regions, each of which runs in parallel at the same time: 44 45 Top Level (relphot -parallel-images): 46 * define regions of the sky -> hosts 47 * load images, assign to hosts 48 * launch region-level jobs on remote hosts 49 50 Region Level (relphot -parallel-images-region) 51 * load my image subset table 52 * request objects and detections for my skyregion 53 * match images & objects, etc 54 55 * update my image parameters 56 * update my detections 57 * write out detections 58 * load detections from my border hosts 59 * match to my objects 60 * update my objects 61 * write out objects 62 * load objects from my border hosts 63 * update images 64 (iterate N times) 65 * write out image parameters 66 67 Top Level 68 * read image parameters, update 69 * update objects 1 70 2 71 2012.02.13 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/include/relphot.h
r35806 r37067 5 5 # include <pthread.h> 6 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 16 7 /* # define GRID_V1 */ 17 8 # define GRID_V2 … … 23 14 // # define IDX_T off_t 24 15 # define IDX_T int 16 17 typedef enum { 18 MODE_ERROR = 0, 19 UPDATE_IMAGES, 20 UPDATE_AVERAGES, 21 PARALLEL_REGIONS, 22 PARALLEL_IMAGES, 23 APPLY_OFFSETS, 24 } RelphotMode; 25 25 26 26 typedef enum { … … 86 86 // others are only used on the final output steps. 87 87 88 double *list; // list of measure.mag values for a given star 89 double *dlist; // mag errors for a star 90 double *wlist; // weights to use for mean mags 91 double *aplist; // ap mags for a star 92 double *kronlist; // kron mags for a star 88 double *Mpsflist; // list of measure.mag values for a given star 89 double *dpsflist; // mag errors for a star 90 double *wpsflist; // weights to use for mean mags 91 92 double *Maplist; // ap mags for a star 93 double *daplist; // ap mags for a star 94 double *waplist; // ap mags for a star 95 96 double *Mkronlist; // kron mags for a star 93 97 double *dkronlist; // kron mag errors 98 double *wkronlist; // kron mag errors 94 99 95 100 double *psfqf_list; // psfqf for all filters … … 97 102 double *stargal_list; // stargal for all filters 98 103 99 StatType stats;104 StatType psfstats; 100 105 StatType apstats; 101 106 StatType kronstats; 102 107 } SetMrelInfo; 108 109 typedef struct { 110 float M; 111 float dM; 112 float Mchisq; 113 int Nsec; 114 unsigned int objID; 115 unsigned int catID; 116 int photcode; 117 } MeanMag; 118 119 typedef struct { 120 float Mcal; 121 float dMcal; 122 float dMagSys; 123 short Xm; 124 int nFitPhotom; 125 int flags; 126 unsigned int imageID; 127 short ubercalDist; 128 } ImageMag; 103 129 104 130 typedef struct { … … 116 142 unsigned int photom_map_id; 117 143 unsigned int flags; 144 int tessID; 118 145 int projID; 119 146 int skycellID; … … 149 176 int SKY_DEPTH; /** XXX EAM : depth of catalog tables, fix usage */ 150 177 178 // globals for parallel region operations 179 char *REGION_FILE; 180 char *IMAGE_TABLE; 181 int REGION_HOST_ID; 182 151 183 int HOST_ID; 152 184 char *HOSTDIR; … … 173 205 int PARALLEL_MANUAL; 174 206 int PARALLEL_SERIAL; 207 208 int PARALLEL_REGIONS_MANUAL; 175 209 176 210 int NTHREADS; … … 260 294 void InterpolateGrid PROTO((float *buffer, int Nx, int Ny, Coords *ccd, Coords *gcoords)); 261 295 off_t *SelectRefMosaic PROTO((Mosaic **refmosaic, off_t *Nimage)); 262 intargs PROTO((int argc, char **argv));296 RelphotMode args PROTO((int argc, char **argv)); 263 297 int args_client PROTO((int argc, char **argv)); 264 298 int bcatalog PROTO((Catalog *subcatalog, Catalog *catalog, int Ncat)); … … 273 307 void findImages PROTO((Catalog *catalog, int Ncatalog, int doImageList)); 274 308 int findMosaics PROTO((Catalog *catalog, int Ncatalog, int doMosaicList)); 309 310 void makeMosaics (Image *image, off_t Nimage, int mergeMcal); 311 Mosaic *getMosaicForImage (off_t im); 312 void setMosaicCenters (Image *image, off_t Nimage); 275 313 276 314 void set_db (FITS_DB *in); … … 309 347 void initMosaics PROTO((Image *subset, off_t Nsubset, Image *image, char *inSubset, off_t Nimage)); 310 348 void initMrel PROTO((Catalog *catalog, int Ncatalog)); 311 voidinitialize PROTO((int argc, char **argv));349 RelphotMode initialize PROTO((int argc, char **argv)); 312 350 void initialize_client PROTO((int argc, char **argv)); 313 351 void liststats_setmode PROTO((StatType *stats, char *strmode)); 314 352 int liststats PROTO((double *value, double *dvalue, double *wvalue, int N, StatType *stats)); 315 Catalog *load_catalogs PROTO((SkyList *skylist, int *Ncatalog, int hostID, char *hostpath ));316 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)); 317 355 318 356 SkyList *load_images PROTO((FITS_DB *db, char *regionName, SkyRegion *region)); … … 397 435 ImageSubset *ImageSubsetLoad(char *filename, off_t *nimage); 398 436 399 int client_logger_init ( );437 int client_logger_init (char *dirname); 400 438 int client_logger_message (char *format,...); 401 439 402 440 int MatchImageName (off_t meas, int cat, char *name); 403 int MatchImageSkycellID (off_t meas, int cat, int myProjectionID, int mySkycellID); 404 405 int load_tree (char *treefile); 406 int BoundaryTreePrimaryCell (char *primaryCellName, double ra, double dec); 407 int BoundaryTreePrimaryCellIDs (int *projID, int *skycellID, double ra, double dec); 441 int MatchImageSkycellID (off_t meas, int cat, int myTessID, int myProjectionID, int mySkycellID); 442 443 int load_tess (char *treefile); 444 int get_tess_ids (int *tessID, int *projID, int *skycellID, double ra, double dec); 445 int TessellationIDsByImageName (int *tessID, int *projID, int *skycellID, char *name); 446 447 // int BoundaryTreePrimaryCell (char *primaryCellName, double ra, double dec); 448 // int BoundaryTreePrimaryCellIDs (int *projID, int *skycellID, double ra, double dec); 408 449 409 450 int print_measure_set_alt (Average *average, SecFilt *secfilt, Measure *measure); … … 417 458 int init_synthetic_mags (); 418 459 int add_synthetic_mags (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, off_t *Nmeasure, off_t *Nm); 460 461 int relphot_parallel_regions (); 462 463 int assign_images (FITS_DB *db, RegionHostTable *regionHosts); 464 int select_images_hostregion (RegionHostTable *hosts, Image *image, off_t Nimage); 465 int find_host_for_coords (RegionHostTable *regionHosts, double R, double d); 466 int calculate_image_bounds (Image *image, double *rmin, double *rmax, double *dmin, double *dmax, double Rmid); 467 468 int launch_region_hosts (RegionHostTable *regionHosts); 469 int strextend (char *input, char *format,...); 470 471 Image *ImageTableLoad(char *filename, off_t *nimage); 472 int ImageTableSave (char *filename, Image *images, off_t Nimages); 473 474 int indexCatalogs (Catalog *catalog, int Ncatalog); 475 int catID_and_objID_to_seq (int catID, int objID, int *catSeq, off_t *objSeq); 476 477 int check_sync_file (char *filename, int nloop); 478 int clear_sync_file (char *filename); 479 int update_sync_file (char *filename, int nloop); 480 char *make_filename (char *dirname, char *hostname, int hostID, char *tailname); 481 482 int share_mean_mags (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 483 int slurp_mean_mags (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 484 int set_mean_mags (MeanMag *meanmags, AverageTiny *average, SecFilt *secfilt, int Nsec); 485 MeanMag *merge_mean_mags (MeanMag *target, int *ntarget, MeanMag *source, int Nsource); 486 487 MeanMag *MeanMagLoad(char *filename, off_t *nmeanmags); 488 int MeanMagSave(char *filename, MeanMag *meanmags, off_t Nmeanmags); 489 490 int share_image_mags (RegionHostTable *regionHosts, int nloop); 491 int slurp_image_mags (RegionHostTable *regionHosts, int nloop); 492 int set_image_mags (ImageMag *image_mags, Image *image); 493 ImageMag *merge_image_mags (ImageMag *target, int *ntarget, ImageMag *source, int Nsource); 494 495 ImageMag *ImageMagLoad(char *filename, off_t *nimage_mags); 496 int ImageMagSave(char *filename, ImageMag *image_mags, off_t Nimage_mags); 497 498 int markObjects (Catalog *catalog, int Ncatalog); 499 500 int relphot_parallel_images (); 501 int relphot_parallel_regions (); 502 503 // in extra.c 504 int isGPC1chip (int photcode); 505 int isGPC1stack (int photcode); 506 int isGPC1warp (int photcode); 507 508 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/BoundaryTreeOps.c
r35759 r37067 1 1 # include "relphot.h" 2 2 3 // XXX for the moment, only load one boundary tree at a time 4 // XXX in fact, only allow RINGS.V3... 3 static int Ntess = 0; 4 static TessellationTable *tess = NULL; 5 5 6 static BoundaryTree *tree = NULL; 6 int TessellationIDsByImageName (int *tessID, int *projID, int *skycellID, char *name) { 7 7 8 int BoundaryTreePrimaryCell (char *primaryCellName, double ra, double dec) { 8 int i; 9 9 10 int zone, band; 11 12 if (!primaryCellName) return FALSE; 13 14 primaryCellName[0] = 0; 15 16 if (!tree) return FALSE; 17 18 if (!BoundaryTreeCellCoords (tree, &zone, &band, ra, dec)) { 19 fprintf (stderr, "mismatch!\n"); 20 return FALSE; 21 } 22 23 # define USE_PROJECTION_CELL 0 24 # if (USE_PROJECTION_CELL) 25 snprintf (primaryCellName, DVO_MAX_PATH, "RINGS.V3.%s", tree->name[zone][band]); 26 # else 27 28 // I have ra, dec, and the primary projection cell. In order to choose the primary skycell, 29 // I just need to project to ra,dec to X,Y based on the center of the cell and then get the subdivision right. 30 31 double x = 0.0; 32 double y = 0.0; 33 BoundaryTreeProjection (&x, &y, ra, dec, tree, zone, band); 34 35 int xi = x / tree->dX[zone][band]; 36 int yi = y / tree->dY[zone][band]; 37 int N = xi + tree->NX_SUB * yi; 38 39 // XXX short-circuit this for now (we should use this code if we make tree have more variable NX,NY values 40 // char format[24], skycellname[128]; 41 // int Ndigit = (int)(log10(tree->NX_SUB*tree->NY_SUB)) + 1 ; 42 // snprintf (format, 24, "%s.%%0%dd", tree->name[zone][band], Ndigit); 43 // snprintf (skycellname, 128, format, N); 44 45 snprintf (primaryCellName, DVO_MAX_PATH, "RINGS.V3.%s.%03d", tree->name[zone][band], N); 46 # endif 47 48 return TRUE; 49 } 50 51 int BoundaryTreePrimaryCellIDs (int *projID, int *skycellID, double ra, double dec) { 52 53 int zone, band; 54 10 *tessID = -1; 55 11 *projID = -1; 56 12 *skycellID = -1; 57 13 58 if (!t ree) return FALSE;14 if (!tess) return FALSE; 59 15 60 if (!BoundaryTreeCellCoords (tree, &zone, &band, ra, dec)) { 61 fprintf (stderr, "mismatch!\n"); 62 return FALSE; 16 for (i = 0; i < Ntess; i++) { 17 // do this with a strhash of some kind? 18 if (!strncmp (name, tess[i].basename, tess[i].Nbasename)) { 19 *tessID = i; 20 if (tess[i].projectIDoff >= 0) { 21 *projID = atoi(&name[tess[i].projectIDoff]); 22 } else { 23 *projID = 0; 24 } 25 if (tess[i].skycellIDoff >= 0) { 26 *skycellID = atoi(&name[tess[i].skycellIDoff]); 27 } else { 28 *skycellID = 0; 29 } 30 return TRUE; 31 } 63 32 } 64 65 // I have ra, dec, and the primary projection cell. In order to choose the primary skycell, 66 // I just need to project to ra,dec to X,Y based on the center of the cell and then get the subdivision right. 67 68 double x = 0.0; 69 double y = 0.0; 70 BoundaryTreeProjection (&x, &y, ra, dec, tree, zone, band); 71 72 int xi = x / tree->dX[zone][band]; 73 int yi = y / tree->dY[zone][band]; 74 int N = xi + tree->NX_SUB * yi; 75 76 *projID = tree->projID[zone][band]; 77 *skycellID = N; 78 79 return TRUE; 33 return FALSE; 80 34 } 81 35 82 int load_t ree (char *treefile) {36 int load_tess (char *tessfile) { 83 37 84 t ree = BoundaryTreeLoad (treefile);85 if (!t ree) {86 fprintf (stderr, "failed to load boundary tree %s\n", treefile);38 tess = TessellationTableLoad (tessfile, &Ntess); 39 if (!tess) { 40 fprintf (stderr, "failed to load tessellation boundary file %s\n", tessfile); 87 41 exit (2); 88 42 } … … 90 44 return TRUE; 91 45 } 46 47 int get_tess_ids (int *tessID, int *projID, int *skycellID, double ra, double dec) { 48 49 int status; 50 51 if (!tess) return FALSE; 52 53 status = TessellationPrimaryCellIDs(tess, Ntess, tessID, projID, skycellID, ra, dec); 54 return status; 55 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/BrightCatalog.c
r33651 r37067 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]; … … 101 101 measure[i].catID = catID[i]; 102 102 measure[i].photcode = photcode[i]; 103 measure[i].myDet = FALSE; 103 104 } 104 105 fprintf (stderr, "loaded data for %lld measure\n", (long long) Nrow); 105 106 106 free ( dR);107 free ( dD);107 free (R ); 108 free (D ); 108 109 free (M ); 109 110 free (Mcal ); … … 135 136 136 137 // need to create and assign to flat-field correction 137 GET_COLUMN(R, "RA", double);138 GET_COLUMN(D, "DEC", double);138 GET_COLUMN(R, "RA", double); 139 GET_COLUMN(D, "DEC", double); 139 140 GET_COLUMN(Nmeasure, "NMEAS", int); 140 141 GET_COLUMN(measureOffset, "MEASURE_OFF", int); 141 142 GET_COLUMN(flags, "FLAGS", int); 142 143 GET_COLUMN(catID, "CAT_ID", int); 144 GET_COLUMN(objID, "OBJ_ID", int); 143 145 gfits_free_header (&theader); 144 146 gfits_free_table (&ftable); … … 153 155 average[i].flags = flags[i]; 154 156 average[i].catID = catID[i]; 157 average[i].objID = objID[i]; 158 average[i].nOwn = 0; 155 159 } 156 160 fprintf (stderr, "loaded data for %lld average\n", (long long) Nrow); … … 162 166 free (flags ); 163 167 free (catID ); 168 free (objID ); 164 169 165 170 catalog->average = average; … … 177 182 178 183 // need to create and assign to flat-field correction 179 GET_COLUMN(M, "MAG", float);180 GET_COLUMN(dM, "MAG_ERR", float);181 GET_COLUMN( Xm,"MAG_CHI", float);182 GET_COLUMN(flags, "FLAGS", int);183 GET_COLUMN(Ncode, "NCODE", short);184 GET_COLUMN(Nused, "NUSED", short);185 GET_COLUMN(M _20, "MAG_20", short);186 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); 187 192 gfits_free_header (&theader); 188 193 gfits_free_table (&ftable); … … 191 196 ALLOCATE (secfilt, SecFilt, Nrow); 192 197 for (i = 0; i < Nrow; i++) { 193 secfilt[i].M = M[i];194 secfilt[i].dM = dM[i];195 secfilt[i]. Xm = Xm[i];196 secfilt[i].flags = flags[i];197 secfilt[i].Ncode = Ncode[i];198 secfilt[i].Nused = Nused[i];199 secfilt[i].M _20 = M_20[i];200 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]; 201 206 } 202 207 fprintf (stderr, "loaded data for %lld secfilt\n", (long long) Nrow); 203 208 204 free (M );205 free (dM );206 free ( Xm);207 free (flags );208 free (Ncode );209 free (Nused );210 free (M _20);211 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 ); 212 217 catalog->secfilt = secfilt; 213 218 // assert Nsecfilt * Naverage = Nrow? … … 260 265 gfits_create_table_header (&theader, "BINTABLE", "MEASURE_TINY"); 261 266 262 gfits_define_bintable_column (&theader, " E", "RA_OFF", "ra offset", "arcsec", 1.0, 0.0);263 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); 264 269 gfits_define_bintable_column (&theader, "E", "MAG_SYS", "magnitude (sys)", NULL, 1.0, 0.0); 265 270 gfits_define_bintable_column (&theader, "E", "MAG_CAL", "magnitude (cal)", NULL, 1.0, 0.0); … … 269 274 gfits_define_bintable_column (&theader, "E", "Y_CCD", "ccd y coord", "pix", 1.0, 0.0); 270 275 gfits_define_bintable_column (&theader, "E", "EXPTIME", "-2.5 * log (exposure time)", "sec", 1.0, 0.0); 271 gfits_define_bintable_column (&theader, "J", "TIME", "time of exp", "sec", 1.0, 1.0*0x8000);272 gfits_define_bintable_column (&theader, "J", "AVE_REF", "pointer to average table", NULL, 1.0, 1.0*0x8000);273 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image", NULL, 1.0, 1.0*0x8000);274 gfits_define_bintable_column (&theader, "J", "DB_FLAGS", "flags", NULL, 1.0, 1.0*0x8000);275 gfits_define_bintable_column (&theader, "J", "PHOT_FLAGS", "photflags", NULL, 1.0, 1.0*0x8000);276 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog", NULL, 1.0, 1.0*0x8000);277 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); 278 283 279 284 // generate the output array that carries the data … … 281 286 282 287 // create intermediate storage arrays 283 float *dR ; ALLOCATE (dR , float, catalog->Nmeasure);284 float *dD ; ALLOCATE (dD , float, catalog->Nmeasure);285 float *M ; ALLOCATE (M , float,catalog->Nmeasure);286 float *Mcal ; ALLOCATE (Mcal , float,catalog->Nmeasure);287 float *dM ; ALLOCATE (dM , float,catalog->Nmeasure);288 float *airmass ; ALLOCATE (airmass , float,catalog->Nmeasure);289 float *Xccd ; ALLOCATE (Xccd , float,catalog->Nmeasure);290 float *Yccd ; ALLOCATE (Yccd , float,catalog->Nmeasure);291 float *dt ; ALLOCATE (dt , float,catalog->Nmeasure);292 int *t ; ALLOCATE (t , int ,catalog->Nmeasure);293 int *averef ; ALLOCATE (averef , int ,catalog->Nmeasure);294 int *imageID ; ALLOCATE (imageID , int ,catalog->Nmeasure);295 int *dbFlags ; ALLOCATE (dbFlags , int ,catalog->Nmeasure);296 int *photFlags ; ALLOCATE (photFlags, int ,catalog->Nmeasure);297 int *catID ; ALLOCATE (catID , int ,catalog->Nmeasure);298 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); 299 304 300 305 // assign the storage arrays 301 306 MeasureTiny *measure = catalog->measure; 302 307 for (i = 0; i < catalog->Nmeasure; i++) { 303 dR[i] = measure[i].dR ;304 dD[i] = measure[i].dD ;308 R[i] = measure[i].R ; 309 D[i] = measure[i].D ; 305 310 M[i] = measure[i].M ; 306 311 Mcal[i] = measure[i].Mcal ; … … 320 325 321 326 // add the columns to the output array 322 gfits_set_bintable_column (&theader, &ftable, "RA _OFF", dR,catalog->Nmeasure);323 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); 324 329 gfits_set_bintable_column (&theader, &ftable, "MAG_SYS", M, catalog->Nmeasure); 325 330 gfits_set_bintable_column (&theader, &ftable, "MAG_CAL", Mcal, catalog->Nmeasure); … … 337 342 gfits_set_bintable_column (&theader, &ftable, "PHOTCODE", photcode, catalog->Nmeasure); 338 343 339 free ( dR);340 free ( dD);344 free (R ); 345 free (D ); 341 346 free (M ); 342 347 free (Mcal ); … … 370 375 gfits_define_bintable_column (&theader, "J", "FLAGS", "flags", NULL, 1.0, 0.0); 371 376 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog ref", NULL, 1.0, 0.0); 377 gfits_define_bintable_column (&theader, "J", "OBJ_ID", "object ref", NULL, 1.0, 0.0); 372 378 373 379 // generate the output array that carries the data … … 381 387 int *flags ; ALLOCATE (flags, int, catalog->Naverage); 382 388 int *catID ; ALLOCATE (catID, int, catalog->Naverage); 389 int *objID ; ALLOCATE (objID, int, catalog->Naverage); 383 390 384 391 // assign the storage arrays … … 391 398 flags[i] = average[i].flags; 392 399 catID[i] = average[i].catID; 400 objID[i] = average[i].objID; 393 401 } 394 402 … … 400 408 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags, catalog->Naverage); 401 409 gfits_set_bintable_column (&theader, &ftable, "CAT_ID", catID, catalog->Naverage); 410 gfits_set_bintable_column (&theader, &ftable, "OBJ_ID", objID, catalog->Naverage); 402 411 403 412 free (R ); … … 407 416 free (flags ); 408 417 free (catID ); 418 free (objID ); 409 419 410 420 gfits_fwrite_Theader (f, &theader); … … 418 428 gfits_create_table_header (&theader, "BINTABLE", "SECFILT"); 419 429 420 gfits_define_bintable_column (&theader, "E", "MAG", " ra offset","arcsec", 1.0, 0.0);421 gfits_define_bintable_column (&theader, "E", "MAG_ERR", " dec offset","arcsec", 1.0, 0.0);422 gfits_define_bintable_column (&theader, "E", "MAG_CHI", " magnitude (sys)",NULL, 1.0, 0.0);423 gfits_define_bintable_column (&theader, "J", "FLAGS", " magnitude (cal)",NULL, 1.0, 0.0);424 gfits_define_bintable_column (&theader, "I", "NCODE", " magnitude (err)",NULL, 1.0, 0.0);425 gfits_define_bintable_column (&theader, "I", "NUSED", " airmass",NULL, 1.0, 0.0);426 gfits_define_bintable_column (&theader, " I", "MAG_20", "ccd x coord", "pix",1.0, 0.0);427 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); 428 438 429 439 // generate the output array that carries the data … … 437 447 float *M ; ALLOCATE (M , float, Nsec); 438 448 float *dM ; ALLOCATE (dM , float, Nsec); 439 float * Xm ; ALLOCATE (Xm, float, Nsec);449 float *Mchisq ; ALLOCATE (Mchisq , float, Nsec); 440 450 int *flags ; ALLOCATE (flags , int, Nsec); 441 451 short *Ncode ; ALLOCATE (Ncode , short, Nsec); 442 452 short *Nused ; ALLOCATE (Nused , short, Nsec); 443 short *M_20 ; ALLOCATE (M_20 , short, Nsec);444 short *M_80 ; ALLOCATE (M_80 , short, Nsec);453 float *Mmin ; ALLOCATE (Mmin , float, Nsec); 454 float *Mmax ; ALLOCATE (Mmax , float, Nsec); 445 455 446 456 // assign the storage arrays 447 457 SecFilt *secfilt = catalog->secfilt; 448 458 for (i = 0; i < Nsec; i++) { 449 M [i] = secfilt[i]. M ;450 dM [i] = secfilt[i]. dM ;451 Xm [i] = secfilt[i]. Xm;452 flags [i] = secfilt[i]. flags ;453 Ncode [i] = secfilt[i]. Ncode ;454 Nused [i] = secfilt[i]. Nused ;455 M _20 [i] = secfilt[i]. M_20;456 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 ; 457 467 } 458 468 459 469 // add the columns to the output array 460 gfits_set_bintable_column (&theader, &ftable, "MAG", M , Nsec);461 gfits_set_bintable_column (&theader, &ftable, "MAG_ERR", dM , Nsec);462 gfits_set_bintable_column (&theader, &ftable, "MAG_CHI", Xm, Nsec);463 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags , Nsec);464 gfits_set_bintable_column (&theader, &ftable, "NCODE", Ncode , Nsec);465 gfits_set_bintable_column (&theader, &ftable, "NUSED", Nused , Nsec);466 gfits_set_bintable_column (&theader, &ftable, "MAG_ 20", M_20, Nsec);467 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); 468 478 469 479 free (M ); 470 480 free (dM ); 471 free ( Xm);481 free (Mchisq ); 472 482 free (flags ); 473 483 free (Ncode ); 474 484 free (Nused ); 475 free (M _20);476 free (M _80);485 free (Mmin ); 486 free (Mmax ); 477 487 478 488 gfits_fwrite_Theader (f, &theader); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/GridOps.c
r34088 r37067 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/ipp-ops-20130712/Ohana/src/relphot/src/ImageOps.c
r35759 r37067 48 48 // stack image. for now, we generate these ID arrays based on the image names when we load in the image table (initImages). 49 49 // When we pass data to the remote clients via the ImageSubset, the projID/skycellID values are carried directly in the table. 50 int *tessID = NULL; 50 51 int *projectID = NULL; 51 52 int *skycellID = NULL; … … 81 82 82 83 // for stack images, assign projection cell ID and skycell ID based on filenames 84 ALLOCATE (tessID, int, Nimage); 83 85 ALLOCATE (projectID, int, Nimage); 84 86 ALLOCATE (skycellID, int, Nimage); … … 87 89 imageIdx[i] = i; 88 90 imageIDs[i] = image[i].imageID; 91 92 tessID[i] = -1; 89 93 projectID[i] = -1; 90 94 skycellID[i] = -1; 91 if (!strncmp (image[i].name, "RINGS.V3.skycell", strlen("RINGS.V3.skycell"))) { 92 projectID[i] = atoi(&image[i].name[17]); 93 skycellID[i] = atoi(&image[i].name[22]); 94 } 95 96 TessellationIDsByImageName (&tessID[i], &projectID[i], &skycellID[i], image[i].name); 95 97 } 96 98 97 99 // sort the image index by the IDs 100 // XXX does this break the imageID <-> projectID, etc match? 98 101 llsortpair (imageIDs, imageIdx, Nimage); 99 102 } … … 106 109 // create full a Image array and save the needed values 107 110 ALLOCATE (image, Image, N); 111 112 ALLOCATE (tessID, int, N); 108 113 ALLOCATE (projectID, int, N); 109 114 ALLOCATE (skycellID, int, N); … … 118 123 image[i].trate = input[i].trate ; 119 124 image[i].ubercalDist = input[i].ubercalDist ; 125 tessID[i] = input[i].tessID ; 120 126 projectID[i] = input[i].projID ; 121 127 skycellID[i] = input[i].skycellID ; … … 153 159 subset[i].trate = image[i].trate ; 154 160 subset[i].ubercalDist = image[i].ubercalDist ; 161 subset[i].tessID = tessID[i]; 155 162 subset[i].projID = projectID[i]; 156 163 subset[i].skycellID = skycellID[i]; … … 237 244 238 245 int Nmatch = 0; 239 for (i = 0; i < Ncatalog; i++) {246 for (i = 0; i < Ncatalog; i++) { 240 247 for (j = 0; j < catalog[i].Nmeasure; j++) { 248 catalog[i].measureT[j].myDet = FALSE; // a detetion is not mine until proven otherwise 241 249 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[j].photcode); 250 251 // skip measurements which do not match one of the requested photcodes ( 252 // (do we not already exclude in bcatalog -- maybe needed for reload_objects? 242 253 found = FALSE; 243 254 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { … … 245 256 } 246 257 if (!found) continue; 258 259 // if we match one of our images, myDet gets set to TRUE 247 260 matchImage (catalog, j, i, doImageList); 248 261 Nmatch ++; … … 315 328 return; 316 329 } 330 catalog[cat].measureT[meas].myDet = TRUE; 317 331 318 332 if (USE_GRID) { … … 461 475 462 476 // returns image.Mcal - ff(x,y) 463 int MatchImageSkycellID (off_t meas, int cat, int my ProjectionID, int mySkycellID) {477 int MatchImageSkycellID (off_t meas, int cat, int myTessID, int myProjectionID, int mySkycellID) { 464 478 465 479 off_t i; … … 470 484 if (i == -1) return FALSE; 471 485 486 if (tessID[i] == -1) return FALSE; 472 487 if (projectID[i] == -1) return FALSE; 473 488 if (skycellID[i] == -1) return FALSE; 474 489 490 if (tessID[i] != myTessID) return FALSE; 475 491 if (projectID[i] != myProjectionID) return FALSE; 476 492 if (skycellID[i] != mySkycellID) return FALSE; … … 515 531 liststats_setmode (&stats, STATMODE); 516 532 517 if (FREEZE_IMAGES) return;533 // FREEZE_IMAGES only applies to mosaic data (eg, gpc1) 518 534 519 535 fprintf (stderr, "limiting negative clouds to %f\n", CLOUD_TOLERANCE); … … 545 561 if (!bad) continue; 546 562 } 563 564 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 547 565 548 566 // UBERCAL image: if this is an ubercal image, set minUbercalDist to 0: … … 592 610 593 611 n = catalog[c].measureT[m].averef; 594 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt] );612 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt], MAG_CLASS_PSF); 595 613 if (isnan(Msys)) { 596 614 Nsys++; … … 679 697 double MaxOffset, MaxScatter, MedOffset; 680 698 681 if (FREEZE_IMAGES) return;699 // if (FREEZE_IMAGES) return; 682 700 683 701 if (VERBOSE) fprintf (stderr, "marking poor images\n"); … … 690 708 for (i = N = 0; i < Nimage; i++) { 691 709 if (image[i].flags & IMAGE_BAD) continue; 710 711 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 712 692 713 mlist[N] = image[i].Mcal; 693 714 slist[N] = image[i].dMcal; … … 781 802 Graphdata graphdata; 782 803 783 if (FREEZE_IMAGES) return;804 // if (FREEZE_IMAGES) return; 784 805 785 806 ALLOCATE (xlist, double, Nimage); … … 794 815 float mindMcal = +100.0; 795 816 float maxdMcal = -100.0; 796 for (i = 0; i < Nimage; i++) { 797 Mlist[i] = image[i].Mcal; 798 dlist[i] = image[i].dMcal; 799 xlist[i] = image[i].secz; 817 818 int Nplot = 0; 819 820 for (i = 0; i < Nimage; i++) { 821 822 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 823 824 Mlist[Nplot] = image[i].Mcal; 825 dlist[Nplot] = image[i].dMcal; 826 xlist[Nplot] = image[i].secz; 800 827 minAirmass = MIN (image[i].secz, minAirmass); 801 828 maxAirmass = MAX (image[i].secz, maxAirmass); … … 804 831 mindMcal = MIN (image[i].dMcal, mindMcal); 805 832 maxdMcal = MAX (image[i].dMcal, maxdMcal); 833 834 Nplot ++; 806 835 } 807 836 … … 836 865 for (i = 0; i < NBIN; i++) xlist[i] = 0.00025*i; 837 866 bzero (Mlist, NBIN*sizeof(double)); 838 for (i = 0; i < Nimage; i++) { 867 868 for (i = 0; i < Nimage; i++) { 869 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 870 839 871 bin = image[i].dMcal / 0.00025; 840 872 bin = MAX (0, MIN (NBIN - 1, bin)); … … 861 893 StatType stats; 862 894 bzero (&stats, sizeof (StatType)); 863 if (FREEZE_IMAGES) return (stats); 895 896 // we no longer blindly apply FREEZE_IMAGES to all images, only to mosaics 897 // if (FREEZE_IMAGES) return (stats); 864 898 865 899 ALLOCATE (list, double, Nimage); … … 869 903 for (i = 0; i < Nimage; i++) { 870 904 if (image[i].flags & IMAGE_BAD) continue; 905 906 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 871 907 872 908 N = 0; … … 904 940 905 941 bzero (&stats, sizeof (StatType)); 906 if (FREEZE_IMAGES) return (stats);942 // if (FREEZE_IMAGES) return (stats); 907 943 908 944 ALLOCATE (list, double, Nimage); … … 913 949 914 950 if (image[i].flags & IMAGE_BAD) continue; 951 952 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 915 953 916 954 list[n] = pow (10.0, 0.01*image[i].Xm); … … 934 972 935 973 bzero (&stats, sizeof (StatType)); 936 if (FREEZE_IMAGES) return (stats);974 // if (FREEZE_IMAGES) return (stats); 937 975 938 976 ALLOCATE (list, double, Nimage); … … 943 981 944 982 if (image[i].flags & IMAGE_BAD) continue; 983 984 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 945 985 946 986 list[n] = image[i].Mcal; … … 964 1004 965 1005 bzero (&stats, sizeof (StatType)); 966 if (FREEZE_IMAGES) return (stats);1006 // if (FREEZE_IMAGES) return (stats); 967 1007 968 1008 ALLOCATE (list, double, Nimage); … … 973 1013 974 1014 if (image[i].flags & IMAGE_BAD) continue; 1015 1016 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 975 1017 976 1018 list[n] = image[i].dMcal; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/ImageSubset.c
r35759 r37067 63 63 GET_COLUMN (map, "PHOTOM_MAP", int); 64 64 GET_COLUMN (flags, "FLAGS", int); 65 GET_COLUMN (tessID, "TESS_ID", int); 65 66 GET_COLUMN (projID, "PROJ_ID", int); 66 67 GET_COLUMN (skycellID, "SKYCELL_ID", int); … … 78 79 image[i].photom_map_id = map[i]; 79 80 image[i].flags = flags[i]; 81 image[i].tessID = tessID[i]; 80 82 image[i].projID = projID[i]; 81 83 image[i].skycellID = skycellID[i]; … … 91 93 free (map); 92 94 free (flags); 95 free (tessID); 93 96 free (projID); 94 97 free (skycellID); … … 123 126 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_SUBSET"); 124 127 125 gfits_define_bintable_column (&theader, "E", "MCAL", "zero point offset", "magnitudes", 1.0, 0.0); 126 gfits_define_bintable_column (&theader, "E", "MCAL_ERR", "zero point error", "magnitudes", 1.0, 0.0); 127 128 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image ID", NULL, 1.0, 1.0*0x8000); 129 gfits_define_bintable_column (&theader, "J", "PHOTOM_MAP", "map", NULL, 1.0, 1.0*0x8000); 130 gfits_define_bintable_column (&theader, "J", "FLAGS", "flags", NULL, 1.0, 1.0*0x8000); 131 132 gfits_define_bintable_column (&theader, "J", "PROJ_ID", "ID", NULL, 1.0, 0.0); 133 gfits_define_bintable_column (&theader, "J", "SKYCELL_ID", "ID", NULL, 1.0, 0.0); 134 135 gfits_define_bintable_column (&theader, "J", "TZERO", "exposure start", NULL, 1.0, 1.0*0x8000); 136 gfits_define_bintable_column (&theader, "I", "TRATE", "tti rate", NULL, 1.0, 0.0); 137 138 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); 139 139 140 140 // generate the output array that carries the data … … 143 143 float *Mcal, *dMcal; 144 144 unsigned int *imageID, *map, *flags, *tzero; 145 int * projID, *skycellID;145 int *tessID, *projID, *skycellID; 146 146 unsigned short *trate; 147 147 short *ucdist; 148 148 149 149 // create intermediate storage arrays 150 ALLOCATE (Mcal, float, Nimage);151 ALLOCATE (dMcal, float, Nimage);150 ALLOCATE (Mcal, float, Nimage); 151 ALLOCATE (dMcal, float, Nimage); 152 152 ALLOCATE (imageID, unsigned int, Nimage); 153 153 ALLOCATE (map, unsigned int, Nimage); 154 154 ALLOCATE (flags, unsigned int, Nimage); 155 ALLOCATE (tessID, int, Nimage); 155 156 ALLOCATE (projID, int, Nimage); 156 157 ALLOCATE (skycellID, int, Nimage); … … 169 170 trate[i] = image[i].trate; 170 171 ucdist[i] = image[i].ubercalDist; 172 tessID[i] = image[i].tessID; 171 173 projID[i] = image[i].projID; 172 174 skycellID[i] = image[i].skycellID; … … 179 181 gfits_set_bintable_column (&theader, &ftable, "PHOTOM_MAP", map, Nimage); 180 182 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags, Nimage); 183 gfits_set_bintable_column (&theader, &ftable, "TESS_ID", tessID, Nimage); 181 184 gfits_set_bintable_column (&theader, &ftable, "PROJ_ID", projID, Nimage); 182 185 gfits_set_bintable_column (&theader, &ftable, "SKYCELL_ID", skycellID, Nimage); … … 190 193 free (map); 191 194 free (flags); 195 free (tessID); 192 196 free (projID); 193 197 free (skycellID); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/MosaicOps.c
r35806 r37067 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; 315 } 316 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 319 */ 320 void makeMosaics (Image *image, off_t Nimage, int mergeMcal) { 321 322 off_t i, j, found, NMOSAIC, *MosaicN_IMAGE; 323 unsigned int start, stop, *startTimes, *startTimesMosaic; 324 325 if (!MOSAIC_ZEROPT) return; 326 327 INITTIME; 328 329 /* a 'mosaic' in relphot is (unlike relastro) a virtual concept: there is no 330 * entry in the image table that represents this mosaic. Instead, it is an 331 * internal construct that defines a group of related images 332 */ 333 334 // generate a list of all image start times 335 ALLOCATE (startTimes, unsigned int, Nimage); 336 int Nmoschip = 0; 337 for (i = 0; i < Nimage; i++) { 338 if (!isGPC1chip(image[i].photcode)) continue; 339 startTimes[Nmoschip] = image[i].tzero; 340 Nmoschip ++; 341 } 342 sort_times (startTimes, Nmoschip); 343 MARKTIME("create array of all image obstimes: %f sec\n", dtime); 344 345 Nmosaic = 0; 346 NMOSAIC = 1000; 347 ALLOCATE (startTimesMosaic, unsigned int, NMOSAIC); 348 startTimesMosaic[0] = startTimes[0]; 349 350 // generate a list of the unique start times (these define the mosaics) 351 for (i = 0; i < Nmoschip; i++) { 352 myAssert (startTimes[i] >= startTimesMosaic[Nmosaic], "times out of order?"); 353 if (startTimes[i] == startTimesMosaic[Nmosaic]) continue; 354 Nmosaic ++; 355 if (Nmosaic >= NMOSAIC) { 356 NMOSAIC += 1000; 357 REALLOCATE (startTimesMosaic, unsigned int, NMOSAIC); 358 } 359 startTimesMosaic[Nmosaic] = startTimes[i]; 360 } 361 Nmosaic ++; 362 MARKTIME("create array of mosaic obstimes: %f sec\n", dtime); 363 364 // now I have a list of uniq start times, and they are in order 365 // create the mosaic arrays for these times 366 ALLOCATE (mosaic, Mosaic, Nmosaic); 367 368 ALLOCATE (MosaicToImage, off_t *, Nmosaic); 369 ALLOCATE (MosaicN_Image, off_t, Nmosaic); 370 ALLOCATE (MosaicN_IMAGE, off_t, Nmosaic); 371 372 // init the mosaic array values 373 for (i = 0; i < Nmosaic; i++) { 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; 382 mosaic[i].photcode = 0; 383 mosaic[i].skipCal = FALSE; 384 385 memset (&mosaic[i].coords, 0, sizeof(Coords)); 386 387 MosaicN_IMAGE[i] = 10; 388 MosaicN_Image[i] = 0; 389 ALLOCATE (MosaicToImage[i], off_t, MosaicN_IMAGE[i]); 390 MosaicToImage[i][0] = -1; 391 } 392 393 ALLOCATE (ImageToMosaic, off_t, Nimage); // mosaic to which image belongs 394 395 // assign each image to a mosaic 396 int Nsimple = 0; 397 for (i = 0; i < Nimage; i++) { 398 ImageToMosaic[i] = -1; 399 400 if (!isGPC1chip(image[i].photcode)) { 401 Nsimple ++; 402 continue; 403 } 404 405 start = image[i].tzero; 406 stop = image[i].tzero + MAX(1.01*image[i].trate*image[i].NY, 1); 407 408 j = findMosaic(startTimesMosaic, Nmosaic, start); 409 if (j == -1) { 410 fprintf (stderr, "programming error? all image images should belong to a mosaic\n"); 411 abort(); 412 } 413 414 // add reference from image to mosaic 415 ImageToMosaic[i] = j; 416 417 // have we already found this mosaic? 418 found = (MosaicN_Image[j] > 0); 419 420 /* add image to mosaic image list */ 421 MosaicToImage[j][MosaicN_Image[j]] = i; 422 MosaicN_Image[j] ++; 423 if (MosaicN_Image[j] == MosaicN_IMAGE[j]) { 424 MosaicN_IMAGE[j] += 10; 425 REALLOCATE (MosaicToImage[j], off_t, MosaicN_IMAGE[j]); 426 } 427 if (found) continue; 428 429 /* a new mosaic, define ranges */ 430 if (mosaic[j].start != start) { 431 fprintf (stderr, "error?\n"); 432 abort(); 433 } 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; 441 mosaic[j].photcode = GetPhotcodeEquivCodebyCode (image[i].photcode); 442 } 443 MARKTIME("assign images to mosaic: %f sec\n", dtime); 444 445 // free this or not? 446 free (MosaicN_IMAGE); 447 free (startTimes); 448 free (startTimesMosaic); 449 450 if (mergeMcal) { 451 initMosaicGrid (image, Nimage); 452 } 453 454 fprintf (stderr, "matched %d images to %d mosaics\n", (int) Nimage, (int) Nmosaic); 455 return; 456 } 457 458 Mosaic *getMosaicForImage (off_t im) { 459 460 if (im < 0) return NULL; 461 if (!ImageToMosaic) return NULL; 462 463 off_t m = ImageToMosaic[im]; 464 if (m < 0) return NULL; 465 if (m >= Nmosaic) return NULL; 466 467 return (&mosaic[m]); 320 468 } 321 469 … … 352 500 } 353 501 502 void setMosaicCenters (Image *image, off_t Nimage) { 503 504 /* find max dR, dD range for all mosaics */ 505 /* define mosaic.coords to cover dR, dD */ 506 /* send results to initGridBins */ 507 508 off_t i, j, m, NX, NY, NC, Nc; 509 double R, D, Rmid, Dmid; 510 double *Rc, *Dc; 511 512 NC = 100; 513 ALLOCATE (Rc, double, NC); 514 ALLOCATE (Dc, double, NC); 515 516 for (i = 0; i < Nmosaic; i++) { 517 Nc = 0; 518 Rmid = Dmid = NAN; 519 for (j = 0; j < MosaicN_Image[i]; j++) { 520 m = MosaicToImage[i][j]; 521 522 if (!FindMosaicForImage (image, Nimage, m)) { 523 if (VERBOSE2) fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i); 524 continue; 525 } 526 527 NX = image[m].NX; 528 NY = image[m].NY; 529 XY_to_RD (&R, &D, 0.5*NX, 0.5*NY, &image[m].coords); 530 R = ohana_normalize_angle_to_midpoint (R, 180.0); 531 532 // Exclude images with crazy astrometry 533 // XXX NOTE : this is gpc1-specific 534 { 535 double dP1 = hypot(image[m].coords.pc1_1, image[m].coords.pc1_2); 536 double dP2 = hypot(image[m].coords.pc2_1, image[m].coords.pc2_2); 537 if (fabs(dP1 - 1.0) > 0.02) continue; 538 if (fabs(dP2 - 1.0) > 0.02) continue; 539 540 double X00, Y00, X10, Y10, X01, Y01; 541 XY_to_LM (&X00, &Y00, 0.0, 0.0, &image[m].coords); 542 XY_to_LM (&X10, &Y10, image[m].NX, 0.0, &image[m].coords); 543 XY_to_LM (&X01, &Y01, 0.0, image[m].NY, &image[m].coords); 544 double dS0 = hypot ((X00 - X10), (Y00 - Y10)); 545 double dS1 = hypot ((X00 - X01), (Y00 - Y01)); 546 if (dS0 > 6000) continue; 547 if (dS1 > 6500) continue; 548 } 549 550 Rc[Nc] = R; 551 Dc[Nc] = D; 552 Nc ++; 553 if (Nc >= NC) { 554 NC += 100; 555 REALLOCATE (Rc, double, NC); 556 REALLOCATE (Dc, double, NC); 557 } 558 } 559 560 if (Nc > 0) { 561 dsort (Rc, Nc); 562 if (Rc[Nc-1] - Rc[0] > 180.0) { 563 // in our list, Rc is in the range 0.0 to 360.0. 564 // any mosaic which is close to the 0.0, 360.0 boundary may have some on 565 // one side or the other. count how many have values more than Rc[0] + 180. 566 // if more than half are at the large end, re-normalize to that range 567 int Nbig = 0; 568 for (j = 1; j < Nc; j++) { 569 if (Rc[j] - Rc[0] > 180.0) Nbig ++; 570 } 571 if (Nbig > 0.5*Nc) { 572 for (j = 0; j < Nc; j++) { 573 Rc[j] = ohana_normalize_angle_to_midpoint (Rc[j], 360.0); 574 } 575 dsort (Rc, Nc); 576 } else if (Nbig > 0) { 577 for (j = 0; j < Nc; j++) { 578 Rc[j] = ohana_normalize_angle_to_midpoint (Rc[j], 0.0); 579 } 580 dsort (Rc, Nc); 581 } 582 } 583 dsort (Dc, Nc); 584 585 Rmid = Rc[(int)(0.5*Nc)]; 586 Dmid = Dc[(int)(0.5*Nc)]; 587 } 588 589 strcpy (mosaic[i].coords.ctype, "DEC--TAN"); 590 mosaic[i].coords.crval1 = Rmid; 591 mosaic[i].coords.crval2 = Dmid; 592 mosaic[i].coords.crpix1 = 0.0; 593 mosaic[i].coords.crpix2 = 0.0; 594 mosaic[i].coords.cdelt1 = 1.0 / 3600.0; 595 mosaic[i].coords.cdelt2 = 1.0 / 3600.0; 596 mosaic[i].coords.pc1_1 = 1.0; 597 mosaic[i].coords.pc2_2 = 1.0; 598 mosaic[i].coords.pc1_2 = 0.0; 599 mosaic[i].coords.pc2_1 = 0.0; 600 601 mosaic[i].Mcal = 0.0; 602 mosaic[i].dMcal = 0.0; 603 mosaic[i].Xm = 0.0; 604 } 605 return; 606 } 607 354 608 void initMosaicGrid (Image *image, off_t Nimage) { 355 609 … … 363 617 double R, D, Rmin, Rmax, Dmin, Dmax; 364 618 double Mcal, dMcal, Xm; 619 620 fprintf (stderr, "*** moving Mcal from image.Mcal to mosaic.Mcal ***\n"); 365 621 366 622 dXmax = dYmax = 0.0; … … 395 651 Dmin = MIN (Dmin, D); 396 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 397 661 Mcal += image[m].Mcal; 398 662 dMcal += image[m].dMcal; 399 663 Xm += image[m].Xm; 400 664 401 // XXX: how does this work with UBERCAL? We want to keep the Mcal values supplied by ubercal, but 402 // solve for a single offset for each exposure (Mosaic.Mcal). 403 404 // we also want to keep the flat-field terms for each exposure (regardless of ubercal or not) 405 406 // if it helps, note that ubercal uses a single zp per exposure, so the mean of those values is the same as the value 407 408 /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */ 409 image[m].Mcal = 0.0; 410 image[m].dMcal = NAN; 411 image[m].Xm = NAN_S_SHORT; 665 image[m].Mcal = 0.0; 666 image[m].dMcal = NAN; 667 image[m].Xm = NAN_S_SHORT; 412 668 } 413 669 dS /= MosaicN_Image[i]; 414 strcpy (mosaic[i].coords.ctype, " RA---TAN");670 strcpy (mosaic[i].coords.ctype, "DEC--TAN"); 415 671 mosaic[i].coords.crval1 = Rmin; 416 672 mosaic[i].coords.crval2 = Dmin; … … 425 681 RD_to_XY (&dX, &dY, Rmax, Dmax, &mosaic[i].coords); 426 682 427 mosaic[i].Mcal = Mcal / MosaicN_Image[i];428 mosaic[i].dMcal = dMcal / MosaicN_Image[i];429 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]; 430 686 } 431 687 if (!USE_GRID) return; … … 437 693 } 438 694 439 // XXX : what about mosaics with skipCal == TRUE?440 695 void setMcalFinal () { 441 696 … … 447 702 image = getimages (&Nimage, NULL); 448 703 449 // XXX I think this is OK in the ubercal context, but probably need to skip UBERCAL 450 // images? (no need to update them) 704 fprintf (stderr, "*** return Mcal from mosaic.Mcal to image.Mcal ***\n"); 451 705 452 706 // copy the mosaic results to the images. set the mosaic Mcal to 0.0 since we have moved its … … 527 781 528 782 if (!MOSAIC_ZEROPT) return (FALSE); 783 // if we are calibrating by mosaic, redefine myDet == on one of my mosaics 529 784 530 785 int Nmatch = 0; 531 786 for (i = 0; i < Ncatalog; i++) { 532 787 for (j = 0; j < catalog[i].Nmeasure; j++) { 788 catalog[i].measureT[j].myDet = FALSE; // a detetion is not mine until proven otherwise 789 533 790 if (TimeSelect) { 534 791 if (catalog[i].measureT[j].t < TSTART) continue; … … 565 822 mosID = ImageToMosaic[idx]; 566 823 if (mosID < 0) { 567 Image *image = getimage(idx); 568 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) 569 827 return; 570 828 } … … 582 840 } 583 841 842 // this measurement is on one of my mosaics, mark it as mine. 843 catalog[cat].measureT[meas].myDet = TRUE; 584 844 MeasureToMosaic[cat][meas] = mosID; 585 845 … … 605 865 if (!MOSAIC_ZEROPT) return (0); 606 866 867 // unassigned measurements belong to simple chips 607 868 i = MeasureToMosaic[cat][meas]; 608 if (i == -1) return ( NAN);869 if (i == -1) return (0.0); 609 870 610 871 if (mosaic[i].flags & IMAGE_BAD) return (NAN); … … 850 1111 851 1112 off_t n = catalog[c].measureT[m].averef; 852 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); 853 1114 854 1115 float delta = Msys - Mrel - Mcal - Mgrid + Mflat; … … 887 1148 888 1149 off_t n = catalog[c].measureT[m].averef; 889 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); 890 1151 if (isnan(Msys)) { 891 1152 info->Nsys++; … … 962 1223 963 1224 if (testImage) { 964 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)); 965 1226 } 966 1227 … … 1315 1576 if (mosaic[i].flags & IMAGE_BAD) continue; 1316 1577 if (mosaic[i].skipCal) continue; 1578 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; 1579 1317 1580 list[n] = mosaic[i].Mcal; 1318 1581 dlist[n] = 1; … … 1345 1608 if (mosaic[i].flags & IMAGE_BAD) continue; 1346 1609 if (mosaic[i].skipCal) continue; 1610 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; 1611 1347 1612 list[n] = mosaic[i].dMcal; 1348 1613 dlist[n] = 1; … … 1376 1641 if (mosaic[i].flags & IMAGE_BAD) continue; 1377 1642 if (mosaic[i].skipCal) continue; 1643 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; 1378 1644 1379 1645 N = 0; … … 1422 1688 if (mosaic[i].flags & IMAGE_BAD) continue; 1423 1689 if (mosaic[i].skipCal) continue; 1424 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); 1425 1693 dlist[n] = 1; 1426 1694 n++; … … 1505 1773 void plot_mosaic_fields (Catalog *catalog) { 1506 1774 1507 off_t i, j, m, c, N, ave,Nimage;1775 off_t i, j, m, c, N, Nimage; 1508 1776 double *xlist, *ylist; 1509 // double Xmin, Xmax, Ymin, Ymax;1510 1777 char string[64]; 1511 1778 Graphdata graphdata; … … 1526 1793 for (i = 0; i < Nmosaic; i++) { 1527 1794 N = 0; 1528 // Xmin = Ymin = +360.0;1529 // Xmax = Ymax = -360.0;1530 1795 for (j = 0; j < N_onMosaic[i]; j++) { 1531 1796 … … 1535 1800 if (catalog[c].measureT[m].dbFlags & (ID_MEAS_AREA | ID_MEAS_NOCAL)) continue; 1536 1801 1537 ave = catalog[c].measureT[m].averef;1538 xlist[N] = catalog[c]. averageT[ave].R - catalog[c].measureT[m].dR / 3600.0;1539 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; 1540 1805 N++; 1541 1806 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/Shutdown.c
r33651 r37067 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/ipp-ops-20130712/Ohana/src/relphot/src/StarOps.c
r35759 r37067 63 63 results->Ngrid = 0; 64 64 if (allocLists) { 65 ALLOCATE (results-> list,double, Nmax);66 ALLOCATE (results->d list, double, Nmax);67 ALLOCATE (results->w list, double, Nmax);65 ALLOCATE (results->Mpsflist, double, Nmax); 66 ALLOCATE (results->dpsflist, double, Nmax); 67 ALLOCATE (results->wpsflist, double, Nmax); 68 68 } 69 69 } 70 70 71 71 void SetMrelInfoFree (SetMrelInfo *results) { 72 free (results-> list);73 free (results->d list);74 free (results->w list);72 free (results->Mpsflist); 73 free (results->dpsflist); 74 free (results->wpsflist); 75 75 } 76 76 77 77 void SetMrelInfoAccum (SetMrelInfo *summary, SetMrelInfo *results) { 78 78 summary->Nfew += results->Nfew ; 79 summary->Ncode += results->Ncode ;79 summary->Ncode += results->Ncode ; 80 80 summary->Nsys += results->Nsys ; 81 81 summary->Nbad += results->Nbad ; … … 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 … … 158 161 SetMrelInfoInit (&summary, FALSE); 159 162 SetMrelInfoInit (&results, TRUE); // allocates results->list,dlist,wlist 160 ALLOCATE (results.aplist, double, Nmax); 161 ALLOCATE (results.kronlist, double, Nmax); 163 164 ALLOCATE (results.Maplist, double, Nmax); 165 ALLOCATE (results.daplist, double, Nmax); 166 ALLOCATE (results.waplist, double, Nmax); 167 168 ALLOCATE (results.Mkronlist, double, Nmax); 162 169 ALLOCATE (results.dkronlist, double, Nmax); 170 ALLOCATE (results.wkronlist, double, Nmax); 163 171 164 172 ALLOCATE (results.psfqf_list, double, Nmax); … … 183 191 184 192 SetMrelInfoFree (&results); 185 free (results.aplist); 186 free (results.kronlist); 193 free (results.Maplist); 194 free (results.daplist); 195 free (results.waplist); 196 197 free (results.Mkronlist); 187 198 free (results.dkronlist); 199 free (results.wkronlist); 188 200 189 201 free (results.psfqf_list); … … 328 340 int setMrel_catalog (Catalog *catalog, int Nc, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, int Nsecfilt) { 329 341 342 fprintf (stderr, "??? should you still be using the old version of setMrel_catalog??\n"); 343 exit (3); 344 345 # if (0) 346 330 347 off_t j, k, m, ID; 331 348 int N; … … 333 350 334 351 StatType stats, apstats, kronstats; 335 liststats_setmode (& stats, STATMODE);352 liststats_setmode (&psfstats, STATMODE); 336 353 liststats_setmode (&apstats, STATMODE); 337 354 liststats_setmode (&kronstats, STATMODE); … … 366 383 if (isSetMrelFinal) { 367 384 // set the name of the primary skycell (this is used in a strcmp to match the skycells in stack detections) 368 BoundaryTreePrimaryCell(primaryCell, catalog[Nc].average[j].R, catalog[Nc].average[j].D); 385 // XXX : this whole function is deprecated 386 // BoundaryTreePrimaryCell(primaryCell, catalog[Nc].average[j].R, catalog[Nc].average[j].D); 369 387 } 370 388 … … 392 410 393 411 /* star/photcodes already calibrated */ 394 if ( isSetMrelFinal && catalog[Nc].found [Nsecfilt*j+Nsec]) continue;412 if ( isSetMrelFinal && catalog[Nc].found_t[Nsecfilt*j+Nsec]) continue; 395 413 396 414 // skip bad stars … … 452 470 453 471 // skip some absurd values NAN, < 0.0, > 30.0 454 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); 455 473 if (isnan(Msys)) SKIP_THIS_MEAS(Nsys); 456 474 if (Msys < 0.0) SKIP_THIS_MEAS(Nsys); … … 655 673 liststats (list, dlist, wlist, N, &stats); 656 674 657 catalog[Nc].secfilt[Nsecfilt*j+Nsec].M = stats.mean;658 catalog[Nc].secfilt[Nsecfilt*j+Nsec].dM = stats.error;659 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; 660 678 661 679 // when running -averages, we have no information about the images, so we cannot set this … … 665 683 666 684 if (isSetMrelFinal) { 667 catalog[Nc].found [Nsecfilt*j+Nsec] = TRUE;685 catalog[Nc].found_t[Nsecfilt*j+Nsec] = TRUE; 668 686 669 687 catalog[Nc].secfilt[Nsecfilt*j+Nsec].Mstdev = 1000.0*stats.sigma; // Mstdev is in millimags (not enough space for more precision) … … 833 851 if (primaryCell) free (primaryCell); 834 852 return (TRUE); 853 # endif 835 854 } 836 855 … … 892 911 } 893 912 913 int markObjects (Catalog *catalog, int Ncatalog) { 914 915 int i, n; 916 off_t j; 917 918 // How strongly do I own this object? 919 for (i = 0; i < Ncatalog; i++) { 920 for (j = 0; j < catalog[i].Naverage; j++) { 921 int nOwn = 0; 922 int m = catalog[i].averageT[j].measureOffset; 923 for (n = 0; n < catalog[i].averageT[j].Nmeasure; n++) { 924 if (!catalog[i].measureT[m+n].myDet) continue; 925 nOwn ++; 926 } 927 catalog[i].averageT[j].nOwn = nOwn; 928 } 929 } 930 return TRUE; 931 } 932 933 int dumpObjects (char *filename, Catalog *catalog, int Ncatalog) { 934 935 int i, n; 936 off_t j; 937 938 FILE *ftest = fopen (filename, "w"); 939 940 for (i = 0; i < Ncatalog; i++) { 941 for (j = 0; j < catalog[i].Naverage; j++) { 942 int m = catalog[i].averageT[j].measureOffset; 943 for (n = 0; n < catalog[i].averageT[j].Nmeasure; n++) { 944 fprintf (ftest, "%08x %08x %10.6f %10.6f %3d %1d\n", catalog[i].averageT[j].catID, catalog[i].averageT[j].objID, catalog[i].averageT[j].R, catalog[i].averageT[j].D, catalog[i].averageT[j].Nmeasure, catalog[i].measureT[m+n].myDet); 945 } 946 } 947 } 948 fclose (ftest); 949 return TRUE; 950 } 951 894 952 void clean_stars (Catalog *catalog, int Ncatalog) { 895 953 896 954 int i, j, Ndel, Nave, Ntot, mark, Ns, Nscat, Nchi, Nnan; 897 float dM , Xm;898 double Chisq,MaxScatter, MaxChisq;955 float dM; 956 double MaxScatter, MaxChisq; 899 957 double *xlist, *slist, *dlist; 900 958 … … 923 981 for (j = 0; j < catalog[i].Naverage; j++) { 924 982 if ( catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD ) continue; 925 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm; 926 if (Xm == -1) continue; 927 Chisq = pow (10.0, 0.01*Xm); 928 xlist[Ntot] = Chisq; 983 float Mchisq = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq; 984 if (isnan(Mchisq)) continue; 985 xlist[Ntot] = Mchisq; 929 986 slist[Ntot] = catalog[i].secfilt[Nsecfilt*j+Nsec].dM; 930 987 dlist[Ntot] = 1; … … 944 1001 for (j = 0; j < catalog[i].Naverage; j++) { 945 1002 dM = catalog[i].secfilt[Nsecfilt*j+Nsec].dM; 946 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm; 947 Chisq = pow (10.0, 0.01*Xm); 948 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); 949 1005 if (mark) { 950 1006 catalog[i].secfilt[Nsecfilt*j+Nsec].flags |= ID_STAR_POOR; 951 1007 Ndel ++; 952 if (dM > MaxScatter) { Nscat ++; }953 if ( Xm == NAN_S_SHORT){ Nnan ++; }954 if ( Chisq > MaxChisq) { Nchi ++; }1008 if (dM > MaxScatter) { Nscat ++; } 1009 if (isnan(Mchisq)) { Nnan ++; } 1010 if (Mchisq > MaxChisq) { Nchi ++; } 955 1011 } else { 956 1012 catalog[i].secfilt[Nsecfilt*j+Nsec].flags &= ~ID_STAR_POOR; … … 1017 1073 1018 1074 /* on final processing, skip stars already measured */ 1019 if (final && catalog[i].found [Nsecfilt*j + Nsec]) continue;1075 if (final && catalog[i].found_t[Nsecfilt*j + Nsec]) continue; 1020 1076 1021 1077 /* skip bad stars to prevent them from becoming good (on inner sample) */ … … 1038 1094 if (isnan(Mgrid)) { Ngrid ++; continue; } 1039 1095 1040 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt] );1096 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt], MAG_CLASS_PSF); 1041 1097 list[N] = Msys - Mcal - Mmos - Mgrid; 1042 1098 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); … … 1083 1139 if (isnan(Mgrid)) continue; 1084 1140 1085 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt] );1141 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt], MAG_CLASS_PSF); 1086 1142 list[N] = Msys - Mcal - Mmos - Mgrid; 1087 1143 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); … … 1178 1234 1179 1235 off_t j, Ntot; 1180 int i, n , Xm;1236 int i, n; 1181 1237 double *list, *dlist; 1182 1238 StatType stats; … … 1199 1255 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 1200 1256 1201 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm;1202 if ( Xm == NAN_S_SHORT) continue;1203 list[n] = pow (10.0, 0.01*Xm);1257 float Mchisq = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq; 1258 if (isnan(Mchisq)) continue; 1259 list[n] = Mchisq; 1204 1260 dlist[n] = 1; 1205 1261 n++; … … 1322 1378 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 1323 1379 xlist[N] = catalog[i].secfilt[Nsecfilt*j+Nsec].M; 1324 value = catalog[i].secfilt[Nsecfilt*j+Nsec]. Xm;1325 if ( value == NAN_S_SHORT) continue;1326 ylist[N] = 0.01*value;1380 value = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq; 1381 if (isnan(value)) continue; 1382 ylist[N] = value; 1327 1383 N++; 1328 1384 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/args.c
r35806 r37067 1 1 # include "relphot.h" 2 2 3 intargs (int argc, char **argv) {3 RelphotMode args (int argc, char **argv) { 4 4 5 5 int N; 6 6 double trange; 7 8 /* define time */ 9 TimeSelect = FALSE; 10 if ((N = get_argument (argc, argv, "-time"))) { 11 remove_argument (N, &argc, argv); 12 if (!ohana_str_to_time (argv[N], &TSTART)) { 13 fprintf (stderr, "ERROR: syntax error\n"); 14 return (MODE_ERROR); 15 } 16 remove_argument (N, &argc, argv); 17 if (!ohana_str_to_dtime (argv[N], &trange)) { 18 if (!ohana_str_to_time (argv[N], &TSTOP)) { 19 fprintf (stderr, "ERROR: syntax error\n"); 20 return (MODE_ERROR); 21 } 22 } else { 23 if (trange < 0) { 24 trange = fabs (trange); 25 TSTOP = TSTART; 26 TSTART -= trange; 27 } else { 28 TSTOP = TSTART + trange; 29 } 30 } 31 remove_argument (N, &argc, argv); 32 TimeSelect = TRUE; 33 } 34 35 /* specify portion of the sky */ 36 UserPatch.Rmin = 0; 37 UserPatch.Rmax = 360; 38 UserPatch.Dmin = -90; 39 UserPatch.Dmax = +90; 40 if ((N = get_argument (argc, argv, "-region"))) { 41 remove_argument (N, &argc, argv); 42 UserPatch.Rmin = atof (argv[N]); 43 remove_argument (N, &argc, argv); 44 UserPatch.Rmax = atof (argv[N]); 45 remove_argument (N, &argc, argv); 46 UserPatch.Dmin = atof (argv[N]); 47 remove_argument (N, &argc, argv); 48 UserPatch.Dmax = atof (argv[N]); 49 remove_argument (N, &argc, argv); 50 } 51 52 /* specify region file by name (eg n0000/0000.00) */ 53 UserCatalog = NULL; 54 if ((N = get_argument (argc, argv, "-catalog"))) { 55 remove_argument (N, &argc, argv); 56 UserCatalog = strcreate (argv[N]); 57 remove_argument (N, &argc, argv); 58 } 59 60 USE_BASIC_CHECK = FALSE; 61 if ((N = get_argument (argc, argv, "-basic-image-search"))) { 62 remove_argument (N, &argc, argv); 63 USE_BASIC_CHECK = TRUE; 64 } 65 66 USE_FULL_OVERLAP = TRUE; 67 if ((N = get_argument (argc, argv, "-sloppy-image-overlap"))) { 68 remove_argument (N, &argc, argv); 69 USE_FULL_OVERLAP = FALSE; 70 } 71 72 SET_MREL_VERSION = 1; 73 if ((N = get_argument (argc, argv, "-set-mrel-version"))) { 74 remove_argument (N, &argc, argv); 75 SET_MREL_VERSION = atof(argv[N]); 76 remove_argument (N, &argc, argv); 77 } 78 79 VERBOSE = VERBOSE2 = FALSE; 80 if ((N = get_argument (argc, argv, "-v"))) { 81 VERBOSE = TRUE; 82 remove_argument (N, &argc, argv); 83 } 84 if ((N = get_argument (argc, argv, "-vv"))) { 85 VERBOSE2 = VERBOSE = TRUE; 86 remove_argument (N, &argc, argv); 87 } 88 89 NTHREADS = 0; 90 if ((N = get_argument (argc, argv, "-threads"))) { 91 remove_argument (N, &argc, argv); 92 NTHREADS = atof (argv[N]); 93 remove_argument (N, &argc, argv); 94 } 95 96 // XXX for the moment, make this selection manual. it needs to be automatic 97 // based on the state of the SkyTable 98 HOST_ID = 0; 99 PARALLEL = FALSE; 100 if ((N = get_argument (argc, argv, "-parallel"))) { 101 PARALLEL = TRUE; 102 remove_argument (N, &argc, argv); 103 } 104 // this is a test mode : rather than launching the remote jobs and waiting for completion, 105 // relphot will simply list the remote command and wait for the user to signal completion 106 PARALLEL_MANUAL = FALSE; 107 if ((N = get_argument (argc, argv, "-parallel-manual"))) { 108 PARALLEL = TRUE; // -parallel-manual implies -parallel 109 PARALLEL_MANUAL = TRUE; 110 remove_argument (N, &argc, argv); 111 } 112 // this is a test mode : rather than launching the relphot_client jobs remotely, they are 113 // run in serial via 'system' 114 PARALLEL_SERIAL = FALSE; 115 if ((N = get_argument (argc, argv, "-parallel-serial"))) { 116 if (PARALLEL_MANUAL) { 117 fprintf (stderr, "ERROR: cannot mix -parallel-manual and -parallel-serial\n"); 118 exit (1); 119 } 120 PARALLEL = TRUE; // -parallel-serial implies -parallel 121 PARALLEL_SERIAL = TRUE; 122 remove_argument (N, &argc, argv); 123 } 124 125 PLOTSTUFF = FALSE; 126 if ((N = get_argument (argc, argv, "-plot"))) { 127 PLOTSTUFF = TRUE; 128 remove_argument (N, &argc, argv); 129 } 130 131 PLOTDELAY = 500000; 132 if ((N = get_argument (argc, argv, "-plotdelay"))) { 133 remove_argument (N, &argc, argv); 134 PLOTDELAY = 1e6*atof(argv[N]); 135 PLOTSTUFF = TRUE; // always turn on plotting if i request a plot delay 136 remove_argument (N, &argc, argv); 137 } 138 139 if ((N = get_argument (argc, argv, "-outroot"))) { 140 remove_argument (N, &argc, argv); 141 OUTROOT = strcreate (argv[N]); 142 remove_argument (N, &argc, argv); 143 } else { 144 OUTROOT = strcreate ("relphot"); 145 } 146 147 strcpy (STATMODE, "WT_MEAN"); 148 if ((N = get_argument (argc, argv, "-statmode"))) { 149 remove_argument (N, &argc, argv); 150 strcpy (STATMODE, argv[N]); 151 remove_argument (N, &argc, argv); 152 } 153 154 NLOOP = 8; 155 if ((N = get_argument (argc, argv, "-n"))) { 156 remove_argument (N, &argc, argv); 157 NLOOP = atof (argv[N]); 158 remove_argument (N, &argc, argv); 159 } 160 if ((N = get_argument (argc, argv, "-nloop"))) { 161 remove_argument (N, &argc, argv); 162 NLOOP = atof (argv[N]); 163 remove_argument (N, &argc, argv); 164 } 165 166 NGRID = 8; 167 if ((N = get_argument (argc, argv, "-ngrid"))) { 168 remove_argument (N, &argc, argv); 169 NGRID = atof (argv[N]); 170 remove_argument (N, &argc, argv); 171 } 172 173 RESET = FALSE; 174 if ((N = get_argument (argc, argv, "-reset"))) { 175 remove_argument (N, &argc, argv); 176 RESET = TRUE; 177 } 178 179 RESET_ZEROPTS = FALSE; 180 if ((N = get_argument (argc, argv, "-reset-zpts"))) { 181 remove_argument (N, &argc, argv); 182 RESET_ZEROPTS = TRUE; 183 } 184 185 UPDATE = FALSE; 186 if ((N = get_argument (argc, argv, "-update"))) { 187 remove_argument (N, &argc, argv); 188 UPDATE = TRUE; 189 } 190 191 UPDATE_CATFORMAT = NULL; 192 if ((N = get_argument (argc, argv, "-update-catformat"))) { 193 remove_argument (N, &argc, argv); 194 UPDATE_CATFORMAT = strcreate (argv[N]); 195 remove_argument (N, &argc, argv); 196 } 197 198 SAVE_IMAGE_UPDATES = TRUE; 199 if ((N = get_argument (argc, argv, "-skip-image-updates"))) { 200 remove_argument (N, &argc, argv); 201 SAVE_IMAGE_UPDATES = FALSE; 202 } 203 204 MaxDensityUse = FALSE; 205 if ((N = get_argument (argc, argv, "-max-density"))) { 206 remove_argument (N, &argc, argv); 207 MaxDensityValue = atof(argv[N]); 208 remove_argument (N, &argc, argv); 209 MaxDensityUse = TRUE; 210 } 211 212 CLOUD_TOLERANCE = 0.02; 213 if ((N = get_argument (argc, argv, "-cloud-limit"))) { 214 remove_argument (N, &argc, argv); 215 CLOUD_TOLERANCE = atof(argv[N]); 216 remove_argument (N, &argc, argv); 217 } 218 219 // XXX should we load a tree from CATDIR by default? 220 // NOTE: a given catdir needs an appropriate boundary tree 221 BOUNDARY_TREE = NULL; 222 if ((N = get_argument (argc, argv, "-boundary-tree"))) { 223 remove_argument (N, &argc, argv); 224 BOUNDARY_TREE = strcreate(argv[N]); 225 load_tess (BOUNDARY_TREE); 226 remove_argument (N, &argc, argv); 227 } 228 229 SHOW_PARAMS = TRUE; 230 if ((N = get_argument (argc, argv, "-params"))) { 231 remove_argument (N, &argc, argv); 232 SHOW_PARAMS = FALSE; 233 } 234 235 PlotMmin = 10.0; PlotMmax = 20.0; PlotdMmin = -1.0; PlotdMmax = 1.0; 236 if ((N = get_argument (argc, argv, "-plrange"))) { 237 remove_argument (N, &argc, argv); 238 PlotMmin = atof (argv[N]); 239 remove_argument (N, &argc, argv); 240 PlotMmax = atof (argv[N]); 241 remove_argument (N, &argc, argv); 242 PlotdMmin = atof (argv[N]); 243 remove_argument (N, &argc, argv); 244 PlotdMmax = atof (argv[N]); 245 remove_argument (N, &argc, argv); 246 } 247 248 /* XXX this argument used to do two things: specify the camera name and tell the analysis to 249 calculate a common zero point for a single mosaic. I've moved the MOSAICNAME concept into the 250 config system, but need to use this argument to specify that the mosaic zeropoints should be 251 calculated. */ 252 MOSAIC_ZEROPT = FALSE; 253 if ((N = get_argument (argc, argv, "-mosaic"))) { 254 remove_argument (N, &argc, argv); 255 MOSAIC_ZEROPT = TRUE; 256 if (!strcasecmp (MOSAICNAME, "none")) { 257 fprintf (stderr, "mosaic astrometry selected by MOSAICNAME not defined\n"); 258 exit (2); 259 } 260 } 261 262 FREEZE_IMAGES = FALSE; 263 if ((N = get_argument (argc, argv, "-imfreeze"))) { 264 remove_argument (N, &argc, argv); 265 FREEZE_IMAGES = TRUE; 266 } 267 268 FREEZE_MOSAICS = FALSE; 269 if ((N = get_argument (argc, argv, "-mosfreeze"))) { 270 remove_argument (N, &argc, argv); 271 FREEZE_MOSAICS = TRUE; 272 } 273 274 // USE_GRID is not valid for all cases, probably should be its own mode... 275 USE_GRID = FALSE; 276 if ((N = get_argument (argc, argv, "-grid"))) { 277 remove_argument (N, &argc, argv); 278 USE_GRID = TRUE; 279 } 280 281 KEEP_UBERCAL = TRUE; 282 if ((N = get_argument (argc, argv, "-reset-ubercal"))) { 283 remove_argument (N, &argc, argv); 284 KEEP_UBERCAL = FALSE; 285 } 286 287 MIN_ERROR = 0.001; 288 if ((N = get_argument (argc, argv, "-minerror"))) { 289 remove_argument (N, &argc, argv); 290 MIN_ERROR = atof (argv[N]); 291 remove_argument (N, &argc, argv); 292 /* require MIN_ERROR > 0 */ 293 } 294 295 AreaSelect = FALSE; 296 if ((N = get_argument (argc, argv, "-area"))) { 297 remove_argument (N, &argc, argv); 298 AreaXmin = atof (argv[N]); 299 remove_argument (N, &argc, argv); 300 AreaXmax = atof (argv[N]); 301 remove_argument (N, &argc, argv); 302 AreaYmin = atof (argv[N]); 303 remove_argument (N, &argc, argv); 304 AreaYmax = atof (argv[N]); 305 remove_argument (N, &argc, argv); 306 AreaSelect = TRUE; 307 } 308 309 ImagSelect = FALSE; 310 if ((N = get_argument (argc, argv, "-instmag"))) { 311 remove_argument (N, &argc, argv); 312 ImagMin = atof (argv[N]); 313 remove_argument (N, &argc, argv); 314 ImagMax = atof (argv[N]); 315 remove_argument (N, &argc, argv); 316 ImagSelect = TRUE; 317 } 318 319 DophotSelect = FALSE; 320 if ((N = get_argument (argc, argv, "-dophot"))) { 321 remove_argument (N, &argc, argv); 322 DophotValue = atof (argv[N]); 323 remove_argument (N, &argc, argv); 324 DophotSelect = TRUE; 325 } 326 327 SyntheticPhotometry = FALSE; 328 if ((N = get_argument (argc, argv, "-synthphot"))) { 329 remove_argument (N, &argc, argv); 330 SyntheticPhotometry = TRUE; 331 init_synthetic_mags(); 332 } 333 334 refPhotcode = NULL; 335 if ((N = get_argument (argc, argv, "-refcode"))) { 336 remove_argument (N, &argc, argv); 337 refPhotcode = GetPhotcodebyName (argv[N]); 338 if (!refPhotcode) { 339 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]); 340 exit (1); 341 } 342 remove_argument (N, &argc, argv); 343 } 344 345 REGION_FILE = NULL; 346 if ((N = get_argument (argc, argv, "-region-hosts"))) { 347 remove_argument (N, &argc, argv); 348 REGION_FILE = strcreate (argv[N]); 349 remove_argument (N, &argc, argv); 350 } 351 352 REGION_HOST_ID = 0; 353 if ((N = get_argument (argc, argv, "-region-hostID"))) { 354 remove_argument (N, &argc, argv); 355 REGION_HOST_ID = atoi (argv[N]); 356 remove_argument (N, &argc, argv); 357 } 358 359 RelphotMode mode = MODE_ERROR; 360 if ((N = get_argument (argc, argv, "-images"))) { 361 remove_argument (N, &argc, argv); 362 mode = UPDATE_IMAGES; 363 } 364 if ((N = get_argument (argc, argv, "-averages"))) { 365 remove_argument (N, &argc, argv); 366 mode = UPDATE_AVERAGES; 367 } 368 if ((N = get_argument (argc, argv, "-apply-offsets"))) { 369 remove_argument (N, &argc, argv); 370 mode = APPLY_OFFSETS; 371 } 372 IMAGE_TABLE = NULL; 373 if ((N = get_argument (argc, argv, "-parallel-images"))) { 374 remove_argument (N, &argc, argv); 375 mode = PARALLEL_IMAGES; 376 if (N >= argc) relphot_usage(); 377 IMAGE_TABLE = strcreate (argv[N]); 378 remove_argument (N, &argc, argv); 379 if (!REGION_FILE) relphot_usage(); 380 } 381 382 PARALLEL_REGIONS_MANUAL = FALSE; 383 if ((N = get_argument (argc, argv, "-parallel-regions"))) { 384 remove_argument (N, &argc, argv); 385 mode = PARALLEL_REGIONS; 386 if (!REGION_FILE) relphot_usage(); 387 if ((N = get_argument (argc, argv, "-parallel-regions-manual"))) { 388 remove_argument (N, &argc, argv); 389 PARALLEL_REGIONS_MANUAL = TRUE; 390 } 391 } 392 393 switch (mode) { 394 case UPDATE_AVERAGES: 395 if (argc != 1) relphot_usage(); 396 break; 397 398 case UPDATE_IMAGES: 399 case PARALLEL_IMAGES: 400 case PARALLEL_REGIONS: 401 PhotcodeList = strcreate (argv[1]); 402 photcodes = ParsePhotcodeList (PhotcodeList, &Nphotcodes, TRUE); // require SEC photcodes 403 remove_argument (1, &argc, argv); 404 break; 405 406 default: 407 fprintf (stderr, "no valid mode selected\n"); 408 relphot_usage(); 409 break; 410 } 411 if (argc != 1) relphot_usage (); 412 413 return mode; 414 } 415 416 int args_client (int argc, char **argv) { 417 418 int N; 419 double trange; 420 421 // by definition, the client is not parallel 422 PARALLEL = FALSE; 423 PARALLEL_MANUAL = FALSE; 424 PARALLEL_SERIAL = FALSE; 425 426 HOST_ID = 0; 427 if ((N = get_argument (argc, argv, "-hostID"))) { 428 remove_argument (N, &argc, argv); 429 HOST_ID = atoi (argv[N]); 430 remove_argument (N, &argc, argv); 431 } 432 if (!HOST_ID) relphot_client_usage(); 433 434 HOSTDIR = NULL; 435 if ((N = get_argument (argc, argv, "-hostdir"))) { 436 remove_argument (N, &argc, argv); 437 HOSTDIR = strcreate (argv[N]); 438 remove_argument (N, &argc, argv); 439 } 440 if (!HOSTDIR) relphot_client_usage(); 441 442 IMAGES = NULL; // used in -update mode 443 BCATALOG = NULL; // used in -load mode 444 MODE = MODE_NONE; 445 if ((N = get_argument (argc, argv, "-load"))) { 446 MODE = MODE_LOAD; 447 remove_argument (N, &argc, argv); 448 BCATALOG = strcreate (argv[N]); 449 remove_argument (N, &argc, argv); 450 } 451 if ((N = get_argument (argc, argv, "-update-catalogs"))) { 452 if (MODE) { 453 fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n"); 454 relphot_client_usage(); 455 } 456 MODE = MODE_UPDATE; 457 remove_argument (N, &argc, argv); 458 IMAGES = strcreate (argv[N]); 459 remove_argument (N, &argc, argv); 460 } 461 if ((N = get_argument (argc, argv, "-update-objects"))) { 462 if (MODE) { 463 fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n"); 464 relphot_client_usage(); 465 } 466 MODE = MODE_UPDATE_OBJECTS; 467 remove_argument (N, &argc, argv); 468 } 469 if (!MODE) relphot_client_usage(); 470 471 strcpy (STATMODE, "WT_MEAN"); 472 if ((N = get_argument (argc, argv, "-statmode"))) { 473 remove_argument (N, &argc, argv); 474 strcpy (STATMODE, argv[N]); 475 remove_argument (N, &argc, argv); 476 } 477 478 BOUNDARY_TREE = NULL; 479 if ((N = get_argument (argc, argv, "-boundary-tree"))) { 480 remove_argument (N, &argc, argv); 481 BOUNDARY_TREE = strcreate(argv[N]); 482 load_tess (BOUNDARY_TREE); 483 remove_argument (N, &argc, argv); 484 } 485 486 /* specify portion of the sky */ 487 UserPatch.Rmin = 0; 488 UserPatch.Rmax = 360; 489 UserPatch.Dmin = -90; 490 UserPatch.Dmax = +90; 491 if ((N = get_argument (argc, argv, "-region"))) { 492 remove_argument (N, &argc, argv); 493 UserPatch.Rmin = atof (argv[N]); 494 remove_argument (N, &argc, argv); 495 UserPatch.Rmax = atof (argv[N]); 496 remove_argument (N, &argc, argv); 497 UserPatch.Dmin = atof (argv[N]); 498 remove_argument (N, &argc, argv); 499 UserPatch.Dmax = atof (argv[N]); 500 remove_argument (N, &argc, argv); 501 } 502 503 SET_MREL_VERSION = 1; 504 if ((N = get_argument (argc, argv, "-set-mrel-version"))) { 505 remove_argument (N, &argc, argv); 506 SET_MREL_VERSION = atof(argv[N]); 507 remove_argument (N, &argc, argv); 508 } 509 510 VERBOSE = VERBOSE2 = FALSE; 511 if ((N = get_argument (argc, argv, "-v"))) { 512 VERBOSE = TRUE; 513 remove_argument (N, &argc, argv); 514 } 515 if ((N = get_argument (argc, argv, "-vv"))) { 516 VERBOSE2 = VERBOSE = TRUE; 517 remove_argument (N, &argc, argv); 518 } 519 520 RESET = FALSE; 521 if ((N = get_argument (argc, argv, "-reset"))) { 522 remove_argument (N, &argc, argv); 523 RESET = TRUE; 524 } 525 526 RESET_ZEROPTS = FALSE; 527 if ((N = get_argument (argc, argv, "-reset-zpts"))) { 528 remove_argument (N, &argc, argv); 529 RESET_ZEROPTS = TRUE; 530 } 531 532 KEEP_UBERCAL = TRUE; 533 if ((N = get_argument (argc, argv, "-reset-ubercal"))) { 534 remove_argument (N, &argc, argv); 535 KEEP_UBERCAL = FALSE; 536 } 7 537 8 538 /* define time */ … … 33 563 } 34 564 35 /* specify portion of the sky */ 36 UserPatch.Rmin = 0; 37 UserPatch.Rmax = 360; 38 UserPatch.Dmin = -90; 39 UserPatch.Dmax = +90; 40 if ((N = get_argument (argc, argv, "-region"))) { 41 remove_argument (N, &argc, argv); 42 UserPatch.Rmin = atof (argv[N]); 43 remove_argument (N, &argc, argv); 44 UserPatch.Rmax = atof (argv[N]); 45 remove_argument (N, &argc, argv); 46 UserPatch.Dmin = atof (argv[N]); 47 remove_argument (N, &argc, argv); 48 UserPatch.Dmax = atof (argv[N]); 49 remove_argument (N, &argc, argv); 50 } 51 52 /* specify region file by name (eg n0000/0000.00) */ 53 UserCatalog = NULL; 54 if ((N = get_argument (argc, argv, "-catalog"))) { 55 remove_argument (N, &argc, argv); 56 UserCatalog = strcreate (argv[N]); 57 remove_argument (N, &argc, argv); 58 } 59 60 USE_BASIC_CHECK = FALSE; 61 if ((N = get_argument (argc, argv, "-basic-image-search"))) { 62 remove_argument (N, &argc, argv); 63 USE_BASIC_CHECK = TRUE; 64 } 65 66 USE_FULL_OVERLAP = TRUE; 67 if ((N = get_argument (argc, argv, "-sloppy-image-overlap"))) { 68 remove_argument (N, &argc, argv); 69 USE_FULL_OVERLAP = FALSE; 70 } 71 72 SET_MREL_VERSION = 1; 73 if ((N = get_argument (argc, argv, "-set-mrel-version"))) { 74 remove_argument (N, &argc, argv); 75 SET_MREL_VERSION = atof(argv[N]); 76 remove_argument (N, &argc, argv); 77 } 78 79 VERBOSE = VERBOSE2 = FALSE; 80 if ((N = get_argument (argc, argv, "-v"))) { 81 VERBOSE = TRUE; 82 remove_argument (N, &argc, argv); 83 } 84 if ((N = get_argument (argc, argv, "-vv"))) { 85 VERBOSE2 = VERBOSE = TRUE; 86 remove_argument (N, &argc, argv); 87 } 88 89 NTHREADS = 0; 90 if ((N = get_argument (argc, argv, "-threads"))) { 91 remove_argument (N, &argc, argv); 92 NTHREADS = atof (argv[N]); 93 remove_argument (N, &argc, argv); 94 } 95 96 // XXX for the moment, make this selection manual. it needs to be automatic 97 // based on the state of the SkyTable 98 HOST_ID = 0; 99 PARALLEL = FALSE; 100 if ((N = get_argument (argc, argv, "-parallel"))) { 101 PARALLEL = TRUE; 102 remove_argument (N, &argc, argv); 103 } 104 // this is a test mode : rather than launching the remote jobs and waiting for completion, 105 // relphot will simply list the remote command and wait for the user to signal completion 106 PARALLEL_MANUAL = FALSE; 107 if ((N = get_argument (argc, argv, "-parallel-manual"))) { 108 PARALLEL = TRUE; // -parallel-manual implies -parallel 109 PARALLEL_MANUAL = TRUE; 110 remove_argument (N, &argc, argv); 111 } 112 // this is a test mode : rather than launching the relphot_client jobs remotely, they are 113 // run in serial via 'system' 114 PARALLEL_SERIAL = FALSE; 115 if ((N = get_argument (argc, argv, "-parallel-serial"))) { 116 if (PARALLEL_MANUAL) { 117 fprintf (stderr, "ERROR: cannot mix -parallel-manual and -parallel-serial\n"); 118 exit (1); 119 } 120 PARALLEL = TRUE; // -parallel-serial implies -parallel 121 PARALLEL_SERIAL = TRUE; 122 remove_argument (N, &argc, argv); 123 } 124 125 PLOTSTUFF = FALSE; 126 if ((N = get_argument (argc, argv, "-plot"))) { 127 PLOTSTUFF = TRUE; 128 remove_argument (N, &argc, argv); 129 } 130 131 PLOTDELAY = 500000; 132 if ((N = get_argument (argc, argv, "-plotdelay"))) { 133 remove_argument (N, &argc, argv); 134 PLOTDELAY = 1e6*atof(argv[N]); 135 PLOTSTUFF = TRUE; // always turn on plotting if i request a plot delay 136 remove_argument (N, &argc, argv); 137 } 138 139 if ((N = get_argument (argc, argv, "-outroot"))) { 140 remove_argument (N, &argc, argv); 141 OUTROOT = strcreate (argv[N]); 142 remove_argument (N, &argc, argv); 143 } else { 144 OUTROOT = strcreate ("relphot"); 145 } 146 147 strcpy (STATMODE, "WT_MEAN"); 148 if ((N = get_argument (argc, argv, "-statmode"))) { 149 remove_argument (N, &argc, argv); 150 strcpy (STATMODE, argv[N]); 151 remove_argument (N, &argc, argv); 152 } 153 154 NLOOP = 8; 155 if ((N = get_argument (argc, argv, "-n"))) { 156 remove_argument (N, &argc, argv); 157 NLOOP = atof (argv[N]); 158 remove_argument (N, &argc, argv); 159 } 160 if ((N = get_argument (argc, argv, "-nloop"))) { 161 remove_argument (N, &argc, argv); 162 NLOOP = atof (argv[N]); 163 remove_argument (N, &argc, argv); 164 } 165 166 NGRID = 8; 167 if ((N = get_argument (argc, argv, "-ngrid"))) { 168 remove_argument (N, &argc, argv); 169 NGRID = atof (argv[N]); 170 remove_argument (N, &argc, argv); 171 } 172 173 RESET = FALSE; 174 if ((N = get_argument (argc, argv, "-reset"))) { 175 remove_argument (N, &argc, argv); 176 RESET = TRUE; 177 } 178 179 RESET_ZEROPTS = FALSE; 180 if ((N = get_argument (argc, argv, "-reset-zpts"))) { 181 remove_argument (N, &argc, argv); 182 RESET_ZEROPTS = TRUE; 183 } 565 566 MIN_ERROR = 0.001; 567 if ((N = get_argument (argc, argv, "-minerror"))) { 568 remove_argument (N, &argc, argv); 569 MIN_ERROR = atof (argv[N]); 570 remove_argument (N, &argc, argv); 571 /* require MIN_ERROR > 0 */ 572 } 184 573 185 574 UPDATE = FALSE; … … 196 585 } 197 586 198 SAVE_IMAGE_UPDATES = TRUE; 199 if ((N = get_argument (argc, argv, "-skip-image-updates"))) { 200 remove_argument (N, &argc, argv); 201 SAVE_IMAGE_UPDATES = FALSE; 587 AreaSelect = FALSE; 588 if ((N = get_argument (argc, argv, "-area"))) { 589 remove_argument (N, &argc, argv); 590 AreaXmin = atof (argv[N]); 591 remove_argument (N, &argc, argv); 592 AreaXmax = atof (argv[N]); 593 remove_argument (N, &argc, argv); 594 AreaYmin = atof (argv[N]); 595 remove_argument (N, &argc, argv); 596 AreaYmax = atof (argv[N]); 597 remove_argument (N, &argc, argv); 598 AreaSelect = TRUE; 599 } 600 601 SyntheticPhotometry = FALSE; 602 if ((N = get_argument (argc, argv, "-synthphot"))) { 603 remove_argument (N, &argc, argv); 604 SyntheticPhotometry = FALSE; 605 init_synthetic_mags(); 606 } 607 608 ImagSelect = FALSE; 609 if ((N = get_argument (argc, argv, "-instmag"))) { 610 remove_argument (N, &argc, argv); 611 ImagMin = atof (argv[N]); 612 remove_argument (N, &argc, argv); 613 ImagMax = atof (argv[N]); 614 remove_argument (N, &argc, argv); 615 ImagSelect = TRUE; 616 } 617 618 DophotSelect = FALSE; 619 if ((N = get_argument (argc, argv, "-dophot"))) { 620 remove_argument (N, &argc, argv); 621 DophotValue = atof (argv[N]); 622 remove_argument (N, &argc, argv); 623 DophotSelect = TRUE; 202 624 } 203 625 … … 210 632 } 211 633 212 CLOUD_TOLERANCE = 0.02; 213 if ((N = get_argument (argc, argv, "-cloud-limit"))) { 214 remove_argument (N, &argc, argv); 215 CLOUD_TOLERANCE = atof(argv[N]); 216 remove_argument (N, &argc, argv); 217 } 218 219 BOUNDARY_TREE = NULL; 220 if ((N = get_argument (argc, argv, "-boundary-tree"))) { 221 remove_argument (N, &argc, argv); 222 BOUNDARY_TREE = strcreate(argv[N]); 223 load_tree (BOUNDARY_TREE); 224 remove_argument (N, &argc, argv); 225 } 226 227 SHOW_PARAMS = FALSE; 228 if ((N = get_argument (argc, argv, "-params"))) { 229 remove_argument (N, &argc, argv); 230 SHOW_PARAMS = TRUE; 231 } 232 233 PlotMmin = 10.0; PlotMmax = 20.0; PlotdMmin = -1.0; PlotdMmax = 1.0; 234 if ((N = get_argument (argc, argv, "-plrange"))) { 235 remove_argument (N, &argc, argv); 236 PlotMmin = atof (argv[N]); 237 remove_argument (N, &argc, argv); 238 PlotMmax = atof (argv[N]); 239 remove_argument (N, &argc, argv); 240 PlotdMmin = atof (argv[N]); 241 remove_argument (N, &argc, argv); 242 PlotdMmax = atof (argv[N]); 243 remove_argument (N, &argc, argv); 244 } 245 246 /* XXX this argument used to do two things: specify the camera name and tell the analysis to 247 calculate a common zero point for a single mosaic. I've moved the MOSAICNAME concept into the 248 config system, but need to use this argument to specify that the mosaic zeropoints should be 249 calculated. */ 250 MOSAIC_ZEROPT = FALSE; 251 if ((N = get_argument (argc, argv, "-mosaic"))) { 252 remove_argument (N, &argc, argv); 253 MOSAIC_ZEROPT = TRUE; 254 if (!strcasecmp (MOSAICNAME, "none")) { 255 fprintf (stderr, "mosaic astrometry selected by MOSAICNAME not defined\n"); 256 exit (2); 257 } 258 } 259 260 FREEZE_IMAGES = FALSE; 261 if ((N = get_argument (argc, argv, "-imfreeze"))) { 262 remove_argument (N, &argc, argv); 263 FREEZE_IMAGES = TRUE; 264 } 265 266 FREEZE_MOSAICS = FALSE; 267 if ((N = get_argument (argc, argv, "-mosfreeze"))) { 268 remove_argument (N, &argc, argv); 269 FREEZE_MOSAICS = TRUE; 270 } 271 272 USE_GRID = FALSE; 273 if ((N = get_argument (argc, argv, "-grid"))) { 274 remove_argument (N, &argc, argv); 275 USE_GRID = TRUE; 276 } 277 278 KEEP_UBERCAL = TRUE; 279 if ((N = get_argument (argc, argv, "-reset-ubercal"))) { 280 remove_argument (N, &argc, argv); 281 KEEP_UBERCAL = FALSE; 282 } 283 284 MIN_ERROR = 0.001; 285 if ((N = get_argument (argc, argv, "-minerror"))) { 286 remove_argument (N, &argc, argv); 287 MIN_ERROR = atof (argv[N]); 288 remove_argument (N, &argc, argv); 289 /* require MIN_ERROR > 0 */ 290 } 291 292 AreaSelect = FALSE; 293 if ((N = get_argument (argc, argv, "-area"))) { 294 remove_argument (N, &argc, argv); 295 AreaXmin = atof (argv[N]); 296 remove_argument (N, &argc, argv); 297 AreaXmax = atof (argv[N]); 298 remove_argument (N, &argc, argv); 299 AreaYmin = atof (argv[N]); 300 remove_argument (N, &argc, argv); 301 AreaYmax = atof (argv[N]); 302 remove_argument (N, &argc, argv); 303 AreaSelect = TRUE; 304 } 305 306 ImagSelect = FALSE; 307 if ((N = get_argument (argc, argv, "-instmag"))) { 308 remove_argument (N, &argc, argv); 309 ImagMin = atof (argv[N]); 310 remove_argument (N, &argc, argv); 311 ImagMax = atof (argv[N]); 312 remove_argument (N, &argc, argv); 313 ImagSelect = TRUE; 314 } 315 316 DophotSelect = FALSE; 317 if ((N = get_argument (argc, argv, "-dophot"))) { 318 remove_argument (N, &argc, argv); 319 DophotValue = atof (argv[N]); 320 remove_argument (N, &argc, argv); 321 DophotSelect = TRUE; 322 } 323 324 SyntheticPhotometry = FALSE; 325 if ((N = get_argument (argc, argv, "-synthphot"))) { 326 remove_argument (N, &argc, argv); 327 SyntheticPhotometry = TRUE; 328 init_synthetic_mags(); 329 } 330 331 refPhotcode = NULL; 332 if ((N = get_argument (argc, argv, "-refcode"))) { 333 remove_argument (N, &argc, argv); 334 refPhotcode = GetPhotcodebyName (argv[N]); 335 if (!refPhotcode) { 336 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]); 337 exit (1); 338 } 339 remove_argument (N, &argc, argv); 340 } 341 342 UpdateAverages = FALSE; 343 if ((N = get_argument (argc, argv, "-averages"))) { 344 remove_argument (N, &argc, argv); 345 UpdateAverages = TRUE; 346 } 347 348 ApplyOffsets = FALSE; 349 if ((N = get_argument (argc, argv, "-apply-offsets"))) { 350 remove_argument (N, &argc, argv); 351 ApplyOffsets = TRUE; 352 } 353 354 if (UpdateAverages && (argc == 1)) return TRUE; 355 if (argc != 2) relphot_usage (); 634 if ((MODE == MODE_UPDATE_OBJECTS) && (argc == 1)) return TRUE; 635 if (argc != 2) relphot_client_usage (); 356 636 357 637 return TRUE; 358 638 } 359 639 360 int args_client (int argc, char **argv) {361 362 int N;363 double trange;364 365 // by definition, the client is not parallel366 PARALLEL = FALSE;367 PARALLEL_MANUAL = FALSE;368 PARALLEL_SERIAL = FALSE;369 370 HOST_ID = 0;371 if ((N = get_argument (argc, argv, "-hostID"))) {372 remove_argument (N, &argc, argv);373 HOST_ID = atoi (argv[N]);374 remove_argument (N, &argc, argv);375 }376 if (!HOST_ID) relphot_client_usage();377 378 HOSTDIR = NULL;379 if ((N = get_argument (argc, argv, "-hostdir"))) {380 remove_argument (N, &argc, argv);381 HOSTDIR = strcreate (argv[N]);382 remove_argument (N, &argc, argv);383 }384 if (!HOSTDIR) relphot_client_usage();385 386 IMAGES = NULL; // used in -update mode387 BCATALOG = NULL; // used in -load mode388 MODE = MODE_NONE;389 if ((N = get_argument (argc, argv, "-load"))) {390 MODE = MODE_LOAD;391 remove_argument (N, &argc, argv);392 BCATALOG = strcreate (argv[N]);393 remove_argument (N, &argc, argv);394 }395 if ((N = get_argument (argc, argv, "-update-catalogs"))) {396 if (MODE) {397 fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n");398 relphot_client_usage();399 }400 MODE = MODE_UPDATE;401 remove_argument (N, &argc, argv);402 IMAGES = strcreate (argv[N]);403 remove_argument (N, &argc, argv);404 }405 if ((N = get_argument (argc, argv, "-update-objects"))) {406 if (MODE) {407 fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n");408 relphot_client_usage();409 }410 MODE = MODE_UPDATE_OBJECTS;411 remove_argument (N, &argc, argv);412 }413 if (!MODE) relphot_client_usage();414 415 strcpy (STATMODE, "WT_MEAN");416 if ((N = get_argument (argc, argv, "-statmode"))) {417 remove_argument (N, &argc, argv);418 strcpy (STATMODE, argv[N]);419 remove_argument (N, &argc, argv);420 }421 422 BOUNDARY_TREE = NULL;423 if ((N = get_argument (argc, argv, "-boundary-tree"))) {424 remove_argument (N, &argc, argv);425 BOUNDARY_TREE = strcreate(argv[N]);426 load_tree (BOUNDARY_TREE);427 remove_argument (N, &argc, argv);428 }429 430 /* specify portion of the sky */431 UserPatch.Rmin = 0;432 UserPatch.Rmax = 360;433 UserPatch.Dmin = -90;434 UserPatch.Dmax = +90;435 if ((N = get_argument (argc, argv, "-region"))) {436 remove_argument (N, &argc, argv);437 UserPatch.Rmin = atof (argv[N]);438 remove_argument (N, &argc, argv);439 UserPatch.Rmax = atof (argv[N]);440 remove_argument (N, &argc, argv);441 UserPatch.Dmin = atof (argv[N]);442 remove_argument (N, &argc, argv);443 UserPatch.Dmax = atof (argv[N]);444 remove_argument (N, &argc, argv);445 }446 447 SET_MREL_VERSION = 1;448 if ((N = get_argument (argc, argv, "-set-mrel-version"))) {449 remove_argument (N, &argc, argv);450 SET_MREL_VERSION = atof(argv[N]);451 remove_argument (N, &argc, argv);452 }453 454 VERBOSE = VERBOSE2 = FALSE;455 if ((N = get_argument (argc, argv, "-v"))) {456 VERBOSE = TRUE;457 remove_argument (N, &argc, argv);458 }459 if ((N = get_argument (argc, argv, "-vv"))) {460 VERBOSE2 = VERBOSE = TRUE;461 remove_argument (N, &argc, argv);462 }463 464 RESET = FALSE;465 if ((N = get_argument (argc, argv, "-reset"))) {466 remove_argument (N, &argc, argv);467 RESET = TRUE;468 }469 470 RESET_ZEROPTS = FALSE;471 if ((N = get_argument (argc, argv, "-reset-zpts"))) {472 remove_argument (N, &argc, argv);473 RESET_ZEROPTS = TRUE;474 }475 476 KEEP_UBERCAL = TRUE;477 if ((N = get_argument (argc, argv, "-reset-ubercal"))) {478 remove_argument (N, &argc, argv);479 KEEP_UBERCAL = FALSE;480 }481 482 /* define time */483 TimeSelect = FALSE;484 if ((N = get_argument (argc, argv, "-time"))) {485 remove_argument (N, &argc, argv);486 if (!ohana_str_to_time (argv[N], &TSTART)) {487 fprintf (stderr, "ERROR: syntax error\n");488 return (FALSE);489 }490 remove_argument (N, &argc, argv);491 if (!ohana_str_to_dtime (argv[N], &trange)) {492 if (!ohana_str_to_time (argv[N], &TSTOP)) {493 fprintf (stderr, "ERROR: syntax error\n");494 return (FALSE);495 }496 } else {497 if (trange < 0) {498 trange = fabs (trange);499 TSTOP = TSTART;500 TSTART -= trange;501 } else {502 TSTOP = TSTART + trange;503 }504 }505 remove_argument (N, &argc, argv);506 TimeSelect = TRUE;507 }508 509 510 MIN_ERROR = 0.001;511 if ((N = get_argument (argc, argv, "-minerror"))) {512 remove_argument (N, &argc, argv);513 MIN_ERROR = atof (argv[N]);514 remove_argument (N, &argc, argv);515 /* require MIN_ERROR > 0 */516 }517 518 UPDATE = FALSE;519 if ((N = get_argument (argc, argv, "-update"))) {520 remove_argument (N, &argc, argv);521 UPDATE = TRUE;522 }523 524 UPDATE_CATFORMAT = NULL;525 if ((N = get_argument (argc, argv, "-update-catformat"))) {526 remove_argument (N, &argc, argv);527 UPDATE_CATFORMAT = strcreate (argv[N]);528 remove_argument (N, &argc, argv);529 }530 531 AreaSelect = FALSE;532 if ((N = get_argument (argc, argv, "-area"))) {533 remove_argument (N, &argc, argv);534 AreaXmin = atof (argv[N]);535 remove_argument (N, &argc, argv);536 AreaXmax = atof (argv[N]);537 remove_argument (N, &argc, argv);538 AreaYmin = atof (argv[N]);539 remove_argument (N, &argc, argv);540 AreaYmax = atof (argv[N]);541 remove_argument (N, &argc, argv);542 AreaSelect = TRUE;543 }544 545 SyntheticPhotometry = FALSE;546 if ((N = get_argument (argc, argv, "-synthphot"))) {547 remove_argument (N, &argc, argv);548 SyntheticPhotometry = FALSE;549 init_synthetic_mags();550 }551 552 ImagSelect = FALSE;553 if ((N = get_argument (argc, argv, "-instmag"))) {554 remove_argument (N, &argc, argv);555 ImagMin = atof (argv[N]);556 remove_argument (N, &argc, argv);557 ImagMax = atof (argv[N]);558 remove_argument (N, &argc, argv);559 ImagSelect = TRUE;560 }561 562 DophotSelect = FALSE;563 if ((N = get_argument (argc, argv, "-dophot"))) {564 remove_argument (N, &argc, argv);565 DophotValue = atof (argv[N]);566 remove_argument (N, &argc, argv);567 DophotSelect = TRUE;568 }569 570 MaxDensityUse = FALSE;571 if ((N = get_argument (argc, argv, "-max-density"))) {572 remove_argument (N, &argc, argv);573 MaxDensityValue = atof(argv[N]);574 remove_argument (N, &argc, argv);575 MaxDensityUse = TRUE;576 }577 578 if ((MODE == MODE_UPDATE_OBJECTS) && (argc == 1)) return TRUE;579 if (argc != 2) relphot_client_usage ();580 581 return TRUE;582 }583 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/bcatalog.c
r35416 r37067 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/ipp-ops-20130712/Ohana/src/relphot/src/client_logger.c
r33963 r37067 5 5 6 6 static FILE *logfile = NULL; 7 int client_logger_init ( ) {7 int client_logger_init (char *dirname) { 8 8 9 9 char filename[DVO_MAX_PATH]; 10 10 11 snprintf (filename, DVO_MAX_PATH, "%s/log.rlpc.XXXXXX", HOSTDIR);11 snprintf (filename, DVO_MAX_PATH, "%s/log.rlpc.XXXXXX", dirname); 12 12 13 13 int fd = mkstemp (filename); 14 14 if (fd == -1) { 15 fprintf (stderr, "failed to open client logger , exiting\n");15 fprintf (stderr, "failed to open client logger %s, exiting\n", filename); 16 16 exit (50); 17 17 } … … 32 32 vfprintf (logfile, format, argp); 33 33 va_end (argp); 34 35 fflush (logfile); 34 36 return TRUE; 35 37 } -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/help.c
r33651 r37067 2 2 3 3 void relphot_usage (void) { 4 fprintf (stderr, "ERROR: USAGE: relphot (photcodes) -region RA RA DEC DEC\n"); 5 fprintf (stderr, " or: relphot (photcodes) -catalog (name)\n"); 6 fprintf (stderr, " or: relphot -averages -region RA RA DEC DEC\n"); 4 fprintf (stderr, "ERROR: USAGE: relphot (photcodes) -images\n"); 5 fprintf (stderr, " or: relphot -averages\n"); 6 fprintf (stderr, " or: relphot -apply-offsets\n"); 7 fprintf (stderr, " or: relphot (photcodes) -parallel-regions -region-hosts (RegionFile)\n"); 8 fprintf (stderr, " or: relphot (photcodes) -parallel-images (ImageTable) -region-hosts (RegionFile)\n\n"); 9 fprintf (stderr, " regions: -region RA RA DEC DEC)\n"); 10 fprintf (stderr, " or: -catalog (name)\n"); 7 11 fprintf (stderr, " use -h for more usage information\n"); 8 12 exit (2); … … 18 22 19 23 show_help: 20 fprintf (stderr, "ERROR: USAGE: relphot (photcode) -region RA RA DEC DEC\n"); 21 fprintf (stderr, " or: relphot (photcode) -catalog (name)\n"); 22 fprintf (stderr, " or: relphot -averages -region RA RA DEC DEC\n"); 24 fprintf (stderr, "ERROR: USAGE: relphot (photcodes) -images\n"); 25 fprintf (stderr, " or: relphot -averages\n"); 26 fprintf (stderr, " or: relphot -apply-offsets\n"); 27 fprintf (stderr, " or: relphot (photcodes) -parallel-regions -region-hosts (RegionFile)\n"); 28 fprintf (stderr, " or: relphot (photcodes) -parallel-images (ImageTable) -region-hosts (RegionFile)\n\n"); 29 fprintf (stderr, " regions: -region RA RA DEC DEC)\n"); 30 fprintf (stderr, " or: -catalog (name)\n"); 23 31 fprintf (stderr, " options: \n"); 24 32 fprintf (stderr, " -time (start) (stop)\n"); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/initialize.c
r34429 r37067 1 1 # include "relphot.h" 2 2 3 voidinitialize (int argc, char **argv) {3 RelphotMode initialize (int argc, char **argv) { 4 4 5 5 relphot_help (argc, argv); 6 6 ConfigInit (&argc, argv); 7 args (argc, argv); 7 RelphotMode mode = args (argc, argv); 8 if (!mode) exit (2); 8 9 9 if (!UpdateAverages) { 10 // load the list of photcodes into the globals (photcodes, Nphotcodes) 11 // only a single remaining argument in this mode (the list of photcodes, eg g,r,i) 12 PhotcodeList = strcreate (argv[1]); 13 photcodes = ParsePhotcodeList (PhotcodeList, &Nphotcodes, TRUE); // require SEC photcodes 14 } else { 10 // UPDATE_AVERAGES always operates on all photcodes? 11 if (mode == UPDATE_AVERAGES) { 15 12 char tmpline1[256]; 16 13 int Ns; … … 39 36 40 37 if (SHOW_PARAMS) { 41 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 } 42 48 if (TimeSelect) { 43 49 fprintf (stderr, "TimeSelect: TRUE (%s - %s)\n", ohana_sec_to_date (TSTART), ohana_sec_to_date (TSTOP)); … … 45 51 fprintf (stderr, "TimeSelect: FALSE\n"); 46 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 47 67 fprintf (stderr, "VERBOSE: %d, PLOTSTUFF: %d\n", VERBOSE, PLOTSTUFF); 48 68 fprintf (stderr, "GRID_X: %d, GRID_Y: %d, BINNING: %d == Nmx: %d, Nmy: %d\n", … … 52 72 (int)(RELPHOT_GRID_X/RELPHOT_GRID_BINNING), (int)(RELPHOT_GRID_Y/RELPHOT_GRID_BINNING)); 53 73 54 fprintf (stderr, "MAG_LIM %lf\n", MAG_LIM);55 74 fprintf (stderr, "STAR_SCATTER %lf\n", STAR_SCATTER); 56 75 fprintf (stderr, "IMAGE_SCATTER %lf\n", IMAGE_SCATTER); … … 59 78 fprintf (stderr, "GSCFILE %s\n", GSCFILE); 60 79 fprintf (stderr, "CATDIR %s\n", CATDIR); 61 exit (0);62 80 } 63 81 … … 67 85 for (B = 0; A == time(NULL); B++); 68 86 srand48(B); 87 88 return mode; 69 89 } 70 90 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/load_catalogs.c
r35416 r37067 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 } … … 89 89 90 90 fprintf (stderr, "using "OFF_T_FMT" of "OFF_T_FMT" stars ("OFF_T_FMT" of "OFF_T_FMT" measurements)\n", Nstar, Nstar_total, Nmeas, Nmeas_total); 91 if (!hostID && (Nstar < 1)) Shutdown ("%s", "ERROR: no stars match the minimum requirements; exiting \n");91 if (!hostID && !REGION_HOST_ID && (Nstar < 1)) Shutdown ("%s", "ERROR: no stars match the minimum requirements; exiting \n"); 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 } 94 99 95 100 // XXX consider only returning the populated catalogs … … 106 111 // CATDIR is supplied globally 107 112 # define DEBUG 1 108 Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog) { 113 Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog, char *syncfile) { 114 115 char uniquer[12]; 116 int TIME = time(NULL); 117 int PID = getpid(); 118 snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000); 109 119 110 120 int Nsecfilt = GetPhotcodeNsecfilt (); // set the desired number in case we need to create the catalog … … 128 138 129 139 ALLOCATE (table->hosts[i].results, char, 1024); 130 snprintf (table->hosts[i].results, 1024, "%s/relphot.catalog. subset.dat", table->hosts[i].pathname);140 snprintf (table->hosts[i].results, 1024, "%s/relphot.catalog.%s.dat", table->hosts[i].pathname, uniquer); 131 141 132 142 // options / arguments that can affect relphot_client -load: … … 202 212 } 203 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 204 227 // each host generates a BrightCatalog structure, with the measure, average, etc value 205 228 // loaded into a single set of arrays (of MeasureTiny, AverageTiny, Secfilt). I need to -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/plot_scatter.c
r35759 r37067 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/ipp-ops-20130712/Ohana/src/relphot/src/reload_catalogs.c
r35806 r37067 156 156 // load the list of hosts 157 157 HostTable *table = HostTableLoad (CATDIR, sky->hosts); 158 if (!table) { 159 fprintf (stderr, "ERROR: problem with parallel host table\n"); 160 exit (2); 161 } 158 162 159 163 if (BOUNDARY_TREE) { -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/relphot.c
r35416 r37067 3 3 int main (int argc, char **argv) { 4 4 5 /* get configuration info, args */ 6 initialize (argc, argv); 5 // get configuration info, args 6 RelphotMode mode = initialize (argc, argv); 7 if (!mode) exit (2); 7 8 8 /* the object analysis is a separate process iterating over catalogs */ 9 if (UpdateAverages) { 10 relphot_objects (0, NULL); 11 exit (0); 9 switch (mode) { 10 case UPDATE_IMAGES: 11 relphot_images (); 12 exit (0); 13 14 case UPDATE_AVERAGES: 15 // take the current set of detections and set the mean magnitudes 16 relphot_objects (0, NULL); 17 exit (0); 18 19 case PARALLEL_REGIONS: 20 // run image updates in parallel across multiple remote machines 21 relphot_parallel_regions (); 22 exit (0); 23 24 case PARALLEL_IMAGES: 25 // operation on the remote machines in the PARALLEL_REGION mode 26 relphot_parallel_images (); 27 exit (0); 28 29 case APPLY_OFFSETS: 30 // re-run this step from a previous attempt (assumes an existing Images.subset.dat file) 31 if (!PARALLEL) { 32 fprintf (stderr, "-apply-offsets only makes sense in an parallel context\n"); 33 exit (2); 34 } 35 reload_catalogs (NULL, NULL, 0, NULL); 36 exit (0); 37 38 default: 39 fprintf (stderr, "ERROR: no valid relphot mode chosen\n"); 40 exit (2); 12 41 } 13 14 if (ApplyOffsets) { 15 // re-run this step from a previous attempt (assumes an existing Images.subset.dat file) 16 if (!PARALLEL) { 17 fprintf (stderr, "-apply-offsets only makes sense in an parallel context\n"); 18 exit (2); 19 } 20 reload_catalogs (NULL, NULL, 0, NULL); 21 exit (0); 22 } 23 24 relphot_images (); 25 26 exit (0); 42 fprintf (stderr, "IMPOSSIBLE: skipped out of switch?\n"); 43 exit (1); 27 44 } 28 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/relphot_client.c
r33963 r37067 19 19 // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, etc) 20 20 initialize_client (argc, argv); 21 client_logger_init ( );21 client_logger_init (HOSTDIR); 22 22 23 23 // load the current sky table (layout of all SkyRegions) … … 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/ipp-ops-20130712/Ohana/src/relphot/src/relphot_images.c
r35806 r37067 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 … … 244 244 if (!UPDATE) exit (0); 245 245 246 /* load catalog data from region files, update Mrel include all data */ 246 /* Load catalog data from region files, update Mrel include all data. In a parallel 247 context, this function writes the image parameters as a subset table for the remote 248 clients */ 247 249 reload_catalogs (skylist, flatcorr, 0, NULL); 248 250 MARKTIME("-- updated all catalogs: %f sec\n", dtime); -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/select_images.c
r35806 r37067 40 40 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 41 41 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 42 strcpy (tcoords.ctype, " RA---TAN");42 strcpy (tcoords.ctype, "DEC--TAN"); 43 43 44 44 double RminSkyRegion = region[0].Rmin; … … 412 412 tcoords.Npolyterms = 0; 413 413 memset (tcoords.polyterms, 0, 14*sizeof(float)); 414 strcpy (tcoords.ctype, " RA---TAN");414 strcpy (tcoords.ctype, "DEC--TAN"); 415 415 416 416 /* compare with each region file */ -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/setExclusions.c
r33651 r37067 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/ipp-ops-20130712/Ohana/src/relphot/src/setMrelCatalog.c
r35759 r37067 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 … … 30 36 } 31 37 38 int setMrelAverageForcedWarp (off_t measureOffset, int cat, int pass, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, off_t *found); 39 32 40 int setMrel_catalog_alt (Catalog *catalog, int Nc, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, int Nsecfilt) { 33 41 34 42 off_t j; 35 43 36 liststats_setmode (&results-> stats, STATMODE);44 liststats_setmode (&results->psfstats, STATMODE); 37 45 liststats_setmode (&results->apstats, STATMODE); 38 46 liststats_setmode (&results->kronstats, STATMODE); … … 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 … … 59 67 setGlobalObjStats (&catalog[Nc].average[j], &catalog[Nc].measure[m]); 60 68 } 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 } 61 75 } 62 76 if (primaryCell) free (primaryCell); … … 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 68 83 off_t k; 69 int N;70 84 float Msys = 0, Mcal= 0, Mmos = 0, Mgrid = 0; 71 85 72 double *list = results->list; 73 double *dlist = results->dlist; 74 double *wlist = results->wlist; 75 double *aplist = results->aplist; 76 double *kronlist = results->kronlist; 86 // we are measuring means for 3 types of mags: psf, ap, kron. I am using the psf mag 87 // error for the ap mags, but krons have their own errors. it is an open question if I 88 // should be doing weighted or unweighted fits (this is a user option) 89 double *Mpsflist = results->Mpsflist; 90 double *dpsflist = results->dpsflist; 91 double *wpsflist = results->wpsflist; 92 93 double *Maplist = results->Maplist; 94 double *daplist = results->daplist; 95 double *waplist = results->waplist; 96 97 double *Mkronlist = results->Mkronlist; 77 98 double *dkronlist = results->dkronlist; 78 79 StatType *stats = &results->stats; 80 StatType *apstats = &results->apstats; 99 double *wkronlist = results->wkronlist; 100 101 StatType *psfstats = &results->psfstats; 102 StatType *apstats = &results->apstats; 81 103 StatType *kronstats = &results->kronstats; 82 104 … … 125 147 off_t meas = measureOffset; 126 148 127 N = 0; 149 int Nap = 0; 150 int Npsf = 0; 151 int Nkron = 0; 128 152 for (k = 0; k < averageT[0].Nmeasure; k++, meas++) { 129 153 … … 135 159 136 160 // are we a PS1 exposure photcode? 137 if ((measure[k].photcode >= 10000) && (measure[k].photcode <= 10500)) { 138 NexpPS1 ++; 139 } 161 if (isGPC1chip(measureT[k].photcode)) NexpPS1 ++; 162 163 // SKIP gpc1 stack data 164 if (isGPC1stack(measureT[k].photcode)) continue; 165 166 // SKIP gpc1 forced-warp data 167 if (isGPC1warp(measureT[k].photcode)) continue; 140 168 141 169 if (measureT[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS(Nbad); … … 157 185 158 186 // skip some absurd values NAN, < 0.0, > 30.0 159 Msys = PhotSysTiny (&measureT[k], &averageT[0], &secfilt[0] );187 Msys = PhotSysTiny (&measureT[k], &averageT[0], &secfilt[0], MAG_CLASS_PSF); 160 188 if (isnan(Msys)) SKIP_THIS_MEAS(Nsys); 161 189 if (Msys < 0.0) SKIP_THIS_MEAS(Nsys); … … 164 192 int myUbercalDist = getUbercalDist(meas, cat); 165 193 minUbercalDist = MIN(minUbercalDist, myUbercalDist); 194 195 int isUbercal = (measureT[k].dbFlags & ID_MEAS_PHOTOM_UBERCAL); 196 float dMpsf = MAX (hypot(measureT[k].dM, code->photomErrSys), MIN_ERROR); 197 198 if (isUbercal) haveUbercal = TRUE; // haveUbercal is set per secfilt, isUbercal is per measure 166 199 167 200 if (isSetMrelFinal) { … … 183 216 } 184 217 havePS1 = TRUE; 185 }186 187 // gpc1 stack data188 if ((measure[k].photcode >= 11000) && (measure[k].photcode <= 11400)) {189 continue;190 218 } 191 219 … … 231 259 if (measureT[k].M < MaxMagForceSynth) { 232 260 forceSynth = TRUE; 233 forceSynthEntry = N ;261 forceSynthEntry = Npsf; 234 262 } else { 235 263 if (pass < 4) { … … 240 268 } 241 269 242 // Map (aplist) and Mkron (kronlist,dkronlist) are used to calculate mean mags per filter 243 float Map = PhotAper (&measure[k]); 244 aplist[N] = Map - Mcal - Mmos - Mgrid; 245 246 float Mkron = PhotKron (&measure[k]); 247 kronlist[N] = Mkron - Mcal - Mmos - Mgrid; 248 dkronlist[N] = measure[k].dMkron; 249 } 270 // Map (Maplist) and Mkron (Mkronlist,dkronlist) are used to calculate mean mags per filter 271 float Map = PhotCat (&measure[k], MAG_CLASS_APER); 272 if (!isnan(Map)) { 273 Maplist[Nap] = Map - Mcal - Mmos - Mgrid; 274 daplist[Nap] = dMpsf;// XXX check on this... 275 waplist[Nap] = isUbercal ? UBERCAL_WEIGHT : 1.0; 276 Nap ++; 277 } 278 279 float Mkron = PhotCat (&measure[k], MAG_CLASS_KRON); 280 if (!isnan(Mkron)) { 281 Mkronlist[Nkron] = Mkron - Mcal - Mmos - Mgrid; 282 dkronlist[Nkron] = measure[k].dMkron; 283 wkronlist[Nkron] = isUbercal ? UBERCAL_WEIGHT : 1.0; 284 Nkron ++; 285 } 286 } // if (isSetMrelFinal) 250 287 251 288 // dlist gives the error per measurement, wlist gives the weight … … 255 292 // 3) UBERCAL measurements can have their weight increased by a big factor to help tie down the averages 256 293 // 4) some reference photcode of some kind can be specified as fixed and have a high weight 257 dlist[N] = MAX (hypot(measureT[k].dM, code->photomErrSys), MIN_ERROR); 258 wlist[N] = 1.0; 259 list[N] = Msys - Mcal - Mmos - Mgrid; 260 261 // up-weight the ubercal values (or convergence can take a long time...) 262 if (measureT[k].dbFlags & ID_MEAS_PHOTOM_UBERCAL) { 263 haveUbercal = TRUE; 264 wlist[N] = 10.0; 265 } 294 Mpsflist[Npsf] = Msys - Mcal - Mmos - Mgrid; 295 dpsflist[Npsf] = dMpsf; 296 wpsflist[Npsf] = isUbercal ? UBERCAL_WEIGHT : 1.0; 297 298 // NOTE: 299 // Msys is measure[i].M + zp corrections 300 // Mcal is image[j].Mcal 301 // Mmos and Mgrid are offsets for mosaic and grid 266 302 267 303 // tie down reference photometry if the -refcode (code) option is selected 268 304 // eg, -refcode g_SDSS 269 305 // this probably makes no sense in the context of multifilter analysis 306 // XXX probably need to use the photocde table to assign reference mag weights. 270 307 if (refPhotcode) { 271 308 if (code->code == refPhotcode->code) { 272 w list[N] = 100.0;309 wpsflist[Npsf] = UBERCAL_WEIGHT; 273 310 } 274 311 } 275 N ++;312 Npsf ++; 276 313 } 277 314 … … 281 318 if (isSetMrelFinal && (pass == 0)) { 282 319 if ((thisCode < 6) || (thisCode == 9)) { 283 secfilt[Nsec].Ncode = NexpPS1; 320 secfilt[Nsec].Ncode = NexpPS1; 284 321 } else { 285 322 secfilt[Nsec].Ncode = Ncode; // 2MASS data if it exists … … 288 325 289 326 // when performing the grid analysis, STAR_TOOFEW should be set to 1; 290 if (N < Nminmeas) { /* too few measurements */291 // fprintf (f, "%10.6f %10.6f %d %d %d\n", averageT[0].R, averageT[0].D, measureT[0].imageID, N , STAR_TOOFEW);327 if (Npsf < Nminmeas) { /* too few measurements */ 328 // fprintf (f, "%10.6f %10.6f %d %d %d\n", averageT[0].R, averageT[0].D, measureT[0].imageID, Npsf, STAR_TOOFEW); 292 329 secfilt[Nsec].flags |= ID_STAR_FEW; 293 330 if (Ncode == 0) { … … 303 340 if (forceSynth) { 304 341 // use the single SYNTH value instead of the other mags here 305 myAssert ((forceSynthEntry < N ) && (forceSynthEntry >= 0), "programming error");306 list[0] =list[forceSynthEntry];307 d list[0] = dlist[forceSynthEntry];308 w list[0] = wlist[forceSynthEntry];309 N = 1;310 } 311 liststats ( list, dlist, wlist, N,stats);312 313 secfilt[Nsec].M =stats->mean;314 secfilt[Nsec].dM =stats->error;315 secfilt[Nsec]. Xm = (stats->Nmeas > 1) ? 100.0*log10(stats->chisq + 1e-4) : NAN_S_SHORT;342 myAssert ((forceSynthEntry < Npsf) && (forceSynthEntry >= 0), "programming error"); 343 Mpsflist[0] = Mpsflist[forceSynthEntry]; 344 dpsflist[0] = dpsflist[forceSynthEntry]; 345 wpsflist[0] = wpsflist[forceSynthEntry]; 346 Npsf = 1; 347 } 348 liststats (Mpsflist, dpsflist, wpsflist, Npsf, psfstats); 349 350 secfilt[Nsec].M = psfstats->mean; 351 secfilt[Nsec].dM = psfstats->error; 352 secfilt[Nsec].Mchisq = (psfstats->Nmeas > 1) ? psfstats->chisq : NAN; 316 353 317 354 // when running -averages, we have no information about the images, so we cannot set this … … 323 360 found[Nsec] = TRUE; 324 361 325 secfilt[Nsec].Mstdev = 1000.0*stats->sigma; // Mstdev is in millimags (not enough space for more precision)362 secfilt[Nsec].Mstdev = psfstats->sigma; // Mstdev is in millimags (not enough space for more precision) 326 363 // secfilt[Nsec].Ncode = Ncode; 327 secfilt[Nsec].Nused = stats->Nmeas;328 329 secfilt[Nsec].M _80 = 1000 * stats->Upper80;330 secfilt[Nsec].M _20 = 1000 * stats->Lower20;364 secfilt[Nsec].Nused = psfstats->Nmeas; 365 366 secfilt[Nsec].Mmax = psfstats->max; 367 secfilt[Nsec].Mmin = psfstats->min; 331 368 332 369 // NOTE : use the modified weight for apmags as well as psf mags 333 liststats (aplist, dlist, wlist, N, apstats); 334 secfilt[Nsec].Map = apstats->mean; 335 336 liststats (kronlist, dkronlist, wlist, N, kronstats); 337 secfilt[Nsec].Mkron = kronstats->mean; 338 secfilt[Nsec].dMkron = kronstats->error; 370 liststats (Maplist, daplist, waplist, Nap, apstats); 371 secfilt[Nsec].Map = Nap > 0 ? apstats->mean : NAN; 372 secfilt[Nsec].dMap = Nap > 0 ? apstats->error : NAN; 373 secfilt[Nsec].sMap = Nap > 0 ? apstats->sigma : NAN; 374 secfilt[Nsec].NusedAp = Nap; 375 376 liststats (Mkronlist, dkronlist, wkronlist, Nkron, kronstats); 377 secfilt[Nsec].Mkron = Nkron > 0 ? kronstats->mean : NAN; 378 secfilt[Nsec].dMkron = Nkron > 0 ? kronstats->error : NAN; 379 secfilt[Nsec].sMkron = Nkron > 0 ? kronstats->sigma : NAN; 380 secfilt[Nsec].NusedKron = Nkron; 339 381 340 382 // NOTE: for 2MASS measurements, Next should be 1, as should N 341 if ((Next > 0) && (Next > 0.5*N )) {383 if ((Next > 0) && (Next > 0.5*Npsf)) { 342 384 secfilt[Nsec].flags |= ID_SECF_OBJ_EXT; 343 385 } … … 405 447 float Msys = 0, Mcal= 0, Mmos = 0, Mgrid = 0; 406 448 407 // set the name of the primary skycell (this is used in a strcmp to match the skycells in stack detections)408 // XXX drop BoundaryTreePrimaryCell(primaryCell, average[0].R, average[0].D);449 // set the primary projection cell and skycell for this coordinate 450 int tessID = -1; 409 451 int projectID = -1; 410 452 int skycellID = -1; 411 BoundaryTreePrimaryCellIDs(&projectID, &skycellID, average[0].R, average[0].D);453 get_tess_ids(&tessID, &projectID, &skycellID, average[0].R, average[0].D); 412 454 413 455 int NstackGood = 0; … … 449 491 450 492 // only examine gpc1 stack data 451 // XXX this is absurdly hardwired (along with several photcode tests) 452 if (measure[k].photcode < 11000) continue; 453 if (measure[k].photcode > 11400) continue; 493 if (!isGPC1stack(measure[k].photcode)) continue; 454 494 455 495 haveStack = TRUE; … … 470 510 if (isnan(Mgrid)) SKIP_THIS_MEAS_STACK(Ngrid); 471 511 472 Msys = PhotSys (&measure[k], &average[0], &secfilt[0] );512 Msys = PhotSys (&measure[k], &average[0], &secfilt[0], MAG_CLASS_PSF); 473 513 if (isnan(Msys)) SKIP_THIS_MEAS_STACK(Nsys); 474 514 … … 477 517 // which stack image should we use for the mean value? 478 518 // if we request the primary (USE_TREE_FOR_PRIMARY), then find the min distances for data from the primary cell 479 if (MatchImageSkycellID (meas, cat, projectID, skycellID)) {519 if (MatchImageSkycellID (meas, cat, tessID, projectID, skycellID)) { 480 520 float stackPrimaryOffset = getCenterOffset (meas, cat, &measure[k], &stackImageID); 481 521 if (stackPrimaryOffset < stackPrimaryOffsetMin) { … … 558 598 559 599 // need to put in AB mag factor to get to Janskies (or uJy?) 560 secfilt[Nsec].FluxPSF = zpFactor * measure[k].FluxPSF; 561 secfilt[Nsec].dFluxPSF = zpFactor * measure[k].dFluxPSF; 562 secfilt[Nsec].FluxKron = zpFactor * measure[k].FluxKron; 563 secfilt[Nsec].dFluxKron = zpFactor * measure[k].dFluxKron; 600 secfilt[Nsec].FpsfStk = zpFactor * measure[k].FluxPSF; 601 secfilt[Nsec].dFpsfStk = zpFactor * measure[k].dFluxPSF; 602 secfilt[Nsec].FkronStk = zpFactor * measure[k].FluxKron; 603 secfilt[Nsec].dFkronStk = zpFactor * measure[k].dFluxKron; 604 secfilt[Nsec].FapStk = zpFactor * measure[k].FluxAp; 605 secfilt[Nsec].dFapStk = zpFactor * measure[k].dFluxAp; 606 607 secfilt[Nsec].MpsfStk = (measure[k].FluxPSF > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FpsfStk) : NAN; 608 secfilt[Nsec].MkronStk = (measure[k].FluxKron > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FkronStk) : NAN; 609 secfilt[Nsec].MapStk = (measure[k].FluxAp > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FapStk) : NAN; 564 610 565 611 secfilt[Nsec].stackDetectID = ID; … … 584 630 } 585 631 632 # undef SKIP_THIS_MEAS 633 # define SKIP_THIS_MEAS(REASON) { \ 634 measure[k].dbFlags |= ID_MEAS_SKIP_PHOTOM; \ 635 results->REASON ++; \ 636 continue; } 637 638 // set mean of forced-warp measurements (selected by photcode range for now): 639 // somewhat simplified relative to chip-photometry: 640 // * no grid, no mosaic, no 2MASS, no SYNTH, no Ubercal, no flatcorr 641 int setMrelAverageForcedWarp (off_t measureOffset, int cat, int pass, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, off_t *found) { 642 643 off_t k; 644 float Fsys = 0, Mcal= 0; 645 646 // we are measuring means for 3 types of FLUXes: psf, ap, kron. I am using the psf mag 647 // error for the ap mags, but krons have their own errors. it is an open question if I 648 // should be doing weighted or unweighted fits (this is a user option) 649 double *Fpsflist = results->Mpsflist; 650 double *dpsflist = results->dpsflist; 651 double *wpsflist = results->wpsflist; 652 653 double *Faplist = results->Maplist; 654 double *daplist = results->daplist; 655 double *waplist = results->waplist; 656 657 double *Fkronlist = results->Mkronlist; 658 double *dkronlist = results->dkronlist; 659 double *wkronlist = results->wkronlist; 660 661 StatType *psfstats = &results->psfstats; 662 StatType *apstats = &results->apstats; 663 StatType *kronstats = &results->kronstats; 664 665 // option for a test print 666 if (FALSE && (average[0].objID == 0x7146) && (average[0].catID == 0x49d8)) { 667 fprintf (stderr, "test obj\n"); 668 print_measure_set_alt (average, secfilt, measure); 669 } 670 671 int Ns; 672 for (Ns = 0; Ns < Nphotcodes; Ns++) { 673 674 int thisCode = photcodes[Ns][0].code; 675 int Nsec = GetPhotcodeNsec(thisCode); 676 677 /* calculate the average mag in this SEC photcode for a single star */ 678 679 /* star/photcodes already calibrated */ 680 if (found[Nsec]) continue; 681 682 off_t meas = measureOffset; 683 684 int Nap = 0; 685 int Npsf = 0; 686 int Nkron = 0; 687 for (k = 0; k < average[0].Nmeasure; k++, meas++) { 688 689 // only examine gpc1 forced-warp data 690 if (!isGPC1warp(measure[k].photcode)) continue; 691 692 // skip measurements that do not match the current photcode 693 PhotCode *code = GetPhotcodebyCode (measure[k].photcode); 694 if (!code) continue; 695 if (code->equiv != thisCode) { continue; } 696 697 if (measure[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS(Nbad); 698 699 if (getImageEntry (meas, cat) < 0) { 700 // measurements without an image are either external reference photometry or 701 // data for which the associated image has not been loaded (probably because of 702 // overlaps). Msys + measure.Mcal is our best guess of the true magnitude 703 Mcal = measure[k].Mcal; // check that this is zero for loaded REF value 704 } else { 705 // use getMcal not getMcal_alt? 706 Mcal = getMcal_alt (meas, cat, NULL, measure[k].Xccd, measure[k].Yccd); 707 // Mcal = getMcal (meas, cat); 708 if (isnan(Mcal)) SKIP_THIS_MEAS(Ncal); 709 } 710 float Fcal = MagToFlux(-Mcal); 711 712 // in the calculations below, 713 // ...list gives the error per measurement, wlist gives the weight 714 // we can modify the error and weight in a few ways: 715 // 1) MIN_ERROR guarantees a floor 716 // 2) photomErrSys is added in quadrature as a sytematic error, set per photcode 717 718 // skip some absurd values NAN 719 // NOTE : I am using PhotCat not PhotSys for now since GPC1 chip-to-chip color terms 720 // are small (and not measured) 721 float Fpsf = PhotFluxCat (&measure[k], MAG_CLASS_PSF); 722 if (isnan(Fsys)) SKIP_THIS_MEAS(Nsys); 723 // if (Msys < 0.0) SKIP_THIS_MEAS(Nsys); 724 // if (Msys > 30.0) SKIP_THIS_MEAS(Nsys); 725 726 float dFpsf = PhotFluxCatErr (&measure[k], MAG_CLASS_PSF); 727 dFpsf = MAX (dFpsf, MIN_ERROR*Fpsf); // MIN_ERROR is a fractional error 728 Fpsflist[Npsf] = Fpsf * Fcal; 729 dpsflist[Npsf] = dFpsf * Fcal; 730 wpsflist[Npsf] = 1.0; 731 Npsf ++; 732 733 float Fap = PhotFluxCat (&measure[k], MAG_CLASS_APER); 734 float dFap = PhotFluxCatErr (&measure[k], MAG_CLASS_APER); 735 if (!isnan(Fap)) { 736 Faplist[Nap] = Fap * Fcal; 737 daplist[Nap] = dFap * Fcal; 738 waplist[Nap] = 1.0; // drop weight lists? 739 Nap ++; 740 } 741 742 float Fkron = PhotFluxCat (&measure[k], MAG_CLASS_KRON); 743 float dFkron = PhotFluxCatErr (&measure[k], MAG_CLASS_KRON); 744 if (!isnan(Fkron)) { 745 Fkronlist[Nkron] = Fkron * Fcal; 746 dkronlist[Nkron] = dFkron * Fcal; 747 wkronlist[Nkron] = 1.0; 748 Nkron ++; 749 } 750 } 751 if (Npsf < 1) continue; 752 753 found[Nsec] = TRUE; 754 755 liststats (Fpsflist, dpsflist, wpsflist, Npsf, psfstats); 756 757 secfilt[Nsec].FpsfWrp = psfstats->mean; 758 secfilt[Nsec].dFpsfWrp = psfstats->error; 759 secfilt[Nsec].sFpsfWrp = psfstats->sigma; // Mstdev is in millimags (not enough space for more precision) 760 secfilt[Nsec].NusedWrp = psfstats->Nmeas; 761 secfilt[Nsec].MpsfWrp = isnan(secfilt[Nsec].FpsfWrp) ? NAN : 8.9 - 2.5*log10(secfilt[Nsec].FpsfWrp); // 8.9 since flux is in Jy 762 763 // NOTE : use the modified weight for apmags as well as psf mags 764 liststats (Faplist, daplist, waplist, Nap, apstats); 765 secfilt[Nsec].FapWrp = Nap > 0 ? apstats->mean : NAN; 766 secfilt[Nsec].dFapWrp = Nap > 0 ? apstats->error : NAN; 767 secfilt[Nsec].sFapWrp = Nap > 0 ? apstats->sigma : NAN; 768 secfilt[Nsec].NusedApWrp = Nap; 769 secfilt[Nsec].MapWrp = isnan(secfilt[Nsec].FapWrp) ? NAN : 8.9 - 2.5*log10(secfilt[Nsec].FapWrp); // 8.9 since flux is in Jy 770 771 liststats (Fkronlist, dkronlist, wkronlist, Nkron, kronstats); 772 secfilt[Nsec].FkronWrp = Nkron > 0 ? kronstats->mean : NAN; 773 secfilt[Nsec].dFkronWrp = Nkron > 0 ? kronstats->error : NAN; 774 secfilt[Nsec].sFkronWrp = Nkron > 0 ? kronstats->sigma : NAN; 775 secfilt[Nsec].NusedKronWrp = Nkron; 776 secfilt[Nsec].MkronWrp = isnan(secfilt[Nsec].FkronWrp) ? NAN : 8.9 - 2.5*log10(secfilt[Nsec].FkronWrp); // 8.9 since flux is in Jy 777 } 778 return (TRUE); 779 } 780 586 781 int setGlobalObjStats (Average *average, Measure *measure) { 587 782 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/relphot/src/setMrelFinal.c
r35759 r37067 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/ipp-ops-20130712/Ohana/src/tools/Makefile
r31496 r37067 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/ipp-ops-20130712/Ohana/src/tools/src/ftable.c
r34260 r37067 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/ipp-ops-20130712/Ohana/src/tools/src/medianfilter.c
r20652 r37067 96 96 for (j = 0; j < Npixrd; j++, O++) { 97 97 Nvalid = 0; 98 int debug = FALSE && (n == 5) && (j >= 1776779) && (j <= 1776789); 98 99 for (k = 0; k < Nfiles; k++) { 99 100 v = (float *)tmpmatr[k].buffer; 101 if (debug) { 102 fprintf (stderr, "%8.2f ", v[j]); 103 } 100 104 if (v[j] < MinValid) continue; 101 if (isnan(v[j])) continue; 102 if (isinf(v[j])) continue; 103 list[k] = v[j]; 105 if (isnan(v[j])) { 106 continue; 107 } 108 if (isinf(v[j])) { 109 continue; 110 } 111 list[Nvalid] = v[j]; 104 112 Nvalid ++; 105 113 } 114 if (debug) fprintf (stderr, "\n"); 106 115 if (Nvalid == 0) { 107 *O = 0.0; 116 *O = NAN; 117 if (debug) { 118 fprintf (stderr, "Nvalid is 0\n"); 119 } 108 120 continue; 109 121 } … … 111 123 sum = 0; 112 124 Nval = 0; 125 if (debug) fprintf (stderr, "list : "); 113 126 for (k = fmin*Nvalid; k < fmax*Nvalid; k++) { 127 if (debug) { 128 fprintf (stderr, "%8.2f ", list[k]); 129 } 114 130 sum += list[k]; 115 131 Nval ++; 116 132 } 117 133 *O = (sum / Nval); 134 if (debug) { 135 fprintf (stderr, " = %f / %f = %f\n", sum, Nval, *O); 136 fprintf (stderr, "\n"); 137 } 118 138 } 119 139 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/uniphot/src/ImageSubset.c
r33654 r37067 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/ipp-ops-20130712/Ohana/src/uniphot/src/ImageSubsetFixImageIDs.c
r35764 r37067 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/ipp-ops-20130712/Ohana/src/uniphot/src/ImageSubsetFixStackIDs.c
r35764 r37067 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/ipp-ops-20130712/Ohana/src/uniphot/src/ImageSubsetSetPosangle.c
r34749 r37067 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/ipp-ops-20130712/Ohana/src/uniphot/src/find_image_sgroups.c
r31160 r37067 22 22 coords.pc1_1 = coords.pc2_2 = 1.0; 23 23 coords.pc1_2 = coords.pc2_1 = 0.0; 24 strcpy (coords.ctype, " RA---TAN");24 strcpy (coords.ctype, "DEC--TAN"); 25 25 26 26 Ngroup = 0; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/uniphot/src/load_images_fiximids.c
r35764 r37067 1 1 # include "fiximids.h" 2 # define FT_BZERO_INT32 1.0*0x800000003 2 4 3 off_t Nimage = 0; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/uniphot/src/load_images_fixstkids.c
r35764 r37067 1 1 # include "fixstkids.h" 2 # define FT_BZERO_INT32 1.0*0x800000003 2 4 3 off_t Nimage = 0; -
branches/eam_branches/ipp-ops-20130712/Ohana/src/uniphot/src/update_catalog_fiximids.c
r35764 r37067 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/ipp-ops-20130712/Ohana/src/uniphot/src/update_catalog_setastrom.c
r35103 r37067 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 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/uniphot/src/update_dvo_setphot.c
r35103 r37067 2 2 int update_dvo_setphot_parallel (SkyTable *sky, Image *image, off_t Nimage); 3 3 4 // XXX convert this to use the ImageSubset to save space 4 5 int update_dvo_setphot (Image *image, off_t Nimage, FlatCorrectionTable *flatcorr) { 5 6 -
branches/eam_branches/ipp-ops-20130712/Ohana/src/uniphot/src/update_dvo_uniphot.c
r34088 r37067 61 61 coords.pc1_1 = coords.pc2_2 = 1.0; 62 62 coords.pc1_2 = coords.pc2_1 = 0.0; 63 strcpy (coords.ctype, " RA---TAN");63 strcpy (coords.ctype, "DEC--TAN"); 64 64 65 65 for (i = 0; i < pglob.gl_pathc; i++) {
Note:
See TracChangeset
for help on using the changeset viewer.
