Changeset 23352
- Timestamp:
- Mar 17, 2009, 12:08:50 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 27 deleted
- 298 edited
- 60 copied
-
. (modified) (1 prop)
-
Nebulous-Server/MANIFEST (modified) (1 diff)
-
Nebulous-Server/bin/neb-admin (modified) (5 diffs)
-
Nebulous-Server/bin/neb-voladd (modified) (2 diffs)
-
Nebulous-Server/docs/c_api.h (deleted)
-
Nebulous-Server/docs/install.txt (copied) (copied from trunk/Nebulous-Server/docs/install.txt )
-
Nebulous-Server/docs/setup.txt (deleted)
-
Nebulous-Server/docs/tmp.txt (deleted)
-
Nebulous/Build.PL (modified) (2 diffs)
-
Nebulous/MANIFEST (modified) (1 diff)
-
Nebulous/docs (deleted)
-
Nebulous/nebclient/src (modified) (1 prop)
-
Nebulous/nebclient/src/nebulous.h (copied) (copied from trunk/Nebulous/nebclient/src/nebulous.h )
-
Nebulous/nebclient/src/soapC.c (copied) (copied from trunk/Nebulous/nebclient/src/soapC.c )
-
Nebulous/nebclient/src/soapClient.c (copied) (copied from trunk/Nebulous/nebclient/src/soapClient.c )
-
Nebulous/nebclient/src/soapClientLib.c (copied) (copied from trunk/Nebulous/nebclient/src/soapClientLib.c )
-
Nebulous/nebclient/src/soapH.h (copied) (copied from trunk/Nebulous/nebclient/src/soapH.h )
-
Nebulous/nebclient/src/soapServer.c (copied) (copied from trunk/Nebulous/nebclient/src/soapServer.c )
-
Nebulous/nebclient/src/soapServerLib.c (copied) (copied from trunk/Nebulous/nebclient/src/soapServerLib.c )
-
Nebulous/nebclient/src/soapStub.h (copied) (copied from trunk/Nebulous/nebclient/src/soapStub.h )
-
Nebulous/nebclient/tests/tap/src (modified) (1 prop)
-
Nebulous/scripts/ptest.pl (modified) (3 diffs)
-
Nebulous/scripts/stats.pl (copied) (copied from trunk/Nebulous/scripts/stats.pl )
-
Ohana (modified) (1 prop)
-
Ohana/Makefile.in (modified) (3 diffs)
-
Ohana/src/addrefs (deleted)
-
Ohana/src/addspphot (deleted)
-
Ohana/src/addstar/doc/ps1.tessellation.tamas.pdf (copied) (copied from trunk/Ohana/src/addstar/doc/ps1.tessellation.tamas.pdf )
-
Ohana/src/addstar/include/skycells.h (modified) (3 diffs)
-
Ohana/src/addstar/src/args_skycells.c (modified) (2 diffs)
-
Ohana/src/addstar/src/get2mass_full.c (modified) (10 diffs)
-
Ohana/src/addstar/src/sky_tessalation.c (modified) (3 diffs)
-
Ohana/src/libdummy (deleted)
-
Ohana/src/libdvo (modified) (1 prop)
-
Ohana/src/libdvo/lib (modified) (1 prop)
-
Ohana/src/libfits/lib (modified) (1 prop)
-
Ohana/src/libkapa/lib (modified) (1 prop)
-
Ohana/src/libohana/lib (modified) (1 prop)
-
Ohana/src/libohana/src/CommOps.c (modified) (1 diff)
-
Ohana/src/libtap/lib (modified) (1 prop)
-
Ohana/src/opihi/dimm/Analysis.c (modified) (1 diff)
-
Ohana/src/opihi/dimm/Makefile (modified) (2 diffs)
-
Ohana/src/opihi/dimm/analysis.c (deleted)
-
Ohana/src/opihi/dimm/camera.c (deleted)
-
Ohana/src/opihi/dimm/camera_cmds.c (copied) (copied from trunk/Ohana/src/opihi/dimm/camera_cmds.c ) (1 prop)
-
Ohana/src/opihi/dimm/telescope.c (deleted)
-
Ohana/src/opihi/dimm/telescope_cmds.c (copied) (copied from trunk/Ohana/src/opihi/dimm/telescope_cmds.c ) (1 prop)
-
Ohana/src/opihi/lib (modified) (1 prop)
-
Ohana/src/opihi/pantasks/CheckTasks.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/task_threads.c (modified) (2 diffs)
-
Ohana/src/opihi/pcontrol/CheckIdleHost.c (modified) (3 diffs)
-
PS-IPP-Config/lib/PS/IPP/Config.pm (modified) (87 diffs)
-
PS-IPP-PStamp (copied) (copied from trunk/PS-IPP-PStamp )
-
PS-IPP-PStamp/Build.PL (copied) (copied from trunk/PS-IPP-PStamp/Build.PL )
-
PS-IPP-PStamp/LICENSE (copied) (copied from trunk/PS-IPP-PStamp/LICENSE )
-
PS-IPP-PStamp/MANIFEST (copied) (copied from trunk/PS-IPP-PStamp/MANIFEST )
-
PS-IPP-PStamp/lib (copied) (copied from trunk/PS-IPP-PStamp/lib )
-
PS-IPP-PStamp/lib/PS (copied) (copied from trunk/PS-IPP-PStamp/lib/PS )
-
PS-IPP-PStamp/lib/PS/IPP (copied) (copied from trunk/PS-IPP-PStamp/lib/PS/IPP )
-
PS-IPP-PStamp/lib/PS/IPP/PStamp (copied) (copied from trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp )
-
PS-IPP-PStamp/lib/PS/IPP/PStamp.pm (copied) (copied from trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp.pm )
-
PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm (copied) (copied from trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm )
-
PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm (copied) (copied from trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm )
-
PStamp (deleted)
-
archive/conv_variance/fake.c (modified) (1 diff)
-
archive/conv_variance/phot.c (modified) (1 diff)
-
dbconfig/changes.txt (modified) (2 diffs)
-
dbconfig/config.md (modified) (1 diff)
-
dbconfig/det.md (modified) (2 diffs)
-
dbconfig/dist.md (copied) (copied from trunk/dbconfig/dist.md )
-
dettools (deleted)
-
doc/ipptools/dataStates.odg (copied) (copied from trunk/doc/ipptools/dataStates.odg )
-
doc/misc/detnorm.rework.txt (copied) (copied from trunk/doc/misc/detnorm.rework.txt )
-
doc/pslib/psLibSDRS.tex (modified) (1 diff)
-
ippMonitor/def/detNormalizedStatImfile_failure.d (modified) (1 diff)
-
ippMonitor/def/detStackedImfile.d (modified) (1 diff)
-
ippMonitor/raw/getimage.php (modified) (3 diffs)
-
ippScripts/Build.PL (modified) (1 diff)
-
ippScripts/scripts/calibrate_dvo.pl (modified) (7 diffs)
-
ippScripts/scripts/camera_exp.pl (modified) (4 diffs)
-
ippScripts/scripts/chip_imfile.pl (modified) (4 diffs)
-
ippScripts/scripts/detrend_correct_imfile.pl (modified) (3 diffs)
-
ippScripts/scripts/detrend_norm_apply.pl (modified) (4 diffs)
-
ippScripts/scripts/detrend_norm_calc.pl (modified) (5 diffs)
-
ippScripts/scripts/detrend_norm_exp.pl (modified) (3 diffs)
-
ippScripts/scripts/detrend_process_exp.pl (modified) (3 diffs)
-
ippScripts/scripts/detrend_process_imfile.pl (modified) (6 diffs)
-
ippScripts/scripts/detrend_reject_exp.pl (modified) (3 diffs)
-
ippScripts/scripts/detrend_resid_exp.pl (modified) (12 diffs)
-
ippScripts/scripts/detrend_resid_imfile.pl (modified) (6 diffs)
-
ippScripts/scripts/detrend_stack.pl (modified) (3 diffs)
-
ippScripts/scripts/diff_skycell.pl (modified) (3 diffs)
-
ippScripts/scripts/dist_advancerun.pl (copied) (copied from trunk/ippScripts/scripts/dist_advancerun.pl )
-
ippScripts/scripts/dist_component.pl (copied) (copied from trunk/ippScripts/scripts/dist_component.pl )
-
ippScripts/scripts/fake_imfile.pl (modified) (3 diffs)
-
ippScripts/scripts/ipp_cleanup.pl (modified) (14 diffs)
-
ippScripts/scripts/ipp_maskscript.pl (modified) (6 diffs)
-
ippScripts/scripts/magic_definerun.pl (modified) (2 diffs)
-
ippScripts/scripts/magic_destreak.pl (modified) (4 diffs)
-
ippScripts/scripts/magic_mask.pl (modified) (3 diffs)
-
ippScripts/scripts/magic_process.pl (modified) (4 diffs)
-
ippScripts/scripts/magic_tree.pl (modified) (3 diffs)
-
ippScripts/scripts/register_exp.pl (modified) (3 diffs)
-
ippScripts/scripts/register_imfile.pl (modified) (7 diffs)
-
ippScripts/scripts/stack_skycell.pl (modified) (4 diffs)
-
ippScripts/scripts/summit_copy.pl (modified) (1 diff)
-
ippScripts/scripts/warp_overlap.pl (modified) (4 diffs)
-
ippScripts/scripts/warp_skycell.pl (modified) (3 diffs)
-
ippTasks/Makefile.am (modified) (1 diff)
-
ippTasks/automate.pro (modified) (4 diffs)
-
ippTasks/calibration.pro (modified) (2 diffs)
-
ippTasks/camera.pro (modified) (4 diffs)
-
ippTasks/chip.pro (modified) (9 diffs)
-
ippTasks/detrend.correct.pro (modified) (2 diffs)
-
ippTasks/detrend.mkruns.pro (modified) (3 diffs)
-
ippTasks/detrend.norm.pro (modified) (12 diffs)
-
ippTasks/detrend.process.pro (modified) (8 diffs)
-
ippTasks/detrend.reject.pro (modified) (2 diffs)
-
ippTasks/detrend.resid.pro (modified) (9 diffs)
-
ippTasks/detrend.stack.pro (modified) (4 diffs)
-
ippTasks/diff.pro (modified) (4 diffs)
-
ippTasks/dist.pro (copied) (copied from trunk/ippTasks/dist.pro )
-
ippTasks/fake.pro (modified) (8 diffs)
-
ippTasks/flatcorr.pro (modified) (3 diffs)
-
ippTasks/magic.pro (modified) (6 diffs)
-
ippTasks/pstamp.pro (modified) (7 diffs)
-
ippTasks/register.pro (modified) (4 diffs)
-
ippTasks/replicate.pro (modified) (6 diffs)
-
ippTasks/stack.pro (modified) (4 diffs)
-
ippTasks/summit.copy.pro (modified) (9 diffs)
-
ippTasks/warp.pro (modified) (6 diffs)
-
ippTools/scripts/test_create_detrend.sql (copied) (copied from trunk/ippTools/scripts/test_create_detrend.sql )
-
ippTools/scripts/test_insert_detrend.sql (copied) (copied from trunk/ippTools/scripts/test_insert_detrend.sql )
-
ippTools/share/Makefile.am (modified) (1 diff)
-
ippTools/share/chiptool_change_imfile_data_state.sql (modified) (1 diff)
-
ippTools/share/chiptool_pendingcleanupimfile.sql (modified) (1 diff)
-
ippTools/share/chiptool_pendingcleanuprun.sql (modified) (1 diff)
-
ippTools/share/dettool_processedimfile.sql (modified) (1 diff)
-
ippTools/share/dettool_residimfile.sql (modified) (1 diff)
-
ippTools/share/dettool_todetrunsummary.sql (modified) (1 diff)
-
ippTools/share/dettool_tonormalizedstat.sql (modified) (1 diff)
-
ippTools/share/dettool_toresidexp.sql (modified) (5 diffs)
-
ippTools/share/dettool_toresidimfile.sql (modified) (3 diffs)
-
ippTools/share/disttool_pendingcomponent.sql (copied) (copied from trunk/ippTools/share/disttool_pendingcomponent.sql )
-
ippTools/share/disttool_processedcomponent.sql (copied) (copied from trunk/ippTools/share/disttool_processedcomponent.sql )
-
ippTools/share/disttool_revertrun_delete.sql (copied) (copied from trunk/ippTools/share/disttool_revertrun_delete.sql )
-
ippTools/share/disttool_revertrun_update.sql (copied) (copied from trunk/ippTools/share/disttool_revertrun_update.sql )
-
ippTools/share/disttool_toadvance.sql (copied) (copied from trunk/ippTools/share/disttool_toadvance.sql )
-
ippTools/share/pxadmin_create_tables.sql (modified) (1 diff)
-
ippTools/share/warptool_change_skyfile_data_state.sql (modified) (1 diff)
-
ippTools/src/camtool.c (modified) (3 diffs)
-
ippTools/src/camtool.h (modified) (1 diff)
-
ippTools/src/camtoolConfig.c (modified) (2 diffs)
-
ippTools/src/chiptool.c (modified) (7 diffs)
-
ippTools/src/chiptool.h (modified) (1 diff)
-
ippTools/src/chiptoolConfig.c (modified) (3 diffs)
-
ippTools/src/dettool.c (modified) (5 diffs)
-
ippTools/src/dettool.h (modified) (1 diff)
-
ippTools/src/dettoolConfig.c (modified) (3 diffs)
-
ippTools/src/dettool_processedimfile.c (modified) (4 diffs)
-
ippTools/src/dettool_residimfile.c (modified) (2 diffs)
-
ippTools/src/difftool.c (modified) (3 diffs)
-
ippTools/src/difftool.h (modified) (1 diff)
-
ippTools/src/difftoolConfig.c (modified) (2 diffs)
-
ippTools/src/disttool.c (copied) (copied from trunk/ippTools/src/disttool.c )
-
ippTools/src/disttool.h (copied) (copied from trunk/ippTools/src/disttool.h )
-
ippTools/src/disttoolConfig.c (copied) (copied from trunk/ippTools/src/disttoolConfig.c )
-
ippTools/src/faketool.c (modified) (6 diffs)
-
ippTools/src/faketool.h (modified) (2 diffs)
-
ippTools/src/faketoolConfig.c (modified) (4 diffs)
-
ippTools/src/flatcorr.c (modified) (3 diffs)
-
ippTools/src/flatcorr.h (modified) (1 diff)
-
ippTools/src/flatcorrConfig.c (modified) (2 diffs)
-
ippTools/src/pxadmin.c (modified) (3 diffs)
-
ippTools/src/pxadmin.h (modified) (1 diff)
-
ippTools/src/pxadminConfig.c (modified) (3 diffs)
-
ippTools/src/pxtools.c (modified) (2 diffs)
-
ippTools/src/pxwarp.c (modified) (1 diff)
-
ippTools/src/regtool.c (modified) (3 diffs)
-
ippTools/src/regtool.h (modified) (1 diff)
-
ippTools/src/regtoolConfig.c (modified) (2 diffs)
-
ippTools/src/stacktool.c (modified) (3 diffs)
-
ippTools/src/stacktool.h (modified) (1 diff)
-
ippTools/src/stacktoolConfig.c (modified) (2 diffs)
-
ippTools/src/warptool.c (modified) (3 diffs)
-
ippTools/src/warptool.h (modified) (1 diff)
-
ippTools/src/warptoolConfig.c (modified) (2 diffs)
-
ippconfig/dvo.ps1v1.photcodes (copied) (copied from trunk/ippconfig/dvo.ps1v1.photcodes )
-
ippconfig/gpc1/format_20080925.config (modified) (1 diff)
-
ippconfig/gpc1/format_20080929.config (modified) (1 diff)
-
ippconfig/gpc1/format_20081011.config (modified) (1 diff)
-
ippconfig/gpc1/format_20090120.config (modified) (1 diff)
-
ippconfig/gpc1/format_20090220.config (modified) (1 diff)
-
ippconfig/gpc1/format_mef.config (modified) (1 diff)
-
ippconfig/gpc1/format_orig.config (modified) (1 diff)
-
ippconfig/gpc1/format_relphot.config (modified) (1 diff)
-
ippconfig/gpc1/ppImage.config (modified) (2 diffs)
-
ippconfig/gpc1/ppMerge.config (modified) (1 diff)
-
ippconfig/ipprc.config.in (modified) (1 diff)
-
ippconfig/megacam/psphot.config (modified) (2 diffs)
-
ippconfig/recipes/filerules-mef.mdc (modified) (2 diffs)
-
ippconfig/recipes/filerules-simple.mdc (modified) (2 diffs)
-
ippconfig/recipes/filerules-split.mdc (modified) (3 diffs)
-
ippconfig/recipes/fitstypes.mdc (modified) (1 diff)
-
ippconfig/recipes/jpeg.mdc (modified) (2 diffs)
-
ippconfig/recipes/ppImage.config (modified) (2 diffs)
-
ippconfig/recipes/ppStack.config (modified) (1 diff)
-
ippconfig/recipes/ppSub.config (modified) (1 diff)
-
ippconfig/recipes/psphot.config (modified) (1 diff)
-
ippconfig/recipes/reductionClasses.mdc (modified) (1 diff)
-
magic/remove/src/streaksrelease.c (modified) (5 diffs)
-
magic/remove/src/streaksreplace.c (modified) (3 diffs)
-
pois (deleted)
-
ppArith/src/Makefile.am (modified) (1 diff)
-
ppArith/src/ppArith.c (modified) (1 diff)
-
ppArith/src/ppArith.h (modified) (4 diffs)
-
ppArith/src/ppArithLoop.c (modified) (1 diff)
-
ppArith/src/ppArithVersion.c (modified) (2 diffs)
-
ppFringe (deleted)
-
ppImage (modified) (1 prop)
-
ppImage/src/Makefile.am (modified) (1 diff)
-
ppImage/src/ppImage.c (modified) (1 diff)
-
ppImage/src/ppImage.h (modified) (2 diffs)
-
ppImage/src/ppImageArguments.c (modified) (5 diffs)
-
ppImage/src/ppImageDefineFile.c (modified) (1 diff)
-
ppImage/src/ppImageDetrendReadout.c (modified) (6 diffs)
-
ppImage/src/ppImageLoop.c (modified) (7 diffs)
-
ppImage/src/ppImageLoop_Threaded.c (deleted)
-
ppImage/src/ppImageOptions.c (modified) (2 diffs)
-
ppImage/src/ppImageParseCamera.c (modified) (15 diffs)
-
ppImage/src/ppImageReplaceBackground.c (modified) (1 diff)
-
ppImage/src/ppImageVersion.c (modified) (2 diffs)
-
ppMerge/src/Makefile.am (modified) (2 diffs)
-
ppMerge/src/ppMerge.c (modified) (1 diff)
-
ppMerge/src/ppMerge.h (modified) (12 diffs)
-
ppMerge/src/ppMergeLoop_Threaded.c (modified) (2 diffs)
-
ppMerge/src/ppMergeMask.c (modified) (5 diffs)
-
ppMerge/src/ppMergeScaleZero.c (modified) (1 diff)
-
ppMerge/src/ppMergeVersion.c (modified) (1 diff)
-
ppMerge/src/ppMergeVersion.h (modified) (1 diff)
-
ppShutter (deleted)
-
ppSim/src/Makefile.am (modified) (2 diffs)
-
ppSim/src/ppSim.h (modified) (3 diffs)
-
ppSim/src/ppSimBadPixels.c (modified) (1 diff)
-
ppSim/src/ppSimLoop.c (modified) (1 diff)
-
ppSim/src/ppSimSequence.c (modified) (2 diffs)
-
ppSim/src/ppSimVersion.c (copied) (copied from trunk/ppSim/src/ppSimVersion.c )
-
ppStac (deleted)
-
ppStack (modified) (1 prop)
-
ppStack/src/Makefile.am (modified) (2 diffs)
-
ppStack/src/ppStack.c (modified) (3 diffs)
-
ppStack/src/ppStack.h (modified) (5 diffs)
-
ppStack/src/ppStackArguments.c (modified) (5 diffs)
-
ppStack/src/ppStackCleanup.c (copied) (copied from trunk/ppStack/src/ppStackCleanup.c )
-
ppStack/src/ppStackCombineFinal.c (copied) (copied from trunk/ppStack/src/ppStackCombineFinal.c )
-
ppStack/src/ppStackCombineInitial.c (copied) (copied from trunk/ppStack/src/ppStackCombineInitial.c )
-
ppStack/src/ppStackConvolve.c (copied) (copied from trunk/ppStack/src/ppStackConvolve.c )
-
ppStack/src/ppStackFiles.c (copied) (copied from trunk/ppStack/src/ppStackFiles.c )
-
ppStack/src/ppStackFinish.c (copied) (copied from trunk/ppStack/src/ppStackFinish.c )
-
ppStack/src/ppStackLoop.c (modified) (2 diffs)
-
ppStack/src/ppStackLoop.h (copied) (copied from trunk/ppStack/src/ppStackLoop.h )
-
ppStack/src/ppStackMatch.c (modified) (6 diffs)
-
ppStack/src/ppStackOptions.c (copied) (copied from trunk/ppStack/src/ppStackOptions.c )
-
ppStack/src/ppStackOptions.h (copied) (copied from trunk/ppStack/src/ppStackOptions.h )
-
ppStack/src/ppStackPSF.c (modified) (2 diffs)
-
ppStack/src/ppStackPhotometry.c (modified) (4 diffs)
-
ppStack/src/ppStackPrepare.c (copied) (copied from trunk/ppStack/src/ppStackPrepare.c )
-
ppStack/src/ppStackReadout.c (modified) (4 diffs)
-
ppStack/src/ppStackReject.c (copied) (copied from trunk/ppStack/src/ppStackReject.c )
-
ppStack/src/ppStackSetup.c (copied) (copied from trunk/ppStack/src/ppStackSetup.c )
-
ppStack/src/ppStackSources.c (modified) (6 diffs)
-
ppStack/src/ppStackThread.c (modified) (5 diffs)
-
ppStack/src/ppStackThread.h (copied) (copied from trunk/ppStack/src/ppStackThread.h )
-
ppStack/src/ppStackVersion.c (modified) (1 diff)
-
ppStats/src/Makefile.am (modified) (1 diff)
-
ppStats/src/ppStats.h (modified) (2 diffs)
-
ppStats/src/ppStatsFromMetadataPrint.c (modified) (2 diffs)
-
ppStats/src/ppStatsVersion.c (modified) (1 diff)
-
ppSub (modified) (1 prop)
-
ppSub/src/Makefile.am (modified) (1 diff)
-
ppSub/src/ppSub.c (modified) (2 diffs)
-
ppSub/src/ppSub.h (modified) (1 diff)
-
ppSub/src/ppSubArguments.c (modified) (10 diffs)
-
ppSub/src/ppSubBackground.c (modified) (1 diff)
-
ppSub/src/ppSubCamera.c (modified) (2 diffs)
-
ppSub/src/ppSubLoop.c (modified) (4 diffs)
-
ppSub/src/ppSubMakePSF.c (modified) (1 diff)
-
ppSub/src/ppSubMatchPSFs.c (modified) (3 diffs)
-
ppSub/src/ppSubReadoutUpdate.c (modified) (1 diff)
-
ppSub/src/ppSubVarianceFactors.c (modified) (1 diff)
-
ppSub/src/ppSubVersion.c (modified) (1 diff)
-
ppSub/test/fake.c (modified) (1 diff)
-
ppstamp (deleted)
-
psLib/configure.ac (modified) (6 diffs)
-
psLib/src/astronomy (deleted)
-
psLib/src/collections (deleted)
-
psLib/src/dataIO (deleted)
-
psLib/src/dataManip (deleted)
-
psLib/src/fileUtils (deleted)
-
psLib/src/fits/psFitsHeader.c (modified) (3 diffs)
-
psLib/src/fits/psFitsHeader.h (modified) (2 diffs)
-
psLib/src/fits/psFitsImage.c (modified) (4 diffs)
-
psLib/src/fits/psFitsScale.c (modified) (2 diffs)
-
psLib/src/image (deleted)
-
psLib/src/imageops/psImageCovariance.c (modified) (4 diffs)
-
psLib/src/imageops/psImageInterpolate.c (modified) (1 diff)
-
psLib/src/math/psRandom.c (modified) (3 diffs)
-
psLib/src/math/psRandom.h (modified) (5 diffs)
-
psLib/src/math/psStats.c (modified) (4 diffs)
-
psLib/src/pslib_strict.h (modified) (1 diff)
-
psLib/src/sys/Makefile.am (modified) (1 diff)
-
psLib/src/sys/psConfigure.c (modified) (3 diffs)
-
psLib/src/sys/psConfigure.h (modified) (2 diffs)
-
psLib/src/sys/psLogMsg.c (modified) (2 diffs)
-
psLib/src/sys/psMemory.c (modified) (1 diff)
-
psLib/src/sys/psMemory.h (modified) (1 diff)
-
psLib/src/sysUtils (deleted)
-
psLib/src/types/Makefile.am (modified) (2 diffs)
-
psLib/src/types/psMetadata.h (modified) (1 diff)
-
psLib/src/types/psMetadataConfig.c (modified) (2 diffs)
-
psLib/src/types/psMetadataHeader.c (copied) (copied from trunk/psLib/src/types/psMetadataHeader.c )
-
psLib/src/types/psMetadataHeader.h (copied) (copied from trunk/psLib/src/types/psMetadataHeader.h )
-
psLib/test/fits/tap_psFitsImage.c (modified) (1 diff)
-
psLib/test/imageops/convolutionBench.c (modified) (1 diff)
-
psLib/test/imageops/tap_psImageInterpolate2.c (modified) (1 diff)
-
psLib/test/math/tap_psMinimizeLMM.c (modified) (2 diffs)
-
psLib/test/math/tap_psPolyFit1D.c (modified) (1 diff)
-
psLib/test/math/tap_psPolyFit2D.c (modified) (1 diff)
-
psLib/test/math/tap_psPolyFit3D.c (modified) (1 diff)
-
psLib/test/math/tap_psPolyFit4D.c (modified) (1 diff)
-
psLib/test/math/tap_psRandom.c (modified) (11 diffs)
-
psLib/test/math/tap_psStats07.c (modified) (1 diff)
-
psLib/test/math/tap_psStats09.c (modified) (1 diff)
-
psLib/test/math/tap_psStatsTiming.c (modified) (1 diff)
-
psLib/test/math/tst_psMinimizeLMM.c (modified) (1 diff)
-
psLib/test/math/tst_psPolyFit1D.c (modified) (1 diff)
-
psLib/test/math/tst_psPolyFit2D.c (modified) (1 diff)
-
psLib/test/math/tst_psPolyFit3D.c (modified) (1 diff)
-
psLib/test/math/tst_psPolyFit4D.c (modified) (1 diff)
-
psLib/test/math/tst_psRandom.c (modified) (13 diffs)
-
psLib/test/math/tst_psStats09.c (modified) (1 diff)
-
psLib/test/mathtypes/tap_psVectorSelect.c (modified) (2 diffs)
-
psLib/test/types/tap_psTree.c (modified) (1 diff)
-
psastro (modified) (1 prop)
-
psastro/src/Makefile.am (modified) (1 diff)
-
psastro/src/psastro.c (modified) (2 diffs)
-
psastro/src/psastro.h (modified) (1 diff)
-
psastro/src/psastroArguments.c (modified) (2 diffs)
-
psastro/src/psastroCleanup.c (modified) (2 diffs)
-
psastro/src/psastroConvert.c (modified) (1 diff)
-
psastro/src/psastroDataSave.c (modified) (5 diffs)
-
psastro/src/psastroVersion.c (modified) (2 diffs)
-
psastro/src/psastroVisual.c (deleted)
-
psconfig/psbuild (modified) (6 diffs)
-
psconfig/pschecklibs (modified) (1 diff)
-
psconfig/tagsets/ipp-2.8.dist (copied) (copied from trunk/psconfig/tagsets/ipp-2.8.dist )
-
psconfig/tagsets/ipp-2.8.libs (copied) (copied from trunk/psconfig/tagsets/ipp-2.8.libs )
-
psconfig/tagsets/ipp-2.8.perl (copied) (copied from trunk/psconfig/tagsets/ipp-2.8.perl )
-
psphot (modified) (1 prop)
-
psphot/src/Makefile.am (modified) (1 diff)
-
psphot/src/psphot.c (modified) (2 diffs)
-
psphot/src/psphot.h (modified) (2 diffs)
-
psphot/src/psphotArguments.c (modified) (1 diff)
-
psphot/src/psphotImageLoop.c (modified) (2 diffs)
-
psphot/src/psphotMagnitudes.c (modified) (8 diffs)
-
psphot/src/psphotMaskReadout.c (modified) (1 diff)
-
psphot/src/psphotModelBackground.c (modified) (6 diffs)
-
psphot/src/psphotSetThreads.c (modified) (1 diff)
-
psphot/src/psphotSourceStats.c (modified) (14 diffs)
-
psphot/src/psphotSubtractBackground.c (modified) (2 diffs)
-
psphot/src/psphotVersion.c (modified) (1 diff)
-
psphot/src/psphotVisual.c (modified) (32 diffs)
-
pstamp/scripts/pstamp_finish.pl (modified) (2 diffs)
-
pstamp/scripts/pstamp_job_run.pl (modified) (1 diff)
-
pstamp/scripts/pstampparse.pl (modified) (2 diffs)
-
pstamp/test/test_lookup.pl (modified) (1 diff)
-
pstest/src/tst_psPolynomial.c (modified) (3 diffs)
-
pswarp/src/Makefile.am (modified) (2 diffs)
-
pswarp/src/pswarp.c (modified) (1 diff)
-
pswarp/src/pswarp.h (modified) (1 diff)
-
pswarp/src/pswarpArguments.c (modified) (4 diffs)
-
pswarp/src/pswarpLoop.c (modified) (4 diffs)
-
pswarp/src/pswarpParseCamera.c (modified) (5 diffs)
-
pswarp/src/pswarpVersion.c (modified) (1 diff)
-
stac (deleted)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk merged eligible /branches/eam_branches/eam_branch_20090303 23158-23228
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/cnb_branches/cnb_branch_20090301/Nebulous-Server/MANIFEST
r20990 r23352 10 10 bin/neb-voladd 11 11 bin/nebdiskd 12 docs/c_api.h13 12 docs/database_setup.txt 14 13 docs/design.txt 14 docs/install.txt 15 15 docs/requirements.txt 16 docs/setup.txt17 docs/tmp.txt18 16 examples/Makefile 19 17 examples/nebexample.c -
branches/cnb_branches/cnb_branch_20090301/Nebulous-Server/bin/neb-admin
r20202 r23352 23 23 $dbpass, 24 24 $dbuser, 25 $so_id_start, 26 $so_id_range, 25 27 $limit, 26 28 $pending, … … 41 43 'pendingreplicate|r' => \$pending, 42 44 'pendingremoval' => \$removal, 45 'so_id_start=i' => \$so_id_start, 46 'so_id_range=i' => \$so_id_range, 43 47 'limit|l=i' => \$limit, 44 48 'verbose|v' => \$verbose, … … 58 62 59 63 # check to make sure that only one instance of neb-admin is running 64 # XXX this implies we should move pending replicate elsewhere 60 65 my $pidfile = '/var/tmp/neb-admin'; 61 66 # abort if an instance is already running … … 91 96 $dbh->do("INSERT INTO myvolume SELECT * FROM volume"); 92 97 98 if (not defined $so_id_start) { $so_id_start = 0; } 99 if (not defined $so_id_range) { $so_id_range = 100000; } 100 my $so_id_end = $so_id_start + $so_id_range; 101 102 # XXX check if so_id_start is beyond MAX(so_id): if so, exit with exit status 10 103 { 104 my $query = $dbh->prepare("SELECT MAX(so_id) from storage_object"); 105 $query->execute; 106 my $answer = $query->fetchrow_arrayref; 107 my $max_so_id = $$answer[0]; 108 $query->finish; 109 110 if ($so_id_start > $max_so_id) { 111 print STDERR "at end of so_id range, reset please\n"; 112 exit 10; 113 } 114 } 115 93 116 my $query = $dbh->prepare( 94 117 " SELECT … … 111 134 USING(vol_id) 112 135 WHERE mymountedvol.available = 1 113 -- WHERE storage_object_xattr.name = 'user.copies' 136 AND storage_object_xattr.name = 'user.copies' 137 AND storage_object.so_id >= $so_id_start 138 AND storage_object.so_id < $so_id_end 114 139 GROUP BY so_id 115 140 HAVING available_instances < instances OR instances < copies -
branches/cnb_branches/cnb_branch_20090301/Nebulous-Server/bin/neb-voladd
r19797 r23352 79 79 =head1 SYNOPSIS 80 80 81 neb-voladd --v olume <volumename> --uri <volume uri>81 neb-voladd --vname <volume name> --vhost <host name> --uri <volume uri> 82 82 [--db <database>] [--user <username>] [--pass <password>] [--host <hostname] 83 83 … … 92 92 =over 4 93 93 94 =item * --v olume <volume name>94 =item * --vname <volume name> 95 95 96 96 Symbolic name of volume being added. 97 98 =item * --vhost <host name> 99 100 Name of the host that containes the C<URI> of the volume being added. 97 101 98 102 =item * --uri|-u <volume uri> -
branches/cnb_branches/cnb_branch_20090301/Nebulous/Build.PL
r20131 r23352 11 11 my $pkg_dir = "./nebclient"; 12 12 13 sub ACTION_code { 14 my $self = shift; 15 16 $self->SUPER::ACTION_code(@_); 17 18 my $old_pwd = getcwd(); 19 chdir $pkg_dir; 20 21 unless (-e "configure") { 22 system("./autogen.sh") == 0 or die "install failed: $?"; 23 } 24 25 chdir $old_pwd; 26 } 27 28 sub ACTION_build { 29 my $self = shift; 30 31 $self->SUPER::ACTION_build(@_); 32 33 my $old_pwd = getcwd(); 34 chdir $pkg_dir; 35 36 unless (-e "Makefile") { 37 system("sh ./configure") == 0 or die "build failed: $?"; 38 } 39 40 system("make") == 0 or die "build failed: $?"; 41 42 chdir $old_pwd; 43 } 44 45 # Do not attempt to install nebclient. It is bundled in this package for 46 # testing only. 47 # 13 # sub ACTION_code { 14 # my $self = shift; 15 # 16 # $self->SUPER::ACTION_code(@_); 17 # 18 # my $old_pwd = getcwd(); 19 # chdir $pkg_dir; 20 # 21 # unless (-e "configure") { 22 # system("./autogen.sh") == 0 or die "install failed: $?"; 23 # } 24 # 25 # chdir $old_pwd; 26 # } 27 # 28 # sub ACTION_build { 29 # my $self = shift; 30 # 31 # $self->SUPER::ACTION_build(@_); 32 # 33 # my $old_pwd = getcwd(); 34 # chdir $pkg_dir; 35 # 36 # unless (-e "Makefile") { 37 # system("sh ./configure") == 0 or die "build failed: $?"; 38 # } 39 # 40 # system("make") == 0 or die "build failed: $?"; 41 # 42 # chdir $old_pwd; 43 # } 44 # 48 45 # sub ACTION_install { 49 46 # my $self = shift; … … 58 55 # chdir $old_pwd; 59 56 # } 60 61 sub ACTION_clean {62 my $self = shift;63 64 $self->SUPER::ACTION_clean(@_);65 66 my $old_pwd = getcwd();67 chdir $pkg_dir;68 69 system("make clean") == 0 or die "install failed: $?";70 71 chdir $old_pwd;72 }57 # 58 # sub ACTION_clean { 59 # my $self = shift; 60 # 61 # $self->SUPER::ACTION_clean(@_); 62 # 63 # my $old_pwd = getcwd(); 64 # chdir $pkg_dir; 65 # 66 # system("make clean") == 0 or die "install failed: $?"; 67 # 68 # chdir $old_pwd; 69 # } 73 70 EOF 74 71 -
branches/cnb_branches/cnb_branch_20090301/Nebulous/MANIFEST
r20131 r23352 20 20 bin/neb-touch 21 21 bin/neb-xattr 22 docs/c_api.h23 docs/database_setup.txt24 docs/design.txt25 docs/requirements.txt26 docs/setup.txt27 docs/tmp.txt28 22 examples/Makefile 29 23 examples/nebexample.c -
branches/cnb_branches/cnb_branch_20090301/Nebulous/nebclient/src
- Property svn:ignore
-
old new 1 Makefile.in 1 2 .deps 3 Makefile 4 soapClientLib.c 5 nebulous.h 6 soapClient.c 7 soapStub.h 8 soapC.c 9 soapH.h 10 soapServerLib.c 11 soapServer.c 2 12 .libs 3 Makefile4 Makefile.in5 SOAP.nsmap6 libnebclient.la7 nebclient.lo8 nebulous.h9 soapC.c10 soapC.lo11 soapClient.c12 soapClient.lo13 soapClientLib.c14 soapH.h15 soapServer.c16 soapServerLib.c17 soapStub.h18 stdsoap2.lo19 xmalloc.lo
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/Nebulous/nebclient/tests/tap/src
- Property svn:ignore
-
old new 6 6 .deps 7 7 Makefile 8 .libs
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/Nebulous/scripts/ptest.pl
r21545 r23352 5 5 6 6 use lib "./lib"; 7 package main; 7 8 8 use Nebulous::Client;9 #use Nebulous::Client; 9 10 use IO::Select; 10 11 use IO::Socket; 12 use POSIX qw(:DEFAULT :sys_wait_h); 13 use Hook::LexWrap; 14 use Sys::Hostname; 11 15 12 my $neb = Nebulous::Client->new( 13 # proxy => 'http://localhost:80/nebulous' 14 proxy => 'http://alala:80/nebulous' 15 ); 16 my $print_stdout = undef; 17 18 $| = 1; 16 19 17 20 my $key = shift || 'foobar'; 18 21 my $kids = shift || 1; 19 22 20 my $s = IO::Select->new(); 23 $key = "/tmp/" . $key; 24 25 #my $s = IO::Select->new(); 21 26 22 27 foreach my $id ( 1..$kids ) { 23 my ($sock_parent, $sock_child) = IO::Socket->socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC);24 $s->add($sock_parent);28 # my ($sock_parent, $sock_child) = IO::Socket->socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC); 29 # $s->add($sock_parent); 25 30 26 31 my $pid = fork; 27 32 28 33 unless ( $pid ) { 34 # child 35 my $sock_child = \*STDOUT; 29 36 child($sock_child, $id); 37 shutdown($sock_child, 2); 30 38 exit 0; 31 39 } … … 33 41 } 34 42 35 while ($kids) { 36 foreach my $child ($s->can_read(1)) { 37 my $string = <$child>; 38 my @events = split(/\n/, $string) if $string; 39 print join("\n", @events), "\n" if scalar @events; 43 $SIG{CHLD} = \&REAPER; 44 45 sub REAPER { 46 while ((my $pid = waitpid(-1,WNOHANG)) > 0) { 47 $kids--; 48 # delete $children{$pid}; 40 49 } 50 $SIG{CHLD} = \&REAPER; 41 51 } 42 52 43 #while ( $kids ) {44 # wait();45 # $kids --;46 #}47 53 48 our $my_sock; 54 while ($kids) { 55 # foreach my $child ($s->can_read(0)) { 56 # my $string = do { local $/; <$child>}; 57 # my @events = split(/\n/, $string) if $string; 58 # print join("\n", @events), "\n" if scalar @events; 59 # } 60 } 49 61 50 62 sub child 51 63 { 52 my ($sock _child, $id) = @_;64 my ($sock, $id) = @_; 53 65 54 $my_sock = $sock_child; 66 unless ($print_stdout) { 67 my $filename = hostname() . "." . $$ . ".txt"; 68 open my $fh, ">$filename" or die "can't open $filename: $!"; 69 70 open STDOUT, ">&", $fh or die "can't reopen STDOUT: $!"; 71 autoflush STDOUT 1; 72 } 73 74 # select $sock; 75 # $| = 1; 55 76 56 77 # child 57 78 my $fname = "${key}_$id"; 58 print $sock_child "$$ : i'm a little tea pot using key: $fname\n";59 my $fh = $neb->open_create( $fname );60 child_die("can't create file $fname") unless $fh;61 79 62 print $fh "fooby\n"; 80 my $neb = Nebulous::Client::Bench->new( 81 # proxy => 'http://localhost:80/nebulous' 82 proxy => 'http://alala:80/nebulous', 83 # sock => \*STDOUT, 84 ); 63 85 64 close $fh;65 86 66 $fh = $neb->open( $fname, 'read' ) or child_die("can't open file"); 67 close $fh; 87 while (1) { 88 # print $sock "$$ : i'm a little tea pot using key: $fname\n"; 89 my $fh = $neb->open_create( $fname ) 90 or child_die($sock, "can't create file $fname"); 91 close $fh; 68 92 69 $neb->lock( $fname, 'read' ); 70 $neb->unlock( $fname, 'read' ); 71 $neb->replicate( $fname ); 72 $neb->cull( $fname ); 93 $fh = $neb->open( $fname, 'read' ) 94 or child_die("can't open file"); 95 close $fh; 73 96 74 print $sock_child "$$ : half way\n"; 97 $neb->lock( $fname, 'read' ); 98 $neb->unlock( $fname, 'read' ); 99 $neb->replicate( $fname ); 100 $neb->cull( $fname ); 101 $neb->find( $fname ); 102 $neb->copy( $fname, $fname . "_copy" ); 103 $neb->move( $fname, $fname . "_move" ); 104 $neb->delete( $fname . "_copy" ); 105 $neb->delete( $fname . "_move" ); 75 106 76 $neb->find( $fname ); 77 $neb->copy( $fname, $fname . "_copy" ); 78 $neb->move( $fname, $fname . "_move" ); 79 $neb->delete( $fname . "_copy" ); 80 $neb->delete( $fname . "_move" ); 81 82 print $sock_child "$$ : all done!\n"; 83 84 $sock_child->flush; 85 sleep 10; 107 # print $sock "$$ : all done!\n"; 108 } 86 109 87 110 return 1; … … 90 113 sub child_die 91 114 { 92 print $my_sock $@; 93 shutdown($my_sock, 2); 115 my $sock = shift; 116 print $sock @_; 117 shutdown($sock, 2); 94 118 exit 1; 95 119 } 120 121 package Nebulous::Client::Bench; 122 123 use base qw( Nebulous::Client ); 124 125 #sub new 126 #{ 127 # my $class = shift; 128 # my %p = @_; 129 # 130 # my $sock = delete $p{sock}; 131 # my $self = $class->SUPER::new(%p); 132 # $self->{sock} = $sock; 133 # 134 # return $self; 135 #} 136 137 BEGIN { 138 sub make_wrapper 139 { 140 my $method = shift; 141 142 eval "sub $method {" 143 .' my $self = shift;' 144 .' my $smark = Time::HiRes::time();' 145 .' my $ret = $self->SUPER::' . "$method" .'(@_);' 146 .' my $emark = Time::HiRes::time();' 147 .' printf "%-17s %-17s %s\n", $emark, " ' . "$method" . ' ", ($emark - $smark), "\n";' 148 .' return $ret;' 149 .'}'; 150 151 } 152 153 make_wrapper("create"); 154 make_wrapper("open_create"); 155 make_wrapper("replicate"); 156 make_wrapper("cull"); 157 make_wrapper("lock"); 158 make_wrapper("unlock"); 159 make_wrapper("setxattr"); 160 make_wrapper("getxattr"); 161 make_wrapper("listxattr"); 162 make_wrapper("removexattr"); 163 make_wrapper("find_objects"); 164 make_wrapper("find_instances"); 165 #make_wrapper("find"); 166 #make_wrapper("open"); 167 #make_wrapper("delete"); 168 #make_wrapper("copy"); 169 make_wrapper("move"); 170 make_wrapper("swap"); 171 make_wrapper("delete_instance"); 172 make_wrapper("stat"); 173 make_wrapper("mounts"); 174 175 } 176 177 1; -
branches/cnb_branches/cnb_branch_20090301/Ohana
-
Property svn:mergeinfo
set to
/trunk/Ohana merged eligible
-
Property svn:mergeinfo
set to
-
branches/cnb_branches/cnb_branch_20090301/Ohana/Makefile.in
r19682 r23352 75 75 mkdir -p $(DESTLIB) 76 76 mkdir -p $(DESTBIN) 77 for i in $(LIBS); do make $$i.install || exit ; done77 for i in $(LIBS); do make $$i.install || exit 1; done 78 78 chmod +x ohana-config 79 79 cp -f ohana-config $(DESTBIN)/ … … 83 83 84 84 all: 85 make libs || exit 86 for i in $(PROGRAM); do make $$i || exit ; done85 make libs || exit 1 86 for i in $(PROGRAM); do make $$i || exit 1; done 87 87 88 88 extras: 89 for i in $(EXTRAS); do make $$i || exit ; done89 for i in $(EXTRAS); do make $$i || exit 1; done 90 90 91 91 pantasks: 92 make libs || exit 93 cd src/opihi; make pclient.install && exit 94 cd src/opihi; make pcontrol.install && exit 95 cd src/opihi; make pantasks.install && exit 92 make libs || exit 1 93 cd src/opihi; make pclient.install && exit 1 94 cd src/opihi; make pcontrol.install && exit 1 95 cd src/opihi; make pantasks.install && exit 1 96 96 97 97 mana: 98 98 make libs 99 99 make kapa2.install 100 cd src/opihi; make mana.install && exit 100 cd src/opihi; make mana.install && exit 1 101 101 102 102 dvoshell: 103 103 make libs 104 104 make kapa2.install 105 cd src/opihi; make dvo.install && exit 105 cd src/opihi; make dvo.install && exit 1 106 106 107 107 clean: 108 108 @if [ "$(ARCH)" = "" ]; then echo ""; echo " *** please define ARCH ***"; echo; exit 1; fi 109 for i in $(LIBS); do make $$i.clean || exit ; done110 for i in $(PROGRAM); do make $$i.clean || exit ; done111 for i in $(EXTRAS); do make $$i.clean || exit ; done109 for i in $(LIBS); do make $$i.clean || exit 1; done 110 for i in $(PROGRAM); do make $$i.clean || exit 1; done 111 for i in $(EXTRAS); do make $$i.clean || exit 1; done 112 112 @rm -f `find . -name .mana` 113 113 @rm -f `find . -name .dvo` … … 116 116 dist: 117 117 @if [ "$(ARCH)" = "" ]; then echo ""; echo " *** please define ARCH ***"; echo; exit 1; fi 118 for i in $(LIBS); do make $$i.dist || exit ; done119 for i in $(PROGRAM); do make $$i.dist || exit ; done118 for i in $(LIBS); do make $$i.dist || exit 1; done 119 for i in $(PROGRAM); do make $$i.dist || exit 1; done 120 120 @echo -n -e "\0033]0; *** Ohana: done $@ *** \0007" \ 121 121 122 122 install: 123 123 @if [ "$(ARCH)" = "" ]; then echo ""; echo " *** please define ARCH ***"; echo; exit 1; fi 124 for i in $(LIBS); do make $$i.install || exit ; done125 for i in $(PROGRAM); do make $$i.install || exit ; done124 for i in $(LIBS); do make $$i.install || exit 1; done 125 for i in $(PROGRAM); do make $$i.install || exit 1; done 126 126 @echo -n -e "\0033]0; *** Ohana: done $@ *** \0007" \ 127 127 128 128 install.extras: 129 for i in $(EXTRAS); do make $$i.install || exit ; done129 for i in $(EXTRAS); do make $$i.install || exit 1; done 130 130 @echo -n -e "\0033]0; *** Ohana: done $@ *** \0007" \ 131 131 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/addstar/include/skycells.h
r21508 r23352 12 12 # include <glob.h> 13 13 14 enum {SQUARES, TRIANGLES, LOCAL };14 enum {SQUARES, TRIANGLES, LOCAL, RINGS}; 15 15 enum {TETRAHEDRON, CUBE, OCTOHEDRON, DODECAHEDRON, ICOSAHEDRON}; 16 16 … … 67 67 double SCALE; 68 68 double PADDING; 69 double CELLSIZE; 69 70 int LEVEL; 70 71 … … 84 85 int sky_tessellation PROTO((FITS_DB *db, int level, int Nmax, int mode, double scale)); 85 86 int sky_tessellation_init PROTO((double scale)); 87 86 88 int sky_tessellation_local PROTO((FITS_DB *db, int level, int Nmax)); 87 89 int sky_tessellation_triangles PROTO((FITS_DB *db, int level, int Nmax)); 88 90 int sky_tessellation_squares PROTO((FITS_DB *db, int level, int Nmax)); 91 int sky_tessellation_rings PROTO((FITS_DB *db, int level, int Nmax)); 92 89 93 int sky_triangle_to_image PROTO((Image *image, SkyTriangle *triangle)); 90 94 int sky_triangle_to_rectangle PROTO((SkyRectangle *image, SkyTriangle *triangle)); 95 91 96 int sky_rectangle_local PROTO((SkyRectangle *rectangle)); 92 97 int sky_subdivide_image PROTO((Image *output, SkyRectangle *input, int Nx, int Ny)); 93 98 int sky_triangle_coords PROTO((SkyTriangle *triangle)); 99 100 SkyRectangle *sky_rectangle_ring PROTO((float dec, float dDEC, int *nring)); 101 94 102 SkyTriangle *sky_divide_triangles PROTO((SkyTriangle *in, int *ntriangles)); 95 103 SkyTriangle *sky_base_triangles PROTO((int *ntriangles)); -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/addstar/src/args_skycells.c
r21048 r23352 35 35 MODE = LOCAL; 36 36 } 37 if (!strcasecmp (argv[N], "rings")) { 38 MODE = RINGS; 39 } 37 40 remove_argument (N, &argc, argv); 38 41 } … … 140 143 141 144 LEVEL = 8; 142 if ((MODE != LOCAL) && (N = get_argument (argc, argv, "-level"))) { 143 remove_argument (N, &argc, argv); 144 LEVEL = strtol (argv[N], &ptr, 10); 145 remove_argument (N, &argc, argv); 146 if ((*ptr != 0) || (LEVEL < 0)) { 147 fprintf (stderr, "-level requires an integer (>= 0) argument\n"); 145 if ((MODE == SQUARES) || (MODE == TRIANGLES)) { 146 if ((N = get_argument (argc, argv, "-level"))) { 147 remove_argument (N, &argc, argv); 148 LEVEL = strtol (argv[N], &ptr, 10); 149 remove_argument (N, &argc, argv); 150 if ((*ptr != 0) || (LEVEL < 0)) { 151 fprintf (stderr, "-level requires an integer (>= 0) argument\n"); 152 help (); 153 } 154 } 155 } 156 157 CELLSIZE = 4.0; 158 if ((MODE == RINGS) && (N = get_argument (argc, argv, "-cellsize"))) { 159 remove_argument (N, &argc, argv); 160 CELLSIZE = strtod (argv[N], &ptr); 161 if ((*ptr != 0) || (CELLSIZE < 0.0)) { 162 fprintf (stderr, "-level requires a floating-point argument\n"); 148 163 help (); 149 164 } 165 remove_argument (N, &argc, argv); 150 166 } 151 167 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/addstar/src/get2mass_full.c
r21508 r23352 1 1 # include "addstar.h" 2 2 # include "2mass.h" 3 4 // XXX check to see if desired output format is PS1_V1 or later? (use 16bit version if not?) 3 5 4 6 // fill in the data for a JHK triplet star. takes a pointer to the start of the line the … … 171 173 172 174 switch (qual) { 173 case ' X': star[0].measure.photFlags |= 0x0000; break;174 case ' U': star[0].measure.photFlags |= 0x0001; break;175 case ' F': star[0].measure.photFlags |= 0x0002; break;176 case ' E': star[0].measure.photFlags |= 0x0003; break;177 case ' A': star[0].measure.photFlags |= 0x0004; break;178 case ' B': star[0].measure.photFlags |= 0x0005; break;179 case ' C': star[0].measure.photFlags |= 0x0006; break;180 case ' D': star[0].measure.photFlags |= 0x0007; break;175 case 'A': star[0].measure.photFlags |= 0x00000001; break; // was: 0x0004 176 case 'B': star[0].measure.photFlags |= 0x00000002; break; // was: 0x0005 177 case 'C': star[0].measure.photFlags |= 0x00000004; break; // was: 0x0006 178 case 'D': star[0].measure.photFlags |= 0x00000008; break; // was: 0x0007 179 case 'E': star[0].measure.photFlags |= 0x00000010; break; // was: 0x0003 180 case 'F': star[0].measure.photFlags |= 0x00000020; break; // was: 0x0002 181 case 'U': star[0].measure.photFlags |= 0x00000040; break; // was: 0x0001 182 case 'X': star[0].measure.photFlags |= 0x00000080; break; // was: 0x0000 181 183 default: 182 184 fprintf (stderr, "error!\n"); … … 189 191 190 192 switch (qual) { 191 case '0': star[0].measure.photFlags |= 0x0000 ; break;192 case '1': star[0].measure.photFlags |= 0x00 10; break;193 case '2': star[0].measure.photFlags |= 0x00 20; break;194 case '3': star[0].measure.photFlags |= 0x00 30; break;195 case '4': star[0].measure.photFlags |= 0x00 40; break;196 case '6': star[0].measure.photFlags |= 0x00 50; break;197 case '9': star[0].measure.photFlags |= 0x00 60; break;193 case '0': star[0].measure.photFlags |= 0x00000100; break; // was: 0x0000 194 case '1': star[0].measure.photFlags |= 0x00000200; break; // was: 0x0010 195 case '2': star[0].measure.photFlags |= 0x00000400; break; // was: 0x0020 196 case '3': star[0].measure.photFlags |= 0x00000800; break; // was: 0x0030 197 case '4': star[0].measure.photFlags |= 0x00001000; break; // was: 0x0040 198 case '6': star[0].measure.photFlags |= 0x00002000; break; // was: 0x0050 199 case '9': star[0].measure.photFlags |= 0x00004000; break; // was: 0x0060 198 200 default: 199 201 fprintf (stderr, "error!\n"); … … 206 208 207 209 switch (qual) { 208 case 'p': star[0].measure.photFlags |= 0x000 0; break;209 case 'c': star[0].measure.photFlags |= 0x0 100; break;210 case 'd': star[0].measure.photFlags |= 0x0 200; break;211 case 's': star[0].measure.photFlags |= 0x0 300; break;212 case 'b': star[0].measure.photFlags |= 0x0 400; break;213 case '0': star[0].measure.photFlags |= 0x0 500; break;210 case 'p': star[0].measure.photFlags |= 0x00010000; break; // was: 0x0000 211 case 'c': star[0].measure.photFlags |= 0x00020000; break; // was: 0x0100 212 case 'd': star[0].measure.photFlags |= 0x00040000; break; // was: 0x0200 213 case 's': star[0].measure.photFlags |= 0x00080000; break; // was: 0x0300 214 case 'b': star[0].measure.photFlags |= 0x00010000; break; // was: 0x0400 215 case '0': star[0].measure.photFlags |= 0x00020000; break; // was: 0x0500 214 216 default: 215 217 fprintf (stderr, "error!\n"); … … 222 224 223 225 switch (qual) { 224 case '0': star[0].measure.photFlags &= ~0x00 08; break;225 case '1': star[0].measure.photFlags &= ~0x0008; break;226 default: star[0].measure.photFlags |= 0x00 08; break;226 case '0': star[0].measure.photFlags &= ~0x00300000; break; // was: ~0x0008 227 case '1': star[0].measure.photFlags |= 0x00100000; break; // was: ~0x0008 228 default: star[0].measure.photFlags |= 0x00200000; break; // was: 0x0008 227 229 } 228 230 return (TRUE); … … 232 234 233 235 switch (qual) { 234 case '0': star[0].measure.photFlags &= ~0x0080; break; 235 case '1': star[0].measure.photFlags &= ~0x0080; break; 236 default: 237 star[0].measure.photFlags |= 0x0080; 236 case '0': star[0].measure.photFlags &= ~0x00c00000; break; // was: ~0x0080 237 case '1': star[0].measure.photFlags |= 0x00400000; break; // was: ~0x0080 238 default: star[0].measure.photFlags |= 0x00800000; // was: 0x0080 238 239 star[0].measure.extNsigma = 100.0; 239 240 break; … … 245 246 246 247 switch (qual) { 247 case '0': star[0].measure.photFlags &= ~0x0 800; break;248 case '1': star[0].measure.photFlags &= ~0x0800; break;249 default: star[0].measure.photFlags |= 0x0 800; break;248 case '0': star[0].measure.photFlags &= ~0x03000000; break; // was: ~0x0800 249 case '1': star[0].measure.photFlags |= 0x01000000; break; // was: ~0x0800 250 default: star[0].measure.photFlags |= 0x02000000; break; // was: 0x0800 250 251 } 251 252 return (TRUE); … … 255 256 256 257 switch (qual) { 257 case '0': star[0].measure.photFlags &= ~0x 1000; break;258 case '1': star[0].measure.photFlags &= ~0x1000; break;259 default: star[0].measure.photFlags |= 0x 1000; break;258 case '0': star[0].measure.photFlags &= ~0x0c000000; break; // was: ~0x1000 259 case '1': star[0].measure.photFlags |= 0x04000000; break; // was: ~0x1000 260 default: star[0].measure.photFlags |= 0x08000000; break; // was: 0x1000 260 261 } 261 262 return (TRUE); … … 265 266 266 267 switch (qual) { 267 case '0': star[0].measure.photFlags &= ~0x 2000; break;268 case '1': star[0].measure.photFlags |= 0x 2000; break;268 case '0': star[0].measure.photFlags &= ~0x10000000; break; // was: ~0x2000 269 case '1': star[0].measure.photFlags |= 0x10000000; break; // was: 0x2000 269 270 default: abort(); 270 271 } … … 272 273 } 273 274 275 // unused photFlags: 276 // 0x0000.8000 277 // 0x0004.0000 278 // 0x0008.0000 279 // 0x2000.0000 280 // 0x4000.0000 281 // 0x8000.0000 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/addstar/src/sky_tessalation.c
r21508 r23352 11 11 sky_tessellation_init (scale); 12 12 13 if (mode == SQUARES) { 14 sky_tessellation_squares (db, level, Nmax); 15 return TRUE; 16 } 17 18 if (mode == TRIANGLES) { 19 sky_tessellation_triangles (db, level, Nmax); 20 return TRUE; 21 } 22 23 if (mode == LOCAL) { 24 sky_tessellation_local (db, level, Nmax); 25 return TRUE; 13 switch (mode) { 14 case SQUARES: 15 sky_tessellation_squares (db, level, Nmax); 16 return TRUE; 17 case TRIANGLES: 18 sky_tessellation_triangles (db, level, Nmax); 19 return TRUE; 20 case LOCAL: 21 sky_tessellation_local (db, level, Nmax); 22 return TRUE; 23 case RINGS: 24 sky_tessellation_rings (db, level, Nmax); 25 return TRUE; 26 default: 27 break; 26 28 } 27 29 … … 222 224 223 225 free (image); 226 return (TRUE); 227 } 228 229 // the RINGS tessellation uses the declination zones proposed by Tamas Budavari 230 // we generate projects on uniform rings of constant dec height 231 int sky_tessellation_rings (FITS_DB *db, int level, int Nmax) { 232 233 int j, nDEC, Nimage, Nring; 234 float dec, dDEC; 235 SkyRectangle *ring; 236 Image *image; 237 238 // The tessellation has one input parameter: the approximate cell size. Starting with 239 // the cell size, determine the optimal projection cell height (dDEC) that results in an 240 // integer number of dec zones between -90 and +90 241 242 // in fact, we place a single image on each pole, so the real range of dec is 180.0 - CELLSIZE: 243 244 nDEC = (180.0 - CELLSIZE) / CELLSIZE; 245 dDEC = (180.0 - CELLSIZE) / nDEC; 246 nDEC += 2; 247 248 // a test 249 // for (dec = 0.0 + 0.5*dDEC; dec < +90.0; dec += dDEC) { 250 251 // generate the a collection of rectangles for each ring 252 for (dec = -90.0; dec < +90.0 + 0.5*dDEC; dec += dDEC) { 253 254 ring = sky_rectangle_ring (dec, dDEC, &Nring); 255 if (!ring) continue; 256 257 // subdivide each image (Nx x Ny subcells) 258 Nimage = NX_SUB*NY_SUB*Nring; 259 ALLOCATE (image, Image, Nimage); 260 for (j = 0; j < Nring; j++) { 261 // convert the SkyRectangles to Images for output 262 sky_subdivide_image (&image[j*NX_SUB*NY_SUB], &ring[j], NX_SUB, NY_SUB); 263 } 264 265 /* add the new images and save */ 266 dvo_image_addrows (db, image, Nimage); 267 SetProtect (TRUE); 268 dvo_image_update (db, VERBOSE); 269 SetProtect (FALSE); 270 dvo_image_clear_vtable (db); 271 272 free (ring); 273 free (image); 274 } 224 275 return (TRUE); 225 276 } … … 480 531 481 532 return (TRUE); 533 } 534 535 // define the parameters of a single sky projection center 536 SkyRectangle *sky_rectangle_ring (float dec, float dDEC, int *nring) { 537 538 int i, NX, NY, nRA; 539 SkyRectangle *ring; 540 float theta, dRA; 541 542 // 'dec' is a guess at the center of the cell; in fact, we need to choose decLower and 543 // decUpper to ensure complete overlap of the cells 544 545 // we can determine the 'lower' bound (bound closest to the equator): 546 float decLower = (dec > 0.0) ? dec - 0.5*dDEC : dec + 0.5*dDEC; 547 548 // solve for actual cellsize (\theta): tan(\delta_{n+1} - \theta/2) = tan(\delta_n + \theta/2)cos(\alpha_n / 2) 549 float decUpper = (dec > 0.0) ? dec + dDEC : dec - dDEC; 550 551 if (fabs(dec) + 0.5*dDEC > 90.0) { 552 // onPole = TRUE; 553 theta = dDEC; 554 nRA = 1; 555 dRA = theta / cos(decLower*RAD_DEG); // make a square at the pole 556 } else { 557 // onPole = FALSE; 558 // Subdivide the 'lower' bound into an integer number of segments: 559 nRA = cos(RAD_DEG*decLower) * 360.0 / CELLSIZE; // CELLSIZE is a projection size 560 dRA = 360.0 / nRA; // dRA is a size in RA degrees == \alpha_n 561 562 // tan(decUpper - theta/2) = tan(dec + theta/2) cos(dRA / 2); 563 564 // we solve this equation for theta (fairly ugly: expand the tangents into sin/cos, expand the 565 // sum-of-angle sine and cosine, multiply through, convert via half-angle formulae and write 566 // as a quadratic expression in sine(theta/2) 567 568 float sd1 = sin(RAD_DEG*decUpper); 569 float cd1 = cos(RAD_DEG*decUpper); 570 float sd2 = sin(RAD_DEG*dec); 571 float cd2 = cos(RAD_DEG*dec); 572 float k = cos(RAD_DEG*dRA/2.0); 573 574 float c1 = (sd1*cd2 + sd2*cd1)*(1.0 - k); 575 float c2 = (sd1*cd2 - sd2*cd1)*(1.0 + k); 576 float c3 = -(sd1*sd2 + cd1*cd2)*(1.0 + k); 577 578 float A = SQ(c3) + SQ(c2); 579 float B = 2*c1*c3; 580 float C = SQ(c1) - SQ(c2); 581 582 float arg = SQ(B) - 4.0*A*C; 583 584 float root; 585 586 if (dec >= 0.0) { 587 root = (-B + sqrt (arg)) / (2.0*A); 588 theta = +DEG_RAD*asin(root); 589 } else { 590 root = (-B - sqrt (arg)) / (2.0*A); 591 theta = -DEG_RAD*asin(root); 592 } 593 594 // the negative solution yields a negative cellsize 595 // float root2 = (-B - sqrt (arg)) / (2.0*A); 596 // float theta2 = DEG_RAD*asin(root2); 597 598 // test lines: 599 // float r1 = tan(RAD_DEG*(decUpper - 0.5*theta1)); 600 // float r2 = tan(RAD_DEG*(dec + 0.5*theta1)); 601 // fprintf (stdout, "%f %f %f %f %f %f %f %f %f %f %f\n", dec, decUpper, dRA, arg, root1, root2, theta1, theta2, r1, r2, k*r2); 602 } 603 fprintf (stdout, "%f %f %f x %f (%d)\n", dec, decUpper, dRA, theta, nRA); 604 605 // I think we need to return the value of dec for the next ring, but I am not sure... 606 607 ALLOCATE (ring, SkyRectangle, nRA); 608 609 for (i = 0; i < nRA; i++) { 610 memset (&ring[i], 0, sizeof(SkyRectangle)); 611 memset (&ring[i].coords, 0, sizeof(Coords)); 612 ring[i].coords.crval1 = i*dRA; 613 ring[i].coords.crval2 = dec; 614 615 ring[i].coords.pc1_1 = +1.0; 616 ring[i].coords.pc1_2 = +0.0; 617 ring[i].coords.pc2_1 = -0.0; 618 ring[i].coords.pc2_2 = +1.0; 619 620 // range values are in projected degrees 621 NX = cos(decLower*RAD_DEG) * dRA * 3600.0 / SCALE; 622 NY = theta * 3600.0 / SCALE; 623 624 // crpix1,crpix2 is the projection center 625 ring[i].coords.crpix1 = 0.5*NX; 626 ring[i].coords.crpix2 = 0.5*NY; 627 628 ring[i].coords.cdelt1 = SCALE / 3600.0; 629 ring[i].coords.cdelt2 = SCALE / 3600.0; 630 631 strcpy (ring[i].coords.ctype, "DEC--TAN"); 632 633 ring[i].NX = NX; 634 ring[i].NY = NY; 635 ring[i].photcode = 1; // this needs to be set more sensibly 636 637 638 // fprintf (stderr, "%f %f : %f %f\n", 639 // ring[i].coords.crval1, ring[i].coords.crval2, 640 // ring[i].coords.crpix1, ring[i].coords.crpix2); 641 } 642 643 *nring = nRA; 644 return (ring); 482 645 } 483 646 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/libdvo
- Property svn:ignore
-
old new 1 lib 1
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/Ohana/src/libdvo/lib
- Property svn:ignore
-
old new 1 *.linux 2 *.lin64 3 *.sol 4 *.sun 5 *.sid 6 *.hp 7 *.irix 8 *.darwin.dylib 9 *.darwin_x86.dylib 1 *.a 2 *.so
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/Ohana/src/libfits/lib
- Property svn:ignore
-
old new 1 *.linux 2 *.lin64 3 *.sol 4 *.sun 5 *.sid 6 *.hp 7 *.irix 8 *.darwin.dylib 9 *.darwin_x86.dylib 1 *.a 2 *.so
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/Ohana/src/libkapa/lib
- Property svn:ignore
-
old new 1 *.linux 2 *.lin64 3 *.sol 4 *.sun 5 *.sid 6 *.hp 7 *.irix 8 *.darwin.dylib 9 *.darwin_x86.dylib 1 *.a 2 *.so
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/Ohana/src/libohana/lib
- Property svn:ignore
-
old new 1 *.linux 2 *.lin64 3 *.sol 4 *.sun 5 *.sid 6 *.hp 7 *.irix 8 *.darwin.dylib 9 *.darwin_x86.dylib 1 *.a 2 *.so
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/Ohana/src/libohana/src/CommOps.c
r8385 r23352 14 14 return (status); 15 15 } 16 // fprintf (stderr, "resp: %s\n", command.buffer); 16 17 17 18 /* buffer contains an EOL NULL, we can just sscan it */ -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/libtap/lib
- Property svn:ignore
-
old new 1 *.linux 2 *.lin64 3 *.sol 4 *.sun 5 *.sid 6 *.hp 7 *.irix 8 *.darwin.dylib 9 *.darwin_x86.dylib 1 *.a 2 *.so
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/dimm/Analysis.c
r2598 r23352 86 86 } 87 87 88 /* find contiguous trigger pixels in row from starting point */ 89 90 int fillrow (float *buffer, int Nx, int offset, int sx, int *xs, int *xe) { 91 92 trigger = FALSE; 93 for (i = sx, pix = offset + i; buffer[pix] && (i < Nx); i++, pix++) { 94 addpix (pix); 95 buffer[pix] = 0; 96 trigger = TRUE; 97 *xe = i; 98 } 99 for (i = sx - 1, pix = offset + i; (i >= 0) && buffer[pix]; i--, pix--) { 100 addpix (pix); 101 buffer[pix] = 0; 102 trigger = TRUE; 103 *xs = i; 104 } 105 return (trigger); 106 } 107 108 static int Npix = 0; 109 static int *Pix = (int *) NULL; 110 111 addpix (int pix) { 112 Npix ++; 113 if (Pix == (int *) NULL) { 114 ALLOCATE (Pix, int, MAX (1, Npix)); 115 } else { 116 REALLOCATE (Pix, int, MAX (1, Npix)); 117 } 118 Pix[Npix - 1] = pix; 119 } 120 121 clearpix () { 122 Npix = 0; 123 REALLOCATE (Pix, int, 1); 124 } 125 126 statpix (double *x, double *y, float *buffer, int Nx) { 127 128 int X, Y; 129 double Sx, Sy, So; 130 131 So = Sx = Sy = 0; 132 for (i = 0; i < Npix; i++) { 133 Y = pix / Nx; 134 X = pix % Nx; 135 So += buffer[pix]; 136 Sx += X * buffer[pix]; 137 Sy += Y * buffer[pix]; 138 } 139 *x = Sx / So; 140 *y = Sy / So; 141 } 142 143 /* find stars: 144 - binarize @ threshold 145 - find all contiguous blobs 146 - find geom center of each blob 147 */ 148 149 150 151 /* 152 153 ..................... 154 ....x................ 155 ...xxx............... 156 ..........xxx.......... 157 .........xx.......... 158 ..................... 159 ..................... 160 ..................... 161 ..................... 162 ..................... 163 164 165 */ 166 88 167 # endif 89 168 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/dimm/Makefile
r17283 r23352 26 26 $(SRC)/init.$(ARCH).o \ 27 27 $(SRC)/dimm.$(ARCH).o \ 28 $(SRC)/camera .$(ARCH).o \28 $(SRC)/camera_cmds.$(ARCH).o \ 29 29 $(SRC)/findstars.$(ARCH).o \ 30 $(SRC)/telescope .$(ARCH).o \30 $(SRC)/telescope_cmds.$(ARCH).o \ 31 31 $(SRC)/version.$(ARCH).o 32 32 … … 64 64 .PHONY: dimm 65 65 66 # are these used or replaced? 67 # $(SRC)/analysis.$(ARCH).o \ 66 # these have not been finished: should be used for analysis of the extracted images 68 67 # $(SRC)/Analysis.$(ARCH).o \ 69 68 # $(SRC)/Image.$(ARCH).o \ -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/dimm/camera_cmds.c
- Property svn:mergeinfo changed
/trunk/Ohana/src/opihi/dimm/camera_cmds.c (added) merged: 22723-23289
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/dimm/telescope_cmds.c
- Property svn:mergeinfo changed
/trunk/Ohana/src/opihi/dimm/telescope_cmds.c (added) merged: 22723-23289
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/lib
-
Property svn:ignore
set to
*.a
*.so
-
Property svn:ignore
set to
-
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/CheckTasks.c
r15872 r23352 48 48 // add random offset between 0 and 5% of exec_period 49 49 // XXX this should be optional 50 fuzz = 0. 05*task[0].exec_period*drand48() + 1e-6*task[0].last.tv_usec;50 fuzz = 0.1*task[0].exec_period*drand48(); 51 51 task[0].last.tv_usec = 1e6*(fuzz - (int)fuzz); 52 52 task[0].last.tv_sec += (int) fuzz; -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/task_threads.c
r15791 r23352 2 2 3 3 /** things related to CheckTasks **/ 4 void ResetTaskTimers (); 4 5 5 6 static int CheckTasksRun = FALSE; 6 7 7 8 void CheckTasksSetState (int state) { 9 if (state && !CheckTasksRun) { 10 ResetTaskTimers (); 11 } 8 12 CheckTasksRun = state; 9 13 } … … 51 55 // timeout. this enforces a certain granularity in the task creation, but prevents the task 52 56 // thread from driving the load up to silly levels. 57 58 // reset all of the task timers, with a bit of fuzz. this is called 59 // whenever we transition from 'stop' to 'run' 60 void ResetTaskTimers () { 61 62 Task *task; 63 struct timeval now; 64 float fuzz; 65 66 // get the current time 67 gettimeofday (&now, NULL); 68 69 // check all tasks 70 while ((task = NextTask ()) != NULL) { 71 task[0].last.tv_usec = now.tv_usec; 72 task[0].last.tv_sec = now.tv_sec; 73 74 // add random offset between 0 and 10% of exec_period 75 // XXX this should be optional 76 fuzz = task[0].exec_period*drand48(); 77 task[0].last.tv_usec += 1e6*(fuzz - (int)fuzz); 78 task[0].last.tv_sec += (int) fuzz; 79 80 // gprint (GP_LOG, "fuzz: %f, last: %d %d\n", fuzz, task[0].last.tv_sec, task[0].last.tv_usec); 81 } 82 return; 83 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pcontrol/CheckIdleHost.c
r22675 r23352 40 40 host[0].job = (struct Job *) job; 41 41 42 if (logfile) fprintf (logfile, "start needhost %s (job host %s) : %s\n", host[0].hostname, job[0].hostname, job[0].argv[0]);42 // if (logfile) fprintf (logfile, "start needhost %s (job host %s) : %s\n", host[0].hostname, job[0].hostname, job[0].argv[0]); 43 43 44 44 /* take the job off the stack and unlock the stack */ … … 60 60 host[0].job = (struct Job *) job; 61 61 62 if (logfile) fprintf (logfile, "start wanthost %s (job host %s) : %s\n", host[0].hostname, job[0].hostname, job[0].argv[0]);62 // if (logfile) fprintf (logfile, "start wanthost %s (job host %s) : %s\n", host[0].hostname, job[0].hostname, job[0].argv[0]); 63 63 64 64 /* take the job off the stack and unlock the stack */ … … 78 78 host[0].job = (struct Job *) job; 79 79 80 if (logfile) fprintf (logfile, "start anyhost %s (job host %s) : %s\n", host[0].hostname, job[0].hostname, job[0].argv[0]);80 // if (logfile) fprintf (logfile, "start anyhost %s (job host %s) : %s\n", host[0].hostname, job[0].hostname, job[0].argv[0]); 81 81 82 82 /* take the job off the stack and unlock the stack */ -
branches/cnb_branches/cnb_branch_20090301/PS-IPP-Config/lib/PS/IPP/Config.pm
r21320 r23352 71 71 unless (defined $class) { 72 72 carp "Programming error"; 73 exit($PS_EXIT_PROG_ERROR);73 return undef; 74 74 } 75 75 … … 85 85 unless (open $file, $name) { 86 86 carp "Unable to open ipprc file $name: $!"; 87 exit($PS_EXIT_CONFIG_ERROR);87 return undef; 88 88 } 89 89 my @contents = <$file>; # Contents of the ipprc file … … 95 95 unless (defined $path) { 96 96 carp "PATH is not set in $name\n"; 97 exit($PS_EXIT_CONFIG_ERROR);97 return undef; 98 98 } 99 99 … … 112 112 bless $self, $class; 113 113 114 $self->load_site() ;115 $self->load_system() ;116 117 $self->define_camera($camera) if defined $camera;114 $self->load_site() or return undef; 115 $self->load_system() or return undef; 116 117 ( $self->define_camera($camera) or return undef ) if defined $camera; 118 118 119 119 return $self; … … 148 148 unless ($found) { 149 149 carp "Unable to find camera configuration file $filename\n"; 150 exit($PS_EXIT_CONFIG_ERROR);150 return undef; 151 151 } 152 152 } … … 158 158 159 159 carp "Unable to find configuration file: $filename"; 160 exit($PS_EXIT_CONFIG_ERROR);160 return undef; 161 161 } 162 162 … … 170 170 unless (defined $self) { 171 171 carp "Programming error"; 172 exit($PS_EXIT_PROG_ERROR);172 return undef; 173 173 } 174 174 … … 176 176 unless (defined $filename) { 177 177 carp "Unable to find site configuration file\n"; 178 exit($PS_EXIT_CONFIG_ERROR);178 return undef; 179 179 } 180 180 181 181 my $realfile = $self->_find_config($filename); # Resolved filename, after hunting the PATH 182 ( carp "Unable to find site configuration" and return undef ) unless defined $realfile; 182 183 183 184 # Read the file … … 185 186 unless (open $file, $realfile) { 186 187 carp "Unable to open site configuration file $realfile: $!"; 187 exit($PS_EXIT_CONFIG_ERROR);188 return undef; 188 189 } 189 190 … … 194 195 unless (defined $self->{_siteConfig}) { 195 196 carp "Failure to parse the site configuration file $realfile"; 196 exit($PS_EXIT_CONFIG_ERROR);197 return undef; 197 198 } 198 199 … … 207 208 unless (defined $self) { 208 209 carp "Programming error"; 209 exit($PS_EXIT_PROG_ERROR);210 return undef; 210 211 } 211 212 … … 213 214 unless (defined $filename) { 214 215 carp "Unable to find system configuration file\n"; 215 exit($PS_EXIT_CONFIG_ERROR);216 return undef; 216 217 } 217 218 218 219 my $realfile = $self->_find_config($filename); # Resolved filename, after hunting the PATH 220 ( carp "Unable to find system configuration" and return undef ) unless defined $realfile; 219 221 220 222 # Read the file … … 222 224 unless (open $file, $realfile) { 223 225 carp "Unable to open system configuration file $realfile: $!"; 224 exit($PS_EXIT_CONFIG_ERROR);226 return undef; 225 227 } 226 228 my @contents = <$file>; … … 230 232 unless (defined $self->{_systemConfig}) { 231 233 carp "Failure to define system configuration"; 232 exit($PS_EXIT_CONFIG_ERROR);234 return undef; 233 235 } 234 236 … … 244 246 unless (defined $self and defined $name) { 245 247 carp "Programming error"; 246 exit($PS_EXIT_PROG_ERROR);248 return undef; 247 249 } 248 250 … … 251 253 unless (defined $filename) { 252 254 carp "Unable to find configuration file for camera $name\n"; 253 exit($PS_EXIT_CONFIG_ERROR);255 return undef; 254 256 } 255 257 256 258 my $realfile = $self->_find_config($filename); # Resolved filename, after hunting the PATH 259 ( carp "Unable to find camera configuration" and return undef ) unless defined $realfile; 257 260 258 261 # Read the file … … 260 263 unless (open $file, $realfile) { 261 264 carp "Unable to open camera configuration file $realfile: $!"; 262 exit($PS_EXIT_CONFIG_ERROR);265 return undef; 263 266 } 264 267 my @contents = <$file>; … … 269 272 unless (defined $self->{camera}) { 270 273 carp "Failure to define camera"; 271 exit($PS_EXIT_CONFIG_ERROR);274 return undef; 272 275 } 273 276 … … 326 329 unless (defined $self and defined $name) { 327 330 carp "Programming error"; 328 exit($PS_EXIT_PROG_ERROR);331 return undef; 329 332 } 330 333 … … 333 336 unless (defined $pathname) { 334 337 carp "Unable to find datapath $name\n" ; 335 exit($PS_EXIT_CONFIG_ERROR);338 return undef; 336 339 } 337 340 … … 340 343 341 344 # convert the database name and the table ID to a image source id 342 sub source_id 345 sub source_id 343 346 { 344 347 my $self = shift; … … 351 354 my $admindb = "ippadmin"; 352 355 353 die "dbserver not defined in configuration"unless defined($dbserver);354 die "dbuser not defined in configuration"unless defined($dbuser);355 die "dbpassword not defined in configuration"unless defined($dbpassword);356 die "dbname not defined in configuration"unless defined($dbname);356 ( carp "dbserver not defined in configuration" and return undef ) unless defined($dbserver); 357 ( carp "dbuser not defined in configuration" and return undef ) unless defined($dbuser); 358 ( carp "dbpassword not defined in configuration" and return undef ) unless defined($dbpassword); 359 ( carp "dbname not defined in configuration" and return undef ) unless defined($dbname); 357 360 358 361 my $dsn = "DBI:mysql:host=$dbserver;database=$admindb"; … … 363 366 $stmt->execute(); 364 367 my $ref = $stmt->fetchrow_hashref(); 365 die "ippdb $dbname not found"unless ($ref);368 ( carp "ippdb $dbname not found" and return undef ) unless ($ref); 366 369 367 370 my $proj_id = $ref->{proj_id}; … … 382 385 if ($@) { 383 386 carp "Can't find Nebulous::Client."; 384 exit($PS_EXIT_PROG_ERROR);387 return undef; 385 388 } 386 389 … … 390 393 unless (defined $server) { 391 394 carp "Unable to find NEB_SERVER in camera configuration file."; 392 exit($PS_EXIT_CONFIG_ERROR);393 } 394 395 my $neb = Nebulous::Client->new( proxy => $server );396 unless (defined $neb) {395 return undef; 396 } 397 398 my $neb = eval { Nebulous::Client->new( proxy => $server ); }; 399 if ($@ or not defined $neb) { 397 400 carp "Unable to find NEB_SERVER in camera configuration file."; 398 exit($PS_EXIT_CONFIG_ERROR);401 return undef; 399 402 } 400 403 … … 415 418 if ($scheme) { 416 419 $scheme = lc($scheme); 417 # print "scheme: $scheme\n";420 # print "scheme: $scheme\n"; 418 421 419 422 if ($scheme eq 'neb') { 420 $self->_neb_start() ;423 $self->_neb_start() or ( carp "Can't start Nebulous" and return undef ); 421 424 my $neb = $self->{nebulous}; # Nebulous handle 422 425 if ($create_if_doesnt_exist) { 423 unless ($neb->stat( $name )) { 424 # print "entry $name not found, creating...\n"; 425 my $uri = $neb->create( $name ); 426 unless(defined $uri) { 426 my $status = eval { $neb->stat( $name ); }; 427 ( carp "Unable to stat Nebulous handle $name" and return undef ) if $@; 428 unless ($status) { 429 # print "entry $name not found, creating...\n"; 430 my $uri = eval { $neb->create( $name ); }; 431 if ($@ or not defined $uri) { 427 432 carp "unable to instantiate $name."; 428 exit($PS_EXIT_DATA_ERROR);433 return undef; 429 434 } 430 435 my $path = URI->new( $uri )->path; 431 # print "created path: $path\n";436 # print "created path: $path\n"; 432 437 return $path; 433 438 } 434 439 } 435 my $path = $neb->find( $name );436 if (not defined $path) { 437 carp "neb entry $name not found, not created\n"; 438 exit($PS_EXIT_DATA_ERROR);439 } 440 # print "found path: $path\n";440 my $path = eval { $neb->find( $name ); }; 441 if ($@ or not defined $path) { 442 carp "neb entry $name not found, not created\n"; 443 return undef; 444 } 445 # print "found path: $path\n"; 441 446 return $path; 442 447 } … … 444 449 if ($scheme eq 'path' or $scheme eq 'file') { 445 450 # guaranteed to have a scheme (path:// or file://) 446 $name = $self->convert_filename_absolute( $name ) ;447 # print "resolved path to $name\n";451 $name = $self->convert_filename_absolute( $name ) or return undef; 452 # print "resolved path to $name\n"; 448 453 } 449 454 } … … 454 459 if (! -e $dir) { 455 460 my $rc = system "mkdir -p $dir"; 456 die "failed to create directory for $name"unless (!$rc);461 ( carp "failed to create directory for $name" and return undef ) unless (!$rc); 457 462 } elsif (! -d $dir ) { 458 die "parent for $name exists and is not a directory"; 459 } 460 461 open F, ">$name" or die "failed to create $name"; 463 carp "parent for $name exists and is not a directory"; 464 return undef; 465 } 466 467 open F, ">$name" or ( carp "failed to create $name" and return undef ); 462 468 close F; 463 # print "created target $name\n";469 # print "created target $name\n"; 464 470 } 465 471 … … 473 479 my $name = shift; # File name to check 474 480 475 $self->file_prepare( $name ) ;481 $self->file_prepare( $name ) or return undef; 476 482 477 483 my $scheme = file_scheme($name); # The scheme, e.g., file://, path:// … … 479 485 $scheme = lc($scheme); 480 486 if ($scheme eq 'neb') { 481 $self->_neb_start(); 482 return $self->{nebulous}->open_create( $name ); 487 $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef ); 488 my $fh = eval { $self->{nebulous}->open_create( $name ); }; 489 if ($@ or not defined $fh) { 490 carp "Unable to open/create Nebulous handle $name"; 491 return undef; 492 } 493 return $fh; 483 494 } 484 495 if ($scheme eq 'path' or $scheme eq 'file') { 485 496 # guaranteed to have a scheme (path:// or file://) 486 $name = $self->convert_filename_absolute( $name ) ;497 $name = $self->convert_filename_absolute( $name ) or return undef; 487 498 } 488 499 } … … 490 501 if (-f $name) { 491 502 carp "Unable to create file $name --- file exists."; 492 exit($PS_EXIT_SYS_ERROR);503 return undef; 493 504 } 494 505 … … 496 507 unless (open $fh, '>', $name) { 497 508 carp "Unable to create file $name --- $!"; 498 exit($PS_EXIT_SYS_ERROR);509 return undef; 499 510 } 500 511 return $fh; … … 507 518 my $name = shift; # File name to check 508 519 509 $self->file_prepare( $name ) ;520 $self->file_prepare( $name ) or return undef; 510 521 511 522 my $scheme = file_scheme($name); # The scheme, e.g., file://, path:// … … 513 524 $scheme = lc($scheme); 514 525 if ($scheme eq 'neb') { 515 $self->_neb_start(); 516 return $self->{nebulous}->open_create( $name ); 526 $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef ); 527 my $fh = eval { $self->{nebulous}->open_create( $name ) }; 528 if ($@ or not defined $fh) { 529 carp "Unable to open/create Nebulous handle $name"; 530 return undef; 531 } 532 return $fh; 517 533 } 518 534 if ($scheme eq 'path' or $scheme eq 'file') { 519 535 # guaranteed to have a scheme (path:// or file://) 520 $name = $self->convert_filename_absolute( $name ) ;536 $name = $self->convert_filename_absolute( $name ) or return undef; 521 537 } 522 538 } … … 525 541 unless (open $fh, '>>', $name) { 526 542 carp "Unable to create file $name --- $!"; 527 exit($PS_EXIT_SYS_ERROR);543 return undef; 528 544 } 529 545 return $fh; … … 536 552 my $name = shift; # File name to check 537 553 538 $self->file_prepare( $name ) ;554 $self->file_prepare( $name ) or return undef; 539 555 540 556 my $scheme = file_scheme($name); # The scheme, e.g., file://, path:// 541 557 if (defined $scheme and lc($scheme) eq 'neb') { 542 $self->_neb_start(); 543 $name = $self->{nebulous}->create( $name ); 558 $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef ); 559 $name = eval { $self->{nebulous}->create( $name ) }; 560 if ($@ or not defined $name) { 561 carp "Unable to create Nebulous handle $name"; 562 return undef; 563 } 544 564 } 545 565 … … 555 575 my $scheme = file_scheme($name); # The scheme, e.g., file://, path:// 556 576 if (defined $scheme and lc($scheme) eq 'neb') { 557 $self->_neb_start(); 558 return (defined $self->{nebulous}->find_instances( $name ) ? 1 : 0); 577 $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef ); 578 my $found = eval { $self->{nebulous}->find_instances( $name ); }; 579 ( carp "Unable to find instances of Nebulous handle $name" and return undef ) if $@; 580 return (defined $found ? 1 : 0); 559 581 } 560 582 … … 569 591 my $target = shift; # Name of target file 570 592 571 $self->file_prepare( $target ) ;593 $self->file_prepare( $target ) or return undef; 572 594 573 595 my $scheme = file_scheme($target); # The scheme, e.g., file://, path:// 574 596 if (defined $scheme and lc($scheme) eq 'neb') { 575 $self->_neb_start(); 576 $target = $self->{nebulous}->create( $target ); 597 $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef ); 598 $target = eval { $self->{nebulous}->create( $target ); }; 599 if ($@ or not defined $target) { 600 carp "Unable to create Nebulous handle"; 601 return undef; 602 } 577 603 } 578 604 $target = $self->file_resolve( $target ); 579 605 $source = $self->file_resolve( $source ); 580 606 581 system("cp $source $target") == 0 or (carp "Can't copy file $source to $target." and 582 exit($PS_EXIT_DATA_ERROR)); 607 system("cp $source $target") == 0 or ( carp "Can't copy file $source to $target." and return undef ); 583 608 return 1; 584 609 } … … 593 618 my $preserve = shift; 594 619 595 die "pathname must be defined"unless ($pathname);620 ( carp "pathname must be defined" and return undef ) unless ($pathname); 596 621 597 622 my $fileRef; … … 602 627 603 628 if ($preserve) { 604 # we want to keep the file just create it in the current directory 629 # we want to keep the file just create it in the current directory 605 630 $fileName = "./$base"; 606 open $fileRef, ">$fileName" or die "can't open $fileName for output";631 open $fileRef, ">$fileName" or ( carp "can't open $fileName for output" and return undef ); 607 632 } else { 608 633 # we really want a tempfile, so put it in /tmp … … 621 646 my $scheme = file_scheme($name); # The scheme, e.g., file://, path:// 622 647 if (defined $scheme and lc($scheme) eq 'neb') { 623 $self->_neb_start(); 624 $status = $self->{nebulous}->delete( $name ); 648 $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef ); 649 $status = eval { $self->{nebulous}->delete( $name ); }; 650 ( carp "Unable to delete Nebulous handle $name" and return undef ) if $@; 625 651 } else { 626 my $resolved = $self->file_resolve($name) ;627 if ( $resolved &&-e $resolved) {652 my $resolved = $self->file_resolve($name) or return undef; 653 if (defined $resolved and -e $resolved) { 628 654 $status = unlink($resolved); 629 655 } … … 638 664 my $name = shift; 639 665 640 die "need name"unless $name;666 ( carp "need redirection target" and return undef ) unless $name; 641 667 642 668 my $filename = $self->file_resolve($name, 1); 643 669 644 die "cannot resolve $name"unless $filename;670 ( carp "cannot resolve $name" and return undef ) unless $filename; 645 671 646 672 if (! open(STDOUT, ">>$filename") ) { … … 651 677 while (! open STDOUT, ">>$filename" ) { 652 678 if ($try == $max_tries) { 653 die "failed to redirect stdout to $filename after trying $max_tries times"; 679 carp "failed to redirect stdout to $filename after trying $max_tries times"; 680 return undef; 654 681 } 655 682 sleep 5; … … 658 685 print STDERR " redirect stdout to $filename succeded on try $try\n"; 659 686 } 660 open STDERR, ">>$filename" or die "failed to redirect stderr to $filename"; 687 open STDERR, ">>$filename" or ( carp "failed to redirect stderr to $filename" and return undef ); 688 689 return 1; 661 690 } 662 691 … … 676 705 my $name = shift; # File name for which to prepare 677 706 my $workdir = shift; # Working directory 678 my $template = shift; # Template filename from which to get working directory if 707 my $template = shift; # Template filename from which to get working directory if 679 708 680 709 if (defined $workdir) { … … 692 721 # not guaranteed to have a scheme (path:// or file://) - might be /PATH/foobar 693 722 # a relative path (PATH/foobar) is invalid here 694 my $resolved = $self->convert_filename_absolute( $name ) ;723 my $resolved = $self->convert_filename_absolute( $name ) or return undef; 695 724 my ( $vol, $dirs, $file ) = File::Spec->splitpath( $resolved ); 696 725 unless (-d $dirs) { 697 system("mkdir -p $dirs") == 0 or ( carp "Can't create directory $dirs" and exit($PS_EXIT_DATA_ERROR));726 system("mkdir -p $dirs") == 0 or ( carp "Can't create directory $dirs" and return undef ); 698 727 } 699 728 … … 716 745 # not guaranteed to have a scheme (path:// or file://) - might be /PATH/foobar 717 746 # a relative path (PATH/foobar) is invalid here 718 my $resolved = $self->convert_filename_absolute( $outroot ) ;747 my $resolved = $self->convert_filename_absolute( $outroot ) or return undef; 719 748 my ( $vol, $dirs, $file ) = File::Spec->splitpath( $resolved ); 720 749 unless (-d $dirs) { 721 system("mkdir -p $dirs") == 0 or ( carp "Can't create directory $dirs" and exit($PS_EXIT_DATA_ERROR));750 system("mkdir -p $dirs") == 0 or ( carp "Can't create directory $dirs" and return undef ); 722 751 } 723 752 … … 734 763 unless (defined $self and defined $name) { 735 764 carp "Programming error"; 736 exit($PS_EXIT_PROG_ERROR);765 return undef; 737 766 } 738 767 … … 741 770 742 771 ## if this is already an absolute path (/PATH/file), just return the path 743 unless (defined $scheme) { 772 unless (defined $scheme) { 744 773 if ($name =~ m|^/|) { return $name; } 745 774 # without a leading slash, this is an error 746 775 carp "Relative file name provided: relative paths are not permitted."; 747 exit($PS_EXIT_SYS_ERROR);776 return undef; 748 777 } 749 778 … … 751 780 752 781 if (lc($scheme) eq 'file') { 753 # the above strips of the leading slash; replace it for file:// 782 # the above strips of the leading slash; replace it for file:// 754 783 $name = '/' . $name; 755 784 return $name; … … 764 793 } 765 794 766 # looks like we cannot reach here without an invalid scheme. 767 # programming error? 768 # return $name; 769 770 carp "Programming error"; 771 exit($PS_EXIT_PROG_ERROR); 795 # It's already absolute 796 return $name; 772 797 } 773 798 … … 777 802 my $self = shift; # Configuration object 778 803 my $name = shift; # raw name 779 804 780 805 unless (defined $self and defined $name) { 781 806 carp "Programming error"; 782 exit($PS_EXIT_PROG_ERROR);783 } 784 807 return undef; 808 } 809 785 810 # First, check to see if it's already in a relative form 786 811 my $scheme = file_scheme($name); # The scheme, e.g., file, path … … 790 815 # We may as well search for a 'better' path 791 816 # guaranteed to have a scheme (path:// or file://) 792 $name = $self->convert_filename_absolute( $name ) ;817 $name = $self->convert_filename_absolute( $name ) or return undef; 793 818 } elsif ($scheme eq 'neb') { 794 819 # No chance of changing anything --- move along … … 796 821 } 797 822 } 798 823 799 824 $name = File::Spec->canonpath( $name); # Clean up 800 825 my @dirs = File::Spec->splitdir( $name ); 801 826 802 827 my $path_list = metadataLookupMD($self->{_siteConfig}, 'DATAPATH'); # List of paths 803 828 my $best_path; … … 809 834 $path =~ s|/*$||; 810 835 my @path_dirs = File::Spec->splitdir( $path ); 811 836 812 837 # Check if the path is suitable 813 838 next if scalar @path_dirs > scalar @dirs; … … 823 848 } 824 849 } 825 850 826 851 $name =~ s|^/||; 827 852 $name =~ s|/$||; … … 845 870 unless (defined $self and defined $name and defined $type) { 846 871 carp "Programming error"; 847 exit($PS_EXIT_PROG_ERROR);872 return undef; 848 873 } 849 874 … … 854 879 return undef; 855 880 } 856 881 857 882 # rejections are saved as a recipe: REJECTIONS 858 883 my @rejContents = `ppConfigDump -dump-recipe REJECTIONS -camera $camera -`; 859 884 860 885 # load from resulting psMetadataConfig 861 886 $self->{rejection} = $parser->parse( join '', @rejContents); # The rejection metadata 862 887 unless (defined $self->{rejection}) { 863 888 carp "Unable to parse REJECTION recipe for $camera."; 864 exit($PS_EXIT_CONFIG_ERROR);889 return undef; 865 890 } 866 891 } … … 873 898 unless ($item->{class} eq "metadata") { 874 899 carp "$name within REJECTIONS is not of type METADATA"; 875 exit($PS_EXIT_PROG_ERROR);900 return undef; 876 901 } 877 902 my $limits = $item->{value}; # List of rejection limits … … 880 905 foreach my $limit (@$limits) { 881 906 if ($limit->{name} eq 'FILTER') { 882 if ($limit->{value} eq '*' or 883 (defined $filter and 884 $limit->{value} eq $filter)) { 907 if ($limit->{value} eq '*' or (defined $filter and $limit->{value} eq $filter)) { 885 908 last; 886 909 } … … 888 911 } 889 912 } 890 913 891 914 foreach my $limit (@$limits) { 892 915 return $limit->{value} if $limit->{name} eq $name; … … 915 938 unless (defined $self and defined $name and defined $output) { 916 939 carp "Programming error: required inputs left undefined"; 917 exit($PS_EXIT_PROG_ERROR);940 return undef; 918 941 } 919 942 … … 929 952 return undef; 930 953 } 931 954 932 955 $filerules = metadataLookup($camera, 'FILERULES'); # File rules 933 956 unless (defined $filerules) { … … 935 958 return undef; 936 959 } 937 960 938 961 if ($filerules->{class} eq "scalar" and $filerules->{type} eq "STR") { 939 962 # Allow indirection to a file 940 963 my $filename = $self->_find_config($filerules->{value}); # Resolved filename 964 ( carp "Unable to find file rules file" and return undef ) unless defined $filename; 965 941 966 # Read the file 942 967 my $file; # File handle 943 968 unless (open $file, $filename) { 944 969 carp "Unable to open filerules file $filename: $!"; 945 exit($PS_EXIT_CONFIG_ERROR);970 return undef; 946 971 } 947 972 my @contents = <$file>; … … 973 998 unless (defined $component) { 974 999 carp "Programming error"; 975 exit($PS_EXIT_PROG_ERROR);1000 return undef; 976 1001 } 977 1002 $filename =~ s/\{CHIP\.NAME\}/$component/; … … 980 1005 981 1006 return $filename; 982 } 1007 } 983 1008 984 1009 # Return an EXTNAME From the EXTNAME.RULE table in the camera configuration … … 991 1016 unless (defined $self and defined $name) { 992 1017 carp "Programming error"; 993 exit($PS_EXIT_PROG_ERROR);1018 return undef; 994 1019 } 995 1020 … … 1015 1040 unless (defined $component) { 1016 1041 carp "Programming error"; 1017 exit($PS_EXIT_PROG_ERROR);1042 return undef; 1018 1043 } 1019 1044 $extname =~ s/\{CHIP\.NAME\}/$component/; … … 1021 1046 1022 1047 return $extname; 1023 } 1048 } 1024 1049 1025 1050 # Return catdir for tessellation, from TESSELLATIONS within the site configuration … … 1031 1056 unless (defined $self and defined $self->{_siteConfig} and defined $tess_id) { 1032 1057 carp "Programming error"; 1033 exit($PS_EXIT_PROG_ERROR);1058 return undef; 1034 1059 } 1035 1060 … … 1037 1062 unless (defined $tessellations) { 1038 1063 carp "Can't find TESSELLATIONS in site configuration.\n"; 1039 exit($PS_EXIT_CONFIG_ERROR);1064 return undef; 1040 1065 } 1041 1066 … … 1050 1075 if (defined $scheme and lc($scheme) eq 'neb') { 1051 1076 carp "Tessellation $tess_id refers to a Nebulous path: $catdir\n"; 1052 exit($PS_EXIT_CONFIG_ERROR);1077 return undef; 1053 1078 } 1054 1079 … … 1065 1090 unless (defined $self and defined $self->{_siteConfig} and defined $dvodb) { 1066 1091 carp "Programming error"; 1067 exit($PS_EXIT_PROG_ERROR);1092 return undef; 1068 1093 } 1069 1094 … … 1071 1096 unless (defined $catdirs) { 1072 1097 carp "Can't find DVO.CATDIRS in site configuration.\n"; 1073 exit($PS_EXIT_CONFIG_ERROR);1098 return undef; 1074 1099 } 1075 1100 … … 1084 1109 if (defined $scheme and lc($scheme) eq 'neb') { 1085 1110 carp "DVO catdir $dvodb refers to a Nebulous path: $catdir\n"; 1086 exit($PS_EXIT_CONFIG_ERROR);1111 return undef; 1087 1112 } 1088 1113 … … 1098 1123 unless (defined $self and defined $self->{_siteConfig} and defined $dvodb) { 1099 1124 carp "Programming error"; 1100 exit($PS_EXIT_PROG_ERROR);1125 return undef; 1101 1126 } 1102 1127 … … 1104 1129 unless (defined $catdirs) { 1105 1130 carp "Can't find PSASTRO.CATDIRS in site configuration.\n"; 1106 exit($PS_EXIT_CONFIG_ERROR);1131 return undef; 1107 1132 } 1108 1133 … … 1117 1142 if (defined $scheme and lc($scheme) eq 'neb') { 1118 1143 carp "PSASTRO catdir $dvodb refers to a Nebulous path: $catdir\n"; 1119 exit($PS_EXIT_CONFIG_ERROR);1144 return undef; 1120 1145 } 1121 1146 … … 1130 1155 unless (defined $self) { 1131 1156 carp "Programming error"; 1132 exit($PS_EXIT_PROG_ERROR);1157 return undef; 1133 1158 } 1134 1159 … … 1158 1183 unless (defined $self and defined $reduction and defined $name) { 1159 1184 carp "Programming error --- inputs undefined"; 1160 exit($PS_EXIT_PROG_ERROR);1185 return undef; 1161 1186 } 1162 1187 … … 1180 1205 return undef; 1181 1206 } 1182 1207 1183 1208 if ($reductionClasses->{class} eq "scalar" and $reductionClasses->{type} eq "STR") { 1184 1209 # Allow indirection to a file 1185 1210 my $filename = $self->_find_config($reductionClasses->{value}); # Resolved filename 1211 ( carp "Unable to find reduction classes file" and return undef ) unless defined $filename; 1186 1212 # Read the file 1187 1213 my $file; # File handle 1188 1214 unless (open $file, $filename) { 1189 1215 carp "Unable to open reductionClasses file $filename: $!"; 1190 exit($PS_EXIT_CONFIG_ERROR);1216 return undef; 1191 1217 } 1192 1218 my @contents = <$file>; … … 1203 1229 1204 1230 my $class = metadataLookupMD($reductionClasses, $reduction) or # Class of interest 1205 (carp "Can't find $reduction in REDUCTION in camera configuration.\n" and 1206 exit($PS_EXIT_CONFIG_ERROR)); 1231 ( carp "Can't find $reduction in REDUCTION in camera configuration.\n" and return undef ); 1207 1232 1208 1233 my $actual = metadataLookupStr($class, $name) or # The actual recipe name of interest 1209 (carp "Can't find $name in $class in REDUCTION in camera configuration.\n" and 1210 exit($PS_EXIT_CONFIG_ERROR)); 1234 (carp "Can't find $name in $class in REDUCTION in camera configuration.\n" and return undef ); 1211 1235 1212 1236 return $actual; … … 1226 1250 } 1227 1251 1228 my $dvoImageExtract = can_run('dvoImageExtract') or die "Can't find dvoImageExtract";1229 1252 my $dvoImageExtract = can_run('dvoImageExtract') or ( carp "Can't find dvoImageExtract" and return undef ); 1253 1230 1254 my $tess_dir = $self->tessellation_catdir( $tess_id ); # Tessellation catdir for DVO 1231 1255 unless (defined $tess_dir) { 1232 1256 carp "Can't get list of tessellations."; 1233 return 0;1234 } 1235 $tess_dir = $self->convert_filename_absolute( $tess_dir ) ;1257 return undef; 1258 } 1259 $tess_dir = $self->convert_filename_absolute( $tess_dir ) or return undef; 1236 1260 1237 1261 unless ($self->file_exists( $outname )) { 1238 my $outnameResolved = $self->file_create( $outname ) ; # Resolved filename, for Nebulous1262 my $outnameResolved = $self->file_create( $outname ) or return undef; # Resolved filename, for Nebulous 1239 1263 my $command = "$dvoImageExtract -D CATDIR $tess_dir $skycell_id -o $outnameResolved"; 1240 1264 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1241 1265 run(command => $command, verbose => $verbose); 1242 die "Unable to perform dvoImageExtract for $tess_id $skycell_id\n"unless ($success and $self->file_exists( $outname ));1266 ( carp "Unable to perform dvoImageExtract for $tess_id $skycell_id\n" and return undef ) unless ($success and $self->file_exists( $outname )); 1243 1267 } 1244 1268 … … 1258 1282 unless (defined $value) { 1259 1283 carp "Unable to find environment variable $name"; 1260 exit($PS_EXIT_SYS_ERROR);1284 return undef; 1261 1285 } 1262 1286 $dir =~ s/\$\{?$name\}?/$value\//; … … 1272 1296 unless (defined $mdc and defined $name) { 1273 1297 carp "Programming error"; 1274 exit($PS_EXIT_PROG_ERROR);1298 return undef; 1275 1299 } 1276 1300 … … 1285 1309 return undef; 1286 1310 } 1287 1311 1288 1312 1289 1313 # Lookup the metadata, checking the type is STR … … 1325 1349 unless (defined $mdc and defined $name) { 1326 1350 carp "Programming error"; 1327 exit($PS_EXIT_PROG_ERROR);1351 return undef; 1328 1352 } 1329 1353 -
branches/cnb_branches/cnb_branch_20090301/archive/conv_variance/fake.c
r20210 r23352 47 47 psFree(weight); 48 48 49 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0);49 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 50 50 51 51 psImage *bright = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32); -
branches/cnb_branches/cnb_branch_20090301/archive/conv_variance/phot.c
r20210 r23352 52 52 53 53 psStats *bgStats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); 54 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0);54 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 55 55 psImageBackground(bgStats, NULL, image, mask, maskVal, rng); 56 56 double bg = bgStats->robustMedian; -
branches/cnb_branches/cnb_branch_20090301/dbconfig/changes.txt
r21434 r23352 795 795 ALTER TABLE magicInputSkyfile DROP PRIMARY KEY, ADD PRIMARY KEY(magic_id, diff_id, node); 796 796 797 798 799 797 -- Version: 1.1.48 800 798 … … 834 832 WHERE warpImfile.skycell_id IS NULL; 835 833 836 837 834 -- Version: 1.1.49 (change detrend sequence) 835 836 show create table detResidImfile; 837 alter table detResidImfile drop foreign key detResidImfile_ibfk_3; -
branches/cnb_branches/cnb_branch_20090301/dbconfig/config.md
r21310 r23352 2 2 pkg_name STR ippdb 3 3 pkg_namespace STR ippdb 4 pkg_version STR 1.1.4 84 pkg_version STR 1.1.49 5 5 END -
branches/cnb_branches/cnb_branch_20090301/dbconfig/det.md
r19620 r23352 90 90 class_id STR 64 # Primary Key 91 91 uri STR 255 92 recipe STR 64 93 bg F64 0.0 94 bg_stdev F64 0.0 95 bg_mean_stdev F64 0.0 96 user_1 F64 0.0 97 user_2 F64 0.0 98 user_3 F64 0.0 99 user_4 F64 0.0 100 user_5 F64 0.0 101 # XXX does it make sense to 'clean' the stacked imfiled? 92 # XXX missing path_base 93 recipe STR 64 94 bg F64 0.0 95 bg_stdev F64 0.0 96 bg_mean_stdev F64 0.0 97 user_1 F64 0.0 98 user_2 F64 0.0 99 user_3 F64 0.0 100 user_4 F64 0.0 101 user_5 F64 0.0 102 # XXX does it make sense to 'clean' the stacked imfiled? (EAM: yes) 102 103 data_state STR 64 # full, cleaned, purged (only track end states; request states are in detRunSummary by iteration) 103 104 fault S16 0 # Key NOT NULL … … 148 149 fault S16 0 # Key NOT NULL 149 150 END 150 151 #detMasterFrame METADATA152 # det_id S64 0 # Primary Key153 # iteration S32 0 # Primary Key154 # comment STR 255155 #END156 #157 ## drop?158 #detMasterImfile METADATA159 # det_id S64 0 # Primary Key160 # class_id STR 64 # Primary Key161 # uri STR 255162 # recipe STR 64163 #END164 151 165 152 detResidImfile METADATA -
branches/cnb_branches/cnb_branch_20090301/doc/pslib/psLibSDRS.tex
r12382 r23352 1197 1197 while returning the type involves descending through a case statement. 1198 1198 1199 To compare the types of two pointers without knowing their types, the following function may be used: 1200 1201 \begin{prototype} 1202 bool psMemTypeEqual (void *ptr1, ///< pointer to first psMemory object 1203 void *ptr2 ///< pointer to second psMemory object 1204 ); 1205 \end{prototype} 1206 1199 1207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1200 1208 -
branches/cnb_branches/cnb_branch_20090301/ippMonitor/def/detNormalizedStatImfile_failure.d
r19726 r23352 4 4 MENU ipp.detrend.dat 5 5 6 wherefault > 06 WHERE fault > 0 7 7 8 8 # field size format name show link to extras -
branches/cnb_branches/cnb_branch_20090301/ippMonitor/def/detStackedImfile.d
r18193 r23352 1 TABLE detStackedImfile 1 TABLE detStackedImfile, detRun 2 2 TITLE detStackedImfile 3 3 FILE detStackedImfile.php 4 4 MENU ipp.imfiles.dat 5 5 6 # field size format name show link to extras 7 FIELD det_id, 7, %s, det_id 8 FIELD iteration, 5, %s, iteration 9 FIELD class_id, 8, %s, class_id 10 FIELD fault, 5, %d, fault 11 FIELD bg, 8, %f, backgnd 12 FIELD bg_stdev, 8, %f, stdev 13 FIELD bg_mean_stdev, 8, %f, [stdev] 14 FIELD uri, 20, %s, uri 6 WHERE detStackedImfile.det_id = detRun.det_id 7 8 # XXX change uri to path_base in db 9 ARGS ARG1 detStackedImfile.det_id=$det_id 10 ARGS ARG1 detStackedImfile.iteration=$iteration 11 ARGS ARG1 camera=$detRun.camera 12 ARGS ARG1 basename=$detStackedImfile.uri 13 14 # field size format name show link to extras 15 FIELD detStackedImfile.det_id, 7, %s, det_id 16 FIELD detStackedImfile.iteration, 5, %s, iteration 17 FIELD detStackedImfile.class_id, 8, %s, class_id, value, detStackedImfile.php, ARG1 18 FIELD detStackedImfile.fault, 5, %d, fault 19 FIELD detStackedImfile.bg, 8, %f, backgnd 20 FIELD detStackedImfile.bg_stdev, 8, %f, stdev 21 FIELD detStackedImfile.bg_mean_stdev, 8, %f, [stdev] 22 FIELD detStackedImfile.uri, 20, %s, uri 15 23 # FIELD recipe, 20, recipe 16 24 17 25 TD_CLASS list_off $fault > 0 26 27 TAIL PHP insert_log ('LOG.EXP'); -
branches/cnb_branches/cnb_branch_20090301/ippMonitor/raw/getimage.php
r14128 r23352 22 22 putenv("PATH=$BINDIR:$PATH"); 23 23 24 # echo "args: $args<br>"; 24 if ($debug) { 25 echo "args: $args<br>"; 26 echo "path: $PATH<br>"; 27 echo "perl: $PERLLIB<br>"; 28 } 25 29 26 30 # $basename may contain filename@filerule … … 31 35 32 36 # $filerule = strtok("@"); 33 # echo "basename: $basename<br>"; 34 # echo "filerule: $filerule<br>"; 37 38 if ($debug) { 39 echo "basename: $basename<br>"; 40 echo "filerule: $filerule<br>"; 41 } 35 42 36 43 # need to supply the camera as well... … … 49 56 $basename = escapeshellarg($basename); 50 57 $basename = str_replace ('..','',$basename); 58 59 if ($debug) { 60 exec ("which ipp_filename.pl", $output, $status); 61 echo "output: $output[0]<br>"; 62 echo "status: $status<br>"; 63 64 exec ("whoami", $output, $status); 65 echo "output: $output[0]<br>"; 66 echo "status: $status<br>"; 67 } 51 68 52 69 exec ("ipp_filename.pl --site=$SITE --basename $basename --filerule $filerule --camera $camera --class_id $class_id", $output, $status); -
branches/cnb_branches/cnb_branch_20090301/ippScripts/Build.PL
r20931 r23352 80 80 scripts/summit_copy.pl 81 81 scripts/ipp_image_path.pl 82 scripts/dist_component.pl 83 scripts/dist_advancerun.pl 82 84 )], 83 85 dist_abstract => 'Scripts for running the Pan-STARRS IPP', -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/calibrate_dvo.pl
r20100 r23352 52 52 my $caltool = can_run('caltool') or (warn "Can't find caltool" and $missing_tools = 1); 53 53 54 if ($missing_tools) { 54 if ($missing_tools) { 55 55 warn ("Can't find required tools"); 56 exit($PS_EXIT_CONFIG_ERROR); 56 exit($PS_EXIT_CONFIG_ERROR); 57 57 } 58 58 … … 74 74 cache_run(command => $command, verbose => 1); 75 75 76 unless ($success) { 76 unless ($success) { 77 77 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 78 78 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RESORT", $status, $dbname); … … 83 83 { 84 84 foreach my $filter (@filters) { 85 my $command = "$relphot $filter";86 $command .= "-D CATDIR $dvodb";87 $command .= "-region $RAs $RAe $DECs $DECe";85 my $command = "$relphot $filter"; 86 $command .= "-D CATDIR $dvodb"; 87 $command .= "-region $RAs $RAe $DECs $DECe"; 88 88 89 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =90 cache_run(command => $command, verbose => 1);89 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 90 cache_run(command => $command, verbose => 1); 91 91 92 unless ($success) { 93 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);94 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELPHOT", $status, $dbname);95 }92 unless ($success) { 93 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 94 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELPHOT", $status, $dbname); 95 } 96 96 } 97 97 } … … 101 101 if (0) { 102 102 foreach my $filter (@filters) { 103 my $command = "$uniphot $filter";104 $command .= "-D CATDIR $dvodb";105 $command .= "-region $RAs $RAe $DECs $DECe";103 my $command = "$uniphot $filter"; 104 $command .= "-D CATDIR $dvodb"; 105 $command .= "-region $RAs $RAe $DECs $DECe"; 106 106 107 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =108 cache_run(command => $command, verbose => 1);107 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 108 cache_run(command => $command, verbose => 1); 109 109 110 unless ($success) { 111 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);112 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "UNIPHOT", $status, $dbname);113 }110 unless ($success) { 111 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 112 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "UNIPHOT", $status, $dbname); 113 } 114 114 } 115 115 } … … 121 121 122 122 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 123 cache_run(command => $command, verbose => 1);123 cache_run(command => $command, verbose => 1); 124 124 125 unless ($success) { 126 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);127 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELASTRO.OBJECTS", $status, $dbname);125 unless ($success) { 126 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 127 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELASTRO.OBJECTS", $status, $dbname); 128 128 } 129 129 } … … 135 135 136 136 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 137 cache_run(command => $command, verbose => 1);137 cache_run(command => $command, verbose => 1); 138 138 139 unless ($success) { 140 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);141 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELASTRO.IMAGES", $status, $dbname);139 unless ($success) { 140 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 141 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELASTRO.IMAGES", $status, $dbname); 142 142 } 143 143 } … … 169 169 my $region = shift; 170 170 my $last_step = shift; 171 my $status = shift;172 my $dbname = shift;171 my $status = shift; 172 my $dbname = shift; 173 173 174 174 carp($msg); 175 175 if (defined $cal_id && defined $region && defined $last_step && defined $status and not $no_update) { 176 176 my $command = "$caltool -addcalrun"; 177 $command .= " -cal_id $cal_id";177 $command .= " -cal_id $cal_id"; 178 178 $command .= " -region $region"; 179 $command .= " -last_step $last_step";180 $command .= " -state $status";179 $command .= " -last_step $last_step"; 180 $command .= " -state $status"; 181 181 $command .= " -dbname $dbname" if defined $dbname; 182 182 system ($command); -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/camera_exp.pl
r22430 r23352 22 22 use PS::IPP::Config 1.01 qw( :standard ); 23 23 use File::Temp qw( tempfile ); 24 25 my $ipprc = PS::IPP::Config->new(); # IPP configuration26 24 27 25 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 70 68 defined $camera; 71 69 72 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 73 $SIG{__DIE__} = sub { die @_ if $^S; 74 my_die( $_[0], $cam_id, $PS_EXIT_UNKNOWN_ERROR ); }; 75 76 $ipprc->define_camera($camera); 70 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $cam_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 77 71 78 72 my $logDest = $ipprc->filename("LOG.EXP", $outroot) or &my_die("Missing entry from camera config", $cam_id, $PS_EXIT_CONFIG_ERROR); … … 84 78 85 79 if ($redirect) { 86 $ipprc->redirect_output($logDest) ;80 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $cam_id, $PS_EXIT_SYS_ERROR ); 87 81 print "\n\n"; 88 82 print "Starting script $0 on $host\n\n"; … … 372 366 my $cam_id = shift; # Camtool identifier 373 367 my $exit_code = shift; # Exit code to add 368 369 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 374 370 375 371 carp($msg); -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/chip_imfile.pl
r22430 r23352 20 20 use PS::IPP::Metadata::Config; 21 21 use PS::IPP::Config 1.01 qw( :standard ); 22 23 my $ipprc = PS::IPP::Config->new(); # IPP configuration24 22 25 23 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 70 68 defined $run_state; 71 69 72 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 73 $SIG{__DIE__} = sub { die @_ if $^S; 74 my_die( $_[0], $exp_id, $chip_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 75 76 $ipprc->define_camera($camera); 70 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 77 71 78 72 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR); … … 80 74 81 75 if ($redirect) { 82 $ipprc->redirect_output($logDest) ;76 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR ); 83 77 print STDOUT "\n\n"; 84 78 print STDOUT "Starting script $0 on $host\n\n"; … … 254 248 # run_state, outputImage, and outroot are globals 255 249 250 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 251 256 252 carp($msg); 257 253 if (defined $chip_id and defined $class_id and not $no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_correct_imfile.pl
r22430 r23352 18 18 use PS::IPP::Metadata::Config; 19 19 use PS::IPP::Config 1.01 qw( :standard ); 20 21 my $ipprc = PS::IPP::Config->new(); # IPP configuration22 20 23 21 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 60 58 and defined $camera; 61 59 62 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 63 $SIG{__DIE__} = sub { die @_ if $^S; 64 my_die( $_[0], $det_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 65 66 # XXX this exits with status = 0 on failure 67 $ipprc->define_camera($camera); 68 60 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 69 61 if ($redirect) { 70 62 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) 71 63 or &my_die("Missing entry from camera config", $det_id, $class_id, $PS_EXIT_CONFIG_ERROR); 72 $ipprc->redirect_output($logDest) ;64 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $det_id, $class_id, $PS_EXIT_SYS_ERROR ); 73 65 } 74 66 … … 132 124 my $exit_code = shift; # Exit code to add 133 125 126 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 127 134 128 carp($msg); 135 129 if (defined $det_id and defined $class_id and not $no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_norm_apply.pl
r22430 r23352 17 17 use PS::IPP::Metadata::Config; 18 18 use PS::IPP::Config 1.01 qw( :standard ); 19 20 my $ipprc = PS::IPP::Config->new(); # IPP configuration21 19 22 20 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 40 38 'iteration|n=s' => \$iter, # Iteration 41 39 'class_id|i=s' => \$class_id, # Class ID 42 'value|v=s' => \$value, # Value to multiple(for normalisation)40 'value|v=s' => \$value, # Value to apply (for normalisation) 43 41 'input_uri|u=s' => \$input_uri, # Input file 44 42 'camera|c=s' => \$camera, # Camera … … 64 62 defined $outroot; 65 63 66 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 67 $SIG{__DIE__} = sub { die @_ if $^S; 68 my_die( $_[0], $det_id, $iter, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 69 70 $ipprc->define_camera($camera); 64 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 71 65 72 66 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) 73 67 or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); 74 $ipprc->redirect_output($logDest) if $redirect;68 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR ) if $redirect; 75 69 76 70 my $RECIPE_PPIMAGE = 'PPIMAGE_N'; # Recipe to use with ppImage … … 202 196 my $exit_code = shift; # Exit code to add 203 197 198 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 199 204 200 carp($msg); 205 201 if (defined $det_id and defined $iter and defined $class_id and not $no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_norm_calc.pl
r22430 r23352 19 19 use PS::IPP::Metadata::List qw( parse_md_list ); 20 20 use PS::IPP::Config 1.01 qw( :standard ); 21 22 my $ipprc = PS::IPP::Config->new(); # IPP configuration23 21 24 22 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 57 55 defined $outroot; 58 56 59 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 60 $SIG{__DIE__} = sub { die @_ if $^S; 61 my_die( $_[0], $det_id, $iter, $PS_EXIT_UNKNOWN_ERROR ); }; 57 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $det_id, $iter, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 62 58 63 59 my $logfile = $outroot . ".log"; 64 65 $ipprc->redirect_output($logfile) if $redirect; 60 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $det_id, $iter, $PS_EXIT_SYS_ERROR ) if $redirect; 66 61 67 62 use constant STATISTIC => 'bg'; # Background statistic to use from the database … … 95 90 my @files; # The input files 96 91 { 97 my $command = "$dettool -processedimfile"; 98 $command .= " -det_id $det_id"; # Command to run 92 my $command = "$dettool -residimfile"; 93 $command .= " -det_id $det_id"; 94 $command .= " -iteration $iter"; 99 95 $command .= " -included"; # only use the inputs for this detrend run to calculate the norm 100 96 $command .= " -dbname $dbname" if defined $dbname; … … 103 99 print "Running [$command]...\n" if $verbose; 104 100 if (not run(\@command, \$stdin, \$stdout, \$stderr)) { 105 &my_die("Unable to perform dettool - processedimfile on detrend $det_id/$iter: $?",101 &my_die("Unable to perform dettool -residimfile on detrend $det_id/$iter: $?", 106 102 $det_id, $iter, $PS_EXIT_SYS_ERROR); 107 103 } … … 233 229 my $iter = shift; # Iteration 234 230 my $exit_code = shift; # Exit code to add 231 232 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 235 233 236 234 carp($msg); -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_norm_exp.pl
r22430 r23352 19 19 use PS::IPP::Metadata::List qw( parse_md_list ); 20 20 use File::Temp qw( tempfile ); 21 22 my $ipprc = PS::IPP::Config->new(); # IPP configuration23 21 24 22 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 60 58 defined $outroot; 61 59 62 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 63 $SIG{__DIE__} = sub { die @_ if $^S; 64 my_die( $_[0], $det_id, $iter, $PS_EXIT_UNKNOWN_ERROR ); }; 65 60 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $iter, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 66 61 my $logfile = $outroot . ".log"; 67 68 $ipprc->redirect_output($logfile) if $redirect; 69 70 $ipprc->define_camera($camera); 62 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $det_id, $iter, $PS_EXIT_SYS_ERROR ) if $redirect; 71 63 72 64 # Recipes to use based on reduction class … … 190 182 my $iter = shift; # Iteration 191 183 my $exit_code = shift; # Exit code to add 184 185 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 192 186 193 187 carp($msg); -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_process_exp.pl
r22430 r23352 19 19 use PS::IPP::Metadata::List qw( parse_md_list ); 20 20 use File::Temp qw( tempfile ); 21 22 my $ipprc = PS::IPP::Config->new(); # IPP configuration23 21 24 22 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 63 61 defined $outroot; 64 62 65 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 66 $SIG{__DIE__} = sub { die @_ if $^S; 67 my_die( $_[0], $det_id, $exp_id, $PS_EXIT_UNKNOWN_ERROR ); }; 68 69 $ipprc->define_camera($camera); 70 63 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $exp_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 71 64 if ($redirect) { 72 65 my $logDest = $ipprc->filename("LOG.EXP", $outroot, "NONE") 73 66 or &my_die("Missing entry in file rules", $det_id, $exp_id, $PS_EXIT_CONFIG_ERROR); 74 $ipprc->redirect_output($logDest) ;67 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $det_id, $exp_id, $PS_EXIT_SYS_ERROR ); 75 68 } 76 69 … … 204 197 my $exp_id = shift; # Exposure tag 205 198 my $exit_code = shift; # Exit code to add 199 200 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 206 201 207 202 carp($msg); -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_process_imfile.pl
r22430 r23352 17 17 use PS::IPP::Metadata::Config; 18 18 use PS::IPP::Config 1.01 qw( :standard ); 19 20 my $ipprc = PS::IPP::Config->new(); # IPP configuration21 19 22 20 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 65 63 defined $outroot; 66 64 67 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 68 $SIG{__DIE__} = sub { die @_ if $^S; 69 my_die( $_[0], $det_id, $exp_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 70 71 # XXX this exits with status = 0 on failure 72 $ipprc->define_camera($camera); 73 65 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 74 66 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR); 75 76 $ipprc->redirect_output($logDest) if $redirect; 67 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR ) if $redirect; 77 68 78 69 # Recipes to use as a function of detrend type … … 81 72 my $jpeg_recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_IMAGE'); # Recipe name for JPEG 82 73 74 # The output file rule name depends on the detrend type 75 my $FILERULES = { 'FLATMASK' => undef, 76 'DARKMASK' => undef, 77 'MASK' => undef, 78 'BIAS' => undef, 79 'DARK' => undef, 80 'DARK_PREMASK' => undef, 81 'SHUTTER' => 'PPIMAGE.OUTPUT.DETREND', 82 'FLAT_PREMASK' => 'PPIMAGE.OUTPUT.DETREND', 83 'DOMEFLAT_PREMASK' => 'PPIMAGE.OUTPUT.DETREND', 84 'SKYFLAT_PREMASK' => 'PPIMAGE.OUTPUT.DETREND', 85 'FLAT_RAW' => 'PPIMAGE.OUTPUT.DETREND', 86 'DOMEFLAT_RAW' => 'PPIMAGE.OUTPUT.DETREND', 87 'SKYFLAT_RAW' => 'PPIMAGE.OUTPUT.DETREND', 88 'FLAT' => 'PPIMAGE.OUTPUT.DETREND', 89 'DOMEFLAT' => 'PPIMAGE.OUTPUT.DETREND', 90 'SKYFLAT' => 'PPIMAGE.OUTPUT.DETREND', 91 'FRINGE' => undef, 92 }; 93 83 94 &my_die("Couldn't find input file: $input_uri\n", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input_uri); 84 95 … … 93 104 my $cmdflags; 94 105 95 my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 106 my $filerule = $FILERULES->{$det_type}; # File rule to use for output 107 $filerule = "PPIMAGE.OUTPUT" unless defined $filerule; 108 109 my $outputImage = $ipprc->filename($filerule, $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 96 110 my $outputBin1 = $ipprc->filename("PPIMAGE.BIN1", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 97 111 my $outputBin2 = $ipprc->filename("PPIMAGE.BIN2", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 98 112 my $outputStats = $ipprc->filename("PPIMAGE.STATS", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 99 113 my $traceDest = $ipprc->filename("TRACE.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR); 114 115 100 116 # Run ppImage 101 117 unless ($no_op) { … … 105 121 $command .= " -recipe PPSTATS DETSTATS"; 106 122 $command .= " -stats $outputStats"; 123 $command .= " -F PPIMAGE.OUTPUT $filerule" if $filerule ne "PPIMAGE.OUTPUT"; 107 124 $command .= " -tracedest $traceDest -log $logDest"; 108 125 $command .= " -threads $threads" if defined $threads; … … 167 184 my $class_id = shift; # Class identifier 168 185 my $exit_code = shift; # Exit code to add 186 187 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 169 188 170 189 carp($msg); -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_reject_exp.pl
r22430 r23352 20 20 use PS::IPP::Metadata::List qw( parse_md_list ); 21 21 use Statistics::Descriptive; 22 23 my $ipprc = PS::IPP::Config->new(); # IPP configuration24 22 25 23 my $ITER_LIMIT = 20; … … 60 58 defined $outroot; 61 59 62 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 63 $SIG{__DIE__} = sub { die @_ if $^S; 64 my_die( $_[0], $det_id, $iter, $PS_EXIT_UNKNOWN_ERROR ); }; 65 66 # check for existing directory, generate if needed 67 $ipprc->outroot_prepare($outroot); 68 60 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $det_id, $iter, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 61 $ipprc->outroot_prepare($outroot) or my_die( "Unable to prepare output root", $det_id, $iter, $PS_EXIT_SYS_ERROR ); 69 62 my $logName = "$outroot.log"; # Name for log 70 71 $ipprc->redirect_output($logName) if $redirect; 63 $ipprc->redirect_output($logName) or my_die( "Unable to redirect", $det_id, $iter, $PS_EXIT_SYS_ERROR ) if $redirect; 72 64 73 65 # values to extract from output metadata and the stats to calculate … … 344 336 my $exit_code = shift; # Exit code to add 345 337 338 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 339 346 340 carp($msg); 347 341 if (defined $det_id and defined $iter and not $no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_resid_exp.pl
r22430 r23352 30 30 use File::Temp qw( tempfile ); # tools to construct temp files 31 31 use PS::IPP::Config 1.01 qw( :standard ); 32 33 my $ipprc = PS::IPP::Config->new(); # IPP configuration34 32 35 33 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); # option parsing … … 47 45 48 46 # parse the command-line options 49 my ( $det_id, $iter, $exp_id, $exp_tag, $det_ type, $camera, $filter, $reject, $outroot, $dbname, $reduction,47 my ( $det_id, $iter, $exp_id, $exp_tag, $det_mode, $det_type, $camera, $filter, $reject, $outroot, $dbname, $reduction, 50 48 $verbose, $no_update, $no_op, $save_temps, $redirect ); 51 49 GetOptions( … … 55 53 'exp_tag|=s' => \$exp_tag, 56 54 'det_type|t=s' => \$det_type, 55 'det_mode=s' => \$det_mode, 57 56 'camera=s' => \$camera, 58 57 'outroot|w=s' => \$outroot, # output file base name … … 76 75 defined $exp_tag and 77 76 defined $det_type and 77 defined $det_mode and 78 78 defined $camera and 79 79 defined $outroot; 80 80 81 # Unhandled exceptions should be passed on to my_die so they get pushed into the database82 $SIG{__DIE__} = sub { die @_ if $^S;83 my_die( $_[0], $det_id, $iter, $exp_id, $PS_EXIT_UNKNOWN_ERROR ); };84 85 81 # load IPP config information for the specified camera 86 $ipprc->define_camera($camera); 87 82 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $iter, $exp_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 88 83 my $logDest = $ipprc->filename("LOG.EXP", $outroot) or &my_die("Missing entry from camera config", $det_id, $iter, $exp_id, $PS_EXIT_CONFIG_ERROR); 89 90 $ipprc->redirect_output($logDest) if $redirect; 84 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $det_id, $iter, $exp_id, $PS_EXIT_SYS_ERROR ) if $redirect; 91 85 92 86 # Recipes to use based on reduction class … … 96 90 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe; 97 91 92 # variables used for I/O 93 my ($command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf); 94 95 # Get list of normalizations by class_id : stored as $norms; save to temp file for ppImage runs below 96 my (%norms, $normsName); 97 if ($det_mode eq 'master') { 98 # dettool command to select imfile data for this exp_id 99 $command = "$dettool -normalizedstat"; 100 $command .= " -det_id $det_id"; 101 $command .= " -iteration $iter"; 102 $command .= " -dbname $dbname" if defined $dbname; 103 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 104 run(command => $command, verbose => $verbose); 105 unless ($success) { 106 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 107 warn("Unable to perform dettool -residimfile: $error_code\n"); 108 exit($error_code); 109 } 110 if (@$stdout_buf == 0) { 111 &my_die("No normalizations were found", $det_id, $iter, $PS_EXIT_PROG_ERROR); 112 } 113 114 # Parse the stdout buffer into a metadata 115 my $mdcParser = PS::IPP::Metadata::Config->new; 116 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 117 &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR); 118 119 # parse the file info in the metadata 120 my $normsMD = parse_md_list($metadata) or 121 &my_die("Unable to parse metadata list", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR); 122 123 124 # write the normalizations to a file as a metadata config file in the form: class_id F32 value 125 # XXX a possible optimization: if there is only one imfile, skip normalization 126 my $normsFile; 127 ($normsFile, $normsName) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.norms.XXXX", UNLINK => !$save_temps ); 128 print "saving norms to $normsName\n"; 129 foreach my $norm (@$normsMD) { 130 my $class_id = $norm->{class_id}; 131 my $normalization = $norm->{norm}; 132 133 $norms{$class_id} = $normalization; 134 printf $normsFile "$class_id F32 $normalization\n", 135 } 136 close $normsFile; 137 } 138 98 139 # Get list of imfile files 99 140 my $cmdflags; 100 my ( $files, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf);141 my (@files); 101 142 { 102 143 # dettool command to select imfile data for this exp_id … … 113 154 exit($error_code); 114 155 } 115 # XXX report an error message if stdout_buf is empty 156 if (@$stdout_buf == 0) { 157 &my_die("No imfiles were found", $det_id, $iter, $PS_EXIT_PROG_ERROR); 158 } 116 159 117 160 # Parse the stdout buffer into a metadata … … 120 163 &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR); 121 164 165 # since I can't figure out how to do input and output within PERL, I'm writing the (modified) metadata to a temp file 166 my ($statFile, $statName) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.stats.XXXX", UNLINK => !$save_temps ); 167 168 print $statFile "rawResidImfile MULTI\n"; 169 122 170 # parse the file info in the metadata 123 $files = parse_md_list($metadata) or 124 &my_die("Unable to parse metadata list", $det_id, $iter, $exp_id, $PS_EXIT_PROG_ERROR); 125 126 # since I can't figure out how to do input and output within PERL, I'm writing to a temp file 127 my ($statFile, $statName) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.stats.XXXX", UNLINK => !$save_temps ); 128 print "saving stats to $statName\n"; 129 foreach my $line (@$stdout_buf) { 130 print $statFile $line; 171 # as we parse the list of files and their stats, apply the normalization to the relevant fields 172 # also, write out the modified metadata set 173 foreach my $mdItem (@$metadata) { 174 if ($mdItem->{class} ne "metadata") { 175 carp "MD element ", $mdItem->{name}, " isn't of type METADATA --- ignored.\n"; 176 next; 177 } 178 my %hash; # Hash element 179 my $mdComponents = $mdItem->{value}; # Components of the metadata 180 181 # determine the class_id for this block: 182 my $class_id; 183 foreach my $data (@$mdComponents) { 184 unless ($data->{name} eq "class_id") { next; } 185 $class_id = $data->{value}; 186 last; 187 } 188 189 # a new metadata block 190 print $statFile "rawResidImfile METADATA\n"; 191 192 # modify and save the data in this block: 193 foreach my $data (@$mdComponents) { 194 my $norm = 1.0; 195 if ($det_mode eq "master") { 196 $norm = $norms{$class_id}; 197 } 198 199 # fields to modify by the normalization: 200 if ($data->{name} eq "bg") { $data->{value} *= $norm; } 201 if ($data->{name} eq "bg_stdev") { $data->{value} *= $norm; } 202 if ($data->{name} eq "bg_mean_stdev") { $data->{value} *= $norm; } 203 if ($data->{name} eq "bg_skewness") { $data->{value} *= $norm; } 204 if ($data->{name} eq "bg_kurtosis") { $data->{value} *= $norm; } 205 if ($data->{name} eq "bin_stdev") { $data->{value} *= $norm; } 206 207 # write out the metadata, save on the array of hashes 208 print $statFile " $data->{name} $data->{type} $data->{value}\n"; 209 $hash{$data->{name}} = $data->{value}; 210 } 211 print $statFile "END\n"; 212 push @files, \%hash; 131 213 } 132 214 close $statFile; … … 162 244 my ($list1File, $list1Name) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.b1.list.XXXX", UNLINK => !$save_temps ); 163 245 my ($list2File, $list2Name) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.b2.list.XXXX", UNLINK => !$save_temps ); 164 foreach my $file (@ $files) {246 foreach my $file (@files) { 165 247 print $list1File ($ipprc->filename( "PPIMAGE.BIN1", $file->{path_base}, $file->{class_id} ) . "\n"); 166 248 print $list2File ($ipprc->filename( "PPIMAGE.BIN2", $file->{path_base}, $file->{class_id} ) . "\n"); … … 173 255 unless ($no_op) { 174 256 # Make the jpeg for binning 1 257 # XXX EAM : supply the collection of normalizations as a metadata 175 258 $command = "$ppImage -list $list1Name $outroot"; # Command to run 176 259 $command .= " -recipe PPIMAGE PPIMAGE_J1"; 177 260 $command .= " -recipe JPEG $recipe"; 261 $command .= " -normlist $normsName" if defined $normsName; 178 262 $command .= " -dbname $dbname" if defined $dbname; 179 263 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 186 270 187 271 # Make the jpeg for binning 2 272 # XXX EAM : supply the collection of normalizations as a metadata 188 273 $command = "$ppImage -list $list2Name $outroot"; # Command to run 189 274 $command .= " -recipe PPIMAGE PPIMAGE_J2"; 190 275 $command .= " -recipe JPEG $recipe"; 276 $command .= " -normlist $normsName" if defined $normsName; 191 277 $command .= " -dbname $dbname" if defined $dbname; 192 278 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 223 309 my @fluxes; 224 310 225 foreach my $file (@ $files) {311 foreach my $file (@files) { 226 312 my $name = $file->{class_id}; 227 313 my $mean = $file->{bg}; # Mean for this imfile … … 554 640 my $exit_code = shift; # Exit code to add 555 641 642 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 643 556 644 carp($msg); 557 645 if (defined $det_id and defined $iter and defined $exp_id and not $no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_resid_imfile.pl
r22430 r23352 17 17 use PS::IPP::Metadata::Config; 18 18 use PS::IPP::Config 1.01 qw( :standard ); 19 20 my $ipprc = PS::IPP::Config->new(); # IPP configuration21 19 22 20 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 76 74 defined $detrend; 77 75 78 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 79 $SIG{__DIE__} = sub { die @_ if $^S; 80 my_die( $_[0], $det_id, $iter, $exp_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 81 82 $ipprc->define_camera($camera); 83 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id); 84 if ($redirect) { 85 $ipprc->redirect_output($logDest); 86 } 76 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 77 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or my_die( "Unable to find LOG.IMFILE", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_CONFIG_ERROR ); 78 $ipprc->redirect_output($logDest) or my_die( "Unable to find LOG.IMFILE", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR ) if $redirect; 87 79 88 80 # Recipes to use as a function of detrend type and mode … … 124 116 }; 125 117 118 # The output file rule name depends on the detrend type 119 my $FILERULES = { 'FLATMASK' => 'PPIMAGE.OUTPUT.RESID', 120 'DARKMASK' => 'PPIMAGE.OUTPUT.RESID', 121 'MASK' => 'PPIMAGE.OUTPUT.RESID', 122 'BIAS' => 'PPIMAGE.OUTPUT.RESID', 123 'DARK' => 'PPIMAGE.OUTPUT.RESID', 124 'DARK_PREMASK' => 'PPIMAGE.OUTPUT.RESID', 125 'SHUTTER' => 'PPIMAGE.OUTPUT.DETREND', 126 'FLAT_PREMASK' => 'PPIMAGE.OUTPUT.DETREND', 127 'DOMEFLAT_PREMASK' => 'PPIMAGE.OUTPUT.DETREND', 128 'SKYFLAT_PREMASK' => 'PPIMAGE.OUTPUT.DETREND', 129 'FLAT_RAW' => 'PPIMAGE.OUTPUT.DETREND', 130 'DOMEFLAT_RAW' => 'PPIMAGE.OUTPUT.DETREND', 131 'SKYFLAT_RAW' => 'PPIMAGE.OUTPUT.DETREND', 132 'FLAT' => 'PPIMAGE.OUTPUT.DETREND', 133 'DOMEFLAT' => 'PPIMAGE.OUTPUT.DETREND', 134 'SKYFLAT' => 'PPIMAGE.OUTPUT.DETREND', 135 'FRINGE' => 'PPIMAGE.OUTPUT.RESID', 136 }; 137 126 138 # outroot examples (HOST components must be set) 127 139 # file://data/ipp004.0/gpc1/20080130 … … 135 147 # my $outputName = $ipprc->filename("PPIMAGE.OUTPUT", $outroot, $class_id); 136 148 137 my $outputName = $ipprc->filename("PPIMAGE.OUTPUT.RESID", $outroot, $class_id); 149 my $filerule = $FILERULES->{$det_type}; # File rule to use 150 151 my $outputName = $ipprc->filename($filerule, $outroot, $class_id); 138 152 my $bin1Name = $ipprc->filename("PPIMAGE.BIN1", $outroot, $class_id); 139 153 my $bin2Name = $ipprc->filename("PPIMAGE.BIN2", $outroot, $class_id); … … 149 163 $command .= " -recipe JPEG $jpeg_recipe"; 150 164 $command .= " -recipe PPSTATS RESIDUAL"; 151 $command .= " -F PPIMAGE.OUTPUT PPIMAGE.OUTPUT.RESID";165 $command .= " -F PPIMAGE.OUTPUT $filerule"; 152 166 $command .= " -stats $outputStats"; 153 167 $command .= " -tracedest $traceDest -log $logDest"; … … 237 251 my $exit_code = shift; # Exit code to add 238 252 253 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 254 239 255 carp($msg); 240 256 if (defined $det_id and defined $iter and defined $exp_id and not $no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_stack.pl
r22430 r23352 18 18 use PS::IPP::Metadata::List qw( parse_md_list ); 19 19 use PS::IPP::Config 1.01 qw( :standard ); 20 21 my $ipprc = PS::IPP::Config->new(); # IPP configuration22 20 23 21 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 63 61 defined $outroot; 64 62 65 $ipprc->define_camera($camera);66 63 $det_type = uc($det_type); 67 64 65 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 68 66 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) 69 67 or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); 70 71 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 72 $SIG{__DIE__} = sub { die @_ if $^S; 73 my_die( $_[0], $det_id, $iter, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 74 75 # optionally redirect the outputs from this script to LOG.IMFILE 76 $ipprc->redirect_output($logDest) if $redirect; 68 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR ) if $redirect; 77 69 78 70 # Recipes to use as a function of detrend type … … 259 251 my $exit_code = shift; # Exit code to add 260 252 253 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 254 261 255 carp($msg); 262 256 if (defined $det_id and defined $iter and defined $class_id and not $no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/diff_skycell.pl
r22433 r23352 21 21 use Data::Dumper; 22 22 use PS::IPP::Config 1.01 qw( :standard ); 23 24 my $ipprc = PS::IPP::Config->new(); # IPP configuration25 23 26 24 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 62 60 and defined $outroot; 63 61 64 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 65 $SIG{__DIE__} = sub { die @_ if $^S; 66 my_die( $_[0], $diff_id, $skycell_id, $PS_EXIT_UNKNOWN_ERROR ); }; 62 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $diff_id, $skycell_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 67 63 68 64 # XXX camera is not known here; cannot use filerules... 69 65 # my $logDest = $ipprc->filename("LOG.EXP", $outroot); 70 66 my $logDest = "$outroot.log"; 71 $ipprc->redirect_output($logDest) if $redirect;67 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect; 72 68 73 69 my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_DIFF); … … 280 276 my $exit_code = shift; # Exit code to add 281 277 278 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 279 282 280 warn($msg); 283 281 if (defined $diff_id and defined $skycell_id and not $no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/fake_imfile.pl
r22430 r23352 36 36 use PS::IPP::Metadata::Config; 37 37 use PS::IPP::Config 1.01 qw( :standard ); 38 39 my $ipprc = PS::IPP::Config->new(); # IPP configuration40 38 41 39 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 82 80 defined $outroot; 83 81 84 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 85 $SIG{__DIE__} = sub { die @_ if $^S; 86 my_die( $_[0], $exp_id, $fake_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 87 88 $ipprc->define_camera($camera); 89 90 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR); 91 92 $ipprc->redirect_output($logDest) if $redirect; 82 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 83 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR); 84 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $exp_id, $fake_id, $class_id, $PS_EXIT_SYS_ERROR ) if $redirect; 93 85 94 86 # Recipes to use based on reduction class … … 214 206 my $exit_code = shift; # Exit code to add 215 207 208 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 209 216 210 carp($msg); 217 211 if (defined $exp_id and defined $fake_id and defined $class_id and not $no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/ipp_cleanup.pl
r21371 r23352 18 18 use Pod::Usage qw( pod2usage ); 19 19 20 my $ipprc = PS::IPP::Config->new(); # this is used for PATH, NEB filename conversions21 22 20 # Parse the command-line arguments 23 21 my ($stage, $camera, $stage_id, $mode, $path_base, $dbname, $verbose, $no_op, $helplist); 24 22 GetOptions('stage=s' => \$stage, # which analysis stage to clean? 25 'camera|i=s' => \$camera, # user-supplied camera name26 'stage_id=s' => \$stage_id, # id for this stage (only needed for certain stages)27 'mode|m=s' => \$mode, # cleanup mode (clean / purge)28 'path_base=s' => \$path_base, # basename for files29 'dbname|d=s' => \$dbname, # Database name23 'camera|i=s' => \$camera, # user-supplied camera name 24 'stage_id=s' => \$stage_id, # id for this stage (only needed for certain stages) 25 'mode|m=s' => \$mode, # cleanup mode (clean / purge) 26 'path_base=s' => \$path_base, # basename for files 27 'dbname|d=s' => \$dbname, # Database name 30 28 'verbose' => \$verbose, # Print to stdout 31 'no-op' => \$no_op, # pretend but don't actually inject32 'helplist' => \$helplist # give help listing33 ) or pod2usage( 2 );34 35 pod2usage( -msg => "remove temporary / all data files for an IPP analysis stage", 36 -exitval => 2) if defined $helplist;37 38 pod2usage( -msg => "Usage: $0 --camera (name) --stage (stage) --stage_id (stage_id) --mode (mode) [--path_base (path)] [--dbname dbname] [--no-op] [--help]", 39 -exitval => 2 ) if scalar @ARGV;29 'no-op' => \$no_op, # pretend but don't actually inject 30 'helplist' => \$helplist # give help listing 31 ) or pod2usage( 2 ); 32 33 pod2usage( -msg => "remove temporary / all data files for an IPP analysis stage", 34 -exitval => 2) if defined $helplist; 35 36 pod2usage( -msg => "Usage: $0 --camera (name) --stage (stage) --stage_id (stage_id) --mode (mode) [--path_base (path)] [--dbname dbname] [--no-op] [--help]", 37 -exitval => 2 ) if scalar @ARGV; 40 38 41 39 pod2usage( -msg => "Required options:--camera (name) --stage (stage) --mode (mode)", 42 -exitval => 3) unless 40 -exitval => 3) unless 43 41 defined $camera and 44 42 defined $stage and 45 43 defined $mode; 46 44 47 # $mode must be one of "goto_cleaned" or "goto_purged" 48 unless (($mode eq "goto_cleaned") || ($mode eq "goto_purged")) { 49 die "invalid cleanup mode $mode\n"; 50 } 45 my $ipprc = PS::IPP::Config->new( $camera ) or my_die("Unable to set up", $stage_id, $PS_EXIT_CONFIG_ERROR); # this is used for PATH, NEB filename conversions 46 47 # $mode must be one of "goto_cleaned", "goto_scrubbed", or 48 # "goto_purged" goto_cleaned and goto_scrubbed both result in 49 # 'cleaned' on success ('scrubbed' allows chips without config files 50 # to be cleaned; they cannot be recovered, but the small data is left 51 # behind). XXX make 'scrubbed' a data_state? 52 unless (($mode eq "goto_cleaned") || ($mode eq "goto_scrubbed") || ($mode eq "goto_purged")) { 53 die "invalid cleanup mode $mode\n"; 54 } 55 56 my $error_state; 57 if ($mode eq "goto_cleaned") { $error_state = "error_cleaned"; } 58 if ($mode eq "goto_scrubbed") { $error_state = "error_scrubbed"; } 59 if ($mode eq "goto_purged") { $error_state = "error_purged"; } 60 51 61 52 62 my %stages = ( chip => 1, camera => 1, fake => 1, warp => 1, stack => 1, diff => 1); … … 55 65 } 56 66 57 $ipprc->define_camera($camera);58 59 67 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 60 68 61 69 # choice of files to delete depends on the stage 62 70 if ($stage eq "chip") { 63 71 64 72 die "--stage_id required for stage chip\n" if !$stage_id; 65 73 ### select the imfiles for this entry … … 78 86 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code); 79 87 } 88 89 # if there are no chipProcessedImfiles (@$stdout_buf == 0), the reset the state to 'new' 90 if (@$stdout_buf == 0) { 91 my $command = "$chiptool -chip_id $stage_id -updaterun -set_state new"; 92 $command .= " -dbname $dbname" if defined $dbname; 93 94 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 95 run(command => $command, verbose => $verbose); 96 unless ($success) { 97 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 98 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code); 99 } 100 exit 0; 101 } 102 80 103 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 81 104 &my_die("Unable to parse metadata config doc", "chip", $stage_id, $PS_EXIT_PROG_ERROR); … … 87 110 # loop over all of the imfiles, determine the path_base and class_id for each 88 111 foreach my $imfile (@$imfiles) { 89 my $class_id = $imfile->{class_id};90 my $path_base = $imfile->{path_base};112 my $class_id = $imfile->{class_id}; 113 my $path_base = $imfile->{path_base}; 91 114 my $status = 1; 92 115 93 116 # don't clean up unless the data needed to update is available 117 # modes goto_purged and goto_scrubbed will remove files even if the config is non-existent 94 118 if ($mode eq "goto_cleaned") { 95 119 my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id); … … 124 148 addFilename (\@files, "PPIMAGE.CONFIG", $path_base, $class_id); 125 149 } 126 150 127 151 # actual command to delete the files 128 152 $status = &delete_files (\@files); 129 153 } 130 154 131 if ($status) {132 my $command = "$chiptool -chip_id $stage_id -class_id $class_id";155 if ($status) { 156 my $command = "$chiptool -chip_id $stage_id -class_id $class_id"; 133 157 if ($mode eq "goto_purged") { 134 158 $command .= " -topurgedimfile"; … … 136 160 $command .= " -tocleanedimfile"; 137 161 } 162 $command .= " -dbname $dbname" if defined $dbname; 163 164 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 165 run(command => $command, verbose => $verbose); 166 unless ($success) { 167 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 168 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code); 169 } 170 } else { 171 172 # if an error happens for one chip, the chipRun will stay in goto_*, but the chips will go to error_* (matching the goto_*) 173 my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -set_state $error_state"; 138 174 $command .= " -dbname $dbname" if defined $dbname; 139 175 140 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =176 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 141 177 run(command => $command, verbose => $verbose); 142 unless ($success) { 143 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 144 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code); 145 } 146 } else { 147 my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -code 1"; 148 $command .= " -dbname $dbname" if defined $dbname; 149 150 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 151 run(command => $command, verbose => $verbose); 152 unless ($success) { 153 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 154 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code); 155 } 156 } 157 } 158 159 } elsif ($stage eq "camera") { 178 unless ($success) { 179 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 180 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code); 181 } 182 } 183 } 184 exit 0; 185 } 186 187 if ($stage eq "camera") { 160 188 die "--stage_id required for stage camera\n" if !$stage_id; 161 189 # this stage uses 'camtool' … … 210 238 211 239 if ($status) { 212 my $command = "$camtool -cam_id $stage_id -updaterun";240 my $command; 213 241 if ($mode eq "goto_cleaned") { 214 $command .= " -state cleaned"; 215 } else { 216 $command .= " -state purged"; 242 $command = "$camtool -updaterun -cam_id $stage_id -set_state cleaned"; 243 } 244 if ($mode eq "goto_scrubbed") { 245 $command = "$camtool -updaterun -cam_id $stage_id -set_state cleaned"; 246 } 247 if ($mode eq "goto_purged") { 248 $command = "$camtool -updaterun -cam_id $stage_id -set_state purged"; 217 249 } 218 250 $command .= " -dbname $dbname" if defined $dbname; … … 224 256 } 225 257 } else { 226 my $command = "$camtool -updateprocessedexp -cam_id $stage_id -code 1"; 258 # since 'camera' has only a single imfile, we can just update the run 259 my $command = "$camtool -updaterun -cam_id $stage_id -set_state $error_state"; 227 260 $command .= " -dbname $dbname" if defined $dbname; 228 261 … … 236 269 } 237 270 exit 0; 238 } elsif ($stage eq "warp") { 271 } 272 273 if ($stage eq "warp") { 239 274 die "--stage_id required for stage warp\n" if !$stage_id; 240 275 # this stage uses 'warptool' … … 295 330 } 296 331 297 if ($status) {298 my $command = "$warptool -warp_id $stage_id -skycell_id $skycell_id";332 if ($status) { 333 my $command = "$warptool -warp_id $stage_id -skycell_id $skycell_id"; 299 334 if ($mode eq "goto_purged") { 300 335 $command .= " -topurgedskyfile"; … … 302 337 $command .= " -tocleanedskyfile"; 303 338 } 304 $command .= " -dbname $dbname" if defined $dbname;305 306 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =339 $command .= " -dbname $dbname" if defined $dbname; 340 341 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 307 342 run(command => $command, verbose => $verbose); 308 unless ($success) {309 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);310 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);311 }343 unless ($success) { 344 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 345 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code); 346 } 312 347 } else { 313 # XXX: -updateskyfile mode does not exist, need to add it 314 my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -code 1"; 348 my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -set_state $error_state"; 315 349 $command .= " -dbname $dbname" if defined $dbname; 316 350 317 351 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 318 352 run(command => $command, verbose => $verbose); 319 unless ($success) {320 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);321 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);322 }353 unless ($success) { 354 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 355 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code); 356 } 323 357 exit $PS_EXIT_UNKNOWN_ERROR; 324 }358 } 325 359 } 326 360 exit 0; … … 329 363 # left TODO 330 364 # fake : faketool : -pendingcleanupimfile (loop over imfiles) 331 # stack: stacktool : -pendingcleanupskyfile (loop over skyfiles)332 # diff: difftool : -pendingcleanupskyfile 365 # stack: stacktool : -pendingcleanupskyfile 366 # diff: difftool : -pendingcleanupskyfile (loop over skyfiles) 333 367 334 368 die "ipp_cleanup.pl -stage $stage not yet implemented\n"; 335 369 336 sub delete_files 370 sub delete_files 337 371 { 338 372 my $files = shift; # reference to a list of files to unlink 339 340 # this script is, of course, very dangerous. 373 374 # this script is, of course, very dangerous. 341 375 foreach my $file (@$files) { 342 print STDERR "unlinking $file\n";376 print STDERR "unlinking $file\n"; 343 377 $ipprc->file_delete($file); 344 378 } … … 346 380 } 347 381 348 sub addFilename 382 sub addFilename 349 383 { 350 384 my $files = shift; # reference to a list of files to unlink … … 359 393 } 360 394 395 # XXX we currently do not set the error state in the db on my_die 361 396 sub my_die 362 397 { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/ipp_maskscript.pl
r17671 r23352 12 12 use PS::IPP::Config 1.01 qw( :standard ); 13 13 14 my $ipprc = PS::IPP::Config->new(); # IPP configuration15 16 14 my ($dbname, $det_id, $camera); 17 18 15 GetOptions('dbname=s' => \$dbname, 19 'det_id=s' => \$det_id,20 'camera|c=s' => \$camera,21 ) or pod2usage( 2 );16 'det_id=s' => \$det_id, 17 'camera|c=s' => \$camera, 18 ) or pod2usage( 2 ); 22 19 23 20 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 24 21 25 22 pod2usage( 26 -msg => "USAGE: ipp_maskscript.pl --dbname (name) --det_id (id) --iter (iteration) --camera (name)",27 -exitval => 3,28 ) unless defined $dbname and defined $det_id and defined $camera;23 -msg => "USAGE: ipp_maskscript.pl --dbname (name) --det_id (id) --iter (iteration) --camera (name)", 24 -exitval => 3, 25 ) unless defined $dbname and defined $det_id and defined $camera; 29 26 30 27 # I could determine the camera from a query for the detrun 31 $ipprc->define_camera($camera); 28 my $ipprc = PS::IPP::Config->new( $camera ) or my_die("Unable to setup", $PS_EXIT_CONFIG_ERROR); # IPP configuration 32 29 33 30 ### Get list of dark imfile results … … 47 44 48 45 # parse the output into a list 49 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files46 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 50 47 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 51 48 &my_die("Unable to parse metadata config doc", $PS_EXIT_PROG_ERROR); … … 81 78 # print STDERR "contents: @contents\n"; 82 79 83 my $parser = PS::IPP::Metadata::Config->new; # Parser for metadata config files80 my $parser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 84 81 my $statsList = $parser->parse(join "", @contents) or &my_die("Unable to parse metadata for imfile stats", $PS_EXIT_SYS_ERROR); 85 82 … … 110 107 open (DATA, ">$component.dat"); 111 108 for (my $i = 0; $i < @{$nameX}; $i++) { 112 print DATA "${$nameX}[$i] ${$nameY}[$i]\n";109 print DATA "${$nameX}[$i] ${$nameY}[$i]\n"; 113 110 } 114 111 close (DATA); … … 147 144 my ($exp_time, $tag, $md) = @_; 148 145 149 # descend through the fpa 146 # descend through the fpa 150 147 foreach my $entry (@$md) { 151 # print STDERR "name: $entry->{name}, class: $entry->{class}\n";148 # print STDERR "name: $entry->{name}, class: $entry->{class}\n"; 152 149 # recurse on nested metadata 153 150 if ($entry->{class} eq 'metadata') { 154 my $newtag = $tag . "_" . $entry->{name};151 my $newtag = $tag . "_" . $entry->{name}; 155 152 &parse_stats_table ($exp_time, $newtag, $entry->{value}); 156 153 } … … 161 158 push @bg_stdev_data, $entry->{value}; 162 159 } else { 163 push @bg_name, $tag;160 push @bg_name, $tag; 164 161 push @bg_data, $entry->{value}; 165 push @bg_exptime, $exp_time;166 # print STDERR "$tag $exp_time $entry->{value}\n";162 push @bg_exptime, $exp_time; 163 # print STDERR "$tag $exp_time $entry->{value}\n"; 167 164 } 168 if (!$componentsHash{$tag}) {169 push @components, $tag;170 $componentsHash{$tag} = 1;171 }172 next;173 } 165 if (!$componentsHash{$tag}) { 166 push @components, $tag; 167 $componentsHash{$tag} = 1; 168 } 169 next; 170 } 174 171 } 175 172 return 1; -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/magic_definerun.pl
r21006 r23352 25 25 use PS::IPP::Config 1.01 qw( :standard ); 26 26 27 my $ipprc = PS::IPP::Config->new(); # IPP configuration28 29 27 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 30 28 use Pod::Usage qw( pod2usage ); 31 29 30 # Look for programs we need 31 my $missing_tools; 32 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1); 33 my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1); 34 my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1); 35 if ($missing_tools) { 36 warn("Can't find required tools."); 37 exit($PS_EXIT_CONFIG_ERROR); 38 } 39 32 40 # Parse the command-line arguments 33 41 my ($exp_id, $warp_id, $min_diff_id, $label, $workdir, $dbname, $save_temps, $verbose); 34 35 42 GetOptions( 36 43 'exp_id=s' => \$exp_id, # exposure identifier … … 50 57 defined $warp_id; 51 58 52 # $ipprc->define_camera($camera); 53 54 # Look for programs we need 55 my $missing_tools; 56 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1); 57 my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1); 58 my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1); 59 if ($missing_tools) { 60 warn("Can't find required tools."); 61 exit($PS_EXIT_CONFIG_ERROR); 62 } 59 my $ipprc = PS::IPP::Config->new() or my_die("Unable to set up", $PS_EXIT_CONFIG_ERROR); # IPP configuration 63 60 64 61 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/magic_destreak.pl
r22430 r23352 21 21 22 22 use PS::IPP::Config 1.01 qw( :standard ); 23 24 my $ipprc = PS::IPP::Config->new(); # IPP configuration25 23 26 24 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 76 74 defined $outroot; 77 75 78 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 79 $SIG{__DIE__} = sub { die @_ if $^S; 80 my_die( $_[0], $magic_ds_id, $component, $PS_EXIT_UNKNOWN_ERROR ); }; 81 76 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 77 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR ) if $logfile; 82 78 83 79 my ($skycell_args, $class_id, $skycell_id); … … 94 90 &my_die("Invalid value for stage: $stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 95 91 } 96 97 $ipprc->redirect_output($logfile) if $logfile;98 99 $ipprc->define_camera($camera);100 101 92 102 93 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 276 267 my $exit_code = shift; # Exit code to add 277 268 269 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 270 278 271 my $command = "$magicdstool -adddestreakedfile"; 279 272 $command .= " -magic_ds_id $magic_ds_id"; -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/magic_mask.pl
r22430 r23352 22 22 23 23 use PS::IPP::Config 1.01 qw( :standard ); 24 25 my $ipprc = PS::IPP::Config->new(); # IPP configuration26 24 27 25 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 58 56 defined $outroot; 59 57 60 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 61 $SIG{__DIE__} = sub { die @_ if $^S; 62 my_die( $_[0], $magic_id, $PS_EXIT_UNKNOWN_ERROR ); }; 63 64 $ipprc->define_camera($camera); 65 66 $ipprc->redirect_output($logfile) if $logfile; 58 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 59 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_id, $PS_EXIT_SYS_ERROR ) if $logfile; 67 60 68 61 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 153 146 my $exit_code = shift; # Exit code to add 154 147 148 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 149 155 150 carp($msg); 156 151 if (defined $magic_id and not $no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/magic_process.pl
r22430 r23352 23 23 24 24 use PS::IPP::Config 1.01 qw( :standard ); 25 26 my $ipprc = PS::IPP::Config->new(); # IPP configuration27 25 28 26 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 62 60 defined $outroot; 63 61 64 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 65 $SIG{__DIE__} = sub { die @_ if $^S; 66 my_die( $_[0], $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR ); }; 67 68 $ipprc->define_camera($camera); 62 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_id, $node, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 63 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_id, $node, $PS_EXIT_SYS_ERROR ) if $logfile; 69 64 70 65 # RemoveStreaks doesn't know about nebulous. It expects to be able to append strings to outroot … … 73 68 # of the file names as arguments 74 69 if ($outroot =~ 'neb:/') { 75 &my_die("RemoveStreaks does not support nebulous paths in outroot", $magic_id, $node, 76 $PS_EXIT_CONFIG_ERROR); 70 &my_die("RemoveStreaks does not support nebulous paths in outroot", $magic_id, $node, $PS_EXIT_CONFIG_ERROR); 77 71 } 78 72 79 73 # resolve any path:// or file:// in outroot 80 74 $outroot = $ipprc->file_resolve($outroot); 81 82 $ipprc->redirect_output($logfile) if $logfile;83 75 84 76 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 340 332 my $exit_code = shift; # Exit code to add 341 333 334 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 335 342 336 carp($msg); 343 337 if (defined $magic_id and defined $node and not $no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/magic_tree.pl
r22430 r23352 24 24 use File::Temp qw( tempfile ); 25 25 use PS::IPP::Config 1.01 qw( :standard ); 26 27 my $ipprc = PS::IPP::Config->new(); # IPP configuration28 26 29 27 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 70 68 defined $outroot; 71 69 72 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 73 $SIG{__DIE__} = sub { die @_ if $^S; 74 my_die( $_[0], $magic_id, $PS_EXIT_UNKNOWN_ERROR ); }; 75 76 $ipprc->define_camera($camera); 77 78 $ipprc->redirect_output($logfile) if $logfile; 70 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 71 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_id, $PS_EXIT_SYS_ERROR ) if $logfile; 79 72 80 73 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 297 290 my $exit_code = shift; # Exit code to add 298 291 292 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 293 299 294 carp($msg); 300 295 if (defined $magic_id and not $no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/register_exp.pl
r22430 r23352 24 24 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 25 25 use Pod::Usage qw( pod2usage ); 26 27 my $ipprc = PS::IPP::Config->new();28 26 29 27 # Look for commands we need … … 53 51 ) or pod2usage( 2 ); 54 52 55 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 56 $SIG{__DIE__} = sub { die @_ if $^S; 57 my_die( $_[0], $exp_id, $PS_EXIT_UNKNOWN_ERROR ); }; 58 59 $ipprc->redirect_output($logfile) if $logfile; 53 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $exp_id, $PS_EXIT_CONFIG_ERROR ); 54 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $exp_id, $PS_EXIT_SYS_ERROR ) if $logfile; 60 55 61 56 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; … … 192 187 my $exit_code = shift; 193 188 189 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 190 194 191 carp($msg); 195 192 if (defined $exp_id and not $no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/register_imfile.pl
r22428 r23352 23 23 use Math::Trig; 24 24 25 my $ipprc = PS::IPP::Config->new(); # IPP configuration26 25 use File::Spec; 27 26 … … 49 48 ) or pod2usage( 2 ); 50 49 51 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 52 $SIG{__DIE__} = sub { die @_ if $^S; 53 my_die( $_[0], $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_UNKNOWN_ERROR ); }; 54 55 $ipprc->redirect_output($logfile) if $logfile; 50 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 51 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_SYS_ERROR ) if $logfile; 56 52 57 53 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; … … 98 94 print "STDOUT:\n$out1"; 99 95 print "STDERR:\n$err1"; 100 &my_die("Unable to perform ppStats on exposure id $exp_id: " . $h1->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $h1->result() ) unless $result1;96 &my_die("Unable to perform ppStats on exposure id $exp_id: " . $h1->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, ($h1->result() or $PS_EXIT_PROG_ERROR) ) unless $result1; 101 97 102 98 print "[Running " . join(' ', @command2) . "]\n"; … … 107 103 print "STDOUT:\n$out2"; 108 104 print "STDERR:\n$err2"; 109 &my_die("Unable to perform ppStatsFromMetadata on exposure id $exp_id: " . $h2->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $h2->result() ) unless $result2;105 &my_die("Unable to perform ppStatsFromMetadata on exposure id $exp_id: " . $h2->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, ($h2->result() or $PS_EXIT_PROG_ERROR) ) unless $result2; 110 106 chomp $out2; 111 107 $cmdflags = $out2; … … 132 128 133 129 # determine solar-system parameters 134 my $longitude = &value_for_flag ($cmdflags, "-longitude");135 my $latitude = &value_for_flag ($cmdflags, "-latitude");136 my $elevation = &value_for_flag ($cmdflags, "-elevation");137 my $ra = &value_for_flag ($cmdflags, "-ra");138 my $dec = &value_for_flag ($cmdflags, "-decl");139 my $dateobs = &value_for_flag ($cmdflags, "-dateobs");130 my $longitude = &value_for_flag($cmdflags, "-longitude"); 131 my $latitude = &value_for_flag($cmdflags, "-latitude"); 132 my $elevation = &value_for_flag($cmdflags, "-elevation"); 133 my $ra = &value_for_flag($cmdflags, "-ra"); 134 my $dec = &value_for_flag($cmdflags, "-decl"); 135 my $dateobs = &value_for_flag($cmdflags, "-dateobs"); 140 136 141 137 # if the needed data is available, pass it to sunmoon: … … 216 212 217 213 # for failed imfiles, we insert UNKNOWN for inst, telescope, class_id 214 215 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 218 216 219 217 carp($msg); … … 230 228 $command .= " -hostname $host" if defined $host; 231 229 $command .= " -dbname $dbname" if defined $dbname; 232 system ($command); 230 print "Running: $command\n"; 231 system($command); 233 232 } 234 233 exit $exit_code; -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/stack_skycell.pl
r22430 r23352 24 24 use File::Basename; 25 25 use PS::IPP::Config 1.01 qw( :standard ); 26 27 my $ipprc = PS::IPP::Config->new(); # IPP configuration28 26 29 27 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 66 64 and defined $run_state; 67 65 68 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 69 $SIG{__DIE__} = sub { die @_ if $^S; 70 my_die( $_[0], $stack_id, $PS_EXIT_UNKNOWN_ERROR ); }; 66 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $stack_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 71 67 72 68 # XXX camera is not known here; cannot use filerules... … … 81 77 } 82 78 83 $ipprc->redirect_output($logDest) if $redirect;79 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $stack_id, $PS_EXIT_SYS_ERROR ) if $redirect; 84 80 85 81 my $temp_images_exist = 0; … … 300 296 my $exit_code = shift; # Exit code to add 301 297 298 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 299 302 300 carp($msg); 303 301 -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/summit_copy.pl
r20310 r23352 136 136 my $exit_code = shift; # Exit code to add 137 137 138 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 139 138 140 warn $msg; 139 141 unless ($no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/warp_overlap.pl
r22430 r23352 23 23 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 24 24 use Pod::Usage qw( pod2usage ); 25 26 my $ipprc = PS::IPP::Config->new(); # IPP configuration27 25 28 26 # Look for programs we need … … 49 47 ) or pod2usage( 2 ); 50 48 51 $ipprc->redirect_output($logfile) if $logfile;52 53 49 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 54 50 pod2usage( … … 59 55 and defined $tess_dir; 60 56 61 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 62 $SIG{__DIE__} = sub { die @_ if $^S; 63 my_die( $_[0], $warp_id, $PS_EXIT_UNKNOWN_ERROR ); }; 64 65 $ipprc->define_camera($camera); 57 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $warp_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 58 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $warp_id, $PS_EXIT_SYS_ERROR ) if $logfile; 66 59 67 60 &my_die("Tessellation identifier not provided: $tess_dir", $warp_id, $PS_EXIT_SYS_ERROR) unless $tess_dir ne "NULL"; … … 193 186 my $warp_id = shift; # Warp identifier 194 187 my $exit_code = shift; # Exit code to add 188 189 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 195 190 196 191 carp($msg); -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/warp_skycell.pl
r22430 r23352 24 24 use PS::IPP::Metadata::List qw( parse_md_list ); 25 25 use PS::IPP::Config 1.01 qw( :standard ); 26 27 my $ipprc = PS::IPP::Config->new(); # IPP configuration28 26 29 27 # Look for programs we need … … 68 66 and defined $run_state; 69 67 70 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 71 $SIG{__DIE__} = sub { die @_ if $^S; 72 my_die( $_[0], $warp_id, $skycell_id, $tess_dir, $PS_EXIT_UNKNOWN_ERROR ); }; 73 74 $ipprc->define_camera($camera); 75 76 my $logDest = $ipprc->filename("LOG.EXP", $outroot, $skycell_id); 68 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 69 70 my $logDest = $ipprc->filename("LOG.EXP", $outroot, $skycell_id) or my_die( "Unable to get log filename", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR ); 77 71 $logDest .= ".update" if ($run_state eq 'update'); 78 72 79 $ipprc->redirect_output($logDest) if $redirect;73 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR ) if $redirect; 80 74 81 75 my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_WARP); … … 294 288 my $exit_code = shift; # Exit code to add 295 289 290 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 291 296 292 warn($msg); 297 293 if (defined $warp_id and defined $skycell_id and defined $tess_dir and not $no_update) { -
branches/cnb_branches/cnb_branch_20090301/ippTasks/Makefile.am
r20879 r23352 20 20 summit.copy.pro \ 21 21 replicate.pro \ 22 dist.pro \ 22 23 pstamp.pro 23 24 -
branches/cnb_branches/cnb_branch_20090301/ippTasks/automate.pro
r19621 r23352 175 175 end 176 176 177 task.exit crash 178 showcommand crash 179 end 180 177 181 # operation times out? 178 182 task.exit timeout … … 283 287 end 284 288 289 task.exit crash 290 showcommand crash 291 end 292 285 293 # operation times out? 286 294 task.exit timeout … … 373 381 end 374 382 383 task.exit crash 384 showcommand crash 385 end 386 375 387 # operation times out? 376 388 task.exit timeout … … 448 460 end 449 461 462 task.exit crash 463 book setword automate $pageName pantaskState INIT.REGULAR 464 showcommand crash 465 end 466 450 467 # operation times out? 451 468 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/calibration.pro
r19465 r23352 90 90 end 91 91 92 task.exit crash 93 showcommand crash 94 end 95 92 96 # operation times out? 93 97 task.exit timeout … … 166 170 end 167 171 172 task.exit crash 173 showcommand crash 174 book setword calBook $options:0 pantaskState CRASH 175 end 176 168 177 # operation timed out? 169 178 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/camera.pro
r19559 r23352 104 104 end 105 105 106 task.exit crash 107 showcommand crash 108 end 109 106 110 # operation times out? 107 111 task.exit timeout … … 177 181 task.exit default 178 182 process_exit camPendingExp $options:0 $JOB_STATUS 183 end 184 185 # locked list 186 task.exit crash 187 showcommand crash 188 echo "hostname: $JOB_HOSTNAME" 189 book setword camPendingExp $options:0 pantaskState CRASH 179 190 end 180 191 … … 236 247 end 237 248 249 task.exit crash 250 showcommand crash 251 end 252 238 253 # operation times out? 239 254 task.exit timeout … … 289 304 end 290 305 306 task.exit crash 307 showcommand crash 308 book setword camPendingCleanup $options:0 pantaskState CRASH 309 end 310 291 311 # operation timed out? 292 312 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/chip.pro
r21464 r23352 29 29 active true 30 30 end 31 task chip. promoteexp31 task chip.advanceexp 32 32 active true 33 33 end … … 41 41 active false 42 42 end 43 task chip. promoteexp43 task chip.advanceexp 44 44 active false 45 45 end … … 111 111 task.exit default 112 112 showcommand failure 113 end 114 115 task.exit crash 116 showcommand crash 113 117 end 114 118 … … 188 192 end 189 193 194 # locked list 195 task.exit crash 196 showcommand crash 197 echo "hostname: $JOB_HOSTNAME" 198 book setword chipPendingImfile $options:0 pantaskState CRASH 199 end 200 190 201 # operation timed out? 191 202 task.exit timeout … … 196 207 197 208 # this variable will cycle through the known database names 198 $chip_ promote_DB = 0199 200 # promote exposures for which all imfiles have completed processing209 $chip_advance_DB = 0 210 211 # advance exposures for which all imfiles have completed processing 201 212 # sets the exposure state to full and queues warp processing if requested 202 task chip. promoteexp213 task chip.advanceexp 203 214 host local 204 215 … … 209 220 210 221 stdout NULL 211 stderr $LOGDIR/chip. promoteexp.log212 213 task.exec 214 $run = chiptool - promoteexp -limit 10222 stderr $LOGDIR/chip.advanceexp.log 223 224 task.exec 225 $run = chiptool -advanceexp -limit 10 215 226 if ($DB:n == 0) 216 227 option DEFAULT 217 228 else 218 229 # save the DB name for the exit tasks 219 option $DB:$chip_ promote_DB220 $run = $run -dbname $DB:$chip_ promote_DB221 $chip_ promote_DB ++222 if ($chip_ promote_DB >= $DB:n) set chip_promote_DB = 0230 option $DB:$chip_advance_DB 231 $run = $run -dbname $DB:$chip_advance_DB 232 $chip_advance_DB ++ 233 if ($chip_advance_DB >= $DB:n) set chip_advance_DB = 0 223 234 end 224 235 add_poll_args run … … 233 244 task.exit default 234 245 showcommand failure 246 end 247 248 task.exit crash 249 showcommand crash 235 250 end 236 251 … … 291 306 end 292 307 308 task.exit crash 309 showcommand crash 310 end 311 293 312 # operation times out? 294 313 task.exit timeout … … 344 363 end 345 364 365 task.exit crash 366 showcommand crash 367 book setword chipPendingCleanup $options:0 pantaskState CRASH 368 end 369 346 370 # operation timed out? 347 371 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/detrend.correct.pro
r20398 r23352 85 85 end 86 86 87 task.exit crash 88 showcommand crash 89 end 90 87 91 # operation times out? 88 92 task.exit timeout 89 showcommand 93 showcommand timeout 90 94 end 91 95 end … … 145 149 end 146 150 151 # locked list 152 task.exit crash 153 showcommand crash 154 echo "hostname: $JOB_HOSTNAME" 155 book setword detPendingCorrectImfile $options:0 pantaskState CRASH 156 end 157 147 158 # operation times out? 148 159 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/detrend.mkruns.pro
r16298 r23352 34 34 end 35 35 36 task.exit crash 37 # send someone email? 38 echo "unable to define a new detrend run" 39 end 40 36 41 # operation timed out? is the database down? 37 42 task.exit timeout … … 60 65 # default exit status 61 66 task.exit default 67 echo "unable to define a new detrend run" 68 end 69 70 task.exit crash 71 # send someone email? 62 72 echo "unable to define a new detrend run" 63 73 end … … 92 102 end 93 103 104 task.exit crash 105 # send someone email? 106 echo "unable to define a new detrend run" 107 end 108 94 109 # operation timed out? is the database down? 95 110 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/detrend.norm.pro
r19465 r23352 168 168 end 169 169 170 task.exit crash 171 showcommand crash 172 end 173 170 174 # operation times out? 171 175 task.exit timeout … … 225 229 task.exit default 226 230 process_exit detPendingNormStatImfile $options:0 $JOB_STATUS 231 end 232 233 # locked list 234 task.exit crash 235 showcommand crash 236 echo "hostname: $JOB_HOSTNAME" 237 book setword detPendingNormStatImfile $options:0 pantaskState CRASH 227 238 end 228 239 … … 278 289 task.exit default 279 290 showcommand failure 291 end 292 293 task.exit crash 294 showcommand crash 280 295 end 281 296 … … 342 357 end 343 358 359 # locked list 360 task.exit crash 361 showcommand crash 362 echo "hostname: $JOB_HOSTNAME" 363 book setword detPendingNormImfile $options:0 pantaskState CRASH 364 end 365 344 366 # operation times out? 345 367 task.exit timeout … … 395 417 end 396 418 419 task.exit crash 420 showcommand crash 421 end 422 397 423 # operation times out? 398 424 task.exit timeout … … 452 478 task.exit default 453 479 process_exit detPendingNormExp $options:0 $JOB_STATUS 480 end 481 482 # locked list 483 task.exit crash 484 showcommand crash 485 echo "hostname: $JOB_HOSTNAME" 486 book setword detPendingNormExp $options:0 pantaskState CRASH 454 487 end 455 488 … … 506 539 end 507 540 541 task.exit crash 542 showcommand crash 543 end 544 508 545 # operation times out? 509 546 task.exit timeout … … 558 595 task.exit default 559 596 process_exit detCleanupNormStatImfile $options:0 $JOB_STATUS 597 end 598 599 task.exit crash 600 showcommand crash 601 book setword detCleanupNormStatImfile $options:0 pantaskState CRASH 560 602 end 561 603 … … 612 654 end 613 655 656 task.exit crash 657 showcommand crash 658 end 659 614 660 # operation times out? 615 661 task.exit timeout … … 665 711 task.exit default 666 712 process_exit detCleanupNormImfile $options:0 $JOB_STATUS 713 end 714 715 task.exit crash 716 showcommand crash 717 book setword detCleanupNormImfile $options:0 pantaskState CRASH 667 718 end 668 719 … … 719 770 end 720 771 772 task.exit crash 773 showcommand crash 774 end 775 721 776 # operation times out? 722 777 task.exit timeout … … 773 828 end 774 829 830 task.exit crash 831 showcommand crash 832 book setword detCleanupNormExp $options:0 pantaskState CRASH 833 end 834 775 835 # operation timed out? 776 836 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/detrend.process.pro
r19465 r23352 136 136 end 137 137 138 task.exit crash 139 showcommand crash 140 end 141 138 142 # operation times out? 139 143 task.exit timeout 140 showcommand 144 showcommand timeout 141 145 end 142 146 end … … 202 206 end 203 207 208 # locked list 209 task.exit crash 210 showcommand crash 211 echo "hostname: $JOB_HOSTNAME" 212 book setword detPendingProcessedImfile $options:0 pantaskState CRASH 213 end 214 204 215 # operation times out? 205 216 task.exit timeout … … 255 266 end 256 267 268 task.exit crash 269 showcommand crash 270 end 271 257 272 # operation times out? 258 273 task.exit timeout … … 319 334 end 320 335 336 # locked list 337 task.exit crash 338 showcommand crash 339 echo "hostname: $JOB_HOSTNAME" 340 book setword detPendingProcessedExp $options:0 pantaskState CRASH 341 end 342 321 343 # operation times out? 322 344 task.exit timeout … … 371 393 end 372 394 395 task.exit crash 396 showcommand crash 397 end 398 373 399 # operation times out? 374 400 task.exit timeout … … 424 450 task.exit default 425 451 process_exit detCleanupProcessedImfile $options:0 $JOB_STATUS 452 end 453 454 # locked list 455 task.exit crash 456 showcommand crash 457 echo "hostname: $JOB_HOSTNAME" 458 book setword detCleanupProcessedImfile $options:0 pantaskState CRASH 426 459 end 427 460 … … 479 512 end 480 513 514 task.exit crash 515 showcommand crash 516 end 517 481 518 # operation times out? 482 519 task.exit timeout … … 533 570 end 534 571 572 # locked list 573 task.exit crash 574 showcommand crash 575 echo "hostname: $JOB_HOSTNAME" 576 book setword detCleanupProcessedExp $options:0 pantaskState CRASH 577 end 578 535 579 # operation timed out? 536 580 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/detrend.reject.pro
r19465 r23352 83 83 end 84 84 85 task.exit crash 86 showcommand crash 87 end 88 85 89 # operation times out? 86 90 task.exit timeout 87 showcommand failure91 showcommand timeout 88 92 end 89 93 end … … 143 147 end 144 148 149 # locked list 150 task.exit crash 151 showcommand crash 152 echo "hostname: $JOB_HOSTNAME" 153 book setword detRejectExp $options:0 pantaskState CRASH 154 end 155 145 156 # operation times out? 146 157 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/detrend.resid.pro
r19621 r23352 129 129 task.exit default 130 130 showcommand failure 131 end 132 133 task.exit crash 134 showcommand crash 131 135 end 132 136 … … 203 207 end 204 208 209 # locked list 210 task.exit crash 211 showcommand crash 212 echo "hostname: $JOB_HOSTNAME" 213 book setword detPendingResidImfile $options:0 pantaskState CRASH 214 end 215 205 216 # operation times out? 206 217 task.exit timeout … … 254 265 task.exit default 255 266 showcommand failure 267 end 268 269 task.exit crash 270 showcommand crash 256 271 end 257 272 … … 301 316 stderr $LOGDIR/detrend.resid.exp.log 302 317 303 $run = detrend_resid_exp.pl --det_id $DET_ID --iteration $ITERATION --exp_id $EXP_ID --exp_tag $EXP_TAG --det_ type $DET_TYPE --camera $CAMERA --outroot $outroot --redirect-output --verbose318 $run = detrend_resid_exp.pl --det_id $DET_ID --iteration $ITERATION --exp_id $EXP_ID --exp_tag $EXP_TAG --det_mode $MODE --det_type $DET_TYPE --camera $CAMERA --outroot $outroot --redirect-output --verbose 304 319 305 320 add_standard_args run … … 318 333 task.exit default 319 334 process_exit detPendingResidExp $options:0 $JOB_STATUS 335 end 336 337 # locked list 338 task.exit crash 339 showcommand crash 340 echo "hostname: $JOB_HOSTNAME" 341 book setword detPendingResidExp $options:0 pantaskState CRASH 320 342 end 321 343 … … 372 394 end 373 395 396 task.exit crash 397 showcommand crash 398 end 399 374 400 # operation times out? 375 401 task.exit timeout … … 426 452 task.exit default 427 453 process_exit detCleanupResidImfile $options:0 $JOB_STATUS 454 end 455 456 # locked list 457 task.exit crash 458 showcommand crash 459 echo "hostname: $JOB_HOSTNAME" 460 book setword detCleanupResidImfile $options:0 pantaskState CRASH 428 461 end 429 462 … … 481 514 end 482 515 516 task.exit crash 517 showcommand crash 518 end 519 483 520 # operation times out? 484 521 task.exit timeout … … 536 573 end 537 574 575 # locked list 576 task.exit crash 577 showcommand crash 578 echo "hostname: $JOB_HOSTNAME" 579 book setword detCleanupResidExp $options:0 pantaskState CRASH 580 end 581 538 582 # operation timed out? 539 583 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/detrend.stack.pro
r19465 r23352 101 101 end 102 102 103 task.exit crash 104 showcommand crash 105 end 106 103 107 # operation times out? 104 108 task.exit timeout … … 163 167 task.exit default 164 168 process_exit detPendingStackedImfile $options:0 $JOB_STATUS 169 end 170 171 # locked list 172 task.exit crash 173 showcommand crash 174 echo "hostname: $JOB_HOSTNAME" 175 book setword detPendingStackedImfile $options:0 pantaskState CRASH 165 176 end 166 177 … … 217 228 end 218 229 230 task.exit crash 231 showcommand crash 232 end 233 219 234 # operation times out? 220 235 task.exit timeout … … 272 287 end 273 288 289 # locked list 290 task.exit crash 291 showcommand crash 292 echo "hostname: $JOB_HOSTNAME" 293 book setword detCleanupStackedImfile $options:0 pantaskState CRASH 294 end 295 274 296 # operation timed out? 275 297 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/diff.pro
r21312 r23352 112 112 end 113 113 114 task.exit crash 115 showcommand crash 116 end 117 114 118 # operation times out? 115 119 task.exit timeout … … 173 177 task.exit default 174 178 process_exit diffSkyfile $options:0 $JOB_STATUS 179 end 180 181 # locked list 182 task.exit crash 183 showcommand crash 184 echo "hostname: $JOB_HOSTNAME" 185 book setword diffSkyfile $options:0 pantaskState CRASH 175 186 end 176 187 … … 229 240 end 230 241 242 task.exit crash 243 showcommand crash 244 end 245 231 246 # operation times out? 232 247 task.exit timeout … … 282 297 end 283 298 299 task.exit crash 300 showcommand crash 301 book setword diffCleanup $options:0 pantaskState CRASH 302 end 303 284 304 # operation timed out? 285 305 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/fake.pro
r21464 r23352 26 26 active true 27 27 end 28 task fake. promoteexp28 task fake.advanceexp 29 29 active true 30 30 end … … 38 38 active false 39 39 end 40 task fake. promoteexp40 task fake.advanceexp 41 41 active false 42 42 end … … 176 176 end 177 177 178 # locked list 179 task.exit crash 180 showcommand crash 181 echo "hostname: $JOB_HOSTNAME" 182 book setword fakePendingImfile $options:0 pantaskState CRASH 183 end 184 178 185 # operation timed out? 179 186 task.exit timeout … … 183 190 end 184 191 185 # promote exposures for which all imfiles have completed processing192 # advance exposures for which all imfiles have completed processing 186 193 # sets the exposure state to full and queues warp processing if requested 187 $fake_ promote_DB = 0188 task fake. promoteexp194 $fake_advance_DB = 0 195 task fake.advanceexp 189 196 host local 190 197 … … 195 202 196 203 stdout NULL 197 stderr $LOGDIR/fake. promoteexp.log198 199 task.exec 200 $run = faketool - promoteexp -limit 10204 stderr $LOGDIR/fake.advanceexp.log 205 206 task.exec 207 $run = faketool -advanceexp -limit 10 201 208 if ($DB:n == 0) 202 209 option DEFAULT 203 210 else 204 211 # save the DB name for the exit tasks 205 option $DB:$fake_ promote_DB206 $run = $run -dbname $DB:$fake_ promote_DB207 $fake_ promote_DB ++208 if ($fake_ promote_DB >= $DB:n) set fake_promote_DB = 0212 option $DB:$fake_advance_DB 213 $run = $run -dbname $DB:$fake_advance_DB 214 $fake_advance_DB ++ 215 if ($fake_advance_DB >= $DB:n) set fake_advance_DB = 0 209 216 end 210 217 add_poll_args run … … 219 226 task.exit default 220 227 showcommand failure 228 end 229 230 task.exit crash 231 showcommand crash 221 232 end 222 233 … … 278 289 end 279 290 291 task.exit crash 292 showcommand crash 293 end 294 280 295 # operation times out? 281 296 task.exit timeout … … 331 346 end 332 347 348 task.exit crash 349 showcommand crash 350 book setword fakePendingCleanup $options:0 pantaskState CRASH 351 end 352 333 353 # operation timed out? 334 354 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/flatcorr.pro
r20513 r23352 104 104 end 105 105 106 task.exit crash 107 showcommand crash 108 end 109 106 110 # operation times out? 107 111 task.exit timeout … … 157 161 end 158 162 163 task.exit crash 164 showcommand crash 165 end 166 159 167 # operation times out? 160 168 task.exit timeout … … 229 237 end 230 238 239 task.exit crash 240 showcommand crash 241 book setword flatcorrBook $options:0 pantaskState CRASH 242 end 243 231 244 # operation timed out? 232 245 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/magic.pro
r21436 r23352 118 118 end 119 119 120 task.exit crash 121 showcommand crash 122 end 123 120 124 # operation times out? 121 125 task.exit timeout … … 189 193 end 190 194 195 task.exit crash 196 showcommand crash 197 book setword magicToTree $options:0 pantaskState CRASH 198 end 199 191 200 # operation timed out? 192 201 task.exit timeout … … 239 248 end 240 249 250 task.exit crash 251 showcommand crash 252 end 253 241 254 # operation times out? 242 255 task.exit timeout … … 302 315 task.exit default 303 316 process_exit magicToProcess $options:0 $JOB_STATUS 317 end 318 319 task.exit crash 320 showcommand crash 321 book setword magicToProcess $options:0 pantaskState CRASH 304 322 end 305 323 … … 353 371 task.exit default 354 372 showcommand failure 373 end 374 375 task.exit crash 376 showcommand crash 355 377 end 356 378 … … 423 445 end 424 446 447 task.exit crash 448 showcommand crash 449 book setword magicToDS $options:0 pantaskState CRASH 450 end 451 425 452 # operation timed out? 426 453 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/pstamp.pro
r21411 r23352 97 97 end 98 98 99 task.exit crash 100 showcommand crash 101 end 102 99 103 task.exit timeout 100 104 showcommand timeout … … 136 140 end 137 141 142 task.exit crash 143 showcommand crash 144 end 145 138 146 task.exit timeout 139 147 showcommand timeout … … 178 186 showcommand failure 179 187 process_exit pstampRequest $options:0 $JOB_STATUS 188 end 189 190 task.exit crash 191 showcommand crash 192 book setword pstampRequest $options:0 pantaskState CRASH 180 193 end 181 194 … … 219 232 end 220 233 234 task.exit crash 235 showcommand crash 236 end 237 221 238 task.exit timeout 222 239 showcommand timeout … … 263 280 process_exit pstampFinish $options:0 $JOB_STATUS 264 281 showcommand failure 282 end 283 284 task.exit crash 285 showcommand crash 286 book setword pstampFinish $options:0 pantaskState CRASH.run 265 287 end 266 288 … … 307 329 end 308 330 331 task.exit crash 332 showcommand crash 333 end 334 309 335 task.exit timeout 310 336 showcommand timeout … … 362 388 end 363 389 390 task.exit crash 391 echo pstamp.job.run task.crash $JOB_ID status: $JOB_STATUS 392 process_exit pstampJob $options:0 $JOB_STATUS 393 showcommand crash 394 book setword pstampJob $options:0 pantaskState CRASH 395 end 396 364 397 task.exit timeout 365 398 echo pstamp.job.run task.timeout $JOB_ID status: $JOB_STATUS -
branches/cnb_branches/cnb_branch_20090301/ippTasks/register.pro
r20498 r23352 180 180 end 181 181 182 task.exit crash 183 showcommand crash 184 end 185 182 186 # operation times out? 183 187 task.exit timeout … … 255 259 task.exit default 256 260 process_exit regPendingImfile $options:0 $JOB_STATUS 261 end 262 263 # locked list 264 task.exit crash 265 showcommand crash 266 echo "hostname: $JOB_HOSTNAME" 267 book setword regPendingImfile $options:0 pantaskState CRASH 257 268 end 258 269 … … 306 317 task.exit default 307 318 showcommand failure 319 end 320 321 task.exit crash 322 showcommand crash 308 323 end 309 324 … … 392 407 end 393 408 409 # locked list 410 task.exit crash 411 showcommand crash 412 echo "hostname: $JOB_HOSTNAME" 413 book setword regPendingExp $options:0 pantaskState CRASH 414 end 415 416 task.exit crash 417 showcommand crash 418 book setword regPendingExp $options:0 pantaskState CRASH 419 end 420 394 421 # operation times out? 395 422 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/replicate.pro
r19747 r23352 62 62 # the replicate process interacts with only the single Nebulous server 63 63 64 # Each 'pendingreplicate' query is limited to a finite number of so_id values. 65 # Each time we call replicate.load, we increment SO_ID_START by the range value. 66 # If the pendingreplicate query exits with exit status 10, we start over at 0 67 68 $SO_ID_START = 0 69 $SO_ID_RANGE = 100000 70 64 71 # select Nebulous objects which desire additional copies 65 72 task replicate.load … … 68 75 # modify these after the tasks are tested 69 76 periods -poll 10 70 periods -exec 1 77 periods -exec 10 71 78 periods -timeout 1500 72 79 npending 1 … … 79 86 # command does not need to be dynamic, but having it so allows us to adjust the periods 80 87 # so that we dont have to wait 10 minutes for things to start up 81 command neb-admin --host $NEB_HOST --db $NEB_DB --user $NEB_USER --pass $NEB_PASS --pendingreplicate --limit 7500 88 # XXX smaller limited? 7500 will be a huge book of things to do... 89 command neb-admin --host $NEB_HOST --db $NEB_DB --user $NEB_USER --pass $NEB_PASS --pendingreplicate --limit 7500 --so_id_start $SO_ID_START --so_id_range $SO_ID_RANGE 82 90 periods -exec 1800 83 91 … … 86 94 # success 87 95 task.exit $EXIT_SUCCESS 96 # advance the so_id counter 97 $SO_ID_START += $SO_ID_RANGE 98 88 99 # convert 'stdout' to book format 89 100 ipptool2book stdout replicatePending -key key -uniq -setword pantaskState INIT … … 97 108 end 98 109 110 # out of so_id range, reset 111 task.exit 10 112 # advance the so_id counter 113 $SO_ID_START = 0 114 end 115 99 116 # locked list 100 117 task.exit default 101 118 showcommand failure 119 end 120 121 task.exit crash 122 showcommand crash 102 123 end 103 124 … … 158 179 end 159 180 181 task.exit crash 182 showcommand crash 183 book setword replicatePending $options:0 pantaskState CRASH 184 end 185 160 186 # operation timed out? 161 187 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/stack.pro
r19597 r23352 112 112 end 113 113 114 task.exit crash 115 showcommand crash 116 end 117 114 118 # operation times out? 115 119 task.exit timeout … … 172 176 task.exit default 173 177 process_exit stackSumSkyfile $options:0 $JOB_STATUS 178 end 179 180 # locked list 181 task.exit crash 182 showcommand crash 183 echo "hostname: $JOB_HOSTNAME" 184 book setword stackSumSkyfile $options:0 pantaskState CRASH 174 185 end 175 186 … … 229 240 end 230 241 242 task.exit crash 243 showcommand crash 244 end 245 231 246 # operation times out? 232 247 task.exit timeout … … 282 297 end 283 298 299 task.exit crash 300 showcommand crash 301 book setword stackCleanup $options:0 pantaskState CRASH 302 end 303 284 304 # operation timed out? 285 305 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/summit.copy.pro
r21478 r23352 126 126 showcommand failure 127 127 end 128 task.exit crash 129 showcommand crash 130 end 128 131 task.exit timeout 129 132 showcommand timeout … … 182 185 showcommand failure 183 186 end 187 task.exit crash 188 showcommand crash 189 end 184 190 task.exit timeout 185 191 showcommand timeout … … 228 234 queueprint stderr 229 235 end 236 end 237 task.exit crash 238 showcommand crash 230 239 end 231 240 task.exit timeout … … 296 305 showcommand failure 297 306 process_exit pzPendingExp $options:0 $JOB_STATUS 307 end 308 309 task.exit crash 310 showcommand crash 311 book setword pzPendingExp $options:0 pantaskState CRASH 298 312 end 299 313 … … 344 358 showcommand failure 345 359 end 360 task.exit crash 361 showcommand crash 362 end 346 363 task.exit timeout 347 364 showcommand timeout … … 413 430 book setword pzPendingImfile $pageName filename $FILENAME 414 431 432 stdout $LOGDIR/summit.copy.log 433 stderr $LOGDIR/summit.copy.log 434 415 435 $run = summit_copy.pl --uri $URI --filename $FILENAME --exp_name $EXP_NAME --inst $CAMERA --telescope $TELESCOPE --class $CLASS --class_id $CLASS_ID --bytes $BYTES --md5 $MD5SUM --end_stage reg --workdir $workdir --dbname $DBNAME --timeout 120 --verbose --copies 2 416 436 if ($COMPRESS) … … 442 462 end 443 463 464 task.exit crash 465 showcommand crash 466 book setword pzPendingImfile $options:0 pantaskState CRASH 467 end 468 444 469 # operation timed out? 445 470 task.exit timeout … … 476 501 task.exit default 477 502 showcommand failure 503 end 504 task.exit crash 505 showcommand crash 478 506 end 479 507 task.exit timeout … … 518 546 end 519 547 548 task.exit crash 549 showcommand crash 550 end 551 520 552 # operation times out? 521 553 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTasks/warp.pro
r20932 r23352 127 127 end 128 128 129 task.exit crash 130 showcommand crash 131 end 132 129 133 # operation times out? 130 134 task.exit timeout … … 185 189 task.exit default 186 190 process_exit warpInputExp $options:0 $JOB_STATUS 191 end 192 193 # locked list 194 task.exit crash 195 showcommand crash 196 echo "hostname: $JOB_HOSTNAME" 197 book setword warpInputExp $options:0 pantaskState CRASH 187 198 end 188 199 … … 239 250 task.exit default 240 251 showcommand failure 252 end 253 254 task.exit crash 255 showcommand crash 241 256 end 242 257 … … 303 318 end 304 319 320 # locked list 321 task.exit crash 322 showcommand crash 323 echo "hostname: $JOB_HOSTNAME" 324 book setword warpPendingSkyCell $options:0 pantaskState CRASH 325 end 326 305 327 # operation timed out? 306 328 task.exit timeout … … 357 379 end 358 380 381 task.exit crash 382 showcommand crash 383 end 384 359 385 # operation times out? 360 386 task.exit timeout … … 410 436 end 411 437 438 task.exit crash 439 showcommand crash 440 book setword warpPendingCleanup $options:0 pantaskState CRASH 441 end 442 412 443 # operation timed out? 413 444 task.exit timeout -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/Makefile.am
r21521 r23352 84 84 difftool_skyfile.sql \ 85 85 difftool_todiffskyfile.sql \ 86 disttool_pendingcomponent.sql \ 87 disttool_processedcomponent.sql \ 88 disttool_revertrun_update.sql \ 89 disttool_revertrun_delete.sql \ 90 disttool_toadvance.sql \ 86 91 faketool_change_exp_state.sql \ 87 92 faketool_change_imfile_data_state.sql \ -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/chiptool_change_imfile_data_state.sql
r19527 r23352 7 7 chip_id = %lld 8 8 AND class_id = '%s' 9 -- only update if chipRun.state has the expected value10 AND (11 SELECT state from chipRun where chipRun.chip_id = chipProcessedImfile.chip_id12 ) = '%s'13 14 -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/chiptool_pendingcleanupimfile.sql
r19527 r23352 15 15 ((chipRun.state = 'goto_cleaned' AND chipProcessedImfile.data_state = 'full') 16 16 OR 17 (chipRun.state = 'goto_scrubbed' AND chipProcessedImfile.data_state = 'full') 18 OR 17 19 (chipRun.state = 'goto_purged' AND chipProcessedImfile.data_state != 'purged')) -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/chiptool_pendingcleanuprun.sql
r19527 r23352 7 7 USING (exp_id) 8 8 WHERE 9 (chipRun.state = 'goto_cleaned' OR chipRun.state = 'goto_ purged')9 (chipRun.state = 'goto_cleaned' OR chipRun.state = 'goto_scrubbed' OR chipRun.state = 'goto_purged') -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/dettool_processedimfile.sql
r18561 r23352 1 -- is this DISTINCT needed? 1 2 SELECT DISTINCT 2 3 detRun.det_type, -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/dettool_residimfile.sql
r19632 r23352 2 2 detRun.det_type, 3 3 detRun.mode, 4 detResidImfile.*, 5 rawExp.exp_time 6 FROM detResidImfile 7 JOIN detRun 8 USING(det_id, iteration) 9 JOIN rawExp 10 USING(exp_id) 4 rawExp.exp_time, 5 detResidImfile.* 6 FROM detResidImfile 7 JOIN detRun 8 USING(det_id, iteration) 9 JOIN detInputExp 10 ON detRun.det_id = detInputExp.det_id 11 AND detRun.iteration = detInputExp.iteration 12 AND detResidImfile.exp_id = detInputExp.exp_id 13 JOIN rawExp 14 ON rawExp.exp_id = detResidImfile.exp_id -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/dettool_todetrunsummary.sql
r14078 r23352 40 40 AND detRunSummary.det_id IS NULL 41 41 AND detRunSummary.iteration IS NULL 42 AND detResidExp.fault = 0 42 43 GROUP BY 43 44 detRun.det_id, -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/dettool_tonormalizedstat.sql
r18118 r23352 1 -- select detRun.det_id (det_id) 2 -- select detRun.iteration 3 -- by: 4 -- find the current iteration bassed on det_id 5 -- find all exp_ids in the current det_id/iteration from detInputExp 6 -- sort to detInputExp.imfiles to find the largest value per det_id/iter 7 -- compare imfiles to the number of detStackedImfiles by class_id 8 -- and: 9 -- ??? 10 -- det_id is not in detStackedImfile; 11 -- iteration is not in detStackedImfile; 12 13 SELECT 14 det_id, 15 det_type, 16 iteration, 17 camera, 18 workdir, 19 class_id 20 FROM 21 (SELECT DISTINCT 22 detRun.det_id, 23 detRun.det_type, 24 detRun.iteration, 25 detRun.workdir, 26 rawExp.camera, 27 detStackedImfile.class_id, 28 rawImfile.class_id as rawimfile_class_id 29 FROM detRun 30 JOIN detInputExp 31 ON detRun.det_id = detInputExp.det_id 32 AND detRun.iteration = detInputExp.iteration 33 JOIN rawExp 34 ON detInputExp.exp_id = rawExp.exp_id 35 JOIN rawImfile 36 ON rawExp.exp_id = rawImfile.exp_id 37 LEFT JOIN detStackedImfile 38 ON detInputExp.det_id = detStackedImfile.det_id 39 AND detInputExp.iteration = detStackedImfile.iteration 40 AND rawImfile.class_id = detStackedImfile.class_id 41 LEFT JOIN detNormalizedStatImfile 42 ON detStackedImfile.det_id = detNormalizedStatImfile.det_id 43 AND detStackedImfile.iteration = detNormalizedStatImfile.iteration 44 AND detStackedImfile.class_id = detNormalizedStatImfile.class_id 45 WHERE 46 detRun.state = 'run' 47 AND detRun.mode = 'master' 48 AND detNormalizedStatImfile.det_id IS NULL 49 AND detNormalizedStatImfile.iteration IS NULL 50 AND detNormalizedStatImfile.class_id IS NULL 51 GROUP BY 52 -- rawExp.exp_id, 53 detRun.iteration, 54 detRun.det_id 55 HAVING 56 COUNT(rawImfile.class_id) = COUNT(detStackedImfile.class_id) 57 AND SUM(detStackedImfile.fault) = 0 58 ) as tonormalizedstat 1 -- a det_run + iteration is ready for normstat when: all detResidImfile entries for that iteration corresponding to all detProcessedImfile entries are available 2 SELECT 3 detRun.det_id, 4 detRun.det_type, 5 detRun.iteration, 6 detRun.camera, 7 detRun.workdir, 8 detProcessedImfile.class_id, 9 COUNT(detProcessedImfile.class_id), 10 COUNT(detResidImfile.class_id) 11 FROM detRun 12 JOIN detProcessedImfile 13 ON detProcessedImfile.det_id = detRun.det_id 14 LEFT JOIN detResidImfile 15 ON detResidImfile.det_id = detProcessedImfile.det_id 16 AND detResidImfile.exp_id = detProcessedImfile.exp_id 17 AND detResidImfile.class_id = detProcessedImfile.class_id 18 AND detResidImfile.iteration = detRun.iteration 19 LEFT JOIN detNormalizedStatImfile 20 ON detNormalizedStatImfile.det_id = detRun.det_id 21 AND detNormalizedStatImfile.iteration = detRun.iteration 22 AND detNormalizedStatImfile.class_id = detProcessedImfile.class_id 23 WHERE 24 detRun.state = 'run' 25 AND detRun.mode = 'master' 26 AND detNormalizedStatImfile.det_id IS NULL 27 AND detNormalizedStatImfile.iteration IS NULL 28 AND detNormalizedStatImfile.class_id IS NULL 29 GROUP BY 30 detRun.iteration, 31 detRun.det_id 32 HAVING 33 COUNT(detProcessedImfile.class_id) = COUNT(detResidImfile.class_id) 34 AND SUM(detResidImfile.fault) = 0 -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/dettool_toresidexp.sql
r19815 r23352 5 5 -- id, detrend type, and whether the exposure was included in the stack for 6 6 -- this iteration. 7 8 -- require the corresponding detNormalizedExp to complete before starting 7 9 8 10 -- select detRun.det_id … … 18 20 -- detResidImfile.{det_id, iteration, exp_id} is not in detResidExp 19 21 20 SELECT DISTINCT22 SELECT 21 23 det_id, 22 24 iteration, … … 28 30 workdir, 29 31 exp_tag 30 FROM 31 (SELECT DISTINCT32 FROM 33 ( SELECT 32 34 detRun.det_id AS det_id, 33 35 detRun.iteration, 34 36 detRun.det_type, 35 37 detRun.mode, 36 detRun.workdir,37 38 detInputExp.exp_id, 38 39 detInputExp.include, 39 40 rawExp.camera, 40 rawExp.exp_tag, 41 detResidImfile.class_id 41 detRun.workdir, 42 rawExp.exp_tag 43 FROM detRun 44 JOIN detNormalizedExp 45 USING(det_id, iteration) 46 JOIN detInputExp 47 USING(det_id, iteration) 48 JOIN rawExp 49 ON detInputExp.exp_id = rawExp.exp_id 50 JOIN rawImfile 51 on rawExp.exp_id = rawImfile.exp_id 52 LEFT JOIN detResidImfile 53 ON detRun.det_id = detResidImfile.det_id 54 AND detRun.iteration = detResidImfile.iteration 55 AND detInputExp.exp_id = detResidImfile.exp_id 56 AND rawImfile.class_id = detResidImfile.class_id 57 LEFT JOIN detResidExp 58 ON detResidImfile.det_id = detResidExp.det_id 59 AND detResidImfile.iteration = detResidExp.iteration 60 AND detResidImfile.exp_id = detResidExp.exp_id 61 WHERE 62 detRun.state = 'run' 63 AND detRun.mode = 'master' 64 AND detResidExp.det_id IS NULL 65 AND detResidExp.iteration IS NULL 66 AND detResidExp.exp_id IS NULL 67 GROUP BY 68 detInputExp.exp_id, 69 detRun.iteration, 70 detRun.det_id 71 HAVING 72 COUNT(rawImfile.class_id) = COUNT(detResidImfile.class_id) 73 AND SUM(detResidImfile.fault) = 0 74 UNION 75 SELECT 76 detRun.det_id AS det_id, 77 detRun.iteration, 78 detRun.det_type, 79 detRun.mode, 80 detInputExp.exp_id, 81 detInputExp.include, 82 rawExp.camera, 83 detRun.workdir, 84 rawExp.exp_tag 42 85 FROM detRun 43 86 JOIN detInputExp … … 58 101 WHERE 59 102 detRun.state = 'run' 103 AND detRun.mode = 'verify' 60 104 AND detResidExp.det_id IS NULL 61 105 AND detResidExp.iteration IS NULL … … 68 112 COUNT(rawImfile.class_id) = COUNT(detResidImfile.class_id) 69 113 AND SUM(detResidImfile.fault) = 0 70 ) AS toresidexp114 ) as temp -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/dettool_toresidimfile.sql
r19816 r23352 13 13 detProcessedImfile.class_id, 14 14 detProcessedImfile.uri, 15 detNormalizedImfile.uri AS det_uri, 15 -- detNormalizedImfile.uri AS det_uri, 16 detStackedImfile.uri AS det_uri, 16 17 detRun.det_id AS ref_det_id, 17 18 detRun.iteration AS ref_iter, … … 26 27 ON detRun.det_id = detProcessedImfile.det_id 27 28 AND detInputExp.exp_id = detProcessedImfile.exp_id 28 JOIN detNormalizedImfile 29 ON detRun.det_id = detNormalizedImfile.det_id 30 AND detRun.iteration = detNormalizedImfile.iteration 31 AND detProcessedImfile.class_id = detNormalizedImfile.class_id 32 JOIN detNormalizedExp 33 ON detRun.det_id = detNormalizedExp.det_id 34 AND detRun.iteration = detNormalizedExp.iteration 29 JOIN detStackedImfile 30 ON detRun.det_id = detStackedImfile.det_id 31 AND detRun.iteration = detStackedImfile.iteration 32 AND detProcessedImfile.class_id = detStackedImfile.class_id 33 -- EAM : replacing detNormalizedImfile with detStackedImfile to change the sequencing 34 -- JOIN detNormalizedImfile 35 -- ON detRun.det_id = detNormalizedImfile.det_id 36 -- AND detRun.iteration = detNormalizedImfile.iteration 37 -- AND detProcessedImfile.class_id = detNormalizedImfile.class_id 38 -- EAM : we there is no reason to wait for all stacks to complete before continuing 39 -- JOIN detNormalizedExp 40 -- ON detRun.det_id = detNormalizedExp.det_id 41 -- AND detRun.iteration = detNormalizedExp.iteration 35 42 LEFT JOIN detResidImfile 36 43 ON detRun.det_id = detResidImfile.det_id … … 41 48 detRun.state = 'run' 42 49 AND detRun.mode = 'master' 43 AND detNormalizedImfile.fault = 0 44 AND detNormalizedExp.fault = 0 50 AND detStackedImfile.fault = 0 51 -- AND detNormalizedImfile.fault = 0 52 -- AND detNormalizedExp.fault = 0 45 53 AND detResidImfile.det_id IS NULL 46 54 AND detResidImfile.iteration IS NULL -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/pxadmin_create_tables.sql
r21308 r23352 737 737 REFERENCES detInputExp(det_id, iteration, exp_id), 738 738 FOREIGN KEY (det_id, exp_id, class_id) 739 REFERENCES detProcessedImfile(det_id, exp_id, class_id), 740 FOREIGN KEY (ref_det_id, ref_iter) 741 REFERENCES detNormalizedExp(det_id, iteration) 739 REFERENCES detProcessedImfile(det_id, exp_id, class_id) 742 740 ) ENGINE=innodb DEFAULT CHARSET=latin1; 743 741 -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/warptool_change_skyfile_data_state.sql
r19521 r23352 9 9 AND skycell_id = '%s' 10 10 -- only update if chipRun.state has the expected value 11 AND ( 12 SELECT state from warpRun where warpRun.warp_id = warpSkyfile.warp_id 13 ) = '%s' 14 15 11 -- AND ( 12 -- SELECT state from warpRun where warpRun.warp_id = warpSkyfile.warp_id 13 -- ) = '%s' -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/camtool.c
r21443 r23352 44 44 static bool pendingcleanupexpMode(pxConfig *config); 45 45 static bool donecleanupMode(pxConfig *config); 46 static bool exportrunMode(pxConfig *config); 47 static bool importrunMode(pxConfig *config); 46 48 47 49 # define MODECASE(caseName, func) \ … … 77 79 MODECASE(CAMTOOL_MODE_PENDINGCLEANUPEXP, pendingcleanupexpMode); 78 80 MODECASE(CAMTOOL_MODE_DONECLEANUP, donecleanupMode); 81 MODECASE(CAMTOOL_MODE_EXPORTRUN, exportrunMode); 82 MODECASE(CAMTOOL_MODE_IMPORTRUN, importrunMode); 79 83 default: 80 84 psAbort("invalid option (this should not happen)"); … … 1081 1085 return true; 1082 1086 } 1087 1088 bool exportrunMode(pxConfig *config) 1089 { 1090 typedef struct ExportTable { 1091 char tableName[80]; 1092 char sqlFilename[80]; 1093 } ExportTable; 1094 1095 int numExportTables = 2; 1096 1097 PS_ASSERT_PTR_NON_NULL(config, NULL); 1098 1099 PXOPT_LOOKUP_S64(det_id, config->args, "-cam_id", true, false); 1100 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 1101 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1102 1103 FILE *f = fopen (outfile, "w"); 1104 if (f == NULL) { 1105 psError(PS_ERR_UNKNOWN, false, "failed to open output file"); 1106 return false; 1107 } 1108 1109 psMetadata *where = psMetadataAlloc(); 1110 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "=="); 1111 1112 ExportTable tables [] = { 1113 {"camRun", "camtool_export_run.sql"}, 1114 {"camProcessedExp", "camtool_export_processed_exp.sql"}, 1115 }; 1116 1117 for (int i=0; i < numExportTables; i++) { 1118 psString query = pxDataGet(tables[i].sqlFilename); 1119 if (!query) { 1120 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1121 return false; 1122 } 1123 1124 if (where && psListLength(where->list)) { 1125 psString whereClause = psDBGenerateWhereSQL(where, NULL); 1126 psStringAppend(&query, " %s", whereClause); 1127 psFree(whereClause); 1128 } 1129 1130 // treat limit == 0 as "no limit" 1131 if (limit) { 1132 psString limitString = psDBGenerateLimitSQL(limit); 1133 psStringAppend(&query, " %s", limitString); 1134 psFree(limitString); 1135 } 1136 1137 if (!p_psDBRunQuery(config->dbh, query)) { 1138 psError(PS_ERR_UNKNOWN, false, "database error"); 1139 psFree(query); 1140 return false; 1141 } 1142 psFree(query); 1143 1144 psArray *output = p_psDBFetchResult(config->dbh); 1145 if (!output) { 1146 psError(PS_ERR_UNKNOWN, false, "database error"); 1147 return false; 1148 } 1149 if (!psArrayLength(output)) { 1150 psTrace("regtool", PS_LOG_INFO, "no rows found"); 1151 psFree(output); 1152 return true; 1153 } 1154 1155 // we must write the export table in non-simple (true) format 1156 if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) { 1157 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1158 psFree(output); 1159 return false; 1160 } 1161 psFree(output); 1162 } 1163 1164 fclose (f); 1165 1166 return true; 1167 } 1168 1169 bool importrunMode(pxConfig *config) 1170 { 1171 unsigned int nFail; 1172 1173 PS_ASSERT_PTR_NON_NULL(config, NULL); 1174 1175 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 1176 1177 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1178 1179 fprintf (stdout, "---- input ----\n"); 1180 psMetadataPrint (stderr, input, 1); 1181 1182 psMetadataItem *item = psMetadataLookup (input, "camRun"); 1183 psAssert (item, "entry not in input?"); 1184 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1185 1186 psMetadataItem *entry = psListGet (item->data.list, 0); 1187 assert (entry); 1188 assert (entry->type == PS_DATA_METADATA); 1189 camRunRow *camRun = camRunObjectFromMetadata (entry->data.md); 1190 camRunInsertObject (config->dbh, camRun); 1191 1192 // fprintf (stdout, "---- cam run ----\n"); 1193 // psMetadataPrint (stderr, entry->data.md, 1); 1194 1195 item = psMetadataLookup (input, "camProcessedImfile"); 1196 psAssert (item, "entry not in input?"); 1197 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1198 1199 for (int i = 0; i < item->data.list->n; i++) { 1200 psMetadataItem *entry = psListGet (item->data.list, i); 1201 assert (entry); 1202 assert (entry->type == PS_DATA_METADATA); 1203 camProcessedExpRow *camProcessedExp = camProcessedExpObjectFromMetadata (entry->data.md); 1204 camProcessedExpInsertObject (config->dbh, camProcessedExp); 1205 1206 // fprintf (stdout, "---- row %d ----\n", i); 1207 // psMetadataPrint (stderr, entry->data.md, 1); 1208 } 1209 1210 return true; 1211 } -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/camtool.h
r19092 r23352 39 39 CAMTOOL_MODE_PENDINGCLEANUPEXP, 40 40 CAMTOOL_MODE_DONECLEANUP, 41 CAMTOOL_MODE_EXPORTRUN, 42 CAMTOOL_MODE_IMPORTRUN 41 43 } camtoolMode; 42 44 -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/camtoolConfig.c
r20276 r23352 228 228 psMetadataAddU64(donecleanupArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 229 229 230 // -exportrun 231 psMetadata *exportrunArgs = psMetadataAlloc(); 232 psMetadataAddS64(exportrunArgs, PS_LIST_TAIL, "-cam_id", 0, "export this camera ID (required)", 0); 233 psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0, "export to this file (required)", NULL); 234 psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 235 236 // -importrun 237 psMetadata *importrunArgs = psMetadataAlloc(); 238 psMetadataAddStr(importrunArgs, PS_LIST_TAIL, "-infile", 0, "import from this file (required)", NULL); 239 240 230 241 psMetadata *argSets = psMetadataAlloc(); 231 242 psMetadata *modes = psMetadataAlloc(); … … 245 256 PXOPT_ADD_MODE("-pendingcleanupexp", "show exposures for cleanup runs", CAMTOOL_MODE_PENDINGCLEANUPEXP, pendingcleanupexpArgs); 246 257 PXOPT_ADD_MODE("-donecleanup", "show runs that have been cleaned", CAMTOOL_MODE_DONECLEANUP, donecleanupArgs); 258 PXOPT_ADD_MODE("-exportrun", "export run for import on other database", CAMTOOL_MODE_EXPORTRUN, exportrunArgs); 259 PXOPT_ADD_MODE("-importrun", "import run from metadata file", CAMTOOL_MODE_IMPORTRUN, importrunArgs); 247 260 248 261 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/chiptool.c
r21521 r23352 42 42 static bool revertprocessedimfileMode(pxConfig *config); 43 43 static bool updateprocessedimfileMode(pxConfig *config); 44 static bool promoteexpMode(pxConfig *config);44 static bool advanceexpMode(pxConfig *config); 45 45 static bool blockMode(pxConfig *config); 46 46 static bool maskedMode(pxConfig *config); … … 81 81 MODECASE(CHIPTOOL_MODE_REVERTPROCESSEDIMFILE, revertprocessedimfileMode); 82 82 MODECASE(CHIPTOOL_MODE_UPDATEPROCESSEDIMFILE, updateprocessedimfileMode); 83 MODECASE(CHIPTOOL_MODE_ PROMOTEEXP, promoteexpMode);83 MODECASE(CHIPTOOL_MODE_ADVANCEEXP, advanceexpMode); 84 84 MODECASE(CHIPTOOL_MODE_BLOCK, blockMode); 85 85 MODECASE(CHIPTOOL_MODE_MASKED, maskedMode); … … 239 239 pxchipGetSearchArgs (config, where); // rawExp, chipRun 240 240 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 241 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "=="); 241 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "=="); 242 PXOPT_COPY_STR(config->args, where, "-state", "chipRun.state", "=="); 242 243 243 244 if (!psListLength(where->list) … … 1078 1079 1079 1080 1080 static bool promoteexpMode(pxConfig *config)1081 static bool advanceexpMode(pxConfig *config) 1081 1082 { 1082 1083 PS_ASSERT_PTR_NON_NULL(config, false); … … 1256 1257 bool exportrunMode(pxConfig *config) 1257 1258 { 1258 PS_ASSERT_PTR_NON_NULL(config, NULL); 1259 1260 PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", true, false); 1261 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 1262 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1263 1264 FILE *f = fopen (outfile, "w"); 1265 if (f == NULL) { 1266 psError(PS_ERR_UNKNOWN, false, "failed to open output file"); 1267 return false; 1268 } 1269 1270 psMetadata *where = psMetadataAlloc(); 1271 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 1272 1273 // *** extract the chipRun in this section *** 1274 psString query = pxDataGet("chiptool_export_run.sql"); 1259 typedef struct ExportTable { 1260 char tableName[80]; 1261 char sqlFilename[80]; 1262 } ExportTable; 1263 1264 int numExportTables = 3; 1265 1266 PS_ASSERT_PTR_NON_NULL(config, NULL); 1267 1268 PXOPT_LOOKUP_S64(det_id, config->args, "-chip_id", true, false); 1269 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 1270 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1271 1272 FILE *f = fopen (outfile, "w"); 1273 if (f == NULL) { 1274 psError(PS_ERR_UNKNOWN, false, "failed to open output file"); 1275 return false; 1276 } 1277 1278 psMetadata *where = psMetadataAlloc(); 1279 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 1280 1281 ExportTable tables [] = { 1282 {"chipRun", "chiptool_export_run.sql"}, 1283 {"chipImfile", "chiptool_export_imfile.sql"}, 1284 {"chipProcessedImfile", "chiptool_export_processed_imfile.sql"}, 1285 }; 1286 1287 1288 for (int i=0; i < numExportTables; i++) { 1289 psString query = pxDataGet(tables[i].sqlFilename); 1275 1290 if (!query) { 1276 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");1277 return false;1291 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1292 return false; 1278 1293 } 1279 1294 1280 1295 if (where && psListLength(where->list)) { 1281 psString whereClause = psDBGenerateWhereSQL(where, NULL);1282 psStringAppend(&query, " %s", whereClause);1283 psFree(whereClause);1296 psString whereClause = psDBGenerateWhereSQL(where, NULL); 1297 psStringAppend(&query, " %s", whereClause); 1298 psFree(whereClause); 1284 1299 } 1285 1300 1286 1301 // treat limit == 0 as "no limit" 1287 1302 if (limit) { 1288 psString limitString = psDBGenerateLimitSQL(limit);1289 psStringAppend(&query, " %s", limitString);1290 psFree(limitString);1303 psString limitString = psDBGenerateLimitSQL(limit); 1304 psStringAppend(&query, " %s", limitString); 1305 psFree(limitString); 1291 1306 } 1292 1307 1293 1308 if (!p_psDBRunQuery(config->dbh, query)) { 1294 psError(PS_ERR_UNKNOWN, false, "database error");1295 psFree(query);1296 return false;1309 psError(PS_ERR_UNKNOWN, false, "database error"); 1310 psFree(query); 1311 return false; 1297 1312 } 1298 1313 psFree(query); … … 1300 1315 psArray *output = p_psDBFetchResult(config->dbh); 1301 1316 if (!output) { 1302 psError(PS_ERR_UNKNOWN, false, "database error");1303 return false;1317 psError(PS_ERR_UNKNOWN, false, "database error"); 1318 return false; 1304 1319 } 1305 1320 if (!psArrayLength(output)) { 1306 psTrace("chiptool", PS_LOG_INFO, "no rows found");1307 psFree(output);1308 return true;1321 psTrace("regtool", PS_LOG_INFO, "no rows found"); 1322 psFree(output); 1323 return true; 1309 1324 } 1310 1325 1311 1326 // we must write the export table in non-simple (true) format 1312 if (!ippdbPrintMetadatas(f, output, "chipRun", true)) {1313 psError(PS_ERR_UNKNOWN, false, "failed to print array");1314 psFree(output);1315 return false;1327 if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) { 1328 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1329 psFree(output); 1330 return false; 1316 1331 } 1317 1332 psFree(output); 1318 1319 // *** extract the chipProcessedImfile entries in this section *** 1320 query = pxDataGet("chiptool_export_imfiles.sql"); 1321 if (!query) { 1322 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1323 return false; 1324 } 1325 1326 if (where && psListLength(where->list)) { 1327 psString whereClause = psDBGenerateWhereSQL(where, NULL); 1328 psStringAppend(&query, " %s", whereClause); 1329 psFree(whereClause); 1330 } 1331 psFree(where); 1332 1333 // treat limit == 0 as "no limit" 1334 if (limit) { 1335 psString limitString = psDBGenerateLimitSQL(limit); 1336 psStringAppend(&query, " %s", limitString); 1337 psFree(limitString); 1338 } 1339 1340 if (!p_psDBRunQuery(config->dbh, query)) { 1341 psError(PS_ERR_UNKNOWN, false, "database error"); 1342 psFree(query); 1343 return false; 1344 } 1345 psFree(query); 1346 1347 output = p_psDBFetchResult(config->dbh); 1348 if (!output) { 1349 psError(PS_ERR_UNKNOWN, false, "database error"); 1350 return false; 1351 } 1352 if (!psArrayLength(output)) { 1353 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 1354 psFree(output); 1355 return true; 1356 } 1357 1358 // we must write the export table in non-simple (true) format 1359 if (!ippdbPrintMetadatas(f, output, "chipProcessedImfiles", true)) { 1360 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1361 psFree(output); 1362 return false; 1363 } 1364 psFree(output); 1365 1366 fclose (f); 1367 1368 return true; 1369 } 1370 1333 } 1334 1335 fclose (f); 1336 1337 return true; 1338 } 1371 1339 1372 1340 bool importrunMode(pxConfig *config) 1373 1341 { 1374 1342 unsigned int nFail; 1343 1344 int numImportTables = 2; 1345 1346 char tables[2] [80] = {"chipImfile", "chipProcessedImfile"}; 1375 1347 1376 1348 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 1383 1355 psMetadataPrint (stderr, input, 1); 1384 1356 1385 psMetadataItem *chipRunItem = psMetadataLookup (input, "chipRun"); 1386 psAssert (chipRunItem, "entry not in input?"); 1387 psAssert (chipRunItem->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1388 1389 psMetadataItem *chipRunEntry = psListGet (chipRunItem->data.list, 0); 1390 assert (chipRunEntry); 1391 assert (chipRunEntry->type == PS_DATA_METADATA); 1392 chipRunRow *chipRun = chipRunObjectFromMetadata (chipRunEntry->data.md); 1393 chipRunInsertObject (config->dbh, chipRun); 1394 1395 // fprintf (stdout, "---- chip run ----\n"); 1396 // psMetadataPrint (stderr, chipRunEntry->data.md, 1); 1397 1398 psMetadataItem *item = psMetadataLookup (input, "chipProcessedImfiles"); 1357 psMetadataItem *item = psMetadataLookup (input, "chipRun"); 1399 1358 psAssert (item, "entry not in input?"); 1400 1359 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1401 1360 1402 // XXX would be better to use the iterator? 1403 for (int i = 0; i < item->data.list->n; i++) { 1404 psMetadataItem *entry = psListGet (item->data.list, i); 1405 assert (entry); 1406 assert (entry->type == PS_DATA_METADATA); 1407 chipProcessedImfileRow *chipProcessedImfile = chipProcessedImfileObjectFromMetadata (entry->data.md); 1408 chipProcessedImfileInsertObject (config->dbh, chipProcessedImfile); 1409 1410 // fprintf (stdout, "---- row %d ----\n", i); 1411 // psMetadataPrint (stderr, entry->data.md, 1); 1361 psMetadataItem *entry = psListGet (item->data.list, 0); 1362 assert (entry); 1363 assert (entry->type == PS_DATA_METADATA); 1364 chipRunRow *chipRun = chipRunObjectFromMetadata (entry->data.md); 1365 chipRunInsertObject (config->dbh, chipRun); 1366 1367 // fprintf (stdout, "---- chip run ----\n"); 1368 // psMetadataPrint (stderr, entry->data.md, 1); 1369 1370 for (int i = 0; i < numImportTables; i++) { 1371 psMetadataItem *item = psMetadataLookup (input, tables[i]); 1372 psAssert (item, "entry not in input?"); 1373 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1374 1375 switch (i) { 1376 case 0: 1377 for (int i = 0; i < item->data.list->n; i++) { 1378 psMetadataItem *entry = psListGet (item->data.list, i); 1379 assert (entry); 1380 assert (entry->type == PS_DATA_METADATA); 1381 chipImfileRow *chipImfile = chipImfileObjectFromMetadata (entry->data.md); 1382 chipImfileInsertObject (config->dbh, chipImfile); 1383 1384 // fprintf (stdout, "---- row %d ----\n", i); 1385 // psMetadataPrint (stderr, entry->data.md, 1); 1386 } 1387 break; 1388 1389 case 1: 1390 for (int i = 0; i < item->data.list->n; i++) { 1391 psMetadataItem *entry = psListGet (item->data.list, i); 1392 assert (entry); 1393 assert (entry->type == PS_DATA_METADATA); 1394 chipProcessedImfileRow *chipProcessedImfile = chipProcessedImfileObjectFromMetadata (entry->data.md); 1395 chipProcessedImfileInsertObject (config->dbh, chipProcessedImfile); 1396 1397 // fprintf (stdout, "---- row %d ----\n", i); 1398 // psMetadataPrint (stderr, entry->data.md, 1); 1399 } 1400 break; 1401 } 1412 1402 } 1413 1403 -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/chiptool.h
r21521 r23352 32 32 CHIPTOOL_MODE_REVERTPROCESSEDIMFILE, 33 33 CHIPTOOL_MODE_UPDATEPROCESSEDIMFILE, 34 CHIPTOOL_MODE_ PROMOTEEXP,34 CHIPTOOL_MODE_ADVANCEEXP, 35 35 CHIPTOOL_MODE_BLOCK, 36 36 CHIPTOOL_MODE_MASKED, -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/chiptoolConfig.c
r21521 r23352 67 67 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-chip_id", 0, "search by chip ID", 0); 68 68 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "set state", NULL); 69 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL); 69 70 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); 70 71 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "set label", NULL); 71 72 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 72 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL);73 73 74 74 // -pendingimfile … … 176 176 psMetadataAddS16(updateprocessedimfileArgs, PS_LIST_TAIL, "-code", 0, "set fault code (required)", 0); 177 177 178 // - promoteexp179 psMetadata * promoteexpArgs = psMetadataAlloc();180 psMetadataAddS64( promoteexpArgs, PS_LIST_TAIL, "-chip_id", 0, "search by chip ID", 0);181 psMetadataAddStr( promoteexpArgs, PS_LIST_TAIL, "-label", 0, "promote exposures for specified label", NULL);182 psMetadataAddU64( promoteexpArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);178 // -advanceexp 179 psMetadata *advanceexpArgs = psMetadataAlloc(); 180 psMetadataAddS64(advanceexpArgs, PS_LIST_TAIL, "-chip_id", 0, "search by chip ID", 0); 181 psMetadataAddStr(advanceexpArgs, PS_LIST_TAIL, "-label", 0, "advance exposures for specified label", NULL); 182 psMetadataAddU64(advanceexpArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 183 183 184 184 // -block … … 265 265 PXOPT_ADD_MODE("-updateprocessedimfile","change procesed imfile properties", CHIPTOOL_MODE_UPDATEPROCESSEDIMFILE,updateprocessedimfileArgs); 266 266 PXOPT_ADD_MODE("-revertprocessedimfile","undo a processed imfile", CHIPTOOL_MODE_REVERTPROCESSEDIMFILE,revertprocessedimfileArgs); 267 PXOPT_ADD_MODE("- promoteexp", "promote completed exposures", CHIPTOOL_MODE_PROMOTEEXP, promoteexpArgs);267 PXOPT_ADD_MODE("-advanceexp", "advance completed exposures", CHIPTOOL_MODE_ADVANCEEXP, advanceexpArgs); 268 268 PXOPT_ADD_MODE("-block", "set a label block", CHIPTOOL_MODE_BLOCK, blockArgs); 269 269 PXOPT_ADD_MODE("-masked", "show blocked labels", CHIPTOOL_MODE_MASKED, maskedArgs); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/dettool.c
r21402 r23352 28 28 static bool inputMode(pxConfig *config); 29 29 static bool rawMode(pxConfig *config); 30 static bool exportrunMode(pxConfig *config); 31 static bool importrunMode(pxConfig *config); 30 32 31 33 // run … … 46 48 } \ 47 49 break; 48 50 /* 51 typedef struct ExportTable { 52 char tableName[80]; 53 char sqlFilename[80]; 54 } ExportTable; 55 */ 49 56 int main(int argc, char **argv) 50 57 { … … 146 153 MODECASE(DETTOOL_MODE_REGISTER_DETREND, register_detrendMode); 147 154 MODECASE(DETTOOL_MODE_REGISTER_DETREND_IMFILE, register_detrend_imfileMode); 155 MODECASE(DETTOOL_MODE_EXPORTRUN, exportrunMode); 156 MODECASE(DETTOOL_MODE_IMPORTRUN, importrunMode); 148 157 default: 149 158 psAbort("invalid option (this should not happen)"); … … 578 587 // generate a random-valued vector, return an index sorted by the random values 579 588 psVector *randomVector = psVectorAlloc(detrendExps->n, PS_TYPE_F32); // random values 580 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); 589 /* 590 * change due to PAP work on random number generator? 591 * psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); 592 */ 593 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 581 594 for (int i = 0; i < randomVector->n; i++) { 582 595 randomVector->data.F32[i] = psRandomUniform(rng); … … 1996 2009 } 1997 2010 2011 bool exportrunMode(pxConfig *config) 2012 { 2013 typedef struct ExportTable { 2014 char tableName[80]; 2015 char sqlFilename[80]; 2016 } ExportTable; 2017 2018 int numExportTables = 12; 2019 2020 PS_ASSERT_PTR_NON_NULL(config, NULL); 2021 2022 PXOPT_LOOKUP_S64(det_id, config->args, "-det_id", true, false); 2023 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 2024 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 2025 2026 FILE *f = fopen (outfile, "w"); 2027 if (f == NULL) { 2028 psError(PS_ERR_UNKNOWN, false, "failed to open output file"); 2029 return false; 2030 } 2031 2032 psMetadata *where = psMetadataAlloc(); 2033 PXOPT_COPY_S64(config->args, where, "-det_id", "det_id", "=="); 2034 2035 ExportTable tables [] = { 2036 {"detInputExp", "dettool_export_input_exp.sql"}, 2037 {"detNormalizedExp", "dettool_export_normalized_exp.sql"}, 2038 {"detNormalizedImfile", "dettool_export_normalized_imfile.sql"}, 2039 {"detNormalizedStatImfile", "dettool_export_normalized_stat_imfile.sql"}, 2040 {"detProcessedExp", "dettool_export_processed_exp.sql"}, 2041 {"detProcessedImfile", "dettool_export_processed_imfile.sql"}, 2042 {"detRegisteredImfile", "dettool_export_registered_imfile.sql"}, 2043 {"detResidExp", "dettool_export_resid_exp.sql"}, 2044 {"detResidImfile", "dettool_export_resid_imfile.sql"}, 2045 {"detRun", "dettool_export_run.sql"}, 2046 {"detRunSummary", "dettool_export_run_summary.sql"}, 2047 {"detStackedImfile", "dettool_export_stacked_imfile.sql"}, 2048 }; 2049 2050 for (int i=0; i < numExportTables; i++) { 2051 psString query = pxDataGet(tables[i].sqlFilename); 2052 if (!query) { 2053 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 2054 return false; 2055 } 2056 2057 if (where && psListLength(where->list)) { 2058 psString whereClause = psDBGenerateWhereSQL(where, NULL); 2059 psStringAppend(&query, " %s", whereClause); 2060 psFree(whereClause); 2061 } 2062 2063 // treat limit == 0 as "no limit" 2064 if (limit) { 2065 psString limitString = psDBGenerateLimitSQL(limit); 2066 psStringAppend(&query, " %s", limitString); 2067 psFree(limitString); 2068 } 2069 2070 if (!p_psDBRunQuery(config->dbh, query)) { 2071 psError(PS_ERR_UNKNOWN, false, "database error"); 2072 psFree(query); 2073 return false; 2074 } 2075 psFree(query); 2076 2077 psArray *output = p_psDBFetchResult(config->dbh); 2078 if (!output) { 2079 psError(PS_ERR_UNKNOWN, false, "database error"); 2080 return false; 2081 } 2082 if (!psArrayLength(output)) { 2083 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 2084 psFree(output); 2085 return true; 2086 } 2087 2088 // we must write the export table in non-simple (true) format 2089 if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) { 2090 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 2091 psFree(output); 2092 return false; 2093 } 2094 psFree(output); 2095 2096 } 2097 2098 fclose (f); 2099 2100 return true; 2101 } 2102 2103 bool importrunMode(pxConfig *config) 2104 { 2105 unsigned int nFail; 2106 2107 int numImportTables = 11; 2108 2109 char tables[11] [80] = {"detInputExp", "detNormalizedExp", 2110 "detNormalizedStatImfile", "detProcessedExp", "detProcessedImfile", 2111 "detRegisteredImfile", "detResidExp", "detResidImfile", 2112 "detNormalizedImfile", "detRunSummary", "detStackedImfile"}; 2113 2114 PS_ASSERT_PTR_NON_NULL(config, NULL); 2115 2116 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 2117 2118 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 2119 2120 fprintf (stdout, "---- input ----\n"); 2121 psMetadataPrint (stderr, input, 1); 2122 2123 psMetadataItem *item = psMetadataLookup (input, "detRun"); 2124 psAssert (item, "entry not in input?"); 2125 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 2126 2127 psMetadataItem *entry = psListGet (item->data.list, 0); 2128 assert (entry); 2129 assert (entry->type == PS_DATA_METADATA); 2130 detRunRow *detRun = detRunObjectFromMetadata (entry->data.md); 2131 detRunInsertObject (config->dbh, detRun); 2132 2133 // fprintf (stdout, "---- det run ----\n"); 2134 // psMetadataPrint (stderr, entry->data.md, 1); 2135 2136 for (int i = 0; i < numImportTables; i++) { 2137 item = psMetadataLookup (input, tables[i]); 2138 psAssert (item, "entry not in input?"); 2139 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 2140 2141 switch (i) { 2142 case 0: 2143 for (int i = 0; i < item->data.list->n; i++) { 2144 entry = psListGet (item->data.list, i); 2145 assert (entry); 2146 assert (entry->type == PS_DATA_METADATA); 2147 detInputExpRow *detInputExp = detInputExpObjectFromMetadata (entry->data.md); 2148 detInputExpInsertObject (config->dbh, detInputExp); 2149 2150 // fprintf (stdout, "---- row %d ----\n", i); 2151 // psMetadataPrint (stderr, entry->data.md, 1); 2152 } 2153 break; 2154 2155 case 1: 2156 for (int i = 0; i < item->data.list->n; i++) { 2157 entry = psListGet (item->data.list, i); 2158 assert (entry); 2159 assert (entry->type == PS_DATA_METADATA); 2160 detNormalizedExpRow *detNormalizedExp = detNormalizedExpObjectFromMetadata (entry->data.md); 2161 detNormalizedExpInsertObject (config->dbh, detNormalizedExp); 2162 2163 // fprintf (stdout, "---- row %d ----\n", i); 2164 // psMetadataPrint (stderr, entry->data.md, 1); 2165 } 2166 break; 2167 2168 case 2: 2169 for (int i = 0; i < item->data.list->n; i++) { 2170 entry = psListGet (item->data.list, i); 2171 assert (entry); 2172 assert (entry->type == PS_DATA_METADATA); 2173 detNormalizedStatImfileRow *detNormalizedStatImfile = detNormalizedStatImfileObjectFromMetadata (entry->data.md); 2174 detNormalizedStatImfileInsertObject (config->dbh, detNormalizedStatImfile); 2175 2176 // fprintf (stdout, "---- row %d ----\n", i); 2177 // psMetadataPrint (stderr, entry->data.md, 1); 2178 } 2179 break; 2180 2181 case 3: 2182 for (int i = 0; i < item->data.list->n; i++) { 2183 entry = psListGet (item->data.list, i); 2184 assert (entry); 2185 assert (entry->type == PS_DATA_METADATA); 2186 detProcessedExpRow *detProcessedExp = detProcessedExpObjectFromMetadata (entry->data.md); 2187 detProcessedExpInsertObject (config->dbh, detProcessedExp); 2188 2189 // fprintf (stdout, "---- row %d ----\n", i); 2190 // psMetadataPrint (stderr, entry->data.md, 1); 2191 } 2192 break; 2193 2194 case 4: 2195 for (int i = 0; i < item->data.list->n; i++) { 2196 entry = psListGet (item->data.list, i); 2197 assert (entry); 2198 assert (entry->type == PS_DATA_METADATA); 2199 detProcessedImfileRow *detProcessedImfile = detProcessedImfileObjectFromMetadata (entry->data.md); 2200 detProcessedImfileInsertObject (config->dbh, detProcessedImfile); 2201 2202 // fprintf (stdout, "---- row %d ----\n", i); 2203 // psMetadataPrint (stderr, entry->data.md, 1); 2204 } 2205 break; 2206 2207 case 5: 2208 for (int i = 0; i < item->data.list->n; i++) { 2209 entry = psListGet (item->data.list, i); 2210 assert (entry); 2211 assert (entry->type == PS_DATA_METADATA); 2212 detRegisteredImfileRow *detRegisteredImfile = detRegisteredImfileObjectFromMetadata (entry->data.md); 2213 detRegisteredImfileInsertObject (config->dbh, detRegisteredImfile); 2214 2215 // fprintf (stdout, "---- row %d ----\n", i); 2216 // psMetadataPrint (stderr, entry->data.md, 1); 2217 } 2218 break; 2219 2220 case 6: 2221 for (int i = 0; i < item->data.list->n; i++) { 2222 entry = psListGet (item->data.list, i); 2223 assert (entry); 2224 assert (entry->type == PS_DATA_METADATA); 2225 detResidExpRow *detResidExp = detResidExpObjectFromMetadata (entry->data.md); 2226 detResidExpInsertObject (config->dbh, detResidExp); 2227 2228 // fprintf (stdout, "---- row %d ----\n", i); 2229 // psMetadataPrint (stderr, entry->data.md, 1); 2230 } 2231 break; 2232 2233 case 7: 2234 for (int i = 0; i < item->data.list->n; i++) { 2235 entry = psListGet (item->data.list, i); 2236 assert (entry); 2237 assert (entry->type == PS_DATA_METADATA); 2238 detResidImfileRow *detResidImfile = detResidImfileObjectFromMetadata (entry->data.md); 2239 detResidImfileInsertObject (config->dbh, detResidImfile); 2240 2241 // fprintf (stdout, "---- row %d ----\n", i); 2242 // psMetadataPrint (stderr, entry->data.md, 1); 2243 } 2244 break; 2245 2246 case 8: 2247 for (int i = 0; i < item->data.list->n; i++) { 2248 entry = psListGet (item->data.list, i); 2249 assert (entry); 2250 assert (entry->type == PS_DATA_METADATA); 2251 detNormalizedImfileRow *detNormalizedImfile = detNormalizedImfileObjectFromMetadata (entry->data.md); 2252 detNormalizedImfileInsertObject (config->dbh, detNormalizedImfile); 2253 2254 // fprintf (stdout, "---- row %d ----\n", i); 2255 // psMetadataPrint (stderr, entry->data.md, 1); 2256 } 2257 break; 2258 2259 case 9: 2260 for (int i = 0; i < item->data.list->n; i++) { 2261 entry = psListGet (item->data.list, i); 2262 assert (entry); 2263 assert (entry->type == PS_DATA_METADATA); 2264 detRunSummaryRow *detRunSummary = detRunSummaryObjectFromMetadata (entry->data.md); 2265 detRunSummaryInsertObject (config->dbh, detRunSummary); 2266 2267 // fprintf (stdout, "---- row %d ----\n", i); 2268 // psMetadataPrint (stderr, entry->data.md, 1); 2269 } 2270 break; 2271 2272 case 10: 2273 for (int i = 0; i < item->data.list->n; i++) { 2274 entry = psListGet (item->data.list, i); 2275 assert (entry); 2276 assert (entry->type == PS_DATA_METADATA); 2277 detStackedImfileRow *detStackedImfile = detStackedImfileObjectFromMetadata (entry->data.md); 2278 detStackedImfileInsertObject (config->dbh, detStackedImfile); 2279 2280 // fprintf (stdout, "---- row %d ----\n", i); 2281 // psMetadataPrint (stderr, entry->data.md, 1); 2282 } 2283 break; 2284 } 2285 } 2286 2287 return true; 2288 } 2289 1998 2290 #if 0 1999 2291 // XXX this function was left in commented as this method may be useful in the -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/dettool.h
r19814 r23352 114 114 DETTOOL_MODE_RERUN, 115 115 DETTOOL_MODE_REGISTER_DETREND, 116 DETTOOL_MODE_REGISTER_DETREND_IMFILE 116 DETTOOL_MODE_REGISTER_DETREND_IMFILE, 117 118 DETTOOL_MODE_EXPORTRUN, 119 DETTOOL_MODE_IMPORTRUN 117 120 } dettoolMode; 118 121 -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/dettoolConfig.c
r20375 r23352 648 648 psMetadataAddBool(residimfileArgs, PS_LIST_TAIL, "-faulted", 0, "only return imfiles with a fault status set", false); 649 649 psMetadataAddBool(residimfileArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 650 psMetadataAddBool(residimfileArgs, PS_LIST_TAIL, "-included", 0, "use only files included in ths detrun", false); 651 // XXX is this option used? 650 652 psMetadataAddStr(residimfileArgs, PS_LIST_TAIL, "-select_state", 0, "search for state", NULL); 651 653 … … 855 857 psMetadataAddStr(register_detrend_imfileArgs, PS_LIST_TAIL, "-path_base", 0, "define base output location", NULL); 856 858 859 // -exportrun 860 psMetadata *exportrunArgs = psMetadataAlloc(); 861 psMetadataAddS64(exportrunArgs, PS_LIST_TAIL, "-det_id", 0, "export this detrend ID (required)", 0); 862 psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0, "export to this file (required)", NULL); 863 psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 864 865 // -importrun 866 psMetadata *importrunArgs = psMetadataAlloc(); 867 psMetadataAddStr(importrunArgs, PS_LIST_TAIL, "-infile", 0, "import from this file (required)", NULL); 868 869 857 870 psFree(now); 858 871 … … 947 960 PXOPT_ADD_MODE("-register_detrend", "", DETTOOL_MODE_REGISTER_DETREND, register_detrendArgs); 948 961 PXOPT_ADD_MODE("-register_detrend_imfile", "", DETTOOL_MODE_REGISTER_DETREND_IMFILE, register_detrend_imfileArgs); 962 PXOPT_ADD_MODE("-exportrun", "export run for import on other database", DETTOOL_MODE_EXPORTRUN, exportrunArgs); 963 PXOPT_ADD_MODE("-importrun", "import run from metadata file", DETTOOL_MODE_IMPORTRUN, importrunArgs); 949 964 950 965 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/dettool_processedimfile.c
r19621 r23352 165 165 PS_ASSERT_PTR_NON_NULL(config, false); 166 166 167 bool hasWhere = false;168 169 PXOPT_LOOKUP_BOOL(included, config->args, "-included", false);170 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);171 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);172 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);173 174 167 psMetadata *where = psMetadataAlloc(); 175 168 PXOPT_COPY_S64(config->args, where, "-det_id", "detProcessedImfile.det_id", "=="); … … 179 172 PXOPT_COPY_STR(config->args, where, "-select_mode", "detRun.mode", "=="); 180 173 174 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 175 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 176 177 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 178 PXOPT_LOOKUP_BOOL(included, config->args, "-included", false); 179 181 180 psString query = pxDataGet("dettool_processedimfile.sql"); 182 181 if (!query) { … … 186 185 } 187 186 187 bool hasWhere = false; 188 188 if (psListLength(where->list)) { 189 189 psString whereClause = psDBGenerateWhereSQL(where, NULL); … … 211 211 212 212 if (faulted) { 213 // list only faulted rows 213 214 psStringAppend(&query, " %s", " detProcessedImfile.fault != 0"); 214 215 } else { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/dettool_residimfile.c
r19632 r23352 159 159 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 160 160 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 161 161 162 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 163 PXOPT_LOOKUP_BOOL(included, config->args, "-included", false); 162 164 163 165 psString query = pxDataGet("dettool_residimfile.sql"); … … 175 177 } 176 178 psFree(where); 179 180 // restrict search to included imfiles 181 if (included) { 182 if (hasWhere) { 183 psStringAppend(&query, " AND detInputExp.include = 1"); 184 } else { 185 psStringAppend(&query, " WHERE detInputExp.include = 1"); 186 } 187 hasWhere = true; 188 } 177 189 178 190 if (hasWhere) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/difftool.c
r21402 r23352 45 45 static bool donecleanupMode(pxConfig *config); 46 46 static bool updatediffskyfileMode(pxConfig *config); 47 static bool exportrunMode(pxConfig *config); 48 static bool importrunMode(pxConfig *config); 47 49 48 50 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state); … … 81 83 MODECASE(DIFFTOOL_MODE_DONECLEANUP, donecleanupMode); 82 84 MODECASE(DIFFTOOL_MODE_UPDATEDIFFSKYFILE, updatediffskyfileMode); 85 MODECASE(DIFFTOOL_MODE_EXPORTRUN, exportrunMode); 86 MODECASE(DIFFTOOL_MODE_IMPORTRUN, importrunMode); 83 87 default: 84 88 psAbort("invalid option (this should not happen)"); … … 1437 1441 } 1438 1442 1443 bool exportrunMode(pxConfig *config) 1444 { 1445 typedef struct ExportTable { 1446 char tableName[80]; 1447 char sqlFilename[80]; 1448 } ExportTable; 1449 1450 int numExportFiles = 3; 1451 1452 PS_ASSERT_PTR_NON_NULL(config, NULL); 1453 1454 PXOPT_LOOKUP_S64(det_id, config->args, "-diff_id", true, false); 1455 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 1456 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1457 1458 FILE *f = fopen (outfile, "w"); 1459 if (f == NULL) { 1460 psError(PS_ERR_UNKNOWN, false, "failed to open output file"); 1461 return false; 1462 } 1463 1464 psMetadata *where = psMetadataAlloc(); 1465 PXOPT_COPY_S64(config->args, where, "-diff_id", "diff_id", "=="); 1466 1467 ExportTable tables [] = { 1468 {"diffRun", "difftool_export_run.sql"}, 1469 {"diffInputSkyfile", "difftool_export_input_skyfile.sql"}, 1470 {"diffSkyfile", "difftool_export_skyfile.sql"}, 1471 }; 1472 1473 for (int i=0; i < numExportFiles; i++) { 1474 psString query = pxDataGet(tables[i].sqlFilename); 1475 if (!query) { 1476 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1477 return false; 1478 } 1479 1480 if (where && psListLength(where->list)) { 1481 psString whereClause = psDBGenerateWhereSQL(where, NULL); 1482 psStringAppend(&query, " %s", whereClause); 1483 psFree(whereClause); 1484 } 1485 1486 // treat limit == 0 as "no limit" 1487 if (limit) { 1488 psString limitString = psDBGenerateLimitSQL(limit); 1489 psStringAppend(&query, " %s", limitString); 1490 psFree(limitString); 1491 } 1492 1493 if (!p_psDBRunQuery(config->dbh, query)) { 1494 psError(PS_ERR_UNKNOWN, false, "database error"); 1495 psFree(query); 1496 return false; 1497 } 1498 psFree(query); 1499 1500 psArray *output = p_psDBFetchResult(config->dbh); 1501 if (!output) { 1502 psError(PS_ERR_UNKNOWN, false, "database error"); 1503 return false; 1504 } 1505 if (!psArrayLength(output)) { 1506 psTrace("regtool", PS_LOG_INFO, "no rows found"); 1507 psFree(output); 1508 return true; 1509 } 1510 1511 // we must write the export table in non-simple (true) format 1512 if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) { 1513 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1514 psFree(output); 1515 return false; 1516 } 1517 psFree(output); 1518 } 1519 1520 fclose (f); 1521 1522 return true; 1523 } 1524 1525 bool importrunMode(pxConfig *config) 1526 { 1527 unsigned int nFail; 1528 1529 int numImportTables = 2; 1530 1531 char tables[2] [80] = {"diffInputSkyfile", "diffSkyfile"}; 1532 1533 PS_ASSERT_PTR_NON_NULL(config, NULL); 1534 1535 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 1536 1537 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1538 1539 fprintf (stdout, "---- input ----\n"); 1540 psMetadataPrint (stderr, input, 1); 1541 1542 psMetadataItem *item = psMetadataLookup (input, "diffRun"); 1543 psAssert (item, "entry not in input?"); 1544 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1545 1546 psMetadataItem *entry = psListGet (item->data.list, 0); 1547 assert (entry); 1548 assert (entry->type == PS_DATA_METADATA); 1549 diffRunRow *diffRun = diffRunObjectFromMetadata (entry->data.md); 1550 diffRunInsertObject (config->dbh, diffRun); 1551 1552 // fprintf (stdout, "---- diff run ----\n"); 1553 // psMetadataPrint (stderr, entry->data.md, 1); 1554 1555 for (int i = 0; i < numImportTables; i++) { 1556 item = psMetadataLookup (input, tables[i]); 1557 psAssert (item, "entry not in input?"); 1558 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1559 1560 switch (i) { 1561 case 0: 1562 for (int i = 0; i < item->data.list->n; i++) { 1563 entry = psListGet (item->data.list, i); 1564 assert (entry); 1565 assert (entry->type == PS_DATA_METADATA); 1566 diffInputSkyfileRow *diffInputSkyfile = diffInputSkyfileObjectFromMetadata (entry->data.md); 1567 diffInputSkyfileInsertObject (config->dbh, diffInputSkyfile); 1568 1569 // fprintf (stdout, "---- row %d ----\n", i); 1570 // psMetadataPrint (stderr, entry->data.md, 1); 1571 } 1572 break; 1573 1574 case 1: 1575 for (int i = 0; i < item->data.list->n; i++) { 1576 entry = psListGet (item->data.list, i); 1577 assert (entry); 1578 assert (entry->type == PS_DATA_METADATA); 1579 diffSkyfileRow *diffSkyfile = diffSkyfileObjectFromMetadata (entry->data.md); 1580 diffSkyfileInsertObject (config->dbh, diffSkyfile); 1581 1582 // fprintf (stdout, "---- row %d ----\n", i); 1583 // psMetadataPrint (stderr, entry->data.md, 1); 1584 } 1585 break; 1586 } 1587 } 1588 1589 return true; 1590 } -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/difftool.h
r19677 r23352 39 39 DIFFTOOL_MODE_DONECLEANUP, 40 40 DIFFTOOL_MODE_UPDATEDIFFSKYFILE, 41 DIFFTOOL_MODE_EXPORTRUN, 42 DIFFTOOL_MODE_IMPORTRUN 41 43 } difftoolMode; 42 44 -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/difftoolConfig.c
r21308 r23352 187 187 psMetadataAddS16(updatediffskyfileArgs, PS_LIST_TAIL, "-code", 0, "set fault code (required)", 0); 188 188 189 // -exportrun 190 psMetadata *exportrunArgs = psMetadataAlloc(); 191 psMetadataAddS64(exportrunArgs, PS_LIST_TAIL, "-diff_id", 0, "export this diff ID (required)", 0); 192 psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0, "export to this file (required)", NULL); 193 psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 194 195 // -importrun 196 psMetadata *importrunArgs = psMetadataAlloc(); 197 psMetadataAddStr(importrunArgs, PS_LIST_TAIL, "-infile", 0, "import from this file (required)", NULL); 198 199 189 200 190 201 psFree(now); … … 207 218 PXOPT_ADD_MODE("-donecleanup", "show runs that have been cleaned", DIFFTOOL_MODE_DONECLEANUP, donecleanupArgs); 208 219 PXOPT_ADD_MODE("-updatediffskyfile", "update fault code for a diffskyfile", DIFFTOOL_MODE_UPDATEDIFFSKYFILE, updatediffskyfileArgs); 220 PXOPT_ADD_MODE("-exportrun", "export run for import on other database", DIFFTOOL_MODE_EXPORTRUN, exportrunArgs); 221 PXOPT_ADD_MODE("-importrun", "import run from metadata file", DIFFTOOL_MODE_IMPORTRUN, importrunArgs); 209 222 210 223 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/faketool.c
r21463 r23352 41 41 static bool revertprocessedimfileMode(pxConfig *config); 42 42 static bool updateprocessedimfileMode(pxConfig *config); 43 static bool promoteexpMode(pxConfig *config);43 static bool advanceexpMode(pxConfig *config); 44 44 static bool blockMode(pxConfig *config); 45 45 static bool maskedMode(pxConfig *config); … … 52 52 static bool tofullimfileMode(pxConfig *config); 53 53 static bool topurgedimfileMode(pxConfig *config); 54 static bool exportrunMode(pxConfig *config); 55 static bool importrunMode(pxConfig *config); 54 56 55 57 # define MODECASE(caseName, func) \ … … 78 80 MODECASE(FAKETOOL_MODE_REVERTPROCESSEDIMFILE, revertprocessedimfileMode); 79 81 MODECASE(FAKETOOL_MODE_UPDATEPROCESSEDIMFILE, updateprocessedimfileMode); 80 MODECASE(FAKETOOL_MODE_ PROMOTEEXP, promoteexpMode);82 MODECASE(FAKETOOL_MODE_ADVANCEEXP, advanceexpMode); 81 83 MODECASE(FAKETOOL_MODE_BLOCK, blockMode); 82 84 MODECASE(FAKETOOL_MODE_MASKED, maskedMode); … … 89 91 MODECASE(FAKETOOL_MODE_TOFULLIMFILE, tofullimfileMode); 90 92 MODECASE(FAKETOOL_MODE_TOPURGEDIMFILE, topurgedimfileMode); 93 MODECASE(FAKETOOL_MODE_EXPORTRUN, exportrunMode); 94 MODECASE(FAKETOOL_MODE_IMPORTRUN, importrunMode); 91 95 92 96 default: … … 1048 1052 } 1049 1053 1050 static bool promoteexpMode(pxConfig *config)1054 static bool advanceexpMode(pxConfig *config) 1051 1055 { 1052 1056 PS_ASSERT_PTR_NON_NULL(config, false); … … 1225 1229 return change_imfile_data_state(config, "purged", "goto_purged"); 1226 1230 } 1231 1232 bool exportrunMode(pxConfig *config) 1233 { 1234 typedef struct ExportTable { 1235 char tableName[80]; 1236 char sqlFilename[80]; 1237 } ExportTable; 1238 1239 int numExportTables = 2; 1240 1241 PS_ASSERT_PTR_NON_NULL(config, NULL); 1242 1243 PXOPT_LOOKUP_S64(det_id, config->args, "-fake_id", true, false); 1244 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 1245 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1246 1247 FILE *f = fopen (outfile, "w"); 1248 if (f == NULL) { 1249 psError(PS_ERR_UNKNOWN, false, "failed to open output file"); 1250 return false; 1251 } 1252 1253 psMetadata *where = psMetadataAlloc(); 1254 PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "=="); 1255 1256 ExportTable tables [] = { 1257 {"fakeRun", "faketool_export_run.sql"}, 1258 {"fakeProcessedImfile", "faketool_export_processed_imfile.sql"}, 1259 }; 1260 1261 for (int i=0; i < numExportTables; i++) { 1262 psString query = pxDataGet(tables[i].sqlFilename); 1263 if (!query) { 1264 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1265 return false; 1266 } 1267 1268 if (where && psListLength(where->list)) { 1269 psString whereClause = psDBGenerateWhereSQL(where, NULL); 1270 psStringAppend(&query, " %s", whereClause); 1271 psFree(whereClause); 1272 } 1273 1274 // treat limit == 0 as "no limit" 1275 if (limit) { 1276 psString limitString = psDBGenerateLimitSQL(limit); 1277 psStringAppend(&query, " %s", limitString); 1278 psFree(limitString); 1279 } 1280 1281 if (!p_psDBRunQuery(config->dbh, query)) { 1282 psError(PS_ERR_UNKNOWN, false, "database error"); 1283 psFree(query); 1284 return false; 1285 } 1286 psFree(query); 1287 1288 psArray *output = p_psDBFetchResult(config->dbh); 1289 if (!output) { 1290 psError(PS_ERR_UNKNOWN, false, "database error"); 1291 return false; 1292 } 1293 if (!psArrayLength(output)) { 1294 psTrace("regtool", PS_LOG_INFO, "no rows found"); 1295 psFree(output); 1296 return true; 1297 } 1298 1299 // we must write the export table in non-simple (true) format 1300 if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) { 1301 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1302 psFree(output); 1303 return false; 1304 } 1305 psFree(output); 1306 } 1307 1308 fclose (f); 1309 1310 return true; 1311 } 1312 1313 bool importrunMode(pxConfig *config) 1314 { 1315 unsigned int nFail; 1316 1317 PS_ASSERT_PTR_NON_NULL(config, NULL); 1318 1319 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 1320 1321 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1322 1323 fprintf (stdout, "---- input ----\n"); 1324 psMetadataPrint (stderr, input, 1); 1325 1326 psMetadataItem *item = psMetadataLookup (input, "fakeRun"); 1327 psAssert (item, "entry not in input?"); 1328 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1329 1330 psMetadataItem *entry = psListGet (item->data.list, 0); 1331 assert (entry); 1332 assert (entry->type == PS_DATA_METADATA); 1333 fakeRunRow *fakeRun = fakeRunObjectFromMetadata (entry->data.md); 1334 fakeRunInsertObject (config->dbh, fakeRun); 1335 1336 // fprintf (stdout, "---- fake run ----\n"); 1337 // psMetadataPrint (stderr, entry->data.md, 1); 1338 1339 item = psMetadataLookup (input, "fakeProcessedImfile"); 1340 psAssert (item, "entry not in input?"); 1341 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1342 1343 for (int i = 0; i < item->data.list->n; i++) { 1344 psMetadataItem *entry = psListGet (item->data.list, i); 1345 assert (entry); 1346 assert (entry->type == PS_DATA_METADATA); 1347 fakeProcessedImfileRow *fakeProcessedImfile = fakeProcessedImfileObjectFromMetadata (entry->data.md); 1348 fakeProcessedImfileInsertObject (config->dbh, fakeProcessedImfile); 1349 1350 // fprintf (stdout, "---- row %d ----\n", i); 1351 // psMetadataPrint (stderr, entry->data.md, 1); 1352 } 1353 1354 return true; 1355 } -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/faketool.h
r21463 r23352 33 33 FAKETOOL_MODE_REVERTPROCESSEDIMFILE, 34 34 FAKETOOL_MODE_UPDATEPROCESSEDIMFILE, 35 FAKETOOL_MODE_ PROMOTEEXP,35 FAKETOOL_MODE_ADVANCEEXP, 36 36 FAKETOOL_MODE_BLOCK, 37 37 FAKETOOL_MODE_MASKED, … … 45 45 FAKETOOL_MODE_TOFULLIMFILE, 46 46 FAKETOOL_MODE_TOPURGEDIMFILE, 47 FAKETOOL_MODE_EXPORTRUN, 48 FAKETOOL_MODE_IMPORTRUN 47 49 } FAKETOOLMode; 48 50 -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/faketoolConfig.c
r21463 r23352 242 242 243 243 244 // - promoteexp245 psMetadata * promoteexpArgs = psMetadataAlloc();246 psMetadataAddS64( promoteexpArgs, PS_LIST_TAIL, "-fake_id", 0, "search by fake ID", 0);247 psMetadataAddStr( promoteexpArgs, PS_LIST_TAIL, "-label", 0, "search by label ", NULL);248 psMetadataAddU64( promoteexpArgs, PS_LIST_TAIL, "-limit", 0, "limit exposures to promote to N items", 0);244 // -advanceexp 245 psMetadata *advanceexpArgs = psMetadataAlloc(); 246 psMetadataAddS64(advanceexpArgs, PS_LIST_TAIL, "-fake_id", 0, "search by fake ID", 0); 247 psMetadataAddStr(advanceexpArgs, PS_LIST_TAIL, "-label", 0, "search by label ", NULL); 248 psMetadataAddU64(advanceexpArgs, PS_LIST_TAIL, "-limit", 0, "limit exposures to advance to N items", 0); 249 249 250 250 // -block … … 301 301 psMetadataAddStr(topurgedimfileArgs, PS_LIST_TAIL, "-class_id", 0, "class ID to update", NULL); 302 302 303 // -exportrun 304 psMetadata *exportrunArgs = psMetadataAlloc(); 305 psMetadataAddS64(exportrunArgs, PS_LIST_TAIL, "-fake_id", 0, "export this fake ID (required)", 0); 306 psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0, "export to this file (required)", NULL); 307 psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 308 309 // -importrun 310 psMetadata *importrunArgs = psMetadataAlloc(); 311 psMetadataAddStr(importrunArgs, PS_LIST_TAIL, "-infile", 0, "import from this file (required)", NULL); 312 313 303 314 304 315 … … 314 325 PXOPT_ADD_MODE("-updateprocessedimfile","change procesed imfile properties", FAKETOOL_MODE_UPDATEPROCESSEDIMFILE, updateprocessedimfileArgs); 315 326 PXOPT_ADD_MODE("-revertprocessedimfile", "undo a processed imfile", FAKETOOL_MODE_REVERTPROCESSEDIMFILE, revertprocessedimfileArgs); 316 PXOPT_ADD_MODE("- promoteexp", "promote completed exposoures", FAKETOOL_MODE_PROMOTEEXP, promoteexpArgs);327 PXOPT_ADD_MODE("-advanceexp", "advance completed exposoures", FAKETOOL_MODE_ADVANCEEXP, advanceexpArgs); 317 328 PXOPT_ADD_MODE("-block", "set a label block", FAKETOOL_MODE_BLOCK, blockArgs); 318 329 PXOPT_ADD_MODE("-masked", "show blocked labels", FAKETOOL_MODE_MASKED, maskedArgs); … … 325 336 PXOPT_ADD_MODE("-tofullimfile", "set imfile state to full", FAKETOOL_MODE_TOFULLIMFILE, tofullimfileArgs); 326 337 PXOPT_ADD_MODE("-topurgedimfile", "set imfile state to purged", FAKETOOL_MODE_TOPURGEDIMFILE, topurgedimfileArgs); 338 PXOPT_ADD_MODE("-exportrun", "export run for import on other database", FAKETOOL_MODE_EXPORTRUN, exportrunArgs); 339 PXOPT_ADD_MODE("-importrun", "import run from metadata file", FAKETOOL_MODE_IMPORTRUN, importrunArgs); 327 340 328 341 -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/flatcorr.c
r21402 r23352 46 46 static bool inputexpMode(pxConfig *config); 47 47 static bool inputimfileMode(pxConfig *config); 48 static bool exportrunMode(pxConfig *config); 49 static bool importrunMode(pxConfig *config); 48 50 49 51 static bool setflatcorrRunState(pxConfig *config, psS64 corr_id, const char *state); … … 78 80 MODECASE(FLATCORR_MODE_INPUTEXP, inputexpMode); 79 81 MODECASE(FLATCORR_MODE_INPUTIMFILE, inputimfileMode); 82 MODECASE(FLATCORR_MODE_EXPORTRUN, exportrunMode); 83 MODECASE(FLATCORR_MODE_IMPORTRUN, importrunMode); 80 84 default: 81 85 psAbort("invalid option (this should not happen)"); … … 734 738 return true; 735 739 } 740 741 bool exportrunMode(pxConfig *config) 742 { 743 typedef struct ExportTable { 744 char tableName[80]; 745 char sqlFilename[80]; 746 } ExportTable; 747 748 int numExportTables = 3; 749 750 PS_ASSERT_PTR_NON_NULL(config, NULL); 751 752 PXOPT_LOOKUP_S64(det_id, config->args, "-corr_id", true, false); 753 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 754 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 755 756 FILE *f = fopen (outfile, "w"); 757 if (f == NULL) { 758 psError(PS_ERR_UNKNOWN, false, "failed to open output file"); 759 return false; 760 } 761 762 psMetadata *where = psMetadataAlloc(); 763 PXOPT_COPY_S64(config->args, where, "-coor_id", "corr_id", "=="); 764 765 ExportTable tables [] = { 766 {"flatcorrRun", "flatcorrtool_export_run.sql"}, 767 {"flatcorrCamLink", "flatcorrtool_export_cam_link.sql"}, 768 {"flatcorrChipLink", "flatcorr_export_chip_link.sql"}, 769 }; 770 771 for (int i=0; i < numExportTables; i++) { 772 psString query = pxDataGet(tables[i].sqlFilename); 773 if (!query) { 774 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 775 return false; 776 } 777 778 if (where && psListLength(where->list)) { 779 psString whereClause = psDBGenerateWhereSQL(where, NULL); 780 psStringAppend(&query, " %s", whereClause); 781 psFree(whereClause); 782 } 783 784 // treat limit == 0 as "no limit" 785 if (limit) { 786 psString limitString = psDBGenerateLimitSQL(limit); 787 psStringAppend(&query, " %s", limitString); 788 psFree(limitString); 789 } 790 791 if (!p_psDBRunQuery(config->dbh, query)) { 792 psError(PS_ERR_UNKNOWN, false, "database error"); 793 psFree(query); 794 return false; 795 } 796 psFree(query); 797 798 psArray *output = p_psDBFetchResult(config->dbh); 799 if (!output) { 800 psError(PS_ERR_UNKNOWN, false, "database error"); 801 return false; 802 } 803 if (!psArrayLength(output)) { 804 psTrace("regtool", PS_LOG_INFO, "no rows found"); 805 psFree(output); 806 return true; 807 } 808 809 // we must write the export table in non-simple (true) format 810 if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) { 811 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 812 psFree(output); 813 return false; 814 } 815 psFree(output); 816 } 817 818 fclose (f); 819 820 return true; 821 } 822 823 bool importrunMode(pxConfig *config) 824 { 825 unsigned int nFail; 826 psMetadataItem *item, *entry; 827 828 int numImportTables = 3; 829 830 char tables[3] [80] = {"flatcorrRun", "flatcorrCamLink", "flatcorrChipLink"}; 831 832 PS_ASSERT_PTR_NON_NULL(config, NULL); 833 834 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 835 836 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 837 838 fprintf (stdout, "---- input ----\n"); 839 psMetadataPrint (stderr, input, 1); 840 841 for (int i = 0; i < numImportTables; i++) { 842 item = psMetadataLookup (input, tables[i]); 843 psAssert (item, "entry not in input?"); 844 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 845 846 entry = psListGet (item->data.list, 0); 847 assert (entry); 848 assert (entry->type == PS_DATA_METADATA); 849 850 switch (i) { 851 case 0: 852 { 853 flatcorrRunRow *flatcorrRun = flatcorrRunObjectFromMetadata (entry->data.md); 854 flatcorrRunInsertObject (config->dbh, flatcorrRun); 855 856 // fprintf (stdout, "---- flatcorr run ----\n"); 857 // psMetadataPrint (stderr, entry->data.md, 1); 858 break; 859 } 860 case 1: 861 { 862 flatcorrCamLinkRow *flatcorrCamLink = flatcorrCamLinkObjectFromMetadata (entry->data.md); 863 flatcorrCamLinkInsertObject (config->dbh, flatcorrCamLink); 864 865 // fprintf (stdout, "---- flatcorr cam link ----\n"); 866 // psMetadataPrint (stderr, entry->data.md, 1); 867 break; 868 } 869 case 2: 870 { 871 flatcorrChipLinkRow *flatcorrChipLink = flatcorrChipLinkObjectFromMetadata (entry->data.md); 872 flatcorrChipLinkInsertObject (config->dbh, flatcorrChipLink); 873 874 // fprintf (stdout, "---- flatcorr chip link ----\n"); 875 // psMetadataPrint (stderr, entry->data.md, 1); 876 break; 877 } 878 } 879 } 880 return true; 881 } -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/flatcorr.h
r20397 r23352 35 35 FLATCORR_MODE_UPDATERUN, 36 36 FLATCORR_MODE_INPUTEXP, 37 FLATCORR_MODE_INPUTIMFILE 37 FLATCORR_MODE_INPUTIMFILE, 38 FLATCORR_MODE_EXPORTRUN, 39 FLATCORR_MODE_IMPORTRUN 38 40 } flatcorrMode; 39 41 -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/flatcorrConfig.c
r20397 r23352 125 125 psMetadataAddU64(inputimfileArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 126 126 127 // -exportrun 128 psMetadata *exportrunArgs = psMetadataAlloc(); 129 psMetadataAddS64(exportrunArgs, PS_LIST_TAIL, "-corr_id", 0, "export this correction ID (required)", 0); 130 psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0, "export to this file (required)", NULL); 131 psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 132 133 // -importrun 134 psMetadata *importrunArgs = psMetadataAlloc(); 135 psMetadataAddStr(importrunArgs, PS_LIST_TAIL, "-infile", 0, "import from this file (required)", NULL); 136 137 127 138 psFree(now); 128 139 … … 141 152 PXOPT_ADD_MODE("-inputexp", "list exposures for a correction run", FLATCORR_MODE_INPUTEXP, inputexpArgs); 142 153 PXOPT_ADD_MODE("-inputimfile", "list imfiles for a chip run", FLATCORR_MODE_INPUTIMFILE, inputimfileArgs); 154 PXOPT_ADD_MODE("-exportrun", "export run for import on other database", FLATCORR_MODE_EXPORTRUN, exportrunArgs); 155 PXOPT_ADD_MODE("-importrun", "import run from metadata file", FLATCORR_MODE_IMPORTRUN, importrunArgs); 143 156 144 157 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxadmin.c
r18927 r23352 29 29 30 30 bool createMode(pxConfig *config); 31 bool createMirrorMode(pxConfig *config); 31 32 bool deleteMode(pxConfig *config); 32 33 static bool runMultipleStatments(pxConfig *config, const char *query); … … 53 54 } 54 55 break; 56 case PXADMIN_MODE_CREATE_MIRROR: 57 if (!createMirrorMode(config)) { 58 goto FAIL; 59 } 60 break; 55 61 case PXADMIN_MODE_DELETE: 56 62 if (!deleteMode(config)) { … … 86 92 87 93 psString query = pxDataGet("pxadmin_create_tables.sql"); 94 if (!query) { 95 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 96 return false; 97 } 98 99 // BEGIN 100 if (!psDBTransaction(config->dbh)) { 101 psError(PS_ERR_UNKNOWN, false, "database error"); 102 return false; 103 } 104 105 if (!runMultipleStatments(config, query)) { 106 if (!psDBRollback(config->dbh)) { 107 psError(PS_ERR_UNKNOWN, false, "database error"); 108 } 109 psError(PS_ERR_UNKNOWN, false, "database error"); 110 psFree(query); 111 return false; 112 } 113 psFree(query); 114 115 // COMMIT 116 if (!psDBCommit(config->dbh)) { 117 psError(PS_ERR_UNKNOWN, false, "database error"); 118 return false; 119 } 120 121 return true; 122 } 123 124 125 bool createMirrorMode(pxConfig *config) 126 { 127 PS_ASSERT_PTR_NON_NULL(config, false); 128 129 psString query = pxDataGet("pxadmin_create_mirror_tables.sql"); 88 130 if (!query) { 89 131 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxadmin.h
r9392 r23352 26 26 PXADMIN_MODE_NONE = 0x0, 27 27 PXADMIN_MODE_CREATE, 28 PXADMIN_MODE_CREATE_MIRROR, 28 29 PXADMIN_MODE_DELETE, 29 30 PXADMIN_MODE_RECREATE -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxadminConfig.c
r19062 r23352 31 31 fprintf (stderr, "\nPan-STARRS DataBase Admin Tool\n\n"); 32 32 fprintf (stderr, "Usage: %s [mode]\n", program); 33 fprintf (stderr, " [mode] : -create | - delete\n\n");33 fprintf (stderr, " [mode] : -create | -create-mirror | -delete\n\n"); 34 34 35 35 psMetadataItem *server = pmConfigUserSite(config->modules, "DBSERVER", PS_DATA_STRING); … … 87 87 config->mode = PXADMIN_MODE_CREATE; 88 88 } 89 if ((N = psArgumentGet(argc, argv, "-create-mirror"))) { 90 psArgumentRemove(N, &argc, argv); 91 if (config->mode) { 92 psAbort("only one mode selection is allowed"); 93 } 94 config->mode = PXADMIN_MODE_CREATE_MIRROR; 95 } 89 96 if ((N = psArgumentGet(argc, argv, "-delete"))) { 90 97 psArgumentRemove(N, &argc, argv); … … 105 112 psMetadataAddStr(arguments, PS_LIST_TAIL, "-create", 0, 106 113 "create all IPP tables", ""); 114 psMetadataAddStr(arguments, PS_LIST_TAIL, "-create-mirror", 0, 115 "mirror all IPP tables", ""); 107 116 psMetadataAddStr(arguments, PS_LIST_TAIL, "-delete", 0, 108 117 "delete all IPP tables", ""); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxtools.c
r20413 r23352 30 30 PS_ASSERT_PTR_NON_NULL(state, false); 31 31 32 // XXX replace strncmp with strcmp33 34 32 if (!strcmp(state, "new")) return true; 35 33 if (!strcmp(state, "reg")) return true; … … 38 36 if (!strcmp(state, "wait")) return true; 39 37 if (!strcmp(state, "goto_cleaned")) return true; 38 if (!strcmp(state, "error_cleaned")) return true; 39 if (!strcmp(state, "goto_scrubbed")) return true; 40 if (!strcmp(state, "error_scrubbed")) return true; 40 41 if (!strcmp(state, "cleaned")) return true; 41 42 if (!strcmp(state, "update")) return true; 42 43 if (!strcmp(state, "purged")) return true; 43 44 if (!strcmp(state, "goto_purged")) return true; 45 if (!strcmp(state, "error_purged")) return true; 44 46 45 47 return false; 46 48 } 49 50 // 'scrubbed' is a virtual state equivalent to cleaned, but allows files to be removed 51 // even if the config files is missing -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxwarp.c
r21402 r23352 58 58 // check that state is a valid string value 59 59 if (!pxIsValidState(state)) { 60 psError(PS_ERR_UNKNOWN, false, "invalid chipRun state: %s", state);60 psError(PS_ERR_UNKNOWN, false, "invalid warpRun state: %s", state); 61 61 return false; 62 62 } -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/regtool.c
r21402 r23352 44 44 static bool updateprocessedexpMode(pxConfig *config); 45 45 static bool cleardupexpMode(pxConfig *config); 46 static bool exportrunMode(pxConfig *config); 47 static bool importrunMode(pxConfig *config); 46 48 47 49 # define MODECASE(caseName, func) \ … … 76 78 MODECASE(REGTOOL_MODE_UPDATEPROCESSEDEXP, updateprocessedexpMode); 77 79 MODECASE(REGTOOL_MODE_CLEARDUPEXP, cleardupexpMode); 80 MODECASE(CHIPTOOL_MODE_EXPORTRUN, exportrunMode); 81 MODECASE(CHIPTOOL_MODE_IMPORTRUN, importrunMode); 78 82 default: 79 83 psAbort("invalid option (this should not happen)"); … … 1107 1111 return true; 1108 1112 } 1113 1114 bool exportrunMode(pxConfig *config) 1115 { 1116 typedef struct ExportTable { 1117 char tableName[80]; 1118 char sqlFilename[80]; 1119 } ExportTable; 1120 1121 int numExportTables = 2; 1122 1123 PS_ASSERT_PTR_NON_NULL(config, NULL); 1124 1125 PXOPT_LOOKUP_S64(det_id, config->args, "-exp_id", true, false); 1126 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 1127 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1128 1129 FILE *f = fopen (outfile, "w"); 1130 if (f == NULL) { 1131 psError(PS_ERR_UNKNOWN, false, "failed to open output file"); 1132 return false; 1133 } 1134 1135 psMetadata *where = psMetadataAlloc(); 1136 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 1137 1138 ExportTable tables [] = { 1139 {"rawExp", "regtool_export_raw__exp.sql"}, 1140 {"rawImfile", "regtool_export_raw_imfile.sql"}, 1141 }; 1142 1143 for (int i=0; i < numExportTables; i++) { 1144 psString query = pxDataGet(tables[i].sqlFilename); 1145 if (!query) { 1146 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1147 return false; 1148 } 1149 1150 if (where && psListLength(where->list)) { 1151 psString whereClause = psDBGenerateWhereSQL(where, NULL); 1152 psStringAppend(&query, " %s", whereClause); 1153 psFree(whereClause); 1154 } 1155 1156 // treat limit == 0 as "no limit" 1157 if (limit) { 1158 psString limitString = psDBGenerateLimitSQL(limit); 1159 psStringAppend(&query, " %s", limitString); 1160 psFree(limitString); 1161 } 1162 1163 if (!p_psDBRunQuery(config->dbh, query)) { 1164 psError(PS_ERR_UNKNOWN, false, "database error"); 1165 psFree(query); 1166 return false; 1167 } 1168 psFree(query); 1169 1170 psArray *output = p_psDBFetchResult(config->dbh); 1171 if (!output) { 1172 psError(PS_ERR_UNKNOWN, false, "database error"); 1173 return false; 1174 } 1175 if (!psArrayLength(output)) { 1176 psTrace("regtool", PS_LOG_INFO, "no rows found"); 1177 psFree(output); 1178 return true; 1179 } 1180 1181 // we must write the export table in non-simple (true) format 1182 if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) { 1183 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1184 psFree(output); 1185 return false; 1186 } 1187 psFree(output); 1188 } 1189 1190 fclose (f); 1191 1192 return true; 1193 } 1194 1195 bool importrunMode(pxConfig *config) 1196 { 1197 unsigned int nFail; 1198 1199 PS_ASSERT_PTR_NON_NULL(config, NULL); 1200 1201 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 1202 1203 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1204 1205 fprintf (stdout, "---- input ----\n"); 1206 psMetadataPrint (stderr, input, 1); 1207 1208 psMetadataItem *item = psMetadataLookup (input, "rawExp"); 1209 psAssert (item, "entry not in input?"); 1210 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1211 1212 psMetadataItem *entry = psListGet (item->data.list, 0); 1213 assert (entry); 1214 assert (entry->type == PS_DATA_METADATA); 1215 rawExpRow *rawExp = rawExpObjectFromMetadata (entry->data.md); 1216 rawExpInsertObject (config->dbh, rawExp); 1217 1218 // fprintf (stdout, "---- raw exp ----\n"); 1219 // psMetadataPrint (stderr, entry->data.md, 1); 1220 1221 item = psMetadataLookup (input, "rawImfile"); 1222 psAssert (item, "entry not in input?"); 1223 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1224 1225 for (int i = 0; i < item->data.list->n; i++) { 1226 psMetadataItem *entry = psListGet (item->data.list, i); 1227 assert (entry); 1228 assert (entry->type == PS_DATA_METADATA); 1229 rawImfileRow *rawImfile = rawImfileObjectFromMetadata (entry->data.md); 1230 rawImfileInsertObject (config->dbh, rawImfile); 1231 1232 // fprintf (stdout, "---- row %d ----\n", i); 1233 // psMetadataPrint (stderr, entry->data.md, 1); 1234 } 1235 1236 return true; 1237 } 1238 -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/regtool.h
r18328 r23352 36 36 REGTOOL_MODE_UPDATEPROCESSEDEXP, 37 37 REGTOOL_MODE_CLEARDUPEXP, 38 REGTOOL_MODE_EXPORTRUN, 39 REGTOOL_MODE_IMPORTRUN 38 40 } regtoolMode; 39 41 -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/regtoolConfig.c
r20608 r23352 278 278 psMetadataAddS16(updatedprocessedexpArgs, PS_LIST_TAIL, "-code", 0, "set fault code (required)", INT16_MAX); 279 279 280 // -exportrun 281 psMetadata *exportrunArgs = psMetadataAlloc(); 282 psMetadataAddS64(exportrunArgs, PS_LIST_TAIL, "-exp_id", 0, "export this exposure ID (required)", 0); 283 psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0, "export to this file (required)", NULL); 284 psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 285 286 // -importrun 287 psMetadata *importrunArgs = psMetadataAlloc(); 288 psMetadataAddStr(importrunArgs, PS_LIST_TAIL, "-infile", 0, "import from this file (required)", NULL); 289 290 280 291 // -cleardupexp 281 292 psMetadata *cleardupexpArgs = psMetadataAlloc(); … … 295 306 PXOPT_ADD_MODE("-updateprocessedexp", "", REGTOOL_MODE_UPDATEPROCESSEDEXP, updatedprocessedexpArgs); 296 307 PXOPT_ADD_MODE("-cleardupexp", "", REGTOOL_MODE_CLEARDUPEXP, cleardupexpArgs); 308 PXOPT_ADD_MODE("-exportrun", "export run for import on other database", REGTOOL_MODE_EXPORTRUN, exportrunArgs); 309 PXOPT_ADD_MODE("-importrun", "import run from metadata file", REGTOOL_MODE_IMPORTRUN, importrunArgs); 297 310 298 311 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/stacktool.c
r21402 r23352 44 44 static bool donecleanupMode(pxConfig *config); 45 45 static bool updatesumskyfileMode(pxConfig *config); 46 static bool exportrunMode(pxConfig *config); 47 static bool importrunMode(pxConfig *config); 46 48 47 49 static bool setstackRunState(pxConfig *config, psS64 stack_id, const char *state); … … 78 80 MODECASE(STACKTOOL_MODE_DONECLEANUP, donecleanupMode); 79 81 MODECASE(STACKTOOL_MODE_UPDATESUMSKYFILE, updatesumskyfileMode); 82 MODECASE(STACKTOOL_MODE_EXPORTRUN, exportrunMode); 83 MODECASE(STACKTOOL_MODE_IMPORTRUN, importrunMode); 80 84 default: 81 85 psAbort("invalid option (this should not happen)"); … … 1180 1184 } 1181 1185 1186 bool exportrunMode(pxConfig *config) 1187 { 1188 typedef struct ExportTable { 1189 char tableName[80]; 1190 char sqlFilename[80]; 1191 } ExportTable; 1192 1193 int numExportTables = 3; 1194 1195 PS_ASSERT_PTR_NON_NULL(config, NULL); 1196 1197 PXOPT_LOOKUP_S64(det_id, config->args, "-stack_id", true, false); 1198 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 1199 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1200 1201 FILE *f = fopen (outfile, "w"); 1202 if (f == NULL) { 1203 psError(PS_ERR_UNKNOWN, false, "failed to open output file"); 1204 return false; 1205 } 1206 1207 psMetadata *where = psMetadataAlloc(); 1208 PXOPT_COPY_S64(config->args, where, "-stack_id", "stack_id", "=="); 1209 1210 ExportTable tables [] = { 1211 {"stackRun", "stacktool_export_run.sql"}, 1212 {"stackInputSkyfile", "stacktool_export_input_skyfile.sql"}, 1213 {"stackSumSkyfile", "stacktool_export_sum_skyfile.sql"}, 1214 }; 1215 1216 for (int i=0; i < numExportTables; i++) { 1217 psString query = pxDataGet(tables[i].sqlFilename); 1218 if (!query) { 1219 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1220 return false; 1221 } 1222 1223 if (where && psListLength(where->list)) { 1224 psString whereClause = psDBGenerateWhereSQL(where, NULL); 1225 psStringAppend(&query, " %s", whereClause); 1226 psFree(whereClause); 1227 } 1228 1229 // treat limit == 0 as "no limit" 1230 if (limit) { 1231 psString limitString = psDBGenerateLimitSQL(limit); 1232 psStringAppend(&query, " %s", limitString); 1233 psFree(limitString); 1234 } 1235 1236 if (!p_psDBRunQuery(config->dbh, query)) { 1237 psError(PS_ERR_UNKNOWN, false, "database error"); 1238 psFree(query); 1239 return false; 1240 } 1241 psFree(query); 1242 1243 psArray *output = p_psDBFetchResult(config->dbh); 1244 if (!output) { 1245 psError(PS_ERR_UNKNOWN, false, "database error"); 1246 return false; 1247 } 1248 if (!psArrayLength(output)) { 1249 psTrace("regtool", PS_LOG_INFO, "no rows found"); 1250 psFree(output); 1251 return true; 1252 } 1253 psFree(output); 1254 } 1255 1256 fclose (f); 1257 1258 return true; 1259 } 1260 1261 bool importrunMode(pxConfig *config) 1262 { 1263 unsigned int nFail; 1264 1265 int numImportTables = 2; 1266 1267 char tables[2] [80] = {"stackInputSkyfile", "stackSumSkyfile"}; 1268 1269 PS_ASSERT_PTR_NON_NULL(config, NULL); 1270 1271 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 1272 1273 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1274 1275 fprintf (stdout, "---- input ----\n"); 1276 psMetadataPrint (stderr, input, 1); 1277 1278 psMetadataItem *item = psMetadataLookup (input, "stackRun"); 1279 psAssert (item, "entry not in input?"); 1280 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1281 1282 psMetadataItem *entry = psListGet (item->data.list, 0); 1283 assert (entry); 1284 assert (entry->type == PS_DATA_METADATA); 1285 stackRunRow *stackRun = stackRunObjectFromMetadata (entry->data.md); 1286 stackRunInsertObject (config->dbh, stackRun); 1287 1288 // fprintf (stdout, "---- stack run ----\n"); 1289 // psMetadataPrint (stderr, entry->data.md, 1); 1290 1291 for (int i = 0; i < numImportTables; i++) { 1292 psMetadataItem *item = psMetadataLookup (input, tables[i]); 1293 psAssert (item, "entry not in input?"); 1294 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1295 1296 switch (i) { 1297 case 0: 1298 for (int i = 0; i < item->data.list->n; i++) { 1299 entry = psListGet (item->data.list, i); 1300 assert (entry); 1301 assert (entry->type == PS_DATA_METADATA); 1302 stackInputSkyfileRow *stackInputSkyfile = stackInputSkyfileObjectFromMetadata (entry->data.md); 1303 stackInputSkyfileInsertObject (config->dbh, stackInputSkyfile); 1304 1305 // fprintf (stdout, "---- row %d ----\n", i); 1306 // psMetadataPrint (stderr, entry->data.md, 1); 1307 } 1308 break; 1309 1310 case 1: 1311 for (int i = 0; i < item->data.list->n; i++) { 1312 entry = psListGet (item->data.list, i); 1313 assert (entry); 1314 assert (entry->type == PS_DATA_METADATA); 1315 stackSumSkyfileRow *stackSumSkyfile = stackSumSkyfileObjectFromMetadata (entry->data.md); 1316 stackSumSkyfileInsertObject (config->dbh, stackSumSkyfile); 1317 1318 // fprintf (stdout, "---- row %d ----\n", i); 1319 // psMetadataPrint (stderr, entry->data.md, 1); 1320 } 1321 break; 1322 } 1323 } 1324 1325 return true; 1326 } -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/stacktool.h
r19676 r23352 38 38 STACKTOOL_MODE_DONECLEANUP, 39 39 STACKTOOL_MODE_UPDATESUMSKYFILE, 40 STACKTOOL_MODE_EXPORTRUN, 41 STACKTOOL_MODE_IMPORTRUN 40 42 } stacktoolMode; 41 43 -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/stacktoolConfig.c
r19931 r23352 187 187 psMetadataAddS16(updatesumskyfileArgs, PS_LIST_TAIL, "-code", 0, "set fault code (required)", 0); 188 188 189 // -exportrun 190 psMetadata *exportrunArgs = psMetadataAlloc(); 191 psMetadataAddS64(exportrunArgs, PS_LIST_TAIL, "-stack_id", 0, "export this stack ID (required)", 0); 192 psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0, "export to this file (required)", NULL); 193 psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 194 195 // -importrun 196 psMetadata *importrunArgs = psMetadataAlloc(); 197 psMetadataAddStr(importrunArgs, PS_LIST_TAIL, "-infile", 0, "import from this file (required)", NULL); 198 199 189 200 psFree(now); 190 201 … … 205 216 PXOPT_ADD_MODE("-donecleanup", "show runs that have been cleaned", STACKTOOL_MODE_DONECLEANUP, donecleanupArgs); 206 217 PXOPT_ADD_MODE("-updatesumskyfile", "update fault code for sumskyfile", STACKTOOL_MODE_UPDATESUMSKYFILE, updatesumskyfileArgs); 218 PXOPT_ADD_MODE("-exportrun", "export run for import on other database", STACKTOOL_MODE_EXPORTRUN, exportrunArgs); 219 PXOPT_ADD_MODE("-importrun", "import run from metadata file", STACKTOOL_MODE_IMPORTRUN, importrunArgs); 207 220 208 221 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/warptool.c
r21402 r23352 54 54 static bool tofullskyfileMode(pxConfig *config); 55 55 static bool updateskyfileMode(pxConfig *config); 56 static bool exportrunMode(pxConfig *config); 57 static bool importrunMode(pxConfig *config); 56 58 57 59 static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile); … … 99 101 MODECASE(WARPTOOL_MODE_TOFULLSKYFILE, tofullskyfileMode); 100 102 MODECASE(WARPTOOL_MODE_UPDATESKYFILE, updateskyfileMode); 103 MODECASE(WARPTOOL_MODE_EXPORTRUN, exportrunMode); 104 MODECASE(WARPTOOL_MODE_IMPORTRUN, importrunMode); 101 105 102 106 default: … … 1680 1684 return true; 1681 1685 } 1686 1687 bool exportrunMode(pxConfig *config) 1688 { 1689 typedef struct ExportTable { 1690 char tableName[80]; 1691 char sqlFilename[80]; 1692 } ExportTable; 1693 1694 PS_ASSERT_PTR_NON_NULL(config, NULL); 1695 1696 PXOPT_LOOKUP_S64(det_id, config->args, "-warp_id", true, false); 1697 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 1698 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1699 1700 FILE *f = fopen (outfile, "w"); 1701 if (f == NULL) { 1702 psError(PS_ERR_UNKNOWN, false, "failed to open output file"); 1703 return false; 1704 } 1705 1706 psMetadata *where = psMetadataAlloc(); 1707 PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "=="); 1708 1709 ExportTable tables [] = { 1710 {"warpRun", "warptool_export_run.sql"}, 1711 {"warpImfile", "warptool_export_imfile.sql"}, 1712 {"warpSkyfile", "warptool_export_skyfile.sql"}, 1713 {"warpSkyCellMap", "warptool_export_sky_cell_map.sql"}, 1714 }; 1715 1716 1717 for (int i=0; i < sizeof(tables); i++) { 1718 psString query = pxDataGet(tables[i].sqlFilename); 1719 if (!query) { 1720 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1721 return false; 1722 } 1723 1724 if (where && psListLength(where->list)) { 1725 psString whereClause = psDBGenerateWhereSQL(where, NULL); 1726 psStringAppend(&query, " %s", whereClause); 1727 psFree(whereClause); 1728 } 1729 1730 // treat limit == 0 as "no limit" 1731 if (limit) { 1732 psString limitString = psDBGenerateLimitSQL(limit); 1733 psStringAppend(&query, " %s", limitString); 1734 psFree(limitString); 1735 } 1736 1737 if (!p_psDBRunQuery(config->dbh, query)) { 1738 psError(PS_ERR_UNKNOWN, false, "database error"); 1739 psFree(query); 1740 return false; 1741 } 1742 psFree(query); 1743 1744 psArray *output = p_psDBFetchResult(config->dbh); 1745 if (!output) { 1746 psError(PS_ERR_UNKNOWN, false, "database error"); 1747 return false; 1748 } 1749 if (!psArrayLength(output)) { 1750 psTrace("regtool", PS_LOG_INFO, "no rows found"); 1751 psFree(output); 1752 return true; 1753 } 1754 1755 // we must write the export table in non-simple (true) format 1756 if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) { 1757 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1758 psFree(output); 1759 return false; 1760 } 1761 psFree(output); 1762 } 1763 1764 fclose (f); 1765 1766 return true; 1767 } 1768 1769 bool importrunMode(pxConfig *config) 1770 { 1771 unsigned int nFail; 1772 1773 int numImportTables = 3; 1774 1775 char tables[3] [80] = {"warpImfile", "warpSkyfile", "warpSkyCellMap"}; 1776 1777 PS_ASSERT_PTR_NON_NULL(config, NULL); 1778 1779 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 1780 1781 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1782 1783 fprintf (stdout, "---- input ----\n"); 1784 psMetadataPrint (stderr, input, 1); 1785 1786 psMetadataItem *item = psMetadataLookup (input, "warpRun"); 1787 psAssert (item, "entry not in input?"); 1788 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1789 1790 psMetadataItem *entry = psListGet (item->data.list, 0); 1791 assert (entry); 1792 assert (entry->type == PS_DATA_METADATA); 1793 warpRunRow *warpRun = warpRunObjectFromMetadata (entry->data.md); 1794 warpRunInsertObject (config->dbh, warpRun); 1795 1796 // fprintf (stdout, "---- warp run ----\n"); 1797 // psMetadataPrint (stderr, entry->data.md, 1); 1798 1799 for (int i = 0; i < numImportTables; i++) { 1800 item = psMetadataLookup (input, tables[i]); 1801 psAssert (item, "entry not in input?"); 1802 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1803 1804 switch (i) { 1805 case 0: 1806 for (int i = 0; i < item->data.list->n; i++) { 1807 entry = psListGet (item->data.list, i); 1808 assert (entry); 1809 assert (entry->type == PS_DATA_METADATA); 1810 warpImfileRow *warpImfile = warpImfileObjectFromMetadata (entry->data.md); 1811 warpImfileInsertObject (config->dbh, warpImfile); 1812 1813 // fprintf (stdout, "---- row %d ----\n", i); 1814 // psMetadataPrint (stderr, entry->data.md, 1); 1815 } 1816 break; 1817 1818 case 1: 1819 for (int i = 0; i < item->data.list->n; i++) { 1820 entry = psListGet (item->data.list, i); 1821 assert (entry); 1822 assert (entry->type == PS_DATA_METADATA); 1823 warpSkyfileRow *warpSkyfile = warpSkyfileObjectFromMetadata (entry->data.md); 1824 warpSkyfileInsertObject (config->dbh, warpSkyfile); 1825 1826 // fprintf (stdout, "---- row %d ----\n", i); 1827 // psMetadataPrint (stderr, entry->data.md, 1); 1828 } 1829 break; 1830 1831 case 2: 1832 for (int i = 0; i < item->data.list->n; i++) { 1833 entry = psListGet (item->data.list, i); 1834 assert (entry); 1835 assert (entry->type == PS_DATA_METADATA); 1836 warpSkyCellMapRow *warpSkyCellMap = warpSkyCellMapObjectFromMetadata (entry->data.md); 1837 warpSkyCellMapInsertObject (config->dbh, warpSkyCellMap); 1838 1839 // fprintf (stdout, "---- row %d ----\n", i); 1840 // psMetadataPrint (stderr, entry->data.md, 1); 1841 } 1842 break; 1843 } 1844 } 1845 return true; 1846 } -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/warptool.h
r19522 r23352 49 49 WARPTOOL_MODE_TOFULLSKYFILE, 50 50 WARPTOOL_MODE_UPDATESKYFILE, 51 WARPTOOL_MODE_EXPORTRUN, 52 WARPTOOL_MODE_IMPORTRUN 51 53 } warptoolMode; 52 54 -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/warptoolConfig.c
r20973 r23352 354 354 psMetadataAddS16(updateskyfileArgs, PS_LIST_TAIL, "-code", 0, "new fault code", 0); 355 355 356 // -exportrun 357 psMetadata *exportrunArgs = psMetadataAlloc(); 358 psMetadataAddS64(exportrunArgs, PS_LIST_TAIL, "-warp_id", 0, "export this warp ID (required)", 0); 359 psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0, "export to this file (required)", NULL); 360 psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 361 362 // -importrun 363 psMetadata *importrunArgs = psMetadataAlloc(); 364 psMetadataAddStr(importrunArgs, PS_LIST_TAIL, "-infile", 0, "import from this file (required)", NULL); 365 366 356 367 psFree(now); 357 368 psMetadata *argSets = psMetadataAlloc(); … … 380 391 PXOPT_ADD_MODE("-tofullskyfile", "set skyfile as full (updated)", WARPTOOL_MODE_TOFULLSKYFILE, tofullskyfileArgs); 381 392 PXOPT_ADD_MODE("-updateskyfile", "update fault code for skyfile", WARPTOOL_MODE_UPDATESKYFILE, updateskyfileArgs); 393 PXOPT_ADD_MODE("-exportrun", "export run for import on other database", WARPTOOL_MODE_EXPORTRUN, exportrunArgs); 394 PXOPT_ADD_MODE("-importrun", "import run from metadata file", WARPTOOL_MODE_IMPORTRUN, importrunArgs); 382 395 383 396 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
branches/cnb_branches/cnb_branch_20090301/ippconfig/gpc1/format_20080925.config
r21023 r23352 189 189 FPA.RA STR RA 190 190 FPA.DEC STR DEC 191 FPA.RADECSYS STR RADECSYS191 FPA.RADECSYS STR EQUINOX 192 192 FPA.OBSTYPE STR OBSTYPE 193 193 FPA.OBJECT STR OBJECT -
branches/cnb_branches/cnb_branch_20090301/ippconfig/gpc1/format_20080929.config
r21023 r23352 184 184 FPA.RA STR RA 185 185 FPA.DEC STR DEC 186 FPA.RADECSYS STR RADECSYS186 FPA.RADECSYS STR EQUINOX 187 187 FPA.OBSTYPE STR OBSTYPE 188 188 FPA.OBJECT STR OBJECT -
branches/cnb_branches/cnb_branch_20090301/ippconfig/gpc1/format_20081011.config
r20951 r23352 174 174 FPA.RA STR RA 175 175 FPA.DEC STR DEC 176 FPA.RADECSYS STR RADECSYS176 FPA.RADECSYS STR EQUINOX 177 177 FPA.OBSTYPE STR OBSTYPE 178 178 FPA.OBJECT STR OBJECT -
branches/cnb_branches/cnb_branch_20090301/ippconfig/gpc1/format_20090120.config
r21539 r23352 173 173 FPA.RA STR RA 174 174 FPA.DEC STR DEC 175 FPA.RADECSYS STR RADECSYS175 FPA.RADECSYS STR EQUINOX 176 176 FPA.OBSTYPE STR OBSTYPE 177 177 FPA.OBJECT STR OBJECT -
branches/cnb_branches/cnb_branch_20090301/ippconfig/gpc1/format_20090220.config
r22212 r23352 173 173 FPA.RA STR RA 174 174 FPA.DEC STR DEC 175 FPA.RADECSYS STR RADECSYS175 FPA.RADECSYS STR EQUINOX 176 176 FPA.OBSTYPE STR OBSTYPE 177 177 FPA.OBJECT STR OBJECT -
branches/cnb_branches/cnb_branch_20090301/ippconfig/gpc1/format_mef.config
r22685 r23352 168 168 FPA.RA STR RA 169 169 FPA.DEC STR DEC 170 FPA.RADECSYS STR RADECSYS170 FPA.RADECSYS STR EQUINOX 171 171 FPA.OBSTYPE STR OBSTYPE 172 172 FPA.OBJECT STR OBJECT -
branches/cnb_branches/cnb_branch_20090301/ippconfig/gpc1/format_orig.config
r21023 r23352 182 182 # FPA.RA STR COMRA 183 183 # FPA.DEC STR COMDEC 184 FPA.RADECSYS STR RADECSYS184 FPA.RADECSYS STR EQUINOX 185 185 FPA.OBSTYPE STR OBSTYPE 186 186 FPA.OBJECT STR OBJECT -
branches/cnb_branches/cnb_branch_20090301/ippconfig/gpc1/format_relphot.config
r21023 r23352 105 105 FPA.RA STR RA 106 106 FPA.DEC STR DEC 107 FPA.RADECSYS STR RADECSYS107 FPA.RADECSYS STR EQUINOX 108 108 FPA.OBSTYPE STR OBSTYPE 109 109 FPA.OBJECT STR OBJECT -
branches/cnb_branches/cnb_branch_20090301/ippconfig/gpc1/ppImage.config
r21370 r23352 10 10 OVERSCAN.BOXCAR S32 3 11 11 12 # Normalization class 13 NORM.CLASS STR CHIP # How to find the per-class normalizations 14 12 15 OLDDARK BOOL FALSE 13 16 … … 134 137 # Overscan, bias, dark, shutter 135 138 PPIMAGE_OBDS METADATA 136 BASE.FITS BOOL TRUE # Save base detrended image?137 BASE.MASK.FITS BOOL TRUE # Save base detrended image?139 BASE.FITS BOOL TRUE # Save base detrended image? 140 BASE.MASK.FITS BOOL TRUE # Save base detrended image? 138 141 BASE.VARIANCE.FITS BOOL TRUE # Save base detrended image? 139 CHIP.FITS BOOL FALSE # Save chip-mosaic-ed image? 140 CHIP.MASK.FITS BOOL FALSE # Save chip-mosaic-ed image? 141 CHIP.VARIANCE.FITS BOOL FALSE # Save chip-mosaic-ed image? 142 OVERSCAN BOOL TRUE # Overscan subtraction 143 BIAS BOOL FALSE # Bias subtraction 144 DARK BOOL TRUE # Dark subtraction 145 SHUTTER BOOL FALSE # Shutter correction 146 FLAT BOOL FALSE # Flat-field normalisation 147 MASK BOOL FALSE # Mask bad pixels 148 FRINGE BOOL FALSE # Fringe subtraction 149 PHOTOM BOOL FALSE # Source identification and photometry 150 ASTROM.CHIP BOOL FALSE # Astrometry per chip? 151 ASTROM.MOSAIC BOOL FALSE # Astrometry for mosaic? 152 BIN1.FITS BOOL TRUE # Save 1st binned chip image? 153 BIN2.FITS BOOL TRUE # Save 2nd binned chip image? 142 CHIP.FITS BOOL FALSE # Save chip-mosaic-ed image? 143 CHIP.MASK.FITS BOOL FALSE # Save chip-mosaic-ed image? 144 CHIP.VARIANCE.FITS BOOL FALSE # Save chip-mosaic-ed image? 145 OVERSCAN BOOL TRUE # Overscan subtraction 146 BIAS BOOL FALSE # Bias subtraction 147 DARK BOOL TRUE # Dark subtraction 148 SHUTTER BOOL FALSE # Shutter correction 149 FLAT BOOL FALSE # Flat-field normalisation 150 MASK BOOL FALSE # Mask bad pixels 151 FRINGE BOOL FALSE # Fringe subtraction 152 PHOTOM BOOL FALSE # Source identification and photometry 153 ASTROM.CHIP BOOL FALSE # Astrometry per chip? 154 ASTROM.MOSAIC BOOL FALSE # Astrometry for mosaic? 155 BIN1.FITS BOOL TRUE # Save 1st binned chip image? 156 BIN2.FITS BOOL TRUE # Save 2nd binned chip image? 157 END 158 159 # Overscan, bias, dark, shutter 160 PPIMAGE_FLATPROC_PREMASK METADATA 161 BASE.FITS BOOL TRUE # Save base detrended image? 162 BASE.MASK.FITS BOOL TRUE # Save base detrended image? 163 BASE.VARIANCE.FITS BOOL TRUE # Save base detrended image? 164 CHIP.FITS BOOL FALSE # Save chip-mosaic-ed image? 165 CHIP.MASK.FITS BOOL FALSE # Save chip-mosaic-ed image? 166 CHIP.VARIANCE.FITS BOOL FALSE # Save chip-mosaic-ed image? 167 OVERSCAN BOOL TRUE # Overscan subtraction 168 BIAS BOOL FALSE # Bias subtraction 169 DARK BOOL TRUE # Dark subtraction 170 SHUTTER BOOL FALSE # Shutter correction 171 FLAT BOOL FALSE # Flat-field normalisation 172 MASK BOOL FALSE # Mask bad pixels 173 FRINGE BOOL FALSE # Fringe subtraction 174 PHOTOM BOOL FALSE # Source identification and photometry 175 ASTROM.CHIP BOOL FALSE # Astrometry per chip? 176 ASTROM.MOSAIC BOOL FALSE # Astrometry for mosaic? 177 BIN1.FITS BOOL TRUE # Save 1st binned chip image? 178 BIN2.FITS BOOL TRUE # Save 2nd binned chip image? 179 180 DETREND.CONSTRAINTS METADATA 181 DARK METADATA 182 DETTYPE STR DARK_PREMASK 183 END 184 END 154 185 END 155 186 -
branches/cnb_branches/cnb_branch_20090301/ippconfig/gpc1/ppMerge.config
r18252 r23352 21 21 DARK.ORDINATES METADATA 22 22 CELL.DARKTIME S32 1 23 CHIP.TEMP METADATA24 ORDER S32 125 SCALE BOOL TRUE26 MIN F32 -9527 MAX F32 -5028 END23 # CHIP.TEMP METADATA 24 # ORDER S32 1 25 # SCALE BOOL TRUE 26 # MIN F32 -95 27 # MAX F32 -50 28 # END 29 29 END -
branches/cnb_branches/cnb_branch_20090301/ippconfig/ipprc.config.in
r22215 r23352 3 3 # Default search path for configuration files (add $HOME if desired) 4 4 # Note: do not include $HOME in the distributed copy used by ippMonitor 5 # PATH STR @pkgdatadir@:$HOME/.ipp:. 6 PATH STR $HOME/ippconfig/:$PSCONFDIR/$PSCONFIG/share/ippconfig/ 5 PATH STR @pkgdatadir@ 6 ### This is a useful setting for an individual user: 7 #PATH STR $HOME/ippconfig/:$PSCONFDIR/$PSCONFIG/share/ippconfig/ 7 8 8 9 # load the site-specific information from here -
branches/cnb_branches/cnb_branch_20090301/ippconfig/megacam/psphot.config
r21070 r23352 14 14 SKY_CLIP_SIGMA F32 2.0 # statistic used to measure background 15 15 16 PSF_SN_LIM F32 100 # minimum S/N for stars used for PSF model16 PSF_SN_LIM F32 20 # minimum S/N for stars used for PSF model 17 17 PSF_MAX_NSTARS S32 300 # limit number of stars used for PSF model 18 18 … … 20 20 PSF_MODEL STR PS_MODEL_QGAUSS 21 21 22 MOMENTS_SN_MIN F32 30.0 22 PSF_MOMENTS_RADIUS F32 10.0 # calculate initial source moments with this radius 23 24 MOMENTS_SN_MIN F32 2.0 23 25 EXT_MIN_SN F32 50.0 # fit galaxies above this S/N limit 24 26 FULL_FIT_SN_LIM F32 50.0 25 AP_MIN_SN F32 50.0 26 27 # OUTPUT.FORMAT STR SMPDATA 28 OUTPUT.FORMAT STR PS1_DEV_1 27 AP_MIN_SN F32 2.0 29 28 30 29 PSF_SHAPE_NSIGMA F32 3.0 # max significance for shape variation -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/filerules-mef.mdc
r21370 r23352 98 98 PPSUB.INPUT.MASK INPUT @FILES FPA MASK 99 99 PPSUB.INPUT.VARIANCE INPUT @FILES FPA VARIANCE 100 PPSUB.INPUT.SOURCES INPUT @FILES FPA CMF 100 101 PPSUB.REF INPUT @FILES FPA IMAGE 101 102 PPSUB.REF.MASK INPUT @FILES FPA MASK 102 103 PPSUB.REF.VARIANCE INPUT @FILES FPA VARIANCE 103 PPSUB. SOURCESINPUT @FILES FPA CMF104 PPSUB.REF.SOURCES INPUT @FILES FPA CMF 104 105 105 106 ## files used by ppstack … … 128 129 PPIMAGE.OUT.WT.SPL OUTPUT {OUTPUT}.{CHIP.NAME}.wt.fits VARIANCE NONE CHIP TRUE SPLIT 129 130 PPIMAGE.OUTPUT.DETMASK OUTPUT {OUTPUT}.fits IMAGE MASK CHIP TRUE MEF 131 PPIMAGE.OUTPUT.DETREND OUTPUT {OUTPUT}.fits IMAGE COMP_DET CHIP TRUE MEF 130 132 PPIMAGE.OUTPUT.RESID OUTPUT {OUTPUT}.b0.fits IMAGE COMP_SUB CHIP TRUE MEF 131 133 PPIMAGE.CONFIG OUTPUT {OUTPUT}.{CHIP.NAME}.ppImage.mdc TEXT NONE CHIP TRUE NONE -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/filerules-simple.mdc
r21370 r23352 61 61 PPSUB.INPUT.MASK INPUT @FILES FPA MASK 62 62 PPSUB.INPUT.VARIANCE INPUT @FILES FPA VARIANCE 63 PPSUB.INPUT.SOURCES INPUT @FILES FPA CMF 63 64 PPSUB.REF INPUT @FILES FPA IMAGE 64 65 PPSUB.REF.MASK INPUT @FILES FPA MASK 65 66 PPSUB.REF.VARIANCE INPUT @FILES FPA VARIANCE 66 PPSUB. SOURCESINPUT @FILES FPA CMF67 PPSUB.REF.SOURCES INPUT @FILES FPA CMF 67 68 68 69 ## files used by ppstack … … 91 92 PPIMAGE.OUTPUT.VARIANCE OUTPUT {OUTPUT}.wt.fits VARIANCE NONE FPA TRUE SIMPLE 92 93 PPIMAGE.OUTPUT.DETMASK OUTPUT {OUTPUT}.fits IMAGE NONE FPA TRUE SIMPLE 94 PPIMAGE.OUTPUT.DETREND OUTPUT {OUTPUT}.fits IMAGE NONE FPA TRUE SIMPLE 93 95 PPIMAGE.OUTPUT.RESID OUTPUT {OUTPUT}.fits IMAGE NONE FPA TRUE SIMPLE 94 96 PPIMAGE.CONFIG OUTPUT {OUTPUT}.ppImage.mdc TEXT NONE FPA TRUE NONE -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/filerules-split.mdc
r21531 r23352 73 73 PPSUB.INPUT.MASK INPUT @FILES FPA MASK 74 74 PPSUB.INPUT.VARIANCE INPUT @FILES FPA VARIANCE 75 PPSUB.INPUT.SOURCES INPUT @FILES FPA CMF 75 76 PPSUB.REF INPUT @FILES FPA IMAGE 76 77 PPSUB.REF.MASK INPUT @FILES FPA MASK 77 78 PPSUB.REF.VARIANCE INPUT @FILES FPA VARIANCE 78 PPSUB. SOURCESINPUT @FILES FPA CMF79 PPSUB.REF.SOURCES INPUT @FILES FPA CMF 79 80 80 81 ## files used by ppstack … … 100 101 PPIMAGE.OUTPUT.VARIANCE OUTPUT {OUTPUT}.{CHIP.NAME}.wt.fits VARIANCE COMP_WT CHIP TRUE NONE 101 102 PPIMAGE.OUTPUT.DETMASK OUTPUT {OUTPUT}.{CHIP.NAME}.fits IMAGE DET_MASK CHIP TRUE NONE 103 PPIMAGE.OUTPUT.DETREND OUTPUT {OUTPUT}.{CHIP.NAME}.fits IMAGE COMP_DET CHIP TRUE NONE 102 104 PPIMAGE.OUTPUT.RESID OUTPUT {OUTPUT}.{CHIP.NAME}.fits IMAGE COMP_SUB CHIP TRUE NONE 103 105 PPIMAGE.CONFIG OUTPUT {OUTPUT}.{CHIP.NAME}.ppImage.mdc TEXT NONE CHIP TRUE NONE 104 105 #PPIMAGE.OUTPUT OUTPUT {OUTPUT}.{CHIP.NAME}.fits IMAGE NONE CHIP TRUE NONE106 #PPIMAGE.OUTPUT.MASK OUTPUT {OUTPUT}.{CHIP.NAME}.mk.fits MASK NONE CHIP TRUE NONE107 #PPIMAGE.OUTPUT.VARIANCE OUTPUT {OUTPUT}.{CHIP.NAME}.wt.fits VARIANCE NONE CHIP TRUE NONE108 #PPIMAGE.OUTPUT.DETMASK OUTPUT {OUTPUT}.{CHIP.NAME}.fits IMAGE NONE CHIP TRUE NONE109 106 110 107 PPIMAGE.CHIP OUTPUT {OUTPUT}.{CHIP.NAME}.ch.fits IMAGE COMP_IMG CHIP TRUE NONE … … 124 121 125 122 PPIMAGE.STATS OUTPUT {OUTPUT}.{CHIP.NAME}.stats STATS NONE CHIP TRUE NONE 126 123 127 124 ## note: these use the same output naming convention since they are used for different ppMerge runs 128 PPMERGE.OUTPUT.MASK OUTPUT {OUTPUT}.{CHIP.NAME}.fits MASK NONECHIP TRUE NONE125 PPMERGE.OUTPUT.MASK OUTPUT {OUTPUT}.{CHIP.NAME}.fits MASK DET_MASK CHIP TRUE NONE 129 126 PPMERGE.OUTPUT.BIAS OUTPUT {OUTPUT}.{CHIP.NAME}.fits IMAGE NONE CHIP TRUE NONE 130 127 PPMERGE.OUTPUT.DARK OUTPUT {OUTPUT}.{CHIP.NAME}.fits DARK NONE CHIP TRUE NONE -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/fitstypes.mdc
r21534 r23352 19 19 # STDEV.NUM(F32) is the number of standard deviations to the edge (when SCALING = STDEV_NEGATIVE|STDEV_POSITIVE) 20 20 # FLOAT(STR) is the name of a custom floating-point type 21 22 # Compressed detrend 23 COMP_FLAT METADATA 24 BITPIX S32 16 25 SCALING STR MANUAL 26 BSCALE F32 1.0 27 BZERO F32 32768.0 28 COMPRESSION STR RICE 29 TILE.X S32 0 30 TILE.Y S32 1 31 TILE.Z S32 1 32 NOISE S32 8 33 END 21 34 22 35 DET_IMAGE METADATA -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/jpeg.mdc
r19743 r23352 138 138 COLORMAP STR -greyscale 139 139 SCALE.MODE STR FRACTION 140 SCALE.MIN F32 0.9 5141 SCALE.MAX F32 1.0 5140 SCALE.MIN F32 0.99 141 SCALE.MAX F32 1.01 142 142 END 143 143 … … 145 145 COLORMAP STR -greyscale 146 146 SCALE.MODE STR FRACTION 147 SCALE.MIN F32 0.9 5148 SCALE.MAX F32 1.0 5147 SCALE.MIN F32 0.99 148 SCALE.MAX F32 1.01 149 149 END 150 150 END -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/ppImage.config
r21370 r23352 41 41 NONLIN.DATA STR nonlin.dat # Filename for lookup table 42 42 43 # Normalization class 44 NORM.CLASS STR FPA # How to find the per-class normalizations 45 43 46 OLDDARK BOOL FALSE # Use old-style darks? 44 47 … … 433 436 BIN1.FITS BOOL TRUE # Save 1st binned chip image? 434 437 BIN2.FITS BOOL TRUE # Save 2nd binned chip image? 438 END 439 440 # used for the pre-mask version of flat-field processing 441 PPIMAGE_FLATPROC_PREMASK METADATA 442 BASE.FITS BOOL TRUE # Save base detrended image? 443 BASE.MASK.FITS BOOL TRUE # Save base detrended image? 444 BASE.VARIANCE.FITS BOOL TRUE # Save base detrended image? 445 CHIP.FITS BOOL FALSE # Save chip-mosaic-ed image? 446 CHIP.MASK.FITS BOOL FALSE # Save chip-mosaic-ed image? 447 CHIP.VARIANCE.FITS BOOL FALSE # Save chip-mosaic-ed image? 448 OVERSCAN BOOL TRUE # Overscan subtraction 449 BIAS BOOL TRUE # Bias subtraction 450 DARK BOOL TRUE # Dark subtraction 451 SHUTTER BOOL FALSE # Shutter correction 452 FLAT BOOL FALSE # Flat-field normalisation 453 MASK BOOL FALSE # Mask bad pixels 454 FRINGE BOOL FALSE # Fringe subtraction 455 PHOTOM BOOL FALSE # Source identification and photometry 456 ASTROM.CHIP BOOL FALSE # Astrometry per chip? 457 ASTROM.MOSAIC BOOL FALSE # Astrometry for mosaic? 458 BIN1.FITS BOOL TRUE # Save 1st binned chip image? 459 BIN2.FITS BOOL TRUE # Save 2nd binned chip image? 460 461 DETREND.CONSTRAINTS METADATA 462 DARK METADATA 463 DETTYPE STR DARK_PREMASK 464 END 465 END 435 466 END 436 467 -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/ppStack.config
r21475 r23352 32 32 33 33 ZP.RADIUS F32 1.0 # Radius (pixels) for matching sources 34 ZP.ITER S32 1000 # Maximum iterations for zero point 34 ZP.ITER.1 S32 5 # Iterations for zero point; pass 1 35 ZP.ITER.2 S32 1000 # Iterations for zero point; pass 2 35 36 ZP.TOL F32 1.0e-6 # Tolerance for zero point iterations 36 37 ZP.TRANS.ITER S32 2 # Iterations for transparency determination 37 38 ZP.TRANS.REJ F32 3.0 # Rejection threshold for transparency determination 38 39 ZP.TRANS.THRESH F32 1.0 # Threshold for transparency determination 39 ZP.STAR.REJ F32 3.0 # Rejection threshold for stars 40 ZP.STAR.REJ.1 F32 20.0 # Rejection threshold for stars; pass 1 41 ZP.STAR.REJ.2 F32 3.0 # Rejection threshold for stars; pass 2 40 42 ZP.STAR.LIMIT F32 1.0e-2 # Limit on star rejection fraction for successful iteration 41 ZP.STAR.SYS F32 0.05 # Estimated systematic error 43 ZP.STAR.SYS.1 F32 0.10 # Estimated systematic error; pass 1 44 ZP.STAR.SYS.2 F32 0.05 # Estimated systematic error; pass 2 45 ZP.MATCH F32 0.3 # Fraction of images to match for good star 42 46 ZP.AIRMASS METADATA # Airmass terms by filter 43 47 g F32 0.0 -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/ppSub.config
r21370 r23352 5 5 SPATIAL.ORDER S32 0 # Spatial polynomial order 6 6 REGION.SIZE F32 0 # Iso-kernel region size (pixels) 7 SOURCE.RADIUS F32 3.0 # Source matching radius (pixels) 7 8 STAMP.SPACING F32 200 # Typical spacing between stamps (pixels) 8 9 STAMP.FOOTPRINT S32 20 # Size of stamps (pixels) -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/psphot.config
r21505 r23352 16 16 ZERO_PT F32 25.000 # zero point used by DVO 17 17 18 OUTPUT.FORMAT STR PS1_ DEV_118 OUTPUT.FORMAT STR PS1_V1 19 19 20 20 # these parameter govern how the background is measured -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/reductionClasses.mdc
r20745 r23352 31 31 32 32 # *** premask (unmasked) flat-field types 33 FLAT_PREMASK_PROCESS STR PPIMAGE_ OBDS33 FLAT_PREMASK_PROCESS STR PPIMAGE_FLATPROC_PREMASK 34 34 FLAT_PREMASK_RESID STR PPIMAGE_F 35 35 FLAT_PREMASK_VERIFY STR PPIMAGE_F 36 36 FLAT_PREMASK_STACK STR PPMERGE_FLAT 37 37 FLAT_PREMASK_JPEG_IMAGE STR FLAT 38 FLAT_PREMASK_JPEG_RESID STR EFLAT_RESID38 FLAT_PREMASK_JPEG_RESID STR FLAT_RESID 39 39 40 40 DOMEFLAT_PREMASK_PROCESS STR PPIMAGE_OBDS -
branches/cnb_branches/cnb_branch_20090301/magic/remove/src/streaksrelease.c
r21156 r23352 8 8 static void excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, double newMaskValue); 9 9 static void writeImages(streakFiles *sf, bool exciseImageCube); 10 static bool replicateOutputs(streakFiles *sfiles);11 10 12 11 int … … 252 251 // image data directly from psFits 253 252 readImage(sf->inImage, sf->extnum, sf->stage, false); 253 254 // astrom struct is only needed for raw stage, and only the chip to cell parameters are used 255 sf->astrom = streakSetAstrometry(sf->astrom, sf->stage, NULL, NULL, false, 256 sf->inImage->header, sf->inImage->numCols, sf->inImage->numRows); 254 257 } 255 258 sf->outImage->header = (psMetadata*) psMemIncrRefCounter(sf->inImage->header); … … 264 267 if (sf->inImage->image) { 265 268 setupImageRefs(sf->outImage, sf->recImage, sf->inImage, sf->extnum, exciseAll); 269 } else if (sf->inImage->imagecube) { 270 // Image cubes should have been excised in the destreaking process 271 streaksExit("unexpected imagecube found", PS_EXIT_CONFIG_ERROR); 266 272 } else { 267 // Image cubes are handeled specially273 return false; 268 274 } 269 275 … … 285 291 if (sf->inMask) { 286 292 readImage(sf->inMask, sf->extnum, sf->stage, true); 287 sf->outMask->header = (psMetadata*) psMemIncrRefCounter(sf->inMask->header); 288 if (sf->recMask) { 289 sf->recMask->header = (psMetadata*) psMemIncrRefCounter(sf->inMask->header); 290 } 291 setupImageRefs(sf->outMask, sf->recMask, sf->inMask, sf->extnum, exciseAll); 292 if (sf->outChMask) { 293 sf->outChMask->header = (psMetadata *) psMemIncrRefCounter(sf->outMask->header); 294 sf->outChMask->image = (psImage *) psMemIncrRefCounter(sf->outMask->image); 295 if (sf->recChMask) { 296 sf->recChMask->header = (psMetadata *) psMemIncrRefCounter(sf->recMask->header); 297 sf->recChMask->image = (psImage *) psMemIncrRefCounter(sf->recMask->image); 298 } 299 } 293 if (sf->outMask) { 294 sf->outMask->header = (psMetadata*) psMemIncrRefCounter(sf->inMask->header); 295 if (sf->recMask) { 296 sf->recMask->header = (psMetadata*) psMemIncrRefCounter(sf->inMask->header); 297 } 298 setupImageRefs(sf->outMask, sf->recMask, sf->inMask, sf->extnum, exciseAll); 299 if (sf->outChMask) { 300 sf->outChMask->header = (psMetadata *) psMemIncrRefCounter(sf->outMask->header); 301 sf->outChMask->image = (psImage *) psMemIncrRefCounter(sf->outMask->image); 302 if (sf->recChMask) { 303 sf->recChMask->header = (psMetadata *) psMemIncrRefCounter(sf->recMask->header); 304 sf->recChMask->image = (psImage *) psMemIncrRefCounter(sf->recMask->image); 305 } 306 } 300 307 301 308 #ifdef STREAKS_COMPRESS_OUTPUT 302 // XXX: see note above303 copyFitsOptions(sf->outMask, sf->recMask, sf->inMask);304 psFitsSetCompression(sf->outMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);305 if (sf->recMask) {306 psFitsSetCompression(sf->recMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);307 }308 if (sf->outChMask) {309 copyFitsOptions(sf->outChMask, sf->recChMask, sf->inMask);310 psFitsSetCompression(sf->outChMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);311 if (sf->recChMask) {312 psFitsSetCompression(sf->recChMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);313 }314 }309 // XXX: see note above 310 copyFitsOptions(sf->outMask, sf->recMask, sf->inMask); 311 psFitsSetCompression(sf->outMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0); 312 if (sf->recMask) { 313 psFitsSetCompression(sf->recMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0); 314 } 315 if (sf->outChMask) { 316 copyFitsOptions(sf->outChMask, sf->recChMask, sf->inMask); 317 psFitsSetCompression(sf->outChMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0); 318 if (sf->recChMask) { 319 psFitsSetCompression(sf->recChMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0); 320 } 321 } 315 322 #endif 323 } 316 324 } 317 325 … … 396 404 } 397 405 } 398 399 // for any of the outputs that are stored in Nebulous set their extended attributes400 // and replicate the files401 402 static bool403 replicateOutputs(streakFiles *sfiles)404 {405 bool status = false;406 407 // XXX: TODO: need a nebGetXatrr function, but there isn't one408 // another option would be to take the number of copies to be409 // created as an option. That way the system could decide410 // whether to replicate anything other than raw Image files411 void *xattr = NULL;412 413 if (!replicate(sfiles->outImage, xattr)) {414 psError(PM_ERR_SYS, false, "failed to replicate outImage.");415 return false;416 }417 418 #ifdef notyet419 // XXX: don't replicate mask and weight images until we can look up420 // the input's xattr. There may be a perl program that can getXattr421 if (sfiles->outMask) {422 // get xattr from input to see if we need to replicate423 if (!replicate(sfiles->outMask, xattr)) {424 psError(PM_ERR_SYS, false, "failed to replicate outImage.");425 return false;426 }427 }428 if (sfiles->outWeight) {429 // get xattr from input to see if we need to replicate430 if (!replicate(sfiles->outWeight, xattr)) {431 psError(PM_ERR_SYS, false, "failed to replicate outImage.");432 return false;433 }434 }435 #endif436 437 return true;438 }439 440 -
branches/cnb_branches/cnb_branch_20090301/magic/remove/src/streaksreplace.c
r21156 r23352 4 4 static bool readAndCopyToOutput(streakFiles *sf, bool restoreImageCube); 5 5 static void writeImages(streakFiles *sf, bool exciseImageCube); 6 static bool replicateOutputs(streakFiles *sfiles);7 6 static bool readAndCopyToOutput(streakFiles *sf, bool restoreImageCube); 8 7 … … 92 91 closeImages(sfiles); 93 92 94 // NOTE: from here on we can't just quit if something goes wrong.95 // especially if we're working at the raw stage96 97 93 if (!replicateOutputs(sfiles)) { 98 94 psError(PS_ERR_UNKNOWN, false, "failed to replicate output files"); … … 429 425 } 430 426 } 431 432 static bool replicateOutputs(streakFiles *sfiles)433 {434 bool status = false;435 436 // XXX: TODO: need a nebGetXatrr function, but there isn't one437 // another option would be to take the number of copies to be438 // created as an option. That way the system could decide439 // whether to replicate anything other than raw Image files440 void *xattr = NULL;441 442 if (!replicate(sfiles->outImage, xattr)) {443 psError(PM_ERR_SYS, false, "failed to replicate outImage.");444 return false;445 }446 447 #ifdef notyet448 // XXX: don't replicate mask and weight images until we can look up449 // the input's xattr. There may be a perl program that can getXattr450 if (sfiles->outMask) {451 // get xattr from input to see if we need to replicate452 if (!replicate(sfiles->outMask, xattr)) {453 psError(PM_ERR_SYS, false, "failed to replicate outImage.");454 return false;455 }456 }457 if (sfiles->outWeight) {458 // get xattr from input to see if we need to replicate459 if (!replicate(sfiles->outWeight, xattr)) {460 psError(PM_ERR_SYS, false, "failed to replicate outImage.");461 return false;462 }463 }464 #endif465 466 // replicate the recovery images (if in nebulous)467 // perhaps whether we do that or not should be configurable.468 // Sounds like we need a recipe469 470 return true;471 }472 -
branches/cnb_branches/cnb_branch_20090301/ppArith/src/Makefile.am
r15571 r23352 1 1 bin_PROGRAMS = ppArith 2 ppArith_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPARITH_CFLAGS) 2 3 # PPARITH_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 4 # PPARITH_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi` 5 # PPARITH_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 6 # 7 # # Force recompilation of ppArithVersion.c, since it gets the version information 8 # ppArithVersion.c: FORCE 9 # touch ppArith.c 10 # FORCE: ; 11 12 ppArith_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPARITH_CFLAGS) -DPPARITH_VERSION=$(SVN_VERSION) -DPPARITH_BRANCH=$(SVN_BRANCH) -DPPARITH_SOURCE=$(SVN_SOURCE) 3 13 ppArith_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PPARITH_LIBS) 4 14 -
branches/cnb_branches/cnb_branch_20090301/ppArith/src/ppArith.c
r21378 r23352 34 34 } 35 35 36 ppArithVersionPrint(); 37 36 38 if (!ppArithArguments(argc, argv, config)) { 37 39 psErrorStackPrint(stderr, "Error reading arguments.\n"); -
branches/cnb_branches/cnb_branch_20090301/ppArith/src/ppArith.h
r21244 r23352 22 22 * Parse the arguments 23 23 */ 24 bool ppArithArguments(int argc, char *argv[], ///< Command-line arguments 25 pmConfig *config ///< Configuration 24 bool ppArithArguments(int argc, char *argv[], ///< Command-line arguments 25 pmConfig *config ///< Configuration 26 26 ); 27 27 … … 29 29 * Parse the camera input 30 30 */ 31 bool ppArithCamera(pmConfig *config ///< Configuration 31 bool ppArithCamera(pmConfig *config ///< Configuration 32 32 ); 33 33 … … 35 35 * Loop over the FPA hierarchy 36 36 */ 37 bool ppArithLoop(pmConfig *config ///< Configuration 37 bool ppArithLoop(pmConfig *config ///< Configuration 38 38 ); 39 39 … … 41 41 * Perform arithmetic on the readout 42 42 */ 43 bool ppArithReadout(pmReadout *output, ///< Output readout 44 const pmReadout *input1, ///< Input readout 45 const pmReadout *input2, ///< Input readout 46 const pmConfig *config, ///< Configuration 47 const pmFPAview *view ///< View of readout on which to operate 43 bool ppArithReadout(pmReadout *output, ///< Output readout 44 const pmReadout *input1, ///< Input readout 45 const pmReadout *input2, ///< Input readout 46 const pmConfig *config, ///< Configuration 47 const pmFPAview *view ///< View of readout on which to operate 48 48 ); 49 49 50 50 /** 51 * Put the program version information into a metadata51 * Put the program version information into header 52 52 */ 53 void ppArithVersionMetadata(psMetadata *metadata ///< Metadatato populate53 bool ppArithVersionHeader(psMetadata *header ///< Header to populate 54 54 ); 55 56 /// Print version information 57 void ppArithVersionPrint(void); 55 58 56 59 ///@} -
branches/cnb_branches/cnb_branch_20090301/ppArith/src/ppArithLoop.c
r21378 r23352 113 113 hdu->header = psMetadataAlloc(); 114 114 } 115 ppArithVersion Metadata(hdu->header);115 ppArithVersionHeader(hdu->header); 116 116 lastHDU = hdu; 117 117 } -
branches/cnb_branches/cnb_branch_20090301/ppArith/src/ppArithVersion.c
r21378 r23352 22 22 #include "ppArith.h" 23 23 24 static const char *cvsTag = "$Name: not supported by cvs2svn $";///< CVS tag name 24 #ifndef PPARITH_VERSION 25 #error "PPARITH_VERSION is not set" 26 #endif 27 #ifndef PPARITH_BRANCH 28 #error "PPARITH_BRANCH is not set" 29 #endif 30 #ifndef PPARITH_SOURCE 31 #error "PPARITH_SOURCE is not set" 32 #endif 33 34 #define xstr(s) str(s) 35 #define str(s) #s 25 36 26 37 psString ppArithVersion(void) 27 38 { 28 psString version = NULL; // Version, to return 29 psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION); 30 return version; 39 char *value = NULL; 40 psStringAppend(&value, "%s@%s", xstr(PPARITH_BRANCH), xstr(PPARITH_VERSION)); 41 return value; 42 } 43 44 psString ppArithSource(void) 45 { 46 return psStringCopy(xstr(PPARITH_SOURCE)); 31 47 } 32 48 33 49 psString ppArithVersionLong(void) 34 50 { 35 psString version = ppArithVersion(); // Version, to return 36 psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag 37 psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__); 38 psFree(tag); 51 psString version = ppArithVersion(); // Version, to return 52 psString source = ppArithSource(); // Source 53 54 psStringPrepend(&version, "ppArith "); 55 psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__); 56 psFree(source); 57 58 #ifdef __OPTIMIZE__ 59 psStringAppend(&version, " optimised"); 60 #else 61 psStringAppend(&version, " unoptimised"); 62 #endif 63 39 64 return version; 65 }; 66 67 bool ppArithVersionHeader(psMetadata *header) 68 { 69 PS_ASSERT_METADATA_NON_NULL(header, false); 70 71 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 72 psString timeString = psTimeToISO(time); // The time in an ISO string 73 psFree(time); 74 psString history = NULL; // History string 75 psStringAppend(&history, "ppArith at %s", timeString); 76 psFree(timeString); 77 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history); 78 psFree(history); 79 80 psLibVersionHeader(header); 81 psModulesVersionHeader(header); 82 ppStatsVersionHeader(header); 83 84 psString version = ppArithVersion(); // Software version 85 psString source = ppArithSource(); // Software source 86 87 psStringPrepend(&version, "ppArith version: "); 88 psStringPrepend(&version, "ppArith source: "); 89 90 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version); 91 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source); 92 93 psFree(version); 94 psFree(source); 95 96 return true; 40 97 } 41 98 42 43 void ppArithVersionMetadata(psMetadata *metadata) 99 void ppArithVersionPrint(void) 44 100 { 45 PS_ASSERT_METADATA_NON_NULL(metadata,); 101 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 102 psString timeString = psTimeToISO(time); // The time in an ISO string 103 psFree(time); 104 psLogMsg("ppArith", PS_LOG_INFO, "ppArith at %s", timeString); 105 psFree(timeString); 46 106 47 107 psString pslib = psLibVersionLong();// psLib version … … 50 110 psString ppArith = ppArithVersionLong(); // ppArith version 51 111 52 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 53 psString timeString = psTimeToISO(time); // The time in an ISO string 54 psFree(time); 55 psString head = NULL; // Head string 56 psStringAppend(&head, "ppArith processing at %s. Component information:", timeString); 57 psFree(timeString); 112 psLogMsg("ppArith", PS_LOG_INFO, "%s", pslib); 113 psLogMsg("ppArith", PS_LOG_INFO, "%s", psmodules); 114 psLogMsg("ppArith", PS_LOG_INFO, "%s", ppStats); 115 psLogMsg("ppArith", PS_LOG_INFO, "%s", ppArith); 58 116 59 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");60 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");61 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");62 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, "");63 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppArith, "");64 65 psFree(head);66 117 psFree(pslib); 67 118 psFree(psmodules); -
branches/cnb_branches/cnb_branch_20090301/ppImage
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/cnb_branches/cnb_branch_20090215/ppImage merged eligible /trunk/ppImage merged eligible /branches/cnb_branch_20090215/ppImage 21495-22685 /branches/eam_branches/eam_branch_20090303/ppImage 23158-23228
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/cnb_branches/cnb_branch_20090301/ppImage/src/Makefile.am
r20774 r23352 4 4 ppImage.h 5 5 6 ppImage_CFLAGS = $(PPIMAGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSASTRO_CFLAGS) $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 6 #PPIMAGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 7 #PPIMAGE_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi` 8 #PPIMAGE_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 9 10 # Force recompilation of ppImageVersion.c, since it gets the version information 11 # ppImageVersion.c: FORCE 12 # touch ppImageVersion.c 13 # FORCE: ; 14 15 ppImage_CFLAGS = $(PPIMAGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSASTRO_CFLAGS) $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPIMAGE_VERSION=$(SVN_VERSION) -DPPIMAGE_BRANCH=$(SVN_BRANCH) -DPPIMAGE_SOURCE=$(SVN_SOURCE) 7 16 ppImage_LDFLAGS = $(PPIMAGE_LIBS) $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 8 17 ppImage_SOURCES = \ -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImage.c
r19928 r23352 21 21 exit(PS_EXIT_CONFIG_ERROR); 22 22 } 23 24 ppImageVersionPrint(); 23 25 24 26 // define recipe options -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImage.h
r21364 r23352 86 86 int remnanceSize; // Size for remnance detection 87 87 float remnanceThresh; // Threshold for remnance detection 88 89 char *normClass; // class to use for per-class normalization 88 90 } ppImageOptions; 89 91 … … 208 210 psString ppImageVersion(void); 209 211 212 /// Return software source 213 psString ppImageSource(void); 214 210 215 /// Return long version information 211 216 psString ppImageVersionLong(void); 212 217 213 /// Update the metadata with version information for all dependencies 214 void ppImageVersionMetadata(psMetadata *metadata ///< Metadata to update with version information 215 ); 218 /// Populate the header with version information for all dependencies 219 bool ppImageVersionHeader(psMetadata *metadata ///< Header to populate 220 ); 221 222 /// Print version information 223 void ppImageVersionPrint(void); 216 224 217 225 -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageArguments.c
r19943 r23352 14 14 fprintf(stderr, "\t-chip CHIPNUM: Only process this chip number.\n"); 15 15 fprintf(stderr, "\t-norm VALUE: Divide through by this value when done.\n"); 16 fprintf(stderr, "\t-normlist file.mdc: normalizations by class_id.\n"); 16 17 fprintf(stderr, "\n"); 17 18 fprintf(stderr, "Input options (single file / file list):\n"); … … 80 81 if ((argnum = psArgumentGet(argc, argv, "-visual"))) { 81 82 psArgumentRemove(argnum, &argc, argv); 82 psphotSetVisual(true);83 pmVisualSetVisual(true); 83 84 } 84 85 … … 86 87 if ((argnum = psArgumentGet(argc, argv, "-threads"))) { 87 88 psArgumentRemove(argnum, &argc, argv); 88 int nThreads = atoi(argv[argnum]);89 int nThreads = atoi(argv[argnum]); 89 90 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "NTHREADS", 0, "number of warp threads", nThreads); 90 91 psArgumentRemove(argnum, &argc, argv); 91 92 92 // create the thread pool with number of desired threads, supplying our thread launcher function93 // XXX need to determine the number of threads from the config data94 psThreadPoolInit (nThreads);93 // create the thread pool with number of desired threads, supplying our thread launcher function 94 // XXX need to determine the number of threads from the config data 95 psThreadPoolInit (nThreads); 95 96 } 96 97 … … 107 108 108 109 // the input file is a required argument; if not found, we will exit 109 bool status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list"); 110 if (!status) { 111 usage (); 112 } 110 pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list"); 113 111 114 112 // if these command-line options are supplied, load the file name lists into config->arguments … … 128 126 } 129 127 130 // Optional normali sation factor128 // Optional normalization factor 131 129 if ((argnum = psArgumentGet(argc, argv, "-norm"))) { 132 130 psArgumentRemove(argnum, &argc, argv); 133 131 float norm = atof(argv[argnum]); 134 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "NORMALI SATION", 0,132 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "NORMALIZATION", 0, 135 133 "Normalisation to apply", norm); 134 psArgumentRemove(argnum, &argc, argv); 135 } 136 137 // Optional per-class normalization table 138 if ((argnum = psArgumentGet(argc, argv, "-normlist"))) { 139 psArgumentRemove(argnum, &argc, argv); 140 141 unsigned int nFail = 0; 142 psMetadata *normlist = psMetadataConfigRead (NULL, &nFail, argv[argnum], false); 143 // XXX allow this file to be in nebulous? 144 145 psMetadataAddMetadata(config->arguments, PS_LIST_TAIL, "NORMALIZATION.TABLE", 0, "Normalization to apply", normlist); 146 psFree (normlist); 136 147 psArgumentRemove(argnum, &argc, argv); 137 148 } -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageDefineFile.c
r13562 r23352 5 5 # include "ppImage.h" 6 6 7 bool ppImageDefineFile (pmConfig *config, pmFPA *input, char *filerule, char *argname, pmFPAfileType fileType, pmDetrendType detrendType) { 7 bool ppImageDefineFile(pmConfig *config, pmFPA *input, char *filerule, char *argname, 8 pmFPAfileType fileType, pmDetrendType detrendType) 9 { 10 bool status; 11 pmFPAfile *file = NULL; // File to be defined 8 12 9 bool status; 10 pmFPAfile *file; 11 12 // look for the file on the argument list 13 file = pmFPAfileDefineFromArgs (&status, config, filerule, argname); 14 if (!status) { 15 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 16 return false; 13 if (!file) { 14 // look for the file on the RUN metadata 15 file = pmFPAfileDefineFromRun(&status, config, filerule); 16 if (!status) { 17 psError(PS_ERR_UNKNOWN, false, "failed to load file definition"); 18 return false; 19 } 17 20 } 18 if (file) { 19 if (file->type != fileType) { 20 psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType)); 21 return false; 22 } 23 return true; 21 if (!file) { 22 // look for the file on the argument list 23 file = pmFPAfileDefineFromArgs(&status, config, filerule, argname); 24 if (!status) { 25 psError(PS_ERR_UNKNOWN, false, "failed to load file definition"); 26 return false; 27 } 28 } 29 if (!file) { 30 // look for the file in the camera config table 31 file = pmFPAfileDefineFromConf(&status, config, filerule); 32 if (!status) { 33 psError(PS_ERR_UNKNOWN, false, "failed to load file definition"); 34 return false; 35 } 36 } 37 if (!file) { 38 // look for the file to be loaded from the detrend database 39 file = pmFPAfileDefineFromDetDB(&status, config, filerule, input, detrendType); 40 if (!status) { 41 psError(PS_ERR_UNKNOWN, false, "failed to load file definition"); 42 return false; 43 } 24 44 } 25 45 26 // look for the file in the camera config table 27 file = pmFPAfileDefineFromConf (&status, config, filerule); 28 if (!status) { 29 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 30 return false; 31 } 32 if (file) { 33 if (file->type != fileType) { 34 psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType)); 35 return false; 36 } 37 return true; 46 if (!file) { 47 return false; 38 48 } 39 49 40 // look for the file to be loaded from the detrend database 41 file = pmFPAfileDefineFromDetDB (&status, config, filerule, input, detrendType); 42 if (!status) { 43 psError (PS_ERR_UNKNOWN, false, "failed to load file definition"); 44 return false; 50 if (file->type != fileType) { 51 psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType)); 52 return false; 45 53 } 46 if (file) { 47 if (file->type != fileType) { 48 psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType)); 49 return false; 50 } 51 return true; 52 } 53 return false; 54 return true; 54 55 } 55 56 -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageDetrendReadout.c
r21364 r23352 54 54 if (!pmBiasSubtract(input, options->overscan, bias, oldDark, view)) { 55 55 psError(PS_ERR_UNKNOWN, false, "Unable to subtract bias."); 56 psFree(detview); 56 57 return false; 57 58 } … … 67 68 if (!pmDarkApply(input, dark, options->maskValue)) { 68 69 psError(PS_ERR_UNKNOWN, false, "Unable to subtract dark."); 70 psFree(detview); 69 71 return false; 70 72 } … … 75 77 options->remnanceSize, options->remnanceThresh)) { 76 78 psError(PS_ERR_UNKNOWN, false, "Unable to mask remnance."); 79 psFree(detview); 77 80 return false; 78 81 } … … 83 86 pmReadout *shutter = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.SHUTTER"); 84 87 if (!pmShutterCorrectionApply(input, shutter, pmConfigMaskGet("FLAT", config))) { 88 psFree(detview); 85 89 return false; 86 90 } … … 91 95 pmReadout *flat = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.FLAT"); 92 96 if (!pmFlatField(input, flat, options->flatMask)) { 97 psFree(detview); 93 98 return false; 94 99 } 95 100 } 96 101 97 // Normali sation by a(known) constant102 // Normalization by a single (known) constant 98 103 bool mdok; // Status of MD lookup 99 float norm = psMetadataLookupF32(&mdok, config->arguments, "NORMALI SATION");104 float norm = psMetadataLookupF32(&mdok, config->arguments, "NORMALIZATION"); 100 105 if (mdok && isfinite(norm) && norm != 1.0) { 101 106 pmHDU *hdu = pmHDUFromReadout(input); // HDU of interest … … 108 113 } 109 114 115 # if (1) 116 // Normalization by per-class values 117 psMetadata *normlist = psMetadataLookupMetadata(&mdok, config->arguments, "NORMALIZATION.TABLE"); 118 if (normlist) { 119 pmFPAfile *inputFile = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.INPUT"); 120 121 // get the menu of class IDs 122 psMetadata *menu = psMetadataLookupMetadata(&mdok, inputFile->camera, "CLASSID"); 123 if (!menu) { 124 psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration"); 125 psFree(detview); 126 return false; 127 } 128 // get the rule for class_id for the desired class 129 const char *rule = psMetadataLookupStr(&mdok, menu, options->normClass); 130 if (!rule) { 131 psError(PS_ERR_IO, false, "Unable to find NORM.CLASS value %s in CLASSID in camera configuration", options->normClass); 132 psFree(detview); 133 return false; 134 } 135 // get the class_id from the rule 136 char *classID = pmFPAfileNameFromRule(rule, inputFile, view); 137 if (!classID) { 138 psError(PS_ERR_IO, false, "error converting CLASSID rule %s to name\n", rule); 139 psFree(detview); 140 return false; 141 } 142 143 // get normalization from the class_id 144 float norm = psMetadataLookupF32 (&mdok, normlist, classID); 145 146 pmHDU *hdu = pmHDUFromReadout(input); // HDU of interest 147 psString comment = NULL; // Comment to add 148 psStringAppend(&comment, "Normalization: %f", norm); 149 psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, comment, ""); 150 psFree(comment); 151 152 // apply the normalization 153 psBinaryOp(input->image, input->image, "*", psScalarAlloc(norm, PS_TYPE_F32)); 154 155 psFree (classID); 156 } 157 # endif 158 110 159 if (options->doFringe) { 111 160 pmCell *fringe = pmFPAfileThisCell(config->files, detview, "PPIMAGE.FRINGE"); 112 161 if (!ppImageDetrendFringeMeasure(input, fringe, false, options)) { 162 psFree(detview); 113 163 return false; 114 164 } -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageLoop.c
r21183 r23352 25 25 } 26 26 27 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 28 if (dump_file) { 29 pmConfigCamerasCull(config, NULL); 30 pmConfigRecipesCull(config, "PPIMAGE,PPSTATS,PSPHOT,MASKS,PSASTRO"); 31 32 pmConfigDump(config, input->fpa, dump_file); 33 } 27 pmConfigCamerasCull(config, NULL); 28 pmConfigRecipesCull(config, "PPIMAGE,PPSTATS,PSPHOT,MASKS,PSASTRO,JPEG"); 34 29 35 30 pmFPAview *view = pmFPAviewAlloc(0);// View for level of interest … … 63 58 64 59 // Put version information into the header 65 pmHDU *hdu = pmHDU FromCell(cell);60 pmHDU *hdu = pmHDUGetHighest(input->fpa, chip, cell); 66 61 if (hdu && hdu != lastHDU) { 67 ppImageVersion Metadata(hdu->header);62 ppImageVersionHeader(hdu->header); 68 63 lastHDU = hdu; 69 64 } … … 96 91 } 97 92 98 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT99 if (!ppImageDetrendFree (config, view)) {100 ESCAPE("Unable to free detrend images");101 }93 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT 94 if (!ppImageDetrendFree (config, view)) { 95 ESCAPE("Unable to free detrend images"); 96 } 102 97 } 103 98 … … 105 100 ppImageDetrendRecord(cell, config, options, view); 106 101 } 107 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT108 if (!ppImageDetrendFree (config, view)) {109 ESCAPE("Unable to free detrend images");110 }111 } 112 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT113 if (!ppImageDetrendFree (config, view)) {114 ESCAPE("Unable to free detrend images");115 }102 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT 103 if (!ppImageDetrendFree (config, view)) { 104 ESCAPE("Unable to free detrend images"); 105 } 106 } 107 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT 108 if (!ppImageDetrendFree (config, view)) { 109 ESCAPE("Unable to free detrend images"); 110 } 116 111 117 112 // Apply the fringe correction … … 121 116 } 122 117 } 123 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT124 if (!ppImageFringeFree (config, view)) {125 ESCAPE("Unable to free fringe images");126 }118 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT 119 if (!ppImageFringeFree (config, view)) { 120 ESCAPE("Unable to free fringe images"); 121 } 127 122 128 123 // measure various pixel-based statistics for this image … … 152 147 } 153 148 154 // these may be used by ppImageSubtractBackground.155 // if these are defined as internal files, drop them here156 status = true;157 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL");158 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV");159 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND");160 if (!status) {161 psError(PSPHOT_ERR_PROG, false, "trouble dropping internal files");162 psFree (view);163 return false;164 }149 // these may be used by ppImageSubtractBackground. 150 // if these are defined as internal files, drop them here 151 status = true; 152 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL"); 153 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV"); 154 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND"); 155 if (!status) { 156 psError(PSPHOT_ERR_PROG, false, "trouble dropping internal files"); 157 psFree (view); 158 return false; 159 } 165 160 166 161 // binning (used for display) must take place after the background is replaced, if desired … … 219 214 } 220 215 psFree(view); 216 217 // Dump configuration 218 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 219 if (dump_file) { 220 pmConfigDump(config, input->fpa, dump_file); 221 } 221 222 222 223 // Write out summary statistics -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageOptions.c
r21364 r23352 81 81 options->remnanceThresh = 25.0; // Threshold for remnance detection 82 82 83 // per-class normalization source 84 options->normClass = NULL; // per-class normalizations refer to this class 85 83 86 return options; 84 87 } … … 278 281 options->remnanceThresh = psMetadataLookupS32(NULL, recipe, "REMNANCE.THRESH"); 279 282 283 // per-class normalization source (just a reference; don't free) 284 options->normClass = psMetadataLookupStr(NULL, recipe, "NORM.CLASS"); 285 280 286 return options; 281 287 } -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageParseCamera.c
r21364 r23352 9 9 bool status = false; 10 10 11 // the input image defines the camera, and all recipes and options the follow 12 pmFPAfile *input = pmFPAfileDefineFromArgs (&status, config, "PPIMAGE.INPUT", "INPUT"); 13 if (!status || !input) { 14 psError(PS_ERR_IO, false, "Failed to build FPA from PPIMAGE.INPUT"); 15 return NULL; 16 } 17 if (input->type != PM_FPA_FILE_IMAGE) { 18 psError(PS_ERR_IO, true, "PPIMAGE.INPUT is not of type IMAGE"); 19 return NULL; 20 } 21 22 // if MASK or VARIANCE was supplied on command line, bind files to 'input'. 23 // the mask and variance will be mosaicked with the image 24 pmFPAfile *inputMask = pmFPAfileBindFromArgs(&status, input, config, "PPIMAGE.INPUT.MASK", "PPIMAGE.INPUT.MASK"); 25 if (!status) { 26 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 27 return NULL; 28 } 29 if (inputMask) { 30 if (inputMask->type != PM_FPA_FILE_MASK) { 31 psError(PS_ERR_IO, true, "PPIMAGE.INPUT.MASK is not of type MASK"); 32 return NULL; 33 } 34 } 35 36 pmFPAfile *inputVariance = pmFPAfileBindFromArgs(&status, input, config, "PPIMAGE.INPUT.VARIANCE", "PPIMAGE.INPUT.VARIANCE"); 37 if (!status) { 38 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 39 return NULL; 40 } 41 if (inputVariance && inputVariance->type != PM_FPA_FILE_VARIANCE) { 42 psError(PS_ERR_IO, true, "PPIMAGE.INPUT.VARIANCE is not of type VARIANCE"); 43 return NULL; 44 } 11 if (!ppImageDefineFile(config, NULL, "PPIMAGE.INPUT", "INPUT", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_NONE)) { 12 psError(PS_ERR_IO, false, "Can't find an input image source"); 13 return NULL; 14 } 15 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.INPUT"); // Input file 16 psAssert(input, "We just put it there!"); 45 17 46 18 // add recipe options supplied on command line 47 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, RECIPE_NAME);19 psMetadata *recipe = psMetadataLookupPtr(&status, config->recipes, RECIPE_NAME); 48 20 49 21 // parse the options from the metadata format to the ppImageOptions structure 50 ppImageOptions *options = ppImageOptionsParse (config);22 ppImageOptions *options = ppImageOptionsParse(config); 51 23 52 24 // the following are defined from the argument list, if given, … … 54 26 // not all input or output images are used in a given recipe 55 27 if (options->doBias) { 56 if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.BIAS", "BIAS", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_BIAS)) { 57 psError (PS_ERR_IO, false, "Can't find a bias image source"); 58 psFree (options); 28 if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.BIAS", "BIAS", 29 PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_BIAS)) { 30 psError(PS_ERR_IO, false, "Can't find a bias image source"); 31 psFree(options); 59 32 return NULL; 60 33 } 61 34 } 62 35 if (options->doDark) { 63 if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.DARK", "DARK", PM_FPA_FILE_DARK, PM_DETREND_TYPE_DARK)) { 64 psError (PS_ERR_IO, false, "Can't find a dark image source"); 65 psFree (options); 36 if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.DARK", "DARK", 37 PM_FPA_FILE_DARK, PM_DETREND_TYPE_DARK)) { 38 psError(PS_ERR_IO, false, "Can't find a dark image source"); 39 psFree(options); 66 40 return NULL; 67 41 } 68 42 } 69 43 if (options->doMask) { 70 71 if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.MASK", "MASK", PM_FPA_FILE_MASK, PM_DETREND_TYPE_MASK)) { 72 psError (PS_ERR_IO, false, "Can't find a mask image source"); 73 psFree (options); 74 return NULL; 75 } 44 if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.MASK", "MASK", 45 PM_FPA_FILE_MASK, PM_DETREND_TYPE_MASK)) { 46 psError(PS_ERR_IO, false, "Can't find a mask image source"); 47 psFree(options); 48 return NULL; 49 } 50 51 #if 0 52 // I think this is now done automatically in the pmFPAfileDefine and pmFPAfileIOChecks -- PAP. 53 76 54 // XXX have ppImageDefineFile return the pmFPAfile? 77 55 pmFPAfile *mask = psMetadataLookupPtr(&status, config->files, "PPIMAGE.MASK"); 78 psAssert (mask, "mask not defined? not possible!");56 psAssert(mask, "Just defined the mask!"); 79 57 80 58 // Need to read the names of bit masks from the mask header and set them in the … … 84 62 // XXX need to load the mask bit names from one of the headers 85 63 // this grabs the first available hdu : no guarantee that it will be valid, though 86 pmHDU *hdu = pmHDUGetFirst (mask->fpa);64 pmHDU *hdu = pmHDUGetFirst(mask->fpa); 87 65 if (!hdu) { 88 66 psError(PS_ERR_IO, true, "no valid HDU for PPIMAGE.INPUT.MASK"); … … 90 68 } 91 69 // XXX is this consistent with the pmConfigMaskReadHeader call above? 92 if (!pmConfigMaskReadHeader (config, hdu->header)) {70 if (!pmConfigMaskReadHeader(config, hdu->header)) { 93 71 psError(PS_ERR_IO, false, "error in mask bits"); 94 72 return NULL; 95 73 } 96 74 } 75 #endif 97 76 } 98 77 if (options->doShutter) { 99 if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.SHUTTER", "SHUTTER", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_SHUTTER)) { 100 psError (PS_ERR_IO, false, "Can't find a shutter image source"); 101 psFree (options); 78 if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.SHUTTER", "SHUTTER", 79 PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_SHUTTER)) { 80 psError(PS_ERR_IO, false, "Can't find a shutter image source"); 81 psFree(options); 102 82 return NULL; 103 83 } … … 105 85 106 86 if (options->doFlat) { 107 if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.FLAT", "FLAT", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_FLAT)) { 108 psError (PS_ERR_IO, false, "Can't find a flat image source"); 109 psFree (options); 110 return NULL; 111 } 112 } 113 114 int nThreads = psMetadataLookupS32 (&status, config->arguments, "NTHREADS"); 87 if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.FLAT", "FLAT", 88 PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_FLAT)) { 89 psError(PS_ERR_IO, false, "Can't find a flat image source"); 90 psFree(options); 91 return NULL; 92 } 93 } 94 95 int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); 115 96 if (nThreads > 0) { 116 int nScanRows = psMetadataLookupS32 (&status, recipe, "SCAN.ROWS");117 pmDetrendSetThreadTasks (nScanRows);97 int nScanRows = psMetadataLookupS32(&status, recipe, "SCAN.ROWS"); 98 pmDetrendSetThreadTasks(nScanRows); 118 99 } 119 100 … … 166 147 skip_fringe: 167 148 if (options->doFringe) { 168 if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.FRINGE", "FRINGE", PM_FPA_FILE_FRINGE, PM_DETREND_TYPE_FRINGE)) { 149 if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.FRINGE", "FRINGE", 150 PM_FPA_FILE_FRINGE, PM_DETREND_TYPE_FRINGE)) { 169 151 psError (PS_ERR_IO, false, "Can't find a fringe image source"); 170 152 return NULL; … … 283 265 // define associated psphot input/output files 284 266 if (!psphotDefineFiles (config, psphotInput)) { 285 psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psphot"); 267 psError(PSPHOT_ERR_CONFIG, false, 268 "Trouble defining the additional input/output files for psphot"); 286 269 return false; 287 270 } … … 291 274 if (options->doAstromChip || options->doAstromMosaic) { 292 275 if (!options->doPhotom) { 293 psError (PSASTRO_ERR_CONFIG, false, "photometry mode is not selected; it is required for astrometry"); 276 psError(PSASTRO_ERR_CONFIG, false, 277 "Photometry mode is not selected; it is required for astrometry"); 294 278 return false; 295 279 } 296 280 297 pmFPAfile *psphotOutput = psMetadataLookupPtr (&status, config->files, "PSPHOT.OUTPUT");298 PS_ASSERT (psphotOutput, false);299 300 pmFPAfile *psastroInput = pmFPAfileDefineInput (config, psphotOutput->fpa, NULL, "PSASTRO.INPUT");301 PS_ASSERT (psastroInput, false);281 pmFPAfile *psphotOutput = psMetadataLookupPtr(&status, config->files, "PSPHOT.OUTPUT"); 282 PS_ASSERT(psphotOutput, false); 283 284 pmFPAfile *psastroInput = pmFPAfileDefineInput(config, psphotOutput->fpa, NULL, "PSASTRO.INPUT"); 285 PS_ASSERT(psastroInput, false); 302 286 psastroInput->mode = PM_FPA_MODE_REFERENCE; 303 287 304 288 // define associated psphot input/output files 305 if (!psastroDefineFiles (config, psastroInput)) { 306 psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psastro"); 289 if (!psastroDefineFiles(config, psastroInput)) { 290 psError(PSPHOT_ERR_CONFIG, false, 291 "Trouble defining the additional input/output files for psastro"); 307 292 return false; 308 293 } 309 294 310 295 // deactivate the psastro files, reactive when needed 311 pmFPAfileActivate (config->files, false, "PSASTRO.OUTPUT");296 pmFPAfileActivate(config->files, false, "PSASTRO.OUTPUT"); 312 297 } 313 298 … … 325 310 326 311 // outImage is used as a carrier: input to chipImage -> require the data to remain at the CHIP level 327 outImage->freeLevel = PS_MIN (outImage->freeLevel, PM_FPA_LEVEL_CHIP);312 outImage->freeLevel = PS_MIN(outImage->freeLevel, PM_FPA_LEVEL_CHIP); 328 313 outImage->dataLevel = outImage->freeLevel; 329 outImage->fileLevel = PS_MIN (outImage->fileLevel, outImage->dataLevel);314 outImage->fileLevel = PS_MIN(outImage->fileLevel, outImage->dataLevel); 330 315 331 316 // outMask and outVariance must be freed at the same level as outImage (all freed by pmFPAFreeData) … … 342 327 343 328 // the input data is the same as the outImage data : force the free levels to match 344 input->freeLevel = PS_MIN (outImage->freeLevel, input->freeLevel);329 input->freeLevel = PS_MIN(outImage->freeLevel, input->freeLevel); 345 330 346 331 // define the binned target files (which may just be carriers for some camera configurations) 347 pmFPAfile *bin1 = pmFPAfileDefineFromFPA (config, chipImage->fpa, options->xBin1, options->yBin1, "PPIMAGE.BIN1"); 332 pmFPAfile *bin1 = pmFPAfileDefineFromFPA(config, chipImage->fpa, options->xBin1, options->yBin1, 333 "PPIMAGE.BIN1"); 348 334 if (!bin1) { 349 335 psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.BIN1")); … … 357 343 } 358 344 359 pmFPAfile *bin2 = pmFPAfileDefineFromFPA (config, chipImage->fpa, options->xBin2, options->yBin2, "PPIMAGE.BIN2"); 345 pmFPAfile *bin2 = pmFPAfileDefineFromFPA(config, chipImage->fpa, options->xBin2, options->yBin2, 346 "PPIMAGE.BIN2"); 360 347 if (!bin2) { 361 348 psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.BIN2")); … … 373 360 bin2->freeLevel = PM_FPA_LEVEL_FPA; 374 361 375 pmFPAfile *jpg1 = pmFPAfileDefineOutput (config, byFPA1->fpa, "PPIMAGE.JPEG1");362 pmFPAfile *jpg1 = pmFPAfileDefineOutput(config, byFPA1->fpa, "PPIMAGE.JPEG1"); 376 363 if (!jpg1) { 377 364 psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.JPEG1")); … … 384 371 return NULL; 385 372 } 386 pmFPAfile *jpg2 = pmFPAfileDefineOutput (config, byFPA2->fpa, "PPIMAGE.JPEG2");373 pmFPAfile *jpg2 = pmFPAfileDefineOutput(config, byFPA2->fpa, "PPIMAGE.JPEG2"); 387 374 if (!jpg2) { 388 375 psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.JPEG2")); … … 404 391 // Chip selection: turn on only the chips specified (pass status to suppress missing-key log msg) 405 392 char *chipLine = psMetadataLookupStr(&status, config->arguments, "CHIP_SELECTIONS"); 406 psArray *chips = psStringSplitArray (chipLine, ",", false);393 psArray *chips = psStringSplitArray(chipLine, ",", false); 407 394 if (chips->n > 0) { 408 395 pmFPASelectChip (input->fpa, -1, true); // deselect all chips … … 454 441 if (psTraceGetLevel("ppImage.config") > 0) { 455 442 // Get a look inside all the files. 456 psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL); // Iterator443 psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL); 457 444 psMetadataItem *item; // Item from iteration 458 445 fprintf(stderr, "Files:\n"); -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageReplaceBackground.c
r21183 r23352 101 101 } 102 102 } 103 psImageBinning *binning = psMetadataLookupPtr(&status, psphotRecipe, "PSPHOT.BACKGROUND.BINNING"); // Binning for model 103 psImageBinning *binning = psMetadataLookupPtr(&status, modelRO->analysis, 104 "PSPHOT.BACKGROUND.BINNING"); // Binning for model 104 105 if (!binning) { 105 106 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find background binning"); -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageVersion.c
r14000 r23352 5 5 #include "ppImage.h" 6 6 7 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name 7 #ifndef PPIMAGE_VERSION 8 #error "PPIMAGE_VERSION is not set" 9 #endif 10 #ifndef PPIMAGE_BRANCH 11 #error "PPIMAGE_BRANCH is not set" 12 #endif 13 #ifndef PPIMAGE_SOURCE 14 #error "PPIMAGE_SOURCE is not set" 15 #endif 16 17 #define xstr(s) str(s) 18 #define str(s) #s 8 19 9 20 psString ppImageVersion(void) 10 21 { 11 psString version = NULL; // Version, to return 12 psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION); 13 return version; 22 char *value = NULL; 23 psStringAppend(&value, "%s@%s", xstr(PPIMAGE_BRANCH), xstr(PPIMAGE_VERSION)); 24 return value; 25 } 26 27 psString ppImageSource(void) 28 { 29 return psStringCopy (xstr(PPIMAGE_SOURCE)); 14 30 } 15 31 16 32 psString ppImageVersionLong(void) 17 33 { 18 psString version = ppImageVersion(); // Version, to return 19 psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag 20 psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__); 21 psFree(tag); 34 psString version = ppImageVersion(); // Version, to return 35 psString source = ppImageSource(); // Source 36 37 psStringPrepend(&version, "ppImage "); 38 psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__); 39 psFree(source); 40 41 #ifdef __OPTIMIZE__ 42 psStringAppend(&version, " optimised"); 43 #else 44 psStringAppend(&version, " unoptimised"); 45 #endif 46 22 47 return version; 48 }; 49 50 bool ppImageVersionHeader(psMetadata *header) 51 { 52 PS_ASSERT_METADATA_NON_NULL(header, false); 53 54 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 55 psString timeString = psTimeToISO(time); // The time in an ISO string 56 psFree(time); 57 psString history = NULL; // History string 58 psStringAppend(&history, "ppImage at %s", timeString); 59 psFree(timeString); 60 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history); 61 psFree(history); 62 63 psLibVersionHeader(header); 64 psModulesVersionHeader(header); 65 psphotVersionHeader(header); 66 psastroVersionHeader(header); 67 ppStatsVersionHeader(header); 68 69 psString version = ppImageVersion(); // ppImage software version 70 psString source = ppImageSource(); // ppImage software source 71 72 psStringPrepend(&version, "ppImage version: "); 73 psStringPrepend(&source, "ppImage source: "); 74 75 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version); 76 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source); 77 78 psFree(version); 79 psFree(source); 80 81 return true; 23 82 } 24 83 25 84 26 void ppImageVersion Metadata(psMetadata *metadata)85 void ppImageVersionPrint(void) 27 86 { 28 PS_ASSERT_METADATA_NON_NULL(metadata,); 87 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 88 psString timeString = psTimeToISO(time); // The time in an ISO string 89 psFree(time); 90 psLogMsg("ppImage", PS_LOG_INFO, "ppImage at %s", timeString); 91 psFree(timeString); 29 92 30 93 psString pslib = psLibVersionLong();// psLib version … … 35 98 psString ppImage = ppImageVersionLong(); // ppImage version 36 99 37 ps Time *time = psTimeGetNow(PS_TIME_TAI); // The time now38 ps String timeString = psTimeToISO(time); // The time in an ISO string39 ps Free(time);40 ps String head = NULL; // Head string41 ps StringAppend(&head, "ppImage processing at %s. Component information:", timeString);42 ps Free(timeString);100 psLogMsg("ppImage", PS_LOG_INFO, "%s", pslib); 101 psLogMsg("ppImage", PS_LOG_INFO, "%s", psmodules); 102 psLogMsg("ppImage", PS_LOG_INFO, "%s", psphot); 103 psLogMsg("ppImage", PS_LOG_INFO, "%s", psastro); 104 psLogMsg("ppImage", PS_LOG_INFO, "%s", ppStats); 105 psLogMsg("ppImage", PS_LOG_INFO, "%s", ppImage); 43 106 44 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");45 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");46 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");47 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psphot, "");48 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psastro, "");49 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, "");50 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppImage, "");51 52 psFree(head);53 107 psFree(pslib); 54 108 psFree(psmodules); -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/Makefile.am
r19586 r23352 1 1 bin_PROGRAMS = ppMerge 2 2 3 ppMerge_CFLAGS = $(PPMERGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 3 # PPMERGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 4 # PPMERGE_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi` 5 # PPMERGE_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 6 # 7 # # Force recompilation of ppMergeVersion.c, since it gets the version information 8 # ppMergeVersion.c: FORCE 9 # touch ppMergeVersion.c 10 # FORCE: ; 11 12 ppMerge_CFLAGS = $(PPMERGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPMERGE_VERSION=$(SVN_VERSION) -DPPMERGE_BRANCH=$(SVN_BRANCH) -DPPMERGE_SOURCE=$(SVN_SOURCE) 4 13 ppMerge_LDFLAGS = $(PPMERGE_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 5 14 … … 14 23 ppMergeLoop_Threaded.c \ 15 24 ppMergeSetThreads.c \ 16 ppMergeMask.c 25 ppMergeMask.c \ 26 ppMergeVersion.c 17 27 18 28 # ppMergeLoop.c -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMerge.c
r21244 r23352 38 38 goto die; 39 39 } 40 41 ppMergeVersionPrint(); 40 42 41 43 ppMergeType type = psMetadataLookupS32(NULL, config->arguments, "TYPE"); ///< Type of frame -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMerge.h
r21244 r23352 28 28 /// @{ 29 29 30 #define TIMERNAME "ppMerge" ///< Name for timer 31 #define PPMERGE_RECIPE "PPMERGE" ///< Recipe name 32 #define THREADED 1 ///< Compile with threads? 30 #define TIMERNAME "ppMerge" ///< Name for timer 31 #define PPMERGE_RECIPE "PPMERGE" ///< Recipe name 32 #define THREADED 1 ///< Compile with threads? 33 33 34 34 /** … … 36 36 */ 37 37 typedef enum { 38 PPMERGE_TYPE_UNKNOWN, ///< Unknown type 39 PPMERGE_TYPE_BIAS, ///< Bias frame 40 PPMERGE_TYPE_DARK, ///< (Multi-)Dark frame 41 PPMERGE_TYPE_MASK, ///< Mask frame 42 PPMERGE_TYPE_SHUTTER, ///< Shutter frame 38 PPMERGE_TYPE_UNKNOWN, ///< Unknown type 39 PPMERGE_TYPE_BIAS, ///< Bias frame 40 PPMERGE_TYPE_DARK, ///< (Multi-)Dark frame 41 PPMERGE_TYPE_MASK, ///< Mask frame 42 PPMERGE_TYPE_SHUTTER, ///< Shutter frame 43 43 PPMERGE_TYPE_FLAT, ///< Flat-field frame (dome or sky) 44 PPMERGE_TYPE_FRINGE, ///< Fringe frame 44 PPMERGE_TYPE_FRINGE, ///< Fringe frame 45 45 } ppMergeType; 46 46 … … 49 49 */ 50 50 typedef enum { 51 PPMERGE_FILES_ALL, ///< All files 52 PPMERGE_FILES_INPUT, ///< Input files 53 PPMERGE_FILES_OUTPUT ///< Output files 51 PPMERGE_FILES_ALL, ///< All files 52 PPMERGE_FILES_INPUT, ///< Input files 53 PPMERGE_FILES_OUTPUT ///< Output files 54 54 } ppMergeFiles; 55 55 … … 60 60 */ 61 61 typedef struct { 62 psArray *readouts; ///< Input readouts 63 bool read; ///< Has the scan been read? 64 bool busy; ///< Is the scan being processed? 65 int firstScan; ///< First row of the chunk to be read for this group 66 int lastScan; ///< Last row of the chunk to be read for this group 62 psArray *readouts; ///< Input readouts 63 bool read; ///< Has the scan been read? 64 bool busy; ///< Is the scan being processed? 65 int firstScan; ///< First row of the chunk to be read for this group 66 int lastScan; ///< Last row of the chunk to be read for this group 67 67 } ppMergeFileGroup; 68 68 … … 71 71 */ 72 72 bool ppMergeArguments(int argc, char *argv[], ///< Command-line arguments 73 pmConfig *config ///< Configuration 73 pmConfig *config ///< Configuration 74 74 ); 75 75 … … 77 77 * Set up camera files 78 78 */ 79 bool ppMergeCamera(pmConfig *config ///< Configuration 79 bool ppMergeCamera(pmConfig *config ///< Configuration 80 80 ); 81 81 … … 83 83 * Measure scale and zero-points 84 84 */ 85 bool ppMergeScaleZero(pmConfig *config ///< Configuration 85 bool ppMergeScaleZero(pmConfig *config ///< Configuration 86 86 ); 87 87 … … 89 89 * Main loop to do the merging 90 90 */ 91 bool ppMergeLoop(pmConfig *config ///< Configuration 91 bool ppMergeLoop(pmConfig *config ///< Configuration 92 92 ); 93 93 … … 95 95 * Main loop for masks 96 96 */ 97 bool ppMergeMask(pmConfig *config ///< Configuration 97 bool ppMergeMask(pmConfig *config ///< Configuration 98 98 ); 99 99 … … 101 101 * Read nominated input file 102 102 */ 103 bool ppMergeFileReadInput(pmConfig *config, ///< Configuration 104 pmReadout *readout, ///< Readout into which to read 105 int num, ///< Number of file in sequence 106 int rows ///< Number of rows to read at once 103 bool ppMergeFileReadInput(pmConfig *config, ///< Configuration 104 pmReadout *readout, ///< Readout into which to read 105 int num, ///< Number of file in sequence 106 int rows ///< Number of rows to read at once 107 107 ); 108 108 … … 110 110 * Open nominated input file 111 111 */ 112 bool ppMergeFileOpenInput(pmConfig *config, ///< Configuration 113 const pmFPAview *view, ///< View to open 114 int num ///< Number of file in sequence 112 bool ppMergeFileOpenInput(pmConfig *config, ///< Configuration 113 const pmFPAview *view, ///< View to open 114 int num ///< Number of file in sequence 115 115 ); 116 116 … … 166 166 bool ppMergeSetThreads(void); 167 167 168 169 /// Return software version 170 psString ppMergeVersion(void); 171 172 /// Return software source 173 psString ppMergeSource(void); 174 175 /// Return detailed software version information 176 psString ppMergeVersionLong(void); 177 178 /// Populate a FITS header with version information 179 bool ppMergeVersionHeader( 180 psMetadata *header ///< Header to populate 181 ); 182 183 /// Print version information 184 void ppMergeVersionPrint(void); 185 186 168 187 ///@} 169 188 #endif -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeLoop_Threaded.c
r21365 r23352 137 137 assert(output && output->fpa); 138 138 pmFPA *outFPA = output->fpa; ///< Output FPA 139 pmHDU *lastHDU = NULL; // Last HDU that was updated 139 140 int cellNum = 0; ///< Index of cell 140 141 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { … … 156 157 // No data here 157 158 continue; 159 } 160 161 // Update the header 162 { 163 pmHDU *hdu = pmHDUGetHighest(outFPA, outChip, outCell); // HDU for file 164 if (hdu && hdu != lastHDU) { 165 ppMergeVersionHeader(hdu->header); 166 lastHDU = hdu; 167 } 158 168 } 159 169 -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeMask.c
r21365 r23352 16 16 const pmFPAview *view, ///< View to chip 17 17 bool writeOut, ///< Write output? 18 pmHDU **lastHDU, ///< HDU last updated 18 19 psRandom *rng, ///< Random number generator 19 20 psMetadata *stats ///< Statistics output … … 96 97 i, inView->chip, inView->cell); 97 98 99 // Update the header 100 { 101 pmHDU *hdu = pmHDUGetHighest(outCell->parent->parent, outCell->parent, outCell); // File HDU 102 if (hdu && hdu != *lastHDU) { 103 ppMergeVersionHeader(hdu->header); 104 *lastHDU = hdu; 105 } 106 } 107 98 108 if (!pmFPAfileIOChecks(config, inView, PM_FPA_BEFORE)) { 99 109 psFree(inView); … … 359 369 360 370 pmFPAview *view = pmFPAviewAlloc(0); ///< View to component of interest 361 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); ///< Random number generator371 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); ///< Random number generator 362 372 363 373 psMetadata *stats = NULL; ///< Statistics for output … … 395 405 assert(output && output->fpa); 396 406 pmFPA *outFPA = output->fpa; ///< Output FPA 407 pmHDU *lastHDU = NULL; // Last HDU updated 397 408 398 409 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { … … 409 420 410 421 for (int i = 0; i < iter; i++) { 411 if (!mergeMask(config, view, (i == iter - 1), rng, stats)) {422 if (!mergeMask(config, view, (i == iter - 1), &lastHDU, rng, stats)) { 412 423 psError(PS_ERR_UNKNOWN, false, "Unable to merge chip %d", view->chip); 413 424 goto PPMERGE_MASK_ERROR; -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeScaleZero.c
r21365 r23352 51 51 break; 52 52 } 53 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); ///< Random number generator53 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); ///< Random number generator 54 54 pmFPAview *view = NULL; ///< View into FPA 55 55 -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeVersion.c
r21244 r23352 22 22 #include "ppMergeVersion.h" 23 23 24 static const char *cvsTag = "$Name: not supported by cvs2svn $";///< CVS tag name 24 #ifndef PPMERGE_VERSION 25 #error "PPMERGE_VERSION is not set" 26 #endif 27 #ifndef PPMERGE_BRANCH 28 #error "PPMERGE_BRANCH is not set" 29 #endif 30 #ifndef PPMERGE_SOURCE 31 #error "PPMERGE_SOURCE is not set" 32 #endif 33 34 #define xstr(s) str(s) 35 #define str(s) #s 25 36 26 37 psString ppMergeVersion(void) 27 38 { 28 psString version = NULL; ///< Version, to return 29 psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION); 30 return version; 39 char *value = NULL; 40 psStringAppend(&value, "%s@%s", xstr(PPMERGE_BRANCH), xstr(PPMERGE_VERSION)); 41 return value; 42 } 43 44 psString ppMergeSource(void) 45 { 46 return psStringCopy(xstr(PPMERGE_SOURCE)); 31 47 } 32 48 33 49 psString ppMergeVersionLong(void) 34 50 { 35 psString version = ppMergeVersion(); ///< Version, to return 36 psString tag = psStringStripCVS(cvsTag, "Name"); ///< CVS tag 37 psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__); 38 psFree(tag); 51 psString version = ppMergeVersion(); // Version, to return 52 psString source = ppMergeSource(); // Source 53 54 psStringPrepend(&version, "ppMerge "); 55 psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__); 56 psFree(source); 57 58 #ifdef __OPTIMIZE__ 59 psStringAppend(&version, " optimised"); 60 #else 61 psStringAppend(&version, " unoptimised"); 62 #endif 63 39 64 return version; 65 }; 66 67 bool ppMergeVersionHeader(psMetadata *header) 68 { 69 PS_ASSERT_METADATA_NON_NULL(header, false); 70 71 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 72 psString timeString = psTimeToISO(time); // The time in an ISO string 73 psFree(time); 74 psString history = NULL; // History string 75 psStringAppend(&history, "ppMerge at %s", timeString); 76 psFree(timeString); 77 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history); 78 psFree(history); 79 80 psLibVersionHeader(header); 81 psModulesVersionHeader(header); 82 ppStatsVersionHeader(header); 83 84 psString version = ppMergeVersion(); // Software version 85 psString source = ppMergeSource(); // Software source 86 87 psStringPrepend(&version, "ppMerge version: "); 88 psStringPrepend(&source, "ppMerge source: "); 89 90 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version); 91 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source); 92 93 psFree(version); 94 psFree(source); 95 96 return true; 40 97 } 41 98 42 43 void ppMergeVersionMetadata(psMetadata *metadata) 99 void ppMergeVersionPrint(void) 44 100 { 45 PS_ASSERT_METADATA_NON_NULL(metadata,); 46 47 psString pslib = psLibVersionLong();///< psLib version 48 psString psmodules = psModulesVersionLong(); ///< psModules version 49 psString ppStats = ppStatsVersionLong(); ///< ppStats version 50 psString ppMerge = ppMergeVersionLong(); ///< ppMerge version 51 52 psTime *time = psTimeGetNow(PS_TIME_TAI); ///< The time now 53 psString timeString = psTimeToISO(time); ///< The time in an ISO string 101 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 102 psString timeString = psTimeToISO(time); // The time in an ISO string 54 103 psFree(time); 55 psString head = NULL; ///< Head string 56 psStringAppend(&head, "ppMerge processing at %s. Component information:", timeString); 104 psLogMsg("ppMerge", PS_LOG_INFO, "ppMerge at %s", timeString); 57 105 psFree(timeString); 58 106 59 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, ""); 60 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, ""); 61 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, ""); 62 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, ""); 63 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppMerge, ""); 107 psString pslib = psLibVersionLong();// psLib version 108 psString psmodules = psModulesVersionLong(); // psModules version 109 psString ppStats = ppStatsVersionLong(); // ppStats version 110 psString ppMerge = ppMergeVersionLong(); // ppMerge version 64 111 65 psFree(head); 112 psLogMsg("ppImage", PS_LOG_INFO, "%s", pslib); 113 psLogMsg("ppImage", PS_LOG_INFO, "%s", psmodules); 114 psLogMsg("ppImage", PS_LOG_INFO, "%s", ppStats); 115 psLogMsg("ppImage", PS_LOG_INFO, "%s", ppMerge); 116 66 117 psFree(pslib); 67 118 psFree(psmodules); -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeVersion.h
r21244 r23352 20 20 21 21 /** 22 * Return software source 23 */ 24 psString ppMergeSource(void); 25 26 /** 22 27 * Return long version information 23 28 */ -
branches/cnb_branches/cnb_branch_20090301/ppSim/src/Makefile.am
r18011 r23352 1 1 bin_PROGRAMS = ppSim ppSimSequence 2 2 3 ppSim_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS) 3 # PPSIM_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 4 # PPSIM_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi` 5 # PPSIM_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 6 # 7 # # Force recompilation of ppSimVersion.c, since it gets the version information 8 # ppSimVersion.c: FORCE 9 # touch ppSimVersion.c 10 # FORCE: ; 11 12 ppSim_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS) -DPPSIM_VERSION=$(SVN_VERSION) -DPPSIM_BRANCH=$(SVN_BRANCH) -DPPSIM_SOURCE=$(SVN_SOURCE) 4 13 ppSim_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSPHOT_LIBS) $(PSASTRO_LIBS) 5 14 ppSim_SOURCES = \ … … 35 44 ppSimMosaicChip.c \ 36 45 ppSimRandomGaussian.c \ 37 ppSimBadPixels.c 46 ppSimBadPixels.c \ 47 ppSimVersion.c 38 48 39 49 ppSimSequence_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS) -
branches/cnb_branches/cnb_branch_20090301/ppSim/src/ppSim.h
r21183 r23352 19 19 20 20 // Compare a value with minimum and maximum values, replacing where required. 21 #define COMPARE(VALUE,MIN,MAX) { \22 if (VALUE < MIN) { MIN = VALUE; } \23 if (VALUE > MAX) { MAX = VALUE; } \21 #define COMPARE(VALUE,MIN,MAX) { \ 22 if (VALUE < MIN) { MIN = VALUE; } \ 23 if (VALUE > MAX) { MAX = VALUE; } \ 24 24 } 25 25 … … 147 147 float ppSimMagToFlux (float mag, float zp); 148 148 149 float ppSimArgToRecipeF32(bool *status, 150 psMetadata *options, // Target to which to add value151 const char *recipeName, // Name for value in the recipe152 psMetadata *arguments, // Command-line arguments153 const char *argName// Argument name in the command-line arguments149 float ppSimArgToRecipeF32(bool *status, 150 psMetadata *options, // Target to which to add value 151 const char *recipeName, // Name for value in the recipe 152 psMetadata *arguments, // Command-line arguments 153 const char *argName // Argument name in the command-line arguments 154 154 ); 155 155 156 156 int ppSimArgToRecipeS32(bool *status, 157 psMetadata *options, // Target to which to add value158 const char *recipeName, // Name for value in the recipe159 psMetadata *arguments, // Command-line arguments160 const char *argName// Argument name in the command-line arguments157 psMetadata *options, // Target to which to add value 158 const char *recipeName, // Name for value in the recipe 159 psMetadata *arguments, // Command-line arguments 160 const char *argName // Argument name in the command-line arguments 161 161 ); 162 162 163 163 char *ppSimArgToRecipeStr(bool *status, 164 psMetadata *options, // Target to which to add value165 const char *recipeName, // Name for value in the recipe166 psMetadata *arguments, // Command-line arguments167 const char *argName// Argument name in the command-line arguments164 psMetadata *options, // Target to which to add value 165 const char *recipeName, // Name for value in the recipe 166 psMetadata *arguments, // Command-line arguments 167 const char *argName // Argument name in the command-line arguments 168 168 ); 169 169 170 170 bool ppSimArgToRecipeBool(bool *status, 171 psMetadata *options, // Target to which to add value172 const char *recipeName, // Name for value in the recipe173 psMetadata *arguments, // Command-line arguments174 const char *argName// Argument name in the command-line arguments171 psMetadata *options, // Target to which to add value 172 const char *recipeName, // Name for value in the recipe 173 psMetadata *arguments, // Command-line arguments 174 const char *argName // Argument name in the command-line arguments 175 175 ); 176 176 … … 198 198 bool ppSimDefinePixels (psArray *sources, pmReadout *readout, psMetadata *recipe); 199 199 200 /// Return software version 201 psString ppSimVersion(void); 202 203 /// Return software source 204 psString ppSimSource(void); 205 206 /// Return long version information 207 psString ppSimVersionLong(void); 208 200 209 #endif -
branches/cnb_branches/cnb_branch_20090301/ppSim/src/ppSimBadPixels.c
r20910 r23352 74 74 } 75 75 76 psRandom *pseudoRNG = psRandomAlloc (PS_RANDOM_TAUS, seed); // Pseudo-random number generator76 psRandom *pseudoRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, seed); // Pseudo-random number generator 77 77 78 78 psImage *image = readout->image; // Image of interest -
branches/cnb_branches/cnb_branch_20090301/ppSim/src/ppSimLoop.c
r21365 r23352 25 25 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe 26 26 27 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); // Random number generator27 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 28 28 29 29 char *typeStr = psMetadataLookupStr(NULL, recipe, "IMAGE.TYPE"); // Type of image to simulate -
branches/cnb_branches/cnb_branch_20090301/ppSim/src/ppSimSequence.c
r19315 r23352 133 133 if (ppsim_recipe) psStringAppend (&ppSimCommand, " -recipe PPSIM %s", ppsim_recipe); 134 134 135 unsigned long seed = psMetadataLookupS32 (&status, config, "RND_SEED"); 136 if (!status) seed = 0; 137 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, seed); 135 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 138 136 139 137 psMetadataItem *item = psMetadataLookup (config, "SEQUENCE"); 140 138 if (item == NULL) { 141 139 psLogMsg ("ppSimSequence", PS_LOG_WARN, "missing SEQUENCE description"); 142 exit ( 1);140 exit (PS_EXIT_CONFIG_ERROR); 143 141 } 144 142 … … 170 168 } 171 169 172 // determine the camera for the sequence and define the ppSim command173 if (camera == NULL) {174 camera = psMetadataLookupStr (&status, sequence, "CAMERA");175 }176 177 psString injectCommandReal = NULL;178 psString ppSimCommandReal = NULL;179 180 psStringAppend (&injectCommandReal, "%s --camera %s", injectCommand, camera);181 psStringAppend (&ppSimCommandReal, "%s -camera %s", ppSimCommand, camera);170 // determine the camera for the sequence and define the ppSim command 171 if (camera == NULL) { 172 camera = psMetadataLookupStr (&status, sequence, "CAMERA"); 173 } 174 175 psString injectCommandReal = NULL; 176 psString ppSimCommandReal = NULL; 177 178 psStringAppend (&injectCommandReal, "%s --camera %s", injectCommand, camera); 179 psStringAppend (&ppSimCommandReal, "%s -camera %s", ppSimCommand, camera); 182 180 183 181 if (!strcasecmp (type, "BIAS")) { -
branches/cnb_branches/cnb_branch_20090301/ppStack
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/cnb_branches/cnb_branch_20090215/ppStack merged eligible /trunk/ppStack merged eligible /branches/cnb_branch_20090215/ppStack 21495-22685 /branches/eam_branches/eam_branch_20090303/ppStack 23158-23228
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/cnb_branches/cnb_branch_20090301/ppStack/src/Makefile.am
r19337 r23352 1 1 bin_PROGRAMS = ppStack 2 2 3 ppStack_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPSTATS_CFLAGS) $(PPSTACK_CFLAGS) 3 # PPSTACK_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 4 # PPSTACK_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi` 5 # PPSTACK_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 6 # 7 # # Force recompilation of ppStackVersion.c, since it gets the version information 8 # ppStackVersion.c: FORCE 9 # touch ppStackVersion.c 10 # FORCE: ; 11 12 ppStack_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPSTATS_CFLAGS) $(PPSTACK_CFLAGS) -DPPSTACK_VERSION=$(SVN_VERSION) -DPPSTACK_BRANCH=$(SVN_BRANCH) -DPPSTACK_SOURCE=$(SVN_SOURCE) 4 13 ppStack_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSPHOT_LIBS) $(PPSTATS_LIBS) $(PPSTACK_LIBS) 5 14 … … 8 17 ppStackArguments.c \ 9 18 ppStackCamera.c \ 19 ppStackFiles.c \ 10 20 ppStackLoop.c \ 11 21 ppStackPSF.c \ 12 22 ppStackReadout.c \ 13 ppStackPhotometry.c \14 23 ppStackVersion.c \ 15 24 ppStackMatch.c \ 16 25 ppStackSources.c \ 17 ppStackThread.c 26 ppStackThread.c \ 27 ppStackOptions.c \ 28 ppStackSetup.c \ 29 ppStackPrepare.c \ 30 ppStackConvolve.c \ 31 ppStackCombineInitial.c \ 32 ppStackReject.c \ 33 ppStackCombineFinal.c \ 34 ppStackCleanup.c \ 35 ppStackPhotometry.c \ 36 ppStackFinish.c 18 37 19 38 noinst_HEADERS = \ 20 ppStack.h 39 ppStack.h \ 40 ppStackLoop.h \ 41 ppStackOptions.h \ 42 ppStackThread.h 21 43 22 44 CLEANFILES = *~ -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStack.c
r21258 r23352 9 9 10 10 #include "ppStack.h" 11 #include "ppStackLoop.h" 11 12 12 13 #define TIMER_NAME "PPSTACK" // Name of timer … … 33 34 goto die; 34 35 } 36 37 ppStackVersionPrint(); 35 38 36 39 if (!pmModelClassInit()) { … … 74 77 pmConfigDone(); 75 78 psLibFinalize(); 76 79 pmVisualClose(); 77 80 exit(exitValue); 78 81 } -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStack.h
r21477 r23352 1 #ifndef PP _STACK_H2 #define PP _STACK_H1 #ifndef PPSTACK_H 2 #define PPSTACK_H 3 3 4 4 #define PPSTACK_RECIPE "PPSTACK" // Name of the recipe … … 10 10 // Mask values for inputs 11 11 typedef enum { 12 PPSTACK_MASK_MATCH = 0x01, // PSF-matching failed 13 PPSTACK_MASK_CHI2 = 0x02, // Chi^2 too deviant 14 PPSTACK_MASK_REJECT = 0x04, // Rejection failed 15 PPSTACK_MASK_BAD = 0x08, // Bad image (too many pixels rejected) 12 PPSTACK_MASK_CAL = 0x01, // Photometric calibration failed 13 PPSTACK_MASK_MATCH = 0x02, // PSF-matching failed 14 PPSTACK_MASK_CHI2 = 0x04, // Chi^2 too deviant 15 PPSTACK_MASK_REJECT = 0x08, // Rejection failed 16 PPSTACK_MASK_BAD = 0x10, // Bad image (too many pixels rejected) 16 17 PPSTACK_MASK_ALL = 0xff // All errors 17 18 } ppStackMask; 18 19 19 // Thread for stacking chunks 20 // 21 // Each input file contributes a readout, into which is read a chunk from that file 22 typedef struct { 23 psArray *readouts; // Input readouts to read and stack 24 bool read; // Has the scan been read? 25 bool busy; // Is the scan being processed? 26 int firstScan; // First row of the chunk to be read for this group 27 int lastScan; // Last row of the chunk to be read for this group 28 } ppStackThread; 20 // List of files 21 typedef enum { 22 PPSTACK_FILES_PREPARE, // Files for preparation 23 PPSTACK_FILES_CONVOLVE, // Files for convolution 24 PPSTACK_FILES_COMBINE, // Files for combination 25 PPSTACK_FILES_PHOT // Files for photometry 26 } ppStackFileList; 29 27 30 // Allocator31 ppStackThread *ppStackThreadAlloc(psArray *readouts // Inputs readouts to read and stack32 );33 34 // Data for threads35 typedef struct {36 psArray *threads; // Threads doing stacking37 int lastScan; // Last row that's been read38 psArray *imageFits; // FITS file pointers for images39 psArray *maskFits; // FITS file pointers for masks40 psArray *varianceFits; // FITS file pointers for variances41 } ppStackThreadData;42 43 // Set up thread data44 ppStackThreadData *ppStackThreadDataSetup(const psArray *cells, // Array of input cells45 const psArray *imageNames, // Names of images to read46 const psArray *maskNames, // Names of masks to read47 const psArray *varianceNames, // Names of variance maps to read48 const psArray *covariances, // Covariance matrices (already read)49 const pmConfig *config // Configuration50 );51 52 // Read chunk into the first available file thread53 ppStackThread *ppStackThreadRead(bool *status, // Status of read54 ppStackThreadData *stack, // Stacks available for reading55 pmConfig *config, // Configuration56 int numChunk, // Chunk number (only for interest)57 int overlap // Overlap between subsequent scans58 );59 60 // Initialise the threads61 void ppStackThreadInit(void);62 28 63 29 // Setup command-line arguments … … 74 40 ); 75 41 76 // Loop over the inputs, doing the combination77 bool ppStackLoop(pmConfig *config // Configuration78 );79 80 42 // Determine target PSF for input images 81 43 pmPSF *ppStackPSF(const pmConfig *config, // Configuration 82 44 int numCols, int numRows, // Size of image 83 const psArray *psfs // List of input PSFs 45 const psArray *psfs, // List of input PSFs 46 const psVector *inputMask // Mask for inputs 84 47 ); 85 48 … … 125 88 ); 126 89 127 // Perform photometry on stack128 bool ppStackPhotometry(pmConfig *config, // Configuration129 const pmReadout *readout, // Readout to be photometered130 const pmFPAview *view // View to readout131 );132 133 90 // Return software version 134 91 psString ppStackVersion(void); 92 93 /// Return software source 94 psString ppStackSource(void); 135 95 136 96 // Return long description of software version 137 97 psString ppStackVersionLong(void); 138 98 139 // Supplement metadatawith software version140 void ppStackVersionMetadata(psMetadata *metadata // Metadatato supplement99 // Supplement header with software version 100 bool ppStackVersionHeader(psMetadata *header // Header to supplement 141 101 ); 102 103 /// Print version information 104 void ppStackVersionPrint(void); 142 105 143 106 /// Convolve image to match specified seeing … … 158 121 /// Corrects the source PSF photometry to a common system. Return the sum of the exposure times. 159 122 float ppStackSourcesTransparency(const psArray *sourceLists, // Sources for each input 123 psVector *inputMask, // Indicates bad input 160 124 const pmFPAview *view, // View to readout 161 125 const pmConfig *config // Configuration 162 126 ); 163 127 128 /// Dump memory debugging information 129 void ppStackMemDump( 130 const char *name ///< Stage name, for inclusion in the output file name 131 ); 132 133 /// Activate/deactivate a list of files 134 void ppStackFileActivation( 135 pmConfig *config, // Configuration 136 ppStackFileList list, // Files to turn on/off 137 bool state // Activation state 138 ); 139 140 // Activate/deactivate a single element for a list 141 void ppStackFileActivationSingle( 142 pmConfig *config, // Configuration 143 ppStackFileList list, // Files to turn on/off 144 bool state, // Activation state 145 int num // Number of file in sequence 146 ); 147 148 /// Iterate down the hierarchy, loading files 149 /// 150 /// We can get away with this simplistic treatment of the FPA hierarchy because we're working on skycells. 151 pmFPAview *ppStackFilesIterateDown( 152 pmConfig *config // Configuration 153 ); 154 155 /// Iterate up the hierarchy, writing files 156 /// 157 /// We can get away with this simplistic treatment of the FPA hierarchy because we're working on skycells. 158 bool ppStackFilesIterateUp( 159 pmConfig *config // Configuration 160 ); 161 162 /// Write an image to a FITS file 163 bool ppStackWriteImage( 164 const char *name, // Name of image 165 psMetadata *header, // Header 166 const psImage *image, // Image 167 pmConfig *config // Configuration 168 ); 169 170 164 171 #endif -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackArguments.c
r21525 r23352 168 168 "Play safe with small numbers of pixels to combine?", false); 169 169 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-radius", 0, "Radius (pixels) for matching sources", NAN); 170 psMetadataAddS32(arguments, PS_LIST_TAIL, "-zp-iter", 0, "Maximum iterations for zero point", 0); 170 psMetadataAddS32(arguments, PS_LIST_TAIL, "-zp-iter-1", 0, "Maximum iterations for zero point; pass 1", 0); 171 psMetadataAddS32(arguments, PS_LIST_TAIL, "-zp-iter-2", 0, "Maximum iterations for zero point; pass 2", 0); 171 172 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-tol", 0, "Tolerance for zero point iterations", NAN); 172 173 psMetadataAddS32(arguments, PS_LIST_TAIL, "-zp-trans-iter", 0, "Iterations for transparency determination", 0); 173 174 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-trans-rej", 0, "Rejection threshold for transparency determination", NAN); 174 175 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-trans-thresh", 0, "Threshold for transparency determination", NAN); 175 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-rej", 0, "Rejection threshold for stars", NAN); 176 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-rej-1", 0, "Rejection threshold for stars; pass 1", NAN); 177 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-rej-2", 0, "Rejection threshold for stars; pass 2", NAN); 176 178 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-limit", 0, "Limit on star rejection fraction for successful iteration", NAN); 177 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-sys", 0, "Estimated systematic error", NAN); 179 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-sys-1", 0, "Estimated systematic error; pass 1", NAN); 180 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-sys-2", 0, "Estimated systematic error; pass 2", NAN); 178 181 psMetadataAddStr(arguments, PS_LIST_TAIL, "-temp-image", 0, "Suffix for temporary images", NULL); 179 182 psMetadataAddStr(arguments, PS_LIST_TAIL, "-temp-mask", 0, "Suffix for temporary masks", NULL); … … 182 185 "Delete temporary files on completion?", false); 183 186 psMetadataAddS32(arguments, PS_LIST_TAIL, "-threads", 0, "Number of threads to use", 0); 184 psMetadataAddBool(arguments, PS_LIST_TAIL, "- psphot-visual", 0, "psphot visualisation", 0);187 psMetadataAddBool(arguments, PS_LIST_TAIL, "-visual", 0, "visualisation", false); 185 188 186 189 if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 3) { … … 242 245 243 246 VALUE_ARG_RECIPE_FLOAT("-zp-radius", "ZP.RADIUS", F32); 244 VALUE_ARG_RECIPE_INT("-zp-iter", "ZP.ITER", S32, 0); 247 VALUE_ARG_RECIPE_INT("-zp-iter-1", "ZP.ITER.1", S32, 0); 248 VALUE_ARG_RECIPE_INT("-zp-iter-2", "ZP.ITER.2", S32, 0); 245 249 VALUE_ARG_RECIPE_FLOAT("-zp-tol", "ZP.TOL", F32); 246 250 VALUE_ARG_RECIPE_INT("-zp-trans-iter", "ZP.TRANS.ITER", S32, 0); 247 251 VALUE_ARG_RECIPE_FLOAT("-zp-trans-rej", "ZP.TRANS.REJ", F32); 248 252 VALUE_ARG_RECIPE_FLOAT("-zp-trans-thresh", "ZP.TRANS.THRESH", F32); 249 VALUE_ARG_RECIPE_FLOAT("-zp-star-rej", "ZP.STAR.REJ", F32); 253 VALUE_ARG_RECIPE_FLOAT("-zp-star-rej-1", "ZP.STAR.REJ.1", F32); 254 VALUE_ARG_RECIPE_FLOAT("-zp-star-rej-2", "ZP.STAR.REJ.2", F32); 250 255 VALUE_ARG_RECIPE_FLOAT("-zp-star-limit", "ZP.STAR.LIMIT", F32); 251 VALUE_ARG_RECIPE_FLOAT("-zp-star-sys", "ZP.STAR.SYS", F32); 256 VALUE_ARG_RECIPE_FLOAT("-zp-star-sys-1", "ZP.STAR.SYS.1", F32); 257 VALUE_ARG_RECIPE_FLOAT("-zp-star-sys-2", "ZP.STAR.SYS.2", F32); 252 258 253 259 VALUE_ARG_RECIPE_INT("-psf-instances", "PSF.INSTANCES", S32, 0); … … 255 261 VALUE_ARG_RECIPE_INT("-psf-order", "PSF.ORDER", S32, 0); 256 262 valueArgRecipeStr(arguments, recipe, "-psf-model", "PSF.MODEL", recipe); 263 264 if (psMetadataLookupBool(NULL, arguments, "-visual")) { 265 pmVisualSetVisual(true); 266 } 257 267 258 268 if (psMetadataLookupBool(NULL, arguments, "-photometry") || … … 290 300 if (dump_file) { 291 301 pmConfigCamerasCull(config, NULL); 292 pmConfigRecipesCull(config, "PPSTACK,PPSUB,PPSTATS,PSPHOT,MASKS ");302 pmConfigRecipesCull(config, "PPSTACK,PPSUB,PPSTATS,PSPHOT,MASKS,JPEG"); 293 303 294 304 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSTACK.INPUT"); // Input file -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackLoop.c
r21526 r23352 4 4 5 5 #include <stdio.h> 6 #include <unistd.h>7 #include <string.h>8 #include <libgen.h>9 6 #include <pslib.h> 10 7 #include <psmodules.h> 11 #include <ppStats.h>12 8 13 9 #include "ppStack.h" 14 15 //#define TESTING 16 17 #define WCS_TOLERANCE 0.001 // Tolerance for WCS 18 #define PIXELS_BUFFER 1024 // Initial size of pixel lists 19 20 // Here follows lists of files for activation/deactivation at various stages. Each must be NULL-terminated. 21 22 // Files required in preparation for convolution 23 static char *prepareFiles[] = { "PPSTACK.INPUT.PSF", "PPSTACK.INPUT.SOURCES", "PPSTACK.TARGET.PSF", NULL }; 24 25 // Files required for the convolution 26 static char *convolveFiles[] = { "PPSTACK.INPUT", "PPSTACK.INPUT.MASK", "PPSTACK.INPUT.VARIANCE", NULL }; 27 28 // Output files for the combination 29 static char *combineFiles[] = { "PPSTACK.OUTPUT", "PPSTACK.OUTPUT.MASK", "PPSTACK.OUTPUT.VARIANCE", 30 "PPSTACK.OUTPUT.JPEG1", "PPSTACK.OUTPUT.JPEG2", NULL }; 31 32 // Files for photometry 33 static char *photFiles[] = { "PSPHOT.INPUT", "PSPHOT.OUTPUT", "PSPHOT.RESID", "PSPHOT.BACKMDL", 34 "PSPHOT.BACKMDL.STDEV", "PSPHOT.BACKGND", "PSPHOT.BACKSUB", 35 "SOURCE.PLOT.MOMENTS", "SOURCE.PLOT.PSFMODEL", "SOURCE.PLOT.APRESID", 36 "PSPHOT.INPUT.CMF", NULL }; 37 38 static void memDump(const char *name) 39 { 40 return; 41 42 static int num = 0; // Counter, to make files unique and give an idea of sequence 43 44 psString filename = NULL; // Name of file 45 psStringAppend(&filename, "memdump_%s_%03d.txt", name, num); 46 FILE *memFile = fopen(filename, "w"); 47 psFree(filename); 48 49 psMemBlock **leaks = NULL; 50 int numLeaks = psMemCheckLeaks(0, &leaks, NULL, true); 51 fprintf(memFile, "# MemBlock Size Source\n"); 52 unsigned long total = 0; // Total memory used 53 for (int i = 0; i < numLeaks; i++) { 54 psMemBlock *mb = leaks[i]; 55 fprintf(memFile, "%12lu\t%12zd\t%s:%d\n", mb->id, mb->userMemorySize, 56 mb->file, mb->lineno); 57 total += mb->userMemorySize; 58 } 59 fclose(memFile); 60 psFree(leaks); 61 62 fprintf(stderr, "Memdump %s %d: Memory use: %ld, sbrk: %p\n", name, num, total, sbrk(0)); 63 num++; 64 } 65 66 67 68 // Activate/deactivate a list of files 69 static void fileActivation(pmConfig *config, // Configuration 70 char **files, // Files to turn on/off 71 bool state // Activation state 72 ) 73 { 74 assert(config); 75 assert(files); 76 77 for (int i = 0; files[i] != NULL; i++) { 78 pmFPAfileActivate(config->files, state, files[i]); 79 } 80 return; 81 } 82 83 // Activate/deactivate a single element for a list 84 static void fileActivationSingle(pmConfig *config, // Configuration 85 char **files, // Files to turn on/off 86 bool state, // Activation state 87 int num // Number of file in sequence 88 ) 89 { 90 assert(config); 91 assert(files); 92 93 for (int i = 0; files[i] != NULL; i++) { 94 pmFPAfileActivateSingle(config->files, state, files[i], num); // Activated file 95 } 96 return; 97 } 98 99 // Iterate down the hierarchy, loading files; we can get away with this because we're working on skycells 100 static pmFPAview *filesIterateDown(pmConfig *config // Configuration 101 ) 102 { 103 assert(config); 104 105 pmFPAview *view = pmFPAviewAlloc(0);// Pointer into FPA hierarchy 106 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 107 return NULL; 108 } 109 view->chip = 0; 110 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 111 return NULL; 112 } 113 view->cell = 0; 114 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 115 return NULL; 116 } 117 view->readout = 0; 118 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 119 return NULL; 120 } 121 return view; 122 } 123 124 // Iterate up the hierarchy, writing files; we can get away with this because we're working on skycells 125 static bool filesIterateUp(pmConfig *config // Configuration 126 ) 127 { 128 assert(config); 129 130 pmFPAview *view = pmFPAviewAlloc(0);// Pointer into FPA hierarchy 131 view->chip = view->cell = view->readout = 0; 132 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 133 return false; 134 } 135 view->readout = -1; 136 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 137 return false; 138 } 139 view->cell = -1; 140 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 141 return false; 142 } 143 view->chip = -1; 144 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 145 return false; 146 } 147 psFree(view); 148 return true; 149 } 150 151 // Write an image to a FITS file 152 static bool writeImage(const char *name, // Name of image 153 psMetadata *header, // Header 154 const psImage *image, // Image 155 pmConfig *config // Configuration 156 ) 157 { 158 assert(name); 159 assert(image); 160 161 psString resolved = pmConfigConvertFilename(name, config, true, true); // Resolved file name 162 psFits *fits = psFitsOpen(resolved, "w"); 163 if (!fits) { 164 psError(PS_ERR_IO, false, "Unable to open FITS file %s to write image.", resolved); 165 psFree(resolved); 166 return false; 167 } 168 if (!psFitsWriteImage(fits, header, image, 0, NULL)) { 169 psError(PS_ERR_IO, false, "Unable to write FITS image %s.", resolved); 170 psFitsClose(fits); 171 psFree(resolved); 172 return false; 173 } 174 psFitsClose(fits); 175 psFree(resolved); 176 return true; 177 } 178 10 #include "ppStackLoop.h" 179 11 180 12 bool ppStackLoop(pmConfig *config) … … 183 15 184 16 psTimerStart("PPSTACK_TOTAL"); 17 psTimerStart("PPSTACK_STEPS"); 185 18 186 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe 187 psAssert(recipe, "We've thrown an error on this before."); 19 ppStackOptions *options = ppStackOptionsAlloc(); // Options for stacking 188 20 189 bool mdok; // Status of MD lookup 190 bool tempDelete = psMetadataLookupBool(&mdok, recipe, "TEMP.DELETE"); // Delete temporary files? 191 const char *tempDir = psMetadataLookupStr(NULL, recipe, "TEMP.DIR"); // Directory for temporary images 192 if (!tempDir) { 193 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find TEMP.DIR in recipe"); 21 // Setup 22 psTrace("ppStack", 1, "Setup....\n"); 23 if (!ppStackSetup(options, config)) { 24 psError(PS_ERR_UNKNOWN, false, "Unable to setup."); 25 psFree(options); 26 return false; 27 } 28 psLogMsg("ppStack", PS_LOG_INFO, "Stage 0: Setup: %f sec", psTimerClear("PPSTACK_STEPS")); 29 ppStackMemDump("setup"); 30 31 32 // Preparation for stacking 33 psTrace("ppStack", 1, "Preparation for stacking: merging sources, determining target PSF....\n"); 34 if (!ppStackPrepare(options, config)) { 35 psError(PS_ERR_UNKNOWN, false, "Unable to prepare for stacking."); 36 psFree(options); 37 return false; 38 } 39 psLogMsg("ppStack", PS_LOG_INFO, "Stage 1: Load Sources and Generate Target PSF: %f sec", 40 psTimerClear("PPSTACK_STEPS")); 41 ppStackMemDump("prepare"); 42 43 44 // Convolve inputs 45 psTrace("ppStack", 1, "Convolving inputs to target PSF....\n"); 46 if (!ppStackConvolve(options, config)) { 47 psError(PS_ERR_UNKNOWN, false, "Unable to convolve images."); 48 psFree(options); 49 return false; 50 } 51 psLogMsg("ppStack", PS_LOG_INFO, "Stage 2: Generate Convolutions and Save: %f sec", 52 psTimerClear("PPSTACK_STEPS")); 53 ppStackMemDump("convolve"); 54 55 56 // Start threading 57 ppStackThreadInit(); 58 ppStackThreadData *stack = ppStackThreadDataSetup(options, config); 59 if (!stack) { 60 psError(PS_ERR_IO, false, "Unable to initialise stack threads."); 61 psFree(options); 194 62 return false; 195 63 } 196 64 197 psString outputName = psStringCopy(psMetadataLookupStr(NULL, config->arguments, "OUTPUT")); // Name for temporary files 198 const char *tempName = basename(outputName); 199 if (!tempName) { 200 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to construct basename for temporary files."); 65 // Initial combination 66 psTrace("ppStack", 1, "Initial stack of convolved images....\n"); 67 if (!ppStackCombineInitial(stack, options, config)) { 68 psError(PS_ERR_UNKNOWN, false, "Unable to perform initial combination."); 69 psFree(stack); 70 psFree(options); 201 71 return false; 202 72 } 73 psLogMsg("ppStack", PS_LOG_INFO, "Stage 2: Generate Convolutions and Save: %f sec", 74 psTimerClear("PPSTACK_STEPS")); 75 ppStackMemDump("convolve"); 76 psLogMsg("ppStack", PS_LOG_INFO, "Stage 4: Make Initial Stack: %f sec", psTimerClear("PPSTACK_STEPS")); 203 77 204 const char *tempImage = psMetadataLookupStr(NULL, recipe, "TEMP.IMAGE"); // Suffix for temporary images 205 const char *tempMask = psMetadataLookupStr(NULL, recipe, "TEMP.MASK"); // Suffix for temporary masks 206 const char *tempVariance = psMetadataLookupStr(NULL, recipe, "TEMP.VARIANCE"); // Suffix for temp variance maps 207 if (!tempImage || !tempMask || !tempVariance) { 208 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 209 "Unable to find TEMP.IMAGE, TEMP.MASK and TEMP.VARIANCE in recipe"); 78 79 // Pixel rejection 80 psTrace("ppStack", 1, "Reject pixels....\n"); 81 if (!ppStackReject(options, config)) { 82 psError(PS_ERR_UNKNOWN, false, "Unable to reject pixels."); 83 psFree(stack); 84 psFree(options); 210 85 return false; 211 86 } 87 psLogMsg("ppStack", PS_LOG_INFO, "Stage 5: Pixel Rejection: %f sec", psTimerClear("PPSTACK_STEPS")); 88 ppStackMemDump("reject"); 212 89 213 float threshold = psMetadataLookupF32(NULL, recipe, "THRESHOLD.MASK"); // Threshold for mask deconvolution214 float imageRej = psMetadataLookupF32(NULL, recipe, "IMAGE.REJ"); // Maximum fraction of image to reject215 // before rejecting entire image216 float poorFrac = psMetadataLookupF32(&mdok, recipe, "POOR.FRACTION"); // Fraction for "poor"217 218 const char *statsName = psMetadataLookupStr(&mdok, config->arguments, "STATS"); // Filename for statistics219 psMetadata *stats = NULL; // Container for statistics220 FILE *statsFile = NULL; // File stream for statistics221 if (statsName && strlen(statsName) > 0) {222 psString resolved = pmConfigConvertFilename(statsName, config, true, true); // Resolved filename223 statsFile = fopen(resolved, "w");224 if (!statsFile) {225 psError(PS_ERR_IO, true, "Unable to open statistics file %s for writing.\n", resolved);226 psFree(resolved);227 return false;228 } else {229 stats = psMetadataAlloc();230 }231 psFree(resolved);232 }233 234 pmFPAfile *output = psMetadataLookupPtr(NULL, config->files, "PPSTACK.OUTPUT"); // Output file235 if (!output) {236 psError(PS_ERR_UNEXPECTED_NULL, false, "Can't find output data!");237 return false;238 }239 int num = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs240 241 psMetadata *ppsub = psMetadataLookupMetadata(NULL, config->recipes, "PPSUB"); // PPSUB recipe242 int overlap = 2 * psMetadataLookupS32(NULL, ppsub,243 "KERNEL.SIZE"); // Overlap by kernel size between consecutive scans244 245 if (!pmConfigMaskSetBits(NULL, NULL, config)) {246 psError(PS_ERR_UNKNOWN, false, "Unable to determine mask value.");247 return false;248 }249 250 memDump("start");251 252 psLogMsg("ppStack", PS_LOG_INFO, "Stage 0 : Initialization and Configuration : %f sec", psTimerClear("PPSTACK_STEPS"));253 254 // Preparation iteration: Load the sources, and get a target PSF model255 psTrace("ppStack", 1, "Determining target PSF....\n");256 psArray *sourceLists = psArrayAlloc(num); // Individual lists of sources for matching257 pmPSF *targetPSF = NULL; // Target PSF258 float sumExposure = NAN; // Sum of exposure times259 if (psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) {260 pmFPAfileActivate(config->files, false, NULL);261 fileActivation(config, prepareFiles, true);262 pmFPAview *view = filesIterateDown(config);263 if (!view) {264 return false;265 }266 267 // Generate list of PSFs268 psMetadataIterator *fileIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD,269 "^PPSTACK.INPUT$"); // Iterator270 psMetadataItem *fileItem; // Item from iteration271 psArray *psfs = psArrayAlloc(num); // PSFs for PSF envelope272 int numCols = 0, numRows = 0; // Size of image273 int index = 0; // Index for file274 while ((fileItem = psMetadataGetAndIncrement(fileIter))) {275 assert(fileItem->type == PS_DATA_UNKNOWN);276 pmFPAfile *inputFile = fileItem->data.V; // An input file277 pmChip *chip = pmFPAviewThisChip(view, inputFile->fpa); // The chip: holds the PSF278 pmPSF *psf = psMetadataLookupPtr(NULL, chip->analysis, "PSPHOT.PSF"); // PSF279 if (!psf) {280 psError(PS_ERR_UNKNOWN, false, "Unable to find PSF.");281 psFree(view);282 psFree(sourceLists);283 psFree(fileIter);284 psFree(psfs);285 return false;286 }287 psfs->data[index] = psMemIncrRefCounter(psf);288 psMetadataRemoveKey(chip->analysis, "PSPHOT.PSF");289 290 pmCell *cell = pmFPAviewThisCell(view, inputFile->fpa); // Cell of interest291 pmHDU *hdu = pmHDUFromCell(cell);292 assert(hdu && hdu->header);293 int naxis1 = psMetadataLookupS32(NULL, hdu->header, "NAXIS1"); // Number of columns294 int naxis2 = psMetadataLookupS32(NULL, hdu->header, "NAXIS2"); // Number of rows295 if (naxis1 <= 0 || naxis2 <= 0) {296 psError(PS_ERR_UNKNOWN, false, "Unable to determine size of image from PSF.");297 psFree(view);298 psFree(sourceLists);299 psFree(fileIter);300 psFree(psfs);301 return false;302 }303 if (numCols == 0 && numRows == 0) {304 numCols = naxis1;305 numRows = naxis2;306 }307 308 pmReadout *ro = pmFPAviewThisReadout(view, inputFile->fpa); // Readout with sources309 psArray *sources = psMetadataLookupPtr(NULL, ro->analysis, "PSPHOT.SOURCES"); // Sources310 if (!sources) {311 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find sources in readout.");312 return NULL;313 }314 sourceLists->data[index] = psMemIncrRefCounter(sources);315 316 // Re-do photometry if we don't trust the source lists317 if (psMetadataLookupBool(NULL, recipe, "PHOT")) {318 psTrace("ppStack", 2, "Photometering input %d of %d....\n", index, num);319 pmFPAfileActivate(config->files, false, NULL);320 fileActivationSingle(config, convolveFiles, true, index);321 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", index); // File322 pmFPAview *view = filesIterateDown(config);323 if (!view) {324 psFree(sourceLists);325 psFree(targetPSF);326 return false;327 }328 329 pmReadout *ro = pmFPAviewThisReadout(view, file->fpa); // Readout of interest330 331 if (!ppStackInputPhotometry(ro, sources, config)) {332 psError(PS_ERR_UNKNOWN, false, "Unable to do photometry on input sources");333 psFree(sourceLists);334 psFree(targetPSF);335 return false;336 }337 338 psFree(view);339 if (!filesIterateUp(config)) {340 psFree(sourceLists);341 psFree(targetPSF);342 return false;343 }344 pmFPAfileActivate(config->files, false, NULL);345 fileActivation(config, prepareFiles, true);346 }347 348 index++;349 }350 psFree(fileIter);351 352 // Zero point calibration353 sumExposure = ppStackSourcesTransparency(sourceLists, view, config);354 if (!isfinite(sumExposure) || sumExposure <= 0) {355 psError(PS_ERR_UNKNOWN, false, "Unable to calculate transparency differences");356 psFree(sourceLists);357 psFree(targetPSF);358 return false;359 }360 361 // Generate target PSF362 targetPSF = ppStackPSF(config, numCols, numRows, psfs);363 psFree(psfs);364 if (!targetPSF) {365 psError(PS_ERR_UNKNOWN, false, "Unable to determine output PSF.");366 psFree(sourceLists);367 psFree(view);368 return false;369 }370 psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "PSF.TARGET", PS_DATA_UNKNOWN,371 "Target PSF for stack", targetPSF);372 373 pmChip *outChip = pmFPAviewThisChip(view, output->fpa); // Output chip374 psMetadataAddPtr(outChip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN,375 "Target PSF", targetPSF);376 outChip->data_exists = true;377 378 psFree(view);379 if (!filesIterateUp(config)) {380 return false;381 }382 }383 384 psLogMsg("ppStack", PS_LOG_INFO, "Stage 1 : Load Sources and Generate Target PSF : %f sec", psTimerClear("PPSTACK_STEPS"));385 memDump("psf");386 387 psArray *imageNames = psArrayAlloc(num);388 psArray *maskNames = psArrayAlloc(num);389 psArray *varianceNames = psArrayAlloc(num);390 for (int i = 0; i < num; i++) {391 psString imageName = NULL, maskName = NULL, varianceName = NULL; // Names for convolved images392 psStringAppend(&imageName, "%s/%s.%d.%s", tempDir, tempName, i, tempImage);393 psStringAppend(&maskName, "%s/%s.%d.%s", tempDir, tempName, i, tempMask);394 psStringAppend(&varianceName, "%s/%s.%d.%s", tempDir, tempName, i, tempVariance);395 psTrace("ppStack", 5, "Temporary files: %s %s %s\n", imageName, maskName, varianceName);396 imageNames->data[i] = imageName;397 maskNames->data[i] = maskName;398 varianceNames->data[i] = varianceName;399 }400 // Free the outputName that we grabbed above to set up tempName.401 psFree(outputName);402 403 // Generate convolutions and write them to disk404 psTrace("ppStack", 1, "Convolving inputs to target PSF....\n");405 psArray *cells = psArrayAlloc(num); // Cells for convolved images --- a handle for reading again406 psArray *subKernels = psArrayAlloc(num); // Subtraction kernels --- required in the stacking407 psArray *subRegions = psArrayAlloc(num); // Subtraction regions --- required in the stacking408 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); // Random number generator409 int numGood = 0; // Number of good frames410 int numCols = 0, numRows = 0; // Size of image411 psVector *inputMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for inputs412 psVectorInit(inputMask, 0);413 psVector *matchChi2 = psVectorAlloc(num, PS_TYPE_F32); // chi^2 for stamps when matching414 psVectorInit(matchChi2, NAN);415 psVector *weightings = psVectorAlloc(num, PS_TYPE_F32); // Combination weightings for images (1/noise^2)416 psVectorInit(weightings, NAN);417 psList *fpaList = psListAlloc(NULL); // List of input FPAs, for concept averaging418 psList *cellList = psListAlloc(NULL); // List of input cells, for concept averaging419 psArray *covariances = psArrayAlloc(num); // Covariance matrices420 for (int i = 0; i < num; i++) {421 psTrace("ppStack", 2, "Convolving input %d of %d to target PSF....\n", i, num);422 pmFPAfileActivate(config->files, false, NULL);423 fileActivationSingle(config, convolveFiles, true, i);424 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", i); // File of interest425 pmFPAview *view = filesIterateDown(config);426 if (!view) {427 psFree(sourceLists);428 psFree(targetPSF);429 psFree(rng);430 psFree(inputMask);431 psFree(matchChi2);432 psFree(fpaList);433 psFree(cellList);434 psFree(covariances);435 return false;436 }437 438 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); // Input readout439 psFree(view);440 441 if (numCols == 0 && numRows == 0) {442 numCols = readout->image->numCols;443 numRows = readout->image->numRows;444 } else if (numCols != readout->image->numCols || numRows != readout->image->numRows) {445 psError(PS_ERR_UNKNOWN, true, "Sizes of input images don't match: %dx%d vs %dx%d",446 readout->image->numCols, readout->image->numRows, numCols, numRows);447 psFree(sourceLists);448 psFree(targetPSF);449 psFree(rng);450 psFree(inputMask);451 psFree(matchChi2);452 psFree(fpaList);453 psFree(cellList);454 psFree(covariances);455 return false;456 }457 458 // Background subtraction, scaling and normalisation is performed automatically by the image matching459 psArray *regions = NULL, *kernels = NULL; // Regions and kernels used in subtraction460 psTimerStart("PPSTACK_MATCH");461 462 if (!ppStackMatch(readout, ®ions, &kernels, &matchChi2->data.F32[i], &weightings->data.F32[i],463 sourceLists->data[i], targetPSF, rng, config)) {464 psErrorStackPrint(stderr, "Unable to match image %d --- ignoring.", i);465 inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_MATCH;466 psErrorClear();467 continue;468 }469 covariances->data[i] = psMemIncrRefCounter(readout->covariance);470 471 if (stats) {472 pmSubtractionKernels *kernels = psMetadataLookupPtr(NULL, readout->analysis,473 PM_SUBTRACTION_ANALYSIS_KERNEL);// Conv kernel474 psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_MATCH", PS_META_DUPLICATE_OK,475 "Time to match PSF", psTimerMark("PPSTACK_MATCH"));476 psMetadataAddF32(stats, PS_LIST_TAIL, "STAMP.MEAN", PS_META_DUPLICATE_OK,477 "Mean deviation for stamps", kernels->mean);478 psMetadataAddF32(stats, PS_LIST_TAIL, "STAMP.RMS", PS_META_DUPLICATE_OK,479 "RMS deviation for stamps", kernels->rms);480 psMetadataAddF32(stats, PS_LIST_TAIL, "STAMP.NUM", PS_META_DUPLICATE_OK,481 "Number of stamps", kernels->numStamps);482 float deconv = psMetadataLookupF32(NULL, readout->analysis,483 PM_SUBTRACTION_ANALYSIS_DECONV_MAX); // Deconvolution fraction484 psMetadataAddF32(stats, PS_LIST_TAIL, "KERNEL.DECONV", PS_META_DUPLICATE_OK,485 "Deconvolution fraction for kernel", deconv);486 psMetadataAddF32(stats, PS_LIST_TAIL, "PPSTACK.WEIGHTING", PS_META_DUPLICATE_OK,487 "Weighting for image", weightings->data.F32[i]);488 }489 psLogMsg("ppStack", PS_LOG_INFO, "Time to match image %d: %f sec", i, psTimerClear("PPSTACK_MATCH"));490 491 subRegions->data[i] = regions;492 subKernels->data[i] = kernels;493 494 // Write the temporary convolved files495 pmHDU *hdu = readout->parent->parent->parent->hdu; // HDU for convolved image496 assert(hdu);497 writeImage(imageNames->data[i], hdu->header, readout->image, config);498 psMetadata *maskHeader = psMetadataCopy(NULL, hdu->header); // Copy of header, for mask499 pmConfigMaskWriteHeader(config, maskHeader);500 writeImage(maskNames->data[i], maskHeader, readout->mask, config);501 psFree(maskHeader);502 psImageCovarianceTransfer(readout->variance, readout->covariance);503 writeImage(varianceNames->data[i], hdu->header, readout->variance, config);504 #ifdef TESTING505 {506 psString name = NULL;507 psStringAppend(&name, "covariance_%d.fits", i);508 writeImage(name, hdu->header, readout->covariance->image, config);509 psFree(name);510 }511 #endif512 513 pmCell *inCell = readout->parent; // Input cell514 515 psListAdd(cellList, PS_LIST_TAIL, inCell);516 psListAdd(fpaList, PS_LIST_TAIL, inCell->parent->parent);517 518 cells->data[i] = psMemIncrRefCounter(inCell);519 if (!filesIterateUp(config)) {520 psFree(fpaList);521 psFree(cellList);522 psFree(covariances);523 return false;524 }525 numGood++;526 527 memDump("match");528 }529 psFree(sourceLists);530 psFree(targetPSF);531 psFree(rng);532 533 psLogMsg("ppStack", PS_LOG_INFO, "Stage 2 : Generate Convolutions and Save : %f sec", psTimerClear("PPSTACK_STEPS"));534 535 if (numGood == 0) {536 psError(PS_ERR_UNKNOWN, false, "No good images to combine.");537 psFree(subKernels);538 psFree(subRegions);539 psFree(cells);540 psFree(inputMask);541 psFree(matchChi2);542 psFree(fpaList);543 psFree(cellList);544 psFree(covariances);545 return false;546 }547 548 549 // Update concepts for output550 {551 pmFPAview view; // View for output552 view.chip = view.cell = view.readout = 0;553 pmCell *outCell = pmFPAfileThisCell(config->files, &view, "PPSTACK.OUTPUT"); // Output cell554 pmFPA *outFPA = outCell->parent->parent; // Output FPA555 pmConceptsAverageFPAs(outFPA, fpaList);556 pmConceptsAverageCells(outCell, cellList, NULL, NULL, true);557 psFree(fpaList);558 psFree(cellList);559 560 // Update the value of a concept561 #define UPDATE_CONCEPT(SOURCE, NAME, VALUE) { \562 psMetadataItem *item = psMetadataLookup(SOURCE->concepts, NAME); \563 psAssert(item, "Concept should be present"); \564 psAssert(item->type == PS_TYPE_F32, "Concept should be F32"); \565 item->data.F32 = VALUE; \566 }567 568 UPDATE_CONCEPT(outFPA, "FPA.EXPOSURE", sumExposure);569 UPDATE_CONCEPT(outCell, "CELL.EXPOSURE", sumExposure);570 UPDATE_CONCEPT(outCell, "CELL.DARKTIME", NAN);571 }572 573 574 // Reject images out-of-hand on the basis of their match chi^2575 {576 psVector *values = psVectorAllocEmpty(num, PS_TYPE_F32); // Values to sort577 for (int i = 0; i < num; i++) {578 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_ALL) {579 continue;580 }581 values->data.F32[values->n++] = matchChi2->data.F32[i];582 }583 assert(values->n == numGood);584 if (!psVectorSortInPlace(values)) {585 psError(PS_ERR_UNKNOWN, false, "Unable to sort vector.");586 psFree(subKernels);587 psFree(subRegions);588 psFree(cells);589 psFree(inputMask);590 psFree(matchChi2);591 psFree(values);592 psFree(covariances);593 return false;594 }595 float median = numGood % 2 ? values->data.F32[numGood / 2] :596 0.5 * (values->data.F32[numGood / 2 - 1] + values->data.F32[numGood / 2]);597 598 float rms = 0.74 * (values->data.F32[numGood * 3 / 4] -599 values->data.F32[numGood / 4]); // Estimated RMS from interquartile range600 601 psFree(values);602 603 float rej = psMetadataLookupF32(NULL, recipe, "MATCH.REJ"); // Rejection threshold (stdevs)604 if (isfinite(rej)) {605 float thresh = median + rej * rms; // Threshold for rejection606 psLogMsg("ppStack", PS_LOG_INFO, "chi^2 rejection threshold = %f + %f * %f = %f",607 median, rej, rms, thresh);608 609 int numRej = 0; // Number rejected610 numGood = 0; // Number of good images611 for (int i = 0; i < num; i++) {612 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_ALL) {613 continue;614 }615 if (matchChi2->data.F32[i] > thresh) {616 numRej++;617 inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_CHI2;618 psLogMsg("ppStack", PS_LOG_INFO, "Rejecting image %d because of large matching chi^2: %f",619 i, matchChi2->data.F32[i]);620 } else {621 psLogMsg("ppStack", PS_LOG_INFO, "Image %d has matching chi^2: %f",622 i, matchChi2->data.F32[i]);623 numGood++;624 }625 }626 }627 }628 629 if (numGood == 0) {630 psError(PS_ERR_UNKNOWN, false, "No good images to combine.");631 psFree(subKernels);632 psFree(subRegions);633 psFree(cells);634 psFree(inputMask);635 psFree(matchChi2);636 psFree(covariances);637 return false;638 }639 640 #ifdef TESTING641 psTraceSetLevel("psModules.imcombine", 7);642 #endif643 644 psLogMsg("ppStack", PS_LOG_INFO, "Stage 3 : Basic Image Rejection : %f sec", psTimerClear("PPSTACK_STEPS"));645 646 // Start threading647 ppStackThreadInit();648 ppStackThreadData *stack = ppStackThreadDataSetup(cells, imageNames, maskNames, varianceNames,649 covariances, config);650 if (!stack) {651 psError(PS_ERR_IO, false, "Unable to initialise stack threads.");652 psFree(subKernels);653 psFree(subRegions);654 psFree(inputMask);655 psFree(matchChi2);656 psFree(cells);657 psFree(covariances);658 return false;659 }660 661 psTimerStart("PPSTACK_INITIAL");662 663 memDump("preinitial");664 665 // Stack the convolved files666 psTrace("ppStack", 1, "Initial stack of convolved images....\n");667 pmReadout *outRO = NULL; // Output readout668 pmFPAview *view = NULL; // View to readout669 psArray *inspect = NULL; // Array of arrays of pixels to inspect670 {671 int row0, col0; // Offset for readout672 int numCols, numRows; // Size of readout673 ppStackThread *thread = stack->threads->data[0]; // Representative thread674 if (!pmReadoutStackSetOutputSize(&col0, &row0, &numCols, &numRows, thread->readouts)) {675 psError(PS_ERR_UNKNOWN, false, "problem setting output readout size.");676 psFree(subKernels);677 psFree(subRegions);678 psFree(stack);679 psFree(inputMask);680 psFree(matchChi2);681 psFree(cells);682 psFree(covariances);683 return false;684 }685 686 pmFPAfileActivate(config->files, false, NULL);687 fileActivation(config, combineFiles, true);688 view = filesIterateDown(config);689 if (!view) {690 psFree(subKernels);691 psFree(subRegions);692 psFree(stack);693 psFree(inputMask);694 psFree(matchChi2);695 psFree(cells);696 psFree(covariances);697 return false;698 }699 700 pmCell *outCell = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT"); // Output cell701 outRO = pmReadoutAlloc(outCell); // Output readout702 703 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad704 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels705 if (!pmReadoutStackDefineOutput(outRO, col0, row0, numCols, numRows, true, true, maskBad)) {706 psError(PS_ERR_UNKNOWN, false, "Unable to prepare output.");707 psFree(subKernels);708 psFree(subRegions);709 psFree(stack);710 psFree(inputMask);711 psFree(matchChi2);712 psFree(view);713 psFree(outRO);714 psFree(cells);715 psFree(covariances);716 return false;717 }718 719 psFree(cells);720 721 bool status; // Status of read722 int numChunk; // Number of chunks723 for (numChunk = 0; true; numChunk++) {724 ppStackThread *thread = ppStackThreadRead(&status, stack, config, numChunk, overlap);725 if (!status) {726 // Something went wrong727 psError(PS_ERR_UNKNOWN, false, "Unable to read chunk %d", numChunk);728 psFree(subKernels);729 psFree(subRegions);730 psFree(stack);731 psFree(inputMask);732 psFree(matchChi2);733 psFree(view);734 psFree(outRO);735 psFree(covariances);736 return false;737 }738 if (!thread) {739 // Nothing more to read740 break;741 }742 743 // call: ppStackReadoutInitial(config, outRO, readouts, subRegions, subKernels)744 psThreadJob *job = psThreadJobAlloc("PPSTACK_INITIAL_COMBINE"); // Job to start745 psArrayAdd(job->args, 1, thread);746 psArrayAdd(job->args, 1, config);747 psArrayAdd(job->args, 1, outRO);748 psArrayAdd(job->args, 1, inputMask);749 psArrayAdd(job->args, 1, weightings);750 psArrayAdd(job->args, 1, matchChi2);751 if (!psThreadJobAddPending(job)) {752 psFree(job);753 psFree(subKernels);754 psFree(subRegions);755 psFree(stack);756 psFree(inputMask);757 psFree(weightings);758 psFree(matchChi2);759 psFree(view);760 psFree(outRO);761 psFree(covariances);762 return false;763 }764 psFree(job);765 }766 767 if (!psThreadPoolWait(false)) {768 psError(PS_ERR_UNKNOWN, false, "Unable to do initial combination.");769 psFree(subKernels);770 psFree(subRegions);771 psFree(stack);772 psFree(inputMask);773 psFree(matchChi2);774 psFree(view);775 psFree(outRO);776 psFree(covariances);777 return false;778 }779 780 // Harvest the jobs, gathering the inspection lists781 inspect = psArrayAlloc(num);782 for (int i = 0; i < num; i++) {783 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {784 continue;785 }786 inspect->data[i] = psArrayAllocEmpty(numChunk);787 }788 psThreadJob *job; // Completed job789 while ((job = psThreadJobGetDone())) {790 psAssert(strcmp(job->type, "PPSTACK_INITIAL_COMBINE") == 0,791 "Job has incorrect type: %s", job->type);792 psArray *results = job->results; // Results of job793 for (int i = 0; i < num; i++) {794 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {795 continue;796 }797 inspect->data[i] = psArrayAdd(inspect->data[i], 1, results->data[i]);798 }799 psFree(job);800 }801 802 memDump("initial");803 }804 805 #ifdef TESTING806 writeImage("combined_initial.fits", NULL, outRO->image, config);807 #endif808 809 if (stats) {810 psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_INITIAL", 0,811 "Time to make initial stack", psTimerMark("PPSTACK_INITIAL"));812 }813 psLogMsg("ppStack", PS_LOG_INFO, "Stage 4 : Make Initial Stack : %f sec", psTimerClear("PPSTACK_STEPS"));814 psLogMsg("ppStack", PS_LOG_INFO, "Time to make initial stack: %f sec", psTimerClear("PPSTACK_INITIAL"));815 816 psTimerStart("PPSTACK_REJECT");817 818 // Pixel rejection819 psArray *rejected = psArrayAlloc(num);820 {821 int numRejected = 0; // Number of inputs rejected completely822 823 // Count images rejected out of hand824 for (int i = 0; i < num; i++) {825 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {826 numRejected++;827 }828 }829 830 for (int i = 0; i < num; i++) {831 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {832 continue;833 }834 835 psThreadJob *job = psThreadJobAlloc("PPSTACK_INSPECT"); // Job to start836 psArrayAdd(job->args, 1, inspect);837 PS_ARRAY_ADD_SCALAR(job->args, i, PS_TYPE_S32);838 if (!psThreadJobAddPending(job)) {839 psFree(job);840 psFree(subKernels);841 psFree(subRegions);842 psFree(stack);843 psFree(inputMask);844 psFree(view);845 psFree(outRO);846 psFree(inspect);847 psFree(rejected);848 psFree(covariances);849 psFree(matchChi2);850 return false;851 }852 psFree(job);853 }854 855 if (!psThreadPoolWait(true)) {856 psError(PS_ERR_UNKNOWN, false, "Unable to concatenate inspection lists.");857 psFree(subKernels);858 psFree(subRegions);859 psFree(stack);860 psFree(inputMask);861 psFree(view);862 psFree(outRO);863 psFree(inspect);864 psFree(rejected);865 psFree(covariances);866 psFree(matchChi2);867 return false;868 }869 870 if (psMetadataLookupS32(NULL, config->arguments, "-threads") > 0) {871 pmStackRejectThreadsInit();872 }873 874 int stride = psMetadataLookupS32(NULL, ppsub, "STRIDE"); // Size of convolution patches875 876 // Reject bad pixels877 for (int i = 0; i < num; i++) {878 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {879 continue;880 }881 psTimerStart("PPSTACK_REJECT");882 883 #ifdef TESTING884 {885 psImage *mask = psPixelsToMask(NULL, inspect->data[i],886 psRegionSet(0, numCols - 1, 0, numRows - 1),887 0xff); // Mask image888 psString name = NULL; // Name of image889 psStringAppend(&name, "inspect_%03d.fits", i);890 psFits *fits = psFitsOpen(name, "w");891 psFree(name);892 psFitsWriteImage(fits, NULL, mask, 0, NULL);893 psFree(mask);894 psFitsClose(fits);895 }896 #endif897 898 psPixels *reject = pmStackReject(inspect->data[i], numCols, numRows, threshold, poorFrac, stride,899 subRegions->data[i], subKernels->data[i]); // Rejected pixels900 901 #ifdef TESTING902 {903 psImage *mask = psPixelsToMask(NULL, reject, psRegionSet(0, numCols - 1, 0, numRows - 1),904 0xff); // Mask image905 psString name = NULL; // Name of image906 psStringAppend(&name, "reject_%03d.fits", i);907 psFits *fits = psFitsOpen(name, "w");908 psFree(name);909 psFitsWriteImage(fits, NULL, mask, 0, NULL);910 psFree(mask);911 psFitsClose(fits);912 }913 #endif914 915 psFree(inspect->data[i]);916 inspect->data[i] = NULL;917 918 if (!reject) {919 psWarning("Rejection on image %d didn't work --- reject entire image.", i);920 numRejected++;921 inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_REJECT;922 } else {923 float frac = reject->n / (float)(numCols * numRows); // Pixel fraction924 psLogMsg("ppStack", PS_LOG_INFO, "%ld pixels rejected from image %d (%.1f%%)",925 reject->n, i, frac * 100.0);926 if (frac > imageRej) {927 psWarning("Image %d rejected completely because rejection fraction (%.3f) "928 "exceeds limit (%.3f)", i, frac, imageRej);929 psFree(reject);930 // reject == NULL means reject image completely931 reject = NULL;932 inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_BAD;933 numRejected++;934 }935 }936 937 // Images without a list of rejected pixels (the list may be empty) are rejected completely938 rejected->data[i] = reject;939 940 if (stats) {941 psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_REJECT", PS_META_DUPLICATE_OK,942 "Time to perform rejection", psTimerMark("PPSTACK_REJECT"));943 psMetadataAddS32(stats, PS_LIST_TAIL, "REJECT_PIXELS", PS_META_DUPLICATE_OK,944 "Number of pixels rejected", reject ? reject->n : 0);945 }946 psLogMsg("ppStack", PS_LOG_INFO, "Time to perform rejection on image %d: %f sec", i,947 psTimerClear("PPSTACK_REJECT"));948 }949 950 psFree(inspect);951 psFree(subKernels);952 psFree(subRegions);953 954 if (numRejected >= num - 1) {955 psError(PS_ERR_UNKNOWN, true, "All inputs completely rejected; unable to proceed.");956 psFree(stack);957 psFree(rejected);958 psFree(inputMask);959 psFree(view);960 psFree(outRO);961 psFree(covariances);962 psFree(matchChi2);963 return false;964 }965 966 if (stats) {967 psMetadataAddS32(stats, PS_LIST_TAIL, "REJECT_IMAGES", 0,968 "Number of images rejected completely", numRejected);969 }970 }971 972 psLogMsg("ppStack", PS_LOG_INFO, "Stage 5 : Pixel Rejection : %f sec", psTimerClear("PPSTACK_STEPS"));973 psTimerStart("PPSTACK_FINAL");974 975 memDump("reject");976 90 977 91 // Final combination 978 92 psTrace("ppStack", 2, "Final stack of convolved images....\n"); 979 { 980 stack->lastScan = 0; // Reset read 981 bool status; // Status of read 982 for (int numChunk = 0; true; numChunk++) { 983 ppStackThread *thread = ppStackThreadRead(&status, stack, config, numChunk, 0); 984 if (!status) { 985 // Something went wrong 986 psError(PS_ERR_UNKNOWN, false, "Unable to read chunk %d", numChunk); 987 psFree(stack); 988 psFree(rejected); 989 psFree(inputMask); 990 psFree(view); 991 psFree(outRO); 992 psFree(covariances); 993 psFree(matchChi2); 994 return false; 995 } 996 if (!thread) { 997 // Nothing more to read 998 break; 999 } 93 if (!ppStackCombineFinal(stack, options, config)) { 94 psError(PS_ERR_UNKNOWN, false, "Unable to perform final combination."); 95 psFree(stack); 96 psFree(options); 97 return false; 98 } 99 psLogMsg("ppStack", PS_LOG_INFO, "Stage 6: Final Stack: %f sec", psTimerClear("PPSTACK_STEPS")); 100 ppStackMemDump("final"); 1000 101 1001 // call: ppStackReadoutFinal(config, outRO, readouts, rejected)1002 psThreadJob *job = psThreadJobAlloc("PPSTACK_FINAL_COMBINE"); // Job to start1003 psArrayAdd(job->args, 1, thread);1004 psArrayAdd(job->args, 1, config);1005 psArrayAdd(job->args, 1, outRO);1006 psArrayAdd(job->args, 1, inputMask);1007 psArrayAdd(job->args, 1, rejected);1008 psArrayAdd(job->args, 1, weightings);1009 psArrayAdd(job->args, 1, matchChi2);1010 if (!psThreadJobAddPending(job)) {1011 psFree(job);1012 psFree(stack);1013 psFree(rejected);1014 psFree(inputMask);1015 psFree(view);1016 psFree(outRO);1017 psFree(covariances);1018 psFree(matchChi2);1019 return false;1020 }1021 psFree(job);1022 }1023 102 1024 if (!psThreadPoolWait(true)) { 1025 psError(PS_ERR_UNKNOWN, false, "Unable to do final combination."); 1026 psFree(stack); 1027 psFree(inputMask); 1028 psFree(rejected); 1029 psFree(view); 1030 psFree(outRO); 1031 psFree(covariances); 1032 psFree(matchChi2); 1033 return false; 1034 } 103 // Clean up 104 psTrace("ppStack", 2, "Cleaning up after combination....\n"); 105 if (!ppStackCombineFinal(stack, options, config)) { 106 psError(PS_ERR_UNKNOWN, false, "Unable to clean up."); 107 psFree(stack); 108 psFree(options); 109 return false; 1035 110 } 111 psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: WCS & JPEGS: %f sec", psTimerClear("PPSTACK_STEPS")); 112 ppStackMemDump("cleanup"); 1036 113 1037 memDump("final");1038 1039 #ifdef TESTING1040 writeImage("combined_final.fits", NULL, outRO->image, config);1041 #endif1042 1043 // Sum covariance matrices1044 for (int i = 0; i < num; i++) {1045 if (inputMask->data.U8[i]) {1046 psFree(covariances->data[i]);1047 covariances->data[i] = NULL;1048 }1049 }1050 outRO->covariance = psImageCovarianceSum(covariances);1051 psFree(covariances);1052 psFree(matchChi2);1053 1054 if (stats) {1055 psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_FINAL", 0,1056 "Time to make final stack", psTimerMark("PPSTACK_FINAL"));1057 }1058 1059 psLogMsg("ppStack", PS_LOG_INFO, "Stage 6 : Final Stack : %f sec", psTimerClear("PPSTACK_STEPS"));1060 psLogMsg("ppStack", PS_LOG_INFO, "Time to make final stack: %f sec", psTimerClear("PPSTACK_FINAL"));1061 1062 psTrace("ppStack", 2, "Cleaning up after combination....\n");1063 1064 #if 01065 // Ensure masked regions really look masked1066 {1067 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits for bad1068 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels1069 if (!pmReadoutMaskApply(outRO, maskBad)) {1070 psWarning("Unable to apply mask");1071 }1072 }1073 #endif1074 1075 // Close up1076 bool wcsDone = false; // Have we done the WCS?1077 for (int i = 0; i < num; i++) {1078 if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {1079 continue;1080 }1081 1082 ppStackThread *thread = stack->threads->data[0]; // Representative stack1083 pmReadout *inRO = thread->readouts->data[i]; // Template readout1084 if (inRO && !wcsDone) {1085 // Copy astrometry over1086 wcsDone = true;1087 pmHDU *inHDU = pmHDUFromCell(inRO->parent); // Template HDU1088 pmHDU *outHDU = pmHDUFromCell(outRO->parent); // Output HDU1089 pmChip *outChip = outRO->parent->parent; // Output chip1090 pmFPA *outFPA = outChip->parent; // Output FPA1091 if (!outHDU || !inHDU) {1092 psWarning("Unable to find HDU at FPA level to copy astrometry.");1093 } else {1094 if (!pmAstromReadWCS(outFPA, outChip, inHDU->header, 1.0)) {1095 psErrorClear();1096 psWarning("Unable to read WCS astrometry from input FPA.");1097 wcsDone = false;1098 } else {1099 if (!outHDU->header) {1100 outHDU->header = psMetadataAlloc();1101 }1102 if (!pmAstromWriteWCS(outHDU->header, outFPA, outChip, WCS_TOLERANCE)) {1103 psErrorClear();1104 psWarning("Unable to write WCS astrometry to output FPA.");1105 wcsDone = false;1106 }1107 }1108 }1109 }1110 1111 if (tempDelete) {1112 psString imageResolved = pmConfigConvertFilename(imageNames->data[i], config, false, false);1113 psString maskResolved = pmConfigConvertFilename(maskNames->data[i], config, false, false);1114 psString varianceResolved = pmConfigConvertFilename(varianceNames->data[i], config, false, false);1115 if (unlink(imageResolved) == -1 || unlink(maskResolved) == -1 ||1116 unlink(varianceResolved) == -1) {1117 psWarning("Unable to delete temporary files for image %d", i);1118 }1119 psFree(imageResolved);1120 psFree(maskResolved);1121 psFree(varianceResolved);1122 }1123 }1124 psFree(imageNames);1125 psFree(maskNames);1126 psFree(varianceNames);1127 1128 psFree(inputMask);1129 114 psFree(stack); 1130 115 1131 memDump("cleanup");1132 116 1133 // Generate binned JPEGs 1134 { 1135 int bin1 = psMetadataLookupS32(NULL, recipe, "BIN1"); // First binning level 1136 int bin2 = psMetadataLookupS32(NULL, recipe, "BIN2"); // Second binning level 1137 1138 // Target cells 1139 pmCell *cell1 = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT.JPEG1"); 1140 pmCell *cell2 = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT.JPEG2"); 1141 psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask 1142 1143 pmReadout *ro1 = pmReadoutAlloc(cell1), *ro2 = pmReadoutAlloc(cell2); // Binned readouts 1144 if (!pmReadoutRebin(ro1, outRO, maskValue, bin1, bin1) || !pmReadoutRebin(ro2, ro1, 0, bin2, bin2)) { 1145 psError(PS_ERR_UNKNOWN, false, "Unable to bin output."); 1146 psFree(ro1); 1147 psFree(ro2); 1148 psFree(outRO); 1149 return false; 1150 } 1151 psFree(ro1); 1152 psFree(ro2); 1153 } 1154 1155 psLogMsg("ppStack", PS_LOG_INFO, "Stage 7 : WCS & JPEGS : %f sec", psTimerClear("PPSTACK_STEPS")); 1156 1157 if (psMetadataLookupBool(&mdok, recipe, "PHOTOMETRY")) { 1158 psTrace("ppStack", 1, "Photometering stacked image....\n"); 1159 1160 psTimerStart("PPSTACK_PHOT"); 1161 1162 fileActivation(config, combineFiles, false); 1163 fileActivation(config, photFiles, true); 1164 pmFPAview *photView = filesIterateDown(config); 1165 if (!ppStackPhotometry(config, outRO, photView)) { 1166 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on output."); 1167 psFree(outRO); 1168 psFree(photView); 1169 return false; 1170 } 1171 psFree(photView); 1172 1173 fileActivation(config, combineFiles, true); 1174 1175 if (stats) { 1176 pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT"); // File 1177 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources 1178 psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources 1179 psMetadataAddS32(stats, PS_LIST_TAIL, "NUM_SOURCES", 0, "Number of sources detected", sources->n); 1180 psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_PHOT", 0, 1181 "Time to do photometry", psTimerMark("PPSTACK_PHOT")); 1182 } 1183 psLogMsg("ppStack", PS_LOG_INFO, "Time to do photometry: %f sec", psTimerClear("PPSTACK_PHOT")); 1184 } 1185 1186 psLogMsg("ppStack", PS_LOG_INFO, "Stage 8 : Photometry Analysis : %f sec", psTimerClear("PPSTACK_STEPS")); 1187 1188 psThreadPoolFinalize(); 1189 1190 memDump("phot"); 1191 1192 // Statistics on output 1193 if (stats) { 1194 psTrace("ppStack", 1, "Gathering statistics on stacked image....\n"); 1195 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits for bad 1196 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 1197 1198 ppStatsFPA(stats, outRO->parent->parent->parent, view, maskBad, config); 1199 } 1200 1201 memDump("stats"); 1202 1203 // Put version information into the header 1204 pmHDU *hdu = pmHDUFromCell(outRO->parent); 1205 if (!hdu) { 1206 psError(PS_ERR_UNKNOWN, false, "Unable to find HDU for output."); 1207 psFree(outRO); 1208 psFree(view); 117 // Photometry 118 psTrace("ppStack", 1, "Photometering stacked image....\n"); 119 if (!ppStackPhotometry(options, config)) { 120 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry."); 121 psFree(options); 1209 122 return false; 1210 123 } 1211 if (!hdu->header) { 1212 hdu->header = psMetadataAlloc(); 1213 } 1214 ppStackVersionMetadata(hdu->header); 124 psLogMsg("ppStack", PS_LOG_INFO, "Stage 8: Photometry Analysis: %f sec", psTimerClear("PPSTACK_STEPS")); 125 ppStackMemDump("photometry"); 1215 126 1216 psFree(outRO);1217 psFree(view);1218 127 1219 // Write out summary statistics 1220 if (stats) { 1221 psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_STACK", 0, 1222 "Time to do photometry", psTimerClear("PPSTACK_TOTAL")); 1223 1224 const char *statsMDC = psMetadataConfigFormat(stats); 1225 if (!statsMDC || strlen(statsMDC) == 0) { 1226 psError(PS_ERR_IO, false, "Unable to get statistics MDC file.\n"); 1227 } else { 1228 fprintf(statsFile, "%s", statsMDC); 1229 } 1230 psFree((void *)statsMDC); 1231 fclose(statsFile); 1232 1233 psFree(stats); 1234 } 1235 1236 // Write out the output files 1237 if (!filesIterateUp(config)) { 128 // Finish up 129 psTrace("ppStack", 1, "Finishing up....\n"); 130 if (!ppStackFinish(options, config)) { 131 psError(PS_ERR_UNKNOWN, false, "Unable to finish up."); 132 psFree(options); 1238 133 return false; 1239 134 } 135 psLogMsg("ppStack", PS_LOG_INFO, "Stage 9: Final output: %f sec", psTimerClear("PPSTACK_STEPS")); 136 ppStackMemDump("finish"); 1240 137 1241 psLogMsg("ppStack", PS_LOG_INFO, "Stage 9 : Final Output : %f sec", psTimerClear("PPSTACK_STEPS")); 1242 1243 memDump("finish"); 1244 138 psFree(options); 1245 139 return true; 1246 140 } -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackMatch.c
r21525 r23352 145 145 146 146 psImage *binned = psphotBackgroundModel(ro, config); // Binned background model 147 psImageBinning *binning = psMetadataLookupPtr(NULL, psphotRecipe,147 psImageBinning *binning = psMetadataLookupPtr(NULL, ro->analysis, 148 148 "PSPHOT.BACKGROUND.BINNING"); // Binning for model 149 149 psAssert(binning, "Need binning parameters"); … … 358 358 psString name = NULL; 359 359 psStringAppend(&name, "fake_%03d.fits", numInput); 360 pmStackVisualPlotTestImage(fake->image, name); 360 361 psFits *fits = psFitsOpen(name, "w"); 361 362 psFree(name); … … 367 368 psString name = NULL; 368 369 psStringAppend(&name, "real_%03d.fits", numInput); 370 pmStackVisualPlotTestImage(readout->image, name); 369 371 psFits *fits = psFitsOpen(name, "w"); 370 372 psFree(name); … … 397 399 psString name = NULL; 398 400 psStringAppend(&name, "conv_%03d.fits", numInput); 401 pmStackVisualPlotTestImage(output->image, name); 399 402 psFits *fits = psFitsOpen(name, "w"); 400 403 psFree(name); … … 406 409 psString name = NULL; 407 410 psStringAppend(&name, "diff_%03d.fits", numInput); 411 pmStackVisualPlotTestImage(fake->image, name); 408 412 psFits *fits = psFitsOpen(name, "w"); 409 413 psFree(name); … … 633 637 psString name = NULL; 634 638 psStringAppend(&name, "convolved_%03d.fits", numInput); 639 pmStackVisualPlotTestImage(output->image, name); 635 640 psFits *fits = psFitsOpen(name, "w"); 636 641 psFree(name); -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackPSF.c
r18918 r23352 9 9 #include "ppStack.h" 10 10 11 pmPSF *ppStackPSF(const pmConfig *config, int numCols, int numRows, const psArray *psfs) 11 pmPSF *ppStackPSF(const pmConfig *config, int numCols, int numRows, 12 const psArray *psfs, const psVector *inputMask) 12 13 { 13 14 // Get the recipe values … … 19 20 const char *psfModel = psMetadataLookupStr(NULL, recipe, "PSF.MODEL"); // Model for PSF 20 21 int psfOrder = psMetadataLookupS32(NULL, recipe, "PSF.ORDER"); // Spatial order for PSF 22 23 for (int i = 0; i < psfs->n; i++) { 24 if (inputMask->data.U8[i]) { 25 psFree(psfs->data[i]); 26 psfs->data[i] = NULL; 27 } 28 } 21 29 22 30 // Solve for the target PSF -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackPhotometry.c
r21259 r23352 9 9 10 10 #include "ppStack.h" 11 #include "ppStackLoop.h" 11 12 12 #define PHOT_SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_SATSTAR | PM_SOURCE_MODE_BLEND | \ 13 PM_SOURCE_MODE_BADPSF | PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_SATURATED | \ 14 PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply to sources 15 16 bool ppStackInputPhotometry(const pmReadout *ro, const psArray *sources, const pmConfig *config) 13 bool ppStackPhotometry(ppStackOptions *options, pmConfig *config) 17 14 { 18 PM_ASSERT_READOUT_NON_NULL(ro, false);19 PS_ASSERT_ARRAY_NON_NULL(sources, false);15 psAssert(options, "Require options"); 16 psAssert(config, "Require configuration"); 20 17 21 18 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe … … 23 20 24 21 bool mdok; // Status of MD lookup 25 26 float zpRadius = psMetadataLookupS32(&mdok, recipe, "PHOT.RADIUS"); // Radius for PHOT measurement 27 if (!mdok) { 28 psError(PS_ERR_UNKNOWN, true, "Unable to find PHOT.RADIUS in recipe"); 29 return false; 30 } 31 float zpSigma = psMetadataLookupF32(&mdok, recipe, "PHOT.SIGMA"); // Gaussian sigma for photometry 32 if (!mdok) { 33 psError(PS_ERR_UNKNOWN, true, "Unable to find PHOT.SIGMA in recipe"); 34 return false; 35 } 36 float zpFrac = psMetadataLookupF32(&mdok, recipe, "PHOT.FRAC"); // Fraction of good pixels for photometry 37 if (!mdok) { 38 psError(PS_ERR_UNKNOWN, true, "Unable to find PHOT.FRAC in recipe"); 39 return false; 22 if (!psMetadataLookupBool(&mdok, recipe, "PHOTOMETRY")) { 23 // Nothing to do 24 return true; 40 25 } 41 26 42 psString maskValStr = psMetadataLookupStr(&mdok, recipe, "MASK.VAL"); // Name of bits to mask going in 43 if (!mdok || !maskValStr) { 44 psError(PS_ERR_UNKNOWN, false, "Unable to find MASK.VAL in recipe"); 45 return false; 46 } 47 psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask 27 psTimerStart("PPSTACK_PHOT"); 48 28 49 psImage *image = ro->image, *mask = ro->mask; // Image and mask from readout 29 ppStackFileActivation(config, PPSTACK_FILES_COMBINE, false); 30 ppStackFileActivation(config, PPSTACK_FILES_PHOT, true); 31 pmFPAview *photView = ppStackFilesIterateDown(config); // View to readout 32 ppStackFileActivation(config, PPSTACK_FILES_COMBINE, true); 50 33 51 // Measure background 52 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); // Random number generator 53 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics 54 if (!psImageBackground(stats, NULL, image, mask, maskVal, rng)) { 55 psError(PS_ERR_UNKNOWN, false, "Unable to measure background for image"); 56 psFree(stats); 57 psFree(rng); 58 return false; 59 } 60 float bg = stats->robustMedian; // Background level 61 psFree(stats); 62 psFree(rng); 34 pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT"); // File for photometry 35 pmFPACopy(photFile->fpa, options->outRO->parent->parent->parent); 63 36 64 // Photometer sources 65 int numCols = image->numCols, numRows = image->numRows; // Size of image 66 int numSources = sources->n; // Number of sources 67 int numGood = 0; // Number of good sources 68 float maxMag = -INFINITY; // Maximum magnitude 69 for (int j = 0; j < numSources; j++) { 70 pmSource *source = sources->data[j]; // Source of interest 71 if (source->mode & PHOT_SOURCE_MASK || !isfinite(source->psfMag)) { 72 source->psfMag = NAN; 73 continue; 74 } 75 float x = source->peak->xf, y = source->peak->yf; // Coordinates of source 76 int xCentral = x + 0.5, yCentral = y + 0.5; // Central pixel 77 // Range of integration 78 int xMin = PS_MAX(0, xCentral - zpRadius), xMax = PS_MIN(numCols - 1, xCentral + zpRadius); 79 int yMin = PS_MAX(0, yCentral - zpRadius), yMax = PS_MIN(numRows - 1, yCentral + zpRadius); 80 81 // Integrate 82 double sumImage = 0.0, sumKernel = 0.0; // Sums from integration 83 int numBadPix = 0; // Number of bad pixels 84 for (int v = yMin; v <= yMax; v++) { 85 float dy2 = PS_SQR(y - v); // Distance from centroid 86 for (int u = xMin; u <= xMax; u++) { 87 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[v][u] & maskVal) { 88 numBadPix++; 89 continue; 90 } 91 float dx2 = PS_SQR(x - u); // Distance from centroid 92 double kernel = exp(-0.5 * (dx2 + dy2) / PS_SQR(zpSigma)); // Kernel value 93 sumImage += (image->data.F32[v][u] - bg) * kernel; 94 sumKernel += kernel; 95 } 96 } 97 98 if (numBadPix > zpFrac * M_PI * PS_SQR(zpRadius) || !isfinite(sumImage)) { 99 source->psfMag = NAN; 100 } else { 101 source->psfMag = - 2.5 * log10(sumImage / sumKernel * M_PI * PS_SQR(zpRadius)); 102 if (isfinite(source->psfMag)) { 103 numGood++; 104 maxMag = PS_MAX(maxMag, source->psfMag); 105 } 106 } 107 } 108 psLogMsg("ppStack", PS_LOG_INFO, "Photometered %d good sources in image; max mag %f", numGood, maxMag); 109 110 return true; 111 } 112 113 114 115 bool ppStackPhotometry(pmConfig *config, const pmReadout *readout, const pmFPAview *view) 116 { 117 pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT"); 118 pmFPACopy(photFile->fpa, readout->parent->parent->parent); 119 120 if (psMetadataLookupBool(NULL, config->arguments, "-psphot-visual")) { 121 psphotSetVisual(true); 37 if (psMetadataLookupBool(NULL, config->arguments, "-visual")) { 38 pmVisualSetVisual(true); 122 39 } 123 40 41 psMetadata *psphot = psMetadataLookupMetadata(NULL, config->recipes, PSPHOT_RECIPE); // Recipe 42 43 #if 0 124 44 // Need to ensure aperture residual is not calculated 125 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PSPHOT_RECIPE); // Recipe126 45 psMetadataItem *item = psMetadataLookup(recipe, "MEASURE.APTREND"); // Item determining aptrend 127 46 if (!item) { … … 131 50 item->data.B = false; 132 51 } 52 #endif 133 53 134 54 // set maskValue and markValue in the psphot recipe 135 55 psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask 136 56 psImageMaskType markValue = pmConfigMaskGet("MARK.VALUE", config); // Bits to use for marking 137 psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "Bits to mask", maskValue); 138 psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "Bits to use for mark", markValue); 57 psMetadataAddImageMask(psphot, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, 58 "Bits to mask", maskValue); 59 psMetadataAddImageMask(psphot, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, 60 "Bits to use for mark", markValue); 139 61 140 // XXX replace with psphotReadoutKnownSources (config, view) 141 // XXX this function requires that we construct the input source list and place it on PSPHOT.INPUT.CMF 142 pmCell *sourcesCell = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT"); 143 psArray *inSources = psMetadataLookupPtr (NULL, sourcesCell->analysis, "PSPHOT.SOURCES"); 62 pmCell *sourcesCell = pmFPAfileThisCell(config->files, photView, "PPSTACK.OUTPUT"); 63 psArray *inSources = psMetadataLookupPtr(NULL, sourcesCell->analysis, "PSPHOT.SOURCES"); 144 64 if (!inSources) { 145 65 psError(PS_ERR_UNKNOWN, false, "Unable to find input sources"); 66 psFree(photView); 146 67 return false; 147 68 } 148 69 149 if (!psphotReadoutKnownSources(config, view, inSources)) {70 if (!psphotReadoutKnownSources(config, photView, inSources)) { 150 71 // Clear the error, so that the output files are written. 151 ps Warning("Unable to perform photometry on stacked image.");152 ps ErrorStackPrint(stderr, "Error stack from photometry:");153 psErrorClear();72 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on stacked image."); 73 psFree(photView); 74 return false; 154 75 } 76 psFree(photView); 155 77 156 78 if (!pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL") || … … 163 85 pmFPAfileActivate(config->files, false, "PSPHOT.INPUT"); 164 86 87 if (options->stats) { 88 pmReadout *photRO = pmFPAviewThisReadout(photView, photFile->fpa); // Readout with the sources 89 psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources 90 psMetadataAddS32(options->stats, PS_LIST_TAIL, "NUM_SOURCES", 0, 91 "Number of sources detected", sources->n); 92 psMetadataAddF32(options->stats, PS_LIST_TAIL, "TIME_PHOT", 0, 93 "Time to do photometry", psTimerMark("PPSTACK_PHOT")); 94 } 95 psLogMsg("ppStack", PS_LOG_INFO, "Time to do photometry: %f sec", psTimerClear("PPSTACK_PHOT")); 96 165 97 return true; 166 98 } -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackReadout.c
r21477 r23352 8 8 #include <psphot.h> 9 9 10 #include "ppStackThread.h" 10 11 #include "ppStack.h" 11 12 … … 16 17 psArray *args = job->args; // Arguments 17 18 ppStackThread *thread = args->data[0]; // Thread 18 pmConfig *config = args->data[1]; // Configuration 19 pmReadout *outRO = args->data[2]; // Output readout 20 psVector *mask = args->data[3]; // Mask for inputs 21 psVector *weightings = args->data[4]; // Weightings (1/noise^2) for each image 22 psVector *addVariance = args->data[5]; // Additional variance when rejecting 19 ppStackOptions *options = args->data[1]; // Options 20 pmConfig *config = args->data[2]; // Configuration 21 22 pmReadout *outRO = options->outRO; // Output readout 23 psVector *mask = options->inputMask; // Mask for inputs 24 psVector *weightings = options->weightings; // Weightings (1/noise^2) for each image 25 psVector *addVariance = options->matchChi2; // Additional variance when rejecting 23 26 24 27 psArray *inspect = ppStackReadoutInitial(config, outRO, thread->readouts, mask, … … 37 40 psArray *args = job->args; // Arguments 38 41 ppStackThread *thread = args->data[0]; // Thread 39 pmConfig *config = args->data[1]; // Configuration 40 pmReadout *outRO = args->data[2]; // Output readout 41 psVector *mask = args->data[3]; // Mask for inputs 42 psArray *rejected = args->data[4]; // Rejected pixels 43 psVector *weightings = args->data[5]; // Weighting (1/noise^2) for each image 44 psVector *addVariance = args->data[6]; // Weighting (1/noise^2) for each image 42 ppStackOptions *options = args->data[1]; // Options 43 pmConfig *config = args->data[2]; // Configuration 44 45 pmReadout *outRO = options->outRO; // Output readout 46 psVector *mask = options->inputMask; // Mask for inputs 47 psArray *rejected = options->rejected; // Rejected pixels 48 psVector *weightings = options->weightings; // Weightings (1/noise^2) for each image 49 psVector *addVariance = options->matchChi2; // Additional variance when rejecting 45 50 46 51 bool status = ppStackReadoutFinal(config, outRO, thread->readouts, mask, rejected, … … 227 232 } 228 233 229 pmStackData *data = pmStackDataAlloc(ro, weightings->data.F32[i], addVariance->data.F32[i]); 234 pmStackData *data = pmStackDataAlloc(ro, weightings->data.F32[i], 235 addVariance ? addVariance->data.F32[i] : NAN); 230 236 data->reject = psMemIncrRefCounter(rejected->data[i]); 231 237 stack->data[i] = data; -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackSources.c
r21260 r23352 13 13 #define FAKE_ROWS 4913 14 14 15 float ppStackSourcesTransparency(const psArray *sourceLists, const pmFPAview *view, const pmConfig *config) 15 #ifdef TESTING 16 // Dump matches to a file 17 static void dumpMatches(const char *filename, // File to which to dump 18 int num, // Number of inputs 19 psArray *matches, // Star matches 20 psVector *zp, // Zero points 21 psVector *trans // Transparencies 22 ) 23 { 24 FILE *outMatches = fopen(filename, "w"); // Output matches 25 psVector *mag = psVectorAlloc(num, PS_TYPE_F32); // Magnitudes for each star 26 psVector *magErr = psVectorAlloc(num, PS_TYPE_F32); // Errors for each star 27 for (int i = 0; i < matches->n; i++) { 28 pmSourceMatch *match = matches->data[i]; // Match of interest 29 psVectorInit(mag, NAN); 30 psVectorInit(magErr, NAN); 31 for (int j = 0; j < match->num; j++) { 32 if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) { 33 continue; 34 } 35 int index = match->image->data.U32[j]; // Image index 36 mag->data.F32[index] = match->mag->data.F32[j] - zp->data.F32[index]; 37 if (trans) { 38 mag->data.F32[index] -= trans->data.F32[index]; 39 } 40 magErr->data.F32[index] = match->magErr->data.F32[j]; 41 } 42 for (int j = 0; j < num; j++) { 43 fprintf(outMatches, "%f (%f) ", mag->data.F32[j], magErr->data.F32[j]); 44 } 45 fprintf(outMatches, "\n"); 46 } 47 psFree(mag); 48 psFree(magErr); 49 fclose(outMatches); 50 return; 51 } 52 #endif 53 54 55 float ppStackSourcesTransparency(const psArray *sourceLists, psVector *inputMask, 56 const pmFPAview *view, const pmConfig *config) 16 57 { 17 58 PS_ASSERT_ARRAY_NON_NULL(sourceLists, NAN); 59 PS_ASSERT_VECTOR_NON_NULL(inputMask, NAN); 60 PS_ASSERT_VECTOR_TYPE(inputMask, PS_TYPE_U8, NAN); 61 PS_ASSERT_VECTOR_SIZE(inputMask, sourceLists->n, NAN); 18 62 PS_ASSERT_PTR_NON_NULL(view, NAN); 19 63 PS_ASSERT_PTR_NON_NULL(config, NAN); 20 64 21 #if def TESTING65 #if defined(TESTING) && 0 22 66 { 23 67 // Deliberately induce a major transparency difference … … 37 81 38 82 float radius = psMetadataLookupF32(NULL, recipe, "ZP.RADIUS"); // Radius (pixels) for matching sources 39 int iter = psMetadataLookupS32(NULL, recipe, "ZP.ITER"); // Maximum iterations 83 int iter1 = psMetadataLookupS32(NULL, recipe, "ZP.ITER.1"); // Maximum iterations for pass 1 84 int iter2 = psMetadataLookupS32(NULL, recipe, "ZP.ITER.2"); // Maximum iterations for pass 2 40 85 float tol = psMetadataLookupF32(NULL, recipe, "ZP.TOL"); // Tolerance for zero point iterations 41 86 int transIter = psMetadataLookupS32(NULL, recipe, "ZP.TRANS.ITER"); // Iterations for transparency 42 87 float transRej = psMetadataLookupF32(NULL, recipe, "ZP.TRANS.REJ");// Rejection threshold for transparency 43 88 float transThresh = psMetadataLookupF32(NULL, recipe, "ZP.TRANS.THRESH"); // Threshold for transparency 44 float starRej = psMetadataLookupF32(NULL, recipe, "ZP.STAR.REJ"); // Rejection threshold for stars 89 90 float starRej1 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.REJ.1"); // Rejection threshold for stars 91 float starSys1 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.SYS.1"); // Estimated systematic error 92 float starRej2 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.REJ.2"); // Rejection threshold for stars 93 float starSys2 = psMetadataLookupF32(NULL, recipe, "ZP.STAR.SYS.2"); // Estimated systematic error 94 45 95 float starLimit = psMetadataLookupF32(NULL, recipe, "ZP.STAR.LIMIT"); // Limit on star rejection fraction 46 float starSys = psMetadataLookupF32(NULL, recipe, "ZP.STAR.SYS"); // Estimated systematic error 96 97 float fracMatch = psMetadataLookupF32(NULL, recipe, "ZP.MATCH"); // Fraction of images to match for star 47 98 48 99 psMetadata *airmassZP = psMetadataLookupMetadata(NULL, recipe, "ZP.AIRMASS"); // Airmass terms … … 63 114 pmCell *cell = pmFPAviewThisCell(view, file->fpa); // Cell of interest 64 115 65 #if def TESTING116 #if defined(TESTING) && 0 66 117 pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout 67 118 pmPSF *psf = psMetadataLookupPtr(NULL, config->arguments, "PSF.TARGET"); // PSF for fake image 68 pmReadoutFakeFromSources(fake, FAKE_COLS, FAKE_ROWS, sourceLists->data[i], NULL, NULL, psf, 5, 0, false, true); 119 pmReadoutFakeFromSources(fake, FAKE_COLS, FAKE_ROWS, sourceLists->data[i], 120 NULL, NULL, psf, 5, 0, false, true); 69 121 psString name = NULL; 70 122 psStringAppend(&name, "start_%03d.fits", i); 123 pmStackVisualPlotTestImage(fake->image, name); 71 124 psFits *fits = psFitsOpen(name, "w"); 72 125 psFree(name); … … 108 161 } 109 162 110 psArray *matches = pmSourceMatchSources(sourceLists, radius ); // List of matches163 psArray *matches = pmSourceMatchSources(sourceLists, radius, true); // List of matches 111 164 if (!matches) { 112 165 psError(PS_ERR_UNKNOWN, false, "Unable to match sources"); … … 114 167 return NAN; 115 168 } 116 psVector *trans = pmSourceMatchRelphot(matches, zp, iter, tol, starLimit, transIter, transRej, 117 transThresh, starRej, starSys); // Transparencies for each image 118 119 #ifdef TESTING 120 { 121 // Dump the corrected magnitudes 122 FILE *outMatches = fopen("source_match.dat", "w"); // Output matches 123 psVector *mag = psVectorAlloc(num, PS_TYPE_F32); // Magnitudes for each star 124 psVector *magErr = psVectorAlloc(num, PS_TYPE_F32); // Errors for each star 125 for (int i = 0; i < matches->n; i++) { 126 pmSourceMatch *match = matches->data[i]; // Match of interest 127 psVectorInit(mag, NAN); 128 psVectorInit(magErr, NAN); 129 for (int j = 0; j < match->num; j++) { 130 if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) { 131 continue; 132 } 133 int index = match->image->data.U32[j]; // Image index 134 mag->data.F32[index] = match->mag->data.F32[j] - zp->data.F32[index] - trans->data.F32[index]; 135 magErr->data.F32[index] = match->magErr->data.F32[j]; 136 } 137 for (int j = 0; j < num; j++) { 138 fprintf(outMatches, "%f (%f) ", mag->data.F32[j], magErr->data.F32[j]); 139 } 140 fprintf(outMatches, "\n"); 141 } 142 psFree(mag); 143 psFree(magErr); 144 fclose(outMatches); 145 } 146 #endif 169 170 #ifdef TESTING 171 dumpMatches("source_match.dat", num, matches, zp, NULL); 172 #endif 173 174 psVector *trans = pmSourceMatchRelphot(matches, zp, tol, iter1, starRej1, starSys1, 175 iter2, starRej2, starSys2, starLimit, 176 transIter, transRej, transThresh); // Transparencies for each image 177 if (!trans) { 178 psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies"); 179 return NAN; 180 } 181 182 #ifdef TESTING 183 dumpMatches("source_mags.dat", num, matches, zp, trans); 184 #endif 185 186 for (int i = 0; i < trans->n; i++) { 187 if (!isfinite(trans->data.F32[i])) { 188 inputMask->data.U8[i] = PPSTACK_MASK_CAL; 189 } 190 } 147 191 148 192 // Save best matches SOMEWHERE for future photometry 149 193 // XXX this is a really poor output location; clean up the pmFPAfiles used in ppStack 150 194 pmCell *sourcesCell = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT"); 151 psArray *sourcesBest = psArrayAllocEmpty (100);152 153 // XXX something of a hack: require at 2 detections or 1/2of the max possible154 int minMatches = PS_MAX (2, 0.5*num);195 psArray *sourcesBest = psArrayAllocEmpty(matches->n); 196 197 // XXX something of a hack: require at least 2 detections or the nominated fraction of the max possible 198 int minMatches = PS_MAX(2, fracMatch * num);// Minimum number of matches required 155 199 for (int i = 0; i < matches->n; i++) { 156 pmSourceMatch *match = matches->data[i]; // Match of interest 157 if (match->num < minMatches) continue; 158 159 // We need to grab a single instance of this source: just take the first available 160 int nImage = match->image->data.S32[0]; 161 int nIndex = match->index->data.S32[0]; 162 psArray *sources = sourceLists->data[nImage]; 163 pmSource *source = sources->data[nIndex]; 164 165 // stick this sample source on sourcesBest 166 psArrayAdd (sourcesBest, 100, source); 167 } 168 psMetadataAdd (sourcesCell->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE, "psphot sources", sourcesBest); 169 psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis\n", sourcesBest->n); 170 psFree (sourcesBest); 200 pmSourceMatch *match = matches->data[i]; // Match of interest 201 if (match->num < minMatches) { 202 continue; 203 } 204 205 // We need to grab a single instance of this source: just take the first available 206 int image = match->image->data.S32[0]; // Index of image 207 int index = match->index->data.S32[0]; // Index of source within image 208 psArray *sources = sourceLists->data[image]; // Sources for image 209 pmSource *source = sources->data[index]; // Source of interest 210 211 psArrayAdd(sourcesBest, sourcesBest->n, source); 212 } 213 psMetadataAdd(sourcesCell->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE, 214 "psphot sources", sourcesBest); 215 psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis", sourcesBest->n); 216 psFree(sourcesBest); 171 217 172 218 psFree(matches); 173 if (!trans) {174 psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies");175 return NAN;176 }177 219 178 220 // M = m + c0 + c1 * airmass - 2.5log(t) + transparency … … 182 224 // We don't need to know the magnitude zero point for the filter, since it cancels out 183 225 for (int i = 0; i < num; i++) { 226 if (!isfinite(trans->data.F32[i])) { 227 continue; 228 } 184 229 psArray *sources = sourceLists->data[i]; // Sources of interest 185 230 float magCorr = airmassTerm - 2.5*log10(sumExpTime) - zp->data.F32[i] - trans->data.F32[i]; -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackThread.c
r21477 r23352 9 9 10 10 #include "ppStack.h" 11 #include "ppStackOptions.h" 12 #include "ppStackThread.h" 13 11 14 12 15 #define THREAD_WAIT 10000 // Microseconds to wait if thread is not available … … 36 39 psFree(stack->threads); 37 40 for (int i = 0; i < stack->imageFits->n; i++) { 38 psFitsClose(stack->imageFits->data[i]); 39 psFitsClose(stack->maskFits->data[i]); 40 psFitsClose(stack->varianceFits->data[i]); 41 if (stack->imageFits->data[i]) { 42 psFitsClose(stack->imageFits->data[i]); 43 } 44 if (stack->maskFits->data[i]) { 45 psFitsClose(stack->maskFits->data[i]); 46 } 47 if (stack->varianceFits->data[i]) { 48 psFitsClose(stack->varianceFits->data[i]); 49 } 41 50 stack->imageFits->data[i] = stack->maskFits->data[i] = stack->varianceFits->data[i] = NULL; 42 51 } … … 47 56 } 48 57 49 ppStackThreadData *ppStackThreadDataSetup(const psArray *cells, const psArray *imageNames, 50 const psArray *maskNames, const psArray *varianceNames, 51 const psArray *covariances, const pmConfig *config) 52 { 58 ppStackThreadData *ppStackThreadDataSetup(const ppStackOptions *options, const pmConfig *config) 59 { 60 psAssert(options, "Require options"); 61 psAssert(config, "Require configuration"); 62 63 const psArray *cells = options->cells; // Array of input cells 64 const psArray *imageNames = options->imageNames; // Names of images to read 65 const psArray *maskNames = options->maskNames; // Names of masks to read 66 const psArray *varianceNames = options->varianceNames; // Names of variance maps to read 67 const psArray *covariances = options->covariances; // Covariance matrices (already read) 68 53 69 PS_ASSERT_ARRAY_NON_NULL(cells, NULL); 54 70 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, imageNames, NULL); … … 239 255 240 256 { 241 psThreadTask *task = psThreadTaskAlloc("PPSTACK_INITIAL_COMBINE", 6);257 psThreadTask *task = psThreadTaskAlloc("PPSTACK_INITIAL_COMBINE", 3); 242 258 task->function = &ppStackReadoutInitialThread; 243 259 psThreadTaskAdd(task); … … 253 269 254 270 { 255 psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 7);271 psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 3); 256 272 task->function = &ppStackReadoutFinalThread; 257 273 psThreadTaskAdd(task); -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackVersion.c
r18419 r23352 7 7 #include <psmodules.h> 8 8 #include <ppStats.h> 9 #include <psphot.h> 9 10 10 11 #include "ppStack.h" 11 12 12 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name 13 #ifndef PPSTACK_VERSION 14 #error "PPSTACK_VERSION is not set" 15 #endif 16 #ifndef PPSTACK_BRANCH 17 #error "PPSTACK_BRANCH is not set" 18 #endif 19 #ifndef PPSTACK_SOURCE 20 #error "PPSTACK_SOURCE is not set" 21 #endif 22 23 #define xstr(s) str(s) 24 #define str(s) #s 13 25 14 26 psString ppStackVersion(void) 15 27 { 16 psString version = NULL; // Version, to return 17 psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION); 18 return version; 28 char *value = NULL; 29 psStringAppend(&value, "%s@%s", xstr(PPSTACK_BRANCH), xstr(PPSTACK_VERSION)); 30 return value; 31 } 32 33 psString ppStackSource(void) 34 { 35 return psStringCopy(xstr(PPSTACK_SOURCE)); 19 36 } 20 37 21 38 psString ppStackVersionLong(void) 22 39 { 23 psString version = ppStackVersion(); // Version, to return 24 psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag 25 psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__); 26 psFree(tag); 40 psString version = ppStackVersion(); // Version, to return 41 psString source = ppStackSource(); // Source 42 43 psStringPrepend(&version, "ppStack "); 44 psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__); 45 psFree(source); 46 47 #ifdef __OPTIMIZE__ 48 psStringAppend(&version, " optimised"); 49 #else 50 psStringAppend(&version, " unoptimised"); 51 #endif 52 27 53 return version; 28 } 54 }; 29 55 30 56 31 void ppStackVersionMetadata(psMetadata *metadata)57 bool ppStackVersionHeader(psMetadata *header) 32 58 { 33 PS_ASSERT_METADATA_NON_NULL(metadata,); 34 35 psString pslib = psLibVersionLong();// psLib version 36 psString psmodules = psModulesVersionLong(); // psModules version 37 psString ppStats = ppStatsVersionLong(); // ppStats version 38 psString ppStack = ppStackVersionLong(); // ppStack version 59 PS_ASSERT_METADATA_NON_NULL(header, false); 39 60 40 61 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 41 62 psString timeString = psTimeToISO(time); // The time in an ISO string 42 63 psFree(time); 43 psString head = NULL; // Head string 44 psStringAppend(&head, "ppStack processing at %s. Component information:", timeString); 64 psString history = NULL; // History string 65 psStringAppend(&history, "ppStack at %s", timeString); 66 psFree(timeString); 67 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history); 68 psFree(history); 69 70 psLibVersionHeader(header); 71 psModulesVersionHeader(header); 72 psphotVersionHeader(header); 73 ppStatsVersionHeader(header); 74 75 psString version = ppStackVersion(); // Software version 76 psString source = ppStackSource(); // Software source 77 78 psStringPrepend(&version, "ppStack version: "); 79 psStringPrepend(&source, "ppStack source: "); 80 81 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version); 82 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source); 83 84 psFree(version); 85 psFree(source); 86 87 return true; 88 } 89 90 void ppStackVersionPrint(void) 91 { 92 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 93 psString timeString = psTimeToISO(time); // The time in an ISO string 94 psFree(time); 95 psLogMsg("ppStack", PS_LOG_INFO, "ppStack at %s", timeString); 45 96 psFree(timeString); 46 97 47 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", head);48 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", pslib);49 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", psmodules);50 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", ppStats);51 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", ppStack);98 psString pslib = psLibVersionLong();// psLib version 99 psString psmodules = psModulesVersionLong(); // psModules version 100 psString psphot = psphotVersionLong(); // psphot version 101 psString ppStats = ppStatsVersionLong(); // psastro version 102 psString ppStack = ppStackVersionLong(); // ppStack version 52 103 53 psFree(head); 104 psLogMsg("ppStack", PS_LOG_INFO, "%s", pslib); 105 psLogMsg("ppStack", PS_LOG_INFO, "%s", psmodules); 106 psLogMsg("ppStack", PS_LOG_INFO, "%s", psphot); 107 psLogMsg("ppStack", PS_LOG_INFO, "%s", ppStats); 108 psLogMsg("ppStack", PS_LOG_INFO, "%s", ppStack); 109 54 110 psFree(pslib); 55 111 psFree(psmodules); 112 psFree(psphot); 56 113 psFree(ppStats); 57 114 psFree(ppStack); -
branches/cnb_branches/cnb_branch_20090301/ppStats/src/Makefile.am
r19626 r23352 1 1 lib_LTLIBRARIES = libppStats.la 2 libppStats_la_CFLAGS = $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 2 3 # PPSTATS_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 4 # PPSTATS_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi` 5 # PPSTATS_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 6 # 7 # # Force recompilation of ppStatsVersion.c, since it gets the version information 8 # ppStatsVersion.c: FORCE 9 # touch ppStatsVersion.c 10 # FORCE: ; 11 12 libppStats_la_CFLAGS = $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPSTATS_VERSION=$(SVN_VERSION) -DPPSTATS_BRANCH=$(SVN_BRANCH) -DPPSTATS_SOURCE=$(SVN_SOURCE) 3 13 libppStats_la_LDFLAGS = $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 4 14 -
branches/cnb_branches/cnb_branch_20090301/ppStats/src/ppStats.h
r21183 r23352 22 22 psList *summary; // Summary statistics to calculate 23 23 // Options for input data 24 bool doFirstReadout3D; // for 3D data, use the first readout?24 bool doFirstReadout3D; // for 3D data, use the first readout? 25 25 float sample; // Fraction of cell to sample for statistics 26 psImageMaskType maskVal; // Mask value for images26 psImageMaskType maskVal; // Mask value for images 27 27 psList *chips; // Chips to look at 28 28 psList *cells; // Cells to look at … … 108 108 psString ppStatsVersion(void); 109 109 110 /// Return source information 111 psString ppStatsSource(void); 112 110 113 /// Return long version information 111 114 psString ppStatsVersionLong(void); 115 116 /// Populate header with version information 117 bool ppStatsVersionHeader( 118 psMetadata *header ///< Header to populate 119 ); 120 112 121 113 122 void p_ppStatsGetMetadata(psMetadata *target, // Target for metadata -
branches/cnb_branches/cnb_branch_20090301/ppStats/src/ppStatsFromMetadataPrint.c
r20305 r23352 41 41 VALUE_NUMERICAL_CASE(F64, "lf", F64); 42 42 case PS_DATA_STRING: 43 fprintf(f, "%s '%s' ", entry->flag, entry->value->data.str); 43 if (entry->value->data.str) { 44 fprintf(f, "%s '%s' ", entry->flag, entry->value->data.str); 45 } 44 46 break; 45 47 case PS_DATA_BOOL: … … 50 52 case PS_DATA_TIME: { 51 53 psTime *t = (psTime*)entry->value->data.V; 52 psString str = psTimeToISO(t); 53 fprintf(f, "%s %.19sZ ", entry->flag, str); 54 psFree(str); 54 if (t) { 55 psString str = psTimeToISO(t); 56 fprintf(f, "%s %.19sZ ", entry->flag, str); 57 psFree(str); 58 } 55 59 break; 56 60 } -
branches/cnb_branches/cnb_branch_20090301/ppStats/src/ppStatsVersion.c
r13993 r23352 1 1 #include "ppStatsInternal.h" 2 2 3 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name 3 #ifndef PPSTATS_VERSION 4 #error "PPSTATS_VERSION is not set" 5 #endif 6 #ifndef PPSTATS_BRANCH 7 #error "PPSTATS_BRANCH is not set" 8 #endif 9 #ifndef PPSTATS_SOURCE 10 #error "PPSTATS_SOURCE is not set" 11 #endif 12 13 #define xstr(s) str(s) 14 #define str(s) #s 4 15 5 16 psString ppStatsVersion(void) 6 17 { 7 psString version = NULL; // Version, to return 8 psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION); 9 return version; 18 char *value = NULL; 19 psStringAppend(&value, "%s@%s", xstr(PPSTATS_BRANCH), xstr(PPSTATS_VERSION)); 20 return value; 21 } 22 23 psString ppStatsSource(void) 24 { 25 return psStringCopy(xstr(PPSTATS_SOURCE)); 10 26 } 11 27 12 28 psString ppStatsVersionLong(void) 13 29 { 14 psString version = ppStatsVersion(); // Version, to return 15 psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag 16 psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__); 17 psFree(tag); 30 psString version = ppStatsVersion(); // Version, to return 31 psString source = ppStatsSource(); // Source 32 33 psStringPrepend(&version, "ppStats "); 34 psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__); 35 psFree(source); 36 37 #ifdef __OPTIMIZE__ 38 psStringAppend(&version, " optimised"); 39 #else 40 psStringAppend(&version, " unoptimised"); 41 #endif 42 18 43 return version; 44 }; 45 46 bool ppStatsVersionHeader(psMetadata *header) 47 { 48 PS_ASSERT_METADATA_NON_NULL(header, false); 49 50 psString version = ppStatsVersion(); // Software version 51 psString source = ppStatsSource(); // Software source 52 53 psStringPrepend(&version, "ppStats version: "); 54 psStringPrepend(&source, "ppStats source: "); 55 56 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version); 57 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source); 58 59 psFree(version); 60 psFree(source); 61 62 return true; 19 63 } -
branches/cnb_branches/cnb_branch_20090301/ppSub
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/cnb_branches/cnb_branch_20090215/ppSub merged eligible /trunk/ppSub merged eligible /branches/cnb_branch_20090215/ppSub 21495-22685 /branches/eam_branches/eam_branch_20090303/ppSub 23158-23228
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/cnb_branches/cnb_branch_20090301/ppSub/src/Makefile.am
r21257 r23352 1 1 bin_PROGRAMS = ppSub ppSubKernel 2 2 3 ppSub_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPSUB_CFLAGS) 3 # PPSUB_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 4 # PPSUB_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi` 5 # PPSUB_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 6 # 7 # # Force recompilation of ppSubVersion.c, since it gets the version information 8 # ppSubVersion.c: FORCE 9 # touch ppSubVersion.c 10 # FORCE: ; 11 12 ppSub_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPSUB_CFLAGS) -DPPSUB_VERSION=$(SVN_VERSION) -DPPSUB_BRANCH=$(SVN_BRANCH) -DPPSUB_SOURCE=$(SVN_SOURCE) 4 13 ppSub_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PPSUB_LIBS) 5 14 -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSub.c
r21524 r23352 34 34 goto die; 35 35 } 36 37 ppSubVersionPrint(); 36 38 37 39 if (!pmModelClassInit()) { … … 75 77 psTimerStop(); 76 78 77 pm SubtractionVisualClose(); //close plot windows, if -visual is set79 pmVisualClose(); //close plot windows, if -visual is set 78 80 psFree(config); 79 81 pmModelClassCleanup(); -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSub.h
r21524 r23352 89 89 ); 90 90 91 /// Put the program version information into a metadata92 void ppSubVersionMetadata(psMetadata *metadata ///< Metadatato populate91 /// Put the program version information into a header 92 bool ppSubVersionHeader(psMetadata *header ///< Header to populate 93 93 ); 94 95 /// Print version information 96 void ppSubVersionPrint(void); 94 97 95 98 -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubArguments.c
r21524 r23352 29 29 { 30 30 fprintf(stderr, "\nPan-STARRS PSF-matched image subtraction\n\n"); 31 fprintf(stderr, "Usage: %s INPUT.fits REFERENCE.fitsOUTPUT_ROOT \n"32 "\t[-psf REFERENCE.psf.fits] [-sources REFERENCE.cmf]\n\n"31 fprintf(stderr, "Usage: %s OUTPUT_ROOT \n" 32 "\t[-psf REFERENCE.psf.fits]\n\n" 33 33 "This subtracts the convolved REFERENCE from the INPUT, by default.\n", 34 34 program); … … 191 191 bool ppSubArgumentsSetup(int argc, char *argv[], pmConfig *config) 192 192 { 193 int argnum; // Argument Number193 // int argnum; // Argument Number 194 194 assert(config); 195 195 … … 200 200 } 201 201 202 if ((argnum = psArgumentGet(argc, argv, "-psphot-visual"))) {203 psArgumentRemove(argnum, &argc, argv);204 psphotSetVisual(true);205 }206 207 pmConfigFileSetsMD(config->arguments, &argc, argv, "PPSUB.SOURCES", "-sources", NULL);208 202 209 203 psMetadata *arguments = config->arguments; // Command-line arguments 204 psMetadataAddStr(arguments, PS_LIST_TAIL, "-inimage", 0, "Input image", NULL); 210 205 psMetadataAddStr(arguments, PS_LIST_TAIL, "-inmask", 0, "Input mask image", NULL); 211 206 psMetadataAddStr(arguments, PS_LIST_TAIL, "-invariance", 0, "Input variance image", NULL); 207 psMetadataAddStr(arguments, PS_LIST_TAIL, "-insources", 0, "Input source list", NULL); 208 psMetadataAddStr(arguments, PS_LIST_TAIL, "-refimage", 0, "Reference image", NULL); 212 209 psMetadataAddStr(arguments, PS_LIST_TAIL, "-refmask", 0, "Reference mask image", NULL); 213 210 psMetadataAddStr(arguments, PS_LIST_TAIL, "-refvariance", 0, "Reference variance image", NULL); 211 psMetadataAddStr(arguments, PS_LIST_TAIL, "-refsources", 0, "Reference source list", NULL); 212 psMetadataAddStr(arguments, PS_LIST_TAIL, "-kernel", 0, "Precalculated kernel to apply", NULL); 214 213 psMetadataAddStr(arguments, PS_LIST_TAIL, "-stats", 0, "Statistics file", NULL); 215 214 psMetadataAddF32(arguments, PS_LIST_TAIL, "-region", 0, "Size of iso-kernel region", NAN); … … 228 227 psMetadataAddF32(arguments, PS_LIST_TAIL, "-spacing", 0, "Typical stamp spacing (pixels)", NAN); 229 228 psMetadataAddS32(arguments, PS_LIST_TAIL, "-footprint", 0, "Stamp footprint half-size (pixels)", -1); 229 psMetadataAddF32(arguments, PS_LIST_TAIL, "-source-radius", 0, "Source matching radius (pixels)", NAN); 230 230 psMetadataAddS32(arguments, PS_LIST_TAIL, "-stride", 0, "Size of convolution patches (pixels)", -1); 231 231 psMetadataAddF32(arguments, PS_LIST_TAIL, "-threshold", 0, "Minimum threshold for stamps (ADU)", NAN); … … 256 256 psMetadataAddBool(arguments, PS_LIST_TAIL, "-visual", 0, "Show diagnostic plots", NULL); 257 257 258 if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 4) {258 if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 2) { 259 259 usage(argv[0], arguments, config); 260 260 } 261 261 262 fileList("INPUT", argv[1], "Name of the input image", config);263 fileList("REF", argv[2], "Name of the reference image", config);264 262 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[3]); 265 263 264 265 const char *inImage = psMetadataLookupStr(NULL, arguments, "-inimage"); // Name of input image 266 if (inImage && strlen(inImage) > 0) { 267 fileList("INPUT", inImage, "Name of the input image", config); 268 } 266 269 const char *inMask = psMetadataLookupStr(NULL, arguments, "-inmask"); // Name of input mask 267 270 if (inMask && strlen(inMask) > 0) { … … 272 275 fileList("INPUT.VARIANCE", inVariance, "Name of the input variance image", config); 273 276 } 274 277 const char *inSources = psMetadataLookupStr(NULL, arguments, "-insources"); // Name of input source list 278 if (inSources && strlen(inSources) > 0) { 279 fileList("INPUT.SOURCES", inSources, "Name of the input source list", config); 280 } 281 282 const char *refImage = psMetadataLookupStr(NULL, arguments, "-refimage"); // Name of reference image 283 if (refImage && strlen(refImage) > 0) { 284 fileList("INPUT", refImage, "Name of the reference image", config); 285 } 275 286 const char *refMask = psMetadataLookupStr(NULL, arguments, "-refmask"); // Name of reference mask 276 287 if (refMask && strlen(refMask) > 0) { … … 280 291 if (refVariance && strlen(refVariance) > 0) { 281 292 fileList("REF.VARIANCE", refVariance, "Name of the reference variance image", config); 293 } 294 const char *refSources = psMetadataLookupStr(NULL, arguments, "-refsources"); // Name of ref source list 295 if (refSources && strlen(refSources) > 0) { 296 fileList("REF.SOURCES", refSources, "Name of the reference source list", config); 297 } 298 299 const char *kernel = psMetadataLookupStr(NULL, arguments, "-kernel"); // Name of kernel 300 if (kernel && strlen(kernel) > 0) { 301 fileList("KERNEL", kernel, "Name of the kernel to apply", config); 282 302 } 283 303 … … 304 324 } 305 325 306 VALUE_ARG_RECIPE_FLOAT("-region", "REGION.SIZE", F32); 307 VALUE_ARG_RECIPE_INT("-size", "KERNEL.SIZE", S32, 0); 308 VALUE_ARG_RECIPE_INT("-order", "SPATIAL.ORDER", S32, -1); 309 VALUE_ARG_RECIPE_FLOAT("-spacing", "STAMP.SPACING", F32); 310 VALUE_ARG_RECIPE_INT("-rings-order", "RINGS.ORDER", S32, -1); 311 VALUE_ARG_RECIPE_INT("-inner", "INNER", S32, -1); 312 VALUE_ARG_RECIPE_INT("-spam-binning", "SPAM.BINNING", S32, 0); 313 VALUE_ARG_RECIPE_INT("-footprint", "STAMP.FOOTPRINT", S32, -1); 314 VALUE_ARG_RECIPE_INT("-stride", "STRIDE", S32, -1); 315 VALUE_ARG_RECIPE_FLOAT("-threshold", "STAMP.THRESHOLD", F32); 316 VALUE_ARG_RECIPE_INT("-iter", "ITER", S32, -1); 317 VALUE_ARG_RECIPE_FLOAT("-rej", "REJ", F32); 318 VALUE_ARG_RECIPE_FLOAT("-sys", "SYS", F32); 319 VALUE_ARG_RECIPE_FLOAT("-badfrac", "BADFRAC", F32); 320 VALUE_ARG_RECIPE_FLOAT("-penalty", "PENALTY", F32); 321 VALUE_ARG_RECIPE_FLOAT("-poor-frac", "POOR.FRACTION", F32); 322 VALUE_ARG_RECIPE_INT("-bin1", "BIN1", S32, 0); 323 VALUE_ARG_RECIPE_INT("-bin2", "BIN2", S32, 0); 326 VALUE_ARG_RECIPE_FLOAT("-region", "REGION.SIZE", F32); 327 VALUE_ARG_RECIPE_INT("-size", "KERNEL.SIZE", S32, 0); 328 VALUE_ARG_RECIPE_INT("-order", "SPATIAL.ORDER", S32, -1); 329 VALUE_ARG_RECIPE_FLOAT("-spacing", "STAMP.SPACING", F32); 330 VALUE_ARG_RECIPE_INT("-rings-order", "RINGS.ORDER", S32, -1); 331 VALUE_ARG_RECIPE_INT("-inner", "INNER", S32, -1); 332 VALUE_ARG_RECIPE_INT("-spam-binning", "SPAM.BINNING", S32, 0); 333 VALUE_ARG_RECIPE_INT("-footprint", "STAMP.FOOTPRINT", S32, -1); 334 VALUE_ARG_RECIPE_FLOAT("-source-radius", "SOURCE.RADIUS", F32); 335 VALUE_ARG_RECIPE_INT("-stride", "STRIDE", S32, -1); 336 VALUE_ARG_RECIPE_FLOAT("-threshold", "STAMP.THRESHOLD", F32); 337 VALUE_ARG_RECIPE_INT("-iter", "ITER", S32, -1); 338 VALUE_ARG_RECIPE_FLOAT("-rej", "REJ", F32); 339 VALUE_ARG_RECIPE_FLOAT("-sys", "SYS", F32); 340 VALUE_ARG_RECIPE_FLOAT("-badfrac", "BADFRAC", F32); 341 VALUE_ARG_RECIPE_FLOAT("-penalty", "PENALTY", F32); 342 VALUE_ARG_RECIPE_FLOAT("-poor-frac", "POOR.FRACTION", F32); 343 VALUE_ARG_RECIPE_INT("-bin1", "BIN1", S32, 0); 344 VALUE_ARG_RECIPE_INT("-bin2", "BIN2", S32, 0); 324 345 325 346 valueArgRecipeStr(arguments, recipe, "-mask-in", "MASK.IN", recipe); … … 360 381 361 382 if (psMetadataLookupBool(NULL, arguments, "-visual")) { 362 pm SubtractionSetVisual(true);383 pmVisualSetVisual(true); 363 384 } 364 385 … … 376 397 psTrace("ppSub", 1, "Done reading command-line arguments\n"); 377 398 378 // Dump configuration, now that's it's settled379 psBool status;380 psString dump_file = psMetadataLookupStr(&status, config->arguments, "-dumpconfig");381 if (dump_file) {382 pmConfigCamerasCull(config, NULL);383 pmConfigRecipesCull(config, "PPSUB,PPSTATS,PSPHOT,MASKS");384 385 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSUB.INPUT"); // Input file386 pmConfigDump(config, input->fpa, dump_file);387 }388 389 399 // XXX move this to ppSubArguments 390 400 int threads = psMetadataLookupS32(NULL, config->arguments, "-threads"); // Number of threads -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubBackground.c
r21524 r23352 53 53 } 54 54 } 55 psImageBinning *binning = psMetadataLookupPtr(&mdok, psphotRecipe,55 psImageBinning *binning = psMetadataLookupPtr(&mdok, modelRO->analysis, 56 56 "PSPHOT.BACKGROUND.BINNING"); // Binning for model 57 57 psImage *modelImage = modelRO->image; // Background model -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubCamera.c
r21524 r23352 22 22 #include "ppSub.h" 23 23 24 // Define an input file 25 static pmFPAfile *defineInputFile(pmConfig *config,// Configuration 26 pmFPAfile *bind, // File to which to bind, or NULL 27 char *filerule, // Name of file rule 28 char *argname, // Argument name 29 pmFPAfileType fileType // Type of file 30 ) 31 { 32 bool status; 33 34 // look for the file on the RUN metadata 35 pmFPAfile *file = pmFPAfileDefineFromRun(&status, config, filerule); // File to return 36 if (!status) { 37 psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule); 38 return NULL; 39 } 40 if (!file) { 41 // look for the file on the argument list 42 if (bind) { 43 file = pmFPAfileBindFromArgs(&status, bind, config, filerule, argname); 44 } else { 45 file = pmFPAfileDefineFromArgs(&status, config, filerule, argname); 46 } 47 if (!status) { 48 psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule); 49 return false; 50 } 51 } 52 53 if (!file) { 54 return NULL; 55 } 56 57 if (file->type != fileType) { 58 psError(PS_ERR_UNKNOWN, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType)); 59 return NULL; 60 } 61 62 return file; 63 } 64 65 // Define an output file 66 static pmFPAfile *defineOutputFile(pmConfig *config, // Configuration 67 pmFPAfile *template, // File to use as basis for definition 68 char *filerule, // Name of file rule 69 pmFPAfileType fileType // Type of file 70 ) 71 { 72 73 pmFPAfile *file = pmFPAfileDefineFromFile(config, template, 1, 1, filerule); 74 if (!file) { 75 psError(PS_ERR_IO, false, _("Unable to generate output file from %s"), filerule); 76 return NULL; 77 } 78 if (file->type != fileType) { 79 psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType)); 80 return NULL; 81 } 82 83 return file; 84 } 85 86 87 // Define an output file that will be used in a calculation 88 // This means it might already be available in the RUN metadata 89 static pmFPAfile *defineCalcFile(pmConfig *config, // Configuration 90 pmFPAfile *bind, // File to which to bind, or NULL 91 char *filerule, // Name of file rule 92 pmFPAfileType fileType // Type of file 93 ) 94 { 95 bool status; 96 97 // look for the file on the RUN metadata 98 pmFPAfile *file = pmFPAfileDefineFromRun(&status, config, filerule); // File to return 99 if (!status) { 100 psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule); 101 return NULL; 102 } 103 if (file) { 104 // It's an input 105 file->save = false; 106 } 107 108 // define new version of file 109 if (!file) { 110 pmFPAfileDefineOutput(config, bind ? bind->fpa : NULL, filerule); 111 if (!status) { 112 psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule); 113 return false; 114 } 115 if (file) { 116 // It's an output 117 file->save = true; 118 } 119 } 120 121 if (!file) { 122 return NULL; 123 } 124 125 if (file->type != fileType) { 126 psError(PS_ERR_UNKNOWN, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType)); 127 return NULL; 128 } 129 130 return file; 131 } 132 133 24 134 bool ppSubCamera(pmConfig *config) 25 135 { 26 bool status = false; // result from pmFPAfileDefine operations136 psAssert(config, "Require configuration"); 27 137 28 138 // Input image 29 pmFPAfile *input = pmFPAfileDefineFromArgs(&status, config, "PPSUB.INPUT", "INPUT");30 if (! status || !input) {139 pmFPAfile *input = defineInputFile(config, NULL, "PPSUB.INPUT", "INPUT", PM_FPA_FILE_IMAGE); 140 if (!input) { 31 141 psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.INPUT"); 32 142 return false; 33 143 } 34 if (input->type != PM_FPA_FILE_IMAGE) { 35 psError(PS_ERR_IO, true, "PPSUB.INPUT is not of type IMAGE"); 36 return false; 37 } 38 39 // Input mask 40 pmFPAfile *inputMask = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.MASK", "INPUT.MASK"); 41 if (!status) { 42 psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.MASK"); 43 return NULL; 44 } 45 if (inputMask && inputMask->type != PM_FPA_FILE_MASK) { 46 psError(PS_ERR_IO, true, "PPSUB.INPUT.MASK is not of type MASK"); 47 return false; 48 } 49 50 // Input variance map 51 pmFPAfile *inputVariance = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE"); 52 if (!status) { 53 psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.VARIANCE"); 54 return NULL; 55 } 56 if (inputVariance && inputVariance->type != PM_FPA_FILE_VARIANCE) { 57 psError(PS_ERR_IO, true, "PPSUB.INPUT.VARIANCE is not of type VARIANCE"); 58 return false; 59 } 144 defineInputFile(config, input, "PPSUB.INPUT.MASK", "INPUT.MASK", PM_FPA_FILE_MASK); 145 pmFPAfile *inVar = defineInputFile(config, input, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE", 146 PM_FPA_FILE_VARIANCE); 147 defineInputFile(config, input, "PPSUB.INPUT.SOURCES", "INPUT.SOURCES", PM_FPA_FILE_CMF); 60 148 61 149 // Reference image 62 status = false; 63 pmFPAfile *ref = pmFPAfileDefineFromArgs(&status, config, "PPSUB.REF", "REF"); 150 pmFPAfile *ref = defineInputFile(config, NULL, "PPSUB.REF", "REF", PM_FPA_FILE_IMAGE); 64 151 if (!ref) { 65 152 psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.REF"); 66 153 return false; 67 154 } 68 if (ref->type != PM_FPA_FILE_IMAGE) { 69 psError(PS_ERR_IO, true, "PPSUB.REF is not of type IMAGE"); 70 return false; 71 } 72 73 // Reference mask 74 pmFPAfile *refMask = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.MASK", "REF.MASK"); 75 if (!status) { 76 psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.MASK"); 77 return NULL; 78 } 79 if (refMask && refMask->type != PM_FPA_FILE_MASK) { 80 psError(PS_ERR_IO, true, "PPSUB.REF.MASK is not of type MASK"); 81 return false; 82 } 83 84 // Reference variance map 85 pmFPAfile *refVariance = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.VARIANCE", "REF.VARIANCE"); 86 if (!status) { 87 psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.VARIANCE"); 88 return NULL; 89 } 90 if (refVariance && refVariance->type != PM_FPA_FILE_VARIANCE) { 91 psError(PS_ERR_IO, true, "PPSUB.REF.VARIANCE is not of type VARIANCE"); 92 return false; 93 } 155 defineInputFile(config, ref, "PPSUB.REF.MASK", "REF.MASK", PM_FPA_FILE_MASK); 156 pmFPAfile *refVar = defineInputFile(config, ref, "PPSUB.REF.VARIANCE", "REF.VARIANCE", 157 PM_FPA_FILE_VARIANCE); 158 defineInputFile(config, ref, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF); 159 94 160 95 161 // Output image 96 pmFPAfile *output = pmFPAfileDefineFromFile(config, input, 1, 1, "PPSUB.OUTPUT"); 97 if (!output) { 98 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT")); 99 return false; 100 } 101 if (output->type != PM_FPA_FILE_IMAGE) { 102 psError(PS_ERR_IO, true, "PPSUB.OUTPUT is not of type IMAGE"); 162 pmFPAfile *output = defineOutputFile(config, input, "PPSUB.OUTPUT", PM_FPA_FILE_IMAGE); 163 pmFPAfile *outMask = defineOutputFile(config, output, "PPSUB.OUTPUT.MASK", PM_FPA_FILE_MASK); 164 if (!output || !outMask) { 165 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 103 166 return false; 104 167 } 105 168 output->save = true; 106 107 // Output mask108 pmFPAfile *outMask = pmFPAfileDefineOutput(config, output->fpa, "PPSUB.OUTPUT.MASK");109 if (!outMask) {110 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.MASK"));111 return false;112 }113 if (outMask->type != PM_FPA_FILE_MASK) {114 psError(PS_ERR_IO, true, "PPSUB.OUTPUT.MASK is not of type MASK");115 return false;116 }117 169 outMask->save = true; 118 119 // Output variance 120 if (inputVariance && refVariance) { 121 pmFPAfile *outVariance = pmFPAfileDefineOutput(config, output->fpa, "PPSUB.OUTPUT.VARIANCE"); 122 if (!outVariance) { 123 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.VARIANCE")); 124 return false; 125 } 126 if (outVariance->type != PM_FPA_FILE_VARIANCE) { 127 psError(PS_ERR_IO, true, "PPSUB.OUTPUT.VARIANCE is not of type VARIANCE"); 128 return false; 129 } 130 outVariance->save = true; 131 } 170 pmFPAfile *outVar = NULL; 171 if (inVar && refVar) { 172 outVar = defineOutputFile(config, output, "PPSUB.OUTPUT.VARIANCE", PM_FPA_FILE_VARIANCE); 173 if (!outVar) { 174 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 175 return false; 176 } 177 outVar->save = true; 178 } 179 132 180 133 181 // Convolved input image 134 pmFPAfile *inConv = pmFPAfileDefineFromFile(config, input, 1, 1, "PPSUB.INPUT.CONV"); 135 if (!inConv) { 136 psError(PS_ERR_IO, false, _("Unable to generate output file for PPSUB.INPUT.CONV")); 137 return false; 138 } 139 if (output->type != PM_FPA_FILE_IMAGE) { 140 psError(PS_ERR_IO, true, "PPSUB.INPUT.CONV is not of type IMAGE"); 141 return false; 142 } 143 // XXX should be based on recipe : inConv->save = true; 144 145 // Convolved input mask 146 pmFPAfile *inConvMask = pmFPAfileDefineOutput(config, inConv->fpa, "PPSUB.INPUT.CONV.MASK"); 147 if (!inConvMask) { 148 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.INPUT.CONV.MASK")); 149 return false; 150 } 151 if (inConvMask->type != PM_FPA_FILE_MASK) { 152 psError(PS_ERR_IO, true, "PPSUB.INPUT.CONV.MASK is not of type MASK"); 153 return false; 154 } 155 // XXX should be based on recipe : inConvMask->save = true; 156 157 // Convolved input variance 158 if (inputVariance) { 159 pmFPAfile *inConvVariance = pmFPAfileDefineOutput(config, inConv->fpa, "PPSUB.INPUT.CONV.VARIANCE"); 160 if (!inConvVariance) { 161 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.VARIANCE")); 162 return false; 163 } 164 if (inConvVariance->type != PM_FPA_FILE_VARIANCE) { 165 psError(PS_ERR_IO, true, "PPSUB.INPUT.CONV.VARIANCE is not of type VARIANCE"); 166 return false; 167 } 168 // XXX should be based on recipe : inConvVariance->save = true; 182 pmFPAfile *inConvImage = defineOutputFile(config, input, "PPSUB.INPUT.CONV", PM_FPA_FILE_IMAGE); 183 pmFPAfile *inConvMask = defineOutputFile(config, input, "PPSUB.INPUT.CONV.MASK", PM_FPA_FILE_MASK); 184 if (!inConvImage || !inConvMask) { 185 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 186 return false; 187 } 188 if (inVar) { 189 pmFPAfile *inConvVar = defineOutputFile(config, input, "PPSUB.INPUT.CONV.VARIANCE", 190 PM_FPA_FILE_VARIANCE); 191 if (!inConvVar) { 192 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 193 return false; 194 } 169 195 } 170 196 171 197 // Convolved ref image 172 pmFPAfile *refConv = pmFPAfileDefineFromFile(config, ref, 1, 1, "PPSUB.REF.CONV"); 173 if (!refConv) { 174 psError(PS_ERR_IO, false, _("Unable to generate output file for PPSUB.REF.CONV")); 175 return false; 176 } 177 if (output->type != PM_FPA_FILE_IMAGE) { 178 psError(PS_ERR_IO, true, "PPSUB.REF.CONV is not of type IMAGE"); 179 return false; 180 } 181 // XXX should be based on recipe : refConv->save = true; 182 183 // Convolved ref mask 184 pmFPAfile *refConvMask = pmFPAfileDefineOutput(config, refConv->fpa, "PPSUB.REF.CONV.MASK"); 185 if (!refConvMask) { 186 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.REF.CONV.MASK")); 187 return false; 188 } 189 if (refConvMask->type != PM_FPA_FILE_MASK) { 190 psError(PS_ERR_IO, true, "PPSUB.REF.CONV.MASK is not of type MASK"); 191 return false; 192 } 193 // XXX should be based on recipe : refConvMask->save = true; 194 195 // Convolved ref variance 196 if (refVariance) { 197 pmFPAfile *refConvVariance = pmFPAfileDefineOutput(config, refConv->fpa, "PPSUB.REF.CONV.VARIANCE"); 198 if (!refConvVariance) { 199 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.VARIANCE")); 200 return false; 201 } 202 if (refConvVariance->type != PM_FPA_FILE_VARIANCE) { 203 psError(PS_ERR_IO, true, "PPSUB.REF.CONV.VARIANCE is not of type VARIANCE"); 204 return false; 205 } 206 // XXX should be based on recipe : refConvVariance->save = true; 207 } 198 pmFPAfile *refConvImage = defineOutputFile(config, input, "PPSUB.REF.CONV", PM_FPA_FILE_IMAGE); 199 pmFPAfile *refConvMask = defineOutputFile(config, input, "PPSUB.REF.CONV.MASK", PM_FPA_FILE_MASK); 200 if (!refConvImage || !refConvMask) { 201 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 202 return false; 203 } 204 if (refVar) { 205 pmFPAfile *refConvVar = defineOutputFile(config, input, "PPSUB.REF.CONV.VARIANCE", 206 PM_FPA_FILE_VARIANCE); 207 if (!refConvVar) { 208 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 209 return false; 210 } 211 } 212 208 213 209 214 // Output JPEGs … … 230 235 231 236 // Output subtraction kernel 232 pmFPAfile *outKernels = pmFPAfileDefineOutput(config, output->fpa, "PPSUB.OUTPUT.KERNELS"); 233 if (!outKernels) { 234 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.KERNELS")); 235 return false; 236 } 237 if (outKernels->type != PM_FPA_FILE_SUBKERNEL) { 238 psError(PS_ERR_IO, true, "PPSUB.OUTPUT.KERNELS is not of type SUBKERNEL"); 239 return false; 240 } 241 outKernels->save = true; 242 243 #if 0 244 if (!pmFPAAddSourceFromFormat(output->fpa, "Subtraction", output->format)) { 245 psError(PS_ERR_UNKNOWN, false, "Unable to generate output FPA."); 246 return false; 247 } 248 #endif 249 250 pmFPAfile *sources = pmFPAfileDefineFromArgs(&status, config, "PPSUB.SOURCES", "PPSUB.SOURCES"); 251 if (!status) { 252 psError(PS_ERR_IO, false, "Failed to load file definition PPSUB.SOURCES"); 253 return false; 254 } 255 if (sources && sources->type != PM_FPA_FILE_CMF) { 256 psError(PS_ERR_IO, true, "PPSUB.SOURCES is not of type CMF"); 237 pmFPAfile *kernel = defineCalcFile(config, output, "PPSUB.OUTPUT.KERNELS", PM_FPA_FILE_SUBKERNEL); 238 if (!kernel) { 239 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to define file PPSUB.OUTPUT.KERNELS"); 257 240 return false; 258 241 } -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubLoop.c
r21524 r23352 23 23 bool ppSubLoop(pmConfig *config) 24 24 { 25 psAssert(config, "Require configuration."); 26 27 pmConfigCamerasCull(config, NULL); 28 pmConfigRecipesCull(config, "PPSUB,PPSTATS,PSPHOT,MASKS,JPEG"); 29 25 30 bool mdok; // Status of MD lookup 26 31 const char *statsName = psMetadataLookupStr(&mdok, config->arguments, "STATS"); // Filename for statistics … … 59 64 60 65 pmFPAview *view = pmFPAviewAlloc(0); // Pointer into FPA hierarchy 61 pmHDU *lastHDU = NULL; // Last HDU that was updated62 66 63 67 // Iterate over the FPA hierarchy … … 99 103 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 100 104 return false; 101 }102 103 // Put version information into the header104 pmHDU *hdu = pmHDUFromCell(inCell);105 if (hdu && hdu != lastHDU) {106 if (!hdu->header) {107 hdu->header = psMetadataAlloc();108 }109 ppSubVersionMetadata(hdu->header);110 lastHDU = hdu;111 105 } 112 106 … … 183 177 } 184 178 179 psString dump_file = psMetadataLookupStr(&mdok, config->arguments, "-dumpconfig"); 180 if (dump_file) { 181 182 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSUB.INPUT"); // Input file 183 pmConfigDump(config, input->fpa, dump_file); 184 } 185 185 186 return true; 186 187 } -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubMakePSF.c
r21524 r23352 81 81 // Extract the loaded sources from the associated readout, and generate PSF 82 82 // Here, we assume the image is background-subtracted 83 pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES"); 84 psArray *sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES"); 83 psArray *sources = psMetadataLookupPtr(&mdok, minuend->analysis, "PSPHOT.SOURCES"); 85 84 if (!psphotReadoutFindPSF(config, view, sources)) { 86 85 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on subtracted image."); -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubMatchPSFs.c
r21524 r23352 49 49 bool mdok; // Status of MD lookup 50 50 51 // Load pre-calculated kernel, if available 52 pmReadout *kernelRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT.KERNEL"); // RO with kernel 53 51 54 // Sources in image, used for stamps: these must be loaded from previous analysis stages 52 pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES"); // Readout with sources 53 psArray *sources = NULL; // Sources in image; used for stamps 54 if (sourcesRO) { 55 sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES"); 55 psArray *inSources = psMetadataLookupPtr(&mdok, inRO->analysis, "PSPHOT.SOURCES"); // Input source list 56 psArray *refSources = psMetadataLookupPtr(&mdok, refRO->analysis, "PSPHOT.SOURCES"); // Ref source list 57 58 psArray *sources = NULL; // Merged list of sources 59 if (inSources && refSources) { 60 float radius = psMetadataLookupF32(NULL, recipe, "SOURCE.RADIUS"); // Matching radius 61 psArray *lists = psArrayAlloc(2); // Source lists 62 lists->data[0] = psMemIncrRefCounter(inSources); 63 lists->data[1] = psMemIncrRefCounter(refSources); 64 sources = pmSourceMatchMerge(lists, radius); 65 psFree(lists); 66 if (!sources) { 67 psError(PS_ERR_UNKNOWN, false, "Unable to merge source lists"); 68 return false; 69 } 70 } else if (inSources) { 71 sources = psMemIncrRefCounter(inSources); 72 } else if (refSources) { 73 sources = psMemIncrRefCounter(refSources); 56 74 } 75 76 psMetadataAddArray(inConv->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE, 77 "Merged source list", sources); 78 psMetadataAddArray(refConv->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE, 79 "Merged source list", sources); 80 psFree(sources); // Drop reference 57 81 58 82 int footprint = psMetadataLookupS32(NULL, recipe, "STAMP.FOOTPRINT"); // Stamp half-size … … 113 137 114 138 // Match the PSFs 115 if (!pmSubtractionMatch(inConv, refConv, inRO, refRO, footprint, stride, regionSize, spacing, threshold, 116 sources, stampsName, type, size, order, widths, orders, inner, ringsOrder, 117 binning, penalty, optimum, optWidths, optOrder, optThresh, iter, rej, sys, 118 maskVal, maskBad, maskPoor, poorFrac, badFrac, subMode)) { 119 psError(PS_ERR_UNKNOWN, false, "Unable to match images."); 120 return false; 139 if (kernelRO) { 140 if (!pmSubtractionMatchPrecalc(inConv, refConv, inRO, refRO, kernelRO->analysis, 141 stride, sys, maskVal, maskBad, maskPoor, poorFrac, badFrac)) { 142 psError(PS_ERR_UNKNOWN, false, "Unable to convolve images."); 143 return false; 144 } 145 } else { 146 if (!pmSubtractionMatch(inConv, refConv, inRO, refRO, footprint, stride, regionSize, spacing, 147 threshold, sources, stampsName, type, size, order, widths, orders, inner, 148 ringsOrder, binning, penalty, optimum, optWidths, optOrder, optThresh, iter, 149 rej, sys, maskVal, maskBad, maskPoor, poorFrac, badFrac, subMode)) { 150 psError(PS_ERR_UNKNOWN, false, "Unable to match images."); 151 return false; 152 } 121 153 } 122 154 … … 129 161 130 162 // XXX drop the pixels associated with inRO and refRO (now that we have inConv and refConf) 131 163 #ifdef TESTING 132 164 psphotSaveImage (NULL, inRO->image, "inRO.fits"); 133 165 psphotSaveImage (NULL, refRO->image, "refRO.fits"); 134 166 psphotSaveImage (NULL, inConv->image, "inConv.fits"); 135 167 psphotSaveImage (NULL, refConv->image, "refConv.fits"); 168 #endif 136 169 137 170 return true; -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubReadoutUpdate.c
r21524 r23352 44 44 psMetadataAddStr(outHDU->header, PS_LIST_TAIL, "PPSUB.INPUT", 0, 45 45 "Subtraction input", inFile->filename); 46 ppSubVersionHeader(outHDU->header); 46 47 47 48 // Statistics on the matching -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubVarianceFactors.c
r21524 r23352 65 65 66 66 psStats *vfStats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics 67 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); // Random number generator67 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 68 68 69 69 // mask these values when examining the background -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubVersion.c
r21524 r23352 19 19 #include <psmodules.h> 20 20 #include <ppStats.h> 21 #include <psphot.h> 21 22 22 23 #include "ppSub.h" 23 24 24 static const char *cvsTag = "$Name: not supported by cvs2svn $";///< CVS tag name 25 #ifndef PPSUB_VERSION 26 #error "PPSUB_VERSION is not set" 27 #endif 28 #ifndef PPSUB_BRANCH 29 #error "PPSUB_BRANCH is not set" 30 #endif 31 #ifndef PPSUB_SOURCE 32 #error "PPSUB_SOURCE is not set" 33 #endif 34 35 #define xstr(s) str(s) 36 #define str(s) #s 25 37 26 38 psString ppSubVersion(void) 27 39 { 28 psString version = NULL; // Version, to return 29 psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION); 30 return version; 40 char *value = NULL; 41 psStringAppend(&value, "%s@%s", xstr(PPSUB_BRANCH), xstr(PPSUB_VERSION)); 42 return value; 43 } 44 45 psString ppSubSource(void) 46 { 47 return psStringCopy(xstr(PPSUB_SOURCE)); 31 48 } 32 49 33 50 psString ppSubVersionLong(void) 34 51 { 35 psString version = ppSubVersion(); // Version, to return 36 psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag 37 psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__); 38 psFree(tag); 52 psString version = ppSubVersion(); // Version, to return 53 psString source = ppSubSource(); // Source 54 55 psStringPrepend(&version, "ppSub "); 56 psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__); 57 psFree(source); 58 59 #ifdef __OPTIMIZE__ 60 psStringAppend(&version, " optimised"); 61 #else 62 psStringAppend(&version, " unoptimised"); 63 #endif 64 39 65 return version; 40 } 66 }; 41 67 42 68 43 void ppSubVersionMetadata(psMetadata *metadata)69 bool ppSubVersionHeader(psMetadata *header) 44 70 { 45 PS_ASSERT_METADATA_NON_NULL(metadata,); 46 47 psString pslib = psLibVersionLong();// psLib version 48 psString psmodules = psModulesVersionLong(); // psModules version 49 psString ppStats = ppStatsVersionLong(); // ppStats version 50 psString ppSub = ppSubVersionLong(); // ppSub version 71 PS_ASSERT_METADATA_NON_NULL(header, false); 51 72 52 73 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 53 74 psString timeString = psTimeToISO(time); // The time in an ISO string 54 75 psFree(time); 55 psString head = NULL; // Head string 56 psStringAppend(&head, "ppSub processing at %s. Component information:", timeString); 76 psString history = NULL; // History string 77 psStringAppend(&history, "ppSub at %s", timeString); 78 psFree(timeString); 79 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history); 80 psFree(history); 81 82 psLibVersionHeader(header); 83 psModulesVersionHeader(header); 84 psphotVersionHeader(header); 85 ppStatsVersionHeader(header); 86 87 psString version = ppSubVersion(); // Software version 88 psString source = ppSubSource(); // Software source 89 90 psStringPrepend(&version, "ppSub version: "); 91 psStringPrepend(&source, "ppSub source: "); 92 93 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version); 94 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source); 95 96 psFree(version); 97 psFree(source); 98 99 return true; 100 } 101 102 void ppSubVersionPrint(void) 103 { 104 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 105 psString timeString = psTimeToISO(time); // The time in an ISO string 106 psFree(time); 107 psLogMsg("ppSub", PS_LOG_INFO, "ppSub at %s", timeString); 57 108 psFree(timeString); 58 109 59 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");60 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");61 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");62 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, "");63 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppSub, "");110 psString pslib = psLibVersionLong();// psLib version 111 psString psmodules = psModulesVersionLong(); // psModules version 112 psString psphot = psphotVersionLong(); // psphot version 113 psString ppStats = ppStatsVersionLong(); // ppStats version 114 psString ppSub = ppSubVersionLong(); // ppSub version 64 115 65 psFree(head); 116 psLogMsg("ppSub", PS_LOG_INFO, "%s", pslib); 117 psLogMsg("ppSub", PS_LOG_INFO, "%s", psmodules); 118 psLogMsg("ppSub", PS_LOG_INFO, "%s", psphot); 119 psLogMsg("ppSub", PS_LOG_INFO, "%s", ppStats); 120 psLogMsg("ppSub", PS_LOG_INFO, "%s", ppSub); 121 66 122 psFree(pslib); 67 123 psFree(psmodules); 124 psFree(psphot); 68 125 psFree(ppStats); 69 126 psFree(ppSub); -
branches/cnb_branches/cnb_branch_20090301/ppSub/test/fake.c
r18591 r23352 89 89 int main(int argc, char *argv[]) 90 90 { 91 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); // Random number generator91 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 92 92 93 93 // Images to generate -
branches/cnb_branches/cnb_branch_20090301/psLib/configure.ac
r21400 r23352 122 122 TMP_CPPFLAGS=${CPPFLAGS} 123 123 124 AC_ARG_WITH(cfitsio, 125 [AS_HELP_STRING(--with-cfitsio=DIR,Specify location of CFITSIO.)], 126 [CFITSIO_CFLAGS="-I$withval/include" 127 CFITSIO_LDFLAGS="-L$withval/lib"]) 128 AC_ARG_WITH(cfitsio-include, 129 [AS_HELP_STRING(--with-cfitsio-include=DIR,Specify CFITSIO include directory.)], 130 [CFITSIO_CFLAGS="-I$withval"]) 131 AC_ARG_WITH(cfitsio-lib, 132 [AS_HELP_STRING(--with-cfitsio-lib=DIR,Specify CFITSIO library directory.)], 133 [CFITSIO_LDFLAGS="-L$withval"]) 124 PKG_CHECK_MODULES([CFITSIO], [cfitsio], [], AC_MSG_ERROR([CFITSIO package not found. Obtain CFITSIO at http://heasarc.gsfc.nasa.gov/docs/software/fitsio])) 125 134 126 PSLIB_CFLAGS="${PSLIB_CFLAGS=} ${CFITSIO_CFLAGS}" 135 PSLIB_LIBS="${PSLIB_LIBS=} $ CFITSIO_LDFLAGS -lcfitsio -lm"127 PSLIB_LIBS="${PSLIB_LIBS=} ${CFITSIO_LIBS}" 136 128 137 129 CFLAGS="${CFLAGS=} ${CFITSIO_CFLAGS}" 138 LDFLAGS="${LDFLAGS=} ${CFITSIO_LDFLAGS}" 139 140 dnl Solaris needs to suck in these symbols from unusual locations 141 AC_SEARCH_LIBS([gethostbyname], [nsl]) 142 AC_SEARCH_LIBS([socket], [socket]) 143 144 AC_CHECK_HEADERS([fitsio.h],[], 145 [AC_MSG_ERROR([CFITSIO headers not found. Obtain CFITSIO at http://heasarc.gsfc.nasa.gov/docs/software/fitsio or use --with-cfitsio to specify location.])] 146 ) 147 TMP_LIBS=${LIBS} 148 AC_CHECK_LIB(cfitsio,ffopen,[], 149 [AC_MSG_ERROR([CFITSIO library not found. Obtain it at http://heasarc.gsfc.nasa.gov/docs/software/fitsio or use --with-cfitsio to specify location.])],[-lm] 150 ) 130 LDFLAGS="${LDFLAGS=} ${CFITSIO_LIBS}" 131 151 132 dnl Now check if CFITSIO supports fits_open_diskfile, i.e., is at least version 2.501 152 AC_CHECK_ LIB(cfitsio,ffdkopn,133 AC_CHECK_FUNC(ffdkopn, 153 134 [CFITSIO_DISKFILE=1], 154 135 [AC_MSG_WARN([The CFITSIO library version is rather old. Suggested version is 2.501 or greater.]) 155 CFITSIO_DISKFILE=0] ,[-lm]136 CFITSIO_DISKFILE=0] 156 137 ) 157 138 158 139 AC_DEFINE_UNQUOTED([CFITSIO_DISKFILE],${CFITSIO_DISKFILE},[Define to 1 if you have fits_open_diskfile in CFITSIO]) 140 159 141 AC_SUBST([CFITSIO_CFLAGS]) 142 AC_SUBST([CFITSIO_LIBS]) 160 143 161 144 dnl restore the LIBS/CFLAGS/LDFLAGS … … 173 156 TMP_CPPFLAGS=${CPPFLAGS} 174 157 175 AC_ARG_WITH(fftw3, 176 [AS_HELP_STRING(--with-fftw3=DIR,Specify location of FFTW version 3.)], 177 [FFTW3_CFLAGS="-I$withval/include" 178 FFTW3_LDFLAGS="-L$withval/lib"]) 179 AC_ARG_WITH(fftw3-include, 180 [AS_HELP_STRING(--with-fftw3-include=DIR,Specify FFTW version 3 include directory.)], 181 [FFTW3_CFLAGS="-I$withval"]) 182 AC_ARG_WITH(fftw3-lib, 183 [AS_HELP_STRING(--with-fftw3-lib=DIR,Specify FFTW version 3 library directory.)], 184 [FFTW3_LDFLAGS="-L$withval"]) 158 PKG_CHECK_MODULES([FFTW3], [fftw3f], [], AC_MSG_ERROR([FFTW version 3 (--enable-float) library not found. Obtain it at http://www.fftw.org/])) 159 185 160 PSLIB_CFLAGS="${PSLIB_CFLAGS=} ${FFTW3_CFLAGS}" 186 PSLIB_LIBS="${PSLIB_LIBS=} $ FFTW3_LDFLAGS -lfftw3f"161 PSLIB_LIBS="${PSLIB_LIBS=} ${FFTW3_LIBS}" 187 162 188 163 CFLAGS="${CFLAGS} ${FFTW3_CFLAGS}" 189 164 CPPFLAGS=${CFLAGS} 190 LDFLAGS="${LDFLAGS} ${FFTW3_LDFLAGS}" 191 192 AC_CHECK_LIB(fftw3f,fftwf_plan_dft_2d,[], 193 [AC_MSG_ERROR([FFTW version 3 (--enable-float) library not found. Obtain it at http://www.fftw.org/ or use --with-fftw3 to specify location.])]) 194 195 FFTW_THREADS=0 196 AC_CHECK_LIB(fftw3f,fftwf_init_threads,[FFTW_THREADS=1], 197 [AC_CHECK_LIB(fftw3f_threads,fftwf_init_threads, [ 198 FFTW_THREADS=1 199 PSLIB_LIBS="${PSLIB_LIBS=} -lfftw3f_threads"], 200 AC_MSG_WARN([FFTW version 3 not compiled with thread support (--enable-threads)]),[-lm] 201 )],[-lm] 202 ) 203 204 dnl AC_CHECK_LIB(fftw3f,fftwf_plan_dft_2d,[], 205 dnl [AC_MSG_ERROR([FFTW version 3 (--enable-float) library not found. Obtain it at http://www.fftw.org/ or use --with-fftw3 to specify location.])],[-lm] 206 dnl ) 207 208 AC_CHECK_HEADERS([fftw3.h],[], 209 [AC_MSG_ERROR([FFTW version 3 (--enable-float) headers not found. Obtain it at http://www.fftw.org/ or use --with-fftw3 to specify location.])] 210 ) 211 165 LDFLAGS="${LDFLAGS} ${FFTW3_LIBS}" 166 167 AC_CHECK_FUNC(fftwf_plan_dft_2d,[], 168 [AC_MSG_ERROR([FFTW version 3 (--enable-float) library not found. Obtain it at http://www.fftw.org/])]) 169 AC_CHECK_FUNC(fftwf_init_threads,[FFTW_THREADS=1],[FFTW_THREADS=0]) 212 170 AC_DEFINE_UNQUOTED([HAVE_FFTW_THREADS],${FFTW_THREADS},[Define to 1 if you have FFTW compiled with thread support]) 213 171 214 172 AC_SUBST([FFTW3_CFLAGS]) 173 AC_SUBST([FFTW3_LIBS]) 215 174 216 175 dnl restore the CFLAGS/LDFLAGS … … 228 187 TMP_CPPFLAGS=${CPPFLAGS} 229 188 230 AC_ARG_WITH(gsl-config, 231 [AS_HELP_STRING(--with-gsl-config=FILE,Specify location of gsl-config.)], 232 [GSL_CONFIG=$withval], 233 [GSL_CONFIG=`which gsl-config`]) 234 AC_CHECK_FILE($GSL_CONFIG,[], 235 [AC_MSG_ERROR([GSL is required. Obtain it at http://www.gnu.org/software/gsl or use --with-gsl-config to specify location.])]) 236 237 AC_MSG_CHECKING([GSL cflags]) 238 GSL_CFLAGS="`${GSL_CONFIG} --cflags`" 239 AC_MSG_RESULT([${GSL_CFLAGS}]) 240 241 AC_MSG_CHECKING([GSL ldflags]) 242 GSL_LDFLAGS="`${GSL_CONFIG} --libs`" 243 AC_MSG_RESULT([${GSL_LDFLAGS}]) 189 PKG_CHECK_MODULES([GSL], [gsl], [], AC_MSG_ERROR([GSL is required. Obtain it at http://www.gnu.org/software/gsl])) 244 190 245 191 PSLIB_CFLAGS="${PSLIB_CFLAGS=} ${GSL_CFLAGS}" 246 PSLIB_LIBS="${PSLIB_LIBS=} ${GSL_L DFLAGS}"192 PSLIB_LIBS="${PSLIB_LIBS=} ${GSL_LIBS}" 247 193 248 194 AC_SUBST([GSL_CFLAGS]) 195 AC_SUBST([GSL_LIBS]) 249 196 250 197 dnl restore the CFLAGS/LDFLAGS … … 277 224 LDFLAGS="${LDFLAGS} ${JPEG_LDFLAGS}" 278 225 279 AC_CHECK_HEADERS([jpeglib.h],[PSLIB_CFLAGS="$ PSLIB_CFLAGS $JPEG_CFLAGS"226 AC_CHECK_HEADERS([jpeglib.h],[PSLIB_CFLAGS="${PSLIB_CFLAGS=} ${JPEG_CFLAGS}" 280 227 AC_SUBST(JPEG_CFLAGS)], 281 228 [AC_MSG_ERROR([libjpeg headers not found. Obtain libjpeg from http://www.ijg.org/ or use --with-jpeg to specify location.])] 282 229 ) 283 230 284 AC_CHECK_LIB(jpeg,jpeg_CreateCompress,[PSLIB_LIBS="$ PSLIB_LIBS $JPEG_LDFLAGS-ljpeg"],231 AC_CHECK_LIB(jpeg,jpeg_CreateCompress,[PSLIB_LIBS="${PSLIB_LIBS=} ${JPEG_LDFLAGS} -ljpeg"], 285 232 [AC_MSG_ERROR([libjpeg library not found. Obtain libjpeg from http://www.ijg.org/ or use --with-jpeg to specify location.])] 286 233 ) … … 291 238 LDFLAGS=${TMP_LDFLAGS} 292 239 CPPFLAGS=${TMP_CPPFLAGS} 293 294 dnl ------------------- XML2 options ---------------------295 dnl AC_ARG_WITH(xml2-config,296 dnl [AS_HELP_STRING(--with-xml2-config=FILE,Specify location of xml2-config.)],297 dnl [XML_CONFIG=$withval],298 dnl [XML_CONFIG=`which xml2-config`])299 dnl AC_CHECK_FILE($XML_CONFIG,[],300 dnl [AC_MSG_ERROR([GNOME XML C parser is required. Obtain it at http://www.xmlsoft.org or use --with-xml2-config to specify location.])])301 dnl302 dnl AC_MSG_CHECKING([xml2 version])303 dnl XML_VERSION=`xml2-config --version`304 dnl XML_VERSION_major=`echo $XML_VERSION | ${PERL} -pe 's|^(\d+).*|\1|'`305 dnl XML_VERSION_minor=`echo $XML_VERSION | ${PERL} -pe 's|^(\d+)\.(\d+).*|\2|'`306 dnl dnl First test the minimum version of 2.6307 dnl if test $XML_VERSION_major -lt 2 || ( test $XML_VERSION_major -eq 2 && test $XML_VERSION_minor -lt 6 )308 dnl then309 dnl AC_MSG_ERROR([requires libxml2 2.6.0 or greater, found $XML_VERSION. Install newer version or use --with-xml2-config to specify another location.])310 dnl else311 dnl AC_MSG_RESULT([$XML_VERSION... yes])312 dnl fi313 dnl314 dnl AC_MSG_CHECKING([xml2 cflags])315 dnl XML_CFLAGS="`${XML_CONFIG} --cflags`"316 dnl AC_MSG_RESULT([${XML_CFLAGS}])317 dnl318 dnl AC_MSG_CHECKING([xml2 ldflags])319 dnl XML_LDFLAGS="`${XML_CONFIG} --libs`"320 dnl AC_MSG_RESULT([${XML_LDFLAGS}])321 dnl322 dnl PSLIB_CFLAGS="${PSLIB_CFLAGS=} ${XML_CFLAGS}"323 dnl PSLIB_LIBS="${PSLIB_LIBS=} ${XML_LDFLAGS}"324 dnl325 dnl AC_SUBST([XML_CFLAGS])326 240 327 241 dnl ------------------- SWIG options --------------------- … … 477 391 utils/Makefile 478 392 ]) 479 dnl src/xml/Makefile480 dnl test/xml/Makefile481 482 393 483 394 #if test "$SWIG_REQ" == "yes" -
branches/cnb_branches/cnb_branch_20090301/psLib/src/fits/psFitsHeader.c
r22432 r23352 149 149 150 150 151 bool psFitsCheck SingleCompressedImagePHU(const psFits *fits, psMetadata *header)151 bool psFitsCheckCompressedImagePHU(const psFits *fits, psMetadata *header) 152 152 { 153 153 PS_ASSERT_FITS_NON_NULL(fits, false); … … 163 163 } 164 164 165 if (psFitsGetSize(fits) != 2) {166 // No second extension, or multiple extensions165 if (psFitsGetSize(fits) == 1) { 166 // No extension present 167 167 return false; 168 168 } … … 416 416 // Explore the potential case that this is an empty PHU, and the first extension contains the sole image, 417 417 // which is compressed. 418 if (psFitsCheck SingleCompressedImagePHU(fits, header)) {418 if (psFitsCheckCompressedImagePHU(fits, header)) { 419 419 // This is really what we want, not the empty PHU 420 420 psTrace("psLib.fits", 1, -
branches/cnb_branches/cnb_branch_20090301/psLib/src/fits/psFitsHeader.h
r15179 r23352 20 20 21 21 22 /// Determine whether the current HDU is an empty PHU with a singlecompressed image following.22 /// Determine whether the current HDU is an empty PHU with a compressed image following. 23 23 /// 24 24 /// In that case, what should be treated as an image PHU is technically an empty PHU with a binary table … … 26 26 /// following compressed image to determine if this is the case. If so, the FITS file pointer is left 27 27 /// pointing at the compressed image. 28 bool psFitsCheck SingleCompressedImagePHU(const psFits *fits, ///< FITS file pointer29 const psMetadata *header ///< Header, or NULL28 bool psFitsCheckCompressedImagePHU(const psFits *fits, ///< FITS file pointer 29 const psMetadata *header ///< Header, or NULL 30 30 ); 31 31 -
branches/cnb_branches/cnb_branch_20090301/psLib/src/fits/psFitsImage.c
r21535 r23352 219 219 PS_ASSERT_FITS_NON_NULL(fits, NULL); 220 220 221 if (psFitsCheck SingleCompressedImagePHU(fits, NULL)) {221 if (psFitsCheckCompressedImagePHU(fits, NULL)) { 222 222 // This is really what we want, not the empty PHU 223 223 psTrace("psLib.fits", 1, … … 432 432 PS_ASSERT_INT_NONNEGATIVE(z, NULL); 433 433 434 if (psFitsCheck SingleCompressedImagePHU(fits, NULL)) {434 if (psFitsCheckCompressedImagePHU(fits, NULL)) { 435 435 // This is really what we want, not the empty PHU 436 436 psTrace("psLib.fits", 1, … … 479 479 } 480 480 481 if (psFitsCheck SingleCompressedImagePHU(fits, NULL)) {481 if (psFitsCheckCompressedImagePHU(fits, NULL)) { 482 482 // This is really what we want, not the empty PHU 483 483 psTrace("psLib.fits", 1, … … 873 873 // code replication, and should be sufficient for our needs. 874 874 875 if (psFitsCheck SingleCompressedImagePHU(fits, NULL)) {875 if (psFitsCheckCompressedImagePHU(fits, NULL)) { 876 876 // This is really what we want, not the empty PHU 877 877 psTrace("psLib.fits", 1, -
branches/cnb_branches/cnb_branch_20090301/psLib/src/fits/psFitsScale.c
r21183 r23352 112 112 // psImageBackground automatically excludes pixels that are non-finite, so we don't need to bother about a 113 113 // mask. 114 psU64 seed = p_psRandomGetSystemSeed(false); 115 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, seed); 114 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 116 115 psStats *stats = psStatsAlloc(MEAN_STAT | STDEV_STAT); // Statistics object 117 116 if (!psImageBackground(stats, NULL, image, mask, maskVal, rng)) { … … 290 289 if (!psMemIncrRefCounter(rng) && options->fuzz) { 291 290 // Don't blab about which seed we're going to get --- it's not necessary for this purpose 292 psU64 seed = p_psRandomGetSystemSeed(false); 293 rng = psRandomAlloc(PS_RANDOM_TAUS, seed); 291 rng = psRandomAlloc(PS_RANDOM_TAUS); 294 292 } 295 293 -
branches/cnb_branches/cnb_branch_20090301/psLib/src/imageops/psImageCovariance.c
r21467 r23352 43 43 } else { 44 44 covar = psImageCovarianceNone(); 45 } 46 47 // Check for non-finite elements 48 for (int y = kernel->yMin; y <= kernel->yMax; y++) { 49 for (int x = kernel->xMin; x <= kernel->xMax; x++) { 50 if (!isfinite(kernel->kernel[y][x])) { 51 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 52 "Non-finite covariance matrix element in kernel at %d,%d", x, y); 53 psFree(covar); 54 return NULL; 55 } 56 } 57 } 58 for (int y = covar->yMin; y <= covar->yMax; y++) { 59 for (int x = covar->xMin; x <= covar->xMax; x++) { 60 if (!isfinite(covar->kernel[y][x])) { 61 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 62 "Non-finite covariance matrix element in covariance matrix at %d,%d", x, y); 63 psFree(covar); 64 return NULL; 65 } 66 } 45 67 } 46 68 … … 110 132 float psImageCovarianceFactor(const psKernel *covariance) 111 133 { 112 return covariance ? covariance->kernel[0][0] : NAN;134 return covariance ? covariance->kernel[0][0] : 1.0; 113 135 } 114 136 … … 144 166 for (int y = covar->yMin; y <= covar->yMax; y++) { 145 167 for (int x = covar->xMin; x <= covar->xMax; x++) { 168 if (!isfinite(covar->kernel[y][x])) { 169 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 170 "Non-finite covariance matrix element at %d,%d for input %d", 171 x, y, i); 172 psFree(sum); 173 return NULL; 174 } 146 175 sum->kernel[y][x] += covar->kernel[y][x]; 147 176 } … … 192 221 int radius = PS_MAX(abs(x), abs(y)); // Squarish radius 193 222 psAssert(radius <= maxRadius, "Radius doesn't fit"); 223 if (!isfinite(covar->kernel[y][x])) { 224 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Non-finite covariance matrix element at %d,%d", 225 x, y); 226 return NULL; 227 } 194 228 radiusSum->data.F64[radius] += fabsf(covar->kernel[y][x]); 195 229 sum += fabsf(covar->kernel[y][x]); -
branches/cnb_branches/cnb_branch_20090301/psLib/src/imageops/psImageInterpolate.c
r21290 r23352 133 133 } 134 134 135 float norm1 = 2.0 / PS_SQR(M_PI); // Normalisation for laczos136 float norm2 = M_PI * 4.0 / (float)size;// Normalisation for sinc function 1137 float norm3 = M_PI _2 * 4.0 / (float)size; // Normalisation for sinc function 2135 float norm1 = size / 2.0 / PS_SQR(M_PI); // Normalisation for laczos 136 float norm2 = M_PI; // Normalisation for sinc function 1 137 float norm3 = M_PI * 2.0 / (float)size; // Normalisation for sinc function 2 138 138 float pos = - (size - 1)/2 - frac; // Position of interest 139 139 for (int i = 0; i < size; i++, pos += 1.0) { -
branches/cnb_branches/cnb_branch_20090301/psLib/src/math/psRandom.c
r20547 r23352 29 29 #include <inttypes.h> 30 30 31 #include "psAbort.h" 31 32 #include "psMemory.h" 32 33 #include "psRandom.h" … … 38 39 39 40 41 unsigned long seed = 0; // Seed for RNG 42 43 40 44 psU64 p_psRandomGetSystemSeed(bool log) 41 45 { 42 FILE* fd; 43 psU64 seedVal = 0; 44 time_t timeVal; 46 psU64 seedVal = 0; // Seed value to return 45 47 46 fd = fopen("/dev/urandom","r"); 47 if(fd == NULL) { 48 // Read system clock to get seed 49 seedVal = (psU64)time(&timeVal); 50 } else { 51 // Read urandom to get seed 52 if (fread(&seedVal, sizeof(psU64),1,fd)) {;} // ignore return value 53 // Close file 54 fclose(fd); 48 // Since zero is a special value in our context, don't allow the final value chosen to be zero 49 while (seedVal == 0) { 50 FILE *fd = fopen("/dev/urandom", "r"); 51 if (fd) { 52 // Read urandom to get seed 53 if (fread(&seedVal, sizeof(psU64), 1, fd)) {;} // ignore return value 54 // Close file 55 fclose(fd); 56 } else { 57 // Read system clock to get seed 58 time_t timeVal; // Time value 59 seedVal = (psU64)time(&timeVal); 60 } 55 61 } 56 62 … … 63 69 } 64 70 65 psRandom *psRandomAlloc(psRandomType type, 66 unsigned long seed) 71 psU64 psRandomSeed(psU64 value) 67 72 { 68 gsl_rng *r = NULL; 69 psRandom *myRNG = NULL; 73 while (value == 0) { 74 value = p_psRandomGetSystemSeed(false); 75 } 76 seed = value; 77 return seed; 78 } 70 79 80 // Destructor for psRandom 81 static void randomFree(psRandom *rng) 82 { 83 if (rng->gsl) { 84 gsl_rng_free(rng->gsl); 85 } 86 return; 87 } 88 89 // Constructor for psRandom 90 static psRandom *randomAlloc(psRandomType type) 91 { 92 psRandom *rng = psAlloc(sizeof(psRandom)); // Random number generator to return 93 psMemSetDeallocator(rng, (psFreeFunc)randomFree); 94 95 rng->type = type; 96 97 const gsl_rng_type *gslType; // Type of RNG according to GSL 71 98 switch (type) { 72 case PS_RANDOM_TAUS: 73 myRNG = (psRandom*)psAlloc(sizeof(psRandom)); 74 r = gsl_rng_alloc(gsl_rng_taus); 75 myRNG->gsl = r; 76 if(seed == 0) { 77 gsl_rng_set(myRNG->gsl, p_psRandomGetSystemSeed(true)); 78 } else { 79 gsl_rng_set(myRNG->gsl, seed); 80 } 81 myRNG->type = type; 99 case PS_RANDOM_TAUS: 100 gslType = gsl_rng_taus; 82 101 break; 83 84 default: 85 psError(PS_ERR_UNEXPECTED_NULL, true, _("Unknown Random Number Generator Type")); 102 default: 103 psAbort("Unknown Random Number Generator Type: %x", type); 86 104 break; 87 105 } 88 106 89 return(myRNG); 107 rng->gsl = gsl_rng_alloc(gslType); 108 return rng; 90 109 } 91 110 92 void psRandomReset(psRandom *rand, 93 unsigned long seed) 111 psRandom *psRandomAlloc(psRandomType type) 94 112 { 95 // Check null psRandom 96 if(rand==NULL) { 97 psError(PS_ERR_UNEXPECTED_NULL, 98 true, 99 _("Random variable is NULL.")); 100 } else { 101 // Check seed value to see if system seed should be used 102 if(seed == 0) { 103 gsl_rng_set(rand->gsl,p_psRandomGetSystemSeed(true)); 104 } else { 105 gsl_rng_set(rand->gsl, seed); 106 } 113 psRandom *rng = randomAlloc(type); 114 psRandomReset(rng); 115 116 return rng; 117 } 118 119 psRandom *psRandomAllocSpecific(psRandomType type, psU64 specificSeed) 120 { 121 psRandom *rng = randomAlloc(type); 122 if (specificSeed == 0) { 123 specificSeed = p_psRandomGetSystemSeed(true); 107 124 } 125 gsl_rng_set(rng->gsl, specificSeed); 126 return rng; 127 } 128 129 bool psRandomReset(psRandom *rand) 130 { 131 PS_ASSERT_RANDOM_NON_NULL(rand, false); 132 if (seed == 0) { 133 seed = p_psRandomGetSystemSeed(true); 134 } 135 gsl_rng_set(rand->gsl, seed); 136 return true; 108 137 } 109 138 110 139 double psRandomUniform(const psRandom *r) 111 140 { 112 // Check null psRandom variable 113 if(r == NULL) { 114 psError(PS_ERR_UNEXPECTED_NULL, 115 true, 116 _("Random variable is NULL.")); 117 return(0); 118 } else { 119 return(gsl_rng_uniform(r->gsl)); 120 } 141 PS_ASSERT_RANDOM_NON_NULL(r, NAN); 142 return gsl_rng_uniform(r->gsl); 121 143 } 122 144 123 145 double psRandomGaussian(const psRandom *r) 124 146 { 125 // Check null psRandom variable 126 if(r == NULL) { 127 psError(PS_ERR_UNEXPECTED_NULL, 128 true, 129 _("Random variable is NULL.")); 130 return(0); 131 } else { 132 // XXX: What should sigma be? 133 return(gsl_ran_gaussian(r->gsl, 1.0)); 134 } 147 PS_ASSERT_RANDOM_NON_NULL(r, NAN); 148 return gsl_ran_gaussian(r->gsl, 1.0); 135 149 } 136 150 137 151 double p_psRandomGaussian(const psRandom *r, double sigma) 138 152 { 139 // Check null psRandom variable 140 if(r == NULL) { 141 psError(PS_ERR_UNEXPECTED_NULL, 142 true, 143 _("Random variable is NULL.")); 144 return(0); 145 } else { 146 return(gsl_ran_gaussian(r->gsl, sigma)); 147 } 153 PS_ASSERT_RANDOM_NON_NULL(r, NAN); 154 return gsl_ran_gaussian(r->gsl, sigma); 148 155 } 149 156 150 157 double psRandomPoisson(const psRandom *r, double mean) 151 158 { 152 // Check null psRandom variable 153 if(r == NULL) { 154 psError(PS_ERR_UNEXPECTED_NULL, 155 true, 156 _("Random variable is NULL.")); 157 return(0); 158 } else { 159 return((psF64) gsl_ran_poisson(r->gsl, mean)); 160 } 159 PS_ASSERT_RANDOM_NON_NULL(r, NAN); 160 return gsl_ran_poisson(r->gsl, mean); 161 161 } 162 162 -
branches/cnb_branches/cnb_branch_20090301/psLib/src/math/psRandom.h
r15627 r23352 29 29 #include <gsl/gsl_randist.h> 30 30 31 / ** Enumeration containing a flag for psRandom types. */31 /// Random number generator types 32 32 typedef enum { 33 33 PS_RANDOM_TAUS ///< A maximally equidistributed combined Tausworthe generator. 34 34 } psRandomType; 35 35 36 /** Data structure for psRandom. 37 * Contains information on the psRandom type and GNU Scientific Library random number generator. 38 */ 36 /// Random number generator 39 37 typedef struct { 40 38 psRandomType type; ///< The type of RNG … … 48 46 ); 49 47 50 /** Allocates a psRandom struct. 51 * 52 * @return psRandom*: A new psRandom structure. 53 */ 48 /// Set the seed to use for random number generators. 49 /// 50 /// A seed value of zero indicates that the seed is to be generated from the system. 51 /// The new seed value is returned 52 psU64 psRandomSeed(psU64 seed ///< Seed for RNG 53 ); 54 55 /// Allocate a random number generator 56 /// 57 /// The currently defined seed (via psRandomSeed) is used 54 58 psRandom *psRandomAlloc( 55 psRandomType type, ///< The type of RNG 56 unsigned long seed ///< Known value with which to seed the RNG 59 psRandomType type ///< The type of RNG 57 60 ) PS_ATTR_MALLOC; 58 61 59 /** Resets an existing psRandom struct. 60 * 61 * @return void 62 */ 63 void psRandomReset( 64 psRandom *rand, ///< Existing psRandom struct to reset 65 unsigned long seed ///< Known value with which to seed the RNG 62 /// Allocate a random number generator with a specific seed 63 /// 64 /// A seed value of zero indicates that the seed is to be generated from the system. 65 psRandom *psRandomAllocSpecific(psRandomType type, ///< The type of RNG 66 psU64 specificSeed ///< The specific seed to use 67 ); 68 69 /// Resets an existing random number generator 70 bool psRandomReset( 71 psRandom *rand ///< Random number generator to reset 66 72 ); 67 73 … … 72 78 */ 73 79 double psRandomUniform( 74 const psRandom *r ///< psRandom struct for RNG80 const psRandom *r ///< Random number generator 75 81 ); 76 82 … … 81 87 */ 82 88 double psRandomGaussian( 83 const psRandom *r ///< psRandom struct for RNG89 const psRandom *r ///< Random number generator 84 90 ); 85 91 86 /** Random number generator based on a Gaussian deviate , N(0,1).92 /** Random number generator based on a Gaussian deviate with specified standard deviation. 87 93 * Uses gsl_ran_gaussian. 88 *89 * XXX: I created this since the above psLib spec for p_psRandomGaussian90 * had no argument for sigma. Verify that with IfA.91 94 * 92 95 * @return double: Random number. 93 96 */ 94 97 double p_psRandomGaussian( 95 const psRandom *r, ///< psRandom struct for RNG98 const psRandom *r, ///< Random number generator 96 99 double sigma 97 100 ); … … 103 106 */ 104 107 double psRandomPoisson( 105 const psRandom *r, ///< psRandom struct for RNG108 const psRandom *r, ///< Random number generator 106 109 double mean ///< Mean value 107 110 ); -
branches/cnb_branches/cnb_branch_20090301/psLib/src/math/psStats.c
r21183 r23352 199 199 for (long i = 0; i < numData; i++) { 200 200 // Check if the data is with the specified range 201 if (!isfinite(data[i])) 202 continue; 201 203 if (useRange && (data[i] < stats->min)) 202 204 continue; … … 322 324 // into the temporary vectors. 323 325 for (long i = 0; i < inVector->n; i++) { 326 if (!isfinite(input[i])) 327 continue; 324 328 if (useRange && (input[i] < stats->min)) 325 329 continue; … … 420 424 for (long i = 0; i < myVector->n; i++) { 421 425 // Check if the data is with the specified range 426 if (!isfinite(data[i])) 427 continue; 422 428 if (useRange && (data[i] < stats->min)) { 423 429 continue; … … 501 507 for (long i = 0; i < myVector->n; i++) { 502 508 // Check if the data is with the specified range 509 if (!isfinite(data[i])) 510 continue; 503 511 if (useRange && (data[i] < stats->min)) { 504 512 continue; -
branches/cnb_branches/cnb_branch_20090301/psLib/src/pslib_strict.h
r21283 r23352 110 110 #include "psMetadataItemParse.h" 111 111 #include "psMetadataItemCompare.h" 112 #include "psMetadataHeader.h" 112 113 #include "psPixels.h" 113 114 #include "psArguments.h" -
branches/cnb_branches/cnb_branch_20090301/psLib/src/sys/Makefile.am
r19056 r23352 3 3 noinst_LTLIBRARIES = libpslibsys.la 4 4 5 libpslibsys_la_CPPFLAGS = $(SRCINC) $(PSLIB_CFLAGS) $(CFITSIO_CFLAGS) 5 # PSLIB_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 6 # PSLIB_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi` 7 # PSLIB_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 8 9 # Force recompilation of psConfigure.c, since it gets the version information 10 psConfigure.c: FORCE 11 touch psConfigure.c 12 FORCE: ; 13 14 libpslibsys_la_CPPFLAGS = $(SRCINC) $(PSLIB_CFLAGS) $(CFITSIO_CFLAGS) -DPSLIB_VERSION=$(SVN_VERSION) -DPSLIB_BRANCH=$(SVN_BRANCH) -DPSLIB_SOURCE=$(SVN_SOURCE) 6 15 libpslibsys_la_SOURCES = \ 7 16 psAbort.c \ -
branches/cnb_branches/cnb_branch_20090301/psLib/src/sys/psConfigure.c
r18953 r23352 12 12 * @author Ross Harman, MHPCC 13 13 * @author Robert DeSonia, MHPCC 14 * @author Paul Price, IfA 14 15 * 15 * @version $Revision: 1.28 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2008-08-08 18:05:08 $ 17 * 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 16 * Copyright 2004-2009 Institute for Astronomy, University of Hawaii 19 17 */ 20 18 … … 26 24 #include <stdlib.h> 27 25 #include <string.h> 26 27 #include <fitsio.h> 28 #include <longnam.h> 29 #include <fftw3.h> 30 #include <gsl/gsl_version.h> 31 #ifdef HAVE_PSDB 32 #include <mysql.h> 33 #endif 28 34 29 35 #include "psAbort.h" … … 41 47 static FILE *memCheckFile = NULL; // File to which to write results of mem check 42 48 43 static const char *cvsTag = "$Name: not supported by cvs2svn $"; // CVS tag name 49 #ifndef PSLIB_VERSION 50 #error "PSLIB_VERSION is not set" 51 #endif 52 #ifndef PSLIB_BRANCH 53 #error "PSLIB_BRANCH is not set" 54 #endif 55 #ifndef PSLIB_SOURCE 56 #error "PSLIB_SOURCE is not set" 57 #endif 58 59 #define xstr(s) str(s) 60 #define str(s) #s 44 61 45 62 psString psLibVersion(void) 46 63 { 47 psString version = NULL; // Version, to return 48 psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION); 49 return version; 64 char *value = NULL; 65 psStringAppend(&value, "%s@%s", xstr(PSLIB_BRANCH), xstr(PSLIB_VERSION)); 66 return value; 67 } 68 69 psString psLibSource(void) 70 { 71 return psStringCopy(xstr(PSLIB_SOURCE)); 72 } 73 74 psString psLibDependencies(void) 75 { 76 psString deps = NULL; // Dependencies, to return 77 float cfitsioVersion; // CFITSIO version number 78 psStringAppend(&deps, "cfitsio-%.3f gsl-%s %s", 79 fits_get_version(&cfitsioVersion), gsl_version, fftwf_version); 80 81 #ifdef HAVE_PSDB 82 psStringAppend(&deps, " mysql-%s", mysql_get_client_info()); 83 #endif 84 85 return deps; 50 86 } 51 87 52 88 psString psLibVersionLong(void) 53 89 { 54 psString version = psLibVersion(); // Version, to return 55 psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag 90 psString version = psLibVersion(); // Version, to return 91 psString source = psLibSource(); // Source 92 psString deps = psLibDependencies();// Dependencies 56 93 57 #ifdef HAVE_PSDB 58 psStringAppend(&version, " (cvs tag %s), %s, %s with psDB", tag, __DATE__, __TIME__); 94 psStringPrepend(&version, "psLib "); 95 psStringAppend(&version, " from %s, built %s, %s with %s", 96 source, __DATE__, __TIME__, deps); 97 psFree(source); 98 psFree(deps); 99 100 #ifdef __OPTIMIZE__ 101 psStringAppend(&version, " optimised"); 59 102 #else 60 psStringAppend(&version, " (cvs tag %s), %s, %s without psDB", tag, __DATE__, __TIME__);103 psStringAppend(&version, " unoptimised"); 61 104 #endif 62 psFree(tag); 105 106 #ifdef PS_NO_TRACE 107 psStringAppend(&version, " without trace"); 108 #else 109 psStringAppend(&version, " with trace"); 110 #endif 111 63 112 return version; 64 } 113 }; 65 114 66 115 // Check the memory; intended for use on exit, but might be used elsewhere -
branches/cnb_branches/cnb_branch_20090301/psLib/src/sys/psConfigure.h
r13950 r23352 20 20 #define PS_CONFIGURE_H 21 21 22 #include <psString.h> 23 22 24 /// @addtogroup SysUtils System Utilities 23 25 /// @{ … … 29 31 * @return psString: String with version name. 30 32 */ 31 psString psLibVersion( 32 void 33 ); 33 psString psLibVersion(void); 34 34 35 /** Get current psLib source 36 * 37 * Returns the current psLib source name as a string. 38 * 39 * @return psString: String with source name. 40 */ 41 psString psLibSource(void); 42 43 /** Get psLib dependencies' versions 44 * 45 * Returns the psLib dependency versions as a string. 46 * 47 * @return psString: String with dependencies. 48 */ 49 psString psLibDependencies(void); 35 50 36 51 /** Get current psLib version (full identification) -
branches/cnb_branches/cnb_branch_20090301/psLib/src/sys/psLogMsg.c
r20546 r23352 195 195 } 196 196 197 int fileD = creat(dest, 0666);197 int fileD = open(dest, O_WRONLY | O_CREAT, 0666); 198 198 if (fileD == 0) { 199 199 psError(PS_ERR_IO, true, _("Could not open file '%s' for output."), dest); … … 316 316 317 317 if (write(logFD, head, strlen(head))) {;} // ignore return value 318 318 319 319 if (logMsg) { 320 320 psString msg = NULL; // Message to print -
branches/cnb_branches/cnb_branch_20090301/psLib/src/sys/psMemory.c
r21346 r23352 1069 1069 memBlock->func, memBlock->file, memBlock->lineno, (unsigned long)memBlock->tid); 1070 1070 } 1071 1072 bool psMemTypeEqual (void *ptr1, void *ptr2) { 1073 1074 // if ptr is a psAlloc()'d memory, find the actual address of the memBlock 1075 psMemBlock *memBlock1 = ((psMemBlock *)ptr1) - 1; 1076 HANDLE_BAD_BLOCK(memBlock1, __FILE__, __LINE__, __func__); 1077 if (!memBlock1->freeFunc) return false; 1078 1079 // if ptr is a psAlloc()'d memory, find the actual address of the memBlock 1080 psMemBlock *memBlock2 = ((psMemBlock *)ptr2) - 1; 1081 HANDLE_BAD_BLOCK(memBlock2, __FILE__, __LINE__, __func__); 1082 if (!memBlock2->freeFunc) return false; 1083 1084 return (memBlock1->freeFunc == memBlock2->freeFunc); 1085 } -
branches/cnb_branches/cnb_branch_20090301/psLib/src/sys/psMemory.h
r15047 r23352 636 636 ); 637 637 638 /** test for matching types (equal free functions) 639 * 640 * This function returns true if the two pointers have matching, non-NULL free functions. 641 * Supplied pointers must have been allocated within the psLib memory system (ie, with a psAlloc) or the function will abort. (XXX just return false?) 642 * Supplied pointers must have been provided with free function or the function returns false. 643 */ 644 bool psMemTypeEqual (void *ptr1, ///< pointer to first psMemory object 645 void *ptr2 ///< pointer to second psMemory object 646 ); 647 638 648 // Ensure this is a psLib pointer 639 649 #define PS_ASSERT_PTR_HEAVY(PTR, RVAL) \ -
branches/cnb_branches/cnb_branch_20090301/psLib/src/types/Makefile.am
r18145 r23352 14 14 psMetadataItemParse.c \ 15 15 psMetadataItemCompare.c \ 16 psMetadataHeader.c \ 16 17 psPixels.c \ 17 18 psArguments.c \ … … 30 31 psMetadataItemParse.h \ 31 32 psMetadataItemCompare.h \ 33 psMetadataHeader.h \ 32 34 psPixels.h \ 33 35 psArguments.h \ -
branches/cnb_branches/cnb_branch_20090301/psLib/src/types/psMetadata.h
r21278 r23352 30 30 #include "psLookupTable.h" 31 31 #include "psMutex.h" 32 #include "psError.h" 32 33 33 34 #define PS_DATA_IS_PRIMITIVE(TYPE) \ -
branches/cnb_branches/cnb_branch_20090301/psLib/src/types/psMetadataConfig.c
r22707 r23352 1477 1477 } 1478 1478 1479 psString newStr = psMetadataConfigFormat(item->data.md); 1480 if (newStr) { 1479 psMetadata *md = item->data.md; // Metadata at new level 1480 if (md) { 1481 psString newStr = psMetadataConfigFormat(item->data.md); 1482 if (!newStr) { 1483 psError(PS_ERR_UNKNOWN, false, "Unable to format metadata %s", item->name); 1484 psFree(content); 1485 return NULL; 1486 } 1487 1481 1488 // add 3 extra spaces to each metadata folder item 1482 1489 char *buf = strtok(newStr, "\n"); … … 1487 1494 psFree(newStr); 1488 1495 } 1489 1490 1496 psStringAppend(&content, "\nEND\n"); 1491 1497 break; -
branches/cnb_branches/cnb_branch_20090301/psLib/test/fits/tap_psFitsImage.c
r19382 r23352 12 12 static psImage *generateImage(void) 13 13 { 14 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 12345); // Random number generator14 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 12345); // Random number generator 15 15 psImage *image = psImageAlloc(NUMCOLS, NUMROWS, PS_TYPE_F32); // Generated image 16 16 for (int y = 0; y < NUMROWS; y++) { -
branches/cnb_branches/cnb_branch_20090301/psLib/test/imageops/convolutionBench.c
r17320 r23352 68 68 int main(int argc, char *argv[]) 69 69 { 70 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0); // Random number generator70 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); // Random number generator 71 71 72 72 printf("#%14s%16s %8s %8s\n", "Image", "Kernel", "Direct", "FFT"); -
branches/cnb_branches/cnb_branch_20090301/psLib/test/imageops/tap_psImageInterpolate2.c
r21465 r23352 77 77 psImage *variance = NULL; // generateVariance(xSize, ySize, type); 78 78 psImage *mask = NULL; // generateMask(xSize, ySize); 79 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 12345);79 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 12345); 80 80 81 81 psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, variance, mask, 0, NAN, NAN, -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tap_psMinimizeLMM.c
r13124 r23352 95 95 { 96 96 psMemId id = psMemGetId(); 97 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed97 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 98 98 psMinimization *min = psMinimizationAlloc(NUM_ITERATIONS, ERR_TOL); 99 99 psArray *ordinates = psArrayAlloc(NUM_DATA_POINTS); … … 203 203 { 204 204 psMemId id = psMemGetId(); 205 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed205 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 206 206 psMinimization *min = psMinimizationAlloc(NUM_ITERATIONS, ERR_TOL); 207 207 psArray *ordinates = psArrayAlloc(NUM_DATA_POINTS); -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tap_psPolyFit1D.c
r13337 r23352 109 109 psVector *xTruth = psVectorAlloc(numData, PS_TYPE_F64); 110 110 psVector *fTruth = psVectorAlloc(numData, PS_TYPE_F64); 111 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using a known seed111 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using a known seed 112 112 for (int i = 0; i < numData; i++) { 113 113 xTruth->data.F64[i] = (flags & TS00_X_NULL) ? i : 2.0*psRandomUniform(rng) - 1.0; -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tap_psPolyFit2D.c
r17567 r23352 108 108 yTruth->n = numData; 109 109 fTruth->n = numData; 110 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using an RNG with a known seed110 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using an RNG with a known seed 111 111 for (int i = 0; i < numData; i++) { 112 112 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tap_psPolyFit3D.c
r17567 r23352 108 108 zTruth->n = numData; 109 109 fTruth->n = numData; 110 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using known seed110 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using known seed 111 111 for (int i = 0; i < numData; i++) { 112 112 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tap_psPolyFit4D.c
r17567 r23352 132 132 tTruth->n = numData; 133 133 fTruth->n = numData; 134 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using known seed134 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using known seed 135 135 for (int i = 0; i < numData; i++) { 136 136 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tap_psRandom.c
r13123 r23352 3 3 work properly. 4 4 5 ensure that psRandom structs are properly allocated by psRandomAlloc ().5 ensure that psRandom structs are properly allocated by psRandomAllocSpecific(). 6 6 ensure that psRandomUniform() produces a sequence of numbers with 7 7 proper mean and stdev. … … 47 47 plan_tests(34); 48 48 49 // ensure that psRandom structs are properly allocated by psRandomAlloc ()49 // ensure that psRandom structs are properly allocated by psRandomAllocSpecific() 50 50 { 51 51 psMemId id = psMemGetId(); 52 52 // Valid type allocation 53 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);54 ok(myRNG != NULL, "psRandom struct was allocated properly"); 55 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAlloc () failed");56 ok(myRNG->type == PS_RANDOM_TAUS, "psRandomAlloc () set type properly");53 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 54 ok(myRNG != NULL, "psRandom struct was allocated properly"); 55 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAllocSpecific() failed"); 56 ok(myRNG->type == PS_RANDOM_TAUS, "psRandomAllocSpecific() set type properly"); 57 57 psFree(myRNG); 58 58 skip_end(); … … 63 63 { 64 64 psMemId id = psMemGetId(); 65 psRandom *myRNG = psRandomAlloc (100,SEED);66 ok(myRNG == NULL, "psRandomAlloc () refused to generate psRandom with unallowed type");65 psRandom *myRNG = psRandomAllocSpecific(100,SEED); 66 ok(myRNG == NULL, "psRandomAllocSpecific() refused to generate psRandom with unallowed type"); 67 67 psFree(myRNG); 68 68 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 72 72 { 73 73 psMemId id = psMemGetId(); 74 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS,-5);75 ok(myRNG != NULL, "psRandomAlloc () allows negative seed");74 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS,-5); 75 ok(myRNG != NULL, "psRandomAllocSpecific() allows negative seed"); 76 76 psFree(myRNG); 77 77 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 85 85 rans->n = rans->nalloc; 86 86 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 87 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);88 ok(myRNG != NULL, "psRandom struct was allocated properly"); 89 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAlloc () failed");87 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 88 ok(myRNG != NULL, "psRandom struct was allocated properly"); 89 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAllocSpecific() failed"); 90 90 91 91 // Initialize vector data with random number … … 125 125 rans->n = rans->nalloc; 126 126 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 127 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);128 ok(myRNG != NULL, "psRandom struct was allocated properly"); 129 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAlloc () failed");127 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 128 ok(myRNG != NULL, "psRandom struct was allocated properly"); 129 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAllocSpecific() failed"); 130 130 131 131 // Initialize vector with random data … … 167 167 rans->n = rans->nalloc; 168 168 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 169 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);170 ok(myRNG != NULL, "psRandom struct was allocated properly"); 171 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAlloc () failed");169 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 170 ok(myRNG != NULL, "psRandom struct was allocated properly"); 171 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAllocSpecific() failed"); 172 172 173 173 // Initialize vector with random data … … 210 210 rans02->n = rans02->nalloc; 211 211 212 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);213 ok(myRNG != NULL, "psRandom struct was allocated properly"); 214 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAlloc () failed");212 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 213 ok(myRNG != NULL, "psRandom struct was allocated properly"); 214 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAllocSpecific() failed"); 215 215 216 216 … … 252 252 if (0) { 253 253 psRandom *myRNG1 = NULL; 254 myRNG1 = psRandomAlloc (PS_RANDOM_TAUS, SEED);254 myRNG1 = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 255 255 // psLogSetDestination("dest:stderr"); 256 256 psLogSetDestination(0); … … 275 275 rans02->n = rans02->nalloc; 276 276 277 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);278 ok(myRNG != NULL, "psRandom struct was allocated properly"); 279 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAlloc () failed");277 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 278 ok(myRNG != NULL, "psRandom struct was allocated properly"); 279 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAllocSpecific() failed"); 280 280 281 281 … … 325 325 rans02->n = rans02->nalloc; 326 326 327 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);328 ok(myRNG != NULL, "psRandom struct was allocated properly"); 329 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAlloc () failed");327 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 328 ok(myRNG != NULL, "psRandom struct was allocated properly"); 329 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAllocSpecific() failed"); 330 330 331 331 // Initialize vectors with random data -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tap_psStats07.c
r12247 r23352 58 58 PS_ASSERT_INT_NONNEGATIVE(Npts, NULL); 59 59 60 // psRandom *r = psRandomAlloc (PS_RANDOM_TAUS, p_psRandomGetSystemSeed());61 psRandom *r = psRandomAlloc (PS_RANDOM_TAUS, PS_XXX_GAUSSIAN_SEED);60 // psRandom *r = psRandomAllocSpecific(PS_RANDOM_TAUS, p_psRandomGetSystemSeed()); 61 psRandom *r = psRandomAllocSpecific(PS_RANDOM_TAUS, PS_XXX_GAUSSIAN_SEED); 62 62 psVector* gauss = psVectorAlloc(Npts, PS_TYPE_F32); 63 63 for (unsigned int i = 0; i < Npts; i++) { -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tap_psStats09.c
r12783 r23352 52 52 srand(SEED); 53 53 54 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed54 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 55 55 psVector *truth = psVectorAlloc(numData, PS_TYPE_F64); 56 56 for (long i = 0; i < numData; i++) { -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tap_psStatsTiming.c
r12513 r23352 20 20 21 21 // build a gauss-deviate vector (mean = 0.0, sigma = 1.0) for tests 22 psRandom *seed = psRandomAlloc (PS_RANDOM_TAUS, 0);22 psRandom *seed = psRandomAllocSpecific (PS_RANDOM_TAUS, 0); 23 23 psVector *rnd = psVectorAlloc (1000, PS_TYPE_F32); 24 24 for (int i = 0; i < rnd->n; i++) { -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tst_psMinimizeLMM.c
r11686 r23352 66 66 psBool testStatus = true; 67 67 68 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed68 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 69 69 psMinimization *min = psMinimizationAlloc(NUM_ITERATIONS, ERR_TOL); 70 70 psArray *ordinates = psArrayAlloc(NUM_DATA_POINTS); -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tst_psPolyFit1D.c
r11686 r23352 101 101 xTruth->n = numData; 102 102 fTruth->n = numData; 103 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using a known seed103 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using a known seed 104 104 for (int i = 0; i < numData; i++) { 105 105 xTruth->data.F64[i] = (flags & TS00_X_NULL) ? i : 2.0*psRandomUniform(rng) - 1.0; -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tst_psPolyFit2D.c
r11686 r23352 100 100 yTruth->n = numData; 101 101 fTruth->n = numData; 102 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using an RNG with a known seed102 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using an RNG with a known seed 103 103 for (int i = 0; i < numData; i++) { 104 104 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tst_psPolyFit3D.c
r11686 r23352 103 103 zTruth->n = numData; 104 104 fTruth->n = numData; 105 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using known seed105 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using known seed 106 106 for (int i = 0; i < numData; i++) { 107 107 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tst_psPolyFit4D.c
r11686 r23352 124 124 tTruth->n = numData; 125 125 fTruth->n = numData; 126 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using known seed126 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using known seed 127 127 for (int i = 0; i < numData; i++) { 128 128 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tst_psRandom.c
r6484 r23352 3 3 work properly. 4 4 5 t00(): ensure that psRandom structs are properly allocated by psRandomAlloc ().5 t00(): ensure that psRandom structs are properly allocated by psRandomAllocSpecific(). 6 6 t01(): ensure that psRandomUniform() produces a sequence of numbers with 7 7 proper mean and stdev. … … 45 45 46 46 testDescription tests[] = { 47 {testRandomAlloc,000,"psRandomAlloc ",0,false},47 {testRandomAlloc,000,"psRandomAllocSpecific",0,false}, 48 48 {testRandomUniform,000,"psRandomUniform",0,false}, 49 49 {testRandomGaussian,000,"psRandomGaussian",0,false}, … … 70 70 71 71 // Valid type allocation 72 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);72 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 73 73 if (myRNG == NULL) { 74 74 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 85 85 // psLogSetDestination("file:seed_msglog1.txt"); 86 86 psLogSetDestination(fd1); 87 myRNG = psRandomAlloc (PS_RANDOM_TAUS, 0);87 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 88 88 // psLogSetDestination("dest:stderr"); 89 89 psLogSetDestination(2); … … 100 100 // Invalid type allocation 101 101 psLogMsg(__func__,PS_LOG_INFO,"Invalid type, should generate error message"); 102 myRNG = psRandomAlloc (100,SEED);102 myRNG = psRandomAllocSpecific(100,SEED); 103 103 if (myRNG != NULL) { 104 104 psError(PS_ERR_UNKNOWN,true,"Did not return NULL for invalid type"); … … 107 107 108 108 // Negative seed value 109 myRNG = psRandomAlloc (PS_RANDOM_TAUS,-5);109 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS,-5); 110 110 if(myRNG == NULL) { 111 111 psError(PS_ERR_UNKNOWN,true,"Did not return allocated psRandom"); … … 125 125 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 126 126 127 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);127 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 128 128 if (myRNG == NULL) { 129 129 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 171 171 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 172 172 173 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);173 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 174 174 if (myRNG == NULL) { 175 175 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 219 219 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 220 220 221 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);221 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 222 222 if (myRNG == NULL) { 223 223 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 268 268 rans02->n = rans02->nalloc; 269 269 270 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);270 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 271 271 if (myRNG == NULL) { 272 272 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 302 302 303 303 psRandom *myRNG1 = NULL; 304 myRNG1 = psRandomAlloc (PS_RANDOM_TAUS, SEED);304 myRNG1 = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 305 305 // psLogSetDestination("dest:stderr"); 306 306 psLogSetDestination(0); … … 326 326 rans02->n = rans02->nalloc; 327 327 328 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);328 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 329 329 if (myRNG == NULL) { 330 330 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 372 372 rans02->n = rans02->nalloc; 373 373 374 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);374 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 375 375 if (myRNG == NULL) { 376 376 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); -
branches/cnb_branches/cnb_branch_20090301/psLib/test/math/tst_psStats09.c
r11686 r23352 52 52 printPositiveTestHeader(stdout, "psMathUtils functions", "psVectorStats Clipped Stats Routine"); 53 53 54 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed54 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 55 55 psVector *truth = psVectorAlloc(numData, PS_TYPE_F64); 56 56 truth->n = numData; -
branches/cnb_branches/cnb_branch_20090301/psLib/test/mathtypes/tap_psVectorSelect.c
r18333 r23352 17 17 psVector *vector = psVectorAlloc(size, PS_TYPE_F32); 18 18 psVectorInit(vector, 0.0); 19 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 12345);19 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 12345); 20 20 for (long i = 0; i < numNonzero; i++) { 21 21 long index = psRandomUniform(rng) * size; … … 52 52 psVector *vector = psVectorAlloc(size, PS_TYPE_F32); 53 53 psVectorInit(vector, 0.0); 54 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 12345);54 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 12345); 55 55 for (long i = 0; i < numNonzero; i++) { 56 56 long index = psRandomUniform(rng) * size; -
branches/cnb_branches/cnb_branch_20090301/psLib/test/types/tap_psTree.c
r18145 r23352 16 16 psVector *y = psVectorAlloc(NUM, PS_TYPE_F64); 17 17 18 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);18 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 19 19 for (int i = 0; i < NUM; i++) { 20 20 x->data.F64[i] = 2.0 * psRandomUniform(rng) - 1.0; -
branches/cnb_branches/cnb_branch_20090301/psastro
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/cnb_branches/cnb_branch_20090215/psastro merged eligible /trunk/psastro merged eligible /branches/cnb_branch_20090215/psastro 21495-22685 /branches/eam_branches/eam_branch_20090303/psastro 23158-23228
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/cnb_branches/cnb_branch_20090301/psastro/src/Makefile.am
r21422 r23352 1 lib_LTLIBRARIES = libpsastro.la 1 2 2 lib_LTLIBRARIES = libpsastro.la 3 libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 4 libpsastro_la_LDFLAGS = $(PSASTRO_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 3 libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSASTRO_VERSION=$(SVN_VERSION) -DPSASTRO_BRANCH=$(SVN_BRANCH) -DPSASTRO_SOURCE=$(SVN_SOURCE) 4 libpsastro_la_LDFLAGS = $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 5 6 # Force recompilation of psastroVersion.c, since it gets the version information 7 # can we do this with dependency info? 8 # psastroVersion.c: FORCE 9 # touch psastroVersion.c 10 # FORCE: ; 5 11 6 12 bin_PROGRAMS = psastro psastroModel psastroModelFit gpcModel -
branches/cnb_branches/cnb_branch_20090301/psastro/src/psastro.c
r21409 r23352 34 34 if (!config) usage (); 35 35 36 psastroVersionPrint(); 37 36 38 // load identify the data sources 37 39 if (!psastroParseCamera (config)) { 38 psErrorStackPrint(stderr, "error setting up the camera\n");39 exit (1);40 psErrorStackPrint(stderr, "error setting up the camera\n"); 41 exit (1); 40 42 } 41 43 … … 43 45 // select subset of stars for astrometry 44 46 if (!psastroDataLoad (config)) { 45 psErrorStackPrint(stderr, "error loading input data\n");46 exit (1);47 psErrorStackPrint(stderr, "error loading input data\n"); 48 exit (1); 47 49 } 48 50 49 51 // run the full astrometry analysis (chip and/or mosaic) 50 52 if (!psastroAnalysis (config)) { 51 psErrorStackPrint(stderr, "failure in psastro analysis\n");52 exit (1);53 psErrorStackPrint(stderr, "failure in psastro analysis\n"); 54 exit (1); 53 55 } 54 56 55 57 // write out the results 56 58 if (!psastroDataSave (config)) { 57 psErrorStackPrint(stderr, "failed to write out data\n");58 exit (1);59 psErrorStackPrint(stderr, "failed to write out data\n"); 60 exit (1); 59 61 } 60 62 -
branches/cnb_branches/cnb_branch_20090301/psastro/src/psastro.h
r21422 r23352 95 95 // Return version strings. 96 96 psString psastroVersion(void); 97 psString psastroSource(void); 97 98 psString psastroVersionLong(void); 99 bool psastroVersionHeader(psMetadata *header); 100 bool psastroVersionHeaderFull(psMetadata *header); 101 void psastroVersionPrint(void); 98 102 99 103 // demo plots -
branches/cnb_branches/cnb_branch_20090301/psastro/src/psastroArguments.c
r21422 r23352 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 09 21:25:34$8 * @version $Revision: 1.34.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 100 100 if ((N = psArgumentGet (argc, argv, "-visual"))) { 101 101 psArgumentRemove (N, &argc, argv); 102 pm AstromSetVisual (true);102 pmVisualSetVisual (true); 103 103 } 104 104 -
branches/cnb_branches/cnb_branch_20090301/psastro/src/psastroCleanup.c
r21422 r23352 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 09 21:25:34$8 * @version $Revision: 1.8.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 16 16 17 17 psFree (config); 18 pm AstromVisualClose ();18 pmVisualClose (); 19 19 20 20 psTimerStop (); -
branches/cnb_branches/cnb_branch_20090301/psastro/src/psastroConvert.c
r21409 r23352 99 99 int n = index->data.S32[i]; 100 100 pmSource *source = sources->data[n]; 101 // XXX this needs to be flexible 101 102 psTrace ("psastro", 6, "mag: %f +/- %f, mode: %x, skip: %x\n", source->psfMag, source->errMag, source->mode, skip); 103 102 104 if (source->mode & skip) { 103 105 nModeSkip ++; 104 106 continue; 105 107 } 108 106 109 if ((iMagMax != 0.0) && (source->psfMag > iMagMax)) { 107 110 nFaintSkip ++; -
branches/cnb_branches/cnb_branch_20090301/psastro/src/psastroDataSave.c
r21409 r23352 18 18 return false; \ 19 19 } 20 20 21 21 /** 22 22 * this loop saves the photometry/astrometry data files … … 31 31 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSASTRO_RECIPE); 32 32 if (!recipe) { 33 psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe!\n");34 return false;33 psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe!\n"); 34 return false; 35 35 } 36 36 … … 38 38 pmFPAfile *output = psMetadataLookupPtr (NULL, config->files, "PSASTRO.OUTPUT"); 39 39 if (!output) { 40 psError(PSASTRO_ERR_CONFIG, true, "Can't find or interpret output file rule PSASTRO.OUTPUT!\n");41 return false;40 psError(PSASTRO_ERR_CONFIG, true, "Can't find or interpret output file rule PSASTRO.OUTPUT!\n"); 41 return false; 42 42 } 43 43 … … 48 48 49 49 pmFPAview *view = pmFPAviewAlloc (0); 50 pmHDU *lastHDU = NULL; // Last HDU updated 50 51 51 52 // open/load files as needed … … 55 56 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 56 57 if (!chip->process || !chip->file_exists) { continue; } 57 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;58 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE; 58 59 59 while ((cell = pmFPAviewNextCell (view, output->fpa, 1)) != NULL) {60 while ((cell = pmFPAviewNextCell (view, output->fpa, 1)) != NULL) { 60 61 psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 61 62 if (!cell->process || !cell->file_exists) { continue; } 62 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;63 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE; 63 64 64 // process each of the readouts65 while ((readout = pmFPAviewNextReadout (view, output->fpa, 1)) != NULL) {66 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;67 if (!readout->data_exists) { continue; }65 // process each of the readouts 66 while ((readout = pmFPAviewNextReadout (view, output->fpa, 1)) != NULL) { 67 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE; 68 if (!readout->data_exists) { continue; } 68 69 69 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE; 70 } 71 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE; 72 } 73 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE; 70 // Put version information into the header 71 pmHDU *hdu = pmHDUGetHighest(output->fpa, chip, cell); 72 if (hdu && hdu != lastHDU) { 73 psastroVersionHeaderFull(hdu->header); 74 lastHDU = hdu; 75 } 76 77 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE; 78 } 79 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE; 80 } 81 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE; 74 82 } 75 83 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE; -
branches/cnb_branches/cnb_branch_20090301/psastro/src/psastroVersion.c
r21409 r23352 5 5 * @ingroup libpsastro 6 6 * 7 * @author IfA8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02-07 02:03:34 $10 7 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 8 */ … … 13 10 #include "psastroInternal.h" 14 11 15 static const char *cvsTag = "$Name: not supported by cvs2svn $";///< CVS tag name 12 #ifndef PSASTRO_VERSION 13 #error "PSASTRO_VERSION is not set" 14 #endif 15 #ifndef PSASTRO_BRANCH 16 #error "PSASTRO_BRANCH is not set" 17 #endif 18 #ifndef PSASTRO_SOURCE 19 #error "PSASTRO_SOURCE is not set" 20 #endif 21 22 #define xstr(s) str(s) 23 #define str(s) #s 16 24 17 25 psString psastroVersion(void) 18 26 { 19 psString version = NULL; // Version, to return 20 psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION); 21 return version; 27 char *value = NULL; 28 psStringAppend(&value, "%s@%s", xstr(PSASTRO_BRANCH), xstr(PSASTRO_VERSION)); 29 return value; 30 } 31 32 psString psastroSource(void) 33 { 34 return psStringCopy(xstr(PSASTRO_SOURCE)); 22 35 } 23 36 24 37 psString psastroVersionLong(void) 25 38 { 26 psString version = psastroVersion(); // Version, to return 27 psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag 28 psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__); 29 psFree(tag); 39 psString version = psastroVersion(); // Version, to return 40 psString source = psastroSource(); // Source 41 42 psStringPrepend(&version, "psastro "); 43 psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__); 44 psFree(source); 45 46 #ifdef __OPTIMIZE__ 47 psStringAppend(&version, " optimised"); 48 #else 49 psStringAppend(&version, " unoptimised"); 50 #endif 51 30 52 return version; 53 }; 54 55 bool psastroVersionHeader(psMetadata *header) 56 { 57 PS_ASSERT_METADATA_NON_NULL(header, false); 58 59 psString version = psastroVersion(); // Software version 60 psString source = psastroSource(); // Software source 61 62 psStringPrepend(&version, "psastro version: "); 63 psStringPrepend(&source, "psastro source: "); 64 65 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version); 66 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source); 67 68 psFree(version); 69 psFree(source); 70 71 return true; 31 72 } 32 73 74 bool psastroVersionHeaderFull(psMetadata *header) 75 { 76 PS_ASSERT_METADATA_NON_NULL(header, false); 77 78 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 79 psString timeString = psTimeToISO(time); // The time in an ISO string 80 psFree(time); 81 psString history = NULL; // History string 82 psStringAppend(&history, "psastro at %s", timeString); 83 psFree(timeString); 84 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history); 85 psFree(history); 86 87 psLibVersionHeader(header); 88 psModulesVersionHeader(header); 89 ppStatsVersionHeader(header); 90 psastroVersionHeader(header); 91 92 return true; 93 } 94 95 void psastroVersionPrint(void) 96 { 97 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 98 psString timeString = psTimeToISO(time); // The time in an ISO string 99 psFree(time); 100 psLogMsg("psastro", PS_LOG_INFO, "psastro at %s", timeString); 101 psFree(timeString); 102 103 psString pslib = psLibVersionLong();// psLib version 104 psString psmodules = psModulesVersionLong(); // psModules version 105 psString ppStats = ppStatsVersionLong(); // ppStats version 106 psString psastro = psastroVersionLong(); // psastro version 107 108 psLogMsg("psastro", PS_LOG_INFO, "%s", pslib); 109 psLogMsg("psastro", PS_LOG_INFO, "%s", psmodules); 110 psLogMsg("psastro", PS_LOG_INFO, "%s", ppStats); 111 psLogMsg("psastro", PS_LOG_INFO, "%s", psastro); 112 113 psFree(pslib); 114 psFree(psmodules); 115 psFree(ppStats); 116 psFree(psastro); 117 118 return; 119 } -
branches/cnb_branches/cnb_branch_20090301/psconfig/psbuild
r22697 r23352 13 13 $stop = ""; 14 14 $verbose = 0; 15 $use_svn = 1; 15 16 16 17 $extlibs = "none"; … … 83 84 if ($ARGV[0] eq "-bootstrap") { 84 85 &bootstrap (); 86 } 87 if ($ARGV[0] eq "-skip-svn") { 88 $use_svn = 0; 89 shift; next; 85 90 } 86 91 if ($ARGV[0] eq "-env") { … … 157 162 sub build_distribution { 158 163 164 # set environment variables used to supply SVN info to the compilation 165 166 if ($use_svn) { 167 # example dump from svn info: 168 # pikake: svn info 169 # Path: . 170 # URL: https://svn.pan-starrs.ifa.hawaii.edu/repo/ipp/branches/eam_branches/eam_branch_20090303/ppImage 171 # Repository Root: https://svn.pan-starrs.ifa.hawaii.edu/repo/ipp 172 # Repository UUID: 60eb6cdc-a59c-4636-a4e0-dba66a9721fd 173 # Revision: 23158 174 # Node Kind: directory 175 # Schedule: normal 176 # Last Changed Author: price 177 # Last Changed Rev: 23125 178 # Last Changed Date: 2009-03-03 15:41:16 -1000 (Tue, 03 Mar 2009) 179 180 $svn_version = `svnversion`; chomp $svn_version; 181 @svn_info = `svn info`; 182 183 # get the svn_root first: 184 foreach $line (@svn_info) { 185 if ($line =~ m|^Repository Root:|) { 186 ($svn_root) = $line =~ m|^Repository Root:\s*(\S*)|; 187 last; 188 } 189 } 190 191 # now get the branch and UUID values 192 foreach $line (@svn_info) { 193 if ($line =~ m|^URL:|) { 194 ($svn_branch) = $line =~ m|^URL:\s*$svn_root/*(\S*)|; 195 } 196 if ($line =~ m|^Repository UUID:|) { 197 ($svn_source) = $line =~ m|^Repository UUID:\s*(\S*)|; 198 } 199 } 200 201 $ENV{SVN_VERSION} = $svn_version; 202 $ENV{SVN_BRANCH} = $svn_branch; 203 $ENV{SVN_SOURCE} = $svn_source; 204 } else { 205 # alternatively, grab these from the following files: 206 if (! -e "SVNINFO") { 207 print "missing SVNINFO file for repository info, skipping\n"; 208 } else { 209 @svn_info = `cat SVNINFO`; 210 foreach $line (@svn_info) { 211 ($name, $value) = split (" ", $line); 212 $ENV{$name} = $value; 213 } 214 } 215 } 216 print "SVN_VERSION $ENV{SVN_VERSION}\n"; 217 print "SVN_BRANCH $ENV{SVN_BRANCH}\n"; 218 print "SVN_SOURCE $ENV{SVN_SOURCE}\n"; 219 159 220 # use psconfig.csh to set needed build aliases 160 161 221 if ($extlibs eq "check") { 162 222 $status = vsystem ("pschecklibs"); … … 247 307 248 308 if (-e "Build.PL") { 249 vsystem ("$psperlbuild");250 if ($ ?) { &failure($module[$i], "failure in perl Build.PL"); }251 252 vsystem ("./Build");253 if ($ ?) { &failure($module[$i], "failure in Build"); }254 255 vsystem ("./Build install");256 if ($ ?) { &failure($module[$i], "failure in Build install"); }309 $status = vsystem ("$psperlbuild"); 310 if ($status) { &failure($module[$i], "failure in perl Build.PL"); } 311 312 $status = vsystem ("./Build"); 313 if ($status) { &failure($module[$i], "failure in Build"); } 314 315 $status = vsystem ("./Build install"); 316 if ($status) { &failure($module[$i], "failure in Build install"); } 257 317 258 318 next; … … 272 332 if ($developer && $rebuild_this && ! -e "configure" && -e "autogen.sh") { 273 333 $skip_configure = 1; 274 vsystem ("$psautogen $psopts");275 if ($ ?) { &failure($module[$i], "failure in psautogen"); }334 $status = vsystem ("$psautogen $psopts"); 335 if ($status) { &failure($module[$i], "failure in psautogen"); } 276 336 } 277 337 278 338 if ($rebuild_this && -e "configure" && !$skip_configure) { 279 vsystem ("$psconfigure $psopts");280 if ($ ?) { &failure($module[$i], "failure in psconfigure"); }339 $status = vsystem ("$psconfigure $psopts"); 340 if ($status) { &failure($module[$i], "failure in psconfigure"); } 281 341 } 282 342 … … 288 348 289 349 if ($clean) { 290 vsystem ("$make clean");291 if ($ ?) { &failure($module[$i], "failure in make clean"); }350 $status = vsystem ("$make clean"); 351 if ($status) { &failure($module[$i], "failure in make clean"); } 292 352 } 293 353 294 vsystem ("$make");295 if ($ ?) { &failure($module[$i], "failure in make"); }296 297 vsystem ("$make install");298 if ($ ?) { &failure($module[$i], "failure in make install"); }354 $status = vsystem ("$make"); 355 if ($status) { &failure($module[$i], "failure in make"); } 356 357 $status = vsystem ("$make install"); 358 if ($status) { &failure($module[$i], "failure in make install"); } 299 359 300 360 print "*** done with $module[$i] ***\n"; -
branches/cnb_branches/cnb_branch_20090301/psconfig/pschecklibs
r22721 r23352 487 487 488 488 sub usage { 489 print STDERR "USAGE: pscheck perl[-version] [-build]\n";489 print STDERR "USAGE: pschecklibs [-version] [-build]\n"; 490 490 exit 2; 491 491 } -
branches/cnb_branches/cnb_branch_20090301/psphot
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/cnb_branches/cnb_branch_20090215/psphot merged eligible /trunk/psphot merged eligible /branches/cnb_branch_20090215/psphot 21495-22685 /branches/eam_branches/eam_branch_20090303/psphot 23158-23228
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/cnb_branches/cnb_branch_20090301/psphot/src/Makefile.am
r21392 r23352 1 1 lib_LTLIBRARIES = libpsphot.la 2 libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 2 3 # PSPHOT_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 4 # PSPHOT_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi` 5 # PSPHOT_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 6 # 7 # # Force recompilation of psphotVersion.c, since it gets the version information 8 # psphotVersion.c: FORCE 9 # touch psphotVersion.c 10 # FORCE: ; 11 12 libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSPHOT_VERSION=$(PSPHOT_VERSION) -DPSPHOT_BRANCH=$(PSPHOT_BRANCH) -DPSPHOT_SOURCE=$(SVN_SOURCE) 3 13 libpsphot_la_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 4 14 -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphot.c
r20411 r23352 9 9 10 10 psTimerStart ("complete"); 11 pmErrorRegister(); // register psModule's error codes/messages11 pmErrorRegister(); // register psModule's error codes/messages 12 12 psphotInit(); 13 13 … … 15 15 pmConfig *config = psphotArguments (argc, argv); 16 16 if (!config) { 17 psErrorStackPrint(stderr, "Error reading arguments\n");18 usage ();17 psErrorStackPrint(stderr, "Error reading arguments\n"); 18 usage (); 19 19 } 20 21 psphotVersionPrint(); 20 22 21 23 // load input data (config and images (signal, noise, mask) -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphot.h
r21392 r23352 16 16 const char *psphotCVSName(void); 17 17 psString psphotVersion(void); 18 psString psphotSource(void); 18 19 psString psphotVersionLong(void); 20 bool psphotVersionHeader(psMetadata *header); 21 bool psphotVersionHeaderFull(psMetadata *header); 22 void psphotVersionPrint(void); 19 23 20 24 bool psphotModelTest (pmConfig *config, const pmFPAview *view, psMetadata *recipe); … … 167 171 168 172 // psphotVisual functions 169 bool psphotSetVisual (bool mode);170 173 bool psphotVisualShowImage (pmReadout *readout); 171 174 bool psphotVisualShowBackground (pmConfig *config, const pmFPAview *view, pmReadout *readout); -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotArguments.c
r21458 r23352 82 82 if ((N = psArgumentGet (argc, argv, "-visual"))) { 83 83 psArgumentRemove (N, &argc, argv); 84 psphotSetVisual (true); 85 // pmSourceSetVisual (true); 84 pmVisualSetVisual(true); 86 85 } 87 86 -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotImageLoop.c
r21458 r23352 26 26 27 27 pmFPAview *view = pmFPAviewAlloc (0); 28 pmHDU *lastHDU = NULL; // Last HDU updated 28 29 29 30 // files associated with the science image … … 64 65 psLogMsg ("psphot", 6, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 65 66 if (! readout->data_exists) { continue; } 67 68 // Update the header 69 { 70 pmHDU *hdu = pmHDUGetHighest(input->fpa, chip, cell); 71 if (hdu && hdu != lastHDU) { 72 psphotVersionHeaderFull(hdu->header); 73 lastHDU = hdu; 74 } 75 } 66 76 67 77 // run the actual photometry analysis on this chip/cell/readout -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotMagnitudes.c
r21519 r23352 15 15 int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); // Number of threads 16 16 if (!status) { 17 nThreads = 0;17 nThreads = 0; 18 18 } 19 19 … … 36 36 37 37 // the binning details are saved on the analysis metadata 38 psImageBinning *binning = psMetadataLookupPtr(&status, recipe, "PSPHOT.BACKGROUND.BINNING"); 38 psImageBinning *binning = NULL; 39 if (backModel) { 40 binning = psMetadataLookupPtr(&status, backModel->analysis, "PSPHOT.BACKGROUND.BINNING"); 41 } 39 42 40 43 bool IGNORE_GROWTH = psMetadataLookupBool (&status, recipe, "IGNORE_GROWTH"); … … 53 56 for (int i = 0; i < cellGroups->n; i++) { 54 57 55 psArray *cells = cellGroups->data[i];56 57 for (int j = 0; j < cells->n; j++) {58 59 // allocate a job -- if threads are not defined, this just runs the job60 psThreadJob *job = psThreadJobAlloc ("PSPHOT_MAGNITUDES");61 62 psArrayAdd(job->args, 1, cells->data[j]); // sources63 psArrayAdd(job->args, 1, psf);64 psArrayAdd(job->args, 1, binning);65 psArrayAdd(job->args, 1, backModel);66 psArrayAdd(job->args, 1, backStdev);67 68 PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32);69 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);70 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for nAp71 72 if (!psThreadJobAddPending(job)) {73 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");74 psFree (job);75 return false;76 }77 psFree(job);58 psArray *cells = cellGroups->data[i]; 59 60 for (int j = 0; j < cells->n; j++) { 61 62 // allocate a job -- if threads are not defined, this just runs the job 63 psThreadJob *job = psThreadJobAlloc ("PSPHOT_MAGNITUDES"); 64 65 psArrayAdd(job->args, 1, cells->data[j]); // sources 66 psArrayAdd(job->args, 1, psf); 67 psArrayAdd(job->args, 1, binning); 68 psArrayAdd(job->args, 1, backModel); 69 psArrayAdd(job->args, 1, backStdev); 70 71 PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32); 72 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 73 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for nAp 74 75 if (!psThreadJobAddPending(job)) { 76 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 77 psFree (job); 78 return false; 79 } 80 psFree(job); 78 81 79 82 # if (0) 80 int nap = 0;81 if (!psphotMagnitudes_Unthreaded (&nap, cells->data[j], psf, binning, backModel, backStdev, photMode, maskVal)) {82 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");83 return false;84 }85 Nap += nap;83 int nap = 0; 84 if (!psphotMagnitudes_Unthreaded (&nap, cells->data[j], psf, binning, backModel, backStdev, photMode, maskVal)) { 85 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 86 return false; 87 } 88 Nap += nap; 86 89 # endif 87 }88 89 // wait for the threads to finish and manage results90 if (!psThreadPoolWait (false)) {91 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");92 return false;93 }94 95 // we have only supplied one type of job, so we can assume the types here96 psThreadJob *job = NULL;97 while ((job = psThreadJobGetDone()) != NULL) {98 if (job->args->n < 1) {99 fprintf (stderr, "error with job\n");100 } else {101 psScalar *scalar = job->args->data[7];102 Nap += scalar->data.S32;103 }104 psFree(job);105 }90 } 91 92 // wait for the threads to finish and manage results 93 if (!psThreadPoolWait (false)) { 94 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 95 return false; 96 } 97 98 // we have only supplied one type of job, so we can assume the types here 99 psThreadJob *job = NULL; 100 while ((job = psThreadJobGetDone()) != NULL) { 101 if (job->args->n < 1) { 102 fprintf (stderr, "error with job\n"); 103 } else { 104 psScalar *scalar = job->args->data[7]; 105 Nap += scalar->data.S32; 106 } 107 psFree(job); 108 } 106 109 } 107 110 … … 130 133 if (status && isfinite(source->apMag)) Nap ++; 131 134 132 if (backModel) {133 psAssert (binning, "if backModel is defined, so should binning be");134 source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning);135 if (isnan(source->sky) && false) {136 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky");137 }138 } else {139 source->sky = NAN;140 }141 142 if (backStdev) {143 psAssert (binning, "if backStdev is defined, so should binning be");144 source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning);145 if (isnan(source->skyErr) && false) {146 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr");147 }148 } else {149 source->skyErr = NAN;150 }135 if (backModel) { 136 psAssert (binning, "if backModel is defined, so should binning be"); 137 source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning); 138 if (isnan(source->sky) && false) { 139 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky"); 140 } 141 } else { 142 source->sky = NAN; 143 } 144 145 if (backStdev) { 146 psAssert (binning, "if backStdev is defined, so should binning be"); 147 source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning); 148 if (isnan(source->skyErr) && false) { 149 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr"); 150 } 151 } else { 152 source->skyErr = NAN; 153 } 151 154 } 152 155 … … 169 172 if (status && isfinite(source->apMag)) Nap ++; 170 173 171 if (backModel) {172 psAssert (binning, "if backModel is defined, so should binning be");173 source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning);174 if (isnan(source->sky) && false) {175 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky");176 }177 } else {178 source->sky = NAN;179 }180 181 if (backStdev) {182 psAssert (binning, "if backStdev is defined, so should binning be");183 source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning);184 if (isnan(source->skyErr) && false) {185 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr");186 }187 } else {188 source->skyErr = NAN;189 }174 if (backModel) { 175 psAssert (binning, "if backModel is defined, so should binning be"); 176 source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning); 177 if (isnan(source->sky) && false) { 178 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky"); 179 } 180 } else { 181 source->sky = NAN; 182 } 183 184 if (backStdev) { 185 psAssert (binning, "if backStdev is defined, so should binning be"); 186 source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning); 187 if (isnan(source->skyErr) && false) { 188 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr"); 189 } 190 } else { 191 source->skyErr = NAN; 192 } 190 193 } 191 194 … … 210 213 int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); // Number of threads 211 214 if (!status) { 212 nThreads = 0;215 nThreads = 0; 213 216 } 214 217 nThreads = 0; // XXX until testing is complete, do not thread this function … … 233 236 for (int i = 0; i < cellGroups->n; i++) { 234 237 235 psArray *cells = cellGroups->data[i];236 237 for (int j = 0; j < cells->n; j++) {238 239 // allocate a job -- if threads are not defined, this just runs the job240 psThreadJob *job = psThreadJobAlloc ("PSPHOT_PSF_WEIGHTS");241 242 psArrayAdd(job->args, 1, cells->data[j]); // sources243 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);244 245 if (!psThreadJobAddPending(job)) {246 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");247 psFree (job);248 return false;249 }250 psFree(job);251 252 }253 254 // wait for the threads to finish and manage results255 if (!psThreadPoolWait (false)) {256 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");257 return false;258 }259 260 // we have only supplied one type of job, so we can assume the types here261 psThreadJob *job = NULL;262 while ((job = psThreadJobGetDone()) != NULL) {263 if (job->args->n < 1) {264 fprintf (stderr, "error with job\n");265 } 266 psFree(job);267 }238 psArray *cells = cellGroups->data[i]; 239 240 for (int j = 0; j < cells->n; j++) { 241 242 // allocate a job -- if threads are not defined, this just runs the job 243 psThreadJob *job = psThreadJobAlloc ("PSPHOT_PSF_WEIGHTS"); 244 245 psArrayAdd(job->args, 1, cells->data[j]); // sources 246 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 247 248 if (!psThreadJobAddPending(job)) { 249 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 250 psFree (job); 251 return false; 252 } 253 psFree(job); 254 255 } 256 257 // wait for the threads to finish and manage results 258 if (!psThreadPoolWait (false)) { 259 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 260 return false; 261 } 262 263 // we have only supplied one type of job, so we can assume the types here 264 psThreadJob *job = NULL; 265 while ((job = psThreadJobGetDone()) != NULL) { 266 if (job->args->n < 1) { 267 fprintf (stderr, "error with job\n"); 268 } 269 psFree(job); 270 } 268 271 } 269 272 … … 285 288 pmSource *source = (pmSource *) sources->data[i]; 286 289 287 // we must have a valid model288 pmModel *model = pmSourceGetModel (&isPSF, source);289 if (model == NULL) {290 psTrace ("psphot", 3, "fail mag : no valid model");291 source->pixWeight = NAN;292 continue;293 }290 // we must have a valid model 291 pmModel *model = pmSourceGetModel (&isPSF, source); 292 if (model == NULL) { 293 psTrace ("psphot", 3, "fail mag : no valid model"); 294 source->pixWeight = NAN; 295 continue; 296 } 294 297 295 298 status = pmSourcePixelWeight (&source->pixWeight, model, source->maskObj, maskVal); 296 if (!status) {297 psTrace ("psphot", 3, "fail to measure pixel weight");298 source->pixWeight = NAN;299 continue;300 }301 302 } 303 304 return true; 305 } 299 if (!status) { 300 psTrace ("psphot", 3, "fail to measure pixel weight"); 301 source->pixWeight = NAN; 302 continue; 303 } 304 305 } 306 307 return true; 308 } -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotMaskReadout.c
r21366 r23352 29 29 } 30 30 31 // make this an option via the recipe 32 if (0) { 33 psImage *im = readout->image; 34 psImage *wt = readout->variance; 35 psImage *mk = readout->mask; 36 for (int j = 0; j < im->numRows; j++) { 37 for (int i = 0; i < im->numCols; i++) { 38 if (isfinite(im->data.F32[j][i]) && isfinite(wt->data.F32[j][i])) continue; 39 mk->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskBad; 40 } 41 } 42 } 43 31 44 // mask the excluded outer pixels 32 45 // these coordinates refer to the parent image -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotModelBackground.c
r21183 r23352 31 31 static bool backgroundModel(psImage *model, // Model image 32 32 psImage *modelStdev, // Model stdev image 33 ps Image *image, // Image for which to generate a background model34 p sImage *mask, // Mask for image33 psMetadata *analysis, // Analysis metadata for outputs 34 pmReadout *readout, // Readout for which to generate a background model 35 35 psImageBinning *binning, // Binning parameters 36 36 const pmConfig *config // Configuration … … 41 41 bool status = true; 42 42 43 psImage *image = readout->image, *mask = readout->mask; // Image and mask for readout 44 43 45 // select the appropriate recipe information 44 46 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); … … 49 51 assert (maskVal); 50 52 51 // user supplied seed, if available 52 unsigned long seed = psMetadataLookupS32 (&status, recipe, "IMSTATS_SEED"); 53 if (!status) { 54 seed = 0; 55 } 56 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, seed); 53 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 57 54 58 55 // subtract this amount extra from the sky … … 140 137 141 138 // we save the binning structure for use in psphotMagnitudes 142 status = psMetadataAddPtr(recipe, PS_LIST_TAIL, "PSPHOT.BACKGROUND.BINNING", PS_DATA_UNKNOWN | PS_META_REPLACE, "Background binning", binning); 143 PS_ASSERT (status, false); 144 139 psMetadataAddPtr(analysis, PS_LIST_TAIL, "PSPHOT.BACKGROUND.BINNING", 140 PS_DATA_UNKNOWN | PS_META_REPLACE, "Background binning", binning); 145 141 146 142 psF32 **modelData = model->data.F32; … … 343 339 psImage *modelStdev = psImageAlloc(binning->nXruff, binning->nYruff, PS_TYPE_F32); // Standard deviation 344 340 345 if (!backgroundModel(model, modelStdev, ro-> image, ro->mask, binning, config)) {341 if (!backgroundModel(model, modelStdev, ro->analysis, ro, binning, config)) { 346 342 psFree(model); 347 343 psFree(modelStdev); … … 365 361 pmFPAfile *file = psMetadataLookupPtr (&status, config->files, filename); 366 362 pmFPA *inFPA = file->fpa; 367 pmReadout *readout = pmFPAviewThisReadout (view, inFPA); 368 psImage *image = readout->image; 369 psImage *mask = readout->mask; 370 371 psImageBinning *binning = backgroundBinning(image, config); // Image binning parameters 363 pmReadout *readout = pmFPAviewThisReadout(view, inFPA); 364 365 psImageBinning *binning = backgroundBinning(readout->image, config); // Image binning parameters 372 366 pmReadout *model = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL", inFPA, binning); 373 367 pmReadout *modelStdev = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL.STDEV", inFPA, binning); 374 368 375 if (!backgroundModel(model->image, modelStdev->image, image, mask, binning, config)) {369 if (!backgroundModel(model->image, modelStdev->image, model->analysis, readout, binning, config)) { 376 370 psError(PS_ERR_UNKNOWN, false, "Unable to generate background model"); 377 371 return false; -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotSetThreads.c
r21392 r23352 25 25 psFree(task); 26 26 27 task = psThreadTaskAlloc("PSPHOT_SOURCE_STATS", 4);27 task = psThreadTaskAlloc("PSPHOT_SOURCE_STATS", 5); 28 28 task->function = &psphotSourceStats_Threaded; 29 29 psThreadTaskAdd(task); -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotSourceStats.c
r21519 r23352 15 15 int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); // Number of threads 16 16 if (!status) { 17 nThreads = 0;17 nThreads = 0; 18 18 } 19 19 … … 41 41 pmSource *source = pmSourceAlloc(); 42 42 43 // add the peak43 // add the peak 44 44 source->peak = psMemIncrRefCounter(peak); 45 45 46 // allocate space for moments46 // allocate space for moments 47 47 source->moments = pmMomentsAlloc(); 48 48 … … 50 50 pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER); 51 51 52 peak->assigned = true;53 psArrayAdd (sources, 100, source);54 psFree (source);52 peak->assigned = true; 53 psArrayAdd (sources, 100, source); 54 psFree (source); 55 55 } 56 56 57 57 if (!strcasecmp (breakPt, "PEAKS")) { 58 psLogMsg ("psphot", PS_LOG_INFO, "%ld sources : %f sec\n", sources->n, psTimerMark ("psphot.stats"));59 psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n");60 psphotVisualShowMoments (sources);61 return sources;58 psLogMsg ("psphot", PS_LOG_INFO, "%ld sources : %f sec\n", sources->n, psTimerMark ("psphot.stats")); 59 psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n"); 60 psphotVisualShowMoments (sources); 61 return sources; 62 62 } 63 63 … … 65 65 int Nfail = 0; 66 66 int Nmoments = 0; 67 int Nfaint = 0; 67 68 68 69 // choose Cx, Cy (see psphotThreadTools.c for overview of the concepts) … … 74 75 for (int i = 0; i < cellGroups->n; i++) { 75 76 76 psArray *cells = cellGroups->data[i]; 77 78 for (int j = 0; j < cells->n; j++) { 79 80 // allocate a job -- if threads are not defined, this just runs the job 81 psThreadJob *job = psThreadJobAlloc ("PSPHOT_SOURCE_STATS"); 82 83 psArrayAdd(job->args, 1, cells->data[j]); // sources 84 psArrayAdd(job->args, 1, recipe); 85 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nmoments 86 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail 87 88 if (!psThreadJobAddPending(job)) { 89 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 90 psFree (job); 91 return NULL; 92 } 93 psFree(job); 77 psArray *cells = cellGroups->data[i]; 78 79 for (int j = 0; j < cells->n; j++) { 80 81 // allocate a job -- if threads are not defined, this just runs the job 82 psThreadJob *job = psThreadJobAlloc ("PSPHOT_SOURCE_STATS"); 83 84 psArrayAdd(job->args, 1, cells->data[j]); // sources 85 psArrayAdd(job->args, 1, recipe); 86 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nmoments 87 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail 88 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfaint 89 90 if (!psThreadJobAddPending(job)) { 91 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 92 psFree (job); 93 return NULL; 94 } 95 psFree(job); 94 96 95 97 # if (0) 96 int nfail = 0;97 int nmoments = 0;98 if (!psphotSourceStats_Unthreaded (&nfail, &nmoments, cells->data[j], recipe)) {99 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");100 return NULL;101 }102 Nfail += nfail;103 Nmoments += nmoments;98 int nfail = 0; 99 int nmoments = 0; 100 if (!psphotSourceStats_Unthreaded (&nfail, &nmoments, cells->data[j], recipe)) { 101 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 102 return NULL; 103 } 104 Nfail += nfail; 105 Nmoments += nmoments; 104 106 # endif 105 } 106 107 // wait for the threads to finish and manage results 108 if (!psThreadPoolWait (false)) { 109 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 110 return NULL; 111 } 112 113 // we have only supplied one type of job, so we can assume the types here 114 psThreadJob *job = NULL; 115 while ((job = psThreadJobGetDone()) != NULL) { 116 if (job->args->n < 1) { 117 fprintf (stderr, "error with job\n"); 118 } else { 119 psScalar *scalar = NULL; 120 scalar = job->args->data[2]; 121 Nmoments += scalar->data.S32; 122 scalar = job->args->data[3]; 123 Nfail += scalar->data.S32; 124 } 125 psFree(job); 126 } 107 } 108 109 // wait for the threads to finish and manage results 110 if (!psThreadPoolWait (false)) { 111 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 112 return NULL; 113 } 114 115 // we have only supplied one type of job, so we can assume the types here 116 psThreadJob *job = NULL; 117 while ((job = psThreadJobGetDone()) != NULL) { 118 if (job->args->n < 1) { 119 fprintf (stderr, "error with job\n"); 120 } else { 121 psScalar *scalar = NULL; 122 scalar = job->args->data[2]; 123 Nmoments += scalar->data.S32; 124 scalar = job->args->data[3]; 125 Nfail += scalar->data.S32; 126 scalar = job->args->data[4]; 127 Nfaint += scalar->data.S32; 128 } 129 psFree(job); 130 } 127 131 } 128 132 129 133 psFree (cellGroups); 130 134 131 psLogMsg ("psphot", PS_LOG_INFO, "%ld sources, %d moments, %d fai led: %f sec\n", sources->n, Nmoments, Nfail, psTimerMark ("psphot.stats"));135 psLogMsg ("psphot", PS_LOG_INFO, "%ld sources, %d moments, %d faint, %d failed: %f sec\n", sources->n, Nmoments, Nfaint, Nfail, psTimerMark ("psphot.stats")); 132 136 133 137 psphotVisualShowMoments (sources); … … 166 170 int Nfail = 0; 167 171 int Nmoments = 0; 172 int Nfaint = 0; 168 173 for (int i = 0; i < sources->n; i++) { 169 174 pmSource *source = sources->data[i]; … … 171 176 // skip faint sources for moments measurement 172 177 if (source->peak->SN < MIN_SN) { 173 source->mode |= PM_SOURCE_MODE_BELOW_MOMENTS_SN; 178 source->mode |= PM_SOURCE_MODE_BELOW_MOMENTS_SN; 179 Nfaint++; 174 180 continue; 175 181 } … … 179 185 status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 180 186 if (!status) { 181 source->mode |= PM_SOURCE_MODE_SKY_FAILURE;182 psErrorClear(); // XXX re-consider the errors raised here183 Nfail ++;184 continue;187 source->mode |= PM_SOURCE_MODE_SKY_FAILURE; 188 psErrorClear(); // XXX re-consider the errors raised here 189 Nfail ++; 190 continue; 185 191 } 186 192 … … 189 195 status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 190 196 if (!status) { 191 source->mode |= PM_SOURCE_MODE_SKYVAR_FAILURE;192 Nfail ++;193 psErrorClear();194 continue;197 source->mode |= PM_SOURCE_MODE_SKYVAR_FAILURE; 198 Nfail ++; 199 psErrorClear(); 200 continue; 195 201 } 196 202 … … 208 214 status = pmSourceMoments (source, BIG_RADIUS); 209 215 if (status) { 210 source->mode |= PM_SOURCE_MODE_BIG_RADIUS;216 source->mode |= PM_SOURCE_MODE_BIG_RADIUS; 211 217 Nmoments ++; 212 218 continue; 213 219 } 214 220 215 source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE;221 source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE; 216 222 Nfail ++; 217 223 psErrorClear(); … … 225 231 scalar = job->args->data[3]; 226 232 scalar->data.S32 = Nfail; 227 233 234 scalar = job->args->data[4]; 235 scalar->data.S32 = Nfaint; 236 228 237 return true; 229 238 } … … 268 277 status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 269 278 if (!status) { 270 psErrorClear(); // XXX re-consider the errors raised here271 Nfail ++;272 continue;279 psErrorClear(); // XXX re-consider the errors raised here 280 Nfail ++; 281 continue; 273 282 } 274 283 … … 277 286 status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 278 287 if (!status) { 279 Nfail ++;280 psErrorClear();281 continue;288 Nfail ++; 289 psErrorClear(); 290 continue; 282 291 } 283 292 … … 307 316 *nmoments = Nmoments; 308 317 *nfail = Nfail; 309 318 310 319 return true; 311 320 } 312 # endif 321 # endif -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotSubtractBackground.c
r21183 r23352 4 4 // generate the median in NxN boxes, clipping heavily 5 5 // linear interpolation to generate full-scale model 6 bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view, const char *filename) 6 bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view, const char *filename) 7 7 { 8 8 bool status = true; … … 31 31 assert (maskVal); 32 32 33 psImageBinning *binning = psMetadataLookupPtr(&status, recipe, "PSPHOT.BACKGROUND.BINNING");33 psImageBinning *binning = psMetadataLookupPtr(&status, model->analysis, "PSPHOT.BACKGROUND.BINNING"); 34 34 assert (binning); 35 35 -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotVersion.c
r12805 r23352 1 # include "psphotInternal.h"1 #include "psphotInternal.h" 2 2 3 # if (HAVE_KAPA)4 # include <kapa.h>5 # endif3 #ifdef HAVE_KAPA 4 #include <kapa.h> 5 #endif 6 6 7 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name 7 #ifndef PSPHOT_VERSION 8 #error "PSPHOT_VERSION is not set" 9 #endif 10 #ifndef PSPHOT_BRANCH 11 #error "PSPHOT_BRANCH is not set" 12 #endif 13 #ifndef PSPHOT_SOURCE 14 #error "PSPHOT_SOURCE is not set" 15 #endif 16 17 #define xstr(s) str(s) 18 #define str(s) #s 8 19 9 20 psString psphotVersion(void) 10 21 { 11 psString version = NULL; // Version, to return 12 psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION); 13 return version; 22 char *value = NULL; 23 psStringAppend(&value, "%s@%s", xstr(PSPHOT_BRANCH), xstr(PSPHOT_VERSION)); 24 return value; 25 } 26 27 psString psphotSource(void) 28 { 29 return psStringCopy(xstr(PSPHOT_SOURCE)); 14 30 } 15 31 16 32 psString psphotVersionLong(void) 17 33 { 18 psString version = psphotVersion(); // Version, to return 19 psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag 20 psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__); 34 psString version = psLibVersion(); // Version, to return 35 psString source = psLibSource(); // Source 21 36 22 # if (HAVE_KAPA) 23 psString ohanaVersion = psStringStripCVS (ohana_version(), "Name");24 ps String libdvoVersion = psStringStripCVS (libdvo_version(), "Name");37 psStringPrepend(&version, "psphot "); 38 psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__); 39 psFree(source); 25 40 26 psStringAppend (&version, " with libkapa (ohana %s, libdvo: %s)", ohanaVersion, libdvoVersion); 27 psFree (ohanaVersion); 28 psFree (libdvoVersion); 29 # else 30 psStringAppend (&version, " WITHOUT libkapa"); 31 # endif 41 #ifdef __OPTIMIZE__ 42 psStringAppend(&version, " optimised"); 43 #else 44 psStringAppend(&version, " unoptimised"); 45 #endif 32 46 33 psFree(tag); 47 #ifdef HAVE_KAPA 48 #if 0 49 // XXX Need to get ohana and libdvo versions 50 psString ohanaVersion = psStringStripCVS(ohana_version(), "Name"); 51 psString libdvoVersion = psStringStripCVS(libdvo_version(), "Name"); 52 psStringAppend(&version, " with libkapa (ohana %s, libdvo: %s)", ohanaVersion, libdvoVersion); 53 psFree(ohanaVersion); 54 psFree(libdvoVersion); 55 #else 56 psStringAppend(&version, " with libkapa"); 57 #endif 58 59 #else 60 psStringAppend (&version, " without libkapa"); 61 #endif 62 34 63 return version; 35 64 } 36 65 37 // Defined by RHL; leaving for backwards compatibility. 38 const char *psphotCVSName(void) { 39 return cvsTag; 66 bool psphotVersionHeader(psMetadata *header) 67 { 68 PS_ASSERT_METADATA_NON_NULL(header, false); 69 70 psString version = psphotVersion(); // Software version 71 psString source = psphotSource(); // Software source 72 73 psStringPrepend(&version, "psphot version: "); 74 psStringPrepend(&source, "psphot source: "); 75 76 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version); 77 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source); 78 79 psFree(version); 80 psFree(source); 81 82 return true; 40 83 } 84 85 86 bool psphotVersionHeaderFull(psMetadata *header) 87 { 88 PS_ASSERT_METADATA_NON_NULL(header, false); 89 90 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 91 psString timeString = psTimeToISO(time); // The time in an ISO string 92 psFree(time); 93 psString history = NULL; // History string 94 psStringAppend(&history, "psphot at %s", timeString); 95 psFree(timeString); 96 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history); 97 psFree(history); 98 99 psLibVersionHeader(header); 100 psModulesVersionHeader(header); 101 psphotVersionHeader(header); 102 103 return true; 104 } 105 106 107 void psphotVersionPrint(void) 108 { 109 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 110 psString timeString = psTimeToISO(time); // The time in an ISO string 111 psFree(time); 112 psLogMsg("psphot", PS_LOG_INFO, "psphot at %s", timeString); 113 psFree(timeString); 114 115 psString pslib = psLibVersionLong();// psLib version 116 psString psmodules = psModulesVersionLong(); // psModules version 117 psString psphot = psphotVersionLong(); // psphot version 118 119 psLogMsg("psphot", PS_LOG_INFO, "%s", pslib); 120 psLogMsg("psphot", PS_LOG_INFO, "%s", psmodules); 121 psLogMsg("psphot", PS_LOG_INFO, "%s", psphot); 122 123 psFree(pslib); 124 psFree(psmodules); 125 psFree(psphot); 126 127 return; 128 } -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotVisual.c
r21519 r23352 18 18 // these are invoked by the -visual options 19 19 20 static bool isVisual = false;21 20 static int kapa = -1; 22 21 static int kapa2 = -1; 23 22 static int kapa3 = -1; 24 23 25 bool psphotSetVisual (bool mode) {26 27 isVisual = mode;28 return true;29 }30 24 31 25 bool psphotVisualShowMask (int kapaFD, psImage *inImage, const char *name, int channel) { … … 38 32 39 33 psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 40 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0);34 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 41 35 if (!psImageBackground(stats, NULL, inImage, NULL, 0, rng)) { 42 36 fprintf (stderr, "failed to get background values\n"); … … 84 78 85 79 psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 86 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0);80 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 87 81 if (!psImageBackground(stats, NULL, inImage, NULL, 0, rng)) { 88 82 fprintf (stderr, "failed to get background values\n"); … … 135 129 bool psphotVisualShowImage (pmReadout *readout) { 136 130 137 if (! isVisual) return true;131 if (!pmVisualIsVisual()) return true; 138 132 139 133 if (kapa == -1) { … … 141 135 if (kapa == -1) { 142 136 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 143 isVisual = false;137 pmVisualSetVisual(false); 144 138 return false; 145 139 } … … 164 158 pmReadout *backgnd; 165 159 166 if (! isVisual) return true;160 if (!pmVisualIsVisual()) return true; 167 161 168 162 if (kapa == -1) { … … 170 164 if (kapa == -1) { 171 165 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 172 isVisual = false;166 pmVisualSetVisual(false); 173 167 return false; 174 168 } … … 199 193 bool psphotVisualShowSignificance (psImage *image) { 200 194 201 if (! isVisual) return true;195 if (!pmVisualIsVisual()) return true; 202 196 203 197 if (kapa == -1) { … … 205 199 if (kapa == -1) { 206 200 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 207 isVisual = false;201 pmVisualSetVisual(false); 208 202 return false; 209 203 } … … 228 222 KiiOverlay *overlay; 229 223 230 if (! isVisual) return true;224 if (!pmVisualIsVisual()) return true; 231 225 232 226 if (kapa == -1) { … … 306 300 KiiOverlay *overlay; 307 301 308 if (! isVisual) return true;302 if (!pmVisualIsVisual()) return true; 309 303 310 304 if (kapa == -1) { … … 423 417 psEllipseAxes axes; 424 418 425 if (! isVisual) return true;419 if (!pmVisualIsVisual()) return true; 426 420 427 421 if (kapa == -1) { … … 478 472 Graphdata graphdata; 479 473 480 if (! isVisual) return true;474 if (!pmVisualIsVisual()) return true; 481 475 482 476 if (kapa3 == -1) { … … 484 478 if (kapa3 == -1) { 485 479 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 486 isVisual = false;480 pmVisualSetVisual(false); 487 481 return false; 488 482 } … … 694 688 bool psphotVisualShowRoughClass (psArray *sources) { 695 689 696 if (! isVisual) return true;690 if (!pmVisualIsVisual()) return true; 697 691 698 692 if (kapa == -1) { … … 723 717 bool psphotVisualShowPSFModel (pmReadout *readout, pmPSF *psf) { 724 718 725 if (! isVisual) return true;719 if (!pmVisualIsVisual()) return true; 726 720 727 721 if (kapa2 == -1) { … … 729 723 if (kapa2 == -1) { 730 724 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 731 isVisual = false;725 pmVisualSetVisual(false); 732 726 return false; 733 727 } … … 801 795 bool status; 802 796 803 if (! isVisual) return true;797 if (!pmVisualIsVisual()) return true; 804 798 805 799 if (kapa2 == -1) { … … 807 801 if (kapa2 == -1) { 808 802 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 809 isVisual = false;803 pmVisualSetVisual(false); 810 804 return false; 811 805 } … … 961 955 bool status; 962 956 963 if (! isVisual) return true;957 if (!pmVisualIsVisual()) return true; 964 958 965 959 if (kapa2 == -1) { … … 967 961 if (kapa2 == -1) { 968 962 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 969 isVisual = false;963 pmVisualSetVisual(false); 970 964 return false; 971 965 } … … 1214 1208 KapaSection section; // put the positive profile in one and the residuals in another? 1215 1209 1216 if (! isVisual) return true;1210 if (!pmVisualIsVisual()) return true; 1217 1211 1218 1212 if (kapa3 == -1) { … … 1220 1214 if (kapa3 == -1) { 1221 1215 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1222 isVisual = false;1216 pmVisualSetVisual(false); 1223 1217 return false; 1224 1218 } … … 1286 1280 psEllipseAxes axes; 1287 1281 1288 if (! isVisual) return true;1282 if (!pmVisualIsVisual()) return true; 1289 1283 1290 1284 if (kapa == -1) { … … 1387 1381 KiiOverlay *overlay; 1388 1382 1389 if (! isVisual) return true;1383 if (!pmVisualIsVisual()) return true; 1390 1384 1391 1385 if (kapa == -1) { … … 1464 1458 KapaSection section; 1465 1459 1466 if (! isVisual) return true;1460 if (!pmVisualIsVisual()) return true; 1467 1461 1468 1462 if (kapa3 == -1) { … … 1470 1464 if (kapa3 == -1) { 1471 1465 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1472 isVisual = false;1466 pmVisualSetVisual(false); 1473 1467 return false; 1474 1468 } … … 1604 1598 bool psphotVisualShowResidualImage (pmReadout *readout) { 1605 1599 1606 if (! isVisual) return true;1600 if (!pmVisualIsVisual()) return true; 1607 1601 1608 1602 if (kapa == -1) { … … 1610 1604 if (kapa == -1) { 1611 1605 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1612 isVisual = false;1606 pmVisualSetVisual(false); 1613 1607 return false; 1614 1608 } … … 1631 1625 Graphdata graphdata; 1632 1626 1633 if (! isVisual) return true;1627 if (!pmVisualIsVisual()) return true; 1634 1628 1635 1629 if (kapa3 == -1) { … … 1637 1631 if (kapa3 == -1) { 1638 1632 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1639 isVisual = false;1633 pmVisualSetVisual(false); 1640 1634 return false; 1641 1635 } … … 1712 1706 # else 1713 1707 1714 bool psphotSetVisual (bool mode){}1715 1708 bool psphotVisualShowImage (pmConfig *config, pmReadout *readout) { return true; } 1716 1709 bool psphotVisualShowBackground (pmConfig *config, const pmFPAview *view, pmReadout *readout) { return true; } -
branches/cnb_branches/cnb_branch_20090301/pstamp/scripts/pstamp_finish.pl
r21410 r23352 21 21 22 22 use PS::IPP::Config qw( :standard ); 23 use PS tamp::RequestFile qw( :standard );24 use PS tamp::Job qw( :standard );23 use PS::IPP::PStamp::RequestFile qw( :standard ); 24 use PS::IPP::PStamp::Job qw( :standard ); 25 25 26 26 my ( $req_id, $req_name, $req_file, $out_dir, $product, $dbname, $verbose, $save_temps, $redirect_output); … … 105 105 } 106 106 107 # this function is PS tamp::RequestFile::read_request_file107 # this function is PS::IPP::PStamp::RequestFile::read_request_file 108 108 my ($header, $rows) = read_request_file($req_file); 109 109 -
branches/cnb_branches/cnb_branch_20090301/pstamp/scripts/pstamp_job_run.pl
r21410 r23352 13 13 use File::Basename; 14 14 use Digest::MD5::File qw( file_md5_hex ); 15 use PS tamp::RequestFile qw( :standard );15 use PS::IPP::PStamp::RequestFile qw( :standard ); 16 16 17 17 my $verbose; -
branches/cnb_branches/cnb_branch_20090301/pstamp/scripts/pstampparse.pl
r21410 r23352 11 11 use Sys::Hostname; 12 12 use Getopt::Long qw( GetOptions ); 13 use PS tamp::RequestFile qw( :standard );14 use PS tamp::Job qw( :standard );13 use PS::IPP::PStamp::RequestFile qw( :standard ); 14 use PS::IPP::PStamp::Job qw( :standard ); 15 15 16 16 my $verbose; … … 178 178 } 179 179 180 # Call PS tamp::Job's locate_images routine to get the parameters for this request specification180 # Call PS::IPP::PStamp::Job's locate_images routine to get the parameters for this request specification 181 181 my $images = locate_images($ipprc, $image_db, $req_type, $img_type, $id, $class_id, 182 182 $x, $y, $mjd_min, $mjd_max, $filter, $verbose); -
branches/cnb_branches/cnb_branch_20090301/pstamp/test/test_lookup.pl
r20113 r23352 9 9 10 10 use Getopt::Long qw( GetOptions ); 11 use PS tamp::Job qw( :standard );11 use PS::IPP::PStamp::Job qw( :standard ); 12 12 13 13 use PS::IPP::Config qw( :standard ); -
branches/cnb_branches/cnb_branch_20090301/pstest/src/tst_psPolynomial.c
r5873 r23352 289 289 fillVectors(x, f, NORD, NPTS, type[k]); 290 290 psTime *now = psTimeGetNow(PS_TIME_UTC); 291 const psRandom *r = psRandomAlloc (PS_RANDOM_TAUS, now->sec);291 const psRandom *r = psRandomAllocSpecific(PS_RANDOM_TAUS, now->sec); 292 292 for (int i = 0; i < NPTS; i++) { 293 293 double errgen = psRandomGaussian(r); … … 361 361 // add random errors to the vector 362 362 psTime *now = psTimeGetNow(PS_TIME_UTC); 363 const psRandom *r = psRandomAlloc (PS_RANDOM_TAUS, now->sec);363 const psRandom *r = psRandomAllocSpecific(PS_RANDOM_TAUS, now->sec); 364 364 for (int i = 0; i < NPTS; i++) { 365 365 double errgen = psRandomGaussian(r); … … 464 464 fillVectors(x, f, NORD, NPTS, type[k]); 465 465 psTime *now = psTimeGetNow(PS_TIME_UTC); 466 const psRandom *r = psRandomAlloc (PS_RANDOM_TAUS, now->sec);466 const psRandom *r = psRandomAllocSpecific(PS_RANDOM_TAUS, now->sec); 467 467 for (int i = 0; i < NPTS; i++) { 468 468 double errgen = psRandomGaussian(r); -
branches/cnb_branches/cnb_branch_20090301/pswarp/src/Makefile.am
r18839 r23352 1 1 bin_PROGRAMS = pswarp 2 pswarp_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PSWARP_CFLAGS) 2 3 PSWARP_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 4 PSWARP_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi` 5 PSWARP_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 6 7 # Force recompilation of pswarpVersion.c, since it gets the version information 8 pswarpVersion.c: FORCE 9 touch pswarpVersion.c 10 FORCE: ; 11 12 pswarp_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PSWARP_CFLAGS) -DPSWARP_VERSION=\"$(PSWARP_VERSION)\" -DPSWARP_BRANCH=\"$(PSWARP_BRANCH)\" -DPSWARP_SOURCE=\"$(PSWARP_SOURCE)\" 3 13 pswarp_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PSWARP_LIBS) 4 14 … … 18 28 pswarpSetThreads.c \ 19 29 pswarpTransformReadout.c \ 20 pswarpTransformSources.c \30 pswarpTransformSources.c \ 21 31 pswarpTransformTile.c \ 22 32 pswarpVersion.c -
branches/cnb_branches/cnb_branch_20090301/pswarp/src/pswarp.c
r21442 r23352 39 39 if (!config) usage(); 40 40 41 pswarpVersionPrint(); 42 41 43 // load identify the data sources 42 44 if (!pswarpParseCamera(config)) { -
branches/cnb_branches/cnb_branch_20090301/pswarp/src/pswarp.h
r21368 r23352 112 112 */ 113 113 bool pswarpSetThreads (); 114 115 /// Return software version 116 psString pswarpVersion(void); 117 118 /// Return software souce 119 psString pswarpSource(void); 120 121 /// Return long software version information 122 psString pswarpVersionLong(void); 123 124 /// Populate header with version information 125 bool pswarpVersionHeader( 126 psMetadata *header ///< Header to populate 127 ); 128 129 /// Print version information 130 void pswarpVersionPrint(void); -
branches/cnb_branches/cnb_branch_20090301/pswarp/src/pswarpArguments.c
r21368 r23352 41 41 if ((arg = psArgumentGet(argc, argv, "-psphot-visual"))) { 42 42 psArgumentRemove(arg, &argc, argv); 43 p sphotSetVisual(true);43 pmVisualSetVisual(true); 44 44 } 45 45 } … … 87 87 88 88 89 if (!pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list")) { 90 psError(PSWARP_ERR_ARGUMENTS, true, "Missing -file (input) or -list (input)"); 91 return NULL; 92 } 93 94 // the mask and variance entries are optional (build from gain?) 95 pmConfigFileSetsMD (config->arguments, &argc, argv, "MASK", "-mask", "-masklist"); 89 pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list"); 90 pmConfigFileSetsMD (config->arguments, &argc, argv, "MASK", "-mask", "-masklist"); 96 91 pmConfigFileSetsMD (config->arguments, &argc, argv, "VARIANCE", "-variance", "-variancelist"); 97 92 … … 105 100 106 101 // output position is fixed 107 psMetadataAddStr (config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "", argv[1]);102 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "", argv[1]); 108 103 109 104 // skycell position is fixed 110 105 array = psArrayAlloc(1); 111 array->data[0] = psStringCopy (argv[2]);112 status = psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "SKYCELL", PS_DATA_ARRAY, "", array);113 psFree (array);106 array->data[0] = psStringCopy(argv[2]); 107 status = psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "SKYCELL", PS_DATA_ARRAY, "", array); 108 psFree(array); 114 109 115 110 psTrace("pswarp", 1, "Done with pswarpArguments...\n"); 116 return (config);111 return config; 117 112 } 118 113 … … 204 199 psTrace("pswarp", 1, "Done with pswarpArguments...\n"); 205 200 206 // Dump configuration, now that's it's settled207 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG");208 if (dump_file) {209 const char *skyCamera = psMetadataLookupStr(NULL, config->arguments,210 "SKYCELL.CAMERA"); ///< Name of camera for skycell211 pmConfigCamerasCull(config, skyCamera);212 pmConfigRecipesCull(config, "PSWARP,PPSTATS,PSPHOT,MASKS");213 214 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PSWARP.INPUT"); // Input file215 pmConfigDump(config, input->fpa, dump_file);216 }217 218 201 return (config); 219 202 } -
branches/cnb_branches/cnb_branch_20090301/pswarp/src/pswarpLoop.c
r21468 r23352 76 76 bool status; 77 77 78 const char *skyCamera = psMetadataLookupStr(NULL, config->arguments, 79 "SKYCELL.CAMERA"); ///< Name of camera for skycell 80 pmConfigCamerasCull(config, skyCamera); 81 pmConfigRecipesCull(config, "PSWARP,PPSTATS,PSPHOT,MASKS,JPEG"); 82 83 78 84 // load the recipe 79 85 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSWARP_RECIPE); … … 81 87 psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSWARP_RECIPE); 82 88 return false; 89 } 90 91 if (!pswarpSetMaskBits(config)) { 92 psError(PS_ERR_IO, false, "failed to set mask bits"); 93 return NULL; 83 94 } 84 95 … … 339 350 } 340 351 352 pswarpVersionHeader(hdu->header); 353 341 354 if (!pmAstromWriteWCS(hdu->header, outFPA, outChip, WCS_NONLIN_TOL)) { 342 355 psError(PS_ERR_UNKNOWN, false, "Unable to generate WCS header."); … … 455 468 } 456 469 470 // Dump configuration 471 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 472 if (dump_file) { 473 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PSWARP.INPUT"); // Input file 474 pmConfigDump(config, input->fpa, dump_file); 475 } 476 457 477 return true; 458 478 } -
branches/cnb_branches/cnb_branch_20090301/pswarp/src/pswarpParseCamera.c
r21368 r23352 11 11 */ 12 12 13 # include "pswarp.h" 13 #include "pswarp.h" 14 15 // Define an input file 16 static pmFPAfile *defineInputFile(pmConfig *config,// Configuration 17 pmFPAfile *bind, // File to which to bind, or NULL 18 char *filerule, // Name of file rule 19 char *argname, // Argument name 20 pmFPAfileType fileType // Type of file 21 ) 22 { 23 bool status; 24 25 // look for the file on the RUN metadata 26 pmFPAfile *file = pmFPAfileDefineFromRun(&status, config, filerule); // File to return 27 if (!status) { 28 psError(PSWARP_ERR_CONFIG, false, "Failed to load file definition for %s", filerule); 29 return NULL; 30 } 31 if (!file) { 32 // look for the file on the argument list 33 if (bind) { 34 file = pmFPAfileBindFromArgs(&status, bind, config, filerule, argname); 35 } else { 36 file = pmFPAfileDefineFromArgs(&status, config, filerule, argname); 37 } 38 if (!status) { 39 psError(PSWARP_ERR_CONFIG, false, "Failed to load file definition for %s", filerule); 40 return false; 41 } 42 } 43 44 if (!file) { 45 return NULL; 46 } 47 48 if (file->type != fileType) { 49 psError(PSWARP_ERR_CONFIG, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType)); 50 return NULL; 51 } 52 53 return file; 54 } 55 56 57 14 58 15 59 bool pswarpParseCamera(pmConfig *config) 16 60 { 17 bool status; 18 bool mdok; ///< Status of MD lookup 19 pmFPAfile *skycell = NULL; 20 pmConfig *skyConfig = NULL; 61 psAssert(config, "Require configuration"); 21 62 22 // the input image(s) are required arguments; they define the camera 23 status = false; 24 pmFPAfile *input = pmFPAfileDefineFromArgs(&status, config, "PSWARP.INPUT", "INPUT"); 25 if (!input || !status) { 63 // The input image(s) is required: it defines the camera 64 pmFPAfile *input = defineInputFile(config, NULL, "PSWARP.INPUT", "INPUT", PM_FPA_FILE_IMAGE); 65 if (!input) { 26 66 psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.INPUT"); 27 67 return false; 28 68 } 29 69 30 // the input image(s) are required arguments; they define the camera 31 status = false; 32 pmFPAfile *astrom = pmFPAfileDefineFromArgs(&status, config, "PSWARP.ASTROM", "ASTROM"); 33 if (!status) { 34 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 35 return NULL; 36 } 37 if (astrom) { 38 psLogMsg ("pswarp", 3, "using supplied astrometry\n"); 39 } else { 40 psLogMsg ("pswarp", 3, "using header astrometry\n"); 70 pmFPAfile *astrom = defineInputFile(config, NULL, "PSWARP.ASTROM", "ASTROM", PM_FPA_FILE_CMF); 71 psLogMsg("pswarp", PS_LOG_INFO, "Astrometry source: %s", astrom ? "supplied" : "header"); 72 73 pmFPAfile *inMask = defineInputFile(config, input, "PSWARP.MASK", "MASK", PM_FPA_FILE_MASK); 74 if (!inMask) { 75 psLogMsg("pswarp", PS_LOG_INFO, "No mask supplied"); 41 76 } 42 77 43 // the mask is not required - but must conform to input camera 44 pmFPAfile *inMask = pmFPAfileBindFromArgs(&status, input, config, "PSWARP.MASK", "MASK"); 45 if (!status) { 46 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 47 return NULL; 48 } 49 if (!inMask) { 50 psLogMsg ("pswarp", 3, "no mask supplied\n"); 78 pmFPAfile *inVariance = defineInputFile(config, input, "PSWARP.VARIANCE", "VARIANCE", 79 PM_FPA_FILE_VARIANCE); 80 if (!inVariance) { 81 psLogMsg("pswarp", PS_LOG_INFO, "No variance supplied"); 51 82 } 52 83 53 // loading the mask here should have invoked pmConfigMaskReadHeader() 54 if (!pswarpSetMaskBits (config)) { 55 psError(PS_ERR_IO, false, "failed to set mask bits"); 56 return NULL; 57 } 58 59 pmFPAfile *inVariance = pmFPAfileBindFromArgs(&status, input, config, "PSWARP.VARIANCE", "VARIANCE"); 60 if (!status) { 61 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 62 return NULL; 63 } 64 if (!inVariance) { 65 psLogMsg ("pswarp", 3, "no variance supplied\n"); 66 } 67 68 // the input skycell is a required argument: it defines the output image 84 // The input skycell is a required argument: it defines the output image 69 85 // XXX we may need a different skycell structure here 70 status = pswarpDefineSkycell(&skycell, &skyConfig, config, "PSWARP.SKYCELL", "SKYCELL"); 86 pmFPAfile *skycell = NULL; 87 pmConfig *skyConfig = NULL; 88 bool status = pswarpDefineSkycell(&skycell, &skyConfig, config, "PSWARP.SKYCELL", "SKYCELL"); 71 89 if (!status) { 72 90 psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.SKYCELL"); … … 81 99 return false; 82 100 } 101 output->save = true; 102 83 103 pmFPAfile *outMask = pmFPAfileDefineSkycell(config, output->fpa, "PSWARP.OUTPUT.MASK"); 84 104 if (!outMask) { … … 86 106 return false; 87 107 } 88 89 output->save = true;90 108 outMask->save = true; 91 109 … … 108 126 } 109 127 128 bool mdok; // Status of MD lookup 110 129 if (psMetadataLookupBool(&mdok, config->arguments, "PSF")) { 111 130 // This file, PSPHOT.INPUT, is just used as a carrier; output files (eg, PSPHOT.RESID) are defined by … … 160 179 } 161 180 } 162 psFree (chips);181 psFree(chips); 163 182 } 164 183 -
branches/cnb_branches/cnb_branch_20090301/pswarp/src/pswarpVersion.c
r21323 r23352 18 18 #include <pslib.h> 19 19 #include <psmodules.h> 20 #include <psphot.h> 21 #include <ppStats.h> 20 22 #include "pswarp.h" 21 23 22 static const char *cvsTag = "$Name: not supported by cvs2svn $";///< CVS tag name23 24 24 25 psString pswarpVersion(void) 25 26 { 26 psString version = NULL; ///< Version, to return 27 psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION); 28 return version; 27 #ifndef PSWARP_VERSION 28 #error "PSWARP_VERSION is not set" 29 #endif 30 #ifndef PSWARP_BRANCH 31 #error "PSWARP_BRANCH is not set" 32 #endif 33 return psStringCopy(PSWARP_BRANCH "@" PSWARP_VERSION); 34 } 35 36 psString pswarpSource(void) 37 { 38 #ifndef PSWARP_SOURCE 39 #error "PSWARP_SOURCE is not set" 40 #endif 41 return psStringCopy(PSWARP_SOURCE); 29 42 } 30 43 31 44 psString pswarpVersionLong(void) 32 45 { 33 psString version = pswarpVersion(); ///< Version, to return 34 psString tag = psStringStripCVS(cvsTag, "Name"); ///< CVS tag 35 psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__); 36 psFree(tag); 46 psString version = pswarpVersion(); // Version, to return 47 psString source = pswarpSource(); // Source 48 49 psStringPrepend(&version, "pswarp "); 50 psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__); 51 psFree(source); 52 53 #ifdef __OPTIMIZE__ 54 psStringAppend(&version, " optimised"); 55 #else 56 psStringAppend(&version, " unoptimised"); 57 #endif 58 37 59 return version; 60 }; 61 62 63 bool pswarpVersionHeader(psMetadata *header) 64 { 65 PS_ASSERT_METADATA_NON_NULL(header, false); 66 67 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 68 psString timeString = psTimeToISO(time); // The time in an ISO string 69 psFree(time); 70 psString history = NULL; // History string 71 psStringAppend(&history, "pswarp at %s", timeString); 72 psFree(timeString); 73 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history); 74 psFree(history); 75 76 psLibVersionHeader(header); 77 psModulesVersionHeader(header); 78 psphotVersionHeader(header); 79 ppStatsVersionHeader(header); 80 81 psString version = pswarpVersion(); // Software version 82 psString source = pswarpSource(); // Software source 83 84 psStringPrepend(&version, "pswarp version: "); 85 psStringPrepend(&source, "pswarp source: "); 86 87 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version); 88 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source); 89 90 psFree(version); 91 psFree(source); 92 93 return true; 38 94 } 39 95 96 void pswarpVersionPrint(void) 97 { 98 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 99 psString timeString = psTimeToISO(time); // The time in an ISO string 100 psFree(time); 101 psLogMsg("pswarp", PS_LOG_INFO, "pswarp at %s", timeString); 102 psFree(timeString); 103 104 psString pslib = psLibVersionLong();// psLib version 105 psString psmodules = psModulesVersionLong(); // psModules version 106 psString psphot = psphotVersionLong(); // psphot version 107 psString ppStats = ppStatsVersionLong(); // ppStats version 108 psString pswarp = pswarpVersionLong(); // pswarp version 109 110 psLogMsg("pswarp", PS_LOG_INFO, "%s", pslib); 111 psLogMsg("pswarp", PS_LOG_INFO, "%s", psmodules); 112 psLogMsg("pswarp", PS_LOG_INFO, "%s", psphot); 113 psLogMsg("pswarp", PS_LOG_INFO, "%s", ppStats); 114 psLogMsg("pswarp", PS_LOG_INFO, "%s", pswarp); 115 116 psFree(pslib); 117 psFree(psmodules); 118 psFree(psphot); 119 psFree(ppStats); 120 psFree(pswarp); 121 122 return; 123 }
Note:
See TracChangeset
for help on using the changeset viewer.
